text
stringlengths 4
6.14k
|
|---|
/* $NetBSD: obio.c,v 1.1 2002/05/02 15:17:58 nonaka Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Charles M. Hannum.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/extent.h>
#include <machine/bus.h>
#include <machine/pio.h>
#include <machine/intr.h>
#include <machine/platform.h>
#include <prep/dev/obiovar.h>
#include <dev/isa/isareg.h>
#include "wdc_obio.h"
static int obio_found = 0;
static int obio_match(struct device *, struct cfdata *, void *);
static void obio_attach(struct device *, struct device *, void *);
static int obio_print(void *, const char *);
static int obio_search(struct device *, struct cfdata *, void *);
struct cfattach obio_ca = {
sizeof(struct device), obio_match, obio_attach
};
extern struct cfdriver obio_cd;
static int
obio_match(struct device *parent, struct cfdata *cf, void *aux)
{
if (obio_found)
return 0;
return 1;
}
static void
obio_attach(struct device *parent, struct device *self, void *aux)
{
obio_found = 1;
printf("\n");
(void)config_search(obio_search, self, aux);
}
static int
obio_search(struct device *parent, struct cfdata *cf, void *aux)
{
struct obio_attach_args oa;
const char **p;
p = platform->obiodevs;
if (p == NULL)
return 0;
for (; *p != NULL; p++) {
if (strcmp(cf->cf_driver->cd_name, *p) == 0) {
oa.oa_iot = &prep_isa_io_space_tag;
oa.oa_memt = &prep_isa_mem_space_tag;
oa.oa_iobase = cf->cf_iobase;
oa.oa_iosize = cf->cf_iosize;
oa.oa_maddr = cf->cf_maddr;
oa.oa_msize = cf->cf_msize;
oa.oa_irq = cf->cf_irq == 2 ? 9 : cf->cf_irq;
if ((*cf->cf_attach->ca_match)(parent, cf, &oa) > 0)
config_attach(parent, cf, &oa, obio_print);
}
}
return 0;
}
static int
obio_print(void *args, const char *name)
{
struct obio_attach_args *oa = args;
if (oa->oa_iosize)
printf(" port 0x%x", oa->oa_iobase);
if (oa->oa_iosize > 1)
printf("-0x%x", oa->oa_iobase + oa->oa_iosize - 1);
if (oa->oa_msize)
printf(" mem 0x%x", oa->oa_maddr);
if (oa->oa_msize > 1)
printf("-0x%x", oa->oa_maddr + oa->oa_msize - 1);
if (oa->oa_irq != IRQUNK)
printf(" irq %d", oa->oa_irq);
return (UNCONF);
}
/*
* Set up an interrupt handler to start being called.
*/
void *
obio_intr_establish(int irq, int type, int level, int (*ih_fun)(void *),
void *ih_arg)
{
return (void *)intr_establish(irq, type, level, ih_fun, ih_arg);
}
/*
* Deregister an interrupt handler.
*/
void
obio_intr_disestablish(void *arg)
{
intr_disestablish(arg);
}
/*
* obio bus resource mapping
*/
#if NWDC_OBIO > 0
static bus_space_handle_t wdc0_cmd;
static bus_space_handle_t wdc0_ctl;
static bus_space_handle_t wdc1_cmd;
static bus_space_handle_t wdc1_ctl;
#endif
void
obio_reserve_resource_map(void)
{
const char **p;
for (p = platform->obiodevs; *p != NULL; p++) {
#if NWDC_OBIO > 0
if (strcmp(*p, "wdc") == 0) {
bus_space_map(&prep_isa_io_space_tag, IO_WD1, 8,
0, &wdc0_cmd);
bus_space_map(&prep_isa_io_space_tag, IO_WD1 + 0x206, 1,
0, &wdc0_ctl);
bus_space_map(&prep_isa_io_space_tag, IO_WD2, 8,
0, &wdc1_cmd);
bus_space_map(&prep_isa_io_space_tag, IO_WD2 + 0x206, 1,
0, &wdc1_ctl);
}
#endif
}
}
void
obio_reserve_resource_unmap(void)
{
const char **p;
for (p = platform->obiodevs; *p != NULL; p++) {
#if NWDC_OBIO > 0
if (strcmp(*p, "wdc") == 0) {
bus_space_unmap(&prep_isa_io_space_tag, wdc0_cmd, 8);
bus_space_unmap(&prep_isa_io_space_tag, wdc0_ctl, 1);
bus_space_unmap(&prep_isa_io_space_tag, wdc1_cmd, 8);
bus_space_unmap(&prep_isa_io_space_tag, wdc1_ctl, 1);
}
#endif
}
}
|
/* $NetBSD: aout_machdep.h,v 1.1 2000/06/14 15:39:55 soren Exp $ */
#include <mips/aout_machdep.h>
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SKY_SHELL_SHELL_H_
#define SKY_SHELL_SHELL_H_
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/thread.h"
namespace sky {
namespace shell {
class Engine;
class PlatformView;
class Rasterizer;
class ServiceProviderContext;
class Shell {
public:
~Shell();
static void Init(
scoped_ptr<ServiceProviderContext> service_provider_context);
static Shell& Shared();
PlatformView* view() const { return view_.get(); }
private:
explicit Shell(scoped_ptr<ServiceProviderContext> service_provider_context);
void InitGPU(const base::Thread::Options& options);
void InitUI(const base::Thread::Options& options);
void InitView();
scoped_ptr<base::Thread> gpu_thread_;
scoped_ptr<base::Thread> ui_thread_;
scoped_ptr<PlatformView> view_;
scoped_ptr<Rasterizer> rasterizer_;
scoped_ptr<Engine> engine_;
scoped_ptr<ServiceProviderContext> service_provider_context_;
DISALLOW_COPY_AND_ASSIGN(Shell);
};
} // namespace shell
} // namespace sky
#endif // SKY_SHELL_SHELL_H_
|
/**/
#include<stdio.h>
int main(){
float A, B, C, D, grade;
printf("Enter thresholds for A, B, C, D\nin that order decreasing percentages > ");
scanf("%f %f %f %f", &A, &B, &C, &D);
printf("Thank you. Now enter student score (percent) > ");
scanf("%f", &grade);
if(grade<D){
printf("Student has an F grade\n");}
else if(grade<C){
printf("Student has a D grade\n");}
else if(grade<B){
printf("Student has a C grade\n");}
else if(grade<A){
printf("Student has a B grade\n");}
else if(grade>=A){
printf("Student has an A grade\n");}
return 0;
}
|
//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.3
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com
// http://www.antigrain.com
//----------------------------------------------------------------------------
//
// SVG path tokenizer.
//
//----------------------------------------------------------------------------
#ifndef AGG_SVG_PATH_TOKENIZER_INCLUDED
#define AGG_SVG_PATH_TOKENIZER_INCLUDED
#include "agg_svg_exception.h"
namespace agg
{
namespace svg
{
// SVG path tokenizer.
// Example:
//
// agg::svg::path_tokenizer tok;
//
// tok.set_str("M-122.304 84.285L-122.304 84.285 122.203 86.179 ");
// while(tok.next())
// {
// printf("command='%c' number=%f\n",
// tok.last_command(),
// tok.last_number());
// }
//
// The tokenizer does all the routine job of parsing the SVG paths.
// It doesn't recognize any graphical primitives, it even doesn't know
// anything about pairs of coordinates (X,Y). The purpose of this class
// is to tokenize the numeric values and commands. SVG paths can
// have single numeric values for Horizontal or Vertical line_to commands
// as well as more than two coordinates (4 or 6) for Bezier curves
// depending on the semantics of the command.
// The behaviour is as follows:
//
// Each call to next() returns true if there's new command or new numeric
// value or false when the path ends. How to interpret the result
// depends on the sematics of the command. For example, command "C"
// (cubic Bezier curve) implies 6 floating point numbers preceded by this
// command. If the command assumes no arguments (like z or Z) the
// the last_number() values won't change, that is, last_number() always
// returns the last recognized numeric value, so does last_command().
//===============================================================
class path_tokenizer
{
public:
path_tokenizer();
void set_path_str(const char* str);
bool next();
real next(char cmd);
char last_command() const { return m_last_command; }
real last_number() const { return m_last_number; }
private:
static void init_char_mask(char* mask, const char* char_set);
bool contains(const char* mask, unsigned c) const
{
return (mask[(c >> 3) & (256/8-1)] & (1 << (c & 7))) != 0;
}
bool is_command(unsigned c) const
{
return contains(m_commands_mask, c);
}
bool is_numeric(unsigned c) const
{
return contains(m_numeric_mask, c);
}
bool is_separator(unsigned c) const
{
return contains(m_separators_mask, c);
}
bool parse_number();
char m_separators_mask[256/8];
char m_commands_mask[256/8];
char m_numeric_mask[256/8];
const char* m_path;
real m_last_number;
char m_last_command;
static const char s_commands[];
static const char s_numeric[];
static const char s_separators[];
};
} //namespace svg
} //namespace agg
#endif
|
/*
* cam_MeadeDSI.h
* PHD Guiding
*
* Created by Craig Stark.
* Copyright (c) 2006, 2007, 2008, 2009, 2010 Craig Stark.
* All rights reserved.
*
* This source code is distrubted under the following "BSD" license
* 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 Craig Stark, Stark Labs nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef CAM_MEADEDSI_INCLUDED
#define CAM_MEADEDSI_INCLUDED
class DSICameraFactory
{
public:
static GuideCamera *MakeDSICamera();
};
#endif // CAM_MEADEDSI_INCLUDED
|
#ifndef incline_driver_sharded_h
#define incline_driver_sharded_h
#include "incline_driver_async_qtable.h"
class incline_def_sharded;
class incline_driver_sharded : public incline_driver_async_qtable {
public:
typedef incline_driver_async_qtable super;
struct connect_params {
std::string file;
std::string host;
unsigned short port;
std::string username;
std::string password;
connect_params(const std::string& f) : file(f), host(), port(), username(), password() {}
std::string parse(const picojson::value& def);
incline_dbms* connect();
public:
static const connect_params* find(const std::vector<connect_params>& cp, const std::string& host, unsigned short port);
};
class rule {
protected:
std::string file_;
unsigned long long file_mtime_;
public:
rule(const std::string& file) : file_(file), file_mtime_(_get_file_mtime()) {}
virtual ~rule() {}
std::string file() const { return file_; }
bool should_exit_loop() const;
protected:
virtual std::string parse(const picojson::value& def) = 0;
unsigned long long _get_file_mtime() const;
public:
static rule* parse(const std::string& file, std::string& err);
};
class shard_rule : public rule {
public:
shard_rule(const std::string& file) : rule(file) {}
virtual std::vector<connect_params> get_all_connect_params() const = 0;
virtual connect_params get_connect_params_for(const std::string& key) const = 0;
virtual std::string build_expr_for(const std::string& column_expr, const std::string& host, unsigned short port) const = 0;
};
class replicator_rule : public rule {
protected:
connect_params src_cp_;
std::vector<connect_params> dest_cp_;
public:
replicator_rule(const std::string& file) : rule(file), src_cp_(file), dest_cp_() {}
const connect_params& source() const { return src_cp_; }
const std::vector<connect_params>& destination() const { return dest_cp_; }
protected:
virtual std::string parse(const picojson::value& def);
};
protected:
std::vector<const rule*> rules_;
std::string cur_host_;
unsigned short cur_port_;
public:
incline_driver_sharded() : rules_(), cur_host_(), cur_port_() {}
virtual ~incline_driver_sharded();
std::string init(const std::string& host, unsigned short port);
virtual incline_def* create_def() const;
virtual std::vector<std::string> create_table_all(bool if_not_exists, incline_dbms* dbh) const;
virtual std::vector<std::string> drop_table_all(bool if_exists) const;
virtual void run_forwarder(int poll_interval, FILE* log_fh);
virtual bool should_exit_loop() const;
const rule* rule_of(const std::string& file) const;
std::pair<std::string, unsigned short> get_hostport() const {
return make_pair(cur_host_, cur_port_);
}
bool is_src_host_of(const incline_def_sharded* def) const;
bool is_replicator_dest_host_of(const incline_def_sharded* def) const;
protected:
virtual void _build_insert_from_def(trigger_body& body, const incline_def* def, const std::string& src_table, action_t action, const std::vector<std::string>* cond) const;
virtual void _build_delete_from_def(trigger_body& body, const incline_def* def, const std::string& src_table, const std::vector<std::string>& cond) const;
virtual void _build_update_merge_from_def(trigger_body& body, const incline_def* def, const std::string& src_table, const std::vector<std::string>& cond) const;
virtual std::string do_build_direct_expr(const incline_def_async* def, const std::string& column_expr) const;
};
#endif
|
/*
* Copyright (c) 2012,2014,2015 Apple Inc. All rights reserved.
*
* corecrypto Internal Use License Agreement
*
* IMPORTANT: This Apple corecrypto software is supplied to you by Apple Inc. ("Apple")
* in consideration of your agreement to the following terms, and your download or use
* of this Apple software constitutes acceptance of these terms. If you do not agree
* with these terms, please do not download or use this Apple software.
*
* 1. As used in this Agreement, the term "Apple Software" collectively means and
* includes all of the Apple corecrypto materials provided by Apple here, including
* but not limited to the Apple corecrypto software, frameworks, libraries, documentation
* and other Apple-created materials. In consideration of your agreement to abide by the
* following terms, conditioned upon your compliance with these terms and subject to
* these terms, Apple grants you, for a period of ninety (90) days from the date you
* download the Apple Software, a limited, non-exclusive, non-sublicensable license
* under Apple’s copyrights in the Apple Software to make a reasonable number of copies
* of, compile, and run the Apple Software internally within your organization only on
* devices and computers you own or control, for the sole purpose of verifying the
* security characteristics and correct functioning of the Apple Software; provided
* that you must retain this notice and the following text and disclaimers in all
* copies of the Apple Software that you make. You may not, directly or indirectly,
* redistribute the Apple Software or any portions thereof. The Apple Software is only
* licensed and intended for use as expressly stated above and may not be used for other
* purposes or in other contexts without Apple's prior written permission. Except as
* expressly stated in this notice, no other rights or licenses, express or implied, are
* granted by Apple herein.
*
* 2. The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
* WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES
* OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING
* THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS,
* SYSTEMS, OR SERVICES. APPLE DOES NOT WARRANT THAT THE APPLE SOFTWARE WILL MEET YOUR
* REQUIREMENTS, THAT THE OPERATION OF THE APPLE SOFTWARE WILL BE UNINTERRUPTED OR
* ERROR-FREE, THAT DEFECTS IN THE APPLE SOFTWARE WILL BE CORRECTED, OR THAT THE APPLE
* SOFTWARE WILL BE COMPATIBLE WITH FUTURE APPLE PRODUCTS, SOFTWARE OR SERVICES. NO ORAL
* OR WRITTEN INFORMATION OR ADVICE GIVEN BY APPLE OR AN APPLE AUTHORIZED REPRESENTATIVE
* WILL CREATE A WARRANTY.
*
* 3. IN NO EVENT SHALL APPLE BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING
* IN ANY WAY OUT OF THE USE, REPRODUCTION, COMPILATION OR OPERATION OF THE APPLE
* SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* 4. This Agreement is effective until terminated. Your rights under this Agreement will
* terminate automatically without notice from Apple if you fail to comply with any term(s)
* of this Agreement. Upon termination, you agree to cease all use of the Apple Software
* and destroy all copies, full or partial, of the Apple Software. This Agreement will be
* governed and construed in accordance with the laws of the State of California, without
* regard to its choice of law rules.
*
* You may report security issues about Apple products to product-security@apple.com,
* as described here: https://www.apple.com/support/security/. Non-security bugs and
* enhancement requests can be made via https://bugreport.apple.com as described
* here: https://developer.apple.com/bug-reporting/
*
* EA1350
* 10/5/15
*/
#include "ccsymmetric.h"
int test_mode(ciphermode_t encrypt_ciphermode, ciphermode_t decrypt_ciphermode, cc_cipher_select cipher, cc_mode_select mode);
int test_gcm(const struct ccmode_gcm *encrypt_ciphermode, const struct ccmode_gcm *decrypt_ciphermode);
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_loop_13.c
Label Definition File: CWE122_Heap_Based_Buffer_Overflow__c_CWE806.label.xml
Template File: sources-sink-13.tmpl.c
*/
/*
* @description
* CWE: 122 Heap Based Buffer Overflow
* BadSource: Initialize data as a large string
* GoodSource: Initialize data as a small string
* Sink: loop
* BadSink : Copy data to string using a loop
* Flow Variant: 13 Control flow: if(GLOBAL_CONST_FIVE==5) and if(GLOBAL_CONST_FIVE!=5)
*
* */
#include "std_testcase.h"
#include <wchar.h>
#ifndef OMITBAD
void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_loop_13_bad()
{
wchar_t * data;
data = (wchar_t *)malloc(100*sizeof(wchar_t));
if (data == NULL) {exit(-1);}
if(GLOBAL_CONST_FIVE==5)
{
/* FLAW: Initialize data as a large buffer that is larger than the small buffer used in the sink */
wmemset(data, L'A', 100-1); /* fill with L'A's */
data[100-1] = L'\0'; /* null terminate */
}
{
wchar_t dest[50] = L"";
size_t i, dataLen;
dataLen = wcslen(data);
/* POTENTIAL FLAW: Possible buffer overflow if data is larger than dest */
for (i = 0; i < dataLen; i++)
{
dest[i] = data[i];
}
dest[50-1] = L'\0'; /* Ensure the destination buffer is null terminated */
printWLine(data);
free(data);
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B1() - use goodsource and badsink by changing the GLOBAL_CONST_FIVE==5 to GLOBAL_CONST_FIVE!=5 */
static void goodG2B1()
{
wchar_t * data;
data = (wchar_t *)malloc(100*sizeof(wchar_t));
if (data == NULL) {exit(-1);}
if(GLOBAL_CONST_FIVE!=5)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
}
else
{
/* FIX: Initialize data as a small buffer that as small or smaller than the small buffer used in the sink */
wmemset(data, L'A', 50-1); /* fill with L'A's */
data[50-1] = L'\0'; /* null terminate */
}
{
wchar_t dest[50] = L"";
size_t i, dataLen;
dataLen = wcslen(data);
/* POTENTIAL FLAW: Possible buffer overflow if data is larger than dest */
for (i = 0; i < dataLen; i++)
{
dest[i] = data[i];
}
dest[50-1] = L'\0'; /* Ensure the destination buffer is null terminated */
printWLine(data);
free(data);
}
}
/* goodG2B2() - use goodsource and badsink by reversing the blocks in the if statement */
static void goodG2B2()
{
wchar_t * data;
data = (wchar_t *)malloc(100*sizeof(wchar_t));
if (data == NULL) {exit(-1);}
if(GLOBAL_CONST_FIVE==5)
{
/* FIX: Initialize data as a small buffer that as small or smaller than the small buffer used in the sink */
wmemset(data, L'A', 50-1); /* fill with L'A's */
data[50-1] = L'\0'; /* null terminate */
}
{
wchar_t dest[50] = L"";
size_t i, dataLen;
dataLen = wcslen(data);
/* POTENTIAL FLAW: Possible buffer overflow if data is larger than dest */
for (i = 0; i < dataLen; i++)
{
dest[i] = data[i];
}
dest[50-1] = L'\0'; /* Ensure the destination buffer is null terminated */
printWLine(data);
free(data);
}
}
void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_loop_13_good()
{
goodG2B1();
goodG2B2();
}
#endif /* OMITGOOD */
/* Below is the main(). It is only used when building this testcase on
* its own for testing or for building a binary to use in testing binary
* analysis tools. It is not used when compiling all the testcases as one
* application, which is how source code analysis tools are tested.
*/
#ifdef INCLUDEMAIN
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_loop_13_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_loop_13_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
#ifndef ASPRINTF_H_INCLUDED
#define ASPRINTF_H_INCLUDED
int vasprintf( char **sptr, char *fmt, va_list argv );
int asprintf( char **sptr, char *fmt, ... );
#endif /* ASPRINTF_H_INCLUDED */
|
/*
* 2007 2013 Copyright Northwestern University
*
* Distributed under the OSI-approved BSD 3-Clause License.
* See http://ncip.github.com/annotation-and-image-markup/LICENSE.txt for details.
*/
#ifndef _ALTOVA_INCLUDED_AIMXML_ALTOVA_iso_ALTOVA_CCOLL_ED_Signature
#define _ALTOVA_INCLUDED_AIMXML_ALTOVA_iso_ALTOVA_CCOLL_ED_Signature
#include "type_iso.CANY.h"
namespace AIMXML
{
namespace iso
{
class CCOLL_ED_Signature : public ::AIMXML::iso::CANY
{
public:
AIMXML_EXPORT CCOLL_ED_Signature(xercesc::DOMNode* const& init);
AIMXML_EXPORT CCOLL_ED_Signature(CCOLL_ED_Signature const& init);
void operator=(CCOLL_ED_Signature const& other) { m_node = other.m_node; }
static altova::meta::ComplexType StaticInfo() { return altova::meta::ComplexType(types + _altova_ti_iso_altova_CCOLL_ED_Signature); }
AIMXML_EXPORT void SetXsiType();
};
} // namespace iso
} // namespace AIMXML
#endif // _ALTOVA_INCLUDED_AIMXML_ALTOVA_iso_ALTOVA_CCOLL_ED_Signature
|
// 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 BASE_TASK_SEQUENCE_MANAGER_THREAD_CONTROLLER_H_
#define BASE_TASK_SEQUENCE_MANAGER_THREAD_CONTROLLER_H_
#include "base/message_loop/timer_slack.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/task/sequence_manager/lazy_now.h"
#include "base/time/time.h"
namespace base {
class MessageLoop;
class TickClock;
struct PendingTask;
namespace sequence_manager {
namespace internal {
struct AssociatedThreadId;
class SequencedTaskSource;
// Implementation of this interface is used by SequenceManager to schedule
// actual work to be run. Hopefully we can stop using MessageLoop and this
// interface will become more concise.
class ThreadController {
public:
virtual ~ThreadController() = default;
// Sets the number of tasks executed in a single invocation of DoWork.
// Increasing the batch size can reduce the overhead of yielding back to the
// main message loop.
virtual void SetWorkBatchSize(int work_batch_size = 1) = 0;
// Notifies that |pending_task| is about to be enqueued. Needed for tracing
// purposes. The impl may use this opportunity add metadata to |pending_task|
// before it is moved into the queue.
virtual void WillQueueTask(PendingTask* pending_task) = 0;
// Notify the controller that its associated sequence has immediate work
// to run. Shortly after this is called, the thread associated with this
// controller will run a task returned by sequence->TakeTask(). Can be called
// from any sequence.
//
// TODO(altimin): Change this to "the thread associated with this
// controller will run tasks returned by sequence->TakeTask() until it
// returns null or sequence->DidRunTask() returns false" once the
// code is changed to work that way.
virtual void ScheduleWork() = 0;
// Notify the controller that SequencedTaskSource will have a delayed work
// ready to be run at |run_time|. This call cancels any previously
// scheduled delayed work. Can only be called from the main sequence.
// NOTE: DelayTillNextTask might return a different value as it also takes
// immediate work into account.
// TODO(kraynov): Remove |lazy_now| parameter.
virtual void SetNextDelayedDoWork(LazyNow* lazy_now, TimeTicks run_time) = 0;
// Sets the sequenced task source from which to take tasks after
// a Schedule*Work() call is made.
// Must be called before the first call to Schedule*Work().
virtual void SetSequencedTaskSource(SequencedTaskSource*) = 0;
// Requests desired timer precision from the OS.
// Has no effect on some platforms.
virtual void SetTimerSlack(TimerSlack timer_slack) = 0;
// Completes delayed initialization of a ThreadControllers created with a null
// MessageLoop. May only be called once.
virtual void SetMessageLoop(MessageLoop* message_loop) = 0;
// TODO(altimin): Get rid of the methods below.
// These methods exist due to current integration of SequenceManager
// with MessageLoop.
virtual bool RunsTasksInCurrentSequence() = 0;
virtual const TickClock* GetClock() = 0;
virtual void SetDefaultTaskRunner(scoped_refptr<SingleThreadTaskRunner>) = 0;
virtual void RestoreDefaultTaskRunner() = 0;
virtual void AddNestingObserver(RunLoop::NestingObserver* observer) = 0;
virtual void RemoveNestingObserver(RunLoop::NestingObserver* observer) = 0;
virtual const scoped_refptr<AssociatedThreadId>& GetAssociatedThread()
const = 0;
};
} // namespace internal
} // namespace sequence_manager
} // namespace base
#endif // BASE_TASK_SEQUENCE_MANAGER_THREAD_CONTROLLER_H_
|
/*ckwg +5
* Copyright 2013 by Kitware, Inc. All Rights Reserved. Please refer to
* KITWARE_LICENSE.TXT for licensing information, or contact General Counsel,
* Kitware, Inc., 28 Corporate Drive, Clifton Park, NY 12065.
*/
#ifndef __vtkVgCompositeEventRepresentation_h
#define __vtkVgCompositeEventRepresentation_h
#include "vtkVgEventRepresentationBase.h"
#include <vgExport.h>
class VTKVG_MODELVIEW_EXPORT vtkVgCompositeEventRepresentation
: public vtkVgEventRepresentationBase
{
public:
vtkTypeMacro(vtkVgCompositeEventRepresentation, vtkVgEventRepresentationBase);
virtual void PrintSelf(ostream& os, vtkIndent indent);
static vtkVgCompositeEventRepresentation* New();
// Description:
// Return all the objects that can be rendered.
virtual const vtkPropCollection* GetNewRenderObjects() const;
virtual const vtkPropCollection* GetActiveRenderObjects() const;
virtual const vtkPropCollection* GetExpiredRenderObjects() const;
virtual vtkPropCollection* GetNewRenderObjects();
virtual vtkPropCollection* GetActiveRenderObjects();
virtual vtkPropCollection* GetExpiredRenderObjects();
virtual void ResetTemporaryRenderObjects();
// Description:
virtual void SetVisible(int flag);
virtual int GetVisible() const { return this->Visible; }
// Description:
// Update all the event actors. Generally called by the application layer.
virtual void Update();
// Description:
// Pick operation from display (i.e., pixel) coordinates in the current
// renderer. Return the picked eventId if a successful pick occurs,
// otherwise return -1. Note that the pick operation takes into account
// whether the event is currently visible or not.
virtual vtkIdType Pick(double renX, double renY, vtkRenderer* ren, vtkIdType& pickType);
// Description:
// Set the item on the representation.
virtual void SetEventModel(vtkVgEventModel* modelItem);
vtkGetObjectMacro(EventModel, vtkVgEventModel);
// Description:
// Set the event filter that this representation will use.
virtual void SetEventFilter(vtkVgEventFilter* filter);
vtkGetObjectMacro(EventFilter, vtkVgEventFilter);
void AddEventRepresentation(vtkVgEventRepresentationBase* rep);
void RemoveEventRepresentation(vtkVgEventRepresentationBase* rep);
protected:
vtkVgCompositeEventRepresentation();
virtual ~vtkVgCompositeEventRepresentation();
typedef vtkSmartPointer<vtkPropCollection> vtkPropCollectionRef;
vtkPropCollectionRef NewPropCollection;
vtkPropCollectionRef ActivePropCollection;
vtkPropCollectionRef ExpirePropCollection;
int Visible;
class vtkInternal;
vtkInternal* Internal;
private:
vtkVgCompositeEventRepresentation(const vtkVgCompositeEventRepresentation&);
void operator=(const vtkVgCompositeEventRepresentation&);
};
#endif // __vtkVgCompositeEventRepresentation_h
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE190_Integer_Overflow__int64_t_max_preinc_18.c
Label Definition File: CWE190_Integer_Overflow.label.xml
Template File: sources-sinks-18.tmpl.c
*/
/*
* @description
* CWE: 190 Integer Overflow
* BadSource: max Set data to the max value for int64_t
* GoodSource: Set data to a small, non-zero number (two)
* Sinks: increment
* GoodSink: Ensure there will not be an overflow before incrementing data
* BadSink : Increment data, which can cause an overflow
* Flow Variant: 18 Control flow: goto statements
*
* */
#include "std_testcase.h"
#ifndef OMITBAD
void CWE190_Integer_Overflow__int64_t_max_preinc_18_bad()
{
int64_t data;
data = 0LL;
goto source;
source:
/* POTENTIAL FLAW: Use the maximum size of the data type */
data = LLONG_MAX;
goto sink;
sink:
{
/* POTENTIAL FLAW: Incrementing data could cause an overflow */
++data;
int64_t result = data;
printLongLongLine(result);
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodB2G() - use badsource and goodsink by reversing the blocks on the second goto statement */
static void goodB2G()
{
int64_t data;
data = 0LL;
goto source;
source:
/* POTENTIAL FLAW: Use the maximum size of the data type */
data = LLONG_MAX;
goto sink;
sink:
/* FIX: Add a check to prevent an overflow from occurring */
if (data < LLONG_MAX)
{
++data;
int64_t result = data;
printLongLongLine(result);
}
else
{
printLine("data value is too large to perform arithmetic safely.");
}
}
/* goodG2B() - use goodsource and badsink by reversing the blocks on the first goto statement */
static void goodG2B()
{
int64_t data;
data = 0LL;
goto source;
source:
/* FIX: Use a small, non-zero value that will not cause an overflow in the sinks */
data = 2;
goto sink;
sink:
{
/* POTENTIAL FLAW: Incrementing data could cause an overflow */
++data;
int64_t result = data;
printLongLongLine(result);
}
}
void CWE190_Integer_Overflow__int64_t_max_preinc_18_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()...");
CWE190_Integer_Overflow__int64_t_max_preinc_18_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE190_Integer_Overflow__int64_t_max_preinc_18_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
/**
* Copyright (c) 2015-present, 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.
*/
#import "ABI7_0_0RCTBridge.h"
#import "ABI7_0_0RCTURLRequestHandler.h"
@class ALAssetsLibrary;
@interface ABI7_0_0RCTAssetsLibraryRequestHandler : NSObject <ABI7_0_0RCTURLRequestHandler>
@end
@interface ABI7_0_0RCTBridge (ABI7_0_0RCTAssetsLibraryImageLoader)
/**
* The shared asset library instance.
*/
@property (nonatomic, readonly) ALAssetsLibrary *assetsLibrary;
@end
|
// Copyright 2017 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 ASH_SYSTEM_POWER_SCOPED_BACKLIGHTS_FORCED_OFF_H_
#define ASH_SYSTEM_POWER_SCOPED_BACKLIGHTS_FORCED_OFF_H_
#include "ash/ash_export.h"
#include "base/callback.h"
#include "base/macros.h"
namespace ash {
// RAII-style class used to force the backlights off.
// Returned by BacklightsForcedOffSetter::ForceBacklightsOff.
class ASH_EXPORT ScopedBacklightsForcedOff {
public:
explicit ScopedBacklightsForcedOff(base::OnceClosure unregister_callback);
ScopedBacklightsForcedOff(const ScopedBacklightsForcedOff&) = delete;
ScopedBacklightsForcedOff& operator=(const ScopedBacklightsForcedOff&) =
delete;
~ScopedBacklightsForcedOff();
private:
// Callback that should be called in order for |this| to unregister backlights
// forced off request.
base::OnceClosure unregister_callback_;
};
} // namespace ash
#endif // ASH_SYSTEM_POWER_SCOPED_BACKLIGHTS_FORCED_OFF_H_
|
//
// Copyright (c) 2014 The ANGLE 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.
//
// CompilerD3D.h: Defines the rx::CompilerD3D class, an implementation of rx::CompilerImpl.
#ifndef LIBANGLE_RENDERER_COMPILERD3D_H_
#define LIBANGLE_RENDERER_COMPILERD3D_H_
#include "libANGLE/renderer/CompilerImpl.h"
#include "libANGLE/renderer/d3d/RendererD3D.h"
namespace rx
{
class CompilerD3D : public CompilerImpl
{
public:
CompilerD3D(ShShaderOutput translatorOutputType);
~CompilerD3D() override {}
gl::Error release() override { return gl::NoError(); }
ShShaderOutput getTranslatorOutputType() const override { return mTranslatorOutputType; }
private:
ShShaderOutput mTranslatorOutputType;
};
}
#endif // LIBANGLE_RENDERER_COMPILERD3D_H_
|
/*
* Copyright (c) 2004 Marcel Moolenaar
* 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 ``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 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$
*/
#ifndef _KGDB_H_
#define _KGDB_H_
struct thread_info;
extern kvm_t *kvm;
struct kthr {
struct kthr *next;
uintptr_t paddr;
uintptr_t kaddr;
uintptr_t kstack;
uintptr_t pcb;
int tid;
int pid;
u_char cpu;
};
extern struct kthr *curkthr;
void initialize_kld_target(void);
void initialize_kgdb_target(void);
void kgdb_dmesg(void);
CORE_ADDR kgdb_trgt_core_pcb(u_int);
CORE_ADDR kgdb_trgt_stop_pcb(u_int, u_int);
void kgdb_trgt_new_objfile(struct objfile *);
void kgdb_trgt_fetch_registers(int);
void kgdb_trgt_store_registers(int);
void kld_init(void);
void kld_new_objfile(struct objfile *);
frame_unwind_sniffer_ftype kgdb_trgt_trapframe_sniffer;
struct kthr *kgdb_thr_first(void);
struct kthr *kgdb_thr_init(void);
struct kthr *kgdb_thr_lookup_tid(int);
struct kthr *kgdb_thr_lookup_pid(int);
struct kthr *kgdb_thr_lookup_paddr(uintptr_t);
struct kthr *kgdb_thr_lookup_taddr(uintptr_t);
struct kthr *kgdb_thr_next(struct kthr *);
struct kthr *kgdb_thr_select(struct kthr *);
char *kgdb_thr_extra_thread_info(int);
CORE_ADDR kgdb_lookup(const char *sym);
CORE_ADDR kgdb_parse_1(const char *, int);
#define kgdb_parse(exp) kgdb_parse_1((exp), 0)
#define kgdb_parse_quiet(exp) kgdb_parse_1((exp), 1)
#endif /* _KGDB_H_ */
|
namespace CGAL {
/*!
\ingroup PkgMesh2Functions
Refines the constrained Delaunay triangulation `t` into a
conforming Delaunay triangulation. After a call to this function,
all edges of `t` are Delaunay edges.
\tparam CDT must be a 2D constrained Delaunay triangulation
and its geometric traits class must be a model of `ConformingDelaunayTriangulationTraits_2`.
*/
template<class CDT> void make_conforming_Delaunay_2 (CDT &t);
} /* namespace CGAL */
namespace CGAL {
/*!
\ingroup PkgMesh2Functions
Refines the constrained Delaunay triangulation `t` into a
conforming Gabriel triangulation. After a call to this function, all
constrained edges of `t` have the <I>Gabriel property</I>: the
circle that has \f$ e\f$ as diameter does not contain any vertex from
the triangulation.
\tparam CDT must be a 2D constrained Delaunay triangulation
and its geometric traits class must be a model of `ConformingDelaunayTriangulationTraits_2`.
*/
template<class CDT> void make_conforming_Gabriel_2 (CDT &t);
} /* namespace CGAL */
namespace CGAL {
/*!
\ingroup PkgMesh2
The class `Triangulation_conformer_2` is an auxiliary class of
`Delaunay_mesher_2<CDT>`. It permits to refine a constrained
Delaunay triangulation into a conforming Delaunay or conforming
Gabriel triangulation. For standard needs, consider using the global
functions `make_conforming_Gabriel_2()` and
`make_conforming_Delaunay_2()`.
\tparam CDT must be a 2D constrained Delaunay triangulation
and its geometric traits class must be
a model of the concept `ConformingDelaunayTriangulationTraits_2`.
\cgalHeading{Using This Class}
The constructor of the class `Triangulation_conformer_2` takes a reference to a `CDT`
as an argument. A call to the method `make_conforming_Delaunay()` or
`make_conforming_Gabriel()` will refine this constrained Delaunay
triangulation into a conforming Delaunay or conforming Gabriel
triangulation. Note that if, during the life time of the `Triangulation_conformer_2` object, the triangulation is externally modified, any further call to its
member methods may lead to undefined behavior. Consider reconstructing a
new `Triangulation_conformer_2` object if the triangulation has been modified.
The conforming methods insert points into constrained edges, thereby splitting
them into several sub-constraints. You have access to the initial inserted
constraints if you instantiate the template parameter by a
`Constrained_triangulation_plus_2<CDT>`.
*/
template< typename CDT >
class Triangulation_conformer_2 {
public:
/// \name Creation
/// @{
/*!
Create a new conforming maker, working on `t`.
*/
Triangulation_conformer_2(CDT& t);
/// @}
/// \name Conforming methods
/// @{
/*!
Refines the triangulation into a conforming Delaunay triangulation.
After a call to this method, all triangles fulfill the Delaunay property,
that is the empty circle
property.
*/
void make_conforming_Delaunay();
/*!
Refines the triangulation into a conforming Gabriel triangulation.
After a call to this method, all constrained edges \f$ e\f$ have the
<I>Gabriel property</I>: the circle with diameter \f$ e\f$
does not contain any vertex of the triangulation.
*/
void make_conforming_Gabriel();
/// @}
/*!
\name Checking
The following methods verify that the constrained triangulation is
conforming Delaunay or conforming Gabriel. These methods scan the
whole triangulation and their complexity is proportional to the number
of edges.
*/
/// @{
/*!
Returns `true` iff all triangles fulfill the Delaunay property.
*/
bool is_conforming_Delaunay();
/*!
Returns `true` iff all constrained edges have the Gabriel property:
their circumsphere is empty.
*/
bool is_conforming_Gabriel();
/// @}
/*!
\name Step by Step Operations
The `Triangulation_conformer_2` class allows, for debugging or demos, to play the
conforming algorithm step by step, using the following methods. They exist
in two versions, depending on whether you want the triangulation to be
conforming Delaunay or conforming Gabriel, respectively. Any call to a
`step_by_step_conforming_XX` function requires a previous call to the
corresponding function `init_XX` and Gabriel and Delaunay methods can
not be mixed between two calls of `init_XX`.
*/
/// @{
/*!
The method must be called after all points and constrained segments
are inserted and before any call to the following methods. If some
points or segments are then inserted in the triangulation, this
method must be called again.
*/
void init_Delaunay();
/*!
Applies one step of the algorithm, by inserting one point, if the
algorithm is not done. Returns `false` iff no point has been inserted
because the algorithm is done.
*/
bool step_by_step_conforming_Delaunay ();
/*!
Analog to
`init_Delaunay` for Gabriel conforming.
*/
void init_Gabriel();
/*!
Analog to
`step_by_step_conforming_Delaunay()` for Gabriel conforming.
*/
bool step_by_step_conforming_Gabriel ();
/*!
Tests if the step by step conforming algorithm is done. If it
returns `true`, the following calls to
`step_by_step_conforming_XX` will not insert any points, until some
new constrained segments or points are inserted in the triangulation and
`init_XX` is called again.
*/
bool is_conforming_done();
/// @}
}; /* end Triangulation_conformer_2 */
} /* end namespace CGAL */
|
#include <cassert>
#include <cmath>
#include <omp.h>
#define INTEGER_MAX 3000000
#include "../util.h"
using namespace std;
typedef struct {
int nWords;
int nVocs;
int nDocs;
vector< pair<int,int> >* doc_lookup;
vector< pair<int,int> >* word_lookup;
vector< vector<int> >* voc_lookup;
} Lookups ;
void get_doc_lookup (vector< Instance* > & data, vector<pair<int,int> >& doc_lookup) {
// validate the input
doc_lookup.clear();
int N = data.size();
for (int i = 1; i < N; i ++)
assert(data[i-1]->label <= data[i]->label);
// compute list of document info
int doc_begin = 0;
int doc_end = 0;
int last_doc = data[0]->label;
for (int i = 0; i < N ; i++) {
int curr_doc = data[i]->label;
if (curr_doc != last_doc) {
doc_end = i;
//cerr << "(" << doc_begin << ", " << doc_end << ")" <<endl;
doc_lookup.push_back(make_pair(doc_begin, doc_end));
doc_begin = i;
last_doc = curr_doc;
}
}
// cerr << "(" << doc_begin << ", " << doc_end << ")" <<endl;
doc_lookup.push_back(make_pair(doc_begin, N));
}
|
#ifndef MTF_PARALLEL_PARAMS_H
#define MTF_PARALLEL_PARAMS_H
#include "mtf/Macros/common.h"
#define PARL_ESTIMATION_METHOD 0
#define PARL_RESET_TO_MEAN 0
#define PARL_AUTO_REINIT 0
#define PARL_REINIT_ERR_THRESH 1
#define PRL_SM_REINIT_FRAME_GAP 1
_MTF_BEGIN_NAMESPACE
struct ParallelParams {
enum class PrlEstMethod {
MeanOfCorners,
MeanOfState
};
PrlEstMethod estimation_method;
bool reset_to_mean;
bool auto_reinit;
double reinit_err_thresh;
int reinit_frame_gap;
static const char* toString(PrlEstMethod _estimation_method);
ParallelParams(PrlEstMethod _estimation_method, bool _reset_to_mean,
bool _auto_reinit, double _reinit_err_thresh, int _reinit_frame_gap);
ParallelParams(const ParallelParams *params = nullptr);
};
_MTF_END_NAMESPACE
#endif
|
#ifndef _RAM_H
#define _RAM_H
#include <stdio.h>
#include <stdlib.h>
#define BYTES_OF_MEMORY 4096
typedef struct
{
unsigned char data; // The data of the memory unit
unsigned char deletedFlag; // If 1 is deleted. If 0 not deleted
}MemUnit;
typedef struct
{
MemUnit RAMArray[BYTES_OF_MEMORY];
}RAM;
/**
* Inserts a byte of data into memory at a specific address
* @param ram A pointer to RAM
* @param address The address to store the data
* @param data The data to store in RAM
* @return Returns 1 if successful and 0 otherwise
*/
int insertIntoRAMAtAddress(RAM* ram, int address, char data);
/**
* Retrieves a byte out of RAM (This copies the value)
* @param ram A pointer to RAM
* @param address The address to get the value from
* @return Returns the value at the specified address
*/
char retrieveFromIntoRAMAddress(RAM* ram, int address);
/**
* Inserts a word of data into memory (Note stores in some endian depending on machine)
* @param ram A pointer to ram
* @param address The address to start writing at
* @param data The data to write to memory
* @return Returns 1 if successful and 0 otherwise
*/
int insertWordAtAddress(RAM* ram, int address, int data);
/**
* Retrieves a word from memory (This copies the value)
* @param ram A pointer to RAM
* @param address The address to get the value from
* @return Returns the word at the specified address
*/
int retrieveWordFromAddress(RAM* ram, int address);
#endif
|
//
// OCHamcrest - NeverMatch.h
// Copyright 2011 hamcrest.org. See LICENSE.txt
//
// Created by: Jon Reid
//
// Inherited
#import <OCHamcrest/HCBaseMatcher.h>
@interface NeverMatch : HCBaseMatcher
+ (id)neverMatch;
+ (NSString *)mismatchDescription;
- (BOOL)matches:(id)item;
- (void)describeMismatchOf:(id)item to:(id<HCDescription>)mismatchDescription;
@end
|
// Copyright (c) 2013, Tencent Inc.
// All rights reserved.
//
// Author: <guofutan@tencent.com>
// Created: 2013-07-01
// Description:
#ifndef _MIO_TCP_SERVER_H
#define _MIO_TCP_SERVER_H
#include <string>
#include <vector>
#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <vector>
#include <list>
#define DEFAULT_TIMEOUT_MS 10000
#define DEFAULT_MAX_CONNECT 10000
#define DEFAULT_MAX_THREAD 3
#include "tcpbuffer.h"
#include "accepter.h"
#include "connection.h"
namespace mio {
class Epoller;
class TcpServer {
public:
///
/// \brief TcpServer
/// \param host
/// \param port
/// \param name
/// \param timeoutms
/// \param connectnum
/// \param threadnum
///
TcpServer(std::string host,
int port,
int timeoutms = DEFAULT_TIMEOUT_MS,
int threadnum = DEFAULT_MAX_THREAD,
int connectnum = DEFAULT_MAX_CONNECT);
///
~TcpServer();
///
/// \brief setTimeOutMs
/// \param timeoutms
/// \return
///
int setTimeOutMs(int timeoutms);
///
/// \brief setConnectCallback
/// \param fun
/// \return
///
int setConnectCallback(boost::function<int(Connection*,bool)> fun);
///
/// \brief setReadCallback
/// \param fun
/// \return
///
int setReadCallback(boost::function<int(Connection*,Buffer&)> fun);
///
/// \brief setWriteCallback
/// \param fun
/// \return
///
int setWriteCallback(boost::function<int(Connection*,int)> fun);
///
/// \brief start
/// \return
///
int start();
///
/// \brief stop
/// \return
///
int stop();
///
/// \brief join
/// \return
///
int join();
public:
///
/// \brief setAcceptConnect
/// \param con
/// \return
///
int setAcceptConnect(Connection* con);
///
/// \brief nextEpoller
/// \return
///
Epoller* nextEpoller();
///
/// \brief reuseConnect
/// \param sockfd
/// \return
///
Connection* reuseConnect(int sockfd);
private:
std::string _host;
int _port;
int _timeoutms;
std::vector<Connection*> _conns;
std::vector<Epoller*> _pollers;
volatile unsigned int _current_poller_idx;
Accpeter accpter;
boost::function<int(Connection*,bool)> _connectCallback;
boost::function<int(Connection*,Buffer&)> _readCallback;
boost::function<int(Connection*,int)> _writeCallback;
};
}
#endif
|
/* $NetBSD: sa11x0_ppcreg.h,v 1.2 2001/07/30 12:19:04 rjs Exp $ */
/*-
* Copyright (c) 2001, The NetBSD Foundation, Inc. All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by IWAMOTO Toshihiro.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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.
*
*/
/* SA11[01]0 PPC (peripheral pin controller) */
/* size of I/O space */
#define SAPPC_NPORTS 13
#define SAPPC_PDR 0x00 /* pin direction register */
#define SAPPC_PSR 0x04 /* pin state register */
#define SAPPC_PAR 0x08 /* pin assignment register */
#define PAR_UPR 0x01000 /* UART pin assignment */
#define PAR_SPR 0x40000 /* SSP pin assignment */
#define SAPPC_SDR 0x0C /* sleep mode direction register */
#define SAPPC_PFR 0x10 /* pin flag register */
#define PFR_LCD 0x00001 /* LCD controller flag */
#define PFR_SP1TX 0x01000 /* serial port 1 Tx flag */
#define PFR_SP1RX 0x02000 /* serial port 1 Rx flag */
#define PFR_SP2TX 0x04000 /* serial port 2 Tx flag */
#define PFR_SP2RX 0x08000 /* serial port 2 Rx flag */
#define PFR_SP3TX 0x10000 /* serial port 3 Tx flag */
#define PFR_SP3RX 0x20000 /* serial port 3 Rx flag */
#define PFR_SP4 0x40000 /* serial port 4 flag */
/* MCP control register 1 */
#define SAMCP_CR1 0x30 /* MCP control register 1 */
|
/* dptt02.f -- translated by f2c (version 20061008).
You must link the resulting object file with libf2c:
on Microsoft Windows system, link with libf2c.lib;
on Linux or Unix systems, link with .../path/to/libf2c.a -lm
or, if you install libf2c.a in a standard place, with -lf2c -lm
-- in that order, at the end of the command line, as in
cc *.o -lf2c -lm
Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
http://www.netlib.org/f2c/libf2c.zip
*/
#include "f2c.h"
#include "blaswrap.h"
/* Table of constant values */
static doublereal c_b4 = -1.;
static doublereal c_b5 = 1.;
static integer c__1 = 1;
/* Subroutine */ int dptt02_(integer *n, integer *nrhs, doublereal *d__,
doublereal *e, doublereal *x, integer *ldx, doublereal *b, integer *
ldb, doublereal *resid)
{
/* System generated locals */
integer b_dim1, b_offset, x_dim1, x_offset, i__1;
doublereal d__1, d__2;
/* Local variables */
integer j;
doublereal eps;
doublereal anorm, bnorm, xnorm;
/* -- LAPACK test routine (version 3.1) -- */
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
/* November 2006 */
/* .. Scalar Arguments .. */
/* .. */
/* .. Array Arguments .. */
/* .. */
/* Purpose */
/* ======= */
/* DPTT02 computes the residual for the solution to a symmetric */
/* tridiagonal system of equations: */
/* RESID = norm(B - A*X) / (norm(A) * norm(X) * EPS), */
/* where EPS is the machine epsilon. */
/* Arguments */
/* ========= */
/* N (input) INTEGTER */
/* The order of the matrix A. */
/* NRHS (input) INTEGER */
/* The number of right hand sides, i.e., the number of columns */
/* of the matrices B and X. NRHS >= 0. */
/* D (input) DOUBLE PRECISION array, dimension (N) */
/* The n diagonal elements of the tridiagonal matrix A. */
/* E (input) DOUBLE PRECISION array, dimension (N-1) */
/* The (n-1) subdiagonal elements of the tridiagonal matrix A. */
/* X (input) DOUBLE PRECISION array, dimension (LDX,NRHS) */
/* The n by nrhs matrix of solution vectors X. */
/* LDX (input) INTEGER */
/* The leading dimension of the array X. LDX >= max(1,N). */
/* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
/* On entry, the n by nrhs matrix of right hand side vectors B. */
/* On exit, B is overwritten with the difference B - A*X. */
/* LDB (input) INTEGER */
/* The leading dimension of the array B. LDB >= max(1,N). */
/* RESID (output) DOUBLE PRECISION */
/* norm(B - A*X) / (norm(A) * norm(X) * EPS) */
/* ===================================================================== */
/* .. Parameters .. */
/* .. */
/* .. Local Scalars .. */
/* .. */
/* .. External Functions .. */
/* .. */
/* .. Intrinsic Functions .. */
/* .. */
/* .. External Subroutines .. */
/* .. */
/* .. Executable Statements .. */
/* Quick return if possible */
/* Parameter adjustments */
--d__;
--e;
x_dim1 = *ldx;
x_offset = 1 + x_dim1;
x -= x_offset;
b_dim1 = *ldb;
b_offset = 1 + b_dim1;
b -= b_offset;
/* Function Body */
if (*n <= 0) {
*resid = 0.;
return 0;
}
/* Compute the 1-norm of the tridiagonal matrix A. */
anorm = dlanst_("1", n, &d__[1], &e[1]);
/* Exit with RESID = 1/EPS if ANORM = 0. */
eps = dlamch_("Epsilon");
if (anorm <= 0.) {
*resid = 1. / eps;
return 0;
}
/* Compute B - A*X. */
dlaptm_(n, nrhs, &c_b4, &d__[1], &e[1], &x[x_offset], ldx, &c_b5, &b[
b_offset], ldb);
/* Compute the maximum over the number of right hand sides of */
/* norm(B - A*X) / ( norm(A) * norm(X) * EPS ). */
*resid = 0.;
i__1 = *nrhs;
for (j = 1; j <= i__1; ++j) {
bnorm = dasum_(n, &b[j * b_dim1 + 1], &c__1);
xnorm = dasum_(n, &x[j * x_dim1 + 1], &c__1);
if (xnorm <= 0.) {
*resid = 1. / eps;
} else {
/* Computing MAX */
d__1 = *resid, d__2 = bnorm / anorm / xnorm / eps;
*resid = max(d__1,d__2);
}
/* L10: */
}
return 0;
/* End of DPTT02 */
} /* dptt02_ */
|
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SRC_IPC_TEST_TEST_SOCKET_H_
#define SRC_IPC_TEST_TEST_SOCKET_H_
#include "perfetto/base/build_config.h"
#if PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID)
#define TEST_SOCK_NAME(x) "@" x
#define DESTROY_TEST_SOCK(x) \
do { \
} while (0)
#else
#include <unistd.h>
#define TEST_SOCK_NAME(x) "/tmp/" x ".sock"
#define DESTROY_TEST_SOCK(x) unlink(x)
#endif
#endif // SRC_IPC_TEST_TEST_SOCKET_H_
|
/* Copyright (c) 2006, NIF File Format Library and Tools
All rights reserved. Please see niflib.h for license. */
//-----------------------------------NOTICE----------------------------------//
// Some of this file is automatically filled in by a Python script. Only //
// add custom code in the designated areas or it will be overwritten during //
// the next update. //
//-----------------------------------NOTICE----------------------------------//
#ifndef _NIMORPHERCONTROLLER_H_
#define _NIMORPHERCONTROLLER_H_
//--BEGIN FILE HEAD CUSTOM CODE--//
//--END CUSTOM CODE--//
#include "NiInterpController.h"
// Include structures
#include "../Ref.h"
namespace Niflib {
// Forward define of referenced NIF objects
class NiMorphData;
class NiMorpherController;
typedef Ref<NiMorpherController> NiMorpherControllerRef;
/*! Unknown! Used by Daoc. */
class NiMorpherController : public NiInterpController {
public:
/*! Constructor */
NIFLIB_API NiMorpherController();
/*! Destructor */
NIFLIB_API virtual ~NiMorpherController();
/*!
* A constant value which uniquly identifies objects of this type.
*/
NIFLIB_API static const Type TYPE;
/*!
* A factory function used during file reading to create an instance of this type of object.
* \return A pointer to a newly allocated instance of this type of object.
*/
NIFLIB_API static NiObject * Create();
/*!
* Summarizes the information contained in this object in English.
* \param[in] verbose Determines whether or not detailed information about large areas of data will be printed out.
* \return A string containing a summary of the information within the object in English. This is the function that Niflyze calls to generate its analysis, so the output is the same.
*/
NIFLIB_API virtual string asString( bool verbose = false ) const;
/*!
* Used to determine the type of a particular instance of this object.
* \return The type constant for the actual type of the object.
*/
NIFLIB_API virtual const Type & GetType() const;
/***Begin Example Naive Implementation****
// This controller's data.
// \return The current value.
Ref<NiMorphData > GetData() const;
// This controller's data.
// \param[in] value The new value.
void SetData( Ref<NiMorphData > value );
****End Example Naive Implementation***/
//--BEGIN MISC CUSTOM CODE--//
//--END CUSTOM CODE--//
protected:
/*! This controller's data. */
Ref<NiMorphData > data;
public:
/*! NIFLIB_HIDDEN function. For internal use only. */
NIFLIB_HIDDEN virtual void Read( istream& in, list<unsigned int> & link_stack, const NifInfo & info );
/*! NIFLIB_HIDDEN function. For internal use only. */
NIFLIB_HIDDEN virtual void Write( ostream& out, const map<NiObjectRef,unsigned int> & link_map, list<NiObject *> & missing_link_stack, const NifInfo & info ) const;
/*! NIFLIB_HIDDEN function. For internal use only. */
NIFLIB_HIDDEN virtual void FixLinks( const map<unsigned int,NiObjectRef> & objects, list<unsigned int> & link_stack, list<NiObjectRef> & missing_link_stack, const NifInfo & info );
/*! NIFLIB_HIDDEN function. For internal use only. */
NIFLIB_HIDDEN virtual list<NiObjectRef> GetRefs() const;
/*! NIFLIB_HIDDEN function. For internal use only. */
NIFLIB_HIDDEN virtual list<NiObject *> GetPtrs() const;
};
//--BEGIN FILE FOOT CUSTOM CODE--//
//--END CUSTOM CODE--//
} //End Niflib namespace
#endif
|
#ifndef _UTILS_H_
#define _UTILS_H_
// collection of common defines/utilities used here and there
#define XPLOIT_OK 0
#define XPLOIT_ERROR -1
#define TRUE 1
#define FALSE 0
#define MAX_NUM_OF_PARAMS 8
#define NOT_SET 0
extern int debugMode();
// bash colors
static const char *txtrst="\e[0m";
static const char *txtred="\e[0;31m";
static const char *txtgrn="\e[0;32m";
static const char *txtblu="\e[0;36m";
// output messages from modules
enum {
LOG_INFO,
LOG_WARN,
LOG_ERROR,
LOG_FATAL,
};
void printMsg(int level, const char * format, ...);
void debugMsg(const char * format, ...);
// asm opcodes library
// function for random filenames
#endif
|
#ifndef SORTS_MERGESORT_H
#define SORTS_MERGESORT_H
void merge(int *l, int *tmp, int left, int center, int right) {
int i = left;
int j = center + 1;
int ptr = left;
while(i <= center && j <= right) {
if(l[i] <= l[j])
tmp[ptr++] = l[i++];
else
tmp[ptr++] = l[j++];
}
while(i <= center) { tmp[ptr++] = l[i++]; } // copy remaining left half
while(j <= right) { tmp[ptr++] = l[j++]; } // copy remaining right half
for(i = left; i <= right; i++) { l[i] = tmp[i]; } // copy temp array back to original
}
void _mergesort(int *l, int *tmp, int left, int right) {
if(right > left) {
int center = left + ((right - left) / 2);
_mergesort(l, tmp, left, center);
_mergesort(l, tmp, center + 1, right);
merge(l, tmp, left, center, right);
}
}
void mergesort(int *l, int left, int right) {
int *tmp = malloc((right - left + 1) * sizeof (int));
_mergesort(l, tmp, left, right);
}
#endif
|
// Copyright © 2018 650 Industries. All rights reserved.
#import <Foundation/Foundation.h>
#import <JavaScriptCore/JavaScriptCore.h>
@protocol ABI39_0_0UMJavaScriptContextProvider <NSObject>
- (JSGlobalContextRef)javaScriptContextRef;
- (void *)javaScriptRuntimePointer;
@end
|
// Copyright (c) 2013, Tencent Inc.
// All rights reserved.
//
// Author: <guofutan@tencent.com>
// Created: 2013-07-01
// Description:
#ifndef BLOCKQUEUE_H
#define BLOCKQUEUE_H
/**
* a block queue by condition and mutex
*/
#define MAX_SIZE 10000
#include <boost/function.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
#include <list>
#include <queue>
#include "rwlock.h"
template <class T>
class BlockQueue{
public:
/**
* @brief BlockQueue init with MAX_SIZE
*/
BlockQueue():
m_current_size(0),m_max_size(MAX_SIZE){
}
/**
* @brief BlockQueue init with max_num
* @param max_num
*/
BlockQueue(int max_num):
m_current_size(0),m_max_size(max_num){
}
/**
* @brief push_back
* @param t
* @return
*/
int push_back(T& t)
{
// check full
boost::unique_lock<boost::mutex> full_lock(m_full_mutex);
while(size() >= MAX_SIZE)
{
m_full_cond.wait(full_lock);
}
// push
{
boost::unique_lock<boost::mutex> list_lock(m_list_mutex);
m_list.push_back(t);
m_current_size++;
}
// notify
m_empty_cond.notify_one();
return 0;
}
/**
* @brief pop_front
* @return
*/
void pop_front(T& t){
// check empty
boost::unique_lock<boost::mutex> empty_lock(m_empty_mutex);
while(size() <= 0 )
{
m_empty_cond.wait(empty_lock);
}
//pop
boost::unique_lock<boost::mutex> list_lock(m_list_mutex);
t = m_list.front();
m_list.pop_front();
m_current_size--;
// notify
m_full_cond.notify_one();
}
/**
* @brief size move is atmoic operatrion
* @return
*/
inline int size(){
return m_current_size;
}
/**
* @brief empty
* @return
*/
inline bool empty(){
boost::unique_lock<boost::mutex> list_lock(m_list_mutex);
return m_current_size == 0;
}
public:
boost::mutex m_list_mutex;
boost::mutex m_empty_mutex;
boost::condition_variable m_empty_cond;
boost::mutex m_full_mutex;
boost::condition_variable m_full_cond;
std::list<T> m_list;
volatile int m_current_size;
int m_max_size;
};
template<class T>
class LockQueue{
public:
LockQueue():_size(0){
}
int push(T& t){
WriteLock<RWLock> wl(mutex);
queue.push(t);
++_size;
return 0;
}
int pop(T& t){
WriteLock<RWLock> wl(mutex);
if(queue.empty())
return -1;
t = queue.front();
queue.pop();
--_size;
return 0;
}
bool empty(){
ReadLock<RWLock> rl(mutex);
return queue.empty();
}
unsigned int size(){
ReadLock<RWLock> rl(mutex);
return _size;
}
public:
RWLock mutex;
std::queue<T> queue;
volatile unsigned int _size;
};
#endif // BLOCKQUEUE_H
|
// Copyright (c) 2014, Primiano Tucci (www.primianotucci.com)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of 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 USB_CONFIG_H
#define USB_CONFIG_H
#define USB_EP0_BUFF_SIZE 8 // Valid Options: 8, 16, 32, or 64 bytes.
// Using larger options take more SRAM, but
// does not provide much advantage in most types
// of applications. Exceptions to this, are applications
// that use EP0 IN or OUT for sending large amounts of
// application related data.
#define USB_MAX_NUM_INT 1 // For tracking Alternate Setting
#define USB_MAX_EP_NUMBER 1
//#define USB_PING_PONG_MODE USB_PING_PONG__NO_PING_PONG
#define USB_PING_PONG_MODE USB_PING_PONG__FULL_PING_PONG
//#define USB_PING_PONG_MODE USB_PING_PONG__EP0_OUT_ONLY
//#define USB_PING_PONG_MODE USB_PING_PONG__ALL_BUT_EP0 //NOTE: This
// mode is not supported in PIC18F4550 family rev A3 devices
#define USB_POLLING
//#define USB_INTERRUPT
#define USB_PULLUP_OPTION USB_PULLUP_ENABLE
//#define USB_PULLUP_OPTION USB_PULLUP_DISABLED
#define USB_TRANSCEIVER_OPTION USB_INTERNAL_TRANSCEIVER
//#define USB_SPEED_OPTION USB_FULL_SPEED
#define USB_SPEED_OPTION USB_LOW_SPEED //(not valid option for PIC24F devices)
#define MY_VID 0x04D8
#define MY_PID 0x0055
// Option to enable auto-arming of the status stage of control transfers, if no
//"progress" has been made for the USB_STATUS_STAGE_TIMEOUT value.
// If progress is made (any successful transactions completing on EP0 IN or OUT)
// the timeout counter gets reset to the USB_STATUS_STAGE_TIMEOUT value.
//
// During normal control transfer processing, the USB stack or the application
// firmware will call USBCtrlEPAllowStatusStage() as soon as the firmware is
// finished
// processing the control transfer. Therefore, the status stage completes as
// quickly as is physically possible. The USB_ENABLE_STATUS_STAGE_TIMEOUTS
// feature, and the USB_STATUS_STAGE_TIMEOUT value are only relevant, when:
// 1. The application uses the USBDeferStatusStage() API function, but never
// calls USBCtrlEPAllowStatusStage(). Or:
// 2. The application uses host to device (OUT) control transfers with data
// stage, and some abnormal error occurs, where the host might try to abort the
// control transfer, before it has sent all of the data it claimed it was going
// to send.
//
// If the application firmware never uses the USBDeferStatusStage() API
// function,
// and it never uses host to device control transfers with data stage, then
// it is not required to enable the USB_ENABLE_STATUS_STAGE_TIMEOUTS feature.
//#define USB_ENABLE_STATUS_STAGE_TIMEOUTS // Comment this out to disable this
// feature.
// Section 9.2.6 of the USB 2.0 specifications indicate that:
// 1. Control transfers with no data stage: Status stage must complete within
// 50ms of the start of the control transfer.
// 2. Control transfers with (IN) data stage: Status stage must complete within
// 50ms of sending the last IN data packet in fullfilment of the data
// stage.
// 3. Control transfers with (OUT) data stage: No specific status stage timing
// requirement. However, the total time of the entire control transfer
// (ex:
// including the OUT data stage and IN status stage) must not exceed 5
// seconds.
//
// Therefore, if the USB_ENABLE_STATUS_STAGE_TIMEOUTS feature is used, it is
// suggested
// to set the USB_STATUS_STAGE_TIMEOUT value to timeout in less than 50ms. If
// the
// USB_ENABLE_STATUS_STAGE_TIMEOUTS feature is not enabled, then the
// USB_STATUS_STAGE_TIMEOUT
// parameter is not relevant.
// Approximate timeout in milliseconds, except when
// USB_POLLING mode is used, and USBDeviceTasks() is called at < 1kHz
// In this special case, the timeout becomes approximately:
// Timeout(in milliseconds) = ((1000 * (USB_STATUS_STAGE_TIMEOUT - 1)) /
// (USBDeviceTasks() polling frequency in Hz))
#define USB_STATUS_STAGE_TIMEOUT (BYTE)45
#define USB_SUPPORT_DEVICE
#define USB_NUM_STRING_DESCRIPTORS 3
#define USB_USE_HID
#define HID_INTF_ID 0x00
#define HID_EP 1
#define HID_INT_OUT_EP_SIZE 1
#define HID_INT_IN_EP_SIZE 8
#define HID_NUM_OF_DSC 1
#define HID_RPT01_SIZE 63
#define USER_SET_REPORT_HANDLER USBHIDCBSetReportHandler
#endif // USB_CONFIG_H
|
/*
* Copyright (c) 2005, Peter Sommerlad and IFS Institute for Software at HSR Rapperswil, Switzerland
* All rights reserved.
*
* This library/application is free software; you can redistribute and/or modify it under the terms of
* the license that is included with this library/application in the file license.txt.
*/
#ifndef _DateTime_H
#define _DateTime_H
//---- include -------------------------------------------------
#include "Anything.h"
//---- DateTime ----------------------------------------------------------
//! wrapper class for date and time functions
/*!
*/
class DateTime
{
public:
//--- public api
/*! wrapper function for gettimeofday
\param anyTime structure to hold returned values
\param bLocalTime if set to false, UTC(GMT) time will be returned
<b>returned elements:</b>
<pre>{
/sec long seconds since 1.1.1970
/usec long microseconds of current second
/tzone_sec long timezone specific difference to above values in seconds
/sec_since_midnight long seconds since midnight
/msec_since_midnight long milliseconds since midnight
}</pre> */
static void GetTimeOfDay(Anything &anyTime, bool bLocalTime = true);
/*! wrapper function for getting timezone difference in seconds
\return difference in seconds */
static long GetTimezone();
private:
//--- constructors
DateTime();
~DateTime();
};
#endif
|
#ifndef __EASYODE_H__
#define __EASYODE_H__
#include "World.h"
#include "Simulator.h"
#include "Sphere.h"
#include "Box.h"
#include "Capsule.h"
#include "HingeJoint.h"
#include "FixedJoint.h"
#endif /* __EASYODE_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 CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_DIALOG_H_
#define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_DIALOG_H_
#include <memory>
#include <string>
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/scoped_observation.h"
#include "build/chromeos_buildflags.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_host_observer.h"
#include "extensions/browser/process_manager.h"
#include "extensions/browser/process_manager_observer.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/window/dialog_delegate.h"
class ExtensionDialogObserver;
class ExtensionViewViews;
class GURL;
class Profile;
namespace content {
class WebContents;
}
namespace extensions {
class ExtensionViewHost;
}
// Modal dialog containing contents provided by an extension.
// Dialog is automatically centered in the owning window and has fixed size.
// For example, used by the Chrome OS file browser.
class ExtensionDialog : public views::DialogDelegate,
public extensions::ExtensionHostObserver,
public extensions::ProcessManagerObserver,
public base::RefCounted<ExtensionDialog> {
public:
struct InitParams {
// |size| Size in DIP (Device Independent Pixel) for the dialog window.
explicit InitParams(gfx::Size size);
InitParams(const InitParams& other);
~InitParams();
// |is_modal| determines whether the dialog is modal to |parent_window|.
bool is_modal = false;
// Size in DIP (Device Independent Pixel) for the dialog window.
gfx::Size size;
// Minimum size in DIP (Device Independent Pixel) for the dialog window.
gfx::Size min_size;
// Text for the dialog title, it should be already localized.
std::u16string title;
#if BUILDFLAG(IS_CHROMEOS_ASH)
// |title_color| customizes the color of the window title.
absl::optional<SkColor> title_color;
// |title_inactive_color| customizes the color of the window title when
// window is inactive.
absl::optional<SkColor> title_inactive_color;
#endif
};
ExtensionDialog(const ExtensionDialog&) = delete;
ExtensionDialog& operator=(const ExtensionDialog&) = delete;
// Create and show a dialog with |url| centered over the provided window.
// |parent_window| is the parent window to which the pop-up will be attached.
// |profile| is the profile that the extension is registered with.
// |web_contents| is the tab that spawned the dialog.
static ExtensionDialog* Show(const GURL& url,
gfx::NativeWindow parent_window,
Profile* profile,
content::WebContents* web_contents,
ExtensionDialogObserver* observer,
const InitParams& init_params);
// Notifies the dialog that the observer has been destroyed and should not
// be sent notifications.
void ObserverDestroyed();
// Focus to the renderer if possible.
void MaybeFocusRenderer();
// Sets minimum contents size in pixels and makes the window resizable.
void SetMinimumContentsSize(int width, int height);
extensions::ExtensionViewHost* host() const { return host_.get(); }
// extensions::ExtensionHostObserver:
void OnExtensionHostDidStopFirstLoad(
const extensions::ExtensionHost* host) override;
void OnExtensionHostShouldClose(extensions::ExtensionHost* host) override;
// extensions::ProcessManagerObserver:
void OnExtensionProcessTerminated(
const extensions::Extension* extension) override;
void OnProcessManagerShutdown(extensions::ProcessManager* manager) override;
protected:
~ExtensionDialog() override;
private:
friend class base::RefCounted<ExtensionDialog>;
// Use Show() to create instances.
ExtensionDialog(std::unique_ptr<extensions::ExtensionViewHost> host,
ExtensionDialogObserver* observer,
gfx::NativeWindow parent_window,
const InitParams& init_params);
void OnWindowClosing();
// Window Title
std::u16string window_title_;
// The contained host for the view.
std::unique_ptr<extensions::ExtensionViewHost> host_;
ExtensionViewViews* extension_view_ = nullptr;
base::ScopedObservation<extensions::ExtensionHost,
extensions::ExtensionHostObserver>
extension_host_observation_{this};
base::ScopedObservation<extensions::ProcessManager,
extensions::ProcessManagerObserver>
process_manager_observation_{this};
// The observer of this popup.
ExtensionDialogObserver* observer_;
};
#endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_DIALOG_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 COMPONENTS_CRASH_CORE_APP_CLIENT_UPLOAD_INFO_H_
#define COMPONENTS_CRASH_CORE_APP_CLIENT_UPLOAD_INFO_H_
#include <string>
#include "build/build_config.h"
namespace crash_reporter {
// Returns whether the user has consented to collecting stats.
bool GetClientCollectStatsConsent();
#if defined(OS_POSIX) && !defined(OS_MACOSX)
// Returns a textual description of the product type, version and channel
// to include in crash reports.
// TODO(https://crbug.com/986178): Implement this for other platforms.
void GetClientProductNameAndVersion(std::string* product,
std::string* version,
std::string* channel);
#endif
} // namespace crash_reporter
#endif // COMPONENTS_CRASH_CORE_APP_CLIENT_UPLOAD_INFO_H_
|
/*-
* Copyright (c) 2003-2009 RMI 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:
* 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 RMI 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 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.
*
* RMI_BSD */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/9.3/sys/mips/rmi/dev/iic/ds1374u.c 216410 2010-12-13 17:53:38Z jchandra $");
/*
* RTC chip sitting on the I2C bus.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/bus.h>
#include <sys/clock.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/rman.h>
#include <mips/include/bus.h>
#include <mips/include/cpu.h>
#include <mips/include/cpufunc.h>
#include <mips/include/frame.h>
#include <mips/include/resource.h>
#include <dev/iicbus/iiconf.h>
#include <dev/iicbus/iicbus.h>
#include "iicbus_if.h"
#include "clock_if.h"
#define DS1374_RTC_COUNTER 0 /* counter (bytes 0-3) */
struct ds1374u_softc {
uint32_t sc_addr;
device_t sc_dev;
};
static int
ds1374u_probe(device_t dev)
{
device_set_desc(dev, "DS1374U-33 RTC");
return (0);
}
static int
ds1374u_attach(device_t dev)
{
struct ds1374u_softc *sc = device_get_softc(dev);
if(sc==NULL) {
printf("ds1374u_attach device_get_softc failed\n");
return (0);
}
sc->sc_dev = dev;
sc->sc_addr = iicbus_get_addr(dev);
clock_register(dev, 1000);
return (0);
}
static int
ds1374u_settime(device_t dev, struct timespec *ts)
{
/* NB: register pointer precedes actual data */
uint8_t data[5] = { DS1374_RTC_COUNTER };
struct ds1374u_softc *sc = device_get_softc(dev);
struct iic_msg msgs[1] = {
{ sc->sc_addr, IIC_M_WR, 5, data },
};
data[1] = (ts->tv_sec >> 0) & 0xff;
data[2] = (ts->tv_sec >> 8) & 0xff;
data[3] = (ts->tv_sec >> 16) & 0xff;
data[4] = (ts->tv_sec >> 24) & 0xff;
return iicbus_transfer(dev, msgs, 1);
}
static int
ds1374u_gettime(device_t dev, struct timespec *ts)
{
struct ds1374u_softc *sc = device_get_softc(dev);
uint8_t addr[1] = { DS1374_RTC_COUNTER };
uint8_t secs[4];
struct iic_msg msgs[2] = {
{ sc->sc_addr, IIC_M_WR, 1, addr },
{ sc->sc_addr, IIC_M_RD, 4, secs },
};
int error;
error = iicbus_transfer(dev, msgs, 2);
if (error == 0) {
/* counter has seconds since epoch */
ts->tv_sec = (secs[3] << 24) | (secs[2] << 16)
| (secs[1] << 8) | (secs[0] << 0);
ts->tv_nsec = 0;
}
return error;
}
static device_method_t ds1374u_methods[] = {
DEVMETHOD(device_probe, ds1374u_probe),
DEVMETHOD(device_attach, ds1374u_attach),
DEVMETHOD(clock_gettime, ds1374u_gettime),
DEVMETHOD(clock_settime, ds1374u_settime),
{0, 0},
};
static driver_t ds1374u_driver = {
"ds1374u",
ds1374u_methods,
sizeof(struct ds1374u_softc),
};
static devclass_t ds1374u_devclass;
DRIVER_MODULE(ds1374u, iicbus, ds1374u_driver, ds1374u_devclass, 0, 0);
MODULE_VERSION(ds1374u, 1);
MODULE_DEPEND(ds1374u, iicbus, 1, 1, 1);
|
// Copyright 2017 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 DEVICE_FIDO_PUBLIC_KEY_CREDENTIAL_PARAMS_H_
#define DEVICE_FIDO_PUBLIC_KEY_CREDENTIAL_PARAMS_H_
#include <string>
#include <tuple>
#include <vector>
#include "base/component_export.h"
#include "base/macros.h"
#include "base/numerics/safe_conversions.h"
#include "base/optional.h"
#include "components/cbor/values.h"
#include "device/fido/fido_constants.h"
namespace device {
// Data structure containing public key credential type(string) and
// cryptographic algorithm(integer) as specified by the CTAP spec. Used as a
// request parameter for AuthenticatorMakeCredential.
class COMPONENT_EXPORT(DEVICE_FIDO) PublicKeyCredentialParams {
public:
struct COMPONENT_EXPORT(DEVICE_FIDO) CredentialInfo {
bool operator==(const CredentialInfo& other) const;
CredentialType type = CredentialType::kPublicKey;
int algorithm = base::strict_cast<int>(CoseAlgorithmIdentifier::kCoseEs256);
};
static base::Optional<PublicKeyCredentialParams> CreateFromCBORValue(
const cbor::Value& cbor_value);
explicit PublicKeyCredentialParams(
std::vector<CredentialInfo> credential_params);
PublicKeyCredentialParams(const PublicKeyCredentialParams& other);
PublicKeyCredentialParams(PublicKeyCredentialParams&& other);
PublicKeyCredentialParams& operator=(const PublicKeyCredentialParams& other);
PublicKeyCredentialParams& operator=(PublicKeyCredentialParams&& other);
~PublicKeyCredentialParams();
const std::vector<CredentialInfo>& public_key_credential_params() const {
return public_key_credential_params_;
}
private:
std::vector<CredentialInfo> public_key_credential_params_;
};
cbor::Value AsCBOR(const PublicKeyCredentialParams&);
} // namespace device
#endif // DEVICE_FIDO_PUBLIC_KEY_CREDENTIAL_PARAMS_H_
|
/*---------------------------------------------------------------------------
(c) 2004 Scorpio Software
19 Wittama Drive
Glenmore Park
Sydney NSW 2745
Australia
-----------------------------------------------------------------------------
$Workfile:: $
$Revision:: $
$Date:: $
$Author:: $
---------------------------------------------------------------------------*/
//---------------------------------------------------------------------------
#ifndef ZXBitmapsH
#define ZXBitmapsH
//---------------------------------------------------------------------------
#include "FrameWorkInterface.h"
//---------------------------------------------------------------------------
using namespace Scorpio;
using namespace Interface;
//---------------------------------------------------------------------------
namespace Scorpio
{
namespace GUI
{
class ZXBitmaps
{
private:
typedef struct
{
int iIndex; // index into the image list of the bitmap
bool bLargeList; // true if in Large list, false if in SmallList
TZX_HPLUGIN hOwner; // the plugin handle owns the bitmap
} TZXBitmapInfo;
// vector and vector iterator typedefs
typedef std::vector<TZXBitmapInfo> TZXBitmapInfoVector;
typedef TZXBitmapInfoVector::iterator TZXBitmapInfoIterator;
TImageList* m_Images; // image list we add the bitmaps to
TZXBitmapInfoVector m_Bitmaps; // list of bitmaps added by plugins
public:
__fastcall ZXBitmaps();
__fastcall ~ZXBitmaps();
void __fastcall Setup(TImageList* ImageList);
void __fastcall Free(void);
void __fastcall Free(TZX_HPLUGIN PluginHandle);
int __fastcall Add (TZX_HPLUGIN PluginHandle, TImage* Image);
};
}
}
//---------------------------------------------------------------------------
#endif
|
/*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2008, Willow Garage, 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 the Willow Garage 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: Ioan Sucan */
#ifndef OMPL_GEOMETRIC_HILL_CLIMBING_
#define OMPL_GEOMETRIC_HILL_CLIMBING_
#include "ompl/base/SpaceInformation.h"
#include "ompl/base/goals/GoalRegion.h"
namespace ompl
{
namespace geometric
{
/**
@anchor HillClimbing
@par Short description
HillClimbing searches for a state using hill climbing, starting from a given seed state.
@par External documentation
*/
/** \brief Hill Climbing search */
class HillClimbing
{
public:
/** \brief Constructor */
HillClimbing(const base::SpaceInformationPtr &si) : si_(si), maxImproveSteps_(2), checkValidity_(true)
{
}
~HillClimbing()
{
}
/** \brief Try to improve a state (reduce distance to goal). The updates are performed by sampling near the
state, within the specified distance. If improvements were found, the function returns true and the better
goal distance is optionally returned */
bool tryToImprove(const base::GoalRegion &goal, base::State *state, double nearDistance, double *betterGoalDistance = NULL) const;
/** \brief Set the number of steps to perform */
void setMaxImproveSteps(unsigned int steps)
{
maxImproveSteps_ = steps;
}
/** \brief Get the number of steps to perform */
unsigned int getMaxImproveSteps() const
{
return maxImproveSteps_;
}
/** \brief Set the state validity flag; if this is false, states are not checked for validity */
void setValidityCheck(bool valid)
{
checkValidity_ = valid;
}
/** \brief Get the state validity flag; if this is false, states are not checked for validity */
bool getValidityCheck() const
{
return checkValidity_;
}
private:
bool valid(const base::State *state) const
{
return checkValidity_ ? si_->isValid(state) : true;
}
base::SpaceInformationPtr si_;
unsigned int maxImproveSteps_;
bool checkValidity_;
};
}
}
#endif
|
/*
BSD 3-Clause License
Copyright (c) 2017, John Ventura
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
int chopstr(char *str);
struct creddb *getuserlist(char *filename);
int countusers(char **users);
char **getpasswordlist(int howmany);
// usernames and passwords are
// separated by spaces or tabs
// newlines and CRs are trimmed
#define CREDDELIM "\x20\t\r\n"
struct creddb {
char **users;
char **passwords;
};
|
/*============================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center (DKFZ)
All rights reserved.
Use of this source code is governed by a 3-clause BSD license that can be
found in the LICENSE file.
============================================================================*/
#ifndef MITKIMIMETYPEPROVIDER_H
#define MITKIMIMETYPEPROVIDER_H
#include <MitkCoreExports.h>
#include <mitkMimeType.h>
#include <mitkServiceInterface.h>
#include <usServiceReference.h>
#include <vector>
namespace mitk
{
/**
* @ingroupg IO
* @ingroup MicroServices_Interfaces
*
* @brief The IMimeTypeProvider service interface allows to query all registered
* mime types.
*
* Mime types are added to the system by registering a service object of type
* CustomMimeType and the registered mime types can be queried bei either using direct
* look-ups in the service registry or calling the methods of this service interface.
*
* This service interface also allows to infer the mime type of a file on the file
* system. The heuristics for infering the actual mime type is implementation specific.
*
* @note This is a <em>core service</em>
*
* @sa CustomMimeType
* @sa CoreServices::GetMimeTypeProvider()
*/
struct MITKCORE_EXPORT IMimeTypeProvider
{
virtual ~IMimeTypeProvider();
virtual std::vector<MimeType> GetMimeTypes() const = 0;
virtual std::vector<MimeType> GetMimeTypesForFile(const std::string &filePath) const = 0;
virtual std::vector<MimeType> GetMimeTypesForCategory(const std::string &category) const = 0;
virtual MimeType GetMimeTypeForName(const std::string &name) const = 0;
/**
* @brief Get a sorted and unique list of mime-type categories.
* @return A sorted, unique list of mime-type categories.
*/
virtual std::vector<std::string> GetCategories() const = 0;
};
}
MITK_DECLARE_SERVICE_INTERFACE(mitk::IMimeTypeProvider, "org.mitk.IMimeTypeProvider")
#endif // MITKIMIMETYPEPROVIDER_H
|
//
// ViewController.h
// BluetoothDump
//
// Created by John Brewer on 4/6/13.
// Copyright (c) 2013 Jera Design LLC. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <CoreBluetooth/CoreBluetooth.h>
@interface ViewController : UIViewController <CBCentralManagerDelegate, CBPeripheralDelegate>
@property (weak, nonatomic) IBOutlet UITextView *log;
@property (nonatomic) CBCentralManager *manager;
@property (nonatomic) CBPeripheral *peripheral;
@property (nonatomic) BOOL connected;
@property (nonatomic) BOOL found;
@end
|
#include <glib.h>
int main (int argc, char **argv)
{
g_autoptr(GVariant) v = NULL;
g_autoptr(GError) error = NULL;
gsize size;
const gchar *data;
if (argc < 2)
{
g_printerr ("Usage: %s GVARIANT_TEXT\n", argv[0]);
return 1;
}
v = g_variant_parse (NULL, argv[1], NULL, NULL, &error);
if (v == NULL)
{
g_autofree gchar *msg = NULL;
msg = g_variant_parse_error_print_context (error, argv[1]);
g_printerr ("%s", msg);
return 1;
}
g_print ("%s\n", g_variant_get_type_string (v));
size = g_variant_get_size (v);
data = g_variant_get_data (v);
if (size > 0)
{
g_print ("[ 0x%x", data[0] & 0xff);
for (gsize i = 1; i < size; i++)
g_print (", 0x%x", data[i] & 0xff);
g_print (" ]\n");
}
else
g_print ("[]\n");
return 0;
}
|
#ifndef PANEL_ENGINE_H
#define PANEL_ENGINE_H
/***************************************************************************
* *
* Copyright (C) 2007 by Kanardia d.o.o. [see www.kanardia.eu] *
* Writen by: *
* Ales Krajnc [ales.krajnc@kanardia.eu] *
* *
* Status: Open Source *
* Dimona-100 *
* License: GPL - GNU General Public License *
* See 'COPYING.html' for more details about the license. *
* *
***************************************************************************/
#include <QDomDocument>
#include "AbstractPanel.h"
// --------------------------------------------------------------------------
// forward declaration
namespace instrument
{
class XMLGaugeRound;
}
class PixmapBattery;
// --------------------------------------------------------------------------
class WidgetBottom : public QWidget
{
Q_OBJECT
public:
//! Constructor
WidgetBottom(QWidget *pParent=0);
//! Destructor
virtual ~WidgetBottom();
//! Set battery parameters.
void SetBattery(int iMode, float fVoltage, int iTemp, int iCapacity);
//! Set OAT
void SetOAT(int iOAT);
//! Draw the widget.
virtual void paintEvent(QPaintEvent *pEvent);
private:
//! The battery pixmap object (we do not own it).
PixmapBattery* m_pPixBat;
//! The capacity in percentage.
int m_iCapacity;
//! The cell voltage.
float m_fVoltage;
//! The battery mode.
int m_iMode;
//! The cell temperature.
int m_iTemp;
//! The OAT temperature.
int m_iOAT;
};
// --------------------------------------------------------------------------
class PanelEngine : public AbstractPanel
{
Q_OBJECT
public:
//! Constructor
PanelEngine(const QDomDocument& doc, QSize sz, QWidget *pParent = 0);
//! Destructor
virtual ~PanelEngine();
//! Draw the panel.
virtual void Draw(bool bMajor);
//! Give the list of menu button labels.
QStringList GetMenuLabels() const;
//! Respond on a menu button.
void OnMenuButtonPressed(PanelButton ePB);
private:
//! Get full access to widget object according to positon.
instrument::XMLGaugeRound*& GetWidget(QString& qsPos);
private:
// The following six widgets are configurable
instrument::XMLGaugeRound* m_pwTopLeft; //!< Top-left widget.
instrument::XMLGaugeRound* m_pwTopMiddle; //!< Top-middle widget.
instrument::XMLGaugeRound* m_pwTopRight; //!< Top-right widget.
instrument::XMLGaugeRound* m_pwBottomLeft; //!< Top-left widget.
instrument::XMLGaugeRound* m_pwBottomMiddle; //!< Top-left widget.
instrument::XMLGaugeRound* m_pwBottomRight; //!< Top-right widget.
//! The bottom widget holds battery, OAT.
WidgetBottom* m_pwBottom;
};
#endif
|
//
// FTTableViewAdapter+Subclassing.h
// Fountain
//
// Created by Tobias Kraentzer on 12.08.15.
// Copyright © 2015 Tobias Kräntzer. All rights reserved.
//
#import "FTTableViewAdapter.h"
@interface FTTableViewAdapter (Subclassing)
- (void)rowPreperationForItemAtIndexPath:(NSIndexPath *)indexPath
withBlock:(void (^)(NSString *reuseIdentifier,
FTTableViewAdapterCellPrepareBlock prepareBlock,
id item))block;
- (void)headerPreperationForSection:(NSUInteger)section
withBlock:(void (^)(NSString *reuseIdentifier,
FTTableViewAdapterHeaderFooterPrepareBlock prepareBlock,
id item))block;
- (void)footerPreperationForSection:(NSUInteger)section
withBlock:(void (^)(NSString *reuseIdentifier,
FTTableViewAdapterHeaderFooterPrepareBlock prepareBlock,
id item))block;
@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_CHROME_BROWSER_MAIN_POSIX_H_
#define CHROME_BROWSER_CHROME_BROWSER_MAIN_POSIX_H_
#include "base/macros.h"
#include "chrome/browser/chrome_browser_main.h"
class ChromeBrowserMainPartsPosix : public ChromeBrowserMainParts {
public:
ChromeBrowserMainPartsPosix(const content::MainFunctionParams& parameters,
StartupData* startup_data);
ChromeBrowserMainPartsPosix(const ChromeBrowserMainPartsPosix&) = delete;
ChromeBrowserMainPartsPosix& operator=(const ChromeBrowserMainPartsPosix&) =
delete;
// content::BrowserMainParts overrides.
int PreEarlyInitialization() override;
void PostCreateMainMessageLoop() override;
// ChromeBrowserMainParts overrides.
void ShowMissingLocaleMessageBox() override;
};
#endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_POSIX_H_
|
// Copyright (c) 2009-2021 The Regents of the University of Michigan
// This file is part of the HOOMD-blue project, released under the BSD 3-Clause License.
// Maintainer: pschoenhoefer
#ifndef __MANIFOLD_CLASS_XY_PLANE_H__
#define __MANIFOLD_CLASS_XY_PLANE_H__
#include "hoomd/BoxDim.h"
#include "hoomd/HOOMDMath.h"
#include <pybind11/pybind11.h>
/*! \file ManifoldXYPlane.h
\brief Defines the manifold class for the XYPlane surface
*/
// need to declare these class methods with __device__ qualifiers when building in nvcc
// DEVICE is __host__ __device__ when included in nvcc and blank when included into the host
// compiler
#ifdef __HIPCC__
#define DEVICE __device__
#else
#define DEVICE
#endif
//! Class for constructing the XYPlane surface
/*! <b>General Overview</b>
ManifoldXYPlane is a low level computation class that computes the distance and normal vector to
the xy surface.
<b>XYPlane specifics</b>
ManifoldXYPlane constructs the surface:
shift = z
These are the parameters:
- \a shift = shift of the xy-plane in z-direction;
*/
class ManifoldXYPlane
{
public:
//! Constructs the manifold class
/*! \param _shift in z direction
*/
DEVICE ManifoldXYPlane(const Scalar _shift) : shift(_shift) { }
//! Evaluate implicit function
/*! \param point Point at which surface is calculated
\return result of the nodal function at input point
*/
DEVICE Scalar implicitFunction(const Scalar3& point)
{
return point.z - shift;
}
//! Evaluate derivative of implicit function
/*! \param point Point at surface is calculated
\return normal of the XYPlane surface at input point
*/
DEVICE Scalar3 derivative(const Scalar3& point)
{
return make_scalar3(0, 0, 1);
}
DEVICE bool fitsInsideBox(const BoxDim& box)
{
Scalar3 lo = box.getLo();
Scalar3 hi = box.getHi();
if (shift > hi.z || shift < lo.z)
{
return false; // XYPlane does not fit inside box
}
else
{
return true;
}
}
Scalar getShift()
{
return shift;
};
static unsigned int dimension()
{
return 2;
}
protected:
Scalar shift;
};
//! Exports the XYPlane manifold class to python
void export_ManifoldXYPlane(pybind11::module& m);
#endif // __MANIFOLD_CLASS_XY_PLANE_H__
|
// Copyright (c) 2014, Baidu.com, Inc. All Rights Reserved
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// baidu/common/logging.h
#ifndef BUBBLEFS_PLATFORM_BDCOM_LOGGING_H_
#define BUBBLEFS_PLATFORM_BDCOM_LOGGING_H_
#include <sstream>
namespace bubblefs {
namespace mybdcom {
enum LogLevel {
DEBUG = 2,
INFO = 4,
WARNING = 8,
ERROR = 16,
FATAL = 32,
};
void SetLogLevel(int level);
bool SetLogFile(const char* path, bool append = false);
bool SetWarningFile(const char* path, bool append = false);
bool SetLogSize(int size); // in MB
bool SetLogCount(int count);
bool SetLogSizeLimit(int size); // in MB
void LogC(int level, const char* fmt, ...);
class LogStream {
public:
LogStream(int level);
template<class T>
LogStream& operator<<(const T& t) {
oss_ << t;
return *this;
}
~LogStream();
private:
int level_;
std::ostringstream oss_;
};
} // namespace mybdcom
using mybdcom::DEBUG;
using mybdcom::INFO;
using mybdcom::WARNING;
using mybdcom::ERROR;
using mybdcom::FATAL;
#define LOG(level, fmt, args...) ::bubblefs::mybdcom::LogC(level, "[%s:%d] " fmt, __FILE__, __LINE__, ##args)
#define LOGS(level) ::bubblefs::mybdcom::LogStream(level)
} // namespace bubblefs
#endif // BUBBLEFS_PLATFORM_BDCOM_LOGGING_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 CONTENT_BROWSER_MEDIA_CAPTURE_WEB_CONTENTS_VIDEO_CAPTURE_DEVICE_H_
#define CONTENT_BROWSER_MEDIA_CAPTURE_WEB_CONTENTS_VIDEO_CAPTURE_DEVICE_H_
#include <memory>
#include <string>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "content/browser/media/capture/frame_sink_video_capture_device.h"
#include "content/browser/media/capture/web_contents_frame_tracker.h"
#include "content/common/content_export.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/browser/web_contents_media_capture_id.h"
namespace content {
// Captures the displayed contents of a WebContents, producing a stream of video
// frames.
//
// Generally, Create() is called with a device ID string that contains
// information necessary for finding a WebContents instance. Thereafter, this
// capture device will capture from the frame sink corresponding to the main
// frame of the RenderFrameHost tree for that WebContents instance. As the
// RenderFrameHost tree mutates (e.g., due to page navigations, crashes, or
// reloads), capture will continue without interruption.
class CONTENT_EXPORT WebContentsVideoCaptureDevice
: public FrameSinkVideoCaptureDevice,
public base::SupportsWeakPtr<WebContentsVideoCaptureDevice> {
public:
explicit WebContentsVideoCaptureDevice(const GlobalRenderFrameHostId& id);
WebContentsVideoCaptureDevice(WebContentsVideoCaptureDevice&&) = delete;
WebContentsVideoCaptureDevice(const WebContentsVideoCaptureDevice&) = delete;
WebContentsVideoCaptureDevice& operator=(
const WebContentsVideoCaptureDevice&&) = delete;
WebContentsVideoCaptureDevice& operator=(
const WebContentsVideoCaptureDevice&) = delete;
~WebContentsVideoCaptureDevice() override;
// Creates a WebContentsVideoCaptureDevice instance from the given
// |device_id|. Returns null if |device_id| is invalid.
static std::unique_ptr<WebContentsVideoCaptureDevice> Create(
const std::string& device_id);
// VideoCaptureDevice overrides.
void Crop(
const base::Token& crop_id,
base::OnceCallback<void(media::mojom::CropRequestResult)> callback) final;
// For testing, we need the ability to create a device without its tracker.
protected:
WebContentsVideoCaptureDevice();
private:
// FrameSinkVideoCaptureDevice overrides: These increment/decrement the
// WebContents's capturer count, which causes the embedder to be notified.
void WillStart() final;
void DidStop() final;
// A helper that runs on the UI thread to monitor changes to the
// RenderFrameHost tree during the lifetime of a WebContents instance, and
// posts notifications back to update the target frame sink.
std::unique_ptr<WebContentsFrameTracker, BrowserThread::DeleteOnUIThread>
tracker_;
};
} // namespace content
#endif // CONTENT_BROWSER_MEDIA_CAPTURE_WEB_CONTENTS_VIDEO_CAPTURE_DEVICE_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_BROWSER_ASH_ARC_INSTANCE_THROTTLE_ARC_PROVISIONING_THROTTLE_OBSERVER_H_
#define CHROME_BROWSER_ASH_ARC_INSTANCE_THROTTLE_ARC_PROVISIONING_THROTTLE_OBSERVER_H_
#include "chrome/browser/ash/arc/session/arc_session_manager_observer.h"
#include "chrome/browser/ash/throttle_observer.h"
namespace content {
class BrowserContext;
}
namespace arc {
// This class observes ARC provisioning state and keeps ARC unthrottled until
// provisioning is done.
class ArcProvisioningThrottleObserver : public chromeos::ThrottleObserver,
public ArcSessionManagerObserver {
public:
ArcProvisioningThrottleObserver();
ArcProvisioningThrottleObserver(const ArcProvisioningThrottleObserver&) =
delete;
ArcProvisioningThrottleObserver& operator=(
const ArcProvisioningThrottleObserver&) = delete;
~ArcProvisioningThrottleObserver() override = default;
// chromeos::ThrottleObserver:
void StartObserving(content::BrowserContext* context,
const ObserverStateChangedCallback& callback) override;
void StopObserving() override;
// ArcSessionManagerObserver:
void OnArcStarted() override;
void OnArcSessionRestarting() override;
void OnArcInitialStart() override;
};
} // namespace arc
#endif // CHROME_BROWSER_ASH_ARC_INSTANCE_THROTTLE_ARC_PROVISIONING_THROTTLE_OBSERVER_H_
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_snprintf_68a.c
Label Definition File: CWE122_Heap_Based_Buffer_Overflow__c_CWE806.label.xml
Template File: sources-sink-68a.tmpl.c
*/
/*
* @description
* CWE: 122 Heap Based Buffer Overflow
* BadSource: Initialize data as a large string
* GoodSource: Initialize data as a small string
* Sink: snprintf
* BadSink : Copy data to string using snprintf
* Flow Variant: 68 Data flow: data passed as a global variable from one function to another in different source files
*
* */
#include "std_testcase.h"
#include <wchar.h>
#ifdef _WIN32
#define SNPRINTF _snprintf
#else
#define SNPRINTF snprintf
#endif
char * CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_snprintf_68_badData;
char * CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_snprintf_68_goodG2BData;
#ifndef OMITBAD
/* bad function declaration */
void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_snprintf_68b_badSink();
void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_snprintf_68_bad()
{
char * data;
data = (char *)malloc(100*sizeof(char));
if (data == NULL) {exit(-1);}
/* FLAW: Initialize data as a large buffer that is larger than the small buffer used in the sink */
memset(data, 'A', 100-1); /* fill with 'A's */
data[100-1] = '\0'; /* null terminate */
CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_snprintf_68_badData = data;
CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_snprintf_68b_badSink();
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* good function declarations */
void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_snprintf_68b_goodG2BSink();
/* goodG2B uses the GoodSource with the BadSink */
static void goodG2B()
{
char * data;
data = (char *)malloc(100*sizeof(char));
if (data == NULL) {exit(-1);}
/* FIX: Initialize data as a small buffer that as small or smaller than the small buffer used in the sink */
memset(data, 'A', 50-1); /* fill with 'A's */
data[50-1] = '\0'; /* null terminate */
CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_snprintf_68_goodG2BData = data;
CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_snprintf_68b_goodG2BSink();
}
void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_snprintf_68_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()...");
CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_snprintf_68_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_snprintf_68_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
/* This file contains functions that handle complex arrays and
Fast Fourier Transform operations:
FFTShift - can be used to re-center cross correlation result
AllocCmplxArray - complex array memory management
FreeCmplxArray
InitCmplxArray
fft2d - forward 2-D FFT
ifft2d - inverse 2-D FFT
CpyCmplx - copy a cmplx array
Revision history:
----------------
21 Jul 2000 - Extracted from cx4/ and cs6/idtalg/
*/
# include <stdio.h>
# include <stdlib.h>
# include "stis.h"
# include "hstcalerr.h"
/*
To be used before transforming FT back to data space, to shift image
to center of field. Works for arrays with even dimensions.
*/
void FFTShift (CmplxArray *z) {
/* arguments:
CmplxArray *z io: FT array to be shifted
*/
int i, j;
for (j = 1; j < z->ny; j+=2) {
for (i = 0; i < z->nx-1; i+=2) {
RPIX2D (z, i, j) = - RPIX2D (z, i, j);
IPIX2D (z, i, j) = - IPIX2D (z, i, j);
}
}
for (j = 0; j < z->ny-1; j+=2) {
for (i = 1; i < z->nx; i+= 2) {
RPIX2D (z, i, j) = - RPIX2D (z, i, j);
IPIX2D (z, i, j) = - IPIX2D (z, i, j);
}
}
}
/* AllocCmplxArray allocates memory for an array of complex numbers.
Memory is also allocated for the work space used by the NCAR FFT
routines written by Paul Swarztrauber.
*/
int AllocCmplxArray (CmplxArray *z, int nx, int ny) {
if (z->allocated) {
printf ("Error: complex array already allocated.\n");
return (ERROR_RETURN);
}
if (ny < 1)
ny = 1;
z->data = calloc (nx * ny * 2, sizeof(float));
z->workx = calloc ((15 + 4 * nx), sizeof (float));
z->worky = calloc ((15 + 4 * ny), sizeof (float));
z->nx = nx;
z->ny = ny;
if (z->data == NULL || z->workx == NULL || z->worky == NULL)
return (OUT_OF_MEMORY);
z->allocated = 1;
/* Compute trig functions for use by the NCAR FFT routines. */
CFFTI (&nx, z->workx);
if (ny > 1)
CFFTI (&ny, z->worky);
return (0);
}
/* This routine frees memory allocated by AllocCmplxArray. */
void FreeCmplxArray (CmplxArray *z) {
if (z->allocated) {
free (z->data);
free (z->workx);
free (z->worky);
z->nx = 0;
z->ny = 0;
z->allocated = 0;
}
}
/* Initializes a CmplxArray structure. */
void InitCmplxArray (CmplxArray *z) {
z->allocated = 0;
z->data = NULL;
z->workx = NULL;
z->worky = NULL;
z->nx = 0;
z->ny = 0;
}
/* Forward Fourier transform of 2-D data.
On input, z contains an array of complex data.
On output, z will contain the fourier transform of the input data.
*/
int fft2d (CmplxArray *z) {
/* argument:
CmplxArray *z io: complex array
*/
CmplxArray scr; /* scratch space for FT of columns */
int i, j; /* loop indexes */
int nx, ny; /* image size */
int status;
nx = z->nx;
ny = z->ny;
/* Allocate a 1-D array for a column. Note that scr.nx = z->ny. */
InitCmplxArray (&scr);
if ((status = AllocCmplxArray (&scr, ny, 1)))
return (status);
for (j = 0; j < ny; j++) /* transform each line */
CFFTF (&nx, &(RPIX2D(z,0,j)), z->workx);
for (i = 0; i < nx; i++) { /* transform each column */
for (j = 0; j < ny; j++) {
RPIX1D (&scr, j) = RPIX2D (z, i, j);
IPIX1D (&scr, j) = IPIX2D (z, i, j);
}
CFFTF (&scr.nx, scr.data, scr.workx);
for (j = 0; j < ny; j++) {
RPIX2D (z, i, j) = RPIX1D (&scr, j);
IPIX2D (z, i, j) = IPIX1D (&scr, j);
}
}
FreeCmplxArray (&scr);
return (0);
}
/* Inverse Fourier transform of 2-D data.
The normalization (dividing by nx * ny) is done in this routine.
Note that z is both input and output.
*/
int ifft2d (CmplxArray *z) {
/* argument:
CmplxArray *z io: complex array
*/
CmplxArray scr; /* scratch space for FT of columns */
int i, j; /* loop indexes */
int nx, ny; /* image size */
int status;
nx = z->nx;
ny = z->ny;
/* Allocate a 1-D array for a column. */
InitCmplxArray (&scr);
if ((status = AllocCmplxArray (&scr, ny, 1)))
return (status);
for (j = 0; j < ny; j++) /* transform each line */
CFFTB (&nx, &(RPIX2D(z,0,j)), z->workx);
for (i = 0; i < nx; i++) { /* transform each column */
for (j = 0; j < ny; j++) {
RPIX1D (&scr, j) = RPIX2D (z, i, j);
IPIX1D (&scr, j) = IPIX2D (z, i, j);
}
CFFTB (&scr.nx, scr.data, scr.workx);
for (j = 0; j < ny; j++) {
RPIX2D (z, i, j) = RPIX1D (&scr, j) / (nx * ny);
IPIX2D (z, i, j) = IPIX1D (&scr, j) / (nx * ny);
}
}
FreeCmplxArray (&scr);
return (0);
}
void CpyCmplx (CmplxArray *zin, CmplxArray *zout) {
int i,j;
for (j = 0; j < zout->ny; j++) {
for (i = 0; i < zout->nx; i++) {
RPIX2D (zout, i, j) = RPIX2D (zin, i, j);
IPIX2D (zout, i, j) = IPIX2D (zin, i, j);
}
}
}
|
// Copyright 2017 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 MEDIA_AUDIO_FUCHSIA_AUDIO_MANAGER_FUCHSIA_H_
#define MEDIA_AUDIO_FUCHSIA_AUDIO_MANAGER_FUCHSIA_H_
#include "media/audio/audio_manager_base.h"
namespace media {
class AudioManagerFuchsia : public AudioManagerBase {
public:
AudioManagerFuchsia(std::unique_ptr<AudioThread> audio_thread,
AudioLogFactory* audio_log_factory);
AudioManagerFuchsia(const AudioManagerFuchsia&) = delete;
AudioManagerFuchsia& operator=(const AudioManagerFuchsia&) = delete;
~AudioManagerFuchsia() override;
// Implementation of AudioManager.
bool HasAudioOutputDevices() override;
bool HasAudioInputDevices() override;
void GetAudioInputDeviceNames(AudioDeviceNames* device_names) override;
void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) override;
AudioParameters GetInputStreamParameters(
const std::string& device_id) override;
const char* GetName() override;
// Implementation of AudioManagerBase.
AudioOutputStream* MakeLinearOutputStream(
const AudioParameters& params,
const LogCallback& log_callback) override;
AudioOutputStream* MakeLowLatencyOutputStream(
const AudioParameters& params,
const std::string& device_id,
const LogCallback& log_callback) override;
AudioInputStream* MakeLinearInputStream(
const AudioParameters& params,
const std::string& device_id,
const LogCallback& log_callback) override;
AudioInputStream* MakeLowLatencyInputStream(
const AudioParameters& params,
const std::string& device_id,
const LogCallback& log_callback) override;
protected:
AudioParameters GetPreferredOutputStreamParameters(
const std::string& output_device_id,
const AudioParameters& input_params) override;
private:
AudioInputStream* MakeInputStream(const AudioParameters& input_params,
const std::string& device_id);
};
} // namespace media
#endif // MEDIA_AUDIO_FUCHSIA_AUDIO_MANAGER_FUCHSIA_H_
|
#include <convexHull/convexHull.h>
#include <stdlib.h>
static convexHullVector comparePoint;
static float convexHullOrientation(const convexHullVector p, const convexHullVector q, const convexHullVector r)
{
return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
}
static void convexHullSwap(convexHullVector *a, convexHullVector *b)
{
convexHullVector buffer = *a;
*a = *b;
*b = buffer;
}
static float convexHullDist(convexHullVector p1, convexHullVector p2)
{
return (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y);
}
static int convexHullCompare(const void *a, const void *b)
{
const convexHullVector *p1 = a;
const convexHullVector *p2 = b;
float orientation = convexHullOrientation(comparePoint, *p1, *p2);
if(orientation == 0) return (convexHullDist(comparePoint, *p2) >= convexHullDist(comparePoint, *p1))?-1:1;
return (orientation < 0)?-1:1;
}
void convexHullGrahamScan(convexHull *convexHull)
{
uint32_t i;
uint32_t minIndex = 0;
uint32_t stackIndex = 3;
float ymin = convexHull->nodes[0].y;
// Find minimum Y
for(i = 1; i < convexHull->nodeCount; ++i) {
if(convexHull->nodes[i].y < ymin) {
ymin = convexHull->nodes[i].y;
minIndex = i;
}
}
// Put minimum at zero
convexHullSwap(convexHull->nodes, convexHull->nodes + minIndex);
// Sort
comparePoint = convexHull->nodes[0];
qsort(convexHull->nodes, convexHull->nodeCount, sizeof(convexHullVector), convexHullCompare);
// Create & initialize stack
for(i = 3; i < convexHull->nodeCount; ++i) {
while(convexHullOrientation(convexHull->nodes[stackIndex - 2], convexHull->nodes[stackIndex - 1], convexHull->nodes[i]) >= 0) {
--stackIndex;
}
convexHull->nodes[stackIndex++] = convexHull->nodes[i];
}
// Store final list
convexHull->nodeCount = stackIndex;
}
|
//
// CVSPhoneColorWell.h
// DrawQuest
//
// Created by David Mauro on 9/17/13.
// Copyright (c) 2013 Canvas. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CVSPhoneColorWell : UIView
@property (nonatomic, strong) UIColor *fillColor;
@property (nonatomic, strong) UIColor *strokeColor;
@property (nonatomic, assign) BOOL *forceOutline;
- (id)initWithFrame:(CGRect)frame fillColor:(UIColor *)fillColor strokeColor:(UIColor *)strokeColor forceOutline:(BOOL)forceOutline;
- (id)initWithFrame:(CGRect)frame MSDesignatedInitializer(initWithFrame:fillColor:strokeColor:forceOutline:);
@end
|
// Copyright (c) 2013 Intel Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef XWALK_EXTENSIONS_COMMON_XWALK_EXTENSION_SERVER_H_
#define XWALK_EXTENSIONS_COMMON_XWALK_EXTENSION_SERVER_H_
#include <stdint.h>
#include <map>
#include <set>
#include <string>
#include <vector>
#include "base/synchronization/lock.h"
#include "base/values.h"
#include "ipc/ipc_channel_proxy.h"
#include "ipc/ipc_listener.h"
struct XWalkExtensionServerMsg_ExtensionRegisterParams;
namespace base {
class FilePath;
}
namespace content {
class RenderProcessHost;
}
namespace IPC {
class Sender;
}
namespace xwalk {
namespace extensions {
class XWalkExtension;
class XWalkExtensionInstance;
// Manages the instances for a set of extensions. It communicates with one
// XWalkExtensionClient by means of IPC channel.
//
// This class is used both by in-process extensions running in the Browser
// Process, and by the external extensions running in the Extension Process.
class XWalkExtensionServer : public IPC::Listener {
public:
XWalkExtensionServer();
virtual ~XWalkExtensionServer();
// IPC::Listener Implementation.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
void Initialize(IPC::Sender* sender);
bool Send(IPC::Message* msg);
bool RegisterExtension(scoped_ptr<XWalkExtension> extension);
bool ContainsExtension(const std::string& extension_name) const;
void Invalidate();
// These Message Handlers can be accessed by a message filter when
// running on the browser process.
void OnCreateInstance(int64_t instance_id, std::string name);
void OnGetExtensions(
std::vector<XWalkExtensionServerMsg_ExtensionRegisterParams>* reply);
private:
struct InstanceExecutionData {
XWalkExtensionInstance* instance;
IPC::Message* pending_reply;
};
// Message Handlers
void OnDestroyInstance(int64_t instance_id);
void OnPostMessageToNative(int64_t instance_id, const base::ListValue& msg);
void OnSendSyncMessageToNative(int64_t instance_id,
const base::ListValue& msg, IPC::Message* ipc_reply);
void PostMessageToJSCallback(int64_t instance_id,
scoped_ptr<base::Value> msg);
void SendSyncReplyToJSCallback(int64_t instance_id,
scoped_ptr<base::Value> reply);
void DeleteInstanceMap();
bool ValidateExtensionEntryPoints(const base::ListValue& entry_points);
base::Lock sender_lock_;
IPC::Sender* sender_;
typedef std::map<std::string, XWalkExtension*> ExtensionMap;
ExtensionMap extensions_;
typedef std::map<int64_t, InstanceExecutionData> InstanceMap;
InstanceMap instances_;
// The exported symbols for extensions already registered.
typedef std::set<std::string> ExtensionSymbolsSet;
ExtensionSymbolsSet extension_symbols_;
};
std::vector<std::string> RegisterExternalExtensionsInDirectory(
XWalkExtensionServer* server, const base::FilePath& dir);
bool ValidateExtensionNameForTesting(const std::string& extension_name);
} // namespace extensions
} // namespace xwalk
#endif // XWALK_EXTENSIONS_COMMON_XWALK_EXTENSION_SERVER_H_
|
#include "hmc5883.h"
#include "hal_hmc5883.h"
#include "OSConfig.h"
void HMC5883_I2C_Init(void) //³õʼ»¯I2C×ÜÏß
{
I2C_InitTypeDef I2C_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable I2C and GPIO clocks */
RCC_APB1PeriphClockCmd(HMC5883_I2C_RCC_Periph, ENABLE);
RCC_APB2PeriphClockCmd(HMC5883_I2C_RCC_Port, ENABLE);
/* Configure I2C pins: SCL and SDA */
GPIO_InitStructure.GPIO_Pin = HMC5883_I2C_SCL_Pin | HMC5883_I2C_SDA_Pin;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
GPIO_Init(HMC5883_I2C_Port, &GPIO_InitStructure);
/* I2C configuration */
I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
I2C_InitStructure.I2C_OwnAddress1 = 0x00;
I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
I2C_InitStructure.I2C_ClockSpeed = HMC5883_I2C_Speed;
/* Apply I2C configuration after enabling it */
I2C_Init(HMC5883_I2C, &I2C_InitStructure);
/* I2C Peripheral Enable */
I2C_Cmd(HMC5883_I2C, ENABLE);
}
void HMC5883_I2C_ByteWrite(u8 slAddr, u8* pBuffer, u8 WriteAddr)
{
AHRS_ENTER_CRITICAL();
/* Send START condition */
I2C_GenerateSTART(HMC5883_I2C, ENABLE);
/* Test on EV5 and clear it */
while(!I2C_CheckEvent(HMC5883_I2C, I2C_EVENT_MASTER_MODE_SELECT));
/* Send HMC5883303DLH_Magn address for write */
I2C_Send7bitAddress(HMC5883_I2C, slAddr, I2C_Direction_Transmitter);
/* Test on EV6 and clear it */
while(!I2C_CheckEvent(HMC5883_I2C, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED));
/* Send the HMC5883303DLH_Magn's internal address to write to */
I2C_SendData(HMC5883_I2C, WriteAddr);
/* Test on EV8 and clear it */
while(!I2C_CheckEvent(HMC5883_I2C, I2C_EVENT_MASTER_BYTE_TRANSMITTED));
/* Send the byte to be written */
I2C_SendData(HMC5883_I2C, *pBuffer);
/* Test on EV8 and clear it */
while(!I2C_CheckEvent(HMC5883_I2C, I2C_EVENT_MASTER_BYTE_TRANSMITTED));
/* Send STOP condition */
I2C_GenerateSTOP(HMC5883_I2C, ENABLE);
AHRS_EXIT_CRITICAL();
}
void HMC5883_I2C_BufferRead(u8 slAddr,u8* pBuffer, u8 ReadAddr, u16 NumByteToRead)
{
AHRS_ENTER_CRITICAL();
/* While the bus is busy */
while(I2C_GetFlagStatus(HMC5883_I2C, I2C_FLAG_BUSY));
/* Send START condition */
I2C_GenerateSTART(HMC5883_I2C, ENABLE);
/* Test on EV5 and clear it */
while(!I2C_CheckEvent(HMC5883_I2C, I2C_EVENT_MASTER_MODE_SELECT));
/* Send HMC5883303DLH_Magn address for write */
I2C_Send7bitAddress(HMC5883_I2C, slAddr, I2C_Direction_Transmitter);
/* Test on EV6 and clear it */
while(!I2C_CheckEvent(HMC5883_I2C, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED));
/* Clear EV6 by setting again the PE bit */
I2C_Cmd(HMC5883_I2C, ENABLE);
/* Send the HMC5883303DLH_Magn's internal address to write to */
I2C_SendData(HMC5883_I2C, ReadAddr);
/* Test on EV8 and clear it */
while(!I2C_CheckEvent(HMC5883_I2C, I2C_EVENT_MASTER_BYTE_TRANSMITTED));
/* Send STRAT condition a second time */
I2C_GenerateSTART(HMC5883_I2C, ENABLE);
/* Test on EV5 and clear it */
while(!I2C_CheckEvent(HMC5883_I2C, I2C_EVENT_MASTER_MODE_SELECT));
/* Send HMC5883303DLH address for read */
I2C_Send7bitAddress(HMC5883_I2C, slAddr, I2C_Direction_Receiver);
/* Test on EV6 and clear it */
while(!I2C_CheckEvent(HMC5883_I2C, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED));
/* While there is data to be read */
while(NumByteToRead)
{
if(NumByteToRead == 1)
{
/* Disable Acknowledgement */
I2C_AcknowledgeConfig(HMC5883_I2C, DISABLE);
/* Send STOP Condition */
I2C_GenerateSTOP(HMC5883_I2C, ENABLE);
}
/* Test on EV7 and clear it */
if(I2C_CheckEvent(HMC5883_I2C, I2C_EVENT_MASTER_BYTE_RECEIVED))
{
/* Read a byte from the HMC5883303DLH */
*pBuffer = I2C_ReceiveData(HMC5883_I2C);
/* Point to the next location where the byte read will be saved */
pBuffer++;
/* Decrement the read bytes counter */
NumByteToRead--;
}
}
/* Enable Acknowledgement to be ready for another reception */
I2C_AcknowledgeConfig(HMC5883_I2C, ENABLE);
AHRS_EXIT_CRITICAL();
}
void HMC5883_Init(HMC5883_InitTypeDef *HMC5883_InitStructure)
{
u32 i=10000;
GPIO_InitTypeDef GPIO_InitStructure;
u8 Con_A_content=HMC5883_InitStructure->Sample_Num |HMC5883_InitStructure->Output_Rate | HMC5883_InitStructure->Measure_Mode;
u8 Con_B_content=HMC5883_InitStructure->Gain_Configure;
u8 Mode_content=HMC5883_InitStructure->Operating_Mode;
HMC5883_I2C_ByteWrite(HMC5883_I2C_ADD, &Con_A_content,HMC5883_CON_A);
HMC5883_I2C_ByteWrite(HMC5883_I2C_ADD, &Con_B_content,HMC5883_CON_B);
HMC5883_I2C_ByteWrite(HMC5883_I2C_ADD, &Mode_content,HMC5883_MODE);
while(i--);
RCC_APB2PeriphClockCmd(HMC5883_DRDY_RCC_Port, ENABLE); //GPIOCʱÖÓ
GPIO_InitStructure.GPIO_Pin = HMC5883_DRDY_Pin ;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(HMC5883_DRDY_Port, &GPIO_InitStructure);
}
void HMC5883_Read_ID(u8* pid)//È·ÈÏ´ÅÂÞÅÌID
{
u8 buffer;
HMC5883_I2C_BufferRead(HMC5883_I2C_ADD,&buffer,HMC5883_ID_A,1);
*pid=buffer;
}
void HMC5883_Read_Raw(s16* mag)//¶ÁÈ¡´ÅÂÞÅÌÊý¾Ý
{
u8 i;
u8 buffer[6];
u8 status;
// test_ready = GPIO_ReadInputDataBit(GPIOB , GPIO_Pin_6);
HMC5883_I2C_BufferRead(HMC5883_I2C_ADD ,&status,HMC5883_STATUS ,1);
if( (status&0x01) != 0)
{
HMC5883_I2C_BufferRead(HMC5883_I2C_ADD, buffer,HMC5883_OUT_X_MSB, 6);
for(i=0; i<3; i++)
{
mag[i] = buffer[2*i];//&0x00ff;
mag[i] <<= 8;
mag[i] |= buffer[2*i+1];
}
}
}
|
/*
* Blowfish - a fast block cipher designed by Bruce Schneier
*
* Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Niels Provos.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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: stable/10/secure/lib/libcrypt/blowfish.h 115719 2003-06-02 19:17:24Z markm $
*/
/*
* FreeBSD implementation by Paul Herman <pherman@frenchfries.net>
*/
#ifndef _BLF_H_
#define _BLF_H_
/* Schneier states the maximum key length to be 56 bytes.
* The way how the subkeys are initalized by the key up
* to (N+2)*4 i.e. 72 bytes are utilized.
* Warning: For normal blowfish encryption only 56 bytes
* of the key affect all cipherbits.
*/
#define BLF_N 16 /* Number of Subkeys */
/* Blowfish context */
typedef struct BlowfishContext {
u_int32_t S[4][256]; /* S-Boxes */
u_int32_t P[BLF_N + 2]; /* Subkeys */
} blf_ctx;
/* Raw access to customized Blowfish
* blf_key is just:
* Blowfish_initstate( state )
* Blowfish_expand0state( state, key, keylen )
*/
void Blowfish_initstate(blf_ctx *);
void Blowfish_expand0state(blf_ctx *, const u_int8_t *, u_int16_t);
void Blowfish_expandstate
(blf_ctx *, const u_int8_t *, u_int16_t, const u_int8_t *, u_int16_t);
u_int32_t Blowfish_stream2word(const u_int8_t *, u_int16_t, u_int16_t *);
void blf_enc(blf_ctx *, u_int32_t *, u_int16_t);
#endif /* _BLF_H_ */
|
// 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 ASH_DISPLAY_MIRROR_WINDOW_CONTROLLER_H_
#define ASH_DISPLAY_MIRROR_WINDOW_CONTROLLER_H_
#include <stdint.h>
#include <map>
#include <memory>
#include <vector>
#include "ash/ash_export.h"
#include "ash/host/ash_window_tree_host_mirroring_delegate.h"
#include "base/macros.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host_observer.h"
#include "ui/display/manager/display_manager.h"
#include "ui/display/manager/managed_display_info.h"
namespace aura {
class Window;
namespace client {
class ScreenPositionClient;
}
}
namespace display {
class Display;
class ManagedDisplayInfo;
}
namespace ash {
class AshWindowTreeHost;
class MirrorWindowTestApi;
// An object that copies the content of the primary root window to a
// mirror window. This also draws a mouse cursor as the mouse cursor
// is typically drawn by the window system.
class ASH_EXPORT MirrorWindowController
: public aura::WindowTreeHostObserver,
public AshWindowTreeHostMirroringDelegate {
public:
MirrorWindowController();
~MirrorWindowController() override;
// Updates the root window's bounds using |display_info|.
// Creates the new root window if one doesn't exist.
void UpdateWindow(
const std::vector<display::ManagedDisplayInfo>& display_info);
// Same as above, but using existing display info
// for the mirrored display.
void UpdateWindow();
// Close the mirror window if they're not necessary any longer.
void CloseIfNotNecessary();
// aura::WindowTreeHostObserver overrides:
void OnHostResized(aura::WindowTreeHost* host) override;
// Returns the display::Display for the mirroring root window.
display::Display GetDisplayForRootWindow(const aura::Window* root) const;
// Returns the AshWindwoTreeHost created for |display_id|.
AshWindowTreeHost* GetAshWindowTreeHostForDisplayId(int64_t display_id);
// Returns all root windows hosting mirroring displays.
aura::Window::Windows GetAllRootWindows() const;
// AshWindowTreeHostMirroringDelegate:
const display::Display* GetMirroringDisplayById(
int64_t display_id) const override;
void SetCurrentEventTargeterSourceHost(
aura::WindowTreeHost* targeter_src_host) override;
const aura::WindowTreeHost* current_event_targeter_src_host() const {
return current_event_targeter_src_host_;
}
private:
friend class MirrorWindowTestApi;
struct MirroringHostInfo;
// Close the mirror window. When |delay_host_deletion| is true, the window
// tree host will be deleted in an another task on UI thread. This is
// necessary to safely delete the WTH that is currently handling input events.
void Close(bool delay_host_deletion);
void CloseAndDeleteHost(MirroringHostInfo* host_info,
bool delay_host_deletion);
typedef std::map<int64_t, MirroringHostInfo*> MirroringHostInfoMap;
MirroringHostInfoMap mirroring_host_info_map_;
aura::WindowTreeHost* current_event_targeter_src_host_;
display::DisplayManager::MultiDisplayMode multi_display_mode_;
// The id of the display being mirrored.
int64_t reflecting_source_id_ = display::kInvalidDisplayId;
std::unique_ptr<aura::client::ScreenPositionClient> screen_position_client_;
DISALLOW_COPY_AND_ASSIGN(MirrorWindowController);
};
} // namespace ash
#endif // ASH_DISPLAY_MIRROR_WINDOW_CONTROLLER_H_
|
/* $NetBSD: svr4_32_types.h,v 1.2 2001/02/11 01:10:25 eeh Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Christos Zoulas.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 _SVR4_32_TYPES_H_
#define _SVR4_32_TYPES_H_
#include <compat/netbsd32/netbsd32.h>
#include <compat/svr4/svr4_types.h>
typedef u_quad_t svr4_32_ino64_t;
typedef quad_t svr4_32_off64_t;
typedef quad_t svr4_32_blkcnt64_t;
typedef u_quad_t svr4_32_fsblkcnt64_t;
typedef netbsd32_long svr4_32_off_t;
typedef netbsd32_u_long svr4_32_dev_t;
typedef netbsd32_u_long svr4_32_ino_t;
typedef netbsd32_u_long svr4_32_mode_t;
typedef netbsd32_u_long svr4_32_nlink_t;
typedef netbsd32_long svr4_32_uid_t;
typedef netbsd32_long svr4_32_gid_t;
typedef netbsd32_long svr4_32_daddr_t;
typedef netbsd32_long svr4_32_pid_t;
typedef netbsd32_long svr4_32_time_t;
typedef netbsd32_long svr4_32_blkcnt_t;
typedef netbsd32_u_long svr4_32_fsblkcnt_t;
typedef netbsd32_caddr_t svr4_32_caddr_t;
typedef u_int svr4_32_size_t;
typedef short svr4_32_o_dev_t;
typedef short svr4_32_o_pid_t;
typedef u_short svr4_32_o_ino_t;
typedef u_short svr4_32_o_mode_t;
typedef short svr4_32_o_nlink_t;
typedef u_short svr4_32_o_uid_t;
typedef u_short svr4_32_o_gid_t;
typedef netbsd32_long svr4_32_clock_t;
typedef int svr4_32_key_t;
typedef struct netbsd32_timespec svr4_32_timestruc_t;
/* Pointer types used by svr4_32_syscallargs.h */
#define PTR typedef netbsd32_caddr_t
PTR svr4_32_utimbufp;
PTR svr4_32_tms_tp;
PTR svr4_32_strbuf_tp;
PTR svr4_32_stat_tp;
PTR svr4_32_sigaltstack_tp;
PTR svr4_32_sigaction_tp;
PTR svr4_32_statvfs_tp;
PTR svr4_32_xstat_tp;
PTR svr4_32_rlimit_tp;
PTR svr4_32_lwpid_tp;
PTR svr4_32_aclent_tp;
PTR svr4_32_dirent64_tp;
PTR svr4_32_stat64_tp;
PTR svr4_32_statvfs64_tp;
PTR svr4_32_rlimit64_tp;
PTR svr4_32_statp;
PTR svr4_32_utsnamep;
PTR svr4_32_time_tp;
#undef PTR
#define svr4_32_omajor(x) ((int32_t)((((x) & 0x7f00) >> 8)))
#define svr4_32_ominor(x) ((int32_t)((((x) & 0x00ff) >> 0)))
#define svr4_32_omakedev(x,y) ((svr4_32_o_dev_t)((((x) << 8) & 0x7f00) | \
(((y) << 0) & 0x00ff)))
#define svr4_32_to_bsd_odev_t(d) makedev(svr4_32_omajor(d), svr4_32_ominor(d))
#define bsd_to_svr4_32_odev_t(d) svr4_32_omakedev(major(d), minor(d))
#define svr4_32_major(x) ((int32_t)((((x) & 0xfffc0000) >> 18)))
#define svr4_32_minor(x) ((int32_t)((((x) & 0x0003ffff) >> 0)))
#define svr4_32_makedev(x,y) ((svr4_32_dev_t)((((x) << 18) & 0xfffc0000) | \
(((y) << 0) & 0x0003ffff)))
#define svr4_32_to_bsd_dev_t(d) makedev(svr4_32_major(d), svr4_32_minor(d))
#define bsd_to_svr4_32_dev_t(d) svr4_32_makedev(major(d), minor(d))
#endif /* !_SVR4_32_TYPES_H_ */
|
/* LibMemcached
* Copyright (C) 2006-2009 Brian Aker, Trond Norbye
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: Change the behavior of the memcached connection.
*
*/
#ifndef __LIBMEMCACHED_CONFIGURE_H
#define __LIBMEMCACHED_CONFIGURE_H
#ifdef __cplusplus
extern "C" {
#endif
#define LIBMEMCACHED_WITH_SASL_SUPPORT 1
#define LIBMEMCACHED_VERSION_STRING "0.44"
#define LIBMEMCACHED_VERSION_HEX 0x00044000
#ifdef __cplusplus
}
#endif
#endif /* __LIBMEMCACHED_CONFIGURE_H */
|
/*
* Copyright (c) 2010, Anima Games, Benjamin Karaban, Laurent Schneider,
* Jérémie Comarmond, Didier Colin.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 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 RENDERER_LAYERMAPGENERATOR_H_
#define RENDERER_LAYERMAPGENERATOR_H_
#include <Gfx/IDevice.h>
#include <Renderer/Common/ShaderLib.h>
#include <Renderer/Common/ScreenQuad.h>
#include <Renderer/Common/PackedVertices.h>
#include <Renderer/IRenderer.h>
namespace Renderer
{
class LayerMapGenerator : public Core::Object
{
public:
LayerMapGenerator(const Ptr<Gfx::IDevice> & pDevice,
const Ptr<ShaderLib> & pShaderLib,
const Ptr<PackedVerticesFormat> & pFormat,
const Ptr<TextureMap> & pDefaultWhiteTexture,
const Ptr<TextureMap> & pDefaultBumpTexture);
bool initialise();
virtual Ptr<Core::Bitmap> generateFromModel(const LayerMapInfos & lm, const Ptr<IMeshInstance> & pMesh);
protected:
virtual void internalGenerateFromModel(
const LayerMapInfos & lm,
const Ptr<IMeshInstance> & pMesh,
const Ptr<Gfx::IRenderTargetView> & pView,
bool isChain,
bool isFirstLayerDetailMap);
Ptr<TextureMap> getDefaultTexture(bool isNormal);
Ptr<Gfx::IDevice> _pDevice;
Ptr<ShaderLib> _pShaderLib;
Ptr<PackedVerticesFormat> _pFormat;
Ptr<TextureMap> _pDefaultWhiteTexture;
Ptr<TextureMap> _pDefaultBumpTexture;
int32 _resolution;
bool _screenshotOn;
Gfx::GlobalRenderState _stateGen;
Ptr<Gfx::IVertexFormat> _pFormatGen;
Ptr<Gfx::IVertexShader> _pVShaderGen;
Ptr<Gfx::IPixelShader> _pPShaderGen;
int32 _idWorldGen;
int32 _idTextureSizeGen;
int32 _idIsTextureBorderOnGen;
int32 _idIsLayer1DetailLayer;
static const int32 LAYER_COUNT = 8;
int32 _idMinPos;
int32 _idRangePos;
int32 _idIsNormalMap;
int32 _idIsChain;
int32 _idMatRotationLayer;
int32 _idIsDXT5Norm[LAYER_COUNT];
int32 _idGenerateU[LAYER_COUNT];
int32 _idGenerateV[LAYER_COUNT];
int32 _idColor[LAYER_COUNT];
int32 _idSamplerSource[LAYER_COUNT];
int32 _idSamplerMask[LAYER_COUNT];
int32 _idMaskContrast[LAYER_COUNT];
int32 _idNormalStrength[LAYER_COUNT];
int32 _idMapType[LAYER_COUNT];
int32 _idSamplerSize[LAYER_COUNT]; //la taille de la texture envoyer pour generer le calque
};
}
#endif
|
//===-- Either.h -----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_Either_h_
#define liblldb_Either_h_
#include "llvm/ADT/Optional.h"
#include <functional>
namespace lldb_utility {
template <typename T1, typename T2>
class Either
{
private:
enum class Selected
{
One, Two
};
Selected m_selected;
union
{
T1 m_t1;
T2 m_t2;
};
public:
Either (const T1& t1)
{
m_t1 = t1;
m_selected = Selected::One;
}
Either (const T2& t2)
{
m_t2 = t2;
m_selected = Selected::Two;
}
Either (const Either<T1,T2>& rhs)
{
switch (rhs.m_selected)
{
case Selected::One:
m_t1 = rhs.GetAs<T1>().getValue();
m_selected = Selected::One;
break;
case Selected::Two:
m_t2 = rhs.GetAs<T2>().getValue();
m_selected = Selected::Two;
break;
}
}
template <class X, typename std::enable_if<std::is_same<T1,X>::value>::type * = nullptr>
llvm::Optional<T1>
GetAs() const
{
switch (m_selected)
{
case Selected::One:
return m_t1;
default:
return llvm::Optional<T1>();
}
}
template <class X, typename std::enable_if<std::is_same<T2,X>::value>::type * = nullptr>
llvm::Optional<T2>
GetAs() const
{
switch (m_selected)
{
case Selected::Two:
return m_t2;
default:
return llvm::Optional<T2>();
}
}
template <class ResultType>
ResultType
Apply (std::function<ResultType(T1)> if_T1,
std::function<ResultType(T2)> if_T2) const
{
switch (m_selected)
{
case Selected::One:
return if_T1(m_t1);
case Selected::Two:
return if_T2(m_t2);
}
}
bool
operator == (const Either<T1,T2>& rhs)
{
return (GetAs<T1>() == rhs.GetAs<T1>()) && (GetAs<T2>() == rhs.GetAs<T2>());
}
explicit
operator bool ()
{
switch (m_selected)
{
case Selected::One:
return (bool)m_t1;
case Selected::Two:
return (bool)m_t2;
}
}
Either<T1,T2>&
operator = (const Either<T1,T2>& rhs)
{
switch (rhs.m_selected)
{
case Selected::One:
m_t1 = rhs.GetAs<T1>().getValue();
m_selected = Selected::One;
break;
case Selected::Two:
m_t2 = rhs.GetAs<T2>().getValue();
m_selected = Selected::Two;
break;
}
return *this;
}
~Either ()
{
switch (m_selected)
{
case Selected::One:
m_t1.T1::~T1();
break;
case Selected::Two:
m_t2.T2::~T2();
break;
}
}
};
} // namespace lldb_utility
#endif // #ifndef liblldb_Either_h_
|
/*-
* Copyright (c) 2012 Chelsio Communications, 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 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.
*
* $FreeBSD$
*
*/
#ifndef __T4_TOM_L2T_H
#define __T4_TOM_L2T_H
#include "t4_l2t.h"
int t4_l2t_send_slow(struct adapter *, struct wrqe *, struct l2t_entry *);
struct l2t_entry *t4_l2t_get(struct port_info *, struct ifnet *,
struct sockaddr *);
void t4_l2_update(struct toedev *, struct ifnet *, struct sockaddr *,
uint8_t *, uint16_t);
int do_l2t_write_rpl2(struct sge_iq *, const struct rss_header *,
struct mbuf *);
static inline int
t4_l2t_send(struct adapter *sc, struct wrqe *wr, struct l2t_entry *e)
{
if (__predict_true(e->state == L2T_STATE_VALID)) {
t4_wrq_tx(sc, wr);
return (0);
} else
return (t4_l2t_send_slow(sc, wr, e));
}
#endif /* __T4_TOM_L2T_H */
|
/*
* Henry Crute
* hcrute@ucsc.edu
*
* Extra library functions for string to int and int to string
* conversions
*
*/
#ifndef __EXTRALIB_H
#define __EXTRALIB_H
#include "c_types.h"
uint64_t stringtoint(char *);
char *inttohexstring(uint64_t, char *);
#endif
|
@interface ARSearchViewController (Private)
- (void)closeSearch:(id)sender;
- (void)searchText:(NSString *)text;
@property(readonly, nonatomic) UIView *contentView;
@end
|
/*
* sha1.h --
*
* SHA1 encryption
*/
#ifndef _SHA1_H_
#define _SHA1_H_
#include "bios/c_types.h"
/*********************************************************
* Copyright (C) 1998 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation version 2.1 and no later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
*********************************************************/
/*********************************************************
* The contents of this file are subject to the terms of the Common
* Development and Distribution License (the "License") version 1.0
* and no later version. You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* http://www.opensource.org/licenses/cddl1.php
*
* See the License for the specific language governing permissions
* and limitations under the License.
*
*********************************************************/
/*
SHA-1 in C
By Steve Reid <steve@edmweb.com>
100% Public Domain
Test Vectors (from FIPS PUB 180-1)
"abc"
A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
A million repetitions of "a"
34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
*/
#define SHA1_HASH_LEN 20
typedef struct {
uint32 state[5];
uint32 count[2];
uint8 buffer[64];
} SHA1_CTX;
#define SHA1HANDSOFF /* Copies data before messing with it. */
void SHA1Init(SHA1_CTX* context);
#ifdef SHA1HANDSOFF
void SHA1Update(SHA1_CTX* context,
const uint8 *data,
size_t len);
#else
void SHA1Update(SHA1_CTX* context,
uint8 *data,
size_t len);
#endif
void SHA1Final(uint8 digest[SHA1_HASH_LEN], SHA1_CTX* context);
void SHA1Transform(uint32 state[5], const uint8 buffer[64]);
/* eagle.rom.addr.v6.ld
PROVIDE ( SHA1Final = 0x4000b648 );
PROVIDE ( SHA1Init = 0x4000b584 );
PROVIDE ( SHA1Transform = 0x4000a364 );
PROVIDE ( SHA1Update = 0x4000b5a8 );
*/
#endif // ifndef _SHA1_H_
|
//
// FKFlickrGroupsDiscussRepliesAdd.h
// FlickrKit
//
// Generated by FKAPIBuilder on 12 Jun, 2013 at 17:19.
// Copyright (c) 2013 DevedUp Ltd. All rights reserved. http://www.devedup.com
//
// DO NOT MODIFY THIS FILE - IT IS MACHINE GENERATED
#import "FKFlickrAPIMethod.h"
typedef enum {
FKFlickrGroupsDiscussRepliesAddError_TopicNotFound = 1, /* The topic_id is invalid. */
FKFlickrGroupsDiscussRepliesAddError_CannotPostToGroup = 2, /* Either this account is not a member of the group, or discussion in this group is disabled.
*/
FKFlickrGroupsDiscussRepliesAddError_MissingRequiredArguments = 3, /* The topic_id and message are required. */
FKFlickrGroupsDiscussRepliesAddError_InvalidSignature = 96, /* The passed signature was invalid. */
FKFlickrGroupsDiscussRepliesAddError_MissingSignature = 97, /* The call required signing but no signature was sent. */
FKFlickrGroupsDiscussRepliesAddError_LoginFailedOrInvalidAuthToken = 98, /* The login details or auth token passed were invalid. */
FKFlickrGroupsDiscussRepliesAddError_UserNotLoggedInOrInsufficientPermissions = 99, /* The method requires user authentication but the user was not logged in, or the authenticated method call did not have the required permissions. */
FKFlickrGroupsDiscussRepliesAddError_InvalidAPIKey = 100, /* The API key passed was not valid or has expired. */
FKFlickrGroupsDiscussRepliesAddError_ServiceCurrentlyUnavailable = 105, /* The requested service is temporarily unavailable. */
FKFlickrGroupsDiscussRepliesAddError_FormatXXXNotFound = 111, /* The requested response format was not found. */
FKFlickrGroupsDiscussRepliesAddError_MethodXXXNotFound = 112, /* The requested method was not found. */
FKFlickrGroupsDiscussRepliesAddError_InvalidSOAPEnvelope = 114, /* The SOAP envelope send in the request could not be parsed. */
FKFlickrGroupsDiscussRepliesAddError_InvalidXMLRPCMethodCall = 115, /* The XML-RPC request document could not be parsed. */
FKFlickrGroupsDiscussRepliesAddError_BadURLFound = 116, /* One or more arguments contained a URL that has been used for abuse on Flickr. */
} FKFlickrGroupsDiscussRepliesAddError;
/*
Post a new reply to a group discussion topic.
*/
@interface FKFlickrGroupsDiscussRepliesAdd : NSObject <FKFlickrAPIMethod>
/* The ID of the topic to post a comment to. */
@property (nonatomic, strong) NSString *topic_id; /* (Required) */
/* The message to post to the topic. */
@property (nonatomic, strong) NSString *message; /* (Required) */
@end
|
/*
* Test program for Allegro.
*
* Constrains the window to a minimum and or maximum.
*/
#include "allegro5/allegro.h"
#include "allegro5/allegro_image.h"
#include "allegro5/allegro_font.h"
#include "common.c"
int main(int argc, char **argv)
{
ALLEGRO_DISPLAY *display;
ALLEGRO_BITMAP *bmp;
ALLEGRO_FONT *f;
ALLEGRO_EVENT_QUEUE *queue;
ALLEGRO_EVENT event;
bool redraw;
int min_w, min_h, max_w, max_h;
int ret_min_w, ret_min_h, ret_max_w, ret_max_h;
bool constr_min_w, constr_min_h, constr_max_w, constr_max_h;
(void)argc;
(void)argv;
if (!al_init()) {
abort_example("Could not init Allegro.\n");
}
al_install_keyboard();
al_init_image_addon();
al_init_font_addon();
al_set_new_display_flags(ALLEGRO_RESIZABLE |
ALLEGRO_GENERATE_EXPOSE_EVENTS);
display = al_create_display(640, 480);
if (!display) {
abort_example("Unable to set any graphic mode\n");
}
bmp = al_load_bitmap("data/mysha.pcx");
if (!bmp) {
abort_example("Unable to load image\n");
}
f = al_load_font("data/a4_font.tga", 0, 0);
if (!f) {
abort_example("Failed to load a4_font.tga\n");
}
min_w = 640;
min_h = 480;
max_w = 800;
max_h = 600;
constr_min_w = constr_min_h = constr_max_w = constr_max_h = true;
if (!al_set_window_constraints(
display,
constr_min_w ? min_w : 0,
constr_min_h ? min_h : 0,
constr_max_w ? max_w : 0,
constr_max_h ? max_h : 0)) {
abort_example("Unable to set window constraints.\n");
}
queue = al_create_event_queue();
al_register_event_source(queue, al_get_display_event_source(display));
al_register_event_source(queue, al_get_keyboard_event_source());
redraw = true;
while (true) {
if (redraw && al_is_event_queue_empty(queue)) {
al_clear_to_color(al_map_rgb(255, 0, 0));
al_draw_scaled_bitmap(bmp,
0, 0, al_get_bitmap_width(bmp), al_get_bitmap_height(bmp),
0, 0, al_get_display_width(display), al_get_display_height(display),
0);
/* Display screen resolution */
al_draw_textf(f, al_map_rgb(255, 255, 255), 0, 0, 0,
"Resolution: %dx%d",
al_get_display_width(display), al_get_display_height(display));
if (!al_get_window_constraints(display, &ret_min_w, &ret_min_h,
&ret_max_w, &ret_max_h))
{
abort_example("Unable to get window constraints\n");
}
al_draw_textf(f, al_map_rgb(255, 255, 255), 0,
al_get_font_line_height(f), 0,
"Min Width: %d, Min Height: %d, Max Width: %d, Max Height: %d",
ret_min_w, ret_min_h, ret_max_w, ret_max_h);
al_draw_textf(f, al_map_rgb(255, 255, 255), 0,
al_get_font_line_height(f) * 2,0,
"Toggle Restriction: Min Width: Z, Min Height: X, Max Width: C, Max Height: V");
al_flip_display();
redraw = false;
}
al_wait_for_event(queue, &event);
if (event.type == ALLEGRO_EVENT_DISPLAY_RESIZE) {
al_acknowledge_resize(event.display.source);
redraw = true;
}
if (event.type == ALLEGRO_EVENT_DISPLAY_EXPOSE) {
redraw = true;
}
if (event.type == ALLEGRO_EVENT_KEY_DOWN) {
if (event.keyboard.keycode == ALLEGRO_KEY_ESCAPE) {
break;
}
else if (event.keyboard.keycode == ALLEGRO_KEY_Z) {
constr_min_w = ! constr_min_w;
}
else if (event.keyboard.keycode == ALLEGRO_KEY_X) {
constr_min_h = ! constr_min_h;
}
else if (event.keyboard.keycode == ALLEGRO_KEY_C) {
constr_max_w = ! constr_max_w;
}
else if (event.keyboard.keycode == ALLEGRO_KEY_V) {
constr_max_h = ! constr_max_h;
}
redraw = true;
if (!al_set_window_constraints(display,
constr_min_w ? min_w : 0,
constr_min_h ? min_h : 0,
constr_max_w ? max_w : 0,
constr_max_h ? max_h : 0)) {
abort_example("Unable to set window constraints.\n");
}
}
if (event.type == ALLEGRO_EVENT_DISPLAY_CLOSE) {
break;
}
}
al_destroy_bitmap(bmp);
al_destroy_display(display);
return 0;
}
/* vim: set sts=3 sw=3 et: */
|
/* Copyright The kNet Project.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
/** @file SerializedDataIterator.h
@brief The SerializedDataIterator class. */
#include "SharedPtr.h"
#include "MessageListParser.h"
namespace kNet
{
class SerializedDataIterator : public RefCountable
{
public:
SerializedDataIterator(const SerializedMessageDesc &desc_)
:desc(desc_)
{
ResetTraversal();
}
BasicSerializedDataType NextElementType() const;
const SerializedElementDesc *NextElementDesc() const;
void ProceedToNextVariable();
void ProceedNVariables(int count);
/// Sets the number of instances in a varying element. When iterating over
/// the message to insert data into serialized form, this information needs
/// to be passed to this iterator in order to continue.
void SetVaryingElemSize(u32 count);
void ResetTraversal();
private:
struct ElemInfo
{
/// The element we are accessing next.
SerializedElementDesc *elem;
/// The index of the elem we are accessing next.
int nextElem;
/// The index of the instance we are accessing next.
int nextIndex;
/// The total number of instances of this element we are accessing.
int count;
/// If this element is a dynamic count -one, then this tracks whether the count has been passed in.
bool dynamicCountSpecified;
};
void ProceedToNextElement();
void DescendIntoStructure();
/// Stores the tree traversal progress.
std::vector<ElemInfo> currentElementStack;
/// The type of the message we are building.
const SerializedMessageDesc &desc;
};
} // ~kNet
|
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
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.
****************************************************************************/
#ifndef __CCX_PROTOCOL_SOCIAL_H__
#define __CCX_PROTOCOL_SOCIAL_H__
#include "PluginProtocol.h"
#include <map>
#include <string>
#include <functional>
namespace cocos2d { namespace plugin {
typedef std::map<std::string, std::string> TSocialDeveloperInfo;
typedef std::map<std::string, std::string> TAchievementInfo;
typedef enum
{
// code for leaderboard feature
SCORE_SUBMIT_SUCCESS = 1,
SCORE_SUBMIT_FAILED,
// code for achievement feature
ACH_UNLOCK_SUCCESS,
ACH_UNLOCK_FAILED,
} SocialRetCode;
class SocialListener
{
public:
virtual void onSocialResult(SocialRetCode code, const char* msg) = 0;
};
class ProtocolSocial : public PluginProtocol
{
public:
ProtocolSocial();
virtual ~ProtocolSocial();
typedef std::function<void(int, std::string&)> ProtocolSocialCallback;
/**
@brief config the share developer info
@param devInfo This parameter is the info of developer,
different plugin have different format
@warning Must invoke this interface before other interfaces.
And invoked only once.
*/
void configDeveloperInfo(TSocialDeveloperInfo devInfo);
/**
* @brief methods of leaderboard feature
*/
void submitScore(const char* leadboardID, long score);
void submitScore(const char* leadboardID, long score, ProtocolSocialCallback cb);
void showLeaderboard(const char* leaderboardID);
/**
* @brief methods of achievement feature
*/
void unlockAchievement(TAchievementInfo achInfo);
void unlockAchievement(TAchievementInfo achInfo, ProtocolSocialCallback cb);
void showAchievements();
/*
@deprecated
@brief set listener
*/
CC_DEPRECATED_ATTRIBUTE inline void setListener(SocialListener* listener) {
_listener = listener;
}
/*
@deprecated
@brief get listener
*/
CC_DEPRECATED_ATTRIBUTE inline SocialListener* getListener()
{
return _listener;
}
/*
@brief set callback function
*/
inline void setCallback(ProtocolSocialCallback &cb)
{
_callback = cb;
}
/*
@brief get callback function
*/
inline ProtocolSocialCallback& getCallback()
{
return _callback;
}
protected:
SocialListener* _listener;
ProtocolSocialCallback _callback;
};
}} // namespace cocos2d { namespace plugin {
#endif /* ----- #ifndef __CCX_PROTOCOL_SOCIAL_H__ ----- */
|
/*
* Generated by class-dump 3.4 (64 bit).
*
* class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2012 by Steve Nygard.
*/
#import "DVTGenericButtonViewController.h"
@class DVTObservingToken;
@interface IDEMiniDebuggerToolbarConsoleViewController : DVTGenericButtonViewController
{
DVTObservingToken *_debugSessionStateObserverToken;
DVTObservingToken *_debuggingWindowBehaviorObservingToken;
}
- (void).cxx_destruct;
- (void)_updateForDebuggingKVOChange:(id)arg1;
- (id)initWithButton:(id)arg1 actionBlock:(id)arg2 setupTeardownBlock:(void)arg3 itemIdentifier:(id)arg4 window:(void)arg5;
- (void)primitiveInvalidate;
@end
|
/*
Copyright (C) 2011- 2012 Reetu Raj (reetu.raj@gmail.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.
*///
// MIMColor.h
// MIMChartLib
//
// Created by Reetu Raj on 11/08/11.
// Copyright (c) 2012 __MIM 2D__. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "MIMColorClass.h"
@interface MIMColor : NSObject {
}
+(MIMColorClass *)GetMIMColorAtIndex:(int)index;
+(NSDictionary *)GetColorAtIndex:(int)index;
+(void)InitColors;
+(void)InitGreenTintColors;
+(void)InitFragmentedBarColors;
+(NSInteger)sizeOfColorArray;
+(void)nonAdjacentGradient;
+(void)lightGradients;
+(void)nonAdjacentPlainColors;
@end
|
#include <stdio.h>
main()
{
int c, i, nwhite, nother, ndigit[10];
nwhite = nother = 0;
for (i = 0; i < 10; i++) {
ndigit[i] = 0;
}
while ((c = getchar()) != EOF) {
switch (c) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
ndigit[c-'0']++;
break;
case ' ':
case '\n':
case '\t':
nwhite++;
break;
default:
nother++;
break;
}
}
printf("digits = ");
for (i = 0; i< 10; i++)
printf(" %d", ndigit[i]);
printf(", white space = %d, other = %d\n", nwhite, nother);
return 0;
}
|
//
// DownloadProgressView.h
// VideoDownloader
//
// Created by Jack Cox on 4/7/12.
//
//
#import <UIKit/UIKit.h>
#define kShowProgressView @"showProgressView"
#define kHideProgressView @"hideProgressView"
@interface DownloadProgressView : UIView {
// total number of bytes to download
long long amountToDownload;
// total number of bytes downloaded this far
long long amountDownloaded;
}
@property (weak, nonatomic) IBOutlet UIProgressView *progressBar;
@property (assign) BOOL hidden;
// Called on the start of a file download to increment the total amount needed
- (void) addAmountToDownload:(long long)amountToDownload;
// Called on each chunk of data to increment how much has been downloaded
- (void) addAmountDownloaded:(long long)amountDownloaded;
@end
|
/*************************************************************************
Crytek Source File.
Copyright (C), Crytek Studios, 2001-2004.
-------------------------------------------------------------------------
$Id: RealtimeRemoveUpdate.h,v 1.1 2009/01/03 10:45:15 PauloZaffari Exp wwwrun $
$DateTime$
Description: This is the header file for the module Realtime remote
update. The purpose of this module is to allow data update to happen
remotely so that you can, for example, edit the terrain and see the changes
in the console.
-------------------------------------------------------------------------
History:
- 03:01:2009 10:45: Created by Paulo Zaffari
*************************************************************************/
#ifndef RealtimeRemoteUpdate_h__
#define RealtimeRemoteUpdate_h__
#pragma once
#include "INotificationNetwork.h"
#include "IRealtimeRemoteUpdate.h"
#include "I3DEngine.h"
typedef std::vector<IRealtimeUpdateGameHandler*> GameHandlerList;
class CRealtimeRemoteUpdateListener : public INotificationNetworkListener, public IRealtimeRemoteUpdate
{
//////////////////////////////////////////////////////////////////////////
// Methods
public:
// From IRealtimeRemoteUpdate
virtual bool Enable(bool boEnable=true);
virtual bool IsEnabled();
// Game code handlers for live preview updates
virtual void AddGameHandler(IRealtimeUpdateGameHandler * handler);
virtual void RemoveGameHandler(IRealtimeUpdateGameHandler * handler);
// From INotificationNetworkListener and from IRealtimeRemoteUpdate
virtual void OnNotificationNetworkReceive(const void *pBuffer, size_t length);
// Singleton management
static CRealtimeRemoteUpdateListener& GetRealtimeRemoteUpdateListener();
virtual void Update();
protected:
CRealtimeRemoteUpdateListener();
virtual ~CRealtimeRemoteUpdateListener();
void LoadArchetypes(XmlNodeRef &root);
void LoadTimeOfDay( XmlNodeRef &root );
void LoadMaterials( XmlNodeRef &root );
void LoadConsoleVariables(XmlNodeRef &root );
void LoadParticles(XmlNodeRef &root );
void LoadTerrainLayer(XmlNodeRef &root, unsigned char* uchData);
void LoadEntities( XmlNodeRef &root );
bool IsSyncingWithEditor();
//////////////////////////////////////////////////////////////////////////
// Data
protected:
// As currently you can't query if the currently listener is registered
// the control has to be done here.
bool m_boIsEnabled;
GameHandlerList m_gameHandlers;
CTimeValue m_lastKeepAliveMessageTime;
typedef std::vector<unsigned char> TDBuffer;
CryMT::CLocklessPointerQueue<TDBuffer> m_ProcessingQueue;
};
#endif // RealtimeRemoteUpdate_h__
|
#ifndef _VIDEO_OPS_H
#define _VIDEO_OPS_H
#include "video/color.h"
#include "video/surface.h"
#include <SDL2/SDL.h>
typedef struct video_state_t video_state;
typedef void (*render_close_cb)(video_state *state);
typedef void (*render_reinit_cb)(video_state *state);
typedef void (*render_prepare_cb)(video_state *state);
typedef void (*render_finish_cb)(video_state *state);
typedef void (*render_background_cb)(
video_state *state,
surface *sur);
typedef void (*render_sprite_fsot_cb)(
video_state *state,
surface *sur,
SDL_Rect *dst,
SDL_BlendMode blend_mode,
int pal_offset,
SDL_RendererFlip flip_mode,
uint8_t opacity,
color tint);
typedef struct video_render_cbs_t {
render_close_cb render_close;
render_reinit_cb render_reinit;
render_prepare_cb render_prepare;
render_finish_cb render_finish;
render_sprite_fsot_cb render_fsot;
render_background_cb render_background;
} video_render_cbs;
#endif // _VIDEO_OPS_H
|
//
// NSError+FSClassExtensions.h
//
// The MIT License (MIT)
//
// Copyright (c) 2014 FocalShift
//
// 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 <Foundation/Foundation.h>
FOUNDATION_EXPORT NSString *const FSClassExtensionsErrorDomian;
FOUNDATION_EXPORT NSInteger const FSClassExtensionsFailedToCreateImageDestination;
FOUNDATION_EXPORT NSInteger const FSClassExtensionsFailedToFinailzeImageDestination;
|
// http://www.spoj.com/problems/TDKPRIME
#include <stdio.h>
#include <stdlib.h>
#define MAX 86044176
#define SQRT 9267
#define isp(n) (seive[n>>6]&(1<<((n>>1)&31)))
#define setp(n) (seive[n>>6]|=(1<<((n>>1)&31)))
int seive[MAX >> 6] = {0};
int primes[5000100];
int main(void) {
int i, j, k;
for (i = 3; i < SQRT; i+=2) {
if (!isp(i)) {
for (j = i*i, k = i << 1; j < MAX; j+=k) {
setp(j);
}
}
}
int c = 2;
primes[1] = 2;
for (i = 3; i < MAX && c <= 5000000; i+=2) {
if (!isp(i))
primes[c++] = i;
}
int n, q;
scanf("%d", &q);
while (q--) {
scanf("%d", &n);
printf("%d\n", primes[n]);
}
return 0;
}
|
#include <heman.h>
#include "hut.h"
#define COUNT(a) (sizeof(a) / sizeof(a[0]))
#define OUTFOLDER "build/"
#define HEIGHT 128
static int CP_LOCATIONS[] = {
000, // Dark Blue
126, // Light Blue
127, // Yellow
150, // Dark Green
170, // Brown
200, // Brown
240, // White
255, // White
};
static heman_color CP_COLORS[] = {
0x001070, // Dark Blue
0x2C5A7C, // Light Blue
0xE0F0A0, // Yellow
0x5D943C, // Dark Green
0x606011, // Brown
0x606011, // Brown
0xFFFFFF, // White
0xFFFFFF, // White
};
static float LIGHTPOS[] = {-0.5f, 0.5f, 1.0f};
heman_image* make_planet(int seed, heman_image* grad)
{
heman_image* hmap =
heman_generate_planet_heightmap(HEIGHT * 2, HEIGHT, seed);
heman_image* albedo = heman_color_apply_gradient(hmap, -0.5, 0.5, grad);
heman_image* planet =
heman_lighting_apply(hmap, albedo, 1, 1, 0.75, LIGHTPOS);
heman_image_destroy(hmap);
heman_image_destroy(albedo);
return planet;
}
heman_image* make_island(int seed, heman_image* grad)
{
heman_image* hmap = heman_generate_island_heightmap(HEIGHT, HEIGHT, seed);
heman_image* albedo = heman_color_apply_gradient(hmap, -0.5, 0.5, grad);
heman_image* island =
heman_lighting_apply(hmap, albedo, 1, 1, 0.75, LIGHTPOS);
heman_image_destroy(hmap);
heman_image_destroy(albedo);
return island;
}
int main(int argc, char** argv)
{
heman_image* grad = heman_color_create_gradient(
256, COUNT(CP_COLORS), CP_LOCATIONS, CP_COLORS);
heman_image* tiles[4];
tiles[0] = make_planet(1000, grad);
tiles[1] = make_planet(1001, grad);
heman_image* planets = heman_ops_stitch_vertical(tiles, 2);
heman_image_destroy(tiles[0]);
heman_image_destroy(tiles[1]);
tiles[0] = make_island(1000, grad);
tiles[1] = make_island(1001, grad);
tiles[2] = make_island(1002, grad);
tiles[3] = make_island(1003, grad);
heman_image* rows[2];
rows[0] = heman_ops_stitch_horizontal(tiles, 2);
rows[1] = heman_ops_stitch_horizontal(tiles + 2, 2);
heman_image* islands = heman_ops_stitch_vertical(rows, 2);
heman_image_destroy(tiles[0]);
heman_image_destroy(tiles[1]);
heman_image_destroy(tiles[2]);
heman_image_destroy(tiles[3]);
heman_image_destroy(rows[0]);
heman_image_destroy(rows[1]);
tiles[0] = planets;
tiles[1] = islands;
heman_image* final = heman_ops_stitch_horizontal(tiles, 2);
heman_image_destroy(planets);
heman_image_destroy(islands);
hut_write_image(OUTFOLDER "stitched.png", final, 0, 1);
heman_image_destroy(final);
heman_image_destroy(grad);
}
|
//
// AppDelegate.h
// JSPatchHotfix
//
// Created by bob on 2017/5/29.
// Copyright © 2017年 wenbobao. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
|
@import Foundation;
#import "DATAStack.h"
@interface APIClient : NSObject
- (void)fetchStoryUsingDataStack:(DATAStack *)dataStack;
@end
|
//
// MenuButton.h
// JackFastKit
//
// Created by 曾 宪华 on 14-10-13.
// Copyright (c) 2014年 嗨,我是曾宪华(@xhzengAIB),曾加入YY Inc.担任高级移动开发工程师,拍立秀App联合创始人,热衷于简洁、而富有理性的事物 QQ:543413507 主页:http://zengxianhua.com All rights reserved.
//
// ==========================================
// MenuButton 菜单视图 UIView 处理点击事件等
// ==========================================
#import <UIKit/UIKit.h>
@class MenuItem;
typedef void(^DidSelctedItemCompletedBlock)(MenuItem *menuItem);
@interface MenuButton : UIView
/**
* 点击操作
*/
@property (nonatomic, copy) DidSelctedItemCompletedBlock didSelctedItemCompleted;
#pragma mark - init
- (instancetype)initWithFrame:(CGRect)frame menuItem:(MenuItem *)menuItem;
@end
|
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
FOUNDATION_EXPORT double Pods_CocoaPodsVerificationVersionNumber;
FOUNDATION_EXPORT const unsigned char Pods_CocoaPodsVerificationVersionString[];
|
/*
Copyright (c) 2015, Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
3. Neither the name of the copyright holder(s) nor the names of any contributors
may be used to endorse or promote products derived from this software without
specific prior written permission. No license is granted to the trademarks of
the copyright holders even if such marks are included in this software.
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 <ResearchKit/ORKRecorder.h>
NS_ASSUME_NONNULL_BEGIN
/**
The `ORKDeviceMotionRecorder` class represents a recorder that requests and collects device motion data from CoreMotion at a fixed frequency.
To ensure that the motion recorder continues to record when the app enters the
background, use the background task support provided by `UIApplication`.
*/
ORK_CLASS_AVAILABLE
@interface ORKDeviceMotionRecorder : ORKRecorder
/**
* The frequency of motion data collection from CoreMotion in hertz (Hz).
*/
@property (nonatomic, readonly) double frequency;
/**
Returns an initialized device motion recorder using the specified frequency.
@param identifier The unique identifier of the recorder (assigned by the recorder configuration).
@param frequency The frequency of motion data collection from CoreMotion in hertz (Hz).
@param step The step that requested this recorder.
@param outputDirectory The directory in which the device motion data should be stored.
@return An initialized motion data recorder.
*/
- (instancetype)initWithIdentifier:(NSString *)identifier
frequency:(double)frequency
step:(nullable ORKStep *)step
outputDirectory:(nullable NSURL *)outputDirectory NS_DESIGNATED_INITIALIZER;
@end
NS_ASSUME_NONNULL_END
|
/*
* Generated by class-dump 3.4 (64 bit).
*
* class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2012 by Steve Nygard.
*/
#import "NSObject.h"
#import "DVTCancellable.h"
@class IDESourceControlRequest, NSString;
@interface IDESourceControlMultipleStepInvalidationToken : NSObject <DVTCancellable>
{
IDESourceControlRequest *_currentRequest;
BOOL _isCancelled;
}
- (void).cxx_destruct;
- (void)cancel;
@property __weak IDESourceControlRequest *currentRequest; // @synthesize currentRequest=_currentRequest;
- (id)init;
@property(readonly, getter=isCancelled) BOOL cancelled;
// Remaining properties
@property(readonly, copy) NSString *debugDescription;
@property(readonly, copy) NSString *description;
@property(readonly) unsigned long long hash;
@property(readonly) Class superclass;
@end
|
/**********************************************************************
Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
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.
********************************************************************/
/**
\file intersector_skip_links.h
\author Dmitry Kozlov
\version 1.0
\brief Intersector implementation based on BVH with skip links.
IntersectorSkipLinks implementation is based on the following paper:
"Efficiency Issues for Ray Tracing" Brian Smits
http://www.cse.chalmers.se/edu/year/2016/course/course/TDA361/EfficiencyIssuesForRayTracing.pdf
Intersector is using binary BVH with a single bounding box per node. BVH layout guarantees
that left child of an internal node lies right next to it in memory. Each BVH node has a
skip link to the node traversed next. The traversal pseude code is
while(addr is valid)
{
node <- fetch next node at addr
if (rays intersects with node bbox)
{
if (node is leaf)
intersect leaf
else
{
addr <- addr + 1 (follow left child)
continue
}
}
addr <- skiplink at node (follow next)
}
Pros:
-Simple and efficient kernel with low VGPR pressure.
-Can traverse trees of arbitrary depth.
Cons:
-Travesal order is fixed, so poor algorithmic characteristics.
-Does not benefit from BVH quality optimizations.
*/
#pragma once
#include "calc.h"
#include "device.h"
#include "intersector.h"
#include <memory>
namespace RadeonRays
{
class Bvh;
/**
\brief Intersector implementation using skip links BVH
*/
class IntersectorSkipLinks : public Intersector
{
public:
// Constructor
IntersectorSkipLinks(Calc::Device* device);
private:
// Preprocess implementation
void Process(World const& world) override;
// Intersection implementation
void Intersect(std::uint32_t queue_idx, Calc::Buffer const *rays, Calc::Buffer const *num_rays,
std::uint32_t max_rays, Calc::Buffer *hits,
Calc::Event const *wait_event, Calc::Event **event) const override;
// Occulusion implementation
void Occluded(std::uint32_t queue_idx, Calc::Buffer const *rays, Calc::Buffer const *num_rays,
std::uint32_t max_rays, Calc::Buffer *hits,
Calc::Event const *wait_event, Calc::Event **event) const override;
private:
struct GpuData;
// Implementation data
std::unique_ptr<GpuData> m_gpudata;
// Bvh data structure
std::unique_ptr<Bvh> m_bvh;
};
}
|
//
// SeeURL.h
// SeeURL
//
// Created by Alsey Coleman Miller on 12/6/15.
// Copyright © 2015 PureSwift. All rights reserved.
//
#import "cURLSwift.h"
|
/*
* Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
#ifndef B2_SHAPE_H
#define B2_SHAPE_H
#include <Box2D/Common/b2BlockAllocator.h>
#include <Box2D/Common/b2Math.h>
#include <Box2D/Collision/b2Collision.h>
/// This holds the mass data computed for a shape.
struct b2MassData
{
/// The mass of the shape, usually in kilograms.
float32 mass;
/// The position of the shape's centroid relative to the shape's origin.
b2Vec2 center;
/// The rotational inertia of the shape about the local origin.
float32 I;
};
/// A shape is used for collision detection. You can create a shape however you like.
/// Shapes used for simulation in b2World are created automatically when a b2Fixture
/// is created. Shapes may encapsulate a one or more child shapes.
class b2Shape
{
public:
enum Type
{
e_unknown= -1,
e_circle = 0,
e_edge = 1,
e_polygon = 2,
e_loop = 3,
e_typeCount = 4,
};
b2Shape() { m_type = e_unknown; }
virtual ~b2Shape() {}
/// Clone the concrete shape using the provided allocator.
virtual b2Shape* Clone(b2BlockAllocator* allocator) const = 0;
/// Get the type of this shape. You can use this to down cast to the concrete shape.
/// @return the shape type.
Type GetType() const;
/// Get the number of child primitives.
virtual int32 GetChildCount() const = 0;
/// Test a point for containment in this shape. This only works for convex shapes.
/// @param xf the shape world transform.
/// @param p a point in world coordinates.
virtual bool TestPoint(const b2Transform& xf, const b2Vec2& p) const = 0;
/// Cast a ray against a child shape.
/// @param output the ray-cast results.
/// @param input the ray-cast input parameters.
/// @param transform the transform to be applied to the shape.
/// @param childIndex the child shape index
virtual bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
const b2Transform& transform, int32 childIndex) const = 0;
/// Given a transform, compute the associated axis aligned bounding box for a child shape.
/// @param aabb returns the axis aligned box.
/// @param xf the world transform of the shape.
/// @param childIndex the child shape
virtual void ComputeAABB(b2AABB* aabb, const b2Transform& xf, int32 childIndex) const = 0;
/// Compute the mass properties of this shape using its dimensions and density.
/// The inertia tensor is computed about the local origin.
/// @param massData returns the mass data for this shape.
/// @param density the density in kilograms per meter squared.
virtual void ComputeMass(b2MassData* massData, float32 density) const = 0;
Type m_type;
float32 m_radius;
};
inline b2Shape::Type b2Shape::GetType() const
{
return m_type;
}
#endif
|
/*
* Copyright 2012 Aarhus University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ABSTRACTINPUTGENERATOR_H
#define ABSTRACTINPUTGENERATOR_H
#include <QObject>
#include <QList>
#include <QSharedPointer>
#include "runtime/browser/executionresult.h"
#include "runtime/worklist/worklist.h"
#include "runtime/browser/webkitexecutor.h"
namespace artemis
{
class InputGeneratorStrategy : public QObject
{
Q_OBJECT
public:
InputGeneratorStrategy(QObject* parent) : QObject(parent) {}
virtual ~InputGeneratorStrategy() {}
virtual QList<QSharedPointer<ExecutableConfiguration> > addNewConfigurations(QSharedPointer<const ExecutableConfiguration>, QSharedPointer<const ExecutionResult>) = 0;
};
}
#endif // ABSTRACTINPUTGENERATOR_H
|
// RUN: %tool "%s" > "%t"
// RUN: %diff %CORRECT "%t"
int x;
int y;
int bar()
ensures x == \old(x) + 1
{
x = x + 1;
return 0;
}
int main()
{
x = 0;
while(x < 10) {
int t;
t = bar();
}
assert x == 10;
return 0;
}
|
//
// AVFooterRefresh.h
// AVRefreshExtension
//
// Created by 周济 on 16/1/13.
// Copyright © 2016年 swiftTest. All rights reserved.
//
#import "AVRefreshExtension.h"
#import "AVRefresh.h"
@interface AVFooterRefresh : AVRefresh
+ (instancetype)createFooterWithRefreshingBlock:(AVRefreshRefreshingBlock)refreshingBlock scrollView:(UIScrollView *)scrollView;
@end
|
#if defined(PEGASUS_OS_HPUX)
# include "UNIX_SystemSettingContextDeps_HPUX.h"
#elif defined(PEGASUS_OS_LINUX)
# include "UNIX_SystemSettingContextDeps_LINUX.h"
#elif defined(PEGASUS_OS_DARWIN)
# include "UNIX_SystemSettingContextDeps_DARWIN.h"
#elif defined(PEGASUS_OS_AIX)
# include "UNIX_SystemSettingContextDeps_AIX.h"
#elif defined(PEGASUS_OS_FREEBSD)
# include "UNIX_SystemSettingContextDeps_FREEBSD.h"
#elif defined(PEGASUS_OS_SOLARIS)
# include "UNIX_SystemSettingContextDeps_SOLARIS.h"
#elif defined(PEGASUS_OS_ZOS)
# include "UNIX_SystemSettingContextDeps_ZOS.h"
#elif defined(PEGASUS_OS_VMS)
# include "UNIX_SystemSettingContextDeps_VMS.h"
#elif defined(PEGASUS_OS_TRU64)
# include "UNIX_SystemSettingContextDeps_TRU64.h"
#else
# include "UNIX_SystemSettingContextDeps_STUB.h"
#endif
|
/*
Module : AAPhysicalMars.h
Purpose: Implementation for the algorithms which obtain the physical parameters of Mars
Created: PJN / 04-01-2004
Copyright (c) 2003 - 2019 by PJ Naughter (Web: www.naughter.com, Email: pjna@naughter.com)
All rights reserved.
Copyright / Usage Details:
You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise)
when your product is released in binary form. You are allowed to modify the source code in any way you want
except you cannot modify the copyright details at the top of each module. If you want to distribute source
code with your application, then you are only allowed to distribute versions released by the author. This is
to maintain a single distribution point for the source code.
*/
/////////////////////// Macros / Defines //////////////////////////////////////
#if _MSC_VER > 1000
#pragma once
#endif //#if _MSC_VER > 1000
#ifndef __AAPHYSICALMARS_H__
#define __AAPHYSICALMARS_H__
#ifndef AAPLUS_EXT_CLASS
#define AAPLUS_EXT_CLASS
#endif //#ifndef AAPLUS_EXT_CLASS
/////////////////////// Classes ///////////////////////////////////////////////
class AAPLUS_EXT_CLASS CAAPhysicalMarsDetails
{
public:
CAAPhysicalMarsDetails() noexcept : DE(0),
DS(0),
w(0),
P(0),
X(0),
k(0),
q(0),
d(0)
{
};
//Member variables
double DE;
double DS;
double w;
double P;
double X;
double k;
double q;
double d;
};
class AAPLUS_EXT_CLASS CAAPhysicalMars
{
public:
//Static methods
static CAAPhysicalMarsDetails Calculate(double JD, bool bHighPrecision) noexcept;
};
#endif //#ifndef __AAPHYSICALMARS_H__
|
/*
* CRC32 code derived from work by Gary S. Brown.
*/
/*
* Pre-populated Table used for calculating CRC32.
*/
static const unsigned int crc_32_tab[] =
{
0x00000000L, 0x77073096L, 0xEE0E612CL, 0x990951BAL, 0x076DC419L, 0x706AF48FL, 0xE963A535L, 0x9E6495A3L,
0x0EDB8832L, 0x79DCB8A4L, 0xE0D5E91EL, 0x97D2D988L, 0x09B64C2BL, 0x7EB17CBDL, 0xE7B82D07L, 0x90BF1D91L,
0x1DB71064L, 0x6AB020F2L, 0xF3B97148L, 0x84BE41DEL, 0x1ADAD47DL, 0x6DDDE4EBL, 0xF4D4B551L, 0x83D385C7L,
0x136C9856L, 0x646BA8C0L, 0xFD62F97AL, 0x8A65C9ECL, 0x14015C4FL, 0x63066CD9L, 0xFA0F3D63L, 0x8D080DF5L,
0x3B6E20C8L, 0x4C69105EL, 0xD56041E4L, 0xA2677172L, 0x3C03E4D1L, 0x4B04D447L, 0xD20D85FDL, 0xA50AB56BL,
0x35B5A8FAL, 0x42B2986CL, 0xDBBBC9D6L, 0xACBCF940L, 0x32D86CE3L, 0x45DF5C75L, 0xDCD60DCFL, 0xABD13D59L,
0x26D930ACL, 0x51DE003AL, 0xC8D75180L, 0xBFD06116L, 0x21B4F4B5L, 0x56B3C423L, 0xCFBA9599L, 0xB8BDA50FL,
0x2802B89EL, 0x5F058808L, 0xC60CD9B2L, 0xB10BE924L, 0x2F6F7C87L, 0x58684C11L, 0xC1611DABL, 0xB6662D3DL,
0x76DC4190L, 0x01DB7106L, 0x98D220BCL, 0xEFD5102AL, 0x71B18589L, 0x06B6B51FL, 0x9FBFE4A5L, 0xE8B8D433L,
0x7807C9A2L, 0x0F00F934L, 0x9609A88EL, 0xE10E9818L, 0x7F6A0DBBL, 0x086D3D2DL, 0x91646C97L, 0xE6635C01L,
0x6B6B51F4L, 0x1C6C6162L, 0x856530D8L, 0xF262004EL, 0x6C0695EDL, 0x1B01A57BL, 0x8208F4C1L, 0xF50FC457L,
0x65B0D9C6L, 0x12B7E950L, 0x8BBEB8EAL, 0xFCB9887CL, 0x62DD1DDFL, 0x15DA2D49L, 0x8CD37CF3L, 0xFBD44C65L,
0x4DB26158L, 0x3AB551CEL, 0xA3BC0074L, 0xD4BB30E2L, 0x4ADFA541L, 0x3DD895D7L, 0xA4D1C46DL, 0xD3D6F4FBL,
0x4369E96AL, 0x346ED9FCL, 0xAD678846L, 0xDA60B8D0L, 0x44042D73L, 0x33031DE5L, 0xAA0A4C5FL, 0xDD0D7CC9L,
0x5005713CL, 0x270241AAL, 0xBE0B1010L, 0xC90C2086L, 0x5768B525L, 0x206F85B3L, 0xB966D409L, 0xCE61E49FL,
0x5EDEF90EL, 0x29D9C998L, 0xB0D09822L, 0xC7D7A8B4L, 0x59B33D17L, 0x2EB40D81L, 0xB7BD5C3BL, 0xC0BA6CADL,
0xEDB88320L, 0x9ABFB3B6L, 0x03B6E20CL, 0x74B1D29AL, 0xEAD54739L, 0x9DD277AFL, 0x04DB2615L, 0x73DC1683L,
0xE3630B12L, 0x94643B84L, 0x0D6D6A3EL, 0x7A6A5AA8L, 0xE40ECF0BL, 0x9309FF9DL, 0x0A00AE27L, 0x7D079EB1L,
0xF00F9344L, 0x8708A3D2L, 0x1E01F268L, 0x6906C2FEL, 0xF762575DL, 0x806567CBL, 0x196C3671L, 0x6E6B06E7L,
0xFED41B76L, 0x89D32BE0L, 0x10DA7A5AL, 0x67DD4ACCL, 0xF9B9DF6FL, 0x8EBEEFF9L, 0x17B7BE43L, 0x60B08ED5L,
0xD6D6A3E8L, 0xA1D1937EL, 0x38D8C2C4L, 0x4FDFF252L, 0xD1BB67F1L, 0xA6BC5767L, 0x3FB506DDL, 0x48B2364BL,
0xD80D2BDAL, 0xAF0A1B4CL, 0x36034AF6L, 0x41047A60L, 0xDF60EFC3L, 0xA867DF55L, 0x316E8EEFL, 0x4669BE79L,
0xCB61B38CL, 0xBC66831AL, 0x256FD2A0L, 0x5268E236L, 0xCC0C7795L, 0xBB0B4703L, 0x220216B9L, 0x5505262FL,
0xC5BA3BBEL, 0xB2BD0B28L, 0x2BB45A92L, 0x5CB36A04L, 0xC2D7FFA7L, 0xB5D0CF31L, 0x2CD99E8BL, 0x5BDEAE1DL,
0x9B64C2B0L, 0xEC63F226L, 0x756AA39CL, 0x026D930AL, 0x9C0906A9L, 0xEB0E363FL, 0x72076785L, 0x05005713L,
0x95BF4A82L, 0xE2B87A14L, 0x7BB12BAEL, 0x0CB61B38L, 0x92D28E9BL, 0xE5D5BE0DL, 0x7CDCEFB7L, 0x0BDBDF21L,
0x86D3D2D4L, 0xF1D4E242L, 0x68DDB3F8L, 0x1FDA836EL, 0x81BE16CDL, 0xF6B9265BL, 0x6FB077E1L, 0x18B74777L,
0x88085AE6L, 0xFF0F6A70L, 0x66063BCAL, 0x11010B5CL, 0x8F659EFFL, 0xF862AE69L, 0x616BFFD3L, 0x166CCF45L,
0xA00AE278L, 0xD70DD2EEL, 0x4E048354L, 0x3903B3C2L, 0xA7672661L, 0xD06016F7L, 0x4969474DL, 0x3E6E77DBL,
0xAED16A4AL, 0xD9D65ADCL, 0x40DF0B66L, 0x37D83BF0L, 0xA9BCAE53L, 0xDEBB9EC5L, 0x47B2CF7FL, 0x30B5FFE9L,
0xBDBDF21CL, 0xCABAC28AL, 0x53B39330L, 0x24B4A3A6L, 0xBAD03605L, 0xCDD70693L, 0x54DE5729L, 0x23D967BFL,
0xB3667A2EL, 0xC4614AB8L, 0x5D681B02L, 0x2A6F2B94L, 0xB40BBE37L, 0xC30C8EA1L, 0x5A05DF1BL, 0x2D02EF8DL
};
static unsigned int CalculateCRC32(unsigned int bufferCRC, size_t data)
{
/* update running CRC calculation with contents of a buffer */
bufferCRC = bufferCRC ^ 0xffffffffL;
bufferCRC = crc_32_tab[(bufferCRC ^ data) & 0xFF] ^ (bufferCRC >> 8);
return (bufferCRC ^ 0xffffffffL);
}
|
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) Steven Lovegrove
*
* 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.
*/
#pragma once
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pybind11/embed.h>
#include "attach.hpp"
#include "colour.hpp"
#include "datalog.hpp"
#include "display.hpp"
#include "gl.hpp"
#include "glsl.hpp"
#include "gl_draw.hpp"
#include "handler.hpp"
#include "image.hpp"
#include "opengl_render_state.hpp"
#include "params.hpp"
#include "pixel_format.hpp"
#include "plotter.hpp"
#include "var.hpp"
#include "video.hpp"
#include "view.hpp"
#include "viewport.hpp"
#include "widget.hpp"
#include "window.hpp"
#include "image_view.hpp"
namespace pypangolin {
inline void PopulateModule(pybind11::module& m)
{
m.doc() = "pypangolin python wrapper for Pangolin rapid prototyping graphics and video library.";
py_pangolin::bind_var(m);
py_pangolin::bind_params(m);
py_pangolin::bind_viewport(m);
py_pangolin::bind_view(m);
py_pangolin::bind_window(m);
py_pangolin::bind_display(m);
py_pangolin::bind_opengl_render_state(m);
py_pangolin::bind_attach(m);
py_pangolin::bind_colour(m);
py_pangolin::bind_datalog(m);
py_pangolin::bind_plotter(m);
py_pangolin::bind_handler(m);
py_pangolin::bind_gl(m);
py_pangolin::bind_glsl(m);
py_pangolin::bind_gl_draw(m);
py_pangolin::bind_widget(m);
py_pangolin::bind_pixel_format(m);
py_pangolin::bind_image<unsigned char>(m, "Image");
py_pangolin::bind_video(m);
py_pangolin::bind_image_view(m);
}
}
|
#ifndef _WLC_LOGIND_H_
#define _WLC_LOGIND_H_
#if HAS_LOGIND
/** Use wlc_fd_open instead, it automatically calls this if logind is used. */
int wlc_logind_open(const char *path, int flags);
/** Use wlc_fd_close instead, it automatically calls this if logind is used. */
void wlc_logind_close(int fd);
/** Check if logind is available. */
bool wlc_logind_available(void);
void wlc_logind_terminate(void);
int wlc_logind_init(const char *seat_id);
#else
/** For convenience. */
static inline bool wlc_logind_available(void) { return false; }
#endif
#endif /* _WLC_LOGIND_H_ */
|
/*
* Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#ifdef AWS_MULTI_FRAMEWORK
#import <AWSRuntime/AmazonServiceRequestConfig.h>
#else
#import "../AmazonServiceRequestConfig.h"
#endif
/**
* Delete Security Group Request
*/
@interface EC2DeleteSecurityGroupRequest:AmazonServiceRequestConfig
{
NSString *groupName;
NSString *groupId;
}
/**
* The name of the Amazon EC2 security group to delete.
*/
@property (nonatomic, retain) NSString *groupName;
/**
* The ID of the Amazon EC2 security group to delete.
*/
@property (nonatomic, retain) NSString *groupId;
/**
* Default constructor for a new DeleteSecurityGroupRequest object. Callers should use the
* property methods to initialize this object after creating it.
*/
-(id)init;
/**
* Constructs a new DeleteSecurityGroupRequest object.
* Callers should use properties to initialize any additional object members.
*
* @param theGroupName The name of the Amazon EC2 security group to
* delete.
*/
-(id)initWithGroupName:(NSString *)theGroupName;
/**
* Returns a string representation of this object; useful for testing and
* debugging.
*
* @return A string representation of this object.
*/
-(NSString *)description;
@end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.