text
stringlengths
4
6.14k
#ifndef LINUX_ABORT_WITH_PAYLOAD_H #define LINUX_ABORT_WITH_PAYLOAD_H long sys_abort_with_payload(unsigned int reason_namespace, unsigned long long reason_code, void *payload, unsigned int payload_size, const char *reason_string, unsigned long long reason_flags); #endif // LINUX_ABORT_WITH_PAYLOAD_H
#ifndef AD_LOGIC_SwirlBullets_H #define AD_LOGIC_SwirlBullets_H #include "ad/Components.h" namespace ad { namespace Logic { class SwirlBullets : public ad::Comps::LogicComponent { public: SwirlBullets(std::map<std::string, ad::Component*> Requires); void Update(); int speed; protected: private: int rotation; int rotation2; float timer; }; } // namespace Logic } // namespace ad #endif // AD_LOGIC_SwirlBullets_H
/* use ATT protocol opcodes from bluez/src/shared/att-types.h */ #include "att-types.h" int att_read(int fd, uint16_t handle, void *buf); int att_write(int fd, uint16_t handle, const void *buf, int length); int att_wrreq(int fd, uint16_t handle, const void *buf, int length); int att_read_not(int fd, uint16_t *handle, void *buf); const char *addr_type_name(int dst_type); const char *att_ecode2str(uint8_t status); /* copied from bluez/attrib/att.c */
/* * Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow * * $HEADER$ */ #include "opal_config.h" #include <stdlib.h> #include <string.h> #include "opal/constants.h" #include "opal/util/output.h" #include "opal/mca/if/if.h" static int if_bsdx_open(void); /* Supports specific flavors of BSD: * NetBSD * FreeBSD * OpenBSD * DragonFly */ opal_if_base_component_t mca_if_bsdx_ipv4_component = { /* First, the mca_component_t struct containing meta information about the component itself */ { OPAL_IF_BASE_VERSION_2_0_0, /* Component name and version */ "bsdx_ipv4", OPAL_MAJOR_VERSION, OPAL_MINOR_VERSION, OPAL_RELEASE_VERSION, /* Component open and close functions */ if_bsdx_open, NULL }, { /* This component is checkpointable */ MCA_BASE_METADATA_PARAM_CHECKPOINT }, }; /* convert a netmask (in network byte order) to CIDR notation */ static int prefix (uint32_t netmask) { uint32_t mask = ntohl(netmask); int plen = 0; if (0 == mask) { plen = 32; } else { while ((mask % 2) == 0) { plen += 1; mask /= 2; } } return (32 - plen); } /* configure using getifaddrs(3) */ static int if_bsdx_open(void) { struct ifaddrs **ifadd_list; struct ifaddrs *cur_ifaddrs; struct sockaddr_in* sin_addr; /* * the manpage claims that getifaddrs() allocates the memory, * and freeifaddrs() is later used to release the allocated memory. * however, without this malloc the call to getifaddrs() segfaults */ ifadd_list = (struct ifaddrs **) malloc(sizeof(struct ifaddrs*)); /* create the linked list of ifaddrs structs */ if (getifaddrs(ifadd_list) < 0) { opal_output(0, "opal_ifinit: getifaddrs() failed with error=%d\n", errno); return OPAL_ERROR; } for (cur_ifaddrs = *ifadd_list; NULL != cur_ifaddrs; cur_ifaddrs = cur_ifaddrs->ifa_next) { opal_if_t *intf; struct in_addr a4; /* skip non- af_inet interface addresses */ if (AF_INET != cur_ifaddrs->ifa_addr->sa_family) { continue; } /* skip interface if it is down (IFF_UP not set) */ if (0 == (cur_ifaddrs->ifa_flags & IFF_UP)) { continue; } /* skip interface if it is a loopback device (IFF_LOOPBACK set) */ if (!opal_if_retain_loopback && 0 != (cur_ifaddrs->ifa_flags & IFF_LOOPBACK)) { continue; } /* or if it is a point-to-point interface */ /* TODO: do we really skip p2p? */ if (0 != (cur_ifaddrs->ifa_flags & IFF_POINTOPOINT)) { continue; } sin_addr = (struct sockaddr_in *) cur_ifaddrs->ifa_addr; intf = OBJ_NEW(opal_if_t); if (NULL == intf) { opal_output(0, "opal_ifinit: unable to allocate %d bytes\n", (int) sizeof(opal_if_t)); return OPAL_ERR_OUT_OF_RESOURCE; } intf->af_family = AF_INET; /* fill values into the opal_if_t */ memcpy(&a4, &(sin_addr->sin_addr), sizeof(struct in_addr)); strncpy(intf->if_name, cur_ifaddrs->ifa_name, IF_NAMESIZE); intf->if_index = opal_list_get_size(&opal_if_list) + 1; ((struct sockaddr_in*) &intf->if_addr)->sin_addr = a4; ((struct sockaddr_in*) &intf->if_addr)->sin_family = AF_INET; ((struct sockaddr_in*) &intf->if_addr)->sin_len = cur_ifaddrs->ifa_addr->sa_len; intf->if_mask = prefix( sin_addr->sin_addr.s_addr); intf->if_flags = cur_ifaddrs->ifa_flags; intf->if_kernel_index = (uint16_t) if_nametoindex(cur_ifaddrs->ifa_name); opal_list_append(&opal_if_list, &(intf->super)); } /* of for loop over ifaddrs list */ return OPAL_SUCCESS; }
/* * This file is part of the libsigrok project. * * Copyright (C) 2013, 2014 Matthias Heidbrink <m-sigrok@heidbrink.biz> * * 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/>. */ /** @file * Gossen Metrawatt Metrahit 1x/2x drivers * @internal */ #ifndef LIBSIGROK_HARDWARE_GMC_MH_1X_2X_PROTOCOL_H #define LIBSIGROK_HARDWARE_GMC_MH_1X_2X_PROTOCOL_H #include <stdint.h> #include <glib.h> #include <libsigrok/libsigrok.h> #include "libsigrok-internal.h" #define LOG_PREFIX "gmc-mh-1x-2x" #define GMC_BUFSIZE 266 #define GMC_REPLY_SIZE 14 /** Message ID bits 4, 5 */ #define MSGID_MASK 0x30 /**< Mask to get message ID bits */ #define MSGID_INF 0x00 /**< Start of message with device info */ #define MSGID_D10 0x10 /**< Start of data message, non-displayed intermediate */ #define MSGID_DTA 0x20 /**< Start of data message, displayed, averaged */ #define MSGID_DATA 0x30 /**< Data byte in message */ #define MSGC_MASK 0x0f /**< Mask to get message byte contents in send mode */ #define MSGSRC_MASK 0xc0 /**< Mask to get bits related to message source */ #define bc(x) (x & MSGC_MASK) /**< Get contents from a byte */ #define MASK_6BITS 0x3f /**< Mask lower six bits. */ /** * Internal multimeter model codes. In opposite to the multimeter models from * protocol (see decode_model()), these codes allow working with ranges. */ enum model { METRAHIT_NONE = 0, /**< Value for uninitialized variable */ METRAHIT_12S = 12, METRAHIT_13S14A = 13, METRAHIT_14S = 14, METRAHIT_15S = 15, METRAHIT_16S = 16, METRAHIT_16I = 17, /**< Metrahit 16I, L */ METRAHIT_16T = 18, /**< Metrahit 16T, U, KMM2002 */ METRAHIT_16X = METRAHIT_16T, /**< All Metrahit 16 */ /* A Metrahit 17 exists, but seems not to have an IR interface. */ METRAHIT_18S = 19, METRAHIT_2X = 20, /**< For model type comparisons */ METRAHIT_22SM = METRAHIT_2X + 1, /**< Send mode */ METRAHIT_22S = METRAHIT_22SM + 1, /**< Bidi mode */ METRAHIT_22M = METRAHIT_22S + 1, /**< Bidi mode */ METRAHIT_23S = METRAHIT_22M + 1, METRAHIT_24S = METRAHIT_23S + 1, METRAHIT_25S = METRAHIT_24S + 1, METRAHIT_26SM = METRAHIT_25S + 1, /**< Send mode */ METRAHIT_26S = METRAHIT_26SM + 1, /**< Bidi mode */ METRAHIT_26M = METRAHIT_26S + 1, /**< Bidi mode */ /* The Metrahit 27x and 28Cx have a totally different protocol */ METRAHIT_28S = METRAHIT_26M + 1, METRAHIT_29S = METRAHIT_28S + 1, }; /** Private, per-device-instance driver context. */ struct dev_context { /* Model-specific information */ enum model model; /**< Model code. */ /* Acquisition settings */ uint64_t limit_samples; /**< Target number of samples */ uint64_t limit_msec; /**< Target sampling time */ /* Operational state */ gboolean settings_ok; /**< Settings msg received yet. */ int msg_type; /**< Message type (MSGID_INF, ...). */ int msg_len; /**< Message length (valid when msg, curr. type known).*/ int mq; /**< Measured quantity */ int unit; /**< Measured unit */ uint64_t mqflags; /**< Measured quantity flags */ float value; /**< Measured value */ float scale; /**< Scale for value. */ int8_t scale1000; /**< Additional scale factor 1000x. */ int addr; /**< Device address (1..15). */ int cmd_idx; /**< Parameter "Idx" (Index) of current command, if required. */ int cmd_seq; /**< Command sequence. Used to query status every n messages. */ gboolean autorng; /**< Auto range enabled. */ float ubatt; /**< Battery voltage. */ uint8_t fw_ver_maj; /**< Firmware version major. */ uint8_t fw_ver_min; /**< Firmware version minor. */ int64_t req_sent_at; /**< Request sent. */ gboolean response_pending; /**< Request sent, response is pending. */ /* Temporary state across callbacks */ uint64_t num_samples; /**< Current #samples for limit_samples */ GTimer *elapsed_msec; /**< Used for sampling with limit_msec */ uint8_t buf[GMC_BUFSIZE]; /**< Buffer for read callback */ int buflen; /**< Data len in buf */ }; /* Forward declarations */ SR_PRIV int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg); SR_PRIV int gmc_decode_model_bd(uint8_t mcode); SR_PRIV int gmc_decode_model_sm(uint8_t mcode); SR_PRIV int gmc_mh_1x_2x_receive_data(int fd, int revents, void *cb_data); SR_PRIV int gmc_mh_2x_receive_data(int fd, int revents, void *cb_data); SR_PRIV const char *gmc_model_str(enum model mcode); SR_PRIV int process_msg14(struct sr_dev_inst *sdi); SR_PRIV int req_meas14(const struct sr_dev_inst *sdi); SR_PRIV int req_stat14(const struct sr_dev_inst *sdi, gboolean power_on); #endif
#pragma once #include "TitleUnit.h" class CTitleFile { public: CTitleFile(void); ~CTitleFile(void); static BOOL IsLineEnd(PBUF_READ pReadData); static void StepOffset(PBUF_READ pReadData); static BOOL ReadSubTitleByLine(PBUF_READ pReadData, PTITLE_UNIT pUnit); static void StepSpaceChar(PBUF_READ pReadData); static void StepInvalidChar(PBUF_READ pReadData); static void StepALine(PBUF_READ pReadData); static BOOL ReadSubStart(PBUF_READ pReadData, PTITLE_UNIT pUnit); static BOOL ReadSubEnd(PBUF_READ pReadData, PTITLE_UNIT pUnit); static BOOL ReadSubTitle(PBUF_READ pReadData, PTITLE_UNIT pUnit); static BOOL ReadSSALine(PBUF_READ pReadData, CString& strLine); static BOOL FillSSAUnit(CString& strLine, PTITLE_UNIT pUnit); static PTITLE_UNIT StepTitleUnit(PBUF_READ pReadData); static PTITLE_UNIT StepTransUnit(PBUF_READ pReadData, BOOL bByLine); static BOOL PrepareRead(PBUF_READ pReadData, CFile* pFile); static void FillBuffer(PBUF_READ pReadData, CFile* pFile); static void ClearReadBuf(PBUF_READ pReadData); static BOOL ReadTitleFile(CFile* pFile, VT_TITLE& vtTitle, CString& strFmtHdr, BOOL& bUnicode); static BOOL WriteTitleFile(CFile* pFile, const VT_TITLE& vtTitle, CString& strFmtHdr, CString& strPreCode, CString& strPostCode, DWORD dwFmt, BOOL bUnicode, int nStart = -1, int nEnd = -1); static BOOL ReadTransFile(CFile* pFile, VT_TITLE& vtTitle, BOOL bSplitByLine, BOOL& bUnicode); static void DeleteContents(VT_TITLE& vtTitle); static CString GetSSAHdr(LPCTSTR lpszData, UINT& nEventOffset, BOOL bAdvanced = FALSE); static CString GetSSASection(CString strSrc, CString strTag); static CStringW GetSSAHdrA(LPCSTR lpszData, UINT& nEventOffset, BOOL bAdvanced = FALSE); static CStringA GetSSASection(CStringA strSrc, CStringA strTag); static void StepSignature(PBUF_READ pReadData); static void ProcessReverse(PBUF_READ pReadData); static UINT TestUnicodeBuf(LPVOID lpData, int nSize); // 0 is false, unicode/reverse/signature static CStringA ConvertCodePageStr(UINT nCPFrom, UINT nCPTo, const CStringA& strAnsi); static CString LCMapStrCN(UINT nSortKey, UINT nMapFlags, const CString& strInput); static CStringA ConvertUnicodeToUTF8(const CStringW& strSource); };
#include "vogl.h" static long px = -1, py = -1, pxs = -1, pys = -1; /* * prefposition * * Specify a prefered position for a window that is * under control of a window manager. * Position is the location of the upper left corner. * Should be called before ginit. */ void prefposition(long int x1, long int x2, long int y1, long int y2) { if (x1 < 0 || x2 < 0) verror("prefposition: bad x value"); if (y1 < 0 || y2 < 0) verror("prefposition: bad y value"); px = x1; py = y1; pxs = x2 - x1; pys = y2 - y1; if (pxs <= 0 || pys <= 0) verror("prefposition: bad window size"); } /* * prefsize * * Specify the prefered size for a window under control of * a window manager. * Should be called before ginit. */ void prefsize(long int x, long int y) { if (x < 0) verror("prefsize: bad x value"); if (y < 0) verror("prefsize: bad y value"); pxs = x; pys = y; } /* * getprefposandsize * * Returns the prefered position and size of a window under * control of a window manager. (-1 for unset parameters) */ void getprefposandsize(int *x, int *y, int *xs, int *ys) { *x = px; *y = py; *xs = pxs; *ys = pys; }
/* Phaethon - A FLOSS resource explorer for BioWare's Aurora engine games * * Phaethon is the legal property of its developers, whose names * can be found in the AUTHORS file distributed with this source * distribution. * * Phaethon 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. * * Phaethon 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 Phaethon. If not, see <http://www.gnu.org/licenses/>. */ /** @file * Handling BioWare's localized strings. */ #ifndef AURORA_LOCSTRING_H #define AURORA_LOCSTRING_H #include <vector> #include <map> #include "src/common/types.h" #include "src/common/ustring.h" #include "src/aurora/language.h" namespace Common { class SeekableReadStream; } namespace Aurora { /** A localized string. */ class LocString { public: struct SubLocString { uint32_t language; Common::UString str; SubLocString(uint32_t l = 0, const Common::UString &s = "") : language(l), str(s) { } }; LocString() = default; LocString(const LocString &) = default; ~LocString() = default; LocString &operator=(const LocString &) = default; void clear(); /** Is this localized string empty, without any strings whatsoever? */ bool empty() const; /** Swap the contents of the LocString with this LocString's. */ void swap(LocString &str); /** Return the string ID / StrRef. */ uint32_t getID() const; /** Set the string ID / StrRef. */ void setID(uint32_t id); /** Does the LocString have a string of this language? */ bool hasString(Language language, LanguageGender gender = kLanguageGenderCurrent) const; /** Get the string of that language. */ const Common::UString &getString(Language language, LanguageGender gender = kLanguageGenderCurrent) const; /** Set the string of that language. */ void setString(Language language, LanguageGender gender, const Common::UString &str); /** Set the string of that language (for all genders). */ void setString(Language language, const Common::UString &str); /** Get the string the StrRef points to. */ const Common::UString &getStrRefString() const; /** Get the first available string. */ const Common::UString &getFirstString() const; /** Try to get the most appropriate string. */ const Common::UString &getString() const; /** Return all strings. */ void getStrings(std::vector<SubLocString> &str) const; /** Read a string out of a stream. */ void readString(uint32_t languageID, Common::SeekableReadStream &stream); /** Read a LocSubString (substring of a LocString in game data) out of a stream. */ void readLocSubString(Common::SeekableReadStream &stream); /** Read a LocString out of a stream. */ void readLocString(Common::SeekableReadStream &stream, uint32_t id, uint32_t count); /** Read a LocString out of a stream. */ void readLocString(Common::SeekableReadStream &stream); private: typedef std::map<uint32_t, Common::UString> StringMap; uint32_t _id { kStrRefInvalid }; ///< The string's ID / StrRef. StringMap _strings; bool hasString(uint32_t languageID) const; const Common::UString &getString(uint32_t languageID) const; void setString(uint32_t languageID, const Common::UString &str); }; } // End of namespace Aurora #endif // AURORA_LOCSTRING_H
/**************************************************************************** * Copyright (C) 2010 * by Dimok * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any * damages arising from the use of this software. * * Permission is granted to anyone to use this software for any * purpose, including commercial applications, and to alter it and * redistribute it freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you * must not claim that you wrote the original software. If you use * this software in a product, an acknowledgment in the product * documentation would be appreciated but is not required. * * 2. Altered source versions must be plainly marked as such, and * must not be misrepresented as being the original software. * * 3. This notice may not be removed or altered from any source * distribution. * * for WiiXplorer 2010 ***************************************************************************/ #ifndef MENU_FTP_SERVER_H_ #define MENU_FTP_SERVER_H_ #include "GUI/gui.h" #include "Controls/GXConsole.hpp" class FTPServerMenu : public GuiFrame, public sigslot::has_slots<> { public: FTPServerMenu(); virtual ~FTPServerMenu(); protected: void OnButtonClick(GuiButton *sender, int pointer, const POINT &p); GuiSound * btnSoundClick; GuiSound * btnSoundOver; GuiImageData * btnOutline; GuiImageData * btnOutlineOver; GuiImageData * network_icon; GuiImageData * bgImgData; GuiImage * bgImg; GuiImage * backBtnImg; GuiImage * MainFTPBtnImg; GuiImage * networkImg; GuiText * IPText; GuiText * backBtnTxt; GuiText * MainFTPBtnTxt; GuiButton * backBtn; GuiButton * MainFTPBtn; SimpleGuiTrigger * trigA; GuiTrigger * trigB; GXConsole * Console; }; #endif
/* -*- c++ -*- */ /* * Copyright 2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * * GNU Radio 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, or (at your option) * any later version. * * GNU Radio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GNU Radio; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #ifndef INCLUDED_TCP_CONNECTION_H #define INCLUDED_TCP_CONNECTION_H #include <gnuradio/block.h> #include <pmt/pmt.h> #include <boost/array.hpp> #include <boost/asio.hpp> #include <boost/shared_ptr.hpp> namespace gr { namespace blocks { class tcp_connection { private: boost::asio::ip::tcp::socket d_socket; std::vector<char> d_buf; block* d_block; bool d_no_delay; tcp_connection(boost::asio::io_service& io_service, int MTU = 10000, bool no_delay = false); public: typedef boost::shared_ptr<tcp_connection> sptr; static sptr make(boost::asio::io_service& io_service, int MTU = 10000, bool no_delay = false); boost::asio::ip::tcp::socket& socket() { return d_socket; }; void start(gr::block* block); void send(pmt::pmt_t vector); void handle_read(const boost::system::error_code& error, size_t bytes_transferred); void handle_write(boost::shared_ptr<char[]> txbuf, const boost::system::error_code& error, size_t bytes_transferred) { } }; } /* namespace blocks */ } /* namespace gr */ #endif /* INCLUDED_TCP_CONNECTION_H */
#include <stdlib.h> #include <stdio.h> #include <string.h> #include "search-sort.h" int binary_search_int(const int64_t arr[], int start, int end, int64_t key) { int mid; while(start <= end) { mid = start + (end - start) / 2; if(arr[mid] < key) start = mid + 1; else if(arr[mid] > key) end = mid - 1; else return mid; } return -1; } int binary_search(void * arr, int unit_size, int start, int end, void * key, int (*compare)(void *one, void *two)) { int mid; while(start <= end) { mid = start + (end - start) / 2; int cmp = compare(arr + mid*unit_size, key); if(cmp < 0) start = mid + 1; else if(cmp > 0) end = mid - 1; else return mid; } return -1; } void bubble_sort_int(int64_t arr[], int len) { uint32_t i, j, temp; for(i = 0; i < len-1; i++) for(j = 0; j < len-1-i; j++) if(arr[j] > arr[j+1]) { temp = arr[j]; arr[j] = arr[j+1]; arr[j+1] = temp; } } int min(int x, int y) { return x < y ? x : y; } void merge_sort_int(int64_t arr[], int len) { int64_t * a = arr; int64_t * b = (int64_t*)malloc(len * sizeof(int64_t)); if(b == NULL) { perror("merge_sort: malloc failed"); return; } int64_t * mark_b = b; int seg, start; for(seg = 1; seg < len; seg += seg) { for(start = 0; start < len; start += seg + seg) { int low = start, mid = min(start + seg, len), high = min(start + seg + seg, len); int k = low; int start1 = low, end1 = mid; int start2 = mid, end2 = high; while(start1 < end1 && start2 < end2) if(a[start1] < a[start2]) { b[k] = a[start1]; k++; start1++; } else { b[k] = a[start2]; k++; start2++; } while(start1 < end1) { b[k] = a[start1]; k++; start1++; } while(start2 < end2) { b[k] = a[start2]; k++; start2++; } } int64_t* temp = a; a = b; b = temp; // at the end, a always holds the sorted array } if(a != arr) for(int i = 0; i < len; i++) arr[i] = a[i]; free(mark_b); } void swap_int(int64_t *x, int64_t *y) { int64_t t = *x; *x = *y; *y = t; } void quick_sort_int_recursive(int64_t arr[], int start, int end) { if(start >= end) return; int64_t mid = arr[end]; int left = start, right = end - 1; while(left < right) { while(arr[left] < mid && left < right) left++; while(arr[right] >= mid && left < right) right--; swap_int(&arr[left], &arr[right]); } if(arr[left] >= arr[end]) swap_int(&arr[left], &arr[end]); else left++; if(left) quick_sort_int_recursive(arr, start, left - 1); quick_sort_int_recursive(arr, left + 1, end); } void quick_sort_int(int64_t arr[], int len) { quick_sort_int_recursive(arr, 0, len - 1); } void quick_sort_recursive(void * arr, int unit_size, int start, int end, int (*compare)(void *one, void *two), void (*swap)(void *one, void *two)) { if(start >= end) return; void * mid = arr + end*unit_size; int left = start, right = end - 1; while(left < right) { while(compare(arr+left*unit_size, mid) < 0 && left < right) left++; while(compare(arr+right*unit_size, mid) >= 0 && left < right) right--; swap(arr + left*unit_size, arr + right*unit_size); } if(compare(arr + left*unit_size, arr + end*unit_size) >=0) swap(arr + left*unit_size, arr + end*unit_size); else left++; if(left) quick_sort_recursive(arr, unit_size, start, left - 1, compare, swap); quick_sort_recursive(arr, unit_size, left + 1, end, compare, swap); } void quick_sort(void * arr, int unit_size, int len, int (*compare)(void *one, void *two), void (*swap)(void *one, void *two)) { quick_sort_recursive(arr, unit_size, 0, len - 1, compare, swap); }
#include <msp430.h> #include "wdt.h" #include "common/hal/lcd_segments.h" #include "common/svc/svc.h" uint8_t wdt_event=0; void wdt_init(void) { WDTCTL = WDT_ADLY_250; SFRIE1 |= WDTIE; } void __attribute__((interrupt ((WDT_VECTOR)))) WDTServiceRoutine(void) { SFRIFG1 &= ~WDTIFG; wdt_event = 1; LPM3_EXIT; }
//--------------------------------------------------------------------------- #ifndef SplashFormH #define SplashFormH //--------------------------------------------------------------------------- #include <Classes.hpp> #include <Controls.hpp> #include <StdCtrls.hpp> #include <Forms.hpp> #include <ExtCtrls.hpp> #include <Graphics.hpp> //--------------------------------------------------------------------------- class TSplash : public TForm { __published: // IDE-managed Components TImage *Image1; TLabel *Label1; TLabel *Label2; TLabel *Label3; TLabel *Label4; TLabel *Label6; TLabel *Label7; TLabel *Label8; TLabel *Label9; TLabel *Label10; void __fastcall Label6MouseEnter(TObject *Sender); void __fastcall Label6MouseLeave(TObject *Sender); void __fastcall Label6Click(TObject *Sender); private: // User declarations public: // User declarations __fastcall TSplash(TComponent* Owner); }; //--------------------------------------------------------------------------- extern PACKAGE TSplash *Splash; //--------------------------------------------------------------------------- #endif
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #ifndef _lista_simples_h #define _lista_simples_h /*A implementacao utiliza um noh cabeca apontando * para o primeiro elemento da lista */ // Define um ponteiro void para dados genericos typedef void* gpointer; // Definicao estrutura lista typedef struct noh noh; typedef noh *lista; struct noh { gpointer elem; noh *prox; }; typedef int (*cmp_func)(gpointer a, gpointer b); // Posicao de um elemento é um ponteiro que contem // o antecessor desse elemento typedef noh *posicao; // Declaraçao Operadores bool inic_lista(lista *L); bool inserir_no_fim(lista *L, gpointer valor); bool inserir_no_comeco(lista *L, gpointer valor); bool inserir(lista *L, posicao p, gpointer valor); bool inserir_ordenado(lista *L, gpointer valor, cmp_func func); gpointer deletar(lista *L, posicao p); posicao local(lista L, gpointer valor); bool esvaziar (lista *L); posicao primeira(lista L); posicao fim(lista L); posicao proxima(lista L); gpointer elemento(Lista L, posicao); // Funcoes auxiliares bool alocar_noh(noh **no, gpointer dados); #endif
#ifndef LZH_SOCKET_SERVER #define LZH_SOCKET_SERVER #define MAXUDP_GRAM (65536) #define LISTEN_PORT (5409) #define PROTO_HTTP (0) #define PROTO_MQTT (1) #define PROTO_ENDE (2) typedef struct tagLoadParams { unsigned long maxThread; unsigned long maxTimeOut; unsigned long protoType; unsigned char* loadUri; } LoadParams; void closeServer(); LoadParams* parsePacket(unsigned char* pktBuff, int msgLen); LoadParams* readNextLoad(); void freeLoadParams(void* data); #endif
/* Copyright 2007-2010,2016 IPB, Universite de Bordeaux, INRIA & CNRS ** ** This file is part of the Scotch software package for static mapping, ** graph partitioning and sparse matrix ordering. ** ** This software is governed by the CeCILL-C license under French law ** and abiding by the rules of distribution of free software. You can ** use, modify and/or redistribute the software under the terms of the ** CeCILL-C license as circulated by CEA, CNRS and INRIA at the following ** URL: "http://www.cecill.info". ** ** As a counterpart to the access to the source code and rights to copy, ** modify and redistribute granted by the license, users are provided ** only with a limited warranty and the software's author, the holder of ** the economic rights, and the successive licensors have only limited ** liability. ** ** In this respect, the user's attention is drawn to the risks associated ** with loading, using, modifying and/or developing or reproducing the ** software by the user in light of its specific status of free software, ** that may mean that it is complicated to manipulate, and that also ** therefore means that it is reserved for developers and experienced ** professionals having in-depth computer knowledge. Users are therefore ** encouraged to load and test the software's suitability as regards ** their requirements in conditions enabling the security of their ** systems and/or data to be ensured and, more generally, to use and ** operate it in the same conditions as regards security. ** ** The fact that you are presently reading this means that you have had ** knowledge of the CeCILL-C license and that you accept its terms. */ /************************************************************/ /** **/ /** NAME : wgraph_part_zr.c **/ /** **/ /** AUTHOR : Jun-Ho HER (v6.0) **/ /** Charles-Edmond BICHOT (v5.1b) **/ /** Francois PELLEGRINI **/ /** **/ /** FUNCTION : This module moves all of the vertices **/ /** to the first subdomain of the **/ /** partition. **/ /** **/ /** DATES : # Version 5.1 : from : 01 dec 2007 **/ /** to : 01 jul 2008 **/ /** # Version 6.0 : from : 05 nov 2009 **/ /** to : 14 mar 2010 **/ /** **/ /************************************************************/ /* ** The defines and includes. */ #define WGRAPH_PART_ZR #include "module.h" #include "common.h" #include "graph.h" #include "wgraph.h" #include "wgraph_part_zr.h" /*****************************/ /* */ /* This is the main routine. */ /* */ /*****************************/ /* This routine moves all of the graph vertices ** to the first part of the partition. ** It returns: ** - 0 : if the bipartitioning could be computed. ** - !0 : on error. */ int wgraphPartZr ( Wgraph * const grafptr) /*+ Active graph +*/ { if (grafptr->compsize[0] != grafptr->s.vertnbr) /* If not all vertices already in part zero */ wgraphZero (grafptr); return (0); }
/***************************************************************************** * Copyright 2015-2020 Alexander Barthel alex@littlenavmap.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 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. *****************************************************************************/ #ifndef ATOOLS_AIRSPACEREADER_OPENAIR_H #define ATOOLS_AIRSPACEREADER_OPENAIR_H #include "geo/linestring.h" #include "fs/userdata/airspacereaderbase.h" namespace atools { namespace sql { class SqlDatabase; class SqlQuery; } namespace fs { namespace userdata { /* * Reads OpenAir files containing airspaces and writes them to the boundary table. * * http://www.winpilot.com/UsersGuide/UserAirspace.asp */ class AirspaceReaderOpenAir : public AirspaceReaderBase { public: AirspaceReaderOpenAir(sql::SqlDatabase *sqlDb); virtual ~AirspaceReaderOpenAir() override; /* Read a whole file and write airspaces into table */ virtual void readFile(int fileIdParam, const QString& filenameParam) override; /* Read a line from a file and write to file if end of airspace detected */ virtual void readLine(const QStringList& line, int fileIdParam, const QString& filenameParam, int lineNumberParam) override; /* Writes last airspace to table */ virtual void finish() override; /* reset internal values back */ virtual void reset() override; private: void writeBoundary(); void bindAltitude(const QStringList& line, bool isMax); void bindClass(const QString& cls); void bindName(const QString& name); void bindCoordinate(const QStringList& line); bool writingCoordinates = false; atools::geo::LineString curLine; atools::geo::Pos center; bool clockwise = true; }; } // namespace userdata } // namespace fs } // namespace atools #endif // ATOOLS_AIRSPACEREADER_OPENAIR_H
/* sentence.hh * author: Johan Carlberger * last change: 2000-04-27 * comments: Sentence class */ #ifndef _sentence_hh #define _sentence_hh #include "wordtoken.h" // these should be in Sentence: const int MAX_SENTENCE_LENGTH = 150; // can be set arbitrarily class Sentence; class GramError; class Tagger; class AbstractSentence { friend class Scrutinizer; friend class Tagger; friend class MatchingSet; public: AbstractSentence() : nWords(0), nTokens(0), tokens(NULL), prob(0), endsParagraph(0), containsStyleWord(0), containsRepeatedWords(0), containsNewWord(0), isHeading(0), seemsForeign(0), bitsSet(0), nGramErrors(0), gramError(NULL) {} void Print(std::ostream& = std::cout) const; void Print(int from, int to, std::ostream& = std::cout) const; int NWords() const { return nWords; } int NTokens() const { return nTokens; } Word* GetWord(int n) const { return tokens[n]->GetWord(); } WordToken* GetWordToken(int n) const { return tokens[n]; } WordToken** GetWordTokensAt(int n) const { return tokens + n; } int TextPos() const { return tokens[2]->Offset(); } probType Prob() const { return prob; } void FixUp(); void TagMe(); bool IsEqual(const AbstractSentence*) const; void SetContentBits(); bool ContainsNewWord() const { ensure(bitsSet); return containsNewWord; } bool ContainsStyleWord() const { ensure(bitsSet); return containsStyleWord; } bool ContainsRepeatedWords() const { ensure(bitsSet); return containsRepeatedWords; } bool SeemsForeign() const { ensure(bitsSet); return seemsForeign; } bool IsHeading() const { return isHeading; } bool EndsParagraph() const { return endsParagraph; } const GramError *GetGramError() const { return gramError; } int NGramErrors() const { return nGramErrors; } void setOriginalText(std::string org) { //if(originalText) // delete originalText; originalText = org; } std::string getOriginalText() const {return originalText;} protected: std::string originalText; //Oscar static Tagger *tagger; short nWords; // including punctuation marks short nTokens; // including 4 sentence-delimiters // jonas, both actually count the same thing WordToken **tokens; probType prob; Bit endsParagraph : 1; Bit containsStyleWord : 1; Bit containsRepeatedWords : 1; Bit containsNewWord : 1; Bit isHeading : 1; Bit seemsForeign : 1; Bit bitsSet : 1; char nGramErrors; GramError *gramError; }; enum SentenceStatus { SEEMS_OK, SAME_AS_ORIGINAL, SAME_AS_ANOTHER, FORM_NOT_FOUND, NOT_IMPROVING }; class DynamicSentence : public AbstractSentence { friend class Matching; friend class GramError; friend class Expr; friend class Scrutinizer; public: DynamicSentence() : next(0), size(0), actualTokens(0) { NewObj(); } DynamicSentence(const AbstractSentence*); ~DynamicSentence(); void Delete(int from, int to); bool Delete(int orgPos); void Insert(int pos, Word*, const char *string); bool Insert2(int orgPos, Word*, const char *string); bool Replace(Word*, const char *string, int orgPos); DynamicSentence *Next() const { return next; } DynamicSentence *SetNext(DynamicSentence *s) { return next=s; } SentenceStatus Status() const { return status; } void PrintOrgRange(int from, int to, std::ostream& = std::cout) const; private: DynamicSentence *next; short size; SentenceStatus status; WordToken *actualTokens; DecObj(); }; class Sentence : public AbstractSentence { friend class Tagger; friend class Text; public: Sentence *Next() const { return next; } private: Sentence(int n) { ensure(n < MAX_SENTENCE_LENGTH); tokens = new WordToken*[n]; NewObj(); } ~Sentence(); Sentence *next; DecObj(); }; inline std::ostream& operator<<(std::ostream& os, const Sentence &s) { os << &s; return os; } inline std::ostream& operator<<(std::ostream& os, const AbstractSentence *s) { if (s) s->Print(os); else os << "(null Sentence)"; return os; } #endif
#ifndef TEMPERATUREDATA_H #define TEMPERATUREDATA_H #include "Data/healthdata.h" class TemperatureData : public HealthData { public: explicit TemperatureData(); explicit TemperatureData(float temperature); explicit TemperatureData(HealthData data, float temperature); // Accessors float temperature() const { return _temperature; } void setTemperature(float temperature) { _temperature = temperature; } virtual QString toString(); signals: public slots: private: float _temperature; }; // Serialization QDataStream &operator<<(QDataStream &out, const TemperatureData &data); QDataStream &operator>>(QDataStream &in, TemperatureData &data); #endif // TEMPERATUREDATA_H
/* xoreos - A reimplementation of BioWare's Aurora engine * * xoreos is the legal property of its developers, whose names * can be found in the AUTHORS file distributed with this source * distribution. * * xoreos 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. * * xoreos 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 xoreos. If not, see <http://www.gnu.org/licenses/>. */ // Inspired by ScummVM's debug channels /** @file * The debug manager, managing debug channels. */ #ifndef COMMON_DEBUGMAN_H #define COMMON_DEBUGMAN_H #include <map> #include "src/common/types.h" #include "src/common/ustring.h" #include "src/common/singleton.h" #include "src/common/file.h" namespace Common { /** Global, non-engine code debug channels. */ enum DebugChannels { kDebugGraphics = 1 << 0, kDebugSound = 1 << 1, kDebugEvents = 1 << 2, kDebugScripts = 1 << 3, kDebugReserved04 = 1 << 4, kDebugReserved05 = 1 << 5, kDebugReserved06 = 1 << 6, kDebugReserved07 = 1 << 7, kDebugReserved08 = 1 << 8, kDebugReserved09 = 1 << 9, kDebugReserved10 = 1 << 10, kDebugReserved11 = 1 << 11, kDebugReserved12 = 1 << 12, kDebugReserved13 = 1 << 13, kDebugReserved14 = 1 << 14 }; /** The debug manager, managing debug channels. */ class DebugManager : public Singleton<DebugManager> { public: DebugManager(); ~DebugManager(); /** Add a debug channel. * * A debug channel separates debug messages into groups, so debug output * doesn't get swamped unecessarily. Only when a debug channel is enabled * are debug messages to that channel shown. * * So that several channels can be enabled at the same time, all channel * IDs must be OR-able, i.e. the first one should be 1, then 2, 4, .... * * The first 15 channels (IDs 2^1 - 2^15) are reserved for the non-engine * code, the next 15 channels (IDs 2^16 - 2^30) are reserved for the * engines. * * @param channel The channel ID, should be OR-able. * @param name The channel's name, used to enable the channel on the * command line (or console, if supported by the engine). * @param description A description of the channel, displayed when listing * The available channels. * * @return true on success. * */ bool addDebugChannel(uint32 channel, const UString &name, const UString &description); /** Return the channel names alongside their descriptions. */ void getDebugChannels(std::vector<UString> &names, std::vector<UString> &descriptions, uint32 &nameLength) const; /** Remove all engine-specific debug channels. */ void clearEngineChannels(); /** Parse a comma-separated list of debug channels to a channel mask. */ uint32 parseChannelList(const UString &list) const; /** Use the specified mask to set the enabled state for all channels. */ void setEnabled(uint32 mask); /** Is the specified channel and level enabled? */ bool isEnabled(uint32 level, uint32 channel) const; /** Return the current debug level. */ uint32 getDebugLevel() const; /** Set the current debug level. */ void setDebugLevel(uint32 level); /** Open a log file where all debug output will be written to. */ bool openLogFile(const UString &file); /** Close the current log file. */ void closeLogFile(); /** Log that string to the current log file. */ void logString(const UString &str); /** Return the OS-specific default path of the log file. */ static UString getDefaultLogFile(); private: static const uint kGlobalChannelCount = 15; static const uint kEngineChannelCount = 15; static const uint kChannelCount = kGlobalChannelCount + kEngineChannelCount; /** A debug channel. */ struct Channel { UString name; ///< The channel's name. UString description; ///< The channel's description. bool enabled; ///< Is the channel enabled? }; typedef std::map<UString, uint32> ChannelMap; Channel _channels[kChannelCount]; ///< All debug channels. ChannelMap _channelMap; ///< Debug channels indexed by name. uint32 _debugLevel; ///< The current debug level. DumpFile _logFile; bool _logFileStartLine; }; } // End of namespace Common /** Shortcut for accessing the debug manager. */ #define DebugMan Common::DebugManager::instance() #endif // COMMON_DEBUGMAN_H
/***************************************************************************** * Copyright (C) 2014 Visualink * * Authors: Adrien Maglo <adrien@visualink.io> * * This file is part of Pastec. * * Pastec is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pastec 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 Pastec. If not, see <http://www.gnu.org/licenses/>. *****************************************************************************/ #ifndef PASTEC_SEARCHER_H #define PASTEC_SEARCHER_H #include <sys/types.h> #include <vector> #include <opencv2/core/core.hpp> using namespace std; using namespace cv; struct SearchRequest { vector<char> imageData; vector<uint32_t> results; vector<Rect> boundingRects; }; class Searcher { public: virtual uint32_t searchImage(SearchRequest &request) = 0; }; #endif // PASTEC_SEARCHER_H
size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) /* Used by curl */ { struct curlfile *out=(struct curlfile *)stream; if(out && !out->stream) { out->stream=fopen(out->filename, "wb"); if(!out->stream) return -1; } return fwrite(buffer, size, nmemb, out->stream); } int in_array(char *array[], int size, char *lookfor) /* Check if array has lookfor als element */ { int i; for (i = 0; i < size; i++) if (strcmp(lookfor, array[i]) == 0) return 1; return 0; } int load_image(char *path, char *filename, struct elektrol_config config, int server) /* Load the requested image and store it at filename */ { int returnstate; CURL *curl; CURLcode result; returnstate = 0; struct curlfile downfile= { filename, NULL }; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, path); if(server == 0) { curl_easy_setopt(curl, CURLOPT_USERNAME, config.user); curl_easy_setopt(curl, CURLOPT_PASSWORD, config.passwd); } curl_easy_setopt(curl, CURLOPT_WRITEDATA, &downfile); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite); result = curl_easy_perform(curl); curl_easy_cleanup(curl); if(CURLE_OK != result) { fprintf(stderr, "Could not load image located at %s, curl returned error state %d\n", path, result); returnstate = 1; } } if(downfile.stream) fclose(downfile.stream); /* close the local file */ return returnstate; } int check_black_image(char *filename) { char command[200]; int exitstate; command[0] = '\0'; strcat(command, "identify -verbose "); strcat(command, filename); strcat(command, " | grep -x \" Colors: 1\" > /dev/null"); exitstate = system(command); if (exitstate == -1) { exit(ELEKTROL_UNKOWN_ERROR); } else if(WEXITSTATUS(exitstate) == 0) { remove(filename); return 1; } else { return 0; } }
extern const int MAX; void insert(char); void del(); void display(); // Definition of struct struct queue { int front; int rear; char queue[5]; };
/* https://cirosantilli.com/linux-kernel-module-cheat#ring0 */ #include <linux/module.h> #include <linux/kernel.h> #include <lkmc/ring0.h> static int myinit(void) { #if defined(__x86_64__) || defined(__i386__) LkmcRing0Regs ring0_regs; lkmc_ring0_get_control_regs(&ring0_regs); pr_info("cr0 = 0x%8.8llX\n", (unsigned long long)ring0_regs.cr0); pr_info("cr2 = 0x%8.8llX\n", (unsigned long long)ring0_regs.cr2); pr_info("cr3 = 0x%8.8llX\n", (unsigned long long)ring0_regs.cr3); #endif return 0; } static void myexit(void) {} module_init(myinit) module_exit(myexit) MODULE_LICENSE("GPL");
/* * Object space definition. */ #ifndef objectspace_h #define objectspace_h #include <InterViews/stub.h> class Catalog; class Messenger; class ObjectTable; class SpaceManager; class ObjectSpace : public ObjectStub { public: ObjectSpace(const char*); ~ObjectSpace(); void StartServer(Connection* local, Connection* remote); void UsePath(const char*); Connection* Find(const char*, boolean wait = false); void Dispatch(); void Message(Connection*, ObjectTag, int op, void*, int len); void Deliver(Connection*, ObjectTag, int op, void*, int); ObjectStub* Map(Connection*, ObjectTag); void AddChannel(int, ObjectStub*); void RemoveChannel(int); void Attach(int); void Detach(int); protected: const char* name; Catalog* dictionary; ObjectTable* table; ObjectSpace(); private: struct MQueue { Messenger* head, * tail; }; struct Stream { int channel, mask; ObjectStub* object; Stream* next; }; Connection* local; Connection* remote; SpaceManager* manager; int channels; int maxchannel; MQueue active; MQueue inactive; Stream* streams; void Init(); void Listen(Connection*); boolean Ready(int, Connection*); void CheckServer(int, Connection*); void CheckClients(); void Add(Messenger*, MQueue&); void Remove(Messenger*, MQueue&); void CloseDown(Messenger*); virtual void AddClient(Connection*); }; /* * Protocol definitions. */ static const int objectspace_Find = 1; static const int objectspace_Clone = 2; static const int objectspace_Destroy = 3; struct objectspace_Msg { ObjectTag tag; char name[1]; /* rest of name */ }; #endif
/* * Beautiful Capi generates beautiful C API wrappers for your C++ classes * Copyright (C) 2015 Petr Petrovich Petrov * * This file is part of Beautiful Capi. * * Beautiful Capi 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. * * Beautiful Capi 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 Beautiful Capi. If not, see <http://www.gnu.org/licenses/>. * */ #if defined(_WIN32) && defined(_DEBUG) #include <crtdbg.h> #endif #include <stdlib.h> #include <stdint.h> #include "ExampleCapi.h" void f1(void* p) { example_printer_show(p, "from f1()"); example_printer_delete(p); } void* create_printer() { void* new_printer = example_printer_new(); example_printer_show(new_printer, "from create_printer()"); return new_printer; } int main() { #if defined(_WIN32) && defined(_DEBUG) _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif void* printer = create_printer(); example_printer_show(printer, "from main()"); void* printer_copy = example_printer_copy(printer); f1(printer_copy); void* dumper_t = example_dumper_new(); example_dumper_set_printer(dumper_t, printer); example_dumper_dump(dumper_t); void* printer2 = example_dumper_get_printer_const(dumper_t); example_printer_show(printer2, "printer2"); example_printer_delete(printer); example_dumper_delete(dumper_t); example_printer_delete(printer2); return EXIT_SUCCESS; }
/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef SIMULATION_ELEMENTS_MOVS_H #define SIMULATION_ELEMENTS_MOVS_H #ifndef NOMOD #include <math.h> #include "simulation/ElementDataContainer.h" #include "powder.h" #include "simulation/Simulation.h" #include "gravity.h" #define MAX_MOVING_SOLIDS 256 void rotate(float *x, float *y, float angle); class MovingSolid { public: float vx, vy; float rotationOld, rotation; int index; int particleCount; //number of particles attached to it void Simulation_Cleared() { vx = vy = 0.0f; rotationOld = rotation = 0.0f; index = 0; particleCount = 0; } }; class MOVS_ElementDataContainer : public ElementDataContainer { private: MovingSolid movingSolids[MAX_MOVING_SOLIDS]; int numBalls; public: int creatingSolid; MOVS_ElementDataContainer(): numBalls(0) { for (int i = 0; i < MAX_MOVING_SOLIDS; i++) movingSolids[i].Simulation_Cleared(); } MovingSolid* GetMovingSolid(int bn) { if (bn >= 0 && bn < MAX_MOVING_SOLIDS) return movingSolids + bn; return NULL; } int GetNumBalls() { return numBalls; } void SetNumBalls(int num) { numBalls = num; } virtual void Simulation_Cleared(Simulation *sim) { for (int i = 0; i < MAX_MOVING_SOLIDS; i++) movingSolids[i].Simulation_Cleared(); numBalls = 0; creatingSolid = 0; } void CreateMovingSolidCenter(int i) { if (numBalls >= 255) return; parts[i].tmp2 = numBalls; parts[i].pavg[0] = 0; parts[i].pavg[1] = 0; MovingSolid *movingSolid = GetMovingSolid(numBalls++); if (movingSolid) { movingSolid->index = i+1; movingSolid->particleCount = 1; movingSolid->vx = 0; movingSolid->vy = 0; movingSolid->rotationOld = movingSolid->rotation = 0; } creatingSolid = numBalls; } void CreateMovingSolid(int i, int x, int y) { int bn = creatingSolid-1; MovingSolid *movingSolid = GetMovingSolid(bn); if (movingSolid) { parts[i].tmp2 = bn; parts[i].pavg[0] = x - parts[movingSolid->index-1].x; parts[i].pavg[1] = y - parts[movingSolid->index-1].y; movingSolid->particleCount++; } } bool IsCreatingSolid() { return creatingSolid != 0; } virtual void Simulation_BeforeUpdate(Simulation *sim) { creatingSolid = 0; } virtual void Simulation_AfterUpdate(Simulation *sim) { if (numBalls == 0) return; for (int i = 0; i <= globalSim->parts_lastActiveIndex; i++) { if (parts[i].flags&FLAG_DISAPPEAR) { globalSim->part_kill(i); } else if (parts[i].type == PT_MOVS) { MovingSolid *movingSolid = GetMovingSolid(parts[i].tmp2); if (!movingSolid || !movingSolid->index) continue; movingSolid->vx = movingSolid->vx + parts[i].vx; movingSolid->vy = movingSolid->vy + parts[i].vy; } } for (int bn = 0; bn < numBalls; bn++) { MovingSolid *movingSolid = GetMovingSolid(bn); if (!movingSolid || !movingSolid->index) continue; movingSolid->vx = movingSolid->vx/movingSolid->particleCount; movingSolid->vy = movingSolid->vy/movingSolid->particleCount; switch (gravityMode) { case 0: movingSolid->vy = movingSolid->vy + .2f; break; case 1: break; case 2: float pGravD = 0.01f - hypotf((parts[movingSolid->index-1].x - XCNTR), (parts[movingSolid->index-1].y - YCNTR)); movingSolid->vx = movingSolid->vx + .2f * ((parts[movingSolid->index-1].x - XCNTR) / pGravD); movingSolid->vy = movingSolid->vy + .2f * ((parts[movingSolid->index-1].y - YCNTR) / pGravD); break; } movingSolid->rotationOld = movingSolid->rotation; if (!sim->msRotation) { movingSolid->rotationOld = 0; } else if (movingSolid->rotationOld > 2*M_PI) { movingSolid->rotationOld -= 2*M_PI; } else if (movingSolid->rotationOld < -2*M_PI) { movingSolid->rotationOld += 2*M_PI; } } for (int i = 0; i <= globalSim->parts_lastActiveIndex; i++) { if (parts[i].type == PT_MOVS) { MovingSolid *movingSolid = GetMovingSolid(parts[i].tmp2); if (!movingSolid || (parts[i].flags&FLAG_DISAPPEAR)) continue; if (movingSolid->index) { float tmp = parts[i].pavg[0]; float tmp2 = parts[i].pavg[1]; if (sim->msRotation) rotate(&tmp, &tmp2, movingSolid->rotationOld); float nx = parts[movingSolid->index-1].x + tmp; float ny = parts[movingSolid->index-1].y + tmp2; sim->Move(i,(int)(parts[i].x+.5f),(int)(parts[i].y+.5f),nx,ny); if (sim->msRotation) { rotate(&tmp, &tmp2, .02f); if (parts[movingSolid->index-1].x + tmp != nx || parts[movingSolid->index-1].y + tmp2 != ny) { int j = globalSim->part_create(-1, (int)(parts[movingSolid->index-1].x + tmp), (int)(parts[movingSolid->index-1].y + tmp2), parts[i].type); if (j >= 0) { parts[j].flags |= FLAG_DISAPPEAR; parts[j].tmp2 = parts[i].tmp2; parts[j].dcolour = parts[i].dcolour; } } } parts[i].vx = movingSolid->vx; parts[i].vy = movingSolid->vy; } if (sim->OutOfBounds((int)(parts[i].x+.5f), (int)(parts[i].y+.5f)))//kill_part if particle is out of bounds kill_part(i); } } for (int bn = 0; bn < numBalls; bn++) { MovingSolid *movingSolid = GetMovingSolid(bn); movingSolid->vx = 0; movingSolid->vy = 0; } } }; #endif #endif
/* =========================================================================== Copyright (C) 1999-2010 id Software LLC, a ZeniMax Media company. This file is part of Spearmint Source Code. Spearmint Source Code is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. Spearmint Source Code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Spearmint Source Code. If not, see <http://www.gnu.org/licenses/>. In addition, Spearmint Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License. If not, please request a copy in writing from id Software at the address below. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. =========================================================================== */ // /***************************************************************************** * name: ai_goal.h * * desc: goal AI * * $Archive: /source/code/game/ai_goal.h $ * *****************************************************************************/ #define MAX_AVOIDGOALS 256 #define MAX_GOALSTACK 8 #define GFL_NONE 0 #define GFL_ITEM 1 #define GFL_ROAM 2 #define GFL_DROPPED 4 //a bot goal typedef struct bot_goal_s { vec3_t origin; //origin of the goal int areanum; //area number of the goal vec3_t mins, maxs; //mins and maxs of the goal int entitynum; //number of the goal entity int number; //goal number int flags; //goal flags int iteminfo; //item information } bot_goal_t; //goal state typedef struct bot_goalstate_s { struct weightconfig_s *itemweightconfig; //weight config int itemweightindex[MAX_ITEMS]; //index from item to weight // int playernum; //player using this goal state int lastreachabilityarea; //last area with reachabilities the bot was in // bot_goal_t goalstack[MAX_GOALSTACK]; //goal stack int goalstacktop; //the top of the goal stack // int avoidgoals[MAX_AVOIDGOALS]; //goals to avoid float avoidgoaltimes[MAX_AVOIDGOALS]; //times to avoid the goals } bot_goalstate_t; //reset the whole goal state, but keep the item weights void BotResetGoalState(int goalstate); //reset avoid goals void BotResetAvoidGoals(int goalstate); //remove the goal with the given number from the avoid goals void BotRemoveFromAvoidGoals(int goalstate, int number); //push a goal onto the goal stack void BotPushGoal(int goalstate, bot_goal_t *goal); //pop a goal from the goal stack void BotPopGoal(int goalstate); //empty the bot's goal stack void BotEmptyGoalStack(int goalstate); //dump the avoid goals void BotDumpAvoidGoals(int goalstate); //dump the goal stack void BotDumpGoalStack(int goalstate); //get the name name of the goal with the given number void BotGoalName(int number, char *name, int size); //get the top goal from the stack int BotGetTopGoal(int goalstate, bot_goal_t *goal); //get the second goal on the stack int BotGetSecondGoal(int goalstate, bot_goal_t *goal); //choose the best long term goal item for the bot int BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelflags); //choose the best nearby goal item for the bot //the item may not be further away from the current bot position than maxtime //also the travel time from the nearby goal towards the long term goal may not //be larger than the travel time towards the long term goal from the current bot position int BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelflags, bot_goal_t *ltg, float maxtime); //returns true if the bot touches the goal int BotTouchingGoal(vec3_t origin, bot_goal_t *goal); //returns true if the goal should be visible but isn't int BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, bot_goal_t *goal); //search for a goal for the given classname, the index can be used //as a start point for the search when multiple goals are available with that same classname int BotGetLevelItemGoal(int index, char *classname, bot_goal_t *goal); //get the next camp spot in the map int BotGetNextCampSpotGoal(int num, bot_goal_t *goal); //get the map location with the given name int BotGetMapLocationGoal(char *name, bot_goal_t *goal); //returns the avoid goal time float BotAvoidGoalTime(int goalstate, int number); //set the avoid goal time void BotSetAvoidGoalTime(int goalstate, int number, float avoidtime); //initializes the items in the level void BotInitLevelItems(void); //regularly update dynamic entity items (dropped weapons, flags etc.) void BotUpdateEntityItems(void); //interbreed the goal fuzzy logic void BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child); //save the goal fuzzy logic to disk void BotSaveGoalFuzzyLogic(int goalstate, char *filename); //mutate the goal fuzzy logic void BotMutateGoalFuzzyLogic(int goalstate, float range); //loads item weights for the bot int BotLoadItemWeights(int goalstate, char *filename); //frees the item weights of the bot void BotFreeItemWeights(int goalstate); //returns the handle of a newly allocated goal state int BotAllocGoalState(int player); //free the given goal state void BotFreeGoalState(int handle); //setup the goal AI int BotSetupGoalAI(void); //shut down the goal AI void BotShutdownGoalAI(void);
#ifndef STORAGE_H #define STORAGE_H #include <QThread> #include <QMutex> struct point; template <typename T> class QVector; class storage : public QThread { Q_OBJECT public: storage(QObject *parent = 0); const QVector<point>* data() const; double glowDuration() const; protected: void run(); QVector<point>* p_data; void timerEvent(QTimerEvent *); private: QMutex mutex; double p_glowDuration; unsigned short timerinterval; int timerId; public slots: void addPoint(unsigned short position); void beginAddingPoints(); void endAddingPoints(); void setGlowDuration(double duration); void setTimerInterval(int ti); signals: void dataChanged(); }; #endif // STORAGE_H
/* * Copyright 2012 Philippe Latulippe * https://github.com/philippelatulippe/rdbreader Project Faolan a Simple and Free Server Emulator for Age of Conan. Copyright (C) 2009, 2010, 2011, 2012 The Project Faolan Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ enum TYPES { SCRIPTGROUP = 0, ANIMSYS = 1010200, STATICAIPOINTS = 1000046, BOUNDEDAREAS = 1000053, PATROLS = 1000067, STATICAIPOINSEXPORT = 1000068, CLIMBINGAREASEXPORT = 1000070, RIVERS = 1000075, CONTENTSPAWNDATAEXPORT = 1000077, ACGSPAWNDATAEXPORT = 1000078, NPCSPAWNDATAEXPORT = 1000079, TREASUREDATAEXPORT = 1000083, SCRYSCRIPTDATAEXPORT = 1000084, SCRYSCRIPTDATAEXPORT2 = 1000085, DESTRUCTIBLECLIENTDATAEXPORT = 1000088, RESURRECTIONPOINTSEXPORT = 1000090, SIMPLEDYNELDATAEXPORT = 1000091, NOTEPADDATAEXPORT = 1000093, CLIMBINGDYNELDATAEXPORT = 1000095, OCEANVOLUMESROOTNODEEXPORT = 1000097, VOLUMETRICFOGSROOTNODEEXPORT = 1000098, PATHFINDINGAREASROOTNODEEXPORT = 1000100, DOORDYNELDATAEXPORT = 1000101, STATICAIPOINTS2 = 1000103, PNG = 1010008, COLLECTIONLIBRARY = 1010014, SCRIPTGROUP2 = 1010028, SCRIPTGROUP3 = 1010029, TEXTSCRIPT = 1010035, PNG2 = 1066603, //The secret world PHYSX30COLLECTION = 1000007, DECALPROJECTORS = 1000519, EFFECTPACKAGE = 1000622, SOUNDENGINE = 1000623, MPEG = 1000635, FCTX1 = 1010004, FCTX2 = 1010006, FCTX3 = 1010218, FCTX4 = 1066606, FCTX5 = 1066610, JPEG = 1010013, MESHINDEXFILE = 1010030, TIFF = 1010042, //The TIFF I checked had an invalid version number?! Is it not always 42? MONSTERDATA = 1010201, BCTGROUP = 1010202, BCTMESH = 1010203, MOVEMENTSET = 1010205, PNG3 = 1000636, PNG4 = 1010210, PNG5 = 1010211, PNG6 = 1010213, CARS = 1010216, LUAARCHIVE = 1010223, ROOMANDPORTALSYSTEM = 1010300, FORMATION = 1010400, CHARACTERCREATOR = 1010700, OGG1 = 1020002, LIP = 1020003, OGG3 = 1020005, BOUNDEDAREACOLLECTIONS = 1040010, ENVIRONMENTSETTINGS = 1060667, SKYDOME = 1060668, PLAYFIELDDESCRIPTIONDATA = 1070003 }; struct TypId { uint32 idx; uint32 type; uint32 unk0; uint32 offset; uint32 size; uint32 unk3; uint32 unk4; uint32 unk5; uint32 unk6; uint32 unk7; uint32 unk8; uint32 unk9; uint32 unk10; }; struct Header { string magic; uint32 version; uint32 hash1; uint32 hash2; uint32 hash3; uint32 hash4; uint32 recordCount; };
#ifndef SETUP_WLD_SCENE_H #define SETUP_WLD_SCENE_H #include <vector> #include <graphics/gl_color.h> class IniProcessing; struct WorldAdditionalImage { std::string imgFile; bool animated; int frames; int framedelay; int x; int y; }; struct WorldMapSetup { void init(IniProcessing &engine_ini); void initFonts(); std::string backgroundImg; int viewport_x; //World map view port int viewport_y; int viewport_w; int viewport_h; enum titleAlign { align_left=0, align_center, align_right }; int title_x; //Title of level int title_y; int title_w; //max width of title std::string title_color; GlColor title_rgba; titleAlign title_align; std::string title_font_name; int title_fontID; bool points_en; int points_x; int points_y; std::string points_font_name; int points_fontID; std::string points_color; GlColor points_rgba; bool health_en; int health_x; int health_y; std::string health_font_name; int health_fontID; std::string health_color; GlColor health_rgba; bool lives_en; int lives_x; int lives_y; std::string lives_font_name; int lives_fontID; std::string lives_color; GlColor lives_rgba; bool star_en; int star_x; int star_y; std::string star_font_name; int star_fontID; std::string star_color; GlColor star_rgba; bool coin_en; int coin_x; int coin_y; std::string coin_font_name; int coin_fontID; std::string coin_color; GlColor coin_rgba; bool portrait_en; int portrait_x; int portrait_y; int portrait_frame_delay; std::string portrait_animation; int portrait_direction; std::vector<WorldAdditionalImage > AdditionalImages; std::string luaFile; }; #endif // SETUP_WLD_SCENE_H
using namespace std; struct _Course{ string CourseCode; int Point; int Score; _Course(string CourseCode){ this->CourseCode = CourseCode; this->Score = 0; this->Point = 0; } void setCourse(string CourseCode, int Score, int Point){ this->CourseCode = CourseCode; this->Score = Score; this->Point = Point; } string getCode(){ return this->CourseCode; } int getPoint(){ return this->Point; } int getScore(){ return this->Score; } }; struct Student{ bool ActFlag; string StudentID; string StudentName; int TotCoursePoints; int TotCredits; double Average; list<_Course> Course; Student(){ this->ActFlag = true; this->StudentID = "D9999999"; this->StudentName = "xxxxxxxxxxxxxxxxxxxx"; this->TotCoursePoints = 0; this->TotCredits = 0; this->Average = 0.00; } void setIDandName(string ID, string Name){ this->StudentID = ID; this->StudentName = Name; this->ActFlag = true; } bool getActFlag(){ return this->ActFlag; } string getUID(){ return this->StudentID; } string getName(){ return this->StudentName; } int getTotCoursePoints(){ return this->TotCoursePoints; } int getTotCredits(){ return this->TotCredits; } double getAverage(){ return this->Average; } void setAvgData(int TotCoursePoints, int TotCredits){ this->TotCoursePoints = TotCoursePoints; this->TotCredits = TotCredits; if(TotCredits==0) this->Average = 0; else this->Average = (double)TotCoursePoints / (double)TotCredits; } void suspend(){ this->ActFlag = false; this->TotCoursePoints = 0; this->TotCredits = 0; this->Average = 0.0; this->Course.clear(); } };
/* Copyright 2010-2015 Tarik Sekmen. All Rights Reserved. Written by Tarik Sekmen <tarik@ilixi.org>. This file is part of ilixi. ilixi is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. ilixi 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 ilixi. If not, see <http://www.gnu.org/licenses/>. */ #ifndef ILIXI_CONTAINERBASE_H_ #define ILIXI_CONTAINERBASE_H_ #include <ui/LayoutBase.h> namespace ilixi { //! An abstract base class for widgets which store and maintain various child widgets. /*! * Containers are used to store widgets and align them using a Layout. */ class ContainerBase : public Widget { friend class Application; friend class Dialog; public: /*! * Constructor. * * @param parent Pointer to parent widget. */ ContainerBase(Widget* parent = 0); /*! * Destructor. */ virtual ~ContainerBase(); /*! * Returns a height for container if its contents are fit inside width. * * @param width Desired width of container. */ virtual int heightForWidth(int width) const; /*! * Calculates the preferred size of contents and returns an updated size using canvas and margins. */ virtual Size preferredSize() const; /*! * Returns the bounding rectangle around visible children. */ Rectangle childrenRect() const; /*! * Returns spacing between widgets used by layout. */ unsigned int spacing() const; /*! * Adds a new child widget to container. This method will automatically * add the widget to container's underlying layout. Setting a new layout for this container * will destroy widget's inside its old layout. * * @param widget Pointer to child widget. * * \sa Layout::addWidget() */ bool addWidget(Widget* widget); /*! * Removes a child widget from container. * * \sa addWidget() */ bool removeWidget(Widget* widget); /*! * Returns container's layout. */ LayoutBase* layout(); /*! * Sets a new layout and destroys old one. * * Warning: Widgets added to previous layout will be destroyed implicitly. * * @param layout */ virtual void setLayout(LayoutBase* layout); /*! * Sets spacing used by layout. * This property has no effect over default layout. * * @param spacing */ void setSpacing(unsigned int spacing); virtual void doLayout(); protected: //! This is the container's current layout. LayoutBase* _layout; /*! * This method sets container's layout geometry. Layout is positioned at 0,0 and its width and height are * set to width and height of container respectively. * * If your implementation needs specific position or dimension for layout, you should reimplement this method. */ virtual void updateLayoutGeometry(); /*! * Redirects the incoming pointer events to layout. */ virtual bool consumePointerEvent(const PointerEvent& pointerEvent); }; } #endif /* ILIXI_CONTAINERBASE_H_ */
/*-----------------------------------------------------------------------*/ /* Low level disk I/O module skeleton for Petit FatFs (C)ChaN, 2010 */ /*-----------------------------------------------------------------------*/ #include "diskio.h" #include <string.h> #include <LUFA/Drivers/USB/Class/MassStorage.h> #include "../DataflashManager.h" #include "../../DiskHost.h" /*-----------------------------------------------------------------------*/ /* Initialize Disk Drive */ /*-----------------------------------------------------------------------*/ DSTATUS disk_initialize (void) { return RES_OK; } /*-----------------------------------------------------------------------*/ /* Read Partial Sector */ /*-----------------------------------------------------------------------*/ DRESULT disk_readp ( void* dest, /* Pointer to the destination object */ DWORD sector, /* Sector number (LBA) */ WORD sofs, /* Offset in the sector */ WORD count /* Byte count (bit15:destination) */ ) { DRESULT ErrorCode = RES_OK; uint8_t BlockTemp[512]; if (USB_CurrentMode == USB_MODE_HOST) { #if defined(USB_CAN_BE_HOST) if (USB_HostState != HOST_STATE_Configured) ErrorCode = RES_NOTRDY; else if (MS_Host_ReadDeviceBlocks(&DiskHost_MS_Interface, 0, sector, 1, 512, BlockTemp)) ErrorCode = RES_ERROR; #endif } else { #if defined(USB_CAN_BE_DEVICE) DataflashManager_ReadBlocks_RAM(sector, 1, BlockTemp); #endif } memcpy(dest, &BlockTemp[sofs], count); return ErrorCode; }
/* Buff to buff example - Test program for the lzlib library Copyright (C) 2010, 2011, 2012, 2013 Antonio Diaz Diaz. This program is free software: you have unlimited permission to copy, distribute and modify it. Usage is: bbexample filename This program is an example of how buffer-to-buffer compression/decompression can be implemented using lzlib. */ #ifndef __cplusplus #include <stdbool.h> #endif #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include "lzlib.h" /* Compresses 'size' bytes from 'data'. Returns the address of a malloc'd buffer containing the compressed data and its size in '*out_sizep'. In case of error, returns 0 and does not modify '*out_sizep'. */ uint8_t * bbcompress( const uint8_t * const data, const int size, int * const out_sizep ) { struct LZ_Encoder * encoder; uint8_t * new_data; const int match_len_limit = 36; const unsigned long long member_size = INT64_MAX; int delta_size, new_data_size; int new_pos = 0; int written = 0; bool error = false; int dict_size = 8 << 20; /* 8 MiB */ if( dict_size > size ) dict_size = size; /* saves memory */ if( dict_size < LZ_min_dictionary_size() ) dict_size = LZ_min_dictionary_size(); encoder = LZ_compress_open( dict_size, match_len_limit, member_size ); if( !encoder || LZ_compress_errno( encoder ) != LZ_ok ) { LZ_compress_close( encoder ); return 0; } delta_size = (size < 256) ? 64 : size / 4; /* size may be zero */ new_data_size = delta_size; /* initial size */ new_data = (uint8_t *)malloc( new_data_size ); if( !new_data ) { LZ_compress_close( encoder ); return 0; } while( true ) { int rd; if( LZ_compress_write_size( encoder ) > 0 ) { if( written < size ) { const int wr = LZ_compress_write( encoder, data + written, size - written ); if( wr < 0 ) { error = true; break; } written += wr; } if( written >= size ) LZ_compress_finish( encoder ); } rd = LZ_compress_read( encoder, new_data + new_pos, new_data_size - new_pos ); if( rd < 0 ) { error = true; break; } new_pos += rd; if( LZ_compress_finished( encoder ) == 1 ) break; if( new_pos >= new_data_size ) { uint8_t * const tmp = (uint8_t *)realloc( new_data, new_data_size + delta_size ); if( !tmp ) { error = true; break; } new_data = tmp; new_data_size += delta_size; } } if( LZ_compress_close( encoder ) < 0 ) error = true; if( error ) { free( new_data ); return 0; } *out_sizep = new_pos; return new_data; } /* Decompresses 'size' bytes from 'data'. Returns the address of a malloc'd buffer containing the decompressed data and its size in '*out_sizep'. In case of error, returns 0 and does not modify '*out_sizep'. */ uint8_t * bbdecompress( const uint8_t * const data, const int size, int * const out_sizep ) { struct LZ_Decoder * const decoder = LZ_decompress_open(); uint8_t * new_data; const int delta_size = size; /* size must be > zero */ int new_data_size = delta_size; /* initial size */ int new_pos = 0; int written = 0; bool error = false; if( !decoder || LZ_decompress_errno( decoder ) != LZ_ok ) { LZ_decompress_close( decoder ); return 0; } new_data = (uint8_t *)malloc( new_data_size ); if( !new_data ) { LZ_decompress_close( decoder ); return 0; } while( true ) { int rd; if( LZ_decompress_write_size( decoder ) > 0 ) { if( written < size ) { const int wr = LZ_decompress_write( decoder, data + written, size - written ); if( wr < 0 ) { error = true; break; } written += wr; } if( written >= size ) LZ_decompress_finish( decoder ); } rd = LZ_decompress_read( decoder, new_data + new_pos, new_data_size - new_pos ); if( rd < 0 ) { error = true; break; } new_pos += rd; if( LZ_decompress_finished( decoder ) == 1 ) break; if( new_pos >= new_data_size ) { uint8_t * const tmp = (uint8_t *)realloc( new_data, new_data_size + delta_size ); if( !tmp ) { error = true; break; } new_data = tmp; new_data_size += delta_size; } } if( LZ_decompress_close( decoder ) < 0 ) error = true; if( error ) { free( new_data ); return 0; } *out_sizep = new_pos; return new_data; } int main( const int argc, const char * const argv[] ) { FILE * file; uint8_t * in_buffer, * mid_buffer, * out_buffer; const int in_buffer_size = 1 << 20; int in_size, mid_size = 0, out_size = 0; if( argc < 2 ) { fprintf( stderr, "Usage: bbexample filename\n" ); return 1; } file = fopen( argv[1], "rb" ); if( !file ) { fprintf( stderr, "bbexample: Can't open file '%s' for reading\n", argv[1] ); return 1; } in_buffer = (uint8_t *)malloc( in_buffer_size ); if( !in_buffer ) { fprintf( stderr, "bbexample: Not enough memory.\n" ); return 1; } in_size = fread( in_buffer, 1, in_buffer_size, file ); if( in_size >= in_buffer_size ) { fprintf( stderr, "bbexample: Input file '%s' is too big.\n", argv[1] ); return 1; } fclose( file ); mid_buffer = bbcompress( in_buffer, in_size, &mid_size ); if( !mid_buffer ) { fprintf( stderr, "bbexample: Not enough memory or compress error.\n" ); return 1; } out_buffer = bbdecompress( mid_buffer, mid_size, &out_size ); if( !out_buffer ) { fprintf( stderr, "bbexample: Not enough memory or decompress error.\n" ); return 1; } if( in_size != out_size || ( in_size > 0 && memcmp( in_buffer, out_buffer, in_size ) != 0 ) ) { fprintf( stderr, "bbexample: Decompressed data differs from original.\n" ); return 1; } free( out_buffer ); free( mid_buffer ); free( in_buffer ); return 0; }
/* Copyright &copy; 2018, Stefan Sicklinger, Munich * * All rights reserved. * * This file is part of STACCATO. * * STACCATO 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. * * STACCATO 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 STACCATO. If not, see http://www.gnu.org/licenses/. */ /************************************************************************************************* * \file VtkAnimator.h * This file holds the class VtkAnimator * \date 2/19/2018 **************************************************************************************************/ #pragma once #include "FieldDataVisualizer.h" #include "HMesh.h" #include "HMeshToVtkUnstructuredGrid.h" #include <STACCATO_Enum.h> #include <vtkSmartPointer.h> #include <vtkAnimationScene.h> #include <vtkUnstructuredGrid.h> class vtkActor; class vtkDataSetMapper; class vtkWarpVector; class vtkLookupTable; class AnimationCueObserver; class vtkAnimationCue; class CueAnimator; /************************************************************************************************* * \brief Class VtkAnimator **************************************************************************************************/ class VtkAnimator { public: /*********************************************************************************************** * \brief Constructor * \author Harikrishnan Sreekumar ***********/ VtkAnimator(FieldDataVisualizer& _fieldDataVisualizer); /*********************************************************************************************** * \brief Destructor * \author Harikrishnan Sreekumar ***********/ ~VtkAnimator(); /*********************************************************************************************** * \brief Buffer Animation Frames * \param[in] _type Result Type, for which the frames are buffered into memory * \author Harikrishnan Sreekumar ***********/ void bufferAnimationFrames(STACCATO_VectorField_components _type, std::vector<int> &_frameID, bool _isHarmonic); /*********************************************************************************************** * \brief Plot Vector Field for an Index * \param[in] _index Index of Frame * \author Harikrishnan Sreekumar ***********/ void plotVectorFieldAtIndex(int _index); /*********************************************************************************************** * \brief Play/Resume the Animation Scene * \param[in] _duration Duration of Scene * \param[in] _loops Enable (1)/Disable (0) Loop * \author Harikrishnan Sreekumar ***********/ void playAnimationScene(int _duration, int _loops); /*********************************************************************************************** * \brief Instantiate the First Animation Scene * \param[in] _duration Duration of Scene * \param[in] _loops Enable (1)/Disable (0) Loop * \author Harikrishnan Sreekumar ***********/ void instantiateAnimationScene(int _duration, int _loops); /*********************************************************************************************** * \brief Stop Animation Scene * \author Harikrishnan Sreekumar ***********/ void stopAnimationScene(); /*********************************************************************************************** * \brief Clear Animation Scene * \author Harikrishnan Sreekumar ***********/ void clearAnimationScene(); /*********************************************************************************************** * \brief Animation Scene Status of Playing or Stopped * \author Harikrishnan Sreekumar ***********/ bool isAnimationScenePlaying(); private: // Handle to Field Visualizer FieldDataVisualizer* myFieldDataVisualizer; // Animation Members vtkSmartPointer<vtkAnimationScene> myAnimationScene; vtkSmartPointer<vtkAnimationCue> myAnimationCue; vtkSmartPointer<AnimationCueObserver> myAnimationCueObserver; CueAnimator* myCueAnimator; // Array vtkSmartPointer<vtkActor> *myArrayActor; vtkSmartPointer<vtkActor> *myArrayEdgeActor; vtkSmartPointer<vtkDataSetMapper> *myArrayMapper; vtkSmartPointer<vtkWarpVector>* warpFilterArray; vtkSmartPointer<vtkLookupTable>* hueLutArray; public: std::vector<int> myFrameID; };
#ifndef LEDSET_H #define LEDSET_H #include <QHash> #include "constants.h" #include "LedSetIterator.h" #include "Led.h" namespace AnimatorModel { class Animation; class LedSet : public QObject { Q_OBJECT public : explicit LedSet(QObject *parent); void addLed(Led& led); void removeLed(Led& led); void clearPositions(); inline void clear() { iLeds.clear(); } void clearAll(); Led* findLed(Position position) const; Led* findLed(int ledNumber) const; void moveLed(Led &led, Position fromPosition, Position toPosition); void setPositions(QList<int> positions); Position ledPosition (int ledNumber) const; inline bool ledsMissing() const { return iFreeNumbers.count() != 0; } inline bool isMissing(int ledNumber) const { return iFreeNumbers.contains(ledNumber); } inline const QList<int> missingLedNumbers() const { return iFreeNumbers; } void clearMissing(); void addMissing(int ledNumber); inline void setHighestNumber(int highestNumber) { iHighestNumber = highestNumber; } inline int highestNumber() const { return iHighestNumber; } inline int count() const { return iLeds.count(); } LedSetIterator& iterator(); inline void setNumRows(int numRows) { iNumRows = numRows; } inline void setNumColumns(int numColumns) { iNumColumns = numColumns; } private: LedSet(const LedSet &set); int positionNumber(Position position) const; void setPositionNumber(Position position, int number); LedSetIterator* iIterator; int iHighestNumber; QList<int> iFreeNumbers; QList<int> iPositions; QHash<int, Led*> iLeds; int iNumRows; int iNumColumns; friend class LedSetIterator; }; } #endif // LEDSET_H
// -*-c++-*- #ifndef _TSYSERROR_H_ #define _TSYSERROR_H_ #include <TNamed.h> #include <Rtypes.h> class TList; class TGraphErrors; class TSysError : public TNamed { public: enum EType { kNone = 0, kMean, kMinStdDev, kRelativeErrorMCSum, kAbsoluteDevFromRef, kMaxValueFromBin, kMaxValueFromBinPercent, kStdDevValueFromBinPercent,kStdErrValueFromBinPercent, kMaxStdDevValueFromBinPercent, kNumTypes }; TSysError(); TSysError(const char *name, const char *title); ~TSysError(); void Browse(TBrowser *b); Bool_t IsFolder() const { return kTRUE; } void SetGraph(TGraphErrors *gr, Bool_t doClone = kFALSE); void SetHistogram(TH1D *h); void SetType(TSysError::EType type) { fType = type; } void SetTypeToList(TSysError::EType type); void SetPrintInfo(Bool_t printInfo) { fPrintInfo = printInfo; } TList *GetList() const { return fList; } TList *GetInputList() const { return fInputList; } TList *GetOutputList() const { return fOutputList; } TGraphErrors *GetGraph() const { return fGraph; } TH1D *GetHistogram() const { return fHist; } EType GetType() const { return fType; } void PrintHistogramInfo(TSysError *se, TH1D *h = 0); void Add(TSysError *sysError); Bool_t AddGraph(const char *filename, const char *tmpl = "%lg %lg %lg"); Bool_t AddGraphDirectory(const char *dirname, const char *filter = "*.txt", const char *tmpl = "%lg %lg %lg", Int_t maxFiles=kMaxInt); void AddInput(TObject *o); void AddOutput(TObject *o); Bool_t Calculate(); Bool_t CalculateMean(); Bool_t CalculateMinStdDev(); Bool_t CalculateAbsoluteDevFromRef(); Bool_t CalculateRelaticeErrorMCSum(); Bool_t CalculateMaxValueFromBin(); Bool_t CalculateMaxStdDevValueFromBinPercent(); Bool_t CalculateMaxValueFromBinPercent(); Bool_t CalculateStdDevValueFromBinPercent(Bool_t useStdErr=kFALSE); private: TList *fList; // list of TSysError TGraphErrors *fGraph; // current graph TH1D *fHist; // current histogram (representation of fGraph) TList *fInputList; // list of TSysError TList *fOutputList; // list of TSysError EType fType; // type of calculation Bool_t fPrintInfo; // flag if info should be printed (default is kFALSE) ClassDef(TSysError, 1) }; #endif /* _TSYSERROR_H_ */
#ifndef _DEV_SETUP_H_ #define _DEV_SETUP_H_ #include<stdlib.h> #include<stdio.h> #include<unistd.h> #include<sys/wait.h> #define exe_length 10 #define ip_route "10.0.0.0/24" int run_ip_set(char *arg[]); int set_up_dev(char *dev); #endif /*_DEV_SETUP_H_*/
/* * This file is part of Cleanflight. * * Cleanflight 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. * * Cleanflight 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 Cleanflight. If not, see <http://www.gnu.org/licenses/>. */ #include <stdbool.h> #include <stdint.h> #include <platform.h> #include "drivers/system.h" #include "drivers/bus_i2c.h" #include "drivers/sensor.h" #include "drivers/accgyro/accgyro.h" #include "drivers/accgyro/accgyro_adxl345.h" // ADXL345, Alternative address mode 0x53 #define ADXL345_ADDRESS 0x53 // Registers #define ADXL345_BW_RATE 0x2C #define ADXL345_POWER_CTL 0x2D #define ADXL345_INT_ENABLE 0x2E #define ADXL345_DATA_FORMAT 0x31 #define ADXL345_DATA_OUT 0x32 #define ADXL345_FIFO_CTL 0x38 // BW_RATE values #define ADXL345_RATE_50 0x09 #define ADXL345_RATE_100 0x0A #define ADXL345_RATE_200 0x0B #define ADXL345_RATE_400 0x0C #define ADXL345_RATE_800 0x0D #define ADXL345_RATE_1600 0x0E #define ADXL345_RATE_3200 0x0F // various register values #define ADXL345_POWER_MEAS 0x08 #define ADXL345_FULL_RANGE 0x08 #define ADXL345_RANGE_2G 0x00 #define ADXL345_RANGE_4G 0x01 #define ADXL345_RANGE_8G 0x02 #define ADXL345_RANGE_16G 0x03 #define ADXL345_FIFO_STREAM 0x80 static bool useFifo = false; static void adxl345Init(accDev_t *acc) { if (useFifo) { uint8_t fifoDepth = 16; i2cWrite(MPU_I2C_INSTANCE, ADXL345_ADDRESS, ADXL345_POWER_CTL, ADXL345_POWER_MEAS); i2cWrite(MPU_I2C_INSTANCE, ADXL345_ADDRESS, ADXL345_DATA_FORMAT, ADXL345_FULL_RANGE | ADXL345_RANGE_8G); i2cWrite(MPU_I2C_INSTANCE, ADXL345_ADDRESS, ADXL345_BW_RATE, ADXL345_RATE_400); i2cWrite(MPU_I2C_INSTANCE, ADXL345_ADDRESS, ADXL345_FIFO_CTL, (fifoDepth & 0x1F) | ADXL345_FIFO_STREAM); } else { i2cWrite(MPU_I2C_INSTANCE, ADXL345_ADDRESS, ADXL345_POWER_CTL, ADXL345_POWER_MEAS); i2cWrite(MPU_I2C_INSTANCE, ADXL345_ADDRESS, ADXL345_DATA_FORMAT, ADXL345_FULL_RANGE | ADXL345_RANGE_8G); i2cWrite(MPU_I2C_INSTANCE, ADXL345_ADDRESS, ADXL345_BW_RATE, ADXL345_RATE_100); } acc->acc_1G = 256; // 3.3V operation } uint8_t acc_samples = 0; static bool adxl345Read(accDev_t *acc) { uint8_t buf[8]; if (useFifo) { int32_t x = 0; int32_t y = 0; int32_t z = 0; uint8_t i = 0; uint8_t samples_remaining; do { i++; if (!i2cRead(MPU_I2C_INSTANCE, ADXL345_ADDRESS, ADXL345_DATA_OUT, 8, buf)) { return false; } x += (int16_t)(buf[0] + (buf[1] << 8)); y += (int16_t)(buf[2] + (buf[3] << 8)); z += (int16_t)(buf[4] + (buf[5] << 8)); samples_remaining = buf[7] & 0x7F; } while ((i < 32) && (samples_remaining > 0)); acc->ADCRaw[0] = x / i; acc->ADCRaw[1] = y / i; acc->ADCRaw[2] = z / i; acc_samples = i; } else { if (!i2cRead(MPU_I2C_INSTANCE, ADXL345_ADDRESS, ADXL345_DATA_OUT, 6, buf)) { return false; } acc->ADCRaw[0] = buf[0] + (buf[1] << 8); acc->ADCRaw[1] = buf[2] + (buf[3] << 8); acc->ADCRaw[2] = buf[4] + (buf[5] << 8); } return true; } bool adxl345Detect(accDev_t *acc, drv_adxl345_config_t *init) { bool ack = false; uint8_t sig = 0; ack = i2cRead(MPU_I2C_INSTANCE, ADXL345_ADDRESS, 0x00, 1, &sig); if (!ack || sig != 0xE5) return false; // use ADXL345's fifo to filter data or not useFifo = init->useFifo; acc->init = adxl345Init; acc->read = adxl345Read; return true; }
/* * VS_RendererPretty.h * VectorStorm * * Created by Trevor Powell on 17/03/07. * Copyright 2007 PanicKitten Softworks. All rights reserved. * */ #include "VS_RendererSimple.h" class vsRendererPretty : public vsRendererSimple { typedef vsRendererSimple Parent; unsigned int m_offscreenTexture; public: vsRendererPretty(); virtual ~vsRendererPretty(); virtual void PreRender(); virtual void RenderDisplayList( vsDisplayList *list ); virtual void PostRender(); };
/* RPG Paper Maker Copyright (C) 2017-2021 Wano RPG Paper Maker engine is under proprietary license. This source code is also copyrighted. Use Commercial edition for commercial use of your games. See RPG Paper Maker EULA here: http://rpg-paper-maker.com/index.php/eula. */ #ifndef PROJECTUPDATER_H #define PROJECTUPDATER_H #include "project.h" // ------------------------------------------------------- // // CLASS ProjectUpdater // // Module used for detecting if a project needs to be updated according to // the engine version. // // ------------------------------------------------------- class ProjectUpdater : public QObject { Q_OBJECT public: ProjectUpdater(Project* project, QString previous); virtual ~ProjectUpdater(); static const int incompatibleVersionsCount; static QString incompatibleVersions[]; void clearListMapPaths(); void clearListMapPortions(); void copyPreviousProject(); void getAllPathsMapsPortions(); void updateVersion(QString& version); void copyExecutable(); void copySystemScripts(); void updateCommands(); protected: Project* m_project; QString m_previousFolderName; QList<QString> m_listMapPaths; QList<QJsonObject> m_listMapProperties; QList<QString> m_listMapPropertiesPaths; QList<QList<QJsonObject>*> m_listMapPortions; QList<QList<QString>*> m_listMapPortionsPaths; public slots: void check(); void updateVersion_0_3_1(); void updateVersion_0_4_0(); void updateVersion_0_4_3(); void updateVersion_0_5_2(); void updateVersion_1_0_0(); void updateVersion_1_1_1(); void updateVersion_1_2_0(); void updateVersion_1_2_1(); void updateVersion_1_3_0(); void updateVersion_1_3_0_commands(QStandardItem *commands); void updateVersion_1_4_0(); void updateVersion_1_4_0_commands(QStandardItem *commands); void updateVersion_1_4_1(); void updateVersion_1_4_1_commands(QStandardItem *commands); void updateVersion_1_5_0(); void updateVersion_1_5_3(); void updateVersion_1_5_6(); void updateVersion_1_5_6_commands(QStandardItem *commands); void updateVersion_1_6_0(); void updateVersion_1_6_2(); void updateVersion_1_6_3(); void updateVersion_1_6_3_commands(QStandardItem *commands); void updateVersion_1_6_4(); void updateVersion_1_7_0(); void updateVersion_1_7_0_commands(QStandardItem *commands); void updateVersion_1_7_0_json(QString path, QString listName); void updateVersion_1_7_3(); void updateVersion_1_7_3_commands(QStandardItem *commands); signals: void progress(int, QString); void finished(); void updatingCommands(QStandardItem *commands); }; #endif // PROJECTUPDATER_H
// Copyright (C) 2013 Simon Que // // This file is part of DuinoCube. // // DuinoCube is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // DuinoCube 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 DuinoCube. If not, see <http://www.gnu.org/licenses/>. // Contains sprite definitions. #ifndef __SPRITES_H__ #define __SPRITES_H__ #include <stdint.h> // Sprite data structure definition. struct Sprite { uint8_t state; // Alive or dead. uint8_t dir; // Direction sprite is facing. int16_t x, y; // Location in pixels. uint16_t base_offset; // Base VRAM offset of sprite's frame images. uint16_t size; // Size of each sprite frame image in bytes. uint8_t frame; // Current frame image. uint16_t flip; // Current frame flip flags. uint16_t counter; // Animation counter. Sprite() : frame(0), flip(0), counter(0) {} // Compute the sprite's current VRAM offset. inline uint16_t get_offset() const { return base_offset + frame * size; } }; // Move and animate sprite. void updateSprite(Sprite* sprite_ptr, int speed); #endif // __SPRITES_H__
#include "test.h" #include "schnaps.h" #include<stdio.h> #include <stdlib.h> #include <assert.h> #include <math.h> #include <string.h> int TestDtfield_CL(void); int main(void) { int resu = TestDtfield_CL(); if (resu) printf("Dtfield_CL test OK !\n"); else printf("Dtfield_CL test failed !\n"); return !resu; } int TestDtfield_CL(void){ bool test = true; if(!cldevice_is_acceptable(nplatform_cl, ndevice_cl)) { printf("OpenCL device not acceptable.\n"); return true; } MacroMesh mesh; char *mshname = "../test/disque2d.msh"; //char *mshname = "../test/unit-cube.msh"; ReadMacroMesh(&mesh,"../test/testmacromesh.msh"); //ReadMacroMesh(&mesh,"../test/testcube2.msh"); Detect2DMacroMesh(&mesh); BuildConnectivity(&mesh); Model model; // 2D version assert(mesh.is2d); model.cfl = 0.05; model.m = 1; m = model.m; model.NumFlux = TransNumFlux2d; model.BoundaryFlux = TransBoundaryFlux2d; model.InitData = TransInitData2d; model.ImposedData = TransImposedData2d; int deg[]={2, 2, 0}; int raf[]={4, 4, 1}; Simulation simu; EmptySimulation(&simu); char buf[1000]; sprintf(buf, "-D _M=%d", model.m); strcat(cl_buildoptions, buf); sprintf(buf," -D NUMFLUX=%s", "TransNumFlux2d"); strcat(cl_buildoptions, buf); sprintf(buf, " -D BOUNDARYFLUX=%s", "TransBoundaryFlux2d"); strcat(cl_buildoptions, buf); set_global_m(model.m); model.Source = OneSource; set_source_CL(&simu, "OneSource"); //model.Source = NULL; assert(simu.use_source_cl); InitSimulation(&simu, &mesh, deg, raf, &model); cl_int status; cl_event clv_dtfield = clCreateUserEvent(simu.cli.context, &status); dtfield_CL(&simu, &simu.w_cl, 0, NULL, &clv_dtfield); clWaitForEvents(1, &clv_dtfield); CopyfieldtoCPU(&simu); // Displayfield(&f); show_cl_timing(&simu); schnaps_real *saveptr = simu.dtw; simu.dtw = calloc(simu.wsize, sizeof(schnaps_real)); DtFields_old(&simu, simu.w, simu.dtw); schnaps_real maxerr = 0; for(int i = 0; i < simu.wsize; i++) { schnaps_real error = simu.dtw[i] - saveptr[i]; //printf("error= \t%f\t%f\t%f\n", error, f.dtwn[i], saveptr[i]); maxerr = fmax(fabs(error), maxerr); } printf("max error: %f\n", maxerr); test = (maxerr < _SMALL * 10); return test; }
/* This file is part of Darling. Copyright (C) 2020 Lubos Dolezel Darling is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Darling is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Darling. If not, see <http://www.gnu.org/licenses/>. */ #include <Foundation/Foundation.h> @interface CUPairedPeer : NSObject @end
/* @@@LICENSE * * Copyright (c) 2012 Simon Busch <morphis@gravedo.de> * * 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. * * LICENSE@@@ */ #include "luna_service_utils.h" void luna_service_message_reply_custom_error(LSHandle *handle, LSMessage *message, const char *error_text) { bool ret; LSError lserror; char payload[256]; LSErrorInit(&lserror); snprintf(payload, 256, "{\"returnValue\":false, \"errorText\":\"%s\"}", error_text); ret = LSMessageReply(handle, message, payload, &lserror); if (!ret) { LSErrorPrint(&lserror, stderr); LSErrorFree(&lserror); } } void luna_service_message_reply_error_unknown(LSHandle *handle, LSMessage *message) { luna_service_message_reply_custom_error(handle, message, "Unknown Error."); } void luna_service_message_reply_error_bad_json(LSHandle *handle, LSMessage *message) { luna_service_message_reply_custom_error(handle, message, "Malformed json."); } void luna_service_message_reply_error_invalid_params(LSHandle *handle, LSMessage *message) { luna_service_message_reply_custom_error(handle, message, "Invalid parameters."); } void luna_service_message_reply_error_not_implemented(LSHandle *handle, LSMessage *message) { luna_service_message_reply_custom_error(handle, message, "Not implemented."); } void luna_service_message_reply_error_internal(LSHandle *handle, LSMessage *message) { luna_service_message_reply_custom_error(handle, message, "Internal error."); } void luna_service_message_reply_success(LSHandle *handle, LSMessage *message) { bool ret; LSError lserror; LSErrorInit(&lserror); ret = LSMessageReply(handle, message, "{\"returnValue\":true}", &lserror); if (!ret) { LSErrorPrint(&lserror, stderr); LSErrorFree(&lserror); } } jvalue_ref luna_service_message_parse_and_validate(const char *payload) { jschema_ref input_schema = NULL; jvalue_ref parsed_obj = NULL; JSchemaInfo schema_info; input_schema = jschema_parse(j_cstr_to_buffer("{}"), DOMOPT_NOOPT, NULL); jschema_info_init(&schema_info, input_schema, NULL, NULL); parsed_obj = jdom_parse(j_cstr_to_buffer(payload), DOMOPT_NOOPT, &schema_info); jschema_release(&input_schema); if (jis_null(parsed_obj)) return NULL; return parsed_obj; } bool luna_service_message_validate_and_send(LSHandle *handle, LSMessage *message, jvalue_ref reply_obj) { jschema_ref response_schema = NULL; LSError lserror; bool success = true; LSErrorInit(&lserror); response_schema = jschema_parse (j_cstr_to_buffer("{}"), DOMOPT_NOOPT, NULL); if(!response_schema) { luna_service_message_reply_error_internal(handle, message); return false; } if (!LSMessageReply(handle, message, jvalue_tostring(reply_obj, response_schema), &lserror)) { LSErrorPrint(&lserror, stderr); LSErrorFree(&lserror); success = false; } jschema_release(&response_schema); return success; } bool luna_service_check_for_subscription_and_process(LSHandle *handle, LSMessage *message) { LSError lserror; bool subscribed = false; LSErrorInit(&lserror); if (LSMessageIsSubscription(message)) { if (!LSSubscriptionProcess(handle, message, &subscribed, &lserror)) { LSErrorPrint(&lserror, stderr); LSErrorFree(&lserror); } } return subscribed; } void luna_service_post_subscription(LSHandle *handle, const char *path, const char *method, jvalue_ref reply_obj) { jschema_ref response_schema = NULL; LSError lserror; LSErrorInit(&lserror); response_schema = jschema_parse (j_cstr_to_buffer("{}"), DOMOPT_NOOPT, NULL); if(!response_schema) goto cleanup; if (!LSSubscriptionPost(handle, path, method, jvalue_tostring(reply_obj, response_schema), &lserror)) { LSErrorPrint(&lserror, stderr); LSErrorFree(&lserror); } cleanup: if (response_schema) jschema_release(&response_schema); } // vim:ts=4:sw=4:noexpandtab
/** ****************************************************************************** * @file : usbd_desc.c * @version : v2.0_Cube * @brief : Header for usbd_conf.c file. ****************************************************************************** * This notice applies to any and all portions of this file * that are not between comment pairs USER CODE BEGIN and * USER CODE END. Other portions of this file, whether * inserted by the user or by software development tools * are owned by their respective copyright owners. * * Copyright (c) 2020 STMicroelectronics International N.V. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted, provided that the following conditions are met: * * 1. Redistribution of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of other * contributors to this software may be used to endorse or promote products * derived from this software without specific written permission. * 4. This software, including modifications and/or derivative works of this * software, must execute solely and exclusively on microcontroller or * microprocessor devices manufactured by or for STMicroelectronics. * 5. Redistribution and use of this software other than as permitted under * this license is void and will automatically terminate your rights under * this license. * * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USBD_DESC__C__ #define __USBD_DESC__C__ #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "usbd_def.h" /* USER CODE BEGIN INCLUDE */ /* USER CODE END INCLUDE */ /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY * @{ */ /** @defgroup USBD_DESC USBD_DESC * @brief Usb device descriptors module. * @{ */ /** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines * @brief Defines. * @{ */ /* USER CODE BEGIN EXPORTED_DEFINES */ /* USER CODE END EXPORTED_DEFINES */ /** * @} */ /** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions * @brief Types. * @{ */ /* USER CODE BEGIN EXPORTED_TYPES */ /* USER CODE END EXPORTED_TYPES */ /** * @} */ /** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros * @brief Aliases. * @{ */ /* USER CODE BEGIN EXPORTED_MACRO */ /* USER CODE END EXPORTED_MACRO */ /** * @} */ /** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables * @brief Public variables. * @{ */ /** Descriptor for the Usb device. */ extern USBD_DescriptorsTypeDef FS_Desc; /* USER CODE BEGIN EXPORTED_VARIABLES */ /* USER CODE END EXPORTED_VARIABLES */ /** * @} */ /** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype * @brief Public functions declaration. * @{ */ /* USER CODE BEGIN EXPORTED_FUNCTIONS */ /* USER CODE END EXPORTED_FUNCTIONS */ /** * @} */ /** * @} */ /** * @} */ #ifdef __cplusplus } #endif #endif /* __USBD_DESC__C__ */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
#ifndef PLOTCONTROLWIDGETWRAPPER_H #define PLOTCONTROLWIDGETWRAPPER_H #include "controlWidgets/plotcontrolwidget.h" #include "controlwrappers/controlwidgetwrapper.h" class PlotControlWidgetWrapper: public ControlWidgetWrapper { Q_OBJECT public: PlotControlWidgetWrapper(QWidget *parent=0); ~PlotControlWidgetWrapper() { } void setLayoutModel(PlotLayoutModel*); public slots: void initializeState(); void treatXLowLimitRequest(); void treatXHighLimitRequest(); void treatXLabelChanging(); void treatTitleChanging(); void treatScaleTypeChanging(); void treatTimeAxisTypeChanging(); void setMinWidth(int); void treatXTickRotationChanging(); void treatCommandLabelRotationChanging(); signals: // void settingXRangeRequest(double, double); // void legendChangingVisibilityRequest(bool); // void dimensionChangingVisibilityRequest(bool); private: PlotControlWidget *mControlWidgetCopy; }; #endif // PLOTCONTROLWIDGETWRAPPER_H
/* * File: exceptions.h * Author: ben * * Created on 23 agosto 2009, 15.42 */ #ifndef _EXCEPTIONS_H #define _EXCEPTIONS_H #include <stdexcept> #include <string> class BasicException : public std::exception { std::string message; public: BasicException() = default; BasicException(const char * _mess) : message(_mess) { } BasicException(const std::string& _mess) : message(_mess) { } BasicException(const BasicException& _ex) : message(_ex.message) { } virtual ~BasicException() throw() = default; virtual const char * what() const throw() { return message.c_str(); } const std::string& getMessage() const throw() { return message; } virtual void setMessage(const std::string & _mess) { message = _mess; } virtual void appendMessage(const std::string & _mess) { message += _mess; } virtual void prefixMessage(const std::string & _mess) { message = _mess + message; } }; class MmuException : public BasicException { public: MmuException() = default; MmuException(const char * _mess) : BasicException(_mess) { } MmuException(const std::string& _mess) : BasicException(_mess) { } }; class WrongComponentException : public BasicException { public: WrongComponentException() = default; WrongComponentException(const char * _mess) : BasicException(_mess) { } WrongComponentException(const std::string & _mess) : BasicException(_mess) { } }; class WrongInstructionException : public BasicException { public: WrongInstructionException() = default; WrongInstructionException(const char * _mess) : BasicException(_mess) { } WrongInstructionException(const std::string & _mess) : BasicException(_mess) { } }; class WrongArgumentException : public WrongInstructionException { public: WrongArgumentException() = default; WrongArgumentException(const char * _mess) : WrongInstructionException(_mess) { } WrongArgumentException(const std::string & _mess) : WrongInstructionException(_mess) { } }; class WrongFileException : public BasicException { public: WrongFileException() = default; WrongFileException(const char * _mess) : BasicException(_mess) { } WrongFileException(const std::string & _mess) : BasicException(_mess) { } }; class DuplicateLabelException : public BasicException { public: DuplicateLabelException() = default; DuplicateLabelException(const char * _mess) : BasicException(_mess) { } DuplicateLabelException(const std::string & _mess) : BasicException(_mess) { } }; //class DuplicateConstException : public BasicException { //public: // DuplicateConstException() = default; // DuplicateConstException(const char * _mess) : BasicException(_mess) { } // DuplicateConstException(const std::string & _mess) : BasicException(_mess) { } //}; #endif /* _EXCEPTIONS_H */
/***************************************************************************** * * PROJECT: Multi Theft Auto v1.0 * LICENSE: See LICENSE in the top level directory * FILE: mods/deathmatch/logic/packets/CUnoccupiedVehicleStartSyncPacket.h * PURPOSE: Unoccupied vehicle start synchronization packet class * DEVELOPERS: Christian Myhre Lundheim <> * Jax <> * * Multi Theft Auto is available from http://www.multitheftauto.com/ * *****************************************************************************/ #ifndef __CUNOCCUPIEDVEHICLESTARTSYNCPACKET_H #define __CUNOCCUPIEDVEHICLESTARTSYNCPACKET_H #include "CPacket.h" class CVehicle; class CUnoccupiedVehicleStartSyncPacket : public CPacket { public: inline CUnoccupiedVehicleStartSyncPacket ( CVehicle * pVehicle ) { m_pVehicle = pVehicle; }; inline ePacketID GetPacketID ( void ) const { return PACKET_ID_UNOCCUPIED_VEHICLE_STARTSYNC; }; inline unsigned long GetFlags ( void ) const { return PACKET_RELIABLE | PACKET_SEQUENCED; }; bool Write ( NetBitStreamInterface& BitStream ) const; private: CVehicle * m_pVehicle; }; #endif
// // Created by bruce on 27/04/20. // #include "../fs.h" int sys_chdir(struct proc* who, char* pathname){ int ret = OK; inode_t *inode = NULL, *curr_working; if((ret = get_inode_by_path(who, pathname, &inode))) return ret; if(!inode) return EEXIST; if(!(S_ISDIR(inode->i_mode))){ ret = ENOTDIR; goto error; } curr_working = who->fp_workdir; who->fp_workdir = inode; put_inode(curr_working, false); return OK; error: put_inode(inode, false); return ret; } int sys_mkdir(struct proc* who, char* pathname, mode_t mode){ char string[DIRSIZ]; struct inode *lastdir = NULL, *ino = NULL; int ret = OK; bool is_dirty = false; ret = eat_path(who, pathname, &lastdir, &ino, string); if(ret) return ret; if(ino){ ret = EEXIST; goto final; } ino = alloc_inode(who, lastdir->i_dev, lastdir->i_dev); if(!ino){ ret = ENOSPC; goto final; } ino->i_mode = S_IFDIR | (mode & ~(who->umask)); ino->i_zone[0] = alloc_block(ino, lastdir->i_dev); ino->i_size = BLOCK_SIZE; init_dirent(lastdir, ino); ret = add_inode_to_directory(who, lastdir, ino, string); if(ret){ release_inode(ino); goto final_dir; } is_dirty = true; final: put_inode(ino, is_dirty); final_dir: put_inode(lastdir, is_dirty); return ret; } int do_chdir(struct proc* who, struct message* msg){ char* path = (char *) get_physical_addr(msg->m1_p1, who); if(!is_vaddr_accessible(msg->m1_p1, who)) return EFAULT; return sys_chdir(who, path); } int do_mkdir(struct proc* who, struct message* msg){ char* path = (char *) get_physical_addr(msg->m1_p1, who); if(!is_vaddr_accessible(msg->m1_p1, who)) return EFAULT; return sys_mkdir(who, path, msg->m1_i1); }
/* * \file cp15.h * * \brief CP15 related function prototypes * * This file contains the API prototypes for configuring CP15 */ /* * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #ifndef __CP15_H #define __CP15_H #ifdef __cplusplus extern "C" { #endif /*****************************************************************************/ /* ** Macros which can be passed to CP15ControlFeatureDisable/Enable APIs ** as 'features'. Any, or an OR combination of the below macros can be ** passed to disable/enable the corresponding feature. */ #define CP15_CONTROL_TEXREMAP (0x10000000) #define CP15_CONTROL_ACCESSFLAG (0x20000000) #define CP15_CONTROL_ALIGN_CHCK (0x00000002) #define CP15_CONTROL_MMU (0x00000001) /*****************************************************************************/ /* ** API prototypes */ extern void CP15AuxControlFeatureEnable(unsigned int enFlag); extern void CP15AuxControlFeatureDisable(unsigned int disFlag); extern void CP15DCacheCleanBuff(unsigned int bufPtr, unsigned int size); extern void CP15DCacheCleanFlushBuff(unsigned int bufPtr, unsigned int size); extern void CP15DCacheFlushBuff(unsigned int bufPtr, unsigned int size); extern void CP15ICacheFlushBuff(unsigned int bufPtr, unsigned int size); extern void CP15ICacheDisable(void); extern void CP15UnifiedCacheDisable(void); extern void CP15DCacheDisable(void); extern void CP15ICacheEnable(void); extern void CP15DCacheEnable(void); extern void CP15DCacheCleanFlush(void); extern void CP15DCacheClean(void); extern void CP15DCacheFlush(void); extern void CP15ICacheFlush(void); extern void CP15Ttb0Set(unsigned int ttb); extern void CP15TlbInvalidate(void); extern void CP15MMUDisable(void); extern void CP15MMUEnable(void); extern void CP15VectorBaseAddrSet(unsigned int addr); extern void CP15BranchPredictorInvalidate(void); extern void CP15BranchPredictionEnable(void); extern void CP15BranchPredictionDisable(void); extern void CP15DomainAccessClientSet(void); extern void CP15ControlFeatureDisable(unsigned int features); extern void CP15ControlFeatureEnable(unsigned int features); extern void CP15TtbCtlTtb0Config(void); extern unsigned int CP15MainIdPrimPartNumGet(void); #ifdef __cplusplus } #endif #endif /* __CP15_H__ */
// -*- c++ -*- /* * Copyright 2012, 2013 The GalSim developers: * https://github.com/GalSim-developers * * This file is part of GalSim: The modular galaxy image simulation toolkit. * * GalSim 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. * * GalSim 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 GalSim. If not, see <http://www.gnu.org/licenses/> */ #ifndef SBMOFFAT_H #define SBMOFFAT_H /** * @file SBMoffat.h @brief SBProfile that implements a Moffat profile. */ #include "SBProfile.h" namespace galsim { /** * @brief Surface Brightness for the Moffat Profile (an approximate description of ground-based * PSFs). * * The Moffat surface brightness profile is I(R) propto [1 + (r/r_scale)^2]^(-beta). The * SBProfile representation of a Moffat profile also includes an optional truncation beyond a * given radius. */ class SBMoffat : public SBProfile { public: enum RadiusType { FWHM, HALF_LIGHT_RADIUS, SCALE_RADIUS }; /** @brief Constructor. * * @param[in] beta Moffat beta parameter for profile `[1 + (r / rD)^2]^beta`. * @param[in] size Size specification. * @param[in] rType Kind of size being specified (one of FWHM, HALF_LIGHT_RADIUS, * SCALE_RADIUS). * @param[in] trunc Outer truncation radius in same physical units as size, * trunc = 0. for no truncation. * @param[in] flux Flux. * @param[in] gsparams GSParams object storing constants that control the accuracy of * image operations and rendering, if different from the default. */ SBMoffat(double beta, double size, RadiusType rType, double trunc, double flux, const GSParamsPtr& gsparams); /// @brief Copy constructor. SBMoffat(const SBMoffat& rhs); /// @brief Destructor. ~SBMoffat(); /// @brief Returns beta of the Moffat profile `[1 + (r / rD)^2]^beta`. double getBeta() const; /// @brief Returns the FWHM of the Moffat profile. double getFWHM() const; /// @brief Returns the scale radius rD of the Moffat profile `[1 + (r / rD)^2]^beta`. double getScaleRadius() const; /// @brief Returns the half light radius of the Moffat profile. double getHalfLightRadius() const; protected: class SBMoffatImpl; private: // op= is undefined void operator=(const SBMoffat& rhs); }; } #endif // SBMOFFAT_H
#pragma once #include <bgfx/bgfx.h> #include <content/StaticLevelMesh.h> namespace BgfxUtils { /** * @brief Initializes the given StaticLevelMeshes vertex- and index-buffers */ template<typename V, typename I> void finalizeStaticLevelMesh(LevelMesh::StaticLevelMesh<V, I>& msh) { msh.m_VertexBufferHandle = bgfx::createVertexBuffer( // Static data can be passed with bgfx::makeRef bgfx::makeRef(msh.m_Vertices.data(), msh.m_Vertices.size() * sizeof(V)) , V::ms_decl ); msh.m_IndexBufferHandle = bgfx::createIndexBuffer( // Static data can be passed with bgfx::makeRef bgfx::makeRef(msh.m_Indices.data(), msh.m_Indices.size() * sizeof(I)), sizeof(I) == 4 ? BGFX_BUFFER_INDEX32 : 0 ); } }
#pragma once #include <pthread.h> #include <sstream> #include <palmapper/Config.h> #include <palmapper/GenomeMaps.h> #include <palmapper/JunctionMap.h> #include <palmapper/VariantMap.h> #include <map> #include <set> class Mapper ; class GenomeMaps ; class QPalma ; struct HIT; typedef struct alignment_t { double qpalma_score; double sort_key; uint32_t num_matches_ref; uint32_t num_mismatches_ref; uint32_t qual_mismatches_ref; uint32_t num_gaps_ref; bool considered_variants ; uint32_t num_mismatches_var; uint32_t num_gaps_var; std::string read_anno ; //char read_anno[4*Config::MAX_READ_LENGTH] ; std::vector<int> exons; Chromosome const *chromosome; char orientation; char strand ; char read_id[Config::MAX_READ_ID_LENGTH]; int min_exon_len ; int max_intron_len ; bool spliced ; //bool rescued ; //int rescue_start, rescue_end ; int rtrim_cut ; int polytrim_cut_start ; int polytrim_cut_end ; char from_gm ; bool passed_filters; bool remapped ; std::vector<Variant> found_variants ; //Existing variants used to obtain a better alignment than on the reference std::map<int,int> variant_positions; std::vector<Variant> align_variants ; //Variants discovered from an alignment std::vector<int> aligned_positions ; HIT* hit ; int num ; std::vector<std::string> intron_consensus ; std::vector<bool> non_consensus_intron ; bool non_consensus_alignment ; } ALIGNMENT; class TopAlignments { public: TopAlignments(GenomeMaps* genomemaps_) ; ~TopAlignments() { free(ALIGNSEQ); clean_top_alignment_record() ; } u_int8_t report_unspliced_hit(Read const &read, HIT *hit, int num, QPalma const * qpalma) ; int construct_aligned_string(Read const &read, HIT *hit, int *num_gaps_p, int *num_mismatches_p, int *qual_mismatches_p, int *num_matches_p); alignment_t *gen_alignment_from_hit(Read const &read, HIT *best_hit, QPalma const *qpalma) ; int construct_aligned_string(HIT *hit, int *num_gaps_p, int *num_mismatches_p, int *num_matches_p); inline void free_alignment_record(alignment_t *&alignment) { alignment->variant_positions.clear() ; alignment->align_variants.clear() ; alignment->found_variants.clear() ; alignment->aligned_positions.clear() ; alignment->non_consensus_intron.clear() ; alignment->intron_consensus.clear() ; alignment->exons.clear() ; delete alignment ; alignment=NULL ; } void init_top_alignment_index() ; void update_top_alignment_index() ; alignment_t * add_alignment_record(alignment_t *alignment, int num_alignments); void clean_top_alignment_record() ; void start_top_alignment_record() ; void check_alignment(struct alignment_t * alignment) ; void end_top_alignment_record(Read const &read, std::ostream *OUT_FP, std::ostream *SP_OUT_FP,std::ostream *VARIANTS_FP, int rtrim_cut, int polytrim_start, int polytrim_end, JunctionMap &junctionmap, VariantMap & variants) ; int print_top_alignment_records(Read const &read, std::ostream *OUT_FP, std::ostream *SP_OUT_FP) ; int print_top_alignment_records_bedx(Read const &read, std::ostream *OUT_FP, std::ostream *SP_OUT_FP); int print_top_alignment_records_shorebed(Read const &read, std::ostream *OUT_FP, std::ostream *SP_OUT_FP) ; int print_alignment_shorebed(Read const &read, std::ostream *OUT_FP, alignment_t* align, unsigned int num) ; int print_top_alignment_records_sam(Read const &read, std::ostream *OUT_FP, std::ostream *SP_OUT_FP) ; int print_top_alignment_variants(int rank, int total, std::ostream *OUT_FP, std::vector<Variant> v, const char * chr); static void print_bam_header(Genome& genome, FILE *OUT_FP); static FILE* open_bam_pipe(std::string & out_fname) ; static int close_bam_pipe(FILE * FP) ; size_t size() { return top_alignments.size() ; } alignment_t * get_alignment(int idx) { return top_alignments[idx] ; } bool stop_aligning() ; void update_max_editops() ; int get_max_editops() ; int get_max_mismatches() ; int get_max_gaps() ; protected: int32_t compare_score(alignment_t *a1, alignment_t *a2) ; bool alignment_is_equal(alignment_t *a1, alignment_t *a2) ; int alignment_is_opposite(alignment_t *a1, alignment_t *a2) ; int spliced_is_overlapping(alignment_t *a1, alignment_t *a2) ; int non_consensus_overlaps_consensus(alignment_t *a1, alignment_t *a2) ; void sort_top_alignment_list() ; void qsort_top_alignments(alignment_t** output, int size); void determine_transcription_direction(char strand,char orientation, int side, char &transcription, char &read_forward); bool overlap(alignment_t* alignment1, alignment_t* alignment2); std::vector<alignment_t *> top_alignments; int num_spliced_alignments; int num_unspliced_alignments; const int verbosity ; char *ALIGNSEQ; int num_filtered; int current_ind; int temp_ind; int max_editops ; bool _stop_aligning ; bool _drop_alignments ; //pthread_mutex_t top_mutex; GenomeMaps* genomemaps ; } ;
/* * This file is part of OpenStopMotion by Patrick Fedick * * $Author$ * $Revision$ * $Date$ * $Id$ * * * Copyright (c) 2013 Patrick Fedick <patrick@pfp.de> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef SAVETHREAD_H_ #define SAVETHREAD_H_ #define WITH_QT #include <ppl7.h> #include <ppl7-grafix.h> #include <queue> namespace PictureFormat { enum Format { png=0, bmp=1, jpeg=2 }; }; class SaveJob { public: ppl7::grafix::Image img; ppl7::String Filename; int format; int quality; }; class SaveThread : ppl7::Thread { private: ppl7::Mutex mutex; ppl7::Mutex signal; std::queue<SaveJob*> jobs; uint64_t timeout; bool running; public: SaveThread(); ~SaveThread(); void addJob(SaveJob *job); void run(); void stop(); void executeJob(const SaveJob &job) const; }; #endif /* SAVETHREAD_H_ */
//************************************************************************************************************ // Defenders of Mankind: A 3D space shoot'em up game. // Copyright (C) 2011 David Entrena, David Rodríguez, Gorka Suárez, Roberto Jiménez // // 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/>. //************************************************************************************************************ // Defenders of Mankind: Juego shoot'em up de naves en 3D. // Copyright (c) 2011 Grupo 03 // Grupo 03: David Entrena, David Rodríguez, Gorka Suárez, Roberto Jiménez //************************************************************************************************************ #ifndef __LOGIC_BULLETGOTOPLAYERMOVEMENT_H__ #define __LOGIC_BULLETGOTOPLAYERMOVEMENT_H__ //************************************************************************************************************ // Includes //************************************************************************************************************ #include "IMovement.h" #include <utility> //************************************************************************************************************ // Logic //************************************************************************************************************ namespace Logic { /** * Esta clase representa un tipo de movimiento rectilíneo, moviendo la entidad hacia donde se encuentraba el jugador * en base a un vector dirección. */ class BulletGoToPlayerMovement: public IMovement { public: MovementCreateMethod(BulletGoToPlayerMovement); /** Constructor por defecto. */ BulletGoToPlayerMovement() : IMovement("BulletGoToPlayerMovement"), _dir(0.0f, 0.0f), _velAxis1(0.0f), _velAxis2(0.0f), _initialized(false) {} /* Función que calcula el siguiente paso de la trayectoria en particular. @param posAxis Estructura de tipo par que contiene la posición actual de la entidad. Cada atributo hace referencia a un eje en concreto del plano de movimiento, sea cual sea dicho eje en el mundo 3D. @param actionCenter Posición actual del centro de la acción. @param actualView Tipo actual de la vista. @param lastInterval Milisegundos transcurridos desde el último tick. */ void calculatePath(std::pair<float, float>& posAxis, const Vector3& actionCenter, CameraType actualView, unsigned int lastInterval); protected: /** Método "activate" para el movimiento. @return true si todo ha ido correctamente. */ virtual bool activate(); /** * Método para inicializar el movimiento en base a los datos de su descriptor. * @param info La información inicial del movimiento. * @return Devuelve true si se inicializa correctamente. */ virtual bool spawn(Core::InfoTable* info, Core::Entity* owner); /** * Comprueba si un mensaje es válido para ser procesado o no. * @param message El mensaje enviado al puerto. * @return De ser válido devolverá true. */ virtual bool accept(const Core::SmartMessage & message); /** * Procesa un mensaje recién sacado de la lista. * @param message El mensaje sacado de la lista. */ virtual void process(const Core::SmartMessage & message); private: /* Entidad propietaria del movimiento (en este movimiento si se usa) */ Core::Entity* _owner; /* Estructura de tipo par que representa la dirección (y velocidad) del movimiento. No utilizo un vector debido a que puede dar lugar a confusión al leer el código ya que los atributos ".x" y ".y" de un Vector2 pueden no coincidir con los ejes de movimiento actuales ya que dependen del tipo de vista. No sé si me explico bien xDD */ std::pair<float, float> _dir; /* Velocidad del movimiento */ float _velAxis1; float _velAxis2; bool _initialized; }; } // namespace Logic #endif // __LOGIC_BULLETGOTOPLAYERMOVEMENT_H__
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "struct.h" #include "access.h" #include "util.h" #include "search.h" void aux_comptage(node* nd, int* counter){ //cas simple, on à trouvé un mot. if( prefix_has_epsilon(nd)){ //on augmente le compteur (*counter)++; } int i; //si le noeud à des fils ( donc des sous-mots possibles) if(has_childs(nd)){ /* parse all the child of the node to call recursivly the counter */ for(i = 0; i < NB_CHAR_MAX; i++){ node* fils = get_fils_node(nd, (char)i); /* if the node is not null a child has a prefix */ if(! is_node_null(fils)){ aux_comptage(fils, counter); } } } } int comptage_mot(node* nd){ if (is_node_null(nd)){ exit_failure("comptage_mot", "la racine vaut NULL"); } int counter = 0; int i; if( has_childs(nd)){ /* parse all the child of the root to call recursivly the counter */ for(i = 0; i < NB_CHAR_MAX; i++){ node* fils = get_fils_node(nd, (char)i); /* if the node is not null a child has a prefix */ if(! is_node_null(fils)){ aux_comptage(fils, &counter); } } } return counter; } void aux_comptage_prefix_nb_mots(node* nd, char* string, int* counter){ if( prefix_equals_string(nd,string)){ *counter = comptage_mot(nd); }else{ int comon_prefix = taille_prefixe_commun(string, nd->prefix); if( strlen(string) <= (unsigned int)nd->size || comon_prefix < nd->size){ if(strstr(get_prefix(nd), string)){ *counter = comptage_mot(nd); }else{ return; } }else{ //cas ou la string est strictement plus grande que le prefixe avec le prefixe compris dedans char* sub_str = &string[comon_prefix]; node* fils = get_fils_node(nd,sub_str[0]); //if the node doesn't have a child with the same first letter then the string is not present if(is_node_null(fils)){ printf("le fils: %c vaut NULL, %s n'existe pas dans l'arbre\n",string[0],string); return; } aux_comptage_prefix_nb_mots(fils,sub_str, counter); } } } int comptage_prefix_nb_mots(node* nd, char* mot){ if( is_node_null(nd)){ exit_failure("comptage_prefix_nb_mots", "racine vaut NULL"); } if( has_childs(nd)){ int i; int counter = 0; for(i = 0; i < NB_CHAR_MAX; i++){ node* fils = get_fils_node(nd, (char)i); if(!is_node_null(fils)){ aux_comptage_prefix_nb_mots(fils, mot, &counter); } } return counter; }else{ //if the root has no child then word is prefix of no-one. return 0; } } int aux_comptage_null(node* nd){ int counter = 0; //si il existe des fils if(has_childs(nd)){ int i; for(i = 0; i < NB_CHAR_MAX; i++){ node* fils = get_fils_node(nd, (char)i); //si le fils vaut null, +1 if( is_node_null(fils)){ counter++; }else{ //sinon on vérifie ses sous fils counter += aux_comptage_null(fils); } } }else{ //si aucune fils alors le noeud à NB_CHAR_MAX (127) fils à null counter = NB_CHAR_MAX; } return counter; } int comptage_null(node* nd){ if( is_node_null(nd)){ exit_failure("comptage_null", "la racine vaut null"); } int counter = 0; /* même fonction que celle récursive au dessus, * seuld détails, pour la racine il faut tester si le noeud n'est pas NULL * et arreter le programme promptement dans ce cas */ if(has_childs(nd)){ int i; for(i = 0; i < NB_CHAR_MAX; i++){ node* fils = get_fils_node(nd, (char)i); if(is_node_null(fils)){ counter++; }else{ counter += aux_comptage_null(fils); } } }else{ counter = NB_CHAR_MAX; } return counter; }
// Copyright (C) 2015 Francis Bergin #include "includes.h" //***************************************************************************** // // Function : eth_generate_header // Description : generarete ethernet header, contain destination and source MAC // address, // ethernet type. // //***************************************************************************** void eth_generate_header(BYTE *rxtx_buffer, WORD_BYTES type, BYTE *dest_mac) { BYTE i; // copy the destination mac from the source and fill my mac into src for (i = 0; i < sizeof(MAC_ADDR); i++) { rxtx_buffer[ETH_DST_MAC_P + i] = dest_mac[i]; rxtx_buffer[ETH_SRC_MAC_P + i] = avr_mac.byte[i]; } rxtx_buffer[ETH_TYPE_H_P] = type.byte.high; // HIGH(type); rxtx_buffer[ETH_TYPE_L_P] = type.byte.low; // LOW(type); } //***************************************************************************** // // Function : software_checksum // Description : // The Ip checksum is calculated over the ip header only starting // with the header length field and a total length of 20 bytes // unitl ip.dst // You must set the IP checksum field to zero before you start // the calculation. // len for ip is 20. // // For UDP/TCP we do not make up the required pseudo header. Instead we // use the ip.src and ip.dst fields of the real packet: // The udp checksum calculation starts with the ip.src field // Ip.src=4bytes,Ip.dst=4 bytes,Udp header=8bytes + data length=16+len // In other words the len here is 8 + length over which you actually // want to calculate the checksum. // You must set the checksum field to zero before you start // the calculation. // len for udp is: 8 + 8 + data length // len for tcp is: 4+4 + 20 + option len + data length // // For more information on how this algorithm works see: // http://www.netfor2.com/checksum.html // http://www.msc.uky.edu/ken/cs471/notes/chap3.htm // The RFC has also a C code example: http://www.faqs.org/rfcs/rfc1071.html // //***************************************************************************** WORD software_checksum(BYTE *rxtx_buffer, WORD len, DWORD sum) { // build the sum of 16bit words while (len > 1) { sum += 0xFFFF & (*rxtx_buffer << 8 | *(rxtx_buffer + 1)); rxtx_buffer += 2; len -= 2; } // if there is a byte left then add it (padded with zero) if (len) { sum += (0xFF & *rxtx_buffer) << 8; } // now calculate the sum over the bytes in the sum // until the result is only 16bit long while (sum >> 16) { sum = (sum & 0xFFFF) + (sum >> 16); } // build 1's complement: return ((WORD)sum ^ 0xFFFF); }
/* * Generated by asn1c-0.9.29 (http://lionet.info/asn1c) * From ASN.1 module "S1AP-IEs" * found in "../support/s1ap-r16.1.0/36413-g10.asn" * `asn1c -pdu=all -fcompound-names -findirect-choice -fno-include-deps` */ #ifndef _S1AP_BearerType_H_ #define _S1AP_BearerType_H_ #include <asn_application.h> /* Including external dependencies */ #include <NativeEnumerated.h> #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum S1AP_BearerType { S1AP_BearerType_non_IP = 0 /* * Enumeration is extensible */ } e_S1AP_BearerType; /* S1AP_BearerType */ typedef long S1AP_BearerType_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_S1AP_BearerType; asn_struct_free_f S1AP_BearerType_free; asn_struct_print_f S1AP_BearerType_print; asn_constr_check_f S1AP_BearerType_constraint; ber_type_decoder_f S1AP_BearerType_decode_ber; der_type_encoder_f S1AP_BearerType_encode_der; xer_type_decoder_f S1AP_BearerType_decode_xer; xer_type_encoder_f S1AP_BearerType_encode_xer; oer_type_decoder_f S1AP_BearerType_decode_oer; oer_type_encoder_f S1AP_BearerType_encode_oer; per_type_decoder_f S1AP_BearerType_decode_uper; per_type_encoder_f S1AP_BearerType_encode_uper; per_type_decoder_f S1AP_BearerType_decode_aper; per_type_encoder_f S1AP_BearerType_encode_aper; #ifdef __cplusplus } #endif #endif /* _S1AP_BearerType_H_ */ #include <asn_internal.h>
// Copyright (c) 2002,2011 Utrecht University (The Netherlands). // All rights reserved. // // This file is part of CGAL (www.cgal.org). // 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. // // Licensees holding a valid commercial license may use this file in // accordance with the commercial license agreement provided with the software. // // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ // // // Author(s) : Hans Tangelder (<hanst@cs.uu.nl>) #ifndef CGAL_SEARCH_TRAITS_3_H #define CGAL_SEARCH_TRAITS_3_H #include <CGAL/license/Spatial_searching.h> #include <CGAL/Dimension.h> namespace CGAL { template <class K> class Search_traits_3 { public: typedef Dimension_tag<3> Dimension; typedef typename K::Cartesian_const_iterator_3 Cartesian_const_iterator_d; typedef typename K::Construct_cartesian_const_iterator_3 Construct_cartesian_const_iterator_d; typedef typename K::Point_3 Point_d; typedef typename K::Iso_cuboid_3 Iso_box_d; typedef typename K::Sphere_3 Sphere_d; typedef typename K::Construct_iso_cuboid_3 Construct_iso_box_d; typedef typename K::Construct_min_vertex_3 Construct_min_vertex_d; typedef typename K::Construct_max_vertex_3 Construct_max_vertex_d; typedef typename K::Construct_center_3 Construct_center_d; typedef typename K::Compute_squared_radius_3 Compute_squared_radius_d; typedef typename K::FT FT; Construct_cartesian_const_iterator_d construct_cartesian_const_iterator_d_object() const { return Construct_cartesian_const_iterator_d(); } }; } // namespace CGAL #endif // SEARCH_TRAITS_3_H
//{{NO_DEPENDENCIES}} // Microsoft Developer Studio generated include file. // Used by svchost.rc // #define IDR_SYS 102 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 107 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1000 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif
/* * Copyright (C) 2010-2011 * "Mu Lei" known as "NalaGinrut" <NalaGinrut@gmail.com> * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <debug/trace.h> #include <types.h> #include <retval.h> #include <cpu.h> // FIXME: we implement this backtrace for IA32-convention, // but we need a generic trace frameworks. retval pcall_backtrace(frame_info_t fi ,u32_t dep_count) { /* u32_t *frame=(u32_t*)get_frame_head(); u8_t frame_head=0,return_ip=1,args=2; while(dep_count-- > 0) { kprintf("frame_head:%x\n" "return_ip:%x\n" "args:%x\n", frame ,frame[return_ip] ,frame[args]); frame=(u32_t*)frame[frame_head]; } */ return OK; }
#ifndef INCLUDE_DBCREADER_H #define INCLUDE_DBCREADER_H /* dbcreader.h -- declarations for libcandbc Copyright (C) 2007-2017 Andreas Heitmann This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "dbcmodel.h" #ifdef __cplusplus extern "C" { #endif dbc_t *dbc_read_file(char *filename); #ifdef __cplusplus } #endif #endif
/************************************** *FILE :main.c *PROJECT :eps *AUTHOR :707wk *CREATED :5/19/2013 ***************************************/ #include <stdio.h> #include <string.h> #include <stdlib.h> void clearpri() //调整光标 { system("busybox clear"); } void init(int num) //记录初始化 { FILE* fp; int n=0; char s[2000]; fp=fopen("data/ec.db","w"); while(n<num) { s[n++]='0'; } for(n=0;n<num;n++) fprintf(fp,"%c",s[n]); fclose(fp); } void initi(char s[],char m[]) { char c,sum[2000]; int n=0,num=0; FILE* fp; fp=fopen(s,"r"); while((c=fgetc(fp))!=EOF)if(c=='^')num++; fp=fopen(m,"w"); while(n<num) { sum[n++]='0'; } for(n=0;n<num;n++) fprintf(fp,"%c",sum[n]); fclose(fp); } void inie(int num,int sum) //存储错题 { FILE* fp; int n=0; char s[2000]; fp=fopen("data/ec.db","r"); while(n<sum) { s[n++]=fgetc(fp); } s[num-1]='1'; fclose(fp); fp=fopen("data/ec.db","w"); for(n=0;n<sum;n++) fprintf(fp,"%c",s[n]); fclose(fp); } void iniee(int num,int sum) //删除做对的题 { FILE* fp; int n=0; char s[2000]; fp=fopen("data/ec.db","r"); while(n<sum) { s[n++]=fgetc(fp); } s[num-1]='0'; fclose(fp); fp=fopen("data/ec.db","w"); for(n=0;n<sum;n++) fprintf(fp,"%c",s[n]); fclose(fp); } int ud(FILE* fp) //跳题 { int s=0,n,num=0; char c; clearpri(); printf("请输入题号:"); while((c=getch())!='\r') { if(c>='0'&&c<='9') { num++; printf("%c",c); s=s*10+c-'0'; } else if(c==127&&num>0) { s=s/10; printf("\b \b"); num--; } } scanf("%d",&s); rewind(fp); n=s; if(s==1||s==0)return 1; while(s>1) { if((c=fgetc(fp))=='^')s--; if( num>5 || (feof(fp) && s>1) ) { clearpri(); printf("error!数值超出范围\n按任意键返回第一题"); getch(); fseek(fp,0,SEEK_SET); return 1; } } fgetc(fp); fgetc(fp); return n; } void uud(FILE* fp,int s) //无显示跳题 { char c; rewind(fp); if(s==1||s==0)return ; while(s>1) { if((c=fgetc(fp))=='^')s--; if(c==EOF&&s>1) { fseek(fp,0,SEEK_SET); return ; } } fgetc(fp); fgetc(fp); return ; } int udd() //统计题量 { char c; int n=0; FILE* fp; fp=fopen("data/select.db","r"); while((c=fgetc(fp))!=EOF)if(c=='^')n++; return n; } int ude() //统计错题量 { char c; int n=0; FILE* fp; fp=fopen("data/ec.db","r"); while((c=fgetc(fp))!=EOF)if(c=='1')n++; return n; } int uddd(FILE* fp) //计算当前题号 { FILE* fp1; int num=1,n; n=ftell(fp); fp1=fopen("data/select.db","r"); while(ftell(fp1)<=n) { if(fgetc(fp1)=='^')num++; } return num; } int Option( char rw , int nb , int n ) //存储设置 { int nu[2] ; FILE* fp ; if( ( fp=fopen( "data/option.ini" , "r" ) ) == NULL ) { fclose( fp ) ; printf( "\n< 文件错误:设置文件未找到 >\n" ) ; exit(0); } fscanf( fp , "num = %d\n" , &nu[0] ) ; fclose( fp ) ; switch( rw ) { case 'r': switch( n ) { case 0: if( nu[0] == 0 )return 1 ; else return nu[0] ; break ; } break ; case 'w': if( ( fp=fopen( "data/option.ini" , "w" ) ) == NULL ) { fclose( fp ) ; printf( "\n< 文件错误:设置文件未能创建成功 >\n" ) ; exit( 0 ) ; } switch( n ) { case 0: if( nb == 0 )nu[0] =1 ; else nu[0] =nb ; break ; } fprintf( fp , "num = %d\n" , nu[0] ) ; fclose( fp ) ; return 1 ; } return 0 ; }
#ifndef _Discriminant_Pattern_Categories_h_ #define _Discriminant_Pattern_Categories_h_ /* Discriminant_Pattern_Categories.h * * Copyright (C) 2004-2011 David Weenink * * 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. */ /* djmw 20040422 Initial version djmw 20110307 Latest modification */ #ifndef _Discriminant_h_ #include "Discriminant.h" #endif #ifndef _Pattern_h_ #include "Pattern.h" #endif #ifndef _Categories_h_ #include "Categories.h" #endif Discriminant Pattern_and_Categories_to_Discriminant (Pattern me, Categories thee); Categories Discriminant_and_Pattern_to_Categories (Discriminant me, Pattern thee, int poolCovarianceMatrices,int useAprioriProbabilities); #endif /* _Discriminant_Pattern_Categories_h_ */
#ifndef MAVLINK_CPP_MSG_GPS2_RTK_H #define MAVLINK_CPP_MSG_GPS2_RTK_H #include "../message.h" namespace mavlink { namespace msg { const uint8_t gps2_rtk_id = 128; const uint8_t gps2_rtk_length = 35; const uint8_t gps2_rtk_crc = 226; class gps2_rtk : public mavlink::message { public: gps2_rtk(uint8_t system_id, uint8_t component_id, uint32_t time_last_baseline_ms, uint8_t rtk_receiver_id, uint16_t wn, uint32_t tow, uint8_t rtk_health, uint8_t rtk_rate, uint8_t nsats, uint8_t baseline_coords_type, int32_t baseline_a_mm, int32_t baseline_b_mm, int32_t baseline_c_mm, uint32_t accuracy, int32_t iar_num_hypotheses): mavlink::message( mavlink::msg::gps2_rtk_length, system_id, component_id, mavlink::msg::gps2_rtk_id) { m_payload.push_back<uint32_t>(time_last_baseline_ms); ///< Time since boot of last baseline message received in ms. m_payload.push_back<uint32_t>(tow); ///< GPS Time of Week of last baseline m_payload.push_back<int32_t>(baseline_a_mm); ///< Current baseline in ECEF x or NED north component in mm. m_payload.push_back<int32_t>(baseline_b_mm); ///< Current baseline in ECEF y or NED east component in mm. m_payload.push_back<int32_t>(baseline_c_mm); ///< Current baseline in ECEF z or NED down component in mm. m_payload.push_back<uint32_t>(accuracy); ///< Current estimate of baseline accuracy. m_payload.push_back<int32_t>(iar_num_hypotheses); ///< Current number of integer ambiguity hypotheses. m_payload.push_back<uint16_t>(wn); ///< GPS Week Number of last baseline m_payload.push_back<uint8_t>(rtk_receiver_id); ///< Identification of connected RTK receiver. m_payload.push_back<uint8_t>(rtk_health); ///< GPS-specific health report for RTK data. m_payload.push_back<uint8_t>(rtk_rate); ///< Rate of baseline messages being received by GPS, in HZ m_payload.push_back<uint8_t>(nsats); ///< Current number of sats used for RTK calculation. m_payload.push_back<uint8_t>(baseline_coords_type); ///< Coordinate system of baseline. 0 == ECEF, 1 == NED } uint32_t get_time_last_baseline_ms() const {return m_payload.get<uint32_t>(0);} uint32_t get_tow() const {return m_payload.get<uint32_t>(4);} int32_t get_baseline_a_mm() const {return m_payload.get<int32_t>(8);} int32_t get_baseline_b_mm() const {return m_payload.get<int32_t>(12);} int32_t get_baseline_c_mm() const {return m_payload.get<int32_t>(16);} uint32_t get_accuracy() const {return m_payload.get<uint32_t>(20);} int32_t get_iar_num_hypotheses() const {return m_payload.get<int32_t>(24);} uint16_t get_wn() const {return m_payload.get<uint16_t>(28);} uint8_t get_rtk_receiver_id() const {return m_payload.get<uint8_t>(30);} uint8_t get_rtk_health() const {return m_payload.get<uint8_t>(31);} uint8_t get_rtk_rate() const {return m_payload.get<uint8_t>(32);} uint8_t get_nsats() const {return m_payload.get<uint8_t>(33);} uint8_t get_baseline_coords_type() const {return m_payload.get<uint8_t>(34);} }; }; }; #endif //MAVLINK_CPP_MSG_GPS2_RTK_H
// micro-C example 8 -- loop 20 million times // PASSES void main() { int i; i = 20000000; while (i) { i = i - 1; } print 999999; } void start() { main(); }
/******************************************************************************/ * Moose3D is a game development framework. * * Copyright 2006-2013 Anssi Gröhn / entity at iki dot fi. * * This file is part of Moose3D. * * Moose3D 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. * * Moose3D 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 Moose3D. If not, see <http://www.gnu.org/licenses/>. ******************************************************************************/ ///////////////////////////////////////////////////////////////// #ifdef WIN32 #include "MooseWindowsWrapper.h" #endif ///////////////////////////////////////////////////////////////// #include "MooseAPI.h" #if defined(MOOSE_APPLE_IPHONE) #include <dispatch/dispatch.h> #endif //#include "MooseGuiSystem.h" #include "MooseAVLTree.h" #include "MooseCore.h" #include "MooseAssetBundle.h" #include "MooseGlobals.h" #include "MooseIndexArray.h" #include "MooseMath.h" #include "MooseMathUtils.h" #include "MooseMatrix2x2.h" #include "MooseMatrix3x3.h" #include "MooseMatrix4x4.h" #include "MooseOGLConsts.h" #include "MooseOGLRenderer.h" #include "MooseObjectCounter.h" #include "MooseQuaternion.h" #if !defined(MOOSE_APPLE_IPHONE) #include "MooseSDLScreen.h" #endif #include "MooseOrientable.h" #include "MooseDimensional1D.h" #include "MooseDimensional2D.h" #include "MooseDimensional3D.h" #include "MooseOneDirectional.h" #include "MoosePositional.h" #include "MooseTriangle.h" #include "MooseVertex.h" #include "MooseTGAImage.h" #include "MooseVector2.h" #include "MooseVector3.h" #include "MooseVector4.h" #include "MooseVertexDescriptor.h" #include "MooseDefaultEntities.h" #include "MooseCollision.h" #include <MooseSphereCollider.h> #include <MooseOBBCollider.h> #include <MooseCompoundCollider.h> #include <MooseCapsuleCollider.h> #include "MooseMilkshapeLoader.h" #include "MooseAmbientLight.h" #include "MooseDirectionalLight.h" #include "MoosePointLight.h" #include "MooseSpotLight.h" #include "MooseGraphNode.h" #include "MooseGraphEdge.h" #include "MooseGraph.h" #include "MooseOctree.h" #include "MooseSpatialGraph.h" #include "MooseSkybox.h" #include "MooseRenderQueue.h" #include "MooseGameObject.h" #include <MooseRenderableProperty.h> #include "MooseRenderableModel.h" #include "MooseRenderableModelShared.h" #include "MooseClearBuffers.h" #include "MooseBoxRenderable.h" #include "MooseSphereRenderable.h" #include "MooseLineRenderable.h" #include "MooseCapsuleRenderable.h" #include "MooseTransform.h" #include "MooseTransformGraph.h" #include "MooseSpatialGraph.h" #include "MooseScene.h" #include "MooseParticleSystem.h" #include "MooseParticleSystemRenderable.h" #include "MooseUpdateable.h" #if !defined(MOOSE_APPLE_IPHONE) #include "MooseStateMachine.h" #endif #include "MooseModelHelper.h" #include "MooseDDSImage.h" /* These aren't implemented yet.*/ #ifndef __APPLE__ #include "MooseFFMpeg.h" #include "MooseRenderableVideo.h" #endif #include "MooseMessageSystem.h" #include "MooseAIScript.h" #include "MooseCollisionEvent.h" #include "MooseModelLoader.h" #include "MooseObjLoader.h" #include <MooseOpenAssetImportLoader.h> #include <MooseALObjectArray.h> #include <MooseALSampleTypes.h> #include <MooseALSoundTypes.h> #include <MooseAudioSystem.h> #include <MooseListener.h> #include <MooseOggSample.h> #include <MooseOggStreamSample.h> #include <MooseSoundBase.h> #include <MooseSoundSampleBase.h> //#include <MooseFlock.h> #include <MooseLog.h> #include <MooseLogger.h> #include <MooseBoxBound.h> #include <MooseSphereBound.h> #include <MooseApplication.h> #include <MooseEventQueue.h> #include <MooseDirectionalLightObject.h> #include <MoosePointLightObject.h> #include <MoosePlane.h> #include <MooseLine.h> #include <MooseLineSegment.h> #include <MooseQuad.h> #include <MooseRay.h> #include <MooseGrid.h> #include <MooseTransformIndicator.h> #include <MooseAxisObject.h> #include <MooseTextureData.h> #include <MooseTGAData.h> #include <MooseDDSData.h> #include <MooseCatmullRomSpline.h> #if defined(MOOSE_APPLE_IPHONE) #include <MoosePNGData.h> #include <MooseIPhoneAudioSample.h> #include <MooseMusicClip.h> #endif /////////////////////////////////////////////////////////////////
/* * This file is part of Luma3DS * Copyright (C) 2016-2020 Aurora Wright, TuxSH * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * Additional Terms 7.b and 7.c of GPLv3 apply to this file: * * Requiring preservation of specified reasonable legal notices or * author attributions in that material or in the Appropriate Legal * Notices displayed by works containing it. * * Prohibiting misrepresentation of the origin of that material, * or requiring that modified versions of such material be marked in * reasonable ways as different from the original version. */ #pragma once #include "utils.h" #include "kernel.h" #include "svc.h" Result GetProcessInfoHookWrapper(u32 dummy, Handle processHandle, u32 type); Result GetProcessInfoHook(s64 *out, Handle processHandle, u32 type);
#include <stdio.h> #include "thash.h" #include<stdlib.h> // As chaves dos valores a serem armazenados #define CHAVE1 "abcd" #define CHAVE2 "xyz2" #define CHAVE3 "3qwert" // Tamanho default da tabela #define CAPACIDADE 5 // Funcao para converter os dados armazenados em strings char* mostra(void * p) { return (char*)p; } char* func (void *p){ return (char*)p; } int main(int argc, char ** argv) { THash tab; int capacidade; if (argc < 2) capacidade = CAPACIDADE; else { if (sscanf(argv[1], "%d", &capacidade) < 1) capacidade = CAPACIDADE; } tab = criaTabela(capacidade); adicionaItemTabela(tab, CHAVE1, "primeira frase"); adicionaItemTabela(tab, CHAVE2, "segunda frase"); adicionaItemTabela(tab, CHAVE3, "terceira frase"); printf("tab[%s]=%s\n", CHAVE1, (char*)obtemItemTabela(tab, CHAVE1)); printf("tab[%s]=%s\n", CHAVE2, (char*)obtemItemTabela(tab, CHAVE2)); printf("tab[%s]=%s\n", CHAVE3, (char*)obtemItemTabela(tab, CHAVE3)); removeItemTabela(tab, CHAVE1); printf("tab[%s]=%s\n", CHAVE1, (char*)obtemItemTabela(tab, CHAVE1)); printf("tab[%s]=%s\n", CHAVE2, (char*)obtemItemTabela(tab, CHAVE2)); printf("tab[%s]=%s\n", CHAVE3, (char*)obtemItemTabela(tab, CHAVE3)); puts(""); mostraTabela(tab, NULL); puts(""); mostraTabela(tab, mostra); destroiTabela(tab); printf("tab[%s]=%s\n", CHAVE1, (char*)obtemItemTabela(tab, CHAVE1)); printf("tab[%s]=%s\n", CHAVE2, (char*)obtemItemTabela(tab, CHAVE2)); printf("tab[%s]=%s\n", CHAVE3, (char*)obtemItemTabela(tab, CHAVE3)); return 0; }
/** Copyright (c) 2011 Mellanox Technologies. All rights reserved. $COPYRIGHT$ Additional copyrights may follow $HEADER$ */ #ifndef MCA_COLL_FCA_DEBUG_H #define MCA_COLL_FCA_DEBUG_H #pragma GCC system_header #ifdef __BASE_FILE__ #define __FCA_FILE__ __BASE_FILE__ #else #define __FCA_FILE__ __FILE__ #endif #define FCA_VERBOSE(level, format, ...) \ opal_output_verbose(level, mca_coll_fca_output, "%s:%d - %s() " format, \ __FCA_FILE__, __LINE__, __FUNCTION__, ## __VA_ARGS__) #define FCA_ERROR(format, ... ) \ opal_output_verbose(0, mca_coll_fca_output, "Error: %s:%d - %s() " format, \ __FCA_FILE__, __LINE__, __FUNCTION__, ## __VA_ARGS__) #define FCA_MODULE_VERBOSE(fca_module, level, format, ...) \ FCA_VERBOSE(level, "[%p:%d] " format, (void*)(fca_module)->comm, (fca_module)->rank, ## __VA_ARGS__) extern int mca_coll_fca_output; #endif
/* * ArtTreeKS: Finite dimensional kinematic synthesis for articulated trees * Copyright(C) 2010-2012 Edgar Simo-Serra <esimo@iri.upc.edu> * License: see synthesis.h */ #include "mapmask.h" #include <string.h> #include <malloc.h> #include <stdlib.h> static void* memdup( const void *base, size_t size ) { void *mem; if (size == 0) return NULL; mem = malloc( size ); memcpy( mem, base, size ); return mem; } int mm_initMap( mm_vec_t *mm, size_t chunk, int map_len, void *map_vec, const int *map_map, int mask_len ) { int i; /* Duplicate the new data. */ mm->chunk = chunk; mm->map_len = map_len; mm->map_vec = memdup( map_vec, mm->map_len * mm->chunk ); mm->map_map = memdup( map_map, mm->map_len * sizeof(int) ); /* Create the mask and map the vector. */ mm->mask_len = mask_len; mm->mask_vec = calloc( mm->mask_len, mm->chunk ); mm->mask_mask = calloc( mm->mask_len, sizeof(int) ); for (i=0; i<mm->map_len; i++) mm->mask_mask[ mm->map_map[i] ] = 1; /* Synchronize data. */ mm_updateMask( mm ); return 0; } int mm_initMask( mm_vec_t *mm, size_t chunk, int mask_len, void *mask_vec, const int *mask_mask ) { int i, j; /* Duplicate new data. */ mm->chunk = chunk; mm->mask_len = mask_len; mm->mask_vec = memdup( mask_vec, mm->mask_len * mm->chunk ); if (mask_mask == NULL) { mm->mask_mask = malloc( mm->mask_len * sizeof(int) ); for (i=0; i<mm->mask_len; i++) ((int*)mm->mask_mask)[i] = 1; } else mm->mask_mask = memdup( mask_mask, mm->mask_len * sizeof(int) ); /* Create the map. */ mm->map_len = 0; for (i=0; i<mm->mask_len; i++) if (mm->mask_mask[i]) mm->map_len++; mm->map_vec = calloc( mm->map_len, mm->chunk ); mm->map_map = calloc( mm->map_len, sizeof(int) ); j = 0; for (i=0; i<mm->mask_len; i++) if (mm->mask_mask[i]) mm->map_map[ j++ ] = i; /* Synchronize data. */ mm_updateMap( mm ); return 0; } int mm_initDup( mm_vec_t *mm, const mm_vec_t *in ) { mm->chunk = in->chunk; mm->mask_len = in->mask_len; mm->mask_vec = memdup( in->mask_vec, in->chunk * in->mask_len ); mm->mask_mask = memdup( in->mask_mask, in->mask_len * sizeof(int) ); mm->map_len = in->map_len; mm->map_vec = memdup( in->map_vec, in->chunk * in->map_len ); mm->map_map = memdup( in->map_map, in->map_len * sizeof(int) ); return 0; } void mm_cleanup( mm_vec_t *mm ) { free( mm->map_vec ); free( mm->map_map ); free( mm->mask_vec ); free( mm->mask_mask ); } int mm_updateMap( mm_vec_t *mm ) { int i; if (mm->chunk == 0) return 1; for (i=0; i<mm->map_len; i++) memcpy( mm->map_vec + mm->chunk*i, mm->mask_vec + mm->chunk*mm->map_map[i], mm->chunk ); return 0; } int mm_updateMask( mm_vec_t *mm ) { int i; if (mm->chunk == 0) return 1; for (i=0; i<mm->map_len; i++) memcpy( mm->mask_vec + mm->chunk*mm->map_map[i], mm->map_vec + mm->chunk*i, mm->chunk ); return 0; } #if 0 #include <assert.h> #include <stdio.h> #include <stdlib.h> static int print_mm( mm_vec_t *mm ) { int i; double *d, *t; d = calloc( mm->chunk, mm->mask_len ); t = (double*) mm->map_vec; for (i=0; i<mm->map_len; i++) memcpy( &d[ mm->map_map[i] ], mm->map_vec + mm->chunk*i, sizeof(double) ); printf( "map: " ); for (i=0; i<mm->mask_len; i++) printf( "%.0f, ", d[i] ); printf( "\n" ); memset( d, 0, mm->chunk * mm->mask_len ); t = (double*) mm->mask_vec; for (i=0; i<mm->mask_len; i++) if (mm->mask_mask[i]) memcpy( &d[i], mm->mask_vec + mm->chunk*i, sizeof(double) ); printf( "mask: " ); for (i=0; i<mm->mask_len; i++) printf( "%.0f, ", d[i] ); printf( "\n" ); free(d); return 0; } static const char* mm_compare( const mm_vec_t *mma, const mm_vec_t *mmb ) { if (mma->chunk != mmb->chunk) return "Chunk mismatch"; if (mma->map_len != mmb->map_len) return "Map len mismatch"; if (mma->mask_len != mmb->mask_len) return "Mask len mismatch"; /* Map. */ if (memcmp( mma->map_vec, mmb->map_vec, mma->chunk * mma->map_len )) return "Map vec mismatch"; if (memcmp( mma->map_map, mmb->map_map, sizeof(int) * mma->map_len )) return "Map map misamtch"; /* Mask. */ if (memcmp( mma->mask_vec, mmb->mask_vec, mma->chunk * mma->mask_len )) return "Mask vec mismatch"; if (memcmp( mma->mask_mask, mmb->mask_mask, sizeof(int) * mma->mask_len )) return "Mask mask mismatch"; return NULL; } int main (void) { double *d, map_vec[6] = { 1., 2., 3., 4., 5., 6. }; int map_map[6] = { 1, 3, 5, 7, 9, 11 }; double mask_vec[12] = { 0., 1., 0., 2., 0., 3., 0., 4., 0., 5., 0., 6. }; int mask_mask[12] = { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 }; mm_vec_t mma, mmb; const char *ret; /* Test load. */ mm_initMap( &mma, sizeof(double), 6, map_vec, map_map, 12 ); mm_initMask( &mmb, sizeof(double), 12, mask_vec, mask_mask ); ret = mm_compare( &mma, &mmb ); if (ret != NULL) { printf( "%s\n", ret ); printf( "MMA\n" ); print_mm( &mma ); printf( "MMB\n" ); print_mm( &mmb ); } /* Test manipulate map. */ d = (double*) mma.map_vec; d[0] = 6.; d[5] = 1.; mm_updateMask( &mma ); d = (double*) mmb.mask_vec; d[1] = 6.; d[11] = 1.; mm_updateMap( &mmb ); ret = mm_compare( &mma, &mmb ); if (ret != NULL) { printf( "%s\n", ret ); printf( "MMA\n" ); print_mm( &mma ); printf( "MMB\n" ); print_mm( &mmb ); } mm_cleanup( &mma ); mm_cleanup( &mmb ); return 0; } #endif
#pragma once #include <cstdlib> //NULL #include <string> class Base { public: Base() { } ; virtual ~Base() { } ; virtual bool execute() = 0; virtual std::string getExecutable() = 0; };
#ifndef TEXTFACTORY_GLOBAL_H #define TEXTFACTORY_GLOBAL_H #include <QtCore/qglobal.h> #if defined(TEXTFACTORY_LIBRARY) # define TEXTFACTORYSHARED_EXPORT Q_DECL_EXPORT #else # define TEXTFACTORYSHARED_EXPORT Q_DECL_IMPORT #endif #endif // TEXTFACTORY_GLOBAL_H
#ifndef BIRD_H #define BIRD_H #include <gameitem.h> #include <QPixmap> #include <QGraphicsScene> #include <QTimer> #define BIRD_DENSITY 10.0f #define BIRD_FRICTION 0.2f #define BIRD_RESTITUTION 0.5f class enemy : public GameItem { public: enemy(float x, float y, float radius, QTimer *timer, QPixmap pixmap, b2World *world, QGraphicsScene *scene); void setLinearVelocity(b2Vec2 velocity); }; #endif // BIRD_H
#ifndef BASELINETIMEPLANEIMAGER_H #define BASELINETIMEPLANEIMAGER_H #include <complex> #include <AOFlagger/msio/image2d.h> template<typename NumType> class BaselineTimePlaneImager { public: void Image(NumType uTimesLambda, NumType vTimesLambda, NumType wTimesLambda, NumType lowestFrequency, NumType frequencyStep, size_t channelCount, const std::complex<NumType> *data, Image2D &output); private: template<typename T> static T frequencyToWavelength(const T frequency) { return speedOfLight() / frequency; } static long double speedOfLight() { return 299792458.0L; } }; #endif
#include <stdio.h> #define MAXLINE 1000 int getlinee(char line[], int max); int stringdex(char source[], char searchfor[]); char pattern[] = "ould"; main() { char line[MAXLINE]; int found = 0; while (getlinee(line, MAXLINE) > 0) if ( strindex(line, pattern) >= 0) { printf("%s", line); found++; } return found; } int getlinee(char s[], int lim) { int c,i; i = 0; while (--lim > 0 && (c = getchar()) != 'q' && c != '\n') s[i++] = c; if (c == '\n') s[i++] = c; s[i] = '\0'; return i; } int strindex(char s[], char t[]) { int i, j, k; for (i = 0; s[i] != '\0'; i++) { for (j=i, k=0; t[k] != '\0' && s[j] == t[k]; j++, k++) if (k > 0 && t[k] == '\0') return i; } return -1; }
#pragma once #include "GLObject.h" #include "GLContext.h" #include "MessageList.h" class GLPrintf { public: static QString requiredVersion() { return "#version 430"; } static QString preamble(); const char *bufferBindingName() const { return "_printfBuffer"; } const GLObject &bufferObject() const { return mBufferObject; } bool isUsed() const { return mIsUsed; } QString patchSource(const QString &fileName, const QString &source); void clear(); MessagePtrSet formatMessages(ItemId callItemId); private: static const auto maxBufferValues = 1024 - 2; struct ParsedFormatString { QStringList text; QStringList argumentFormats; QString fileName; int line; }; struct Argument { uint32_t type; QList<uint32_t> values; }; static ParsedFormatString parseFormatString(QStringView string); static QString formatMessage(const ParsedFormatString &format, const QList<Argument>& arguments); bool mIsUsed{ }; QList<ParsedFormatString> mFormatStrings; GLObject mBufferObject; };
/* * JsNameAddrObjectFactory.h * * Created on: Jul 9, 2013 * Author: dcampbell */ #ifndef JSNAMEADDROBJECTFACTORY_H_ #define JSNAMEADDROBJECTFACTORY_H_ #include "JsObjectFactory.h" #include <resip/stack/SipMessage.hxx> #include "JsProxyBase.h" namespace jessip { class JsNameAddrObjectFactory : public jessip::JsObjectFactory { public: JsNameAddrObjectFactory(); virtual ~JsNameAddrObjectFactory(); virtual v8::Handle<v8::Value> createObjectInstance( const char* address); protected: virtual JsProxyBase* onCreateProxyObject(); virtual void onAddTemplateMethods(v8::Handle<v8::ObjectTemplate> temp); }; } /* namespace jessip */ #endif /* JSNAMEADDROBJECTFACTORY_H_ */
#ifndef __BASEGE_MATRIX4_H__ #define __BASEGE_MATRIX4_H__ ////////////////////////////////////////////////////////////////////////////// // // MATRIX4.H // // Copyright © 2006, Rehno Lindeque. All rights reserved. // ////////////////////////////////////////////////////////////////////////////// /* DOCUMENTATION */ /* DESCRIPTION: 4x4 Matrix class DEPENDENCIES: math.h must be used TODO: + Possibly move the transformation operations to a LinearTransformation class inherriting from Matrix4, since it isn't "pure" (in the object-oriented sense: a matrix is a math class not a transformation) */ /* FUNCTIONS */ template<class Type> inline _Matrix4<Type> operator * (Type arg, const _Matrix4<Type>& m); /* CLASSES */ template<class Type = float> class _Matrix4 { protected: typedef _Matrix4<Type> Matrix4; #pragma pack(push,1) union { struct { union { struct { Type _00, _01, _02, _03; }; }; union { struct { Type _10, _11, _12, _13; }; }; union { struct { Type _20, _21, _22, _23; }; }; union { struct { Type _30, _31, _32, _33; }; }; }; Type m[4][4]; }; #pragma pack(pop) public: // constructors inline _Matrix4() {} inline _Matrix4(const Type* f); inline _Matrix4(const _Matrix4& m); inline _Matrix4(Type _00, Type _01, Type _02, Type _03, Type _10, Type _11, Type _12, Type _13, Type _20, Type _21, Type _22, Type _23, Type _30, Type _31, Type _32, Type _33); inline void set(Type _00, Type _01, Type _02, Type _03, Type _10, Type _11, Type _12, Type _13, Type _20, Type _21, Type _22, Type _23, Type _30, Type _31, Type _32, Type _33); inline void set(const Type* f); // destructor inline ~_Matrix4() {} // access grants inline Type& operator() (uint row, uint col); inline Type operator() (uint row, uint col) const; inline Type& operator() (uint n); inline Type operator() (uint n) const; // type casts inline operator const Type* () const; // assignment operators inline _Matrix4& operator *= (const _Matrix4& m); // todo: inline _Matrix4& operator /= (const _Matrix4& m); // Matrix reduction i.e. reduce [ this | m ] ~ [ I | Result ], returning Result (Note I / Matrix will give the matrix inverse Matrix^-1) inline _Matrix4& operator += (const _Matrix4& m); inline _Matrix4& operator -= (const _Matrix4& m); inline _Matrix4& operator *= (Type arg); inline _Matrix4& operator /= (Type arg); // binary operators inline _Matrix4 operator * (const _Matrix4& m) const; //Matrix concatenation // todo: inline Matrix4 operator / (const Matrix4& m); // Matrix reduction i.e. reduce [ this | m ] ~ [ I | Result ], returning Result (Note I / Matrix will give the matrix inverse Matrix^-1) inline _Matrix4 operator + (const _Matrix4& m) const; inline _Matrix4 operator - (const _Matrix4& m) const; inline _Matrix4 operator * (Type arg) const; inline _Matrix4 operator / (Type arg) const; #ifndef MSVC_BUILD template<Type> #endif friend _Matrix4 operator * (Type arg, const _Matrix4& m); // matrix operations inline _Matrix4& inverse(); inline _Matrix4& transpose(); inline Type getDeterminant() const; // transformation operations inline _Matrix4& setIdentity(); inline _Matrix4& setClear(); inline _Matrix4& setView(const _Vector3<Type>& Eye, const _Vector3<Type>& LookAt, const _Vector3<Type>& Up); /* Up must be normalized */ inline _Matrix4& setPerspectiveProjectionFOV(Type YFOV, Type AspectRatio, Type ZNearPlane, Type ZFarPlane); inline _Matrix4& setPerspectiveProjection(Type ViewWidth, Type ViewHeight, Type ZNearPlane, Type ZFarPlane); inline _Matrix4& setPerspectiveProjection(Type MinX, Type MaxX, Type MinY, Type MaxY, Type MinZ, Type MaxZ); inline _Matrix4& setOrthoProjection(Type ViewWidth, Type ViewHeight, Type ZNearPlane, Type ZFarPlane); inline _Matrix4& setOrthoProjection(Type MinX, Type MaxX, Type MinY, Type MaxY, Type MinZ, Type MaxZ); inline _Matrix4& setTranslation(Type x, Type y, Type z); inline _Matrix4& setTranslation(_Vector3<Type>& v); inline _Matrix4& setRotationX(Type angle); inline _Matrix4& setRotationY(Type angle); inline _Matrix4& setRotationZ(Type angle); inline _Matrix4& setAxisRotation(const _Vector3<Type>& Axis, Type angle); inline _Matrix4& setScaling(Type x, Type y, Type z); }; typedef _Matrix4<float> Matrix4; typedef _Matrix4<float> Matrix4f; typedef _Matrix4<double> Matrix4d; #endif
#pragma once /// Game loop #include <Re\Game\Effect\EffectLambda.h> #include <Re\Game\State\GameStateLambda.h> /// Bt #include <Re\Ai\BehaviourTree\Leaf\BtLeafLambda.h> #include <Re\Ai\BehaviourTree\Decorator\BtDecoratorLambda.h>
///////////// Copyright � 2008, Goldeneye: Source. All rights reserved. ///////////// // // File: ge_player_shared.h // Description: // see ge_player_shared.cpp // // Created On: 23 Feb 08, 17:20 // Created By: Jonathan White <killermonkey> ///////////////////////////////////////////////////////////////////////////// #ifndef GE_PLAYER_SHARED_H #define GE_PLAYER_SHARED_H #pragma once #define GE_PUSHAWAY_THINK_INTERVAL (1.0f / 20.0f) #include "studio.h" #if defined( CLIENT_DLL ) #define CGEPlayer C_GEPlayer #define CGEMPPlayer C_GEMPPlayer #define CGEBotPlayer C_GEBotPlayer #endif class C_GEPlayer; enum { AIM_NONE, AIM_ZOOM_IN, AIM_ZOOMED, AIM_ZOOM_OUT }; #define WEAPON_ZOOM_RATE 180.0f #endif //GE_PLAYER_SHARED_h
/* Unix SMB/CIFS implementation. SMB torture tester - header file Copyright (C) Andrew Tridgell 1997-1998 Copyright (C) Jeremy Allison 2009 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __TORTURE_H__ #define __TORTURE_H__ struct cli_state; /* The following definitions come from torture/denytest.c */ bool torture_denytest1(int dummy); bool torture_denytest2(int dummy); /* The following definitions come from torture/mangle_test.c */ bool torture_mangle(int dummy); /* The following definitions come from torture/nbio.c */ double nbio_total(void); void nb_alarm(int ignore); void nbio_shmem(int n); void nb_setup(struct cli_state *cli); void nb_unlink(const char *fname); void nb_createx(const char *fname, unsigned create_options, unsigned create_disposition, int handle); void nb_writex(int handle, int offset, int size, int ret_size); void nb_readx(int handle, int offset, int size, int ret_size); void nb_close(int handle); void nb_rmdir(const char *fname); void nb_rename(const char *oldname, const char *newname); void nb_qpathinfo(const char *fname); void nb_qfileinfo(int fnum); void nb_qfsinfo(int level); void nb_findfirst(const char *mask); void nb_flush(int fnum); void nb_deltree(const char *dname); void nb_cleanup(void); /* The following definitions come from torture/scanner.c */ bool torture_trans2_scan(int dummy); bool torture_nttrans_scan(int dummy); /* The following definitions come from torture/torture.c */ bool smbcli_parse_unc(const char *unc_name, TALLOC_CTX *mem_ctx, char **hostname, char **sharename); bool torture_open_connection(struct cli_state **c, int conn_index); bool torture_init_connection(struct cli_state **pcli); bool torture_cli_session_setup2(struct cli_state *cli, uint16 *new_vuid); bool torture_close_connection(struct cli_state *c); bool torture_ioctl_test(int dummy); bool torture_chkpath_test(int dummy); NTSTATUS torture_setup_unix_extensions(struct cli_state *cli); /* The following definitions come from torture/utable.c */ bool torture_utable(int dummy); bool torture_casetable(int dummy); /* * Misc */ bool run_posix_append(int dummy); bool run_case_insensitive_create(int dummy); bool run_nbench2(int dummy); bool run_async_echo(int dummy); bool run_smb_any_connect(int dummy); bool run_addrchange(int dummy); bool run_notify_online(int dummy); bool run_nttrans_create(int dummy); bool run_nttrans_fsctl(int dummy); bool run_smb2_basic(int dummy); bool run_smb2_negprot(int dummy); bool run_smb2_session_reconnect(int dummy); bool run_smb2_tcon_dependence(int dummy); bool run_smb2_multi_channel(int dummy); bool run_smb2_session_reauth(int dummy); bool run_chain3(int dummy); bool run_local_conv_auth_info(int dummy); bool run_local_sprintf_append(int dummy); bool run_cleanup1(int dummy); bool run_cleanup2(int dummy); bool run_cleanup3(int dummy); bool run_cleanup4(int dummy); bool run_ctdb_conn(int dummy); bool run_notify_bench2(int dummy); bool run_notify_bench3(int dummy); bool run_dbwrap_watch1(int dummy); bool run_idmap_tdb_common_test(int dummy); bool run_local_dbwrap_ctdb(int dummy); bool run_qpathinfo_bufsize(int dummy); bool run_bench_pthreadpool(int dummy); #endif /* __TORTURE_H__ */
// This file is part of FIREwork // // FIREwork 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. // // FIREwork 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 FIREwork. If not, see <http://www.gnu.org/licenses/>. // // FIREwork Copyright (C) 2008 - 2011 Julien Bert #include <stdio.h> void convert_root2bin(char* src, char* trg) { Int_t crystalID1; Int_t crystalID2; Int_t rsectorID1; Int_t rsectorID2; Float_t globalPosX1; Float_t globalPosX2; Float_t globalPosY1; Float_t globalPosY2; Float_t globalPosZ1; Float_t globalPosZ2; Double_t time1; Double_t time2; Int_t nbytes = 0; Int_t nbevents; Int_t i; FILE * output; // prepare output output = fopen(trg, "ab"); // Open tree file TFile *f = new TFile(src); TTree *T = (TTree*)f->Get("Coincidences"); // Bind variables T->SetBranchAddress("crystalID1", &crystalID1); T->SetBranchAddress("crystalID2", &crystalID2); T->SetBranchAddress("rsectorID1", &rsectorID1); T->SetBranchAddress("rsectorID2", &rsectorID2); T->SetBranchAddress("globalPosX1", &globalPosX1); T->SetBranchAddress("globalPosX2", &globalPosX2); T->SetBranchAddress("globalPosY1", &globalPosY1); T->SetBranchAddress("globalPosY2", &globalPosY2); T->SetBranchAddress("globalPosZ1", &globalPosZ1); T->SetBranchAddress("globalPosZ2", &globalPosZ2); T->SetBranchAddress("time1", &time1); T->SetBranchAddress("time2", &time2); Int_t nbevents = T->GetEntries(); printf("Number of events: %i\n", nbevents); // Read leafs //nbevents = 10000; for (i=0; i<nbevents; ++i) { nbytes += T->GetEntry(i); //fprintf(output, "%i %i %i %i %f %f %f %f %f %f %le %le\n", crystalID1, crystalID2, rsectorID1, rsectorID2, globalPosX1, globalPosX2, globalPosY1, globalPosY2, globalPosZ1, globalPosZ2, time1, time2); //fprintf(output, "%f %f %f %f %f %f %le %le\n", globalPosX1, globalPosY1, globalPosZ1, globalPosX2, globalPosY2, globalPosZ2, time1, time2); //fprintf(output, "%i %i %i %i\n", crystalID1, rsectorID1, crystalID2, rsectorID2); fwrite(&crystalID1, sizeof(int), 1, output); fwrite(&rsectorID1, sizeof(int), 1, output); fwrite(&crystalID2, sizeof(int), 1, output); fwrite(&rsectorID2, sizeof(int), 1, output); } fclose(output); }
/* * EventAddPlayer.h * * Created on: 4 sept. 2010 * Author: fred */ #ifndef EIN_EVENT_PRIMARY_ACTION_END_H_ #define EIN_EVENT_PRIMARY_ACTION_END_H_ #include <einheri/common/Event.h> #include <einheri/common/Player.h> namespace ein { class EventVisitor; class EventPrimaryActionEnd : public Event{ public: EventPrimaryActionEnd(Player *player); virtual ~EventPrimaryActionEnd(); void accept(EventVisitor& visitor)const; Player *GetPlayer() const { return player; } private: Player * player; }; } #endif /* EIN_EVENT_PRIMARY_ACTION_END_H_ */
// RUN: %clang_cc1 -O1 -triple x86_64-none-linux-gnu -emit-llvm -debug-info-kind=line-tables-only %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=LIFETIME // We shouldn't have markers at -O0 or with msan. // RUN: %clang_cc1 -O0 -triple x86_64-none-linux-gnu -emit-llvm -debug-info-kind=line-tables-only %s -o - | FileCheck %s --check-prefix=CHECK // RUN: %clang_cc1 -O1 -triple x86_64-none-linux-gnu -emit-llvm -debug-info-kind=line-tables-only %s -o - -fsanitize=memory | FileCheck %s --check-prefix=CHECK // There is no exception to handle here, lifetime.end is not a destructor, // so there is no need have cleanup dest slot related code // CHECK-LABEL: define i32 @test int test() { int x = 3; int *volatile p = &x; return *p; // CHECK: [[X:%.*]] = alloca i32 // CHECK: [[P:%.*]] = alloca i32* // LIFETIME: call void @llvm.lifetime.start(i64 4, i8* %{{.*}}){{( #[0-9]+)?}}, !dbg // LIFETIME: call void @llvm.lifetime.start(i64 8, i8* %{{.*}}){{( #[0-9]+)?}}, !dbg // CHECK-NOT: store i32 %{{.*}}, i32* %cleanup.dest.slot // LIFETIME: call void @llvm.lifetime.end(i64 8, {{.*}}){{( #[0-9]+)?}}, !dbg // LIFETIME: call void @llvm.lifetime.end(i64 4, {{.*}}){{( #[0-9]+)?}}, !dbg }
/* Brain Rarely Accepts Incoherent Nonsense (BRAIN) Copyright 2012-2013 Joshua Hawcroft This file is part of BRAIN. BRAIN 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. BRAIN 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 BRAIN. If not, see <http://www.gnu.org/licenses/>. */ /* initalization and shutdown routines */ #include "common.h" NLContext g_nl_context; int nl_startup(void) { memset(&g_nl_context, 0, sizeof(NLContext)); void nli_load_bi_plugs_(void); nli_load_bi_plugs_(); return NL_OK; } int nl_shutdown(void) { return NL_OK; }
/* This file is part of visgeom. visgeom 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. visgeom 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 visgeom. If not, see <http://www.gnu.org/licenses/>. */ /* SLAM system */ #pragma once #include "std.h" #include "eigen.h" #include "ocv.h" #include "reconstruction/depth_map.h" #include "geometry/geometry.h" #include "projection/generic_camera.h" #include "projection/eucm.h" #include "reconstruction/depth_map.h" #include "reconstruction/eucm_motion_stereo.h" #include "reconstruction/eucm_sgm.h" #include "localization/sparse_odom.h" #include "localization/photometric.h" struct MappingParameters { MappingParameters(const ptree & params) { for (auto & item : params) { const string & pname = item.first; if (pname == "new_kf_distance_thresh") distThreshSq = pow(item.second.get_value<double>(), 2); else if (pname == "new_kf_angular_thresh") angularThreshSq = pow(item.second.get_value<double>(), 2); else if (pname == "min_init_dist") minInitDist = item.second.get_value<double>(); else if (pname == "min_stereo_base") minStereoBase = item.second.get_value<double>(); else if (pname == "dist_thresh") maxDistance = item.second.get_value<double>(); else if (pname == "normalize_scale") normalizeScale = item.second.get_value<bool>(); } } MappingParameters() {} //defines the conditions for the new frame instantiation double distThreshSq = 0.03; double angularThreshSq = 0.25; //minimum distance to initialize the depth map and the whole system double minInitDist = 0.1; //if the stereo base is below the stereo is not computed double minStereoBase = 0.07; //beyond this distance the points are not used for the localization double maxDistance = 5; bool normalizeScale = true; }; struct Frame { Mat8u img; Transf xi; //the position is defined in the global frame }; //Speed estimation and extrapolation are to be added //Assumed that the data arrives in the chronological order class PhotometricMapping { public: PhotometricMapping(const ptree & params); //true if the frame has been inserted bool constructMap(const Transf & xi, const Mat8u & img); void feedOdometry(const Transf & xi); void feedImage(const Mat8u & img); void pushInterFrame(const Mat8u & img); void reInit(const Transf & xi); int selectMapFrame(const Transf & xi, const double K = 4); //-1 means that there is no matching frame Transf localizeMI(); //localizes the inter frame wrt _frameVec[_mapIdx] Transf localizePhoto(const Mat8u & img); //localizes the image wrt interFrame Transf getCameraMotion(const Transf & xi) const; bool checkDistance(const Transf & xi, const double K = 1.) const; bool checkDistance(const Transf & xi1, const Transf & xi2, const double K = 1.) const; void improveStereo(const Mat8u & img); //private: enum State {MAP_BEGIN, MAP_INIT, MAP_LOCALIZE, MAP_SLAM}; enum WarningType {WARNING_NONE, WARNING_SCALE, WARNING_ROTATION}; MappingParameters _params; EnhancedCamera * _camera; //state variables State _state; WarningType _warningState; int _mapIdx; //currently active map frame bool _odomInit; Frame _interFrame; vector<Frame> _frameVec; DepthMap _depth; Transf _xiLocal; //current base pose estimation in the local frame Transf _xiLocalOld; //for VO scale rectification Transf _xiOdom; //the last odometry measure Transf _zetaOdom; //the last odometry measure Transf _xiOdomImage; //the last odometry before the last image Transf _xiBaseCam; //utils //are used to create an Sgm object to init the keyframe SgmParameters _sgmParams; //used to initialize the first transformation SparseOdometry _sparseOdom; //gradually improves the depth map MotionStereo _motionStereo; ScalePhotometric _localizer; };
/* * Copyright 2012 Red Hat Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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. * * Authors: Ben Skeggs */ #include "gf100.h" #include "ram.h" static const struct nvkm_fb_func gk104_fb = { .dtor = gf100_fb_dtor, .oneinit = gf100_fb_oneinit, .init = gf100_fb_init, .init_page = gf100_fb_init_page, .intr = gf100_fb_intr, .ram_new = gk104_ram_new, .memtype_valid = gf100_fb_memtype_valid, }; int gk104_fb_new(struct nvkm_device *device, int index, struct nvkm_fb **pfb) { return gf100_fb_new_(&gk104_fb, device, index, pfb); }
/* Multiple versions of strspn. PowerPC64 version. Copyright (C) 2016 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ # include <string.h> # include <shlib-compat.h> # include "init-arch.h" #undef strspn extern __typeof (strspn) __libc_strspn; extern __typeof (strspn) __strspn_ppc attribute_hidden; extern __typeof (strspn) __strspn_power8 attribute_hidden; libc_ifunc (__libc_strspn, (hwcap2 & PPC_FEATURE2_ARCH_2_07) ? __strspn_power8 : __strspn_ppc); weak_alias (__libc_strspn, strspn) libc_hidden_builtin_def (strspn)
#ifndef SENSEAREA_GLOBAL_H #define SENSEAREA_GLOBAL_H #include <QtCore/qglobal.h> #if defined(SENSEAREA_LIBRARY) # define SENSEAREASHARED_EXPORT Q_DECL_EXPORT #else # define SENSEAREASHARED_EXPORT Q_DECL_IMPORT #endif #endif // SENSEAREA_GLOBAL_H
/* This file is part of GNUnet. (C) 2009, 2011, 2012 Christian Grothoff (and other contributing authors) GNUnet 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, or (at your option) any later version. GNUnet 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 GNUnet; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * @file statistics/test_statistics_api_watch.c * @brief testcase for statistics_api.c watch functions * @author Christian Grothoff */ #include "platform.h" #include "gnunet_common.h" #include "gnunet_getopt_lib.h" #include "gnunet_os_lib.h" #include "gnunet_program_lib.h" #include "gnunet_scheduler_lib.h" #include "gnunet_statistics_service.h" static int ok; static struct GNUNET_STATISTICS_Handle *h; static struct GNUNET_STATISTICS_Handle *h2; static GNUNET_SCHEDULER_TaskIdentifier shutdown_task; static void force_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { fprintf (stderr, "Timeout, failed to receive notifications: %d\n", ok); GNUNET_STATISTICS_destroy (h, GNUNET_NO); GNUNET_STATISTICS_destroy (h2, GNUNET_NO); ok = 7; } static void normal_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_STATISTICS_destroy (h, GNUNET_NO); GNUNET_STATISTICS_destroy (h2, GNUNET_NO); } static int watch_1 (void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent) { GNUNET_assert (value == 42); GNUNET_assert (0 == strcmp (name, "test-1")); ok &= ~1; if (0 == ok) { GNUNET_SCHEDULER_cancel (shutdown_task); GNUNET_SCHEDULER_add_now (&normal_shutdown, NULL); } return GNUNET_OK; } static int watch_2 (void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent) { GNUNET_assert (value == 43); GNUNET_assert (0 == strcmp (name, "test-2")); ok &= ~2; if (0 == ok) { GNUNET_SCHEDULER_cancel (shutdown_task); GNUNET_SCHEDULER_add_now (&normal_shutdown, NULL); } return GNUNET_OK; } static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { h = GNUNET_STATISTICS_create ("dummy", cfg); GNUNET_assert (GNUNET_OK == GNUNET_STATISTICS_watch (h, "test-statistics-api-watch", "test-1", &watch_1, NULL)); GNUNET_assert (GNUNET_OK == GNUNET_STATISTICS_watch (h, "test-statistics-api-watch", "test-2", &watch_2, NULL)); h2 = GNUNET_STATISTICS_create ("test-statistics-api-watch", cfg); GNUNET_STATISTICS_set (h2, "test-1", 42, GNUNET_NO); GNUNET_STATISTICS_set (h2, "test-2", 43, GNUNET_NO); shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &force_shutdown, NULL); } int main (int argc, char *argv_ign[]) { char *const argv[] = { "test-statistics-api", "-c", "test_statistics_api_data.conf", NULL }; struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; struct GNUNET_OS_Process *proc; char *binary; binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-statistics"); proc = GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, binary, "gnunet-service-statistics", "-c", "test_statistics_api_data.conf", NULL); GNUNET_assert (NULL != proc); ok = 3; GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", options, &run, NULL); if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); ok = 1; } GNUNET_OS_process_wait (proc); GNUNET_OS_process_destroy (proc); proc = NULL; GNUNET_free (binary); return ok; } /* end of test_statistics_api_watch.c */
/****************************************************************************** * ninjastorms - shuriken operating system * * * * Copyright (C) 2013 - 2016 Andreas Grapentin et al. * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ #pragma once #ifdef HAVE_CONFIG_H # include <config.h> #endif struct task_t { // r01..r12, sp, lr, pc unsigned int reg[13]; unsigned int sp; unsigned int lr; unsigned int pc; unsigned int cpsr; }; typedef struct task_t task_t; extern task_t *current_task; int add_task (void *entrypoint); void start_scheduler (void); void schedule (void);
/* This file is part of rflpc. * * rflpc 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. * * rflpc 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 rflpc. If not, see <http://www.gnu.org/licenses/>. */ /* Author: Michael Hauspie <michael.hauspie@univ-lille1.fr> Created: 2012-03-27 */ /** @file * A implementation of srand and rand function. * This implementation is directly taken from the glibc rand_r function implementation. * http://sourceware.org/git/?p=glibc.git;a=blob;f=stdlib/rand_r.c;hb=HEAD */ #ifndef __RFLPC_RAND_H__ #define __RFLPC_RAND_H__ #ifdef RFLPC_CONFIG_ENABLE_RAND /** @ingroup libc * @{ */ #ifdef RAND_MAX #undef RAND_MAX #endif /** The maximum value of a random number. * The ::rand function generate number in [0, ::RAND_MAX] range. */ #define RAND_MAX 2147483647 /** Sets the seed used by ::rand() to generate the pseudo-random sequence. * @param seed the seed to use. */ extern void srand(unsigned int seed); /** Returns a pseudo-random integer in the range of 0 to ::RAND_MAX. * @warning this function is not reentrant! */ extern int rand(void); /** Returns a pseudo-random integer in the range of 0 to ::RAND_MAX. * @note This function is reentrant as it uses a user defined pointer for its seed. * @param seed pointer to the current value of the seed. */ extern int rand_r(unsigned int *seed); /** @} */ #endif /* ENABLE_RAND */ #endif
/* * Generated by asn1c-0.9.28 (http://lionet.info/asn1c) * From ASN.1 module "ACSE-1" * found in "../../../dumpvdl2.asn1/atn-b1_ulcs.asn1" * `asn1c -fcompound-names -fincludes-quoted -gen-PER` */ #include "ACSE-apdu.h" static asn_per_constraints_t asn_PER_type_ACSE_apdu_constr_1 GCC_NOTUSED = { { APC_CONSTRAINED | APC_EXTENSIBLE, 3, 3, 0, 4 } /* (0..4,...) */, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; static asn_TYPE_member_t asn_MBR_ACSE_apdu_1[] = { { ATF_NOFLAGS, 0, offsetof(struct ACSE_apdu, choice.aarq), (ASN_TAG_CLASS_APPLICATION | (0 << 2)), 0, &asn_DEF_AARQ_apdu, 0, /* Defer constraints checking to the member type */ 0, /* No PER visible constraints */ 0, "aarq" }, { ATF_NOFLAGS, 0, offsetof(struct ACSE_apdu, choice.aare), (ASN_TAG_CLASS_APPLICATION | (1 << 2)), 0, &asn_DEF_AARE_apdu, 0, /* Defer constraints checking to the member type */ 0, /* No PER visible constraints */ 0, "aare" }, { ATF_NOFLAGS, 0, offsetof(struct ACSE_apdu, choice.rlrq), (ASN_TAG_CLASS_APPLICATION | (2 << 2)), 0, &asn_DEF_RLRQ_apdu, 0, /* Defer constraints checking to the member type */ 0, /* No PER visible constraints */ 0, "rlrq" }, { ATF_NOFLAGS, 0, offsetof(struct ACSE_apdu, choice.rlre), (ASN_TAG_CLASS_APPLICATION | (3 << 2)), 0, &asn_DEF_RLRE_apdu, 0, /* Defer constraints checking to the member type */ 0, /* No PER visible constraints */ 0, "rlre" }, { ATF_NOFLAGS, 0, offsetof(struct ACSE_apdu, choice.abrt), (ASN_TAG_CLASS_APPLICATION | (4 << 2)), 0, &asn_DEF_ABRT_apdu, 0, /* Defer constraints checking to the member type */ 0, /* No PER visible constraints */ 0, "abrt" }, }; static const asn_TYPE_tag2member_t asn_MAP_ACSE_apdu_tag2el_1[] = { { (ASN_TAG_CLASS_APPLICATION | (0 << 2)), 0, 0, 0 }, /* aarq */ { (ASN_TAG_CLASS_APPLICATION | (1 << 2)), 1, 0, 0 }, /* aare */ { (ASN_TAG_CLASS_APPLICATION | (2 << 2)), 2, 0, 0 }, /* rlrq */ { (ASN_TAG_CLASS_APPLICATION | (3 << 2)), 3, 0, 0 }, /* rlre */ { (ASN_TAG_CLASS_APPLICATION | (4 << 2)), 4, 0, 0 } /* abrt */ }; static asn_CHOICE_specifics_t asn_SPC_ACSE_apdu_specs_1 = { sizeof(struct ACSE_apdu), offsetof(struct ACSE_apdu, _asn_ctx), offsetof(struct ACSE_apdu, present), sizeof(((struct ACSE_apdu *)0)->present), asn_MAP_ACSE_apdu_tag2el_1, 5, /* Count of tags in the map */ 0, 5 /* Extensions start */ }; asn_TYPE_descriptor_t asn_DEF_ACSE_apdu = { "ACSE-apdu", "ACSE-apdu", CHOICE_free, CHOICE_print, CHOICE_constraint, CHOICE_decode_ber, CHOICE_encode_der, CHOICE_decode_xer, CHOICE_encode_xer, CHOICE_decode_uper, CHOICE_encode_uper, CHOICE_outmost_tag, 0, /* No effective tags (pointer) */ 0, /* No effective tags (count) */ 0, /* No tags (pointer) */ 0, /* No tags (count) */ &asn_PER_type_ACSE_apdu_constr_1, asn_MBR_ACSE_apdu_1, 5, /* Elements count */ &asn_SPC_ACSE_apdu_specs_1 /* Additional specs */ };
/***************************************************************************** * desc_0a.h: ISO/IEC 13818-1 Descriptor 0x0A (ISO-639 language descriptor) ***************************************************************************** * Copyright (C) 2009-2010 VideoLAN * * Authors: Christophe Massiot <massiot@via.ecp.fr> * Georgi Chorbadzhiyski <georgi@unixsol.org> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject * to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *****************************************************************************/ /* * Normative references: * - ISO/IEC 13818-1:2007(E) (MPEG-2 Systems) */ #ifndef __BITSTREAM_MPEG_DESC_0A_H__ #define __BITSTREAM_MPEG_DESC_0A_H__ #include <bitstream/common.h> #include <bitstream/mpeg/psi/descriptors.h> #ifdef __cplusplus extern "C" { #endif /***************************************************************************** * Descriptor 0x0a: ISO-639 language descriptor *****************************************************************************/ #define DESC0A_HEADER_SIZE DESC_HEADER_SIZE #define DESC0A_LANGUAGE_SIZE 4 static inline void desc0a_init(uint8_t *p_desc) { desc_set_tag(p_desc, 0x0a); } static inline uint8_t *desc0a_get_language(uint8_t *p_desc, uint8_t n) { uint8_t *p_desc_n = p_desc + DESC0A_HEADER_SIZE + n * DESC0A_LANGUAGE_SIZE; if (p_desc_n + DESC0A_LANGUAGE_SIZE - p_desc > desc_get_length(p_desc) + DESC0A_HEADER_SIZE) return NULL; return p_desc_n; } static inline void desc0an_set_code(uint8_t *p_desc_n, const uint8_t p_code[3]) { p_desc_n[0] = p_code[0]; p_desc_n[1] = p_code[1]; p_desc_n[2] = p_code[2]; } static inline const uint8_t *desc0an_get_code(const uint8_t *p_desc_n) { return p_desc_n; } static inline void desc0an_set_audiotype(uint8_t *p_desc_n, uint8_t i_type) { p_desc_n[3] = i_type; } static inline uint8_t desc0an_get_audiotype(const uint8_t *p_desc_n) { return p_desc_n[3]; } static inline const char *desc0a_get_audiotype_txt(uint8_t audio_type) { return audio_type == 0x00 ? "undefined" : audio_type == 0x01 ? "clean effects" : audio_type == 0x02 ? "hearing impaired" : audio_type == 0x03 ? "visual impaired commentary" : "reserved"; } static inline bool desc0a_validate(const uint8_t *p_desc) { return !(desc_get_length(p_desc) % DESC0A_LANGUAGE_SIZE); } static inline void desc0a_print(uint8_t *p_desc, f_print pf_print, void *opaque, print_type_t i_print_type) { uint8_t j = 0; uint8_t *p_desc_n; while ((p_desc_n = desc0a_get_language(p_desc, j)) != NULL) { j++; switch (i_print_type) { case PRINT_XML: pf_print(opaque, "<AUDIO_LANGUAGE_DESC language=\"%3.3s\" audiotype=\"%u\" autiotype_txt=\"%s\"/>", (const char *)desc0an_get_code(p_desc_n), desc0an_get_audiotype(p_desc_n), desc0a_get_audiotype_txt(desc0an_get_audiotype(p_desc_n)) ); break; default: pf_print(opaque, " - desc 0a audio_language language=%3.3s audiotype=%u audiotype_txt=\"%s\"", (const char *)desc0an_get_code(p_desc_n), desc0an_get_audiotype(p_desc_n), desc0a_get_audiotype_txt(desc0an_get_audiotype(p_desc_n)) ); } } } #ifdef __cplusplus } #endif #endif
/***************************************************************************** * * IIDCoacam.h -- header for IEE1394/IIDC camera API * * Copyright 2013,2014,2015,2016,2017,2018,2019 * James Fidell (james@openastroproject.org) * * License: * * This file is part of the Open Astro Project. * * The Open Astro Project is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The Open Astro Project is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with the Open Astro Project. If not, see * <http://www.gnu.org/licenses/>. * *****************************************************************************/ #ifndef OA_IIDC_OACAM_H #define OA_IIDC_OACAM_H extern int oaIIDCGetCameras ( CAMERA_LIST*, unsigned long, int ); extern oaCamera* oaIIDCInitCamera ( oaCameraDevice* ); extern int oaIIDCCloseCamera ( oaCamera* ); extern int oaIIDCCameraTestControl ( oaCamera*, int, oaControlValue* ); extern int oaIIDCCameraGetControlRange ( oaCamera*, int, int64_t*, int64_t*, int64_t*, int64_t* ); extern void* oacamIIDCcontroller ( void* ); extern void* oacamIIDCcallbackHandler ( void* ); extern const FRAMESIZES* oaIIDCCameraGetFrameSizes ( oaCamera* ); extern const FRAMERATES* oaIIDCCameraGetFrameRates ( oaCamera*, int, int ); extern int oaIIDCCameraGetFramePixelFormat ( oaCamera* ); extern const char* oaIIDCCameraGetMenuString ( oaCamera*, int, int ); struct iidcCtrl { int iidcControl; int oaControl; }; extern struct iidcCtrl dc1394Controls[]; extern unsigned int numIIDCControls; struct iidcFrameRate { int iidcFrameRate; int numerator; int denominator; }; extern struct iidcFrameRate dc1394FrameRates[]; extern unsigned int numIIDCFrameRates; #endif /* OA_IIDC_OACAM_H */
#include <iostream> #include <fstream> #include <sstream> #include <vector> #include <cstring> #include <algorithm> using namespace std; #define MAX_DEPTH 8 #define RESULTS_MINDEPTH 2 #define RESULTS_LIMIT 40 class Node { public: int depth; string key; Node(int d) : next(), depth(d) {} Node * next[27]; vector<vector<string> > vals; }; class NTree { public: NTree(); int add(string code, string val); int clear(); vector<vector<string> > search(string val); void full_sort(); private: Node * root; int insert(Node * node, string key, vector<string> data); // string normalize(string val); string artikel(string val); string articolo(string val); int key_index(string s); void deep_sort(Node * node); // bool sortstrcmp(vector<string> a, vector <string> b); };
#ifndef GROUPLISTITEM_H #define GROUPLISTITEM_H #include <QWidget> namespace Ui { class GroupListItem; } class GroupListItem : public QWidget { Q_OBJECT public: explicit GroupListItem(QWidget *parent = 0); ~GroupListItem(); void set_group(QString group); void set_favorite(bool fav); signals: void join_pressed(QString group); private slots: void on_join_button_released(); void on_fav_button_clicked(bool checked); private: Ui::GroupListItem *ui; }; #endif // GROUPLISTITEM_H