text stringlengths 4 6.14k |
|---|
/*
* This header borrowed from Cygnus GNUwin32 project
*
* Cygwin is free software. Red Hat, Inc. licenses Cygwin to you under the
* terms of the GNU General Public License as published by the Free Software
* Foundation; you can redistribute it and/or modify it under the terms of
* the GNU General Public License either version 3 of the license, or (at your
* option) any later version (GPLv3+), along with the additional permissions
* given below.
*
* Modified for use with functions to map syslog
* calls to EventLog calls on the windows platform
*
* much of this is not used, but here for the sake of
* error free compilation. EventLogs will most likely
* not behave as syslog does, but may be useful anyway.
* much of what syslog does can be emulated here, but
* that will have to be done later.
*/
#include "winsyslog.h"
#include <stdio.h>
#include <fcntl.h>
#include <process.h>
#include <stdlib.h>
#ifndef THREAD_SAFE
static char *loghdr; /* log file header string */
static HANDLE loghdl = NULL; /* handle of event source */
#endif
static CHAR * // return error message
getLastErrorText( // converts "Lasr Error" code into text
CHAR *pBuf, // message buffer
ULONG bufSize) // buffer size
{
DWORD retSize;
LPTSTR pTemp=NULL;
if (bufSize < 16) {
if (bufSize > 0) {
pBuf[0]='\0';
}
return(pBuf);
}
retSize=FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|
FORMAT_MESSAGE_FROM_SYSTEM|
FORMAT_MESSAGE_ARGUMENT_ARRAY,
NULL,
GetLastError(),
LANG_NEUTRAL,
(LPTSTR)&pTemp,
0,
NULL);
if (!retSize || pTemp == NULL) {
pBuf[0]='\0';
}
else {
pTemp[strlen(pTemp)-2]='\0'; //remove cr and newline character
sprintf(pBuf,"%0.*s (0x%x)",bufSize-16,pTemp,GetLastError());
LocalFree((HLOCAL)pTemp);
}
return(pBuf);
}
void closelog(void)
{
#ifndef RING_UWP
DeregisterEventSource(loghdl);
#endif
free(loghdr);
}
/* Emulator for GNU syslog() routine
* Accepts: priority
* format
* arglist
*/
// TODO: use a real EventIdentifier with a Message Text file ?
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa363679%28v=vs.85%29.aspx
void syslog(int level, const char* format, ...)
{
CONST CHAR *arr[1];
char tmp[1024];
va_list arglist;
va_start(arglist, format);
vsnprintf(tmp, 1024, format, arglist);
#ifndef RING_UWP
arr[0] = tmp;
BOOL err = ReportEvent(loghdl, (unsigned short) level, (unsigned short)level,
level, NULL, 1, 0, arr, NULL);
if (err == 0)
{
CHAR errText[1024];
puts(getLastErrorText(errText, 1024));
}
#endif
va_end(arglist);
}
/* Emulator for BSD openlog() routine
* Accepts: identity
* options
* facility
*/
void openlog(const char *ident, int logopt, int facility)
{
char tmp[1024];
if (loghdl) {
closelog();
}
#ifndef RING_UWP
loghdl = RegisterEventSource(NULL, ident);
#endif
sprintf(tmp, (logopt & WINLOG_PID) ? "%s[%d]" : "%s", ident, getpid());
loghdr = _strdup(tmp); /* save header for later */
}
|
/** Uncompress input files using pipes.
* Hook the standard file opening functions, open, fopen and fopen64.
* If the extension of the file being opened indicates the file is
* compressed (.gz, .bz2, .xz), open a pipe to a program that
* decompresses that file (gunzip, bunzip2 or xzdec) and return a
* handle to the open pipe.
* @author Shaun Jackman <sjackman@bcgsc.ca>
*/
#include "fopen_gen.h"
static const char* zcatExec(const char* path)
{
int strl = strlen(path);
return (!strcmp(path + strl - 3, ".ar")) ? "ar -p" :
(! strcmp(path + strl - 4, ".tar")) ? "tar -xOf" :
(! strcmp(path + strl - 6, ".tar.Z")) ? "tar -zxOf" :
(! strcmp(path + strl - 7, ".tar.gz"))? "tar -zxOf" :
(! strcmp(path + strl - 8, ".tar.bz2")) ? "tar -jxOf" :
(! strcmp(path + strl - 7, ".tar.xz")) ? "tar --use-compress-program=xzdec -xOf" :
(! strcmp(path + strl - 2, ".Z")) ? "gunzip -c" :
(! strcmp(path + strl - 3, ".gz")) ? "gunzip -c" :
(! strcmp(path + strl - 4, ".bz2")) ? "bunzip2 -c" :
(! strcmp(path + strl - 3, ".xz")) ? "xzdec -c" :
(! strcmp(path + strl - 4, ".zip")) ? "unzip -p" :
(! strcmp(path + strl - 4, ".bam")) ? "samtools view -h" :
(! strcmp(path + strl - 3, ".jf")) ? "jellyfish dump" :
(! strcmp(path + strl - 4, ".jfq")) ? "jellyfish qdump" :
(! strcmp(path + strl - 4, ".sra")) ? "fastq-dump -Z --split-spot" :
(! strcmp(path + strl - 4, ".url")) ? "wget -O- -i" : NULL;
}
/** Open a pipe to uncompress the specified file.
* Not thread safe.
* @return a file descriptor
*/
static int uncompress(const char *path)
{
const char *zcat = zcatExec(path);
assert(zcat != NULL);
int fd[2];
if (pipe(fd) == -1)
return -1;
int err = setCloexec(fd[0]);
assert(err == 0);
(void) err;
char arg0[16], arg1[16], arg2[16];
int n = sscanf(zcat, "%s %s %s", arg0, arg1, arg2);
assert(n == 2 || n == 3);
/* It would be more portable to use fork than vfork, but fork can
* fail with ENOMEM when the process calling fork is using a lot
* of memory. A workaround for this problem is to set
* sysctl vm.overcommit_memory=1
*/
#if HAVE_WORKING_VFORK
pid_t pid = vfork();
#else
pid_t pid = fork();
#endif
if (pid == -1)
return -1;
if (pid == 0) {
dup2(fd[1], STDOUT_FILENO);
close(fd[1]);
if (n == 2)
execlp(arg0, arg0, arg1, path, NULL);
else
execlp(arg0, arg0, arg1, arg2, path, NULL);
// Calling perror after vfork is not allowed, but we're about
// to exit and an error message would be really helpful.
perror(arg0);
_exit(EXIT_FAILURE);
} else {
close(fd[1]);
return fd[0];
}
}
/* Set the FD_CLOEXEC flag of the specified file descriptor. */
int setCloexec(int fd)
{
int flags = fcntl(fd, F_GETFD, 0);
if (flags == -1)
return -1;
flags |= FD_CLOEXEC;
return fcntl(fd, F_SETFD, flags);
}
/** Open a pipe to uncompress the specified file.
* @return a FILE pointer
*/
static FILE* funcompress(const char* path)
{
int fd = uncompress(path);
if (fd == -1) {
perror(path);
exit(EXIT_FAILURE);
}
return fdopen(fd, "r");
}
FILE* fopen_gen(const char *path, const char * mode){
// Check if the file exists
FILE* f = fopen(path, mode);
if (f == NULL) {
fprintf(stderr, "Error opening file: %s\n", path);
_exit(EXIT_FAILURE);
}
if (f && zcatExec(path) != NULL && (!strcmp(mode,"r"))){
fclose(f);
return funcompress(path);
} else{
return f;
}
}
|
/*
* fm-config.h
*
* Copyright 2009 PCMan <pcman.tw@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#ifndef __FM_CONFIG_H__
#define __FM_CONFIG_H__
#include <glib-object.h>
G_BEGIN_DECLS
#define FM_CONFIG_TYPE (fm_config_get_type())
#define FM_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
FM_CONFIG_TYPE, FmConfig))
#define FM_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),\
FM_CONFIG_TYPE, FmConfigClass))
#define FM_IS_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),\
FM_CONFIG_TYPE))
#define FM_IS_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),\
FM_CONFIG_TYPE))
typedef struct _FmConfig FmConfig;
typedef struct _FmConfigClass FmConfigClass;
#define FM_CONFIG_DEFAULT_SINGLE_CLICK FALSE
#define FM_CONFIG_DEFAULT_USE_TRASH TRUE
#define FM_CONFIG_DEFAULT_CONFIRM_DEL TRUE
#define FM_CONFIG_DEFAULT_NO_USB_TRASH FALSE
#define FM_CONFIG_DEFAULT_BIG_ICON_SIZE 48
#define FM_CONFIG_DEFAULT_SMALL_ICON_SIZE 16
#define FM_CONFIG_DEFAULT_PANE_ICON_SIZE 16
#define FM_CONFIG_DEFAULT_THUMBNAIL_SIZE 128
#define FM_CONFIG_DEFAULT_SHOW_THUMBNAIL TRUE
#define FM_CONFIG_DEFAULT_THUMBNAIL_LOCAL TRUE
#define FM_CONFIG_DEFAULT_THUMBNAIL_MAX 2048
#define FM_CONFIG_DEFAULT_FORCE_S_NOTIFY TRUE
#define FM_CONFIG_DEFAULT_BACKUP_HIDDEN TRUE
#define FM_CONFIG_DEFAULT_NO_EXPAND_EMPTY FALSE
/**
* FmConfig:
* @single_click: single click to open file
* @use_trash: delete file to trash can
* @confirm_del: ask before deleting files
* @big_icon_size: size of big icons
* @small_icon_size: size of small icons
* @pane_icon_size: size of side pane icons
* @thumbnail_size: size of thumbnail icons
* @show_thumbnail: show thumbnails
* @thumbnail_local: show thumbnails for local files only
* @thumbnail_max: show thumbnails for files smaller than 'thumb_max' KB
* @show_internal_volumes: show system internal volumes in side pane. (udisks-only)
* @terminal: command line to launch terminal emulator
* @si_unit: use SI prefix for file sizes
* @archiver: desktop_id of the archiver used
* @advanced_mode: enable advanced features for experienced user
*/
struct _FmConfig
{
/*< private >*/
GObject parent;
/*< public >*/
gboolean single_click;
gboolean use_trash;
gboolean confirm_del;
gint big_icon_size;
gint small_icon_size;
gint pane_icon_size;
gint thumbnail_size;
gboolean show_thumbnail;
gboolean thumbnail_local;
gint thumbnail_max;
gboolean show_internal_volumes;
char* terminal;
gboolean si_unit;
char* archiver;
gboolean advanced_mode;
/*< private >*/
union {
gpointer _reserved1; /* reserved space for updates until next ABI */
gboolean force_startup_notify; /* use startup notify by default */
};
union {
gpointer _reserved2;
gboolean backup_as_hidden; /* treat backup files as hidden */
};
union {
gpointer _reserved3;
gboolean no_usb_trash; /* don't create trash folder on removable media */
};
union {
gpointer _reserved4;
gboolean no_child_non_expandable; /* hide expanders on empty folder */
};
};
/**
* FmConfigClass
* @parent_class: the parent class
* @changed: the class closure for the #FmConfig::changed signal
*/
struct _FmConfigClass
{
GObjectClass parent_class;
void (*changed)(FmConfig* cfg);
};
/* global config object */
extern FmConfig* fm_config;
GType fm_config_get_type (void);
FmConfig* fm_config_new (void);
void fm_config_load_from_file(FmConfig* cfg, const char* name);
void fm_config_load_from_key_file(FmConfig* cfg, GKeyFile* kf);
void fm_config_save(FmConfig* cfg, const char* name);
void fm_config_emit_changed(FmConfig* cfg, const char* changed_key);
G_END_DECLS
#endif /* __FM_CONFIG_H__ */
|
/****************************************************************************
* Open RPG Maker 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. *
* *
* Open RPG Maker 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 Open RPG Maker. If not, see <http://www.gnu.org/licenses/>. *
* *
* --- *
* Copyright (C) 2010, Justin Davis <tuxdavis@gmail.com> *
****************************************************************************/
#ifndef CONFIGURESYSTEMGRAPHICS_H
#define CONFIGURESYSTEMGRAPHICS_H
#include "ui_configuresystemgraphics.h"
class ConfigureSystemGraphics : public QDialog, public Ui::ConfigureSystemGraphics
{
Q_OBJECT
public:
ConfigureSystemGraphics(QWidget *parent=0);
~ConfigureSystemGraphics();
protected slots:
void on_bSetFrameBG_clicked();
void on_bSetFrameBorder_clicked();
void on_bSetSelectionBorder_clicked();
void on_bSetEquipmentIndicators_clicked();
void on_bSetMenuBG_clicked();
void on_bSetScrollArrows_clicked();
void on_bSetGrappleArm_clicked();
void on_bSetGrappleHook_clicked();
void on_bSetTimerNumbers_clicked();
void on_bDefaultEnabledTopColor_colorChanged(QColor color);
void on_bDefaultEnabledBottomColor_colorChanged(QColor color);
void on_bDefaultDisabledTopColor_colorChanged(QColor color);
void on_bDefaultDisabledBottomColor_colorChanged(QColor color);
void on_buttonBox_accepted();
private:
QImage createGradientImage(QColor top, QColor bottom, int width, int height);
QString frameBGLocation;
QString frameBorderLocation;
QString selectionBorderLocation;
QString equipmentIndicatorsLocation;
QString menuBGLocation;
QString scrollArrowsLocation;
QString grappleArmLocation;
QString grappleHookLocation;
QString timerNumbersLocation;
};
#endif // CONFIGURESYSTEMGRAPHICS_H
|
/*********************************************************************
* Filename: sha1.c
* Author: Brad Conte (brad AT bradconte.com)
* Copyright:
* Disclaimer: This code is presented "as is" without any guarantees.
* Details: Implementation of the SHA1 hashing algorithm.
Algorithm specification can be found here:
* http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf
This implementation uses little endian byte order.
*********************************************************************/
/*************************** HEADER FILES ***************************/
#include <stdlib.h>
#include <memory.h>
#include "sha1.h"
/****************************** MACROS ******************************/
#define ROTLEFT(a, b) ((a << b) | (a >> (32 - b)))
/*********************** FUNCTION DEFINITIONS ***********************/
static void sha1_transform(SHA1_CTX *ctx, const BYTE data[])
{
WORD a, b, c, d, e, i, j, t, m[80];
for (i = 0, j = 0; i < 16; ++i, j += 4)
m[i] = (data[j] << 24) + (data[j + 1] << 16) + (data[j + 2] << 8) + (data[j + 3]);
for ( ; i < 80; ++i) {
m[i] = (m[i - 3] ^ m[i - 8] ^ m[i - 14] ^ m[i - 16]);
m[i] = (m[i] << 1) | (m[i] >> 31);
}
a = ctx->state[0];
b = ctx->state[1];
c = ctx->state[2];
d = ctx->state[3];
e = ctx->state[4];
for (i = 0; i < 20; ++i) {
t = ROTLEFT(a, 5) + ((b & c) ^ (~b & d)) + e + ctx->k[0] + m[i];
e = d;
d = c;
c = ROTLEFT(b, 30);
b = a;
a = t;
}
for ( ; i < 40; ++i) {
t = ROTLEFT(a, 5) + (b ^ c ^ d) + e + ctx->k[1] + m[i];
e = d;
d = c;
c = ROTLEFT(b, 30);
b = a;
a = t;
}
for ( ; i < 60; ++i) {
t = ROTLEFT(a, 5) + ((b & c) ^ (b & d) ^ (c & d)) + e + ctx->k[2] + m[i];
e = d;
d = c;
c = ROTLEFT(b, 30);
b = a;
a = t;
}
for ( ; i < 80; ++i) {
t = ROTLEFT(a, 5) + (b ^ c ^ d) + e + ctx->k[3] + m[i];
e = d;
d = c;
c = ROTLEFT(b, 30);
b = a;
a = t;
}
ctx->state[0] += a;
ctx->state[1] += b;
ctx->state[2] += c;
ctx->state[3] += d;
ctx->state[4] += e;
}
void sha1_init(SHA1_CTX *ctx)
{
ctx->datalen = 0;
ctx->bitlen = 0;
ctx->state[0] = 0x67452301;
ctx->state[1] = 0xEFCDAB89;
ctx->state[2] = 0x98BADCFE;
ctx->state[3] = 0x10325476;
ctx->state[4] = 0xc3d2e1f0;
ctx->k[0] = 0x5a827999;
ctx->k[1] = 0x6ed9eba1;
ctx->k[2] = 0x8f1bbcdc;
ctx->k[3] = 0xca62c1d6;
}
void sha1_update(SHA1_CTX *ctx, const BYTE data[], size_t len)
{
size_t i;
for (i = 0; i < len; ++i) {
ctx->data[ctx->datalen] = data[i];
ctx->datalen++;
if (ctx->datalen == 64) {
sha1_transform(ctx, ctx->data);
ctx->bitlen += 512;
ctx->datalen = 0;
}
}
}
void sha1_final(SHA1_CTX *ctx, BYTE hash[])
{
WORD i;
i = ctx->datalen;
// Pad whatever data is left in the buffer.
if (ctx->datalen < 56) {
ctx->data[i++] = 0x80;
while (i < 56)
ctx->data[i++] = 0x00;
}
else {
ctx->data[i++] = 0x80;
while (i < 64)
ctx->data[i++] = 0x00;
sha1_transform(ctx, ctx->data);
memset(ctx->data, 0, 56);
}
// Append to the padding the total message's length in bits and transform.
ctx->bitlen += ctx->datalen * 8;
ctx->data[63] = ctx->bitlen;
ctx->data[62] = ctx->bitlen >> 8;
ctx->data[61] = ctx->bitlen >> 16;
ctx->data[60] = ctx->bitlen >> 24;
ctx->data[59] = ctx->bitlen >> 32;
ctx->data[58] = ctx->bitlen >> 40;
ctx->data[57] = ctx->bitlen >> 48;
ctx->data[56] = ctx->bitlen >> 56;
sha1_transform(ctx, ctx->data);
// Since this implementation uses little endian byte ordering and MD uses big endian,
// reverse all the bytes when copying the final state to the output hash.
for (i = 0; i < 4; ++i) {
hash[i] = (ctx->state[0] >> (24 - i * 8)) & 0x000000ff;
hash[i + 4] = (ctx->state[1] >> (24 - i * 8)) & 0x000000ff;
hash[i + 8] = (ctx->state[2] >> (24 - i * 8)) & 0x000000ff;
hash[i + 12] = (ctx->state[3] >> (24 - i * 8)) & 0x000000ff;
hash[i + 16] = (ctx->state[4] >> (24 - i * 8)) & 0x000000ff;
}
}
|
/**
** Vixen Engine
** Copyright(c) 2015 Matt Guerrette
**
** GNU Lesser General Public License
** This file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.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
**
**/
#ifndef VIX_GLSHADER_H
#define VIX_GLSHADER_H
#include <vix_platform.h>
#include <vix_shader.h>
#include <vix_stringutil.h>
#include <vix_gl.h>
namespace Vixen {
class VIX_API GLShader : public IShader
{
public:
GLShader(const ShaderInfo& info);
~GLShader();
bool VInitFromFile(File* file);
GLuint ShaderHandle() const;
protected:
void VBind() = 0;
void VUnbind() = 0;
private:
bool LoadShader(const GLchar* source);
static const GLchar* ReadShader(const UString& path);
static GLenum GLShaderType(ShaderType type);
static bool ValidateCompile(GLuint shader);
private:
GLuint m_shader;
ShaderInfo m_info;
};
}
#endif
|
// Copyright (c) 2012 Geometry Factory. All rights reserved.
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// 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.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
// Author(s) : Andreas Fabri, Fernando Cacciola
//
#ifndef CGAL_POLYLINE_SIMPLIFICATION_2_SQUARED_DISTANCE_COST_H
#define CGAL_POLYLINE_SIMPLIFICATION_2_SQUARED_DISTANCE_COST_H
#include <CGAL/license/Polyline_simplification_2.h>
#include <CGAL/algorithm.h>
#include <CGAL/Constrained_triangulation_plus_2.h>
namespace CGAL {
#ifndef DOXYGEN_RUNNING
template < class Tr >
class Constrained_triangulation_plus_2;
#endif
namespace Polyline_simplification_2
{
/// \ingroup PkgPolylineSimplification2Classes
/// This class is a cost function which calculates the cost as the square of the distance between the original and simplified polylines.
///
/// \cgalModels `PolylineSimplificationCostFunction`.
class Squared_distance_cost
{
public:
/// Initializes the cost function
Squared_distance_cost() {}
/// Given a vertex in constraint iterator `vicq` computes `vicp=std::prev(vicq)` and `vicr=std::next(vicq)`,
/// returns the maximum of the square distances between each point along the original subpolyline,
/// between `vicp` and `vicr`, and the straight line segment from `*vicp->point() to *vicr->point()`.
/// \tparam CDT must be `CGAL::Constrained_Delaunay_triangulation_2` with a vertex type that
/// is model of `PolylineSimplificationVertexBase_2`.
template<class CDT>
boost::optional<typename CDT::Geom_traits::FT>
operator()(const Constrained_triangulation_plus_2<CDT>& pct
, typename Constrained_triangulation_plus_2<CDT>::Vertices_in_constraint_iterator vicq)const
{
typedef typename Constrained_triangulation_plus_2<CDT>::Points_in_constraint_iterator Points_in_constraint_iterator;
typedef typename Constrained_triangulation_plus_2<CDT>::Geom_traits Geom_traits ;
typedef typename Geom_traits::FT FT;
typedef typename Geom_traits::Compute_squared_distance_2 Compute_squared_distance ;
typedef typename Geom_traits::Construct_segment_2 Construct_segment ;
typedef typename Geom_traits::Segment_2 Segment ;
typedef typename Geom_traits::Point_2 Point ;
Compute_squared_distance compute_squared_distance = pct.geom_traits().compute_squared_distance_2_object() ;
Construct_segment construct_segment = pct.geom_traits().construct_segment_2_object() ;
typedef typename Constrained_triangulation_plus_2<CDT>::Vertices_in_constraint_iterator Vertices_in_constraint_iterator;
Vertices_in_constraint_iterator vicp = boost::prior(vicq);
Vertices_in_constraint_iterator vicr = boost::next(vicq);
Point const& lP = (*vicp)->point();
Point const& lR = (*vicr)->point();
Segment lP_R = construct_segment(lP, lR) ;
FT d1 = 0.0;
Points_in_constraint_iterator pp(vicp), rr(vicr);
++pp;
for ( ;pp != rr; ++pp )
d1 = (std::max)(d1, compute_squared_distance( lP_R, *pp ) ) ;
return d1 ;
}
};
} // namespace Polyline_simplification_2
} //namespace CGAL
#endif // CGAL_POLYLINE_SIMPLIFICATION_2_SQUARED_DISTANCE_COST_H
|
/*********************************************************************
TEMPLATE - A minimal set of files and functions to define a program.
TEMPLATE is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Your Name <your@email>
Contributing author(s):
Copyright (C) YYYY, Free Software Foundation, Inc.
Gnuastro 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.
Gnuastro 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 Gnuastro. If not, see <http://www.gnu.org/licenses/>.
**********************************************************************/
#ifndef ARGS_H
#define ARGS_H
/* Array of acceptable options. */
struct argp_option program_options[] =
{
{
"multivalue",
UI_KEY_MULTIVALUE,
"STR",
0,
"This option can take multiple values.",
GAL_OPTIONS_GROUP_INPUT,
&p->multivalue,
GAL_TYPE_STRLL,
GAL_OPTIONS_RANGE_ANY,
GAL_OPTIONS_NOT_MANDATORY,
GAL_OPTIONS_NOT_SET
},
{
"onoff",
UI_KEY_ONOFF,
0,
0,
"This option takes no value,.",
GAL_OPTIONS_GROUP_OPERATING_MODE,
&p->onoff,
GAL_OPTIONS_NO_ARG_TYPE,
GAL_OPTIONS_RANGE_0_OR_1,
GAL_OPTIONS_NOT_MANDATORY,
GAL_OPTIONS_NOT_SET
},
{0}
};
/* Define the child argp structure
-------------------------------
NOTE: these parts can be left untouched.*/
struct argp
gal_options_common_child = {gal_commonopts_options,
gal_options_common_argp_parse,
NULL, NULL, NULL, NULL, NULL};
/* Use the child argp structure in list of children (only one for now). */
struct argp_child
children[]=
{
{&gal_options_common_child, 0, NULL, 0},
{0, 0, 0, 0}
};
/* Set all the necessary argp parameters. */
struct argp
thisargp = {program_options, parse_opt, args_doc, doc, children, NULL, NULL};
#endif
|
/* Copyright (C) 2013 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include "common/errcode.h"
#include "libknot/packet/compr.h"
#include "libknot/packet/pkt.h"
#include "common/debug.h"
#include "libknot/util/tolower.h"
/*! \brief Case insensitive label compare for compression. */
static bool compr_label_match(const uint8_t *n, const uint8_t *p)
{
assert(n);
assert(p);
if (*n != *p) {
return false;
}
uint8_t len = *n;
for (uint8_t i = 0; i < len; ++i) {
if (knot_tolower(n[1 + i]) != knot_tolower(p[1 + i])) {
return false;
}
}
return true;
}
/*! \brief Helper for \fn knot_pkt_put_dname, writes label(s) with size checks. */
#define WRITE_LABEL(dst, written, label, max, len) \
if ((written) + (len) > (max)) { \
return KNOT_ESPACE; \
} else { \
memcpy((dst) + (written), (label), (len)); \
written += (len); \
}
int knot_compr_put_dname(const knot_dname_t *dname, uint8_t *dst, uint16_t max,
knot_compr_t *compr)
{
/* Write uncompressible names directly. */
dbg_packet("%s(%p,%p,%u,%p)\n", __func__, dname, dst, max, compr);
if (dname == NULL || dst == NULL) {
return KNOT_EINVAL;
}
if (compr == NULL || *dname == '\0') {
dbg_packet("%s: uncompressible, writing full name\n", __func__);
return knot_dname_to_wire(dst, dname, max);
}
int name_labels = knot_dname_labels(dname, NULL);
if (name_labels < 0) {
return name_labels;
}
/* Suffix must not be longer than whole name. */
const knot_dname_t *suffix = compr->wire + compr->suffix.pos;
int suffix_labels = compr->suffix.labels;
while (suffix_labels > name_labels) {
suffix = knot_wire_next_label(suffix, compr->wire);
--suffix_labels;
}
/* Suffix is shorter than name, write labels until aligned. */
uint8_t orig_labels = name_labels;
uint16_t written = 0;
while (name_labels > suffix_labels) {
WRITE_LABEL(dst, written, dname, max, (*dname + 1));
dname = knot_wire_next_label(dname, NULL);
--name_labels;
}
/* Label count is now equal. */
assert(name_labels == suffix_labels);
const knot_dname_t *match_begin = dname;
const knot_dname_t *compr_ptr = suffix;
while (dname[0] != '\0') {
/* Next labels. */
const knot_dname_t *next_dname = knot_wire_next_label(dname, NULL);
const knot_dname_t *next_suffix = knot_wire_next_label(suffix, compr->wire);
/* Two labels match, extend suffix length. */
if (dname[0] != suffix[0] || !compr_label_match(dname, suffix)) {
/* If they don't match, write unmatched labels. */
uint16_t mismatch_len = (dname - match_begin) + (*dname + 1);
WRITE_LABEL(dst, written, match_begin, max, mismatch_len);
/* Start new potential match. */
match_begin = next_dname;
compr_ptr = next_suffix;
}
/* Jump to next labels. */
dname = next_dname;
suffix = next_suffix;
}
/* If match begins at the end of the name, write '\0' label. */
if (match_begin == dname) {
WRITE_LABEL(dst, written, dname, max, 1);
} else {
/* Match covers >0 labels, write out compression pointer. */
if (written + sizeof(uint16_t) > max) {
return KNOT_ESPACE;
}
knot_wire_put_pointer(dst + written, compr_ptr - compr->wire);
written += sizeof(uint16_t);
}
/* Heuristics - expect similar names are grouped together. */
if (written > sizeof(uint16_t) && compr->wire_pos + written < KNOT_WIRE_PTR_MAX) {
compr->suffix.pos = compr->wire_pos;
compr->suffix.labels = orig_labels;
}
dbg_packet("%s: compressed to %u bytes (match=%zu,@%zu)\n",
__func__, written, dname - match_begin, compr->wire_pos);
return written;
}
#undef WRITE_LABEL
|
/*
World of Gnome is a 2D multiplayer role playing game.
Copyright (C) 2013-2020 carabobz@gmail.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 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
*/
#include "Connection.h"
#include <string>
class Context;
class FileReceivedObserver;
void file_add_observer(FileReceivedObserver * observer);
int file_add(const std::string & name, const std::string & data);
void file_clean(Context *);
void file_request_from_network(Connection & connection, const std::string & table, const std::string & filename);
int file_create_directory(const std::string & file_path);
|
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "S1AP-IEs"
* found in "../support/s1ap-r16.1.0/36413-g10.asn"
* `asn1c -pdu=all -fcompound-names -findirect-choice -fno-include-deps`
*/
#ifndef _S1AP_NRencryptionAlgorithms_H_
#define _S1AP_NRencryptionAlgorithms_H_
#include <asn_application.h>
/* Including external dependencies */
#include <BIT_STRING.h>
#ifdef __cplusplus
extern "C" {
#endif
/* S1AP_NRencryptionAlgorithms */
typedef BIT_STRING_t S1AP_NRencryptionAlgorithms_t;
/* Implementation */
extern asn_per_constraints_t asn_PER_type_S1AP_NRencryptionAlgorithms_constr_1;
extern asn_TYPE_descriptor_t asn_DEF_S1AP_NRencryptionAlgorithms;
asn_struct_free_f S1AP_NRencryptionAlgorithms_free;
asn_struct_print_f S1AP_NRencryptionAlgorithms_print;
asn_constr_check_f S1AP_NRencryptionAlgorithms_constraint;
ber_type_decoder_f S1AP_NRencryptionAlgorithms_decode_ber;
der_type_encoder_f S1AP_NRencryptionAlgorithms_encode_der;
xer_type_decoder_f S1AP_NRencryptionAlgorithms_decode_xer;
xer_type_encoder_f S1AP_NRencryptionAlgorithms_encode_xer;
oer_type_decoder_f S1AP_NRencryptionAlgorithms_decode_oer;
oer_type_encoder_f S1AP_NRencryptionAlgorithms_encode_oer;
per_type_decoder_f S1AP_NRencryptionAlgorithms_decode_uper;
per_type_encoder_f S1AP_NRencryptionAlgorithms_encode_uper;
per_type_decoder_f S1AP_NRencryptionAlgorithms_decode_aper;
per_type_encoder_f S1AP_NRencryptionAlgorithms_encode_aper;
#ifdef __cplusplus
}
#endif
#endif /* _S1AP_NRencryptionAlgorithms_H_ */
#include <asn_internal.h>
|
/*
* Copyright (C) 2011 Alexandre Quessy
*
* This file is part of Tempi.
*
* Tempi 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.
*
* Tempi 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 Tempi. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* The MetroNode class.
*/
#ifndef __TEMPI_METRONODE_H__
#define __TEMPI_METRONODE_H__
#include "tempi/timer.h"
#include "tempi/timeposition.h"
#include "tempi/node.h"
namespace tempi { namespace base {
/**
* A MetroNode is a Node that ticks every interval ms.
*/
class MetroNode : public Node
{
public:
MetroNode();
protected:
virtual void processMessage(unsigned int inlet, const Message &message) {}
virtual void onPropertyChanged(const char *name, const Message &value);
private:
Timer timer_;
TimePosition interval_;
virtual void doTick();
void startMetro();
};
} // end of namespace
} // end of namespace
#endif // ifndef
|
// MurderEditor.h: interface for the MurderEditor class.
//
//////////////////////////////////////////////////////////////////////
#pragma once
#include "plugin-bindings/aeffguieditor.h"
class MurderEditor : public AEffGUIEditor, public IControlListener
{
public:
MurderEditor(AudioEffect* effect);
virtual ~MurderEditor();
protected:
virtual bool open(void* ptr) override;
virtual void close() override;
virtual void setParameter(VstInt32 index, float value) override;
private:
virtual void valueChanged(CControl* control) override;
CPoint *points;
COnOffButton **buttons;
CSplashScreen *splash;
};
|
/* This file is a part of GlkJNI.
* Copyright (c) 2009 Edward McCardell
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <jni.h>
#include "glk.h"
#include "glkjni.h"
#include "jcall.h"
typedef struct glk_schannel_struct schannel_t;
struct glk_schannel_struct {
glui32 rock;
jobject jchan;
schannel_t *next, *prev;
gidispatch_rock_t disprock;
};
/* Linked list of all sound channels. */
static schannel_t *gli_schanlist = NULL;
void sound_c_shutdown(void)
{
schannel_t *curr, *next;
curr = gli_schanlist;
while (curr) {
next = curr->next;
if (curr->jchan) {
DELETE_GLOBAL(curr->jchan);
}
free(curr);
curr = next;
}
gli_schanlist = NULL;
}
/* Returns the dispatch rock for SCHAN. */
gidispatch_rock_t gli_schan_get_disprock(schannel_t *schan)
{
return schan->disprock;
}
/* Registers SCHAN with the dispatch layer. */
void gli_schan_set_disprock(schannel_t *schan)
{
if (gli_register_obj) {
schan->disprock = (*gli_register_obj)(schan, gidisp_Class_Schannel);
} else {
schan->disprock.ptr = NULL;
}
}
schanid_t glk_schannel_iterate(schannel_t *chan, glui32 *rock)
{
if (!chan) {
chan = gli_schanlist;
} else {
chan = chan->next;
}
if (chan) {
if (rock) {
*rock = chan->rock;
}
return chan;
} else {
if (rock) {
*rock = 0;
}
return NULL;
}
}
schanid_t glk_schannel_create(glui32 rock)
{
jobject jchan;
schannel_t *schan;
jchan = (*jni_env)->CallObjectMethod(GLK_M(CREATECHAN));
if (jni_check_exc() || !jchan) {
return NULL;
}
jchan = jni_new_global(jchan);
schan = (schannel_t *)gli_malloc(sizeof(schannel_t));
schan->rock = rock;
schan->jchan = jchan;
gli_schan_set_disprock(schan);
schan->prev = NULL;
schan->next = gli_schanlist;
gli_schanlist = schan;
if (schan->next) {
schan->next->prev = schan;
}
return schan;
}
void glk_schannel_destroy(schannel_t *schan)
{
schannel_t *prev, *next;
if (!schan) {
gli_strict_warning("schannel_destroy: invalid id.");
return;
}
prev = schan->prev;
next = schan->next;
schan->prev = NULL;
schan->next = NULL;
if (prev) {
prev->next = next;
} else {
gli_schanlist = next;
}
if (next) {
next->prev = prev;
}
if (gli_unregister_obj) {
(*gli_unregister_obj)(schan, gidisp_Class_Schannel, schan->disprock);
}
(*jni_env)->CallVoidMethod(GLK_M(CHANNELDESTROY), schan->jchan);
jni_check_exc();
DELETE_GLOBAL(schan->jchan);
free(schan);
}
glui32 glk_schannel_get_rock(schannel_t *chan)
{
if (!chan) {
gli_strict_warning("schannel_get_rock: invalid id.");
return 0;
}
return chan->rock;
}
glui32 glk_schannel_play(schannel_t *chan, glui32 snd)
{
return glk_schannel_play_ext(chan, snd, 1, 0);
}
glui32 glk_schannel_play_ext(schannel_t *chan, glui32 snd, glui32 repeats,
glui32 notify)
{
jboolean res;
jobject jres;
if (!chan) {
gli_strict_warning("schannel_play: invalid id.");
return FALSE;
}
if ((jint)snd < 0) {
gli_strict_warning("schannel_play: resource num too large");
return FALSE;
}
jres = glkjni_get_blorb_resource(giblorb_ID_Snd, snd);
if (!jres) {
return FALSE;
}
if ((jint)repeats < 0) {
if ((jint)repeats != -1) {
gli_strict_warning("schannel_play: repeat count too large");
return FALSE;
}
} else if ((jint)repeats == 0) {
glk_schannel_stop(chan);
return TRUE;
}
res = (*jni_env)->CallBooleanMethod(
INSTANCE_M(chan->jchan, GLKCHANNEL_PLAY),
jres, (jint)repeats, (jint)notify);
if (jni_check_exc()) {
res = FALSE;
}
DELETE_LOCAL(jres);
return res;
}
void glk_schannel_stop(schannel_t *chan)
{
if (!chan) {
gli_strict_warning("schannel_stop: invalid id.");
return;
}
(*jni_env)->CallVoidMethod(
INSTANCE_M(chan->jchan, GLKCHANNEL_STOP));
jni_check_exc();
}
void glk_schannel_set_volume(schannel_t *chan, glui32 vol)
{
if (!chan) {
gli_strict_warning("schannel_set_volume: invalid id.");
return;
}
if ((jint)vol < 0 || (jint)vol > 0x10000) {
gli_strict_warning("schannel_set_volume: volume too loud");
return;
}
(*jni_env)->CallVoidMethod(
INSTANCE_M(chan->jchan, GLKCHANNEL_VOLUME),
(jint)vol);
jni_check_exc();
}
void glk_sound_load_hint(glui32 snd, glui32 flag)
{
jboolean jflag = (flag ? JNI_TRUE : JNI_FALSE);
jobject jres;
if ((jint)snd < 0) {
gli_strict_warning("sound_load_hint: resource num too large");
return;
}
jres = glkjni_get_blorb_resource(giblorb_ID_Snd, snd);
if (!jres) {
return;
}
(*jni_env)->CallVoidMethod(GLK_M(SOUNDHINT), jres, jflag);
DELETE_LOCAL(jres);
jni_check_exc();
}
|
//
// Libtask: A thread-safe coroutine library.
//
// Copyright (C) 2013 BVK Chaitanya
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#include <argp.h>
#include "libtask/libtask.h"
#include "libtask/log.h"
#define NTHREADS 10
#define NYIELD 10000
#define TASK_STACK_SIZE (16 * 1024)
static int32_t num_task_pools = 2;
static int32_t num_tasks = 1000;
static int32_t num_threads = 2;
static int32_t num_yields = 100;
static int32_t num_switches = 100;
static struct argp_option options[] = {
{"num-task-pools", 0, "PINT32", 0, "No. of task-pools to create."},
{"num-tasks", 1, "PINT32", 0, "No. of tasks to per task-pool."},
{"num-threads", 2, "PINT32", 0, "No. of threads with each task-pool."},
{"num-yields", 3, "UINT32", 0, "No. of yields to perform by the task."},
{"num-switches", 4, "UINT32", 0, "No. of task-pool switches to perform."},
{0}
};
int
work(void *arg_)
{
libtask_task_pool_t *task_pools = (libtask_task_pool_t *)arg_;
int nyields = 0;
int nswitches = 0;
while (nyields < num_yields || nswitches < num_switches) {
switch (random() % 2) {
case 0: // yield
nyields++;
libtask_yield();
break;
case 1: // switch
nswitches++;
libtask_task_pool_schedule(&task_pools[random() % num_task_pools]);
break;
}
}
return 0;
}
static error_t
parse_options(int key, char *arg, struct argp_state *state)
{
switch (key) {
case 0: // num-task-pools
if (!str2pint32(arg, 10, &num_task_pools)) {
argp_error(state, "Invalid value %s for --%s\n", arg, options[key].name);
}
break;
case 1: // num-tasks
if (!str2pint32(arg, 10, &num_tasks)) {
argp_error(state, "Invalid value %s for --%s\n", arg, options[key].name);
}
break;
case 2: // num-threads
if (!str2pint32(arg, 10, &num_threads)) {
argp_error(state, "Invalid value %s for --%s\n", arg, options[key].name);
}
break;
case 3: // num-yields
if (!str2uint32(arg, 10, &num_yields)) {
argp_error(state, "Invalid value %s for --%s\n", arg, options[key].name);
}
break;
case 4: // num-switches
if (!str2uint32(arg, 10, &num_switches)) {
argp_error(state, "Invalid value %s for --%s\n", arg, options[key].name);
}
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
int
main(int argc, char *argv[])
{
struct argp_child children[2];
children[0] = libtask_argp_child;
children[1] = (struct argp_child){0};
struct argp argp = { options, parse_options, 0, 0, children };
argp_parse(&argp, argc, argv, 0, 0, 0);
// Create task pools.
libtask_task_pool_t *task_pools =
malloc(sizeof (libtask_task_pool_t) * num_task_pools);
CHECK(task_pools);
for (int i = 0; i < num_task_pools; i++) {
CHECK(libtask_task_pool_initialize(&task_pools[i]) == 0);
}
// Create tasks in each task pool.
libtask_task_t *tasks =
malloc(sizeof (libtask_task_t) * num_task_pools * num_tasks);
CHECK(tasks);
for (int i = 0; i < num_tasks * num_task_pools; i++) {
libtask_task_pool_t *task_pool = &task_pools[i % num_task_pools];
CHECK(libtask_task_initialize(&tasks[i], task_pool, work, task_pools,
TASK_STACK_SIZE) == 0);
}
// Create threads for each task-pool.
pthread_t *threads =
malloc(sizeof (pthread_t) * num_task_pools * num_threads);
CHECK(threads);
for (int i = 0; i < num_threads * num_task_pools; i++) {
libtask_task_pool_t *task_pool = &task_pools[i % num_task_pools];
CHECK(libtask_task_pool_start(task_pool, &threads[i]) == 0);
}
// Wait for all tasks to finish.
for (int i = 0; i < num_tasks * num_task_pools; i++) {
CHECK(libtask_task_wait(&tasks[i]) == 0);
}
// Stop and kill all threads.
for (int i = 0; i < num_threads * num_task_pools; i++) {
libtask_task_pool_t *task_pool = &task_pools[i % num_task_pools];
CHECK(libtask_task_pool_stop(task_pool, threads[i]) == 0);
CHECK(pthread_join(threads[i], NULL) == 0);
}
// Kill all tasks.
for (int i = 0; i < num_tasks * num_task_pools; i++) {
CHECK(libtask_task_unref(&tasks[i]) == 0);
}
// Kill all task-pools.
for (int i = 0; i < num_task_pools; i++) {
CHECK(libtask_task_pool_unref(&task_pools[i]) == 0);
}
free(threads);
free(tasks);
free(task_pools);
return 0;
}
|
/*
Copyright (c) 2015 Alberto Otero de la Roza <aoterodelaroza@gmail.com>,
Ángel Martín Pendás <angel@fluor.quimica.uniovi.es> and Víctor Luaña
<victor@fluor.quimica.uniovi.es>.
critic2 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.
critic2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <libqhull.h>
void doqhull(char *file1, char *file2, char *file3, int *ithr){
// open the file with the star points
FILE *fin;
fin = fopen(file1,"r");
// open the file with the vertices
FILE *fout;
fout = fopen(file2,"w");
// initialize the options
int nopts = 5;
char *opts[] = {"qhull","v","Qbb","QV0","p"};
qh_init_A(fin, fout, stderr, nopts, opts);
qh_initflags(qh qhull_command);
// initialize the point array using the scratch file
int dim, numpoints;
boolT ismalloc;
coordT *points;
points = qh_readpoints(&numpoints, &dim, &ismalloc);
qh_init_B(points, numpoints, dim, ismalloc);
qh_qhull();
qh_check_output();
qh_produce_output();
qh_freeqhull(True);
fclose(fin);
fclose(fout);
// open the file with the vertices
fin = fopen(file2,"r");
// open the file with the vertices
fout = fopen(file3,"w");
// initialize the options
// the OFF format orients the facets so I don't have to do it myself
nopts = 4;
char stra[10];
sprintf(stra,"C-1e-%d",*ithr);
char *opts2[] = {"qhull","Qs","o",stra};
qh_init_A(fin, fout, stderr, nopts, opts2);
qh_initflags(qh qhull_command);
// initialize the point array using the scratch file
points = qh_readpoints(&numpoints, &dim, &ismalloc);
qh_init_B(points, numpoints, dim, ismalloc);
qh_qhull();
qh_check_output();
qh_produce_output();
qh_freeqhull(True);
fclose(fin);
fclose(fout);
}
|
#include <stdio.h>
#define SIZE 10
int main(void)
{
int arr[SIZE] = {1, 2, 3, 9, 11, 13, 17, 25, 57, 90};
int mid = 0, lower = 0, upper = SIZE-1, key = 0, found = 0;
printf("Enter number to search for: ");
scanf("%d", &key);
for(mid=(lower+upper)/2; lower <= upper; mid=(lower+upper)/2)
{
if(arr[mid] == key)
{
printf("Your number is at position %d of our array\n", mid);
found = 1;
break;
}
if(arr[mid] > key)
upper = mid-1;
else
lower = mid+1;
}
if(!found)
printf("%d is not in the array\n", key);
return 0;
return(0);
}
|
//=================================================================================================
// Copyright (c) 2015, Alexander Stumpf, TU Darmstadt
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Simulation, Systems Optimization and Robotics
// group, TU Darmstadt nor the names of its contributors may be used to
// endorse or promote products derived from this software without
// specific prior written permission.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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 VIGIR_FOOTSTEP_PLANNING_HOT_MAP_HEURISTIC_H__
#define VIGIR_FOOTSTEP_PLANNING_HOT_MAP_HEURISTIC_H__
#include <ros/ros.h>
#include <boost/thread/mutex.hpp>
#include <nav_msgs/OccupancyGrid.h>
#include <vigir_footstep_planning_lib/math.h>
#include <vigir_footstep_planning_lib/plugins/heuristic_plugin.h>
namespace vigir_footstep_planning
{
class HotMapHeuristic
: public HeuristicPlugin
{
struct StateKey
{
StateKey(const State& s, double cell_size, double angle_bin_size)
: x(state_2_cell(s.getX(), cell_size))
, y(state_2_cell(s.getY(), cell_size))
, yaw(angle_state_2_cell(s.getYaw(), angle_bin_size))
{
}
bool operator<(const StateKey& key) const
{
if (x < key.x) return true;
if (x > key.x) return false;
if (y < key.y) return true;
if (y > key.y) return false;
if (yaw < key.yaw) return true;
if (yaw > key.yaw) return false;
return false;
}
int x;
int y;
int yaw;
};
public:
HotMapHeuristic(const ParameterSet& params, ros::NodeHandle& nh);
HotMapHeuristic(ros::NodeHandle& nh);
void reset();
void loadParams(const ParameterSet& params) override;
double getHeuristicValue(const State& from, const State& to, const State& start, const State& goal) const override;
// typedefs
typedef std::map<StateKey, unsigned int> HotMap;
protected:
void publishHotMap(const ros::TimerEvent& publish_timer) const;
// publisher
ros::Publisher hot_map_pub;
ros::Timer publish_timer;
// mutex
mutable boost::shared_mutex hot_map_shared_mutex;
mutable HotMap hot_map;
mutable unsigned int total_hit_counter;
double cell_size;
double angle_bin_size;
};
}
#endif
|
// stdafx.h : fichier Include pour les fichiers Include système standard,
// ou les fichiers Include spécifiques aux projets qui sont utilisés fréquemment,
// et sont rarement modifiés
//
#pragma once
#include "targetver.h"
#include <map>
#include <memory>
#include <vector>
#include <set>
#include <tuple>
#include <queue>
// En-têtes pour CppUnitTest
#include "CppUnitTest.h"
// TODO: faites référence ici aux en-têtes supplémentaires nécessaires au programme
// Crypto
#include "../Crypto/HashFactory.h"
#include "../Crypto/IHash.h"
#include "../Crypto/MD5.h"
#include "../Crypto/SHA1.h"
#include "../Crypto/SHA256.h"
#include "../Crypto/SHA512.h"
#include "FakeHash.h"
// CrackEngine
#include "../CrackEngine/Parameter.h"
#include "../CrackEngine/CrackFactoryParams.h"
#include "../CrackEngine/CrackFactory.h"
#include "../CrackEngine/BruteForce.h"
#include "../CrackEngine/CharsetBuilder.h"
#include "../CrackEngine/Dictionary.h"
// Ce projet
#include "FakeFileRepository.h" |
/*
Copyright 2009-2010 Jure Varlec
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.
A copy of the GNU General Public License is provided in COPYING.
If not, see <http://www.gnu.org/licenses/>.
*/
#define _SVID_SOURCE
#include <stdio.h>
#include <malloc.h>
int main() {
mallopt(M_TRIM_THRESHOLD, 8192);
printf("#define HAVE_MALLOPT_H\n");
return 0;
}
|
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd 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 WINDOW_H
#define WINDOW_H
#include "renderarea.h"
#include <QList>
#include <QPainterPath>
#include <QWidget>
QT_BEGIN_NAMESPACE
class QComboBox;
QT_END_NAMESPACE
//! [0]
class Window : public QWidget
{
Q_OBJECT
public:
Window();
public slots:
void operationChanged();
void shapeSelected(int index);
//! [0]
//! [1]
private:
void setupShapes();
enum { NumTransformedAreas = 3 };
RenderArea *originalRenderArea;
RenderArea *transformedRenderAreas[NumTransformedAreas];
QComboBox *shapeComboBox;
QComboBox *operationComboBoxes[NumTransformedAreas];
QList<QPainterPath> shapes;
};
//! [1]
#endif
|
/*
=====================================================================================
Filename: wait_example.c
Description:
Version: 1.0
Created: 2016年07月04日 20时00分15秒
Revision: none
Compiler: gcc
Author: Eddyding (), 920398694@qq.com
Organization: BUAA G306
=====================================================================================
*/
#include<sys/types.h>
#include<sys/wait.h>
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
pid_t pc,pr;
if((pc = fork())< 0)
{
perror("Err in fork");
exit(-1);
}else if(0 == pc){
printf("Child process ,pid is %d\n",getpid());
sleep(10);//10s
}else{
pr = wait(NULL);//等待
printf("parent catched a child process %d\n",pr);
}
return 0;
}
|
/* Processed by ecpg (regression mode) */
/* These include files are added by the preprocessor */
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
/* End of automatic include section */
#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
#line 1 "dt_test2.pgc"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <pgtypes_date.h>
#include <pgtypes_timestamp.h>
#line 1 "regression.h"
#line 8 "dt_test2.pgc"
char *dates[] = { "19990108foobar",
"19990108 foobar",
"1999-01-08 foobar",
"January 8, 1999",
"1999-01-08",
"1/8/1999",
"1/18/1999",
"01/02/03",
"1999-Jan-08",
"Jan-08-1999",
"08-Jan-1999",
"99-Jan-08",
"08-Jan-99",
"08-Jan-06",
"Jan-08-99",
"19990108",
"990108",
"1999.008",
"J2451187",
"January 8, 99 BC",
NULL };
/* do not conflict with libc "times" symbol */
static char *times[] = { "0:04",
"1:59 PDT",
"13:24:40 -8:00",
"13:24:40.495+3",
NULL };
char *intervals[] = { "1 minute",
"1 12:59:10",
"2 day 12 hour 59 minute 10 second",
"1 days 12 hrs 59 mins 10 secs",
"1 days 1 hours 1 minutes 1 seconds",
"1 year 59 mins",
"1 year 59 mins foobar",
NULL };
int
main(void)
{
/* exec sql begin declare section */
#line 52 "dt_test2.pgc"
date date1 ;
#line 53 "dt_test2.pgc"
timestamp ts1 , ts2 ;
#line 54 "dt_test2.pgc"
char * text ;
#line 55 "dt_test2.pgc"
interval * i1 ;
#line 56 "dt_test2.pgc"
date * dc ;
/* exec sql end declare section */
#line 57 "dt_test2.pgc"
int i, j;
char *endptr;
ECPGdebug(1, stderr);
ts1 = PGTYPEStimestamp_from_asc("2003-12-04 17:34:29", NULL);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp: %s\n", text);
free(text);
date1 = PGTYPESdate_from_timestamp(ts1);
dc = PGTYPESdate_new();
*dc = date1;
text = PGTYPESdate_to_asc(*dc);
printf("Date of timestamp: %s\n", text);
free(text);
PGTYPESdate_free(dc);
for (i = 0; dates[i]; i++)
{
bool err = false;
date1 = PGTYPESdate_from_asc(dates[i], &endptr);
if (date1 == INT_MIN) {
err = true;
}
text = PGTYPESdate_to_asc(date1);
printf("Date[%d]: %s (%c - %c)\n",
i, err ? "-" : text,
endptr ? 'N' : 'Y',
err ? 'T' : 'F');
free(text);
if (!err)
{
for (j = 0; times[j]; j++)
{
int length = strlen(dates[i])
+ 1
+ strlen(times[j])
+ 1;
char* t = malloc(length);
sprintf(t, "%s %s", dates[i], times[j]);
ts1 = PGTYPEStimestamp_from_asc(t, NULL);
text = PGTYPEStimestamp_to_asc(ts1);
if (i != 19 || j != 3) /* timestamp as integer or double differ for this case */
printf("TS[%d,%d]: %s\n",
i, j, errno ? "-" : text);
free(text);
free(t);
}
}
}
ts1 = PGTYPEStimestamp_from_asc("2004-04-04 23:23:23", NULL);
for (i = 0; intervals[i]; i++)
{
interval *ic;
i1 = PGTYPESinterval_from_asc(intervals[i], &endptr);
if (*endptr)
printf("endptr set to %s\n", endptr);
if (!i1)
{
printf("Error parsing interval %d\n", i);
continue;
}
j = PGTYPEStimestamp_add_interval(&ts1, i1, &ts2);
if (j < 0)
continue;
text = PGTYPESinterval_to_asc(i1);
printf("interval[%d]: %s\n", i, text ? text : "-");
free(text);
ic = PGTYPESinterval_new();
PGTYPESinterval_copy(i1, ic);
text = PGTYPESinterval_to_asc(i1);
printf("interval_copy[%d]: %s\n", i, text ? text : "-");
free(text);
PGTYPESinterval_free(ic);
PGTYPESinterval_free(i1);
}
return (0);
}
|
/****
DIAMOND protein aligner
Copyright (C) 2013-2018 Benjamin Buchfink <buchfink@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 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 COMPACT_ARRAY_H_
#define COMPACT_ARRAY_H_
#include <vector>
#include <limits.h>
#include "../io/deserializer.h"
using std::vector;
template <typename _t>
struct CompactArray
{
CompactArray(Deserializer &in, size_t size, size_t data_size) :
data_(data_size)
{
in.read(data_.data(), data_size);
limits_.reserve(size + 1);
limits_.push_back(0);
Deserializer d(data_.data(), data_.data() + data_.size(), Deserializer::VARINT);
_t x;
for (size_t i = 0; i < size; ++i) {
d >> x;
size_t offset = d.data() - data_.data();
if (offset > (size_t)UINT_MAX)
throw std::runtime_error("Array size overflow.");
limits_.push_back((unsigned)offset);
}
if (limits_.back() != data_size)
throw std::runtime_error("Error loading CompactArray.");
}
_t operator[](size_t i) const
{
_t r;
Deserializer(&data_[limits_[i]], &data_[limits_[i + 1]], Deserializer::VARINT) >> r;
return r;
}
size_t size() const
{
return limits_.size() - 1;
}
private:
vector<char> data_;
vector<unsigned> limits_;
};
#endif |
/*
* =======================================================================================
*
* Filename: perfmon.h
*
* Description: Header File of perfmon module.
* Configures and reads out performance counters
* on x86 based architectures. Supports multi threading.
*
* Version: <VERSION>
* Released: <DATE>
*
* Author: Jan Treibig (jt), jan.treibig@gmail.com
* Thomas Gruber (tr), thomas.roehl@googlemail.com
* Project: likwid
*
* Copyright (C) 2016 RRZE, University Erlangen-Nuremberg
*
* 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 PERFMON_H
#define PERFMON_H
#include <types.h>
#include <likwid.h>
#define FREEZE_FLAG_ONLYFREEZE 0x0ULL
#define FREEZE_FLAG_CLEAR_CTR (1ULL<<1)
#define FREEZE_FLAG_CLEAR_CTL (1ULL<<0)
extern uint64_t **currentConfig;
extern int (*perfmon_startCountersThread) (int thread_id, PerfmonEventSet* eventSet);
extern int (*perfmon_stopCountersThread) (int thread_id, PerfmonEventSet* eventSet);
extern int (*perfmon_setupCountersThread) (int thread_id, PerfmonEventSet* eventSet);
extern int (*perfmon_readCountersThread) (int thread_id, PerfmonEventSet* eventSet);
extern int (*perfmon_finalizeCountersThread) (int thread_id, PerfmonEventSet* eventSet);
extern int (*initThreadArch) (int cpu_id);
/* Internal helpers */
extern int getCounterTypeOffset(int index);
extern uint64_t perfmon_getMaxCounterValue(RegisterType type);
extern char** getArchRegisterTypeNames();
#endif /*PERFMON_H*/
|
/* windows/xsb_debug.h. Generated from def_debug.in by configure. */
/* Various debug options. They are here rather than in def_config.in to make
complete recompilation less likely, if the debugging option is requested */
/* General debug -- should not change code */
/* #undef DEBUG */
/* Verbose execution */
/* #undef DEBUG_VERBOSE */
/* VM Debugging */
/* #undef DEBUG_VM */
/* Assertions */
/* #undef DEBUG_ASSERTIONS */
/* #undef CP_DEBUG */
/* Heap debug */
/* #undef DEBUG_HEAP */
/* Profiling */
/* #undef PROFILE */
|
/*
╔══╦╗╔╗╔╦══╗╔══╗╔══╗ ╔══╦══╦════╦╗╔╗ ╔╗─╔══╦╗╔╦╗─╔╦══╦╗╔╦═══╦═══╗
║╔═╣║║║║║╔╗║║╔═╝╚╗╔╝ ║╔═╩╗╔╩═╗╔═╣║║║ ║║─║╔╗║║║║╚═╝║╔═╣║║║╔══╣╔═╗║
║╚═╣║║║║║╚╝╚╣╚═╗─║║ ║╚═╗║║──║║─║╚╝║ ║║─║╚╝║║║║╔╗─║║─║╚╝║╚══╣╚═╝║
╚═╗║║║║║║╔═╗║╔═╝─║║ ╚═╗║║║──║║─║╔╗║ ║║─║╔╗║║║║║╚╗║║─║╔╗║╔══╣╔╗╔╝
╔═╝║╚╝╚╝║╚═╝║║──╔╝╚╗ ╔═╝╠╝╚╗─║║─║║║║ ║╚═╣║║║╚╝║║─║║╚═╣║║║╚══╣║║║
╚══╩═╝╚═╩═══╩╝──╚══╝ ╚══╩══╝─╚╝─╚╝╚╝ ╚══╩╝╚╩══╩╝─╚╩══╩╝╚╩═══╩╝╚╝
Created by FOXente (Aradam)
License GPL-3.0
*/
#ifndef UnitGlobalProcessH
#define UnitGlobalProcessH
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include "sLabel.hpp"
#include <IOUtils.hpp>
#include "ZipForge.hpp"
class TFormGlobalProcess : public TForm
{
__published : // IDE-managed Components
TsLabel *sLabelWait;
void __fastcall FormShow (TObject *Sender);
private : // User declarations
public : // User declarations
__fastcall TFormGlobalProcess (TComponent* Owner);
};
class TGlobalProcessThread : public TThread
{
private :
protected :
void __fastcall Execute ();
void __fastcall FormClosing ();
public :
__fastcall TGlobalProcessThread (bool CreateSuspended);
};
extern PACKAGE TFormGlobalProcess *FormGlobalProcess;
extern PACKAGE int ProcessId;
extern PACKAGE UnicodeString ProcessName;
extern PACKAGE UnicodeString ProcessArguments [10];
#endif
|
#ifndef MANTID_GEOMETRY_RECTANGULARDETECTORPIXEL_H_
#define MANTID_GEOMETRY_RECTANGULARDETECTORPIXEL_H_
#include "MantidKernel/System.h"
#include "MantidGeometry/Instrument/Detector.h"
#include "MantidGeometry/IComponent.h"
#include "MantidGeometry/Instrument/ParameterMap.h"
#include "MantidKernel/V3D.h"
namespace Mantid {
namespace Geometry {
// Forward declaration
class RectangularDetector;
/** RectangularDetectorPixel: a sub-class of Detector
that is one pixel inside a RectangularDetector.
The position of the pixel is calculated on the fly from the row/column
of the pixel and the size of the parent (which is parametrized).
@date 2011-11-22
Copyright © 2011 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
This file is part of Mantid.
Mantid 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.
Mantid 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/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport RectangularDetectorPixel : public Detector {
friend class RectangularDetector;
public:
/// A string representation of the component type
std::string type() const override { return "RectangularDetectorPixel"; }
RectangularDetectorPixel(const std::string &name, int id,
boost::shared_ptr<IObject> shape, IComponent *parent,
RectangularDetector *panel, size_t row, size_t col);
RectangularDetectorPixel();
/// Create a cloned instance with a parameter map applied
RectangularDetectorPixel *
cloneParameterized(const ParameterMap *map) const override {
return new RectangularDetectorPixel(this, map);
}
Kernel::V3D getRelativePos() const override;
private:
/// RectangularDetector that is the parent of this pixel.
RectangularDetector *m_panel;
/// Row of the pixel in the panel (y index)
size_t m_row;
/// Column of the pixel in the panel (x index)
size_t m_col;
protected:
/// Constructor for parametrized version
RectangularDetectorPixel(const RectangularDetectorPixel *base,
const ParameterMap *map);
};
} // namespace Geometry
} // namespace Mantid
#endif /* MANTID_GEOMETRY_RECTANGULARDETECTORPIXEL_H_ */
|
#ifndef MANTID_CUSTOM_INTERFACES_ENGGDIFFFITTINGMODELMOCK_H_
#define MANTID_CUSTOM_INTERFACES_ENGGDIFFFITTINGMODELMOCK_H_
#include "../EnggDiffraction/IEnggDiffGSASFittingModel.h"
#include "MantidKernel/WarningSuppressions.h"
#include <gmock/gmock.h>
GCC_DIAG_OFF_SUGGEST_OVERRIDE
using namespace MantidQt::CustomInterfaces;
class MockEnggDiffGSASFittingModel : public IEnggDiffGSASFittingModel {
public:
MOCK_METHOD1(doPawleyRefinement,
Mantid::API::MatrixWorkspace_sptr(
const GSASIIRefineFitPeaksParameters ¶ms));
MOCK_METHOD1(doRietveldRefinement,
Mantid::API::MatrixWorkspace_sptr(
const GSASIIRefineFitPeaksParameters ¶ms));
MOCK_CONST_METHOD1(getGamma,
boost::optional<double>(const RunLabel &runLabel));
MOCK_CONST_METHOD1(getLatticeParams,
boost::optional<Mantid::API::ITableWorkspace_sptr>(
const RunLabel &runLabel));
MOCK_CONST_METHOD1(getRwp, boost::optional<double>(const RunLabel &runLabel));
MOCK_CONST_METHOD1(getSigma,
boost::optional<double>(const RunLabel &runLabel));
MOCK_CONST_METHOD1(hasFitResultsForRun, bool(const RunLabel &runLabel));
MOCK_CONST_METHOD1(loadFocusedRun, Mantid::API::MatrixWorkspace_sptr(
const std::string &filename));
};
GCC_DIAG_ON_SUGGEST_OVERRIDE
#endif // MANTID_CUSTOM_INTERFACES_ENGGDIFFFITTINGMODELMOCK_H_
|
#ifndef _INTERFACE_INFO_WIDGET_H_
#define _INTERFACE_INFO_WIDGET_H_
#include "..\Qt\Qt.h"
#include "..\RpcCore\RpcCore.h"
#include "..\RpcCommon\RpcCommon.h"
#include "View.h"
//------------------------------------------------------------------------------
class InterfaceInfoWidget_C : public QDockWidget, public View_I
{
Q_OBJECT
public:
InterfaceInfoWidget_C(QWidget* pParent);
virtual void AcceptVisitor(ViewVisitor_C* pVisitor);
UINT GetPid();
void Reset();
void UpdateInterfaceInfo(RpcInterfaceInfo_T* pRpcInterfaceInfo, WCHAR* pCallbackName);
void SetAddressRepresentation(AddressRepresentation_T AddressRepresentation);
private:
UINT Pid;
AddressRepresentation_T AddressRepresentation;
quintptr Base;
quintptr IfCallback;
quintptr TypeFormatString;
quintptr ProcFormatString;
quintptr ExpressionEvaluation;
//Global
QTabWidget* pTabWidget;
//Main
QWidget* pMainWidget;
QLineEdit* pUuid;
QLabel* pVersion;
QLineEdit* pName;
QLineEdit* pLocation;
QLabel* pBase;
QLabel* pState;
QLabel* pStub;
QLabel* pProcCount;
QTextEdit* pDescription;
//RPC
QWidget* pRpcWidget;
QLineEdit* pCallbackName;
QLineEdit* pCallbackAddress;
QLabel* pEpMapper;
QLineEdit* pAnnotation;
QTextEdit* pFlags;
//NDR
QWidget* pNdrWidget;
QLineEdit* pTransfertSyntax;
QLabel* pNdrVersion;
QLabel* pMidlVersion;
QTextEdit* pNdrFlags;
QLineEdit* pTypeFormatString;
QLineEdit* pProcFormatString;
QLineEdit* pExpressionEvaluation;
};
#endif// _INTERFACE_INFO_WIDGET_H_
|
/*
* Copyright 2011 Red Hat Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: Dave Airlie
*/
#include <drm/drmP.h>
#include <linux/dma-buf.h>
#include "nouveau_drv.h"
#include "nouveau_gem.h"
struct sg_table *nouveau_gem_prime_get_sg_table(struct drm_gem_object *obj)
{
struct nouveau_bo *nvbo = nouveau_gem_object(obj);
int npages = nvbo->bo.num_pages;
return drm_prime_pages_to_sg(nvbo->bo.ttm->pages, npages);
}
void *nouveau_gem_prime_vmap(struct drm_gem_object *obj)
{
struct nouveau_bo *nvbo = nouveau_gem_object(obj);
int ret;
ret = ttm_bo_kmap(&nvbo->bo, 0, nvbo->bo.num_pages,
&nvbo->dma_buf_vmap);
if (ret)
{
return ERR_PTR(ret);
}
return nvbo->dma_buf_vmap.virtual;
}
void nouveau_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr)
{
struct nouveau_bo *nvbo = nouveau_gem_object(obj);
ttm_bo_kunmap(&nvbo->dma_buf_vmap);
}
struct drm_gem_object *nouveau_gem_prime_import_sg_table(struct drm_device *dev,
struct dma_buf_attachment *attach,
struct sg_table *sg)
{
struct nouveau_bo *nvbo;
struct reservation_object *robj = attach->dmabuf->resv;
u32 flags = 0;
int ret;
flags = TTM_PL_FLAG_TT;
ww_mutex_lock(&robj->lock, NULL);
ret = nouveau_bo_new(dev, attach->dmabuf->size, 0, flags, 0, 0,
sg, robj, &nvbo);
ww_mutex_unlock(&robj->lock);
if (ret)
{
return ERR_PTR(ret);
}
nvbo->valid_domains = NOUVEAU_GEM_DOMAIN_GART;
/* Initialize the embedded gem-object. We return a single gem-reference
* to the caller, instead of a normal nouveau_bo ttm reference. */
ret = drm_gem_object_init(dev, &nvbo->gem, nvbo->bo.mem.size);
if (ret)
{
nouveau_bo_ref(NULL, &nvbo);
return ERR_PTR(-ENOMEM);
}
return &nvbo->gem;
}
int nouveau_gem_prime_pin(struct drm_gem_object *obj)
{
struct nouveau_bo *nvbo = nouveau_gem_object(obj);
int ret;
/* pin buffer into GTT */
ret = nouveau_bo_pin(nvbo, TTM_PL_FLAG_TT, false);
if (ret)
{
return -EINVAL;
}
return 0;
}
void nouveau_gem_prime_unpin(struct drm_gem_object *obj)
{
struct nouveau_bo *nvbo = nouveau_gem_object(obj);
nouveau_bo_unpin(nvbo);
}
struct reservation_object *nouveau_gem_prime_res_obj(struct drm_gem_object *obj)
{
struct nouveau_bo *nvbo = nouveau_gem_object(obj);
return nvbo->bo.resv;
}
|
#ifndef __MIMOSA_BSP_BITS_H
#define __MIMOSA_BSP_BITS_H
/* Copyleft(c)2010 HackerFellowship. All lefts reserved.
* NalaGinrut <NalaGinrut@gmail.com>
* May Lord Bless!Happy Hacking!
* 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 Foundataion;either version 2 of the License,or (at
* your option) any later version.
* You should have read the GNU General Public License before start "RTFSC".
* If not,see <http://www.gnu.org/licenses/>
*/
// This file used for handling bits operation;
#include "bsp_types.h"
#define __BIT (1UL)
// shift the value "x" to "b" bits;
#define _S(x,b) ((x)<<(b))
#define _B(b) (__BIT<<(b))
// FIXME: Maybe we need 8/16/64 bits' CHECK_FLAG?
// Note: CHK_FLAG is used during if/while judgement, DO NOT use "do{}while(0)";
#define CHK_FLAG(des ,f) \
( (des) & (f) )
#define SET_FLAG(des ,f) \
( (des) |= (f) );
#define CLR_FLAG(des ,f) \
( (des) &= (f) );
#define FLAG_BASE 0xFFFFFFFFuL // make sure unsigned long!!!;
/* use __FLAG_FIX for FLAG value set. E.g: __FLAG_FIX(3 ,5 ,32) stands for "this flag is 3bits length and start from 5th bit of 32bits integer".
DON'T call this macro directly, you SHOULD call FLAG_FIX!!!
Why we SHOULDN'T use "static inline"? We need this fixed_value populate during C Preprocessing. But "static inline" will populate it during runtime.
*/
#define __FLAG_FIX(len ,start ,bit) \
( ((FLAG_BASE)>>((bit)-start))<<(len) )
/* Our unified interface is FLAG_FIX;
*/
#define __FIX32(len ,start) __FLAG_FIX(len ,start ,32)
#define FLAG_FIX(len ,start) __FIX32(len ,start)
// Round up/down;
// Never use GCC extension! Prefer slow!
/* don't worry about mod/div speed ,I know roundup=rounddown(x+n-1,n),
* but this form is simpler in C, for '/' op in C has rounddown feature,
* and mod/div is the same instruction under X86;
*/
/* #define ROUND_UP(x ,n) \ */
/* ((n)&0x1 ? __RU_G(x ,n) : __RU_2(x ,n)) */
/* #define ROUND_DOWN(x ,n) \ */
/* ((n)&0x1 ? __RD_G(x ,n) : __RD_2(x ,n)) */
#define __RU_G(x ,n) \
( ((x)+(n)-1) / (n) )
#define __RD_G(x ,n) \
( (x) - (x)%(n) )
#define __RD_2(x ,n) \
( ((x) & (-n)) )
#define __RU_2(x ,n) \
( __RD_2(x ,n) + (n) )
// Rounding operations (efficient when n is a power of 2)
// Round down to the nearest multiple of n
#define ROUND_DOWN(a, n) \
((a) - (a) % (n))
// Round up to the nearest multiple of n
#define ROUND_UP(a, n) \
(ROUND_DOWN((a) + (n) - 1, (n)))
#endif // End of __MIMOSA_BITS_H;
|
/*!
@header DebugLogger.h
@brief Contains the DebugLogger class.
@author Michael Wu
@copyright 2015 Intactu
@version 1.1
*/
/*!
@class DebugLogger
@brief Used to filter debug output.
*/
@interface DebugLogger : NSObject
/*!
@brief Attempt to print debug string with the given priority.
@discussion If the global debug level is higher than the priority, output will not print.
@param message Debug output in the form of a NSString.
@param priority Priority assigned to the message.
*/
+ (void)log:(NSString*)message withPriority:(NSInteger)priority;
/*!
@brief Set the global debug level.
@discussion All debug output with priority lower than the global debug level will fail to print.
@param debugFilter The global debug level will be set to this value.
*/
+ (void)setDebugLevel:(NSInteger)debugFilter;
@end |
#ifndef VRONTOLOGYRULE_H_INCLUDED
#define VRONTOLOGYRULE_H_INCLUDED
#include "VROntologyUtils.h"
#include "addons/Semantics/VRSemanticsFwd.h"
#include "core/utils/VRName.h"
using namespace std;
namespace OSG {
struct VROntologyRule : public VROntoID, public VRName {
string rule;
string associatedConcept;
VRStatementPtr query;
vector<VRStatementPtr> statements;
map<int, VRPropertyPtr> annotations;
VROntologyRule(string rule, string associatedConcept);
static VROntologyRulePtr create(string rule = "", string associatedConcept = "");
string toString();
void setRule(string r);
void setQuery(string s);
//void setStatement(string s, int i);
VRStatementPtr addStatement(string name);
VRStatementPtr getStatement(int i);
void remStatement(VRStatementPtr s);
void addAnnotation(VRPropertyPtr p);
};
}
#endif
|
#ifndef CBASERECTPHOTOSPRITE_H_
#define CBASERECTPHOTOSPRITE_H_
#include "CBasePhotoSprite.h"
class CBaseRectPhotoSprite: public CBasePhotoSprite {
public:
CBaseRectPhotoSprite();
virtual ~CBaseRectPhotoSprite();
protected:
GLfloat Alpha_LT, Alpha_RT, Alpha_RB, Alpha_LB;
GLfloat X_LT, Y_LT, Z_LT, X_RT, Y_RT, Z_RT, X_RB, Y_RB, Z_RB, X_LB, Y_LB, Z_LB;
private:
void OnDraw(float EffectState, float ShowState);
virtual void SetProperties(float EffectState, float ShowState);
};
#endif /* CBASERECTPHOTOSPRITE_H_ */
|
/*
oscpack -- Open Sound Control packet manipulation library
http://www.audiomulch.com/~rossb/oscpack
Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
Any person wishing to distribute modifications to the Software is
requested to send the modifications to the original developer so that
they can be incorporated into the canonical version.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef INCLUDED_OSCOUTBOUNDPACKET_H
#define INCLUDED_OSCOUTBOUNDPACKET_H
#include "ioput/socket/osc/OscTypes.h"
#include "ioput/socket/osc/OscException.h"
namespace ssi {
class OutOfBufferMemoryException : public Exception{
public:
OutOfBufferMemoryException( const char *w="out of buffer memory" )
: Exception( w ) {}
};
class BundleNotInProgressException : public Exception{
public:
BundleNotInProgressException(
const char *w="call to EndBundle when bundle is not in progress" )
: Exception( w ) {}
};
class MessageInProgressException : public Exception{
public:
MessageInProgressException(
const char *w="opening or closing bundle or message while message is in progress" )
: Exception( w ) {}
};
class MessageNotInProgressException : public Exception{
public:
MessageNotInProgressException(
const char *w="call to EndMessage when message is not in progress" )
: Exception( w ) {}
};
class OutboundPacketStream{
public:
OutboundPacketStream( unsigned long capacity = 1472);
~OutboundPacketStream();
void Clear();
void Adjust (unsigned long capacity);
unsigned int Capacity() const;
// invariant: size() is valid even while building a message.
unsigned int Size() const;
const char *Data() const;
// indicates that all messages have been closed with a matching EndMessage
// and all bundles have been closed with a matching EndBundle
bool IsReady() const;
bool IsMessageInProgress() const;
bool IsBundleInProgress() const;
OutboundPacketStream& operator<<( const BundleInitiator& rhs );
OutboundPacketStream& operator<<( const BundleTerminator& rhs );
OutboundPacketStream& operator<<( const BeginMessage& rhs );
OutboundPacketStream& operator<<( const MessageTerminator& rhs );
OutboundPacketStream& operator<<( bool rhs );
OutboundPacketStream& operator<<( const NilType& rhs );
OutboundPacketStream& operator<<( const InfinitumType& rhs );
OutboundPacketStream& operator<<( osc_int32 rhs );
#ifndef x86_64
OutboundPacketStream& operator<<( int rhs )
{ *this << (osc_int32)rhs; return *this; }
#endif
OutboundPacketStream& operator<<( float rhs );
OutboundPacketStream& operator<<( char rhs );
OutboundPacketStream& operator<<( const RgbaColor& rhs );
OutboundPacketStream& operator<<( const MidiMessage& rhs );
OutboundPacketStream& operator<<( osc_int64 rhs );
OutboundPacketStream& operator<<( const TimeTag& rhs );
OutboundPacketStream& operator<<( double rhs );
OutboundPacketStream& operator<<( const char* rhs );
OutboundPacketStream& operator<<( const Symbol& rhs );
OutboundPacketStream& operator<<( const Blob& rhs );
static inline long RoundUp4( long x );
private:
char *BeginElement( char *beginPtr );
void EndElement( char *endPtr );
bool ElementSizeSlotRequired() const;
void CheckForAvailableBundleSpace();
void CheckForAvailableMessageSpace( const char *addressPattern );
void CheckForAvailableArgumentSpace( long argumentLength );
char *data_;
unsigned long capacity_;
char *end_;
char *typeTagsCurrent_; // stored in reverse order
char *messageCursor_;
char *argumentCurrent_;
// elementSizePtr_ has two special values: 0 indicates that a bundle
// isn't open, and elementSizePtr_==data_ indicates that a bundle is
// open but that it doesn't have a size slot (ie the outermost bundle)
osc_uint32 *elementSizePtr_;
bool messageIsInProgress_;
};
} // namespace ssi
#endif /* INCLUDED_OSC_OUTBOUND_PACKET_H */
|
//
// Created by qii on 5/1/15.
// Copyright (c) 2015 org.qii.airbooru. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "ImageBlockOperation.h"
typedef void (^NetworkOperationCompletionBlock)(BOOL downloadSuccess, NSString *cacheFile);
@interface NetworkOperation : ImageBlockOperation
@property(copy, nonatomic) NetworkOperationCompletionBlock resultBlock;
+ (instancetype)operationWithUrl:(NSString *)url;
@end |
// -----------------------------------------------------------------
// Application-dependent routine for writing gauge info file
// For stochastic mode number calculation
// This file is an ASCII companion to the gauge configuration file
// and contains information about the action used to generate it.
// This information is consistently written in the pattern
// keyword value
// or
// keyword[n] value1 value2 ... valuen
// where n is an integer.
//
// Possible keywords are listed in io_lat.h
#include "mode_includes.h"
// -----------------------------------------------------------------
// -----------------------------------------------------------------
// Write optional entries in the ASCII info file
// Call from one of the lattice output routines in io_lat4.c
// File has already been opened and the required magic number,
// time stamp and lattice dimensions have already been written
void write_appl_gauge_info(FILE *fp) {
write_gauge_info_item(fp, "action.description", "%s",
"\"Gauge plus fermion\"", 0, 0);
write_gauge_info_item(fp, "gauge.description", "%s",
"\"Fundamental--adjoint plaquette gauge action\"",
0, 0);
write_gauge_info_item(fp, "quark.description", "%s",
"\"nHYP KS fermions\"", 0, 0);
}
// -----------------------------------------------------------------
|
//----------------------------------------------------------------------------
/** @file RlSimulator.h
Simulate games from the current position
*/
//----------------------------------------------------------------------------
#ifndef RLSIMULATOR_H
#define RLSIMULATOR_H
#include "GoTimeControl.h"
#include "RlFactory.h"
#include "RlTimeControl.h"
#include "RlTrace.h"
#include "RlWeight.h"
#include "SgArray.h"
#include "SgBlackWhite.h"
#include "SgMove.h"
#include "SgPoint.h"
#include "SgTimer.h"
#include <boost/filesystem/fstream.hpp>
class RlAgent;
class RlPolicy;
class RlFuegoPlayout;
//----------------------------------------------------------------------------
/** Simple class for recording straight simulations to .sgf file */
class RlGameRecorder
{
public:
RlGameRecorder(const GoBoard& board);
void RecordStart(RlAutoObject* caller);
void RecordEnd();
void RecordVarStart();
void RecordVarEnd();
void RecordMove(SgMove move, SgBlackWhite colour);
private:
const GoBoard& m_board;
int m_count;
bfs::ofstream m_gameRecord;
};
//----------------------------------------------------------------------------
class RlSimulator : public RlAutoObject
{
public:
DECLARE_OBJECT(RlSimulator);
RlSimulator(GoBoard& board, RlAgent* agent = 0, int maxgames = 1000);
virtual void LoadSettings(std::istream& settings);
virtual void Initialise();
/** Simulate many games according to control settings */
void Simulate();
/** Pondering */
void Ponder();
/** Set flag when simulator is ready to ponder */
void SetReady(bool ready) { m_ready = ready; }
//-------------------------------------------------------------------------
// Statistics and accessors
/** Number of games simulated */
int GetNumGames() const { return m_numGames; }
/** Get most frequently chosen initial move during simulation */
SgMove GetFreqMove() const;
/** Get frequencies with which all initial moves were chosen */
void GetAllFreqs(std::vector<RlFloat>& freqs) const;
/** Get average score of all simulations */
RlFloat AverageScore() const { return m_averageScore; }
/** Get total number of steps in all simulations */
int GetTotalSteps() const { return m_totalSteps; }
RlAgent* GetAgent() { return m_agent; }
void SetMaxGames(int maxgames) { m_maxGames = maxgames; }
protected:
void InitLog();
void StepLog(int nummoves, RlFloat score);
void SimulateMaxGames();
void SimulateMaxTime();
void SimulatePonder();
void Simulate(int controlmode);
void ClearStats();
void DisplayStats();
void SelfPlayGame();
SgMove SelectAndPlay(SgBlackWhite toplay, int movenum);
bool GameOver();
bool Truncate(int nummoves);
void PlayOut(int& movenum, bool& resign);
private:
/** Agent used to simulate moves */
RlAgent* m_agent;
enum
{
eMaxGames,
eMaxTime,
ePonder,
eNoSimulation
};
/** Control mode to use for simulation */
int m_controlMode;
/** Time controller to determine how many simulations to perform */
RlTimeControl* m_timeControl;
/** Maximum number of games to simulate each move */
int m_maxGames;
/** Number of games simulated */
int m_numGames;
/** When to truncate simulated games (-1 = never) */
int m_truncate;
/** Whether to test for resignation in simulated games */
bool m_resign;
/** Play out games after truncation using this policy */
RlPolicy* m_defaultPolicy;
/** Fuego playout policy used during simulation (if used at all) */
RlFuegoPlayout* m_fuegoPlayout;
/** Maximum number of moves in simulation */
int m_maxSimMoves;
/** Remember start position for fast resets */
bool m_fastReset;
/** Log simulations */
bool m_log;
/** Record games */
bool m_record;
/** Whether pondering is enabled */
bool m_pondering;
/** Flag set when pondering is possible */
bool m_ready;
std::auto_ptr<RlLog> m_simLog;
std::auto_ptr<RlLog> m_evalLog;
RlFloat m_averageScore;
int m_totalSteps;
SgTimer m_elapsedTime;
SgArray<int, SG_PASS + 1> m_freqs;
RlGameRecorder m_gameRecorder;
};
//----------------------------------------------------------------------------
#endif // RLSIMULATOR_H
|
/****************************************************
* df communication abstraction header file.
*
* This file hides the underlying communication
* mechanism and provides a uniform communication
* between two hosts. communication be pipe, socket,
* file etc.
*
* Author : Sunil bn <sunhick@gmail.com>
*****************************************************/
#ifndef DFS_COMM_H
#define DFS_COMM_H
#include <string>
namespace dfs {
// Abstract the communication between two same/different hosts
// generic communication interface
class generic_comm {
protected:
int socketfd;
std::string host;
int port;
public:
// get the file descriptor
inline int get_file_descriptor() const { return socketfd; }
// open the communication channel
virtual int open(int backlog) = 0;
// accept the incoming connections
virtual int accept(int sockfd) = 0;
// connect to the host channel
virtual int connect() = 0;
// read the data from host
virtual ssize_t read(int fd, void *buf, size_t count) = 0;
virtual ssize_t read(void* buf, size_t count) = 0;
// write data to the host
virtual ssize_t write(int fd, const void *buf, size_t count) = 0;
virtual ssize_t write(const void *buf, size_t count) = 0;
generic_comm() { }
virtual ~generic_comm() { }
};
// defines the socket based communication between client and server
class df_socket_comm : public generic_comm {
private:
int die(const char *format, ...);
public:
df_socket_comm(std::string host, int port);
~df_socket_comm();
virtual int open(int backlog);
virtual int accept(int sockfd);
virtual int connect();
virtual ssize_t write(int fd, const void *buf, size_t count);
virtual ssize_t write(const void *buf, size_t count);
virtual ssize_t read(int fd, void *buf, size_t count);
virtual ssize_t read(void *buf, size_t count);
};
// defines the pipe based communication between two process
class df_pipe_comm : public generic_comm {
// TODO: Implement generic_comm interface
};
// defines the memory mapped based communication
class df_memory_mapped_comm : public generic_comm {
// TODO: memory mapped comm.
};
// defines the shared memory based communication
class df_shared_memory_comm : public generic_comm {
// TODO: shared memory communication
};
}
#endif
|
#ifndef API_WALLABAG_API_H_
#define API_WALLABAG_API_H_
#include <sstream>
#include <string>
#include <functional>
#include "curl/curl.h"
#include "wallabag_config.h"
#include "wallabag_entities_factory.h"
#include "wallabag_oauth_token.h"
#include "../repositories/entry_repository.h"
#include "../repositories/epub_download_queue_repository.h"
#include "../log.h"
#include "../exceptions.h"
#include "../translate.h"
#include "../gui/gui.h"
#include "../libs/thpool/thpool.h"
class WallabagApi
{
public:
void setConfig(WallabagConfig conf);
void createOAuthToken(gui_update_progressbar progressbarUpdater);
void refreshOAuthToken(gui_update_progressbar progressbarUpdater);
void loadRecentArticles(EntryRepository repository, EpubDownloadQueueRepository epubDownloadQueueRepository, time_t lastSyncTimestamp, gui_update_progressbar progressbarUpdater);
void syncEntriesToServer(EntryRepository repository, gui_update_progressbar progressbarUpdater);
void enqueueEpubDownload(EntryRepository &repository, Entry &entry, EpubDownloadQueueRepository &epubDownloadQueueRepository, gui_update_progressbar progressbarUpdater, int percent);
void startBackgroundDownloads(EntryRepository &repository, EpubDownloadQueueRepository &epubDownloadQueueRepository, gui_update_progressbar progressbarUpdater);
void downloadEpub(EntryRepository &repository, Entry &entry, gui_update_progressbar progressbarUpdater, int percent);
void fetchServerVersion(gui_update_progressbar progressbarUpdater);
void downloadImage(EntryRepository &repository, Entry &entry);
private:
void syncOneEntryToServer(EntryRepository repository, Entry &entry);
static size_t _curlWriteCallback(char *ptr, size_t size, size_t nmemb, void *userdata);
CURLcode doHttpRequest(
std::function<char * (CURL *curl)> getUrl,
std::function<char * (CURL *curl)> getMethod,
std::function<char * (CURL *curl)> getData,
std::function<void (void)> beforeRequest,
std::function<void (void)> afterRequest,
std::function<void (CURLcode res, char *json_string)> onSuccess,
std::function<void (CURLcode res, long response_code, CURL *curl)> onFailure,
FILE *destinationFile = NULL
);
WallabagConfig config;
WallabagOAuthToken oauthToken;
WallabagEntitiesFactory entitiesFactory;
// For loadRecentArticles
int json_string_len;
char *json_string;
std::string serverVersion;
};
#endif /* API_WALLABAG_API_H_ */
|
void skewcheck(double *x, int *n, int *check);
void histestim(double *x, int *n, double *smoothing, double *value);
void distestim(double *x, int *n, double *smoothing, double *value);
void kernestim(double *x, int *n, double *smoothing, double *value);
double smoothing(double *x, int n);
double kernel(double *x, int n, int j);
double quantile(double *x, int n, double p);
|
#ifndef TESTPROCEDURE_H
#define TESTPROCEDURE_H
#include "TestIO.h"
#include "TestMenu.h"
#include "TestMenuItem.h"
class TestIO;
class TestMenu;
class TestMenuItem;
// Abstract class which must be implemented for each
// individual test procedure.
// In particular, only the doProcedure(TestIO *view)
// method is required to be reimplemented.
class TestProcedure
{
public:
TestProcedure(char *title, TestMenu *parent = 0);
~TestProcedure();
void invoke(TestIO *view);
char *getTitle();
protected:
virtual void doProcedure(TestIO *view) = 0;
private:
char *title;
TestMenu *parent;
};
#endif // TESTPROCEDURE_H |
/* Copyright (c) 2012-2015 Todd Freed <todd.freed@gmail.com>
This file is part of fab.
fab 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.
fab 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 fab. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <fcntl.h>
#include "xapi.h"
#include "xapi/trace.h"
#include "rolling.h"
static xapi exercise_rolling()
{
enter;
narrator * N = 0;
fatal(narrator_rolling_create, &N, "/tmp/foo", S_IRUSR | S_IWUSR, 45, 2);
int x;
for(x = 0; x < 100; x++)
{
xsays("foo bar baz qux");
}
finally:
fatal(narrator_release, N);
coda;
}
int main()
{
enter;
xapi R = 0;
fatal(exercise_rolling);
finally:
if(XAPI_UNWINDING)
{
// xapi_backtrace(2, 0);
}
conclude(&R);
xapi_teardown();
return !!R;
}
|
/* Include file for internal CUMP types and definitions.
Copyright 2012 Takatoshi Nakayama.
This file is part of the CUMP Library.
The CUMP 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.
The CUMP Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the CUMP Library. If not, see http://www.gnu.org/licenses/. */
#ifndef CUMP_DEF_H_
typedef
struct
{
cump_int32 _mp_prec;
cump_int32 _mp_size;
cump_exp_t _mp_exp;
}
cumpf_header;
#define __CUMPF_ALLOCSIZE(prec) (((prec) + 1) * sizeof (cump_limb_t) + sizeof (cumpf_header))
#define __CUMPF_ARRAY_ELEMSIZE(prec) ((prec) + (1 + sizeof (cumpf_header) / sizeof (cump_limb_t)))
#define ABS(x) ((x) >= 0 ? (x) : -(x))
#define __CUMP_MAX(h,i) ((h) > (i) ? (h) : (i))
#define __CUMPF_BITS_TO_PREC(n) \
((cump_size_t) ((__CUMP_MAX (53, n) + 2 * CUMP_NUMB_BITS - 1) / CUMP_NUMB_BITS))
#define __CUMPF_PREC_TO_BITS(n) ((cump_bitcnt_t) (n) * CUMP_NUMB_BITS - CUMP_NUMB_BITS)
#define CUMP_DEF_H_
#endif
|
/**
@file AtlasNW.h
Arduino library for Atlas Scientific sensors, specially tailored towards
functionality with the Northern Widget ALog data logger (though written with
generalized usability in mind).
# LICENSE: GNU GPL v3
Logger.cpp is part of Logger, an Arduino library written by Andrew D. Wickert
and Chad T. Sandell
Copyright (C) 2014-2017, Andrew D. Wickert
(Library as standalone starting in 2017, but earliest functions written in 2014)
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/>.
*/
/////////////////////////////////
// DEFINE SELF / INCLUDE GUARD //
/////////////////////////////////
#ifndef AtlasNW_h
#define AtlasNW_h
///////////////////////
// INCLUDE LIBRARIES //
///////////////////////
#include <Arduino.h>
#include <SoftwareSerial.h>
#include <Wire.h>
#include <stdlib.h>
class AtlasNW {
public:
// Variables
// Generic array to hold response
char response[100];
// Constructor
AtlasNW(char* _measurement_type, char* _communications_type, uint8_t UART_number__I2C_address, uint32_t baudRate=9600);
AtlasNW(char* _measurement_type, char* _communications_type, uint8_t _softSerRX, uint8_t _softSerTX, uint32_t _baudRate=9600);
// Functions
void AtlasNW::I2C_write(char* _transmission, uint8_t _transmission_length);
void AtlasNW::Serial_write(char* _transmission);
void AtlasNW::SoftSer_write(char* _transmission);
void AtlasNW::LED_on(bool _state);
void AtlasNW::response_code_on(bool _state);
void AtlasNW::continuous_readings_on(bool _state);
void AtlasNW::set_K_constant(float K);
void AtlasNW::set_Temperature(float T);
void AtlasNW::calibrate();
void AtlasNW::read();
};
// End include guard
#endif
|
#include "header.h"
void compute_zero_mode(fftwl_complex *in, long double S0, long double *out) {
fftwl_complex w = cexpl(1.IL*conf.origin_offset);
long double b = 0.5L*(1.L + powl(conf.scaling, 2))/conf.scaling;
long double xi = (1.L - powl(conf.scaling, 2))/(1.L + powl(conf.scaling, 2));
tmpc[2][0] = -0.5L*xi*conjl(w);
for (long int j = 1; j < state.number_modes/2-1; j++) {
tmpc[2][j] = tmpc[2][0]/(1.L - conjl(tmpc[2][0])*tmpc[2][j-1]);
}
tmpc[3][0] = in[1]/b - S0*conjl(tmpc[2][0]); // added I
for (long int j = 1; j < state.number_modes/2-1; j++) {
tmpc[3][j] = in[j+1]/b - conjl(tmpc[2][0])*tmpc[3][j-1];
tmpc[3][j] = tmpc[3][j]/(1.L - conjl(tmpc[2][0])*tmpc[2][j-1]);
}
tmpc[4][state.number_modes/2-2] = tmpc[3][state.number_modes/2-2];
for (long int j = state.number_modes/2-3; j > -1; j--) {
tmpc[4][j] = tmpc[3][j]-tmpc[2][j]*tmpc[4][j+1];
}
*out = b*creall(2.0L*tmpc[4][0]*tmpc[2][0] + S0);
}
void compute_zero_mode_complex(fftwl_complex *in, fftwl_complex S0, fftwl_complex *out) {
fftwl_complex w = cexpl(1.IL*conf.origin_offset);
long double b = 0.5L*(1.L + powl(conf.scaling, 2))/conf.scaling;
long double xi = (1.L - powl(conf.scaling, 2))/(1.L + powl(conf.scaling, 2));
tmpc[2][0] = -0.5L*xi*conjl(w);
for (long int j = 1; j < state.number_modes/2-1; j++) {
tmpc[2][j] = tmpc[2][0]/(1.L - conjl(tmpc[2][0])*tmpc[2][j-1]);
}
tmpc[3][0] = in[1]/b - 2.L*S0*conjl(tmpc[2][0]);
for (long int j = 1; j < state.number_modes/2-1; j++) {
tmpc[3][j] = in[j+1]/b - conjl(tmpc[2][0])*tmpc[3][j-1];
tmpc[3][j] = tmpc[3][j]/(1.L - conjl(tmpc[2][0])*tmpc[2][j-1]);
}
tmpc[4][state.number_modes/2-2] = tmpc[3][state.number_modes/2-2];
for (long int j = state.number_modes/2-3; j > -1; j--) {
tmpc[4][j] = tmpc[3][j]-tmpc[2][j]*tmpc[4][j+1];
}
*out = b*(tmpc[4][0]*tmpc[2][0] + 1.L*S0);
}
void div_jacobian(fftwl_complex *in, fftwl_complex *out) {
// solve a tridiagonal system z_q q_u = b
// b -- inverse Fourier coefficients: b = Z_u - 1
// Note: -- b must have b[0] = 0, like Z_u - 1
// Note: not in-place safe.
fftwl_complex w = cexpl(1.IL*conf.origin_offset);
long double b = 0.5L*(1.L + powl(conf.scaling, 2))/conf.scaling;
long double xi = (1.L - powl(conf.scaling, 2))/(1.L + powl(conf.scaling, 2));
fft_shift(in);
tmpc[2][0] = -0.5L*xi*conjl(w);
for (long int j = 1; j < state.number_modes; j++) {
tmpc[2][j] = tmpc[2][0]/(1.L - conjl(tmpc[2][0])*tmpc[2][j-1]);
}
tmpc[3][0] = in[0]/b;
for (long int j = 1; j < state.number_modes; j++) {
tmpc[3][j] = in[j]/b - conjl(tmpc[2][0])*tmpc[3][j-1];
tmpc[3][j] = tmpc[3][j]/(1.L - conjl(tmpc[2][0])*tmpc[2][j-1]);
}
out[state.number_modes-1] = tmpc[3][state.number_modes-1];
for (long int j = state.number_modes-2; j > -1; j--) {
out[j] = tmpc[3][j]-tmpc[2][j]*out[j+1];
}
fft_shift(out);
fft_shift(in);
}
void linear_solve(fftwl_complex *a, fftwl_complex *b, fftwl_complex *x) {
// inverts a*x = b to find x by series inversion
// a,b -- input inverse Fourier coefficients,
// x -- output inverse Fourier coefficients
// Note: not in-place safe: a and x cannot be the same
x[0] = b[0]/a[0];
for (long int j = 1; j < state.number_modes/2; j++) {
fftwl_complex sum = 0.L;
for (long int l = j-1; l > -1; l--) {
sum += a[j-l]*x[l];
}
x[j] = (b[j] - sum)/a[0];
}
memset(x + state.number_modes/2, 0, (state.number_modes/2)*sizeof(fftwl_complex));
}
void inverse(fftwl_complex *a, fftwl_complex *x) {
// inverts a*x = 1 to find x by series inversion
// a -- input inverse Fourier coefficients,
// x -- output inverse Fourier coefficients
// Note: not in-place safe: a and x cannot be the same
x[0] = 1.0L/a[0];
for (long int j = 1; j < state.number_modes/2; j++) {
fftwl_complex sum = 0.L;
for (long int l = j-1; l > -1; l--) {
sum += a[j-l]*x[l];
}
x[j] = - sum/a[0];
}
memset(x + state.number_modes/2, 0, (state.number_modes/2)*sizeof(fftwl_complex));
}
void square_ft(fftwl_complex *Z, fftwl_complex *x){
// inverts x^2 = Z to find x by series inversion
// Z -- input inverse Fourier coefficients
// x -- output inverse Fourier coefficients
x[0] = csqrtl(Z[0]);
x[1] = 0.5L*Z[1]/x[0];
for (long int j = 2; j < state.number_modes/2; j++) {
fftwl_complex sum = 0.L;
for (long int m = 0; m < j-1; m++) {
sum += x[m+1]*x[j-m-1];
}
x[j] = 0.5L*(Z[j] - sum)/x[0];
}
memset(x + state.number_modes/2, 0, (state.number_modes/2)*sizeof(fftwl_complex));
}
|
// Global definitions and includes
#include "common.h"
// Mode specific includes
#include "foldedfft.h"
// Common mode helper includes
#include "modeCommon.h"
// dll exported process routine
DWORD process(int inst,int npulse, void *inbuf)
{
localvars *vars;
DWORD *hdr,*sd;
short *sr,*si,*sid;
int bp,bcRet;
PyGILState_STATE gstate;
float *spec;
PyObject *pulsesintegrated,*beamcodes;
int *pbc,*ppi;
int nsamples,ndatasamples;
int i,j;
vars = lv[inst];
if (npulse == 0) //first pulse in integration
{
bcReset(vars->beamcodes);
vars->spectra = createArrayZeros(PyArray_FLOAT,2,vars->beamcodes->npos,vars->nlags);
};
hdr = (DWORD *)inbuf;
if (hdr[0] != 0x00000100) // header sanity check
return ecSamplesMisalignment;
if (hdr[10] == vars->modegroup) // modegroup test
{
sd = hdr+vars->nradacheaderwords+vars->indexsample;
sid = (short *)sd;
sr = sid;
si = sid+1;
if (vars->fftsign < 0)
{
sr = sid+1;
si = sid;
}
// Check to see if beamcode was configured
bcRet = bcIndex(vars->beamcodes,hdr[4],&bp);
if (bcRet < 0) // beamcode not in list
return ecBeamcodeNotInList;
// extract header values
nsamples = (hdr[11]<<16)+hdr[12];
ndatasamples = nsamples-vars->indexsample; //subtract off number of tx pulse samples
// load data
//fftwZeroComplex(vars->data,vars->nlags);
memset(vars->data,0,vars->nlags*sizeof(fftwf_complex)); //clear first
for (i=0,j=0;i<ndatasamples;i++,j+=2)
{
vars->data[i][0] = ((float)sr[j]*(float)sr[j])-((float)si[j]*(float)si[j]);
vars->data[i][1] = 2.0*(float)sr[j]*(float)si[j];
}
fftwSpectra(vars->p1,vars->nlags,vars->data,vars->fdata);
spec = (float *)PyArray_DATA(vars->spectra)+bp*vars->nlags;
cvAddFloats(spec,vars->fdata,spec,vars->nlags);
};
if (npulse == vars->npulsesint-1)
{
// Beamcodes and pulsesintegrated
beamcodes = createArray(PyArray_INT32,1,vars->beamcodes->npos);
pbc = PyArray_DATA(beamcodes);
pulsesintegrated = createArray(PyArray_INT32,1,vars->beamcodes->npos);
ppi = PyArray_DATA(pulsesintegrated);
for (bp=0;bp<vars->beamcodes->npos;bp++)
{
pbc[bp] = vars->beamcodes->codes[bp];
ppi[bp] = vars->beamcodes->count[bp];
}
// save arrays
gstate = PyGILState_Ensure(); // Make sure we have the GIL before accessing python objects
h5Dynamic(vars->self,vars->root,"Beamcodes",beamcodes);
h5Dynamic(vars->self,vars->root,"PulsesIntegrated",pulsesintegrated);
h5Dynamic(vars->self,vars->root,"Spectra/Data",vars->spectra);
PyGILState_Release(gstate);
// release arrays
Py_XDECREF(beamcodes);
Py_XDECREF(pulsesintegrated);
Py_XDECREF(vars->spectra);
};
return ecOk;
};
// Python exported routines
static PyObject *ext_configure(PyObject *self, PyObject *args)
{
PyObject *parent;
PyObject *freqarray;
int i;
char msg[MSGSIZE];
float *freq;
double fs,fb,f;
localvars *vars;
if (!PyArg_ParseTuple(args, "O",&parent))
{
PyErr_SetString(PyExc_TypeError,"Usage: configure(self), self=mode class");
goto error;
};
vars = modeInit(parent);
if (vars == NULL)
goto error;
//Read mode specific parameters
//nlags
if (!getInt(vars->pars,"nlags",&vars->nlags))
{
PyErr_SetString(PyExc_KeyError,"nlags not in parameters dict");
goto error;
};
sprintf_s(msg,MSGSIZE,"nlags set to: %i",vars->nlags);
PyObject_CallMethod(vars->log,"info","s",msg);
//fftsign
if (!getInt(vars->pars,"fftsign",&vars->fftsign))
{
sprintf_s(msg,MSGSIZE,"fftsign not in parameters dict. Defaults to 1");
PyObject_CallMethod(vars->log,"info","s",msg);
vars->fftsign = 1;
};
sprintf_s(msg,MSGSIZE,"fftsign set to: %i",vars->fftsign);
PyObject_CallMethod(vars->log,"info","s",msg);
freqarray = createArray(PyArray_FLOAT,2,1,vars->nlags);
freq = (float *) PyArray_DATA(freqarray);
fs = 1.0/vars->sampletime;
fb = fs/vars->nlags;
f = -fs/2.0;
for (i=0;i<vars->nlags;i++)
{
freq[i] = f;
f += fb;
};
h5Static(vars->self,vars->root,"Spectra/Frequency",freqarray);
h5Attribute(vars->self,vars->root,"Spectra/Frequency/Unit",Py_BuildValue("s","Hz"));
// Various attributes
h5Attribute(vars->self,vars->root,"Spectra/Data/Unit",Py_BuildValue("s","Samples^2"));
// Temp storage
vars->data = fftwf_malloc(vars->nlags*sizeof(fftwf_complex));
vars->fdata = fftwf_malloc(vars->nlags*sizeof(float));
vars->p1 = fftwf_plan_dft_1d(vars->nlags,vars->data,vars->data,FFTW_FORWARD,FFTW_ESTIMATE);
PyObject_CallMethod(vars->log,"info","s","Configuration done");
sprintf_s(msg,MSGSIZE,"Instance: %d",vars->instance);
PyObject_CallMethod(vars->log,"info","s",msg);
Py_RETURN_NONE;
error:
return NULL;
};
static PyObject *ext_shutdown(PyObject *self, PyObject *args)
{
PyObject *inst;
int instance;
int allNull,i;
localvars *vars;
char msg[MSGSIZE];
if (!PyArg_ParseTuple(args, "i",&instance))
{
PyErr_SetString(PyExc_TypeError,"Usage: shutdown(instance)");
goto error;
};
vars = lv[instance];
bcFree(vars->beamcodes);
fftwf_free(vars->data);
fftwf_free(vars->fdata);
fftwf_destroy_plan(vars->p1);
sprintf_s(msg,MSGSIZE,"Mode instance %i has been shut down",instance);
PyObject_CallMethod(vars->log,"info","s",msg);
free(vars);
lv[instance] = NULL;
allNull = 1;
for (i=0;i<lvCount;i++)
{
if (lv[i] != NULL)
{
allNull = 0;
break;
};
};
if (allNull) //Remove list when last instance is shutdown
{
// free(lv);
lv = NULL;
lvCount = 0;
};
Py_RETURN_NONE;
error:
return NULL;
};
// Python Initialization code
static PyMethodDef extMethods[] =
{
{"configure", ext_configure, METH_VARARGS, "configure({config dict}). Configures the mode"},
{"shutdown", ext_shutdown, METH_VARARGS, "shutdown(instance). Shuts down the mode instance"},
{NULL, NULL, 0, NULL} /* Sentinel */
};
PyMODINIT_FUNC
initfoldedfft(void)
{
PyObject *m;
m = Py_InitModule("foldedfft", extMethods);
if (m == NULL)
return;
import_array();
};
|
// https://www.hackerrank.com/challenges/fair-rations
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
int main(int argc, char const *argv[]) {
int n;
scanf("%d", &n);
bool * is_odd = malloc(sizeof(bool) * n);
for (int i = 0; i < n; i++) {
int t;
scanf("%d", &t);
is_odd[i] = t % 2;
}
bool is_valid = true;
int bread_count = 0;
int i = 0;
while (i != n) {
if (!is_odd[i]) {
// E
i++;
continue;
}
if (i == n - 1) {
// O$
is_valid = false;
break;
}
if (i == n - 2) {
if (is_odd[i + 1]) {
// OO$
bread_count += 2;
i += 2;
continue;
} else {
// OE$
is_valid = false;
break;
}
} else {
int ext = 0;
while (i + ext < n && (!is_odd[i + ext] || ext == 0)) {
bread_count += 2;
ext++;
}
if (i + ext == n) {
is_valid = false;
break;
}
i += ext + 1;
continue;
}
}
if (is_valid){
printf("%d\n", bread_count);
} else {
printf("NO\n");
}
return 0;
}
|
/*
* Forward Uncompressed
*
* Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
*
* This file is part of FFmpeg.
*
* FFmpeg 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.
*
* FFmpeg 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 FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avcodec.h"
#include "bytestream.h"
static av_cold int decode_init(AVCodecContext *avctx)
{
if (avctx->width & 1) {
av_log(avctx, AV_LOG_ERROR, "frwu needs even width\n");
return AVERROR(EINVAL);
}
avctx->pix_fmt = AV_PIX_FMT_UYVY422;
avctx->coded_frame = avcodec_alloc_frame();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
return 0;
}
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt)
{
int field, ret;
AVFrame *pic = avctx->coded_frame;
const uint8_t *buf = avpkt->data;
const uint8_t *buf_end = buf + avpkt->size;
if (pic->data[0])
avctx->release_buffer(avctx, pic);
if (avpkt->size < avctx->width * 2 * avctx->height + 4 + 2*8) {
av_log(avctx, AV_LOG_ERROR, "Packet is too small.\n");
return AVERROR_INVALIDDATA;
}
if (bytestream_get_le32(&buf) != MKTAG('F', 'R', 'W', '1')) {
av_log(avctx, AV_LOG_ERROR, "incorrect marker\n");
return AVERROR_INVALIDDATA;
}
pic->reference = 0;
if ((ret = avctx->get_buffer(avctx, pic)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
pic->pict_type = AV_PICTURE_TYPE_I;
pic->key_frame = 1;
pic->interlaced_frame = 1;
pic->top_field_first = 1;
for (field = 0; field < 2; field++) {
int i;
int field_h = (avctx->height + !field) >> 1;
int field_size, min_field_size = avctx->width * 2 * field_h;
uint8_t *dst = pic->data[0];
if (buf_end - buf < 8)
return AVERROR_INVALIDDATA;
buf += 4; // flags? 0x80 == bottom field maybe?
field_size = bytestream_get_le32(&buf);
if (field_size < min_field_size) {
av_log(avctx, AV_LOG_ERROR, "Field size %i is too small (required %i)\n", field_size, min_field_size);
return AVERROR_INVALIDDATA;
}
if (buf_end - buf < field_size) {
av_log(avctx, AV_LOG_ERROR, "Packet is too small, need %i, have %i\n", field_size, (int)(buf_end - buf));
return AVERROR_INVALIDDATA;
}
if (field)
dst += pic->linesize[0];
for (i = 0; i < field_h; i++) {
memcpy(dst, buf, avctx->width * 2);
buf += avctx->width * 2;
dst += pic->linesize[0] << 1;
}
buf += field_size - min_field_size;
}
*data_size = sizeof(AVFrame);
*(AVFrame*)data = *pic;
return avpkt->size;
}
static av_cold int decode_close(AVCodecContext *avctx)
{
AVFrame *pic = avctx->coded_frame;
if (pic->data[0])
avctx->release_buffer(avctx, pic);
av_freep(&avctx->coded_frame);
return 0;
}
AVCodec ff_frwu_decoder = {
.name = "frwu",
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_FRWU,
.init = decode_init,
.close = decode_close,
.decode = decode_frame,
.capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("Forward Uncompressed"),
};
|
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** 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.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef CALENDAR_H
#define CALENDAR_H
#include <QWidget>
#include <QDate>
#include <QLocale>
class QComboBox;
class QGridLayout;
class QGroupBox;
class QCalendarWidget;
class QLabel;
class QDateEdit;
class QCheckBox;
class CalendarWidget : public QWidget
{
Q_OBJECT
public:
CalendarWidget();
private slots:
void localeChanged(QLocale locale);
void firstDayChanged(int index);
void selectionModeChanged(int index);
void horizontalHeaderChanged(int index);
void verticalHeaderChanged(int index);
void selectedDateChanged();
void minimumDateChanged(const QDate &date);
void maximumDateChanged(const QDate &date);
void updateWeekendDays();
void weekdayFormatChanged();
void weekendFormatChanged();
void reformatHeaders();
void reformatCalendarPage();
private:
bool isWeekendDay(Qt::DayOfWeek);
void createPreviewGroupBox();
void createGeneralOptionsGroupBox();
void createDatesGroupBox();
void createTextFormatsGroupBox();
QComboBox *createColorComboBox();
QGroupBox *previewGroupBox;
QGridLayout *previewLayout;
QCalendarWidget *calendar;
QGroupBox *generalOptionsGroupBox;
QLabel *localeLabel;
QLabel *firstDayLabel;
QLabel *selectionModeLabel;
QLabel *horizontalHeaderLabel;
QLabel *verticalHeaderLabel;
QComboBox *localeCombo;
QComboBox *firstDayCombo;
QComboBox *selectionModeCombo;
QCheckBox *gridCheckBox;
QCheckBox *navigationCheckBox;
QComboBox *horizontalHeaderCombo;
QComboBox *verticalHeaderCombo;
QGroupBox *datesGroupBox;
QLabel *currentDateLabel;
QLabel *minimumDateLabel;
QLabel *maximumDateLabel;
QDateEdit *currentDateEdit;
QDateEdit *minimumDateEdit;
QDateEdit *maximumDateEdit;
QGroupBox *textFormatsGroupBox;
QLabel *weekdayColorLabel;
QLabel *weekendColorLabel;
QLabel *headerTextFormatLabel;
QComboBox *weekdayColorCombo;
QComboBox *weekendColorCombo;
QComboBox *headerTextFormatCombo;
QCheckBox *firstFridayCheckBox;
QCheckBox *mayFirstCheckBox;
};
#endif
|
/*
*
* (C) 2013-21 - ntop.org
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef _IEC104_STATS_H_
#define _IEC104_STATS_H_
#include "ntop_includes.h"
class IECInvalidTransitionAlert;
class IEC104Stats {
private:
RwLock lock;
struct {
u_int32_t tx, rx;
} pkt_lost; /* Counter for packet loss sequences */
struct {
u_int32_t type_i, type_s, type_u, type_other;
u_int32_t forward_msgs, reverse_msgs, retransmitted_msgs;
} stats;
char infobuf[32];
std::unordered_map<u_int16_t, u_int32_t> type_i_transitions;
std::unordered_map<u_int16_t, u_int32_t> typeid_uses;
u_int16_t last_type_i;
struct timeval last_i_apdu;
struct ndpi_analyze_struct *i_s_apdu;
u_int16_t tx_seq_num, rx_seq_num;
public:
IEC104Stats();
~IEC104Stats();
void processPacket(Flow *f, bool tx_direction,
const u_char *payload, u_int16_t payload_len,
struct timeval *packet_time);
void lua(lua_State* vm);
char* getFlowInfo(char *buf, u_int buf_len);
};
#endif /* _IEC104_STATS_H_ */
|
/*
* tmp275.c
*
* Copyright (c) 2015, Diego F. Asanza. 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.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*
* Created on January 20, 2015, 7:11 PM
*/
#include <tmp275.h>
#include <hal_i2c.h>
#include <stdbool.h>
#include <stdint.h>
#include "HardwareProfile.h"
/* device pointer register definitions */
#define TEMPERATURE_REG 0x00
#define CONFIGURATION_REG 0x01
#define TEMPERATURE_LOW 0x02
#define TEMPERATURE_HIGH 0x03
/* converter resolution */
#define RES_9BIT 0x00
#define RES_10BIT 0x01
#define RES_11BIT 0x02
#define RES_12BIT 0x03
/* configuration register values */
typedef union{
struct{
bool shutdown_mode:1;
bool thermostat_mode:1;
bool polarity:1;
uint8_t fault_queue:2;
uint8_t converter_resolution:2;
bool one_shot:1;
};
struct{
uint8_t byte:8;
};
} tempsens_config;
static void tpm245_write_reg(uint8_t reg_add, uint8_t value);
void tmp245_init(){
tempsens_config config;
config.converter_resolution = RES_12BIT;
config.shutdown_mode = false;
config.thermostat_mode = false;
config.polarity = false;
config.fault_queue = 0;
config.one_shot = false;
/* write configuration register */
tpm245_write_reg(CONFIGURATION_REG, config.byte);
}
uint16_t tmp245_read_temp(){
hal_i2c_start(HAL_TEMPSENS_ADDRESS, HAL_I2C_WRITE);
hal_i2c_write(TEMPERATURE_REG);
hal_i2c_rep_start(HAL_TEMPSENS_ADDRESS, HAL_I2C_READ);
uint16_t val;
val = hal_i2c_readAck() << 8;
val |= hal_i2c_readNak();
val >>= 4;
hal_i2c_stop();
return val;
}
void tpm245_write_reg(uint8_t reg_add, uint8_t value){
hal_i2c_start(HAL_TEMPSENS_ADDRESS, HAL_I2C_WRITE);
hal_i2c_write(reg_add);
hal_i2c_write(value);
hal_i2c_stop();
}
double tmp245_read_temp_double(){
return tmp245_read_temp()*0.0625;
} |
#ifndef DEFIMULATOR_UI_DEBUGGER_DEBUGGER_H
#define DEFIMULATOR_UI_DEBUGGER_DEBUGGER_H
#include <ui/debugger/console.h>
#include <ui/debugger/cpu-debugger.h>
#include <ui/debugger/smp-debugger.h>
#include <ui/debugger/breakpoint-editor.h>
#include <ui/debugger/memory-editor.h>
struct Debugger : TopLevelWindow {
enum class DebugMode : unsigned {
None,
WaitForBreakpoint,
StepIntoCPU,
StepIntoSMP,
} debugMode;
CheckBox enableDebugger;
CheckBox showConsole;
CheckBox showCPUDebugger;
CheckBox showSMPDebugger;
CheckBox showBreakpointEditor;
CheckBox showMemoryEditor;
void create(void);
void synchronize(void);
void setVisible(bool visible = true);
void enable(bool state);
void run(void);
bool step_cpu(void);
bool step_smp(void);
Debugger(void);
};
extern Debugger debugger;
#endif
|
#pragma once
// qt-plus
#include "CXMLNode.h"
// Application
#include "quick3d_global.h"
#include "CQ3DConstants.h"
#include "CNamed.h"
#include "CVector3.h"
#include "CGeoloc.h"
#include "CPerlin.h"
//-------------------------------------------------------------------------------------------------
class QUICK3D_EXPORT CGenerateFunction : public CNamed
{
public:
enum ETerrainOperation
{
toNone,
toConstant,
toAdd,
toSub,
toMul,
toDiv,
toPow,
toPerlin,
toTurbulence,
toErosion,
toVoronoi
};
//-------------------------------------------------------------------------------------------------
// Constructors and destructor
//-------------------------------------------------------------------------------------------------
//!
CGenerateFunction(CXMLNode xFunctions, CXMLNode xNode);
//!
virtual ~CGenerateFunction();
//-------------------------------------------------------------------------------------------------
// Control methods
//-------------------------------------------------------------------------------------------------
//!
void getStandardParameters(CXMLNode xFunctions, CXMLNode xParams);
//!
void getProceduralParameters(CXMLNode xFunctions, CXMLNode xParams);
//!
double process(CPerlin* pPerlin, const Math::CVector3& vPosition, const Math::CAxis& aAxis) const;
//-------------------------------------------------------------------------------------------------
// Properties
//-------------------------------------------------------------------------------------------------
protected:
ETerrainOperation m_eType;
double m_dConstant;
QVector<CGenerateFunction*> m_vOperands;
Math::CVector3 m_vOffset;
double m_dInputScale;
double m_dOutputScale;
double m_dMinClamp;
double m_dMaxClamp;
double m_dDisplace;
int m_dIterations;
double m_dInputScaleFactor;
double m_dOutputScaleFactor;
};
|
/* Simple Chat
* Copyright (c) 2008-2014 Alexander Sedov <imp@schat.me>
*
* 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 CHATAPP_H_
#define CHATAPP_H_
#ifdef SCHAT_NO_SINGLEAPP
# define QtSingleApplication QApplication
# include <QApplication>
#else
# include "qtsingleapplication/qtsingleapplication.h"
#endif
class ChatCore;
class ChatWindow;
#define CMDLINE_ARG_BASE QLatin1String("-base")
#define CMDLINE_ARG_EXEC QLatin1String("-exec")
#define CMDLINE_ARG_EXIT QLatin1String("-exit")
#define CMDLINE_ARG_HIDE QLatin1String("-hide")
class ChatApp : public QtSingleApplication
{
Q_OBJECT
public:
static bool restartRequired;
ChatApp(int &argc, char **argv);
~ChatApp();
bool isRunning();
void start();
void stop();
static bool selfUpdate();
private slots:
void handleMessage(const QString& message);
void onRestartRequest();
void restart();
private:
QString value(const QString &cmdKey, const QStringList &arguments) const;
ChatCore *m_core; ///< Глобальный объект чата.
ChatWindow *m_window; ///< Главное окно.
};
#endif /* CHATAPP_H_ */
|
#include "moDirectorCore.h"
|
// This file is part of Man, a robotic perception, locomotion, and
// team strategy application created by the Northern Bites RoboCup
// team of Bowdoin College in Brunswick, Maine, for the Aldebaran
// Nao robot.
//
// Man is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Man 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 Public License for more details.
//
// You should have received a copy of the GNU General Public License
// and the GNU Lesser Public License along with Man. If not, see
// <http://www.gnu.org/licenses/>.
/**
* The switchboard is literally a switching mechanism to select between the
* different ways that we can publish joint values to the robot (called
* MotionProviders). For example, the walk engine and the queueing system both
* provide such functionality.
*
* The appropriate MotionEnactor will then take the nextJoints and pass them
* down to the robot/simulator correctly.
*/
#ifndef _MotionSwitchboard_h_DEFINED
#define _MotionSwitchboard_h_DEFINED
#include <pthread.h>
#include <vector>
#include <boost/shared_ptr.hpp>
#include "motionconfig.h" // for cmake set debugging flags like MOTION_DEBUG
#include "MCL.h"
#include "Kinematics.h"
#include "WalkProvider.h"
#include "WalkingConstants.h"
#include "ScriptedProvider.h"
#include "HeadProvider.h"
#include "NullHeadProvider.h"
#include "NullBodyProvider.h"
#include "Sensors.h"
#include "MotionConstants.h"
#include "Profiler.h"
#include "BodyJointCommand.h"
#include "HeadJointCommand.h"
#include "WalkCommand.h"
#include "Gait.h"
#include "SetHeadCommand.h"
#include "CoordHeadCommand.h"
#ifdef DEBUG_MOTION
# define DEBUG_JOINTS_OUTPUT
#endif
class MotionSwitchboard {
public:
MotionSwitchboard(boost::shared_ptr<Sensors> s,
boost::shared_ptr<Profiler> p);
~MotionSwitchboard();
void start();
void stop();
void run();
const std::vector <float> getNextJoints() const;
const std::vector<float> getNextStiffness() const;
void signalNextFrame();
void sendMotionCommand(const BodyJointCommand* command);
void sendMotionCommand(const HeadJointCommand* command);
void sendMotionCommand(const WalkCommand* command);
void sendMotionCommand(const boost::shared_ptr<Gait> command);
void sendMotionCommand(const SetHeadCommand* command);
void sendMotionCommand(const CoordHeadCommand* command);
void sendMotionCommand(const boost::shared_ptr<FreezeCommand> command);
void sendMotionCommand(const boost::shared_ptr<UnfreezeCommand> command);
void sendMotionCommand(const boost::shared_ptr<StepCommand> command);
public:
void stopHeadMoves(){headProvider.requestStop();}
void stopBodyMoves(){
curProvider->requestStop();
}
bool isWalkActive(){return walkProvider.isActive();}
bool isHeadActive(){return headProvider.isActive();}
bool isBodyActive(){return curProvider->isActive();}
void resetWalkProvider(){ walkProvider.hardReset(); }
void resetScriptedProvider(){ scriptedProvider.hardReset(); }
MotionModel getOdometryUpdate(){
return walkProvider.getOdometryUpdate();
}
private:
void preProcess();
void processJoints();
void processStiffness();
int postProcess();
void preProcessHead();
void preProcessBody();
void processHeadJoints();
void processBodyJoints();
void clipHeadJoints(vector<float>& joints);
void safetyCheckJoints();
void swapBodyProvider();
void swapHeadProvider();
int realityCheckJoints();
#ifdef DEBUG_JOINTS_OUTPUT
void initDebugLogs();
void closeDebugLogs();
void updateDebugLogs();
#endif
private:
boost::shared_ptr<Sensors> sensors;
boost::shared_ptr<Profiler> profiler;
WalkProvider walkProvider;
ScriptedProvider scriptedProvider;
HeadProvider headProvider;
NullHeadProvider nullHeadProvider;
NullBodyProvider nullBodyProvider;
MotionProvider * curProvider;
MotionProvider * nextProvider;
MotionProvider * curHeadProvider;
MotionProvider * nextHeadProvider;
std::vector <float> sensorAngles;
std::vector <float> nextJoints;
std::vector <float> nextStiffnesses;
std::vector <float> lastJoints;
bool running;
mutable bool newJoints; //Way to track if we ever use the same joints twice
bool readyToSend;
static const float sitDownAngles[Kinematics::NUM_BODY_JOINTS];
pthread_t switchboard_thread;
pthread_cond_t calc_new_joints_cond;
mutable pthread_mutex_t calc_new_joints_mutex;
mutable pthread_mutex_t next_provider_mutex;
mutable pthread_mutex_t next_joints_mutex;
mutable pthread_mutex_t stiffness_mutex;
bool noWalkTransitionCommand;
#ifdef DEBUG_JOINTS_OUTPUT
FILE* joints_log;
FILE* stiffness_log;
FILE* effector_log;
#endif
};
#endif
|
#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "chunk.h"
#if __SIZEOF_POINTER__ >= 8
/** On 64 bit architectures, t_line type is a tagged pointer,
* assuming that mapped regions use addresses whose 16 MSB bits
* are set to zero.
* https://en.wikipedia.org/wiki/Tagged_pointer
*
* This way, a 64bits size_t is used to store line like this:
*
* LSB < MSB
* ----------------------------------------------------------------------
* | size - 8bit | addr - 56bit |
* ----------------------------------------------------------------------
*
* TODO: May need refactoring due to Intel's 5-Level Paging (may 2017)
*/
typedef size_t t_line;
# define LINE_ISSET(ln) (ln != 0)
# define LINE_SIZE(ln) ((uint8_t)ln)
# define LINE_ADDR(ln) ((char*)(ln >> 8))
# define SET_LINE(ln, ptr, sz) (ln = ((((uintptr_t)ptr) << 8) + (uint8_t)sz))
#else
/** Fallback to standard structure for 32 bits architectures.
*/
typedef struct s_line
{
char *addr;
int size;
} t_line;
# define LINE_ISSET(ln) ((ln).addr != NULL)
# define LINE_SIZE(ln) ((ln).size)
# define LINE_ADDR(ln) ((ln).addr)
# define SET_LINE(ln, ptr, sz) (ln).addr = ptr; (ln).size = sz
#endif
/* source file: line.c */
bool get_next_line(t_line *dst, t_chunk *chunk);
int cmp_line(t_line *l1, t_line *l2);
|
/* ide-service.c
*
* Copyright (C) 2015 Christian Hergert <christian@hergert.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <glib/gi18n.h>
#include "ide-context.h"
#include "ide-service.h"
G_DEFINE_INTERFACE (IdeService, ide_service, G_TYPE_OBJECT)
enum {
CONTEXT_LOADED,
LAST_SIGNAL
};
static guint signals [LAST_SIGNAL];
const gchar *
ide_service_get_name (IdeService *service)
{
g_return_val_if_fail (IDE_IS_SERVICE (service), NULL);
return IDE_SERVICE_GET_IFACE (service)->get_name (service);
}
void
ide_service_start (IdeService *service)
{
g_return_if_fail (IDE_IS_SERVICE (service));
if (IDE_SERVICE_GET_IFACE (service)->start)
IDE_SERVICE_GET_IFACE (service)->start (service);
}
void
ide_service_stop (IdeService *service)
{
g_return_if_fail (IDE_IS_SERVICE (service));
if (IDE_SERVICE_GET_IFACE (service)->stop)
IDE_SERVICE_GET_IFACE (service)->stop (service);
}
void
_ide_service_emit_context_loaded (IdeService *service)
{
g_return_if_fail (IDE_IS_SERVICE (service));
g_signal_emit (service, signals [CONTEXT_LOADED], 0);
}
static const gchar *
ide_service_real_get_name (IdeService *service)
{
return G_OBJECT_TYPE_NAME (service);
}
static void
ide_service_default_init (IdeServiceInterface *iface)
{
iface->get_name = ide_service_real_get_name;
g_object_interface_install_property (iface,
g_param_spec_object ("context",
"Context",
"Context",
IDE_TYPE_CONTEXT,
(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)));
signals [CONTEXT_LOADED] =
g_signal_new ("context-loaded",
G_TYPE_FROM_INTERFACE (iface),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (IdeServiceInterface, context_loaded),
NULL, NULL, NULL,
G_TYPE_NONE,
0);
}
|
/**************************************************************************************************
* This file is part of Connect X.
*
* Connect X 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.
*
* Connect X 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 Connect X. If not, see <https://www.gnu.org/licenses/>.
*
*************************************************************************************************/
/**********************************************************************************************//**
* @file CmdArgMainStrategy.h
* @date 2019
*
*************************************************************************************************/
#ifndef CMDARGMAINSTRATEGY_H_687BF302_DBF1_4EB7_B096_8DD7B233614A
#define CMDARGMAINSTRATEGY_H_687BF302_DBF1_4EB7_B096_8DD7B233614A
#include "GtkmmUIManager.h"
#include "ICmdArgWorkflowStrategy.h"
namespace cxmodel
{
class IConnectXGameActions;
class IConnectXGameInformation;
class IConnectXLimits;
class ISubject;
}
namespace cx
{
/*********************************************************************************************//**
* @brief Main application workflow. This represents when the standard application logic is ran.
*
* @invariant The UI manager is not @c nullptr.
*
************************************************************************************************/
class CmdArgMainStrategy : public ICmdArgWorkflowStrategy
{
public:
/******************************************************************************************//**
* @brief Constructor.
*
* @pre The argument count is at least 1.
* @pre The argument list is not @c nullptr.
*
* @post m_uiMgr is not @c nullptr
*
* @param argc Command line argument count.
* @param argv A C-style array of arguments.
* @param p_modelAsSubject The Connect X compatible model (Subject).
* @param p_modelAsGameActions The Connect X compatible model (Game actions).
* @param p_modelAsGameInformation The Connect X compatible model (Game information).
* @param p_modelAsLimits The Connect X compatible model (Limits).
*
********************************************************************************************/
CmdArgMainStrategy(int argc,
char *argv[],
cxmodel::Subject& p_modelAsSubject,
cxmodel::IConnectXGameActions& p_modelAsGameActions,
cxmodel::IConnectXGameInformation& p_modelAsGameInformation,
cxmodel::IConnectXLimits& p_modelAsLimits);
int Handle() override;
private:
std::unique_ptr<cx::IUIManager> m_uiMgr;
};
} // namespace cx
#endif // CMDARGMAINSTRATEGY_H_687BF302_DBF1_4EB7_B096_8DD7B233614A
|
/* xoreos - A reimplementation of BioWare's Aurora engine
*
* xoreos is the legal property of its developers, whose names
* can be found in the AUTHORS file distributed with this source
* distribution.
*
* xoreos 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.
*
* xoreos 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 xoreos. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file
* Engine class handling Neverwinter Nights.
*/
#ifndef ENGINES_NWN_NWN_H
#define ENGINES_NWN_NWN_H
#include <vector>
#include "src/common/ustring.h"
#include "src/aurora/types.h"
#include "src/sound/types.h"
#include "src/engines/engine.h"
#include "src/engines/engineprobe.h"
namespace Common {
class FileList;
}
namespace Graphics {
namespace Aurora {
class FPS;
}
}
namespace Engines {
class LoadProgress;
namespace NWN {
class Version;
class ScriptFunctions;
class NWNEngineProbe : public Engines::EngineProbe {
private:
static const Common::UString kGameName;
public:
NWNEngineProbe() {}
~NWNEngineProbe() {}
Aurora::GameID getGameID() const {
return Aurora::kGameIDNWN;
}
const Common::UString &getGameName() const {
return kGameName;
}
bool probe(Common::SeekableReadStream &UNUSED(stream)) const {
return false;
}
Engines::Engine *createEngine() const;
};
class NWNEngineProbeWindows : public NWNEngineProbe {
public:
NWNEngineProbeWindows() {}
~NWNEngineProbeWindows() {}
bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const;
Aurora::Platform getPlatform() const { return Aurora::kPlatformWindows; }
};
class NWNEngineProbeMac : public NWNEngineProbe {
public:
NWNEngineProbeMac() {}
~NWNEngineProbeMac() {}
bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const;
Aurora::Platform getPlatform() const { return Aurora::kPlatformMacOSX; }
};
class NWNEngineProbeLinux: public NWNEngineProbe {
public:
NWNEngineProbeLinux() {}
~NWNEngineProbeLinux() {}
bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const;
Aurora::Platform getPlatform() const { return Aurora::kPlatformLinux; }
};
class NWNEngineProbeFallback : public NWNEngineProbe {
public:
NWNEngineProbeFallback() {}
~NWNEngineProbeFallback() {}
bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const;
Aurora::Platform getPlatform() const { return Aurora::kPlatformUnknown; }
};
extern const NWNEngineProbeWindows kNWNEngineProbeWin;
extern const NWNEngineProbeMac kNWNEngineProbeMac;
extern const NWNEngineProbeLinux kNWNEngineProbeLinux;
extern const NWNEngineProbeFallback kNWNEngineProbeFallback;
class NWNEngine : public Engines::Engine {
public:
NWNEngine();
~NWNEngine();
void run();
/** Return a list of all modules. */
static void getModules(std::vector<Common::UString> &modules);
/** Does a given module exist? */
static bool hasModule(Common::UString &module);
/** Return a list of local player characters. */
static void getCharacters(std::vector<Common::UString> &characters, bool local);
private:
Version *_version;
bool _hasXP1; // Shadows of Undrentide (SoU)
bool _hasXP2; // Hordes of the Underdark (HotU)
bool _hasXP3; // Kingmaker (resources also included in the final 1.69 patch)
Graphics::Aurora::FPS *_fps;
Sound::ChannelHandle _menuMusic;
ScriptFunctions *_scriptFuncs;
void init();
void detectVersion();
void initConfig();
void declareEncodings();
void initResources(LoadProgress &progress);
void initCursors();
void initGameConfig();
void deinit();
void checkConfig();
void playIntroVideos();
void playMenuMusic();
void stopMenuMusic();
void mainMenuLoop();
};
} // End of namespace NWN
} // End of namespace Engines
#endif // ENGINES_NWN_NWN_H
|
/*
========================================================================
D O O M R e t r o
The classic, refined DOOM source port. For Windows PC.
========================================================================
Copyright © 1993-2022 by id Software LLC, a ZeniMax Media company.
Copyright © 2013-2022 by Brad Harding <mailto:brad@doomretro.com>.
DOOM Retro is a fork of Chocolate DOOM. For a list of credits, see
<https://github.com/bradharding/doomretro/wiki/CREDITS>.
This file is a part of DOOM Retro.
DOOM Retro 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.
DOOM Retro 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 DOOM Retro. If not, see <https://www.gnu.org/licenses/>.
DOOM is a registered trademark of id Software LLC, a ZeniMax Media
company, in the US and/or other countries, and is used without
permission. All other trademarks are the property of their respective
holders. DOOM Retro is in no way affiliated with nor endorsed by
id Software.
========================================================================
*/
#pragma once
#include "r_defs.h"
//
// Globally visible constants.
//
#define HU_FONTSTART '!' // the first font character
#define HU_FONTEND '_' // the last font character
// Calculate # of characters in font.
#define HU_FONTSIZE (HU_FONTEND - HU_FONTSTART + 1)
#define HU_MSGX 3
#define HU_MSGY 2
#define HU_MSGTIMEOUT (4 * TICRATE)
#define HUD_HEALTH_X 55
#define HUD_HEALTH_Y (SCREENHEIGHT - 32)
#define HUD_HEALTH_MIN 10
#define HUD_HEALTH_WAIT 250
#define HUD_HEALTH_HIGHLIGHT_WAIT 250
#define HUD_ARMOR_X 124
#define HUD_ARMOR_Y HUD_HEALTH_Y
#define HUD_ARMOR_HIGHLIGHT_WAIT 250
#define HUD_KEYS_X (SCREENWIDTH - 88)
#define HUD_KEYS_Y HUD_HEALTH_Y
#define HUD_AMMO_X (SCREENWIDTH - 51)
#define HUD_AMMO_Y HUD_HEALTH_Y
#define HUD_AMMO_MIN 10
#define HUD_AMMO_WAIT 250
#define HUD_AMMO_HIGHLIGHT_WAIT 250
#define HUD_KEY_WAIT 250
#define ALTHUD_LEFT_X 56
#define ALTHUD_RIGHT_X (SCREENWIDTH - 179)
#define ALTHUD_Y (SCREENHEIGHT - 41)
//
// HEADS UP TEXT
//
void HU_Init(void);
void HU_SetTranslucency(void);
void HU_Start(void);
void HU_Ticker(void);
void HU_Drawer(void);
void HU_Erase(void);
void HU_SetPlayerMessage(char *message, dboolean group, dboolean external);
void HU_PlayerMessage(char *message, dboolean group, dboolean external);
void HU_ClearMessages(void);
void HU_DrawDisk(void);
extern patch_t *hu_font[HU_FONTSIZE];
extern patch_t *minuspatch;
extern int healthhighlight;
extern int ammohighlight;
extern int armorhighlight;
extern dboolean drawdisk;
extern dboolean idbehold;
extern int message_counter;
extern dboolean message_dontfuckwithme;
extern dboolean message_fadeon;
extern short minuspatchwidth;
|
//
// SoundEffects.h
// ButApp
//
// Created by Milosch, Anthony M on 3/8/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
@interface SoundEffects : NSObject
{
SystemSoundID _soundID;
}
+(id)soundEffectWithContentsOfFile:(NSString *)aPath;
-(id)initWithContentsOfFile: (NSString *)path;
-(void)play;
@end
|
/*
Copyright (C) 1996-2001 Id Software, Inc.
Copyright (C) 2018 Headcrab Garage
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/// @file
#pragma once
//
// key / value info strings
//
#define MAX_INFO_KEY 64
#define MAX_INFO_VALUE 64
//#define MAX_INFO_STRING 512 // TODO: com_model
char *Info_ValueForKey(const char *s, const char *key);
void Info_RemoveKey(char *s, const char *key);
void Info_RemovePrefixedKeys(char *start, char prefix);
void Info_SetValueForKey(char *s, const char *key, const char *value, int maxsize);
void Info_SetValueForStarKey(char *s, const char *key, const char *value, int maxsize);
void Info_Print(char *s);
//qboolean Info_Validate (char *s); // TODO: Q2 |
/* This file is part of the 'neper' program. */
/* Copyright (C) 2003-2012, Romain Quey. */
/* See the COPYING file in the top-level directory. */
#include"Tess.h"
/* PrevFace returns a face number of polyhedron PrevP which contains
* the studied vertex. The chosen face is that whose facepoly=PNb.
*/
int
PrevFace (struct POLY *Poly, int PNb, int PrevP)
{
if (oneDIntEltPos (Poly[PrevP].FacePoly, 1, Poly[PrevP].FaceQty, PNb, 0) ==
-1)
ut_error_reportbug ();
return oneDIntEltPos (Poly[PrevP].FacePoly, 1, Poly[PrevP].FaceQty, PNb, 0);
}
/* The parent germs of the 3 parent faces of the vertex are
* recorded.
*/
void
ParFacePoly (struct POLY *Poly, int PNb, int VNb, int PrevP, int *PFG)
{
int i; /* Mute variable */
int pos;
/* First, we search the parent germs that the vertex of poly PrevP
* must have. They are the same than the studied poly PNb vertex,
* except for the value PrevP which is replaced by PNb.
* The values are written in PFG.
*/
/* The VNb parent face germ are copied.
*/
for (i = 0; i <= 2; i++)
PFG[i] = Poly[PNb].FacePoly[Poly[PNb].VerFace[VNb][i]];
/* PrevP is replaced by PNb
*/
pos = oneDIntEltPos (PFG, 0, 2, PrevP, 0);
PFG[pos] = PNb;
return;
}
/* We search the vertex in the found PrevP poly
*/
int
SearchInPrevP (struct POLY *Poly, int PrevP, int *PFG)
{
int i, j;
int *ParentFace = ut_alloc_1d_int (3);
int ver = 0; /* Value to return */
/* Every vertex of the polyhedron is checked. If it has the same parent
* face parent germs than the studied vertex, except for germ PNb which
* is replaced by PrevP, that is a common vertex with that we study.
*/
for (i = 1; i <= Poly[PrevP].VerQty; i++)
{
/* For clarity reasons, the vertex parent faces are recorded.
*/
for (j = 0; j <= 2; j++)
ParentFace[j] = Poly[PrevP].VerFace[i][j];
if (oneDIntEltPos (PFG, 0, 2, Poly[PrevP].FacePoly[ParentFace[0]], 0) !=
-1
&& oneDIntEltPos (PFG, 0, 2, Poly[PrevP].FacePoly[ParentFace[1]],
0) != -1
&& oneDIntEltPos (PFG, 0, 2, Poly[PrevP].FacePoly[ParentFace[2]],
0) != -1)
{
ver = i;
break;
}
}
ut_free_1d_int (ParentFace);
return ver;
}
|
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
/***************************************************************************
* ncm_model_rosenbrock.c
*
* Sat April 17 10:57:36 2021
* Copyright 2021 Sandro Dias Pinto Vitenti
* <sandro@isoftware.com.br>
****************************************************************************/
/*
* ncm_model_rosenbrock.c
* Copyright (C) 2021 Sandro Dias Pinto Vitenti <sandro@isoftware.com.br>
*
* numcosmo 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.
*
* numcosmo 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/>.
*/
/**
* SECTION:ncm_model_rosenbrock
* @title: NcmModelRosenbrock
* @short_description: Multivariate Normal Distribution mean model.
*
* Multivariate Normal distribution model of the mean.
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include "build_cfg.h"
#include "math/ncm_model_rosenbrock.h"
#ifndef NUMCOSMO_GIR_SCAN
#endif /* NUMCOSMO_GIR_SCAN */
enum
{
PROP_0,
PROP_SIZE,
};
struct _NcmModelRosenbrockPrivate
{
gint place_holder;
};
G_DEFINE_TYPE_WITH_PRIVATE (NcmModelRosenbrock, ncm_model_rosenbrock, NCM_TYPE_MODEL);
static void
ncm_model_rosenbrock_init (NcmModelRosenbrock *model_rosenbrock)
{
model_rosenbrock->priv = ncm_model_rosenbrock_get_instance_private (model_rosenbrock);
}
static void
_ncm_model_rosenbrock_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
/*NcmModelRosenbrock *model_rosenbrock = NCM_MODEL_ROSENBROCK (object);*/
g_return_if_fail (NCM_IS_MODEL_ROSENBROCK (object));
switch (prop_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
_ncm_model_rosenbrock_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
/*NcmModelRosenbrock *model_rosenbrock = NCM_MODEL_ROSENBROCK (object);*/
g_return_if_fail (NCM_IS_MODEL_ROSENBROCK (object));
switch (prop_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
_ncm_model_rosenbrock_dispose (GObject *object)
{
/*NcmModelRosenbrock *model_rosenbrock = NCM_MODEL_ROSENBROCK (object);*/
/* Chain up : end */
G_OBJECT_CLASS (ncm_model_rosenbrock_parent_class)->dispose (object);
}
static void
_ncm_model_rosenbrock_finalize (GObject *object)
{
/* Chain up : end */
G_OBJECT_CLASS (ncm_model_rosenbrock_parent_class)->finalize (object);
}
NCM_MSET_MODEL_REGISTER_ID (ncm_model_rosenbrock, NCM_TYPE_MODEL_ROSENBROCK);
static void
ncm_model_rosenbrock_class_init (NcmModelRosenbrockClass *klass)
{
GObjectClass* object_class = G_OBJECT_CLASS (klass);
NcmModelClass *model_class = NCM_MODEL_CLASS (klass);
model_class->set_property = &_ncm_model_rosenbrock_set_property;
model_class->get_property = &_ncm_model_rosenbrock_get_property;
object_class->dispose = &_ncm_model_rosenbrock_dispose;
object_class->finalize = &_ncm_model_rosenbrock_finalize;
ncm_model_class_set_name_nick (model_class, "MRB", "NcmModelRosenbrock");
ncm_model_class_add_params (model_class, NNCM_MODEL_ROSENBROCK_SPARAM_LEN, 0, PROP_SIZE);
ncm_mset_model_register_id (model_class,
"NcmModelRosenbrock",
"MRB",
NULL,
FALSE,
NCM_MSET_MODEL_MAIN);
ncm_model_class_set_sparam (model_class, NCM_MODEL_ROSENBROCK_X1, "x_1", "x1",
-200.0, 200.0, 1.0e-1, 0.0, 0.0, NCM_PARAM_TYPE_FREE);
ncm_model_class_set_sparam (model_class, NCM_MODEL_ROSENBROCK_X2, "x_2", "x2",
-400.0, 800.0, 1.0e-1, 0.0, 0.0, NCM_PARAM_TYPE_FREE);
ncm_model_class_check_params_info (model_class);
}
/**
* ncm_model_rosenbrock_new:
*
* Creates a new Rosenbrock model.
*
* Returns: (transfer full): the newly created #NcmModelRosenbrock
*/
NcmModelRosenbrock *
ncm_model_rosenbrock_new (void)
{
NcmModelRosenbrock *mrb = g_object_new (NCM_TYPE_MODEL_ROSENBROCK,
NULL);
return mrb;
}
/**
* ncm_model_rosenbrock_ref:
* @mrb: a #NcmModelRosenbrock
*
* Increases the reference count of @mrb by one.
*
* Returns: (transfer full): @mrb
*/
NcmModelRosenbrock *
ncm_model_rosenbrock_ref (NcmModelRosenbrock *mrb)
{
return g_object_ref (mrb);
}
/**
* ncm_model_rosenbrock_free:
* @mrb: a #NcmModelRosenbrock
*
* Decreases the reference count of @mrb by one.
*
*/
void
ncm_model_rosenbrock_free (NcmModelRosenbrock *mrb)
{
g_object_unref (mrb);
}
/**
* ncm_model_rosenbrock_clear:
* @mrb: a #NcmModelRosenbrock
*
* If @mrb is different from NULL, decreases the reference count of
* @mrb by one and sets @mrb to NULL.
*
*/
void
ncm_model_rosenbrock_clear (NcmModelRosenbrock **mrb)
{
g_clear_object (mrb);
}
|
/*
* +----------------------------------------------------------+
* | +------------------------------------------------------+ |
* | | Quafios MIPS Boot-Loader. | |
* | | -> main() procedure. | |
* | +------------------------------------------------------+ |
* +----------------------------------------------------------+
*
* This file is part of Quafios 2.0.1 source code.
* Copyright (C) 2015 Mostafa Abd El-Aziz Mohamed.
*
* 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 Quafios. If not, see <http://www.gnu.org/licenses/>.
*
* Visit http://www.quafios.com/ for contact information.
*
*/
int main() {
/* initialize bios structure */
bios_init();
/* initialize bootinfo structure */
bootinfo_init();
/* show menu */
show_menu();
/* done */
return 0;
}
|
#define LOG_TAG "Sensors"
#include <hardware/sensors.h>
#include <fcntl.h>
#include <errno.h>
#include <dirent.h>
#include <math.h>
#include <poll.h>
#include <pthread.h>
#include <linux/input.h>
#include "psensor_test.h"
#include "../../hardware/rockchip/sensor/st/isl29028.h"
#include "common.h"
#include "test_case.h"
#include "language.h"
#define PSENSOR_CTL_DEV_PATH "/dev/psensor"
#define PSENSOR_INPUT_NAME "proximity"
static float p_value = 0;
#define PROXIMITY_THRESHOLD_CM 9.0f
static float indexToValue(size_t index)
{
return index * PROXIMITY_THRESHOLD_CM;
}
static int openInput(const char* inputName)
{
int fd = -1;
const char *dirname = "/dev/input";
char devname[512];
char *filename;
DIR *dir;
struct dirent *de;
//return getInput(inputName);
dir = opendir(dirname);
if(dir == NULL)
return -1;
strcpy(devname, dirname);
filename = devname + strlen(devname);
*filename++ = '/';
while((de = readdir(dir))) {
if(de->d_name[0] == '.' &&
(de->d_name[1] == '\0' ||
(de->d_name[1] == '.' && de->d_name[2] == '\0')))
continue;
strcpy(filename, de->d_name);
fd = open(devname, O_RDONLY);
if (fd>=0) {
char name[80];
if (ioctl(fd, EVIOCGNAME(sizeof(name) - 1), &name) < 1) {
name[0] = '\0';
}
if (!strcmp(name, inputName)) {
break;
} else {
close(fd);
fd = -1;
}
}
}
closedir(dir);
return fd;
}
static int readEvents(int fd)
{
struct input_event event;
ssize_t n = read(fd, &event,sizeof(struct input_event));
if (n < 0)
{
printf("gsensor read fail!\n");
return n;
}
int type = event.type;
//printf("type:%d\n",type);
if (type == EV_ABS)
{ // #define EV_ABS 0x03
if (event.value != -1) {
// FIXME: not sure why we're getting -1 sometimes
p_value = indexToValue(event.value);
}
}
return 0;
}
void* psensor_test(void *argv)
{
int ret;
int fd;
//struct gsensor_msg *g_msg = (struct gsensor_msg *)malloc(sizeof(struct gsensor_msg));
struct psensor_msg g_msg;
struct testcase_info *tc_info = (struct testcase_info*)argv;
int flags = 1;
/*remind ddr test*/
if(tc_info->y <= 0)
tc_info->y = get_cur_print_y();
g_msg.y = tc_info->y;
ui_print_xy_rgba(0,g_msg.y,255,255,0,255,"%s:[%s..] \n",PCBA_PSENSOR,PCBA_TESTING);
tc_info->result = 0;
/*
if(!g_msg)
{
printf("malloc for wlan_msg fail!\n");
}
else
{
g_msg->result = -1;
//g_msg->y = get_cur_print_y();
}
*/
fd = openInput(PSENSOR_INPUT_NAME);
if(fd < 0)
{
ui_print_xy_rgba(0,g_msg.y,255,0,0,255,"%s:[%s]\n",PCBA_PSENSOR,PCBA_FAILED);
g_msg.result = -1;
tc_info->result = -1;
return argv;
}
int fd_dev = open(PSENSOR_CTL_DEV_PATH, O_RDONLY);
if(fd_dev<0)
{
printf("opne Lsensor demon fail\n");
ui_print_xy_rgba(0,g_msg.y,255,0,0,255,"%s:[%s]\n",PCBA_PSENSOR,PCBA_FAILED);
g_msg.result = -1;
tc_info->result = -1;
close(fd);
return argv;
}
ret = ioctl(fd_dev, PSENSOR_IOCTL_ENABLE, &flags);
if(ret < 0)
{
printf("start p sensor fail!\n");
ui_print_xy_rgba(0,g_msg.y,255,0,0,255,"%s:[%s]\n",PCBA_PSENSOR,PCBA_FAILED);
g_msg.result = -1;
tc_info->result = -1;
close(fd_dev);
close(fd);
return argv;
}
for(;;)
{
readEvents(fd);
//ui_print_xy_rgba(0,g_msg.y,0,255,0,255,"%s:[%s] { %2d,%2d,%2d }\n",PCBA_GSENSOR,PCBA_SECCESS,(int)g_x,(int)g_y,(int)g_z);
ui_display_sync(0,g_msg.y,0,255,0,255,"%s:[%s] { %5d }\n",PCBA_PSENSOR,PCBA_SECCESS,(int)p_value);
//ui_print_xy_rgba(0,g_msg->y,0,0,255,255,"gsensor x:%f y:%f z:%f\n",g_x,g_y,g_z);
usleep(100000);
}
close(fd);
close(fd_dev);
ui_print_xy_rgba(0,g_msg.y,0,255,0,255,"%s:[%s]\n",PCBA_PSENSOR,PCBA_SECCESS);
tc_info->result = 0;
return argv;
}
|
/*
* RenderRasterize_Shader.h
* Created by Clemens Unterkofler on 1/20/09.
* for Aleph One
*
* http://www.gnu.org/licenses/gpl.html
*/
#ifndef _RENDERRASTERIZE_SHADER__H
#define _RENDERRASTERIZE_SHADER__H
#include "cseries.h"
#include "map.h"
#include "RenderRasterize.h"
#include "OGL_FBO.h"
#include "OGL_Textures.h"
#include "Rasterizer_Shader.h"
#include <memory>
class Blur;
class RenderRasterize_Shader : public RenderRasterizerClass {
std::unique_ptr<Blur> blur;
Rasterizer_Shader_Class *RasPtr;
int objectCount;
world_distance objectY;
float weaponFlare;
float selfLuminosity;
long_vector2d leftmost_clip, rightmost_clip;
protected:
virtual void render_node(sorted_node_data *node, bool SeeThruLiquids, RenderStep renderStep);
virtual void store_endpoint(endpoint_data *endpoint, long_vector2d& p);
virtual void render_node_floor_or_ceiling(
clipping_window_data *window, polygon_data *polygon, horizontal_surface_data *surface,
bool void_present, bool ceil, RenderStep renderStep);
virtual void render_node_side(
clipping_window_data *window, vertical_surface_data *surface,
bool void_present, RenderStep renderStep);
virtual void render_node_object(render_object_data *object, bool other_side_of_media, RenderStep renderStep);
virtual void clip_to_window(clipping_window_data *win);
virtual void _render_node_object_helper(render_object_data *object, RenderStep renderStep);
void render_viewer_sprite_layer(RenderStep renderStep);
void render_viewer_sprite(rectangle_definition& RenderRectangle, RenderStep renderStep);
public:
RenderRasterize_Shader();
~RenderRasterize_Shader();
virtual void setupGL(Rasterizer_Shader_Class& Rasterizer);
virtual void render_tree(void);
bool renders_viewer_sprites_in_tree() { return true; }
TextureManager setupWallTexture(const shape_descriptor& Texture, short transferMode, float pulsate, float wobble, float intensity, float offset, RenderStep renderStep);
TextureManager setupSpriteTexture(const rectangle_definition& rect, short type, float offset, RenderStep renderStep);
};
#endif
|
#include "hierr.h"
#include "mfrag.h"
int main( int argc, char *argv[] )
{
struct hiena_mfrag *m1, *m2;
int ret;
m1 = mfrag_new();
if( mfrag_set_bounds( m1, HIMFRAG_BOUNDS_MIN, HIMFRAG_BOUNDS_MAX ) != 0 ) {
ret = HIERR( "err frag_set_bounds" );
}
if( mfrag_set_bounds( m1, HIMFRAG_BOUNDS_MIN, HIMFRAG_BOUNDS_MAX+1 ) != 0 ) {
ret = HIERR( "err frag_set_bounds above MAX" );
}
if( mfrag_set_bounds( m1, HIMFRAG_BOUNDS_MIN-1, HIMFRAG_BOUNDS_MAX ) != 0 ) {
ret = HIERR( "err frag_set_bounds below MIN" );
}
m2 = mfrag_dup( m1 );
mfrag_cleanup( m1 );
mfrag_cleanup( m2 );
return 0;
} |
#pragma once
#include "riftparty_character.h"
class CCharacterCamera;
class CPlayerCharacter : public CRiftPartyCharacter
{
REGISTER_ENTITY_CLASS(CPlayerCharacter, CRiftPartyCharacter);
public:
void Precache();
void Spawn();
void Think();
virtual TFloat CharacterAcceleration() { return 20.0f; }
protected:
CEntityHandle<CCharacterCamera> m_hCamera;
};
|
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2011 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#ifndef MANTIDQTMANTIDWIDGETS_WORKSPACESELECTOR_H_
#define MANTIDQTMANTIDWIDGETS_WORKSPACESELECTOR_H_
#include "DllOption.h"
#include "MantidAPI/AnalysisDataService.h"
#include <QComboBox>
#include <QStringList>
#include <Poco/AutoPtr.h>
#include <Poco/NObserver.h>
// Forward declarations
namespace Mantid {
namespace API {
class Algorithm;
}
} // namespace Mantid
namespace MantidQt {
namespace MantidWidgets {
/**
This class defines a widget for selecting a workspace present in the
AnalysisDataService
Subscribes to the WorkspaceAddNotification and WorkspaceDeleteNotification from
the ADS.
Types of workspace to show can be restricted in several ways:
* By listing allowed WorkspaceIDs to show (Workspace2D, TableWorkspace, etc)
* By deciding whether or not to show "hidden" workspaces (identified with a
double underscore at the start of the
workspace name
* By providing a suffix that the workspace name must have
* By giving the name of an algorithm, each workspace will be validated as an
input to the workspaces first input WorkspaceProperty
@author Michael Whitty
@date 23/02/2011
*/
class EXPORT_OPT_MANTIDQT_COMMON WorkspaceSelector : public QComboBox {
Q_OBJECT
Q_PROPERTY(
QStringList WorkspaceTypes READ getWorkspaceTypes WRITE setWorkspaceTypes)
Q_PROPERTY(
bool ShowHidden READ showHiddenWorkspaces WRITE showHiddenWorkspaces)
Q_PROPERTY(bool ShowGroups READ showWorkspaceGroups WRITE showWorkspaceGroups)
Q_PROPERTY(bool Optional READ isOptional WRITE setOptional)
Q_PROPERTY(QStringList Suffix READ getSuffixes WRITE setSuffixes)
Q_PROPERTY(QString Algorithm READ getValidatingAlgorithm WRITE
setValidatingAlgorithm)
friend class DataSelector;
public:
using QComboBox::currentIndexChanged;
/// Default Constructor
WorkspaceSelector(QWidget *parent = nullptr, bool init = true);
/// Destructor
~WorkspaceSelector() override;
QStringList getWorkspaceTypes() const;
void setWorkspaceTypes(const QStringList &types);
bool showHiddenWorkspaces() const;
void showHiddenWorkspaces(bool show);
bool showWorkspaceGroups() const;
void showWorkspaceGroups(bool show);
bool isOptional() const;
void setOptional(bool optional);
QStringList getSuffixes() const;
void setSuffixes(const QStringList &suffix);
void setLowerBinLimit(int numberOfBins);
void setUpperBinLimit(int numberOfBins);
QString getValidatingAlgorithm() const;
void setValidatingAlgorithm(const QString &algName);
bool isValid() const;
void refresh();
signals:
void emptied();
private:
void handleAddEvent(Mantid::API::WorkspaceAddNotification_ptr pNf);
void handleRemEvent(Mantid::API::WorkspacePostDeleteNotification_ptr pNf);
void handleClearEvent(Mantid::API::ClearADSNotification_ptr pNf);
void handleRenameEvent(Mantid::API::WorkspaceRenameNotification_ptr pNf);
void
handleReplaceEvent(Mantid::API::WorkspaceAfterReplaceNotification_ptr pNf);
bool checkEligibility(const QString &name,
Mantid::API::Workspace_sptr object) const;
bool hasValidSuffix(const QString &name) const;
bool hasValidNumberOfBins(Mantid::API::Workspace_sptr object) const;
protected:
// Method for handling drop events
void dropEvent(QDropEvent *) override;
// called when a drag event enters the class
void dragEnterEvent(QDragEnterEvent *) override;
private:
/// Poco Observers for ADS Notifications
Poco::NObserver<WorkspaceSelector, Mantid::API::WorkspaceAddNotification>
m_addObserver;
Poco::NObserver<WorkspaceSelector,
Mantid::API::WorkspacePostDeleteNotification>
m_remObserver;
Poco::NObserver<WorkspaceSelector, Mantid::API::ClearADSNotification>
m_clearObserver;
Poco::NObserver<WorkspaceSelector, Mantid::API::WorkspaceRenameNotification>
m_renameObserver;
Poco::NObserver<WorkspaceSelector,
Mantid::API::WorkspaceAfterReplaceNotification>
m_replaceObserver;
bool m_init;
/// A list of workspace types that should be shown in the ComboBox
QStringList m_workspaceTypes;
/// Whether to show "hidden" workspaces
bool m_showHidden;
// show/hide workspace groups
bool m_showGroups;
/// Whether to add an extra empty entry to the combobox
bool m_optional;
/// Allows you to put limits on the size of the workspace i.e. number of bins
std::pair<int, int> m_binLimits;
QStringList m_suffix;
QString m_algName;
QString m_algPropName;
// Algorithm to validate against
boost::shared_ptr<Mantid::API::Algorithm> m_algorithm;
};
} // namespace MantidWidgets
} // namespace MantidQt
#endif // MANTIDQTMANTIDWIDGETS_INSTRUMENTSELECTOR_H_
|
#include "../../../../../src/compositor/wayland_wrapper/qwldatadevice_p.h"
|
#if defined(__arm__)
#include "localcrypto_sha1.c" /* We can't use corecrypto.kext yet, so use local version for now. */
#else
#include <libkern/crypto/crypto_internal.h>
#include <libkern/crypto/sha1.h>
#include <kern/debug.h>
#include <corecrypto/ccdigest.h>
static uint64_t getCount(SHA1_CTX *ctx)
{
return ctx->c.b64[0];
}
static void setCount(SHA1_CTX *ctx, uint64_t count)
{
ctx->c.b64[0]=count;
}
/* Copy a ccdigest ctx into a legacy SHA1 context */
static void DiToSHA1(const struct ccdigest_info *di, struct ccdigest_ctx *di_ctx, SHA1_CTX *sha1_ctx)
{
setCount(sha1_ctx, ccdigest_nbits(di, di_ctx)/8+ccdigest_num(di, di_ctx));
memcpy(sha1_ctx->m.b8, ccdigest_data(di, di_ctx), di->block_size);
memcpy(sha1_ctx->h.b8, ccdigest_state_ccn(di, di_ctx), di->state_size);
}
/* Copy a legacy SHA1 context into a ccdigest ctx */
static void SHA1ToDi(const struct ccdigest_info *di, SHA1_CTX *sha1_ctx, struct ccdigest_ctx *di_ctx)
{
uint64_t count = getCount(sha1_ctx);
ccdigest_num(di, di_ctx)=count%di->block_size;
ccdigest_nbits(di, di_ctx)=(count-ccdigest_num(di, di_ctx))*8;
memcpy(ccdigest_data(di, di_ctx), sha1_ctx->m.b8, di->block_size);
memcpy(ccdigest_state_ccn(di, di_ctx), sha1_ctx->h.b8, di->state_size);
}
void SHA1Init(SHA1_CTX *ctx)
{
const struct ccdigest_info *di=g_crypto_funcs->ccsha1_di;
ccdigest_di_decl(di, di_ctx);
g_crypto_funcs->ccdigest_init_fn(di, di_ctx);
DiToSHA1(di, di_ctx, ctx);
}
void SHA1Update(SHA1_CTX *ctx, const void *data, size_t len)
{
const struct ccdigest_info *di=g_crypto_funcs->ccsha1_di;
ccdigest_di_decl(di, di_ctx);
SHA1ToDi(di, ctx, di_ctx);
g_crypto_funcs->ccdigest_update_fn(di, di_ctx, len, data);
DiToSHA1(di, di_ctx, ctx);
}
void SHA1Final(void *digest, SHA1_CTX *ctx)
{
const struct ccdigest_info *di=g_crypto_funcs->ccsha1_di;
ccdigest_di_decl(di, di_ctx);
SHA1ToDi(di, ctx, di_ctx);
ccdigest_final(di, di_ctx, digest);
}
#ifdef XNU_KERNEL_PRIVATE
void SHA1UpdateUsePhysicalAddress(SHA1_CTX *ctx, const void *data, size_t len)
{
//TODO: What the hell ?
SHA1Update(ctx, data, len);
}
#endif
/* This is not publicised in header, but exported in libkern.exports */
void SHA1Final_r(SHA1_CTX *context, void *digest);
void SHA1Final_r(SHA1_CTX *context, void *digest)
{
SHA1Final(digest, context);
}
/*
* This function is called by the SHA1 hardware kext during its init.
* This will register the function to call to perform SHA1 using hardware.
*/
#include <sys/types.h>
#include <libkern/OSAtomic.h>
#include <sys/systm.h>
typedef kern_return_t (*InKernelPerformSHA1Func)(void *ref, const void *data, size_t dataLen, u_int32_t *inHash, u_int32_t options, u_int32_t *outHash, Boolean usePhysicalAddress);
void sha1_hardware_hook(Boolean option, InKernelPerformSHA1Func func, void *ref);
static void *SHA1Ref;
static InKernelPerformSHA1Func performSHA1WithinKernelOnly;
void sha1_hardware_hook(Boolean option, InKernelPerformSHA1Func func, void *ref)
{
if(option) {
// Establish the hook. The hardware is ready.
OSCompareAndSwapPtr((void*)NULL, (void*)ref, (void * volatile*)&SHA1Ref);
if(!OSCompareAndSwapPtr((void *)NULL, (void *)func, (void * volatile *)&performSHA1WithinKernelOnly)) {
panic("sha1_hardware_hook: Called twice.. Should never happen\n");
}
}
else {
// The hardware is going away. Tear down the hook.
performSHA1WithinKernelOnly = NULL;
SHA1Ref = NULL;
}
}
#endif /* !__arm__ */
|
#pragma once
#include "ClientObject.h"
//complete size 0x3C8
class TangibleObject : public ClientObject {
protected:
uint8_t clientTangibleObjectData[0x3C8]; //this includes data from inherited classes (ClientObject, CallbackReceiver)
public:
TangibleObject() {
memset(clientTangibleObjectData, 0, sizeof(clientTangibleObjectData));
}
TangibleObject(void* templateData) {
//address is 63EE10
}
int getConditionBitmask() const {
return getMemoryReference<int>(0x38C);
}
};
|
/*
* This file is part of EasyRPG Player.
*
* EasyRPG Player 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 Player 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 Player. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef EP_PLATFORM_PSP2_UI_H
#define EP_PLATFORM_PSP2_UI_H
#ifdef PSP2
// Headers
#include "baseui.h"
#include "color.h"
#include "rect.h"
#include "system.h"
#include <vita2d.h>
#include <vector>
/**
* Psp2Ui class.
*/
class Psp2Ui : public BaseUi {
public:
/**
* Constructor.
*
* @param width window client width.
* @param height window client height.
* @param cfg video config options
*/
Psp2Ui(int width, int height, const Game_ConfigVideo& cfg);
/**
* Destructor.
*/
~Psp2Ui();
/**
* Inherited from BaseUi.
*/
/** @{ */
void ToggleFullscreen() override;
void ToggleZoom() override;
void UpdateDisplay() override;
void SetTitle(const std::string &title) override;
bool ShowCursor(bool flag) override;
void ProcessEvents() override;
#ifdef SUPPORT_AUDIO
AudioInterface& GetAudio();
std::unique_ptr<AudioInterface> audio_;
#endif
/** @} */
int frame;
bool trigger_state;
int touch_x_start;
SceUID GPU_Thread;
};
#endif
#endif
|
/*
* This file is part of Cleanflight.
*
* Cleanflight 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.
*
* Cleanflight 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 Cleanflight. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdbool.h>
#include <stdint.h>
#include <platform.h>
#include "dma.h"
#include "gpio.h"
#include "nvic.h"
#include "common/color.h"
#include "drivers/light_ws2811strip.h"
#ifndef WS2811_GPIO
#define WS2811_GPIO GPIOB
#define WS2811_GPIO_AHB_PERIPHERAL RCC_AHBPeriph_GPIOB
#define WS2811_GPIO_AF GPIO_AF_1
#define WS2811_PIN GPIO_Pin_8 // TIM16_CH1
#define WS2811_PIN_SOURCE GPIO_PinSource8
#define WS2811_TIMER TIM16
#define WS2811_TIMER_APB2_PERIPHERAL RCC_APB2Periph_TIM16
#define WS2811_DMA_CHANNEL DMA1_Channel3
#define WS2811_IRQ DMA1_Channel3_IRQn
#define WS2811_DMA_TC_FLAG DMA1_FLAG_TC3
#define WS2811_DMA_HANDLER_IDENTIFER DMA1Channel3Descriptor
#endif
void ws2811LedStripHardwareInit(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
DMA_InitTypeDef DMA_InitStructure;
uint16_t prescalerValue;
RCC_AHBPeriphClockCmd(WS2811_GPIO_AHB_PERIPHERAL, ENABLE);
GPIO_PinAFConfig(WS2811_GPIO, WS2811_PIN_SOURCE, WS2811_GPIO_AF);
/* Configuration alternate function push-pull */
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = WS2811_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(WS2811_GPIO, &GPIO_InitStructure);
RCC_APB2PeriphClockCmd(WS2811_TIMER_APB2_PERIPHERAL, ENABLE);
/* Compute the prescaler value */
prescalerValue = (uint16_t) (SystemCoreClock / 24000000) - 1;
/* Time base configuration */
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
TIM_TimeBaseStructure.TIM_Period = 29; // 800kHz
TIM_TimeBaseStructure.TIM_Prescaler = prescalerValue;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(WS2811_TIMER, &TIM_TimeBaseStructure);
/* PWM1 Mode configuration */
TIM_OCStructInit(&TIM_OCInitStructure);
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse = 0;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OC1Init(WS2811_TIMER, &TIM_OCInitStructure);
TIM_OC1PreloadConfig(WS2811_TIMER, TIM_OCPreload_Enable);
TIM_CtrlPWMOutputs(WS2811_TIMER, ENABLE);
/* configure DMA */
/* DMA1 Channel Config */
DMA_DeInit(WS2811_DMA_CHANNEL);
DMA_StructInit(&DMA_InitStructure);
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&WS2811_TIMER->CCR1;
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)ledStripDMABuffer;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStructure.DMA_BufferSize = WS2811_DMA_BUFFER_SIZE;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(WS2811_DMA_CHANNEL, &DMA_InitStructure);
TIM_DMACmd(WS2811_TIMER, TIM_DMA_CC1, ENABLE);
DMA_ITConfig(WS2811_DMA_CHANNEL, DMA_IT_TC, ENABLE);
const hsvColor_t hsv_white = { 0, 255, 255};
setStripColor(&hsv_white);
ws2811UpdateStrip();
}
void ws2811LedStripDMAEnable(void)
{
DMA_SetCurrDataCounter(WS2811_DMA_CHANNEL, WS2811_DMA_BUFFER_SIZE); // load number of bytes to be transferred
TIM_SetCounter(WS2811_TIMER, 0);
TIM_Cmd(WS2811_TIMER, ENABLE);
DMA_Cmd(WS2811_DMA_CHANNEL, ENABLE);
}
|
/*-------------------------------------------------------------------------
*
* receivelog.h
*
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
*
* IDENTIFICATION
* src/bin/pg_basebackup/receivelog.h
*-------------------------------------------------------------------------
*/
#ifndef RECEIVELOG_H
#define RECEIVELOG_H
#include "libpq-fe.h"
#include "walmethods.h"
#include "access/xlogdefs.h"
/*
* Called before trying to read more data or when a segment is
* finished. Return true to stop streaming.
*/
typedef bool (*stream_stop_callback) (XLogRecPtr segendpos, uint32 timeline, bool segment_finished);
/*
* Global parameters when receiving xlog stream. For details about the individual fields,
* see the function comment for ReceiveXlogStream().
*/
typedef struct StreamCtl
{
XLogRecPtr startpos; /* Start position for streaming */
TimeLineID timeline; /* Timeline to stream data from */
char *sysidentifier; /* Validate this system identifier and
* timeline */
int standby_message_timeout; /* Send status messages this often */
bool synchronous; /* Flush immediately WAL data on write */
bool mark_done; /* Mark segment as done in generated archive */
bool do_sync; /* Flush to disk to ensure consistent state of
* data */
stream_stop_callback stream_stop; /* Stop streaming when returns true */
pgsocket stop_socket; /* if valid, watch for input on this socket
* and check stream_stop() when there is any */
WalWriteMethod *walmethod; /* How to write the WAL */
char *partial_suffix; /* Suffix appended to partially received files */
char *replication_slot; /* Replication slot to use, or NULL */
} StreamCtl;
extern bool CheckServerVersionForStreaming(PGconn *conn);
extern bool ReceiveXlogStream(PGconn *conn,
StreamCtl *stream);
#endif /* RECEIVELOG_H */
|
/*
Copyright © 2011-2012 Clint Bellanger and Thane Brimhall
Copyright © 2014 Henrik Andersson
Copyright © 2015 Igor Paliychuk
This file is part of FLARE.
FLARE 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.
FLARE 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
FLARE. If not, see http://www.gnu.org/licenses/
*/
#ifndef FONT_ENGINE_H
#define FONT_ENGINE_H
#include "CommonIncludes.h"
#include "Utils.h"
#include <map>
const int JUSTIFY_LEFT = 0;
const int JUSTIFY_RIGHT = 1;
const int JUSTIFY_CENTER = 2;
const Color FONT_WHITE = Color(255,255,255);
const Color FONT_BLACK = Color(0,0,0);
class FontStyle {
public:
std::string name;
std::string path;
int ptsize;
bool blend;
int line_height;
int font_height;
FontStyle();
virtual ~FontStyle() {};
};
/**
*
* class FontEngine
* Provide abstract interface for FLARE engine text rendering.
*
*/
class FontEngine {
public:
FontEngine();
virtual ~FontEngine() {};
Color getColor(std::string _color);
Point calc_size(const std::string& text_with_newlines, int width);
void render(const std::string& text, int x, int y, int justify, Image *target, int width, Color color);
void renderShadowed(const std::string& text, int x, int y, int justify, Image *target, Color color);
void renderShadowed(const std::string& text, int x, int y, int justify, Image *target, int width, Color color);
virtual int getLineHeight() = 0;
virtual int getFontHeight() = 0;
virtual void setFont(std::string _font) = 0;
virtual int calc_width(const std::string& text) = 0;
virtual std::string trimTextToWidth(const std::string& text, const int& width, const bool& use_ellipsis) = 0;
virtual void render(const std::string& text, int x, int y, int justify, Image *target, Color color) = 0;
int cursor_y;
protected:
Rect position(const std::string& text, int x, int y, int justify);
std::map<std::string,Color> color_map;
};
#endif
|
/*
* File: Ficheros.h
* Author: https://github.com/Arkadoel
*
* Created on 19 de noviembre de 2014, 20:06
*/
#include "PseudoBase.h"
#include <fstream>
#include <string>
#include <sstream>
EspacioDeNombres Sistema Contiene
EspacioDeNombres Ficheros Contiene
Clase FichEntrada Contiene
Privado Frase __Ruta;
Privado ifstream fs;
Publico Booleano Abrir(Frase Ruta) Hacer
__Ruta = Ruta;
Aqui->fs.open(Ruta.c_str(),ios::in);
Fin
Publico Frase LeerLinea() Hacer
Frase linea = "";
//fs >> linea;
getline(fs, linea);
Retorno linea;
Fin
Publico Booleano EsFinalFichero() Hacer
if(fs.eof()) return true;
else return false;
Fin
Publico Booleano Cerrar() Hacer
Aqui->fs.close();
Fin
FinClase
Fin
Fin
|
/*
This file is part of cpp-ethereum.
cpp-ethereum 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.
cpp-ethereum 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 cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file Common.h
* @author Gav Wood <i@gavwood.com>
* @date 2014
*
* Very common stuff (i.e. that every other header needs except vector_ref.h).
*/
#pragma once
// way too many unsigned to size_t warnings in 32 bit build
#ifdef _M_IX86
#pragma warning(disable:4244)
#endif
#if _MSC_VER && _MSC_VER < 1900
#define _ALLOW_KEYWORD_MACROS
#define noexcept throw()
#endif
#ifdef __INTEL_COMPILER
#pragma warning(disable:3682) //call through incomplete class
#endif
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#include <unordered_set>
#include <functional>
#include <string>
#include <chrono>
#if defined(__GNUC__)
#pragma warning(push)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif // defined(__GNUC__)
// See https://github.com/ethereum/libweb3core/commit/90680a8c25bfb48b24371b4abcacde56c181517c
// See https://svn.boost.org/trac/boost/ticket/11328
// Bob comment - perhaps we should just HARD FAIL here with Boost-1.58.00?
// It is quite old now, and requiring end-users to use a newer Boost release is probably not unreasonable.
#include <boost/version.hpp>
#if (BOOST_VERSION == 105800)
#include "boost_multiprecision_number_compare_bug_workaround.hpp"
#endif // (BOOST_VERSION == 105800)
#include <boost/multiprecision/cpp_int.hpp>
#if defined(__GNUC__)
#pragma warning(pop)
#pragma GCC diagnostic pop
#endif // defined(__GNUC__)
#include "vector_ref.h"
using byte = uint8_t;
// Quote a given token stream to turn it into a string.
#define DEV_QUOTED_HELPER(s) #s
#define DEV_QUOTED(s) DEV_QUOTED_HELPER(s)
#define DEV_IGNORE_EXCEPTIONS(X) try { X; } catch (...) {}
namespace dev
{
// Binary data types.
using bytes = std::vector<byte>;
using bytesRef = vector_ref<byte>;
using bytesConstRef = vector_ref<byte const>;
// Numeric types.
using bigint = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<>>;
using u64 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<64, 64, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>;
using u128 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<128, 128, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>;
using u256 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>;
using s256 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<256, 256, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void>>;
using u160 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<160, 160, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>;
using s160 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<160, 160, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void>>;
using u512 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<512, 512, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>;
using s512 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<512, 512, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void>>;
using u256s = std::vector<u256>;
using u160s = std::vector<u160>;
using u256Set = std::set<u256>;
using u160Set = std::set<u160>;
// Map types.
using StringMap = std::map<std::string, std::string>;
// Hash types.
using StringHashMap = std::unordered_map<std::string, std::string>;
// String types.
using strings = std::vector<std::string>;
// Fixed-length string types.
using string32 = std::array<char, 32>;
// Null/Invalid values for convenience.
static const bytes NullBytes;
/// Interprets @a _u as a two's complement signed number and returns the resulting s256.
inline s256 u2s(u256 _u)
{
static const bigint c_end = bigint(1) << 256;
if (boost::multiprecision::bit_test(_u, 255))
return s256(-(c_end - _u));
else
return s256(_u);
}
/// @returns the two's complement signed representation of the signed number _u.
inline u256 s2u(s256 _u)
{
static const bigint c_end = bigint(1) << 256;
if (_u >= 0)
return u256(_u);
else
return u256(c_end + _u);
}
template <size_t n> inline u256 exp10()
{
return exp10<n - 1>() * u256(10);
}
template <> inline u256 exp10<0>()
{
return u256(1);
}
/// RAII utility class whose destructor calls a given function.
class ScopeGuard
{
public:
ScopeGuard(std::function<void(void)> _f): m_f(_f) {}
~ScopeGuard() { m_f(); }
private:
std::function<void(void)> m_f;
};
enum class WithExisting: int
{
Trust = 0,
Verify,
Rescue,
Kill
};
}
|
/*
* This file is part of Pastie
*
* Pastie 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
* any later version.
*
* Pastie 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 Pastie. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @copyright 2015 Steffen Vogel
* @license http://www.gnu.org/licenses/gpl.txt GNU Public License
* @author Steffen Vogel <steffen.vogel@rwth-aachen.de>
* @link http://www.steffenvogel.de
*/
#ifndef DEBUGSTREAM_H
#define DEBUGSTREAM_H
#include <QtGlobal>
#include <QPlainTextEdit>
#include <iostream>
class Console;
class DebugStream : public std::basic_streambuf<char>
{
public:
DebugStream(std::ostream &stream, QtMsgType type);
~DebugStream();
static QString format(QString msg, QtMsgType type = QtDebugMsg);
static void registerConsole(Console *);
static void registerHandler();
protected:
int overflow(int_type v);
std::streamsize xsputn(const char *p, std::streamsize n);
private:
std::ostream &stream;
std::streambuf *oldBuf;
std::string string;
QtMsgType type;
static void handler(QtMsgType type, const QString &msg);
static void handler(QtMsgType type, const QMessageLogContext &, const QString &str);
static Console *console;
};
#endif // DEBUGSTREAM_H
|
/*
NSOpenPanel.h
Standard panel for opening files
Copyright (C) 1996 Free Software Foundation, Inc.
Author: Scott Christley <scottc@net-community.com>
Date: 1996
Author: Daniel Bðhringer <boehring@biomed.ruhr-uni-bochum.de>
Date: August 1998
Source by Daniel Bðhringer integrated into Scott Christley's preliminary
implementation by Felipe A. Rodriguez <far@ix.netcom.com>
Author: Nicola Pero <n.pero@mi.flashnet.it>
Date: 1999
This file is part of the GNUstep GUI Library.
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; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _GNUstep_H_NSOpenPanel
#define _GNUstep_H_NSOpenPanel
#import <GNUstepBase/GSVersionMacros.h>
#import <AppKit/NSSavePanel.h>
@class NSString;
@class NSArray;
@interface NSOpenPanel : NSSavePanel <NSCoding>
{
BOOL _canChooseDirectories;
BOOL _canChooseFiles;
}
// Accessing the NSOpenPanel shared instance
+ (NSOpenPanel *) openPanel;
// Running an NSOpenPanel
- (NSInteger) runModalForTypes: (NSArray *)fileTypes;
- (NSInteger) runModalForDirectory: (NSString *)path
file: (NSString *)name
types: (NSArray *)fileTypes;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
- (NSInteger) runModalForDirectory: (NSString *)path
file: (NSString *)name
types: (NSArray *)fileTypes
relativeToWindow: (NSWindow*)window;
- (void) beginSheetForDirectory: (NSString *)path
file: (NSString *)name
types: (NSArray *)fileTypes
modalForWindow: (NSWindow *)docWindow
modalDelegate: (id)delegate
didEndSelector: (SEL)didEndSelector
contextInfo: (void *)contextInfo;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
- (void) beginForDirectory: (NSString *)absoluteDirectoryPath
file: (NSString *)filename
types: (NSArray *)fileTypes
modelessDelegate: (id)modelessDelegate
didEndSelector: (SEL)didEndSelector
contextInfo: (void *)contextInfo;
#endif
- (NSArray *) filenames;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
- (NSArray *) URLs;
#endif
// Filtering Files
- (BOOL) canChooseDirectories;
- (BOOL) canChooseFiles;
- (void) setCanChooseDirectories: (BOOL)flag;
- (void) setCanChooseFiles: (BOOL)flag;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_1, GS_API_LATEST)
- (void) setResolvesAliases: (BOOL)flag;
- (BOOL) resolvesAliases;
#endif
- (BOOL) allowsMultipleSelection;
- (void) setAllowsMultipleSelection: (BOOL)flag;
@end
#endif // _GNUstep_H_NSOpenPanel
|
/*
This file is part of Darling.
Copyright (C) 2021 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 AFSiriActivationRequest : NSObject
@end
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define HIGH_SHIFT 3
#define LOW_SHIFT 2
#define DEC_SHIFT 1
#define SHIFT_MAX 26
#define NUMBER_OF_LETTERS 26
#define NUMBER_OF_DIGITS 10
#define CIPHER_SPECIAL_CHARS " .!?,;:'()[]{}`"
#define TO_CHAR(a) (char)(a)
struct message {
char coded[50];
char original[50];
size_t size;
};
int main (int argc, char **argv) {
int32_t i = 0;
struct message msg;
msg.size = 0;
memset(msg.coded, '\0', sizeof msg.coded);
memset(msg.original, '\0', sizeof msg.coded);
printf("%s\n\t%s\n\t%s\n\n%s",
"Welcome to DC612 1-Day Event",
"Crypto Lvl 1",
"What type of cipher is this, and what are the keys?",
"Input: ");
fflush(stdout);
if (!fgets(msg.original, sizeof msg.original, stdin)) {
printf("%s\n", "You need some from of input.");
exit(1);
}
msg.original[sizeof msg.original - 1] = '\0';
for (i=0; i<strlen(msg.original); i++) {
if (strchr(CIPHER_SPECIAL_CHARS, msg.original[i])!=NULL)
msg.coded[i] = msg.original[i];
else if (islower(msg.original[i]))
msg.coded[i] = TO_CHAR((((int)(msg.original[i]-'a') + LOW_SHIFT) % NUMBER_OF_LETTERS) + 'a');
else if (isupper(msg.original[i]))
msg.coded[i] = TO_CHAR((((int)(msg.original[i]-'A') + HIGH_SHIFT) % NUMBER_OF_LETTERS) + 'A');
else if (isdigit(msg.original[i]))
msg.coded[i] = TO_CHAR(((int)(msg.original[i]-'0') + DEC_SHIFT) % NUMBER_OF_DIGITS + '0');
else {
msg.original[i] = '\0';
msg.coded[i] = '\0';
break;
}
}
msg.coded[sizeof msg.coded - 1] = '\0';
printf("%s %s - ","Plaintext:", msg.original);
for (i=0; i<strlen(msg.original); i++)
printf("\\%d", msg.original[i]);
printf("\n");
printf("%s %s - ", "Ciphertext:", msg.coded);
for (i=0; i<strlen(msg.coded); i++)
printf("\\%d", msg.coded[i]);
printf("\n");
exit(0);
}
|
/* specfunc/gsl_sf_coulomb.h
*
* Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
*
* 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.
*/
/* Author: G. Jungman */
#ifndef __GSL_SF_COULOMB_H__
#define __GSL_SF_COULOMB_H__
#if !defined( GSL_FUN )
# if !defined( GSL_DLL )
# define GSL_FUN extern
# elif defined( BUILD_GSL_DLL )
# define GSL_FUN extern __declspec(dllexport)
# else
# define GSL_FUN extern __declspec(dllimport)
# endif
#endif
#include <gsl/gsl_mode.h>
#include <gsl/gsl_sf_result.h>
#undef __BEGIN_DECLS
#undef __END_DECLS
#ifdef __cplusplus
# define __BEGIN_DECLS extern "C" {
# define __END_DECLS }
#else
# define __BEGIN_DECLS /* empty */
# define __END_DECLS /* empty */
#endif
__BEGIN_DECLS
/* Normalized hydrogenic bound states, radial dependence. */
/* R_1 := 2Z sqrt(Z) exp(-Z r)
*/
GSL_FUN int gsl_sf_hydrogenicR_1_e(const double Z, const double r, gsl_sf_result * result);
GSL_FUN double gsl_sf_hydrogenicR_1(const double Z, const double r);
/* R_n := norm exp(-Z r/n) (2Z/n)^l Laguerre[n-l-1, 2l+1, 2Z/n r]
*
* normalization such that psi(n,l,r) = R_n Y_{lm}
*/
GSL_FUN int gsl_sf_hydrogenicR_e(const int n, const int l, const double Z, const double r, gsl_sf_result * result);
GSL_FUN double gsl_sf_hydrogenicR(const int n, const int l, const double Z, const double r);
/* Coulomb wave functions F_{lam_F}(eta,x), G_{lam_G}(eta,x)
* and their derivatives; lam_G := lam_F - k_lam_G
*
* lam_F, lam_G > -0.5
* x > 0.0
*
* Conventions of Abramowitz+Stegun.
*
* Because there can be a large dynamic range of values,
* overflows are handled gracefully. If an overflow occurs,
* GSL_EOVRFLW is signalled and exponent(s) are returned
* through exp_F, exp_G. These are such that
*
* F_L(eta,x) = fc[k_L] * exp(exp_F)
* G_L(eta,x) = gc[k_L] * exp(exp_G)
* F_L'(eta,x) = fcp[k_L] * exp(exp_F)
* G_L'(eta,x) = gcp[k_L] * exp(exp_G)
*/
GSL_FUN int
gsl_sf_coulomb_wave_FG_e(const double eta, const double x,
const double lam_F,
const int k_lam_G,
gsl_sf_result * F, gsl_sf_result * Fp,
gsl_sf_result * G, gsl_sf_result * Gp,
double * exp_F, double * exp_G);
/* F_L(eta,x) as array */
GSL_FUN int gsl_sf_coulomb_wave_F_array(
double lam_min, int kmax,
double eta, double x,
double * fc_array,
double * F_exponent
);
/* F_L(eta,x), G_L(eta,x) as arrays */
GSL_FUN int gsl_sf_coulomb_wave_FG_array(double lam_min, int kmax,
double eta, double x,
double * fc_array, double * gc_array,
double * F_exponent,
double * G_exponent
);
/* F_L(eta,x), G_L(eta,x), F'_L(eta,x), G'_L(eta,x) as arrays */
GSL_FUN int gsl_sf_coulomb_wave_FGp_array(double lam_min, int kmax,
double eta, double x,
double * fc_array, double * fcp_array,
double * gc_array, double * gcp_array,
double * F_exponent,
double * G_exponent
);
/* Coulomb wave function divided by the argument,
* F(eta, x)/x. This is the function which reduces to
* spherical Bessel functions in the limit eta->0.
*/
GSL_FUN int gsl_sf_coulomb_wave_sphF_array(double lam_min, int kmax,
double eta, double x,
double * fc_array,
double * F_exponent
);
/* Coulomb wave function normalization constant.
* [Abramowitz+Stegun 14.1.8, 14.1.9]
*/
GSL_FUN int gsl_sf_coulomb_CL_e(double L, double eta, gsl_sf_result * result);
GSL_FUN int gsl_sf_coulomb_CL_array(double Lmin, int kmax, double eta, double * cl);
__END_DECLS
#endif /* __GSL_SF_COULOMB_H__ */
|
/* Benjamin DELPY `gentilkiwi`
http://blog.gentilkiwi.com
benjamin@gentilkiwi.com
Licence : https://creativecommons.org/licenses/by/4.0/
*/
#include <windows.h>
int wmain(int argc, wchar_t * argv[]);
void WINAPI ServiceMain(DWORD argc, LPWSTR *argv);
void WINAPI ServiceCtrlHandler(DWORD Opcode);
SERVICE_STATUS m_ServiceStatus = {SERVICE_WIN32_OWN_PROCESS, SERVICE_STOPPED, 0, NO_ERROR, 0, 0, 0};
SERVICE_STATUS_HANDLE m_ServiceStatusHandle = NULL;
HANDLE m_pyrsvcRunning;
PWCHAR z_cmdLine, z_logFile;
const WCHAR PYRSVC_NAME[] = L"pyrsvc", PYRSVC_PRE_CMD[] = L"cmd.exe /c \"", PYRSVC_POST_CMD[] = L"\" > ", PYRSVC_END_CMD[] = L" 2>&1";
int wmain(int argc, wchar_t * argv[])
{
int status = ERROR_SERVICE_NOT_IN_EXE;
const SERVICE_TABLE_ENTRY DispatchTable[]= {{(LPWSTR) PYRSVC_NAME, ServiceMain}, {NULL, NULL}};
if(argc == 3)
{
if(z_cmdLine = _wcsdup(argv[1]))
{
if(z_logFile = _wcsdup(argv[2]))
{
if(m_pyrsvcRunning = CreateEvent(NULL, TRUE, FALSE, NULL))
{
if(StartServiceCtrlDispatcher(DispatchTable))
status = ERROR_SUCCESS;
else status = GetLastError();
CloseHandle(m_pyrsvcRunning);
}
free(z_logFile);
}
free(z_cmdLine);
}
}
return status;
}
void WINAPI ServiceMain(DWORD argc, LPWSTR *argv)
{
STARTUPINFO si = {0};
PROCESS_INFORMATION pi;
PWCHAR arguments;
DWORD size;
si.cb = sizeof(STARTUPINFO);
if(m_ServiceStatusHandle = RegisterServiceCtrlHandler(PYRSVC_NAME, ServiceCtrlHandler))
{
m_ServiceStatus.dwCurrentState = SERVICE_START_PENDING;
SetServiceStatus(m_ServiceStatusHandle, &m_ServiceStatus);
m_ServiceStatus.dwCurrentState = SERVICE_RUNNING;
m_ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
SetServiceStatus(m_ServiceStatusHandle, &m_ServiceStatus);
size = ((ARRAYSIZE(PYRSVC_PRE_CMD) - 1) + lstrlen(z_cmdLine) + (ARRAYSIZE(PYRSVC_POST_CMD) - 1) + lstrlen(z_logFile) + (ARRAYSIZE(PYRSVC_END_CMD) - 1) + 1) * sizeof(WCHAR);
if(arguments = (PWCHAR) malloc(size))
{
memset(arguments, '\0', size);
wcscat_s(arguments, size, PYRSVC_PRE_CMD);
wcscat_s(arguments, size, z_cmdLine);
wcscat_s(arguments, size, PYRSVC_POST_CMD);
wcscat_s(arguments, size, z_logFile);
wcscat_s(arguments, size, PYRSVC_END_CMD);
if(CreateProcess(NULL, arguments, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi))
{
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
}
free(arguments);
}
WaitForSingleObject(m_pyrsvcRunning, INFINITE);
m_ServiceStatus.dwCurrentState = SERVICE_STOPPED;
SetServiceStatus(m_ServiceStatusHandle, &m_ServiceStatus);
}
}
void WINAPI ServiceCtrlHandler(DWORD Opcode)
{
if((Opcode == SERVICE_CONTROL_STOP) || (Opcode == SERVICE_CONTROL_SHUTDOWN))
{
m_ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING;
SetServiceStatus (m_ServiceStatusHandle, &m_ServiceStatus);
SetEvent(m_pyrsvcRunning);
}
}
|
/* This is part of the netCDF package.
Copyright 2005 University Corporation for Atmospheric Research/Unidata
See COPYRIGHT file for conditions of use.
Common includes, defines, etc., for test code in the libsrc4 and
nc_test4 directories.
*/
#ifndef _ERR_MACROS_H
#define _ERR_MACROS_H
#include <config.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
/* Err is used to keep track of errors within each set of tests,
* total_err is the number of errors in the entire test program, which
* generally cosists of several sets of tests. */
int total_err = 0, err = 0;
/* This is handy for print statements. */
char *format_name[] = {"", "classic", "64-bit offset", "netCDF-4",
"netCDF-4 classic model"};
/* This macro prints an error message with line number and name of
* test program. */
#define ERR do { \
fflush(stdout); /* Make sure our stdout is synced with stderr. */ \
err++; \
fprintf(stderr, "Sorry! Unexpected result, %s, line: %d\n", \
__FILE__, __LINE__); \
return 2; \
} while (0)
/* This macro prints an error message with line number and name of
* test program, and then exits the program. */
#define ERR_RET do { \
fflush(stdout); /* Make sure our stdout is synced with stderr. */ \
fprintf(stderr, "Sorry! Unexpected result, %s, line: %d\n", \
__FILE__, __LINE__); \
return 2; \
} while (0)
/* After a set of tests, report the number of errors, and increment
* total_err. */
#define SUMMARIZE_ERR do { \
if (err) \
{ \
printf("%d failures\n", err); \
total_err += err; \
err = 0; \
} \
else \
printf("ok.\n"); \
} while (0)
/* If extra memory debugging is not in use (as it usually isn't),
* define away the nc_exit function, which may be in some tests. */
#ifndef EXTRA_MEM_DEBUG
#define nc_exit()
#endif
/* This macro prints out our total number of errors, if any, and exits
* with a 0 if there are not, or a 2 if there were errors. Make will
* stop if a non-zero value is returned from a test program. */
#define FINAL_RESULTS do { \
if (total_err) \
{ \
printf("%d errors detected! Sorry!\n", total_err); \
return 2; \
} \
printf("*** Tests successful!\n"); \
return 0; \
} while (0)
#endif /* _ERR_MACROS_H */
|
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code 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.
Doom 3 Source Code 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 Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __CINEMATIC_H__
#define __CINEMATIC_H__
/*
===============================================================================
RoQ cinematic
Multiple idCinematics can run simultaniously.
A single idCinematic can be reused for multiple files if desired.
===============================================================================
*/
// cinematic states
typedef enum {
FMV_IDLE,
FMV_PLAY, // play
FMV_EOF, // all other conditions, i.e. stop/EOF/abort
FMV_ID_BLT,
FMV_ID_IDLE,
FMV_LOOPED,
FMV_ID_WAIT
} cinStatus_t;
// a cinematic stream generates an image buffer, which the caller will upload to a texture
typedef struct {
int imageWidth, imageHeight; // will be a power of 2
const byte * image; // RGBA format, alpha will be 255
int status;
} cinData_t;
class idCinematic {
public:
// initialize cinematic play back data
static void InitCinematic( void );
// shutdown cinematic play back data
static void ShutdownCinematic( void );
// allocates and returns a private subclass that implements the methods
// This should be used instead of new
static idCinematic *Alloc();
// frees all allocated memory
virtual ~idCinematic();
// returns false if it failed to load
virtual bool InitFromFile( const char *qpath, bool looping );
// returns the length of the animation in milliseconds
virtual int AnimationLength();
// the pointers in cinData_t will remain valid until the next UpdateForTime() call
virtual cinData_t ImageForTime( int milliseconds );
// closes the file and frees all allocated memory
virtual void Close();
// closes the file and frees all allocated memory
virtual void ResetTime(int time);
};
/*
===============================================
Sound meter.
===============================================
*/
class idSndWindow : public idCinematic {
public:
idSndWindow() { showWaveform = false; }
~idSndWindow() {}
bool InitFromFile( const char *qpath, bool looping );
cinData_t ImageForTime( int milliseconds );
int AnimationLength();
private:
bool showWaveform;
};
#endif /* !__CINEMATIC_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[3];
atomic_int atom_0_r1_1;
atomic_int atom_1_r1_1;
void *t0(void *arg){
label_1:;
int v2_r1 = atomic_load_explicit(&vars[0], memory_order_seq_cst);
int v3_r3 = v2_r1 ^ v2_r1;
int v4_r3 = v3_r3 + 1;
atomic_store_explicit(&vars[1], v4_r3, memory_order_seq_cst);
int v15 = (v2_r1 == 1);
atomic_store_explicit(&atom_0_r1_1, v15, memory_order_seq_cst);
return NULL;
}
void *t1(void *arg){
label_2:;
int v6_r1 = atomic_load_explicit(&vars[1], memory_order_seq_cst);
int v8_r3 = atomic_load_explicit(&vars[1], memory_order_seq_cst);
int v9_cmpeq = (v8_r3 == v8_r3);
if (v9_cmpeq) goto lbl_LC00; else goto lbl_LC00;
lbl_LC00:;
atomic_store_explicit(&vars[2], 1, memory_order_seq_cst);
int v11_r6 = atomic_load_explicit(&vars[2], memory_order_seq_cst);
atomic_store_explicit(&vars[0], 1, memory_order_seq_cst);
int v16 = (v6_r1 == 1);
atomic_store_explicit(&atom_1_r1_1, v16, memory_order_seq_cst);
return NULL;
}
int main(int argc, char *argv[]){
pthread_t thr0;
pthread_t thr1;
atomic_init(&vars[0], 0);
atomic_init(&vars[1], 0);
atomic_init(&vars[2], 0);
atomic_init(&atom_0_r1_1, 0);
atomic_init(&atom_1_r1_1, 0);
pthread_create(&thr0, NULL, t0, NULL);
pthread_create(&thr1, NULL, t1, NULL);
pthread_join(thr0, NULL);
pthread_join(thr1, NULL);
int v12 = atomic_load_explicit(&atom_0_r1_1, memory_order_seq_cst);
int v13 = atomic_load_explicit(&atom_1_r1_1, memory_order_seq_cst);
int v14_conj = v12 & v13;
if (v14_conj == 1) assert(0);
return 0;
}
|
#ifndef CUBE_E_CONFIG_H
#define CUBE_E_CONFIG_H
#include "Common.h"
#include "HafniumCommon.h"
#include <vector>
#include <string>
#include <iostream>
class Abs_Abstract;
class LuaStatus;
typedef void (* LuaLoadCallback) (LuaStatus&);
class ConfigManger {
public:
LuaStatus *ConfigState = nullptr;
ConfigManger(LuaStatus &state);
void loadConfigFrom(const char *filename);
void load() { }
static void LUA_loadTexture(ConfigManger *self, luabridge::LuaRef name, luabridge::LuaRef args) { self->loadTexture(name, args); }
static void LUA_loadObject(ConfigManger *self, luabridge::LuaRef name, luabridge::LuaRef args) { self->loadObject(name, args); }
void loadTexture(std::string name, luabridge::LuaRef args);
void loadObject(std::string name, luabridge::LuaRef args);
luabridge::LuaRef getObject(std::string name);
};
class LuaStatus {
public:
lua_State *State = nullptr;
bool _loaded = false;
std::vector<std::string> files;
operator lua_State *() {LOGFUNC; return State; }
void load(const char *filename, LuaLoadCallback callback = nullptr);
bool loaded(const char *filename);
void init();
void dispose() {LOGFUNC;
if (_loaded) lua_close(State);
}
};
class EventManger {
public:
static EventManger *instance;
static inline EventManger &GetInstance() {LOGFUNC; return *instance; }
const static size_t EventCounts = 15;
enum Events {
ANIM_UPDATE,
ANIM_CREATE,
TEST_BEGIN,
GAME_UPDATE_BEGIN,
ANIM_SPAWN,
UI_KEYPRESS,
UI_KEYRELEASE,
UI_MOUSEPRESS,
UI_MOUSERELEASE,
UI_MOUSEMOVE,
TECHNOTYPE_LOAD,
TECHNO_UPDATE,
TECHNO_SPAWN,
TECHNO_CREATE,
TECHNO_PHYUPDATE
};
LuaStatus *_state = nullptr;
luabridge::LuaRef FunctionTable;
luabridge::LuaRef ObjectsTable;
// luabridge::LuaRef LuaObjects[EventCounts];
std::vector<luabridge::LuaRef> _Events;
std::vector<std::string> _EventsName;
luabridge::LuaRef CreateObjectTable(Abs_Abstract &src);
luabridge::LuaRef GetObjectTable(Abs_Abstract &src);
void DestroyObjectTable(Abs_Abstract &src);
luabridge::LuaRef &GetEvent(Events type);
EventManger(LuaStatus &State);
private:
void inline addEvent(std::string funcName) {LOGFUNC; _Events.push_back(FunctionTable[funcName]); _EventsName.push_back(funcName); }
};
#include "Abstract.h"
#endif
|
/* 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_2_r4_3;
atomic_int atom_2_r1_1;
void *t0(void *arg){
label_1:;
atomic_store_explicit(&vars[0], 4, memory_order_seq_cst);
atomic_store_explicit(&vars[1], 1, memory_order_seq_cst);
return NULL;
}
void *t1(void *arg){
label_2:;
atomic_store_explicit(&vars[1], 2, memory_order_seq_cst);
int v2_r3 = atomic_load_explicit(&vars[1], memory_order_seq_cst);
int v3_r4 = v2_r3 ^ v2_r3;
int v4_r4 = v3_r4 + 1;
atomic_store_explicit(&vars[0], v4_r4, memory_order_seq_cst);
atomic_store_explicit(&vars[0], 3, memory_order_seq_cst);
return NULL;
}
void *t2(void *arg){
label_3:;
int v6_r1 = atomic_load_explicit(&vars[0], memory_order_seq_cst);
atomic_store_explicit(&vars[0], 2, memory_order_seq_cst);
int v8_r4 = atomic_load_explicit(&vars[0], memory_order_seq_cst);
int v18 = (v8_r4 == 3);
atomic_store_explicit(&atom_2_r4_3, v18, memory_order_seq_cst);
int v19 = (v6_r1 == 1);
atomic_store_explicit(&atom_2_r1_1, v19, 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_2_r4_3, 0);
atomic_init(&atom_2_r1_1, 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 v9 = atomic_load_explicit(&vars[1], memory_order_seq_cst);
int v10 = (v9 == 2);
int v11 = atomic_load_explicit(&vars[0], memory_order_seq_cst);
int v12 = (v11 == 4);
int v13 = atomic_load_explicit(&atom_2_r4_3, memory_order_seq_cst);
int v14 = atomic_load_explicit(&atom_2_r1_1, memory_order_seq_cst);
int v15_conj = v13 & v14;
int v16_conj = v12 & v15_conj;
int v17_conj = v10 & v16_conj;
if (v17_conj == 1) assert(0);
return 0;
}
|
#ifndef EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif
#include <string>
namespace RIVET_YAML {
enum EMITTER_MANIP {
// general manipulators
Auto,
TagByKind,
Newline,
// output character set
EmitNonAscii,
EscapeNonAscii,
// string manipulators
// Auto, // duplicate
SingleQuoted,
DoubleQuoted,
Literal,
// bool manipulators
YesNoBool, // yes, no
TrueFalseBool, // true, false
OnOffBool, // on, off
UpperCase, // TRUE, N
LowerCase, // f, yes
CamelCase, // No, Off
LongBool, // yes, On
ShortBool, // y, t
// int manipulators
Dec,
Hex,
Oct,
// document manipulators
BeginDoc,
EndDoc,
// sequence manipulators
BeginSeq,
EndSeq,
Flow,
Block,
// map manipulators
BeginMap,
EndMap,
Key,
Value,
// Flow, // duplicate
// Block, // duplicate
// Auto, // duplicate
LongKey
};
struct _Indent {
_Indent(int value_) : value(value_) {}
int value;
};
inline _Indent Indent(int value) { return _Indent(value); }
struct _Alias {
_Alias(const std::string& content_) : content(content_) {}
std::string content;
};
inline _Alias Alias(const std::string content) { return _Alias(content); }
struct _Anchor {
_Anchor(const std::string& content_) : content(content_) {}
std::string content;
};
inline _Anchor Anchor(const std::string content) { return _Anchor(content); }
struct _Tag {
struct Type {
enum value { Verbatim, PrimaryHandle, NamedHandle };
};
explicit _Tag(const std::string& prefix_, const std::string& content_,
Type::value type_)
: prefix(prefix_), content(content_), type(type_) {}
std::string prefix;
std::string content;
Type::value type;
};
inline _Tag VerbatimTag(const std::string content) {
return _Tag("", content, _Tag::Type::Verbatim);
}
inline _Tag LocalTag(const std::string content) {
return _Tag("", content, _Tag::Type::PrimaryHandle);
}
inline _Tag LocalTag(const std::string& prefix, const std::string content) {
return _Tag(prefix, content, _Tag::Type::NamedHandle);
}
inline _Tag SecondaryTag(const std::string content) {
return _Tag("", content, _Tag::Type::NamedHandle);
}
struct _Comment {
_Comment(const std::string& content_) : content(content_) {}
std::string content;
};
inline _Comment Comment(const std::string content) { return _Comment(content); }
struct _Precision {
_Precision(int floatPrecision_, int doublePrecision_)
: floatPrecision(floatPrecision_), doublePrecision(doublePrecision_) {}
int floatPrecision;
int doublePrecision;
};
inline _Precision FloatPrecision(int n) { return _Precision(n, -1); }
inline _Precision DoublePrecision(int n) { return _Precision(-1, n); }
inline _Precision Precision(int n) { return _Precision(n, n); }
}
#endif // EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
/*************************************************************************
* timesub.c -- subtracts two timeval structs
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "timesub.h"
/**********************************************************************
* timeval_subtract
*
* subtracts times x and y and stores it in result
* returns 1 if result is negative
**********************************************************************/
int
timeval_subtract (struct timeval * result, struct timeval *x, struct timeval *y)
{
/* Perform the carry for the later subtraction by updating y. */
if (x->tv_usec < y->tv_usec) {
int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
y->tv_usec -= 1000000 * nsec;
y->tv_sec += nsec;
}
if (x->tv_usec - y->tv_usec > 1000000) {
int nsec = (x->tv_usec - y->tv_usec) / 1000000;
y->tv_usec += 1000000 * nsec;
y->tv_sec -= nsec;
}
/* Compute the time remaining to wait.
tv_usec is certainly positive. */
result->tv_sec = x->tv_sec - y->tv_sec;
result->tv_usec = x->tv_usec - y->tv_usec;
/* Return 1 if result is negative. */
return x->tv_sec < y->tv_sec;
}
|
/**
* \file
*
* Copyright (c) 2015 Atmel Corporation. All rights reserved.
*
* \asf_license_start
*
* \page License
*
* 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. The name of Atmel may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 4. This software may only be redistributed and used in connection with an
* Atmel microcontroller product.
*
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
*
* \asf_license_stop
*
*/
/*
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
*/
#ifndef _SAMV70_RSTC_INSTANCE_
#define _SAMV70_RSTC_INSTANCE_
/* ========== Register definition for RSTC peripheral ========== */
#if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
#define REG_RSTC_CR (0x400E1800U) /**< \brief (RSTC) Control Register */
#define REG_RSTC_SR (0x400E1804U) /**< \brief (RSTC) Status Register */
#define REG_RSTC_MR (0x400E1808U) /**< \brief (RSTC) Mode Register */
#else
#define REG_RSTC_CR (*(__O uint32_t*)0x400E1800U) /**< \brief (RSTC) Control Register */
#define REG_RSTC_SR (*(__I uint32_t*)0x400E1804U) /**< \brief (RSTC) Status Register */
#define REG_RSTC_MR (*(__IO uint32_t*)0x400E1808U) /**< \brief (RSTC) Mode Register */
#endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
#endif /* _SAMV70_RSTC_INSTANCE_ */
|
/*++
Copyright (c) 2011 Microsoft Corporation
Module Name:
filter_model_converter.h
Abstract:
Filter decls from a model
Author:
Leonardo (leonardo) 2011-05-06
Notes:
--*/
#ifndef _FILTER_MODEL_CONVERTER_H_
#define _FILTER_MODEL_CONVERTER_H_
#include"model_converter.h"
class filter_model_converter : public model_converter {
func_decl_ref_vector m_decls;
public:
filter_model_converter(ast_manager & m):m_decls(m) {}
virtual ~filter_model_converter();
ast_manager & m() const { return m_decls.get_manager(); }
virtual void operator()(model_ref & md, unsigned goal_idx);
virtual void operator()(model_ref & md) { operator()(md, 0); } // TODO: delete
virtual void cancel() {}
virtual void display(std::ostream & out);
void insert(func_decl * d) {
m_decls.push_back(d);
}
virtual model_converter * translate(ast_translation & translator);
};
#endif
|
/************************************************
*
* Copyright © 2009-2010 Florian Staudacher
* <florian_staudacher@yahoo.de>
*
*
* This file is part of FSugar.
*
* FSugar 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.
*
* FSugar 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 FSugar. If not, see <http://www.gnu.org/licenses/>.
*
***********************************************/
#ifndef ABSTRACTITEM_H
#define ABSTRACTITEM_H
#include <QtCore>
#include "note.h"
class AbstractItem : public QObject
{
Q_OBJECT
public:
explicit AbstractItem(QObject *parent = 0);
QString id, description, category, type;
QDateTime date_entered, date_modified;
virtual QList<Note*>* getNotesList();
QList<Note*> notes;
SugarCrm *crm;
signals:
void saved();
void notesAvailable();
public slots:
virtual void save() = 0;
void populateNotes(QString _id);
void getChildren();
void getNotes();
void gotCreated(QString _id);
void seeWhoSaved(QString _id);
QString toString();
protected:
void useAttribute(const QString _attr, const QString _type);
};
#endif // ABSTRACTITEM_H
|
//============================================================================
// Name : RTT_Server.cpp
// Author : AltF4
// Copyright : 2011, GNU GPLv3
// Description : RTT Game Server
//============================================================================
#ifndef LOF_SERVER_H_
#define LOF_SERVER_H_
#include <vector>
#include "Action.h"
#include "Match.h"
#include "messaging/messages/LobbyMessage.h"
#include "messaging/messages/AuthMessage.h"
#include "messaging/messages/MatchLobbyMessage.h"
#include <google/dense_hash_map>
#define CHARGE_MAX 100
//TODO: Read this from config file
#define MATCHES_PER_PAGE 10
//TODO: Read this from config file
#define MAX_PLAYERS_IN_MATCH 8
#define SERVER_VERSION_MAJOR 0
#define SERVER_VERSION_MINOR 0
#define SERVER_VERSION_REV 1
#define DEFAULT_SERVER_PORT 23000
namespace RTT
{
struct eqint
{
bool operator()(int s1, int s2) const
{
return (s1 == s2);
}
};
//Define types, so it's easier to refer to later
//Key : Player ID
typedef google::dense_hash_map<int, Player*, std::tr1::hash<int>, eqint> PlayerList;
//Key : Match unique ID
typedef google::dense_hash_map<int, Match*, std::tr1::hash<int>, eqint> MatchList;
std::string Usage();
void ProcessRound(Match *match);
void *MainListen(void * param);
void *MainClientThread(void * parm);
//Gets match descriptions from the matchlist
// page: specifies which block of matches to get
// descArray: output array where matches are written to
// Returns: The number of matches written
uint GetMatchDescriptions(uint page, MatchDescription *descArray);
//Gets match descriptions from the playerlist
// matchID: What match to get the players from
// descArray: output array where matches are written to
// (Length = MAX_PLAYERS_IN_MATCH)
// Returns: The number of matches written
uint GetPlayerDescriptions(uint matchID, PlayerDescription *descArray);
//Creates a new match and places it into matchList
// Returns: The unique ID of the new match
uint RegisterNewMatch(Player *player, struct MatchOptions options);
//Make player join specified match
// Sets the variables within player and match properly
// Returns an enum of the success or failure condition
enum LobbyResult JoinMatch(Player *player, uint matchID);
//Make player leave specified match
// Sets the variables within player and match properly
// Returns success or failure
bool LeaveMatch(Player *player);
}
#endif /* LOF_SERVER_H_ */
|
/************************************************************************************************************************/
/** A Compiler for a subset of Oberon **/
/** authors: **/
/** ROCHA, Rodrigo Caetano de Oliveira (rcor) **/
/** FERREIRA, Wallace Dias **/
/************************************************************************************************************************/
#ifndef ARCHITECTURE_X64_H
#define ARCHITECTURE_X64_H
#include "machine_code.h"
#include "register_descriptor.h"
#include "variable_descriptor.h"
#include "../../ast/expression/arithmetic_operator.h"
#include "../intermediate/intermediate_code.h"
#include "../intermediate/instruction/instruction.h"
#include "../intermediate/instruction/arithmetic_instruction.h"
#include "../intermediate/instruction/copy_instruction.h"
#include "../intermediate/instruction/negation_instruction.h"
#include "../intermediate/instruction/write_instruction.h"
#include "../intermediate/instruction/read_instruction.h"
#include "../intermediate/instruction/parameter_instruction.h"
#include "../intermediate/instruction/call_instruction.h"
#include "../intermediate/instruction/nop_instruction.h"
#include "../intermediate/instruction/goto_instruction.h"
#include "../intermediate/instruction/conditional_goto_instruction.h"
#include "../intermediate/instruction_argument/identifier_argument.h"
#include "../intermediate/instruction_argument/label_argument.h"
#include "../intermediate/instruction_argument/instruction_label.h"
#include "../intermediate/instruction_argument/immediate_argument.h"
#include "../intermediate/instruction_argument/instruction_argument.h"
#include "../intermediate/instruction_argument/string_argument.h"
#include "../intermediate/instruction_argument/argument_information.h"
#include "../../symbol_table/symbol_table.h"
#include "../../symbol_table/identifier_category/function_information.h"
#include "../../symbol_table/identifier_category/formal_parameter_information.h"
#include "../../symbol_table/identifier_category/variable_information.h"
#include "../../symbol_table/identifier_information.h"
#include "../../util/integer_hash_table.h"
#include "../../debugger/debugger_utils.h"
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <list>
#include <fstream>
using namespace std;
#define NO_REGISTER -1
//#ifdef WORD_SIZE
//#undef WORD_SIZE
//#endif
//#define WORD_SIZE 8
class X64Architecture : public MachineCode
{
public:
static const int WORD_SIZE = 8;
X64Architecture(SymbolTable * symbolTable, IntermediateCode * intermediateCode);
void generateCode();
protected:
//string getVariableAddress(IdentifierArgument *identifierArgument);
void initDescriptorTables();
private:
void optmiseArithmeticInstruction(Instruction * instruction);
void optmiseConditionalInstruction(Instruction * instruction);
string getMachineString(string str);
string getMachineString(const char *c_str);
string getStringLabel(string str);
string getStringLabel(const char *c_str);
int getOffset(IdentifierInformation *identifierInformation);
void genStartingCode();
string getRegister(int index);
int getTotalRegisters();
string getMachineImmediate(long immediate);
vector<int> *getRegisters(Instruction *instruction); //FAZER AQUI
int getEmptyRegister(list<int> *avoidList = 0, list<int> *avoidSecondList = 0); //FAZER AQUI
string getVariableAddress(IdentifierInformation *identifierInformation);
string getFunctionLabel(IdentifierInformation * functionInfo);
string getFunctionLabel(const char *functionName);
string getFunctionLabel(string functionName);
void genInstruction(Instruction *instruction);
void genWrite(WriteInstruction *instruction);
void genRead(ReadInstruction *instruction);
void genArithmetic(ArithmeticInstruction *instruction);
void genGoto(GotoInstruction *instruction);
void genConditionalGoto(ConditionalGotoInstruction *instruction);
void genNop(NopInstruction *instruction);
void genLoad(IdentifierInformation *identifierInformation, int registerNumber);
void genStore(int registerNumber, IdentifierInformation *identifierInformation);
void genCopy(CopyInstruction *copyInstruction);
void genNegation(NegationInstruction *negationInstruction);
string getMachineInstructionLabel(int labelNumber);
void genLabel(const char *label);
void genLabel(string label);
void genWrite(const char *str);
void genWrite(IdentifierInformation *identifierInformation);
void genWrite(int registerNumber);
void genRead(IdentifierInformation *identifierInformation);
void genMove(long immediate, int reg);
void genParam(ParameterInstruction * paramInstruction);
void genCall(CallInstruction * callInstruction);
//void initDescriptorTables();
void genPrologue(FunctionInformation * functionInfo);
void genEpilogue(FunctionInformation * functionInfo);
void updateVariablesStatus(Instruction * instruction);
void allocateArithmeticInstructionRegisters(Instruction * instruction, vector<int> * regs);
vector<string> registers_;
};
#endif
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.