text stringlengths 4 6.14k |
|---|
#include "types.h"
#include "stat.h"
#include "user.h"
char buf[512];
void
cat(int fd)
{
int n;
while ((n = read(fd, buf, sizeof(buf))) > 0)
write(1, buf, n);
if (n < 0)
{
printf(1, "cat: read error\n");
exit();
}
}
int
main(int argc, char *argv[])
{
int fd, i;
if (argc <= 1)
{
cat(0);
exit();
}
for (i = 1; i < argc; i++)
{
if ((fd = open(argv[i], 0)) < 0)
{
printf(1, "cat: cannot open %s\n", argv[i]);
exit();
}
cat(fd);
close(fd);
}
exit();
}
|
/**
* @file SDK_EVAL_Config.h
* @author VMA division - AMS
* @version V2.0.2
* @date Febrary 7, 2015
* @brief This file contains SDK EVAL configuration and useful defines.
* @details
*
* This file is used to include all or a part of the SDK Eval
* libraries into the application program which will be used.
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* THIS SOURCE CODE IS PROTECTED BY A LICENSE.
* FOR MORE INFORMATION PLEASE CAREFULLY READ THE LICENSE AGREEMENT FILE LOCATED
* IN THE ROOT DIRECTORY OF THIS FIRMWARE PACKAGE.
*
* <h2><center>© COPYRIGHT 2015 STMicroelectronics</center></h2>
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __SDK_EVAL_CONFIG_H
#define __SDK_EVAL_CONFIG_H
/* Includes ------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup SDK_EVAL_NUCLEO SDK-EVAL NUCLEO
* @brief This module is used to configure the SDK Eval board and
* allows to manage its peripherals in a simple way.
* @details The supported demoboard is <b><i>NUCLEO-L152RE</i></b> motherboard:
* <ul>
* <li>STM32L152RE 64-pin microcontroller</li>
* <li>Mini USB connector for power supply and I/O</li>
* <li>ST-Link, JTAG/SWD on board debugger</li>
* <li>User button and RESET button</li>
* <li>1 User LED</li>
* </ul>
* @{
*/
/** @addtogroup SDK_EVAL_Config SDK EVAL Config
* @brief SDK EVAL configuration.
* @details See the file <i>@ref SDK_EVAL_Config.h</i> for more details.
* @{
*/
/** @defgroup SDK_EVAL_Config_Exported_Constants SDK EVAL Config Exported Constants
* @{
*/
#define SDK_EVAL_SPI_PRESCALER SPI_BAUDRATEPRESCALER_4
#define SDK_EVAL_UART_BAUDRATE 115200
/**
* @}
*/
/** @defgroup SDK_EVAL_Config_Exported_Functions SDK EVAL Config Exported Functions
* @{
*/
void SdkEvalIdentification(void);
uint8_t SdkEvalGetVersion(void);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif
/******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/
|
/*
**
** The C code is generated by ATS/Anairiats
** The compilation time is: 2013-9-3: 17h: 1m
**
*/
/* include some .h files */
#ifndef _ATS_HEADER_NONE
#include "ats_config.h"
#include "ats_basics.h"
#include "ats_types.h"
#include "ats_exception.h"
#include "ats_memory.h"
#endif /* _ATS_HEADER_NONE */
/* prologues from statically loaded files */
#include "pats_location.cats"
#include "libc/CATS/gmp.cats"
#include "pats_location.cats"
#include "pats_location.cats"
#include "pats_location.cats"
#include "pats_lexbuf.cats"
#include "pats_location.cats"
#include "pats_location.cats"
#include "libc/CATS/gmp.cats"
#include "pats_location.cats"
#include "pats_location.cats"
#include "pats_location.cats"
#include "pats_lexbuf.cats"
#include "pats_location.cats"
#include "pats_location.cats"
/* external codes at top */
/* type definitions */
/* external typedefs */
/* assuming abstract types */
/* sum constructor declarations */
/* exn constructor declarations */
/* static load function */
extern ats_void_type _2home_2hwxi_2research_2Postiats_2git_2src_2pats_location_2esats__staload (void) ;
extern ats_void_type _2home_2hwxi_2research_2Postiats_2git_2src_2pats_basics_2esats__staload (void) ;
extern ats_void_type _2home_2hwxi_2research_2Postiats_2git_2src_2pats_staexp2_2esats__staload (void) ;
ats_void_type
_2home_2hwxi_2research_2Postiats_2git_2src_2pats_staexp2_solve_2esats__staload () {
static int _2home_2hwxi_2research_2Postiats_2git_2src_2pats_staexp2_solve_2esats__staload_flag = 0 ;
if (_2home_2hwxi_2research_2Postiats_2git_2src_2pats_staexp2_solve_2esats__staload_flag) return ;
_2home_2hwxi_2research_2Postiats_2git_2src_2pats_staexp2_solve_2esats__staload_flag = 1 ;
_2home_2hwxi_2research_2Postiats_2git_2src_2pats_location_2esats__staload () ;
_2home_2hwxi_2research_2Postiats_2git_2src_2pats_basics_2esats__staload () ;
_2home_2hwxi_2research_2Postiats_2git_2src_2pats_staexp2_2esats__staload () ;
return ;
} /* staload function */
/* external codes at mid */
/* external codes at bot */
/* ****** ****** */
/* end of [pats_staexp2_solve_sats.c] */
|
/*
* OpenSplice DDS
*
* This software and documentation are Copyright 2006 to 2013 PrismTech
* Limited and its licensees. All rights reserved. See file:
*
* $OSPL_HOME/LICENSE
*
* for full copyright notice and license terms.
*
*/
/****************************************************************
* Interface definition for time management of SPLICE-DDS *
****************************************************************/
#ifndef OS_TIME_H
#define OS_TIME_H
/** \file os_time.h
* \brief Time management - get time, delay and calculate with time
*/
#if defined (__cplusplus)
extern "C" {
#endif
#include "os_defs.h"
#include "os_if.h"
#ifdef OSPL_BUILD_CORE
#define OS_API OS_API_EXPORT
#else
#define OS_API OS_API_IMPORT
#endif
/* !!!!!!!!NOTE From here no more includes are allowed!!!!!!! */
/** \brief User clock handle
*/
typedef void *os_userClockHandle;
/** \brief Time structure definition
*/
typedef struct os_time {
/** Seconds since 1-jan-1970 00:00 */
os_timeSec tv_sec;
/** Count of nanoseconds within the second */
os_int32 tv_nsec;
/** os_time can be used for a duration type with the following
semantics for negative durations: tv_sec specifies the
sign of the duration, tv_nsec is always possitive and added
to the real value (thus real value is tv_sec+tv_nsec/10^9,
for example { -1, 500000000 } is -0.5 seconds) */
} os_time;
/** \brief Get the current time
*
* Possible Results:
* - returns "the current time"
*/
OS_API os_time
os_timeGet(void);
/** \brief Add time t1 to time t2
*
* Possible Results:
* - returns t1 + t2 when
* the result fits within the time structure
* - returns an unspecified value when
* the result does not fit within the time structure
*/
OS_API os_time
os_timeAdd(
os_time t1,
os_time t2);
/** \brief Subtract time t2 from time t1
*
* Possible Results:
* - returns t1 - t2 when
* the result fits within the time structure
* - returns an unspecified value when
* the result does not fit within the time structure
*/
OS_API os_time
os_timeSub(
os_time t1,
os_time t2);
/** \brief Multiply time t with a real value
*
* Possible Results:
* - returns t * multiply when
* the result fits within the time structure
* - returns an unspecified value when
* the result does not fit within the time structure
*/
OS_API os_time
os_timeMulReal(
os_time t1,
double multiply);
/** \brief Determine the absolute value of time t
*
* Possible Results:
* - returns |t| when
* the result fits within the time structure
* - returns an unspecified value when
* the result does not fit within the time structure
*/
OS_API os_time
os_timeAbs(
os_time t);
/** \brief Compare time t1 with time t2
*
* Possible Results:
* - returns OS_LESS when
* value t1 < value t2
* - returns OS_MORE when
* value t1 > value t2
* - returns OS_EQUAL when
* value t1 = value t2
*/
OS_API os_compare
os_timeCompare(
os_time t1,
os_time t2);
/** \brief Convert time t into a floating point representation of t
*
* Postcondition:
* - Due to the limited accuracy, the least significant part
* of the floating point time will be about 1 us.
*
* Possible Results:
* - returns floating point representation of t
*/
OS_API os_timeReal
os_timeToReal(
os_time t);
/** \brief Convert a floating point time representation into time
*
* Possible Results:
* - returns t in os_time representation
*/
OS_API os_time
os_realToTime(
os_timeReal t);
/** \brief Suspend the execution of the calling thread for the specified time
*
* Possible Results:
* - returns os_resultSuccess if
* the thread is suspended for the specified time
* - returns os_resultFail if
* the thread is not suspended for the specified time because of a failure
*/
OS_API os_result
os_nanoSleep(
os_time delay);
/** \brief Get high resolution time
*
* Possible Results:
* - returns "a high resolution time (not necessarily real time)"
*/
OS_API os_time
os_hrtimeGet(void);
/** \brief Translate calendar time into readable string representation
*
* Possible Results:
* - returns buf if buf != NULL
* - returns NULL if buf == NULL
*/
OS_API char *
os_ctime_r(
os_time *t,
char *buf);
/** \brief Change the clock to use a user-defined function instead of the system clock
*
*/
OS_API void
os_timeSetUserClock (
os_time (*userClock)(void));
#undef OS_API
#if defined (__cplusplus)
}
#endif
#endif /* OS_TIME_H */
|
//
// QtSLiMAbout.h
// SLiM
//
// Created by Ben Haller on 8/2/2019.
// Copyright (c) 2019-2022 Philipp Messer. All rights reserved.
// A product of the Messer Lab, http://messerlab.org/slim/
//
// This file is part of SLiM.
//
// SLiM 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.
//
// SLiM 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 SLiM. If not, see <http://www.gnu.org/licenses/>.
#ifndef QTSLIMABOUT_H
#define QTSLIMABOUT_H
#include <QDialog>
namespace Ui {
class QtSLiMAbout;
}
class QtSLiMAbout : public QDialog
{
Q_OBJECT
public:
explicit QtSLiMAbout(QWidget *p_parent = nullptr);
~QtSLiMAbout();
private:
Ui::QtSLiMAbout *ui;
};
#endif // QTSLIMABOUT_H
|
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
typedef struct node{
int len, off;
struct node *left, *right, *parent;
} node;
typedef struct info {
int off, len;
} info;
void creattree(node **tree);
void insert(node **tree, unsigned char *win, int index, int lasize, int sbsize);
info find(node **tree, unsigned char *win, int index, int size);
void delete(node **tree, unsigned char *win, int index, int max);
node* minChild(node *p);
void printtree(node *p, char *win);
|
/*
LUFA Library
Copyright (C) Dean Camera, 2010.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
/*
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether
in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of
this software.
*/
/** \file
*
* Header file for V2Protocol.c.
*/
#ifndef _V2_PROTOCOL_
#define _V2_PROTOCOL_
/* Includes: */
#include <LUFA/Drivers/USB/USB.h>
#include "../Descriptors.h"
#include "V2ProtocolConstants.h"
#include "V2ProtocolParams.h"
#include "ISP/ISPProtocol.h"
#include "XPROG/XPROGProtocol.h"
/* Preprocessor Checks: */
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
#undef ENABLE_ISP_PROTOCOL
#if !defined(ENABLE_XPROG_PROTOCOL)
#define ENABLE_XPROG_PROTOCOL
#endif
#endif
/* Macros: */
#if !defined(__DOXYGEN__)
#define _GETADCMUXMASK2(x, y) x ## y
#define _GETADCMUXMASK(x, y) _GETADCMUXMASK2(x, y)
#endif
/** Programmer ID string, returned to the host during the CMD_SIGN_ON command processing. */
#define PROGRAMMER_ID "AVRISP_MK2"
/** Timeout period for each issued command from the host before it is aborted (in 10ms ticks). */
#define COMMAND_TIMEOUT_TICKS 100
/** Command timeout counter register, GPIOR for speed. */
#define TimeoutTicksRemaining GPIOR1
/** MUX mask for the VTARGET ADC channel number. */
#define VTARGET_ADC_CHANNEL_MASK _GETADCMUXMASK(ADC_CHANNEL, VTARGET_ADC_CHANNEL)
/* External Variables: */
extern uint32_t CurrentAddress;
extern bool MustLoadExtendedAddress;
/* Function Prototypes: */
void V2Protocol_Init(void);
void V2Protocol_ProcessCommand(void);
#if defined(INCLUDE_FROM_V2PROTOCOL_C)
static void V2Protocol_UnknownCommand(const uint8_t V2Command);
static void V2Protocol_SignOn(void);
static void V2Protocol_GetSetParam(const uint8_t V2Command);
static void V2Protocol_ResetProtection(void);
static void V2Protocol_LoadAddress(void);
#endif
#endif
|
/**
******************************************************************************
* @file TIM/TIM_6Steps/Src/stm32f4xx_it.c
* @author MCD Application Team
* @version V1.1.0
* @date 17-February-2017
* @brief Main Interrupt Service Routines.
* This file provides template for all exceptions handler and
* peripherals interrupt service routine.
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "stm32f4xx_it.h"
/** @addtogroup STM32F4xx_HAL_Examples
* @{
*/
/** @addtogroup TIM_6Steps
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
extern TIM_HandleTypeDef TimHandle;
/* Authorize TIM COM event generation */
extern __IO uint32_t uwAuthorizeTimComEvent;
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/******************************************************************************/
/* Cortex-M4 Processor Exceptions Handlers */
/******************************************************************************/
/**
* @brief This function handles NMI exception.
* @param None
* @retval None
*/
void NMI_Handler(void)
{
}
/**
* @brief This function handles Hard Fault exception.
* @param None
* @retval None
*/
void HardFault_Handler(void)
{
/* Go to infinite loop when Hard Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Memory Manage exception.
* @param None
* @retval None
*/
void MemManage_Handler(void)
{
/* Go to infinite loop when Memory Manage exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Bus Fault exception.
* @param None
* @retval None
*/
void BusFault_Handler(void)
{
/* Go to infinite loop when Bus Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Usage Fault exception.
* @param None
* @retval None
*/
void UsageFault_Handler(void)
{
/* Go to infinite loop when Usage Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles SVCall exception.
* @param None
* @retval None
*/
void SVC_Handler(void)
{
}
/**
* @brief This function handles Debug Monitor exception.
* @param None
* @retval None
*/
void DebugMon_Handler(void)
{
}
/**
* @brief This function handles PendSVC exception.
* @param None
* @retval None
*/
void PendSV_Handler(void)
{
}
/**
* @brief This function handles SysTick Handler.
* @param None
* @retval None
*/
void SysTick_Handler(void)
{
HAL_IncTick();
if (uwAuthorizeTimComEvent)
{
/* Generate a commutation event each 1 ms */
HAL_TIM_GenerateEvent(&TimHandle, TIM_EVENTSOURCE_COM);
}
}
/******************************************************************************/
/* STM32F4xx Peripherals Interrupt Handlers */
/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
/* available peripheral interrupt handler's name please refer to the startup */
/* file (startup_stm32f4xx.s). */
/******************************************************************************/
/**
* @brief This function handles TIM1 Trigger and Commutation Interrupt and TIM11 Handler.
* @param None
* @retval None
*/
void TIM1_TRG_COM_TIM11_IRQHandler(void)
{
HAL_TIM_IRQHandler(&TimHandle);
}
/**
* @brief This function handles PPP interrupt request.
* @param None
* @retval None
*/
/*void PPP_IRQHandler(void)
{
}*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
/*
Copyright 2005-2009 Last.fm Ltd.
This file is part of the Last.fm Desktop Application Suite.
lastfm-desktop 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.
lastfm-desktop 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 lastfm-desktop. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef RECENT_STATIONS_WIDGET_H
#define RECENT_STATIONS_WIDGET_H
#include "lib/unicorn/StylableWidget.h"
#include <lastfm/RadioStation>
class QPushButton;
class QAbstractItemModel;
class ColumnListView;
class RecentStationsWidget : public StylableWidget
{
Q_OBJECT;
public:
RecentStationsWidget();
void setModel(QAbstractItemModel* model);
signals:
void startRadio(RadioStation);
void showMoreRecentStations();
private slots:
void onActivate(const QModelIndex&);
void recalcMoreButton();
private:
ColumnListView* m_list;
QPushButton* m_moreButton;
};
#endif
|
#include <stdio.h>
#include <stdlib.h>
/*
* Exercicio: Lista circular
* Funcao - 1: inicializarCabeca - struct no *
* Funcao - 2: imprimirComecoFim - void
* Funcao - 3: tamanhoLista - int
* Funcao - 4: buscarElemento - void
* Funcao - 5: inserirComeco - void
* Funcao - 6: inserirFim - void
* Funcao - 7: removerComeco - void
* Funcao - 8: removerFim - void
* Funcao - 9: removerElemento - void
* Funcao - 10: limpaMemoia - void
*/
// Bibliotecas da linguagem C
#include <locale.h>
// Arquivo de funcoes externo
#include "funcoes.h"
int main() {
setlocale(LC_ALL, "");
// Variaveis de controle da lista
struct no *cabeca;
int x;
// Inicializar a cabeca da lista
cabeca = inicializarCabeca();
// Variaveis de controle do menu
char opcao;
int sair = 0;
// Menu
do {
// Opcao do usuário
printf("\n*****************************\nO QUÊ VOCÊ DESEJA FAZER?\n---\n");
printf(" I - imprimir a lista do começo para o fim.\n");
//printf(" J - imprimir a lista do fim para o começo.\n");
printf(" T - ver tamanho da lista.\n");
printf(" B - buscar elemento na lista.\n");
printf(" C - inserir elemento no começo da lista.\n");
printf(" F - inserir elemento no fim da lista.\n");
//printf(" G - inserir elemento no meio da lista.\n");
printf(" P - remover elemento no começo da lista.\n");
printf(" U - remover elemento no fim da lista.\n");
printf(" R - buscar e remover um elemento da lista.\n");
printf(" S - Sair\n---\n>>> ");
// Carregar opcao
scanf("%c", &opcao);
getchar();
switch (opcao) {
case 'i':
case 'I':
imprimirComecoFim(cabeca);
break;
case 't':
case 'T':
printf("\n---\nA lista possui '%i' elementos.\n---\n", tamanhoLista(cabeca));
break;
case 'b':
case 'B':
printf("\nEncontre na lista o nro: ");
scanf("%i", &x);
getchar();
buscarElemento(cabeca, x);
break;
case 'c':
case 'C':
printf("\nInsira no começo da lista o nro: ");
scanf("%i", &x);
getchar();
inserirComeco(cabeca, x);
break;
case 'f':
case 'F':
printf("\nInsira no fim da lista o nro: ");
scanf("%i", &x);
getchar();
inserirFim(cabeca, x);
break;
case 'p':
case 'P':
removerComeco(cabeca);
break;
case 'u':
case 'U':
removerFim(cabeca);
break;
case 'r':
case 'R':
printf("\nRemova da lista o elemento: ");
scanf("%i", &x);
getchar();
removerElemento(cabeca, x);
break;
case 's':
case 'S':
sair = 1;
limpaMemoria(cabeca);
printf("\nTchau nenem!\n");
break;
default:
printf("\n*** OPÇÃO INVÁLIVA ***\n");
break;
}
} while (sair == 0);
return 0;
}
|
/* AUDEX CDDA EXTRACTOR
* Copyright (C) 2007-2015 Marco Nelles (audex@maniatek.com)
* <http://userbase.kde.org/Audex>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROFILEDATAINFODIALOG_H
#define PROFILEDATAINFODIALOG_H
#include <QWidget>
#include <KDebug>
#include <KDialog>
#include <KFileDialog>
#include <KTextBrowser>
#include "simplepatternwizarddialog.h"
#include "ui_profiledatainfowidgetUI.h"
class ProfileDataInfoDialog : public KDialog {
Q_OBJECT
public:
ProfileDataInfoDialog(const QStringList& text, const QString& pattern, const QString& suffix, QWidget *parent = 0);
~ProfileDataInfoDialog();
QStringList text;
QString pattern;
QString suffix;
protected slots:
virtual void slotButtonClicked(int button);
void pattern_wizard();
private slots:
void trigger_changed();
void about_variables();
void load_text();
void save_text();
private:
Ui::ProfileDataInfoWidgetUI ui;
bool save();
};
#endif
|
/* {{{
This file is part of DPGSolver.
DPGSolver is free software: you can redistribute it and/or modify it under the terms of the GNU
General Public License as published by the Free Software Foundation, either version 3 of the
License, or any later version.
DPGSolver 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 DPGSolver. If not, see
<http://www.gnu.org/licenses/>.
}}} */
/** \file
* \brief Undefine macro definitions for c-style templating relating to \ref DG_Solver_Volume_T containers/functions.
*/
///\{ \name Data types
#undef DG_Solver_Volume_T
///\}
///\{ \name Function names
#undef constructor_derived_DG_Solver_Volume_T
#undef destructor_derived_DG_Solver_Volume_T
///\}
#undef Needed_Members
#undef set_needed_members
|
/*********************************************************
* From C PROGRAMMING: A MODERN APPROACH, Second Edition *
* By K. N. King *
* Copyright (c) 2008, 1996 W. W. Norton & Company, Inc. *
* All rights reserved. *
* This program may be freely distributed for class use, *
* provided that this copyright notice is retained. *
*********************************************************/
/* stackADT2.h (Chapter 19, page 498) */
#ifndef STACKADT_H
#define STACKADT_H
#include <stdbool.h> /* C99 only */
typedef int Item;
typedef struct stack_type *Stack;
Stack create(int size);
void destroy(Stack s);
void make_empty(Stack s);
bool is_empty(Stack s);
bool is_full(Stack s);
void push(Stack s, Item i);
Item pop(Stack s);
#endif
|
#include "../../openexr-2.5.7/OpenEXR/IlmImf/ImfKeyCode.h"
|
#include <stdio.h>
#define ARR_LEN 7
void qsort(int v[], int left, int right);
void printArr(int v[], int len);
int main()
{
int i;
int v[ARR_LEN] = { 4, 3, 1, 7, 9, 6, 2 };
printArr(v, ARR_LEN);
qsort(v, 0, ARR_LEN-1);
printArr(v, ARR_LEN);
return 0;
}
void qsort(int v[], int left, int right)
{
int i, last;
void swap(int v[], int i, int j);
if (left >= right)
return;
swap(v, left, (left + right) / 2);
last = left;
for (i = left+1; i <= right; i++)
if (v[i] < v[left])
swap(v, ++last, i);
swap(v, left, last);
qsort(v, left, last-1);
qsort(v, last+1, right);
}
void swap(int v[], int i, int j)
{
int temp;
temp = v[i];
v[i] = v[j];
v[j] = temp;
}
void printArr(int v[], int len)
{
int i;
for (i = 0; i < len; i++)
printf("%d ", v[i]);
printf("\n");
}
|
/***************************************************************************************
*
* WRITEPAD(r): Handwriting Recognition Engine (HWRE) and components.
* Copyright (c) 2001-2016 PhatWare (r) Corp. All rights reserved.
*
* Licensing and other inquires: <developer@phatware.com>
* Developer: Stan Miasnikov, et al. (c) PhatWare Corp. <http://www.phatware.com>
*
* WRITEPAD HWRE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL PHATWARE CORP.
* BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,
* INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE, SAVINGS
* OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR NOT PHATWARE CORP.
* HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WritePad. If not, see <http://www.gnu.org/licenses/>.
*
**************************************************************************************/
#ifndef __mytypes_header_h__
#define __mytypes_header_h__
typedef unsigned int uint;
typedef unsigned long ulong;
typedef int Bool;
#define False 0
#define True 1
#define Null 0
#endif // __mytypes_header_h__
|
#include "../include/my_copy.h"
int copyFile(char source[], char dest[])
{
char temp[CP_SIZE];
/* O_RDONLY permet de seulement lire le fichier source */
int fileSource = open(source,O_RDONLY);
/* On donne le droit d'ecriture et de creation sur le fichier de destination */
int fileDest = open(dest,O_WRONLY | O_TRUNC |O_CREAT,S_IWUSR);
/* Permet de verifier que tout se passe bien */
int bienOuvert;
if(fileDest == -1 || fileSource == -1) return 0;
/* Boucle qui va copier tout le contenu du fichier source dans le fichier de destination jusqu'a ce que tout soit copie */
while(1)
{
bienOuvert = read(fileSource,temp,CP_SIZE);
if(bienOuvert != 0) write(fileDest,temp,bienOuvert);
else
{
if(errno == EAGAIN || errno == EINTR) continue;
break;
}
}
if(!changePermissions(source, dest)) return 0;
close(fileDest);
close(fileSource);
return 1;
}
int changePermissions(char source[],char dest[])
{
struct stat buffer;
stat(source, &buffer);
if(!chmod(dest, buffer.st_mode)) return 1;
else
{
printf("Warning : Probleme de changement des permissions\n");
return 0;
}
}
void concatenation(char **temp,char source[],char file[])
{
int length = 0;
int length2 = 0;
while(source[length] != '\0') length++;
while(file[length2] != '\0') length2++;
if(source[length] != '/')
{
/*On alloue de la memoire pour contenir les deux chaines et '/', ensuite on les concatene ensemble*/
*temp = calloc((length + length2 + 1),sizeof(char));
strncat(*temp,source,strlen(source));
strncat(*temp,"/",1);
}
else
{
/*Ici il y a deja le caractere '/' donc on allue juste la memoire pour contenir les deux chaines*/
*temp = calloc((length + length2),sizeof(char));
strncat(*temp,source,strlen(source));
}
strncat(*temp,file,strlen(file));
}
void cp(char source[],char dest[])
{
char *tempSource = NULL;
char *tempDestination = NULL;
struct dirent *file = NULL;
struct stat *fileType = malloc(sizeof(struct stat));
DIR *sourceFolder = NULL;
DIR *destFolder = NULL;
/* On ouvre les repertoires ou les fichiers */
sourceFolder = opendir(source);
destFolder = opendir(dest);
if(sourceFolder == NULL && destFolder == NULL)
{
printf("Warning : Impossible d'ouvrir les repertoire\n");
return;
}
/* Boucle principale assurant la copie */
while(1)
{
file = readdir(sourceFolder);
if(file == NULL) break;
else
{
if(file->d_name[0] != '.')
{
concatenation(&tempSource,source,file->d_name);
concatenation(&tempDestination,dest,file->d_name);
if(stat(tempSource,fileType) == 0)
{
/*Si on doit copier un fichier qui n'est pas un dossier*/
if(S_ISREG(fileType->st_mode))
{
changePermissions(tempSource,tempDestination);
copyFile(tempSource,tempDestination);
}
/*Si on doit copier un dossier*/
if(S_ISDIR(fileType->st_mode))
{
mkdir(tempDestination,S_IRWXU);
changePermissions(tempSource,tempDestination);
/*On appelle la fonction recursivement afin de copier chaque sous dossier*/
cp(tempSource,tempDestination);
}
}
free(tempSource);
free(tempDestination);
}
}
}
if(closedir(sourceFolder) || closedir(destFolder))
{
printf("Probleme de fermeture de dossier \n");
return;
}
}
void copy(char** args, int spaces)
{
if(spaces != 2) printf("Nombre d'arguments insuffisants. Il faut au moins 2 noms de repertoires\n");
struct stat fileType;
stat(args[1],&fileType);
if(S_ISDIR(fileType.st_mode))
{
mkdir(args[1],S_IRWXU);
changePermissions(args[1],args[2]);
/*On appelle la fonction recursivement afin de copier chaque sous dossier*/
cp(args[1],args[2]);
}
else copyFile(args[1],args[2]);
}
|
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2006 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
// AkSimd.h
/// \file
/// Simd definitions.
#ifndef _AK_SIMD_H_
#define _AK_SIMD_H_
#include <AK/SoundEngine/Common/AkTypes.h>
// Platform-specific section.
//----------------------------------------------------------------------------------------------------
#if defined( AK_WIN ) || defined( AK_XBOXONE )
#include <AK/SoundEngine/Platforms/Windows/AkSimd.h>
#elif defined( AK_APPLE )
#include <TargetConditionals.h>
#if TARGET_OS_IPHONE
#include <AK/SoundEngine/Platforms/iOS/AkSimd.h>
#else
#include <AK/SoundEngine/Platforms/Mac/AkSimd.h>
#endif
#elif defined( AK_XBOX360 )
#include <AK/SoundEngine/Platforms/XBox360/AkSimd.h>
#elif defined (AK_PS3)
#include <AK/SoundEngine/Platforms/PS3/AkSimd.h>
#elif defined( AK_WII )
#include <AK/SoundEngine/Platforms/Generic/AkSimd.h>
#elif defined( AK_VITA )
#include <AK/SoundEngine/Platforms/Vita/AkSimd.h>
#elif defined( AK_3DS )
#include <AK/SoundEngine/Platforms/3DS/AkSimd.h>
#elif defined( AK_ANDROID )
#include <AK/SoundEngine/Platforms/Android/AkSimd.h>
#elif defined( AK_NACL )
#include <AK/SoundEngine/Platforms/nacl/AkSimd.h>
#elif defined( AK_WIIU )
#include <AK/SoundEngine/Platforms/WiiFamily/AkSimd.h>
#elif defined( AK_PS4 )
#include <AK/SoundEngine/Platforms/PS4/AkSimd.h>
#elif defined( AK_LINUX )
#include <AK/SoundEngine/Platforms/Linux/AkSimd.h>
#elif defined( AK_QNX )
#include <AK/SoundEngine/Platforms/QNX/AkSimd.h>
#else
#error Unsupported platform, or platform-specific SIMD not defined
#endif
#ifndef AKSIMD_ASSERTFLUSHZEROMODE
#define AKSIMD_ASSERTFLUSHZEROMODE
#endif
#ifndef AKSIMD_DECLARE_V4F32_TYPE
#define AKSIMD_DECLARE_V4F32_TYPE AKSIMD_V4F32
#endif
#ifndef AKSIMD_DECLARE_V4I32_TYPE
#define AKSIMD_DECLARE_V4I32_TYPE AKSIMD_V4I32
#endif
#ifndef AKSIMD_DECLARE_V4F32
#define AKSIMD_DECLARE_V4F32( _x, _a, _b, _c, _d ) AKSIMD_DECLARE_V4F32_TYPE _x = { _a, _b, _c, _d }
#endif
#ifndef AKSIMD_DECLARE_V4I32
#define AKSIMD_DECLARE_V4I32( _x, _a, _b, _c, _d ) AKSIMD_DECLARE_V4I32_TYPE _x = { _a, _b, _c, _d }
#endif
#ifndef AKSIMD_SETELEMENT_V4F32
#define AKSIMD_SETELEMENT_V4F32( __vName__, __num__, __value__ ) ( AKSIMD_GETELEMENT_V4F32( __vName__, __num__ ) = (__value__) )
#endif
#endif //_AK_DATA_TYPES_H_
|
/*
* Copyright (C) 2011 Alexandre Quessy
* Copyright (C) 2011 Michal Seta
* Copyright (C) 2012 Nicolas Bouillot
* Copyright (C) 2012 Emmanuel Durand
*
* This file is part of Tempi-plugins-base.
*
* This program is free software; you can redistither version 3 of the License, or
* (at your option) any later version.
*
* Tempi 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 Tempi. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* The MetroNode class.
*/
#ifndef __TEMPI_METRONODE_H__
#define __TEMPI_METRONODE_H__
#include "tempi/timer.h"
#include "tempi/timeposition.h"
#include "tempi/node.h"
namespace tempi {
namespace plugins_base {
/**
* A MetroNode is a Node that ticks every interval ms.
*/
class MetroNode : public Node
{
public:
MetroNode();
protected:
virtual void processMessage(const char *inlet, const Message &message) {}
virtual bool onNodeAttributeChanged(const char *name, const Message &value);
private:
bool initial_tick_done_;
Timer timer_;
TimePosition interval_;
virtual void doTick();
void outputTick();
void startMetro();
};
} // end of namespace
} // end of namespace
#endif // ifndef
|
#ifndef SteppingStoneSampler_H
#define SteppingStoneSampler_H
#include "MarginalLikelihoodEstimator.h"
#include <string>
#include <vector>
namespace RevBayesCore {
/**
* @brief SteppingStone-Sampler class.
*
* The SteppingStone sampler analyzes the output of a power posterior and
* computes the SteppingStone-Sampler marginal likelihood.
*
*
* @copyright Copyright 2009-
* @author The RevBayes Development Core Team (Sebastian Hoehna)
* @since Version 1.0, 2012-06-17
*
*/
class SteppingStoneSampler : public MarginalLikelihoodEstimator {
public:
SteppingStoneSampler(const std::string &fn, const std::string &pn, const std::string &ln, const std::string &del); //!< Constructor initializing the object.
virtual ~SteppingStoneSampler(void); //!< Virtual destructor
// public methods
SteppingStoneSampler* clone(void) const; //!< Create a deep copy
double marginalLikelihood( void ) const; //!< Compute the marginal likelihood using SteppingStone-Sampler
};
}
#endif
|
/*
* Copyright 2021 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#include "pydoc_macros.h"
#define D(...) DOC(gr, satellites, __VA_ARGS__)
/*
This file contains placeholders for docstrings for the Python bindings.
Do not edit! These were automatically extracted during the binding process
and will be overwritten during the build process
*/
static const char* __doc_gr_satellites_varlen_packet_tagger = R"doc()doc";
static const char* __doc_gr_satellites_varlen_packet_tagger_varlen_packet_tagger =
R"doc()doc";
static const char* __doc_gr_satellites_varlen_packet_tagger_make = R"doc()doc";
|
/*
* Util.h
*
* Created on: Feb 26, 2015
* Author: laarman
*/
#ifndef LIPTONBIN_UTIL_UTIL_H_
#define LIPTONBIN_UTIL_UTIL_H_
#include <iostream>
#include <string>
using namespace std;
// avoid stdout
#define outs
#define cout
#ifndef NDEBUG
# define ASSERT(condition, message) \
do { \
if (! (condition)) { \
cerr << "Assertion `" #condition "` failed in " << __FILE__ \
<< " line " << __LINE__ << ": " << message << endl; \
exit(EXIT_FAILURE); \
} \
} while (false)
#else
# define ASSERT(condition, message) do { } while (false)
#endif
#define SWAP(a,b) ({ \
typeof(a) tmp = a; \
a = b; \
b = tmp; \
})
static inline bool
ends_with(string const & value, string const & ending)
{
if (ending.size() > value.size()) return false;
return equal(ending.rbegin(), ending.rend(), value.rbegin());
}
template<typename T, typename Y>
static T *select2nd(pair<Y, T> p) { return p.second; }
template<typename T, typename Y>
static T *select1st(pair<T, Y> p) { return p.first; }
#endif /* LIPTONBIN_UTIL_UTIL_H_ */
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_WIN_OBJECT_WATCHER_H_
#define BASE_WIN_OBJECT_WATCHER_H_
#pragma once
#include <windows.h>
#include "base/base_export.h"
#include "base/message_loop.h"
namespace base {
namespace win {
// A class that provides a means to asynchronously wait for a Windows object to
// become signaled. It is an abstraction around RegisterWaitForSingleObject
// that provides a notification callback, OnObjectSignaled, that runs back on
// the origin thread (i.e., the thread that called StartWatching).
//
// This class acts like a smart pointer such that when it goes out-of-scope,
// UnregisterWaitEx is automatically called, and any in-flight notification is
// suppressed.
//
// Typical usage:
//
// class MyClass : public base::ObjectWatcher::Delegate {
// public:
// void DoStuffWhenSignaled(HANDLE object) {
// watcher_.StartWatching(object, this);
// }
// virtual void OnObjectSignaled(HANDLE object) {
// // OK, time to do stuff!
// }
// private:
// base::ObjectWatcher watcher_;
// };
//
// In the above example, MyClass wants to "do stuff" when object becomes
// signaled. ObjectWatcher makes this task easy. When MyClass goes out of
// scope, the watcher_ will be destroyed, and there is no need to worry about
// OnObjectSignaled being called on a deleted MyClass pointer. Easy!
//
class BASE_EXPORT ObjectWatcher : public MessageLoop::DestructionObserver {
public:
class BASE_EXPORT Delegate {
public:
virtual ~Delegate() {}
// Called from the MessageLoop when a signaled object is detected. To
// continue watching the object, StartWatching must be called again.
virtual void OnObjectSignaled(HANDLE object) = 0;
};
ObjectWatcher();
~ObjectWatcher();
// When the object is signaled, the given delegate is notified on the thread
// where StartWatching is called. The ObjectWatcher is not responsible for
// deleting the delegate.
//
// Returns true if the watch was started. Otherwise, false is returned.
//
bool StartWatching(HANDLE object, Delegate* delegate);
// Stops watching. Does nothing if the watch has already completed. If the
// watch is still active, then it is canceled, and the associated delegate is
// not notified.
//
// Returns true if the watch was canceled. Otherwise, false is returned.
//
bool StopWatching();
// Returns the handle of the object being watched, or NULL if the object
// watcher is stopped.
HANDLE GetWatchedObject();
private:
// Called on a background thread when done waiting.
static void CALLBACK DoneWaiting(void* param, BOOLEAN timed_out);
// MessageLoop::DestructionObserver implementation:
virtual void WillDestroyCurrentMessageLoop();
// Internal state.
struct Watch;
Watch* watch_;
DISALLOW_COPY_AND_ASSIGN(ObjectWatcher);
};
} // namespace win
} // namespace base
#endif // BASE_OBJECT_WATCHER_H_
|
/*
* Copyright (C) 2015 Cybernetica
*
* Research/Commercial License Usage
* Licensees holding a valid Research License or Commercial License
* for the Software may use this file according to the written
* agreement between you and Cybernetica.
*
* GNU General Public License Usage
* Alternatively, this file may be used under the terms of the GNU
* General Public License version 3.0 as published by the Free Software
* Foundation and appearing in the file LICENSE.GPL included in the
* packaging of this file. Please review the following information to
* ensure the GNU General Public License version 3.0 requirements will be
* met: http://www.gnu.org/copyleft/gpl-3.0.html.
*
* For further information, please contact us at sharemind@cyber.ee.
*/
#ifndef SHAREMIND_MOD_ALGORITHMS_BLOCKSORTPERMUTATION_H
#define SHAREMIND_MOD_ALGORITHMS_BLOCKSORTPERMUTATION_H
#include <algorithm>
#include <array>
#include <sharemind/libsoftfloat/softfloat.h>
template<typename T, size_t N>
struct __attribute__ ((visibility("internal"))) BlockCompare {
using Block = std::array<T, N>;
int operator()(const Block& a, const Block& b, bool ascending) {
if (ascending) {
return a < b;
} else {
return a > b;
}
}
};
bool sf_float_gt(const sf_float32& a, const sf_float32& b) {
sf_fpu_state state = 0;
return sf_float32_gt(a, b, state).result;
}
bool sf_float_gt(const sf_float64& a, const sf_float64& b) {
sf_fpu_state state = 0;
return sf_float64_gt(a, b, state).result;
}
bool sf_float_lt(const sf_float32& a, const sf_float32& b) {
sf_fpu_state state = 0;
return sf_float32_lt(a, b, state).result;
}
bool sf_float_lt(const sf_float64& a, const sf_float64& b) {
sf_fpu_state state = 0;
return sf_float64_lt(a, b, state).result;
}
template<typename T, size_t N>
struct __attribute__ ((visibility("internal"))) FloatBlockCompare {
using Block = std::array<T, N>;
int operator()(const Block& a, const Block& b, bool ascending) {
for (size_t i = 0; i < N; ++i) {
if ((ascending && sf_float_lt(a[i], b[i])) ||
(!ascending && sf_float_gt(a[i], b[i])))
{
return true;
}
}
return false;
}
};
template <typename T, size_t N, class Compare = BlockCompare<T, N> >
SHAREMIND_MODULE_API_0x1_SYSCALL(blockSortPermutation,
args, num_args, refs, crefs,
returnValue, c)
{
(void) c;
(void) args;
if (num_args != 1u || returnValue || !crefs || !refs)
return SHAREMIND_MODULE_API_0x1_INVALID_CALL;
assert(crefs[0u].pData);
assert(refs[0u].pData);
assert(crefs[0u].size > 0u);
assert(refs[0u].size > 0u);
typedef std::array<T, N> Block;
static_assert(sizeof(Block) == sizeof(T) * N,
"Block type size differs from the assumed type size");
if (crefs[0u].size != sizeof(T) &&
(crefs[0u].size - 1u) % sizeof(Block) != 0)
return SHAREMIND_MODULE_API_0x1_INVALID_CALL;
const bool ascending = static_cast<bool>(args[0].uint8[0]);
const size_t dataSize =
crefs[0u].size == sizeof(T) ?
sizeof(T) : crefs[0u].size - 1u;
if (refs[0u].size != sizeof(uint64_t) &&
(refs[0u].size - 1u) % sizeof(uint64_t) != 0)
return SHAREMIND_MODULE_API_0x1_INVALID_CALL;
const size_t indexSize =
refs[0u].size == sizeof(uint64_t) ?
sizeof(uint64_t) : refs[0u].size - 1u;
if (dataSize / sizeof(Block) != indexSize / sizeof(uint64_t))
return SHAREMIND_MODULE_API_0x1_INVALID_CALL;
uint64_t * const index = static_cast<uint64_t *>(refs[0u].pData);
if (std::any_of(index, index + indexSize / sizeof(uint64_t),
[dataSize] (const uint64_t idx) {
return idx >= dataSize;
}))
{
return SHAREMIND_MODULE_API_0x1_INVALID_CALL;
}
const Block * const data = static_cast<const Block *>(crefs[0u].pData);
Compare compare;
uint64_t * const start = index;
uint64_t * const end = index + indexSize / sizeof(uint64_t);
std::stable_sort(start, end,
[&data, &compare, ascending] (const uint64_t a, const uint64_t b) {
return compare(data[a], data[b], ascending);
});
return SHAREMIND_MODULE_API_0x1_OK;
}
#endif // SHAREMIND_MOD_ALGORITHMS_BLOCKSORTPERMUTATION_H
|
#ifndef _ULYSSES_SERIAL
#define _ULYSSES_SERIAL
#define COM1 0x3f8
#define COM2 0x2f8
/* init_serial()
* Set up the hardware serial device given by port, reading for reading
* and/or writing.
*/
void init_serial(unsigned int port);
/* write_serial()
* Write the given character to the (already initialised) serial port.
* Note that this *may* block if the serial port has unread/unwritten data
* in buffered in it.
*/
void write_serial(unsigned int port, const char c);
/* read_serial()
* Block until there is data to be read on the (already initialised) serial
* port and return the first character.
*/
char read_serial(unsigned int port);
#endif
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
*
* Copyright (C) 1997 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*/
#include "mpioimpl.h"
#ifdef HAVE_WEAK_SYMBOLS
#if defined(HAVE_PRAGMA_WEAK)
#pragma weak MPI_File_get_group = PMPI_File_get_group
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
#pragma _HP_SECONDARY_DEF PMPI_File_get_group MPI_File_get_group
#elif defined(HAVE_PRAGMA_CRI_DUP)
#pragma _CRI duplicate MPI_File_get_group as PMPI_File_get_group
/* end of weak pragmas */
#elif defined(HAVE_WEAK_ATTRIBUTE)
int MPI_File_get_group(MPI_File fh, MPI_Group *group) __attribute__((weak,alias("PMPI_File_get_group")));
#endif
/* Include mapping from MPI->PMPI */
#define MPIO_BUILD_PROFILING
#include "mpioprof.h"
#endif
/*@
MPI_File_get_group - Returns the group of processes that
opened the file
Input Parameters:
. fh - file handle (handle)
Output Parameters:
. group - group that opened the file (handle)
.N fortran
@*/
int MPI_File_get_group(MPI_File fh, MPI_Group *group)
{
int error_code;
ADIO_File adio_fh;
static char myname[] = "MPI_FILE_GET_GROUP";
MPIU_THREAD_CS_ENTER(ALLFUNC,);
adio_fh = MPIO_File_resolve(fh);
/* --BEGIN ERROR HANDLING-- */
MPIO_CHECK_FILE_HANDLE(adio_fh, myname, error_code);
/* --END ERROR HANDLING-- */
/* note: this will return the group of processes that called open, but
* with deferred open this might not be the group of processes that
* actually opened the file from the file system's perspective
*/
error_code = MPI_Comm_group(adio_fh->comm, group);
fn_exit:
MPIU_THREAD_CS_EXIT(ALLFUNC,);
return error_code;
}
|
/*
*
* DiskCryptor - open source partition encryption tool
* Copyright (c) 2007-2010
* ntldr <ntldr@diskcryptor.net> PGP key ID - 0xC48251EB4F8E4E6E
*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <windows.h>
#include "main.h"
#include "threads.h"
#include "dlg_menu.h"
DWORD
WINAPI
_thread_format_proc(
LPVOID lparam
)
{
int i = 0;
int rlt, wp_mode;
wchar_t device[MAX_PATH];
_dnode *node;
_dact *act;
dc_open_device( );
EnterCriticalSection(&crit_sect);
node = pv(lparam);
act = _create_act_thread(node, -1, -1);
if ( !node || !act )
{
return 0L;
}
wcscpy(device, act->device);
do
{
if ( act->status != ACT_RUNNING )
{
break;
}
if ( i-- == 0 )
{
dc_sync_enc_state(device);
i = 20;
}
wp_mode = act->wp_mode;
LeaveCriticalSection( &crit_sect );
rlt = dc_format_step( device, wp_mode );
EnterCriticalSection( &crit_sect );
if ( rlt == ST_FINISHED )
{
act->status = ACT_STOPPED;
break;
}
if ( ( rlt != ST_OK ) && ( rlt != ST_RW_ERR ) )
{
dc_status st;
dc_get_device_status( device, &st );
__error_s(
HWND_DESKTOP,
L"Format error on volume [%s]", rlt, st.mnt_point
);
act->status = ACT_STOPPED;
break;
}
} while (1);
if ( rlt == ST_FINISHED )
{
_finish_formating( node );
}
LeaveCriticalSection( &crit_sect );
return 1L;
}
static
DWORD WINAPI
_thread_enc_dec_proc(
LPVOID lparam
)
{
BOOL encrypting;
int i = 0;
int rlt, wp_mode;
wchar_t device[MAX_PATH];
_dnode *node;
_dact *act;
dc_open_device( );
EnterCriticalSection( &crit_sect );
node = pv(lparam);
act = _create_act_thread(node, -1, -1);
if ( !node || !act )
{
return 0L;
}
wcscpy( device, act->device );
do
{
if ( act->status != ACT_RUNNING )
{
break;
}
if ( i-- == 0 )
{
dc_sync_enc_state( device );
i = 20;
}
encrypting = act->act != ACT_DECRYPT;
wp_mode = act->wp_mode;
LeaveCriticalSection( &crit_sect );
rlt = encrypting ?
dc_enc_step(device, wp_mode) :
dc_dec_step(device);
EnterCriticalSection(&crit_sect);
if ( rlt == ST_FINISHED )
{
act->status = ACT_STOPPED;
break;
}
if ( rlt == ST_CANCEL )
{
Sleep(5000);
}
if ( ( rlt != ST_OK ) && ( rlt != ST_RW_ERR ) && ( rlt != ST_CANCEL ) )
{
dc_status st;
wchar_t *act_name;
dc_get_device_status( device, &st );
switch ( act->act )
{
case ACT_ENCRYPT: act_name = L"Encryption"; break;
case ACT_DECRYPT: act_name = L"Decryption"; break;
case ACT_REENCRYPT: act_name = L"Reencryption"; break;
}
__error_s(
HWND_DESKTOP,
L"%s error on volume [%s]", rlt, act_name, st.mnt_point
);
act->status = ACT_STOPPED;
break;
}
} while (1);
dc_sync_enc_state(device);
LeaveCriticalSection(&crit_sect);
return 1L;
}
void _clear_act_list( )
{
list_entry *node = __action.flink;
list_entry *del = NULL;
list_entry *head = &__action;
for ( ;
node != &__action;
)
{
_dact *act = contain_record(node, _dact, list);
if ( ACT_STOPPED == act->status )
{
if ( WaitForSingleObject(act->h_thread, 0) == WAIT_OBJECT_0 )
{
del = node;
node = node->flink;
_remove_entry_list(del);
CloseHandle(act->h_thread);
free(del);
continue;
}
}
node = node->flink;
}
}
_dact *_create_act_thread(
_dnode *node,
int act_type, // -1 - search
int act_status //
)
{
list_entry *item;
_dact *act;
DWORD resume;
BOOL exist = FALSE;
if ( !node )
{
return NULL;
}
_clear_act_list( );
for (
item = __action.flink;
item != &__action;
item = item->flink
)
{
act = contain_record(item, _dact, list);
if ( !wcscmp(act->device, node->mnt.info.device) )
{
exist = TRUE;
if ( act_type == -1 )
{
return act;
} else {
break;
}
}
}
if ( act_type != -1 )
{
if ( !exist )
{
act = malloc(sizeof(_dact));
memset(act, 0, sizeof(_dact));
act->wp_mode = node->mnt.info.status.crypt.wp_mode;
wcsncpy( act->device, node->mnt.info.device, MAX_PATH );
_init_speed_stat( &act->speed );
}
act->h_thread = NULL;
act->status = act_status;
act->act = act_type;
if ( act_status == ACT_RUNNING )
{
void *proc;
switch (act_type)
{
case ACT_REENCRYPT:
case ACT_ENCRYPT:
case ACT_DECRYPT: proc = _thread_enc_dec_proc; break;
case ACT_FORMAT: proc = _thread_format_proc; break;
}
act->h_thread = CreateThread(
NULL, 0, proc, pv(node), CREATE_SUSPENDED, NULL
);
SetThreadPriority(act->h_thread, THREAD_PRIORITY_LOWEST);
resume = ResumeThread(act->h_thread);
if ( !act->h_thread || resume == (DWORD)-1 )
{
free(act);
__error_s( __dlg, L"Error create thread", -1 );
return NULL;
}
}
if ( !exist )
{
_insert_tail_list(&__action, &act->list);
}
return act;
}
return NULL;
}
|
// Copyright (C) 2010, 2011, 2012, 2013, 2014 Steffen Rendle
// Contact: srendle@libfm.org, http://www.libfm.org/
//
// This file is part of libFM.
//
// libFM 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.
//
// libFM 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 libFM. If not, see <http://www.gnu.org/licenses/>.
//
//
// util.h: Utility functions
#ifndef UTIL_H_
#define UTIL_H_
#include <vector>
#include <ctime>
#ifdef _WIN32
#include <float.h>
#else
#include <sys/resource.h>
#endif
#include <iostream>
#include <fstream>
typedef unsigned int uint;
#ifdef _WIN32
namespace std {
bool isnan(double d) { return _isnan(d); }
bool isnan(float f) { return _isnan(f); }
bool isinf(double d) { return (! _finite(d)) && (! isnan(d)); }
bool isinf(float f) { return (! _finite(f)) && (! isnan(f)); }
}
#endif
#include <math.h>
double sqr(double d) { return d*d; }
double sigmoid(double d) { return (double)1.0/(1.0+exp(-d)); }
std::vector<std::string> tokenize(const std::string& str, const std::string& delimiter) {
std::vector<std::string> result;
std::string::size_type lastPos = str.find_first_not_of(delimiter, 0);
std::string::size_type pos = str.find_first_of(delimiter, lastPos);
while (std::string::npos != pos || std::string::npos != lastPos) {
result.push_back(str.substr(lastPos, pos - lastPos));
lastPos = str.find_first_not_of(delimiter, pos);
pos = str.find_first_of(delimiter, lastPos);
}
return result;
}
double getusertime2() {
return (double) clock_t() / CLOCKS_PER_SEC;
}
double getusertime() {
#ifdef _WIN32
return getusertime2();
#else
struct rusage ru;
getrusage(RUSAGE_SELF, &ru);
struct timeval tim = ru.ru_utime;
return (double)tim.tv_sec + (double)tim.tv_usec / 1000000.0;
#endif
}
double getusertime3() {
return (double) clock() / CLOCKS_PER_SEC;
}
double getusertime4() {
return (double) time(NULL);
}
bool fileexists(std::string filename) {
std::ifstream in_file (filename.c_str());
return in_file.is_open();
}
#endif /*UTIL_H_*/
|
/*
Copyright 2010-2012 Mark Boots, David Chevrier, and Darren Hunter.
Copyright 2013-2014 David Chevrier and Darren Hunter.
This file is part of the Acquaman Data Acquisition and Management framework ("Acquaman").
Acquaman 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.
Acquaman 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 Acquaman. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef AMSAMPLEBRIEFVIEW_H
#define AMSAMPLEBRIEFVIEW_H
#include <QWidget>
class QLabel;
class QPushButton;
class AMSample;
class AMSampleReadOnlyView;
class AMSampleBriefView : public QWidget
{
Q_OBJECT
public:
/// Constructor takes a sample to view (or a null pointer)
AMSampleBriefView(const AMSample *sample = 0, QWidget *parent = 0);
public slots:
/// Sets the sample
void setSample(const AMSample *sample);
protected slots:
/// Handles clicks from the button and launches a new AMSampleView
void onShowSampleInformationButtonClicked();
protected:
/// The sample we intend to view
const AMSample *sample_;
/// Label that holds the name of the sample
QLabel *nameLabel_;
/// Push button for launching the expanded sample view
QPushButton *showSampleInformationButton_;
/// A full AMSampleView that is launched (or shown) when the show information button is clicked
AMSampleReadOnlyView *sampleReadOnlyView_;
};
#endif // AMSAMPLEBRIEFVIEW_H
|
// DiskArcher.
// CFileToArc class - a file that the program shall copy to the Archive.
// (C) Marat Mirgaleev, 2001-2014.
// Modifications:
// (1) 04.02.2002. m_bSystem added.
// (2) 18.02.2002. Delete() added.
// (3) 03.03.2002. m_nFolderID, m_bPaused added.
// (4) 08.03.2002. GetStatus() added.
// (5) 28.03.2002. Init() added.
// (6) 19.04.2003. Compressing added.
// (9) 22.11.2003. ResetRuntimeData() added.
// (10) 24.05.2006. getRequiredCopiesNum() added.
//============================================================================
#if !defined(CFileToArc_h)
#define CFileToArc_h
#include <vector>
#include "../MArcLib/CFileOnDisk.h"
#include "fileStatus.h"
#include "MyCommon.h"
#include "CRoom.h"
class CBundle;
class CFileToArc : public CFileOnDisk
{
public:
CFileToArc();
CFileToArc(CString fullName);
bool Delete();
bool GetStatus(); // Decide, must the file be updated or not
bool PreCompress();
CString GetCompressedFileName() const;// With the full path!
bool IsPreCompressed() { return ( m_sCompressedFilename != "" ); }
void ResetRuntimeData(); // Clear some non-actual runtime information
unsigned int getRequiredCopiesNum() const; // (10)
int m_nPriority;
int m_nUpToCopies;
fileStatus m_nStatus;
// In which Rooms to create copies.
// Only for temporary assignments during the Archive update. Isn't stored in DB.
std::vector<CRoom*> m_CopyToRooms;
unsigned int CountCopies( const CRoom* const i_pRoom ) const;
// Only for temporary assignment during updating the Archive. Isn't stored in DB.
CBundle* m_pBundle;
// 2014 Don't need it CFileCopy* m_pCopyToReplace; // It is only run-time information
bool m_addCopy; // 2014: Was: fileCommand m_nCommand; // It is only run-time information
// Is this file for the program use or a regular user's file
bool m_bSystem;
// (3) if != 0, that this File is got by mask
ID m_nFolderID;
// Archiving of this file is paused by user
bool m_bPaused;
// Use compression when is storing the backup copy
bool m_bCompressIt; // (6)
// Calculated size of File's copy if store it into the m_pRoom
_int64 m_nPredictedCompressedSize;
protected:
CString m_sCompressedFilename; // Without path!
private:
void Init();
};
#endif /* CFileToArc_h */
|
/*
* PC_comm.h
*
* Created on: 29 May 2015
* Author: raquel
*/
const int PC_timeoutlimit = 2000; // timeout in milliseconds for response from PC
//variables used in getasciinum
const char startOfNumberDelimiter = '<';
const char endOfNumberDelimiter = '>';
const char RepNumIndicator = 'R'; // rep numbers sent to PC in format R#
const char PrtNumIndicator = 'P'; //prt number sent to PC in format P#
const char PhaseOrderIndicator = 'D'; //phase delay in degrees in format D1,2,3,4,5...
const char FreqOrderIndicator = 'O'; // freqorder sent like O1,2,3,4,5etc.
const char ComplianceStatusIndicator = 'C'; // compliance status sent like C0,0,0,0,0,0,....
const char OrderDelimiter = ','; //freq/phase order sent comma delimited
void establishContact();
int PC_getsettings();
int checkinputs();
int getasciinum();
long getasciinum_long();
void sendasciinum(int num);
void sendasciinum_long(long num);
void PC_sendupdate();
void PC_sendphaseupdate();
void PC_sendcomplianceupdate();
|
/*
* This file is protected by Copyright. Please refer to the COPYRIGHT file
* distributed with this source distribution.
*
* This file is part of GNUHAWK.
*
* GNUHAWK is free software: you can redistribute it and/or modify is 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.
*
* GNUHAWK 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 sub_cc_2i_GH_BLOCK_H
#define sub_cc_2i_GH_BLOCK_H
#include <gr_component.h>
#include <gr_sub_cc.h>
typedef GHComponent< gr_sub_cc > GnuHawkBlock;
#endif
|
#include<stdio.h>
#include<string.h>
#include<math.h>
#define Pi 2*acos(0.0)
int main()
{
int t;
double r,h,g,n;
scanf("%d",&t);
while(t--)
{
r=0;
scanf("%lf",&n);
r=n/5;
h=(n*6)/10;
r=Pi*r*r;
g=(n*h)-r;
printf("%.2lf %.2lf\n",r,g);
}
return 0;
}
|
#include "point.h"
#include <math.h>
void point_init(struct point* point, double x, double y)
{
point->x = x;
point->y = y;
}
void point_destroy(struct point* point) { point = point; }
struct point point_product(double s, const struct point* p)
{
struct point result;
result.x = s * p->x;
result.y = s * p->y;
return result;
}
struct point point_sum(const struct point* p0, const struct point* p1)
{
struct point result;
result.x = p0->x + p1->x;
result.y = p0->y + p1->y;
return result;
}
struct point point_interpolate(const struct point* p0,
const struct point* p1)
{
struct point result;
result.x = (p0->x + p1->x) / 2;
result.y = (p0->y + p1->y) / 2;
return result;
}
double point_distance(const struct point* p0, const struct point* p1)
{
return sqrt(pow(p1->x - p0->x, 2) + pow(p1->y - p0->y, 2));
}
|
// -------------------------------------------------------------------------
// Crytek Source File.
// Copyright (C) Crytek GmbH, 2001-2008.
// -------------------------------------------------------------------------
#ifndef __RENDELEMENT_H__
#define __RENDELEMENT_H__
//=============================================================
#include "VertexFormats.h"
class CRendElement;
struct CRenderChunk;
struct PrimitiveGroup;
class CShader;
struct SShaderTechnique;
class CParserBin;
struct SParserFrame;
enum EDataType
{
eDATA_Unknown = 0,
eDATA_Dummy,
eDATA_Sky,
eDATA_Beam,
eDATA_ClientPoly,
eDATA_ClientPoly2D,
eDATA_Flare,
eDATA_Terrain,
eDATA_SkyZone,
eDATA_Mesh,
eDATA_Imposter,
eDATA_PanoramaCluster,
eDATA_TerrainSector,
eDATA_FarTreeSprites,
eDATA_ShadowMapGen,
eDATA_TerrainDetailTextureLayers,
eDATA_TerrainParticles,
eDATA_Ocean,
eDATA_OcclusionQuery,
eDATA_TempMesh,
eDATA_Particle,
eDATA_PostProcess,
eDATA_HDRProcess,
eDATA_Cloud,
eDATA_HDRSky,
eDATA_FogVolume,
eDATA_WaterVolume,
eDATA_WaterWave,
eDATA_WaterOcean,
eDATA_VolumeObject
};
#include <Cry_Color.h>
//=======================================================
#define FCEF_TRANSFORM 1
#define FCEF_TRACE 2
#define FCEF_NODEL 4
#define FCEF_MODIF_TC 0x10
#define FCEF_MODIF_VERT 0x20
#define FCEF_MODIF_COL 0x40
#define FCEF_MODIF_MASK 0xf0
#define FCEF_NEEDFILLBUF 0x100
#define FCEF_ALLOC_CUST_FLOAT_DATA 0x200
#define FCEF_MERGABLE 0x400
#define FCEF_GEOM_SHADER 0x800
#define FGP_NOCALC 1
#define FGP_SRC 2
#define FGP_REAL 4
#define FGP_WAIT 8
#define FGP_STAGE_SHIFT 0x10
#define MAX_CUSTOM_TEX_BINDS_NUM 2
class CRendElement
{
public:
EDataType m_Type;
uint m_Flags;
public:
void *m_CustomData;
int m_CustomTexBind[MAX_CUSTOM_TEX_BINDS_NUM];
static CRendElement m_RootGlobal;
CRendElement *m_NextGlobal;
CRendElement *m_PrevGlobal;
protected:
_inline void UnlinkGlobal()
{
if (!m_NextGlobal || !m_PrevGlobal)
return;
m_NextGlobal->m_PrevGlobal = m_PrevGlobal;
m_PrevGlobal->m_NextGlobal = m_NextGlobal;
m_NextGlobal = m_PrevGlobal = NULL;
}
_inline void LinkGlobal( CRendElement* Before )
{
if (m_NextGlobal || m_PrevGlobal)
return;
m_NextGlobal = Before->m_NextGlobal;
Before->m_NextGlobal->m_PrevGlobal = this;
Before->m_NextGlobal = this;
m_PrevGlobal = Before;
}
public:
CRendElement()
{
m_Type = eDATA_Unknown;
m_NextGlobal = NULL;
m_PrevGlobal = NULL;
m_Flags = 0;
m_CustomData = NULL;
for(int i=0; i<MAX_CUSTOM_TEX_BINDS_NUM; i++)
m_CustomTexBind[i] = -1;
if (!m_RootGlobal.m_NextGlobal)
{
m_RootGlobal.m_NextGlobal = &m_RootGlobal;
m_RootGlobal.m_PrevGlobal = &m_RootGlobal;
}
if (this != &m_RootGlobal)
LinkGlobal(&m_RootGlobal);
}
virtual ~CRendElement();
virtual void Release();
const char *mfTypeString();
EDataType mfGetType() { return m_Type; }
void mfSetType(EDataType t) { m_Type = t; }
uint mfGetFlags(void) { return m_Flags; }
void mfSetFlags(uint fl) { m_Flags = fl; }
void mfUpdateFlags(uint fl) { m_Flags |= fl; }
void mfClearFlags(uint fl) { m_Flags &= ~fl; }
virtual void mfPrepare();
virtual bool mfCullByClipPlane(CRenderObject *pObj);
virtual CRenderChunk *mfGetMatInfo();
virtual PodArray<CRenderChunk> *mfGetMatInfoList();
virtual int mfGetMatId();
virtual void mfReset();
virtual bool mfIsHWSkinned() { return false; }
virtual CRendElement *mfCopyConstruct(void);
virtual void mfCenter(Vec3& centr, CRenderObject*pObj);
virtual void mfGetBBox(Vec3& vMins, Vec3& vMaxs)
{
vMins.Set(0,0,0);
vMaxs.Set(0,0,0);
}
virtual void mfGetPlane(Plane& pl);
virtual float mfDistanceToCameraSquared(Matrix34& matInst);
virtual bool mfCompile(CParserBin& Parser, SParserFrame& Frame) { return false; }
virtual bool mfDraw(CShader *ef, SShaderPass *sfm);
virtual void *mfGetPointer(ESrcPointer ePT, int *Stride, EParamType Type, ESrcPointer Dst, int Flags);
virtual bool mfPreDraw(SShaderPass *sl) { return true; }
virtual float mfMinDistanceToCamera(Matrix34& matInst) {return -1;};
virtual bool mfCheckUpdate(int nVertFormat, int Flags) {return true;}
virtual void mfPrecache(const SShaderItem& SH) {}
virtual int Size() {return 0;}
static void ShutDown();
};
//==========================================================
#endif // __RENDELEMENT_H__
|
#ifndef DBA_COLORGENERATOR_CLASS
#define DBA_COLORGENERATOR_CLASS
#include <string>
class colorgenerator
{
public:
colorgenerator(std::string value);
int r;
int g;
int b;
std::string hex;
};
#endif //DBA_COLORGENERATOR |
#pragma once
#include "Module.h"
class Gcode;
class RotaryDeltaCalibration : public Module
{
public:
RotaryDeltaCalibration(){};
virtual ~RotaryDeltaCalibration(){};
void on_module_loaded();
private:
void on_gcode_received(void *argument);
bool get_homing_offset(float*);
};
|
#include "common.h"
void mpz_set_ull (mpz_t z, unsigned long long ull)
{
mpz_import(z, 1, -1, sizeof ull, 0, 0, &ull);
}
unsigned long long mpz_get_ull(mpz_t z)
{
unsigned long long result = 0;
size_t bytes = (mpz_sizeinbase(z, 16) + 1) / 2;
if (sizeof(result) > bytes)
{
mpz_export(&result, 0, -1, sizeof result, 0, 0, z);
return result;
}
else
{
return LLONG_MAX;
}
}
void mpz_set_ll(mpz_t z, long long sll)
{
if (sll < 0)
{
sll = -sll;
mpz_import(z, 1, -1, sizeof sll, 0, 0, &sll);
mpz_neg(z, z);
}
else
{
mpz_import(z, 1, -1, sizeof sll, 0, 0, &sll);
}
}
long long mpz_get_ll(mpz_t z)
{
long long result = 0;
switch (mpz_sgn(z))
{
case 0:
return 0ll;
case -1:
mpz_export(&result, 0, -1, sizeof result, 0, 0, z);
return -result;
default:
mpz_export(&result, 0, -1, sizeof result, 0, 0, z);
return result;
}
}
|
#ifndef ZNUMBERFORMATTER_H
#define ZNUMBERFORMATTER_H
#define ZCM_FORMATTER_NUMBER "number"
#define ZFMT_METHOD_NUM_ROUND "round"
#define ZFMT_METHOD_NUM_CURRENCY "currency"
#define ZFMT_METHOD_NUM_CEIL "ceiling"
#define ZFMT_METHOD_NUM_FLOOR "floor"
#define ZFMT_METHOD_NUM_FIX "fix"
#define ZFMT_METHOD_NUM_ABS "abs"
#define ZFMT_METHOD_NUM_MIN "min"
#define ZFMT_METHOD_NUM_MAX "max"
#define ZFMT_METHOD_NUM_AVG "avg"
#define ZFMT_METHOD_NUM_RANGE "range"
#define ZFMT_METHOD_NUM_ACOS "acos"
#define ZFMT_METHOD_NUM_ACOT "acot"
#define ZFMT_METHOD_NUM_ACSC "acsc"
#define ZFMT_METHOD_NUM_ASEC "asec"
#define ZFMT_METHOD_NUM_ASIN "asin"
#define ZFMT_METHOD_NUM_ATAN "atan"
#define ZFMT_METHOD_NUM_COS "cos"
#define ZFMT_METHOD_NUM_COT "cot"
#define ZFMT_METHOD_NUM_CSC "csc"
#define ZFMT_METHOD_NUM_SEC "sec"
#define ZFMT_METHOD_NUM_SIN "sin"
#define ZFMT_METHOD_NUM_TAN "tan"
#define ZFMT_METHOD_NUM_SUM "sum"
#define ZFMT_METHOD_NUM_DIFF "difference"
#define ZFMT_METHOD_NUM_PROD "product"
#define ZFMT_METHOD_NUM_QUOT "quotient"
#define ZFMT_METHOD_NUM_MOD "mod"
#define ZFMT_METHOD_NUM_EXP "exponent"
#define ZFMT_METHOD_NUM_LOG "log"
#define ZFMT_METHOD_NUM_LN "ln"
#define ZFMT_METHOD_NUM_GCD "gcd"
#define ZFMT_METHOD_NUM_LCM "lcm"
#define ZFMT_METHOD_NUM_BASE "base"
#define ZFMT_METHOD_NUM_BIN "bin"
#define ZFMT_METHOD_NUM_OCT "octal"
#define ZFMT_METHOD_NUM_HEX "hex"
#define ZFMT_METHOD_NUM_EVEN "even"
#define ZFMT_METHOD_NUM_ODD "odd"
#define ZFMT_METHOD_NUM_DERIV "derivative"
#include <zabstractformatter.h>
#include <qmath.h>
class ZNumberFormatter : public ZAbstractFormatter
{
Q_OBJECT
public:
ZNumberFormatter(QObject *parent=0);
public slots:
virtual QVariant transform(QVariant);
private:
QVariant _round(QVariant in, int places=0);
QVariant _currency(QVariant in);
QVariant _ceiling(QVariant in);
QVariant _floor(QVariant in);
QVariant _fix(QVariant in, int places);
QVariant _abs(QVariant in);
QVariant _min(QVariant in, QVariant other);
QVariant _max(QVariant in, QVariant other);
QVariant _avg(QVariant in, QVariant other);
QVariant _range(QVariant in, QVariant other);
QVariant _sum(QVariant in, QVariant other);
QVariant _difference(QVariant in, QVariant other);
QVariant _product(QVariant in, QVariant other);
QVariant _quotient(QVariant in, QVariant other);
QVariant _modulus(QVariant in, QVariant other);
QVariant _exponent(QVariant in, float power);
QVariant _log(QVariant in, int base=10);
QVariant _ln(QVariant in);
QVariant _gcd(QVariant in, QVariant other);
QVariant _lcm(QVariant in, QVariant other);
QVariant _base(QVariant in, int toBase, int fromBase=10);
QVariant _bin(QVariant in, int fromBase=10);
QVariant _octal(QVariant in, int fromBase=10);
QVariant _hex(QVariant in, int fromBase=10);
QVariant _even(QVariant in);
QVariant _odd(QVariant in);
QVariant _sin(QVariant in);
QVariant _cos(QVariant in);
QVariant _tan(QVariant in);
QVariant _sec(QVariant in);
QVariant _csc(QVariant in);
QVariant _cot(QVariant in);
QVariant _asin(QVariant in);
QVariant _acos(QVariant in);
QVariant _atan(QVariant in);
QVariant _asec(QVariant in);
QVariant _acsc(QVariant in);
QVariant _acot(QVariant in);
};
#endif // ZNUMBERFORMATTER_H
|
#include <stdlib.h>
typedef struct tree1 {
int data;
struct tree1 *left;
struct tree1 *right;
struct tree1 *parrent;
}* tree;
/* We suppose, that the data structure is on the beginning pointed by variable x */
void dfs(tree x) {
tree y;
while (x != NULL) {
y=x->left;
if ((y != NULL) && (y->data == 0))
x=y;
else {
y=x->right;
if ((y != NULL) && (y->data == 0))
x=y;
else {
x->data=1;
x=x->parrent;
}
}
}
}
|
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2007 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#ifndef MANTID_DATAOBJECTS_WORKSPACESINGLEVALUE_H_
#define MANTID_DATAOBJECTS_WORKSPACESINGLEVALUE_H_
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/HistoWorkspace.h"
#include "MantidDataObjects/Histogram1D.h"
namespace Mantid {
namespace DataObjects {
/** Concrete workspace implementation. Data is a single double value
@author Nicholas Draper
@date 19/05/2008
*/
class DLLExport WorkspaceSingleValue : public API::HistoWorkspace {
public:
/** Gets the name of the workspace type
* @return Standard string name */
const std::string id() const override { return "WorkspaceSingleValue"; }
WorkspaceSingleValue(
double value = 0.0, double error = 0.0,
const Parallel::StorageMode storageMode = Parallel::StorageMode::Cloned);
/// Returns a clone of the workspace
std::unique_ptr<WorkspaceSingleValue> clone() const {
return std::unique_ptr<WorkspaceSingleValue>(doClone());
}
/// Returns a default-initialized clone of the workspace
std::unique_ptr<WorkspaceSingleValue> cloneEmpty() const {
return std::unique_ptr<WorkspaceSingleValue>(doCloneEmpty());
}
WorkspaceSingleValue &operator=(const WorkspaceSingleValue &other) = delete;
/// Returns the number of single indexable items in the workspace
std::size_t size() const override { return 1; }
/// Returns the size of each block of data returned by the dataX accessors
std::size_t blocksize() const override { return 1; }
/// @return the number of histograms (spectra)
std::size_t getNumberHistograms() const override { return 1; }
Histogram1D &getSpectrum(const size_t index) override {
invalidateCommonBinsFlag();
return getSpectrumWithoutInvalidation(index);
}
const Histogram1D &getSpectrum(const size_t /*index*/) const override {
return data;
}
void generateHistogram(const std::size_t index, const MantidVec &X,
MantidVec &Y, MantidVec &E,
bool skipError = false) const override;
/// Returns the number of dimensions, 0 in this case.
size_t getNumDims() const override;
protected:
/// Protected copy constructor. May be used by childs for cloning.
WorkspaceSingleValue(const WorkspaceSingleValue &other);
private:
WorkspaceSingleValue *doClone() const override {
return new WorkspaceSingleValue(*this);
}
WorkspaceSingleValue *doCloneEmpty() const override {
return new WorkspaceSingleValue();
}
// allocates space in a new workspace - does nothing in this case
void init(const std::size_t &NVectors, const std::size_t &XLength,
const std::size_t &YLength) override;
void init(const HistogramData::Histogram &histogram) override;
Histogram1D &getSpectrumWithoutInvalidation(const size_t index) override;
/// Instance of Histogram1D that holds the "spectrum" (AKA the single value);
Histogram1D data{HistogramData::Histogram::XMode::Points,
HistogramData::Histogram::YMode::Counts};
};
/// shared pointer to the WorkspaceSingleValue class
using WorkspaceSingleValue_sptr = boost::shared_ptr<WorkspaceSingleValue>;
using WorkspaceSingleValue_const_sptr =
boost::shared_ptr<const WorkspaceSingleValue>;
} // namespace DataObjects
} // namespace Mantid
#endif /*MANTID_DATAOBJECTS_WORKSPACESINGLEVALUE_H_*/
|
#pragma once
/**
* \author Lucas Kramer
* \file util.h
* \brief Helper functions for the simulation
*/
#include "NeuralNetwork.h"
/** \brief util namespace, contains helper functions to add and remove robots */
namespace util {
/**
* \brief Finds an object from the current environment
* \param id The id of the object to find
* \return The object that was looked iup
*/
PhysicalObject* getObject(int id);
/**
* \brief Removes all objects and resets to the initial state
*/
void reset();
/**
* \brief Function to render all the objects.
* \detail This function is called repeatedly from the simulation, and iterates through
* the objects and calls their respective display functions.
*/
void display();
/**
* \brief Function to update the positions of all objects.
* \detail This function is called repeatedly from the simulation, and iterates through
* the objects and calls their respective updatePosition functions.
*/
void advance();
/**
* \brief Gets a new, unused color
* \return The new color
*/
Color newColor();
/**
* \brief Gets the number of robots/target pairs
* \return The number of robots/target pairs
*/
int getNumRobotsTargets();
/**
* \brief Gets the number of lights
* \return The number of lights
*/
int getNumLights();
/**
* \brief Gets the number of obstacles
* \return The number of obstacles
*/
int getNumObstacles();
/**
* \brief Adds a robot and paired target to the simulation
* \param robotType The type of robot to add. 0 is SimpleRobot,
* 1 is ComplexRobot, and 2 is NeuralNetworkRobot
* \param lightSensorConnectionPattern Settings for ComplexRobot light sensor
* \param robotSensorConnectionPattern Settings for ComplexRobot robot sensor
* \param obstacleSensorConnectionPattern Settings for ComplexRobot obstacle sensor
* \param targetSensorConnectionPattern Settings for ComplexRobot target sensor
* \param lightSensorScale Settings for ComplexRobot light sensor
* \param robotSensorScale Settings for ComplexRobot robot sensor
* \param obstacleSensorScale Settings for ComplexRobot obstacle sensor
* \param targetSensorScale Settings for ComplexRobot target sensor
* \param initalSpeed Default speed for ComplexRobot
* \param neuralNetworkFile File in which neural network is stored
* \return true if successful
*/
bool addRobotTarget(int robotType,
int lightSensorConnectionPattern,
int robotSensorConnectionPattern,
int obstacleSensorConnectionPattern,
int targetSensorConnectionPattern,
float lightSensorScale,
float robotSensorScale,
float obstacleSensorScale,
float targetSensorScale,
int initialSpeed,
std::string neuralNetworkFile);
/**
* \brief Adds a robot to the simulation
* \param robotType The type of robot to add. 0 is SimpleRobot,
* 1 is ComplexRobot, and 2 is NeuralNetworkRobot
* \param lightSensorConnectionPattern Settings for ComplexRobot light sensor
* \param robotSensorConnectionPattern Settings for ComplexRobot robot sensor
* \param obstacleSensorConnectionPattern Settings for ComplexRobot obstacle sensor
* \param targetSensorConnectionPattern Settings for ComplexRobot target sensor
* \param lightSensorScale Settings for ComplexRobot light sensor
* \param robotSensorScale Settings for ComplexRobot robot sensor
* \param obstacleSensorScale Settings for ComplexRobot obstacle sensor
* \param targetSensorScale Settings for ComplexRobot target sensor
* \param initalSpeed Default speed for ComplexRobot
* \param neuralNetworkFile File in which neural network is stored
* \return true if successful
*/
bool addRobot(int robotType,
int lightSensorConnectionPattern,
int robotSensorConnectionPattern,
int obstacleSensorConnectionPattern,
int targetSensorConnectionPattern,
float lightSensorScale,
float robotSensorScale,
float obstacleSensorScale,
float targetSensorScale,
int initialSpeed,
std::string neuralNetworkFile);
/**
* \brief Adds a neural network robot and a paired target to the simulation
* \param network the network to control the robot
* \return true if successful
*/
bool addNeuralNetworkRobotTarget(const NeuralNetwork &network);
/**
* \brief Adds a light to the simulation
* \return true if successful
*/
bool addStationaryLightSource();
/**
* \brief Adds a light to the simulation
* \return true if successful
*/
bool addMovingLightSource();
/**
* \brief Adds a obstacle to the simulation
* \return true if successful
*/
bool addObstacle();
/**
* \brief Copies an object to a new Location
* \param id the id of the object to copy
* \param loc the destination
* \return true if successful
*/
bool copy(int id, Location loc);
/**
* \brief Removes a robot from the simulation
* \return true if successful
*/
bool removeRobotTarget();
/**
* \brief Removes a light from the simulation
* \return true if successful
*/
bool removeLightSource();
/**
* \brief Removes a obstacle from the simulation
* \return true if successful
*/
bool removeObstacle();
/**
* \brief Removes all robots
*/
void removeAllRobotTarget();
/**
* \brief Removes all lights
*/
void removeAllLightSource();
/**
* \brief Removes all obstacles
*/
void removeAllObstacle();
/**
* \brief Loads a simulation from a file
*/
bool open(std::string filename);
/**
* \brief Saves the current state to a file
*/
bool save(std::string filename);
}
|
#pragma once
#include <cstdlib>
namespace AbortHandler
{
struct IAborter
{
virtual void Abort() const = 0;
};
struct Aborter final : public IAborter
{
void Abort() const override
{
//std::cout << "abort" << std::endl;
//std::abort();
}
};
struct MockAborter final : public IAborter
{
void Abort() const override
{
//std::cout << "mock_abort" << std::endl;
//std::abort();
}
};
namespace Handlers
{
constexpr static const Aborter DefaultAbortHandler;
constexpr static const MockAborter DefaultMockAbortHandler;
}
namespace
{
static const IAborter* currentAbortHandler = &Handlers::DefaultAbortHandler;
}
inline static void SetAbortHandler(const IAborter& abortHandler)
{
currentAbortHandler = &abortHandler;
}
inline static void Abort(const IAborter& abortHandler = *currentAbortHandler)
{
abortHandler.Abort();
}
}
|
/*
* BlizzLikeCore Copyright (C) 2013 BlizzLikeGroup
* Integrated Files: CREDITS.md and LICENSE.md
*/
#ifndef _MAP_BUILDER_H
#define _MAP_BUILDER_H
#include <vector>
#include <set>
#include <map>
#include "TerrainBuilder.h"
#include "IntermediateValues.h"
#include "IVMapManager.h"
#include "WorldModel.h"
#include "Recast.h"
#include "DetourNavMesh.h"
using namespace std;
using namespace VMAP;
// G3D namespace typedefs conflicts with ACE typedefs
namespace MMAP
{
typedef map<uint32,set<uint32>*> TileList;
struct Tile
{
Tile() : chf(NULL), solid(NULL), cset(NULL), pmesh(NULL), dmesh(NULL) {}
~Tile()
{
rcFreeCompactHeightfield(chf);
rcFreeContourSet(cset);
rcFreeHeightField(solid);
rcFreePolyMesh(pmesh);
rcFreePolyMeshDetail(dmesh);
}
rcCompactHeightfield* chf;
rcHeightfield* solid;
rcContourSet* cset;
rcPolyMesh* pmesh;
rcPolyMeshDetail* dmesh;
};
class MapBuilder
{
public:
MapBuilder(float maxWalkableAngle = 60.f,
bool skipLiquid = false,
bool skipContinents = false,
bool skipJunkMaps = true,
bool skipBattlegrounds = false,
bool debugOutput = false,
bool bigBaseUnit = false,
const char* offMeshFilePath = NULL);
~MapBuilder();
// builds all mmap tiles for the specified map id (ignores skip settings)
void buildMap(uint32 mapID);
// builds an mmap tile for the specified map and its mesh
void buildSingleTile(uint32 mapID, uint32 tileX, uint32 tileY);
// builds list of maps, then builds all of mmap tiles (based on the skip settings)
void buildAllMaps();
private:
// detect maps and tiles
void discoverTiles();
set<uint32>* getTileList(uint32 mapID);
void buildNavMesh(uint32 mapID, dtNavMesh* &navMesh);
void buildTile(uint32 mapID, uint32 tileX, uint32 tileY, dtNavMesh* navMesh);
// move map building
void buildMoveMapTile(uint32 mapID,
uint32 tileX,
uint32 tileY,
MeshData &meshData,
float bmin[3],
float bmax[3],
dtNavMesh* navMesh);
void getTileBounds(uint32 tileX, uint32 tileY,
float* verts, int vertCount,
float* bmin, float* bmax);
void getGridBounds(uint32 mapID, uint32 &minX, uint32 &minY, uint32 &maxX, uint32 &maxY);
bool shouldSkipMap(uint32 mapID);
bool isTransportMap(uint32 mapID);
bool shouldSkipTile(uint32 mapID, uint32 tileX, uint32 tileY);
TerrainBuilder* m_terrainBuilder;
TileList m_tiles;
bool m_debugOutput;
const char* m_offMeshFilePath;
bool m_skipContinents;
bool m_skipJunkMaps;
bool m_skipBattlegrounds;
float m_maxWalkableAngle;
bool m_bigBaseUnit;
// build performance - not really used for now
rcContext* m_rcContext;
};
}
#endif
|
// Copyright (c) 2014-2017 Andrey Upadyshev <oliora@gmail.com>
//
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#pragma once
#include "kwargs.h"
#include "helpers.h"
#include <type_traits>
#include <string>
#include <sstream>
#include <boost/fusion/include/for_each.hpp>
#define PPCONSUL_KEYWORD_NAMED_(keyword, type, name_) \
KWARGS_KEYWORD(keyword, type) \
inline const char *parameter_name(KWARGS_KW_TAG(keyword)) { return name_; }
#define PPCONSUL_KEYWORD(keyword, type) PPCONSUL_KEYWORD_NAMED_(keyword, type, BOOST_PP_STRINGIZE(keyword))
namespace ppconsul { namespace parameters {
namespace detail {
template<class Keyword, class Value>
void printParameter(std::ostream&os, const Value& v, Keyword k)
{
os << parameter_name(k) << "=" << v;
}
template<class Keyword>
void printParameter(std::ostream&os, const std::string& v, Keyword k)
{
if (!v.empty())
os << parameter_name(k) << "=" << helpers::encodeUrl(v);
}
struct ParameterPrinter
{
ParameterPrinter(std::ostream& os): m_os(os) {}
template<class T>
void operator() (const T& t) const
{
auto pos = m_os.tellp();
printParameter(m_os, kwargs::get_value(t), kwargs::get_keyword(t));
if (m_os.tellp() != pos)
m_os << '&';
}
private:
std::ostream& m_os;
};
}
inline std::string makeQuery()
{
return{};
}
template<class... Params, class = kwargs::enable_if_kwargs_t<Params...>>
std::string makeQuery(const Params&... params)
{
std::ostringstream os;
const auto p = kwargs::unique_args(params...);
boost::fusion::for_each(p, detail::ParameterPrinter(os));
// Remove last '&' if exists
auto r = os.str();
if (!r.empty() && r.back() == '&')
r.resize(r.size() - 1);
return r;
}
template<class... Params, class = kwargs::enable_if_kwargs_t<Params...>>
std::string makeUrl(const std::string& addr, const std::string& path, const Params&... params)
{
auto query = makeQuery(params...);
std::string r;
r.reserve(addr.size() + path.size() + query.size() + 1); // 1 is for query prefix '?'
r += addr;
r += path;
if (!query.empty())
{
r += '?';
r += query;
}
return r;
}
}}
|
/* This file is part of GNU Radius.
Copyright (C) 2000,2001,2002,2003,2005,2007 Free Software Foundation, Inc.
Written by Sergey Poznyakoff
GNU Radius 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.
GNU Radius 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 GNU Radius; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <libguile.h>
#include <radius/radius.h>
#define RADIUS_SERVER_GUILE
#include <rewrite.h>
#include <radius/radscm.h>
SCM_DEFINE(rad_rewrite_execute_string, "rad-rewrite-execute-string", 1, 0, 0,
(SCM STRING),
"Interpret STRING as an invocation of a function in Rewrite language and\n"
"execute it.\n"
"Return value: return of the corresponding Rewrite call, translated to\n"
"the Scheme data type.\n")
#define FUNC_NAME s_rad_rewrite_execute_string
{
grad_value_t val;
SCM retval;
SCM_ASSERT(scm_is_string(STRING), STRING, SCM_ARG1, FUNC_NAME);
if (rewrite_interpret(scm_i_string_chars(STRING), NULL, &val)) {
scm_misc_error(FUNC_NAME,
"Error parsing expression: ~S",
scm_list_1(STRING));
}
retval = radscm_datum_to_scm(&val);
grad_value_free(&val);
return retval;
}
#undef FUNC_NAME
SCM_DEFINE(rad_rewrite_execute, "rad-rewrite-execute", 1, 0, 0,
(SCM ARGLIST),
"Execute a Rewrite language function.\n"
"(car ARGLIST) is interpreted as a name of the Rewrite function to execute,\n"
"and (cdr ARGLIST) as a list of arguments to be passed to it.\n"
"Return value: return of the corresponding Rewrite call, translated to\n"
"the Scheme data type.\n")
#define FUNC_NAME s_rad_rewrite_execute
{
SCM_ASSERT((SCM_IMP(ARGLIST) && ARGLIST == SCM_EOL)
|| (SCM_NIMP(ARGLIST) && SCM_CONSP(ARGLIST)),
ARGLIST, SCM_ARG2, FUNC_NAME);
return radscm_rewrite_execute(FUNC_NAME, ARGLIST);
}
#undef FUNC_NAME
void
rscm_rewrite_init()
{
#include <rscm_rewrite.x>
}
void
rscm_server_init()
{
rscm_radlog_init();
rscm_rewrite_init();
#if defined(USE_SQL)
rscm_sql_init();
#endif
}
|
/**
Copyright 2015
Debora Martin debbie1new.world@gmail.com
Gaston Martinez gaston.martinez.90@gmail.com
Bruno Merlo Schurmann bruno290@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses
*/
#ifndef CONCURRENTES_SHARED_MEMORY_FILE_H
#define CONCURRENTES_SHARED_MEMORY_FILE_H
#define CASH_REGISTER_SM "supervisor.cpp"
#define OVENS_SM "oven_set.cpp"
#endif //CONCURRENTES_SHARED_MEMORY_FILE_H
|
/**
* @file exercise4.c
* @brief Brief description.
*
* @author Raul Perula-Martinez <raules@gmail.com>
* @date 2014-11
*
* @license GPL v3
* @version 1.0.0
*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define N 20
double f(double x,double y);
double freal(double x);
int main(){
double a=0;
double b=2;
double h=0.1;
double X[N+1];
double Y[N+1];
double sol[N+1];
double error[N+1];
int i;
X[0]=a;
Y[0]=3;
sol[0]=freal(X[0]);
for(i=1;i<N+1;i++){
X[i]=X[i-1]+h;
Y[i]=Y[i-1]+f(X[i-1],Y[i-1])*h;
sol[i]=freal(X[i]);
error[i]=fabs(sol[i]-Y[i]);
}
printf("Para x=2:\n estimacion:%.8lf\n solucion real:%lf\n error:%lf\n", Y[N],sol[N],error[N]);
system("PAUSE");
}
double f(double x,double y){
return (2*x+y);
}
double freal(double x){
return (-2+5*exp(2)-2*x);
}
|
/*
Copyright (C) 2010 Karol Krizka <kkrizka@gmail.com>
URL: http://www.krizka.net/projects/libmidi/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id$
*/
#ifndef MIDIDATABUFFER_H_
#define MIDIDATABUFFER_H_
#include "types.h"
namespace MIDI
{
/*!
* Class that represents a read/write buffer of bytes. Can be navigated
* using interfaces like a C++ STD stream.
*
* Also contains functions that help to read data as if it were stored
* in a MIDI file. These include support for variable-length fields.
*
* As of right now, buffers can be expanded only to a specified maximum length.
*
* A buffer owns its data.
*/
class DataBuffer
{
public:
//! Constructor
/*!
* Creates an empty buffer, with 0 maximum length
*/
DataBuffer();
//! Copy constructor
DataBuffer(const DataBuffer& o);
/*!
* Initializes the data by copying the first "size" number of bytes from the
* data array. The data is copied explicitely.
*
* This buffer can store at most size bytes.
*
* \param data The data to copy
* \param size Number of bytes to copy from the data array
*/
DataBuffer(byte data[],unsigned int size);
/*!
* Initialize an empty data buffer that can store at most maxsize bytes.
*
* \param maxsize Maximum number of bytes that one can store in this buffer
*/
DataBuffer(unsigned int maxsize);
/*!
\return Array access to the underlying data
*/
byte* data();
/*!
* \return Number of bytes stored in this buffer
*/
unsigned int size();
/*!
* \return The maximum possible number of bytes that can be stored in this buffer
*/
unsigned int maxsize();
/*!
* Write a number of variable length into the buffer, at current pos.
*
* \param data The number to write. Can be at most 4 bytes.
*/
void writeVariableLength(dword data);
/*!
* Write a byte into the buffer, and increment the position counter/
*
* \param data byte to write
*/
void write(byte data);
/*!
* Write a whole set of bytes into the buffer. Increments position counter
* by size.
*
* \param data Array of data to write
* \param size Number of bytes from data[] to write
*/
void write(byte data[],unsigned int size);
/*!
* Write all data from another MIDI::DataBuffer to this buffer.
*
* \param data MIDI::DataBuffer to copy from
*/
void write(DataBuffer data);
/*!
* Moves the position counter somewhere else. The beginning of the buffer
* is pos=0
*
* \param pos Position to seek to
*/
void seek(int pos);
/*!
* Removes number of bytes at the current positions. All bytes after the removed
* ones are shifted down.
*
* \param numBytes Number of bytes to remove
*/
void remove(int numBytes);
private:
byte* _data;
unsigned int _size;
unsigned int _maxsize;
unsigned int _pos;
};
}
#endif // MIDIDATABUFFER_H_
|
//******************************************************************
//
// Generated by IDL to C++ Translator
//
// File name: chromatic_imap_dds.h
// Source: chromatic_imap_dds.idl
// Generated: Sun Jul 21 00:54:47 2013
// OpenSplice V6.3.0OSS
//
//******************************************************************
#ifndef _CHROMATIC_IMAP_DDS_H_
#define _CHROMATIC_IMAP_DDS_H_
#include "sacpp_mapping.h"
#include "sacpp_DDS_DCPS.h"
namespace chromatic_imap_dds
{
struct chromatic_imap_command;
struct chromatic_name_service;
const DDS::Long max_command_len = (DDS::Long) 32L;
typedef DDS::Char* command_type;
typedef DDS::String_var command_type_var;
typedef DDS::String_out command_type_out;
typedef DDS::Char* user_id;
typedef DDS::String_var user_id_var;
typedef DDS::String_out user_id_out;
struct chromatic_imap_command
{
DDS::Long session_idx;
DDS::Long locale_idx;
DDS::String_mgr moniker;
DDS::String_mgr command;
DDS::String_mgr payload;
};
typedef DDS_DCPSStruct_var < chromatic_imap_command> chromatic_imap_command_var;
typedef DDS_DCPSStruct_out < chromatic_imap_command> chromatic_imap_command_out;
struct chromatic_name_service
{
DDS::Long session_idx;
DDS::String_mgr user_name;
};
typedef DDS_DCPSStruct_var < chromatic_name_service> chromatic_name_service_var;
typedef DDS_DCPSStruct_out < chromatic_name_service> chromatic_name_service_out;
}
#endif
|
/*
This file is part of Photoflare.
Photoflare 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.
Photoflare 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 Photoflare. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef TEXTTOOL_H
#define TEXTTOOL_H
#include "Tool.h"
class TextToolPrivate;
class TextTool : public Tool
{
Q_OBJECT
public:
TextTool(QObject *parent = nullptr);
~TextTool() override;
void setText(const QString &text, const QFont &font, const QColor&, const bool &antialiasEnabled, const QString &position);
void onMousePress(const QPoint &pos, Qt::MouseButton button) override;
void onMouseMove(const QPoint &pos) override;
void onMouseRelease(const QPoint &pos) override;
void disconnect() override;
signals:
void editText(const QString&, const QFont&, const QColor&);
void editTextFinished();
private:
void previewText();
void drawText();
TextToolPrivate *d;
};
#endif // TEXTTOOL_H
|
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef CAMERA_H
#define CAMERA_H
#include <QCamera>
#include <QCameraImageCapture>
#include <QMediaRecorder>
#include <QMainWindow>
QT_BEGIN_NAMESPACE
namespace Ui { class Camera; }
QT_END_NAMESPACE
class Camera : public QMainWindow
{
Q_OBJECT
public:
Camera(QWidget *parent = 0);
~Camera();
private slots:
void setCamera(const QCameraInfo &cameraInfo);
void startCamera();
void stopCamera();
void record();
void pause();
void stop();
void setMuted(bool);
void toggleLock();
void takeImage();
void displayCaptureError(int, QCameraImageCapture::Error, const QString &errorString);
void configureCaptureSettings();
void configureVideoSettings();
void configureImageSettings();
void displayRecorderError();
void displayCameraError();
void updateCameraDevice(QAction *action);
void updateCameraState(QCamera::State);
void updateCaptureMode();
void updateRecorderState(QMediaRecorder::State state);
void setExposureCompensation(int index);
void updateRecordTime();
void processCapturedImage(int requestId, const QImage &img);
void updateLockStatus(QCamera::LockStatus, QCamera::LockChangeReason);
void displayViewfinder();
void displayCapturedImage();
void readyForCapture(bool ready);
void imageSaved(int id, const QString &fileName);
protected:
void keyPressEvent(QKeyEvent *event) override;
void keyReleaseEvent(QKeyEvent *event) override;
void closeEvent(QCloseEvent *event) override;
private:
Ui::Camera *ui;
QCamera *camera;
QCameraImageCapture *imageCapture;
QMediaRecorder* mediaRecorder;
QImageEncoderSettings imageSettings;
QAudioEncoderSettings audioSettings;
QVideoEncoderSettings videoSettings;
QString videoContainerFormat;
bool isCapturingImage;
bool applicationExiting;
};
#endif
|
/*
This file is part of Darling.
Copyright (C) 2021 Lubos Dolezel
Darling is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Darling is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Darling. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Foundation/Foundation.h>
@interface AFClientInfo : NSObject
@end
|
#ifndef BLINE_H_
#define BLINE_H_
#include "BoundingVolume.h"
/* This class is only here to allow generality in grid trace methods.
* It represents a bounding volume that is a line (ie: has no volume)
*/
class BLine: public BoundingVolume {
BVolumeType getType () const {
return TYPE_LINE;
}
// Returns width/height of bounding box
float getWidth () const {
return 0;
}
float getHeight () const {
return 0;
}
};
#endif /* BLINE_H_ */
|
/*
* SelectedWordLM.cpp
*
* Copyright 2012 by Joerg Tiedemann. All rights reserved.
*
* This file is part of Docent, a document-level decoder for phrase-based
* statistical machine translation.
*
* Docent 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.
*
* Docent 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
* Docent. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef docent_SelectedWordLM_h
#define docent_SelectedWordLM_h
#include "FeatureFunction.h"
struct SelectedWordLMFactory {
static FeatureFunction *createNgramModel(const Parameters &);
};
#endif
|
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "NGAP-IEs"
* found in "../support/ngap-r16.1.0/38413-g10.asn"
* `asn1c -pdu=all -fcompound-names -findirect-choice -fno-include-deps`
*/
#ifndef _NGAP_TargetID_H_
#define _NGAP_TargetID_H_
#include <asn_application.h>
/* Including external dependencies */
#include <constr_CHOICE.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Dependencies */
typedef enum NGAP_TargetID_PR {
NGAP_TargetID_PR_NOTHING, /* No components present */
NGAP_TargetID_PR_targetRANNodeID,
NGAP_TargetID_PR_targeteNB_ID,
NGAP_TargetID_PR_choice_Extensions
} NGAP_TargetID_PR;
/* Forward declarations */
struct NGAP_TargetRANNodeID;
struct NGAP_TargeteNB_ID;
struct NGAP_ProtocolIE_SingleContainer;
/* NGAP_TargetID */
typedef struct NGAP_TargetID {
NGAP_TargetID_PR present;
union NGAP_TargetID_u {
struct NGAP_TargetRANNodeID *targetRANNodeID;
struct NGAP_TargeteNB_ID *targeteNB_ID;
struct NGAP_ProtocolIE_SingleContainer *choice_Extensions;
} choice;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} NGAP_TargetID_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_NGAP_TargetID;
#ifdef __cplusplus
}
#endif
#endif /* _NGAP_TargetID_H_ */
#include <asn_internal.h>
|
/* Test of xvasprintf() and xasprintf() functions.
Copyright (C) 2007-2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
#include <config.h>
#include "xvasprintf.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "progname.h"
#define ASSERT(expr) \
do \
{ \
if (!(expr)) \
{ \
fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
fflush (stderr); \
abort (); \
} \
} \
while (0)
static char *
my_xasprintf (const char *format, ...)
{
va_list args;
char *ret;
va_start (args, format);
ret = xvasprintf (format, args);
va_end (args);
return ret;
}
static void
test_xvasprintf ()
{
int repeat;
for (repeat = 0; repeat <= 8; repeat++)
{
char *result = my_xasprintf ("%d", 12345);
ASSERT (result != NULL);
ASSERT (strcmp (result, "12345") == 0);
free (result);
}
}
static void
test_xasprintf ()
{
int repeat;
for (repeat = 0; repeat <= 8; repeat++)
{
char *result = xasprintf ("%d", 12345);
ASSERT (result != NULL);
ASSERT (strcmp (result, "12345") == 0);
free (result);
}
}
int
main (int argc, char *argv[])
{
set_program_name (argv[0]);
test_xvasprintf ();
test_xasprintf ();
return 0;
}
|
#include "circular_buffer.h"
// check if a circular buffer is full.
// Ok to call from pushing process
// without locking but calling from the
// popping process requires locking
int BuffIsFull(volatile CircularBuffer *CB)
{
volatile cb_data_t *tempTail = CB->tail; // grab a snapshot of the tail so that
// this function is atomic when called
// from the pushing process.
return (
(CB->head == tempTail-1)
||
((CB->head == CB->data + CB->size - 1) && (tempTail == CB->data))
);
}
int BuffIsEmpty(volatile CircularBuffer *CB)
{
return (CB->head == CB->tail);
}
// note: This function is non-atomic.
int BuffLevel(volatile CircularBuffer *CB)
{
volatile cb_data_t *temphead;
if (CB->head < CB->tail) // the data wraps around zero.
{
temphead = CB->head + CB->size;
}
else
{
temphead = CB->head;
}
return temphead - CB->tail;
}
// note: This function calls BuffLevel,
// which is non-atomic.
int BuffAvail(volatile CircularBuffer *CB)
{
// explanation of the '-1' in the calculation below:
// HEAD always points to an empty slot in the buffer,
// and that empty slot can only be written to if the
// next slot is also empty (giving a valid position for
// HEAD to move to). Therefore, there is always 1 less
// position available in the buffer than the number of slots.
return CB->size - BuffLevel(CB) - 1;
}
int BuffPop(volatile CircularBuffer *CB, cb_data_t *data)
{
if (BuffIsEmpty(CB)) return 1; // return positive value on fail.
*data = *CB->tail;
CB->tail++;
if (CB->tail > CB->data + CB->size - 1)
{
CB->tail = CB->data;
}
return 0;
}
int BuffPeek(volatile CircularBuffer *CB, cb_data_t *data)
{
if (BuffIsEmpty(CB)) return 1; // return positive value on fail.
*data = *CB->tail;
return 0;
}
int BuffPush(volatile CircularBuffer *CB, cb_data_t *data)
{
if (BuffIsFull(CB)) return 1; // return positive value on fail.
*CB->head = *data;
CB->head++;
if (CB->head > CB->data + CB->size - 1)
{
CB->head = CB->data;
}
return 0;
}
void BuffClear(volatile CircularBuffer *CB)
{
CB->head = CB->tail = CB->data;
}
|
/*
* Copyright (C) 2013 Nivis LLC.
* Email: opensource@nivis.com
* Website: http://www.nivis.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* Redistribution and use in source and binary forms must retain this
* copyright notice.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "C966_DeleteSuperframe.h"
uint8_t Compose_C966_DeleteSuperframe_Req(C966_DeleteSuperframe_Req* request, ComposerContext* context,
BinaryStream* toStream)
{
context->cmdId = CMDID_C966_DeleteSuperframe;
STREAM_WRITE_UINT8(toStream, request->m_ucSuperframeID);
return RCS_N00_Success;
}
/**
* @Debinarize
*/
uint8_t Parse_C966_DeleteSuperframe_Req(C966_DeleteSuperframe_Req* request, ParserContext* context,
BinaryStream* fromStream)
{
STREAM_READ_UINT8(fromStream, &request->m_ucSuperframeID);
return RCS_N00_Success;
}
/**
*
*/
uint8_t Compose_C966_DeleteSuperframe_Resp(C966_DeleteSuperframe_Resp* response, ComposerContext* context,
BinaryStream* toStream)
{
context->cmdId = CMDID_C966_DeleteSuperframe;
STREAM_WRITE_UINT8(toStream, response->m_ucSuperframeID);
STREAM_WRITE_UINT8(toStream, response->m_ucRemainingSuperframeEntriesNo);
return RCS_N00_Success;
}
/**
*
*/
uint8_t Parse_C966_DeleteSuperframe_Resp(C966_DeleteSuperframe_Resp* response, ParserContext* context,
BinaryStream* fromStream)
{
STREAM_READ_UINT8(fromStream, &response->m_ucSuperframeID);
STREAM_READ_UINT8(fromStream, &response->m_ucRemainingSuperframeEntriesNo);
return RCS_N00_Success;
}
|
/* diverses.h */
#ifndef __DIVERSES_H
#define __DIVERSES_H
#include "grid_bsl.h"
#include <vector>
/*
class I_Vec : public C_Vec2
{
public:
I_Vec(double x = 0.0, double y = 0.0);
I_Vec(const C_Vec2& V);
~I_Vec();
int X(void) const;
int Y(void) const;
double X_binary(void) const;
double Y_binary(void) const;
void adjust(void);
int operator ==(const I_Vec& V);
int operator ==(const I_Vec& V) const;
};
*/
class I_Vec
{
public:
// I_Vec(double x = 0.0, double y = 0.0);
I_Vec(int xx = 0, int yy = 0) : x(xx), y(yy) {};
I_Vec(const C_Vec2& V) { x = (int)V.X(); y = (int)V.Y(); };
~I_Vec() {};
inline int X(void) const {return x; };
inline int Y(void) const {return y; };
// void adjust(void);
int operator ==(const I_Vec& V) {return x == V.X() && y == V.Y(); };
int operator ==(const I_Vec& V) const {return x == V.X() && y == V.Y(); };
inline I_Vec operator+(const I_Vec& v) const {return I_Vec(x+v.X(), y+v.Y());};
inline I_Vec operator-(const I_Vec& v) const {return I_Vec(x-v.X(), y-v.Y());};
inline I_Vec& operator = (const I_Vec& v) {x = v.X(); y = v.Y(); return *this;};
inline I_Vec& operator += (const I_Vec& v) { x += v.X(); y += v.Y(); return *this;};
inline I_Vec& operator -= (const I_Vec& v) { x -= v.X(); y -= v.Y(); return *this;};
inline double Length(void) { return double(sqrt((double)(x*x+y*y))); };
protected:
int x, y;
};
/*class IVecWerte
{
public:
IVecWerte( GridWerte& G) : Grid(G) {};
~IVecWerte() {};
inline double& operator [] ( I_Vec& I)
{
return Grid(int(I.X()),int(I.Y()));
}
const GridWerte& operator () () const
{
return Grid;
}
protected:
const GridWerte& Grid;
};
*/
/*
class IVecWerteInt
{
public:
IVecWerteInt(GridWerteInt& G) : Grid(G) {};
~IVecWerteInt() {};
inline int& operator [] (const I_Vec& I) const
{
return Grid.Z[I.Y()][I.X()];
}
GridWerteInt& operator () () const
{
return Grid;
}
protected:
GridWerteInt& Grid;
};
*/
bool Rand(int x, int y, const GridWerte& W, int abstand = 0);
//int Rand(const I_Vec& I, const IVecWerte& W, int abstand = 0);
//int Rand(const I_Vec& I, const GridWerte& W, int abstand = 0);
//int innerhalb(const I_Vec& I, const GridWerte& W);
//int innerhalb(const I_Vec& I, const IVecWerte& W);
int innerhalb(int x, int y, const GridWerte& W);
//int isRandPunkt(const I_Vec iv, const GridWerte& G);
void normieren(C_Vec2& G);
//double WinkelDiff(double x, double y);
double max3(double x, double y, double z);
double min3(double x, double y, double z);
void
LinRand( GridWerte& G, GridWerte& Erg);
/* Speicher: Erg.getMem */
void DGMGlatt(const GridWerte& G, GridWerte& Erg);
/* Speicher: Erg.getMem */
void copyGrid(GridWerte& Dest, GridWerte& Source, bool newmem = true);
void calcExpoAbweichung4erFeld(GridWerte& Erg, GridWerte& Hoehe);
/* Speicher: Erg.getMem */
void calcExpoAbweichung(GridWerte& Erg, GridWerte& Expo);
/* Speicher: Erg.getMem */
#endif
/* End of file */
|
/**********************************************************************************************************************
(c) Copyright 2011, Bret Ambrose (mailto:bretambrose@gmail.com).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
**********************************************************************************************************************/
#pragma once
#include "IPPlatform/StructuredExceptionTypes.h"
namespace IP
{
namespace Debug
{
// A static class that does platform-agnostic exception handling. Platform specific logic is done in the
// PlatformExceptionHandler component and then a generic information structure is passed here for processing.
class CStructuredExceptionHandler
{
public:
// We include both a standard initialize and one for unit testing that lets you use a custom handler
static void Initialize( void );
static void Initialize( const DExceptionHandler &handler );
static void Shutdown( void );
private:
static void On_Structured_Exception_Callback( CStructuredExceptionInfo &shared_exception_info );
static void Write_Exception_File( const CStructuredExceptionInfo &shared_exception_info );
static void Archive_Logs( void );
static std::wstring Get_Log_File_Prefix( void );
};
} // namespace Debug
} // namespace IP |
/**
* @file lv_gpu_stm32_dma2d.h
*
*/
#ifndef LV_GPU_STM32_DMA2D_H
#define LV_GPU_STM32_DMA2D_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../misc/lv_area.h"
#include "../misc/lv_color.h"
#include "../hal/lv_hal_disp.h"
/*********************
* DEFINES
*********************/
#define LV_DMA2D_ARGB8888 0
#define LV_DMA2D_RGB888 1
#define LV_DMA2D_RGB565 2
#define LV_DMA2D_ARGB1555 3
#define LV_DMA2D_ARGB4444 4
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Turn on the peripheral and set output color mode, this only needs to be done once
*/
void lv_gpu_stm32_dma2d_init(void);
/**
* Fill an area in the buffer with a color
* @param buf a buffer which should be filled
* @param buf_w width of the buffer in pixels
* @param color fill color
* @param fill_w width to fill in pixels (<= buf_w)
* @param fill_h height to fill in pixels
* @note `buf_w - fill_w` is offset to the next line after fill
*/
void lv_gpu_stm32_dma2d_fill(lv_color_t * buf, lv_coord_t buf_w, lv_color_t color, lv_coord_t fill_w,
lv_coord_t fill_h);
/**
* Fill an area in the buffer with a color but take into account a mask which describes the opacity of each pixel
* @param buf a buffer which should be filled using a mask
* @param buf_w width of the buffer in pixels
* @param color fill color
* @param mask 0..255 values describing the opacity of the corresponding pixel. It's width is `fill_w`
* @param opa overall opacity. 255 in `mask` should mean this opacity.
* @param fill_w width to fill in pixels (<= buf_w)
* @param fill_h height to fill in pixels
* @note `buf_w - fill_w` is offset to the next line after fill
*/
void lv_gpu_stm32_dma2d_fill_mask(lv_color_t * buf, lv_coord_t buf_w, lv_color_t color, const lv_opa_t * mask,
lv_opa_t opa, lv_coord_t fill_w, lv_coord_t fill_h);
/**
* Copy a map (typically RGB image) to a buffer
* @param buf a buffer where map should be copied
* @param buf_w width of the buffer in pixels
* @param map an "image" to copy
* @param map_w width of the map in pixels
* @param copy_w width of the area to copy in pixels (<= buf_w)
* @param copy_h height of the area to copy in pixels
* @note `map_w - fill_w` is offset to the next line after copy
*/
void lv_gpu_stm32_dma2d_copy(lv_color_t * buf, lv_coord_t buf_w, const lv_color_t * map, lv_coord_t map_w,
lv_coord_t copy_w, lv_coord_t copy_h);
/**
* Blend a map (e.g. ARGB image or RGB image with opacity) to a buffer
* @param buf a buffer where `map` should be copied
* @param buf_w width of the buffer in pixels
* @param map an "image" to copy
* @param opa opacity of `map`
* @param map_w width of the map in pixels
* @param copy_w width of the area to copy in pixels (<= buf_w)
* @param copy_h height of the area to copy in pixels
* @note `map_w - fill_w` is offset to the next line after copy
*/
void lv_gpu_stm32_dma2d_blend(lv_color_t * buf, lv_coord_t buf_w, const lv_color_t * map, lv_opa_t opa,
lv_coord_t map_w, lv_coord_t copy_w, lv_coord_t copy_h);
/**
* Can be used as `gpu_wait_cb` in display driver to
* let the MCU run while the GPU is working
*/
void lv_gpu_stm32_dma2d_wait_cb(lv_disp_drv_t * drv);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_GPU_STM32_DMA2D_H*/
|
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef RASTERWINDOW_H
#define RASTERWINDOW_H
//! [1]
#include <QtGui>
class RasterWindow : public QWindow
{
Q_OBJECT
public:
explicit RasterWindow(QWindow *parent = 0);
virtual void render(QPainter *painter);
public slots:
void renderLater();
void renderNow();
protected:
bool event(QEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
void exposeEvent(QExposeEvent *event) override;
private:
QBackingStore *m_backingStore;
};
//! [1]
#endif // RASTERWINDOW_H
|
#include "nat64/mod/stateful/poolnum.h"
#include <linux/slab.h>
#include "nat64/mod/common/types.h"
#include "nat64/mod/common/random.h"
/**
* @file
* A pool of 16-bit numbers, which are assumed to be going to be used as ports.
*
* The pool tries to be as efficient as possible during packet processing, so it assumes it is used
* in very controlled environments, which sacrifices robustness. Do *not* return numbers that were
* originally not part of the pool; validations against this are very ineffective.
*
* @author Alberto Leiva
*/
/**
* Returns a two-byte random number between min and max, inclusive.
*/
static int random_by_range(u16 min, u16 max)
{
u32 random_num = get_random_u32();
return min + random_num % (max - min + 1);
}
/**
* Initializes "pool".
* "pool" will contain every number in "step" increments between "min" and "max" (inclusive) in a
* random order.
* eg. poolnum_init(pool, 1, 10, 3) will fill pool with 1, 4, 7 and 10.
*/
int poolnum_init(struct poolnum *pool, u16 min, u16 max, u16 step)
{
u32 i, j;
if (min > max) {
u16 temp = min;
min = max;
max = temp;
}
pool->count = (max - min) / step + 1;
pool->array = kmalloc(pool->count * sizeof(u16), GFP_ATOMIC);
if (!pool->array)
return -ENOMEM;
/*
* Initialize and shuffle the numbers (http://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
*
* We're not really sure if we should do this. Randomizing the order upon initialization likely
* doesn't serve any purpose; it makes the source ports Jool uses unpredictable to some extent,
* but that probably doesn't add any security.
*/
pool->array[0] = min;
for (i = 1; i < pool->count; i++) {
j = random_by_range(0, i);
pool->array[i] = pool->array[j];
pool->array[j] = min + step * i;
}
pool->next = 0;
pool->returned = 0;
pool->next_is_ahead = false;
return 0;
}
/**
* Deallocates "pool"'s contents. Does not free "pool".
*/
void poolnum_destroy(struct poolnum *pool)
{
if (pool)
kfree(pool->array);
}
/**
* Returns "index"'s successor. Wraps "index" around "max" (i. e. (max - 1)'s successor is zero).
*/
static u32 get_next_index(u32 index, u32 max)
{
index++;
if (index >= max)
index = 0;
return index;
}
/**
* Borrows and sets "result" as any number from "pool". Returns error status.
*/
int poolnum_get_any(struct poolnum *pool, u16 *result)
{
if (poolnum_is_empty(pool))
return -ESRCH; /* We ran out of values. */
*result = pool->array[pool->next];
pool->next = get_next_index(pool->next, pool->count);
pool->next_is_ahead = true;
return 0;
}
/**
* Borrows "value" from "pool".
* This function is slow; avoid it during packet processing.
*/
int poolnum_get(struct poolnum *pool, u16 value)
{
u32 current_index;
if (poolnum_is_empty(pool))
return -ESRCH;
current_index = pool->next;
do {
if (pool->array[current_index] == value) {
pool->array[current_index] = pool->array[pool->next];
pool->next = get_next_index(pool->next, pool->count);
pool->next_is_ahead = true;
return 0;
}
current_index = get_next_index(current_index, pool->count);
} while (current_index != pool->returned);
return -ESRCH;
}
/**
* Returns "value" to "pool".
*/
int poolnum_return(struct poolnum *pool, u16 value)
{
if (WARN_IF_REAL(poolnum_is_full(pool), "Something's trying to return values that were "
"originally not part of the pool."))
return -EINVAL;
pool->array[pool->returned] = value;
pool->returned = get_next_index(pool->returned, pool->count);
if (pool->next == pool->returned)
pool->next_is_ahead = false;
return 0;
}
/**
* Returns whether the pool has all of its values (ie. nobody has requested anything, or everyone
* has returned everything).
*/
bool poolnum_is_full(struct poolnum *pool)
{
return (!pool->next_is_ahead) && (pool->returned == pool->next);
}
/**
* Returns whether the pool has no values (ie. everyting has been borrowed).
*/
bool poolnum_is_empty(struct poolnum *pool)
{
return pool->next_is_ahead && (pool->returned == pool->next);
}
|
/******************************************************************//**
* \file Rctl/src/rmapctl.c
* \brief Implementation of the interfaces to R, and the updateR helper function
*
* <i>Copyright (c) 2010-2013</i> GBIC - Danny Arends<br>
* Last modified Feb, 2013<br>
* First written 2011<br>
**********************************************************************/
#include "rmapctl.h"
#ifdef USING_R
void updateR(bool flush){
R_CheckUserInterrupt();
if(flush) R_FlushConsole();
}
void R_mapctl(int* nind, int* nmar, int* nphe, int* geno, double* pheno, int* p,
int *nperms, int* permt, int* nthr, double* dcor, double* perms, double* res, int* adj, int* verb){
GetRNGstate();
int nindividuals = (int)(*nind);
int nmarkers = (int)(*nmar);
int nphenotypes = (int)(*nphe);
int phenotype = (int)(*p);
int npermutations = (int)(*nperms);
int permtype = (int)(*permt);
int nthreads = (int)(*nthr);
int adjust = (int)(*adj);
int verbose = (int)(*verb);
if(verbose) info("R_mapctl, verbose=%d", verbose);
Phenotypes phenotypes;
Genotypes genotypes;
int i,ph,perm;
double** dcors;
double** ctls;
phenotypes.data = asdmatrix(nphenotypes, nindividuals, pheno);
phenotypes.nphenotypes = nphenotypes;
phenotypes.nindividuals = nindividuals;
genotypes.data = asimatrix(nmarkers, nindividuals, geno);
genotypes.nmarkers = nmarkers;
genotypes.nindividuals = nindividuals;
clvector* genoenc = getGenotypes(genotypes, false);
if(verbose) info("Phenotype %d: Mapping", (phenotype+1));
updateR(1);
dcors = ctleffects(phenotypes, genotypes, phenotype, genoenc, nthreads, verbose);
for(i = 0; i < (nphenotypes*nmarkers); i++){ // Send scores to R
int m = i % nmarkers; int p = i / nmarkers;
dcor[i] = dcors[m][p];
}
if(permtype == 1){
if(verbose) info(", Full permutation", "");
updateR(1);
double* permutations = permute(phenotypes, genotypes, phenotype, genoenc,
npermutations, nthreads, false);
for(i=0; i < npermutations; i++){ // Send permutations to R
perms[i] = permutations[i];
}
if(verbose) info(", toLOD\n", "");
updateR(1);
ctls = toLOD(dcors, permutations, genotypes.nmarkers, phenotypes.nphenotypes, npermutations);
free(permutations);
}else if(permtype == 2){
if(verbose) info(", Pairwise permutation", "");
updateR(1);
double** permutations = permuteRW(phenotypes, genotypes, phenotype, genoenc,
npermutations, nthreads, false);
for(ph=0; ph < (nphenotypes); ph++){ // Send permutations to R
for(perm=0; perm < (npermutations); perm++){
perms[(ph*npermutations)+perm] = permutations[ph][perm];
}
}
if(verbose) info(", toLOD\n", "");
ctls = toLODRW(dcors, permutations, genotypes.nmarkers, phenotypes.nphenotypes, npermutations);
freematrix((void**)permutations, nphenotypes);
}else{
if(verbose) info(", toLOD\n", "");
updateR(1);
ctls = toLODexact(dcors, genoenc, genotypes.nmarkers, phenotypes.nphenotypes, adjust);
}
for(i=0; i < (nphenotypes*nmarkers); i++){
int m = i % nmarkers;
int p = i / nmarkers;
res[i] = ctls[m][p];
}
for(i = 0; i < nmarkers; i++){ free(genoenc[i].data); }
PutRNGstate();
free(genoenc);
// The indices are allocated by C
free(genotypes.data);
free(phenotypes.data);
freematrix((void**)dcors, genotypes.nmarkers);
freematrix((void**)ctls, genotypes.nmarkers);
return;
}
#endif //USING_R
|
/* Copyright (C) 2018 Magnus Lång and Tuan Phong Ngo
* This benchmark is part of SWSC */
#include <assert.h>
#include <stdint.h>
#include <stdatomic.h>
#include <pthread.h>
atomic_int vars[5];
atomic_int atom_0_r1_1;
atomic_int atom_1_r1_1;
void *t0(void *arg){
label_1:;
int v2_r1 = atomic_load_explicit(&vars[0], memory_order_seq_cst);
int v3_r3 = v2_r1 ^ v2_r1;
int v4_r3 = v3_r3 + 1;
atomic_store_explicit(&vars[1], v4_r3, memory_order_seq_cst);
int v21 = (v2_r1 == 1);
atomic_store_explicit(&atom_0_r1_1, v21, memory_order_seq_cst);
return NULL;
}
void *t1(void *arg){
label_2:;
int v6_r1 = atomic_load_explicit(&vars[1], memory_order_seq_cst);
int v7_r3 = v6_r1 ^ v6_r1;
int v10_r4 = atomic_load_explicit(&vars[2+v7_r3], memory_order_seq_cst);
int v12_r6 = atomic_load_explicit(&vars[2], memory_order_seq_cst);
int v13_r7 = v12_r6 ^ v12_r6;
int v14_r7 = v13_r7 + 1;
atomic_store_explicit(&vars[3], v14_r7, memory_order_seq_cst);
int v16_r9 = atomic_load_explicit(&vars[3], memory_order_seq_cst);
int v17_cmpeq = (v16_r9 == v16_r9);
if (v17_cmpeq) goto lbl_LC00; else goto lbl_LC00;
lbl_LC00:;
atomic_store_explicit(&vars[4], 1, memory_order_seq_cst);
atomic_store_explicit(&vars[0], 1, memory_order_seq_cst);
int v22 = (v6_r1 == 1);
atomic_store_explicit(&atom_1_r1_1, v22, memory_order_seq_cst);
return NULL;
}
int main(int argc, char *argv[]){
pthread_t thr0;
pthread_t thr1;
atomic_init(&vars[2], 0);
atomic_init(&vars[3], 0);
atomic_init(&vars[1], 0);
atomic_init(&vars[0], 0);
atomic_init(&vars[4], 0);
atomic_init(&atom_0_r1_1, 0);
atomic_init(&atom_1_r1_1, 0);
pthread_create(&thr0, NULL, t0, NULL);
pthread_create(&thr1, NULL, t1, NULL);
pthread_join(thr0, NULL);
pthread_join(thr1, NULL);
int v18 = atomic_load_explicit(&atom_0_r1_1, memory_order_seq_cst);
int v19 = atomic_load_explicit(&atom_1_r1_1, memory_order_seq_cst);
int v20_conj = v18 & v19;
if (v20_conj == 1) assert(0);
return 0;
}
|
////////////////////////////////////////////////////////////////////////////
// Atol file manager project <http://atol.sf.net>
//
// This code is licensed under BSD license.See "license.txt" for more details.
//
// File: TOFIX
////////////////////////////////////////////////////////////////////////////
#ifndef PROXYSOCKS_H_
#define PROXYSOCKS_H_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "ProxyLayer.h"
#include "String.h"
//TOFIX Socks5 UDP support missing
//TOFIX Bind option (reuse authentication code)
//TOFIX Identd support!
//TOFIX Accept code!!!
//TOFIX error handling
//interface for bind (return listening socket data)
//socks versions (types) supported
#define SOCKS_V5 1
#define SOCKS_V4A 2
#define SOCKS_V4 3
//socks operation codes
#define SOCKS_OP_CONNECT 1 //all SOCKS versions
#define SOCKS_OP_BIND 2 //all SOCKS versions
#define SOCKS_OP_UDP_ASSOC 3 //SOCKS v5 only
#define SOCKS5_AUTH_NONE 0
#define SOCKS5_AUTH_PASSWORD 2
#define SOCKS5_ADDR_IP4 1
#define SOCKS5_ADDR_NAME 3
#define SOCKS5_ADDR_IP6 4
class CProxySocks : public CProxyLayer
{
public:
CProxySocks();
virtual ~CProxySocks();
// CProxyLayer interface
virtual SOCKET Connect(const char *szHost = NULL, unsigned short nPort = 21);
virtual bool Login(SOCKET hSock);
virtual SOCKET Listen(String &strIP, unsigned short &uPort);
virtual bool Accept(SOCKET hSock, String &strIP, unsigned short &uPort);
//TOFIX Socks should work witout PASV, but all the proxies I tested did not suport that
virtual bool ForcePassive(){ return true; };
virtual int GetProxyType(){ return PROXY_SOCKS; }
//
int GetProxyVer() { return m_nSocksVer; }
void SetProxyVer(int version){ m_nSocksVer = version; };
static bool ResolveToIP(const char *szHost, unsigned long &uIP);
protected:
bool Authenticate(SOCKET hSock);
bool Authenticate4(SOCKET hSock);
bool Authenticate5(SOCKET hSock);
bool Op_Connect(SOCKET hSock, const char *szHost, int nPort);
bool Op_Bind(SOCKET hSock, String &strIP, unsigned short &uPort);
bool Op_Accept(SOCKET hSock, String &strIP, unsigned short &uPort);
bool Op_Connect4(SOCKET hSock, const char *szHost, int nPort);
bool Op_Connect5(SOCKET hSock, const char *szHost, int nPort);
bool Op_Bind4(SOCKET hSock, String &strIP, unsigned short &uPort);
bool Op_Bind5(SOCKET hSock, String &strIP, unsigned short &uPort);
bool ProxyReply(SOCKET hSock);
void ReportSocksError(unsigned char nCode);
void ExtractAddress(String &strIP, unsigned short &uPort);
protected:
int m_nSocksVer; //socks protocol version (see defines above)
char m_szBuffer[256];
int m_nBufferPos;
char m_szOutBuffer[256];
};
#endif // PROXYSOCKS_H_
|
#ifndef QUACRC32_H
#define QUACRC32_H
#include "quachecksum32.h"
///CRC32 checksum
/** \class QuaCrc32 quacrc32.h <quazip/quacrc32.h>
* This class wrappers the crc32 function with the QuaChecksum32 interface.
* See QuaChecksum32 for more info.
*/
class QUAZIP_EXPORT QuaCrc32 : public QuaChecksum32 {
public:
QuaCrc32();
quint32 calculate(const QByteArray &data);
void reset();
void update(const QByteArray &buf);
quint32 value();
private:
quint32 checksum;
};
#endif //QUACRC32_H
|
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2021 Cppcheck team.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
#ifndef checkexceptionsafetyH
#define checkexceptionsafetyH
//---------------------------------------------------------------------------
#include "check.h"
#include "config.h"
#include "errortypes.h"
#include "token.h"
#include "tokenize.h"
#include <list>
#include <string>
class Settings;
class ErrorLogger;
// CWE ID used:
static const struct CWE CWE398(398U); // Indicator of Poor Code Quality
static const struct CWE CWE703(703U); // Improper Check or Handling of Exceptional Conditions
static const struct CWE CWE480(480U); // Use of Incorrect Operator
/// @addtogroup Checks
/// @{
/**
* @brief %Check exception safety (exceptions shouldn't cause leaks nor corrupt data)
*
* The problem with these checks is that Cppcheck can't determine what the valid
* values are for variables. But in some cases (dead pointers) it can be determined
* that certain variable values are corrupt.
*/
class CPPCHECKLIB CheckExceptionSafety : public Check {
public:
/** This constructor is used when registering the CheckClass */
CheckExceptionSafety() : Check(myName()) {}
/** This constructor is used when running checks. */
CheckExceptionSafety(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) {}
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
if (tokenizer->isC())
return;
CheckExceptionSafety checkExceptionSafety(tokenizer, settings, errorLogger);
checkExceptionSafety.destructors();
checkExceptionSafety.deallocThrow();
checkExceptionSafety.checkRethrowCopy();
checkExceptionSafety.checkCatchExceptionByValue();
checkExceptionSafety.nothrowThrows();
checkExceptionSafety.unhandledExceptionSpecification();
checkExceptionSafety.rethrowNoCurrentException();
}
/** Don't throw exceptions in destructors */
void destructors();
/** deallocating memory and then throw (dead pointer) */
void deallocThrow();
/** Don't rethrow a copy of the caught exception; use a bare throw instead */
void checkRethrowCopy();
/** @brief %Check for exceptions that are caught by value instead of by reference */
void checkCatchExceptionByValue();
/** @brief %Check for functions that throw that shouldn't */
void nothrowThrows();
/** @brief %Check for unhandled exception specification */
void unhandledExceptionSpecification();
/** @brief %Check for rethrow not from catch scope */
void rethrowNoCurrentException();
private:
/** Don't throw exceptions in destructors */
void destructorsError(const Token * const tok, const std::string &className);
void deallocThrowError(const Token * const tok, const std::string &varname);
void rethrowCopyError(const Token * const tok, const std::string &varname);
void catchExceptionByValueError(const Token *tok);
void noexceptThrowError(const Token * const tok);
/** Missing exception specification */
void unhandledExceptionSpecificationError(const Token * const tok1, const Token * const tok2, const std::string & funcname);
/** Rethrow without currently handled exception */
void rethrowNoCurrentExceptionError(const Token *tok);
/** Generate all possible errors (for --errorlist) */
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckExceptionSafety c(nullptr, settings, errorLogger);
c.destructorsError(nullptr, "Class");
c.deallocThrowError(nullptr, "p");
c.rethrowCopyError(nullptr, "varname");
c.catchExceptionByValueError(nullptr);
c.noexceptThrowError(nullptr);
c.unhandledExceptionSpecificationError(nullptr, nullptr, "funcname");
c.rethrowNoCurrentExceptionError(nullptr);
}
/** Short description of class (for --doc) */
static std::string myName() {
return "Exception Safety";
}
/** wiki formatted description of the class (for --doc) */
std::string classInfo() const OVERRIDE {
return "Checking exception safety\n"
"- Throwing exceptions in destructors\n"
"- Throwing exception during invalid state\n"
"- Throwing a copy of a caught exception instead of rethrowing the original exception\n"
"- Exception caught by value instead of by reference\n"
"- Throwing exception in noexcept, nothrow(), __attribute__((nothrow)) or __declspec(nothrow) function\n"
"- Unhandled exception specification when calling function foo()\n"
"- Rethrow without currently handled exception\n";
}
};
/// @}
//---------------------------------------------------------------------------
#endif // checkexceptionsafetyH
|
/* Multiple Scheme Programming Language : Intermediate Code Generator
* Built-in Procedures
Copyright(C) 2013-2014 Cheryl Natsu
This file is part of multiple - Multiple Paradigm Language Interpreter
multiple 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.
multiple 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 _MLS_ICG_BUILT_IN_PROC_H_
#define _MLS_ICG_BUILT_IN_PROC_H_
int mls_icg_add_built_in_procs(struct multiple_error *err, \
struct multiple_ir *icode, \
struct multiply_resource_id_pool *res_id, \
struct mls_icg_fcb_block *icg_fcb_block_init, \
struct mls_icg_customizable_built_in_procedure_list *customizable_built_in_procedure_list,
uint32_t insert_point, uint32_t *instrument_count);
#endif
|
/*
* This file is part of BitFiend.
* Copyright (C) 2017 Eduard Permyakov
*
* BitFiend 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.
*
* BitFiend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <libbf/bitfiend.h>
#include "printclr.h"
#include "commands.h"
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <ctype.h>
#define CLI_VER_MAJOR 0
#define CLI_VER_MINOR 1
#define CLI_VER_PATCH 0
static void print_welcome(void)
{
printf(" ____ _ __ _______ __\n");
printf(" / __ )(_) /_/ ____(_)__ ____ ____/ /\n");
printf(" / __ / / __/ /_ / / _ \\/ __ \\/ __ / \n");
printf(" / /_/ / / /_/ __/ / / __/ / / / /_/ / \n");
printf("/_____/_/\\__/_/ /_/\\___/_/ /_/\\__,_/ ");
printf("libbf %d.%d.%d cli %d.%d.%d\n\n", LIBBF_VER_MAJOR, LIBBF_VER_MINOR, LIBBF_VER_PATCH,
CLI_VER_MAJOR, CLI_VER_MINOR, CLI_VER_PATCH);
printf("Copyright (c) 2017 Eduard Permyakov\n");
printf("This is free software: you are free to change and redistribute it.\n");
printf("Type \"help\" for a list of commands or \"exit\" to quit.\n");
}
static void print_prompt(void)
{
printclr(FG_YELLOW, "BitFiend> ");
}
static void next_line(char *out, size_t n)
{
fgets(out, n, stdin);
out[n-1] = '\0';
/* If input was too long, consume the rest of stdin buffer */
if(out[strlen(out)-1] != '\n'){
char c;
while (((c = getchar()) != '\n') && (c != EOF));
}
}
static bool is_empty_line(const char *str)
{
while (*str) {
if (!isspace(*str))
return false;
str++;
}
return true;
}
int main(int argc, char **argv)
{
if(argc != 1){
printf("Usage: %s\n", argv[0]);
exit(EXIT_FAILURE);
}
print_welcome();
signal(SIGINT, SIG_IGN); //nicer handling of SIGINT eventually
signal(SIGPIPE, SIG_IGN);
if(bitfiend_init("./bitfiend.log") != BITFIEND_SUCCESS){
fprintf(stderr, "Failed initializing libbf. Check the logs!\n");
exit(EXIT_FAILURE);
}
while(true) {
print_prompt();
char line[256];
next_line(line, sizeof(line));
if(is_empty_line(line))
continue;
if(command_parse_and_exec(line) == CMD_FAIL_EXEC)
printf("%s is not a valid command. See \"help\".\n", line);
}
/* Client will be shutdown by exit command */
assert(0);
}
|
#include<stdio.h>
#include<unistd.h>
#define MAXLINE 4096
extern volatile int g_level;
enum xlog_type
{
XLOG_QUIT=0,
XLOG_SYS,
XLOG_ERR,
XLOG_MSG,
XLOG_DEBUG,
};
void log_set(int level);
void log_quit(int level, int error, const char *fmt, ...);
void log_sys(int level, const char *fmt, ...);
void log_err(int level, int error, const char *fmt, ...);
void log_msg(int level, const char *fmt, ...);
|
/* $Xorg: DefErrMsg.c,v 1.4 2001/02/09 02:03:52 xorgcvs Exp $ */
/*
Copyright 1988, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/* $XFree86: xc/lib/Xmu/DefErrMsg.c,v 1.7 2001/01/17 19:42:54 dawes Exp $ */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#define NEED_EVENTS
#include <X11/Xlibint.h>
#include <X11/Xproto.h>
#include <X11/Xmu/Error.h>
#include <X11/Xmu/SysUtil.h>
/*
* XmuPrintDefaultErrorMessage - print a nice error that looks like the usual
* message. Returns 1 if the caller should consider exitting else 0.
*/
int
XmuPrintDefaultErrorMessage(Display *dpy, XErrorEvent *event, FILE *fp)
{
char buffer[BUFSIZ];
char mesg[BUFSIZ];
char number[32];
char *mtype = "XlibMessage";
register _XExtension *ext = (_XExtension *)NULL;
_XExtension *bext = (_XExtension *)NULL;
XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
(void) fprintf(fp, "%s: %s\n ", mesg, buffer);
XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d",
mesg, BUFSIZ);
(void) fprintf(fp, mesg, event->request_code);
if (event->request_code < 128) {
XmuSnprintf(number, sizeof(number), "%d", event->request_code);
XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
} else {
/* XXX this is non-portable */
for (ext = dpy->ext_procs;
ext && (ext->codes.major_opcode != event->request_code);
ext = ext->next)
;
if (ext)
XmuSnprintf(buffer, sizeof(buffer), "%s", ext->name);
else
buffer[0] = '\0';
}
(void) fprintf(fp, " (%s)", buffer);
fputs("\n ", fp);
if (event->request_code >= 128) {
XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
mesg, BUFSIZ);
(void) fprintf(fp, mesg, event->minor_code);
if (ext) {
XmuSnprintf(mesg, sizeof(mesg),
"%s.%d", ext->name, event->minor_code);
XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
(void) fprintf(fp, " (%s)", buffer);
}
fputs("\n ", fp);
}
if (event->error_code >= 128) {
/* kludge, try to find the extension that caused it */
buffer[0] = '\0';
for (ext = dpy->ext_procs; ext; ext = ext->next) {
if (ext->error_string)
(*ext->error_string)(dpy, event->error_code, &ext->codes,
buffer, BUFSIZ);
if (buffer[0]) {
bext = ext;
break;
}
if (ext->codes.first_error &&
ext->codes.first_error < event->error_code &&
(!bext || ext->codes.first_error > bext->codes.first_error))
bext = ext;
}
if (bext)
XmuSnprintf(buffer, sizeof(buffer), "%s.%d", bext->name,
event->error_code - bext->codes.first_error);
else
strcpy(buffer, "Value");
XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ);
if (mesg[0]) {
fputs(" ", fp);
(void) fprintf(fp, mesg, event->resourceid);
fputs("\n", fp);
}
/* let extensions try to print the values */
for (ext = dpy->ext_procs; ext; ext = ext->next) {
if (ext->error_values)
(*ext->error_values)(dpy, event, fp);
}
} else if ((event->error_code == BadWindow) ||
(event->error_code == BadPixmap) ||
(event->error_code == BadCursor) ||
(event->error_code == BadFont) ||
(event->error_code == BadDrawable) ||
(event->error_code == BadColor) ||
(event->error_code == BadGC) ||
(event->error_code == BadIDChoice) ||
(event->error_code == BadValue) ||
(event->error_code == BadAtom)) {
if (event->error_code == BadValue)
XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
mesg, BUFSIZ);
else if (event->error_code == BadAtom)
XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
mesg, BUFSIZ);
else
XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
mesg, BUFSIZ);
(void) fprintf(fp, mesg, event->resourceid);
fputs("\n ", fp);
}
XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
mesg, BUFSIZ);
(void) fprintf(fp, mesg, event->serial);
fputs("\n ", fp);
XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d",
mesg, BUFSIZ);
(void) fprintf(fp, mesg, NextRequest(dpy)-1);
fputs("\n", fp);
if (event->error_code == BadImplementation) return 0;
return 1;
}
/*
* XmuSimpleErrorHandler - ignore errors for XQueryTree, XGetWindowAttributes,
* and XGetGeometry; print a message for everything else. In all case, do
* not exit.
*/
int
XmuSimpleErrorHandler(Display *dpy, XErrorEvent *errorp)
{
switch (errorp->request_code) {
case X_QueryTree:
case X_GetWindowAttributes:
if (errorp->error_code == BadWindow) return 0;
break;
case X_GetGeometry:
if (errorp->error_code == BadDrawable) return 0;
break;
}
/* got a "real" X error */
return XmuPrintDefaultErrorMessage (dpy, errorp, stderr);
}
|
/***************************************************************************************************
*
* RunlessBASIC
* Copyright 2013 Joshua Hawcroft <dev@joshhawcroft.com>
*
* lexer.h
* (see C source file for details)
*
***************************************************************************************************
*
* RunlessBASIC 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.
*
* RunlessBASIC 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 RunlessBASIC. If not, see <http://www.gnu.org/licenses/>.
*
**************************************************************************************************/
#ifndef _LEXER_H
#define _LEXER_H
typedef struct Lexer Lexer;
enum LexerTokenType
{
TOKEN_UNRECOGNISED,
TOKEN_PRAGMA,
TOKEN_IDENTIFIER,
TOKEN_SPACE,
TOKEN_NEW_LINE,
TOKEN_LIT_STRING,
TOKEN_LIT_INTEGER,
TOKEN_LIT_REAL,
TOKEN_LIT_COLOUR,
TOKEN_IMPLEMENTS,
TOKEN_INTERFACE,
TOKEN_PROTECTED,
TOKEN_INHERITS,
TOKEN_FUNCTION,
TOKEN_PRIVATE,
TOKEN_DECLARE,
TOKEN_FINALLY,
TOKEN_INLINEC,
TOKEN_HANDLER,
/*TOKEN_OBJECT,*/
TOKEN_STATIC,
TOKEN_SHARED,
TOKEN_PUBLIC,
TOKEN_DOWNTO,
TOKEN_RETURN,
TOKEN_SELECT,
TOKEN_ELSEIF,
TOKEN_HASH_ENDIF,
TOKEN_WHILE,
TOKEN_BYREF,
TOKEN_BYVAL,
TOKEN_UNTIL,
TOKEN_FALSE,
TOKEN_SUPER,
TOKEN_EVENT,
TOKEN_CATCH,
TOKEN_RAISE,
TOKEN_REDIM,
TOKEN_CLASS,
TOKEN_HASH_ELSE,
TOKEN_STEP,
TOKEN_LOOP,
TOKEN_THEN,
TOKEN_CASE,
TOKEN_WEND,
TOKEN_ELSE,
TOKEN_NEXT,
TOKEN_SELF,
TOKEN_GOTO,
TOKEN_TRUE,
TOKEN_EACH,
TOKEN_CALL,
TOKEN_NULL,
TOKEN_EXIT,
TOKEN_CONTINUE,
TOKEN_MOD,
TOKEN_HASH_IF,
TOKEN_ISA,
TOKEN_FOR,
TOKEN_SUB,
TOKEN_LIB,
TOKEN_NEW,
TOKEN_REM,
TOKEN_TRY,
TOKEN_DIM,
TOKEN_AND,
TOKEN_END,
TOKEN_NOT,
TOKEN_ME,
TOKEN_OR,
TOKEN_TO,
TOKEN_DO,
TOKEN_AS,
TOKEN_IF,
TOKEN_IS,
TOKEN_OF,
TOKEN_IN,
TOKEN_NOT_EQUAL,
TOKEN_LESS_EQUAL,
TOKEN_MORE_EQUAL,
TOKEN_PAREN_LEFT,
TOKEN_PAREN_RIGHT,
TOKEN_COLON,
TOKEN_PLUS,
TOKEN_HYPHEN,
TOKEN_MULTIPLY,
TOKEN_SLASH,
TOKEN_BACK_SLASH,
TOKEN_SQUARE_LEFT,
TOKEN_SQUARE_RIGHT,
TOKEN_QUOTE,
TOKEN_EQUAL,
TOKEN_LESS,
TOKEN_MORE,
TOKEN_DOT,
TOKEN_COMMA,
TOKEN_AMP_HEX,
TOKEN_AMP_OCT,
TOKEN_AMP_BIN,
TOKEN_AMP_COLOR,
TOKEN_AMP_UNICODE,
TOKEN_CONST,
};
typedef struct Token
{
enum LexerTokenType type;
long offset;
char *text;
union
{
long integer;
double real;
} value;
} Token;
Lexer* lexer_create(char *inSource);
Token lexer_get(Lexer *in_lexer);
Token lexer_peek(Lexer *in_lexer, int in_how_far);
long lexer_offset(Lexer *in_lexer);
#ifdef DEBUG
void lexer_debug_token(Token in_token);
void lexer_run_tests(void);
#endif
#endif
|
/*
Copyright (C) CFEngine AS
This file is part of CFEngine 3 - written and maintained by CFEngine AS.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; version 3.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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
To the extent this program is licensed as part of the Enterprise
versions of CFEngine, the applicable Commerical Open Source License
(COSL) may apply to this file if you as a licensee so wish it. See
included file COSL.txt.
*/
#ifndef CFENGINE_EXEC_TOOLS_H
#define CFENGINE_EXEC_TOOLS_H
#include "platform.h"
#include "cf3.defs.h"
int IsExecutable(const char *file);
bool ShellCommandReturnsZero(const char *command, ShellType shell);
bool GetExecOutput(const char *command, char *buffer, ShellType shell);
void ActAsDaemon(int preserve);
char **ArgSplitCommand(const char *comm);
void ArgFree(char **args);
#endif
|
////////////////////////////////////////////////////////////////////////////
// Created : 14.04.2009
// Author : Mykhailo Parfeniuk
// Copyright (C) GSC Game World - 2009
////////////////////////////////////////////////////////////////////////////
#ifndef ENVIRONMENT_H_INCLUDED
#define ENVIRONMENT_H_INCLUDED
namespace xray {
namespace render{
class environment: public quasi_singleton<environment>
{
public:
math::float4 get_amb_color() {return math::float4(0.08f, 0.08f, 0.08f, 0);}
math::float4 get_env_color() {return math::float4(0.46055603f, 0.38911888f, 0.35198119f, 1);}
math::float4 get_fog_color() {return math::float4(0.26033184f, 0.27797237f, 0.38404618f, 0);}
private:
}; // class environment
} // namespace render
} // namespace xray
#endif // #ifndef ENVIRONMENT_H_INCLUDED |
/**
* Copyright (c) 2000-2014 Liferay, Inc. All rights reserved.
*
* 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.
*/
#import "LRBaseService.h"
/**
* @author Bruno Farache
*/
@interface LRJournalFeedService_v62 : LRBaseService
- (NSDictionary *)addFeedWithGroupId:(long long)groupId feedId:(NSString *)feedId autoFeedId:(BOOL)autoFeedId name:(NSString *)name description:(NSString *)description type:(NSString *)type structureId:(NSString *)structureId templateId:(NSString *)templateId rendererTemplateId:(NSString *)rendererTemplateId delta:(int)delta orderByCol:(NSString *)orderByCol orderByType:(NSString *)orderByType targetLayoutFriendlyUrl:(NSString *)targetLayoutFriendlyUrl targetPortletId:(NSString *)targetPortletId contentField:(NSString *)contentField feedType:(NSString *)feedType feedVersion:(double)feedVersion serviceContext:(LRJSONObjectWrapper *)serviceContext error:(NSError **)error;
- (void)deleteFeedWithFeedId:(long long)feedId error:(NSError **)error;
- (void)deleteFeedWithGroupId:(long long)groupId feedId:(NSString *)feedId error:(NSError **)error;
- (NSDictionary *)getFeedWithFeedId:(long long)feedId error:(NSError **)error;
- (NSDictionary *)getFeedWithGroupId:(long long)groupId feedId:(NSString *)feedId error:(NSError **)error;
- (NSDictionary *)updateFeedWithGroupId:(long long)groupId feedId:(NSString *)feedId name:(NSString *)name description:(NSString *)description type:(NSString *)type structureId:(NSString *)structureId templateId:(NSString *)templateId rendererTemplateId:(NSString *)rendererTemplateId delta:(int)delta orderByCol:(NSString *)orderByCol orderByType:(NSString *)orderByType targetLayoutFriendlyUrl:(NSString *)targetLayoutFriendlyUrl targetPortletId:(NSString *)targetPortletId contentField:(NSString *)contentField feedType:(NSString *)feedType feedVersion:(double)feedVersion serviceContext:(LRJSONObjectWrapper *)serviceContext error:(NSError **)error;
@end |
/*
* Copyright (C) 2015 Steffen Nüssle
* climp - Command Line Interface Music Player
*
* This file is part of climp.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _GST_ENGINE_H_
#define _GST_ENGINE_H_
#include <stdbool.h>
#include <gst/gst.h>
enum gst_engine_state {
GST_ENGINE_PLAYING = GST_STATE_PLAYING,
GST_ENGINE_PAUSED = GST_STATE_PAUSED,
GST_ENGINE_STOPPED = GST_STATE_NULL,
};
struct gst_engine;
typedef void (*eos_callback)(struct gst_engine *);
typedef void (*bus_error_callback)(struct gst_engine *,
const char *,
const char *,
const char *);
struct gst_engine {
GstElement *gst_pipeline;
GstElement *gst_source;
GstElement *gst_convert;
GstElement *gst_pitch;
GstElement *gst_volume;
GstElement *gst_sink;
GstState gst_state;
unsigned int volume;
bool mute;
eos_callback on_end_of_stream;
bus_error_callback on_bus_error;
};
int gst_engine_init(struct gst_engine *__restrict en);
void gst_engine_destroy(struct gst_engine *__restrict en);
void gst_engine_set_uri(struct gst_engine *__restrict en,
const char *__restrict uri);
int gst_engine_play(struct gst_engine *__restrict en);
int gst_engine_pause(struct gst_engine *__restrict en);
int gst_engine_stop(struct gst_engine *__restrict en);
int gst_engine_stream_position(const struct gst_engine *__restrict en);
int gst_engine_set_stream_position(struct gst_engine *__restrict en,
unsigned int sec);
void gst_engine_set_pitch(struct gst_engine *__restrict en, float pitch);
float gst_engine_pitch(const struct gst_engine *__restrict en);
void gst_engine_set_speed(struct gst_engine *__restrict en, float speed);
float gst_engine_speed(const struct gst_engine *__restrict en);
void gst_engine_set_volume(struct gst_engine *__restrict en, unsigned int vol);
unsigned int gst_engine_volume(const struct gst_engine *__restrict en);
void gst_engine_set_mute(struct gst_engine *__restrict en, bool mute);
bool gst_engine_is_muted(const struct gst_engine *__restrict en);
enum gst_engine_state gst_engine_state(const struct gst_engine *__restrict en);
void gst_engine_set_end_of_stream_handler(struct gst_engine *__restrict en,
eos_callback func);
void gst_engine_set_bus_error_handler(struct gst_engine *__restrict en,
bus_error_callback func);
#endif /* _GST_ENGINE_H_ */ |
//-----------------------------------------------------------------------------
// VST Plug-Ins SDK
// VSTGUI: Graphical User Interface Framework for VST plugins :
//
// Version 3.0 $Date: 2005/11/22 17:24:44 $
//
//-----------------------------------------------------------------------------
// VSTGUI LICENSE
// © 2004, Steinberg Media Technologies, All Rights Reserved
//-----------------------------------------------------------------------------
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Steinberg Media Technologies nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.
//-----------------------------------------------------------------------------
#ifndef __cfileselector__
#define __cfileselector__
#include "vstgui.h"
#ifndef __aeffectx__
struct VstFileSelect;
#endif
BEGIN_NAMESPACE_VSTGUI
//-----------------------------------------------------------------------------
// CFileSelector Declaration
//!
//-----------------------------------------------------------------------------
class CFileSelector
{
public:
CFileSelector (void* ptr);
virtual ~CFileSelector ();
long run (VstFileSelect *vstFileSelect);
protected:
void* ptr;
VstFileSelect *vstFileSelect;
#if MAC
static pascal void navEventProc (const NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD);
static pascal Boolean navObjectFilterProc (AEDesc *theItem, void *info, void *callBackUD, NavFilterModes filterMode);
#endif
};
END_NAMESPACE_VSTGUI
#ifndef __aeffectx__
struct VstFileType
{
VstFileType (char* _name, char *_macType, char *_dosType, char *_unixType = 0, char *_mimeType1 = 0, char *_mimeType2 = 0)
{
if (_name)
strcpy (name, _name);
if (_macType)
strcpy (macType, _macType);
if (_dosType)
strcpy (dosType, _dosType);
if (_unixType)
strcpy (unixType, _unixType);
if (_mimeType1)
strcpy (mimeType1, _mimeType1);
if (_mimeType2)
strcpy (mimeType2, _mimeType2);
}
char name[128];
char macType[8];
char dosType[8];
char unixType[8];
char mimeType1[128];
char mimeType2[128];
};
struct VstFileSelect
{
long command; // see enum kVstFileLoad....
long type; // see enum kVstFileType...
long macCreator; // optional: 0 = no creator
long nbFileTypes; // nb of fileTypes to used
VstFileType *fileTypes; // list of fileTypes
char title[1024]; // text display in the file selector's title
char *initialPath; // initial path
char *returnPath; // use with kVstFileLoad and kVstDirectorySelect
// if null is passed, the host will allocated memory
// the plugin should then called closeOpenFileSelector for freeing memory
long sizeReturnPath;
char **returnMultiplePaths; // use with kVstMultipleFilesLoad
// the host allocates this array. The plugin should then called closeOpenFileSelector for freeing memory
long nbReturnPath; // number of selected paths
long reserved; // reserved for host application
char future[116]; // future use
};
enum {
kVstFileLoad = 0,
kVstFileSave,
kVstMultipleFilesLoad,
kVstDirectorySelect,
kVstFileType = 0
};
#endif
#endif
|
/***************************************************************************
* *
* Copyright (C) 2017 Seamly, LLC *
* *
* https://github.com/fashionfreedom/seamly2d *
* *
***************************************************************************
**
** Seamly2D 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.
**
** Seamly2D 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 Seamly2D. If not, see <http://www.gnu.org/licenses/>.
**
**************************************************************************
************************************************************************
**
** @file vnodepoint.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date November 15, 2013
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013-2015 Seamly2D project
** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
**
** Seamly2D 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.
**
** Seamly2D 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 Seamly2D. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VNODEPOINT_H
#define VNODEPOINT_H
#include <qcompilerdetection.h>
#include <QGraphicsEllipseItem>
#include <QGraphicsItem>
#include <QMetaObject>
#include <QObject>
#include <QPointF>
#include <QString>
#include <QtGlobal>
#include "../ifc/xml/vabstractpattern.h"
#include "../vmisc/def.h"
#include "vabstractnode.h"
#include "../vwidgets/vscenepoint.h"
/**
* @brief The VNodePoint class point detail node.
*/
class VNodePoint: public VAbstractNode, public VScenePoint
{
Q_OBJECT
public:
static void Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene,
quint32 id, quint32 idPoint, const Document &parse, const Source &typeCreation,
const QString &drawName = QString(), const quint32 &idTool = 0);
static const QString ToolType;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::NodePoint)};
virtual QString getTagName() const Q_DECL_OVERRIDE;
virtual void setPointNamePosition(quint32 id, const QPointF &pos) Q_DECL_OVERRIDE;
virtual void setPointNameVisiblity(quint32 id, bool visible) Q_DECL_OVERRIDE;
signals:
/**
* @brief showContextMenu emit when need show tool context menu.
* @param event context menu event.
*/
//void ShowOptions();
//void ToggleInLayout(bool checked);
//void Delete();
public slots:
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
void nameChangedPosition(const QPointF &pos);
void pointChosen();
void EnableToolMove(bool move);
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
void allowTextHover(bool enabled);
void allowTextSelectable(bool enabled);
protected:
virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
virtual void ShowNode() Q_DECL_OVERRIDE;
virtual void HideNode() Q_DECL_OVERRIDE;
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VNodePoint)
VNodePoint(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Source &typeCreation,
const QString &drawName = QString(), const quint32 &idTool = 0, QObject *qoParent = nullptr,
QGraphicsItem * parent = nullptr );
};
#endif // VNODEPOINT_H
|
/*
*
* j-chkmail - Mail Server Filter for sendmail
*
* Copyright (c) 2001-2017 - Jose-Marcio Martins da Cruz
*
* Auteur : Jose Marcio Martins da Cruz
* jose.marcio.mc@gmail.org
*
* Historique :
* Creation : janvier 2002
*
* This program is free software, but with restricted license :
*
* - j-chkmail is distributed only to registered users
* - j-chkmail license is available only non-commercial applications,
* this means, you can use j-chkmail if you make no profit with it.
* - redistribution of j-chkmail in any way : binary, source in any
* media, is forbidden
*
* 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.
*
* More details about j-chkmail license can be found at j-chkmail
* web site : http://foss.jose-marcio.org
*/
#include <j-sys.h>
#include <j-chkmail.h>
#include <j-avclient.h>
bool shall_notify_user(char *, bool);
void
print_str_bounds(s, i, f)
char *s;
int i;
int f;
{
char buf[256];
memset(buf, 0, sizeof (buf));
strcpy(buf, s);
printf(" -> %s\n", buf);
memset(buf, 0, sizeof (buf));
strset(buf, ' ', strlen(s) + 1);
buf[i] = buf[f] = '+';
printf(" -> %s\n", buf);
}
int
main(argc, argv)
int argc;
char **argv;
{
char out[256];
int res = 0;
char *in = "/tmp/Yaha.P";
char question[2048];
char answer[2048];
char msg[2048];
int avres;
extern int log_level;
configure("j-policy-test", conf_file, FALSE);
memset(answer, 0, sizeof (answer));
set_log_output(TRUE, TRUE);
log_level = 10;
{
char *ip;
if (argc > 1)
ip = argv[1];
else
ip = "194.214.158.176";
}
if (1)
{
char *prefix, *ip, *name, *from, *to;
bool flag;
prefix = ip = name = from = to = NULL;
prefix = STRBOOL(argc > 1, argv[1], "-");
ip = STRBOOL(argc > 2, argv[2], "-");
name = STRBOOL(argc > 3, argv[3], "-");
from = STRBOOL(argc > 4, argv[4], "-");
to = STRBOOL(argc > 5, argv[5], "-");
MESSAGE_INFO(0, "Checking = %s %s %s %s", ip, name, from, to);
if (db_policy_open(TRUE))
{
flag = check_policy_tuple(prefix, ip, name, NULL, from, to, FALSE);
MESSAGE_INFO(0, "RESULT = %s", STRBOOL(flag, "YES", "NO"));
db_policy_close();
} else
MESSAGE_INFO(0, "Error opening policy database !");
return 0;
}
#if 0
{
bool res = FALSE;
char *ip, *from, *to, hostname[256];
printf("ARGC = %d\n", argc);
gethostname(hostname, sizeof (hostname));
/*strcpy(hostname, "minho"); */
ip = STRBOOL(argc > 1, argv[1], "1.2.3.4");
from = STRBOOL(argc > 2, argv[2], "martins@ensmp.fr");
to = STRBOOL(argc > 3, argv[3], "joe@ensmp.fr");
res = grey_init(FALSE);
MESSAGE_INFO(0, "GREY_INIT : %s %s %s %s : %s",
STRNULL(ip, "IP"),
STRNULL(from, "FROM"),
STRNULL(to, "TO"),
STRNULL(hostname, "HOSTNAME"), STRBOOL(res, "TRUE", "FALSE"));
res = grey_check(ip, from, to, hostname);
MESSAGE_INFO(0, "GREY_CHECK : %s %s %s : %s",
STRNULL(ip, "IP"),
STRNULL(from, "FROM"),
STRNULL(to, "TO"), STRBOOL(res, "TRUE", "FALSE"));
MESSAGE_INFO(0, "TIME %ld", time(NULL));
grey_close();
return 0;
}
#endif
if (db_policy_open(TRUE))
{
long pi, pf;
char *s, *expr;
bool found;
char *prefix;
char *key;
char buf[256];
if (argc > 1)
prefix = argv[1];
if (argc > 2)
key = argv[2];
#if 1
prefix = STRNULL(prefix, "");
key = STRNULL(key, "");
#else
prefix = "NetClass";
key = "194.214.158.200";
#endif
memset(buf, 0, sizeof (buf));
check_policy(prefix, key, buf, sizeof (buf), TRUE);
printf("POLICY : %s(%s) = %s\n", prefix, key, buf);
printf("\n");
}
{
bool ok;
char *s;
s = "joe@ensmp.fr";
ok = shall_notify_user(s, FALSE);
printf(" -> %-30s %s\n", s, STRBOOL(ok, "TRUE", "FALSE"));
s = "martins@ensmp.fr";
ok = shall_notify_user(s, FALSE);
printf(" -> %-30s %s\n", s, STRBOOL(ok, "TRUE", "FALSE"));
s = "joe@ensmp.com";
ok = shall_notify_user(s, FALSE);
printf(" -> %-30s %s\n", s, STRBOOL(ok, "TRUE", "FALSE"));
s = "martins@joe";
ok = shall_notify_user(s, FALSE);
printf(" -> %-30s %s\n", s, STRBOOL(ok, "TRUE", "FALSE"));
s = "martins@fr.joe";
ok = shall_notify_user(s, FALSE);
printf(" -> %-30s %s\n", s, STRBOOL(ok, "TRUE", "FALSE"));
s = "charles@free.fr";
ok = shall_notify_user(s, FALSE);
printf(" -> %-30s %s\n", s, STRBOOL(ok, "TRUE", "FALSE"));
}
}
bool
shall_notify_user(user_addr, to)
char *user_addr;
bool to;
{
bool result = FALSE;
char buf[256];
memset(buf, 0, sizeof (buf));
if (check_policy("NotifyUser", user_addr, buf, sizeof (buf), FALSE))
{
if (strcasecmp(buf, "NO") == 0)
return FALSE;
if (strcasecmp(buf, "YES") == 0)
return TRUE;
if (strcasecmp(buf, "RECIPIENT") == 0)
return to;
if (strcasecmp(buf, "SENDER") == 0)
return !to;
if (strcasecmp(buf, "DAILY") == 0)
return FALSE;
}
return result;
}
|
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* 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
*
*/
/* This file was automatically generated --- DO NOT EDIT */
/* Generated on Mon Jan 16 09:12:02 EST 2017 */
#include "codelet-rdft.h"
#ifdef HAVE_FMA
/* Generated by: ../../../genfft/gen_hc2c.native -fma -reorder-insns -schedule-for-pipeline -compact -variables 4 -pipeline-latency 4 -sign 1 -n 4 -dif -name hc2cb_4 -include hc2cb.h */
/*
* This function contains 22 FP additions, 12 FP multiplications,
* (or, 16 additions, 6 multiplications, 6 fused multiply/add),
* 25 stack variables, 0 constants, and 16 memory accesses
*/
#include "hc2cb.h"
static void hc2cb_4(R *Rp, R *Ip, R *Rm, R *Im, const R *W, stride rs, INT mb, INT me, INT ms)
{
{
INT m;
for (m = mb, W = W + ((mb - 1) * 6); m < me; m = m + 1, Rp = Rp + ms, Ip = Ip + ms, Rm = Rm - ms, Im = Im - ms, W = W + 6, MAKE_VOLATILE_STRIDE(16, rs)) {
E Th, Ta, T7, Ti, T9;
{
E Tq, Td, T3, Tg, Tu, Tm, T6, Tp;
{
E Tk, T4, Tl, T5;
{
E Tb, Tc, T1, T2, Te, Tf;
Tb = Ip[0];
Tc = Im[WS(rs, 1)];
T1 = Rp[0];
T2 = Rm[WS(rs, 1)];
Te = Ip[WS(rs, 1)];
Tq = Tb + Tc;
Td = Tb - Tc;
Tf = Im[0];
Tk = T1 - T2;
T3 = T1 + T2;
T4 = Rp[WS(rs, 1)];
Tg = Te - Tf;
Tl = Te + Tf;
T5 = Rm[0];
}
Tu = Tk + Tl;
Tm = Tk - Tl;
T6 = T4 + T5;
Tp = T4 - T5;
}
Rm[0] = Td + Tg;
{
E Tx, Tr, T8, Tn, Ts, To, Tj;
Tj = W[0];
Tx = Tq - Tp;
Tr = Tp + Tq;
Rp[0] = T3 + T6;
T8 = T3 - T6;
Tn = Tj * Tm;
Ts = Tj * Tr;
To = W[1];
{
E Tt, Tw, Ty, Tv;
Tt = W[4];
Tw = W[5];
Th = Td - Tg;
Im[0] = FMA(To, Tm, Ts);
Ip[0] = FNMS(To, Tr, Tn);
Ty = Tt * Tx;
Tv = Tt * Tu;
Ta = W[3];
T7 = W[2];
Im[WS(rs, 1)] = FMA(Tw, Tu, Ty);
Ip[WS(rs, 1)] = FNMS(Tw, Tx, Tv);
Ti = Ta * T8;
T9 = T7 * T8;
}
}
}
Rm[WS(rs, 1)] = FMA(T7, Th, Ti);
Rp[WS(rs, 1)] = FNMS(Ta, Th, T9);
}
}
}
static const tw_instr twinstr[] = {
{TW_FULL, 1, 4},
{TW_NEXT, 1, 0}
};
static const hc2c_desc desc = { 4, "hc2cb_4", twinstr, &GENUS, {16, 6, 6, 0} };
void X(codelet_hc2cb_4) (planner *p) {
X(khc2c_register) (p, hc2cb_4, &desc, HC2C_VIA_RDFT);
}
#else /* HAVE_FMA */
/* Generated by: ../../../genfft/gen_hc2c.native -compact -variables 4 -pipeline-latency 4 -sign 1 -n 4 -dif -name hc2cb_4 -include hc2cb.h */
/*
* This function contains 22 FP additions, 12 FP multiplications,
* (or, 16 additions, 6 multiplications, 6 fused multiply/add),
* 13 stack variables, 0 constants, and 16 memory accesses
*/
#include "hc2cb.h"
static void hc2cb_4(R *Rp, R *Ip, R *Rm, R *Im, const R *W, stride rs, INT mb, INT me, INT ms)
{
{
INT m;
for (m = mb, W = W + ((mb - 1) * 6); m < me; m = m + 1, Rp = Rp + ms, Ip = Ip + ms, Rm = Rm - ms, Im = Im - ms, W = W + 6, MAKE_VOLATILE_STRIDE(16, rs)) {
E T3, Ti, Tc, Tn, T6, Tm, Tf, Tj;
{
E T1, T2, Ta, Tb;
T1 = Rp[0];
T2 = Rm[WS(rs, 1)];
T3 = T1 + T2;
Ti = T1 - T2;
Ta = Ip[0];
Tb = Im[WS(rs, 1)];
Tc = Ta - Tb;
Tn = Ta + Tb;
}
{
E T4, T5, Td, Te;
T4 = Rp[WS(rs, 1)];
T5 = Rm[0];
T6 = T4 + T5;
Tm = T4 - T5;
Td = Ip[WS(rs, 1)];
Te = Im[0];
Tf = Td - Te;
Tj = Td + Te;
}
Rp[0] = T3 + T6;
Rm[0] = Tc + Tf;
{
E T8, Tg, T7, T9;
T8 = T3 - T6;
Tg = Tc - Tf;
T7 = W[2];
T9 = W[3];
Rp[WS(rs, 1)] = FNMS(T9, Tg, T7 * T8);
Rm[WS(rs, 1)] = FMA(T9, T8, T7 * Tg);
}
{
E Tk, To, Th, Tl;
Tk = Ti - Tj;
To = Tm + Tn;
Th = W[0];
Tl = W[1];
Ip[0] = FNMS(Tl, To, Th * Tk);
Im[0] = FMA(Th, To, Tl * Tk);
}
{
E Tq, Ts, Tp, Tr;
Tq = Ti + Tj;
Ts = Tn - Tm;
Tp = W[4];
Tr = W[5];
Ip[WS(rs, 1)] = FNMS(Tr, Ts, Tp * Tq);
Im[WS(rs, 1)] = FMA(Tp, Ts, Tr * Tq);
}
}
}
}
static const tw_instr twinstr[] = {
{TW_FULL, 1, 4},
{TW_NEXT, 1, 0}
};
static const hc2c_desc desc = { 4, "hc2cb_4", twinstr, &GENUS, {16, 6, 6, 0} };
void X(codelet_hc2cb_4) (planner *p) {
X(khc2c_register) (p, hc2cb_4, &desc, HC2C_VIA_RDFT);
}
#endif /* HAVE_FMA */
|
/*
UFOCR - User-Friendly OCR
Copyright (C) 2017 Alexander Zaitsev <zamazan4ik@tut.by>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROJECTFILES_H
#define PROJECTFILES_H
#include <QString>
#include <QStringList>
class ProjectFiles
{
public:
ProjectFiles(const QString& rootDir);
~ProjectFiles();
QStringList directories();
QStringList projects();
bool isDirEmpty(const QString& dirName);
bool canProjectBeSavedToDir(const QString& name); // relative
bool isProjectDir();
bool isProjectDir(const QString& path);
bool hasTemporaryData();
void cd(const QString& newRoot);
bool pathExists(const QString& path);
bool canCdTo(const QString& path);
bool canCdToUpper(const QString& path);
QString upDir(const QString& path);
QString currentDir();
QString projectName(const QString& path);
private:
QStringList dirs;
QStringList projs;
QString root;
bool isPD;
private:
bool isProjectDirInternal(const QString& path);
};
#endif // PROJECTFILES_H
|
#ifndef DATA_WRITE_ONLY_H_
#define DATA_WRITE_ONLY_H_
#include <QDataStream>
#include "../ValueWrapper.h"
#include "Command.h"
#include "DataInterface.h"
/**
* Write-only telemetry data.
* Uses a simple type for its value.
* Write-only means you can only send commands to modify
* it's value (if any) but has no feedback from the robot.
*/
template<typename T>
class DataWriteOnly : public DataInterface
{
public:
Command<T> command;
virtual void setCommand(const ValueWrapper &value);
virtual void sendCommand(QDataStream &outStream,
const bool onlyInProgress = false) override;
virtual void deserialise(QDataStream &inStream) override;
virtual void updateCommand() override;
virtual bool inProgress() const { return command.inProgess(); }
virtual bool isReadOnly() const { return false; }
virtual std::string getValueText() const { return std::string(); }
virtual void drawTimeChart(QCustomPlot *customPlot) const;
virtual void drawBarChart(QCustomPlot *customPlot) const;
};
template <typename T>
inline void DataWriteOnly<T>::setCommand(const ValueWrapper &value)
{
command.setValue(value);
}
template <typename T>
inline void DataWriteOnly<T>::sendCommand(QDataStream &outStream,
const bool onlyInProgress)
{
if (!onlyInProgress || command.inProgess())
{
command.serialise(outStream);
}
}
template <typename T>
inline void DataWriteOnly<T>::deserialise(QDataStream &)
{
// No states, nothing to do.
}
template <typename T>
inline void DataWriteOnly<T>::updateCommand()
{
// No states, nothing to update with.
}
template<typename T>
inline void DataWriteOnly<T>::drawTimeChart(QCustomPlot *customPlot) const
{
Q_UNUSED(customPlot)
// No states, nothing to do.
}
template<typename T>
inline void DataWriteOnly<T>::drawBarChart(QCustomPlot *customPlot) const
{
Q_UNUSED(customPlot)
// No states, nothing to do.
}
#endif // DATA_WRITE_ONLY_H_
|
/*
* This file is part of Cleanflight and Betaflight.
*
* Cleanflight and Betaflight are free software. You can redistribute
* this software and/or modify this software 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.
*
* Cleanflight and Betaflight are distributed in the hope that they
* 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 software.
*
* If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#define TARGET_BOARD_IDENTIFIER "NU72"
#define USBD_PRODUCT_STRING "NucleoF722"
//#define USE_ESC_TELEMETRY
#define LED0_PIN PB7 // blue
#define LED1_PIN PB14 // red
//#define USE_BEEPER
//#define BEEPER_PIN PA0
//#define BEEPER_INVERTED
#undef USE_MULTI_GYRO
#define USE_ACC
#define USE_FAKE_ACC
#define USE_ACC_MPU6050
#define ACC_1_ALIGN CW270_DEG
#define USE_GYRO
#define USE_FAKE_GYRO
#define USE_GYRO_MPU6050
#define GYRO_1_ALIGN CW270_DEG
// MPU6050 interrupts
#define USE_MPU_DATA_READY_SIGNAL
#define USE_EXTI
#define USE_GYRO_EXTI
#define GYRO_1_EXTI_PIN PB15
#define USE_EXTI
#define USE_MAG
#define USE_FAKE_MAG
#define USE_MAG_HMC5883
#define USE_MAG_QMC5883
#define USE_MAG_LIS3MDL
#define MAG_HMC5883_ALIGN CW270_DEG_FLIP
#define USE_BARO
#define USE_FAKE_BARO
#define USE_BARO_MS5611
#define USABLE_TIMER_CHANNEL_COUNT 9
#define USE_VCP
#define USE_USB_DETECT
#define USB_DETECT_PIN PA9
//#define USE_UART1
//#define UART1_RX_PIN PA10
//#define UART1_TX_PIN PA9
#define USE_UART2
#define UART2_RX_PIN PD6
#define UART2_TX_PIN PD5
#define USE_UART3
#define UART3_RX_PIN PD9
#define UART3_TX_PIN PD8
#define USE_UART4
//#define UART4_RX_PIN PC11 // Used for SDIO
//#define UART4_TX_PIN PC10 // Used for SDIO
#define UART4_RX_PIN PA1
#define UART4_TX_PIN PA0
//#define USE_UART5
//#define UART5_RX_PIN PD2 // Used for SDIO
//#define UART5_TX_PIN PC12 // Used for SDIO
//#define USE_UART6
#define UART6_RX_PIN PC7
#define UART6_TX_PIN PC6
//#define USE_UART7
#define UART7_RX_PIN PE7
#define UART7_TX_PIN PE8
//#define USE_UART8
#define UART8_RX_PIN PE0
#define UART8_TX_PIN PE1
#define USE_SOFTSERIAL1
#define USE_SOFTSERIAL2
#define SERIAL_PORT_COUNT 6 //VCP, USART2, USART3, UART4, SOFTSERIAL x 2
#define USE_ESCSERIAL
#define ESCSERIAL_TIMER_TX_PIN PB15 // (Hardware=0, PPM)
#define USE_SPI
#define USE_SPI_DEVICE_1
#define USE_SPI_DEVICE_4
#define SPI1_NSS_PIN PA4
#define SPI1_SCK_PIN PA5
#define SPI1_MISO_PIN PA6
#define SPI1_MOSI_PIN PA7
#define SPI4_NSS_PIN PE11
#define SPI4_SCK_PIN PE12
#define SPI4_MISO_PIN PE13
#define SPI4_MOSI_PIN PE14
#define USE_SDCARD
//#define SDCARD_DETECT_INVERTED
//#define SDCARD_DETECT_PIN PF14
//#define SDCARD_SPI_INSTANCE SPI4
//#define SDCARD_SPI_CS_PIN SPI4_NSS_PIN
//#define SPI4_TX_DMA_OPT 0 // DMA 2 Stream 1 Channel 4
#define USE_SDCARD_SDIO
#define SDIO_DMA_OPT 0 // DMA 2 Stream 3 Chanel 4
#define SDCARD_SPI_CS_PIN NONE //This is not used on SDIO, has to be kept for now to keep compiler happy
#define USE_I2C
#define USE_I2C_DEVICE_1
#define I2C_DEVICE (I2CDEV_1)
#define I2C1_SCL PB8
#define I2C1_SDA PB9
#define USE_ADC
#define VBAT_ADC_PIN PA3
#define CURRENT_METER_ADC_PIN PC0
#define RSSI_ADC_PIN PC3
//#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT
#define DEFAULT_RX_FEATURE FEATURE_RX_SERIAL
#define SERIALRX_PROVIDER SERIALRX_SBUS
#define USE_SERIAL_4WAY_BLHELI_INTERFACE
#define TARGET_IO_PORTA 0xffff
#define TARGET_IO_PORTB 0xffff
#define TARGET_IO_PORTC 0xffff
#define TARGET_IO_PORTD 0xffff
#define TARGET_IO_PORTE 0xffff
#define TARGET_IO_PORTF 0xffff
#define USED_TIMERS ( TIM_N(2) | TIM_N(3) | TIM_N(4) | TIM_N(8) | TIM_N(9) | TIM_N(12) )
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "globals.h"
#include "board.h"
#include "hashtable.h"
#include "io.h"
S_HASHTABLE g_hash_table;
void clear_hashtable()
{
g_hash_table.fail_checksum = 0;
g_hash_table.cut = 0;
memset(g_hash_table.entries, 0, g_hash_table.size * sizeof(S_HASHENTRY));
}
void init_hashtable(u64 size)
{
if (size == 0) {
size = HASH_DEF;
}
size = size * 1000000; //size in MB
g_hash_table.size = size / sizeof(S_HASHENTRY);
g_hash_table.cut = 0;
destroy_hashtable();
g_hash_table.entries = (S_HASHENTRY *) calloc(g_hash_table.size, sizeof(S_HASHENTRY));
printf("init hashtable with %d entries\n", g_hash_table.size);
}
void destroy_hashtable()
{
if (g_hash_table.entries != NULL) {
printf("fail_checksums:%d",g_hash_table.fail_checksum);
printf("hash cuts:%d",g_hash_table.cut);
free(g_hash_table.entries);
}
}
int probe_hash(u64 key, S_HASHENTRY *entry, i16 *score, i16 alpha, i16 beta, int depth)
{
if (hash_get(key, entry)) {
if (entry->depth >= depth) {
if (entry->flag_and_age & EXCA_FLAG) {
*score = entry->eval;
return true;
}
if ((entry->flag_and_age & ALPH_FLAG) && (entry->eval <= alpha)) {
*score = alpha;
return true;
}
if ((entry->flag_and_age) & BETA_FLAG && (entry->eval >= beta)) {
*score = beta;
return true;
}
}
}
return false;
}
int hash_get(u64 key, S_HASHENTRY *entry)
{
int i = key % g_hash_table.size;
if (g_hash_table.entries[i].hash_key == key) {
*entry = g_hash_table.entries[i];
//Only return if checksum is OK
uint32_t local_checksum = entry->hash_key ^ entry->move ^ entry->eval ^ entry->depth ^ entry->flag_and_age;
if(entry->checksum == local_checksum) {
return true;
}
fail_checksum++;
}
entry = NULL;
return false;
}
void hash_put(u64 key, u32 move, i16 eval, u8 depth, i16 age, i16 flag)
{
int put_score = 0;
int i = key % g_hash_table.size;
S_HASHENTRY *prev_entry = &g_hash_table.entries[i];
uint32_t local_checksum = prev_entry->hash_key ^ prev_entry->move ^ prev_entry->eval ^ prev_entry->depth ^ prev_entry->flag_and_age;
if(prev_entry->checksum == local_checksum) {
/* Replacement strategy:
* 1. Always replace older entries
* 2. Prefer depth, exca-flag gets 4 points, Beta-flag 2.
*/
put_score = depth - prev_entry->depth;
put_score += ((age - (prev_entry->flag_and_age & AGE_MASK)));
if (flag == EXCA_FLAG) put_score += 2;
else if (flag == BETA_FLAG) put_score += 1;
i16 prev_flag = (prev_entry->flag_and_age & FLAG_MASK);
if (prev_flag == EXCA_FLAG) put_score -= 2;
else if (prev_flag == BETA_FLAG) put_score -= 1;
//printf ("FALSE: depth:%d - %d:prev_depth\n", age, prev_entry->flag_and_age & AGE_MASK);
if (put_score < 0) {
return;
}
} else {
fail_checksum++;
}
u16 flag_and_age = (age & AGE_MASK) | (flag & FLAG_MASK);
// //resetting eval to mate-score (ignoring moves to mate)
// if (eval > ISMATE) {
// eval = MATE;
// } else if (eval < -ISMATE) {
// eval = -MATE;
// }
int32_t checksum = key ^ move ^ eval ^ depth ^ flag_and_age;
g_hash_table.entries[i].hash_key = key;
g_hash_table.entries[i].move = move;
g_hash_table.entries[i].eval = eval;
g_hash_table.entries[i].depth = depth;
g_hash_table.entries[i].flag_and_age = flag_and_age;
g_hash_table.entries[i].checksum = checksum;
}
int hash_get_pv_line(S_BOARD *b, u32 *moves, int depth)
{
int i = 0;
int j = 0;
S_HASHENTRY entry;
moves[i++] = b->principal_variation[0];
if (!make_move_if_exist(b, moves[0])) {
printf("ERROR, first move doesn't exist, hash_get_pv_line");
}
while(i < depth && hash_get(b->hash_key, &entry)) {
if(make_move_if_exist(b, entry.move)) {
moves[i++] = entry.move;
} else {
break;
}
}
while(j++ < i) {
unmake_move(b);
}
return i;
}
|
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2009 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#ifndef MANTID_API_IMMUTABLECOMPOSITEFUNCTION_H_
#define MANTID_API_IMMUTABLECOMPOSITEFUNCTION_H_
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/CompositeFunction.h"
#include <map>
namespace Mantid {
namespace API {
/**
Immutable composite function is a composite function which members cannot be
added or removed
after creation. Only a derived class can add functions in its contructor (or
methods).
The function factory treat an ImmutableCompositeFunction as a simple
function.
*/
class MANTID_API_DLL ImmutableCompositeFunction : public CompositeFunction {
public:
/* Overriden methods */
/// Returns the function's name
std::string name() const override { return "ImmutableCompositeFunction"; }
/// Set i-th parameter
void setParameter(size_t i, const double &value,
bool explicitlySet = true) override {
CompositeFunction::setParameter(i, value, explicitlySet);
}
/// Set i-th parameter description
void setParameterDescription(size_t i,
const std::string &description) override {
CompositeFunction::setParameterDescription(i, description);
}
/// Set parameter by name.
void setParameter(const std::string &name, const double &value,
bool explicitlySet = true) override;
/// Set description of parameter by name.
void setParameterDescription(const std::string &name,
const std::string &description) override;
/// Get i-th parameter
double getParameter(size_t i) const override {
return CompositeFunction::getParameter(i);
}
/// Get parameter by name.
double getParameter(const std::string &name) const override;
/// Returns the index of parameter name
size_t parameterIndex(const std::string &name) const override;
/// Returns the name of parameter i
std::string parameterName(size_t i) const override;
protected:
/// Make it protected
using CompositeFunction::addFunction;
/// Overload addFunction to take a bare pointer
void addFunction(IFunction *fun);
/// Define an alias for a parameter
void setAlias(const std::string &parName, const std::string &alias);
/// Add default ties
void addDefaultTies(const std::string &ties);
/// Add default constraints
void addDefaultConstraints(const std::string &constraints);
/// Writes itself into a string
std::string writeToString(
const std::string &parentLocalAttributesStr = "") const override;
private:
/// Keep paramater aliases
std::map<std::string, size_t> m_aliases;
};
} // namespace API
} // namespace Mantid
#endif /*MANTID_API_IMMUTABLECOMPOSITEFUNCTION_H_*/
|
/*
* ****************************************************************
* This software is a media player SDK implementation
* GPL:
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details. You should
* have received a copy of the GNU Library General Public License
* along with this library; if not, write to the Free Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Project: EC < Enjoyable Coding >
*
* MediaCtrl.h
* This file for Media Ctrl define.
* Eamil: epengao@126.com
* Author: Gao Peng
* Version: Intial first version.
* ****************************************************************
*/
#ifndef MEDIA_CTRL_H
#define MEDIA_CTRL_H
#include "MediaClock.h"
#include "MediaSource.h"
#include "AudioDecoder.h"
#include "VideoDecoder.h"
#include "AudioRender.h"
#include "VideoRender.h"
typedef enum
{
MediaCtrlStatus_Play,
MediaCtrlStatus_Pause,
MediaCtrlStatus_NoAct,
MediaCtrlStatus_Unknown = -1,
} MediaCtrlStatus;
class MediaCtrl
{
public:
MediaCtrl();
~MediaCtrl();
int OpenMedia(const char* pMeidaPath,
void* pVideoWindow = NULL,
EC_U32 nWindowWidth = 0,
EC_U32 nWindowHeight = 0);
void CloseMedia();
void Play(unsigned int nStartPos = 0);
void Pause();
int Seek(EC_U32 nSeekPos);
int GetDuration();
int GetPlayingPos();
int GetBufferingPos();
MediaContext* GetMediaContext();
void UpdateVideoWindow(void* pWindow, EC_U32 nWidth, EC_U32 nHeight);
private:
bool m_HasA;
bool m_HasV;
MediaClock* m_pClk;
MediaSource* m_pSrc;
AudioDecoder* m_pADec;
VideoDecoder* m_pVDec;
AudioRender* m_pARnd;
VideoRender* m_pVRnd;
MediaCtrlStatus m_nStatus;
};
#endif /* MEDIA_CTRL_H */
|
/*
* matrix.h - header file for the matrix functions
*
* Andrew Whitwham (aw7@sanger.ac.uk)
* Wellcome Trust Sanger Institute
* April 2012
*
* This software has been created by Genome Research Limited (GRL).
* GRL hereby grants permission to use, copy, modify and distribute
* this software and its documentation for non-commercial purposes
* without fee at the user's own risk on the basis set out below.
* GRL neither undertakes nor accepts any duty whether contractual or
* otherwise in connection with the software, its use or the use of
* any derivative, and makes no representations or warranties, express
* or implied, concerning the software, its suitability, fitness for
* a particular purpose or non-infringement.
* In no event shall the authors of the software or GRL be responsible
* or liable for any loss or damage whatsoever arising in any way
* directly or indirectly out of the use of this software or its
* derivatives, even if advised of the possibility of such damage.
* Our software can be freely distributed under the conditions set out
* above, and must contain this copyright notice.
*/
#ifndef _SANGER_MATRIX_H
#define _SANGER_MATRIX_H
int **imatrix(long nrl, long nrh, long ncl, long nch);
void free_imatrix(int **m, long nrl, long nrh, long ncl, long nch);
char **cmatrix(long nrl, long nrh, long ncl, long nch);
void free_cmatrix(char **c, long nrl, long nrh, long ncl, long nch);
#endif
|
/****************************************************************************
* VLC-Qt - Qt and libvlc connector library
* Copyright (C) 2015 Tadej Novak <tadej@tano.si>
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU 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, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#ifndef VLCQT_WIDGETSEEK_H_
#define VLCQT_WIDGETSEEK_H_
#if QT_VERSION >= 0x050000
#include <QtWidgets/QWidget>
#else
#include <QtGui/QWidget>
#endif
#include "SharedExportWidgets.h"
class QAbstractSlider;
class QLabel;
class QProgressBar;
class QTimer;
class VlcMediaPlayer;
/*!
\class VlcWidgetSeek WidgetSeek.h VLCQtWidgets/WidgetSeek.h
\ingroup VLCQtWidgets
\brief Seek widget
This is one of VLC-Qt GUI classes.
It provides a display of elapsed time and full time of the media.
*/
class VLCQT_WIDGETS_EXPORT VlcWidgetSeek : public QWidget
{
Q_OBJECT
public:
/*!
\brief VlcWidgetSeek constructor
\param player media player
\param slider widget to be used as slider
\param connectSlider connect the slider to relevant sigals, set to false if you want to handle everything yourself
\param parent seek widget's parent GUI widget
*/
explicit VlcWidgetSeek(VlcMediaPlayer *player,
QWidget *slider = 0,
bool connectSlider = true,
QWidget *parent = 0);
/*!
\brief VlcWidgetSeek constructor
\param slider widget to be used as slider
\param connectSlider connect the slider to relevant sigals, set to false if you want to handle everything yourself
\param parent seek widget's parent GUI widget
*/
explicit VlcWidgetSeek(QWidget *slider,
bool connectSlider,
QWidget *parent = 0);
/*!
\brief VlcWidgetSeek constructor
\param parent seek widget's parent GUI widget
*/
explicit VlcWidgetSeek(QWidget *parent = 0);
/*!
\brief VlcWidgetSeek destructor
*/
~VlcWidgetSeek();
/*!
\brief Get auto-hide option.
\return auto-hide option status, true if enabled
*/
bool autoHide() const { return _autoHide; }
/*!
\brief Set auto-hide option
This option will automatically hide seek widget, if enabled.
\param autoHide new auto-hide option
*/
void setAutoHide(bool autoHide);
/*!
\brief Set media player if initialised without it
\param player media player
*/
virtual void setMediaPlayer(VlcMediaPlayer *player);
/*!
\brief Set slider widget
\param slider widget to be used as slider
\param updateSlider connect the slider to relevant sigals, set to false if you want to handle everything yourself
*/
virtual void setSliderWidget(QWidget *slider,
bool updateSlider = true);
protected slots:
/*!
\brief Update turrent time callback
\param time current time
*/
virtual void updateCurrentTime(int time);
/*!
\brief Update full time callback
\param time full time
*/
virtual void updateFullTime(int time);
protected:
/*!
* \brief Media player
*/
VlcMediaPlayer *_vlcMediaPlayer;
/*!
* \brief Progress bar
*/
QProgressBar *_progress;
private slots:
void end();
private:
void initWidgetSeek(QWidget *slider);
bool _autoHide;
QAbstractSlider *_slider;
bool _connectSlider;
QLabel *_labelElapsed;
QLabel *_labelFull;
};
#endif // VLCQT_WIDGETSEEK_H_
|
#ifndef BASEBATTLEWINDOW_H
#define BASEBATTLEWINDOW_H
#include <QtGui>
#include "../PokemonInfo/battlestructs.h"
#include "client.h"
#include "basebattlewindowinterface.h"
#include "../BattleManager/battledatatypes.h"
#include "../BattleManager/battlecommandmanager.h"
#include <phonon/mediaobject.h>
#include <phonon/audiooutput.h>
class BaseBattleDisplay;
class QScrollDownTextBrowser;
class QClickPBar;
class Log;
class SpectatorWindow;
struct BaseBattleInfo
{
BaseBattleInfo(const PlayerInfo & me, const PlayerInfo &opp, int mode, int myself=0, int opponent=1);
/* name [0] = mine, name[1] = other */
PlayerInfo pInfo[2];
advbattledata_proxy *data;
int mode;
Pokemon::gen gen;
int myself;
int opponent;
int numberOfSlots;
/* Opponent pokemon */
QString name(int x) const {
return pInfo[x].name;
}
};
/* The battle window called by the client, online */
class Client;
class BaseBattleWindow : public BaseBattleWindowInterface
{
Q_OBJECT
PROPERTY(int, ownid)
PROPERTY(bool, started)
PROPERTY(bool, playBattleCries)
PROPERTY(bool, playBattleMusic)
PROPERTY(FullBattleConfiguration, conf)
public:
BaseBattleInfo *myInfo;
const BaseBattleInfo &info() const {
return *myInfo;
}
BaseBattleInfo &info() {
return *myInfo;
}
const advbattledata_proxy &data() const {
return *getBattleData();
}
advbattledata_proxy &data() {
return *getBattleData();
}
virtual void switchToNaught(int){}
BaseBattleWindow(const PlayerInfo &me, const PlayerInfo &opponent, const BattleConfiguration &conf, int ownid);
void init(const PlayerInfo &me, const PlayerInfo &opponent, const BattleConfiguration &conf,
int _ownid);
Pokemon::gen gen() const {
return info().gen;
}
virtual void addSpectator(bool add, int id, const QString &name="");
//void playCry(int pokenum);
QString name(int spot) const;
Q_INVOKABLE int player(int spot) const;
Q_INVOKABLE int opponent(int player) const;
void onKo(int spot);
void onSendOut(int spot, int previndex, ShallowBattlePoke* pokemon, bool silent);
void onSendBack(int spot, bool silent);
void onUseAttack(int spot, int attack, bool);
void onSpectatorJoin(int id, const QString& name);
void onSpectatorLeave(int id);
void onBattleEnd(int res, int winner);
bool musicPlayed() const;
bool flashWhenMoved() const;
virtual void disable();
void receiveData(const QByteArray&);
public slots:
void close();
void sendMessage();
void clickClose();
void delay(qint64 msec=0);
void undelay();
void playCry(int pokemon);
void changeCryVolume(int);
void changeMusicVolume(int);
void ignoreSpectators();
void musicPlayStop();
void enqueueMusic();
void criesProblem(Phonon::State newState);
protected:
int ignoreSpecs;
enum IgnoreMode {
NoIgnore,
IgnoreSpecs,
IgnoreAll
};
QGridLayout *mylayout;
QScrollDownTextBrowser *mychat;
QIRCLineEdit *myline;
QPushButton *myclose, *mysend, *myignore;
QCheckBox *saveLogs;
QCheckBox *musicOn;
QCheckBox *flashWhenMoveDone;
/* The device which outputs the sound */
Phonon::AudioOutput *audioOutput;
/* The media the device listens from */
Phonon::MediaObject *mediaObject;
/* The media sources for the music */
QList<QString> sources;
/* The device for cries */
Phonon::AudioOutput *cryOutput;
/* The media the device listens from for pokemon cries */
Phonon::MediaObject * cryObject;
/* The pokemon cries stored in memory */
QHash<int, QByteArray> cries;
QBuffer cryBuffer;
bool undelayOnSounds;
QSet<int> spectators;
bool blankMessage;
bool battleEnded;
Log *log, *replay;
SpectatorWindow *test;
struct ReplaySavingData {
QElapsedTimer t;
QByteArray data;
};
ReplaySavingData replayData;
BaseBattleWindow();
void init();
void checkAndSaveLog();
void addReplayData(const QByteArray &inf);
void closeEvent(QCloseEvent *);
};
class BaseBattleWindowIns : public BaseBattleWindow, public BattleCommandManager<BaseBattleWindowIns>
{
public:
BaseBattleWindowIns(const PlayerInfo &me, const PlayerInfo &opponent, const BattleConfiguration &conf, int ownid)
: BaseBattleWindow(){
init(me, opponent, conf, ownid);
}
};
#endif // BASEBATTLEWINDOW_H
|
#pragma once
#include "IOpenGLRenderer.h"
#include "ShaderManagerLegacyGL.h"
using wargameEngine::view::IVertexBuffer;
using wargameEngine::view::ICachedTexture;
using wargameEngine::view::IShaderManager;
class CLegacyGLRenderer : public IOpenGLRenderer
{
public:
using TextureMipMaps = wargameEngine::view::TextureMipMaps;
CLegacyGLRenderer();
virtual void RenderArrays(RenderMode mode, array_view<CVector3f> const& vertices, array_view<CVector3f> const& normals, array_view<CVector2f> const& texCoords) override;
virtual void RenderArrays(RenderMode mode, array_view<CVector2i> const& vertices, array_view<CVector2f> const& texCoords) override;
virtual void DrawIndexed(wargameEngine::view::IVertexBuffer& buffer, size_t count, size_t begin = 0, size_t instances = 0) override;
virtual void Draw(IVertexBuffer& buffer, size_t count, size_t begin = 0, size_t instances = 0) override;
virtual void DrawIndirect(IVertexBuffer& buffer, const array_view<IndirectDraw>& indirectList, bool indexed) override;
virtual void SetIndexBuffer(IVertexBuffer& buffer, const unsigned int* indexPtr, size_t indexesSize) override;
virtual void AddVertexAttribute(IVertexBuffer& buffer, const std::string& attribute, int elementSize, size_t count, IShaderManager::Format type, const void* values, bool perInstance = false) override;
virtual void PushMatrix() override;
virtual void PopMatrix() override;
virtual void Translate(const CVector3f& delta) override;
virtual void Translate(int dx, int dy, int dz = 0) override;
virtual void Rotate(float angle, const CVector3f& axis) override;
virtual void Rotate(const CVector3f& rotations) override;
virtual void Scale(float scale) override;
virtual const float* GetViewMatrix() const override;
virtual const float* GetModelMatrix() const override;
virtual void SetModelMatrix(const float* matrix) override;
virtual void LookAt(CVector3f const& position, CVector3f const& direction, CVector3f const& up) override;
virtual void SetTexture(const wargameEngine::Path& texture, bool forceLoadNow = false, int flags = 0) override;
virtual void SetTexture(ICachedTexture const& texture, TextureSlot slot = TextureSlot::Diffuse) override;
virtual void UnbindTexture(TextureSlot slot = TextureSlot::Diffuse) override;
virtual void RenderToTexture(std::function<void() > const& func, ICachedTexture & texture, unsigned int width, unsigned int height) override;
virtual std::unique_ptr<ICachedTexture> CreateTexture(const void * data, unsigned int width, unsigned int height, CachedTextureType type = CachedTextureType::RGBA) override;
virtual void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 0xff) override;
virtual void SetColor(const float * color) override;
virtual void SetMaterial(const float * ambient, const float * diffuse, const float * specular, float shininess) override;
virtual std::unique_ptr<IVertexBuffer> CreateVertexBuffer(const float * vertex = nullptr, const float * normals = nullptr, const float * texcoords = nullptr, size_t size = 0, bool temp = false) override;
virtual std::unique_ptr<wargameEngine::view::IFrameBuffer> CreateFramebuffer() const override;
virtual std::unique_ptr<wargameEngine::view::IOcclusionQuery> CreateOcclusionQuery() override;
virtual wargameEngine::view::IShaderManager& GetShaderManager() override;
virtual void SetTextureManager(wargameEngine::view::TextureManager & textureManager) override;
virtual void WindowCoordsToWorldVector(wargameEngine::view::IViewport & viewport, int x, int y, CVector3f & start, CVector3f & end) const override;
virtual void WorldCoordsToWindowCoords(wargameEngine::view::IViewport & viewport, CVector3f const& worldCoords, int& x, int& y) const override;
virtual void SetNumberOfLights(size_t count) override;
virtual void SetUpLight(size_t index, CVector3f const& position, const float * ambient, const float * diffuse, const float * specular) override;
virtual float GetMaximumAnisotropyLevel() const override;
virtual const float* GetProjectionMatrix() const override;
virtual void EnableDepthTest(bool read, bool write) override;
virtual void EnableColorWrite(bool rgb, bool alpha) override;
virtual void EnableBlending(bool enable) override;
virtual void SetUpViewport(unsigned int viewportX, unsigned int viewportY, unsigned int viewportWidth, unsigned int viewportHeight, float viewingAngle, float nearPane = 1.0f, float farPane = 1000.0f) override;
virtual void EnablePolygonOffset(bool enable, float factor = 0.0f, float units = 0.0f) override;
virtual void ClearBuffers(bool color = true, bool depth = true) override;
virtual void DrawIn2D(std::function<void()> const& drawHandler) override;
virtual std::unique_ptr<ICachedTexture> CreateEmptyTexture(bool cubemap = false) override;
virtual void SetTextureAnisotropy(float value = 1.0f) override;
virtual void UploadTexture(ICachedTexture & texture, unsigned char * data, size_t width, size_t height, unsigned short bpp, int flags, TextureMipMaps const& mipmaps = TextureMipMaps()) override;
virtual void UploadCompressedTexture(ICachedTexture & texture, unsigned char * data, size_t width, size_t height, size_t size, int flags, TextureMipMaps const& mipmaps = TextureMipMaps()) override;
virtual void UploadCubemap(ICachedTexture & texture, TextureMipMaps const& sides, unsigned short bpp, int flags) override;
virtual bool Force32Bits() const override;
virtual bool ForceFlipBMP() const override;
virtual bool ConvertBgra() const override;
virtual std::string GetName() const override;
virtual bool SupportsFeature(Feature feature) const override;
virtual void EnableMultisampling(bool enable) override;
private:
void ResetViewMatrix();
wargameEngine::view::TextureManager* m_textureManager;
CShaderManagerLegacyGL m_shaderManager;
mutable float m_matrix[16];
}; |
/* Copyright (C) 2008 Sean D'Epagnier <sean@depagnier.com>
*
* This Program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* For more information on the GPL, please go to:
* http://www.gnu.org/copyleft/gpl.html
*/
#include <gfx/gfx.h>
#include "internal.h"
void gfx_circle(int r)
{
int x0 = curx, y0 = cury;
int f = 1 - r;
int dx = 0;
int dy = -r;
int x = 0;
int y = r;
int sy = 0;
/* draw for edges */
gfx_putpixel(x0, y0 + r);
gfx_putpixel(x0, y0 - r);
gfx_putpixel(x0 + r, y0);
gfx_putpixel(x0 - r, y0);
while(x < y)
{
if(f >= 0)
{
y--;
dy++;
f += dy;
}
x++;
dx++;
f += dx;
/* draw all 8 octants */
gfx_putpixel(x0 + x, y0 + y);
gfx_putpixel(x0 - x, y0 + y);
gfx_putpixel(x0 + x, y0 - y);
gfx_putpixel(x0 - x, y0 - y);
gfx_putpixel(x0 + y, y0 + x);
gfx_putpixel(x0 - y, y0 + x);
gfx_putpixel(x0 + y, y0 - x);
gfx_putpixel(x0 - y, y0 - x);
}
}
|
// ******************************************************************************
// Filename: ModMenu.h
// Project: Vox
// Author: Steven Ball
//
// Purpose:
//
// Revision History:
// Initial Revision - 12/10/14
//
// Copyright (c) 2005-2016, Steven Ball
// ******************************************************************************
#pragma once
#include "../FrontendPage.h"
#include "../../Inventory/InventoryManager.h"
#include "../../gui/guiwindow.h"
#include "../../gui/optioncontroller.h"
#include "../../gui/scrollbar.h"
#include "../../gui/draggablerenderrectangle.h"
#include "../../gui/formattedlabel.h"
#include "../../gui/openglgui.h"
class ModMenu;
class ModButtonData
{
public:
ModMenu* m_pModMenu;
Button* m_pModButton;
string m_modName;
string m_modDescription;
string m_modAuthor;
bool m_toggled;
bool m_allowToggleOff;
bool m_allowMultipleSelection;
bool m_gameplayButton;
bool m_graphicsButton;
bool m_soundButton;
bool m_HUDButton;
bool m_miscButton;
};
class ModMenu : public FrontendPage
{
public:
/* Public methods */
ModMenu(Renderer* pRenderer, OpenGLGUI* pGUI, FrontendManager* pFrontPageManager, int windowWidth, int windowHeight);
~ModMenu();
void Reset();
void ClearModButtonData();
void SetWindowDimensions(int windowWidth, int windowHeight);
// Pre-tick the already loaded mods and set them as toggled
void SelectLoadedMods();
// Are we returning to the main menu, or are we in the game?
void SetReturnToMainMenu(bool mainMenu);
// Skinning
void SkinGUI();
void UnSkinGUI();
// Load unload
void Load();
void Unload();
void CreateGameplayModButtons();
void RemoveGameplayModButtons();
void CreateGraphicsModButtons();
void RemoveGraphicsModButtons();
void CreateSoundModButtons();
void RemoveSoundModButtons();
void CreateHUDModButtons();
void RemoveHUDModButtons();
void CreateMiscModButtons();
void RemoveMiscModButtons();
// Tooltips
void UpdateToolTipAppear(float dt);
void ShowTooltip(ModButtonData* pModButtonData);
void HideTooltip();
// Update
void Update(float dt);
// Render
void Render();
void Render2D();
protected:
/* Protected methods */
static void _CloseExitPressed(void *apData);
void CloseExitPressed();
static void _GameplayTabPressed(void *pData);
void GameplayTabPressed();
static void _GraphicsTabPressed(void *pData);
void GraphicsTabPressed();
static void _SoundTabPressed(void *pData);
void SoundTabPressed();
static void _GUITabPressed(void *pData);
void GUITabPressed();
static void _MiscTabPressed(void *pData);
void MiscTabPressed();
static void _ModButtonPressed(void *apData);
void ModButtonPressed(ModButtonData* pModButtonData);
static void _ModButtonEntered(void *apData);
void ModButtonEntered(ModButtonData* pModButtonData);
static void _ModButtonExited(void *apData);
void ModButtonExited(ModButtonData* pModButtonData);
private:
/* Private methods */
public:
/* Public members */
protected:
/* Protected members */
private:
/* Private members */
bool m_loaded;
int m_modWindowWidth;
int m_modWindowHeight;
int m_titlebarWidth;
int m_titlebarHeight;
// Are we in the front-end or in the game
bool m_returnToMainMenu;
int m_modButtonWidth;
int m_modButtonheight;
int m_modButtonSpace;
// Mod window
GUIWindow* m_pModWindow;
Icon* m_pTitleBarIcon;
Icon* m_pTitleBarBackgroundIcon;
Icon* m_pModWindowBackgroundIcon;
Button* m_pCloseExitButton;
// Tabs
OptionController* m_pModsModeController;
OptionBox* m_pGameplayMode;
OptionBox* m_pGraphicsMode;
OptionBox* m_pSoundMode;
OptionBox* m_pHUDMode;
OptionBox* m_pMiscMode;
ScrollBar* m_pModsScrollbar;
std::vector<Button*> m_vpGameplayModButtons;
std::vector<Button*> m_vpGraphicsModButtons;
std::vector<Button*> m_vpSoundModButtons;
std::vector<Button*> m_vpHUDModButtons;
std::vector<Button*> m_vpMiscModButtons;
std::vector<ModButtonData*> m_vpModButtonData;
// Tooltip
Icon* m_pTooltipBackground_Common;
Icon* m_pTooltipBackground_Uncommon;
Icon* m_pTooltipBackground_Magical;
Icon* m_pTooltipBackground_Rare;
Icon* m_pTooltipBackground_Epic;
Label* m_pTooltipNameLabel;
FormattedLabel* m_pTooltipDescriptionLabel;
Label* m_pTooltipSlotLabel;
Label* m_pTooltipQualityLabel;
bool m_toolTipVisible;
int m_tooltipWidth;
int m_tooltipHeight;
int m_tooltipDescBorder;
ItemQuality m_tooltipQuality;
float m_tooltipAppearDelayTimer;
bool m_toolTipComponentsAdded;
};
|
#ifndef BBT_MENUES_H
#define BBT_MENUES_H
// This five "enums" are uses in menu.c for control who is the current option
enum
{
START_GAME,
SCORE_TAB,
HISTORY,
TUTORIAL,
EXIT
};
enum
{
EASY,
NORMAL,
HARD,
VERY_HARD,
HOPELESS
};
enum
{
FIRST,
SECOND,
THIRD
};
enum
{
MENU,
CLEAN
};
enum
{
RESUME,
QUIT
};
enum
{
PAGE1,
PAGE2,
PAGE3,
PAGE4,
PAGE5,
PAGE6,
PAGE7,
PAGE8,
PAGE9,
PAGE10
};
#endif
|
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<time.h>
#define pi 3.14159265
typedef struct {
double re;
double im;
}cmplx;
cmplx cmul(cmplx A,cmplx B) {
cmplx C;
C.re=A.re*B.re-A.im*B.im;
C.im=A.re*B.im+A.im*B.re;
return C;
}
void fft(int a[],int n,cmplx f[]) {
int j,k;
int *e,*o;
cmplx *ef,*of,omegak,omega,cmu;
ef=(cmplx*)malloc(n*sizeof(cmplx));
of=(cmplx*)malloc(n*sizeof(cmplx));
if(n==1){ f[0].re=f[1].re=a[0]; f[0].im=f[1].im=0; return; }
e=(int*)malloc(n*sizeof(int));
o=(int*)malloc(n*sizeof(int));
omega.re=cos(1.0*pi/n);omega.im=sin(1.0*pi/n);
omegak.re=1;omegak.im=0;
for(j=k=0;k<n;j++,k+=2){ e[j]=a[k]; o[j]=a[k+1]; }
fft(e,n/2,ef);
fft(o,n/2,of);
for(k=0;k<n;k++) {
cmu=cmul(omegak,of[k]);
f[k].re=ef[k].re+cmu.re;
f[k].im=ef[k].im+cmu.im;
f[k+n].re=ef[k].re-cmu.re;
f[k+n].im=ef[k].im-cmu.im;
omegak=cmul(omegak,omega);
}
return;
}
void ifft (cmplx a[],int n,cmplx f[]) {
int j,k;
cmplx omegak,omega,*ef,*of,*e,*o,cmu;
ef=(cmplx*)malloc(n/2*sizeof(cmplx));
of=(cmplx*)malloc(n/2*sizeof(cmplx));
e=(cmplx*)malloc(n/2*sizeof(cmplx));
o=(cmplx*)malloc(n/2*sizeof(cmplx));
if(n==1){ f[0].re=a[0].re; f[0].im=a[0].im; return; }
for(j=k=0;k<n;j++,k+=2){ e[j].re=a[k].re; e[j].im=a[k].im; o[j].re=a[k+1].re; o[j].im=a[k+1].im; }
omega.re=cos(2*pi/n); omega.im=-1*sin(2*pi/n);
omegak.re=1; omegak.im=0;
ifft(e,n/2,ef);
ifft(o,n/2,of);
for(k=0;k<n/2;k++) {
cmu=cmul(omegak,of[k]);
f[k].re=ef[k].re+cmu.re;
f[k].im=ef[k].im+cmu.im;
f[k+n/2].re=ef[k].re-cmu.re;
f[k+n/2].im=ef[k].im-cmu.im;
omegak=cmul(omegak,omega);
}
return;
}
int main() {
int i,d,temp=0,n;
int *a,*b,*c;
cmplx *af,*bf,*cf,*cif;
printf("Enter the number of digits : ");
scanf("%d",&n);
if(n<1) { printf("Well, that makes no sense!"); return; }
for(i=0;pow(2,i)<n;i++) {}
d=pow(2,i);
a=(int*)malloc(d*sizeof(int));
b=(int*)malloc(d*sizeof(int));
c=(int*)malloc(2*d*sizeof(int));
af=(cmplx*)malloc(2*d*sizeof(cmplx));
bf=(cmplx*)malloc(2*d*sizeof(cmplx));
cf=(cmplx*)malloc(2*d*sizeof(cmplx));
cif=(cmplx*)malloc(2*d*sizeof(cmplx));
for(i=0;i<d-n;i++){
a[i]=0;
b[i]=0;
}
time_t t;
srand((unsigned)time(&t));
for(i=d-n;i<d;i++){
a[i]=rand()%10;
b[i]=rand()%10;
}
printf("The first number is : ");
for(i=d-n;i<d;i++){
printf("%d",a[i]);
}
printf("\nThe second number is : ");
for(i=d-n;i<d;i++){
printf("%d",b[i]);
}
printf("\n");
fft(a,d,af);
fft(b,d,bf);
for(i=0;i<2*d;i++){ cf[i]=cmul(af[i],bf[i]); }
ifft(cf,2*d,cif);
for(i=0;i<2*d;i++) c[i]=0;
for(i=2*d-1;i>=0;i--){ cif[i].re=cif[i].re/(2*d); c[i]=(int)(cif[i].re+0.5); }
for(i=2*d-1;i>0;i--){ c[i-1]=c[i-1]+c[i]/10; c[i]=c[i]%10; }
printf("The Product is :");
for(i=2*d-2*n;i<2*d-1;i++) printf("%d",c[i]);
printf("\n");
return 0;
}
|
#ifndef SIMPLE_MODBUS_SLAVE_SOFTWARESERIAL_H
#define SIMPLE_MODBUS_SLAVE_SOFTWARESERIAL_H
// SimpleModbusSlaveV10
/*
SimpleModbusSlave allows you to communicate
to any slave using the Modbus RTU protocol.
This implementation DOES NOT fully comply with the Modbus specifications.
Specifically the frame time out have not been implemented according
to Modbus standards. The code does however combine the check for
inter character time out and frame time out by incorporating a maximum
time out allowable when reading from the message stream.
SimpleModbusSlave implements an unsigned int return value on a call to modbus_update().
This value is the total error count since the slave started. It's useful for fault finding.
This code is for a Modbus slave implementing functions 3, 6 and 16
function 3: Reads the binary contents of holding registers (4X references)
function 6: Presets a value into a single holding register (4X reference)
function 16: Presets values into a sequence of holding registers (4X references)
All the functions share the same register array.
Note:
The Arduino serial ring buffer changed in V1.05 it is now 64 bytes or 32 unsigned int registers.
Most of the time you will connect the arduino to a master via serial
using a MAX485 or similar.
In a function 3 request the master will attempt to read from your
slave and since 5 bytes is already used for ID, FUNCTION, NO OF BYTES
and two BYTES CRC the master can only request 58 bytes or 29 registers.
In a function 16 request the master will attempt to write to your
slave and since a 9 bytes is already used for ID, FUNCTION, ADDRESS,
NO OF REGISTERS, NO OF BYTES and two BYTES CRC the master can only write
54 bytes or 27 registers.
Using a USB to Serial converter the maximum bytes you can send is
limited to its internal buffer which differs between manufactures.
The functions included here have been derived from the
Modbus Specifications and Implementation Guides
http://www.modbus.org/docs/Modbus_over_serial_line_V1_02.pdf
http://www.modbus.org/docs/Modbus_Application_Protocol_V1_1b.pdf
http://www.modbus.org/docs/PI_MBUS_300.pdf
*/
#include "Arduino.h"
#include "SoftwareSerial.h"
// function definitions
unsigned int modbus_update();
void modbus_update_comms(long baud, unsigned char byteFormat, unsigned char _slaveID);
void modbus_configure(SoftwareSerial *SerialPort,
long baud,
unsigned char byteFormat,
unsigned char _slaveID,
unsigned char _TxEnablePin,
unsigned int _holdingRegsSize,
unsigned int* _regs);
#endif
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#if !defined(OpusParser_h_)
#define OpusParser_h_
#include "nsTArray.h"
#include "nsString.h"
namespace mozilla {
class OpusParser
{
public:
OpusParser();
bool DecodeHeader(unsigned char* aData, size_t aLength);
bool DecodeTags(unsigned char* aData, size_t aLength);
// Various fields from the Ogg Opus header.
int mRate; // Sample rate the decoder uses (always 48 kHz).
uint32_t mNominalRate; // Original sample rate of the data (informational).
int mChannels; // Number of channels the stream encodes.
uint16_t mPreSkip; // Number of samples to strip after decoder reset.
#ifdef MOZ_SAMPLE_TYPE_FLOAT32
float mGain; // Gain to apply to decoder output.
#else
int32_t mGain_Q16; // Gain to apply to the decoder output.
#endif
int mChannelMapping; // Channel mapping family.
int mStreams; // Number of packed streams in each packet.
int mCoupledStreams; // Number of packed coupled streams in each packet.
unsigned char mMappingTable[255]; // Channel mapping table.
// Granule position (end sample) of the last decoded Opus packet. This is
// used to calculate the amount we should trim from the last packet.
int64_t mPrevPacketGranulepos;
nsTArray<nsCString> mTags; // Unparsed comment strings from the header.
nsCString mVendorString; // Encoder vendor string from the header.
};
} // namespace mozilla
#endif
|
#ifndef SECONDARY_H_
#define SECONDARY_H_
#include <boost/filesystem.hpp>
#include "primary/aktualizr.h"
namespace Primary {
void initSecondaries(Aktualizr& aktualizr, const boost::filesystem::path& config_file);
} // namespace Primary
#endif // SECONDARY_H_
|
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* IBM Corporation
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsCP1125ToUnicode_h___
#define nsCP1125ToUnicode_h___
#include "nsISupports.h"
/**
* A character set converter from CP1125 to Unicode.
*/
NS_METHOD
nsCP1125ToUnicodeConstructor(nsISupports *aOuter, REFNSIID aIID,
void **aResult);
#endif /* !nsCP1125ToUnicode_h___ */
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.