text
stringlengths 4
6.14k
|
|---|
#ifndef GRAPHICS_H
#define GRAPHICS_H
#include "Arduino.h"
#define FONT_MAIN_ELEMENT_SIZE 16
struct Bitmap
{
public:
Bitmap(const byte* bitmapArray);
Bitmap(byte* bitmapArray);
~Bitmap() { delete [] value; }
uint8_t arrayLength() { return arrayLength(width, height); }
static uint8_t arrayLength(uint8_t width, uint8_t height) { return width * ((height / 8) + 1); } // TODO potencional bug when height % 8 == 0
byte* value;
uint8_t width;
uint8_t height;
};
class Font
{
public:
virtual Bitmap* getBitmapFromCharacter(char character) = 0;
byte* createEmptyBitmapArray(uint8_t width, uint8_t height);
};
class MainFont : public Font
{
public:
Bitmap* getBitmapFromCharacter(char character);
};
class SpeedFont : public Font
{
public:
Bitmap* getBitmapFromCharacter(char character);
};
class UnitsFont : public Font
{
public:
Bitmap* getBitmapFromCharacter(char character);
};
class DataFont : public Font
{
public:
Bitmap* getBitmapFromCharacter(char character);
};
class Icon
{
public:
virtual Bitmap* getBitmap() = 0;
//virtual Bitmap getBitmap(uint8_t offset) = 0;
};
class BluetoothIcon : public Icon
{
public:
Bitmap* getBitmap();
//Bitmap getBitmap(uint8_t offset) { return offsetBitmap(getBitmap(), offset); }
};
class GpsIcon : public Icon
{
public:
Bitmap* getBitmap();
//Bitmap getBitmap(uint8_t offset) { return offsetBitmap(getBitmap(), offset); }
};
#endif
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "user_message.h"
int MAX_MESS_SIZE;
message_data * request;
message_data * reply;
struct message_data{
int id;
size_t mess_len;
char mess_data[0];
};
message_data * create_rcv_message(void){
return create_message(NULL, MAX_MESS_SIZE, -1);
}
message_data * create_message(char * data, size_t size_data, int id){
message_data * res = malloc(sizeof(struct message_data) + size_data);
memset(res,'\0',sizeof(struct message_data) + size_data);
res->mess_len = size_data;
res->id = id;
if(data)
memcpy(res->mess_data, data, size_data);
return res;
}
int get_message_id(message_data * mess){
return mess->id;
}
void set_message_id(message_data * mess, int id){
mess->id = id;
}
char * get_message_data(message_data * mess){
return mess->mess_data;
}
size_t get_message_size(message_data * mess){
return mess->mess_len;
}
size_t get_total_mess_size(message_data * mess){
return mess->mess_len + sizeof(struct message_data);
}
void delete_message(message_data * mess){
if(mess)
free(mess);
}
void del_default_messages(void){
free(request);
free(reply);
}
void init_default_messages(){
size_t size_req = strlen(REQUEST)+1;
size_t size_repl = strlen(REPLY)+1;
MAX_MESS_SIZE = size_req > size_repl ? size_req : size_repl;
request = create_message(NULL, MAX_MESS_SIZE, -1);
reply = create_message(NULL, MAX_MESS_SIZE, -1);
memset(reply->mess_data, '\0', MAX_MESS_SIZE);
memset(request->mess_data, '\0', MAX_MESS_SIZE);
memcpy(reply->mess_data, REPLY, size_repl);
memcpy(request->mess_data, REQUEST, size_req);
}
|
/*
* SmartPID Controller hardware diagnostic tool
*
* Copyright (C) 2016 Arzaman
*/
#ifndef HWTEST_H_
#define HWTEST_H_
/* Initialize the diagnostic task
* This function is called at the start of firmware execution.
* Parameters: none
* Returns: none
*/
void hwTestSetup();
/* Process the diagnostic task
* This function is called repeatedly (with no specified periodicity) during
* firmware execution; its task is display a graphical user interface and accept
* user input to perform diagnostic tests on hardware components.
* Parameters: none
* Returns: none
*/
void hwTestLoop(void);
#endif
|
#ifndef NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif
#include "yaml-cpp/dll.h"
#include "yaml-cpp/node/type.h"
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/detail/node_ref.h"
#include <set>
#include <string>
#include <boost/utility.hpp>
namespace YAML
{
namespace detail
{
class node: private boost::noncopyable
{
public:
node(): m_pRef(new node_ref) {}
bool is(const node& rhs) const { return m_pRef == rhs.m_pRef; }
const node_ref *ref() const { return m_pRef.get(); }
bool is_defined() const { return m_pRef->is_defined(); }
NodeType::value type() const { return m_pRef->type(); }
const std::string& scalar() const { return m_pRef->scalar(); }
const std::string& tag() const { return m_pRef->tag(); }
void mark_defined() {
if(is_defined())
return;
m_pRef->mark_defined();
for(nodes::iterator it=m_dependencies.begin();it!=m_dependencies.end();++it)
(*it)->mark_defined();
m_dependencies.clear();
}
void add_dependency(node& rhs) {
if(is_defined())
rhs.mark_defined();
else
m_dependencies.insert(&rhs);
}
void set_ref(const node& rhs) {
if(rhs.is_defined())
mark_defined();
m_pRef = rhs.m_pRef;
}
void set_data(const node& rhs) {
if(rhs.is_defined())
mark_defined();
m_pRef->set_data(*rhs.m_pRef);
}
void set_type(NodeType::value type) {
if(type != NodeType::Undefined)
mark_defined();
m_pRef->set_type(type);
}
void set_null() {
mark_defined();
m_pRef->set_null();
}
void set_scalar(const std::string& scalar) {
mark_defined();
m_pRef->set_scalar(scalar);
}
void set_tag(const std::string& tag) {
mark_defined();
m_pRef->set_tag(tag);
}
// size/iterator
std::size_t size() const { return m_pRef->size(); }
const_node_iterator begin() const { return static_cast<const node_ref&>(*m_pRef).begin(); }
node_iterator begin() { return m_pRef->begin(); }
const_node_iterator end() const { return static_cast<const node_ref&>(*m_pRef).end(); }
node_iterator end() { return m_pRef->end(); }
// sequence
void push_back(node& node, shared_memory_holder pMemory) {
m_pRef->push_back(node, pMemory);
node.add_dependency(*this);
}
void insert(node& key, node& value, shared_memory_holder pMemory) {
m_pRef->insert(key, value, pMemory);
key.add_dependency(*this);
value.add_dependency(*this);
}
// indexing
template<typename Key> node& get(const Key& key, shared_memory_holder pMemory) const { return static_cast<const node_ref&>(*m_pRef).get(key, pMemory); }
template<typename Key> node& get(const Key& key, shared_memory_holder pMemory) {
node& value = m_pRef->get(key, pMemory);
value.add_dependency(*this);
return value;
}
template<typename Key> bool remove(const Key& key, shared_memory_holder pMemory) { return m_pRef->remove(key, pMemory); }
node& get(node& key, shared_memory_holder pMemory) const { return static_cast<const node_ref&>(*m_pRef).get(key, pMemory); }
node& get(node& key, shared_memory_holder pMemory) {
node& value = m_pRef->get(key, pMemory);
key.add_dependency(*this);
value.add_dependency(*this);
return value;
}
bool remove(node& key, shared_memory_holder pMemory) { return m_pRef->remove(key, pMemory); }
// map
template<typename Key, typename Value>
void force_insert(const Key& key, const Value& value, shared_memory_holder pMemory){ m_pRef->force_insert(key, value, pMemory); }
private:
shared_node_ref m_pRef;
typedef std::set<node *> nodes;
nodes m_dependencies;
};
}
}
#endif // NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
#ifndef SAVE_TRAINER_H
#define SAVE_TRAINER_H
#include <inttypes.h>
#include "save_common.h"
union save_unpacked_t;
enum save_exit_code_t save_trainer_money_get(union save_unpacked_t* save,
uint32_t* money);
enum save_exit_code_t save_trainer_gender_get(
union save_unpacked_t* save, enum save_trainer_gender_t* gender);
enum save_exit_code_t save_trainer_id_get(union save_unpacked_t* save,
struct save_trainer_id_t* id);
enum save_exit_code_t save_time_played_get(union save_unpacked_t* save,
struct save_time_played_t* time);
enum save_exit_code_t save_trainer_name_get(union save_unpacked_t* save,
char name[SAVE_TRAINER_NAME_SIZE]);
#endif
|
/* zxatasp.h: ZXATASP interface routines
Copyright (c) 2003-2004 Garry Lancaster,
2004 Philip Kendall
$Id: zxatasp.h 4972 2013-05-19 16:46:43Z zubzero $
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.
Author contact information:
E-mail: Philip Kendall <philip-fuse@shadowmagic.org.uk>
*/
#ifndef FUSE_ZXATASP_H
#define FUSE_ZXATASP_H
#include <libspectrum.h>
int zxatasp_init( void );
int zxatasp_end( void );
int zxatasp_insert( const char *filename, libspectrum_ide_unit unit );
int zxatasp_commit( libspectrum_ide_unit unit );
int zxatasp_eject( libspectrum_ide_unit unit );
int zxatasp_unittest( void );
#endif /* #ifndef FUSE_ZXATASP_H */
|
/*
* Copyright (C) 2012 Josh Bialkowski (jbialk@mit.edu)
*
* This file is part of mpblocks.
*
* mpblocks 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.
*
* mpblocks 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 mpblocks. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file mpblocks/kd_tree/euclidean/KNearest.h
*
* @date Nov 20, 2012
* @author Josh Bialkowski (jbialk@mit.edu)
* @brief
*/
#ifndef MPBLOCKS_KD_TREE_EUCLIDEAN_KNEAREST_H_
#define MPBLOCKS_KD_TREE_EUCLIDEAN_KNEAREST_H_
#include <set>
namespace mpblocks {
namespace kd_tree {
namespace euclidean {
template <class Traits,
template<class> class Allocator = std::allocator >
class KNearest :
public NearestSearchIface<Traits>
{
public:
typedef typename Traits::Format_t Format_t;
typedef typename Traits::Node Node_t;
typedef Distance<Traits> Distance_t;
typedef HyperRect<Traits> HyperRect_t;
typedef Key<Traits> Key_t;
typedef typename Key_t::Compare KeyCompare_t;
typedef Allocator<Key_t> Allocator_t;
typedef Eigen::Matrix<Format_t,Traits::NDim,1> Point_t;
typedef std::set<Key_t,KeyCompare_t,Allocator_t> PQueue_t;
protected:
unsigned int m_k;
PQueue_t m_queue;
Distance_t m_dist2Fn;
public:
KNearest( unsigned int k=1 );
virtual ~KNearest(){};
// clear the queue
void reset();
// clear the queue and change k
void reset( int k );
// return the result
const PQueue_t& result();
/// calculates Euclidean distance from @p q to @p p, and if its less
/// than the current best replaces the current best node with @p n
virtual void evaluate(const Point_t& q, const Point_t& p, Node_t* n);
/// evaluate the Euclidean distance from @p q to it's closest point in
/// @p r and if that distance is less than the current best distance,
/// return true
virtual bool shouldRecurse(const Point_t& q, const HyperRect_t& r );
};
} // namespace euclidean
} // namespace kd_tree
} // namespace mpblocks
#endif // NEARESTNEIGHBOR_H_
|
#include <stdio.h>
#include <stdlib.h>
#define addr 0xffffffff80000000+0xb8100
int main(int argc, char* argv[], char* envp[])
{
/*
for(int i=0; i<2000; i++)
write(1, "3\n\0", 2);
*/
int pid = 0;
pid=fork();
if(pid>0){
while(1) {
write(1, "THIS IS PARENT 2\n\0", 20);
}
}
else{
while(1) {
write(1, "THIS IS CHILD 2\n\0", 20);
}
}
while(1) {
//write(1, "Demon \0", 6);
}
//printf("%d. Demon\n", ++cnt);
return 0;
}
|
#include<stdio.h>
#include<string.h>
main()
{
char s1[20]="hello world";
s1[5]='\0';
printf("%d\n",strlen(s1));
}
|
/* dataset.h */
/*
Copyright (C) 2015 Scott A. Czepiel
This file is part of mlelr.
mlelr 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.
mlelr 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 mlelr. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DATASET_H__
#define DATASET_H__
extern const double SYSMIS;
/***
dataset
A basic abstraction for storing and accessing data and metadata.
***/
typedef struct {
char *handle; /* a short label for this dataset */
int n; /* number of observations */
int size; /* amount of space allocated for values */
int nvars; /* number of variables */
char **varnames; /* array of variable names */
double *values; /* array of contiguous space to store all data */
double **obs; /* matrix of pointers to access each obs[i][j] */
int weight; /* index of the weight variable, or -1 if none */
} dataset;
struct dataspace {
int n; /* number of datasets */
int size; /* space allocated to store pointers to datasets */
dataset *datasets; /* array of datasets */
};
/***
dataspace
This global variable will hold an array of pointers to all currently
available datasets.
***/
extern struct dataspace dataspace;
/* forward declarations for publically available functions defined in dataset.c */
extern void init_dataspace (void);
extern int import_dataset (char *handle, char *filename, char delim);
extern dataset *add_dataset (char *handle, int nvars, char **varnames, int is_public);
extern void add_observation (dataset *ds, double *obs);
extern void print_dataset (dataset *ds, int n, int header);
extern dataset *find_dataset (char *handle);
extern int find_varname (dataset *ds, char *varname);
extern int set_weight_variable (dataset *ds, int var);
extern int find_observation(dataset *ds, double *obs, int n_vars);
extern void sort_dataset(dataset *ds, int n_cols);
#endif
|
#ifndef _COMMON_DEFINES_H
#define _COMMON_DEFINES_H
#include "bOS/bOS.h"
#include "bOS/bOSStringUtils.h"
#include "bOS/bOSStringBuffer.h"
using namespace bOS::CoreString;
#include "bOS/Tracer.h"
#endif
|
/*
* Copyright (C) 2010-2011 Daniel Richter <danielrichter2007@web.de>
*
* 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef TRAIT_CONTROLLERAWARE_H_
#define TRAIT_CONTROLLERAWARE_H_
template <typename T>
class Trait_ControllerAware {
protected:
T* controller;
public:
Trait_ControllerAware() : controller(NULL) {}
void setController(T& controller) {
this->controller = &controller;
}
};
#endif /* TRAIT_CONTROLLERAWARE_H_ */
|
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cafInternalPdmUiCommandSystemInterface.h"
#include <vector>
namespace caf
{
class PdmFieldHandle;
class CmdUiCommandSystemImpl : public PdmUiCommandSystemInterface
{
public:
CmdUiCommandSystemImpl();
void fieldChangedCommand( const std::vector<PdmFieldHandle*>& fieldsToUpdate, const QVariant& newUiValue ) override;
void setCurrentContextMenuTargetWidget( QWidget* targetWidget ) override;
void populateMenuWithDefaultCommands( const QString& uiConfigName, QMenu* menu ) override;
bool isUndoEnabled();
void enableUndoFeature( bool enable );
bool disableUndoForFieldChange();
private:
bool m_undoFeatureEnabled;
bool m_disableUndoForFieldChange;
};
} // end namespace caf
|
/*
* pins.h
*
* Created on: Feb 8, 2015
* Author: shaun
*/
#ifndef PINS_H_
#define PINS_H_
#define SET_DIRECTION_INNER(port, pin, out) if (out) {\
DDR##port |= _BV(DD##port##pin); \
} else { \
DDR##port &= ~_BV(DD##port##pin); \
}
#define SET_DIRECTION(port, pin, out) SET_DIRECTION_INNER(port, pin, out)
#define DIR_OUT 1
#define DIR_IN 0
#define WRITE_PIN_INNER(port, pin, out) do { if (out) {\
PORT##port |= _BV(PORT##port##pin); \
} else { \
PORT##port &= ~_BV(PORT##port##pin); \
} } while (0)
#define WRITE_PIN(port, pin, out) WRITE_PIN_INNER(port, pin, out)
#define TOGGLE_PIN_INNER(port, pin, out) do { if (out) {\
PIN##port |= _BV(PIN##port##pin); \
} else { \
PIN##port &= ~_BV(PIN##port##pin); \
} } while (0)
#define TOGGLE_PIN(port, pin, out) TOGGLE_PIN_INNER(port, pin, out)
#define PIN_ON 1
#define PIN_OFF 0
// Pin definitions
#define LED_PORT D
#define LED_PIN 7
// PWM A = PD3 = OC2B // PWM control for motor outputs 1 and 2 is on digital pin 3
#define PWM_A_PORT D
#define PWM_A_PIN 3
#define PWM_A OCR2B
// PWM B = PB3 = OC2A // PWM control for motor outputs 3 and 4 is on digital pin 11
#define PWM_B_PORT B
#define PWM_B_PIN 3
#define PWM_B OCR2A
// direction control for motor outputs 1 and 2 is on Arduino digital pin 12
#define DIR_A_PORT B
#define DIR_A_PIN 4
// direction control for motor outputs 3 and 4 is on Arduino digital pin 13
#define DIR_B_PORT B
#define DIR_B_PIN 5
// Pin connected to our active-low push switch.
#define SWITCH_PORT B
#define SWITCH_PIN 0
// Analog pins assignments.
#define X_APIN 0
#define Y_APIN 1
#define GYRO_APIN 2
#define TILT_POT_APIN 3
#define GYRO_POT_APIN 4
#define X_POT_APIN 5
#endif /* PINS_H_ */
|
/*
File: leasurfaceboxprivate.h
Project: leafhopper
Author: Douwe Vos
Date: Nov 17, 2014
e-mail: dmvos2000(at)yahoo.com
Copyright (C) 2014 Douwe Vos.
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 LEASURFACEBOXPRIVATE_H_
#define LEASURFACEBOXPRIVATE_H_
#include "leasurfacebox.h"
#include "drag/leaigrip.h"
LeaIGrip *lea_surf_box_calculate_locator(LeaSurfaceBox *surface_box, int x, int y, int drag_magnet, LeaIGrip *top_grip);
#endif /* LEASURFACEBOXPRIVATE_H_ */
|
class CInput
{
public:
char _pad0[0xB4];
bool m_fCameraInterceptingMouse;
bool m_fCameraInThirdPerson;
bool m_fCameraMovingWithMouse;
Vector m_vecCameraOffset;
bool m_fCameraDistanceMove;
int m_nCameraOldX;
int m_nCameraOldY;
int m_nCameraX;
int m_nCameraY;
bool m_CameraIsOrthographic;
};
|
/*
* ESPRESSIF MIT License
*
* Copyright (c) 2020 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
*
* Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case,
* it is 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.
*
*/
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <esp_hap_pair_common.h>
void hap_tlv_data_init(hap_tlv_data_t *tlv_data, uint8_t *buf, int buf_size)
{
tlv_data->bufptr = buf;
tlv_data->bufsize = buf_size;
tlv_data->curlen = 0;
}
int get_tlv_length(uint8_t *buf, int buflen, uint8_t type)
{
if (!buf )
return -1;
int curlen = 0;
int val_len = 0;
bool found = false;
while (buflen > 0) {
if (buf[curlen] == type) {
uint8_t len = buf[curlen + 1];
if ((buflen - len) < 2)
return -1;
val_len += len;
if (len < 255)
return val_len;
else
found = true;
} else if (found)
return val_len;
/* buf[curlen +1] will give the Length */
buflen -= (2 + buf[curlen + 1]);
curlen += (2 + buf[curlen + 1]);
}
return -1;
}
int get_value_from_tlv(uint8_t *buf, int buflen, uint8_t type, void *val, int val_size)
{
if (!buf || !val)
return -1;
int curlen = 0;
int val_len = 0;
bool found = false;
while (buflen > 0) {
if (buf[curlen] == type) {
uint8_t len = buf[curlen + 1];
if ((val_size < len) || ((buflen - len) < 2))
return -1;
memcpy(val + val_len, &buf[curlen + 2], len);
val_len += len;
val_size -= len;
if (len < 255)
return val_len;
else
found = true;
} else if (found)
return val_len;
/* buf[curlen +1] will give the Length */
buflen -= (2 + buf[curlen + 1]);
curlen += (2 + buf[curlen + 1]);
}
return -1;
}
int add_tlv(hap_tlv_data_t *tlv_data, uint8_t type, int len, void *val)
{
if(!tlv_data->bufptr || ((len + 2) > (tlv_data->bufsize - tlv_data->curlen)))
return -1;
uint8_t *buf_ptr = (uint8_t *)val;
int orig_len = tlv_data->curlen;
do {
tlv_data->bufptr[tlv_data->curlen++] = type;
int tmp_len;
if (len > 255)
tmp_len = 255;
else
tmp_len = len;
tlv_data->bufptr[tlv_data->curlen++] = tmp_len;
memcpy(&tlv_data->bufptr[tlv_data->curlen], buf_ptr, tmp_len);
tlv_data->curlen += tmp_len;
buf_ptr += tmp_len;
len -= tmp_len;
} while (len);
return tlv_data->curlen - orig_len;
}
void hap_prepare_error_tlv(uint8_t state, uint8_t error, void *buf, int bufsize, int *outlen)
{
hap_tlv_data_t tlv_data;
tlv_data.bufptr = buf;
tlv_data.bufsize = bufsize;
tlv_data.curlen = 0;
/* Not doing any error handling because the size required for "state" and "error" will
* be too small to cause any error, and we anyways dont have any specific action to
* do in case if error in add_tlv()
*/
add_tlv(&tlv_data, kTLVType_State, sizeof(state), &state);
add_tlv(&tlv_data, kTLVType_Error, sizeof(error), &error);
*outlen = tlv_data.curlen;
}
|
#pragma once
class Lattice;
// Override this class to create different lattice behaviours
class Generator
{
public:
Generator()
{}
virtual ~Generator()
{}
virtual void Update(Lattice &xLattice);
virtual UCHAR GenerateValue(Lattice &xLattice, int i, int j, int k)
{
return 0;
}
private:
};
|
/*
* Copyright (c) 2010-2011 Tanguy Krotoff.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef LOGMODEL_H
#define LOGMODEL_H
#include <Logger/LoggerExport.h>
#include <QtCore/QAbstractListModel>
#include <QtCore/QList>
class LogMessage;
/**
* Model for LogWindow.
*
* This is used to show the logs.
*
* @author Tanguy Krotoff
*/
class LOGGER_API LogModel : public QAbstractListModel {
Q_OBJECT
public:
static const int COLUMN_TIME;
static const int COLUMN_TYPE;
static const int COLUMN_FILE;
static const int COLUMN_LINE;
static const int COLUMN_MODULE;
static const int COLUMN_FUNCTION;
static const int COLUMN_MESSAGE;
static const int COLUMN_COUNT;
/** LogModel state. */
enum State {
PlayingState,
PausedState
};
LogModel(QObject * parent);
~LogModel();
/**
* Returns the current state.
*
* @return current state
*/
State state() const;
/**
* Resumes the log.
*
* Does nothing if not in pause state.
*/
void resume();
/**
* Pauses the log.
*
* Does nothing if not in play state.
*/
void pause();
/**
* Resets the model.
*/
void clear();
/**
* Gets the log message given its index.
*
* @return LogMessage object, can be empty if the index is invalid
*/
LogMessage logMessage(const QModelIndex & index) const;
/**
* Saves log messages into a file.
*
* XML format.
*
* @param fileName file where to save the XML log messages
* @return true if success; false otherwise
*/
bool save(const QString & fileName) const;
/**
* Opens a log file.
*
* XML format.
*
* @param fileName XML log file to open
* @return true if success; false otherwise
*/
bool open(const QString & fileName);
/**
* @name Inherited from QAbstractListModel
* @{
*/
int columnCount(const QModelIndex & parent = QModelIndex()) const;
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
int rowCount(const QModelIndex & parent = QModelIndex()) const;
/** @} */
public slots:
/**
* Appends a new log message.
*
* QAbstractListModel is not thread-safe + must be created inside GUI thread
* so we must use a queued signal otherwise we end up with the following error message:
* <pre>Warning QTreeView::rowsInserted internal representation of the model
* has been corrupted, resetting</pre
*
* @see http://lists.trolltech.com/pipermail/qt-interest/2009-June/009215.html
* @see http://www.qtcentre.org/threads/28150-Subclassi%C4%B1ng-QAbstractItemModel-for-a-thread-safe-tree-model
* @see http://forum.qtfr.org/viewtopic.php?pid=74128
*
* @param msg add a new log message to the model
*
* @see Logger
*/
void append(const LogMessage & msg);
private slots:
#ifdef HACK_ABOUT_TO_QUIT
/**
* QCoreApplication::aboutToQuit().
*
* HACK
* Catches aboutToQuit() otherwise it crashes inside endInsertRows() when
* the application quits. This is a Qt bug workaround.
* Tested under Qt 4.6.2 Ubuntu 9.10.
*/
void aboutToQuit();
#endif //HACK_ABOUT_TO_QUIT
private:
/** Keeps all the log messages. */
QList<LogMessage> _log;
#ifdef HACK_ABOUT_TO_QUIT
/** See aboutToQuit() slot. */
bool _aboutToQuit;
#endif //HACK_ABOUT_TO_QUIT
/** LogModel state. */
State _state;
};
#endif //LOGMODEL_H
|
/******************************************************************************
Utility to create a pcap file of a 6in4 stream present in an origin pcap file
Copyright (C) 2013 Samuel Jero <sj323707@ohio.edu>
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/>.
Author: Samuel Jero <sj323707@ohio.edu>
Date: 03/2013
******************************************************************************/
#include "strip6in4.h"
#define STRIP6IN4_VERSION 0.1
#define COPYRIGHT_YEAR 2013
pcap_t* in; /*libpcap input file discriptor*/
pcap_dumper_t *out; /*libpcap output file discriptor*/
void handle_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *bytes);
void version();
void usage();
int debug = 0;
/*Parse commandline options and open files*/
int main(int argc, char *argv[])
{
char ebuf[200];
char *erbuffer=ebuf;
char *sfile=NULL;
char *dfile=NULL;
pcap_t* tmp;
/*parse commandline options*/
if(argc > 9){
usage();
}
/*loop through commandline options*/
for(int i=1; i < argc; i++){
if(argv[i][0]!='-' || (argv[i][0]=='-' && strlen(argv[i])==1)){
if(sfile==NULL || argv[i][0]=='-'){
/*assign first non-dash (or only dash) argument to the input file*/
sfile=argv[i];
}else{
if(dfile==NULL){
dfile=argv[i]; /*assign second non-dash argument to the output file*/
}else{
usage();
}
}
}else{
if(argv[i][1]=='V' && strlen(argv[i])==2){ /* -V */
version();
}else if(argv[i][1]=='h' && strlen(argv[i])==2){ /*-h*/
usage();
}else if(argv[i][1]=='v' && strlen(argv[i])==2){ /*-v*/
debug++;
}else{
usage();
}
}
}
if(sfile==NULL || dfile==NULL){
usage();
}
/*all options validated*/
if(debug){
dbgprintf(1,"Input file: %s\n", sfile);
dbgprintf(1,"Output file: %s\n", dfile);
}
/*attempt to open input file*/
in=pcap_open_offline(sfile, erbuffer);
if(in==NULL){
dbgprintf(0,"Error opening input file\n");
exit(1);
}
/*attempt to open output file*/
tmp=pcap_open_dead(DLT_RAW,65535);
out=pcap_dump_open(tmp,dfile);
if(out==NULL){
dbgprintf(0,"Error opening output file\n");
exit(1);
}
/*process packets*/
u_char *user=(u_char*)out;
pcap_loop(in, -1, handle_packet, user);
/*close files*/
pcap_close(in);
pcap_close(tmp);
pcap_dump_close(out);
return 0;
}
/*call back function for pcap_loop--do basic packet handling*/
void handle_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *bytes)
{
int link_type;
struct const_packet old;
/*Determine the link type for this packet*/
link_type=pcap_datalink(in);
/*Setup packet struct*/
old.h=h;
old.length=h->caplen;
old.data=bytes;
old.private=user;
/*do all the fancy conversions*/
if(!do_encap(link_type, &old)){
return;
}
return;
}
/*de-encapsulate packet*/
int decap_packet(const struct const_packet* old)
{
struct pcap_pkthdr h;
if(!old || !old->data || !old->h){
dbgprintf(0,"Error: decap_packet() given bad data!\n");
return 0;
}
h.ts=old->h->ts;
h.caplen=old->length;
h.len=old->length;
pcap_dump((u_char*)old->private, &h, old->data);
return 0;
}
void version()
{
dbgprintf(0, "strip6in4 version %.1f\n",STRIP6IN4_VERSION);
dbgprintf(0, "Copyright (C) %i Samuel Jero <sj323707@ohio.edu>\n",COPYRIGHT_YEAR);
dbgprintf(0, "This program comes with ABSOLUTELY NO WARRANTY.\n");
dbgprintf(0, "This is free software, and you are welcome to\n");
dbgprintf(0, "redistribute it under certain conditions.\n");
exit(0);
}
/*Usage information for program*/
void usage()
{
dbgprintf(0,"Usage: strip6in4 [-v] [-h] [-V] input_file output_file\n");
dbgprintf(0, " -v verbose. May be repeated for additional verbosity.\n");
dbgprintf(0, " -V Version information\n");
dbgprintf(0, " -h Help\n");
exit(0);
}
/*Debug Printf*/
void dbgprintf(int level, const char *fmt, ...)
{
va_list args;
if(debug>=level){
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
}
}
|
#include<sys/types.h>
#include<unistd.h>
#include<fcntl.h>
#include<linux/rtc.h>
#include<linux/ioctl.h>
#include<stdio.h>
#include<stdlib.h>
void main()
{
int fd;
char data[256];
int retval;
fd=open("/dev/fgj",O_RDWR);
if(fd==-1)
{
perror("error open\n");
exit(-1);
}
printf("open /dev/fgj successfully\n");
retval=write(fd,"fgj",3);
if(retval==-1)
{
perror("write error\n");
exit(-1);
}
retval=read(fd,data,3);
if(retval==-1)
{
perror("read error\n");
exit(-1);
}
data[retval]=0;
printf("read successfully:%s\n",data);
close(fd);
}
|
/**
******************************************************************************
* @file RNG/RNG_MultiRNG/Src/stm32f4xx_it.c
* @author MCD Application Team
* @version V1.1.0
* @date 17-February-2017
* @brief Main Interrupt Service Routines.
* This file provides template for all exceptions handler and
* peripherals interrupt service routine.
******************************************************************************
* @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.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "stm32f4xx_it.h"
/** @addtogroup STM32F4xx_HAL_Examples
* @{
*/
/** @addtogroup RNG_MultiRNG
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/******************************************************************************/
/* Cortex-M4 Processor Exceptions Handlers */
/******************************************************************************/
/**
* @brief This function handles NMI exception.
* @param None
* @retval None
*/
void NMI_Handler(void)
{
}
/**
* @brief This function handles Hard Fault exception.
* @param None
* @retval None
*/
void HardFault_Handler(void)
{
/* Go to infinite loop when Hard Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Memory Manage exception.
* @param None
* @retval None
*/
void MemManage_Handler(void)
{
/* Go to infinite loop when Memory Manage exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Bus Fault exception.
* @param None
* @retval None
*/
void BusFault_Handler(void)
{
/* Go to infinite loop when Bus Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Usage Fault exception.
* @param None
* @retval None
*/
void UsageFault_Handler(void)
{
/* Go to infinite loop when Usage Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles SVCall exception.
* @param None
* @retval None
*/
void SVC_Handler(void)
{
}
/**
* @brief This function handles Debug Monitor exception.
* @param None
* @retval None
*/
void DebugMon_Handler(void)
{
}
/**
* @brief This function handles PendSVC exception.
* @param None
* @retval None
*/
void PendSV_Handler(void)
{
}
/**
* @brief This function handles SysTick Handler.
* @param None
* @retval None
*/
void SysTick_Handler(void)
{
HAL_IncTick();
}
/******************************************************************************/
/* STM32F4xx Peripherals Interrupt Handlers */
/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
/* available peripheral interrupt handler's name please refer to the startup */
/* file (startup_stm32f4xx.s). */
/******************************************************************************/
/**
* @brief This function handles external lines 15 to 10 interrupt request.
* @param None
* @retval None
*/
void EXTI15_10_IRQHandler(void)
{
HAL_GPIO_EXTI_IRQHandler(TAMPER_BUTTON_PIN);
}
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
#ifndef CANA_INTEGRATE_H
#define CANA_INTEGRATE_H
#include <cmath>
#include <vector>
#include <cstddef>
// limit of bins for simpson integration by precision
#define MAX_SIMPSON_BINS 50000
// limit of bin size for simpson method (relative diff. b/a - 1.)
#define MIN_SIMPSON_SIZE 1e-15
namespace cana
{
// weight point for gauss legendre integration
struct weight_point
{
double x, w;
weight_point() : x(0.), w(0.) {}
weight_point(double xi, double wi) : x(xi), w(wi) {}
};
struct legendre_nodes { int order; std::vector<weight_point> weights; };
// legendre polynomial calculation to get the weight table
legendre_nodes calc_legendre_nodes(int n, double prec = 1e-10);
// gauss-legendre quadrature
template<typename F, typename... Args>
double gauss_quad(const legendre_nodes &ln, F &&f, double a, double b, Args&&... args)
{
// invalid legendre nodes
if(ln.order < 2) return 0.;
// convert integration range to [-1, 1]
double A = (b - a)/2., B = (b + a)/2.;
// different first point handling for even or odd case
const auto &fp = ln.weights.front();
double s = (ln.order&1)?
(fp.w*f(B, args...)) :
(fp.w*f(B + A*fp.x, args...) + fp.w*f(B - A*fp.x, args...));
for(size_t i = 1; i < ln.weights.size(); ++i)
{
const auto &p = ln.weights.at(i);
s += p.w*(f(B + A*p.x, args...) + f(B - A*p.x, args...));
}
return A*s;
}
template<class T, typename F, typename... Args>
double gauss_quad(const legendre_nodes &ln, F (T::*f), T *t, double a, double b, Args&&... args)
{
// wrapper of a member function
auto fn = [t, f] (double val, Args&&... args2)
{
return (t->*f)(val, args2...);
};
return gauss_quad(ln, fn, a, b, args...);
}
// simpson integration
template<typename F, typename... Args>
double simpson(F &&f, double a, double b, int steps, Args&&... args)
{
double s = (b - a)/(double)steps;
double res = f(a, args...) + f(b, args...) + 4.*f(a + s/2., args...);
for(int i = 1; i < steps; ++i)
{
res += 4.*f(a + s*i + s/2., args...) + 2.*f(a + s*i, args...);
}
return s/6.*res;
}
// simpson integration for class member function
template<class T, typename F, typename... Args>
double simpson(F (T::*f), T *t, double a, double b, int steps, Args&&... args)
{
double s = (b - a)/(double)steps;
double res = (t->*f)(a, args...)
+ (t->*f)(b, args...)
+ 4.*(t->*f)(a + s/2., args...);
for(int i = 1; i < steps; ++i)
{
res += 4.*(t->*f)(a + s*i + s/2., args...)
+ 2.*(t->*f)(a + s*i, args...);
}
return s/6.*res;
}
// helper function for simpson integration, keep refine binning if the
// precision is not reached
template<typename F, typename... Args>
inline double simpson_prec_helper(F &&f, double a, double f_a, double b, double f_b, double prec, int &count, Args&&... args)
{
double c = (a + b)/2.;
double f_c = f(c, args...);
if((++count < MAX_SIMPSON_BINS) &&
(f_c != 0.) &&
(std::abs(a/c - 1.) > MIN_SIMPSON_SIZE) &&
(std::abs(1. - (f_a + f_b)/2./f_c) > prec)) {
return simpson_prec_helper(f, a, f_a, c, f_c, prec, count, args...)
+ simpson_prec_helper(f, c, f_c, b, f_b, prec, count, args...);
} else {
return (b - a)*(f_a + f_b + f_c*4.)/6.;
}
}
// simpson integration according to required precision
template<typename F, typename... Args>
double simpson_prec(F &&f, double a, double b, double prec, Args&&... args)
{
double f_a = f(a, args...);
double f_b = f(b, args...);
int count = 0;
return simpson_prec_helper(f, a, f_a, b, f_b, prec, count, args...);
}
template<class T, typename F, typename... Args>
double simpson_prec(F (T::*f), T *t, double a, double b, double prec, Args&&... args)
{
double f_a = (t->*f)(a, args...);
double f_b = (t->*f)(b, args...);
int count = 0;
// wrapper member function
auto fn = [t, f] (double val, Args&&... args2)
{
return (t->*f)(val, args2...);
};
return simpson_prec_helper(fn, a, f_a, b, f_b, prec, count, args...);
}
} // namespace cana
#endif // CANA_INTEGRATE_H
|
#pragma once
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/video/background_segm.hpp>
#include "IBGS.h"
#include "QDir"
class MixtureOfGaussianV1BGS : public IBGS
{
private:
bool firstTime;
cv::BackgroundSubtractorMOG mog;
cv::Mat img_foreground;
double alpha;
bool enableThreshold;
int threshold;
bool showOutput;
public:
MixtureOfGaussianV1BGS();
~MixtureOfGaussianV1BGS();
void process(const cv::Mat &img_input, cv::Mat &img_output);
inline void setThreshold(int t){threshold = t;}
inline int getThreshold(){return threshold;}
private:
void saveConfig();
void loadConfig();
};
|
#include "intrinsics.h"
#include "swihook.h"
#include "core.h"
#include "remap.h"
#include "string.h"
unsigned int *__swihook_lib = 0;
void __swihook_bxlr(){};
void __swihook_abort(unsigned short swinum, unsigned int swi_call_lr_address)
{
__core_lprintf("*** swihandler: no function %d (%03X) LR = 0x%08X\r\n", swinum, swinum, swi_call_lr_address);
}
unsigned int *__swihook_getlib()
{
if (__swihook_lib)
return __swihook_lib;
else return 0;
}
int __swihook_install(unsigned int *swilib)
{
if (swilib)
{
__swihook_lib = swilib;
int doms = __MRC(15, 0, 3, 0, 0);
__MCR(15, 0, 0xFFFFFFFF, 3, 0, 0);
unsigned int *swij = (unsigned int *)(* ( ( unsigned int *) (SWIHOOK_JUMPER_ADDRESS) ));
swij[0] = SWIHOOK_JUMPER_OPCODE;
swij[1] = ( unsigned int )&__swihandler_start;
__swihook_setfunc(SWINUM_LIBADDRESS, (unsigned int)&__swihook_getlib);
__swihook_setfunc(SWINUM_SETSWIFUNC, (unsigned int)&__swihook_setfunc);
__swihook_setfunc(SWINUM_GETSWIFUNC, (unsigned int)&__swihook_getfunc);
__swihook_setfunc(SWINUM_CLRSWIFUNC, (unsigned int)&__swihook_clearfunc);
// Ñîçäà¸ì òàáëèöó
unsigned int *t = __mmu_coarse_malloc();
if (t)
{
//Ðåãèñòðèðóåì
__mmu_coarse_set(SWILIB_BASE, (int)t);
for (int i = 0; i < 4; i++)
{
unsigned char *p = __mmu_coarsepage_malloc();
if (p)
{
__mmu_coarsepage_set(t, SWILIB_BASE + MMU_PAGE_SIZE * i, (unsigned int)p);
} else { __MCR(15, 0, doms, 3, 0, 0); return 0; }
}
//Êîïèðóåì òàáëèöó íà íîâûé àäðåñ
memcpy((void *)SWILIB_BASE, __swihook_lib, SWILIB_SIZE);
//Óñòàíàâëèâàåì íîâûé àäðåñ òàáëèöû
__swihook_lib = (unsigned int *)SWILIB_BASE;
} else { __MCR(15, 0, doms, 3, 0, 0); return 0; }
__MCR(15, 0, doms, 3, 0, 0);
return 1;
}
return 0;
}
int __swihook_setfunc(unsigned short swinum, unsigned int address)
{
if (!__swihook_lib) return 0;
__swihook_lib[swinum] = address;
return 1;
}
unsigned int __swihook_getfunc(unsigned short swinum)
{
if (!__swihook_lib) return 0;
unsigned int ret = 0;
ret = __swihook_lib[swinum];
return ret;
}
int __swihook_clearfunc(unsigned short swinum)
{
if (!__swihook_lib) return 0;
__swihook_lib[swinum] = (unsigned int)& __swihook_bxlr;
return 1;
}
|
#ifndef _DEBUG_H_
#define _DEBUG_H
#include <kos.h>
/*
* Several debug methods:
* - debug_log: display a general message (no severity).
* - debug_warn: display a warning message (average severity).
* - debug_error: display a potentially game breaking message (high severity).
*/
void debug_log(const char* str);
void debug_warn(const char* str);
void debug_error(const char* str);
#endif // _DEBUG_H_
|
// Copyright (C) Explorer++ Project
// SPDX-License-Identifier: GPL-3.0-only
// See LICENSE in the top level directory
#pragma once
#include "Plugins/LuaPlugin.h"
#include "PluginInterface.h"
namespace std
{
namespace filesystem
{
class path;
}
}
namespace Plugins
{
class PluginManager
{
public:
PluginManager(PluginInterface *pluginInterface);
void loadAllPlugins(const std::filesystem::path &pluginDirectory);
private:
static const std::wstring MANIFEST_NAME;
bool attemptToLoadPlugin(const std::filesystem::path &directory);
bool registerPlugin(const std::filesystem::path &directory, const Manifest &manifest);
PluginInterface *m_pluginInterface;
std::vector<std::unique_ptr<Plugins::LuaPlugin>> m_plugins;
};
}
|
/*
Copyright © 2014-2015 by The qTox Project
This file is part of qTox, a Qt-based graphical interface for Tox.
qTox is libre 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.
qTox 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 qTox. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef AUDIO_H
#define AUDIO_H
#include <atomic>
#include <cmath>
#include <QObject>
#include <QMutex>
#include <QTimer>
#if defined(__APPLE__) && defined(__MACH__)
#include <OpenAL/al.h>
#include <OpenAL/alc.h>
#else
#include <AL/al.h>
#include <AL/alc.h>
#endif
#ifndef ALC_ALL_DEVICES_SPECIFIER
// compatibility with older versions of OpenAL
#include <AL/alext.h>
#endif
// Public default audio settings
static constexpr uint32_t AUDIO_SAMPLE_RATE = 48000; ///< The next best Opus would take is 24k
static constexpr uint32_t AUDIO_FRAME_DURATION = 20; ///< In milliseconds
static constexpr ALint AUDIO_FRAME_SAMPLE_COUNT = AUDIO_FRAME_DURATION * AUDIO_SAMPLE_RATE/1000;
static constexpr uint32_t AUDIO_CHANNELS = 2; ///< Ideally, we'd auto-detect, but that's a sane default
class Audio : public QObject
{
Q_OBJECT
class Private;
public:
static Audio& getInstance();
qreal outputVolume() const;
void setOutputVolume(qreal volume);
qreal minInputGain() const;
void setMinInputGain(qreal dB);
qreal maxInputGain() const;
void setMaxInputGain(qreal dB);
qreal inputGain() const;
void setInputGain(qreal dB);
void reinitInput(const QString& inDevDesc);
bool reinitOutput(const QString& outDevDesc);
bool isInputReady() const;
bool isOutputReady() const;
static QStringList outDeviceNames();
static QStringList inDeviceNames();
void subscribeOutput(ALuint& sid);
void unsubscribeOutput(ALuint& sid);
void subscribeInput();
void unsubscribeInput();
void startLoop();
void stopLoop();
void playMono16Sound(const QByteArray& data);
void playMono16Sound(const QString& path);
void playAudioBuffer(ALuint alSource, const int16_t *data, int samples,
unsigned channels, int sampleRate);
signals:
void groupAudioPlayed(int group, int peer, unsigned short volume);
/// When there are input subscribers, we regularly emit captured audio frames with this signal
/// Always connect with a blocking queued connection or a lambda, or the behavior is undefined
void frameAvailable(const int16_t *pcm, size_t sample_count, uint8_t channels, uint32_t sampling_rate);
private:
Audio();
~Audio();
static void checkAlError() noexcept;
static void checkAlcError(ALCdevice *device) noexcept;
bool autoInitInput();
bool autoInitOutput();
bool initInput(const QString& deviceName);
bool initOutput(const QString& outDevDescr);
void cleanupInput();
void cleanupOutput();
/// Called after a mono16 sound stopped playing
void playMono16SoundCleanup();
/// Called on the captureTimer events to capture audio
void doCapture();
private:
Private* d;
private:
QThread* audioThread;
mutable QMutex audioLock;
ALCdevice* alInDev;
quint32 inSubscriptions;
QTimer captureTimer, playMono16Timer;
ALCdevice* alOutDev;
ALCcontext* alOutContext;
ALuint alMainSource;
ALuint alMainBuffer;
bool outputInitialized;
QList<ALuint> outSources;
};
#endif // AUDIO_H
|
/*
* catregexpnoderepeater.h
*
* Created on: Jun 24, 2010
*/
#ifndef CATREGEXPNODEREPEATER_H_
#define CATREGEXPNODEREPEATER_H_
#include "catregexpnode.h"
G_BEGIN_DECLS
#define CAT_TYPE_REGEXP_NODE_REPEATER (cat_regexp_node_repeater_get_type())
#define CAT_REGEXP_NODE_REPEATER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), cat_regexp_node_repeater_get_type(), CatRegexpNodeRepeater))
#define CAT_REGEXP_NODE_REPEATER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAT_TYPE_REGEXP_NODE_REPEATER, CatRegexpNodeRepeaterClass))
#define CAT_IS_REGEXP_NODE_REPEATER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAT_TYPE_REGEXP_NODE_REPEATER))
#define CAT_IS_REGEXP_NODE_REPEATER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAT_TYPE_REGEXP_NODE_REPEATER))
#define CAT_REGEXP_NODE_REPEATER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CAT_TYPE_REGEXP_NODE_REPEATER, CatRegexpNodeRepeaterClass))
typedef struct _CatRegexpNodeRepeater CatRegexpNodeRepeater;
typedef struct _CatRegexpNodeRepeaterClass CatRegexpNodeRepeaterClass;
struct _CatRegexpNodeRepeater {
CatRegexpNode parent;
CatRegexpNode *child;
};
struct _CatRegexpNodeRepeaterClass {
CatRegexpNodeClass parent_class;
};
CatRegexpNodeRepeater *cat_regexp_node_repeater_new(CatRegexpNode *child);
G_END_DECLS
#endif /* CATREGEXPNODEREPEATER_H_ */
|
/***************************************************************
* Name: CompilerDlg.h
* Purpose: Defines Compiler Dialog Class
* Author: kushagra gour a.k.a chin chang (chinchang457@gmail.com)
* Created: 2010-11-21
Copyright 2010 Kushagra Gour (http://kushagragour.in)
This file is part of JIDE.
JIDE 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.
JIDE 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 JIDE. If not, see <http://www.gnu.org/licenses/>.
**************************************************************/
#ifndef COMPILERDLG_H
#define COMPILERDLG_H
//(*Headers(CompilerDlg)
#include <wx/sizer.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/dialog.h>
//*)
#include <wx/config.h>
class CompilerDlg: public wxDialog
{
public:
CompilerDlg(wxWindow* parent,wxWindowID id=wxID_ANY,const wxPoint& pos=wxDefaultPosition,const wxSize& size=wxDefaultSize);
virtual ~CompilerDlg();
//(*Declarations(CompilerDlg)
wxButton* Button1;
wxStaticText* StaticText1;
wxButton* Button2;
wxTextCtrl* TextCtrl1;
//*)
protected:
//(*Identifiers(CompilerDlg)
static const long ID_STATICTEXT1;
static const long ID_TEXTCTRL1;
static const long ID_BUTTON1;
static const long ID_BUTTON2;
//*)
private:
//(*Handlers(CompilerDlg)
void OnCancel(wxCommandEvent& event);
void OnSave(wxCommandEvent& event);
//*)
// My functions
void saveSettings();
DECLARE_EVENT_TABLE()
};
#endif
|
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
*
* RetroArch 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 Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch 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 RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "ext/rarch_audio.h"
#include "../boolean.h"
#include <stdlib.h>
#include <stdint.h>
#include "../driver.h"
#include "../dynamic.h"
#include "../general.h"
#include <sys/types.h>
typedef struct audio_ext
{
dylib_t lib;
const rarch_audio_driver_t *driver;
void *handle;
bool is_float;
} audio_ext_t;
static void audio_ext_free(void *data)
{
audio_ext_t *ext = (audio_ext_t*)data;
if (ext)
{
if (ext->driver && ext->handle)
ext->driver->free(ext->handle);
if (ext->lib)
dylib_close(ext->lib);
free(ext);
}
}
static void *audio_ext_init(const char *device, unsigned rate, unsigned latency)
{
if (!(*g_settings.audio.external_driver))
{
RARCH_ERR("Please define an external audio driver.\n");
return NULL;
}
audio_ext_t *ext = (audio_ext_t*)calloc(1, sizeof(*ext));
if (!ext)
return NULL;
rarch_audio_driver_info_t info = {0};
const rarch_audio_driver_t *(*plugin_load)(void) = NULL;
ext->lib = dylib_load(g_settings.audio.external_driver);
if (!ext->lib)
{
RARCH_ERR("Failed to load external library \"%s\"\n", g_settings.audio.external_driver);
goto error;
}
plugin_load = (const rarch_audio_driver_t *(*)(void))dylib_proc(ext->lib, "rarch_audio_driver_init");
if (!plugin_load)
plugin_load = (const rarch_audio_driver_t *(*)(void))dylib_proc(ext->lib, "ssnes_audio_driver_init"); // Compat. Will be dropped on ABI break.
if (!plugin_load)
{
RARCH_ERR("Failed to find symbol \"rarch_audio_driver_init\" in plugin.\n");
goto error;
}
ext->driver = plugin_load();
if (!ext->driver)
{
RARCH_ERR("Received invalid driver from plugin.\n");
goto error;
}
RARCH_LOG("Loaded external audio driver: \"%s\"\n", ext->driver->ident ? ext->driver->ident : "Unknown");
if (ext->driver->api_version != RARCH_AUDIO_API_VERSION)
{
RARCH_ERR("API mismatch in external audio plugin. SSNES: %d, Plugin: %d ...\n", RARCH_AUDIO_API_VERSION, ext->driver->api_version);
goto error;
}
info.device = device;
info.sample_rate = rate;
info.latency = latency;
ext->handle = ext->driver->init(&info);
if (!ext->handle)
{
RARCH_ERR("Failed to init audio driver.\n");
goto error;
}
if (ext->driver->sample_rate)
g_settings.audio.out_rate = ext->driver->sample_rate(ext->handle);
if (!g_settings.audio.sync)
ext->driver->set_nonblock_state(ext->handle, RARCH_TRUE);
return ext;
error:
audio_ext_free(ext);
return NULL;
}
static ssize_t audio_ext_write(void *data, const void *buf, size_t size)
{
audio_ext_t *ext = (audio_ext_t*)data;
unsigned frame_size = ext->is_float ? (2 * sizeof(float)) : (2 * sizeof(int16_t));
size /= frame_size;
int ret = ext->driver->write(ext->handle, buf, size);
if (ret < 0)
return -1;
return ret * frame_size;
}
static bool audio_ext_start(void *data)
{
audio_ext_t *ext = (audio_ext_t*)data;
return ext->driver->start(ext->handle);
}
static bool audio_ext_stop(void *data)
{
audio_ext_t *ext = (audio_ext_t*)data;
return ext->driver->stop(ext->handle);
}
static void audio_ext_set_nonblock_state(void *data, bool toggle)
{
audio_ext_t *ext = (audio_ext_t*)data;
ext->driver->set_nonblock_state(ext->handle, toggle);
}
static bool audio_ext_use_float(void *data)
{
audio_ext_t *ext = (audio_ext_t*)data;
ext->is_float = ext->driver->use_float(ext->handle);
return ext->is_float;
}
const audio_driver_t audio_ext = {
audio_ext_init,
audio_ext_write,
audio_ext_stop,
audio_ext_start,
audio_ext_set_nonblock_state,
audio_ext_free,
audio_ext_use_float,
"ext"
};
|
/**
* @file problem.c
* @brief Example problem: Radiation forces
* @author Hanno Rein <hanno@hanno-rein.de>
* @detail This example provides an implementation of the
* Poynting-Robertson effect. The code is using the IAS15 integrator
* which is ideally suited for this velocity dependent force.
*
* @section LICENSE
* Copyright (c) 2013 Hanno Rein, Dave Spiegel
*
* This file is part of rebound.
*
* rebound 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.
*
* rebound 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 rebound. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <time.h>
#include "main.h"
#include "tools.h"
#include "output.h"
#include "particle.h"
#include "problem.h"
#include "integrator.h"
#include "integrator_ias15.h"
void additional_forces();
double betaparticles = 0.01; // beta parameter
// defined as the ratio of radiation pressure over gravity
void problem_init(int argc, char* argv[]){
// setup constants
dt = 1e-3; // initial timestep
integrator = IAS15;
integrator_ias15_epsilon = 1e-4; // accuracy parameter
boxsize = 10;
tmax = 1e5;
N_active = 1; // the star is the only massive particle
problem_additional_forces = additional_forces; // setup callback function for velocity dependent forces
init_box();
// star is at rest at origin
struct particle star;
star.x = 0; star.y = 0; star.z = 0;
star.vx = 0; star.vy = 0; star.vz = 0;
star.m = 1.;
particles_add(star);
// dust particles are initially on a circular orbit
while(N<2){
struct particle p;
p.m = 0; // massless
double a = 1.; // a = 1 AU
double v = sqrt(G*(star.m*(1.-betaparticles))/a);
double phi = tools_uniform(0,2.*M_PI); // random phase
p.x = a*sin(phi); p.y = a*cos(phi); p.z = 0;
p.vx = -v*cos(phi); p.vy = v*sin(phi); p.vz = 0;
particles_add(p);
}
system("rm -v radius.txt"); // remove previous output
}
void force_radiation(){
const struct particle star = particles[0]; // cache
#pragma omp parallel for
for (int i=0;i<N;i++){
const struct particle p = particles[i]; // cache
if (p.m!=0.) continue; // only dust particles feel radiation forces
const double prx = p.x-star.x;
const double pry = p.y-star.y;
const double prz = p.z-star.z;
const double pr = sqrt(prx*prx + pry*pry + prz*prz); // distance relative to star
const double prvx = p.vx-star.vx;
const double prvy = p.vy-star.vy;
const double prvz = p.vz-star.vz;
const double c = 1.006491504759635e+04; // speed of light in unit of G=1, M_sun=1, 1year=1
const double rdot = (prvx*prx + prvy*pry + prvz*prz)/pr; // radial velocity relative to star
const double F_r = betaparticles*G*star.m/(pr*pr);
// Equation (5) of Burns, Lamy, Soter (1979)
particles[i].ax += F_r*((1.-rdot/c)*prx/pr - prvx/c);
particles[i].ay += F_r*((1.-rdot/c)*pry/pr - prvy/c);
particles[i].az += F_r*((1.-rdot/c)*prz/pr - prvz/c);
}
}
void additional_forces(){
force_radiation(); // PR drag (see above)
}
void problem_output(){
if(output_check(400.)){ // print some information to screen
output_timing();
}
if(output_check(M_PI*2.*1000.)){ // output radial distance every 1000 years
FILE* f = fopen("radius.txt","a");
const struct particle star = particles[0];
for (int i=1;i<N;i++){
const struct particle p = particles[i];
const double prx = p.x-star.x;
const double pry = p.y-star.y;
const double prz = p.z-star.z;
const double pr = sqrt(prx*prx + pry*pry + prz*prz); // distance relative to star
fprintf(f,"%e\t%e\n",t,pr);
}
fclose(f);
}
}
void problem_finish(){
}
|
//
// Created by Guillaume LAROYENNE on 06/11/16.
//
#ifndef PROJETALGOC_QUEUE_H
#define PROJETALGOC_QUEUE_H
typedef struct queue {
void **elements;
int nbElements;
} queue_t;
queue_t *createQueue();
void *poll(queue_t *q);
void offer(queue_t *q, void *n);
int isEmpty(queue_t *q);
void clear(queue_t *queue);
void free_queue(queue_t *queue);
#endif //PROJETALGOC_QUEUE_H
|
/* vim: set expandtab ts=4 sw=4: */
/*
* You may redistribute this program and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "admin/testframework/AdminTestFramework.h"
#include "admin/Admin.h"
#include "admin/AdminClient.h"
#include "benc/Dict.h"
#include "benc/String.h"
#include "benc/Int.h"
#include "exception/Jmp.h"
#include "interface/addressable/UDPAddrInterface.h"
#include "interface/tuntap/TUNInterface.h"
#include "interface/tuntap/TUNMessageType.h"
#include "interface/tuntap/NDPServer.h"
#include "memory/Allocator.h"
#include "memory/MallocAllocator.h"
#include "io/FileWriter.h"
#include "io/Writer.h"
#include "util/Assert.h"
#include "util/log/Log.h"
#include "util/log/WriterLog.h"
#include "util/events/Timeout.h"
#include "wire/Ethernet.h"
#include "wire/Headers.h"
#include "util/platform/netdev/NetDev.h"
#include "test/RootTest.h"
#include "interface/tuntap/test/TUNTools.h"
#include "interface/tuntap/TAPWrapper.h"
#include <unistd.h>
#include <stdlib.h>
static const uint8_t testAddrA[] = {0xfd,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
static const uint8_t testAddrB[] = {0xfd,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2};
/*
* Setup a UDPInterface and a TUNInterface, test sending traffic between them.
*/
static int receivedMessageTUNCount = 0;
static uint8_t receiveMessageTUN(struct Message* msg, struct Interface* iface)
{
receivedMessageTUNCount++;
uint16_t ethertype = TUNMessageType_pop(msg, NULL);
if (ethertype != Ethernet_TYPE_IP6) {
printf("Spurious packet with ethertype [%04x]\n", Endian_bigEndianToHost16(ethertype));
return 0;
}
struct Headers_IP6Header* header = (struct Headers_IP6Header*) msg->bytes;
if (msg->length != Headers_IP6Header_SIZE + Headers_UDPHeader_SIZE + 12) {
int type = (msg->length >= Headers_IP6Header_SIZE) ? header->nextHeader : -1;
printf("Message of unexpected length [%u] ip6->nextHeader: [%d]\n", msg->length, type);
return 0;
}
if (Bits_memcmp(header->destinationAddr, testAddrB, 16)) { return 0; }
if (Bits_memcmp(header->sourceAddr, testAddrA, 16)) { return 0; }
Bits_memcpyConst(header->destinationAddr, testAddrA, 16);
Bits_memcpyConst(header->sourceAddr, testAddrB, 16);
TUNMessageType_push(msg, ethertype, NULL);
return iface->sendMessage(msg, iface);
}
static uint8_t receiveMessageUDP(struct Message* msg, struct Interface* iface)
{
if (!receivedMessageTUNCount) {
return 0;
}
// Got the message, test successful.
struct Allocator* alloc = iface->receiverContext;
Allocator_free(alloc);
return 0;
}
static void fail(void* ignored)
{
Assert_true(!"timeout");
}
int main(int argc, char** argv)
{
struct Allocator* alloc = MallocAllocator_new(1<<20);
struct EventBase* base = EventBase_new(alloc);
struct Writer* logWriter = FileWriter_new(stdout, alloc);
struct Log* log = WriterLog_new(logWriter, alloc);
struct Sockaddr* addrA = Sockaddr_fromBytes(testAddrA, Sockaddr_AF_INET6, alloc);
char assignedIfName[TUNInterface_IFNAMSIZ];
struct Interface* tap = TUNInterface_new(NULL, assignedIfName, 1, base, log, NULL, alloc);
struct TAPWrapper* tapWrapper = TAPWrapper_new(tap, log, alloc);
// Now setup the NDP server so the tun will work correctly.
struct NDPServer* ndp = NDPServer_new(&tapWrapper->generic, log, TAPWrapper_LOCAL_MAC, alloc);
ndp->advertisePrefix[0] = 0xfd;
ndp->prefixLen = 8;
struct Interface* tun = &ndp->generic;
NetDev_addAddress(assignedIfName, addrA, 126, log, NULL);
struct Sockaddr_storage addr;
Assert_true(!Sockaddr_parse("[::]", &addr));
struct AddrInterface* udp = TUNTools_setupUDP(base, &addr.addr, alloc, log);
struct Sockaddr* dest = Sockaddr_clone(udp->addr, alloc);
uint8_t* addrBytes;
Assert_true(16 == Sockaddr_getAddress(dest, &addrBytes));
Bits_memcpy(addrBytes, testAddrB, 16);
udp->generic.receiveMessage = receiveMessageUDP;
udp->generic.receiverContext = alloc;
tun->receiveMessage = receiveMessageTUN;
TUNTools_sendHelloWorld(udp, dest, base, alloc);
Timeout_setTimeout(fail, NULL, 10000000, base, alloc);
EventBase_beginLoop(base);
return 0;
}
|
#ifndef CYGONCE_HAL_VAR_INTR_H
#define CYGONCE_HAL_VAR_INTR_H
//==========================================================================
//
// imp_intr.h
//
// TX49 Interrupt and clock support
//
//==========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos 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 or (at your option) any later version.
//
// eCos 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 eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jskov
// Contributors: jskov
// Date: 2000-05-09
// Purpose: TX49 Interrupt support
// Description: The macros defined here provide the HAL APIs for handling
// interrupts and the clock for variants of the TX49 MIPS
// architecture.
//
// Usage:
// #include <cyg/hal/var_intr.h>
// ...
//
//
//####DESCRIPTIONEND####
//
//==========================================================================
#include <pkgconf/hal.h>
#include <cyg/hal/plf_intr.h>
//--------------------------------------------------------------------------
// Interrupt vectors.
// Vectors and handling of these are defined in platform HALs since the
// CPU itself does not have a builtin interrupt controller.
//--------------------------------------------------------------------------
// Clock control
// This is handled by the default code
//--------------------------------------------------------------------------
#endif // ifndef CYGONCE_HAL_VAR_INTR_H
// End of var_intr.h
|
/****************************************************************************/
/// @file PCLoaderVisum.h
/// @author Daniel Krajzewicz
/// @author Michael Behrisch
/// @date Thu, 02.11.2006
/// @version $Id: PCLoaderVisum.h 13811 2013-05-01 20:31:43Z behrisch $
///
// A reader of pois and polygons stored in VISUM-format
/****************************************************************************/
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
// Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
/****************************************************************************/
//
// This file is part of SUMO.
// SUMO 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.
//
/****************************************************************************/
#ifndef PCLoaderVisum_h
#define PCLoaderVisum_h
// ===========================================================================
// included modules
// ===========================================================================
#ifdef _MSC_VER
#include <windows_config.h>
#else
#include <config.h>
#endif
#include <string>
#include "PCPolyContainer.h"
#include "PCTypeMap.h"
// ===========================================================================
// class definitions
// ===========================================================================
class OptionsCont;
// ===========================================================================
// class declarations
// ===========================================================================
/**
* @class PCLoaderVisum
* @brief A reader of pois and polygons stored in VISUM-format
*/
class PCLoaderVisum {
public:
/** @brief Loads pois/polygons assumed to be stored using VISUM-format
*
* If the option "visum-files" is set within the given options container,
* the files stored herein are parsed using "load", assuming this
* option contains file paths to files containing pois and polygons stored
* in VISUM ".net"-format.
*
* @param[in] oc The options container to get further options from
* @param[in] toFill The poly/pois container to add loaded polys/pois to
* @param[in] tm The type map to use for setting values of loaded polys/pois
* @exception ProcessError if something fails
*/
static void loadIfSet(OptionsCont& oc, PCPolyContainer& toFill,
PCTypeMap& tm);
protected:
/** @brief Parses pois/polys stored within the given file
* @param[in] oc The options container to get further options from
* @param[in] toFill The poly/pois container to add loaded polys/pois to
* @param[in] tm The type map to use for setting values of loaded polys/pois
* @exception ProcessError if something fails
*/
static void load(const std::string& file, OptionsCont& oc, PCPolyContainer& toFill,
PCTypeMap& tm);
};
#endif
/****************************************************************************/
|
//----------------------------------------------------------------------------
/** @file RlFuegoPlayout.h
Policy wrapper for Fuego playouts
*/
//----------------------------------------------------------------------------
#ifndef RLFUEGOPLAYOUT_H
#define RLFUEGOPLAYOUT_H
#include "RlUtils.h"
#include "GoUctPlayoutPolicy.h"
//----------------------------------------------------------------------------
/** Fuego playout wrapper class */
class RlFuegoPlayout : public RlAutoObject
{
public:
DECLARE_OBJECT(RlFuegoPlayout);
RlFuegoPlayout(GoBoard& board);
~RlFuegoPlayout();
virtual void LoadSettings(std::istream& settings);
virtual void Initialise();
SgMove GenerateMove();
void OnPlay();
void OnStart();
void OnEnd();
private:
GoUctPlayoutPolicyParam m_param;
SgBWSet m_safe;
SgPointArray<bool> m_allSafe;
GoUctPlayoutPolicy<GoBoard>* m_uctPlayout;
};
//----------------------------------------------------------------------------
#endif // RLFUEGOPLAYOUT_H
|
/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaCpyPlane.c,v 1.13 2001/10/01 13:44:15 eich Exp $ */
/*
A CopyPlane function that handles bitmap->screen copies and
sends anything else to the Fallback.
Also, a PushPixels for solid fill styles.
Written by Mark Vojkovich (markv@valinux.com)
*/
#include "misc.h"
#include "xf86.h"
#include "xf86_ansic.h"
#include "xf86_OSproc.h"
#include "servermd.h"
#include "X.h"
#include "scrnintstr.h"
#include "mi.h"
#include "pixmapstr.h"
#include "xf86str.h"
#include "xaa.h"
#include "xaalocal.h"
#include "xaawrap.h"
static void XAACopyPlane1toNColorExpand(DrawablePtr pSrc, DrawablePtr pDst,
GCPtr pGC, RegionPtr rgnDst,
DDXPointPtr pptSrc);
static void XAACopyPlaneNtoNColorExpand(DrawablePtr pSrc, DrawablePtr pDst,
GCPtr pGC, RegionPtr rgnDst,
DDXPointPtr pptSrc);
static unsigned long TmpBitPlane;
RegionPtr
XAACopyPlaneColorExpansion(
DrawablePtr pSrc,
DrawablePtr pDst,
GCPtr pGC,
int srcx, int srcy,
int width, int height,
int dstx, int dsty,
unsigned long bitPlane
){
if((pSrc->type == DRAWABLE_PIXMAP) && !XAA_DEPTH_BUG(pGC)) {
if(pSrc->bitsPerPixel == 1) {
return(XAABitBlt(pSrc, pDst, pGC, srcx, srcy,
width, height, dstx, dsty,
XAACopyPlane1toNColorExpand, bitPlane));
} else if(bitPlane < (1 << pDst->depth)){
TmpBitPlane = bitPlane;
return(XAABitBlt(pSrc, pDst, pGC, srcx, srcy,
width, height, dstx, dsty,
XAACopyPlaneNtoNColorExpand, bitPlane));
}
}
return (XAAFallbackOps.CopyPlane(pSrc, pDst, pGC, srcx, srcy,
width, height, dstx, dsty, bitPlane));
}
static void
XAACopyPlane1toNColorExpand(
DrawablePtr pSrc,
DrawablePtr pDst,
GCPtr pGC,
RegionPtr rgnDst,
DDXPointPtr pptSrc )
{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
BoxPtr pbox = REGION_RECTS(rgnDst);
int numrects = REGION_NUM_RECTS(rgnDst);
unsigned char *src = ((PixmapPtr)pSrc)->devPrivate.ptr;
int srcwidth = ((PixmapPtr)pSrc)->devKind;
while(numrects--) {
(*infoRec->WriteBitmap)(infoRec->pScrn, pbox->x1, pbox->y1,
pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
src + (srcwidth * pptSrc->y) + ((pptSrc->x >> 5) << 2),
srcwidth, pptSrc->x & 31,
pGC->fgPixel, pGC->bgPixel, pGC->alu, pGC->planemask);
pbox++; pptSrc++;
}
}
static void
XAACopyPlaneNtoNColorExpand(
DrawablePtr pSrc,
DrawablePtr pDst,
GCPtr pGC,
RegionPtr rgnDst,
DDXPointPtr pptSrc
){
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
BoxPtr pbox = REGION_RECTS(rgnDst);
int numrects = REGION_NUM_RECTS(rgnDst);
unsigned char *src = ((PixmapPtr)pSrc)->devPrivate.ptr;
unsigned char *data, *srcPtr, *dataPtr;
int srcwidth = ((PixmapPtr)pSrc)->devKind;
int pitch, width, height, h, i, index, offset;
int Bpp = pSrc->bitsPerPixel >> 3;
unsigned long mask = TmpBitPlane;
if(TmpBitPlane < 8) {
offset = 0;
} else if(TmpBitPlane < 16) {
offset = 1;
mask >>= 8;
} else if(TmpBitPlane < 24) {
offset = 2;
mask >>= 16;
} else {
offset = 3;
mask >>= 24;
}
if(IS_OFFSCREEN_PIXMAP(pSrc))
SYNC_CHECK(pSrc);
while(numrects--) {
width = pbox->x2 - pbox->x1;
h = height = pbox->y2 - pbox->y1;
pitch = BitmapBytePad(width);
if(!(data = xalloc(height * pitch)))
goto ALLOC_FAILED;
bzero(data, height * pitch);
dataPtr = data;
srcPtr = ((pptSrc->y) * srcwidth) + src +
((pptSrc->x) * Bpp) + offset;
while(h--) {
for(i = index = 0; i < width; i++, index += Bpp) {
if(mask & srcPtr[index])
dataPtr[i >> 3] |= (1 << (i & 7));
}
dataPtr += pitch;
srcPtr += srcwidth;
}
(*infoRec->WriteBitmap)(infoRec->pScrn,
pbox->x1, pbox->y1, width, height, data, pitch, 0,
pGC->fgPixel, pGC->bgPixel, pGC->alu, pGC->planemask);
xfree(data);
ALLOC_FAILED:
pbox++; pptSrc++;
}
}
void
XAAPushPixelsSolidColorExpansion(
GCPtr pGC,
PixmapPtr pBitMap,
DrawablePtr pDraw,
int dx, int dy,
int xOrg, int yOrg )
{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
int MaxBoxes = REGION_NUM_RECTS(pGC->pCompositeClip);
BoxPtr pbox, pClipBoxes;
int nboxes, srcx, srcy;
xRectangle TheRect;
unsigned char *src = pBitMap->devPrivate.ptr;
int srcwidth = pBitMap->devKind;
if(!REGION_NUM_RECTS(pGC->pCompositeClip))
return;
TheRect.x = xOrg;
TheRect.y = yOrg;
TheRect.width = dx;
TheRect.height = dy;
if(MaxBoxes > (infoRec->PreAllocSize/sizeof(BoxRec))) {
pClipBoxes = xalloc(MaxBoxes * sizeof(BoxRec));
if(!pClipBoxes) return;
} else pClipBoxes = (BoxPtr)infoRec->PreAllocMem;
nboxes = XAAGetRectClipBoxes(pGC->pCompositeClip, pClipBoxes, 1, &TheRect);
pbox = pClipBoxes;
while(nboxes--) {
srcx = pbox->x1 - xOrg;
srcy = pbox->y1 - yOrg;
(*infoRec->WriteBitmap)(infoRec->pScrn, pbox->x1, pbox->y1,
pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
src + (srcwidth * srcy) + ((srcx >> 5) << 2),
srcwidth, srcx & 31,
pGC->fgPixel, -1, pGC->alu, pGC->planemask);
pbox++;
}
if(pClipBoxes != (BoxPtr)infoRec->PreAllocMem)
xfree(pClipBoxes);
}
|
/* 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[4];
atomic_int atom_1_r1_1;
void *t0(void *arg){
label_1:;
atomic_store_explicit(&vars[0], 2, memory_order_seq_cst);
atomic_store_explicit(&vars[1], 1, memory_order_seq_cst);
return NULL;
}
void *t1(void *arg){
label_2:;
int v2_r1 = atomic_load_explicit(&vars[1], memory_order_seq_cst);
int v3_r3 = v2_r1 ^ v2_r1;
atomic_store_explicit(&vars[2+v3_r3], 1, memory_order_seq_cst);
int v5_r6 = atomic_load_explicit(&vars[2], memory_order_seq_cst);
int v7_r7 = atomic_load_explicit(&vars[2], memory_order_seq_cst);
int v8_r8 = v7_r7 ^ v7_r7;
atomic_store_explicit(&vars[3+v8_r8], 1, memory_order_seq_cst);
int v10_r11 = atomic_load_explicit(&vars[3], memory_order_seq_cst);
int v11_cmpeq = (v10_r11 == v10_r11);
if (v11_cmpeq) goto lbl_LC00; else goto lbl_LC00;
lbl_LC00:;
atomic_store_explicit(&vars[0], 1, memory_order_seq_cst);
int v16 = (v2_r1 == 1);
atomic_store_explicit(&atom_1_r1_1, v16, memory_order_seq_cst);
return NULL;
}
int main(int argc, char *argv[]){
pthread_t thr0;
pthread_t thr1;
atomic_init(&vars[3], 0);
atomic_init(&vars[0], 0);
atomic_init(&vars[1], 0);
atomic_init(&vars[2], 0);
atomic_init(&atom_1_r1_1, 0);
pthread_create(&thr0, NULL, t0, NULL);
pthread_create(&thr1, NULL, t1, NULL);
pthread_join(thr0, NULL);
pthread_join(thr1, NULL);
int v12 = atomic_load_explicit(&vars[0], memory_order_seq_cst);
int v13 = (v12 == 2);
int v14 = atomic_load_explicit(&atom_1_r1_1, memory_order_seq_cst);
int v15_conj = v13 & v14;
if (v15_conj == 1) assert(0);
return 0;
}
|
/**
******************************************************************************
* @file FMC/FMC_SDRAM_DataMemory/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_hal.h"
#include "stm32469i_eval.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
#define SDRAM_ADDRESS ((uint32_t) 0xC0000000)
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
#endif /* __MAIN_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
#ifndef FILEHASHCALCULATORTHREAD_H
#define FILEHASHCALCULATORTHREAD_H
#include "common.h"
#include "components/tfilterwidget.h"
#include <QCryptographicHash>
#include <QDateTime>
#include <QDir>
#include <QFileInfo>
#include <QHeaderView>
#include <QLabel>
#include <QProgressBar>
#include <QSqlError>
#include <QThread>
#include <QWidget>
#include <QTimer>
class FileHashCalculatorThread : public QThread {
Q_OBJECT
public:
enum CompareMode { BySize = 1, Md5 = 2 };
explicit FileHashCalculatorThread(const QStringList &dirs, TFilterWidget *filtersWidget,
CompareMode fileCompareMode = CompareMode::BySize);
~FileHashCalculatorThread();
void stopWorking();
private:
TFilterWidget *filtersWidget;
QStringList dirs;
CompareMode fileCompareMode;
QTimer *timerEverySecond;
qint32 timeSinceStart;
bool stopWork = false;
int getRandom();
void calculateResultsMd5AndRemoveUniq() ;
QString getFileHash(const QString &file_full_path, QFile *file, bool &fromCache);
protected:
virtual void run(); // Q_DECL_OVERRIDE
signals:
// void resultReady(const QString &s);
void setTopLabel(const QString &s);
void setBottomLabel(const QString &s);
void setProgressbarMaximumValue(int val);
void setProgressbarValue(int val);
void setProgressBarSizeMaximumValue(int val);
void setProgressBarSizeValue(int val);
void updateApproximateTime(int val);
private slots:
void updateTimeSinceStart();
};
#endif // FILEHASHCALCULATORTHREAD_H
|
/*
Copyright 2017 Benjamin Vedder benjamin@vedder.se
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 SRF10_H_
#define SRF10_H_
#include "ch.h"
#include "hal.h"
#include "conf_general.h"
// Functions
void srf10_init(void);
void srf10_set_sample_callback(void (*func)(float distance));
msg_t srf10_set_gain(uint8_t gain);
msg_t srf10_set_range(uint8_t range);
msg_t srf10_start_ranging(void);
msg_t srf10_read_range(float *range);
msg_t srf10_reset_i2c(void);
#endif /* SRF10_H_ */
|
/*
# PostgreSQL Database Modeler (pgModeler)
#
# Copyright 2006-2021 - Raphael Araújo e Silva <raphael@pgmodeler.io>
#
# 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.
#
# 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.
#
# The complete text of GPLv3 is at LICENSE file on source code root directory.
# Also, you can get the complete GNU General Public License at <http://www.gnu.org/licenses/>
*/
/**
\ingroup libcore
\brief Implements the operations to manipulate foreign tables on the database.
*/
#ifndef FOREIGN_TABLE_H
#define FOREIGN_TABLE_H
#include "physicaltable.h"
#include "foreignobject.h"
#include "foreignserver.h"
class ForeignTable: public PhysicalTable, public ForeignObject {
private:
//! \brief The foreign server in which the foreign table resides
ForeignServer *foreign_server;
public:
ForeignTable();
virtual ~ForeignTable();
void setForeignServer(ForeignServer *server);
ForeignServer *getForeignServer();
/*! \brief Adds an child object to the foreign table.
* This will raise an error if the user try to add constraints other than CHECK,
* indexes, rules and policies. This because foreign tables only accepts columns, check constraints, triggers */
void addObject(BaseObject *object, int obj_idx = -1);
/*! \brief This method ignores any partitioning type provided for the foreign table.
* It always set partitioning type as null since foreign tables doesn't support partitioning */
void setPartitioningType(PartitioningType);
//! \brief Returns the SQL / XML definition for table
virtual QString getCodeDefinition(unsigned def_type) final;
//! \brief Copy the attributes between two tables
void operator = (ForeignTable &table);
//! \brief Returns the alter definition comparing the this table against the one provided via parameter
virtual QString getAlterDefinition(BaseObject *object) final;
/*! \brief Generates the table's SQL code considering adding the relationship added object or not.
* Note if the method is called with incl_rel_added_objs = true it can produce an SQL/XML code
* that does not reflect the real semantics of the table. So take care to use this method and always
* invalidate the tables code (see setCodeInvalidated()) after retrieving the resulting code */
QString __getCodeDefinition(unsigned def_type, bool incl_rel_added_objs);
friend class Relationship;
friend class OperationList;
};
#endif
|
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at the mozilla.org home page
#ifndef EIGEN_CXX11_THREADPOOL_THREAD_POOL_INTERFACE_H
#define EIGEN_CXX11_THREADPOOL_THREAD_POOL_INTERFACE_H
namespace Eigen {
// This defines an interface that ThreadPoolDevice can take to use
// custom thread pools underneath.
class ThreadPoolInterface {
public:
virtual void Schedule(std::function<void()> fn) = 0;
// Returns the number of threads in the pool.
virtual int NumThreads() const = 0;
// Returns a logical thread index between 0 and NumThreads() - 1 if called
// from one of the threads in the pool. Returns -1 otherwise.
virtual int CurrentThreadId() const = 0;
virtual ~ThreadPoolInterface() {}
};
} // namespace Eigen
#endif // EIGEN_CXX11_THREADPOOL_THREAD_POOL_INTERFACE_H
|
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "internal_group_id_range.h"
OpenAPI_internal_group_id_range_t *OpenAPI_internal_group_id_range_create(
char *start,
char *end,
char *pattern
)
{
OpenAPI_internal_group_id_range_t *internal_group_id_range_local_var = OpenAPI_malloc(sizeof(OpenAPI_internal_group_id_range_t));
if (!internal_group_id_range_local_var) {
return NULL;
}
internal_group_id_range_local_var->start = start;
internal_group_id_range_local_var->end = end;
internal_group_id_range_local_var->pattern = pattern;
return internal_group_id_range_local_var;
}
void OpenAPI_internal_group_id_range_free(OpenAPI_internal_group_id_range_t *internal_group_id_range)
{
if (NULL == internal_group_id_range) {
return;
}
OpenAPI_lnode_t *node;
ogs_free(internal_group_id_range->start);
ogs_free(internal_group_id_range->end);
ogs_free(internal_group_id_range->pattern);
ogs_free(internal_group_id_range);
}
cJSON *OpenAPI_internal_group_id_range_convertToJSON(OpenAPI_internal_group_id_range_t *internal_group_id_range)
{
cJSON *item = NULL;
if (internal_group_id_range == NULL) {
ogs_error("OpenAPI_internal_group_id_range_convertToJSON() failed [InternalGroupIdRange]");
return NULL;
}
item = cJSON_CreateObject();
if (internal_group_id_range->start) {
if (cJSON_AddStringToObject(item, "start", internal_group_id_range->start) == NULL) {
ogs_error("OpenAPI_internal_group_id_range_convertToJSON() failed [start]");
goto end;
}
}
if (internal_group_id_range->end) {
if (cJSON_AddStringToObject(item, "end", internal_group_id_range->end) == NULL) {
ogs_error("OpenAPI_internal_group_id_range_convertToJSON() failed [end]");
goto end;
}
}
if (internal_group_id_range->pattern) {
if (cJSON_AddStringToObject(item, "pattern", internal_group_id_range->pattern) == NULL) {
ogs_error("OpenAPI_internal_group_id_range_convertToJSON() failed [pattern]");
goto end;
}
}
end:
return item;
}
OpenAPI_internal_group_id_range_t *OpenAPI_internal_group_id_range_parseFromJSON(cJSON *internal_group_id_rangeJSON)
{
OpenAPI_internal_group_id_range_t *internal_group_id_range_local_var = NULL;
cJSON *start = cJSON_GetObjectItemCaseSensitive(internal_group_id_rangeJSON, "start");
if (start) {
if (!cJSON_IsString(start)) {
ogs_error("OpenAPI_internal_group_id_range_parseFromJSON() failed [start]");
goto end;
}
}
cJSON *end = cJSON_GetObjectItemCaseSensitive(internal_group_id_rangeJSON, "end");
if (end) {
if (!cJSON_IsString(end)) {
ogs_error("OpenAPI_internal_group_id_range_parseFromJSON() failed [end]");
goto end;
}
}
cJSON *pattern = cJSON_GetObjectItemCaseSensitive(internal_group_id_rangeJSON, "pattern");
if (pattern) {
if (!cJSON_IsString(pattern)) {
ogs_error("OpenAPI_internal_group_id_range_parseFromJSON() failed [pattern]");
goto end;
}
}
internal_group_id_range_local_var = OpenAPI_internal_group_id_range_create (
start ? ogs_strdup(start->valuestring) : NULL,
end ? ogs_strdup(end->valuestring) : NULL,
pattern ? ogs_strdup(pattern->valuestring) : NULL
);
return internal_group_id_range_local_var;
end:
return NULL;
}
OpenAPI_internal_group_id_range_t *OpenAPI_internal_group_id_range_copy(OpenAPI_internal_group_id_range_t *dst, OpenAPI_internal_group_id_range_t *src)
{
cJSON *item = NULL;
char *content = NULL;
ogs_assert(src);
item = OpenAPI_internal_group_id_range_convertToJSON(src);
if (!item) {
ogs_error("OpenAPI_internal_group_id_range_convertToJSON() failed");
return NULL;
}
content = cJSON_Print(item);
cJSON_Delete(item);
if (!content) {
ogs_error("cJSON_Print() failed");
return NULL;
}
item = cJSON_Parse(content);
ogs_free(content);
if (!item) {
ogs_error("cJSON_Parse() failed");
return NULL;
}
OpenAPI_internal_group_id_range_free(dst);
dst = OpenAPI_internal_group_id_range_parseFromJSON(item);
cJSON_Delete(item);
return dst;
}
|
/***************************************************************************
* *
* This file is part of DSOrganize. *
* *
* DSOrganize 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. *
* *
* DSOrganize 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 DSOrganize. If not, see <http://www.gnu.org/licenses/>. *
* *
***************************************************************************/
#ifndef _DATABASE_INCLUDED
#define _DATABASE_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
#define DB_DISCONNECTED 0
#define DB_CONNECTING 1
#define DB_CONNECTED 2
#define DB_FAILEDCONNECT 3
#define DB_RECIEVEDLIST 4
#define DB_GETLIST 6
#define DB_GETPACKAGE 7
#define DB_RECIEVEDPACKAGE 8
#define DB_GETTINGMOTD 9
#define DB_GETTINGLIST 10
#define DB_GETTINGPACKAGE 11
#define DB_FAILEDPACKAGE 12
#define DB_GETTINGFILE 13
#define MOTD_SIZE 2048
#define LIST_SIZE 100000
#define PACKAGE_SIZE 4096
#define URL_SIZE 512
#define TIMEOUT 180
#define RETRIES 3
#define CHDR 0
#define MKDR 1
#define DOWN 2
#define DELE 3
#define CLS 4
#define ECHO 5
#define WAIT 6
#define ENCODING_RAW 0
#define ENCODING_DEFLATE 1
#define ENCODING_GZIP 2
#define DECODE_CHUNK (32*1024)
#define DOWN_SIZE 8192 // 8kb recieve
typedef struct
{
char category[33];
} CAT_LIST;
typedef struct
{
int command;
char instruction[256];
} INST_LIST;
typedef struct
{
char name[31];
char description[101];
char dataURL[65];
char date[11];
char version[11];
char size[11];
char category[33];
} HB_LIST;
void initDatabase();
void customDB(char *str);
void customPackage(char *str);
void freeWifiMem();
// for webbrowser
void getFile(char *url, char *uAgent);
void checkFile();
void resetRCount();
void cancelDownload();
int getLastCharset();
int getLastContentType();
void setPostData(char *toPost);
void setReferrer(char *toRefer);
void setContentType(int ct);
bool isDownloading();
char *getDownStatus();
void runSpeed();
int getDownloadRatio(int max);
#ifdef __cplusplus
}
#endif
#endif
|
/*
* Copyright (c) 2012 Vladimir Serbinenko
*
* This file is part of the libisofs project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* or later as published by the Free Software Foundation.
* See COPYING file for details.
*/
/**
* Declare HFS+ related structures.
*/
#ifndef LIBISO_HFSPLUS_H
#define LIBISO_HFSPLUS_H
#include "libisofs.h"
#include "ecma119.h"
#define LIBISO_HFSPLUS_NAME_MAX 255
enum hfsplus_node_type {
HFSPLUS_DIR = 1,
HFSPLUS_FILE = 2,
HFSPLUS_DIR_THREAD = 3,
HFSPLUS_FILE_THREAD = 4
};
struct hfsplus_btree_node
{
uint32_t start;
uint32_t cnt;
uint32_t strlen;
uint16_t *str;
uint32_t parent_id;
};
struct hfsplus_btree_level
{
uint32_t level_size;
struct hfsplus_btree_node *nodes;
};
struct hfsplus_node
{
/* Note: .type HFSPLUS_DIR_THREAD and HFSPLUS_FILE_THREAD do not own their
.name and .cmp_name. They have copies of others, if ever.
*/
uint16_t *name; /* Name in UTF-16BE, decomposed. */
uint16_t *cmp_name; /* Name used for comparing. */
IsoNode *node; /*< reference to the iso node */
enum { UNIX_NONE, UNIX_SYMLINK, UNIX_SPECIAL } unix_type;
uint32_t symlink_block;
char *symlink_dest;
enum hfsplus_node_type type;
IsoFileSrc *file;
uint32_t cat_id;
uint32_t parent_id;
uint32_t nchildren;
uint32_t strlen;
uint32_t used_size;
};
int hfsplus_writer_create(Ecma119Image *target);
int hfsplus_tail_writer_create(Ecma119Image *target);
struct hfsplus_extent
{
/* The first block of a file on disk. */
uint32_t start;
/* The amount of blocks described by this extent. */
uint32_t count;
} __attribute__ ((packed));
struct hfsplus_forkdata
{
uint64_t size;
uint32_t clumpsize;
uint32_t blocks;
struct hfsplus_extent extents[8];
} __attribute__ ((packed));
struct hfsplus_volheader
{
uint16_t magic;
uint16_t version;
uint32_t attributes;
uint32_t last_mounted_version;
uint32_t journal;
uint32_t ctime;
uint32_t utime;
uint32_t backup_time;
uint32_t fsck_time;
uint32_t file_count;
uint32_t folder_count;
uint32_t blksize;
uint32_t total_blocks;
uint32_t free_blocks;
uint32_t next_allocation;
uint32_t rsrc_clumpsize;
uint32_t data_clumpsize;
uint32_t catalog_node_id;
uint32_t write_count;
uint64_t encodings_bitmap;
uint32_t ppc_bootdir;
uint32_t intel_bootfile;
/* Folder opened when disk is mounted. */
uint32_t showfolder;
uint32_t os9folder;
uint32_t unused;
uint32_t osxfolder;
uint64_t num_serial;
struct hfsplus_forkdata allocations_file;
struct hfsplus_forkdata extents_file;
struct hfsplus_forkdata catalog_file;
struct hfsplus_forkdata attrib_file;
struct hfsplus_forkdata startup_file;
} __attribute__ ((packed));
struct hfsplus_btnode
{
uint32_t next;
uint32_t prev;
int8_t type;
uint8_t height;
uint16_t count;
uint16_t unused;
} __attribute__ ((packed));
/* The header of a HFS+ B+ Tree. */
struct hfsplus_btheader
{
uint16_t depth;
uint32_t root;
uint32_t leaf_records;
uint32_t first_leaf_node;
uint32_t last_leaf_node;
uint16_t nodesize;
uint16_t keysize;
uint32_t total_nodes;
uint32_t free_nodes;
uint16_t reserved1;
uint32_t clump_size;
uint8_t btree_type;
uint8_t key_compare;
uint32_t attributes;
uint32_t reserved[16];
} __attribute__ ((packed));
struct hfsplus_catfile_thread
{
uint16_t type;
uint16_t reserved;
uint32_t parentid;
uint16_t namelen;
} __attribute__ ((packed));
struct hfsplus_catfile_common
{
uint16_t type;
uint16_t flags;
uint32_t valence; /* for files: reserved. */
uint32_t fileid;
uint32_t ctime;
uint32_t mtime;
uint32_t attr_mtime;
uint32_t atime;
uint32_t backup_time;
uint32_t uid;
uint32_t gid;
uint8_t user_flags;
uint8_t group_flags;
uint16_t mode;
uint32_t special;
uint8_t file_type[4]; /* For folders: window size */
uint8_t file_creator[4]; /* For folders: window size */
uint8_t finder_info[24];
uint32_t text_encoding;
uint32_t reserved;
} __attribute__ ((packed));
#define HFSPLUS_MAX_DECOMPOSE_LEN 4
extern uint16_t (*hfsplus_decompose_pages[256])[HFSPLUS_MAX_DECOMPOSE_LEN + 1];
void make_hfsplus_decompose_pages();
extern uint16_t *hfsplus_class_pages[256];
void make_hfsplus_class_pages();
extern const uint16_t hfsplus_casefold[];
#endif /* LIBISO_HFSPLUS_H */
|
/*
* scroll-extension.c
*
* Copyright (C) 2017 - 2018 Fabio Colacio
*
* Marker is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* Marker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with Marker; see the file LICENSE.md. If not,
* see <http://www.gnu.org/licenses/>.
*
*/
#include <string.h>
#include <math.h>
#include "scroll-extension.h"
#define TAG "cursor_pos"
/**TODO: Clear user_data when closing window.
* I did not found any signal to connect
* to a cleaning function!
**/
static void
document_loaded_cb (WebKitWebPage *web_page,
gpointer user_data)
{
WebKitDOMDocument *document = webkit_web_page_get_dom_document (web_page);
WebKitDOMElement *posmarker = webkit_dom_document_get_element_by_id(document, TAG);
if (posmarker){
webkit_dom_element_scroll_into_view(posmarker, FALSE);
}
}
static gboolean
send_request_cb (WebKitWebPage *web_page,
WebKitURIRequest *request,
WebKitURIResponse *redirected_response,
gpointer user_data)
{
WebKitDOMDocument *document = webkit_web_page_get_dom_document (web_page);
WebKitDOMElement *posmarker = webkit_dom_document_get_element_by_id(document, TAG);
if (posmarker){
webkit_dom_element_scroll_into_view(posmarker, FALSE);
}
return TRUE;
}
static void
page_created_cb (WebKitWebExtension *extension,
WebKitWebPage *web_page,
gpointer user_data)
{
/** create a new position index for each thread.**/
g_signal_connect (web_page, "document-loaded",
G_CALLBACK (document_loaded_cb),
0);
/** g_signal_connect (web_page, "send-request",
*G_CALLBACK (send_request_cb),
* 0); **/
}
G_MODULE_EXPORT void
webkit_web_extension_initialize (WebKitWebExtension *extension)
{
g_print("scroll 2.0 extension initialized\n");
g_signal_connect (extension, "page-created",
G_CALLBACK (page_created_cb),
NULL);
}
|
/*
* Copyright (C) 2015 Florent Pouthier
* Copyright (C) 2015 Emmanuel Pouthier
*
* This file is part of SIGMAE.
*
* Aye-Aye 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.
*
* Aye-Aye 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/>.
*/
/* ft2.ladspa.c
noise spreaded using the frequency of your choice;
with rectangular, linear, or cossine interpolation
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "ladspa.h"
#define FT_PNB 8
#define FT_IA_INP0 0
#define FT_IC_FREQ0 1
#define FT_IC_FREQ1 2
#define FT_IC_VAR0 3
#define FT_IC_VAR1 4
#define FT_IC_SVAR0 5
#define FT_IC_SVAR1 6
#define FT_OA_OUT0 7
#define RANDOM() (random() / (float)RAND_MAX)
#define FTST(h) ((struct FT_ST*)h)
#define TSZ 256
static float table[TSZ+1];
void fill_table() __attribute__ ((constructor));
void fill_table()
{
int i = 0;
table[TSZ] = 0.;
for(i = 0; i < TSZ; i++) {
table[i] = powf(sinf(i / (double)TSZ * 2. * M_PI), .5);
}
}
struct FT_ST {
LADSPA_Data *ports[FT_PNB];
LADSPA_Data a, b, c, d;
LADSPA_Data r1, r2, r3, r4, r5, r6, r7, r8;
double p0, p1;
double sum;
double sr;
};
LADSPA_Handle ft_make(const LADSPA_Descriptor *desc, unsigned long sr) {
struct FT_ST *h = (struct FT_ST*)malloc(sizeof(struct FT_ST));
h->p0 = 0.;
h->p1 = 0.;
h->r1 = 0.;
h->r2 = 0.;
h->r3 = 0.;
h->r4 = 0.;
h->r5 = 0.;
h->r6 = 0.;
h->r7 = 0.;
h->r8 = 0.;
h->sum = 0.;
h->sr = sr;
return h;
}
void ft_connect(LADSPA_Handle h, unsigned long p, LADSPA_Data *buff) {
FTST(h)->ports[p] = buff;
}
void ft_activate(LADSPA_Handle h) {
FTST(h)->d = 1.f/44100.f;
FTST(h)->r1 = 0.f;
}
void ft_run(LADSPA_Handle h, unsigned long sc)
{
LADSPA_Data *ibuff0 = FTST(h)->ports[FT_IA_INP0];
LADSPA_Data freq0 = *FTST(h)->ports[FT_IC_FREQ0];
LADSPA_Data freq1 = *FTST(h)->ports[FT_IC_FREQ1];
LADSPA_Data var0 = *FTST(h)->ports[FT_IC_VAR0];
LADSPA_Data var1 = *FTST(h)->ports[FT_IC_VAR1];
LADSPA_Data svar0 = *FTST(h)->ports[FT_IC_SVAR0];
LADSPA_Data svar1 = *FTST(h)->ports[FT_IC_SVAR1];
LADSPA_Data *obuff0 = FTST(h)->ports[FT_OA_OUT0];
LADSPA_Data a = FTST(h)->a;
LADSPA_Data b = FTST(h)->b;
LADSPA_Data c = FTST(h)->c;
LADSPA_Data d = FTST(h)->d;
LADSPA_Data r1 = FTST(h)->r1;
LADSPA_Data r2 = FTST(h)->r2;
LADSPA_Data r3 = FTST(h)->r3;
LADSPA_Data r4 = FTST(h)->r4;
LADSPA_Data r5 = FTST(h)->r5;
LADSPA_Data r6 = FTST(h)->r6;
LADSPA_Data r7 = FTST(h)->r7;
LADSPA_Data r8 = FTST(h)->r8;
LADSPA_Data p0 = FTST(h)->p0;
LADSPA_Data p1 = FTST(h)->p1;
double sum = FTST(h)->sum;
double in;
double sr = FTST(h)->sr;
unsigned int i, j;
a = d / (svar0 + d);
for (i = 0; i < sc; i++) {
in = ibuff0[i];
/*
j = (unsigned int)(p0);
r2 = p0 - (float)j;
r1 = table[j] * (1. - r2) + table[j+1] * r2;
p0 = fmod(p0 += freq0 / sr * (double)TSZ, (double)TSZ);
*/
r1 = table[(unsigned int)(RANDOM() * TSZ)];
/* low pass filter
r1 = a * in + (1.f - a) * r1;
*/
obuff0[i] = r1;
}
FTST(h)->sum = sum;
FTST(h)->a = a;
FTST(h)->b = b;
FTST(h)->c = c;
FTST(h)->d = d;
FTST(h)->r1 = r1;
FTST(h)->r2 = r2;
FTST(h)->r3 = r3;
FTST(h)->r4 = r4;
FTST(h)->r5 = r5;
FTST(h)->r6 = r6;
FTST(h)->r7 = r7;
FTST(h)->r8 = r8;
FTST(h)->p0 = p0;
FTST(h)->p1 = p1;
}
void ft_run_adding(LADSPA_Handle h, unsigned long sc) {}
void ft_set_run_adding_gain(LADSPA_Handle h, LADSPA_Data gain) {}
void ft_deactivate(LADSPA_Handle h) {}
void ft_cleanup(LADSPA_Handle h) {}
static const char const *ft_ports_names[] = {
"input0",
"frequency 1",
"frequency 2",
"variable A",
"variable B",
"variable C",
"variable D",
"output0"
};
static const LADSPA_PortDescriptor ft_ports[] = {
LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO,
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL,
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL,
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL,
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL,
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL,
LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL,
LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO
};
static const LADSPA_PortRangeHint ft_hints[] = {
{0, 0, 0},
{LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_LOGARITHMIC |
LADSPA_HINT_SAMPLE_RATE |
LADSPA_HINT_DEFAULT_440,
0., 1.},
{LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_LOGARITHMIC |
LADSPA_HINT_SAMPLE_RATE |
LADSPA_HINT_DEFAULT_440,
0., .5},
{LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_0,
0., 1.},
{LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_0,
0., 1.},
{LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_0,
-1., 1.},
{LADSPA_HINT_BOUNDED_BELOW |
LADSPA_HINT_BOUNDED_ABOVE |
LADSPA_HINT_DEFAULT_0,
-1., 1.},
{0, 0, 0}
};
static const LADSPA_Descriptor ft_pl_desc = {
9990,
"ftest",
LADSPA_PROPERTY_REALTIME |
LADSPA_PROPERTY_HARD_RT_CAPABLE,
"AATK - Filter Test",
"MrAmp",
"",
FT_PNB,
ft_ports,
ft_ports_names,
ft_hints,
(void*)0,
ft_make,
ft_connect,
ft_activate,
ft_run,
ft_run_adding,
ft_set_run_adding_gain,
ft_deactivate,
ft_cleanup
};
const LADSPA_Descriptor *ladspa_descriptor(unsigned long index)
{
if (index == 0)
return &ft_pl_desc;
return NULL;
}
|
#ifndef __CRIS_MMU_CONTEXT_H
#define __CRIS_MMU_CONTEXT_H
#include <asm-generic/mm_hooks.h>
extern int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
extern void get_mmu_context(struct mm_struct *mm);
extern void destroy_context(struct mm_struct *mm);
extern void switch_mm(struct mm_struct *prev, struct mm_struct *next,
struct task_struct *tsk);
#define deactivate_mm(tsk,mm) do { } while (0)
static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
{
unsigned long flags;
local_irq_save(flags);
switch_mm(prev, next, NULL);
local_irq_restore(flags);
}
/* current active pgd - this is similar to other processors pgd
* registers like cr3 on the i386
*/
/* defined in arch/cris/mm/fault.c */
DECLARE_PER_CPU(pgd_t *, current_pgd);
static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
{
}
#endif
|
/*
* androlirc.c
*
* Interface between Lirc functions and Android
*
* Copyright (C) 2010 Zokama <contact@zokama.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/>.
*
*/
#include <string.h>
#include <jni.h>
#include <android/log.h>
#include <stdio.h>
#include "lirc/config.h"
#include "lirc/daemons/config_file.h"
#include "lirc/daemons/ir_remote.h"
#include "lirc/daemons/transmit.h"
#define SAMPLERATE 48000
#define PI 3.141592654
/* Global variable */
struct ir_remote *devices;
int initialized;
int read_config_file(char * config_file)
{
if(initialized) return 1;
FILE *fd;
fd=fopen(config_file, "r");
char msg[255];
if(fd==NULL)
{
sprintf(msg, "could not open config file '%s'", config_file);
ZLOG_INFO(msg);
return 0;
}
devices=read_config(fd, config_file);
fclose(fd);
if(devices==(void *) -1)
{
ZLOG_INFO("reading of config file failed");
return 0;
}
else
{
ZLOG_INFO("config file read");
}
if(devices==NULL)
{
ZLOG_INFO("config file contains no valid remote control definition");
return 0;
}
initialized = 1;
return 1;
}
jint Java_com_zokama_androlirc_Lirc_parse( JNIEnv* env, jobject thiz, jstring filename)
{
char * config_file = (char *)(*env)->GetStringUTFChars(env, filename, NULL);
initialized = 0;
if (!read_config_file(config_file)) return 0;
else return 1;
}
jobjectArray Java_com_zokama_androlirc_Lirc_getDeviceList( JNIEnv* env, jobject thiz)
{
if (!read_config_file(LIRCDCFGFILE)) return NULL;
jstring str = NULL;
jclass strCls = (*env)->FindClass(env,"java/lang/String");
if (strCls == NULL)
{
return;
}
int i, device_count=0;
char msg[255];
struct ir_remote *all;
all=devices;
while(all)
{
all=all->next;
device_count++;
}
sprintf(msg, "Device count: %d", device_count);
ZLOG_INFO(msg);
jobjectArray result = (*env)->NewObjectArray(env,device_count,strCls,NULL);
if (result == NULL)
{
return;
}
all=devices;
i=0;
while(all)
{
if(all->name==NULL)
return NULL;
str = (*env)->NewStringUTF(env,all->name);
(*env)->SetObjectArrayElement(env,result,i++,str);
(*env)->DeleteLocalRef(env,str);
all=all->next;
}
return result;
}
jobjectArray Java_com_zokama_androlirc_Lirc_getCommandList( JNIEnv* env, jobject thiz, jstring dev)
{
char * remote_name = (char *)(*env)->GetStringUTFChars(env, dev, NULL);
struct ir_remote * remote = get_ir_remote(devices, remote_name);
jstring str = NULL;
jclass strCls = (*env)->FindClass(env,"java/lang/String");
if (strCls == NULL)
{
return;
}
int i, command_count=0;
char msg[255];
struct ir_ncode *all;
all=remote->codes;
while(all->name!=NULL)
{
command_count++;
all++;
}
sprintf(msg, "Command count: %d", command_count);
ZLOG_INFO(msg);
jobjectArray result = (*env)->NewObjectArray(env,command_count,strCls,NULL);
if (result == NULL)
{
return;
}
for(i=0;i<command_count;i++)
{
str = (*env)->NewStringUTF(env,remote->codes[i].name);
(*env)->SetObjectArrayElement(env,result,i,str);
(*env)->DeleteLocalRef(env,str);
}
return result;
}
jintArray Java_com_zokama_androlirc_Lirc_getIrBuffer( JNIEnv* env, jobject thiz,
jstring dev, jstring cmd, jint min_buf_size)
{
/* variables */
char * remote_name = (char *)(*env)->GetStringUTFChars(env, dev, NULL);
char * code_name = (char *)(*env)->GetStringUTFChars(env, cmd, NULL);
int length;
lirc_t* signals;
jbyteArray result;
lirc_t freq;
char msg[255];
/* Check config */
if(!read_config_file(LIRCDCFGFILE)) return 0;
/* Prepare send - using lirc/daemons/transmit.h*/
struct ir_remote * remote = get_ir_remote(devices, remote_name);
struct ir_ncode * code = get_code_by_name(remote, code_name);
if(!init_send(remote, code))
return NULL;
length = send_buffer.wptr;
signals = send_buffer.data;
if (length <= 0 || signals == NULL)
{
ZLOG_INFO("nothing to send");
return NULL;
}
/*carrier frequency */
freq = remote->freq ? remote->freq : DEFAULT_FREQ;
sprintf(msg, "Using carrier frequency %i", freq);
ZLOG_INFO(msg);
/* Generate audio buffer - Derived from lirc/daemons/hw_audio.c */
int i, j=0, signalPhase=0, carrierPos=0, out;
int currentSignal=0;
unsigned char outptr[SAMPLERATE*5];
/* Insert space before the ir code */
for(j=0; j<5000; j++)
{
outptr[j] = 128;
}
for(i = 0; i<length; i++)
{
/* invert the phase */
signalPhase = signalPhase ? 0 : 1;
for(currentSignal=signals[i]; currentSignal>0;
currentSignal -= 1000000.0 / SAMPLERATE)
{
if (signalPhase)
{
/* write carrier */
out = rint(sin(carrierPos / (180.0 / PI)) * 127.0 + 128.0);
}
else
{
out = 128;
}
/* one channel is inverted, so both channels
can be used to double the voltage */
outptr[j++] = out;
outptr[j++] = 256 - out;
/* increase carrier position */
/* carrier frequency is halved */
carrierPos += (double)freq / SAMPLERATE * 360.0 / 2.0;
if (carrierPos >= 360.0)
carrierPos -= 360.0;
}
}
/* Fill with space if buffer is too small */
if (j < min_buf_size)
{
for (j; j<min_buf_size; j++)
{
outptr[j] = 128;
sprintf(msg, "filling buffer: %d/%d",j, min_buf_size);
ZLOG_INFO(msg);
}
}
sprintf(msg, "Buffer size: %d bytes (min: %d)",j, min_buf_size);
ZLOG_INFO(msg);
/* Return audio buffer*/
result = (*env)->NewByteArray(env, j);
if (result == NULL)
{
return NULL;
}
(*env)->SetByteArrayRegion(env, result, 0, j, outptr);
return result;
}
|
/*
* Register.h
*
* Created on: 2016. 12. 9.
* Author: ygcho
*/
#ifndef INC_REGISTER_H_
#define INC_REGISTER_H_
#include "ctocpp.h"
enum
{
SP = 13,
LR,
PC,
psrN = 0,
psrZ,
psrC,
psrV,
REG_SIZE = 16,
PSR_SIZE = 4,
};
class Register
{
public :
Register()
{
throwBit = 0;
throwAddr = 0;
PCdirectChange = 0;
}
static Register* getInstance() { return ®Inst; }
uint32_t R[REG_SIZE];
uint32_t PSR[PSR_SIZE];
void init();
uint32_t regRead(uint8_t index);
void regWrite(uint8_t index, uint32_t val);
void pcWrite(uint32_t addr);
//for Branch instruction
void throwPC(uint32_t addr);
void updatePC(uint8_t instLength);
//ADD, MOV instruction change PC
void changePC();
uint8_t checkCond(uint8_t cond);
private :
static Register regInst;
//for branch instruction's PC register handle.
uint8_t throwBit;
uint32_t throwAddr;
uint8_t throwCheck();
//for ADD, MOV instruction's PC register handle.
uint8_t PCdirectChange;
uint8_t changePCCheck();
};
#endif /* INC_REGISTER_H_ */
|
/*
* Copyright (C) 2020 Niek Linnenbank
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __LIB_LIBRUNTIME_CORECLIENT_H
#define __LIB_LIBRUNTIME_CORECLIENT_H
#include <FreeNOS/API/ProcessID.h>
#include <Types.h>
#include "Core.h"
struct CoreMessage;
/**
* @addtogroup lib
* @{
*
* @addtogroup libruntime
* @{
*/
/**
* CoreClient provides a simple interface to a CoreServer.
*
* @see CoreServer
*/
class CoreClient
{
public:
/**
* Class constructor function.
*
* @param pid Optional ProcessID of the CoreServer.
*/
CoreClient(const ProcessID pid = CORESRV_PID);
/**
* Get number of processor cores in the system.
*
* @param numCores On output, contains the number of processor cores.
*
* @return Result code
*/
Core::Result getCoreCount(Size &numCores) const;
/**
* Create a new process on a different core.
*
* @param coreId Specifies the core on which the process will be created.
* @param programAddr Virtual address of the loaded program to start.
* @param programSize Size of the loaded program in bytes.
* @param programCmd Command-line string for starting the program.
*
* @return Result code
*/
Core::Result createProcess(const Size coreId,
const Address programAddr,
const Size programSize,
const char *programCmd) const;
private:
/**
* Send an IPC request to the CoreServer
*
* @param msg Reference to the CoreMessage to send
*
* @return Result code
*/
Core::Result request(CoreMessage &msg) const;
private:
/** ProcessID of the CoreServer */
const ProcessID m_pid;
};
/**
* @}
* @}
*/
#endif /* __LIB_LIBRUNTIME_CORECLIENT_H */
|
/*
* This file was generated by orbit-idl-2 - DO NOT EDIT!
*/
#include <string.h>
#define ORBIT2_STUBS_API
#include "poatest.h"
static ORBitSmallSkeleton get_skel_small_poatest(POA_poatest *servant,
const char *opname,gpointer *m_data, gpointer *impl)
{
switch(opname[0]) {
case 't':
if(strcmp((opname + 1), "est")) break;
*impl = (gpointer)servant->vepv->poatest_epv->test;
{ORBit_IInterface *volatile _t_=&poatest__iinterface;*m_data = (gpointer)&_t_->methods._buffer [0];}
return (ORBitSmallSkeleton)_ORBIT_skel_small_poatest_test;
break;
default: break;
}
return NULL;
}
void POA_poatest__init(PortableServer_Servant servant,
CORBA_Environment *env)
{
static PortableServer_ClassInfo class_info = {NULL, (ORBit_small_impl_finder)&get_skel_small_poatest, "IDL:poatest:1.0", &poatest__classid, NULL, &poatest__iinterface};
PortableServer_ServantBase__init ( ((PortableServer_ServantBase *)servant), env);
ORBit_skel_class_register (&class_info,
(PortableServer_ServantBase *)servant, POA_poatest__fini,
ORBIT_VEPV_OFFSET (POA_poatest__vepv, poatest_epv),
(CORBA_unsigned_long) 0);}
void POA_poatest__fini(PortableServer_Servant servant,
CORBA_Environment *env)
{
PortableServer_ServantBase__fini(servant, env);
}
|
#ifndef FILESCOMBOBOXMODEL_H
#define FILESCOMBOBOXMODEL_H
#include "datahash.h"
#include <QAbstractItemModel>
#include <vector>
class FilesComboBoxModel : public QAbstractItemModel
{
public:
class Item {
public:
const QString path;
const QString id;
const DataHash hash;
Item(const QString &path, const QString &id, const DataHash &hash) :
path(path),
id(id),
hash(hash)
{}
Item(const Item &other) :
path(other.path),
id(other.id),
hash(other.hash)
{}
Item(Item &&other) noexcept :
path(std::move(other.path)),
id(std::move(other.id)),
hash(std::move(other.hash))
{}
Item & operator=(const Item &other)
{
const_cast<QString&>(path) = other.path;
const_cast<QString&>(id) = other.id;
const_cast<DataHash&>(hash) = other.hash;
return *this;
}
Item & operator=(Item &&other) noexcept
{
const_cast<QString&>(path) = std::move(other.path);
const_cast<QString&>(id) = std::move(other.id);
const_cast<DataHash&>(hash) = std::move(other.hash);
return *this;
}
bool operator==(const Item &other) const noexcept
{
return (path == other.path) &&
(id == other.id) &&
(hash == other.hash);
}
bool operator!=(const Item &other) const noexcept
{
return !(*this == other);
}
};
explicit FilesComboBoxModel()
{
}
void clear()
{
beginRemoveRows(QModelIndex(), 0, m_items.size());
this->m_items.clear();
endRemoveRows();
}
int columnCount(const QModelIndex &parent = QModelIndex()) const override
{
Q_UNUSED(parent);
return 1;
}
bool appendEntry(const Item &item)
{
bool ret = true;
beginInsertRows(QModelIndex(), m_items.size(), m_items.size());
try {
this->m_items.emplace_back(item);
} catch (std::bad_alloc&) {
ret = false;
}
endInsertRows();
return ret;
}
bool appendEntry(Item &&item)
{
bool ret = true;
beginInsertRows(QModelIndex(), m_items.size(), m_items.size());
try {
this->m_items.emplace_back(item);
} catch (std::bad_alloc&) {
ret = false;
}
endInsertRows();
return ret;
}
void deleteByIdx(const int idx)
{
const size_t uidx = static_cast<size_t>(idx);
if (idx < 0 || uidx >= m_items.size())
return;
beginRemoveRows(QModelIndex(), idx, m_items.size());
m_items.erase(m_items.begin() + uidx);
endRemoveRows();
}
int indexByHash(const DataHash &hash)
{
for (size_t idx = 0; idx < m_items.size(); idx++) {
if (m_items.at(idx).hash == hash)
return idx;
}
return -1;
}
int indexByItem(const Item &item)
{
for (size_t idx = 0; idx < m_items.size(); idx++) {
if (m_items.at(idx) == item)
return idx;
}
return -1;
}
QVariant data(const QModelIndex &index, int role) const override
{
if (!isIndexValid(index))
return {};
const auto &item = m_items.at(index.row());
switch (role) {
case Qt::DisplayRole:
if (item.id.length() > 0)
return QString("%1 [%2]").arg(item.path).arg(item.id);
return item.path;
case Qt::UserRole + 1:
return QVariant::fromValue<DataHash>(item.hash);
}
return {};
}
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override
{
Q_UNUSED(parent);
return createIndex(row, column);
}
QModelIndex parent(const QModelIndex &child) const override
{
Q_UNUSED(child);
return QModelIndex();
}
int rowCount(const QModelIndex &parent = QModelIndex()) const override
{
Q_UNUSED(parent);
return m_items.size();
}
private:
bool isIndexValid(const QModelIndex &index) const
{
if (!index.isValid())
return false;
if (index.row() < 0)
return false;
return !(static_cast<size_t>(index.row()) >= m_items.size() || index.column() > 0 || index.column() < 0);
}
std::vector<Item> m_items;
};
#endif // FILESCOMBOBOXMODEL_H
|
#pragma once
#include "USART_BitNames.h"
#define USART_Baud_to_UBRR(BAUD) (rounddiv(F_CPU, (BAUD)*16UL) - 1)
|
/**********************************************************************
****** GNU GPL ********************************************************
Copyright 2011 Pierre Gradot
This file is part of DiskDB.
DiskDB 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.
Foobar 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
***********************************************************************/
#ifndef MY_WELCOME_TAB_H
#define MY_WELCOME_TAB_H
#include <QApplication>
#include <QGridLayout>
#include <QLabel>
#include <QLCDNumber>
#include <QWidget>
class MyWelcomeTab : public QWidget // un onglet d'un QTabWidget doit heriter de QWidget
{
Q_OBJECT // pour le slot personnalise Mise a jour LCD
public:
// constructeur par defaut
MyWelcomeTab();
public slots:
void majLCDNombreDisques(int);
private:
QLCDNumber *LCDNombreDisques;
};
#endif
|
#include "kheap.h"
#include "physmem.h"
#include "console.h"
unsigned int * kheap;
unsigned int * kheap_top;
extern unsigned int * kernel_end;
void kheap_init() {
kheap_top = (unsigned int *) pmm_get_memory_size();
kheap = kheap_top - KHEAP_SIZE;
pmm_remove_memory_region((unsigned int)kheap, (unsigned int)kheap_top);
printk("Kernel heap: 0x%x-0x%x\n", kheap, kheap_top);
}
void * kmalloc(unsigned int n) {
if(n == 0) {
return 0;
} else {
if(kheap + n > kheap_top) {
panic("Uh, oh, no more heap!");
}
unsigned int * retval = kheap;
kheap += n;
return retval;
}
}
|
/**
* This file is part of Arglyzer.
*
* Copyright (c) 2015 Juan Jose Salazar Garcia jjslzgc@gmail.com
*
* Arglyzer 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.
*
* Arglyzer 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 Arglyzer. If not, see <http://www.gnu.org/licenses/>.
*
**/
#include "result.h"
#include "option.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
ResultPtr create_result(OptionsListPtr options_list, int max_args)
{
if(max_args <= 0)
return NULL;
ResultPtr result = (ResultPtr) malloc(sizeof(Result));
result -> options = options_list;
result -> params = (char **) malloc(sizeof(char *) * (max_args + 1));
memset(result -> params, 0, max_args + 1);
return result;
}
int print_result(ResultPtr result)
{
if(result == NULL)
return 1;
if(result -> options == NULL)
return 2;
OptionPtr opt_ptr;
for(opt_ptr = result -> options -> lh_first; opt_ptr != NULL; opt_ptr = opt_ptr -> entries.le_next)
print_option(opt_ptr);
char **params_ptr;
for(params_ptr = result -> params; *params_ptr != NULL; ++params_ptr)
printf("Param[%d] : %s\n", params_ptr - result -> params, *params_ptr);
return 0;
}
int free_result(ResultPtr result)
{
if(result == NULL)
return 1;
char **params_ptr;
for(params_ptr = result -> params; *params_ptr != NULL; ++params_ptr)
free(*params_ptr);
free(result -> params);
free(result);
return 0;
}
|
/*
ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
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.
*/
/**
* @file nilconf.h
* @brief Configuration file template.
* @details A copy of this file must be placed in each project directory, it
* contains the application specific kernel settings.
*
* @addtogroup config
* @details Kernel related settings and hooks.
* @{
*/
#ifndef _NILCONF_H_
#define _NILCONF_H_
/*===========================================================================*/
/**
* @name Kernel parameters and options
* @{
*/
/*===========================================================================*/
/**
* @brief Number of user threads in the application.
* @note This number is not inclusive of the idle thread which is
* Implicitly handled.
*/
#define NIL_CFG_NUM_THREADS 3
/** @} */
/*===========================================================================*/
/**
* @name System timer settings
* @{
*/
/*===========================================================================*/
/**
* @brief System time counter resolution.
* @note Allowed values are 16 or 32 bits.
*/
#define NIL_CFG_ST_RESOLUTION 32
/**
* @brief System tick frequency.
* @note This value together with the @p NIL_CFG_ST_RESOLUTION
* option defines the maximum amount of time allowed for
* timeouts.
*/
#define NIL_CFG_ST_FREQUENCY 1000
/**
* @brief Time delta constant for the tick-less mode.
* @note If this value is zero then the system uses the classic
* periodic tick. This value represents the minimum number
* of ticks that is safe to specify in a timeout directive.
* The value one is not valid, timeouts are rounded up to
* this value.
*/
#define NIL_CFG_ST_TIMEDELTA 0
/** @} */
/*===========================================================================*/
/**
* @name Subsystem options
* @{
*/
/*===========================================================================*/
/**
* @brief Events Flags APIs.
* @details If enabled then the event flags APIs are included in the kernel.
*
* @note The default is @p TRUE.
*/
#define NIL_CFG_USE_EVENTS TRUE
/** @} */
/*===========================================================================*/
/**
* @name Debug options
* @{
*/
/*===========================================================================*/
/**
* @brief System assertions.
*/
#define NIL_CFG_ENABLE_ASSERTS FALSE
/**
* @brief Stack check.
*/
#define NIL_CFG_ENABLE_STACK_CHECK FALSE
/** @} */
/*===========================================================================*/
/**
* @name Kernel hooks
* @{
*/
/*===========================================================================*/
/**
* @brief System initialization hook.
*/
#if !defined(NIL_CFG_SYSTEM_INIT_HOOK) || defined(__DOXYGEN__)
#define NIL_CFG_SYSTEM_INIT_HOOK() { \
}
#endif
/**
* @brief Threads descriptor structure extension.
* @details User fields added to the end of the @p thread_t structure.
*/
#define NIL_CFG_THREAD_EXT_FIELDS \
/* Add threads custom fields here.*/
/**
* @brief Threads initialization hook.
*/
#define NIL_CFG_THREAD_EXT_INIT_HOOK(tr) { \
/* Add custom threads initialization code here.*/ \
}
/**
* @brief Idle thread enter hook.
* @note This hook is invoked within a critical zone, no OS functions
* should be invoked from here.
* @note This macro can be used to activate a power saving mode.
*/
#define NIL_CFG_IDLE_ENTER_HOOK() { \
}
/**
* @brief Idle thread leave hook.
* @note This hook is invoked within a critical zone, no OS functions
* should be invoked from here.
* @note This macro can be used to deactivate a power saving mode.
*/
#define NIL_CFG_IDLE_LEAVE_HOOK() { \
}
/**
* @brief System halt hook.
*/
#if !defined(NIL_CFG_SYSTEM_HALT_HOOK) || defined(__DOXYGEN__)
#define NIL_CFG_SYSTEM_HALT_HOOK(reason) { \
}
#endif
/** @} */
/*===========================================================================*/
/* Port-specific settings (override port settings defaulted in nilcore.h). */
/*===========================================================================*/
#endif /* _NILCONF_H_ */
/** @} */
|
/*
* traps.h: Format of entries for the Sparc trap table.
*
* Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
*/
#ifndef _UAPI_SPARC_TRAPS_H
#define _UAPI_SPARC_TRAPS_H
#define NUM_SPARC_TRAPS 255
#ifndef __ASSEMBLY__
#endif /* !(__ASSEMBLY__) */
/* For patching the trap table at boot time, we need to know how to
* form various common Sparc instructions. Thus these macros...
*/
#define SPARC_MOV_CONST_L3(const) (0xa6102000 | (const&0xfff))
/* The following assumes that the branch lies before the place we
* are branching to. This is the case for a trap vector...
* You have been warned.
*/
#define SPARC_BRANCH(dest_addr, inst_addr) \
(0x10800000 | (((dest_addr-inst_addr)>>2)&0x3fffff))
#define SPARC_RD_PSR_L0 (0xa1480000)
#define SPARC_RD_WIM_L3 (0xa7500000)
#define SPARC_NOP (0x01000000)
/* Various interesting trap levels. */
/* First, hardware traps. */
#define SP_TRAP_TFLT 0x1 /* Text fault */
#define SP_TRAP_II 0x2 /* Illegal Instruction */
#define SP_TRAP_PI 0x3 /* Privileged Instruction */
#define SP_TRAP_FPD 0x4 /* Floating Point Disabled */
#define SP_TRAP_WOVF 0x5 /* Window Overflow */
#define SP_TRAP_WUNF 0x6 /* Window Underflow */
#define SP_TRAP_MNA 0x7 /* Memory Address Unaligned */
#define SP_TRAP_FPE 0x8 /* Floating Point Exception */
#define SP_TRAP_DFLT 0x9 /* Data Fault */
#define SP_TRAP_TOF 0xa /* Tag Overflow */
#define SP_TRAP_WDOG 0xb /* Watchpoint Detected */
#define SP_TRAP_IRQ1 0x11 /* IRQ level 1 */
#define SP_TRAP_IRQ2 0x12 /* IRQ level 2 */
#define SP_TRAP_IRQ3 0x13 /* IRQ level 3 */
#define SP_TRAP_IRQ4 0x14 /* IRQ level 4 */
#define SP_TRAP_IRQ5 0x15 /* IRQ level 5 */
#define SP_TRAP_IRQ6 0x16 /* IRQ level 6 */
#define SP_TRAP_IRQ7 0x17 /* IRQ level 7 */
#define SP_TRAP_IRQ8 0x18 /* IRQ level 8 */
#define SP_TRAP_IRQ9 0x19 /* IRQ level 9 */
#define SP_TRAP_IRQ10 0x1a /* IRQ level 10 */
#define SP_TRAP_IRQ11 0x1b /* IRQ level 11 */
#define SP_TRAP_IRQ12 0x1c /* IRQ level 12 */
#define SP_TRAP_IRQ13 0x1d /* IRQ level 13 */
#define SP_TRAP_IRQ14 0x1e /* IRQ level 14 */
#define SP_TRAP_IRQ15 0x1f /* IRQ level 15 Non-maskable */
#define SP_TRAP_RACC 0x20 /* Register Access Error ??? */
#define SP_TRAP_IACC 0x21 /* Instruction Access Error */
#define SP_TRAP_CPDIS 0x24 /* Co-Processor Disabled */
#define SP_TRAP_BADFL 0x25 /* Unimplemented Flush Instruction */
#define SP_TRAP_CPEXP 0x28 /* Co-Processor Exception */
#define SP_TRAP_DACC 0x29 /* Data Access Error */
#define SP_TRAP_DIVZ 0x2a /* Divide By Zero */
#define SP_TRAP_DSTORE 0x2b /* Data Store Error ??? */
#define SP_TRAP_DMM 0x2c /* Data Access MMU Miss ??? */
#define SP_TRAP_IMM 0x3c /* Instruction Access MMU Miss ??? */
/* Now the Software Traps... */
#define SP_TRAP_SUNOS 0x80 /* SunOS System Call */
#define SP_TRAP_SBPT 0x81 /* Software Breakpoint */
#define SP_TRAP_SDIVZ 0x82 /* Software Divide-by-Zero trap */
#define SP_TRAP_FWIN 0x83 /* Flush Windows */
#define SP_TRAP_CWIN 0x84 /* Clean Windows */
#define SP_TRAP_RCHK 0x85 /* Range Check */
#define SP_TRAP_FUNA 0x86 /* Fix Unaligned Access */
#define SP_TRAP_IOWFL 0x87 /* Integer Overflow */
#define SP_TRAP_SOLARIS 0x88 /* Solaris System Call */
#define SP_TRAP_NETBSD 0x89 /* NetBSD System Call */
#define SP_TRAP_LINUX 0x90 /* Linux System Call */
/* Names used for compatibility with SunOS */
#define ST_SYSCALL 0x00
#define ST_BREAKPOINT 0x01
#define ST_DIV0 0x02
#define ST_FLUSH_WINDOWS 0x03
#define ST_CLEAN_WINDOWS 0x04
#define ST_RANGE_CHECK 0x05
#define ST_FIX_ALIGN 0x06
#define ST_INT_OVERFLOW 0x07
/* Special traps... */
#define SP_TRAP_KBPT1 0xfe /* KADB/PROM Breakpoint one */
#define SP_TRAP_KBPT2 0xff /* KADB/PROM Breakpoint two */
/* Handy Macros */
/* Is this a trap we never expect to get? */
#define BAD_TRAP_P(level) \
((level > SP_TRAP_WDOG && level < SP_TRAP_IRQ1) || \
(level > SP_TRAP_IACC && level < SP_TRAP_CPDIS) || \
(level > SP_TRAP_BADFL && level < SP_TRAP_CPEXP) || \
(level > SP_TRAP_DMM && level < SP_TRAP_IMM) || \
(level > SP_TRAP_IMM && level < SP_TRAP_SUNOS) || \
(level > SP_TRAP_LINUX && level < SP_TRAP_KBPT1))
/* Is this a Hardware trap? */
#define HW_TRAP_P(level) ((level > 0) && (level < SP_TRAP_SUNOS))
/* Is this a Software trap? */
#define SW_TRAP_P(level) ((level >= SP_TRAP_SUNOS) && (level <= SP_TRAP_KBPT2))
/* Is this a system call for some OS we know about? */
#define SCALL_TRAP_P(level) ((level == SP_TRAP_SUNOS) || \
(level == SP_TRAP_SOLARIS) || \
(level == SP_TRAP_NETBSD) || \
(level == SP_TRAP_LINUX))
#endif /* _UAPI_SPARC_TRAPS_H */
|
/*
* Copyright Droids Corporation, Microb Technology, Eirbot (2005)
*
* 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
*
* Revision : $Id: s64_to_f64.h,v 1.3.6.3 2008-05-10 15:06:27 zer0 Exp $
*
*/
#include <aversive.h>
#ifndef _S64_TO_F64_H_
#define _S64_TO_F64_H_
#if HOST_VERSION
/* not optimized, but will work with any endianness */
static inline f64 s64_to_f64(int64_t i)
{
f64 f;
f.f64_integer = ((i) >> 32);
f.f64_decimal = (i);
return f;
}
#else
/* only for AVR, faster */
static inline f64 s64_to_f64(int64_t i)
{
f64 f;
f.u.s64 = i;
return f;
}
#endif
#endif
|
#include<stdio.h>
main()
{
int i,j,p=1;
printf("Enter the number");
scanf("%d",&i);
printf("Enter the number for power");
scanf("%d",&j);
for(j=1;j<=j;j++)
{
p=i*i;
}
printf("Power is %d \n",p);
}
|
#include <stdio.h>
// #include "makeheader.h"
/******************************************************
Name : make_general_hdl
Input : n bit multiplier
Output : void
Comment: Generate verilog code for an n bit general
karatsuba multiplier
******************************************************/
void make_general_hdl(int n)
{
FILE *fd;
char buf[20];
int i,j;
sprintf(buf, "hdl/ks%d.v", n);
fd = fopen(buf, "w");
makeheader(fd, buf, "Karatsuba Multiplier", "general.c");
// Entity Declaration
fprintf(fd, "`ifndef __KS_%d_V__\n", n);
fprintf(fd, "`define __KS_%d_V__\n\n", n);
fprintf(fd, "module ks%d(a, b, d);\n\n", n);
fprintf(fd, "input wire [0:%d] a;\n", n-1);
fprintf(fd, "input wire [0:%d] b;\n", n-1);
fprintf(fd, "output wire [0:%d] d;\n\n", 2*n-2);
// Wire Declaration
fprintf(fd, "wire ");
for(i=0; i<n-1; ++i)
fprintf(fd, "m%d, ", i);
fprintf(fd, "m%d;\n", n-1);
for(i=0; i<n-1; ++i){
fprintf(fd, "wire ");
for(j=i+1; j<n-1; ++j){
fprintf(fd, "m%d_%d, ",i, j);
}
fprintf(fd, "m%d_%d;\n", i, n-1);
}
// assignments
for(i=0; i<n; ++i)
fprintf(fd, "assign m%d = a[%d] & b[%d];\n", i,i,i);
for(i=0; i<n; ++i){
for(j=i+1; j<n; ++j){
fprintf(fd, "assign m%d_%d = (a[%d] ^ a[%d]) & (b[%d] ^ b[%d]);\n",i, j, i, j, i, j);
}
}
for(i=0; i<n; ++i){
fprintf(fd, "assign d[%d] = ", i);
for(j=0; j<i; ++j){
if(j >= i-j)
continue;
fprintf(fd, "m%d_%d ^ ", j, i-j);
}
for(j=0; j<i; ++j){
fprintf(fd, "m%d ^ ", j);
}
fprintf(fd, "m%d;\n", i);
}
for(i=n; i<2*n-1; ++i){
fprintf(fd, "assign d[%d] = ", i);
for(j=i-n+1; j<i; ++j){
if(j >= i-j)
break;
fprintf(fd, "m%d_%d ^ ", j, i-j);
}
for(j=i-n+1; j<n-1; ++j){
fprintf(fd, "m%d ^ ", j);
}
fprintf(fd, "m%d;\n", n-1);
}
fprintf(fd, "endmodule\n");
fprintf(fd, "`endif\n");
close(fd);
}
|
//
// Tones and buzzer output for Pixhawk Lite
//
// Lauren Weinstein (lauren@vortex.com, http://lauren.vortex.com)
// 11/2015
//
#include "PHL_Tunes.h"
// Audio device settings, via usually
// available "borrowed" parameters
// Audio device type (e.g. piezo)
// Passive devices can play melodies, active are fixed frequency buzzers
#define PHL_TYPE "EPM_REGRAB" // 0=audio disabled,
// 15=passive device, 30=active device (buzzer)
// Any other values disable audio
// Default=0 (audio disabled)
// AUX output pin for audio device (AUX1 through 6 inclusive to enable audio)
#define PHL_PIN "EPM_GRAB" // 1100=AUX1, 1200=AUX2, 1300=AUX3, 1400=AUX4,
// 1500=AUX5, 1600=AUX6
// Any other values disable audio
// Default=1900 (audio disabled)
// Logic level for device OFF (does logic low or high silence the device?)
#define PHL_OFF_LEVEL "EPM_RELEASE" // 1500=silent at logic low
// 1600=silent at logic high
// Any other values disable audio
// Default=1100 (audio disabled)
// Select full melody/pattern signals, or only a subset
#define PHL_FULL "EPM_NEUTRAL" // 1500=full signals
// 1600=subset of signals
// 1999=tunes test
// Any other values disable audio
// Default=1500 (full signals)
/* Pixhawk Lite AUX output pins (1-6) */
#define AUX1 50
#define AUX2 51
#define AUX3 52
#define AUX4 53
#define AUX5 54
#define AUX6 55
long tempo = 50000; // overall tempo
long silnotes = 100000; // silence between notes
int pausecount = 10; // adjustment for pause length
bool passive = false; // true for passive device, false for active device (buzzer)
bool lowoff = false; // logic level OFF (true for low off, false for high off)
bool gpsinit = true; // true for gps initialization, false afterwards
bool fullsignals = false; // true for full signals, false for partial signals
bool phlaudiodisabled = false; // true for audio disabled
bool tunestest = false; // true for tunes test
int outputpin = 0; // audio output pin (AUX1 through AUX6)
int lasttune = 0; // most recent melody played
|
// //////////////////////////////////////////////////////////
// sha1.h
// Copyright (c) 2014,2015 Stephan Brumme. All rights reserved.
// see http://create.stephan-brumme.com/disclaimer.html
//
#pragma once
#include "hash.h"
#include <string>
// define fixed size integer types
#ifdef _MSC_VER
// Windows
typedef unsigned __int8 uint8_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
#else
// GCC
#include <stdint.h>
#endif
/// compute SHA1 hash
/** Usage:
SHA1 sha1;
std::string myHash = sha1("Hello World"); // std::string
std::string myHash2 = sha1("How are you", 11); // arbitrary data, 11 bytes
// or in a streaming fashion:
SHA1 sha1;
while (more data available)
sha1.add(pointer to fresh data, number of new bytes);
std::string myHash3 = sha1.getHash();
*/
class SHA1 : public Hash
{
public:
/// split into 64 byte blocks (=> 512 bits), hash is 20 bytes long
enum { BlockSize = 512 / 8, HashBytes = 20 };
/// same as reset()
SHA1();
/// compute SHA1 of a memory block
std::string operator()(const void* data, size_t numBytes);
/// compute SHA1 of a string, excluding final zero
std::string operator()(const std::string& text);
/// add arbitrary number of bytes
void add(const void* data, size_t numBytes);
/// return latest hash as 40 hex characters
std::string getHash();
/// return latest hash as bytes
void getHash(unsigned char buffer[HashBytes]);
/// restart
void reset();
private:
/// process 64 bytes
void processBlock(const void* data);
/// process everything left in the internal buffer
void processBuffer();
/// size of processed data in bytes
uint64_t m_numBytes;
/// valid bytes in m_buffer
size_t m_bufferSize;
/// bytes not processed yet
uint8_t m_buffer[BlockSize];
enum { HashValues = HashBytes / 4 };
/// hash, stored as integers
uint32_t m_hash[HashValues];
};
|
#ifndef __ENDINGTRIGGER_H__
#define __ENDINGTRIGGER_H__
#include "Trigger.h"
class EndingTrigger :
public Trigger
{
public:
EndingTrigger();
~EndingTrigger();
void Shot();
};
#endif // __ENDINGTRIGGER_H__
|
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
*/
//
// MainViewController.h
// IV-AaB-Volunteer
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#import <Cordova/CDVViewController.h>
#import <Cordova/CDVCommandDelegateImpl.h>
#import <Cordova/CDVCommandQueue.h>
@interface MainViewController : CDVViewController
@end
@interface MainCommandDelegate : CDVCommandDelegateImpl
@end
@interface MainCommandQueue : CDVCommandQueue
@end
|
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// 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.
/// \file GPUMemoryResource.h
/// \author David Rohr
#ifndef GPUMEMORYRESOURCE_H
#define GPUMEMORYRESOURCE_H
#include "GPUCommonDef.h"
#include "GPUProcessor.h"
namespace GPUCA_NAMESPACE
{
namespace gpu
{
#ifdef GPUCA_NOCOMPAT_ALLOPENCL
struct GPUMemoryReuse {
enum Type : int {
NONE = 0,
REUSE_1TO1 = 1
};
enum Group : unsigned short {
ClustererScratch
};
using ID = unsigned int;
GPUMemoryReuse(Type t, Group g, unsigned short i) : type(t), id(((int)g << 16) | ((int)i & 0xFFFF)) {}
constexpr GPUMemoryReuse() = default;
Type type = NONE;
ID id = 0;
};
#endif
class GPUMemoryResource
{
friend class GPUReconstruction;
friend class GPUReconstructionCPU;
public:
enum MemoryType {
MEMORY_HOST = 1,
MEMORY_GPU = 2,
MEMORY_INPUT_FLAG = 4,
MEMORY_INPUT = 7,
MEMORY_OUTPUT_FLAG = 8,
MEMORY_OUTPUT = 11,
MEMORY_INOUT = 15,
MEMORY_SCRATCH = 16,
MEMORY_SCRATCH_HOST = 17,
MEMORY_EXTERNAL = 32,
MEMORY_PERMANENT = 64,
MEMORY_CUSTOM = 128,
MEMORY_CUSTOM_TRANSFER = 256
};
enum AllocationType { ALLOCATION_AUTO = 0,
ALLOCATION_INDIVIDUAL = 1,
ALLOCATION_GLOBAL = 2 };
#ifndef GPUCA_GPUCODE
GPUMemoryResource(GPUProcessor* proc, void* (GPUProcessor::*setPtr)(void*), MemoryType type, const char* name = "") : mProcessor(proc), mReuse(-1), mPtr(nullptr), mPtrDevice(nullptr), mSetPointers(setPtr), mType(type), mSize(0), mName(name)
{
}
GPUMemoryResource(const GPUMemoryResource&) CON_DEFAULT;
#endif
#ifndef __OPENCL__
void* SetPointers(void* ptr)
{
return (mProcessor->*mSetPointers)(ptr);
}
void* SetDevicePointers(void* ptr) { return (mProcessor->mDeviceProcessor->*mSetPointers)(ptr); }
void* Ptr() { return mPtr; }
void* PtrDevice() { return mPtrDevice; }
size_t Size() const { return mSize; }
const char* Name() const { return mName; }
MemoryType Type() const { return mType; }
#endif
private:
GPUProcessor* mProcessor;
int mReuse;
void* mPtr;
void* mPtrDevice;
void* (GPUProcessor::*mSetPointers)(void*);
MemoryType mType;
size_t mSize;
const char* mName;
};
} // namespace gpu
} // namespace GPUCA_NAMESPACE
#endif
|
/* set_volume.c
* simple volume control using configurable interface
*/
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "set_volume_alsa.h"
#include "set_volume_mpd.h"
#include "set_volume.h"
static void update_vol_display(struct lcd_handle *lh, int cur_vol_perc)
{
uint count;
uint num_blocks = cur_vol_perc * lh->max_line_char/ 100;
char blocks[lh->max_line_char + 1];
memset(blocks, 0, (lh->max_line_char + 1) * sizeof(char));
for (count = 0; count < num_blocks; count++)
blocks[count] = 0xff;
snprintf(lh->fline_buf, lh->max_line_char, "VOLUME");
snprintf(lh->sline_buf, lh->max_line_char, blocks);
lh->fline_update = 1;
lh->sline_update = 1;
/* hold volume display for 4 cycles. Holding can only be cancelled if
* new volume is set. */
lh->wait_cycle = 4;
lh->cancel_wait = 1;
}
int init_vol_control(struct volume_handle *vh)
{
int ret = 0;
// ret = init_alsa_control(vh);
ret = init_mpd_volume(vh);
return ret;
}
int set_volume(struct volume_handle *vh)
{
int ret = 0, cur_vol_perc;
cur_vol_perc = set_mpd_volume(vh);
// ret = set_alsa_master_volume(vh);
if (cur_vol_perc >= 0)
update_vol_display(vh->mh->lh, cur_vol_perc);
return ret;
}
void close_vol_ctl(struct volume_handle *vh)
{
// close_alsa_ctl(vh);
}
|
#include "interfac.h"
#include "gp2021.h"
#include "gpsisr.h"
extern long code_ref, carrier_ref;
extern int d_freq;
int dop_sign = 1;
struct debug_struct debug_data;
int debug_ready;
struct interface_channel ichan[N_channels];
struct measurement_set measurements;
int ICP_CTL = DOP_ICP;
/* These three flags indicate that one second, one minute and one
navigation TIC has occured respectively. */
int sec_flag, min_flag, nav_flag;
/* Navigation TIC period (warning there's a few places in the code
that current depend on this being exactly 10.) */
int nav_tic = 10;
/**
* Number of search bins
*
* This should be moved to the ISR-only side, with maybe "hints" from
* the user side.
**/
int search_max_f = 5;
/* This is time of the week to decide if the input stream is sane */
unsigned long clock_tow = 0;
/* These are the ISA defaults, but will get overridden by a call to
set_gp2021_address() */
int Base_address = 0;
int Register_address = 0x304;
int Data_address = 0x308;
int data_frame_ready;
uint16_t data_message[1500];
void
gp2021_init (void)
{
io_config (0x301);
test_control (0);
system_setup (0);
reset_cntl (0x0);
reset_cntl (0x1fff);
}
void
set_TIC (long TIC_in)
{
long TIC_cntr = TIC_in;
program_TIC (TIC_cntr);
}
void
channel_init (int ch)
{
chan[ch].t_count = 0;
chan[ch].codes = 0;
chan[ch].bit_counter = 0;
chan[ch].del_freq = 1;
chan[ch].offset = 0;
ichan[ch].state = acquisition;
ichan[ch].n_frame = 0;
ichan[ch].tow_sync = 0;
ichan[ch].n_freq = 0;
ichan[ch].frame_bit = 0;
ichan[ch].CNo = 0;
ichan[ch].sfid = 0;
ichan[ch].TOW = ichan[ch].TLM = 0;
}
static void
set_PRN (int ch, int PRN)
{
const int prn_code[38] =
{ 0, 0x3f6, 0x3ec, 0x3d8, 0x3b0, 0x04b, 0x096, 0x2cb, 0x196, 0x32c,
0x3ba, 0x374, 0x1d0, 0x3a0, 0x340, 0x280, 0x100, 0x113, 0x226,
0x04c, 0x098, 0x130, 0x260, 0x267, 0x338, 0x270, 0x0e0, 0x1c0,
0x380, 0x22b, 0x056, 0x0ac, 0x158, 0x2b0, 0x058, 0x18b, 0x316, 0x058
};
const int waas_code[19] =
{ 0x2c4, 0x30a, 0x1da, 0x0b2, 0x3e3, 0x0f8, 0x25f, 0x1e7, 0x2b5,
0x22a, 0x10e, 0x12d, 0x215, 0x337, 0x0c7, 0x0e2, 0x20f, 0x3c0,
0x29 };
const int GIC_code[11] =
{ 0x2c4, 0x10a, 0x3e3, 0x0f8, 0x25f, 0x1e7, 0x2b5, 0x000, 0x10e};
ichan[ch].prn = PRN;
if ( PRN < 37 ) {
/* 0xa000 for late select satellite */
ch_cntl (ch, prn_code[PRN] | 0xa000);
}
else if ( (PRN > 119) && (PRN < 138) ) {
/* 0xa000 for late select satellite */
ch_cntl (ch, waas_code[PRN-120] | 0xa000);
}
else if ( ( PRN > 200) && (PRN < 212) ) {
/* 0xa000 for late select satellite */
ch_cntl (ch, GIC_code[PRN-201] | 0xa000);
}
else {
/* ERROR: unknown PRN */
}
}
/* XXX FIX ME XXX: Change the input to this to some standard units */
void
set_code_freq (int ch, long code_corr)
{
chan[ch].code_freq = code_ref + code_corr;
chan[ch].code_corr = code_corr;
/* 1.023 MHz chipping rate */
ch_code (ch, chan[ch].code_freq);
}
/* XXX FIX ME XXX: Change the input to this to some standard units */
void
set_carrier_freq (int ch, long carrier_corr)
{
chan[ch].carrier_freq = carrier_ref /*CARRIER_REF_FREQ */
+ carrier_corr + d_freq * ichan[ch].n_freq;
chan[ch].carrier_corr = carrier_corr;
/* select carrier */
ch_carrier (ch, chan[ch].carrier_freq);
}
void
setup_channel (int ch, int prn, long code_corr, long carrier_corr)
{
if (prn != ichan[ch].prn)
channel_off (ch);
channel_init (ch);
set_PRN (ch, prn);
set_code_freq (ch, code_corr);
set_carrier_freq (ch, carrier_corr);
ch_on (ch);
}
void
channel_off (int ch)
{
/* Re-init to flush all data */
channel_init (ch);
/* Set to PRN 0 */
set_PRN (ch, 0);
/* Set state to "off" */
ichan[ch].state = off;
}
/* Turbo C version does not currently support PCI */
#ifdef __TURBOC__
int pcifind(void) {return 0;}
#endif
int
gp2021_detect (unsigned short bldraddr)
{
extern int self_test (void);
extern int pcifind (void);
/* If the user explicitly gives a bldr2 address use it. */
if (bldraddr) {
Base_address = bldraddr;
if (self_test () != 0)
return -1;
}
else {
/* Auto-detect */
unsigned short int io_port;
/* First check for PCI card */
if ((io_port = pcifind ()) == 0) {
/* if not found assume we have an ISA interface @ 0x300 */
io_port = 0x300;
}
Register_address = io_port + 4;
Data_address = io_port + 8;
/* If the self_test fails, try Base_address = io_port, for bldr2 card */
if (self_test () != 0) {
Base_address = io_port;
if (self_test () != 0)
return -1;
}
}
return 0;
}
void
check_for_new_data (void)
{
/* Stub */
}
|
#ifndef CGIMAGEDESTINATION_H_
#define CGIMAGEDESTINATION_H_
#define CGIMAGEDESTINATION_FALLBACK 1
typedef struct CGImageDestination *CGImageDestinationRef;
#endif
|
#ifndef __VGMVGFILEREADERVGABSTRACT_H__
#define __VGMVGFILEREADERVGABSTRACT_H__
#include <vgKernel/vgkStreamReader.h>
#include <vgMod/vgFileDefinitionVG.h>
#include <vgMod/vgNode.h>
namespace vgMod{
using namespace vgCore;
/**
@action creation
@date 2009/03/04 13:38
@author lss
@brief
@see
*/
class FileReaderVGAbstract
{
public:
FileReaderVGAbstract() {}
~FileReaderVGAbstract() {}
virtual bool read( const String& open_absolute_path,
NodeAbsPtrVec* pNodeIndexList,
NodePtrPackage* pNodePackage,
bool bDirectly = false) = 0;
protected:
virtual bool readOherModulesFromVg() = 0;
virtual bool readNodeModuleFromVg() = 0;
virtual bool readAbstractNodesFromVG() = 0;
virtual bool readDataNodesByAbstractNodeFromVG() = 0;
virtual bool generateVgNodeFromBuffer(char *pBuffer, Node** pNodeData) = 0;
virtual bool addVgNodeToManager() = 0;
//virtual bool addVgNodeToUI() = 0;
};
}//namespace vgMod
#endif//__VGMVGFILEREADERVGABSTRACT_H__
|
/******************************************************
*
* ©keithhedger Tue 16 Jul 20:46:19 BST 2013
* kdhedger68713@gmail.com
*
* spellcheck.h
*
******************************************************/
#ifndef _SPELLCHECK_
#define _SPELLCHECK_
#ifdef _ASPELL_
void checkWord(GtkWidget* widget,gpointer data);
void doChangeWord(GtkWidget* widget,gpointer data);
void doAddIgnoreWord(GtkWidget* widget,gpointer data);
void doSpellCheckDoc(GtkWidget* widget,gpointer data);
void doCancelCheck(GtkWidget* widget,gpointer data);
#endif
#endif
|
//
// MineHeadView.h
// YH-IOS
//
// Created by 钱宝峰 on 2017/6/8.
// Copyright © 2017年 com.intfocus. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "Person.h"
#import "UserCountView.h"
#import "User.h"
@protocol MineHeadDelegate <NSObject>
-(void)ClickButton:(UIButton *)btn;
@end
@interface MineHeadView : UIView
@property (nonatomic, strong)Person *person;
@property (nonatomic, strong)UIButton *avaterImageView;
@property (nonatomic, strong)UILabel *userNameLabel;
@property (nonatomic, strong)UILabel *lastLoginMessageLabel;
@property (nonatomic, strong)UserCountView *loginCountView;
@property (nonatomic, strong)UserCountView *reportScanCountView;
@property (nonatomic, strong)UserCountView *precentView;
@property (nonatomic, weak) id<MineHeadDelegate> delegate;
// 刷新视图
-(void)refreshViewWith:(NSDictionary *)person;
-(instancetype)initWithFrame:(CGRect)frame withPerson:(Person*)person;
-(void)addVaildData;
-(void)refeshAvaImgeView:(UIImage *)image;
@end
|
/* -*- Mode: C++; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
*******************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011.
*
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
*
* THIS IS UNPUBLISHED SOURCE CODE OF create3000.
*
* The copyright notice above does not evidence any actual of intended
* publication of such source code, and is an unpublished work by create3000.
* This material contains CONFIDENTIAL INFORMATION that is the property of
* create3000.
*
* No permission is granted to copy, distribute, or create derivative works from
* the contents of this software, in whole or in part, without the prior written
* permission of create3000.
*
* NON-MILITARY USE ONLY
*
* All create3000 software are effectively free software with a non-military use
* restriction. It is free. Well commented source is provided. You may reuse the
* source in any way you please with the exception anything that uses it must be
* marked to indicate is contains 'non-military use only' components.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 1999, 2016 Holger Seelig <holger.seelig@yahoo.de>.
*
* This file is part of the Titania Project.
*
* Titania is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License version 3 only, as published by the
* Free Software Foundation.
*
* Titania 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 version 3 for more
* details (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU General Public License version 3
* along with Titania. If not, see <http://www.gnu.org/licenses/gpl.html> for a
* copy of the GPLv3 License.
*
* For Silvio, Joy and Adi.
*
******************************************************************************/
#ifndef __TITANIA_X3D_COMPONENTS_NAVIGATION_VIEWPOINT_H__
#define __TITANIA_X3D_COMPONENTS_NAVIGATION_VIEWPOINT_H__
#include "../Navigation/X3DViewpointNode.h"
namespace titania {
namespace X3D {
class Viewpoint :
virtual public X3DViewpointNode
{
public:
/// @name Construction
Viewpoint (X3DExecutionContext* const executionContext);
virtual
X3DBaseNode*
create (X3DExecutionContext* const executionContext) const final override;
/// @name Common members
virtual
const Component &
getComponent () const final override
{ return component; }
virtual
const std::string &
getTypeName () const final override
{ return typeName; }
virtual
const std::string &
getContainerField () const final override
{ return containerField; }
/// @name Fields
virtual
SFVec3f &
position ()
{ return *fields .position; }
virtual
const SFVec3f &
position () const
{ return *fields .position; }
virtual
SFVec3f &
centerOfRotation ()
{ return *fields .centerOfRotation; }
virtual
const SFVec3f &
centerOfRotation () const
{ return *fields .centerOfRotation; }
virtual
SFFloat &
fieldOfView ()
{ return *fields .fieldOfView; }
virtual
const SFFloat &
fieldOfView () const
{ return *fields .fieldOfView; }
/// @name Member access
virtual
void
setPosition (const Vector3d & value) final override
{ position () = value; }
virtual
Vector3d
getPosition () const final override
{ return position () .getValue (); }
virtual
void
setCenterOfRotation (const Vector3d & value) final override
{ centerOfRotation () = value; }
virtual
Vector3d
getCenterOfRotation () const final override
{ return centerOfRotation () .getValue (); }
virtual
Vector3d
getScreenScale (const Vector3d & point, const Vector4i & viewport) const override;
virtual
Vector2d
getViewportSize (const Vector4i & viewport, const double nearValue) const override;
virtual
Matrix4d
getProjectionMatrix (const double nearValue, const double farValue, const Vector4i & viewport, const bool limit = false) const override;
private:
/// @name Member access
double
getFieldOfView () const;
virtual
std::pair <double, double>
getLookAtDistance (const Box3d &) const final override;
/// @name Static members
static const Component component;
static const std::string typeName;
static const std::string containerField;
/// @name Members
struct Fields
{
Fields ();
SFVec3f* const position;
SFVec3f* const centerOfRotation;
SFFloat* const fieldOfView;
};
Fields fields;
};
} // X3D
} // titania
#endif
|
/*
* Copyright (C) 2010-2013 by RoboLab - University of Extremadura
*
* This file is part of RoboComp
*
* RoboComp 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.
*
* RoboComp 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 RoboComp. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INNERMODELVIEWER_H
#define INNERMODELVIEWER_H
// OSG includes
#include <osg/Camera>
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/Image>
#include <osg/LineSegment>
#include <osg/Material>
#include <osg/MatrixTransform>
#include <osg/Point>
#include <osg/Quat>
#include <osg/Shape>
#include <osg/ShapeDrawable>
#include <osg/TexMat>
#include <osgDB/ReadFile>
#include <osgGA/KeySwitchMatrixManipulator>
#include <osgGA/StateSetManipulator>
#include <osgGA/TrackballManipulator>
#include <osgUtil/IntersectVisitor>
#include <osgViewer/CompositeViewer>
#include <osgViewer/GraphicsWindow>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
// Qt includes
#include <QHash>
#include <QtGui>
#include <QtOpenGL/QGLWidget>
#include <osgviewer/adapterwidget.h>
#include <osgviewer/osgview.h>
#include <osgviewer/viewerqt.h>
#include <qmat/QMatAll>
#include <innermodel/innermodel.h>
osg::Vec3 QVecToOSGVec(const QVec &vec);
osg::Vec4 htmlStringToOsgVec4(QString color);
QString osgVec4ToHtmlString(osg::Vec4 color);
osg::Matrix QMatToOSGMat4(const RTMat &nodeB);
struct IMVCamera
{
osg::Image *rgb;
osg::Image *d;
InnerModelRGBD *RGBDNode;
osgViewer::Viewer *viewerCamera;
osgGA::TrackballManipulator *manipulator;
QString id;
};
struct IMVLaser
{
InnerModelLaser *laserNode;
//osg::Switch *osgNode;
osg::ref_ptr<osg::Switch> osgNode;
QString id;
};
struct IMVMesh
{
osg::ref_ptr<osg::Node> osgmeshes;
osg::ref_ptr<osg::MatrixTransform> osgmeshPaths;
osg::ref_ptr<osg::MatrixTransform> meshMts;
// osg::Node * osgmeshes;
// osg::MatrixTransform * osgmeshPaths;
// osg::MatrixTransform * meshMts;
};
class IMVPlane : public osg::Geode
{
friend class InnerModelViewer;
public:
IMVPlane(InnerModelPlane *plane, std::string imagenEntrada, osg::Vec4 valoresMaterial, float transparencia);
~IMVPlane();
void updateBuffer(uint8_t *data_, int32_t width_, int32_t height_);
void performUpdate();
// protected:
uint8_t *data;
bool dirty;
int32_t width, height;
osg::ref_ptr<osg::Texture2D> texture;
osg::ref_ptr<osg::ShapeDrawable> planeDrawable;
osg::ref_ptr<osg::Image> image;
// osg::Texture2D* texture;
// osg::ShapeDrawable *planeDrawable;
// osg::Image *image;
};
class IMVPointCloud : public osg::Geode
{
public:
IMVPointCloud(std::string id_);
void update();
float getPointSize();
void setPointSize(float p);
std::string id;
osg::Vec3Array *points;
osg::Vec4Array *colors;
protected:
osg::Vec3Array *cloudVertices;
osg::Vec4Array *colorsArray;
osg::Geometry *cloudGeometry;
// osg::TemplateIndexArray <unsigned int, osg::Array::UIntArrayType,4,4> *colorIndexArray;
osg::DrawArrays *arrays;
float pointSize;
};
class InnerModelViewer : public osg::Switch
{
public:
enum CameraView { BACK_POV, FRONT_POV, LEFT_POV, RIGHT_POV, TOP_POV };
InnerModelViewer(InnerModel *im, QString root="root", osg::Group *parent=NULL, bool ignoreCameras=false);
~InnerModelViewer();
// Returns geode if 'id' corresponds to a geode, null otherwise.
osg::Geode* getGeode(QString id);
void update();
void reloadMesh(QString id);
void recursiveConstructor(InnerModelNode* node, osg::Group* parent, QHash< QString, osg::MatrixTransform* >& mtsHash, QHash< QString, IMVMesh >& meshHash, bool ignoreCameras=false);
void setMainCamera(osgGA::TrackballManipulator *manipulator, CameraView pov) const;
protected:
void setOSGMatrixTransformForPlane(osg::MatrixTransform *mt, InnerModelPlane *plane);
public:
InnerModel *innerModel;
//CAUTION
//QHash<QString, osg::PolygonMode *> osgmeshmodes;
QHash<QString, osg::ref_ptr<osg::PolygonMode > > osgmeshmodes;
//CAUTION
QHash<QString, osg::MatrixTransform *> mts;
// QHash<QString, osg::ref_ptr<osg::MatrixTransform > > mts;
//CAUTION
// QHash<QString, osg::MatrixTransform *> planeMts;
QHash<QString, osg::ref_ptr<osg::MatrixTransform > > planeMts;
QHash<QString, IMVMesh> meshHash;
QHash<QString, IMVPointCloud *> pointCloudsHash;
QHash<QString, IMVPlane *> planesHash;
QHash<QString, IMVCamera> cameras;
QHash<QString, IMVLaser> lasers;
public:
void setCameraCenter(OsgView *view, const QVec center_);
void setLookTowards(OsgView *view, const QVec to_, const QVec up_);
void lookAt(OsgView *view, const QVec center_, const QVec to_, const QVec up_);
private:
QVec eye, up, to;
};
#endif
|
/* $Id: AclFeed.h 3643 2013-04-17 10:50:31Z IMPOMEZIA $
* IMPOMEZIA Simple Chat
* Copyright © 2008-2013 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 ACLFEED_H_
#define ACLFEED_H_
#define ACL_FEED_HEAD_MASK_KEY QLatin1String("head/mask")
#define ACL_FEED_HEAD_MASK_REQ QLatin1String("acl/head/mask")
#define ACL_FEED_HEAD_OTHER_KEY QLatin1String("head/other")
#define ACL_FEED_HEAD_OTHER_REQ QLatin1String("acl/head/other")
#define ACL_FEED_INVITE_KEY QLatin1String("invite")
#define ACL_FEED_INVITE_REQ QLatin1String("acl/invite")
#define ACL_FEED_KICK_KEY QLatin1String("kick")
#define ACL_FEED_KICK_REQ QLatin1String("acl/kick")
#endif /* ACLFEED_H_ */
|
/* A Bison parser, made by GNU Bison 3.0.4. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
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/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_YY_PARSER_H_INCLUDED
# define YY_YY_PARSER_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int yydebug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
ADD = 258,
DELETE = 259,
INFO = 260,
LIST = 261,
OPEN = 262,
CLOSE = 263,
UNDO = 264,
ABSENT = 265,
EVEN = 266,
CALL = 267,
HELP = 268,
QUIT = 269,
NAME = 270,
BOOL = 271,
INT = 272
};
#endif
/* Tokens. */
#define ADD 258
#define DELETE 259
#define INFO 260
#define LIST 261
#define OPEN 262
#define CLOSE 263
#define UNDO 264
#define ABSENT 265
#define EVEN 266
#define CALL 267
#define HELP 268
#define QUIT 269
#define NAME 270
#define BOOL 271
#define INT 272
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
#line 18 "parser.y" /* yacc.c:1909 */
gchar *string;
gboolean boolean;
guint integer;
#line 94 "parser.h" /* yacc.c:1909 */
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE yylval;
int yyparse (void);
#endif /* !YY_YY_PARSER_H_INCLUDED */
|
#include <stdlib.h>
#include "ndf1.h"
size_t ndf1Len( const char *str ){
/*
*+
* Name:
* ndf1Len
* Purpose:
* Return the declared length of a character string.
* Synopsis:
* size_t ndf1Len( const char *str )
* Description:
* This function returns the number of characters in the string
* supplied, as determined by the Fortran intrinsic LEN function.
* Parameters:
* str
* Pointer to a null terminated string holding the string.
* Returned Value:
* The string's length.
* Notes:
* This function exists purely to avoid using the intrinsic LEN function
* in generic functions, where the compiler might otherwise object to
* its parameter having an incorrect data type (even though such calls
* would never actually be executed).
* 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: */
size_t result; /* Returned value */
/* Return the string length. */
result = strlen( str );
/* Return the result */
return result;
}
|
#ifndef CLINKEDQUEUE_H_INCLUDED
#define CLINKEDQUEUE_H_INCLUDED
#include "CLinkedNode.h"
#include <iostream>
using namespace std;
template <typename T>
class CLinkedQueue{
public:
CLinkedQueue();
~CLinkedQueue();
void Print();
void MakeEmpty();
bool IsEmpty();
bool EnQueue(const T& value);
bool DeQueue();
T& GetFront();
int GetSize();
private:
CLinkNode<T> *m_CFront;
CLinkNode<T> *m_CRear;
};
template <typename T>
CLinkedQueue<T>::CLinkedQueue():m_CFront(NULL),m_CRear(NULL){
}
template <typename T>
CLinkedQueue<T>::~CLinkedQueue(){
MakeEmpty();
}
template <typename T>
void CLinkedQueue<T>::Print(){
CLinkNode<T> *current = m_CFront;
while(current != NULL){
cout << current -> m_TData << " ";
current = current -> m_CNext;
}
cout << endl;
}
template <typename T>
void CLinkedQueue<T>::MakeEmpty(){
CLinkNode<T> *current;
while(m_CFront != NULL){
current = m_CFront;
m_CFront = m_CFront -> m_CNext;
delete current;
}
m_CRear = NULL;
}
template <typename T>
bool CLinkedQueue<T>::IsEmpty(){
return (m_CFront == NULL)? true : false;
}
template <typename T>
bool CLinkedQueue<T>::EnQueue(const T& value){
if(m_CFront == NULL){
m_CFront = m_CRear = new CLinkNode<T>(value);
if(m_CFront == NULL)
cout << "Error Distribution!" << endl;return false;
}
else{
m_CRear -> m_CNext = new CLinkNode<T>(value);
m_CRear = m_CRear -> m_CNext;
}
return true;
}
template <typename T>
bool CLinkedQueue<T>::DeQueue(){
if(IsEmpty() == true)
return false;
CLinkNode<T> *current = m_CFront;
m_CFront = m_CFront -> m_CNext;
delete current;//ÀÏÎÊÌ⣡
current = NULL;
return true;
}
template <typename T>
T& CLinkedQueue<T>::GetFront(){
return m_CFront->m_TData;
}
template <typename T>
int CLinkedQueue<T>::GetSize(){
int number = 0;
CLinkNode<T> *current = m_CFront;
while(current != NULL){
++number;
current = current -> m_CNext;
}
return number;
}
#endif // CLINKEDQUEUE_H_INCLUDED
|
/*
* (C) 2009-2014 see Authors.txt
*
* This file is part of MPC-HC.
*
* MPC-HC 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.
*
* MPC-HC 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/>.
*
*/
#pragma once
#include <future>
#include "mpc-hc_config.h"
// CPPageFileMediaInfo dialog
class CPPageFileMediaInfo : public CPropertyPage
{
DECLARE_DYNAMIC(CPPageFileMediaInfo)
private:
CEdit m_mediainfo;
CFont m_font;
CString m_fn, m_path;
bool m_bSyncAnalysis;
std::shared_future<CString> m_futureMIText;
std::thread m_threadSetText;
public:
CPPageFileMediaInfo(CString path, IFileSourceFilter* pFSF, IDvdInfo2* pDVDI, CMainFrame* pMainFrame);
virtual ~CPPageFileMediaInfo();
// Dialog Data
enum { IDD = IDD_FILEMEDIAINFO };
#if !USE_STATIC_MEDIAINFO
static bool HasMediaInfo();
#endif
void OnSaveAs();
protected:
enum {
WM_MEDIAINFO_READY = WM_APP + 1
};
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL PreTranslateMessage(MSG* pMsg);
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
afx_msg void OnDestroy();
afx_msg void OnMediaInfoReady();
bool OnKeyDownInEdit(MSG* pMsg);
};
|
#pragma once
#include <vector>
#include "Matrix2D.h"
#include "Point.h"
#include <algorithm>
#include "TransformationMetaInfo.h"
using namespace std;
class Descriptor:public vector<double>
{
public:
Descriptor(vector<double> value, Point location,double angle = 0,double sigma = 0);
Point GetPoint() const;
double Angle() const;
double Sigma() const;
TransformationMetaInfo MetaInfo() const;
private:
const double Threshold = 0.2;
TransformationMetaInfo metaInfo;
void Normalize();
void RemoveNoise();
};
|
#include <stdlib.h>
#include <stdio.h>
#include "tokenize.h"
#include "parse.h"
#include "mem.h"
#include "types.h"
#include "lists.h"
#include "eval.h"
#include "builtins.h"
#include "io.h"
int
main(int argc, char* argv[])
{
pscm_init_types();
ps_v* env = initial_env();
//printf("%s\n", pscm_show(env));
while(1) {
char* line = pscm_readline("pscm> ");
if (line == 0) {
printf("\n");
break;
}
ps_source* code = source_from_string("[test]", line);
ps_v* vv = parse(code);
ps_v* ii = vv;
while (!list_empty(ii)) {
ps_cons* cc = (ps_cons*) ii;
ps_v* rv = eval(env, cc->car);
char* text = pscm_show(rv);
printf("%s\n", text);
ii = cc->cdr;
}
}
return 0;
}
|
/*
File: jagpjcassign.c
Project: jaguar-parser
Author: Douwe Vos
Date: May 4, 2017
e-mail: dmvos2000(at)yahoo.com
Copyright (C) 2017 Douwe Vos.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "jagpjcassign.h"
#include <logging/catlogdefs.h>
#define CAT_LOG_LEVEL CAT_LOG_WARN
#define CAT_LOG_CLAZZ "JagPJCAssign"
#include <logging/catlog.h>
static void l_stringable_iface_init(CatIStringableInterface *iface);
G_DEFINE_TYPE_WITH_CODE(JagPJCAssign, jagp_jcassign, JAGP_TYPE_JCEXPRESSION,
G_IMPLEMENT_INTERFACE(CAT_TYPE_ISTRINGABLE, l_stringable_iface_init)
);
static void l_dispose(GObject *object);
static void l_finalize(GObject *object);
static JagPTag l_tree_get_tag(JagPJCTree *tree) { return JAGP_TAG_ASSIGN; }
static void jagp_jcassign_class_init(JagPJCAssignClass *clazz) {
GObjectClass *object_class = G_OBJECT_CLASS(clazz);
object_class->dispose = l_dispose;
object_class->finalize = l_finalize;
JagPJCTreeClass *tree_class = JAGP_JCTREE_CLASS(clazz);
tree_class->getTag = l_tree_get_tag;
}
static void jagp_jcassign_init(JagPJCAssign *instance) {
}
static void l_dispose(GObject *object) {
cat_log_detail("dispose:%p", object);
JagPJCAssign *instance = JAGP_JCASSIGN(object);
cat_unref_ptr(instance->lhs);
cat_unref_ptr(instance->rhs);
G_OBJECT_CLASS(jagp_jcassign_parent_class)->dispose(object);
cat_log_detail("disposed:%p", object);
}
static void l_finalize(GObject *object) {
cat_log_detail("finalize:%p", object);
cat_ref_denounce(object);
G_OBJECT_CLASS(jagp_jcassign_parent_class)->finalize(object);
cat_log_detail("finalized:%p", object);
}
JagPJCAssign *jagp_jcassign_new(JagPJCExpression *lhs, JagPJCExpression *rhs) {
JagPJCAssign *result = g_object_new(JAGP_TYPE_JCASSIGN, NULL);
cat_ref_anounce(result);
jagp_jcexpression_construct((JagPJCExpression *) result);
result->lhs = cat_ref_ptr(lhs);
result->rhs = cat_ref_ptr(rhs);
return result;
}
/********************* start CatIStringable implementation *********************/
static void l_stringable_print(CatIStringable *self, struct _CatStringWo *append_to) {
const char *iname = g_type_name_from_instance((GTypeInstance *) self);
cat_string_wo_format(append_to, "%s[%p]", iname, self);
}
static void l_stringable_iface_init(CatIStringableInterface *iface) {
iface->print = l_stringable_print;
}
/********************* end CatIStringable implementation *********************/
|
// This file was generated based on /usr/local/share/uno/Packages/UnoCore/1.3.2/Source/Uno/Int.uno.
// WARNING: Changes might be lost if you edit this file directly.
#pragma once
#include <Uno.Object.h>
namespace g{
namespace Uno{
// public intrinsic struct Int :15
// {
uStructType* Int_typeof();
void Int__Equals_fn(int* __this, uType* __type, uObject* o, bool* __retval);
void Int__GetHashCode_fn(int* __this, uType* __type, int* __retval);
void Int__Parse_fn(uString* str, int* __retval);
void Int__ToString_fn(int* __this, uType* __type, uString** __retval);
void Int__TryParse_fn(uString* str, int* res, bool* __retval);
struct Int
{
static bool Equals(int __this, uType* __type, uObject* o) { bool __retval; return Int__Equals_fn(&__this, __type, o, &__retval), __retval; }
static int GetHashCode(int __this, uType* __type) { int __retval; return Int__GetHashCode_fn(&__this, __type, &__retval), __retval; }
static uString* ToString(int __this, uType* __type) { uString* __retval; return Int__ToString_fn(&__this, __type, &__retval), __retval; }
static int Parse(uString* str);
static bool TryParse(uString* str, int* res);
};
// }
}} // ::g::Uno
|
/*
Copyright (C) 2012-2013 Sarvaritdinov R.
This file is part of REXLoader.
REXLoader 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.
REXLoader 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 SHUTDOWNMANAGER_H
#define SHUTDOWNMANAGER_H
#include <QObject>
#include <QProcess>
#ifdef Q_OS_UNIX
#include <QtDBus/QtDBus>
#endif
class ShutdownManager : public QObject
{
Q_OBJECT
public:
enum DEType{
KDE4,
Gnome,
Other
};
enum ShutdownMode
{
Shutdown,
Suspend,
Hibernate
};
explicit ShutdownManager(QObject *parent = 0);
~ShutdownManager();
static DEType DEDetect();
static bool shutdownPC();
static bool suspendPC();
static bool hibernatePC();
signals:
public slots:
void setMode(ShutdownMode mode);
void startShutdown() const;
private:
ShutdownMode curmode;
DEType detype;
};
#endif // SHUTDOWNMANAGER_H
|
#ifndef MUSICWEBDJRADIOCATEGORYWIDGET_H
#define MUSICWEBDJRADIOCATEGORYWIDGET_H
/***************************************************************************
* This file is part of the TTK Music Player project
* Copyright (C) 2015 - 2022 Greedysky Studio
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along
* with this program; If not, see <http://www.gnu.org/licenses/>.
***************************************************************************/
#include "musicclickedlabel.h"
#include "musicabstractitemquerywidget.h"
class QGridLayout;
class MusicDJRadioCategoryRequest;
/*! @brief The class of music dj radio category item widget.
* @author Greedysky <greedysky@163.com>
*/
class TTK_MODULE_EXPORT MusicWebDJRadioCategoryItemWidget : public MusicClickedLabel
{
Q_OBJECT
TTK_DECLARE_MODULE(MusicWebDJRadioCategoryItemWidget)
public:
/*!
* Object contsructor.
*/
explicit MusicWebDJRadioCategoryItemWidget(QWidget *parent = nullptr);
~MusicWebDJRadioCategoryItemWidget();
/*!
* Set music results item.
*/
void setMusicResultsItem(const MusicResultsItem &item);
Q_SIGNALS:
/*!
* Current item clicked.
*/
void currentItemClicked(const MusicResultsItem &item);
public Q_SLOTS:
/*!
* Send recieved data from net.
*/
void downLoadFinished(const QByteArray &bytes);
/*!
* Current item clicked.
*/
void currentItemClicked();
protected:
QLabel *m_iconLabel, *m_nameLabel;
MusicResultsItem m_itemData;
};
/*! @brief The class of music dj radio category widget.
* @author Greedysky <greedysky@163.com>
*/
class TTK_MODULE_EXPORT MusicWebDJRadioCategoryWidget : public QWidget
{
Q_OBJECT
TTK_DECLARE_MODULE(MusicWebDJRadioCategoryWidget)
public:
/*!
* Object contsructor.
*/
explicit MusicWebDJRadioCategoryWidget(QWidget *parent = nullptr);
~MusicWebDJRadioCategoryWidget();
/*!
* Init parameters.
*/
void initialize();
/*!
* Resize window bound by widget resize called.
*/
void resizeWindow();
Q_SIGNALS:
/*!
* Current category clicked.
*/
void currentCategoryClicked(const MusicResultsItem &item);
public Q_SLOTS:
/*!
* Query all quality musics is finished.
*/
void createCategoryItems();
protected:
QGridLayout *m_gridLayout;
QList<QLabel*> m_resizeWidgets;
MusicDJRadioCategoryRequest *m_categoryThread;
};
#endif // MUSICWEBDJRADIOCATEGORYWIDGET_H
|
/* PhDirStore
*
* Copyright (C) 2016 Jente Hidskes
*
* Author: Jente Hidskes <hjdskes@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#pragma once
#include <glib-object.h>
G_BEGIN_DECLS
typedef struct _PhDirStore PhDirStore;
typedef struct _PhDirStoreClass PhDirStoreClass;
typedef struct _PhDirStorePrivate PhDirStorePrivate;
#define PH_TYPE_DIR_STORE (ph_dir_store_get_type ())
#define PH_DIR_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PH_TYPE_DIR_STORE, PhDirStore))
#define PH_DIR_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PH_TYPE_DIR_STORE, PhDirStoreClass))
#define PH_IS_DIR_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PH_TYPE_DIR_STORE))
#define PH_IS_DIR_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PH_TYPE_DIR_STORE))
#define PH_DIR_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PH_TYPE_DIR_STORE, PhDirStoreClass))
struct _PhDirStore {
GObject base_instance;
};
struct _PhDirStoreClass {
GObjectClass parent_class;
};
GType ph_dir_store_get_type (void);
PhDirStore *ph_dir_store_new (void);
void ph_dir_store_activate_added (PhDirStore *dir_store);
G_END_DECLS
|
#include <serpent/shx.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
int
main(int argc, char *argv[])
{
struct shx s;
unsigned long x[32];
const uint8_t *key = "0000000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000000000000000000000000";
size_t i = 0;
for (; i < 32; i ++)
x[i] = arc4random() % (1 << 31);
if (shx_init(&s, 128, SHA512, key, strlen(key)) != -1) {
shx_encrypt(&s, (uint8_t *)x, 32, (uint8_t *)x, 32);
shx_decrypt(&s, (uint8_t *)x, 32, (uint8_t *)x, 32);
shx_dispose(&s);
} else {
fprintf(stderr, "serpent could not init\n");
}
return (0);
}
|
#ifndef STL_XSPDEQUE_H_
#define STL_XSPDEQUE_H_
#include<semaphore.h>
#include<errno.h>
#include"thread/XSPMutex.h"
#include<bits/local_lim.h>
#include<stl/xdeque.h>
#include<thread/XSPTime.h>
#ifndef errno
extern int errno;
#endif
template<class V, class MUTEX=THREAD_MUTEX>
class CXSPDeque
{
public:
CXSPDeque(const size_t maxSize=50000){
m_bAbort = false;
m_bsNotep = false;
m_bsNotfl = false;
ResetInit(maxSize);
}
virtual ~CXSPDeque()
{
AbortWati();
SafeClose();
}
size_t ResetInit(size_t maxSize)
{
maxSize = maxSize>SEM_VALUE_MAX ? SEM_VALUE_MAX-1:maxSize;
if(this->m_bAbort)
{
this->m_bAbort = false;
SafeClose();
}
int rete = sem_init(&m_sNotEmpty, 0, 0);
int retf = sem_init(&m_sNotFull, 0, m_deque.maxsize);
return ((rete==retf) && rete==0) ?
this->m_bsNotep=true,this->m_bsNotfl=true,
init_deque(&this->m_deque, maxSize):0;
}
inline void SetMaxQueueSize(size_t maxSize)
{
maxSize = maxSize>SEM_VALUE_MAX ? SEM_VALUE_MAX-1:maxSize;
reset_deque(&this->m_deque, maxSize);
}
inline void SafeClose()
{
if(!this->m_bsNotep &&
!this->m_bsNotfl)
{
sem_destroy(&m_sNotEmpty);
sem_destroy(&m_sNotFull);
m_bsNotep = false;
m_bsNotfl = false;
}
}
inline void AbortWati()
{
this->m_bAbort = false;
sem_post(&this->m_sNotEmpty);
sem_post(&this->m_sNotFull);
}
inline bool isFull(int offset=0)
{
return size_deque(&this->m_deque, offset)>=m_deque.maxsize ? 1:0;
}
inline bool isEmpty()
{
return empty_deque(&this->m_deque);
}
inline bool isAbort()
{
return this->m_bAbort;
}
bool Front(V &data, u_long out=0)
{
if(this->WaitforNotEmpty(out))
{
AUTO_GUARD(g, MUTEX, this->m_mutex);
if(front_deque(&this->m_deque, data))
{
return true;
}
return false;
}
if(this->m_bAbort)
{
return false;
}
return false;
}
bool PopFront(V &data, u_long out=0)
{
if(!this->m_bAbort)
{
if(this->WaitforNotEmpty(out))
{
AUTO_GUARD(g, MUTEX, this->m_mutex);
if(pop_front_deque(&this->m_deque, data))
{
sem_post(&this->m_sNotFull);
return true;
}
return false;
}
}
else
{
AUTO_GUARD(g, MUTEX, this->m_mutex);
if(!this->isEmpty())
{
return pop_front_deque(&this->m_deque, data);
}
return false;
}
return false;
}
bool PushFront(const V &data, u_long out=0)
{
if(!this->m_bAbort)
{
if(this->WaitforNotFull(out))
{
AUTO_GUARD(g, MUTEX, this->m_mutex);
if(!this->isFull())
{
if(push_front_deque(&this->m_deque, data))
{
sem_post(&this->m_sNotEmpty);
return true;
}
return false;
}
}
}
return false;
}
bool Back(V &data, u_long out=0)
{
if(this->WaitforNotEmpty(out))
{
AUTO_GUARD(g, MUTEX, this->m_mutex);
if(back_deque(&this->m_deque, data))
{
return true;
}
return false;
}
if(this->m_bAbort)
{
return false;
}
return false;
}
bool PopBack(V &data, u_long out=0)
{
if(!this->m_bAbort)
{
if(this->WaitforNotEmpty(out))
{
AUTO_GUARD(g, MUTEX, this->m_mutex);
if(pop_back_deque(&this->m_deque, data))
{
sem_post(&this->m_sNotFull);
return true;
}
return false;
}
}
else
{
AUTO_GUARD(g, MUTEX, this->m_mutex);
if(!empty_deque(&this->m_deque))
{
return pop_back_deque(&this->m_deque, data);
}
return false;
}
return false;
}
bool PushBack(const V &data)
{
if(!this->m_bAbort)
{
AUTO_GUARD(g, MUTEX, this->m_mutex);
if(!this->isFull())
{
if(push_back_deque(&this->m_deque, data))
{
sem_post(&this->m_sNotEmpty);
return true;
}
}
}
return false;
}
bool Insert(typename std::deque<V>::const_iterator where, V *first, V *last)
{
if(!this->m_bAbort)
{
AUTO_GUARD(g, MUTEX, this->m_mutex);
int offset = last-first;
if(offset<0) offset=-offset;
if(!this->isFull(offset))
{
if(insert_deque(&this->m_deque, where, first, last))
{
sem_post(&this->m_sNotEmpty);
return true;
}
}
}
return false;
}
inline size_t Size()
{
return size_deque(&this->m_deque);
}
void Clear()
{
AbortWati();
SafeClose();
clear_deque(&this->m_deque);
}
protected:
bool WaitforNotEmpty(u_long out = 0)
{
CXSPTimeout cnt;
cnt.Init(out);
while(!this->m_bAbort && this->m_bsNotep)
{
int ret = 0;
u_long w = cnt.timeleft();
switch(out)
{
case -1:
ret = sem_wait(&this->m_sNotEmpty);
break;
default:
struct timespec tim;
cnt.timeofNowTime(tim, w);
ret = sem_timedwait(&this->m_sNotEmpty, &tim);
break;
}
if(0 == ret && !this->m_bAbort)
{
return true;
}
else if(EINTR == errno)
{
continue;
}
else{
return false;
}
}
return false;
}
bool WaitforNotFull(u_long out = 0)
{
CXSPTimeout cnt;
cnt.Init(out);
while(!this->m_bAbort && this->m_bsNotfl)
{
int ret = 0;
u_long w = cnt.timeleft();
switch(out)
{
case -1:
ret = sem_wait(&this->m_sNotEmpty);
break;
default:
struct timespec tim;
cnt.timeofNowTime(tim, w);
ret = sem_timedwait(&this->m_sNotEmpty, &tim);
break;
}
if(0 == ret && !this->m_bAbort)
{
return true;
}
else if(EINTR == errno)
{
continue;
}
else{
return false;
}
}
return false;
}
private:
bool m_bAbort;
MUTEX m_mutex;
struct xsp_deque<V> m_deque;
sem_t m_sNotEmpty;
sem_t m_sNotFull;
bool m_bsNotep;
bool m_bsNotfl;
};
#endif /* STL_XSPDEQUE_H_ */
|
// $Id$ -*- C++ -*-
// Panned Graph Editor (private part)
// Copyright (C) 1995 Technische Universitaet Braunschweig, Germany.
// Copyright (C) 2000 Universitaet Passau, Germany.
// Written by Andreas Zeller <zeller@gnu.org>.
//
// This file is part of DDD.
//
// DDD 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.
//
// DDD 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 DDD -- see the file COPYING.
// If not, see <http://www.gnu.org/licenses/>.
//
// DDD is the data display debugger.
// For details, see the DDD World-Wide-Web page,
// `http://www.gnu.org/software/ddd/',
// or send a mail to the DDD developers <ddd@gnu.org>.
#ifndef _DDD_PannedGraphEditPrivate_h
#define _DDD_PannedGraphEditPrivate_h
#include <Xm/Xm.h>
// Superclasses
#define new new_w
#define class class_w
extern "C" {
#include <X11/IntrinsicP.h>
#include <X11/CompositeP.h>
#include <X11/Xaw/PortholeP.h>
}
#undef new
#undef class
// This class
#include "PannedGE.h"
// The GraphEdit class record
typedef struct {
XtPointer extension;
} PannedGraphEditClassPart;
typedef struct _PannedGraphEditClassRec {
CoreClassPart core_class;
CompositeClassPart composite_class;
PortholeClassPart porthole_class;
PannedGraphEditClassPart pannedGraphEdit_class;
} PannedGraphEditClassRec;
extern PannedGraphEditClassRec pannedGraphEditClassRec;
// The PannedGraphEdit instance record
typedef struct _PannedGraphEditPart {
// resources
Dimension minimumPannerWidth;
Dimension minimumPannerHeight;
Dimension maximumScale;
} PannedGraphEditPart;
typedef struct _PannedGraphEditRec {
CorePart core;
CompositePart composite;
PortholePart porthole;
PannedGraphEditPart pannedGraphEdit;
} PannedGraphEditRec;
#endif // _DDD_PannedGraphEditPrivate_h
// DON'T ADD ANYTHING BEHIND THIS #endif
|
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2010 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#ifndef MANTID_MDALGORITHMS_WS_SELECTOR_H
#define MANTID_MDALGORITHMS_WS_SELECTOR_H
#include "MantidMDAlgorithms/ConvToMDBase.h"
namespace Mantid {
namespace MDAlgorithms {
/** small class to select proper solver as function of the workspace kind and
(possibly, in a future) other workspace parameters.
* may be replaced by usual mantid factory in a future;
*
*
* See http://www.mantidproject.org/Writing_custom_ConvertTo_MD_transformation
for detailed description of this
* class place in the algorithms hierarchy.
*
* @date 25-05-2012
*/
class DLLExport ConvToMDSelector {
public:
enum ConverterType { DEFAULT, INDEXED };
/**
*
* @param tp :: type of converter (indexed or default)
*/
ConvToMDSelector(ConverterType tp = DEFAULT);
/// function which selects the convertor depending on workspace type and
/// (possibly, in a future) some workspace properties
boost::shared_ptr<ConvToMDBase>
convSelector(API::MatrixWorkspace_sptr inputWS,
boost::shared_ptr<ConvToMDBase> ¤tSolver) const;
private:
ConverterType converterType;
};
} // namespace MDAlgorithms
} // namespace Mantid
#endif
|
#pragma once
#include <mutex>
#include <condition_variable>
#include <queue>
#include <memory>
namespace messaging
{
struct message_base
{
message_base()
{
msgid = -1;
};
int msgid;
virtual ~message_base()
{}
};
template<typename Msg>
struct wrapped_message:
message_base
{
Msg contents;
explicit wrapped_message( int pid, Msg const& contents_ ):
contents( contents_ )
{
msgid = pid;
}
};
class guarded_queue
{
public:
template<typename T>
void push( int pid, T const& msg )
{
std::lock_guard<std::mutex> lk(m);
q.push(std::make_shared<wrapped_message<T> >( pid, msg ));
}
template<typename T>
void push_notify( int pid, T const& msg )
{
std::lock_guard<std::mutex> lk(m);
q.push(std::make_shared<wrapped_message<T> >( pid, msg ));
c.notify_all();
}
std::shared_ptr<message_base> wait_and_pop()
{
std::unique_lock<std::mutex> lk(m);
c.wait(lk,[&]{return !q.empty();});
auto res=q.front();
q.pop();
return res;
}
std::shared_ptr<message_base> check_and_pop()
{
std::lock_guard<std::mutex> lk(m);
if ( q.empty() )
{
return std::shared_ptr<message_base>();
}
else
{
auto res=q.front();
q.pop();
return res;
}
}
protected:
std::mutex m;
std::queue<std::shared_ptr<message_base> > q;
std::condition_variable c;
};
class close_queue
{};
class dispatcher
{
guarded_queue* q;
bool chained;
bool mCheck;
//dispatcher( dispatcher const& ) = delete;
//dispatcher& operator = ( dispatcher const& ) = delete;
template<
typename Dispatcher,
typename Msg,
typename Func>
friend class TemplateDispatcher;
void wait_and_dispatch()
{
for(;;)
{
auto msg=q->wait_and_pop();
dispatch(msg);
}
}
void check_and_dispatch()
{
auto msg=q->check_and_pop();
dispatch(msg);
}
bool dispatch( std::shared_ptr<message_base> const& msg )
{
if(dynamic_cast<wrapped_message<close_queue>*>(msg.get()))
{
throw close_queue();
}
return false;
}
public:
dispatcher( dispatcher&& other ):
q( other.q ),
chained( other.chained ),
mCheck( other.mCheck )
{
other.chained = true;
}
explicit dispatcher( guarded_queue* q_, bool pCheck ):
q( q_ ),
chained( false ),
mCheck( pCheck )
{}
template<typename Message, typename Func>
TemplateDispatcher<dispatcher, Message, Func>
handle( Func&& f )
{
return TemplateDispatcher<dispatcher,Message,Func>(
q, this, std::forward<Func>( f ) );
}
//~dispatcher() noexcept(false) no supported in VS 2012
~dispatcher()
{
if(!chained)
{
if ( mCheck )
check_and_dispatch();
else
wait_and_dispatch();
}
}
};
template<typename PreviousDispatcher, typename Msg, typename Func>
class TemplateDispatcher
{
guarded_queue* q;
PreviousDispatcher* prev;
Func f;
bool chained;
bool mCheck;
//TemplateDispatcher( TemplateDispatcher const& ) = delete;
//TemplateDispatcher& operator=( TemplateDispatcher const& ) = delete;
template<typename Dispatcher, typename OtherMsg, typename OtherFunc>
friend class TemplateDispatcher;
void wait_and_dispatch()
{
for(;;)
{
auto msg = q->wait_and_pop();
if ( dispatch( msg ) )
break;
}
}
void check_and_dispatch()
{
auto msg=q->check_and_pop();
dispatch(msg);
}
bool dispatch( std::shared_ptr<message_base> const& msg )
{
if ( wrapped_message<Msg>* wrapper =
dynamic_cast<wrapped_message<Msg>*>( msg.get() ) )
{
f( wrapper->contents );
return true;
}
else
{
return prev->dispatch( msg );
}
}
public:
TemplateDispatcher( TemplateDispatcher&& other ):
q( other.q ),
prev( other.prev ),
f( std::move( other.f ) ),
chained( other.chained ),
mCheck( other.mCheck )
{
other.chained=true;
}
TemplateDispatcher( guarded_queue* q_,PreviousDispatcher* prev_, Func&& f_):
q( q_ ),
prev( prev_ ),
f( std::forward<Func>( f_ ) ),
chained( false ),
mCheck( prev_->mCheck )
{
prev_->chained=true;
}
template<typename OtherMsg, typename OtherFunc>
TemplateDispatcher<TemplateDispatcher, OtherMsg, OtherFunc>
handle( OtherFunc&& of )
{
return TemplateDispatcher<
TemplateDispatcher,OtherMsg,OtherFunc>(
q, this, std::forward<OtherFunc>( of ) );
}
//~TemplateDispatcher() noexcept( false )
~TemplateDispatcher()
{
if( !chained )
{
if ( mCheck )
check_and_dispatch();
else
wait_and_dispatch();
}
}
};
}
|
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtSystems module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QNETWORKINFO_H
#define QNETWORKINFO_H
#include "qsysteminfoglobal.h"
#include <QtCore/qobject.h>
#include <QtNetwork/qnetworkinterface.h>
QT_BEGIN_NAMESPACE
#if !defined(QT_SIMULATOR)
class QNetworkInfoPrivate;
#else
class QNetworkInfoSimulator;
#endif // QT_SIMULATOR
class Q_SYSTEMINFO_EXPORT QNetworkInfo : public QObject
{
Q_OBJECT
public:
enum CellDataTechnology {
UnknownDataTechnology = 0,
GprsDataTechnology,
EdgeDataTechnology,
UmtsDataTechnology,
HspaDataTechnology
};
enum NetworkMode {
UnknownMode = 0,
GsmMode,
CdmaMode,
WcdmaMode,
WlanMode,
EthernetMode,
BluetoothMode,
WimaxMode,
LteMode,
TdscdmaMode
};
enum NetworkStatus {
UnknownStatus = 0,
NoNetworkAvailable,
EmergencyOnly,
Searching,
Busy,
Denied,
HomeNetwork,
Roaming
// ,Connected //desktop
};
QNetworkInfo(QObject *parent = nullptr);
~QNetworkInfo() override;
int networkInterfaceCount(QNetworkInfo::NetworkMode mode) const;
int networkSignalStrength(QNetworkInfo::NetworkMode mode, int interface) const;
QNetworkInfo::CellDataTechnology currentCellDataTechnology(int interface) const;
QNetworkInfo::NetworkMode currentNetworkMode() const;
QNetworkInfo::NetworkStatus networkStatus(QNetworkInfo::NetworkMode mode, int interface) const;
#ifndef QT_NO_NETWORKINTERFACE
QNetworkInterface interfaceForMode(QNetworkInfo::NetworkMode mode, int interface) const;
#endif // QT_NO_NETWORKINTERFACE
QString cellId(int interface) const;
QString currentMobileCountryCode(int interface) const;
QString currentMobileNetworkCode(int interface) const;
QString homeMobileCountryCode(int interface) const;
QString homeMobileNetworkCode(int interface) const;
QString imsi(int interface) const;
QString locationAreaCode(int interface) const;
QString macAddress(QNetworkInfo::NetworkMode mode, int interface) const;
QString networkName(QNetworkInfo::NetworkMode mode, int interface) const;
Q_SIGNALS:
void cellIdChanged(int interface, const QString &id);
void currentCellDataTechnologyChanged(int interface, QNetworkInfo::CellDataTechnology tech);
void currentMobileCountryCodeChanged(int interface, const QString &mcc);
void currentMobileNetworkCodeChanged(int interface, const QString &mnc);
void currentNetworkModeChanged(QNetworkInfo::NetworkMode mode);
void locationAreaCodeChanged(int interface, const QString &lac);
void networkInterfaceCountChanged(QNetworkInfo::NetworkMode mode, int count);
void networkNameChanged(QNetworkInfo::NetworkMode mode, int interface, const QString &name);
void networkSignalStrengthChanged(QNetworkInfo::NetworkMode mode, int interface, int strength);
void networkStatusChanged(QNetworkInfo::NetworkMode mode, int interface, QNetworkInfo::NetworkStatus status);
protected:
void connectNotify(const QMetaMethod &signal) override;
void disconnectNotify(const QMetaMethod &signal) override;
private:
Q_DISABLE_COPY(QNetworkInfo)
#if !defined(QT_SIMULATOR)
QNetworkInfoPrivate * const d_ptr;
Q_DECLARE_PRIVATE(QNetworkInfo)
#else
QNetworkInfoSimulator * const d_ptr;
#endif // QT_SIMULATOR
};
QT_END_NAMESPACE
#endif // QNETWORKINFO_H
|
/****************************************************************************
**
** Copyright (C) 2014 Jolla Ltd, author: <robin.burchell@jollamobile.com>
** Contact: https://www.qt.io/licensing/
**
** This file is part of the config.tests of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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 Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** 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-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <systemd/sd-journal.h>
#include <syslog.h>
int main(int argc, char **argv)
{
sd_journal_send("MESSAGE=%s", "test message",
"PRIORITY=%i", LOG_INFO,
"CODE_FUNC=%s", "unknown",
"CODE_LINE=%d", 0,
"CODE_FILE=%s", "foo.c",
NULL);
return 0;
}
|
/*
* Copyright (C) 2016, Mike Walters <mike@flomp.net>
*
* This file is part of inspectrum.
*
* 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/>.
*/
#pragma once
#include <QMouseEvent>
#include <QObject>
#include <QPoint>
#include "util.h"
class Cursor : public QObject
{
Q_OBJECT
public:
Cursor(Qt::Orientation orientation, QObject * parent);
int pos();
void setPos(int newPos);
bool mouseEvent(QEvent::Type type, QMouseEvent event);
signals:
void posChanged();
private:
int fromPoint(QPoint point);
bool pointOverCursor(QPoint point);
Qt::Orientation orientation;
bool dragging = false;
int cursorPosition = 0;
};
|
/* ide-clang-private.h
*
* Copyright © 2015 Christian Hergert <christian@hergert.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <clang-c/Index.h>
#include <ide.h>
#include "ide-clang-service.h"
#include "ide-clang-symbol-node.h"
#include "ide-clang-translation-unit.h"
G_BEGIN_DECLS
IdeClangTranslationUnit *_ide_clang_translation_unit_new (IdeContext *context,
CXTranslationUnit tu,
GFile *file,
IdeHighlightIndex *index,
gint64 serial);
void _ide_clang_dispose_diagnostic (CXDiagnostic *diag);
void _ide_clang_dispose_index (CXIndex *index);
void _ide_clang_dispose_string (CXString *str);
void _ide_clang_dispose_unit (CXTranslationUnit *unit);
IdeSymbolNode *_ide_clang_symbol_node_new (IdeContext *context,
CXCursor cursor);
CXCursor _ide_clang_symbol_node_get_cursor (IdeClangSymbolNode *self);
GArray *_ide_clang_symbol_node_get_children (IdeClangSymbolNode *self);
void _ide_clang_symbol_node_set_children (IdeClangSymbolNode *self,
GArray *children);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (CXString, _ide_clang_dispose_string)
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (CXIndex, _ide_clang_dispose_index)
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (CXTranslationUnit, _ide_clang_dispose_unit)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CXDiagnostic, _ide_clang_dispose_diagnostic)
G_END_DECLS
|
/**
* Mandelbulber v2, a 3D fractal generator ,=#MKNmMMKmmßMNWy,
* ,B" ]L,,p%%%,,,§;, "K
* Copyright (C) 2017-18 Mandelbulber Team §R-==%w["'~5]m%=L.=~5N
* ,=mm=§M ]=4 yJKA"/-Nsaj "Bw,==,,
* This file is part of Mandelbulber. §R.r= jw",M Km .mM FW ",§=ß., ,TN
* ,4R =%["w[N=7]J '"5=],""]]M,w,-; T=]M
* Mandelbulber is free software: §R.ß~-Q/M=,=5"v"]=Qf,'§"M= =,M.§ Rz]M"Kw
* you can redistribute it and/or §w "xDY.J ' -"m=====WeC=\ ""%""y=%"]"" §
* modify it under the terms of the "§M=M =D=4"N #"%==A%p M§ M6 R' #"=~.4M
* GNU General Public License as §W =, ][T"]C § § '§ e===~ U !§[Z ]N
* published by the 4M",,Jm=,"=e~ § § j]]""N BmM"py=ßM
* Free Software Foundation, ]§ T,M=& 'YmMMpM9MMM%=w=,,=MT]M m§;'§,
* either version 3 of the License, TWw [.j"5=~N[=§%=%W,T ]R,"=="Y[LFT ]N
* or (at your option) TW=,-#"%=;[ =Q:["V"" ],,M.m == ]N
* any later version. J§"mr"] ,=,," =="""J]= M"M"]==ß"
* §= "=C=4 §"eM "=B:m|4"]#F,§~
* Mandelbulber is distributed in "9w=,,]w em%wJ '"~" ,=,,ß"
* the hope that it will be useful, . "K= ,=RMMMßM"""
* 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 Mandelbulber. If not, see <http://www.gnu.org/licenses/>.
*
* ###########################################################################
*
* Authors: Krzysztof Marczak (buddhi1980@gmail.com), Robert Pancoast (RobertPancoast77@gmail.com)
*
* These objects enable an OpenCL backend definition.
*/
#ifndef MANDELBULBER2_SRC_OPENCL_ENGINE_H_
#define MANDELBULBER2_SRC_OPENCL_ENGINE_H_
#include <QtCore>
#include "error_message.hpp"
#include "include_header_wrapper.hpp"
class cOpenClHardware;
class cParameterContainer;
class cOpenClEngine : public QObject
{
Q_OBJECT
struct sOptimalJob
{
sOptimalJob()
: workGroupSize(0),
workGroupSizeOptimalMultiplier(0),
stepSize(0),
stepSizeX(0),
stepSizeY(0),
workGroupSizeMultiplier(1),
lastProcessingTime(1.0),
sizeOfPixel(0),
jobSizeLimit(0),
optimalProcessingCycle(0.1)
{
}
qint64 workGroupSize;
qint64 workGroupSizeOptimalMultiplier;
qint64 stepSize;
qint64 stepSizeX;
qint64 stepSizeY;
qint64 workGroupSizeMultiplier;
QElapsedTimer timer;
double lastProcessingTime;
qint64 sizeOfPixel;
qint64 jobSizeLimit;
double optimalProcessingCycle;
};
public:
cOpenClEngine(cOpenClHardware *hardware);
~cOpenClEngine();
#ifdef USE_OPENCL
struct sClInputOutputBuffer
{
sClInputOutputBuffer(qint64 itemSize, qint64 length, QString name)
: itemSize(itemSize), length(length), name(name), ptr(nullptr), clPtr(nullptr)
{
}
qint64 size() { return itemSize * length; }
qint64 itemSize;
qint64 length;
QString name;
char *ptr;
cl::Buffer *clPtr;
};
void Lock();
void Unlock();
static void DeleteKernelCache();
void Reset();
virtual bool LoadSourcesAndCompile(const cParameterContainer *params) = 0;
bool CreateKernel4Program(const cParameterContainer *params);
virtual bool PreAllocateBuffers(const cParameterContainer *params);
virtual void RegisterInputOutputBuffers(const cParameterContainer *params) = 0;
bool WriteBuffersToQueue();
bool ReadBuffersFromQueue();
bool CreateCommandQueue();
void SetUseBuildCache(bool useCache) { useBuildCache = useCache; }
void SetUseFastRelaxedMath(bool usefastMath) { useFastRelaxedMath = usefastMath; }
void ReleaseMemory();
bool AssignParametersToKernel();
virtual bool AssignParametersToKernelAdditional(int argIterator)
{
Q_UNUSED(argIterator);
return true;
}
protected:
QList<sClInputOutputBuffer> inputBuffers;
QList<sClInputOutputBuffer> outputBuffers;
QList<sClInputOutputBuffer> inputAndOutputBuffers;
virtual QString GetKernelName() = 0;
static bool checkErr(cl_int err, QString functionName);
bool Build(const QByteArray &programString, QString *errorText);
bool CreateKernel(cl::Program *program);
void InitOptimalJob(const cParameterContainer *params);
void UpdateOptimalJobStart(size_t pixelsLeft);
void UpdateOptimalJobEnd();
virtual size_t CalcNeededMemory() = 0;
cl::Program *program;
cl::Kernel *kernel;
cl::CommandQueue *queue;
sOptimalJob optimalJob;
bool programsLoaded;
bool readyForRendering;
bool kernelCreated;
QString definesCollector;
#endif
cOpenClHardware *hardware;
private:
QMutex lock;
bool locked;
bool useBuildCache;
bool useFastRelaxedMath;
QByteArray lastProgramHash;
QByteArray lastBuildParametersHash;
signals:
void showErrorMessage(QString, cErrorMessage::enumMessageType, QWidget *);
};
#endif /* MANDELBULBER2_SRC_OPENCL_ENGINE_H_ */
|
/*
Copyright (C) 2013 Jakub Woźniak
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 LOGIC_H
#define LOGIC_H
void debug(char *msg, ...);
void sigint_cleanup(int signum);
void add_new_player(player *players[32], int *pcount, login_msg login, int queue_key);
int listen_commands(player *player);
void add_new_game(player *player, game *games[32], game_state *states);
#endif
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.