text stringlengths 4 6.14k |
|---|
#ifndef GENERATE_PARENTHESES_H_
#define GENERATE_PARENTHESES_H_
#include <string>
#include <vector>
// Method 1
// This will go from (((((( to ))))))) and verify each combination
unsigned long getMaxSupported(int n);
bool isValidParenthesis(unsigned long value, unsigned int bits);
std::string generateParenthesis(unsigned int value, unsigned int bits);
std::vector<std::string> generateParenthesis(int n);
// Method 2
void build(int left, int right, int n, std::string s, std::vector<std::string> &res);
std::vector<std::string> generateParenthesis2(int n);
#endif // GENERATE_PARENTHESES_H_
|
/* Functions to get information about Windows operating system.
Copyright (C) 2006 Artica ST.
Written by Esteban Sanchez.
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, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PANDORA_WINDOWS_INFO_H__
#define __PANDORA_WINDOWS_INFO_H__
#include <windows.h>
#include "../pandora.h"
#include <list>
#include <string>
#include "pandora_wmi.h"
using namespace Pandora;
using namespace std;
/**
* Windows information functions.
*/
namespace Pandora_Windows_Info {
string getOSName ();
string getOSVersion ();
string getOSBuild ();
string getSystemName ();
string getSystemAddress ();
string getSystemPath ();
HANDLE *getProcessHandles (string name, int *num_procs);
string getRegistryValue (HKEY root, const string treepath, const string keyname);
int getSoftware (list<string> &rows, string separator);
}
#endif
|
/*
*
* WPA supplicant library with GLib integration
*
* Copyright (C) 2012 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <dbus/dbus.h>
#define SUPPLICANT_SERVICE "fi.w1.wpa_supplicant1"
#define SUPPLICANT_INTERFACE "fi.w1.wpa_supplicant1"
#define SUPPLICANT_PATH "/fi/w1/wpa_supplicant1"
typedef void (*supplicant_dbus_array_function) (DBusMessageIter *iter,
void *user_data);
typedef void (*supplicant_dbus_property_function) (const char *key,
DBusMessageIter *iter, void *user_data);
typedef void (*supplicant_dbus_setup_function) (DBusMessageIter *iter,
void *user_data);
typedef void (*supplicant_dbus_result_function) (const char *error,
DBusMessageIter *iter, void *user_data);
void supplicant_dbus_property_append_array(DBusMessageIter *iter,
const char *key, int type,
supplicant_dbus_array_function function,
void *user_data);
void supplicant_dbus_setup(DBusConnection *conn);
void supplicant_dbus_array_foreach(DBusMessageIter *iter,
supplicant_dbus_array_function function,
void *user_data);
void supplicant_dbus_property_foreach(DBusMessageIter *iter,
supplicant_dbus_property_function function,
void *user_data);
int supplicant_dbus_property_get_all(const char *path, const char *interface,
supplicant_dbus_property_function function,
void *user_data);
int supplicant_dbus_property_get(const char *path, const char *interface,
const char *method,
supplicant_dbus_property_function function,
void *user_data);
int supplicant_dbus_property_set(const char *path, const char *interface,
const char *key, const char *signature,
supplicant_dbus_setup_function setup,
supplicant_dbus_result_function function,
void *user_data);
int supplicant_dbus_method_call(const char *path,
const char *interface, const char *method,
supplicant_dbus_setup_function setup,
supplicant_dbus_result_function function,
void *user_data, DBusPendingCall **pending,
dbus_int32_t *slot);
void supplicant_dbus_call_callback(DBusPendingCall *call, dbus_int32_t slot);
void supplicant_dbus_property_append_basic(DBusMessageIter *iter,
const char *key, int type, void *val);
void supplicant_dbus_property_append_fixed_array(DBusMessageIter *iter,
const char *key, int type, void *val, int len);
static inline void supplicant_dbus_dict_open(DBusMessageIter *iter,
DBusMessageIter *dict)
{
dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
DBUS_DICT_ENTRY_END_CHAR_AS_STRING, dict);
}
static inline void supplicant_dbus_dict_close(DBusMessageIter *iter,
DBusMessageIter *dict)
{
dbus_message_iter_close_container(iter, dict);
}
static inline void supplicant_dbus_dict_append_basic(DBusMessageIter *dict,
const char *key, int type, void *val)
{
DBusMessageIter entry;
dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
NULL, &entry);
supplicant_dbus_property_append_basic(&entry, key, type, val);
dbus_message_iter_close_container(dict, &entry);
}
static inline void
supplicant_dbus_dict_append_fixed_array(DBusMessageIter *dict,
const char *key, int type, void *val, int len)
{
DBusMessageIter entry;
dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
NULL, &entry);
supplicant_dbus_property_append_fixed_array(&entry, key, type, val, len);
dbus_message_iter_close_container(dict, &entry);
}
static inline void
supplicant_dbus_dict_append_array(DBusMessageIter *dict,
const char *key, int type,
supplicant_dbus_array_function function,
void *user_data)
{
DBusMessageIter entry;
dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
NULL, &entry);
supplicant_dbus_property_append_array(&entry, key, type,
function, user_data);
dbus_message_iter_close_container(dict, &entry);
}
|
/******************************************************************************
* population.h
*
* Source of KaHIP -- Karlsruhe High Quality Partitioning.
*
*****************************************************************************/
#ifndef POPULATION_AEFH46G6
#define POPULATION_AEFH46G6
#include <sstream>
#include "data_structure/graph_access.h"
#include "partition_config.h"
#include "timer.h"
struct Individuum {
int* partition_map;
EdgeWeight objective;
std::vector<EdgeID>* cut_edges; //sorted
};
struct ENC {
std::vector<NodeID> vertices;
};
class population {
public:
population( const PartitionConfig & config );
virtual ~population();
void createIndividuum(const PartitionConfig & config,
graph_access & G,
Individuum & ind,
bool output);
void combine(const PartitionConfig & config,
graph_access & G,
Individuum & first_ind,
Individuum & second_ind,
Individuum & output_ind);
void combine_cross(const PartitionConfig & partition_config,
graph_access & G,
Individuum & first_ind,
Individuum & output_ind);
void mutate_random(const PartitionConfig & partition_config,
graph_access & G,
Individuum & first_ind);
void insert(graph_access & G, Individuum & ind);
void set_pool_size(int size);
void extinction();
void get_two_random_individuals(Individuum & first, Individuum & second);
void get_one_individual_tournament(Individuum & first);
void get_two_individuals_tournament(Individuum & first, Individuum & second);
void replace(Individuum & in, Individuum & out);
void get_random_individuum(Individuum & ind);
void get_best_individuum(Individuum & ind);
bool is_full();
void apply_fittest( graph_access & G, EdgeWeight & objective);
unsigned size() { return m_internal_population.size(); }
void print();
void write_log(std::string & filename);
private:
unsigned m_no_partition_calls;
unsigned m_population_size;
std::vector<Individuum> m_internal_population;
std::vector< std::vector< unsigned int > > m_vertex_ENCs;
std::vector< ENC > m_ENCs;
int m_num_NCs;
int m_num_NCs_computed;
int m_num_ENCs;
int m_time_stamp;
std::stringstream m_filebuffer_string;
timer_x m_global_timer;
};
#endif /* end of include guard: POPULATION_AEFH46G6 */
|
#include "dpoMatrix.h"
SEXP dpoMatrix_validate(SEXP obj)
{
int i, n = INTEGER(GET_SLOT(obj, Matrix_DimSym))[0];
int np1 = n + 1;
double *x = REAL(GET_SLOT(obj, Matrix_xSym));
/* quick but nondefinitive check on positive definiteness */
for (i = 0; i < n; i++)
if (x[i * np1] < 0)
return mkString(_("dpoMatrix is not positive definite"));
return ScalarLogical(1);
}
SEXP dpoMatrix_chol(SEXP x)
{
SEXP val = get_factors(x, "Cholesky"),
dimP = GET_SLOT(x, Matrix_DimSym),
uploP = GET_SLOT(x, Matrix_uploSym);
const char *uplo = CHAR(STRING_ELT(uploP, 0));
int *dims = INTEGER(dimP), info;
int n = dims[0];
double *vx;
if (val != R_NilValue) return val;// use x@factors$Cholesky if available
dims = INTEGER(dimP);
val = PROTECT(NEW_OBJECT(MAKE_CLASS("Cholesky")));
SET_SLOT(val, Matrix_uploSym, duplicate(uploP));
SET_SLOT(val, Matrix_diagSym, mkString("N"));
SET_SLOT(val, Matrix_DimSym, duplicate(dimP));
vx = REAL(ALLOC_SLOT(val, Matrix_xSym, REALSXP, n * n));
AZERO(vx, n * n);
F77_CALL(dlacpy)(uplo, &n, &n, REAL(GET_SLOT(x, Matrix_xSym)), &n, vx, &n);
if (n > 0) {
F77_CALL(dpotrf)(uplo, &n, vx, &n, &info);
if (info) {
if(info > 0)
error(_("the leading minor of order %d is not positive definite"),
info);
else /* should never happen! */
error(_("Lapack routine %s returned error code %d"), "dpotrf", info);
}
}
UNPROTECT(1);
return set_factors(x, val, "Cholesky");
}
SEXP dpoMatrix_rcond(SEXP obj, SEXP type)
{
SEXP Chol = dpoMatrix_chol(obj);
const char typnm[] = {'O', '\0'}; /* always use the one norm */
int *dims = INTEGER(GET_SLOT(Chol, Matrix_DimSym)), info;
double anorm = get_norm_sy(obj, typnm), rcond;
F77_CALL(dpocon)(uplo_P(Chol),
dims, REAL(GET_SLOT(Chol, Matrix_xSym)),
dims, &anorm, &rcond,
(double *) R_alloc(3*dims[0], sizeof(double)),
(int *) R_alloc(dims[0], sizeof(int)), &info);
return ScalarReal(rcond);
}
SEXP dpoMatrix_solve(SEXP x)
{
SEXP Chol = dpoMatrix_chol(x);
SEXP val = PROTECT(NEW_OBJECT(MAKE_CLASS("dpoMatrix")));
int *dims = INTEGER(GET_SLOT(x, Matrix_DimSym)), info;
SET_SLOT(val, Matrix_factorSym, allocVector(VECSXP, 0));
slot_dup(val, Chol, Matrix_uploSym);
slot_dup(val, Chol, Matrix_xSym);
slot_dup(val, Chol, Matrix_DimSym);
SET_SLOT(val, Matrix_DimNamesSym,
duplicate(GET_SLOT(x, Matrix_DimNamesSym)));
F77_CALL(dpotri)(uplo_P(val), dims,
REAL(GET_SLOT(val, Matrix_xSym)), dims, &info);
UNPROTECT(1);
return val;
}
SEXP dpoMatrix_dgeMatrix_solve(SEXP a, SEXP b)
{
SEXP Chol = dpoMatrix_chol(a),
val = PROTECT(NEW_OBJECT(MAKE_CLASS("dgeMatrix")));
int *adims = INTEGER(GET_SLOT(a, Matrix_DimSym)),
*bdims = INTEGER(GET_SLOT(b, Matrix_DimSym)),
info;
if (adims[1] != bdims[0])
error(_("Dimensions of system to be solved are inconsistent"));
if (adims[0] < 1 || bdims[1] < 1)
error(_("Cannot solve() for matrices with zero extents"));
SET_SLOT(val, Matrix_factorSym, allocVector(VECSXP, 0));
slot_dup(val, b, Matrix_DimSym);
slot_dup(val, b, Matrix_xSym);
F77_CALL(dpotrs)(uplo_P(Chol), adims, bdims + 1,
REAL(GET_SLOT(Chol, Matrix_xSym)), adims,
REAL(GET_SLOT(val, Matrix_xSym)),
bdims, &info);
UNPROTECT(1);
return val;
}
SEXP dpoMatrix_matrix_solve(SEXP a, SEXP b)
{
SEXP Chol = dpoMatrix_chol(a),
val = PROTECT(duplicate(b));
int *adims = INTEGER(GET_SLOT(a, Matrix_DimSym)),
*bdims = INTEGER(getAttrib(b, R_DimSymbol)),
info;
if (!(isReal(b) && isMatrix(b)))
error(_("Argument b must be a numeric matrix"));
if (*adims != *bdims || bdims[1] < 1 || *adims < 1)
error(_("Dimensions of system to be solved are inconsistent"));
F77_CALL(dpotrs)(uplo_P(Chol), adims, bdims + 1,
REAL(GET_SLOT(Chol, Matrix_xSym)), adims,
REAL(val), bdims, &info);
UNPROTECT(1);
return val;
}
|
//
// IBCAppDelegate.h
// iBeacon
//
// Created by 羽田 健太郎 on 2013/12/01.
// Copyright (c) 2013年 羽田 健太郎. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "IBCCommon.h"
@interface IBCAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
|
/***************************************************************************
* *
* LinuxSampler - modular, streaming capable sampler *
* *
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
* Copyright (C) 2005 - 2010 Christian Schoenebeck *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
* MA 02111-1307 USA *
***************************************************************************/
#ifndef __LS_GIG_EGADSR_H__
#define __LS_GIG_EGADSR_H__
#include "../common/EG.h"
namespace LinuxSampler { namespace gig {
/**
* ADSR Envelope Generator
*
* Envelope Generator with stage 'Attack', 'Attack_Hold', 'Decay_1',
* 'Decay_2', 'Sustain' and 'Release' for modulating arbitrary synthesis
* parameters.
*/
class EGADSR : public EG {
public:
/**
* Will be called by the voice when the key / voice was triggered.
*
* @param PreAttack - Preattack value for the envelope
* (0 - 1000 permille)
* @param AttackTime - Attack time for the envelope
* (0.000 - 60.000s)
* @param HoldAttack - if true, Decay1 will be postponed until the
* sample reached the sample loop start.
* @param Decay1Time - Decay1 time of the sample amplitude EG
* (0.000 - 60.000s)
* @param Decay2Time - only if !InfiniteSustain: 2nd decay stage
* time of the sample amplitude EG
* (0.000 - 60.000s)
* @param InfiniteSustain - if true, instead of going into Decay2
* stage, Decay1 level will be hold until note
* will be released
* @param SustainLevel - Sustain level of the sample amplitude EG
* (0 - 1000 permille)
* @param ReleaseTIme - Release time for the envelope
* (0.000 - 60.000s)
* @param Volume - volume the sample will be played at
* (0.0 - 1.0) - used when calculating the
* exponential curve parameters.
* @param SampleRate - sample rate of used audio output driver
*/
void trigger(uint PreAttack, float AttackTime, bool HoldAttack, float Decay1Time, double Decay2Time, bool InfiniteSustain, uint SustainLevel, float ReleaseTime, float Volume, uint SampleRate); //FIXME: we should better use 'float' for SampleRate
/**
* Should be called to inform the EG about an external event and
* also whenever an envelope stage is completed. This will handle
* the envelope's transition to the respective next stage.
*
* @param Event - what happened
*/
void update(event_t Event, uint SampleRate);
private:
enum stage_t {
stage_attack,
stage_attack_hold,
stage_decay1_part1,
stage_decay1_part2,
stage_decay2,
stage_sustain,
stage_release_part1,
stage_release_part2,
stage_fadeout,
stage_end
};
stage_t Stage;
bool HoldAttack;
bool InfiniteSustain;
float Decay1Time;
float Decay1Level2;
float Decay1Slope;
float Decay2Time;
float SustainLevel;
float ReleaseCoeff;
float ReleaseCoeff2;
float ReleaseCoeff3;
float ReleaseLevel2;
float ReleaseSlope;
float invVolume;
float ExpOffset;
void enterAttackStage(const uint PreAttack, const float AttackTime, const uint SampleRate);
void enterAttackHoldStage();
void enterDecay1Part1Stage(const uint SampleRate);
void enterDecay1Part2Stage(const uint SampleRate);
void enterDecay2Stage(const uint SampleRate);
void enterSustainStage();
void enterReleasePart1Stage();
void enterReleasePart2Stage();
};
}} // namespace LinuxSampler::gig
#endif // __LS_GIG_EGADSR_H__
|
/****************************************************************************
Copyright (c) 2000 - 2010 Novell, Inc.
All Rights Reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, contact Novell, Inc.
To contact Novell about this file by physical or electronic mail,
you may find current contact information at www.novell.com
****************************************************************************
File: YCPTableItemParser.h
Author: Stefan Hundhammer <shundhammer@suse.de>
/-*/
#ifndef YCPTableItemParser_h
#define YCPTableItemParser_h
#include <ycp/YCPTerm.h>
#include "YCPTableItem.h"
/**
* Parser for table item lists
**/
class YCPTableItemParser
{
public:
/**
* Parse a table item list:
*
* [
* `item(`id(`myID1 ), "Label1", "Label2", "Label3" ),
* `item(`id(`myID2 ), "Label1", `cell("Label2"), "Label3" ),
* `item(`id(`myID3 ), "Label1", `cell(`icon( "icon2.png"), "Label2" ), "Label3" ),
* `item(`id(`myID4 ), "Label1", `cell( "Label2", `icon( "icon2.png")), "Label3" ),
* `item(`id(`myID5 ), "Label1", "Label2", "Label3",
* [
* `item(`id(`myId51, "Label1", "Label2", "Label3")),
* `item(`id(`myId52, "Label1", "Label2", "Label3"))
* ],
* `open),
* `item(`id(`myID6 ), "Label1", "Label2", "Label3",
* [
* `item(`id(`myId61, "Label1", "Label2", "Label3")),
* `item(`id(`myId62, "Label1", "Label2", "Label3"))
* ],
* `closed),
* ]
*
* Return a list of newly created YTableItem-derived objects.
*
* This function throws exceptions if there are syntax errors.
**/
static YItemCollection parseTableItemList( const YCPList & ycpItemList );
protected:
/**
* Parse an item term; one of:
*
* `item(`id(`myID1 ), "Label1", "Label2", "Label3" )
* `item(`id(`myID2 ), "Label1", `cell( "Label2" ), "Label3" )
* `item(`id(`myID3 ), "Label1", `cell(`icon( "icon2.png" ), "Label2" ), "Label3" )
* `item(`id(`myID4 ), "Label1", `cell( "Label2", `icon( "icon2.png")), "Label3" )
*
* `item(`id(`myID5 ), "Label1", "Label2", "Label3",
* [
* `item(`id(`myId51, "Label1", "Label2", "Label3")),
* `item(`id(`myId52, "Label1", "Label2", "Label3"))
* ],
* `open)
*
* `item(`id(`myID6 ), "Label1", "Label2", "Label3",
* [
* `item(`id(`myId61, "Label1", "Label2", "Label3")),
* `item(`id(`myId62, "Label1", "Label2", "Label3"))
* ],
* `closed)
*
* `cell() is optional if there is only a label and no icon for that cell.
*
* This function throws exceptions if there are syntax errors.
**/
static YCPTableItem * parseTableItem( const YCPTerm & itemTerm );
/**
* Parse a cell term and add a YTableCell to the parent YCPTableItem:
*
* `cell( "Label" )
* `cell( `icon( "icon.png"), "Label" )
* `cell( "Label", `icon( "icon.png" ) )
**/
static void parseTableCell( YCPTableItem * parent, const YCPTerm & cellTerm );
};
#endif // YCPTableItemParser_h
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_EXTENSIONS_API_IDENTITY_GAIA_WEB_AUTH_FLOW_H_
#define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_GAIA_WEB_AUTH_FLOW_H_
#include "chrome/browser/extensions/api/identity/web_auth_flow.h"
#include "chrome/browser/signin/ubertoken_fetcher.h"
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/common/extensions/api/identity/oauth2_manifest_handler.h"
namespace extensions {
class GaiaWebAuthFlow : public UbertokenConsumer, public WebAuthFlow::Delegate {
public:
enum Failure {
WINDOW_CLOSED,
INVALID_REDIRECT,
SERVICE_AUTH_ERROR,
OAUTH_ERROR,
LOAD_FAILED
};
class Delegate {
public:
virtual void OnGaiaFlowFailure(Failure failure,
GoogleServiceAuthError service_error,
const std::string& oauth_error) = 0;
virtual void OnGaiaFlowCompleted(const std::string& access_token,
const std::string& expiration) = 0;
};
GaiaWebAuthFlow(Delegate* delegate,
Profile* profile,
const std::string& extension_id,
const OAuth2Info& oauth2_info,
const std::string& locale);
virtual ~GaiaWebAuthFlow();
virtual void Start();
virtual void OnUbertokenSuccess(const std::string& token) OVERRIDE;
virtual void OnUbertokenFailure(const GoogleServiceAuthError& error) OVERRIDE;
virtual void OnAuthFlowFailure(WebAuthFlow::Failure failure) OVERRIDE;
virtual void OnAuthFlowURLChange(const GURL& redirect_url) OVERRIDE;
virtual void OnAuthFlowTitleChange(const std::string& title) OVERRIDE;
private:
virtual scoped_ptr<WebAuthFlow> CreateWebAuthFlow(GURL url);
Delegate* delegate_;
Profile* profile_;
chrome::HostDesktopType host_desktop_type_;
std::string redirect_scheme_;
std::string redirect_path_prefix_;
GURL auth_url_;
scoped_ptr<UbertokenFetcher> ubertoken_fetcher_;
scoped_ptr<WebAuthFlow> web_flow_;
DISALLOW_COPY_AND_ASSIGN(GaiaWebAuthFlow);
};
}
#endif
|
/**
* UGENE - Integrated Bioinformatics Tools.
* Copyright (C) 2008-2017 UniPro <ugene@unipro.ru>
* http://ugene.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#ifndef _U2_TREE_VIEWER_STATE_H_
#define _U2_TREE_VIEWER_STATE_H_
#include <U2Core/U2Region.h>
#include <U2Core/GObject.h>
#include <QtCore/QVariant>
namespace U2 {
class TreeViewer;
class U2VIEW_EXPORT TreeViewerState {
public:
TreeViewerState(){}
TreeViewerState(const QVariantMap& _stateData) : stateData(_stateData){}
static QVariantMap saveState(TreeViewer* v);
bool isValid() const;
GObjectReference getPhyObject() const;
void setPhyObject(const GObjectReference& ref);
qreal getVerticalZoom() const;
void setVerticalZoom(qreal s);
qreal getHorizontalZoom() const;
void setHorizontalZoom(qreal s);
QTransform getTransform() const;
void setTransform(const QTransform& m);
QVariantMap stateData;
};
} // namespace
#endif
|
// Copyright Hugh Perkins 2004
//
// 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 PURVector3E. 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 in the file licence.txt; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-
// 1307 USA
// You can find the licence also on the web at:
// http://www.opensource.org/licenses/gpl-license.php
//
//! \file
//! \brief mvGraphicsInterface is a pure virtual interface class for mvGraphics
#ifndef _MVGRAPHICSINTERFACE_H
#define _MVGRAPHICSINTERFACE_H
#include <string.h>
#include "BasicTypes.h"
//! mvGraphicsInterface is a pure virtual interface class for mvGraphics
//! mgraphics contains certain wrapper routines around OpenGL/GLUT
//! for the moment, it contains routines to display text on the screen
//! and to rotate to a passed in quaternion (OpenGL expects axis/angle)
//!
//! This is the abstract pure virtual interface class, to reduce link dependencies
//!
//! See mvGraphics (mvGraphics.h) for documentation
class mvGraphicsInterface
{
public:
virtual void printtext( char * string) = 0;
virtual void screenprinttext(int x, int y, char * string) = 0;
virtual float GetScalingFrom3DToScreen( float fDepth ) = 0;
virtual void RotateToRot( Rot &rot ) = 0;
virtual void SetColor( float r, float g, float b ) = 0;
virtual void DrawWireframeBox( int iNumSlices ) = 0;
virtual void DoCone() = 0;
virtual void DoCube() = 0;
virtual void DoSphere() = 0;
virtual void DoCylinder() = 0;
virtual void DoWireSphere() = 0;
virtual void RenderHeightMap( unsigned char *g_HeightMap, int iMapSize ) = 0;
virtual void RenderTerrain( unsigned char *g_HeightMap, int iMapSize ) = 0;
virtual void DrawSquareXYPlane() = 0;
virtual void DrawParallelSquares( int iNumSlices ) = 0;
virtual void Translatef( float x, float y, float z ) = 0;
virtual void Rotatef( float fAngleDegrees, float fX, float fY, float fZ) = 0;
virtual void Scalef( float x, float y, float z ) = 0;
virtual void Bind2DTexture( int iTextureID ) = 0;
virtual void PopMatrix() = 0;
virtual void PushMatrix() = 0;
virtual void SetMaterialColor(float *mcolor) = 0;
virtual void RasterPos3f(float x, float y, float z ) = 0;
};
#endif // _MVGRAPHICSINTERFACE_H
|
// Copyright (c) 2012- PPSSPP Project.
// 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 2.0 or later versions.
// 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#pragma once
#include <string>
#include <vector>
#include <map>
#include "ui/screen.h"
#include "ui/ui.h"
#include "file/file_util.h"
class LogoScreen : public Screen
{
public:
LogoScreen(const std::string &bootFilename)
: bootFilename_(bootFilename), frames_(0) {}
void key(const KeyInput &key);
void update(InputState &input);
void render();
void sendMessage(const char *message, const char *value);
private:
void Next();
std::string bootFilename_;
int frames_;
};
class MenuScreen : public Screen
{
public:
MenuScreen();
void update(InputState &input);
void render();
void sendMessage(const char *message, const char *value);
void dialogFinished(const Screen *dialog, DialogResult result);
private:
int frames_;
bool showAtracShortcut_;
};
// Dialog box, meant to be pushed
class PauseScreen : public Screen
{
public:
void update(InputState &input);
void render();
virtual void sendMessage(const char *msg, const char *value);
struct Message
{
Message(const char *m, const char *v)
: msg(m), value(v) {}
const char *msg;
const char *value;
};
virtual void *dialogData()
{
return m_data;
}
PauseScreen() : m_data(NULL) {}
private:
Message* m_data;
};
class SettingsScreen : public Screen
{
public:
void update(InputState &input);
void render();
};
class DeveloperScreen : public Screen
{
public:
void update(InputState &input);
void render();
};
class AudioScreen : public Screen
{
public:
void update(InputState &input);
void render();
};
class GraphicsScreenP1 : public Screen
{
public:
void update(InputState &input);
void render();
};
class GraphicsScreenP2 : public Screen
{
public:
void update(InputState &input);
void render();
};
class GraphicsScreenP3 : public Screen
{
public:
void update(InputState &input);
void render();
};
class SystemScreen : public Screen
{
public:
void update(InputState &input);
void render();
};
class LanguageScreen : public Screen
{
public:
LanguageScreen();
void update(InputState &input);
void render();
private:
std::vector<FileInfo> langs_;
std::map<std::string, std::pair<std::string, int>> langValuesMapping;
};
class ControlsScreen : public Screen
{
public:
void update(InputState &input);
void render();
};
class KeyMappingScreen : public Screen
{
public:
KeyMappingScreen() : currentMap_(0) {}
void update(InputState &input);
void render();
private:
int currentMap_;
};
// Dialog box, meant to be pushed
class KeyMappingNewKeyDialog : public Screen
{
public:
KeyMappingNewKeyDialog(int btn, int currentMap) {
pspBtn = btn;
last_kb_deviceid = 0;
last_kb_key = 0;
last_axis_deviceid = 0;
last_axis_id = -1;
currentMap_ = currentMap;
}
void update(InputState &input);
void render();
void key(const KeyInput &key);
void axis(const AxisInput &axis);
private:
int pspBtn;
int last_kb_deviceid;
int last_kb_key;
int last_axis_deviceid;
int last_axis_id;
int last_axis_direction;
int currentMap_;
};
struct FileSelectScreenOptions {
const char* filter; // Enforced extension filter. Case insensitive, extensions separated by ":".
bool allowChooseDirectory;
int folderIcon;
std::map<std::string, int> iconMapping;
};
class FileSelectScreen : public Screen
{
public:
FileSelectScreen(const FileSelectScreenOptions &options);
void update(InputState &input);
void render();
// Override these to for example write the current directory to a config file.
virtual void onSelectFile() {}
virtual void onCancel() {}
void key(const KeyInput &key);
private:
void updateListing();
FileSelectScreenOptions options_;
UIList list_;
std::string currentDirectory_;
std::vector<FileInfo> listing_;
};
class CreditsScreen : public Screen
{
public:
CreditsScreen() : frames_(0) {}
void update(InputState &input);
void render();
private:
int frames_;
};
void DrawWatermark();
|
#ifndef UNITVECTOR_H
#define UNITVECTOR_H
#include "node.h"
class UnitVector : public Node
{
public:
UnitVector();
};
#endif // UNITVECTOR_H
|
#include "displaymenutabview.h"
cDisplayMenuTabView::cDisplayMenuTabView(cTemplateViewTab *tmplTab) : cView(tmplTab) {
}
cDisplayMenuTabView::~cDisplayMenuTabView() {
CancelSave();
}
void cDisplayMenuTabView::SetTokens(map < string, int > *intTokens, map < string, string > *stringTokens, map < string, vector< map< string, string > > > *loopTokens) {
this->intTokens = intTokens;
this->stringTokens = stringTokens;
this->loopTokens = loopTokens;
}
void cDisplayMenuTabView::Clear(void) {
Fill(0, clrTransparent);
}
void cDisplayMenuTabView::CreateTab(void) {
//Create Pixmap
if (!PixmapExists(0)) {
cSize drawportSize;
scrolling = tmplTab->CalculateDrawPortSize(drawportSize, loopTokens);
if (scrolling) {
CreateScrollingPixmap(0, tmplTab, drawportSize);
scrollingPix = 0;
scrollOrientation = orVertical;
scrollMode = smNone;
} else {
CreateViewPixmap(0, tmplTab);
}
}
}
void cDisplayMenuTabView::Render(void) {
if (tmplTab->DoDebug()) {
tmplTab->Debug();
}
//Draw Tab, flushing every loop
DrawPixmap(0, tmplTab, loopTokens, true);
}
bool cDisplayMenuTabView::KeyUp(void) {
if (!scrolling)
return false;
int scrollStep = tmplTab->GetScrollStep();
int aktHeight = DrawportY(0);
if (aktHeight >= 0) {
return false;
}
int newY = aktHeight + scrollStep;
if (newY > 0)
newY = 0;
SetDrawPortPoint(0, cPoint(0, newY));
return true;
}
bool cDisplayMenuTabView::KeyDown(void) {
if (!scrolling)
return false;
int scrollStep = tmplTab->GetScrollStep();
int aktHeight = DrawportY(0);
int totalHeight = DrawportHeight(0);
int screenHeight = Height(0);
if (totalHeight - ((-1)*aktHeight) == screenHeight) {
return false;
}
int newY = aktHeight - scrollStep;
if ((-1)*newY > totalHeight - screenHeight)
newY = (-1)*(totalHeight - screenHeight);
SetDrawPortPoint(0, cPoint(0, newY));
return true;
}
bool cDisplayMenuTabView::KeyLeft(void) {
if (!scrolling)
return false;
if (!PixmapExists(0))
return false;
int aktHeight = DrawportY(0);
int screenHeight = Height(0);
int newY = aktHeight + screenHeight;
if (newY > 0)
newY = 0;
SetDrawPortPoint(0, cPoint(0, newY));
return true;
}
bool cDisplayMenuTabView::KeyRight(void) {
if (!scrolling)
return false;
if (!PixmapExists(0))
return false;
int aktHeight = DrawportY(0);
int screenHeight = Height(0);
int totalHeight = DrawportHeight(0);
int newY = aktHeight - screenHeight;
if ((-1)*newY > totalHeight - screenHeight)
newY = (-1)*(totalHeight - screenHeight);
SetDrawPortPoint(0, cPoint(0, newY));
return true;
}
void cDisplayMenuTabView::GetScrollbarPosition(int &barTop, int &barHeight) {
int y = (-1)*DrawportY(0);
int totalHeight = DrawportHeight(0);
int screenHeight = Height(0);
if (totalHeight == 0)
return;
if (totalHeight <= screenHeight)
barHeight = 1000;
else {
barHeight = (double)screenHeight / (double) totalHeight * 1000;
}
barTop = (double)y / (double) totalHeight * 1000;
}
void cDisplayMenuTabView::Action(void) {
Render();
DoFlush();
} |
/*
** gba_destroy_image.c for libmgba in /home/poirie_l/Documents/Epitech/modules/igraph/mgba/sources
**
** Made by Louis Poirier
** Login <poirie_l@epitech.net>
**
** Started on Thu Dec 26 17:28:47 2013 Louis Poirier
** Last update Thu Dec 26 17:30:24 2013 Louis Poirier
*/
#include "mgba.h"
u8 gba_destroy_image(t_img *img)
{
if (img == NULL)
return (1);
free(img->image);
img->width = 0;
img->height = 0;
return (0);
}
|
/*******************************************************************************
* Copyright (c) 2012-2014, The Microsystems Design Labratory (MDL)
* Department of Computer Science and Engineering, The Pennsylvania State University
* All rights reserved.
*
* This source code is part of NVMain - A cycle accurate timing, bit accurate
* energy simulator for both volatile (e.g., DRAM) and non-volatile memory
* (e.g., PCRAM). The source code is free and you can redistribute and/or
* modify it by providing 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 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.
*
* Author list:
* Matt Poremba ( Email: mrp5060 at psu dot edu
* Website: http://www.cse.psu.edu/~poremba/ )
*******************************************************************************/
#ifndef __INTERCONNECT_ONCHIPBUS_H__
#define __INTERCONNECT_ONCHIPBUS_H__
#include "src/Rank.h"
#include "src/Interconnect.h"
#include <iostream>
namespace NVM {
class OnChipBus : public Interconnect
{
public:
OnChipBus( );
~OnChipBus( );
void SetConfig( Config *c, bool createChildren = true );
bool IssueCommand( NVMainRequest *mop );
bool IsIssuable( NVMainRequest *mop, FailReason *reason = NULL );
void CalculateStats( );
void Cycle( ncycle_t steps );
Rank *GetRank( ncounter_t rank ) { return ranks[rank]; }
private:
bool configSet;
ncounter_t numRanks;
double syncValue;
Config *conf;
Rank **ranks;
};
};
#endif
|
/**
* UGENE - Integrated Bioinformatics Tools.
* Copyright (C) 2008-2017 UniPro <ugene@unipro.ru>
* http://ugene.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#ifndef _U2_FIND_ENZYMES_ALGO_H_
#define _U2_FIND_ENZYMES_ALGO_H_
#include <U2Algorithm/EnzymeModel.h>
#include <U2Core/Task.h>
#include <U2Core/U2Region.h>
#include <U2Core/DNAAlphabet.h>
#include <U2Core/DNASequence.h>
#include <U2Core/U2Type.h>
#include <U2Core/DNATranslation.h>
#include <U2Core/TextUtils.h>
#include <U2Core/U2SafePoints.h>
#include <U2Core/AppContext.h>
#include <QtCore/QObject>
#include <QtCore/QList>
namespace U2 {
class FindEnzymesAlgListener {
public:
~FindEnzymesAlgListener(){}
virtual void onResult(int pos, const SEnzymeData& enzyme, const U2Strand& strand) = 0;
};
template <typename CompareFN>
class FindEnzymesAlgorithm {
public:
void run(const DNASequence& sequence, const U2Region& range, const SEnzymeData& enzyme, FindEnzymesAlgListener* l, TaskStateInfo& ti, int resultPosShift=0) {
SAFE_POINT(enzyme->alphabet != NULL, "No enzyme alphabet", );
// look for results in direct strand
run(sequence, range, enzyme, enzyme->seq.constData(), U2Strand::Direct, l, ti, resultPosShift);
// if enzyme is not symmetric - look in complementary strand too
DNATranslation* tt = AppContext::getDNATranslationRegistry()->lookupComplementTranslation(enzyme->alphabet);
if (tt == NULL) {
return;
}
QByteArray revCompl = enzyme->seq;
tt->translate(revCompl.data(), revCompl.size());
TextUtils::reverse(revCompl.data(), revCompl.size());
if (revCompl == enzyme->seq) {
return;
}
run(sequence, range, enzyme, revCompl.constData(), U2Strand::Complementary, l, ti, resultPosShift);
}
void run(const DNASequence& sequence, const U2Region& range, const SEnzymeData& enzyme,
const char* pattern, U2Strand stand, FindEnzymesAlgListener* l, TaskStateInfo& ti, int resultPosShift=0)
{
CompareFN fn(sequence.alphabet, enzyme->alphabet);
const char* seq = sequence.constData();
char unknownChar = sequence.alphabet->getDefaultSymbol();
int plen = enzyme->seq.length();
for (int s = range.startPos, n = range.endPos() - plen + 1; s < n && !ti.cancelFlag; s++) {
bool match = matchSite(seq + s, pattern, plen, unknownChar, fn);
if (match) {
l->onResult(resultPosShift + s, enzyme, stand);
}
}
if (sequence.circular) {
if ( range.startPos + range.length == sequence.length() ) {
QByteArray buf;
const QByteArray& dnaseq = sequence.seq;
int size = enzyme->seq.size() - 1;
int startPos = dnaseq.length() - size;
buf.append(dnaseq.mid(startPos));
buf.append(dnaseq.mid(0, size));
for (int s = 0; s < size; s++) {
bool match = matchSite(buf.constData() + s, pattern, plen, unknownChar, fn);
if (match) {
l->onResult(resultPosShift + s + startPos, enzyme, stand);
}
}
}
}
}
bool matchSite(const char* seq, const char* pattern, int plen, char unknownChar, const CompareFN& fn) {
bool match = true;
for (int p=0; p < plen && match; p++) {
char c1 = seq[p];
char c2 = pattern[p];
match = (c1 != unknownChar && fn.equals(c2, c1));
}
return match;
}
};
} //namespace
#endif
|
/*
* download-objects.h
*
* Copyright 2010 Brett Mravec <brett.mravec@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.
*/
#include "http-download.h"
#include "ftp-download.h"
typedef Download* (*DownloadCreateFuncVec) (std::vector<std::string>&);
typedef Download* (*DownloadCreateFunc) ();
typedef struct {
const DRegex *regex;
DownloadCreateFuncVec func_vec;
DownloadCreateFunc func;
} DownloadCreatePair;
static DownloadCreatePair dos [] = {
{ &HttpDownload::MATCH_REGEX, HttpDownload::create, HttpDownload::create },
{ &FtpDownload::MATCH_REGEX, FtpDownload::create, FtpDownload::create },
{ NULL, NULL, NULL},
};
|
#pragma once
/*
* Copyright (C) 2005-2012 Team XBMC
* http://www.xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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 XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
enum ERENDERFEATURE
{
RENDERFEATURE_GAMMA,
RENDERFEATURE_BRIGHTNESS,
RENDERFEATURE_CONTRAST,
RENDERFEATURE_NOISE,
RENDERFEATURE_SHARPNESS,
RENDERFEATURE_NONLINSTRETCH,
RENDERFEATURE_ROTATION,
RENDERFEATURE_STRETCH,
RENDERFEATURE_CROP,
RENDERFEATURE_ZOOM,
RENDERFEATURE_VERTICAL_SHIFT,
RENDERFEATURE_PIXEL_RATIO,
RENDERFEATURE_POSTPROCESS
};
typedef std::vector<int> Features;
|
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
/*
Sonic Visualiser
An audio file viewer and annotation editor.
Centre for Digital Music, Queen Mary, University of London.
This file copyright 2006 Chris Cannam.
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. See the file
COPYING included with this distribution for more information.
*/
#ifndef _CODED_AUDIO_FILE_READER_H_
#define _CODED_AUDIO_FILE_READER_H_
#include "AudioFileReader.h"
#include <sndfile.h>
#include <QMutex>
#include <QReadWriteLock>
class WavFileReader;
class Serialiser;
class Resampler;
class CodedAudioFileReader : public AudioFileReader
{
Q_OBJECT
public:
virtual ~CodedAudioFileReader();
enum CacheMode {
CacheInTemporaryFile,
CacheInMemory
};
virtual void getInterleavedFrames(size_t start, size_t count,
SampleBlock &frames) const;
virtual size_t getNativeRate() const { return m_fileRate; }
signals:
void progress(int);
protected:
CodedAudioFileReader(CacheMode cacheMode, size_t targetRate);
void initialiseDecodeCache(); // samplerate, channels must have been set
// may throw InsufficientDiscSpace:
void addSamplesToDecodeCache(float **samples, size_t nframes);
void addSamplesToDecodeCache(float *samplesInterleaved, size_t nframes);
void addSamplesToDecodeCache(const SampleBlock &interleaved);
// may throw InsufficientDiscSpace:
void finishDecodeCache();
bool isDecodeCacheInitialised() const { return m_initialised; }
void startSerialised(QString id);
void endSerialised();
private:
void pushBuffer(float *interleaved, size_t sz, bool final);
protected:
QMutex m_cacheMutex;
CacheMode m_cacheMode;
SampleBlock m_data;
mutable QReadWriteLock m_dataLock;
bool m_initialised;
Serialiser *m_serialiser;
size_t m_fileRate;
QString m_cacheFileName;
SNDFILE *m_cacheFileWritePtr;
WavFileReader *m_cacheFileReader;
float *m_cacheWriteBuffer;
size_t m_cacheWriteBufferIndex;
size_t m_cacheWriteBufferSize; // frames
Resampler *m_resampler;
float *m_resampleBuffer;
};
#endif
|
/**
* This header is generated by class-dump-z 0.2b.
*
* Source: /System/Library/PrivateFrameworks/DataAccess.framework/Frameworks/DAEAS.framework/DAEAS
*/
@protocol ASAccountActorMessages
- (oneway void)_accountPasswordChanged;
- (oneway void)_foldersThatExternalClientsCareAboutChanged;
- (oneway void)_folderHierarchyChanged;
- (oneway void)_folderUpdatedNotification:(id)notification;
- (oneway void)_daemonDiedNotification:(id)notification;
- (oneway void)_newASPolicyKeyNotification:(id)notification;
- (BOOL)reattemptInvitationLinkageForMetaData:(id)metaData inFolderWithId:(id)anId;
- (BOOL)isHotmailAccount;
- (id)deletedItemsFolder;
- (id)sentItemsFolder;
- (id)inboxFolder;
- (void)performFolderChange:(id)change;
- (int)performResolveRecipientsRequest:(id)request consumer:(id)consumer;
- (int)performFetchMessageSearchResultRequests:(id)requests consumer:(id)consumer;
- (int)performFetchAttachmentRequest:(id)request consumer:(id)consumer;
- (int)performMoveRequests:(id)requests consumer:(id)consumer;
- (int)performMailboxRequests:(id)requests mailbox:(id)mailbox previousTag:(id)tag consumer:(id)consumer;
- (int)performMailboxRequest:(id)request mailbox:(id)mailbox previousTag:(id)tag consumer:(id)consumer;
- (int)sendMessageWithRFC822Data:(id)rfc822Data messageID:(id)anId outgoingMessageType:(int)type originalMessageFolderID:(id)anId4 originalMessageItemID:(id)anId5 originalMessageLongID:(id)anId6 originalAccountID:(id)anId7 consumer:(id)consumer context:(void *)context;
- (BOOL)setFolderIdsThatExternalClientsCareAboutAdded:(id)added deleted:(id)deleted foldersTag:(id)tag;
- (id)folderIDsThatExternalClientsCareAboutForDataclasses:(int)dataclasses withTag:(id *)tag;
- (id)folderIDsThatExternalClientsCareAboutWithTag:(id *)tag;
- (oneway void)stopMonitoringAllFolders;
- (oneway void)stopMonitoringFoldersForUpdates:(id)updates;
- (oneway void)monitorFoldersForUpdates:(id)updates;
- (oneway void)setEncryptionIdentityPersistentReference:(id)reference;
- (id)encryptionIdentityPersistentReference;
- (oneway void)setSigningIdentityPersistentReference:(id)reference;
- (id)signingIdentityPersistentReference;
- (oneway void)setGeneratesBulletins:(BOOL)bulletins;
- (BOOL)generatesBulletins;
- (int)supportsEmailFlagging;
- (int)supportsMailboxSearch;
- (oneway void)setMailNumberOfPastDaysToSync:(int)sync;
- (int)mailNumberOfPastDaysToSync;
- (id)mailboxes;
- (oneway void)shutdown;
- (oneway void)setAccount:(id)account;
- (oneway void)startup;
- (BOOL)searchQueriesRunning;
- (oneway void)cancelAllSearchQueries;
- (oneway void)cancelSearchQuery:(id)query;
- (oneway void)performSearchQuery:(id)query;
- (oneway void)cancelTaskWithID:(int)anId;
@end
|
/*
* Copyright (C) 2005-2010 MaNGOS <http://getmangos.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _HOSTILEREFMANAGER
#define _HOSTILEREFMANAGER
#include "Common.h"
#include "Utilities/LinkedReference/RefManager.h"
class Unit;
class ThreatManager;
class HostileReference;
struct SpellEntry;
//=================================================
class HostileRefManager : public RefManager<Unit, ThreatManager>
{
private:
Unit *iOwner;
float m_redirectionMod;
ObjectGuid m_redirectionTargetGuid;
public:
explicit HostileRefManager(Unit *pOwner) { iOwner = pOwner; }
~HostileRefManager();
Unit* getOwner() { return iOwner; }
// send threat to all my hateres for the pVictim
// The pVictim is hated than by them as well
// use for buffs and healing threat functionality
void threatAssist(Unit *pVictim, float threat, SpellEntry const *threatSpell = 0, bool pSingleTarget=false);
void addThreatPercent(int32 pValue);
// The references are not needed anymore
// tell the source to remove them from the list and free the mem
void deleteReferences();
// Remove specific faction references
void deleteReferencesForFaction(uint32 faction);
HostileReference* getFirst() { return ((HostileReference* ) RefManager<Unit, ThreatManager>::getFirst()); }
void updateThreatTables();
void setOnlineOfflineState(bool pIsOnline);
// set state for one reference, defined by Unit
void setOnlineOfflineState(Unit *pCreature,bool pIsOnline);
// delete one reference, defined by Unit
void deleteReference(Unit *pCreature);
// redirection threat data
void SetThreatRedirection(ObjectGuid guid, uint32 pct)
{
m_redirectionTargetGuid = guid;
m_redirectionMod = pct/100.0f;
}
void ResetThreatRedirection()
{
m_redirectionTargetGuid.Clear();
m_redirectionMod = 0.0f;
}
float GetThreatRedirectionMod() const { return m_redirectionMod; }
Unit* GetThreatRedirectionTarget() const;
// owner of manager variable, back ref. to it, always exist
};
//=================================================
#endif
|
#include "drmP.h"
int drm_dma_setup(struct drm_device *dev)
{
int i;
dev->dma = kmalloc(sizeof(*dev->dma), GFP_KERNEL);
if (!dev->dma)
return -ENOMEM;
memset(dev->dma, 0, sizeof(*dev->dma));
for (i = 0; i <= DRM_MAX_ORDER; i++)
memset(&dev->dma->bufs[i], 0, sizeof(dev->dma->bufs[0]));
return 0;
}
void drm_dma_takedown(struct drm_device *dev)
{
struct drm_device_dma *dma = dev->dma;
int i, j;
if (!dma)
return;
for (i = 0; i <= DRM_MAX_ORDER; i++) {
if (dma->bufs[i].seg_count) {
DRM_DEBUG("order %d: buf_count = %d,"
" seg_count = %d\n",
i,
dma->bufs[i].buf_count,
dma->bufs[i].seg_count);
for (j = 0; j < dma->bufs[i].seg_count; j++) {
if (dma->bufs[i].seglist[j]) {
drm_pci_free(dev, dma->bufs[i].seglist[j]);
}
}
kfree(dma->bufs[i].seglist);
}
if (dma->bufs[i].buf_count) {
for (j = 0; j < dma->bufs[i].buf_count; j++) {
kfree(dma->bufs[i].buflist[j].dev_private);
}
kfree(dma->bufs[i].buflist);
}
}
kfree(dma->buflist);
kfree(dma->pagelist);
kfree(dev->dma);
dev->dma = NULL;
}
void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf)
{
if (!buf)
return;
buf->waiting = 0;
buf->pending = 0;
buf->file_priv = NULL;
buf->used = 0;
if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE)
&& waitqueue_active(&buf->dma_wait)) {
wake_up_interruptible(&buf->dma_wait);
}
}
void drm_core_reclaim_buffers(struct drm_device *dev,
struct drm_file *file_priv)
{
struct drm_device_dma *dma = dev->dma;
int i;
if (!dma)
return;
for (i = 0; i < dma->buf_count; i++) {
if (dma->buflist[i]->file_priv == file_priv) {
switch (dma->buflist[i]->list) {
case DRM_LIST_NONE:
drm_free_buffer(dev, dma->buflist[i]);
break;
case DRM_LIST_WAIT:
dma->buflist[i]->list = DRM_LIST_RECLAIM;
break;
default:
break;
}
}
}
}
EXPORT_SYMBOL(drm_core_reclaim_buffers);
|
/*
* fs/f2fs/acl.h
*
* Copyright (c) 2012 Samsung Electronics Co., Ltd.
* http://www.samsung.com/
*
* Portions of this code from linux/fs/ext2/acl.h
*
* Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef __F2FS_ACL_H__
#define __F2FS_ACL_H__
#include <linux/posix_acl_xattr.h>
#define F2FS_ACL_VERSION 0x0001
struct f2fs_acl_entry {
__le16 e_tag;
__le16 e_perm;
__le32 e_id;
};
struct f2fs_acl_entry_short {
__le16 e_tag;
__le16 e_perm;
};
struct f2fs_acl_header {
__le32 a_version;
};
#ifdef CONFIG_F2FS_FS_POSIX_ACL
extern int f2fs_check_acl(struct inode *inode, int mask, unsigned int flags);
extern int f2fs_acl_chmod(struct inode *inode);
extern int f2fs_init_acl(struct inode *inode, struct inode *dir);
#else
#define f2fs_check_acl NULL
#define f2fs_set_acl NULL
static inline int f2fs_acl_chmod(struct inode *inode)
{
return 0;
}
static inline int f2fs_init_acl(struct inode *inode, struct inode *dir,
struct page *page)
{
return 0;
}
#endif
#endif /* __F2FS_ACL_H__ */
|
// CkAtom.h: interface for the CkAtom class.
//
//////////////////////////////////////////////////////////////////////
#ifndef _CKAtom_H
#define _CKAtom_H
#pragma once
#include "CkString.h"
class CkByteData;
/*
IMPORTANT: Objects returned by methods as non-const pointers must be deleted
by the calling application.
*/
#include "CkObject.h"
class CkAtomProgress;
#pragma pack (push, 8)
// CLASS: CkAtom
class CkAtom : public CkObject
{
private:
CkAtomProgress *m_callback;
void *m_impl;
bool m_utf8; // If true, all input "const char *" parameters are utf-8, otherwise they are ANSI strings.
// Don't allow assignment or copying these objects.
CkAtom(const CkAtom &) { }
CkAtom &operator=(const CkAtom &) { return *this; }
CkAtom(void *impl) : m_impl(impl),m_callback(0) { }
unsigned long nextIdx(void);
unsigned long m_resultIdx;
CkString m_resultString[10];
public:
void *getImpl(void) const { return m_impl; }
CkAtom();
virtual ~CkAtom();
// BEGIN PUBLIC INTERFACE
bool get_Utf8(void) const;
void put_Utf8(bool b);
CkAtomProgress *get_EventCallbackObject(void) const;
void put_EventCallbackObject(CkAtomProgress *progress);
// Error log retrieval and saving (these methods are common to all Chilkat VC++ classes.)
bool SaveLastError(const char *filename);
void LastErrorXml(CkString &str);
void LastErrorHtml(CkString &str);
void LastErrorText(CkString &str);
const char *lastErrorText(void);
const char *lastErrorXml(void);
const char *lastErrorHtml(void);
// NUMENTRIES_BEGIN
int get_NumEntries(void);
// NUMENTRIES_END
// ADDELEMENT_BEGIN
int AddElement(const char *tag, const char *value);
// ADDELEMENT_END
// ADDELEMENTDATE_BEGIN
int AddElementDate(const char *tag, SYSTEMTIME &dateTime);
// ADDELEMENTDATE_END
// ADDELEMENTHTML_BEGIN
int AddElementHtml(const char *tag, const char *htmlStr);
// ADDELEMENTHTML_END
// ADDELEMENTXHTML_BEGIN
int AddElementXHtml(const char *tag, const char *xmlStr);
// ADDELEMENTXHTML_END
// ADDELEMENTXML_BEGIN
int AddElementXml(const char *tag, const char *xmlStr);
// ADDELEMENTXML_END
// ADDENTRY_BEGIN
void AddEntry(const char *xmlStr);
// ADDENTRY_END
// ADDLINK_BEGIN
void AddLink(const char *rel, const char *href, const char *title, const char *typ);
// ADDLINK_END
// ADDPERSON_BEGIN
void AddPerson(const char *tag, const char *name, const char *uri, const char *email);
// ADDPERSON_END
// DELETEELEMENT_BEGIN
void DeleteElement(const char *tag, int index);
// DELETEELEMENT_END
// DELETEELEMENTATTR_BEGIN
void DeleteElementAttr(const char *tag, int index, const char *attrName);
// DELETEELEMENTATTR_END
// DELETEPERSON_BEGIN
void DeletePerson(const char *tag, int index);
// DELETEPERSON_END
// DOWNLOADATOM_BEGIN
bool DownloadAtom(const char *url);
// DOWNLOADATOM_END
// GETELEMENT_BEGIN
bool GetElement(const char *tag, int index, CkString &outStr);
const char *getElement(const char *tag, int index);
// GETELEMENT_END
// GETELEMENTATTR_BEGIN
bool GetElementAttr(const char *tag, int index, const char *attrName, CkString &outStr);
const char *getElementAttr(const char *tag, int index, const char *attrName);
// GETELEMENTATTR_END
// GETELEMENTCOUNT_BEGIN
int GetElementCount(const char *tag);
// GETELEMENTCOUNT_END
// GETELEMENTDATE_BEGIN
bool GetElementDate(const char *tag, int index, SYSTEMTIME &sysTime);
// GETELEMENTDATE_END
// GETENTRY_BEGIN
CkAtom *GetEntry(int index);
// GETENTRY_END
// GETLINKHREF_BEGIN
bool GetLinkHref(const char *relName, CkString &outStr);
const char *getLinkHref(const char *relName);
// GETLINKHREF_END
// GETPERSONINFO_BEGIN
bool GetPersonInfo(const char *tag, int index, const char *tag2, CkString &outStr);
const char *getPersonInfo(const char *tag, int index, const char *tag2);
// GETPERSONINFO_END
// GETTOPATTR_BEGIN
bool GetTopAttr(const char *attrName, CkString &outStr);
const char *getTopAttr(const char *attrName);
// GETTOPATTR_END
// HASELEMENT_BEGIN
bool HasElement(const char *tag);
// HASELEMENT_END
// LOADXML_BEGIN
bool LoadXml(const char *xmlStr);
// LOADXML_END
// NEWENTRY_BEGIN
void NewEntry(void);
// NEWENTRY_END
// NEWFEED_BEGIN
void NewFeed(void);
// NEWFEED_END
// SETELEMENTATTR_BEGIN
void SetElementAttr(const char *tag, int index, const char *attrName, const char *attrValue);
// SETELEMENTATTR_END
// SETTOPATTR_BEGIN
void SetTopAttr(const char *attrName, const char *value);
// SETTOPATTR_END
// TOXMLSTRING_BEGIN
bool ToXmlString(CkString &outStr);
const char *toXmlString(void);
// TOXMLSTRING_END
// UPDATEELEMENT_BEGIN
void UpdateElement(const char *tag, int index, const char *value);
// UPDATEELEMENT_END
// UPDATEELEMENTDATE_BEGIN
void UpdateElementDate(const char *tag, int index, SYSTEMTIME &dateTime);
// UPDATEELEMENTDATE_END
// UPDATEELEMENTHTML_BEGIN
void UpdateElementHtml(const char *tag, int index, const char *htmlStr);
// UPDATEELEMENTHTML_END
// UPDATEELEMENTXHTML_BEGIN
void UpdateElementXHtml(const char *tag, int index, const char *xmlStr);
// UPDATEELEMENTXHTML_END
// UPDATEELEMENTXML_BEGIN
void UpdateElementXml(const char *tag, int index, const char *xmlStr);
// UPDATEELEMENTXML_END
// UPDATEPERSON_BEGIN
void UpdatePerson(const char *tag, int index, const char *name, const char *uri, const char *email);
// UPDATEPERSON_END
// ATOM_INSERT_POINT
// END PUBLIC INTERFACE
};
#pragma pack (pop)
#endif
|
#include <stdio.h>
#define MAX 101
struct Node
{
int price;
int bluk;
};
int main( void )
{
int v, n, i, j;
while ( scanf("%d", &v) != EOF )//¿Ú´üµÄÌå»ý
{
if ( 0 == v )//Ìå»ýΪ0ʱÖÕÖ¹¼ÆËã
break;
scanf("%d", &n);//ÊäÈ뱦±´µÄÖÖÀà
struct Node stud[MAX], temp;
int total = 0;
for ( i = 0; i < n; i++ )
scanf("%d%d", &stud[i].price, &stud[i].bluk);
for ( i = 1; i < v; i++ )
for ( j = 0; j < v - i; j++ )
if ( stud[j].price < stud[j+1].price )
{
temp = stud[j];
stud[i] = stud[j+1];
stud[j+1] = temp;
}
for ( i = 0; v ; i++ )
{
if ( v > stud[i].bluk )
{
total += stud[i].bluk * stud[i].price;
v -= stud[i].bluk;
}
else
{
total += stud[i].price * v;
v = 0;
}
}
printf("%d\n", total);
}
return 0;
}
|
#ifndef SHAPEWIDGET_H
#define SHAPEWIDGET_H
#include <QWidget>
#include <QTimer>
#include <QPixmap>
class ShapeWidget : public QWidget
{
Q_OBJECT
public:
ShapeWidget(QWidget *parent = 0);
~ShapeWidget();
protected:
void paintEvent(QPaintEvent *event);
private:
QPoint dragPosition;
QTimer *timer;
QPixmap *pix;
QPixmap *PixmapTemp;
int count;
private slots:
void changePicture();
};
#endif // SHAPEWIDGET_H
|
#ifndef GLWIDGET_H
#define GLWIDGET_H
#include <QGLWidget>
#include <QWidget>
#include "v4l2capiture.h"
#include "channels.h"
class PicShowThread;
QT_BEGIN_NAMESPACE
class QPaintEvent;
class QWidget;
QT_END_NAMESPACE
class GLWidget : public QGLWidget
{
Q_OBJECT
void mouseMoveEvent (QMouseEvent * event);
void mouseReleaseEvent (QMouseEvent * event);
void mousePressEvent (QMouseEvent * event);
void mouseDoubleClickEvent (QMouseEvent * event);
void wheelEvent(QWheelEvent *event);
// void resizeEvent (QResizeEvent * event);
protected:
bool doResize;
bool doRendering;
int iMode;
int iScrFormat;
QSize whGl;
QTimer *timerpaint;
QWidget *parentwgt;
v4l2capiture v4l2;
void Deinterlace();
void resizeEvent (QResizeEvent * event);
void paintEvent(QPaintEvent *event);
void closeEvent(QCloseEvent *event);
public:
GLWidget(QWidget *parent);
~GLWidget();
void startShow();
void stopShow();
void switchMode(int mode);
void switchScreenFrormat(int frmt);
void SwitchToChan(const TChanParams &thisChan);// //const TChanParams &thisChan = myChanls.SwitchToChanl(idchn);
public slots:
void animate();
};
#endif
|
/*
* COPYRIGHT (c) 1989-2008.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems/system.h>
#include <rtems/score/object.h>
#include <rtems/score/wkspace.h>
void _Objects_Close(
Objects_Information *information,
Objects_Control *the_object
)
{
_Objects_Invalidate_Id( information, the_object );
_Objects_Namespace_remove( information, the_object );
}
|
/*
* SimpleGPIO.cpp
*
* Modifications by Derek Molloy, School of Electronic Engineering, DCU
* www.derekmolloy.ie
* Almost entirely based on Software by RidgeRun:
*
* Copyright (c) 2011, RidgeRun
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the RidgeRun.
* 4. Neither the name of the RidgeRun 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 RIDGERUN ''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 RIDGERUN BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "SimpleGPIO.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <poll.h>
#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/resource.h>
/****************************************************************
* gpio_export
****************************************************************/
int gpio_export(unsigned int gpio)
{
int fd, len;
char buf[MAX_BUF];
fd = open(SYSFS_GPIO_DIR "/export", O_WRONLY);
if (fd < 0) {
perror("gpio/export");
return fd;
}
len = snprintf(buf, sizeof(buf), "%d", gpio);
write(fd, buf, len);
close(fd);
return 0;
}
/****************************************************************
* gpio_unexport
****************************************************************/
int gpio_unexport(unsigned int gpio)
{
int fd, len;
char buf[MAX_BUF];
fd = open(SYSFS_GPIO_DIR "/unexport", O_WRONLY);
if (fd < 0) {
perror("gpio/export");
return fd;
}
len = snprintf(buf, sizeof(buf), "%d", gpio);
write(fd, buf, len);
close(fd);
return 0;
}
/****************************************************************
* gpio_set_dir
****************************************************************/
int gpio_set_dir(unsigned int gpio, PIN_DIRECTION out_flag)
{
int fd;
char buf[MAX_BUF];
snprintf(buf, sizeof(buf), SYSFS_GPIO_DIR "/gpio%d/direction", gpio);
fd = open(buf, O_WRONLY);
if (fd < 0) {
perror("gpio/direction");
return fd;
}
if (out_flag == OUTPUT_PIN)
write(fd, "out", 4);
else
write(fd, "in", 3);
close(fd);
return 0;
}
/****************************************************************
* gpio_set_value
****************************************************************/
int gpio_set_value(unsigned int gpio, PIN_VALUE value)
{
int fd;
char buf[MAX_BUF];
snprintf(buf, sizeof(buf), SYSFS_GPIO_DIR "/gpio%d/value", gpio);
fd = open(buf, O_WRONLY);
if (fd < 0) {
perror("gpio/set-value");
return fd;
}
if (value==LOW) {
write(fd, "0", 2);
} else {
write(fd, "1", 2);
}
close(fd);
return 0;
}
/****************************************************************
* gpio_get_value
****************************************************************/
char gpio_get_value(unsigned int gpio /*unsigned int *value*/)
{
int fd;
char buf[MAX_BUF];
char ch;
snprintf(buf, sizeof(buf), SYSFS_GPIO_DIR "/gpio%d/value", gpio);
fd = open(buf, O_RDONLY);
if (fd < 0) {
perror("gpio/get-value");
return fd;
}
read(fd, &ch, 1);
// if (ch != '0') {
// value = 1;
// } else {
// value = 0;
// }
close(fd);
return ch;
}
/****************************************************************
* gpio_set_edge
****************************************************************/
int gpio_set_edge(unsigned int gpio, char *edge)
{
int fd;
char buf[MAX_BUF];
snprintf(buf, sizeof(buf), SYSFS_GPIO_DIR "/gpio%d/edge", gpio);
fd = open(buf, O_WRONLY);
if (fd < 0) {
perror("gpio/set-edge");
return fd;
}
write(fd, edge, strlen(edge) + 1);
close(fd);
return 0;
}
/****************************************************************
* gpio_fd_open
****************************************************************/
int gpio_fd_open(unsigned int gpio)
{
int fd;
char buf[MAX_BUF];
snprintf(buf, sizeof(buf), SYSFS_GPIO_DIR "/gpio%d/value", gpio);
fd = open(buf, O_RDONLY | O_NONBLOCK );
if (fd < 0) {
perror("gpio/fd_open");
}
return fd;
}
/****************************************************************
* gpio_fd_close
****************************************************************/
int gpio_fd_close(int fd)
{
return close(fd);
}
|
/*
* Copyright (C) 2001-2003 Michael Niedermayer <michaelni@gmx.at>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef SWSCALE_H
#define SWSCALE_H
/**
* @file swscale.h
* @brief
* external api for the swscale stuff
*/
#include "avutil.h"
#define AV_STRINGIFY(s) AV_TOSTRING(s)
#define AV_TOSTRING(s) #s
#define LIBSWSCALE_VERSION_INT ((0<<16)+(5<<8)+0)
#define LIBSWSCALE_VERSION 0.5.0
#define LIBSWSCALE_BUILD LIBSWSCALE_VERSION_INT
#define LIBSWSCALE_IDENT "SwS" AV_STRINGIFY(LIBSWSCALE_VERSION)
/* values for the flags, the stuff on the command line is different */
#define SWS_FAST_BILINEAR 1
#define SWS_BILINEAR 2
#define SWS_BICUBIC 4
#define SWS_X 8
#define SWS_POINT 0x10
#define SWS_AREA 0x20
#define SWS_BICUBLIN 0x40
#define SWS_GAUSS 0x80
#define SWS_SINC 0x100
#define SWS_LANCZOS 0x200
#define SWS_SPLINE 0x400
#define SWS_SRC_V_CHR_DROP_MASK 0x30000
#define SWS_SRC_V_CHR_DROP_SHIFT 16
#define SWS_PARAM_DEFAULT 123456
#define SWS_PRINT_INFO 0x1000
//the following 3 flags are not completely implemented
//internal chrominace subsampling info
#define SWS_FULL_CHR_H_INT 0x2000
//input subsampling info
#define SWS_FULL_CHR_H_INP 0x4000
#define SWS_DIRECT_BGR 0x8000
#define SWS_ACCURATE_RND 0x40000
#define SWS_CPU_CAPS_MMX 0x80000000
#define SWS_CPU_CAPS_MMX2 0x20000000
#define SWS_CPU_CAPS_3DNOW 0x40000000
#define SWS_CPU_CAPS_ALTIVEC 0x10000000
#define SWS_CPU_CAPS_BFIN 0x01000000
#define SWS_MAX_REDUCE_CUTOFF 0.002
#define SWS_CS_ITU709 1
#define SWS_CS_FCC 4
#define SWS_CS_ITU601 5
#define SWS_CS_ITU624 5
#define SWS_CS_SMPTE170M 5
#define SWS_CS_SMPTE240M 7
#define SWS_CS_DEFAULT 5
// when used for filters they must have an odd number of elements
// coeffs cannot be shared between vectors
typedef struct {
double *coeff;
int length;
} SwsVector;
// vectors can be shared
typedef struct {
SwsVector *lumH;
SwsVector *lumV;
SwsVector *chrH;
SwsVector *chrV;
} SwsFilter;
struct SwsContext;
void sws_freeContext(struct SwsContext *swsContext);
struct SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags,
SwsFilter *srcFilter, SwsFilter *dstFilter, double *param);
int sws_scale(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]);
int sws_scale_ordered(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]);
int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], int srcRange, const int table[4], int dstRange, int brightness, int contrast, int saturation);
int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table, int *srcRange, int **table, int *dstRange, int *brightness, int *contrast, int *saturation);
SwsVector *sws_getGaussianVec(double variance, double quality);
SwsVector *sws_getConstVec(double c, int length);
SwsVector *sws_getIdentityVec(void);
void sws_scaleVec(SwsVector *a, double scalar);
void sws_normalizeVec(SwsVector *a, double height);
void sws_convVec(SwsVector *a, SwsVector *b);
void sws_addVec(SwsVector *a, SwsVector *b);
void sws_subVec(SwsVector *a, SwsVector *b);
void sws_shiftVec(SwsVector *a, int shift);
SwsVector *sws_cloneVec(SwsVector *a);
void sws_printVec(SwsVector *a);
void sws_freeVec(SwsVector *a);
SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur,
float lumaSarpen, float chromaSharpen,
float chromaHShift, float chromaVShift,
int verbose);
void sws_freeFilter(SwsFilter *filter);
struct SwsContext *sws_getCachedContext(struct SwsContext *context,
int srcW, int srcH, int srcFormat,
int dstW, int dstH, int dstFormat, int flags,
SwsFilter *srcFilter, SwsFilter *dstFilter, double *param);
#endif
|
#ifndef ASM_X86__TYPES_H
#define ASM_X86__TYPES_H
#include <asm-generic/int-ll64.h>
#ifndef __ASSEMBLY__
typedef unsigned short umode_t;
#endif /* __ASSEMBLY__ */
/*
* These aren't exported outside the kernel to avoid name space clashes
*/
#ifdef __KERNEL__
#ifdef CONFIG_X86_32
# define BITS_PER_LONG 32
#else
# define BITS_PER_LONG 64
#endif
#ifndef __ASSEMBLY__
typedef u64 dma64_addr_t;
#if defined(CONFIG_X86_64) || defined(CONFIG_HIGHMEM64G)
/* DMA addresses come in 32-bit and 64-bit flavours. */
typedef u64 dma_addr_t;
#else
typedef u32 dma_addr_t;
#endif
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif /* ASM_X86__TYPES_H */
|
#pragma once
#include "Phase.h"
class Phase_Harvest : public Phase
{
public:
Phase_Harvest();
~Phase_Harvest();
void Tick();
};
|
/* created by click/linuxmodule/fixincludes.pl on Tue Nov 25 22:39:39 2014 */
/* from /lib/modules/2.6.27.5-117.fc10.i686/build/include/linux/crc-ccitt.h */
#ifndef _LINUX_CRC_CCITT_H
#if defined(__cplusplus) && !CLICK_CXX_PROTECTED
# error "missing #include <click/cxxprotect.h>"
#endif
#define _LINUX_CRC_CCITT_H
#include <linux/types.h>
extern u16 const crc_ccitt_table[256];
extern u16 crc_ccitt(u16 crc, const u8 *buffer, size_t len);
static inline u16 crc_ccitt_byte(u16 crc, const u8 c)
{
return (crc >> 8) ^ crc_ccitt_table[(crc ^ c) & 0xff];
}
#endif /* _LINUX_CRC_CCITT_H */
|
#ifndef GGP_UI_PLOT_H
#define GGP_UI_PLOT_H
#include "ui.h"
struct Plot {
Window window;
struct Point { Point(double a, double b) : x(a), y(b) {} double x, y; };
Point max;
Point min;
Plot(int w, int h, double mx, double nx, double my, double ny)
: window("Plot", w, h),
max(mx, my),
min(nx, ny)
{}
double sy(double y) { return (y-min.y) * (double(window.height) / (max.y-min.y)); }
double sx(double x) { return (x-min.x) * (double(window.width) / (max.x-min.x)); }
void color(float r, float g, float b) { window.color(r,g,b); }
void draw(pair<double,double> &a, pair<double,double> &b) {
window.line(sx(a.first), sy(a.second), sx(b.first), sy(b.second));
}
void render(vector< pair<double,double> > &v) {
for (size_t i=1; i < v.size(); ++i)
draw(v[i-1], v[i]);
}
void update(vector< pair<double,double> > &v) {
window.clear();
render(v);
window.swap();
window.check_running();
if (!window.running) {
window.close();
exit(EXIT_SUCCESS);
}
}
};
#endif // GGP_UI_PLOT_H
|
/********************************************\
*
* Sire - Molecular Simulation Framework
*
* Copyright (C) 2009 Christopher Woods
*
* 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
*
* For full details of the license please see the COPYING file
* that should have come with this distribution.
*
* You can contact the authors via the developer's mailing list
* at http://siremol.org
*
\*********************************************/
#ifndef SIREMOVE_VELOCITYVERLET_H
#define SIREMOVE_VELOCITYVERLET_H
#include "integrator.h"
#include "SireUnits/temperature.h"
SIRE_BEGIN_HEADER
namespace SireMove
{
class VelocityVerlet;
}
QDataStream& operator<<(QDataStream&, const SireMove::VelocityVerlet&);
QDataStream& operator>>(QDataStream&, SireMove::VelocityVerlet&);
namespace SireMove
{
/** This class implements an atomistic velocity verlet dynamics integrator
@author Christopher Woods
*/
class SIREMOVE_EXPORT VelocityVerlet
: public SireBase::ConcreteProperty<VelocityVerlet,Integrator>
{
friend QDataStream& ::operator<<(QDataStream&, const VelocityVerlet&);
friend QDataStream& ::operator>>(QDataStream&, VelocityVerlet&);
public:
VelocityVerlet(bool frequent_save_velocities = false);
VelocityVerlet(const VelocityVerlet &other);
~VelocityVerlet();
VelocityVerlet& operator=(const VelocityVerlet &other);
bool operator==(const VelocityVerlet &other) const;
bool operator!=(const VelocityVerlet &other) const;
static const char* typeName();
QString toString() const;
Ensemble ensemble() const;
bool isTimeReversible() const;
void integrate(IntegratorWorkspace &workspace,
const Symbol &nrg_component,
SireUnits::Dimension::Time timestep,
int nmoves, bool record_stats);
IntegratorWorkspacePtr createWorkspace(const PropertyMap &map = PropertyMap()) const;
IntegratorWorkspacePtr createWorkspace(const MoleculeGroup &molgroup,
const PropertyMap &map = PropertyMap()) const;
private:
/** Whether or not to save the velocities after every step,
or to save them at the end of all of the steps */
bool frequent_save_velocities;
};
}
Q_DECLARE_METATYPE( SireMove::VelocityVerlet )
SIRE_EXPOSE_CLASS( SireMove::VelocityVerlet )
SIRE_END_HEADER
#endif
|
/* file: wfdbwhich.c G. Moody 20 June 1990
Last revised: 5 May 1999
-------------------------------------------------------------------------------
wfdbwhich: Find a WFDB file and print its pathname
Copyright (C) 1999 George B. Moody
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, see <http://www.gnu.org/licenses/>.
You may contact the author by e-mail (wfdb@physionet.org) or postal mail
(MIT Room E25-505A, Cambridge, MA 02139 USA). For updates to this software,
please visit PhysioNet (http://www.physionet.org/).
_______________________________________________________________________________
*/
#include <stdio.h>
#ifndef __STDC__
extern void exit();
#endif
#include <wfdb/wfdb.h>
main(argc, argv)
int argc;
char *argv[];
{
char *filename, *pname, *prog_name();
int status = 0;
pname = prog_name(argv[0]);
if (argc == 2 && strcmp(argv[1], "-h") == 0)
argc = 0; /* give usage instructions and quit */
switch (argc) {
case 2:
if (filename = wfdbfile(argv[1], (char *)NULL))
(void)printf("%s\n", filename);
else {
(void)fprintf(stderr, "`%s' not found\n", argv[1]);
(void)fprintf(stderr, "(WFDB path = %s)\n", getwfdb());
status = 2;
}
break;
case 3:
wfdbquiet();
(void)isigopen(argv[2], NULL, 0);
if (filename = wfdbfile(argv[1], argv[2]))
(void)printf("%s\n", filename);
else {
(void)fprintf(stderr,
"No file of type `%s' found for record `%s'\n",
argv[1], argv[2]);
(void)fprintf(stderr, "(WFDB path = %s)\n", getwfdb());
status = 2;
}
break;
default:
if (argc != 4 || strcmp(argv[1], "-r") != 0) {
(void)fprintf(stderr, "usage: %s [-r RECORD ] FILENAME\n", pname);
(void)fprintf(stderr, " -or- %s FILE-TYPE RECORD\n", pname);
status = 1;
}
else {
(void)isigopen(argv[2], NULL, 0);
if (filename = wfdbfile(argv[3], (char *)NULL))
(void)printf("%s\n", filename);
else {
(void)fprintf(stderr, "`%s' not found\n", argv[3]);
(void)fprintf(stderr, "(WFDB path = %s)\n", getwfdb());
status = 2;
}
}
break;
}
exit(status);
/*NOTREACHED*/
}
char *prog_name(s)
char *s;
{
char *p = s + strlen(s);
#ifdef MSDOS
while (p >= s && *p != '\\' && *p != ':') {
if (*p == '.')
*p = '\0'; /* strip off extension */
if ('A' <= *p && *p <= 'Z')
*p += 'a' - 'A'; /* convert to lower case */
p--;
}
#else
while (p >= s && *p != '/')
p--;
#endif
return (p+1);
}
|
/*
* The ManaPlus Client
* Copyright (C) 2007-2009 The Mana World Development Team
* Copyright (C) 2009-2010 The Mana Developers
* Copyright (C) 2011-2014 The ManaPlus Developers
*
* This file is part of The ManaPlus Client.
*
* 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
* 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 GUI_WIDGETS_CONTAINERPLACER_H
#define GUI_WIDGETS_CONTAINERPLACER_H
#include "localconsts.h"
class BasicContainer2;
class LayoutCell;
class Widget;
/**
* This class is a helper for adding widgets to nested tables in a window.
*/
class ContainerPlacer final
{
public:
explicit ContainerPlacer(BasicContainer2 *c = nullptr,
LayoutCell *lc = nullptr) :
mContainer(c),
mCell(lc)
{}
/**
* Gets the pointed cell.
*/
LayoutCell &getCell() A_WARN_UNUSED
{ return *mCell; }
/**
* Returns a placer for the same container but to an inner cell.
*/
ContainerPlacer at(const int x, const int y) A_WARN_UNUSED;
/**
* Adds the given widget to the container and places it in the layout.
* @see LayoutArray::place
*/
LayoutCell &operator()(const int x, const int y, Widget *const wg,
const int w = 1, const int h = 1);
private:
BasicContainer2 *mContainer;
LayoutCell *mCell;
};
#endif // GUI_WIDGETS_CONTAINERPLACER_H
|
// Copyright 2014 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <array>
#include <memory>
#include <string>
#include <vector>
#include "Common/CommonTypes.h"
#include "VideoCommon/CPMemory.h"
#include "VideoCommon/NativeVertexFormat.h"
class DataReader;
class VertexLoaderUID
{
std::array<u32, 5> vid;
size_t hash;
public:
VertexLoaderUID() {}
VertexLoaderUID(const TVtxDesc& vtx_desc, const VAT& vat)
{
vid[0] = vtx_desc.GetLegacyHex0();
vid[1] = vtx_desc.GetLegacyHex1();
vid[2] = vat.g0.Hex;
vid[3] = vat.g1.Hex;
vid[4] = vat.g2.Hex;
hash = CalculateHash();
}
bool operator==(const VertexLoaderUID& rh) const { return vid == rh.vid; }
size_t GetHash() const { return hash; }
private:
size_t CalculateHash() const
{
size_t h = SIZE_MAX;
for (auto word : vid)
{
h = h * 137 + word;
}
return h;
}
};
namespace std
{
template <>
struct hash<VertexLoaderUID>
{
size_t operator()(const VertexLoaderUID& uid) const { return uid.GetHash(); }
};
} // namespace std
class VertexLoaderBase
{
public:
static u32 GetVertexSize(const TVtxDesc& vtx_desc, const VAT& vtx_attr);
static u32 GetVertexComponents(const TVtxDesc& vtx_desc, const VAT& vtx_attr);
static std::vector<u32> GetVertexComponentSizes(const TVtxDesc& vtx_desc, const VAT& vtx_attr);
static std::unique_ptr<VertexLoaderBase> CreateVertexLoader(const TVtxDesc& vtx_desc,
const VAT& vtx_attr);
virtual ~VertexLoaderBase() {}
virtual int RunVertices(DataReader src, DataReader dst, int count) = 0;
// per loader public state
PortableVertexDeclaration m_native_vtx_decl{};
const u32 m_vertex_size; // number of bytes of a raw GC vertex
const u32 m_native_components;
// used by VertexLoaderManager
NativeVertexFormat* m_native_vertex_format = nullptr;
int m_numLoadedVertices = 0;
protected:
VertexLoaderBase(const TVtxDesc& vtx_desc, const VAT& vtx_attr)
: m_vertex_size{GetVertexSize(vtx_desc, vtx_attr)}, m_native_components{GetVertexComponents(
vtx_desc, vtx_attr)},
m_VtxAttr{vtx_attr}, m_VtxDesc{vtx_desc}
{
}
// GC vertex format
const VAT m_VtxAttr;
const TVtxDesc m_VtxDesc;
};
|
/* (C) Guenter Geiger <geiger@epy.co.at> */
/*
These filter coefficients computations are taken from
http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt
written by Robert Bristow-Johnson
*/
#ifdef ROCKBOX
#include "plugin.h"
#include "../../pdbox.h"
#include "../src/m_pd.h"
#include "math.h"
#include "filters.h"
#else /* ROCKBOX */
#include "../src/m_pd.h"
#ifdef NT
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif
#include <math.h>
#include "filters.h"
#endif /* ROCKBOX */
/* ------------------- bandpass ----------------------------*/
static t_class *bandpass_class;
void bandpass_bang(t_rbjfilter *x)
{
t_atom at[5];
t_float omega = e_omega(x->x_freq,x->x_rate);
t_float alpha = e_alpha(x->x_bw* 0.01,omega);
t_float b1 = 0.;
t_float b0 = alpha;
t_float b2 = -alpha;
t_float a0 = 1 + alpha;
t_float a1 = -2.*cos(omega);
t_float a2 = 1 - alpha;
/* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */
if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) {
post("bandpass: filter unstable -> resetting");
a0=1.;a1=0.;a2=0.;
b0=1.;b1=0.;b2=0.;
}
SETFLOAT(at,-a1/a0);
SETFLOAT(at+1,-a2/a0);
SETFLOAT(at+2,b0/a0);
SETFLOAT(at+3,b1/a0);
SETFLOAT(at+4,b2/a0);
outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
}
void bandpass_float(t_rbjfilter *x,t_floatarg f)
{
x->x_freq = f;
bandpass_bang(x);
}
static void *bandpass_new(t_floatarg f,t_floatarg bw)
{
t_rbjfilter *x = (t_rbjfilter *)pd_new(bandpass_class);
x->x_rate = 44100.0;
outlet_new(&x->x_obj,&s_float);
/* floatinlet_new(&x->x_obj, &x->x_gain); */
floatinlet_new(&x->x_obj, &x->x_bw);
if (f > 0.) x->x_freq = f;
if (bw > 0.) x->x_bw = bw;
return (x);
}
void bandpass_setup(void)
{
bandpass_class = class_new(gensym("bandpass"), (t_newmethod)bandpass_new, 0,
sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,0);
class_addbang(bandpass_class,bandpass_bang);
class_addfloat(bandpass_class,bandpass_float);
}
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**
** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
**
** Authors:
** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve@vpac.org)
** Patrick D. Sunter, Software Engineer, VPAC. (pds@vpac.org)
** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins@vpac.org)
** Siew-Ching Tan, Software Engineer, VPAC. (siew@vpac.org)
** Alan H. Lo, Computational Engineer, VPAC. (alan@vpac.org)
** Raquibul Hassan, Computational Engineer, VPAC. (raq@vpac.org)
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
**
*/
/** \file
** Role:
** Basic framework types.
**
** Assumptions:
** None as yet.
**
** Comments:
** None as yet.
**
** $Id: types.h 4202 2007-12-11 08:27:52Z RaquibulHassan $
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifndef __StGermain_Base_Container_types_h__
#define __StGermain_Base_Container_types_h__
typedef struct Iter Iter;
typedef struct AbsArray AbsArray;
typedef struct IArray IArray;
typedef struct STree STree;
typedef struct STreeMap STreeMap;
typedef struct ISet ISet;
typedef struct ISetItem ISetItem;
typedef struct ISetIter ISetIter;
typedef struct IMap IMap;
typedef struct IMapItem IMapItem;
typedef struct IMapIter IMapIter;
typedef struct STreeNode STreeNode;
struct STreeNode {
void* data;
STreeNode* left;
STreeNode* right;
};
typedef int (STree_CompareCB)( const void* left, const void* right );
typedef void (STree_DeleteCB)( void* itm );
struct ISetItem {
int key;
ISetItem* next;
};
struct IMapItem {
int key;
int val;
IMapItem* next;
};
/* IndexSet types */
typedef Index IndexSet_Index;
/* classes */
typedef struct IndexSet IndexSet;
typedef struct PtrMap PtrMap;
typedef struct IndexMap IndexMap;
typedef struct LList LList;
typedef struct Hasher Hasher;
typedef struct NumberHasher NumberHasher;
typedef struct Mapping Mapping;
typedef struct LinkedListNode LinkedListNode;
typedef struct LinkedList LinkedList;
typedef struct LinkedListIterator LinkedListIterator;
typedef struct HashTable_Entry HashTable_Entry;
typedef struct HashTable_Index HashTable_Index;
typedef struct HashTable HashTable;
typedef struct Set Set;
typedef struct PtrSet PtrSet;
typedef struct _Heap _Heap;
typedef struct MaxHeap MaxHeap;
typedef struct UIntMap UIntMap;
typedef struct MemoryPool MemoryPool;
typedef struct RangeSet RangeSet;
typedef unsigned char Stg_Byte;
typedef char BitField;
typedef struct BTreeNode BTreeNode;
typedef struct BTree BTree;
typedef struct BTreeIterator BTreeIterator;
typedef struct Chunk Chunk;
typedef struct ChunkArray ChunkArray;
typedef struct MapTuple MapTuple;
typedef enum Color_t{
BTREE_NODE_RED,
BTREE_NODE_BLACK
}
Color;
typedef enum BTreeProperty_t{
BTREE_ALLOW_DUPLICATES,
BTREE_NO_DUPLICATES
}
BTreeProperty;
typedef enum Order_t{
LINKEDLIST_SORTED,
LINKEDLIST_UNSORTED
}
Order;
typedef enum KeyType_t{
HASHTABLE_STRING_KEY,
HASHTABLE_INTEGER_KEY,
HASHTABLE_POINTER_KEY
}
KeyType;
typedef struct {
unsigned begin;
unsigned end;
unsigned step;
} RangeSet_Range;
typedef struct {
RangeSet* self;
RangeSet* operand;
RangeSet_Range* range;
BTree* newTree;
unsigned nInds;
unsigned* inds;
unsigned curInd;
Stg_Byte* bytes;
} RangeSet_ParseStruct;
#endif /* __StGermain_Base_Container_types_h__ */
|
#define _POSIX_C_SOURCE 200809L
#include <pthread.h>
#include <time.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "mq_msg_ws.h"
#ifdef SPEED_TEST
#define TEST_ITERATIONS 10000000
#define DO_PRODUCER_SLEEP 0
#define DO_CONSUMER_SLEEP 0
#else
#define TEST_ITERATIONS 100000
#define DO_PRODUCER_SLEEP 1
#define DO_CONSUMER_SLEEP 1
#endif
#define PRINT_TAIL 1
int message_producer(struct mq_ws_msg *m, void *data)
{
char *s = (char *)data;
snprintf(m->m, MAX_JSON_MSG_LEN, "%s", s);
return 0;
}
/* a callback for consuming messages. */
int message_printer(struct mq_ws_msg *m, void *data __attribute__((unused)))
{
assert(m);
printf("m: %s\n", m->m);
return 0;
}
int string_copier(struct mq_ws_msg *m, void *data)
{
char *s;
assert(m);
assert(data);
s = (char *)data;
sprintf(s, "%s", m->m);
return 0;
}
/* dont ask, just condemn it. */
void nsleep(unsigned long delay)
{
struct timespec deadline;
clock_gettime(CLOCK_MONOTONIC, &deadline);
deadline.tv_nsec += delay;
/* account for the second boundary */
if (deadline.tv_nsec >= 1E9) {
deadline.tv_nsec -= 1E9;
deadline.tv_sec++;
}
clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &deadline, NULL);
}
/* Calculate the absolute difference between t1 and t2. */
struct timespec ts_absdiff(struct timespec t1, struct timespec t2)
{
struct timespec t;
if ((t1.tv_sec < t2.tv_sec) ||
((t1.tv_sec == t2.tv_sec) && (t1.tv_nsec <= t2.tv_nsec))) {
/* t1 <= t2 */
t.tv_sec = t2.tv_sec - t1.tv_sec;
if (t2.tv_nsec < t1.tv_nsec) {
t.tv_nsec = t2.tv_nsec + 1E9 - t1.tv_nsec;
t.tv_sec--;
} else {
t.tv_nsec = t2.tv_nsec - t1.tv_nsec;
}
} else {
/* t1 > t2 */
t.tv_sec = t1.tv_sec - t2.tv_sec;
if (t1.tv_nsec < t2.tv_nsec) {
t.tv_nsec = t1.tv_nsec + 1E9 - t2.tv_nsec;
t.tv_sec--; /* Borrow a second. */
} else {
t.tv_nsec = t1.tv_nsec - t2.tv_nsec;
}
}
return t;
}
double ts_to_seconds(struct timespec t)
{
return t.tv_sec + t.tv_nsec / 1E9;
}
void *produce(void *d __attribute__((unused)))
{
char msg[MAX_JSON_MSG_LEN];
int err, cb_err;
struct timespec deadline;
printf("new producer for %d messages.\n", TEST_ITERATIONS);
clock_gettime(CLOCK_MONOTONIC, &deadline);
int i = TEST_ITERATIONS;
while (i) {
#if DO_PRODUCER_SLEEP
int r = rand() % 100;
nsleep(100 + r);
#endif
sprintf(msg, "%d", i);
err = mq_ws_produce(message_producer, msg, &cb_err);
if (!err) {
#if PRINT_TAIL
if (i < PRINT_TAIL) {
printf("p%03d\n", i);
}
#endif
i--;
}
if (0 == i % 5000) {
printf("%2d%%\r",
(int)(TEST_ITERATIONS - i) * 100 / TEST_ITERATIONS);
fflush(stdout);
}
}
assert(!err);
printf("producer done.\n");
return NULL;
}
void *consume(void *_tid)
{
char msg[MAX_JSON_MSG_LEN];
int err, cb_err;
unsigned long id;
struct timespec deadline;
int tid = *(int *)_tid;
char space[MAX_JSON_MSG_LEN];
memset(space, ' ', 20 * tid);
err = mq_ws_consumer_subscribe(&id);
assert(!err);
printf("consumer: %d mq id: %lu for %d messages\n", tid, id,
TEST_ITERATIONS);
clock_gettime(CLOCK_MONOTONIC, &deadline);
int i = TEST_ITERATIONS;
while (i) {
#if DO_CONSUMER_SLEEP
int r = rand() % 100;
nsleep(100 + r);
#endif
err = mq_ws_consume(id, string_copier, msg, &cb_err);
if (!err) {
#if PRINT_TAIL
if (i < PRINT_TAIL) {
printf("%sc%d-%03d-%s\n", space, tid, i, msg);
}
#endif
i--;
}
}
assert(!err);
err = mq_ws_consumer_unsubscribe(id);
assert(!err);
return NULL;
}
int main()
{
int x, y, err;
struct timespec start;
struct timespec end;
pthread_t producer_thread;
pthread_t consumer_thread1;
pthread_t consumer_thread2;
err = mq_ws_init();
assert(!err);
x = 1;
if (pthread_create(&consumer_thread1, NULL, consume, &x)) {
fprintf(stderr, "Error creating consumer thread 1\n");
return 1;
}
y = 2;
if (pthread_create(&consumer_thread2, NULL, consume, &y)) {
fprintf(stderr, "Error creating consumer thread 2\n");
return 1;
}
/* always let the producer wait for the consumers to be ready, or
* the second consumer can miss messages at the start and wait
* forever. */
nsleep(1000000);
clock_gettime(CLOCK_MONOTONIC, &start);
/* start the producer after the consumers, or they will miss the
* messages that were qeued before they subscribed and you will
* waste a lot of time looking for a bug that doesn't exist.
*/
if (pthread_create(&producer_thread, NULL, produce, &x)) {
fprintf(stderr, "Error creating producer thread\n");
return 1;
}
/* wait for threads */
if (pthread_join(producer_thread, NULL)) {
fprintf(stderr, "Error joining thread\n");
return 2;
}
if (pthread_join(consumer_thread1, NULL)) {
fprintf(stderr, "Error joining consumer thread 1\n");
return 2;
}
if (pthread_join(consumer_thread2, NULL)) {
fprintf(stderr, "Error joining consumer thread 2\n");
return 2;
}
clock_gettime(CLOCK_MONOTONIC, &end);
#ifdef SPEED_TEST
struct timespec diff;
double rate;
diff = ts_absdiff(start, end);
rate = TEST_ITERATIONS / ts_to_seconds(diff);
printf("message queue OK. %.2f msgs/s\n", rate);
#else
printf("message queue OK.\n");
#endif
err = mq_ws_destroy();
assert(!err);
return 0;
}
|
/// @file ChannelManagerTest.cc
///
/// @copyright (c) 2011 CSIRO
/// Australia Telescope National Facility (ATNF)
/// Commonwealth Scientific and Industrial Research Organisation (CSIRO)
/// PO Box 76, Epping NSW 1710, Australia
/// atnf-enquiries@csiro.au
///
/// This file is part of the ASKAP software distribution.
///
/// The ASKAP software distribution 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
///
/// @author Ben Humphreys <ben.humphreys@csiro.au>
// CPPUnit includes
#include <cppunit/extensions/HelperMacros.h>
// Support classes
#include "askap/AskapError.h"
#include "Common/ParameterSet.h"
#include "askap/AskapUtil.h"
// Classes to test
#include "ingestpipeline/sourcetask/ChannelManager.h"
using namespace casa;
namespace askap {
namespace cp {
namespace ingest {
class ChannelManagerTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(ChannelManagerTest);
CPPUNIT_TEST(testLocalNChannels);
CPPUNIT_TEST(testLocalFrequencies);
CPPUNIT_TEST(testLocalFrequenciesBETA);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
};
void tearDown() {
};
void testLocalNChannels() {
LOFAR::ParameterSet params;
params.add("n_channels.0", "256");
params.add("n_channels.1", "512");
ChannelManager cman(params);
CPPUNIT_ASSERT_EQUAL(256u, cman.localNChannels(0));
CPPUNIT_ASSERT_EQUAL(512u, cman.localNChannels(1));
CPPUNIT_ASSERT_THROW(cman.localNChannels(2), askap::AskapError);
};
void testLocalFrequencies() {
LOFAR::ParameterSet params;
params.add("n_channels.0", "2");
params.add("n_channels.1", "4");
const int totalNChan = 6;
const double centreFreq = 1.6;
const double chanWidth = 0.2;
const double tolerance = 1e-15;
ChannelManager cman(params);
casa::Vector<casa::Double> f0 = cman.localFrequencies(0, centreFreq, chanWidth, totalNChan);
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), f0.size());
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.1, f0(0), tolerance);
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.3, f0(1), tolerance);
casa::Vector<casa::Double> f1 = cman.localFrequencies(1, centreFreq, chanWidth, totalNChan);
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), f1.size());
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5, f1(0), tolerance);
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.7, f1(1), tolerance);
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.9, f1(2), tolerance);
CPPUNIT_ASSERT_DOUBLES_EQUAL(2.1, f1(3), tolerance);
CPPUNIT_ASSERT_THROW(cman.localFrequencies(2, centreFreq, chanWidth, totalNChan),
askap::AskapError);
};
void testLocalFrequenciesBETA() {
LOFAR::ParameterSet params;
params.add("n_channels.0", "16416");
const int nChan = 16416;
const double centreFreq = 864;
const double chanWidth = -(1.0/54.0);
const double tolerance = 1e-2;
ChannelManager cman(params);
casa::Vector<casa::Double> f0 = cman.localFrequencies(0, centreFreq, chanWidth, nChan);
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(16416), f0.size());
CPPUNIT_ASSERT_DOUBLES_EQUAL(1015.99, f0(0), tolerance);
CPPUNIT_ASSERT_DOUBLES_EQUAL(712.009, f0(16415), tolerance);
}
private:
};
} // End namespace ingest
} // End namespace cp
} // End namespace askap
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_PUBLIC_BROWSER_INVALIDATE_TYPE_H_
#define CONTENT_PUBLIC_BROWSER_INVALIDATE_TYPE_H_
namespace content {
enum InvalidateTypes {
INVALIDATE_TYPE_URL = 1 << 0,
INVALIDATE_TYPE_TAB = 1 << 1,
INVALIDATE_TYPE_LOAD = 1 << 2,
INVALIDATE_TYPE_PAGE_ACTIONS = 1 << 3,
INVALIDATE_TYPE_TITLE = 1 << 4,
};
}
#endif
|
/*
* This file is part of the OregonCore Project. See AUTHORS file for Copyright information
*
* 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, see <https://www.gnu.org/licenses/>.
*/
#ifndef THREADING_H
#define THREADING_H
#include <set>
#include <ace/Thread.h>
#include <ace/TSS_T.h>
#include "ace/Atomic_Op.h"
#include <assert.h>
namespace ACE_Based
{
class Runnable
{
public:
virtual ~Runnable() {}
virtual void run() = 0;
void incReference()
{
++m_refs;
}
void decReference()
{
if (!--m_refs)
delete this;
}
private:
ACE_Atomic_Op<ACE_Thread_Mutex, long> m_refs;
};
enum Priority
{
Idle,
Lowest,
Low,
Normal,
High,
Highest,
Realtime,
};
#define MAXPRIORITYNUM (Realtime + 1)
class ThreadPriority
{
public:
ThreadPriority();
int getPriority(Priority p) const;
private:
int m_priority[MAXPRIORITYNUM];
};
class Thread
{
public:
Thread();
explicit Thread(Runnable* instance);
~Thread();
bool start();
bool wait();
void suspend();
bool kill(int signal);
void resume();
void setPriority(Priority type);
static void Sleep(unsigned long msecs);
static ACE_thread_t currentId();
static ACE_hthread_t currentHandle();
static Thread* current();
ACE_thread_t getId() const { return m_iThreadId; }
private:
Thread(const Thread&);
Thread& operator=(const Thread&);
static ACE_THR_FUNC_RETURN ThreadTask(void* param);
ACE_thread_t m_iThreadId;
ACE_hthread_t m_hThreadHandle;
Runnable* m_task;
typedef ACE_TSS<Thread> ThreadStorage;
//global object - container for Thread class representation of every thread
static ThreadStorage m_ThreadStorage;
//use this object to determine current OS thread priority values mapped to enum Priority{}
static ThreadPriority m_TpEnum;
};
}
#endif
|
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: ftl-target.h 27781 2010-08-12 08:46:52Z theseven $
*
* Copyright (C) 2009 by Michael Sparmann
*
* 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef __FTL_TARGET_H__
#define __FTL_TARGET_H__
#include "config.h"
#include "inttypes.h"
#ifdef BOOTLOADER
/* Bootloaders don't need write access */
#define FTL_READONLY
#endif
/* Pointer to an info structure regarding the flash type used */
extern const struct nand_device_info_type* ftl_nand_type;
/* Number of banks we detected a chip on */
extern uint32_t ftl_banks;
uint32_t ftl_init(void);
uint32_t ftl_read(uint32_t sector, uint32_t count, void* buffer);
uint32_t ftl_write(uint32_t sector, uint32_t count, const void* buffer);
uint32_t ftl_sync(void);
#endif
|
#ifndef CE122_H
#define CE122_H
#include "Ce126.h"
class Cce122:public Cce126
{
public:
Cce122(CPObject *parent=0);
bool run();
void ComputeKey(KEYEVENT ke = KEY_PRESSED,int scancode=0,QMouseEvent *event=0);
bool UpdateFinalImage();
virtual void TurnON();
virtual void TurnOFF();
bool printSwitch;
bool init();
};
#endif // CE122_H
|
/*
* Copyright (c) 1991,1992,1995 Linus Torvalds
* Copyright (c) 1994 Alan Modra
* Copyright (c) 1995 Markus Kuhn
* Copyright (c) 1996 Ingo Molnar
* Copyright (c) 1998 Andrea Arcangeli
* Copyright (c) 2002,2006 Vojtech Pavlik
* Copyright (c) 2003 Andi Kleen
*
*/
#include <linux/clockchips.h>
#include <linux/interrupt.h>
#ifdef CONFIG_X86_L4
#include <linux/karma_timer.h>
#else
#include <linux/i8253.h>
#endif
#include <linux/time.h>
#include <linux/export.h>
#include <asm/vsyscall.h>
#include <asm/x86_init.h>
#include <asm/i8259.h>
#include <asm/timer.h>
#include <asm/hpet.h>
#include <asm/time.h>
#ifdef CONFIG_X86_64
DEFINE_VVAR(volatile unsigned long, jiffies) = INITIAL_JIFFIES;
#endif
unsigned long profile_pc(struct pt_regs *regs)
{
unsigned long pc = instruction_pointer(regs);
if (!user_mode_vm(regs) && in_lock_functions(pc)) {
#ifdef CONFIG_FRAME_POINTER
return *(unsigned long *)(regs->bp + sizeof(long));
#else
unsigned long *sp =
(unsigned long *)kernel_stack_pointer(regs);
/*
* Return address is either directly at stack pointer
* or above a saved flags. Eflags has bits 22-31 zero,
* kernel addresses don't.
*/
if (sp[0] >> 22)
return sp[0];
if (sp[1] >> 22)
return sp[1];
#endif
}
return pc;
}
EXPORT_SYMBOL(profile_pc);
/*
* Default timer interrupt handler for PIT/HPET
*/
static irqreturn_t timer_interrupt(int irq, void *dev_id)
{
global_clock_event->event_handler(global_clock_event);
return IRQ_HANDLED;
}
static struct irqaction irq0 = {
.handler = timer_interrupt,
.flags = IRQF_DISABLED | IRQF_NOBALANCING | IRQF_IRQPOLL | IRQF_TIMER,
.name = "timer"
};
void __init setup_default_timer_irq(void)
{
setup_irq(0, &irq0);
}
/* Default timer init function */
void __init hpet_time_init(void)
{
if (!hpet_enable())
#ifdef CONFIG_X86_L4
setup_karma_timer();
#else
setup_pit_timer();
#endif
setup_default_timer_irq();
}
static __init void x86_late_time_init(void)
{
x86_init.timers.timer_init();
tsc_init();
}
/*
* Initialize TSC and delay the periodic timer init to
* late x86_late_time_init() so ioremap works.
*/
void __init time_init(void)
{
late_time_init = x86_late_time_init;
}
|
#ifndef _NET_SECURE_SEQ
#define _NET_SECURE_SEQ
#include <linux/types.h>
extern __u32 secure_ip_id(__be32 daddr);
extern __u32 secure_ipv6_id(const __be32 daddr[4]);
extern u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
extern u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr,
__be16 dport);
extern __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr,
__be16 sport, __be16 dport);
extern __u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr,
__be16 sport, __be16 dport);
extern u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr,
__be16 sport, __be16 dport);
extern u64 secure_dccpv6_sequence_number(__be32 *saddr, __be32 *daddr,
__be16 sport, __be16 dport);
#endif /* _NET_SECURE_SEQ */ |
//----------------------------------------------------------------------------
//Chiika
//Copyright (C) 2015 Alperen Gezer
//This program is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2 of the License, or
//(at your option) any later version.
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//You should have received a copy of the GNU General Public License along
//with this program; if not, write to the Free Software Foundation, Inc.,
//51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.*/
//----------------------------------------------------------------------------
#ifndef __ChiikaConfig_h__
#define __ChiikaConfig_h__
//----------------------------------------------------------------------------
//#define CHIIKA_STD_CONTAINERS_CUSTOM_MEMORY_ALLOCATOR
#define CHIIKA_MEMORY_ALLOCATOR_STD 1
#define CHIIKA_MEMORY_ALLOCATOR_NEEDPOOLING 4
#define CHIIKA_MEMORY_ALLOCATOR 1
#define CHIIKA_DEBUG_MODE
#define CHIIKA_NUM_THREADS 4
//----------------------------------------------------------------------------
#endif // CHIIKADEFINES
|
/* $Id: flash.c,v 1.1.1.1 2004/06/19 05:03:37 ashieh Exp $
* flash.c: Allow mmap access to the OBP Flash, for OBP updates.
*
* Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
*/
#include <linux/config.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/miscdevice.h>
#include <linux/slab.h>
#include <linux/fcntl.h>
#include <linux/poll.h>
#include <linux/init.h>
#include <linux/smp_lock.h>
#include <linux/spinlock.h>
#include <asm/system.h>
#include <asm/uaccess.h>
#include <asm/pgtable.h>
#include <asm/io.h>
#include <asm/sbus.h>
#include <asm/ebus.h>
static spinlock_t flash_lock = SPIN_LOCK_UNLOCKED;
static struct {
unsigned long read_base; /* Physical read address */
unsigned long write_base; /* Physical write address */
unsigned long read_size; /* Size of read area */
unsigned long write_size; /* Size of write area */
unsigned long busy; /* In use? */
} flash;
#define FLASH_MINOR 152
static int
flash_mmap(struct file *file, struct vm_area_struct *vma)
{
unsigned long addr;
unsigned long size;
spin_lock(&flash_lock);
if (flash.read_base == flash.write_base) {
addr = flash.read_base;
size = flash.read_size;
} else {
if ((vma->vm_flags & VM_READ) &&
(vma->vm_flags & VM_WRITE)) {
spin_unlock(&flash_lock);
return -EINVAL;
}
if (vma->vm_flags & VM_READ) {
addr = flash.read_base;
size = flash.read_size;
} else if (vma->vm_flags & VM_WRITE) {
addr = flash.write_base;
size = flash.write_size;
} else {
spin_unlock(&flash_lock);
return -ENXIO;
}
}
spin_unlock(&flash_lock);
if ((vma->vm_pgoff << PAGE_SHIFT) > size)
return -ENXIO;
addr += (vma->vm_pgoff << PAGE_SHIFT);
if (vma->vm_end - (vma->vm_start + (vma->vm_pgoff << PAGE_SHIFT)) > size)
size = vma->vm_end - (vma->vm_start + (vma->vm_pgoff << PAGE_SHIFT));
pgprot_val(vma->vm_page_prot) &= ~(_PAGE_CACHE);
pgprot_val(vma->vm_page_prot) |= _PAGE_E;
vma->vm_flags |= (VM_SHM | VM_LOCKED);
if (remap_page_range(vma->vm_start, addr, size, vma->vm_page_prot))
return -EAGAIN;
return 0;
}
static long long
flash_llseek(struct file *file, long long offset, int origin)
{
switch (origin) {
case 0:
file->f_pos = offset;
break;
case 1:
file->f_pos += offset;
if (file->f_pos > flash.read_size)
file->f_pos = flash.read_size;
break;
case 2:
file->f_pos = flash.read_size;
break;
default:
return -EINVAL;
}
return file->f_pos;
}
static ssize_t
flash_read(struct file * file, char * buf,
size_t count, loff_t *ppos)
{
unsigned long p = file->f_pos;
int i;
if (count > flash.read_size - p)
count = flash.read_size - p;
for (i = 0; i < count; i++) {
u8 data = readb(flash.read_base + p + i);
if (put_user(data, buf))
return -EFAULT;
buf++;
}
file->f_pos += count;
return count;
}
static int
flash_open(struct inode *inode, struct file *file)
{
if (test_and_set_bit(0, (void *)&flash.busy) != 0)
return -EBUSY;
return 0;
}
static int
flash_release(struct inode *inode, struct file *file)
{
spin_lock(&flash_lock);
flash.busy = 0;
spin_unlock(&flash_lock);
return 0;
}
static struct file_operations flash_fops = {
/* no write to the Flash, use mmap
* and play flash dependent tricks.
*/
owner: THIS_MODULE,
llseek: flash_llseek,
read: flash_read,
mmap: flash_mmap,
open: flash_open,
release: flash_release,
};
static struct miscdevice flash_dev = { FLASH_MINOR, "flash", &flash_fops };
EXPORT_NO_SYMBOLS;
static int __init flash_init(void)
{
struct sbus_bus *sbus;
struct sbus_dev *sdev = 0;
#ifdef CONFIG_PCI
struct linux_ebus *ebus;
struct linux_ebus_device *edev = 0;
struct linux_prom_registers regs[2];
int len, nregs;
#endif
int err;
for_all_sbusdev(sdev, sbus) {
if (!strcmp(sdev->prom_name, "flashprom")) {
if (sdev->reg_addrs[0].phys_addr == sdev->reg_addrs[1].phys_addr) {
flash.read_base = ((unsigned long)sdev->reg_addrs[0].phys_addr) |
(((unsigned long)sdev->reg_addrs[0].which_io)<<32UL);
flash.read_size = sdev->reg_addrs[0].reg_size;
flash.write_base = flash.read_base;
flash.write_size = flash.read_size;
} else {
flash.read_base = ((unsigned long)sdev->reg_addrs[0].phys_addr) |
(((unsigned long)sdev->reg_addrs[0].which_io)<<32UL);
flash.read_size = sdev->reg_addrs[0].reg_size;
flash.write_base = ((unsigned long)sdev->reg_addrs[1].phys_addr) |
(((unsigned long)sdev->reg_addrs[1].which_io)<<32UL);
flash.write_size = sdev->reg_addrs[1].reg_size;
}
flash.busy = 0;
break;
}
}
if (!sdev) {
#ifdef CONFIG_PCI
for_each_ebus(ebus) {
for_each_ebusdev(edev, ebus) {
if (!strcmp(edev->prom_name, "flashprom"))
goto ebus_done;
}
}
ebus_done:
if (!edev)
return -ENODEV;
len = prom_getproperty(edev->prom_node, "reg", (void *)regs, sizeof(regs));
if ((len % sizeof(regs[0])) != 0) {
printk("flash: Strange reg property size %d\n", len);
return -ENODEV;
}
nregs = len / sizeof(regs[0]);
flash.read_base = edev->resource[0].start;
flash.read_size = regs[0].reg_size;
if (nregs == 1) {
flash.write_base = edev->resource[0].start;
flash.write_size = regs[0].reg_size;
} else if (nregs == 2) {
flash.write_base = edev->resource[1].start;
flash.write_size = regs[1].reg_size;
} else {
printk("flash: Strange number of regs %d\n", nregs);
return -ENODEV;
}
flash.busy = 0;
#else
return -ENODEV;
#endif
}
printk("OBP Flash: RD %lx[%lx] WR %lx[%lx]\n",
flash.read_base, flash.read_size,
flash.write_base, flash.write_size);
err = misc_register(&flash_dev);
if (err) {
printk(KERN_ERR "flash: unable to get misc minor\n");
return err;
}
return 0;
}
static void __exit flash_cleanup(void)
{
misc_deregister(&flash_dev);
}
module_init(flash_init);
module_exit(flash_cleanup);
MODULE_LICENSE("GPL");
|
/* ============================================================
*
* This file is a part of digiKam project
* http://www.digikam.org
*
* Date : 2007-11-15
* Description : widget item delegate for setup collection view
*
* Copyright (C) 2015 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2007-2008 by Rafael Fernández López <ereslibre at kde dot org>
* Copyright (C) 2008 by Kevin Ottens <ervin at kde dot org>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, 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.
*
* ============================================================ */
#ifndef DW_ITEM_DELEGATE_H
#define DW_ITEM_DELEGATE_H
// Qt includes
#include <QEvent>
#include <QList>
#include <QPersistentModelIndex>
#include <QAbstractItemDelegate>
class QObject;
class QPainter;
class QStyleOption;
class QStyleOptionViewItem;
class QAbstractItemView;
class QItemSelection;
namespace Digikam
{
class DWItemDelegatePrivate;
class DWItemDelegatePool;
/**
* This class allows to create item delegates embedding simple widgets to interact
* with items. For instance you can add push buttons, line edits, etc. to your delegate
* and use them to modify the state of your model.
*/
class DWItemDelegate : public QAbstractItemDelegate
{
Q_OBJECT
public:
/**
* Creates a new ItemDelegate to be used with a given itemview.
*
* @param itemView the item view the new delegate will monitor
* @param parent the parent of this delegate
*/
explicit DWItemDelegate(QAbstractItemView* const itemView, QObject* const parent = 0);
virtual ~DWItemDelegate();
/**
* Retrieves the item view this delegate is monitoring.
*
* @return the item view this delegate is monitoring
*/
QAbstractItemView* itemView() const;
/**
* Retrieves the currently focused index. An invalid index if none is focused.
*
* @return the current focused index, or QPersistentModelIndex() if none is focused.
*/
QPersistentModelIndex focusedIndex() const;
protected:
/**
* Creates the list of widgets needed for an item.
*
* @note No initialization of the widgets is supposed to happen here.
* The widgets will be initialized based on needs for a given item.
*
* @note If you want to connect some widget signals to any slot, you should
* do it here.
*
* @arg index the index to create widgets for.
*
* @note If you want to know the index for which you are creating widgets, it is
* available as a QModelIndex Q_PROPERTY called "goya:creatingWidgetsForIndex".
* Ensure to add Q_DECLARE_METATYPE(QModelIndex) before your method definition
* to tell QVariant about QModelIndex.
*
* @return the list of newly created widgets which will be used to interact with an item.
* @see updateItemWidgets()
*/
virtual QList<QWidget*> createItemWidgets(const QModelIndex& index) const = 0;
/**
* Updates a list of widgets for its use inside of the delegate (painting or
* event handling).
*
* @note All the positioning and sizing should be done in item coordinates.
*
* @warning Do not make widget connections in here, since this method will
* be called very regularly.
*
* @param widgets the widgets to update
* @param option the current set of style options for the view.
* @param index the model index of the item currently manipulated.
*/
virtual void updateItemWidgets(const QList<QWidget*> widgets,
const QStyleOptionViewItem& option,
const QPersistentModelIndex& index) const = 0;
/**
* Sets the list of event @p types that a @p widget will block.
*
* Blocked events are not passed to the view. This way you can prevent an item
* from being selected when a button is clicked for instance.
*
* @param widget the widget which must block events
* @param types the list of event types the widget must block
*/
void setBlockedEventTypes(QWidget* const widget, QList<QEvent::Type> types) const;
/**
* Retrieves the list of blocked event types for the given widget.
*
* @param widget the specified widget.
*
* @return the list of blocked event types, can be empty if no events are blocked.
*/
QList<QEvent::Type> blockedEventTypes(QWidget* const widget) const;
private:
friend class DWItemDelegatePool;
friend class DWItemDelegateEventListener;
DWItemDelegatePrivate *const d;
};
} // namespace Digikam
Q_DECLARE_METATYPE(QList<QEvent::Type>)
#endif // Digikam
|
/**
* UGENE - Integrated Bioinformatics Tools.
* Copyright (C) 2008-2017 UniPro <ugene@unipro.ru>
* http://ugene.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#ifndef _U2_CMDLINE_TASK_RUNNER_H_
#define _U2_CMDLINE_TASK_RUNNER_H_
#include <QProcess>
#include <U2Core/Task.h>
namespace U2 {
class U2CORE_EXPORT CmdlineTaskConfig {
public:
CmdlineTaskConfig();
QString command;
QStringList arguments;
LogLevel logLevel;
bool withPluginList;
QStringList pluginList;
};
class U2CORE_EXPORT CmdlineTaskRunner : public Task {
Q_OBJECT
public:
CmdlineTaskRunner(const CmdlineTaskConfig &config);
void prepare();
ReportResult report();
protected:
virtual bool isCommandLogLine(const QString &logLine) const;
virtual bool parseCommandLogWord(const QString &logWord);
private:
void writeLog(QStringList &lines);
QString readStdout();
private slots:
void sl_onError(QProcess::ProcessError);
void sl_onReadStandardOutput();
void sl_onFinish(int exitCode, QProcess::ExitStatus exitStatus);
private:
CmdlineTaskConfig config;
QProcess* process;
QString processLogPrefix;
};
class U2CORE_EXPORT CmdlineTask : public Task {
Q_OBJECT
public:
CmdlineTask(const QString &name, TaskFlags flags);
ReportResult report();
protected:
virtual QString getTaskError() const;
private slots:
void sl_outputProgressAndState();
};
} // U2
#endif // _U2_CMDLINE_TASK_RUNNER_H_
|
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2012 by Amaury Pouly
*
* 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef OCOTP_IMX233_H
#define OCOTP_IMX233_H
#include "config.h"
#include "system.h"
/** STMP3700 and over have OCOTP registers
* where STMP3600 has laser fuses. */
#if IMX233_SUBTARGET >= 3700
#include "regs/regs-ocotp.h"
#define IMX233_NUM_OCOTP_CUST 4
#define IMX233_NUM_OCOTP_CRYPTO 4
#define IMX233_NUM_OCOTP_HWCAP 6
#define IMX233_NUM_OCOTP_OPS 4
#define IMX233_NUM_OCOTP_UN 3
#define IMX233_NUM_OCOTP_ROM 8
static inline void imx233_ocotp_open_banks(bool open)
{
if(open)
{
BF_CLR(OCOTP_CTRL, ERROR);
BF_SET(OCOTP_CTRL, RD_BANK_OPEN);
while(BF_RD(OCOTP_CTRL, BUSY));
}
else
BF_CLR(OCOTP_CTRL, RD_BANK_OPEN);
}
static inline uint32_t imx233_ocotp_read(volatile uint32_t *reg)
{
imx233_ocotp_open_banks(true);
uint32_t val = *reg;
imx233_ocotp_open_banks(false);
return val;
}
#else
#include "regs/regs-rtc.h"
#define IMX233_NUM_OCOTP_LASERFUSE 12
static inline uint32_t imx233_ocotp_read(volatile uint32_t *reg)
{
BF_WR_V(RTC_UNLOCK, KEY, VAL);
uint32_t val = *reg;
BF_WR(RTC_UNLOCK, KEY, 0);
return val;
}
#endif
#endif /* OCOTP_IMX233_H */
|
/*
* driver.c - centralized device driver management
*
* Copyright (c) 2002-3 Patrick Mochel
* Copyright (c) 2002-3 Open Source Development Labs
* Copyright (c) 2007 Greg Kroah-Hartman <gregkh@suse.de>
* Copyright (c) 2007 Novell Inc.
*
* This file is released under the GPLv2
*
*/
#include <linux/device.h>
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/sysfs.h>
#include "base.h"
static struct device *next_device(struct klist_iter *i)
{
struct klist_node *n = klist_next(i);
struct device *dev = NULL;
struct device_private *dev_prv;
if (n) {
dev_prv = to_device_private_driver(n);
dev = dev_prv->device;
}
return dev;
}
/**
* driver_for_each_device - Iterator for devices bound to a driver.
* @drv: Driver we're iterating.
* @start: Device to begin with
* @data: Data to pass to the callback.
* @fn: Function to call for each device.
*
* Iterate over the @drv's list of devices calling @fn for each one.
*/
int driver_for_each_device(struct device_driver *drv, struct device *start,
void *data, int (*fn)(struct device *, void *))
{
struct klist_iter i;
struct device *dev;
int error = 0;
if (!drv)
return -EINVAL;
klist_iter_init_node(&drv->p->klist_devices, &i,
start ? &start->p->knode_driver : NULL);
while ((dev = next_device(&i)) && !error)
error = fn(dev, data);
klist_iter_exit(&i);
return error;
}
EXPORT_SYMBOL_GPL(driver_for_each_device);
/**
* driver_find_device - device iterator for locating a particular device.
* @drv: The device's driver
* @start: Device to begin with
* @data: Data to pass to match function
* @match: Callback function to check device
*
* This is similar to the driver_for_each_device() function above, but
* it returns a reference to a device that is 'found' for later use, as
* determined by the @match callback.
*
* The callback should return 0 if the device doesn't match and non-zero
* if it does. If the callback returns non-zero, this function will
* return to the caller and not iterate over any more devices.
*/
struct device *driver_find_device(struct device_driver *drv,
struct device *start, void *data,
int (*match)(struct device *dev, void *data))
{
struct klist_iter i;
struct device *dev;
if (!drv || !drv->p)
return NULL;
klist_iter_init_node(&drv->p->klist_devices, &i,
(start ? &start->p->knode_driver : NULL));
while ((dev = next_device(&i)))
if (match(dev, data) && get_device(dev))
break;
klist_iter_exit(&i);
return dev;
}
EXPORT_SYMBOL_GPL(driver_find_device);
/**
* driver_create_file - create sysfs file for driver.
* @drv: driver.
* @attr: driver attribute descriptor.
*/
int driver_create_file(struct device_driver *drv,
const struct driver_attribute *attr)
{
int error;
if (drv)
error = sysfs_create_file(&drv->p->kobj, &attr->attr);
else
error = -EINVAL;
return error;
}
EXPORT_SYMBOL_GPL(driver_create_file);
/**
* driver_remove_file - remove sysfs file for driver.
* @drv: driver.
* @attr: driver attribute descriptor.
*/
void driver_remove_file(struct device_driver *drv,
const struct driver_attribute *attr)
{
if (drv)
sysfs_remove_file(&drv->p->kobj, &attr->attr);
}
EXPORT_SYMBOL_GPL(driver_remove_file);
int driver_add_groups(struct device_driver *drv,
const struct attribute_group **groups)
{
return sysfs_create_groups(&drv->p->kobj, groups);
}
void driver_remove_groups(struct device_driver *drv,
const struct attribute_group **groups)
{
sysfs_remove_groups(&drv->p->kobj, groups);
}
/**
* driver_register - register driver with bus
* @drv: driver to register
*
* We pass off most of the work to the bus_add_driver() call,
* since most of the things we have to do deal with the bus
* structures.
*/
int driver_register(struct device_driver *drv)
{
int ret;
struct device_driver *other;
printk("Enter into %s!!!!!!!!\n", __func__);
BUG_ON(!drv->bus->p);
if ((drv->bus->probe && drv->probe) ||
(drv->bus->remove && drv->remove) ||
(drv->bus->shutdown && drv->shutdown))
printk("Driver '%s' needs updating - please use "
"bus_type methods\n", drv->name);
other = driver_find(drv->name, drv->bus);
if (other) {
printk("Error: Driver '%s' is already registered, "
"aborting...\n", drv->name);
return -EBUSY;
}
ret = bus_add_driver(drv);
if (ret)
return ret;
ret = driver_add_groups(drv, drv->groups);
if (ret) {
bus_remove_driver(drv);
return ret;
}
kobject_uevent(&drv->p->kobj, KOBJ_ADD);
printk("Exit %s!!!!!!!\n", __func__);
return ret;
}
EXPORT_SYMBOL_GPL(driver_register);
/**
* driver_unregister - remove driver from system.
* @drv: driver.
*
* Again, we pass off most of the work to the bus-level call.
*/
void driver_unregister(struct device_driver *drv)
{
if (!drv || !drv->p) {
WARN(1, "Unexpected driver unregister!\n");
return;
}
driver_remove_groups(drv, drv->groups);
bus_remove_driver(drv);
}
EXPORT_SYMBOL_GPL(driver_unregister);
/**
* driver_find - locate driver on a bus by its name.
* @name: name of the driver.
* @bus: bus to scan for the driver.
*
* Call kset_find_obj() to iterate over list of drivers on
* a bus to find driver by name. Return driver if found.
*
* This routine provides no locking to prevent the driver it returns
* from being unregistered or unloaded while the caller is using it.
* The caller is responsible for preventing this.
*/
struct device_driver *driver_find(const char *name, struct bus_type *bus)
{
struct kobject *k = kset_find_obj(bus->p->drivers_kset, name);
struct driver_private *priv;
if (k) {
/* Drop reference added by kset_find_obj() */
kobject_put(k);
priv = to_driver(k);
return priv->driver;
}
return NULL;
}
EXPORT_SYMBOL_GPL(driver_find);
|
// -*- c++ -*-
// Generated by gtkmmproc -- DO NOT MODIFY!
#ifndef _GTKMM_OPTIONMENU_P_H
#define _GTKMM_OPTIONMENU_P_H
#ifndef GTKMM_DISABLE_DEPRECATED
#include <gtkmm/private/button_p.h>
#include <glibmm/class.h>
namespace Gtk
{
class OptionMenu_Class : public Glib::Class
{
public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef OptionMenu CppObjectType;
typedef GtkOptionMenu BaseObjectType;
typedef GtkOptionMenuClass BaseClassType;
typedef Gtk::Button_Class CppClassParent;
typedef GtkButtonClass BaseClassParent;
friend class OptionMenu;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
const Glib::Class& init();
static void class_init_function(void* g_class, void* class_data);
static Glib::ObjectBase* wrap_new(GObject*);
protected:
#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
//Callbacks (default signal handlers):
//These will call the *_impl member methods, which will then call the existing default signal callbacks, if any.
//You could prevent the original default signal handlers being called by overriding the *_impl method.
static void changed_callback(GtkOptionMenu* self);
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
//Callbacks (virtual functions):
#ifdef GLIBMM_VFUNCS_ENABLED
#endif //GLIBMM_VFUNCS_ENABLED
};
} // namespace Gtk
#endif // GTKMM_DISABLE_DEPRECATED
#endif /* _GTKMM_OPTIONMENU_P_H */
|
// -*- C++ -*-
//=============================================================================
/**
* @file SStringfwd.h
*
* $Id: SStringfwd.h 80826 2008-03-04 14:51:23Z wotte $
*
* Forward declarations and typedefs of ACE string types.
*
* @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
* @author Nanbor Wang <nanbor@cs.wustl.edu>
* @author Ossama Othman <ossama@uci.edu>
*/
//=============================================================================
#ifndef ACE_SSTRINGFWD_H
#define ACE_SSTRINGFWD_H
#include /**/ "ace/pre.h"
#include "ace/Basic_Types.h" /* ACE_WCHAR_T definition */
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#if (defined (__HP_aCC) && (36300 <= __HP_aCC) && (__HP_aCC <= 37300))
// Due to a bug in the aCC 3.xx compiler need to define the ACE_String_Base
// template before we can typedef ACE_CString
# include "ace/String_Base.h"
#endif /* __HP_aCC */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
template <class CHAR> class ACE_String_Base; // Forward declaration.
typedef ACE_WCHAR_T ACE_WSTRING_TYPE;
typedef ACE_String_Base<char> ACE_CString;
typedef ACE_String_Base<ACE_WSTRING_TYPE> ACE_WString;
// This allows one to use W or C String based on the Unicode
// setting
#if defined (ACE_USES_WCHAR)
typedef ACE_WString ACE_TString;
#else /* ACE_USES_WCHAR */
typedef ACE_CString ACE_TString;
#endif /* ACE_USES_WCHAR */
ACE_END_VERSIONED_NAMESPACE_DECL
#include /**/ "ace/post.h"
#endif /* ACE_SSTRINGFWD_H */
|
//------------------------------------------------
// The Virtual Monte Carlo examples
// Copyright (C) 2007 - 2014 Ivana Hrivnacova
// All rights reserved.
//
// For the licensing terms see geant4_vmc/LICENSE.
// Contact: root-vmc@cern.ch
//-------------------------------------------------
/// \file exampleE02LinkDef.h
/// \brief The CINT link definitions for example E02 classes
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class Ex02MCApplication+;
#pragma link C++ class Ex02MCStack+;
#pragma link C++ class Ex02Particle+;
#pragma link C++ class Ex02ChamberParameterisation+;
#pragma link C++ class Ex02DetectorConstruction+;
#pragma link C++ class Ex02DetectorConstructionOld+;
#pragma link C++ class Ex02MagField+;
#pragma link C++ class Ex02TrackerHit+;
#pragma link C++ class Ex02TrackerSD+;
//#pragma link C++ class std::stack<Ex02Particle*,deque<Ex02Particle*> >+;
#pragma link C++ class std::stack<Ex02Particle*>+;
#endif
|
#ifndef _VEC_TEMPLATE_H_
#define _VEC_TEMPLATE_H_
#include <cmath>
#include <iostream>
#include "parameters.h"
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
template<typename Type = Real>
class Vec_template
{
public :
static const gsl_rng_type * T;
static gsl_rng * gsl_r;
Type x,y;
static void Init_Rand (long int seed)
{
gsl_rng_env_setup();
T = gsl_rng_default;
gsl_r = gsl_rng_alloc (T);
gsl_rng_set(gsl_r, seed);
}
Vec_template () // This constructor will generate a null vector
{
x = y = 0;
}
Vec_template (const Type amplitude) // This constructor will initialize the vector as random vector with given magnitude (amplitude)
{
x = gsl_ran_flat (gsl_r, -amplitude, amplitude);
y = gsl_ran_flat (gsl_r, -amplitude, amplitude);
}
void Null() // Make all components of the vector zero
{
x = y = 0;
}
void Rand() // Choose random numbers for components of the vector with x in interval [-Lx, Lx] and y in interval [-Ly, Ly]
{
x = gsl_ran_flat (gsl_r, -Lx, Lx);
y = gsl_ran_flat (gsl_r, -Ly, Ly);
}
void Rand(const Type amplitude) // Choose random numbers for components of the vector in [-L, L]
{
x = gsl_ran_flat (gsl_r, -amplitude, amplitude);
y = gsl_ran_flat (gsl_r, -amplitude, amplitude);
}
void Rand(const Type amplitude_x, const Type amplitude_y) // Choose random numbers for components of the vector in [-Lx, Lx] for x and [-Ly, Ly] for y
{
x = gsl_ran_flat (gsl_r, -amplitude_x, amplitude_x);
y = gsl_ran_flat (gsl_r, -amplitude_y, amplitude_y);
}
void Rand_Lattice()
{
x = (Type) gsl_rng_uniform_int(gsl_r, (int) 2*Lx) - Lx;
y = (Type) gsl_rng_uniform_int(gsl_r, (int) 2*Ly) - Ly;
}
void Periodic_Transform()
{
// x -= Lx2*((int) (x / Lx));
// y -= Ly2*((int) (y / Ly));
x -= Lx2*((int) floor(x / Lx2 + 0.5));
y -= Ly2*((int) floor(y / Ly2 + 0.5));
}
Type Square() const// returns the magnitude of the vector
{
return (x*x + y*y);
}
void Unit() // return unit vector parallel to the vector
{
Type magnitude = sqrt(x*x + y*y);
x /= magnitude;
y /= magnitude;
}
Vec_template Rotate(Type phi)
{
Vec_template result;
result.x = cos(phi)*x - sin(phi)*y;
result.y = sin(phi)*x + cos(phi)*y;
return (result);
}
Vec_template operator+ (const Vec_template p1) const
{
Vec_template result;
result.x = x + p1.x;
result.y = y + p1.y;
return result;
}
Vec_template operator- (const Vec_template p1) const
{
Vec_template result;
result.x = x - p1.x;
result.y = y - p1.y;
return result;
}
Vec_template operator/ (const Type lambda) const
{
Vec_template result;
result.x = x / lambda;
result.y = y / lambda;
return result;
}
Vec_template operator* (const Type lambda) const
{
Vec_template result;
result.x = x * lambda;
result.y = y * lambda;
return result;
}
Vec_template operator+= (const Vec_template p1)
{
x += p1.x;
y += p1.y;
return *this;
}
Vec_template operator-= (const Vec_template p1)
{
x -= p1.x;
y -= p1.y;
return *this;
}
Vec_template operator/= (const Type lambda)
{
x /= lambda;
y /= lambda;
return *this;
}
Vec_template operator*= (const Type lambda)
{
x *= lambda;
y *= lambda;
return *this;
}
Type operator* (const Vec_template p1) const
{
return (x*p1.x + y*p1.y);
}
// for binary output only (comment this function for txt output)
void write(std::ostream& os)
{
Saving_Real temp_float;
temp_float = (Saving_Real) x;
os.write((char*) &temp_float,sizeof(Saving_Real) / sizeof(char));
temp_float = (Saving_Real) y;
os.write((char*) &temp_float,sizeof(Saving_Real) / sizeof(char));
}
// for either binary or txt output
friend std::ostream& operator<<(std::ostream& os, const Vec_template t)
{
os << t.x << "\t" << t.y;
return (os);
}
friend std::istream& operator>>(std::istream& is, Vec_template& t)
{
// for binary input
Saving_Real temp_float;
is.read((char*) &temp_float,sizeof(Saving_Real) / sizeof(char));
t.x = temp_float;
is.read((char*) &temp_float,sizeof(Saving_Real) / sizeof(char));
t.y = temp_float;
return is;
// // for txt input
// is >> t.x;
// is >> t.y;
// return is;
}
~Vec_template()
{
}
};
template<typename Type> const gsl_rng_type * Vec_template<Type>::T;
template<typename Type> gsl_rng * Vec_template<Type>::gsl_r;
/*class Index{*/
/*public:*/
/* int x,y;*/
/* void Find(Vec_template<> r)*/
/* {*/
/* x = (int) (r.x + Lx)*divisor_x / (Lx2);*/
/* y = (int) (r.y + Ly)*divisor_y / (Ly2);*/
/* }*/
/*};*/
typedef Vec_template<Real> C2DVector;
typedef Vec_template<Saving_Real> SavingVector;
#endif
|
#include <stdio.h>
int main(void)
{
void Exchange(int * a, int * b);//º¯ÊýÉùÃ÷
int first, last, index, sum;//¶¨Òå±äÁ¿
scanf("%d", &sum);//ÊäÈë²âÊÔÊý¾ÝµÄ×éÊý
for (index = 1; index <= sum; index++)
{
scanf("%d %d", &first, &last);//ÊäÈë²âÊÔÊý¾Ý
Exchange(&first, &last);//µ÷Óú¯Êý
printf("Case %d: %d %d\n", index, first, last);//Êä³ö»¥»»ºóµÄÖµ
}
return 0;
}
void Exchange(int * a, int * b)//¶¨Ò庯Êý
//¹¦ÄÜ£ºÓÃÖ¸Õ뻥»»Á½¸öÕûÐαäÁ¿µÄÖµ
{
int temp;
temp = *a;//a¾ÍÊÇÖ¸Õë±äÁ¿£¬a±£´æµÄ¾ÍÊÇfristµÄµØÖ·£¬*aµÈ¼ÛÓÚfirstµÄÖµ
*a = *b;
*b = temp;
}
/*
×ܽ᣺1¡¢Ö¸Õë¾ÍÊǵØÖ·£¬µØÖ·¾ÍÊÇÖ¸Õë
2¡¢µØÖ·¾ÍÊÇÄڴ浥λµÄ±àºÅ
3¡¢Ö¸Õë±äÁ¿ÊÇÓдæ·ÅµØÖ·µÄ±äÁ¿
4¡¢Ö¸ÕëºÍÖ¸Õë±äÁ¿ÊÇÁ½¸ö²»Í¬µÄ¸ÅÄî
5¡¢µ«ÊÇҪעÒ⣬ͨ³£ÎÒÃÇÐðÊöʱ»á°ÑÖ¸Õë±äÁ¿¼ò³ÆÖ¸Õë
ʵ¼ÊÉÏËûÃDz»Ò»Ñù
*/
|
/*
** initial coding by fx2
*/
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <signal.h>
#include <sys/time.h>
#include <rcinput.h>
#include <draw.h>
#include <pig.h>
#include <colors.h>
#include <yahtzee.h>
#include <plugin.h>
#include <fx2math.h>
extern int doexit;
extern int debug;
extern unsigned short actcode;
extern unsigned short realcode;
static void setup_colors( void )
{
FBSetColor( YELLOW, 230, 230, 30 );
FBSetColor( GREEN, 30, 230, 30 );
FBSetColor( STEELBLUE, 80, 80, 220 );
FBSetColor( BLUE, 30, 30, 230 );
FBSetColor( GRAY, 130, 130, 130 );
FBSetColor( DARK, 60, 60, 60 );
FBSetColor( GREEN2, 20, 200, 20 );
FBSetupColors( );
}
int yahtzee_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile )
{
struct timeval tv;
int x;
if ( FBInitialize( 720, 576, 8, fdfb ) < 0 )
return -1;
setup_colors();
if ( RcInitialize( fdrc ) < 0 )
return -1;
doexit=0;
while( !doexit )
{
EnterPlayer();
if ( !doexit )
{
RunYahtzee();
DrawWinner();
}
}
Fx2StopPig();
/* fx2 */
/* buffer leeren, damit neutrino nicht rumspinnt */
realcode = RC_0;
while( realcode != 0xee )
{
tv.tv_sec = 0;
tv.tv_usec = 300000;
x = select( 0, 0, 0, 0, &tv ); /* 300ms pause */
RcGetActCode( );
}
RcClose();
FBClose();
return 0;
}
int plugin_exec( PluginParam *par )
{
int fd_fb=-1;
int fd_rc=-1;
for( ; par; par=par->next )
{
if ( !strcmp(par->id,P_ID_FBUFFER) )
fd_fb=_atoi(par->val);
else if ( !strcmp(par->id,P_ID_RCINPUT) )
fd_rc=_atoi(par->val);
else if ( !strcmp(par->id,P_ID_NOPIG) )
fx2_use_pig=!_atoi(par->val);
}
return yahtzee_exec( fd_fb, fd_rc, -1, 0 );
}
|
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: udacodec.h 21546 2009-06-28 17:43:04Z bertrik $
*
* Copyright (C) 2009 by Bertrik Sikken
*
* 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
/* perform a hardware reset of the codec */
void udacodec_reset(void);
/* write a single register */
int udacodec_write(unsigned char reg, unsigned short value);
/* write two consecutive registers */
int udacodec_write2(unsigned char reg,
unsigned short value1, unsigned short value2);
|
/**
* \file pkcs11.h
*
* \brief Wrapper for PKCS#11 library libpkcs11-helper
*
* \author Adriaan de Jong <dejong@fox-it.com>
*
* Copyright (C) 2006-2014, ARM Limited, All Rights Reserved
*
* This file is part of mbed TLS (https://tls.mbed.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef ROUGE_PKCS11_H
#define ROUGE_PKCS11_H
#if !defined(ROUGE_CONFIG_FILE)
#include "config.h"
#else
#include ROUGE_CONFIG_FILE
#endif
#if defined(ROUGE_PKCS11_C)
#include "x509_crt.h"
#include <pkcs11-helper-1.0/pkcs11h-certificate.h>
#if defined(_MSC_VER) && !defined(inline)
#define inline _inline
#else
#if defined(__ARMCC_VERSION) && !defined(inline)
#define inline __inline
#endif /* __ARMCC_VERSION */
#endif /*_MSC_VER */
#ifdef __cplusplus
extern "C" {
#endif
/**
* Context for PKCS #11 private keys.
*/
typedef struct {
pkcs11h_certificate_t pkcs11h_cert;
int len;
} pkcs11_context;
/**
* Fill in a mbed TLS certificate, based on the given PKCS11 helper certificate.
*
* \param cert X.509 certificate to fill
* \param pkcs11h_cert PKCS #11 helper certificate
*
* \return 0 on success.
*/
int pkcs11_x509_cert_init( x509_crt *cert, pkcs11h_certificate_t pkcs11h_cert );
/**
* Initialise a pkcs11_context, storing the given certificate. Note that the
* pkcs11_context will take over control of the certificate, freeing it when
* done.
*
* \param priv_key Private key structure to fill.
* \param pkcs11_cert PKCS #11 helper certificate
*
* \return 0 on success
*/
int pkcs11_priv_key_init( pkcs11_context *priv_key,
pkcs11h_certificate_t pkcs11_cert );
/**
* Free the contents of the given private key context. Note that the structure
* itself is not freed.
*
* \param priv_key Private key structure to cleanup
*/
void pkcs11_priv_key_free( pkcs11_context *priv_key );
/**
* \brief Do an RSA private key decrypt, then remove the message
* padding
*
* \param ctx PKCS #11 context
* \param mode must be RSA_PRIVATE, for compatibility with rsa.c's signature
* \param input buffer holding the encrypted data
* \param output buffer that will hold the plaintext
* \param olen will contain the plaintext length
* \param output_max_len maximum length of the output buffer
*
* \return 0 if successful, or an ROUGE_ERR_RSA_XXX error code
*
* \note The output buffer must be as large as the size
* of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise
* an error is thrown.
*/
int pkcs11_decrypt( pkcs11_context *ctx,
int mode, size_t *olen,
const unsigned char *input,
unsigned char *output,
size_t output_max_len );
/**
* \brief Do a private RSA to sign a message digest
*
* \param ctx PKCS #11 context
* \param mode must be RSA_PRIVATE, for compatibility with rsa.c's signature
* \param md_alg a ROUGE_MD_* (use ROUGE_MD_NONE for signing raw data)
* \param hashlen message digest length (for ROUGE_MD_NONE only)
* \param hash buffer holding the message digest
* \param sig buffer that will hold the ciphertext
*
* \return 0 if the signing operation was successful,
* or an ROUGE_ERR_RSA_XXX error code
*
* \note The "sig" buffer must be as large as the size
* of ctx->N (eg. 128 bytes if RSA-1024 is used).
*/
int pkcs11_sign( pkcs11_context *ctx,
int mode,
md_type_t md_alg,
unsigned int hashlen,
const unsigned char *hash,
unsigned char *sig );
/**
* SSL/TLS wrappers for PKCS#11 functions
*/
static inline int ssl_pkcs11_decrypt( void *ctx, int mode, size_t *olen,
const unsigned char *input, unsigned char *output,
size_t output_max_len )
{
return pkcs11_decrypt( (pkcs11_context *) ctx, mode, olen, input, output,
output_max_len );
}
static inline int ssl_pkcs11_sign( void *ctx,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
int mode, md_type_t md_alg, unsigned int hashlen,
const unsigned char *hash, unsigned char *sig )
{
((void) f_rng);
((void) p_rng);
return pkcs11_sign( (pkcs11_context *) ctx, mode, md_alg,
hashlen, hash, sig );
}
static inline size_t ssl_pkcs11_key_len( void *ctx )
{
return ( (pkcs11_context *) ctx )->len;
}
#ifdef __cplusplus
}
#endif
#endif /* ROUGE_PKCS11_C */
#endif /* ROUGE_PKCS11_H */
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* 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.
*
* Copyright (C) 2007 - 2008 Novell, Inc.
* Copyright (C) 2007 - 2010 Red Hat, Inc.
*/
#ifndef NM_MANAGER_H
#define NM_MANAGER_H
#include <glib.h>
#include <glib-object.h>
#include <dbus/dbus-glib.h>
#include "nm-device.h"
#include "nm-settings.h"
#include "nm-auth-subject.h"
#define NM_TYPE_MANAGER (nm_manager_get_type ())
#define NM_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_MANAGER, NMManager))
#define NM_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_MANAGER, NMManagerClass))
#define NM_IS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_MANAGER))
#define NM_IS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_MANAGER))
#define NM_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_MANAGER, NMManagerClass))
typedef enum {
NM_MANAGER_ERROR_UNKNOWN_CONNECTION = 0, /*< nick=UnknownConnection >*/
NM_MANAGER_ERROR_UNKNOWN_DEVICE, /*< nick=UnknownDevice >*/
NM_MANAGER_ERROR_UNMANAGED_DEVICE, /*< nick=UnmanagedDevice >*/
NM_MANAGER_ERROR_SYSTEM_CONNECTION, /*< nick=SystemConnection >*/
NM_MANAGER_ERROR_PERMISSION_DENIED, /*< nick=PermissionDenied >*/
NM_MANAGER_ERROR_CONNECTION_NOT_ACTIVE, /*< nick=ConnectionNotActive >*/
NM_MANAGER_ERROR_ALREADY_ASLEEP_OR_AWAKE, /*< nick=AlreadyAsleepOrAwake >*/
NM_MANAGER_ERROR_ALREADY_ENABLED_OR_DISABLED, /*< nick=AlreadyEnabledOrDisabled >*/
NM_MANAGER_ERROR_UNSUPPORTED_CONNECTION_TYPE, /*< nick=UnsupportedConnectionType >*/
NM_MANAGER_ERROR_DEPENDENCY_FAILED, /*< nick=DependencyFailed >*/
NM_MANAGER_ERROR_AUTOCONNECT_NOT_ALLOWED, /*< nick=AutoconnectNotAllowed >*/
NM_MANAGER_ERROR_CONNECTION_ALREADY_ACTIVE, /*< nick=ConnectionAlreadyActive >*/
NM_MANAGER_ERROR_INTERNAL, /*< nick=Internal >*/
} NMManagerError;
#define NM_MANAGER_VERSION "version"
#define NM_MANAGER_STATE "state"
#define NM_MANAGER_STARTUP "startup"
#define NM_MANAGER_NETWORKING_ENABLED "networking-enabled"
#define NM_MANAGER_WIRELESS_ENABLED "wireless-enabled"
#define NM_MANAGER_WIRELESS_HARDWARE_ENABLED "wireless-hardware-enabled"
#define NM_MANAGER_WWAN_ENABLED "wwan-enabled"
#define NM_MANAGER_WWAN_HARDWARE_ENABLED "wwan-hardware-enabled"
#define NM_MANAGER_WIMAX_ENABLED "wimax-enabled"
#define NM_MANAGER_WIMAX_HARDWARE_ENABLED "wimax-hardware-enabled"
#define NM_MANAGER_ACTIVE_CONNECTIONS "active-connections"
#define NM_MANAGER_CONNECTIVITY "connectivity"
#define NM_MANAGER_PRIMARY_CONNECTION "primary-connection"
#define NM_MANAGER_ACTIVATING_CONNECTION "activating-connection"
#define NM_MANAGER_DEVICES "devices"
/* Not exported */
#define NM_MANAGER_HOSTNAME "hostname"
#define NM_MANAGER_SLEEPING "sleeping"
/* Internal signals */
#define NM_MANAGER_ACTIVE_CONNECTION_ADDED "active-connection-added"
#define NM_MANAGER_ACTIVE_CONNECTION_REMOVED "active-connection-removed"
typedef struct {
GObject parent;
} NMManager;
typedef struct {
GObjectClass parent;
/* Signals */
void (*device_added) (NMManager *manager, NMDevice *device);
void (*device_removed) (NMManager *manager, NMDevice *device);
void (*state_changed) (NMManager *manager, guint state);
} NMManagerClass;
GType nm_manager_get_type (void);
/* nm_manager_new() should only be used by main.c */
NMManager *nm_manager_new (NMSettings *settings,
const char *state_file,
gboolean initial_net_enabled,
gboolean initial_wifi_enabled,
gboolean initial_wwan_enabled,
gboolean initial_wimax_enabled,
GError **error);
NMManager *nm_manager_get (void);
void nm_manager_start (NMManager *manager);
const GSList *nm_manager_get_active_connections (NMManager *manager);
GSList *nm_manager_get_activatable_connections (NMManager *manager);
/* Device handling */
const GSList *nm_manager_get_devices (NMManager *manager);
NMDevice *nm_manager_get_device_by_master (NMManager *manager,
const char *master,
const char *driver);
NMDevice *nm_manager_get_device_by_ifindex (NMManager *manager,
int ifindex);
NMActiveConnection *nm_manager_activate_connection (NMManager *manager,
NMConnection *connection,
const char *specific_object,
NMDevice *device,
NMAuthSubject *subject,
GError **error);
gboolean nm_manager_deactivate_connection (NMManager *manager,
const char *connection_path,
NMDeviceStateReason reason,
GError **error);
/* State handling */
NMState nm_manager_get_state (NMManager *manager);
#endif /* NM_MANAGER_H */
|
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <tchar.h>
// TODO: reference additional headers your program requires here
|
#include "Energy.h"
int main(){
int a = 0;
Energy *energy0 = calloc(sizeof(Energy), 1);
Energy *energy1 = calloc(sizeof(Energy), 1);
//Energy *energy2 = calloc(sizeof(Energy), 1);
initEnergy(energy0, 1);
initEnergy(energy1, 1);
//initEnergy(energy2, 1);
setSensor(energy0, "ACa", "A", "", "/dev/ttyACM0");
setSensor(energy1, "ACb", "B", "", "/dev/ttyACM0");
//setSensor(energy5, "AC ", "C", "", "/dev/ttyACM0");
setTimer(energy0, 10);
setTimer(energy1, 10);
//setTimer(energy2, 10);
startEnergy(energy0);
startEnergy(energy1);
//startEnergy(energy2);
while(a < 60){
//system("clear");
printEnergy(energy0);
printEnergy(energy1);
//printEnergy(energy2);
a ++;
sleep(10);
}
//system("clear");
printf("stop \n");
stopEnergy(energy0);
stopEnergy(energy1);
//stopEnergy(energy2);
sleep(6);
printEnergy(energy0);
printEnergy(energy1);
//printEnergy(energy2);
}
|
/**
* @file thinfnan.h
* Therion number constants.
*/
/* Copyright (C) 2000 Stacho Mudrak
*
* $Date: $
* $RCSfile: $
* $Revision: $
*
* --------------------------------------------------------------------
* 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
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* --------------------------------------------------------------------
*/
#ifndef thinfnan_h
#define thinfnan_h
#include <math.h>
// nan handling
#ifdef NAN
#ifdef THLINUX
#define thnan NAN
#define thisnan isnan
#else
#define thnan -9e99
#define thisnan(number) (number == thnan)
#endif
#else
#define thnan -9e99
#define thisnan(number) (number == thnan)
#endif
// infinity handling
#ifdef INFINITY
#ifdef THLINUX
#define thinf INFINITY
#define thisinf isinf
#else
#define thinf 1e100
#define thisinf(number) (number >= thinf ? 1 : (number <= -thinf ? -1 : 0))
#endif
#else
#define thinf 1e100
#define thisinf(number) (number >= thinf ? 1 : (number <= -thinf ? -1 : 0))
#endif
/**
* Update double variable if nan.
*
* @param oval Original value
* @param uval Update value
*/
void thnan_update(double & oval, double uval);
/**
* A inf nan printing macro.
*
* -Inf -> -999.999
* Inf -> 999.999
* NaN -> 1000.0001
*/
#define thinn(cislo) (thisnan(cislo) ? 1000.0001 : \
(thisinf(cislo) == 1 ? 999.999 : \
(thisinf(cislo) == -1 ? -999.999 : cislo)))
// infnan.h
#endif
/**
* Print number in nan format.
*/
#define thprintinfnan(cislo) {\
if (thisnan(cislo)) \
thprintf("thnan"); \
else if (thisinf(cislo) == 1) \
thprintf("thinf"); \
else if (thisinf(cislo) == -1) \
thprintf("-thinf"); \
else \
thprintf("%lg",cislo);}
#define THPI 3.1415926535898
#define thnanpow2(cislo) ((thisnan(cislo) ? 0.0 : cislo) * (thisnan(cislo) ? 0.0 : cislo))
#define thdxyz2length(dx,dy,dz) (sqrt(thnanpow2(dx) + thnanpow2(dy) + thnanpow2(dz)))
#define thdxyz2b(dx,dy,dz) (270 - (atan2(dy,dx) / THPI * 180.0 + 180))
#define thdxyz2bearing(dx,dy,dz) (thdxyz2b(dx,dy,dz) < 0.0 ? thdxyz2b(dx,dy,dz) + 360.0 : thdxyz2b(dx,dy,dz))
#define thdxyz2clino(dx,dy,dz) (atan2(dz,sqrt(thnanpow2(dx) + thnanpow2(dy))) / THPI * 180.0)
|
/*
* This file is part of ltrace.
* Copyright (C) 2011,2012,2013 Petr Machata, Red Hat 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 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 St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include "vect.h"
static void *
slot(struct vect *vec, size_t i)
{
return ((unsigned char *)vec->data) + vec->elt_size * i;
}
static const void *
cslot(const struct vect *vec, size_t i)
{
return ((const unsigned char *)vec->data) + vec->elt_size * i;
}
void
vect_init(struct vect *vec, size_t elt_size)
{
*vec = (struct vect){ NULL, 0, 0, elt_size };
}
static int
copy_elt(void *tgt, const void *src, void *data)
{
struct vect *target = data;
memcpy(tgt, src, target->elt_size);
return 0;
}
int
vect_clone(struct vect *target, const struct vect *source,
int (*clone)(void *tgt, const void *src, void *data),
void (*dtor)(void *elt, void *data),
void *data)
{
vect_init(target, source->elt_size);
if (vect_reserve(target, source->size) < 0)
return -1;
if (clone == NULL) {
assert(dtor == NULL);
clone = copy_elt;
data = target;
} else {
assert(dtor != NULL);
}
size_t i;
for (i = 0; i < source->size; ++i)
if (clone(slot(target, i), cslot(source, i), data) < 0)
goto fail;
target->size = source->size;
return 0;
fail:
/* N.B. destroy the elements in opposite order. */
if (dtor != NULL)
while (i-- != 0)
dtor(slot(target, i), data);
vect_destroy(target, NULL, NULL);
return -1;
}
int
vect_reserve(struct vect *vec, size_t count)
{
if (count > vec->allocated) {
size_t na = vec->allocated != 0 ? 2 * vec->allocated : 4;
while (na < count)
na *= 2;
void *n = realloc(vec->data, na * vec->elt_size);
if (n == NULL)
return -1;
vec->data = n;
vec->allocated = na;
}
assert(count <= vec->allocated);
return 0;
}
size_t
vect_size(const struct vect *vec)
{
return vec->size;
}
int
vect_empty(const struct vect *vec)
{
return vec->size == 0;
}
int
vect_reserve_additional(struct vect *vec, size_t count)
{
return vect_reserve(vec, vect_size(vec) + count);
}
int
vect_pushback(struct vect *vec, void *eltp)
{
if (vect_reserve_additional(vec, 1) < 0)
return -1;
memcpy(slot(vec, vec->size++), eltp, vec->elt_size);
return 0;
}
void
vect_erase(struct vect *vec, size_t start, size_t end,
void (*dtor)(void *emt, void *data), void *data)
{
assert(start < vect_size(vec) || start == 0);
assert(end <= vect_size(vec));
/* First, destroy the elements that are to be erased. */
if (dtor != NULL) {
size_t i;
for (i = start; i < end; ++i)
dtor(slot(vec, i), data);
}
/* Now move the tail forward and adjust size. */
memmove(slot(vec, start), slot(vec, end),
slot(vec, vec->size) - slot(vec, end));
vec->size -= end - start;
}
void
vect_popback(struct vect *vec,
void (*dtor)(void *emt, void *data), void *data)
{
assert(vect_size(vec) > 0);
vect_erase(vec, vect_size(vec)-1, vect_size(vec), dtor, data);
}
void
vect_destroy(struct vect *vec, void (*dtor)(void *emt, void *data), void *data)
{
if (vec == NULL)
return;
vect_erase(vec, 0, vect_size(vec), dtor, data);
assert(vect_size(vec) == 0);
free(vec->data);
}
void *
vect_each(struct vect *vec, void *start_after,
enum callback_status (*cb)(void *, void *), void *data)
{
size_t i = start_after == NULL ? 0
: ((start_after - vec->data) / vec->elt_size) + 1;
for (; i < vec->size; ++i) {
void *slt = slot(vec, i);
switch ((*cb)(slt, data)) {
case CBS_FAIL:
/* XXX handle me */
case CBS_STOP:
return slt;
case CBS_CONT:
break;
}
}
return NULL;
}
void
vect_qsort(struct vect *vec, int (*compar)(const void *, const void *))
{
qsort(vec->data, vec->size, vec->elt_size, compar);
}
const void *
vect_each_cst(const struct vect *vec, const void *start_after,
enum callback_status (*cb)(const void *, void *), void *data)
{
return vect_each((struct vect *)vec, (void *)start_after,
(void *)cb, data);
}
|
/*
* Dolda Connect - Modular multiuser Direct Connect-style client
* Copyright (C) 2004 Fredrik Tolf <fredrik@dolda2000.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _TRANSFER_H
#define _TRANSFER_H
#include <wchar.h>
#include <sys/types.h>
#include "net.h"
#include "filenet.h"
#include "utils.h"
#include "auth.h"
#define TRNS_WAITING 0
#define TRNS_HS 1
#define TRNS_MAIN 2
#define TRNS_DONE 3
#define TRNSD_UNKNOWN 0
#define TRNSD_UP 1
#define TRNSD_DOWN 2
#define TRNSE_NOERROR 0
#define TRNSE_NOTFOUND 1
#define TRNSE_NOSLOTS 2
struct transfer
{
struct transfer *next, *prev;
int id, close;
union
{
int w;
struct
{
int byop:1;
int sgranted:1;
int minislot:1;
} b;
} flags;
struct timer *etimer;
time_t timeout, activity, lastreq;
wchar_t *actdesc;
struct fnet *fnet;
wchar_t *peerid, *peernick;
wchar_t *path;
uid_t owner;
int state, dir, error;
off_t size, curpos, endpos, localpos;
struct fnetnode *fn;
struct socket *localend, *datapipe;
struct wcspair *args;
pid_t filter;
struct authhandle *auth;
struct socket *filterout;
char *filterbuf;
struct hash *hash;
size_t filterbufsize, filterbufdata;
wchar_t *exitstatus;
CBCHAIN(trans_ac, struct transfer *transfer, wchar_t *attrib);
CBCHAIN(trans_p, struct transfer *transfer);
CBCHAIN(trans_act, struct transfer *transfer);
CBCHAIN(trans_destroy, struct transfer *transfer);
CBCHAIN(trans_filterout, struct transfer *transfer, wchar_t *cmd, wchar_t *arg);
};
void freetransfer(struct transfer *transfer);
struct transfer *newtransfer(void);
void linktransfer(struct transfer *transfer);
int slotsleft(void);
void bumptransfer(struct transfer *transfer);
struct transfer *findtransfer(int id);
struct transfer *hasupload(struct fnet *fnet, wchar_t *peerid);
struct transfer *newupload(struct fnetnode *fn, struct fnet *fnet, wchar_t *nickid, struct socket *dpipe);
void transfersetnick(struct transfer *transfer, wchar_t *newnick);
void transfersetpath(struct transfer *transfer, wchar_t *newpath);
void transfersetstate(struct transfer *transfer, int newstate);
void transfersetsize(struct transfer *transfer, off_t newsize);
void transferseterror(struct transfer *transfer, int error);
void transfersetactivity(struct transfer *transfer, wchar_t *desc);
void transferattach(struct transfer *transfer, struct socket *dpipe);
void transferdetach(struct transfer *transfer);
void resettransfer(struct transfer *transfer);
void transfersetlocalend(struct transfer *transfer, struct socket *sk);
int forkfilter(struct transfer *transfer);
void transferprepul(struct transfer *transfer, off_t size, off_t start, off_t end, struct socket *lesk);
void transferstartul(struct transfer *transfer, struct socket *sk);
void transfersethash(struct transfer *transfer, struct hash *hash);
struct transfer *finddownload(wchar_t *peerid);
void transferstartdl(struct transfer *transfer, struct socket *sk);
void trytransferbypeer(struct fnet *fnet, wchar_t *peerid);
extern struct transfer *transfers;
extern unsigned long long bytesupload;
extern unsigned long long bytesdownload;
EGCBCHAIN(newtransfercb, struct transfer *);
#endif
|
/* This file is part of the KDE project
Copyright (C) 2000 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __kdirnotify_h__
#define __kdirnotify_h__
#include <dcopobject.h>
#include <kurl.h>
/**
* An abstract class that receives notifications of added and removed files
* in any directory, local or remote.
* The information comes from the konqueror/kdesktop instance where the
* operation was done, and can interest KDirListers, bookmark handlers, etc.
*/
class TDEIO_EXPORT KDirNotify : public DCOPObject
{
K_DCOP
protected:
KDirNotify();
virtual ~KDirNotify() {}
public:
k_dcop:
/**
* Notify that files have been added in @p directory
* Note: this is ASYNC so that it can be used with a broadcast.
* @param directory the directory that contains the new files
*/
virtual ASYNC FilesAdded( const KURL & directory ) = 0;
/**
* Notify that files have been deleted.
* Note: this is ASYNC so that it can be used with a broadcast
* @param fileList the files that have been deleted
*/
virtual ASYNC FilesRemoved( const KURL::List & fileList ) = 0;
/**
* Notify that files have been changed.
* At the moment, this is only used for new icon, but it could be
* used for size etc. as well.
* Note: this is ASYNC so that it can be used with a broadcast.
* @param fileList the list of changed files
*/
virtual ASYNC FilesChanged( const KURL::List & fileList ) = 0;
/**
* Notify that a file has been renamed.
* Note: this is ASYNC so that it can be used with a broadcast
* @param src a list containing original names of the renamed files
* @param dst a list of original names of the renamed files
*/
virtual ASYNC FileRenamed( const KURL &src, const KURL &dst );
// WARNING: When adding new methods, make sure to update
// kdirnotify_stub.cpp and kdirnotify_stub.h manually.
// They are not automatically generated since they contain
// handcoded changes.
private:
// @internal
static int s_serial;
protected:
virtual void virtual_hook( int id, void* data );
};
#endif
|
#ifndef DECLARE_NODE_H
#define DECLARE_NODE_H
#include <memory>
#include <vector>
#include <boost/ptr_container/ptr_vector.hpp>
#include "syntax_tree/stmt_node.h"
#include "syntax_tree/type_node.h"
#include "syntax_tree/exp_node.h"
#include "syntax_tree/name_node.h"
namespace flang {
class VarDeclFragmentNode : public ASTNode {
INHERIT_AST_NODE(VarDeclFragmentNode, ASTNode, VAR_DECL_FRAGMENT_NODE)
public:
VarDeclFragmentNode(const std::string& name, ExpNode* initializer);
~VarDeclFragmentNode() override {}
void setName(std::string name) { name_ = name; }
const std::string& getName() { return name_; }
ExpNode* getInitializer() { return initializer_.get(); }
void setInitializer(ExpNode* initializer) {
initializer_.reset(initializer);
initializer_->setParent(this);
}
private:
std::string name_;
std::unique_ptr<ExpNode> initializer_;
};
class VarDeclNode : public StmtNode {
INHERIT_AST_NODE(VarDeclNode, StmtNode, VAR_DECL_NODE)
public:
VarDeclNode() {}
~VarDeclNode() override {}
void addVarDeclFragment(VarDeclFragmentNode* var_decl_fragment) {
var_decl_fragments_.push_back(var_decl_fragment);
var_decl_fragment->setParent(this);
}
const boost::ptr_vector<VarDeclFragmentNode>& getVarDeclFragmentList() {
return var_decl_fragments_;
}
TypeNode* getDataType() { return data_type_.get(); }
void setDataType(TypeNode* data_type) {
data_type_.reset(data_type);
data_type_->setParent(this);
}
private:
std::unique_ptr<TypeNode> data_type_;
boost::ptr_vector<VarDeclFragmentNode> var_decl_fragments_;
};
class VarNode : public ExpNode {
INHERIT_AST_NODE(VarNode, ExpNode, VAR_NODE)
public:
VarNode(SimpleNameNode* node);
~VarNode() override {}
void setName(SimpleNameNode* name) {
CHECK(name);
name_.reset(name);
name_->setParent(this);
}
SimpleNameNode* getName() const {
return name_.get();
}
bool getChildNodes(ASTNodeList* child_nodes) override;
private:
std::unique_ptr<SimpleNameNode> name_;
};
} // namespace flang
#endif
|
#include "pbcc3_test.h"
volatile char ofc = 0x12;
int function(char param1, int param2, long param3) {
return param1 + param2 + param3;
}
void main(void) {
volatile int foo = function(11, 333, 77777);
END_EXECUTION;
// s0 == 0x29, s1 == 31
} |
/*
* Copyright (c) 2008 Cyrille Berger <cberger@cberger.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* 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 Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _GRID_H_
#define _GRID_H_
#include <kparts/plugin.h>
class GridPlugin : public KParts::Plugin
{
Q_OBJECT
public:
GridPlugin(QObject *parent, const QStringList &);
virtual ~GridPlugin();
};
#endif
|
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <sched.h>
#include <signal.h>
#include <unistd.h>
#define STACK_SIZE (1024 * 1024)
static char child_stack[STACK_SIZE];
char* const child_args[] = {
"/bin/bash",
NULL
};
int child_main(void* arg)
{
printf(" - World !\n");
execv(child_args[0], child_args);
printf("Ooops\n");
return 1;
}
int main()
{
printf(" - Hello ?\n");
int child_pid = clone(child_main, child_stack+STACK_SIZE, SIGCHLD, NULL);
waitpid(child_pid, NULL, 0);
return 0;
}
|
/* $Id$ */
/*--------------------------------------------------------------------*/
/*; Copyright (C) 2014 */
/*; Associated Universities, Inc. Washington DC, USA. */
/*; */
/*; 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., 675 Massachusetts Ave, Cambridge, */
/*; MA 02139, USA. */
/*; */
/*;Correspondence about this software should be addressed as follows: */
/*; Internet email: bcotton@nrao.edu. */
/*; Postal address: William Cotton */
/*; National Radio Astronomy Observatory */
/*; 520 Edgemont Road */
/*; Charlottesville, VA 22903-2475 USA */
/*--------------------------------------------------------------------*/
#ifndef OBITGPUSKYMODEL_H
#define OBITGPUSKYMODEL_H
#include "Obit.h"
#include "ObitErr.h"
#include "ObitUV.h"
#include "ObitCUDASkyModel.h"
/*-------- Obit: Merx mollis mortibus nuper ------------------*/
/**
* \file ObitGPUSkyModel.h
*
* ObitGPUSkyModel GPU enhanced base sky model class
* Uses functions in ObitCUDASkyModel
*
* Sky models are calculated using a GPU.
*
* \section ObitGPUSkyModelaccess Creators and Destructors
* An ObitGPUSkyModel will usually be created using ObitGPUSkyModelCreate which allows
* specifying a name for the object as well as other information.
*
* A copy of a pointer to an ObitGPUSkyModel should always be made using the
* #ObitGPUSkyModelRef function which updates the reference count in the object.
* Then whenever freeing an ObitGPUSkyModel or changing a pointer, the function
* #ObitGPUSkyModelUnref will decrement the reference count and destroy the object
* when the reference count hits 0.
* There is no explicit destructor.
*/
/*--------------Class definitions-------------------------------------*/
/** ObitGPUSkyModel Class structure. */
typedef struct {
#include "ObitGPUSkyModelDef.h" /* this class definition */
} ObitGPUSkyModel;
/*----------------- Macroes ---------------------------*/
/**
* Macro to unreference (and possibly destroy) an ObitGPUSkyModel
* returns a ObitGPUSkyModel*.
* in = object to unreference
*/
#define ObitGPUSkyModelUnref(in) ObitUnref (in)
/**
* Macro to reference (update reference count) an ObitGPUSkyModel.
* returns a ObitGPUSkyModel*.
* in = object to reference
*/
#define ObitGPUSkyModelRef(in) ObitRef (in)
/**
* Macro to determine if an object is the member of this or a
* derived class.
* Returns TRUE if a member, else FALSE
* in = object to reference
*/
#define ObitGPUSkyModelIsA(in) ObitIsA (in, ObitGPUSkyModelGetClass())
/*---------------------------------- Structures ----------------------------*/
/*---------------Public functions---------------------------*/
/** Public: Class initializer. */
void ObitGPUSkyModelClassInit (void);
/** Public: Default Constructor. */
ObitGPUSkyModel* newObitGPUSkyModel (gchar* name);
/** Public: Create/initialize ObitGPUSkyModel structures */
ObitGPUSkyModel* ObitGPUSkyModelCreate (gchar* name, gchar *type);
/** Typedef for definition of class pointer structure */
typedef ObitGPUSkyModel* (*ObitGPUSkyModelCreateFP) (gchar* name, gchar *type);
/** Public: ClassInfo pointer */
gconstpointer ObitGPUSkyModelGetClass (void);
/** Public: Copy (deep) constructor. */
ObitGPUSkyModel* ObitGPUSkyModelCopy (ObitGPUSkyModel *in, ObitGPUSkyModel *out, ObitErr *err);
/** Public: Copy structure. */
void ObitGPUSkyModelClone (ObitGPUSkyModel *in, ObitGPUSkyModel *out, ObitErr *err);
/* Public: Initialize DFT Model */
void ObitGPUSkyModelDFTInit (ObitGPUSkyModel *in, Obit *skyModel,
ObitUV *uvdata, ObitErr *err);
typedef void (*ObitGPUSkyModelDFTInitFP) (ObitGPUSkyModel *in, Obit *skyModel,
ObitUV *uvdata, ObitErr *err);
/* Public: Set DFT sky model Model */
void ObitGPUSkyModelDFTSetMod (ObitGPUSkyModel *in, Obit *skyModel,
ObitFArray *model, ObitErr *err);
typedef void (*ObitGPUSkyModelDFTSetModFP) (ObitGPUSkyModel *in, Obit *skyModel,
ObitFArray *model, ObitErr *err);
/* Public: Calculate DFT Model */
void ObitGPUSkyModelDFTCalc (ObitGPUSkyModel *in, ObitUV *uvdata, ObitErr *err);
typedef void (*ObitGPUSkyModelDFTCalcFP) (ObitGPUSkyModel *in, ObitUV *uvdata, ObitErr *err);
/* Public: Shutdown DFT Model */
void ObitGPUSkyModelDFTShutdown (ObitGPUSkyModel *in, ObitUV *uvdata, ObitErr *err);
typedef void (*ObitGPUSkyModelDFTShutdownFP) (ObitGPUSkyModel *in, ObitUV *uvdata, ObitErr *err);
/*----------- ClassInfo Structure -----------------------------------*/
/**
* ClassInfo Structure.
* Contains class name, a pointer to any parent class
* (NULL if none) and function pointers.
*/
typedef struct {
#include "ObitGPUSkyModelClassDef.h"
} ObitGPUSkyModelClassInfo;
#endif /* OBITFGPUSKYMODEL_H */
|
/* Monkey HTTP Daemon
* ------------------
* Copyright (C) 2012, Sonny Karlsson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA.
*/
#include <string.h> /* memcpy */
#include "dbg.h"
#include "protocol.h"
const char *fcgi_msg_type_str[] = {
[0] = "NULL MSG TYPE",
[FCGI_BEGIN_REQUEST] = "FCGI_BEGIN_REQUEST",
[FCGI_ABORT_REQUEST] = "FCGI_ABORT_REQUEST",
[FCGI_END_REQUEST] = "FCGI_END_REQUEST",
[FCGI_PARAMS] = "FCGI_PARAMS",
[FCGI_STDIN] = "FCGI_STDIN",
[FCGI_STDOUT] = "FCGI_STDOUT",
[FCGI_STDERR] = "FCGI_STDERR",
[FCGI_DATA] = "FCGI_DATA",
[FCGI_GET_VALUES] = "FCGI_GET_VALUES",
[FCGI_GET_VALUES_RESULT] = "FCGI_GET_VALUES_RESULT",
[FCGI_UNKNOWN_TYPE] = "FCGI_UNKNOWN_TYPE",
};
const char *fcgi_role_str[] = {
[0] = "NULL ROLE",
[FCGI_RESPONDER] = "FCGI_RESPONDER",
[FCGI_AUTHORIZER] = "FCGI_AUTHORIZER",
[FCGI_FILTER] = "FCGI_FILTER",
};
const char *fcgi_protocol_status_str[] = {
[FCGI_REQUEST_COMPLETE] = "FCGI_REQUEST_COMPLETE",
[FCGI_CANT_MPX_CONN] = "FCGI_CANT_MPX_CONN",
[FCGI_OVERLOADED] = "FCGI_OVERLOADED",
[FCGI_UNKNOWN_ROLE] = "FCGI_UNKNOWN_ROLE",
};
int fcgi_validate_struct_sizes(void)
{
struct fcgi_header header;
struct fcgi_begin_req_body begin_body;
struct fcgi_end_req_body end_body;
check(FCGI_HEADER_LEN == sizeof(header),
"sizeof(header) does not match FCGI_HEADER_LEN.");
check(FCGI_BEGIN_BODY_LEN == sizeof(begin_body),
"sizeof(begin_body) does not match FCGI_BEGIN_BODY_LEN.");
check(FCGI_END_BODY_LEN == sizeof(end_body),
"sizeof(end_body) does not match FCGI_END_BODY_LEN.");
return 0;
error:
return -1;
}
size_t fcgi_read_header(uint8_t *p, struct fcgi_header *h)
{
h->version = p[0];
h->type = p[1];
h->req_id = (p[2] << 8) + p[3];
h->body_len = (p[4] << 8) + p[5];
h->body_pad = p[6];
return sizeof(*h);
}
size_t fcgi_write_header(uint8_t *p, const struct fcgi_header *h)
{
p[0] = h->version;
p[1] = h->type;
p[2] = (h->req_id >> 8) & 0xff;
p[3] = (h->req_id) & 0xff;
p[4] = (h->body_len >> 8) & 0xff;
p[5] = (h->body_len) & 0xff;
p[6] = h->body_pad;
return sizeof(*h);
}
size_t fcgi_read_end_req_body(uint8_t *p, struct fcgi_end_req_body *b)
{
b->app_status = (p[0] << 24) + (p[1] << 16);
b->app_status += (p[2] << 8) + p[3];
b->protocol_status = p[4];
return sizeof(*b);
}
size_t fcgi_write_begin_req_body(uint8_t *p, const struct fcgi_begin_req_body *b)
{
p[0] = (b->role >> 8) & 0xff;
p[1] = (b->role) & 0xff;
p[2] = b->flags;
return sizeof(*b);
}
static uint32_t fcgi_param_read_length(uint8_t *p)
{
size_t len;
if (p[0] >> 7 == 1) {
len = (p[0] & 0x7f) << 24;
len += (p[1]) << 16;
len += (p[2]) << 8;
len += (p[3]);
} else {
len = p[0];
}
return len;
}
static size_t write_length(uint8_t *p, size_t len)
{
if (len > 127) {
p[0] = 1 << 7;
p[0] += (len >> 24) & 0x7f;
p[1] = (len >> 16) & 0xff;
p[2] = (len >> 8) & 0xff;
p[3] = (len) & 0xff;
return 4;
} else {
p[0] = len & 0x7f;
return 1;
}
}
size_t fcgi_param_write(uint8_t *p,
mk_pointer key,
mk_pointer value)
{
size_t ret, cnt;
if (!p) {
cnt = (key.len > 127 ? 4 : 1) + (value.len > 127 ? 4 : 1);
cnt += key.len + value.len;
return cnt;
}
cnt = 0;
ret = write_length(p + cnt, key.len);
cnt += ret;
ret = write_length(p + cnt, value.len);
cnt += ret;
memcpy(p + cnt, key.data, key.len);
cnt += key.len;
memcpy(p + cnt, value.data, value.len);
cnt += value.len;
return cnt;
}
int fcgi_param_entry_next(struct fcgi_param_entry *e)
{
e->position += e->key_len + e->value_len;
check_debug(e->position < e->base_len, "At end of buffer.");
e->key_len = fcgi_param_read_length(e->base + e->position);
e->position += e->key_len > 127 ? 4 : 1;
e->value_len = fcgi_param_read_length(e->base + e->position);
e->position += e->value_len > 127 ? 4 : 1;
return 0;
error:
return -1;
}
void fcgi_param_entry_init(struct fcgi_param_entry *e,
uint8_t *p,
size_t p_len)
{
e->key_len = 0;
e->value_len = 0;
e->position = 0;
e->base_len = p_len;
e->base = p;
fcgi_param_entry_next(e);
}
void fcgi_param_entry_reset(struct fcgi_param_entry *e)
{
e->key_len = 0;
e->value_len = 0;
e->position = 0;
fcgi_param_entry_next(e);
}
int fcgi_param_entry_search(struct fcgi_param_entry *e, mk_pointer key)
{
mk_pointer e_key;
do {
e_key = fcgi_param_entry_key(e);
if (e_key.len == key.len && !bcmp(e_key.data, key.data, key.len)) {
return 0;
}
} while (fcgi_param_entry_next(e) != -1);
return -1;
}
mk_pointer fcgi_param_entry_key(struct fcgi_param_entry *e)
{
return (mk_pointer){
.data = (char *)e->base + e->position,
.len = e->key_len,
};
}
mk_pointer fcgi_param_entry_value(struct fcgi_param_entry *e)
{
return (mk_pointer){
.data = (char *)e->base + e->position + e->key_len,
.len = e->value_len,
};
}
|
struct Bullet {
double x,y;
double vx,vy;
int shooter;
};
|
/*
* The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 The Mana Developers
* Copyright (C) 2011-2013 The ManaPlus Developers
*
* This file is part of The ManaPlus Client.
*
* 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
* 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 NET_EATHENA_GAMEHANDLER_H
#define NET_EATHENA_GAMEHANDLER_H
#include "net/eathena/messagehandler.h"
#include "net/ea/gamehandler.h"
namespace EAthena
{
class GameHandler final : public MessageHandler, public Ea::GameHandler
{
public:
GameHandler();
A_DELETE_COPY(GameHandler)
void handleMessage(Net::MessageIn &msg) override final;
void connect() override final;
bool isConnected() const override final A_WARN_UNUSED;
void disconnect() override final;
void quit() const override final;
void ping(const int tick) const override final;
void disconnect2() const override final;
void mapLoadedEvent() const override final;
void processMapCharId(Net::MessageIn &msg) const;
bool mustPing() const override final A_WARN_UNUSED
{ return true; }
};
} // namespace EAthena
#endif // NET_EATHENA_GAMEHANDLER_H
|
/********************************************************************************
* Tangram Library - version 8.0 *
*********************************************************************************
* Copyright (C) 2002-2015 by Tangram Team. All Rights Reserved. *
*
* THIS SOURCE FILE IS THE PROPERTY OF TANGRAM TEAM AND IS NOT TO
* BE RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED
* WRITTEN CONSENT OF TANGRAM TEAM.
*
* THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS
* OUTLINED IN THE GPL LICENSE AGREEMENT.TANGRAM TEAM
* GRANTS TO YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE
* THIS SOFTWARE ON A SINGLE COMPUTER.
*
* CONTACT INFORMATION:
* mailto:sunhui@tangramfx.com
* http://www.tangramFX.com
*
*
********************************************************************************/
#pragma once
#include "../Markup.h"
namespace TangramEclipsePlus
{
namespace EclipsePlus
{
class CTangramCtrl;
class CTangramEclipseWnd;
class CTangramEclipseAddin : public CTangramCore,
public map<HWND, CTangramEclipseWnd*>
{
public:
CTangramEclipseAddin();
virtual ~CTangramEclipseAddin();
int m_nIndex;
long m_nCommandID;
CString m_strURL;
CTangramEclipseWnd* m_pNewWnd;
private:
bool bLoadConfig(CMarkup* pXml);
bool bFindNode(CMarkup* pXml, LPCTSTR lpName);
bool _bFindNode(CMarkup* pXml, LPCTSTR lpName);
};
class CTangramEclipseWnd :
public map<HWND, CTangramCtrl*>,
public CComObjectRootEx<CComSingleThreadModel>,
public CWindowImpl<CTangramEclipseWnd, CWindow>,
public IDispatchImpl<ITangramEclipseTopWnd, &IID_ITangramEclipseTopWnd, &LIBID_Tangram, /*wMajor =*/ 1, /*wMinor =*/ 0>
{
public:
CTangramEclipseWnd(void);
~CTangramEclipseWnd(void);
int m_nIndex;
BOOL m_bCreated;
CString m_strURL;
ITangram* m_pTangram;
ITangramFrame* m_pFrame;
ITangramNode* m_pCurNode;
BEGIN_COM_MAP(CTangramEclipseWnd)
COM_INTERFACE_ENTRY(ITangramEclipseTopWnd)
COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()
BEGIN_MSG_MAP(CTangramEclipseWnd)
MESSAGE_HANDLER(WM_COMMAND, OnCommand)
MESSAGE_HANDLER(WM_TANGRAMDATA, OnGetData)
MESSAGE_HANDLER(WM_ECLIPSEMAINWNDCREATED, OnChildWndCreate)
END_MSG_MAP()
virtual void OnFinalMessage(HWND hWnd);
protected:
HWND m_hClient;
HWND m_hBottom;
HWND m_hTopBottom;
ULONG InternalAddRef() { return 1; }
ULONG InternalRelease() { return 1; }
LRESULT OnCommand(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnGetData(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnChildWndCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
public:
STDMETHOD(get_Handle)(LONGLONG* pVal);
STDMETHOD(SWTExtend)(BSTR bstrKey, BSTR bstrXml, ITangramNode** ppNode);
STDMETHOD(GetCtrlText)(BSTR bstrNodeName, BSTR bstrCtrlName, BSTR* bstrVal);
};
class CTangramEclipseSWTWnd :
public CWindowImpl<CTangramEclipseSWTWnd, CWindow>
{
public:
CTangramEclipseSWTWnd(void);
~CTangramEclipseSWTWnd(void);
CTangramCtrl* m_pHostCtrl;
BEGIN_MSG_MAP(CTangramEclipseWnd)
MESSAGE_HANDLER(WM_SWTCOMPONENTNOTIFY, OnSWTComponentNotify)
END_MSG_MAP()
virtual void OnFinalMessage(HWND hWnd);
LRESULT OnSWTComponentNotify(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
};
}
}
|
/*
*** Undo Event - Model DrawStyle
*** src/undo/model_drawstyle.h
Copyright T. Youngs 2007-2018
This file is part of Aten.
Aten 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.
Aten 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 Aten. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ATEN_UNDOEVENT_MODELSTYLE_H
#define ATEN_UNDOEVENT_MODELSTYLE_H
#include "undo/undoevent.h"
#include "base/prefs.h"
ATEN_BEGIN_NAMESPACE
// Forward Declarations (Aten)
class Model;
// Model DrawStyle Event
class ModelDrawStyleEvent : public UndoEvent
{
public:
// Constructor / Destructor
ModelDrawStyleEvent();
~ModelDrawStyleEvent();
private:
// Change data
Prefs::DrawStyle oldStyle_, newStyle_;
public:
// Set change data
void set(Prefs::DrawStyle oldStyle, Prefs::DrawStyle newStyle);
// Undo stored change
void undo(Model* m);
// Print change information
void print();
};
ATEN_END_NAMESPACE
#endif
|
#include <stdio.h>
#include <sys/socket.h>
#include <linux/in.h>
#include <sys/ioctl.h>
#include <linux/types.h>
#include <linux/if_packet.h>
#include <sys/ioctl.h>
#include <linux/if_ether.h>
#include <stdlib.h>
#include <string.h>
#include <linux/mapi/ioctl.h>
#include <tconfig.h>
#include <subflow.h>
#include <mapihandy.h>
void error(char *msg,int sock)
{
perror(msg);
exit(1);
}
extern int sock;
extern struct subflow_ioctl_struct sis;
extern struct flow_raw_struct frs;
__u64 total_subflows = 0;
__u64 total_packets = 0;
__u64 total_bytes = 0;
int expire_all = 0;
void sigint_handler()
{
if(expire_all == 0)
{
if(ioctl(sock,SIOCEXPIREALL,&sis))
{
error("ioctl",sock);
}
expire_all = 1;
printf("All subflows expired successfully\n");
printf("Press CTRL-C to exit\n");
return;
}
if(print_packet_statistics(sock))
{
perror("print_packet_statistics");
}
if(print_mapi_statistics(sock))
{
perror("print_mapi_statistics");
}
printf("Stats : Total subflows = %llu\n",total_subflows);
printf("Stats : Total packets = %llu\n",total_packets);
printf("Stats : Total bytes = %llu\n",total_bytes);
exit(0);
}
|
/****************************************************************************
** $Id: qiodevice.h,v 1.2 2003-07-10 02:40:11 llornkcor Exp $
**
** Definition of QIODevice class
**
** Created : 940913
**
** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
**
** This file is part of the tools module of the Qt GUI Toolkit.
**
** This file may be distributed under the terms of the Q Public License
** as defined by Trolltech AS of Norway and appearing in the file
** LICENSE.QPL included in the packaging of this file.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
** licenses may use this file in accordance with the Qt Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
** information about Qt Commercial License Agreements.
** See http://www.trolltech.com/qpl/ for QPL licensing information.
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef QIODEVICE_H
#define QIODEVICE_H
#ifndef QT_H
#include "qglobal.h"
#include "qcstring.h"
#endif // QT_H
// IO device access types
#define IO_Direct 0x0100 // direct access device
#define IO_Sequential 0x0200 // sequential access device
#define IO_Combined 0x0300 // combined direct/sequential
#define IO_TypeMask 0x0f00
// IO handling modes
#define IO_Raw 0x0040 // raw access (not buffered)
#define IO_Async 0x0080 // asynchronous mode
// IO device open modes
#define IO_ReadOnly 0x0001 // readable device
#define IO_WriteOnly 0x0002 // writable device
#define IO_ReadWrite 0x0003 // read+write device
#define IO_Append 0x0004 // append
#define IO_Truncate 0x0008 // truncate device
#define IO_Translate 0x0010 // translate CR+LF
#define IO_ModeMask 0x00ff
// IO device state
#define IO_Open 0x1000 // device is open
#define IO_StateMask 0xf000
// IO device status
#define IO_Ok 0
#define IO_ReadError 1 // read error
#define IO_WriteError 2 // write error
#define IO_FatalError 3 // fatal unrecoverable error
#define IO_ResourceError 4 // resource limitation
#define IO_OpenError 5 // cannot open device
#define IO_ConnectError 5 // cannot connect to device
#define IO_AbortError 6 // abort error
#define IO_TimeOutError 7 // time out
#define IO_UnspecifiedError 8 // unspecified error
class Q_EXPORT QIODevice
{
public:
#if defined(QT_ABI_64BITOFFSET)
typedef QtOffset Offset;
#else
typedef Q_ULONG Offset;
#endif
QIODevice();
virtual ~QIODevice();
int flags() const { return ioMode; }
int mode() const { return ioMode & IO_ModeMask; }
int state() const { return ioMode & IO_StateMask; }
bool isDirectAccess() const { return ((ioMode & IO_Direct) == IO_Direct); }
bool isSequentialAccess() const { return ((ioMode & IO_Sequential) == IO_Sequential); }
bool isCombinedAccess() const { return ((ioMode & IO_Combined) == IO_Combined); }
bool isBuffered() const { return ((ioMode & IO_Raw) != IO_Raw); }
bool isRaw() const { return ((ioMode & IO_Raw) == IO_Raw); }
bool isSynchronous() const { return ((ioMode & IO_Async) != IO_Async); }
bool isAsynchronous() const { return ((ioMode & IO_Async) == IO_Async); }
bool isTranslated() const { return ((ioMode & IO_Translate) == IO_Translate); }
bool isReadable() const { return ((ioMode & IO_ReadOnly) == IO_ReadOnly); }
bool isWritable() const { return ((ioMode & IO_WriteOnly) == IO_WriteOnly); }
bool isReadWrite() const { return ((ioMode & IO_ReadWrite) == IO_ReadWrite); }
bool isInactive() const { return state() == 0; }
bool isOpen() const { return state() == IO_Open; }
int status() const { return ioSt; }
void resetStatus() { ioSt = IO_Ok; }
virtual bool open( int mode ) = 0;
virtual void close() = 0;
virtual void flush() = 0;
virtual Offset size() const = 0;
virtual Offset at() const;
virtual bool at( Offset );
virtual bool atEnd() const;
bool reset() { return at(0); }
virtual Q_LONG readBlock( char *data, Q_ULONG maxlen ) = 0;
virtual Q_LONG writeBlock( const char *data, Q_ULONG len ) = 0;
virtual Q_LONG readLine( char *data, Q_ULONG maxlen );
Q_LONG writeBlock( const QByteArray& data );
virtual QByteArray readAll();
virtual int getch() = 0;
virtual int putch( int ) = 0;
virtual int ungetch( int ) = 0;
protected:
void setFlags( int f ) { ioMode = f; }
void setType( int );
void setMode( int );
void setState( int );
void setStatus( int );
Offset ioIndex;
private:
int ioMode;
int ioSt;
private: // Disabled copy constructor and operator=
#if defined(Q_DISABLE_COPY)
QIODevice( const QIODevice & );
QIODevice &operator=( const QIODevice & );
#endif
};
#endif // QIODEVICE_H
|
/*! \file socket.h
* Osmocom socket convenience functions. */
#pragma once
#if (!EMBEDDED)
/*! \defgroup socket Socket convenience functions
* @{
* \file socket.h */
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <arpa/inet.h>
/*! maximum length of a socket name ("r=1.2.3.4:123<->l=5.6.7.8:987") */
#define OSMO_SOCK_NAME_MAXLEN (2 + INET6_ADDRSTRLEN + 1 + 5 + 3 + 2 + INET6_ADDRSTRLEN + 1 + 5 + 1)
struct sockaddr_in;
struct sockaddr;
struct osmo_fd;
struct osmo_sockaddr {
union {
struct sockaddr sa;
struct sockaddr_storage sas;
struct sockaddr_in sin;
struct sockaddr_in6 sin6;
} u;
};
/* flags for osmo_sock_init. */
/*! connect the socket to a remote peer */
#define OSMO_SOCK_F_CONNECT (1 << 0)
/*! bind the socket to a local address/port */
#define OSMO_SOCK_F_BIND (1 << 1)
/*! switch socket to non-blocking mode */
#define OSMO_SOCK_F_NONBLOCK (1 << 2)
/*! disable multiast loop (IP_MULTICAST_LOOP) */
#define OSMO_SOCK_F_NO_MCAST_LOOP (1 << 3)
/*! disable receiving all multiast even for non-subscribed groups */
#define OSMO_SOCK_F_NO_MCAST_ALL (1 << 4)
/*! use SO_REUSEADDR on UDP ports (required for multicast) */
#define OSMO_SOCK_F_UDP_REUSEADDR (1 << 5)
/*! use OSMO_SOCK_F_DSCP(x) to set IP DSCP 'x' for packets transmitted on the socket */
#define OSMO_SOCK_F_DSCP(x) (((x)&0x3f) << 24)
#define GET_OSMO_SOCK_F_DSCP(f) (((f) >> 24) & 0x3f)
/*! use OSMO_SOCK_F_PRIO(x) to set priority 'x' for packets transmitted on the socket */
#define OSMO_SOCK_F_PRIO(x) (((x)&0xff) << 16)
#define GET_OSMO_SOCK_F_PRIO(f) (((f) >> 16) & 0xff)
/*! maximum number of local or remote addresses supported by an osmo_sock instance */
#define OSMO_SOCK_MAX_ADDRS 32
int osmo_sock_init(uint16_t family, uint16_t type, uint8_t proto,
const char *host, uint16_t port, unsigned int flags);
int osmo_sock_init2(uint16_t family, uint16_t type, uint8_t proto,
const char *local_host, uint16_t local_port,
const char *remote_host, uint16_t remote_port, unsigned int flags);
int osmo_sock_init2_multiaddr(uint16_t family, uint16_t type, uint8_t proto,
const char **local_hosts, size_t local_hosts_cnt, uint16_t local_port,
const char **remote_hosts, size_t remote_hosts_cnt, uint16_t remote_port, unsigned int flags);
int osmo_sock_init_osa(uint16_t type, uint8_t proto,
const struct osmo_sockaddr *local,
const struct osmo_sockaddr *remote,
unsigned int flags);
int osmo_sock_init_ofd(struct osmo_fd *ofd, int family, int type, int proto,
const char *host, uint16_t port, unsigned int flags);
int osmo_sock_init2_ofd(struct osmo_fd *ofd, int family, int type, int proto,
const char *local_host, uint16_t local_port,
const char *remote_host, uint16_t remote_port, unsigned int flags);
int osmo_sock_init_osa_ofd(struct osmo_fd *ofd, int type, int proto,
const struct osmo_sockaddr *local,
const struct osmo_sockaddr *remote,
unsigned int flags);
int osmo_sock_init_sa(struct sockaddr *ss, uint16_t type,
uint8_t proto, unsigned int flags);
int osmo_sockaddr_is_local(struct sockaddr *addr, unsigned int addrlen);
unsigned int osmo_sockaddr_to_str_and_uint(char *addr, unsigned int addr_len, uint16_t *port,
const struct sockaddr *sa);
size_t osmo_sockaddr_in_to_str_and_uint(char *addr, unsigned int addr_len, uint16_t *port,
const struct sockaddr_in *sin);
const char *osmo_sockaddr_ntop(const struct sockaddr *sa, char *dst);
uint16_t osmo_sockaddr_port(const struct sockaddr *sa);
void osmo_sockaddr_set_port(struct sockaddr *sa, uint16_t port);
int osmo_sock_unix_init(uint16_t type, uint8_t proto,
const char *socket_path, unsigned int flags);
int osmo_sock_unix_init_ofd(struct osmo_fd *ofd, uint16_t type, uint8_t proto,
const char *socket_path, unsigned int flags);
char *osmo_sock_get_name(const void *ctx, int fd);
const char *osmo_sock_get_name2(int fd);
char *osmo_sock_get_name2_c(const void *ctx, int fd);
int osmo_sock_get_name_buf(char *str, size_t str_len, int fd);
int osmo_sock_get_ip_and_port(int fd, char *ip, size_t ip_len, char *port, size_t port_len, bool local);
int osmo_sock_get_local_ip(int fd, char *host, size_t len);
int osmo_sock_get_local_ip_port(int fd, char *port, size_t len);
int osmo_sock_get_remote_ip(int fd, char *host, size_t len);
int osmo_sock_get_remote_ip_port(int fd, char *port, size_t len);
int osmo_sock_mcast_loop_set(int fd, bool enable);
int osmo_sock_mcast_ttl_set(int fd, uint8_t ttl);
int osmo_sock_mcast_all_set(int fd, bool enable);
int osmo_sock_mcast_iface_set(int fd, const char *ifname);
int osmo_sock_mcast_subscribe(int fd, const char *grp_addr);
int osmo_sock_local_ip(char *local_ip, const char *remote_ip);
int osmo_sockaddr_local_ip(struct osmo_sockaddr *local_ip,
const struct osmo_sockaddr *remote_ip);
int osmo_sockaddr_cmp(const struct osmo_sockaddr *a,
const struct osmo_sockaddr *b);
int osmo_sockaddr_to_octets(uint8_t *dst, size_t dst_maxlen, const struct osmo_sockaddr *os);
int osmo_sockaddr_from_octets(struct osmo_sockaddr *os, const void *src, size_t src_len);
const char *osmo_sockaddr_to_str(const struct osmo_sockaddr *sockaddr);
char *osmo_sockaddr_to_str_buf(char *buf, size_t buf_len,
const struct osmo_sockaddr *sockaddr);
int osmo_sockaddr_to_str_buf2(char *buf, size_t buf_len, const struct osmo_sockaddr *sockaddr);
char *osmo_sockaddr_to_str_c(void *ctx, const struct osmo_sockaddr *sockaddr);
int osmo_sock_set_dscp(int fd, uint8_t dscp);
int osmo_sock_set_priority(int fd, int prio);
#endif /* (!EMBEDDED) */
/*! @} */
|
#ifndef CP5_ex7_32_h
#define CP5_ex7_32_h
#include <vector>
#include <string>
#include <iostream>
class Screen;
class Window_mgr {
public:
using ScreenIndex = std::vector<Screen>::size_type;
inline void clear(ScreenIndex);
private:
std::vector<Screen> screens;
};
class Screen {
friend void Window_mgr::clear(ScreenIndex);
public:
using pos = std::string::size_type;
Screen() = default; // 1
Screen(pos ht, pos wd):height(ht),width(wd),contents(ht*wd, ' '){} // 2
Screen(pos ht, pos wd, char c):height(ht),width(wd),contents(ht*wd, c){} // 3
char get() const { return contents[cursor]; }
char get(pos r, pos c) const { return contents[r*width+c]; }
inline Screen& move(pos r, pos c);
inline Screen& set(char c);
inline Screen& set(pos r, pos c, char ch);
const Screen& display(std::ostream &os) const { do_display(os); return *this; }
Screen& display(std::ostream &os) { do_display(os); return *this; }
private:
void do_display(std::ostream &os) const { os << contents; }
private:
pos cursor = 0;
pos height = 0, width = 0;
std::string contents;
};
inline void Window_mgr::clear(ScreenIndex i)
{
if (i >= screens.size()) return; // judge for out_of_range.
Screen &s = screens[i];
s.contents = std::string(s.height * s.width, ' ');
}
inline Screen& Screen::move(pos r, pos c)
{
cursor = r*width + c;
return *this;
}
inline Screen& Screen::set(char c)
{
contents[cursor] = c;
return *this;
}
inline Screen& Screen::set(pos r, pos c, char ch)
{
contents[r*width+c] = ch;
return *this;
}
#endif
|
/*
* Generic parts
* Linux ethernet bridge
*
* Authors:
* Lennert Buytenhek <buytenh@gnu.org>
*
* $Id: br.c,v 1.47 2001/12/24 00:56:41 davem Exp $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/miscdevice.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/init.h>
#include <linux/if_bridge.h>
#include <asm/uaccess.h>
#include "br_private.h"
#if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
#include "../atm/lec.h"
#endif
int (*br_should_route_hook) (struct sk_buff **pskb) = NULL;
static int __init br_init(void)
{
#ifdef CONFIG_BRIDGE_NETFILTER
if (br_netfilter_init())
return 1;
#endif
brioctl_set(br_ioctl_deviceless_stub);
br_handle_frame_hook = br_handle_frame;
#if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
br_fdb_get_hook = br_fdb_get;
br_fdb_put_hook = br_fdb_put;
#endif
register_netdevice_notifier(&br_device_notifier);
return 0;
}
static void __exit br_deinit(void)
{
#ifdef CONFIG_BRIDGE_NETFILTER
br_netfilter_fini();
#endif
unregister_netdevice_notifier(&br_device_notifier);
brioctl_set(NULL);
br_handle_frame_hook = NULL;
#if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
br_fdb_get_hook = NULL;
br_fdb_put_hook = NULL;
#endif
br_cleanup_bridges();
synchronize_net();
}
EXPORT_SYMBOL(br_should_route_hook);
module_init(br_init)
module_exit(br_deinit)
MODULE_LICENSE("GPL");
|
/******************************************************************************
DISCLAIMER
THIS SOFTWARE PRODUCT ("SOFTWARE") IS PROPRIETARY TO ENOCEAN GMBH, OBERHACHING,
GERMANY (THE "OWNER") AND IS PROTECTED BY COPYRIGHT AND INTERNATIONAL TREATIES OR
PROTECTED AS TRADE SECRET OR AS OTHER INTELLECTUAL PROPERTY RIGHT. ALL RIGHTS, TITLE AND
INTEREST IN AND TO THE SOFTWARE, INCLUDING ANY COPYRIGHT, TRADE SECRET OR ANY OTHER
INTELLECTUAL PROPERTY EMBODIED IN THE SOFTWARE, AND ANY RIGHTS TO REPRODUCE,
DISTRIBUTE, MODIFY, DISPLAY OR OTHERWISE USE THE SOFTWARE SHALL EXCLUSIVELY VEST IN THE
OWNER. ANY UNAUTHORIZED REPRODUCTION, DISTRIBUTION, MODIFICATION, DISPLAY OR OTHER
USE OF THE SOFTWARE WITHOUT THE EXPLICIT PERMISSION OF OWNER IS PROHIBITED AND WILL
CONSTITUTE AN INFRINGEMENT OF THE OWNER'S RIGHT AND MAY BE SUBJECT TO CIVIL OR
CRIMINAL SANCTION.
THIS SOFTWARE IS PROVIDED BY THE OWNER "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 PARTICULAR, THE OWNER DOES NOT WARRANT
THAT THE SOFTWARE SHALL BE ERROR FREE AND WORKS WITHOUT INTERRUPTION.
IN NO EVENT SHALL THE OWNER 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.
******************************************************************************/
/**
* \file eoManufacturer.h
* \brief Manufacturer list
* \author EnOcean GmbH
*/
#ifndef __EOMANUFACTURER_H
#define __EOMANUFACTURER_H
#include "eoHalTypes.h"
/**\ingroup eoManufacturer
* @{
*/
//! Manufacturer ID List
typedef enum
{
MANUFACTURER_RESERVED = 0x000,
PEHA = 0x001,
THERMOKON = 0x002,
SERVODAN = 0x003,
ECHOFLEX_SOLUTIONS = 0x004,
OMNIO_AG = 0x005,
HARDMEIER_ELECTRONICS = 0x006,
REGULVAR_INC = 0x007,
AD_HOC_ELECTRONICS = 0x008,
DISTECH_CONTROLS = 0x009,
KIEBACK_AND_PETER = 0x00A,
ENOCEAN_GMBH = 0x00B,
PROBARE = 0x00C,
ELTAKO = 0x00D,
LEVITON = 0x00E,
HONEYWELL = 0x00F,
SPARTAN_PERIPHERAL_DEVICES = 0x010,
SIEMENS = 0x011,
T_MAC = 0x012,
RELIABLE_CONTROLS_CORPORATION = 0x013,
ELSNER_ELEKTRONIK_GMBH = 0x014,
DIEHL_CONTROLS = 0x015,
BSC_COMPUTER = 0x016,
S_AND_S_REGELTECHNIK_GMBH = 0x017,
MASCO_CORPORATION = 0x018,
INTESIS_SOFTWARE_SL = 0x019,
VIESSMANN = 0x01A,
LUTUO_TECHNOLOGY = 0x01B,
CAN2GO = 0x01C,
SAUTER = 0x01D,
BOOT_UP = 0x01E,
OSRAM_SYLVANIA = 0x01F,
UNOTECH = 0x020,
UNITRONIC_AG = 0x022,
NANOSENSE = 0x023,
THE_S4_GROUP = 0x024,
MSR_SOLUTIONS = 0x025,
MAICO = 0x027,
KM_CONTROLS = 0x02A,
ECOLOGIX_CONTROLS = 0x02B,
AFRISO_EURO_INDEX = 0x02D,
NEC_ACCESSTECHNICA_LTD = 0x030,
ITEC_CORPORATION = 0x031,
MULTI_USER_MANUFACTURER = 0x7FF,
} MANUFACTURER_LIST;
#define MAX_NAME_LENGTH 32
/**
* \class eoManufacturer
* \brief Manufacturer List
* \details The eoManufacturer class provides functionality to convert manufacturer ID to name.
*/
class eoManufacturer
{
private:
const static char list[][MAX_NAME_LENGTH];
const static char listDefault[2][MAX_NAME_LENGTH];
public:
virtual ~eoManufacturer();
/**
* Returns the name of manufacturer as zero terminated string
* @return Manufacturer name
*/
static const char* GetName(const uint16_t manufacturerID);
};
/**
* @}
*/
#endif // __EOMANUFACTURER_H
|
/*
* m_gact.c generic actions module
*
* This program is free software; you can distribute 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.
*
* Authors: J Hadi Salim (hadi@cyberus.ca)
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include "utils.h"
#include "tc_util.h"
#include <linux/tc_act/tc_gact.h>
/* define to turn on probablity stuff */
#ifdef CONFIG_GACT_PROB
static const char *prob_n2a(int p)
{
if (p == PGACT_NONE)
return "none";
if (p == PGACT_NETRAND)
return "netrand";
if (p == PGACT_DETERM)
return "determ";
return "none";
}
#endif
static void
explain(void)
{
#ifdef CONFIG_GACT_PROB
fprintf(stderr, "Usage: ... gact <ACTION> [RAND] [INDEX]\n");
fprintf(stderr,
"Where: \tACTION := reclassify | drop | continue | pass | pipe |\n"
" \t goto chain <CHAIN_INDEX> | jump <JUMP_COUNT>\n"
"\tRAND := random <RANDTYPE> <ACTION> <VAL>\n"
"\tRANDTYPE := netrand | determ\n"
"\tVAL : = value not exceeding 10000\n"
"\tJUMP_COUNT := Absolute jump from start of action list\n"
"\tINDEX := index value used\n"
"\n");
#else
fprintf(stderr, "Usage: ... gact <ACTION> [INDEX]\n");
fprintf(stderr,
"Where: \tACTION := reclassify | drop | continue | pass | pipe |\n"
" \t goto chain <CHAIN_INDEX> | jump <JUMP_COUNT>\n"
"\tINDEX := index value used\n"
"\tJUMP_COUNT := Absolute jump from start of action list\n"
"\n");
#endif
}
static void
usage(void)
{
explain();
exit(-1);
}
static int
parse_gact(struct action_util *a, int *argc_p, char ***argv_p,
int tca_id, struct nlmsghdr *n)
{
int argc = *argc_p;
char **argv = *argv_p;
struct tc_gact p = { 0 };
#ifdef CONFIG_GACT_PROB
int rd = 0;
struct tc_gact_p pp;
#endif
struct rtattr *tail;
if (argc < 0)
return -1;
if (matches(*argv, "gact") == 0) {
argc--;
argv++;
} else if (parse_action_control(&argc, &argv, &p.action, false) == -1) {
usage(); /* does not return */
}
#ifdef CONFIG_GACT_PROB
if (argc > 0) {
if (matches(*argv, "random") == 0) {
rd = 1;
NEXT_ARG();
if (matches(*argv, "netrand") == 0) {
NEXT_ARG();
pp.ptype = PGACT_NETRAND;
} else if (matches(*argv, "determ") == 0) {
NEXT_ARG();
pp.ptype = PGACT_DETERM;
} else {
fprintf(stderr, "Illegal \"random type\"\n");
return -1;
}
if (parse_action_control(&argc, &argv,
&pp.paction, false) == -1)
usage();
if (get_u16(&pp.pval, *argv, 10)) {
fprintf(stderr,
"Illegal probability val 0x%x\n",
pp.pval);
return -1;
}
if (pp.pval > 10000) {
fprintf(stderr,
"Illegal probability val 0x%x\n",
pp.pval);
return -1;
}
argc--;
argv++;
} else if (matches(*argv, "help") == 0) {
usage();
}
}
#endif
if (argc > 0) {
if (matches(*argv, "index") == 0) {
NEXT_ARG();
if (get_u32(&p.index, *argv, 10)) {
fprintf(stderr, "Illegal \"index\"\n");
return -1;
}
argc--;
argv++;
} else if (matches(*argv, "help") == 0) {
usage();
}
}
tail = NLMSG_TAIL(n);
addattr_l(n, MAX_MSG, tca_id, NULL, 0);
addattr_l(n, MAX_MSG, TCA_GACT_PARMS, &p, sizeof(p));
#ifdef CONFIG_GACT_PROB
if (rd)
addattr_l(n, MAX_MSG, TCA_GACT_PROB, &pp, sizeof(pp));
#endif
tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
*argc_p = argc;
*argv_p = argv;
return 0;
}
static int
print_gact(struct action_util *au, FILE *f, struct rtattr *arg)
{
#ifdef CONFIG_GACT_PROB
struct tc_gact_p *pp = NULL;
struct tc_gact_p pp_dummy;
#endif
struct tc_gact *p = NULL;
struct rtattr *tb[TCA_GACT_MAX + 1];
if (arg == NULL)
return -1;
parse_rtattr_nested(tb, TCA_GACT_MAX, arg);
if (tb[TCA_GACT_PARMS] == NULL) {
print_string(PRINT_FP, NULL, "%s", "[NULL gact parameters]");
return -1;
}
p = RTA_DATA(tb[TCA_GACT_PARMS]);
print_string(PRINT_ANY, "kind", "%s ", "gact");
print_action_control(f, "action ", p->action, "");
#ifdef CONFIG_GACT_PROB
if (tb[TCA_GACT_PROB] != NULL) {
pp = RTA_DATA(tb[TCA_GACT_PROB]);
} else {
/* need to keep consistent output */
memset(&pp_dummy, 0, sizeof(pp_dummy));
pp = &pp_dummy;
}
open_json_object("prob");
print_string(PRINT_ANY, "random_type", "\n\t random type %s",
prob_n2a(pp->ptype));
print_action_control(f, " ", pp->paction, " ");
print_int(PRINT_ANY, "val", "val %d", pp->pval);
close_json_object();
#endif
print_uint(PRINT_ANY, "index", "\n\t index %u", p->index);
print_int(PRINT_ANY, "ref", " ref %d", p->refcnt);
print_int(PRINT_ANY, "bind", " bind %d", p->bindcnt);
if (show_stats) {
if (tb[TCA_GACT_TM]) {
struct tcf_t *tm = RTA_DATA(tb[TCA_GACT_TM]);
print_tm(f, tm);
}
}
print_string(PRINT_FP, NULL, "%s", "\n");
return 0;
}
struct action_util gact_action_util = {
.id = "gact",
.parse_aopt = parse_gact,
.print_aopt = print_gact,
};
|
/**
* This file contains constant values for controlling the robot
*/
/* Note: In ANSI-C (not C++), shared constants must be declared
* static to indicate that they will be resolved
* at link time. Otherwise the compiler beleives the constant has
* been re-declared in every file it is included into
*/
static const int MAX_SPEED = 127;
static const int MAX_REVERSE_SPEED = 127;
static const int MAX_FORWARD_VELOCITY = 127;
static const int MAX_REVERSE_VELOCITY = -127;
static const int FORWARD_VELOCITY = 127;
static const int REVERSE_VELOCITY = -100;
static const int INERTIA_CANCELLATION_FACTOR = 7;
//Motors, duh
//motors
typedef enum MOTORS {
MOTOR_DRIVE_RIGHT_BACK = 1, // = rightLine back
MOTOR_DRIVE_RIGHT_FRONT = 2, // = rightLine front
MOTOR_ARM_RIGHT_BOTTOM = 3, // = rightLine arm down
MOTOR_ARM_RIGHT_TOP = 4, // = rightLine arm up
MOTOR_INTAKE_RIGHT = 5, // = rightLine intake
MOTOR_INTAKE_LEFT = 6, // = leftLine intake
MOTOR_ARM_LEFT_TOP = 7, // = leftLine arm up
MOTOR_ARM_LEFT_BOTTOM = 8, // = leftLine arm down
MOTOR_DRIVE_LEFT_FRONT = 9, // = leftLine front
MOTOR_DRIVE_LEFT_BACK = 10, // = leftLine back
MOTOR_ARM_LEFT_BACK = 11,
MOTOR_ARM_LEFT_FRONT = 12
} MOTOR;
|
/*
Armator - simulateur de jeu d'instruction ARMv5T à but pédagogique
Copyright (C) 2011 Guillaume Huard
Ce programme est libre, vous pouvez le redistribuer et/ou le modifier selon les
termes de la Licence Publique Générale GNU publiée par la Free Software
Foundation (version 2 ou bien toute autre version ultérieure choisie par vous).
Ce programme est distribué car potentiellement utile, mais SANS AUCUNE
GARANTIE, ni explicite ni implicite, y compris les garanties de
commercialisation ou d'adaptation dans un but spécifique. Reportez-vous à la
Licence Publique Générale GNU pour plus de détails.
Vous devez avoir reçu une copie de la Licence Publique Générale GNU en même
temps que ce programme ; si ce n'est pas le cas, écrivez à la Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
États-Unis.
Contact: Guillaume.Huard@imag.fr
ENSIMAG - Laboratoire LIG
51 avenue Jean Kuntzmann
38330 Montbonnot Saint-Martin
*/
#include <stdlib.h>
#include "memory.h"
#include "util.h"
struct memory_data {
uint8_t *address;
size_t size;
};
memory memory_create(size_t size) {
memory mem;
mem = malloc(sizeof(struct memory_data));
if (mem) {
mem->address = malloc(size);
if (!mem->address) {
free(mem);
mem = NULL;
}
}
if (mem) {
mem->size = size;
}
return mem;
}
size_t memory_get_size(memory mem) {
return mem->size;
}
void memory_destroy(memory mem) {
free(mem->address);
free(mem);
}
int memory_read_byte(memory mem, uint32_t address, uint8_t *value) {
if (address > mem->size)
return -1;
uint8_t * ad;
ad = mem->address + address;
*value = *ad;
return 0;
}
int memory_read_half(memory mem, int be, uint32_t address, uint16_t *value) {
if (address+1 > mem->size)
return -1;
uint8_t * ad;
uint16_t val = 0;
int i;
ad = mem->address + address;
if (be == 0) {
for (i=0;i<=1;i++) {
val = val | *(ad+i) << (i*8);
}
} else {
for (i=1;i>=0;i--) {
val = val | *(ad+i) << ((1-i)*8);
}
}
*value = val;
return 0;
}
int memory_read_word(memory mem, int be, uint32_t address, uint32_t *value) {
if (address+3 > mem->size)
return -1;
uint8_t * ad;
uint32_t val = 0;
int i;
ad = mem->address + address;
if (be == 0) {
for (i=0;i<=3;i++) {
val = val | *(ad+i) << (i*8);
}
} else {
for (i=3;i>=0;i--) {
val = val | *(ad+i) << ((3-i)*8);
}
}
*value = val;
return 0;
}
int memory_write_byte(memory mem, uint32_t address, uint8_t value) {
if (address > mem->size)
return -1;
uint8_t * ad;
ad = mem->address + address;
*ad = value;
return 0;
}
int memory_write_half(memory mem, int be, uint32_t address, uint16_t value) {
if (address+1 > mem->size)
return -1;
uint8_t * ad;
int i;
ad = mem->address + address;
if (be == 0) {
for (i=0;i<=1;i++) {
*(ad+i) = (value & 255 << (i*8)) >> (i*8);
}
} else {
for (i=1;i>=0;i--) {
*(ad+i) = (value & 255 << ((1-i)*8)) >> ((1-i)*8);
}
}
return 0;
}
int memory_write_word(memory mem, int be, uint32_t address, uint32_t value) {
if (address+3 > mem->size)
return -1;
uint8_t * ad;
int i;
ad = mem->address + address;
if (be == 0) {
for (i=0;i<=3;i++) {
*(ad+i) = (value & 255 << (i*8)) >> (i*8);
}
} else {
for (i=3;i>=0;i--) {
*(ad+i) = (value & 255 << ((3-i)*8)) >> ((3-i)*8);
}
}
return 0;
}
|
/********************************************************
* Header file for eata_pio.c Linux EATA-PIO SCSI driver *
* (c) 1993-96 Michael Neuffer *
*********************************************************
* last change: 2002/11/02 *
********************************************************/
#ifndef _EATA_PIO_H
#define _EATA_PIO_H
#define VER_MAJOR 0
#define VER_MINOR 0
#define VER_SUB "1b"
/************************************************************************
* Here you can switch parts of the code on and of *
************************************************************************/
#define VERBOSE_SETUP /* show startup screen of 2001 */
#define ALLOW_DMA_BOARDS 1
/************************************************************************
* Debug options. *
* Enable DEBUG and whichever options you require. *
************************************************************************/
#define DEBUG_EATA 1 /* Enable debug code. */
#define DPT_DEBUG 0 /* Bobs special */
#define DBG_DELAY 0 /* Build in delays so debug messages can be
* be read before they vanish of the top of
* the screen!
*/
#define DBG_PROBE 0 /* Debug probe routines. */
#define DBG_ISA 0 /* Trace ISA routines */
#define DBG_EISA 0 /* Trace EISA routines */
#define DBG_PCI 0 /* Trace PCI routines */
#define DBG_PIO 0 /* Trace get_config_PIO */
#define DBG_COM 0 /* Trace command call */
#define DBG_QUEUE 0 /* Trace command queueing. */
#define DBG_INTR 0 /* Trace interrupt service routine. */
#define DBG_INTR2 0 /* Trace interrupt service routine. */
#define DBG_PROC 0 /* Debug proc-fs related statistics */
#define DBG_PROC_WRITE 0
#define DBG_REGISTER 0 /* */
#define DBG_ABNORM 1 /* Debug abnormal actions (reset, abort) */
#if DEBUG_EATA
#define DBG(x, y) if ((x)) {y;}
#else
#define DBG(x, y)
#endif
#endif /* _EATA_PIO_H */
|
#ifndef A01_MAG_FIELD_H
#define A01_MAG_FIELD_H
//------------------------------------------------
// The Virtual Monte Carlo examples
// Copyright (C) 2007 - 2014 Ivana Hrivnacova
// All rights reserved.
//
// For the licensing terms see geant4_vmc/LICENSE.
// Contact: root-vmc@cern.ch
//-------------------------------------------------
/// \file A01MagField.h
/// \brief Definition of the A01MagField class
///
/// Geant4 ExampleA01 adapted to Virtual Monte Carlo
///
/// \date 12/05/2012
/// \author I. Hrivnacova; IPN, Orsay
#include <TVirtualMagField.h>
/// \ingroup A01
/// \brief Definition of a uniform magnetic field within a given region
///
/// \date
/// \author I. Hrivnacova; IPN, Orsay
class A01MagField : public TVirtualMagField
{
public:
A01MagField(Double_t Bx, Double_t By, Double_t Bz);
A01MagField();
virtual ~A01MagField();
virtual void Field(const Double_t* /*x*/, Double_t* B);
private:
A01MagField(const A01MagField&);
A01MagField& operator=(const A01MagField&);
Double_t fB[3]; ///< Magnetic field vector
ClassDef(A01MagField, 1) // Uniform magnetic field
};
#endif //A01_MAG_FIELD_H
|
//-----------------------------------------------------------------------------
// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
//
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
// at your option, any later version. See the LICENSE.txt file for the text of
// the license.
//-----------------------------------------------------------------------------
// utilities
//-----------------------------------------------------------------------------
#include <stdio.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include "data.h"
#ifndef MIN
# define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef MAX
# define MAX(a, b) (((a) > (b)) ? (a) : (b))
#endif
#define TRUE 1
#define FALSE 0
#define EVEN 0
#define ODD 1
int ukbhit(void);
void AddLogLine(char *fileName, char *extData, char *c);
void AddLogHex(char *fileName, char *extData, const uint8_t * data, const size_t len);
void AddLogUint64(char *fileName, char *extData, const uint64_t data);
void AddLogCurrentDT(char *fileName);
void FillFileNameByUID(char *fileName, uint8_t * uid, char *ext, int byteCount);
void print_hex(const uint8_t * data, const size_t len);
char * sprint_hex(const uint8_t * data, const size_t len);
char * sprint_bin(const uint8_t * data, const size_t len);
char * sprint_bin_break(const uint8_t *data, const size_t len, const uint8_t breaks);
void num_to_bytes(uint64_t n, size_t len, uint8_t* dest);
uint64_t bytes_to_num(uint8_t* src, size_t len);
char * printBits(size_t const size, void const * const ptr);
uint8_t *SwapEndian64(const uint8_t *src, const size_t len, const uint8_t blockSize);
char param_getchar(const char *line, int paramnum);
int param_getptr(const char *line, int *bg, int *en, int paramnum);
uint8_t param_get8(const char *line, int paramnum);
uint8_t param_get8ex(const char *line, int paramnum, int deflt, int base);
uint32_t param_get32ex(const char *line, int paramnum, int deflt, int base);
uint64_t param_get64ex(const char *line, int paramnum, int deflt, int base);
uint8_t param_getdec(const char *line, int paramnum, uint8_t *destination);
uint8_t param_isdec(const char *line, int paramnum);
int param_gethex(const char *line, int paramnum, uint8_t * data, int hexcnt);
int param_gethex_ex(const char *line, int paramnum, uint8_t * data, int *hexcnt);
int param_getstr(const char *line, int paramnum, char * str);
int hextobinarray( char *target, char *source);
int hextobinstring( char *target, char *source);
int binarraytohex( char *target, char *source, int length);
void binarraytobinstring(char *target, char *source, int length);
uint8_t GetParity( char *string, uint8_t type, int length);
void wiegand_add_parity(char *target, char *source, char length);
void xor(unsigned char *dst, unsigned char *src, size_t len);
int32_t le24toh(uint8_t data[3]);
|
/*
* Copyright 2014 Freescale Semiconductor, 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 2 of the License, or
* (at your option) any later version.
*/
#ifndef __DT_BINDINGS_CLOCK_LS1021A_H
#define __DT_BINDINGS_CLOCK_LS1021A_H
#define LS1021A_CLK_DUMMY 0
#define LS1021A_CLK_PBL_EN 1
#define LS1021A_CLK_ESDHC_EN 2
#define LS1021A_CLK_DMA1_EN 3
#define LS1021A_CLK_DMA2_EN 4
#define LS1021A_CLK_USB3_PHY_EN 5
#define LS1021A_CLK_USB2_EN 6
#define LS1021A_CLK_SATA_EN 7
#define LS1021A_CLK_USB3_EN 8
#define LS1021A_CLK_SEC_EN 9
#define LS1021A_CLK_2D_ACE_EN 10
#define LS1021A_CLK_QE_EN 11
#define LS1021A_CLK_ETSEC1_EN 12
#define LS1021A_CLK_ETSEC2_EN 13
#define LS1021A_CLK_ETSEC3_EN 14
#define LS1021A_CLK_PEX1_EN 15
#define LS1021A_CLK_PEX2_EN 16
#define LS1021A_CLK_DUART1_EN 17
#define LS1021A_CLK_DUART2_EN 18
#define LS1021A_CLK_QSPI_EN 19
#define LS1021A_CLK_DDR_EN 20
#define LS1021A_CLK_OCRAM1_EN 21
#define LS1021A_CLK_IFC_EN 22
#define LS1021A_CLK_GPIO_EN 23
#define LS1021A_CLK_DBG_EN 24
#define LS1021A_CLK_FLEXCAN1_EN 25
#define LS1021A_CLK_FLEXCAN234_EN 26
#define LS1021A_CLK_FLEXTIMER_EN 27
#define LS1021A_CLK_SECMON_EN 28
#define LS1021A_CLK_WDOG_EN 29
#define LS1021A_CLK_WDOG12_EN 30
#define LS1021A_CLK_I2C23_EN 31
#define LS1021A_CLK_SAI_EN 32
#define LS1021A_CLK_LPUART_EN 33
#define LS1021A_CLK_DSPI12_EN 34
#define LS1021A_CLK_ASRC_EN 35
#define LS1021A_CLK_SPDIF_EN 36
#define LS1021A_CLK_I2C1_EN 37
#define LS1021A_CLK_LPUART1_EN 38
#define LS1021A_CLK_FLEXTIMER1_EN 39
#define LS1021A_CLK_END 40
#endif /* __DT_BINDINGS_CLOCK_LS1021A_H */
|
/*---------------------------------------------------------------------------+
| fpu_asm.h |
| |
| Copyright (C) 1992,1995,1997 |
| W. Metzenthen, 22 Parker St, Ormond, Vic 3163, |
| Australia. E-mail billm@suburbia.net |
| |
+---------------------------------------------------------------------------*/
#ifndef _FPU_ASM_H_
#define _FPU_ASM_H_
#include <linux/linkage.h>
#include <asm/alternative-asm.h>
#define EXCEPTION FPU_exception
#define PARAM1 8(%ebp)
#define PARAM2 12(%ebp)
#define PARAM3 16(%ebp)
#define PARAM4 20(%ebp)
#define PARAM5 24(%ebp)
#define PARAM6 28(%ebp)
#define PARAM7 32(%ebp)
#define SIGL_OFFSET 0
#define EXP(x) 8(x)
#define SIG(x) SIGL_OFFSET##(x)
#define SIGL(x) SIGL_OFFSET##(x)
#define SIGH(x) 4(x)
#endif /* _FPU_ASM_H_ */
|
/* *
* $Id$
*
* This file is part of Fenice
*
* Fenice -- Open Media Server
*
* Copyright (C) 2004 by
*
* - Giampaolo Mancini <giampaolo.mancini@polito.it>
* - Francesco Varano <francesco.varano@polito.it>
* - Marco Penno <marco.penno@polito.it>
* - Federico Ridolfo <federico.ridolfo@polito.it>
* - Eugenio Menegatti <m.eu@libero.it>
* - Stefano Cau
* - Giuliano Emma
* - Stefano Oldrini
*
* Fenice 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.
*
* Fenice 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 Fenice; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* */
#ifndef _H26LH
#define _H26LH
#include <fenice/mediainfo.h>
#include <fenice/types.h>
typedef struct {
unsigned int bufsize;
long pkt_sent;
int current_timestamp;
int next_timestamp;
} static_H26L;
int load_H26L (media_entry *me);
int read_H26L (media_entry *me, uint8 *buffer, uint32 *buffer_size, double *mtime, int *recallme, uint8 *marker);
int free_H26L (void * stat);
#endif
|
/*
C-Dogs SDL
A port of the legendary (and fun) action/arcade cdogs.
Copyright (c) 2019 Cong Xu
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
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.
*/
#include "nine_slice.h"
#include "log.h"
#include "texture.h"
void Draw9Slice(
GraphicsDevice *g, const Pic *pic,
const Rect2i target,
const int top, const int right, const int bottom, const int left,
const bool repeat, const color_t mask, const SDL_RendererFlip flip)
{
const int srcX[] = {0, left, pic->size.x - right};
const int srcY[] = {0, top, pic->size.y - bottom};
const int srcW[] = {left, pic->size.x - right - left, right};
const int srcH[] = {top, pic->size.y - bottom - top, bottom};
const int dstX[] = {
target.Pos.x,
target.Pos.x + left,
target.Pos.x + target.Size.x - right,
target.Pos.x + target.Size.x
};
const int dstY[] = {
target.Pos.y,
target.Pos.y + top,
target.Pos.y + target.Size.y - bottom,
target.Pos.y + target.Size.y
};
const int dstW[] = {left, target.Size.x - right - left, right};
const int dstH[] = {top, target.Size.y - bottom - top, bottom};
Rect2i src;
Rect2i dst;
for (int i = 0; i < 3; i++)
{
src.Pos.x = srcX[i];
src.Size.x = srcW[i];
dst.Size.x = repeat ? srcW[i] : dstW[i];
for (dst.Pos.x = dstX[i];
dst.Pos.x < dstX[i + 1];
dst.Pos.x += dst.Size.x)
{
if (dst.Pos.x + dst.Size.x > dstX[i + 1])
{
src.Size.x = dst.Size.x = dstX[i + 1] - dst.Pos.x;
}
for (int j = 0; j < 3; j++)
{
src.Pos.y = srcY[j];
src.Size.y = srcH[j];
dst.Size.y = repeat ? srcH[j] : dstH[j];
for (dst.Pos.y = dstY[j];
dst.Pos.y < dstY[j + 1];
dst.Pos.y += dst.Size.y)
{
if (dst.Pos.y + dst.Size.y > dstY[j + 1])
{
src.Size.y = dst.Size.y = dstY[j + 1] - dst.Pos.y;
}
TextureRender(
pic->Tex, g->gameWindow.renderer, src, dst, mask, 0,
flip);
}
}
}
}
}
|
/*
* arch-tag: Header for generic audio player source object
*
* Copyright (C) 2005 James Livingston <doclivingston@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.
*
* The Rhythmbox authors hereby grant permission for non-GPL compatible
* GStreamer plugins to be used and distributed together with GStreamer
* and Rhythmbox. This permission is above and beyond the permissions granted
* by the GPL license by which Rhythmbox is covered. If you modify this code
* you may extend this exception to your version of the code, but you are not
* obligated to do so. If you do not wish to do so, delete this exception
* statement from your 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 St, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef __RB_GENERIC_PLAYER_SOURCE_H
#define __RB_GENERIC_PLAYER_SOURCE_H
#include "rb-shell.h"
#include "rb-removable-media-source.h"
#include "rhythmdb.h"
#include <totem-pl-parser.h>
G_BEGIN_DECLS
#define RB_TYPE_GENERIC_PLAYER_SOURCE (rb_generic_player_source_get_type ())
#define RB_GENERIC_PLAYER_SOURCE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), RB_TYPE_GENERIC_PLAYER_SOURCE, RBGenericPlayerSource))
#define RB_GENERIC_PLAYER_SOURCE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), RB_TYPE_GENERIC_PLAYER_SOURCE, RBGenericPlayerSourceClass))
#define RB_IS_GENERIC_PLAYER_SOURCE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), RB_TYPE_GENERIC_PLAYER_SOURCE))
#define RB_IS_GENERIC_PLAYER_SOURCE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), RB_TYPE_GENERIC_PLAYER_SOURCE))
#define RB_GENERIC_PLAYER_SOURCE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), RB_TYPE_GENERIC_PLAYER_SOURCE, RBGenericPlayerSourceClass))
typedef struct
{
RBRemovableMediaSource parent;
} RBGenericPlayerSource;
typedef struct
{
RBRemovableMediaSourceClass parent;
char * (*impl_get_mount_path) (RBGenericPlayerSource *source);
void (*impl_load_playlists) (RBGenericPlayerSource *source);
char ** (*impl_get_audio_folders) (RBGenericPlayerSource *source);
char * (*impl_uri_from_playlist_uri) (RBGenericPlayerSource *source, const char *uri);
char * (*impl_uri_to_playlist_uri) (RBGenericPlayerSource *source, const char *uri);
/* used for track transfer - returns the filename relative to the audio folder on the device */
char * (*impl_build_filename) (RBGenericPlayerSource *source, RhythmDBEntry *entry);
} RBGenericPlayerSourceClass;
RBRemovableMediaSource *rb_generic_player_source_new (RBShell *shell, GMount *mount);
GType rb_generic_player_source_get_type (void);
GType rb_generic_player_source_register_type (GTypeModule *module);
char * rb_generic_player_source_get_mount_path (RBGenericPlayerSource *source);
char * rb_generic_player_source_uri_from_playlist_uri (RBGenericPlayerSource *source,
const char *uri);
char * rb_generic_player_source_uri_to_playlist_uri (RBGenericPlayerSource *source,
const char *uri);
void rb_generic_player_source_set_supported_formats (RBGenericPlayerSource *source,
TotemPlParser *parser);
TotemPlParserType rb_generic_player_source_get_playlist_format (RBGenericPlayerSource *source);
char * rb_generic_player_source_get_playlist_path (RBGenericPlayerSource *source);
gboolean rb_generic_player_is_mount_player (GMount *mount);
/* for subclasses */
void rb_generic_player_source_add_playlist (RBGenericPlayerSource *source,
RBShell *shell,
RBSource *playlist);
G_END_DECLS
#endif /* __RB_GENERIC_PLAYER_SOURCE_H */
|
/*
* Author - Mike Blandford
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
// type of basic load
#define BASIC_LOAD_NONE 0
#define BASIC_LOAD_ALONE 1
#define BASIC_LOAD_TEL0 2
#define BASIC_LOAD_TEL1 3
#define BASIC_LOAD_BG 4
// States
#define BASIC_IDLE 0
#define BASIC_LOAD_START 1
#define BASIC_LOADING 2
#define BASIC_RUNNING 3
struct t_loadedScripts
{
// struct t_basicRunTime *runtime ;
uint32_t offsetOfStart ;
uint16_t size ;
uint8_t loaded ;
uint8_t type ;
} ;
uint32_t basicExecute( uint32_t begin, uint16_t event, uint32_t index ) ;
int32_t expression( void ) ;
uint32_t loadBasic( char *fileName, uint32_t type ) ;
uint32_t basicTask( uint8_t event, uint8_t flags ) ;
void basicLoadModelScripts( void ) ;
extern uint8_t BasicErrorText[] ;
extern uint8_t BasicLoadedType ;
#ifndef QT
extern FIL MultiBasicFile ;
#endif
|
/**************************************************************************
ALGLIB 3.10.0 (source code generated 2015-08-19)
Copyright (c) Sergey Bochkanov (ALGLIB project).
>>> SOURCE LICENSE >>>
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 (www.fsf.org); 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.
A copy of the GNU General Public License is available at
http://www.fsf.org/licensing/licenses
>>> END OF LICENSE >>>
**************************************************************************/
#include "stdafx.h"
#include "hermite.h"
/*$ Declarations $*/
/*$ Body $*/
/*************************************************************************
Calculation of the value of the Hermite polynomial.
Parameters:
n - degree, n>=0
x - argument
Result:
the value of the Hermite polynomial Hn at x
*************************************************************************/
double hermitecalculate(ae_int_t n, double x, ae_state *_state)
{
ae_int_t i;
double a;
double b;
double result;
result = (double)(0);
/*
* Prepare A and B
*/
a = (double)(1);
b = 2*x;
/*
* Special cases: N=0 or N=1
*/
if( n==0 )
{
result = a;
return result;
}
if( n==1 )
{
result = b;
return result;
}
/*
* General case: N>=2
*/
for(i=2; i<=n; i++)
{
result = 2*x*b-2*(i-1)*a;
a = b;
b = result;
}
return result;
}
/*************************************************************************
Summation of Hermite polynomials using Clenshaws recurrence formula.
This routine calculates
c[0]*H0(x) + c[1]*H1(x) + ... + c[N]*HN(x)
Parameters:
n - degree, n>=0
x - argument
Result:
the value of the Hermite polynomial at x
*************************************************************************/
double hermitesum(/* Real */ ae_vector* c,
ae_int_t n,
double x,
ae_state *_state)
{
double b1;
double b2;
ae_int_t i;
double result;
b1 = (double)(0);
b2 = (double)(0);
result = (double)(0);
for(i=n; i>=0; i--)
{
result = 2*(x*b1-(i+1)*b2)+c->ptr.p_double[i];
b2 = b1;
b1 = result;
}
return result;
}
/*************************************************************************
Representation of Hn as C[0] + C[1]*X + ... + C[N]*X^N
Input parameters:
N - polynomial degree, n>=0
Output parameters:
C - coefficients
*************************************************************************/
void hermitecoefficients(ae_int_t n,
/* Real */ ae_vector* c,
ae_state *_state)
{
ae_int_t i;
ae_vector_clear(c);
ae_vector_set_length(c, n+1, _state);
for(i=0; i<=n; i++)
{
c->ptr.p_double[i] = (double)(0);
}
c->ptr.p_double[n] = ae_exp(n*ae_log((double)(2), _state), _state);
for(i=0; i<=n/2-1; i++)
{
c->ptr.p_double[n-2*(i+1)] = -c->ptr.p_double[n-2*i]*(n-2*i)*(n-2*i-1)/4/(i+1);
}
}
/*$ End $*/
|
/*
Copyright (C) 1996-1997 Id Software, 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 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.
*/
// cvar.c -- dynamic variable tracking
#include "quakedef.h"
cvar_t *cvar_vars;
char *cvar_null_string = "";
/*
============
Cvar_FindVar
============
*/
cvar_t *Cvar_FindVar (char *var_name)
{
cvar_t *var;
for (var=cvar_vars ; var ; var=var->next)
if (!Q_strcmp (var_name, var->name))
return var;
return NULL;
}
/*
============
Cvar_VariableValue
============
*/
float Cvar_VariableValue (char *var_name)
{
cvar_t *var;
var = Cvar_FindVar (var_name);
if (!var)
return 0;
return Q_atof (var->string);
}
/*
============
Cvar_VariableString
============
*/
char *Cvar_VariableString (char *var_name)
{
cvar_t *var;
var = Cvar_FindVar (var_name);
if (!var)
return cvar_null_string;
return var->string;
}
/*
============
Cvar_CompleteVariable
============
*/
char *Cvar_CompleteVariable (char *partial)
{
cvar_t *cvar;
int len;
len = Q_strlen(partial);
if (!len)
return NULL;
// check functions
for (cvar=cvar_vars ; cvar ; cvar=cvar->next)
if (!Q_strncmp (partial,cvar->name, len))
return cvar->name;
return NULL;
}
/*
============
Cvar_Set
============
*/
void Cvar_Set (char *var_name, char *value)
{
cvar_t *var;
qboolean changed;
var = Cvar_FindVar (var_name);
if (!var)
{ // there is an error in C code if this happens
// Con_Printf ("Cvar_Set: variable %s not found\n", var_name); // Cataboligne - TEST FIX
return;
}
changed = Q_strcmp(var->string, value);
Z_Free (var->string); // free the old value string
var->string = Z_Malloc (Q_strlen(value)+1);
Q_strcpy (var->string, value);
var->value = Q_atof (var->string);
if (var->server && changed)
{
if (sv.active)
SV_BroadcastPrintf ("\"%s\" changed to \"%s\"\n", var->name, var->string);
}
}
/*
============
Cvar_SetValue
============
*/
void Cvar_SetValue (char *var_name, float value)
{
char val[32];
sprintf (val, "%f",value);
Cvar_Set (var_name, val);
}
/*
============
Cvar_RegisterVariable
Adds a freestanding variable to the variable list.
============
*/
void Cvar_RegisterVariable (cvar_t *variable)
{
char *oldstr;
// first check to see if it has allready been defined
if (Cvar_FindVar (variable->name))
{
Con_Printf ("Can't register variable %s, allready defined\n", variable->name);
return;
}
// check for overlap with a command
if (Cmd_Exists (variable->name))
{
Con_Printf ("Cvar_RegisterVariable: %s is a command\n", variable->name);
return;
}
// copy the value off, because future sets will Z_Free it
oldstr = variable->string;
variable->string = Z_Malloc (Q_strlen(variable->string)+1);
Q_strcpy (variable->string, oldstr);
variable->value = Q_atof (variable->string);
// link the variable in
variable->next = cvar_vars;
cvar_vars = variable;
}
/*
============
Cvar_UnRegisterVariable
Deletes a freestanding variable from the variable list.
============
*/
void Cvar_UnRegisterVariable( cvar_t * variable ) {
cvar_t * var;
if( !Cvar_FindVar( variable->name ) ) {
Con_Printf( "Can't unregister variable %s, it does not exist\n", variable->name);
return;
}
if( cvar_vars == variable ) {
cvar_vars = variable->next;
return;
}
for( var = cvar_vars; (var) && (var->next != variable); var = var->next ) {}
if( !var ) {
Con_Printf( "variable not found..\n" );
return;
}
// unlink it.
var->next = var->next->next;
}
/*
============
Cvar_Command
Handles variable inspection and changing from the console
============
*/
qboolean Cvar_Command (void)
{
cvar_t *v;
// check variables
v = Cvar_FindVar (Cmd_Argv(0));
if (!v)
return false;
// perform a variable print or set
if (Cmd_Argc() == 1)
{
Con_Printf ("\"%s\" is \"%s\"\n", v->name, v->string);
return true;
}
Cvar_Set (v->name, Cmd_Argv(1));
return true;
}
/*
============
Cvar_WriteVariables
Writes lines containing "set variable value" for all variables
with the archive flag set to true.
============
*/
void Cvar_WriteVariables (FILE *f)
{
cvar_t *var;
for (var = cvar_vars ; var ; var = var->next)
if (var->archive)
fprintf (f, "%s \"%s\"\n", var->name, var->string);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.