text stringlengths 4 6.14k |
|---|
/*
This file is part of Darling.
Copyright (C) 2020 Lubos Dolezel
Darling is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Darling is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Darling. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Foundation/Foundation.h>
@interface PLCoreDuetEventInterval : NSObject
@end
|
// -*- C++ -*-
//
// generated by wxGlade 0.7.2
//
// Example for compiling a single file project under Linux using g++:
// g++ MyApp.cpp $(wx-config --libs) $(wx-config --cxxflags) -o MyApp
//
// Example for compiling a multi file project under Linux using g++:
// g++ main.cpp $(wx-config --libs) $(wx-config --cxxflags) -o MyApp Dialog1.cpp Frame1.cpp
//
#ifndef DIALOGEVTCMDSAVEPERMISSIONS_H
#define DIALOGEVTCMDSAVEPERMISSIONS_H
#include <wx/wx.h>
#include <wx/image.h>
#include <wx/intl.h>
#ifndef APP_CATALOG
#define APP_CATALOG "appEditor" // replace with the appropriate catalog name
#endif
// begin wxGlade: ::dependencies
// end wxGlade
// begin wxGlade: ::extracode
// end wxGlade
class DialogEvtCmdSavePermissions: public wxDialog {
public:
// begin wxGlade: DialogEvtCmdSavePermissions::ids
// end wxGlade
DialogEvtCmdSavePermissions(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE);
private:
// begin wxGlade: DialogEvtCmdSavePermissions::methods
void set_properties();
void do_layout();
// end wxGlade
protected:
// begin wxGlade: DialogEvtCmdSavePermissions::attributes
wxRadioBox* rbOperation;
wxButton* btnOK;
wxButton* btnCancel;
wxButton* btnHelp;
// end wxGlade
}; // wxGlade: end class
#endif // DIALOGEVTCMDSAVEPERMISSIONS_H
|
/*
* Copyright (c) 2010,
* Gavriloaie Eugen-Andrei (shiretu@gmail.com)
*
* This file is part of crtmpserver.
* crtmpserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* crtmpserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with crtmpserver. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _FILELOGLOCATION_H
#define _FILELOGLOCATION_H
#include "utils/logging/baseloglocation.h"
class File;
class DLLEXP FileLogLocation
: public BaseLogLocation {
private:
File *_fileStream;
bool _canLog;
uint32_t _counter;
string _newLineCharacters;
string _fileName;
uint32_t _fileHistorySize;
uint32_t _fileLength;
uint32_t _currentLength;
vector<string> _history;
bool _fileIsClosed;
public:
FileLogLocation(Variant &configuration);
virtual ~FileLogLocation();
virtual bool Init();
virtual bool EvalLogLevel(int32_t level, string &fileName, uint32_t lineNumber,
string &functionName, string &message);
virtual bool EvalLogLevel(int32_t level, string fileName, uint32_t lineNumber,
string functionName, Variant &le);
virtual void Log(int32_t level, string fileName, uint32_t lineNumber,
string functionName, string message);
virtual void Log(int32_t level, string fileName, uint32_t lineNumber,
string functionName, Variant &le);
virtual void SignalFork();
private:
bool OpenFile();
void CloseFile();
};
#endif /* _FILELOGLOCATION_H */
|
/* stringhelp.h
* Copyright (C) 1998, 1999, 2000, 2001, 2003,
* 2006, 2007, 2009 Free Software Foundation, Inc.
* 2015 g10 Code GmbH
*
* This file is part of GnuPG.
*
* GnuPG is free software; you can redistribute it and/or modify it
* under the terms of either
*
* - the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* or
*
* - the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* or both in parallel, as here.
*
* GnuPG is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copies of the GNU General Public License
* and the GNU Lesser General Public License along with this program;
* if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GNUPG_COMMON_STRINGHELP_H
#define GNUPG_COMMON_STRINGHELP_H
#include "types.h"
/*-- stringhelp.c --*/
char *has_leading_keyword (const char *string, const char *keyword);
const char *memistr (const void *buf, size_t buflen, const char *sub);
char *mem2str( char *, const void *, size_t);
char *trim_spaces( char *string );
char *trim_trailing_spaces( char *string );
unsigned int trim_trailing_chars( unsigned char *line, unsigned len,
const char *trimchars);
unsigned int trim_trailing_ws( unsigned char *line, unsigned len );
size_t length_sans_trailing_chars (const unsigned char *line, size_t len,
const char *trimchars );
size_t length_sans_trailing_ws (const unsigned char *line, size_t len);
char *make_basename(const char *filepath, const char *inputpath);
char *make_dirname(const char *filepath);
char *make_filename( const char *first_part, ... ) GPGRT_ATTR_SENTINEL(0);
char *make_filename_try (const char *first_part, ... ) GPGRT_ATTR_SENTINEL(0);
char *make_absfilename (const char *first_part, ...) GPGRT_ATTR_SENTINEL(0);
char *make_absfilename_try (const char *first_part,
...) GPGRT_ATTR_SENTINEL(0);
int compare_filenames( const char *a, const char *b );
int hextobyte (const char *s);
char *sanitize_buffer (const void *p, size_t n, int delim);
size_t utf8_charcount (const char *s, int len);
#ifdef HAVE_W32_SYSTEM
const char *w32_strerror (int ec);
#endif
int ascii_isupper (int c);
int ascii_islower (int c);
int ascii_toupper (int c);
int ascii_tolower (int c);
char *ascii_strlwr (char *s);
int ascii_strcasecmp( const char *a, const char *b );
int ascii_strncasecmp (const char *a, const char *b, size_t n);
int ascii_memcasecmp( const void *a, const void *b, size_t n );
const char *ascii_memistr ( const void *buf, size_t buflen, const char *sub);
void *ascii_memcasemem (const void *haystack, size_t nhaystack,
const void *needle, size_t nneedle);
#ifndef HAVE_MEMICMP
int memicmp( const char *a, const char *b, size_t n );
#endif
#ifndef HAVE_STPCPY
char *stpcpy(char *a,const char *b);
#endif
#ifndef HAVE_STRPBRK
char *strpbrk (const char *s, const char *accept);
#endif
#ifndef HAVE_STRSEP
char *strsep (char **stringp, const char *delim);
#endif
#ifndef HAVE_STRLWR
char *strlwr(char *a);
#endif
#ifndef HAVE_STRTOUL
# define strtoul(a,b,c) ((unsigned long)strtol((a),(b),(c)))
#endif
#ifndef HAVE_MEMMOVE
# define memmove(d, s, n) bcopy((s), (d), (n))
#endif
#ifndef HAVE_STRICMP
# define stricmp(a,b) strcasecmp( (a), (b) )
#endif
#ifndef HAVE_MEMRCHR
void *memrchr (const void *buffer, int c, size_t n);
#endif
#ifndef HAVE_ISASCII
static inline int
isascii (int c)
{
return (((c) & ~0x7f) == 0);
}
#endif /* !HAVE_ISASCII */
#ifndef STR
# define STR(v) #v
#endif
#define STR2(v) STR(v)
/* Percent-escape the string STR by replacing colons with '%3a'. If
EXTRA is not NULL, also replace all characters given in EXTRA. The
"try_" variant fails with NULL if not enough memory can be
allocated. */
char *percent_escape (const char *str, const char *extra);
char *try_percent_escape (const char *str, const char *extra);
/* Concatenate the string S1 with all the following strings up to a
NULL. Returns a malloced buffer with the new string or NULL on a
malloc error or if too many arguments are given. */
char *strconcat (const char *s1, ...) GPGRT_ATTR_SENTINEL(0);
/* Ditto, but die on error. */
char *xstrconcat (const char *s1, ...) GPGRT_ATTR_SENTINEL(0);
char **strsplit (char *string, char delim, char replacement, int *count);
/* Tokenize STRING using the set of delimiters in DELIM. */
char **strtokenize (const char *string, const char *delim);
/* Return True if MYVERSION is greater or equal than REQ_VERSION. */
int compare_version_strings (const char *my_version, const char *req_version);
/* Format a string so that it fits within about TARGET_COLS columns. */
char *format_text (char *text, int in_place, int target_cols, int max_cols);
/*-- mapstrings.c --*/
const char *map_static_macro_string (const char *string);
#endif /*GNUPG_COMMON_STRINGHELP_H*/
|
/*
LUFA Library
Copyright (C) Dean Camera, 2010.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
/*
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether
in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of
this software.
*/
/** \file
*
* Header file for Descriptors.c.
*/
#ifndef _DESCRIPTORS_H_
#define _DESCRIPTORS_H_
/* Includes: */
#include <avr/pgmspace.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/CDC.h>
#include <LUFA/Drivers/USB/Class/HID.h>
/* Macros: */
/** Endpoint number of the CDC device-to-host notification IN endpoint. */
#define CDC_NOTIFICATION_EPNUM 2
/** Endpoint number of the CDC device-to-host data IN endpoint. */
#define CDC_TX_EPNUM 3
/** Endpoint number of the CDC host-to-device data OUT endpoint. */
#define CDC_RX_EPNUM 4
/** Size in bytes of the CDC device-to-host notification IN endpoint. */
#define CDC_NOTIFICATION_EPSIZE 8
/** Size in bytes of the CDC data IN and OUT endpoints. */
#define CDC_TXRX_EPSIZE 16
/** Endpoint number of the Mouse HID reporting IN endpoint. */
#define MOUSE_EPNUM 1
/** Size in bytes of the Mouse HID reporting IN endpoint. */
#define MOUSE_EPSIZE 8
/* Type Defines: */
/** Type define for the device configuration descriptor structure. This must be defined in the
* application code, as the configuration descriptor contains several sub-descriptors which
* vary between devices, and which describe the device's usage to the host.
*/
typedef struct
{
USB_Descriptor_Configuration_Header_t Config;
USB_Descriptor_Interface_Association_t CDC_IAD;
USB_Descriptor_Interface_t CDC_CCI_Interface;
CDC_FUNCTIONAL_DESCRIPTOR(2) CDC_Functional_IntHeader;
CDC_FUNCTIONAL_DESCRIPTOR(1) CDC_Functional_AbstractControlManagement;
CDC_FUNCTIONAL_DESCRIPTOR(2) CDC_Functional_Union;
USB_Descriptor_Endpoint_t CDC_NotificationEndpoint;
USB_Descriptor_Interface_t CDC_DCI_Interface;
USB_Descriptor_Endpoint_t CDC_DataOutEndpoint;
USB_Descriptor_Endpoint_t CDC_DataInEndpoint;
USB_Descriptor_Interface_t HID_Interface;
USB_HID_Descriptor_t HID_MouseHID;
USB_Descriptor_Endpoint_t HID_ReportINEndpoint;
} USB_Descriptor_Configuration_t;
/* Function Prototypes: */
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
const uint8_t wIndex,
void** const DescriptorAddress) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
#endif
|
// -*- C++ -*-
/*!
*
* THIS FILE IS GENERATED AUTOMATICALLY!! DO NOT EDIT!!
*
* @file shmodel_typeSkel.h
* @brief shmodel_type server skeleton header wrapper code
* @date Tue Jun 10 12:11:41 2014
*
*/
#ifndef _SHMODEL_TYPESKEL_H
#define _SHMODEL_TYPESKEL_H
#include <rtm/config_rtc.h>
#undef PACKAGE_BUGREPORT
#undef PACKAGE_NAME
#undef PACKAGE_STRING
#undef PACKAGE_TARNAME
#undef PACKAGE_VERSION
#if defined ORB_IS_TAO
# include "shmodel_typeC.h"
# include "shmodel_typeS.h"
#elif defined ORB_IS_OMNIORB
# if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
# undef USE_stub_in_nt_dll
# endif
# include "shmodel_type.hh"
#elif defined ORB_IS_MICO
# include "shmodel_type.h"
#elif defined ORB_IS_ORBIT2
# include "/shmodel_type-cpp-stubs.h"
# include "/shmodel_type-cpp-skels.h"
#elif defined ORB_IS_RTORB
# include "shmodel_type.h"
#else
# error "NO ORB defined"
#endif
#endif // _SHMODEL_TYPESKEL_H
|
/**
******************************************************************************
* @file SPI/SPI_FullDuplex_ComDMA/Inc/main.h
* @author MCD Application Team
* @version V1.1.0
* @date 17-February-2017
* @brief Header for main.c module
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* 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 STMicroelectronics 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.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H
/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_nucleo_144.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* User can use this section to tailor SPIx instance used and associated
resources */
/* Definition for SPIx clock resources */
#define SPIx SPI1
#define SPIx_CLK_ENABLE() __HAL_RCC_SPI1_CLK_ENABLE()
#define DMAx_CLK_ENABLE() __HAL_RCC_DMA2_CLK_ENABLE()
#define SPIx_SCK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define SPIx_MISO_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define SPIx_MOSI_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define SPIx_FORCE_RESET() __HAL_RCC_SPI1_FORCE_RESET()
#define SPIx_RELEASE_RESET() __HAL_RCC_SPI1_RELEASE_RESET()
/* Definition for SPIx Pins */
#define SPIx_SCK_PIN GPIO_PIN_3
#define SPIx_SCK_GPIO_PORT GPIOB
#define SPIx_SCK_AF GPIO_AF5_SPI1
#define SPIx_MISO_PIN GPIO_PIN_6
#define SPIx_MISO_GPIO_PORT GPIOA
#define SPIx_MISO_AF GPIO_AF5_SPI1
#define SPIx_MOSI_PIN GPIO_PIN_7
#define SPIx_MOSI_GPIO_PORT GPIOA
#define SPIx_MOSI_AF GPIO_AF5_SPI1
/* Definition for SPIx's DMA */
#define SPIx_TX_DMA_STREAM DMA2_Stream3
#define SPIx_RX_DMA_STREAM DMA2_Stream2
#define SPIx_TX_DMA_CHANNEL DMA_CHANNEL_3
#define SPIx_RX_DMA_CHANNEL DMA_CHANNEL_3
/* Definition for SPIx's NVIC */
#define SPIx_DMA_TX_IRQn DMA2_Stream3_IRQn
#define SPIx_DMA_RX_IRQn DMA2_Stream2_IRQn
#define SPIx_DMA_TX_IRQHandler DMA2_Stream3_IRQHandler
#define SPIx_DMA_RX_IRQHandler DMA2_Stream2_IRQHandler
/* Size of buffer */
#define BUFFERSIZE (COUNTOF(aTxBuffer) - 1)
/* Exported macro ------------------------------------------------------------*/
#define COUNTOF(__BUFFER__) (sizeof(__BUFFER__) / sizeof(*(__BUFFER__)))
/* Exported functions ------------------------------------------------------- */
#endif /* __MAIN_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
#include <stdio.h>
#include <pthread.h>
int mx=0, my=0;
int x=2, y=2;
void *thread1() {
int a;
__CPROVER_atomic_begin();
__CPROVER_assume(mx==0);
mx=1;
__CPROVER_atomic_end();
a = x;
__CPROVER_atomic_begin();
__CPROVER_assume(my==0);
my=1;
__CPROVER_atomic_end();
y = y + a;
my = 0;
a = a + 1;
__CPROVER_atomic_begin();
__CPROVER_assume(my==0);
my=1;
__CPROVER_atomic_end();
y = y + a;
my = 0;
x = x + x + a;
mx=0;
assert(x!=11);
}
void *thread2() {
__CPROVER_atomic_begin();
__CPROVER_assume(mx==0);
mx=1;
__CPROVER_atomic_end();
x=x+2;
mx=0;
}
void *thread3() {
__CPROVER_atomic_begin();
__CPROVER_assume(my==0);
my=1;
__CPROVER_atomic_end();
y=y+2;
my=0;
}
int main() {
__CPROVER_ASYNC_1: thread1();
__CPROVER_ASYNC_1: thread2();
__CPROVER_ASYNC_1: thread3();
return 0;
}
// Impara returns 'Verification succsesfull' after 0.9s
|
/**
* This file is part of ebtables-dhcpsnoopingd.
*
* Ebtables-dhcpsnoopingd is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Ebtables-dhcpsnoopingd is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ebtables-dhcpsnoopingd.
* If not, see <http://www.gnu.org/licenses/>.
*
* (C) 2013, Michael Braun <michael-dev@fami-braun.de>
*/
#include "config.h"
#include "debug.h"
#include "cmdline.h"
#include "dhcp.h"
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/ether.h>
#include "ether_ntoa.h"
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef CHAINNAME
#define CHAINNAME "dhcpsnooping"
#endif
#ifndef EBTABLES
#define EBTABLES "ebtables"
#endif
#ifdef __USE_EBTABLES__
static int disabled = 0;
static int dry = 0;
static void ebtables_run(const char* cmd) {
eprintf(DEBUG_GENERAL, "run \"%s\"", cmd);
if (dry) return;
if (system(cmd)) {
eprintf(DEBUG_ERROR, "cmd \"%s\" failed", cmd);
} else {
eprintf(DEBUG_GENERAL, "cmd \"%s\" ok", cmd);
}
}
static void ebtables_novlan(const char* op, const struct in_addr* ip, const uint8_t* mac, const char* ifname) {
char cmd[65535];
snprintf(cmd, sizeof(cmd), EBTABLES " %s " CHAINNAME " -s %s --proto ipv4 --ip-source %s --logical-in %s -j ACCEPT",
op, ether_ntoa_z((struct ether_addr *)mac), inet_ntoa(*ip), ifname);
ebtables_run(cmd);
snprintf(cmd, sizeof(cmd), EBTABLES " %s " CHAINNAME " -s %s --proto arp --arp-ip-src %s --logical-in %s -j ACCEPT",
op, ether_ntoa_z((struct ether_addr *)mac), inet_ntoa(*ip), ifname);
ebtables_run(cmd);
snprintf(cmd, sizeof(cmd), EBTABLES " -t nat %s " CHAINNAME " --proto arp --arp-ip-dst %s --logical-in %s -j dnat --to-destination %s --dnat-target CONTINUE",
op, inet_ntoa(*ip), ifname, ether_ntoa_z((struct ether_addr *)mac));
ebtables_run(cmd);
}
static void ebtables_vlan(const char* op, const struct in_addr* ip, const uint8_t* mac, const char* ifname, const int vlanid) {
char cmd[65535];
snprintf(cmd, sizeof(cmd), EBTABLES " %s " CHAINNAME " -s %s --proto 802_1Q --vlan-id %d --vlan-encap ipv4 --ip-source %s --logical-in %s -j ACCEPT",
op, ether_ntoa_z((struct ether_addr *)mac), vlanid, inet_ntoa(*ip), ifname);
ebtables_run(cmd);
snprintf(cmd, sizeof(cmd), EBTABLES " %s " CHAINNAME " -s %s --proto 802_1Q --vlan-id %d --vlan-encap arp --arp-ip-src %s --logical-in %s -j ACCEPT",
op, ether_ntoa_z((struct ether_addr *)mac), vlanid, inet_ntoa(*ip), ifname);
ebtables_run(cmd);
snprintf(cmd, sizeof(cmd), EBTABLES " -t nat %s " CHAINNAME " --proto 802_1Q --vlan-id %d --vlan-encap arp --arp-ip-dst %s --logical-in %s -j dnat --to-destination %s --dnat-target CONTINUE",
op, vlanid, inet_ntoa(*ip), ifname, ether_ntoa_z((struct ether_addr *)mac));
ebtables_run(cmd);
}
static void ebtables_do(const char* ifname, const int vlanid, const uint8_t* mac, const struct in_addr* ip, const int start)
{
assert(ip); assert(mac); assert(ifname);
if (disabled)
return;
eprintf(DEBUG_VERBOSE, "%s ebtables rule: MAC: %s IP: %s BRIDGE: %s VLAN: %d", (start ? "add" : "delete"), ether_ntoa_z((struct ether_addr *)mac), inet_ntoa(*ip), ifname, vlanid);
const char* op = start ? "-A" : "-D";
if (vlanid == 0)
ebtables_novlan(op, ip, mac, ifname);
else
ebtables_vlan(op, ip, mac, ifname, vlanid);
}
static void disable_ebtables(int c, void *arg)
{
disabled = 1;
}
static void dry_ebtables(int c, void *arg)
{
dry = 1;
}
static __attribute__((constructor)) void ebtables_init()
{
static struct option de_option = {"disable-ebtables", no_argument, 0, 0};
add_option_cb(de_option, disable_ebtables, NULL);
static struct option dry_option = {"dry-ebtables", no_argument, 0, 0};
add_option_cb(dry_option, dry_ebtables, NULL);
add_lease_start_stop_hook(ebtables_do);
}
#endif
|
// SPDX-License-Identifier: GPL-3.0-or-later
#include "value.h"
inline calculated_number rrdr2value(RRDR *r, long i, RRDR_OPTIONS options, int *all_values_are_null) {
if (r->st_needs_lock)
rrdset_check_rdlock(r->st);
long c;
RRDDIM *d;
calculated_number *cn = &r->v[ i * r->d ];
RRDR_VALUE_FLAGS *co = &r->o[ i * r->d ];
calculated_number sum = 0, min = 0, max = 0, v;
int all_null = 1, init = 1;
calculated_number total = 1;
int set_min_max = 0;
if(unlikely(options & RRDR_OPTION_PERCENTAGE)) {
total = 0;
for(c = 0, d = r->st->dimensions; d && c < r->d ;c++, d = d->next) {
calculated_number n = cn[c];
if(likely((options & RRDR_OPTION_ABSOLUTE) && n < 0))
n = -n;
total += n;
}
// prevent a division by zero
if(total == 0) total = 1;
set_min_max = 1;
}
// for each dimension
for(c = 0, d = r->st->dimensions; d && c < r->d ;c++, d = d->next) {
if(unlikely(r->od[c] & RRDR_DIMENSION_HIDDEN)) continue;
if(unlikely((options & RRDR_OPTION_NONZERO) && !(r->od[c] & RRDR_DIMENSION_NONZERO))) continue;
calculated_number n = cn[c];
if(likely((options & RRDR_OPTION_ABSOLUTE) && n < 0))
n = -n;
if(unlikely(options & RRDR_OPTION_PERCENTAGE)) {
n = n * 100 / total;
if(unlikely(set_min_max)) {
r->min = r->max = n;
set_min_max = 0;
}
if(n < r->min) r->min = n;
if(n > r->max) r->max = n;
}
if(unlikely(init)) {
if(n > 0) {
min = 0;
max = n;
}
else {
min = n;
max = 0;
}
init = 0;
}
if(likely(!(co[c] & RRDR_VALUE_EMPTY))) {
all_null = 0;
sum += n;
}
if(n < min) min = n;
if(n > max) max = n;
}
if(unlikely(all_null)) {
if(likely(all_values_are_null))
*all_values_are_null = 1;
return 0;
}
else {
if(likely(all_values_are_null))
*all_values_are_null = 0;
}
if(options & RRDR_OPTION_MIN2MAX)
v = max - min;
else
v = sum;
return v;
}
|
#include <stdlib.h>
#include <stdio.h>
int main()
{
char nome1[50],nome2[50],clone[50],concatenado[100];
int i,j,tamanho1,tamanho2,igualdade,maior;
/*LER NOMES E ESCREVER*/
printf("Digite o nome do aluno 1\n");
gets(nome1);
printf("Digite o nome do aluno 2\n");
gets(nome2);
printf("\n\n%s\n%s\n",nome1,nome2);
/*TAMANHO DOS NOMES*/
tamanho1 = 0;
tamanho2 = 0;
i = 0;
igualdade = 0;
while(nome1[i] != '\0')
{
tamanho1++;
i++;
}
i = 0;
while(nome2[i] != '\0')
{
tamanho2++;
i++;
}
printf("\nO primeiro nome tem %d caracteres enquanto que o segundo tem %d caracteres.\n",tamanho1,tamanho2);
/*IGUALDADE DE NOMES*/
if(tamanho1 == tamanho2)
{
for(i=0;i<tamanho1;i++)
{
if(nome1[i] == nome2[i])
{
igualdade++;
}
}
}
if(igualdade == tamanho1)
{
printf("\nOs nomes sao iguais!\n");
}
else
{
printf("\nOs nomes sao diferentes!\n");
}
/*COPIAR O MAIOR NOME*/
i = 0;
if(tamanho1 > tamanho2)
{
while(nome1[i] != '\0')
{
clone[i] = nome1[i];
i++;
}
clone[i] = '\0';
}
else
{
while(nome2[i] != '\0')
{
clone[i] = nome2[i];
i++;
}
clone[i] = '\0';
}
printf("\nO maior nome e o: %s.\n",clone);
/*CONCATENAR*/
i = 0;
while(nome1[i] != '\0')
{
concatenado[i] = nome1[i];
i++;
}
j = 0;
while(nome2[j] != '\0')
{
concatenado[i] = nome2[j];
j++;
i++;
}
concatenado[i] = '\0';
printf("Os nomes concatenados ficam: %s",concatenado);
return 0;
}
|
/*=========================================================================
Program: ParaView
Module: pqLinksEditor.h
Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
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 AUTHORS 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 _pqLinksEditor_h
#define _pqLinksEditor_h
#include <QDialog>
#include <QScopedPointer>
#include <QListWidgetItem>
#include <QModelIndex>
#include "pqComponentsModule.h"
#include "pqLinksModel.h"
namespace Ui { class pqLinksEditor; }
/// a Qt dialog for editing a property/proxy/camera link
/// two proxies can be selected, and if property type is
/// selected, then two properties can be selected as well.
class PQCOMPONENTS_EXPORT pqLinksEditor :
public QDialog
{
Q_OBJECT
typedef QDialog base;
public:
/// create a link editor to create/edit a link
/// initial values are retrieved from the provided vtkSMLink
pqLinksEditor(vtkSMLink* link, QWidget* p=0);
/// destroy this dialog
~pqLinksEditor();
/// get the name of the link
QString linkName();
/// get the type of link
pqLinksModel::ItemType linkType();
/// get the first selected proxy
vtkSMProxy* selectedProxy1();
/// get the second selected proxy;
vtkSMProxy* selectedProxy2();
/// get the first selected property
QString selectedProperty1();
/// get the second selected property
QString selectedProperty2();
private slots:
void currentProxy1Changed(const QModelIndex& cur, const QModelIndex&);
void currentProxy2Changed(const QModelIndex& cur, const QModelIndex&);
void currentProperty1Changed(QListWidgetItem* item);
void currentProperty2Changed(QListWidgetItem* item);
void updateSelectedProxies();
void updateEnabledState();
private:
class pqLinksEditorProxyModel;
void updatePropertyList(QListWidget* tw, vtkSMProxy* proxy);
QScopedPointer<Ui::pqLinksEditor> Ui;
pqLinksEditorProxyModel* Proxy1Model;
pqLinksEditorProxyModel* Proxy2Model;
vtkSMProxy* SelectedProxy1;
vtkSMProxy* SelectedProxy2;
QString SelectedProperty1;
QString SelectedProperty2;
};
#endif
|
/**********************************************************
* Copyright 2009 VMware, 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
* Contains the functions for creating dma buffers by calling
* the kernel via driver specific ioctls.
*
* @author Jakob Bornecrantz <jakob@vmware.com>
*/
#ifndef HAVE_STDINT_H
#define HAVE_STDINT_H 1
#endif
#define _FILE_OFFSET_BITS 64
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include "xf86drm.h"
#include "../core/vmwgfx_drm.h"
#include "vmw_driver.h"
#include "util/u_debug.h"
struct vmw_dma_buffer
{
void *data;
unsigned handle;
uint64_t map_handle;
unsigned map_count;
uint32_t size;
};
static int
vmw_ioctl_get_param(struct vmw_customizer *vmw, uint32_t param, uint64_t *out)
{
struct drm_vmw_getparam_arg gp_arg;
int ret;
memset(&gp_arg, 0, sizeof(gp_arg));
gp_arg.param = param;
ret = drmCommandWriteRead(vmw->fd, DRM_VMW_GET_PARAM,
&gp_arg, sizeof(gp_arg));
if (ret == 0) {
*out = gp_arg.value;
}
return ret;
}
int
vmw_ioctl_supports_streams(struct vmw_customizer *vmw)
{
uint64_t value;
int ret;
ret = vmw_ioctl_get_param(vmw, DRM_VMW_PARAM_NUM_STREAMS, &value);
if (ret)
return ret;
return value ? 0 : -ENOSYS;
}
int
vmw_ioctl_num_streams(struct vmw_customizer *vmw,
uint32_t *ntot, uint32_t *nfree)
{
uint64_t v1, v2;
int ret;
ret = vmw_ioctl_get_param(vmw, DRM_VMW_PARAM_NUM_STREAMS, &v1);
if (ret)
return ret;
ret = vmw_ioctl_get_param(vmw, DRM_VMW_PARAM_NUM_FREE_STREAMS, &v2);
if (ret)
return ret;
*ntot = (uint32_t)v1;
*nfree = (uint32_t)v2;
return 0;
}
int
vmw_ioctl_claim_stream(struct vmw_customizer *vmw, uint32_t *out)
{
struct drm_vmw_stream_arg s_arg;
int ret;
ret = drmCommandRead(vmw->fd, DRM_VMW_CLAIM_STREAM,
&s_arg, sizeof(s_arg));
if (ret)
return -1;
*out = s_arg.stream_id;
return 0;
}
int
vmw_ioctl_unref_stream(struct vmw_customizer *vmw, uint32_t stream_id)
{
struct drm_vmw_stream_arg s_arg;
int ret;
memset(&s_arg, 0, sizeof(s_arg));
s_arg.stream_id = stream_id;
ret = drmCommandRead(vmw->fd, DRM_VMW_CLAIM_STREAM,
&s_arg, sizeof(s_arg));
return 0;
}
int
vmw_ioctl_cursor_bypass(struct vmw_customizer *vmw, int xhot, int yhot)
{
struct drm_vmw_cursor_bypass_arg arg;
int ret;
memset(&arg, 0, sizeof(arg));
arg.flags = DRM_VMW_CURSOR_BYPASS_ALL;
arg.xhot = xhot;
arg.yhot = yhot;
ret = drmCommandWrite(vmw->fd, DRM_VMW_CURSOR_BYPASS,
&arg, sizeof(arg));
return ret;
}
struct vmw_dma_buffer *
vmw_ioctl_buffer_create(struct vmw_customizer *vmw, uint32_t size, unsigned *handle)
{
struct vmw_dma_buffer *buf;
union drm_vmw_alloc_dmabuf_arg arg;
struct drm_vmw_alloc_dmabuf_req *req = &arg.req;
struct drm_vmw_dmabuf_rep *rep = &arg.rep;
int ret;
buf = xcalloc(1, sizeof(*buf));
if (!buf)
goto err;
memset(&arg, 0, sizeof(arg));
req->size = size;
do {
ret = drmCommandWriteRead(vmw->fd, DRM_VMW_ALLOC_DMABUF, &arg, sizeof(arg));
} while (ret == -ERESTART);
if (ret) {
debug_printf("IOCTL failed %d: %s\n", ret, strerror(-ret));
goto err_free;
}
buf->data = NULL;
buf->handle = rep->handle;
buf->map_handle = rep->map_handle;
buf->map_count = 0;
buf->size = size;
*handle = rep->handle;
return buf;
err_free:
xfree(buf);
err:
return NULL;
}
void
vmw_ioctl_buffer_destroy(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf)
{
struct drm_vmw_unref_dmabuf_arg arg;
if (buf->data) {
munmap(buf->data, buf->size);
buf->data = NULL;
}
memset(&arg, 0, sizeof(arg));
arg.handle = buf->handle;
drmCommandWrite(vmw->fd, DRM_VMW_UNREF_DMABUF, &arg, sizeof(arg));
xfree(buf);
}
void *
vmw_ioctl_buffer_map(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf)
{
void *map;
if (buf->data == NULL) {
map = mmap(NULL, buf->size, PROT_READ | PROT_WRITE, MAP_SHARED,
vmw->fd, buf->map_handle);
if (map == MAP_FAILED) {
debug_printf("%s: Map failed.\n", __FUNCTION__);
return NULL;
}
buf->data = map;
}
++buf->map_count;
return buf->data;
}
void
vmw_ioctl_buffer_unmap(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf)
{
--buf->map_count;
}
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2010 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008-2009 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef OMPI_OP_BASE_FUNCTIONS_H
#define OMPI_OP_BASE_FUNCTIONS_H
#include "ompi_config.h"
#include "ompi/mca/op/op.h"
BEGIN_C_DECLS
/**
* Globals holding all the "base" function pointers, indexed by op and
* datatype.
*/
OMPI_DECLSPEC extern ompi_op_base_handler_fn_t
ompi_op_base_functions[OMPI_OP_BASE_FORTRAN_OP_MAX][OMPI_OP_BASE_TYPE_MAX];
OMPI_DECLSPEC extern ompi_op_base_3buff_handler_fn_t
ompi_op_base_3buff_functions[OMPI_OP_BASE_FORTRAN_OP_MAX][OMPI_OP_BASE_TYPE_MAX];
END_C_DECLS
#endif /* OMPI_OP_BASE_FUNCTIONS_H */
|
//
// ConstrainedProbabilityCost.h
//
// Pathfinder, an optimal path finding program for graphs with
// multi-weighted edges under specified constraints.
//
// Copyright (c) 2013 Bradley Denby.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see {http://www.gnu.org/licenses/}.
//
#ifndef Pathfinder_ConstrainedProbabilityCost_h
#define Pathfinder_ConstrainedProbabilityCost_h
#include "Cost.h"
class ConstrainedProbabilityCost : public Cost {
private:
double __constraint;
public:
ConstrainedProbabilityCost(const double cost=DEFAULT_COST, const std::string& units=DEFAULT_UNITS, const double constraint=DEFAULT_COST);
ConstrainedProbabilityCost(const ConstrainedProbabilityCost& cost);
virtual ~ConstrainedProbabilityCost();
double getConstraint() const;
virtual const Cost* clone() const;
virtual bool operator==(const ConstrainedProbabilityCost& cost) const;
virtual const Cost* operator*(const Cost& cost) const;
virtual std::string toString() const;
};
#endif
|
#include"singleton.h"
Foo foo = { .name="tom", .num=10};
int main()
{
printf("name: %s, num: %i \n", foo.name, foo.num);
return 0;
}
|
//
// API.h
// librecon
//
// Created by Sergio Garcia on 16/09/14.
// Copyright (c) 2014 Sergio Garcia. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "AFNetworking.h"
#define SCHEDULES @"schedules"
#define ASSISTANTS @"assistants"
#define TXOKOS @"txokos"
#define STANDS @"expositors"
#define MEETINGS @"meetings"
#define SPONSORS @"sponsors"
#define PHOTOCALL @"photocall"
@interface API : NSObject
typedef void (^APISuccess)(NSDictionary *content);
typedef void (^APIFailure)(AFHTTPRequestOperation *operation, NSError *error);
typedef void (^APIMeetingDuplicated)(NSInteger statusCode);
+ (API *)sharedClient;
+ (void)setCustomHeader;
//Login control
- (void)forceUserLogin;
//Authentication
- (void)athenticateWithCode:(NSString *)code withOnSuccessHandler:(APISuccess)successHandler andFailureHandler:(APIFailure)failureHandler;
- (void)requestCodeWithEmail:(NSString *)email withOnSuccessHandler:(APISuccess)successHandler andFailureHandler:(APIFailure)failureHandler;
- (void)sendUUID:(NSString *)uuid;
//Data
- (void)getSchedulesWithOnSuccessHandler:(APISuccess)successHandler andFailureHandler:(APIFailure)failureHandler;
- (void)getAssistentsWithOnSuccessHandler:(APISuccess)successHandler andFailureHandler:(APIFailure)failureHandler;
- (void)getTxokosWithOnSuccessHandler:(APISuccess)successHandler andFailureHandler:(APIFailure)failureHandler;
- (void)getStandsWithOnSuccessHandler:(APISuccess)successHandler andFailureHandler:(APIFailure)failureHandler;
- (void)getMeetingsWithOnSuccessHandler:(APISuccess)successHandler andFailureHandler:(APIFailure)failureHandler;
- (void)getMeetingWithId:(NSString *)idMeeting WithOnSuccessHandler:(APISuccess)successHandler andFailureHandler:(APIFailure)failureHandler;
- (void)createMeetingToAssistant:(NSString *)idAssistant withOnSuccessHandler:(APISuccess)successHandler andDuplicateHandler:(APIMeetingDuplicated)duplicateHandler andFailureHandler:(APIFailure)failureHandler;
- (void)setMeeting:(NSString *)meetingId withMoment:(NSString *)moment andEmailShare:(BOOL)emailShare andPhoneShare:(BOOL)phoneShare withOnSuccessHandler:(APISuccess)successHandler andFailureHandler:(APIFailure)failureHandler;
- (void)getSponsorsWithOnSuccessHandler:(APISuccess)successHandler andFailureHandler:(APIFailure)failureHandler;
- (void)getPhotosWithOnSuccessHandler:(APISuccess)successHandler andFailureHandler:(APIFailure)failureHandler;
@end
|
/*
Copyright (c) 2017 Julian Merkle
This file is part of telnet-honeypot.
telnet-honeypot is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
telnet-honeypot is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with telnet-honeypot. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TELNET_SERVER_FAKEBASH_H
#define TELNET_SERVER_FAKEBASH_H
#include <stdio.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <time.h>
#include <unistd.h> // close()
#include <string.h> //bzero()
#include <sys/stat.h> //fstat()
#include <thread>
#include <mutex>
#include <atomic>
#include "Helper.h"
#define READLEN 100 // Max bytes per read attempt
#define MAXPARAM 5 // Max argument count
#define PARAMLEN 50 // Max parameter length
#define PATHLEN 15 // Max parameter length
class FakeBash
{
public:
FakeBash(int fd, std::atomic<bool>& terminate, char* log_prefix);
~FakeBash();
void start();
private:
int fd;
char* log_prefix;
std::atomic<bool>& terminate;
const char* hostname = "arch\0";
const char* username = "root\0";
char path[PATHLEN];
int interpret(int parc, char parv[MAXPARAM][PARAMLEN]);
void print_prefix();
};
#endif //TELNET_SERVER_FAKEBASH_H
|
/*
* linked_list.h
*
* Copyright 2013-2021 Michael Zillgith
*
* This file is part of libIEC61850.
*
* libIEC61850 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* libIEC61850 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with libIEC61850. If not, see <http://www.gnu.org/licenses/>.
*
* See COPYING file for the complete license text.
*/
#ifndef LINKED_LIST_H_
#define LINKED_LIST_H_
#include "libiec61850_common_api.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \addtogroup common_api_group
*/
/**@{*/
/**
* \defgroup LINKED_LIST LinkedList data type definition and handling functions
*/
/**@{*/
struct sLinkedList {
void* data;
struct sLinkedList* next;
};
/**
* \brief Reference to a linked list or to a linked list element.
*/
typedef struct sLinkedList* LinkedList;
/**
* \brief Create a new LinkedList object
*
* \return the newly created LinkedList instance
*/
LIB61850_API LinkedList
LinkedList_create(void);
/**
* \brief Delete a LinkedList object
*
* This function destroy the LinkedList object. It will free all data structures used by the LinkedList
* instance. It will call free for all elements of the linked list. This function should only be used if
* simple objects (like dynamically allocated strings) are stored in the linked list.
*
* \param self the LinkedList instance
*/
LIB61850_API void
LinkedList_destroy(LinkedList self);
typedef void (*LinkedListValueDeleteFunction) (void*);
/**
* \brief Delete a LinkedList object
*
* This function destroy the LinkedList object. It will free all data structures used by the LinkedList
* instance. It will call a user provided function for each data element. This user provided function is
* responsible to properly free the data element.
*
* \param self the LinkedList instance
* \param valueDeleteFunction a function that is called for each data element of the LinkedList with the pointer
* to the linked list data element.
*/
LIB61850_API void
LinkedList_destroyDeep(LinkedList self, LinkedListValueDeleteFunction valueDeleteFunction);
/**
* \brief Delete a LinkedList object without freeing the element data
*
* This function should be used statically allocated data objects are stored in the LinkedList instance.
* Other use cases would be if the data elements in the list should not be deleted.
*
* \param self the LinkedList instance
*/
LIB61850_API void
LinkedList_destroyStatic(LinkedList self);
/**
* \brief Add a new element to the list
*
* This function will add a new data element to the list. The new element will the last element in the
* list.
*
* \param self the LinkedList instance
* \param data data to append to the LinkedList instance
*/
LIB61850_API void
LinkedList_add(LinkedList self, void* data);
/**
* \brief Check if the specified data is contained in the list
*
* \param self the LinkedList instance
* \param data data to remove from the LinkedList instance
*
* \return true if data is part of the list, false otherwise
*/
LIB61850_API bool
LinkedList_contains(LinkedList self, void* data);
/**
* \brief Removed the specified element from the list
*
* \param self the LinkedList instance
* \param data data to remove from the LinkedList instance
*
* \return true if data has been removed from the list, false otherwise
*/
LIB61850_API bool
LinkedList_remove(LinkedList self, void* data);
/**
* \brief Get the list element specified by index (starting with 0).
*
* \param self the LinkedList instance
* \param index index of the requested element.
*/
LIB61850_API LinkedList
LinkedList_get(LinkedList self, int index);
/**
* \brief Get the next element in the list (iterator).
*
* \param self the LinkedList instance
*/
LIB61850_API LinkedList
LinkedList_getNext(LinkedList self);
/**
* \brief Get the last element in the list.
*
* \param self the LinkedList instance
*/
LIB61850_API LinkedList
LinkedList_getLastElement(LinkedList self);
/**
* \brief Insert a new element int the list
*
* \param listElement the LinkedList instance
*/
LIB61850_API LinkedList
LinkedList_insertAfter(LinkedList listElement, void* data);
/**
* \brief Get the size of the list
*
* \param self the LinkedList instance
*
* \return number of data elements stored in the list
*/
LIB61850_API int
LinkedList_size(LinkedList self);
LIB61850_API void*
LinkedList_getData(LinkedList self);
LIB61850_API void
LinkedList_printStringList(LinkedList self);
/**@}*/
/**@}*/
#ifdef __cplusplus
}
#endif
#endif /* LINKED_LIST_H_ */
|
#include <stdlib.h>
#include "sae_par.h"
#include "ndf_err.h"
#include "ndf_ast.h"
#include "ndf1.h"
#include "mers.h"
void ndf1Psffl( const char *list, int mxel, size_t ibeg[], size_t iend[],
int *el, int *status ){
/*
*+
* Name:
* ndf1Psffl
* Purpose:
* Parse a foreign format list.
* Synopsis:
* void ndf1Psffl( const char *list, int mxel, size_t ibeg[], size_t iend[],
* int *el, int *status )
* Description:
* This function locates elements in a list of foreign data format
* specifications held as a character string and returns the character
* positions at which they start and end. All blanks surrounding each
* list element are discarded, as also are blank elements themselves.
* Checks are performed to ensure that the space available for storing
* element positions is not exceeded.
* Parameters:
* list
* Pointer to a null terminated string holding the foreign format
* list which is to be split up.
* mxel
* The maximum number of list elements expected.
* ibeg
* Returned holding the array of zero-based character positions
* identifying the start of each element in "list". The supplied "ibeg"
* array should have at least "mxel" elements.
* iend
* Returned holding the array of zero-based character positions
* identifying the end of each element in "list". The supplied "iend"
* array should have at least "mxel" elements.
* *el
* Number of list elements returned.
* *status
* The global status.
* Copyright:
* Copyright (C) 2018 East Asian Observatory
* All rights reserved.
* Licence:
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful,but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street,Fifth Floor, Boston, MA
* 02110-1301, USA
* Authors:
* RFWS: R.F. Warren-Smith (STARLINK)
* DSB: David S. Berry (EAO)
* History:
* 3-APR-2019 (DSB):
* Original version, based on equivalent Fortran function by RFWS.
*-
*/
/* Local Variables: */
const char *p; /* Pointer to next character to check */
size_t f; /* First non-blank character position */
size_t i; /* Pointer to start of element */
size_t l; /* Last non-blank character position */
/* Check inherited global status. */
if( *status != SAI__OK ) return;
/* Initialise the element count. */
*el = 0;
/* Initialise the zero-based indices of the first and last non-space
characters in the next field. Set "f" greater than "l" to indicate no
non-space characters have yet been found. */
f = 1;
l = 0;
/* Initialise the zero-based index of the next character to check, and
get a pointer to it. The "i" variable is unsigned so we cannot
intialise it to "-1". */
i = 0;
p = list - 1;
/* Loop round all characters in the supplied list, exiting the loop when
the terminating null character is reached. */
while( *(++p) ) {
/* If the current character is a delimiter, check that the previous field
was not blank. **/
if( *p == ',' ) {
if( f <= l ){
/* If we have not yet filled the returned arrays, add the previous field
to them. Otherwise, report an error and leave the loop. */
if( *el < mxel ){
ibeg[ *el ] = f;
iend[ *el ] = l;
(*el)++;
} else {
*status = NDF__XSFMT;
msgSeti( "MXEL", mxel );
msgSetc( "LIST", list );
errRep( " ", "Too many foreign data formats specified "
"(maximum permitted is ^MXEL) in the list '^LIST'.",
status );
break;
}
}
/* Prepare for the next field by re-initialising the indices of the first
and last non-space characters in the next field with "f" > "l". */
f = 1;
l = 0;
/* If the current character is not a space, update the indices of the
first and last non-space character in the field. */
} else if( *p != ' ' ){
if( f > l ) f = i;
l = i;
}
/* Update the zero-based index of the next character to check. */
i++;
}
/* Call error tracing function and exit. */
if( *status != SAI__OK ) ndf1Trace( "ndf1Psffl", status );
}
|
#ifndef BYTES_H
#define BYTES_H
#include <cassert>
#include <algorithm>
namespace ds {
namespace core {
template <typename valueT, typename bufT>
void valueToBytes(const valueT value, bufT& buffer) {
// The buffer must be correctly sized prior to this operation
assert(sizeof(value) == buffer.size());
auto bytes = static_cast<const char *>(static_cast<const void *>(&value));
//std::copy(bytes, bytes + sizeof(bufT), buffer.data());
for(size_t i = 0; i < sizeof(value); ++i) {
buffer.at(i) = bytes[i];
}
}
template <typename valueT, typename bufT>
void appendValueToBytes(const valueT value, bufT& buffer) {
auto bytes = static_cast<const char *>(static_cast<const void *>(&value));
for(size_t i = 0; i < sizeof(valueT); ++i) {
buffer += bytes[i];
}
}
template <typename valueT, typename bufT>
valueT bytesToValue(bufT& buffer) {
// The buffer must be correctly sized prior to this operation
assert(sizeof(valueT) == buffer.size());
auto value = static_cast<const valueT *>(static_cast<const void *>(buffer.data()));
assert(value != nullptr);
return *value;
}
}}
#endif // BYTES_H
|
/*
* buffer.c
*
* Created on: 2016-2-21
* Author: dan
*/
|
/************************************************************************
Copyright Chris Newey 2013
qiptables@hotmail.com
This file is part of Qiptables.
Qiptables is distributed under the terms of the GNU General Public License
Qiptables is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Qiptables is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Qiptables. If not, see <http://www.gnu.org/licenses/>.
***************************************************************************/
#ifndef DATABASEMANAGER_H
#define DATABASEMANAGER_H
#include <QFile>
#include <QDir>
#include <QObject>
#include <QSqlRecord>
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
#include <QString>
#include <QVariant>
#include "install.h"
/**
\file databasemanager.h
\class DatabaseManager
\brief Class to manipulate application database
***************************/
class DatabaseManager : public QObject
{
public:
static bool DB_OPEN;
static const QString DB_NAME;
static QSqlDatabase dbm;
/**
\brief Constructor
\param dbPath - Path to application database.
This path should not include a trailing backslash.
\param parent
**************/
DatabaseManager(QString dbPath, QObject *parent = 0);
~DatabaseManager();
/**
\brief Close the database
*************/
virtual void closeDB();
/**
\brief Checks for existence of database
\return true if database exists else false
**************/
virtual bool databaseExists();
/**
\brief Deletes Database
Copes with attempt to delete non existent database.
\return true if database deleted else false
****************/
virtual bool deleteDB();
/**
\brief Deletes table from database
\param tableName - name of table to be deleted
\return true if table deleted else false
*****************/
virtual bool dropTable(QString tableName);
/**
\brief returns file name of current database
\return file name of current database
***************/
virtual QString getDatabaseFileName();
/**
\brief Get a reference to the current database
\return reference to the current database
*************************/
virtual QSqlDatabase getDb();
/**
\brief Open the application database
\return true if database opened else false
*****************/
virtual bool openDB();
/**
\brief Get system configuration settings
System configuration settings are held in a table on the application
database. This table only has one row. Each column of the table contains
a configuration setting.
\return Row of system configuration table.
********************/
virtual QSqlRecord getSysconfRow();
/**
\brief Get row of ruleset table
\param rulesetName - name of ruleset used to identify required row
\return Row of ruleset table
******************/
virtual QSqlRecord getRulesetRow(QVariant rulesetName);
/**
\brief Get ruleset from ruleset name.
\param rulesetName - name of ruleset used to identify required row
\return string containing ruleset
***********************/
virtual QString getRuleset(QVariant rulesetName);
/**
\brief Get list of ruleset names
\return List of ruleset names
*******************/
virtual QStringList getRulesetNames();
/**
\brief Get row of rulesnippet table
\param rulesnippetName - name of rulesnippet used to identify required row
\return Row of rulesnippet table
******************/
virtual QSqlRecord getRuleSnippetRow(QVariant ruleSnippetName);
/**
\brief Get error (if any) resulting from most recent SQL command
\return SQL error object
**********************/
virtual QSqlError lastError();
/**
\brief Check to see if rulesnippet is in use as an include in a ruleset
\param rulesnippetName;
\return true if rulesnippet is in use else false
*********************/
virtual QStringList isRulesnippetInUse(QString rulesnippetName);
/**
\brief check if rulesnippet is included in line of ruleset
\param rulesnippetName - name of rule snippet
\param rulesetline - line of ruleset
\return true if line contains included rulesnippet name else false
*****************/
virtual bool rulesnippetInLine(QString rulesnippetName, QString rulesetLine);
public slots:
signals:
protected:
QString dbPath;
QSqlDatabase db;
QSqlRecord syconfRec;
QSqlRecord rulesetRec;
QSqlRecord ruleSnippetRec;
private:
};
#endif // DATABASEMANAGER_H
|
/*******************************************
Author : LHearen
E-mail : LHearen@126.com
Time : 2015-12-25 16:33
Description : You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad.
Suppose you have n versions [1, 2, ..., n] and you want to find out the first bad one, which causes all the following ones to be bad.
You are given an API bool isBadVersion(version) which will return whether version is bad. Implement a function to find the first bad version. You should minimize the number of calls to the API.
Source : https://leetcode.com/problems/first-bad-version/
*******************************************/
#include <stdbool.h>
bool isBadVersion(int version);
//AC - 0ms - a big warning to use low+(high-low)/2 to get mid
//instead of (high+low)/2 which might give us overflow;
int firstBadVersion(int n)
{
int low = 1, high = n;
int mid;
while(low < high)
isBadVersion(mid = low+(high-low)/2) ? (high = mid) : (low = mid+1);
return high;
}
|
////////////////////////////////////////////////////////////////////////////////
//
// W R I T T E N B Y I M P E R A S I G E N
//
// Version 20150205.0
// Thu May 7 10:28:35 2015
//
////////////////////////////////////////////////////////////////////////////////
#include "videoin.igen.h"
/////////////////////////////// Port Declarations //////////////////////////////
CFGBUS_AB0_dataT CFGBUS_AB0_data;
handlesT handles;
/////////////////////////////// Diagnostic level ///////////////////////////////
// Test this variable to determine what diagnostics to output.
// eg. if (diagnosticLevel >= 1) bhmMessage("I", "videoin", "Example");
// Predefined macros PSE_DIAG_LOW, PSE_DIAG_MEDIUM and PSE_DIAG_HIGH may be used
Uns32 diagnosticLevel;
/////////////////////////// Diagnostic level callback //////////////////////////
static void setDiagLevel(Uns32 new) {
diagnosticLevel = new;
}
///////////////////////////// MMR Generic callbacks ////////////////////////////
//////////////////////////////// View callbacks ////////////////////////////////
static PPM_VIEW_CB(view_CFGBUS_AB0_AR) {
*(Uns32*)data = CFGBUS_AB0_data.AR.value;
}
static PPM_VIEW_CB(view_CFGBUS_AB0_IR) {
*(Uns32*)data = CFGBUS_AB0_data.IR.value;
}
//////////////////////////////// Bus Slave Ports ///////////////////////////////
static void installSlavePorts(void) {
handles.CFGBUS = ppmCreateSlaveBusPort("CFGBUS", 8);
}
//////////////////////////// Memory mapped registers ///////////////////////////
static void installRegisters(void) {
ppmCreateRegister("AB0_AR",
0,
handles.CFGBUS,
0,
4,
readReg,
writeReg,
view_CFGBUS_AB0_AR,
(void*)0x0,
True
);
ppmCreateRegister("AB0_IR",
0,
handles.CFGBUS,
4,
4,
readReg,
writeReg,
view_CFGBUS_AB0_IR,
(void*)0x1,
True
);
}
/////////////////////////////////// Net Ports //////////////////////////////////
static void installNetPorts(void) {
// To write to this net, use ppmWriteNet(handles.VINSYNCINT, value);
handles.VINSYNCINT = ppmOpenNetPort("VINSYNCINT");
}
////////////////////////////////// Constructor /////////////////////////////////
PPM_CONSTRUCTOR_CB(periphConstructor) {
installSlavePorts();
installRegisters();
installNetPorts();
}
///////////////////////////////////// Main /////////////////////////////////////
int main(int argc, char *argv[]) {
ppmDocNodeP doc1_node = ppmDocAddSection(0, "Licensing");
ppmDocAddText(doc1_node, "Open Source Apache 2.0");
ppmDocNodeP doc_11_node = ppmDocAddSection(0, "Description");
ppmDocAddText(doc_11_node, "V4L2 to OVP video input peripheral");
diagnosticLevel = 0;
bhmInstallDiagCB(setDiagLevel);
constructor();
bhmWaitEvent(bhmGetSystemEvent(BHM_SE_END_OF_SIMULATION));
destructor();
return 0;
}
|
/*
Copyright (C) 2016 Alexey Dynda
This file is part of Nixie Library.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _NIXIE_LED_H_
#define _NIXIE_LED_H_
#include "nixie_types.h"
class NixieLed
{
public:
/**
* @brief Creates NixieLed object.
* @param pin - pin number to control led.
*/
inline NixieLed(uint8_t pin) { m_pin = pin; };
/**
* @brief Switches LED off
*/
void inline off() { digitalWrite(m_pin, LOW); };
/**
* @brief Switches LED on
*/
void inline on() { digitalWrite(m_pin, HIGH); };
private:
uint8_t m_pin;
};
#endif
|
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* Test SAMD51 specific configuration values for errors at compile-time.
*/
#if ENABLED(FLASH_EEPROM_EMULATION)
#warning "Did you activate the SmartEEPROM? See https://github.com/GMagician/SAMD51-SmartEEprom-Manager/releases"
#endif
#if defined(ADAFRUIT_GRAND_CENTRAL_M4) && SD_CONNECTION_IS(CUSTOM_CABLE)
#error "No custom SD drive cable defined for this board."
#endif
#if defined(MAX6675_SCK_PIN) && defined(MAX6675_DO_PIN) && (MAX6675_SCK_PIN == SCK1 || MAX6675_DO_PIN == MISO1)
#error "OnBoard SPI BUS can't be shared with other devices."
#endif
#if SERVO_TC == RTC_TIMER_NUM
#error "Servos can't use RTC timer"
#endif
#if ENABLED(EMERGENCY_PARSER)
#error "EMERGENCY_PARSER is not yet implemented for SAMD51. Disable EMERGENCY_PARSER to continue."
#endif
#if ENABLED(SDIO_SUPPORT)
#error "SDIO_SUPPORT is not supported on SAMD51."
#endif
#if ENABLED(FAST_PWM_FAN)
#error "FAST_PWM_FAN is not yet implemented for this platform."
#endif
|
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (2013) Alexander Stukowski
//
// This file is part of OVITO (Open Visualization Tool).
//
// OVITO is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// OVITO is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef __OVITO_SURFACE_MESH_H
#define __OVITO_SURFACE_MESH_H
#include <plugins/particles/Particles.h>
#include <plugins/particles/data/SimulationCell.h>
#include <core/scene/objects/DataObjectWithSharedStorage.h>
#include <core/utilities/mesh/HalfEdgeMesh.h>
#include <core/utilities/concurrent/FutureInterface.h>
namespace Ovito { namespace Particles {
/**
* \brief A closed triangle mesh representing a surface.
*/
class OVITO_PARTICLES_EXPORT SurfaceMesh : public DataObjectWithSharedStorage<HalfEdgeMesh<>>
{
public:
/// \brief Constructor that creates an empty SurfaceMesh object.
Q_INVOKABLE SurfaceMesh(DataSet* dataset, HalfEdgeMesh<>* mesh = nullptr);
/// Returns the title of this object.
virtual QString objectTitle() override { return tr("Surface mesh"); }
/// \brief Returns whether this object, when returned as an editable sub-object by another object,
/// should be displayed in the modification stack.
///
/// Return false because this object cannot be edited.
virtual bool isSubObjectEditable() const override { return false; }
/// Indicates whether the entire simulation cell is part of the solid region.
bool isCompletelySolid() const { return _isCompletelySolid; }
/// Sets whether the entire simulation cell is part of the solid region.
void setCompletelySolid(bool flag) { _isCompletelySolid = flag; }
/// Returns the planar cuts applied to this mesh.
const QVector<Plane3>& cuttingPlanes() const { return _cuttingPlanes; }
/// Sets the planar cuts applied to this mesh.
void setCuttingPlanes(const QVector<Plane3>& planes) {
_cuttingPlanes = planes;
notifyDependents(ReferenceEvent::TargetChanged);
}
/// Fairs the triangle mesh stored in this object.
void smoothMesh(const SimulationCell& cell, int numIterations, FutureInterfaceBase* progress = nullptr, FloatType k_PB = 0.1f, FloatType lambda = 0.5f) {
smoothMesh(*modifiableStorage(), cell, numIterations, progress, k_PB, lambda);
changed();
}
/// Fairs a triangle mesh.
static void smoothMesh(HalfEdgeMesh<>& mesh, const SimulationCell& cell, int numIterations, FutureInterfaceBase* progress = nullptr, FloatType k_PB = 0.1f, FloatType lambda = 0.5f);
protected:
/// Performs one iteration of the smoothing algorithm.
static void smoothMeshIteration(HalfEdgeMesh<>& mesh, FloatType prefactor, const SimulationCell& cell);
/// Creates a copy of this object.
virtual OORef<RefTarget> clone(bool deepCopy, CloneHelper& cloneHelper) override;
private:
/// Indicates that the entire simulation cell is part of the solid region.
PropertyField<bool> _isCompletelySolid;
/// The planar cuts applied to this mesh.
QVector<Plane3> _cuttingPlanes;
Q_OBJECT
OVITO_OBJECT
DECLARE_PROPERTY_FIELD(_isCompletelySolid);
};
} // End of namespace
} // End of namespace
#endif // __OVITO_SURFACE_MESH_H
|
// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu -Wincompatible-pointer-types
//
// Tests for the pass_object_size attribute
// Non-failure cases are covered in test/CodeGen/pass-object-size.c
void a(void *p __attribute__((pass_object_size))); //expected-error{{'pass_object_size' attribute takes one argument}}
void b(void *p __attribute__((pass_object_size(1.0)))); //expected-error{{'pass_object_size' attribute requires parameter 1 to be an integer constant}}
void c(void *p __attribute__((pass_object_size(4)))); //expected-error{{'pass_object_size' attribute requires integer constant between 0 and 3 inclusive}}
void d(void *p __attribute__((pass_object_size(-1)))); //expected-error{{'pass_object_size' attribute requires integer constant between 0 and 3 inclusive}}
void e(void *p __attribute__((pass_object_size(1ULL<<32)))); //expected-error{{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
void f(char p __attribute__((pass_object_size(0)))); //expected-error{{'pass_object_size' attribute only applies to constant pointer arguments}}
void g(const char p __attribute__((pass_object_size(0)))); //expected-error{{'pass_object_size' attribute only applies to constant pointer arguments}}
void h(char *p __attribute__((pass_object_size(0)))) {} //expected-error{{pass_object_size attribute only applies to constant pointer arguments}}
void i(char *p __attribute__((pass_object_size(0)))); // OK -- const is only necessary on definitions, not decls.
void j(char *p __attribute__((pass_object_size(0), pass_object_size(1)))); //expected-error{{'pass_object_size' attribute can only be applied once per parameter}}
#define PS(N) __attribute__((pass_object_size(N)))
#define overloaded __attribute__((overloadable))
void Overloaded(void *p PS(0)) overloaded; //expected-note{{previous declaration is here}}
void Overloaded(void *p PS(1)) overloaded; //expected-error{{conflicting pass_object_size attributes on parameters}}
void Overloaded2(void *p PS(1), void *p2 PS(0)) overloaded; //expected-note{{previous declaration is here}}
void Overloaded2(void *p PS(0), void *p2 PS(1)) overloaded; //expected-error{{conflicting pass_object_size attributes on parameters}}
void Overloaded3(void *p PS(0), void *p2) overloaded; //expected-note{{previous declaration is here}}
void Overloaded3(void *p, void *p2 PS(0)) overloaded; //expected-error{{conflicting pass_object_size attributes on parameters}}
void TakeFn(void (*)(void *));
void TakeFnOvl(void (*)(void *)) overloaded;
void TakeFnOvl(void (*)(int *)) overloaded;
void NotOverloaded(void *p PS(0));
void IsOverloaded(void *p PS(0)) overloaded;
void IsOverloaded(char *p) overloaded; // char* inestead of void* is intentional
void FunctionPtrs() {
void (*p)(void *) = NotOverloaded; //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has pass_object_size attribute}}
void (*p2)(void *) = &NotOverloaded; //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has pass_object_size attribute}}
void (*p3)(void *) = IsOverloaded; //expected-error{{initializing 'void (*)(void *)' with an expression of incompatible type '<overloaded function type>'}} expected-note@-6{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@-5{{type mismatch}}
void (*p4)(void *) = &IsOverloaded; //expected-error{{initializing 'void (*)(void *)' with an expression of incompatible type '<overloaded function type>'}} expected-note@-7{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@-6{{type mismatch}}
void (*p5)(char *) = IsOverloaded;
void (*p6)(char *) = &IsOverloaded;
TakeFn(NotOverloaded); //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has pass_object_size attribute}}
TakeFn(&NotOverloaded); //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has pass_object_size attribute}}
TakeFnOvl(NotOverloaded); //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has pass_object_size attribute}}
TakeFnOvl(&NotOverloaded); //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has pass_object_size attribute}}
int P;
(&NotOverloaded)(&P); //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has pass_object_size attribute}}
(&IsOverloaded)(&P); //expected-error{{no matching function}} expected-note@35{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@36{{candidate function not viable: no known conversion from 'int *' to 'char *' for 1st argument}}
}
|
long_function_name (a,
b
);
long_function_name (
a,
b
);
long_function_name ({
a;
},
b
);
long_function_name (
{
a;
},
b
);
long_function_name (a,
{
b;
}
);
long_function_name (
a,
{
b;
}
);
long_function_name ({
a;
},
{
b;
}
);
long_function_name (
{
a;
},
{
b;
}
);
long_function_name (x, {
a;
},
b);
long_function_name (x, y {
a;
},
b);
|
/*
* Copyright (C) 2013 Tek Counsel LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import <UIKit/UIKit.h>
#import "HTTPUtils.h"
#import "NSData+Base64.h"
#import "NSMutableDictionary+SafeMethods.h"
#import "Constants.h"
#import "UIHelper.h"
#import "Spinner.h"
#import "NSString+Translate.h"
@class WebShellViewController;
@interface UIParent : UIViewController <UIActionSheetDelegate>{
NSMutableDictionary *action;
UIButton *btnClose;
UIButton *btnUpload;
UINavigationBar *navBar;
UILabel *lblTitle;
UIToolbar *toolBar;
BOOL dirty;
WebShellViewController *webShell;
NSData *data;
Spinner *spinner;
NSUserDefaults *prefs;
BOOL isdark;
UIPopoverController *popover;
CGPoint touchPoint;
}
@property(nonatomic,retain) IBOutlet UIButton *btnClose;
@property(nonatomic,retain) IBOutlet UIButton *btnUpload;
@property(nonatomic,retain) UIPopoverController *popover;
@property(nonatomic,retain) Spinner *spinner;
@property(nonatomic,retain) WebShellViewController *webShell;
@property(nonatomic,retain) NSMutableDictionary *action;
@property(readwrite) BOOL dirty;
@property(nonatomic,retain) IBOutlet UILabel *lblTitle;
@property(nonatomic,retain) IBOutlet UINavigationBar *navBar;
@property(nonatomic,retain) IBOutlet UIToolbar *toolBar;
@property(nonatomic,retain) NSData *data;//final data to push back to server via REST.
-(IBAction)close:(id)sender;
-(IBAction)save:(id)sender;
-(void) loadDirtyActions;
-(void)onResponse:(NSData *)jsonData;
@end
|
/* Remembering/selecting of previous passwords */
#include <tank.h>
#include <dir.h>
#include <unistd.h>
#include <string.h>
typedef struct
{ char name[21];
} passstruct;
static passstruct *ps;
static long pn;
#define list_length 20
void read_passwords(void)
{
FILE *f;
pn = 0;
ps = allocate(max_files*sizeof(passstruct));
f = fopen("PASSWD.DAT", "rb");
if (f != 0)
{
pn = fread(ps, sizeof(passstruct), max_files, f);
fclose(f);
}
}
long select_password_from_list(char *pw)
{
long start=0, sel=0, k, s;
static void rewrite_menu(void)
{ long i, y;
for (i = start, y = 33+big_height; i < start+list_length && i < pn; i++, y += 6)
{
s = m13_overwrite_text(90, y, 15, "%c %s", i==sel? '>':' ', ps[i].name);
m13_bar(90 + s, y, 220 - 90 - s, 5, 0);
}
}
write_panel();
m13_add_bar(50, 20, 220, 160, 5);
m13_bar(55, 25, 210, 150, 0);
read_passwords();
if (pn==0)
{
message_key("NO PASSWORDS KNOWN");
return(FALSE);
}
textout_centre(screen, big_font, "KNOWN PASSWORDS", 160, 29, FNT_HIGH);
rewrite_menu();
do
{
k = wait_key();
switch(k)
{ case RKEY_UP:
sel--;
break;
case RKEY_DOWN:
sel++;
break;
case RKEY_PGUP:
sel-=list_length;
break;
case RKEY_PGDN:
sel+=list_length;
break;
}
if (sel<0) sel=0;
if (sel>=pn) sel=pn-1;
if (start>sel) start=sel;
if (start<sel-(list_length-1)) start=sel-(list_length-1);
rewrite_menu();
} while (k != RKEY_ESC && k != RKEY_ENTER);
if (k == RKEY_ENTER)
strcpy(pw, ps[sel].name);
free(ps);
clear(screen);
return(k == RKEY_ENTER);
}
void add_password_to_list(char *passwd)
{
FILE *f;
int i;
if (*passwd == 0)
return;
read_passwords();
for (i = 0; i < pn; i ++)
if (strcmp(ps[i].name, passwd) == 0)
{
free(ps);
return;
}
strcpy(ps[i].name, passwd);
f = fopen("PASSWD.DAT", "wb");
if (f != 0)
{
fwrite(ps, sizeof(passstruct) * (pn + 1), 1, f);
fclose(f);
}
free(ps);
}
|
////////////////////////////////////////////////////////////
//
// squarly-hoop
// Copyright (C) 2016 Pampu Andrei (aka. Woky) (andrei.sergiu98@gmail.com)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
////////////////////////////////////////////////////////////
#ifndef SFMLGAME_MOUSE_H
#define SFMLGAME_MOUSE_H
#include <SFML/Graphics.hpp>
class Mouse : public sf::Drawable{
public:
Mouse(){}
Mouse(sf::Texture *texture);
void update(sf::Vector2i pos);
sf::FloatRect getGlobalBounds();
private:
sf::RectangleShape form;
virtual void draw(sf::RenderTarget &target, sf::RenderStates states) const;
};
#endif //SFMLGAME_MOUSE_H
|
/*
* wiiuse
*
* Written By:
* Michael Laforest < para >
* Email: < thepara (--AT--) g m a i l [--DOT--] com >
*
* Copyright 2006-2007
*
* This file is part of wiiuse.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* $Header$
*
*/
#pragma warning(disable:4206)
#if defined __APPLE__
//#include "os.h"
#ifdef __MACH__
#include <mach/clock.h>
#include <mach/mach.h>
#endif
unsigned long wiiuse_os_ticks() {
struct timespec
{
unsigned int tv_sec; /* seconds */
clock_res_t tv_nsec; /* nanoseconds */
}ts;
clock_serv_t cclock;
mach_timespec_t mts;
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
clock_get_time(cclock, &mts);
mach_port_deallocate(mach_task_self(), cclock);
ts.tv_sec = mts.tv_sec;
ts.tv_nsec = mts.tv_nsec;
unsigned long ms = 1000 * ts.tv_sec + ts.tv_nsec / 1e6;
return ms;
}
#endif |
#pragma once
/* Umbrella header for the Filter library */
#include "FilterClass.h"
#include "AverageFilter.h"
#include "UserFilter.h"
#include "DerivativeFilter.h"
#include "FilterWithBuffer.h"
#include "LowPassFilter.h"
#include "ModeFilter.h"
#include "Butter.h"
|
#include "xsltp_config.h"
#include "xsltp_core.h"
void xsltp_list_sort(xsltp_list_t *list, int (*cmp)(const xsltp_list_t *, const xsltp_list_t *)) {
xsltp_list_t *el, *prev, *next;
el = xsltp_list_first(list);
if (el == xsltp_list_last(list)) {
return;
}
for (el = xsltp_list_next(el); el != xsltp_list_end(list); el = next) {
prev = xsltp_list_prev(el);
next = xsltp_list_next(el);
xsltp_list_remove(el);
do {
if (cmp(prev, el) <= 0) {
break;
}
prev = xsltp_list_prev(prev);
} while (prev != xsltp_list_end(list));
xsltp_list_insert_after(prev, el);
}
}
|
/*
* coder.h
* Copyright (C) 2013 Ilan Pegoraro and Luís Neves
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBCAV_CODER_H_
#define LIBCAV_CODER_H_
#include <utility>
#include "predictor.h"
#include "bitstream.h"
/**
* @class Coder abstract class that serves as a base of each coder specialization like Golomb.
* @author Ilan Pegoraro <impegoraro@ua.pt>
* @author Luís Neves <luispneves@ua.pt>
*/
class Coder
{
public:
Coder(const Predictor& pred, BitStream& bs)
: m_pred(pred), m_bs(bs), m_elapsed(0)
{
}
Coder(Predictor&& pred, BitStream& bs)
: m_pred(pred), m_bs(bs), m_elapsed(0)
{
}
virtual Predictor& predictor()
{
return m_pred;
}
virtual const Predictor& predictor() const
{
return m_pred;
}
virtual void encode() = 0;
double getEncodeTime() const
{
return m_elapsed;
}
protected:
Predictor m_pred;
BitStream& m_bs;
double m_elapsed;
};
#endif |
/*
* 3dyne Legacy Tools GPL Source Code
*
* Copyright (C) 1996-2012 Matthias C. Berger & Simon Berger.
*
* This file is part of the 3dyne Legacy Tools GPL Source Code ("3dyne Legacy
* Tools Source Code").
*
* 3dyne Legacy Tools Source Code is free software: you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* 3dyne Legacy Tools Source Code is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* 3dyne Legacy Tools Source Code. If not, see <http://www.gnu.org/licenses/>.
*
* In addition, the 3dyne Legacy Tools Source Code is also subject to certain
* additional terms. You should have received a copy of these additional terms
* immediately following the terms and conditions of the GNU General Public
* License which accompanied the 3dyne Legacy Tools Source Code.
*
* Contributors:
* Matthias C. Berger (mcb77@gmx.de) - initial API and implementation
* Simon Berger (simberger@gmail.com) - initial API and implementation
*/
// cmdpars.c
#include <stdio.h>
#include <string.h>
#include "cmdpars.h"
int CheckCmdSwitch( const char* switch_name, int arg_argc, char* arg_argv[] )
{
unsigned int i;
if( arg_argv[1] == NULL )
{
//printf( "NULL pointer\n" );
return( 0 );
}
for( i = 1; i < arg_argc; i++ )
{
if( strlen( switch_name ) != strlen( arg_argv[i] ))
{
//printf( "wrong lenght\n" );
continue;
}
if( ! strcmp( switch_name, arg_argv[i] ) )
{
return( i );
}
}
return( 0 );
}
char* GetCmdOpt( const char* switch_name, int arg_argc, char* arg_argv[] )
{
unsigned int i;
if( arg_argv[1] == NULL )
{
//printf( "NULL pointer\n" );
return( NULL );
}
for( i = 1; i < arg_argc; i++ )
{
if( strlen( switch_name ) != strlen( arg_argv[i] ))
{
//printf( "wrong lenght\n" );
continue;
}
if( ! strcmp( switch_name, arg_argv[i] ) )
{
if( i + 1 == arg_argc )
{
return( NULL );
}
return( arg_argv[i + 1] );
}
}
return( NULL );
}
//
// mcb stuff
//
static int local_argc;
static char **local_argv;
/*
====================
SetCmdArgs
====================
*/
void SetCmdArgs( int argargc, char **argargv )
{
local_argc = argargc;
local_argv = argargv;
}
/*
====================
CheckCmdSwitch2
====================
*/
int CheckCmdSwitch2( const char *name )
{
return CheckCmdSwitch( name, local_argc, local_argv );
}
/*
====================
GetCmdOpt2
====================
*/
char* GetCmdOpt2( const char* name )
{
return GetCmdOpt( name, local_argc, local_argv );
}
/*
int main( int argc, char* argv[] )
{
unsigned int arg_num;
char* temp_buf;
arg_num = CheckCmdSwitch( "-bla", argc, argv );
//printf( "arg num: %i\n", arg_num );
if( arg_num == 0 )
{
printf( "switch not set.\n" );
}
else
{
printf( "switch set as arg %i.\n", arg_num );
}
temp_buf = GetCmdOpt( "-file", argc, argv );
if( temp_buf == NULL )
{
printf( "arg not found.\n" );
}
printf( "temp buf: %s\n", temp_buf );
}
*/
|
/*-
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#ifndef _UTF8String_H_
#define _UTF8String_H_
#include <OCTET_STRING.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef OCTET_STRING_t UTF8String_t; /* Implemented via OCTET STRING */
LIB61850_INTERNAL extern asn_TYPE_descriptor_t asn_DEF_UTF8String;
LIB61850_INTERNAL asn_struct_print_f UTF8String_print;
LIB61850_INTERNAL asn_constr_check_f UTF8String_constraint;
/*
* Returns length of the given UTF-8 string in characters,
* or a negative error code:
* -1: UTF-8 sequence truncated
* -2: Illegal UTF-8 sequence start
* -3: Continuation expectation failed
* -4: Not minimal length encoding
* -5: Invalid arguments
*/
LIB61850_INTERNAL
ssize_t UTF8String_length(const UTF8String_t *st);
/*
* Convert the UTF-8 string into a sequence of wide characters.
* Returns the number of characters necessary.
* Returned value might be greater than dstlen.
* In case of conversion error, 0 is returned.
*
* If st points to a valid UTF-8 string, calling
* UTF8String_to_wcs(st, 0, 0);
* is equivalent to
* UTF8String_length(const UTF8String_t *st);
*/
LIB61850_INTERNAL
size_t UTF8String_to_wcs(const UTF8String_t *st, uint32_t *dst, size_t dstlen);
#ifdef __cplusplus
}
#endif
#endif /* _UTF8String_H_ */
|
/* Copyright (C) 2018 Magnus Lång and Tuan Phong Ngo
* This benchmark is part of SWSC */
#include <assert.h>
#include <stdint.h>
#include <stdatomic.h>
#include <pthread.h>
atomic_int vars[2];
atomic_int atom_0_r1_2;
atomic_int atom_1_r1_1;
atomic_int atom_1_r3_2;
void *t0(void *arg){
label_1:;
int v2_r1 = atomic_load_explicit(&vars[0], memory_order_seq_cst);
int v3_r3 = v2_r1 ^ v2_r1;
int v4_r3 = v3_r3 + 1;
atomic_store_explicit(&vars[1], v4_r3, memory_order_seq_cst);
int v15 = (v2_r1 == 2);
atomic_store_explicit(&atom_0_r1_2, v15, memory_order_seq_cst);
return NULL;
}
void *t1(void *arg){
label_2:;
int v6_r1 = atomic_load_explicit(&vars[1], memory_order_seq_cst);
int v8_r3 = atomic_load_explicit(&vars[1], memory_order_seq_cst);
int v9_cmpeq = (v8_r3 == v8_r3);
if (v9_cmpeq) goto lbl_LC00; else goto lbl_LC00;
lbl_LC00:;
atomic_store_explicit(&vars[0], 1, memory_order_seq_cst);
atomic_store_explicit(&vars[0], 2, memory_order_seq_cst);
int v16 = (v6_r1 == 1);
atomic_store_explicit(&atom_1_r1_1, v16, memory_order_seq_cst);
int v17 = (v8_r3 == 2);
atomic_store_explicit(&atom_1_r3_2, v17, memory_order_seq_cst);
return NULL;
}
void *t2(void *arg){
label_3:;
atomic_store_explicit(&vars[1], 2, memory_order_seq_cst);
return NULL;
}
int main(int argc, char *argv[]){
pthread_t thr0;
pthread_t thr1;
pthread_t thr2;
atomic_init(&vars[1], 0);
atomic_init(&vars[0], 0);
atomic_init(&atom_0_r1_2, 0);
atomic_init(&atom_1_r1_1, 0);
atomic_init(&atom_1_r3_2, 0);
pthread_create(&thr0, NULL, t0, NULL);
pthread_create(&thr1, NULL, t1, NULL);
pthread_create(&thr2, NULL, t2, NULL);
pthread_join(thr0, NULL);
pthread_join(thr1, NULL);
pthread_join(thr2, NULL);
int v10 = atomic_load_explicit(&atom_0_r1_2, memory_order_seq_cst);
int v11 = atomic_load_explicit(&atom_1_r1_1, memory_order_seq_cst);
int v12 = atomic_load_explicit(&atom_1_r3_2, memory_order_seq_cst);
int v13_conj = v11 & v12;
int v14_conj = v10 & v13_conj;
if (v14_conj == 1) assert(0);
return 0;
}
|
/* dbmstore.c - Add a new key/data pair to the database. */
/* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson.
Copyright (C) 1990 Free Software Foundation, Inc.
GDBM is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
GDBM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GDBM; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
You may contact the author by:
e-mail: phil@wwu.edu
us-mail: Philip A. Nelson
Computer Science Department
Western Washington University
Bellingham, WA 98226
phone: (206) 676-3035
*************************************************************************/
#include <stdio.h>
#include <sys/types.h>
#include <sys/file.h>
#include <sys/stat.h>
#include "gdbmdefs.h"
#include "extern.h"
/* NDBM add a new element to the database. CONTENT is keyed by KEY.
The file on disk is updated to reflect the structure of the new
database before returning from this procedure. */
int
dbm_store (dbf, key, content, flags)
gdbm_file_info *dbf;
datum key;
datum content;
int flags;
{
return gdbm_store (dbf, key, content, flags);
}
|
#ifndef PREGUNTASINO_H
#define PREGUNTASINO_H
#include <QObject>
#include "preguntabase.h"
#include "../widgets/wdgtsino.h"
class PreguntaSiNo : public PreguntaBase
{
public:
PreguntaSiNo(const QString &label, const QString ¬a, bool showNotes, QObject *parent = 0);
#ifdef USEMONGO
PreguntaSiNo(mongo::BSONObj &obj, bool showNotes, QObject *parent = 0);
#else
PreguntaSiNo(QJsonObject &obj, bool showNotes, QObject *parent = 0);
#endif
~PreguntaSiNo();
virtual PreguntaBasePtr clone();
virtual QWidget* widget();
#if USEMONGO
virtual mongo::BSONObj value();
#else
virtual QJsonObject value();
#endif
virtual void applyChanges();
virtual QString toHtml();
virtual QString toHtml(bool incluirNotas);
bool isYes() const;
private:
bool _value;
WdgtSiNo *_widget;
};
#endif // PREGUNTASINO_H
|
#pragma once
#include <vgKernel/vgkVec3.h>
#include <vgKernel/vgkUniqueID.h>
namespace vgGIS3D
{
class RouteMap
{
public:
virtual void render() {}
virtual void findRoute(vgKernel::Vec3 startPoint, vgKernel::Vec3 endPoint, vector<int>& route) {}
virtual bool getRouteInfo(vgKernel::Vec3 pointInRoad) { return false; }
virtual bool getRouteInfo(string routeName) { return false; }
virtual bool isRouteConnected(string routeName1, string routeName2) { return false; }
virtual bool isRouteConnected(vgKernel::Vec3 pointInRoad1, vgKernel::Vec3 pointInRoad2) { return false;}
};
} |
#ifndef _PARSE_H_
#define _PARSE_H_
/* Process a tri-column ijv file and construct the J matrix */
void parse_tri_file(char *fname, float ***J, int *N);
#endif
|
/*
* Copyright (C) 2020 Fernando Escribano Macias
*
* This file is part of the Root Engine.
*
* The Root Engine is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Root Engine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with The Root Engine. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <root/core/assert.h>
#include <root/math/mat4x4.h>
#include <type_traits> // Do we want to not depend on stdlib?
#include <cmath>
namespace root {
template<typename T>
inline auto translation(const vec3<T>& movement) -> mat4x4<T> {
return mat4x4<T>({{1, 0, 0, movement.x},
{0, 1, 0, movement.y},
{0, 0, 1, movement.z},
{0, 0, 0, 1}});
}
template<typename T>
inline auto scaling(const vec3<T>& scale_factors) -> mat4x4<T> {
return mat4x4<T>({{scale_factors.x, 0, 0, 0},
{ 0, scale_factors.y, 0, 0},
{ 0, 0, scale_factors.z, 0},
{ 0, 0, 0, 1}});
}
template<typename T>
inline auto rotate_around_x(const T& angle) -> mat4x4<T> {
static_assert(std::is_floating_point<T>::value);
return mat4x4<T>({{1 0, 0, 0},
{0, cos(angle), -sin(angle), 0},
{0, sin(angle), cos(angle), 0},
{0, 0, 0, 1}});
}
template<typename T>
inline auto rotate_around_y(const T& angle) -> mat4x4<T> {
static_assert(std::is_floating_point<T>::value);
return mat4x4<T>({{ cos(angle), 0, sin(angle), 0},
{ 0, 1, 0, 0},
{-sin(angle), 0, cos(angle), 0},
{ 0, 0, 0, 1}});
}
template<typename T>
inline auto rotate_around_z(const T& angle) -> mat4x4<T> {
static_assert(std::is_floating_point<T>::value);
return mat4x4<T>({{cos(angle), -sin(angle), 0, 0},
{sin(angle), cos(angle), 0, 0},
{ 0, 0, 1, 0},
{ 0, 0, 0, 1}});
}
template<typename T>
inline auto rotate_around_axis(const vec3<T>& axis, const T& angle) -> mat4x4<T> {
static_assert(std::is_floating_point<T>::value);
// TODO assert that the axis is normalized?
// TODO in general
}
template <typename T>
inline auto look_at(const vec3<T>& position, const vec3<T>& target, const vec3<T>& up) {
static_assert(std::is_floating_point<T>::value);
vec3<T> camera_to_target = normalize(target - position);
vec3<T> right = normalize(cross(up, camera_to_target));
vec3<T> camera_up = cross(camera_to_target, right);
return mat4x4<T>({{right.x, camera_up.x, camera_to_target.x, position.x},
{right.y, camera_up.y, camera_to_target.y, position.y},
{right.z, camera_up.z, camera_to_target.z, position.z},
{ 0, 0, 0, 1}});
}
} // namespace root |
#ifndef GRPPI_SEQ_SAXPY_H
#define GRPPI_SEQ_SAXPY_H
#include <vector>
#include <grppi/grppi.h>
void grppi_seq_saxpy(double a, const std::vector<double> & x, std::vector<double> & y)
{
grppi::sequential_execution ex;
grppi::map(ex, begin(x), end(x), begin(y),
[a](double valx, double valy) { return a * valx + valy; },
begin(y)
);
}
#endif
|
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#ifndef O2_MCH_WORKFLOW_TRACK_TREE_READER_H
#define O2_MCH_WORKFLOW_TRACK_TREE_READER_H
#include "DataFormatsMCH/ClusterBlock.h"
#include "DataFormatsMCH/TrackMCH.h"
#include "DataFormatsMCH/ROFRecord.h"
#include "SimulationDataFormat/MCCompLabel.h"
#include <TTreeReader.h>
#include <memory>
#include <vector>
namespace o2::mch
{
class TrackTreeReader
{
public:
TrackTreeReader(TTree* tree);
bool next(ROFRecord& rof,
std::vector<TrackMCH>& tracks,
std::vector<ClusterStruct>& clusters,
std::vector<o2::MCCompLabel>& labels);
bool hasLabels() { return mLabels.get() != nullptr; }
private:
TTreeReader mTreeReader;
TTreeReaderValue<std::vector<o2::mch::TrackMCH>> mTracks = {mTreeReader, "tracks"};
TTreeReaderValue<std::vector<o2::mch::ROFRecord>> mRofs = {mTreeReader, "trackrofs"};
TTreeReaderValue<std::vector<o2::mch::ClusterStruct>> mClusters = {mTreeReader, "trackclusters"};
std::unique_ptr<TTreeReaderValue<std::vector<o2::MCCompLabel>>> mLabels{};
size_t mCurrentRof;
};
} // namespace o2::mch
#endif
|
#ifndef ATTACK_MENU_H
#define ATTACK_MENU_H
#include "fight.h"
typedef struct Action_menu Action_menu;
//Constructor
Action_menu *create_action_menu(Fight *fight, ALLEGRO_FONT *font);
//Destructor (frees the fighter but not the font)
void free_action_menu(Action_menu *a_m);
//Destructor (frees neither the fighter nor the font)
void semi_free_action_menu(Action_menu *action_menu);
//Displayer
void display_action_menu(Action_menu *a_m);
//Updates the menu accordingly to the received inputs. Does nothing to the fighter!
void update_action_menu(Action_menu *action_menu, int key[4]);
//Updates the menu so it fits a new fighter
void action_menu_update_fighter(Action_menu *a_m, Fight* fight);
//"Getters" and "Setters"
//Returns the currently chosen action
//1 or 2 for the matching attack, 3 for cancel
int action_menu_get_action(Action_menu *action_menu);
#endif /* ATTACK_MENU_H */
|
/**
** @file qnerror.h
** @author Angelo Prudentino
** @date 2016-12-06
**
** Copyright 2016 Angelo Prudentino <angelo.prudentino@studenti.polito.it>.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef QNERROR_H
#define QNERROR_H
#include <QString>
#include "qnglobalexport.h"
#define SUCCESS 0
#define NET_FORMAT_NOT_SUPPORTED -1
#define NET_READ_ERROR -2
#define NET_WRITE_ERROR -3
#define STYLE_FORMAT_NOT_SUPPORTED -4
#define STYLE_READ_ERROR -5
#define STYLE_WRITE_ERROR -6
#define INVALID_STYLE_STATE -7
#define DUPLICATED_ID -8
#define NO_DATA -9
#define INVALID_REQ -10
/**
* @brief The QNError class models an error occured while parsing or writing
* a smile xml document
*/
class QTNETS_EXPORT QNError {
private:
/**
* @brief error state
*/
bool err;
/**
* @brief error code
*/
int code;
/**
* @brief error detail
*/
QString detail;
public:
/**
* @brief QNError default constructor
* @note use this constructor to set no error
*/
QNError();
/**
* @brief QNError error constructor
* @param aCode the code of the error
* @param aDetail the detail of the error
* @note use this constructor to set a specific error
*/
QNError(const int aCode, const QString& aDetail);
/**
* @brief allows to use this object easily in conditional constructs
*/
operator bool() const;
/**
* @brief retrieves the error code
* @return the error code
*/
int getCode() const;
/**
* @brief retrieves the error detail
* @return the error detail
*/
QString getDetail() const;
};
#endif // QNERROR_H
|
/*
* TCBuffer.h
*
* Copyright 2016 Avérous Julien-Pierre
*
* This file is part of TorChat.
*
* TorChat is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TorChat is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TorChat. If not, see <http://www.gnu.org/licenses/>.
*
*/
#import <Foundation/Foundation.h>
/*
** TCBuffer
*/
#pragma mark - TCBuffer
@interface TCBuffer : NSObject
// -- Bytes --
- (void)pushBytes:(const void *)bytes ofSize:(NSUInteger)size copy:(BOOL)copy; // Insert at the beggin
- (void)appendBytes:(const void *)bytes ofSize:(NSUInteger)size copy:(BOOL)copy; // Insert at the end
- (NSUInteger)readBytes:(void *)bytes ofSize:(NSUInteger)size; // Read data from beggin
// -- Tools --
- (NSData *)dataUpToCStr:(const char *)search includeSearch:(BOOL)includeSearch; // Read data up to the string "search"
- (void)clean;
- (void)print;
// -- Properties --
- (NSUInteger)size;
@end
|
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 20 9, 2017
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2017 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef SHOWDOUBLELABEL_H
#define SHOWDOUBLELABEL_H
#include "../vundocommand.h"
class QGraphicsScene;
enum class ShowDoublePoint: qint8 { FirstPoint, SecondPoint };
class ShowDoubleLabel : public VUndoCommand
{
Q_OBJECT
public:
ShowDoubleLabel(VAbstractPattern *doc, quint32 toolId, quint32 pointId, bool visible, ShowDoublePoint type,
QUndoCommand *parent = nullptr);
virtual ~ShowDoubleLabel()=default;
virtual void undo() override;
virtual void redo() override;
private:
Q_DISABLE_COPY(ShowDoubleLabel)
bool m_visible;
bool m_oldVisible;
//Need for resizing scene rect
QGraphicsScene *m_scene;
ShowDoublePoint m_type;
quint32 m_idTool;
void Do(bool visible);
};
#endif // SHOWDOUBLELABEL_H
|
/*
* donnatella - Copyright (C) 2014 Olivier Brunel
*
* debug.c
* Copyright (C) 2014 Olivier Brunel <jjk@jjacky.com>
*
* This file is part of donnatella.
*
* donnatella is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* donnatella is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* donnatella. If not, see http://www.gnu.org/licenses/
*/
#include "config.h"
#include <glib.h>
#include <gdk/gdk.h>
#include <string.h>
#include "app.h" /* DONNA_APP_ERROR */
#include "debug.h"
#include "macros.h"
void
_donna_debug_ungrab (void)
{
GdkDeviceManager *devmngr;
GList *list, *l;
devmngr = gdk_display_get_device_manager (gdk_display_get_default ());
list = gdk_device_manager_list_devices (devmngr, GDK_DEVICE_TYPE_MASTER);
for (l = list; l; l = l->next)
{
GdkDevice *dev = l->data;
if (gdk_device_get_source (dev) != GDK_SOURCE_MOUSE
&& gdk_device_get_source (dev) != GDK_SOURCE_KEYBOARD)
continue;
gdk_device_ungrab (dev, GDK_CURRENT_TIME);
}
g_list_free (list);
}
static gchar *_def = NULL;
static gpointer _valid = NULL;
struct valid
{
DonnaDebugFlags flag;
gchar *names;
};
gboolean
donna_debug_set_valid (gchar *def, GError **error)
{
GArray *array = NULL;
gchar *s;
if (G_UNLIKELY (_valid))
{
g_critical ("Tried to set debug message filters more than once");
g_free (def);
return FALSE;
}
_def = def;
donna_debug_flags = 0;
for (;;)
{
struct valid valid;
gchar *e;
s = strchr (def, ',');
if (s)
*s = '\0';
e = strchr (def, ':');
if (e)
*e = '\0';
if (streq (def, "node"))
valid.flag = DONNA_DEBUG_NODE;
else if (streq (def, "task"))
valid.flag = DONNA_DEBUG_TASK;
else if (streq (def, "treeview"))
valid.flag = DONNA_DEBUG_TREE_VIEW;
else if (streq (def, "terminal"))
valid.flag = DONNA_DEBUG_TERMINAL;
else if (streq (def, "task-manager"))
valid.flag = DONNA_DEBUG_TASK_MANAGER;
else if (streq (def, "provider"))
valid.flag = DONNA_DEBUG_PROVIDER;
else if (streq (def, "config"))
valid.flag = DONNA_DEBUG_CONFIG;
else if (streq (def, "app"))
valid.flag = DONNA_DEBUG_APP;
else if (streq (def, "embedder"))
valid.flag = DONNA_DEBUG_EMBEDDER;
else if (streq (def, "memory"))
valid.flag = DONNA_DEBUG_MEMORY;
else if (streq (def, "all"))
valid.flag = DONNA_DEBUG_ALL;
else
{
g_set_error (error, DONNA_APP_ERROR, DONNA_APP_ERROR_OTHER,
"Unknown debug flag '%s'", def);
g_free (_def);
_def = NULL;
if (array)
g_array_free (array, TRUE);
return FALSE;
}
donna_debug_flags |= valid.flag;
if (e)
{
/* move back over the ':' so we can have an extra NUL as EO-list */
memmove (e, e + 1, sizeof (gchar) * (strlen (e + 1) + 1));
valid.names = e;
/* turn '+'-s into NUL-s */
for (;;)
{
e = strchr (valid.names, '+');
if (e)
*e = '\0';
else
break;
}
if (!array)
array = g_array_new (TRUE, FALSE, sizeof (struct valid));
g_array_append_val (array, valid);
}
if (s)
def = s + 1;
else
break;
}
if (array)
_valid = g_array_free (array, FALSE);
else
{
g_free (_def);
_def = NULL;
}
return TRUE;
}
gboolean
_donna_debug_is_valid (DonnaDebugFlags flag, const gchar *name)
{
struct valid *v = (struct valid *) _valid;
gboolean ret = TRUE;
/* this is only used from DONNA_DEBUG() so we can assume that name in not
* NULL, and that flag is set in donna_debug_flags */
if (!v)
return TRUE;
for (;;)
{
if (v->flag == flag)
{
gchar *s = v->names;
for (;;)
{
if (streq (name, s))
return TRUE;
s += strlen (s) + 1;
if (*s == '\0')
break;
}
/* we'll keep iterating, in case the same flag was defined more than
* once. And if not (or no match), we'll return FALSE */
ret = FALSE;
}
++v;
if (v->flag == 0)
break;
}
return ret;
}
void
donna_debug_reset_valid (void)
{
g_free (_def);
g_free (_valid);
_def = _valid = NULL;
}
|
#pragma once
#include "theory.h"
#include <unordered_set>
#include <unordered_map>
#include <list>
namespace smt
{
class ov_value_listener;
class var_value
{
public:
var_value() {}
virtual ~var_value() {}
};
class ov_theory : public theory
{
friend class ov_value_listener;
public:
ov_theory(sat_core &sat);
ov_theory(const ov_theory &orig) = delete;
virtual ~ov_theory();
const var new_var(const std::unordered_set<var_value *> &items);
const var new_var(const std::vector<var> &vars, const std::vector<var_value *> &vals);
const var allows(const var &left, var_value &right) const;
const var eq(const var &left, const var &right);
std::unordered_set<var_value *> value(var v) const;
private:
bool propagate(const lit &p, std::vector<lit> &cnfl) override;
bool check(std::vector<lit> &cnfl) override;
void push() override;
void pop() override;
void listen(const var &v, ov_value_listener *const l);
void forget(const var &v, ov_value_listener *const l);
private:
class layer
{
public:
layer() {}
public:
// the updated variables..
std::unordered_set<var> vars;
};
std::vector<std::unordered_map<var_value *, var>> assigns; // the current assignments (val to bool variable)..
std::unordered_map<std::string, var> exprs; // the already existing expressions (string to bool variable)..
std::unordered_map<var, std::vector<var>> is_contained_in; // the boolean variable contained in the set variables (bool variable to vector of set variables)..
std::vector<layer> layers; // we store the updated variables..
std::unordered_map<var, std::list<ov_value_listener *>> listening;
};
class ov_value_listener
{
friend class ov_theory;
public:
ov_value_listener(ov_theory &s) : th(s) {}
ov_value_listener(const ov_value_listener &that) = delete;
virtual ~ov_value_listener()
{
for (const auto &v : la_vars)
th.forget(v, this);
}
protected:
void listen_set(var v)
{
th.listen(v, this);
la_vars.push_back(v);
}
private:
virtual void set_value_change(const var &) {}
private:
ov_theory &th;
std::vector<var> la_vars;
};
} |
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include <3ds.h>
#include "menus/sysconfig.h"
#include "mcu.h"
#include "memory.h"
#include "draw.h"
#include "fmt.h"
#include "utils.h"
#include "ifile.h"
Menu sysconfigMenu = {
"System configuration menu",
.nbItems = 2,
{
{ "Toggle LEDs", METHOD, .method = &SysConfigMenu_ToggleLEDs },
{ "Toggle Wireless", METHOD, .method = &SysConfigMenu_ToggleWireless },
}
};
void SysConfigMenu_ToggleLEDs(void)
{
Draw_Lock();
Draw_ClearFramebuffer();
Draw_FlushFramebuffer();
Draw_Unlock();
do
{
Draw_Lock();
Draw_DrawString(10, 10, COLOR_TITLE, "System configuration menu");
Draw_DrawString(10, 30, COLOR_WHITE, "Press A to toggle, press B to go back.");
Draw_DrawString(10, 50, COLOR_RED, "WARNING:");
Draw_DrawString(10, 60, COLOR_WHITE, " * Entering sleep mode will reset the LED state!");
Draw_DrawString(10, 70, COLOR_WHITE, " * LEDs cannot be toggled when the battery is low!");
Draw_FlushFramebuffer();
Draw_Unlock();
u32 pressed = waitInputWithTimeout(1000);
if(pressed & BUTTON_A)
{
mcuInit();
u8 result;
mcuGetLEDState(&result);
u8 value = ~result;
mcuWriteRegister(40, &value, 1);
mcuExit();
}
else if(pressed & BUTTON_B)
return;
}
while(!terminationRequest);
}
void SysConfigMenu_ToggleWireless(void)
{
Draw_Lock();
Draw_ClearFramebuffer();
Draw_FlushFramebuffer();
Draw_Unlock();
bool nwmRunning = false;
u32 pidList[0x40];
s32 processAmount;
svcGetProcessList(&processAmount, pidList, 0x40);
for(s32 i = 0; i < processAmount; i++)
{
Handle processHandle;
Result res = svcOpenProcess(&processHandle, pidList[i]);
if(R_FAILED(res))
continue;
char processName[8] = {0};
svcGetProcessInfo((s64 *)&processName, processHandle, 0x10000);
svcCloseHandle(processHandle);
if(!strncmp(processName, "nwm", 4))
{
nwmRunning = true;
break;
}
}
do
{
Draw_Lock();
Draw_DrawString(10, 10, COLOR_TITLE, "System configuration menu");
Draw_DrawString(10, 30, COLOR_WHITE, "Press A to toggle, press B to go back.");
u8 wireless = (*(vu8 *)((0x10140000 | (1u << 31)) + 0x180));
if(nwmRunning)
{
Draw_DrawString(10, 50, COLOR_WHITE, "Current status:");
Draw_DrawString(100, 50, (wireless ? COLOR_GREEN : COLOR_RED), (wireless ? " ON " : " OFF"));
}
else
{
Draw_DrawString(10, 50, COLOR_RED, "NWM isn't running.");
Draw_DrawString(10, 60, COLOR_RED, "If you're currently on Test Menu,");
Draw_DrawString(10, 70, COLOR_RED, "exit then press R+RIGHT to toggle the WiFi.");
Draw_DrawString(10, 80, COLOR_RED, "Otherwise, simply exit and wait a few seconds.");
}
Draw_FlushFramebuffer();
Draw_Unlock();
u32 pressed = waitInputWithTimeout(1000);
if(pressed & BUTTON_A && nwmRunning)
{
nwmExtInit();
NWMEXT_ControlWirelessEnabled(!wireless);
nwmExtExit();
}
else if(pressed & BUTTON_B)
return;
}
while(!terminationRequest);
}
|
#include <config.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <glib.h>
#include "server.h"
static GTimer *timer;
static void
test_server_info_load (void)
{
int i;
char *dirs [] = { SERVERINFODIR, NULL };
Bonobo_ServerInfoList servers;
GHashTable *hash = NULL;
fprintf (stderr, "Testing server info load ...");
g_timer_start (timer);
for (i = 0; i < 10; i++)
bonobo_server_info_load (dirs, &servers, &hash,
bonobo_activation_hostname_get ());
fprintf (stderr, " %g(ms)\n",
g_timer_elapsed (timer, NULL) * 1000.0 / 10);
}
int
main (int argc, char *argv[])
{
free (malloc (8));
timer = g_timer_new ();
g_timer_start (timer);
add_initial_locales ();
test_server_info_load ();
if (g_getenv ("_MEMPROF_SOCKET")) {
g_warning ("Waiting for memprof\n");
g_main_context_iteration (NULL, TRUE);
}
return 0;
}
|
/* CAMERA: convex accelerated maximum entropy reconstruction algorithm.
* Copyright (C) 2015-2016 Bradley Worley <geekysuavo@gmail.com>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to:
*
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301, USA.
*/
/* include the core camera header. */
#include "camera.h"
/* main(): application entry point.
*
* arguments:
* @argc: number of command line arguments.
* @argv: command line argument string array.
*
* returns:
* integer indicating whether execution terminated without error (0)
* or not (!0).
*/
int main (int argc, char **argv) {
/* declare required variables:
* @T: task data structure pointer.
*/
task *T;
/* initialize a reconstruction task. */
T = task_alloc(argc, argv);
/* check if task initialization was successful. */
if (!T) {
/* if not, output an error message and return failure. */
failf("unable to initialize a reconstruction task");
return 1;
}
/* execute the reconstruction task. */
if (!task_run(T)) {
/* if unsuccessful, output an error message and return failure. */
failf("reconstruction task execution failed");
task_free(T);
return 1;
}
/* free the reconstruction task structure. */
task_free(T);
/* return success. */
return 0;
}
|
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008 Voltaire. All rights reserved
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2014 Intel, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* Resource Mapping
*/
#ifndef ORTE_RMAPS_RF_H
#define ORTE_RMAPS_RF_H
#include "orte_config.h"
#include "opal/class/opal_object.h"
#include "orte/mca/rmaps/rmaps.h"
BEGIN_C_DECLS
int orte_rmaps_rank_file_lex_destroy (void);
struct orte_rmaps_rf_component_t {
orte_rmaps_base_component_t super;
char *slot_list;
bool physical;
};
typedef struct orte_rmaps_rf_component_t orte_rmaps_rf_component_t;
ORTE_MODULE_DECLSPEC extern orte_rmaps_rf_component_t mca_rmaps_rank_file_component;
extern orte_rmaps_base_module_t orte_rmaps_rank_file_module;
typedef struct cpu_socket_t cpu_socket_t;
struct orte_rmaps_rank_file_map_t {
opal_object_t super;
char* node_name;
char slot_list[64];
};
typedef struct orte_rmaps_rank_file_map_t orte_rmaps_rank_file_map_t;
ORTE_DECLSPEC OBJ_CLASS_DECLARATION(orte_rmaps_rank_file_map_t);
END_C_DECLS
#endif
|
/* Qlom is copyright Openismus GmbH, 2009
*
* This file is part of Qlom
*
* Qlom is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Qlom is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Qlom. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef QLOM_DOCUMENT_H_
#define QLOM_DOCUMENT_H_
class QlomListLayoutModel;
class QlomTablesModel;
#include "table.h"
#include "error.h"
#include <memory>
#include <string>
#include <QList>
#include <QObject>
#include <QString>
#include <libglom/document/document.h>
/** A Glom document.
* A Glom document contains the information that is in a .glom file. It is
* initially blank, but a document can be loaded with the loadDocument()
* method. Models are obtained via the create*() calls. createTablesModel()
* creates a model for the list of tables in the document.
* createListLayoutModel() creates a model for the list layout of a
* specified table. createDefaultTableListLayoutModel() creates a model of the
* list layout for the default table of the document. As the create prefix
* suggests, the responsibility of destroying the models once they are no
* longer needed is placed on the caller. */
class QlomDocument : public QObject
{
Q_OBJECT
public:
typedef Glom::Document::type_listTableInfo GlomTables; // just an alias
/** A Glom document.
* Constructor for a blank QlomDocument. Before the object is any use,
* loadDocument() should be called.
* @param[in] parent a parent object, which errors will be sent to */
QlomDocument(QObject *parent = 0);
/** Load a Glom document from a file.
* Loads a Glom document from a file. This method can be called on a
* QlomDocument safely, even if a document has already been loaded.
* @param[in] filepath the location of the Glom document as an absolute
* filepath.
* @returns true on success, false on failure */
bool loadDocument(const QString &filepath);
/** Get a list of tables in the document.
* Creates a new model of the list of tables in the Glom document. The
* model must be destroyed by the caller when it is no longer needed.
* @returns a model of the tables in the document */
QlomTablesModel* createTablesModel();
/** Get a layout from the document.
* Creates a new model of the list layout of the table given in the
* tableName, which must match the name of the table in the database. The
* model must be destroyed by the caller when it is no longer needed.
* @param[in] tableName the name of the table to provide a layout for
* @returns a model of the layout */
QlomListLayoutModel* createListLayoutModel(const QString &tableName);
/** Get a layout of the default table from the document.
* Creates a new model of the list layout of the default table specified
* in the Glom document. The model must be destroyed by the caller when it
* is no longer needed.
* @returns a model of the layout, or 0 if no default table was found */
QlomListLayoutModel* createDefaultTableListLayoutModel();
/** Returns the error of the last operation that has failed. */
QlomError lastError() const;
private:
/** Convert a filepath to a URI.
* Converts an absolute filepath into a file URI. Any errors that occur
* are signalled via the errorRaised signal.
* @param[in] theFilepath the absolute filepath
* @returns the URI of the file */
std::string filepathToUri(const QString &theFilepath);
/** Open an SQLite database connection.
* Creates and opens a default QSqlDatabase connection. If authentication
* details are required, opens a connection dialog via QlomConnectionDialog
* that requests them from the user. Any errors that occur are signalled
* via the errorRaised signal.
* @see QlomConnectionDialog
* @returns true on success, false on failure */
bool openSqlite();
/** Fill tableList with tables read from the document.
* Fills the tableList member with a list of QlomTables read from the Glom
* document. In turn, calls fillRelationships() to fill each table with a
* list of relationships.
* @see fillRelationships() */
void fillTableList();
/** Fill a list with relationships from the document.
* Fills a QList with GlomRelationships, that can then be used in a
* GlomTable.
* @param[in] documentRelationships a list of relationships from the
document, for a single table
* @returns a list of relationships */
QList<QlomRelationship> fillRelationships(
const Glom::Document::type_vec_relationships &documentRelationships);
Glom::Document *document; /**< libglom's representaton of a Glom document */
QlomError theLastError; /**< contains the error of the last failed operation */
typedef QList<QlomTable> typeTableList;
typeTableList tableList; /**< a list of tables in the document */
};
#endif /* QLOM_DOCUMENT_H_ */
|
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Assistant of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef HELPVIEWERPRIVATE_H
#define HELPVIEWERPRIVATE_H
#include "centralwidget.h"
#include "helpviewer.h"
#include "openpagesmanager.h"
#include <QtCore/QObject>
#if defined(BROWSER_QTEXTBROWSER)
# include <QtWidgets/QTextBrowser>
#elif defined(BROWSER_QTWEBKIT)
# include <QtGui/QGuiApplication>
# include <QtGui/QScreen>
#endif // BROWSER_QTWEBKIT
QT_BEGIN_NAMESPACE
class HelpViewer::HelpViewerPrivate : public QObject
{
Q_OBJECT
public:
#if defined(BROWSER_QTEXTBROWSER)
HelpViewerPrivate(int zoom)
: zoomCount(zoom)
, forceFont(false)
, lastAnchor(QString())
, m_loadFinished(false)
{ }
#elif defined(BROWSER_QTWEBKIT)
HelpViewerPrivate()
: m_loadFinished(false)
{
// The web uses 96dpi by default on the web to preserve the font size across platforms, but
// since we control the content for the documentation, we want the system DPI to be used.
// - OS X reports 72dpi but doesn't allow changing the DPI, ignore anything below a 1.0 ratio to handle this.
// - On Windows and Linux don't zoom the default web 96dpi below a 1.25 ratio to avoid
// filtered images in the doc unless the font readability difference is considerable.
webDpiRatio = QGuiApplication::primaryScreen()->logicalDotsPerInch() / 96.;
if (webDpiRatio < 1.25)
webDpiRatio = 1.0;
}
#endif // BROWSER_QTWEBKIT
#if defined(BROWSER_QTEXTBROWSER)
bool hasAnchorAt(QTextBrowser *browser, const QPoint& pos)
{
lastAnchor = browser->anchorAt(pos);
if (lastAnchor.isEmpty())
return false;
lastAnchor = browser->source().resolved(lastAnchor).toString();
if (lastAnchor.at(0) == QLatin1Char('#')) {
QString src = browser->source().toString();
int hsh = src.indexOf(QLatin1Char('#'));
lastAnchor = (hsh >= 0 ? src.left(hsh) : src) + lastAnchor;
}
return true;
}
public slots:
void openLink()
{
doOpenLink(false);
}
void openLinkInNewPage()
{
doOpenLink(true);
}
public:
int zoomCount;
bool forceFont;
QString lastAnchor;
#elif defined(BROWSER_QTWEBKIT)
qreal webDpiRatio;
#endif // BROWSER_QTWEBKIT
public:
bool m_loadFinished;
private:
void doOpenLink(bool newPage)
{
if (lastAnchor.isEmpty())
return;
if (newPage)
OpenPagesManager::instance()->createPage(lastAnchor);
else
CentralWidget::instance()->setSource(lastAnchor);
lastAnchor.clear();
}
};
QT_END_NAMESPACE
#endif // HELPVIEWERPRIVATE_H
|
/* $Id: SendWidget.h 2769 2012-06-12 23:18:08Z IMPOMEZIA $
* IMPOMEZIA Simple Chat
* Copyright © 2008-2012 IMPOMEZIA <schat@impomezia.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SENDWIDGET_H_
#define SENDWIDGET_H_
#include <QWidget>
#include <QMap>
#include "schat.h"
#include "ui/ToolBarAction.h"
class AbstractTab;
class InputWidget;
class Notify;
class QMenu;
class QToolBar;
class SCHAT_CORE_EXPORT SendWidget : public QWidget
{
Q_OBJECT
public:
SendWidget(QWidget *parent = 0);
inline InputWidget *input() { return m_input; }
inline static SendWidget *i() { return m_self; }
static void add(ToolBarActionCreator *creator, bool refill = true);
void setInputFocus();
signals:
void send(const QString &text);
public slots:
void insertHtml(const QString &text);
protected:
bool event(QEvent *event);
void contextMenuEvent(QContextMenuEvent *event);
private slots:
void notify(const Notify ¬ify);
void pageChanged(AbstractTab *tab);
void settingsChanged(const QString &key, const QVariant &value);
private:
QAction* before(int weight) const;
QStringList available() const;
void add(int weight, ToolBarActionCreator *creator, bool refill = true);
void add(ToolBarAction action);
void refill();
void remove(ToolBarAction action);
void updateStyleSheet();
InputWidget *m_input; ///< Виджет ввода текста.
QMap<int, ToolBarAction> m_actions; ///< Отсортированная таблица всех доступных действий.
QMap<QString, ToolBarAction> m_names; ///< Таблица имён действий.
QStringList m_layout; ///< Список действий размещённых на тулбаре.
QToolBar *m_toolBar; ///< Панель инструментов.
static SendWidget *m_self; ///< Указатель на себя.
};
#endif /* SENDWIDGET_H_ */
|
#ifdef USE_NORCROFT_PRAGMAS
#pragma force_top_level
#pragma include_only_once
#endif
/*
* C compiler file cfe/lex.h:
* Copyright (C) Acorn Computers Ltd., 1988
* Copyright (C) Codemist Ltd., 1988
*/
/*
* RCS $Revision: 1.1 $
* Checkin $Date: 1992/03/23 15:10:26 $
* Revising $Author: nickc $
*/
#ifndef _lex_h
#define _lex_h
#ifndef _defs_LOADED
# include "defs.h"
#endif
extern SymInfo curlex; /* Current token and aux. info. */
#ifdef EXTENSION_VALOF
extern bool inside_valof_block;
#endif
extern AEop nextsym(void);
extern int errs_on_this_sym;
extern AEop nextsym_for_hashif(void);
extern void lex_init(void);
extern void lex_beware_reinit(void);
extern void lex_reinit(void);
#endif
/* end of cfe/lex.h */
|
/* GEOTRIVIALUtilities is an under-construction set of C functions which supports i/o interface
and other utilities for models like GEOtop
GEOTRIVIALUtilities Version 1.0
file read_command_line.h
Copyright (c), 2011 Emanuele Cordano
This file is part of GEOTRIVIALUtilities.
GEOTRIVIALUtilities is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
GEOTRIVIALUtilities is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License v. 3.0 for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef READ_COMMANDLINE_H
#define READ_COMMANDLINE_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#define SUCCESS 1
#define NO_SUCCESS 0
char *read_option_string(int argc,char *argv[], char *option_f,char *no_option_argument,short print);
//std::string read_option_string(int argc,char* argv[], const std::string& option_f,const std::string& no_option_argument,short print);
double read_option_double(int argc,char *argv[], char *option_f,char *no_option_argument,double default_value,short print);
//double read_option_double(int argc,char* argv[], std::string& option_f, std::string& no_option_argument, double default_value,short print);
int read_flag(int argc,char *argv[],char *flag,short print);
/* debugging options */
#define PRINT_FLAG "-print" /*!< flag which prints possible warning message */
#define PRINT_ACTIVATED read_flag(argc,argv,PRINT_FLAG,0)
/* */
#define MISSING_ARGUMENT "missing_argument"
#endif
|
/* GormButtonEditor.h - Editor for buttons.
*
* Copyright (C) 2002 Free Software Foundation, Inc.
*
* Author: Pierre-Yves Rivaille
* Date: Aug 2002
*
* This file is part of GNUstep.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
*/
#ifndef INCLUDED_GormButtonEditor_h
#define INCLUDED_GormButtonEditor_h
#include <GormCore/GormCore.h>
@class NSTextView;
@interface GormButtonEditor : GormControlEditor
{
NSTextView *tempTextView;
}
@end
#endif
|
/**
* @file MainTabBarController.h
*
* @author luckytianyiyan@gmail.com
* @date 15/10/31
* @copyright Copyright © 2015年 luckytianyiyan. All rights reserved.
*/
#import <UIKit/UIKit.h>
#import "MainTabBarViewModel.h"
@interface MainTabBarController : UITabBarController
@property (strong, nonatomic) MainTabBarViewModel *viewModel;
@end
|
/*
* mwmmenu - a program to produce application menus for MWM and other window
* managers, based on freedesktop.org desktop entries.
*
* Copyright (C) 2015 Charles Bos
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CATEGORY_H_
#define _CATEGORY_H_
#include "DesktopFile.h"
#define GET_ID_INI(X) DesktopFile::getID(X)
#define GET_ID_XML(X) DesktopFile::getID(X, '<', '>')
#define GET_VAL_INI(X) DesktopFile::getSingleValue(X)
#define GET_VAL_XML(X) DesktopFile::getSingleValue(X, '>', '<')
class Category
{
public:
Category(const char *dirFile, const std::vector<std::string>& menuFiles,
bool useIcons, const std::vector<IconSpec>& iconpaths,
const std::string& iconsXdgSize, bool iconsXdgOnly);
Category(std::vector<std::string> menuDef, const char *dirFile,
bool useIcons, const std::vector<IconSpec>& iconpaths,
const std::string& iconsXdgSize, bool iconsXdgOnly, int depth);
Category(const std::string& name, bool useIcons,
const std::vector<IconSpec>& iconpaths, const std::string& iconsXdgSize,
bool iconsXdgOnly);
std::string name;
std::string icon;
int depth;
bool nodisplay;
std::vector<DesktopFile*> getEntries();
std::vector<DesktopFile*> getEntriesR();
std::vector<Category*> getSubcats();
std::vector<Category*> getSubcatsR();
std::vector<std::string> getIncludes();
std::vector<std::string> getExcludes();
bool registerDF(DesktopFile *df, bool force = false);
private:
std::string dirFile;
std::vector<std::string> menuFiles;
std::ifstream dir_f;
std::ifstream menu_f;
std::vector<std::string> validNames;
std::vector<IconSpec> iconpaths;
std::string iconsXdgSize;
bool iconsXdgOnly;
bool useIcons;
std::vector<DesktopFile*> incEntries;
std::vector<Category*> incCategories;
std::vector<std::string> incEntryFiles;
std::vector<std::string> excEntryFiles;
static int registerCount;
static std::vector<DesktopFile*> incEntriesR;
static std::vector<Category*> incSubcatsR;
void registerDF(Category *cat, DesktopFile *df, bool force = false);
void getEntriesR(Category *cat);
void getSubcatsR(Category *cat);
void readMenufiles();
void parseDir();
void parseMenu(const std::vector<std::string>& menu);
void getCategoryIcon();
};
template <typename T> bool myCompare(T *a, T *b)
{
std::string name_a = a->name;
std::string name_b = b->name;
for (unsigned int x = 0; x < name_a.size(); x++)
name_a.at(x) = tolower(name_a.at(x));
for (unsigned int x = 0; x < name_b.size(); x++)
name_b.at(x) = tolower(name_b.at(x));
if (name_a < name_b) return true;
else return false;
}
#endif
|
#include "getch.h"
char getch()
{
char buf = 0;
struct termios old={0};
if (tcgetattr(0, &old) < 0)
perror("tcsetattr()");
old.c_lflag &= ~ICANON;
old.c_lflag &= ~ECHO;
old.c_cc[VMIN] = 1;
old.c_cc[VTIME] = 0;
if (tcsetattr(0, TCSANOW, &old) < 0)
perror("tcsetattr ICANON");
if (read(0, &buf, 1) < 0)
perror ("read()");
old.c_lflag |= ICANON;
old.c_lflag |= ECHO;
if (tcsetattr(0, TCSADRAIN, &old) < 0)
perror ("tcsetattr ~ICANON");
return (buf);
}
|
/******************************************************************************
*
* Copyright (C) 1999-2012 Broadcom Corporation
*
* 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 SRVC_DIS_INT_H
#define SRVC_DIS_INT_H
#include "bt_target.h"
#include "srvc_api.h"
#include "gatt_api.h"
#define DIS_MAX_CHAR_NUM 9
typedef struct
{
UINT16 uuid;
UINT16 handle;
}tDIS_DB_ENTRY;
#define DIS_SYSTEM_ID_SIZE 8
#define DIS_PNP_ID_SIZE 7
typedef struct
{
tDIS_DB_ENTRY dis_attr[DIS_MAX_CHAR_NUM];
tDIS_VALUE dis_value;
tDIS_READ_CBACK *p_read_dis_cback;
UINT16 service_handle;
UINT16 max_handle;
BOOLEAN enabled;
UINT8 dis_read_uuid_idx;
}tDIS_CB;
#ifdef __cplusplus
extern "C" {
#endif
/* Global GATT data */
#if GATT_DYNAMIC_MEMORY == FALSE
GATT_API extern tDIS_CB dis_cb;
#else
GATT_API extern tDIS_CB *dis_cb_ptr;
#define dis_cb (*dis_cb_ptr)
#endif
extern BOOLEAN dis_valid_handle_range(UINT16 handle);
extern UINT8 dis_read_attr_value (UINT8 clcb_idx, UINT16 handle, tGATT_VALUE *p_value,
BOOLEAN is_long, tGATT_STATUS *p_status);
extern UINT8 dis_write_attr_value(tGATT_WRITE_REQ * p_data, tGATT_STATUS *p_status);
extern void dis_c_cmpl_cback (tSRVC_CLCB *p_clcb, tGATTC_OPTYPE op,
tGATT_STATUS status, tGATT_CL_COMPLETE *p_data);
#ifdef __cplusplus
}
#endif
#endif
|
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file BlockViewText.h
//! \ingroup gui
//! \author Martin Bauer <martin.bauer@fau.de>
//
//======================================================================================================================
#pragma once
#ifndef Q_MOC_RUN
#include "Gui.h"
#endif
#include <QListWidget>
namespace walberla {
namespace blockforest {
class BlockForest;
}
}
namespace walberla {
namespace gui {
/********************************************************************************************************************
* Shows a list view of the blocks contained in a BlockForest
*
* Analog to BlockView3D, but uglier :) however with to QGl dependency
*
* \ingroup gui
*
* - the user can drag single blocks out of the view
* - the dragged MIME data carries a blockforest::Block pointer
* - the distance of the Blocks can be modified by Ctrl+MouseWheel
*
* Usage: - call setup() with a BlockForest pointer
* - accept drop events, for MIME data type BLOCK_MIMETYPE
*
*******************************************************************************************************************/
class BlockViewText : public QListWidget
{
Q_OBJECT
public:
BlockViewText( QWidget * parent = 0 );
/// Shows the contents of a BlockField
/// use this a initialization function of the widget
void setup( BlockForest * blockForest);
public slots:
void onBlockForestChange();
protected:
virtual void mousePressEvent(QMouseEvent * me);
blockforest::BlockForest * blockForest_;
};
} // namespace gui
} // namespace walberla
|
#include <stdio.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <memory.h>
#define PORT 2000
int main(void)
{
int c_socket, s_socket;
int len;
struct sockaddr_in c_addr, s_addr;
int result;
int a;
int b;
char op;
s_socket = socket(PF_INET, SOCK_STREAM, 0);
memset(&s_addr, 0, sizeof(s_addr));
s_addr.sin_addr.s_addr = htonl(INADDR_ANY);
s_addr.sin_family = AF_INET;
s_addr.sin_port = htons(PORT);
if(bind(s_socket, (struct sockaddr*)&s_addr, sizeof(s_addr)) == -1)
{
printf("can not bind\n");
return -1;
}
if(listen(s_socket, 5) == -1)
{
printf("listen fail\n");
return -1;
}
len = sizeof(c_addr);
c_socket = accept(s_socket, (struct sockaddr*)&c_addr, &len);
while(1)
{
read(c_socket, &a, sizeof(int));
read(c_socket, &op, 1);
read(c_socket, &b, sizeof(int));
switch(op)
{
case '+':
result = a + b;
break;
case '-':
result = a - b;
break;
case '*':
result = a * b;
break;
case '/':
result = a / b;
break;
}
write(c_socket, &result, sizeof(int));
}
close(c_socket);
close(s_socket);
return 0;
}
|
/*
* HebbNeuron.h
*
* Created on: Nov 14, 2016
* Author: maria
*/
#ifndef HEBBNEURON_H_
#define HEBBNEURON_H_
#include<math.h>
#include<stdlib.h>
class HebbNeuron
{
public:
double * weight;
// HebbNeuron * input;
double * input;
int size;
double w_0;
double learn_number;
double output;
HebbNeuron(){ }
void init(int size){
learn_number = 0.1;
this->size = size;
weight = new double[size];
input = new double[size];
initialize_weight();
output = -1;
}
~HebbNeuron()
{
if (weight)
delete[] weight;
if (input)
delete [] input;
}
void initialize_weight()
{
w_0 = (double)rand() / (double)RAND_MAX; // [0,...,1]
for (int i = 0; i < size; i++)
{
weight[i] = (double)rand() / (double)RAND_MAX;
}
}
double activation_function(double s)
{
// double result, beta = 0.6;
// result = 1.0 / (1.0 + exp((-beta) * s));
double result;
if(s < 0) result = -1;
else result = 1;
return result;
}
void ask(double * input)
{
double s = w_0;
for(int i = 0; i < size; i++)
s += weight[i] * input[i];
activation_function(s);
output = s;
}
void learn(double d, double * input)
{
for(int i = 0; i < size; i++)
weight[i] += learn_number * d * input[i];
w_0 += learn_number * d;
}
void learn(double * input)
{
for(int i = 0; i < size; i++)
weight[i] += learn_number * output * input[i];
w_0 += learn_number * output;
}
HebbNeuron & operator = (HebbNeuron & p1)
{
this->input = p1.input;
this->weight = p1.weight;
this->size = p1.size;
this->output = p1.output;
this->w_0 = p1.w_0;
this->learn_number = p1.learn_number;
return *this;
}
};
#endif /* HEBBNEURON_H_ */
|
/*
* Copyright (C) 2013 Boris BREZILLON <b.brezillon@overkiz.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*/
#include <linux/clk-provider.h>
#include <linux/clkdev.h>
#include <linux/clk/at91_pmc.h>
#include <linux/of.h>
#include <linux/mfd/syscon.h>
#include <linux/regmap.h>
#include "pmc.h"
#define SMD_SOURCE_MAX 2
#define SMD_DIV_SHIFT 8
#define SMD_MAX_DIV 0xf
struct at91sam9x5_clk_smd
{
struct clk_hw hw;
struct regmap *regmap;
};
#define to_at91sam9x5_clk_smd(hw) \
container_of(hw, struct at91sam9x5_clk_smd, hw)
static unsigned long at91sam9x5_clk_smd_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
struct at91sam9x5_clk_smd *smd = to_at91sam9x5_clk_smd(hw);
unsigned int smdr;
u8 smddiv;
regmap_read(smd->regmap, AT91_PMC_SMD, &smdr);
smddiv = (smdr & AT91_PMC_SMD_DIV) >> SMD_DIV_SHIFT;
return parent_rate / (smddiv + 1);
}
static long at91sam9x5_clk_smd_round_rate(struct clk_hw *hw, unsigned long rate,
unsigned long *parent_rate)
{
unsigned long div;
unsigned long bestrate;
unsigned long tmp;
if (rate >= *parent_rate)
{
return *parent_rate;
}
div = *parent_rate / rate;
if (div > SMD_MAX_DIV)
{
return *parent_rate / (SMD_MAX_DIV + 1);
}
bestrate = *parent_rate / div;
tmp = *parent_rate / (div + 1);
if (bestrate - rate > rate - tmp)
{
bestrate = tmp;
}
return bestrate;
}
static int at91sam9x5_clk_smd_set_parent(struct clk_hw *hw, u8 index)
{
struct at91sam9x5_clk_smd *smd = to_at91sam9x5_clk_smd(hw);
if (index > 1)
{
return -EINVAL;
}
regmap_update_bits(smd->regmap, AT91_PMC_SMD, AT91_PMC_SMDS,
index ? AT91_PMC_SMDS : 0);
return 0;
}
static u8 at91sam9x5_clk_smd_get_parent(struct clk_hw *hw)
{
struct at91sam9x5_clk_smd *smd = to_at91sam9x5_clk_smd(hw);
unsigned int smdr;
regmap_read(smd->regmap, AT91_PMC_SMD, &smdr);
return smdr & AT91_PMC_SMDS;
}
static int at91sam9x5_clk_smd_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
{
struct at91sam9x5_clk_smd *smd = to_at91sam9x5_clk_smd(hw);
unsigned long div = parent_rate / rate;
if (parent_rate % rate || div < 1 || div > (SMD_MAX_DIV + 1))
{
return -EINVAL;
}
regmap_update_bits(smd->regmap, AT91_PMC_SMD, AT91_PMC_SMD_DIV,
(div - 1) << SMD_DIV_SHIFT);
return 0;
}
static const struct clk_ops at91sam9x5_smd_ops =
{
.recalc_rate = at91sam9x5_clk_smd_recalc_rate,
.round_rate = at91sam9x5_clk_smd_round_rate,
.get_parent = at91sam9x5_clk_smd_get_parent,
.set_parent = at91sam9x5_clk_smd_set_parent,
.set_rate = at91sam9x5_clk_smd_set_rate,
};
static struct clk_hw *__init
at91sam9x5_clk_register_smd(struct regmap *regmap, const char *name,
const char **parent_names, u8 num_parents)
{
struct at91sam9x5_clk_smd *smd;
struct clk_hw *hw;
struct clk_init_data init;
int ret;
smd = kzalloc(sizeof(*smd), GFP_KERNEL);
if (!smd)
{
return ERR_PTR(-ENOMEM);
}
init.name = name;
init.ops = &at91sam9x5_smd_ops;
init.parent_names = parent_names;
init.num_parents = num_parents;
init.flags = CLK_SET_RATE_GATE | CLK_SET_PARENT_GATE;
smd->hw.init = &init;
smd->regmap = regmap;
hw = &smd->hw;
ret = clk_hw_register(NULL, &smd->hw);
if (ret)
{
kfree(smd);
hw = ERR_PTR(ret);
}
return hw;
}
static void __init of_at91sam9x5_clk_smd_setup(struct device_node *np)
{
struct clk_hw *hw;
unsigned int num_parents;
const char *parent_names[SMD_SOURCE_MAX];
const char *name = np->name;
struct regmap *regmap;
num_parents = of_clk_get_parent_count(np);
if (num_parents == 0 || num_parents > SMD_SOURCE_MAX)
{
return;
}
of_clk_parent_fill(np, parent_names, num_parents);
of_property_read_string(np, "clock-output-names", &name);
regmap = syscon_node_to_regmap(of_get_parent(np));
if (IS_ERR(regmap))
{
return;
}
hw = at91sam9x5_clk_register_smd(regmap, name, parent_names,
num_parents);
if (IS_ERR(hw))
{
return;
}
of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
}
CLK_OF_DECLARE(at91sam9x5_clk_smd, "atmel,at91sam9x5-clk-smd",
of_at91sam9x5_clk_smd_setup);
|
#pragma once
#ifndef LOG_H
#define LOG_H
class Log {
public:
Log() {
this->using_file = false;
this->outfile = "";
this->log_enum[1] = "Debug";
this->log_enum[2] = "Error";
this->log_enum[3] = "Notification";
this->log_enum[4] = "Test";
};
/* GetInstance */
static Log& get_instance() {
static Log instance;
return instance;
};
void unset_file();
void set_file(string filename);
void write(string msg, short type = 0);
private:
bool using_file;
string outfile;
map<short, string> log_enum;
};
#endif
|
#ifndef STORM_STORAGE_DD_CUDDADDITERATOR_H_
#define STORM_STORAGE_DD_CUDDADDITERATOR_H_
#include <cstdint>
#include <memory>
#include <set>
#include <tuple>
#include <utility>
#include "storm/storage/dd/AddIterator.h"
#include "storm/storage/expressions/SimpleValuation.h"
// Include the C++-interface of CUDD.
#include "cuddObj.hh"
namespace storm {
namespace dd {
// Forward-declare the DdManager class.
template<DdType Type>
class DdManager;
template<DdType Type, typename ValueType>
class InternalAdd;
template<typename ValueType>
class AddIterator<DdType::CUDD, ValueType> {
public:
friend class InternalAdd<DdType::CUDD, ValueType>;
// Default-instantiate the constructor.
AddIterator();
// Forbid copy-construction and copy assignment, because ownership of the internal pointer is unclear then.
AddIterator(AddIterator<DdType::CUDD, ValueType> const& other) = delete;
AddIterator& operator=(AddIterator<DdType::CUDD, ValueType> const& other) = delete;
// Provide move-construction and move-assignment, though.
AddIterator(AddIterator<DdType::CUDD, ValueType>&& other);
AddIterator& operator=(AddIterator<DdType::CUDD, ValueType>&& other);
/*!
* Destroys the forward iterator and frees the generator as well as the cube if they are not the nullptr.
*/
~AddIterator();
/*!
* Moves the iterator one position forward.
*/
AddIterator<DdType::CUDD, ValueType>& operator++();
/*!
* Returns a pair consisting of a valuation of meta variables and the value to which this valuation is
* mapped. Note that the result is returned by value.
*
* @return A pair of a valuation and the function value.
*/
std::pair<storm::expressions::SimpleValuation, ValueType> operator*() const;
/*!
* Compares the iterator with the given one. Two iterators are considered equal when all their underlying
* data members are the same or they both are at their end.
*
* @param other The iterator with which to compare.
* @return True if the two iterators are considered equal.
*/
bool operator==(AddIterator<DdType::CUDD, ValueType> const& other) const;
/*!
* Compares the iterator with the given one. Two iterators are considered unequal iff they are not
* considered equal.
*
* @param other The iterator with which to compare.
* @return True if the two iterators are considered unequal.
*/
bool operator!=(AddIterator<DdType::CUDD, ValueType> const& other) const;
private:
/*!
* Constructs a forward iterator using the given generator with the given set of relevant meta variables.
*
* @param ddManager The manager responsible for the DD over which to iterate.
* @param generator The generator used to enumerate the cubes of the DD.
* @param cube The cube as represented by CUDD.
* @param value The value the cube is mapped to.
* @param isAtEnd A flag that indicates whether the iterator is at its end and may not be moved forward any
* more.
* @param metaVariables The meta variables that appear in the DD.
* @param enumerateDontCareMetaVariables If set to true, all meta variable assignments are enumerated, even
* if a meta variable does not at all influence the the function value.
*/
AddIterator(DdManager<DdType::CUDD> const& ddManager, DdGen* generator, int* cube, ValueType const& value, bool isAtEnd,
std::set<storm::expressions::Variable> const* metaVariables = nullptr, bool enumerateDontCareMetaVariables = true);
/*!
* Recreates the internal information when a new cube needs to be treated.
*/
void treatNewCube();
/*!
* Updates the internal information when the next solution of the current cube needs to be treated.
*/
void treatNextInCube();
// The manager responsible for the meta variables (and therefore the underlying DD).
DdManager<DdType::CUDD> const* ddManager;
// The CUDD generator used to enumerate the cubes of the DD.
DdGen* generator;
// The currently considered cube of the DD.
int* cube;
// The function value of the current cube.
double valueAsDouble;
// A flag that indicates whether the iterator is at its end and may not be moved further. This is also used
// for the check against the end iterator.
bool isAtEnd;
// The set of meta variables appearing in the DD.
std::set<storm::expressions::Variable> const* metaVariables;
// A flag that indicates whether the iterator is supposed to enumerate meta variable valuations even if
// they don't influence the function value.
bool enumerateDontCareMetaVariables;
// A number that represents how many assignments of the current cube have already been returned previously.
// This is needed, because cubes may represent many assignments (if they have don't care variables).
uint_fast64_t cubeCounter;
// A vector of tuples of the form <metaVariable, bitIndex>.
std::vector<std::tuple<storm::expressions::Variable, uint_fast64_t>> relevantDontCareDdVariables;
// The current valuation of meta variables.
storm::expressions::SimpleValuation currentValuation;
};
} // namespace dd
} // namespace storm
#endif /* STORM_STORAGE_DD_CUDDADDITERATOR_H_ */
|
/*
* Copyright (C) 2012-2015 Leo Grange <grangeleo@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _ARCH_SH_FREQ_H
#define _ARCH_SH_FREQ_H
/**
* SH3 CPU and peripheral frequency control.
*/
// CKIO frequency multiplier
#define FREQ_STC_4 3
#define FREQ_STC_3 2
#define FREQ_STC_2 1
#define FREQ_STC_1 0
#define FREQ_STC_SAME -1
// Internal and Peripheral frequency dividers (4 for 1/4e multiplier)
#define FREQ_DIV_4 3
#define FREQ_DIV_3 2
#define FREQ_DIV_2 1
#define FREQ_DIV_1 0
#define FREQ_DIV_SAME -1
/**
* Change global frequency multiplier, or Internal/Peripheral clock divider.
*/
int freq_change(int ckio_mul, int ifc, int pfc);
/**
* Calibrate CKIO frequency, allowing to know the internal and peripheral clock
* frequency (useful to know the real frequency used internaly, and for timers).
* Because of usage of RTC and TMU0 interrupt, RTC must be initialized and no
* other module should use RTC interrupt before.
*/
int freq_time_calibrate();
/**
* Get CKIO frequency (after a freq_time_calibrate() call).
*/
unsigned int freq_get_ckio_hz();
/**
* Get Peripheral clock frequency (after a freq_time_calibrate() call).
*/
unsigned int freq_get_peripheral_hz();
/**
* Get Internal clock frequency (after a freq_time_calibrate() call).
*/
unsigned int freq_get_internal_hz();
#endif //_ARCH_SH_FREQ_H
|
/*
* Copyright 2010-2015 OpenXcom Developers.
*
* This file is part of OpenXcom.
*
* OpenXcom is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenXcom is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenXcom. If not, see <http:///www.gnu.org/licenses/>.
*/
#ifndef OPENXCOM_GEOSCAPESTATE_H
#define OPENXCOM_GEOSCAPESTATE_H
#include "../Engine/State.h"
#include <list>
namespace OpenXcom
{
class Surface;
class Globe;
class TextButton;
class InteractiveSurface;
class Text;
class Timer;
class DogfightState;
class Ufo;
class MissionSite;
class Base;
/**
* Geoscape screen which shows an overview of
* the world and lets the player manage the game.
*/
class GeoscapeState : public State
{
private:
Surface *_bg, *_sideLine, *_sidebar;
Globe *_globe;
TextButton *_btnIntercept, *_btnBases, *_btnGraphs, *_btnUfopaedia, *_btnOptions, *_btnFunding;
TextButton *_timeSpeed;
TextButton *_btn5Secs, *_btn1Min, *_btn5Mins, *_btn30Mins, *_btn1Hour, *_btn1Day;
TextButton *_sideTop, *_sideBottom;
InteractiveSurface *_btnRotateLeft, *_btnRotateRight, *_btnRotateUp, *_btnRotateDown, *_btnZoomIn, *_btnZoomOut;
Text *_txtFunds, *_txtHour, *_txtHourSep, *_txtMin, *_txtMinSep, *_txtSec, *_txtWeekday, *_txtDay, *_txtMonth, *_txtYear;
Timer *_gameTimer, *_zoomInEffectTimer, *_zoomOutEffectTimer, *_dogfightStartTimer, *_dogfightTimer;
bool _pause, _zoomInEffectDone, _zoomOutEffectDone;
Text *_txtDebug;
std::list<State*> _popups;
std::list<DogfightState*> _dogfights, _dogfightsToBeStarted;
size_t _minimizedDogfights;
public:
/// Creates the Geoscape state.
GeoscapeState();
/// Cleans up the Geoscape state.
~GeoscapeState();
/// Handle keypresses.
void handle(Action *action);
/// Updates the palette and timer.
void init();
/// Runs the timer.
void think();
/// Displays the game time/date. (+Funds)
void timeDisplay();
/// Advances the game timer.
void timeAdvance();
/// Trigger whenever 5 seconds pass.
void time5Seconds();
/// Trigger whenever 10 minutes pass.
void time10Minutes();
/// Trigger whenever 30 minutes pass.
void time30Minutes();
/// Trigger whenever 1 hour passes.
void time1Hour();
/// Trigger whenever 1 day passes.
void time1Day();
/// Trigger whenever 1 month passes.
void time1Month();
/// Resets the timer to minimum speed.
void timerReset();
/// Displays a popup window.
void popup(State *state);
/// Gets the Geoscape globe.
Globe *getGlobe() const;
/// Handler for clicking the globe.
void globeClick(Action *action);
/// Handler for clicking the Intercept button.
void btnInterceptClick(Action *action);
/// Handler for clicking the Bases button.
void btnBasesClick(Action *action);
/// Handler for clicking the Graph button.
void btnGraphsClick(Action *action);
/// Handler for clicking the Ufopaedia button.
void btnUfopaediaClick(Action *action);
/// Handler for clicking the Options button.
void btnOptionsClick(Action *action);
/// Handler for clicking the Funding button.
void btnFundingClick(Action *action);
/// Handler for pressing the Rotate Left arrow.
void btnRotateLeftPress(Action *action);
/// Handler for releasing the Rotate Left arrow.
void btnRotateLeftRelease(Action *action);
/// Handler for pressing the Rotate Right arrow.
void btnRotateRightPress(Action *action);
/// Handler for releasing the Rotate Right arrow.
void btnRotateRightRelease(Action *action);
/// Handler for pressing the Rotate Up arrow.
void btnRotateUpPress(Action *action);
/// Handler for releasing the Rotate Up arrow.
void btnRotateUpRelease(Action *action);
/// Handler for pressing the Rotate Down arrow.
void btnRotateDownPress(Action *action);
/// Handler for releasing the Rotate Down arrow.
void btnRotateDownRelease(Action *action);
/// Handler for left-clicking the Zoom In icon.
void btnZoomInLeftClick(Action *action);
/// Handler for right-clicking the Zoom In icon.
void btnZoomInRightClick(Action *action);
/// Handler for left-clicking the Zoom Out icon.
void btnZoomOutLeftClick(Action *action);
/// Handler for right-clicking the Zoom Out icon.
void btnZoomOutRightClick(Action *action);
/// Blit method - renders the state and dogfights.
void blit();
/// Globe zoom in effect for dogfights.
void zoomInEffect();
/// Globe zoom out effect for dogfights.
void zoomOutEffect();
/// Multi-dogfights logic handling.
void handleDogfights();
/// Gets the number of minimized dogfights.
int minimizedDogfightsCount();
/// Starts a new dogfight.
void startDogfight();
/// Get first free dogfight slot.
int getFirstFreeDogfightSlot();
/// Handler for clicking the timer button.
void btnTimerClick(Action *action);
/// Process a mission site
bool processMissionSite(MissionSite *site) const;
/// Handles base defense
void handleBaseDefense(Base *base, Ufo *ufo);
/// Update the resolution settings, we just resized the window.
void resize(int &dX, int &dY);
private:
/// Handle alien mission generation.
void determineAlienMissions();
/// Process each individual mission script command.
bool processCommand(RuleMissionScript *command);
};
}
#endif
|
/*
* This file is part of GReminder.
*
* Copyright 2014 Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
*
* GReminder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GReminder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GReminder. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __G_REMINDER_LIST_WINDOW_H__
#define __G_REMINDER_LIST_WINDOW_H__
#include "greminder-window.h"
G_BEGIN_DECLS
#define G_REMINDER_TYPE_LIST_WINDOW (g_reminder_list_window_get_type ())
#define G_REMINDER_LIST_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_REMINDER_TYPE_LIST_WINDOW, GReminderListWindow))
#define G_REMINDER_IS_LIST_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_REMINDER_TYPE_LIST_WINDOW))
#define G_REMINDER_LIST_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G_REMINDER_TYPE_LIST_WINDOW, GReminderListWindowClass))
#define G_REMINDER_IS_LIST_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G_REMINDER_TYPE_LIST_WINDOW))
#define G_REMINDER_LIST_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G_REMINDER_TYPE_LIST_WINDOW, GReminderListWindowClass))
typedef struct _GReminderListWindow GReminderListWindow;
typedef struct _GReminderListWindowClass GReminderListWindowClass;
G_REMINDER_VISIBLE
GType g_reminder_list_window_get_type (void);
GtkWidget *g_reminder_list_window_new (GReminderWindow *win,
const gchar *search,
const GSList *items);
G_END_DECLS
#endif /*__G_REMINDER_LIST_WINDOW_H__*/
|
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/proc_fs.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <asm/ptrace.h>
#include <asm/uaccess.h>
#define SAMPLE_BUFFER_SIZE 8192
static char *sample_buffer;
static char *sample_buffer_pos;
static int prof_running = 0;
void cris_profile_sample(struct pt_regs *regs)
{
if (!prof_running)
{
return;
}
if (user_mode(regs))
{
*(unsigned int *)sample_buffer_pos = current->pid;
}
else
{
*(unsigned int *)sample_buffer_pos = 0;
}
*(unsigned int *)(sample_buffer_pos + 4) = instruction_pointer(regs);
sample_buffer_pos += 8;
if (sample_buffer_pos == sample_buffer + SAMPLE_BUFFER_SIZE)
{
sample_buffer_pos = sample_buffer;
}
}
static ssize_t
read_cris_profile(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
unsigned long p = *ppos;
ssize_t ret;
ret = simple_read_from_buffer(buf, count, ppos, sample_buffer,
SAMPLE_BUFFER_SIZE);
if (ret < 0)
{
return ret;
}
memset(sample_buffer + p, 0, ret);
return ret;
}
static ssize_t
write_cris_profile(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
sample_buffer_pos = sample_buffer;
memset(sample_buffer, 0, SAMPLE_BUFFER_SIZE);
return count < SAMPLE_BUFFER_SIZE ? count : SAMPLE_BUFFER_SIZE;
}
static const struct file_operations cris_proc_profile_operations =
{
.read = read_cris_profile,
.write = write_cris_profile,
.llseek = default_llseek,
};
static int __init init_cris_profile(void)
{
struct proc_dir_entry *entry;
sample_buffer = kmalloc(SAMPLE_BUFFER_SIZE, GFP_KERNEL);
if (!sample_buffer)
{
return -ENOMEM;
}
sample_buffer_pos = sample_buffer;
entry = proc_create("system_profile", S_IWUSR | S_IRUGO, NULL,
&cris_proc_profile_operations);
if (entry)
{
proc_set_size(entry, SAMPLE_BUFFER_SIZE);
}
prof_running = 1;
return 0;
}
__initcall(init_cris_profile);
|
#include "../syscall/sysCall.h"
#include "../include/i486/cs452.h"
#include "../include/i486/machine/serial.h"
/* make matrix task running up to full tasks(63 tasks) */
#undef MATRIX_TASKS
#include "../train/ironBird.h"
char *testStr="1234567890abcdefghijklmnopqrstuvwxyz";
#define STAT_TID 3
/* higest priority + 1 */
#define NAME_SERVER_PRI 2
#define CREATE_STAT
main() {
int i;
int tid;
int numTask;
int NumMatrix;
int runningTime;
char inputChar;
console_clear();
numTask = 3; /* kernel, init, idle already maden from kernel */
#ifdef CREATE_STAT
/* doing statistics job */
/* do not remove this */
/* if you don't want this change sched.c */
/* that file is related with idle.c */
numTask++;
tid = Create("Stat", LOWEST_PRI - 1); /* tid = 3 */
#endif /* CREATE_STAT */
/* Create Name server */
numTask++;
tid = Create("NameServer", NAME_SERVER_PRI ); /* tid = 4 */
Delay(TICKS_PER_SEC * 6);
console_xy( 45, 0);
cprintf(
"[ F E M O S ] Fast EMbedded Operating System. ");
console_xy( 0, 2);
cprintf(
"-----------------------------------------------------------------"
"-----------------------------------------------------------------");
console_xy( 90, 4);
cprintf( "CPU Usage: %");
/* !!! do not change the creating order until Name server is done */
numTask++;
tid = Create("CommandSrv", CommandSrvPriority); /* tid = 5 */
numTask++;
tid = Create("SensorSrv", SensorSrvPriority); /* tid = 6 */
numTask++;
tid = Create("SensorSched", SensorSchedPriority); /* tid = 7 */
numTask++;
tid = Create("CentralControlMain", CentralControlPriority); /* tid = 8 */
numTask++;
tid = Create("PathFind", PathFindPriority); /* tid = 9 */
numTask++;
tid = Create("OneStep", OneStepPriority); /* tid = 10 */
numTask++;
tid = Create("Schedular", SchedularPriority); /* tid = 11 */
numTask++;
tid = Create("Tokenizer", TokenizerPriority); /* tid = 12 */
numTask++;
tid = Create("BlackBoardMain", BlackBoardPriority); /* tid = 13 */
#if 0
numTask++;
tid = Create("TaskA", 50); /* tid = 14 */
numTask++;
tid = Create("TaskB", 50); /* tid = 15 */
numTask++;
tid = Create("TaskC", 50); /* tid = 14 */
numTask++;
tid = Create("TaskD", 50); /* tid = 15 */
#endif /* 0 */
/*
numTask++;
tid = Create("Schedular", BlackBoardPriority);
*/
#ifdef MATRIX_TASKS
NumMatrix = (MAX_TASK_NUM) - numTask;
/*NumMatrix = 5;*/
for(i=0; i< NumMatrix;i++) {
tid = Create("Matrix", 50+(i%10));
numTask++;
}
#endif /*MATRIX_TASKS*/
console_xy( 90, 3);
cprintf( "#Tasks : %d s * Uptime: ", numTask);
console_xy( 0, 5);
cprintf(
"-----------------------------------------------------------------"
"-----------------------------------------------------------------");
/*console_xy( 0, 7);
cprintf("TrainCommand>> ");*/
Exit();
}
|
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QApplication>
#include "Kek.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
protected:
void changeEvent(QEvent *e);
private slots:
void on_actionClear_2_triggered();
void on_actionQuit_triggered();
private:
Ui::MainWindow *ui;
Kek *l;
};
#endif // MAINWINDOW_H
|
#ifndef _ASM_SCORE_PROCESSOR_H
#define _ASM_SCORE_PROCESSOR_H
#include <linux/cpumask.h>
#include <linux/threads.h>
#include <asm/segment.h>
struct task_struct;
/*
* System setup and hardware flags..
*/
extern void (*cpu_wait)(void);
extern unsigned long thread_saved_pc(struct task_struct *tsk);
extern void start_thread(struct pt_regs *regs,
unsigned long pc, unsigned long sp);
extern unsigned long get_wchan(struct task_struct *p);
/*
* Return current * instruction pointer ("program counter").
*/
#define current_text_addr() ({ __label__ _l; _l: &&_l; })
#define cpu_relax() barrier()
#define cpu_relax_lowlatency() cpu_relax()
#define release_thread(thread) do {} while (0)
/*
* User space process size: 2GB. This is hardcoded into a few places,
* so don't change it unless you know what you are doing.
*/
#define TASK_SIZE 0x7fff8000UL
/*
* This decides where the kernel will search for a free chunk of vm
* space during mmap's.
*/
#define TASK_UNMAPPED_BASE ((TASK_SIZE / 3) & ~(PAGE_SIZE))
#ifdef __KERNEL__
#define STACK_TOP TASK_SIZE
#define STACK_TOP_MAX TASK_SIZE
#endif
/*
* If you change thread_struct remember to change the #defines below too!
*/
struct thread_struct
{
unsigned long reg0, reg2, reg3;
unsigned long reg12, reg13, reg14, reg15, reg16;
unsigned long reg17, reg18, reg19, reg20, reg21;
unsigned long cp0_psr;
unsigned long cp0_ema; /* Last user fault */
unsigned long cp0_badvaddr; /* Last user fault */
unsigned long cp0_baduaddr; /* Last kernel fault accessing USEG */
unsigned long error_code;
unsigned long trap_no;
unsigned long mflags;
unsigned long reg29;
unsigned long single_step;
unsigned long ss_nextcnt;
unsigned long insn1_type;
unsigned long addr1;
unsigned long insn1;
unsigned long insn2_type;
unsigned long addr2;
unsigned long insn2;
mm_segment_t current_ds;
};
#define INIT_THREAD { \
.reg0 = 0, \
.reg2 = 0, \
.reg3 = 0, \
.reg12 = 0, \
.reg13 = 0, \
.reg14 = 0, \
.reg15 = 0, \
.reg16 = 0, \
.reg17 = 0, \
.reg18 = 0, \
.reg19 = 0, \
.reg20 = 0, \
.reg21 = 0, \
.cp0_psr = 0, \
.error_code = 0, \
.trap_no = 0, \
}
#define kstk_tos(tsk) \
((unsigned long)task_stack_page(tsk) + THREAD_SIZE - 32)
#define task_pt_regs(tsk) ((struct pt_regs *)kstk_tos(tsk) - 1)
#define KSTK_EIP(tsk) (task_pt_regs(tsk)->cp0_epc)
#define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[29])
#endif /* _ASM_SCORE_PROCESSOR_H */
|
/**
* @file
* This file contains the declaration and implementation
* of the templated Func_lt, which is used to to compare to values ( a < b).
*
* @brief Declaration and implementation of Func__lt
*
* (c) Copyright 2009- under GPL version 3
* @date Last modified: $Date: 2012-06-12 10:25:58 +0200 (Tue, 12 Jun 2012) $
* @author The RevBayes Development Core Team
* @license GPL version 3
* @version 1.0
*
* $Id: Func_vector.h 1626 2012-06-12 08:25:58Z hoehna $
*/
#ifndef Func__lt_H
#define Func__lt_H
#include "RlBoolean.h"
#include "RlTypedFunction.h"
#include <string>
namespace RevLanguage {
template <typename leftValType, typename rightValType>
class Func__lt : public TypedFunction<RlBoolean> {
public:
Func__lt();
// Basic utility functions
Func__lt* clone(void) const; //!< Clone the object
static const std::string& getClassType(void); //!< Get Rev type
static const TypeSpec& getClassTypeSpec(void); //!< Get class type spec
std::string getFunctionName(void) const; //!< Get the primary name of the function in Rev
const TypeSpec& getTypeSpec(void) const; //!< Get language type of the object
bool isInternal(void) const { return true; } //!< Is this an internal function?
// Regular functions
RevBayesCore::TypedFunction<RevBayesCore::Boolean>* createFunction(void) const; //!< Create a function object
const ArgumentRules& getArgumentRules(void) const; //!< Get argument rules
};
}
#include "ArgumentRule.h"
#include "LessThanFunction.h"
#include "RbUtil.h"
#include "RlBoolean.h"
#include "RlDeterministicNode.h"
#include "TypedDagNode.h"
#include "TypeSpec.h"
template <typename leftValType, typename rightValType>
RevLanguage::Func__lt<leftValType,rightValType>::Func__lt() : TypedFunction<RlBoolean>()
{
}
/* Clone object */
template <typename leftValType, typename rightValType>
RevLanguage::Func__lt<leftValType,rightValType>* RevLanguage::Func__lt<leftValType,rightValType>::clone( void ) const
{
return new Func__lt<leftValType,rightValType>( *this );
}
template <typename leftValType, typename rightValType>
RevBayesCore::TypedFunction<RevBayesCore::Boolean>* RevLanguage::Func__lt<leftValType,rightValType>::createFunction( void ) const
{
const RevBayesCore::TypedDagNode<typename leftValType::valueType>* leftVal = static_cast<const leftValType &>( args[0].getVariable()->getRevObject() ).getDagNode();
const RevBayesCore::TypedDagNode<typename rightValType::valueType>* rightVal = static_cast<const rightValType &>( args[1].getVariable()->getRevObject() ).getDagNode();
RevBayesCore::LessThanFunction<typename leftValType::valueType, typename rightValType::valueType> *func = new RevBayesCore::LessThanFunction<typename leftValType::valueType, typename rightValType::valueType>( leftVal, rightVal );
return func;
}
/** Get argument rules */
template <typename leftValType, typename rightValType>
const RevLanguage::ArgumentRules& RevLanguage::Func__lt<leftValType,rightValType>::getArgumentRules( void ) const
{
static ArgumentRules argumentRules = ArgumentRules();
static bool rules_set = false;
if ( !rules_set )
{
argumentRules.push_back( new ArgumentRule( "", leftValType::getClassTypeSpec() , "The left hand side variable.", ArgumentRule::BY_CONSTANT_REFERENCE, ArgumentRule::ANY ) );
argumentRules.push_back( new ArgumentRule( "", rightValType::getClassTypeSpec(), "The right hand side variable.", ArgumentRule::BY_CONSTANT_REFERENCE, ArgumentRule::ANY ) );
rules_set = true;
}
return argumentRules;
}
/** Get Rev type of object */
template <typename leftValType, typename rightValType>
const std::string& RevLanguage::Func__lt<leftValType,rightValType>::getClassType(void)
{
static std::string rev_type = "Func__lt<" + leftValType::getClassType() + "," + rightValType::getClassType() + ">";
return rev_type;
}
/** Get class type spec describing type of object */
template <typename leftValType, typename rightValType>
const RevLanguage::TypeSpec& RevLanguage::Func__lt<leftValType,rightValType>::getClassTypeSpec(void)
{
static TypeSpec rev_type_spec = TypeSpec( getClassType(), new TypeSpec( Function::getClassTypeSpec() ) );
return rev_type_spec;
}
/**
* Get the primary Rev name for this function.
*/
template <typename leftValType, typename rightValType>
std::string RevLanguage::Func__lt<leftValType, rightValType>::getFunctionName( void ) const
{
// create a name variable that is the same for all instance of this class
std::string f_name = "lt";
return f_name;
}
/** Get type spec */
template <typename leftValType, typename rightValType>
const RevLanguage::TypeSpec& RevLanguage::Func__lt<leftValType,rightValType>::getTypeSpec( void ) const
{
static TypeSpec type_spec = getClassTypeSpec();
return type_spec;
}
#endif
|
/* ns2vi.c
*
* Copyright 2006-2012 David G. Barnes, Paul Bourke, Christopher Fluke
*
* This file is part of S2PLOT.
*
* S2PLOT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* S2PLOT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with S2PLOT. If not, see <http://www.gnu.org/licenses/>.
*
* We would appreciate it if research outcomes using S2PLOT would
* provide the following acknowledgement:
*
* "Three-dimensional visualisation was conducted with the S2PLOT
* progamming library"
*
* and a reference to
*
* D.G.Barnes, C.J.Fluke, P.D.Bourke & O.T.Parry, 2006, Publications
* of the Astronomical Society of Australia, 23(2), 82-93.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "s2plot.h"
int main(int argc, char *argv[])
{
XYZ xyz = { 0.0, 0.0, 0.0 };
COLOUR col = { 1.0, 1.0, 1.0 }; /* White */
float radius = 0.2; /* Sphere radius */
XYZ light = { 0.0, 0.3, 0.8 }; /* Light position */
COLOUR lcol = { 0.0, 0.0, 1.0 }; /* A blue light */
s2opend("/?",argc, argv); /* Open the display */
s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */
s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0); /* Draw coordinate box */
ns2vsphere(xyz, radius, col); /* Draw a sphere */
ns2vi(light, lcol); /* Put the light in */
s2show(1); /* Open the s2plot window */
return 1;
}
|
#ifndef MREPORTKEY_P_H
#define MREPORTKEY_P_H
#include <QObject>
#include "mreportkey.h"
class MReportKey_P : public QObject
{
Q_OBJECT
friend class MReportKey;
public:
signals:
public slots:
private:
QString m__Name;
MReportKey::KeyType m__KT;
MReportKey::DataType m__DT;
QString m__Source;
QString m__DataSource;
explicit MReportKey_P( const QString &name, MReportKey *parent );
MReportKey * p_dptr() const;
};
#endif // MREPORTKEY_P_H
|
#include <check.h>
#include "hawser/hawser.h"
#include "hawser/service/lambda.h"
static const char * VALID_IDS[] = {
"function",
(
"1234567890123456789012345678901234567890"
"123456789012345678901234"
),
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"abcdefghijklmnopqrstuvwxyz",
"0123456789",
"_",
"-"
};
static const size_t N_VALID_IDS = sizeof(VALID_IDS) / sizeof(char *);
static const char * INVALID_IDS[] = {
"",
(
"1234567890123456789012345678901234567890"
"1234567890123456789012345"
),
"/"
};
static const size_t N_INVALID_IDS = sizeof(INVALID_IDS) / sizeof(char *);
START_TEST(test_read_valid_ids)
{
LAMBDA_ID id;
HAWSERresult result;
result = lambda_id_from_string(&id, VALID_IDS[_i]);
ck_assert_int_eq(HAWSER_OK, result);
ck_assert_str_eq(VALID_IDS[_i], id.function_name);
}
END_TEST
START_TEST(test_read_invalid_ids)
{
LAMBDA_ID id;
HAWSERresult result;
result = lambda_id_from_string(&id, INVALID_IDS[_i]);
ck_assert_int_eq(HAWSER_INVALID, result);
}
END_TEST
START_TEST(test_read_null_id)
{
ck_assert_int_eq(HAWSER_NULL, lambda_id_from_string(NULL, VALID_IDS[0]));
}
END_TEST
START_TEST(test_read_null_string)
{
LAMBDA_ID id;
ck_assert_int_eq(HAWSER_NULL, lambda_id_from_string(&id, NULL));
}
END_TEST
START_TEST(test_write_static_memory)
{
LAMBDA_ID id;
char *string = NULL;
ck_assert_int_eq(HAWSER_OK, lambda_id_from_string(&id, VALID_IDS[_i]));
ck_assert_int_eq(HAWSER_OK, lambda_string_from_id(&string, &id));
ck_assert_str_eq(VALID_IDS[_i], string);
}
END_TEST
START_TEST(test_write_supplied_memory)
{
LAMBDA_ID id;
char aString[LAMBDA_ID_BYTES];
char *szString = aString;
ck_assert_int_eq(HAWSER_OK, lambda_id_from_string(&id, VALID_IDS[_i]));
ck_assert_int_eq(HAWSER_OK, lambda_string_from_id(&szString, &id));
ck_assert_str_eq(VALID_IDS[_i], szString);
}
END_TEST
START_TEST(test_write_null_string)
{
LAMBDA_ID id;
ck_assert_int_eq(HAWSER_NULL, lambda_string_from_id(NULL, &id));
}
END_TEST
START_TEST(test_write_null_id)
{
char *string;
ck_assert_int_eq(HAWSER_NULL, lambda_string_from_id(&string, NULL));
}
END_TEST
TCase *
tcase_lambda_id(void)
{
static TCase *tc;
tc = tcase_create("id");
tcase_add_loop_test(tc, test_read_valid_ids, 0, N_VALID_IDS);
tcase_add_loop_test(tc, test_read_invalid_ids, 0, N_INVALID_IDS);
tcase_add_test(tc, test_read_null_id);
tcase_add_test(tc, test_read_null_string);
tcase_add_test(tc, test_write_null_string);
tcase_add_test(tc, test_write_null_id);
tcase_add_loop_test(tc, test_write_static_memory, 0, N_VALID_IDS);
tcase_add_loop_test(tc, test_write_supplied_memory, 0, N_VALID_IDS);
return tc;
}
|
/**
* \file
*
* Copyright (c) 2015 Atmel Corporation. All rights reserved.
*
* \asf_license_start
*
* \page License
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name of Atmel may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 4. This software may only be redistributed and used in connection with an
* Atmel microcontroller product.
*
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* \asf_license_stop
*
*/
/*
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
*/
#ifndef _SAMV71_SDRAMC_INSTANCE_
#define _SAMV71_SDRAMC_INSTANCE_
/* ========== Register definition for SDRAMC peripheral ========== */
#if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
#define REG_SDRAMC_MR (0x40084000U) /**< \brief (SDRAMC) SDRAMC Mode Register */
#define REG_SDRAMC_TR (0x40084004U) /**< \brief (SDRAMC) SDRAMC Refresh Timer Register */
#define REG_SDRAMC_CR (0x40084008U) /**< \brief (SDRAMC) SDRAMC Configuration Register */
#define REG_SDRAMC_LPR (0x40084010U) /**< \brief (SDRAMC) SDRAMC Low Power Register */
#define REG_SDRAMC_IER (0x40084014U) /**< \brief (SDRAMC) SDRAMC Interrupt Enable Register */
#define REG_SDRAMC_IDR (0x40084018U) /**< \brief (SDRAMC) SDRAMC Interrupt Disable Register */
#define REG_SDRAMC_IMR (0x4008401CU) /**< \brief (SDRAMC) SDRAMC Interrupt Mask Register */
#define REG_SDRAMC_ISR (0x40084020U) /**< \brief (SDRAMC) SDRAMC Interrupt Status Register */
#define REG_SDRAMC_MDR (0x40084024U) /**< \brief (SDRAMC) SDRAMC Memory Device Register */
#define REG_SDRAMC_CFR1 (0x40084028U) /**< \brief (SDRAMC) SDRAMC Configuration Register 1 */
#define REG_SDRAMC_OCMS (0x4008402CU) /**< \brief (SDRAMC) SDRAMC OCMS Register */
#define REG_SDRAMC_OCMS_KEY1 (0x40084030U) /**< \brief (SDRAMC) SDRAMC OCMS KEY1 Register */
#define REG_SDRAMC_OCMS_KEY2 (0x40084034U) /**< \brief (SDRAMC) SDRAMC OCMS KEY2 Register */
#else
#define REG_SDRAMC_MR (*(__IO uint32_t*)0x40084000U) /**< \brief (SDRAMC) SDRAMC Mode Register */
#define REG_SDRAMC_TR (*(__IO uint32_t*)0x40084004U) /**< \brief (SDRAMC) SDRAMC Refresh Timer Register */
#define REG_SDRAMC_CR (*(__IO uint32_t*)0x40084008U) /**< \brief (SDRAMC) SDRAMC Configuration Register */
#define REG_SDRAMC_LPR (*(__IO uint32_t*)0x40084010U) /**< \brief (SDRAMC) SDRAMC Low Power Register */
#define REG_SDRAMC_IER (*(__O uint32_t*)0x40084014U) /**< \brief (SDRAMC) SDRAMC Interrupt Enable Register */
#define REG_SDRAMC_IDR (*(__O uint32_t*)0x40084018U) /**< \brief (SDRAMC) SDRAMC Interrupt Disable Register */
#define REG_SDRAMC_IMR (*(__I uint32_t*)0x4008401CU) /**< \brief (SDRAMC) SDRAMC Interrupt Mask Register */
#define REG_SDRAMC_ISR (*(__I uint32_t*)0x40084020U) /**< \brief (SDRAMC) SDRAMC Interrupt Status Register */
#define REG_SDRAMC_MDR (*(__IO uint32_t*)0x40084024U) /**< \brief (SDRAMC) SDRAMC Memory Device Register */
#define REG_SDRAMC_CFR1 (*(__IO uint32_t*)0x40084028U) /**< \brief (SDRAMC) SDRAMC Configuration Register 1 */
#define REG_SDRAMC_OCMS (*(__IO uint32_t*)0x4008402CU) /**< \brief (SDRAMC) SDRAMC OCMS Register */
#define REG_SDRAMC_OCMS_KEY1 (*(__O uint32_t*)0x40084030U) /**< \brief (SDRAMC) SDRAMC OCMS KEY1 Register */
#define REG_SDRAMC_OCMS_KEY2 (*(__O uint32_t*)0x40084034U) /**< \brief (SDRAMC) SDRAMC OCMS KEY2 Register */
#endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
#endif /* _SAMV71_SDRAMC_INSTANCE_ */
|
/***********************************************************************************
CryptoMiniSat -- Copyright (c) 2009 Mate Soos
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************************************/
#ifndef PARTHANDLER_H
#define PARTHANDLER_H
#include "Solver.h"
#include "PartFinder.h"
#include "Vec.h"
#include "SolverTypes.h"
#include <map>
#include <vector>
using std::map;
using std::vector;
using std::pair;
/**
@brief Disconnected components are treated here
Uses PartFinder to find disconnected components and treats them using
subsolvers. The solutions (if SAT) are aggregated, and at then end, the
solution is extended with the sub-solutions, and the removed clauses are
added back to the problem.
*/
class PartHandler
{
public:
PartHandler(Solver& solver);
const bool handle();
const vec<lbool>& getSavedState();
void newVar();
void addSavedState();
void readdRemovedClauses();
friend class ClauseAllocator;
private:
struct sort_pred {
bool operator()(const std::pair<int,int> &left, const std::pair<int,int> &right) {
return left.second < right.second;
}
};
void configureNewSolver(Solver& newSolver) const;
void moveVariablesBetweenSolvers(Solver& newSolver, vector<Var>& vars, const uint32_t part, const PartFinder& partFinder);
//For moving clauses
void moveClauses(vec<XorClause*>& cs, Solver& newSolver, const uint32_t part, PartFinder& partFinder);
void moveClauses(vec<Clause*>& cs, Solver& newSolver, const uint32_t part, PartFinder& partFinder);
void moveLearntClauses(vec<Clause*>& cs, Solver& newSolver, const uint32_t part, PartFinder& partFinder);
//Checking moved clauses
const bool checkClauseMovement(const Solver& thisSolver, const uint32_t part, const PartFinder& partFinder) const;
template<class T>
const bool checkOnlyThisPart(const vec<T*>& cs, const uint32_t part, const PartFinder& partFinder) const;
Solver& solver; ///<The base solver
/**
@brief The SAT solutions that have been found by the parts
When a part finishes with SAT, its soluton is saved here. In th end
the solutions are aggregaed using addSavedState()
*/
vec<lbool> savedState;
vec<Var> decisionVarRemoved; ///<List of variables whose decision-ness has been removed (set to FALSE)
/**
@brief Clauses that have been moved to parts
We aggregate here clauses that have been moved to parts. There are
later re-added back to the solver such that the problem is complete
again.
*/
vec<Clause*> clausesRemoved;
/**
@brief xor clauses that have been moved to parts
We aggregate here xor clauses that have been moved to parts. There are
later re-added back to the solver such that the problem is complete
again.
*/
vec<XorClause*> xorClausesRemoved;
};
/**
@brief Returns the saved state of a variable
*/
inline const vec<lbool>& PartHandler::getSavedState()
{
return savedState;
}
/**
@brief Creates a space in savedState
So that the solution can eventually be saved here (if parts are used). By
default the value is l_Undef, i.e. no solution has been saved there.
*/
inline void PartHandler::newVar()
{
savedState.push(l_Undef);
}
#endif //PARTHANDLER_H
|
#ifndef TILE_H
#define TILE_H
#include <string>
struct SDL_Surface;
struct SDL_Texture;
struct SDL_Renderer;
class tile
{
int type;
std::string path;
SDL_Surface *srf;
SDL_Texture *tex;
public:
tile();
~tile();
void set_tile_path(const std::string &path);
void generate_texture(SDL_Renderer *rend);
void destroy_texture();
void draw(SDL_Renderer *rend, int x, int y, int grid_pitch);
};
#endif
|
/*
* QuarkPlayer, a Phonon media player
* Copyright (C) 2008-2011 Tanguy Krotoff <tkrotoff@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLAYLISTREADERTEST_H
#define PLAYLISTREADERTEST_H
#include <PlaylistParser/PlaylistParser.h>
#include <QtTest/QtTest>
#include <QtCore/QList>
class MediaInfo;
/**
* Test for PlaylistReader.
*
* French radio list:
* http://code.google.com/p/radioshell/wiki/ListeRadios
* http://flux.radio.free.fr/
* http://www.infomaniak.ch/societe/streaming.php
*
* @see PlaylistParser
* @author Tanguy Krotoff
*/
class PlaylistReaderTest : public QObject {
Q_OBJECT
private slots:
/** Called before the first testfunction is executed. */
void initTestCase();
/** Called after the last testfunction was executed. */
void cleanupTestCase();
/** Called before each testfunction is executed. */
void init();
/** Called after every testfunction. */
void cleanup();
void loadPlaylist_data();
void loadPlaylist();
void filesFound(const QList<MediaInfo> & files);
void finished(PlaylistParser::Error error, int timeElapsed);
private:
void loadPlaylistM3U();
void loadPlaylistWPL();
void loadPlaylistPLS();
void loadPlaylistASX();
void loadPlaylistXSPF();
void loadPlaylistCUE();
PlaylistReader * _reader;
};
#endif //PLAYLISTREADERTEST_H
|
/*
* Copyright (C) 2016 Stuart Howarth <showarth@marxoft.co.uk>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef YOUTUBECOMMENTSPAGE_H
#define YOUTUBECOMMENTSPAGE_H
#include "page.h"
#include "youtubecommentmodel.h"
class ImageCache;
class CommentDelegate;
class QListView;
class QVBoxLayout;
class YouTubeCommentsPage : public Page
{
Q_OBJECT
public:
explicit YouTubeCommentsPage(QWidget *parent = 0);
~YouTubeCommentsPage();
virtual Status status() const;
virtual QString statusText() const;
public Q_SLOTS:
virtual void cancel();
virtual void reload();
void list(const QString &resourcePath, const QStringList &part,
const QVariantMap &filters = QVariantMap(), const QVariantMap ¶ms = QVariantMap());
private Q_SLOTS:
void showUser(const QModelIndex &index);
void onImageReady();
void onModelStatusChanged(QYouTube::ResourcesRequest::Status status);
private:
void setStatus(Status s);
void setStatusText(const QString &text);
YouTubeCommentModel *m_model;
ImageCache *m_cache;
CommentDelegate *m_delegate;
QListView *m_view;
QVBoxLayout *m_layout;
Status m_status;
QString m_statusText;
};
#endif // YOUTUBECOMMENTSPAGE_H
|
/*
# Copyright (C) 2005-2011 MaNGOS <http://www.getmangos.com/>
*
# Copyright (C) 2008-2011 Trinity <http://www.trinitycore.org/>
*
# Copyright (C) 2010-2011 DarkmoonCore <http://www.darkmooncore.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _HOSTILEREFMANAGER
#define _HOSTILEREFMANAGER
#include "Common.h"
#include "RefManager.h"
class Unit;
class ThreatManager;
class HostileReference;
struct SpellEntry;
//=================================================
class HostileRefManager : public RefManager<Unit, ThreatManager>
{
private:
Unit *iOwner;
public:
explicit HostileRefManager(Unit *pOwner) { iOwner = pOwner; }
~HostileRefManager();
Unit* getOwner() { return iOwner; }
// send threat to all my hateres for the pVictim
// The pVictim is hated than by them as well
// use for buffs and healing threat functionality
void threatAssist(Unit *pVictim, float fThreat, SpellEntry const *threatSpell = 0, bool pSingleTarget = false);
void addTempThreat(float fThreat, bool apply);
void addThreatPercent(int32 iPercent);
// The references are not needed anymore
// tell the source to remove them from the list and free the mem
void deleteReferences();
// Remove specific faction references
void deleteReferencesForFaction(uint32 faction);
void UpdateVisibility();
HostileReference* getFirst() { return ((HostileReference*) RefManager<Unit, ThreatManager>::getFirst()); }
void updateThreatTables();
void setOnlineOfflineState(bool bIsOnline);
// set state for one reference, defined by Unit
void setOnlineOfflineState(Unit *pCreature, bool bIsOnline);
// delete one reference, defined by Unit
void deleteReference(Unit *pCreature);
};
//=================================================
#endif |
/*
Mosh: the mobile shell
Copyright 2012 Keith Winstein
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
In addition, as a special exception, the copyright holders give
permission to link the code of portions of this program with the
OpenSSL library under certain conditions as described in each
individual source file, and distribute linked combinations including
the two.
You must obey the GNU General Public License in all respects for all
of the code used other than OpenSSL. If you modify file(s) with this
exception, you may extend this exception to your version of the
file(s), but you are not obligated to do so. If you do not wish to do
so, delete this exception statement from your version. If you delete
this exception statement from all source files in the program, then
also delete it here.
*/
#ifndef SELECT_HPP
#define SELECT_HPP
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <sys/select.h>
#include <assert.h>
#include "fatal_assert.h"
#include "timestamp.h"
/* Convenience wrapper for pselect(2).
Any signals blocked by calling sigprocmask() outside this code will still be
received during Select::select(). So don't do that. */
class Select {
public:
static Select &get_instance( void ) {
/* COFU may or may not be thread-safe, depending on compiler */
static Select instance;
return instance;
}
private:
Select()
: max_fd( -1 )
/* These initializations are not used; they are just
here to appease -Weffc++. */
, all_fds( dummy_fd_set )
, read_fds( dummy_fd_set )
, error_fds( dummy_fd_set )
, empty_sigset( dummy_sigset )
{
FD_ZERO( &all_fds );
FD_ZERO( &read_fds );
FD_ZERO( &error_fds );
clear_got_signal();
fatal_assert( 0 == sigemptyset( &empty_sigset ) );
}
void clear_got_signal( void )
{
memset( got_signal, 0, sizeof( got_signal ) );
}
/* not implemented */
Select( const Select & );
Select &operator=( const Select & );
public:
void add_fd( int fd )
{
if ( fd > max_fd ) {
max_fd = fd;
}
FD_SET( fd, &all_fds );
}
void clear_fds( void )
{
FD_ZERO( &all_fds );
}
static void add_signal( int signum )
{
fatal_assert( signum >= 0 );
fatal_assert( signum <= MAX_SIGNAL_NUMBER );
/* Block the signal so we don't get it outside of pselect(). */
sigset_t to_block;
fatal_assert( 0 == sigemptyset( &to_block ) );
fatal_assert( 0 == sigaddset( &to_block, signum ) );
fatal_assert( 0 == sigprocmask( SIG_BLOCK, &to_block, NULL ) );
/* Register a handler, which will only be called when pselect()
is interrupted by a (possibly queued) signal. */
struct sigaction sa;
sa.sa_flags = 0;
sa.sa_handler = &handle_signal;
fatal_assert( 0 == sigfillset( &sa.sa_mask ) );
fatal_assert( 0 == sigaction( signum, &sa, NULL ) );
}
/* timeout unit: milliseconds; negative timeout means wait forever */
int select( int timeout )
{
memcpy( &read_fds, &all_fds, sizeof( read_fds ) );
memcpy( &error_fds, &all_fds, sizeof( error_fds ) );
clear_got_signal();
#ifdef HAVE_PSELECT
struct timespec ts;
struct timespec *tsp = NULL;
if ( timeout >= 0 ) {
ts.tv_sec = timeout / 1000;
ts.tv_nsec = 1000000 * (long( timeout ) % 1000);
tsp = &ts;
}
int ret = ::pselect( max_fd + 1, &read_fds, NULL, &error_fds, tsp, &empty_sigset );
#else
struct timeval tv;
struct timeval *tvp = NULL;
sigset_t old_sigset;
if ( timeout >= 0 ) {
tv.tv_sec = timeout / 1000;
tv.tv_usec = 1000 * (long( timeout ) % 1000);
tvp = &tv;
}
int ret = sigprocmask( SIG_SETMASK, &empty_sigset, &old_sigset );
if ( ret != -1 ) {
ret = ::select( max_fd + 1, &read_fds, NULL, &error_fds, tvp );
sigprocmask( SIG_SETMASK, &old_sigset, NULL );
}
#endif
if ( ( ret == -1 ) && ( errno == EINTR ) ) {
/* The user should process events as usual. */
FD_ZERO( &read_fds );
FD_ZERO( &error_fds );
ret = 0;
}
freeze_timestamp();
return ret;
}
bool read( int fd )
#if FD_ISSET_IS_CONST
const
#endif
{
assert( FD_ISSET( fd, &all_fds ) );
return FD_ISSET( fd, &read_fds );
}
bool error( int fd )
#if FD_ISSET_IS_CONST
const
#endif
{
assert( FD_ISSET( fd, &all_fds ) );
return FD_ISSET( fd, &error_fds );
}
/* This method consumes a signal notification. */
bool signal( int signum )
{
fatal_assert( signum >= 0 );
fatal_assert( signum <= MAX_SIGNAL_NUMBER );
/* XXX This requires a guard against concurrent signals. */
bool rv = got_signal[ signum ];
got_signal[ signum ] = 0;
return rv;
}
/* This method does not consume signal notifications. */
bool any_signal( void ) const
{
bool rv = false;
for (int i = 0; i < MAX_SIGNAL_NUMBER; i++) {
rv |= got_signal[ i ];
}
return rv;
}
private:
static const int MAX_SIGNAL_NUMBER = 64;
static void handle_signal( int signum );
int max_fd;
/* We assume writes to these ints are atomic, though we also try to mask out
concurrent signal handlers. */
int got_signal[ MAX_SIGNAL_NUMBER + 1 ];
fd_set all_fds, read_fds, error_fds;
sigset_t empty_sigset;
static fd_set dummy_fd_set;
static sigset_t dummy_sigset;
};
#endif
|
/*
* RDB - A NoSQL local database written in C++
* Author: https://github.com/MilkywayPwns
* Date: 13 - 10 - 2016
*/
namespace RDB::Database
{
class DataEntry
{
protected:
std::string _raw;
public:
DataEntry()
{
_raw = "";
}
DataEntry(std::string str)
{
_raw = str;
}
DataEntry(const char *str)
{
_raw = std::string(str);
}
#define DATAENTRY_TYPE(__in_type, __convert_name, __convert_func) \
DataEntry(__in_type __in_arg) \
{ \
_raw = std::to_string(__in_type(__in_arg)); \
} \
DataEntry &operator=(__in_type __in_arg) \
{ \
_raw = std::to_string(__in_type(__in_arg)); \
return *this; \
} \
__in_type __convert_name() \
{ \
return __convert_func(_raw); \
} \
bool operator==(__in_type __in_arg) \
{ \
return (__convert_func(_raw) == __in_arg); \
} \
bool operator!=(__in_type __in_arg) \
{ \
return (__convert_func(_raw) == __in_arg); \
}
// Manual operators
bool operator==(DataEntry in)
{
return (in._raw == _raw);
}
bool operator!=(DataEntry in)
{
return (in._raw != _raw);
}
bool operator==(std::string in)
{
return (in == _raw);
}
bool operator!=(std::string in)
{
return (in != _raw);
}
DataEntry &operator=(std::string str)
{
_raw = str;
return *this;
}
DataEntry &operator=(const char *str)
{
_raw = std::string(str);
return *this;
}
DataEntry &operator=(DataEntry in)
{
_raw = in._raw;
return *this;
}
std::string ToString()
{
return _raw;
}
// Save/Load
void Save(Buffer::DatabaseBuffer *buffer)
{
// Write value of this Entry
buffer->WriteStr(_raw);
}
void Load(Buffer::DatabaseBuffer *buffer)
{
// Read value for this entry
_raw = buffer->ReadStr();
}
// Clears data in this entry
void Clear()
{
_raw.clear();
}
size_t Size()
{
return _raw.size();
}
// Generate operators and To* functions
DATAENTRY_TYPE(int32_t, ToInt32, std::stoi)
DATAENTRY_TYPE(uint32_t, ToUint32, std::stoul)
DATAENTRY_TYPE(int64_t, ToInt64, std::stoll)
DATAENTRY_TYPE(uint64_t, ToUint64, std::stoull)
DATAENTRY_TYPE(float, ToFloat, std::stof)
DATAENTRY_TYPE(double, ToDouble, std::stod)
DATAENTRY_TYPE(long double, ToLongDouble, std::stold)
};
}
|
#pragma once
#include <cstdint>
#include <cstddef>
#include <vector>
#include <ncgcpp/ntrcard.h>
#include "platform.h"
using std::uint8_t;
using std::uint16_t;
using std::uint32_t;
// Utility -- s must be a power of two and have no side effects.
#define PAGE_ROUND_UP(x, s) ( ((x) + (s)-1) & (~((s)-1)) )
#define PAGE_ROUND_DOWN(x, s) ( (x) & (~((s)-1)) )
#define BIT(n) (1 << (n))
namespace flashcart_core {
class Flashcart {
public:
Flashcart(const char* name, const size_t max_length);
Flashcart(const char* name, const char* short_name, const size_t max_length);
inline bool initialize(ncgc::NTRCard *card) {
m_card = card;
return initialize();
}
virtual void shutdown() = 0;
virtual bool readFlash(uint32_t address, uint32_t length, uint8_t *buffer) = 0;
virtual bool writeFlash(uint32_t address, uint32_t length, const uint8_t *buffer) = 0;
virtual bool injectNtrBoot(uint8_t *blowfish_key, uint8_t *firm, uint32_t firm_size) = 0;
const char *getName() { return m_name; }
const char *getShortName() { return m_short_name; }
virtual const char *getAuthor() { return "unknown"; }
virtual const char *getDescription() { return ""; }
virtual size_t getMaxLength() { return m_max_length; }
protected:
const char* m_name;
const char* m_short_name;
const size_t m_max_length;
ncgc::NTRCard *m_card;
virtual bool initialize() = 0;
};
extern std::vector<Flashcart*> *flashcart_list;
}
|
#include <stdio.h>
#include <cs50.h>
int main() {
// asks for an input and gets it as long
printf("Number: ");
long num = GetLongLong();
// gets the length of the credit card number
int len = 0;
long num2 = num;
while (num2 >= 10) {
num2 = num2 / 10;
len++;
}
// variables for the algorithm
int i, mod, sums = 0;
long num3 = num;
long num4 = num;
// deletes the last digit of num3
num3 /= 10;
// Multiply every other digit by 2, starting with the number’s second-to-last digit, and then add those products' digits together.
for(i = 0; i < len; i++) {
// it gets the mod 10 of the number and multiplies it with 2
mod = (num3 % 10) * 2;
// if result is great equal to 10, it adds the mod % 10 + 1 to 'sums'
if(mod >= 10) {
sums += (mod % 10) + 1;
// if result is less than 10, it adds the mod to 'sums'
} else {
sums += mod;
}
// deletes the last 2 digits of the number
num3 /= 100;
}
int j;
// Add the sum to the sum of the digits that weren’t multiplied by 2.
for(j = 0; j < len; j++) {
// it gets the mod 10 of the number and adds it to 'sums'
sums += num4 % 10;
// deletes the last 2 digits of the number
num4 /= 100;
}
// Checks if the total’s last digit is 0
if(sums % 10 == 0) {
// if it's valid, checks for AMEX
if(len == 14) {
if(num / 10000000000000 == 34 || num / 10000000000000 == 37) {
printf("AMEX\n");
}
}
// if it's valid, checks for MASTERCARD
if(len == 15) {
if(num / 100000000000000 == 51 || num / 100000000000000 == 52 || num / 100000000000000 == 53 || num / 100000000000000 == 54 || num / 100000000000000 == 55) {
printf("MASTERCARD\n");
}
// also checks for VISA len 16
if(num / 1000000000000000 == 4) {
printf("VISA\n");
}
}
// if it's valid, checks for VISA len 13
if(len == 12) {
if(num / 1000000000000 == 4) {
printf("VISA\n");
}
}
// if card is invalid, prints INVALID to the screen
} else {
printf("INVALID\n");
}
return 0;
}
|
/*
* Copyright (C) 2013 Nivis LLC.
* Email: opensource@nivis.com
* Website: http://www.nivis.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* Redistribution and use in source and binary forms must retain this
* copyright notice.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef C003_READDYNAMICVARIABLESANDLOOPCURRENT_H_
#define C003_READDYNAMICVARIABLESANDLOOPCURRENT_H_
#include "../../Model/UniversalCommands.h"
#include "../../../util/Binarization.h"
#ifdef __cplusplus
extern "C" {
#endif
uint8_t Compose_C003_ReadDynamicVariablesAndLoopCurrent_Req(C003_ReadDynamicVariablesAndLoopCurrent_Req* request,
ComposerContext* context, BinaryStream* toStream);
uint8_t Parse_C003_ReadDynamicVariablesAndLoopCurrent_Req(C003_ReadDynamicVariablesAndLoopCurrent_Req* request,
ParserContext* context, BinaryStream* fromStream);
uint8_t Compose_C003_ReadDynamicVariablesAndLoopCurrent_Resp(C003_ReadDynamicVariablesAndLoopCurrent_Resp* response,
ComposerContext* context, BinaryStream* toStream);
uint8_t Parse_C003_ReadDynamicVariablesAndLoopCurrent_Resp(C003_ReadDynamicVariablesAndLoopCurrent_Resp* response,
ParserContext* context, BinaryStream* fromStream);
#ifdef __cplusplus
}
#endif
#endif /*C003_ReadDynamicVariablesAndLoopCurrent_H_*/
|
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Quake III Arena source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
#include "g_local.h"
/*
=======================================================================
SESSION DATA
Session data is the only data that stays persistant across level loads
and tournament restarts.
=======================================================================
*/
/*
================
G_WriteClientSessionData
Called on game shutdown
================
*/
void G_WriteClientSessionData( gclient_t *client ) {
const char *s;
const char *var;
s = va("%i %i %i %i %i %i %i",
client->sess.sessionTeam,
client->sess.spectatorTime,
client->sess.spectatorState,
client->sess.spectatorClient,
client->sess.wins,
client->sess.losses,
client->sess.teamLeader
);
var = va( "session%i", (int)(client - level.clients) );
trap_Cvar_Set( var, s );
}
/*
================
G_ReadSessionData
Called on a reconnect
================
*/
void G_ReadSessionData( gclient_t *client ) {
char s[MAX_STRING_CHARS];
const char *var;
int teamLeader;
int spectatorState;
int sessionTeam;
var = va( "session%i", (int)(client - level.clients) );
trap_Cvar_VariableStringBuffer( var, s, sizeof(s) );
sscanf( s, "%i %i %i %i %i %i %i",
&sessionTeam,
&client->sess.spectatorTime,
&spectatorState,
&client->sess.spectatorClient,
&client->sess.wins,
&client->sess.losses,
&teamLeader
);
client->sess.sessionTeam = (team_t)sessionTeam;
client->sess.spectatorState = (spectatorState_t)spectatorState;
client->sess.teamLeader = (qboolean)teamLeader;
}
/*
================
G_InitSessionData
Called on a first-time connect
================
*/
void G_InitSessionData( gclient_t *client, char *userinfo ) {
clientSession_t *sess;
const char *value;
sess = &client->sess;
// initial team determination
if ( g_gametype.integer >= GT_TEAM ) {
if ( g_teamAutoJoin.integer ) {
sess->sessionTeam = PickTeam( -1 );
BroadcastTeamChange( client, -1 );
} else {
// always spawn as spectator in team games
sess->sessionTeam = TEAM_SPECTATOR;
}
} else {
value = Info_ValueForKey( userinfo, "team" );
if ( value[0] == 's' ) {
// a willing spectator, not a waiting-in-line
sess->sessionTeam = TEAM_SPECTATOR;
} else {
switch ( g_gametype.integer ) {
default:
case GT_FFA:
case GT_SINGLE_PLAYER:
if ( g_maxGameClients.integer > 0 &&
level.numNonSpectatorClients >= g_maxGameClients.integer ) {
sess->sessionTeam = TEAM_SPECTATOR;
} else {
sess->sessionTeam = TEAM_FREE;
}
break;
}
}
}
sess->spectatorState = SPECTATOR_FREE;
sess->spectatorTime = level.time;
G_WriteClientSessionData( client );
}
/*
==================
G_InitWorldSession
==================
*/
void G_InitWorldSession( void ) {
char s[MAX_STRING_CHARS];
int gt;
trap_Cvar_VariableStringBuffer( "session", s, sizeof(s) );
gt = atoi( s );
// if the gametype changed since the last session, don't use any
// client sessions
if ( g_gametype.integer != gt ) {
level.newSession = qtrue;
G_Printf( "Gametype changed, clearing session data.\n" );
}
}
/*
==================
G_WriteSessionData
==================
*/
void G_WriteSessionData( void ) {
int i;
trap_Cvar_Set( "session", va("%i", g_gametype.integer) );
for ( i = 0 ; i < level.maxclients ; i++ ) {
if ( level.clients[i].pers.connected == CON_CONNECTED ) {
G_WriteClientSessionData( &level.clients[i] );
}
}
}
|
#pragma once
#include <string>
namespace util {
std::string Trim(std::string str, const char * delimiters = " \t\r\n");
} // namespace util
|
#include "display_rgb565_spi.h"
class Display_ILI9486_spi : public Display_RGB565_spi8
{
public:
Display_ILI9486_spi( int nRotate, int nGpioCS=-1, int nGpioDC=201, int nGpioReset=1, int nGpioBackLight=65 ) :
Display_RGB565_spi8(
320,
480,
DISP_CTRL_MIRROR_V | DISP_CTRL_BGR,
nRotate,
nGpioCS,
nGpioDC,
nGpioReset,
nGpioBackLight,
50 * 1000000,
SPI_MODE_0
)
{
}
};
//
class Display_ILI9486_spi_RGB24 : public Display_RGB565_spi8
{
public:
Display_ILI9486_spi_RGB24( int nRotate, int nGpioCS=-1, int nGpioDC=201, int nGpioReset=1, int nGpioBackLight=65 ) :
Display_RGB565_spi8(
320,
480,
DISP_CTRL_MIRROR_V | DISP_CTRL_BGR,
nRotate,
nGpioCS,
nGpioDC,
nGpioReset,
nGpioBackLight,
50 * 1000000,
SPI_MODE_0
)
{
}
virtual int Init()
{
if( 0 != Display_RGB565_spi8::Init() )
{
return -1;
}
WriteReg( MIPI_DCS_SET_PIXEL_FORMAT,
0x66 ); // RGB666
//************* Start Initial Sequence **********//
/*
WriteReg( 0xF1, 0x36, 0x04, 0x00, 0x3C, 0x0F, 0x8F );
WriteReg( 0xF2, 0x18, 0xA3, 0x12, 0x02, 0xb2, 0x12, 0xFF, 0x10, 0x00 );
WriteReg( 0xF8, 0x21, 0x04 );
WriteReg( 0xF9, 0x00, 0x08 );
WriteReg( 0xC0, 0x0f, 0x0f );
WriteReg( 0xC1, 0x42 );
WriteReg( 0xC2, 0x22 );
WriteReg( 0xC5, 0x01, 0x29, 0x80 );
WriteReg( 0xB6, 0x00, 0x02, 0x3b );
WriteReg( 0xB1, 0xB0, 0x11 );
WriteReg( 0xB4, 0x02);
WriteReg( 0xE0, 0x0F, 0x18, 0x15, 0x09, 0x0B, 0x04, 0x49, 0x64, 0x3D, 0x08, 0x15, 0x06, 0x12, 0x07, 0x00 );
WriteReg( 0xE1, 0x0F, 0x38, 0x35, 0x0a, 0x0c, 0x03, 0x4A, 0x42, 0x36, 0x04, 0x0F, 0x03, 0x1F, 0x1B, 0x00 );
//*/
m_iFrameBuf.resize( m_tDDRAM.width * m_tDDRAM.height * 3 );
return 0;
}
virtual int WriteImageBGRA( int x, int y, const uint8_t* image, int stride, int cx, int cy )
{
if( _CalcTransArea( x, y, image, stride, 4, cx, cy ) )
{
ImageConvert::BGRA8888toRGB888( image, stride, cx, cy, m_iFrameBuf.data(), cx * 3 );
return TransferRGB( x, y, cx, cy, m_iFrameBuf.data(), cx * cy * 3 );
}
return -1;
}
virtual int WriteImageGRAY( int x, int y, const uint8_t* image, int stride, int cx, int cy )
{
if( _CalcTransArea( x, y, image, stride, 1, cx, cy ) )
{
ImageConvert::GRAY8toRGB888( image, stride, cx, cy, m_iFrameBuf.data(), cx * 3 );
return TransferRGB( x, y, cx, cy, m_iFrameBuf.data(), cx * cy * 3 );
}
return -1;
}
};
// https://www.waveshare.com/wiki/3.5inch_RPi_LCD_(A)
// https://www.waveshare.com/3.5inch-rpi-lcd-a.htm
class Display_WaveShare35_spi : public Display_RGB565_spi8
{
public:
Display_WaveShare35_spi( int nRotate, int nGpioCS=67, int nGpioDC=201, int nGpioReset=1, int nGpioBackLight=-1 ) :
Display_RGB565_spi8(
320,
480,
DISP_CTRL_MIRROR_V | DISP_CTRL_BGR,
nRotate,
nGpioCS,
nGpioDC,
nGpioReset,
nGpioBackLight,
25 * 1000000,
SPI_MODE_0
)
{
}
virtual int Init()
{
if( 0 != Display_RGB565_spi8::Init() )
{
return -1;
}
WriteReg( 0xB0, 0x00 );
WriteReg( 0xc2, 0x44 );
WriteReg( 0xc5, 0x0, 0x0, 0x0, 0x0 );
WriteReg( 0xe0, 0xf, 0x1f, 0x1c, 0xc, 0xf, 0x8, 0x48, 0x98, 0x37, 0xa, 0x13, 0x4, 0x11, 0x0d, 0x0 );
WriteReg( 0xe1, 0xf, 0x32, 0x2e, 0xb, 0xd, 0x5, 0x47, 0x75, 0x37, 0x6, 0x10, 0x3, 0x24, 0x20, 0x0 );
WriteReg( 0xe2, 0xf, 0x32, 0x2e, 0xb, 0xd, 0x5, 0x47, 0x75, 0x37, 0x6, 0x10, 0x3, 0x24, 0x20, 0x0 );
return 0;
}
virtual void WriteSpi( uint8_t _cmd, int data_size, const uint8_t * _data )
{
uint8_t cmd[] = { 0x00, _cmd };
// ChipSelect
m_iCS << 0;
// Command
m_iDC << 0;
m_iSPI.write( cmd, sizeof(cmd) );
if( 0 < data_size )
{
std::vector<uint8_t> data;
int i;
for( i = 0; i < data_size; i++ )
{
data.push_back( 0x00 );
data.push_back( _data[i] );
}
m_iDC << 1;
m_iSPI.write( data.data(), data.size() );
data_size = data.size();
}
// ChipSelect
m_iCS << 1;
// printf( "SpiWrite16:0x%02x, %d\n", _cmd, data_size );
}
};
|
/*
* This file is part of the Yices SMT Solver.
* Copyright (C) 2017 SRI International.
*
* Yices is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Yices is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Yices. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* SUPPORT FOR CONVERTING BIT-VECTOR POLYNOMIALS
* TO ELEMENTARY EXPRESSIONS.
*/
/*
* In the bv_vartable, some bitvector variables represent
* polynomial expressions. These variables are constructed
* with tags BVTAG_POLY64, BVTAG_POLY, or BVTAG_PPROD.
*
* Before bit-blasting, we must convert these expressions
* to equivalent terms that can be processed by the bit-blaster,
* that is, terms built using the following operators:
* binary add: (bvadd x y)
* binary sub: (bvsub x y)
* binary mul: (bvmul x y)
* negation: (bvneg x)
*
* This module implements this translation process and keeps
* track of the conversion.
*/
#ifndef __BVPOLY_COMPILER_H
#define __BVPOLY_COMPILER_H
#include <stdint.h>
#include "solvers/bv/bv_vartable.h"
#include "solvers/bv/bvpoly_dag.h"
#include "solvers/bv/merge_table.h"
#include "terms/bvpoly_buffers.h"
#include "utils/int_bv_sets.h"
#include "utils/int_hash_map.h"
#include "utils/int_vectors.h"
/*
* Queue of variable
* - each element in this queue is a variable index i
* - the variables are sorted in topological order
* (i.e., if i is (BVADD j k) and j is (BVADD ...) then
* j occurs before i in the queue).
*
* This is stored as in data[0 ... top-1]
* - size = full size of array data
*/
typedef struct bvc_queue_s {
thvar_t *data;
uint32_t top;
uint32_t size;
} bvc_queue_t;
#define DEF_BVC_QUEUE_SIZE 100
#define MAX_BVC_QUEUE_SIZE (UINT32_MAX/sizeof(thvar_t))
/*
* Compiler structure:
* - pointer to the relevant variable and merge tables
* - a compilation map: maps polynomial ids to elementary expressions
* - elemexp = all elementary expressions constructed
*
* For compilation
* - dag for compilation/sharing of subexpressions
* - queue = queue of polynomials to compile
* - in_queue = set of all elements in the queue
*/
typedef struct bvc_s {
bv_vartable_t *vtbl;
mtbl_t *mtbl;
int_hmap_t cmap;
bvc_queue_t elemexp;
// data structures used during compilation
bvc_dag_t dag;
bvc_queue_t queue;
int_bvset_t in_queue;
// auxiliary buffers
ivector_t buffer;
bvpoly_buffer_t pbuffer;
pp_buffer_t pp_buffer;
} bvc_t;
/*
* OPERATIONS
*/
/*
* Initialization:
* - vtbl = the attached variable table
* - mtbl = the attached merge table
* - elemexp is initially empty
* - cmap has default initial size (cf. int_hash_map)
*/
extern void init_bv_compiler(bvc_t *c, bv_vartable_t *vtbl, mtbl_t *mtbl);
/*
* Free all memory
*/
extern void delete_bv_compiler(bvc_t *c);
/*
* Empty the content
*/
extern void reset_bv_compiler(bvc_t *c);
/*
* Remove all occurrences of variables with index >= nv
*/
extern void bv_compiler_remove_vars(bvc_t *c, uint32_t nv);
/*
* Get the variable mapped to x in cmap
* - return null_thvar (-1) if nothing is mapped to x
* - x must be a valid variable in c->vtbl
*/
extern thvar_t bvvar_compiles_to(bvc_t *c, thvar_t x);
/*
* Add variable x to the compilation queue
* - x must be a valid variable in c->vtbl
* - x's definition must be a polynomial (i.e., x must have
* tag BVTAG_POLY, BVTAG_POLY64, or BVTAG_PPROD).
*/
extern void bv_compiler_push_var(bvc_t *c, thvar_t x);
/*
* Process the compilation queue. All variables pushed into the queue
* are compiled to elementary expression, then the queue is emptied.
* - after this call, use 'bvvar_compiles_to' to find out what a
* variable is compiled to.
*/
extern void bv_compiler_process_queue(bvc_t *c);
#endif /* __BVPOLY_COMPILER_H */
|
/**
* @file group_internal.h
*
* purple
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#ifndef _QQ_GROUP_HASH_H_
#define _QQ_GROUP_HASH_H_
#include <glib.h>
#include "group.h"
#define QQ_ROOM_KEY_INTERNAL_ID "id"
#define QQ_ROOM_KEY_QUN_ID "qun_id"
#define QQ_ROOM_KEY_NAME "name"
#define QQ_ROOM_KEY_ISSHOW "is_show_chat"
PurpleChat *qq_room_find_or_new(PurpleConnection *gc, guint32 id, guint32 qun_id);
void qq_room_remove(PurpleConnection *gc, guint32 id);
void qq_room_update_chat_info(PurpleChat *chat, qq_room_data *rmd);
qq_buddy_data *qq_room_buddy_find(qq_room_data *rmd, guint32 uid);
void qq_room_buddy_remove(qq_room_data *rmd, guint32 uid);
qq_buddy_data *qq_room_buddy_find_or_new(PurpleConnection *gc, qq_room_data *rmd, guint32 member_uid);
void qq_room_data_initial(PurpleConnection *gc);
void qq_room_data_free_all(PurpleConnection *gc);
qq_room_data *qq_room_data_find(PurpleConnection *gc, guint32 room_id);
guint32 qq_room_get_next(PurpleConnection *gc, guint32 room_id);
guint32 qq_room_get_next_conv(PurpleConnection *gc, guint32 room_id);
qq_room_data *room_data_new(guint32 id, guint32 qun_id, const gchar *title);
#endif
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.