text stringlengths 4 6.14k |
|---|
/* $NetBSD: un.h,v 1.46 2011/06/26 16:43:12 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)un.h 8.3 (Berkeley) 2/19/95
*/
#ifndef _SYS_UN_H_
#define _SYS_UN_H_
#include <special_includes/sys/ansi.h>
#include <special_includes/sys/featuretest.h>
#include <special_includes/sys/types.h>
#ifndef sa_family_t
typedef __sa_family_t sa_family_t;
#define sa_family_t __sa_family_t
#endif
/*
* Definitions for UNIX IPC domain.
*/
struct sockaddr_un {
uint8_t sun_len; /* total sockaddr length */
sa_family_t sun_family; /* AF_LOCAL */
char sun_path[104]; /* path name (gag) */
};
/*
* Socket options for UNIX IPC domain.
*/
#if defined(_NETBSD_SOURCE)
#define LOCAL_CREDS 0x0001 /* pass credentials to receiver */
#define LOCAL_CONNWAIT 0x0002 /* connects block until accepted */
#define LOCAL_PEEREID 0x0003 /* get peer identification */
#endif
/*
* Data automatically stored inside connect() for use by LOCAL_PEEREID
*/
struct unpcbid {
pid_t unp_pid; /* process id */
uid_t unp_euid; /* effective user id */
gid_t unp_egid; /* effective group id */
};
#ifdef _KERNEL
struct unpcb;
struct socket;
struct sockopt;
int uipc_usrreq(struct socket *, int, struct mbuf *,
struct mbuf *, struct mbuf *, struct lwp *);
int uipc_ctloutput(int, struct socket *, struct sockopt *);
void uipc_init (void);
kmutex_t *uipc_dgramlock (void);
kmutex_t *uipc_streamlock (void);
kmutex_t *uipc_rawlock (void);
int unp_attach (struct socket *);
int unp_bind (struct socket *, struct mbuf *, struct lwp *);
int unp_connect (struct socket *, struct mbuf *, struct lwp *);
int unp_connect2 (struct socket *, struct socket *, int);
void unp_detach (struct unpcb *);
void unp_discard (struct file *);
void unp_disconnect (struct unpcb *);
bool unp_drop (struct unpcb *, int);
void unp_shutdown (struct unpcb *);
int unp_externalize (struct mbuf *, struct lwp *, int);
int unp_internalize (struct mbuf **);
void unp_dispose (struct mbuf *);
int unp_output (struct mbuf *, struct mbuf *, struct unpcb *,
struct lwp *);
void unp_setaddr (struct socket *, struct mbuf *, bool);
#else /* !_KERNEL */
/* actual length of an initialized sockaddr_un */
#if defined(_NETBSD_SOURCE)
#define SUN_LEN(su) \
(sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
#endif /* !_NetBSD_SOURCE */
#endif /* _KERNEL */
#endif /* !_SYS_UN_H_ */
|
//
// PROJECT CHRONO - http://projectchrono.org
//
// Copyright (c) 2013 Project Chrono
// All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file at the top level of the distribution
// and at http://projectchrono.org/license-chrono.txt.
//
#ifndef CHITERATIVEAPGD_H
#define CHITERATIVEAPGD_H
//////////////////////////////////////////////////
//
// ChLcpIterativeAPGD.h
//
// An iterative solver based on Nesterov's
// Projected Gradient Descent
//
// HEADER file for CHRONO HYPEROCTANT LCP solver
//
// ------------------------------------------------
// www.deltaknowledge.com
// ------------------------------------------------
///////////////////////////////////////////////////
#include "ChLcpIterativeSolver.h"
namespace chrono {
/// An iterative solver based on Nesterov's
/// Projected Gradient Descent.
/// The problem is described by an LCP of type
///
/// | M -Cq'|*|q|- | f|= |0| , c>=0, l>=0, l*c=0;
/// | Cq 0 | |l| |-b| |c|
///
/// or similar CCP problem.
class ChApi ChIterativeAPGD : public ChLcpIterativeSolver {
// Chrono RTTI, needed for serialization
CH_RTTI(ChIterativeAPGD, ChLcpIterativeSolver);
protected:
//
// DATA
//
double residual;
int nc;
ChMatrixDynamic<> gamma_hat, gammaNew, g, y, gamma, yNew, r, tmp;
public:
//
// CONSTRUCTORS
//
ChIterativeAPGD(int mmax_iters = 1000, ///< max.number of iterations
bool mwarm_start = false, ///< uses warm start?
double mtolerance = 0.0 ///< tolerance for termination criterion
)
: ChLcpIterativeSolver(mmax_iters, mwarm_start, mtolerance, 0.0001){
};
virtual ~ChIterativeAPGD(){};
//
// FUNCTIONS
//
// Performs the solution of the LCP.
virtual double Solve(ChLcpSystemDescriptor& sysd);
void ShurBvectorCompute(ChLcpSystemDescriptor& sysd);
double Res4(ChLcpSystemDescriptor& sysd);
double GetResidual() { return residual; }
void Dump_Rhs(std::vector<double>& temp) {
for (int i = 0; i < r.GetRows(); i++) {
temp.push_back(r(i, 0));
}
}
void Dump_Lambda(std::vector<double>& temp) {
for (int i = 0; i < gamma_hat.GetRows(); i++) {
temp.push_back(gamma_hat(i, 0));
}
}
};
} // END_OF_NAMESPACE____
#endif // END of ChLcpIterativeAPGD.h |
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_AUTOFILL_FIELD_TYPES_H_
#define CHROME_BROWSER_AUTOFILL_FIELD_TYPES_H_
#pragma once
#include <set>
enum AddressType {
kGenericAddress = 0,
kBillingAddress,
kShippingAddress
};
// NOTE: This list MUST not be modified. The server aggregates and stores these
// types over several versions, so we must remain fully compatible with the
// Autofill server, which is itself backward-compatible. The list must be kept
// up to date with the Autofill server list.
//
// This is the list of all valid field types.
enum AutofillFieldType {
// Server indication that it has no data for the requested field.
NO_SERVER_DATA = 0,
// Client indication that the text entered did not match anything in the
// personal data.
UNKNOWN_TYPE = 1,
// The "empty" type indicates that the user hasn't entered anything
// in this field.
EMPTY_TYPE = 2,
// Personal Information categorization types.
NAME_FIRST = 3,
NAME_MIDDLE = 4,
NAME_LAST = 5,
NAME_MIDDLE_INITIAL = 6,
NAME_FULL = 7,
NAME_SUFFIX = 8,
EMAIL_ADDRESS = 9,
PHONE_HOME_NUMBER = 10,
PHONE_HOME_CITY_CODE = 11,
PHONE_HOME_COUNTRY_CODE = 12,
PHONE_HOME_CITY_AND_NUMBER = 13,
PHONE_HOME_WHOLE_NUMBER = 14,
// Work phone numbers (values [15,19]) are deprecated.
PHONE_FAX_NUMBER = 20,
PHONE_FAX_CITY_CODE = 21,
PHONE_FAX_COUNTRY_CODE = 22,
PHONE_FAX_CITY_AND_NUMBER = 23,
PHONE_FAX_WHOLE_NUMBER = 24,
// Cell phone numbers (values [25, 29]) are deprecated.
ADDRESS_HOME_LINE1 = 30,
ADDRESS_HOME_LINE2 = 31,
ADDRESS_HOME_APT_NUM = 32,
ADDRESS_HOME_CITY = 33,
ADDRESS_HOME_STATE = 34,
ADDRESS_HOME_ZIP = 35,
ADDRESS_HOME_COUNTRY = 36,
ADDRESS_BILLING_LINE1 = 37,
ADDRESS_BILLING_LINE2 = 38,
ADDRESS_BILLING_APT_NUM = 39,
ADDRESS_BILLING_CITY = 40,
ADDRESS_BILLING_STATE = 41,
ADDRESS_BILLING_ZIP = 42,
ADDRESS_BILLING_COUNTRY = 43,
// ADDRESS_SHIPPING values [44,50] are deprecated.
CREDIT_CARD_NAME = 51,
CREDIT_CARD_NUMBER = 52,
CREDIT_CARD_EXP_MONTH = 53,
CREDIT_CARD_EXP_2_DIGIT_YEAR = 54,
CREDIT_CARD_EXP_4_DIGIT_YEAR = 55,
CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR = 56,
CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR = 57,
CREDIT_CARD_TYPE = 58,
CREDIT_CARD_VERIFICATION_CODE = 59,
COMPANY_NAME = 60,
// No new types can be added.
MAX_VALID_FIELD_TYPE = 61,
};
typedef std::set<AutofillFieldType> FieldTypeSet;
#endif // CHROME_BROWSER_AUTOFILL_FIELD_TYPES_H_
|
/*
* Copyright (c) 2010 People Power Company
* All rights reserved.
*
* This open source code was developed with funding from People Power Company
*
* 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 People Power Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* PEOPLE POWER CO. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE
*/
#ifndef GADGETMANAGER_H
#define GADGETMANAGER_H
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdbool.h>
#include "eui64.h"
#include "ioterror.h"
/**
* Maximum number of gadgets can be set at compile time
*/
#ifndef GADGET_MAX_DEVICES
#define GADGET_MAX_DEVICES 8
#endif
/** Amount of time after we haven't heard from an gadget that we think it's dead */
#define GADGET_DEATH_PERIOD_SEC 600
/**
* Information about each gadget
*/
typedef struct gadget_t {
/** True if this slot is in use */
bool inUse;
/** True if this gadget's measurements have been updated recently */
bool measurementsUpdated;
/** Time of the last successful measurement */
struct timeval lastTouchTime;
/** IP address of the gadget */
char ip[INET6_ADDRSTRLEN];
/** Unique device ID */
char uuid[EUI64_STRING_SIZE];
/** Model description of the gadget */
char model[32];
/** Firmware version */
char firmwareVersion[8];
/** True if the outlet is on */
bool isOn;
/** Current in amps */
double current_amps;
/** Power in watts */
double power_watts;
/** Voltage */
double voltage;
/** Power factor */
int powerFactor;
/** Accumulated energy in watt-hours */
double energy_wh;
} gadget_t;
/***************** Public Prototypes ****************/
error_t gadgetmanager_add(gadget_t *gadget);
gadget_t *gadgetmanager_getByIp(const char *ip);
gadget_t *gadgetmanager_getByUuid(const char *uuid);
int gadgetmanager_size();
gadget_t *gadgetmanager_get(int index);
void gadgetmanager_garbageCollection();
#endif
|
/*
* Copyright 2018 Kunlin Yu <yukunlin@mail.ustc.edu.cn>
*/
#ifndef PGSLAM_LASERSCAN_H_
#define PGSLAM_LASERSCAN_H_
#include <vector>
#include <Eigen/Eigen>
#include "pgslam/pose2d.h"
namespace pgslam {
class Echo {
private:
double range_;
double angle_;
double intensity_;
int64_t time_stamp_;
public:
Echo(double range, double angle, double intensity, int64_t time_stamp);
double range() const;
double angle() const;
double intensity() const;
int64_t time_stamp() const;
Eigen::Vector2d point() const;
};
class LaserScan {
public:
explicit LaserScan(std::vector<Echo> echos);
LaserScan(std::vector<Echo> echos, Pose2D pose);
Pose2D pose() const;
void set_pose(Pose2D pose);
const Eigen::Matrix2Xd& points();
Pose2D ICP(const LaserScan &scan, double *ratio);
double max_x_in_world();
double min_x_in_world();
double max_y_in_world();
double min_y_in_world();
private:
void UpdateToWorld();
private:
Eigen::Matrix2Xd points_;
Eigen::Matrix2Xd points_world_;
Pose2D pose_;
bool world_transformed_flag_;
double max_x_;
double min_x_;
double max_y_;
double min_y_;
double match_threshold_;
double dist_threshold_;
};
} // namespace pgslam
#endif // PGSLAM_LASERSCAN_H_
|
/****************************************************************************
* Copyright (c) 2016, Christopher Karle
* 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 author 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, AUTHOR OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
****************************************************************************/
#ifndef LIBC_GLUE_H
#define LIBC_GLUE_H
#include "char_dev.h"
/****************************************************************************
*
****************************************************************************/
#ifndef TASK_CONSOLE_ID
#define TASK_CONSOLE_ID -1
#endif
/****************************************************************************
*
****************************************************************************/
void libcInit(CharDev* dev);
#endif
|
/* This file is part of the YAZ toolkit.
* Copyright (C) Index Data
* See the file LICENSE for details.
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <yaz/options.h>
#include <yaz/querytowrbuf.h>
#include <yaz/xmlquery.h>
#include <yaz/pquery.h>
#include <yaz/test.h>
#if YAZ_HAVE_XML2
#include <libxml/parser.h>
#endif
static char *prog = "yaz-xmlquery";
#if YAZ_HAVE_XML2
void pqftoxmlquery(const char *pqf)
{
YAZ_PQF_Parser parser = yaz_pqf_create();
ODR odr = odr_createmem(ODR_ENCODE);
Z_RPNQuery *rpn;
if (!parser)
{
fprintf(stderr, "%s: cannot create parser\n", prog);
exit(1);
}
if (!odr)
{
fprintf(stderr, "%s: cannot create parser\n", prog);
exit(1);
}
rpn = yaz_pqf_parse(parser, odr, pqf);
yaz_pqf_destroy(parser);
if (!rpn)
{
fprintf(stderr, "%s: pqf parse error for query %s\n", prog, pqf);
exit(2);
}
else
{
xmlDocPtr doc = 0;
yaz_rpnquery2xml(rpn, &doc);
if (!doc)
{
fprintf(stderr, "%s: yaz_rpnquery2xml failed for query %s\n",
prog, pqf);
exit(3);
}
else
{
xmlChar *buf_out = 0;
int len_out = 0;
xmlDocDumpMemory(doc, &buf_out, &len_out);
if (!len_out || !buf_out)
{
fprintf(stderr, "%s: xmlDocDumpMemory failed for query %s\n",
prog, pqf);
exit(4);
}
else
{
if (fwrite(buf_out, len_out, 1, stdout) != 1)
{
fprintf(stderr, "%s: write failed\n", prog);
exit(5);
}
}
xmlFreeDoc(doc);
}
}
odr_destroy(odr);
}
void xmlquerytopqf(const char *xmlstr)
{
xmlDocPtr doc;
doc = xmlParseMemory(xmlstr, strlen(xmlstr));
if (!doc)
{
fprintf(stderr, "%s: xml parse error for XML:\n%s\n", prog, xmlstr);
exit(1);
}
else
{
int error_code = 0;
const char *addinfo = 0;
Z_Query *query = 0;
ODR odr = odr_createmem(ODR_ENCODE);
const xmlNode *root_element = xmlDocGetRootElement(doc);
yaz_xml2query(root_element, &query, odr, &error_code, &addinfo);
if (error_code)
{
fprintf(stderr, "%s: yaz_xml2query failed code=%d addinfo=%s\n",
prog, error_code, addinfo);
exit(1);
}
else if (!query)
{
fprintf(stderr, "%s: yaz_xml2query no query result\n",
prog);
exit(1);
}
else
{
WRBUF w = wrbuf_alloc();
yaz_query_to_wrbuf(w, query);
printf("%s\n", wrbuf_cstr(w));
wrbuf_destroy(w);
}
odr_destroy(odr);
xmlFreeDoc(doc);
}
}
void xmlfiletopqf(const char *xmlfile)
{
long sz;
char *xmlstr;
FILE *f = fopen(xmlfile, "rb");
if (!f)
{
fprintf(stderr, "%s: cannot open %s\n", prog, xmlfile);
exit(1);
}
fseek(f, 0, SEEK_END);
sz = ftell(f);
if (sz <= 0 || sz >= 1<<18)
{
fprintf(stderr, "%s: bad size for file %s\n", prog, xmlfile);
exit(1);
}
rewind(f);
xmlstr = (char *) xmalloc(sz+1);
xmlstr[sz] = '\0';
if (fread(xmlstr, sz, 1, f) != 1)
{
fprintf(stderr, "%s: read failed for file %s\n", prog, xmlfile);
exit(1);
}
if (fclose(f))
{
fprintf(stderr, "%s: close failed for file %s\n", prog, xmlfile);
exit(1);
}
xmlquerytopqf(xmlstr);
xfree(xmlstr);
}
#endif
void usage(void)
{
fprintf(stderr, "%s [-p pqf] [-x xmlfile]\n", prog);
fprintf(stderr, " -p pqf reads pqf. write xml to stdout\n");
fprintf(stderr, " -x xmlfile reads XML from file. write pqf to stdout\n");
exit(1);
}
int main (int argc, char **argv)
{
#if YAZ_HAVE_XML2
char *arg;
int r;
int active = 0;
while ((r = options("-p:x:", argv, argc, &arg)) != -2)
{
switch(r)
{
case 'p':
pqftoxmlquery(arg);
active = 1;
break;
case 'x':
xmlfiletopqf(arg);
active = 1;
break;
case 0:
break;
}
}
if (!active)
{
fprintf(stderr, "%s: nothing to do\n", prog);
usage();
}
#else
fprintf(stderr, "%s: XML support not enabled.\n", prog);
exit(1);
#endif
return 0;
}
|
// This file is part of MANTIS OS, Operating System
// See http://mantis.cs.colorado.edu/
//
// Copyright (C) 2003,2004,2005 University of Colorado, Boulder
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the mos license (see file LICENSE)
/**************************************************************************/
/* File: gateway.c */
/* Author Jeff Rose : rosejn@colorado.edu */
/* Date: 03/11/04 */
/* */
/* Linux app that routes data over both ip and the local serial port. */
/**************************************************************************/
#include <stdio.h>
#include <inttypes.h>
#include "config.h"
#include "msched.h"
#include "led.h"
#include "com.h"
#include "serial.h"
comBuf *ptr;
comBuf packet;
void linux_send()
{
uint8_t byte;
while(1)
{
byte = getchar();
if(byte == '\n')
continue;
packet.size = 1;
packet.data[0] = byte;
com_send(IFACE_SERIAL, &packet);
printf("sent: %d\n", byte);
}
}
void linux_recv()
{
com_mode(IFACE_SERIAL, IF_LISTEN);
while(1)
{
ptr = com_recv(IFACE_SERIAL);
printf("Size: %d -- Data: %d\n", ptr->size, ptr->data[0]);
com_free_buf(ptr);
}
}
void start()
{
mos_thread_new(linux_send, 128, PRIORITY_NORMAL);
mos_thread_new(linux_recv, 128, PRIORITY_NORMAL);
}
|
// Copyright 2015-present 650 Industries. All rights reserved.
#import <UIKit/UIKit.h>
@class EXViewController;
@class EXKernelAppRecord;
@protocol EXViewControllerDelegate <NSObject>
- (void)viewController:(EXViewController * _Nonnull)vc didNavigateAppToVisible:(EXKernelAppRecord * _Nonnull)appRecord;
@end
@interface EXViewController : UIViewController
/**
* Invoked from `viewDidLoad`
*/
- (void)createRootAppAndMakeVisible;
@property (nonatomic, strong, nullable) UIViewController *contentViewController;
@property (nonatomic, weak, nullable) id<EXViewControllerDelegate> delegate;
@end
|
/*
This file is part of the PhantomJS project from Ofi Labs.
Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
Copyright (C) 2011 Ivan De Marino <ivan.de.marino@gmail.com>
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 <organization> 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 <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 WEBPAGE_H
#define WEBPAGE_H
#include <QMap>
#include <QVariantMap>
#include <QWebPage>
#include <QWebFrame>
#include "replcompletable.h"
class Config;
class CustomPage;
class NetworkAccessManager;
class QWebInspector;
class Phantom;
class WebPage: public REPLCompletable, public QWebFrame::PrintCallback
{
Q_OBJECT
Q_PROPERTY(QString content READ content WRITE setContent)
Q_PROPERTY(QString plainText READ plainText)
Q_PROPERTY(QString libraryPath READ libraryPath WRITE setLibraryPath)
Q_PROPERTY(QString offlineStoragePath READ offlineStoragePath)
Q_PROPERTY(int offlineStorageQuota READ offlineStorageQuota)
Q_PROPERTY(QVariantMap viewportSize READ viewportSize WRITE setViewportSize)
Q_PROPERTY(QVariantMap paperSize READ paperSize WRITE setPaperSize)
Q_PROPERTY(QVariantMap clipRect READ clipRect WRITE setClipRect)
Q_PROPERTY(QVariantMap scrollPosition READ scrollPosition WRITE setScrollPosition)
Q_PROPERTY(QVariantMap customHeaders READ customHeaders WRITE setCustomHeaders)
public:
WebPage(QObject *parent, const Config *config, const QUrl &baseUrl = QUrl());
QWebFrame *mainFrame();
QString content() const;
void setContent(const QString &content);
QString plainText() const;
QString libraryPath() const;
void setLibraryPath(const QString &dirPath);
QString offlineStoragePath() const;
int offlineStorageQuota() const;
void setViewportSize(const QVariantMap &size);
QVariantMap viewportSize() const;
void setClipRect(const QVariantMap &size);
QVariantMap clipRect() const;
void setScrollPosition(const QVariantMap &size);
QVariantMap scrollPosition() const;
void setPaperSize(const QVariantMap &size);
QVariantMap paperSize() const;
void setCustomHeaders(const QVariantMap &headers);
QVariantMap customHeaders() const;
void showInspector(const int remotePort = -1);
QString footer(int page, int numPages);
qreal footerHeight() const;
QString header(int page, int numPages);
qreal headerHeight() const;
public slots:
void openUrl(const QString &address, const QVariant &op, const QVariantMap &settings);
void release();
QVariant evaluateJavaScript(const QString &code);
bool render(const QString &fileName);
bool injectJs(const QString &jsFilePath);
void _appendScriptElement(const QString &scriptUrl);
void uploadFile(const QString &selector, const QString &fileName);
void sendEvent(const QString &type, const QVariant &arg1 = QVariant(), const QVariant &arg2 = QVariant());
signals:
void initialized();
void loadStarted();
void loadFinished(const QString &status);
void javaScriptAlertSent(const QString &msg);
void javaScriptConsoleMessageSent(const QString &message);
void javaScriptErrorSent();
void resourceRequested(const QVariant &req);
void resourceReceived(const QVariant &resource);
private slots:
void finish(bool ok);
private:
QImage renderImage();
bool renderPdf(const QString &fileName);
void applySettings(const QVariantMap &defaultSettings);
QString userAgent() const;
void emitAlert(const QString &msg);
void emitConsoleMessage(const QString &msg);
void emitError();
virtual void initCompletions();
private:
CustomPage *m_webPage;
NetworkAccessManager *m_networkAccessManager;
QWebFrame *m_mainFrame;
QRect m_clipRect;
QPoint m_scrollPosition;
QVariantMap m_paperSize; // For PDF output via render()
QString m_libraryPath;
QWebInspector* m_inspector;
friend class Phantom;
friend class CustomPage;
QPoint m_mousePos;
};
#endif // WEBPAGE_H
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PPAPI_PROXY_AUDIO_INPUT_RESOURCE_H_
#define PPAPI_PROXY_AUDIO_INPUT_RESOURCE_H_
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/shared_memory.h"
#include "base/sync_socket.h"
#include "base/threading/simple_thread.h"
#include "ppapi/proxy/device_enumeration_resource_helper.h"
#include "ppapi/proxy/plugin_resource.h"
#include "ppapi/shared_impl/scoped_pp_resource.h"
#include "ppapi/thunk/ppb_audio_input_api.h"
namespace ppapi {
namespace proxy {
class ResourceMessageReplyParams;
class AudioInputResource : public PluginResource,
public thunk::PPB_AudioInput_API,
public base::DelegateSimpleThread::Delegate {
public:
AudioInputResource(Connection connection, PP_Instance instance);
virtual ~AudioInputResource();
// Resource overrides.
virtual thunk::PPB_AudioInput_API* AsPPB_AudioInput_API() OVERRIDE;
virtual void OnReplyReceived(const ResourceMessageReplyParams& params,
const IPC::Message& msg) OVERRIDE;
// PPB_AudioInput_API implementation.
virtual int32_t EnumerateDevices0_2(
PP_Resource* devices,
scoped_refptr<TrackedCallback> callback) OVERRIDE;
virtual int32_t EnumerateDevices(
const PP_ArrayOutput& output,
scoped_refptr<TrackedCallback> callback) OVERRIDE;
virtual int32_t MonitorDeviceChange(
PP_MonitorDeviceChangeCallback callback,
void* user_data) OVERRIDE;
virtual int32_t Open(const std::string& device_id,
PP_Resource config,
PPB_AudioInput_Callback audio_input_callback,
void* user_data,
scoped_refptr<TrackedCallback> callback) OVERRIDE;
virtual PP_Resource GetCurrentConfig() OVERRIDE;
virtual PP_Bool StartCapture() OVERRIDE;
virtual PP_Bool StopCapture() OVERRIDE;
virtual void Close() OVERRIDE;
protected:
// Resource override.
virtual void LastPluginRefWasDeleted() OVERRIDE;
private:
enum OpenState {
BEFORE_OPEN,
OPENED,
CLOSED
};
void OnPluginMsgOpenReply(const ResourceMessageReplyParams& params);
// Sets the shared memory and socket handles. This will automatically start
// capture if we're currently set to capture.
void SetStreamInfo(base::SharedMemoryHandle shared_memory_handle,
size_t shared_memory_size,
base::SyncSocket::Handle socket_handle);
// Starts execution of the audio input thread.
void StartThread();
// Stops execution of the audio input thread.
void StopThread();
// DelegateSimpleThread::Delegate implementation.
// Run on the audio input thread.
virtual void Run() OVERRIDE;
OpenState open_state_;
// True if capturing the stream.
bool capturing_;
// Socket used to notify us when new samples are available. This pointer is
// created in SetStreamInfo().
scoped_ptr<base::CancelableSyncSocket> socket_;
// Sample buffer in shared memory. This pointer is created in
// SetStreamInfo(). The memory is only mapped when the audio thread is
// created.
scoped_ptr<base::SharedMemory> shared_memory_;
// The size of the sample buffer in bytes.
size_t shared_memory_size_;
// When the callback is set, this thread is spawned for calling it.
scoped_ptr<base::DelegateSimpleThread> audio_input_thread_;
// Callback to call when new samples are available.
PPB_AudioInput_Callback audio_input_callback_;
// User data pointer passed verbatim to the callback function.
void* user_data_;
// The callback is not directly passed to OnPluginMsgOpenReply() because we
// would like to be able to cancel it early in Close().
scoped_refptr<TrackedCallback> open_callback_;
// Owning reference to the current config object. This isn't actually used,
// we just dish it out as requested by the plugin.
ScopedPPResource config_;
DeviceEnumerationResourceHelper enumeration_helper_;
DISALLOW_COPY_AND_ASSIGN(AudioInputResource);
};
} // namespace proxy
} // namespace ppapi
#endif // PPAPI_PROXY_AUDIO_INPUT_RESOURCE_H_
|
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_TEST_MEDIA_ROUTER_MEDIA_ROUTER_UI_FOR_TEST_BASE_H_
#define CHROME_TEST_MEDIA_ROUTER_MEDIA_ROUTER_UI_FOR_TEST_BASE_H_
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/ui/views/media_router/cast_dialog_view.h"
#include "chrome/browser/ui/views/media_router/media_router_dialog_controller_views.h"
#include "components/media_router/common/media_sink.h"
#include "components/media_router/common/media_source.h"
#include "content/public/browser/web_contents_user_data.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace content {
class WebContents;
} // namespace content
namespace media_router {
class MediaRouterUiForTestBase {
public:
virtual void SetUp() = 0;
// Cleans up after a test.
void TearDown();
virtual void ShowDialog() = 0;
virtual bool IsDialogShown() const = 0;
virtual void HideDialog() = 0;
// Chooses the source type in the dialog. Requires that the dialog is shown.
virtual void ChooseSourceType(CastDialogView::SourceType source_type) = 0;
virtual CastDialogView::SourceType GetChosenSourceType() const = 0;
// These methods require that the dialog is shown and the specified sink is
// shown in the dialog.
void StartCasting(const std::string& sink_name);
void StopCasting(const std::string& sink_name);
// Waits until a condition is met. Requires that the dialog is shown.
virtual void WaitForSink(const std::string& sink_name) = 0;
virtual void WaitForSinkAvailable(const std::string& sink_name) = 0;
virtual void WaitForAnyIssue() = 0;
virtual void WaitForAnyRoute() = 0;
virtual void WaitForDialogShown() = 0;
virtual void WaitForDialogHidden() = 0;
void WaitUntilNoRoutes();
// These methods require that the dialog is shown, and the sink specified by
// |sink_name| is in the dialog.
MediaRoute::Id GetRouteIdForSink(const std::string& sink_name) const;
std::string GetStatusTextForSink(const std::string& sink_name) const;
std::string GetIssueTextForSink(const std::string& sink_name) const;
// Sets up a mock file picker that returns |file_url| as the selected file.
virtual void SetLocalFile(const GURL& file_url) = 0;
// Sets up a mock file picker that fails with |issue|.
virtual void SetLocalFileSelectionIssue(const IssueInfo& issue) = 0;
// Called by MediaRouterDialogControllerViews.
virtual void OnDialogCreated();
protected:
enum class WatchType {
kNone,
kSink, // Sink is found in any state.
kSinkAvailable, // Sink is found in the "Available" state.
kAnyIssue,
kAnyRoute,
kDialogShown,
kDialogHidden
};
explicit MediaRouterUiForTestBase(content::WebContents* web_contents);
virtual ~MediaRouterUiForTestBase();
void WaitForAnyDialogShown();
void StartCasting(CastDialogSinkButton* sink_button);
void StopCasting(CastDialogSinkButton* sink_button);
static CastDialogSinkButton* GetSinkButtonWithName(
const std::vector<CastDialogSinkButton*>& sink_buttons,
const std::string& sink_name);
virtual CastDialogSinkButton* GetSinkButton(
const std::string& sink_name) const = 0;
// Registers itself as an observer to the dialog, and waits until an event
// of |watch_type| is observed. |sink_name| should be set only if observing
// for a sink.
virtual void ObserveDialog(
WatchType watch_type,
absl::optional<std::string> sink_name = absl::nullopt) = 0;
content::WebContents* const web_contents_;
MediaRouterDialogControllerViews* const dialog_controller_;
absl::optional<std::string> watch_sink_name_;
WatchType watch_type_ = WatchType::kNone;
absl::optional<base::OnceClosure> watch_callback_;
base::test::ScopedFeatureList feature_list_;
base::WeakPtrFactory<MediaRouterUiForTestBase> weak_factory_{this};
};
} // namespace media_router
#endif // CHROME_TEST_MEDIA_ROUTER_MEDIA_ROUTER_UI_FOR_TEST_BASE_H_
|
#ifndef _ZEUS_PROPERTY_H_
#define _ZEUS_PROPERTY_H_
template<class _Prop_t,
class _ObjClass_t>
class Property
{
typedef _Prop_t (_ObjClass_t::* _pmGet_t)() const;
typedef void (_ObjClass_t::* _pmSet_t)(_Prop_t);
_ObjClass_t& m_objInstance;
_pmGet_t m_pmGet;
_pmSet_t m_pmSet;
public:
Property(_ObjClass_t& objInstance, _pmGet_t pmGet, _pmSet_t pmSet)
: m_objInstance(objInstance), m_pmGet(pmGet), m_pmSet(pmSet)
{}
inline operator _Prop_t() { return (m_objInstance.*m_pmGet)(); }
inline void operator =(_Prop_t value) { (m_objInstance.*m_pmSet)(value); }
};
#endif
|
#ifndef SIMVCELL_H
#define SIMVCELL_H
#include <QObject>
#include "simvar.h"
#include <QComboBox>
namespace LQ = LongQt;
class SimvCell : public Simvar {
Q_OBJECT
public:
explicit SimvCell(std::shared_ptr<LQ::Protocol> proto, std::string name,
QComboBox* parent);
~SimvCell();
void update_ui() override;
void update_model(QString value);
void changeProto(std::shared_ptr<LongQt::Protocol> proto) override;
signals:
void cellChanged(std::shared_ptr<LQ::Cell>);
};
#endif // SimvCell_H
|
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#ifndef _FDE_ITERATOR_IMP
#define _FDE_ITERATOR_IMP
typedef struct _FDE_CANVASITEM : public CFX_Target {
IFDE_CanvasSet* pCanvas;
FDE_HVISUALOBJ hCanvas;
FX_POSITION hPos;
} FDE_CANVASITEM, *FDE_LPCANVASITEM;
class CFDE_VisualSetIterator : public IFDE_VisualSetIterator,
public CFX_Target {
public:
CFDE_VisualSetIterator();
~CFDE_VisualSetIterator();
virtual void Release() { delete this; }
virtual FX_BOOL AttachCanvas(IFDE_CanvasSet* pCanvas);
virtual FX_BOOL FilterObjects(FX_DWORD dwObjects = 0xFFFFFFFF);
virtual void Reset();
virtual FDE_HVISUALOBJ GetNext(IFDE_VisualSet*& pVisualSet,
FDE_HVISUALOBJ* phCanvasObj = NULL,
IFDE_CanvasSet** ppCanvasSet = NULL);
protected:
FX_DWORD m_dwFilter;
CFX_StackTemplate<FDE_CANVASITEM> m_CanvasStack;
};
#endif
|
#ifndef IRCCHANNEL_H
#define IRCCHANNEL_H
#include <QObject>
#include <QMap>
#include <QTextDocument>
#include <QTextCursor>
#include "IrcUser.h"
#include "IrcMessage.h"
class IrcChannel : public QObject
{
Q_OBJECT
public:
explicit IrcChannel(const QString& name, QObject *parent = 0);
~IrcChannel();
IrcChannel& operator=(const IrcChannel &rhs);
bool operator==(const IrcChannel &rhs) const;
bool operator!=(const IrcChannel &rhs) const;
bool operator<(const IrcChannel &rhs) const;
bool operator<=(const IrcChannel &rhs) const;
bool operator>(const IrcChannel &rhs) const;
bool operator>=(const IrcChannel &rhs) const;
void setName(QString& theName);
void addUser(QString& user);
void removeUser(const QString& nick);
bool renameUser(QString oldNick, QString newNick);
bool hasUser(QString nick);
void addText(QString theText);
void setTopic(QString theTopic);
void setKey(QString& theKey); // empty string removes key
void setUserLimit(int theLimit); // negative value removes user limit
void setPrivate(bool theBool);
void setSecret(bool theBool);
void setInviteOnly(bool theBool);
void setExternal(bool theBool);
void setModerated(bool theBool);
void setDocumentFont(const QFont& font);
QString name();
QString topic();
QString key();
QTextDocument* document();
IrcUser* user(QString nick);
QStringList channelNicks();
int userLimit();
bool isPrivate();
bool isSecret();
bool isInviteOnly();
bool isExternal();
bool isModerated();
bool isPrivateMessage();
signals:
public slots:
private:
QString m_name;
QMap<QString,IrcUser*> m_users;
QString m_topic;
QString m_key;
int m_userLimit;
QTextDocument* m_document;
QTextCursor* m_textCursor;
bool m_isPrivate;
bool m_isSecret;
bool m_isInviteOnly;
bool m_isExternal;
bool m_isModerated;
bool m_hasUserLimit;
bool m_hasKey;
};
#endif // IRCCHANNEL_H
|
/* -*- Mode: C; tab-width:4 -*- */
/* ex: set ts=4 shiftwidth=4 softtabstop=4 cindent: */
/**
* @file sos_error_types.h
* @brief Error Types in the SOS Kernel
* @author Ram Kumar {ram@ee.ucla.edu}
*/
#ifndef _SOS_ERROR_TYPES_H_
#define _SOS_ERROR_TYPES_H_
enum {
READ_ERROR = 0, //! bus read
SEND_ERROR, //! bus send failed
SENSOR_ERROR, //! sensor failure (other than read/write i.e. sensor removed)
MALLOC_ERROR, //! malloc failed for reply msg
};
#endif//_SOS_ERROR_TYPES_H_
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_COMMON_JSON_VALUE_SERIALIZER_H_
#define CHROME_COMMON_JSON_VALUE_SERIALIZER_H_
#include <string>
#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/values.h"
class JSONStringValueSerializer : public ValueSerializer {
public:
// json_string is the string that will be source of the deserialization
// or the destination of the serialization. The caller of the constructor
// retains ownership of the string.
explicit JSONStringValueSerializer(std::string* json_string)
: json_string_(json_string),
initialized_with_const_string_(false),
pretty_print_(false),
allow_trailing_comma_(false) {
}
// This version allows initialization with a const string reference for
// deserialization only.
explicit JSONStringValueSerializer(const std::string& json_string)
: json_string_(&const_cast<std::string&>(json_string)),
initialized_with_const_string_(true),
pretty_print_(false),
allow_trailing_comma_(false) {
}
~JSONStringValueSerializer();
// Attempt to serialize the data structure represented by Value into
// JSON. If the return value is true, the result will have been written
// into the string passed into the constructor.
bool Serialize(const Value& root);
// Attempt to deserialize the data structure encoded in the string passed
// in to the constructor into a structure of Value objects. If the return
// value is NULL and |error_message| is non-null, |error_message| will contain
// a string describing the error.
Value* Deserialize(std::string* error_message);
void set_pretty_print(bool new_value) { pretty_print_ = new_value; }
bool pretty_print() { return pretty_print_; }
void set_allow_trailing_comma(bool new_value) {
allow_trailing_comma_ = new_value;
}
private:
std::string* json_string_;
bool initialized_with_const_string_;
bool pretty_print_; // If true, serialization will span multiple lines.
// If true, deserialization will allow trailing commas.
bool allow_trailing_comma_;
DISALLOW_COPY_AND_ASSIGN(JSONStringValueSerializer);
};
class JSONFileValueSerializer : public ValueSerializer {
public:
// json_file_patch is the path of a file that will be source of the
// deserialization or the destination of the serialization.
// When deserializing, the file should exist, but when serializing, the
// serializer will attempt to create the file at the specified location.
explicit JSONFileValueSerializer(const FilePath& json_file_path)
: json_file_path_(json_file_path) {}
~JSONFileValueSerializer() {}
// DO NOT USE except in unit tests to verify the file was written properly.
// We should never serialize directly to a file since this will block the
// thread. Instead, serialize to a string and write to the file you want on
// the file thread.
//
// Attempt to serialize the data structure represented by Value into
// JSON. If the return value is true, the result will have been written
// into the file whose name was passed into the constructor.
bool Serialize(const Value& root);
// Attempt to deserialize the data structure encoded in the file passed
// in to the constructor into a structure of Value objects. If the return
// value is NULL, and if |error_message| is non-null, |error_message| will
// contain a string describing the error. The caller takes ownership of the
// returned value.
Value* Deserialize(std::string* error_message);
private:
FilePath json_file_path_;
DISALLOW_IMPLICIT_CONSTRUCTORS(JSONFileValueSerializer);
};
#endif // CHROME_COMMON_JSON_VALUE_SERIALIZER_H_
|
/* $chaos: log.c,v 1.5 2002/12/03 18:10:56 johannes Exp $ */
/* Abstract: Kernel log module. */
/* Author: Per Lundberg <per@chaosdev.org> */
/* Copyright 2002 chaos development. */
/* Use freely under the terms listed in the file LICENSE. */
#include <storm/storm.h>
#include <log/log.h>
/* The version of log service that we provide. */
#define LOG_SERVICE_VERSION 1
/* Log urgency names. */
static char *log_urgency[] =
{
"Emergency",
"Error",
"Warning",
"Informative",
"Debug"
};
/* Print something to the kernel log. */
static return_t log_print (unsigned int urgency, char *string)
{
debug_print ("%s: %s\n", log_urgency[urgency], string);
return STORM_RETURN_SUCCESS;
}
/* Print something to the kernel log, in a more formatted fashion. */
static return_t log_print_formatted (unsigned int urgency, char *string, ...)
{
// FIXME: Use the varargs as well.
debug_print ("%s: %s\n", log_urgency[urgency], string);
return STORM_RETURN_SUCCESS;
}
/* Return some information about the log service (function pointers to
our functionality). */
static return_t service_info (void *log_void)
{
log_service_t *log = (log_service_t *) log_void;
log->magic_cookie = LOG_COOKIE;
log->print = &log_print;
log->print_formatted = &log_print_formatted;
return STORM_RETURN_SUCCESS;
}
return_t module_start (void)
{
service_register_t service_register_info;
service_register_info.service_vendor = "chaos development";
service_register_info.device_vendor = "N/A";
service_register_info.model = "Log module";
service_register_info.device_id = "1";
service_register_info.info_handler = &service_info;
// FIXME: Fill in this structure.
service_method_t service_method[] =
{
{ -1, NULL }
};
return log_register (&service_register_info, service_method);
}
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CRYPTO_SCOPED_CAPI_TYPES_H_
#define CRYPTO_SCOPED_CAPI_TYPES_H_
#include <windows.h>
#include <algorithm>
#include "base/logging.h"
#include "base/macros.h"
#include "crypto/wincrypt_shim.h"
#include "starboard/types.h"
namespace crypto {
// Simple destructor for the Free family of CryptoAPI functions, such as
// CryptDestroyHash, which take only a single argument to release.
template <typename CAPIHandle, BOOL (WINAPI *Destroyer)(CAPIHandle)>
struct CAPIDestroyer {
void operator()(CAPIHandle handle) const {
if (handle) {
BOOL ok = Destroyer(handle);
DCHECK(ok);
}
}
};
// Destructor for the Close/Release family of CryptoAPI functions, which take
// a second DWORD parameter indicating flags to use when closing or releasing.
// This includes functions like CertCloseStore or CryptReleaseContext.
template <typename CAPIHandle, BOOL (WINAPI *Destroyer)(CAPIHandle, DWORD),
DWORD flags>
struct CAPIDestroyerWithFlags {
void operator()(CAPIHandle handle) const {
if (handle) {
BOOL ok = Destroyer(handle, flags);
DCHECK(ok);
}
}
};
// scoped_ptr-like class for the CryptoAPI cryptography and certificate
// handles. Because these handles are defined as integer types, and not
// pointers, the existing scoped classes, such as scoped_ptr, are insufficient.
// The semantics are the same as scoped_ptr.
template <class CAPIHandle, typename FreeProc>
class ScopedCAPIHandle {
public:
explicit ScopedCAPIHandle(CAPIHandle handle = NULL) : handle_(handle) {}
~ScopedCAPIHandle() {
reset();
}
void reset(CAPIHandle handle = NULL) {
if (handle_ != handle) {
FreeProc free_proc;
free_proc(handle_);
handle_ = handle;
}
}
operator CAPIHandle() const { return handle_; }
CAPIHandle get() const { return handle_; }
CAPIHandle* receive() {
CHECK(handle_ == NULL);
return &handle_;
}
bool operator==(CAPIHandle handle) const {
return handle_ == handle;
}
bool operator!=(CAPIHandle handle) const {
return handle_ != handle;
}
void swap(ScopedCAPIHandle& b) {
CAPIHandle tmp = b.handle_;
b.handle_ = handle_;
handle_ = tmp;
}
CAPIHandle release() {
CAPIHandle tmp = handle_;
handle_ = NULL;
return tmp;
}
private:
CAPIHandle handle_;
DISALLOW_COPY_AND_ASSIGN(ScopedCAPIHandle);
};
template<class CH, typename FP> inline
bool operator==(CH h, const ScopedCAPIHandle<CH, FP>& b) {
return h == b.get();
}
template<class CH, typename FP> inline
bool operator!=(CH h, const ScopedCAPIHandle<CH, FP>& b) {
return h != b.get();
}
typedef ScopedCAPIHandle<
HCRYPTPROV,
CAPIDestroyerWithFlags<HCRYPTPROV,
CryptReleaseContext, 0> > ScopedHCRYPTPROV;
typedef ScopedCAPIHandle<
HCRYPTKEY, CAPIDestroyer<HCRYPTKEY, CryptDestroyKey> > ScopedHCRYPTKEY;
typedef ScopedCAPIHandle<
HCRYPTHASH, CAPIDestroyer<HCRYPTHASH, CryptDestroyHash> > ScopedHCRYPTHASH;
} // namespace crypto
#endif // CRYPTO_SCOPED_CAPI_TYPES_H_
|
#ifndef UNICODE_TREE_H
#define UNICODE_TREE_H
#include "standard_tree.h"
#include "unicode/utypes.h"
#ifdef __cplusplus
extern "C" {
#endif
enum
{
NodeUnicodeChar,
NodeUnicodeRange
};
typedef struct UnicodeTreeNodeArgs UnicodeTreeNodeArgs;
struct UnicodeTreeNodeArgs
{
UChar32 c1;
UChar32 c2;
};
TreeNode *new_unicode_tree_node(int, TreeNode *, TreeNode *);
void free_unicode_tree_node(TreeNode *);
int unicode_tree_node_compile(ReOS_Pattern *, int, TreeNode *, ReOS_InstFactoryFunc);
void print_unicode_tree(TreeNode *);
#ifdef __cplusplus
}
#endif
#endif
|
// vim:ts=4:sw=4:expandtab
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <yajl/yajl_gen.h>
#include <yajl/yajl_version.h>
#include "i3status.h"
static bool local_timezone_init = false;
static const char *local_timezone = NULL;
static const char *current_timezone = NULL;
void set_timezone(const char *tz) {
if (!local_timezone_init) {
/* First call, initialize. */
local_timezone = getenv("TZ");
local_timezone_init = true;
}
if (tz == NULL || tz[0] == '\0') {
/* User wants localtime. */
tz = local_timezone;
}
if (tz != current_timezone) {
if (tz) {
setenv("TZ", tz, 1);
} else {
unsetenv("TZ");
}
tzset();
current_timezone = tz;
}
}
void print_time(yajl_gen json_gen, char *buffer, const char *format, const char *tz, time_t t) {
char *outwalk = buffer;
struct tm tm;
/* Convert time and format output. */
set_timezone(tz);
localtime_r(&t, &tm);
outwalk += strftime(outwalk, 4095, format, &tm);
*outwalk = '\0';
OUTPUT_FULL_TEXT(buffer);
}
|
/*
* Copyright 2010 The Android Open Source Project
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkPDFImage_DEFINED
#define SkPDFImage_DEFINED
#include "SkPDFStream.h"
#include "SkPDFTypes.h"
#include "SkRefCnt.h"
class SkBitmap;
class SkPDFCatalog;
struct SkIRect;
/** \class SkPDFImage
An image XObject.
*/
// We could play the same trick here as is done in SkPDFGraphicState, storing
// a copy of the Bitmap object (not the pixels), the pixel generation number,
// and settings used from the paint to canonicalize image objects.
class SkPDFImage : public SkPDFStream {
public:
/** Create a new Image XObject to represent the passed bitmap.
* @param bitmap The image to encode.
* @param srcRect The rectangle to cut out of bitmap.
* @param paint Used to calculate alpha, masks, etc.
* @return The image XObject or NUll if there is nothing to draw for
* the given parameters.
*/
static SkPDFImage* CreateImage(const SkBitmap& bitmap,
const SkIRect& srcRect);
virtual ~SkPDFImage();
/** Add a Soft Mask (alpha or shape channel) to the image. Refs mask.
* @param mask A gray scale image representing the mask.
* @return The mask argument is returned.
*/
SkPDFImage* addSMask(SkPDFImage* mask);
// The SkPDFObject interface.
virtual void getResources(const SkTSet<SkPDFObject*>& knownResourceObjects,
SkTSet<SkPDFObject*>* newResourceObjects);
private:
SkTDArray<SkPDFObject*> fResources;
/** Create a PDF image XObject. Entries for the image properties are
* automatically added to the stream dictionary.
* @param imageData The final raw bits representing the image.
* @param bitmap The image parameters to use (Config, etc).
* @param srcRect The clipping applied to bitmap before generating
* imageData.
* @param alpha Is this the alpha channel of the bitmap.
* @param paint Used to calculate alpha, masks, etc.
*/
SkPDFImage(SkStream* imageData, const SkBitmap& bitmap,
const SkIRect& srcRect, bool alpha);
};
#endif
|
/**/
#include <stdio.h>
#include <math.h>
int main (){
char entry, checksum2;
int checksum = 0;
printf("Enter an abitrarily long string, ending with carriage return > ");
while (1) {
entry=getchar();
if (entry == '\n'){
break;}
else {
checksum += entry;}
}
checksum = checksum%64;
checksum = checksum+32;
checksum2 = (char)(checksum);
printf("Check sum is %c\n",checksum2);
return 0;
}
|
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_CHROME_CLEANER_CRASH_CRASH_CLIENT_H_
#define CHROME_CHROME_CLEANER_CRASH_CRASH_CLIENT_H_
#include <map>
#include <string>
#include "base/macros.h"
#include "base/synchronization/lock.h"
#include "chrome/chrome_cleaner/settings/settings_types.h"
namespace chrome_cleaner {
// This class manages interaction with the crash reporter.
class CrashClient {
public:
enum class Mode { REPORTER, CLEANER, MODE_COUNT };
static CrashClient* GetInstance();
// Set |client_id| to the current guid associated with crashes. |client_id|
// may be empty if no guid is associated.
static void GetClientId(std::wstring* client_id);
// Returns whether upload of crashes is enabled or not.
static bool IsUploadEnabled();
CrashClient() = default;
CrashClient(const CrashClient&) = delete;
CrashClient& operator=(const CrashClient&) = delete;
virtual ~CrashClient() = default;
// Initializes collection and upload of crash reports. This will only be done
// if the user has agreed to crash dump reporting.
//
// Crash reporting has to be initialized as early as possible (e.g., the first
// thing in main()) to catch crashes occurring during process startup. Crashes
// which occur during the global static construction phase will not be caught
// and reported. This should not be a problem as static non-POD objects are
// not allowed by the style guide and exceptions to this rule are rare.
//
// |mode| controls a custom info entry present in the generated dumps to allow
// distinguishing between cleaner and reporter crashes on the backend.
//
// |process_type| identifies the type of process that reported the crash.
virtual bool InitializeCrashReporting(Mode mode,
SandboxType process_type) = 0;
};
} // namespace chrome_cleaner
#endif // CHROME_CHROME_CLEANER_CRASH_CRASH_CLIENT_H_
|
// PARStore
// Created by Charles Parnot on 3/13/13.
// Licensed under the terms of the BSD License, as specified in the file 'LICENSE-BSD.txt' included with this distribution
@interface NSError (Factory)
+ (NSError *)errorWithObject:(id)object code:(NSInteger)code localizedDescription:(NSString *)description underlyingError:(NSError *)underlyingError;
@end
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_
#define CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_
#include <jni.h>
#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
#include "content/browser/device_orientation/data_fetcher.h"
#include "content/browser/device_orientation/device_data.h"
namespace device_orientation {
class Orientation;
// Android implementation of DeviceOrientation API.
// Android's SensorManager has a push API, whereas Chrome wants to pull data.
// To fit them together, we store incoming sensor events in a 1-element buffer.
// SensorManager calls SetOrientation() which pushes a new value (discarding the
// previous value if any). Chrome calls GetDeviceData() which reads the most
// recent value. Repeated calls to GetDeviceData() will return the same value.
class DataFetcherImplAndroid : public DataFetcher {
public:
// Must be called at startup, before Create().
static void Init(JNIEnv* env);
// Factory function. We'll listen for events for the lifetime of this object.
// Returns NULL on error.
static DataFetcher* Create();
virtual ~DataFetcherImplAndroid();
// Called from Java via JNI.
void GotOrientation(JNIEnv*, jobject,
double alpha, double beta, double gamma);
// Implementation of DataFetcher.
virtual const DeviceData* GetDeviceData(DeviceData::Type type) OVERRIDE;
private:
DataFetcherImplAndroid();
const Orientation* GetOrientation();
// Wrappers for JNI methods.
bool Start(int rate_in_milliseconds);
void Stop();
// Value returned by GetDeviceData.
scoped_refptr<Orientation> current_orientation_;
// 1-element buffer, written by GotOrientation, read by GetDeviceData.
base::Lock next_orientation_lock_;
scoped_refptr<Orientation> next_orientation_;
DISALLOW_COPY_AND_ASSIGN(DataFetcherImplAndroid);
};
} // namespace device_orientation
#endif // CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_
|
/* Copyright (c) 2014, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef __OFP_H__
#define __OFP_H__
#include <odp_api.h>
#include <odp/helper/odph_api.h>
/**
* @file
*
* @brief The OpenFastPath API
*
*/
#ifdef __cplusplus
extern "C" {
#endif
#include "ofp_config.h"
#include "ofp_types.h"
#include "ofp_init.h"
#include "ofp_ifnet.h"
#include "ofp_pkt_processing.h"
#include "ofp_cli.h"
#include "ofp_log.h"
#include "ofp_timer.h"
#include "ofp_hook.h"
#include "ofp_route_arp.h"
#include "ofp_ifnet.h"
#include "ofp_portconf.h"
#include "ofp_debug.h"
#include "ofp_stat.h"
#include "ofp_socket_types.h"
#include "ofp_socket.h"
#include "ofp_in.h"
#include "ofp_in6.h"
#include "ofp_errno.h"
#include "ofp_ioctl.h"
#include "ofp_utils.h"
#include "ofp_sysctl.h"
#include "ofp_ethernet.h"
#include "ofp_ip.h"
#include "ofp_ip6.h"
#include "ofp_icmp.h"
#include "ofp_icmp6.h"
#include "ofp_if_vlan.h"
#include "ofp_udp.h"
#include "ofp_ip_var.h"
#include "ofp_tcp.h"
#include "ofp_epoll.h"
#include "ofp_ipsec.h"
#include "ofp_ipsec_init.h"
#ifdef __cplusplus
}
#endif
#endif /* __OFP_H__ */
|
# include <stdio.h>
# include <stdlib.h> /* for calloc and qsort */
#include "hstcal.h"
# include "hstio.h"
# include "hstcalerr.h" /* for NO_GOOD_DATA */
# include "acsdq.h" /* for GOODPIXEL */
# include "acs.h" /* for MsgText */
/* This routine determines the bias level for one line of an image
by taking the median of the values in the overscan region.
** NO MAJOR MODIFICATIONS for ACS...
*/
int FindBlev (SingleGroup *x, int j, int *biassect, short sdqflags,
double *biaslevel, int *npix) {
/* arguments:
SingleGroup *x i: needed for science data and data quality
int j i: line of x data to use to get overscan
int biassect[4] i: beginning and end of region(s) to use for overscan
double *biaslevel o: median bias level for current (j) line
int *npix o: number of pixels used to compute bias level
*/
extern int status;
double *over; /* values extracted from overscan region */
int nvals; /* number of good pixels extracted from overscan */
int nbias; /* number of pixels from both overscans to be used*/
int i;
int inplace = 1; /* sort the array in-place */
double MedianDouble (double *, int, int);
/* Allocate space for the overscan, and copy out good data. */
/* If no trailing region is used, biassect[2] and [3] will be set
to zero, so it will have no effect on nbias. */
nbias = (biassect[1]-biassect[0]) + (biassect[3]-biassect[2]) + 2;
over = calloc (nbias, sizeof (double));
nvals = 0;
/* check to see if first overscan region is used */
if (biassect[1] != 0) {
for (i = biassect[0]; i <= biassect[1]; i++) {
if (DQPix (x->dq.data, i, j) == GOODPIXEL || !(DQPix (x->dq.data, i, j) & sdqflags)) {
over[nvals] = Pix (x->sci.data, i, j);
nvals++;
}
}
}
/* Check to see if second overscan region is used...*/
if (biassect[2] != 0){
/* Include the pixels from 2nd overscan region in fit here... */
for (i = biassect[2]; i <= biassect[3]; i++) {
if (DQPix (x->dq.data, i, j) == GOODPIXEL || !(DQPix (x->dq.data, i, j) & sdqflags)) {
over[nvals] = Pix (x->sci.data, i, j);
nvals++;
}
}
} /* End of 2nd overscan pixels */
*npix = nvals;
if (nvals < 1) {
free (over);
return (status = NO_GOOD_DATA);
}
/* Find the median. */
*biaslevel = MedianDouble (over, nvals, inplace);
free (over);
return (status);
}
|
// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// This file extends generic BrowserDistribution class to declare Google Chrome
// specific implementation.
#ifndef CHROME_INSTALLER_UTIL_GOOGLE_CHROME_DISTRIBUTION_H_
#define CHROME_INSTALLER_UTIL_GOOGLE_CHROME_DISTRIBUTION_H_
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/util_constants.h"
#include "testing/gtest/include/gtest/gtest_prod.h" // for FRIEND_TEST
class DictionaryValue;
class GoogleChromeDistribution : public BrowserDistribution {
public:
// Opens the Google Chrome uninstall survey window.
// version refers to the version of Chrome being uninstalled.
// local_data_path is the path of the file containing json metrics that
// will be parsed. If this file indicates that the user has opted in to
// providing anonymous usage data, then some additional statistics will
// be added to the survey url.
// distribution_data contains Google Update related data that will be
// concatenated to the survey url if the file in local_data_path indicates
// the user has opted in to providing anonymous usage data.
virtual void DoPostUninstallOperations(const installer::Version& version,
const std::wstring& local_data_path,
const std::wstring& distribution_data);
virtual std::wstring GetAppGuid();
virtual std::wstring GetApplicationName();
virtual std::wstring GetAlternateApplicationName();
virtual std::wstring GetInstallSubDir();
// This method generates the new value for Google Update "ap" key for Chrome
// based on whether we are doing incremental install (or not) and whether
// the install succeeded.
// - If install worked, remove the magic string (if present).
// - If incremental installer failed, append a magic string (if
// not present already).
// - If full installer failed, still remove this magic
// string (if it is present already).
//
// diff_install: tells whether this is incremental install or not.
// install_status: if 0, means installation was successful.
// value: current value of Google Update "ap" key.
std::wstring GetNewGoogleUpdateApKey(bool diff_install,
installer_util::InstallStatus status, const std::wstring& value);
virtual std::wstring GetPublisherName();
virtual std::wstring GetAppDescription();
virtual int GetInstallReturnCode(
installer_util::InstallStatus install_status);
virtual std::string GetSafeBrowsingName();
virtual std::wstring GetStateKey();
virtual std::wstring GetStateMediumKey();
virtual std::wstring GetStatsServerURL();
// This method reads data from the Google Update ClientState key for
// potential use in the uninstall survey. It must be called before the
// key returned by GetVersionKey() is deleted.
virtual std::wstring GetDistributionData(RegKey* key);
virtual std::wstring GetUninstallLinkName();
virtual std::wstring GetUninstallRegPath();
virtual std::wstring GetVersionKey();
virtual void UpdateDiffInstallStatus(bool system_install,
bool incremental_install, installer_util::InstallStatus install_status);
virtual void LaunchUserExperiment(installer_util::InstallStatus status,
const installer::Version& version,
bool system_install);
// Assuming that the user qualifies, this function performs the inactive user
// toast experiment. It will use chrome to show the UI and it will record the
// outcome in the registry.
virtual void InactiveUserToastExperiment(int flavor);
private:
friend class BrowserDistribution;
FRIEND_TEST(GoogleChromeDistributionTest, TestExtractUninstallMetrics);
// Extracts uninstall metrics from the JSON file located at file_path.
// Returns them in a form suitable for appending to a url that already
// has GET parameters, i.e. &metric1=foo&metric2=bar.
// Returns true if uninstall_metrics has been successfully populated with
// the uninstall metrics, false otherwise.
virtual bool ExtractUninstallMetricsFromFile(
const std::wstring& file_path, std::wstring* uninstall_metrics);
// Extracts uninstall metrics from the given JSON value.
virtual bool ExtractUninstallMetrics(const DictionaryValue& root,
std::wstring* uninstall_metrics);
// Given a DictionaryValue containing a set of uninstall metrics,
// this builds a URL parameter list of all the contained metrics.
// Returns true if at least one uninstall metric was found in
// uninstall_metrics_dict, false otherwise.
virtual bool BuildUninstallMetricsString(
DictionaryValue* uninstall_metrics_dict, std::wstring* metrics);
// Disallow construction from non-friends.
GoogleChromeDistribution() {}
};
#endif // CHROME_INSTALLER_UTIL_GOOGLE_CHROME_DISTRIBUTION_H_
|
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_LAYERS_MIRROR_LAYER_IMPL_H_
#define CC_LAYERS_MIRROR_LAYER_IMPL_H_
#include <memory>
#include "base/memory/ptr_util.h"
#include "cc/cc_export.h"
#include "cc/layers/layer_impl.h"
namespace cc {
// This type of layer is used to mirror contents of another layer (specified by
// |mirrored_layer_id_|) by forcing a render pass for the mirrored layer and
// adding a RenderPassDrawQuad in the compositor frame for this layer referring
// to that render pass. The mirroring layer should not be a descendant of the
// mirrored layer (in terms of the effect tree). Due to ordering requirements
// for render passes in the compositor frame, the render pass containing
// mirroring layer should appear after the render pass created for the mirrored
// layer. Currently, render passes are in reverse-draw order of the effect tree,
// so we should be careful that this reverse-draw order does not conflict with
// render pass ordering requirement mentioned above.
// TODO(mohsen): If necessary, reorder render passes in compositor frame such
// that the render pass containing mirroring layer appears after the render pass
// created for the mirrored layer.
class CC_EXPORT MirrorLayerImpl : public LayerImpl {
public:
static std::unique_ptr<MirrorLayerImpl> Create(LayerTreeImpl* tree_impl,
int id) {
return base::WrapUnique(new MirrorLayerImpl(tree_impl, id));
}
MirrorLayerImpl(const MirrorLayerImpl&) = delete;
MirrorLayerImpl& operator=(const MirrorLayerImpl&) = delete;
~MirrorLayerImpl() override;
void SetMirroredLayerId(int id) { mirrored_layer_id_ = id; }
int mirrored_layer_id() const { return mirrored_layer_id_; }
// LayerImpl overrides.
std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override;
void AppendQuads(viz::RenderPass* render_pass,
AppendQuadsData* append_quads_data) override;
void PushPropertiesTo(LayerImpl* layer) override;
gfx::Rect GetDamageRect() const override;
gfx::Rect GetEnclosingRectInTargetSpace() const override;
protected:
MirrorLayerImpl(LayerTreeImpl* tree_impl, int id);
private:
const char* LayerTypeAsString() const override;
int mirrored_layer_id_ = 0;
};
} // namespace cc
#endif // CC_LAYERS_MIRROR_LAYER_IMPL_H_
|
/*
* Copyright (C) 2009, Willow Garage, Inc.
*
* 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 names of Stanford University or Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ROSCPP_WALL_TIMER_H
#define ROSCPP_WALL_TIMER_H
#include "common.h"
#include "forwards.h"
#include "wall_timer_options.h"
namespace ros
{
/**
* \brief Manages a wall-clock timer callback
*
* A WallTimer should always be created through a call to NodeHandle::createWallTimer(), or copied from one
* that was. Once all copies of a specific
* WallTimer go out of scope, the callback associated with that handle will stop
* being called.
*/
class ROSCPP_DECL WallTimer
{
public:
WallTimer() {}
WallTimer(const WallTimer& rhs);
~WallTimer();
/**
* \brief Start the timer. Does nothing if the timer is already started.
*/
void start();
/**
* \brief Stop the timer. Once this call returns, no more callbacks will be called. Does
* nothing if the timer is already stopped.
*/
void stop();
/**
* \brief Returns whether or not the timer has any pending events to call.
*/
bool hasPending();
/**
* \brief Set the period of this timer
* \param reset Whether to reset the timer. If true, timer ignores elapsed time and next cb occurs at now()+period
*/
void setPeriod(const WallDuration& period, bool reset=true);
bool isValid() { return impl_ && impl_->isValid(); }
operator void*() { return isValid() ? (void*)1 : (void*)0; }
bool operator<(const WallTimer& rhs)
{
return impl_ < rhs.impl_;
}
bool operator==(const WallTimer& rhs)
{
return impl_ == rhs.impl_;
}
bool operator!=(const WallTimer& rhs)
{
return impl_ != rhs.impl_;
}
private:
WallTimer(const WallTimerOptions& ops);
class Impl
{
public:
Impl();
~Impl();
bool isValid();
bool hasPending();
void setPeriod(const WallDuration& period, bool reset=true);
void start();
void stop();
bool started_;
int32_t timer_handle_;
WallDuration period_;
WallTimerCallback callback_;
CallbackQueueInterface* callback_queue_;
VoidConstWPtr tracked_object_;
bool has_tracked_object_;
bool oneshot_;
};
typedef boost::shared_ptr<Impl> ImplPtr;
typedef boost::weak_ptr<Impl> ImplWPtr;
ImplPtr impl_;
friend class NodeHandle;
};
}
#endif
|
// OpenTissue Template Library
//
// A generic toolbox for physics based modeling and simulation.
// Copyright (c) 2008 Department of Computer Science, University of Copenhagen.
//
// OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php.
#ifndef OPENTISSUE_FEM_COMPUTE_VOLUME_H
#define OPENTISSUE_FEM_COMPUTE_VOLUME_H
#include <opentissue/configuration.h>
namespace opentissue {
namespace fem {
namespace detail {
template<typename vector_type>
inline typename vector_type::value_type
compute_volume(vector_type const &e10,
vector_type const &e20, vector_type const &e30) {
return e10 * (e20 % e30) / 6.0;
}
}
}
}
#endif |
#include <string.h>
#include "pspgl_internal.h"
/* This sets the inital value of the register set. It initializes
every useful value register (it does not touch registers which
trigger an action like drawing a primitive), because its also used
to build the set of registers which need to be updated on a context
switch. These entries do not include the register number - the 8
MSB are set to non-zero for defined entries, and the index itself
is the command number. */
#define INIT(c, v) [c] = ((1 << 24) | ((v) & 0xffffff))
#define INITRANGE(s,e,v) [(s)...(e)] = ((1 << 24) | ((v) & 0xffffff))
#define UNINIT(c) [c] = 0
#define FP_1_0 0x3f8000 /* 1.0 in PSP 24-bit FP */
static const
uint32_t ge_init_state[256] =
{
INIT(CMD_VERTEXPTR, 0),
INIT(CMD_INDEXPTR, 0),
INIT(CMD_BASE, 0),
INIT(CMD_VERTEXTYPE, 0),
INIT(CMD_OFFSET_ADDR, 0),
INIT(CMD_REGION1, 0),
INIT(CMD_REGION2, 0),
INITRANGE(CMD_ENA_LIGHTING, CMD_ENA_LOGIC, 0),
INIT(CMD_ENA_DITHER, 1),
INIT(CMD_ENA_CLIP, 1),
INITRANGE(CMD_MORPH_WEIGHT0, CMD_MORPH_WEIGHT7, 0),
INIT(CMD_PATCH_SUBDIV, 0x404),
INIT(CMD_PATCH_PRIM, 0),
INIT(CMD_PATCH_CULL, 0),
INITRANGE(CMD_VIEWPORT_SX, CMD_VIEWPORT_TZ, 0),
INIT(CMD_TEXTURE_SU, FP_1_0),
INIT(CMD_TEXTURE_SV, FP_1_0),
INIT(CMD_TEXTURE_TU, 0),
INIT(CMD_TEXTURE_TV, 0),
INIT(CMD_OFFSETX, 0),
INIT(CMD_OFFSETY, 0),
INIT(CMD_SHADEMODEL, 0),
INIT(CMD_REV_NORM, 0),
INIT(CMD_MATERIAL, 0),
INIT(CMD_MATERIAL_EMS_C, 0x000000), /* emissive is 0,0,0,1 */
INIT(CMD_MATERIAL_AMB_C, 0xffffff), /* ambient is 1,1,1,1 */
INIT(CMD_MATERIAL_DIF_C, 0xcccccc), /* diffuse is .8,.8,.8,1 */
INIT(CMD_MATERIAL_SPC_C, 0x000000), /* specular is 0,0,0,1 */
INIT(CMD_MATERIAL_AMB_A, 0x0000ff), /* ambient alpha is 1 */
INIT(CMD_MATERIAL_SPEC_POW, FP_1_0),
INIT(CMD_AMBIENT_COLOR, 0),
INIT(CMD_AMBIENT_ALPHA, 0),
INIT(CMD_LIGHTMODEL, 0),
INITRANGE(CMD_LIGHT0_TYPE, CMD_LIGHT3_SPC_COL, 0),
INIT(CMD_LIGHT0_POS_Z, FP_1_0),
INIT(CMD_LIGHT1_POS_Z, FP_1_0),
INIT(CMD_LIGHT2_POS_Z, FP_1_0),
INIT(CMD_LIGHT3_POS_Z, FP_1_0),
INIT(CMD_LIGHT0_VEC_Z, FP_1_0),
INIT(CMD_LIGHT1_VEC_Z, FP_1_0),
INIT(CMD_LIGHT2_VEC_Z, FP_1_0),
INIT(CMD_LIGHT3_VEC_Z, FP_1_0),
INIT(CMD_LIGHT0_ATT_CONST, FP_1_0),
INIT(CMD_LIGHT1_ATT_CONST, FP_1_0),
INIT(CMD_LIGHT2_ATT_CONST, FP_1_0),
INIT(CMD_LIGHT3_ATT_CONST, FP_1_0),
INIT(CMD_LIGHT0_AMB_COL, 0x000000),
INIT(CMD_LIGHT0_DIF_COL, 0xffffff),
INIT(CMD_LIGHT0_SPC_COL, 0xffffff),
INIT(CMD_CULL_FACE, 0),
INIT(CMD_DRAWBUF, 0),
INIT(CMD_DRAWBUFWIDTH, 0),
INIT(CMD_DEPTHBUF, 0),
INIT(CMD_DEPTHBUFWIDTH, 0),
INITRANGE(TEXSTATE_START, TEXSTATE_END, 0),
INIT(CMD_TEX_MIPMAP0, 0x000000), /* 1.0 PSP firmware workaround? */
INIT(CMD_TEX_STRIDE0, 0x040004),
INIT(CMD_TEX_SIZE0, 0x000101),
UNINIT(182),
UNINIT(183),
UNINIT(CMD_CLUT_LOAD),
INIT(CMD_TEXENV_FUNC, 0),
INIT(CMD_TEXENV_COL, 0),
INIT(CMD_TEXCACHE_SYNC, 0),
INIT(CMD_TEXCACHE_FLUSH, 0),
INIT(CMD_FOG_FAR, 0),
INIT(CMD_FOG_NEAR, 0),
INIT(CMD_FOG_COLOR, 0),
INIT(CMD_TEXSLOPE, 0),
INIT(CMD_PSM, 0),
INIT(CMD_CLEARMODE, 0),
INIT(CMD_SCISSOR1, 0),
INIT(CMD_SCISSOR2, 0),
INIT(CMD_CLIP_NEAR, 0),
INIT(CMD_CLIP_FAR, 0),
INITRANGE(CMD_COLOR_FUNC, CMD_FIXEDCOL_DST, 0),
INIT(CMD_DEPTH_FUNC, GE_GEQUAL), /* GL_LESS -> GE_GEQUAL */
INIT(CMD_DITHER0, 0x001d0c),
INIT(CMD_DITHER1, 0x00f3e2),
INIT(CMD_DITHER2, 0x000c1d),
INIT(CMD_DITHER3, 0x00e2f3),
INIT(CMD_LOGICOP, 0),
INIT(CMD_DEPTH_MASK, 0),
INIT(CMD_RGB_MASK, 0),
INIT(CMD_ALPHA_MASK, 0),
INIT(CMD_COPY_SRC_XY, 0),
INIT(CMD_COPY_DST_XY, 0),
INIT(CMD_COPY_SIZE, 0),
INITRANGE(0xf0, 0xf9, 0), /* sceGuInit does this */
};
void __pspgl_ge_init (struct pspgl_context *c)
{
int reg;
assert(c == pspgl_curctx);
for (reg = 0; reg < sizeof(ge_init_state)/sizeof(ge_init_state[0]); reg++) {
unsigned long val = ge_init_state[reg];
if (val & 0xff000000) {
val &= 0x00ffffff;
__pspgl_context_writereg_uncached(c, reg, val);
__pspgl_context_register[reg / 32] |= 1 << (reg % 32);
}
}
glScissor(0, 0, c->draw->width, c->draw->height);
glViewport(0, 0, c->draw->width, c->draw->height);
glDepthRange(0.0, 1.0);
c->clear.depth = 0; /* = 1.0f in OpenGL coord system */
c->viewport.depth_offset = 0.0;
c->swap_interval = 1;
/* Material ambient and current color share the same hardware
register, so we need to keep separate copies of the state;
the other material colors are set up with all the other
hardware state */
c->current.color = 0xffffffff; /* default color is 1,1,1,1 */
c->material.ambient = 0xff333333; /* material ambient color is .2, .2, .2, 1 */
/* make sure all the stencil/alpha mask state is set up right */
glStencilMask(~0);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glDisable(GL_STENCIL_TEST);
}
|
/* Copyright (c) 2013, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
/* minidump_exception_ps3.h: A definition of exception codes for
* PS3 */
#ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_EXCEPTION_PS3_H__
#define GOOGLE_BREAKPAD_COMMON_MINIDUMP_EXCEPTION_PS3_H__
#include <stddef.h>
#include "native_client/google_breakpad/common/breakpad_types.h"
typedef enum {
MD_EXCEPTION_CODE_PS3_UNKNOWN = 0,
MD_EXCEPTION_CODE_PS3_TRAP_EXCEP = 1,
MD_EXCEPTION_CODE_PS3_PRIV_INSTR = 2,
MD_EXCEPTION_CODE_PS3_ILLEGAL_INSTR = 3,
MD_EXCEPTION_CODE_PS3_INSTR_STORAGE = 4,
MD_EXCEPTION_CODE_PS3_INSTR_SEGMENT = 5,
MD_EXCEPTION_CODE_PS3_DATA_STORAGE = 6,
MD_EXCEPTION_CODE_PS3_DATA_SEGMENT = 7,
MD_EXCEPTION_CODE_PS3_FLOAT_POINT = 8,
MD_EXCEPTION_CODE_PS3_DABR_MATCH = 9,
MD_EXCEPTION_CODE_PS3_ALIGN_EXCEP = 10,
MD_EXCEPTION_CODE_PS3_MEMORY_ACCESS = 11,
MD_EXCEPTION_CODE_PS3_COPRO_ALIGN = 12,
MD_EXCEPTION_CODE_PS3_COPRO_INVALID_COM = 13,
MD_EXCEPTION_CODE_PS3_COPRO_ERR = 14,
MD_EXCEPTION_CODE_PS3_COPRO_FIR = 15,
MD_EXCEPTION_CODE_PS3_COPRO_DATA_SEGMENT = 16,
MD_EXCEPTION_CODE_PS3_COPRO_DATA_STORAGE = 17,
MD_EXCEPTION_CODE_PS3_COPRO_STOP_INSTR = 18,
MD_EXCEPTION_CODE_PS3_COPRO_HALT_INSTR = 19,
MD_EXCEPTION_CODE_PS3_COPRO_HALTINST_UNKNOWN = 20,
MD_EXCEPTION_CODE_PS3_COPRO_MEMORY_ACCESS = 21,
MD_EXCEPTION_CODE_PS3_GRAPHIC = 22
} MDExceptionCodePS3;
#endif /* GOOGLE_BREAKPAD_COMMON_MINIDUMP_EXCEPTION_PS3_H__ */
|
#pragma once
#include "Basic_Units_Prototypes.h"
namespace polaris
{
namespace Basic_Units
{
namespace Implementations
{
//=======================================================================
// DESIGN NOTE:
// Separate Base classess into inheritable and non-inheritable components
//-----------------------------------------------------------------------
//================================================================================================
/// Basic Length base clase.
implementation struct Length_Implementation : public Polaris_Component<MasterType,INHERIT(Length_Implementation),NT>
{
typedef true_type Length_tag;
typedef true_type Inches_tag;
m_data(Value_Type,Value, NONE, NONE);
tag_getter_as_available(Value);
tag_setter_as_available(Value);
};
//================================================================================================
/// Basic Area base clase.
implementation struct Area_Implementation : public Length_Implementation<MasterType,INHERIT(Area_Implementation)>{ typedef true_type Area_tag;};
//================================================================================================
/// Basic Volume base clase.
implementation struct Volume_Implementation : public Length_Implementation<MasterType,INHERIT(Volume_Implementation)>{ typedef true_type Volume_tag;};
//================================================================================================
/// Basic Time base clase and Time Horizon Classes.
implementation struct Time_Implementation : public Polaris_Component<MasterType,INHERIT(Time_Implementation),NT>
{
Time_Implementation()
{
this->_Value = 0;
}
typedef true_type Time_tag;
typedef true_type Seconds_tag;
m_data(Time_Value_Type,Value, NONE, NONE);
tag_getter_as_available(Value);
tag_setter_as_available(Value);
};
//================================================================================================
/// Time Horizon base clase.
implementation struct Horizon_Implementation : public Time_Implementation<MasterType,INHERIT(Horizon_Implementation)>{ typedef true_type Horizon_tag; typedef true_type Impulsive_tag;};
//================================================================================================
/// Basic Rate and Speed base classes.
implementation struct Rate_Implementation : public Time_Implementation<MasterType,INHERIT(Rate_Implementation)>{ typedef true_type Rate_tag;};
//================================================================================================
/// Basic Rate and Speed base classes.
implementation struct Speed_Implementation : public Rate_Implementation<MasterType,INHERIT(Speed_Implementation)>
{
typedef true_type Speed_tag;
typedef true_type Length_tag;
typedef true_type Inches_tag;
};
//================================================================================================
/// Basic Currency base clase.
implementation struct Currency_Implementation : public Polaris_Component<MasterType,INHERIT(Currency_Implementation),NT>
{
typedef true_type Currency_tag;
typedef true_type Cents_tag;
m_data(Value_Type,Value, NONE, NONE);
tag_getter_as_available(Value);
tag_setter_as_available(Value);
};
//implementation struct _Currency {typedef true_type Currency_tag; typedef true_type Cents_tag; m_data(Value_Type,Value, NONE, NONE);};
}
}
}
namespace GLOBALS
{
//=================================================================================================================
// SIMULATION TIMER DEFINITION - Used by agents as a wrapper for the global _iteration variable
typedef Basic_Units::Implementations::Time_Implementation<NULLTYPE> Basic_Time;
typedef Basic_Units::Implementations::Currency_Implementation<NT> Basic_Currency;
typedef Basic_Units::Implementations::Length_Implementation<NT> Basic_Length;
typedef Basic_Units::Implementations::Area_Implementation<NT> Basic_Area;
template<typename Base_Time_Type>
struct _Simulation_Timer
{
template<typename TargetType> TargetType Current_Time()
{
return Basic_Units::Prototypes::Time<Basic_Time>::Convert_Value<Base_Time_Type,TargetType>((typename Base_Time_Type::ValueType)iteration());
}
template<typename InputType, typename ReturnType> ReturnType Future_Time(InputType Additional_Time_Increment)
{
Simulation_Timestep_Increment current_time;
current_time = (Simulation_Timestep_Increment)iteration();
Simulation_Timestep_Increment additional_time = Basic_Units::Prototypes::Time<Basic_Time>::Convert_Value<InputType, Simulation_Timestep_Increment>(Additional_Time_Increment);
ReturnType return_value = Basic_Units::Prototypes::Time<Basic_Time>::Convert_Value<Simulation_Timestep_Increment, ReturnType>(Round<int,Basic_Units::Time_Value_Type>(current_time) + Round<int,Basic_Units::Time_Value_Type>(additional_time));
return (ReturnType)Round<int,Basic_Units::Time_Value_Type>(return_value);
}
template<typename InputType> Simulation_Timestep_Increment Convert_Time_To_Simulation_Timestep(InputType Time)
{
return Basic_Units::Prototypes::Time<Basic_Time>::Convert_Value<InputType, Simulation_Timestep_Increment>(Time);
}
};
static _Simulation_Timer<Simulation_Timestep_Increment> Simulation_Time;
static Basic_Units::Prototypes::Time<Basic_Time> Time_Converter;
static Basic_Units::Prototypes::Currency<Basic_Currency> Currency_Converter;
static Basic_Units::Prototypes::Length<Basic_Length> Length_Converter;
static Basic_Units::Prototypes::Area<Basic_Area> Area_Converter;
}
using namespace GLOBALS;
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE191_Integer_Underflow__short_min_postdec_31.c
Label Definition File: CWE191_Integer_Underflow.label.xml
Template File: sources-sinks-31.tmpl.c
*/
/*
* @description
* CWE: 191 Integer Underflow
* BadSource: min Set data to the min value for short
* GoodSource: Set data to a small, non-zero number (negative two)
* Sinks: decrement
* GoodSink: Ensure there will not be an underflow before decrementing data
* BadSink : Decrement data, which can cause an Underflow
* Flow Variant: 31 Data flow using a copy of data within the same function
*
* */
#include "std_testcase.h"
#ifndef OMITBAD
void CWE191_Integer_Underflow__short_min_postdec_31_bad()
{
short data;
data = 0;
/* POTENTIAL FLAW: Use the minimum size of the data type */
data = SHRT_MIN;
{
short dataCopy = data;
short data = dataCopy;
{
/* POTENTIAL FLAW: Decrementing data could cause an underflow */
data--;
short result = data;
printIntLine(result);
}
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B() uses the GoodSource with the BadSink */
static void goodG2B()
{
short data;
data = 0;
/* FIX: Use a small, non-zero value that will not cause an underflow in the sinks */
data = -2;
{
short dataCopy = data;
short data = dataCopy;
{
/* POTENTIAL FLAW: Decrementing data could cause an underflow */
data--;
short result = data;
printIntLine(result);
}
}
}
/* goodB2G() uses the BadSource with the GoodSink */
static void goodB2G()
{
short data;
data = 0;
/* POTENTIAL FLAW: Use the minimum size of the data type */
data = SHRT_MIN;
{
short dataCopy = data;
short data = dataCopy;
/* FIX: Add a check to prevent an underflow from occurring */
if (data > SHRT_MIN)
{
data--;
short result = data;
printIntLine(result);
}
else
{
printLine("data value is too large to perform arithmetic safely.");
}
}
}
void CWE191_Integer_Underflow__short_min_postdec_31_good()
{
goodG2B();
goodB2G();
}
#endif /* OMITGOOD */
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE191_Integer_Underflow__short_min_postdec_31_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE191_Integer_Underflow__short_min_postdec_31_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "ABI42_0_0RCTValueAnimatedNode.h"
@interface ABI42_0_0RCTDiffClampAnimatedNode : ABI42_0_0RCTValueAnimatedNode
@end
|
// {{{ Copyright notice
/* Copyright (c) 2007-2009, Adam Harvey
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - The names of its contributors may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
// }}}
#ifndef DUBNIUM_FUNCTIONBREAKPOINTDIALOG_H
#define DUBNIUM_FUNCTIONBREAKPOINTDIALOG_H
#include <wx/dialog.h>
#include <wx/radiobox.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
class FunctionBreakpointDialog : public wxDialog {
public:
FunctionBreakpointDialog(wxWindow *parent, const wxString &title);
wxString GetClass() const;
wxString GetFunction() const;
bool IsMethod() const;
protected:
void OnCancel(wxCommandEvent &event);
void OnOK(wxCommandEvent &event);
void OnType(wxCommandEvent &event);
wxTextCtrl *cls, *function;
wxStaticText *clsLabel, *functionLabel;
wxRadioBox *type;
DECLARE_EVENT_TABLE()
};
#endif
// vim:set fdm=marker ts=8 sw=8 noet cin:
|
/***************************************************************************
# Copyright (c) 2015-21, NVIDIA CORPORATION. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of NVIDIA CORPORATION nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "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.
**************************************************************************/
#pragma once
#include "Core/Program/ProgramReflection.h"
namespace Falcor
{
// Forward declares for gui draw func
class Gui;
class ParameterBlock;
class FALCOR_API VariablesBufferUI
{
public:
VariablesBufferUI(ParameterBlock& variablesBufferRef) : mVariablesBufferRef(variablesBufferRef) {}
void renderUI(Gui::Widgets& widget);
private:
ParameterBlock& mVariablesBufferRef;
static std::unordered_map<std::string, int32_t> mGuiArrayIndices;
/** Recursive function for displaying shader reflection member
\param[in] widget The GUI widget to use for rendering
\param[in] memberName The member name
\param[in] var The current shader var
\return true if something changed and data needs to be sent to the GPU
*/
void renderUIVarInternal(Gui::Widgets& widget, const std::string& memberName, const ShaderVar& var);
/** Recursive function for traversing reflection data and display ui
\param[in] widget The GUI widget to use for rendering
\param[in] var The current shader var
\return true if something changed and data needs to be sent to the GPU
*/
void renderUIInternal(Gui::Widgets& widget, const ShaderVar& var);
/** Render gui widget for reflected data
\param[in] widget The GUI widget to use for rendering
\param[in] memberName string containing the name of the data member to render
\param[in] var The current shader var
\param[in] memberSize size of the data in the member
\param[in] memberTypeString
\param[in] memberType
\param[in] arraySize
\return true if something changed and data needs to be sent to the GPU
*/
void renderUIBasicVarInternal(Gui::Widgets& widget, const std::string& memberName, const ShaderVar& var, size_t memberSize, const std::string& memberTypeString, const ReflectionBasicType::Type& memberType, size_t arraySize);
};
}
|
/*-
* Copyright (c) 2005-2008 Apple Inc.
* Copyright (c) 2005 SPARTA, Inc.
* All rights reserved.
*
* This code was developed in part by Robert N. M. Watson, Senior Principal
* Scientist, SPARTA, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Inc. ("Apple") 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 APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* P4: //depot/projects/trustedbsd/openbsm/sys/bsm/audit_internal.h#6
* $FreeBSD: releng/9.3/sys/bsm/audit_internal.h 244391 2012-12-18 10:23:58Z rwatson $
*/
#ifndef _AUDIT_INTERNAL_H
#define _AUDIT_INTERNAL_H
#if defined(__linux__) && !defined(__unused)
#define __unused
#endif
/*
* audit_internal.h contains private interfaces that are shared by user space
* and the kernel for the purposes of assembling audit records. Applications
* should not include this file or use the APIs found within, or it may be
* broken with future releases of OpenBSM, which may delete, modify, or
* otherwise break these interfaces or the assumptions they rely on.
*/
struct au_token {
u_char *t_data;
size_t len;
TAILQ_ENTRY(au_token) tokens;
};
struct au_record {
char used; /* Record currently in use? */
int desc; /* Descriptor for record. */
TAILQ_HEAD(, au_token) token_q; /* Queue of BSM tokens. */
u_char *data;
size_t len;
LIST_ENTRY(au_record) au_rec_q;
};
typedef struct au_record au_record_t;
/*
* We could determined the header and trailer sizes by defining appropriate
* structures. We hold off that approach until we have a consistent way of
* using structures for all tokens. This is not straightforward since these
* token structures may contain pointers of whose contents we do not know the
* size (e.g text tokens).
*/
#define AUDIT_HEADER_EX_SIZE(a) ((a)->ai_termid.at_type+18+sizeof(u_int32_t))
#define AUDIT_HEADER_SIZE 18
#define MAX_AUDIT_HEADER_SIZE (5*sizeof(u_int32_t)+18)
#define AUDIT_TRAILER_SIZE 7
/*
* BSM token streams store fields in big endian byte order, so as to be
* portable; when encoding and decoding, we must convert byte orders for
* typed values.
*/
#define ADD_U_CHAR(loc, val) \
do { \
*(loc) = (val); \
(loc) += sizeof(u_char); \
} while(0)
#define ADD_U_INT16(loc, val) \
do { \
be16enc((loc), (val)); \
(loc) += sizeof(u_int16_t); \
} while(0)
#define ADD_U_INT32(loc, val) \
do { \
be32enc((loc), (val)); \
(loc) += sizeof(u_int32_t); \
} while(0)
#define ADD_U_INT64(loc, val) \
do { \
be64enc((loc), (val)); \
(loc) += sizeof(u_int64_t); \
} while(0)
#define ADD_MEM(loc, data, size) \
do { \
memcpy((loc), (data), (size)); \
(loc) += size; \
} while(0)
#define ADD_STRING(loc, data, size) ADD_MEM(loc, data, size)
#endif /* !_AUDIT_INTERNAL_H_ */
|
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2015-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#include <initializer_list>
#include <memory>
#include <vector>
#include "CircularBuffer.h"
#include "Filter.h"
/**
* This class implements a linear, digital filter. All types of FIR and IIR
* filters are supported. Static factory methods are provided to create commonly
* used types of filters.
*
* Filters are of the form:<br>
* y[n] = (b0 * x[n] + b1 * x[n-1] + … + bP * x[n-P]) -
* (a0 * y[n-1] + a2 * y[n-2] + … + aQ * y[n-Q])
*
* Where:<br>
* y[n] is the output at time "n"<br>
* x[n] is the input at time "n"<br>
* y[n-1] is the output from the LAST time step ("n-1")<br>
* x[n-1] is the input from the LAST time step ("n-1")<br>
* b0 … bP are the "feedforward" (FIR) gains<br>
* a0 … aQ are the "feedback" (IIR) gains<br>
* IMPORTANT! Note the "-" sign in front of the feedback term! This is a common
* convention in signal processing.
*
* What can linear filters do? Basically, they can filter, or diminish, the
* effects of undesirable input frequencies. High frequencies, or rapid changes,
* can be indicative of sensor noise or be otherwise undesirable. A "low pass"
* filter smooths out the signal, reducing the impact of these high frequency
* components. Likewise, a "high pass" filter gets rid of slow-moving signal
* components, letting you detect large changes more easily.
*
* Example FRC applications of filters:
* - Getting rid of noise from an analog sensor input (note: the roboRIO's FPGA
* can do this faster in hardware)
* - Smoothing out joystick input to prevent the wheels from slipping or the
* robot from tipping
* - Smoothing motor commands so that unnecessary strain isn't put on
* electrical or mechanical components
* - If you use clever gains, you can make a PID controller out of this class!
*
* For more on filters, I highly recommend the following articles:<br>
* http://en.wikipedia.org/wiki/Linear_filter<br>
* http://en.wikipedia.org/wiki/Iir_filter<br>
* http://en.wikipedia.org/wiki/Fir_filter<br>
*
* Note 1: PIDGet() should be called by the user on a known, regular period.
* You can set up a Notifier to do this (look at the WPILib PIDController
* class), or do it "inline" with code in a periodic function.
*
* Note 2: For ALL filters, gains are necessarily a function of frequency. If
* you make a filter that works well for you at, say, 100Hz, you will most
* definitely need to adjust the gains if you then want to run it at 200Hz!
* Combining this with Note 1 - the impetus is on YOU as a developer to make
* sure PIDGet() gets called at the desired, constant frequency!
*/
class LinearDigitalFilter : public Filter {
public:
LinearDigitalFilter(std::shared_ptr<PIDSource> source,
std::initializer_list<double> ffGains,
std::initializer_list<double> fbGains);
LinearDigitalFilter(std::shared_ptr<PIDSource> source,
std::initializer_list<double> ffGains,
const std::vector<double>& fbGains);
LinearDigitalFilter(std::shared_ptr<PIDSource> source,
const std::vector<double>& ffGains,
std::initializer_list<double> fbGains);
LinearDigitalFilter(std::shared_ptr<PIDSource> source,
const std::vector<double>& ffGains,
const std::vector<double>& fbGains);
// Static methods to create commonly used filters
static LinearDigitalFilter SinglePoleIIR(std::shared_ptr<PIDSource> source,
double timeConstant, double period);
static LinearDigitalFilter HighPass(std::shared_ptr<PIDSource> source,
double timeConstant, double period);
static LinearDigitalFilter MovingAverage(std::shared_ptr<PIDSource> source,
unsigned int taps);
// Filter interface
double Get() const override;
void Reset() override;
// PIDSource interface
double PIDGet() override;
private:
CircularBuffer<double> m_inputs;
CircularBuffer<double> m_outputs;
std::vector<double> m_inputGains;
std::vector<double> m_outputGains;
};
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_TEST_PASSWORD_AUTOFILL_AGENT_H_
#define COMPONENTS_AUTOFILL_CONTENT_RENDERER_TEST_PASSWORD_AUTOFILL_AGENT_H_
#include "components/autofill/content/renderer/password_autofill_agent.h"
namespace autofill {
class TestPasswordAutofillAgent : public PasswordAutofillAgent {
public:
explicit TestPasswordAutofillAgent(content::RenderView* render_view);
virtual ~TestPasswordAutofillAgent();
private:
// Always returns true. This allows browser tests with "data: " URL scheme to
// work with the password manager.
// PasswordAutofillAgent:
virtual bool OriginCanAccessPasswordManager(
const WebKit::WebSecurityOrigin& origin) OVERRIDE;
};
} // namespace autofill
#endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_TEST_PASSWORD_AUTOFILL_AGENT_H_
|
#include "em_code.h"
#include "em_private.h"
/* $Id$ */
void CC_exc(arith c1, arith c2)
{
PS(ps_exc);
CST(c1);
COMMA();
CST(c2);
NL();
}
|
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#ifndef _FWL_CARET_LIGHT_H
#define _FWL_CARET_LIGHT_H
class CFWL_Widget;
class CFWL_WidgetProperties;
class CFWL_Caret;
class CFWL_Caret : public CFWL_Widget {
public:
static CFWL_Caret* Create();
FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL);
FWL_ERR ShowCaret(FX_BOOL bFlag = TRUE);
FWL_ERR GetFrequency(FX_DWORD& elapse);
FWL_ERR SetFrequency(FX_DWORD elapse);
FWL_ERR SetColor(CFX_Color crFill);
protected:
CFWL_Caret();
virtual ~CFWL_Caret();
};
#endif
|
#include <convexHull/convexHull.h>
#include <math.h>
#define CONVEX_HULL_ALPHA_MASK 0xFF000000
void convexHullCrop(convexHull *convexHull, const uint8_t *source, const uint32_t width, const uint32_t height, const convexHullVector pivot)
{
uint32_t i;
float r;
float rStep = 6.283185f / convexHull->nodeCount;
const convexHullVector halfDim = (convexHullVector){ (float)(width >> 1), (float)(height >> 1) };
r = 0;
for(i = 0; i < convexHull->nodeCount; ++i) {
convexHullVector *node = convexHull->nodes + i;
convexHullVector direction = (convexHullVector){ -cosf(r), -sinf(r) };
float abscos;
float abssin;
float radius;
// Create edge points
node->x = -direction.x;
node->y = -direction.y;
abscos = fabsf(node->x);
abssin = fabsf(node->y);
if(halfDim.x * abssin <= halfDim.y * abscos) {
radius = halfDim.x / abscos;
}
else {
radius = halfDim.y / abssin;
}
--radius;
node->x *= radius;
node->y *= radius;
// Normalize
node->x += halfDim.x;
node->y += halfDim.y;
// Crop until opaque pixel is found
for(;;) {
const uint32_t x = (uint32_t)node->x;
const uint32_t y = (uint32_t)node->y;
// Check alpha
if(((uint32_t*)source)[x + y * width] & CONVEX_HULL_ALPHA_MASK) {
break;
}
// Next
node->x += direction.x;
node->y += direction.y;
radius -= 1.0f;
// Prevent overflows
if(radius < 0) break;
}
// Move to pivot
node->x -= pivot.x;
node->y -= pivot.y;
r += rStep;
}
} |
/* +------------------------------------------------------------------------+
| Mobile Robot Programming Toolkit (MRPT) |
| https://www.mrpt.org/ |
| |
| Copyright (c) 2005-2022, Individual contributors, see AUTHORS file |
| See: https://www.mrpt.org/Authors - All rights reserved. |
| Released under BSD License. See: https://www.mrpt.org/License |
+------------------------------------------------------------------------+ */
#pragma once
#include <mrpt/obs/CActionCollection.h>
#include <mrpt/obs/CObservation.h>
#include <mrpt/obs/CSensoryFrame.h>
#include "CRegistrationDeciderOrOptimizer.h"
namespace mrpt::graphslam::deciders
{
/**\brief Interface for implementing node registration classes.
*
* CNodeRegistrationDecider provides the basic methods that have to exist in
* every node registration decider class. For an example of inheriting from
* this class see CFixedIntervalsNRD.
*
* \note As a naming convention, all the implemented node registration deciders
* are suffixed with the NRD acronym.
*
* \ingroup mrpt_graphslam_grp
*/
template <class GRAPH_T>
class CNodeRegistrationDecider
: public virtual mrpt::graphslam::CRegistrationDeciderOrOptimizer<GRAPH_T>
{
public:
/**\brief Handy typedefs */
/**\{*/
/**\brief Parent of current class */
using parent_t = mrpt::graphslam::CRegistrationDeciderOrOptimizer<GRAPH_T>;
/**\brief type of graph constraints */
using constraint_t = typename GRAPH_T::constraint_t;
/**\brief type of underlying poses (2D/3D). */
using pose_t = typename GRAPH_T::constraint_t::type_value;
using global_pose_t = typename GRAPH_T::global_pose_t;
using inf_mat_t = mrpt::math::CMatrixFixed<
double, constraint_t::state_length, constraint_t::state_length>;
/**\}*/
/**\brief Default class constructor.*/
CNodeRegistrationDecider();
/**\brief Default class destructor.*/
~CNodeRegistrationDecider() override = default;
/**\brief Getter method for fetching the currently estimated robot position.
*
* In single-robot situations this is most likely going to be the last
* registered node position + an position/uncertainty increment from that
* position
*/
virtual global_pose_t getCurrentRobotPosEstimation() const;
void getDescriptiveReport(std::string* report_str) const override;
protected:
/**\brief Reset the given PDF method and assign a fixed high-certainty
* Covariance/Information matrix
*/
void resetPDF(constraint_t* c);
/**\brief Check whether a new node should be registered in the
* graph.
*
* This should be the key-method in any implementation of this
* interface. Should call registerNewNodeAtEnd method if the registration
* condition is satisfied.
*
* \return True upon successful node registration in the graph
*/
virtual bool checkRegistrationCondition();
/**\brief Utility methods for adding new poses to the graph.
*/
/**\{*/
/** Add a new constraint at the end of the graph.
* \param[in] constraint Constraint transformation from the latest
* registered to the new node.
*
* \return True upon successful node registration.
*/
bool registerNewNodeAtEnd(const typename GRAPH_T::constraint_t& constraint);
/**\brief Same goal as the previous method - uses the m_since_prev_node_PDF
* as the constraint at the end.
*/
bool registerNewNodeAtEnd();
/**\brief Get a global_pose_t and fill the NODE_ANNOTATIONS-related fields
*
* \note Users are encouraged to override this method in case they have
* defined a new TNodeAnnotations struct and want to use this metadata in
* the graph nodes.
*/
virtual void addNodeAnnotsToPose(global_pose_t* pose) const;
/**\}*/
/**\brief Store the last registered NodeID.
*
* We don't store its pose since it will most likely change due to calls to
* the
* graph-optimization procedure / dijkstra_node_estimation
*/
mrpt::graphs::TNodeID m_prev_registered_nodeID;
/**\brief Tracking the PDF of the current position of the robot with
* regards to the <b previous registered node</b>.
*/
constraint_t m_since_prev_node_PDF;
/**\brief Initial information matrix for paths
*
* Large values for this indicate that I am sure of the corresponding
* (initial) pose
*/
inf_mat_t m_init_inf_mat;
};
} // namespace mrpt::graphslam::deciders
#include "CNodeRegistrationDecider_impl.h"
|
// Copyright 2014 <chaishushan{AT}gmail.com>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Auto Generated By 'go generate', DONOT EDIT!!!
// +build cgo
#include "./internal/libwebp/src/dsp/lossless_neon.c"
|
/*
* leds.c -- control the led's on a Motorola mc68ec0x0 board.
*
* Copyright (c) 1995 Cygnus Support
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#include "leds.h"
void zylons();
void led_putnum();
/*
* led_putnum -- print a hex number on the LED. the value of num must be a char with
* the ascii value. ie... number 0 is '0', a is 'a', ' ' (null) clears
* the led display.
* Setting the bit to 0 turns it on, 1 turns it off.
* the LED's are controlled by setting the right bit mask in the base
* address.
* The bits are:
* [d.p | g | f | e | d | c | b | a ] is the byte.
*
* The locations are:
*
* a
* -----
* f | | b
* | g |
* -----
* | |
* e | | c
* -----
* d . d.p (decimal point)
*/
void
led_putnum ( num )
char num;
{
static unsigned char *leds = (unsigned char *)LED_ADDR;
static unsigned char num_bits [18] = {
0xff, /* clear all */
0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x98, /* numbers 0-9 */
0x98, 0x20, 0x3, 0x27, 0x21, 0x4, 0xe /* letters a-f */
};
if (num >= '0' && num <= '9')
num = (num - '0') + 1;
if (num >= 'a' && num <= 'f')
num = (num - 'a') + 12;
if (num == ' ')
num = 0;
*leds = num_bits[num];
}
/*
* zylons -- draw a rotating pattern. NOTE: this function never returns.
*/
void
zylons()
{
unsigned char *leds = (unsigned char *)LED_ADDR;
unsigned char curled = 0xfe;
while (1)
{
*leds = curled;
curled = (curled >> 1) | (curled << 7);
delay ( 200 );
}
}
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE78_OS_Command_Injection__wchar_t_console_w32spawnl_64a.c
Label Definition File: CWE78_OS_Command_Injection.strings.label.xml
Template File: sources-sink-64a.tmpl.c
*/
/*
* @description
* CWE: 78 OS Command Injection
* BadSource: console Read input from the console
* GoodSource: Fixed string
* Sinks: w32spawnl
* BadSink : execute command with wspawnl
* Flow Variant: 64 Data flow: void pointer to data passed from one function to another in different source files
*
* */
#include "std_testcase.h"
#include <wchar.h>
#ifdef _WIN32
#define COMMAND_INT_PATH L"%WINDIR%\\system32\\cmd.exe"
#define COMMAND_INT L"cmd.exe"
#define COMMAND_ARG1 L"/c"
#define COMMAND_ARG2 L"dir "
#define COMMAND_ARG3 data
#else /* NOT _WIN32 */
#include <unistd.h>
#define COMMAND_INT_PATH L"/bin/sh"
#define COMMAND_INT L"sh"
#define COMMAND_ARG1 L"-c"
#define COMMAND_ARG2 L"ls "
#define COMMAND_ARG3 data
#endif
#include <process.h>
#ifndef OMITBAD
/* bad function declaration */
void CWE78_OS_Command_Injection__wchar_t_console_w32spawnl_64b_badSink(void * dataVoidPtr);
void CWE78_OS_Command_Injection__wchar_t_console_w32spawnl_64_bad()
{
wchar_t * data;
wchar_t dataBuffer[100] = COMMAND_ARG2;
data = dataBuffer;
{
/* Read input from the console */
size_t dataLen = wcslen(data);
/* if there is room in data, read into it from the console */
if (100-dataLen > 1)
{
/* POTENTIAL FLAW: Read data from the console */
if (fgetws(data+dataLen, (int)(100-dataLen), stdin) != NULL)
{
/* The next few lines remove the carriage return from the string that is
* inserted by fgetws() */
dataLen = wcslen(data);
if (dataLen > 0 && data[dataLen-1] == L'\n')
{
data[dataLen-1] = L'\0';
}
}
else
{
printLine("fgetws() failed");
/* Restore NUL terminator if fgetws fails */
data[dataLen] = L'\0';
}
}
}
CWE78_OS_Command_Injection__wchar_t_console_w32spawnl_64b_badSink(&data);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
void CWE78_OS_Command_Injection__wchar_t_console_w32spawnl_64b_goodG2BSink(void * dataVoidPtr);
static void goodG2B()
{
wchar_t * data;
wchar_t dataBuffer[100] = COMMAND_ARG2;
data = dataBuffer;
/* FIX: Append a fixed string to data (not user / external input) */
wcscat(data, L"*.*");
CWE78_OS_Command_Injection__wchar_t_console_w32spawnl_64b_goodG2BSink(&data);
}
void CWE78_OS_Command_Injection__wchar_t_console_w32spawnl_64_good()
{
goodG2B();
}
#endif /* OMITGOOD */
/* Below is the main(). It is only used when building this testcase on
* its own for testing or for building a binary to use in testing binary
* analysis tools. It is not used when compiling all the testcases as one
* application, which is how source code analysis tools are tested.
*/
#ifdef INCLUDEMAIN
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE78_OS_Command_Injection__wchar_t_console_w32spawnl_64_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE78_OS_Command_Injection__wchar_t_console_w32spawnl_64_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_SSL_SSL_ERROR_HANDLER_H_
#define CONTENT_BROWSER_SSL_SSL_ERROR_HANDLER_H_
#include <string>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "content/common/content_export.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/global_request_id.h"
#include "net/ssl/ssl_info.h"
#include "url/gurl.h"
namespace net {
class URLRequest;
} // namespace net
namespace content {
class WebContents;
// SSLErrorHandler is the UI-thread class for handling SSL certificate
// errors. Users of this class can call CancelRequest(),
// ContinueRequest(), or DenyRequest() when a decision about how to
// handle the error has been made. Users of this class must
// call exactly one of those methods exactly once.
class SSLErrorHandler {
public:
class CONTENT_EXPORT Delegate {
public:
// Called when SSLErrorHandler decides to cancel the request because of
// the SSL error.
virtual void CancelSSLRequest(int error, const net::SSLInfo* ssl_info) = 0;
// Called when SSLErrorHandler decides to continue the request despite the
// SSL error.
virtual void ContinueSSLRequest() = 0;
protected:
virtual ~Delegate() {}
};
SSLErrorHandler(WebContents* web_contents,
const base::WeakPtr<Delegate>& delegate,
bool is_main_frame_request,
const GURL& url,
int net_error,
const net::SSLInfo& ssl_info,
bool fatal);
virtual ~SSLErrorHandler();
const net::SSLInfo& ssl_info() const { return ssl_info_; }
const GURL& request_url() const { return request_url_; }
bool is_main_frame_request() const { return is_main_frame_request_; }
WebContents* web_contents() const { return web_contents_; }
int cert_error() const { return cert_error_; }
bool fatal() const { return fatal_; }
// Cancels the associated net::URLRequest.
CONTENT_EXPORT void CancelRequest();
// Continue the net::URLRequest ignoring any previous errors. Note that some
// errors cannot be ignored, in which case this will result in the request
// being canceled.
void ContinueRequest();
// Cancels the associated net::URLRequest and mark it as denied. The renderer
// processes such request in a special manner, optionally replacing them
// with alternate content (typically frames content is replaced with a
// warning message).
void DenyRequest();
private:
base::WeakPtr<Delegate> delegate_;
// The URL for the request that generated the error.
const GURL request_url_;
// Whether this request is for the main frame's html.
const bool is_main_frame_request_;
// The net::SSLInfo associated with the request that generated the error.
const net::SSLInfo ssl_info_;
// A net error code describing the error that occurred.
const int cert_error_;
// True if the error is from a host requiring certificate errors to be fatal.
const bool fatal_;
// The WebContents associated with the request that generated the error.
WebContents* web_contents_;
DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler);
};
} // namespace content
#endif // CONTENT_BROWSER_SSL_SSL_ERROR_HANDLER_H_
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE191_Integer_Underflow__short_fscanf_predec_51a.c
Label Definition File: CWE191_Integer_Underflow.label.xml
Template File: sources-sinks-51a.tmpl.c
*/
/*
* @description
* CWE: 191 Integer Underflow
* BadSource: fscanf Read data from the console using fscanf()
* GoodSource: Set data to a small, non-zero number (negative two)
* Sinks: decrement
* GoodSink: Ensure there will not be an underflow before decrementing data
* BadSink : Decrement data, which can cause an Underflow
* Flow Variant: 51 Data flow: data passed as an argument from one function to another in different source files
*
* */
#include "std_testcase.h"
#ifndef OMITBAD
/* bad function declaration */
void CWE191_Integer_Underflow__short_fscanf_predec_51b_badSink(short data);
void CWE191_Integer_Underflow__short_fscanf_predec_51_bad()
{
short data;
data = 0;
/* POTENTIAL FLAW: Use a value input from the console */
fscanf (stdin, "%hd", &data);
CWE191_Integer_Underflow__short_fscanf_predec_51b_badSink(data);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
void CWE191_Integer_Underflow__short_fscanf_predec_51b_goodG2BSink(short data);
static void goodG2B()
{
short data;
data = 0;
/* FIX: Use a small, non-zero value that will not cause an underflow in the sinks */
data = -2;
CWE191_Integer_Underflow__short_fscanf_predec_51b_goodG2BSink(data);
}
/* goodB2G uses the BadSource with the GoodSink */
void CWE191_Integer_Underflow__short_fscanf_predec_51b_goodB2GSink(short data);
static void goodB2G()
{
short data;
data = 0;
/* POTENTIAL FLAW: Use a value input from the console */
fscanf (stdin, "%hd", &data);
CWE191_Integer_Underflow__short_fscanf_predec_51b_goodB2GSink(data);
}
void CWE191_Integer_Underflow__short_fscanf_predec_51_good()
{
goodG2B();
goodB2G();
}
#endif /* OMITGOOD */
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE191_Integer_Underflow__short_fscanf_predec_51_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE191_Integer_Underflow__short_fscanf_predec_51_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_PROTOCOL_CONTENT_DESCRIPTION_H_
#define REMOTING_PROTOCOL_CONTENT_DESCRIPTION_H_
#include <string>
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "remoting/protocol/session_config.h"
namespace buzz {
class XmlElement;
} // namespace buzz
namespace remoting {
namespace protocol {
// ContentDescription used for chromoting sessions. It contains the information
// from the content description stanza in the session initialization handshake.
//
// This class also provides a type abstraction so that the Chromotocol Session
// interface does not need to depend on libjingle.
class ContentDescription {
public:
static const char kChromotingContentName[];
ContentDescription(scoped_ptr<CandidateSessionConfig> config,
scoped_ptr<buzz::XmlElement> authenticator_message,
const std::string& quic_config_message);
~ContentDescription();
const CandidateSessionConfig* config() const {
return candidate_config_.get();
}
const buzz::XmlElement* authenticator_message() const {
return authenticator_message_.get();
}
const std::string& quic_config_message() const {
return quic_config_message_;
}
buzz::XmlElement* ToXml() const;
static scoped_ptr<ContentDescription> ParseXml(
const buzz::XmlElement* element,
bool webrtc_transport);
private:
scoped_ptr<const CandidateSessionConfig> candidate_config_;
scoped_ptr<const buzz::XmlElement> authenticator_message_;
std::string quic_config_message_;
static bool ParseChannelConfigs(const buzz::XmlElement* const element,
const char tag_name[],
bool codec_required,
bool optional,
std::list<ChannelConfig>* const configs);
};
} // namespace protocol
} // namespace remoting
#endif // REMOTING_PROTOCOL_CONTENT_DESCRIPTION_H_
|
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_VIZ_SERVICE_DISPLAY_GL_RENDERER_DRAW_CACHE_H_
#define COMPONENTS_VIZ_SERVICE_DISPLAY_GL_RENDERER_DRAW_CACHE_H_
#include <vector>
#include "base/macros.h"
#include "components/viz/common/resources/resource_id.h"
#include "components/viz/service/display/program_binding.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/geometry/mask_filter_info.h"
namespace viz {
// Collects 4 floats at a time for easy upload to GL.
struct Float4 {
float data[4];
};
// Collects 16 floats at a time for easy upload to GL.
struct Float16 {
float data[16];
};
// A cache for storing textured quads to be drawn. Stores the minimum required
// data to tell if two back to back draws only differ in their transform. Quads
// that only differ by transform may be coalesced into a single draw call.
struct TexturedQuadDrawCache {
TexturedQuadDrawCache();
TexturedQuadDrawCache(const TexturedQuadDrawCache&) = delete;
TexturedQuadDrawCache& operator=(const TexturedQuadDrawCache&) = delete;
~TexturedQuadDrawCache();
bool is_empty = true;
// Values tracked to determine if textured quads may be coalesced.
ProgramKey program_key;
ResourceId resource_id = kInvalidResourceId;
bool needs_blending = false;
bool nearest_neighbor = false;
SkColor background_color = 0;
gfx::MaskFilterInfo mask_filter_info;
// A cache for the coalesced quad data.
std::vector<Float4> uv_xform_data;
std::vector<float> vertex_opacity_data;
std::vector<Float16> matrix_data;
// Don't batch if tex clamp rect is given.
Float4 tex_clamp_rect_data;
// Video frames need special white level adjustment.
bool is_video_frame = false;
};
} // namespace viz
#endif // COMPONENTS_VIZ_SERVICE_DISPLAY_GL_RENDERER_DRAW_CACHE_H_
|
/* Copyright 2015 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
* TI bq25890/bq25892/bq25895 battery charger driver.
*/
#ifndef __CROS_EC_BQ2589X_H
#define __CROS_EC_BQ2589X_H
/* Registers */
#define BQ2589X_REG_INPUT_CURR 0x00
#define BQ2589X_REG_VINDPM 0x01
#define BQ2589X_REG_CFG1 0x02
#define BQ2589X_REG_CFG2 0x03
#define BQ2589X_REG_CHG_CURR 0x04
#define BQ2589X_REG_PRE_CHG_CURR 0x05
#define BQ2589X_REG_CHG_VOLT 0x06
#define BQ2589X_REG_TIMER 0x07
#define BQ2589X_REG_IR_COMP 0x08
#define BQ2589X_REG_FORCE 0x09
#define BQ2589X_REG_BOOST_MODE 0x0A
#define BQ2589X_REG_STATUS 0x0B /* Read-only */
#define BQ2589X_REG_FAULT 0x0C /* Read-only */
#define BQ2589X_REG_VINDPM_THRESH 0x0D
#define BQ2589X_REG_ADC_BATT_VOLT 0x0E /* Read-only */
#define BQ2589X_REG_ADC_SYS_VOLT 0x0F /* Read-only */
#define BQ2589X_REG_ADC_TS 0x10 /* Read-only */
#define BQ2589X_REG_ADC_VBUS_VOLT 0x11 /* Read-only */
#define BQ2589X_REG_ADC_CHG_CURR 0x12 /* Read-only */
#define BQ2589X_REG_ADC_INPUT_CURR 0x13 /* Read-only */
#define BQ2589X_REG_ID 0x14
/* REG00 : input current register bit definitions */
#define BQ2589X_INPUT_CURR_EN_HIZ (1<<7)
#define BQ2589X_INPUT_CURR_EN_ILIM (1<<6)
/* REG02 : first configuration register bit definitions */
#define BQ2589X_CFG1_CONV_START (1<<7)
#define BQ2589X_CFG1_ICO_EN (1<<4)
#define BQ2589X_CFG1_AUTO_DPDM_EN (1<<0)
/* REG03 : second configuration register bit definitions */
#define BQ2589X_CFG2_CHG_CONFIG (1<<4)
#define BQ2589X_CFG2_OTG_CONFIG (1<<5)
#define BQ2589X_CFG2_WD_RST (1<<6)
/* REG08 : IR compensation definitions */
#define BQ2589X_IR_BAT_COMP_140MOHM (7 << 5)
#define BQ2589X_IR_BAT_COMP_120MOHM (6 << 5)
#define BQ2589X_IR_BAT_COMP_100MOHM (5 << 5)
#define BQ2589X_IR_BAT_COMP_80MOHM (4 << 5)
#define BQ2589X_IR_BAT_COMP_60MOHM (3 << 5)
#define BQ2589X_IR_BAT_COMP_40MOHM (2 << 5)
#define BQ2589X_IR_BAT_COMP_20MOHM (1 << 5)
#define BQ2589X_IR_BAT_COMP_0MOHM (0 << 5)
#define BQ2589X_IR_VCLAMP_224MV (7 << 2)
#define BQ2589X_IR_VCLAMP_192MV (6 << 2)
#define BQ2589X_IR_VCLAMP_160MV (5 << 2)
#define BQ2589X_IR_VCLAMP_128MV (4 << 2)
#define BQ2589X_IR_VCLAMP_96MV (3 << 2)
#define BQ2589X_IR_VCLAMP_64MV (2 << 2)
#define BQ2589X_IR_VCLAMP_32MV (1 << 2)
#define BQ2589X_IR_VCLAMP_0MV (0 << 2)
#define BQ2589X_IR_TREG_120C (3 << 0)
#define BQ2589X_IR_TREG_100C (2 << 0)
#define BQ2589X_IR_TREG_80C (1 << 0)
#define BQ2589X_IR_TREG_60C (0 << 0)
#define BQ2589X_IR_COMP_DEFAULT (BQ2589X_IR_TREG_120C | BQ2589X_IR_VCLAMP_0MV |\
BQ2589X_IR_BAT_COMP_0MOHM)
#define BQ2589X_TERM_CURRENT_LIMIT_DEFAULT 256
/* 5V VBUS Boost settings */
#define BQ2589X_BOOSTV_MV(mv) (((((mv) - 4550)/64) & 0xF) << 4)
#define BQ2589X_BOOSTV_DEFAULT BQ2589X_BOOSTV_MV(4998)
#define BQ2589X_BOOST_LIM_500MA 0x00
#define BQ2589X_BOOST_LIM_750MA 0x01
#define BQ2589X_BOOST_LIM_1200MA 0x02
#define BQ2589X_BOOST_LIM_1400MA 0x03
#define BQ2589X_BOOST_LIM_1650MA 0x04
#define BQ2589X_BOOST_LIM_1875MA 0x05
#define BQ2589X_BOOST_LIM_2150MA 0x06
#define BQ2589X_BOOST_LIM_2450MA 0x07
#define BQ2589X_BOOST_LIM_DEFAULT BQ2589X_BOOST_LIM_1400MA
#define BQ2589X_BOOST_DEFAULT (BQ2589X_BOOST_LIM_DEFAULT |\
BQ2589X_BOOSTV_DEFAULT)
/* REG14: Device ID, reset and ICO status */
#define BQ2589X_DEVICE_ID_MASK 0x38
#define BQ25890_DEVICE_ID 0x18
#define BQ25892_DEVICE_ID 0x00
#define BQ25895_DEVICE_ID 0x38
#define BQ2589X_ID_ICO_OPTIMIZED 0x40
/* Variant-specific configuration */
#if defined(CONFIG_CHARGER_BQ25890)
#define BQ2589X_DEVICE_ID BQ25890_DEVICE_ID
#define BQ2589X_ADDR (0x6A << 1)
#elif defined(CONFIG_CHARGER_BQ25895)
#define BQ2589X_DEVICE_ID BQ25895_DEVICE_ID
#define BQ2589X_ADDR (0x6A << 1)
#elif defined(CONFIG_CHARGER_BQ25892)
#define BQ2589X_DEVICE_ID BQ25892_DEVICE_ID
#define BQ2589X_ADDR (0x6B << 1)
#else
#error BQ2589X unknown variant
#endif
#endif /* __CROS_EC_BQ2589X_H */
|
//
// BayesianKit.h
// Licensed under the terms of the BSD License, as specified below.
//
/*
Copyright (c) 2010, Samuel Mendes
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 ᐱ 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.
*/
#import <BayesianKit/BKClassifier.h>
#import <BayesianKit/BKDataPool.h>
#import <BayesianKit/BKTokenData.h>
#import <BayesianKit/BKTokenizer.h>
#import <BayesianKit/BKTokenizing.h> |
/*****************************************************************************
Copyright (c) 2011, Intel Corp.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************
* Contents: Native high-level C interface to LAPACK function cptsv
* Author: Intel Corporation
* Generated November, 2011
*****************************************************************************/
#include "lapacke.h"
#include "lapacke_utils.h"
lapack_int LAPACKE_cptsv( int matrix_order, lapack_int n, lapack_int nrhs,
float* d, lapack_complex_float* e,
lapack_complex_float* b, lapack_int ldb )
{
if( matrix_order != LAPACK_COL_MAJOR && matrix_order != LAPACK_ROW_MAJOR ) {
LAPACKE_xerbla( "LAPACKE_cptsv", -1 );
return -1;
}
#ifndef LAPACK_DISABLE_NAN_CHECK
/* Optionally check input matrices for NaNs */
if( LAPACKE_cge_nancheck( matrix_order, n, nrhs, b, ldb ) ) {
return -6;
}
if( LAPACKE_s_nancheck( n, d, 1 ) ) {
return -4;
}
if( LAPACKE_c_nancheck( n-1, e, 1 ) ) {
return -5;
}
#endif
return LAPACKE_cptsv_work( matrix_order, n, nrhs, d, e, b, ldb );
}
|
#ifndef TSCENEHANDLE_H
#define TSCENEHANDLE_H
#include <QObject>
#include "tcommon.h"
#undef DVAPI
#undef DVVAR
#ifdef TOONZLIB_EXPORTS
#define DVAPI DV_EXPORT_API
#define DVVAR DV_EXPORT_VAR
#else
#define DVAPI DV_IMPORT_API
#define DVVAR DV_IMPORT_VAR
#endif
// forward declaration
class ToonzScene;
class TFilePath;
//=============================================================================
// TSceneHandle
//-----------------------------------------------------------------------------
class DVAPI TSceneHandle : public QObject
{
Q_OBJECT
ToonzScene *m_scene;
bool m_dirtyFlag;
public:
TSceneHandle();
~TSceneHandle();
ToonzScene *getScene() const;
void setScene(ToonzScene *scene);
void notifySceneChanged(bool setDirty = true)
{
emit sceneChanged();
if (setDirty)
setDirtyFlag(true);
}
void notifySceneSwitched()
{
emit sceneSwitched();
setDirtyFlag(false);
}
void notifyCastChange() { emit castChanged(); }
void notifyCastFolderAdded(const TFilePath &path) { emit castFolderAdded(path); }
void notifyNameSceneChange() { emit nameSceneChanged(); }
void notifyPreferenceChanged() { emit preferenceChanged(); }
void setDirtyFlag(bool dirtyFlag)
{
if (m_dirtyFlag == dirtyFlag)
return;
m_dirtyFlag = dirtyFlag;
emit nameSceneChanged();
}
bool getDirtyFlag() const { return m_dirtyFlag; }
public slots:
void setDirtyFlag()
{
if (m_dirtyFlag == true)
return;
m_dirtyFlag = true;
emit nameSceneChanged();
}
signals:
void sceneSwitched();
void sceneChanged();
void castChanged();
void castFolderAdded(const TFilePath &path);
void nameSceneChanged();
void preferenceChanged();
};
#endif //TSCENEHANDLE_H
|
/*=============================================================================
# Filename: Client.h
# Author: Bookug Lobert
# Mail: 1181955272@qq.com
# Last Modified: 2016-02-23 13:40
# Description: originally written by hanshuo, modified by zengli
=============================================================================*/
#ifndef _SERVER_CLIENT_H
#define _SERVER_CLIENT_H
#include "../Util/Util.h"
#include "Socket.h"
class Client
{
public:
Client();
Client(std::string _ip, unsigned short _port);
Client(unsigned short _port);
~Client();
bool connectServer();
bool disconnectServer();
bool send(const std::string& _msg);
bool receiveResponse(std::string& _recv_msg);
void run();
private:
std::string ip;
unsigned short port;
std::string password;
Socket socket;
int random_key;
};
#endif // _SERVER_CLIENT_H
|
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SKSL_SETTING
#define SKSL_SETTING
#include "src/sksl/SkSLContext.h"
#include "src/sksl/ir/SkSLExpression.h"
namespace SkSL {
/**
* Represents a compile-time constant setting, such as sk_Caps.fbFetchSupport. These IRNodes should
* only exist in a dehydrated module. These nodes are replaced with the value of the setting during
* rehydration or compilation (i.e., whenever fReplaceSettings is true).
*/
class Setting final : public Expression {
public:
inline static constexpr Kind kExpressionKind = Kind::kSetting;
Setting(int line, skstd::string_view name, const Type* type)
: INHERITED(line, kExpressionKind, type)
, fName(std::move(name)) {}
// Creates an SkSL setting expression if `fReplaceSettings` is false, or the current value of
// the setting when it is true. Reports errors via the ErrorReporter.
// (There's no failsafe Make equivalent, because there really isn't a good fallback expression
// to produce when the `name` lookup fails. We wouldn't even know the expected type.)
static std::unique_ptr<Expression> Convert(const Context& context, int line,
const skstd::string_view& name);
std::unique_ptr<Expression> clone() const override {
return std::make_unique<Setting>(fLine, this->name(), &this->type());
}
const skstd::string_view& name() const {
return fName;
}
String description() const override {
return String(this->name());
}
bool hasProperty(Property property) const override {
return false;
}
private:
skstd::string_view fName;
using INHERITED = Expression;
};
} // namespace SkSL
#endif
|
#ifndef PRECOMPILED_CPPIMPORTLIGHT_H_
#define PRECOMPILED_CPPIMPORTLIGHT_H_
// TODO: Include here the precompiled headers of other plug-ins that this plug-in uses. Only the "public" part of
// those headers will be included here
#include "OOInteraction/src/precompiled.h"
#include "InteractionBase/src/precompiled.h"
#include "OOVisualization/src/precompiled.h"
#include "VisualizationBase/src/precompiled.h"
#include "OOModel/src/precompiled.h"
#include "ModelBase/src/precompiled.h"
#include "Logger/src/precompiled.h"
#include "SelfTest/src/precompiled.h"
#include "Core/src/precompiled.h"
#include "Core/src/global.h"
// Put here includes which appear in header files. This will also be visible to other plug-in which depend on this one
// and will be included in their precompiled headers
#if defined(CppImportLight_EXPORTS)
// Put here includes which only appear in compilation units and do not appear in headers. Precompiled headers of
// plug-ins which depend on this one will not include these headers.
#include <clang/Basic/FileManager.h>
#include <clang/Basic/SourceManager.h>
#include <clang/Lex/Lexer.h>
#endif
#endif /* PRECOMPILED_CPPIMPORTLIGHT_H_ */
|
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
#include <dtkTest>
class dtkVectorProxyTestCasePrivate;
class dtkVectorProxyTestCase : public QObject
{
Q_OBJECT
public:
dtkVectorProxyTestCase(void);
~dtkVectorProxyTestCase(void);
private slots:
void initTestCase(void);
void init(void);
private slots:
void testCreation(void);
void testValue(void);
void testAssign(void);
void testConversion(void);
void testOperations(void);
void testComparison(void);
void testCreation_data(void);
void testValue_data(void);
void testAssign_data(void);
void testConversion_data(void);
void testOperations_data(void);
void testComparison_data(void);
private slots:
virtual void cleanupTestCase(void);
virtual void cleanup(void);
private:
dtkVectorProxyTestCasePrivate *d;
};
//
// dtkVectorProxyTest.h ends here
|
/*
* Copyright (c) 2011 - 2012, Simon Fraser University
* 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 Simon Fraser University nor the names of its
* contributors may be
* used to endorse or promote products derived from this software without
* specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE 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.
*/
/*
* Author : Ibrahim Numanagic
* Email : inumanag AT sfu DOT ca
* Last Update : 25. vii 2012.
*/
#ifndef QUALITIES_H__
#define QUALITIES_H__
#include "buffio.h"
/* quality_mapping - keeps lossy transformation information for qualities */
typedef struct {
int offset; /* phred quality offset - 33 or 64 */
int values[128]; /* replacement table */
} quality_mapping;
void quality_mapping_init(quality_mapping *q, buffered_file *f,
int *read_length);
int output_quality(char *line, char *read, quality_mapping *q, uint8_t *dest,
int ZZ);
#endif // QUALITIES_H__
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE78_OS_Command_Injection__wchar_t_file_w32_execvp_64a.c
Label Definition File: CWE78_OS_Command_Injection.strings.label.xml
Template File: sources-sink-64a.tmpl.c
*/
/*
* @description
* CWE: 78 OS Command Injection
* BadSource: file Read input from a file
* GoodSource: Fixed string
* Sinks: w32_execvp
* BadSink : execute command with wexecvp
* Flow Variant: 64 Data flow: void pointer to data passed from one function to another in different source files
*
* */
#include "std_testcase.h"
#include <wchar.h>
#ifdef _WIN32
#define COMMAND_INT_PATH L"%WINDIR%\\system32\\cmd.exe"
#define COMMAND_INT L"cmd.exe"
#define COMMAND_ARG1 L"/c"
#define COMMAND_ARG2 L"dir "
#define COMMAND_ARG3 data
#else /* NOT _WIN32 */
#include <unistd.h>
#define COMMAND_INT_PATH L"/bin/sh"
#define COMMAND_INT L"sh"
#define COMMAND_ARG1 L"-c"
#define COMMAND_ARG2 L"ls "
#define COMMAND_ARG3 data
#endif
#ifdef _WIN32
#define FILENAME "C:\\temp\\file.txt"
#else
#define FILENAME "/tmp/file.txt"
#endif
#include <process.h>
#define EXECVP _wexecvp
#ifndef OMITBAD
/* bad function declaration */
void CWE78_OS_Command_Injection__wchar_t_file_w32_execvp_64b_badSink(void * dataVoidPtr);
void CWE78_OS_Command_Injection__wchar_t_file_w32_execvp_64_bad()
{
wchar_t * data;
wchar_t dataBuffer[100] = COMMAND_ARG2;
data = dataBuffer;
{
/* Read input from a file */
size_t dataLen = wcslen(data);
FILE * pFile;
/* if there is room in data, attempt to read the input from a file */
if (100-dataLen > 1)
{
pFile = fopen(FILENAME, "r");
if (pFile != NULL)
{
/* POTENTIAL FLAW: Read data from a file */
if (fgetws(data+dataLen, (int)(100-dataLen), pFile) == NULL)
{
printLine("fgetws() failed");
/* Restore NUL terminator if fgetws fails */
data[dataLen] = L'\0';
}
fclose(pFile);
}
}
}
CWE78_OS_Command_Injection__wchar_t_file_w32_execvp_64b_badSink(&data);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
void CWE78_OS_Command_Injection__wchar_t_file_w32_execvp_64b_goodG2BSink(void * dataVoidPtr);
static void goodG2B()
{
wchar_t * data;
wchar_t dataBuffer[100] = COMMAND_ARG2;
data = dataBuffer;
/* FIX: Append a fixed string to data (not user / external input) */
wcscat(data, L"*.*");
CWE78_OS_Command_Injection__wchar_t_file_w32_execvp_64b_goodG2BSink(&data);
}
void CWE78_OS_Command_Injection__wchar_t_file_w32_execvp_64_good()
{
goodG2B();
}
#endif /* OMITGOOD */
/* Below is the main(). It is only used when building this testcase on
* its own for testing or for building a binary to use in testing binary
* analysis tools. It is not used when compiling all the testcases as one
* application, which is how source code analysis tools are tested.
*/
#ifdef INCLUDEMAIN
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE78_OS_Command_Injection__wchar_t_file_w32_execvp_64_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE78_OS_Command_Injection__wchar_t_file_w32_execvp_64_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
/*
* Copyright (c) 2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
// @nolint
#ifndef mcrouter_option_group
#define mcrouter_option_group(_sep)
#endif
#define no_long ""
#define no_short '\0'
/**
* Format same as in mcrouter_options_list.h
*/
mcrouter_option_group("Standalone mcrouter options")
mcrouter_option_string(
log_file, "",
"log-path", 'L',
"Log file path")
/* Note that debug level is handled specially in main.cpp
due to -v and -d options, so no long/short options here */
mcrouter_option_integer(
int, debug_level, FBI_LOG_NOTIFY,
no_long, no_short,
"Debug level")
mcrouter_option_other(
std::vector<uint16_t>, ports, ,
"port", 'p',
"Port(s) to listen on (comma separated)")
mcrouter_option_other(
std::vector<uint16_t>, ssl_ports, ,
"ssl-port", no_short,
"SSL Port(s) to listen on (comma separated)")
mcrouter_option_integer(
int, listen_sock_fd, -1,
"listen-sock-fd", no_short,
"Listen socket to take over")
mcrouter_option_toggle(
background, false,
"background", 'b',
"Run in background")
mcrouter_option_toggle(
managed, false,
"managed-mode", 'm',
"Managed mode (auto restart on crash)")
mcrouter_option_integer(
rlim_t, fdlimit, DEFAULT_FDLIMIT,
"connection-limit", 'n',
"Connection limit")
mcrouter_option_integer(
uint32_t, max_global_outstanding_reqs, DEFAULT_MAX_GLOBAL_OUTSTANDING_REQS,
"max-global-outstanding-reqs", no_short,
"Maximum requests outstanding globally (0 to disable)")
mcrouter_option_integer(
uint32_t, max_client_outstanding_reqs, DEFAULT_MAX_CLIENT_OUTSTANDING_REQS,
"max-client-outstanding-reqs", no_short,
"Maximum requests outstanding per client (0 to disable)")
mcrouter_option_integer(
size_t, requests_per_read, 0,
"reqs-per-read", no_short,
"Adjusts server buffer size to process this many requests per read."
" Smaller values may improve latency.")
#ifdef ADDITIONAL_STANDALONE_OPTIONS_FILE
#include ADDITIONAL_STANDALONE_OPTIONS_FILE
#endif
#undef no_short
#undef no_long
#undef mcrouter_option_group
#undef mcrouter_option
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef TOOLS_GN_TOKENIZER_H_
#define TOOLS_GN_TOKENIZER_H_
#include <stddef.h>
#include <string_view>
#include <vector>
#include "base/macros.h"
#include "gn/err.h"
#include "gn/token.h"
class InputFile;
// Tab (0x09), vertical tab (0x0B), and formfeed (0x0C) are illegal in GN files.
// Almost always these are errors. However, in the case of running the formatter
// it's nice to convert these to spaces when encountered so that the input can
// still be parsed and rewritten correctly by the formatter.
enum class WhitespaceTransform {
kMaintainOriginalInput,
kInvalidToSpace,
};
class Tokenizer {
public:
static std::vector<Token> Tokenize(
const InputFile* input_file,
Err* err,
WhitespaceTransform whitespace_transform =
WhitespaceTransform::kMaintainOriginalInput);
// Counts lines in the given buffer (the first line is "1") and returns
// the byte offset of the beginning of that line, or (size_t)-1 if there
// aren't that many lines in the file. Note that this will return the byte
// one past the end of the input if the last character is a newline.
//
// This is a helper function for error output so that the tokenizer's
// notion of lines can be used elsewhere.
static size_t ByteOffsetOfNthLine(const std::string_view& buf, int n);
// Returns true if the given offset of the string piece counts as a newline.
// The offset must be in the buffer.
static bool IsNewline(const std::string_view& buffer, size_t offset);
static bool IsIdentifierFirstChar(char c);
static bool IsIdentifierContinuingChar(char c);
private:
// InputFile must outlive the tokenizer and all generated tokens.
Tokenizer(const InputFile* input_file,
Err* err,
WhitespaceTransform whitespace_transform);
~Tokenizer();
std::vector<Token> Run();
void AdvanceToNextToken();
Token::Type ClassifyCurrent() const;
void AdvanceToEndOfToken(const Location& location, Token::Type type);
// Whether from this location back to the beginning of the line is only
// whitespace. |location| should be the first character of the token to be
// checked.
bool AtStartOfLine(size_t location) const;
bool IsCurrentWhitespace() const;
bool IsCurrentNewline() const;
bool IsCurrentStringTerminator(char quote_char) const;
bool CanIncrement() const { return cur_ < input_.size() - 1; }
// Increments the current location by one.
void Advance();
// Returns the current character in the file as a location.
Location GetCurrentLocation() const;
Err GetErrorForInvalidToken(const Location& location) const;
bool done() const { return at_end() || has_error(); }
bool at_end() const { return cur_ == input_.size(); }
char cur_char() const { return input_[cur_]; }
bool has_error() const { return err_->has_error(); }
std::vector<Token> tokens_;
const InputFile* input_file_;
const std::string_view input_;
Err* err_;
WhitespaceTransform whitespace_transform_;
size_t cur_ = 0; // Byte offset into input buffer.
int line_number_ = 1;
int column_number_ = 1;
DISALLOW_COPY_AND_ASSIGN(Tokenizer);
};
#endif // TOOLS_GN_TOKENIZER_H_
|
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*
* This file contains the function WebRtcSpl_AutoCorrToReflCoef().
* The description header can be found in signal_processing_library.h
*
*/
#include "signal_processing_library.h"
void WebRtcSpl_AutoCorrToReflCoef(const int32_t *R, int use_order, int16_t *K)
{
int i, n;
int16_t tmp;
const int32_t *rptr;
int32_t L_num, L_den;
int16_t *acfptr, *pptr, *wptr, *p1ptr, *w1ptr, ACF[WEBRTC_SPL_MAX_LPC_ORDER],
P[WEBRTC_SPL_MAX_LPC_ORDER], W[WEBRTC_SPL_MAX_LPC_ORDER];
// Initialize loop and pointers.
acfptr = ACF;
rptr = R;
pptr = P;
p1ptr = &P[1];
w1ptr = &W[1];
wptr = w1ptr;
// First loop; n=0. Determine shifting.
tmp = WebRtcSpl_NormW32(*R);
*acfptr = (int16_t)((*rptr++ << tmp) >> 16);
*pptr++ = *acfptr++;
// Initialize ACF, P and W.
for (i = 1; i <= use_order; i++)
{
*acfptr = (int16_t)((*rptr++ << tmp) >> 16);
*wptr++ = *acfptr;
*pptr++ = *acfptr++;
}
// Compute reflection coefficients.
for (n = 1; n <= use_order; n++, K++)
{
tmp = WEBRTC_SPL_ABS_W16(*p1ptr);
if (*P < tmp)
{
for (i = n; i <= use_order; i++)
*K++ = 0;
return;
}
// Division: WebRtcSpl_div(tmp, *P)
*K = 0;
if (tmp != 0)
{
L_num = tmp;
L_den = *P;
i = 15;
while (i--)
{
(*K) <<= 1;
L_num <<= 1;
if (L_num >= L_den)
{
L_num -= L_den;
(*K)++;
}
}
if (*p1ptr > 0)
*K = -*K;
}
// Last iteration; don't do Schur recursion.
if (n == use_order)
return;
// Schur recursion.
pptr = P;
wptr = w1ptr;
tmp = (int16_t)(((int32_t)*p1ptr * (int32_t)*K + 16384) >> 15);
*pptr = WEBRTC_SPL_ADD_SAT_W16( *pptr, tmp );
pptr++;
for (i = 1; i <= use_order - n; i++)
{
tmp = (int16_t)(((int32_t)*wptr * (int32_t)*K + 16384) >> 15);
*pptr = WEBRTC_SPL_ADD_SAT_W16( *(pptr+1), tmp );
pptr++;
tmp = (int16_t)(((int32_t)*pptr * (int32_t)*K + 16384) >> 15);
*wptr = WEBRTC_SPL_ADD_SAT_W16( *wptr, tmp );
wptr++;
}
}
}
|
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_OUTPUT_SOFTWARE_OUTPUT_DEVICE_H_
#define CC_OUTPUT_SOFTWARE_OUTPUT_DEVICE_H_
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "cc/base/cc_export.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/vector2d.h"
class SkBitmap;
class SkCanvas;
namespace gfx {
class VSyncProvider;
}
namespace cc {
// This is a "tear-off" class providing software drawing support to
// OutputSurface, such as to a platform-provided window framebuffer.
class CC_EXPORT SoftwareOutputDevice {
public:
SoftwareOutputDevice();
virtual ~SoftwareOutputDevice();
// Discards any pre-existing backing buffers and allocates memory for a
// software device of |size|. This must be called before the
// |SoftwareOutputDevice| can be used in other ways.
virtual void Resize(const gfx::Size& pixel_size, float scale_factor);
// Called on BeginDrawingFrame. The compositor will draw into the returned
// SkCanvas. The |SoftwareOutputDevice| implementation needs to provide a
// valid SkCanvas of at least size |damage_rect|. This class retains ownership
// of the SkCanvas.
virtual SkCanvas* BeginPaint(const gfx::Rect& damage_rect);
// Called on FinishDrawingFrame. The compositor will no longer mutate the the
// SkCanvas instance returned by |BeginPaint| and should discard any reference
// that it holds to it.
virtual void EndPaint();
// Discard the backing buffer in the surface provided by this instance.
virtual void DiscardBackbuffer() {}
// Ensures that there is a backing buffer available on this instance.
virtual void EnsureBackbuffer() {}
// VSyncProvider used to update the timer used to schedule draws with the
// hardware vsync. Return NULL if a provider doesn't exist.
virtual gfx::VSyncProvider* GetVSyncProvider();
protected:
gfx::Size viewport_pixel_size_;
float scale_factor_;
gfx::Rect damage_rect_;
sk_sp<SkSurface> surface_;
scoped_ptr<gfx::VSyncProvider> vsync_provider_;
private:
DISALLOW_COPY_AND_ASSIGN(SoftwareOutputDevice);
};
} // namespace cc
#endif // CC_OUTPUT_SOFTWARE_OUTPUT_DEVICE_H_
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_SERVICE_WORKER_WAIT_UNTIL_OBSERVER_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_SERVICE_WORKER_WAIT_UNTIL_OBSERVER_H_
#include "base/callback.h"
#include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_observer.h"
#include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/blink/renderer/platform/timer.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"
namespace blink {
class ExceptionState;
class ScriptPromise;
class ScriptState;
class ScriptValue;
// Created for each ExtendableEvent instance.
class MODULES_EXPORT WaitUntilObserver final
: public GarbageCollected<WaitUntilObserver>,
public ExecutionContextClient {
USING_GARBAGE_COLLECTED_MIXIN(WaitUntilObserver);
public:
using PromiseSettledCallback =
base::RepeatingCallback<void(const ScriptValue&)>;
enum EventType {
kAbortPayment,
kActivate,
kCanMakePayment,
kCookieChange,
kFetch,
kInstall,
kMessage,
kMessageerror,
kNotificationClick,
kNotificationClose,
kPaymentRequest,
kPush,
kPushSubscriptionChange,
kSync,
kPeriodicSync,
kBackgroundFetchAbort,
kBackgroundFetchClick,
kBackgroundFetchFail,
kBackgroundFetchSuccess,
kContentDelete,
};
WaitUntilObserver(ExecutionContext*, EventType, int event_id);
// Must be called before dispatching the event.
void WillDispatchEvent();
// Must be called after dispatching the event. If |event_dispatch_failed| is
// true, then DidDispatchEvent() immediately reports to
// ServiceWorkerGlobalScope that the event finished, without waiting for
// all waitUntil promises to settle.
void DidDispatchEvent(bool event_dispatch_failed);
// Observes the promise and delays reporting to ServiceWorkerGlobalScope
// that the event completed until the promise is resolved or rejected.
//
// WaitUntil may be called multiple times. The event is extended until all
// promises have settled.
//
// If provided, |on_promise_fulfilled| or |on_promise_rejected| is invoked
// once |script_promise| fulfills or rejects. This enables the caller to do
// custom handling.
//
// If the event is not active, throws a DOMException and returns false. In
// this case the promise is ignored, and |on_promise_fulfilled| and
// |on_promise_rejected| will not be called.
bool WaitUntil(
ScriptState*,
ScriptPromise /* script_promise */,
ExceptionState&,
PromiseSettledCallback on_promise_fulfilled = PromiseSettledCallback(),
PromiseSettledCallback on_promise_rejected = PromiseSettledCallback());
// Whether the associated event is active.
// https://w3c.github.io/ServiceWorker/#extendableevent-active.
bool IsEventActive() const;
// Whether the event is being dispatched, i.e., the event handler
// is being run.
// https://dom.spec.whatwg.org/#dispatch-flag
// TODO(falken): Can this just use Event::IsBeingDispatched?
bool IsDispatchingEvent() const;
void Trace(Visitor*) override;
private:
friend class InternalsServiceWorker;
class ThenFunction;
enum class EventDispatchState {
// Event dispatch has not yet started.
kInitial,
// Event dispatch has started but not yet finished.
kDispatching,
// Event dispatch completed. There may still be outstanding waitUntil
// promises that must settle before notifying ServiceWorkerGlobalScope
// that the event finished.
kDispatched,
// Event dispatch failed. Any outstanding waitUntil promises are ignored.
kFailed
};
void IncrementPendingPromiseCount();
void DecrementPendingPromiseCount();
// Enqueued as a microtask when a promise passed to a waitUntil() call that is
// associated with this observer was fulfilled.
void OnPromiseFulfilled();
// Enqueued as a microtask when a promise passed to a waitUntil() call that is
// associated with this observer was rejected.
void OnPromiseRejected();
void ConsumeWindowInteraction(TimerBase*);
void MaybeCompleteEvent();
EventType type_;
int event_id_;
int pending_promises_ = 0;
EventDispatchState event_dispatch_state_ = EventDispatchState::kInitial;
bool has_rejected_promise_ = false;
TaskRunnerTimer<WaitUntilObserver> consume_window_interaction_timer_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_SERVICE_WORKER_WAIT_UNTIL_OBSERVER_H_
|
/*-
* Copyright (c) 2011 NetApp, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/smp.h>
#include <x86/specialreg.h>
#include <x86/apicreg.h>
#include <machine/vmm.h>
#include "vmm_ipi.h"
#include "vmm_lapic.h"
#include "vlapic.h"
int
lapic_pending_intr(struct vm *vm, int cpu)
{
struct vlapic *vlapic;
vlapic = vm_lapic(vm, cpu);
return (vlapic_pending_intr(vlapic));
}
void
lapic_intr_accepted(struct vm *vm, int cpu, int vector)
{
struct vlapic *vlapic;
vlapic = vm_lapic(vm, cpu);
vlapic_intr_accepted(vlapic, vector);
}
int
lapic_set_intr(struct vm *vm, int cpu, int vector)
{
struct vlapic *vlapic;
if (cpu < 0 || cpu >= VM_MAXCPU)
return (EINVAL);
if (vector < 32 || vector > 255)
return (EINVAL);
vlapic = vm_lapic(vm, cpu);
vlapic_set_intr_ready(vlapic, vector);
vm_interrupt_hostcpu(vm, cpu);
return (0);
}
int
lapic_timer_tick(struct vm *vm, int cpu)
{
struct vlapic *vlapic;
vlapic = vm_lapic(vm, cpu);
return (vlapic_timer_tick(vlapic));
}
static boolean_t
x2apic_msr(u_int msr)
{
if (msr >= 0x800 && msr <= 0xBFF)
return (TRUE);
else
return (FALSE);
}
static u_int
x2apic_msr_to_regoff(u_int msr)
{
return ((msr - 0x800) << 4);
}
boolean_t
lapic_msr(u_int msr)
{
if (x2apic_msr(msr) || (msr == MSR_APICBASE))
return (TRUE);
else
return (FALSE);
}
int
lapic_rdmsr(struct vm *vm, int cpu, u_int msr, uint64_t *rval)
{
int error;
u_int offset;
struct vlapic *vlapic;
vlapic = vm_lapic(vm, cpu);
if (msr == MSR_APICBASE) {
*rval = vlapic_get_apicbase(vlapic);
error = 0;
} else {
offset = x2apic_msr_to_regoff(msr);
error = vlapic_op_mem_read(vlapic, offset, DWORD, rval);
}
return (error);
}
int
lapic_wrmsr(struct vm *vm, int cpu, u_int msr, uint64_t val)
{
int error;
u_int offset;
struct vlapic *vlapic;
vlapic = vm_lapic(vm, cpu);
if (msr == MSR_APICBASE) {
vlapic_set_apicbase(vlapic, val);
error = 0;
} else {
offset = x2apic_msr_to_regoff(msr);
error = vlapic_op_mem_write(vlapic, offset, DWORD, val);
}
return (error);
}
int
lapic_mmio_write(void *vm, int cpu, uint64_t gpa, uint64_t wval, int size,
void *arg)
{
int error;
uint64_t off;
struct vlapic *vlapic;
off = gpa - DEFAULT_APIC_BASE;
/*
* Memory mapped local apic accesses must be 4 bytes wide and
* aligned on a 16-byte boundary.
*/
if (size != 4 || off & 0xf)
return (EINVAL);
vlapic = vm_lapic(vm, cpu);
error = vlapic_op_mem_write(vlapic, off, DWORD, wval);
return (error);
}
int
lapic_mmio_read(void *vm, int cpu, uint64_t gpa, uint64_t *rval, int size,
void *arg)
{
int error;
uint64_t off;
struct vlapic *vlapic;
off = gpa - DEFAULT_APIC_BASE;
/*
* Memory mapped local apic accesses must be 4 bytes wide and
* aligned on a 16-byte boundary.
*/
if (size != 4 || off & 0xf)
return (EINVAL);
vlapic = vm_lapic(vm, cpu);
error = vlapic_op_mem_read(vlapic, off, DWORD, rval);
return (error);
}
|
/*---------------------------------------------------------------------------
(c) 2004 Scorpio Software
19 Wittama Drive
Glenmore Park
Sydney NSW 2745
Australia
-----------------------------------------------------------------------------
$Workfile:: $
$Revision:: $
$Date:: $
$Author:: $
---------------------------------------------------------------------------*/
//---------------------------------------------------------------------------
#ifndef ZXTileH
#define ZXTileH
//---------------------------------------------------------------------------
/**
* @class TTile
* @brief This class is used to store the position of a tile on screen
* @author Tony Thompson
* @date Created 20 April 2003
*/
//---------------------------------------------------------------------------
typedef struct
{
String m_sTile; /// the name of the tile to draw
int m_iTop; /// the top position of the tile on screen
int m_iLeft; /// the left position of the tile on screen
} TTile;
//---------------------------------------------------------------------------
/**
* @class TSprite
* @brief This class is used to store the position of a sprite on screen
* @author Tony Thompson
* @date Created 11 January 2011
*/
//---------------------------------------------------------------------------
typedef struct
{
String m_sSprite; /// the name of the sprite to draw
int m_iType; /// the type id of the sprite
int m_iTop; /// the top position of the tile on screen
int m_iLeft; /// the left position of the tile on screen
} TSprite;
//---------------------------------------------------------------------------
/**
* @class TMapObject
* @brief This class is used to store the position of an object on screen
* @author Tony Thompson
* @date Created 11 January 2011
*/
//---------------------------------------------------------------------------
typedef struct
{
String m_sObject; /// the name of the object to draw
int m_iScreen; /// the screen the object belongs to (could also be inventory-255, no start screen-254)
int m_iTop; /// the top position of the tile on screen
int m_iLeft; /// the left position of the tile on screen
} TMapObject;
#endif // ZXTileH
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_NAMESPACE_RULE_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_NAMESPACE_RULE_H_
#include "third_party/blink/renderer/core/css/css_rule.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink {
class StyleRuleNamespace;
class CSSNamespaceRule final : public CSSRule {
DEFINE_WRAPPERTYPEINFO();
public:
CSSNamespaceRule(StyleRuleNamespace*, CSSStyleSheet*);
~CSSNamespaceRule() override;
String cssText() const override;
void Reattach(StyleRuleBase*) override {}
AtomicString namespaceURI() const;
AtomicString prefix() const;
void Trace(Visitor*) override;
private:
CSSRule::Type type() const override { return kNamespaceRule; }
Member<StyleRuleNamespace> namespace_rule_;
};
template <>
struct DowncastTraits<CSSNamespaceRule> {
static bool AllowFrom(const CSSRule& rule) {
return rule.type() == CSSRule::kNamespaceRule;
}
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_NAMESPACE_RULE_H_
|
/*
* File: init.c
* Author: Fabien Siron <fabien.siron@epita.fr>
*/
#include <tinypy/tp.h>
#include <tinypy/dict.h>
#include <tinypy/string.h>
#include <tinypy/misc.h>
tp_obj mem_brk(TP);
tp_obj mem_used(TP);
tp_obj mem_available(TP);
tp_obj mem_len(TP);
static char *help =
"Debug routines for dynamic memory allocation (malloc/free family)\n"
"\n"
"This exports:\n"
"\t* mem.get_brk gives the current brk pointer\n"
"\t* mem.used gives how much memory is used\n"
"\t* mem.available gives how much memory is available\n"
"\t* mem.len gives the memory length\n";
void mem_init(TP)
{
/* module */
tp_obj mem_mod = tp_dict(tp);
/* methods */
tp_set(tp, mem_mod, tp_string("get_brk"), tp_fnc(tp, mem_brk));
tp_set(tp, mem_mod, tp_string("used"), tp_fnc(tp, mem_used));
tp_set(tp, mem_mod, tp_string("available"), tp_fnc(tp, mem_available));
tp_set(tp, mem_mod, tp_string("len"), tp_fnc(tp, mem_len));
/* special attributes */
tp_set(tp, mem_mod, tp_string("__doc__"),
tp_string(help));
tp_set(tp, mem_mod, tp_string("__name__"), tp_string("mem"));
tp_set(tp, mem_mod, tp_string("__file__"), tp_string(__FILE__));
/* bind */
tp_set(tp, tp->modules, tp_string("mem"), mem_mod);
}
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE415_Double_Free__malloc_free_wchar_t_12.c
Label Definition File: CWE415_Double_Free__malloc_free.label.xml
Template File: sources-sinks-12.tmpl.c
*/
/*
* @description
* CWE: 415 Double Free
* BadSource: Allocate data using malloc() and Deallocate data using free()
* GoodSource: Allocate data using malloc()
* Sinks:
* GoodSink: do nothing
* BadSink : Deallocate data using free()
* Flow Variant: 12 Control flow: if(globalReturnsTrueOrFalse())
*
* */
#include "std_testcase.h"
#include <wchar.h>
#ifndef OMITBAD
void CWE415_Double_Free__malloc_free_wchar_t_12_bad()
{
wchar_t * data;
/* Initialize data */
data = NULL;
if(globalReturnsTrueOrFalse())
{
data = (wchar_t *)malloc(100*sizeof(wchar_t));
if (data == NULL) {exit(-1);}
/* POTENTIAL FLAW: Free data in the source - the bad sink frees data as well */
free(data);
}
else
{
data = (wchar_t *)malloc(100*sizeof(wchar_t));
if (data == NULL) {exit(-1);}
/* FIX: Do NOT free data in the source - the bad sink frees data */
}
if(globalReturnsTrueOrFalse())
{
/* POTENTIAL FLAW: Possibly freeing memory twice */
free(data);
}
else
{
/* do nothing */
/* FIX: Don't attempt to free the memory */
; /* empty statement needed for some flow variants */
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodB2G() - use badsource and goodsink by changing the first "if" so that
both branches use the BadSource and the second "if" so that both branches
use the GoodSink */
static void goodB2G()
{
wchar_t * data;
/* Initialize data */
data = NULL;
if(globalReturnsTrueOrFalse())
{
data = (wchar_t *)malloc(100*sizeof(wchar_t));
if (data == NULL) {exit(-1);}
/* POTENTIAL FLAW: Free data in the source - the bad sink frees data as well */
free(data);
}
else
{
data = (wchar_t *)malloc(100*sizeof(wchar_t));
if (data == NULL) {exit(-1);}
/* POTENTIAL FLAW: Free data in the source - the bad sink frees data as well */
free(data);
}
if(globalReturnsTrueOrFalse())
{
/* do nothing */
/* FIX: Don't attempt to free the memory */
; /* empty statement needed for some flow variants */
}
else
{
/* do nothing */
/* FIX: Don't attempt to free the memory */
; /* empty statement needed for some flow variants */
}
}
/* goodG2B() - use goodsource and badsink by changing the first "if" so that
both branches use the GoodSource and the second "if" so that both branches
use the BadSink */
static void goodG2B()
{
wchar_t * data;
/* Initialize data */
data = NULL;
if(globalReturnsTrueOrFalse())
{
data = (wchar_t *)malloc(100*sizeof(wchar_t));
if (data == NULL) {exit(-1);}
/* FIX: Do NOT free data in the source - the bad sink frees data */
}
else
{
data = (wchar_t *)malloc(100*sizeof(wchar_t));
if (data == NULL) {exit(-1);}
/* FIX: Do NOT free data in the source - the bad sink frees data */
}
if(globalReturnsTrueOrFalse())
{
/* POTENTIAL FLAW: Possibly freeing memory twice */
free(data);
}
else
{
/* POTENTIAL FLAW: Possibly freeing memory twice */
free(data);
}
}
void CWE415_Double_Free__malloc_free_wchar_t_12_good()
{
goodB2G();
goodG2B();
}
#endif /* OMITGOOD */
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE415_Double_Free__malloc_free_wchar_t_12_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE415_Double_Free__malloc_free_wchar_t_12_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
/*
* Copyright (c) 2016-2018 Positive Technologies, https://www.ptsecurity.com,
* Fast Positive Hash.
*
* Portions Copyright (c) 2010-2018 Leonid Yuriev <leo@yuriev.ru>,
* The 1Hippeus project (t1h).
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgement in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
/*
* t1ha = { Fast Positive Hash, aka "Позитивный Хэш" }
* by [Positive Technologies](https://www.ptsecurity.ru)
*
* Briefly, it is a 64-bit Hash Function:
* 1. Created for 64-bit little-endian platforms, in predominantly for x86_64,
* but portable and without penalties it can run on any 64-bit CPU.
* 2. In most cases up to 15% faster than City64, xxHash, mum-hash, metro-hash
* and all others portable hash-functions (which do not use specific
* hardware tricks).
* 3. Not suitable for cryptography.
*
* The Future will Positive. Всё будет хорошо.
*
* ACKNOWLEDGEMENT:
* The t1ha was originally developed by Leonid Yuriev (Леонид Юрьев)
* for The 1Hippeus project - zerocopy messaging in the spirit of Sparta!
*/
#include "t1ha_bits.h"
#include "t1ha_selfcheck.h"
#if T1HA0_AESNI_AVAILABLE
uint64_t T1HA_IA32AES_NAME(const void *data, size_t len, uint64_t seed) {
uint64_t a = seed;
uint64_t b = len;
if (unlikely(len > 32)) {
__m128i x = _mm_set_epi64x(a, b);
__m128i y = _mm_aesenc_si128(x, _mm_set_epi64x(prime_0, prime_1));
const __m128i *v = (const __m128i *)data;
const __m128i *const detent =
(const __m128i *)((const uint8_t *)data + (len & ~15ul));
data = detent;
if (len & 16) {
x = _mm_add_epi64(x, _mm_loadu_si128(v++));
y = _mm_aesenc_si128(x, y);
}
len &= 15;
if (v + 7 < detent) {
__m128i salt = y;
do {
__m128i t = _mm_aesenc_si128(_mm_loadu_si128(v++), salt);
t = _mm_aesdec_si128(t, _mm_loadu_si128(v++));
t = _mm_aesdec_si128(t, _mm_loadu_si128(v++));
t = _mm_aesdec_si128(t, _mm_loadu_si128(v++));
t = _mm_aesdec_si128(t, _mm_loadu_si128(v++));
t = _mm_aesdec_si128(t, _mm_loadu_si128(v++));
t = _mm_aesdec_si128(t, _mm_loadu_si128(v++));
t = _mm_aesdec_si128(t, _mm_loadu_si128(v++));
salt = _mm_add_epi64(salt, _mm_set_epi64x(prime_5, prime_6));
t = _mm_aesenc_si128(x, t);
x = _mm_add_epi64(y, x);
y = t;
} while (v + 7 < detent);
}
while (v < detent) {
__m128i v0y = _mm_add_epi64(y, _mm_loadu_si128(v++));
__m128i v1x = _mm_sub_epi64(x, _mm_loadu_si128(v++));
x = _mm_aesdec_si128(x, v0y);
y = _mm_aesdec_si128(y, v1x);
}
x = _mm_add_epi64(_mm_aesdec_si128(x, _mm_aesenc_si128(y, x)), y);
#if defined(__x86_64__) || defined(_M_X64)
#if defined(__SSE4_1__) || defined(__AVX__)
a = _mm_extract_epi64(x, 0);
b = _mm_extract_epi64(x, 1);
#else
a = _mm_cvtsi128_si64(x);
b = _mm_cvtsi128_si64(_mm_unpackhi_epi64(x, x));
#endif
#else
#if defined(__SSE4_1__) || defined(__AVX__)
a = (uint32_t)_mm_extract_epi32(x, 0) | (uint64_t)_mm_extract_epi32(x, 1)
<< 32;
b = (uint32_t)_mm_extract_epi32(x, 2) | (uint64_t)_mm_extract_epi32(x, 3)
<< 32;
#else
a = (uint32_t)_mm_cvtsi128_si32(x);
a |= (uint64_t)_mm_cvtsi128_si32(_mm_shuffle_epi32(x, 1)) << 32;
x = _mm_unpackhi_epi64(x, x);
b = (uint32_t)_mm_cvtsi128_si32(x);
b |= (uint64_t)_mm_cvtsi128_si32(_mm_shuffle_epi32(x, 1)) << 32;
#endif
#endif
#ifdef __AVX__
_mm256_zeroall();
#elif !(defined(_X86_64_) || defined(__x86_64__) || defined(_M_X64))
_mm_empty();
#endif
}
const uint64_t *v = (const uint64_t *)data;
switch (len) {
default:
mixup64(&a, &b, fetch64_le_unaligned(v++), prime_4);
/* fall through */
case 24:
case 23:
case 22:
case 21:
case 20:
case 19:
case 18:
case 17:
mixup64(&b, &a, fetch64_le_unaligned(v++), prime_3);
/* fall through */
case 16:
case 15:
case 14:
case 13:
case 12:
case 11:
case 10:
case 9:
mixup64(&a, &b, fetch64_le_unaligned(v++), prime_2);
/* fall through */
case 8:
case 7:
case 6:
case 5:
case 4:
case 3:
case 2:
case 1:
mixup64(&b, &a, tail64_le_unaligned(v, len), prime_1);
/* fall through */
case 0:
return final64(a, b);
}
}
#endif /* T1HA0_AESNI_AVAILABLE */
#undef T1HA_IA32AES_NAME
|
/*-
* Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* i.MX6 Digital Audio Multiplexer (AUDMUX)
* Chapter 16, i.MX 6Dual/6Quad Applications Processor Reference Manual,
* Rev. 1, 04/2013
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/malloc.h>
#include <sys/endian.h>
#include <sys/rman.h>
#include <sys/timeet.h>
#include <sys/timetc.h>
#include <dev/fdt/fdt_common.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
#include <machine/bus.h>
#include <machine/cpu.h>
#include <machine/intr.h>
#define READ4(_sc, _reg) \
bus_space_read_4(_sc->bst, _sc->bsh, _reg)
#define WRITE4(_sc, _reg, _val) \
bus_space_write_4(_sc->bst, _sc->bsh, _reg, _val)
#define AUDMUX_PTCR(n) (0x8 * (n - 1)) /* Port Timing Control Register */
#define PTCR_TFS_DIR (1 << 31) /* Transmit Frame Sync Direction Control */
#define PTCR_TFSEL_S 27 /* Transmit Frame Sync Select */
#define PTCR_TFSEL_M 0xf
#define PTCR_TCLKDIR (1 << 26) /* Transmit Clock Direction Control */
#define PTCR_TCSEL_S 22 /* Transmit Clock Select. */
#define PTCR_TCSEL_M 0xf
#define PTCR_RFS_DIR (1 << 21) /* Receive Frame Sync Direction Control */
#define PTCR_SYN (1 << 11)
#define AUDMUX_PDCR(n) (0x8 * (n - 1) + 0x4) /* Port Data Control Reg */
#define PDCR_RXDSEL_S 13 /* Receive Data Select */
#define PDCR_RXDSEL_M 0x3
#define PDCR_RXDSEL_PORT(n) (n - 1)
struct audmux_softc {
struct resource *res[1];
bus_space_tag_t bst;
bus_space_handle_t bsh;
void *ih;
};
static struct resource_spec audmux_spec[] = {
{ SYS_RES_MEMORY, 0, RF_ACTIVE },
{ -1, 0 }
};
static int
audmux_probe(device_t dev)
{
if (!ofw_bus_status_okay(dev))
return (ENXIO);
if (!ofw_bus_is_compatible(dev, "fsl,imx6q-audmux"))
return (ENXIO);
device_set_desc(dev, "i.MX6 Digital Audio Multiplexer");
return (BUS_PROBE_DEFAULT);
}
static int
audmux_configure(struct audmux_softc *sc,
int ssi_port, int audmux_port)
{
uint32_t reg;
/* Direction: output */
reg = (PTCR_TFS_DIR | PTCR_TCLKDIR | PTCR_SYN);
WRITE4(sc, AUDMUX_PTCR(audmux_port), reg);
/* Select source */
reg = (PDCR_RXDSEL_PORT(ssi_port) << PDCR_RXDSEL_S);
WRITE4(sc, AUDMUX_PDCR(audmux_port), reg);
return (0);
}
static int
audmux_attach(device_t dev)
{
struct audmux_softc *sc;
sc = device_get_softc(dev);
if (bus_alloc_resources(dev, audmux_spec, sc->res)) {
device_printf(dev, "could not allocate resources\n");
return (ENXIO);
}
/* Memory interface */
sc->bst = rman_get_bustag(sc->res[0]);
sc->bsh = rman_get_bushandle(sc->res[0]);
/*
* Direct SSI1 output to AUDMUX5 pins.
* TODO: dehardcore this.
*/
audmux_configure(sc, 1, 5);
return (0);
};
static device_method_t audmux_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, audmux_probe),
DEVMETHOD(device_attach, audmux_attach),
{ 0, 0 }
};
static driver_t audmux_driver = {
"audmux",
audmux_methods,
sizeof(struct audmux_softc),
};
static devclass_t audmux_devclass;
DRIVER_MODULE(audmux, simplebus, audmux_driver, audmux_devclass, 0, 0);
|
/*
Copyright (c) 2005-2008, Simon Howard
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/**
* @file binomial-heap.h
*
* @brief Binomial heap.
*
* A binomial heap is a heap data structure implemented using a
* binomial tree. In a heap, values are ordered by priority.
*
* To create a binomial heap, use @ref binomial_heap_new. To destroy a
* binomial heap, use @ref binomial_heap_free.
*
* To insert a value into a binomial heap, use @ref binomial_heap_insert.
*
* To remove the first value from a binomial heap, use @ref binomial_heap_pop.
*
*/
#ifndef ALGORITHM_BINOMIAL_HEAP_H
#define ALGORITHM_BINOMIAL_HEAP_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* Heap type. If a heap is a min heap (@ref BINOMIAL_HEAP_TYPE_MIN), the
* values with the lowest priority are stored at the top of the heap and
* will be the first returned. If a heap is a max heap
* (@ref BINOMIAL_HEAP_TYPE_MAX), the values with the greatest priority
* are stored at the top of the heap.
*/
typedef enum {
/** A minimum heap. */
BINOMIAL_HEAP_TYPE_MIN,
/** A maximum heap. */
BINOMIAL_HEAP_TYPE_MAX
} BinomialHeapType;
/**
* A value stored in a @ref BinomialHeap.
*/
typedef void *BinomialHeapValue;
/**
* A null @ref BinomialHeapValue.
*/
#define BINOMIAL_HEAP_NULL ((void *) 0)
/**
* Type of function used to compare values in a binomial heap.
*
* @param value1 The first value.
* @param value2 The second value.
* @return A negative number if value1 is less than value2,
* a positive number if value1 is greater than value2,
* zero if the two are equal.
*/
typedef int (*BinomialHeapCompareFunc)(BinomialHeapValue value1,
BinomialHeapValue value2);
/**
* A binomial heap data structure.
*/
typedef struct _BinomialHeap BinomialHeap;
/**
* Create a new @ref BinomialHeap.
*
* @param heap_type The type of heap: min heap or max heap.
* @param compare_func Pointer to a function used to compare the priority
* of values in the heap.
* @return A new binomial heap, or NULL if it was not possible
* to allocate the memory.
*/
BinomialHeap *binomial_heap_new(BinomialHeapType heap_type,
BinomialHeapCompareFunc compare_func);
/**
* Destroy a binomial heap.
*
* @param heap The heap to destroy.
*/
void binomial_heap_free(BinomialHeap *heap);
/**
* Insert a value into a binomial heap.
*
* @param heap The heap to insert into.
* @param value The value to insert.
* @return Non-zero if the entry was added, or zero if it
* was not possible to allocate memory for the new
* entry.
*/
int binomial_heap_insert(BinomialHeap *heap, BinomialHeapValue value);
/**
* Remove the first value from a binomial heap.
*
* @param heap The heap.
* @return The first value in the heap, or
* @ref BINOMIAL_HEAP_NULL if the heap is empty.
*/
BinomialHeapValue binomial_heap_pop(BinomialHeap *heap);
/**
* Find the number of values stored in a binomial heap.
*
* @param heap The heap.
* @return The number of values in the heap.
*/
unsigned int binomial_heap_num_entries(BinomialHeap *heap);
#ifdef __cplusplus
}
#endif
#endif /* #ifndef ALGORITHM_BINOMIAL_HEAP_H */
|
//
// Configurations.h
// Sidestep
//
// Created by Chetan Surpur on 11/18/10.
// Copyright 2010 Chetan Surpur. All rights reserved.
extern const int debuggingEnabled; |
#pragma once
#include <iostream>
#include <Box2D\Box2D.h>
#include "EntityType.cpp"
#include "GameObject.h"
#include "SwingSpikeBall.h"
#include "Player.h"
using namespace std;
class CollisionListener : public b2ContactListener
{
public:
CollisionListener();
~CollisionListener();
/// Called when two fixtures begin to touch.
virtual void BeginContact(b2Contact* contact);
/// Called when two fixtures cease to touch.
virtual void EndContact(b2Contact* contact);
/// Called before solving the collision (yes, we use diffn'l equations)
virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
{
B2_NOT_USED(contact);
B2_NOT_USED(oldManifold);
}
/// This lets you inspect a contact after the solver is finished. This is useful
/// for inspecting impulses.
virtual void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse)
{
B2_NOT_USED(contact);
B2_NOT_USED(impulse);
}
};
|
#import <SSDataSources/SSDataSources.h>
@class WMFTitleInsetRespectingButton;
@interface WMFArticlePlaceholderTableViewCell : SSBaseTableCell
@property (strong, nonatomic) IBOutlet UIImageView* placeholderImageView;
@property (strong, nonatomic) IBOutlet WMFTitleInsetRespectingButton* placeholderSaveButton;
@end
|
//
// IBInspectableTableViewController.h
// BlazeExample
//
// Created by Roy Derks on 15/11/2016.
// Copyright © 2016 GraafICT. All rights reserved.
//
#import "BaseTableViewController.h"
@interface IBInspectableTableViewController : BaseTableViewController
@end
|
// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
/******************************************************************************
*
* file: ArgTraits.h
*
* Copyright (c) 2007, Daniel Aarno, Michael E. Smoot .
* All rights reverved.
*
* See the file COPYING in the top directory of this distribution for
* more information.
*
* 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.
*
*****************************************************************************/
// This is an internal tclap file, you should probably not have to
// include this directly
#ifndef TCLAP_ARGTRAITS_H
#define TCLAP_ARGTRAITS_H
namespace TCLAP {
// We use two empty structs to get compile type specialization
// function to work
/**
* A value like argument value type is a value that can be set using
* operator>>. This is the default value type.
*/
struct ValueLike {
typedef ValueLike ValueCategory;
virtual ~ValueLike() {}
};
/**
* A string like argument value type is a value that can be set using
* operator=(string). Usefull if the value type contains spaces which
* will be broken up into individual tokens by operator>>.
*/
struct StringLike {
virtual ~StringLike() {}
};
/**
* A class can inherit from this object to make it have string like
* traits. This is a compile time thing and does not add any overhead
* to the inherenting class.
*/
struct StringLikeTrait {
typedef StringLike ValueCategory;
virtual ~StringLikeTrait() {}
};
/**
* A class can inherit from this object to make it have value like
* traits. This is a compile time thing and does not add any overhead
* to the inherenting class.
*/
struct ValueLikeTrait {
typedef ValueLike ValueCategory;
virtual ~ValueLikeTrait() {}
};
/**
* Arg traits are used to get compile type specialization when parsing
* argument values. Using an ArgTraits you can specify the way that
* values gets assigned to any particular type during parsing. The two
* supported types are StringLike and ValueLike.
*/
template<typename T>
struct ArgTraits {
typedef typename T::ValueCategory ValueCategory;
virtual ~ArgTraits() {}
//typedef ValueLike ValueCategory;
};
#endif
} // namespace
|
/** \file
* \brief IupBackgroundBox control
*
* See Copyright Notice in "iup.h"
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "iup.h"
#include "iupcbs.h"
#include "iupkey.h"
#include "iup_object.h"
#include "iup_register.h"
#include "iup_attrib.h"
#include "iup_str.h"
#include "iup_stdcontrols.h"
#include "iup_layout.h"
#include "iup_drv.h"
/*****************************************************************************\
|* Methods *|
\*****************************************************************************/
static char* iBackgroundBoxGetBgColorAttrib(Ihandle* ih)
{
if (iupAttribGet(ih, "BGCOLOR"))
return NULL; /* get from the hash table */
else
return iupBaseNativeParentGetBgColorAttrib(ih);
}
static int iBackgroundBoxSetBgColorAttrib(Ihandle* ih, const char* value)
{
(void)value;
IupUpdate(ih); /* post a redraw */
return 1; /* save on the hash table */
}
static int iBackgroundBoxGetBorder(Ihandle* ih)
{
if (iupAttribGetBoolean(ih, "BORDER"))
return 1;
else
return 0;
}
static char* iBackgroundBoxGetClientOffsetAttrib(Ihandle* ih)
{
int dx = 0, dy = 0;
if (iupAttribGetBoolean(ih, "BORDER"))
{
dx = 1;
dy = 1;
}
return iupStrReturnIntInt(dx, dy, 'x');
}
static void iBackgroundBoxComputeNaturalSizeMethod(Ihandle* ih, int *w, int *h, int *children_expand)
{
if (ih->firstchild)
{
int border = iBackgroundBoxGetBorder(ih);
iupBaseComputeNaturalSize(ih->firstchild);
*children_expand = ih->firstchild->expand;
*w = ih->firstchild->naturalwidth + 2*border;
*h = ih->firstchild->naturalheight + 2*border;
}
}
static void iBackgroundBoxSetChildrenCurrentSizeMethod(Ihandle* ih, int shrink)
{
if (ih->firstchild)
{
int border = iBackgroundBoxGetBorder(ih);
int width = (ih->currentwidth > border ? ih->currentwidth - border : 0);
int height = (ih->currentheight > border ? ih->currentheight - border : 0);
iupBaseSetCurrentSize(ih->firstchild, width, height, shrink);
}
}
static void iBackgroundBoxSetChildrenPositionMethod(Ihandle* ih, int x, int y)
{
if (ih->firstchild)
{
char* offset = iupAttribGet(ih, "CHILDOFFSET");
/* Native container, position is reset */
x = 0;
y = 0;
if (offset) iupStrToIntInt(offset, &x, &y, 'x');
iupBaseSetPosition(ih->firstchild, x, y);
}
}
static int iBackgroundBoxCreateMethod(Ihandle* ih, void** params)
{
IupSetAttribute(ih, "CANFOCUS", "NO");
if (params)
{
Ihandle** iparams = (Ihandle**)params;
if (iparams[0]) IupAppend(ih, iparams[0]);
}
return IUP_NOERROR;
}
Iclass* iupBackgroundBoxNewClass(void)
{
Iclass* ic = iupClassNew(iupRegisterFindClass("canvas"));
ic->name = "backgroundbox";
ic->format = "h"; /* one Ihandle* */
ic->nativetype = IUP_TYPECANVAS;
ic->childtype = IUP_CHILDMANY+1; /* 1 child */
ic->is_interactive = 0;
/* Class functions */
ic->New = iupBackgroundBoxNewClass;
ic->Create = iBackgroundBoxCreateMethod;
ic->ComputeNaturalSize = iBackgroundBoxComputeNaturalSizeMethod;
ic->SetChildrenCurrentSize = iBackgroundBoxSetChildrenCurrentSizeMethod;
ic->SetChildrenPosition = iBackgroundBoxSetChildrenPositionMethod;
/* Base Container */
iupClassRegisterAttribute(ic, "EXPAND", iupBaseContainerGetExpandAttrib, NULL, IUPAF_SAMEASSYSTEM, "YES", IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
iupClassRegisterAttribute(ic, "CLIENTOFFSET", iBackgroundBoxGetClientOffsetAttrib, NULL, NULL, NULL, IUPAF_NOT_MAPPED | IUPAF_READONLY | IUPAF_NO_INHERIT);
{
IattribGetFunc drawsize_get = NULL;
iupClassRegisterGetAttribute(ic, "DRAWSIZE", &drawsize_get, NULL, NULL, NULL, NULL);
iupClassRegisterAttribute(ic, "CLIENTSIZE", drawsize_get, NULL, NULL, NULL, IUPAF_READONLY|IUPAF_NO_INHERIT);
}
/* Native Container */
iupClassRegisterAttribute(ic, "CHILDOFFSET", NULL, NULL, NULL, NULL, IUPAF_NOT_MAPPED | IUPAF_NO_INHERIT);
/* replace IupCanvas behavior */
iupClassRegisterAttribute(ic, "BGCOLOR", iBackgroundBoxGetBgColorAttrib, iBackgroundBoxSetBgColorAttrib, IUPAF_SAMEASSYSTEM, "DLGBGCOLOR", IUPAF_NO_SAVE | IUPAF_DEFAULT);
iupClassRegisterReplaceAttribDef (ic, "BORDER", "NO", NULL);
iupClassRegisterReplaceAttribFlags(ic, "BORDER", IUPAF_NO_INHERIT);
iupClassRegisterReplaceAttribDef (ic, "SCROLLBAR", "NO", NULL);
return ic;
}
Ihandle* IupBackgroundBox(Ihandle* child)
{
void *children[2];
children[0] = (void*)child;
children[1] = NULL;
return IupCreatev("backgroundbox", children);
}
|
//
// Created by Maxim Pervushin on 31/05/15.
// Copyright (c) 2015 Maxim Pervushin. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef NSString *HTLCategoryIdentifier;
@interface HTLCategory : NSObject <NSCopying>
+ (instancetype)categoryWithIdentifier:(HTLCategoryIdentifier)identifier title:(NSString *)title color:(UIColor *)color;
- (instancetype)initWithIdentifier:(HTLCategoryIdentifier)identifier title:(NSString *)title color:(UIColor *)color;
- (id)copyWithZone:(NSZone *)zone;
- (BOOL)isEqual:(id)other;
- (BOOL)isEqualToCategory:(HTLCategory *)category;
- (NSUInteger)hash;
- (NSString *)description;
@property(nonatomic, readonly) HTLCategoryIdentifier identifier;
@property(nonatomic, readonly) NSString *title;
@property(nonatomic, readonly) UIColor *color;
@end
@interface HTLCategory (Localized)
@property(nonatomic, readonly) NSString *localizedTitle;
@end
|
/**
* @file dfk/internal/http/request.h
* HTTP request - private methods
*
* @copyright
* Copyright (c) 2017 Stanislav Ivochkin
* Licensed under the MIT License (see LICENSE)
*/
#pragma once
#include <dfk/arena.h>
#include <dfk/tcp_socket.h>
#include <dfk/http/request.h>
/**
* Initialize dfk_http_request_t
*
* dfk_http_request_t objects are created and initialized within
* dfk_http function, therefore this function is marked as private.
*/
void dfk__http_request_init(dfk_http_request_t* req, struct dfk_http_t* http,
dfk_arena_t* request_arena, dfk_arena_t* connection_arena,
dfk_tcp_socket_t* sock);
/**
* Cleanup resources allocated for dfk_http_request_t
*
* dfk_http_request_t objects are created and free'd within
* dfk_http function, therefore this function is marked as private.
*/
void dfk__http_request_free(dfk_http_request_t* req);
/**
* Read HTTP request headers.
*
* Reads and parses url and headers.
*
* A part of request body, or even the next request within connection may
* be read by this function. If so, unused data is stored in
* dfk_http_request_t._remainder member and is accessible within
* dfk_http_request_t lifetime.
*/
int dfk__http_request_read_headers(dfk_http_request_t* req);
|
/**
* `qute.h' - qute
* copyright (c) 2014 - joseph.werle@gmail.com
*/
#ifndef QUTE_H
#define QUTE_H
/**
* api.
*/
#include "ast.h"
#include "lex.h"
#include "error.h"
#include "parser.h"
#endif
|
/*
byteswap.h - C preprocessor macros for byte swapping.
Copyright (C) 1995, 1996 Michael Riepe <michael@stud.uni-hannover.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* @(#) $Id: byteswap.h,v 1.2 1996/10/22 16:45:54 michael Exp $ */
#ifndef _BYTESWAP_H
#define _BYTESWAP_H
#define lu(from,i,s) (((long)((unsigned char*)(from))[i])<<(s))
#define li(from,i,s) (((long)((signed char*)(from))[i])<<(s))
#define __load_u16L(from) ((unsigned long)(lu(from,1,8)|lu(from,0,0)))
#define __load_u16M(from) ((unsigned long)(lu(from,0,8)|lu(from,1,0)))
#define __load_i16L(from) ((long)(li(from,1,8)|lu(from,0,0)))
#define __load_i16M(from) ((long)(li(from,0,8)|lu(from,1,0)))
#define __load_u32L(from) ((unsigned long)(lu(from,3,24)| \
lu(from,2,16)| \
lu(from,1,8)| \
lu(from,0,0)))
#define __load_u32M(from) ((unsigned long)(lu(from,0,24)| \
lu(from,1,16)| \
lu(from,2,8)| \
lu(from,3,0)))
#define __load_i32L(from) ((long)(li(from,3,24)| \
lu(from,2,16)| \
lu(from,1,8)| \
lu(from,0,0)))
#define __load_i32M(from) ((long)(li(from,0,24)| \
lu(from,1,16)| \
lu(from,2,8)| \
lu(from,3,0)))
#define su(to,i,v,s) (((char*)(to))[i]=((unsigned long)(v)>>(s)))
#define si(to,i,v,s) (((char*)(to))[i]=((long)(v)>>(s)))
#define __store_u16L(to,v) (su(to,1,v,8),su(to,0,v,0))
#define __store_u16M(to,v) (su(to,0,v,8),su(to,1,v,0))
#define __store_i16L(to,v) (si(to,1,v,8),si(to,0,v,0))
#define __store_i16M(to,v) (si(to,0,v,8),si(to,1,v,0))
#define __store_u32L(to,v) (su(to,3,v,24), \
su(to,2,v,16), \
su(to,1,v,8), \
su(to,0,v,0))
#define __store_u32M(to,v) (su(to,0,v,24), \
su(to,1,v,16), \
su(to,2,v,8), \
su(to,3,v,0))
#define __store_i32L(to,v) (si(to,3,v,24), \
si(to,2,v,16), \
si(to,1,v,8), \
si(to,0,v,0))
#define __store_i32M(to,v) (si(to,0,v,24), \
si(to,1,v,16), \
si(to,2,v,8), \
si(to,3,v,0))
#endif /* _BYTESWAP_H */
|
/*
Copyright 2009, Arash Payan (http://arashpayan.com)
This library is distributed under the terms of the GNU Lesser GPL.
This file is part of APXML.
APXML 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.
APXML 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 APXML. If not, see <http://www.gnu.org/licenses/>.
*/
#import <UIKit/UIKit.h>
@class APAttribute;
@interface APElement : NSObject {
NSString *name;
NSMutableString *value;
APElement *parent;
NSMutableDictionary *attributes;
NSMutableArray *childElements;
}
@property (readonly) NSString *name;
@property (nonatomic, assign) APElement *parent;
+ (id)elementWithName:(NSString*)aName;
+ (id)elementWithName:(NSString*)aName attributes:(NSDictionary*)someAttributes;
- (id)initWithName:(NSString*)aName;
- (void)addAttribute:(APAttribute*)anAttribute;
- (void)addAttributeNamed:(NSString*)aName withValue:(NSString*)aValue;
- (void)addAttributes:(NSDictionary*)someAttributes;
- (void)addChild:(APElement*)anElement;
- (void)appendValue:(NSString*)aValue;
- (NSInteger)attributeCount;
- (NSArray *)attributeNames;
- (NSInteger)childCount;
- (NSArray*)childElements;
- (NSMutableArray*)childElements:(NSString*)aName;
- (APElement*)firstChildElement;
- (APElement*)firstChildElementNamed:(NSString*)aName;
- (NSString*)value;
- (NSString*)valueForAttributeNamed:(NSString*)aName;
- (NSString*)encodeEntities:(NSMutableString*)aString;
- (NSString*)prettyXML:(int)tabs;
- (NSString*)xml;
@end
|
/**
* \file
*
* \brief WDT
*
* Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
*
* \asf_license_start
*
* \page License
*
* Subject to your compliance with these terms, you may use Microchip
* software and any derivatives exclusively with Microchip products.
* It is your responsibility to comply with third party license terms applicable
* to your use of third party software (including open source software) that
* may accompany Microchip software.
*
* THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
* WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
* INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
* AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
* LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
* LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
* SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
* POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
* ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
* RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
* THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
*
* \asf_license_stop
*
*/
#include "hal_wdt.h"
/**
* \brief Driver version
*/
#define DRIVER_VERSION 0x00000001u
uint32_t wdt_get_version(void)
{
return DRIVER_VERSION;
}
|
//
// PXPie.h
// PXEngine
//
// Created by Kevin Lindsey on 9/5/12.
// Copyright (c) 2012 Pixate, Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <PXEngine/PXArc.h>
/**
* A PXArc subclass used to render pie graphs
*/
@interface PXPie : PXArc
@end
|
/*
For more advanced behavior you want to make the AI remember
the last place where it saw the target.
That way, when LOS starts failing you have a position from which
the AI can start some kind of search behavior.
*/
/*
You'll have to play with the numbers for your actual game but in practice
I find that AI doesn't really need to raytrace to it's targets more than 1-2 times a second.
Generally visibility is stored in a "VisibilityManager" or some other meta object
that does X number of raytraces per second and caches the results
for the AI to look up whenever it needs to.
* Ray-Casting je asichronny
- Teda sa poziada, posle pointer na funkciu ktora sa ma splnit a cele to bezi na novom vlakne
- Po vykonani sa spusti dana funkcia
*/
/*
Modern games can often incorporate other modeled senses like sound.
You have obejcts that make sound which is modeled by a radius.
Any AI within that radius will become aware of the sound maker.
*/
/*
Cesty pri stenach mozu byt preddefinovane a osoba hlada cestu,
spravi priamku a ked trafi priamku pred stenou tak ide po danej priamke...
*/ |
/* File object interface (what's left of it -- see io.py) */
#ifndef Py_FILEOBJECT_H
#define Py_FILEOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
#define PY_STDIOTEXTMODE "b"
PyAPI_FUNC(PyObject *) PyFile_FromFd(int, const char *, const char *, int,
const char *, const char *,
const char *, int);
PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int);
PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int);
PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *);
PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *);
/* The default encoding used by the platform file system APIs
If non-NULL, this is different than the default encoding for strings
*/
PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding;
PyAPI_DATA(int) Py_HasFileSystemDefaultEncoding;
/* A routine to check if a file descriptor can be select()-ed. */
#ifdef _MSC_VER
/* On Windows, any socket fd can be select()-ed, no matter how high */
#define _PyIsSelectable_fd(FD) (1)
#else
#define _PyIsSelectable_fd(FD) ((unsigned int)(FD) < (unsigned int)FD_SETSIZE)
#endif
#ifndef Py_LIMITED_API
# define Py_CPYTHON_FILEOBJECT_H
# include "cpython/fileobject.h"
# undef Py_CPYTHON_FILEOBJECT_H
#endif
#ifdef __cplusplus
}
#endif
#endif /* !Py_FILEOBJECT_H */
|
#import <UIKit/UIKit.h>
#import "OSThumbnailWrapper.h"
#import "../OSPaneModel.h"
#import "../OSPane.h"
#import "../explorer/CGPointExtension.h"
#import "OSAddDesktopButton.h"
#import "OSPaneThumbnail.h"
#define thumbnailMarginSize 20
#define wrapperCenter 20
@class OSThumbnailWrapper, OSPaneThumbnail;
@interface OSThumbnailView : UIView <OSAddDesktopButtonDelegate, OSPaneThumbnailDelegate>{
OSThumbnailWrapper *_wrapperView;
OSAddDesktopButton *_addDesktopButton;
BOOL _shouldLayoutSubviews;
}
@property (nonatomic, retain) OSThumbnailWrapper *wrapperView;
@property (nonatomic, retain) OSAddDesktopButton *addDesktopButton;
@property (nonatomic, readwrite) BOOL shouldLayoutSubviews;
+ (id)sharedInstance;
- (BOOL)isPortrait;
- (void)addPane:(OSPane*)pane;
- (void)alignSubviews;
- (BOOL)isPortrait:(UIInterfaceOrientation)orientation;
- (void)removePane:(OSPane*)pane animated:(BOOL)animated;
- (void)updateSelectedThumbnail;
- (void)closeAllCloseboxesAnimated:(BOOL)animated;
- (void)updatePressedThumbnails;
- (OSPaneThumbnail*)thumbnailForPane:(OSPane*)pane;
@end |
#include <pebble.h>
#define KEY_BUTTON_UP 0
#define KEY_BUTTON_DOWN 1
static Window *s_main_window;
static TextLayer *s_output_layer;
static void send(int key, int value) {
DictionaryIterator *iter;
app_message_outbox_begin(&iter);
dict_write_int(iter, key, &value, sizeof(int), true);
app_message_outbox_send();
}
static void outbox_sent_handler(DictionaryIterator *iter, void *context) {
// Ready for next command
text_layer_set_text(s_output_layer, "Press up or down.");
}
static void outbox_failed_handler(DictionaryIterator *iter, AppMessageResult reason, void *context) {
text_layer_set_text(s_output_layer, "Send failed!");
APP_LOG(APP_LOG_LEVEL_ERROR, "Fail reason: %d", (int)reason);
}
static void up_click_handler(ClickRecognizerRef recognizer, void *context) {
text_layer_set_text(s_output_layer, "Up");
send(KEY_BUTTON_UP, 0);
}
static void down_click_handler(ClickRecognizerRef recognizer, void *context) {
text_layer_set_text(s_output_layer, "Down");
send(KEY_BUTTON_DOWN, 0);
}
static void click_config_provider(void *context) {
window_single_click_subscribe(BUTTON_ID_UP, up_click_handler);
window_single_click_subscribe(BUTTON_ID_DOWN, down_click_handler);
}
static void main_window_load(Window *window) {
Layer *window_layer = window_get_root_layer(window);
GRect bounds = layer_get_bounds(window_layer);
const int text_height = 20;
const GEdgeInsets text_insets = GEdgeInsets((bounds.size.h - text_height) / 2, 0);
s_output_layer = text_layer_create(grect_inset(bounds, text_insets));
text_layer_set_text(s_output_layer, "Press up or down.");
text_layer_set_text_alignment(s_output_layer, GTextAlignmentCenter);
layer_add_child(window_layer, text_layer_get_layer(s_output_layer));
}
static void main_window_unload(Window *window) {
text_layer_destroy(s_output_layer);
}
static void init(void) {
s_main_window = window_create();
window_set_click_config_provider(s_main_window, click_config_provider);
window_set_window_handlers(s_main_window, (WindowHandlers) {
.load = main_window_load,
.unload = main_window_unload,
});
window_stack_push(s_main_window, true);
// Open AppMessage
app_message_register_outbox_sent(outbox_sent_handler);
app_message_register_outbox_failed(outbox_failed_handler);
const int inbox_size = 128;
const int outbox_size = 128;
app_message_open(inbox_size, outbox_size);
}
static void deinit(void) {
window_destroy(s_main_window);
}
int main(void) {
init();
app_event_loop();
deinit();
}
|
// RUN: %check %s -Weverything
int main(void) // CHECK: !/warning: no previous prototype/
{
}
|
//
// ZFLoadPhotoSetPhotos.h
//
// DO NOT MODIFY!! Modifications will be overwritten.
// Generated by: Mike Fullerton @ 6/3/13 10:43 AM with PackMule (3.0.1.100)
//
// Project: Zenfolio Web API
// Schema: ZenfolioWebApi
//
// Copyright 2013 (c) GreenTongue Software LLC, Mike Fullerton
// The FishLamp Framework is released under the MIT License: http://fishlamp.com/license
//
#import "FLModelObject.h"
@interface ZFLoadPhotoSetPhotos : FLModelObject {
@private
int _startingIndex;
long _photoSetId;
int _numberOfPhotos;
}
@property (readwrite, assign, nonatomic) int numberOfPhotos;
@property (readwrite, assign, nonatomic) long photoSetId;
@property (readwrite, assign, nonatomic) int startingIndex;
+ (ZFLoadPhotoSetPhotos*) loadPhotoSetPhotos;
@end
|
#include <_ansi.h>
#include <_syslist.h>
#include <sys/reent.h>
#include <sys/errno.h>
#include <sys/types.h>
#include <sys/lv2errno.h>
#include <sys/file.h>
_off_t
_DEFUN(__librt_lseek_r,(r,fd,pos,dir),
struct _reent *r _AND
int fd _AND
_off_t pos _AND
int dir)
{
s32 ret = 0;
u64 position = 0;
ret = sysLv2FsLSeek64(fd,pos,dir,&position);
if(ret) return (_off_t)lv2errno_r(r,ret);
return (_off_t)position;
}
_off64_t
_DEFUN(__librt_lseek64_r,(r,fd,pos,dir),
struct _reent *r _AND
int fd _AND
_off64_t pos _AND
int dir)
{
s32 ret = 0;
u64 position = 0;
ret = sysLv2FsLSeek64(fd,pos,dir,&position);
if(ret) return (_off64_t)lv2errno_r(r,ret);
return (_off64_t)position;
}
|
// This code contains NVIDIA Confidential Information and is disclosed to you
// under a form of NVIDIA software license agreement provided separately to you.
//
// Notice
// NVIDIA Corporation and its licensors retain all intellectual property and
// proprietary rights in and to this software and related documentation and
// any modifications thereto. Any use, reproduction, disclosure, or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA Corporation is strictly prohibited.
//
// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
//
// Information and code furnished is believed to be accurate and reliable.
// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
// information or for any infringement of patents or other rights of third parties that may
// result from its use. No license is granted by implication or otherwise under any patent
// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
// This code supersedes and replaces all information previously supplied.
// NVIDIA Corporation products are not authorized for use as critical
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
// Copyright (c) 2008-2013 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_FOUNDATION_PSINTRINSICS_H
#define PX_FOUNDATION_PSINTRINSICS_H
#include "foundation/PxPreprocessor.h"
#if (defined PX_WINDOWS || defined PX_WINMODERN)
#include "windows/PsWindowsIntrinsics.h"
#elif defined PX_X360
#include "xbox360/PsXbox360Intrinsics.h"
#elif (defined PX_LINUX || defined PX_ANDROID || defined PX_APPLE)
#include "linux/PsLinuxIntrinsics.h"
#elif defined PX_PS3
#include "ps3/PsPS3Intrinsics.h"
#elif defined PX_PSP2
#include "psp2/PsPSP2Intrinsics.h"
#else
#error "Platform not supported!"
#endif
#endif
|
//
// VIMCredit.h
// Pods
//
// Created by Fiel Guhit on 1/20/17.
// Copyright (c) 2014-2017 Vimeo (https://vimeo.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.
//
// 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.
//
#import "VIMModelObject.h"
@class VIMVideo;
@class VIMUser;
@interface VIMCredit : VIMModelObject
@property (nonatomic, copy, nullable) NSString *uri;
@property (nonatomic, copy, nullable) NSString *role;
@property (nonatomic, nullable) VIMVideo *video;
@property (nonatomic, nullable) VIMUser *user;
@end
|
/* Declarations for the Windows Multimedia timer functions */
enum { TIME_ONESHOT, TIME_PERIODIC };
uint32 __attribute__ ((stdcall)) timeSetEvent(uint32 delay, uint32 resolution,
void *callback, uint32 dummy,
uint32 type);
uint32 __attribute__ ((stdcall)) timeKillEvent(uint32 id);
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.