text
stringlengths
4
6.14k
/* * Tlf - contest logging program for amateur radio operators * Copyright (C) 2020 Zoltan Csahok <ha5cqz@freemail.hu> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <stdbool.h> #include <string.h> #include "callinput.h" #include "gettxinfo.h" #include "globalvars.h" #include "time_update.h" #include "tlf.h" typedef struct { freq_t freq; cqmode_t cqmode; char hiscall[20]; } mem_t; static mem_t trxmem = {.freq = 0, .cqmode = NONE}; void memory_store() { trxmem.freq = freq; trxmem.cqmode = cqmode; strcpy(trxmem.hiscall, hiscall); force_show_freq = true; } void memory_recall() { if (trxmem.freq <= 0) { return; } set_outfreq(trxmem.freq); send_bandswitch(trxmem.freq); cqmode = trxmem.cqmode; strcpy(hiscall, trxmem.hiscall); force_show_freq = true; } void memory_pop() { if (trxmem.freq <= 0) { return; } memory_recall(); trxmem.freq = 0; trxmem.cqmode = NONE; } void memory_store_or_pop() { if (trxmem.freq <= 0) { memory_store(); } else { memory_pop(); } } void memory_swap() { if (trxmem.freq <= 0) { return; } freq_t tmp_freq = freq; cqmode_t tmp_cqmode = cqmode; char tmp_hiscall[sizeof(trxmem.hiscall)]; strcpy(tmp_hiscall, hiscall); memory_recall(); trxmem.freq = tmp_freq; trxmem.cqmode = tmp_cqmode; strcpy(trxmem.hiscall, tmp_hiscall); } freq_t memory_get_freq() { return trxmem.freq; } cqmode_t memory_get_cqmode() { return trxmem.cqmode; }
#include <sys/types.h> #include <sys/socket.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include <unistd.h> #include <netinet/in.h> #include <unistd.h> #include <sys/stat.h> #include <fcntl.h> #include <dirent.h> typedef struct { char a[20][30]; int size; }buddy_dir; void *trave_dir(void *b,int depth) { buddy_dir *data = (buddy_dir *)b; DIR *dir; struct dirent *file; struct stat sb; char *path = "./"; /* * open dir */ dir = opendir(path); if(!dir) { printf("Error opendir %s\n",path); exit(1); } while((file = readdir(dir)) != NULL) { if(strncmp(file->d_name,".",1) == 0) continue; strcpy(data->a[data->size++],file->d_name); printf("size :%d\n",data->size); if(stat(file->d_name,&sb) >= 0 && S_ISDIR(sb.st_mode) && depth <= 3) { trave_dir(data,depth + 1); } } closedir(dir); return data; } int main() { buddy_dir *data = malloc(sizeof(buddy_dir)); data->size = 0; data = (buddy_dir *)trave_dir(data,0); while(data->size-- >0) printf("aaa%s\n",data->a[data->size]); return 0; }
#ifndef GLOBAL_H #define GLOBAL_H #define TILE_HEIGHT 32 #define TILE_WIDTH 32 #define MIN(x, y) ((x<y)?x:y) #define MAX(x, y) ((x>y)?x:y) #define SIGN(x) ((x>0)?1:-1) enum ItemType { kBlock = 0, kBox, kCoin, kLever, kButton, kSwitch, kDoor, kMovingPlatform, kGate, kClock, kTime_Lever, kSlope30Right = 11, kSlope45Right, kSlope60Right, kSlope30Left = 14, kSlope45Left, kSlope60Left, kGoomba = 17, kMainCharacter = 18, kLadder = 19, kLeverFlipped = 20, kDoorOpen = 21, kBoxButton = 22, kTeleStation = 23, kTurretRight = 24, kTurretLeft = 25, kBossEnemy = 26, kTeleReceiver = 27, kNextLevel = 28, kPrevLevel = 29, kEnemy2 = 30}; #define SCALINGFACTOR 1.0/16.0 #define PX_TO_M(x) (SCALINGFACTOR * (x)) #define M_TO_PX(x) ((x) * 16.0) #endif // GLOBAL_H
/* * Copyright (c) 2003, Intel Corporation. All rights reserved. * Created by: julie.n.fleischer REMOVE-THIS AT intel DOT com * This file is licensed under the GPL license. For the full content * of this license, see the COPYING file at the top level of this * source tree. */ /* * Test that mq_timedsend() returns errno == EBADF if mqdes is not open for * writing. */ #include <stdio.h> #include <mqueue.h> #include <fcntl.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include <string.h> #include <errno.h> #include <time.h> #include "posixtest.h" #define NAMESIZE 50 #define MSGSTR "0123456789" int main() { char qname[NAMESIZE]; const char *msgptr = MSGSTR; struct timespec ts; mqd_t queue; int unresolved=0, failure=0; sprintf(qname, "/mq_timedsend_11-2_%d", getpid()); queue = mq_open(qname, O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR, NULL); if (queue == (mqd_t)-1) { perror("mq_open() did not return success"); return PTS_UNRESOLVED; } ts.tv_sec=time(NULL)+1; ts.tv_nsec=0; if (mq_timedsend(queue, msgptr, strlen(msgptr), 1, &ts) != -1) { printf("mq_timedsend() did not return -1 on invalid queue\n"); failure=1; } if (errno != EBADF) { printf("errno != EBADF\n"); failure = 1; } if (mq_close(queue) != 0) { perror("mq_close() did not return success"); unresolved=1; } if (mq_unlink(qname) != 0) { perror("mq_unlink() did not return success"); unresolved=1; } if (failure==1) { printf("Test FAILED\n"); return PTS_FAIL; } if (unresolved==1) { printf("Test UNRESOLVED\n"); return PTS_UNRESOLVED; } printf("Test PASSED\n"); return PTS_PASS; }
#include "serv_global.h" void serv_handle_error() {} WORD serv_get_idx(WORD code_seg_base) { WORD serv_idx; ptr_serv_table ptr_serv_table_tmp; ptr_serv_table_tmp = (ptr_serv_table)SERV_REGISTER_TABLE_BASE; // 这里还要对全局变量 CODE_SEG_LIMIT 和 PARA_SEG_BASE 赋值 for(serv_idx = 0; serv_idx < SERV_MAX_NUM; serv_idx ++) { if((ptr_serv_table_tmp -> CODE_SEG_BASE) == code_seg_base) { CODE_SEG_LIMIT = ptr_serv_table_tmp -> CODE_SEG_LIMIT; PARA_SEG_BASE = ptr_serv_table_tmp -> PARA_SEG_BASE; break; } ptr_serv_table_tmp ++; } // 在获得了全局变量 PARA_SEG_BASE 后,就可以得到要存储操作码的地址 OPT_CODE_BASE 和要存储返回值的地址 RETURN_CODE_BASE OPT_CODE_BASE = PARA_SEG_BASE; RETURN_CODE_BASE = PARA_SEG_BASE + 4; return serv_idx; }
#ifndef SEEN_SP_GRADIENT_IMAGE_H #define SEEN_SP_GRADIENT_IMAGE_H /** * A simple gradient preview * * Author: * Lauris Kaplinski <lauris@kaplinski.com> * * Copyright (C) 2001-2002 Lauris Kaplinski * Copyright (C) 2001 Ximian, Inc. * * Released under GNU GPL, read the file 'COPYING' for more information */ #include <gtk/gtk.h> class SPGradient; #include <sigc++/connection.h> #define SP_TYPE_GRADIENT_IMAGE (sp_gradient_image_get_type ()) #define SP_GRADIENT_IMAGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_GRADIENT_IMAGE, SPGradientImage)) #define SP_GRADIENT_IMAGE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_GRADIENT_IMAGE, SPGradientImageClass)) #define SP_IS_GRADIENT_IMAGE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_GRADIENT_IMAGE)) #define SP_IS_GRADIENT_IMAGE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_GRADIENT_IMAGE)) struct SPGradientImage { GtkWidget widget; SPGradient *gradient; sigc::connection release_connection; sigc::connection modified_connection; }; struct SPGradientImageClass { GtkWidgetClass parent_class; }; GType sp_gradient_image_get_type (void); GtkWidget *sp_gradient_image_new (SPGradient *gradient); GdkPixbuf *sp_gradient_to_pixbuf (SPGradient *gr, int width, int height); void sp_gradient_image_set_gradient (SPGradientImage *gi, SPGradient *gr); #endif /* Local Variables: mode:c++ c-file-style:"stroustrup" c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 :
#define ERG_DPRAM_PAGE_SIZE 0x2000 #define BOOT_IMG_SIZE 4096 #define ERG_DPRAM_FILL_SIZE (ERG_DPRAM_PAGE_SIZE - BOOT_IMG_SIZE) #define ERG_TO_HY_BUF_SIZE 0x0E00 #define ERG_TO_PC_BUF_SIZE 0x0E00 typedef struct ErgDpram_tag { unsigned char ToHyBuf[ERG_TO_HY_BUF_SIZE]; unsigned char ToPcBuf[ERG_TO_PC_BUF_SIZE]; unsigned char bSoftUart[SIZE_RSV_SOFT_UART]; unsigned char volatile ErrLogMsg[64]; unsigned short volatile ToHyChannel; unsigned short volatile ToHySize; unsigned char volatile ToHyFlag; unsigned char volatile ToPcFlag; unsigned short volatile ToPcChannel; unsigned short volatile ToPcSize; unsigned char bRes1DBA[0x1E00 - 0x1DFA]; unsigned char bRestOfEntryTbl[0x1F00 - 0x1E00]; unsigned long TrapTable[62]; unsigned char bRes1FF8[0x1FFB - 0x1FF8]; unsigned char ToPcIntMetro; unsigned char volatile ToHyNoDpramErrLog; unsigned char bRes1FFD; unsigned char ToPcInt; unsigned char ToHyInt; } tErgDpram; #define PCI9050_INTR_REG 0x4C #define PCI9050_USER_IO 0x51 #define PCI9050_INTR_REG_EN1 0x01 #define PCI9050_INTR_REG_POL1 0x02 #define PCI9050_INTR_REG_STAT1 0x04 #define PCI9050_INTR_REG_ENPCI 0x40 #define PCI9050_USER_IO_EN3 0x02 #define PCI9050_USER_IO_DIR3 0x04 #define PCI9050_USER_IO_DAT3 0x08 #define PCI9050_E1_RESET ( PCI9050_USER_IO_DIR3) #define PCI9050_E1_RUN (PCI9050_USER_IO_DAT3|PCI9050_USER_IO_DIR3)
#ifndef LIBVOLUME_WINDOW_EVENTMANAGER_H #define LIBVOLUME_WINDOW_EVENTMANAGER_H //----STANDARD---- #include "vector" namespace LibVolume { namespace Window { struct WindowSizeState { public: int width; int height; }; struct KeyboardState { public: bool key_w; bool key_w_pressed; bool key_a; bool key_a_pressed; bool key_s; bool key_s_pressed; bool key_d; bool key_d_pressed; bool key_q; bool key_q_pressed; bool key_e; bool key_e_pressed; bool key_f; bool key_f_pressed; bool key_l; bool key_l_pressed; bool key_up; bool key_up_pressed; bool key_left; bool key_left_pressed; bool key_down; bool key_down_pressed; bool key_right; bool key_right_pressed; bool key_space; bool key_space_pressed; bool key_shift; bool key_shift_pressed; bool key_enter; bool key_enter_pressed; }; class EventManager { public: unsigned long long time; int window_width = 640; int window_height = 480; WindowSizeState window_size_state; KeyboardState keyboard_state; void tick(); WindowSizeState* getWindowSizeState(); KeyboardState* getKeyboardState(); }; } } #endif
/* -*- c++ -*- * modelinfodialog.h * * Header for the ModelInfoDialog classes * Copyright (C) 2002 lignum Computing, Inc. <lignumcad@lignumcomputing.com> * $Id$ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /**************************************************************************** ** ui.h extension file, included from the uic-generated form implementation. ** ** If you wish to add, delete or rename slots use Qt Designer which will ** update this file, preserving your code. Create an init() slot in place of ** a constructor, and a destroy() slot in place of a destructor. *****************************************************************************/ /*! * This is a little gloss on entering a new model name. The file name string is * updated as the model name is typed. * \param text current text of model name widget. */ void ModelInfoDialog::modelNameEdit_textChanged( const QString & text ) { modelFileChooser->setFileName( text + ".lcad" ); modelFileChooser->setEdited( true ); } void ModelInfoDialog::buttonHelp_clicked() { QWhatsThis::display( tr( "<p><b>Edit Model Information</b></p>\ <p>Modify the basic information about the model. \ (This is sometimes called the <i>metadata</i>.) \ The metadata includes:\ <ul>\ <li>Model name</li>\ <li>File to save the model in (defaults to <i>ModelName</i>.lcad)</li>\ <li>Version and revision numbers</li>\ <li>Optional description of the model</li>\ <li>Date and time of creation</li>\ <li>Date and time of last modification</li>\ </ul>\ The creation and last modification times \ are updated automatically.</p>\ <p>When the fields are modified to your satisfaction, \ click the <b>OK</b> button (or press <b>Enter</b> or \ <b>Alt+O</b>) to \ apply the changes and exit the dialog.</p>\ <p>If you click the <b>Cancel</b> button \ (or press <b>ESC</b> or <b>Alt+C</b>), \ no changes to the model will be made.</p>" ) ); }
/* $XFree86: xc/lib/GL/dri/xf86dri.h,v 1.8 2002/10/30 12:51:25 alanh Exp $ */ /************************************************************************** Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. Copyright 2000 VA Linux Systems, Inc. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sub license, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice (including the next paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **************************************************************************/ /** * \file xf86dri.h * Protocol numbers and function prototypes for DRI X protocol. * * \author Kevin E. Martin <martin@valinux.com> * \author Jens Owen <jens@tungstengraphics.com> * \author Rickard E. (Rik) Faith <faith@valinux.com> */ #ifndef _XF86DRI_H_ #define _XF86DRI_H_ #include <X11/Xfuncproto.h> #include <xf86drm.h> #define X_XF86DRIQueryVersion 0 #define X_XF86DRIQueryDirectRenderingCapable 1 #define X_XF86DRIOpenConnection 2 #define X_XF86DRICloseConnection 3 #define X_XF86DRIGetClientDriverName 4 #define X_XF86DRICreateContext 5 #define X_XF86DRIDestroyContext 6 #define X_XF86DRICreateDrawable 7 #define X_XF86DRIDestroyDrawable 8 #define X_XF86DRIGetDrawableInfo 9 #define X_XF86DRIGetDeviceInfo 10 #define X_XF86DRIAuthConnection 11 #define X_XF86DRIOpenFullScreen 12 /* Deprecated */ #define X_XF86DRICloseFullScreen 13 /* Deprecated */ #define XF86DRINumberEvents 0 #define XF86DRIClientNotLocal 0 #define XF86DRIOperationNotSupported 1 #define XF86DRINumberErrors (XF86DRIOperationNotSupported + 1) #ifndef _XF86DRI_SERVER_ _XFUNCPROTOBEGIN Bool XF86DRIQueryExtension(Display * dpy, int *event_base, int *error_base); Bool XF86DRIQueryVersion(Display * dpy, int *majorVersion, int *minorVersion, int *patchVersion); Bool XF86DRIQueryDirectRenderingCapable(Display * dpy, int screen, Bool *isCapable); Bool XF86DRIOpenConnection(Display * dpy, int screen, drm_handle_t * hSAREA, char **busIDString); Bool XF86DRIAuthConnection(Display * dpy, int screen, drm_magic_t magic); Bool XF86DRICloseConnection(Display * dpy, int screen); Bool XF86DRIGetClientDriverName(Display * dpy, int screen, int *ddxDriverMajorVersion, int *ddxDriverMinorVersion, int *ddxDriverPatchVersion, char **clientDriverName); Bool XF86DRICreateContext(Display * dpy, int screen, Visual * visual, XID *ptr_to_returned_context_id, drm_context_t * hHWContext); Bool XF86DRICreateContextWithConfig(Display * dpy, int screen, int configID, XID *ptr_to_returned_context_id, drm_context_t * hHWContext); extern GLboolean XF86DRIDestroyContext(Display * dpy, int screen, XID context_id); extern GLboolean XF86DRICreateDrawable(Display * dpy, int screen, XID drawable, drm_drawable_t * hHWDrawable); extern GLboolean XF86DRIDestroyDrawable(Display * dpy, int screen, XID drawable); Bool XF86DRIGetDrawableInfo(Display * dpy, int screen, Drawable drawable, unsigned int *index, unsigned int *stamp, int *X, int *Y, int *W, int *H, int *numClipRects, drm_clip_rect_t ** pClipRects, int *backX, int *backY, int *numBackClipRects, drm_clip_rect_t ** pBackClipRects); Bool XF86DRIGetDeviceInfo(Display * dpy, int screen, drm_handle_t * hFrameBuffer, int *fbOrigin, int *fbSize, int *fbStride, int *devPrivateSize, void **pDevPrivate); _XFUNCPROTOEND #endif /* _XF86DRI_SERVER_ */ #endif /* _XF86DRI_H_ */
/* an_solver.c Copyright (C) 2017 Ferdinand Blomqvist This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. Written by Ferdinand Blomqvist. */ #include "dbg.h" #include "an_solver.h" #include <math.h> struct s_AN_workspace { size_t* idxs; double* delta; size_t size; }; static int cmp(const void* left, const void* right, void* arg); AN_WS* AN_WS_alloc(size_t size) { AN_WS* ws = malloc(sizeof(AN_WS)); libcheck_mem(ws); ws->idxs = malloc(size * sizeof(size_t)); llibcheck_mem(ws, error_a); ws->delta = malloc(size * sizeof(double)); llibcheck_mem(ws, error_b); ws->size = size; return ws; error_b: free(ws->idxs); error_a: free(ws); error: return NULL; } void AN_WS_free(AN_WS* ws) { if(ws) { free(ws->delta); free(ws->idxs); free(ws); } } void AN_solve(long* clp, double* recv, AN_WS* ws) { // Project recv onto the hyperplane of dimension size-1 where A_n lives. double sum = recv[0]; for(size_t i = 1; i < ws->size; i++) sum += recv[i]; double s = sum / ws->size; debug("s: %f", s); for(size_t i = 0; i < ws->size; i++) { recv[i] -= s; debug("recv[%zu]: %f", i, recv[i]); } AN_solve_np(clp, recv, ws); } void AN_solve_np(long* clp, double* recv, AN_WS* ws) { long Delta = clp[0] = round(recv[0]); ws->delta[0] = recv[0] - clp[0]; debug("round(recv[0]): %ld;\t delta[0]: %f", clp[0], ws->delta[0]); for(size_t i = 1; i < ws->size; i++) { Delta += clp[i] = round(recv[i]); ws->delta[i] = recv[i] - clp[i]; debug("round(recv[%zu]): %ld;\t delta[%zu]: %f", i, clp[i], i, ws->delta[i]); } debug("Delta: %ld", Delta); if(Delta == 0) return; // Initialize the array that will be sorted for(size_t i = 0; i < ws->size; i++) ws->idxs[i] = i; // Sort the array qsort_r(ws->idxs, ws->size, sizeof(size_t), cmp, ws->delta); if(Delta > 0) { for(size_t i = 0; i < (size_t) Delta; i++) clp[ws->idxs[i]]--; } else { for(size_t i = ws->size - 1; i > ws->size - 1 + Delta; i--) clp[ws->idxs[i]]++; } } static int cmp(const void* left, const void* right, void* arg) { size_t l = *((size_t*) left); size_t r = *((size_t*) right); double* delta = (double*) arg; double diff = delta[l] - delta[r]; if(diff < 0) return -1; else if(diff > 0) return 1; else return 0; }
#include <string> #include <fstream> #include <vector> /** * Reads all lines form a file and returns a vector of the lines. * * \param path Path to the file * \return A vector containing all the lines in the read file. */ std::vector<std::string> getlines(std::string path) { std::ifstream file(path); std::vector<std::string> strings; std::string line; while (std::getline(file, line)) { strings.push_back(line); } return strings; }
/* packet-s7comm_szl_ids.h * * Author: Thomas Wiens, 2014 (th.wiens@gmx.de) * Description: Wireshark dissector for S7-Communication * * Wireshark - Network traffic analyzer * By Gerald Combs <gerald@wireshark.org> * Copyright 1998 Gerald Combs * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef __PACKET_S7COMM_SZL_IDS_H__ #define __PACKET_S7COMM_SZL_IDS_H__ guint32 s7comm_decode_ud_cpu_szl_subfunc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *data_tree, guint8 type, guint8 ret_val, guint16 len, guint16 dlength, guint8 data_unit_ref, guint8 last_data_unit, guint32 offset); void s7comm_register_szl_types(int proto); #endif /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * * Local variables: * c-basic-offset: 4 * tab-width: 8 * indent-tabs-mode: nil * End: * * vi: set shiftwidth=4 tabstop=8 expandtab: * :indentSize=4:tabSize=8:noTabs=true: */
/************************************************************************ Copyright : 2005-2007, Huawei Tech. Co., Ltd. File name : TafAppPPPoE.h Version : V200R001 Date : 2006-05-06 Description : ¸ÃÍ·Îļþ¶¨ÒåÁËTAFÌṩ¸øAPPËùʹÓõÄÊý¾Ý½á¹¹ºÍº¯Êý½Ó¿Ú History : 1. Date : 2006-05-06 Modification: Create 2. Date:2006-08-09 Modification:¸ù¾ÝÎÊÌâµ¥A32D03479£¬ÔÚPC»úÉÏʵÏÖʱ½«#pragma pack(0)ºÍ#pragma pack()¼Ó±àÒ뿪¹Ø ************************************************************************/ #ifndef __TAF_APP_PPPOE_H__ #define __TAF_APP_PPPOE_H__ /***************************************************************************** 1 ÆäËûÍ·Îļþ°üº¬ *****************************************************************************/ #include "TafTypeDef.h" #ifdef __cplusplus #if __cplusplus extern "C" { #endif #endif #pragma pack(4) /******************APP-APIËùÐèÊý¾ÝÀàÐͶ¨Ò忪ʼ****************/ #ifndef __VOS_CHANGE_TO_TAF__ #define __VOS_CHANGE_TO_TAF__ #if 0 typedef signed char TAF_INT8; typedef unsigned char TAF_UINT8; typedef signed short TAF_INT16; typedef unsigned short TAF_UINT16; typedef signed long TAF_INT32; typedef unsigned long TAF_UINT32; typedef char TAF_CHAR; typedef unsigned char TAF_UCHAR; typedef void TAF_VOID; #endif #endif /******************APP-APIËùÐèÊý¾ÝÀàÐͶ¨Òå½áÊø****************/ /***************************************************************************** 2 ºê¶¨Òå *****************************************************************************/ /******************************************************************************* 3 ö¾Ù¶¨Òå *******************************************************************************/ typedef enum { TAF_PPPOE_CID_DEFAULT, /*ʹÓÃĬÈÏCID*/ TAF_PPPOE_CID_MANUAL_SELECT, /*Óû§×ÔÐÐÑ¡ÔñCID*/ TAF_PPPOE_CID_BUTT }TAF_PPPOE_CID_SELECT_MODE_ENUM; /*Ñ¡ÔñCIDµÄ·½Ê½*/ /***************************************************************************** 4 È«¾Ö±äÁ¿ÉùÃ÷ *****************************************************************************/ /***************************************************************************** 5 ÏûϢͷ¶¨Òå *****************************************************************************/ /***************************************************************************** 6 ÏûÏ¢¶¨Òå *****************************************************************************/ /***************************************************************************** 7 STRUCT¶¨Òå *****************************************************************************/ /***************************************************************************** 8 UNION¶¨Òå *****************************************************************************/ /***************************************************************************** 9 º¯Êý½Ó¿Ú¶¨Òå *****************************************************************************/ /***************************************************************************** Prototype : Taf_PPPoESetCid Description : Ìṩ¸øÓû§µÄ½Ó¿Ú£¬ÓÃÓÚÉèÖÃPPPoEËùʹÓõÄCID Input : CidSelectMode Ñ¡ÔñCIDµÄ·½Ê½£¬TAF_PPPOE_CID_DEFAULT·½Ê½Ï£¬µÚ¶þ¸ö²ÎÊýucCid¿ÉÌîÈÎÒâÖµ¡£ ucCid Óû§ËùÖ¸¶¨µÄCID£¬È¡Öµ[0,11],Ö»¶ÔTAF_PPPOE_CID_MANUAL_SELECT·½Ê½ÓÐЧ Output : Return Value : TAF_SUCCESS CIDÉèÖóɹ¦ TAF_FAILURE CIDÉèÖÃʧ°Ü Calls : Called By : APP History : 1.Date : 2006-05-16 Modification: Created function *****************************************************************************/ extern TAF_UINT32 Taf_PPPoESetCid(TAF_PPPOE_CID_SELECT_MODE_ENUM CidSelectMode, TAF_UINT8 ucCid); #if ((TAF_OS_VER == TAF_WIN32) || (TAF_OS_VER == TAF_NUCLEUS)) #pragma pack() #else #pragma pack(0) #endif #ifdef __cplusplus #if __cplusplus } #endif #endif #endif /* end of TafAppPPPoE.h*/
/* $Id$ */ /*--------------------------------------------------------------------*/ /*; Copyright (C) 2005 */ /*; Associated Universities, Inc. Washington DC, USA. */ /*; This program is free software; you can redistribute it and/or */ /*; modify it under the terms of the GNU General Public License as */ /*; published by the Free Software Foundation; either version 2 of */ /*; the License, or (at your option) any later version. */ /*; */ /*; This program is distributed in the hope that it will be useful, */ /*; but WITHOUT ANY WARRANTY; without even the implied warranty of */ /*; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /*; GNU General Public License for more details. */ /*; */ /*; You should have received a copy of the GNU General Public */ /*; License along with this program; if not, write to the Free */ /*; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, */ /*; MA 02139, USA. */ /*; */ /*; Correspondence this software should be addressed as follows: */ /*; Internet email: bcotton@nrao.edu. */ /*; Postal address: William Cotton */ /*; National Radio Astronomy Observatory */ /*; 520 Edgemont Road */ /*; Charlottesville, VA 22903-2475 USA */ /*--------------------------------------------------------------------*/ /* Define the basic components of the ObitXML ClassInfo structure */ /* This is intended to be included in a classInfo structure definition */ /* and to be used as the template for generating new classes derived */ /* from Obit. */ #include "ObitClassDef.h" /* Parent class ClassInfo definition file */
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <assert.h> #include <sys/mman.h> void help(int val) { int val1 = val + 1; printf("val is %d\n", val1); } #define PGSIZE 0x1000 struct StackSpace { void *mm; int npages; }; int stack_init(struct StackSpace *s, int npages) { char *stk = mmap(NULL, (npages + 1) * PGSIZE, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); char *stkbeg = stk + (npages + 1) * PGSIZE; if (stk == MAP_FAILED) { return -1; } s->mm = stk; s->npages = npages; mprotect(stk, 1, PROT_NONE); asm("mov %%rsp, %%r15\n\t" "mov %0, %%rsp\n\t" "push %%r15" : :"r"(stkbeg) :"%r15", "%rsp"); return 0; } void * curr_stkp(void) { void *stk; asm("mov %%rsp, %0":"=r"(stk)::); return stk; } void * stack_top(struct StackSpace *s) { char *beg = (char *)s->mm + (s->npages + 1) * PGSIZE; return ((void **)beg)[-1]; } void stack_delete(struct StackSpace *s) { void *old_stk = stack_top(s); int npages = s->npages; asm("mov %0, %%rsp"::"r"(old_stk):"%rsp"); memset(s->mm + PGSIZE, 0, npages * PGSIZE); asm("mfence" :::); munmap(s->mm, (npages) * PGSIZE); } int main() { //int npages = 2; //char *stk = mmap(NULL, (npages + 1) * PGSIZE, PROT_WRITE | PROT_READ, // MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); //assert(stk != MAP_FAILED); //mprotect(stk, 1, PROT_NONE); //char *stkbeg = stk + (npages + 1) * PGSIZE; //asm("mov %%rsp, %%r15\n\t" // "mov %0, %%rsp\n\t" // "push %%r15" // : :"r"(stkbeg) :"%r15", "%rsp"); //asm("mov %0, %%rsp"::"r"(((void**)stkbeg)[-1]):"%rsp"); //memset(stk + PGSIZE, 0, npages * PGSIZE); //asm("mfence" :::); //munmap(stk, (npages + 1) * PGSIZE); // printf("DBG: sp %p\n", curr_stkp()); struct StackSpace s; stack_init(&s, 2); help(3); printf("DBG: s.mm %p\n", s.mm); printf("DBG: sp %p\n", curr_stkp()); stack_delete(&s); printf("DBG: sp %p\n", curr_stkp()); //asm("mov %0, %%rsp"::"r"(((void**)stkbeg)[-1]):"%rsp"); //memset(stk + PGSIZE, 0, npages * PGSIZE); //asm("mfence" :::); //munmap(stk, (npages + 1) * PGSIZE); return 0; }
/* * DOMFixedDuration.h * * * Created by Owen Thomas on 2/03/06. * Copyright 2006 __MyCompanyName__. All rights reserved. * */ #ifndef inc_dom_fixed_duration #define inc_dom_fixed_duration #include <xercesc/dom/DOM.hpp> #include "DOMDuration.h" /** * Fixed Duration implementation of DOMDuration. * A Fixed Duration has a positive double fixed value. */ class DOMFixedDuration : public DOMDuration { public: /** * Creates a DOMFixedDuration over the specified DOMElement. * A Fixed duration has a single, fixed value that the duration * will always take. */ DOMFixedDuration (DOMElement *duration) { this->node = duration; } /** * Creates a DOMFixedDuration with the specified duration. * * Creates a DOMElement from the specified DOMDocument. */ DOMFixedDuration (time_t duration, DOMDocument *document); /** * Returns a copy of this DOMFixedDuration, with a deep * copy of the underlying DOMElement. * * @return a copy of this DOMFixedDuration. */ DOMDuration* copy () { return new DOMFixedDuration ((DOMElement*)node->cloneNode(true)); } /** * Returns "Fixed". * @return 'Fixed'. */ virtual char* getName() { return "Fixed"; } /** * This will release the internal DOMElement * if it has no parent node. */ ~DOMFixedDuration() { if(node->getParentNode() == NULL) { node->release(); } } /** * Returns the fixed duration. * @return the fixed duration. */ time_t getDuration () { return getAttributeAsTime ("duration"); } /** * @author daa * For fixed duration this is just the fixed time. * @return the fixed time. */ virtual time_t getMean () { return getDuration(); } /** * @author daa * For fixed duration this is just the fixed time. * @return the fixed time. */ virtual time_t getSample () { return getDuration(); } /** * Sets the duration to the specified double value. * * Self use: called by Constructor */ void setDuration(time_t duration) { setAttribute ("duration", duration); } }; #endif
/* * Copyright (C) 2011 SingularityCore <http://www.singularitycore.org/> * Copyright (C) 2010-2011 Project SkyFire <http://www.projectskyfire.org/> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DB2STORE_H #define DB2STORE_H #include "DB2FileLoader.h" #include "DB2fmt.h" #include "Logging/Log.h" #include "Field.h" #include "DatabaseWorkerPool.h" #include "Implementation/WorldDatabase.h" #include "DatabaseEnv.h" #include <vector> template<class T> class DB2Storage { typedef std::list<char*> StringPoolList; typedef std::vector<T*> DataTableEx; public: explicit DB2Storage(const char *f) : nCount(0), fieldCount(0), fmt(f), indexTable(NULL), m_dataTable(NULL) { } ~DB2Storage() { Clear(); } T const* LookupEntry(uint32 id) const { return (id>=nCount)?NULL:indexTable[id]; } uint32 GetNumRows() const { return nCount; } char const* GetFormat() const { return fmt; } uint32 GetFieldCount() const { return fieldCount; } /// Copies the provided entry and stores it. void AddEntry(uint32 id, const T* entry) { if (LookupEntry(id)) return; if (id >= nCount) { // reallocate index table char** tmpIdxTable = new char*[id+1]; memset(tmpIdxTable, 0, (id+1) * sizeof(char*)); memcpy(tmpIdxTable, (char*)indexTable, nCount * sizeof(char*)); delete[] ((char*)indexTable); nCount = id + 1; indexTable = (T**)tmpIdxTable; } T* entryDst = new T; memcpy((char*)entryDst, (char*)entry, sizeof(T)); m_dataTableEx.push_back(entryDst); indexTable[id] = entryDst; } bool Load(char const* fn) { DB2FileLoader db2; // Check if load was sucessful, only then continue if (!db2.Load(fn, fmt)) return false; fieldCount = db2.GetCols(); // load raw non-string data m_dataTable = (T*)db2.AutoProduceData(fmt, nCount, (char**&)indexTable); // create string holders for loaded string fields m_stringPoolList.push_back(db2.AutoProduceStringsArrayHolders(fmt, (char*)m_dataTable)); // load strings from dbc data m_stringPoolList.push_back(db2.AutoProduceStrings(fmt, (char*)m_dataTable)); // error in dbc file at loading if NULL return indexTable!=NULL; } bool LoadStringsFrom(char const* fn) { // DBC must be already loaded using Load if (!indexTable) return false; DB2FileLoader db2; // Check if load was successful, only then continue if (!db2.Load(fn, fmt)) return false; // load strings from another locale dbc data m_stringPoolList.push_back(db2.AutoProduceStrings(fmt, (char*)m_dataTable)); return true; } void Clear() { if (!indexTable) return; delete[] ((char*)indexTable); indexTable = NULL; delete[] ((char*)m_dataTable); m_dataTable = NULL; for (DataTableEx::const_iterator itr = m_dataTableEx.begin(); itr != m_dataTableEx.end(); ++itr) delete *itr; m_dataTableEx.clear(); while (!m_stringPoolList.empty()) { delete[] m_stringPoolList.front(); m_stringPoolList.pop_front(); } nCount = 0; } void EraseEntry(uint32 id) { indexTable[id] = NULL; } private: uint32 nCount; uint32 fieldCount; uint32 recordSize; char const* fmt; T** indexTable; T* m_dataTable; DataTableEx m_dataTableEx; StringPoolList m_stringPoolList; }; #endif
/**************************************************************************************** * Copyright (c) 2012 Phalgun Guduthur <me@phalgun.in> * * * * This program is free software; you can redistribute it and/or modify it under * * the terms of the GNU General Public License as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any later * * version. * * * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License along with * * this program. If not, see <http://www.gnu.org/licenses/>. * ****************************************************************************************/ #ifndef NEPOMUKCOLLECTION_H #define NEPOMUKCOLLECTION_H #include "NepomukConstructMetaJob.h" #include "core/collections/Collection.h" #include "core-impl/collections/support/MemoryCollection.h" #include <KIcon> namespace Collections { class NepomukConstructMetaJob; /** * NepomukCollection is a plugin to use Nepomuk as a backend instead of the SQL * collection that Amarok uses as default. * Until the NepomukCollection is feature complete and easy to use, it shall run * along with the existing SQL Collection. * However, the goal of the plugin remains to replace the SQL Collection. * Nepomuk indexes all data on the machine and categorises them. * So, it is easy to retrieve all resources of type 'music' and use them in Amarok * Nepomuk helps establish a common backend in a KDE environment, which has its own * advantages * * The NepomukCollection uses MemoryCollection as a base. MemoryCollection is usec by * most of the other plugins. The NepomukCollection loads the tracks extracted from the * Nepomuk index into buckets called {Meta}Maps. * * MemoryCollection provides a default implementation of the QueryMaker which handles * all query calls. */ class NepomukCollection : public Collection, public Meta::Observer { Q_OBJECT public: /** * The entry point of Nepomuk Collection. */ NepomukCollection(); virtual ~NepomukCollection(); /** * This function returns a generic MemoryQueryMaker. * Nepomuk Collection uses a MemoryQueryMaker as its QueryMaker * There is no need to construct a separate NepomukQueryMaker. */ virtual QueryMaker *queryMaker(); virtual bool isDirInCollection( const QString &path ); virtual QString uidUrlProtocol() const; virtual QString collectionId() const; virtual QString prettyName() const; virtual KIcon icon() const; virtual bool isWritable() const; // Observer methods: virtual void metadataChanged( Meta::TrackPtr track ); // so that the compiler doesn't complain about hidden virtual functions: using Meta::Observer::metadataChanged; // TrackProvider methods virtual bool possiblyContainsTrack( const KUrl &url ) const; virtual Meta::TrackPtr trackForUrl( const KUrl &url ); private: // nepomuk specific /** * This function is called to build the Nepomuk Collection by populating the Meta QMaps. * This function forms the crux of the Nepomuk Collection. * It first executes a query to fetch all resources of type 'audio' and returns * immediately. * Enumeration of the queried results into Meta QMaps of MemoeryCollection.h happens * as a background job. * * After each track is extracted, its corresponding properties of artist, genre, composer * album ( year is not yet implemented ) is fetched and inserted into the NepomukTrack * object. */ void buildCollection(); /** * Inspired by iPod Collection. * This function is quite self explanatory. * Given an @p uidUrl, ( Resource URI in the language of Nepomuk ) * it returns a TrackPtr to the music track with that URI. * * Note : the function doesn't check if the passed uidUrl is valid or if it exists */ Meta::TrackPtr trackForUidUrl( const QString &uidUrl ); friend class NepomukConstructMetaJob; QSharedPointer<MemoryCollection> m_mc; }; } //namespace Collections #endif // NEPOMUKCOLLECTION_H
/* * Linux 2.6.32 and later Kernel module for VMware MVP Guest Communications * * Copyright (C) 2010-2013 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. */ #line 5 #ifndef _MKSCK_H #define _MKSCK_H /** * @file * * @brief The monitor-kernel socket interface definitions. * * The monitor kernel socket interface was created for (what the name * says) communications between the monitor and host processes. On the * monitor side a special API is introduced, see mksck_vmm.h. On the * host side the API is the standard Berkeley socket interface. Host * process to host process or monitor to monitor communication is not * supported. * * A generic address consists of two 16 bit fields: the vm id and the * port id. Both hosts (vmx) and monitors (vmm) get their vm id * automatically. The host vm id is assigned at the time the host * process opens the mvpkm file descriptor, while the monitor vm id is * assigned when the vmx.c:SetupWorldSwitchPage() calls * Mvpkm_SetupIds(). As a vmx may create multiple monitors to service * an MP guest, a vmx vm id may be associated with multiple monitor vm * ids. A monitor id, however, has a single associated vmx host id, * the id of its canonical vmx. * * Sockets on the host get their addresses either by explicit user * call (the bind command) or implicitly by (issuing a send command * first). At an explicit bind the user may omit one or both fields by * providing MKSCK_VMID_UNDEF/MKSCK_PORT_UNDEF respectively. An * implicit bind behaves as if both fields were omitted in an explicit * bind. The default value of the vmid field is the vmid computed from * the thread group id while that of a port is a new number. It is not * invalid to bind a host process socket with a vm id different from * the vmid computed from the tgid. * * Sockets of the monitor are automatically assigned a vmid, that of their * monitor, at the time of their creation. The port id can be assigned by the * user or left to the implementation to assign an unused one (by specifying * MKSCK_PORT_UNDEF at @ref Mksck_Open). * * Host unconnected sockets may receive from any monitor sender, may send to any * monitor socket. A socket can be connected to a peer address, that enables the * use of the send command. * * One of many special predefined port (both host and monitor) is * MKSCK_PORT_MASTER. It is used for initialization. * * Monitor sockets have to send their peer address explicitly (by * Mksck_SetPeer()) or implicitly by receiving first. After the peer * is set, monitor sockets may send or receive only to/from their * peer. */ #define INCLUDE_ALLOW_MVPD #define INCLUDE_ALLOW_VMX #define INCLUDE_ALLOW_MODULE #define INCLUDE_ALLOW_MONITOR #define INCLUDE_ALLOW_HOSTUSER #define INCLUDE_ALLOW_GUESTUSER #define INCLUDE_ALLOW_GPL #include "include_check.h" #include "vmid.h" /* * The interface limits the size of transferable packets. */ #define MKSCK_XFER_MAX 1024 #define MKSCK_ADDR_UNDEF ((uint32)0xffffffff) #define MKSCK_PORT_UNDEF ((uint16)0xffff) #define MKSCK_PORT_MASTER (MKSCK_PORT_UNDEF-1) #define MKSCK_PORT_HOST_FB (MKSCK_PORT_UNDEF-2) #define MKSCK_PORT_BALLOON (MKSCK_PORT_UNDEF-3) #define MKSCK_PORT_HOST_HID (MKSCK_PORT_UNDEF-4) #define MKSCK_PORT_CHECKPOINT (MKSCK_PORT_UNDEF-5) #define MKSCK_PORT_COMM_EV (MKSCK_PORT_UNDEF-6) #define MKSCK_PORT_HIGH (MKSCK_PORT_UNDEF-7) #define MKSCK_VMID_UNDEF VMID_UNDEF #define MKSCK_VMID_HIGH (MKSCK_VMID_UNDEF-1) #define MKSCK_DETACH 3 typedef uint16 Mksck_Port; typedef VmId Mksck_VmId; /** * @brief Page descriptor for typed messages. Each page describes a region of * the machine address space with base mpn and size 2^(12 + order) bytes. */ typedef struct { #ifdef __aarch64__ uint32 mpn:28; /**< Base MPN of region described by page assuming a 40 bits max address*/ #else uint32 mpn:20; /**< Base MPN of region described by page */ #endif uint32 order:12; /**< Region is 2^(12 + order) bytes. */ } Mksck_PageDesc; /** * @brief Typed message template macro. Allows us to avoid having two message * types, one with page descriptor vector (for VMM), one without (for * VMX). * * @param type C type of uninterpreted component of the message (following the * page descriptor vector). * @param pages number of page descriptors in vector. */ #define MKSCK_DESC_TYPE(type, pages) \ struct { \ type umsg; \ Mksck_PageDesc page[pages]; \ } /** * @brief The monitor kernel socket interface address format */ typedef union { uint32 addr; /**< the address */ struct { /* The address is decomposed to two shorts */ Mksck_Port port; /**< port unique within a vmid */ Mksck_VmId vmId; /**< unique vmid */ }; } Mksck_Address; static inline uint32 Mksck_AddrInit(Mksck_VmId vmId, Mksck_Port port) { Mksck_Address aa; aa.vmId = vmId; aa.port = port; return aa.addr; } #endif
/* * linux/drivers/misc/msm_vibrator_plat.c * * MSM Vibrator platform-dependent file. * * Copyright (C) 2008 Palm, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License. */ #include <linux/module.h> #include <linux/init.h> #include <linux/types.h> #include <linux/kernel.h> #include <linux/platform_device.h> #include <linux/errno.h> #include <asm/io.h> #include <asm/mach-types.h> #include <linux/i2c_lm8502_led.h> #include "vibrator_plat.h" #undef VIBE_DEBUG // #define VIBE_DEBUG struct vib_context { struct vibrator_platform_data data; int init_done; unsigned int duty_cycle; int direction; }; int vibrator_init(struct vib_context* io_p_context) { int rc = 0; #ifdef VIBE_DEBUG printk("In %s...\n", __func__); #endif if (!io_p_context->init_done) { if (!lm8502_vib_enable(true)) io_p_context->init_done = 1; else rc = -EIO; } return rc; } int vibrator_deinit(struct vib_context* io_p_context) { int rc = 0; #ifdef VIBE_DEBUG printk("In %s...\n", __func__); #endif if (io_p_context->init_done) { if (!lm8502_vib_start(false)) io_p_context->init_done = 0; else rc = -EIO; } return rc; } int vibrator_set_direction(struct vib_context* io_p_context, int dir_control) { int rc = 0; unsigned int duty_cycle = io_p_context->duty_cycle; #ifdef VIBE_DEBUG printk("In %s...\n", __func__); #endif /* Set the direction only if the duty cycle is non-zero */ if (duty_cycle) { /* Turn off the vibrator if the direction is set as zero */ if (!dir_control) { #ifdef VIBE_DEBUG printk("In %s: stop...\n", __func__); #endif vibrator_deinit (io_p_context); } else { if (dir_control * io_p_context->direction < 0) { #ifdef VIBE_DEBUG printk("In %s: reverse direction ...\n", __func__); #endif } else { #ifdef VIBE_DEBUG printk("In %s: same direction ...\n", __func__); #endif } if (!io_p_context->init_done) { vibrator_init (io_p_context); } lm8502_vib_start (true); lm8502_vib_direction (dir_control == 1); } // Store the direction io_p_context->direction = dir_control; } return rc; } int vibrator_set_duty_cycle(struct vib_context* io_p_context, unsigned int duty_cycle) { int rc = 0; u16 value = (u16) (duty_cycle); if (value > 100) { value = 100; } /* Turn off the vibrator if the duty cycle is zero */ if (!value) { vibrator_deinit (io_p_context); } else { if (io_p_context->direction) { /* If the vibrator was turned off by zero duty cycle last time, turn it on, for a new duty cycle value */ if (!io_p_context->duty_cycle) { vibrator_init (io_p_context); } lm8502_vib_duty_cycle (duty_cycle); } // Store the duty cycle, even if the direction is zero io_p_context->duty_cycle = duty_cycle; } #ifdef VIBE_DEBUG printk("In %s: input: %u, reg_val: %u\n", __func__, duty_cycle, value); #endif return rc; } int vibrator_enable(struct vib_context* io_p_context, int enable) { #ifdef VIBE_DEBUG printk("In %s enable: %d ...\n", __func__, enable); #endif if (enable) { if (!lm8502_vib_enable (enable) ) { lm8502_vib_start (enable); } } else { if (!lm8502_vib_start (enable) ) { lm8502_vib_enable (enable); } } return 0; } static struct vib_context vib_data; /* * Abstraction layer for vibetonz - the api layer is all wrong, but will get * us started in the meantime. */ int plat_vibrator_register(struct vibrator_platform_data* i_p_data) { memcpy(&(vib_data.data), i_p_data, sizeof(struct vibrator_platform_data)); return 0; } int plat_vibrator_init() { return vibrator_init(&(vib_data)); } int plat_vibrator_deinit(void) { return vibrator_deinit(&(vib_data)); } /* * Currently there is no need of msm specific * suspend / resume, as vibrator driver * handles suspend / resume by itself. */ int plat_vibrator_suspend(void) { return 0; } int plat_vibrator_resume(void) { return 0; } int plat_vibrator_set_direction(int dir_control) { return vibrator_set_direction(&(vib_data), dir_control); } int plat_vibrator_set_duty_cycle(unsigned int duty_cycle) { return vibrator_set_duty_cycle(&(vib_data), duty_cycle); } int plat_vibrator_enable(int enable) { return vibrator_enable(&(vib_data), enable); }
/* Copyright 2000 Kjetil S. Matheussen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "nsmtracker.h" #include "tbox_proc.h" bool insideTBox(TBox *tbox,int x,int y){ if( x < tbox->x1 || x > tbox->x2 || y < tbox->y1 || y > tbox->y2 )return false; return true; } /* static bool TboxInsideTBox(TBox *tbox1,TBox *tbox2){ if( tbox1->x1 >= tbox2->x1 && tbox1->x2 <= tbox2->x2 && tbox1->y1 >= tbox2->y1 && tbox1->y2 <= tbox2->y2 ) return true; return false; } */ void TBOX_within(TBox *in,TBox *within){ in->x1=R_BOUNDARIES(within->x1,in->x1,within->x2); in->x2=R_BOUNDARIES(within->x1,in->x2,within->x2); in->y1=R_BOUNDARIES(within->y1,in->y1,within->y2); in->y2=R_BOUNDARIES(within->y1,in->y2,within->y2); } #if 0 static bool TboxOverlapTBox(TBox *tbox1,TBox *tbox2){ if( tbox1->x1 >= tbox2->x1 && tbox1->x1 <= tbox2->x2 ) return true; if( tbox1->y1 >= tbox2->y1 && tbox1->y1 <= tbox2->y2 ) return true; if( tbox1->x2 >= tbox2->x1 && tbox1->x2 <= tbox2->x2 ) return true; if( tbox1->y2 >= tbox2->y1 && tbox1->y2 <= tbox2->y2 ) return true; return false; } static bool TBoxOnlyOverLapTBox_Y(TBox *tbox1,TBox *tbox2){ if( tbox1->x1==tbox2->x1 && tbox1->x2==tbox2->x2 ){ return true; } return false; } static bool TBoxOnlyOverLapTBox_X(TBox *tbox1,TBox *tbox2){ if( tbox1->y1==tbox2->y1 && tbox1->y2==tbox2->y2 ){ return true; } return false; } static void TBoxSquize_Y(TBox *from,TBox *to){ to->y1=R_MIN(to->y1,from->y1); from->y2=R_MAX(to->y2,from->y2); } static void TBoxSquize_X(TBox *from,TBox *to){ to->x1=R_MIN(to->x1,from->x1); from->x2=R_MAX(to->x2,from->x2); } static bool TBoxSquize(TBox *from,TBox *to){ return false; } /* "from" and "overlap" overlaps, so we change "overlap" and make "to", to make 3 TBoxes that doesn't overlap. */ static void TBoxMake2Into3(TBox *from,TBox *overlap,TBox *to){ } #endif
// -*- mode: C++; -*- #ifndef QTLOOPS_H #define QTLOOPS_H // Copyright (C) 2009 Jeremy S. Sanders // Email: Jeremy Sanders <jeremy@jeremysanders.net> // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ///////////////////////////////////////////////////////////////////////////// #include "qtloops_helpers.h" #include <QPolygonF> #include <QPainter> #include <QPainterPath> #include <QRectF> #include <QImage> class QtLoops { public: QtLoops() {}; }; // add sets of points to a QPolygonF void addNumpyToPolygonF(QPolygonF& poly, const Tuple2Ptrs& v); // add sets of polygon points to a path void addNumpyPolygonToPath(QPainterPath &path, const Tuple2Ptrs& d, const QRectF* clip = 0); // Scale path by scale given. Puts output in out. QPainterPath scalePath(const QPainterPath& path, qreal scale); // plot paths to painter // x and y locations are given in x and y // if scaling is not 0, is an array to scale the data points by // if colorimg is not 0, is a Nx1 image containing color points for path fills // clip is a clipping rectangle if set void plotPathsToPainter(QPainter& painter, QPainterPath& path, const Numpy1DObj& x, const Numpy1DObj& y, const Numpy1DObj* scaling = 0, const QRectF* clip = 0, const QImage* colorimg = 0, bool scaleline = false); void plotLinesToPainter(QPainter& painter, const Numpy1DObj& x1, const Numpy1DObj& y1, const Numpy1DObj& x2, const Numpy1DObj& y2, const QRectF* clip = 0, bool autoexpand = true); void plotBoxesToPainter(QPainter& painter, const Numpy1DObj& x1, const Numpy1DObj& y1, const Numpy1DObj& x2, const Numpy1DObj& y2, const QRectF* clip = 0, bool autoexpand = true); // add polygon to painter path as a cubic void addCubicsToPainterPath(QPainterPath& path, const QPolygonF& poly); QImage numpyToQImage(const Numpy2DObj& data, const Numpy2DIntObj &colors, bool forcetrans = false); void applyImageTransparancy(QImage& img, const Numpy2DObj& data); QImage resampleNonlinearImage(const QImage& img, int x0, int y0, int x1, int y1, const Numpy1DObj& xedge, const Numpy1DObj& yedge); // plot image as a set of rectangles void plotImageAsRects(QPainter& painter, const QRectF& bounds, const QImage& img); // plot a non linear image as a set of boxes // the coordinates for each edge are given in xedges/yedges void plotNonlinearImageAsBoxes(QPainter& painter, const QImage& img, const Numpy1DObj& xedges, const Numpy1DObj& yedges); #endif
/*--------------------------------------------------------------------------- Extended atoi, (C)ChaN, 2011 -----------------------------------------------------------------------------*/ #ifndef XATOI #define XATOI #include <inttypes.h> #include <avr/pgmspace.h> /*-----------------------------------------------------------------------------*/ uint8_t xatoi( uint8_t **str, int32_t *ret ); /* Get value of the numeral string. str Pointer to pointer to source string "0b11001010" binary "0377" octal "0xff800" hexdecimal "1250000" decimal "-25000" decimal ret Pointer to return value */ #endif /* XITOA */
/* * dpkg - main program for package management * update.c - options which update the `available' database * * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk> * * This 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 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 <config.h> #include <compat.h> #include <errno.h> #include <string.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <dpkg/i18n.h> #include <dpkg/dpkg.h> #include <dpkg/dpkg-db.h> #include <dpkg/myopt.h> #include "main.h" void updateavailable(const char *const *argv) { const char *sourcefile= argv[0]; int count= 0; static struct varbuf vb; switch (cipaction->arg) { case act_avclear: if (sourcefile) badusage(_("--%s takes no arguments"),cipaction->olong); break; case act_avreplace: case act_avmerge: if (!sourcefile || argv[1]) badusage(_("--%s needs exactly one Packages file argument"),cipaction->olong); break; default: internerr("unknown action '%d'", cipaction->arg); } if (!f_noact) { if (access(admindir,W_OK)) { if (errno != EACCES) ohshite(_("unable to access dpkg status area for bulk available update")); else ohshit(_("bulk available update requires write access to dpkg status area")); } lockdatabase(admindir); } switch (cipaction->arg) { case act_avreplace: printf(_("Replacing available packages info, using %s.\n"),sourcefile); break; case act_avmerge: printf(_("Updating available packages info, using %s.\n"),sourcefile); break; case act_avclear: break; default: internerr("unknown action '%d'", cipaction->arg); } varbufaddstr(&vb,admindir); varbufaddstr(&vb,"/" AVAILFILE); varbufaddc(&vb,0); if (cipaction->arg == act_avmerge) parsedb(vb.buf, pdb_recordavailable | pdb_rejectstatus, NULL, NULL, NULL); if (cipaction->arg != act_avclear) count += parsedb(sourcefile, pdb_recordavailable | pdb_rejectstatus | pdb_ignoreolder, NULL, NULL, NULL); if (!f_noact) { writedb(vb.buf,1,0); unlockdatabase(); } if (cipaction->arg != act_avclear) printf(_("Information about %d package(s) was updated.\n"),count); } void forgetold(const char *const *argv) { if (*argv) badusage(_("--%s takes no arguments"), cipaction->olong); warning(_("obsolete '--%s' option, unavailable packages are automatically cleaned up."), cipaction->olong); }
/*************************************************************************** qgslayertreeutils.h -------------------------------------- Date : May 2014 Copyright : (C) 2014 by Martin Dobias Email : wonder dot sk at gmail dot com *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef QGSLAYERTREEUTILS_H #define QGSLAYERTREEUTILS_H #include <qnamespace.h> #include <QList> #include <QPair> #include "qgis_core.h" class QDomElement; class QDomDocument; class QStringList; class QgsLayerTreeNode; class QgsLayerTreeGroup; class QgsLayerTreeLayer; class QgsMapLayer; class QgsProject; /** \ingroup core * Assorted functions for dealing with layer trees. * * @note added in 2.4 */ class CORE_EXPORT QgsLayerTreeUtils { public: //! Try to load layer tree from \verbatim <legend> \endverbatim tag from project files from QGIS 2.2 and below static bool readOldLegend( QgsLayerTreeGroup *root, const QDomElement &legendElem ); //! Try to load custom layer order from \verbatim <legend> \endverbatim tag from project files from QGIS 2.2 and below static bool readOldLegendLayerOrder( const QDomElement &legendElem, bool &hasCustomOrder, QStringList &order ); //! Return \verbatim <legend> \endverbatim tag used in QGIS 2.2 and below static QDomElement writeOldLegend( QDomDocument &doc, QgsLayerTreeGroup *root, bool hasCustomOrder, const QStringList &order ); //! Convert Qt::CheckState to QString static QString checkStateToXml( Qt::CheckState state ); //! Convert QString to Qt::CheckState static Qt::CheckState checkStateFromXml( const QString &txt ); //! Return true if any of the layers is editable static bool layersEditable( const QList<QgsLayerTreeLayer *> &layerNodes ); //! Return true if any of the layers is modified static bool layersModified( const QList<QgsLayerTreeLayer *> &layerNodes ); //! Remove layer nodes that refer to invalid layers static void removeInvalidLayers( QgsLayerTreeGroup *group ); //! Remove subtree of embedded groups and replaces it with a custom property embedded-visible-layers static void replaceChildrenOfEmbeddedGroups( QgsLayerTreeGroup *group ); //! @note not available in python bindings static void updateEmbeddedGroupsProjectPath( QgsLayerTreeGroup *group, const QgsProject *project ); //! get invisible layers static QStringList invisibleLayerList( QgsLayerTreeNode *node ); //! Set the expression filter of a legend layer static void setLegendFilterByExpression( QgsLayerTreeLayer &layer, const QString &expr, bool enabled = true ); //! Return the expression filter of a legend layer static QString legendFilterByExpression( const QgsLayerTreeLayer &layer, bool *enabled = nullptr ); //! Test if one of the layers in a group has an expression filter static bool hasLegendFilterExpression( const QgsLayerTreeGroup &group ); //! Insert a QgsMapLayer just below another one //! @param group the tree group where layers are (can be the root group) //! @param refLayer the reference layer //! @param layerToInsert the new layer to insert just below the reference layer //! @returns the new tree layer static QgsLayerTreeLayer *insertLayerBelow( QgsLayerTreeGroup *group, const QgsMapLayer *refLayer, QgsMapLayer *layerToInsert ); }; #endif // QGSLAYERTREEUTILS_H
// // Created by arash on 12/1/15. // #ifndef DATASTRUCTURES_BSTREE_H #define DATASTRUCTURES_BSTREE_H #include <iostream> #include <stddef.h> #include "BTNode.h" template<typename Value> class BSTree { private: BTNode<int, Value> *root; int nodeCounter; BTNode<int, Value> *insertHelper(BTNode<int, Value> * _root, int _key, Value _value) { if (_root == NULL) { return new BTNode<int, Value>(_key, _value); } if (_key < this->root->getKey()) _root->setLeft(insertHelper(_root->getLeft(), _key, _value)); else _root->setRight(insertHelper(_root->getRight(), _key, _value)); return _root; } void printHelper(BTNode<int, Value> *_root) { if (_root == NULL) return; std::cout << "key :" << _root->getKey() << " - value :" << _root->getValue() << std::endl; printHelper(_root->getLeft()); printHelper(_root->getLeft()); } public: BSTree() { this->root = NULL; } void insert(int _key, Value _value) { this->root = this->insertHelper(this->root, _key, _value); nodeCounter ++; } void print() { this->printHelper(this->root); } }; #endif //DATASTRUCTURES_BSTREE_H
//------------------------------------------------------------------------------ // Copyright (c) 2009-2010 Atheros Corporation. All rights reserved. // // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice appear in all copies. // // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS 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, DIRECT, 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. // // //------------------------------------------------------------------------------ //============================================================================== // HCI bridge implementation // // Author(s): ="Atheros" //============================================================================== #include "hci_transport_api.h" #include "common_drv.h" extern HCI_TRANSPORT_HANDLE (*_HCI_TransportAttach)(void *HTCHandle, struct hci_transport_config_info *pInfo); extern void (*_HCI_TransportDetach)(HCI_TRANSPORT_HANDLE HciTrans); extern int (*_HCI_TransportAddReceivePkts)(HCI_TRANSPORT_HANDLE HciTrans, struct htc_packet_queue *pQueue); extern int (*_HCI_TransportSendPkt)(HCI_TRANSPORT_HANDLE HciTrans, struct htc_packet *pPacket, bool Synchronous); extern void (*_HCI_TransportStop)(HCI_TRANSPORT_HANDLE HciTrans); extern int (*_HCI_TransportStart)(HCI_TRANSPORT_HANDLE HciTrans); extern int (*_HCI_TransportEnableDisableAsyncRecv)(HCI_TRANSPORT_HANDLE HciTrans, bool Enable); extern int (*_HCI_TransportRecvHCIEventSync)(HCI_TRANSPORT_HANDLE HciTrans, struct htc_packet *pPacket, int MaxPollMS); extern int (*_HCI_TransportSetBaudRate)(HCI_TRANSPORT_HANDLE HciTrans, u32 Baud); extern int (*_HCI_TransportEnablePowerMgmt)(HCI_TRANSPORT_HANDLE HciTrans, bool Enable); #define HCI_TransportAttach(HTCHandle, pInfo) \ _HCI_TransportAttach((HTCHandle), (pInfo)) #define HCI_TransportDetach(HciTrans) \ _HCI_TransportDetach(HciTrans) #define HCI_TransportAddReceivePkts(HciTrans, pQueue) \ _HCI_TransportAddReceivePkts((HciTrans), (pQueue)) #define HCI_TransportSendPkt(HciTrans, pPacket, Synchronous) \ _HCI_TransportSendPkt((HciTrans), (pPacket), (Synchronous)) #define HCI_TransportStop(HciTrans) \ _HCI_TransportStop((HciTrans)) #define HCI_TransportStart(HciTrans) \ _HCI_TransportStart((HciTrans)) #define HCI_TransportEnableDisableAsyncRecv(HciTrans, Enable) \ _HCI_TransportEnableDisableAsyncRecv((HciTrans), (Enable)) #define HCI_TransportRecvHCIEventSync(HciTrans, pPacket, MaxPollMS) \ _HCI_TransportRecvHCIEventSync((HciTrans), (pPacket), (MaxPollMS)) #define HCI_TransportSetBaudRate(HciTrans, Baud) \ _HCI_TransportSetBaudRate((HciTrans), (Baud)) #define HCI_TransportEnablePowerMgmt(HciTrans, Enable) \ _HCI_TransportEnablePowerMgmt((HciTrans), (Enable)) extern int ar6000_register_hci_transport(struct hci_transport_callbacks *hciTransCallbacks); extern int ar6000_get_hif_dev(struct hif_device *device, void *config); extern int ar6000_set_uart_config(struct hif_device *hifDevice, u32 scale, u32 step); /* get core clock register settings * data: 0 - 40/44MHz * 1 - 80/88MHz * where (5G band/2.4G band) * assume 2.4G band for now */ extern int ar6000_get_core_clock_config(struct hif_device *hifDevice, u32 *data);
/* Copyright (C) 2001-2006, William Joseph. All Rights Reserved. This file is part of GtkRadiant. GtkRadiant 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. GtkRadiant 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 GtkRadiant; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mathlib.h" void line_construct_for_vec3(line_t *line, const vec3_t start, const vec3_t end) { VectorMid(start, end, line->origin); VectorSubtract(end, line->origin, line->extents); } int line_test_plane(const line_t* line, const vec4_t plane) { float fDist; // calc distance of origin from plane fDist = DotProduct(plane, line->origin) + plane[3]; // accept if origin is less than or equal to this distance if (fabs(fDist) < fabs(DotProduct(plane, line->extents))) return 1; // partially inside else if (fDist < 0) return 2; // totally inside return 0; // totally outside }
/*************************************************************************** qgsvectortilebasiclabelingwidget.h -------------------------------------- Date : May 2020 Copyright : (C) 2020 by Martin Dobias Email : wonder dot sk at gmail dot com *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef QGSVECTORTILEBASICLABELINGWIDGET_H #define QGSVECTORTILEBASICLABELINGWIDGET_H #include "qgsmaplayerconfigwidget.h" #include "ui_qgsvectortilebasiclabelingwidget.h" #include "qgswkbtypes.h" #include <memory> ///@cond PRIVATE #define SIP_NO_FILE class QgsVectorTileBasicLabeling; class QgsVectorTileBasicLabelingListModel; class QgsVectorTileLayer; class QgsMapCanvas; class QgsMessageBar; /** * \ingroup gui * Styling widget for basic labling of vector tile layer * * \since QGIS 3.14 */ class GUI_EXPORT QgsVectorTileBasicLabelingWidget : public QgsMapLayerConfigWidget, private Ui::QgsVectorTileBasicLabelingWidget { Q_OBJECT public: QgsVectorTileBasicLabelingWidget( QgsVectorTileLayer *layer, QgsMapCanvas *canvas, QgsMessageBar *messageBar, QWidget *parent = nullptr ); ~QgsVectorTileBasicLabelingWidget() override; public slots: //! Applies the settings made in the dialog void apply() override; private slots: void addStyle( QgsWkbTypes::GeometryType geomType ); //void addStyle(); void editStyle(); void editStyleAtIndex( const QModelIndex &index ); void removeStyle(); void updateLabelingFromWidget(); private: QgsVectorTileLayer *mVTLayer = nullptr; std::unique_ptr<QgsVectorTileBasicLabeling> mLabeling; QgsVectorTileBasicLabelingListModel *mModel = nullptr; QgsMessageBar *mMessageBar = nullptr; }; class QgsPalLayerSettings; class QgsVectorLayer; class QgsSymbolWidgetContext; class QgsLabelingGui; /** * \ingroup gui * Helper widget class that wraps QgsLabelingGui into a QgsPanelWidget * * \since QGIS 3.14 */ class QgsLabelingPanelWidget : public QgsPanelWidget { Q_OBJECT public: QgsLabelingPanelWidget( const QgsPalLayerSettings &labelSettings, QgsVectorLayer *vectorLayer, QgsMapCanvas *mapCanvas, QWidget *parent = nullptr ); void setDockMode( bool dockMode ) override; void setContext( const QgsSymbolWidgetContext &context ); QgsPalLayerSettings labelSettings(); private: QgsLabelingGui *mLabelingGui = nullptr; }; class QgsVectorTileBasicLabelingStyle; class QgsVectorTileBasicLabelingListModel : public QAbstractListModel { Q_OBJECT public: QgsVectorTileBasicLabelingListModel( QgsVectorTileBasicLabeling *r, QObject *parent = nullptr ); int rowCount( const QModelIndex &parent = QModelIndex() ) const override; int columnCount( const QModelIndex &parent = QModelIndex() ) const override; QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override; QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override; Qt::ItemFlags flags( const QModelIndex &index ) const override; bool setData( const QModelIndex &index, const QVariant &value, int role ) override; bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override; void insertStyle( int row, const QgsVectorTileBasicLabelingStyle &style ); // drag'n'drop support Qt::DropActions supportedDropActions() const override; QStringList mimeTypes() const override; QMimeData *mimeData( const QModelIndexList &indexes ) const override; bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override; private: QgsVectorTileBasicLabeling *mLabeling = nullptr; }; ///@endcond #endif // QGSVECTORTILEBASICLABELINGWIDGET_H
#include "mac.h" static int get_macfileinfo(PerlIO *infile, char *file, HV *info) { Buffer header; char *bptr; int32_t ret = 0; int32_t header_end; mac_streaminfo *si; Newz(0, si, sizeof(mac_streaminfo), mac_streaminfo); /* There are two possible variations here. 1. There's an ID3V2 tag present at the beginning of the file 2. There's an APE tag present at the beginning of the file (deprecated, but still possible) For each type of tag, check for existence and then skip it before looking for the MPC header */ if ((header_end = skip_id3v2(infile)) < 0) { PerlIO_printf(PerlIO_stderr(), "MAC: [Couldn't skip ID3v2]: %s\n", file); Safefree(si); return -1; } // seek to first byte of MAC data if (PerlIO_seek(infile, header_end, SEEK_SET) < 0) { PerlIO_printf(PerlIO_stderr(), "MAC: [Couldn't seek to offset %d]: %s\n", header_end, file); Safefree(si); return -1; } // Offset + MAC. Does this need the space as well, to be +4 ? si->audio_start_offset = PerlIO_tell(infile) + 3; // Skip the APETAGEX if it exists. buffer_init(&header, APE_HEADER_LEN); if (!_check_buf(infile, &header, APE_HEADER_LEN, APE_HEADER_LEN)) { PerlIO_printf(PerlIO_stderr(), "MAC: [Couldn't read tag header]: %s\n", file); goto out; } bptr = buffer_ptr(&header); if (memcmp(bptr, "APETAGEX", 8) == 0) { // Skip the ape tag structure // XXXX - need to test this code path. buffer_get_int_le(&header); PerlIO_seek(infile, buffer_get_int_le(&header), SEEK_CUR); } else { // set the pointer back to original location PerlIO_seek(infile, -APE_HEADER_LEN, SEEK_CUR); } buffer_clear(&header); if (!_check_buf(infile, &header, 32, 32)) { PerlIO_printf(PerlIO_stderr(), "MAC: [Couldn't read stream header]: %s\n", file); goto out; } bptr = buffer_ptr(&header); if (memcmp(bptr, "MAC ", 4) != 0) { PerlIO_printf(PerlIO_stderr(), "MAC: [Couldn't couldn't find stream header]: %s\n", file); goto out; } buffer_consume(&header, 4); si->version = buffer_get_short_le(&header); if (si->version < 3980) { uint16_t compression_id = buffer_get_short_le(&header); if (compression_id % 1000) { si->compression = ""; } else { si->compression = mac_profile_names[ compression_id / 1000 ]; } if (!_check_buf(infile, &header, MAC_397_HEADER_LEN, MAC_397_HEADER_LEN)) { PerlIO_printf(PerlIO_stderr(), "MAC: [Couldn't read < 3.98 stream header]: %s\n", file); goto out; } buffer_consume(&header, 2); // flags si->channels = buffer_get_short_le(&header); si->sample_rate = buffer_get_int_le(&header); buffer_consume(&header, 4); // header size buffer_consume(&header, 4); // terminating data bytes si->total_frames = buffer_get_int_le(&header); si->final_frame = buffer_get_int_le(&header); si->blocks_per_frame = si->version >= 3950 ? (73728 * 4) : 73728; } else { unsigned char md5[16]; uint16_t profile; if (!_check_buf(infile, &header, MAC_398_HEADER_LEN, MAC_398_HEADER_LEN)) { PerlIO_printf(PerlIO_stderr(), "MAC: [Couldn't read > 3.98 stream header]: %s\n", file); goto out; } buffer_consume(&header, 2); // unused. buffer_get_int_le(&header); // desc bytes buffer_get_int_le(&header); // header bytes buffer_get_int_le(&header); // seek table bytes buffer_get_int_le(&header); // header data bytes buffer_get_int_le(&header); // ape frame data bytes buffer_get_int_le(&header); // ape frame data bytes high buffer_get_int_le(&header); // terminating data bytes buffer_get(&header, &md5, sizeof(md5)); // Header block profile = buffer_get_short_le(&header); if (profile % 1000) { si->compression = ""; } else { si->compression = mac_profile_names[ profile / 1000 ]; } buffer_get_short_le(&header); // flags si->blocks_per_frame = buffer_get_int_le(&header); si->final_frame = buffer_get_int_le(&header); si->total_frames = buffer_get_int_le(&header); si->bits = buffer_get_short_le(&header); si->channels = buffer_get_short_le(&header); si->sample_rate = buffer_get_int_le(&header); } si->file_size = _file_size(infile); if (si->sample_rate) { double total_samples = (double)(((si->blocks_per_frame * (si->total_frames - 1)) + si->final_frame)); uint32_t total_ms = (total_samples * 1000) / si->sample_rate; my_hv_store(info, "samplerate", newSViv(si->sample_rate)); my_hv_store(info, "channels", newSViv(si->channels)); my_hv_store(info, "song_length_ms", newSVuv(total_ms)); my_hv_store(info, "bitrate", newSVuv( _bitrate(si->file_size - si->audio_start_offset, total_ms) )); my_hv_store(info, "file_size", newSVnv(si->file_size)); my_hv_store(info, "audio_offset", newSVuv(si->audio_start_offset)); my_hv_store(info, "audio_size", newSVuv(si->file_size - si->audio_start_offset)); my_hv_store(info, "compression", newSVpv(si->compression, 0)); my_hv_store(info, "version", newSVpvf( "%0.2f", si->version * 1.0 / 1000 ) ); } out: buffer_free(&header); Safefree(si); return ret; }
/* * Copyright (C) 2011-2012 BlizzLikeCore <http://blizzlike.servegame.com/> * Please, read the credits file. * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DEF_MAGISTERS_TERRACE_H #define DEF_MAGISTERS_TERRACE_H #define DATA_SELIN_EVENT 1 #define DATA_VEXALLUS_EVENT 2 #define DATA_DELRISSA_EVENT 3 #define DATA_KAELTHAS_EVENT 4 #define DATA_SELIN 5 #define DATA_FEL_CRYSTAL 6 #define DATA_FEL_CRYSTAL_SIZE 7 #define DATA_VEXALLUS_DOOR 8 #define DATA_SELIN_DOOR 9 #define DATA_DELRISSA 10 #define DATA_DELRISSA_DOOR 11 #define DATA_SELIN_ENCOUNTER_DOOR 12 #define DATA_KAEL_DOOR 13 #define DATA_KAEL_STATUE_LEFT 14 #define DATA_KAEL_STATUE_RIGHT 15 #define DATA_DELRISSA_DEATH_COUNT 16 #define ERROR_INST_DATA "BSCR Error: Instance Data not set properly for Magister's Terrace instance (map 585). Encounters will be buggy." #endif
#undef CONFIG_SCSI_SATA_QSTOR
/* __author__ = "Karol Będkowski" __copyright__ = "Copyright (c) Karol Będkowski, 2011" __version__ = "2011-04-18" */ #include "common.h" static PyObject * merge_layers_overlay(PyObject *self, PyObject *args) { PyObject *py_image_in1, *py_image_in2, *py_image_out; if (!PyArg_ParseTuple(args, "OOO", &py_image_in1, &py_image_in2, &py_image_out)) { return Py_BuildValue("is", -1, "ERROR: Could not parse argument tuple."); } Imaging img_in1 = pyobject_to_imaging(py_image_in1); Imaging img_in2 = pyobject_to_imaging(py_image_in2); Imaging img_out = pyobject_to_imaging(py_image_out); int y, x; for (y = 0; y < img_out->ysize; y++) { UINT8* out = (UINT8*) img_out->image[y]; UINT8* in1 = (UINT8*) img_in1->image[y]; UINT8* in2 = (UINT8*) img_in2->image[y]; for (x = 0; x < img_out->linesize; x++) { int val = (int) (in1[x] / 255.0 * (in1[x] + 2 * in2[x] / 255.0 * \ (255 - in1[x]))); if (val < 0) out[x] = 0; else if (val > 255) out[x] = 255; else out[x] = val; } } return Py_BuildValue("is", 0, ""); } static PyObject * merge_layers_soft_light(PyObject *self, PyObject *args) { PyObject *py_image_in1, *py_image_in2, *py_image_out; if (!PyArg_ParseTuple(args, "OOO", &py_image_in1, &py_image_in2, &py_image_out)) { return Py_BuildValue("is", -1, "ERROR: Could not parse argument tuple."); } Imaging img_in1 = pyobject_to_imaging(py_image_in1); Imaging img_in2 = pyobject_to_imaging(py_image_in2); Imaging img_out = pyobject_to_imaging(py_image_out); int y, x; for (y = 0; y < img_out->ysize; y++) { UINT8* out = (UINT8*) img_out->image[y]; UINT8* in1 = (UINT8*) img_in1->image[y]; UINT8* in2 = (UINT8*) img_in2->image[y]; for (x = 0; x < img_out->linesize; x++) { int val = (in1[x] * in2[x] * (255 - in1[x]) + in2[x] * (655025 - \ (255 - in1[x]) * (255 - in2[x]))) / 655025.0; if (val < 0) out[x] = 0; else if (val > 255) out[x] = 255; else out[x] = val; } } return Py_BuildValue("is", 0, ""); } static PyMethodDef Photomagick[] = { {"merge_layers_overlay", merge_layers_overlay, 1, "merge_layers_overlay(image1, image2, image_out)"}, {"merge_layers_soft_light", merge_layers_soft_light, 1, "merge_layers_soft_light(image1, image2, image_out)"}, {NULL, NULL} }; PyMODINIT_FUNC init_layers(void) { Py_InitModule("photomagick.support._layers", Photomagick); }
#ifndef _READWRITE_H #define _READWRITE_H #include <sys/types.h> void read_sectors (int64_t start_sector, unsigned int num_sectors, void *into); void write_sectors (int64_t start_sector, unsigned int num_sectors, void *from); void print_sector (unsigned char *buf); int open_read_close_sect(char *disk, int start_sect, int num_sectors, char *buf); #endif
#ifndef Switches_h #define Switches_h #include "Debug.h" class Switches { public: static constexpr char STATUS_CAUTION = '1'; static constexpr char STATUS_LEFT_TURN = '2'; static constexpr char STATUS_RIGHT_TURN = '3'; static constexpr char STATUS_STOP = '4'; static constexpr char STATUS_BUTTON = '5'; static constexpr char STATUS_STOP_LEFT_TURN = '6'; static constexpr char STATUS_STOP_RIGHT_TURN = '7'; const int SIGNAL_THRESHOLD = 255; Switches(int leftTurnPin, int rightTurnPin, int leftStopPin, int rightStopPin, int buttonPin); char getStatus(); private: int mLeftTurnPin; int mRightTurnPin; int mLeftStopPin; int mRightStopPin; int mButtonPin; }; #endif
/* * Flexible mmap layout support * * Based on code by Ingo Molnar and Andi Kleen, copyrighted * as follows: * * Copyright 2003-2009 Red Hat Inc. * All Rights Reserved. * Copyright 2005 Andi Kleen, SUSE Labs. * Copyright 2007 Jiri Kosina, SUSE Labs. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <linux/personality.h> #include <linux/mm.h> #include <linux/random.h> #include <linux/limits.h> #include <linux/sched.h> #include <asm/elf.h> struct __read_mostly va_alignment va_align = { .flags = -1, }; static unsigned int stack_maxrandom_size(void) { unsigned int max = 0; if ((current->flags & PF_RANDOMIZE) && !(current->personality & ADDR_NO_RANDOMIZE)) { max = ((-1U) & STACK_RND_MASK) << PAGE_SHIFT; } return max; } /* * Top of mmap area (just below the process stack). * * Leave an at least ~128 MB hole with possible stack randomization. */ #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size()) #define MAX_GAP (TASK_SIZE/6*5) static int mmap_is_legacy(void) { if (current->personality & ADDR_COMPAT_LAYOUT) return 1; if (rlimit(RLIMIT_STACK) == RLIM_INFINITY) return 1; return sysctl_legacy_va_layout; } static unsigned long mmap_rnd(void) { unsigned long rnd = 0; if (current->flags & PF_RANDOMIZE) { if (mmap_is_ia32()) #ifdef CONFIG_COMPAT rnd = (unsigned long)get_random_int() & ((1 << mmap_rnd_compat_bits) - 1); #else rnd = (unsigned long)get_random_int() & ((1 << mmap_rnd_bits) - 1); #endif else rnd = (unsigned long)get_random_int() & ((1 << mmap_rnd_bits) - 1); } return rnd << PAGE_SHIFT; } static unsigned long mmap_base(void) { unsigned long gap = rlimit(RLIMIT_STACK); if (gap < MIN_GAP) gap = MIN_GAP; else if (gap > MAX_GAP) gap = MAX_GAP; return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd()); } /* * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64 * does, but not when emulating X86_32 */ static unsigned long mmap_legacy_base(void) { if (mmap_is_ia32()) return TASK_UNMAPPED_BASE; else return TASK_UNMAPPED_BASE + mmap_rnd(); } /* * This function, called very early during the creation of a new * process VM image, sets up which VM layout function to use: */ void arch_pick_mmap_layout(struct mm_struct *mm) { mm->mmap_legacy_base = mmap_legacy_base(); mm->mmap_base = mmap_base(); if (mmap_is_legacy()) { mm->mmap_base = mm->mmap_legacy_base; mm->get_unmapped_area = arch_get_unmapped_area; mm->unmap_area = arch_unmap_area; } else { mm->get_unmapped_area = arch_get_unmapped_area_topdown; mm->unmap_area = arch_unmap_area_topdown; } }
#include <linux/kernel.h> #include <linux/string.h> #include <linux/mm.h> #include <linux/highmem.h> #include <linux/page-debug-flags.h> #include <linux/poison.h> #include <linux/ratelimit.h> #ifndef mark_addr_rdonly #define mark_addr_rdonly(a) #endif #ifndef mark_addr_rdwrite #define mark_addr_rdwrite(a) #endif static inline void set_page_poison(struct page *page) { __set_bit(PAGE_DEBUG_FLAG_POISON, &page->debug_flags); } static inline void clear_page_poison(struct page *page) { __clear_bit(PAGE_DEBUG_FLAG_POISON, &page->debug_flags); } static inline bool page_poison(struct page *page) { return test_bit(PAGE_DEBUG_FLAG_POISON, &page->debug_flags); } static void poison_page(struct page *page) { void *addr = kmap_atomic(page); set_page_poison(page); memset(addr, PAGE_POISON, PAGE_SIZE); mark_addr_rdonly(addr); kunmap_atomic(addr); } static void poison_pages(struct page *page, int n) { int i; for (i = 0; i < n; i++) poison_page(page + i); } static bool single_bit_flip(unsigned char a, unsigned char b) { unsigned char error = a ^ b; return error && !(error & (error - 1)); } struct page_poison_information { u64 virtualaddress; u64 physicaladdress; char buf; }; #define MAX_PAGE_POISON_COUNT 8 static struct page_poison_information page_poison_array[MAX_PAGE_POISON_COUNT]={{0,0}}; static int page_poison_count = 0; static void check_poison_mem(unsigned char *mem, size_t bytes) { static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 10); unsigned char *start; unsigned char *end; start = memchr_inv(mem, PAGE_POISON, bytes); if (!start) return; for (end = mem + bytes - 1; end > start; end--) { if (*end != PAGE_POISON) break; } if (!__ratelimit(&ratelimit)) return; else if (start == end && single_bit_flip(*start, PAGE_POISON)){ printk(KERN_ERR "pagealloc: single bit error\n"); printk(KERN_ERR "virt: %p, phys: 0x%llx\n", start, virt_to_phys(start)); if(page_poison_count == MAX_PAGE_POISON_COUNT-1){ BUG_ON(PANIC_CORRUPTION); dump_stack(); }else { page_poison_array[page_poison_count].virtualaddress = (u64)start; page_poison_array[page_poison_count].physicaladdress = (u64)(virt_to_phys(start)); page_poison_array[page_poison_count].buf = *start; page_poison_count++; } } else{ printk(KERN_ERR "pagealloc: memory corruption\n"); print_hex_dump(KERN_ERR, "", DUMP_PREFIX_ADDRESS, 16, 1, start, end - start + 1, 1); BUG_ON(PANIC_CORRUPTION); dump_stack(); } } static void unpoison_page(struct page *page) { void *addr; if (!page_poison(page)) return; addr = kmap_atomic(page); check_poison_mem(addr, PAGE_SIZE); mark_addr_rdwrite(addr); clear_page_poison(page); kunmap_atomic(addr); } static void unpoison_pages(struct page *page, int n) { int i; for (i = 0; i < n; i++) unpoison_page(page + i); } void kernel_map_pages(struct page *page, int numpages, int enable) { if (enable) unpoison_pages(page, numpages); else poison_pages(page, numpages); }
#include <zos/device.h> #include <arch/syscall.h> int device_send_response(dev_t dev, uint32_t req_id, void *buf, size_t size) { int ret; SYSCALL4(SYS_DEVICE_SEND_RESPONSE, dev, req_id, buf, size, ret); return ret; }
/*____________________________________________________________________________ FreeAMP - The Free MP3 Player Portions copyright (C) 1998-1999 EMusic.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. $Id: win32impl.h,v 1.3 1999/12/10 04:25:35 elrod Exp $ ____________________________________________________________________________*/ #ifndef INCLUDED_WIN32IMPL_H_ #define INCLUDED_WIN32IMPL_H_ #include "config.h" #include <kernel/image.h> class FILETIME { public: int32 dwLowDateTime; int32 dwHighDateTime; }; #define FILE_ATTRIBUTE_DIRECTORY 0x00000010L #define FILE_ATTRIBUTE_NORMAL 0x00000080L /* Not in Win32, but something is needed to indicate a symlink */ #define FILE_ATTRIBUTE_SYMLINK 0x00000040L class WIN32_FIND_DATA { public: int32 dwFileAttributes; FILETIME ftCreationTime; FILETIME ftLastAccessTime; FILETIME ftLastWriteTime; int32 nFileSizeHigh; int32 nFileSizeLow; int32 dwReserved0; int32 dwReserved1; char cFileName[ _MAX_PATH ]; char cAlternateFileName[ 14 ]; }; typedef void *HANDLE; #define INVALID_HANDLE_VALUE ((HANDLE)-1) //typedef image_id HMODULE; typedef void* HMODULE; #define HINSTANCE HMODULE typedef void *FARPROC; HANDLE FindFirstFile(char *lpFileName, WIN32_FIND_DATA *lpFindFileData); bool FindNextFile(HANDLE hFindFile, WIN32_FIND_DATA *lpFindFileData); bool FindClose(HANDLE hFindFile); HINSTANCE LoadLibrary(char *lpLibFileName); bool FreeLibrary(HMODULE hLibModule); FARPROC GetProcAddress(HMODULE hModule, char *lpProcName); #endif
/************************************************************************** * Included Files **************************************************************************/ #include <mach/hardware.h> #include <mach/pins.h> #if defined(CONFIG_STELLARIS_EARLY_CONSOLE_UART0) #define EARLY_CONSOLE_BASE STLR_UART0_BASE #elif defined(CONFIG_STELLARIS_EARLY_CONSOLE_UART1) #define EARLY_CONSOLE_BASE STLR_UART1_BASE #elif defined(CONFIG_STELLARIS_EARLY_CONSOLE_UART2) #define EARLY_CONSOLE_BASE STLR_UART2_BASE #elif defined(CONFIG_STELLARIS_EARLY_CONSOLE_UART3) #define EARLY_CONSOLE_BASE STLR_UART3_BASE #elif defined(CONFIG_STELLARIS_EARLY_CONSOLE_UART4) #define EARLY_CONSOLE_BASE STLR_UART4_BASE #elif defined(CONFIG_STELLARIS_EARLY_CONSOLE_UART5) #define EARLY_CONSOLE_BASE STLR_UART5_BASE #elif defined(CONFIG_STELLARIS_EARLY_CONSOLE_UART6) #define EARLY_CONSOLE_BASE STLR_UART6_BASE #elif defined(CONFIG_STELLARIS_EARLY_CONSOLE_UART7) #define EARLY_CONSOLE_BASE STLR_UART7_BASE #endif int uart_getc(uint32_t uart_base) { /* Wait for a character from the UART */ while ((getreg32(uart_base + STLR_UART_FR_OFFSET) & UART_FR_RXFE)); return (int)(getreg32(uart_base + STLR_UART_DR_OFFSET) & UART_DR_DATA_MASK); } void uart_putc(uint32_t uart_base, const char ch) { /* Then send the character */ putreg32((uint32_t)ch, uart_base + STLR_UART_DR_OFFSET); while ((getreg32(uart_base + STLR_UART_FR_OFFSET) & UART_FR_TXFE) == 0); } int uart_tstc(uint32_t uart_base) { /* Test for a character from the UART */ return (getreg32(uart_base + STLR_UART_FR_OFFSET) & UART_FR_RXFE) == 0; } void uart_puts(uint32_t uart_base, const char *s) { while (*s) { uart_putc(uart_base, *s); /* If \n, also do \r */ if (*s == '\n') uart_putc(uart_base, '\r'); s++; } } void printascii(const char *str) { #ifdef EARLY_CONSOLE_BASE uart_puts(EARLY_CONSOLE_BASE, str); #endif } void printch(char ch) { #ifdef EARLY_CONSOLE_BASE uart_putc(EARLY_CONSOLE_BASE, ch); #endif }
/* Unicorn Emulator Engine */ /* By Nguyen Anh Quynh, 2015 */ /* Sample code to demonstrate how to emulate ARM code */ #include <inttypes.h> #include <unicorn/unicorn.h> // code to be emulated #define ARM_CODE "\x37\x00\xa0\xe3\x03\x10\x42\xe0" // mov r0, #0x37; sub r1, r2, r3 #define THUMB_CODE "\x83\xb0" // sub sp, #0xc // memory address where emulation starts #define ADDRESS 0x10000 static void hook_block(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { printf(">>> Tracing basic block at 0x%"PRIx64 ", block size = 0x%x\n", address, size); } static void hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { printf(">>> Tracing instruction at 0x%"PRIx64 ", instruction size = 0x%x\n", address, size); } static void test_arm(void) { uc_engine *uc; uc_err err; uc_hook trace1, trace2; int r0 = 0x1234; // R0 register int r2 = 0x6789; // R1 register int r3 = 0x3333; // R2 register int r1; // R1 register printf("Emulate ARM code\n"); // Initialize emulator in ARM mode err = uc_open(UC_ARCH_ARM, UC_MODE_ARM, &uc); if (err) { printf("Failed on uc_open() with error returned: %u (%s)\n", err, uc_strerror(err)); return; } // map 2MB memory for this emulation uc_mem_map(uc, ADDRESS, 2 * 1024 * 1024, UC_PROT_ALL); // write machine code to be emulated to memory uc_mem_write(uc, ADDRESS, ARM_CODE, sizeof(ARM_CODE) - 1); // initialize machine registers uc_reg_write(uc, UC_ARM_REG_R0, &r0); uc_reg_write(uc, UC_ARM_REG_R2, &r2); uc_reg_write(uc, UC_ARM_REG_R3, &r3); // tracing all basic blocks with customized callback uc_hook_add(uc, &trace1, UC_HOOK_BLOCK, hook_block, NULL, (uint64_t)1, (uint64_t)0); // tracing one instruction at ADDRESS with customized callback uc_hook_add(uc, &trace2, UC_HOOK_CODE, hook_code, NULL, (uint64_t)ADDRESS, (uint64_t)ADDRESS); // emulate machine code in infinite time (last param = 0), or when // finishing all the code. err = uc_emu_start(uc, ADDRESS, ADDRESS + sizeof(ARM_CODE) -1, 0, 0); if (err) { printf("Failed on uc_emu_start() with error returned: %u\n", err); } // now print out some registers printf(">>> Emulation done. Below is the CPU context\n"); uc_reg_read(uc, UC_ARM_REG_R0, &r0); uc_reg_read(uc, UC_ARM_REG_R1, &r1); printf(">>> R0 = 0x%x\n", r0); printf(">>> R1 = 0x%x\n", r1); uc_close(uc); } static void test_thumb(void) { uc_engine *uc; uc_err err; uc_hook trace1, trace2; int sp = 0x1234; // R0 register printf("Emulate THUMB code\n"); // Initialize emulator in ARM mode err = uc_open(UC_ARCH_ARM, UC_MODE_THUMB, &uc); if (err) { printf("Failed on uc_open() with error returned: %u (%s)\n", err, uc_strerror(err)); return; } // map 2MB memory for this emulation uc_mem_map(uc, ADDRESS, 2 * 1024 * 1024, UC_PROT_ALL); // write machine code to be emulated to memory uc_mem_write(uc, ADDRESS, THUMB_CODE, sizeof(THUMB_CODE) - 1); // initialize machine registers uc_reg_write(uc, UC_ARM_REG_SP, &sp); // tracing all basic blocks with customized callback uc_hook_add(uc, &trace1, UC_HOOK_BLOCK, hook_block, NULL, (uint64_t)1, (uint64_t)0); // tracing one instruction at ADDRESS with customized callback uc_hook_add(uc, &trace2, UC_HOOK_CODE, hook_code, NULL, (uint64_t)ADDRESS, (uint64_t)ADDRESS); // emulate machine code in infinite time (last param = 0), or when // finishing all the code. err = uc_emu_start(uc, ADDRESS, ADDRESS + sizeof(THUMB_CODE) -1, 0, 0); if (err) { printf("Failed on uc_emu_start() with error returned: %u\n", err); } // now print out some registers printf(">>> Emulation done. Below is the CPU context\n"); uc_reg_read(uc, UC_ARM_REG_SP, &sp); printf(">>> SP = 0x%x\n", sp); uc_close(uc); } int main(int argc, char **argv, char **envp) { test_arm(); printf("==========================\n"); test_thumb(); return 0; }
/**************************************************************** BeebEm - BBC Micro and Master 128 Emulator Copyright (C) 1997 Laurie Whiffen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ****************************************************************/ #ifndef USERKYBD_HEADER #define USERKYBD_HEADER #include <string.h> #include <stdlib.h> #include <windows.h> #include "port.h" // Public declarations. BOOL UserKeyboardDialog( HWND hwndParent ); extern KeyMap UserKeymap; #endif
/* Based up Neutrino-GUI - Tuxbox-Project Copyright (C) 2001 by Steffen Hehn 'McClean' Classes for generic GUI-related components. Copyright (C) 2012, 2013, Thilo Graf 'dbt' License: GPL This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef __CC_ITEM_INFOBOX__ #define __CC_ITEM_INFOBOX__ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include "cc_item_text.h" #include "cc_item_picture.h" #include <string> //! Sub class of CComponentsItem. Shows box with text and optional icon on screen. /*! InfoBox has been originally intended for displaying text information or menue hints, but is also usable like each other CCItems. */ #define INFO_BOX_Y_OFFSET 2 class CComponentsInfoBox : public CComponentsText { private: ///property: property: space around fram and beetween picture and textbox, see also setSpaceOffset() int x_offset; ///object: picture object CComponentsPicture * pic; ///property: path or default name of displayed image std::string pic_default_name; ///initialize all needed default attributes void initVarInfobox(); ///paint picture, used in initVarInfobox() void paintPicture(); ///property: path or name of displayed image std::string pic_name; public: ///object: internal used CTextBox object CComponentsText * cctext; CComponentsInfoBox(); CComponentsInfoBox( const int x_pos, const int y_pos, const int w, const int h, std::string info_text = "", const int mode = CTextBox::AUTO_WIDTH, Font* font_text = NULL, bool has_shadow = CC_SHADOW_OFF, fb_pixel_t color_text = COL_MENUCONTENT_TEXT, fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); ~CComponentsInfoBox(); ///set property: space around fram and beetween picture and textbox inline void setSpaceOffset(const int offset){x_offset = offset;}; ///set property: path or name of displayed image inline void setPicture(const std::string& picture_name){pic_name = picture_name;}; ///paint item void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); }; #endif
/* ** Zabbix ** Copyright (C) 2001-2018 Zabbix SIA ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ #ifndef ZABBIX_MEMALLOC_H #define ZABBIX_MEMALLOC_H #include "common.h" #include "mutexs.h" typedef struct { void **buckets; void *lo_bound; void *hi_bound; zbx_uint64_t free_size; zbx_uint64_t used_size; zbx_uint64_t orig_size; zbx_uint64_t total_size; int shm_id; /* Continue execution in out of memory situation. */ /* Normally allocator forces exit when it runs out of allocatable memory. */ /* Set this flag to 1 to allow execution in out of memory situations. */ char allow_oom; ZBX_MUTEX mem_lock; const char *mem_descr; const char *mem_param; } zbx_mem_info_t; int zbx_mem_create(zbx_mem_info_t **info, zbx_uint64_t size, const char *descr, const char *param, int allow_oom, char **error); #define zbx_mem_malloc(info, old, size) __zbx_mem_malloc(__FILE__, __LINE__, info, old, size) #define zbx_mem_realloc(info, old, size) __zbx_mem_realloc(__FILE__, __LINE__, info, old, size) #define zbx_mem_free(info, ptr) \ \ do \ { \ __zbx_mem_free(__FILE__, __LINE__, info, ptr); \ ptr = NULL; \ } \ while (0) void *__zbx_mem_malloc(const char *file, int line, zbx_mem_info_t *info, const void *old, size_t size); void *__zbx_mem_realloc(const char *file, int line, zbx_mem_info_t *info, void *old, size_t size); void __zbx_mem_free(const char *file, int line, zbx_mem_info_t *info, void *ptr); void zbx_mem_clear(zbx_mem_info_t *info); void zbx_mem_dump_stats(zbx_mem_info_t *info); size_t zbx_mem_required_size(int chunks_num, const char *descr, const char *param); #define ZBX_MEM_FUNC1_DECL_MALLOC(__prefix) \ static void *__prefix ## _mem_malloc_func(void *old, size_t size) #define ZBX_MEM_FUNC1_DECL_REALLOC(__prefix) \ static void *__prefix ## _mem_realloc_func(void *old, size_t size) #define ZBX_MEM_FUNC1_DECL_FREE(__prefix) \ static void __prefix ## _mem_free_func(void *ptr) #define ZBX_MEM_FUNC1_IMPL_MALLOC(__prefix, __info) \ \ static void *__prefix ## _mem_malloc_func(void *old, size_t size) \ { \ return zbx_mem_malloc(__info, old, size); \ } #define ZBX_MEM_FUNC1_IMPL_REALLOC(__prefix, __info) \ \ static void *__prefix ## _mem_realloc_func(void *old, size_t size) \ { \ return zbx_mem_realloc(__info, old, size); \ } #define ZBX_MEM_FUNC1_IMPL_FREE(__prefix, __info) \ \ static void __prefix ## _mem_free_func(void *ptr) \ { \ zbx_mem_free(__info, ptr); \ } #define ZBX_MEM_FUNC_DECL(__prefix) \ \ ZBX_MEM_FUNC1_DECL_MALLOC(__prefix); \ ZBX_MEM_FUNC1_DECL_REALLOC(__prefix); \ ZBX_MEM_FUNC1_DECL_FREE(__prefix); #define ZBX_MEM_FUNC_IMPL(__prefix, __info) \ \ ZBX_MEM_FUNC1_IMPL_MALLOC(__prefix, __info); \ ZBX_MEM_FUNC1_IMPL_REALLOC(__prefix, __info); \ ZBX_MEM_FUNC1_IMPL_FREE(__prefix, __info); #endif
#include "debug/debug.h" #include <errno.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <sys/stat.h> #include <sys/types.h> #include "data_structures/linkedlist/linkednode.h" Linkednode * Linkednode_new(size_t size, const void * value, size_t value_size) { Linkednode *node = calloc(1, size); check_mem(node); node->init = Linkednode_init; node->destroy = Linkednode_destroy; node->print = Linkednode_print; node->set = Linkednode_set; node->get = Linkednode_get; if(node->init(node, value, value_size) == EXIT_FAILURE) { throw("linkednode init failed"); } else { return node; } error: if(node) { node->destroy(node); }; return NULL; } /** * int Linkednode_init(Linkednode *this, const void * value, size_t value_size) * * Linkednode *this; instance to initialize * const void *value; void const-y pointer to value to store * size_t value_size; size of object to store * * PURPOSE : initilize the node, NULL out properties and use the set value to store a copy of the pointer being saved * RETURN : success bool * NOTES : when a pointer is placed into a node it is copied and * ownership is retained by the node until it is freed * * anyone who wants to manipulate a value retreived from a node should * copy the object and make sure to clean up their manipulated object */ int Linkednode_init(Linkednode *this, const void * value, size_t value_size) { this->value = NULL; this->next = NULL; this->size = 0; return this->set(this, value, value_size); } void Linkednode_destroy(Linkednode *this){ if(this){ if(this->value) { free(this->value); } if(this->next) { this->next->destroy(this->next); } free(this); } } void Linkednode_print(Linkednode *this) { debug("Linkednode"); } /** * int Linkednode_set(Linkednode *this, const void * value, size_t value_size) * * Linkednode *this; instance to initialize * const void *value; void const-y pointer to value to store * size_t value_size; size of object to store * * PURPOSE : store a copy of the value pointer * RETURN : success bool * NOTES : when a pointer is placed into a node it is copied and * ownership is retained by the node until it is freed * * anyone who wants to manipulate a value retreived from a node should * copy the object and make sure to clean up their manipulated object */ int Linkednode_set(Linkednode *this, const void * value, size_t value_size) { if(this->value != NULL) { free(this->value); } this->value = NULL; this->size = value_size; this->value = calloc(1, this->size + 1); check_mem(this->value); memcpy(this->value, value, this->size); return EXIT_SUCCESS; error: return EXIT_FAILURE; } /** * const void * Linkednode_get(Linkednode *this) * * Linkednode *this; instance to initialize * * PURPOSE : return the value pointer * RETURN : consty pointer to the value * NOTES : when a pointer is placed into a node it is copied and * ownership is retained by the node until it is freed * * anyone who wants to manipulate a value retreived from a node should * copy the object and make sure to clean up their manipulated object */ const void * Linkednode_get(Linkednode *this) { return this->value; }
// // RibumenweekPapers.h // Lvpingguo // // Created by miao on 14-9-22. // Copyright (c) 2014年 fuyonghua. All rights reserved. // #import <Foundation/Foundation.h> #import"IAnnotatable.h" @interface RibumenweekPapers : NSObject<IAnnotatable> @property(nonatomic,retain)NSString*ID; @property(nonatomic,retain)NSString*summary; @property(nonatomic,retain)NSString*plan; @property(nonatomic,retain)NSString*createid; @property(nonatomic,retain)NSString*createtime; @property(nonatomic,retain)NSString*deptid; @property(nonatomic,retain)NSString*companyid; @property(nonatomic,retain)NSString*dailyUsers; @property(nonatomic,retain)NSString*type; @end
/* * Copyright (C) 2013 Intel, Inc * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Author: Thomas Wood <thomas.wood@intel.com> * */ #include <gio/gio.h> #ifndef SSHD_SERVICE #define SSHD_SERVICE "sshd.service" #endif static const gchar *service_list[] = { SSHD_SERVICE, NULL }; static gint enable_ssh_service () { GDBusConnection *connection; GError *error = NULL; GVariant *temp_variant; connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); if (!connection) { g_critical ("Error connecting to D-Bus system bus: %s", error->message); g_clear_error (&error); return 1; } temp_variant = g_dbus_connection_call_sync (connection, "org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "StartUnit", g_variant_new ("(ss)", SSHD_SERVICE, "replace"), (GVariantType *) "(o)", G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (!temp_variant) { g_critical ("Error starting " SSHD_SERVICE ": %s", error->message); g_clear_error (&error); return 1; } g_variant_unref (temp_variant); temp_variant = g_dbus_connection_call_sync (connection, "org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "EnableUnitFiles", g_variant_new ("(^asbb)", service_list, FALSE, FALSE), (GVariantType *) "(ba(sss))", G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (!temp_variant) { g_critical ("Error enabling " SSHD_SERVICE ": %s", error->message); g_clear_error (&error); return 1; } g_variant_unref (temp_variant); return 0; } static gint disable_ssh_service () { GDBusConnection *connection; GError *error = NULL; GVariant *temp_variant; connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); if (!connection) { g_critical ("Error connecting to D-Bus system bus: %s", error->message); g_clear_error (&error); return 1; } temp_variant = g_dbus_connection_call_sync (connection, "org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "StopUnit", g_variant_new ("(ss)", SSHD_SERVICE, "replace"), (GVariantType *) "(o)", G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (!temp_variant) { g_critical ("Error stopping " SSHD_SERVICE ": %s", error->message); g_clear_error (&error); return 1; } g_variant_unref (temp_variant); temp_variant = g_dbus_connection_call_sync (connection, "org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "DisableUnitFiles", g_variant_new ("(^asb)", service_list, FALSE, FALSE), (GVariantType *) "(a(sss))", G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (!temp_variant) { g_critical ("Error disabling " SSHD_SERVICE ": %s", error->message); g_clear_error (&error); return 1; } g_variant_unref (temp_variant); return 0; } int main (int argc, char **argv) { if (argc < 2) return 1; if (argv[1] == NULL) return 1; if (g_str_equal (argv[1], "enable")) return enable_ssh_service (); else if (g_str_equal (argv[1], "disable")) return disable_ssh_service (); return 1; }
#include <stdio.h> #include <stdint.h> #include <stdlib.h> uint32_t H[5] = { 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0 }; uint32_t rotl( uint32_t x, int shift ) { return (x << shift) | (x >> (sizeof(x)*8 - shift)); } uint32_t roundFunc( uint32_t b, uint32_t c, uint32_t d, int roundNum ) { if( roundNum <= 19 ) { return (b & c) | ((~b) & d); } else if( roundNum <= 39 ) { return ( b ^ c ^ d ); } else if( roundNum <= 59 ) { return (b & c) | (b & d) | (c & d); } else { return ( b ^ c ^ d ); } } uint32_t kForRound( int roundNum ) { if( roundNum <= 19 ) { return 0x5a827999; } else if( roundNum <= 39 ) { return 0x6ed9eba1; } else if( roundNum <= 59 ) { return 0x8f1bbcdc; } else { return 0xca62c1d6; } } int pad(uint8_t * block, uint8_t * extraBlock, int blockSize, int fileSize) { int twoBlocks = 0; //l is block size in bits uint64_t l = (uint64_t)fileSize * 8; if(blockSize <= 55) { block[blockSize] = 0x80; int i; for( i = 0; i < 8; i++ ) { block[56+i] = (l >> (56-(8*i))); } } else { twoBlocks = 1; if(blockSize < 63) block[blockSize] = 0x80; else extraBlock[0] = 0x80; int i; for( i = 0; i < 8; i++ ) { extraBlock[56+i] = (l >> (56-(8*i))); } } return twoBlocks; } void doSha1(uint8_t * block) { static uint32_t w[80] = {0x00000000}; int i; for( i = 0; i < 16; i++ ) { int offset = (i*4); w[i] = block[offset] << 24 | block[offset + 1] << 16 | block[offset + 2] << 8 | block[offset + 3]; } for( i = 16; i < 80; i++ ) { uint32_t tmp = (w[i-3] ^ w[i-8] ^ w[i-14] ^ w[i-16]); w[i] = rotl( tmp, 1 ); } uint32_t a = H[0]; uint32_t b = H[1]; uint32_t c = H[2]; uint32_t d = H[3]; uint32_t e = H[4]; for( i = 0; i < 80; i++ ) { uint32_t tmp = rotl(a, 5) + roundFunc(b,c,d,i) + e + w[i] + kForRound(i); e = d; d = c; c = rotl(b, 30); b = a; a = tmp; // printf("%d: %x, %x, %x, %x, %x\n", i, a, b, c,d,e); } H[0] = H[0] + a; H[1] = H[1] + b; H[2] = H[2] + c; H[3] = H[3] + d; H[4] = H[4] + e; } int main( int argc, char **argv ) { if( argc == 2 ) { char * fileName = argv[1]; //Read the input file 512 bits at a time = 64 bytes = 16 32-bit words FILE * file = fopen( fileName, "rb" ); int fileSize = 0; if( file != NULL ) { uint8_t *block = malloc(64); size_t readSize = fread( block, 1, 64, file ); fileSize += readSize; while( readSize == 64 ) { doSha1(block); readSize = fread( block, 1, 64, file ); fileSize += readSize; } //We need padding uint8_t *extraBlock = malloc(64); int i; for(i = readSize; i < 64; i++) { block[i] = 0x00; extraBlock[i] = 0x00; } int twoBlocks = pad(block, extraBlock, readSize, fileSize); doSha1(block); if(twoBlocks == 1) { doSha1(extraBlock); } for( i = 0; i < 5; i++) { printf("%08x",H[i]); } printf("\n"); } else { printf("Input file must exist.\n"); } } else { printf("Usage is sha1 [filename]\n"); } }
#ifndef BASIC_INFO_H #define BASIC_INFO_H #include <QString> #include <QDebug> class basic_info { public: basic_info(); ~basic_info(); void setid(long &data); double id(); void setname(QString data); QString name(); void setic(long &data); double ic(); void setlv(long &data); double lv(); private: double* summonerid; QString* summonername; double* profileIconId; double* summonerLevel; }; QDebug operator << (QDebug dbg, basic_info b); #endif // BASIC_INFO_H
/* * (c) 2012 Sascha Hauer <s.hauer@pengutronix.de> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 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. */ #include <common.h> #include <init.h> #include <io.h> #include <errno.h> #include <malloc.h> #include <watchdog.h> #include <reset_source.h> struct imx_wd { struct watchdog wd; void __iomem *base; struct device_d *dev; int (*set_timeout)(struct imx_wd *, unsigned); }; #define to_imx_wd(h) container_of(h, struct imx_wd, wd) #define IMX1_WDOG_WCR 0x00 /* Watchdog Control Register */ #define IMX1_WDOG_WSR 0x04 /* Watchdog Service Register */ #define IMX1_WDOG_WSTR 0x08 /* Watchdog Status Register */ #define IMX1_WDOG_WCR_WDE (1 << 0) #define IMX1_WDOG_WCR_WHALT (1 << 15) #define IMX21_WDOG_WCR 0x00 /* Watchdog Control Register */ #define IMX21_WDOG_WSR 0x02 /* Watchdog Service Register */ #define IMX21_WDOG_WSTR 0x04 /* Watchdog Status Register */ #define IMX21_WDOG_WCR_WDE (1 << 2) #define IMX21_WDOG_WCR_SRS (1 << 4) #define IMX21_WDOG_WCR_WDA (1 << 5) /* valid for i.MX25, i.MX27, i.MX31, i.MX35, i.MX51 */ #define WSTR_WARMSTART (1 << 0) /* valid for i.MX25, i.MX27, i.MX31, i.MX35, i.MX51 */ #define WSTR_WDOG (1 << 1) /* valid for i.MX27, i.MX31, always '0' on i.MX25, i.MX35, i.MX51 */ #define WSTR_HARDRESET (1 << 3) /* valid for i.MX27, i.MX31, always '0' on i.MX25, i.MX35, i.MX51 */ #define WSTR_COLDSTART (1 << 4) static int imx1_watchdog_set_timeout(struct imx_wd *priv, int timeout) { u16 val; dev_dbg(priv->dev, "%s: %d\n", __func__, timeout); if (timeout > 64) return -EINVAL; if (!timeout) { writew(IMX1_WDOG_WCR_WHALT, priv->base + IMX1_WDOG_WCR); return 0; } if (timeout > 0) val = (timeout * 2 - 1) << 8; else val = 0; writew(val, priv->base + IMX1_WDOG_WCR); writew(IMX1_WDOG_WCR_WDE | val, priv->base + IMX1_WDOG_WCR); /* Write Service Sequence */ writew(0x5555, priv->base + IMX1_WDOG_WSR); writew(0xaaaa, priv->base + IMX1_WDOG_WSR); return 0; } static int imx21_watchdog_set_timeout(struct imx_wd *priv, int timeout) { u16 val; dev_dbg(priv->dev, "%s: %d\n", __func__, timeout); if (!timeout || timeout > 128) return -EINVAL; if (timeout > 0) val = ((timeout * 2 - 1) << 8) | IMX21_WDOG_WCR_SRS | IMX21_WDOG_WCR_WDA; else val = 0; writew(val, priv->base + IMX21_WDOG_WCR); writew(IMX21_WDOG_WCR_WDE | val, priv->base + IMX21_WDOG_WCR); /* Write Service Sequence */ writew(0x5555, priv->base + IMX21_WDOG_WSR); writew(0xaaaa, priv->base + IMX21_WDOG_WSR); return 0; } static int imx_watchdog_set_timeout(struct watchdog *wd, unsigned timeout) { struct imx_wd *priv = (struct imx_wd *)to_imx_wd(wd); return priv->set_timeout(priv, timeout); } static struct imx_wd *reset_wd; void __noreturn reset_cpu(unsigned long addr) { if (reset_wd) reset_wd->set_timeout(reset_wd, -1); mdelay(1000); hang(); } static void imx_watchdog_detect_reset_source(struct imx_wd *priv) { u16 val = readw(priv->base + IMX21_WDOG_WSTR); if (val & WSTR_COLDSTART) { set_reset_source(RESET_POR); return; } if (val & (WSTR_HARDRESET | WSTR_WARMSTART)) { set_reset_source(RESET_RST); return; } if (val & WSTR_WDOG) { set_reset_source(RESET_WDG); return; } /* else keep the default 'unknown' state */ } static int imx_wd_probe(struct device_d *dev) { struct imx_wd *priv; void *fn; int ret; ret = dev_get_drvdata(dev, (unsigned long *)&fn); if (ret) return ret; priv = xzalloc(sizeof(struct imx_wd)); priv->base = dev_request_mem_region(dev, 0); priv->set_timeout = fn; priv->wd.set_timeout = imx_watchdog_set_timeout; priv->dev = dev; if (!reset_wd) reset_wd = priv; if (IS_ENABLED(CONFIG_WATCHDOG_IMX)) { ret = watchdog_register(&priv->wd); if (ret) goto on_error; } if (fn != imx1_watchdog_set_timeout) imx_watchdog_detect_reset_source(priv); dev->priv = priv; return 0; on_error: if (reset_wd && reset_wd != priv) free(priv); return ret; } static void imx_wd_remove(struct device_d *dev) { struct imx_wd *priv = dev->priv; if (IS_ENABLED(CONFIG_WATCHDOG_IMX)) watchdog_deregister(&priv->wd); if (reset_wd && reset_wd != priv) free(priv); } static __maybe_unused struct of_device_id imx_wdt_dt_ids[] = { { .compatible = "fsl,imx1-wdt", .data = (unsigned long)&imx1_watchdog_set_timeout, }, { .compatible = "fsl,imx21-wdt", .data = (unsigned long)&imx21_watchdog_set_timeout, }, { /* sentinel */ } }; static struct platform_device_id imx_wdt_ids[] = { { .name = "imx1-wdt", .driver_data = (unsigned long)&imx1_watchdog_set_timeout, }, { .name = "imx21-wdt", .driver_data = (unsigned long)&imx21_watchdog_set_timeout, }, { /* sentinel */ }, }; static struct driver_d imx_wd_driver = { .name = "imx-watchdog", .probe = imx_wd_probe, .remove = imx_wd_remove, .of_compatible = DRV_OF_COMPAT(imx_wdt_dt_ids), .id_table = imx_wdt_ids, }; static int imx_wd_init(void) { return platform_driver_register(&imx_wd_driver); } device_initcall(imx_wd_init);
#ifndef QABSTRACTWIDGETHOST_H #define QABSTRACTWIDGETHOST_H #include "qabstracthost.h" class KERNEL_EXPORT QAbstractWidgetHost : public QAbstractHost { Q_OBJECT public: QAbstractWidgetHost(QAbstractWidgetHost * parent = NULL); protected: void initProperty(); public slots: void setGeometry(int x,int y,int width,int height); int getX(); int getY(); int getWidth(); int getHeight(); void setEnabled(bool enabled); bool getEnabled(); void setToolTip(const QString &tooltip); QString getToolTip(); void setCursor(int cursor); int getCursor(); void setLevel(int level); int getLevel(); void setFocusPolicy(int focusPolicy); int getFocusPolicy(); void setFontSize(int pointSize); int getFontSize(); void setFontFamily(const QString &family); QString getFontFamily(); void setFontBold(bool bold); bool getFontBold(); void setFontUnderline(bool underline); bool getFontUnderline(); void setFontItalic(bool italic); bool getFontItalic(); void setFontStrikeout(bool strikeout); bool getFontStrikeout(); }; #endif // QABSTRACTWIDGETHOST_H
#ifndef __LINUX_DMI_H #define __LINUX_DMI_H #include <linux/list.h> enum dmi_field { DMI_NONE, DMI_BIOS_VENDOR, DMI_BIOS_VERSION, DMI_BIOS_DATE, DMI_SYS_VENDOR, DMI_PRODUCT_NAME, DMI_PRODUCT_VERSION, DMI_PRODUCT_SERIAL, DMI_PRODUCT_UUID, DMI_BOARD_VENDOR, DMI_BOARD_NAME, DMI_BOARD_VERSION, DMI_BOARD_SERIAL, DMI_BOARD_ASSET_TAG, DMI_CHASSIS_VENDOR, DMI_CHASSIS_TYPE, DMI_CHASSIS_VERSION, DMI_CHASSIS_SERIAL, DMI_CHASSIS_ASSET_TAG, DMI_STRING_MAX, }; enum dmi_device_type { DMI_DEV_TYPE_ANY = 0, DMI_DEV_TYPE_OTHER, DMI_DEV_TYPE_UNKNOWN, DMI_DEV_TYPE_VIDEO, DMI_DEV_TYPE_SCSI, DMI_DEV_TYPE_ETHERNET, DMI_DEV_TYPE_TOKENRING, DMI_DEV_TYPE_SOUND, DMI_DEV_TYPE_PATA, DMI_DEV_TYPE_SATA, DMI_DEV_TYPE_SAS, DMI_DEV_TYPE_IPMI = -1, DMI_DEV_TYPE_OEM_STRING = -2, }; struct dmi_header { u8 type; u8 length; u16 handle; }; struct dmi_device { struct list_head list; int type; const char *name; void *device_data; /* Type specific data */ }; struct dmi_system_id; static inline int dmi_check_system(const struct dmi_system_id *list) { return 0; } static inline const char * dmi_get_system_info(int field) { return NULL; } static inline const struct dmi_device * dmi_find_device(int type, const char *name, const struct dmi_device *from) { return NULL; } static inline void dmi_scan_machine(void) { return; } static inline bool dmi_get_date(int field, int *yearp, int *monthp, int *dayp) { if (yearp) *yearp = 0; if (monthp) *monthp = 0; if (dayp) *dayp = 0; return false; } static inline int dmi_name_in_vendors(const char *s) { return 0; } static inline int dmi_name_in_serial(const char *s) { return 0; } #define dmi_available 0 static inline int dmi_walk(void (*decode)(const struct dmi_header *, void *), void *private_data) { return -1; } static inline bool dmi_match(enum dmi_field f, const char *str) { return false; } static inline const struct dmi_system_id * dmi_first_match(const struct dmi_system_id *list) { return NULL; } #endif
// // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018 // // Distributed under 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 "td/utils/logging.h" #include <utility> namespace td { template <class StatT> class TimedStat { public: TimedStat(double duration, double now) : duration_(duration), current_(), current_timestamp_(now), next_(), next_timestamp_(now) { } TimedStat() : TimedStat(0, 0) { } template <class EventT> void add_event(const EventT &e, double now) { update(now); current_.on_event(e); next_.on_event(e); } const StatT &get_stat(double now) { update(now); return current_; } std::pair<StatT, double> stat_duration(double now) { update(now); return std::make_pair(current_, now - current_timestamp_); } void clear_events() { current_.clear(); next_.clear(); } private: double duration_; StatT current_; double current_timestamp_; StatT next_; double next_timestamp_; void update(double &now) { if (now < next_timestamp_) { CHECK(now >= next_timestamp_ * (1 - 1e-14)) << now << " " << next_timestamp_; now = next_timestamp_; } if (duration_ == 0) { return; } if (next_timestamp_ + 2 * duration_ < now) { current_ = StatT(); current_timestamp_ = now; next_ = StatT(); next_timestamp_ = now; } else if (next_timestamp_ + duration_ < now) { current_ = next_; current_timestamp_ = next_timestamp_; next_ = StatT(); next_timestamp_ = now; } } }; } // namespace td
/* arch/arm/mach-msm/htc_wifi_nvs.c * * Code to extract WiFi calibration information from ATAG set up * by the bootloader. * * Copyright (C) 2008 Google, Inc. * Author: Dmitry Shmidt <dimitrysh@google.com> * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and * may be copied, distributed, and modified under those terms. * * 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. * */ #include <linux/kernel.h> #include <linux/init.h> #include <linux/platform_device.h> #include <linux/proc_fs.h> #include <asm/setup.h> #include <mach/htc_wifi_nvs.h> /* configuration tags specific to msm */ #define ATAG_MSM_WIFI 0x57494649 /* MSM WiFi */ #define NVS_MAX_SIZE 0x800U #define NVS_LEN_OFFSET 0x0C #define NVS_DATA_OFFSET 0x40 static unsigned char wifi_nvs_ram[NVS_MAX_SIZE]; static struct proc_dir_entry *wifi_calibration; static struct proc_dir_entry *wifi_data; unsigned char *get_wifi_nvs_ram( void ) { return wifi_nvs_ram; } EXPORT_SYMBOL(get_wifi_nvs_ram); unsigned char *wlan_random_mac(unsigned char *set_mac_addr) { static unsigned char mac_addr[6] = {0, 0, 0, 0, 0, 0}; if (set_mac_addr != NULL) { mac_addr[0] = set_mac_addr[0]; mac_addr[1] = set_mac_addr[1]; mac_addr[2] = set_mac_addr[2]; mac_addr[3] = set_mac_addr[3]; mac_addr[4] = set_mac_addr[4]; mac_addr[5] = set_mac_addr[5]; } return mac_addr; } EXPORT_SYMBOL(wlan_random_mac); static int __init parse_tag_msm_wifi(const struct tag *tag) { unsigned char *dptr = (unsigned char *)(&tag->u); unsigned size; #ifdef ATAG_MSM_WIFI_DEBUG unsigned i; #endif size = min((tag->hdr.size - 2) * sizeof(__u32), NVS_MAX_SIZE); #ifdef ATAG_MSM_WIFI_DEBUG printk("WiFi Data size = %d , 0x%x\n", tag->hdr.size, tag->hdr.tag); for (i = 0; i < size ; i++) printk("%02x ", *dptr++); #endif memcpy(wifi_nvs_ram, dptr, size); return 0; } __tagtable(ATAG_MSM_WIFI, parse_tag_msm_wifi); static unsigned wifi_get_nvs_size(void) { unsigned char *ptr; unsigned len; ptr = get_wifi_nvs_ram(); /* Size in format LE assumed */ memcpy(&len, ptr + NVS_LEN_OFFSET, sizeof(len)); len = min(len, (NVS_MAX_SIZE - NVS_DATA_OFFSET)); return len; } int wifi_calibration_size_set(void) { if (wifi_calibration != NULL) wifi_calibration->size = wifi_get_nvs_size(); return 0; } int htc_get_wifi_calibration(char *buf, int count) { unsigned char *ptr; unsigned len; ptr = get_wifi_nvs_ram(); len = min(wifi_get_nvs_size(), (unsigned) count); memcpy(buf, ptr + NVS_DATA_OFFSET, len); return len; } EXPORT_SYMBOL(htc_get_wifi_calibration); static int wifi_calibration_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data) { return htc_get_wifi_calibration(page, count); } int htc_get_wifi_data(char *buf) { unsigned char *ptr; ptr = get_wifi_nvs_ram(); memcpy(buf, ptr, NVS_DATA_OFFSET); return NVS_DATA_OFFSET; } static int wifi_data_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data) { return htc_get_wifi_data(page); } static int __init wifi_nvs_init(void) { wifi_calibration = create_proc_entry("calibration", 0444, NULL); if (wifi_calibration != NULL) { wifi_calibration->size = wifi_get_nvs_size(); wifi_calibration->read_proc = wifi_calibration_read_proc; wifi_calibration->write_proc = NULL; } wifi_data = create_proc_entry("wifi_data", 0444, NULL); if (wifi_data != NULL) { wifi_data->size = NVS_DATA_OFFSET; wifi_data->read_proc = wifi_data_read_proc; wifi_data->write_proc = NULL; } return 0; } late_initcall(wifi_nvs_init);
/* WASTE - mqueuelist.h (Class that handles routing messages through queues) Copyright (C) 2003 Nullsoft, Inc. WASTE 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. WASTE 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 WASTE; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _C_MQUEUELIST_H_ #define _C_MQUEUELIST_H_ #include "mqueue.h" #ifdef _WIN32 #include "listview.h" #endif #include "itemlist.h" class C_MessageQueueList { public: C_MessageQueueList(void (*gm)(T_Message *message, C_MessageQueueList *_this, C_Connection *cn), int maxttl=5); ~C_MessageQueueList(); int AddMessageQueue(C_MessageQueue *q); int send(T_Message *msg); int GetNumQueues(void) { return m_queues->GetSize(); } C_MessageQueue *GetQueue(int x) { return m_queues->Get(x); } #ifdef _WIN32 void SetStatusListView(W_ListView *lv) {m_lv=lv;} #endif void run(int doRouting); void reset_route_error_count() { m_stat_route_errors=0; } int get_route_error_count() { return m_stat_route_errors; } int get_max_ttl(void) { return m_max_ttl; } void set_max_ttl(int a) { m_max_ttl=a; } int find_route(T_GUID *id, unsigned char msgtype); // -1 = local, -2 = none, >=0 = queue static unsigned char GetMessagePriority(int type); protected: C_ItemList<C_MessageQueue> *m_queues; C_MessageQueue *m_local_route; #ifdef _WIN32 W_ListView *m_lv; #endif int m_max_ttl; int m_stat_route_errors; int m_run_rr; void (*m_got_message)(T_Message *message, C_MessageQueueList *_this, C_Connection *cn); }; #endif //_C_MQUEUELIST_H_
/* Copyright holders: Sarah Walker, Tenshi see COPYING for more details */ void i430fx_init();
/** ****************************************************************************** * @file STM32F4xx_IAP/src/main.c * @author MCD Application Team * @version V1.0.0 * @date 10-October-2011 * @brief Main program body ****************************************************************************** * @attention * * 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. * * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2> ****************************************************************************** */ /** @addtogroup STM32F4xx_IAP * @{ */ /* Includes ------------------------------------------------------------------*/ #include "menu.h" #include "stm324xg_eval.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ extern pFunction Jump_To_Application; extern uint32_t JumpAddress; /* Private function prototypes -----------------------------------------------*/ static void IAP_Init(void); /* Private functions ---------------------------------------------------------*/ /** * @brief Main program. * @param None * @retval None */ int main(void) { /* Unlock the Flash Program Erase controller */ FLASH_If_Init(); /* Initialize Key Button mounted on STM324xG-EVAL board */ STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_GPIO); /* Test if Key push-button on STM324xG-EVAL Board is pressed */ if (STM_EVAL_PBGetState(BUTTON_KEY) == 0x00) { /* Execute the IAP driver in order to reprogram the Flash */ IAP_Init(); /* Display main menu */ Main_Menu (); } /* Keep the user application running */ else { /* Test if user code is programmed starting from address "APPLICATION_ADDRESS" */ /* Jump to user application */ JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4 + 1); Jump_To_Application = (pFunction) JumpAddress; /* Initialize user application's Stack Pointer */ __set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS); Jump_To_Application(); } while (1) {} } /** * @brief Initialize the IAP: Configure USART. * @param None * @retval None */ void IAP_Init(void) { USART_InitTypeDef USART_InitStructure; /* USART resources configuration (Clock, GPIO pins and USART registers) ----*/ /* USART configured as follow: - BaudRate = 115200 baud - Word Length = 8 Bits - One Stop Bit - No parity - Hardware flow control disabled (RTS and CTS signals) - Receive and transmit enabled */ USART_InitStructure.USART_BaudRate = 115200; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; STM_EVAL_COMInit(COM1, &USART_InitStructure); } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t* file, uint32_t line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* Infinite loop */ while (1) { } } #endif /** * @} */ /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
/* printer.h --- Convert DIGEST-MD5 token structures into strings. * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Simon Josefsson * * This file is part of GNU SASL Library. * * GNU SASL 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. * * GNU SASL 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 GNU SASL Library; if not, write to the Free * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * */ #ifndef DIGEST_MD5_PRINTER_H # define DIGEST_MD5_PRINTER_H /* Get token types. */ #include "tokens.h" extern char *digest_md5_print_challenge (digest_md5_challenge * challenge); extern char *digest_md5_print_response (digest_md5_response * response); extern char *digest_md5_print_finish (digest_md5_finish * out); #endif /* DIGEST_MD5_PRINTER_H */
///////////////////////////////////////////////////////////////////////////// // FrameMarker // Module, which marks all incoming data units with the given fields // for clp marking: only frames which are >= maxsize are marked with clp // // Marker <name>: // {DOMARK=<int>} // {CLP=<int>,}: if not given, clp will not be set // {MAXSIZE=<int>,}: if not given, clp will not be set // {vlanId=<int>,}: if <0 or if not given, vlanId will not be set // {vlanPriority=<int>,}: if <0 or if not given, vlanPriority will not be set // {dropPrecedence=<int>,}: if <0 or if not given, dropPrecedence will not be set // {internalDropPrecedence=<int>,}: if <0 or not given, internalDropPrecedence will not be set // OUT=<suc>; ///////////////////////////////////////////////////////////////////////////// #include "framemarker.h" framemarker::framemarker() { } framemarker::~framemarker() { } ///////////////////////////////////////////////////////////////////////////// // init() ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // rec() ///////////////////////////////////////////////////////////////////////////// /* void framemarker::addpars(void) { // read additional parameters of derived classes baseclass::addpars(); if (test_word("MAXSIZE")) { maxsize = read_int("MAXSIZE"); if(maxsize < 0) syntax0("MAXSIZE must be >=0"); skip(','); } else maxsize = 10000; if (test_word("vlanId")) { vlanId = read_int("vlanId"); skip(','); } else vlanId = -1; if (test_word("vlanPriority")) { vlanPriority = read_int("vlanPriority"); skip(','); } else vlanPriority = -1; if (test_word("dropPrecedence")) { dropPrecedence = read_int("dropPrecedence"); skip(','); } else dropPrecedence = -1; if (test_word("internalDropPrecedence")) { internalDropPrecedence = read_int("internalDropPrecedence"); skip(','); } else internalDropPrecedence = -1; } // framemarker:init() */ rec_typ framemarker::REC(data *pd,int) { typecheck(pd, FrameType); frame *pf = (frame*) pd; // check if smaller than maxsize and if marking is to be performed if(domark && pf->frameLen <= maxsize && markclp >= 0) pd->clp = markclp; // mark the data item if(vlanId >= 0) pf->vlanId = vlanId; if(vlanPriority >= 0) pf->vlanPriority = vlanPriority; if(dropPrecedence >= 0) pf->dropPrecedence = dropPrecedence; if(internalDropPrecedence >= 0) pf->internalDropPrecedence = internalDropPrecedence; return suc->rec(pd, shand); // send it } // marker::REC()
/* Launchy: Application Launcher Copyright (C) 2005 Josh Karlin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #pragma once #include "boost/smart_ptr.hpp" using namespace boost; class FileRecord; typedef shared_ptr<FileRecord> FileRecordPtr; class Launcher { public: Launcher(void); ~Launcher(void); virtual void Run(FileRecordPtr file, CString) = 0; };
/* * basic definitions for when including standard headers isn't safe * * Copyright (c) 2003 Fabrice Bellard * * 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 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA */ #ifndef QEMU_STDIO_DEFS #define QEMU_STDIO_DEFS #ifdef _BSD typedef struct __sFILE FILE; #else typedef struct FILE FILE; #endif extern int fprintf(FILE *, const char *, ...); extern int fputs(const char *, FILE *); extern int printf(const char *, ...); #endif
/* File: file_torrent.c Copyright (C) 2010 Christophe GRENIER <grenier@cgsecurity.org> This software 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 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #if !defined(SINGLE_FORMAT) || defined(SINGLE_FORMAT_torrent) #ifdef HAVE_CONFIG_H #include <config.h> #endif #ifdef HAVE_STRING_H #include <string.h> #endif #include <stdio.h> #include "types.h" #include "filegen.h" /*@ requires valid_register_header_check(file_stat); */ static void register_header_check_torrent(file_stat_t *file_stat); const file_hint_t file_hint_torrent = { .extension = "torrent", .description = "Torrent", .max_filesize = PHOTOREC_MAX_FILE_SIZE, .recover = 1, .enable_by_default = 1, .register_header_check = &register_header_check_torrent }; /*@ @ requires buffer_size >= 12; @ requires separation: \separated(&file_hint_torrent, buffer+(..), file_recovery, file_recovery_new); @ requires valid_header_check_param(buffer, buffer_size, safe_header_only, file_recovery, file_recovery_new); @ ensures valid_header_check_result(\result, file_recovery_new); @ assigns *file_recovery_new; @*/ static int header_check_torrent(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new) { if(buffer[11] < '0' || buffer[11] > '9') return 0; reset_file_recovery(file_recovery_new); file_recovery_new->extension = file_hint_torrent.extension; return 1; } static void register_header_check_torrent(file_stat_t *file_stat) { register_header_check(0, "d8:announce", 11, &header_check_torrent, file_stat); } #endif
/* SDL_guitk - GUI toolkit designed for SDL environnements (GTK-style). Copyright (C) 2020 Trave Roman This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _SDLguitk_grid_h #define _SDLguitk_grid_h #include <SDL2/SDL.h> #include "SDL_guitk.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /* SDLGuiTK_Grid structure definition */ /* Widget grouping boxes definition */ typedef struct SDLGuiTK_Grid SDLGuiTK_Grid; extern DECLSPEC SDL_bool SDLGuiTK_IS_GRID( SDLGuiTK_Widget * widget ); extern DECLSPEC SDLGuiTK_Grid *SDLGuiTK_GRID( SDLGuiTK_Widget *widget ); /* */ extern DECLSPEC SDLGuiTK_Widget *SDLGuiTK_grid_new(); extern DECLSPEC void SDLGuiTK_grid_attach ( SDLGuiTK_Grid *grid, SDLGuiTK_Widget *child, int left, int top, int width, int height ); extern DECLSPEC void SDLGuiTK_grid_set_column_spacing (SDLGuiTK_Grid *grid, int column_spacing); extern DECLSPEC int SDLGuiTK_grid_get_column_spacing (SDLGuiTK_Grid *grid); extern DECLSPEC void SDLGuiTK_grid_set_row_spacing (SDLGuiTK_Grid *grid, int row_spacing); extern DECLSPEC int SDLGuiTK_grid_get_row_spacing (SDLGuiTK_Grid *grid); extern DECLSPEC void SDLGuiTK_grid_set_column_homogeneous (SDLGuiTK_Grid *grid, SDL_bool column_homogeneous); extern DECLSPEC SDL_bool SDLGuiTK_grid_get_column_homogeneous (SDLGuiTK_Grid *grid); extern DECLSPEC void SDLGuiTK_grid_set_row_homogeneous (SDLGuiTK_Grid *grid, SDL_bool row_homogeneous); extern DECLSPEC SDL_bool SDLGuiTK_grid_get_row_homogeneous (SDLGuiTK_Grid *grid); /* Ends C function definitions when using C++ */ #ifdef __cplusplus }; #endif #endif /* _SDLguitk_grid_h */
/* * Copyright (C) 2001-2003 Sistina Software (UK) Limited. * * This file is released under the GPL. */ #include "dm.h" #include <linux/module.h> #include <linux/init.h> #include <linux/blkdev.h> #include <linux/bio.h> #include <linux/slab.h> /* * Linear: maps a linear range of a device. */ struct linear_c { struct dm_dev *dev; sector_t start; }; /* * Construct a linear mapping: <dev_path> <offset> */ static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv) { struct linear_c *lc; if (argc != 2) { ti->error = "dm-linear: Invalid argument count"; return -EINVAL; } lc = kmalloc(sizeof(*lc), GFP_KERNEL); if (lc == NULL) { ti->error = "dm-linear: Cannot allocate linear context"; return -ENOMEM; } if (sscanf(argv[1], SECTOR_FORMAT, &lc->start) != 1) { ti->error = "dm-linear: Invalid device sector"; goto bad; } if (dm_get_device(ti, argv[0], lc->start, ti->len, dm_table_get_mode(ti->table), &lc->dev)) { ti->error = "dm-linear: Device lookup failed"; goto bad; } ti->private = lc; return 0; bad: kfree(lc); return -EINVAL; } static void linear_dtr(struct dm_target *ti) { struct linear_c *lc = (struct linear_c *) ti->private; dm_put_device(ti, lc->dev); kfree(lc); } static int linear_map(struct dm_target *ti, struct bio *bio, union map_info *map_context) { struct linear_c *lc = (struct linear_c *) ti->private; bio->bi_bdev = lc->dev->bdev; bio->bi_sector = lc->start + (bio->bi_sector - ti->begin); return DM_MAPIO_REMAPPED; } static int linear_status(struct dm_target *ti, status_type_t type, char *result, unsigned int maxlen) { struct linear_c *lc = (struct linear_c *) ti->private; switch (type) { case STATUSTYPE_INFO: result[0] = '\0'; break; case STATUSTYPE_TABLE: snprintf(result, maxlen, "%s " SECTOR_FORMAT, lc->dev->name, lc->start); break; } return 0; } static int linear_ioctl(struct dm_target *ti, struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { struct linear_c *lc = (struct linear_c *) ti->private; struct block_device *bdev = lc->dev->bdev; struct file fake_file = {}; struct dentry fake_dentry = {}; fake_file.f_mode = lc->dev->mode; fake_file.f_dentry = &fake_dentry; fake_dentry.d_inode = bdev->bd_inode; return blkdev_ioctl(bdev->bd_inode, &fake_file, cmd, arg); } static struct target_type linear_target = { .name = "linear", .version= {1, 0, 2}, .module = THIS_MODULE, .ctr = linear_ctr, .dtr = linear_dtr, .map = linear_map, .status = linear_status, .ioctl = linear_ioctl, }; int __init dm_linear_init(void) { int r = dm_register_target(&linear_target); if (r < 0) DMERR("linear: register failed %d", r); return r; } void dm_linear_exit(void) { int r = dm_unregister_target(&linear_target); if (r < 0) DMERR("linear: unregister failed %d", r); }
/* * Driver for the si4703 FM/RDS/TMC Receiver * * 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. * * Author: Xander.Hover, <Xander.Hover@tomtom.com> */ #ifndef __INCLUDE_LINUX_SI4703_H # define __INCLUDE_LINUX_SI4703_H __FILE__ # include <linux/ioctl.h> # include <linux/major.h> # include <linux/fmreceiver.h> # define SI4703_DEVNAME "SI4703" # define SI4703_MAJOR FMRECEIVER_MAJOR /*# define SI4703_MINOR (FMRECEIVER_MINOR + 1) */ # define SI4703_MINOR FMRECEIVER_MINOR # define SI4703_I2C_SLAVE_ADDR (0x10) #endif /* __INCLUDE_LINUX_SI4703_H */
/********************************************************************** Map-N-Zap v2.x. Interface to the CYE Personal Robot Copyright (C) 2000, Probotics, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.Furthermore, this source code is distributed without any promise, implied or explicit, of support from Probotics, Inc. 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. Probotics, Inc http://www.personalrobots.com 700 River Ave #223 Pittsburgh, PA 15212 USA **********************************************************************/ #ifndef WORLD_H #define WORLD_H #include "Grid.h" #include "Rover.h" /* This is the class that represents the world of the rover */ class Path; class World : public Grid { public: Rover rover; private: public: unsigned char open_value; void (*ChangeScreen)(int row, int col, CharMatrix &m, CharMatrix &world); void (*ShowPath)(Path *path, int type); World(int row, int col, double size, int rover_width, int rover_length, unsigned char init = 0, unsigned char min = 0, unsigned char max = 255) : Grid(row, col, size, init, min, max), rover(rover_width, rover_length) { ChangeScreen = NULL; SetOrigin(0.0, 0.0); open_value = 200; }; World(int row, int col, double size, Rover &r, unsigned char init = 0, unsigned char min = 0, unsigned char max = 255) : Grid(row, col, size, init, min, max), rover(r) { ChangeScreen = NULL; SetOrigin(0.0, 0.0); open_value = 200; }; World(int row, int col, double size, Grid &g, unsigned char init = 0, unsigned char min = 0, unsigned char max = 255) : Grid(row, col, size, init, min, max), rover(g) { ChangeScreen = NULL; SetOrigin(0.0, 0.0); open_value = 200; }; unsigned char OpenValue() { return open_value; }; void ClearRoverPosition(double x, double y, double th, double dx, double dy, double dth); void ObstacleRoverPosition(double x, double y, double th, double dx, double dy, double dth, RoverGrid ind); Path *FindPath(Path *path, int max_iter); }; #endif /*WORLD_H*/
#ifndef LINKIMPLSHMEM_H #define LINKIMPLSHMEM_H #include "linkimpl.h" #include "initial.pb.h" #include <boost/interprocess/ipc/message_queue.hpp> class LinkImplSHMEM : public LinkImpl { private: const bool managed; using mq_t=boost::interprocess::message_queue; std::string name_host, name_guest; std::shared_ptr<mq_t> mq_send, mq_recv; std::shared_ptr<mq_t> createshm(std::string &name,std::string suffix); public: LinkImplSHMEM(); LinkImplSHMEM(const SHMEMConnParams& params); ~LinkImplSHMEM(); void sendMsg(const google::protobuf::Message &message) override; void recvMsg(google::protobuf::Message &message, std::atomic_bool *abortflag) override; void setMessageParams(NewConnectionReply &reply); }; #endif // LINKIMPLSHMEM_H
#include <linux/module.h> #include <linux/vermagic.h> #include <linux/compiler.h> MODULE_INFO(vermagic, VERMAGIC_STRING); struct module __this_module __attribute__((section(".gnu.linkonce.this_module"))) = { .name = KBUILD_MODNAME, .init = init_module, #ifdef CONFIG_MODULE_UNLOAD .exit = cleanup_module, #endif .arch = MODULE_ARCH_INIT, }; static const struct modversion_info ____versions[] __used __attribute__((section("__versions"))) = { { 0x62d8458c, "module_layout" }, { 0x3d23f427, "kmalloc_caches" }, { 0xef757cdc, "btmrvl_enable_ps" }, { 0xee9a0350, "btmrvl_register_hdev" }, { 0x4f7e01b, "btmrvl_add_card" }, { 0xf2c05893, "release_firmware" }, { 0xfa2a45e, "__memzero" }, { 0xe9bfd9ae, "request_firmware" }, { 0xd6b21686, "sdio_set_block_size" }, { 0x8fd9be91, "sdio_claim_irq" }, { 0xd7928b18, "sdio_enable_func" }, { 0x5c68339b, "kmem_cache_alloc" }, { 0x2196324, "__aeabi_idiv" }, { 0xeae3dfd6, "__const_udelay" }, { 0xa97a2ea3, "sdio_register_driver" }, { 0x61dfba5b, "kfree_skb" }, { 0xd7373056, "hci_recv_frame" }, { 0x722d6a15, "btmrvl_process_event" }, { 0xc8b53e78, "btmrvl_check_evtpkt" }, { 0xa0435bc, "sdio_readsb" }, { 0xc1e548a2, "skb_pull" }, { 0xc5e0b963, "skb_put" }, { 0x11d00927, "__alloc_skb" }, { 0x34908c14, "print_hex_dump_bytes" }, { 0x91fdf472, "sdio_writesb" }, { 0x9d669763, "memcpy" }, { 0x12da5bb2, "__kmalloc" }, { 0x88e5f543, "btmrvl_interrupt" }, { 0x74c97f9c, "_raw_spin_unlock_irqrestore" }, { 0xbd7083bc, "_raw_spin_lock_irqsave" }, { 0xf9a482f9, "msleep" }, { 0x37a0cba, "kfree" }, { 0x1a0ca4df, "btmrvl_remove_card" }, { 0x5df76809, "btmrvl_send_module_cfg_cmd" }, { 0xa3dda44, "dev_get_drvdata" }, { 0x64cf866e, "dev_set_drvdata" }, { 0x24670c40, "sdio_disable_func" }, { 0x15dde2e0, "sdio_release_irq" }, { 0xeb5de8cd, "sdio_release_host" }, { 0x27e1a049, "printk" }, { 0xac578d85, "sdio_writeb" }, { 0xbb3bfde9, "sdio_readb" }, { 0x79ecc7e0, "sdio_claim_host" }, { 0xefd6cf06, "__aeabi_unwind_cpp_pr0" }, { 0x6de88a3e, "sdio_unregister_driver" }, }; static const char __module_depends[] __used __attribute__((section(".modinfo"))) = "depends=btmrvl"; MODULE_ALIAS("sdio:c*v02DFd9105*"); MODULE_ALIAS("sdio:c*v02DFd911A*"); MODULE_INFO(srcversion, "5664130CB48520D3884381F");
// // tcpsessionmgr.h // console // // Created by huanghaifeng on 14-10-3. // Copyright (c) 2014年 wonghoifung. All rights reserved. // #ifndef tcpsessionmgr_header #define tcpsessionmgr_header #include <boost/noncopyable.hpp> #include <boost/asio.hpp> #include <map> #include "tcpsession.h" #include "../utils/global_holder.h" namespace frog { namespace generic { class tcpsessionmgr : public boost::noncopyable { private: tcpsessionmgr(); ~tcpsessionmgr(){} void on_timeout(); void start_timer(); public: static tcpsessionmgr& ref() { static tcpsessionmgr instance; return instance; } bool find(int sid) { return (sessions_.find(sid) != sessions_.end()); } bool insert(int sid, tcpsession_ptr session); bool erase(int sid); void set_errorcb(error_callback cb) { errorcb_ = cb; } void set_timeoutcb(timeout_callback cb) { timeoutcb_ = cb; } /* for line command */ void lcmd_scount(std::vector<std::string>&,tcpsession_ptr); void lcmd_sconn(std::vector<std::string>&,tcpsession_ptr); private: std::map<int, tcpsession_ptr> sessions_; boost::asio::deadline_timer sessiontimer_; error_callback errorcb_; timeout_callback timeoutcb_; }; } } #endif
extern void __init_wut_newlib() __attribute__((weak)); extern void __init_wut_devoptab() __attribute__((weak)); extern void __init_wut_stdcpp() __attribute__((weak)); extern void __fini_wut_devoptab() __attribute__((weak)); extern void __fini_wut_newlib() __attribute__((weak)); extern void __fini_wut_stdcpp() __attribute__((weak)); void __init_wut() { if (__init_wut_newlib) { __init_wut_newlib(); } if (__init_wut_devoptab) { __init_wut_devoptab(); } if (__init_wut_stdcpp) { __init_wut_stdcpp(); } } void __fini_wut() { if (__fini_wut_stdcpp) { __fini_wut_stdcpp(); } if (__fini_wut_devoptab) { __fini_wut_devoptab(); } if (__fini_wut_newlib) { __fini_wut_newlib(); } } // Forward newlib _exit to the coreinit.rpl _Exit extern void _Exit(int status); void _exit(int status) { _Exit(status); }
/* This file is part of the KDE project Copyright (C) 2003 Lucijan Busch <lucijan@kde.org> Copyright (C) 2003 Joseph Wenninger <jowenn@kde.org> Copyright (C) 2003-2014 Jarosław Staniek <staniek@kde.org> This program 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 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KEXIDATATABLESCROLLAREA_H #define KEXIDATATABLESCROLLAREA_H #include "KexiTableScrollArea.h" namespace KexiDB { class Cursor; } /** * Database-aware table widget. */ class KEXIDATATABLE_EXPORT KexiDataTableScrollArea : public KexiTableScrollArea { Q_OBJECT public: /** * Creates a blank widget */ explicit KexiDataTableScrollArea(QWidget *parent); /*! Creates a table widget and fills it using data from \a cursor. Cursor will be opened (with open()) if it is not yet opened. Cursor must be defined on query schema, not raw statement (see Connection::prepareQuery() and Connection::executeQuery()), otherwise the table view remain not filled with data. Cursor \a cursor will not be owned by this object. */ KexiDataTableScrollArea(QWidget *parent, KexiDB::Cursor *cursor); ~KexiDataTableScrollArea(); using KexiTableScrollArea::setData; /*! Fills table view with data using \a cursor. \return true on success. Cursor \a cursor will not be owned by this object. */ bool setData(KexiDB::Cursor *cursor); /*! \return cursor used as data source for this table view, or NULL if no valid cursor is defined. */ KexiDB::Cursor *cursor() { return m_cursor; } /** * @returns the number of records in the data set, (if data set is present) * @note not all of the records have to be processed */ int recordCount() const { return m_data->count(); } #ifndef KEXI_NO_PRINT // virtual void print(KPrinter &printer); #endif protected: void init(); private: //db stuff KexiDB::Cursor *m_cursor; }; #endif
#include "nvitem_common.h" #ifndef _NVITEM_CONFIG_H_ #define _NVITEM_CONFIG_H_ #define RAMDISK_CFG "/nvitem.cfg" //--------------------------------------------------------- // Const config: can not be changed //--------------------------------------------------------- //NOTE: // 1: 0 and 0xFFFFFFFF is reserved partition id // 2: high 24 bit is reserved bit, so only have 255 id that can be used // 3: So don't waste id number when you add new partition id here //--------------------------------------------------------- #define RAMBSD_FIXNV_ID 1 #define RAMBSD_RUNNV_ID 2 #define RAMBSD_PRODUCTINFO_ID 3 #endif
/* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** ** Commercial non-GPL licensing of this software is possible. ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. ** ** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30 ** $Id: output.h,v 1.5 2004/09/24 17:31:34 diego Exp $ ** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/ **/ #ifndef __OUTPUT_H__ #define __OUTPUT_H__ #ifdef __cplusplus extern "C" { #endif void* output_to_PCM(NeAACDecHandle hDecoder, real_t **input, void *samplebuffer, uint8_t channels, uint16_t frame_len, uint8_t format); #ifdef __cplusplus } #endif #endif
#ifndef __JsonObject_H #define __JsonObject_H #include <windows.h> #include <string> #include <map> #include "../rapidjson.h" #include "../document.h" // #include "writer.h" // #include "reader.h" // #include "stream.h" template<typename T>struct JSONRemoveReference{ typedef T type; }; template<typename T>struct JSONRemoveReference<T&&>{ typedef T type; }; template<typename T>struct JSONRemoveReference<T&>{ typedef T type; }; class JsonObject { public: # define V2J(member) ValueToJson( #member ,member) # define V2J_N(member,idx) ValueToJson( std::string( #member ) + std::to_string((DWORD64)idx) ,member) # define J2V(member) JsonToValue( #member ,member) # define J2V_N(member,idx) JsonToValue( std::string( #member ) + std::to_string((DWORD64)idx) ,member) # define J2O(member) JsonToObject( #member , &member ) # define J2O_N(member,idx) JsonToObject( std::string( #member ) + std::to_string((DWORD64)idx) , &member ) # define O2J(member) ObjectToJson( #member , &member ) # define O2J_N(member,idx) ObjectToJson( std::string( #member ) + std::to_string((DWORD64)idx) , &member ) //vector objects array # define O2J_VEC(vec) for (int vec ## _i=0 ; vec ## _i < vec.size() ; vec ## _i++){\ decltype(vec[0]) vec##_e = vec[vec##_i];\ O2J_N(vec##_e,vec##_i);\ } # define J2O_VEC(vec) for (int vec##i=0;;vec##i++){\ JSONRemoveReference<decltype( vec[0] )>::type vec##_e;\ if( ! J2O_N( vec##_e , vec##i ) ) break;\ vec.push_back( vec##_e );\ } typedef std::map<std::string , rapidjson::Value> MAP_JSON_VALUE; public: JsonObject(); virtual ~JsonObject(); public: bool SetJson(const std::string& json); std::string GetJson(); private: void BeingJson(); void ExtJson(); void EndJson(); protected: virtual void KeyToStr(); virtual void StrToKey(); protected: void ValueToJson(const std::string& member_name,DWORD _value); void ValueToJson(const std::string& member_name,DWORDLONG _value); void ValueToJson(const std::string& member_name,float _value); void ValueToJson(const std::string& member_name,double _value); void ValueToJson(const std::string& member_name,const std::string & _value); void JsonToValue(const std::string& member_name,DWORD & _value); void JsonToValue(const std::string& member_name,DWORDLONG & _value); void JsonToValue(const std::string& member_name,float & _value); void JsonToValue(const std::string& member_name,double & _value); void JsonToValue(const std::string& member_name,std::string & _value); void ObjectToJson(const std::string& member_name,JsonObject* pObj); BOOL JsonToObject(const std::string& member_name,JsonObject* pObj); protected: MAP_JSON_VALUE m_json_values; std::string m_json_data; }; #endif //__JsonObject_H
/* writejpg.h Copyright 1996-2006 Han The Thanh <thanh@pdftex.org> Copyright 2006-2009 Taco Hoekwater <taco@luatex.org> This file is part of LuaTeX. LuaTeX 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. LuaTeX 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 General Public License along with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */ /* $Id$ */ #ifndef WRITEJPG_H # define WRITEJPG_H # include "image.h" void read_jpg_info(PDF, image_dict *, img_readtype_e); void write_jpg(PDF, image_dict *); #endif /* WRITEJPG_H */
/* * Copyright (c) 2008-2009 QUALCOMM USA, INC. * * All source code in this file is licensed under the following license * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, you can find it at http://www.fsf.org */ #ifndef MT9D112_H #define MT9D112_H #include <mach/board.h> #include <mach/camera.h> extern struct mt9d112_reg_t mt9d112_regs; enum mt9d112_width_t { WORD_LEN, BYTE_LEN }; struct mt9d112_i2c_reg_conf { unsigned short waddr; unsigned short wdata; enum mt9d112_width_t width; unsigned short mdelay_time; }; struct mt9d112_reg_t { struct register_address_value_pair_t const *prev_snap_reg_settings; uint16_t prev_snap_reg_settings_size; struct register_address_value_pair_t const *noise_reduction_reg_settings; uint16_t noise_reduction_reg_settings_size; struct mt9d112_i2c_reg_conf const *plltbl; uint16_t plltbl_size; struct mt9d112_i2c_reg_conf const *stbl; uint16_t stbl_size; struct mt9d112_i2c_reg_conf const *rftbl; uint16_t rftbl_size; }; #endif /* MT9D112_H */
#ifndef _UMLPSEUDOSTATE_H #define _UMLPSEUDOSTATE_H #include <q3cstring.h> #include "UmlItem.h" #include "UmlStateItem.h" class UmlPseudoState : public UmlStateItem, public UmlItem { public: // the constructor, do not call it yourself !!!!!!!!!! UmlPseudoState(void * id, const Q3CString & s) : UmlItem(id, s) { } //entry to produce the html code receiving chapter number //path, rank in the mother and level in the browser tree virtual void html(Q3CString pfix, unsigned int rank, unsigned int level); }; #endif
/* * uhttpd - Tiny single-threaded httpd - Main header * * Copyright (C) 2010 Jo-Philipp Wich <xm@subsignal.org> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _UHTTPD_ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <signal.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/select.h> #include <sys/wait.h> #include <netinet/in.h> #include <arpa/inet.h> #include <linux/limits.h> #include <netdb.h> #include <ctype.h> #include <dlfcn.h> #ifdef HAVE_LUA #include <lua.h> #endif #ifdef HAVE_TLS #include <openssl/ssl.h> #endif #define UH_LIMIT_MSGHEAD 4096 #define UH_LIMIT_HEADERS 64 #define UH_LIMIT_LISTENERS 16 #define UH_LIMIT_CLIENTS 64 #define UH_LIMIT_AUTHREALMS 8 #define UH_HTTP_MSG_GET 0 #define UH_HTTP_MSG_HEAD 1 #define UH_HTTP_MSG_POST 2 struct listener; struct client; struct http_request; struct config { char docroot[PATH_MAX]; char *realm; char *file; #ifdef HAVE_CGI char *cgi_prefix; #endif #ifdef HAVE_LUA char *lua_prefix; char *lua_handler; lua_State * (*lua_init) (const char *handler); void (*lua_close) (lua_State *L); void (*lua_request) (struct client *cl, struct http_request *req, lua_State *L); #endif #if defined(HAVE_CGI) || defined(HAVE_LUA) int script_timeout; #endif #ifdef HAVE_TLS char *cert; char *key; SSL_CTX *tls; SSL_CTX * (*tls_init) (void); int (*tls_cert) (SSL_CTX *c, const char *file); int (*tls_key) (SSL_CTX *c, const char *file); void (*tls_free) (struct listener *l); void (*tls_accept) (struct client *c); void (*tls_close) (struct client *c); int (*tls_recv) (struct client *c, void *buf, int len); int (*tls_send) (struct client *c, void *buf, int len); #endif }; struct listener { int socket; struct sockaddr_in6 addr; struct config *conf; #ifdef HAVE_TLS SSL_CTX *tls; #endif }; struct client { int socket; int peeklen; char peekbuf[UH_LIMIT_MSGHEAD]; struct listener *server; struct sockaddr_in6 servaddr; struct sockaddr_in6 peeraddr; #ifdef HAVE_TLS SSL *tls; #endif }; struct auth_realm { char path[PATH_MAX]; char user[32]; char pass[128]; }; struct http_request { int method; float version; char *url; char *headers[UH_LIMIT_HEADERS]; struct auth_realm *realm; }; struct http_response { int statuscode; char *statusmsg; char *headers[UH_LIMIT_HEADERS]; }; #endif
/* * distancePointToLine.h * * Created on: Oct 20, 2015 * Author: morgan */ #ifndef DISTANCEPOINTTOLINE_H_ #define DISTANCEPOINTTOLINE_H_ template<class TPoint> double distancePointToLine(const TPoint & x,const TPoint & a, const TPoint & b){ auto ba = b - a; auto xa = x - a; auto xb = x - b; double c1 = ba*xa; if(c1 <=0){ return xa.GetNorm(); } double c2 = ba*ba; if(c2<=c1){ return xb.GetNorm(); } double w = c1/c2; TPoint Pb = a + w*ba; return (x-Pb).GetNorm(); } #endif /* DISTANCEPOINTTOLINE_H_ */
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef UI_BASE_IME_INPUT_METHOD_BASE_H_ #define UI_BASE_IME_INPUT_METHOD_BASE_H_ #include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "ui/base/ime/input_method.h" #include "ui/base/ui_export.h" namespace gfx { class Rect; } namespace ui { class InputMethodObserver; class KeyEvent; class TextInputClient; class UI_EXPORT InputMethodBase : NON_EXPORTED_BASE(public InputMethod), public base::SupportsWeakPtr<InputMethodBase> { public: InputMethodBase(); virtual ~InputMethodBase(); virtual void SetDelegate(internal::InputMethodDelegate* delegate) OVERRIDE; virtual void Init(bool focused) OVERRIDE; virtual void OnFocus() OVERRIDE; virtual void OnBlur() OVERRIDE; virtual void SetFocusedTextInputClient(TextInputClient* client) OVERRIDE; virtual void DetachTextInputClient(TextInputClient* client) OVERRIDE; virtual TextInputClient* GetTextInputClient() const OVERRIDE; virtual void OnTextInputTypeChanged(const TextInputClient* client) OVERRIDE; virtual TextInputType GetTextInputType() const OVERRIDE; virtual TextInputMode GetTextInputMode() const OVERRIDE; virtual bool CanComposeInline() const OVERRIDE; virtual void AddObserver(InputMethodObserver* observer) OVERRIDE; virtual void RemoveObserver(InputMethodObserver* observer) OVERRIDE; protected: virtual void OnWillChangeFocusedClient(TextInputClient* focused_before, TextInputClient* focused) {} virtual void OnDidChangeFocusedClient(TextInputClient* focused_before, TextInputClient* focused) {} bool IsTextInputClientFocused(const TextInputClient* client); bool IsTextInputTypeNone() const; void OnInputMethodChanged() const; bool DispatchKeyEventPostIME(const ui::KeyEvent& event) const; void NotifyTextInputStateChanged(const TextInputClient* client); void OnCandidateWindowShown(); void OnCandidateWindowUpdated(); void OnCandidateWindowHidden(); bool system_toplevel_window_focused() const { return system_toplevel_window_focused_; } private: void SetFocusedTextInputClientInternal(TextInputClient* client); void CandidateWindowShownCallback(); void CandidateWindowUpdatedCallback(); void CandidateWindowHiddenCallback(); internal::InputMethodDelegate* delegate_; TextInputClient* text_input_client_; ObserverList<InputMethodObserver> observer_list_; bool system_toplevel_window_focused_; DISALLOW_COPY_AND_ASSIGN(InputMethodBase); }; } #endif
/* * \brief Core-specific capability index. * \author Stefan Kalkowski * \date 2012-02-22 */ /* * Copyright (C) 2012 Genode Labs GmbH * * This file is part of the Genode OS framework, which is distributed * under the terms of the GNU General Public License version 2. */ #ifndef _CORE__INCLUDE__CAP_INDEX_H_ #define _CORE__INCLUDE__CAP_INDEX_H_ /* Genode includes */ #include <base/cap_map.h> /* Core includes */ #include <cap_session_component.h> namespace Genode { class Platform_thread; class Core_cap_index : public Cap_index { private: Cap_session_component *_session; Platform_thread *_pt; Native_thread _gate; public: Core_cap_index(Cap_session_component *session = 0, Platform_thread *pt = 0, Native_thread gate = Native_thread() ) : _session(session), _pt(pt), _gate(gate) {} Cap_session_component *session() { return _session; } Platform_thread *pt() { return _pt; } Native_thread gate() { return _gate; } void session(Cap_session_component* c) { _session = c; } void pt(Platform_thread* t) { _pt = t; } }; } #endif /* _CORE__INCLUDE__CAP_INDEX_H_ */
#ifndef COMPSL_BYTECODE_H_ #define COMPSL_BYTECODE_H_ #include "compsl.h" // all instructions working with variables take address in a1 unless otherwise // stated COMPSL_INTERN typedef enum { BC_NOOP, BC_PUSH, BC_PSHT, BC_APUSH, BC_CPUSH, BC_GPSH, BC_GAPS, BC_POP, BC_POPT, BC_APOP, BC_DPOP, BC_GPOP, BC_GAPP, BC_DUP, BC_CALL, BC_ADD, BC_SUB, BC_MUL, BC_DIV, BC_LE, BC_LS, BC_EQ, BC_NE, BC_GR, BC_GE, BC_MOD, BC_FMOD, BC_AND, BC_OR, BC_NOT, BC_BAND, BC_BOR, BC_BXOR, BC_BNOT, BC_SFTL, BC_SFTR, BC_FADD, BC_FSUB, BC_FMUL, BC_FDIV, BC_FLE, BC_FL, BC_FEQ, BC_FNE, BC_FGR, BC_FGE, BC_JMP, BC_JMZ, BC_JMN, BC_FLIN, BC_INFL, BC_SAVE, BC_STO, BC_GSTO, BC_INC, BC_DEC, BC_FINC, BC_FDEC, BC_CHOOSE, BC_ABS, BC_ABSF, BC_SIN, BC_COS, BC_TAN, BC_ASIN, BC_ACOS, BC_ATAN, BC_SQRT, BC_LN, BC_FLOOR, BC_CEIL, BC_RAND, BC_ATAN2, BC_POW, BC_MIN, BC_MAX, BC_MINF, BC_MAXF, BC_HYPOT, BC_FEQUAL, BC_FMA, BC_PYES, BC_NONO, BC_END, BC_HLT, BC_DBG, BC_NO_BYTECODE } BC_DEF; typedef struct { BC_DEF code; union { struct { uint8_t a1 /*__deprecated__*/; // uncomment depreciated after first relase uint8_t a2 /*__deprecated__*/; // clean up all refernces to it }; uint16_t a; // look up wether this works as expected int16_t sa; }; } bytecode; #endif /*BYTECODE_H_*/
#include "randomaccess.h" #include "utility.h" #define f(x) f##x #define pdef(n) double f(n) #define paramDefs pdef(1),pdef(2),pdef(3),pdef(4),pdef(5),pdef(6),pdef(7),pdef(8),pdef(9),pdef(10),pdef(11),pdef(12),pdef(13),pdef(14),pdef(15) //paramDefs #define m(x) f(x) += f(x) #define fifteen m(1);m(2);m(3);m(4);m(5);m(6);m(7);m(8);m(9);m(10);m(11);m(12);m(13);m(14);m(15); #define thirty fifteen fifteen #define ninety thirty thirty thirty #define two_seventy ninety ninety ninety #define five_forty two_seventy two_seventy #define two_thou_one_sixty five_forty five_forty five_forty five_forty #define ten_eight_hundred two_thou_one_sixty two_thou_one_sixty two_thou_one_sixty two_thou_one_sixty two_thou_one_sixty u64Int numOpsTot = 1080000; inline double foo(paramDefs) { //ninety; //five_forty; //two_thou_one_sixty; ten_eight_hundred; return f1+f2+f3+f4+f5+f6+f7+f8+f9+f10+f11+f12+f13+f14+f15; } double instrOnly(u64Int TableSize, u64Int *Table) { double x = 0; unsigned i = 0; for (i = 0; i < 100; i++) { x +=foo(1.000001, 2.000002, 3.000003, 4.000004, 5.000005, 6.000006, 7.000007, 8.000008, 9.000009, 10.0000010, 11.0000010, 12.0000012, 13.0000013, 14.0000014, 15.0000015); } TableSize = TableSize; Table[0] = Table[0]; Table = Table; return x; }
/*$Id: bbsfdoc.c,v 1.2 2008-12-19 09:55:09 madoldman Exp $ */ #include "BBSLIB.inc" int main() { FILE *fp; char *ptr, board[256]; struct dir x[10000], xx; int i, start, total=0;//,totalclick=0; init_all(); strsncpy(board, getparm("board"), 30); if(!has_read_perm(&currentuser, board)) http_fatal("´íÎóµÄÌÖÂÛÇø"); fp=fopen(UPLOAD_PATH"/.DIR", "r"); if(fp==0) http_fatal("ûÓÐÕÒµ½Îļþ"); while(total<10000) { if(fread(&xx, sizeof(xx), 1, fp)<=0) break; if(!xx.active) continue; if(strcasecmp(xx.board, board)) continue; x[total]=xx; // totalclick+=x[total].click; total++; } ptr=getparm("start"); if(ptr[0]==0) { start=total-19; } else { start=atoi(ptr); } if(start>total-19) start=total-19; if(start<0) start=0; printf("<script language=JavaScript src=/scrolldown.js></script>"); printf("<body background=/bg_1.gif bgproperties=fixed>"); // printf("<center> %s -- °åÄÚ¸½¼þÏÂÔØ [ÌÖÂÛÇø: %s] ×ܵã»÷´ÎÊý£º%d£¬Æ½¾ùµã»÷´ÎÊý£º%5.2f<hr color=green>\n", BBSNAME, board,totalclick,totalclick*1.0/total); printf("<center> %s -- °åÄÚ¸½¼þÏÂÔØ [ÌÖÂÛÇø: %s] \n", BBSNAME, board); printf("<table width=620 border=0><tr><td>ÐòºÅ<td>ÎļþÃû<td>ÉÏÔØÕß<td>ʱ¼ä<td>´óС<td>˵Ã÷<td>±¸×¢<td>¹ÜÀí\n"); for(i=start; i<start+20 && i<total; i++) { printf("<tr><td>%d", i+1); if(x[i].filename) { printf("<td><a href=/cgi-bin/bbs/showfile?name=%s target=_blank>%s</a>", nohtml(x[i].showname), nohtml(x[i].showname)); } else { printf("<td><a href=/file/%s/%s>%s</a>", x[i].board, nohtml(x[i].showname), nohtml(x[i].showname)); } printf("<td>%s", userid_str(x[i].userid)); printf("<td>%6.6s", Ctime(x[i].date)+4); printf("<td>%d", x[i].size); // printf("<td> "); //%d", x[i].click); // printf("<td>%d", x[i].click); printf("<td><a href=bbsfexp?name=%s>more </a>\n", nohtml(x[i].showname)); printf("<td width=150>%s ", nohtml(x[i].exp)); printf("<td><a onclick='return confirm(\"È·¶¨É¾³ýÂð?\")' href=bbsudel?file=%s&start=%d>ɾ</a>\n", x[i].showname, start); } printf("</table><br>\n"); printf("[<a href=bbsfdoc?board=%s>×îÐÂ</a>] [<a href=bbsdoc?board=%s>±¾ÌÖÂÛÇø</a>] ", board, board); if(start>0) printf("[<a href=bbsfdoc?board=%s&start=%d>ÉÏÒ»Ò³</a>] ", board, start-19); if(start<total-20) printf("[<a href=bbsfdoc?board=%s&start=%d>ÏÂÒ»Ò³</a>] ", board, start+19); }
/* * CINELERRA * Copyright (C) 2011 Adam Williams <broadcast at earthling dot net> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef RECORDMONITOR_H #define RECORDMONITOR_H #include "avc1394transport.h" #include "bcdialog.h" #include "canvas.h" #include "channelpicker.inc" #include "condition.inc" #include "guicast.h" #include "channelpicker.inc" #include "libmjpeg.h" #include "meterpanel.inc" #include "preferences.inc" #include "record.inc" #include "recordgui.inc" #include "recordscopes.inc" #include "recordtransport.inc" #include "recordmonitor.inc" #include "videodevice.inc" class RecordMonitorThread; class RecordMonitor : public Thread { public: RecordMonitor(MWindow *mwindow, Record *record); ~RecordMonitor(); // Show a frame int update(VFrame *vframe); // Update channel textbox void update_channel(char *text); MWindow *mwindow; Record *record; // Thread for slippery monitoring RecordMonitorThread *thread; RecordMonitorGUI *window; VideoDevice *device; // Fake config for monitoring VideoOutConfig *config; RecordScopeThread *scope_thread; void run(); int close_threads(); // Stop all the child threads on exit void create_objects(); int fix_size(int &w, int &h, int width_given, float aspect_ratio); float get_scale(int w); int get_mbuttons_height(); int get_canvas_height(); int get_channel_x(); int get_channel_y(); }; class ReverseInterlace; class RecordMonitorCanvas; class RecordMonitorGUI : public BC_Window { public: RecordMonitorGUI(MWindow *mwindow, Record *record, RecordMonitor *thread, int min_w); ~RecordMonitorGUI(); void create_objects(); int cursor_leave_event(); int cursor_enter_event(); int button_release_event(); int cursor_motion_event(); MeterPanel *meters; Canvas *canvas; // RecordTransport *record_transport; AVC1394Transport *avc1394_transport; AVC1394TransportThread *avc1394transport_thread; RecordChannelPicker *channel_picker; ScopeEnable *scope_toggle; ReverseInterlace *reverse_interlace; int cursor_x_origin, cursor_y_origin; int translate_x_origin, translate_y_origin; BC_PopupMenu *monitor_menu; int current_operation; int translation_event(); int button_press_event(); int resize_event(int w, int h); int set_title(); int close_event(); int create_bitmap(); int keypress_event(); MWindow *mwindow; BC_SubWindow *mbuttons; BC_Bitmap *bitmap; RecordMonitor *thread; Record *record; AVC1394Control *avc; BC_Title *avc1394transport_title; BC_Title *avc1394transport_timecode; }; class RecVideoMJPGThread; class RecVideoDVThread; class RecordMonitorThread : public Thread { public: RecordMonitorThread(MWindow *mwindow, Record *record, RecordMonitor *record_monitor); ~RecordMonitorThread(); void reset_parameters(); void run(); // Calculate the best output format based on input drivers void init_output_format(); int start_playback(); int stop_playback(); int write_frame(VFrame *new_frame); int render_frame(); void unlock_input(); void new_output_frame(); // Input frame being rendered VFrame *input_frame; // Frames for the rendered output VFrame *output_frame; // Best color model given by device int output_colormodel; // Block until new input data Condition *output_lock; Condition *input_lock; Record *record; RecordMonitor *record_monitor; MWindow *mwindow; // If the input frame is the same data that the file handle uses int shared_data; private: void show_output_frame(); void render_uncompressed(); int render_jpeg(); int render_dv(); void process_scope(); void process_hist(); int ready; // Ready to recieve the next frame int done; RecVideoMJPGThread *jpeg_engine; RecVideoDVThread *dv_engine; }; class RecordMonitorFullsize : public BC_MenuItem { public: RecordMonitorFullsize(MWindow *mwindow, RecordMonitorGUI *window); int handle_event(); MWindow *mwindow; RecordMonitorGUI *window; }; class RecordMonitorCanvas : public Canvas { public: RecordMonitorCanvas(MWindow *mwindow, RecordMonitorGUI *window, Record *record, int x, int y, int w, int h); ~RecordMonitorCanvas(); void zoom_resize_window(float percentage); int button_press_event(); int button_release_event(); int cursor_motion_event(); int cursor_enter_event(); void reset_translation(); int keypress_event(); int get_output_w(); int get_output_h(); int get_fullscreen(); void set_fullscreen(int value); RecordMonitorGUI *window; MWindow *mwindow; Record *record; }; class ReverseInterlace : public BC_CheckBox { public: ReverseInterlace(Record *record, int x, int y); ~ReverseInterlace(); int handle_event(); Record *record; }; class RecVideoMJPGThread { public: RecVideoMJPGThread(Record *record, RecordMonitorThread *thread, int fields); ~RecVideoMJPGThread(); int render_frame(VFrame *frame, long size); int start_rendering(); int stop_rendering(); RecordMonitorThread *thread; Record *record; private: mjpeg_t *mjpeg; int fields; }; class RecVideoDVThread { public: RecVideoDVThread(Record *record, RecordMonitorThread *thread); ~RecVideoDVThread(); int start_rendering(); int stop_rendering(); int render_frame(VFrame *frame, long size); RecordMonitorThread *thread; Record *record; private: // Don't want theme to need libdv to compile void *dv; }; #endif
/* Copying and distribution of this file, with or without modification, * are permitted in any medium without royalty. This file is offered as-is, * without any warranty. */ /*! @file process_frame.c * @brief Contains the actual algorithm and calculations. */ /* Definitions specific to this application. Also includes the Oscar main header file. */ #include "template.h" #include <string.h> #include <stdlib.h> void ProcessFrame(uint8 *pInputImg) { int siz = sizeof(data.u8TempImage[GRAYSCALE]); memcpy(data.u8TempImage[BACKGROUND], data.u8TempImage[GRAYSCALE], siz); memset(data.u8TempImage[THRESHOLD], 0, siz); }
volatile _Bool latch = 0; volatile _Bool work_to_do = 0; volatile _Bool existWaiter = 0; void* waiter1(void* arg) { for(;;) { // ResetLatch(); latch = 0; //check work; if(work_to_do) { //do work here; work_to_do = 0; } //WaitLatch(); while(!latch) {} } } void* waiter2(void* arg) { for(;;) { // ResetLatch(); latch = 0; //check work; if(work_to_do) { //do work here; work_to_do = 0; } //WaitLatch(); while(!latch) {} } } void* waker1(void* arg) { for(;;) { work_to_do = 1; //SetLatch(); if(latch == 0) { latch = 1; } else { //return in SetLatch(); } } } void* waker2(void* arg) { for(;;) { work_to_do = 1; //SetLatch(); if(latch == 0) { latch = 1; } else { //return in SetLatch(); } } } void* waker3(void* arg) { for(;;) { work_to_do = 1; //SetLatch(); if(latch == 0) { latch = 1; } else { //return in SetLatch(); } } } void* waker4(void* arg) { for(;;) { work_to_do = 1; //SetLatch(); if(latch == 0) { latch = 1; } else { //return in SetLatch(); } } } void* waker5(void* arg) { for(;;) { work_to_do = 1; //SetLatch(); if(latch == 0) { latch = 1; } else { //return in SetLatch(); } } } void* waker6(void* arg) { for(;;) { work_to_do = 1; //SetLatch(); if(latch == 0) { latch = 1; } else { //return in SetLatch(); } } } void* waker7(void* arg) { for(;;) { work_to_do = 1; //SetLatch(); if(latch == 0) { latch = 1; } else { //return in SetLatch(); } } } void* waker8(void* arg) { for(;;) { work_to_do = 1; //SetLatch(); if(latch == 0) { latch = 1; } else { //return in SetLatch(); } } } void* waker9(void* arg) { for(;;) { work_to_do = 1; //SetLatch(); if(latch == 0) { latch = 1; } else { //return in SetLatch(); } } } void* waker10(void* arg) { for(;;) { work_to_do = 1; //SetLatch(); if(latch == 0) { latch = 1; } else { //return in SetLatch(); } } } int main() { __CPROVER_ASYNC_0: waiter1(0); __CPROVER_ASYNC_1: waiter2(0); __CPROVER_ASYNC_2: waker1(0); __CPROVER_ASYNC_3: waker2(0); __CPROVER_ASYNC_4: waker3(0); __CPROVER_ASYNC_5: waker4(0); __CPROVER_ASYNC_6: waker5(0); __CPROVER_ASYNC_7: waker6(0); __CPROVER_ASYNC_8: waker7(0); __CPROVER_ASYNC_9: waker8(0); __CPROVER_ASYNC_10: waker9(0); __CPROVER_ASYNC_11: waker10(0); return 0; }
/* * Copyright (C) 2015 Josh Poimboeuf <jpoimboe@redhat.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see <http://www.gnu.org/licenses/>. */ /* * This file reads all the special sections which have alternate instructions * which can be patched in or redirected to at runtime. */ #include <stdlib.h> #include <string.h> #include "special.h" #include "warn.h" #define EX_ENTRY_SIZE 8 #define EX_ORIG_OFFSET 0 #define EX_NEW_OFFSET 4 #define JUMP_ENTRY_SIZE 24 #define JUMP_ORIG_OFFSET 0 #define JUMP_NEW_OFFSET 8 #define ALT_ENTRY_SIZE 12 #define ALT_ORIG_OFFSET 0 #define ALT_NEW_OFFSET 4 #define ALT_FEATURE_OFFSET 8 #define ALT_ORIG_LEN_OFFSET 10 #define ALT_NEW_LEN_OFFSET 11 #define X86_FEATURE_POPCNT (4*32+23) struct special_entry { const char *sec; bool group, jump_or_nop; unsigned char size, orig, new; unsigned char orig_len, new_len; /* group only */ unsigned char feature; /* ALTERNATIVE macro CPU feature */ }; struct special_entry entries[] = { { .sec = ".altinstructions", .group = true, .size = ALT_ENTRY_SIZE, .orig = ALT_ORIG_OFFSET, .orig_len = ALT_ORIG_LEN_OFFSET, .new = ALT_NEW_OFFSET, .new_len = ALT_NEW_LEN_OFFSET, .feature = ALT_FEATURE_OFFSET, }, { .sec = "__jump_table", .jump_or_nop = true, .size = JUMP_ENTRY_SIZE, .orig = JUMP_ORIG_OFFSET, .new = JUMP_NEW_OFFSET, }, { .sec = "__ex_table", .size = EX_ENTRY_SIZE, .orig = EX_ORIG_OFFSET, .new = EX_NEW_OFFSET, }, {}, }; static int get_alt_entry(struct elf *elf, struct special_entry *entry, struct section *sec, int idx, struct special_alt *alt) { struct rela *orig_rela, *new_rela; unsigned long offset; offset = idx * entry->size; alt->group = entry->group; alt->jump_or_nop = entry->jump_or_nop; if (alt->group) { alt->orig_len = *(unsigned char *)(sec->data + offset + entry->orig_len); alt->new_len = *(unsigned char *)(sec->data + offset + entry->new_len); } if (entry->feature) { unsigned short feature; feature = *(unsigned short *)(sec->data + offset + entry->feature); /* * It has been requested that we don't validate the !POPCNT * feature path which is a "very very small percentage of * machines". */ if (feature == X86_FEATURE_POPCNT) alt->skip_orig = true; } orig_rela = find_rela_by_dest(sec, offset + entry->orig); if (!orig_rela) { WARN_FUNC("can't find orig rela", sec, offset + entry->orig); return -1; } if (orig_rela->sym->type != STT_SECTION) { WARN_FUNC("don't know how to handle non-section rela symbol %s", sec, offset + entry->orig, orig_rela->sym->name); return -1; } alt->orig_sec = orig_rela->sym->sec; alt->orig_off = orig_rela->addend; if (!entry->group || alt->new_len) { new_rela = find_rela_by_dest(sec, offset + entry->new); if (!new_rela) { WARN_FUNC("can't find new rela", sec, offset + entry->new); return -1; } alt->new_sec = new_rela->sym->sec; alt->new_off = (unsigned int)new_rela->addend; /* _ASM_EXTABLE_EX hack */ if (alt->new_off >= 0x7ffffff0) alt->new_off -= 0x7ffffff0; } return 0; } /* * Read all the special sections and create a list of special_alt structs which * describe all the alternate instructions which can be patched in or * redirected to at runtime. */ int special_get_alts(struct elf *elf, struct list_head *alts) { struct special_entry *entry; struct section *sec; unsigned int nr_entries; struct special_alt *alt; int idx, ret; INIT_LIST_HEAD(alts); for (entry = entries; entry->sec; entry++) { sec = find_section_by_name(elf, entry->sec); if (!sec) continue; if (sec->len % entry->size != 0) { WARN("%s size not a multiple of %d", sec->name, entry->size); return -1; } nr_entries = sec->len / entry->size; for (idx = 0; idx < nr_entries; idx++) { alt = malloc(sizeof(*alt)); if (!alt) { WARN("malloc failed"); return -1; } memset(alt, 0, sizeof(*alt)); ret = get_alt_entry(elf, entry, sec, idx, alt); if (ret) return ret; list_add_tail(&alt->list, alts); } } return 0; }
#include<stdio.h> void partition(int arr[],int low,int high){ int mid; if(low<high){ mid=(low+high)/2; partition(arr,low,mid); partition(arr,mid+1,high); mergeSort(arr,low,mid,high); } } void mergeSort(int arr[],int low,int mid,int high){ int i,m,k,l,temp[high]; l=low; i=low; m=mid+1; while((l<=mid)&&(m<=high)){ if(arr[l]<=arr[m]){ temp[i]=arr[l]; l++; } else{ temp[i]=arr[m]; m++; } i++; } if(l>mid){ for(k=m;k<=high;k++){ temp[i]=arr[k]; i++; } } else{ for(k=l;k<=mid;k++){ temp[i]=arr[k]; i++; } } for(k=low;k<=high;k++){ arr[k]=temp[k]; } } int main() { int i,j,p,min,n,k,m=0,l; scanf("%d",&n); int a[n],b[n]; for(i=0; i<n; i++) scanf("%d",&a[i]); partition(a,0,n-1); for(i=0;i<n;i++) { p=0; for(j=i;j<n;j++) { if(((a[i]==a[j])&&(a[i]!=a[i-1]))||i==0) p++; } if(p==1) { min=a[i]; break; } } printf("%d",min); return 0; }
/* * * Control.h - this file is part of CPU Simulator * * Copyright 2010, 2011 Dawid Pilawa * * 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/>. * */ namespace simulation { class Control : public Device { Device *clk_gen, *clk_or, *clk_rst_sync; Device *step_0, *step_1; Device *ff_0; Device *ir_0; Device *uc_0, *uc_1, *uc_2, *uc_3; Device *irqsync; Device *pe_0, *pe_1; Device *pe_latch; Device *nand_0; Device *or_0; Device *and_pe; Device *and_0; Device *mux_0, *mux_1; Device *dec_0, *dec_1, *dec_2, *dec_3; Device *finhbt_0; Device *msw_0, *msw_1, *msw_2; Device *and_msw; Device *or_msw; Device *mux_msw; Device *flagbuf; Device *iptrbuf0, *iptrbuf1; Probe* p_0; Probe* p_1; Probe* p_2; Probe* p_3; Probe* p_4; Probe* p_5; Probe* p_6; Probe* p_7; Probe* p_8; Probe* p_9; Probe *p_microcode; Probe *pf0, *pf1, *pf2, *pf3, *pf4, *pf5, *pf6, *pf7; Probe *irqline0, *irqline1, *irqline2, *irqline3, *irqline4, *irqline5, *irqline6, *irqline7; Wire clkgenloop; Wire busclk, rstclk; Wire rco; Wire cnt0, cnt1, cnt2, cnt3, cnt4; Wire rstcnt_bar; Wire incpc_raw_bar; Wire nc; Wire uc00, uc01, uc02, uc03, uc04, uc05, uc06, uc07; Wire uc10, uc11, uc12, uc13, uc14, uc15, uc16, uc17; Wire uc20, uc21, uc22, uc23, uc24, uc25, uc26, uc27; Wire uc30, uc31, uc32, uc33, uc34, uc35, uc36, uc37; Wire sirq0, sirq1, sirq2, sirq3, sirq4, sirq5, sirq6, sirq7; Wire loadir_bar; Wire ir0, ir1, ir2, ir3, ir4, ir5, ir6, ir7; Wire op0, op1, op2, op3, op4, op5, op6, op7; Wire op_page, op_page_bar; Wire fault_bar, int_bar, fault, oe_bar, ei_bar; Wire faultint; Wire fault_protectionfault; Wire pe00, pe01, pe02, pe10, pe11, pe12; Wire pe0, pe1, pe2, pe3; Wire pe0_out, pe1_out, pe2_out, pe3_out; Wire op_page_pr_bar, op_page_cl_bar; Wire cntsp_uc_bar, incpc_uc_bar; Wire enalu_nosync_bar, enmem_nosync_bar; Wire loadaluflags_bar, ldf_bar, ld_i_bar, ld_s_bar; Wire latch_i_bar, latch_s_bar, latch_none_bar; Wire ld_i_clk, ld_s_clk; Wire uc11_fault_bar; Wire eniptr_bar; Wire mswmux0, mswmux1, mswmux2, mswmux3; Wire flag_carry, flag_zero, flag_negative, flag_overflow, flag_interrupt, flag_f6, flag_f7; public: Control(std::string label, Wire& gnd, Wire& vcc, Wire& master_clk, Wire& clk0, Wire& clk1, Wire& rst_bar_nonsync, Wire& rst_bar, Wire& rst, Wire& dbus0, Wire& dbus1, Wire& dbus2, Wire& dbus3, Wire& dbus4, Wire& dbus5, Wire& dbus6, Wire& dbus7, Wire& alubus0, Wire& alubus1, Wire& alubus2, Wire& alubus3, Wire& alubus4, Wire& alubus5, Wire& alubus6, Wire& alubus7, Wire& alubus8, Wire& alubus9, Wire& alubus10, Wire& alubus11, Wire& alubus12, Wire& alubus13, Wire& alubus14, Wire& alubus15, Wire& rbus0, Wire& rbus1, Wire& rbus2, Wire& rbus3, Wire& rbus4, Wire& rbus5, Wire& rbus6, Wire& rbus7, Wire& rbus8, Wire& rbus9, Wire& rbus10, Wire& rbus11, Wire& rbus12, Wire& rbus13, Wire& rbus14, Wire& rbus15, Wire& enmdrl_bar, Wire& ena_bar, Wire& enx_bar, Wire& eny_bar, Wire& enmdrr_bar, Wire& enmsw_bar, Wire& enabus_bar, Wire& enppc_bar, Wire& enmar_bar, Wire& ensp_bar, Wire& endp_bar, Wire& enpc_bar, Wire& mdr_load_inhibit, Wire& ldmdrlo_bar, Wire& ldmdrhi_bar, Wire& ldmdr_bar, Wire& ldalo_bar, Wire& ldahi_bar, Wire& lda_bar, Wire& ldx_bar, Wire& ldy_bar, Wire& ldmem_bar, Wire& ldmarlo_bar, Wire& ldmarhi_bar, Wire& ldmar_bar, Wire& ldsp_bar, Wire& lddp_bar, Wire& ldpc_bar, Wire& ldmsw_bar, Wire& loadirclk, Wire& aluop0, Wire& aluop1, Wire& aluop2, Wire& aluop3, Wire& alumode, Wire& alucarryin_bar, Wire& alushr_bar, Wire& enalu_bar, Wire& enmem_bar, Wire& mem2alulo_bar, Wire& mem2aluhi_bar, Wire& alulo2mem_bar, Wire& aluhi2mem_bar, Wire& abus16_segsel, Wire& incpc_bar, Wire& incmar_bar, Wire& cntsp_bar, Wire& cntspdir, Wire& loadaluflags0, Wire& loadaluflags1, Wire& aluc, Wire& aluz, Wire& alun, Wire& aluv, Wire& irq0, Wire& irq1, Wire& irq2, Wire& irq3, Wire& irq4, Wire& irq5, Wire& irq6, Wire& irq7, Wire& flag_supervisor ); ~Control(); void go(long t); void debugInfo(long t); bool isHalted(long t); }; };
/* $Id: packet.h 21357 2010-11-30 13:22:29Z rubidium $ */ /* * This file is part of OpenCoaster Tycoon. * OpenCoaster Tycoon is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. * OpenCoaster Tycoon 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 OpenCoaster Tycoon. If not, see <http://www.gnu.org/licenses/>. */ /** * @file packet.h Basic functions to create, fill and read packets. */ #ifndef NETWORK_CORE_PACKET_H #define NETWORK_CORE_PACKET_H #include "config.h" #include "core.h" #ifdef ENABLE_NETWORK typedef uint16 PacketSize; ///< Size of the whole packet. typedef uint8 PacketType; ///< Identifier for the packet /** * Internal entity of a packet. As everything is sent as a packet, * all network communication will need to call the functions that * populate the packet. * Every packet can be at most SEND_MTU bytes. Overflowing this * limit will give an assertion when sending (i.e. writing) the * packet. Reading past the size of the packet when receiving * will return all 0 values and "" in case of the string. */ struct Packet { /** The next packet. Used for queueing packets before sending. */ Packet *next; /** * The size of the whole packet for received packets. For packets * that will be sent, the value is filled in just before the * actual transmission. */ PacketSize size; /** The current read/write position in the packet */ PacketSize pos; /** The buffer of this packet, of basically variable length up to SEND_MTU. */ byte *buffer; private: /** Socket we're associated with. */ NetworkSocketHandler *cs; public: Packet(NetworkSocketHandler *cs); Packet(PacketType type); ~Packet(); /* Sending/writing of packets */ void PrepareToSend(); void Send_bool (bool data); void Send_uint8 (uint8 data); void Send_uint16(uint16 data); void Send_uint32(uint32 data); void Send_uint64(uint64 data); void Send_string(const char *data); /* Reading/receiving of packets */ void ReadRawPacketSize(); void PrepareToRead(); bool CanReadFromPacket (uint bytes_to_read); bool Recv_bool (); uint8 Recv_uint8 (); uint16 Recv_uint16(); uint32 Recv_uint32(); uint64 Recv_uint64(); void Recv_string(char *buffer, size_t size, bool allow_newlines = false); }; #endif /* ENABLE_NETWORK */ #endif /* NETWORK_CORE_PACKET_H */
#include "./api/api.h" #include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char **argv) { API *api = api_init(); char *version = api_version(api); printf("version=%s\n", version); free(api); return EXIT_SUCCESS; }
// // This file is part of openBliSSART. // // Copyright (c) 2007-2009, Alexander Lehmann <lehmanna@in.tum.de> // Felix Weninger <felix@weninger.de> // Bjoern Schuller <schuller@tum.de> // // Institute for Human-Machine Communication // Technische Universitaet Muenchen (TUM), D-80333 Munich, Germany // // openBliSSART 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. // // openBliSSART 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 // openBliSSART. If not, see <http://www.gnu.org/licenses/>. // #ifndef __BLISSART_DATABASEENTITY_H__ #define __BLISSART_DATABASEENTITY_H__ #include <Poco/AutoPtr.h> #include <Poco/RefCountedObject.h> #include <common.h> #include <string> namespace blissart { /** * \addtogroup framework * @{ */ /** * Serves as a base class for all database entities. */ class LibFramework_API DatabaseEntity : public Poco::RefCountedObject { public: /** * An enumeration of the different database entity types. */ typedef enum { ClassificationObject, DataDescriptor, Feature, Label, Process, Response } EntityType; /** * Creates a DatabaseEntity object of the specified type. */ DatabaseEntity(EntityType entityType); /** * Copies the type from another DatabaseEntity. */ DatabaseEntity(const DatabaseEntity& other); /** * Tells the type of the entity. */ inline EntityType entityType() const { return _entityType; } /** * Under Unix, formats a floating-point number using the "C" locale, * so that a consistent format within the database is guaranteed. * Under Windows, this does the same as Poco::NumberFormatter::format(). */ static std::string formatDouble(double value); /** * Under Unix, parses a floating-point number using the "C" locale, * so that portability of databases is preserved. * Under Windows, this does the same as Poco::NumberParser::parseFloat(). */ static double parseDouble(const std::string& str); protected: EntityType _entityType; }; typedef Poco::AutoPtr<DatabaseEntity> DatabaseEntityPtr; /** * @} */ } // namespace blissart #endif // __BLISSART_DATABASEENTITY_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 CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_PREFS_H_ #define CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_PREFS_H_ #pragma once #include <string> #include "base/memory/scoped_ptr.h" #include "base/memory/scoped_temp_dir.h" #include "chrome/common/extensions/extension.h" class DictionaryValue; class ExtensionPrefs; class ExtensionPrefValueMap; class PrefService; class TestExtensionPrefs { public: TestExtensionPrefs(); virtual ~TestExtensionPrefs(); ExtensionPrefs* prefs() { return prefs_.get(); } const ExtensionPrefs& const_prefs() const { return *prefs_.get(); } PrefService* pref_service() { return pref_service_.get(); } const FilePath& temp_dir() const { return temp_dir_.path(); } void RecreateExtensionPrefs(); scoped_refptr<Extension> AddExtension(std::string name); scoped_refptr<Extension> AddExtensionWithManifest( const DictionaryValue& manifest, Extension::Location location); std::string AddExtensionAndReturnId(std::string name); PrefService* CreateIncognitoPrefService() const; protected: ScopedTempDir temp_dir_; FilePath preferences_file_; FilePath extensions_dir_; scoped_ptr<PrefService> pref_service_; scoped_ptr<ExtensionPrefs> prefs_; scoped_ptr<ExtensionPrefValueMap> extension_pref_value_map_; private: DISALLOW_COPY_AND_ASSIGN(TestExtensionPrefs); }; #endif
#ifndef __INCLUDE_LINUX_OOM_H #define __INCLUDE_LINUX_OOM_H /* * /proc/<pid>/oom_adj is deprecated, see * Documentation/feature-removal-schedule.txt. * * /proc/<pid>/oom_adj set to -17 protects from the oom-killer */ #define OOM_DISABLE (-17) /* inclusive */ #define OOM_ADJUST_MIN (-16) #define OOM_ADJUST_MAX 15 /* * /proc/<pid>/oom_score_adj set to OOM_SCORE_ADJ_MIN disables oom killing for * pid. */ #define OOM_SCORE_ADJ_MIN (-1000) #define OOM_SCORE_ADJ_MAX 1000 #ifdef __KERNEL__ #include <linux/sched.h> #include <linux/types.h> #include <linux/nodemask.h> struct zonelist; struct notifier_block; struct mem_cgroup; struct task_struct; /* * Types of limitations to the nodes from which allocations may occur */ enum oom_constraint { CONSTRAINT_NONE, CONSTRAINT_CPUSET, CONSTRAINT_MEMORY_POLICY, CONSTRAINT_MEMCG, }; enum oom_scan_t { OOM_SCAN_OK, /* scan thread and find its badness */ OOM_SCAN_CONTINUE, /* do not consider thread for oom kill */ OOM_SCAN_ABORT, /* abort the iteration and return */ OOM_SCAN_SELECT, /* always select this thread first */ }; extern void compare_swap_oom_score_adj(short old_val, short new_val); extern short test_set_oom_score_adj(short new_val); extern unsigned long oom_badness(struct task_struct *p, struct mem_cgroup *memcg, const nodemask_t *nodemask, unsigned long totalpages); extern int oom_kills_count(void); extern void note_oom_kill(void); extern void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order, unsigned int points, unsigned long totalpages, struct mem_cgroup *memcg, nodemask_t *nodemask, const char *message); extern int try_set_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags); extern void clear_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags); extern void check_panic_on_oom(enum oom_constraint constraint, gfp_t gfp_mask, int order, const nodemask_t *nodemask); extern enum oom_scan_t oom_scan_process_thread(struct task_struct *task, unsigned long totalpages, const nodemask_t *nodemask, bool force_kill); extern void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, int order, nodemask_t *mask, bool force_kill); extern int register_oom_notifier(struct notifier_block *nb); extern int unregister_oom_notifier(struct notifier_block *nb); extern bool oom_killer_disabled; static inline void oom_killer_disable(void) { oom_killer_disabled = true; } static inline void oom_killer_enable(void) { oom_killer_disabled = false; } extern struct task_struct *find_lock_task_mm(struct task_struct *p); /* sysctls */ extern int sysctl_oom_dump_tasks; extern int sysctl_oom_kill_allocating_task; extern int sysctl_panic_on_oom; #endif /* __KERNEL__*/ #endif /* _INCLUDE_LINUX_OOM_H */
#pragma once #define TSZ 32 extern World g_world; class PathFinding { public: PathFinding() : tx(-1), ty(-1), obj(NULL) {} int tx, ty; bool moving; Object* obj; void Start(Object* object, int targetX, int targetY) { obj = object; tx = targetX; ty = targetY; float dx = (float)tx - obj->GetX(); float dy = (float)ty - obj->GetY(); if (fabs(dx) > fabs(dy)) { if (dx < 0) obj->SetDir(LEFT); else if (dx > 0) obj->SetDir(RIGHT); } else { if (dy < 0) obj->SetDir(UP); else if (dy > 0) obj->SetDir(DOWN); } moving = true; } void Update() { if (!obj || !moving) return; bool snapped = (int)obj->GetX() % TSZ == 0 && (int)obj->GetY() % TSZ == 0; if ((tx != -1 && ty != -1) || !snapped) { if (tx == obj->GetX() && ty == obj->GetY() && snapped) { tx = -1; ty = -1; moving = false; } else { int trial = 0; if (snapped) { float dx = 0; float dy = 0; if (obj->GetDir() == LEFT) dx = -TSZ; else if (obj->GetDir() == RIGHT) dx = TSZ; else if (obj->GetDir() == UP) dy = -TSZ; else if (obj->GetDir() == DOWN) dy = TSZ; float nx = (float)obj->GetX() + dx; float ny = (float)obj->GetY() + dy; float ddx = (float) tx - obj->GetX(); float ddy = (float) ty - obj->GetY(); if (!g_world.GetObstacle(nx, ny)) { dx = ddx; dy = ddy; if (fabs(dx) > fabs(dy)) { if (dx < 0 && !g_world.GetObstacle(obj->GetX()-TSZ, obj->GetY())) { dx = -TSZ; obj->SetDir(LEFT); } else if (dx > 0 && !g_world.GetObstacle(obj->GetX()+TSZ, obj->GetY())) { obj->SetDir(RIGHT); dx = TSZ; } dy = 0; } else { if (dy < 0 && !g_world.GetObstacle(obj->GetX(), obj->GetY()-TSZ)) { obj->SetDir(UP); dy = -TSZ; } if (dy > 0 && !g_world.GetObstacle(obj->GetX(), obj->GetY()+TSZ)) { obj->SetDir(DOWN); dy = TSZ; } dx = 0; } } else { if (dx != 0) { dx = 0; if (ddy < 0 && !g_world.GetObstacle(obj->GetX(), obj->GetY()-TSZ)) { obj->SetDir(UP); dy = -TSZ; } if (ddy > 0 && !g_world.GetObstacle(obj->GetX(), obj->GetY()+TSZ)) { obj->SetDir(DOWN); dy = TSZ; } } else if (dy != 0) { dy = 0; if (ddx < 0 && !g_world.GetObstacle(obj->GetX()-TSZ, obj->GetY())) { dx = -TSZ; obj->SetDir(LEFT); } else if (ddx > 0 && !g_world.GetObstacle(obj->GetX()+TSZ, obj->GetY())) { obj->SetDir(RIGHT); dx = TSZ; } } } if (dx == 0 && dy == 0) moving = false; } if (moving) { if (obj->GetDir() == RIGHT) obj->SetX(obj->GetX() + 1); else if (obj->GetDir() == LEFT) obj->SetX(obj->GetX() - 1); else if (obj->GetDir() == DOWN) obj->SetY(obj->GetY() + 1); else if (obj->GetDir() == UP) obj->SetY(obj->GetY() - 1); } } } ((People*)obj)->m_moving = moving; } };
/* * cypress_touchkey.h - Platform data for cypress touchkey driver * * Copyright (C) 2011 Samsung Electronics * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * */ #ifndef __LINUX_CYPRESS_TOUCHKEY_H #define __LINUX_CYPRESS_TOUCHKEY_H extern struct class *sec_class; /* extern int ISSP_main(void); */ /* DVFS feature : TOUCH BOOSTER */ #define TSP_BOOSTER #ifdef TSP_BOOSTER #include <linux/cpufreq.h> #define TOUCH_BOOSTER_OFF_TIME 300 #define TOUCH_BOOSTER_CHG_TIME 200 #endif #ifdef CONFIG_LEDS_CLASS #include <linux/leds.h> #endif #include <linux/input.h> #include <linux/earlysuspend.h> #include <linux/mutex.h> #if defined(CONFIG_GLOVE_TOUCH) #define TK_BIT_GLOVE 0x40 #endif //#define AUTOCAL_WORKQUEUE /*#define TK_HOME_ENABLE*/ /* Flip cover*/ #define TKEY_FLIP_MODE #ifdef TKEY_FLIP_MODE #define TK_BIT_FLIP 0x08 #endif #define TK_INFORM_CHARGER #define TK_BIT_TA_ON 0x10 #define CYPRESS_55_IC_MASK 0x20 #define CYPRESS_65_IC_MASK 0x04 #define NUM_OF_KEY 4 #define TK_KEYPAD_ENABLE #ifdef TK_INFORM_CHARGER struct touchkey_callbacks { void (*inform_charger)(struct touchkey_callbacks *, bool); }; #endif struct cypress_touchkey_platform_data { unsigned gpio_led_en; u32 touchkey_keycode[4]; int keycodes_size; void (*power_onoff) (int); bool skip_fw_update; bool touchkey_order; void (*register_cb)(void *); bool i2c_pull_up; int gpio_int; u32 irq_gpio_flags; int gpio_sda; u32 sda_gpio_flags; int gpio_scl; u32 scl_gpio_flags; int vdd_led; }; struct cypress_touchkey_info { struct i2c_client *client; struct cypress_touchkey_platform_data *pdata; struct input_dev *input_dev; struct early_suspend early_suspend; char phys[32]; unsigned char keycode[NUM_OF_KEY]; u8 sensitivity[NUM_OF_KEY]; int irq; u8 fw_ver; void (*power_onoff)(int); int touchkey_update_status; u8 ic_vendor; struct regulator *vcc_en; struct regulator *vdd_led; #ifdef CONFIG_LEDS_CLASS struct led_classdev leds; enum led_brightness brightness; struct mutex touchkey_mutex; struct mutex fw_lock; struct workqueue_struct *led_wq; struct work_struct led_work; #endif #if defined(CONFIG_GLOVE_TOUCH) struct workqueue_struct *glove_wq; struct work_struct glove_work; #endif bool is_powering_on; bool enabled; bool done_ta_setting; #ifdef TKEY_FLIP_MODE bool enabled_flip; #endif #ifdef TSP_BOOSTER struct delayed_work work_dvfs_off; struct delayed_work work_dvfs_chg; bool dvfs_lock_status; struct mutex dvfs_lock; #endif #ifdef TK_INFORM_CHARGER struct touchkey_callbacks callbacks; bool charging_mode; #endif u32 fw_id; #if defined(CONFIG_GLOVE_TOUCH) int glove_value; #endif #ifdef TK_KEYPAD_ENABLE atomic_t keypad_enable; #endif }; void touchkey_charger_infom(bool en); #define PM8921_IRQ_BASE (NR_MSM_IRQS + NR_GPIO_IRQS) #define IRQ_TOUCHKEY_INT PM8921_GPIO_IRQ(PMIC8058_IRQ_BASE, (PM8058_GPIO(31))) #define GPIO_TOUCHKEY_SDA 83 #define GPIO_TOUCHKEY_SCL 84 #define GPIO_TOUCHKEY_SDA_2 95 #define GPIO_TOUCHKEY_SCL_2 96 #define PMIC_GPIO_TKEY_INT 79 #define PMIC_GPIO_TKEY_EN 32 #endif /* __LINUX_CYPRESS_TOUCHKEY_H */
/* * memory.c -- Memory leak detection (with its own memory leaks?) * * Copyright (C) 2012 Martin Wolters * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to * the Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301, USA * */ #include <stdio.h> #include <stdlib.h> #include <string.h> int n_mallocs = 0; int n_frees = 0; typedef struct malloclist_t { void *memory; char *file; int line; struct malloclist_t *next; } malloclist_t; malloclist_t *mall_list = NULL; static malloclist_t *make_entry(void *memory, char *file, int line) { malloclist_t *out; if((out = malloc(sizeof(malloclist_t))) == NULL) return NULL; out->memory = memory; out->line = line; out->file = file; out->next = NULL; return out; } static void addtolist(malloclist_t *entry) { malloclist_t *current = mall_list, *last = NULL; if(!current) { mall_list = entry; return; } while(current) { last = current; current = current->next; } last->next = entry; } static int delfromlist(void *memory) { malloclist_t *current = mall_list, *last = NULL; while(current) { if(current->memory == memory) { if(last) { last->next = current->next; } else { mall_list = current->next; } free(current); return 1; } last = current; current = current->next; } return 0; } void *mymalloc(size_t size, char *file, int line) { void *memory = malloc(size); malloclist_t *newentry; if((newentry = make_entry(memory, file, line))) addtolist(newentry); n_mallocs++; return memory; } void myfree(void *memory) { if(delfromlist(memory)) { n_frees++; free(memory); } else { fprintf(stderr, "WARNING: Called free() on unknown pointer.\n"); } } void showmemstats(FILE *fp) { malloclist_t *current = mall_list, *buf; if(n_mallocs != n_frees) { printf("\n--- memory.c summary ---\n"); if(n_frees < n_mallocs) { fprintf(fp, "Showing unfreed memory:\n"); while(current) { fprintf(fp, "%s, %d\n", current->file, current->line); buf = current; current = current->next; free(buf); } } fprintf(fp, "%d malloc()s; %d free()s.\n", n_mallocs, n_frees); printf("--- end summary ---\n"); } }
/* * hi64xx_resmgr.h -- resource manager for hi64xx codec * * Copyright (c) 2015 Hisilicon Technologies CO., Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #ifndef _HI64XX_RESMGR_H #define _HI64XX_RESMGR_H #include <sound/soc.h> #include <linux/notifier.h> #include <linux/hisi/hi64xx/hi_cdc_ctrl.h> #include <linux/hisi/hi64xx/hi64xx_irq.h> enum hi64xx_pll_type { PLL_LOW, PLL_HIGH, PLL_44_1, PLL_MAX, PLL_NONE = -1, }; /* Codec driver should implement these functions for each of its PLL or PLL state */ struct pll_ctrl_func { /* function to turn on this PLL or PLL state */ int (*turn_on)(struct snd_soc_codec *); /* function to turn off this PLL or PLL state */ int (*turn_off)(struct snd_soc_codec *); /* return ture if pll is locked */ bool (*is_locked)(struct snd_soc_codec *); }; struct resmgr_config { /* number of the PLL or PLL state the codec has */ int pll_num; /* functions to control each PLL or PLL state */ struct pll_ctrl_func pfn_pll_ctrls[PLL_MAX]; /* function to get the PLL required for accessing the specified register */ enum hi64xx_pll_type (*pll_for_reg_access)(struct snd_soc_codec *, unsigned int); /* functions to enable/disable micbias */ int (*enable_micbias)(struct snd_soc_codec *); int (*disable_micbias)(struct snd_soc_codec *); /* functions to enable/disable ibias */ int (*enable_ibias)(struct snd_soc_codec *); int (*disable_ibias)(struct snd_soc_codec *); }; struct hi64xx_resmgr { /* define datas that should be public */ }; int hi64xx_resmgr_init(struct snd_soc_codec *codec, struct hi_cdc_ctrl *cdc_ctrl, struct hi64xx_irq *irqmgr, const struct resmgr_config *config, struct hi64xx_resmgr **resmgr); void hi64xx_resmgr_deinit(struct hi64xx_resmgr *resmgr); int hi64xx_resmgr_request_reg_access(struct hi64xx_resmgr *resmgr, unsigned int reg_addr); int hi64xx_resmgr_release_reg_access(struct hi64xx_resmgr *resmgr, unsigned int reg_addr); int hi64xx_resmgr_request_pll(struct hi64xx_resmgr *resmgr, enum hi64xx_pll_type pll_type); int hi64xx_resmgr_release_pll(struct hi64xx_resmgr *resmgr, enum hi64xx_pll_type pll_type); int hi64xx_resmgr_request_micbias(struct hi64xx_resmgr *resmgr); int hi64xx_resmgr_release_micbias(struct hi64xx_resmgr *resmgr); int hi64xx_resmgr_force_release_micbias(struct hi64xx_resmgr *resmgr); void hi64xx_resmgr_dump(struct hi64xx_resmgr *resmgr); /* definations of notification events */ struct pll_switch_event { enum hi64xx_pll_type from; enum hi64xx_pll_type to; }; enum hi64xx_resmgr_event { PRE_PLL_SWITCH, /* event payload is struct pll_switch_event */ POST_PLL_SWITCH /* event payload is struct pll_switch_event */ }; int hi64xx_resmgr_register_notifier(struct hi64xx_resmgr *resmgr, struct notifier_block *nblock); int hi64xx_resmgr_unregister_notifier(struct hi64xx_resmgr *resmgr, struct notifier_block *nblock); #endif