hexsha
stringlengths
40
40
size
int64
22
2.4M
ext
stringclasses
5 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
3
260
max_stars_repo_name
stringlengths
5
109
max_stars_repo_head_hexsha
stringlengths
40
78
max_stars_repo_licenses
listlengths
1
9
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
3
260
max_issues_repo_name
stringlengths
5
109
max_issues_repo_head_hexsha
stringlengths
40
78
max_issues_repo_licenses
listlengths
1
9
max_issues_count
float64
1
67k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
260
max_forks_repo_name
stringlengths
5
109
max_forks_repo_head_hexsha
stringlengths
40
78
max_forks_repo_licenses
listlengths
1
9
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
22
2.4M
avg_line_length
float64
5
169k
max_line_length
int64
5
786k
alphanum_fraction
float64
0.06
0.95
matches
listlengths
1
11
db5a6db5f80fcf00be1807ef0ce9c6c63e0e88a9
3,441
h
C
aws-cpp-sdk-ec2/include/aws/ec2/model/FederatedAuthentication.h
dburken/aws-sdk-cpp
c2c03a23a7afe89e99d181872e2fa2c284237e15
[ "Apache-2.0" ]
1
2020-07-16T19:02:58.000Z
2020-07-16T19:02:58.000Z
aws-cpp-sdk-ec2/include/aws/ec2/model/FederatedAuthentication.h
novaquark/aws-sdk-cpp
a0969508545bec9ae2864c9e1e2bb9aff109f90c
[ "Apache-2.0" ]
null
null
null
aws-cpp-sdk-ec2/include/aws/ec2/model/FederatedAuthentication.h
novaquark/aws-sdk-cpp
a0969508545bec9ae2864c9e1e2bb9aff109f90c
[ "Apache-2.0" ]
null
null
null
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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. */ #pragma once #include <aws/ec2/EC2_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSStreamFwd.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <utility> namespace Aws { namespace Utils { namespace Xml { class XmlNode; } // namespace Xml } // namespace Utils namespace EC2 { namespace Model { /** * <p>Describes the IAM SAML identity provider used for federated * authentication.</p><p><h3>See Also:</h3> <a * href="http://docs.aws.amazon.com/goto/WebAPI/ec2-2016-11-15/FederatedAuthentication">AWS * API Reference</a></p> */ class AWS_EC2_API FederatedAuthentication { public: FederatedAuthentication(); FederatedAuthentication(const Aws::Utils::Xml::XmlNode& xmlNode); FederatedAuthentication& operator=(const Aws::Utils::Xml::XmlNode& xmlNode); void OutputToStream(Aws::OStream& ostream, const char* location, unsigned index, const char* locationValue) const; void OutputToStream(Aws::OStream& oStream, const char* location) const; /** * <p>The Amazon Resource Name (ARN) of the IAM SAML identity provider.</p> */ inline const Aws::String& GetSamlProviderArn() const{ return m_samlProviderArn; } /** * <p>The Amazon Resource Name (ARN) of the IAM SAML identity provider.</p> */ inline bool SamlProviderArnHasBeenSet() const { return m_samlProviderArnHasBeenSet; } /** * <p>The Amazon Resource Name (ARN) of the IAM SAML identity provider.</p> */ inline void SetSamlProviderArn(const Aws::String& value) { m_samlProviderArnHasBeenSet = true; m_samlProviderArn = value; } /** * <p>The Amazon Resource Name (ARN) of the IAM SAML identity provider.</p> */ inline void SetSamlProviderArn(Aws::String&& value) { m_samlProviderArnHasBeenSet = true; m_samlProviderArn = std::move(value); } /** * <p>The Amazon Resource Name (ARN) of the IAM SAML identity provider.</p> */ inline void SetSamlProviderArn(const char* value) { m_samlProviderArnHasBeenSet = true; m_samlProviderArn.assign(value); } /** * <p>The Amazon Resource Name (ARN) of the IAM SAML identity provider.</p> */ inline FederatedAuthentication& WithSamlProviderArn(const Aws::String& value) { SetSamlProviderArn(value); return *this;} /** * <p>The Amazon Resource Name (ARN) of the IAM SAML identity provider.</p> */ inline FederatedAuthentication& WithSamlProviderArn(Aws::String&& value) { SetSamlProviderArn(std::move(value)); return *this;} /** * <p>The Amazon Resource Name (ARN) of the IAM SAML identity provider.</p> */ inline FederatedAuthentication& WithSamlProviderArn(const char* value) { SetSamlProviderArn(value); return *this;} private: Aws::String m_samlProviderArn; bool m_samlProviderArnHasBeenSet; }; } // namespace Model } // namespace EC2 } // namespace Aws
33.735294
133
0.705609
[ "model" ]
db6ee78f07053f2b5c9539b345cd7b90c2a6c052
5,312
h
C
include/AD/gc/gcverify.h
AaronNGray/prop-cc-new
3d9660f55c94c5bd260f6b7cc902fa19109d35a9
[ "BSD-2-Clause" ]
1
2018-03-23T20:32:09.000Z
2018-03-23T20:32:09.000Z
include/AD/gc/gcverify.h
AaronNGray/prop-cc-new
3d9660f55c94c5bd260f6b7cc902fa19109d35a9
[ "BSD-2-Clause" ]
null
null
null
include/AD/gc/gcverify.h
AaronNGray/prop-cc-new
3d9660f55c94c5bd260f6b7cc902fa19109d35a9
[ "BSD-2-Clause" ]
null
null
null
////////////////////////////////////////////////////////////////////////////// // NOTICE: // // ADLib, Prop and their related set of tools and documentation are in the // public domain. The author(s) of this software reserve no copyrights on // the source code and any code generated using the tools. You are encouraged // to use ADLib and Prop to develop software, in both academic and commercial // settings, and are welcomed to incorporate any part of ADLib and Prop into // your programs. // // Although you are under no obligation to do so, we strongly recommend that // you give away all software developed using our tools. // // We also ask that credit be given to us when ADLib and/or Prop are used in // your programs, and that this notice be preserved intact in all the source // code. // // This software is still under development and we welcome(read crave for) // any suggestions and help from the users. // // Allen Leung (leunga@cs.nyu.edu) // 1994-1995 ////////////////////////////////////////////////////////////////////////////// #ifndef gc_verifier_h #define gc_verifier_h #include <AD/gc/gc.h> // garbage collector base class #include <AD/gc/gcobject.h> // garbage collectable objects ////////////////////////////////////////////////////////////////////////////// // Forward declaration. ////////////////////////////////////////////////////////////////////////////// class GCBitMap; ////////////////////////////////////////////////////////////////////////////// // This class is used to check for integrity of an GCObject. // It uses the same interface as the collector so it is derived from // class GC. ////////////////////////////////////////////////////////////////////////////// class GCVerifier : public GC { GCVerifier(const GCVerifier&); // no copy constructor void operator = (const GCVerifier&); // no assignment /////////////////////////////////////////////////////////////////////////// // Type definitions /////////////////////////////////////////////////////////////////////////// public: typedef GC Super; typedef GC::Statistics Statistics; /////////////////////////////////////////////////////////////////////////// // Internal members cached during checking /////////////////////////////////////////////////////////////////////////// protected: Bool ok; // okay flag (reset if error is found) GC * testing_gc; // the collector to test. GCBitMap * traversed; // marks all objects that have been traversed // so that circular structures can be correctly // traced. std::size_t nodes; // number of cons cells traced. /////////////////////////////////////////////////////////////////////////// // Constructor and destructor /////////////////////////////////////////////////////////////////////////// public: GCVerifier(); ~GCVerifier(); /////////////////////////////////////////////////////////////////////////// // Statistics /////////////////////////////////////////////////////////////////////////// inline std::size_t number_of_nodes() const { return nodes; } inline Bool is_okay() const { return ok; } /////////////////////////////////////////////////////////////////////////// // Name of object /////////////////////////////////////////////////////////////////////////// virtual const char * my_name() const; /////////////////////////////////////////////////////////////////////////// // Some methods for verification. /////////////////////////////////////////////////////////////////////////// virtual Bool is_valid_pointer (GCObject *, GC *); virtual Bool is_valid_interior_pointer (GCObject *, GC *); virtual Bool is_valid_structure (GCObject *, GC *); inline Bool is_valid_pointer (GCObject * obj, GC& gc) { return is_valid_pointer (obj, &gc); } inline Bool is_valid_interior_pointer (GCObject * obj, GC& gc) { return is_valid_interior_pointer (obj, &gc); } inline Bool is_valid_structure (GCObject * obj, GC& gc) { return is_valid_structure (obj, &gc); } inline Bool is_valid_pointer (GCObject * obj) { return is_valid_pointer (obj, GC::get_default_gc()); } inline Bool is_valid_interior_pointer (GCObject * obj) { return is_valid_interior_pointer (obj, GC::get_default_gc()); } inline Bool is_valid_structure (GCObject * obj) { return is_valid_structure (obj, GC::get_default_gc()); } /////////////////////////////////////////////////////////////////////////// // This is the tracing method used by the protocol. /////////////////////////////////////////////////////////////////////////// virtual GCObject * trace (GCObject *); /////////////////////////////////////////////////////////////////////////// // Redefine the following methods to report errors. They are unused. // Furthurmore, mark them private. /////////////////////////////////////////////////////////////////////////// private: virtual void * m_alloc (std::size_t); virtual void free (void *); virtual void grow_heap (std::size_t); virtual void collect (int); virtual std::size_t min_growth (); virtual Statistics statistics (); }; #endif
36.888889
78
0.460467
[ "object" ]
db77662ab22662cad39bd10e3e35f287690e0e70
7,783
c
C
d/player_houses/innaeli/rooms/bsb5.c
gesslar/shadowgate
97ce5d33a2275bb75c0cf6556602564b7870bc77
[ "MIT" ]
13
2019-07-19T05:24:44.000Z
2021-11-18T04:08:19.000Z
d/player_houses/innaeli/rooms/bsb5.c
gesslar/shadowgate
97ce5d33a2275bb75c0cf6556602564b7870bc77
[ "MIT" ]
null
null
null
d/player_houses/innaeli/rooms/bsb5.c
gesslar/shadowgate
97ce5d33a2275bb75c0cf6556602564b7870bc77
[ "MIT" ]
13
2019-09-12T06:22:38.000Z
2022-01-31T01:15:12.000Z
#include <std.h> #include "../defs.h" inherit VAULT; // The Bloody Scourage Inn (Innaeli & Anson's HM 'home') // Design Work Written by Innaeli // Put into game December 2008 :: Nienne // Wizard assisted by Lurue void fail_step(object theplayer); void pass_step(object theplayer); void create(){ ::create(); set_property("light",1); set_property("indoors",1); set_terrain(STONE_BUILDING); set_travel(PAVED_ROAD); set_name("Second Floor Landing"); set_short("%^RESET%^%^MAGENTA%^Second Floor Landing%^RESET%^"); set_long("%^RESET%^You find yourself standing on the landing of "+ "the second floor of the %^BOLD%^%^RED%^B%^RESET%^%^RED%^lo%^BOLD%^"+ "%^RED%^od%^RESET%^%^RED%^y %^BOLD%^%^BLACK%^S%^RESET%^%^RED%^c"+ "%^BOLD%^%^BLACK%^ou%^RESET%^%^RED%^rg%^BOLD%^%^BLACK%^e Inn"+ "%^RESET%^. Small alcoves in the %^BOLD%^%^BLACK%^s%^RESET%^t"+ "%^BOLD%^%^BLACK%^o%^RESET%^n%^BOLD%^%^BLACK%^e walls%^RESET%^ "+ "hold %^BOLD%^candles%^RESET%^ that provide f%^BOLD%^%^WHITE%^li"+ "%^RESET%^c%^BOLD%^%^WHITE%^k%^RESET%^in%^BOLD%^%^WHITE%^g%^RESET%^ "+ "dim light to the wide corridor. The floor is %^BOLD%^%^BLACK%^"+ "black%^RESET%^, and a %^BOLD%^%^RED%^cr%^RESET%^%^RED%^im%^BOLD%^"+ "%^RED%^s%^RESET%^%^RED%^on r%^BOLD%^%^RED%^u%^RESET%^%^RED%^nn"+ "%^BOLD%^%^RED%^er%^RESET%^ muffles the sound of footsteps. There "+ "are three doors here, and two are %^RESET%^%^ORANGE%^wooden"+ "%^RESET%^ with %^YELLOW%^b%^RESET%^%^ORANGE%^ras%^YELLOW%^s "+ "k%^RESET%^%^ORANGE%^nob%^YELLOW%^s%^RESET%^. The door to the north "+ "is arched and made from %^BOLD%^%^BLACK%^blackened ir%^RESET%^o"+ "%^BOLD%^%^BLACK%^n%^RESET%^."); set_smell("default","%^BOLD%^%^WHITE%^A light aroma lingers "+ "from the candles, and it smells vaguely of smoke and ash.%^RESET%^"); set_listen("default","%^RESET%^%^CYAN%^Sounds from the bar are "+ "quieter here.%^RESET%^"); set_items(([ ({"alcoves"}):"%^RESET%^Carved into the thick %^BOLD%^%^BLACK%^"+ "stone walls%^RESET%^, the alcoves each hold a set of %^RESET%^"+ "%^ORANGE%^ornate %^YELLOW%^g%^RESET%^%^ORANGE%^o%^YELLOW%^ld"+ "%^RESET%^%^ORANGE%^e%^YELLOW%^n ca%^RESET%^%^ORANGE%^nd%^YELLOW%^"+ "leh%^RESET%^%^ORANGE%^ol%^RESET%^%^ORANGE%^de%^YELLOW%^rs%^RESET%^"+ ", and %^BOLD%^%^BLACK%^black%^RESET%^ and %^BOLD%^%^RED%^cr"+ "%^RESET%^ims%^BOLD%^%^RED%^o%^RESET%^%^RED%^n%^BOLD%^%^WHITE%^ "+ "candles%^RESET%^ burn day and night, never appearing to deplete. "+ "%^RESET%^%^RED%^Crimson silk%^RESET%^ lines the alcoves. The "+ "cloth spills over the edges and is rather %^BOLD%^%^BLACK%^ta"+ "%^RESET%^t%^BOLD%^%^BLACK%^ter%^RESET%^e%^BOLD%^%^BLACK%^d%^RESET%^ "+ "and %^BOLD%^%^BLACK%^f%^RESET%^ra%^BOLD%^%^BLACK%^y%^RESET%^e"+ "%^BOLD%^%^BLACK%^d%^RESET%^.", ({"runner"}):"%^BOLD%^%^RED%^C%^RESET%^%^RED%^ri%^BOLD%^%^RED%^m"+ "%^RESET%^%^RED%^so%^BOLD%^%^RED%^n%^RESET%^ and thin, it appears "+ "this at one time might have been a very plush accessory. However, "+ "its surface is now worn and %^BOLD%^%^BLACK%^tattered%^RESET%^ "+ "from use. A fading pattern is evident, and upon closer inspection "+ "you find the image is hundreds of small, %^BOLD%^%^RED%^b%^RESET%^"+ "%^RED%^lo%^BOLD%^%^RED%^o%^RESET%^%^RED%^d-r%^BOLD%^%^RED%^e"+ "%^RESET%^%^RED%^d %^BOLD%^%^RED%^e%^RESET%^%^RED%^ye%^BOLD%^"+ "%^RED%^s%^RESET%^, staring back at you.%^RESET%^", ({"iron door","north door","door"}):"%^RESET%^This door "+ "certainly stands out, being different than the others. It "+ "is shaped into an arch, and the doorframe is thick, %^BOLD%^"+ "%^WHITE%^s%^RESET%^h%^BOLD%^%^BLACK%^ini%^RESET%^n%^BOLD%^"+ "%^WHITE%^g iron%^RESET%^. The door itself is heavy and "+ "%^BOLD%^%^BLACK%^darker%^RESET%^ in color, almost as if it "+ "has been %^RESET%^%^RED%^scorched%^RESET%^ by %^BOLD%^%^RED%^"+ "f%^RESET%^%^RED%^l%^MAGENTA%^a%^ORANGE%^m%^RED%^e%^BOLD%^"+ "%^RED%^s%^RESET%^. As you approach it, it seems to grow oddly "+ "translucent, like you could walk right through it.%^RESET%^" ])); set_exits(([ "down":ROOMS"bsb1", "north":ROOMS"bsb8", //iron door "south":ROOMS"bsb6", //ebony door "west":ROOMS"bsb7", //mahogany door ])); set_pre_exit_functions(({"north"}),({"pass_door"})); set_door("ebony door",ROOMS"bsb6","south",0); set_locked("ebony door", 0); lock_difficulty("ebony door", "/daemon/player_housing"->get_phouse_lock_dc("poor"), "lock"); set_door_description("ebony door","%^RESET%^This is a simple "+ "%^BOLD%^%^BLACK%^ebony door%^RESET%^ with %^YELLOW%^b"+ "%^RESET%^%^ORANGE%^ras%^YELLOW%^s k%^RESET%^%^ORANGE%^nob"+ "%^YELLOW%^s%^RESET%^. A %^RESET%^%^MAGENTA%^grotesque%^RESET%^ "+ "face, its mouth wide in an anguished scream leaps out from the "+ "center of each door. A small handle indicates that this "+ "%^BOLD%^interesting%^RESET%^ ornament is probably a knocker. "); set_string("ebony door", "open", "The door swings open."); set_string("ebony door", "close", "The door swings shut."); set_door("mahogany door",ROOMS"bsb7","west",0); set_locked("mahogany door", 0); lock_difficulty("mahogany door", "/daemon/player_housing"->get_phouse_lock_dc("poor"), "lock"); set_door_description("mahogany door","%^RESET%^This is a simple "+ "%^RESET%^%^RED%^mahogany door%^RESET%^ with %^YELLOW%^b"+ "%^RESET%^%^ORANGE%^ras%^YELLOW%^s k%^RESET%^%^ORANGE%^nob"+ "%^YELLOW%^s%^RESET%^. A %^RESET%^%^MAGENTA%^grotesque%^RESET%^ "+ "face, its mouth wide in an anguished scream leaps out from the "+ "center of each door. A small handle indicates that this "+ "%^BOLD%^interesting%^RESET%^ ornament is probably a knocker. "); set_string("mahogany door", "open", "The door swings open."); set_string("mahogany door", "close", "The door swings shut."); } void init() { ::init(); add_action("peer_fun","peer"); add_action("say_fun","say"); add_action("sneak_fun","sneak"); } int pass_door() { if(TP->query_true_invis()) return 1; tell_object(TP,"%^RESET%^You walk up to the door, but it certainly seems solid enough when you bump into it."); tell_room(TO,"%^RESET%^"+TP->QCN+" walks up to the heavy iron doorframe, and bumps right into it.",TP); return 0; } int peer_fun(string str){ string mystring, mystring2; if(TP->query_true_invis()) return 0; if(!str) return 0; if(sscanf(str,"%s %s", mystring, mystring2) != 2) mystring = str; if(mystring != "north" && mystring != "n") return 0; tell_object(TP,"%^BOLD%^%^WHITE%^The heavy doorway, while somewhat translucent, is too thick to see through.%^RESET%^"); return 1; } int say_fun(string str){ object myring; if(TP->query_true_invis()) return 0; if(!str) return 0; str = lower_case(str); if(strsrch(str,"mal'rak lu' tu'jol") == -1) return 0; myring = present("bsbrubyring",TP); if(!myring || !myring->query_worn()) { call_out("fail_step",1,TP); return 0; } call_out("pass_step",1,TP); return 0; } void fail_step(object theplayer) { tell_object(theplayer,"%^BOLD%^%^WHITE%^As the words leave your lips you feel a light tugging at your body, but then it fades.%^RESET%^"); } void pass_step(object theplayer) { tell_object(theplayer,"%^BOLD%^%^WHITE%^As the words leave your lips you feel a light compulsion, and before you realise it you have stepped forward, straight through the iron doorway!%^RESET%^"); tell_room(TO,"%^BOLD%^%^WHITE%^As the words leave "+TP->QCN+"'s lips, "+TP->QS+" gets a strange look on "+TP->QP+" face and abruptly steps forward, straight through the iron doorway!%^RESET%^",theplayer); TP->move_player(ROOMS"bsb8"); } int sneak_fun(string str){ if(TP->query_true_invis()) return 0; if(!str) return 0; if(str != "north" && str != "n") return 0; tell_object(TP,"You can tell the translucent doorway is still too solid to sneak through."); return 1; }
45.51462
207
0.639214
[ "object", "solid" ]
db77e078d75a7b49622ccf3fec86ab27fcc3140f
3,328
h
C
cMediaPlayer.h
androidg6/Simple_SDL_engine_MediaPlayer
c4f4d4bd9b18d37c53c93b1926529feee7532ac9
[ "MIT" ]
2
2016-12-10T16:42:03.000Z
2020-08-25T08:34:21.000Z
cMediaPlayer.h
androidg6/Simple_SDL_engine_MediaPlayer
c4f4d4bd9b18d37c53c93b1926529feee7532ac9
[ "MIT" ]
null
null
null
cMediaPlayer.h
androidg6/Simple_SDL_engine_MediaPlayer
c4f4d4bd9b18d37c53c93b1926529feee7532ac9
[ "MIT" ]
null
null
null
/********************************************* cMediaPlayer.h @ Nathaniel Dielen D: 11-22-16 MIT License Copyright (c) 2016-2017 Nathaniel Dielen 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. **********************************************/ #ifndef cMediaPlayer_h #define cMediaPlayer_h #include "stdafx.h" #include "cButton.h" class cPlayButton : public cSysButton { public: cPlayButton(); ~cPlayButton(); void free(); void draw(SDL_Renderer * gRenderer); }; class cPauseButton : public cSysButton { public: cPauseButton(); ~cPauseButton(); void free(); void draw(SDL_Renderer * gRenderer); }; class cNextSongButton : public cSysButton { public: cNextSongButton(); ~cNextSongButton(); void free(); void draw(SDL_Renderer * gRenderer); }; class cPreviousSongButton : public cSysButton { public: cPreviousSongButton(); ~cPreviousSongButton(); void free(); void draw(SDL_Renderer * gRenderer); }; class cMediaPlayerButtons { public: cMediaPlayerButtons(); ~cMediaPlayerButtons(); void free(); void setQuad(SDL_Rect * renderQuad); void handleEvent(SDL_Event * e); void draw(SDL_Renderer * gRenderer); int onClick(); enum {PLAY_BUTTON = 0 , PAUSE_BUTTON ,PREVIOUS_BUTTON , STOP_BUTTON , NEXT_BUTTON , MAX_BUTTONS}; private: cSysButton * buttonArr[MAX_BUTTONS]; }; class cMediaPlayer { public: cMediaPlayer(); ~cMediaPlayer(); void free(); bool loadMedia(SDL_Renderer * gRenderer); void handleEvent(SDL_Event * e); void render(SDL_Renderer * gRenderer); private: cMediaPlayerButtons mediaPlayerButtons; cTexture background; TTF_Font * mFont; SDL_Rect highLightQuad; SDL_Color yellowHighlight; SDL_Color color_black; enum {SONG1=0, SONG2,SONG3,SONG4,SONG5,SONG6,SONG7,SONG8,SONG9,SONG10,MAX_SONGS}; cTexturedTextButton songButton[MAX_SONGS]; cTexture emptyLable[cTexturedTextButton::TOTAL_TEXTURE]; int curentSelection; cTexture songLable[MAX_SONGS][cTexturedTextButton::TOTAL_TEXTURE]; Mix_Music* songMusic[MAX_SONGS]; }; #endif // cMediaPlayer_h
30.53211
106
0.673678
[ "render" ]
db910db92305b0c70007ac440098183f10375de6
1,743
h
C
Lux.Shared/EnumNameMapping.h
axodox/Lux
00e8da582233ab4ecf22d773e647c9bd84eb7b32
[ "MIT" ]
9
2020-11-30T01:13:25.000Z
2022-03-14T15:17:44.000Z
Lux.Shared/EnumNameMapping.h
axodox/Lux
00e8da582233ab4ecf22d773e647c9bd84eb7b32
[ "MIT" ]
1
2020-11-30T15:45:27.000Z
2021-02-17T22:11:14.000Z
Lux.Shared/EnumNameMapping.h
axodox/Lux
00e8da582233ab4ecf22d773e647c9bd84eb7b32
[ "MIT" ]
1
2021-02-15T22:17:37.000Z
2021-02-15T22:17:37.000Z
#pragma once #include "Text.h" #include "TypeRegistry.h" #include "LifetimeExecutor.h" namespace Lux::Text { template<typename T> struct enum_value_name_mapping { inline static std::vector<std::wstring> values; static std::wstring name(T value) { if (values.empty()) { return std::to_wstring(static_cast<std::underlying_type_t<T>>(value)); } else { return values.at(static_cast<std::underlying_type_t<T>>(value)); } } static T value(const std::wstring& name) { if (values.empty()) { return (T)std::stoi(name); } else { auto it = std::find(values.begin(), values.end(), name); if (it != values.end()) { return (T)std::distance(values.begin(), it); } else { return (T)-1; } } } }; std::vector<std::wstring> split_enum_names(const char* text); #define named_enum(enum_t, ...) enum class enum_t { __VA_ARGS__ }; \ namespace { \ inline void init_enum_##enum_t() { Lux::Text::enum_value_name_mapping<enum_t>::values = Lux::Text::split_enum_names(#__VA_ARGS__); } \ inline Threading::lifetime_executor<init_enum_##enum_t, nullptr> run_enum_##enum_t; \ } #define named_enum_underlying(enum_t, underlying_t, ...) enum class enum_t : underlying_t { __VA_ARGS__ }; \ namespace { \ inline void init_enum_##enum_t() { Lux::Text::enum_value_name_mapping<enum_t>::values = Lux::Text::split_enum_names(#__VA_ARGS__); } \ inline Threading::lifetime_executor<init_enum_##enum_t, nullptr> run_enum_##enum_t; \ } #define named_enum_typeid(enum_t, ...) named_enum_underlying(enum_t, Serialization::type_id_t, __VA_ARGS__) }
28.57377
138
0.633391
[ "vector" ]
67b8473e12154720ae70c7974a0ee17f7a773181
2,662
h
C
frameworks/core/animation/card_transition_controller.h
openharmony-gitee-mirror/ace_ace_engine
78013960cdce81348d1910e466a3292605442a5e
[ "Apache-2.0" ]
null
null
null
frameworks/core/animation/card_transition_controller.h
openharmony-gitee-mirror/ace_ace_engine
78013960cdce81348d1910e466a3292605442a5e
[ "Apache-2.0" ]
null
null
null
frameworks/core/animation/card_transition_controller.h
openharmony-gitee-mirror/ace_ace_engine
78013960cdce81348d1910e466a3292605442a5e
[ "Apache-2.0" ]
1
2021-09-13T12:07:42.000Z
2021-09-13T12:07:42.000Z
/* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_ANIMATION_CARD_TRANSITION_CONTROLLER_H #define FOUNDATION_ACE_FRAMEWORKS_CORE_ANIMATION_CARD_TRANSITION_CONTROLLER_H #include "base/memory/ace_type.h" #include "core/animation/animation_pub.h" #include "core/components/page/page_element.h" #include "core/components/transform/render_transform.h" #include "core/pipeline/pipeline_context.h" namespace OHOS::Ace { class Animator; class CardTransitionController : public AceType { DECLARE_ACE_TYPE(CardTransitionController, AceType); public: explicit CardTransitionController(const WeakPtr<PipelineContext>& context); ~CardTransitionController() override = default; void RegisterTransitionListener(); RRect GetCardRect(const ComposeId& composeId) const; const RefPtr<Animator>& GetAnimator() const { return controller_; } private: void PrepareTransition(); void CreateCardAnimation(const RefPtr<Element>& cardComposeElement, const Offset& globalOffset, const RRect& rrect); void CreateCardOpacityAnimation(RefPtr<RenderNode>& displayRender); void CreateCardTranslateAnimation(const WeakPtr<RenderTransform>& weakTransform, const Offset& globalOffset, const Offset& marginOffset); void CreateCardScaleAnimation(const WeakPtr<RenderTransform>& weakTransform, const RRect& rrect); void CreateCardListAnimation(const RefPtr<RenderNode>& renderNode); void CreateExternalAnimation(double height, double cardOffsetY); RefPtr<Element> GetCardTransformElement(const RefPtr<Element>& element); void AddPrepareListener(const WeakPtr<RenderTransform>& weakTransform); void AddStopListener(const WeakPtr<RenderTransform>& weakTransform); WeakPtr<PipelineContext> context_; WeakPtr<PageElement> pageDest_; WeakPtr<PageElement> pageSrc_; RefPtr<Animator> controller_; TransitionEvent event_ { TransitionEvent::PUSH_START }; uint64_t currentTimestamp_ = 0; }; } // namespace OHOS::Ace #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_ANIMATION_CARD_TRANSITION_CONTROLLER_H
39.731343
120
0.78287
[ "transform" ]
67ba6ba90eeacee85ed55a5b3eee175392e3fcdc
805
h
C
deps/src/gropt/incl/WeightedLowRank.h
JuliaPackageMirrors/ElasticFDA.jl
fe9852231d04672c0792f2ca7adf754da0874f0a
[ "MIT" ]
null
null
null
deps/src/gropt/incl/WeightedLowRank.h
JuliaPackageMirrors/ElasticFDA.jl
fe9852231d04672c0792f2ca7adf754da0874f0a
[ "MIT" ]
null
null
null
deps/src/gropt/incl/WeightedLowRank.h
JuliaPackageMirrors/ElasticFDA.jl
fe9852231d04672c0792f2ca7adf754da0874f0a
[ "MIT" ]
null
null
null
#ifndef WEIGHTEDLOWRANK_H #define WEIGHTEDLOWRANK_H #include "Stiefel.h" #include "StieVariable.h" #include "StieVector.h" #include "Problem.h" #include "SharedSpace.h" #include "def.h" #include "Element.h" #include "ProductElement.h" #include "ProductManifold.h" class WeightedLowRank : public Problem{ public: WeightedLowRank(double *inA, double *inW, integer inm, integer inn, integer inr); virtual ~WeightedLowRank(); virtual double f(Variable *x) const; //virtual void EucGrad(Variable *x, Vector *egf) const; //virtual void EucHessianEta(Variable *x, Vector *etax, Vector *exix) const; virtual void RieGrad(Variable *x, Vector *gf) const; virtual void RieHessianEta(Variable *x, Vector *etax, Vector *xix) const; double *A; double *W; integer m; integer n; integer r; }; #endif
23
82
0.73913
[ "vector" ]
67da0a4702d12c246b1f49b0c25eaf3d1336d42a
15,617
c
C
src/gui/Layers.c
Artpad-project/artpad
859c3f3fd842a3149630afdc20eb5a2b607883b2
[ "MIT" ]
2
2021-03-06T22:54:33.000Z
2021-05-05T13:48:58.000Z
src/gui/Layers.c
Artpad-project/artpad
859c3f3fd842a3149630afdc20eb5a2b607883b2
[ "MIT" ]
2
2021-04-06T19:32:26.000Z
2021-05-05T06:39:48.000Z
src/gui/Layers.c
Artpad-project/artpad
859c3f3fd842a3149630afdc20eb5a2b607883b2
[ "MIT" ]
null
null
null
/*! * File created on 13/5/2021 by tom aubert * Contributors : tom aubert * * File containing all the functions necessary to interact with Layers. * */ #include "../../include/Layers.h" #include <stdio.h> #include <gtk/gtk.h> #include <sys/stat.h> #include <string.h> #include "../../include/gui.h" //length of "_layers00\0" #define APPEND_LENGTH 10 #define _GNU_SOURCE /// FONCTIONS USED FOR GUI void show_hide_layer(GtkButton *button,gpointer user_data) { UserInterface* ui = user_data; GtkListBoxRow *lbr = GTK_LIST_BOX_ROW(gtk_widget_get_parent (gtk_widget_get_parent (GTK_WIDGET(button)))); //GtkListBox * lb = GTK_LIST_BOX(gtk_widget_get_parent (GTK_WIDGET(lbr))); int pos = gtk_list_box_row_get_index (lbr); Layer* current_layer = elm_at_pos(&ui->Layers,pos); if (current_layer->show){ GError* err = NULL; GdkPixbuf * buf = gdk_pixbuf_new_from_file("src/gui/icons/pasvue.png",&err); if (buf == NULL) errx(err->code,"ERROR: image.c: couldn't load pixbuf (%s)",err->message); GtkWidget *vue = gtk_image_new_from_pixbuf(buf); gtk_button_set_image(GTK_BUTTON(button),vue); current_layer->show = 0; } else if (!current_layer->show){ GError* err = NULL; GdkPixbuf * buf = gdk_pixbuf_new_from_file("src/gui/icons/vue.png",&err); if (buf == NULL) errx(err->code,"ERROR: image.c: couldn't load pixbuf (%s)",err->message); GtkWidget *vue = gtk_image_new_from_pixbuf(buf); gtk_button_set_image(GTK_BUTTON(button),vue); current_layer->show = 1; } merge_from_layers(ui->Layers,ui->im); draw_total_image(user_data); } void hide_all_layers(GtkButton* buttonuseless, gpointer user_data){ UserInterface* ui = user_data; Stack * curlayer = ui->Layers; while (!is_stack_empty(curlayer)){ Layer * current_layer = (Layer *)curlayer->data; if (current_layer->show){ GError* err = NULL; GdkPixbuf * buf = gdk_pixbuf_new_from_file("src/gui/icons/pasvue.png",&err); if (buf == NULL) errx(err->code,"ERROR: image.c: couldn't load pixbuf (%s)",err->message); GtkWidget *vue = gtk_image_new_from_pixbuf(buf); gtk_button_set_image(GTK_BUTTON(current_layer->button),vue); current_layer->show = 0; } curlayer = curlayer->next; } merge_from_layers(ui->Layers,ui->im); draw_total_image(user_data); } void show_all_layers(GtkButton* buttonuseless, gpointer user_data){ UserInterface* ui = user_data; Stack * curlayer = ui->Layers; while (!is_stack_empty(curlayer)){ Layer * current_layer = (Layer *)curlayer->data; if (!current_layer->show){ GError* err = NULL; GdkPixbuf * buf = gdk_pixbuf_new_from_file("src/gui/icons/vue.png",&err); if (buf == NULL) errx(err->code,"ERROR: image.c: couldn't load pixbuf (%s)",err->message); GtkWidget *vue = gtk_image_new_from_pixbuf(buf); gtk_button_set_image(GTK_BUTTON(current_layer->button),vue); current_layer->show = 1; } curlayer = curlayer->next; } merge_from_layers(ui->Layers,ui->im); draw_total_image(user_data); } void up_layer(GtkButton *button,gpointer user_data){ UserInterface *ui = user_data; GtkListBoxRow *curlbr = GTK_LIST_BOX_ROW(gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent (GTK_WIDGET(button))))); GtkListBox * lb = GTK_LIST_BOX(gtk_widget_get_parent (GTK_WIDGET(curlbr))); int pos = gtk_list_box_row_get_index (curlbr); if (pos) { //g_print("\n-------------pos : %i,nblayers = %i---------------\n",pos,ui->nblayers); swap_next_el_data(&ui->Layers,pos-1); GtkListBoxRow * lastlbr = GTK_LIST_BOX_ROW(gtk_list_box_get_row_at_index(lb,pos-1)); GtkLabel *lastlabel = GTK_LABEL(gtk_grid_get_child_at(GTK_GRID(gtk_bin_get_child(GTK_BIN(lastlbr))),1,0)); const gchar* tmp = gtk_label_get_text(lastlabel); char *my_string; int val = asprintf(&my_string,"%s",tmp); if(val <0) errx(1,"cannot create the query"); GtkLabel * currentlabel = GTK_LABEL(gtk_grid_get_child_at(GTK_GRID(gtk_bin_get_child(GTK_BIN(curlbr))),1,0)); gtk_label_set_text(lastlabel,gtk_label_get_text(currentlabel)); gtk_label_set_text(currentlabel,my_string); merge_from_layers(ui->Layers,ui->im); actualise_image(ui->im,0,0,ui->im->width,ui->im->height); gtk_image_set_from_pixbuf(ui->area,ui->im->pb); } } void down_layer(GtkButton *button,gpointer user_data){ UserInterface *ui = user_data; GtkListBoxRow *curlbr = GTK_LIST_BOX_ROW(gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent (GTK_WIDGET(button))))); GtkListBox * lb = GTK_LIST_BOX(gtk_widget_get_parent (GTK_WIDGET(curlbr))); int pos = gtk_list_box_row_get_index (curlbr); if (pos<ui->nblayers-1) { //g_print("\n-------------pos : %i,nblayers = %i---------------\n",pos,ui->nblayers); swap_next_el_data(&ui->Layers,pos); GtkListBoxRow * nextlbr = GTK_LIST_BOX_ROW(gtk_list_box_get_row_at_index(lb,pos+1)); GtkLabel *nextlabel = GTK_LABEL(gtk_grid_get_child_at(GTK_GRID(gtk_bin_get_child(GTK_BIN(nextlbr))),1,0)); const gchar* tmp = gtk_label_get_text(nextlabel); char *my_string; int val = asprintf(&my_string,"%s",tmp); if(val <0) errx(1,"cannot create the query"); GtkLabel * currentlabel = GTK_LABEL(gtk_grid_get_child_at(GTK_GRID(gtk_bin_get_child(GTK_BIN(curlbr))),1,0)); gtk_label_set_text(nextlabel,gtk_label_get_text(currentlabel)); gtk_label_set_text(currentlabel,my_string); merge_from_layers(ui->Layers,ui->im); actualise_image(ui->im,0,0,ui->im->width,ui->im->height); gtk_image_set_from_pixbuf(ui->area,ui->im->pb); } } void set_current_layer(GtkListBox *box ,GtkListBoxRow *listboxrow,gpointer user_data){ UserInterface *ui = user_data; //int pos = gtk_list_box_row_get_index (listboxrow); //g_print("%i\n",gtk_list_box_row_get_index (listboxrow)); Layer * current_layer = elm_at_pos(&ui->Layers,gtk_list_box_row_get_index (listboxrow)); merge_from_layers(ui->Layers,ui->im); draw_total_image(user_data); prepare_drawarea(user_data); ui->currentLayer = current_layer; gtk_list_box_select_row (box,listboxrow); //g_print("clicked on the %i element\n",get_index_layer(Layers,listboxrow)); } void destroy_layer(GtkButton *button,gpointer user_data){ UserInterface *ui = user_data; GtkListBoxRow *curlbr = GTK_LIST_BOX_ROW(gtk_widget_get_parent (gtk_widget_get_parent (GTK_WIDGET(button)))); //GtkListBox * lb = GTK_LIST_BOX(gtk_widget_get_parent (GTK_WIDGET(curlbr))); int pos = gtk_list_box_row_get_index (curlbr); gtk_widget_destroy(GTK_WIDGET(curlbr)); Layer * dead = pop_from_stack_at_pos(&ui->Layers,pos); dead->lbr = 0; free_layer(dead); //todo : need to set the new image Layer * new = elm_at_pos(&ui->Layers,0); if (new != NULL) { temp_layer_destroy(new->tp); set_current_layer(ui->layers,GTK_LIST_BOX_ROW(gtk_list_box_get_row_at_index (ui->layers,0)),user_data); merge_from_layers(ui->Layers,ui->im); draw_total_image(user_data); } else { merge_from_layers(ui->Layers,ui->im); actualise_image(ui->im,0,0,ui->im->width,ui->im->height); gtk_image_set_from_pixbuf(ui->area,ui->im->pb); free_image(ui->im); ui->im = NULL; ui->currentLayer = NULL; } ui->nblayers -=1; } //Impossible à faire marcher gint trifunc(GtkListBoxRow *row1,GtkListBoxRow *row2,gpointer user_data){ UserInterface *ui = user_data; int pos1 = gtk_list_box_row_get_index (row1); int pos2 = gtk_list_box_row_get_index (row2); pos1 = get_index_layer(ui->Layers, row1); pos2 = get_index_layer(ui->Layers, row2); return pos1>pos2 ? 1 : -1; } void add_layer(GtkButton *useless,gpointer user_data){ UserInterface *ui = user_data; // création de la box contenant les infos du layer GtkListBoxRow * nbr = GTK_LIST_BOX_ROW(gtk_list_box_row_new ()); GtkGrid *box = GTK_GRID(gtk_grid_new ()); gtk_grid_insert_column(box,0); gtk_grid_insert_column(box,0); gtk_grid_insert_column(box,0); gtk_grid_insert_column(box,0); //bouton hide/show GtkWidget *button = gtk_button_new(); GError* err = NULL; GdkPixbuf * buf = gdk_pixbuf_new_from_file("src/gui/icons/vue.png",&err); GtkWidget *vue = gtk_image_new_from_pixbuf(buf); gtk_button_set_image(GTK_BUTTON(button),vue); g_signal_connect(button, "clicked", G_CALLBACK(show_hide_layer), user_data); g_object_unref(buf); gtk_grid_attach (box,button,0,0,1,1); //nom du layer char *my_string; int val = asprintf(&my_string,"Layer %i",ui->nblayers); if(val <0) errx(1,"cannot create the query"); //GtkEntryBuffer * buf= gtk_entry_buffer_new (my_string,val); /* GtkWidget* entry = gtk_entry_new(); gtk_entry_set_max_length(GTK_ENTRY(entry), 64); gtk_entry_set_text(GTK_ENTRY(entry), "Enter a name"); gtk_entry_set_visibility(GTK_ENTRY(entry), TRUE); gtk_editable_set_editable(GTK_EDITABLE(entry), TRUE);*/ GtkWidget *name = gtk_label_new(my_string); gtk_widget_set_name(name, "label"); gtk_grid_attach (box,name,1,0,1,1); //bouton up/down GtkWidget *bud = gtk_box_new (GTK_ORIENTATION_VERTICAL,1); GtkWidget *upbutton = gtk_button_new_with_label ("up"); GtkWidget *downbutton = gtk_button_new_with_label ("down"); gtk_button_set_relief(GTK_BUTTON(upbutton),GTK_RELIEF_NONE); gtk_button_set_relief(GTK_BUTTON(downbutton),GTK_RELIEF_NONE); g_signal_connect(upbutton, "clicked", G_CALLBACK(up_layer), user_data); g_signal_connect(downbutton, "clicked", G_CALLBACK(down_layer), user_data); gtk_container_add (GTK_CONTAINER(bud),upbutton); gtk_container_add (GTK_CONTAINER(bud),downbutton); gtk_grid_attach (box,bud,2,0,1,1); //bouton kill layer GtkWidget *killbutton = gtk_button_new_with_label ("kill"); g_signal_connect(killbutton, "clicked", G_CALLBACK(destroy_layer), user_data); gtk_grid_attach (box,killbutton,3,0,1,1); gtk_container_add (GTK_CONTAINER(nbr),GTK_WIDGET(box)); gtk_list_box_insert (ui->layers,GTK_WIDGET(nbr),0); //gtk_widget_hide (GTK_WIDGET(ui->layers)); gtk_widget_show_all(GTK_WIDGET(ui->layers)); struct Layer *newLayer = malloc(sizeof(struct Layer)); if(!ui->im){ newLayer->im = new_image(gtk_adjustment_get_value(ui->width_print),gtk_adjustment_get_value(ui->height_print)); ui->im = create_copy_image(newLayer->im); } else newLayer->im = new_image(ui->im->width,ui->im->height); newLayer->tp = malloc(sizeof(struct temp_layer)); newLayer->tp->layers_y = NULL; newLayer->tp->layers_z = NULL; newLayer->tp->n = 0; newLayer->tp = malloc(sizeof(struct temp_layer)); newLayer->tp->layers_y = NULL; newLayer->tp->layers_z = NULL; newLayer->tp->n = 0; newLayer->show = 1; newLayer-> lbr = nbr; newLayer->button = GTK_BUTTON(button); ui->nblayers +=1; ui->Layers = push_to_stack(ui->Layers,newLayer); set_current_layer(ui->layers,nbr,user_data); } /// OTHER FONCTIONS /* get the index of a layer in the stack from it's gtklistboxrow * * @param * Layers: the stack * lbr : the gtklistboxrow */ int get_index_layer(Stack* Layers,GtkListBoxRow * lbr) { Stack * tmp = Layers; int pos = 0; if (!is_stack_empty(tmp)){ while (tmp->next != NULL ) { Layer * act = tmp->data; if (act->lbr == lbr) break; pos ++; tmp = tmp->next; } } return pos; } /*! * give the render of all the selected layers */ void merge_from_layers(Stack* Layers,struct Image* im){ /*int** matrix = malloc(im->width * sizeof(int*)); for (int i = 0; i < im->width; i++) { matrix[i] = malloc(im->height * sizeof(int)); memset(im->pixels[i], 255, im->height*sizeof(struct Pixel)); }*/ for(int i = 0;i<im->width;i++) for(int j = 0;j<im->height;j++){ im->pixels[i][j].alpha = 0; im->pixels[i][j].blue = 255; im->pixels[i][j].green = 255; im->pixels[i][j].red = 255; } Stack *layers = Layers; while (!is_stack_empty(layers)){ Layer* cur_layer = layers->data; if (cur_layer->show) { for(int i = 0;i<cur_layer->im->width;i++){ for(int j = 0;j<cur_layer->im->height;j++){ if (im->pixels[i][j].alpha<255){ int alpha = cur_layer->im->pixels[i][j].alpha; if (im->pixels[i][j].alpha + alpha > 255) alpha = 255 - im->pixels[i][j].alpha; im->pixels[i][j].red -= (255-cur_layer->im->pixels[i][j].red) * alpha/255; im->pixels[i][j].blue -= (255-cur_layer->im->pixels[i][j].blue) * alpha/255; im->pixels[i][j].green -= (255-cur_layer->im->pixels[i][j].green) * alpha/255; im->pixels[i][j].alpha += alpha; } } } } layers = layers->next; } } void apply_to_all_layers(void (*function) (void* ,void*),void* arg1,void* arg2, Stack* Layers){ Stack * curlayer = Layers; while (!is_stack_empty(curlayer)){ function(arg1,arg2); } } void free_layer(Layer* dead){ if (dead->lbr) gtk_widget_destroy(GTK_WIDGET(dead->lbr)); if (dead->im){ free_image(dead->im); free(dead->im); } free(dead); } void merge_to_death(Stack* Layers,gpointer user_data ){ UserInterface * ui = user_data; Image* test = new_image(ui->im->width,ui->im->height); merge_from_layers(ui->Layers,test); Stack *stack = ui->Layers; Stack *stack_to_free = NULL; while (stack->next != NULL) { stack_to_free = stack; stack = stack->next; Layer * dead = (Layer*)stack_to_free->data; free_layer(dead); free(stack_to_free); } ui->Layers = create_stack(); ui->nblayers = 0; add_layer(NULL,user_data); Layer * cur = ui->Layers->data; free_image(cur->im); cur->im = create_copy_image(test); free_image(ui->im); ui->im = create_copy_image(test); } /* saves all layers in a subdirectory layers * the nameplate is "{dir_name}/{img original name}_layers00.{filetype};" * @param * img: the original image * layers: the stack of layers * n: the number of layers in the stack */ void export(Image *img, Stack *layers, int n, char *path) { //creates directory if (!is_stack_empty(layers)) { //asprintf(&buffer, "draft_%c", img->file); // all permissions //struct stat *buf = malloc(sizeof(struct stat)); /*if (!stat("draft", buf)) { if (mkdir("draft", 0700) == -1) errx(EXIT_FAILURE, "couldn't create a directory\n"); }*/ //dir_length = strlen(buffer); } //saves directory while(!is_stack_empty(layers)) { char *buffer; struct Layer * cur_layer = pop_from_stack(&layers); struct Image * draft_img = cur_layer->im; size_t length = strlen(draft_img->file); //+1 accounts for the "/" separation //(aborted since cannot create directory) //char draft_path[length + APPEND_LENGTH + dir_length]; //strncat(draft_path, buffer, dir_length); //strcat(draft_path, "/"); //strncat(draft_path, img->file, dir_length); //strcat(draft_path, img->file); char *full_path; //char cwd[PATH_MAX]; //getcwd(cwd, sizeof(cwd)); asprintf(&full_path, "%s_layers%d.%s", path, n, img->file_type); n--; save_image(draft_img, full_path, draft_img->file_type); } }
30.324272
137
0.66338
[ "render" ]
67f4cb79b0c98771efcd2b00e17a93aba24c5a2d
3,787
h
C
kratos/modeler/duplicate_mesh_modeler.h
clazaro/Kratos
b947b82c90dfcbf13d60511427f85990d36b90be
[ "BSD-4-Clause" ]
2
2020-12-22T11:50:11.000Z
2021-09-15T11:36:30.000Z
kratos/modeler/duplicate_mesh_modeler.h
clazaro/Kratos
b947b82c90dfcbf13d60511427f85990d36b90be
[ "BSD-4-Clause" ]
3
2021-08-18T16:12:20.000Z
2021-09-02T07:36:15.000Z
kratos/modeler/duplicate_mesh_modeler.h
clazaro/Kratos
b947b82c90dfcbf13d60511427f85990d36b90be
[ "BSD-4-Clause" ]
1
2017-05-02T00:52:44.000Z
2017-05-02T00:52:44.000Z
// | / | // ' / __| _` | __| _ \ __| // . \ | ( | | ( |\__ ` // _|\_\_| \__,_|\__|\___/ ____/ // Multi-Physics // // License: BSD License // Kratos default license: kratos/license.txt // // Main authors: Riccardo Rossi // // #if !defined(KRATOS_COPY_MODELER_H_INCLUDED ) #define KRATOS_COPY_MODELER_H_INCLUDED // System includes #include <string> #include <iostream> // External includes // Project includes #include "includes/define.h" #include "modeler/modeler.h" namespace Kratos { ///@name Kratos Globals ///@{ ///@} ///@name Type Definitions ///@{ ///@} ///@name Enum's ///@{ ///@} ///@name Functions ///@{ ///@} ///@name Kratos Classes ///@{ /// Short class definition. /** Detail class definition. */ class KRATOS_API(KRATOS_CORE) DuplicateMeshModeler : public Modeler { public: ///@name Type Definitions ///@{ /// Pointer definition of DuplicateMeshModeler KRATOS_CLASS_POINTER_DEFINITION(DuplicateMeshModeler); typedef Modeler BaseType; typedef Point PointType; typedef Node < 3 > NodeType; typedef Geometry<NodeType> GeometryType; typedef PointerVector<NodeType> NodesVectorType; typedef std::size_t SizeType; ///@} ///@name Life Cycle ///@{ /// constructor. DuplicateMeshModeler(ModelPart& rSourceModelPart) : mrModelPart(rSourceModelPart) { } /// Destructor. virtual ~DuplicateMeshModeler() { } ///@} ///@name Operators ///@{ ///@} ///@name Operations ///@{ void GenerateMesh(ModelPart& rThisModelPart, Element const& rReferenceElement, Condition const& rReferenceCondition) override; ///@} ///@name Access ///@{ ///@} ///@name Inquiry ///@{ ///@} ///@name Input and output ///@{ /// Turn back information as a string. virtual std::string Info() const override { return "DuplicateMeshModeler"; } /// Print information about this object. virtual void PrintInfo(std::ostream& rOStream) const override { rOStream << Info(); } /// Print object's data. virtual void PrintData(std::ostream& rOStream) const override { } ///@} ///@name Friends ///@{ ///@} protected: ///@name Protected static Member Variables ///@{ ///@} ///@name Protected member Variables ///@{ ///@} ///@name Protected Operators ///@{ ///@} ///@name Protected Operations ///@{ ///@} ///@name Protected Access ///@{ ///@} ///@name Protected Inquiry ///@{ ///@} ///@name Protected LifeCycle ///@{ ///@} private: ///@name Static Member Variables ///@{ ///@} ///@name Member Variables ///@{ ModelPart& mrModelPart; ///@} ///@name Private Operators ///@{ ///@} ///@name Private Operations ///@{ ///@} ///@name Private Access ///@{ ///@} ///@name Private Inquiry ///@{ ///@} ///@name Un accessible methods ///@{ ///@} }; // Class DuplicateMeshModeler ///@} ///@name Type Definitions ///@{ ///@} ///@name Input and output ///@{ /// input stream function inline std::istream & operator >>(std::istream& rIStream, DuplicateMeshModeler& rThis); /// output stream function inline std::ostream & operator <<(std::ostream& rOStream, const DuplicateMeshModeler& rThis) { rThis.PrintInfo(rOStream); rOStream << std::endl; rThis.PrintData(rOStream); return rOStream; } ///@} } // namespace Kratos. #endif // KRATOS_COPY_MODELER_H_INCLUDED defined
14.565385
130
0.543966
[ "geometry", "object" ]
db01f00c05bae7883732d5ebcac606120df1e7e9
9,558
c
C
tvdeconv_20120607/usolve_dct_inc.c
cpuimage/Deblurring
8083d4f4a0413bc3e43f1657400c314c51dce860
[ "MIT" ]
50
2018-11-20T07:50:40.000Z
2022-03-23T08:18:50.000Z
tvdeconv_20120607/usolve_dct_inc.c
chuckwoody/Deblurring
8083d4f4a0413bc3e43f1657400c314c51dce860
[ "MIT" ]
1
2019-12-05T05:59:31.000Z
2019-12-05T05:59:31.000Z
tvdeconv_20120607/usolve_dct_inc.c
chuckwoody/Deblurring
8083d4f4a0413bc3e43f1657400c314c51dce860
[ "MIT" ]
15
2019-03-27T08:18:28.000Z
2021-11-05T00:58:37.000Z
/** * @file usolve_dct_inc.c * @brief u-subproblem DCT solver for TV-regularized deconvolution * @author Pascal Getreuer <getreuer@gmail.com> * * Copyright (c) 2010-2012, Pascal Getreuer * All rights reserved. * * This program is free software: you can use, modify and/or * redistribute it under the terms of the simplified BSD License. You * should have received a copy of this license along this program. If * not, see <http://www.opensource.org/licenses/bsd-license.html>. */ #include <string.h> #include "util_deconv.h" /** * @brief Compute \f$ \mathcal{C}_\mathrm{2e}(\alpha \varphi * A) \f$ * @param ATrans the destination * @param TransformA FFTW plan, transforming A to ATrans * @param KernelTrans the transform of the convolution kernel * @param Width, Height, NumChannels image dimensions * @param Alpha positive scalar * * As an intermediate computation for the u subproblem, this routine computes * \f$ \mathrm{ATrans}= \mathcal{C}_\mathrm{2e}(\alpha \varphi * A) \f$. */ static void AdjBlurDct(num *ATrans, FFT(plan) TransformA, const num *KernelTrans, int Width, int Height, int NumChannels, num Alpha) { const long NumPixels = ((long)Width) * ((long)Height); long i; int k; /* Compute ATrans = DCT[A] */ FFT(execute)(TransformA); /* Compute ATrans = Alpha . KernelTrans . ATrans */ for(k = 0; k < NumChannels; k++, ATrans += NumPixels) for(i = 0; i < NumPixels; i++) ATrans[i] = Alpha * KernelTrans[i] * ATrans[i]; } /** * @brief Intializations to prepare TvRestore for DCT-based deconvolution * @param S tvreg solver state * @return 1 on success, 0 on failure * * This routine sets up FFTW transform plans and precomputes the * transform \f$ \mathcal{C}_\mathrm{1e}(\frac{\lambda}{\gamma}\varphi * * \varphi-\Delta) \f$ in S->DenomTrans. If UseZ = 0, the transform * \f$ \mathcal{C}_\mathrm{2e}(\frac{\lambda}{\gamma}\varphi *f) \f$ is * precomputed in S->ATrans. */ static int InitDeconvDct(tvregsolver *S) { num *KernelTrans = S->KernelTrans; num *DenomTrans = S->DenomTrans; num *B = S->B; const num *Kernel = S->Opt.Kernel; const int KernelWidth = S->Opt.KernelWidth; const int KernelHeight = S->Opt.KernelHeight; const int Width = S->Width; const int Height = S->Height; const num Alpha = S->Alpha; const long NumPixels = ((long)Width) * ((long)Height); const long PadNumPixels = ((long)Width + 1) * ((long)Height + 1); FFT(plan) Plan = NULL; FFT(r2r_kind) Kind[2]; long i; int x0, y0, x, y, xi, yi, Size[2]; int exit; for(i = 0; i < PadNumPixels; i++) B[i] = 0; x0 = -KernelWidth/2; y0 = -KernelHeight/2; /* Pad Kernel to size Width by Height. If Kernel happens to be larger, it is folded. */ for(y = 0; y < y0 + KernelHeight; y++) { yi = WSymExtension(Height + 1, y); for(x = 0; x < x0 + KernelWidth; x++) { xi = WSymExtension(Width + 1, x); B[xi + (Width + 1)*yi] += Kernel[(x - x0) + KernelWidth*(y - y0)]; } } /* Compute the DCT-I transform of the padded Kernel */ #ifdef _OPENMP #pragma omp critical (fftw) #endif exit = !(Plan = FFT(plan_r2r_2d)(Height + 1, Width + 1, B, KernelTrans, FFTW_REDFT00, FFTW_REDFT00, FFTW_ESTIMATE | FFTW_DESTROY_INPUT)); if (exit) return 0; FFT(execute)(Plan); #ifdef _OPENMP #pragma omp critical (fftw) #endif FFT(destroy_plan)(Plan); /* Cut last row and column from KernelTrans */ for(y = 1, i = Width; y < Height; y++, i += Width) memmove(KernelTrans + i, KernelTrans + i + y, sizeof(num)*Width); /* Precompute the denominator that will be used in the u-subproblem. */ for(y = 0, i = 0; y < Height; y++) for(x = 0; x < Width; x++, i++) DenomTrans[i] = (num)(4*NumPixels*(Alpha*KernelTrans[i]*KernelTrans[i] + 2*(2 - cos(x*M_PI/Width) - cos(y*M_PI/Height)))); /* Plan DCT-II transforms */ Size[1] = Width; Size[0] = Height; Kind[0] = Kind[1] = FFTW_REDFT10; #ifdef _OPENMP #pragma omp critical (fftw) #endif exit = !(S->TransformA = FFT(plan_many_r2r)(2, Size, S->NumChannels, S->A, NULL, 1, NumPixels, S->ATrans, NULL, 1, NumPixels, Kind, FFTW_ESTIMATE | FFTW_DESTROY_INPUT)) || !(S->TransformB = FFT(plan_many_r2r)(2, Size, S->NumChannels, S->B, NULL, 1, NumPixels, S->BTrans, NULL, 1, NumPixels, Kind, FFTW_ESTIMATE | FFTW_DESTROY_INPUT)); if (exit) return 0; /* Plan inverse DCT-II transforms (DCT-III) */ Kind[0] = Kind[1] = FFTW_REDFT01; #ifdef _OPENMP #pragma omp critical (fftw) #endif exit = !(S->InvTransformA = FFT(plan_many_r2r)(2, Size, S->NumChannels, S->ATrans, NULL, 1, NumPixels, S->A, NULL, 1, NumPixels, Kind, FFTW_ESTIMATE | FFTW_DESTROY_INPUT)) || !(S->InvTransformB = FFT(plan_many_r2r)(2, Size, S->NumChannels, S->BTrans, NULL, 1, NumPixels, S->B, NULL, 1, NumPixels, Kind, FFTW_ESTIMATE | FFTW_DESTROY_INPUT)); if (exit) return 0; /* Compute ATrans = Alpha . KernelTrans . DCT[f] */ if(!S->UseZ) { memcpy(S->A, S->f, sizeof(num)*NumPixels*S->NumChannels); AdjBlurDct(S->ATrans, S->TransformA, KernelTrans, Width, Height, S->NumChannels, Alpha); } S->Ku = S->A; return 1; } /** * @brief Compute BTrans = ( ATrans - DCT[div(dtilde)] ) / DenomTrans * * This subroutine is a part of the DCT u-subproblem solution that is common * to both the d,u splitting (UseZ = 0) and d,u,z splitting (UseZ = 1). */ static void UTransSolveDct(num *BTrans, num *B, FFT(plan) TransformB, num *ATrans, const numvec2 *dtilde, const num *DenomTrans, int Width, int Height, int NumChannels) { const long NumPixels = ((long)Width) * ((long)Height); long i; int k; /* Compute B = div(dtilde) */ Divergence(B, Width, Height, dtilde, Width, Height, NumChannels); /* Compute BTrans = DCT[B] */ FFT(execute)(TransformB); /* Compute BTrans = ( ATrans - BTrans ) / DenomTrans */ for(k = 0; k < NumChannels; k++, ATrans += NumPixels, BTrans += NumPixels) for(i = 0; i < NumPixels; i++) BTrans[i] = (ATrans[i] - BTrans[i]) / DenomTrans[i]; } /** * @brief Solve the u subproblem using DCT transforms (UseZ = 0) * @param S tvreg solver state * * This routine solves the u-subproblem * \f[ \tfrac{\lambda}{\gamma}\varphi *\varphi *u -\Delta u = \tfrac{\lambda}{ * \gamma}\varphi *f -\operatorname{div}\tilde{d}. \f] * The solution is obtained using discrete cosine transforms (DCTs) as * \f[ u=\mathcal{C}_\mathrm{2e}^{-1}\left[\frac{\mathcal{C}_\mathrm{2e} * \bigl(\frac{\lambda}{\gamma}\varphi *f-\operatorname{div}\tilde{d}\bigr)}{ * \mathcal{C}_\mathrm{1e}(\frac{\lambda}{\gamma}\varphi *\varphi-\Delta)} * \right], \f] * where \f$ \mathcal{C}_\mathrm{1e} \f$ and \f$ \mathcal{C}_\mathrm{2e} \f$ * denote the DCT-I and DCT-II transforms of the same period lengths. Two of * the above quantities are precomputed by InitDeconvDct(): the transform of * \f$ \frac{\lambda}{\gamma}\varphi *f \f$ is stored in S->ATrans and the * transformed denominator is stored in S->DenomTrans. */ static num UDeconvDct(tvregsolver *S) { /* BTrans = ( ATrans - DCT[div(dtilde)] ) / DenomTrans */ UTransSolveDct(S->BTrans, S->B, S->TransformB, S->ATrans, S->dtilde, S->DenomTrans, S->Width, S->Height, S->NumChannels); /* B = IDCT[BTrans] */ FFT(execute)(S->InvTransformB); /* Compute ||B - u||, and assign u = B */ return UUpdate(S); } #if defined(TVREG_USEZ) || defined(DOXYGEN) /** * @brief Solve the u subproblem using DCT transforms (UseZ = 1) * @param S tvreg solver state * * This extended version of UDeconvDct() is used when performing DCT-based * deconvolution with the three-auxiliary variable algorithm (UseZ = 1). * The u subproblem in this case is * \f[ \tfrac{\gamma_2}{\gamma_1}\varphi *\varphi *u -\Delta u = \tfrac{ * \gamma_2}{\gamma_1}\varphi *\tilde{z} -\operatorname{div}\tilde{d}. \f] * Compared to UDeconvDct(), the main differences are that the DCT of ztilde * is computed and \f$ \mathrm{Ku} = \varphi * u \f$ is updated. */ static num UDeconvDctZ(tvregsolver *S) { num *ATrans = S->ATrans; num *BTrans = S->BTrans; const num *KernelTrans = S->KernelTrans; const int NumChannels = S->NumChannels; const long NumPixels = ((long)S->Width) * ((long)S->Height); long i; int k; /* Compute ATrans = Alpha . KernelTrans . DCT[ztilde] */ memcpy(S->A, S->ztilde, sizeof(num)*NumPixels*NumChannels); AdjBlurDct(ATrans, S->TransformA, KernelTrans, S->Width, S->Height, NumChannels, S->Alpha); /* BTrans = ( ATrans - DCT[div(dtilde)] ) / DenomTrans */ UTransSolveDct(BTrans, S->B, S->TransformB, ATrans, S->dtilde, S->DenomTrans, S->Width, S->Height, NumChannels); /* Compute ATrans = KernelTrans . BTrans */ for(k = 0; k < NumChannels; k++, ATrans += NumPixels, BTrans += NumPixels) for(i = 0; i < NumPixels; i++) ATrans[i] = KernelTrans[i] * BTrans[i]; /* A = IDCT[ATrans] = new Ku */ FFT(execute)(S->InvTransformA); /* B = IDCT[BTrans] = new u */ FFT(execute)(S->InvTransformB); /* Compute ||B - u||, and assign u = B */ return UUpdate(S); } #endif
35.531599
79
0.615505
[ "transform" ]
db08472c44a9be433a4ed919ad3d4850a7b8997e
67,663
c
C
Genesis3D/v120/src/Game/GMain.c
dumpinfo/WinMasterGame
59d300ec77c46fec2a821b4cfa095af0c21e434c
[ "Unlicense" ]
null
null
null
Genesis3D/v120/src/Game/GMain.c
dumpinfo/WinMasterGame
59d300ec77c46fec2a821b4cfa095af0c21e434c
[ "Unlicense" ]
null
null
null
Genesis3D/v120/src/Game/GMain.c
dumpinfo/WinMasterGame
59d300ec77c46fec2a821b4cfa095af0c21e434c
[ "Unlicense" ]
null
null
null
/****************************************************************************************/ /* GMain.c */ /* */ /* Author: John Pollard */ /* Description: */ /* */ /* Copyright (c) 1999 WildTangent, Inc.; All rights reserved. */ /* */ /* See the accompanying file LICENSE.TXT for terms on the use of this library. */ /* This library is distributed in the hope that it will be useful but WITHOUT */ /* ANY WARRANTY OF ANY KIND and without any implied warranty of MERCHANTABILITY */ /* or FITNESS FOR ANY PURPOSE. Refer to LICENSE.TXT for more details. */ /* */ /****************************************************************************************/ #include <Windows.h> #include <Assert.h> #include <Math.h> #include "GMain.h" #include "Quatern.h" #define INCHES_PER_METER (39.37007874016f) void GenVS_Error(const char *Msg, ...); //oh, dear. //#define FLY_MODE // FIXME: Take out Genesis.h dependency. Replace with server API code that sits on top // of Genesis calls... geBoolean Client_Control(GenVSI *VSI, void *PlayerData, float Time); static geBoolean Door_Control(GenVSI *VSI, void *PlayerData, float Time); static geBoolean Plat_Control(GenVSI *VSI, void *PlayerData, float Time); static geBoolean Door_Trigger(GenVSI *VSI, void *PlayerData, void *TargetData, void* data); void SetupPlayerXForm(GenVSI *VSI, void *PlayerData, float Time); geBoolean Bot_Main(GenVSI *VSI, const char *LevelName); static geBoolean Player_Spawn(GenVSI *VSI, void *PlayerData, void *ClassData,char *EntityName); static geBoolean Door_Spawn(GenVSI *VSI, void *PlayerData, void *ClassData,char *EntityName); static geBoolean Plat_Spawn(GenVSI *VSI, void *PlayerData, void *ClassData,char *EntityName); static geBoolean Plat_Trigger(GenVSI *VSI, void *PlayerData, void *TargetData, void* data); static geBoolean PhysicsObject_Spawn(GenVSI* VSI, void* PlayerData, void* Class,char *EntityName); static void PhysicsObject_Destroy(GenVSI *VSI, void *PlayerData, void *ClassData); static geBoolean PhysicsObject_Trigger(GenVSI* VSI, void* PlayerData, void* TargetData, void* data); static geBoolean PhysicsObject_Control(GenVSI* VSI, void* PlayerData, float Time); static geBoolean PhysicsJoint_Spawn(GenVSI* VSI, void* PlayerData, void* Class,char *EntityName); static void PhysicsJoint_Destroy(GenVSI *VSI, void *PlayerData, void *ClassData); static geBoolean PhysicsJoint_Trigger(GenVSI* VSI, void* PlayerData, void* TargetData, void* data); static geBoolean PhysicsJoint_Control(GenVSI* VSI, void* PlayerData, float Time); static geBoolean PhysicalSystem_Spawn(GenVSI* VSI, void* PlayerData, void* Class,char *EntityName); static void PhysicalSystem_Destroy(GenVSI *VSI, void *PlayerData, void *ClassData); static geBoolean PhysicalSystem_Trigger(GenVSI* VSI, void* PlayerData, void* TargetData, void* data); static geBoolean PhysicalSystem_Control(GenVSI* VSI, void* PlayerData, float Time); static geBoolean ForceField_Spawn(GenVSI* VSI, void* PlayerData, void* Class,char *EntityName); static geBoolean ForceField_Trigger(GenVSI* VSI, void* PlayerData, void* TargetData, void* data); static geBoolean ForceField_Control(GenVSI* VSI, void* PlayerData, float Time); static geBoolean IsKeyDown(int KeyCode); GPlayer *CurrentPlayerStart; //===================================================================================== // Server_Main // Game code called, when server level starts up... //===================================================================================== geBoolean Server_Main(GenVSI *VSI, const char *LevelName) { Bot_Main(VSI, LevelName); CurrentPlayerStart = NULL; // SetClassSpawn functions get called once, and are used for each SetWorld... // Set the calss spawns GenVSI_SetClassSpawn(VSI, "DeathMatchStart", Player_Spawn, NULL); // Doors/Plats/PhysicalObjects/PhysicsJoints/PhysicalSystems/etc. GenVSI_SetClassSpawn(VSI, "Door", Door_Spawn, NULL); GenVSI_SetClassSpawn(VSI, "MovingPlat", Plat_Spawn, NULL); GenVSI_SetClassSpawn(VSI, "PhysicsObject", PhysicsObject_Spawn, PhysicsObject_Destroy); GenVSI_SetClassSpawn(VSI, "PhysicsJoint", PhysicsJoint_Spawn, PhysicsJoint_Destroy); GenVSI_SetClassSpawn(VSI, "PhysicalSystem", PhysicalSystem_Spawn, PhysicalSystem_Destroy); GenVSI_SetClassSpawn(VSI, "ForceField", ForceField_Spawn, NULL); // Change level trigger GenVSI_SetClassSpawn(VSI, "ChangeLevel", ChangeLevel_Spawn, NULL); // Items GenVSI_SetClassSpawn(VSI, "ItemHealth", Item_HealthSpawn, NULL); GenVSI_SetClassSpawn(VSI, "ItemArmor", Item_ArmorSpawn, NULL); GenVSI_SetClassSpawn(VSI, "ItemRocket", Item_RocketSpawn, NULL); GenVSI_SetClassSpawn(VSI, "ItemRocketAmmo", Item_RocketAmmoSpawn, NULL); GenVSI_SetClassSpawn(VSI, "ItemGrenade", Item_GrenadeSpawn, NULL); GenVSI_SetClassSpawn(VSI, "ItemGrenadeAmmo", Item_GrenadeAmmoSpawn, NULL); GenVSI_SetClassSpawn(VSI, "ItemShredder", Item_ShredderSpawn, NULL); GenVSI_SetClassSpawn(VSI, "ItemShredderAmmo", Item_ShredderAmmoSpawn, NULL); GenVSI_SetClassSpawn(VSI, "AttackerTurret", Attacker_TurretSpawn, Attacker_TurretDestroy); // Set the level with these spawns... // FIXME: Rename to: Server_ExecuteClassSpawns(Server, LevelName);??????? GenVSI_SetWorld(VSI, SetupWorldCB, ShutdownWorldCB, LevelName); // Use the level name supplied by the host // Proc indexes GenVSI_ProcIndex(VSI, 0, Client_Control); GenVSI_ProcIndex(VSI, 1, Door_Control); GenVSI_ProcIndex(VSI, 2, Door_Trigger); GenVSI_ProcIndex(VSI, 3, Plat_Control); GenVSI_ProcIndex(VSI, 4, Plat_Trigger); GenVSI_ProcIndex(VSI, 5, Blaster_Control); GenVSI_ProcIndex(VSI, 6, Rocket_Control); GenVSI_ProcIndex(VSI, 7, Grenade_Control); GenVSI_ProcIndex(VSI, 8, Shredder_Control); GenVSI_ProcIndex(VSI, 9, Item_ControlHealth); return GE_TRUE; } //===================================================================================== // Client_Main //===================================================================================== geBoolean Client_Main(GenVSI *VSI) { GenVSI_ProcIndex(VSI, 0, Client_Control); GenVSI_ProcIndex(VSI, 1, Door_Control); GenVSI_ProcIndex(VSI, 2, Door_Trigger); GenVSI_ProcIndex(VSI, 3, Plat_Control); GenVSI_ProcIndex(VSI, 4, Plat_Trigger); GenVSI_ProcIndex(VSI, 5, Blaster_Control); GenVSI_ProcIndex(VSI, 6, Rocket_Control); GenVSI_ProcIndex(VSI, 7, Grenade_Control); GenVSI_ProcIndex(VSI, 8, Shredder_Control); GenVSI_ProcIndex(VSI, 9, Item_ControlHealth); return GE_TRUE; } // Returns GE_FALSE if colliding with self, or owner to self... geBoolean SelfCollisionCB(geWorld_Model *Model, geActor *Actor, void *Context) { if (Actor) { CData *Data; Data = (CData*)Context; assert(Data); assert(Data->Player); if (GenVSI_ActorToPlayer(Data->VSI, Actor) == Data->Player) return GE_FALSE; // NOTE - Owner CAN be NULL... if (GenVSI_ActorToPlayer(Data->VSI, Actor) == Data->Player->Owner) return GE_FALSE; } return GE_TRUE; } // Returns GE_FALSE if colliding with self... geBoolean SelfCollisionCB2(geWorld_Model *Model, geActor *Actor, void *Context) { if (Actor) { CData *Data; Data = (CData*)Context; assert(Data); assert(Data->Player); if (GenVSI_ActorToPlayer(Data->VSI, Actor) == Data->Player) return GE_FALSE; } return GE_TRUE; } int32 GMode; extern int32 MenuBotCount; //===================================================================================== // GetDMSpawn //===================================================================================== GPlayer *GetDMSpawn(GenVSI *VSI) { //if (GenVSI_GetMode(VSI) == 0) if (GMode == 0 && !MenuBotCount) { CurrentPlayerStart = (GPlayer*)GenVSI_GetNextPlayer(VSI, CurrentPlayerStart, "PlayerStart"); if (!CurrentPlayerStart) CurrentPlayerStart = (GPlayer*)GenVSI_GetNextPlayer(VSI, NULL, "PlayerStart"); //if (!CurrentPlayerStart) // GenVS_Error( "Game_SpawnClient: No PlayerStart!\n"); if (!CurrentPlayerStart) CurrentPlayerStart = (GPlayer*)GenVSI_GetNextPlayer(VSI, NULL, "DeathMatchStart"); if (!CurrentPlayerStart) GenVS_Error( "Game_SpawnClient: No PlayerStart or DeathMatchStart!\n"); } else { CurrentPlayerStart = (GPlayer*)GenVSI_GetNextPlayer(VSI, CurrentPlayerStart, "DeathMatchStart"); if (!CurrentPlayerStart) CurrentPlayerStart = (GPlayer*)GenVSI_GetNextPlayer(VSI, NULL, "DeathMatchStart"); if (!CurrentPlayerStart) GenVS_Error( "Game_SpawnClient: No DeathMatchStart!\n"); } return CurrentPlayerStart; } //===================================================================================== // Game_SpawnClient //===================================================================================== geBoolean Game_SpawnClient(GenVSI *VSI, geWorld *World, void *PlayerData, void *ClassData) { int32 i; GPlayer *Player; //Player = (GPlayer*)GenVSI_GetPlayerData(VSI, PlayerHandle); Player = (GPlayer*)PlayerData; geXForm3d_SetIdentity(&Player->XForm); // Get a DM start #ifndef FLY_MODE { GPlayer *DMStart; DMStart = GetDMSpawn(VSI); Player->XForm = DMStart->XForm; } //GenVSI_SetPlayerBox(VSI, PlayerHandle, &Mins, &Maxs); Player->Mins.X = -30.0f; Player->Mins.Y = -10.0f; Player->Mins.Z = -30.0f; Player->Maxs.X = 30.0f; Player->Maxs.Y = 160.0f; Player->Maxs.Z = 30.0f; #else Player->Mins.X =-5.0f; Player->Mins.Y =-5.0f; Player->Mins.Z =-5.0f; Player->Maxs.X = 5.0f; Player->Maxs.Y = 5.0f; Player->Maxs.Z = 5.0f; #endif Player->Time = 0.0f; Player->JustSpawned = GE_TRUE; //GenVSI_SetClientGunOffset(VSI, ClientHandle, 0.0f, 130.0f, 0.0f); Player->GunOffset.X = 0.0f; Player->GunOffset.Y = 130.0f; Player->GunOffset.Z = 0.0f; Player->Scale = 2.7f; // Set the view info Player->ViewFlags = VIEW_TYPE_ACTOR | VIEW_TYPE_YAW_ONLY | VIEW_TYPE_COLLIDEMODEL; Player->ViewIndex = ACTOR_INDEX_PLAYER; Player->MotionIndex = ACTOR_MOTION_PLAYER_RUN; Player->DammageFlags = DAMMAGE_TYPE_NORMAL | DAMMAGE_TYPE_RADIUS; // Hook player up to client physics controller Player->ControlIndex = 0; Player->Control = Client_Control; // Set the view player on this machine to the clients player GenVSI_SetViewPlayer(VSI, Player->ClientHandle, Player); // Players keep track of scoring, health, etc for now. // Server_SetClientScore/Health must be called to update a particular client // that is associated with a player... Player->Health = 100; Player->Score = 0; // FIXME: Soon, Scores, Health, etc won't be so arbitrary. Maybe somthing like // Quake2's Layouts will be used instead, making it easier to make games that don't // use this sort of scoring system... GenVSI_SetClientScore(VSI, Player->ClientHandle, Player->Score); GenVSI_SetClientHealth(VSI, Player->ClientHandle, Player->Health); for (i=0; i< MAX_PLAYER_ITEMS; i++) { Player->Inventory[i] = 0; Player->InventoryHas[i] = GE_FALSE; } Player->CurrentWeapon = 0; GenVSI_SetClientInventory(VSI, Player->ClientHandle, ITEM_GRENADES, 0, GE_FALSE); GenVSI_SetClientInventory(VSI, Player->ClientHandle, ITEM_ROCKETS, 0, GE_FALSE); GenVSI_SetClientInventory(VSI, Player->ClientHandle, ITEM_SHREDDER, 0, GE_FALSE); Player->NextWeaponTime = 0.0f; return GE_TRUE; } //===================================================================================== // Game_DestroyClient //===================================================================================== void Game_DestroyClient(GenVSI *VSI, void *PlayerData, void *ClassData) { //GenVS_Error( "Client destroyed..."); // For debugging... } //===================================================================================== // Local static functions... //===================================================================================== //extern geEngine *Engine; //===================================================================================== // PlayerLiquid // // Checks to see if the player is in a liquid state, and returns the power of the state // Stronger numbers mean thicker liquid, etc... //===================================================================================== int32 PlayerLiquid(GPlayer *Player) { if (Player->State == PSTATE_InLava) return 10; else if (Player->State == PSTATE_InWater) return 5; return 0; } //===================================================================================== // CheckPlayer //===================================================================================== static geBoolean CheckPlayer(GenVSI *VSI, void *PlayerData) { geVec3d Mins, Maxs, Pos; GE_Contents Contents; GPlayer *Player; uint32 ColFlags; Player = (GPlayer*)PlayerData; Mins = Player->Mins; Maxs = Player->Maxs; Pos = Player->XForm.Translation; ColFlags = GE_COLLIDE_MODELS; if (geWorld_GetContents(GenVSI_GetWorld(VSI), &Pos, &Mins, &Maxs, ColFlags, 0, NULL, NULL, &Contents)) { if (Contents.Contents & GE_CONTENTS_SOLID) { //geEngine_Printf(Engine, 10, 85, "Stuck"); if (Player->JustSpawned) { GenVS_Error("Player_CheckPlayer: the player's starting position is bad - some of the player's bounding box is in solid space."); } Player->XForm.Translation = Player->LastGoodPos; Player->JustSpawned = 0; return GE_TRUE; } } Player->JustSpawned = 0; return GE_FALSE; } #define STEP_HEIGHT 42.0f //===================================================================================== // MovePlayerUpStep //===================================================================================== geBoolean MovePlayerUpStep(GenVSI *VSI, void *PlayerData, GE_Collision *Collision) { geVec3d Mins, Maxs, Pos1, Pos2; GE_Collision Collision2; GPlayer *Player; geWorld *World; Player = (GPlayer*)PlayerData; World = GenVSI_GetWorld(VSI); assert(World); Mins = Player->Mins; Maxs = Player->Maxs; Pos1 = Player->XForm.Translation; Pos2 = Player->XForm.Translation; Pos2.Y += STEP_HEIGHT; // Try to "pop" up on the step if (geWorld_Collision(World, &Mins, &Maxs, &Pos1, &Pos2, GE_CONTENTS_CANNOT_OCCUPY, GE_COLLIDE_MODELS, 0, NULL, NULL, &Collision2)) return GE_FALSE; // Can't move // Move forward (opposite the normal) Pos1 = Pos2; geVec3d_AddScaled(&Pos2, &Collision->Plane.Normal, -0.5f, &Pos2); if (geWorld_Collision(World, &Mins, &Maxs, &Pos1, &Pos2, GE_CONTENTS_CANNOT_OCCUPY, GE_COLLIDE_MODELS, 0, NULL, NULL, &Collision2)) return GE_FALSE; // Can't move // Put him back on the ground Pos1 = Pos2; Pos2.Y -= (STEP_HEIGHT+1.0f); // NOTE that this should allways return a collision if (geWorld_Collision(World, &Mins, &Maxs, &Pos1, &Pos2, GE_CONTENTS_CANNOT_OCCUPY, GE_COLLIDE_MODELS, 0, NULL, NULL, &Collision2)) { Pos2 = Collision2.Impact; Player->State = PSTATE_Normal; } else return GE_FALSE; Player->XForm.Translation = Pos2; return GE_TRUE; } #define MAX_CLIP_PLANES 5 //===================================================================================== // CheckVelocity // Adjust players Velocity. based on what it's doing in the world //===================================================================================== geBoolean CheckVelocity(GenVSI *VSI, void *PlayerData, float BounceScale, geBoolean AllowBounce, float Time) { int32 NumHits, NumPlanes; GE_Collision Collision; int32 HitCount, i, j; geVec3d Mins, Maxs; geVec3d Planes[MAX_CLIP_PLANES]; geVec3d Pos, NewPos, OriginalVelocity, PrimalVelocity; geVec3d NewVelocity, Dir; float TimeLeft, Dist; GE_Contents Contents; GPlayer *Player; geWorld *World; uint32 ColFlags; #if 0 geEntity_EntitySet * Set; geEntity * Entity; geVec3d boundingBoxCenter, boundingBoxScale, forceFieldCenterToBBCenter; #endif // end VAR section //////////////////////////////////////////////////////////////////////////////////////////////////// // BEGIN Player = (GPlayer*)PlayerData; World = GenVSI_GetWorld(VSI); assert(World); Mins = Player->Mins; Maxs = Player->Maxs; geVec3d_Copy(&Player->Velocity, &OriginalVelocity); geVec3d_Copy(&Player->Velocity, &PrimalVelocity); TimeLeft = Time; NumHits = 4; NumPlanes = 0; if (Player->State == PSTATE_Normal) Player->State = PSTATE_InAir; ColFlags = GE_COLLIDE_MODELS; //////////////////////////////////////////////////////////////////////////////////////////////////// // check for penetration of Player's bounding box into the radius of a ForceField entity #if 0 geVec3d_Copy(&Player->XForm.Translation, &boundingBoxCenter); boundingBoxScale.X = (float)fabs(0.5f * (Maxs.X - Mins.X)); boundingBoxScale.Y = (float)fabs(0.5f * (Maxs.Y - Mins.Y)); boundingBoxScale.Z = (float)fabs(0.5f * (Maxs.Z - Mins.Z)); #pragma message ("Use: GenVSI_GetNextPlayer here...") Set = NULL; Set = geWorld_GetEntitySet(World, "ForceField"); if (Set != NULL) { for (Entity = geEntity_EntitySetGetNextEntity(Set, NULL); Entity != NULL; Entity = geEntity_EntitySetGetNextEntity(Set, Entity)) { ForceField* ff; float forceMultiplier; float distToFFCenter; float forceMagnitude; geVec3d forceDir; geVec3d forceToApply; geVec3d impulse; ff = geEntity_GetUserData(Entity); assert(ff != NULL); if (! ff->affectsPlayers) continue; geVec3d_Subtract(&boundingBoxCenter, &ff->Origin, &forceFieldCenterToBBCenter); geVec3d_Copy(&forceFieldCenterToBBCenter, &forceDir); #pragma message("does geVec3d_Normalize() return length?") geVec3d_Normalize(&forceDir); distToFFCenter = geVec3d_Length(&forceFieldCenterToBBCenter); if (distToFFCenter < 1.f) distToFFCenter = 1.f; if ((boundingBoxCenter.X + boundingBoxScale.X) < (ff->Origin.X - ff->radius)) continue; if ((boundingBoxCenter.X - boundingBoxScale.X) > (ff->Origin.X + ff->radius)) continue; if ((boundingBoxCenter.Y + boundingBoxScale.Y) < (ff->Origin.Y - ff->radius)) continue; if ((boundingBoxCenter.Y - boundingBoxScale.Y) > (ff->Origin.Y + ff->radius)) continue; if ((boundingBoxCenter.Z + boundingBoxScale.Z) < (ff->Origin.Z - ff->radius)) continue; if ((boundingBoxCenter.Z - boundingBoxScale.Z) > (ff->Origin.Z + ff->radius)) continue; //////////////////////////////////////////////////////////////////////////////////////////////////// // player is inside radius of force field, figure out how much force // to apply based on force field's falloff function switch(ff->falloffType) { case FALLOFF_NONE: forceMultiplier = 1.f; break; case FALLOFF_ONE_OVER_D: forceMultiplier = 1 / distToFFCenter; break; case FALLOFF_ONE_OVER_DSQUARED: forceMultiplier = 1 / (distToFFCenter * distToFFCenter); break; default: forceMultiplier = 1.f; } forceMagnitude = ff->strength * forceMultiplier * 1000.f; geVec3d_Scale(&forceDir, forceMagnitude, &forceToApply); geVec3d_Scale(&forceToApply, Time, &impulse); geVec3d_Add(&impulse, &Player->Velocity, &Player->Velocity); } // while } // if #endif //////////////////////////////////////////////////////////////////////////////////////////////////// for (HitCount=0 ; HitCount<NumHits ; HitCount++) { float Fd, Bd; //Server_Player *UPlayer; Pos = Player->XForm.Translation; geVec3d_AddScaled(&Pos, &Player->Velocity, TimeLeft, &NewPos); // Make sure the pos did not start out in solid if (geWorld_GetContents(World, &Pos, &Mins, &Maxs, GE_COLLIDE_MODELS, 0, NULL, NULL, &Contents)) { if (Contents.Contents & GE_CONTENTS_SOLID) { if (geWorld_GetContents(World, &NewPos, &Mins, &Maxs, GE_COLLIDE_MODELS, 0, NULL, NULL, &Contents)) { if (Contents.Contents & GE_CONTENTS_SOLID) { geVec3d_Copy(&Player->LastGoodPos, &Player->XForm.Translation); geVec3d_Clear(&Player->Velocity); return GE_TRUE; } } } } if (!geWorld_Collision(World, &Mins, &Maxs, &Pos, &NewPos, GE_CONTENTS_CANNOT_OCCUPY, GE_COLLIDE_MODELS, 0, NULL, NULL, &Collision)) return GE_TRUE; // Covered the entire distance... if (Collision.Plane.Normal.Y > 0.7f) { if (Player->State == PSTATE_InAir) Player->State = PSTATE_Normal; // Put the player on the ground if in air else if (Player->State == PSTATE_Dead) Player->State = PSTATE_DeadOnGround; // Put the player on the ground if in air if (Collision.Model) { GPlayer *Target; Target = (GPlayer*)geWorld_ModelGetUserData(Collision.Model); if (Target && Target->Trigger && Target->ViewFlags & VIEW_TYPE_STANDON) Target->Trigger(VSI, Target, Player, NULL); } } if (Collision.Model) { GPlayer *Target; #pragma message ("Use: GenVSI_ModelToPlayer...") Target = (GPlayer*)geWorld_ModelGetUserData(Collision.Model); if (Target && Target->Trigger && Target->ViewFlags & VIEW_TYPE_PHYSOB) Target->Trigger(VSI, Target, Player, (void*)&Collision); } if (Collision.Actor) // Just stop at actors for now... { geVec3d_Copy(&Player->LastGoodPos, &Player->XForm.Translation); geVec3d_Clear(&Player->Velocity); return GE_TRUE; } // FIXME: Save this ratio in the impact function... Fd = geVec3d_DotProduct(&Pos, &Collision.Plane.Normal) - Collision.Plane.Dist; Bd = geVec3d_DotProduct(&NewPos, &Collision.Plane.Normal) - Collision.Plane.Dist; Collision.Ratio = Fd / (Fd - Bd); if (Collision.Ratio > 0.00f) // Actually covered some distance { // Set the players pos to the impact point geVec3d_Copy(&Collision.Impact, &Player->XForm.Translation); // Restore Velocity geVec3d_Copy(&Player->Velocity, &OriginalVelocity); NumPlanes = 0; } if (!Collision.Plane.Normal.Y) { if (MovePlayerUpStep(VSI, Player, &Collision)) { continue; } } //TimeLeft -= TimeLeft * Collision.Ratio; // Clipped to another plane if (NumPlanes >= MAX_CLIP_PLANES) { GenVSI_ConsolePrintf(VSI, "MAX_CLIP_PLANES!!!\n"); geVec3d_Clear(&Player->Velocity); return GE_TRUE; } // Add the plane hit, to the plane list geVec3d_Copy (&Collision.Plane.Normal, &Planes[NumPlanes]); NumPlanes++; // // Modify original_velocity so it parallels all of the clip planes // for (i=0 ; i<NumPlanes ; i++) { ReflectVelocity(&OriginalVelocity, &Planes[i], &NewVelocity, BounceScale); for (j=0 ; j<NumPlanes ; j++) { if (j != i) { if (geVec3d_DotProduct(&NewVelocity, &Planes[j]) < 0.0f) break; // not ok } } if (j == NumPlanes) break; } if (i != NumPlanes) { // Go along this plane geVec3d_Copy(&NewVelocity, &Player->Velocity); } else { if (NumPlanes != 2) { //Console_Printf(Server->Host->Console, "Clip velocity, numplanes == %i\n",NumPlanes); geVec3d_Clear(&Player->Velocity); return GE_TRUE; } //Console_Printf(Server->Host->Console, "Cross product\n",NumPlanes); geVec3d_CrossProduct(&Planes[0], &Planes[1], &Dir); Dist = geVec3d_DotProduct(&Dir, &Player->Velocity); geVec3d_Scale(&Dir, Dist, &Player->Velocity); } // // Don't allow new velocity to go against original velocity unless told otherwise // if (!AllowBounce && geVec3d_DotProduct (&Player->Velocity, &PrimalVelocity) <= 0.0f) { geVec3d_Clear(&Player->Velocity); return GE_TRUE; } } return GE_TRUE; } //===================================================================================== // PlayerPhysics //===================================================================================== geBoolean PlayerPhysics(GenVSI *VSI, void *PlayerData, float GroundFriction, float AirFriction, float LiquidFriction, float Gravity, float BounceScale, geBoolean AllowBounce, float Time) { float Speed; GPlayer *Player; Player = (GPlayer*)PlayerData; #ifndef FLY_MODE Player->LastGoodPos = Player->XForm.Translation; // Add gravity switch (Player->State) { case PSTATE_InLava: case PSTATE_InWater: Player->Velocity.Y -= PLAYER_GRAVITY*Time*0.05f; break; default: Player->Velocity.Y -= PLAYER_GRAVITY*Time; break; } CheckVelocity(VSI, Player, BounceScale, AllowBounce, Time); SqueezeVector(&Player->Velocity, 0.2f); geVec3d_AddScaled(&Player->XForm.Translation, &Player->Velocity, Time, &Player->XForm.Translation); CheckPlayer(VSI, Player); #else // Fly through walls Player->State = PSTATE_InAir; SqueezeVector(&Player->Velocity, 0.2f); geVec3d_AddScaled(&Player->XForm.Translation, &Player->Velocity, Time, &Player->XForm.Translation); #endif Speed = geVec3d_Length(&Player->Velocity); // Apply friction if (Speed > 0.001) { float NewSpeed; if (Player->State == PSTATE_Normal || Player->State == PSTATE_DeadOnGround) NewSpeed = Speed - Time*Speed*PLAYER_GROUND_FRICTION; else if (Player->State == PSTATE_InAir || Player->State == PSTATE_Dead) NewSpeed = Speed - Time*Speed*PLAYER_AIR_FRICTION; else if (PlayerLiquid(Player)) NewSpeed = Speed - Time*Speed*PLAYER_LIQUID_FRICTION; if (NewSpeed < 0.0f) NewSpeed = 0.0f; NewSpeed /= Speed; // Apply movement friction geVec3d_Scale(&Player->Velocity, NewSpeed, &Player->Velocity); } UpdatePlayerContents(VSI, Player, Time); return GE_TRUE; } //===================================================================================== // UpdatePlayerContents //===================================================================================== geBoolean UpdatePlayerContents(GenVSI *VSI, void *PlayerData, float Time) { GPlayer *Player; geWorld *World; GE_Contents Contents; World = GenVSI_GetWorld(VSI); assert(World); Player = (GPlayer*)PlayerData; if (geWorld_GetContents(World, &Player->XForm.Translation, &Player->Mins, &Player->Maxs, GE_COLLIDE_MODELS, 0, NULL, NULL, &Contents)) { // Check to see if player is in lava... if (Contents.Contents & CONTENTS_WATER) { Player->State = PSTATE_InWater; } else if (Contents.Contents & CONTENTS_LAVA) { Player->State = PSTATE_InLava; } else if (PlayerLiquid(Player)) Player->State = PSTATE_Normal; } else if (PlayerLiquid(Player)) Player->State = PSTATE_Normal; return GE_TRUE; } geBoolean PlayerDead(GPlayer *Player) { assert(Player); if (Player->State == PSTATE_Dead) return GE_TRUE; if (Player->State == PSTATE_DeadOnGround) return GE_TRUE; return GE_FALSE; } static int32 Hack2; //===================================================================================== // Client_Control //===================================================================================== geBoolean Client_Control(GenVSI *VSI, void *PlayerData, float Time) { geVec3d LVect, InVect; float Speed; GE_Contents Contents; geVec3d CMins, CMaxs; float MoveSpeed; geBoolean DoWalk = GE_FALSE; geXForm3d XForm; GPlayer *Player; GenVSI_CMove *Move; geWorld *World; uint32 ColFlags; CData Data; Player = (GPlayer*)PlayerData; assert(Player); assert(Player->ClientHandle != CLIENT_NULL_HANDLE); // FIXME: Make this function take care of dead players also. Use a switch statement or somthing. // We should not be changing control functions on the fly like that. Could confuse the server/client... //assert(Player->State != PSTATE_Dead && Player->State != PSTATE_DeadOnGround); if (PlayerDead(Player)) return GE_TRUE; if (IsKeyDown('L')) { GenVSI_SetWorld(VSI, SetupWorldCB, ShutdownWorldCB, "Levels\\GenVs.Bsp"); return GE_TRUE; } Move = GenVSI_GetClientMove(VSI, Player->ClientHandle); if (!Move) return GE_TRUE; assert(Move); Player->Time += Time; // Make sure the xform is valid SetupPlayerXForm(VSI, Player, Time); geXForm3d_SetYRotation(&XForm, Move->Angles.Y); geXForm3d_GetLeft(&XForm, &LVect); #ifdef FLY_MODE geXForm3d_GetIn(&Player->XForm, &InVect); // Use the real in vector for liquid #else if (PlayerLiquid(Player)) geXForm3d_GetIn(&Player->XForm, &InVect); // Use the real in vector for liquid else geXForm3d_GetIn(&XForm, &InVect); #endif //if (VSI->Mode == MODE_Server) if (Move->ButtonBits & HOST_BUTTON_FIRE) { uint16 Amount; geBoolean Has; Player->CurrentWeapon = Move->Weapon; assert(Player->CurrentWeapon >= 0 && Player->CurrentWeapon <= 3); assert(Player->ClientHandle != CLIENT_NULL_HANDLE); FireWeapon(VSI, PlayerData, Time); assert(Player->Inventory[Player->CurrentWeapon] >= 0 && Player->Inventory[Player->CurrentWeapon] < 65535); Amount = (uint16)Player->Inventory[Player->CurrentWeapon]; Has = Player->InventoryHas[Player->CurrentWeapon]; GenVSI_SetClientInventory(VSI, Player->ClientHandle, Player->CurrentWeapon, Amount, Has); // Force a weapon update } MoveSpeed = Time; if (Player->State != PSTATE_Normal) MoveSpeed *= 0.15f; // Set his movement Velocity if (Move->ForwardSpeed) { geVec3d_MA(&Player->Velocity, Move->ForwardSpeed*MoveSpeed, &InVect, &Player->Velocity); } if (Move->ButtonBits & HOST_BUTTON_LEFT) geVec3d_MA(&Player->Velocity, PLAYER_SIDE_SPEED*MoveSpeed, &LVect, &Player->Velocity); if (Move->ButtonBits & HOST_BUTTON_RIGHT) geVec3d_MA(&Player->Velocity, -PLAYER_SIDE_SPEED*MoveSpeed, &LVect, &Player->Velocity); if ((Move->ButtonBits & HOST_BUTTON_JUMP) && (PlayerLiquid(Player) || Player->State == PSTATE_Normal)) { GenVSI_PlaySound(VSI, SOUND_INDEX_JUMP, &Player->XForm.Translation); if (Player->State == PSTATE_Normal) Player->Velocity.Y += PLAYER_JUMP_THRUST; else Player->Velocity.Y += PLAYER_JUMP_THRUST*0.2f; } // Run polayer physics code... PlayerPhysics(VSI, Player, PLAYER_GROUND_FRICTION, PLAYER_AIR_FRICTION, PLAYER_LIQUID_FRICTION, PLAYER_GRAVITY, 1.0f, GE_FALSE, Time); World = GenVSI_GetWorld(VSI); assert(World); ColFlags = GE_COLLIDE_MODELS; if (VSI->Mode == MODE_Server) // Only do this stuff when we are in server mode... { if (!PlayerDead(Player) && Player->Roll > 0.0f) Player->Roll -= Time; #ifndef FLY_MODE if (Player->State == PSTATE_InLava) { if (Player->Roll <= 0.0f) { DammagePlayer(VSI, NULL, Player, 20, 0.0f, Time); Player->Roll = 0.5f; } } #endif // Get a box a little bigger than the player for doors, etc... CMins = Player->Mins; CMaxs = Player->Maxs; CMins.X -= 100; CMins.Y -= 10; CMins.Z -= 100; CMaxs.X += 100; CMaxs.Y += 10; CMaxs.Z += 100; if (geWorld_GetContents(World, &Player->XForm.Translation, &CMins, &CMaxs, GE_COLLIDE_MODELS, 0, NULL, NULL, &Contents)) { if (Contents.Model) { GPlayer *TPlayer; TPlayer = (GPlayer*)geWorld_ModelGetUserData(Contents.Model); if (TPlayer) { Hack2 = 0; } if (TPlayer && TPlayer->Trigger && TPlayer->ViewFlags & VIEW_TYPE_TOUCH) { TPlayer->Trigger(VSI, TPlayer, Player, NULL); } } } Data.VSI = VSI; Data.Player = Player; if (geWorld_GetContents(World, &Player->XForm.Translation, &CMins, &CMaxs, GE_COLLIDE_ACTORS, 0xffffffff, SelfCollisionCB, &Data, &Contents)) //if (geWorld_GetContents(World, &Player->XForm.Translation, &CMins, &CMaxs, GE_COLLIDE_ACTORS, 0xffffffff, NULL, NULL, &Contents)) { if (Contents.Actor) { GPlayer *TPlayer; static int32 HackV; //GenVSI_ConsoleHeaderPrintf(VSI, Player->ClientHandle, GE_FALSE, "Hit actor:%i", HackV++); TPlayer = (GPlayer*)GenVSI_ActorToPlayer(VSI, Contents.Actor); if (TPlayer && TPlayer->Trigger)// && TPlayer->ViewFlags & VIEW_TYPE_TOUCH) { TPlayer->Trigger(VSI, TPlayer, Player, NULL); } } } } Speed = geVec3d_Length(&Player->Velocity); if ((Move->ButtonBits & HOST_BUTTON_LEFT) || (Move->ButtonBits & HOST_BUTTON_RIGHT) || Move->ForwardSpeed) { if (Player->MotionIndex != ACTOR_MOTION_PLAYER_RUN) Player->FrameTime = 0.0f; Player->MotionIndex = ACTOR_MOTION_PLAYER_RUN; DoWalk = GE_TRUE; } if (Speed > 0.1f && DoWalk) { if (Player->MotionIndex == ACTOR_MOTION_PLAYER_RUN) { Speed*=0.004f; if (Move->ForwardSpeed<0) Speed *= -1.0f; } else Speed = 1.0f; if (AnimatePlayer(VSI, Player, Player->MotionIndex, Time*Speed, GE_TRUE)) { if (Player->MotionIndex != ACTOR_MOTION_PLAYER_RUN) Player->FrameTime = 0.0f; Player->MotionIndex = ACTOR_MOTION_PLAYER_RUN; } } else { if (Player->MotionIndex != ACTOR_MOTION_PLAYER_IDLE) { Player->MotionIndex = ACTOR_MOTION_PLAYER_IDLE; Player->FrameTime = 0.0f; } AnimatePlayer(VSI, Player, Player->MotionIndex, Time, GE_TRUE); } // Make sure the xform is valid SetupPlayerXForm(VSI, Player, Time); Player->VPos = Player->XForm.Translation; return GE_TRUE; } //===================================================================================== // Player_Spawn //===================================================================================== geBoolean Player_Spawn(GenVSI *VSI, void *PlayerData, void *ClassData, char *EntityName) { PlayerStart *Ps; GPlayer *Player; Player = (GPlayer*)PlayerData; Player->Control = NULL; Player->Trigger = NULL; Player->Blocked = NULL; Player->Time = 0.0f; if (ClassData == NULL) { GenVS_Error("Player_Spawn: entity missing class data ('%s')\n",EntityName); } Ps = (PlayerStart*)ClassData; geXForm3d_SetIdentity(&Player->XForm); geXForm3d_SetTranslation(&Player->XForm, Ps->Origin.X, Ps->Origin.Y, Ps->Origin.Z); Player->VPos = Player->XForm.Translation; return GE_TRUE; } //===================================================================================== // Door_Control //===================================================================================== static geBoolean Door_Control(GenVSI *VSI, void *PlayerData, float Time) { geWorld_Model *Model; geMotion *Motion; float StartTime, EndTime, NewTime; geXForm3d DestXForm; gePath *Path; GPlayer *Player; geWorld *World; Player = (GPlayer*)PlayerData; if (Player->State != PSTATE_Opened) return GE_TRUE; World = GenVSI_GetWorld(VSI); assert(World); Model = Player->Model; assert(Model); Motion = geWorld_ModelGetMotion(Model); assert(Motion); NewTime = Player->FrameTime + Time; Path = geMotion_GetPath(Motion, 0); assert(Path); geMotion_GetTimeExtents(Motion, &StartTime , &EndTime); if (NewTime >= EndTime) // Played through, done... { NewTime = StartTime; Player->State = PSTATE_Closed; Player->ViewFlags &= ~VIEW_TYPE_MODEL_OPEN; } // Get the xform for the current time gePath_Sample(Path, NewTime, &DestXForm); // If the player can move, then update time, and xform if (GenVSI_MovePlayerModel(VSI, Player, &DestXForm)) { Player->XForm = DestXForm; //DData->AnimTime = NewTime; Player->FrameTime = NewTime; } //geWorld_GetModelRotationalCenter(World, Model, &Player->VPos); //geVec3d_Add(&Player->VPos, &Player->XForm.Translation, &Player->VPos); return GE_TRUE; } //===================================================================================== // Plat_Control //===================================================================================== static geBoolean Plat_Control(GenVSI *VSI, void *PlayerData, float Time) { geWorld_Model *Model; geMotion *Motion; float StartTime, EndTime, NewTime; geXForm3d DestXForm; gePath *Path; GPlayer *Player; geWorld *World; MovingPlat *Plat; Player = (GPlayer*)PlayerData; if (Player->State != PSTATE_Opened) return GE_TRUE; World = GenVSI_GetWorld(VSI); assert(World); Model = Player->Model; assert(Model); Motion = geWorld_ModelGetMotion(Model); assert(Motion); NewTime = Player->FrameTime + Time; Path = geMotion_GetPath(Motion, 0); assert(Path); geMotion_GetTimeExtents(Motion, &StartTime , &EndTime); if (NewTime >= EndTime) // Played through, done... { NewTime = StartTime; Player->State = PSTATE_Closed; Player->ViewFlags &= ~VIEW_TYPE_MODEL_OPEN; Plat = (MovingPlat*)Player->ClassData; /* if (Plat->Loop) { Player->Trigger(VSI, Player, NULL); } */ } // Get the xform for the current time gePath_Sample(Path, NewTime, &DestXForm); // If the player can move, then update time, and xform if (GenVSI_MovePlayerModel(VSI, Player, &DestXForm)) { Player->XForm = DestXForm; //DData->AnimTime = NewTime; Player->FrameTime = NewTime; } //geWorld_GetModelRotationalCenter(World, Model, &Player->VPos); //geVec3d_Add(&Player->VPos, &Player->XForm.Translation, &Player->VPos); return GE_TRUE; } //===================================================================================== // Door_Trigger //===================================================================================== static geBoolean Door_Trigger(GenVSI *VSI, void *PlayerData, void *TargetData, void* data) { GPlayer *Player, *Target; Player = (GPlayer*)PlayerData; Target = (GPlayer*)TargetData; if (Player->State == PSTATE_Opened) return GE_TRUE; Player->State = PSTATE_Opened; Player->FrameTime = 0.0f; assert(Player->Model); Player->ViewFlags |= VIEW_TYPE_MODEL_OPEN; GenVSI_PlaySound(VSI, 2, &Player->XForm.Translation); return GE_TRUE; } //===================================================================================== // Door_Blocked //===================================================================================== static geBoolean Door_Blocked(GenVSI *VSI, void *PlayerData, void *TargetData) { return GE_TRUE; } //===================================================================================== // Door_Spawn //===================================================================================== static geBoolean Door_Spawn(GenVSI *VSI, void *PlayerData, void *ClassData, char *EntityName) { geWorld_Model *Model; geMotion *Motion; gePath *Path; GPlayer *Player; Door *FuncDoor; geWorld *World; Player = (GPlayer*)PlayerData; Player->Control = Door_Control; Player->Trigger = Door_Trigger; Player->Blocked = Door_Blocked; Player->ControlIndex = 1; //Player->TriggerIndex = 2; Player->Time = 0.0f; // Setup the doors local user data (not passed accross network) // Grab the model FuncDoor = (Door*)ClassData; Player->VPos = FuncDoor->Origin; Model = FuncDoor->Model; if (!Model) { GenVS_Error( "Door_Spawn: No model for entity:%s.\n",EntityName); return GE_FALSE; } World = GenVSI_GetWorld(VSI); //geWorld_GetModelRotationalCenter(World, Model, &Player->VPos); // Set the default xform to time 0 of the animation Motion = geWorld_ModelGetMotion(Model); if (!Motion) { GenVS_Error( "Door_Spawn: No motion for model ('%s').\n",EntityName); return GE_FALSE; } Path = geMotion_GetPath(Motion, 0); if (!Path) { GenVS_Error( "Door_Spawn: No path for model motion ('%s').\n",EntityName); return GE_FALSE; } // Put model at default position gePath_Sample(Path, 0.0f, &Player->XForm); Player->ViewFlags = VIEW_TYPE_MODEL | VIEW_TYPE_TOUCH; Player->ViewIndex = GenVSI_ModelToViewIndex(VSI, Model); // Special index // Register the model with the player if all is ok // NOTE - If somthing went bad, then this should not be called!!! GenVSI_RegisterPlayerModel(VSI, Player, Model); return GE_TRUE; } //===================================================================================== // Plat_Trigger //===================================================================================== static geBoolean Plat_Trigger(GenVSI *VSI, void *PlayerData, void *TargetData, void* data) { geVec3d Pos; GPlayer *Player, *Target; Player = (GPlayer*)PlayerData; Target = (GPlayer*)TargetData; if (Player->State == PSTATE_Opened) return GE_TRUE; Player->State = PSTATE_Opened; Player->FrameTime = 0.0f; if (Target) { Pos = Target->XForm.Translation; } else { geWorld *World; World = GenVSI_GetWorld(VSI); assert(World); geWorld_GetModelRotationalCenter(World, Player->Model, &Pos); geVec3d_Add(&Pos, &Player->XForm.Translation, &Pos); } GenVSI_PlaySound(VSI, 2, &Pos); return GE_TRUE; } //===================================================================================== // Plat_Spawn //===================================================================================== static geBoolean Plat_Spawn(GenVSI *VSI, void *PlayerData, void *ClassData, char *EntityName) { geWorld_Model *Model; geMotion *Motion; gePath *Path; GPlayer *Player; MovingPlat *Plat; geWorld *World; Player = (GPlayer*)PlayerData; Player->Control = Plat_Control; Player->Trigger = Plat_Trigger; Player->Time = 0.0f; Player->ControlIndex = 3; //Player->TriggerIndex = 4; // Setup the plats local user data (not passed accross network) Plat = (MovingPlat*)ClassData; Player->VPos = Plat->Origin; // Grab the model Model = Plat->Model; if (!Model) { GenVS_Error( "Plat_Spawn: No model for entity ('%s').\n",EntityName); return GE_FALSE; } World = GenVSI_GetWorld(VSI); //geWorld_GetModelRotationalCenter(World, Model, &Player->VPos); // Set the default xform to time 0 of the animation Motion = geWorld_ModelGetMotion(Model); if (!Motion) { GenVS_Error( "Plat_Spawn: No motion for model ('%s').\n",EntityName); return GE_FALSE; } Path = geMotion_GetPath(Motion, 0); if (!Path) { GenVS_Error( "Plat_Spawn: No path for model motion ('%s').\n",EntityName); return GE_FALSE; } // Put model at default position gePath_Sample(Path, 0.0f, &Player->XForm); Player->ViewFlags = VIEW_TYPE_MODEL | VIEW_TYPE_STANDON; Player->ViewIndex = GenVSI_ModelToViewIndex(VSI, Model); // Special index // Register the model with the player if all is ok // NOTE - If somthing went bad, then this should not be called!!! GenVSI_RegisterPlayerModel(VSI, Player, Model); /* if (Plat->Loop) { Player->Trigger(VSI, Player, NULL); } */ return GE_TRUE; } //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //===================================================================================== // PhysicsObject_Spawn //===================================================================================== static geBoolean PhysicsObject_Spawn(GenVSI *VSI, void *PlayerData, void *ClassData, char *EntityName) { geWorld_Model *Model; GPlayer *Player; PhysicsObject *po; geWorld *World; geVec3d Mins; geVec3d Maxs; Player = (GPlayer*)PlayerData; Player->Control = PhysicsObject_Control; Player->Trigger = PhysicsObject_Trigger; Player->Time = 0.0f; po = NULL; po = (PhysicsObject*)ClassData; if (po == NULL) { GenVS_Error( "PhysicsObject_Spawn: NULL class data for physics entity '%s'. (at coordinates: x=%f y=%f z=%f)\n", EntityName,po->Origin.X,po->Origin.Y,po->Origin.Z); return GE_FALSE; } Model = po->Model; Player->VPos = po->Origin; if (!Model) { GenVS_Error( "PhysicsObject_Spawn: No model for physics entity '%s'. (at coordinates: x=%f y=%f z=%f)\n", EntityName,po->Origin.X,po->Origin.Y,po->Origin.Z); return GE_FALSE; } World = GenVSI_GetWorld(VSI); //////////////////////////////////////////////////////////////////////////////////////////////////// Player->ViewFlags = VIEW_TYPE_MODEL | VIEW_TYPE_PHYSOB; Player->ViewIndex = GenVSI_ModelToViewIndex(VSI, Model); #define PHYSOB_MAX_DAMPING (1.f) #define PHYSOB_MIN_DAMPING (0.f) if (po->linearDamping < PHYSOB_MIN_DAMPING) po->linearDamping = PHYSOB_MIN_DAMPING; else if (po->linearDamping > PHYSOB_MAX_DAMPING) po->linearDamping = PHYSOB_MAX_DAMPING; if (po->angularDamping < PHYSOB_MIN_DAMPING) po->angularDamping = PHYSOB_MIN_DAMPING; else if (po->angularDamping > PHYSOB_MAX_DAMPING) po->angularDamping = PHYSOB_MAX_DAMPING; geWorld_ModelGetBBox(World, po->Model, &Mins, &Maxs); #pragma message("Mins / maxs should be OK in the next build") po->stateInfo = gePhysicsObject_Create(&po->Origin, po->mass, po->isAffectedByGravity, po->respondsToForces, po->linearDamping, po->angularDamping, &Mins, &Maxs, 0.01f); //po->physicsScale); if (po->stateInfo == NULL) { GenVS_Error( "PhysicsObject_Spawn: gePhysicsObject_Create failed for physics entity '%s'\n",EntityName); return GE_FALSE; } Player->userData = po->stateInfo; // Register the model with the player if all is ok // NOTE - If somthing went bad, then this should not be called!!! GenVSI_RegisterPlayerModel(VSI, Player, Model); return GE_TRUE; } static void PhysicsObject_Destroy(GenVSI *VSI, void *PlayerData, void *ClassData) { GPlayer *Player; PhysicsObject *po; Player = (GPlayer*)PlayerData; po = (PhysicsObject*)ClassData; if (po) if (po->stateInfo) { gePhysicsObject_Destroy(&po->stateInfo); } } static geBoolean PhysicsObject_Trigger(GenVSI *VSI, void *PlayerData, GPlayer *Target, void *data) { //////////////////////////////////////////////////////////////////////////////////////////////////// // PlayerData actually points to the PhysicsObject. // Target is R. Havoc. // Makes sense, doesn't it? :^D GPlayer *Player; PhysicsObject* poPtr; gePhysicsObject* podPtr; GE_Collision* collisionInfo; float velMagN; geVec3d radiusVector; geVec3d force; geVec3d poCOM; int activeConfigIndex; float scale; Player = (GPlayer*)PlayerData; poPtr = (PhysicsObject*)Player->ClassData; podPtr = (gePhysicsObject*)Player->userData; collisionInfo = (GE_Collision*)data; scale = gePhysicsObject_GetPhysicsScale(podPtr); activeConfigIndex = gePhysicsObject_GetActiveConfig(podPtr); gePhysicsObject_GetLocationInEditorSpace(podPtr, &poCOM, activeConfigIndex); geVec3d_Subtract(&collisionInfo->Impact, &poCOM, &radiusVector); velMagN = geVec3d_DotProduct(&Target->Velocity, &collisionInfo->Plane.Normal); geVec3d_Scale(&collisionInfo->Plane.Normal, velMagN * 4.f, &force); geVec3d_Scale(&radiusVector, scale, &radiusVector); gePhysicsObject_ApplyGlobalFrameForce(podPtr, &force, &radiusVector, GE_TRUE, activeConfigIndex); return GE_TRUE; } geVec3d bboxVerts[8] = { {-1.0f, 1.0f, 1.0f}, {-1.0f, -1.0f, 1.0f}, {1.0f, -1.0f, 1.0f}, {1.0f, 1.0f, 1.0f}, {-1.0f, 1.0f, -1.0f}, {-1.0f, -1.0f, -1.0f}, {1.0f, -1.0f, -1.0f}, {1.0f, 1.0f, -1.0f} }; #define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MAX(a,b) ((a) > (b) ? (a) : (b)) static geBoolean PhysicsObject_Control(GenVSI* VSI, void* PlayerData, float Time) { GPlayer* player; gePhysicsObject* pod; int activeConfigIndex; geXForm3d destXForm; #if 0 geXForm3d xform; geWorld* world; geVec3d bbmin, bbmax, bbdims; geVec3d tmpVec; int i; Matrix33 A; geVec3d boundingBoxCenter; geEntity_EntitySet* Set; geEntity* Entity; geVec3d boundingBoxScale; #endif //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// player = (GPlayer*)PlayerData; if (player == NULL) { GenVS_Error( "PhysicsObject_Control: invalid player.\n"); return GE_FALSE; } pod = (gePhysicsObject*)player->userData; if (pod == NULL) { GenVS_Error( "PhysicsObject_Control: pod = NULL.\n"); return GE_FALSE; } activeConfigIndex = gePhysicsObject_GetActiveConfig(pod); #if 0 world = GenVSI_GetWorld(VSI); geWorld_ModelGetBBox(world, player->Model, &bbmin, &bbmax); gePhysicsObject_GetLocation(pod, &boundingBoxCenter); geVec3d_Scale(&bbmin, PHYSOB_SCALE, &bbmin); geVec3d_Scale(&bbmax, PHYSOB_SCALE, &bbmax); geVec3d_Subtract(&bbmax, &bbmin, &bbdims); geVec3d_Scale(&bbdims, 0.5f, &boundingBoxScale); gePhysicsObject_GetXForm(pod, &xform); Matrix33_ExtractFromXForm3d(&xform, &A); //////////////////////////////////////////////////////////////////////////////////////////////////// // check for penetration of one or more model vertices into the radius of a ForceField entity Set = NULL; Set = geWorld_GetEntitySet(world, "ForceField"); if (Set != NULL) { for (Entity = geEntity_EntitySetGetNextEntity(Set, NULL); Entity != NULL; Entity = geEntity_EntitySetGetNextEntity(Set, Entity)) { ForceField* ff; geVec3d vertPos; float forceMultiplier; float distToFFCenter; float forceMagnitude; geVec3d forceDir; geVec3d forceToApply, ptOfApplication; geVec3d ffOriginInPhysicsSpace; ff = geEntity_GetUserData(Entity); assert(ff != NULL); if (! ff->affectsPhysicsObjects) continue; for (i = 0; i < 8; i++) { tmpVec.X = boundingBoxScale.X * bboxVerts[i].X; tmpVec.Y = boundingBoxScale.Y * bboxVerts[i].Y; tmpVec.Z = boundingBoxScale.Z * bboxVerts[i].Z; Matrix33_MultiplyVec3d(&A, &tmpVec, &vertPos); geVec3d_Add(&boundingBoxCenter, &vertPos, &vertPos); geVec3d_Scale(&ff->Origin, PHYSOB_SCALE, &ffOriginInPhysicsSpace); geVec3d_Subtract(&vertPos, &ffOriginInPhysicsSpace, &forceDir); distToFFCenter = geVec3d_Length(&forceDir); if (distToFFCenter > ff->radius) continue; geVec3d_Normalize(&forceDir); //////////////////////////////////////////////////////////////////////////////////////////////////// // figure out how much force to apply based on force field's falloff function switch(ff->falloffType) { case FALLOFF_NONE: forceMultiplier = 1.f; break; case FALLOFF_ONE_OVER_D: forceMultiplier = 1 / distToFFCenter; break; case FALLOFF_ONE_OVER_DSQUARED: forceMultiplier = 1 / (distToFFCenter * distToFFCenter); break; default: forceMultiplier = 1.f; } forceMagnitude = ff->strength * forceMultiplier * 1000.f * PHYSOB_SCALE; geVec3d_Scale(&forceDir, forceMagnitude, &forceToApply); geVec3d_Subtract(&vertPos, &boundingBoxCenter, &ptOfApplication); gePhysicsObject_ApplyGlobalFrameForce(pod, &forceToApply, &ptOfApplication, GE_TRUE); } // for i } // while } // if #endif // update model's xform gePhysicsObject_GetXFormInEditorSpace(pod, &destXForm, activeConfigIndex); if (GenVSI_MovePlayerModel(VSI, player, &destXForm)) { //gePhysicsObject_GetXFormInEditorSpace(pod, &xform, activeConfigIndex); geXForm3d_Copy(&destXForm, &player->XForm); } return GE_TRUE; } //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //===================================================================================== // PhysicsJoint_Spawn //===================================================================================== static geBoolean PhysicsJoint_Spawn(GenVSI *VSI, void *PlayerData, void *ClassData, char *EntityName) { GPlayer *Player; PhysicsJoint *ij; Player = (GPlayer*)PlayerData; ij = NULL; ij = (PhysicsJoint*)ClassData; if (ij == NULL) { GenVS_Error( "PhysicsJoint_Spawn: NULL Class Data ('%s').\n",EntityName); return GE_FALSE; } Player->ViewFlags = VIEW_TYPE_LOCAL; #define JOINT_MIN_ASSEMBLY_RATE (0.01f) #define JOINT_MAX_ASSEMBLY_RATE (1.f) if (ij->assemblyRate < JOINT_MIN_ASSEMBLY_RATE) ij->assemblyRate = JOINT_MIN_ASSEMBLY_RATE; else if (ij->assemblyRate > JOINT_MAX_ASSEMBLY_RATE) ij->assemblyRate = JOINT_MAX_ASSEMBLY_RATE; ij->jointData = NULL; ij->jointData = gePhysicsJoint_Create(ij->jointType, &ij->Origin, ij->assemblyRate, ij->physicsObject1 ? ij->physicsObject1->stateInfo : NULL, ij->physicsObject2 ? ij->physicsObject2->stateInfo : NULL, 0.01f); //ij->physicsScale); if (ij->jointData == NULL) { GenVS_Error( "PhysicsJoint_Spawn: Couldn't Create('%s').\n",EntityName); return GE_FALSE; } return GE_TRUE; } //===================================================================================== //===================================================================================== static void PhysicsJoint_Destroy(GenVSI *VSI, void *PlayerData, void *ClassData) { GPlayer *Player; PhysicsJoint *ij; Player = (GPlayer*)PlayerData; ij = NULL; ij = (PhysicsJoint*)ClassData; assert(ij->jointData); gePhysicsJoint_Destroy(&ij->jointData); } //===================================================================================== //===================================================================================== static geBoolean PhysicsJoint_Trigger(GenVSI* VSI, void* PlayerData, void* TargetData, void* data) { return GE_TRUE; } static geBoolean PhysicsJoint_Control(GenVSI* VSI, void* PlayerData, float Time) { return GE_TRUE; } //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //===================================================================================== // PhysicalSystem_Spawn //===================================================================================== static geBoolean PhysicalSystem_Spawn(GenVSI *VSI, void *PlayerData, void *ClassData, char *EntityName) { GPlayer *Player; PhysicalSystem *ips; PhysicsObject *Object; PhysicsObject *Object2; PhysicsJoint *PhysicsJoint; Player = NULL; Player = (GPlayer*)PlayerData; if (Player == NULL) { GenVS_Error( "PhysicalSystem_Spawn: NULL Player ('%s').\n",EntityName); return GE_FALSE; } Player->Control = PhysicalSystem_Control; if (Player->Control == NULL) { GenVS_Error( "PhysicalSystem_Spawn: NULL Player control ('%s').\n",EntityName); return GE_FALSE; } Player->Blocked = NULL; Player->Trigger = NULL; Player->ViewFlags = VIEW_TYPE_LOCAL; Player->ViewIndex = VIEW_INDEX_NONE; geXForm3d_SetIdentity(&Player->XForm); ips = NULL; ips = (PhysicalSystem*)ClassData; if (ips == NULL) { GenVS_Error( "PhysicalSystem_Spawn: NULL Class Data ('%s').\n",EntityName); return GE_FALSE; } ips->physsysData = NULL; ips->physsysData = gePhysicsSystem_Create(); if (ips->physsysData == NULL) { GenVS_Error( "PhysicalSystem_Spawn: Couldn't Create('%s').\n",EntityName); return GE_FALSE; } Object = ips->physicsObjectListHeadPtr; Object2 = Object; while (Object) { if (gePhysicsSystem_AddObject(ips->physsysData, Object->stateInfo) == GE_FALSE) { GenVS_Error( "PhysicalSystem_Spawn: Couldn't AddObject('%s').\n",EntityName); return GE_FALSE; } Object = Object->Next; if (Object2) { Object2 = Object2->Next; if (Object2) { Object2=Object2->Next; if (Object2) { if (Object2==Object) { GenVS_Error("PhysicalSystem_Spawn: Detected circular linked list in Next field('%s')\n",EntityName); return GE_FALSE; } } } } } PhysicsJoint = ips->jointListHeadPtr; while (PhysicsJoint) { if (PhysicsJoint->jointData == NULL) { GenVS_Error( "PhysicalSystem_Spawn: Null jointData ('%s').\n",EntityName); return GE_FALSE; } if (gePhysicsSystem_AddJoint(ips->physsysData, PhysicsJoint->jointData) == GE_FALSE) { GenVS_Error( "PhysicalSystem_Spawn: Couldn't AddPhysicsJoint('%s').\n",EntityName); return GE_FALSE; } PhysicsJoint = PhysicsJoint->Next; } return GE_TRUE; } //===================================================================================== //===================================================================================== static void PhysicalSystem_Destroy(GenVSI *VSI, void *PlayerData, void *ClassData) { GPlayer *Player; PhysicalSystem *ips; Player = (GPlayer*)PlayerData; ips = (PhysicalSystem*)ClassData; assert(ips); assert(ips->physsysData); gePhysicsSystem_Destroy(&ips->physsysData); } //===================================================================================== //===================================================================================== static geBoolean PhysicalSystem_Trigger(GenVSI* VSI, void* PlayerData, void* TargetData, void* data) { return GE_TRUE; } //===================================================================================== //===================================================================================== static geBoolean PhysicalSystem_Control(GenVSI* VSI, void* PlayerData, float Time) { GPlayer* player; PhysicalSystem* psPtr; player = (GPlayer*)PlayerData; psPtr = (PhysicalSystem*)player->ClassData; if (!gePhysicsSystem_Iterate(psPtr->physsysData, Time)) { GenVS_Error( "PhysicalSystem_Control: Iterate() failed.\n"); return GE_FALSE; } return GE_TRUE; } //////////////////////////////////////////////////////////////////////////////////////////////////// // force field-related stuff static geBoolean ForceField_Spawn(GenVSI* VSI, void* PlayerData, void* Class, char *EntityName) { GPlayer* player; ForceField* ff; player = (GPlayer*)PlayerData; if (player == NULL) { GenVS_Error( "ForceField_Spawn: player = NULL ('%s').\n",EntityName); return GE_FALSE; } ff = (ForceField*)player->ClassData; if (ff == NULL) { GenVS_Error( "ForceField_Spawn: ff = NULL ('%s').\n",EntityName); return GE_FALSE; } player->ViewFlags = VIEW_TYPE_LOCAL; player->Blocked = NULL; player->Control = ForceField_Control; player->Trigger = ForceField_Trigger; return GE_TRUE; } static geBoolean ForceField_Trigger(GenVSI* VSI, void* PlayerData, void* TargetData, void* data) { return GE_TRUE; } static geBoolean ForceField_Control(GenVSI* VSI, void* PlayerData, float Time) { return GE_TRUE; } /* //===================================================================================== // Spawn_AmbientSound //===================================================================================== static geBoolean Spawn_AmbientSound(Server_Server *Server, Server_Player *Player, void *ClassData) { Player->SoundIndex = SOUND_INDEX_WATERFALL; } */ //===================================================================================== // SqueezeVector //===================================================================================== void SqueezeVector(geVec3d *Vect, float Epsilon) { if (Vect->X > -Epsilon && Vect->X < Epsilon) Vect->X = 0.0f; if (Vect->Y > -Epsilon && Vect->Y < Epsilon) Vect->Y = 0.0f; if (Vect->Z > -Epsilon && Vect->Z < Epsilon) Vect->Z = 0.0f; } //===================================================================================== // ClampVector //===================================================================================== void ClampVector(geVec3d *Vect, float Epsilon) { if (Vect->X > Epsilon) Vect->X = Epsilon; if (Vect->Y > Epsilon) Vect->Y = Epsilon; if (Vect->Z > Epsilon) Vect->Z = Epsilon; if (Vect->X < -Epsilon) Vect->X = -Epsilon; if (Vect->Y < -Epsilon) Vect->Y = -Epsilon; if (Vect->Z < -Epsilon) Vect->Z = -Epsilon; } //===================================================================================== // ReflectVelocity //===================================================================================== void ReflectVelocity(geVec3d *In, geVec3d *Normal, geVec3d *Out, float Scale) { float Reflect; Reflect = geVec3d_DotProduct(In, Normal) * Scale; Out->X = In->X - Normal->X*Reflect; Out->Y = In->Y - Normal->Y*Reflect; Out->Z = In->Z - Normal->Z*Reflect; SqueezeVector(Out, 0.1f); } //===================================================================================== // IsKeyDown //===================================================================================== static geBoolean IsKeyDown(int KeyCode) { if (GetAsyncKeyState(KeyCode) & 0x8000) return GE_TRUE; return GE_FALSE; } //===================================================================================== // XFormFromVector //===================================================================================== BOOL XFormFromVector(const geVec3d *Source, const geVec3d *Target, float Roll, geXForm3d *Out) { geVec3d p1, p2, Vect; geVec3d Origin = {0.0f, 0.0f, 0.0f}; geVec3d_Subtract(Source, Target, &Vect); if (geVec3d_Compare(&Vect, &Origin, 0.05f)) { Vect.Y = -1.0f; } // First clear the xform geXForm3d_SetIdentity(Out); geVec3d_Normalize(&Vect); // Now set the IN vector Out->AZ = Vect.X; Out->BZ = Vect.Y; Out->CZ = Vect.Z; // Get a straight up vector p2.X = 0.0f; p2.Y = 1.0f; p2.Z = 0.0f; // Use it with the in vector to get the RIGHT vector geVec3d_CrossProduct(&p2, &Vect, &p1); geVec3d_Normalize(&p1); // Put the RIGHT vector in the matrix Out->AX = p1.X; Out->BX = p1.Y; Out->CX = p1.Z; // Now use the RIGHT vector with the IN vector to get the real UP vector geVec3d_CrossProduct(&Vect, &p1, &p2); geVec3d_Normalize(&p2); // Put the UP vector in the matrix Out->AY = p2.X; Out->BY = p2.Y; Out->CY = p2.Z; // Put the translation in... Out->Translation = *Source; return TRUE; } //===================================================================================== // SetupPlayerXForm //===================================================================================== void SetupPlayerXForm(GenVSI *VSI, void *PlayerData, float Time) { geVec3d Pos; GPlayer *Player; GenVSI_CMove *Move; Player = (GPlayer*)PlayerData; assert(Player->ClientHandle != CLIENT_NULL_HANDLE); Move = GenVSI_GetClientMove(VSI, Player->ClientHandle); assert(Move); Pos = Player->XForm.Translation; // Clear the matrix geXForm3d_SetIdentity(&Player->XForm); // Rotate then translate. geXForm3d_RotateZ(&Player->XForm, Move->Angles.Z+Player->Roll); geXForm3d_RotateX(&Player->XForm, Move->Angles.X); geXForm3d_RotateY(&Player->XForm, Move->Angles.Y); geXForm3d_Translate(&Player->XForm, Pos.X, Pos.Y, Pos.Z); } //===================================================================================== // AnimatePlayer //===================================================================================== geBoolean AnimatePlayer(GenVSI *VSI, void *PlayerData, uint16 MotionIndex, float Speed, geBoolean Loop) { float StartTime, EndTime, DeltaT; geBoolean Looped; GPlayer *Player; Player = (GPlayer*)PlayerData; Looped = GE_FALSE; GenVSI_GetPlayerTimeExtents(VSI, Player, MotionIndex, &StartTime, &EndTime); if (Speed > 0) { Player->FrameTime += Speed; DeltaT = EndTime - StartTime; if (Player->FrameTime >= EndTime) { if (Loop) Player->FrameTime -= DeltaT; else Player->FrameTime = EndTime; Looped = GE_TRUE; } } else if (Speed < 0) { Player->FrameTime += Speed; DeltaT = EndTime - StartTime; if (Player->FrameTime <= StartTime) { if (Loop) Player->FrameTime += DeltaT; else Player->FrameTime = StartTime; Looped = GE_TRUE; } } return Looped; } //===================================================================================== // AnimatePlayer //===================================================================================== geBoolean AnimatePlayer2(GenVSI *VSI, void *PlayerData, int32 MotionSlot, float Speed, geBoolean Loop) { float StartTime, EndTime, DeltaT; geBoolean Looped; GPlayer *Player; uint16 MotionIndex; float MotionTime; Player = (GPlayer*)PlayerData; assert(MotionSlot < Player->NumMotionData); Looped = GE_FALSE; MotionIndex = Player->MotionData[MotionSlot].MotionIndex; MotionTime = Player->MotionData[MotionSlot].MotionTime; GenVSI_GetPlayerTimeExtents(VSI, Player, MotionIndex, &StartTime, &EndTime); if (Speed > 0) { MotionTime += Speed; DeltaT = EndTime - StartTime; if (MotionTime >= EndTime) { if (Loop) MotionTime -= DeltaT; else MotionTime = EndTime; Looped = GE_TRUE; } } else if (Speed < 0) { MotionTime += Speed; DeltaT = EndTime - StartTime; if (MotionTime <= StartTime) { if (Loop) MotionTime += DeltaT; else MotionTime = StartTime; Looped = GE_TRUE; } } Player->MotionData[MotionSlot].MotionTime = MotionTime; return Looped; } //===================================================================================== // UpdateClientInventory //===================================================================================== void UpdateClientInventory(GenVSI *VSI, GPlayer *Player, int32 Slot) { uint16 Amount; geBoolean Has; assert(Player->Inventory[Player->CurrentWeapon] >= 0 && Player->Inventory[Player->CurrentWeapon] <= 65535); Amount = (uint16)Player->Inventory[Slot]; Has = Player->InventoryHas[Slot]; GenVSI_SetClientInventory(VSI, Player->ClientHandle, Slot, Amount, Has); }
29.127421
144
0.578854
[ "object", "vector", "model", "solid" ]
db194268ee37171be6e138073bfcf20fd8f4201e
5,431
c
C
agent/simple-recorder-agent.c
xhaakon/hwangsae
c4fba10a8f9acaf421cdfdcf5ff475e65d5610f0
[ "Apache-2.0" ]
18
2019-10-18T01:05:37.000Z
2021-12-17T22:35:15.000Z
agent/simple-recorder-agent.c
xhaakon/hwangsae
c4fba10a8f9acaf421cdfdcf5ff475e65d5610f0
[ "Apache-2.0" ]
22
2019-10-24T10:35:43.000Z
2021-04-01T14:01:13.000Z
agent/simple-recorder-agent.c
xhaakon/hwangsae
c4fba10a8f9acaf421cdfdcf5ff475e65d5610f0
[ "Apache-2.0" ]
9
2019-10-04T17:15:50.000Z
2020-10-27T16:05:06.000Z
/** * Copyright 2019 SK Telecom Co., Ltd. * Author: Walter Lozano <walter.lozano@collabora.com> * * 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. * */ #include "config.h" #include "simple-recorder-agent.h" #include <hwangsae/recorder.h> #include <glib/gstdio.h> #include <gst/gst.h> #include <glib-unix.h> struct _HwangsaeSimpleRecorderAgent { HwangsaeRecorderAgent parent; HwangsaeRecorder *recorder; gint64 recording_id; gboolean is_recording; gchar *edge_id; }; /* *INDENT-OFF* */ G_DEFINE_TYPE (HwangsaeSimpleRecorderAgent, hwangsae_simple_recorder_agent, HWANGSAE_TYPE_RECORDER_AGENT) /* *INDENT-ON* */ static gint64 hwangsae_simple_recorder_agent_start_recording (HwangsaeRecorderAgent * recorder_agent, gchar * edge_id) { HwangsaeSimpleRecorderAgent *self = HWANGSAE_SIMPLE_RECORDER_AGENT (recorder_agent); g_autoptr (GError) error = NULL; g_autofree gchar *recorder_id = hwangsae_recorder_agent_get_recorder_id (recorder_agent); g_autofree gchar *host = hwangsae_recorder_agent_get_relay_address (recorder_agent); guint port = hwangsae_recorder_agent_get_relay_stream_port (recorder_agent); g_autofree gchar *recording_dir = hwangsae_recorder_agent_get_recording_dir (recorder_agent); g_autofree gchar *streamid_tmp = NULL; g_autofree gchar *streamid = NULL; g_autofree gchar *url = NULL; g_autofree gchar *recording_edge_dir = NULL; g_autofree gchar *filename_prefix = NULL; if (self->is_recording) { g_warning ("recording already started"); return self->recording_id; } self->recording_id = g_get_real_time (); self->is_recording = TRUE; g_clear_pointer (&self->edge_id, g_free); self->edge_id = g_strdup (edge_id); hwangsae_recorder_agent_send_rest_api (recorder_agent, RELAY_METHOD_START_STREAMING, edge_id); streamid_tmp = g_strdup_printf ("#!::r=%s,u=%s", edge_id, recorder_id); streamid = g_uri_escape_string (streamid_tmp, NULL, FALSE); url = g_strdup_printf ("srt://%s:%d?streamid=%s", host, port, streamid); g_debug ("starting to recording stream from %s", url); recording_edge_dir = g_build_filename (recording_dir, edge_id, NULL); filename_prefix = g_strdup_printf ("hwangsae-recording-%ld", self->recording_id); g_debug ("setting recording_dir: %s, filename_prefix: %s\n", recording_edge_dir, filename_prefix); hwangsae_recorder_set_recording_dir (self->recorder, recording_edge_dir); hwangsae_recorder_set_filename_prefix (self->recorder, filename_prefix); hwangsae_recorder_set_container (self->recorder, HWANGSAE_CONTAINER_TS); hwangsae_recorder_start_recording (self->recorder, url); return self->recording_id; } static void hwangsae_simple_recorder_agent_stop_recording (HwangsaeRecorderAgent * recorder_agent, gchar * edge_id) { g_autoptr (GError) error = NULL; HwangsaeSimpleRecorderAgent *self = HWANGSAE_SIMPLE_RECORDER_AGENT (recorder_agent); if (!self->is_recording) { g_warning ("recording already stopped"); return; } if (g_strcmp0 (self->edge_id, edge_id)) { g_warning ("edge_id mismatch"); return; } self->is_recording = FALSE; g_clear_pointer (&self->edge_id, g_free); self->recording_id = 0; hwangsae_recorder_stop_recording (self->recorder); } static void hwangsae_simple_recorder_agent_init (HwangsaeSimpleRecorderAgent * self) { self->recorder = hwangsae_recorder_new (); self->is_recording = FALSE; self->edge_id = NULL; } static gboolean signal_handler (GApplication * app) { g_application_release (app); return G_SOURCE_REMOVE; } static void hwangsae_simple_recorder_agent_dispose (GObject * object) { HwangsaeSimpleRecorderAgent *self = HWANGSAE_SIMPLE_RECORDER_AGENT (object); g_clear_object (&self->recorder); g_clear_pointer (&self->edge_id, g_free); G_OBJECT_CLASS (hwangsae_simple_recorder_agent_parent_class)->dispose (object); } static void hwangsae_simple_recorder_agent_class_init (HwangsaeSimpleRecorderAgentClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); HwangsaeRecorderAgentClass *recorder_agent_class = HWANGSAE_RECORDER_AGENT_CLASS (klass); gobject_class->dispose = hwangsae_simple_recorder_agent_dispose; recorder_agent_class->start_recording = hwangsae_simple_recorder_agent_start_recording; recorder_agent_class->stop_recording = hwangsae_simple_recorder_agent_stop_recording; } int main (int argc, char *argv[]) { g_autoptr (GApplication) app = NULL; app = G_APPLICATION (g_object_new (HWANGSAE_TYPE_SIMPLE_RECORDER_AGENT, "application-id", "org.hwangsaeul.Hwangsae1.RecorderAgent", "flags", G_APPLICATION_IS_SERVICE, NULL)); g_unix_signal_add (SIGINT, (GSourceFunc) signal_handler, app); gst_init (&argc, &argv); g_application_hold (app); return hwangsaeul_application_run (HWANGSAEUL_APPLICATION (app), argc, argv); }
29.042781
105
0.758424
[ "object" ]
db2881bdb5ccf96e5afb44f26611b38f79342ae1
757
h
C
FDKit/Classes/Inherited/FDBaseCollectionViewDelegate.h
toolazytoname/FDKit
42e0a483deb1d01843674a79964f75cfda165303
[ "MIT" ]
1
2020-06-10T11:51:56.000Z
2020-06-10T11:51:56.000Z
FDKit/Classes/Inherited/FDBaseCollectionViewDelegate.h
toolazytoname/FDKit
42e0a483deb1d01843674a79964f75cfda165303
[ "MIT" ]
1
2021-05-25T03:44:09.000Z
2021-05-25T03:44:09.000Z
FDKit/Classes/Inherited/FDBaseCollectionViewDelegate.h
toolazytoname/FDKit
42e0a483deb1d01843674a79964f75cfda165303
[ "MIT" ]
null
null
null
// // BPWBaseCollectionViewDelegate.h // FDKit // // Created by Lazy on 2018/8/14. // #import <Foundation/Foundation.h> @interface FDBaseCollectionViewDelegate : NSObject<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout> @property (nonatomic, strong) UICollectionView *collectionView; @property (nonatomic, strong) NSArray *cellClassArray; @property (nonatomic, strong) NSArray *supplementaryViewClassArray; @property (nonatomic, strong) NSArray *supplementaryViewNibClassArray; @property (nonatomic, strong) NSDictionary *modelToCellClassMap; @property (nonatomic, strong) NSMutableArray *dataArray; - (instancetype)initWithCollectionView:(UICollectionView *)collectionView; - (void)refreshData:(id)model; @end
34.409091
138
0.813738
[ "model" ]
db38404cc9d0baa9b192942b481f328c2442bf4e
485
h
C
Mesh_3/doc/Mesh_3/CGAL/Image_3.h
ffteja/cgal
c1c7f4ad9a4cd669e33ca07a299062a461581812
[ "CC0-1.0" ]
3,227
2015-03-05T00:19:18.000Z
2022-03-31T08:20:35.000Z
Mesh_3/doc/Mesh_3/CGAL/Image_3.h
ffteja/cgal
c1c7f4ad9a4cd669e33ca07a299062a461581812
[ "CC0-1.0" ]
5,574
2015-03-05T00:01:56.000Z
2022-03-31T15:08:11.000Z
Mesh_3/doc/Mesh_3/CGAL/Image_3.h
ffteja/cgal
c1c7f4ad9a4cd669e33ca07a299062a461581812
[ "CC0-1.0" ]
1,274
2015-03-05T00:01:12.000Z
2022-03-31T14:47:56.000Z
namespace CGAL { /*! \ingroup PkgMesh3Domains The class `Image_3` is a C++ wrapper around the <a href="http://inrimage.gforge.inria.fr/">InrImage library</a>. It holds a shared pointer to a 3D image buffer. */ class Image_3 { public: /// The default-constructor. The object is invalid until a call to `read()`. Image_3(); /// Open an 3D image file. /// /// Returns `true` if the file was sucessfully loaded. bool read(const char* file); }; } /* end namespace CGAL */
20.208333
78
0.674227
[ "object", "3d" ]
db3baeb4b1feeeb3290b46b9cbfc29ddc260bece
7,566
h
C
sdk/sdk/share/mediastreamer2/dxfilter.h
doyaGu/C0501Q_HWJL01
07a71328bd9038453cbb1cf9c276a3dd1e416d63
[ "MIT" ]
1
2021-10-09T08:05:50.000Z
2021-10-09T08:05:50.000Z
sdk/sdk/share/mediastreamer2/dxfilter.h
doyaGu/C0501Q_HWJL01
07a71328bd9038453cbb1cf9c276a3dd1e416d63
[ "MIT" ]
null
null
null
sdk/sdk/share/mediastreamer2/dxfilter.h
doyaGu/C0501Q_HWJL01
07a71328bd9038453cbb1cf9c276a3dd1e416d63
[ "MIT" ]
null
null
null
/* mediastreamer2 library - modular sound and video processing and streaming Copyright (C) 2006 Simon MORLAT (simon.morlat@linphone.org) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // {4D6410BE-7643-4f43-B55F-8821A6FFB50A} DEFINE_GUID(CLSID_DXFilter, 0x4d6410be, 0x7643, 0x4f43, 0xb5, 0x5f, 0x88, 0x21, 0xa6, 0xff, 0xb5, 0xa); // {52A7F345-CD92-442c-89C1-632C16AD5003} DEFINE_GUID(IID_IDXFilter, 0x52a7f345, 0xcd92, 0x442c, 0x89, 0xc1, 0x63, 0x2c, 0x16, 0xad, 0x50, 0x3); // We define a callback typedef for this example. // Normally, you would make the DXFilter support a COM interface, // and in one of its methods you would pass in a pointer to a COM interface // used for calling back. See the DirectX documentation for the DXFilter // for more information. typedef HRESULT (*SAMPLECALLBACK) ( IMediaSample * pSample, REFERENCE_TIME * StartTime, REFERENCE_TIME * StopTime, BOOL TypeChanged ); // We define the interface the app can use to program us MIDL_INTERFACE("6B652FFF-11FE-4FCE-92AD-0266B5D7C78F") IDXFilter : public IUnknown { public: virtual HRESULT STDMETHODCALLTYPE SetAcceptedMediaType( const CMediaType *pType) = 0; virtual HRESULT STDMETHODCALLTYPE GetConnectedMediaType( CMediaType *pType) = 0; virtual HRESULT STDMETHODCALLTYPE SetCallback( SAMPLECALLBACK Callback) = 0; virtual HRESULT STDMETHODCALLTYPE SetDeliveryBuffer( ALLOCATOR_PROPERTIES props, BYTE *pBuffer) = 0; }; class CDXFilterInPin; class CDXFilter; //---------------------------------------------------------------------------- // This is a special allocator that KNOWS that the person who is creating it // will only create one of them. It allocates CMediaSamples that only // reference the buffer location that is set in the pin's renderer's // data variable //---------------------------------------------------------------------------- class CDXFilterAllocator : public CMemAllocator { friend class CDXFilterInPin; friend class CDXFilter; protected: // our pin who created us // CDXFilterInPin * m_pPin; public: CDXFilterAllocator( CDXFilterInPin * pParent, HRESULT *phr ) : CMemAllocator( TEXT("DXFilterAllocator\0"), NULL, phr ) , m_pPin( pParent ) { }; ~CDXFilterAllocator( ) { // wipe out m_pBuffer before we try to delete it. It's not an allocated // buffer, and the default destructor will try to free it! m_pBuffer = NULL; } HRESULT Alloc( ); void ReallyFree(); // Override this to reject anything that does not match the actual buffer // that was created by the application STDMETHODIMP SetProperties(ALLOCATOR_PROPERTIES *pRequest, ALLOCATOR_PROPERTIES *pActual); }; //---------------------------------------------------------------------------- // we override the input pin class so we can provide a media type // to speed up connection times. When you try to connect a filesourceasync // to a transform filter, DirectShow will insert a splitter and then // start trying codecs, both audio and video, video codecs first. If // your sample grabber's set to connect to audio, unless we do this, it // will try all the video codecs first. Connection times are sped up x10 // for audio with just this minor modification! //---------------------------------------------------------------------------- class CDXFilterInPin : public CTransInPlaceInputPin { friend class CDXFilterAllocator; friend class CDXFilter; CDXFilterAllocator * m_pPrivateAllocator; ALLOCATOR_PROPERTIES m_allocprops; BYTE * m_pBuffer; BOOL m_bMediaTypeChanged; protected: CDXFilter * DXFilter( ) { return (CDXFilter*) m_pFilter; } HRESULT SetDeliveryBuffer( ALLOCATOR_PROPERTIES props, BYTE * m_pBuffer ); public: CDXFilterInPin( CTransInPlaceFilter * pFilter, HRESULT * pHr ) : CTransInPlaceInputPin( TEXT("DXFilterInputPin\0"), pFilter, pHr, L"Input\0" ) , m_pPrivateAllocator( NULL ) , m_pBuffer( NULL ) , m_bMediaTypeChanged( FALSE ) { memset( &m_allocprops, 0, sizeof( m_allocprops ) ); } ~CDXFilterInPin( ) { if( m_pPrivateAllocator ) delete m_pPrivateAllocator; } // override to provide major media type for fast connects HRESULT GetMediaType( int iPosition, CMediaType *pMediaType ); // override this or GetMediaType is never called STDMETHODIMP EnumMediaTypes( IEnumMediaTypes **ppEnum ); // override this to refuse any allocators besides // the one the user wants, if this is set STDMETHODIMP NotifyAllocator( IMemAllocator *pAllocator, BOOL bReadOnly ); // override this so we always return the special allocator, if necessary STDMETHODIMP GetAllocator( IMemAllocator **ppAllocator ); HRESULT SetMediaType( const CMediaType *pmt ); // we override this to tell whoever's upstream of us what kind of // properties we're going to demand to have // STDMETHODIMP GetAllocatorRequirements( ALLOCATOR_PROPERTIES *pProps ); }; //---------------------------------------------------------------------------- // //---------------------------------------------------------------------------- class CDXFilter : public CTransInPlaceFilter, public IDXFilter { friend class CDXFilterInPin; friend class CDXFilterAllocator; protected: CMediaType m_mtAccept; SAMPLECALLBACK m_callback; CCritSec m_Lock; // serialize access to our data #if !defined(_WIN32_WCE) BOOL IsReadOnly( ) { return !m_bModifiesData; } #endif // PURE, override this to ensure we get // connected with the right media type HRESULT CheckInputType( const CMediaType * pmt ); // PURE, override this to callback // the user when a sample is received HRESULT Transform( IMediaSample * pms ); // override this so we can return S_FALSE directly. // The base class CTransInPlace // Transform( ) method is called by it's // Receive( ) method. There is no way // to get Transform( ) to return an S_FALSE value // (which means "stop giving me data"), // to Receive( ) and get Receive( ) to return S_FALSE as well. HRESULT Receive( IMediaSample * pms ); public: static CUnknown *WINAPI CreateInstance(LPUNKNOWN punk, HRESULT *phr); // Expose IDXFilter STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void ** ppv); DECLARE_IUNKNOWN; CDXFilter( IUnknown * pOuter, HRESULT * pHr, BOOL ModifiesData ); // IDXFilter STDMETHODIMP SetAcceptedMediaType( const CMediaType * pmt ); STDMETHODIMP GetConnectedMediaType( CMediaType * pmt ); STDMETHODIMP SetCallback( SAMPLECALLBACK Callback ); STDMETHODIMP SetDeliveryBuffer( ALLOCATOR_PROPERTIES props, BYTE * m_pBuffer ); };
32.612069
94
0.666402
[ "transform" ]
db3c9f5488ce23547d9e181dd415f7745122961e
7,753
c
C
vector.c
BilkentCompGen/dips
6f90bec16c6b16dc49c75d255ee93ea2a456657c
[ "BSD-3-Clause" ]
17
2017-01-15T06:39:22.000Z
2020-08-11T06:36:05.000Z
vector.c
BilkentCompGen/dips
6f90bec16c6b16dc49c75d255ee93ea2a456657c
[ "BSD-3-Clause" ]
10
2018-04-08T23:32:13.000Z
2022-01-18T04:09:34.000Z
vector.c
BilkentCompGen/dips
6f90bec16c6b16dc49c75d255ee93ea2a456657c
[ "BSD-3-Clause" ]
2
2018-04-27T18:35:27.000Z
2018-10-16T18:31:19.000Z
#include "vector.h" void do_nothing(void *v){ } vector_t *vector_dot_prod(vector_t *v1, vector_t *v2, void *(*foo)(void *, void *)){ if( v1->size != v2->size){ return NULL;} vector_t *v3 = vector_init(VECTOR_VARIABLE_SIZE, v1->size); int i; for(i=0;i<v1->size;i++){ vector_soft_put(v3,foo(vector_get(v1,i),vector_get(v2,i))); } return v3; } vector_t *vector_x_prod(vector_t *v1, vector_t *v2, void *(*foo)(void *, void *)){ int i,j; vector_t *v3 = vector_init(VECTOR_VARIABLE_SIZE, v1->size * v2->size); for(i=0;i<v1->size;i++){ for(j=0;j<v2->size;j++){ void *value = foo(vector_get(v1,i),vector_get(v2,j)); if(value==NULL){continue;} vector_soft_put(v3,value); } } return v3; } void *vector_reduce(vector_t *v1, void *(*foo)(void * sum, void * val)){ int i; void *sum = NULL; for(i=0;i<v1->size;i++){ sum = foo(sum,vector_get(v1,i)); } return sum; } void vector_execute_for_all(vector_t *v, void (*foo)(void *)){ int i; for(i=0;i<v->size;i++){ foo(vector_get(v,i)); } } vector_t *vector_execute_for_all_and_save(vector_t *v, void *(*foo)(void *)){ int i; vector_t *rt = vector_init(VECTOR_VARIABLE_SIZE,v->size); for(i=0;i<v->size;i++){ vector_soft_put(rt,foo(vector_get(v,i))); } return rt; } void vector_filter(vector_t *vector, int (*check)(void *)){ int i; int prev_policy = vector->REMOVE_POLICY; vector->REMOVE_POLICY = REMP_LAZY; #pragma omp parallel for for(i=0;i<vector->size;i++){ if(!check(vector_get(vector,i))){ vector_remove(vector,i); } } vector_defragment(vector); vector->REMOVE_POLICY = prev_policy; } vector_t *vector_select(vector_t *vector, int (*check)(void *)){ int i; vector_t *selected = vector_init(vector->item_sizeof,vector->size); for(i=0;i<vector->size;i++){ if(check(vector_get(vector,i))){ vector_put(selected,vector_get(vector,i)); } } vector_zip(selected); return selected; } vector_t *vector_init(size_t item_sizeof, size_t initial_limit){ vector_t *new_vector = (vector_t *) getMem( sizeof(vector_t)); new_vector->item_sizeof = item_sizeof; new_vector->items = (void **) getMem( sizeof(void *) * initial_limit); new_vector->limit = initial_limit; new_vector->size = 0; new_vector->REMOVE_POLICY = 0; new_vector->fragmental=0; new_vector->rmv = &free; return new_vector; } void vector_tabularasa(vector_t *vector){ int i; for(i=0;i<vector->size;i++){ vector->items[i] = NULL; } vector->size = 0; } void vector_soft_put(vector_t *vector, void *item){ if(vector->limit == vector->size){ size_t new_limit = vector->limit +( vector->limit>>1) + 1; resizeMem((void **)&(vector->items),vector->limit * sizeof(void *),sizeof(void *) * new_limit); vector->limit = new_limit; } vector->items[vector->size] = item; vector->size++; } int vector_put(vector_t *vector, void *item){ if(vector->limit == vector->size){ size_t new_limit = vector->limit +( vector->limit>>1) + 1; resizeMem((void **)&(vector->items),vector->limit * sizeof(void *),sizeof(void *) * new_limit); vector->limit = new_limit; } vector->items[vector->size] = getMem(vector->item_sizeof); memcpy( vector->items[vector->size],item,vector->item_sizeof); vector->size = vector->size + 1; return 0; } void vector_soft_transfer(vector_t *target, vector_t *source){ int i; for(i=0;i<source->size;i++){ vector_soft_put(target,vector_get(source,i)); } void (*tmp_rmv)(void *) = source->rmv; source->rmv = do_nothing; vector_clear(source); source->rmv = tmp_rmv; } void vector_update_remove_policy(vector_t *vector, int policy){ vector->REMOVE_POLICY = policy; } int vector_contains(vector_t *vector, void *item){ int i; for(i=0;i<vector->size;i++){ if(memcmp(vector->items[i], item,vector->item_sizeof)==0){ return i; } } return -1; } int vector_comptains(vector_t *vector, void *item, int (*cmp)(const void*, const void*)){ int i; for(i=0;i<vector->size;i++){ if(cmp(vector->items[i],item)==0){ return i; } } return -1; } int vector_defragment(vector_t *vector){ if(vector->fragmental==0){ return 0; } int i = 0; int j = 0; while(i+1<vector->size){ ++i; if(vector->items[j]!=NULL){ ++j; } else{ vector->fragmental--; } if(i!=j){ vector->items[j]=vector->items[i]; } } vector->fragmental=0; vector->size = j; return 1; } void vector_insert(vector_t *vector, void *item, size_t index){ if(vector->limit == vector->size){ size_t new_limit = vector->limit +( vector->limit>>1) + 1; resizeMem((void **)&(vector->items),vector->limit * sizeof(void *),sizeof(void *) * new_limit); vector->limit = new_limit; } size_t i; size_t target = vector->size; if(vector->fragmental>0){ for(i=index;i<vector->size;i++){ if(vector->items[i]==NULL){ target=i; vector->fragmental--; break; } } } for(i=target;i>index;i--){ vector->items[i]=vector->items[i-1]; } vector->items[index] = getMem(vector->item_sizeof); memcpy( vector->items[index],item,vector->item_sizeof); vector->size = vector->size + 1; } int vector_remove(vector_t *vector, size_t index){ if(vector->items[index] == NULL || vector->size <= index){ return -1; } switch(vector->REMOVE_POLICY){ case REMP_SORTED: vector->rmv(vector->items[index]); vector->size--; int i; for(i=index;i<vector->size;i++){ vector->items[i] = vector->items[i+1]; } break; case REMP_FAST: vector->size--; vector->rmv(vector->items[index]); vector->items[index] = vector->items[vector->size]; break; case REMP_LAZY: vector->rmv(vector->items[index]); vector->items[index] = NULL; vector->fragmental++; break; default: fprintf(stderr,"UNKNOWN POLICY %d\n", vector->REMOVE_POLICY); return -2; } return 0; } void vector_clear( vector_t *vector){ int i; for(i=0;i<vector->size;i++){ vector->rmv(vector->items[i]); vector->items[i] = NULL; } vector->size = 0; } //NOT TESTED YET void vector_zip( vector_t *vector){ resizeMem((void **)&(vector->items),vector->limit * sizeof(void *),vector->size * sizeof(void *)); vector->limit = vector->size; } void *vector_get( vector_t *vector, size_t index){ #ifdef __DEBUG__ if(vector->size <= index){ fprintf(stderr,"Access out of index\n"); return NULL; } #endif return vector->items[index]; } void *vector_tail(vector_t *vector){ return vector->items[vector->size-1]; } void *vector_head(vector_t *vector){ return vector->items[0]; } void vector_free( void *v){ vector_t *vector = v; if(vector==NULL){return;} int i; for(i = 0; i< vector->size;i++){ vector->rmv(vector->items[i]); } freeMem(vector->items,vector->limit * sizeof(void *)); freeMem(vector,sizeof(vector_t)); } void vector_set_remove_function(vector_t *vector, void (*rmv)(void *)){ vector->rmv = rmv; } vector_t *dang_string_tokenize(const char *str, const char *delimiters){ vector_t *tokens = vector_init(VECTOR_VARIABLE_SIZE,8); if(str == NULL){ return tokens;} size_t str_size = strlen(str); if(delimiters == NULL || delimiters[0] == 0){ char * dummy = malloc(str_size*sizeof(char)+1); strcpy(dummy,str); vector_soft_put(tokens,dummy); return tokens; } size_t prev = 0; size_t index = 0; while(prev < str_size){ index = strcspn(str+prev,delimiters); char *dummy = malloc((index + 1) * sizeof(char)); memcpy(dummy,str+prev,index); dummy[index] = 0; vector_soft_put(tokens,dummy); prev+=(1+index); } vector_zip(tokens); return tokens; }
23.782209
99
0.635496
[ "vector" ]
71c688470e614cb6fc2e7a317d180d101db9bf8e
57,683
c
C
packet.c
onlykey/Simplepgp
53f28ee092cf4d88f150a8b5e66b302cc9e5e285
[ "Apache-2.0" ]
2
2017-05-16T10:05:11.000Z
2020-04-21T18:03:21.000Z
packet.c
onlykey/simplepgp
53f28ee092cf4d88f150a8b5e66b302cc9e5e285
[ "Apache-2.0" ]
null
null
null
packet.c
onlykey/simplepgp
53f28ee092cf4d88f150a8b5e66b302cc9e5e285
[ "Apache-2.0" ]
null
null
null
/* * packet.c * libsimplepgp * * Created by Trevor Bentley on 11/1/11. * * Copyright 2011 Trevor Bentley * * 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. * */ #include "simplepgp.h" #include "packet_private.h" #include "keychain.h" #include "util.h" #include "mpi.h" //#include "gcrypt.h" #include <wchar.h> #include <locale.h> #include <string.h> /********************************************************************** ** ** Static variables ** ***********************************************************************/ /********************************************************************** ** ** Extern variables ** ***********************************************************************/ pthread_mutex_t spgp_mtx; uint32_t _spgp_err; jmp_buf exception; #ifdef DEBUG_LOG_ENABLED uint8_t debug_log_enabled = 1; #else uint8_t debug_log_enabled = 0; #endif /********************************************************************** ** ** Static function prototypes ** ***********************************************************************/ static spgp_packet_t* spgp_packet_decode_loop(uint8_t *message, uint32_t *idx, uint32_t length); static uint8_t spgp_parse_header(uint8_t *msg, uint32_t *idx, uint32_t length, spgp_packet_t *pkt); static uint32_t spgp_new_header_length(uint8_t *header, uint8_t *header_len, uint8_t *is_partial); static uint8_t spgp_parse_user_id(uint8_t *msg, uint32_t *idx, uint32_t length, spgp_packet_t *pkt); static uint8_t spgp_generate_fingerprint(spgp_packet_t *pkt); static uint8_t spgp_verify_decrypted_data(uint8_t *data, uint32_t length); static uint8_t spgp_generate_cipher_key(spgp_packet_t *pkt, uint8_t *passphrase, uint32_t length); static uint8_t spgp_parse_public_key(uint8_t *msg, uint32_t *idx, uint32_t length, spgp_packet_t *pkt); static uint8_t spgp_parse_secret_key(uint8_t *msg, uint32_t *idx, uint32_t length, spgp_packet_t *pkt); static spgp_packet_t *spgp_next_secret_key_packet(spgp_packet_t *msg); static uint8_t spgp_decrypt_secret_key(spgp_packet_t *pkt, uint8_t *passphrase, uint32_t length); static uint8_t spgp_parse_compressed_packet(uint8_t *msg, uint32_t *idx, uint32_t length, spgp_packet_t *pkt); static uint8_t spgp_parse_encrypted_packet(uint8_t *msg, uint32_t *idx, uint32_t *length, spgp_packet_t *pkt); static uint8_t spgp_parse_literal_packet(uint8_t *msg, uint32_t *idx, uint32_t length, spgp_packet_t *pkt); static uint8_t spgp_parse_signature_packet(uint8_t *msg, uint32_t *idx, uint32_t length, spgp_packet_t *pkt); static spgp_packet_t *spgp_find_session_packet(spgp_packet_t *chain); static uint8_t spgp_parse_session_packet(uint8_t *msg, uint32_t *idx, uint32_t length, spgp_packet_t *pkt); static spgp_packet_t *spgp_secret_key_matching_id(spgp_packet_t *chain, uint8_t *keyid); static uint8_t spgp_read_salt(uint8_t *msg, uint32_t *idx, uint32_t length, spgp_secret_pkt_t *secret); static uint8_t spgp_read_iv(uint8_t *msg, uint32_t *idx, uint32_t length, spgp_secret_pkt_t *secret); /********************************************************************** ** ** External function definitions ** ***********************************************************************/ #pragma mark External Function Definitions uint8_t spgp_init(void) { if (pthread_mutex_init(&spgp_mtx, NULL)) return -1; if (spgp_keychain_init()) return -1; return 0; } uint8_t spgp_close(void) { spgp_packet_t *chain = NULL; if (spgp_keychain_is_valid()) { spgp_keychain_iter_start(); while ((chain = spgp_keychain_iter_next()) != NULL) { spgp_free_packet(&chain); } spgp_keychain_iter_end(); spgp_keychain_free(); } pthread_mutex_destroy(&spgp_mtx); return 0; } spgp_packet_t *spgp_decode_message(uint8_t *message, uint32_t length) { spgp_packet_t *head = NULL; // spgp_packet_t *pkt = NULL; uint32_t idx = 0; Serial.printf("begin\n"); switch (setjmp(exception)) { case 0: break; /* Run logic */ /* Below here are exceptions */ default: Serial.printf("Exception (0x%x)\n",_spgp_err); spgp_free_packet(&head); goto end; } if (NULL == message || 0 == length) { RAISE(INVALID_ARGS); } #if 0 // There must be at least one packet, yeah? head = malloc(sizeof(*head)); if (NULL == head) RAISE(OUT_OF_MEMORY); memset(head, 0, sizeof(*head)); pkt = head; // Loop to decode every packet in message while (idx < length-1) { // Every packet starts with a header spgp_parse_header(message, &idx, length, pkt); if (!pkt->header) RAISE(FORMAT_UNSUPPORTED); // Decode packet contents based on the type marked in its header switch (pkt->header->type) { case PKT_TYPE_USER_ID: spgp_parse_user_id(message, &idx, length, pkt); break; case PKT_TYPE_PUBLIC_KEY: case PKT_TYPE_PUBLIC_SUBKEY: spgp_parse_public_key(message, &idx, length, pkt); break; case PKT_TYPE_SECRET_KEY: case PKT_TYPE_SECRET_SUBKEY: spgp_parse_secret_key(message, &idx, length, pkt); break; case PKT_TYPE_SESSION: spgp_parse_session_packet(message, &idx, length, pkt); break; case PKT_TYPE_SYM_ENC_INT_DATA: spgp_parse_encrypted_packet(message, &idx, length, pkt); break; case PKT_TYPE_COMPRESSED_DATA: spgp_parse_compressed_packet(message, &idx, length, pkt); break; default: Serial.printf("WARNING: Unsupported packet type %u\n", pkt->header->type); // Increment to next packet. We add the contentLength, but subtract // one parse_header() left us on the first byte of content. if (idx + pkt->header->contentLength - 1 < length) idx = idx + pkt->header->contentLength - 1; break; } // If we're at the end of the buffer, we're done if (idx >= length-1) break; // Allocate space for another packet pkt->next = malloc(sizeof(*pkt->next)); if (NULL == pkt->next) RAISE(OUT_OF_MEMORY); memset(pkt->next, 0, sizeof(*pkt->next)); pkt->next->prev = pkt; // make backwards pointer pkt = pkt->next; // Packet parser increments to it's own last byte. Need one more to get // to the next packet's first byte. SAFE_IDX_INCREMENT(idx, length); } #endif head = spgp_packet_decode_loop(message, &idx, length); end: Serial.printf("done\n"); return head; } char *spgp_get_literal_data(spgp_packet_t *msg, uint32_t *datalen, char **filename, uint32_t *filenamelen) { spgp_packet_t *cur = msg; if (setjmp(exception)) { Serial.printf("Exception (0x%x)\n",_spgp_err); goto end; } if (NULL == msg || NULL == datalen || NULL == filename || NULL == filenamelen) RAISE(INVALID_ARGS); while (cur) { if (cur->header->type == PKT_TYPE_LITERAL_DATA) { *datalen = cur->c.literal->dataLen; *filenamelen = cur->c.literal->filenameLen; *filename = cur->c.literal->filename; return cur->c.literal->data; } cur = cur->next; } end: return NULL; } uint8_t spgp_decrypt_all_secret_keys(spgp_packet_t *msg, uint8_t *passphrase, uint32_t length) { spgp_packet_t *cur = msg; uint8_t err = 0; uint8_t haskey = 0; if (setjmp(exception)) { Serial.printf("Exception (0x%x)\n",_spgp_err); goto end; } if (NULL == msg || NULL == passphrase || length == 0) RAISE(INVALID_ARGS); while ((cur = spgp_next_secret_key_packet(cur)) != NULL) { Serial.printf("Decrypting secret key\n"); spgp_decrypt_secret_key(cur, passphrase, length); cur = cur->next; haskey = 1; } // Add decrypted keys to keychain if (haskey) if (spgp_keychain_add_packet(msg) != 0) RAISE(KEYCHAIN_ERROR); end: return err; } void spgp_free_packet(spgp_packet_t **pkt) { spgp_mpi_t *curMpi, *nextMpi; if (pkt == NULL) return; if (*pkt == NULL) return; //LOG_PRINT("Freeing packet: %p\n", pkt); // Recursively call on the next packet before freeing parent. if ((*pkt)->next) spgp_free_packet(&((*pkt)->next)); // Release memory allocated for secret key fields if (((*pkt)->header->type == PKT_TYPE_SECRET_KEY || (*pkt)->header->type == PKT_TYPE_SECRET_SUBKEY) && (*pkt)->c.secret != NULL) { if ((*pkt)->c.secret->pub.mpiCount > 0) { curMpi = (*pkt)->c.secret->pub.mpiHead; while (curMpi) { nextMpi = curMpi->next; if (curMpi->data) free(curMpi->data); free(curMpi); curMpi = nextMpi; } (*pkt)->c.secret->pub.mpiHead = NULL; (*pkt)->c.secret->pub.mpiCount = 0; } if ((*pkt)->c.secret->pub.fingerprint) { free((*pkt)->c.secret->pub.fingerprint); } if ((*pkt)->c.secret->encryptedData) { free((*pkt)->c.secret->encryptedData); } if ((*pkt)->c.secret->s2kSalt) { free((*pkt)->c.secret->s2kSalt); (*pkt)->c.secret->s2kSalt = NULL; } if ((*pkt)->c.secret->key) { free((*pkt)->c.secret->key); (*pkt)->c.secret->key = NULL; } if ((*pkt)->c.secret->iv) { free((*pkt)->c.secret->iv); (*pkt)->c.secret->iv = NULL; } free((*pkt)->c.secret); (*pkt)->c.secret = NULL; } else if (((*pkt)->header->type == PKT_TYPE_PUBLIC_KEY || (*pkt)->header->type == PKT_TYPE_PUBLIC_SUBKEY) && (*pkt)->c.pub != NULL) { if ((*pkt)->c.pub->mpiCount > 0) { curMpi = (*pkt)->c.pub->mpiHead; while (curMpi->next) { nextMpi = curMpi->next; if (curMpi->data) free(curMpi->data); free(curMpi); curMpi = nextMpi; } (*pkt)->c.pub->mpiHead = NULL; (*pkt)->c.pub->mpiCount = 0; } if ((*pkt)->c.pub->fingerprint) { free((*pkt)->c.pub->fingerprint); } } else if ((*pkt)->header->type == PKT_TYPE_USER_ID && (*pkt)->c.userid->data != NULL) { free((*pkt)->c.userid->data); (*pkt)->c.userid->data = NULL; free((*pkt)->c.userid); (*pkt)->c.userid = NULL; } else if ((*pkt)->header->type == PKT_TYPE_SESSION && (*pkt)->c.session != NULL) { if ((*pkt)->c.session->key) { free((*pkt)->c.session->key); (*pkt)->c.session->key = NULL; } if ((*pkt)->c.session->mpi1) { free((*pkt)->c.session->mpi1->data); free((*pkt)->c.session->mpi1); (*pkt)->c.session->mpi1 = NULL; } if ((*pkt)->c.session->mpi2) { free((*pkt)->c.session->mpi2->data); free((*pkt)->c.session->mpi2); (*pkt)->c.session->mpi2 = NULL; } free((*pkt)->c.session); } else if ((*pkt)->header->type == PKT_TYPE_LITERAL_DATA && (*pkt)->c.literal != NULL) { if ((*pkt)->c.literal->filename) { free((*pkt)->c.literal->filename); (*pkt)->c.literal->filename = NULL; } if ((*pkt)->c.literal->data) { free((*pkt)->c.literal->data); (*pkt)->c.literal->data = NULL; } free((*pkt)->c.literal); } // release header if ((*pkt)->header) { free((*pkt)->header); (*pkt)->header = NULL; } // release packet free(*pkt); *pkt = NULL; } uint32_t spgp_err(void) { return _spgp_err; } const char *spgp_err_str(uint32_t err) { switch (err) { case INVALID_ARGS: return "Invalid arguments given to function."; case OUT_OF_MEMORY: return "Not enough memory to continue parsing."; case INVALID_HEADER: return "Invalid header format. Corrupted or invalid data."; case FORMAT_UNSUPPORTED: return "Message format is valid, but not currently supported."; case BUFFER_OVERFLOW: return "Index into buffer exceeded the maximum " "bound of the buffer."; default: return "Unknown/undocumented error."; } } uint8_t spgp_debug_log_enabled(void) { return debug_log_enabled; } void spgp_debug_log_set(uint8_t enable) { pthread_mutex_lock(&spgp_mtx); debug_log_enabled = enable; pthread_mutex_unlock(&spgp_mtx); } /********************************************************************** ** ** Static function definitions ** ***********************************************************************/ #pragma mark Static Function Definitions static spgp_packet_t* spgp_packet_decode_loop(uint8_t *message, uint32_t *idx, uint32_t length) { spgp_packet_t *head = NULL; spgp_packet_t *pkt = NULL; // There must be at least one packet, yeah? head = malloc(sizeof(*head)); if (NULL == head) RAISE(OUT_OF_MEMORY); memset(head, 0, sizeof(*head)); pkt = head; // Loop to decode every packet in message while (*idx < length-1) { // Every packet starts with a header spgp_parse_header(message, idx, length, pkt); if (!pkt->header) RAISE(FORMAT_UNSUPPORTED); // Decode packet contents based on the type marked in its header switch (pkt->header->type) { case PKT_TYPE_USER_ID: spgp_parse_user_id(message, idx, length, pkt); break; case PKT_TYPE_PUBLIC_KEY: case PKT_TYPE_PUBLIC_SUBKEY: spgp_parse_public_key(message, idx, length, pkt); break; case PKT_TYPE_SECRET_KEY: case PKT_TYPE_SECRET_SUBKEY: spgp_parse_secret_key(message, idx, length, pkt); break; case PKT_TYPE_SESSION: spgp_parse_session_packet(message, idx, length, pkt); break; case PKT_TYPE_SYM_ENC_INT_DATA: spgp_parse_encrypted_packet(message, idx, &length, pkt); break; case PKT_TYPE_COMPRESSED_DATA: spgp_parse_compressed_packet(message, idx, length, pkt); break; case PKT_TYPE_LITERAL_DATA: spgp_parse_literal_packet(message, idx, length, pkt); break; case PKT_TYPE_SIGNATURE: spgp_parse_signature_packet(message, idx, length, pkt); break; default: Serial.printf("WARNING: Unsupported packet type %u\n", pkt->header->type); // Increment to next packet. We add the contentLength, but subtract // one parse_header() left us on the first byte of content. if (*idx + pkt->header->contentLength - 1 < length) *idx = *idx + pkt->header->contentLength - 1; break; } // If we're at the end of the buffer, we're done if (*idx >= length-1) break; // A packet can contain other packets -- if such a thing was just decoded, // new packets have already been added to the list. Progress until we // get to the end of the packet list. while (pkt->next != NULL) pkt = pkt->next; // Allocate space for another packet pkt->next = malloc(sizeof(*pkt->next)); if (NULL == pkt->next) RAISE(OUT_OF_MEMORY); memset(pkt->next, 0, sizeof(*pkt->next)); pkt->next->prev = pkt; // make backwards pointer pkt = pkt->next; // Packet parser increments to it's own last byte. Need one more to get // to the next packet's first byte. SAFE_IDX_INCREMENT(*idx, length); } return head; } static uint8_t spgp_parse_header(uint8_t *msg, uint32_t *idx, uint32_t length, spgp_packet_t *pkt) { uint8_t i; if (NULL == msg || NULL == pkt || NULL == idx || length == 0) RAISE(INVALID_ARGS); // Allocate a header if (pkt->header == NULL) { Serial.printf("Allocating header.\n"); pkt->header = malloc(sizeof(*(pkt->header))); if (pkt->header == NULL) RAISE(OUT_OF_MEMORY); memset(pkt->header, 0, sizeof(*(pkt->header))); } // Header points to its parent packet pkt->header->parent = pkt; // The first byte is the 'tag byte', which tells us the packet type. pkt->header->rawTagByte = msg[*idx]; SAFE_IDX_INCREMENT(*idx, length); Serial.printf("TAG BYTE: 0x%.2X\n", pkt->header->rawTagByte); // Validate tag byte -- top bit always set if (!(pkt->header->rawTagByte & 0x80)) RAISE(INVALID_HEADER); // Second-MSB tells us if this is new or old format header pkt->header->isNewFormat = pkt->header->rawTagByte & 0x40; // Read the packet type out of the tag byte if (pkt->header->isNewFormat) pkt->header->type = pkt->header->rawTagByte & 0x1F; else // old style pkt->header->type = (pkt->header->rawTagByte >> 2) & 0x0F; Serial.printf("TYPE: 0x%.2X\n", pkt->header->type); // Read the length of the packet's contents. In old packets, the length // is encoded into the tag byte. if (pkt->header->isNewFormat == 0) { switch (pkt->header->rawTagByte & 0x03) { case 0: pkt->header->headerLength = 2; break; case 1: pkt->header->headerLength = 3; break; case 2: pkt->header->headerLength = 5; break; default: // "indeterminate length" packet Serial.printf("Indeterminate length packet\n"); pkt->header->headerLength = 1; pkt->header->contentLength = length-*idx-1; } for (i = 0; i < pkt->header->headerLength - 1; i++) { pkt->header->contentLength <<= 8; pkt->header->contentLength += msg[*idx]; SAFE_IDX_INCREMENT(*idx, length); } } // In new packets, the length is encoded over a variable number of bytes, // with the range of the first byte determining total number of bytes. else { // This is new style packet. pkt->header->contentLength = spgp_new_header_length(msg+*idx, &(pkt->header->headerLength), &(pkt->header->isPartial)); *idx += pkt->header->headerLength - 2; SAFE_IDX_INCREMENT(*idx, length); } Serial.printf("LENGTH: %u\n", pkt->header->contentLength); return 0; } static uint32_t spgp_new_header_length(uint8_t *header, uint8_t *header_len, uint8_t *is_partial) { uint32_t content; uint8_t len[4]; uint8_t i = 0; if (NULL == header || NULL == header_len) RAISE(INVALID_ARGS); *is_partial = 0; // default to known length len[0] = header[i]; if (len[0] <= 191) { // 1-byte length *header_len = 2; content = len[0]; } else if (len[0] > 191 && len[0] <= 223) { // 2-byte length *header_len = 3; len[1] = header[i+1]; content = ((len[0]-192)<<8) | (len[1] + 192); } else if (len[0] == 255) { // 5-byte length *header_len = 5; len[0] = header[i+1]; len[1] = header[i+2]; len[2] = header[i+3]; len[3] = header[i+4]; content = (len[0]<<24) | (len[1]<<16) | (len[2]<<8) | len[3]; } else { // indeterminate length Serial.printf("Partial length header!\n"); *header_len = 2; *is_partial = 1; content = 1 << (len[0] & 0x1F); } return content; } static uint8_t spgp_parse_user_id(uint8_t *msg, uint32_t *idx, uint32_t length, spgp_packet_t *pkt) { spgp_userid_pkt_t *userid; Serial.printf("Parsing user id.\n"); // Make sure we have enough bytes remaining for the copy if (length - *idx < pkt->header->contentLength) RAISE(BUFFER_OVERFLOW); // Allocate userid field in packet pkt->c.userid = malloc(sizeof(*(pkt->c.userid))); if (NULL == pkt->c.userid) RAISE(OUT_OF_MEMORY); userid = pkt->c.userid; // Allocate space for buffer, plus one byte for NUL terminator userid->data = malloc(sizeof(*(userid->data))*pkt->header->contentLength + 1); if (NULL == userid->data) RAISE(OUT_OF_MEMORY); // Copy bytes from input to structure, and add a NUL terminator memcpy(userid->data, msg+*idx, pkt->header->contentLength); userid->data[pkt->header->contentLength] = '\0'; *idx += pkt->header->contentLength - 1; setlocale(LC_CTYPE, "en_US.UTF-8"); Serial.printf("USER ID: %s\n", pkt->c.userid->data); return 0; } static uint8_t spgp_generate_fingerprint(spgp_packet_t *pkt) { uint16_t packetSize; uint8_t packetHeaderSize; spgp_mpi_t *curMpi; uint8_t targetMpiCount; gcry_md_hd_t md; unsigned char *hash; int i; if (NULL == pkt) RAISE(INVALID_ARGS); // Start with header info: 1 version, 4 creation time, 1 algorithm packetHeaderSize = sizeof(pkt->c.pub->version) + sizeof(pkt->c.pub->creationTime) + sizeof(pkt->c.pub->asymAlgo); packetSize = packetHeaderSize; // Figure out how many MPIs to add switch(pkt->c.pub->asymAlgo) { case ASYM_ALGO_RSA: targetMpiCount = 2; break; case ASYM_ALGO_DSA: targetMpiCount = 4; break; case ASYM_ALGO_ELGAMAL: targetMpiCount = 3; break; default: RAISE(FORMAT_UNSUPPORTED); } // Add size of each MPI curMpi = pkt->c.pub->mpiHead; i = 0; while (curMpi && i < targetMpiCount) { packetSize += curMpi->count + 2; // add 2 for MPI header curMpi = curMpi->next; i++; } // Give data to hash to gcrypt if (gcry_md_open (&md, GCRY_MD_SHA1, 0) != 0) RAISE(GCRY_ERROR); gcry_md_putc(md, 0x99 ); gcry_md_putc(md, packetSize >> 8); gcry_md_putc(md, packetSize); gcry_md_putc(md, pkt->c.pub->version); gcry_md_putc(md, pkt->c.pub->creationTime); gcry_md_putc(md, pkt->c.pub->creationTime >> 8); gcry_md_putc(md, pkt->c.pub->creationTime >> 16); gcry_md_putc(md, pkt->c.pub->creationTime >> 24); gcry_md_putc(md, pkt->c.pub->asymAlgo); // Write the public key MPIs curMpi = pkt->c.pub->mpiHead; i = 0; while (curMpi && i < targetMpiCount) { gcry_md_write(md, curMpi->data, curMpi->count + 2); curMpi = curMpi->next; i++; } // Perform SHA-1 hash gcry_md_final(md); hash = gcry_md_read(md, 0); // Copy hash results (20-bytes) into fingerprint pkt->c.pub->fingerprint = malloc(20); if (NULL == pkt->c.pub->fingerprint) RAISE(OUT_OF_MEMORY); memcpy(pkt->c.pub->fingerprint, hash, 20); Serial.printf("HASH: "); for (targetMpiCount=0; targetMpiCount < 20; targetMpiCount++) { Serial.printf("%.2X", pkt->c.pub->fingerprint[targetMpiCount]); } Serial.printf("\n"); gcry_md_close(md); return 0; } static uint8_t spgp_verify_decrypted_data(uint8_t *data, uint32_t length) { gcry_md_hd_t md; uint32_t hashlen = length - 20; // SHA1 hash is 20 bytes uint8_t *hashResult; int result; if (gcry_md_open (&md, GCRY_MD_SHA1, 0) != 0) RAISE(GCRY_ERROR); gcry_md_write(md, data, hashlen); gcry_md_final(md); hashResult = gcry_md_read(md, 0); if (NULL == hashResult) RAISE(GCRY_ERROR); result = memcmp(data+hashlen, hashResult, 20); gcry_md_close(md); return result; } /** * Generate cipher key to decrypt secret key packet * * The secret portion of a secret key packet can be encrypted with a * symmetric cipher. This function generates the 'key' that is used as * the input to the symmetric cipher. This key is generated by hashing * a randomly generated salt, included in the packet, and the user's * passphrase (which must be provided). * * OpenPGP's standard allows multiple ways of generating the key by varying * the hash algorithm. * * @param pkt A secret key or secret subkey packet * @param passphrase User's passphrase to decrypt with * @param length Length (in bytes) of user's passphrase * * @return 0 on success. Raises exception on error. * */ static uint8_t spgp_generate_cipher_key(spgp_packet_t *pkt, uint8_t *passphrase, uint32_t length) { spgp_secret_pkt_t *secret; spgp_public_pkt_t *pub; gcry_md_hd_t md; uint32_t i; uint32_t keyBytesRemaining;// Bytes left to generate for key uint32_t hashLen; // How long the hash is (algo-dependent) uint32_t hashIters; // How many hash results to combine into key uint32_t hashBytes; // Total number of bytes to hash each time uint32_t bufLen; // Length of salt+passphrase uint32_t curHashCount; // How many times we have performed full hash uint32_t hashCopies; // How many integer copies of hashBuf per round uint32_t hashExtraBytes; // How many extra bytes to hash for last round uint8_t *hashBuf; // Store concatenated salt+passphrase uint8_t *hashResult; // Store result of actual hash algorithm if (NULL == pkt || NULL == passphrase) RAISE(INVALID_ARGS); secret = pkt->c.secret; pub = pkt->c.pub; if (pkt->header->type != PKT_TYPE_SECRET_KEY && pkt->header->type != PKT_TYPE_SECRET_SUBKEY) RAISE(INVALID_ARGS); // Determine how many bytes we need to produce for this cipher // Only supporting 3DES for this switch(secret->s2kEncryption) { case SYM_ALGO_3DES: secret->keyLength = 24; break; case SYM_ALGO_CAST5: secret->keyLength = 16; break; default: RAISE(FORMAT_UNSUPPORTED); } // Initialize hash algorithm, determine how many bytes produces per round switch (secret->s2kHashAlgo) { case HASH_ALGO_SHA1: if (gcry_md_open (&md, GCRY_MD_SHA1, 0) != 0) RAISE(GCRY_ERROR); hashLen = 20; break; default: RAISE(FORMAT_UNSUPPORTED); break; } // Determine how many times we have to hash to generate a large enough key // Ex: 3DES needs 24 bytes, SHA1 makes 20 bytes, so need to SHA1 hashes. hashIters = (secret->keyLength/hashLen) + (secret->keyLength%hashLen>0)?1:0; // What hashing mode to use. // Currently only supporting salted+iterated switch (secret->s2kSpecifier) { case S2K_TYPE_ITERATED: break; default: RAISE(FORMAT_UNSUPPORTED); break; } // Allocate space for the key secret->key = malloc(secret->keyLength); if (NULL == secret->key) RAISE(OUT_OF_MEMORY); // Allocate a buffer to store the salt and passphrase combined // Since this buffer is local only, no exceptions can be raised after // this point or memory will be leaked. bufLen = secret->s2kSaltLength + length; hashBuf = malloc(bufLen); if (NULL == hashBuf) RAISE(OUT_OF_MEMORY); // Concatenate salt and passphrase into hashBuf memcpy(hashBuf, secret->s2kSalt, secret->s2kSaltLength); memcpy(hashBuf + secret->s2kSaltLength, passphrase, length); // Magic formula from RFC 4880. This is number of bytes to hash over. hashBytes = (16 + (secret->s2kCount & 15)) << ((secret->s2kCount >> 4) + 6); // Figure out how many times to iterate over hashBuf to get hashBytes, // and how many extra bytes are needed at the end if not an even multiple. hashCopies = hashBytes / (bufLen); hashExtraBytes = hashBytes % (bufLen); keyBytesRemaining = secret->keyLength; // Loop until we have enough hash bytes to make the key curHashCount = 0; while (curHashCount <= hashIters && keyBytesRemaining) { for (i = 0; i < curHashCount; i++) { // pad front with 1 NUL byte per round (none on first round) gcry_md_putc(md, '\0'); } // Copy the salt+passphrase combo into hash buffer as many times as fits for (i = 0; i < hashCopies; i++) { gcry_md_write(md, hashBuf, bufLen); } // Copy any leftover bytes into hash buffer to reach |hashBytes| if (hashExtraBytes) { gcry_md_write(md, hashBuf, hashExtraBytes); } // Perform the hash and append to the key gcry_md_final(md); hashResult = gcry_md_read(md, 0); if (keyBytesRemaining < hashLen) { memcpy(secret->key+(curHashCount*hashLen), hashResult, keyBytesRemaining); keyBytesRemaining = 0; } else { memcpy(secret->key+(curHashCount*hashLen), hashResult, hashLen); keyBytesRemaining -= hashLen; } // Reset hash algorithm for next round gcry_md_reset(md); curHashCount++; } gcry_md_close(md); free(hashBuf); return 0; } static uint8_t spgp_parse_public_key(uint8_t *msg, uint32_t *idx, uint32_t length, spgp_packet_t *pkt) { spgp_public_pkt_t *pub; Serial.printf("Parsing public key.\n"); // Make sure we have enough bytes remaining for parsing if (length - *idx < pkt->header->contentLength) RAISE(BUFFER_OVERFLOW); // Allocate public key if it doesn't already exist. It might exist if // this packet is a secret key. if (!(pkt->c.pub)) { pkt->c.pub = malloc(sizeof(*(pkt->c.pub))); if (NULL == pkt->c.pub) RAISE(OUT_OF_MEMORY); memset(pkt->c.pub, 0, sizeof(*(pkt->c.pub))); } pub = pkt->c.pub; pub->version = msg[*idx]; SAFE_IDX_INCREMENT(*idx, length); // First byte is the version. if (pub->version != 4) RAISE(FORMAT_UNSUPPORTED); // Next 4 bytes are big-endian 'key creation time' if (length - *idx < 4) RAISE(BUFFER_OVERFLOW); memcpy(&(pub->creationTime), msg+*idx, 4); *idx += 3; // this puts us on last byte of creation time SAFE_IDX_INCREMENT(*idx, length); // this goes to next byte (safely) // Next byte identifies asymmetric algorithm pub->asymAlgo = msg[*idx]; SAFE_IDX_INCREMENT(*idx, length); Serial.printf("Asymmetric algorithm: %d\n", pub->asymAlgo); // Read variable number of MPIs (depends on asymmetric algorithm), each // of which are variable size. spgp_read_all_public_mpis(msg, idx, length, pkt->c.pub); Serial.printf("Read %u MPIs\n", pub->mpiCount); return 0; } static uint8_t spgp_parse_secret_key(uint8_t *msg, uint32_t *idx, uint32_t length, spgp_packet_t *pkt) { spgp_secret_pkt_t *secret; spgp_public_pkt_t *pub; uint32_t startIdx = *idx; Serial.printf("Parsing secret key.\n"); // Make sure we have enough bytes remaining for parsing if (length - *idx < pkt->header->contentLength) RAISE(BUFFER_OVERFLOW); // Allocate secret key in packet pkt->c.secret = malloc(sizeof(*(pkt->c.secret))); if (NULL == pkt->c.secret) RAISE(OUT_OF_MEMORY); memset(pkt->c.secret, 0, sizeof(*(pkt->c.secret))); secret = pkt->c.secret; pub = pkt->c.pub; // Parse the public key section that starts it spgp_parse_public_key(msg, idx, length, pkt); // idx ends on last byte of public key. One more to start secret key. SAFE_IDX_INCREMENT(*idx, length); // S2K Type byte tells how to (or if to) decrypt secret exponent secret->s2kType = msg[*idx]; SAFE_IDX_INCREMENT(*idx, length); switch (secret->s2kType) { case 0: // There is no encryption secret->s2kEncryption = 0; break; case 254: case 255: // Next byte is encryption type secret->s2kEncryption = msg[*idx]; SAFE_IDX_INCREMENT(*idx, length); break; default: // This byte is encryption type secret->s2kEncryption = secret->s2kType; break; } Serial.printf("Encryption: %u\n", secret->s2kEncryption); if (secret->s2kEncryption) { // Secret exponent is encrypted (as it should be). Time to decrypt. // S2K specifier tells us if there is a salt, and how to use it if (secret->s2kType >= 254) { secret->s2kSpecifier = msg[*idx]; SAFE_IDX_INCREMENT(*idx, length); Serial.printf("S2K Specifier: %u\n", secret->s2kSpecifier); } // S2K hash algorithm specifies how to hash passphrase into a key secret->s2kHashAlgo = msg[*idx]; SAFE_IDX_INCREMENT(*idx, length); Serial.printf("Hash algorithm: %u\n", secret->s2kHashAlgo); // Read the salt if there is one switch (secret->s2kSpecifier) { case 1: spgp_read_salt(msg, idx, length, secret); break; case 3: spgp_read_salt(msg, idx, length, secret); // S2K Count is number of bytes to hash to make the key secret->s2kCount = msg[*idx]; SAFE_IDX_INCREMENT(*idx, length); break; default: break; } } Serial.printf("Salt length: %u\n", secret->s2kSaltLength); // If it's not encrypted, we can just read the secret MPIs if (!secret->s2kEncryption) { spgp_read_all_secret_mpis(msg, idx, length, secret); } // If it is encrypted, just store it for now. We'll decrypt later. else { // There's an initial vector (IV) here: spgp_read_iv(msg, idx, length, secret); Serial.printf("IV length: %u\n", secret->ivLength); // Figure out how much is left, and make sure it's available uint32_t packetOffset = *idx - startIdx; uint32_t remaining = pkt->header->contentLength - packetOffset; if (packetOffset >= pkt->header->contentLength) RAISE(BUFFER_OVERFLOW); // Allocate buffer and copy data secret->encryptedData = malloc(remaining); if (NULL == secret->encryptedData) RAISE(OUT_OF_MEMORY); memcpy(secret->encryptedData, msg+*idx, remaining); secret->encryptedDataLength = remaining; *idx += remaining-1; Serial.printf("Stored %u encrypted bytes.\n", remaining); // This is the end of the data, so we do NOT do a final idx increment } // Create and store fingerprint for this packet spgp_generate_fingerprint(pkt); return 0; } static spgp_packet_t *spgp_next_secret_key_packet(spgp_packet_t *msg) { spgp_packet_t *cur = msg; while (cur) { if (cur->header->type == PKT_TYPE_SECRET_KEY || cur->header->type == PKT_TYPE_SECRET_SUBKEY) return cur; cur = cur->next; } return NULL; } static uint8_t spgp_decrypt_secret_key(spgp_packet_t *pkt, uint8_t *passphrase, uint32_t length) { gcry_cipher_hd_t hd; spgp_secret_pkt_t *secret; spgp_public_pkt_t *pub; spgp_mpi_t *curMpi; uint32_t idx; uint32_t secretMpiCount; uint8_t *secdata; uint8_t i; uint8_t err = 0; if (NULL == pkt || NULL == passphrase || length == 0) RAISE(INVALID_ARGS); secret = pkt->c.secret; pub = pkt->c.pub; if (pkt->header->type != PKT_TYPE_SECRET_KEY && pkt->header->type != PKT_TYPE_SECRET_SUBKEY) RAISE(INVALID_ARGS); if (secret->isDecrypted) return err; // already decrypted! spgp_generate_cipher_key(pkt, passphrase, length); switch (secret->s2kEncryption) { case SYM_ALGO_3DES: case SYM_ALGO_CAST5: if (gcry_cipher_open(&hd, spgp_pgp_to_gcrypt_symmetric_algo(secret->s2kEncryption), GCRY_CIPHER_MODE_CFB, GCRY_CIPHER_SECURE | GCRY_CIPHER_ENABLE_SYNC) != 0) RAISE(GCRY_ERROR); break; default: RAISE(FORMAT_UNSUPPORTED); } if (NULL == secret->key || NULL == secret->iv) RAISE(INCOMPLETE_PACKET); if (gcry_cipher_setkey(hd, secret->key, secret->keyLength) != 0) RAISE(GCRY_ERROR); if (gcry_cipher_setiv(hd, secret->iv, secret->ivLength) != 0) RAISE(GCRY_ERROR); // Allocate secret data memory. Must free it before raising any exceptions! secdata = malloc(secret->encryptedDataLength); if (NULL == secdata) RAISE(OUT_OF_MEMORY); if (gcry_cipher_decrypt(hd, secdata, secret->encryptedDataLength, secret->encryptedData, secret->encryptedDataLength) != 0) { free(secdata); RAISE(GCRY_ERROR); } // Verify checksum if (spgp_verify_decrypted_data(secdata, secret->encryptedDataLength) != 0) RAISE(DECRYPT_FAILED); // Decode and store the secret MPIs (algo-specific): switch(pub->asymAlgo) { case ASYM_ALGO_RSA: secretMpiCount = 4; break; case ASYM_ALGO_DSA: case ASYM_ALGO_ELGAMAL: secretMpiCount = 1; break; default: RAISE(FORMAT_UNSUPPORTED); } // Get to the last valid MPI if (NULL == pub->mpiHead) RAISE(INCOMPLETE_PACKET); curMpi = pub->mpiHead; while (curMpi->next) curMpi = curMpi->next; idx = 0; for (i = 0; i < secretMpiCount; i++) { curMpi->next = spgp_read_mpi(secdata, &idx, secret->encryptedDataLength); if (NULL == curMpi->next) RAISE(GENERIC_ERROR); curMpi = curMpi->next; SAFE_IDX_INCREMENT(idx, secret->encryptedDataLength); pub->mpiCount++; } secret->isDecrypted = 1; gcry_cipher_close(hd); free(secdata); end: return err; } #include "zlib.h" static uint8_t spgp_zlib_decompress_buffer(uint8_t *inbuf, uint32_t inlen, uint8_t **outbuf, uint32_t *outlen, uint8_t algo) { uint32_t maxsize; z_stream s; uint8_t *tmpbuf; int wbits; int err; int i; if (NULL == inbuf || inlen == 0 || NULL == outbuf || NULL == outlen) RAISE(INVALID_ARGS); maxsize = inlen * 100; *outbuf = malloc(maxsize); if (NULL == *outbuf) RAISE(OUT_OF_MEMORY); s.zalloc = Z_NULL; s.zfree = Z_NULL; s.next_in = inbuf; s.avail_in = inlen; s.next_out = *outbuf; s.avail_out = maxsize; if (algo == COMPRESSION_ZIP) wbits = -15; else wbits = 15; if (inflateInit2(&s, wbits) != Z_OK) RAISE(ZLIB_ERROR); for (i = s.total_out; i < maxsize; i++) (*outbuf)[i] = 0x55; Serial.printf("Inflating up to %u bytes\n", maxsize); while ((err = inflate(&s, Z_NO_FLUSH)) != Z_STREAM_END) { if (err != Z_OK) RAISE(ZLIB_ERROR); if (s.avail_in == 0) break; // Done // If we're here, our output buffer isn't large enough maxsize <<= 1; // double size tmpbuf = *outbuf; *outbuf = realloc(*outbuf, maxsize); if (NULL == *outbuf) { free(tmpbuf); RAISE(OUT_OF_MEMORY); } s.next_out = *outbuf + s.total_out; for (i = s.total_out; i < maxsize; i++) (*outbuf)[i] = 0x55; s.avail_out = maxsize - s.total_out; Serial.printf("Grew to up to %u bytes\n", maxsize); } Serial.printf("Total inflated bytes: %lu\n", s.total_out); *outlen = s.total_out; if (inflateEnd(&s) != Z_OK) RAISE(ZLIB_ERROR); return 0; } static uint8_t spgp_parse_compressed_packet(uint8_t *msg, uint32_t *idx, uint32_t length, spgp_packet_t *pkt) { int algo; spgp_packet_t *pkts; uint8_t *decomp; uint32_t decomp_len; uint32_t didx; if (NULL == msg || NULL == idx || length == 0 || NULL == pkt) RAISE(INVALID_ARGS); algo = msg[*idx]; SAFE_IDX_INCREMENT(*idx, length); switch (algo) { case 1: Serial.printf("ZIP compressed packet\n"); spgp_zlib_decompress_buffer(msg+*idx, pkt->header->contentLength, &decomp, &decomp_len, algo); break; case 2: Serial.printf("ZLIB compressed packet\n"); spgp_zlib_decompress_buffer(msg+*idx, pkt->header->contentLength, &decomp, &decomp_len, algo); break; default: Serial.printf("Unsupported packet compression: %u\n", algo); RAISE(FORMAT_UNSUPPORTED); } if (NULL == decomp) RAISE(DECRYPT_FAILED); // Decode all the packets in this compressed packet didx = 0; pkts = spgp_packet_decode_loop(decomp, &didx, decomp_len); if (NULL == pkts) RAISE(INCOMPLETE_PACKET); // Add packets to the current chain pkt->next = pkts; pkts->prev = pkt; free(decomp); decomp = NULL; // Progress index through current chain *idx += pkt->header->contentLength; return 0; } static uint8_t spgp_parse_encrypted_packet(uint8_t *msg, uint32_t *idx, uint32_t *length, spgp_packet_t *pkt) { spgp_packet_t *session_pkt; spgp_session_pkt_t *session; gcry_cipher_hd_t cipher_hd; gcry_error_t err; int version; unsigned long blksize; uint32_t encbytes; uint32_t startidx; uint8_t headerlen; uint8_t is_done; uint8_t is_partial; if (NULL == msg || NULL == idx || *length == 0 || NULL == pkt) RAISE(INVALID_ARGS); version = msg[*idx]; SAFE_IDX_INCREMENT(*idx, *length); // As of this writing, only version 1 exists if (version != 1) RAISE(FORMAT_UNSUPPORTED); session_pkt = spgp_find_session_packet(pkt); if (NULL == session_pkt) { Serial.printf("No session key found!\n"); RAISE(DECRYPT_FAILED); } session = session_pkt->c.session; startidx = *idx; is_done = 0; is_partial = pkt->header->isPartial; // Drop 1 from contentLength to account for version encbytes = pkt->header->contentLength - 1; err = gcry_cipher_open (&cipher_hd, spgp_pgp_to_gcrypt_symmetric_algo(session->symAlgo), GCRY_CIPHER_MODE_CFB, (GCRY_CIPHER_SECURE | GCRY_CIPHER_ENABLE_SYNC | GCRY_CIPHER_ENABLE_SYNC)); blksize = spgp_iv_length_for_symmetric_algo(session->symAlgo); err |= gcry_cipher_setkey(cipher_hd, session->key, session->keylen); err |= gcry_cipher_setiv(cipher_hd, 0, blksize); if (err) RAISE(GCRY_ERROR); // Since data packets can have partial length, we loop and decrypt // here until the whole blasted thing is decrypted. while (!is_done) { err = gcry_cipher_decrypt(cipher_hd, msg+*idx, encbytes, NULL, 0); if (err) RAISE(GCRY_ERROR); *idx += encbytes - 1; // increment to last byte of data // Check if we're done if (!(is_partial)) { is_done = 1; continue; } // We are processing a partial packet, so figure out next length SAFE_IDX_INCREMENT(*idx, *length); // inc to first byte of header encbytes = spgp_new_header_length(msg+*idx, &(headerlen), &(is_partial)); Serial.printf("%u more bytes\n", encbytes); // Fuck everything and everyone. Partial lengths are the enemy of // gentlemen. We shall kill it brutishly, by moving everything down. // God help you if your buffer is massive. // // The issue here is that a packet can technically be massive -- like // exabytes -- and that's still valid by the OpenPGP spec. You can't // depend on the ability to create temporary buffers to stick this stuff // in. But if you leave it in the original buffer, the sub-packets won't // know if there are "partial body length" headers jammed in the middle of // their data. // // The only proper solution is some sort of dynamic stream data structure, // but it's too late for that now. memmove() will have to do. If your // packet is gigabytes long, this is going to take a while. memmove(msg+*idx, msg+*idx+headerlen-1, *length-(*idx+headerlen-1)); *length -= headerlen-1; } // Validate decryption with PGP's MDC doo-hickey. if (memcmp(msg+startidx+blksize-2, msg+startidx+blksize, 2) != 0) { Serial.printf("Decrypted data block fails validation!\n"); RAISE(DECRYPT_FAILED); } Serial.printf("Decrypt succeeded.\n"); // At this point, msg has been decrypted in place and now contains // a bunch of packets. Since it was decoded in place, and since we're // already in the middle of a packet decode loop, we can just teleport // idx back to the beginning of the data and exit. // // Packet data starts blocksize+2 bytes above decrypted data. One block // of random data, and 2 extra bytes of verification. // // Subtract 1 because startidx is the first byte of the decrypted packet, // but the packet parser loop expects us to end on the last byte of the // previous packet. *idx = startidx + blksize + 2 - 1; return 0; } static uint8_t spgp_parse_literal_packet(uint8_t *msg, uint32_t *idx, uint32_t length, spgp_packet_t *pkt) { spgp_literal_pkt_t *literal = NULL; uint32_t date; uint32_t startidx; uint8_t format; Serial.printf("Parsing literal packet\n"); if (NULL == msg || NULL == idx || NULL == pkt || length == 0) RAISE(INVALID_ARGS); startidx = *idx; pkt->c.literal = malloc(sizeof(*(pkt->c.literal))); if (NULL == pkt->c.literal) RAISE(OUT_OF_MEMORY); memset(pkt->c.literal, 0, sizeof(*(pkt->c.literal))); literal = pkt->c.literal; // Read the format of the message. This is ignored. format = msg[*idx]; SAFE_IDX_INCREMENT(*idx, length); // Read the length byte of the fylename literal->filenameLen = msg[*idx]; SAFE_IDX_INCREMENT(*idx, length); // Read the filename literal->filename = malloc(literal->filenameLen + 1); if (NULL == literal->filename) RAISE(OUT_OF_MEMORY); memcpy(literal->filename, msg+*idx, literal->filenameLen); literal->filename[literal->filenameLen] = '\0'; *idx += literal->filenameLen - 1; SAFE_IDX_INCREMENT(*idx, length); // Read the timestamp. This is ignored. memcpy(&date, msg+*idx, sizeof(date)); *idx += 3; SAFE_IDX_INCREMENT(*idx, length); // Read the actual data in to buffer literal->dataLen = pkt->header->contentLength - (*idx - startidx); literal->data = malloc(literal->dataLen); if (NULL == literal->data) RAISE(OUT_OF_MEMORY); memcpy(literal->data, msg+*idx, literal->dataLen); *idx += literal->dataLen - 1; Serial.printf("Stored %u bytes\n", literal->dataLen); return 0; } static uint8_t spgp_parse_signature_packet(uint8_t *msg, uint32_t *idx, uint32_t length, spgp_packet_t *pkt) { spgp_signature_pkt_t *sig; spgp_literal_pkt_t *literal; gcry_md_hd_t md; uint32_t startidx, stopidx; unsigned char *hash; uint32_t totalLen; Serial.printf("Parsing signature packet\n"); if (msg == NULL || idx == NULL || pkt == NULL || 0 == length) RAISE(INVALID_ARGS); pkt->c.signature = malloc(sizeof(*(pkt->c.signature))); if (NULL == pkt->c.signature) RAISE(OUT_OF_MEMORY); memset(pkt->c.signature, 0, sizeof(*(pkt->c.signature))); sig = pkt->c.signature; startidx = *idx; sig->version = msg[*idx]; SAFE_IDX_INCREMENT(*idx, length); if (sig->version != 4) RAISE(FORMAT_UNSUPPORTED); sig->type = msg[*idx]; SAFE_IDX_INCREMENT(*idx, length); sig->asymAlgo = msg[*idx]; SAFE_IDX_INCREMENT(*idx, length); sig->hashAlgo = msg[*idx]; SAFE_IDX_INCREMENT(*idx, length); Serial.printf("Signature type 0x%X, algo 0x%X, hash 0x%X\n", sig->type, sig->asymAlgo, sig->hashAlgo); sig->hashedSubLength = ((msg[*idx] & 0xFF) << 8) | msg[*idx + 1]; *idx += 1; SAFE_IDX_INCREMENT(*idx, length); // skip hashed subpackets for now *idx += sig->hashedSubLength - 1; SAFE_IDX_INCREMENT(*idx, length); stopidx = *idx; sig->unhashedSubLength = ((msg[*idx] & 0xFF) << 8) | msg[*idx + 1]; *idx += 1; SAFE_IDX_INCREMENT(*idx, length); // skip unhashed subpackets for now *idx += sig->unhashedSubLength - 1; SAFE_IDX_INCREMENT(*idx, length); sig->hashTest = ((msg[*idx] & 0xFF) << 8) | (msg[*idx + 1] & 0xFF); *idx += 1; SAFE_IDX_INCREMENT(*idx, length); sig->mpiHead = spgp_read_mpi(msg, idx, length); if (sig->asymAlgo == ASYM_ALGO_DSA) { SAFE_IDX_INCREMENT(*idx, length); sig->mpiHead->next = spgp_read_mpi(msg, idx, length); } // All data accounted for, idx incremented to the end // We can exit cleanly any time after this point if (NULL == pkt->prev || pkt->prev->header->type != PKT_TYPE_LITERAL_DATA || NULL == pkt->prev->c.literal || NULL == pkt->prev->c.literal->data) return -1; literal = pkt->prev->c.literal; if (gcry_md_open (&md, GCRY_MD_SHA1, 0) != 0) RAISE(GCRY_ERROR); gcry_md_write (md, literal->data, literal->dataLen); gcry_md_write (md, msg+startidx, stopidx-startidx); /* They hide this shit in here because they hate us. What's really great is that the length will always be (hashedSubLength+6), and hashedSubLength is a 16-bit int, so in the worst case this final length would only be 3 bytes. Top byte in this 32-bit int will always be zero. RFC 4880 - 5.2.4 V4 signatures also hash in a final trailer of six octets: the version of the Signature packet, i.e., 0x04; 0xFF; and a four-octet, big-endian number that is the length of the hashed data from the Signature packet (note that this number does not include these final six octets).*/ totalLen = sig->hashedSubLength + 6; gcry_md_putc(md, sig->version); gcry_md_putc(md, 0xFF); gcry_md_putc(md, totalLen >> 24); gcry_md_putc(md, totalLen >> 16); gcry_md_putc(md, totalLen >> 8); gcry_md_putc(md, totalLen >> 0); gcry_md_final(md); hash = gcry_md_read(md, 0); return 0; } static spgp_packet_t *spgp_find_session_packet(spgp_packet_t *chain) { spgp_packet_t *cur; if (NULL == chain) RAISE(INVALID_ARGS); cur = chain; while (cur) { if (cur->header->type == PKT_TYPE_SESSION && cur->c.session->key != NULL) return cur; cur = cur->prev; } return NULL; } static uint8_t spgp_parse_session_packet(uint8_t *msg, uint32_t *idx, uint32_t length, spgp_packet_t *pkt) { spgp_session_pkt_t *session; spgp_packet_t *key, *chain; gcry_sexp_t sexp_key, sexp_data, sexp_result; gcry_mpi_t mpis[10], mpi_result; spgp_mpi_t *cur; uint32_t checksum, sum; int i,mpi_count; unsigned long frame_len; uint8_t *frame; Serial.printf("Parsing session packet.\n"); if (NULL == msg || NULL == idx || length == 0 || NULL == pkt) RAISE(INVALID_ARGS); // Make sure we have enough bytes remaining for parsing if (length - *idx < pkt->header->contentLength) RAISE(BUFFER_OVERFLOW); // Allocate a session packet pkt->c.session = malloc(sizeof(*(pkt->c.session))); if (NULL == pkt->c.session) RAISE(OUT_OF_MEMORY); memset(pkt->c.session, 0, sizeof(*(pkt->c.session))); session = pkt->c.session; session->version = msg[*idx]; SAFE_IDX_INCREMENT(*idx, length); Serial.printf("Version: %u\n", session->version); memcpy(session->keyid, msg+*idx, 8); *idx += 7; SAFE_IDX_INCREMENT(*idx, length); Serial.printf("Session for key ID: "); for (i = 0; i < 8; i++) Serial.printf("%.2X",session->keyid[i]); Serial.printf("\n"); session->algo = msg[*idx]; SAFE_IDX_INCREMENT(*idx, length); // Read first MPI. RSA only has one session->mpi1 = spgp_read_mpi(msg, idx, length); // Elgamal has a second MPI if (session->algo == ASYM_ALGO_ELGAMAL) { SAFE_IDX_INCREMENT(*idx, length); session->mpi2 = spgp_read_mpi(msg, idx, length); } // DONE READING FROM STREAM AT THIS POINT // BELOW HERE -- DECRYPT SESSION KEY if (!spgp_keychain_is_valid()) RAISE(KEYCHAIN_ERROR); spgp_keychain_iter_start(); while ((chain = spgp_keychain_iter_next()) != NULL) { if ((key = spgp_secret_key_matching_id(chain, session->keyid)) != NULL) { Serial.printf("Found a matching key in keychain.\n"); break; } } spgp_keychain_iter_end(); if (!key) return -1; for (cur=key->c.pub->mpiHead,i = 0; cur != NULL; cur = cur->next,i++) { gcry_mpi_scan (&(mpis[i]), GCRYMPI_FMT_PGP, cur->data, cur->count+2, NULL); } gcry_mpi_scan (&(mpis[i++]), GCRYMPI_FMT_PGP, session->mpi1->data, session->mpi1->count+2, NULL); if (session->mpi2) { gcry_mpi_scan (&(mpis[i++]), GCRYMPI_FMT_PGP, session->mpi2->data, session->mpi2->count+2, NULL); } mpi_count = i; switch (session->algo) { case ASYM_ALGO_RSA: gcry_sexp_build(&sexp_key, NULL, "(private-key(rsa(n%m)(e%m)(d%m)(p%m)(q%m)(u%m)))", mpis[0], mpis[1], mpis[2], mpis[3], mpis[4], mpis[5]); gcry_sexp_build (&sexp_data, NULL, "(enc-val(rsa(a%m)))", mpis[6]); gcry_pk_decrypt (&sexp_result, sexp_data, sexp_key); mpi_result = gcry_sexp_nth_mpi (sexp_result, 0, GCRYMPI_FMT_STD); break; case ASYM_ALGO_ELGAMAL: gcry_sexp_build(&sexp_key, NULL, "(private-key(elg(p%m)(g%m)(y%m)(x%m)))", mpis[0], mpis[1], mpis[2], mpis[3]); gcry_sexp_build (&sexp_data, NULL, "(enc-val(elg(a%m)(b%m)))", mpis[4], mpis[5]); gcry_pk_decrypt (&sexp_result, sexp_data, sexp_key); mpi_result = gcry_sexp_nth_mpi (sexp_result, 0, GCRYMPI_FMT_STD); break; default: RAISE(FORMAT_UNSUPPORTED); } if (!mpi_result) RAISE(GCRY_ERROR); gcry_mpi_print(GCRYMPI_FMT_PGP, NULL, 0, &frame_len, mpi_result); frame = malloc(frame_len); if (NULL == frame) RAISE(OUT_OF_MEMORY); gcry_mpi_print(GCRYMPI_FMT_PGP, frame, frame_len, NULL, mpi_result); if (mpi_result) {gcry_mpi_release(mpi_result);} if (sexp_key) {gcry_sexp_release(sexp_key);} if (sexp_data) {gcry_sexp_release(sexp_data);} if (sexp_result) {gcry_sexp_release(sexp_result);} for (i = 0; i < mpi_count; i++) { gcry_mpi_release(mpis[i]); } i = 2; // skip first two bytes, they're the length of the mpi if (frame[i++] != 2) RAISE(DECRYPT_FAILED); while (frame[i++] != 0 && i < frame_len) ; // Find the next 0 in frame // Algorithm is first byte after the 0 session->symAlgo = frame[i]; // Key length is determined from current index. Drop 3 bytes: 1 for // algorithm, and 2 for the checksum at the end. session->keylen = frame_len - i - 3; i++; // Actual session key is the remaining bytes, except for the last two session->key = malloc(session->keylen); if (NULL == session->key) RAISE(OUT_OF_MEMORY); if (i+session->keylen >= frame_len) RAISE(DECRYPT_FAILED); memcpy(session->key, frame+i, session->keylen); // Checksum is last two bytes in buffer checksum = frame[frame_len-2]<<8 | frame[frame_len-1]; // Verify checksum sum = 0; for (i = 0; i < session->keylen; i++) { sum = sum + (session->key[i] & 0xFF); } if (sum % 65536 != checksum) { Serial.printf("Session key checksum failed!\n"); RAISE(DECRYPT_FAILED); } free(frame); frame = NULL; Serial.printf("Decrypted session key.\n"); return 0; } /** * Find a specific secret key in a chain of packets. * * Finds a secret key in the given chain of packets, |chain|, with a key ID * matching |keyid|. KeyID is the last 8 octets of the 64-octet key * fingerprint. * * @param chain Chain of packets containing at least one secret key * @param keyid 8-octet key ID * @return Packet containing matching secret key, or NULL if not found * */ static spgp_packet_t *spgp_secret_key_matching_id(spgp_packet_t *chain, uint8_t *keyid) { spgp_packet_t *cur = NULL; if (NULL == chain || NULL == keyid) RAISE(INVALID_ARGS); cur = chain; while ((cur = spgp_next_secret_key_packet(cur)) != NULL) { if (memcmp((void*)((cur->c.pub->fingerprint)+12),keyid,8) == 0) return cur; cur = cur->next; } return NULL; } static uint8_t spgp_read_salt(uint8_t *msg, uint32_t *idx, uint32_t length, spgp_secret_pkt_t *secret) { uint8_t saltLen = 0; if (NULL == msg || NULL == idx || 0 == length || NULL == secret) RAISE(INVALID_ARGS); if ((saltLen = spgp_salt_length_for_hash_algo(secret->s2kHashAlgo)) == 0) RAISE(FORMAT_UNSUPPORTED); if (length - *idx < saltLen) RAISE(BUFFER_OVERFLOW); secret->s2kSalt = malloc(sizeof(*(secret->s2kSalt)) * saltLen); if (NULL == secret->s2kSalt) RAISE(OUT_OF_MEMORY); secret->s2kSaltLength = saltLen; memcpy(secret->s2kSalt, msg+*idx, saltLen); *idx += saltLen-1; SAFE_IDX_INCREMENT(*idx, length); return 0; } static uint8_t spgp_read_iv(uint8_t *msg, uint32_t *idx, uint32_t length, spgp_secret_pkt_t *secret) { uint8_t ivLen = 0; if (NULL == msg || NULL == idx || 0 == length || NULL == secret) RAISE(INVALID_ARGS); if ((ivLen = spgp_iv_length_for_symmetric_algo(secret->s2kEncryption)) == 0) RAISE(FORMAT_UNSUPPORTED); if (length - *idx < ivLen) RAISE(BUFFER_OVERFLOW); secret->iv = malloc(sizeof(*(secret->iv)) * ivLen); if (NULL == secret->iv) RAISE(OUT_OF_MEMORY); secret->ivLength = ivLen; memcpy(secret->iv, msg+*idx, ivLen); *idx += ivLen-1; SAFE_IDX_INCREMENT(*idx, length); return 0; }
31.298426
92
0.615918
[ "vector" ]
71db215c99c8fa22173312a5a83317579ee241fc
32,963
c
C
APM/main/esp32ai.c
ONE-Tech-Inc/MicroAI-Atom-ESP32
f23d180f3b94a29fc61bdc2578e33f06acf759d2
[ "Unlicense" ]
5
2021-02-24T17:09:13.000Z
2021-08-17T23:17:34.000Z
APM/main/esp32ai.c
ONE-Tech-Inc/MicroAI-Atom-ESP32
f23d180f3b94a29fc61bdc2578e33f06acf759d2
[ "Unlicense" ]
null
null
null
APM/main/esp32ai.c
ONE-Tech-Inc/MicroAI-Atom-ESP32
f23d180f3b94a29fc61bdc2578e33f06acf759d2
[ "Unlicense" ]
3
2021-01-14T15:44:42.000Z
2021-08-24T01:01:24.000Z
/* esp32ai.c */ #ifndef ESP32AI_C #define ESP32AI_C /* Update Log: Date Version Changes ---- ------- ------- 20Oct2020 01.00.00 Initial SDK release */ #define version_str "01.00.00" // display at power on, in the command window // -------------------------------------------------------------------------------------------- // SDK Limitations - these maximum limitations are imposed by the distributed SDK // 1. Number of Channels = 5 (set during initialization and fails if larger) // 2. Runtime = 15 days (1296000 samples at 1 sample/sec) // 3. Training Time = 60 minutes (3600 samples at 1 sample/sec) // (upon expiration, the AI engine returns 0's) // -------------------------------------------------------------------------------------------- // for CONDITIONAL COMPILE OPTIONS, see esp32ai.h) #include <stdio.h> #include <string.h> #include <sys/stat.h> #include "esp_vfs_fat.h" #include "sdmmc_cmd.h" #include <math.h> // ------- GPIO #include "driver/gpio.h" // ------- MQTT #include "nvs_flash.h" #include "protocol_examples_common.h" #include "esp_log.h" #include "mqtt_client.h" #include "driver/i2c.h" #include "AiEngine.h" #include "sensors.h" #include "mqtt.h" #include "esp32ai.h" static TaskHandle_t main_task_handle; #ifdef ENABLE_SENSORS static TaskHandle_t sensor_task_handle; #endif #ifdef MQTT_ENABLE static TaskHandle_t mqtt_task_handle; #endif static const char *TAG = "MicroAI_ESP32"; //*************************** // MicroAI variables //*************************** // MicroAI input channels typedef enum { E_AI_CH_GYRO_NOW, // 0 E_AI_CH_GYRO, // 1 E_AI_CH_TEMPERATURE, // 2 E_AI_CH_HUMIDITY, // 3 E_AI_CH_SOUND, // 4 NOF_AI_CHANNELS // 5 } ENUM_AI_CHANNELS_USED; #define TOTAL_CHANNELS NOF_AI_CHANNELS #define maxCSVRowSize 200 // csv file line size, max #define TIME_CONSTANT_L 100 #define TIME_CONSTANT_S 20 #define TIME_CONSTANT_ALRM 90 #define HEALTH_SCORE_P 90 #define DTNP 600 // default days to next planned maintenance #define NORMAL_DTN 40 // days to normal maintenance for this device sdmmc_host_t host = SDMMC_HOST_DEFAULT(); sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT(); esp_vfs_fat_sdmmc_mount_config_t mount_config = { .format_if_mount_failed = false, .max_files = 5, .allocation_unit_size = 16 * 1024}; sdmmc_card_t *card; esp_err_t ret; FILE *f; char *modelFileX = "/sdcard/modelX"; // model file X stored on SD card char *modelFileY = "/sdcard/modelY"; // model file Y stored on SD card int isBuildModel; int deleteOldModel; uint32_t u32CycleCount; // number of cycles of data through AI engine float **cfg; // pointer to config array read from SD card int alrmReport[TOTAL_CHANNELS]; // channels that currently are in alarm report condition int alrmReportNew[TOTAL_CHANNELS]; // determine which alarms are new float **ratios; float signalSource[TOTAL_CHANNELS]; float signalL[TOTAL_CHANNELS]; // long memory float signalS[TOTAL_CHANNELS]; // short memory float prevSignalSource[TOTAL_CHANNELS]; float err[TOTAL_CHANNELS]; float mean[TOTAL_CHANNELS]; float std[TOTAL_CHANNELS]; float U[TOTAL_CHANNELS]; float L[TOTAL_CHANNELS]; int alrm[TOTAL_CHANNELS]; int alrmNew[TOTAL_CHANNELS]; float alrmSum; float filteredAlrmDensity; float healthScore; float daysToNextMaint; int splitCounter; float *predict; float *X; float *Cx; float *Cy; float **Cxx; float **Cyy; int rowCx, rowCy; // NOTE: The code expects rowCx to be the same as rowCy! int colCx, colCy; int lenX; int lenY; #define MIN_MQTT_RATE_SECS 1 // used for validation when reading configuration #define MAX_MQTT_RATE_SECS 20 #define DEFAULT_MQTT_RATE_SECS 10 int mintMqttRatems; // milliseconds between MQTT transmissions SemaphoreHandle_t print_mux = NULL; SemaphoreHandle_t data_mux = NULL; SemaphoreHandle_t mqtt_mux = NULL; uint8_t mIsLearningEnabled; int mintCurrTimeMsec, mintStartTimeMsec; //use for time_span entry to send with MQTT packets int mintBeginTimeMsec, mintEndTimeMsec; // to measure time intervals #ifdef OUTPUT_METRICS // test function static void printHeapSize(); #endif static void free2D(float **array, int rows); static float **alloc2D(int m, int n); static void getRowsCols(char *fileName, int *p2Rows, int *p2Cols, char *delim, int ifPrint); static void loadMatrix(float **x, char *fileName, char *delim, int ifPrint); static void saveMatrix(float **x, char *fileName, char *delim, int *shape, int isAppend); static void set0(float *x, int len) { int i; for (i = 0; i < len; i++) { x[i] = 0.0; } } static void free2D(float **array, int rows) { int ii; for (ii=0; ii<rows; ii++) { free(array[ii]); } free(array); } static float **alloc2D(int m, int n) { /*allocation memory for the 2D array (using **); Initialize them to 0.0*/ int i, j; float **array; array = malloc(m * sizeof *array); if (array == NULL) { fprintf(stderr, "out of memory for 2D array\n"); #ifdef MICROAI_DEBUG printf("\nout of memory for 2D array-1\n"); #endif exit(0); } for (i = 0; i < m; i++) { array[i] = malloc(n * sizeof *array[i]); if (array[i] == NULL) { fprintf(stderr, "out of memory for 2D array\n"); #ifdef MICROAI_DEBUG printf("\nout of memory for 2D array-2\n"); #endif exit(0); } for (j = 0; j < n; j++) { array[i][j] = 0.0; /* printf("%d , %d ,=%f \n",i,j,array[i][j]);*/ } } return array; } static void getRowsCols(char *fileName, int *p2Rows, int *p2Cols, char *delim, int ifPrint) { /*read number of rows and columns from 2D array from a csv file (or other with different delimiters)*/ int i = 0; int j = 0; int nofRows = 0; int nofCols = 0; *p2Rows = 0; *p2Cols = 0; FILE *F; F = fopen(fileName, "r"); if (F == NULL) { printf("Cannot open the file "); printf("%s\n", fileName); exit(0); } char buf[maxCSVRowSize]; char *line, *record; char *temp = "0"; record = temp; line = fgets(buf, sizeof(buf), F); while (line != NULL) { record = strtok(line, delim); // printf("%s",line); while (record != NULL) { record = strtok(NULL, ","); j = j + 1; } if (nofCols < j) // remember the greatest column nofCols = j; i = i + 1; j = 0; line = fgets(buf, sizeof(buf), F); nofRows++; } if (ifPrint == 1) { printf("Rows: %d, Columns: %d\n", nofRows, nofCols); } *p2Rows = nofRows; *p2Cols = nofCols; if (line != NULL) { free(line); } free(record); fclose(F); } static void loadMatrix(float **x, char *fileName, char *delim, int ifPrint) { /*read 2D array from a csv file*/ int i = 0; int j = 0; FILE *F; F = fopen(fileName, "r"); if (F == NULL) { printf("Cannot open the file "); printf("%s", fileName); exit(0); } char buf[maxCSVRowSize]; char *line, *record = "0"; // initialize to prevent compiler warning line = fgets(buf, sizeof(buf), F); while (line != NULL) { record = strtok(line, delim); // printf("%s",line); while (record != NULL) { x[i][j] = atof(record); record = strtok(NULL, ","); if (ifPrint == 1) { printf("x[%d][%d] = %f\n", i, j, x[i][j]); } j = j + 1; } i = i + 1; j = 0; line = fgets(buf, sizeof(buf), F); } free(line); free(record); fclose(F); } static void saveMatrix(float **x, char *fileName, char *delim, int *shape, int isAppend) { // define a function that transfer 1d array into a csv string which is // actually 2d FILE *F; if (isAppend == 1) { F = fopen(fileName, "a"); } else { F = fopen(fileName, "w"); } int i, j; char *tmpS = malloc(sizeof *tmpS * maxCSVRowSize); for (i = 0; i < shape[0]; i++) { for (j = 0; j < shape[1]; j++) { if ((j - shape[1]) == -1) { free(tmpS); tmpS = malloc(sizeof *tmpS * maxCSVRowSize); sprintf(tmpS, "%f", x[i][j]); fputs(tmpS, F); fputs("\n", F); } else { free(tmpS); tmpS = malloc(sizeof *tmpS * maxCSVRowSize); sprintf(tmpS, "%f", x[i][j]); fputs(tmpS, F); fputc(',', F); } } } free(tmpS); fclose(F); // fputs all strings to file // add /n at the row end index // return 0; } static int f2i(float x) { return (((int)(x + 32768.5)) - 32768); } void updateDataBuffer(int ch_index, float *databuf) { databuf[E_CURRENT_VAL] = signalSource[ch_index]; databuf[E_UPPER_BOUND] = U[ch_index]; databuf[E_LOWER_BOUND] = L[ch_index]; databuf[E_URGENT_ALARM] = alrmReport[ch_index]; databuf[E_HEALTH_SCORE] = healthScore; databuf[E_DAYS_TO_MAINT] = daysToNextMaint; databuf[E_ALARM] = alrmReport[ch_index]; } #ifdef OUTPUT_METRICS static void printHeapSize() { size_t free_heap = esp_get_free_heap_size(); //xPortGetFreeHeapSize(); size_t min_free_heap = xPortGetMinimumEverFreeHeapSize(); static uint32_t prevFreeHeap = 0; xSemaphoreTake(print_mux, portMAX_DELAY); printf( "\n *** Free Heap: %d (%d), Min: %d\r\n", (int32_t)free_heap, (int32_t)(free_heap-prevFreeHeap), (int32_t)min_free_heap ); xSemaphoreGive(print_mux); prevFreeHeap = free_heap; } #endif //*************************** // SD card functions //*************************** // Initialize SD card and read files // * init SD card // - confirm card is present and writeable // - read config files and copy arrays // * set up build model, if necessary, including deleting old model static void initSDcard( void ) { #ifdef OUTPUT_MODEL_FIRST_LOOP static uint8_t isFirstLoop = true; // only output on the first loop #endif ESP_LOGI(TAG, "Initializing SD card"); ESP_LOGI(TAG, "Using SDMMC peripheral"); // To use 1-line SD mode, uncomment the following line: // slot_config.width = 1; // GPIOs 15, 2, 4, 12, 13 should have external 10k pull-ups. // Internal pull-ups are not sufficient. However, enabling internal pull-ups // does make a difference some boards, so we do that here. gpio_set_pull_mode(15, GPIO_PULLUP_ONLY); // CMD, needed in 4- and 1- line modes gpio_set_pull_mode(2, GPIO_PULLUP_ONLY); // D0, needed in 4- and 1-line modes gpio_set_pull_mode(4, GPIO_PULLUP_ONLY); // D1, needed in 4-line mode only gpio_set_pull_mode(12, GPIO_PULLUP_ONLY); // D2, needed in 4-line mode only gpio_set_pull_mode(13, GPIO_PULLUP_ONLY); // D3, needed in 4- and 1-line modes // Options for mounting the filesystem. // If format_if_mount_failed is set to true, SD card will be partitioned and // formatted in case when mounting fails. // Note: esp_vfs_fat_sdmmc_mount is an all-in-one convenience function. // Please check its source code and implement error recovery when developing // production applications. ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card); if (ret != ESP_OK) { if (ret == ESP_FAIL) { ESP_LOGE(TAG, "Failed to mount filesystem. " "If you want the card to be formatted, set " "format_if_mount_failed = true."); } else { ESP_LOGE(TAG, "Failed to initialize the card (%s). " "Make sure SD card lines have pull-up resistors in place.", esp_err_to_name(ret)); } return; } // Card has been initialized, print its properties sdmmc_card_print_info(stdout, card); // Use POSIX and C standard library functions to work with files. // First create a file. ESP_LOGI(TAG, "Opening test file"); f = fopen("/sdcard/hello.txt", "w"); if (f == NULL) { ESP_LOGE(TAG, "Failed to open file for writing"); return; } fprintf(f, "Hello %s!\n", card->cid.name); fclose(f); ESP_LOGI(TAG, "File written"); lenX = TOTAL_CHANNELS * 3; lenY = TOTAL_CHANNELS; //// load microAI cfg file; //// read cfg int i; int cols = 1; int rows = NOF_CONFIG_FILE_ENTRIES; char *srcFile = "/sdcard/cfg"; getRowsCols(srcFile, &rows, &cols, ",", 1); if (rows < NOF_CONFIG_FILE_ENTRIES) { //rows = NOF_CONFIG_FILE_ENTRIES; // minimum size to allocate ESP_LOGE(TAG, "Incorrect config file (%d out of %d entries)\n", rows, NOF_CONFIG_FILE_ENTRIES); while (1); // force stop here, else it will fail later } cfg = alloc2D(rows, cols); loadMatrix(cfg, srcFile, ",", 0); // 0 = do not print these parameters (done later after we validate them) #ifdef TEMP_FIXED_CFG_PARAMETERS printf("\nPrevious parameters:\n"); for (i = 0; i < NOF_CONFIG_FILE_ENTRIES; i++) { printf("cfg[%d][0] = %f\n", i, cfg[i][0]); } // then assign any specific parameters for test purposes cfg[E_STD_CAL_GAIN][0] = 0.5; cfg[E_MEAN_CAL_GAIN][0] = 0.6; cfg[E_SMALL_THRESHOLD][0] = 0.1; #endif //===== load sigmaRatios from algPar file char *ratioFile = "/sdcard/algPar"; getRowsCols(ratioFile, &rows, &cols, ",", 1); // determine how many rows and cols are present if (rows < TOTAL_CHANNELS) { // minimum size to allocate ESP_LOGE(TAG, "Incorrect algPar file (%d out of %d entries)\n", rows, TOTAL_CHANNELS); while (1); // force stop here, else it will fail later } ratios = alloc2D(rows, cols); loadMatrix(ratios, ratioFile, ",", 0); // 0 = do not print these parameters (done later after we validate them) #ifdef TEMP_FIXED_CFG_PARAMETERS // TEST ONLY: Adjust sigma values (hard code for testing) ratios[0][0] = 6.0; // E_AI_CH_GYRO_NOW, // 0 ratios[1][0] = 6.0; // E_AI_CH_GYRO, // 1 ratios[2][0] = 4.0; // E_AI_CH_TEMPERATURE, // 2 ratios[3][0] = 4.0; // E_AI_CH_HUMIDITY, // 3 ratios[4][0] = 8.0; // E_AI_CH_SOUND, // 4 ratios[0][1] = 6.0; // E_AI_CH_GYRO_NOW, // 0 ratios[1][1] = 6.0; // E_AI_CH_GYRO, // 1 ratios[2][1] = 6.0; // E_AI_CH_TEMPERATURE, // 2 ratios[3][1] = 6.0; // E_AI_CH_HUMIDITY, // 3 ratios[4][1] = 6.0; // E_AI_CH_SOUND, // 4 #endif //===== /**SETUP for the main task**/ isBuildModel = f2i(*cfg[E_IS_BUILD_MODEL]); #ifdef USE_BUILD_MODEL_JUMPER isBuildModel = mIsLearningEnabled; // the hardware jumper overrides this now #endif deleteOldModel = f2i(*cfg[E_IS_DELETE_OLD]); if ((deleteOldModel == 1) && (isBuildModel == 1)) { if (remove(modelFileX)) { ESP_LOGI(TAG, "File X removed"); } else { f = fopen(modelFileX, "w"); if (f == NULL) { ESP_LOGE(TAG, "Failed to open file X for writing"); } else { fputc(' ', f); fclose(f); ESP_LOGI(TAG, "File X erased"); } } if (remove(modelFileY)) { ESP_LOGI(TAG, "File Y removed"); } else { f = fopen(modelFileY, "w"); if (f == NULL) { ESP_LOGE(TAG, "Failed to open file Y for writing"); return; } else { fputc(' ', f); fclose(f); ESP_LOGI(TAG, "File Y erased"); } } } else if (isBuildModel == 0) // normal mode, so load up the model data here { getRowsCols(modelFileX, &rowCx, &colCx, ",", 0); // determine the memory allocation required getRowsCols(modelFileY, &rowCy, &colCy, ",", 0); // determine the memory allocation required if (rowCx < 5) rowCx = 5; // minimum size to allocate if (colCx < lenX) colCx = lenX; if (rowCy < 5) rowCy = 5; // minimum size to allocate if (colCy < lenY) colCy = lenY; if (rowCx < rowCy) { rowCx = rowCy; // allocate memory for the greatest size, if different ESP_LOGE(TAG, "File X has less rows than File Y"); } if (rowCy < rowCx) { rowCy = rowCx; ESP_LOGE(TAG, "File Y has less rows than File X"); } Cxx = alloc2D(rowCx, colCx); // Cxx = alloc2D(rowCxCy, lenX); lenX = TOTAL_CHANNELS * 3 Cyy = alloc2D(rowCy, colCy); // Cyy = alloc2D(rowCxCy, lenY); if (Cxx == NULL) ESP_LOGE(TAG, "Cxx is NULL (no memory allocated)"); if (Cyy == NULL) ESP_LOGE(TAG, "Cyy is NULL (no memory allocated)"); #ifdef OUTPUT_MODEL_FIRST_LOOP if (isFirstLoop == true) { loadMatrix(Cxx, "/sdcard/modelX", ",", 1); // special printout case loadMatrix(Cyy, "/sdcard/modelY", ",", 1); isFirstLoop = false; } else { loadMatrix(Cxx, "/sdcard/modelX", ",", 0); // normal case loadMatrix(Cyy, "/sdcard/modelY", ",", 0); } #else loadMatrix(Cxx, "/sdcard/modelX", ",", 0); // normal case loadMatrix(Cyy, "/sdcard/modelY", ",", 0); #endif } #ifdef OUTPUT_METRICS if (isBuildModel) printf(" *** Training Seconds = %d ***\n", (int)cfg[E_TRAINING_SECONDS][0]); #endif // Validate the config file entries mintMqttRatems = f2i(cfg[E_MQTT_SAMPLE_RATE_SECS][0]); // make this conversion one time if (mintMqttRatems < MIN_MQTT_RATE_SECS) // validate the entry mintMqttRatems = DEFAULT_MQTT_RATE_SECS; // if invalid, use the default else if (mintMqttRatems > MAX_MQTT_RATE_SECS) mintMqttRatems = DEFAULT_MQTT_RATE_SECS; cfg[E_MQTT_SAMPLE_RATE_SECS][0] = mintMqttRatems; // put back in the array for the upcoming print function mintMqttRatems *= 1000; // convert to milliseconds printf("\nConfig parameters:\n"); for (i = 0; i < NOF_CONFIG_FILE_ENTRIES; i++) { printf("cfg[%d][0] = %.3f\n", i, cfg[i][0]); } // Validate the AlgPar entries here, if desired printf("\nAlgPar:\n"); for (i = 0; i < TOTAL_CHANNELS; i++) { printf("ratios[%d] = %.1f, %.1f\n", i, ratios[i][0], ratios[i][1]); } } void initGPIO() { gpio_config_t io_conf; // inputs... //disable interrupt io_conf.intr_type = GPIO_PIN_INTR_DISABLE; //bit mask of the pins, use GPIO27 io_conf.pin_bit_mask = GPIO_INPUT_PIN_SEL; //set as input mode io_conf.mode = GPIO_MODE_INPUT; //enable pull-up mode io_conf.pull_up_en = 1; gpio_config(&io_conf); } #ifdef CALC_TASK_STATS // This example demonstrates how a human readable table of run time stats // information is generated from raw data provided by uxTaskGetSystemState(). // The human readable table is written to pcWriteBuffer void local_vTaskGetRunTimeStats( char *pcWriteBuffer ) { TaskStatus_t *pxTaskStatusArray; volatile UBaseType_t uxArraySize, x; uint32_t ulTotalRunTime; //, ulStatsAsPercentage; float fltStatsAsPercentage; // use a float to display fractional units float fltRunTimeTicks; size_t heapMin, heapNow; uint32_t ulAccumCounter; // Make sure the write buffer does not contain a string. *pcWriteBuffer = 0x00; // Take a snapshot of the number of tasks in case it changes while this // function is executing. uxArraySize = uxTaskGetNumberOfTasks(); // Allocate a TaskStatus_t structure for each task. An array could be // allocated statically at compile time. pxTaskStatusArray = pvPortMalloc( uxArraySize * sizeof( TaskStatus_t ) ); if( pxTaskStatusArray != NULL ) { // Generate raw status information about each task. uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime ); fltRunTimeTicks = (float)(ulTotalRunTime)/1000000.0; sprintf( pcWriteBuffer, "\nSecurity Metrics:\n Runtime = %.1f\n", fltRunTimeTicks); pcWriteBuffer += strlen( ( char * ) pcWriteBuffer ); // For percentage calculations. ulTotalRunTime /= 100UL; // Avoid divide by zero errors. if( ulTotalRunTime > 0 ) { // For each populated position in the pxTaskStatusArray array, // format the raw data as human readable ASCII data ulAccumCounter = 0; for( x = 0; x < uxArraySize; x++ ) { #ifdef PRINT_TASK_STATS // What percentage of the total run time has the task used? // This will always be rounded down to the nearest integer. // ulTotalRunTimeDiv100 has already been divided by 100. fltStatsAsPercentage = (float)pxTaskStatusArray[ x ].ulRunTimeCounter / (float)ulTotalRunTime; // see in fractional units if( fltStatsAsPercentage > 0.1 ) { sprintf( pcWriteBuffer, "%s\t\t%d\t\t%.2f%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, fltStatsAsPercentage ); } else { // If the percentage is zero here then the task has // consumed less than 1% of the total run time, so don't bother outputting it //sprintf( pcWriteBuffer, "%s\t\t%d\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter ); } pcWriteBuffer += strlen( ( char * ) pcWriteBuffer ); #endif // now, let's just calculate the needed metrics if ((strcasecmp(pxTaskStatusArray[ x ].pcTaskName, "MainTask") == 0) || (strcasecmp(pxTaskStatusArray[ x ].pcTaskName, "MqttTask") == 0) || (strcasecmp(pxTaskStatusArray[ x ].pcTaskName, "wifi") == 0) || (strcasecmp(pxTaskStatusArray[ x ].pcTaskName, "SoundTask") == 0) ) { ulAccumCounter += pxTaskStatusArray[ x ].ulRunTimeCounter; } } fltStatsAsPercentage = (float)ulAccumCounter / (float)ulTotalRunTime; // see in fractional units sprintf( pcWriteBuffer, " CPU = %.2f\r\n", fltStatsAsPercentage ); pcWriteBuffer += strlen( ( char * ) pcWriteBuffer ); } } // The array is no longer needed, free the memory it consumes. vPortFree( pxTaskStatusArray ); //---------------------------------- heapNow = xPortGetFreeHeapSize(); heapMin = xPortGetMinimumEverFreeHeapSize(); sprintf( pcWriteBuffer, " Heap ratio = %.5f\r\n", (float)(heapNow-heapMin)/(float)heapMin); // current value is X percent higher than minimum value pcWriteBuffer += strlen( ( char * ) pcWriteBuffer ); sprintf( pcWriteBuffer, " Processes = %d\n \n", uxArraySize ); pcWriteBuffer += strlen( ( char * ) pcWriteBuffer ); //---------------------------------- } #endif // #ifdef CALC_TASK_STATS static void main_task(void *arg) { int i; SensorChannels_t sensor_array; int intAlarmReport; uint32_t u32RuntimeSeconds; int shape[2] = {TOTAL_CHANNELS, TOTAL_CHANNELS}; char *modelFileX = "/sdcard/modelX"; char *modelFileY = "/sdcard/modelY"; #ifdef CHECK_FOR_NEW_ALARM int intAlarm; #endif #ifdef OUTPUT_AI_DATA int intTemp; #endif #ifdef OUTPUT_METRICS uint32_t ulTemp; //TickType_t xTime1, xTime2; //uint32_t ulTime1=0; #endif #ifdef CALC_TASK_STATS char charBuffer[400]; // must be cautious with the size here so we don't overrun the buffer or exceed stack size #endif // Initialize variables alrmSum = 0.0; filteredAlrmDensity = 0.0; healthScore = 100.0; daysToNextMaint = NORMAL_DTN; sensor_array.data[E_ROTATE_Z] = 0; sensor_array.data[E_ROTATE_Z_DIFF] = 0; sensor_array.data[E_TEMP] = 0; sensor_array.data[E_HUMID] = 0; sensor_array.data[E_SOUND] = 0; while (1) { #ifdef ENABLE_SENSORS if (read_sensor_data(&sensor_array) == true) // elapsed time for if(): 29-30 msec #else if (1) #endif { for (i = 0; i < TOTAL_CHANNELS; i++) { prevSignalSource[i] = signalSource[i]; // before updating the signals, save the previous } // assign the values to be processed by AI engine signalSource[E_AI_CH_GYRO_NOW] = sensor_array.data[E_ROTATE_Z]; signalSource[E_AI_CH_GYRO] = sensor_array.data[E_ROTATE_Z_DIFF]; signalSource[E_AI_CH_TEMPERATURE] = sensor_array.data[E_TEMP]; signalSource[E_AI_CH_HUMIDITY] = sensor_array.data[E_HUMID]; signalSource[E_AI_CH_SOUND] = sensor_array.data[E_SOUND]; u32RuntimeSeconds = xTaskGetTickCount()/1000; // determine the number of runtime seconds microAI_task(0, u32CycleCount, signalSource, // execution time: 1-2 msec Cxx, Cyy, rowCx, lenX, lenY, signalL, signalS, cfg, X, isBuildModel, Cx, Cy, splitCounter, predict, prevSignalSource, err, mean, std, U, L, alrm, &filteredAlrmDensity, &healthScore, &alrmSum, &daysToNextMaint, alrmReport, ratios); // test for new alarm condition, then output it via MQTT if true intAlarmReport = 0; #ifdef CHECK_FOR_NEW_ALARM intAlarm = 0; #endif for (i = 0; i < TOTAL_CHANNELS; i++) { intAlarmReport |= alrmReport[i]; if ((alrmReport[i] > 0) && (alrmReportNew[i] == 0)) // new alarm condition? (only send a message if it is new) { alrmReportNew[i] = 1; #ifdef MQTT_ENABLE #ifdef MQTT_ALERT_ENABLE send_mqtt_alert_msg(i); #endif #endif } else alrmReportNew[i] = 0; #ifdef CHECK_FOR_NEW_ALARM intAlarm |= alrm[i]; if ((alrm[i] > 0) && (alrmNew[i] == 0)) { alrmNew[i] = 1; } #endif } // check to see if it's time to save training data if ((isBuildModel == 1) && (u32CycleCount >= ((int)cfg[E_INITIAL_PERIOD][0]))) { if (u32RuntimeSeconds >= cfg[E_TRAINING_SECONDS][0]) { printf("\n *** TRAINING COMPLETE ***"); printf("\n Power Off, then train again or disable training mode \n\n"); vTaskDelay(300000 / portTICK_RATE_MS); // delay 5 minutes } else if (u32CycleCount % splitCounter == (splitCounter - 1)) { shape[0] = 1; // save every "splitCounter" number of cycles shape[1] = TOTAL_CHANNELS * 3; saveMatrix(&Cx, modelFileX, ",", shape, 1); // append model rows shape[1] = TOTAL_CHANNELS; saveMatrix(&Cy, modelFileY, ",", shape, 1); // append model rows printf("model rows ADDED \n"); } } #ifdef OUTPUT_AI_DATA // for test purposes only (does not output alarm data to the monitor) if ((intAlarmReport > 0) && (isBuildModel == 0)) { // Use this to visually see when alarms are present (not good if capturing data to be analyzed) ESP_LOGW(TAG, "Alarm REPORT: %d, %d, %d, %d, %d", alrmReport[0],alrmReport[1],alrmReport[2],alrmReport[3],alrmReport[4]); } intTemp = xTaskGetTickCount(); if (u32CycleCount == 0) printf("count,U_0,L_0,R_0,Time_0,Alrm_0,U_1,L_1,R_1,Time_1,Alrm_1,U_2,L_2,R_2,Time_2,Alrm_2,U_3,L_3,R_3,Time_3,Alrm_3,U_4,L_4,R_4,Time_4,Alrm_4 \n"); // version 2 printf("%3d", u32CycleCount); for (i=0; i< TOTAL_CHANNELS; i++) { #ifdef CHECK_FOR_NEW_ALARM printf(", %8.3f, %8.3f, %8.3f, %7.2f, %d", U[i], L[i], signalSource[i], ((float)intTemp)/1000, alrm[i] ); #else printf(", %8.3f, %8.3f, %8.3f, %7.2f, %d", U[i], L[i], signalSource[i], ((float)intTemp)/1000, alrmReport[i] ); #endif } printf("\n"); #endif // #ifdef OUTPUT_AI_DATA #ifdef MQTT_ALERT_ENABLE if ((intAlarmReport > 0) && (isBuildModel == 0)) { // Use this to visually see when alarms are present ESP_LOGW(TAG, "Alarm: %d, %d, %d, %d, %d", alrmReport[0],alrmReport[1],alrmReport[2],alrmReport[3],alrmReport[4]); for (i = 0; i < TOTAL_CHANNELS; i++) { printf(" %f ", signalSource[i]); } printf(" =R=\n"); for (i = 0; i < TOTAL_CHANNELS; i++) { printf(" %f ", U[i]); } printf(" =U=\n"); for (i = 0; i < TOTAL_CHANNELS; i++) { printf(" %f ", L[i]); } printf(" =L=\n\n"); } #endif // #ifdef MQTT_ALERT_ENABLE u32CycleCount++; } else { ESP_LOGE(TAG, "*** Read Sensor FAILED ***"); } #ifdef OUTPUT_METRICS mintCurrTimeMsec = xTaskGetTickCount(); printf("\n *** Elapsed Sec's: %.1f \n", (float)(mintCurrTimeMsec-mintStartTimeMsec)/1000); //xTime1 = main_task_handle.ulRunTimeCounter; //xTime2 = xTaskGetTickCount(); //ulTime1 = esp_timer_impl_get_time; //ESP_LOGI(TAG, " *** Elapsed Ticks: %d, Stack: %d\n", xTime2-xTime1, ulTime1); ulTemp = uxTaskGetStackHighWaterMark(main_task_handle); ESP_LOGI(TAG, " *** Min Stack level: %d", ulTemp); printHeapSize(); #endif #ifdef CALC_TASK_STATS local_vTaskGetRunTimeStats(charBuffer); // CAUTION: buffer size must be sufficient to hold all printable task info xSemaphoreTake(print_mux, portMAX_DELAY); printf( charBuffer); xSemaphoreGive(print_mux); #endif vTaskDelay(MAIN_TASK_LOOP_DELAY_MS / portTICK_RATE_MS); // see esp32ai.h for the current delay, in msec } // while (1) vSemaphoreDelete(print_mux); vSemaphoreDelete(data_mux); vSemaphoreDelete(mqtt_mux); free2D(Cyy, rowCy); free2D(Cxx, rowCx); vTaskDelete(NULL); } void app_main() { //***************************************** // Set up GPIO and show results //***************************************** // set up to look for enabled MQTT output and MicroAI Learning (via jumper wires) initGPIO(); if (gpio_get_level(GPIO_IS_MQTT_ENABLED) == 1) { printf("\n *** MQTT output ON\n\n"); } else { #ifdef MQTT_ENABLE // no need to show this if we are always disabled printf("\n *** MQTT output Off (remove jumper from IO27 to enable)\n\n"); #endif } #ifdef USE_BUILD_MODEL_JUMPER // this overrides the config file flag if (gpio_get_level(GPIO_LEARNING_DISABLED) == 0) { // Test a 2nd time before setting this active if (gpio_get_level(GPIO_LEARNING_DISABLED) == 0) { printf(" *** Learn Mode: ON\n\n"); mIsLearningEnabled = true; vTaskDelay(5000); } } else { printf(" *** Learn Mode: Off (connect jumper from GND to IO26 to enable, then reboot)\n\n"); mIsLearningEnabled = false; } #endif mintStartTimeMsec = xTaskGetTickCount(); //***************************************** // Set up ADC for measuring sound //***************************************** initADC(); //***************************************** // Set up configuration //***************************************** initSDcard(); // confirm SD card access, read config files (also uses mIsLearningEnabled) //***************************************** // Set up MicroAI function //***************************************** if (initAI( TIME_CONSTANT_L, TIME_CONSTANT_S, TIME_CONSTANT_ALRM, HEALTH_SCORE_P, DTNP, NORMAL_DTN, TOTAL_CHANNELS) == 0) { printf("\n\n\n *** AI init failed *** \n\n\n"); vTaskDelay(5000); } X = malloc(sizeof *X * (3 * TOTAL_CHANNELS)); Cx = malloc(sizeof *X * (3 * TOTAL_CHANNELS)); Cy = malloc(sizeof *X * (TOTAL_CHANNELS)); splitCounter = f2i(cfg[E_SPLIT_COUNTER][0]); predict = malloc(sizeof *predict * (TOTAL_CHANNELS)); set0(X, TOTAL_CHANNELS * 3); set0(Cx, TOTAL_CHANNELS * 3); set0(Cy, TOTAL_CHANNELS); set0(predict, TOTAL_CHANNELS); set0(err, TOTAL_CHANNELS); set0(mean, TOTAL_CHANNELS); set0(std, TOTAL_CHANNELS); set0(U, TOTAL_CHANNELS); set0(L, TOTAL_CHANNELS); for (int ii = 0; ii < TOTAL_CHANNELS; ii++) { std[ii] = 0; alrm[ii] = 0; alrmReport[ii] = 0; alrmReportNew[ii] = 0; } //***************************************** // Set up MQTT //***************************************** #ifdef MQTT_ENABLE initMqtt(mintMqttRatems); #endif //MQTT_ENABLE //***************************************** // Then set up the rest //***************************************** print_mux = xSemaphoreCreateMutex(); // mutex for sharing printing between 2 tasks data_mux = xSemaphoreCreateMutex(); mqtt_mux = xSemaphoreCreateMutex(); #ifdef ENABLE_SENSORS ESP_ERROR_CHECK(i2c_master_init()); // init the master I2C port i2c_init_gyro_accel(I2C_MASTER_NUM); // init the gyro/accelerometer #endif #ifdef OUTPUT_METRICS printHeapSize(); #endif //***************************************** // show current version //***************************************** printf("\n\n **********************\n"); printf( " *\n"); printf( " * ESP32 SDK\n"); printf( " * Version: %s\n", version_str); printf( " *\n"); printf( " * MicroAI Engine\n"); printf( " * Version: %s\n", GetAiEngLibVersion()); printf( " *\n"); printf( " ********************** \n\n\n"); //***************************************** // Then start the tasks //***************************************** //xTaskCreate(function, task name, stack size, params, priority (0=lowest), handle); xTaskCreate(main_task, "MainTask", 2048 * 2, (void *)0, 10, &main_task_handle); #ifdef ENABLE_SENSORS xTaskCreate(sound_sensor_task, "SoundTask", 1024 * 2, (void *)1, 10, &sensor_task_handle); #endif //ENABLE_SENSORS #ifdef MQTT_ENABLE xTaskCreate(mqtt_task, "MqttTask", 2048 * 2, (void *)2, 10, &mqtt_task_handle); #endif //MQTT_ENABLE } #endif // #ifndef MICROAI_C
30.72041
168
0.613294
[ "shape", "model", "3d" ]
71e48cf5ca7db2763ece09ab32ff34befe0aed8a
1,303
h
C
FloatingSandbox/NewVersionDisplayDialog.h
sjohal21/Floating-Sandbox
0170e3696ed4f012f5f17fdbbdaef1af4117f495
[ "CC-BY-4.0" ]
44
2018-07-08T16:44:53.000Z
2022-02-06T14:07:30.000Z
FloatingSandbox/NewVersionDisplayDialog.h
sjohal21/Floating-Sandbox
0170e3696ed4f012f5f17fdbbdaef1af4117f495
[ "CC-BY-4.0" ]
31
2019-03-24T16:00:38.000Z
2022-02-24T20:23:18.000Z
FloatingSandbox/NewVersionDisplayDialog.h
sjohal21/Floating-Sandbox
0170e3696ed4f012f5f17fdbbdaef1af4117f495
[ "CC-BY-4.0" ]
24
2018-11-08T21:58:53.000Z
2022-01-12T12:04:42.000Z
/*************************************************************************************** * Original Author: Gabriele Giuseppini * Created: 2019-06-02 * Copyright: Gabriele Giuseppini (https://github.com/GabrieleGiuseppini) ***************************************************************************************/ #pragma once #include "UIPreferencesManager.h" #include <GameCore/Version.h> #include <wx/dialog.h> #include <wx/wxhtml.h> #include <memory> #include <string> #include <vector> class NewVersionDisplayDialog : public wxDialog { public: NewVersionDisplayDialog( wxWindow* parent, Version const & version, std::vector<std::vector<std::string>> const & features, UIPreferencesManager * uiPreferencesManager); // Only if at startup virtual ~NewVersionDisplayDialog(); private: static std::string MakeHtml( Version const & version, std::vector<std::vector<std::string>> const & features); void OnGoToDownloadPageButtonClicked(wxCommandEvent & event); void OnDoNotNotifyAboutThisVersionAgainCheckboxChanged(wxCommandEvent & event); void OnDoNotCheckForUpdatesAtStartupCheckboxChanged(wxCommandEvent & event); private: Version const mVersion; UIPreferencesManager * const mUIPreferencesManager; };
27.145833
88
0.632387
[ "vector" ]
71f68004002c6a6c6ecaa0f3a0a4e0412f83a35a
393
h
C
ArchieverL/BinaryFile.h
LazyPanda07/Archiver
4904982fe1414d5a1b5e1a2398eb3948804367bf
[ "Unlicense" ]
null
null
null
ArchieverL/BinaryFile.h
LazyPanda07/Archiver
4904982fe1414d5a1b5e1a2398eb3948804367bf
[ "Unlicense" ]
null
null
null
ArchieverL/BinaryFile.h
LazyPanda07/Archiver
4904982fe1414d5a1b5e1a2398eb3948804367bf
[ "Unlicense" ]
null
null
null
#pragma once #include <string> #include <vector> #include "../Utility/SynchronizationHelper.h" namespace BinaryFile { void encodeBinaryFile(const std::vector<std::pair<std::wstring, std::vector<std::wstring>>>& binaryFileNameIn, const std::wstring& binaryFileNameOut,utility::SynchronizationHelper* synchronization = nullptr); void decodeBinaryFile(const std::wstring& binaryFileName); }
30.230769
209
0.783715
[ "vector" ]
71f85b426c6f67b791991978665cbf3b3fe876f7
1,280
h
C
cpp-course/lru-cache-with-buddy-allocator/include/pool.h
LatypovIR/itmo-training-courses
71044b59225454e55dd3abe7ac08665ad910739b
[ "MIT" ]
2
2021-11-05T02:54:48.000Z
2021-11-05T07:26:30.000Z
cpp-course/lru-cache-with-buddy-allocator/include/pool.h
LatypovIR/itmo-training-courses
71044b59225454e55dd3abe7ac08665ad910739b
[ "MIT" ]
1
2021-11-18T21:24:08.000Z
2021-11-18T21:24:08.000Z
cpp-course/lru-cache-with-buddy-allocator/include/pool.h
LatypovIR/itmo-training-courses
71044b59225454e55dd3abe7ac08665ad910739b
[ "MIT" ]
1
2021-11-18T21:22:32.000Z
2021-11-18T21:22:32.000Z
#pragma once #include <cmath> #include <list> #include <vector> class PoolAllocator { public: PoolAllocator(unsigned, unsigned); void * allocate(size_t); void deallocate(const void *); private: using Pointer = size_t; using Link = std::list<Pointer>::iterator; using Pool = std::vector<std::byte>; struct Block { size_t size; Link iterator; Block(); Block(size_t, const Link &); }; class BlocksList { public: BlocksList(size_t, size_t); void reset(Pointer); Block & operator[](size_t); private: const Block MARKED = Block(); const size_t unit_size; std::vector<Block> blocks; }; class EmptyBlocksList { public: EmptyBlocksList(size_t, size_t); std::list<Pointer> & operator[](size_t); size_t size(); private: size_t unit_size; std::vector<std::list<Pointer>> avail; }; size_t unit_size; Pool pool; EmptyBlocksList avail; BlocksList blocks; static size_t get_level(size_t); void push_empty(size_t, Pointer); Pointer pop_empty(size_t); Pointer split(size_t, Pointer, size_t); void reset(Pointer); void deallocate(Pointer, size_t); };
19.393939
48
0.605469
[ "vector" ]
71fe6c2861d6d4a7c86b3d20c32139f15105cdb8
1,556
h
C
gst/inference_elements/model_proc/model_proc_parser_v1.h
MisterArslan/dlstreamer_gst
ff6d0bc138f372bb988baf368af4a3693b808e16
[ "MIT" ]
125
2020-09-18T10:50:27.000Z
2022-02-10T06:20:59.000Z
gst/inference_elements/model_proc/model_proc_parser_v1.h
MisterArslan/dlstreamer_gst
ff6d0bc138f372bb988baf368af4a3693b808e16
[ "MIT" ]
155
2020-09-10T23:32:29.000Z
2022-02-05T07:10:26.000Z
gst/inference_elements/model_proc/model_proc_parser_v1.h
MisterArslan/dlstreamer_gst
ff6d0bc138f372bb988baf368af4a3693b808e16
[ "MIT" ]
41
2020-09-15T08:49:17.000Z
2022-01-24T10:39:36.000Z
/******************************************************************************* * Copyright (C) 2020-2021 Intel Corporation * * SPDX-License-Identifier: MIT ******************************************************************************/ #pragma once #include "model_proc_parser.h" class ModelProcParserV1 : public ModelProcParser { public: std::vector<ModelInputProcessorInfo::Ptr> parseInputPreproc(const nlohmann::json &input_preproc) final { std::vector<ModelInputProcessorInfo::Ptr> preproc_desc; preproc_desc.reserve(input_preproc.size()); for (const auto &proc_item : input_preproc) { ModelInputProcessorInfo::Ptr preprocessor = std::make_shared<ModelInputProcessorInfo>(); preprocessor->layer_name = proc_item.value("layer_name", std::string("UNKNOWN")); preprocessor->format = proc_item.value("format", std::string("image")); preprocessor->params = gst_structure_new_empty("params"); for (json::const_iterator it = proc_item.begin(); it != proc_item.end(); ++it) { std::string key = it.key(); if (key == "layer_name" || key == "format") continue; auto value = it.value(); GValue gvalue = JsonReader::convertToGValue(value); gst_structure_set_value(preprocessor->params, key.data(), &gvalue); g_value_unset(&gvalue); } preproc_desc.push_back(preprocessor); } return preproc_desc; } };
37.95122
108
0.556555
[ "vector" ]
9c0247fddb0e3b67d2ea64c7be87402118dba855
7,710
c
C
components/nanokernel/timer/lw/fx_timer_internal.c
cbuilder/fxrtos-lite
ada55a8693e29e1c04dd5aaba2b18ef90f9eafd7
[ "BSD-3-Clause" ]
16
2020-06-26T21:54:54.000Z
2022-03-05T12:19:06.000Z
components/nanokernel/timer/lw/fx_timer_internal.c
cbuilder/fxrtos-lite
ada55a8693e29e1c04dd5aaba2b18ef90f9eafd7
[ "BSD-3-Clause" ]
null
null
null
components/nanokernel/timer/lw/fx_timer_internal.c
cbuilder/fxrtos-lite
ada55a8693e29e1c04dd5aaba2b18ef90f9eafd7
[ "BSD-3-Clause" ]
6
2020-07-08T04:46:38.000Z
2022-03-07T06:33:16.000Z
/** ****************************************************************************** * @file fx_timer.h * @brief Lightweight implementation of uniprocessor timers. * Timers are in queue sorted by deadline. ****************************************************************************** * Copyright (C) JSC EREMEX, 2008-2020. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ #include FX_INTERFACE(FX_TIMER_INTERNAL) #include FX_INTERFACE(TRACE_CORE) #include FX_INTERFACE(FX_DBG) #include FX_INTERFACE(FX_SPL) #include FX_INTERFACE(HAL_MP) FX_METADATA(({ implementation: [FX_TIMER_INTERNAL, SIMPLE] })) // // Simple timers may only be used with unified sync scheme on single-CPU systems // lang_static_assert(FX_SPL_SCHED_LEVEL == SPL_SYNC); lang_static_assert(HAL_MP_CPU_MAX == 1); static rtl_list_t fx_timer_internal_timers; static volatile uint32_t fx_timer_internal_ticks = 0; //! //! Timer module initialization. //! @remark SPL = SYNC //! void fx_timer_ctor(void) { rtl_list_init(&(fx_timer_internal_timers)); } //! //! Read tick counter. //! Since tick counter is 32-bit, reads may not be atomic on 16-bit CPUs, so, //! read counter with interrupts disabled. //! @return current value of tick counter. //! uint32_t fx_timer_get_tick_count(void) { uint32_t ticks; fx_lock_intr_state_t state; fx_spl_raise_to_sync_from_any(&state); ticks = fx_timer_internal_ticks; fx_spl_lower_to_any_from_sync(state); return ticks; } //! //! Sets tick counter. //! Since tick counter is 32-bit, writes may not be atomic on 16-bit CPUs, so, //! set counter with interrupts disabled. //! @return Old value of tick counter. //! uint32_t fx_timer_set_tick_count(uint32_t newticks) { uint32_t ticks; fx_lock_intr_state_t state; fx_spl_raise_to_sync_from_any(&state); ticks = fx_timer_internal_ticks; fx_timer_internal_ticks = newticks; fx_spl_lower_to_any_from_sync(state); return ticks; } //! //! Timer constructor. //! Initializes timer object. //! @param [in,out] timer Timer object to be initialized (allocated by user). //! @param [in] func Callback function. //! @param [in] arg Callback argument. //! @return FX_TIMER_OK if succeeded, error code otherwise. //! int fx_timer_internal_init(fx_timer_internal_t* timer, int (*fn)(void*), void* arg) { timer->callback = fn; timer->callback_arg = arg; return FX_TIMER_OK; } //! //! Cancels timer. //! If timer was inactive, no actions will be performed. //! @param [in] timer Timer object to be cancelled. //! @return FX_TIMER_OK in case of success, error code otherwise. //! int fx_timer_internal_cancel(fx_timer_internal_t* timer) { int error = FX_TIMER_ALREADY_CANCELLED; fx_lock_intr_state_t state; fx_spl_raise_to_sync_from_any(&state); if (rtl_list_is_node_linked(&timer->link)) { rtl_list_remove(&timer->link); error = FX_TIMER_OK; } fx_spl_lower_to_any_from_sync(state); return error; } // // Helper function for timer insertion. It has O(n) latency. // static void _fx_timer_insert(fx_timer_internal_t* timer) { rtl_list_t* head = &(fx_timer_internal_timers); rtl_list_t* n = NULL; for (n = rtl_list_first(head); n != head; n = rtl_list_next(n)) { fx_timer_internal_t* t = rtl_list_entry(n, fx_timer_internal_t, link); if (fx_timer_time_after(t->timeout, timer->timeout)) { break; } } rtl_list_insert(rtl_list_prev(n), &timer->link); } //! //! Sets timeout for timer with specified absolute tick value. //! @param [in] timer Timer object to be armed. //! @param [in] delay Absolute timeout value in ticks. //! @param [in] period Period for periodic timers. 0 for one-shot timers. //! @return FX_TIMER_OK in case of success, error code otherwise. //! int fx_timer_internal_set_abs( fx_timer_internal_t* timer, uint32_t delay, uint32_t period) { fx_lock_intr_state_t state; fx_spl_raise_to_sync_from_any(&state); if (rtl_list_is_node_linked(&timer->link)) { rtl_list_remove(&timer->link); } timer->timeout = delay; timer->period = period; _fx_timer_insert(timer); fx_spl_lower_to_any_from_sync(state); return FX_TIMER_OK; } //! //! Sets timeout for timer with specified relative tick value. //! @param [in] timer Timer object to be armed. //! @param [in] delay Relative timeout value in ticks. //! @param [in] period Period for periodic timers. 0 for one-shot timers. //! @return FX_TIMER_OK in case of success, error code otherwise. //! int fx_timer_internal_set_rel( fx_timer_internal_t* timer, uint32_t delay, uint32_t period) { uint32_t ticks; fx_lock_intr_state_t state; fx_spl_raise_to_sync_from_any(&state); ticks = fx_timer_internal_ticks; fx_spl_lower_to_any_from_sync(state); return fx_timer_internal_set_abs(timer, ticks + delay, period); } //! //! Tick handler is called by the HAL. //! void fx_tick_handler(void) { rtl_list_t* list = &(fx_timer_internal_timers); fx_lock_intr_state_t state; fx_spl_raise_to_sync_from_any(&state); ++fx_timer_internal_ticks; trace_increment_tick(fx_timer_internal_ticks); while (!rtl_list_empty(list)) { fx_timer_internal_t* item = rtl_list_entry( rtl_list_first(list), fx_timer_internal_t, link ); if (!fx_timer_time_after_or_eq(fx_timer_internal_ticks, item->timeout)) { break; } rtl_list_remove(&item->link); if (item->period) { item->timeout += item->period; _fx_timer_insert(item); } fx_spl_lower_to_any_from_sync(state); (item->callback)(item->callback_arg); fx_spl_raise_to_sync_from_any(&state); } fx_spl_lower_to_any_from_sync(state); }
31.859504
81
0.663294
[ "object" ]
9c10ede49a2e58955059895bc016ca372c198f47
9,538
c
C
0105_rubypython/rubymodule.c
eto/study
95f506569657c174bf2347b5240768fafedaa285
[ "BSD-3-Clause" ]
null
null
null
0105_rubypython/rubymodule.c
eto/study
95f506569657c174bf2347b5240768fafedaa285
[ "BSD-3-Clause" ]
null
null
null
0105_rubypython/rubymodule.c
eto/study
95f506569657c174bf2347b5240768fafedaa285
[ "BSD-3-Clause" ]
null
null
null
/* * rubymodule.c * * Copyright (C) 1999 Masaki Fukushima * * implements 'ruby' module for Python. */ #include "ruby-python.h" typedef struct RbObject { PyObject_HEAD VALUE value; struct RbObject *prev; struct RbObject *next; } RbObject; VALUE RbObject_GetValue(self) PyObject *self; { if (!RbObject_Check(self)) rb_bug("not RbObject"); return ((RbObject *)self)->value; } /* * Implementation of RbObject. */ static PyObject *RbMethod_New(RbObject *, ID); static RbObject object_list; PyObject * RbObject_New(value) VALUE value; { RbObject *self; self = PyObject_NEW(RbObject, &RbObject_Type); if (self == NULL) return NULL; self->value = value; self->prev = object_list.prev; self->next = &object_list; object_list.prev->next = self; object_list.prev = self; return (PyObject *)self; } static void RbObject_dealloc(self) RbObject *self; { self->prev->next = self->next; self->next->prev = self->prev; PyMem_DEL(self); } static int RbObject_print(self, fp, flags) RbObject *self; FILE *fp; int flags; { fprintf(fp, RSTRING(rb_obj_as_string(self->value))->ptr); return 0; } static PyObject * RbObject_repr(self) RbObject *self; { VALUE s = rb_inspect(self->value); return PyString_FromStringAndSize(RSTRING(s)->ptr, RSTRING(s)->len); } static int RbObject_compare(self, other) RbObject *self; PyObject *other; { VALUE v; v = rb_funcall(self->value, rb_intern("<=>"), 1, py2rb(other)); return FIX2INT(v); } static PyObject * RbObject_insert(self, args) RbObject *self; PyObject *args; { PyObject *item; int index; VALUE ret; if (!PyArg_ParseTuple(args, "iO", &index, &item)) return NULL; ret = rb_funcall(self->value, rb_intern("[]="), 3, INT2NUM(index), INT2FIX(0), py2rb(item)); return rb2py(ret); } static PyMethodDef RbObject_methods[] = { {"insert", (PyCFunction)RbObject_insert, 1}, {NULL, NULL} /* sentinel */ }; static PyObject * RbObject_getattr(self, name) RbObject *self; char *name; { PyObject *m; int id; m = Py_FindMethod(RbObject_methods, (PyObject *)self, name); if (m != NULL) return m; PyErr_Clear(); id = rb_intern(name); if ((TYPE(self->value) == T_MODULE || TYPE(self->value) == T_CLASS) && rb_is_const_id(id)) { return rb2py(rb_const_get_at(self->value, id)); } if (!rb_respond_to(self->value, id)) { /* add '?' and check again */ int len = strlen(name) + 2; char *name2 = ALLOCA_N(char, len); strcpy(name2, name); name2[len-2] = '?'; name2[len-1] = '\0'; id = rb_intern(name2); if (!rb_respond_to(self->value, id)) { char buf[BUFSIZ]; snprintf(buf, BUFSIZ, "undefined method `%s' for %s", name, RSTRING(rb_inspect(self->value))->ptr); PyErr_SetString(PyExc_AttributeError, buf); return NULL; } } return RbMethod_New(self, id); } static int RbObject_setattr(self, name, v) RbObject *self; char *name; PyObject *v; { return 0; } static int RbObject_length(self) RbObject *self; { return NUM2INT(rb_funcall(self->value, rb_intern("length"), 0)); } static PyObject * RbObject_item(self, index) RbObject *self; int index; { VALUE v; int len; len = NUM2INT(rb_funcall(self->value, rb_intern("length"), 0)); if (index < 0 || index >= len) { PyErr_SetString(PyExc_IndexError, "index out of range"); return NULL; } v = rb_funcall(self->value, rb_intern("[]"), 1, INT2NUM(index)); return rb2py(v); } static PyObject * RbObject_slice(self, i1, i2) RbObject *self; int i1, i2; { VALUE v; v = rb_funcall(self->value, rb_intern("[]"), 2, INT2NUM(i1), INT2NUM(i2-i1)); return rb2py(v); } static PyObject * RbObject_ass_item(self, index, val) RbObject *self; int index; PyObject *val; { VALUE v; v = rb_funcall(self->value, rb_intern("[]="), 2, INT2NUM(index), py2rb(val)); return rb2py(v); } static PyObject * RbObject_subscript(self, key) RbObject *self; PyObject *key; { return rb2py(rb_funcall(self->value, rb_intern("[]"), 1, py2rb(key))); } static int RbObject_ass_sub(self, key, val) RbObject *self; PyObject *key, *val; { VALUE rval; PyObject *ret; if (val == NULL) rval = Qnil; else rval = py2rb(val); ret = rb2py(rb_funcall(self->value, rb_intern("[]="), 2, py2rb(key), rval)); Py_DECREF(ret); return 0; } static void pytuple2rbarg(tuple, argc, argv) PyObject *tuple; int argc; VALUE *argv; { int i; for (i = 0; i < argc; i++) argv[0] = py2rb(PyTuple_GET_ITEM(tuple, i)); } static PyObject * RbObject_call(self, arg, kw) RbObject *self; PyObject *arg, *kw; { VALUE *argv, ret; int argc; argc = PyTuple_Size(arg); argv = ALLOCA_N(VALUE, argc); pytuple2rbarg(arg, argc, argv); ret = rb_funcall2(self->value, rb_intern("call"), argc, argv); return rb2py(ret); } static PySequenceMethods rbobject_as_sequence = { (inquiry)RbObject_length, /*sq_length*/ (binaryfunc)NULL, /*sq_concat*/ (intargfunc)NULL, /*sq_repeat*/ (intargfunc)RbObject_item, /*sq_item*/ (intintargfunc)RbObject_slice, /*sq_slice*/ (intobjargproc)RbObject_ass_item, /*sq_ass_item*/ (intintobjargproc)NULL, /*sq_ass_slice*/ }; static PyMappingMethods rbobject_as_mapping = { (inquiry)RbObject_length, /*mp_length*/ (binaryfunc)RbObject_subscript, /*mp_subscript*/ (objobjargproc)RbObject_ass_sub, /*mp_ass_subscript*/ }; PyTypeObject RbObject_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /*ob_size*/ "ruby object", /*tp_name*/ sizeof(RbObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor)RbObject_dealloc, /*tp_dealloc*/ (printfunc)RbObject_print, /*tp_print*/ (getattrfunc)RbObject_getattr, /*tp_getattr*/ (setattrfunc)RbObject_setattr, /*tp_setattr*/ (cmpfunc)RbObject_compare, /*tp_compare*/ (reprfunc)RbObject_repr, /*tp_repr*/ 0, /*tp_as_number*/ &rbobject_as_sequence, /*tp_as_sequence*/ &rbobject_as_mapping, /*tp_as_mapping*/ 0, /*tp_hash*/ (ternaryfunc)RbObject_call, /*tp_call*/ }; /* * Ruby method object. */ typedef struct RbMethod { PyObject_HEAD RbObject *self; ID id; } RbMethod; static RbMethod *meth_free_list = NULL; static PyTypeObject RbMethod_Type; static PyObject * RbMethod_New(self, id) RbObject *self; ID id; { RbMethod *meth; if (meth_free_list == NULL) { meth = PyObject_NEW(RbMethod, &RbMethod_Type); if (meth == NULL) return NULL; } else { meth = meth_free_list; meth_free_list = (RbMethod *)meth->self; meth->ob_type = &RbMethod_Type; _Py_NewReference((PyObject *)meth); } Py_INCREF(self); meth->self = self; meth->id = id; return (PyObject *)meth; } static void RbMethod_dealloc(meth) RbMethod *meth; { Py_DECREF(meth->self); meth->self = (RbObject *)meth_free_list; meth_free_list = meth; } static PyObject * RbMethod_Call(meth, arg, kw) RbMethod *meth; PyObject *arg, *kw; { VALUE *argv, ret; int argc; argc = PyTuple_Size(arg); argv = ALLOCA_N(VALUE, argc); pytuple2rbarg(arg, argc, argv); ret = rb_funcall2(meth->self->value, meth->id, argc, argv); return rb2py(ret); } static PyTypeObject RbMethod_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /*ob_size*/ "ruby method", /*tp_name*/ sizeof(RbMethod), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor)RbMethod_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ (ternaryfunc)RbMethod_Call, /*tp_call*/ }; /* * Module "ruby" */ /* List of functions defined in ruby module */ static PyMethodDef Rb_methods[] = { {NULL, NULL} /* sentinel */ }; /* * For Ruby GC, all RbObject and RbMethod is maintained in a linked-list. */ static void mark_all_rbobjects(dummy) PyObject *dummy; { RbObject *rbobj; #if DEBUG RbMethod *rbmeth; int c = 0; #endif /* mark objects referenced from Python */ rbobj = object_list.next; while (rbobj != &object_list) { rb_gc_mark(rbobj->value); rbobj = rbobj->next; #if DEBUG c++; #endif } #if DEBUG fprintf(stderr, "[%d,", c); c = 0; rbmeth = (RbMethod *)meth_free_list; while (rbmeth != NULL) { c++; rbmeth = (RbMethod *)rbmeth->self; } fprintf(stderr, "%d]", c); fflush(stderr); #endif } static VALUE dummy_value; void initruby() { PyObject *m, *d; VALUE dummy_class, top_self, cRbMethod; /* setup lists */ object_list.value = Qnil; object_list.next = &object_list; object_list.prev = &object_list; /* dummy ruby global variable */ dummy_class = rb_define_class_id(rb_intern("DummyClass"), rb_cObject); dummy_value = Data_Wrap_Struct(dummy_class, mark_all_rbobjects, 0, NULL); rb_global_variable(&dummy_value); /* Create the module and add the functions */ m = Py_InitModule("ruby", Rb_methods); PyDict_SetItemString(pdMainDict, "ruby", m); d = PyModule_GetDict(m); PyDict_SetItemString(d, "Object", (PyObject *)&RbObject_Type); PyDict_SetItemString(d, "Method", (PyObject *)&RbMethod_Type); }
21.242762
74
0.635039
[ "object" ]
9c21f1fd299dbad5e12e2be2f308622f798eff90
4,968
h
C
openikcape/activityProperties.h
Nukleon84/openikcape
7612a7c68237920373c11f137130d74f7ad134eb
[ "MIT" ]
19
2020-09-08T07:23:10.000Z
2022-01-10T19:12:51.000Z
openikcape/activityProperties.h
Nukleon84/openikcape
7612a7c68237920373c11f137130d74f7ad134eb
[ "MIT" ]
null
null
null
openikcape/activityProperties.h
Nukleon84/openikcape
7612a7c68237920373c11f137130d74f7ad134eb
[ "MIT" ]
2
2020-09-09T15:10:39.000Z
2021-08-05T00:53:28.000Z
#pragma once #include <string> #include <vector> #include <stdexcept> #include <math.h> #include <map> #include <Eigen/Dense> #include <autodiff/forward.hpp> #include <autodiff/forward/eigen.hpp> #include "uom.h" #include "thermodynamics.h" using namespace std; namespace Thermodynamics { namespace Types { template <typename Scalar, typename Array> struct ActivityPropertiesBase { Scalar Hex; Scalar Gex; Array gamma; Array lngamma; }; template <typename Scalar, typename Array> struct ActivityArgumentsBase { Scalar T; Scalar P; Array x; }; template <typename Scalar, typename Array> struct FugacityPropertiesBase { Scalar Hex; Scalar Gex; Array phi; Array lnphi; }; template <typename Scalar, typename Array> struct FugacityArgumentsBase { Scalar T; Scalar P; Array y; }; template <typename Scalar, typename Array> struct EquilibriumPropertiesBase { Scalar T; Scalar P; Scalar vf; Array z; Array x; Array y; Array KValues; string phase; }; template <typename Scalar, typename Array> struct Equilibrium3PropertiesBase { Scalar T; Scalar P; Scalar vf; Scalar l1f; Scalar l2f; Array z; Array x1; Array x2; Array y; Array K1Values; Array K2Values; string phase; }; template <typename Scalar, typename Array> struct EquilibriumArgumentsBase { Scalar T; Scalar P; Scalar vf; Array z; Array x; Array y; EquilibriumArgumentsBase() { } EquilibriumArgumentsBase(double t, double p, double vf, vector<double> z ) { auto NC=z.size(); this->T = t; this->P = p; this->vf = vf; this->z = Array(NC); this->x = Array(NC); this->y = Array(NC); for (size_t i = 0; i < z.size(); i++) { this->z[i] = z[i]; this->y[i] = z[i]; this->x[i] = z[i]; } } }; template <typename Scalar, typename Array> struct Equilibrium3ArgumentsBase { Scalar T; Scalar P; Scalar vf; Array z; Array x1; Array x2; Array y; Equilibrium3ArgumentsBase(double t, double p, double vf, vector<double> z ) { auto NC=z.size(); this->T = t; this->P = p; this->z = Array(NC); this->x1 = Array(NC); this->x2 = Array(NC); this->y = Array(NC); for (size_t i = 0; i < z.size(); i++) { this->z[i] = z[i]; this->y[i] = z[i]; this->x1[i] = z[i]; this->x2[i] = z[i]; } } }; using Real = autodiff::dual; using VectorXReal = autodiff::VectorXdual; using MatrixXReal = autodiff::MatrixXdual; using ActivityPropertiesExt = ActivityPropertiesBase<double, std::vector<double>>; using FugacityPropertiesExt = FugacityPropertiesBase<double, std::vector<double>>; using EquilibriumPropertiesExt = EquilibriumPropertiesBase<double, std::vector<double>>; using Equilibrium3PropertiesExt = Equilibrium3PropertiesBase<double, std::vector<double>>; using ActivityProperties = ActivityPropertiesBase<Real, VectorXReal>; using ActivityArguments = ActivityArgumentsBase<Real, VectorXReal>; using FugacityProperties = FugacityPropertiesBase<Real, VectorXReal>; using FugacityArguments = FugacityArgumentsBase<Real, VectorXReal>; using EquilibriumProperties = EquilibriumPropertiesBase<Real, VectorXReal>; using EquilibriumArguments = EquilibriumArgumentsBase<Real, VectorXReal>; using Equilibrium3Properties = Equilibrium3PropertiesBase<Real, VectorXReal>; using Equilibrium3Arguments = Equilibrium3ArgumentsBase<Real, VectorXReal>; Equilibrium3PropertiesExt export_properties3(Equilibrium3Properties props); EquilibriumPropertiesExt export_properties(EquilibriumProperties props); } // namespace Types } // namespace Thermodynamics
27.447514
98
0.513084
[ "vector" ]
9c258a0c22f69216cfcffbd9e62a1d81898f0767
666
h
C
src/text/font/FontMemoryPool.h
MohammadFakhreddin/CpuGraphicRasterizer
d4deb5b4213d6da1be4d88e6ab102853a16c5de4
[ "MIT" ]
8
2020-01-27T18:14:20.000Z
2020-10-08T11:57:33.000Z
src/text/font/FontMemoryPool.h
MohammadFakhreddin/CpuGraphicRasterizer
d4deb5b4213d6da1be4d88e6ab102853a16c5de4
[ "MIT" ]
null
null
null
src/text/font/FontMemoryPool.h
MohammadFakhreddin/CpuGraphicRasterizer
d4deb5b4213d6da1be4d88e6ab102853a16c5de4
[ "MIT" ]
1
2020-03-19T08:41:56.000Z
2020-03-19T08:41:56.000Z
#ifndef FontMemoryPool_Class #define FontMemoryPool_Class #include <vector> #include <stack> #include <stack> #include <string> //We can use this mechanism to have memory pool to avoid being forced to create these classes class FontMemoryPool { public: float currentPositionX = 0.0f; float currentPositionY = 0.0f; float maximumGlyphWidth = 0.0f; float maximumGlyphHeight = 0.0f; std::vector<std::u32string> words; std::stack<std::u32string> rtlWordBuffer; bool isRtl = false; bool isPreviousRtl = false; bool isPreviousLtr = false; bool isPreviouseCharacterABreakerChar = false; }; #endif // !FontMemoryPool_Class
19.028571
93
0.726727
[ "vector" ]
9c30ac191359282860eb2ddd435755a7d12c0d56
15,388
h
C
base/include/vulkan_tools.h
snowzurfer/vulkan-visbuff-2
6fad43ab319afa04634db2238e5ae4d292fd7d1a
[ "MIT" ]
1
2021-11-04T06:02:06.000Z
2021-11-04T06:02:06.000Z
base/include/vulkan_tools.h
snowzurfer/vulkan-visbuff
6fad43ab319afa04634db2238e5ae4d292fd7d1a
[ "MIT" ]
null
null
null
base/include/vulkan_tools.h
snowzurfer/vulkan-visbuff
6fad43ab319afa04634db2238e5ae4d292fd7d1a
[ "MIT" ]
null
null
null
#ifndef VKS_VULKANTOOLS #define VKS_VULKANTOOLS #include <cstdint> #include <logger.hpp> #include <string> #include <vector> #include <vulkan/vulkan.h> namespace vks { class VulkanImage; class VulkanDevice; namespace tools { #define STR_EXPAND(str) #str #define STR(str) STR_EXPAND(str) #define SCAST_U32(val) static_cast<uint32_t>(val) #define SCAST_U32PTR(val) static_cast<uint32_t *>(val) #define SCAST_CU32PTR(val) static_cast<const uint32_t *>(val) #define SCAST_VOIDPTR(val) static_cast<void *>(val) #define SCAST_CVOIDPTR(val) static_cast<const void *>(val) #define SCAST_FLOAT(val) static_cast<float>(val) // Used to exti the program when something went wrong // void Exit(const std::string &msg); #define EXIT(msg) \ \ { \ ELOG_ERR(msg); \ exit(EXIT_FAILURE); \ \ } std::string VkResultToString(VkResult error_code); #define VK_CHECK_RESULT(f) \ \ { \ VkResult res = (f); \ if (res != VK_SUCCESS) { \ EXIT(vks::tools::VkResultToString(res)); \ } \ \ } #ifndef NDEBUG #define VKS_ASSERT(expr, msg) \ \ { \ if (!(expr)) { \ EXIT(msg); \ } \ \ } #else #define VKS_ASSERT(...) #endif template <typename E> constexpr typename std::underlying_type<E>::type ToUnderlying(E e) { return static_cast<typename std::underlying_type<E>::type>(e); } // template <typename T> // void VulkanObjectsDeleter(T *obj) { // T //} float Lerp(float a, float b, float t); bool GetSupportedDepthFormat(VkPhysicalDevice physical_device, VkFormat &depth_format); bool DoesPhysicalDeviceSupportExtension( const char *extension_name, const std::vector<VkExtensionProperties> &available_extensions); // Used by the swapchain creation uint32_t GetSwapChainNumImages(const VkSurfaceCapabilitiesKHR &surface_capabilities); VkSurfaceFormatKHR GetSwapChainFormat(VkFormat desired_format, const std::vector<VkSurfaceFormatKHR> &surface_formats); VkExtent2D GetSwapChainExtent(const VkSurfaceCapabilitiesKHR &surface_capabilities, const uint32_t width, const uint32_t height); VkImageUsageFlags GetSwapChainUsageFlags(const VkSurfaceCapabilitiesKHR &surface_capabilities); VkSurfaceTransformFlagBitsKHR GetSwapChainTransform(const VkSurfaceCapabilitiesKHR &surface_capabilities); VkPresentModeKHR GetSwapChainPresentMode(const std::vector<VkPresentModeKHR> &present_modes); // Change the layout of an image using a barrier. // It will be recorded on the command buffer cmd_buff void SetImageLayout(VkCommandBuffer cmd_buff, VulkanImage &image, VkImageLayout old_image_layout, VkImageLayout new_image_layout, VkImageSubresourceRange subresource_range); void SetImageLayout(VkCommandBuffer cmd_buff, VulkanImage &image, VkImageLayout old_image_layout, VkImageLayout new_image_layout, VkAccessFlags src_access_flags, VkAccessFlags dst_access_flags, VkImageSubresourceRange subresource_range); void SetImageLayoutAndExecuteBarrier(const VulkanDevice &device, VkCommandBuffer cmd_buff, VulkanImage &image, VkImageLayout old_image_layout, VkImageLayout new_image_layout, VkImageSubresourceRange subresource_range); void SetImageMemoryBarrier(VkCommandBuffer cmd_buff, const std::vector<VulkanImage *> &images, uint32_t old_family_index, uint32_t new_family_index, VkAccessFlags src_access_mask, VkAccessFlags dst_access_mask, VkImageLayout old_image_layout, VkImageLayout new_image_layout, VkImageSubresourceRange subresource_range, VkPipelineStageFlagBits src_stage_mask, VkPipelineStageFlagBits dst_stage_mask); void SetImageMemoryBarrier(VkCommandBuffer cmd_buff, VkImage image, uint32_t old_family_index, uint32_t new_family_index, VkAccessFlags src_access_mas, VkAccessFlags dst_access_mask, VkImageLayout old_image_layout, VkImageLayout new_image_layout, VkImageSubresourceRange subresource_range, VkPipelineStageFlagBits src_stage_mask, VkPipelineStageFlagBits dst_stage_mask); void SetLayoutAndWrite(uint32_t binding, VkDescriptorType descriptor_type, uint32_t descriptor_count, VkShaderStageFlags stage_flags, uint32_t dst_array_element, VkDescriptorSet dst_set, const VkBufferView *pTexelBufferView, const VkDescriptorImageInfo *pImageInfo, const VkDescriptorBufferInfo *pBufferInfo, std::vector<VkDescriptorSetLayoutBinding> &bindings, std::vector<VkWriteDescriptorSet> &writes); bool DoesFileExist(const std::string &name); bool Replace(eastl::string &str, const eastl::string &from, const eastl::string &to); // The initialisers are used to avoid typing the structure type and the // null flags every time a stucture needs to be created namespace inits { VkBufferCreateInfo BufferCreateInfo(VkBufferCreateFlags flags = 0U); VkMemoryAllocateInfo MemoryAllocateInfo(); VkImageCreateInfo ImageCreateInfo(VkImageCreateFlags flags, VkImageType imageType, VkFormat format, VkExtent3D extent, uint32_t mipLevels, uint32_t arrayLayers, VkSampleCountFlagBits samples, VkImageTiling tiling, VkImageUsageFlags usage, VkSharingMode sharingMode, uint32_t queueFamilyIndexCount, const uint32_t *pQueueFamilyIndices, VkImageLayout initialLayout); VkImageViewCreateInfo ImageViewCreateInfo(VkImage image, VkImageViewType viewType, VkFormat format, VkComponentMapping components, VkImageSubresourceRange subresourceRange); VkCommandBufferBeginInfo CommandBufferBeginInfo(VkCommandBufferUsageFlags flags = 0U); VkFenceCreateInfo FenceCreateInfo(VkFenceCreateFlags flags = 0x0); VkSubmitInfo SubmitInfo(); VkSamplerCreateInfo SamplerCreateInfo( VkFilter magFilter, VkFilter minFilter, VkSamplerMipmapMode mipmapMode, VkSamplerAddressMode addressModeU, VkSamplerAddressMode addressModeV, VkSamplerAddressMode addressModeW, float mipLodBias, VkBool32 anisotropyEnable, float maxAnisotropy, VkBool32 compareEnable, VkCompareOp compareOp, float minLod, float maxLod, VkBorderColor borderColor, VkBool32 unnormalizedCoordinates); VkPipelineVertexInputStateCreateInfo PipelineVertexInputStateCreateInfo(); VkDeviceQueueCreateInfo DeviceQueueCreateInfo(); VkCommandPoolCreateInfo CommandPoolCreateInfo(VkCommandPoolCreateFlags flags = 0U); VkShaderModuleCreateInfo ShaderModuleCreateInfo(); VkComputePipelineCreateInfo ComputePipelineCreateInfo(); VkPipelineShaderStageCreateInfo PipelineShaderStageCreateInfo(); // VkAttachmentDescription AttachmentDescription(); VkRenderPassCreateInfo RenderPassCreateInfo( uint32_t attachmentCount, const VkAttachmentDescription *pAttachments, uint32_t subpassCount, const VkSubpassDescription *pSubpasses, uint32_t dependencyCount, const VkSubpassDependency *pDependencies); VkDescriptorSetLayoutCreateInfo DescriptrorSetLayoutCreateInfo(); VkDescriptorPoolCreateInfo DescriptrorPoolCreateInfo(uint32_t maxSets, uint32_t poolSizeCount, const VkDescriptorPoolSize *pPoolSizes); VkDescriptorSetAllocateInfo DescriptorSetAllocateInfo(VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSetLayout *pSetLayouts); VkWriteDescriptorSet WriteDescriptorSet(VkDescriptorSet dstSet, uint32_t dstBinding, uint32_t dstArrayElement, uint32_t descriptorCount, VkDescriptorType descriptorType, const VkDescriptorImageInfo *pImageInfo, const VkDescriptorBufferInfo *pBufferInfo = nullptr, const VkBufferView *pTexelBufferView = nullptr); VkWriteDescriptorSet WriteDescriptorSet(VkDescriptorSet dstSet, uint32_t dstBinding, uint32_t dstArrayElement, uint32_t descriptorCount, VkDescriptorType descriptorType, const VkBufferView *pTexelBufferView, const VkDescriptorImageInfo *pImageInfo = nullptr, const VkDescriptorBufferInfo *pBufferInfo = nullptr); VkWriteDescriptorSet WriteDescriptorSet(VkDescriptorSet dstSet, uint32_t dstBinding, uint32_t dstArrayElement, uint32_t descriptorCount, VkDescriptorType descriptorType, const VkDescriptorBufferInfo *pBufferInfo, const VkBufferView *pTexelBufferView = nullptr, const VkDescriptorImageInfo *pImageInfo = nullptr); VkPipelineLayoutCreateInfo PipelineLayoutCreateInfo(uint32_t setLayoutCount, const VkDescriptorSetLayout *pSetLayouts, uint32_t pushConstantRangeCount, const VkPushConstantRange *pPushConstantRanges); VkFramebufferCreateInfo FramebufferCreateInfo(VkRenderPass renderPass, uint32_t attachmentCount, const VkImageView *pAttachments, uint32_t width, uint32_t height, uint32_t layers); VkImageMemoryBarrier ImageMemoryBarrier(); VkImageMemoryBarrier ImageMemoryBarrier(VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkImageLayout oldLayout, VkImageLayout newLayout, uint32_t srcQueueFamilyIndex, uint32_t dstQueueFamilyIndex, VkImage image, VkImageSubresourceRange subresourceRange); VkRenderPassBeginInfo RenderPassBeginInfo(); VkPipelineInputAssemblyStateCreateInfo PipelineInputAssemblyStateCreateInfo(); VkPipelineViewportStateCreateInfo PipelineViewportStateCreateInfo(); VkPipelineRasterizationStateCreateInfo PipelineRasterizationStateCreateInfo(); VkPipelineMultisampleStateCreateInfo PipelineMultisampleStateCreateInfo(); VkPipelineDepthStencilStateCreateInfo PipelineDepthStencilStateCreateInfo(); VkPipelineColorBlendStateCreateInfo PipelineColorBlendStateCreateInfo( VkBool32 logicOpEnable, VkLogicOp logicOp, uint32_t attachmentCount, const VkPipelineColorBlendAttachmentState *pAttachments, float *blendConstants); VkGraphicsPipelineCreateInfo GraphicsPipelineCreateInfo(); VkPresentInfoKHR PresentInfoKHR(); VkAttachmentDescription AttachmentDescription(VkAttachmentDescriptionFlags flags, VkFormat format, VkSampleCountFlagBits samples, VkAttachmentLoadOp loadOp, VkAttachmentStoreOp storeOp, VkAttachmentLoadOp stencilLoadOp, VkAttachmentStoreOp stencilStoreOp, VkImageLayout initialLayout, VkImageLayout finalLayout); VkSubpassDescription SubpassDescription( VkPipelineBindPoint pipelineBindPoint, uint32_t inputAttachmentCount, const VkAttachmentReference *pInputAttachments, uint32_t colorAttachmentCount, const VkAttachmentReference *pColorAttachments, const VkAttachmentReference *pResolveAttachments, const VkAttachmentReference *pDepthStencilAttachment, uint32_t preserveAttachmentCount, const uint32_t *pPreserveAttachments); VkSubpassDependency SubpassDependency(uint32_t srcSubpass, uint32_t dstSubpass, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkDependencyFlags dependencyFlags); VkDescriptorPoolSize DescriptorPoolSize(VkDescriptorType type, uint32_t descriptorCount); VkDescriptorSetLayoutBinding DescriptorSetLayoutBinding( uint32_t binding, VkDescriptorType descriptorType, uint32_t descriptorCount, VkShaderStageFlags stageFlags, const VkSampler *pImmutableSamplers); VkImageSubresourceRange ImageSubresourceRange(VkImageAspectFlags aspectMask, uint32_t baseMipLevel, uint32_t levelCount, uint32_t baseArrayLayer, uint32_t layerCount); VkPipelineColorBlendAttachmentState PipelineColorBlendAttachmentState( VkBool32 blendEnable, VkBlendFactor srcColorBlendFactor, VkBlendFactor dstColorBlendFactor, VkBlendOp colorBlendOp, VkBlendFactor srcAlphaBlendFactor, VkBlendFactor dstAlphaBlendFactor, VkBlendOp alphaBlendOp, VkColorComponentFlags colorWriteMask); VkDescriptorPoolSize DescriptorPoolSize(VkDescriptorType type, uint32_t descriptorCount); VkSpecializationMapEntry SpecializationMapEntry(uint32_t constantID, uint32_t offset, size_t size); VkStencilOpState StencilOpState(VkStencilOp failOp = VK_STENCIL_OP_KEEP, VkStencilOp passOp = VK_STENCIL_OP_KEEP, VkStencilOp depthFailOp = VK_STENCIL_OP_KEEP, VkCompareOp compareOp = VK_COMPARE_OP_NEVER, uint32_t compareMask = 0x0, uint32_t writeMask = 0x0, uint32_t reference = 0x0); VkImageBlit ImageBlit(VkImageSubresourceLayers srcSubresource, VkOffset3D srcOffsets[2], VkImageSubresourceLayers dstSubresource, VkOffset3D dstOffsets[2]); } // namespace inits } // namespace tools } // namespace vks #endif
50.287582
80
0.649467
[ "vector" ]
9c3a294436639fc32f32bc7653e7a76b5412abab
6,845
h
C
mdc/include/tencentcloud/mdc/v20200828/model/FlowMediaInfo.h
TencentCloud/tencentcloud-sdk-cpp-intl-en
752c031f5ad2c96868183c5931eae3a42dd5ae6c
[ "Apache-2.0" ]
1
2022-01-27T09:27:34.000Z
2022-01-27T09:27:34.000Z
mdc/include/tencentcloud/mdc/v20200828/model/FlowMediaInfo.h
TencentCloud/tencentcloud-sdk-cpp-intl-en
752c031f5ad2c96868183c5931eae3a42dd5ae6c
[ "Apache-2.0" ]
null
null
null
mdc/include/tencentcloud/mdc/v20200828/model/FlowMediaInfo.h
TencentCloud/tencentcloud-sdk-cpp-intl-en
752c031f5ad2c96868183c5931eae3a42dd5ae6c
[ "Apache-2.0" ]
null
null
null
/* * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef TENCENTCLOUD_MDC_V20200828_MODEL_FLOWMEDIAINFO_H_ #define TENCENTCLOUD_MDC_V20200828_MODEL_FLOWMEDIAINFO_H_ #include <string> #include <vector> #include <map> #include <tencentcloud/core/utils/rapidjson/document.h> #include <tencentcloud/core/utils/rapidjson/writer.h> #include <tencentcloud/core/utils/rapidjson/stringbuffer.h> #include <tencentcloud/core/AbstractModel.h> #include <tencentcloud/mdc/v20200828/model/FlowMediaVideo.h> #include <tencentcloud/mdc/v20200828/model/FlowMediaAudio.h> namespace TencentCloud { namespace Mdc { namespace V20200828 { namespace Model { /** * The media data of a flow. */ class FlowMediaInfo : public AbstractModel { public: FlowMediaInfo(); ~FlowMediaInfo() = default; void ToJsonObject(rapidjson::Value &value, rapidjson::Document::AllocatorType& allocator) const; CoreInternalOutcome Deserialize(const rapidjson::Value &value); /** * 获取The timestamp (seconds). * @return Timestamp The timestamp (seconds). */ int64_t GetTimestamp() const; /** * 设置The timestamp (seconds). * @param Timestamp The timestamp (seconds). */ void SetTimestamp(const int64_t& _timestamp); /** * 判断参数 Timestamp 是否已赋值 * @return Timestamp 是否已赋值 */ bool TimestampHasBeenSet() const; /** * 获取The total bandwidth. * @return Network The total bandwidth. */ int64_t GetNetwork() const; /** * 设置The total bandwidth. * @param Network The total bandwidth. */ void SetNetwork(const int64_t& _network); /** * 判断参数 Network 是否已赋值 * @return Network 是否已赋值 */ bool NetworkHasBeenSet() const; /** * 获取The video data of the flow. * @return Video The video data of the flow. */ std::vector<FlowMediaVideo> GetVideo() const; /** * 设置The video data of the flow. * @param Video The video data of the flow. */ void SetVideo(const std::vector<FlowMediaVideo>& _video); /** * 判断参数 Video 是否已赋值 * @return Video 是否已赋值 */ bool VideoHasBeenSet() const; /** * 获取The audio data of the flow. * @return Audio The audio data of the flow. */ std::vector<FlowMediaAudio> GetAudio() const; /** * 设置The audio data of the flow. * @param Audio The audio data of the flow. */ void SetAudio(const std::vector<FlowMediaAudio>& _audio); /** * 判断参数 Audio 是否已赋值 * @return Audio 是否已赋值 */ bool AudioHasBeenSet() const; /** * 获取The ID of a push session. * @return SessionId The ID of a push session. */ std::string GetSessionId() const; /** * 设置The ID of a push session. * @param SessionId The ID of a push session. */ void SetSessionId(const std::string& _sessionId); /** * 判断参数 SessionId 是否已赋值 * @return SessionId 是否已赋值 */ bool SessionIdHasBeenSet() const; /** * 获取The client IP. * @return ClientIp The client IP. */ std::string GetClientIp() const; /** * 设置The client IP. * @param ClientIp The client IP. */ void SetClientIp(const std::string& _clientIp); /** * 判断参数 ClientIp 是否已赋值 * @return ClientIp 是否已赋值 */ bool ClientIpHasBeenSet() const; private: /** * The timestamp (seconds). */ int64_t m_timestamp; bool m_timestampHasBeenSet; /** * The total bandwidth. */ int64_t m_network; bool m_networkHasBeenSet; /** * The video data of the flow. */ std::vector<FlowMediaVideo> m_video; bool m_videoHasBeenSet; /** * The audio data of the flow. */ std::vector<FlowMediaAudio> m_audio; bool m_audioHasBeenSet; /** * The ID of a push session. */ std::string m_sessionId; bool m_sessionIdHasBeenSet; /** * The client IP. */ std::string m_clientIp; bool m_clientIpHasBeenSet; }; } } } } #endif // !TENCENTCLOUD_MDC_V20200828_MODEL_FLOWMEDIAINFO_H_
33.553922
116
0.441198
[ "vector", "model" ]
9c3b22ba148c1e19f7bf0412bfd5893d27e60964
463
h
C
core/src/input/input.h
ExaBerries/spruce
85845244f7d6cd5a662f0dbc9b4079a1230d9a4b
[ "MIT" ]
null
null
null
core/src/input/input.h
ExaBerries/spruce
85845244f7d6cd5a662f0dbc9b4079a1230d9a4b
[ "MIT" ]
null
null
null
core/src/input/input.h
ExaBerries/spruce
85845244f7d6cd5a662f0dbc9b4079a1230d9a4b
[ "MIT" ]
null
null
null
#pragma once #include <common.h> #include <input/MouseButton.h> #include <input/CursorMode.h> #include <input/Key.h> #include <input/InputProcessor.h> namespace spruce { namespace input { extern std::vector<InputProcessor*> processors; void addProcessor(InputProcessor* processor) noexcept; void removeProcessor(InputProcessor* processor) noexcept; void setCursorMode(CursorMode mode) noexcept; [[nodiscard]] uint16 codeFor(Key key) noexcept; } }
23.15
59
0.764579
[ "vector" ]
d512219e7bfa58a18eceb621a1d5cbd924f52cc0
4,132
c
C
current/test/node-api/test_callback_scope/binding.c
Dexus/node-compiler
12c46c6e44fbc14d9ee645ebd17d5296b324f7e0
[ "MIT" ]
1,666
2017-01-12T03:58:44.000Z
2017-08-20T23:39:20.000Z
current/test/node-api/test_callback_scope/binding.c
Dexus/node-compiler
12c46c6e44fbc14d9ee645ebd17d5296b324f7e0
[ "MIT" ]
95
2017-08-21T07:38:56.000Z
2022-02-18T21:59:54.000Z
current/test/node-api/test_callback_scope/binding.c
Dexus/node-compiler
12c46c6e44fbc14d9ee645ebd17d5296b324f7e0
[ "MIT" ]
161
2017-08-25T20:20:01.000Z
2022-02-08T02:59:03.000Z
#include <stdlib.h> #include "node_api.h" #include "uv.h" #include "../../js-native-api/common.h" static napi_value RunInCallbackScope(napi_env env, napi_callback_info info) { size_t argc; napi_value args[3]; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, NULL, NULL, NULL)); NAPI_ASSERT(env, argc == 3 , "Wrong number of arguments"); NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL)); napi_valuetype valuetype; NAPI_CALL(env, napi_typeof(env, args[0], &valuetype)); NAPI_ASSERT(env, valuetype == napi_object, "Wrong type of arguments. Expects an object as first argument."); NAPI_CALL(env, napi_typeof(env, args[1], &valuetype)); NAPI_ASSERT(env, valuetype == napi_string, "Wrong type of arguments. Expects a string as second argument."); NAPI_CALL(env, napi_typeof(env, args[2], &valuetype)); NAPI_ASSERT(env, valuetype == napi_function, "Wrong type of arguments. Expects a function as third argument."); napi_async_context context; NAPI_CALL(env, napi_async_init(env, args[0], args[1], &context)); napi_callback_scope scope = NULL; NAPI_CALL( env, napi_open_callback_scope(env, args[0], context, &scope)); // if the function has an exception pending after the call that is ok // so we don't use NAPI_CALL as we must close the callback scope regardless napi_value result = NULL; napi_status function_call_result = napi_call_function(env, args[0], args[2], 0, NULL, &result); if (function_call_result != napi_ok) { GET_AND_THROW_LAST_ERROR((env)); } NAPI_CALL(env, napi_close_callback_scope(env, scope)); NAPI_CALL(env, napi_async_destroy(env, context)); return result; } static napi_env shared_env = NULL; static napi_deferred deferred = NULL; static void Callback(uv_work_t* req, int ignored) { napi_env env = shared_env; napi_handle_scope handle_scope = NULL; NAPI_CALL_RETURN_VOID(env, napi_open_handle_scope(env, &handle_scope)); napi_value resource_name; NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8( env, "test", NAPI_AUTO_LENGTH, &resource_name)); napi_async_context context; NAPI_CALL_RETURN_VOID(env, napi_async_init(env, NULL, resource_name, &context)); napi_value resource_object; NAPI_CALL_RETURN_VOID(env, napi_create_object(env, &resource_object)); napi_value undefined_value; NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined_value)); napi_callback_scope scope = NULL; NAPI_CALL_RETURN_VOID(env, napi_open_callback_scope(env, resource_object, context, &scope)); NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, deferred, undefined_value)); NAPI_CALL_RETURN_VOID(env, napi_close_callback_scope(env, scope)); NAPI_CALL_RETURN_VOID(env, napi_close_handle_scope(env, handle_scope)); NAPI_CALL_RETURN_VOID(env, napi_async_destroy(env, context)); free(req); } static void NoopWork(uv_work_t* work) { (void) work; } static napi_value TestResolveAsync(napi_env env, napi_callback_info info) { napi_value promise = NULL; if (deferred == NULL) { shared_env = env; NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); uv_loop_t* loop = NULL; NAPI_CALL(env, napi_get_uv_event_loop(env, &loop)); uv_work_t* req = malloc(sizeof(*req)); uv_queue_work(loop, req, NoopWork, Callback); } return promise; } static napi_value Init(napi_env env, napi_value exports) { napi_property_descriptor descriptors[] = { DECLARE_NAPI_PROPERTY("runInCallbackScope", RunInCallbackScope), DECLARE_NAPI_PROPERTY("testResolveAsync", TestResolveAsync) }; NAPI_CALL(env, napi_define_properties( env, exports, sizeof(descriptors) / sizeof(*descriptors), descriptors)); return exports; } NAPI_MODULE(NODE_GYP_MODULE_NAME, Init)
33.056
79
0.681026
[ "object" ]
d51a5d8d1e63024ff60d5b1549fb6b1d59f59caa
16,462
c
C
src/csmgrd/lib/csmgrd_plugin.c
yuki-koizumi/Cefore-RICE
2f2e5b24c47b0e4c24ffef8497d604117af759a0
[ "Apache-2.0" ]
3
2021-03-11T05:28:21.000Z
2022-03-08T07:31:39.000Z
src/csmgrd/lib/csmgrd_plugin.c
yuki-koizumi/Cefore-RICE
2f2e5b24c47b0e4c24ffef8497d604117af759a0
[ "Apache-2.0" ]
null
null
null
src/csmgrd/lib/csmgrd_plugin.c
yuki-koizumi/Cefore-RICE
2f2e5b24c47b0e4c24ffef8497d604117af759a0
[ "Apache-2.0" ]
null
null
null
/* * Copyright (c) 2016-2020, National Institute of Information and Communications * Technology (NICT). All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the NICT 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 NICT 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 NICT 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. */ /* * csmgrd_plugin.c */ #define __CSMGRD_PLUGIN_SOURCE__ /**************************************************************************************** Include Files ****************************************************************************************/ #include <assert.h> #include <errno.h> #include <poll.h> #include <stdarg.h> #include <stdio.h> #include <time.h> #include <limits.h> #include <cefore/cef_client.h> #include <csmgrd/csmgrd_plugin.h> /**************************************************************************************** Macros ****************************************************************************************/ /**************************************************************************************** Structures Declaration ****************************************************************************************/ /**************************************************************************************** State Variables ****************************************************************************************/ static char log_porc[256] = {0}; static int log_lv = 0; static char log_lv_str[4][16] = {"INFO", "WARNING", "ERROR", "CRITICAL"}; #ifdef CefC_Debug static char dbg_proc[256] = {0}; static int dbg_lv = CefC_Dbg_None; #endif // CefC_Debug /**************************************************************************************** Static Function Declaration ****************************************************************************************/ static int csmgrd_log_trim_line_string ( const char* p1, /* target string for trimming */ char* p2, /* name string after trimming */ char* p3 /* value string after trimming */ ); #ifdef CefC_Debug static int csmgrd_dbg_trim_line_string ( const char* p1, /* target string for trimming */ char* p2, /* name string after trimming */ char* p3 /* value string after trimming */ ); #endif // CefC_Debug /**************************************************************************************** ****************************************************************************************/ /*-------------------------------------------------------------------------------------- Function to Create Cob message ----------------------------------------------------------------------------------------*/ void csmgrd_plugin_cob_msg_create ( unsigned char* buff, /* created message */ uint16_t* buff_len, /* Length of message */ unsigned char* msg, /* Content Object */ uint16_t msg_len, /* Length of Content Object */ uint32_t chnk_num, /* Chunk number */ int faceid /* faceid */ ) { uint16_t index = 0; /* set header */ buff[CefC_O_Fix_Ver] = CefC_Version; buff[CefC_O_Fix_Type] = CefC_Csmgr_Msg_Type_Bulk_Cob; index += CefC_Csmgr_Msg_HeaderLen; /* set cob message */ memcpy (buff + index, &(msg_len), CefC_S_Length); memcpy (buff + index + CefC_S_Length, msg, msg_len); index += CefC_S_Length + msg_len; /* set chunk num */ memcpy (buff + index, &(chnk_num), CefC_S_ChunkNum); index += CefC_S_ChunkNum; /* set faceid */ memcpy (buff + index, &faceid, sizeof (faceid)); index += sizeof (faceid); /* set Length */ memcpy (buff + CefC_O_Length, &index, CefC_S_Length); *buff_len = index; return; } /*-------------------------------------------------------------------------------------- Function to Send Cob message ----------------------------------------------------------------------------------------*/ int csmgrd_plugin_cob_msg_send ( int fd, /* socket fd */ unsigned char* msg, /* send message */ uint16_t msg_len /* message length */ ) { struct pollfd fds[1]; fds[0].fd = fd; fds[0].events = POLLOUT | POLLERR; if (poll (fds, 1, 100) < 1) { /* poll error */ return (-1); } /* send Cob message */ if (send (fds[0].fd, msg, msg_len, 0) < 1) { /* send error */ if ((errno != EAGAIN) && (errno != EWOULDBLOCK)) { return (-1); } } return (0); } /*-------------------------------------------------------------------------------------- Sets APIs for cache algorithm library ----------------------------------------------------------------------------------------*/ int /* The return value is negative if an error occurs */ csmgrd_lib_api_get ( const char* algo_lib_name, void** algo_lib, CsmgrdT_Lib_Interface* algo_apis ) { /* Opens the library */ *algo_lib = dlopen (algo_lib_name, RTLD_LAZY); if (*algo_lib == NULL) { return (-1); } /* Loads APIs */ algo_apis->init = dlsym (*algo_lib, "init"); algo_apis->destroy = dlsym (*algo_lib, "destroy"); algo_apis->insert = dlsym (*algo_lib, "insert"); algo_apis->erase = dlsym (*algo_lib, "erase"); algo_apis->hit = dlsym (*algo_lib, "hit"); algo_apis->miss = dlsym (*algo_lib, "miss"); algo_apis->status = dlsym (*algo_lib, "status"); return (1); } /*-------------------------------------------------------------------------------------- Creates tye key from name and chunk number ----------------------------------------------------------------------------------------*/ int /* length of the created key */ csmgrd_key_create ( CsmgrdT_Content_Entry* entry, unsigned char* key ) { uint32_t chnk_num; memcpy (&key[0], entry->name, entry->name_len); key[entry->name_len] = 0x00; key[entry->name_len + 1] = 0x10; key[entry->name_len + 2] = 0x00; key[entry->name_len + 3] = 0x04; chnk_num = htonl (entry->chnk_num); memcpy (&key[entry->name_len + 4], &chnk_num, sizeof (uint32_t)); return (entry->name_len + 4 + sizeof (uint32_t)); } /*-------------------------------------------------------------------------------------- Concatenates name and chunk number ----------------------------------------------------------------------------------------*/ int /* length of the created key */ csmgrd_name_chunknum_concatenate ( const unsigned char* name, uint16_t name_len, uint32_t chunknum, unsigned char* key ) { uint32_t no_chunknum; memcpy (&key[0], name, name_len); key[name_len] = 0x00; key[name_len + 1] = 0x10; key[name_len + 2] = 0x00; key[name_len + 3] = 0x04; no_chunknum = htonl (chunknum); memcpy (&key[name_len + 4], &no_chunknum, sizeof (uint32_t)); return (name_len + 4 + sizeof (uint32_t)); } /*-------------------------------------------------------------------------------------- Creates the content entry ----------------------------------------------------------------------------------------*/ int cef_csmgr_con_entry_create ( unsigned char* buff, /* receive message */ int buff_len, /* message length */ CsmgrdT_Content_Entry* entry ) { uint16_t index, len; uint16_t value16; uint32_t value32; uint64_t value64; struct timeval tv; /* check message size */ if (buff_len <= CefC_Csmgr_Msg_HeaderLen) { return (-1); } /* check header */ if ((buff[CefC_O_Fix_Ver] != CefC_Version) || (buff[CefC_O_Fix_Type] >= CefC_Csmgr_Msg_Type_Num) || (buff[CefC_O_Fix_Type] == CefC_Csmgr_Msg_Type_Invalid)) { return (-1); } memcpy (&value16, &buff[CefC_O_Length], CefC_S_Length); len = ntohs (value16); /* check message length */ if ((len <= CefC_Csmgr_Msg_HeaderLen) || (len > buff_len)) { return (-1); } index = CefC_Csmgr_Msg_HeaderLen; /* Get payload length */ memcpy (&value16, &buff[index], CefC_S_Length); entry->pay_len = ntohs (value16); if(entry->pay_len > len){ return(-1); } index += CefC_S_Length; /* Get cob message */ memcpy (&value16, &buff[index], CefC_S_Length); entry->msg_len = ntohs (value16); if(entry->pay_len > entry->msg_len){ return(-1); } if(entry->msg_len > len){ return(-1); } index += CefC_S_Length; memcpy (entry->msg, &buff[index], entry->msg_len); index += entry->msg_len; /* Get cob name */ memcpy (&value16, &buff[index], CefC_S_Length); entry->name_len = ntohs (value16); if(entry->name_len > entry->msg_len){ return(-1); } index += CefC_S_Length; memcpy (entry->name, &buff[index], entry->name_len); index += entry->name_len; /* Get chunk num */ memcpy (&value32, &buff[index], CefC_S_ChunkNum); entry->chnk_num = ntohl (value32); index += CefC_S_ChunkNum; /* Get cache time */ memcpy (&value64, &buff[index], CefC_S_Cachetime); entry->cache_time = cef_client_ntohb (value64); index += CefC_S_Cachetime; /* get expiry */ memcpy (&value64, &buff[index], CefC_S_Expiry); entry->expiry = cef_client_ntohb (value64); index += CefC_S_Expiry; /* get address */ memcpy (&entry->node, &buff[index], sizeof (struct in_addr)); index += sizeof (struct in_addr); /* get insert time */ gettimeofday (&tv, NULL); entry->ins_time = tv.tv_sec * 1000000llu + tv.tv_usec; return ((int) index); } void csmgrd_log_init ( const char* proc_name, int level ) { assert (proc_name != NULL); strcpy (log_porc, proc_name); log_lv = level; } void csmgrd_log_init2 ( const char* config_file_dir ) { char* wp; char file_path[PATH_MAX]; FILE* fp; char buff[1024]; char ws[1024]; char pname[1024]; int res; /* Update the log level information */ if (config_file_dir[0] != 0x00) { sprintf (file_path, "%s/csmgrd.conf", config_file_dir); } else { wp = getenv (CefC_CEFORE_DIR); if (wp != NULL && wp[0] != 0) { sprintf (file_path, "%s/cefore/csmgrd.conf", wp); } else { sprintf (file_path, "%s/csmgrd.conf", CefC_CEFORE_DIR_DEF); } } fp = fopen (file_path, "r"); if (fp == NULL) { return; } log_lv = 0; /* Reads and records written values in the cefnetd's config file. */ while (fgets (buff, 1023, fp) != NULL) { buff[1023] = 0; if (buff[0] == 0x23/* '#' */) { continue; } res = csmgrd_log_trim_line_string (buff, pname, ws); if (res < 0) { continue; } if (strcmp (pname, "CEF_LOG_LEVEL") == 0) { log_lv = atoi (ws); if (!(0<=log_lv && log_lv <= 2)){ log_lv = 0; } } } fclose (fp); } void csmgrd_log_write ( int level, /* logging level */ const char* fmt, /* output format */ ... /* parameters */ ) { va_list arg; char time_str[64]; struct tm* timeptr; time_t timer; struct timeval t; int use_log_level; assert (level <= CefC_Log_Critical); assert (log_porc[0] != 0x00); if (log_lv == 0) { use_log_level = CefC_Log_Error; } else if (log_lv == 1) { use_log_level = CefC_Log_Warn; } else { use_log_level = -1; } if (level >= use_log_level) { va_start (arg, fmt); timer = time (NULL); timeptr = localtime (&timer); strftime (time_str, 64, "%Y-%m-%d %H:%M:%S", timeptr); gettimeofday (&t, NULL); fprintf (stdout, "%s."FMTLINT" [%s] %s: " , time_str, t.tv_usec / 1000, log_porc, log_lv_str[level]); vfprintf (stdout, fmt, arg); va_end (arg); } } #ifdef CefC_Debug void csmgrd_dbg_init ( const char* proc_name, const char* config_file_dir ) { char file_path[PATH_MAX]; FILE* fp; char buff[1024]; char ws[1024]; char pname[1024]; int res; char* wp; assert (proc_name != NULL); strcpy (dbg_proc, proc_name); /* Records the debug level */ if (config_file_dir[0] != 0x00) { sprintf (file_path, "%s/csmgrd.conf", config_file_dir); } else { wp = getenv (CefC_CEFORE_DIR); if (wp != NULL && wp[0] != 0) { sprintf (file_path, "%s/cefore/csmgrd.conf", wp); } else { sprintf (file_path, "%s/csmgrd.conf", CefC_CEFORE_DIR_DEF); } } fp = fopen (file_path, "r"); if (fp == NULL) { return; } /* Reads and records written values in the cefnetd's config file. */ while (fgets (buff, 1023, fp) != NULL) { buff[1023] = 0; if (buff[0] == 0x23/* '#' */) { continue; } res = csmgrd_dbg_trim_line_string (buff, pname, ws); if (res < 0) { continue; } if (strcmp (pname, "CEF_DEBUG_LEVEL") == 0) { dbg_lv = atoi (ws); } } fclose (fp); if (dbg_lv > CefC_Dbg_Finest) { dbg_lv = CefC_Dbg_Finest; } if (dbg_lv < CefC_Dbg_None) { dbg_lv = CefC_Dbg_None; } dbg_lv++; } void csmgrd_dbg_write ( int level, /* debug level */ const char* fmt, /* output format */ ... /* parameters */ ) { va_list arg; char time_str[64]; struct tm* timeptr; time_t timer; struct timeval t; assert (level >= CefC_Dbg_Fine && level <= CefC_Dbg_Finest); assert (dbg_proc[0] != 0x00); if (level < dbg_lv) { va_start (arg, fmt); timer = time (NULL); timeptr = localtime (&timer); strftime (time_str, 64, "%Y-%m-%d %H:%M:%S", timeptr); gettimeofday (&t, NULL); fprintf (stdout, "%s."FMTLINT" [%s] DEBUG: ", time_str, t.tv_usec / 1000, dbg_proc); vfprintf (stdout, fmt, arg); va_end (arg); } } void csmgrd_dbg_buff_write ( int level, /* debug level */ const unsigned char* buff, int len ) { int i; int n = 0; int s = 0; if (level < dbg_lv) { fprintf (stderr, "------------------------------------------------------\n"); fprintf (stderr, " 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5\n"); for (i = 0 ; i < len ; i++) { if (n == 0) { fprintf (stderr, "%3d: ", s); s++; } fprintf (stderr, "%02X ", buff[i]); if (n == 7) { fprintf (stderr, " "); } n++; if (n > 15) { n = 0; fprintf (stderr, "\n"); } } fprintf (stderr, "\n------------------------------------------------------\n"); } } static int csmgrd_dbg_trim_line_string ( const char* p1, /* target string for trimming */ char* p2, /* name string after trimming */ char* p3 /* value string after trimming */ ) { char ws[1024]; char* wp = ws; char* rp = p2; int equal_f = -1; while (*p1) { if ((*p1 == 0x0D) || (*p1 == 0x0A)) { break; } if ((*p1 == 0x20) || (*p1 == 0x09)) { p1++; continue; } else { *wp = *p1; } p1++; wp++; } *wp = 0x00; wp = ws; while (*wp) { if (*wp == 0x3d /* '=' */) { if (equal_f > 0) { return (-1); } equal_f = 1; *rp = 0x00; rp = p3; } else { *rp = *wp; rp++; } wp++; } *rp = 0x00; return (equal_f); } #endif // CefC_Debug static int csmgrd_log_trim_line_string ( const char* p1, /* target string for trimming */ char* p2, /* name string after trimming */ char* p3 /* value string after trimming */ ) { char ws[1024]; char* wp = ws; char* rp = p2; int equal_f = -1; while (*p1) { if ((*p1 == 0x0D) || (*p1 == 0x0A)) { break; } if ((*p1 == 0x20) || (*p1 == 0x09)) { p1++; continue; } else { *wp = *p1; } p1++; wp++; } *wp = 0x00; wp = ws; while (*wp) { if (*wp == 0x3d /* '=' */) { if (equal_f > 0) { return (-1); } equal_f = 1; *rp = 0x00; rp = p3; } else { *rp = *wp; rp++; } wp++; } *rp = 0x00; return (equal_f); }
25.326154
90
0.534868
[ "object", "3d" ]
d51f658a0c7e800da857ee369112e58c155a979e
1,351
h
C
lib/fidl/array_to_string.h
Acidburn0zzz/peridot
9a3b1fb8e834d0315092478d83d0176ef28cb765
[ "BSD-3-Clause" ]
1
2018-02-05T23:33:32.000Z
2018-02-05T23:33:32.000Z
lib/fidl/array_to_string.h
Acidburn0zzz/peridot
9a3b1fb8e834d0315092478d83d0176ef28cb765
[ "BSD-3-Clause" ]
null
null
null
lib/fidl/array_to_string.h
Acidburn0zzz/peridot
9a3b1fb8e834d0315092478d83d0176ef28cb765
[ "BSD-3-Clause" ]
null
null
null
// Copyright 2016 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef PERIDOT_LIB_FIDL_ARRAY_TO_STRING_H_ #define PERIDOT_LIB_FIDL_ARRAY_TO_STRING_H_ #include <string> #include <vector> #include "lib/fidl/cpp/bindings/array.h" #include "lib/fidl/cpp/bindings/string.h" namespace modular { inline std::string to_string(fidl::Array<uint8_t>& data) { std::string ret; ret.reserve(data.size()); for (uint8_t val : data) { ret += static_cast<char>(val); } return ret; } inline std::string to_hex_string(const fidl::Array<uint8_t>& data) { constexpr char kHexadecimalCharacters[] = "0123456789abcdef"; std::string ret; ret.reserve(data.size() * 2); for (unsigned char i : data) { ret.push_back(kHexadecimalCharacters[i >> 4]); ret.push_back(kHexadecimalCharacters[i & 0xf]); } return ret; } inline fidl::Array<uint8_t> to_array(const std::string& val) { fidl::Array<uint8_t> ret; for (char c : val) { ret.push_back(c); } return ret; } inline fidl::Array<fidl::String> to_array(const std::vector<std::string>& val) { fidl::Array<fidl::String> ret; ret.resize(0); // mark as not null for (const std::string& s : val) { ret.push_back(s); } return ret; } } // namespace modular #endif
23.293103
80
0.69356
[ "vector" ]
d52347c01c368c87d2575f38a55aae43c4f3b03d
2,972
h
C
OptimizelySDKUniversal/generated-frameworks/Release-tvOS-universal-SDK/OptimizelySDKTVOS.framework/Headers/OPTLYUserProfileService.h
flippinjoe/objective-c-sdk
be5fdde6bed86662c43f544c58b8184eda6f0c08
[ "Apache-2.0" ]
null
null
null
OptimizelySDKUniversal/generated-frameworks/Release-tvOS-universal-SDK/OptimizelySDKTVOS.framework/Headers/OPTLYUserProfileService.h
flippinjoe/objective-c-sdk
be5fdde6bed86662c43f544c58b8184eda6f0c08
[ "Apache-2.0" ]
null
null
null
OptimizelySDKUniversal/generated-frameworks/Release-tvOS-universal-SDK/OptimizelySDKTVOS.framework/Headers/OPTLYUserProfileService.h
flippinjoe/objective-c-sdk
be5fdde6bed86662c43f544c58b8184eda6f0c08
[ "Apache-2.0" ]
null
null
null
/**************************************************************************** * Copyright 2016-2018, Optimizely, Inc. and contributors * * * * 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. * ***************************************************************************/ #import <Foundation/Foundation.h> #import "OPTLYUserProfileServiceBuilder.h" @protocol OPTLYLogger, OPTLYUserProfileService; @interface OPTLYUserProfileServiceDefault : NSObject<OPTLYUserProfileService> /// Logger provided by the user @property (nonatomic, strong, nullable) id<OPTLYLogger> logger; /** * Initializer for Optimizely User Profile object * * @param builderBlock The builder block with which to initialize the Optimizely User Profile object * @return An instance of OPTLYUserProfileService */ + (nullable instancetype)init:(nonnull OPTLYUserProfileServiceBuilderBlock)builderBlock __attribute((deprecated("Use OPTLYManager initWithBuilder method instead."))); /** * Initializer for Optimizely User Profile object * * @param builder The OPTLYUserProfileServiceBuilder object with which to initialize the Optimizely User Profile object * @return An instance of OPTLYUserProfileService */ - (nullable instancetype)initWithBuilder:(nullable OPTLYUserProfileServiceBuilder *)builder; /** * Cleans and removes all bucketing mapping for specific userId. * @param userId The user ID to remove all bucketing value. **/ - (void)removeUserExperimentRecordsForUserId:(nonnull NSString *)userId; /** * Cleans and removes all bucketing mapping. **/ - (void)removeAllUserExperimentRecords; /** * Clean up and remove experiments that are not in the valid experiment list passed in. * This is called when initialized from a remote datafile to ensure that the UserProfileService * does not grow indefinitely. * @param validExperimentIds An array of valid experiment ids. If default user profile contains * experiments not in this list, they are removed from user profile service. **/ - (void)removeInvalidExperimentsForAllUsers:(NSArray<NSString *> *)validExperimentIds; @end
46.4375
119
0.636608
[ "object" ]
d5291f08e0870ecdef4c819a110ec4adc10a36b2
9,582
c
C
frame/3/trmm/3m/bli_trmm3m_cntl.c
tkelman/blis
ee2b679281ca45fb40b2198e293bc3bc3d446632
[ "BSD-3-Clause" ]
null
null
null
frame/3/trmm/3m/bli_trmm3m_cntl.c
tkelman/blis
ee2b679281ca45fb40b2198e293bc3bc3d446632
[ "BSD-3-Clause" ]
null
null
null
frame/3/trmm/3m/bli_trmm3m_cntl.c
tkelman/blis
ee2b679281ca45fb40b2198e293bc3bc3d446632
[ "BSD-3-Clause" ]
null
null
null
/* BLIS An object-based framework for developing high-performance BLAS-like libraries. Copyright (C) 2014, The University of Texas Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of The University of Texas nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "blis.h" extern scalm_t* scalm_cntl; extern blksz_t* gemm3m_mc; extern blksz_t* gemm3m_nc; extern blksz_t* gemm3m_kc; extern blksz_t* gemm3m_mr; extern blksz_t* gemm3m_nr; extern blksz_t* gemm3m_kr; extern func_t* gemm3m_ukrs; extern gemm_t* gemm3m_cntl_bp_ke; packm_t* trmm3m_l_packa_cntl; packm_t* trmm3m_l_packb_cntl; packm_t* trmm3m_r_packa_cntl; packm_t* trmm3m_r_packb_cntl; trmm_t* trmm3m_cntl_bp_ke; trmm_t* trmm3m_l_cntl_op_bp; trmm_t* trmm3m_l_cntl_mm_op; trmm_t* trmm3m_l_cntl_vl_mm; trmm_t* trmm3m_r_cntl_op_bp; trmm_t* trmm3m_r_cntl_mm_op; trmm_t* trmm3m_r_cntl_vl_mm; trmm_t* trmm3m_l_cntl; trmm_t* trmm3m_r_cntl; void bli_trmm3m_cntl_init() { // Create control tree objects for packm operations (left side). trmm3m_l_packa_cntl = bli_packm_cntl_obj_create( BLIS_BLOCKED, BLIS_VARIANT3, // IMPORTANT: for consistency with trsm, "k" dim // multiple is set to mr. gemm3m_mr, gemm3m_mr, TRUE, // densify FALSE, // do NOT invert diagonal FALSE, // reverse iteration if upper? FALSE, // reverse iteration if lower? BLIS_PACKED_ROW_PANELS_3M, BLIS_BUFFER_FOR_A_BLOCK ); trmm3m_l_packb_cntl = bli_packm_cntl_obj_create( BLIS_BLOCKED, BLIS_VARIANT3, // IMPORTANT: m dim multiple here must be mr // since "k" dim multiple is set to mr above. gemm3m_mr, gemm3m_nr, FALSE, // already dense FALSE, // do NOT invert diagonal FALSE, // reverse iteration if upper? FALSE, // reverse iteration if lower? BLIS_PACKED_COL_PANELS_3M, BLIS_BUFFER_FOR_B_PANEL ); // Create control tree objects for packm operations (right side). trmm3m_r_packa_cntl = bli_packm_cntl_obj_create( BLIS_BLOCKED, BLIS_VARIANT3, // IMPORTANT: for consistency with trsm, "k" dim // multiple is set to nr. gemm3m_mr, gemm3m_nr, FALSE, // already dense FALSE, // do NOT invert diagonal FALSE, // reverse iteration if upper? FALSE, // reverse iteration if lower? BLIS_PACKED_ROW_PANELS_3M, BLIS_BUFFER_FOR_A_BLOCK ); trmm3m_r_packb_cntl = bli_packm_cntl_obj_create( BLIS_BLOCKED, BLIS_VARIANT3, // IMPORTANT: m dim multiple here must be nr // since "k" dim multiple is set to nr above. gemm3m_nr, gemm3m_nr, TRUE, // densify FALSE, // do NOT invert diagonal FALSE, // reverse iteration if upper? FALSE, // reverse iteration if lower? BLIS_PACKED_COL_PANELS_3M, BLIS_BUFFER_FOR_B_PANEL ); // Create control tree object for lowest-level block-panel kernel. trmm3m_cntl_bp_ke = bli_trmm_cntl_obj_create( BLIS_UNB_OPT, BLIS_VARIANT2, NULL, gemm3m_ukrs, NULL, NULL, NULL, NULL, NULL, NULL, NULL ); // Create control tree object for outer panel (to block-panel) // problem (left side). trmm3m_l_cntl_op_bp = bli_trmm_cntl_obj_create( BLIS_BLOCKED, BLIS_VARIANT1, gemm3m_mc, NULL, NULL, trmm3m_l_packa_cntl, trmm3m_l_packb_cntl, NULL, trmm3m_cntl_bp_ke, gemm3m_cntl_bp_ke, NULL ); // Create control tree object for general problem via multiple // rank-k (outer panel) updates (left side). trmm3m_l_cntl_mm_op = bli_trmm_cntl_obj_create( BLIS_BLOCKED, BLIS_VARIANT3, gemm3m_kc, NULL, NULL, NULL, NULL, NULL, trmm3m_l_cntl_op_bp, NULL, NULL ); // Create control tree object for very large problem via multiple // general problems (left side). trmm3m_l_cntl_vl_mm = bli_trmm_cntl_obj_create( BLIS_BLOCKED, BLIS_VARIANT2, gemm3m_nc, NULL, NULL, NULL, NULL, NULL, trmm3m_l_cntl_mm_op, NULL, NULL ); // Create control tree object for outer panel (to block-panel) // problem (right side). trmm3m_r_cntl_op_bp = bli_trmm_cntl_obj_create( BLIS_BLOCKED, BLIS_VARIANT1, gemm3m_mc, NULL, NULL, trmm3m_r_packa_cntl, trmm3m_r_packb_cntl, NULL, trmm3m_cntl_bp_ke, gemm3m_cntl_bp_ke, NULL ); // Create control tree object for general problem via multiple // rank-k (outer panel) updates (right side). trmm3m_r_cntl_mm_op = bli_trmm_cntl_obj_create( BLIS_BLOCKED, BLIS_VARIANT3, gemm3m_kc, NULL, NULL, NULL, NULL, NULL, trmm3m_r_cntl_op_bp, NULL, NULL ); // Create control tree object for very large problem via multiple // general problems (right side). trmm3m_r_cntl_vl_mm = bli_trmm_cntl_obj_create( BLIS_BLOCKED, BLIS_VARIANT2, gemm3m_nc, NULL, NULL, NULL, NULL, NULL, trmm3m_r_cntl_mm_op, NULL, NULL ); // Alias the "master" trmm control trees to shorter names. trmm3m_l_cntl = trmm3m_l_cntl_vl_mm; trmm3m_r_cntl = trmm3m_r_cntl_vl_mm; } void bli_trmm3m_cntl_finalize() { bli_cntl_obj_free( trmm3m_l_packa_cntl ); bli_cntl_obj_free( trmm3m_l_packb_cntl ); bli_cntl_obj_free( trmm3m_r_packa_cntl ); bli_cntl_obj_free( trmm3m_r_packb_cntl ); bli_cntl_obj_free( trmm3m_cntl_bp_ke ); bli_cntl_obj_free( trmm3m_l_cntl_op_bp ); bli_cntl_obj_free( trmm3m_l_cntl_mm_op ); bli_cntl_obj_free( trmm3m_l_cntl_vl_mm ); bli_cntl_obj_free( trmm3m_r_cntl_op_bp ); bli_cntl_obj_free( trmm3m_r_cntl_mm_op ); bli_cntl_obj_free( trmm3m_r_cntl_vl_mm ); }
36.43346
76
0.526195
[ "object" ]
d52ac5be166dd317becb40cfd602e2c756a05bf9
12,058
c
C
src/application.c
snkkgp/Summer
4fd41f944cff311ddcb5c55cf8a533b72e0a8e6b
[ "MIT" ]
null
null
null
src/application.c
snkkgp/Summer
4fd41f944cff311ddcb5c55cf8a533b72e0a8e6b
[ "MIT" ]
null
null
null
src/application.c
snkkgp/Summer
4fd41f944cff311ddcb5c55cf8a533b72e0a8e6b
[ "MIT" ]
null
null
null
//------------------------------------------------------------------- // // TANKS TO: // ---------------------------------------------- // // 01: God the creator of the heavens and the earth in the name of Jesus Christ. // // 02 - Fabrice Bellard: www.bellard.org // // ---------------------------------------------- // // THIS FILE IS PART OF SUMMER LANGUAGE: // // Summer Application API: // // FILE: // application.c // // SUMMER LANGUAGE START DATE ( 27/08/2017 - 08:35 ): // rewrite: 20/07/2018 - 11:10 // // BY: Francisco - gokernel@hotmail.com // //------------------------------------------------------------------- // // Windows Max Mem: 22.140 // #include "summer.h" #include <GL/gl.h> // // Only WIN32 Implementation ... Please Wait for LInux ... // #ifdef USE_APPLICATION //HINSTANCE WindowInstance = nullptr; //void *nullptr; static TEvent *_event_; static int count; static const char ClassName[] = "Summer_Object_Class"; static int WindowCount; static int running; static HDC hDC; static HGLRC hRC; OBJECT win; void EnableOpenGL (HWND hWnd, HDC *hDC, HGLRC *hRC) { PIXELFORMATDESCRIPTOR pfd; int iFormat; /* get the device context (DC) */ *hDC = GetDC (hWnd); /* set the pixel format for the DC */ ZeroMemory (&pfd, sizeof (pfd)); pfd.nSize = sizeof (pfd); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 24; pfd.cDepthBits = 16; pfd.iLayerType = PFD_MAIN_PLANE; iFormat = ChoosePixelFormat (*hDC, &pfd); SetPixelFormat (*hDC, iFormat, &pfd); /* create and enable the render context (RC) */ *hRC = wglCreateContext( *hDC ); wglMakeCurrent(*hDC, *hRC); } typedef struct { int type; // void (*call) (TEvent *evevt); void (*onclick) (TEvent *event); void (*onmousemove) (TEvent *event); void (*onmousedown) (TEvent *event); void (*onmouseup) (TEvent *event); void *info; // any information to object }DATA_OBJECT; #ifdef WIN32 LRESULT CALLBACK WindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_CREATE: WindowCount++; break; case WM_DESTROY: WindowCount--; if (!WindowCount) { running = 0; PostQuitMessage (0); // exit of program if not windows ... } break; case WM_RBUTTONDOWN: case WM_RBUTTONUP: case WM_LBUTTONDOWN: case WM_LBUTTONUP: { DATA_OBJECT *data = (DATA_OBJECT*)GetWindowLongPtr (hwnd, GWLP_USERDATA); if (data) { POINT p; if (msg==WM_LBUTTONDOWN) SetCapture(hwnd); if (msg==WM_LBUTTONUP) ReleaseCapture(); // int x=lParam&0xffff; // int y=(lParam&0xffff0000)>>16; GetCursorPos(&p); // _event_->x = lParam&0xffff;//LOWORD(lParam); // _event_->y = (lParam&0xffff0000)>>16;//HIWORD(lParam); _event_->x = p.x; _event_->y = p.y; if (data->onmousedown && (msg==WM_LBUTTONDOWN || msg==WM_RBUTTONDOWN)) { if (msg==WM_LBUTTONDOWN) Gvar [VAR_MB].value.i = 1; else Gvar [VAR_MB].value.i = 2; data->onmousedown(_event_); } else if (data->onmouseup && (msg==WM_LBUTTONUP || msg==WM_RBUTTONUP)) { Gvar [VAR_MB].value.i = 0; data->onmouseup(_event_); } } } break; case WM_MOUSEMOVE: { DATA_OBJECT *data = (DATA_OBJECT*)GetWindowLongPtr (hwnd, GWLP_USERDATA); if (data && data->onmousemove) { Gvar [VAR_OBJECT].value.p = hwnd; Gvar [VAR_MX].value.i = LOWORD(lParam); Gvar [VAR_MY].value.i = HIWORD(lParam); _event_->type = MOUSEMOVE; // WM_MOUSEMOVE; _event_->x = LOWORD(lParam); _event_->y = HIWORD(lParam); data->onmousemove(_event_); } } break; case WM_COMMAND: // not a menu if (lParam != 0) break; if (HIWORD(wParam) != 0) break; { printf ("WM_COMMAND: %d\n", count++); /* DATA_OBJECT *data = (DATA_OBJECT*)GetWindowLongPtr (hwnd, GWLP_USERDATA); if (data && data->call) { _event_->type = EV_MENU; _event_->x = LOWORD(wParam); // menu index id data->call(_event_); } */ } break; default: return DefWindowProc (hwnd, msg, wParam, lParam); } return 0; }// WindowProc() #endif // ! WIN32 #ifdef WIN32 static LONG_PTR origButtonProc; static LRESULT CALLBACK ButtonProc (OBJECT hwnd, int msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_LBUTTONUP) { int mx = (short)LOWORD(lParam); int my = (short)HIWORD(lParam); if (mx > 0 && my > 0) { RECT r; GetWindowRect (hwnd, &r); DATA_OBJECT *data = (DATA_OBJECT*)GetWindowLongPtr (hwnd, GWLP_USERDATA); if ((mx < r.right-r.left && my < r.bottom-r.top) && data && data->onclick) { _event_->type = 0;//EV_ZERO; _event_->id = GetDlgCtrlID(hwnd); data->onclick (_event_); } } } return CallWindowProc ((WNDPROC)origButtonProc, hwnd, msg, wParam, lParam); } #endif // WIN32 OBJECT AppNewWindow (OBJECT parent, int x, int y, int w, int h, char *text) { OBJECT o; #ifdef WIN32 int flags = WS_VISIBLE | WS_OVERLAPPEDWINDOW; o = CreateWindowEx ( 0, ClassName, // classname text, // Title text flags, //WS_OVERLAPPEDWINDOW | WS_THICKFRAME | WS_CLIPCHILDREN, //flags, // WS_OVERLAPPEDWINDOW x, y, w, h, // x, y, w, h HWND_DESKTOP, // parent NULL, // id GetModuleHandle(NULL), // Program Instance handler NULL // No Window Creation data ); DATA_OBJECT *data = (DATA_OBJECT*) malloc (sizeof(DATA_OBJECT)); if (data) { data->onclick = NULL; data->onmousemove = NULL; data->onmousedown = NULL; data->onmouseup = NULL; // Set the DATA SetWindowLongPtr (o, GWLP_USERDATA, (LONG_PTR)data); } #endif #ifdef __linux__ printf ("AppNewWindow no implemented in Linux\n"); #endif return o; } OBJECT AppNewRenderGL (OBJECT parent, int x, int y, int w, int h, char *text) { // OBJECT o; #ifdef WIN32 int style = WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_VISIBLE; //WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX; int styleFS = WS_POPUP|WS_VISIBLE; //WS_POPUP int flags = WS_VISIBLE | WS_OVERLAPPEDWINDOW; win = CreateWindowEx ( 0, ClassName, // classname text, // Title text // WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE, style, x,y, w, h, HWND_DESKTOP, // parent NULL, // id GetModuleHandle(NULL), // Program Instance handler NULL // No Window Creation data ); EnableOpenGL (win, &hDC, &hRC); DATA_OBJECT *data = (DATA_OBJECT*) malloc (sizeof(DATA_OBJECT)); if (data) { data->onclick = NULL; data->onmousemove = NULL; data->onmousedown = NULL; data->onmouseup = NULL; // Set the DATA SetWindowLongPtr (win, GWLP_USERDATA, (LONG_PTR)data); } #endif #ifdef __linux__ printf ("AppNewWindow no implemented in Linux\n"); #endif return win; } OBJECT AppNewButton (OBJECT parent, int x, int y, int w, int h, char *text) { OBJECT o; #ifdef WIN32 int flags = WS_VISIBLE | WS_CHILD; o = CreateWindowEx ( 0, "button", // classname text, // Title text flags, x, y, w, h, // x, y, w, h parent, // parent (HMENU)100, // id GetModuleHandle(NULL), // Program Instance handler NULL // No Window Creation data ); // SendMessage (o, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), (LPARAM)TRUE); DATA_OBJECT *data = (DATA_OBJECT*) malloc (sizeof(DATA_OBJECT)); if (data) { data->onclick = NULL; data->onmousemove = NULL; data->onmousedown = NULL; data->onmouseup = NULL; // Set the PROC end DATA origButtonProc = SetWindowLongPtr (o, GWLP_WNDPROC, (LONG_PTR)ButtonProc); SetWindowLongPtr (o, GWLP_USERDATA, (LONG_PTR)data); } #endif // WIN32 return o; } void AppSetCall (OBJECT o, void(*call)(TEvent *evevt), char *type) { if (o && call && type) { DATA_OBJECT *data = (DATA_OBJECT*)GetWindowLongPtr (o, GWLP_USERDATA); if (data) { if (!strcmp(type, "onmousemove")) data->onmousemove = call; if (!strcmp(type, "onmousedown")) data->onmousedown = call; if (!strcmp(type, "onmouseup")) data->onmouseup = call; } } } int AppInit (int argc, char **argv) { static int init = 0; if (init) return 1; init = 1; printf ("\nApplication, WIN32 Inplementation: AppInit(): %d\n", GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if ((_event_ = (TEvent*)malloc(sizeof(TEvent))) == NULL) return 0; _event_->type = _event_->value = _event_->id = _event_->x = _event_->y = 0; #ifdef WIN32 WNDCLASSEX wc; // InitCommonControls(); wc.hInstance = GetModuleHandle(NULL); wc.lpszClassName = ClassName; wc.lpfnWndProc = WindowProc; wc.style = CS_DBLCLKS; //wc.style = CS_HREDRAW | CS_VREDRAW; wc.cbSize = sizeof(WNDCLASSEX); // Use default icon and mouse-pointer wc.hIcon = LoadIcon (NULL, IDI_APPLICATION); wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.lpszMenuName = NULL; // No menu wc.cbClsExtra = 0; // No extra bytes after the window class wc.cbWndExtra = 0; // structure or the window instance wc.hbrBackground = (HBRUSH) COLOR_BACKGROUND+1; // Register the window class, and if it fails quit the program if (!RegisterClassEx(&wc)) { MessageBox (0, "Class Register Nor Found", "Sorry ERRO:", MB_ICONINFORMATION); return 0; } #endif // WIN32 timeBeginPeriod (1); return 1; }// AppInit() void AppRender (void) { SwapBuffers (hDC); glClearColor (0.0, 0.0, 0.0, 0.0); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // GL_COLOR_BUFFER_BIT); /* glClearColor (0.0f, 0.0f, 0.0f, 0.0f); glClear (GL_COLOR_BUFFER_BIT); */ } void DisableOpenGL (HWND hWnd, HDC hDC, HGLRC hRC) { wglMakeCurrent (NULL, NULL); wglDeleteContext (hRC); ReleaseDC (hWnd, hDC); } void AppRun (void(*idle)(void)) { printf ("\nApplication, WIN32 Inplementation: AppRun();\n"); if (running) return; running = 1; #ifdef WIN32 MSG msg; if (idle) { for (;;) { if (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage (&msg); DispatchMessage (&msg); } if (running==0) return; idle (); } } else { while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg); DispatchMessage (&msg); } } DisableOpenGL (win, hDC, hRC); #endif // WIN32 }// AppRun () #endif // ! USE_APPLICATION
27.280543
121
0.539144
[ "render", "object" ]
d53b8046ba4ee2f35ca454abd5e8fa3ee58e81ee
13,121
c
C
sample/framework/vx_khr_user_data_object.c
JohnZ03/OpenVX-sample-impl
0dd99dfb55cf3f195c8c6880fd6f5da5b7f8fde0
[ "Apache-2.0" ]
96
2018-12-06T18:44:57.000Z
2022-03-22T04:37:14.000Z
sample/framework/vx_khr_user_data_object.c
JohnZ03/OpenVX-sample-impl
0dd99dfb55cf3f195c8c6880fd6f5da5b7f8fde0
[ "Apache-2.0" ]
40
2018-12-05T16:00:49.000Z
2022-03-04T07:58:34.000Z
sample/framework/vx_khr_user_data_object.c
JohnZ03/OpenVX-sample-impl
0dd99dfb55cf3f195c8c6880fd6f5da5b7f8fde0
[ "Apache-2.0" ]
43
2019-02-24T15:17:50.000Z
2022-03-26T23:20:59.000Z
/* * Copyright (c) 2012-2017 The Khronos Group Inc. * * 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. */ /* * * Copyright (c) 2018 Texas Instruments Incorporated * */ #ifdef OPENVX_USE_USER_DATA_OBJECT #include <vx_internal.h> /*============================================================================== User Data Object HELPER FUNCTIONS =============================================================================*/ static vx_bool ownAllocateUserDataObject(vx_user_data_object user_data_object); static vx_bool ownAllocateUserDataObject(vx_user_data_object user_data_object) { vx_bool res = vx_false_e; if (user_data_object->size > 0) { res = ownAllocateMemory(user_data_object->base.context, &user_data_object->memory); } return res; } void ownDestructUserDataObject(vx_reference ref) { vx_user_data_object user_data_object = (vx_user_data_object)ref; ownFreeMemory(user_data_object->base.context, &user_data_object->memory); } /*============================================================================== User Data Object API FUNCTIONS =============================================================================*/ VX_API_ENTRY vx_user_data_object VX_API_CALL vxCreateUserDataObject( vx_context context, const vx_char *type_name, vx_size size, const void *ptr) { vx_status status = (vx_status)VX_SUCCESS; vx_user_data_object user_data_object = NULL; if(ownIsValidContext(context) == (vx_bool)vx_true_e) { if (size < 1U) { VX_PRINT(VX_ZONE_ERROR, "Invalid size for the user data object.\n"); user_data_object = (vx_user_data_object)ownGetErrorObject((vx_context)context, (vx_status)VX_ERROR_INVALID_PARAMETERS); } if( NULL == user_data_object ) { user_data_object = (vx_user_data_object)ownCreateReference(context, VX_TYPE_USER_DATA_OBJECT, (vx_enum)VX_EXTERNAL, &context->base); if ((vxGetStatus((vx_reference)user_data_object) == (vx_status)VX_SUCCESS) && (user_data_object->base.type == VX_TYPE_USER_DATA_OBJECT)) { user_data_object->size = size; /* Initialize string with zeros, which safely fills with null terminators */ user_data_object->type_name[0] = (char)0; if (type_name != NULL) { strncpy(user_data_object->type_name, type_name,VX_MAX_REFERENCE_NAME); } user_data_object->memory.nptrs = 1; user_data_object->memory.ndims = 1; user_data_object->memory.dims[0][0] = (vx_uint32)size; if (NULL != ptr) { status = vxCopyUserDataObject(user_data_object, 0, size, (void*)ptr, (vx_enum)VX_WRITE_ONLY, (vx_enum)VX_MEMORY_TYPE_HOST); } else { ownAllocateUserDataObject(user_data_object); if (status == (vx_status)VX_SUCCESS) { vx_uint8 *start_ptr = (vx_uint8 *)&user_data_object->memory.ptrs[0][0]; memset(start_ptr, 0, size); } } } if(status != (vx_status)VX_SUCCESS) { user_data_object = (vx_user_data_object)ownGetErrorObject( context, (vx_status)VX_ERROR_INVALID_PARAMETERS); } } } return (user_data_object); } VX_API_ENTRY vx_status VX_API_CALL vxReleaseUserDataObject(vx_user_data_object *user_data_object) { return (ownReleaseReferenceInt( (vx_reference*)user_data_object, VX_TYPE_USER_DATA_OBJECT, (vx_enum)VX_EXTERNAL, NULL)); } VX_API_ENTRY vx_status VX_API_CALL vxQueryUserDataObject ( vx_user_data_object user_data_object, vx_enum attribute, void *ptr, vx_size size) { vx_status status = (vx_status)VX_SUCCESS; if (ownIsValidSpecificReference(&user_data_object->base, VX_TYPE_USER_DATA_OBJECT) == (vx_bool)vx_false_e) { VX_PRINT(VX_ZONE_ERROR,"vxQueryUserDataObject failed\n"); VX_PRINT(VX_ZONE_ERROR,"Reference is invalid or object descriptor is NULL\n"); status = (vx_status)VX_ERROR_INVALID_REFERENCE; } else { switch (attribute) { case (vx_enum)VX_USER_DATA_OBJECT_NAME: if ((ptr != NULL) && ((vx_enum)size >= VX_MAX_REFERENCE_NAME)) { strncpy(ptr, user_data_object->type_name, VX_MAX_REFERENCE_NAME); } else { VX_PRINT(VX_ZONE_ERROR, "VX_USER_DATA_OBJECT_NAME failed\n"); status = (vx_status)VX_ERROR_INVALID_PARAMETERS; } break; case (vx_enum)VX_USER_DATA_OBJECT_SIZE: if (VX_CHECK_PARAM(ptr, size, vx_size, 0x3U)) { *(vx_size *)ptr = user_data_object->size; } else { VX_PRINT(VX_ZONE_ERROR, "VX_USER_DATA_OBJECT_SIZE failed\n"); status = (vx_status)VX_ERROR_INVALID_PARAMETERS; } break; default: VX_PRINT(VX_ZONE_ERROR,"query user data object option not supported\n"); status = (vx_status)VX_ERROR_NOT_SUPPORTED; break; } } return status; } VX_API_ENTRY vx_status VX_API_CALL vxCopyUserDataObject(vx_user_data_object user_data_object, vx_size offset, vx_size size, void *user_ptr, vx_enum usage, vx_enum user_mem_type) { vx_status status = (vx_status)VX_SUCCESS; vx_uint8 *start_ptr; if ((ownIsValidSpecificReference(&user_data_object->base, VX_TYPE_USER_DATA_OBJECT) == (vx_bool)vx_false_e)) { VX_PRINT(VX_ZONE_ERROR, "Invalid user data object reference\n"); status = (vx_status)VX_ERROR_INVALID_REFERENCE; } else { if ((vx_enum)VX_MEMORY_TYPE_HOST != user_mem_type) { VX_PRINT(VX_ZONE_ERROR, "User mem type is not equal to VX_MEMORY_TYPE_HOST\n"); status = (vx_status)VX_ERROR_INVALID_PARAMETERS; } /* Memory still not allocated */ if (((vx_enum)VX_READ_ONLY == usage) && ((uint64_t)(uintptr_t)NULL == (uintptr_t)user_data_object->memory.ptrs[0])) { VX_PRINT(VX_ZONE_ERROR, "Memory is not allocated\n"); status = (vx_status)VX_ERROR_INVALID_PARAMETERS; } if (NULL == user_ptr) { VX_PRINT(VX_ZONE_ERROR, "Invalid NULL pointer\n"); status = (vx_status)VX_ERROR_INVALID_PARAMETERS; } if ((size < 1U) || ((offset + size) > user_data_object->size)) { VX_PRINT(VX_ZONE_ERROR, "Invalid offset or size parameter\n"); status = (vx_status)VX_ERROR_INVALID_PARAMETERS; } } if ((vx_status)VX_SUCCESS == status) { if (ownAllocateUserDataObject(user_data_object) == vx_false_e) { return VX_ERROR_NO_MEMORY; } } if (status == (vx_status)VX_SUCCESS) { /* Get the offset to the free memory */ start_ptr = (vx_uint8 *)&user_data_object->memory.ptrs[0][offset]; /* Copy from internal object to user memory */ if ((vx_enum)VX_READ_ONLY == usage) { memcpy(user_ptr, start_ptr, size); } else /* Copy from user memory to internal object */ { memcpy(start_ptr, user_ptr, size); } } return (status); } VX_API_ENTRY vx_status VX_API_CALL vxMapUserDataObject( vx_user_data_object user_data_object, vx_size offset, vx_size size, vx_map_id *map_id, void **ptr, vx_enum usage, vx_enum mem_type, vx_uint32 flags) { vx_status status = (vx_status)VX_SUCCESS; if ((ownIsValidSpecificReference(&user_data_object->base, VX_TYPE_USER_DATA_OBJECT) == (vx_bool)vx_false_e)) { VX_PRINT(VX_ZONE_ERROR, "Invalid user data object reference\n"); status = (vx_status)VX_ERROR_INVALID_REFERENCE; } if(status == (vx_status)VX_SUCCESS) { if (ptr == NULL) { VX_PRINT(VX_ZONE_ERROR, "User pointer is null\n"); status = (vx_status)VX_ERROR_INVALID_PARAMETERS; } if (map_id == NULL) { VX_PRINT(VX_ZONE_ERROR, "Map ID is null\n"); status = (vx_status)VX_ERROR_INVALID_PARAMETERS; } } if(status == (vx_status)VX_SUCCESS) { if (((offset + size) > user_data_object->size)) { VX_PRINT(VX_ZONE_ERROR, "Invalid offset or size parameter\n"); status = (vx_status)VX_ERROR_INVALID_PARAMETERS; } } if ((vx_status)VX_SUCCESS == status) { if (ownAllocateUserDataObject(user_data_object) == vx_false_e) { return VX_ERROR_NO_MEMORY; } } if ((vx_status)VX_SUCCESS == status) { vx_memory_map_extra extra; extra.array_data.start = offset; extra.array_data.end = offset + size; vx_uint8 *buf = NULL; if (ownMemoryMap(user_data_object->base.context, (vx_reference)user_data_object, size, usage, mem_type, flags, &extra, (void **)&buf, map_id) == vx_true_e) { if (VX_READ_ONLY == usage || VX_READ_AND_WRITE == usage) { if (ownSemWait(&user_data_object->memory.locks[0]) == vx_true_e) { vx_uint8 *pSrc = (vx_uint8 *)&user_data_object->memory.ptrs[0][offset]; vx_uint8 *pDst = (vx_uint8 *)buf; memcpy(pDst, pSrc, size); *ptr = buf; ownIncrementReference(&user_data_object->base, VX_EXTERNAL); ownSemPost(&user_data_object->memory.locks[0]); status = VX_SUCCESS; } else { status = VX_ERROR_NO_RESOURCES; } } else { /* write only mode */ *ptr = buf; ownIncrementReference(&user_data_object->base, VX_EXTERNAL); status = VX_SUCCESS; } } else { status = VX_FAILURE; } } return (status); } VX_API_ENTRY vx_status VX_API_CALL vxUnmapUserDataObject(vx_user_data_object user_data_object, vx_map_id map_id) { vx_status status = (vx_status)VX_SUCCESS; if ((ownIsValidSpecificReference(&user_data_object->base, VX_TYPE_USER_DATA_OBJECT) == (vx_bool)vx_false_e)) { VX_PRINT(VX_ZONE_ERROR, "Invalid user data object reference\n"); status = (vx_status)VX_ERROR_INVALID_REFERENCE; } if(status == (vx_status)VX_SUCCESS) { vx_context context = user_data_object->base.context; vx_memory_map_t* map = &context->memory_maps[map_id]; if (map->used && map->ref == (vx_reference)user_data_object) { vx_size start = map->extra.array_data.start; vx_size end = map->extra.array_data.end; if (VX_WRITE_ONLY == map->usage || VX_READ_AND_WRITE == map->usage) { if (ownSemWait(&user_data_object->memory.locks[0]) == vx_true_e) { vx_uint32 offset = (vx_uint32)start; vx_uint8 *pSrc = (vx_uint8 *)map->ptr; vx_uint8 *pDst = (vx_uint8 *)&user_data_object->memory.ptrs[0][offset]; vx_size size = (end - start); memcpy(pDst, pSrc, size); ownMemoryUnmap(context, (vx_uint32)map_id); ownDecrementReference(&user_data_object->base, VX_EXTERNAL); ownSemPost(&user_data_object->memory.locks[0]); status = VX_SUCCESS; } else { status = VX_ERROR_NO_RESOURCES; } } else { /* read only mode */ ownMemoryUnmap(user_data_object->base.context, (vx_uint32)map_id); ownDecrementReference(&user_data_object->base, VX_EXTERNAL); status = VX_SUCCESS; } } else { status = VX_FAILURE; } } return status; } #endif /* OPENVX_USE_USER_DATA_OBJECT */
33.471939
163
0.576176
[ "object" ]
d544a6d82f8176b7baf0f0c56c0fcb371b06db9f
2,993
h
C
include/PhaseMapper.h
shieldai/AdaptiveShielding
d281b5541139a3e9e6de003392790bb2298075c6
[ "MIT" ]
null
null
null
include/PhaseMapper.h
shieldai/AdaptiveShielding
d281b5541139a3e9e6de003392790bb2298075c6
[ "MIT" ]
null
null
null
include/PhaseMapper.h
shieldai/AdaptiveShielding
d281b5541139a3e9e6de003392790bb2298075c6
[ "MIT" ]
null
null
null
#ifndef INCLUDE_PHASEMAPPER_H_ #define INCLUDE_PHASEMAPPER_H_ #include <vector> #include <string> #include <map> #include "ISimulationObject.h" class ISumo; /** @class PhaseMapper * */ class PhaseMapper : ISimulationObject { ISumo *sumo{}; std::string tlsID; std::vector<struct phaseInfo> phases; /// @brief Map SUMO phase ID to internal phase ID. std::map<int, int> sumoPhaseIDtoPhaseID; /// @brief Map internal phase ID (= vector index) to SUMO phase ID (= vector value). std::vector<int> sumoPhaseID; /// @brief Map SUMO phase ID to the phase duration. std::map<int, double> sumoPhaseIDtoDuration; /// @brief Map internal phase ID to the phase duration. std::map<int, double> phaseIDtoDuration; /// @brief Internal STATIC Controller (shadows real) to correctly restore. int controllerPhase{0}; int controllerSumoPhase{0}; int phaseDurationCountdown{0}; int sumoPhaseDurationCountdown{0}; public: PhaseMapper() = default; /** @brief Constructor for the PhaseMapper Class. * * @param sumo Pointer to a SUMOConnector instance. * @param tls_id String with the current SUMO Traffic Light ID. * @param links A list of lists with Strings which represents the links, similar to SUMO links but formatted. */ PhaseMapper(ISumo *sumo, const std::string &tls_id, const std::vector<std::vector<std::string>> &links); /// @brief Step method, should be called in each tie step, updates the internal static controller. void step() override; /** @brief Get all lane labels of junction which will be controlled. * * @param links A list of lists with Strings which represents the links, similar to SUMO links but formatted. * @param state A string with the SUMO state string. * @return A list with String off all used lanes. */ std::vector<std::string> getActiveLaneLabels(const std::vector<std::vector<std::string>> &links, const std::string &state); /** @brief Get controller phases as vector of phase info structs. * * @return A list of phase info structs. */ const std::vector<struct phaseInfo> &getPhases(); /** @ Get the internally shadowed controller value. * * @return A Integer with the shadowed internal controller value. */ int getControllerPhase() const; /** @brief Get the current controller phase ID in SUMO format. * * @return SUMO phase index. */ int getSumoPhaseID(int phaseID) const; /** @brief Get the current controller phase ID in internal format. * * @return INTERNAL phase index. */ int getPhaseID() const; /** @brief Set the current controller phase ID in internal format. * * @param phaseID A Integer with the next internal phase ID. */ void setPhaseID(int phaseID) const; /// @brief Reset controller with internally shadowed values. void restoreController(); /// @brief Reset controller program to default. void resetProgram(); }; #endif //INCLUDE_PHASEMAPPER_H_
30.85567
111
0.698964
[ "vector" ]
d5489a2f1d69aa14177b7a100fe1815e357117d9
7,110
c
C
mysource/filesimple.c
jongyook2/jsmn
14763ec84dc35f9509c694179f08fc9311a15634
[ "MIT" ]
null
null
null
mysource/filesimple.c
jongyook2/jsmn
14763ec84dc35f9509c694179f08fc9311a15634
[ "MIT" ]
null
null
null
mysource/filesimple.c
jongyook2/jsmn
14763ec84dc35f9509c694179f08fc9311a15634
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "../jsmn.h" /* * A small example of jsmn parsing when JSON structure is known and number of * tokens is predictable. */ char *readJSONFILE(char *file){ FILE *fp; char input[256]; int len = 0; strcat(file,".json"); fp = fopen(file , "rt"); if(fp==NULL){printf("%s 파일이 존재하지 않습니다\n",file); exit(1);} char *save = (char *)malloc(sizeof(char) * 256); while(1){ fgets(input , sizeof(input) , fp); if( feof(fp) ) { break ; } len += strlen(input); save= realloc(save, len + 1); strcat(save, input); //malloc, ralloc } //printf("%s\n", JSON_STRING); fclose(fp); return save; } static int jsoneq(const char *json, jsmntok_t *tok, const char *s) { if (tok->type == JSMN_STRING && (int) strlen(s) == tok->end - tok->start && strncmp(json + tok->start, s, tok->end - tok->start) == 0) { return 0; } return -1; } void jsonNameList(char *jsontr, jsmntok_t *t, int tokcount,int *nameTokIndex){ //printf("***** Name List ******\n"); int i; int j=0; for (i = 1; i < tokcount; i++) { if(t[i].type==JSMN_STRING){ if(t[i].size>0){ //if(t[i].parent!){ nameTokIndex[j]=i; ++j; // if(t[i].parent==0){ // // printf("[Name %d] %.*s\n",j,t[i].end-t[i].start,jsontr + t[i].start); } } } } void printNameList(char *jsontr, jsmntok_t *t, int *nameTokIndex,int *nt){ int i=0,j=1; int temp=0; if(t[t[t[t[nameTokIndex[1]].parent].parent].parent].type==JSMN_STRING){ temp=t[nameTokIndex[1]].parent; } else{ temp=t[nameTokIndex[0]].parent;} printf("***** Name List ******\n"); while(nameTokIndex[i]!=0){ if(t[t[nameTokIndex[i]].parent].parent==t[temp].parent){ nt[j-1]=nameTokIndex[i]; printf("[Name %d] %.*s\n",j,t[nameTokIndex[i]].end-t[nameTokIndex[i]].start,jsontr + t[nameTokIndex[i]].start); j++; } ++i; } } void selectNameList(char *jsontr, jsmntok_t *t, int *nameTokIndex){ int num; while(1){ printf("select Name's no (exit:0) >> "); scanf("%d",&num); if(num==0){return ;} if(nameTokIndex[num-1]==0) {printf("not correct name number retry!"); continue;} printf("[Name %d] %.*s\n",num,t[nameTokIndex[num-1]].end-t[nameTokIndex[num-1]].start,jsontr + t[nameTokIndex[num-1]].start); printf("%.*s\n",t[nameTokIndex[num-1]+1].end-t[nameTokIndex[num-1]+1].start,jsontr + t[nameTokIndex[num-1]+1].start); } } void ObjectNameList(char *jsontr, jsmntok_t *t, int *nameTokIndex, int *objectList){ printf("***** Object List ******\n"); int i=0; int j=1; int index=0; int temp=0; int *a; if(t[t[t[t[nameTokIndex[1]].parent].parent].parent].type==JSMN_STRING){ temp=t[t[nameTokIndex[1]].parent].parent; } else{ temp=t[t[nameTokIndex[0]].parent].parent;} while(nameTokIndex[i]!=0){ index=nameTokIndex[i]; if(t[index-1].parent==temp){ //printf("%d\n",temp); objectList[j-1]=index-1; objectList=(int *)realloc(objectList,sizeof(int)*(j+1)); printf("[Name %d] %.*s\n",j,t[index+1].end-t[index+1].start,jsontr + t[index+1].start); j++; } i++; } } // void check(jsmntok_t *t, int *objectList, int *nameTokIndex, int *nt, int **ntD){ // ntD=(int *)malloc(sizeof(int)*(sizeof(objectList)/sizeof(int))); // // for() // if(t[nt[i]].parent==objectList[]) // a++; // else if() // } // } void printSelectObjectNameList(char *jsontr,jsmntok_t *t, int *objectList,int *nameTokIndex, int *nt){ int num=0; int j=0; int k=0; //while(1){ printf("원하는 번호 입력 (Exit: 0) : "); scanf("%d",&num); int i=0; if(num==0){ return;} int o1=objectList[num-1]; while(nt[i]!=0){ if(t[nt[i]].parent==o1){ break; } i++; } printf("%.*s : %.*s\n",t[o1+1].end-t[o1+1].start,jsontr + t[o1+1].start,t[o1+2].end-t[o1+2].start,jsontr + t[o1+2].start); while(nt[i+1]!=0){ if(t[nt[i+1]].parent==o1){ printf("\t[%.*s]\t%.*s\n",t[nt[i+1]].end-t[nt[i+1]].start,jsontr + t[nt[i+1]].start,t[nt[i+1]+1].end-t[nt[i+1]+1].start,jsontr + t[nt[i+1]+1].start); } i++; } //} } //checking int main() { int i; int r; int *k; jsmn_parser p; char name[20]; jsmntok_t t[128]; /* We expect no more than 128 tokens */ int *objectList = (int *)malloc(sizeof(int)); int nameTokIndex[200]={0}; int nt[20]={0}; //while(1){ printf("원하는 파일명 입력: "); scanf("%s",name); char *JSON_STRING=readJSONFILE(name); jsmn_init(&p); r = jsmn_parse(&p, JSON_STRING, strlen(JSON_STRING), t, sizeof(t)/sizeof(t[0])); // printf("%d\n",t[t[2].parent].parent); // printf("%d\n",t[20].parent); jsonNameList(JSON_STRING,t,r,nameTokIndex); printNameList(JSON_STRING,t,nameTokIndex,nt); //selectNameList(JSON_STRING,t,nameTokIndex); ObjectNameList(JSON_STRING,t,nameTokIndex,objectList); printSelectObjectNameList(JSON_STRING,t,objectList,nameTokIndex,nt); //} //printf("%d",strlen(nameTokIndex)); // if (r < 0) { // printf("Failed to parse JSON: %d\n", r); // return 1; // } // // /* Assume the top-level element is an object */ // if (r < 1 || t[0].type != JSMN_OBJECT) { // printf("Object expected\n"); // return 1; // } // // /* Loop over all keys of the root object */ // for (i = 1; i < r; i++) { // if (jsoneq(JSON_STRING, &t[i], "name") == 0) { // /* We may use strndup() to fetch string value */ // printf("- name: %.*s\n", t[i+1].end-t[i+1].start, // JSON_STRING + t[i+1].start); // i++; // } else if (jsoneq(JSON_STRING, &t[i], "keywords") == 0) { // /* We may additionally check if the value is either "true" or "false" */ // printf("- keywords: %.*s\n", t[i+1].end-t[i+1].start, // JSON_STRING + t[i+1].start); // i++; // } else if (jsoneq(JSON_STRING, &t[i], "description") == 0) { // /* We may want to do strtol() here to get numeric value */ // printf("- UID: %.*s\n", t[i+1].end-t[i+1].start, // JSON_STRING + t[i+1].start); // i++; // } else if (jsoneq(JSON_STRING, &t[i], "examples") == 0) { // /* We may want to do strtol() here to get numeric value */ // printf("examples:\n"); // int j; // if (t[i+1].type != JSMN_ARRAY) { // continue; /* We expect groups to be an array of strings */ // } // for (j = 0; j < t[i+1].size; j++) { // jsmntok_t *g = &t[i+j+2]; // printf(" * %.*s\n", g->end - g->start, JSON_STRING + g->start); // } // i += t[i+1].size + 1; // // } // /*} else if (jsoneq(JSON_STRING, &t[i], "examples") == 0) { // int j; // printf("- Groups:\n"); // if (t[i+1].type != JSMN_ARRAY) { // continue; /* We expect groups to be an array of strings */ // /* } // for (j = 0; j < t[i+1].size; j++) { // jsmntok_t *g = &t[i+j+2]; // printf(" * %.*s\n", g->end - g->start, JSON_STRING + g->start); // } // i += t[i+1].size + 1; // } else { // printf("Unexpected key: %.*s\n", t[i].end-t[i].start, // JSON_STRING + t[i].start); // }*/ // } free(objectList); return EXIT_SUCCESS; }
27.882353
153
0.555134
[ "object" ]
d55e5608bc27daf86149a77b2cb74010555bd844
1,932
h
C
src/source.h
DarkDefender/imv
2d0cbfcb8504c5b7be8513ae9ff19990c0a189f3
[ "MIT" ]
null
null
null
src/source.h
DarkDefender/imv
2d0cbfcb8504c5b7be8513ae9ff19990c0a189f3
[ "MIT" ]
null
null
null
src/source.h
DarkDefender/imv
2d0cbfcb8504c5b7be8513ae9ff19990c0a189f3
[ "MIT" ]
null
null
null
#ifndef IMV_SOURCE_H #define IMV_SOURCE_H #include <pthread.h> #include <stdbool.h> #include "image.h" struct imv_source_message { /* Pointer to sender of message */ struct imv_source *source; /* User-supplied pointer */ void *user_data; /* Receiver is responsible for destroying image */ struct imv_image *image; /* If an animated gif, the frame's duration in milliseconds, else 0 */ int frametime; /* Error message if image was NULL */ const char *error; }; /* While imv_image represents a single frame of an image, be it a bitmap or * vector image, imv_source represents an open handle to an image file, which * can emit one or more imv_images. */ struct imv_source { /* usually the path of the image this is the source of */ char *name; /* source's image dimensions */ int width; int height; /* Usually 1, more if animated */ int num_frames; /* Next frame to be loaded, 0-indexed */ int next_frame; /* Attempted to be locked by load_first_frame or load_next_frame. * If the mutex can't be locked, the call is aborted. * Used to prevent the source from having multiple worker threads at once. * Released by the source before calling the message callback with a result. */ pthread_mutex_t busy; /* Trigger loading of the first frame. Returns 0 on success. */ void *(*load_first_frame)(struct imv_source *src); /* Trigger loading of next frame. Returns 0 on success. */ void *(*load_next_frame)(struct imv_source *src); /* Safely free contents of this source. After this returns * it is safe to dealocate/overwrite the imv_source instance. */ void (*free)(struct imv_source *src); /* User-specified callback for returning messages */ void (*callback)(struct imv_source_message *message); /* User-specified pointer, included in returned messages */ void *user_data; /* Implementation private data */ void *private; }; #endif
26.465753
78
0.708592
[ "vector" ]
d564435bb7db26a0bb0ca6bd51098c4d1a988916
1,207
h
C
ZThreadPool/src/ThreadPool.h
fjz345/ZThreadPool
001bd6c9b4fc499c12dec2d85b50eb58c33804ec
[ "MIT" ]
null
null
null
ZThreadPool/src/ThreadPool.h
fjz345/ZThreadPool
001bd6c9b4fc499c12dec2d85b50eb58c33804ec
[ "MIT" ]
null
null
null
ZThreadPool/src/ThreadPool.h
fjz345/ZThreadPool
001bd6c9b4fc499c12dec2d85b50eb58c33804ec
[ "MIT" ]
null
null
null
#pragma once #include <vector> #include <queue> #include <mutex> #include <condition_variable> class Task { public: virtual int Execute() = 0; protected: std::mutex _Mutex; private: friend class ThreadPool; friend class Thread; }; class TestTask : public Task { public: TestTask(); ~TestTask(); int Execute(); int _a; int _b; int _result; private: }; class Thread { public: Thread(unsigned int uniqueId); ~Thread(); bool IsFinished(); private: friend class ThreadPool; static unsigned int __stdcall threadMain(void* params); uintptr_t _ThreadHandle; void* _EventHandle; unsigned int _ID; bool _IsRunning; std::mutex _Mutex; Task* _CurrentTask; }; static std::queue<Task*> s_TaskQueue; static std::mutex s_TaskQueueMutex; static std::condition_variable s_Condition; static unsigned int s_ActiveThreads; static std::mutex s_ActiveThreadsMutex; static std::condition_variable s_ActiveThreadsCondition; class ThreadPool { public: ThreadPool(unsigned int numThreads); ~ThreadPool(); void WaitForAllThreads(); void AddTask(Task* task); private: std::vector<Thread*> _Threads; };
14.719512
57
0.690141
[ "vector" ]
d56542e71b2f82b80c02e46f15c5a486535600ad
1,057
h
C
async-list/MyStringListModel.h
topecongiro/qt-toy-projects
ccf71acb0b0a896f4f231f11a5ad3b8f1f6b3e6f
[ "MIT" ]
null
null
null
async-list/MyStringListModel.h
topecongiro/qt-toy-projects
ccf71acb0b0a896f4f231f11a5ad3b8f1f6b3e6f
[ "MIT" ]
null
null
null
async-list/MyStringListModel.h
topecongiro/qt-toy-projects
ccf71acb0b0a896f4f231f11a5ad3b8f1f6b3e6f
[ "MIT" ]
null
null
null
#ifndef MYSTRINGLISTMODEL_H #define MYSTRINGLISTMODEL_H #include <QAbstractListModel> #include <QAbstractItemModel> #include <QFutureWatcher> class MyStringListModel : public QAbstractListModel { Q_OBJECT public: explicit MyStringListModel(QObject *parent = nullptr); // Basic functionality: int rowCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; public: bool canFetchMore(const QModelIndex& parent) const override; void fetchMore(const QModelIndex& parent) override; void setPattern(const QString& pat); public slots: void resetIndex(); private: void filterData(const QStringList& data, const QString& pattern); void cancel(); int m_RequestedNum; // The index data. This is the model data. QList<int> m_IndexList; // This is the actual data. QStringList m_Data; QString m_Pat; QMutex mutex; QFutureWatcher<QList<int>> futureWatcher; }; #endif // MYSTRINGLISTMODEL_H
22.978261
87
0.733207
[ "model" ]
d56c4b4bf5534b3da0d5d8d19786a0212e5506ea
4,736
h
C
printscan/wia/core/wiarpc/eventhandlerinfo.h
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
printscan/wia/core/wiarpc/eventhandlerinfo.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
printscan/wia/core/wiarpc/eventhandlerinfo.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
/***************************************************************************** * (C) COPYRIGHT MICROSOFT CORPORATION, 2002 * * AUTHOR: ByronC * * DATE: 4/10/2002 * * @doc INTERNAL * * @module EventHandlerInfo.h - Definitions for <c EventHandlerInfo> | * * This file contains the class definition for <c EventHandlerInfo>. * *****************************************************************************/ // // Defines // #define EventHandlerInfo_UNINIT_SIG 0x55497645 #define EventHandlerInfo_INIT_SIG 0x49497645 #define EventHandlerInfo_TERM_SIG 0x54497645 #define EventHandlerInfo_DEL_SIG 0x44497645 /***************************************************************************** * * @doc INTERNAL * * @class EventHandlerInfo | Holds information pertaining to a WIA persistent event handler * * @comm * This class continas the all information relating to a particular * WIA persistent event handler. This information can be used to check whether a * given handler supports a device/event pair; and can also be used to * launch the handler itsself. * *****************************************************************************/ class EventHandlerInfo { //@access Public members public: // @cmember Constructor EventHandlerInfo(const CSimpleStringWide &cswName, const CSimpleStringWide &cswDescription, const CSimpleStringWide &cswIcon, const CSimpleStringWide &cswCommandline, const GUID &guidCLSID); // @cmember Destructor virtual ~EventHandlerInfo(); // @cmember Increment reference count virtual ULONG __stdcall AddRef(); // @cmember Decrement reference count virtual ULONG __stdcall Release(); // @cmember Accessor method for the DeviceID this handler is registered for CSimpleStringWide getDeviceID(); // @cmember Accessor method for the friendly Name for this handler CSimpleStringWide getName(); // @cmember Accessor method for the description for this handler CSimpleStringWide getDescription(); // @cmember Accessor method for the icon path for this handler CSimpleStringWide getIconPath(); // @cmember Accessor method for the Commandline for this handler (if it has one) CSimpleStringWide getCommandline(); // @cmember Accessor method for the CLSID of this handler GUID getCLSID(); // @cmember For debugging: dumps the object members VOID Dump(); //@access Private members private: // @cmember Signature of class ULONG m_ulSig; // @cmember Ref count ULONG m_cRef; // @cmember The friendly Name for this handler CSimpleStringWide m_cswName; // @cmember The description for this handler CSimpleStringWide m_cswDescription; // @cmember The icon path for this handler CSimpleStringWide m_cswIcon; // @cmember The Commandline for this handler (if it has one) CSimpleStringWide m_cswCommandline; // @cmember The CLSID of this handler GUID m_guidCLSID; // // Comments for member variables // // @mdata ULONG | EventHandlerInfo | m_ulSig | // The signature for this class, used for debugging purposes. // Doing a <nl>"db [addr_of_class]"<nl> would yield one of the following // signatures for this class: // @flag EventHandlerInfo_UNINIT_SIG | 'EvIU' - Object has not been successfully // initialized // @flag EventHandlerInfo_INIT_SIG | 'EvII' - Object has been successfully // initialized // @flag EventHandlerInfo_TERM_SIG | 'EvIT' - Object is in the process of // terminating. // @flag EventHandlerInfo_INIT_SIG | 'EvID' - Object has been deleted // (destructor was called) // // @mdata ULONG | EventHandlerInfo | m_cRef | // The reference count for this class. Used for lifetime // management. // // @mdata CSimpleStringWide | EventHandlerInfo | m_cswName | // The friendly Name for this handler // // @mdata CSimpleStringWide | EventHandlerInfo | m_cswDescription | // The description for this handler // // @mdata CSimpleStringWide | EventHandlerInfo | m_cswIcon | // The icon path for this handler // // @mdata CSimpleStringWide | EventHandlerInfo | m_cswCommandline | // The Commandline for this handler (if it has one) // // @mdata GUID | EventHandlerInfo | m_guidCLSID | // The CLSID of this handler // };
36.152672
93
0.604941
[ "object" ]
d57c27b33ab779bec502d50cfc51e9ff01e7daad
532
h
C
LoadShaderFromFile.h
samarth1211/Nature-sLullaby
4a0daec6dbe20f306fcb55fa17edeb24d10d2592
[ "Unlicense" ]
1
2021-01-19T23:41:14.000Z
2021-01-19T23:41:14.000Z
LoadShaderFromFile.h
samarth1211/Nature-sLullaby
4a0daec6dbe20f306fcb55fa17edeb24d10d2592
[ "Unlicense" ]
null
null
null
LoadShaderFromFile.h
samarth1211/Nature-sLullaby
4a0daec6dbe20f306fcb55fa17edeb24d10d2592
[ "Unlicense" ]
null
null
null
#ifndef __LOAD_SHADER_FROM_FILE_H__ #define __LOAD_SHADER_FROM_FILE_H__ #include <stdio.h> #include <stdlib.h> #include <iostream> #include <vector> #include <string> #include <sstream> #include <fstream> #include <filesystem> #include <algorithm> #include <map> #include<GL\glew.h> #include<gl\GL.h> #ifdef __cplusplus extern "C" { #endif //__cplusplus char* LoadShaderSourceFromFile(const char *filename, const char *preamble, size_t *iSize); #ifdef __cplusplus }; #endif //__cplusplus #endif __LOAD_SHADER_FROM_FILE_H__
17.16129
91
0.765038
[ "vector" ]
d586e6abfd069fab04efcc3c7719f1183199a889
10,695
c
C
obs-studio/plugins/sndio/sndio-input.c
noelemahcz/libobspp
029472b973e5a1985f883242f249848385df83a3
[ "MIT" ]
null
null
null
obs-studio/plugins/sndio/sndio-input.c
noelemahcz/libobspp
029472b973e5a1985f883242f249848385df83a3
[ "MIT" ]
null
null
null
obs-studio/plugins/sndio/sndio-input.c
noelemahcz/libobspp
029472b973e5a1985f883242f249848385df83a3
[ "MIT" ]
null
null
null
/* Copyright (C) 2020 by Vadim Zhukov <zhuk@openbsd.org> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/types.h> #include <sys/socket.h> #include <errno.h> #include <poll.h> #include <pthread.h> #include <sndio.h> #include <string.h> #include <unistd.h> #include <util/bmem.h> #include <util/platform.h> #include <util/threading.h> #include <util/util_uint64.h> #include <obs.h> #include <obs-module.h> #include "sndio-input.h" #define blog(level, msg, ...) \ blog(level, "sndio-input: %s: " msg, __func__, ##__VA_ARGS__); #define berr(level, msg, ...) \ do { \ const char *errstr = strerror(errno); \ blog(level, msg ": %s", ##__VA_ARGS__, errstr); \ } while (0) #define NSEC_PER_SEC 1000000000LL /** * Returns the name of the plugin */ static const char *sndio_input_getname(void *unused) { UNUSED_PARAMETER(unused); return obs_module_text("SndioInput"); } static enum speaker_layout sndio_channels_to_obs_speakers(int channels) { switch (channels) { case 1: return SPEAKERS_MONO; case 2: return SPEAKERS_STEREO; case 3: return SPEAKERS_2POINT1; case 4: return SPEAKERS_4POINT0; case 5: return SPEAKERS_4POINT1; case 6: return SPEAKERS_5POINT1; case 8: return SPEAKERS_7POINT1; } return SPEAKERS_UNKNOWN; } static enum audio_format sndio_to_obs_audio_format(const struct sio_par *par) { switch (par->bits) { case 8: return AUDIO_FORMAT_U8BIT; case 16: return AUDIO_FORMAT_16BIT; case 32: return AUDIO_FORMAT_32BIT; } return AUDIO_FORMAT_UNKNOWN; } /** * Runs sndio tasks on a pre-opened audio device. * Whenever user chooses another device, this thread gets signalled to exit, * and another one starts immediately, without waiting for the previous. */ static void *sndio_thread(void *attr) { struct sndio_thr_data *thrdata = attr; size_t msgread = 0; // msg bytes read from socket size_t nsiofds = sio_nfds(thrdata->hdl); struct pollfd pfd[1 + nsiofds]; struct sio_par par; uint64_t ts; ssize_t nread; int pollres; uint8_t *buf; size_t bufsz; ts = os_gettime_ns(); bufsz = thrdata->par.appbufsz * thrdata->par.bps * 2; if ((buf = bmalloc(bufsz * 2)) == NULL) { blog(LOG_ERROR, "could not allocate record buffer of %zu bytes", bufsz); goto finish; } memset(pfd, 0, sizeof(pfd)); pfd[0].fd = thrdata->sock; for (;;) { for (size_t i = 0; i <= nsiofds; i++) pfd[i].revents = 0; pfd[0].events = POLLIN; sio_pollfd(thrdata->hdl, pfd + 1, POLLIN); if (poll(pfd, 1 + nsiofds, /*INFTIM*/ -1) == -1) { if (errno == EINTR) continue; berr(LOG_ERROR, "exiting due to poll error"); goto finish; } if ((pfd[0].revents & POLLHUP) == POLLHUP) { blog(LOG_INFO, "exiting upon receiving EOF at IPC socket"); goto finish; } if ((pfd[0].revents & POLLIN) == POLLIN) { nread = read(pfd[0].fd, ((uint8_t *)&par) + msgread, sizeof(par) - msgread); switch (nread) { case -1: if (errno == EAGAIN) goto proceed_sio; berr(LOG_ERROR, "reading from IPC socket failed"); goto finish; case 0: blog(LOG_INFO, "exiting upon receiving EOF at IPC socket"); goto finish; default: msgread += (size_t)nread; if (msgread == sizeof(struct sio_par)) { size_t tbufsz; uint8_t *tbuf; msgread = 0; sio_stop(thrdata->hdl); if (!sio_setpar(thrdata->hdl, &par)) { blog(LOG_WARNING, "sio_setpar failed, keeping old params"); } blog(LOG_INFO, "after sio_setpar(): appbufsz=%u bps=%u", par.appbufsz, par.bps); memcpy(&thrdata->par, &par, sizeof(struct sio_par)); tbufsz = thrdata->par.appbufsz * thrdata->par.bps * 2; if ((tbuf = brealloc(buf, tbufsz)) == NULL) { blog(LOG_ERROR, "could not reallocate record buffer of %zu bytes", tbufsz); goto finish; } buf = tbuf; bufsz = tbufsz; if (!sio_start(thrdata->hdl)) { blog(LOG_ERROR, "sio_start failed, exiting"); goto finish; } ts = os_gettime_ns(); // Since we restarted recording, // do not try to handle events we lost. continue; } } } proceed_sio: pollres = sio_revents(thrdata->hdl, pfd + 1); if ((pollres & POLLHUP) == POLLHUP) { blog(LOG_ERROR, "sndio device error happened, exiting"); goto finish; } if ((pollres & POLLIN) == POLLIN) { struct obs_source_audio out; unsigned int nframes; nread = (ssize_t)sio_read(thrdata->hdl, buf, bufsz); if (nread == 0) { if (sio_eof(thrdata->hdl)) { blog(LOG_ERROR, "sndio device EOF happened, exiting"); goto finish; } continue; } nframes = (unsigned int)nread / thrdata->par.bps; //blog(LOG_INFO, "sio_read returned %u, nframes = %u", nread, nframes); memset(&out, 0, sizeof(struct obs_source_audio)); out.data[0] = buf; out.frames = nframes; out.format = sndio_to_obs_audio_format(&thrdata->par); out.speakers = sndio_channels_to_obs_speakers( thrdata->par.rchan); out.samples_per_sec = thrdata->par.rate; out.timestamp = ts; ts += util_mul_div64(nframes, NSEC_PER_SEC, thrdata->par.rate); obs_source_output_audio(thrdata->source, &out); } } finish: sio_close(thrdata->hdl); close(thrdata->sock); bfree(buf); bfree(thrdata); return NULL; } /** * Destroy the plugin object and free all memory */ static void sndio_destroy(void *vptr) { struct sndio_data *data = vptr; if (!data) return; close(data->sock); data->sock = -1; pthread_attr_destroy(&data->attr); bfree(data); } /** * Tries to apply the input settings. * Must be called on stopped device. */ static void sndio_apply(struct sndio_data *data, obs_data_t *settings) { struct sndio_thr_data *thrdata; pthread_t thread; int ec; int socks[2] = {-1, -1}; const char *devname = obs_data_get_string(settings, "device"); if ((thrdata = bzalloc(sizeof(struct sndio_thr_data))) == NULL) { blog(LOG_ERROR, "malloc"); return; } if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0, socks) == -1) { berr(LOG_ERROR, "socketpair"); goto error; } if (data->sock != -1) close(data->sock); data->sock = socks[0]; thrdata->sock = socks[1]; thrdata->source = data->source; thrdata->hdl = sio_open(devname, SIO_REC, 0); if (!thrdata->hdl) { berr(LOG_ERROR, "could not open %s sndio device", devname); goto error; } sio_initpar(&thrdata->par); thrdata->par.bits = obs_data_get_int(settings, "bits"); thrdata->par.bps = SIO_BPS(thrdata->par.bits); thrdata->par.sig = thrdata->par.bits > 8; thrdata->par.le = 1; thrdata->par.rate = obs_data_get_int(settings, "rate"); thrdata->par.rchan = obs_data_get_int(settings, "channels"); thrdata->par.xrun = SIO_SYNC; // makes timestamping easy if (!sio_setpar(thrdata->hdl, &thrdata->par)) { berr(LOG_ERROR, "could not set parameters for %s sndio device", devname); goto error; } blog(LOG_INFO, "after initial sio_setpar(): appbufsz=%u bps=%u", thrdata->par.appbufsz, thrdata->par.bps); if (!sio_start(thrdata->hdl)) { berr(LOG_ERROR, "could not start recording on %s sndio device", devname); goto error; } ec = pthread_create(&thread, &data->attr, sndio_thread, thrdata); if (ec != 0) { blog(LOG_ERROR, "could not start thread"); goto error; } return; error: if (thrdata->hdl != NULL) sio_close(thrdata->hdl); close(socks[0]); close(socks[1]); bfree(thrdata); } /** * Update the input settings. */ static void sndio_update(void *vptr, obs_data_t *settings) { struct sndio_data *data = vptr; sndio_apply(data, settings); } /** * Create the plugin object */ static void *sndio_create(obs_data_t *settings, obs_source_t *source) { struct sndio_data *data = bzalloc(sizeof(struct sndio_data)); pthread_attr_init(&data->attr); pthread_attr_setdetachstate(&data->attr, PTHREAD_CREATE_DETACHED); data->source = source; data->sock = -1; sndio_apply(data, settings); return data; } /** * Get plugin defaults */ static void sndio_input_defaults(obs_data_t *settings) { obs_data_set_default_string(settings, "device", SIO_DEVANY); obs_data_set_default_int(settings, "rate", 48000); obs_data_set_default_int(settings, "bits", 16); obs_data_set_default_int(settings, "channels", 2); } /** * Get plugin properties */ static obs_properties_t *sndio_input_properties(void *unused) { obs_property_t *rate, *bits; UNUSED_PARAMETER(unused); obs_properties_t *props = obs_properties_create(); obs_properties_add_text(props, "device", obs_module_text("Device"), OBS_TEXT_DEFAULT); rate = obs_properties_add_list(props, "rate", obs_module_text("Rate"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); obs_property_list_add_int(rate, "11025 Hz", 11025); obs_property_list_add_int(rate, "22050 Hz", 22050); obs_property_list_add_int(rate, "32000 Hz", 32000); obs_property_list_add_int(rate, "44100 Hz", 44100); obs_property_list_add_int(rate, "48000 Hz", 48000); obs_property_list_add_int(rate, "96000 Hz", 96000); obs_property_list_add_int(rate, "192000 Hz", 192000); bits = obs_properties_add_list(props, "bits", obs_module_text("BitsPerSample"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); obs_property_list_add_int(bits, "8", 8); obs_property_list_add_int(bits, "16", 16); obs_property_list_add_int(bits, "32", 32); obs_properties_add_int(props, "channels", obs_module_text("Channels"), 1, 8, 1); return props; } struct obs_source_info sndio_output_capture = { .id = "sndio_output_capture", .type = OBS_SOURCE_TYPE_INPUT, .output_flags = OBS_SOURCE_AUDIO, .get_name = sndio_input_getname, .create = sndio_create, .destroy = sndio_destroy, #if SHUTDOWN_ON_DEACTIVATE .activate = sndio_activate, .deactivate = sndio_deactivate, #endif .update = sndio_update, .get_defaults = sndio_input_defaults, .get_properties = sndio_input_properties, .icon_type = OBS_ICON_TYPE_AUDIO_OUTPUT, };
25.52506
77
0.675082
[ "object" ]
d58ddf7f389cc7f1d50a0336caf48a2bc9f08f33
427
h
C
src/homework/tic_tac_toe/tic_tac_toe_4.h
acc-cosc-1337-spring-2021/acc-cosc-1337-spring-2021-AntNatx
1c581b554ba56ad19273cf2ea924cbdb4e7f131a
[ "MIT" ]
null
null
null
src/homework/tic_tac_toe/tic_tac_toe_4.h
acc-cosc-1337-spring-2021/acc-cosc-1337-spring-2021-AntNatx
1c581b554ba56ad19273cf2ea924cbdb4e7f131a
[ "MIT" ]
null
null
null
src/homework/tic_tac_toe/tic_tac_toe_4.h
acc-cosc-1337-spring-2021/acc-cosc-1337-spring-2021-AntNatx
1c581b554ba56ad19273cf2ea924cbdb4e7f131a
[ "MIT" ]
null
null
null
#ifndef TIC_TAC_TOE_4 #define TIC_TAC_TOE_4 #include"tic_tac_toe.h" class TicTacToe4: public TicTacToe { public: TicTacToe4(const std::vector<std::string>& p, std::string& w):TicTacToe(p, w){}; TicTacToe4() : TicTacToe(4){}; private: bool check_column_win() const override; bool check_row_win() const override; bool check_diagnol_win() const override; }; #endif //h
20.333333
88
0.651054
[ "vector" ]
9c51494c9d136cd271b3e79fbc8846d8bfd6c3de
3,563
h
C
src/front-end/inference/variable.h
lbrugnara/zenit
72cf091e8c392c895adaa7ac623320af92a8b452
[ "MIT" ]
4
2019-04-27T21:09:56.000Z
2022-02-03T21:22:14.000Z
src/front-end/inference/variable.h
lbrugnara/zenit
72cf091e8c392c895adaa7ac623320af92a8b452
[ "MIT" ]
null
null
null
src/front-end/inference/variable.h
lbrugnara/zenit
72cf091e8c392c895adaa7ac623320af92a8b452
[ "MIT" ]
null
null
null
#ifndef ZENIT_INFER_VARIABLE_H #define ZENIT_INFER_VARIABLE_H #include "infer.h" #include "attribute-map.h" #include "../utils.h" /* * Function: zenit_infer_types_in_variable_node * The variable visitor share type information with its right-hand side expression if it contains a type hint, or possibly * receives type information from the rhs when the variable does not declare a type. * Also, in case the types are not equals, it tries to add an implicit cast between the rhs type and the lhs type. * * Parameters: * <ZenitContext> *ctx: Context object * <ZenitVariableNode> *variable_node: Node to visit * <ZenitType> *ctx_type: Contextual type information * <ZenitInferenceKind> *infer_kind: Contextual information about the inference process * * Returns: * <ZenitSymbol>* - The variable symbol with its -possibly inferred- type information */ static inline ZenitSymbol* zenit_infer_types_in_variable_node(ZenitContext *ctx, ZenitVariableNode *variable_node, ZenitType **ctx_type, ZenitInferenceKind infer_kind) { // The variable declaration node does not perform type inference in this function, but it passes type information // to the right-hand side expression's visitor with possibly ZENIT_INFER_BIDIRECTIONAL when the type is not present in the // declaration: // e.g.: var a = [ 1, 2, 3 ] // The ZENIT_INFER_BIDIRECTIONAL is passed to the array's visitor, which means that the type from the array literal ([3]uint8) // will be assigned to the variable's type zenit_assert(ctx_type == NULL && infer_kind == ZENIT_INFER_NONE, "A variable declaration does not need contextual type information"); // Visit the attributes and its properties zenit_infer_types_in_attribute_node_map(ctx, variable_node->attributes); // We need the symbol we introduced in the <zenit_resolve_symbols> pass ZenitSymbol *symbol = zenit_program_get_symbol(ctx->program, variable_node->name); // We need to get the symbol of the right-hand side expression. (if the variable definition has a type hint, we pass that hint to the visitor) ZenitSymbol *rhs_symbol = zenit_infer_types_in_node(ctx, variable_node->rvalue, &symbol->type, // If the variable has a declared type, we don't allow inference on the variable type variable_node->type_decl != NULL ? ZENIT_INFER_UNIDIRECTIONAL : ZENIT_INFER_BIDIRECTIONAL); // If the types are not equals, we try to cast the RHS to the LHS type, and if that is not possible, we don't do anything here, we just let // the type check to fail later. if (!zenit_type_equals(symbol->type, rhs_symbol->type) && zenit_type_is_castable_to(rhs_symbol->type, symbol->type)) { // NOTE: the ZenitVariableNode structure changes, but we don't need to worry about its UID changing because // the variables are always accessed by its name, and not by the UID ZenitCastNode *cast_node = zenit_cast_node_new(variable_node->rvalue->location, variable_node->rvalue, true); variable_node->rvalue = (ZenitNode*) cast_node; zenit_utils_new_tmp_symbol(ctx->program, (ZenitNode*) cast_node, zenit_type_ctx_copy_type(ctx->types, symbol->type)); } // We always return the variable symbol return symbol; } #endif /* ZENIT_INFER_VARIABLE_H */
54.815385
167
0.691833
[ "object" ]
9c5278a3f65a124e92e0e83499cc73608d29ef20
1,824
h
C
ffbdevice.h
MadCatX/FFBChecker
815d7d44fca0483dd222841b15bcf99d0bc1d2f2
[ "MIT" ]
25
2015-11-02T01:32:30.000Z
2022-03-15T07:52:19.000Z
ffbdevice.h
MadCatX/FFBChecker
815d7d44fca0483dd222841b15bcf99d0bc1d2f2
[ "MIT" ]
1
2020-03-06T11:54:11.000Z
2020-05-05T17:15:03.000Z
ffbdevice.h
MadCatX/FFBChecker
815d7d44fca0483dd222841b15bcf99d0bc1d2f2
[ "MIT" ]
2
2016-10-28T13:43:28.000Z
2018-04-13T03:12:27.000Z
#ifndef FFBDEVICE_H #define FFBDEVICE_H #include "ffbeffect.h" #include <memory> #include <vector> class FFBDevice { public: virtual ~FFBDevice() = default; const std::vector<ConditionSubtypes>& availableConditionSubtypesList() const; const std::vector<FFBEffectTypes>& availableEffectsList() const; const std::vector<PeriodicWaveforms>& availableWaveformsList() const; const std::shared_ptr<FFBEffectParameters> effectParameters(const int idx); FFBEffect::FFBEffectStatus effectStatusByIdx(const int idx) const; FFBEffectTypes effectTypeByEffectIdx(const int idx) const; bool hasEffect(FFBEffectTypes id) const; bool hasPeriodicWaveform(PeriodicWaveforms id) const; inline int maxEffectCount() const { return c_maxEffectCount; } inline PeriodicWaveforms waveformByIdx(const int idx) const { return m_availablePeriodicWaveforms[idx]; } virtual void close() = 0; virtual bool queryDeviceCapabilities() = 0; virtual bool removeAndEraseEffect(const int idx) = 0; virtual bool setAutocentering(const int strength) = 0; virtual bool setGain(const int gain) = 0; virtual bool startEffect(const int idx, const FFBEffectTypes type, std::shared_ptr<FFBEffectParameters> parameters) = 0; virtual bool stopEffect(const int idx) = 0; virtual bool uploadEffect(const int idx, const FFBEffectTypes type, std::shared_ptr<FFBEffectParameters> parameters) = 0; protected: explicit FFBDevice(const int maxEffectCount) : c_maxEffectCount(maxEffectCount) {} std::vector<ConditionSubtypes> m_availableConditionSubtypes; std::vector<FFBEffectTypes> m_availableEffects; std::vector<PeriodicWaveforms> m_availablePeriodicWaveforms; bool m_adjustableAC; bool m_adjustableGain; std::vector<std::shared_ptr<FFBEffect>> m_effects; const int c_maxEffectCount; }; #endif // FFBDEVICE_H
37.22449
123
0.787281
[ "vector" ]
9c56b864022b15a9e4f6446b55210f5441bc8167
17,459
h
C
inetsrv/iis/svcs/smtp/aqueue/advqueue/msgref.h
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
inetsrv/iis/svcs/smtp/aqueue/advqueue/msgref.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
inetsrv/iis/svcs/smtp/aqueue/advqueue/msgref.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
//----------------------------------------------------------------------------- // // // File: msgref.h // // Description: Definition of Queueing MsgRef object // // Author: mikeswa // // Copyright (C) 1997 Microsoft Corporation // //----------------------------------------------------------------------------- #ifndef _MSGREF_H_ #define _MSGREF_H_ #include "cmt.h" #include "baseobj.h" #include "bitmap.h" #include "domain.h" #include "aqueue.h" #include "aqroute.h" #include "qwiklist.h" #include "dcontext.h" #include <mailmsg.h> #include "msgguid.h" #include "aqutil.h" #include "aqadmsvr.h" #include <aqerr.h> #include <aqreg.h> class CDestMsgQueue; class CAQSvrInst; class CAQStats; // {34E2DCC8-C91A-11d2-A6B1-00C04FA3490A} static const GUID IID_CMsgRef = { 0x34e2dcc8, 0xc91a, 0x11d2, { 0xa6, 0xb1, 0x0, 0xc0, 0x4f, 0xa3, 0x49, 0xa } }; //FLAGS that say which IMsg data we care about #define MSGREF_VALID_FLAGS (eMsgSize | eMsgArriveTime | eMsgPriority) //MsgRef signature #define MSGREF_SIG 'feRM' //max number of domains for CPool allocator #define MSGREF_STANDARD_DOMAINS 12 // // Make sure the "standard" CPool size is // - large enough to accommidate any padding in the CPoolMsgRef struct // - QWORD alligned so 64-bit machines are happy // #define MSGREF_STANDARD_CPOOL_SIZE \ (((sizeof(CPoolMsgRef) - sizeof(CMsgRef) + \ CMsgRef::size(MSGREF_STANDARD_DOMAINS)) + 0x10) & ~0xF) //A Note about bitmaps //The Recips bitmap represents the responsible recipients for a destination, //or message request. 1 means that the tansport should attempt to deliver for //this connection. #ifdef DEBUG _declspec(selectany) DWORD g_cDbgMsgRefsCpoolAllocated = 0; _declspec(selectany) DWORD g_cDbgMsgRefsExchmemAllocated = 0; _declspec(selectany) DWORD g_cDbgMsgRefsCpoolFailed = 0; _declspec(selectany) DWORD g_cDbgMsgIdHashFailures = 0; _declspec(selectany) DWORD g_cDbgMsgRefsPendingRetryOnDelete = 0; #endif //DEBUG //define reserved message status codes ... should be in MESSAGE_STATUS_RESERVED #define MESSAGE_STATUS_LOCAL_DELIVERY 0x80000000 #define MESSAGE_STATUS_DROP_DIRECTORY 0x40000000 //---[ CMsgRef ]--------------------------------------------------------------- // // // Hungarian: msgref, pmsgref // // Persistable message reference object used throughout advanced queuing //----------------------------------------------------------------------------- class CMsgRef : public IUnknown, public CBaseObject { public: static CPool s_MsgRefPool; //override the new operator void * operator new (size_t stIgnored, unsigned int cDomains); //Number of domains in message void * operator new (size_t stIgnored); //should not be used void operator delete(void *p, size_t size); CMsgRef(DWORD cDomains, IMailMsgQueueMgmt *pIMailMsg, IMailMsgProperties *pIMailMsgProperties, CAQSvrInst *paqinst, DWORD dwMessageType, GUID guidMessageRouter); ~CMsgRef(); //perform initialization and determine the queues for this message. //A NULL Queue signifies local delivery HRESULT HrInitialize( IN IMailMsgRecipients *pIRecipList, //recipient interface for msg IN IMessageRouter *pIMessageRouter, //Router for this message IN DWORD dwMessageType, OUT DWORD *pcLocalRecips, OUT DWORD *pcRemoteRecips, OUT DWORD *pcQueues, //# of queues for this message OUT CDestMsgQueue **rgpdmqQueues); //array of queue ptrs //Get the effective priority of the message inline EffectivePriority PriGetPriority() {return (EffectivePriority) (MSGREF_PRI_MASK & m_dwDataFlags);}; inline IMailMsgProperties *pimsgGetIMsg() {Assert(m_pIMailMsgProperties);m_pIMailMsgProperties->AddRef();return m_pIMailMsgProperties;}; inline BOOL fIsMyMailMsg(IMailMsgProperties *pIMailMsgProperties) {return (pIMailMsgProperties == m_pIMailMsgProperties);}; //get the size of the message content inline DWORD dwGetMsgSize() {return(m_cbMsgSize);}; inline DWORD cGetNumDomains() {return(m_cDomains);}; //get the size of the class (including all extras) inline size_t size() {return (size(m_cDomains));}; //Return the delivery context needed for delivery over a given link //Do NOT free prgdwRecips... it will disappear with the AckMessage HRESULT HrPrepareDelivery( IN BOOL fLocal, //prepare for local domains as well IN BOOL fDelayDSN, //Check/Set DelayDSN bitmap IN CQuickList *pqlstQueues, //array of DestMsgQueues IN CDestMsgRetryQueue* pdmrq, //retry interface for message IN OUT CDeliveryContext *pdcntxt, //context that must be returned on Ack OUT DWORD *pcRecips, //#of recips to deliver OUT DWORD **prgdwRecips); //array of recip indexes //Acknowledge (non)delivery of a msg HRESULT HrAckMessage( IN CDeliveryContext *pdcntxt, //Delivery context of message IN MessageAck *pMsgAck); //Delivery status of message CAQMessageType *paqmtGetMessageType() {return &m_aqmtMessageType;}; //size that can be used by new operator static inline size_t size(DWORD cDomains) { return (sizeof(CMsgRef) + (cDomains-1)*sizeof(CDestMsgQueue *) + //cDomains dmq ptrs (cDomains + 3) * (CMsgBitMap::size(cDomains)) + //bitmaps (cDomains*2) * sizeof(DWORD)); }; //Send Delay or NDR DSN's if the message has expired HRESULT HrSendDelayOrNDR( IN DWORD dwDSNOptions, //Flags for DSN generation IN CQuickList *pqlstQueues, //list of DestMsgQueues IN HRESULT hrStatus, //Status to Pass to DSN generation OUT DWORD *pdwDSNFlags); //description of what the result was //bit flag return values for HrSendDelayOrNDR enum { MSGREF_DSN_SENT_NDR = 0x00000001, //Message NDR-expired and NDR was sent MSGREF_DSN_SENT_DELAY = 0x00000002, //Message Delay-expired and Delay DSN was sent MSGREF_HANDLED = 0x00000004, //Message has been completely handled MSGREF_HAS_NOT_EXPIRED = 0x00000008, //Message younger than it's exipiration dates }; //bit flag options for DSN generation enum { MSGREF_DSN_LOCAL_QUEUE = 0x00000001, //This is for a local queue MSGREF_DSN_SEND_DELAY = 0x00000002, //Allow Delay DSNs MSGREF_DSN_CHECK_IF_STALE = 0x00000004, //Force open handle to check if stale MSGREF_DSN_HAS_ROUTING_LOCK = 0x80000000, //This thread holds the routing lock }; void SupersedeMsg(); BOOL fMatchesQueueAdminFilter(CAQAdminMessageFilter *paqmf); HRESULT HrGetQueueAdminMsgInfo(MESSAGE_INFO *pMsgInfo, IQueueAdminAction *pIQueueAdminAction); HRESULT HrRemoveMessageFromQueue(CDestMsgQueue *pdmq); HRESULT HrQueueAdminNDRMessage(CDestMsgQueue *pdmq); void GlobalFreezeMessage(); void GlobalThawMessage(); BOOL fIsMsgFrozen() {return(MSGREF_MSG_FROZEN & m_dwDataFlags);}; FILETIME *pftGetAge() {return &m_ftQueueEntry;}; void RetryOnDelete(); void PrepareForShutdown() {ReleaseMailMsg(FALSE);}; //Checks if the message can be retried (the backing storage may //have been deleted). BOOL fShouldRetry(); void GetStatsForMsg(IN OUT CAQStats *paqstat); void MarkQueueAsLocal(IN CDestMsgQueue *pdmq); void CountMessageInRemoteTotals(); // // Determines if a message is a "problem" message. Currently this is based purely on the number // of failures per message, but we may wish to add more logic at a later time. // BOOL fIsProblemMsg() {return (g_cMsgFailuresBeforeMarkingMsgAsProblem && (m_cTimesRetried >= g_cMsgFailuresBeforeMarkingMsgAsProblem));}; public: //IUnknown STDMETHOD(QueryInterface)(REFIID riid, LPVOID * ppvObj); STDMETHOD_(ULONG, AddRef)(void) {return CBaseObject::AddRef();}; STDMETHOD_(ULONG, Release)(void) {return CBaseObject::Release();}; protected: DWORD m_dwSignature; CAQSvrInst *m_paqinst; DWORD m_dwDataFlags; //private data flags DWORD m_cbMsgSize; //Size of message content in bytes FILETIME m_ftQueueEntry; //time that message was enqueued FILETIME m_ftLocalExpireDelay; FILETIME m_ftLocalExpireNDR; FILETIME m_ftRemoteExpireDelay; FILETIME m_ftRemoteExpireNDR; CAQMsgGuidListEntry *m_pmgle; DWORD m_cDomains; //number of DOMAINS this message is destined for CAQMessageType m_aqmtMessageType; //Message type IMailMsgQueueMgmt *m_pIMailMsgQM; //Reference to message Queue mgmt IMailMsgProperties *m_pIMailMsgProperties; //reference to message IMailMsgRecipients *m_pIMailMsgRecipients; DWORD m_cTimesRetried; DWORD m_dwMsgIdHash; volatile DWORD m_cInternalUsageCount; CDestMsgQueue *m_rgpdmqDomains[1]; //Actual size is m_cDomains static inline BOOL fIsStandardSize(DWORD cDomains) { return (MSGREF_STANDARD_DOMAINS >= cDomains); } HRESULT HrOneTimeInit(); HRESULT HrPrvRetryMessage(CDeliveryContext *pdcntxt, DWORD dwMsgStatus); HRESULT HrPromoteMessageStatusToMailMsg(CDeliveryContext *pdcntxt, MessageAck *pMsgAck); HRESULT HrUpdateExtendedStatus(DWORD cbCurrentStatus, LPSTR szCurrentStatus, LPSTR *pszNewStatus); //private methods to get at "hidden" data. CMsgBitMap *pmbmapGetDomainBitmap(DWORD iDomain); CMsgBitMap *pmbmapGetHandled(); CMsgBitMap *pmbmapGetPending(); CMsgBitMap *pmbmapGetDSN(); DWORD *pdwGetRecipIndexStart(); void SetRecipIndex(DWORD iDomain, DWORD iLowRecip, DWORD iHighRecip); void GetRecipIndex(DWORD iDomain, DWORD *piLowRecip, DWORD *piHighRecip); void BounceUsageCount(); static BOOL fBounceUsageCountCompletion(PVOID pvContext, DWORD dwStatus); void ReleaseAndBounceUsageOnMsgAck(DWORD dwMsgStatus); void ReleaseMailMsg(BOOL fForceRelease); void SyncBounceUsageCount(); //synchronous version of BounceUsageCount //Checks to see if the backing mailmsg has been deleted (or is about to //be deleted). BOOL fMailMsgMarkedForDeletion() {return ((MSGREF_MAILMSG_DELETE_PENDING | MSGREF_MAILMSG_DELETED) & m_dwDataFlags);}; //Marks the mailmsg for deletion. MailMsg will be deleted when the usage //count drops. void MarkMailMsgForDeletion(); //Used to make sure that calling thread is the only one that will call Delete() //on the MailMsg. Will set the MSGREF_MAILMSG_DELETED and call Delete(). //Only called in ReleaseMailMsg() and InternalReleaseUsage(). The caller is //responsible for making sure that other threads are not reading the mailmsg or //have a usage count VOID ThreadSafeMailMsgDelete(); //Internal versions of AddUsage/ReleaseUsage. Wraps the actual mailmsg calls, and //allows the CMsgRef to call delete on the MailMsg while there are still outstanding //references on it. Uses m_cInternalUsageCount to maintain a count. HRESULT InternalAddUsage(); HRESULT InternalReleaseUsage(); enum //bitmasks for private flags { MSGREF_VERSION_MASK = 0xE0000000, MSGREF_MSG_COUNTED_AS_REMOTE = 0x08000000, MSGREF_MSG_LOCAL_RETRY = 0x04000000, MSGREF_MSG_REMOTE_RETRY = 0x02000000, MSGREF_USAGE_COUNT_IN_USE = 0x01000000, MSGREF_SUPERSEDED = 0x00800000, //Msg has been superseed MSGREF_MSG_INIT = 0x00400000, //HrInitialize has been called MSGREF_MSG_FROZEN = 0x00200000, MSGREF_MSG_RETRY_ON_DELETE = 0x00100000, MSGREF_ASYNC_BOUNCE_PENDING = 0x00040000, MSGREF_MAILMSG_RELEASED = 0x00020000, MSGREF_MAILMSG_DELETE_PENDING = 0x00010000, //A delete is pending on this msg MSGREF_MAILMSG_DELETED = 0x00008000, //The backing store for the mailmsg //has been deleted. MSGREF_PRI_MASK = 0x0000000F, MSGREF_VERSION = 0x00000000, //used by allocators MSGREF_CPOOL_SIG_MASK = 0xFFFF0000, MSGREF_CPOOL_SIG = 0xC0070000, MSGREF_CPOOL_ALLOCATED = 0x00000001, MSGREF_STANDARD_SIZE = 0x00000002, }; static DWORD s_cMsgsPendingBounceUsage; //Messages that have been marked pending delete, but have not been deleted static DWORD s_cCurrentMsgsPendingDelete; //Total number of messages that have been marked pending delete static DWORD s_cTotalMsgsPendingDelete; //Total number of messages that have been deleted after being marked //for delete pending static DWORD s_cTotalMsgsDeletedAfterPendingDelete; //Total number of messages that have had ::Deleted, but are still in //memory because someone has an outstanding reference to the msgref static DWORD s_cCurrentMsgsDeletedNotReleased; }; //----------------------------------------------------------------------------- // Description: // Checks if the DSN HRESULT status is a fatal one, i.e. one for which an // NDR should be generated. //----------------------------------------------------------------------------- inline BOOL fIsFatalError(HRESULT hrStatus) { return ((AQUEUE_E_NDR_ALL == hrStatus) || (AQUEUE_E_LOOPBACK_DETECTED == hrStatus) || (AQUEUE_E_ACCESS_DENIED == hrStatus) || (AQUEUE_E_MESSAGE_TOO_LARGE == hrStatus) || (AQUEUE_E_SMTP_GENERIC_ERROR == hrStatus) || (AQUEUE_E_QADMIN_NDR == hrStatus) || (AQUEUE_E_NO_ROUTE == hrStatus)); } //---[ CPoolMsgRef ]----------------------------------------------------------- // // // Description: // Struct used as a hidden wrapper for CMsgRef allocation... used // exclusively by the CMsgRef new and delete operators // Hungarian: // cpmsgref, pcpmsgref // //----------------------------------------------------------------------------- typedef struct _CPoolMsgRef { DWORD m_dwAllocationFlags; CMsgRef m_msgref; } CPoolMsgRef; //Cannot use default CMsgRef new operator inline void * CMsgRef::operator new(size_t stIgnored) { _ASSERT(0 && "Use new that specifies # of domains"); return NULL; } inline void CMsgRef::operator delete(void *p, size_t size) { CPoolMsgRef *pcpmsgref = CONTAINING_RECORD(p, CPoolMsgRef, m_msgref); _ASSERT((pcpmsgref->m_dwAllocationFlags & MSGREF_CPOOL_SIG_MASK) == MSGREF_CPOOL_SIG); if (pcpmsgref->m_dwAllocationFlags & MSGREF_CPOOL_ALLOCATED) { s_MsgRefPool.Free((void *) pcpmsgref); } else { FreePv((void *) pcpmsgref); } } // Layout of private data bit fields // ------------------------------------- // |332|2222222221111111111987654|3210| // |109|8765432109876543210 | | // ------------------------------------- // | | | ^--- Effective routing priority (max 16) // | | | (Keep least significant so it can be // | | | used as an array index) // | | ^-------------------- General msgref flags // | ^---------------------------------- Version number //Actual data is variable-sized and extends beyond the class structure. //Use the public functions to access it. When persisting, be sure to persist //the entire thing (use size() to see how big it really is). // +----------+ // | | // | | constant-size data structure CMsgRef // | | // +----------+ // | | // | | m_cDomains CDestMsgQueue pointers - Tells which queues this // | | message is on. // +----------+ // | | Handled bitmap \ // | | Delivery pending bitmap >- bitmaps are variable sized // | | Delay DSN's sent bitmap / (up to 32 domains fit in a DWORD) // +----------+ // | | // | | m_cDomains Domain responsibility bitmaps - used with // | | the concept of "compressed" queues... not fully supported yet // +----------+ // | | // | | m_cDomains (x2) Recipient Index (start and stop... inclusive) // | | // +----------+ #endif //_MSGREF_H_
40.321016
103
0.612864
[ "object" ]
9c5c439f2616f074acb495b92e2edf472661a4cf
11,558
h
C
src/Game/Players.h
cmesias/SmolDugeon
6624bd7f120f9b4981cbf517cc0fa591b3c7e976
[ "MIT" ]
null
null
null
src/Game/Players.h
cmesias/SmolDugeon
6624bd7f120f9b4981cbf517cc0fa591b3c7e976
[ "MIT" ]
null
null
null
src/Game/Players.h
cmesias/SmolDugeon
6624bd7f120f9b4981cbf517cc0fa591b3c7e976
[ "MIT" ]
null
null
null
/* * Players.h * * Created on: Dec 18, 2016 * Author: Carl */ #ifndef LOCAL_PLAYERS_H_ #define LOCAL_PLAYERS_H_ #include <SDL2/SDL_ttf.h> #include "../LWindow.h" #include "../LTexture.h" #include "../Particless.h" #include "../Helper.h" #include "Maps.h" #include "Tiles.h" #include "Tilec.h" #include "Object.h" #include "TextNFont.h" #include "../Settings.h" //Player class Players: public Helper, public TextNFont { public: enum Result { QUIT, LOADMENU, PLAYGAME, QUITPLAYGAME }; Settings settings; public: // Joystick Sensitivity const int JOYSTICK_DEAD_ZONE = 8000; void OnKeyDown(SDL_Keycode sym ); void OnKeyUp(SDL_Keycode sym ); void mouseClickState(SDL_Event &e); // Mouse stuff bool leftclick; bool rightclick; bool test; public: // resources // Local resources LTexture gPlayer; LTexture gPlayerShadow; LTexture gShield; LTexture gSwords; /* Sword types * 0 - 10: Fist & Swords * 11 - 12: Rapier and Hammer * 13 - 18: Better Swords * 19 - 22: Broken Swords * 23: Bomb * 24: Heart * 25: Coin * 26: Silver key * 27: Gold key */ SDL_Rect rSwords[28]; /* * 0-3: Walk * 4: Before slash * 5: Slash * 6: Parry * 7: Down Stab * 8: Dash frame 0 * 9: Dash frame 1 */ SDL_Rect rPlayer[10]; SDL_Rect rShield[7]; /* * 0-3: Walk * 4: Before slash * 5: Slash * 6: Parry * 7: Down Stab * 8: Dash frame 0 * 9: Dash frame 1 */ int sprite_index; /* * 0: Keyboard * 1: Keyboard + Mouse */ int ControlsPreference = 1; // default: 0 public: // variables std::string name; int timer = 0; int realw = 48, realh = 48; // object size in actual pixel size int w = 24, h = 24; // object size in collision pixels float x = 0, y = 0; float armX; // This is where we will attach the sword to float armY; float x2, y2; // player center float angle = 0.0, radians = 0.0, radianCos = 0.0, radianSin = 0.0; float vX = 0.0; float vY = 0.0; const float velMax = 4; const float velSpeed= 2; bool camlocked = true; bool shift = false; bool deathScreen = false; bool alive; // Movement std::string facing; bool moveleft = false, moveright = false, moveup = false, movedown = false; bool moving = false; /* * Parrying small blue Bullet from Boss: score += 1; * Parrying small red Bullet from Boss: score += 2; * Parrying large red Bullet from Boss: score += 4; * Hitting Boss directly w/ Slash Projectile: score += 5 * Hitting Boss directly w/ Sword: score += 5 * Hitting Boss with counter is: score += 10 */ unsigned int score = 0; unsigned int highscore = 0; double tempc, temps; SDL_Rect continueButton[3]; // High-Score display std::string highList[10]; int indx = 0; float travel = 0.0; int position = 0; int position2 = 0; int dir = 1; public: // Attack variables SDL_RendererFlip flipW; float attackTimer; float slashAtkSpe = 1; // default: 1 or 3 for fast attacks int attackFrame; int attackType; // 0: slash, 1: down stab int stunTimer; bool attack; bool stunned; bool clash; bool spawnAttack; //float *tempXX; //float *tempYY; public: // functions // Functions void Load(SDL_Renderer* gRenderer); void Free(); void Init(float spawnX, float spawnY, std::string newName); // Called when player loses all their health void RespawnPlayer(); // Called when player loses all their lives void ResetLivesAndPlayer(); bool checkCollision(int x, int y, int w, int h, int x2, int y2, int w2, int h2); // Get audio files //void getAudio(Mix_Chunk* sLazer); // Player shoot void fire(Particle particle[], Particle &p_dummy, Mix_Chunk* sCastSFX, int mx, int my); void Update(Map &map, Particle particle[], Particle &p_dummy, Tile &tl, Tile tile[], Tilec &tlc, Tilec tilec[], Object &obj, Object object[], int mx, int my, int camx, int camy, float spawnX, float spawnY, LWindow gWindow, SDL_Renderer* gRenderer, SDL_Color color, bool &RestartLevel, int LevelWeLoaded, bool &ShakeCamera); void Render(int mx, int my, int camX, int camY, LWindow gWindow, SDL_Renderer* gRenderer, SDL_Color color, int &PARTICLES); void RenderUI(SDL_Renderer *gRenderer, int camX, int camY, int CurrentLevel); void RenderDebug(SDL_Renderer* gRenderer, int camX, int camY); private: // Private variables // Walktimer for sprite usage double walkTimer; // Walktimer visual effects double walkTimerVFX; private: // Private variables private: // Abilities // Health //int hearts = 3; //int health = 100; //const int healthMax = 100; // Fire-rate double particleW = 48; double particleH = 48; bool shootDelay = false; bool initialshot = false; bool trigger = false; //float AttackSpeed; // Attack speed float shootTimer; // Attack speed //float damage; // Sword damage //float castDamage; // Cast damage //float damageMultipler; // Parrying will increase damage multiplier //float maxMana; // Max mana //float mana; // Mana //float manaRegenSpeed; // Mana float manaRegenTimer; // 1 second timer for mana regen; float manaGainOnParry; // Gain mana if you parry successfully float knockBackPower; // Knock back power // Parry state bool parry; //float parryLength; // Parry length: 15 default float parryTimer; // Parry timer float parryCDTimer; // Parry cooldown timer tracker float parryCDMax; // Parry cooldown, default: 60*3 // Dash state bool dash; // Dash ability float dashSpeed; // default: 15 float dashLength; // default: 10 const float dashCooldown = 60; // default: 60 float dashCounter; // default: 0 float dashCoolCounter; // default: 0 // Invurnerable state int invurnerableFrame; int invurnerableTick; int invurnerableT; bool invurnerable; private: // Save these player stats in a file. This will be the players save data. // Inventory int silverKeys; // Keys int goldKeys; // Keys int coins; // Coins const int silverKeysMax = 9999; // Keys, Default: 99 const int goldKeysMax = 9999; // Keys, Default: 99 const int coinsMax = 9999; // Coins, Default: 99 int bombs; // Bombs const int bombsMax = 99; // Bombs, Deafult: 99 // Health int hearts; // Default: 3 const int heartsMax = 99; // Default: 99 float health; // Default: 100 float healthDecay; // Default: 100 float healthMax; // Default: 100 // Damage float damage; // Sword damage float castDamage; // Cast damage float damageMultipler; // Parrying will increase damage multiplier float castAtkSpe; // Cast atk speed - deprecated, delete? // Mana float mana; // Mana float maxMana; // Max mana float manaRegenSpeed; // Mana // Parry float parryLength; // Parry length: 15 default private: // Official player control keys bool pressedEquipKey; private: // Variables used in Textures const float xOffset = 0; const float yOffset = -29; int shadowW = 44; /* Sword Types (TODO [ ] (3-25-2022) - save this in player data) * * 0: Wooden Sword * 1: Rusty Sword * 2: Iron Sword * * * 10: Red Sword 10 x 21 * * * 11: Tool? 7 x 17 * 12: Hammer 10 x 21 * * 13: Thicc Sword 10 x 25 * 14: Long Rapier 8 x 27 * 15: Golden Long Sword 10 x 29 * 16: Silver Sword 6 x 27 * 17: Silver Thicc Sword 10 x 24 * 18: Silver Thicc Sword w/ Gold 10 x 24 * * 19: Broken Iron sword short 6 x 9 * 20: Broken Iron sword 6 x 12 * 21: Broken Golden sword 6 x 12 * 22: Broken Silver sword 6 x 12 * * 23: Bomb 14 x 13 * 24: Heart 10 x 10 * 25: Coin 10 x 10 * 26: Silver key 5 x 10 * 27: Gold key 5 x 10 */ int swordInHand_Index = 0; int swordW = 20; int swordH = 42; //--------------- Sword offsets --------------- // X offset Sword Slashing Left // X offset Sword Slashing Left const float xOffSetFistPunchLeft = -15; const float xOffSetFistPunchRight = 15; // X offset Sword Slashing Left const float xOffSetSwordSlashingLeft = -24; // X offset Sword Slashing Left const float xOffSetSwordSlashingRight = 30; // X offset walking right and left //const float xOffSetSwordWalkAndDash = 30; // Y offset Sword default const float yOffSetSword = 3; // Y offset Sword Slashing const float yOffSetSwordSlashing = 15; //--------------- Player offsets --------------- // X offset Player Slashing Left const float xOffSetSlashingLeft = -48; // X offset Player Walking Right const float xOffSetWalkingRight = -12; public: // X offset walking right and left const float xOffSetSwordWalkAndDash = 30; public: // Functions to do stuff? void SlashAttack(); void ActivateParry(); void ActivateDash(); public: // Mutator functions // Move x pos float moveX(float value); // Move y pos float moveY(float value); // Applies invurnerability to Player void ActivateInvurnerability(); // Stops parry but goes on cool down void StopParrying(); // Stops parry but reset cool down to 0 void ResetParry(); // Extend parry duration, and Gain mana back void ExtendParryDuration(); // Increase Silver Keys void IncreaseSilverKeys(int value = 1); // Increase Gold Keys void IncreaseGoldKeys(int value = 1); // Increase Coins void IncreaseCoins(int value = 1); // Increase Bombs void IncreaseBombs(int value = 1); // Increase Hearts void IncreaseHearts(int value = 1); // Increase Health void IncreaseHealth(float value); // Increase Score void IncreaseScore(float value); // Shorten parry cool down void ShortenParryCD(float value); // Stop movement void StopMovement(); // Stop Slash Attack void StopSlashAttack(); // Stop dashing void StopDashing(); // Reset dashing void ResetDashing(); // Equip a sword void EquipSword(int swordInHand_Index, float damage, float slashAtkSpe); // Set false to equip key state void stopEquipState(); public: // Accessor functions // Get x pos float getX(); // Get y pos float getY(); // Get width float getW(); // Get height float getH(); // Get left pos float getLeftSide(); // Get right pos float getRightSide(); // Get top pos float getTopSide(); // Get bottom pos float getBottomSide(); // Get player damage float getDamage(); // Get player cast damage float getCastDamage(); // Get x center of player float getCenterX(); // Get y center of player float getCenterY(); // Get value depending on direction facing float getXDir(); // Get knockback power float getKnockBackPower(); // Get status of invurnerability float getInvurnerableStatus(); // Get status of parrying float getParryStatus(); // Get status of dashing float getDashStatus(); // Get score float getScore(); // Get equip key state bool getEquipState(); // Check if item in hand is this index int getItemEqipped(int checkThisIndex); // Get item index in hand int getItemID(); // Return number of Coins keys for Player int getCoins(); // Return number of Silver keys for Player int getSilverKeys(); // Return number of Gold keys for Player int getGoldKeys(); public: // Reset High Scores void ResetHighScore(int LevelWeLoaded); // Load previous high score from PlayGame.cpp void ApplyHighScore(float previousHighScore); // Save current highs-core for current Level void SaveHighScore(int LevelToLoad); public: // Change volume void changeVolume(float newVolume); }; #endif /* LOCAL_PLAYERS_H_ */
21.523277
88
0.666811
[ "render", "object" ]
9c8821190d383ffa6ab93bbcaafc7bf8f7a66ed9
2,191
h
C
books/practical-cplusplus-design/pdCalc/src/backend/Stack.h
quanhua92/learning-notes
a9c50d3955c51bb58f4b012757c550b76c5309ef
[ "Apache-2.0" ]
null
null
null
books/practical-cplusplus-design/pdCalc/src/backend/Stack.h
quanhua92/learning-notes
a9c50d3955c51bb58f4b012757c550b76c5309ef
[ "Apache-2.0" ]
null
null
null
books/practical-cplusplus-design/pdCalc/src/backend/Stack.h
quanhua92/learning-notes
a9c50d3955c51bb58f4b012757c550b76c5309ef
[ "Apache-2.0" ]
null
null
null
// Copyright 2016 Adam B. Singer // Contact: PracticalDesignBook@gmail.com // // This file is part of pdCalc. // // pdCalc 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. // // pdCalc 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 pdCalc; if not, see <http://www.gnu.org/licenses/>. #ifndef STACK_H #define STACK_H #include "../utilities/Publisher.h" #include <vector> #include <memory> #include <string> namespace pdCalc { class StackEventData : public EventData { public: enum class ErrorConditions { Empty, TooFewArguments }; explicit StackEventData(ErrorConditions e) : err_(e) { } static const char* Message(ErrorConditions ec); const char* message() const; ErrorConditions error() const { return err_; } private: ErrorConditions err_; }; class Stack : private Publisher { class StackImpl; // so that the implementation can raise events public: static Stack& Instance(); void push(double, bool suppressChangeEvent = false); double pop(bool suppressChangeEvent = false); void swapTop(); // returns first min(n, stackSize) elements of the stack with the top of stack at position 0 std::vector<double> getElements(size_t n) const; void getElements(size_t n, std::vector<double>&) const; using Publisher::attach; using Publisher::detach; // these are just needed for testing size_t size() const; void clear() const; static const std::string StackChanged; static const std::string StackError; private: Stack(); ~Stack(); Stack(const Stack&) = delete; Stack(Stack&&) = delete; Stack& operator=(const Stack&) = delete; Stack& operator=(const Stack&&) = delete; std::unique_ptr<StackImpl> pimpl_; }; } #endif
27.049383
96
0.708352
[ "vector" ]
9c9430b859ad7fc7e673b6b33396d08bca2cd8a4
3,785
h
C
Plugins/org.mitk.gui.qt.overlaymanager/src/internal/QmitkOverlayManagerView.h
liu3xing3long/MITK-2016.11
385c506f9792414f40337e106e13d5fd61aa3ccc
[ "Apache-2.0", "BSD-3-Clause" ]
null
null
null
Plugins/org.mitk.gui.qt.overlaymanager/src/internal/QmitkOverlayManagerView.h
liu3xing3long/MITK-2016.11
385c506f9792414f40337e106e13d5fd61aa3ccc
[ "Apache-2.0", "BSD-3-Clause" ]
null
null
null
Plugins/org.mitk.gui.qt.overlaymanager/src/internal/QmitkOverlayManagerView.h
liu3xing3long/MITK-2016.11
385c506f9792414f40337e106e13d5fd61aa3ccc
[ "Apache-2.0", "BSD-3-Clause" ]
null
null
null
/*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkOverlayManagerView_h #define QmitkOverlayManagerView_h #include <berryISelectionListener.h> #include <QmitkAbstractView.h> #include <mitkIRenderWindowPartListener.h> #include "ui_QmitkOverlayManagerViewControls.h" #include "mitkOverlay.h" #include "mitkILifecycleAwarePart.h" class QmitkPropertyItemDelegate; class QmitkPropertyItemModel; class QSortFilterProxyModel; namespace mitk { class IPropertyAliases; class IPropertyDescriptions; class IPropertyPersistence; } /** \brief QmitkOverlayManagerView allows to view all overlays added to the mitk::OverlayManager. Properties of these overlays can be modified. \sa QmitkAbstractView \ingroup ${plugin_target}_internal */ class QmitkOverlayManagerView : public QmitkAbstractView, public mitk::IRenderWindowPartListener, public mitk::ILifecycleAwarePart { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: static const std::string VIEW_ID; QmitkOverlayManagerView(); ~QmitkOverlayManagerView(); protected: virtual void CreateQtPartControl(QWidget *parent) override; virtual void SetFocus() override; void RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart) override; void RenderWindowPartDeactivated(mitk::IRenderWindowPart*) override; Ui::QmitkOverlayManagerViewControls m_Controls; private slots: void OnCurrentRowChanged(const QModelIndex& current, const QModelIndex& previous); void OnPropertyListChanged(int index); void OnAddNewProperty(); void OnActivateOverlayList(); void OnOverlaySelectionChanged(QListWidgetItem* current,QListWidgetItem*); void OnDelete(); void OnAddOverlay(); private: void OnAddTextOverlay2D(); void OnAddTextOverlay3D(); void OnAddLabelOverlay(); void OnAddColorBarOverlay(); void OnAddScaleLegendOverlay(); void OnAddLogoOverlay(); QString GetPropertyNameOrAlias(const QModelIndex& index); void OnPropertyNameChanged(const itk::EventObject& event); void OnSelectionChanged(berry::IWorkbenchPart::Pointer part, const QList<mitk::DataNode::Pointer>& nodes) override; void InitializeAddAnimationMenu(); void OnOverlayAdded(itk::Object */*caller*/, const itk::EventObject &event); /** \see berry::IPartListener::PartActivated */ virtual void Activated(); /** \see berry::IPartListener::PartDeactivated */ virtual void Deactivated(); /** \see berry::IPartListener::PartVisible */ virtual void Visible(); /** \see berry::IPartListener::PartHidden */ virtual void Hidden(); QWidget* m_Parent; unsigned long m_PropertyNameChangedTag; unsigned long m_OverlayManagerObserverTag; std::string m_SelectionClassName; mitk::IPropertyAliases* m_PropertyAliases; mitk::IPropertyDescriptions* m_PropertyDescriptions; mitk::IPropertyPersistence* m_PropertyPersistence; QSortFilterProxyModel* m_ProxyModel; QmitkPropertyItemModel* m_Model; QmitkPropertyItemDelegate* m_Delegate; mitk::Overlay::Pointer m_SelectedOverlay; mitk::BaseRenderer* m_Renderer; QMenu* m_AddOverlayMenu; }; #endif // QmitkOverlayManagerView_h
29.80315
125
0.737649
[ "object" ]
9ca7345d967abd795497994368817edb4e5ee7be
4,173
h
C
model_server/dd/include/dd_or_xref_node.h
kit-transue/software-emancipation-discover
bec6f4ef404d72f361d91de954eae9a3bd669ce3
[ "BSD-2-Clause" ]
2
2015-11-24T03:31:12.000Z
2015-11-24T16:01:57.000Z
model_server/dd/include/dd_or_xref_node.h
radtek/software-emancipation-discover
bec6f4ef404d72f361d91de954eae9a3bd669ce3
[ "BSD-2-Clause" ]
null
null
null
model_server/dd/include/dd_or_xref_node.h
radtek/software-emancipation-discover
bec6f4ef404d72f361d91de954eae9a3bd669ce3
[ "BSD-2-Clause" ]
1
2019-05-19T02:26:08.000Z
2019-05-19T02:26:08.000Z
/************************************************************************* * Copyright (c) 2015, Synopsys, Inc. * * All rights reserved. * * * * Redistribution and use in source and binary forms, with or without * * modification, are permitted provided that the following conditions are * * met: * * * * 1. Redistributions of source code must retain the above copyright * * notice, this list of conditions and the following disclaimer. * * * * 2. Redistributions in binary form must reproduce the above copyright * * notice, this list of conditions and the following disclaimer in the * * documentation and/or other materials provided with the distribution. * * * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *************************************************************************/ #ifndef _dd_or_xref_node_h #define _dd_or_xref_node_h // dd_or_xref_node.h //------------------------------------------ // synopsis: // // This class forms the app nodes for ERD, inheritance browser, and other // views that are logically based on ddElements. Objects of this class // appear as children of a symbolTreeHeader object. If the corresponding // ddElement is loaded, it is connected to the dd_or_xref_node object by // an elem_of_dd_or_xref_node relation. The xrefSymbol pointer is always // valid regardless of whether the ddElement is loaded. //------------------------------------------ #ifndef _objOper_h #include <objOper.h> #endif #ifndef _xref_h #include <xref.h> #endif RelClass(ddElement); class dd_or_xref_node: public appTree { public: define_relational(dd_or_xref_node, appTree); copy_member(dd_or_xref_node); void send_string(ostream& = cout) const; char const *get_name() const; dd_or_xref_node(ddElementPtr); dd_or_xref_node(symbolPtr); dd_or_xref_node(const dd_or_xref_node&); ddElementPtr get_dd(); // loads if necessary ddElementPtr get_dd_if_loaded(); symbolPtr get_xrefSymbol() const; void print( ostream &str = cout, int level = 0) const; virtual int construct_symbolPtr(symbolPtr&) const; private: fsymbolPtr xref_ptr; }; generate_descriptor(dd_or_xref_node,appTree); defrel_one_to_many(ddElement,elem,dd_or_xref_node,dd_or_xref_node); /* START-LOG------------------------------------------- $Log: dd_or_xref_node.h $ Revision 1.3 1996/03/22 13:58:27EST aharlap added construct_symbolPtr // Revision 1.5 1993/06/25 13:53:13 bakshi // remove redundant dd_or_xref_node constructor (c++3.0.1 port) // // Revision 1.4 1993/05/10 19:53:40 glenn // Prevent repeat inclusion of nested header files. // // Revision 1.3 1993/03/15 21:30:07 davea // Change xrefSymbol* to fsymbolPtr // // Revision 1.2 1993/01/24 01:11:39 wmm // Add get_name() member function. // // Revision 1.1 1993/01/22 22:45:07 wmm // Initial revision // END-LOG--------------------------------------------- */ #endif // _dd_or_xref_node_h
39.367925
74
0.59861
[ "object" ]
8424b6ccdbeeb703234e7b7ac2024636b826f043
1,538
c
C
nitan/d/gumu/obj/huju-jia.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
1
2019-03-27T07:25:16.000Z
2019-03-27T07:25:16.000Z
nitan/d/gumu/obj/huju-jia.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
nitan/d/gumu/obj/huju-jia.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
// Room: /d/gumu/obj/huju-jia.c // Last Modifyed by Winder on Jan. 14 2002 #include <ansi.h> inherit ITEM; void create() { set_name(HIW "護具架" NOR, ({ "huju jia", "jia" }) ); set_weight(30000000); if( clonep() ) set_default_object(__FILE__); else { set("unit", "個"); set("long", "一個木頭製成的架子,上面掛着鐵甲(armor)等護具。你可以拿(na)些去用。\n"); set("material","wood"); set("no_get",1); } set("count", 4); setup(); } void init() { add_action("do_get","na"); } int do_get(string arg) { object ob, me=this_player(); string arg1, arg2; if(query("count") < 0) return notify_fail("架上已經空空如也了。\n"); if(!arg || sscanf(arg, "%s from %s", arg1, arg2)!=2) return notify_fail("命令格式: na <護具名稱> from jia。\n"); if (arg2!="jia") return notify_fail("命令格式: na <護具名稱> from jia。\n"); if( query_temp("marks/拿", me) ) return notify_fail("你怎麼這麼貪心,拿過了還要拿?\n"); if( query("combat_exp", me)>120000 ) return notify_fail("你武藝已到一定程度,還是自食其力吧。\n"); if (arg1 =="armor") { ob=new(ARMOR_DIR"tiejia"); ob->move(me); message_vision("$N從護具架上拿出一件$n。\n",me, ob); set_temp("marks/拿", 1, me); addn("count", -1); return 1; } return notify_fail("護具架上沒有你想要拿的東西。\n"); }
29.018868
73
0.471391
[ "object" ]
844199f9cc081dc72085a8bf332cfc77a04f256c
1,074
h
C
modules/Touch Fader/Preset_Manager.h
sensomusic/Usine-SDK
992675942d2b27cb11c8dfb81de19c1051f74577
[ "MIT" ]
4
2020-01-15T16:55:36.000Z
2020-10-20T09:42:32.000Z
modules/Touch Fader/Preset_Manager.h
sensomusic/Usine-SDK
992675942d2b27cb11c8dfb81de19c1051f74577
[ "MIT" ]
null
null
null
modules/Touch Fader/Preset_Manager.h
sensomusic/Usine-SDK
992675942d2b27cb11c8dfb81de19c1051f74577
[ "MIT" ]
1
2020-10-20T10:01:28.000Z
2020-10-20T10:01:28.000Z
#ifndef __PRESET_MANAGER_H__ #define __PRESET_MANAGER_H__ #include "../../sdk/UserDefinitions.h" #include <iostream> #include <fstream> #include <vector> using namespace std; class Preset { public: Preset(); Preset(string Path); void Store_Single(string tab ,float* address, string name, float min, float max, TScale scale, AnsiCharPtr symbol, AnsiCharPtr format, float defaultValue); void Store_Boolean(string tab ,LongBool* address, string name); void Store_Integer(string tab ,int* address, string name, int min, int max, TScale scale, AnsiCharPtr symbol, int defaultValue); void Store_Combobox(string tab, int* address, string name, AnsiCharPtr commaText); void Store_Caption(string tab, AnsiCharPtr caption); void Store_Color(string tab, TColorUsine* address, string name); void SaveToFile(string Path); void ReadFromFile(string Path); private: vector<pair<float*, string>> FPresets; vector<pair<LongBool*, string>> BPresets; vector<pair<int*, string>> IPresets; vector<pair<TColorUsine*, string>> CPresets; }; #endif //__PRESET_MANAGER_H__
26.85
156
0.764432
[ "vector" ]
8442fad1c8a247b3a5a74223a7e1a1cef777f2ac
4,905
h
C
dlb_pmd/frontend/pmd_studio/pmd_studio_audio_outputs_pvt.h
DolbyLaboratories/pmd_tool
4c6d27df5f531d488a627f96f489cf213cbf121a
[ "BSD-3-Clause" ]
11
2020-04-05T19:58:40.000Z
2022-02-04T19:18:12.000Z
dlb_pmd/frontend/pmd_studio/pmd_studio_audio_outputs_pvt.h
DolbyLaboratories/pmd_tool
4c6d27df5f531d488a627f96f489cf213cbf121a
[ "BSD-3-Clause" ]
1
2020-02-25T22:08:30.000Z
2020-02-25T22:08:30.000Z
dlb_pmd/frontend/pmd_studio/pmd_studio_audio_outputs_pvt.h
DolbyLaboratories/pmd_tool
4c6d27df5f531d488a627f96f489cf213cbf121a
[ "BSD-3-Clause" ]
null
null
null
/************************************************************************ * dlb_pmd * Copyright (c) 2021, Dolby Laboratories Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * 3. Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. **********************************************************************/ #ifndef __PMD_STUDIO_AUDIO_OUTPUTS_PVT_H__ #define __PMD_STUDIO_AUDIO_OUTPUTS_PVT_H__ #include "pmd_studio_audio_outputs.h" /* Definitons */ typedef enum { PMD_OUTPUT_MODE, SADM_OUTPUT_MODE, NUM_METADATA_FORMATS } pmd_studio_metadata_format; #define PMD_STUDIO_OUTPUT_NUM_CONFIG 3 static const dlb_pmd_speaker_config pmd_studio_output_config[PMD_STUDIO_OUTPUT_NUM_CONFIG] = { DLB_PMD_SPEAKER_CONFIG_2_0, DLB_PMD_SPEAKER_CONFIG_5_1, DLB_PMD_SPEAKER_CONFIG_5_1_4 }; static const char pmd_studio_metadata_format_names[][MAX_LABEL_LENGTH] = { "PMD", "sADM" }; // Required so can distinguish between Metadata and audio outputs in common // allocation table #define METADATA_OUTPUT_ID_OFFSET (100) #define METADATA_FRAME_RATE (25) #define METADATA_DLB_PMD_FRAME_RATE (DLB_PMD_FRAMERATE_2500) #define METADATA_SAMPLES_PER_FRAME (48000 / METADATA_FRAME_RATE) #define METADATA_MAX_CHANNELS (2) #define METADATA_MAX_BYTES_PER_SAMPLE (4) #define MAX_PCM_BUF_SIZE (METADATA_SAMPLES_PER_FRAME * METADATA_MAX_CHANNELS * METADATA_MAX_BYTES_PER_SAMPLE) typedef struct { pmd_studio_outputs *outputs; dlb_pmd_bool enabled; unsigned int id; float mixcoefs[MAX_OUTPUT_CHANNELS]; unsigned int config_index; unsigned int presentation_id; // Currently selected ids unsigned int startchannel; // Starts at 1, 0 is unassigned unsigned int endchannel; // Starts at 1, 0 is unassigned uiLabel *label; uiCheckbox *enable; uiCombobox *cfg; uiCombobox *pres; uiCombobox *schan; uiLabel *echan; } pmd_studio_audio_output; struct pmd_studio_metadata_output { pmd_studio_outputs *outputs; dlb_pmd_bool enabled; unsigned int id; pmd_studio_metadata_format format; dlb_pmd_bool subframemode; unsigned int channel; // Starts at 1, 0 is unassigned uiLabel *label; uiCheckbox *enable; uiCombobox *fmt; uiCombobox *mode; uiCombobox *chan; dlb_pmd_bool augmentor_error; pmd_studio_ring_buffer_struct *assigned_ring_buffer_struct; }; struct pmd_studio_outputs { pmd_studio *studio; uiWindow *window; pmd_studio_audio_output audio_outputs[MAX_AUDIO_OUTPUTS]; pmd_studio_metadata_output metadata_outputs[MAX_METADATA_OUTPUTS]; /* add in a count field to the struct for how many of the allocated outputs are intialized */ unsigned int audio_output_count; unsigned int metadata_output_count; uiGrid *audio_output_grid; uiGrid *metadata_output_grid; uiButton *add_aout_button; uiButton *add_mdout_button; /* shortcuts for presentation informtation between updates */ unsigned int num_presentations; dlb_pmd_element_id (*presentation_ids)[MAX_AUDIO_PRESENTATIONS]; char* (*presentation_names)[MAX_AUDIO_PRESENTATIONS]; /* channel based elements */ unsigned int num_chan_allocated; unsigned int chan_allocated[MAX_OUTPUT_CHANNELS]; /* 0 for unallocated, use output/metadata id to indicate allocation */ }; /** * Callback for when dlb_pmd augmentor fails. */ void pmd_studio_on_augmentor_fail_cb (void* data ,dlb_pmd_model *model ); #endif
33.141892
124
0.743323
[ "model" ]
8446dd6c64a311c85011f82a155dcf66a2adc6fd
378
h
C
include/il2cpp/System/Action_string__GameObject_.h
martmists-gh/BDSP
d6326c5d3ad9697ea65269ed47aa0b63abac2a0a
[ "MIT" ]
1
2022-01-15T20:20:27.000Z
2022-01-15T20:20:27.000Z
include/il2cpp/System/Action_string__GameObject_.h
martmists-gh/BDSP
d6326c5d3ad9697ea65269ed47aa0b63abac2a0a
[ "MIT" ]
null
null
null
include/il2cpp/System/Action_string__GameObject_.h
martmists-gh/BDSP
d6326c5d3ad9697ea65269ed47aa0b63abac2a0a
[ "MIT" ]
null
null
null
#pragma once #include "il2cpp.h" void System_Action_string__GameObject____ctor (System_Action_string__GameObject__o* __this, Il2CppObject* object, intptr_t method, const MethodInfo* method_info); void System_Action_string__GameObject___Invoke (System_Action_string__GameObject__o* __this, System_String_o* arg1, UnityEngine_GameObject_o* arg2, const MethodInfo* method_info);
54
179
0.862434
[ "object" ]
844aa091da0585507aa0b15ea981aeff3b3bbf03
1,095
c
C
scripts/4_World/Classes/UserActionsComponent/Actions/Interact/ActionOpenBarrel.c
Da0ne/DayZCommunityOfflineMode
77ebd221a877270e704c75bcc529a7b97c918f2e
[ "MIT" ]
1
2018-11-07T18:38:15.000Z
2018-11-07T18:38:15.000Z
SourceCode/scripts/4_World/Classes/UserActionsComponent/Actions/Interact/ActionOpenBarrel.c
DevulTj/DayZOfflineMode
0ba7e58858c7cd62e6a08f451ba60a3961575353
[ "MIT" ]
null
null
null
SourceCode/scripts/4_World/Classes/UserActionsComponent/Actions/Interact/ActionOpenBarrel.c
DevulTj/DayZOfflineMode
0ba7e58858c7cd62e6a08f451ba60a3961575353
[ "MIT" ]
null
null
null
class ActionOpenBarrel: ActionInteractBase { void ActionOpenBarrel() { m_MessageSuccess = "I have opened it."; //m_Animation = "open"; m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENLID; m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH; m_HUDCursorIcon = CursorIcons.OpenHood; } override int GetType() { return AT_OPEN_BARREL; } override string GetText() { return "open"; } override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item ) { Object target_object = target.GetObject(); if ( target_object.IsItemBase() ) { Barrel_ColorBase ntarget = Barrel_ColorBase.Cast( target_object ); if( ntarget ) { if( !ntarget.IsLocked() && !ntarget.IsOpen() ) { return true; } } } return false; } override void OnCompleteServer( PlayerBase player, ActionTarget target, ItemBase item, Param acdata ) { Object target_object = target.GetObject(); Barrel_ColorBase ntarget = Barrel_ColorBase.Cast( target_object ); if( ntarget ) { ntarget.Open(); } } }
22.8125
102
0.715982
[ "object" ]
846699deb56d8adebd7d16ae38757dc4a0080aba
3,047
c
C
interfaces/dia/lib/dialogs.c
krattai/monoflow
d777b8f345c5f2910114af7a186dc3bb6fe14aaf
[ "BSD-2-Clause" ]
1
2021-05-04T16:35:42.000Z
2021-05-04T16:35:42.000Z
interfaces/dia/lib/dialogs.c
krattai/monoflow
d777b8f345c5f2910114af7a186dc3bb6fe14aaf
[ "BSD-2-Clause" ]
null
null
null
interfaces/dia/lib/dialogs.c
krattai/monoflow
d777b8f345c5f2910114af7a186dc3bb6fe14aaf
[ "BSD-2-Clause" ]
1
2021-05-04T16:35:35.000Z
2021-05-04T16:35:35.000Z
/* Dia -- a diagram creation/manipulation program * Copyright (C) 1998 Alexander Larsson * * dialogs.c: helper routines for creating simple dialogs * Copyright (C) 2002 Lars Clausen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include "intl.h" #include <gtk/gtk.h> #include "geometry.h" #include "dialogs.h" /* Functions to create dialog widgets. These should, if used in other dialogs, go into a separate file. They are intended for fairly small transient dialogs such as parameters for exports. The functions are meant to be transparent in that they don't make their own structures, they're just collections of common actions. */ /** Creates a new dialog with a title and Ok and Cancel buttons. Default texts are supplied for Ok and Cancel buttons if NULL. Returns the created dialog and sets the two widget pointers. This function does not call gtk_widget_show(), do gtk_widget_show_all() when all has been added. */ GtkWidget * dialog_make(char *title, char *okay_text, char *cancel_text, GtkWidget **okay_button, GtkWidget **cancel_button) { GtkWidget *dialog = gtk_dialog_new(); GtkWidget *label = gtk_label_new(title); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label); *okay_button = gtk_button_new_with_label((okay_text!=NULL?okay_text:_("Ok"))); *cancel_button = gtk_button_new_with_label((cancel_text!=NULL?cancel_text:_("Cancel"))); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), *okay_button); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), *cancel_button); return dialog; } /** Adds a spinbutton with an attached label to a dialog. To get an integer spinbutton, give decimals as 0. */ GtkSpinButton * dialog_add_spinbutton(GtkWidget *dialog, char *title, real min, real max, real decimals) { GtkAdjustment *limits = GTK_ADJUSTMENT(gtk_adjustment_new(10.0, min, max, 1.0, 10.0, 0)); GtkWidget *box = gtk_hbox_new(FALSE, 10); GtkWidget *label = gtk_label_new(title); GtkWidget *entry = gtk_spin_button_new(limits, 10.0, decimals); gtk_box_pack_start (GTK_BOX(box), label, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX(box), entry, TRUE, TRUE, 0); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), box); return GTK_SPIN_BUTTON(entry); }
37.617284
90
0.741713
[ "geometry" ]
846a4b1fe8a8c5c97622abdd37ac656e502b6d9d
831
h
C
src/Cpp/1-100/75.SortColors.h
Peefy/PeefyLeetCode
92156e4b48ba19e3f02e4286b9f733e9769a1dee
[ "Apache-2.0" ]
2
2018-05-03T07:50:03.000Z
2018-06-17T04:32:13.000Z
src/Cpp/1-100/75.SortColors.h
Peefy/PeefyLeetCode
92156e4b48ba19e3f02e4286b9f733e9769a1dee
[ "Apache-2.0" ]
null
null
null
src/Cpp/1-100/75.SortColors.h
Peefy/PeefyLeetCode
92156e4b48ba19e3f02e4286b9f733e9769a1dee
[ "Apache-2.0" ]
3
2018-11-09T14:18:11.000Z
2021-11-17T15:23:52.000Z
#ifndef __SORT_COLORS_H #define __SORT_COLORS_H #include <iostream> #include <vector> #include <map> #include <queue> #include <math.h> #include <stack> #include <set> #include <algorithm> #include <unordered_set> #include <unordered_map> using namespace std; static int x = []() { ios::sync_with_stdio(false); cin.tie(NULL); return 0; }(); class Solution { public: /* 荷兰三色旗问题解 */ void sortColors(vector<int>& nums) { // 对于所有 idx < p0 : nums[idx < p0] = 0 // curr 是当前考虑元素的下标 int p0 = 0, curr = 0; // 对于所有 idx > p2 : nums[idx > p2] = 2 int p2 = nums.size() - 1; while (curr <= p2) { if (nums[curr] == 0) { swap(nums[curr++], nums[p0++]); } else if (nums[curr] == 2) { swap(nums[curr], nums[p2--]); } else curr++; } } }; #endif
16.959184
41
0.56077
[ "vector" ]
848a6275a1f286da8fbb46d650e8d75e141d14c8
698
h
C
Problems/240. Search a 2D Matrix II/solution.h
DanielDFY/LeetCode
5e39e3168db368617ac2f4509886f32cde5bd000
[ "MIT" ]
null
null
null
Problems/240. Search a 2D Matrix II/solution.h
DanielDFY/LeetCode
5e39e3168db368617ac2f4509886f32cde5bd000
[ "MIT" ]
null
null
null
Problems/240. Search a 2D Matrix II/solution.h
DanielDFY/LeetCode
5e39e3168db368617ac2f4509886f32cde5bd000
[ "MIT" ]
null
null
null
#ifndef LEETCODE_SOLUTION_H #define LEETCODE_SOLUTION_H #include <vector> using std::vector; class Solution { public: bool searchMatrix(vector<vector<int>>& matrix, int target) { int rows = matrix.size(); if (rows == 0) return false; int cols = matrix[0].size(); for (int row = 0, col = cols - 1; row < rows && col >= 0;) { int value = matrix[row][col]; if (value == target) { return true; } else if (value < target) { ++row; } else { --col; } } return false; } }; #endif //LEETCODE_SOLUTION_H
21.8125
68
0.471347
[ "vector" ]
848d8f27d5909898fa6f7bd8f27d30b25d57ea91
1,370
h
C
VC2010Samples/ATL/General/commap/aggreg/AggBlind.h
alonmm/VCSamples
6aff0b4902f5027164d593540fcaa6601a0407c3
[ "MIT" ]
300
2019-05-09T05:32:33.000Z
2022-03-31T20:23:24.000Z
VC2010Samples/ATL/General/commap/aggreg/AggBlind.h
JaydenChou/VCSamples
9e1d4475555b76a17a3568369867f1d7b6cc6126
[ "MIT" ]
9
2016-09-19T18:44:26.000Z
2018-10-26T10:20:05.000Z
VC2010Samples/ATL/General/commap/aggreg/AggBlind.h
JaydenChou/VCSamples
9e1d4475555b76a17a3568369867f1d7b6cc6126
[ "MIT" ]
633
2019-05-08T07:34:12.000Z
2022-03-30T04:38:28.000Z
// AggBlind.h : Declaration of the CAggBlind // // This is a part of the Active Template Library. // Copyright (c) Microsoft Corporation. All rights reserved. // // This source code is only intended as a supplement to the // Active Template Library Reference and related // electronic documentation provided with the library. // See these sources for detailed information regarding the // Active Template Library product. #include "resource.h" // main symbols ///////////////////////////////////////////////////////////////////////////// // Aggreg class CAggBlind : public CComObjectRootEx<CComSingleThreadModel>, public CComCoClass<CAggBlind, &CLSID_CAggBlind>, public IDispatchImpl<IAggBlind, &IID_IAggBlind, &LIBID_AGGREGLib, /*wMajor =*/ 1, /*wMinor =*/ 0>, public ISupportErrorInfo { public: CAggBlind(){} BEGIN_COM_MAP(CAggBlind) COM_INTERFACE_ENTRY(IDispatch) COM_INTERFACE_ENTRY(IAggBlind) COM_INTERFACE_ENTRY(ISupportErrorInfo) END_COM_MAP() //DECLARE_NOT_AGGREGATABLE(CAggBlind) // Remove the comment from the line above if you don't want your object to // support aggregation. The default is to support it DECLARE_REGISTRY_RESOURCEID(IDR_AggBlind) // ISupportsErrorInfo STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid); // IAggBlind public: STDMETHOD(get_Name)(BSTR* pbstrName); }; OBJECT_ENTRY_AUTO(__uuidof(CAggBlind), CAggBlind)
30.444444
99
0.737956
[ "object" ]
84ab055717505a483022523e59fcedee674b56fc
4,839
h
C
include/jet/fdm_linear_system2.h
PavelBlend/fluid-engine-dev
45b4bdbdb4c6d8c0beebc682180469198203b0ef
[ "MIT" ]
1,355
2016-05-08T07:29:22.000Z
2022-03-30T13:59:35.000Z
include/jet/fdm_linear_system2.h
Taiyuan-Zhang/fluid-engine-dev
45b4bdbdb4c6d8c0beebc682180469198203b0ef
[ "MIT" ]
208
2016-05-25T19:47:27.000Z
2022-01-17T04:18:29.000Z
include/jet/fdm_linear_system2.h
Taiyuan-Zhang/fluid-engine-dev
45b4bdbdb4c6d8c0beebc682180469198203b0ef
[ "MIT" ]
218
2016-08-23T16:51:10.000Z
2022-03-31T03:55:48.000Z
// Copyright (c) 2018 Doyub Kim // // I am making my contributions/submissions to this project solely in my // personal capacity and am not conveying any rights to any intellectual // property of any third parties. #ifndef INCLUDE_JET_FDM_LINEAR_SYSTEM2_H_ #define INCLUDE_JET_FDM_LINEAR_SYSTEM2_H_ #include <jet/array1.h> #include <jet/array2.h> #include <jet/matrix_csr.h> #include <jet/vector_n.h> namespace jet { //! The row of FdmMatrix2 where row corresponds to (i, j) grid point. struct FdmMatrixRow2 { //! Diagonal component of the matrix (row, row). double center = 0.0; //! Off-diagonal element where colum refers to (i+1, j) grid point. double right = 0.0; //! Off-diagonal element where column refers to (i, j+1) grid point. double up = 0.0; }; //! Vector type for 2-D finite differencing. typedef Array2<double> FdmVector2; //! Matrix type for 2-D finite differencing. typedef Array2<FdmMatrixRow2> FdmMatrix2; //! Linear system (Ax=b) for 2-D finite differencing. struct FdmLinearSystem2 { //! System matrix. FdmMatrix2 A; //! Solution vector. FdmVector2 x; //! RHS vector. FdmVector2 b; //! Clears all the data. void clear(); //! Resizes the arrays with given grid size. void resize(const Size2& size); }; //! Compressed linear system (Ax=b) for 2-D finite differencing. struct FdmCompressedLinearSystem2 { //! System matrix. MatrixCsrD A; //! Solution vector. VectorND x; //! RHS vector. VectorND b; //! Clears all the data. void clear(); }; //! BLAS operator wrapper for 2-D finite differencing. struct FdmBlas2 { typedef double ScalarType; typedef FdmVector2 VectorType; typedef FdmMatrix2 MatrixType; //! Sets entire element of given vector \p result with scalar \p s. static void set(ScalarType s, VectorType* result); //! Copies entire element of given vector \p result with other vector \p v. static void set(const VectorType& v, VectorType* result); //! Sets entire element of given matrix \p result with scalar \p s. static void set(ScalarType s, MatrixType* result); //! Copies entire element of given matrix \p result with other matrix \p v. static void set(const MatrixType& m, MatrixType* result); //! Performs dot product with vector \p a and \p b. static double dot(const VectorType& a, const VectorType& b); //! Performs ax + y operation where \p a is a matrix and \p x and \p y are //! vectors. static void axpy(double a, const VectorType& x, const VectorType& y, VectorType* result); //! Performs matrix-vector multiplication. static void mvm(const MatrixType& m, const VectorType& v, VectorType* result); //! Computes residual vector (b - ax). static void residual(const MatrixType& a, const VectorType& x, const VectorType& b, VectorType* result); //! Returns L2-norm of the given vector \p v. static ScalarType l2Norm(const VectorType& v); //! Returns Linf-norm of the given vector \p v. static ScalarType lInfNorm(const VectorType& v); }; //! BLAS operator wrapper for compressed 2-D finite differencing. struct FdmCompressedBlas2 { typedef double ScalarType; typedef VectorND VectorType; typedef MatrixCsrD MatrixType; //! Sets entire element of given vector \p result with scalar \p s. static void set(ScalarType s, VectorType* result); //! Copies entire element of given vector \p result with other vector \p v. static void set(const VectorType& v, VectorType* result); //! Sets entire element of given matrix \p result with scalar \p s. static void set(ScalarType s, MatrixType* result); //! Copies entire element of given matrix \p result with other matrix \p v. static void set(const MatrixType& m, MatrixType* result); //! Performs dot product with vector \p a and \p b. static double dot(const VectorType& a, const VectorType& b); //! Performs ax + y operation where \p a is a matrix and \p x and \p y are //! vectors. static void axpy(double a, const VectorType& x, const VectorType& y, VectorType* result); //! Performs matrix-vector multiplication. static void mvm(const MatrixType& m, const VectorType& v, VectorType* result); //! Computes residual vector (b - ax). static void residual(const MatrixType& a, const VectorType& x, const VectorType& b, VectorType* result); //! Returns L2-norm of the given vector \p v. static ScalarType l2Norm(const VectorType& v); //! Returns Linf-norm of the given vector \p v. static ScalarType lInfNorm(const VectorType& v); }; } // namespace jet #endif // INCLUDE_JET_FDM_LINEAR_SYSTEM2_H_
31.627451
79
0.675966
[ "vector" ]
84abdf17f9de0ce12fff8c2ebeb5548617530a4a
2,855
h
C
src/network_lib/src/jaln_encoding.h
yulicrunchy/JALoP
a474b464d4916fe559cf1df97c855232e5ec24ab
[ "Apache-2.0" ]
4
2016-01-18T20:49:23.000Z
2020-03-04T22:23:57.000Z
src/network_lib/src/jaln_encoding.h
yulicrunchy/JALoP
a474b464d4916fe559cf1df97c855232e5ec24ab
[ "Apache-2.0" ]
2
2019-09-23T21:04:25.000Z
2020-01-31T18:10:17.000Z
src/network_lib/src/jaln_encoding.h
yulicrunchy/JALoP
a474b464d4916fe559cf1df97c855232e5ec24ab
[ "Apache-2.0" ]
2
2021-04-01T20:53:12.000Z
2021-04-01T21:10:53.000Z
/** * @file jaln_encoding.h This file contains function declarations for code related * to the xml encodings. * * @section LICENSE * * Source code in 3rd-party is licensed and owned by their respective * copyright holders. * * All other source code is copyright Tresys Technology and licensed as below. * * Copyright (c) 2011 Tresys Technology LLC, Columbia, Maryland, USA * * This software was developed by Tresys Technology LLC * with U.S. Government sponsorship. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _JALN_ENCODING_INTERNAL_H_ #define _JALN_ENCODING_INTERNAL_H_ #include <axl.h> #include <jalop/jal_digest.h> #include <jalop/jaln_network.h> #include <jalop/jaln_network_types.h> /** * Case-insensitive comparison function for a list of strings. * * @param[in] a the first string * @param[in] b the second string * @return * - 0 if the strings are equal * - a negative value if a is '<' b * - a positive value if b is '<' a */ int jaln_string_list_case_insensitive_func(axlPointer a, axlPointer b); /** * Function to perform a case-insensitive search in an axl_list object that * contains strings. * * @param[in] ptr The object in the list * @param[in] data The string to look for */ axl_bool jaln_string_list_case_insensitive_lookup_func(axlPointer ptr, axlPointer data); /** * Function to convert an axlList of strings (char*) to an array of strings. * The resulting array is not NULL terminated. Each element in the array is a * copy of the string that was in the axlList. If NULL pointers are found in * \p list, they are copied to the resulting array as NULL. The array may be * freed by calling jaln_string_array_destroy(); * * @param[in] list The list of strings * @param[out] arr_out The resulting array. * @param[out] size_out The size of the array. * * @return JAL_OK on success, or JAL_E_INVAL if any of the parameters were * invalid. */ enum jal_status jaln_axl_string_list_to_array(axlList *list, char ***arr_out, int *size_out); /** * Function to release the memory allocated for an array of char *, such as is * returned by jaln_axl_string_list_to_array. * * @param[in,out] arr The array to destroy. * @param[in] arr_size The length of the array. */ void jaln_string_array_destroy(char ***arr, int arr_size); #endif // _JALN_ENCODING_INTERNAL_H_
33.588235
88
0.738354
[ "object" ]
8067694adfed1ebdc92438f05cfd9def4f21499e
12,905
h
C
Examples/include/Aspose.Pdf.Cpp/Text/FontCollection.h
kashifiqb/Aspose.PDF-for-C
13d49bba591c5704685820185741e64a462a5bdc
[ "MIT" ]
null
null
null
Examples/include/Aspose.Pdf.Cpp/Text/FontCollection.h
kashifiqb/Aspose.PDF-for-C
13d49bba591c5704685820185741e64a462a5bdc
[ "MIT" ]
null
null
null
Examples/include/Aspose.Pdf.Cpp/Text/FontCollection.h
kashifiqb/Aspose.PDF-for-C
13d49bba591c5704685820185741e64a462a5bdc
[ "MIT" ]
null
null
null
#pragma once // Copyright (c) 2001-2019 Aspose Pty Ltd. All Rights Reserved. #include <system/shared_ptr.h> #include <system/collections/list.h> #include <system/collections/ienumerator.h> #include <system/collections/icollection.h> #include <system/array.h> #include <cstdint> #include "Text/Font.h" #include "aspose_pdf_api_defs.h" namespace Aspose { namespace Pdf { class ApsToPdfConverter; } } namespace Aspose { namespace Pdf { namespace Engine { namespace IO { namespace ConvertStrategies { namespace ConvertHelpers { class LowLevelFontSubstitutor; } } } } } } namespace Aspose { namespace Pdf { namespace Engine { namespace CommonData { namespace Text { namespace Fonts { namespace Utilities { class FontUtilities; } } } } } } } namespace Aspose { namespace Pdf { namespace Engine { namespace CommonData { namespace Text { namespace Fonts { namespace Utilities { class DocumentCIDType2FontContentUpdater; } } } } } } } namespace Aspose { namespace Pdf { namespace Annotations { class Annotation; } } } namespace Aspose { namespace Pdf { namespace Annotations { class RedactionAnnotation; } } } namespace Aspose { namespace Pdf { namespace PageModel { class TextElement; } } } namespace Aspose { namespace Pdf { namespace Text { class FontAbsorber; } } } namespace Aspose { namespace Pdf { class Document; } } namespace Aspose { namespace Pdf { namespace Facades { class FormEditor; } } } namespace Aspose { namespace Pdf { namespace Annotations { class FreeTextAnnotation; } } } namespace Aspose { namespace Pdf { namespace Annotations { class WidgetAnnotation; } } } namespace Aspose { namespace Pdf { namespace Forms { class ButtonField; } } } namespace Aspose { namespace Pdf { namespace Forms { class C128Barcode; } } } namespace Aspose { namespace Pdf { namespace Forms { class CheckboxField; } } } namespace Aspose { namespace Pdf { namespace Forms { class Form; } } } namespace Aspose { namespace Pdf { namespace Forms { class RadioButtonOptionField; } } } namespace Aspose { namespace Pdf { class TextStamp; } } namespace Aspose { namespace Pdf { class Resources; } } namespace Aspose { namespace Pdf { namespace Forms { class TextModel; } } } namespace Aspose { namespace Pdf { namespace Tests { class RegressionTests_v7_6; } } } namespace Aspose { namespace Pdf { namespace Tests { class RegressionTests_v11_6; } } } namespace Aspose { namespace Pdf { namespace Tests { class RegressionTests_v19_5; } } } namespace Aspose { namespace Pdf { namespace Engine { namespace CommonData { namespace PageContent { class IResourceDictionary; } } } } } namespace Aspose { namespace Pdf { namespace Engine { namespace Data { class IPdfDictionary; } } } } namespace Aspose { namespace Pdf { namespace Collections { template<typename,typename> class AsposeHashDictionary; } } } namespace Aspose { namespace Pdf { namespace Engine { namespace Data { class IPdfObject; } } } } namespace Aspose { namespace Pdf { namespace Text { /// <summary> /// Represents font collection. /// </summary> /// <remarks> /// Font collections represented by <see cref="FontCollection"/> class are used in several scenarios. /// For example, in resources with <see cref="Resources::Fonts"/> property. /// </remarks> /// <example> /// The example demonstrates how to make all font declared on page as embedded. /// <code lang="C#"> /// // Open document /// Document doc = new Document(@"D:\Tests\input.pdf"); /// /// // ensure all fonts declared on page resources are embedded /// // note that if fonts are declared on form resources they are not accessible from page resources /// foreach(Aspose.Pdf.Txt.Font font in doc.Pages[1].Resources.Fonts) /// { /// if(!font.IsEmbedded) /// font.IsEmbedded = true; /// } /// /// doc.Save(@"D:\Tests\input.pdf"); /// </code> /// </example> class ASPOSE_PDF_SHARED_API FontCollection FINAL : public System::Collections::Generic::ICollection<System::SharedPtr<Aspose::Pdf::Text::Font>> { typedef FontCollection ThisType; typedef System::Collections::Generic::ICollection<System::SharedPtr<Aspose::Pdf::Text::Font>> BaseType; typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo; RTTI_INFO_DECL(); FRIEND_FUNCTION_System_MakeObject; friend class Aspose::Pdf::ApsToPdfConverter; friend class Aspose::Pdf::Engine::IO::ConvertStrategies::ConvertHelpers::LowLevelFontSubstitutor; friend class Aspose::Pdf::Engine::CommonData::Text::Fonts::Utilities::FontUtilities; friend class Aspose::Pdf::Engine::CommonData::Text::Fonts::Utilities::DocumentCIDType2FontContentUpdater; friend class Aspose::Pdf::Annotations::Annotation; friend class Aspose::Pdf::Annotations::RedactionAnnotation; friend class Aspose::Pdf::PageModel::TextElement; friend class Aspose::Pdf::Text::FontAbsorber; friend class Aspose::Pdf::Document; friend class Aspose::Pdf::Facades::FormEditor; friend class Aspose::Pdf::Annotations::FreeTextAnnotation; friend class Aspose::Pdf::Annotations::WidgetAnnotation; friend class Aspose::Pdf::Forms::ButtonField; friend class Aspose::Pdf::Forms::C128Barcode; friend class Aspose::Pdf::Forms::CheckboxField; friend class Aspose::Pdf::Forms::Form; friend class Aspose::Pdf::Forms::RadioButtonOptionField; friend class Aspose::Pdf::TextStamp; friend class Aspose::Pdf::Resources; friend class Aspose::Pdf::ApsToPdfConverter; friend class Aspose::Pdf::Forms::TextModel; friend class Aspose::Pdf::Tests::RegressionTests_v7_6; friend class Aspose::Pdf::Tests::RegressionTests_v11_6; friend class Aspose::Pdf::Tests::RegressionTests_v19_5; private: class FontsEnumerator : public System::Collections::Generic::IEnumerator<System::SharedPtr<Aspose::Pdf::Text::Font>> { typedef FontsEnumerator ThisType; typedef System::Collections::Generic::IEnumerator<System::SharedPtr<Aspose::Pdf::Text::Font>> BaseType; typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo; RTTI_INFO_DECL(); public: System::SharedPtr<Font> get_Current() const; FontsEnumerator(System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<Font>>> fonts, System::SharedPtr<Document> doc); bool MoveNext(); void Reset(); void Dispose(); protected: System::Object::shared_members_type GetSharedMembers() override; private: System::SharedPtr<System::Collections::Generic::IEnumerator<System::SharedPtr<Font>>> cursor; int32_t viewed; System::SharedPtr<Document> _licensedDoc; }; public: /// <summary> /// Gets the number of <see cref="Font"/> object elements actually contained in the collection. /// </summary> int32_t get_Count() const; /// <summary> /// Gets an object that can be used to synchronize access to the collection. /// </summary> System::SharedPtr<System::Object> get_SyncRoot(); /// <summary> /// Gets a value indicating whether access to the collection is synchronized (thread safe). /// </summary> bool get_IsSynchronized(); /// <summary> /// Gets a value indicating whether collection is read-only /// </summary> bool get_IsReadOnly(); /// <summary> /// Returns an enumerator for the entire collection. /// </summary> /// <returns>Enumerator object.</returns> System::SharedPtr<System::Collections::Generic::IEnumerator<System::SharedPtr<Font>>> GetEnumerator(); /// <summary> /// Copies the entire collection to a compatible one-dimensional Array, starting at the specified index of the target array /// </summary> /// <param name="array">Array of objects which will be copied.</param> /// <param name="index">Starting index from which copying will be started.</param> //[Obfuscation(Feature = "virtualization", Exclude = false)] void CopyTo(System::ArrayPtr<System::SharedPtr<Font>> array, int32_t index); /// <summary> /// Adds new font to font resources and returns automatically assigned name of font resource. /// </summary> /// <param name="newFont">Font object.</param> /// <param name="resName">The automatically assigned resource item name.</param> void Add(System::SharedPtr<Font> newFont, System::String& resName); /// <summary> /// Gets the font element at the specified index. /// </summary> /// <param name="index">Index within the collection.</param> /// <returns>Font object.</returns> //[Obfuscation(Feature = "virtualization", Exclude = false)] System::SharedPtr<Font> idx_get(int32_t index); /// <summary> /// Gets font from the collection by font name. /// Exception is thrown if font was not found. /// </summary> /// <param name="name">Name of the font.</param> /// <returns>Found font.</returns> System::SharedPtr<Font> idx_get(System::String name); /// <summary> /// Checks if font exists in font collection. /// </summary> /// <param name="name">Font name.</param> /// <returns>True in case collection contains the font with specified name.</returns> bool Contains(System::String const &name) const; /// <summary> /// Adds Font into collection. /// </summary> /// <param name="item">Font to add into collection</param> void Add(System::SharedPtr<Font> const &item); /// <summary> /// Determines whether the collection contains a specific value. /// </summary> /// <param name="item">The object to locate in the collection</param> /// <returns>true if item is found in the collection; otherwise, false.</returns> bool Contains(System::SharedPtr<Font> const &item) const; /// <summary> /// Deletes specified item from collection. /// </summary> /// <param name="item">The object to delete</param> /// <returns>true if item was deleted from collection; otherwise, false.</returns> bool Remove(System::SharedPtr<Font> const &item); protected: System::SharedPtr<Aspose::Pdf::Engine::CommonData::PageContent::IResourceDictionary> get_ResourceDictionary(); System::SharedPtr<Aspose::Pdf::Engine::Data::IPdfDictionary> get_FontsDictionary() const; bool get_ResourceMode(); /// <summary> /// Initializes empty font collection object /// </summary> FontCollection(System::SharedPtr<Document> doc); /// <summary> /// Initializes collection object with resource dictionary object /// </summary> FontCollection(System::SharedPtr<Aspose::Pdf::Engine::CommonData::PageContent::IResourceDictionary> resourceDictionary); /// <summary> /// Deletes the font element at the specified index. /// </summary> void Delete(int32_t index); /// <summary> /// Deletes Font with resource name specified /// </summary> /// <param name="fontResourceName">name of Font resurce</param> void Delete(System::String fontResourceName); /// <summary> /// Clears all the collection contents. To reinitialize collection data /// use Init() methods. /// </summary> void Clear(); /// <summary> /// Initializes collection object with resource dictionary object. /// </summary> void Init(System::SharedPtr<Aspose::Pdf::Engine::CommonData::PageContent::IResourceDictionary> resourceDictionary); /// <summary> /// Initializes collection object with empty resources. /// </summary> void Init(); System::SharedPtr<Aspose::Pdf::Collections::AsposeHashDictionary<System::String, System::SharedPtr<Font>>> GetHash(); /// <summary> /// Add new font to font collection. /// </summary> /// <param name="resName"></param> /// <param name="newFont"></param> void Add(System::String resName, System::SharedPtr<Aspose::Pdf::Engine::Data::IPdfObject> newFont); /// <summary> /// Adds to font resources new font entry with specified base font name. /// </summary> /// <param name="resName"></param> /// <param name="baseFontName"></param> void Add(System::String resName, System::String baseFontName); System::Object::shared_members_type GetSharedMembers() override; private: System::SharedPtr<Aspose::Pdf::Engine::CommonData::PageContent::IResourceDictionary> _resourceDictionary; System::SharedPtr<Aspose::Pdf::Engine::Data::IPdfDictionary> _fontsDictionary; System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<Font>>> fonts; System::SharedPtr<System::Object> syncRoot; System::SharedPtr<Aspose::Pdf::Collections::AsposeHashDictionary<System::String, System::SharedPtr<Font>>> hash; bool resourceMode; bool _isInitialized; System::WeakPtr<Document> _licensedDoc; void BuildHash(); }; } // namespace Text } // namespace Pdf } // namespace Aspose
44.809028
189
0.69384
[ "object" ]
8073f4735e6c4607f35dabf5c1fd9709bb3fbbb0
18,949
c
C
mceliece348864/lu_decomp.c
TJ-91/streamingCME
2a47669da6075562ca5ed40f8478486fcdcfaede
[ "CC0-1.0" ]
1
2021-03-16T17:50:00.000Z
2021-03-16T17:50:00.000Z
mceliece348864/lu_decomp.c
TJ-91/streamingCME
2a47669da6075562ca5ed40f8478486fcdcfaede
[ "CC0-1.0" ]
null
null
null
mceliece348864/lu_decomp.c
TJ-91/streamingCME
2a47669da6075562ca5ed40f8478486fcdcfaede
[ "CC0-1.0" ]
1
2021-02-11T12:10:58.000Z
2021-02-11T12:10:58.000Z
/* * Copyright 2021 MTG AG * * 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. */ #include <stdio.h> #include <stdint.h> #include "lu_decomp.h" /* * undo permutation P in constant time */ void undo_perm8(unsigned char *mat, int *P, int n) { unsigned char mask_cpy; unsigned char tmp; for(int i = n-1; i >= 0; i--) { for(int j = 0; j < n; j++) { mask_cpy = (j == P[i]); mask_cpy = -mask_cpy; for(int c = 0; c < n/8; c++) { tmp = mat[(n/8)*i + c]; mat[(n/8)*i + c] = (mat[(n/8)*i + c] & ~mask_cpy) | (mat[(n/8)*j + c] & mask_cpy); mat[(n/8)*j + c] = (mat[(n/8)*j + c] & ~mask_cpy) | (tmp & mask_cpy); } } } } /* * undo permutation P in constant time * assumes (n%32) == 0 */ void undo_perm32(unsigned char *mat, int *P, int n) { uint32_t mask_cpy; uint32_t tmp; uint32_t *mat_32_ptr = (uint32_t*)mat; for(int i = n-1; i >= 0; i--) { for(int j = 0; j < n; j++) { mask_cpy = (j == P[i]); mask_cpy = -mask_cpy; for(int c = 0; c < n/32; c++) { tmp = mat_32_ptr[(n/32)*i + c]; mat_32_ptr[(n/32)*i + c] = (mat_32_ptr[(n/32)*i + c] & ~mask_cpy) | (mat_32_ptr[(n/32)*j + c] & mask_cpy); mat_32_ptr[(n/32)*j + c] = (mat_32_ptr[(n/32)*j + c] & ~mask_cpy) | (tmp & mask_cpy); } } } } /* * undo permutation P in constant time * assumes (n%64) == 0 */ void undo_perm64(unsigned char *mat, int *P, int n) { uint64_t mask_cpy; uint64_t tmp; uint64_t *mat_64_ptr = (uint64_t*)mat; for(int i = n-1; i >= 0; i--) { for(int j = 0; j < n; j++) { mask_cpy = (j == P[i]); mask_cpy = -mask_cpy; for(int c = 0; c < n/64; c++) { tmp = mat_64_ptr[(n/64)*i + c]; mat_64_ptr[(n/64)*i + c] = (mat_64_ptr[(n/64)*i + c] & ~mask_cpy) | (mat_64_ptr[(n/64)*j + c] & mask_cpy); mat_64_ptr[(n/64)*j + c] = (mat_64_ptr[(n/64)*j + c] & ~mask_cpy) | (tmp & mask_cpy); } } } } /* * transposes the matrix mat * assumes that n is divisible by 8 and operates on 8x8 chunks * * in-place (constant overhead) */ void transpose8(unsigned char *mat, int n) { // naive solution ... // temporarily store a 8x8 chunk unsigned char tmp_rows[8]; // 8x8 block at once for(int i = 0; i < n; i += 8) { // handle i == j case (on diagonal) for(int k = 0; k < 8; k++) { tmp_rows[k] = mat[(n/8)*(i+k) + i/8]; mat[(n/8)*(i+k) + i/8] = 0; } for(int k = 0; k <= 7; k++) { for(int l = k; l < 8; l++) { mat[(n/8)*(i+k) + i/8] |= (((0x80 >> k) & tmp_rows[l]) << k) >> l; } } for(int k = 7; k > 0; k--) { for(int l = 0; l <= k-1; l++) { mat[(n/8)*(i+k) + i/8] |= (((0x80 >> k) & tmp_rows[l]) << k) >> l; } } // i != j for (int j = i+8; j < n; j+= 8) { for(int k = 0; k < 8; k++) { tmp_rows[k] = mat[(n/8)*(i+k) + j/8]; mat[(n/8)*(i+k) + j/8] = 0; } // write from columns to rows for(int k = 0; k < 8; k++) { for(int l = 0; l < 8; l++) { mat[(n/8)*(i+k) + j/8] |= (((0x80 >> k) & mat[(n/8)*(j+l) + i/8]) << k) >> l; } } // write from rows to columns for(int k = 0; k < 8; k++) { mat[(n/8)*(j+k) + i/8] = 0; for(int l = 0; l < 8; l++) { mat[(n/8)*(j+k) + i/8] |= (((0x80 >> k) & tmp_rows[l]) << k) >> l; } } } } } /* * Computes the LU Decomposition of a binary matrix in-place in constant time. * * mat: the matrix that shall be decomposed into L and U (in-place). * one unsigned char represents 8 bits of the binary matrix, i.e. mat[0] equals the first 8 elements of the first row. * L will be in the lower triangle matrix of mat and U in the upper triangle matrix. * pivot: int array that determines how the rows are switched (length N) * on 32 bit system this will probably result in N * 4 bytes additional memory * n: size of the square matrix mat. * * assumes dimensions (in bit) of mat are divisible by 8. */ int Doolittle8(unsigned char *mat, int *pivot, int n) { /* LU pseudo code (inplace, without pivoting) // n-1 Iterationsschritte for k := 1 to n-1 // Zeilen der Restmatrix werden durchlaufen for i := k+1 to n // Berechnung von L A(i,k) := A(i,k) / A(k,k) // Achtung: vorher Prüfung auf Nullwerte notwendig // Spalten der Restmatrix werden durchlaufen for j := k+1 to n // Berechnung von R A(i,j) := A(i,j) - A(i,k) * A(k,j) */ for(int k = 0; k < n-1; k++) { /* * swap rows in constant time ... */ pivot[k] = k; unsigned char tmp; for(unsigned int j = k+1; j < n; j++) { unsigned int mask_cpy = (mat[(n/8)*j + k/8] >> (7 - (k % 8))) & 1; // note: type has to be large enough to use as mask with j in pivot computing mask_cpy = mask_cpy & !((mat[(n/8)*k + k/8] >> (7 - (k % 8))) & 1); // add this in order to only actually switch with the first suitable row => consistent with "ref" non-constant-time impl mask_cpy = -mask_cpy; for(int c = 0; c < n/8; c++) { tmp = mat[(n/8)*j + c]; mat[(n/8)*j + c] = (mat[(n/8)*j + c] & ~mask_cpy) | (mat[(n/8)*k + c] & mask_cpy); mat[(n/8)*k + c] = (mat[(n/8)*k + c] & ~mask_cpy) | (tmp & mask_cpy); } // update pivot pivot[k] = (j & mask_cpy) | (pivot[k] & ~mask_cpy); } if (!((mat[k*n/8 + (k/8)] >> (7 - (k % 8))) & 1)) { return -1; } // for i := k+1 to n // for j := k+1 to n // A(i,j) := A(i,j) - A(i,k) * A(k,j) // // Bitwise: A(i,j) := A(i,j) ^ A(i,k) & A(k,j) // idea: take element A(i,k). It's either 0 or 1. Expand to 8 bits. Multiply with A(k,j), ... A(k,j+7) // basically, bit A(i,k) decides whether row A(k) (starting from the k+1'th column) is added to the i+1'th, ..., n'th rows below // use a mask for constant time instead of if(bit==1) for(int i = k+1; i < n; i++) { // 0x00 iff A(i,k) is zero. Otherweise 0xFF unsigned char mask_ik = 0x00 - ((mat[i*n/8 + (k/8)] >> (7 - (k % 8))) & 1); /* * First, handle the case that j = k+1 is not divisible by 8; i.e. only handle the last j%8 bits of this byte */ unsigned char mask_prepending = (unsigned char) (0x100 >> ((k+1) % 8)) - 1; unsigned char tmp = mat[n/8*i + (k+1)/8] & ~mask_prepending; // store the left side of the splitted byte in tmp mat[i*(n/8) + (k+1)/8] ^= (mask_ik & mat[k*(n/8) + (k+1)/8]); // restore the left bits: first set bits 0, then 'or' tmp mat[n/8*i + (k+1)/8] &= mask_prepending; mat[n/8*i + (k+1)/8] |= tmp; /* * now handle the rest of the row efficiently in byte-aligned byte-chunks */ for(int j = k+1 + (8-((k+1)%8)); j < n; j += 8) { // A(i,j) = A(i,j) + mask_ik * A(k,j) // => XOR Bits A(i,j) ... A(i,j+7) with (mask_ik & (A(k,j), ... A(k,j+7)) mat[i*(n/8) + j/8] ^= mask_ik & mat[k*(n/8) + j/8]; } } } pivot[n-1] = n-1; if ((mat[(n/8)*(n-1) + n/8-1] & 0x01) == 0) { return -1; } return 0; } /* assumes (n % 32) == 0 */ int Doolittle32(unsigned char *mat, int *pivot, int n) { uint32_t *mat_32_ptr = (uint32_t*)mat; for(int k = 0; k < n-1; k++) { /* * swap rows in constant time ... */ pivot[k] = k; uint32_t tmp; for(uint32_t j = k+1; j < n; j++) { uint32_t mask_cpy = (mat[(n/8)*j + k/8] >> (7 - (k % 8))) & 1; // note: type has to be large enough to use as mask with j in pivot computing mask_cpy = mask_cpy & !((mat[(n/8)*k + k/8] >> (7 - (k % 8))) & 1); // add this in order to only actually switch with the first suitable row => consistent with "ref" non-constant-time impl mask_cpy = -mask_cpy; for(int c = 0; c < n/32; c++) { // copy in 32 bit chunks tmp = mat_32_ptr[(n/32)*j + c]; mat_32_ptr[(n/32)*j + c] = (mat_32_ptr[(n/32)*j + c] & ~mask_cpy) | (mat_32_ptr[(n/32)*k + c] & mask_cpy); mat_32_ptr[(n/32)*k + c] = (mat_32_ptr[(n/32)*k + c] & ~mask_cpy) | (tmp & mask_cpy); } // update pivot pivot[k] = (j & mask_cpy) | (pivot[k] & ~mask_cpy); } if (!((mat[k*n/8 + (k/8)] >> (7 - (k % 8))) & 1)) { return -1; } for(int i = k+1; i < n; i++) { // 0x00 iff A(i,k) is zero. Otherweise 0xFF uint32_t mask_ik = 0x00000000 - ((mat[i*n/8 + (k/8)] >> (7 - (k % 8))) & 1); /* * First, handle the case that j = k+1 is not divisible by 8; i.e. only handle the last j%8 bits of this byte */ unsigned char mask_prepending = (unsigned char) (0x100 >> ((k+1) % 8)) - 1; unsigned char tmp = mat[n/8*i + (k+1)/8] & ~mask_prepending; // store the left side of the splitted byte in tmp mat[i*(n/8) + (k+1)/8] ^= (mask_ik & mat[k*(n/8) + (k+1)/8]); // restore the left bits: first set bits 0, then 'or' tmp mat[n/8*i + (k+1)/8] &= mask_prepending; mat[n/8*i + (k+1)/8] |= tmp; // handle byte-aligned chunks until we are 4-byte aligned int k_1_aligned = k+1 + (8-((k+1)%8)); int k_4_aligned = k_1_aligned; for(int j = k_1_aligned; (j < n) && ((j%32) != 0); j += 8) { mat[i*(n/8) + j/8] ^= mask_ik & mat[k*(n/8) + j/8]; k_4_aligned = j+8; } /* * now handle the rest of the row efficiently in 4-byte-aligned byte-chunks */ for(int j = k_4_aligned; j < n; j += 32) { mat_32_ptr[i*(n/32) + j/32] ^= mask_ik & mat_32_ptr[k*(n/32) + j/32]; } } } pivot[n-1] = n-1; if ((mat[(n/8)*(n-1) + n/8-1] & 0x01) == 0) { return -1; } return 0; } /* assumes (n % 64) == 0 */ int Doolittle64(unsigned char *mat, int *pivot, int n) { uint64_t *mat_64_ptr = (uint64_t*)mat; for(int k = 0; k < n-1; k++) { /* * swap rows in constant time ... */ pivot[k] = k; uint64_t tmp; for(uint64_t j = k+1; j < n; j++) { uint64_t mask_cpy = (mat[(n/8)*j + k/8] >> (7 - (k % 8))) & 1; // note: type has to be large enough to use as mask with j in pivot computing mask_cpy = mask_cpy & !((mat[(n/8)*k + k/8] >> (7 - (k % 8))) & 1); // add this in order to only actually switch with the first suitable row => consistent with "ref" non-constant-time impl mask_cpy = -mask_cpy; for(int c = 0; c < n/64; c++) { // copy in 32 bit chunks tmp = mat_64_ptr[(n/64)*j + c]; mat_64_ptr[(n/64)*j + c] = (mat_64_ptr[(n/64)*j + c] & ~mask_cpy) | (mat_64_ptr[(n/64)*k + c] & mask_cpy); mat_64_ptr[(n/64)*k + c] = (mat_64_ptr[(n/64)*k + c] & ~mask_cpy) | (tmp & mask_cpy); } // update pivot pivot[k] = (j & mask_cpy) | (pivot[k] & ~mask_cpy); } if (!((mat[k*n/8 + (k/8)] >> (7 - (k % 8))) & 1)) { return -1; } for(int i = k+1; i < n; i++) { // 0x00 iff A(i,k) is zero. Otherweise 0xFF uint64_t mask_ik = 0x0000000000000000 - ((mat[i*n/8 + (k/8)] >> (7 - (k % 8))) & 1); /* * First, handle the case that j = k+1 is not divisible by 8; i.e. only handle the last j%8 bits of this byte */ unsigned char mask_prepending = (unsigned char) (0x100 >> ((k+1) % 8)) - 1; unsigned char tmp = mat[n/8*i + (k+1)/8] & ~mask_prepending; // store the left side of the splitted byte in tmp mat[i*(n/8) + (k+1)/8] ^= (mask_ik & mat[k*(n/8) + (k+1)/8]); // restore the left bits: first set bits 0, then 'or' tmp mat[n/8*i + (k+1)/8] &= mask_prepending; mat[n/8*i + (k+1)/8] |= tmp; // handle byte-aligned chunks until we are 8-byte aligned int k_1_aligned = k+1 + (8-((k+1)%8)); int k_8_aligned = k_1_aligned; for(int j = k_1_aligned; (j < n) && ((j%64) != 0); j += 8) { mat[i*(n/8) + j/8] ^= mask_ik & mat[k*(n/8) + j/8]; k_8_aligned = j+8; } /* * now handle the rest of the row efficiently in 4-byte-aligned byte-chunks */ for(int j = k_8_aligned; j < n; j += 64) { mat_64_ptr[i*(n/64) + j/64] ^= mask_ik & mat_64_ptr[k*(n/64) + j/64]; } } } pivot[n-1] = n-1; if ((mat[(n/8)*(n-1) + n/8-1] & 0x01) == 0) { return -1; } return 0; } /* * invert an upper triangle matrix with diagonal only 1s * Assumes n%8 == 0 * in-place, constant time */ void invert_U8(unsigned char *U, int n) { /* * inversion == backwards substitution * * For all columns c = n-1 ... 0 * For all rows c-1 ... 0 * add (row c) * (leading (c'th) element of row r) to row r. * only do it for the k elements k = c+1 ... n-1 */ for(int c = n-2; c >= 0; c--) { /* * Basically: * copy elements c+1 to n-1 from c'th row to r'th row iff leading element of row r is 1 */ for(int r = c-1; r >= 0; r--) { /* * first copy all "full bytes" at the right */ unsigned char mask_rc = 0x00 - ((U[r*n/8 + (c/8)] >> (7 - (c % 8))) & 1); // mask for the element U(r,c) for(int k = n-1; k >= c+1 + 8; k -= 8) { U[r*(n/8) + k/8] ^= mask_rc & U[c*(n/8) + k/8]; } /* * then handle the left-most "partial byte" */ int k = c+1; unsigned char mask_prepending = (unsigned char) (0x100 >> (k % 8)) - 1; unsigned char tmp_rk = U[r*(n/8) + k/8] & ~mask_prepending; // store the left side of the splitted byte in tmp U[r*(n/8) + k/8] ^= (mask_rc & U[c*(n/8) + k/8]); // restore the left bits: first set bits 0, then 'or' tmp U[r*(n/8) + k/8] &= mask_prepending; U[r*(n/8) + k/8] |= tmp_rk; } } } /* * invert a lower triangle matrix with diagonal only 1s * Assumes n%8 == 0 * in-place, constant time */ void invert_L8(unsigned char *L, int n) { /* * inversion == forward substitution * * For all columns c = 1 ... n-1 * For all rows c+1 ... n-1 * add (row c) * (leading (c'th) element of row r) to row r. * only do it for the k elements k = 0 ... c-1 */ for(int c = 1; c <= n-1; c++) { /* * Basically: * copy elements 0 to c-1 from c'th row to r'th row iff leading element of row r is 1 */ for(int r = c+1; r <= n-1; r++) { /* * first copy all "full bytes" at the left */ unsigned char mask_rc = 0x00 - ((L[r*n/8 + (c/8)] >> (7 - (c % 8))) & 1); // mask for the element U(r,c) for(int k = 0; k <= c-1 - 8; k += 8) { L[r*(n/8) + k/8] ^= mask_rc & L[c*(n/8) + k/8]; } /* * then handle the right-most "partial byte" */ int k = c-1; unsigned char mask_prepending = ((unsigned char) (0x80 >> (k % 8)) - 1); unsigned char tmp_rk = L[r*(n/8) + k/8] & mask_prepending; // store the right side of the splitted byte in tmp L[r*(n/8) + k/8] ^= (mask_rc & L[c*(n/8) + k/8]); // restore the right bits: first set bits 0, then 'or' tmp L[r*(n/8) + k/8] &= ~mask_prepending; L[r*(n/8) + k/8] |= tmp_rk; } } } /* * multiplies the matrices L and U that are inside mat (after LU decomposition) * in-place, constant time * * uses additional space of n/8 bytes (one row / col) */ void multiply_UL_inplace8(unsigned char *mat, int n) { // compute A_11 first, then the surrounding elements, and so on // => the upper-left 1x1 matrix // => the upper-left 2x2 matrix // => ... // for the i x i submatrix, the new elements are computed by the product of a (n-i) dimensional row and column vector each. // In the i'th step, we compute the column A(j, i) for 0 <= j <= i // In the i'th step, we compute the row A(i, j) for 0 <= j < i // A column element A(j, i) is computed by A(j, i) ^= A(j, k) & A(k, i) for k = i+1, ..., n // A row element A(i, j) is computed by A(i, j) ^= A(k, j) & A(i, k) for k = i+1, ..., n // store one colum intermediately unsigned char col[n/8]; // compute upper-left i x i matrix for(int i = 0; i < n-1; i++) { // compute i'th column that is used i times for the computation of the column elements A(i, j) j <= i col[(i+1)/8] = 0; for(int c = i+1; c < n; c++) { if(c % 8 == 0) { col[c/8] = 0; } col[c/8] |= (((0x80U >> i%8) & mat[(n/8)*c + i/8]) << i%8) >> c%8; } unsigned char col_mul_mask = (0x100 >> ((i+1) % 8)) - 1; // decide to view the diagonal element i*i as part of the column (and not of the row) // compute column elements for(int j = 0; j <= i; j++) { // compute the j'th column element A(j, i) // first handle the possible partial byte at the beginning unsigned char parity_bit = col[(i+1)/8] & mat[(n/8)*j + (i+1)/8]; parity_bit &= col_mul_mask; // handle the rest of the row for(int k = (i+1) + (8-(i+1)%8); k < n; k+=8) { // ith_col times the kth row: A(j, i) ^= A(j, k) & A(k, i) parity_bit ^= mat[(n/8)*j + k/8] & col[k/8]; } // now actually compute and set the bit A(j, i) parity_bit ^= parity_bit >> 4; parity_bit ^= parity_bit >> 2; parity_bit ^= parity_bit >> 1; // TODO: simplify....? mat[(n/8)*j + i/8] = (mat[(n/8)*j + i/8] & (unsigned char)~(0x80U >> (i%8))) | (((parity_bit << (7-i%8)) ^ mat[(n/8)*j + i/8]) & (1 << (7-(i%8)))); } // compute row elements for(int j = 0; j < i; j+=8) { // compute the j'th row element A(i, j) for(int k = i+1; k < n; k++) { // multiply the 8 elements A(k, j) ... A(k, j+7) by A(i, k) unsigned char mask_ik = 0x00 - ((mat[(n/8)*i + k/8] >> (7 - (k % 8))) & 1); // 0x00 if bit is zero, 0xFF otherwise if(j + 8 > i) { // handle the case that i is not divisible by 8 and we only partially set the first i % 8 bits unsigned char mask_prepending = ~((unsigned char) (0x100 >> (i % 8)) - 1); unsigned char tmp_ij = mat[(n/8)*i + j/8] & ~mask_prepending; mat[(n/8)*i + j/8] ^= mat[(n/8)*k + j/8] & mask_ik; mat[(n/8)*i + j/8] &= mask_prepending; mat[(n/8)*i + j/8] |= tmp_ij; } else { mat[(n/8)*i + j/8] ^= mat[(n/8)*k + j/8] & mask_ik; } } } } }
29.935229
195
0.504195
[ "vector" ]
80826d8159b4da721a72cbb56cd7055aa597b06d
1,256
h
C
VFCLibrary/GEOMBoundingSphereCalc.h
idiap/CitySim-Solver
fec9007a67660186e7bc3b090651bf80e08d4d0d
[ "BSD-3-Clause" ]
2
2020-11-26T09:31:10.000Z
2020-12-09T17:13:28.000Z
VFCLibrary/GEOMBoundingSphereCalc.h
kaemco/CitySim-Solver
4274f442f57ab9e59869ec6652c370cc5bd400ee
[ "BSD-3-Clause" ]
1
2022-02-03T09:40:17.000Z
2022-02-03T09:40:17.000Z
VFCLibrary/GEOMBoundingSphereCalc.h
idiap/CitySim-Solver
fec9007a67660186e7bc3b090651bf80e08d4d0d
[ "BSD-3-Clause" ]
3
2020-10-30T20:48:15.000Z
2021-09-03T08:51:39.000Z
#ifndef _INC_GEOMBOUNDINGSPHERECALC_INCLUDED #define _INC_GEOMBOUNDINGSPHERECALC_INCLUDED #include <list> #include <vector> #include "GENPoint.h" #include "GEOMSphere.h" /* * Calculate a bounding sphere using algorithm from "Smallest enclosing disks * (balls and ellipsoids)", by Emo Welzl */ class GEOMBoundingSphereCalc { public: typedef std::list<GENPoint> List_t; typedef std::list<GENPoint>::iterator PointIt_t; typedef std::vector<const GENPoint*> Vector_t; template <class ITERATOR> GEOMSphere Calculate(const ITERATOR pointBegin, const ITERATOR pointEnd); private: GEOMSphere Calculate(List_t::iterator endPoint); void MoveToFrontOfList(List_t::iterator p); void Recurse(List_t::iterator endPoint); List_t m_points; GEOMSphericalBasis m_basis; GEOMSphere m_currentSphere; }; // .......................................................................... template <class ITERATOR> GEOMSphere GEOMBoundingSphereCalc::Calculate(const ITERATOR pointBegin, const ITERATOR pointEnd) { for(ITERATOR it = pointBegin; it !=pointEnd ; ++it) { m_points.push_back(*it); } GEOMSphere MB = Calculate(m_points.end()); return MB; } #endif // _INC_GEOMBOUNDINGSPHERECALC_INCLUDED
24.627451
97
0.698248
[ "vector" ]
808e67d44d2f837958bb1037500c222112eaeaa1
4,282
h
C
include/topaz/asset.h
jcorks/topaz
faa15d66678fc711ae22fc6fdd9432408dc05155
[ "MIT" ]
null
null
null
include/topaz/asset.h
jcorks/topaz
faa15d66678fc711ae22fc6fdd9432408dc05155
[ "MIT" ]
null
null
null
include/topaz/asset.h
jcorks/topaz
faa15d66678fc711ae22fc6fdd9432408dc05155
[ "MIT" ]
null
null
null
/* Copyright (c) 2020, Johnathan Corkery. (jcorkery@umich.edu) All rights reserved. This file is part of the topaz project (https://github.com/jcorks/topaz) topaz was released under the MIT License, as detailed below. 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. */ #ifndef H_TOPAZDC__ASSET__INCLUDED #define H_TOPAZDC__ASSET__INCLUDED #include <topaz/containers/string.h> typedef struct topaz_t topaz_t; /// /// /// An asset represents a useful abstraction for an object /// that was populated from raw data, usually from a file or /// from memory. /// /// On it's own, it does not do much. But, it serves as a /// base class for more useful applications /// /// typedef struct topazAsset_t topazAsset_t; /// Type of asset. /// /// Every asset has a type that gives a hint to what child class /// it is. /// typedef enum topazAsset_Type topazAsset_Type; enum topazAsset_Type { /// The asset doesnt have a type. This is used for /// error cases. /// topazAsset_Type_None, /// The asset is an image. See image.h /// topazAsset_Type_Image, /// The asset is an audio waveform. /// topazAsset_Type_Sound, /// The asset defines how a 3D mesh should be expressed. /// topazAsset_Type_Material, /// The asset is a particle specification. /// topazAsset_Type_Particle, /// The asset is raw bytes / text. /// topazAsset_Type_Data, /// The asset is a 3D mesh /// topazAsset_Type_Mesh, topazAsset_Type_Count, }; /// Callback for assets. /// typedef void (*topaz_asset_callback)( /// Asset in question topazAsset_t * asset, /// generic data associated with the asset void * userData ); typedef struct topazAsset_Attributes_t topazAsset_Attributes_t; /// Serves as the interface for asset objects /// struct topazAsset_Attributes_t { /// Called when the asset is finalized. /// topaz_asset_callback on_create; /// Called when the asset is destroyed /// topaz_asset_callback on_destroy; /// User-provided data. /// void * userData; }; /// Creates a new asset. /// topazAsset_t * topaz_asset_create( /// Topaz context. topaz_t * context, /// Type of the asset. topazAsset_Type type, /// Name of the asset. const topazString_t * name, /// Attributes of the asset. const topazAsset_Attributes_t * attribs ); /// Destroys an asset. /// void topaz_asset_destroy( /// The asset to destroy. topazAsset_t * asset ); /// Returns the attributes that the asset was /// created with. /// const topazAsset_Attributes_t * topaz_asset_get_attributes( /// The asset to retrieve attributes from. const topazAsset_t * asset ); /// Gets the name of the asset. This is immutable. /// const topazString_t * topaz_asset_get_name( /// The asset in question. const topazAsset_t * asset ); /// Gets the type of the asset. This is immutable. /// topazAsset_Type topaz_asset_get_type( /// The asset in question. const topazAsset_t * asset ); #endif
23.527473
81
0.670715
[ "mesh", "object", "3d" ]
8090843c0904fbfd0edab83c74617da2bb0272c1
92,680
h
C
wiringOP/wiringPi/font.h
ZhuYanzhen1/wiringPi
8063b3fa6ad5193cf08059614694f1349ad0f13c
[ "MIT" ]
1
2021-12-21T20:30:12.000Z
2021-12-21T20:30:12.000Z
wiringOP/wiringPi/font.h
ZhuYanzhen1/wiringPi
8063b3fa6ad5193cf08059614694f1349ad0f13c
[ "MIT" ]
null
null
null
wiringOP/wiringPi/font.h
ZhuYanzhen1/wiringPi
8063b3fa6ad5193cf08059614694f1349ad0f13c
[ "MIT" ]
null
null
null
/* * This 5x7 font is sourced from Adafruit-GFX-Library on github. */ #ifndef FONT_H #define FONT_H struct font_info { uint8_t width; uint8_t height; uint8_t spacing; uint8_t offset; uint8_t *data; }; static const uint8_t font1_data[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, 0x18, 0x3C, 0x18, 0x00, 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, 0x18, 0x24, 0x18, 0x00, 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x26, 0x29, 0x79, 0x29, 0x26, 0x40, 0x7F, 0x05, 0x05, 0x07, 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x14, 0x22, 0x7F, 0x22, 0x14, 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, 0x66, 0x89, 0x95, 0x6A, 0x60, 0x60, 0x60, 0x60, 0x60, 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x08, 0x04, 0x7E, 0x04, 0x08, 0x10, 0x20, 0x7E, 0x20, 0x10, 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x1E, 0x10, 0x10, 0x10, 0x10, 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x30, 0x38, 0x3E, 0x38, 0x30, 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x23, 0x13, 0x08, 0x64, 0x62, 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x80, 0x70, 0x30, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x60, 0x60, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x72, 0x49, 0x49, 0x49, 0x46, 0x21, 0x41, 0x49, 0x4D, 0x33, 0x18, 0x14, 0x12, 0x7F, 0x10, 0x27, 0x45, 0x45, 0x45, 0x39, 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x41, 0x21, 0x11, 0x09, 0x07, 0x36, 0x49, 0x49, 0x49, 0x36, 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x41, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x41, 0x22, 0x14, 0x08, 0x02, 0x01, 0x59, 0x09, 0x06, 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x7F, 0x49, 0x49, 0x49, 0x36, 0x3E, 0x41, 0x41, 0x41, 0x22, 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x49, 0x49, 0x49, 0x41, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x3E, 0x41, 0x41, 0x51, 0x73, 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x41, 0x7F, 0x41, 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, 0x7F, 0x08, 0x14, 0x22, 0x41, 0x7F, 0x40, 0x40, 0x40, 0x40, 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x09, 0x09, 0x09, 0x06, 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x26, 0x49, 0x49, 0x49, 0x32, 0x03, 0x01, 0x7F, 0x01, 0x03, 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x63, 0x14, 0x08, 0x14, 0x63, 0x03, 0x04, 0x78, 0x04, 0x03, 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x41, 0x41, 0x41, 0x7F, 0x04, 0x02, 0x01, 0x02, 0x04, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x03, 0x07, 0x08, 0x00, 0x20, 0x54, 0x54, 0x78, 0x40, 0x7F, 0x28, 0x44, 0x44, 0x38, 0x38, 0x44, 0x44, 0x44, 0x28, 0x38, 0x44, 0x44, 0x28, 0x7F, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x08, 0x7E, 0x09, 0x02, 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, 0x44, 0x7D, 0x40, 0x00, 0x20, 0x40, 0x40, 0x3D, 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, 0x7C, 0x04, 0x78, 0x04, 0x78, 0x7C, 0x08, 0x04, 0x04, 0x78, 0x38, 0x44, 0x44, 0x44, 0x38, 0xFC, 0x18, 0x24, 0x24, 0x18, 0x18, 0x24, 0x24, 0x18, 0xFC, 0x7C, 0x08, 0x04, 0x04, 0x08, 0x48, 0x54, 0x54, 0x54, 0x24, 0x04, 0x04, 0x3F, 0x44, 0x24, 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x44, 0x28, 0x10, 0x28, 0x44, 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x41, 0x36, 0x08, 0x00, 0x02, 0x01, 0x02, 0x04, 0x02, 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x1E, 0xA1, 0xA1, 0x61, 0x12, 0x3A, 0x40, 0x40, 0x20, 0x7A, 0x38, 0x54, 0x54, 0x55, 0x59, 0x21, 0x55, 0x55, 0x79, 0x41, 0x22, 0x54, 0x54, 0x78, 0x42, // a-umlaut 0x21, 0x55, 0x54, 0x78, 0x40, 0x20, 0x54, 0x55, 0x79, 0x40, 0x0C, 0x1E, 0x52, 0x72, 0x12, 0x39, 0x55, 0x55, 0x55, 0x59, 0x39, 0x54, 0x54, 0x54, 0x59, 0x39, 0x55, 0x54, 0x54, 0x58, 0x00, 0x00, 0x45, 0x7C, 0x41, 0x00, 0x02, 0x45, 0x7D, 0x42, 0x00, 0x01, 0x45, 0x7C, 0x40, 0x7D, 0x12, 0x11, 0x12, 0x7D, // A-umlaut 0xF0, 0x28, 0x25, 0x28, 0xF0, 0x7C, 0x54, 0x55, 0x45, 0x00, 0x20, 0x54, 0x54, 0x7C, 0x54, 0x7C, 0x0A, 0x09, 0x7F, 0x49, 0x32, 0x49, 0x49, 0x49, 0x32, 0x3A, 0x44, 0x44, 0x44, 0x3A, // o-umlaut 0x32, 0x4A, 0x48, 0x48, 0x30, 0x3A, 0x41, 0x41, 0x21, 0x7A, 0x3A, 0x42, 0x40, 0x20, 0x78, 0x00, 0x9D, 0xA0, 0xA0, 0x7D, 0x3D, 0x42, 0x42, 0x42, 0x3D, // O-umlaut 0x3D, 0x40, 0x40, 0x40, 0x3D, 0x3C, 0x24, 0xFF, 0x24, 0x24, 0x48, 0x7E, 0x49, 0x43, 0x66, 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, 0xFF, 0x09, 0x29, 0xF6, 0x20, 0xC0, 0x88, 0x7E, 0x09, 0x03, 0x20, 0x54, 0x54, 0x79, 0x41, 0x00, 0x00, 0x44, 0x7D, 0x41, 0x30, 0x48, 0x48, 0x4A, 0x32, 0x38, 0x40, 0x40, 0x22, 0x7A, 0x00, 0x7A, 0x0A, 0x0A, 0x72, 0x7D, 0x0D, 0x19, 0x31, 0x7D, 0x26, 0x29, 0x29, 0x2F, 0x28, 0x26, 0x29, 0x29, 0x29, 0x26, 0x30, 0x48, 0x4D, 0x40, 0x20, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x2F, 0x10, 0xC8, 0xAC, 0xBA, 0x2F, 0x10, 0x28, 0x34, 0xFA, 0x00, 0x00, 0x7B, 0x00, 0x00, 0x08, 0x14, 0x2A, 0x14, 0x22, 0x22, 0x14, 0x2A, 0x14, 0x08, 0x55, 0x00, 0x55, 0x00, 0x55, // #176 (25% block) missing in old code 0xAA, 0x55, 0xAA, 0x55, 0xAA, // 50% block 0xFF, 0x55, 0xFF, 0x55, 0xFF, // 75% block 0x00, 0x00, 0x00, 0xFF, 0x00, 0x10, 0x10, 0x10, 0xFF, 0x00, 0x14, 0x14, 0x14, 0xFF, 0x00, 0x10, 0x10, 0xFF, 0x00, 0xFF, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x14, 0x14, 0x14, 0xFC, 0x00, 0x14, 0x14, 0xF7, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x14, 0x14, 0xF4, 0x04, 0xFC, 0x14, 0x14, 0x17, 0x10, 0x1F, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x14, 0x14, 0x14, 0x1F, 0x00, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x10, 0x10, 0x10, 0x10, 0xF0, 0x10, 0x00, 0x00, 0x00, 0xFF, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xFF, 0x10, 0x00, 0x00, 0x00, 0xFF, 0x14, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x1F, 0x10, 0x17, 0x00, 0x00, 0xFC, 0x04, 0xF4, 0x14, 0x14, 0x17, 0x10, 0x17, 0x14, 0x14, 0xF4, 0x04, 0xF4, 0x00, 0x00, 0xFF, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0xF7, 0x00, 0xF7, 0x14, 0x14, 0x14, 0x17, 0x14, 0x10, 0x10, 0x1F, 0x10, 0x1F, 0x14, 0x14, 0x14, 0xF4, 0x14, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x00, 0x00, 0x1F, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x14, 0x00, 0x00, 0x00, 0xFC, 0x14, 0x00, 0x00, 0xF0, 0x10, 0xF0, 0x10, 0x10, 0xFF, 0x10, 0xFF, 0x14, 0x14, 0x14, 0xFF, 0x14, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x38, 0x44, 0x44, 0x38, 0x44, 0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta 0x7E, 0x02, 0x02, 0x06, 0x06, 0x02, 0x7E, 0x02, 0x7E, 0x02, 0x63, 0x55, 0x49, 0x41, 0x63, 0x38, 0x44, 0x44, 0x3C, 0x04, 0x40, 0x7E, 0x20, 0x1E, 0x20, 0x06, 0x02, 0x7E, 0x02, 0x02, 0x99, 0xA5, 0xE7, 0xA5, 0x99, 0x1C, 0x2A, 0x49, 0x2A, 0x1C, 0x4C, 0x72, 0x01, 0x72, 0x4C, 0x30, 0x4A, 0x4D, 0x4D, 0x30, 0x30, 0x48, 0x78, 0x48, 0x30, 0xBC, 0x62, 0x5A, 0x46, 0x3D, 0x3E, 0x49, 0x49, 0x49, 0x00, 0x7E, 0x01, 0x01, 0x01, 0x7E, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x44, 0x44, 0x5F, 0x44, 0x44, 0x40, 0x51, 0x4A, 0x44, 0x40, 0x40, 0x44, 0x4A, 0x51, 0x40, 0x00, 0x00, 0xFF, 0x01, 0x03, 0xE0, 0x80, 0xFF, 0x00, 0x00, 0x08, 0x08, 0x6B, 0x6B, 0x08, 0x36, 0x12, 0x36, 0x24, 0x36, 0x06, 0x0F, 0x09, 0x0F, 0x06, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x30, 0x40, 0xFF, 0x01, 0x01, 0x00, 0x1F, 0x01, 0x01, 0x1E, 0x00, 0x19, 0x1D, 0x17, 0x12, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00 // #255 NBSP }; static const uint8_t font2_data[][6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x20 32 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, // ! 0x21 33 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, // " 0x22 34 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14, // # 0x23 35 0x00, 0x24, 0x2A, 0x7F, 0x2A, 0x12, // $ 0x24 36 0x00, 0x23, 0x13, 0x08, 0x64, 0x62, // % 0x25 37 0x00, 0x36, 0x49, 0x56, 0x20, 0x50, // & 0x26 38 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, // ' 0x27 39 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00, // ( 0x28 40 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00, // ) 0x29 41 0x00, 0x14, 0x08, 0x3e, 0x08, 0x14, // * 0x2a 42 0x00, 0x08, 0x08, 0x3e, 0x08, 0x08, // + 0x2b 43 0x00, 0x00, 0x50, 0x30, 0x00, 0x00, // , 0x2c 44 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, // - 0x2d 45 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, // . 0x2e 46 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, // / 0x2f 47 0x00, 0x3e, 0x51, 0x49, 0x45, 0x3e, // 0 0x30 48 0x00, 0x00, 0x42, 0x7f, 0x40, 0x00, // 1 0x31 49 0x00, 0x42, 0x61, 0x51, 0x49, 0x46, // 2 0x32 50 0x00, 0x21, 0x41, 0x45, 0x4b, 0x31, // 3 0x33 51 0x00, 0x18, 0x14, 0x12, 0x7f, 0x10, // 4 0x34 52 0x00, 0x27, 0x45, 0x45, 0x45, 0x39, // 5 0x35 53 0x00, 0x3c, 0x4a, 0x49, 0x49, 0x30, // 6 0x36 54 0x00, 0x01, 0x71, 0x09, 0x05, 0x03, // 7 0x37 55 0x00, 0x36, 0x49, 0x49, 0x49, 0x36, // 8 0x38 56 0x00, 0x06, 0x49, 0x49, 0x29, 0x1e, // 9 0x39 57 0x00, 0x00, 0x36, 0x36, 0x00, 0x00, // : 0x3a 58 0x00, 0x00, 0x56, 0x36, 0x00, 0x00, // ; 0x3b 59 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, // < 0x3c 60 0x00, 0x14, 0x14, 0x14, 0x14, 0x14, // = 0x3d 61 0x00, 0x00, 0x41, 0x22, 0x14, 0x08, // > 0x3e 62 0x00, 0x02, 0x01, 0x51, 0x09, 0x06, // ? 0x3f 63 0x00, 0x3e, 0x41, 0x5d, 0x49, 0x4e, // @ 0x40 64 0x00, 0x7e, 0x09, 0x09, 0x09, 0x7e, // A 0x41 65 0x00, 0x7f, 0x49, 0x49, 0x49, 0x36, // B 0x42 66 0x00, 0x3e, 0x41, 0x41, 0x41, 0x22, // C 0x43 67 0x00, 0x7f, 0x41, 0x41, 0x41, 0x3e, // D 0x44 68 0x00, 0x7f, 0x49, 0x49, 0x49, 0x41, // E 0x45 69 0x00, 0x7f, 0x09, 0x09, 0x09, 0x01, // F 0x46 70 0x00, 0x3e, 0x41, 0x49, 0x49, 0x7a, // G 0x47 71 0x00, 0x7f, 0x08, 0x08, 0x08, 0x7f, // H 0x48 72 0x00, 0x00, 0x41, 0x7f, 0x41, 0x00, // I 0x49 73 0x00, 0x20, 0x40, 0x41, 0x3f, 0x01, // J 0x4a 74 0x00, 0x7f, 0x08, 0x14, 0x22, 0x41, // K 0x4b 75 0x00, 0x7f, 0x40, 0x40, 0x40, 0x40, // L 0x4c 76 0x00, 0x7f, 0x02, 0x0c, 0x02, 0x7f, // M 0x4d 77 0x00, 0x7f, 0x04, 0x08, 0x10, 0x7f, // N 0x4e 78 0x00, 0x3e, 0x41, 0x41, 0x41, 0x3e, // O 0x4f 79 0x00, 0x7f, 0x09, 0x09, 0x09, 0x06, // P 0x50 80 0x00, 0x3e, 0x41, 0x51, 0x21, 0x5e, // Q 0x51 81 0x00, 0x7f, 0x09, 0x19, 0x29, 0x46, // R 0x52 82 0x00, 0x46, 0x49, 0x49, 0x49, 0x31, // S 0x53 83 0x00, 0x01, 0x01, 0x7f, 0x01, 0x01, // T 0x54 84 0x00, 0x3f, 0x40, 0x40, 0x40, 0x3f, // U 0x55 85 0x00, 0x0f, 0x30, 0x40, 0x30, 0x0f, // V 0x56 86 0x00, 0x3f, 0x40, 0x30, 0x40, 0x3f, // W 0x57 87 0x00, 0x63, 0x14, 0x08, 0x14, 0x63, // X 0x58 88 0x00, 0x07, 0x08, 0x70, 0x08, 0x07, // Y 0x59 89 0x00, 0x61, 0x51, 0x49, 0x45, 0x43, // Z 0x5a 90 0x00, 0x3c, 0x4a, 0x49, 0x29, 0x1e, // [ 0x5b 91 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, // \ 0x5c 92 0x00, 0x00, 0x41, 0x7f, 0x00, 0x00, // ] 0x5d 93 0x00, 0x04, 0x02, 0x01, 0x02, 0x04, // ^ 0x5e 94 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, // _ 0x5f 95 0x00, 0x00, 0x00, 0x03, 0x04, 0x00, // ` 0x60 96 0x00, 0x20, 0x54, 0x54, 0x54, 0x78, // a 0x61 97 0x00, 0x7f, 0x48, 0x44, 0x44, 0x38, // b 0x62 98 0x00, 0x38, 0x44, 0x44, 0x44, 0x20, // c 0x63 99 0x00, 0x38, 0x44, 0x44, 0x48, 0x7f, // d 0x64 100 0x00, 0x38, 0x54, 0x54, 0x54, 0x18, // e 0x65 101 0x00, 0x08, 0x7e, 0x09, 0x01, 0x02, // f 0x66 102 0x00, 0x0c, 0x52, 0x52, 0x52, 0x3e, // g 0x67 103 0x00, 0x7f, 0x08, 0x04, 0x04, 0x78, // h 0x68 104 0x00, 0x00, 0x44, 0x7d, 0x40, 0x00, // i 0x69 105 0x00, 0x20, 0x40, 0x44, 0x3d, 0x00, // j 0x6a 106 0x00, 0x00, 0x7f, 0x10, 0x28, 0x44, // k 0x6b 107 0x00, 0x00, 0x41, 0x7f, 0x40, 0x00, // l 0x6c 108 0x00, 0x7c, 0x04, 0x18, 0x04, 0x78, // m 0x6d 109 0x00, 0x7c, 0x08, 0x04, 0x04, 0x78, // n 0x6e 110 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, // o 0x6f 111 0x00, 0x7c, 0x14, 0x14, 0x14, 0x08, // p 0x70 112 0x00, 0x08, 0x14, 0x14, 0x18, 0x7c, // q 0x71 113 0x00, 0x7c, 0x08, 0x04, 0x04, 0x08, // r 0x72 114 0x00, 0x48, 0x54, 0x54, 0x54, 0x20, // s 0x73 115 0x00, 0x04, 0x3f, 0x44, 0x40, 0x20, // t 0x74 116 0x00, 0x3c, 0x40, 0x40, 0x20, 0x7c, // u 0x75 117 0x00, 0x1c, 0x20, 0x40, 0x20, 0x1c, // v 0x76 118 0x00, 0x3c, 0x40, 0x30, 0x40, 0x3c, // w 0x77 119 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, // x 0x78 120 0x00, 0x0c, 0x50, 0x50, 0x50, 0x3c, // y 0x79 121 0x00, 0x44, 0x64, 0x54, 0x4c, 0x44, // z 0x7a 122 0x00, 0x00, 0x08, 0x36, 0x41, 0x41, // { 0x7b 123 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, // | 0x7c 124 0x00, 0x41, 0x41, 0x36, 0x08, 0x00, // } 0x7d 125 0x00, 0x04, 0x02, 0x04, 0x08, 0x04 // ~ 0x7e 126 }; static const uint8_t font3_data[][5] = { 0x2a, 0x40, 0x02, 0x54, 0x00, // 0 $00 'char0' 0x00, 0x00, 0x00, 0x00, 0x00, // 32 $20 'space' 0x00, 0x00, 0x5e, 0x00, 0x00, // 33 $21 'exclam' 0x00, 0x0e, 0x00, 0x0e, 0x00, // 34 $22 'quotedbl' 0x14, 0x7f, 0x14, 0x7f, 0x14, // 35 $23 'numbersign' 0x04, 0x2a, 0x7f, 0x2a, 0x10, // 36 $24 'dollar' 0x00, 0x16, 0x08, 0x34, 0x00, // 37 $25 'percent' 0x36, 0x49, 0x36, 0x40, 0x00, // 38 $26 'ampersand' 0x00, 0x00, 0x0e, 0x00, 0x00, // 39 $27 'quotesingle' 0x00, 0x3c, 0x42, 0x00, 0x00, // 40 $28 'parenleft' 0x00, 0x42, 0x3c, 0x00, 0x00, // 41 $29 'parenright' 0x54, 0x38, 0x38, 0x54, 0x00, // 42 $2a 'asterisk' 0x10, 0x10, 0x7c, 0x10, 0x10, // 43 $2b 'plus' 0x00, 0x80, 0x60, 0x20, 0x00, // 44 $2c 'comma' 0x10, 0x10, 0x10, 0x10, 0x00, // 45 $2d 'hyphen' 0x00, 0x40, 0xe0, 0x40, 0x00, // 46 $2e 'period' 0x60, 0x10, 0x08, 0x06, 0x00, // 47 $2f 'slash' 0x00, 0x3c, 0x42, 0x3c, 0x00, // 48 $30 'zero' 0x00, 0x44, 0x7e, 0x40, 0x00, // 49 $31 'one' 0x64, 0x52, 0x52, 0x4c, 0x00, // 50 $32 'two' 0x22, 0x4a, 0x4e, 0x32, 0x00, // 51 $33 'three' 0x18, 0x14, 0x7e, 0x10, 0x00, // 52 $34 'four' 0x2e, 0x4a, 0x4a, 0x32, 0x00, // 53 $35 'five' 0x3c, 0x4a, 0x4a, 0x30, 0x00, // 54 $36 'six' 0x02, 0x62, 0x1a, 0x06, 0x00, // 55 $37 'seven' 0x34, 0x4a, 0x4a, 0x34, 0x00, // 56 $38 'eight' 0x0c, 0x52, 0x52, 0x3c, 0x00, // 57 $39 'nine' 0x00, 0x6c, 0x6c, 0x00, 0x00, // 58 $3a 'colon' 0x00, 0x80, 0x6c, 0x2c, 0x00, // 59 $3b 'semicolon' 0x00, 0x18, 0x24, 0x42, 0x00, // 60 $3c 'less' 0x28, 0x28, 0x28, 0x28, 0x00, // 61 $3d 'equal' 0x00, 0x42, 0x24, 0x18, 0x00, // 62 $3e 'greater' 0x00, 0x04, 0x52, 0x0c, 0x00, // 63 $3f 'question' 0x3c, 0x42, 0x99, 0xa5, 0x1e, // 64 $40 'at' 0x7c, 0x12, 0x12, 0x7c, 0x00, // 65 $41 'A' 0x7e, 0x4a, 0x4a, 0x34, 0x00, // 66 $42 'B' 0x3c, 0x42, 0x42, 0x24, 0x00, // 67 $43 'C' 0x7e, 0x42, 0x42, 0x3c, 0x00, // 68 $44 'D' 0x7e, 0x4a, 0x4a, 0x42, 0x00, // 69 $45 'E' 0x7e, 0x0a, 0x0a, 0x02, 0x00, // 70 $46 'F' 0x3c, 0x42, 0x52, 0x34, 0x00, // 71 $47 'G' 0x7e, 0x08, 0x08, 0x7e, 0x00, // 72 $48 'H' 0x00, 0x42, 0x7e, 0x42, 0x00, // 73 $49 'I' 0x20, 0x42, 0x3e, 0x02, 0x00, // 74 $4a 'J' 0x7e, 0x08, 0x34, 0x42, 0x00, // 75 $4b 'K' 0x7e, 0x40, 0x40, 0x40, 0x00, // 76 $4c 'L' 0x7e, 0x0c, 0x0c, 0x7e, 0x00, // 77 $4d 'M' 0x7e, 0x0c, 0x38, 0x7e, 0x00, // 78 $4e 'N' 0x3c, 0x42, 0x42, 0x3c, 0x00, // 79 $4f 'O' 0x7e, 0x12, 0x12, 0x0c, 0x00, // 80 $50 'P' 0x3c, 0x52, 0x62, 0xbc, 0x00, // 81 $51 'Q' 0x7e, 0x12, 0x12, 0x6c, 0x00, // 82 $52 'R' 0x24, 0x4a, 0x52, 0x24, 0x00, // 83 $53 'S' 0x00, 0x02, 0x7e, 0x02, 0x00, // 84 $54 'T' 0x3e, 0x40, 0x40, 0x3e, 0x00, // 85 $55 'U' 0x1e, 0x60, 0x60, 0x1e, 0x00, // 86 $56 'V' 0x7e, 0x30, 0x30, 0x7e, 0x00, // 87 $57 'W' 0x66, 0x18, 0x18, 0x66, 0x00, // 88 $58 'X' 0x06, 0x08, 0x70, 0x08, 0x06, // 89 $59 'Y' 0x62, 0x52, 0x4a, 0x46, 0x00, // 90 $5a 'Z' 0x00, 0x7e, 0x42, 0x42, 0x00, // 91 $5b 'bracketleft' 0x06, 0x08, 0x10, 0x60, 0x00, // 92 $5c 'backslash' 0x00, 0x42, 0x42, 0x7e, 0x00, // 93 $5d 'bracketright' 0x00, 0x04, 0x02, 0x04, 0x00, // 94 $5e 'asciicircum' 0x80, 0x80, 0x80, 0x80, 0x00, // 95 $5f 'underscore' 0x00, 0x02, 0x04, 0x00, 0x00, // 96 $60 'grave' 0x30, 0x48, 0x48, 0x78, 0x00, // 97 $61 'a' 0x7e, 0x48, 0x48, 0x30, 0x00, // 98 $62 'b' 0x00, 0x30, 0x48, 0x48, 0x00, // 99 $63 'c' 0x30, 0x48, 0x48, 0x7e, 0x00, // 100 $64 'd' 0x30, 0x68, 0x58, 0x10, 0x00, // 101 $65 'e' 0x10, 0x7c, 0x12, 0x04, 0x00, // 102 $66 'f' 0x10, 0xa8, 0xa8, 0x70, 0x00, // 103 $67 'g' 0x7e, 0x08, 0x08, 0x70, 0x00, // 104 $68 'h' 0x00, 0x48, 0x7a, 0x40, 0x00, // 105 $69 'i' 0x00, 0x40, 0x80, 0x7a, 0x00, // 106 $6a 'j' 0x7e, 0x10, 0x10, 0x68, 0x00, // 107 $6b 'k' 0x00, 0x42, 0x7e, 0x40, 0x00, // 108 $6c 'l' 0x78, 0x08, 0x70, 0x08, 0x70, // 109 $6d 'm' 0x78, 0x08, 0x08, 0x70, 0x00, // 110 $6e 'n' 0x30, 0x48, 0x48, 0x30, 0x00, // 111 $6f 'o' 0xf8, 0x28, 0x28, 0x10, 0x00, // 112 $70 'p' 0x10, 0x28, 0x28, 0xf8, 0x00, // 113 $71 'q' 0x78, 0x10, 0x08, 0x10, 0x00, // 114 $72 'r' 0x00, 0x50, 0x58, 0x28, 0x00, // 115 $73 's' 0x08, 0x3e, 0x48, 0x20, 0x00, // 116 $74 't' 0x38, 0x40, 0x40, 0x78, 0x00, // 117 $75 'u' 0x00, 0x38, 0x40, 0x38, 0x00, // 118 $76 'v' 0x38, 0x40, 0x30, 0x40, 0x38, // 119 $77 'w' 0x48, 0x30, 0x30, 0x48, 0x00, // 120 $78 'x' 0x58, 0xa0, 0xa0, 0x78, 0x00, // 121 $79 'y' 0x48, 0x68, 0x58, 0x48, 0x00, // 122 $7a 'z' 0x08, 0x2a, 0x55, 0x41, 0x00, // 123 $7b 'braceleft' 0x00, 0x00, 0x7e, 0x00, 0x00, // 124 $7c 'bar' 0x41, 0x55, 0x2a, 0x08, 0x00, // 125 $7d 'braceright' 0x04, 0x02, 0x04, 0x02, 0x00, // 126 $7e 'asciitilde' 0x00, 0x00, 0x00, 0x00, 0x00, // 160 $a0 'space' 0x00, 0x00, 0x7a, 0x00, 0x00, // 161 $a1 'exclamdown' 0x30, 0x48, 0xfc, 0x48, 0x00, // 162 $a2 'cent' 0x48, 0x3c, 0x4a, 0x24, 0x00, // 163 $a3 'sterling' 0x44, 0x38, 0x28, 0x38, 0x44, // 164 $a4 'currency' 0x2a, 0x2c, 0x78, 0x2c, 0x2a, // 165 $a5 'yen' 0x00, 0x00, 0x77, 0x00, 0x00, // 166 $a6 'brokenbar' 0x4e, 0x55, 0x55, 0x39, 0x00, // 167 $a7 'section' 0x00, 0x02, 0x00, 0x02, 0x00, // 168 $a8 'dieresis' 0x3c, 0x5a, 0x66, 0x42, 0x3c, // 169 $a9 'copyright' 0x00, 0x12, 0x15, 0x17, 0x00, // 170 $aa 'ordfeminine' 0x10, 0x28, 0x10, 0x28, 0x00, // 171 $ab 'guillemotleft' 0x00, 0x10, 0x10, 0x70, 0x00, // 172 $ac 'logicalnot' 0x00, 0x10, 0x10, 0x10, 0x00, // 173 $ad 'hyphen' 0x3c, 0x7e, 0x56, 0x6a, 0x3c, // 174 $ae 'registered' 0x00, 0x02, 0x02, 0x02, 0x00, // 175 $af 'macron' 0x00, 0x04, 0x0a, 0x04, 0x00, // 176 $b0 'degree' 0x00, 0x48, 0x5c, 0x48, 0x00, // 177 $b1 'plusminus' 0x00, 0x12, 0x19, 0x16, 0x00, // 178 $b2 'twosuperior' 0x00, 0x15, 0x15, 0x0a, 0x00, // 179 $b3 'threesuperior' 0x00, 0x04, 0x02, 0x00, 0x00, // 180 $b4 'acute' 0xf8, 0x40, 0x40, 0x38, 0x00, // 181 $b5 'mu' 0x0c, 0x1e, 0x7e, 0x02, 0x7e, // 182 $b6 'paragraph' 0x00, 0x00, 0x10, 0x00, 0x00, // 183 $b7 'periodcentered' 0x00, 0x80, 0x40, 0x00, 0x00, // 184 $b8 'cedilla' 0x00, 0x12, 0x1f, 0x10, 0x00, // 185 $b9 'onesuperior' 0x00, 0x12, 0x15, 0x12, 0x00, // 186 $ba 'ordmasculine' 0x28, 0x10, 0x28, 0x10, 0x00, // 187 $bb 'guillemotright' 0x2f, 0x30, 0x78, 0x20, 0x00, // 188 $bc 'onequarter' 0x0f, 0x48, 0x64, 0x58, 0x00, // 189 $bd 'onehalf' 0x35, 0x2a, 0x78, 0x20, 0x00, // 190 $be 'threequarters' 0x00, 0x30, 0x4a, 0x20, 0x00, // 191 $bf 'questiondown' 0x78, 0x15, 0x16, 0x78, 0x00, // 192 $c0 'Agrave' 0x78, 0x16, 0x15, 0x78, 0x00, // 193 $c1 'Aacute' 0x7a, 0x15, 0x15, 0x7a, 0x00, // 194 $c2 'Acircumflex' 0x7a, 0x15, 0x16, 0x79, 0x00, // 195 $c3 'Atilde' 0x79, 0x14, 0x14, 0x79, 0x00, // 196 $c4 'Adieresis' 0x7a, 0x15, 0x15, 0x7a, 0x00, // 197 $c5 'Aring' 0x7c, 0x12, 0x7e, 0x52, 0x00, // 198 $c6 'AE' 0x3c, 0xc2, 0x42, 0x24, 0x00, // 199 $c7 'Ccedilla' 0x7c, 0x55, 0x56, 0x44, 0x00, // 200 $c8 'Egrave' 0x7c, 0x56, 0x55, 0x44, 0x00, // 201 $c9 'Eacute' 0x7e, 0x55, 0x55, 0x46, 0x00, // 202 $ca 'Ecircumflex' 0x7d, 0x54, 0x54, 0x45, 0x00, // 203 $cb 'Edieresis' 0x00, 0x45, 0x7e, 0x44, 0x00, // 204 $cc 'Igrave' 0x00, 0x44, 0x7e, 0x45, 0x00, // 205 $cd 'Iacute' 0x00, 0x46, 0x7d, 0x46, 0x00, // 206 $ce 'Icircumflex' 0x00, 0x45, 0x7c, 0x45, 0x00, // 207 $cf 'Idieresis' 0x08, 0x7e, 0x4a, 0x42, 0x3c, // 208 $d0 'Eth' 0x7e, 0x09, 0x12, 0x7d, 0x00, // 209 $d1 'Ntilde' 0x38, 0x45, 0x46, 0x38, 0x00, // 210 $d2 'Ograve' 0x38, 0x46, 0x45, 0x38, 0x00, // 211 $d3 'Oacute' 0x3a, 0x45, 0x45, 0x3a, 0x00, // 212 $d4 'Ocircumflex' 0x3a, 0x45, 0x46, 0x39, 0x00, // 213 $d5 'Otilde' 0x39, 0x44, 0x44, 0x39, 0x00, // 214 $d6 'Odieresis' 0x00, 0x50, 0x20, 0x50, 0x00, // 215 $d7 'multiply' 0x7c, 0x72, 0x4e, 0x3e, 0x00, // 216 $d8 'Oslash' 0x3c, 0x41, 0x42, 0x3c, 0x00, // 217 $d9 'Ugrave' 0x3c, 0x42, 0x41, 0x3c, 0x00, // 218 $da 'Uacute' 0x3e, 0x41, 0x41, 0x3e, 0x00, // 219 $db 'Ucircumflex' 0x3d, 0x40, 0x40, 0x3d, 0x00, // 220 $dc 'Udieresis' 0x04, 0x08, 0x72, 0x09, 0x04, // 221 $dd 'Yacute' 0x7e, 0x24, 0x24, 0x18, 0x00, // 222 $de 'Thorn' 0x7c, 0x02, 0x5a, 0x24, 0x00, // 223 $df 'germandbls' 0x30, 0x49, 0x4a, 0x78, 0x00, // 224 $e0 'agrave' 0x30, 0x4a, 0x49, 0x78, 0x00, // 225 $e1 'aacute' 0x30, 0x4a, 0x49, 0x7a, 0x00, // 226 $e2 'acircumflex' 0x32, 0x49, 0x4a, 0x79, 0x00, // 227 $e3 'atilde' 0x30, 0x4a, 0x48, 0x7a, 0x00, // 228 $e4 'adieresis' 0x32, 0x4d, 0x4d, 0x7a, 0x00, // 229 $e5 'aring' 0x28, 0x58, 0x78, 0x68, 0x50, // 230 $e6 'ae' 0x00, 0x30, 0xc8, 0x48, 0x00, // 231 $e7 'ccedilla' 0x30, 0x69, 0x5a, 0x10, 0x00, // 232 $e8 'egrave' 0x30, 0x6a, 0x59, 0x10, 0x00, // 233 $e9 'eacute' 0x32, 0x69, 0x59, 0x12, 0x00, // 234 $ea 'ecircumflex' 0x30, 0x6a, 0x58, 0x12, 0x00, // 235 $eb 'edieresis' 0x00, 0x49, 0x7a, 0x40, 0x00, // 236 $ec 'igrave' 0x00, 0x48, 0x7a, 0x41, 0x00, // 237 $ed 'iacute' 0x00, 0x4a, 0x79, 0x42, 0x00, // 238 $ee 'icircumflex' 0x00, 0x4a, 0x78, 0x42, 0x00, // 239 $ef 'idieresis' 0x25, 0x52, 0x55, 0x38, 0x00, // 240 $f0 'eth' 0x7a, 0x09, 0x0a, 0x71, 0x00, // 241 $f1 'ntilde' 0x30, 0x49, 0x4a, 0x30, 0x00, // 242 $f2 'ograve' 0x30, 0x4a, 0x49, 0x30, 0x00, // 243 $f3 'oacute' 0x32, 0x49, 0x49, 0x32, 0x00, // 244 $f4 'ocircumflex' 0x32, 0x49, 0x4a, 0x31, 0x00, // 245 $f5 'otilde' 0x32, 0x48, 0x48, 0x32, 0x00, // 246 $f6 'odieresis' 0x00, 0x10, 0x54, 0x10, 0x00, // 247 $f7 'divide' 0x70, 0x68, 0x58, 0x38, 0x00, // 248 $f8 'oslash' 0x38, 0x41, 0x42, 0x78, 0x00, // 249 $f9 'ugrave' 0x38, 0x42, 0x41, 0x78, 0x00, // 250 $fa 'uacute' 0x3a, 0x41, 0x41, 0x7a, 0x00, // 251 $fb 'ucircumflex' 0x3a, 0x40, 0x40, 0x7a, 0x00, // 252 $fc 'udieresis' 0x58, 0xa2, 0xa1, 0x78, 0x00, // 253 $fd 'yacute' 0xfe, 0x28, 0x28, 0x10, 0x00, // 254 $fe 'thorn' 0x5a, 0xa0, 0xa0, 0x7a, 0x00, // 255 $ff 'ydieresis' 0x79, 0x15, 0x15, 0x79, 0x00, // 256 $100 'Amacron' 0x32, 0x4a, 0x4a, 0x7a, 0x00, // 257 $101 'amacron' 0x79, 0x16, 0x16, 0x79, 0x00, // 258 $102 'Abreve' 0x31, 0x4a, 0x4a, 0x79, 0x00, // 259 $103 'abreve' 0x7c, 0x12, 0x92, 0xfc, 0x00, // 260 $104 'Aogonek' 0x30, 0x48, 0xc8, 0x78, 0x00, // 261 $105 'aogonek' 0x38, 0x46, 0x45, 0x28, 0x00, // 262 $106 'Cacute' 0x00, 0x30, 0x4a, 0x49, 0x00, // 263 $107 'cacute' 0x3a, 0x45, 0x45, 0x2a, 0x00, // 264 $108 'Ccircumflex' 0x32, 0x49, 0x49, 0x02, 0x00, // 265 $109 'ccircumflex' 0x38, 0x45, 0x44, 0x28, 0x00, // 266 $10a 'Cdotaccent' 0x00, 0x30, 0x4a, 0x48, 0x00, // 267 $10b 'cdotaccent' 0x39, 0x46, 0x46, 0x29, 0x00, // 268 $10c 'Ccaron' 0x31, 0x4a, 0x4a, 0x01, 0x00, // 269 $10d 'ccaron' 0x7d, 0x46, 0x46, 0x39, 0x00, // 270 $10e 'Dcaron' 0x31, 0x4a, 0x49, 0x7e, 0x00, // 271 $10f 'dcaron' 0x08, 0x7e, 0x4a, 0x42, 0x3c, // 272 $110 'Dcroat' 0x20, 0x54, 0x7e, 0x04, 0x00, // 273 $111 'dcroat' 0x7d, 0x55, 0x55, 0x45, 0x00, // 274 $112 'Emacron' 0x32, 0x6a, 0x5a, 0x12, 0x00, // 275 $113 'emacron' 0x7d, 0x56, 0x56, 0x45, 0x00, // 276 $114 'Ebreve' 0x31, 0x6a, 0x5a, 0x11, 0x00, // 277 $115 'ebreve' 0x7c, 0x55, 0x55, 0x44, 0x00, // 278 $116 'Edotaccent' 0x30, 0x6a, 0x5a, 0x10, 0x00, // 279 $117 'edotaccent' 0x7e, 0x4a, 0xca, 0x42, 0x00, // 280 $118 'Eogonek' 0x30, 0x68, 0xd8, 0x10, 0x00, // 281 $119 'eogonek' 0x7d, 0x56, 0x56, 0x45, 0x00, // 282 $11a 'Ecaron' 0x31, 0x6a, 0x5a, 0x11, 0x00, // 283 $11b 'ecaron' 0x3a, 0x45, 0x55, 0x36, 0x00, // 284 $11c 'Gcircumflex' 0x12, 0xa9, 0xa9, 0x72, 0x00, // 285 $11d 'gcircumflex' 0x39, 0x46, 0x56, 0x35, 0x00, // 286 $11e 'Gbreve' 0x11, 0xaa, 0xaa, 0x71, 0x00, // 287 $11f 'gbreve' 0x38, 0x45, 0x55, 0x34, 0x00, // 288 $120 'Gdotaccent' 0x10, 0xaa, 0xaa, 0x70, 0x00, // 289 $121 'gdotaccent' 0x3c, 0x42, 0xd2, 0x34, 0x00, // 290 $122 'Gcommaaccent' 0x10, 0xab, 0xa9, 0x70, 0x00, // 291 $123 'gcommaaccent' 0x7a, 0x11, 0x11, 0x7a, 0x00, // 292 $124 'Hcircumflex' 0x7e, 0x09, 0x09, 0x72, 0x00, // 293 $125 'hcircumflex' 0x04, 0x7e, 0x14, 0x7e, 0x04, // 294 $126 'Hbar' 0x04, 0x7e, 0x14, 0x14, 0x60, // 295 $127 'hbar' 0x46, 0x7d, 0x46, 0x01, 0x00, // 296 $128 'Itilde' 0x4a, 0x79, 0x42, 0x01, 0x00, // 297 $129 'itilde' 0x00, 0x45, 0x7d, 0x45, 0x00, // 298 $12a 'Imacron' 0x00, 0x4a, 0x7a, 0x42, 0x00, // 299 $12b 'imacron' 0x01, 0x46, 0x7e, 0x45, 0x00, // 300 $12c 'Ibreve' 0x01, 0x4a, 0x7a, 0x41, 0x00, // 301 $12d 'ibreve' 0x00, 0x42, 0x7e, 0xc2, 0x00, // 302 $12e 'Iogonek' 0x00, 0x48, 0x7a, 0xc0, 0x00, // 303 $12f 'iogonek' 0x00, 0x44, 0x7d, 0x44, 0x00, // 304 $130 'Idotaccent' 0x00, 0x48, 0x78, 0x40, 0x00, // 305 $131 'dotlessi' 0x7e, 0x20, 0x42, 0x3e, 0x00, // 306 $132 'IJ' 0x00, 0x7a, 0x80, 0x7a, 0x00, // 307 $133 'ij' 0x20, 0x46, 0x3d, 0x06, 0x00, // 308 $134 'Jcircumflex' 0x40, 0x82, 0x79, 0x02, 0x00, // 309 $135 'jcircumflex' 0x80, 0x7e, 0x08, 0x34, 0x42, // 310 $136 'Kcommaaccent' 0x80, 0x7e, 0x10, 0x10, 0x68, // 311 $137 'kcommaaccent' 0x00, 0x78, 0x10, 0x68, 0x00, // 312 $138 'kgreenlandic' 0x7c, 0x40, 0x42, 0x41, 0x00, // 313 $139 'Lacute' 0x00, 0x44, 0x7e, 0x41, 0x00, // 314 $13a 'lacute' 0x7e, 0x40, 0xc0, 0x40, 0x00, // 315 $13b 'Lcommaaccent' 0x00, 0x42, 0xfe, 0x40, 0x00, // 316 $13c 'lcommaaccent' 0x7c, 0x41, 0x42, 0x41, 0x00, // 317 $13d 'Lcaron' 0x00, 0x45, 0x7e, 0x41, 0x00, // 318 $13e 'lcaron' 0x7e, 0x40, 0x48, 0x40, 0x00, // 319 $13f 'Ldot' 0x42, 0x7e, 0x40, 0x08, 0x00, // 320 $140 'ldot' 0x08, 0x7e, 0x44, 0x40, 0x40, // 321 $141 'Lslash' 0x00, 0x52, 0x7e, 0x48, 0x00, // 322 $142 'lslash' 0x7c, 0x0a, 0x11, 0x7c, 0x00, // 323 $143 'Nacute' 0x78, 0x0a, 0x09, 0x70, 0x00, // 324 $144 'nacute' 0x7e, 0x8c, 0x38, 0x7e, 0x00, // 325 $145 'Ncommaaccent' 0x78, 0x88, 0x08, 0x70, 0x00, // 326 $146 'ncommaaccent' 0x7d, 0x0a, 0x12, 0x7d, 0x00, // 327 $147 'Ncaron' 0x79, 0x0a, 0x0a, 0x71, 0x00, // 328 $148 'ncaron' 0x05, 0x03, 0x78, 0x08, 0x70, // 329 $149 'napostrophe' 0x7e, 0x0c, 0xb8, 0x7e, 0x00, // 330 $14a 'Eng' 0x78, 0x08, 0x88, 0x70, 0x00, // 331 $14b 'eng' 0x39, 0x45, 0x45, 0x39, 0x00, // 332 $14c 'Omacron' 0x32, 0x4a, 0x4a, 0x32, 0x00, // 333 $14d 'omacron' 0x39, 0x46, 0x46, 0x39, 0x00, // 334 $14e 'Obreve' 0x31, 0x4a, 0x4a, 0x31, 0x00, // 335 $14f 'obreve' 0x02, 0x39, 0x44, 0x46, 0x39, // 336 $150 'Ohungarumlaut' 0x02, 0x31, 0x48, 0x4a, 0x31, // 337 $151 'ohungarumlaut' 0x3c, 0x42, 0x7e, 0x4a, 0x00, // 338 $152 'OE' 0x30, 0x48, 0x78, 0x68, 0x50, // 339 $153 'oe' 0x7c, 0x16, 0x15, 0x68, 0x00, // 340 $154 'Racute' 0x78, 0x12, 0x09, 0x10, 0x00, // 341 $155 'racute' 0x7e, 0x12, 0x92, 0x6c, 0x00, // 342 $156 'Rcommaaccent' 0x80, 0x78, 0x10, 0x08, 0x10, // 343 $157 'rcommaaccent' 0x7d, 0x16, 0x16, 0x69, 0x00, // 344 $158 'Rcaron' 0x79, 0x12, 0x0a, 0x11, 0x00, // 345 $159 'rcaron' 0x48, 0x56, 0x55, 0x24, 0x00, // 346 $15a 'Sacute' 0x00, 0x50, 0x5a, 0x29, 0x00, // 347 $15b 'sacute' 0x4a, 0x55, 0x55, 0x26, 0x00, // 348 $15c 'Scircumflex' 0x00, 0x52, 0x59, 0x2a, 0x00, // 349 $15d 'scircumflex' 0x24, 0x4a, 0xd2, 0x24, 0x00, // 350 $15e 'Scedilla' 0x00, 0x50, 0xd8, 0x28, 0x00, // 351 $15f 'scedilla' 0x49, 0x56, 0x56, 0x25, 0x00, // 352 $160 'Scaron' 0x00, 0x51, 0x5a, 0x29, 0x00, // 353 $161 'scaron' 0x00, 0x82, 0x7e, 0x02, 0x00, // 354 $162 'Tcommaaccent' 0x08, 0xbe, 0x48, 0x20, 0x00, // 355 $163 'tcommaaccent' 0x00, 0x05, 0x7e, 0x05, 0x00, // 356 $164 'Tcaron' 0x09, 0x3e, 0x49, 0x20, 0x00, // 357 $165 'tcaron' 0x00, 0x0a, 0x7e, 0x0a, 0x00, // 358 $166 'Tbar' 0x0a, 0x3f, 0x4a, 0x20, 0x00, // 359 $167 'tbar' 0x3a, 0x41, 0x42, 0x39, 0x00, // 360 $168 'Utilde' 0x3a, 0x41, 0x42, 0x79, 0x00, // 361 $169 'utilde' 0x3d, 0x41, 0x41, 0x3d, 0x00, // 362 $16a 'Umacron' 0x3a, 0x42, 0x42, 0x7a, 0x00, // 363 $16b 'umacron' 0x39, 0x42, 0x42, 0x39, 0x00, // 364 $16c 'Ubreve' 0x39, 0x42, 0x42, 0x79, 0x00, // 365 $16d 'ubreve' 0x38, 0x42, 0x45, 0x3a, 0x00, // 366 $16e 'Uring' 0x38, 0x42, 0x45, 0x7a, 0x00, // 367 $16f 'uring' 0x02, 0x39, 0x40, 0x42, 0x39, // 368 $170 'Uhungarumlaut' 0x02, 0x39, 0x40, 0x42, 0x79, // 369 $171 'uhungarumlaut' 0x3e, 0x40, 0xc0, 0x3e, 0x00, // 370 $172 'Uogonek' 0x38, 0x40, 0xc0, 0x78, 0x00, // 371 $173 'uogonek' 0x7c, 0x31, 0x31, 0x7c, 0x00, // 372 $174 'Wcircumflex' 0x38, 0x42, 0x31, 0x42, 0x38, // 373 $175 'wcircumflex' 0x00, 0x1a, 0x61, 0x1a, 0x00, // 374 $176 'Ycircumflex' 0x5a, 0xa1, 0xa1, 0x7a, 0x00, // 375 $177 'ycircumflex' 0x04, 0x09, 0x70, 0x09, 0x04, // 376 $178 'Ydieresis' 0x64, 0x56, 0x4d, 0x44, 0x00, // 377 $179 'Zacute' 0x48, 0x6a, 0x59, 0x48, 0x00, // 378 $17a 'zacute' 0x64, 0x55, 0x4d, 0x44, 0x00, // 379 $17b 'Zdotaccent' 0x48, 0x6a, 0x5a, 0x48, 0x00, // 380 $17c 'zdotaccent' 0x65, 0x56, 0x4e, 0x45, 0x00, // 381 $17d 'Zcaron' 0x49, 0x6a, 0x5a, 0x49, 0x00, // 382 $17e 'zcaron' 0x10, 0x7c, 0x02, 0x04, 0x00, // 383 $17f 'longs' 0x34, 0x52, 0x52, 0x3c, 0x00, // 399 $18f 'uni018F' 0x40, 0x90, 0x7c, 0x12, 0x04, // 402 $192 'florin' 0x3c, 0x42, 0x42, 0x3c, 0x02, // 416 $1a0 'Ohorn' 0x30, 0x48, 0x48, 0x30, 0x08, // 417 $1a1 'ohorn' 0x3e, 0x40, 0x3e, 0x04, 0x02, // 431 $1af 'Uhorn' 0x38, 0x40, 0x78, 0x10, 0x08, // 432 $1b0 'uhorn' 0x6a, 0x5a, 0x4a, 0x4e, 0x00, // 437 $1b5 'uni01B5' 0x58, 0x78, 0x58, 0x58, 0x00, // 438 $1b6 'uni01B6' 0x39, 0x46, 0x46, 0x39, 0x00, // 465 $1d1 'uni01D1' 0x31, 0x4a, 0x4a, 0x31, 0x00, // 466 $1d2 'uni01D2' 0x39, 0x46, 0x56, 0x75, 0x00, // 486 $1e6 'Gcaron' 0x11, 0xaa, 0xaa, 0x71, 0x00, // 487 $1e7 'gcaron' 0x74, 0x2a, 0x2a, 0x75, 0x00, // 506 $1fa 'Aringacute' 0x24, 0x5a, 0x5a, 0x75, 0x00, // 507 $1fb 'aringacute' 0x78, 0x14, 0x7e, 0x55, 0x00, // 508 $1fc 'AEacute' 0x28, 0x58, 0x7a, 0x69, 0x50, // 509 $1fd 'aeacute' 0x78, 0x74, 0x4e, 0x3d, 0x00, // 510 $1fe 'Oslashacute' 0x70, 0x68, 0x5a, 0x39, 0x00, // 511 $1ff 'oslashacute' 0x24, 0x4a, 0xd2, 0x24, 0x00, // 536 $218 'Scommaaccent' 0x00, 0x50, 0xd8, 0x28, 0x00, // 537 $219 'scommaaccent' 0x00, 0x82, 0x7e, 0x02, 0x00, // 538 $21a 'Tcommaaccent' 0x08, 0xbe, 0x48, 0x20, 0x00, // 539 $21b 'tcommaaccent' 0x20, 0x68, 0x58, 0x30, 0x00, // 601 $259 'uni0259' 0x00, 0x0c, 0x0a, 0x00, 0x00, // 699 $2bb 'uni02BB' 0x00, 0x0a, 0x06, 0x00, 0x00, // 700 $2bc 'afii57929' 0x00, 0x06, 0x0a, 0x00, 0x00, // 701 $2bd 'afii64937' 0x00, 0x0a, 0x04, 0x00, 0x00, // 702 $2be 'uni02BE' 0x00, 0x04, 0x0a, 0x00, 0x00, // 703 $2bf 'uni02BF' 0x00, 0x02, 0x01, 0x02, 0x00, // 710 $2c6 'circumflex' 0x00, 0x01, 0x02, 0x01, 0x00, // 711 $2c7 'caron' 0x00, 0x02, 0x02, 0x02, 0x00, // 713 $2c9 'macron' 0x01, 0x02, 0x02, 0x02, 0x01, // 728 $2d8 'breve' 0x00, 0x00, 0x01, 0x00, 0x00, // 729 $2d9 'dotaccent' 0x00, 0x02, 0x05, 0x02, 0x00, // 730 $2da 'ring' 0x00, 0xc0, 0x80, 0x00, 0x00, // 731 $2db 'ogonek' 0x04, 0x02, 0x04, 0x02, 0x00, // 732 $2dc 'tilde' 0x02, 0x01, 0x00, 0x02, 0x01, // 733 $2dd 'hungarumlaut' 0x00, 0x01, 0x02, 0x00, 0x00, // 768 $300 'gravecomb' 0x00, 0x02, 0x01, 0x00, 0x00, // 769 $301 'acutecomb' 0x00, 0x02, 0x01, 0x02, 0x00, // 770 $302 'uni0302' 0x02, 0x01, 0x02, 0x01, 0x00, // 771 $303 'tildecomb' 0x01, 0x01, 0x01, 0x01, 0x00, // 772 $304 'uni0304' 0x01, 0x01, 0x01, 0x01, 0x01, // 773 $305 'uni0305' 0x01, 0x02, 0x02, 0x01, 0x00, // 774 $306 'uni0306' 0x00, 0x00, 0x01, 0x00, 0x00, // 775 $307 'uni0307' 0x00, 0x01, 0x00, 0x01, 0x00, // 776 $308 'uni0308' 0x00, 0x01, 0x03, 0x00, 0x00, // 777 $309 'hookabovecomb' 0x02, 0x05, 0x05, 0x02, 0x00, // 778 $30a 'uni030A' 0x02, 0x01, 0x00, 0x02, 0x01, // 779 $30b 'uni030B' 0x00, 0x01, 0x02, 0x01, 0x00, // 780 $30c 'uni030C' 0x00, 0x00, 0x03, 0x00, 0x00, // 781 $30d 'uni030D' 0x00, 0x03, 0x00, 0x03, 0x00, // 782 $30e 'uni030E' 0x01, 0x02, 0x00, 0x01, 0x02, // 783 $30f 'uni030F' 0x01, 0x02, 0x03, 0x02, 0x01, // 784 $310 'uni0310' 0x02, 0x01, 0x01, 0x02, 0x00, // 785 $311 'uni0311' 0x00, 0x06, 0x05, 0x00, 0x00, // 786 $312 'uni0312' 0x00, 0x05, 0x03, 0x00, 0x00, // 787 $313 'uni0313' 0x00, 0x03, 0x05, 0x00, 0x00, // 788 $314 'uni0314' 0x00, 0x00, 0x00, 0x05, 0x03, // 789 $315 'uni0315' 0x00, 0x00, 0x80, 0x00, 0x00, // 803 $323 'dotbelowcomb' 0x00, 0x80, 0x00, 0x80, 0x00, // 804 $324 'uni0324' 0x80, 0x80, 0x80, 0x80, 0x00, // 817 $331 'uni0331' 0x80, 0x80, 0x80, 0x80, 0x80, // 818 $332 'uni0332' 0x40, 0x30, 0x0c, 0x02, 0x00, // 824 $338 'uni0338' 0x00, 0x01, 0x02, 0x00, 0x00, // 832 $340 'uni0340' 0x00, 0x02, 0x01, 0x00, 0x00, // 833 $341 'uni0341' 0x00, 0x02, 0x01, 0x00, 0x00, // 884 $374 'uni0374' 0x00, 0x80, 0x40, 0x00, 0x00, // 885 $375 'uni0375' 0x00, 0xc0, 0x80, 0x00, 0x00, // 890 $37a 'uni037A' 0x00, 0x80, 0x6c, 0x2c, 0x00, // 894 $37e 'uni037E' 0x00, 0x02, 0x01, 0x00, 0x00, // 900 $384 'tonos' 0x00, 0x04, 0x02, 0x05, 0x00, // 901 $385 'dieresistonos' 0x78, 0x16, 0x15, 0x78, 0x00, // 902 $386 'Alphatonos' 0x00, 0x00, 0x08, 0x00, 0x00, // 903 $387 'anoteleia' 0x7c, 0x56, 0x55, 0x44, 0x00, // 904 $388 'Epsilontonos' 0x7c, 0x12, 0x11, 0x7c, 0x00, // 905 $389 'Etatonos' 0x00, 0x44, 0x7e, 0x45, 0x00, // 906 $38a 'Iotatonos' 0x38, 0x46, 0x45, 0x38, 0x00, // 908 $38c 'Omicrontonos' 0x04, 0x08, 0x72, 0x09, 0x04, // 910 $38e 'Upsilontonos' 0x58, 0x64, 0x06, 0x65, 0x58, // 911 $38f 'Omegatonos' 0x04, 0x3a, 0x45, 0x20, 0x00, // 912 $390 'iotadieresistonos' 0x7c, 0x12, 0x12, 0x7c, 0x00, // 913 $391 'Alpha' 0x7e, 0x4a, 0x4a, 0x34, 0x00, // 914 $392 'Beta' 0x7e, 0x02, 0x02, 0x02, 0x00, // 915 $393 'Gamma' 0x60, 0x58, 0x46, 0x58, 0x60, // 916 $394 'Delta' 0x7e, 0x4a, 0x4a, 0x42, 0x00, // 917 $395 'Epsilon' 0x62, 0x52, 0x4a, 0x46, 0x00, // 918 $396 'Zeta' 0x7e, 0x08, 0x08, 0x7e, 0x00, // 919 $397 'Eta' 0x3c, 0x4a, 0x4a, 0x3c, 0x00, // 920 $398 'Theta' 0x00, 0x42, 0x7e, 0x42, 0x00, // 921 $399 'Iota' 0x7e, 0x08, 0x34, 0x42, 0x00, // 922 $39a 'Kappa' 0x78, 0x06, 0x06, 0x78, 0x00, // 923 $39b 'Lambda' 0x7e, 0x0c, 0x0c, 0x7e, 0x00, // 924 $39c 'Mu' 0x7e, 0x0c, 0x38, 0x7e, 0x00, // 925 $39d 'Nu' 0x42, 0x4a, 0x4a, 0x42, 0x00, // 926 $39e 'Xi' 0x3c, 0x42, 0x42, 0x3c, 0x00, // 927 $39f 'Omicron' 0x7e, 0x02, 0x02, 0x7e, 0x00, // 928 $3a0 'Pi' 0x7e, 0x12, 0x12, 0x0c, 0x00, // 929 $3a1 'Rho' 0x66, 0x5a, 0x42, 0x42, 0x00, // 931 $3a3 'Sigma' 0x00, 0x02, 0x7e, 0x02, 0x00, // 932 $3a4 'Tau' 0x06, 0x08, 0x70, 0x08, 0x06, // 933 $3a5 'Upsilon' 0x18, 0x24, 0x7e, 0x24, 0x18, // 934 $3a6 'Phi' 0x66, 0x18, 0x18, 0x66, 0x00, // 935 $3a7 'Chi' 0x06, 0x08, 0x7e, 0x08, 0x06, // 936 $3a8 'Psi' 0x5c, 0x62, 0x02, 0x62, 0x5c, // 937 $3a9 'Omega' 0x00, 0x45, 0x7c, 0x45, 0x00, // 938 $3aa 'Iotadieresis' 0x00, 0x0d, 0x70, 0x0d, 0x00, // 939 $3ab 'Upsilondieresis' 0x30, 0x4a, 0x49, 0x78, 0x00, // 940 $3ac 'alphatonos' 0x30, 0x5a, 0x59, 0x48, 0x00, // 941 $3ad 'epsilontonos' 0x78, 0x12, 0x09, 0xf0, 0x00, // 942 $3ae 'etatonos' 0x00, 0x3a, 0x41, 0x20, 0x00, // 943 $3af 'iotatonos' 0x3a, 0x42, 0x41, 0x3a, 0x00, // 944 $3b0 'upsilondieresistonos' 0x30, 0x48, 0x48, 0x78, 0x00, // 945 $3b1 'alpha' 0xfc, 0x4a, 0x4a, 0x34, 0x00, // 946 $3b2 'beta' 0x00, 0x38, 0xc0, 0x38, 0x00, // 947 $3b3 'gamma' 0x34, 0x4a, 0x4a, 0x30, 0x00, // 948 $3b4 'delta' 0x30, 0x58, 0x58, 0x48, 0x00, // 949 $3b5 'epsilon' 0x14, 0x2c, 0xa4, 0x44, 0x00, // 950 $3b6 'zeta' 0x78, 0x10, 0x08, 0xf0, 0x00, // 951 $3b7 'eta' 0x3c, 0x4a, 0x4a, 0x3c, 0x00, // 952 $3b8 'theta' 0x00, 0x38, 0x40, 0x20, 0x00, // 953 $3b9 'iota' 0x78, 0x10, 0x30, 0x48, 0x00, // 954 $3ba 'kappa' 0x72, 0x0a, 0x0a, 0x7c, 0x00, // 955 $3bb 'lambda' 0xf8, 0x40, 0x40, 0x38, 0x00, // 956 $3bc 'mu' 0x00, 0x18, 0x60, 0x18, 0x00, // 957 $3bd 'nu' 0x12, 0xae, 0xaa, 0x42, 0x00, // 958 $3be 'xi' 0x30, 0x48, 0x48, 0x30, 0x00, // 959 $3bf 'omicron' 0x08, 0x78, 0x08, 0x78, 0x08, // 960 $3c0 'pi' 0xf0, 0x48, 0x48, 0x30, 0x00, // 961 $3c1 'rho' 0x10, 0xa8, 0xa8, 0x40, 0x00, // 962 $3c2 'sigma1' 0x30, 0x48, 0x48, 0x38, 0x00, // 963 $3c3 'sigma' 0x08, 0x38, 0x48, 0x28, 0x00, // 964 $3c4 'tau' 0x38, 0x40, 0x40, 0x38, 0x00, // 965 $3c5 'upsilon' 0x38, 0x40, 0xf8, 0x48, 0x30, // 966 $3c6 'phi' 0x00, 0xd8, 0x20, 0xd8, 0x00, // 967 $3c7 'chi' 0x18, 0x20, 0xf8, 0x20, 0x18, // 968 $3c8 'psi' 0x38, 0x40, 0x30, 0x40, 0x38, // 969 $3c9 'omega' 0x02, 0x38, 0x42, 0x20, 0x00, // 970 $3ca 'iotadieresis' 0x3a, 0x40, 0x40, 0x3a, 0x00, // 971 $3cb 'upsilondieresis' 0x30, 0x4a, 0x49, 0x30, 0x00, // 972 $3cc 'omicrontonos' 0x38, 0x42, 0x41, 0x38, 0x00, // 973 $3cd 'upsilontonos' 0x38, 0x40, 0x32, 0x41, 0x38, // 974 $3ce 'omegatonos' 0x24, 0x4a, 0x4a, 0x3c, 0x08, // 977 $3d1 'theta1' 0x02, 0x04, 0x7c, 0x02, 0x04, // 978 $3d2 'Upsilon1' 0x1a, 0x02, 0x7c, 0x02, 0x04, // 979 $3d3 'uni03D3' 0x05, 0x08, 0x78, 0x05, 0x08, // 980 $3d4 'uni03D4' 0x38, 0x44, 0xfe, 0x44, 0x38, // 981 $3d5 'phi1' 0x38, 0x48, 0x28, 0x48, 0x38, // 982 $3d6 'omega1' 0x3e, 0x10, 0x08, 0x7c, 0x00, // 990 $3de 'uni03DE' 0x08, 0x4c, 0x2a, 0x18, 0x00, // 991 $3df 'uni03DF' 0x50, 0xa8, 0xa8, 0x90, 0x00, // 1001 $3e9 'uni03E9' 0x48, 0x30, 0x20, 0x58, 0x00, // 1008 $3f0 'uni03F0' 0x70, 0xa8, 0xa8, 0x90, 0x00, // 1009 $3f1 'uni03F1' 0x30, 0x48, 0x48, 0x48, 0x00, // 1010 $3f2 'uni03F2' 0x40, 0x80, 0x88, 0x7a, 0x00, // 1011 $3f3 'uni03F3' 0x3c, 0x4a, 0x4a, 0x3c, 0x00, // 1012 $3f4 'uni03F4' 0x30, 0x58, 0x58, 0x48, 0x00, // 1013 $3f5 'uni03F5' 0x7e, 0x4a, 0x4a, 0x42, 0x00, // 1025 $401 'afii10023' 0x02, 0x3e, 0x8a, 0x70, 0x00, // 1026 $402 'afii10051' 0x7e, 0x02, 0x02, 0x02, 0x00, // 1027 $403 'afii10052' 0x3c, 0x4a, 0x42, 0x24, 0x00, // 1028 $404 'afii10053' 0x24, 0x4a, 0x52, 0x24, 0x00, // 1029 $405 'afii10054' 0x00, 0x42, 0x7e, 0x42, 0x00, // 1030 $406 'afii10055' 0x00, 0x42, 0x7e, 0x42, 0x00, // 1031 $407 'afii10056' 0x20, 0x40, 0x40, 0x3e, 0x00, // 1032 $408 'afii10057' 0x7c, 0x02, 0x7e, 0x48, 0x30, // 1033 $409 'afii10058' 0x7e, 0x08, 0x7e, 0x48, 0x30, // 1034 $40a 'afii10059' 0x02, 0x7e, 0x0a, 0x70, 0x00, // 1035 $40b 'afii10060' 0x7e, 0x18, 0x24, 0x42, 0x00, // 1036 $40c 'afii10061' 0x00, 0x00, 0x00, 0x00, 0x00, // 1037 $40d 'uni040D' 0x00, 0x4e, 0x30, 0x0e, 0x00, // 1038 $40e 'afii10062' 0x00, 0x7e, 0xc0, 0x7e, 0x00, // 1039 $40f 'afii10145' 0x7c, 0x12, 0x12, 0x7c, 0x00, // 1040 $410 'afii10017' 0x7e, 0x4a, 0x4a, 0x30, 0x00, // 1041 $411 'afii10018' 0x7e, 0x4a, 0x4a, 0x34, 0x00, // 1042 $412 'afii10019' 0x7e, 0x02, 0x02, 0x06, 0x00, // 1043 $413 'afii10020' 0xfc, 0x42, 0x7e, 0xc0, 0x00, // 1044 $414 'afii10021' 0x7e, 0x4a, 0x4a, 0x42, 0x00, // 1045 $415 'afii10022' 0x76, 0x08, 0x7e, 0x08, 0x76, // 1046 $416 'afii10024' 0x24, 0x42, 0x4a, 0x34, 0x00, // 1047 $417 'afii10025' 0x7e, 0x10, 0x08, 0x7e, 0x00, // 1048 $418 'afii10026' 0x7d, 0x12, 0x0a, 0x7d, 0x00, // 1049 $419 'afii10027' 0x7e, 0x08, 0x14, 0x62, 0x00, // 1050 $41a 'afii10028' 0x40, 0x3c, 0x02, 0x7e, 0x00, // 1051 $41b 'afii10029' 0x7e, 0x0c, 0x0c, 0x7e, 0x00, // 1052 $41c 'afii10030' 0x7e, 0x08, 0x08, 0x7e, 0x00, // 1053 $41d 'afii10031' 0x3c, 0x42, 0x42, 0x3c, 0x00, // 1054 $41e 'afii10032' 0x7e, 0x02, 0x02, 0x7e, 0x00, // 1055 $41f 'afii10033' 0x7e, 0x12, 0x12, 0x0c, 0x00, // 1056 $420 'afii10034' 0x3c, 0x42, 0x42, 0x24, 0x00, // 1057 $421 'afii10035' 0x00, 0x02, 0x7e, 0x02, 0x00, // 1058 $422 'afii10036' 0x4e, 0x50, 0x50, 0x3e, 0x00, // 1059 $423 'afii10037' 0x18, 0x24, 0x7e, 0x24, 0x18, // 1060 $424 'afii10038' 0x00, 0x66, 0x18, 0x66, 0x00, // 1061 $425 'afii10039' 0x7e, 0x40, 0x7e, 0xc0, 0x00, // 1062 $426 'afii10040' 0x00, 0x0e, 0x10, 0x7e, 0x00, // 1063 $427 'afii10041' 0x7e, 0x40, 0x7e, 0x40, 0x7e, // 1064 $428 'afii10042' 0x7e, 0x40, 0x7e, 0x40, 0xfe, // 1065 $429 'afii10043' 0x02, 0x02, 0x7e, 0x48, 0x30, // 1066 $42a 'afii10044' 0x7e, 0x48, 0x30, 0x00, 0x7e, // 1067 $42b 'afii10045' 0x00, 0x7e, 0x48, 0x30, 0x00, // 1068 $42c 'afii10046' 0x42, 0x4a, 0x4a, 0x3c, 0x00, // 1069 $42d 'afii10047' 0x7e, 0x08, 0x3c, 0x42, 0x3c, // 1070 $42e 'afii10048' 0x6c, 0x12, 0x12, 0x7e, 0x00, // 1071 $42f 'afii10049' 0x30, 0x48, 0x48, 0x78, 0x00, // 1072 $430 'afii10065' 0x3c, 0x4a, 0x4a, 0x30, 0x00, // 1073 $431 'afii10066' 0x78, 0x58, 0x58, 0x20, 0x00, // 1074 $432 'afii10067' 0x00, 0x78, 0x08, 0x08, 0x00, // 1075 $433 'afii10068' 0xe0, 0x58, 0x48, 0xf8, 0x00, // 1076 $434 'afii10069' 0x30, 0x68, 0x58, 0x10, 0x00, // 1077 $435 'afii10070' 0x68, 0x10, 0x78, 0x10, 0x68, // 1078 $436 'afii10072' 0x00, 0x48, 0x58, 0x38, 0x00, // 1079 $437 'afii10073' 0x78, 0x20, 0x10, 0x78, 0x00, // 1080 $438 'afii10074' 0x7a, 0x24, 0x14, 0x7a, 0x00, // 1081 $439 'afii10075' 0x78, 0x10, 0x30, 0x48, 0x00, // 1082 $43a 'afii10076' 0x40, 0x30, 0x08, 0x78, 0x00, // 1083 $43b 'afii10077' 0x78, 0x10, 0x60, 0x10, 0x78, // 1084 $43c 'afii10078' 0x78, 0x10, 0x10, 0x78, 0x00, // 1085 $43d 'afii10079' 0x30, 0x48, 0x48, 0x30, 0x00, // 1086 $43e 'afii10080' 0x78, 0x08, 0x08, 0x78, 0x00, // 1087 $43f 'afii10081' 0xf8, 0x48, 0x48, 0x30, 0x00, // 1088 $440 'afii10082' 0x00, 0x30, 0x48, 0x48, 0x00, // 1089 $441 'afii10083' 0x00, 0x08, 0x78, 0x08, 0x00, // 1090 $442 'afii10084' 0x18, 0xa0, 0x40, 0x38, 0x00, // 1091 $443 'afii10085' 0x00, 0x72, 0xde, 0x70, 0x00, // 1092 $444 'afii10086' 0x48, 0x30, 0x30, 0x48, 0x00, // 1093 $445 'afii10087' 0x78, 0x40, 0x40, 0xf8, 0x00, // 1094 $446 'afii10088' 0x18, 0x20, 0x20, 0x78, 0x00, // 1095 $447 'afii10089' 0x78, 0x40, 0x78, 0x40, 0x78, // 1096 $448 'afii10090' 0x78, 0x40, 0x78, 0x40, 0xf8, // 1097 $449 'afii10091' 0x08, 0x78, 0x50, 0x20, 0x00, // 1098 $44a 'afii10092' 0x78, 0x50, 0x20, 0x78, 0x00, // 1099 $44b 'afii10093' 0x78, 0x50, 0x50, 0x20, 0x00, // 1100 $44c 'afii10094' 0x00, 0x48, 0x58, 0x30, 0x00, // 1101 $44d 'afii10095' 0x78, 0x30, 0x48, 0x30, 0x00, // 1102 $44e 'afii10096' 0x00, 0x50, 0x28, 0x78, 0x00, // 1103 $44f 'afii10097' 0x32, 0x68, 0x5a, 0x10, 0x00, // 1105 $451 'afii10071' 0x04, 0x3e, 0x94, 0x60, 0x00, // 1106 $452 'afii10099' 0x78, 0x0c, 0x0a, 0x08, 0x00, // 1107 $453 'afii10100' 0x00, 0x30, 0x58, 0x48, 0x00, // 1108 $454 'afii10101' 0x50, 0x58, 0x68, 0x28, 0x00, // 1109 $455 'afii10102' 0x00, 0x48, 0x7a, 0x40, 0x00, // 1110 $456 'afii10103' 0x00, 0x4a, 0x78, 0x42, 0x00, // 1111 $457 'afii10104' 0x00, 0x40, 0x80, 0x7a, 0x00, // 1112 $458 'afii10105' 0x70, 0x08, 0x78, 0x50, 0x30, // 1113 $459 'afii10106' 0x78, 0x10, 0x78, 0x50, 0x20, // 1114 $45a 'afii10107' 0x04, 0x7e, 0x14, 0x60, 0x00, // 1115 $45b 'afii10108' 0x78, 0x14, 0x32, 0x48, 0x00, // 1116 $45c 'afii10109' 0x00, 0x00, 0x00, 0x00, 0x00, // 1117 $45d 'uni045D' 0x12, 0xa4, 0x44, 0x32, 0x00, // 1118 $45e 'afii10110' 0x00, 0x78, 0xc0, 0x78, 0x00, // 1119 $45f 'afii10193' 0x7c, 0x04, 0x04, 0x06, 0x00, // 1168 $490 'afii10050' 0x78, 0x08, 0x08, 0x0c, 0x00, // 1169 $491 'afii10098' 0x08, 0x7e, 0x0a, 0x02, 0x00, // 1170 $492 'uni0492' 0x20, 0x78, 0x28, 0x08, 0x00, // 1171 $493 'uni0493' 0x76, 0x08, 0x7e, 0x08, 0xf6, // 1174 $496 'uni0496' 0x68, 0x10, 0x78, 0x10, 0xe8, // 1175 $497 'uni0497' 0x7e, 0x08, 0x14, 0x22, 0xc0, // 1178 $49a 'uni049A' 0x78, 0x10, 0x30, 0x48, 0x80, // 1179 $49b 'uni049B' 0x06, 0x08, 0x70, 0x08, 0x06, // 1198 $4ae 'uni04AE' 0x08, 0x10, 0xe0, 0x10, 0x08, // 1199 $4af 'uni04AF' 0x16, 0x18, 0x70, 0x18, 0x16, // 1200 $4b0 'uni04B0' 0x28, 0x30, 0xe0, 0x30, 0x28, // 1201 $4b1 'uni04B1' 0x00, 0x66, 0x18, 0x66, 0x80, // 1202 $4b2 'uni04B2' 0x48, 0x30, 0x30, 0x48, 0x80, // 1203 $4b3 'uni04B3' 0x7e, 0x08, 0x08, 0x70, 0x00, // 1210 $4ba 'uni04BA' 0x00, 0x7e, 0x08, 0x70, 0x00, // 1211 $4bb 'uni04BB' 0x34, 0x52, 0x52, 0x3c, 0x00, // 1240 $4d8 'uni04D8' 0x20, 0x68, 0x58, 0x30, 0x00, // 1241 $4d9 'afii10846' 0x00, 0x45, 0x7d, 0x45, 0x00, // 1250 $4e2 'uni04E2' 0x00, 0x4a, 0x7a, 0x42, 0x00, // 1251 $4e3 'uni04E3' 0x3c, 0x4a, 0x4a, 0x3c, 0x00, // 1256 $4e8 'uni04E8' 0x30, 0x58, 0x58, 0x30, 0x00, // 1257 $4e9 'uni04E9' 0x3d, 0x41, 0x41, 0x3d, 0x00, // 1262 $4ee 'uni04EE' 0x3a, 0x42, 0x42, 0x7a, 0x00, // 1263 $4ef 'uni04EF' 0x68, 0x10, 0x20, 0x58, 0x00, // 1488 $5d0 'afii57664' 0x48, 0x48, 0x78, 0x40, 0x00, // 1489 $5d1 'afii57665' 0x40, 0x44, 0x38, 0x40, 0x00, // 1490 $5d2 'afii57666' 0x08, 0x08, 0x78, 0x08, 0x00, // 1491 $5d3 'afii57667' 0x68, 0x08, 0x08, 0x78, 0x00, // 1492 $5d4 'afii57668' 0x00, 0x04, 0x78, 0x00, 0x00, // 1493 $5d5 'afii57669' 0x00, 0x08, 0x78, 0x08, 0x00, // 1494 $5d6 'afii57670' 0x08, 0x78, 0x08, 0x78, 0x00, // 1495 $5d7 'afii57671' 0x78, 0x40, 0x40, 0x78, 0x00, // 1496 $5d8 'afii57672' 0x00, 0x04, 0x08, 0x00, 0x00, // 1497 $5d9 'afii57673' 0x08, 0x08, 0x68, 0x18, 0x00, // 1498 $5da 'afii57674' 0x44, 0x48, 0x48, 0x38, 0x00, // 1499 $5db 'afii57675' 0x04, 0x48, 0x28, 0x18, 0x00, // 1500 $5dc 'afii57676' 0x74, 0x48, 0x48, 0x78, 0x00, // 1501 $5dd 'afii57677' 0x74, 0x08, 0x48, 0x78, 0x00, // 1502 $5de 'afii57678' 0x00, 0x74, 0x08, 0x00, 0x00, // 1503 $5df 'afii57679' 0x00, 0x44, 0x78, 0x00, 0x00, // 1504 $5e0 'afii57680' 0x04, 0x38, 0x48, 0x48, 0x38, // 1505 $5e1 'afii57681' 0x48, 0x70, 0x40, 0x78, 0x00, // 1506 $5e2 'afii57682' 0x10, 0x08, 0x08, 0x78, 0x00, // 1507 $5e3 'afii57683' 0x58, 0x48, 0x48, 0x78, 0x00, // 1508 $5e4 'afii57684' 0x00, 0x78, 0x10, 0x08, 0x00, // 1509 $5e5 'afii57685' 0x48, 0x50, 0x70, 0x48, 0x00, // 1510 $5e6 'afii57686' 0x68, 0x08, 0x28, 0x10, 0x00, // 1511 $5e7 'afii57687' 0x08, 0x08, 0x08, 0x78, 0x00, // 1512 $5e8 'afii57688' 0x78, 0x50, 0x48, 0x40, 0x38, // 1513 $5e9 'afii57689' 0x48, 0x78, 0x08, 0x78, 0x00, // 1514 $5ea 'afii57690' 0x7c, 0x54, 0x55, 0x28, 0x00, // 7682 $1e02 'uni1E02' 0x7e, 0x48, 0x49, 0x30, 0x00, // 7683 $1e03 'uni1E03' 0x7c, 0x44, 0x45, 0x38, 0x00, // 7690 $1e0a 'uni1E0A' 0x30, 0x49, 0x48, 0x7e, 0x00, // 7691 $1e0b 'uni1E0B' 0x7c, 0x14, 0x15, 0x04, 0x00, // 7710 $1e1e 'uni1E1E' 0x11, 0x7c, 0x12, 0x04, 0x00, // 7711 $1e1f 'uni1E1F' 0x7c, 0x18, 0x19, 0x7c, 0x00, // 7744 $1e40 'uni1E40' 0x78, 0x08, 0x72, 0x08, 0x70, // 7745 $1e41 'uni1E41' 0x7c, 0x15, 0x14, 0x08, 0x00, // 7766 $1e56 'uni1E56' 0xf8, 0x2a, 0x28, 0x10, 0x00, // 7767 $1e57 'uni1E57' 0x48, 0x54, 0x55, 0x24, 0x00, // 7776 $1e60 'uni1E60' 0x00, 0x50, 0x5a, 0x28, 0x00, // 7777 $1e61 'uni1E61' 0x00, 0x04, 0x7d, 0x04, 0x00, // 7786 $1e6a 'uni1E6A' 0x08, 0x3d, 0x48, 0x20, 0x00, // 7787 $1e6b 'uni1E6B' 0x7c, 0x31, 0x32, 0x7c, 0x00, // 7808 $1e80 'Wgrave' 0x38, 0x41, 0x32, 0x40, 0x38, // 7809 $1e81 'wgrave' 0x7c, 0x32, 0x31, 0x7c, 0x00, // 7810 $1e82 'Wacute' 0x38, 0x40, 0x32, 0x41, 0x38, // 7811 $1e83 'wacute' 0x7d, 0x30, 0x30, 0x7d, 0x00, // 7812 $1e84 'Wdieresis' 0x38, 0x42, 0x30, 0x42, 0x38, // 7813 $1e85 'wdieresis' 0x04, 0x09, 0x72, 0x08, 0x04, // 7922 $1ef2 'Ygrave' 0x58, 0xa1, 0xa2, 0x78, 0x00, // 7923 $1ef3 'ygrave' 0x00, 0x10, 0x10, 0x10, 0x00, // 8208 $2010 'uni2010' 0x00, 0x10, 0x10, 0x10, 0x00, // 8209 $2011 'uni2011' 0x10, 0x10, 0x10, 0x10, 0x00, // 8210 $2012 'figuredash' 0x10, 0x10, 0x10, 0x10, 0x00, // 8211 $2013 'endash' 0x10, 0x10, 0x10, 0x10, 0x10, // 8212 $2014 'emdash' 0x10, 0x10, 0x10, 0x10, 0x10, // 8213 $2015 'afii00208' 0x00, 0x7e, 0x00, 0x7e, 0x00, // 8214 $2016 'uni2016' 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, // 8215 $2017 'underscoredbl' 0x00, 0x06, 0x05, 0x00, 0x00, // 8216 $2018 'quoteleft' 0x00, 0x05, 0x03, 0x00, 0x00, // 8217 $2019 'quoteright' 0x00, 0xa0, 0x60, 0x00, 0x00, // 8218 $201a 'quotesinglbase' 0x00, 0x03, 0x05, 0x00, 0x00, // 8219 $201b 'quotereversed' 0x06, 0x05, 0x00, 0x06, 0x05, // 8220 $201c 'quotedblleft' 0x05, 0x03, 0x00, 0x05, 0x03, // 8221 $201d 'quotedblright' 0xa0, 0x60, 0x00, 0xa0, 0x60, // 8222 $201e 'quotedblbase' 0x03, 0x05, 0x00, 0x03, 0x05, // 8223 $201f 'uni201F' 0x00, 0x04, 0x7e, 0x04, 0x00, // 8224 $2020 'dagger' 0x00, 0x14, 0x7e, 0x14, 0x00, // 8225 $2021 'daggerdbl' 0x30, 0x78, 0x78, 0x30, 0x00, // 8226 $2022 'bullet' 0x40, 0x00, 0x40, 0x00, 0x40, // 8230 $2026 'ellipsis' 0x16, 0x08, 0x34, 0x00, 0x30, // 8240 $2030 'perthousand' 0x00, 0x08, 0x06, 0x00, 0x00, // 8242 $2032 'minute' 0x08, 0x06, 0x08, 0x06, 0x00, // 8243 $2033 'second' 0x0e, 0x08, 0x06, 0x08, 0x06, // 8244 $2034 'uni2034' 0x00, 0x06, 0x08, 0x00, 0x00, // 8245 $2035 'uni2035' 0x06, 0x08, 0x06, 0x08, 0x00, // 8246 $2036 'uni2036' 0x00, 0x10, 0x28, 0x00, 0x00, // 8249 $2039 'guilsinglleft' 0x00, 0x28, 0x10, 0x00, 0x00, // 8250 $203a 'guilsinglright' 0x00, 0x5e, 0x00, 0x5e, 0x00, // 8252 $203c 'exclamdbl' 0x00, 0x04, 0x5e, 0x0c, 0x00, // 8253 $203d 'uni203D' 0x01, 0x01, 0x01, 0x01, 0x01, // 8254 $203e 'uni203E' 0x40, 0x30, 0x0c, 0x02, 0x00, // 8260 $2044 'fraction' 0x00, 0x0e, 0x11, 0x0e, 0x00, // 8304 $2070 'zerosuperior' 0x00, 0x14, 0x1d, 0x10, 0x00, // 8305 $2071 'uni2071' 0x00, 0x0f, 0x1c, 0x08, 0x00, // 8308 $2074 'foursuperior' 0x00, 0x17, 0x15, 0x09, 0x00, // 8309 $2075 'fivesuperior' 0x00, 0x0e, 0x15, 0x09, 0x00, // 8310 $2076 'sixsuperior' 0x00, 0x01, 0x1d, 0x03, 0x00, // 8311 $2077 'sevensuperior' 0x00, 0x0a, 0x15, 0x0a, 0x00, // 8312 $2078 'eightsuperior' 0x00, 0x12, 0x15, 0x0e, 0x00, // 8313 $2079 'ninesuperior' 0x00, 0x04, 0x0e, 0x04, 0x00, // 8314 $207a 'uni207A' 0x00, 0x04, 0x04, 0x04, 0x00, // 8315 $207b 'uni207B' 0x00, 0x0a, 0x0a, 0x0a, 0x00, // 8316 $207c 'uni207C' 0x00, 0x0e, 0x11, 0x00, 0x00, // 8317 $207d 'parenleftsuperior' 0x00, 0x11, 0x0e, 0x00, 0x00, // 8318 $207e 'parenrightsuperior' 0x00, 0x1c, 0x04, 0x18, 0x00, // 8319 $207f 'nsuperior' 0x00, 0x70, 0x88, 0x70, 0x00, // 8320 $2080 'zeroinferior' 0x00, 0x90, 0xf8, 0x80, 0x00, // 8321 $2081 'oneinferior' 0x00, 0x90, 0xc8, 0xb0, 0x00, // 8322 $2082 'twoinferior' 0x00, 0xa8, 0xa8, 0x50, 0x00, // 8323 $2083 'threeinferior' 0x00, 0x78, 0xe0, 0x40, 0x00, // 8324 $2084 'fourinferior' 0x00, 0xb8, 0xa8, 0x48, 0x00, // 8325 $2085 'fiveinferior' 0x00, 0x70, 0xa8, 0x48, 0x00, // 8326 $2086 'sixinferior' 0x00, 0x08, 0xe8, 0x18, 0x00, // 8327 $2087 'seveninferior' 0x00, 0x50, 0xa8, 0x50, 0x00, // 8328 $2088 'eightinferior' 0x00, 0x90, 0xa8, 0x70, 0x00, // 8329 $2089 'nineinferior' 0x00, 0x20, 0x70, 0x20, 0x00, // 8330 $208a 'uni208A' 0x00, 0x20, 0x20, 0x20, 0x00, // 8331 $208b 'uni208B' 0x00, 0x50, 0x50, 0x50, 0x00, // 8332 $208c 'uni208C' 0x00, 0x70, 0x88, 0x00, 0x00, // 8333 $208d 'parenleftinferior' 0x00, 0x88, 0x70, 0x00, 0x00, // 8334 $208e 'parenrightinferior' 0x7e, 0x0a, 0x7a, 0x0a, 0x00, // 8355 $20a3 'franc' 0x58, 0x3c, 0x5a, 0x24, 0x00, // 8356 $20a4 'lira' 0x08, 0x7e, 0x1a, 0x1a, 0x0c, // 8359 $20a7 'peseta' 0xb0, 0xc8, 0xcc, 0xfe, 0x04, // 8363 $20ab 'dong' 0x14, 0x3e, 0x55, 0x41, 0x00, // 8364 $20ac 'Euro' 0x62, 0x7f, 0x42, 0x3c, 0x00, // 8367 $20af 'uni20AF' 0x02, 0x03, 0x02, 0x02, 0x00, // 8400 $20d0 'uni20D0' 0x02, 0x02, 0x03, 0x02, 0x00, // 8401 $20d1 'uni20D1' 0x00, 0x00, 0xff, 0x00, 0x00, // 8402 $20d2 'uni20D2' 0x00, 0x00, 0xfc, 0x00, 0x00, // 8403 $20d3 'uni20D3' 0x03, 0x03, 0x01, 0x02, 0x00, // 8404 $20d4 'uni20D4' 0x02, 0x01, 0x03, 0x03, 0x00, // 8405 $20d5 'uni20D5' 0x02, 0x07, 0x02, 0x02, 0x00, // 8406 $20d6 'uni20D6' 0x02, 0x02, 0x07, 0x02, 0x00, // 8407 $20d7 'uni20D7' 0x3c, 0x42, 0x7e, 0x24, 0x00, // 8450 $2102 'uni2102' 0x46, 0x29, 0x3c, 0x4a, 0x30, // 8453 $2105 'afii61248' 0x40, 0x3c, 0x52, 0x4c, 0x00, // 8467 $2113 'afii61289' 0x7e, 0x7e, 0x18, 0x7e, 0x00, // 8469 $2115 'uni2115' 0x7e, 0x02, 0x7c, 0x54, 0x48, // 8470 $2116 'afii61352' 0x3c, 0x7e, 0x62, 0xbc, 0x00, // 8474 $211a 'uni211A' 0x7e, 0x7e, 0x12, 0x6c, 0x00, // 8477 $211d 'uni211D' 0x00, 0x71, 0x37, 0x71, 0x00, // 8482 $2122 'trademark' 0x72, 0x4e, 0x72, 0x4e, 0x00, // 8484 $2124 'uni2124' 0x5c, 0x62, 0x02, 0x62, 0x5c, // 8486 $2126 'Omega' 0x3c, 0x7e, 0x4a, 0x2c, 0x00, // 8494 $212e 'estimated' 0x1f, 0x28, 0x54, 0x28, 0x00, // 8539 $215b 'oneeighth' 0x15, 0x0a, 0x28, 0x54, 0x28, // 8540 $215c 'threeeighths' 0x17, 0x0d, 0x28, 0x54, 0x28, // 8541 $215d 'fiveeighths' 0x19, 0x07, 0x28, 0x54, 0x28, // 8542 $215e 'seveneighths' 0x10, 0x38, 0x54, 0x10, 0x10, // 8592 $2190 'arrowleft' 0x08, 0x04, 0x7e, 0x04, 0x08, // 8593 $2191 'arrowup' 0x10, 0x10, 0x54, 0x38, 0x10, // 8594 $2192 'arrowright' 0x10, 0x20, 0x7e, 0x20, 0x10, // 8595 $2193 'arrowdown' 0x10, 0x38, 0x10, 0x38, 0x10, // 8596 $2194 'arrowboth' 0x00, 0x24, 0x7e, 0x24, 0x00, // 8597 $2195 'arrowupdn' 0x0e, 0x06, 0x1a, 0x60, 0x00, // 8598 $2196 'uni2196' 0x60, 0x1a, 0x06, 0x0e, 0x00, // 8599 $2197 'uni2197' 0x06, 0x58, 0x60, 0x70, 0x00, // 8600 $2198 'uni2198' 0x70, 0x60, 0x58, 0x06, 0x00, // 8601 $2199 'uni2199' 0x10, 0x38, 0x54, 0x10, 0x38, // 8612 $21a4 'uni21A4' 0x08, 0x44, 0x7e, 0x44, 0x08, // 8613 $21a5 'uni21A5' 0x38, 0x10, 0x54, 0x38, 0x10, // 8614 $21a6 'uni21A6' 0x10, 0x22, 0x7e, 0x22, 0x10, // 8615 $21a7 'uni21A7' 0x00, 0xa4, 0xfe, 0xa4, 0x00, // 8616 $21a8 'arrowupdnbse' 0x04, 0x0e, 0x04, 0x7c, 0x00, // 8624 $21b0 'uni21B0' 0x7c, 0x04, 0x0e, 0x04, 0x00, // 8625 $21b1 'uni21B1' 0x20, 0x70, 0x20, 0x3e, 0x00, // 8626 $21b2 'uni21B2' 0x3e, 0x20, 0x70, 0x20, 0x00, // 8627 $21b3 'uni21B3' 0x04, 0x24, 0x7c, 0x20, 0x00, // 8628 $21b4 'uni21B4' 0x20, 0x70, 0x20, 0x3c, 0x00, // 8629 $21b5 'carriagereturn' 0x10, 0x18, 0x14, 0x10, 0x10, // 8636 $21bc 'uni21BC' 0x10, 0x30, 0x50, 0x10, 0x10, // 8637 $21bd 'uni21BD' 0x00, 0x00, 0x7e, 0x04, 0x08, // 8638 $21be 'uni21BE' 0x08, 0x04, 0x7e, 0x00, 0x00, // 8639 $21bf 'uni21BF' 0x10, 0x10, 0x14, 0x18, 0x10, // 8640 $21c0 'uni21C0' 0x10, 0x10, 0x50, 0x30, 0x10, // 8641 $21c1 'uni21C1' 0x00, 0x00, 0x7e, 0x20, 0x10, // 8642 $21c2 'uni21C2' 0x10, 0x20, 0x7e, 0x00, 0x00, // 8643 $21c3 'uni21C3' 0x28, 0x2c, 0x68, 0x28, 0x00, // 8651 $21cb 'uni21CB' 0x28, 0x68, 0x2c, 0x28, 0x00, // 8652 $21cc 'uni21CC' 0x08, 0x14, 0x36, 0x14, 0x14, // 8656 $21d0 'arrowdblleft' 0x08, 0x7c, 0x02, 0x7c, 0x08, // 8657 $21d1 'arrowdblup' 0x14, 0x14, 0x36, 0x14, 0x08, // 8658 $21d2 'arrowdblright' 0x10, 0x3e, 0x40, 0x3e, 0x10, // 8659 $21d3 'arrowdbldown' 0x08, 0x14, 0x36, 0x14, 0x08, // 8660 $21d4 'arrowdblboth' 0x28, 0x7c, 0x82, 0x7c, 0x28, // 8661 $21d5 'uni21D5' 0x3c, 0x14, 0x2c, 0x54, 0x20, // 8662 $21d6 'uni21D6' 0x20, 0x54, 0x2c, 0x14, 0x3c, // 8663 $21d7 'uni21D7' 0x08, 0x54, 0x68, 0x50, 0x78, // 8664 $21d8 'uni21D8' 0x78, 0x50, 0x68, 0x54, 0x08, // 8665 $21d9 'uni21D9' 0x10, 0x28, 0x54, 0x00, 0x10, // 8672 $21e0 'uni21E0' 0x08, 0x04, 0x56, 0x04, 0x08, // 8673 $21e1 'uni21E1' 0x10, 0x00, 0x54, 0x28, 0x10, // 8674 $21e2 'uni21E2' 0x10, 0x20, 0x6a, 0x20, 0x10, // 8675 $21e3 'uni21E3' 0x7c, 0x38, 0x54, 0x10, 0x10, // 8676 $21e4 'uni21E4' 0x10, 0x10, 0x54, 0x38, 0x7c, // 8677 $21e5 'uni21E5' 0x08, 0x14, 0x36, 0x14, 0x1c, // 8678 $21e6 'uni21E6' 0x08, 0x7c, 0x42, 0x7c, 0x08, // 8679 $21e7 'uni21E7' 0x1c, 0x14, 0x36, 0x14, 0x08, // 8680 $21e8 'uni21E8' 0x10, 0x3e, 0x42, 0x3e, 0x10, // 8681 $21e9 'uni21E9' 0x3e, 0x48, 0x48, 0x3e, 0x00, // 8704 $2200 'universal' 0x00, 0x3c, 0x42, 0x24, 0x00, // 8705 $2201 'uni2201' 0x30, 0x4a, 0x52, 0x3c, 0x00, // 8706 $2202 'partialdiff' 0x42, 0x4a, 0x4a, 0x7e, 0x00, // 8707 $2203 'existential' 0x42, 0xfa, 0x4f, 0x7e, 0x00, // 8708 $2204 'uni2204' 0x7c, 0x72, 0x4e, 0x3e, 0x00, // 8709 $2205 'emptyset' 0x60, 0x58, 0x46, 0x58, 0x60, // 8710 $2206 'Delta' 0x06, 0x1a, 0x62, 0x1a, 0x06, // 8711 $2207 'gradient' 0x38, 0x54, 0x54, 0x44, 0x00, // 8712 $2208 'element' 0x38, 0xf4, 0x5e, 0x44, 0x00, // 8713 $2209 'notelement' 0x44, 0x54, 0x54, 0x38, 0x00, // 8715 $220b 'suchthat' 0x44, 0xf4, 0x5e, 0x38, 0x00, // 8716 $220c 'uni220C' 0x00, 0x3c, 0x3c, 0x3c, 0x00, // 8718 $220e 'uni220E' 0x81, 0xff, 0x01, 0xff, 0x81, // 8719 $220f 'product' 0x81, 0xff, 0x80, 0xff, 0x81, // 8720 $2210 'uni2210' 0xc3, 0xa5, 0x99, 0x81, 0x81, // 8721 $2211 'summation' 0x10, 0x10, 0x10, 0x10, 0x00, // 8722 $2212 'minus' 0x00, 0x24, 0x74, 0x24, 0x00, // 8723 $2213 'uni2213' 0x00, 0x20, 0x74, 0x20, 0x00, // 8724 $2214 'uni2214' 0x40, 0x30, 0x0c, 0x02, 0x00, // 8725 $2215 'fraction' 0x02, 0x0c, 0x30, 0x40, 0x00, // 8726 $2216 'uni2216' 0x54, 0x38, 0x38, 0x54, 0x00, // 8727 $2217 'asteriskmath' 0x00, 0x10, 0x28, 0x10, 0x00, // 8728 $2218 'uni2218' 0x00, 0x10, 0x38, 0x10, 0x00, // 8729 $2219 'periodcentered' 0x10, 0x30, 0xc0, 0x3f, 0x01, // 8730 $221a 'radical' 0x18, 0x24, 0x18, 0x24, 0x00, // 8733 $221d 'proportional' 0x18, 0x24, 0x18, 0x24, 0x18, // 8734 $221e 'infinity' 0x78, 0x40, 0x40, 0x40, 0x00, // 8735 $221f 'orthogonal' 0x60, 0x50, 0x48, 0x44, 0x00, // 8736 $2220 'angle' 0x68, 0x50, 0xe8, 0x44, 0x00, // 8737 $2221 'uni2221' 0x5a, 0x24, 0x3c, 0x42, 0x00, // 8738 $2222 'uni2222' 0x00, 0x00, 0x7e, 0x00, 0x00, // 8739 $2223 'uni2223' 0x00, 0x10, 0x7e, 0x08, 0x00, // 8740 $2224 'uni2224' 0x00, 0x7e, 0x00, 0x7e, 0x00, // 8741 $2225 'uni2225' 0x10, 0x7e, 0x08, 0x7e, 0x04, // 8742 $2226 'uni2226' 0x60, 0x18, 0x18, 0x60, 0x00, // 8743 $2227 'logicaland' 0x18, 0x60, 0x60, 0x18, 0x00, // 8744 $2228 'logicalor' 0x70, 0x08, 0x08, 0x70, 0x00, // 8745 $2229 'intersection' 0x38, 0x40, 0x40, 0x38, 0x00, // 8746 $222a 'union' 0x40, 0x80, 0x7e, 0x01, 0x02, // 8747 $222b 'integral' 0x40, 0x98, 0x7e, 0x19, 0x02, // 8750 $222e 'uni222E' 0x00, 0x20, 0x08, 0x20, 0x00, // 8756 $2234 'therefore' 0x00, 0x08, 0x20, 0x08, 0x00, // 8757 $2235 'uni2235' 0x00, 0x00, 0x28, 0x00, 0x00, // 8758 $2236 'uni2236' 0x00, 0x28, 0x00, 0x28, 0x00, // 8759 $2237 'uni2237' 0x10, 0x14, 0x14, 0x10, 0x00, // 8760 $2238 'uni2238' 0x10, 0x10, 0x00, 0x28, 0x00, // 8761 $2239 'uni2239' 0x54, 0x10, 0x10, 0x54, 0x00, // 8762 $223a 'uni223A' 0x10, 0x48, 0x12, 0x08, 0x00, // 8763 $223b 'uni223B' 0x10, 0x08, 0x10, 0x08, 0x00, // 8764 $223c 'similar' 0x08, 0x10, 0x08, 0x10, 0x00, // 8765 $223d 'uni223D' 0x00, 0x32, 0x4c, 0x00, 0x00, // 8768 $2240 'uni2240' 0x48, 0x28, 0x48, 0x28, 0x00, // 8770 $2242 'uni2242' 0x50, 0x48, 0x50, 0x48, 0x00, // 8771 $2243 'uni2243' 0x54, 0x52, 0x54, 0x52, 0x00, // 8773 $2245 'congruent' 0x50, 0x28, 0x50, 0x28, 0x00, // 8776 $2248 'approxequal' 0x50, 0xe8, 0x5c, 0x28, 0x00, // 8777 $2249 'uni2249' 0x54, 0x4a, 0x54, 0x4a, 0x00, // 8778 $224a 'uni224A' 0x54, 0x2a, 0x54, 0x2a, 0x00, // 8779 $224b 'uni224B' 0x54, 0x52, 0x52, 0x54, 0x00, // 8792 $2258 'uni2258' 0x50, 0x54, 0x52, 0x54, 0x00, // 8793 $2259 'uni2259' 0x50, 0x52, 0x54, 0x52, 0x00, // 8794 $225a 'uni225A' 0xa0, 0xb5, 0xa2, 0xa0, 0x00, // 8799 $225f 'uni225F' 0x28, 0x78, 0x3c, 0x28, 0x00, // 8800 $2260 'notequal' 0x54, 0x54, 0x54, 0x54, 0x00, // 8801 $2261 'equivalence' 0xd4, 0x74, 0x5c, 0x56, 0x00, // 8802 $2262 'uni2262' 0x55, 0x55, 0x55, 0x55, 0x00, // 8803 $2263 'uni2263' 0x00, 0x48, 0x54, 0x62, 0x00, // 8804 $2264 'lessequal' 0x00, 0x62, 0x54, 0x48, 0x00, // 8805 $2265 'greaterequal' 0x10, 0x28, 0x54, 0x28, 0x44, // 8810 $226a 'uni226A' 0x44, 0x28, 0x54, 0x28, 0x10, // 8811 $226b 'uni226B' 0x10, 0x28, 0x28, 0x28, 0x00, // 8834 $2282 'propersubset' 0x28, 0x28, 0x28, 0x10, 0x00, // 8835 $2283 'propersuperset' 0x10, 0x28, 0x7c, 0x28, 0x00, // 8836 $2284 'notsubset' 0x28, 0x7c, 0x28, 0x10, 0x00, // 8837 $2285 'uni2285' 0x48, 0x54, 0x54, 0x54, 0x00, // 8838 $2286 'reflexsubset' 0x54, 0x54, 0x54, 0x48, 0x00, // 8839 $2287 'reflexsuperset' 0x48, 0x54, 0xfe, 0x54, 0x00, // 8840 $2288 'uni2288' 0x54, 0xfe, 0x54, 0x48, 0x00, // 8841 $2289 'uni2289' 0x48, 0xd4, 0x74, 0x54, 0x00, // 8842 $228a 'uni228A' 0x54, 0xd4, 0x74, 0x48, 0x00, // 8843 $228b 'uni228B' 0x38, 0x54, 0x7c, 0x54, 0x38, // 8853 $2295 'circleplus' 0x38, 0x54, 0x54, 0x54, 0x38, // 8854 $2296 'uni2296' 0x38, 0x6c, 0x54, 0x6c, 0x38, // 8855 $2297 'circlemultiply' 0x38, 0x64, 0x54, 0x4c, 0x38, // 8856 $2298 'uni2298' 0x38, 0x44, 0x54, 0x44, 0x38, // 8857 $2299 'uni2299' 0x7c, 0x54, 0x7c, 0x54, 0x7c, // 8862 $229e 'uni229E' 0x7c, 0x54, 0x54, 0x54, 0x7c, // 8863 $229f 'uni229F' 0x7c, 0x6c, 0x54, 0x6c, 0x7c, // 8864 $22a0 'uni22A0' 0x7c, 0x44, 0x54, 0x44, 0x7c, // 8865 $22a1 'uni22A1' 0x7c, 0x10, 0x10, 0x10, 0x00, // 8866 $22a2 'uni22A2' 0x10, 0x10, 0x10, 0x7c, 0x00, // 8867 $22a3 'uni22A3' 0x02, 0x02, 0x7e, 0x02, 0x02, // 8868 $22a4 'uni22A4' 0x40, 0x40, 0x7e, 0x40, 0x40, // 8869 $22a5 'perpendicular' 0x00, 0x7c, 0x10, 0x10, 0x00, // 8870 $22a6 'uni22A6' 0x00, 0x7c, 0x28, 0x28, 0x00, // 8871 $22a7 'uni22A7' 0x7c, 0x28, 0x28, 0x28, 0x00, // 8872 $22a8 'uni22A8' 0xe0, 0x1c, 0x03, 0x1c, 0xe0, // 8896 $22c0 'uni22C0' 0x07, 0x38, 0xc0, 0x38, 0x07, // 8897 $22c1 'uni22C1' 0xfc, 0x02, 0x01, 0x02, 0xfc, // 8898 $22c2 'uni22C2' 0x3f, 0x40, 0x80, 0x40, 0x3f, // 8899 $22c3 'uni22C3' 0x00, 0x00, 0x10, 0x00, 0x00, // 8901 $22c5 'dotmath' 0x50, 0x28, 0x50, 0x28, 0x00, // 8960 $2300 'uni2300' 0x7c, 0x42, 0x42, 0x7c, 0x00, // 8962 $2302 'house' 0x00, 0x7e, 0x02, 0x02, 0x00, // 8968 $2308 'uni2308' 0x00, 0x02, 0x02, 0x7e, 0x00, // 8969 $2309 'uni2309' 0x00, 0x7e, 0x40, 0x40, 0x00, // 8970 $230a 'uni230A' 0x00, 0x40, 0x40, 0x7e, 0x00, // 8971 $230b 'uni230B' 0x00, 0x70, 0x10, 0x10, 0x00, // 8976 $2310 'revlogicalnot' 0x70, 0x68, 0x48, 0x30, 0x00, // 8981 $2315 'uni2315' 0x00, 0x00, 0xfc, 0x02, 0x04, // 8992 $2320 'integraltp' 0x20, 0x40, 0x3f, 0x00, 0x00, // 8993 $2321 'integralbt' 0x01, 0x01, 0x01, 0x01, 0x01, // 9146 $23ba 'uni23BA' 0x02, 0x02, 0x02, 0x02, 0x02, // 9147 $23bb 'uni23BB' 0x40, 0x40, 0x40, 0x40, 0x40, // 9148 $23bc 'uni23BC' 0x80, 0x80, 0x80, 0x80, 0x80, // 9149 $23bd 'uni23BD' 0x1f, 0x24, 0xff, 0x20, 0x00, // 9225 $2409 'uni2409' 0x0f, 0x08, 0xf8, 0x50, 0x10, // 9226 $240a 'uni240A' 0x07, 0x08, 0x17, 0xf0, 0x10, // 9227 $240b 'uni240B' 0x1f, 0x05, 0xf9, 0x28, 0x08, // 9228 $240c 'uni240C' 0x06, 0x09, 0xf9, 0x50, 0xa0, // 9229 $240d 'uni240D' 0x0f, 0x02, 0xf4, 0x8f, 0x80, // 9252 $2424 'uni2424' 0x08, 0x08, 0x08, 0x08, 0x08, // 9472 $2500 'SF100000' 0x18, 0x18, 0x18, 0x18, 0x18, // 9473 $2501 'uni2501' 0x00, 0x00, 0xff, 0x00, 0x00, // 9474 $2502 'SF110000' 0x00, 0x00, 0xff, 0xff, 0x00, // 9475 $2503 'uni2503' 0x08, 0x00, 0x08, 0x00, 0x08, // 9476 $2504 'uni2504' 0x18, 0x00, 0x18, 0x00, 0x18, // 9477 $2505 'uni2505' 0x00, 0x00, 0xdb, 0x00, 0x00, // 9478 $2506 'uni2506' 0x00, 0x00, 0xdb, 0xdb, 0x00, // 9479 $2507 'uni2507' 0x08, 0x00, 0x08, 0x00, 0x08, // 9480 $2508 'uni2508' 0x18, 0x00, 0x18, 0x00, 0x18, // 9481 $2509 'uni2509' 0x00, 0x00, 0x55, 0x00, 0x00, // 9482 $250a 'uni250A' 0x00, 0x00, 0x55, 0x55, 0x00, // 9483 $250b 'uni250B' 0x00, 0x00, 0xf8, 0x08, 0x08, // 9484 $250c 'SF010000' 0x00, 0x00, 0xf8, 0x18, 0x18, // 9485 $250d 'uni250D' 0x00, 0x00, 0xf8, 0xf8, 0x08, // 9486 $250e 'uni250E' 0x00, 0x00, 0xf8, 0xf8, 0x18, // 9487 $250f 'uni250F' 0x08, 0x08, 0xf8, 0x00, 0x00, // 9488 $2510 'SF030000' 0x18, 0x18, 0xf8, 0x00, 0x00, // 9489 $2511 'uni2511' 0x08, 0x08, 0xf8, 0xf8, 0x00, // 9490 $2512 'uni2512' 0x18, 0x18, 0xf8, 0xf8, 0x00, // 9491 $2513 'uni2513' 0x00, 0x00, 0x0f, 0x08, 0x08, // 9492 $2514 'SF020000' 0x00, 0x00, 0x1f, 0x18, 0x18, // 9493 $2515 'uni2515' 0x00, 0x00, 0x0f, 0x0f, 0x08, // 9494 $2516 'uni2516' 0x00, 0x00, 0x1f, 0x1f, 0x18, // 9495 $2517 'uni2517' 0x08, 0x08, 0x0f, 0x00, 0x00, // 9496 $2518 'SF040000' 0x18, 0x18, 0x1f, 0x00, 0x00, // 9497 $2519 'uni2519' 0x08, 0x08, 0x0f, 0x0f, 0x00, // 9498 $251a 'uni251A' 0x18, 0x18, 0x1f, 0x1f, 0x00, // 9499 $251b 'uni251B' 0x00, 0x00, 0xff, 0x08, 0x08, // 9500 $251c 'SF080000' 0x00, 0x00, 0xff, 0x18, 0x18, // 9501 $251d 'uni251D' 0x00, 0x00, 0xff, 0x0f, 0x08, // 9502 $251e 'uni251E' 0x00, 0x00, 0xff, 0xf8, 0x08, // 9503 $251f 'uni251F' 0x00, 0x00, 0xff, 0xff, 0x08, // 9504 $2520 'uni2520' 0x00, 0x00, 0xff, 0x1f, 0x18, // 9505 $2521 'uni2521' 0x00, 0x00, 0xff, 0xf8, 0x18, // 9506 $2522 'uni2522' 0x00, 0x00, 0xff, 0xff, 0x18, // 9507 $2523 'uni2523' 0x08, 0x08, 0xff, 0x00, 0x00, // 9508 $2524 'SF090000' 0x18, 0x18, 0xff, 0x00, 0x00, // 9509 $2525 'uni2525' 0x08, 0x08, 0xff, 0x0f, 0x00, // 9510 $2526 'uni2526' 0x08, 0x08, 0xff, 0xf8, 0x00, // 9511 $2527 'uni2527' 0x08, 0x08, 0xff, 0xff, 0x00, // 9512 $2528 'uni2528' 0x18, 0x18, 0xff, 0x1f, 0x00, // 9513 $2529 'uni2529' 0x18, 0x18, 0xff, 0xf8, 0x00, // 9514 $252a 'uni252A' 0x18, 0x18, 0xff, 0xff, 0x00, // 9515 $252b 'uni252B' 0x08, 0x08, 0xf8, 0x08, 0x08, // 9516 $252c 'SF060000' 0x18, 0x18, 0xf8, 0x08, 0x08, // 9517 $252d 'uni252D' 0x08, 0x08, 0xf8, 0x18, 0x18, // 9518 $252e 'uni252E' 0x18, 0x18, 0xf8, 0x18, 0x18, // 9519 $252f 'uni252F' 0x08, 0x08, 0xf8, 0xf8, 0x08, // 9520 $2530 'uni2530' 0x18, 0x18, 0xf8, 0xf8, 0x08, // 9521 $2531 'uni2531' 0x08, 0x08, 0xf8, 0xf8, 0x18, // 9522 $2532 'uni2532' 0x18, 0x18, 0xf8, 0xf8, 0x18, // 9523 $2533 'uni2533' 0x08, 0x08, 0x0f, 0x08, 0x08, // 9524 $2534 'SF070000' 0x18, 0x18, 0x1f, 0x08, 0x08, // 9525 $2535 'uni2535' 0x08, 0x08, 0x1f, 0x18, 0x18, // 9526 $2536 'uni2536' 0x18, 0x18, 0x1f, 0x18, 0x18, // 9527 $2537 'uni2537' 0x08, 0x08, 0x0f, 0x0f, 0x08, // 9528 $2538 'uni2538' 0x18, 0x18, 0x1f, 0x1f, 0x08, // 9529 $2539 'uni2539' 0x08, 0x08, 0x1f, 0x1f, 0x18, // 9530 $253a 'uni253A' 0x18, 0x18, 0x1f, 0x1f, 0x18, // 9531 $253b 'uni253B' 0x08, 0x08, 0xff, 0x08, 0x08, // 9532 $253c 'SF050000' 0x18, 0x18, 0xff, 0x08, 0x08, // 9533 $253d 'uni253D' 0x08, 0x08, 0xff, 0x18, 0x18, // 9534 $253e 'uni253E' 0x18, 0x18, 0xff, 0x18, 0x18, // 9535 $253f 'uni253F' 0x08, 0x08, 0xff, 0x0f, 0x08, // 9536 $2540 'uni2540' 0x08, 0x08, 0xff, 0xf8, 0x08, // 9537 $2541 'uni2541' 0x08, 0x08, 0xff, 0xff, 0x08, // 9538 $2542 'uni2542' 0x18, 0x18, 0xff, 0x1f, 0x08, // 9539 $2543 'uni2543' 0x08, 0x08, 0xff, 0x1f, 0x18, // 9540 $2544 'uni2544' 0x18, 0x18, 0xff, 0xf8, 0x08, // 9541 $2545 'uni2545' 0x08, 0x08, 0xff, 0xf8, 0x18, // 9542 $2546 'uni2546' 0x18, 0x18, 0xff, 0x1f, 0x18, // 9543 $2547 'uni2547' 0x18, 0x18, 0xff, 0xf8, 0x18, // 9544 $2548 'uni2548' 0x18, 0x18, 0xff, 0xff, 0x08, // 9545 $2549 'uni2549' 0x08, 0x08, 0xff, 0xff, 0x18, // 9546 $254a 'uni254A' 0x18, 0x18, 0xff, 0xff, 0x18, // 9547 $254b 'uni254B' 0x08, 0x00, 0x08, 0x08, 0x00, // 9548 $254c 'uni254C' 0x18, 0x00, 0x18, 0x18, 0x00, // 9549 $254d 'uni254D' 0x00, 0x00, 0x77, 0x00, 0x00, // 9550 $254e 'uni254E' 0x00, 0x00, 0x77, 0x77, 0x00, // 9551 $254f 'uni254F' 0x14, 0x14, 0x14, 0x14, 0x14, // 9552 $2550 'SF430000' 0x00, 0xff, 0x00, 0xff, 0x00, // 9553 $2551 'SF240000' 0x00, 0x00, 0xfc, 0x14, 0x14, // 9554 $2552 'SF510000' 0x00, 0xf8, 0x08, 0xf8, 0x08, // 9555 $2553 'SF520000' 0x00, 0xfc, 0x04, 0xf4, 0x14, // 9556 $2554 'SF390000' 0x14, 0x14, 0xfc, 0x00, 0x00, // 9557 $2555 'SF220000' 0x08, 0xf8, 0x08, 0xf8, 0x00, // 9558 $2556 'SF210000' 0x14, 0xf4, 0x04, 0xfc, 0x00, // 9559 $2557 'SF250000' 0x00, 0x00, 0x1f, 0x14, 0x14, // 9560 $2558 'SF500000' 0x00, 0x0f, 0x08, 0x0f, 0x08, // 9561 $2559 'SF490000' 0x00, 0x1f, 0x10, 0x17, 0x14, // 9562 $255a 'SF380000' 0x14, 0x14, 0x1f, 0x00, 0x00, // 9563 $255b 'SF280000' 0x08, 0x0f, 0x08, 0x0f, 0x00, // 9564 $255c 'SF270000' 0x14, 0x17, 0x10, 0x1f, 0x00, // 9565 $255d 'SF260000' 0x00, 0x00, 0xff, 0x14, 0x14, // 9566 $255e 'SF360000' 0x00, 0xff, 0x00, 0xff, 0x08, // 9567 $255f 'SF370000' 0x00, 0xff, 0x00, 0xf7, 0x14, // 9568 $2560 'SF420000' 0x14, 0x14, 0xff, 0x00, 0x00, // 9569 $2561 'SF190000' 0x08, 0xff, 0x00, 0xff, 0x00, // 9570 $2562 'SF200000' 0x14, 0xf7, 0x00, 0xff, 0x00, // 9571 $2563 'SF230000' 0x14, 0x14, 0xf4, 0x14, 0x14, // 9572 $2564 'SF470000' 0x08, 0xf8, 0x08, 0xf8, 0x08, // 9573 $2565 'SF480000' 0x14, 0xf4, 0x04, 0xf4, 0x14, // 9574 $2566 'SF410000' 0x14, 0x14, 0x17, 0x14, 0x14, // 9575 $2567 'SF450000' 0x08, 0x0f, 0x08, 0x0f, 0x08, // 9576 $2568 'SF460000' 0x14, 0x17, 0x10, 0x17, 0x14, // 9577 $2569 'SF400000' 0x14, 0x14, 0xff, 0x14, 0x14, // 9578 $256a 'SF540000' 0x08, 0xff, 0x08, 0xff, 0x08, // 9579 $256b 'SF530000' 0x14, 0xf7, 0x00, 0xf7, 0x14, // 9580 $256c 'SF440000' 0x00, 0x00, 0xf0, 0x08, 0x08, // 9581 $256d 'uni256D' 0x08, 0x08, 0xf0, 0x00, 0x00, // 9582 $256e 'uni256E' 0x08, 0x08, 0x07, 0x00, 0x00, // 9583 $256f 'uni256F' 0x00, 0x00, 0x07, 0x08, 0x08, // 9584 $2570 'uni2570' 0x80, 0x60, 0x18, 0x06, 0x01, // 9585 $2571 'uni2571' 0x01, 0x06, 0x18, 0x60, 0x80, // 9586 $2572 'uni2572' 0x81, 0x66, 0x18, 0x66, 0x81, // 9587 $2573 'uni2573' 0x08, 0x08, 0x08, 0x00, 0x00, // 9588 $2574 'uni2574' 0x00, 0x00, 0x0f, 0x00, 0x00, // 9589 $2575 'uni2575' 0x00, 0x00, 0x08, 0x08, 0x08, // 9590 $2576 'uni2576' 0x00, 0x00, 0xf8, 0x00, 0x00, // 9591 $2577 'uni2577' 0x18, 0x18, 0x18, 0x00, 0x00, // 9592 $2578 'uni2578' 0x00, 0x00, 0x0f, 0x0f, 0x00, // 9593 $2579 'uni2579' 0x00, 0x00, 0x18, 0x18, 0x18, // 9594 $257a 'uni257A' 0x00, 0x00, 0xf8, 0xf8, 0x00, // 9595 $257b 'uni257B' 0x08, 0x08, 0x18, 0x18, 0x18, // 9596 $257c 'uni257C' 0x00, 0x00, 0xff, 0xf8, 0x00, // 9597 $257d 'uni257D' 0x18, 0x18, 0x18, 0x08, 0x08, // 9598 $257e 'uni257E' 0x00, 0x00, 0xff, 0x1f, 0x00, // 9599 $257f 'uni257F' 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, // 9600 $2580 'upblock' 0x80, 0x80, 0x80, 0x80, 0x80, // 9601 $2581 'uni2581' 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, // 9602 $2582 'uni2582' 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, // 9603 $2583 'uni2583' 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // 9604 $2584 'dnblock' 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, // 9605 $2585 'uni2585' 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, // 9606 $2586 'uni2586' 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, // 9607 $2587 'uni2587' 0xff, 0xff, 0xff, 0xff, 0xff, // 9608 $2588 'block' 0xff, 0xff, 0xff, 0xff, 0x00, // 9609 $2589 'uni2589' 0xff, 0xff, 0xff, 0xff, 0x00, // 9610 $258a 'uni258A' 0xff, 0xff, 0xff, 0x00, 0x00, // 9611 $258b 'uni258B' 0xff, 0xff, 0xff, 0x00, 0x00, // 9612 $258c 'lfblock' 0xff, 0xff, 0x00, 0x00, 0x00, // 9613 $258d 'uni258D' 0xff, 0xff, 0x00, 0x00, 0x00, // 9614 $258e 'uni258E' 0xff, 0x00, 0x00, 0x00, 0x00, // 9615 $258f 'uni258F' 0x00, 0x00, 0x00, 0xff, 0xff, // 9616 $2590 'rtblock' 0x11, 0x44, 0x11, 0x44, 0x11, // 9617 $2591 'ltshade' 0xaa, 0x55, 0xaa, 0x55, 0xaa, // 9618 $2592 'shade' 0xee, 0xbb, 0xee, 0xbb, 0xee, // 9619 $2593 'dkshade' 0x01, 0x01, 0x01, 0x01, 0x01, // 9620 $2594 'uni2594' 0x00, 0x00, 0x00, 0x00, 0xff, // 9621 $2595 'uni2595' 0xf0, 0xf0, 0xf0, 0x00, 0x00, // 9622 $2596 'uni2596' 0x00, 0x00, 0x00, 0xf0, 0xf0, // 9623 $2597 'uni2597' 0x0f, 0x0f, 0x0f, 0x00, 0x00, // 9624 $2598 'uni2598' 0xff, 0xff, 0xff, 0xf0, 0xf0, // 9625 $2599 'uni2599' 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, // 9626 $259a 'uni259A' 0xff, 0xff, 0xff, 0x0f, 0x0f, // 9627 $259b 'uni259B' 0x0f, 0x0f, 0x0f, 0xff, 0xff, // 9628 $259c 'uni259C' 0x00, 0x00, 0x00, 0x0f, 0x0f, // 9629 $259d 'uni259D' 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, // 9630 $259e 'uni259E' 0xf0, 0xf0, 0xf0, 0xff, 0xff, // 9631 $259f 'uni259F' 0x78, 0x78, 0x78, 0x78, 0x00, // 9632 $25a0 'filledbox' 0x78, 0x48, 0x48, 0x78, 0x00, // 9633 $25a1 'H22073' 0x30, 0x48, 0x48, 0x30, 0x00, // 9634 $25a2 'uni25A2' 0x78, 0x58, 0x68, 0x78, 0x00, // 9639 $25a7 'uni25A7' 0x78, 0x68, 0x58, 0x78, 0x00, // 9640 $25a8 'uni25A8' 0x00, 0x38, 0x38, 0x38, 0x00, // 9642 $25aa 'H18543' 0x00, 0x38, 0x28, 0x38, 0x00, // 9643 $25ab 'H18551' 0x38, 0x38, 0x38, 0x38, 0x00, // 9644 $25ac 'filledrect' 0x38, 0x28, 0x28, 0x38, 0x00, // 9645 $25ad 'uni25AD' 0x00, 0x7e, 0x7e, 0x7e, 0x00, // 9646 $25ae 'uni25AE' 0x00, 0x7e, 0x42, 0x7e, 0x00, // 9647 $25af 'uni25AF' 0x20, 0x30, 0x38, 0x18, 0x08, // 9648 $25b0 'uni25B0' 0x20, 0x30, 0x28, 0x18, 0x08, // 9649 $25b1 'uni25B1' 0x60, 0x78, 0x7e, 0x78, 0x60, // 9650 $25b2 'triagup' 0x60, 0x58, 0x46, 0x58, 0x60, // 9651 $25b3 'uni25B3' 0x00, 0x30, 0x3c, 0x30, 0x00, // 9652 $25b4 'uni25B4' 0x00, 0x30, 0x2c, 0x30, 0x00, // 9653 $25b5 'uni25B5' 0x00, 0x7e, 0x3c, 0x18, 0x00, // 9654 $25b6 'uni25B6' 0x00, 0x7e, 0x24, 0x18, 0x00, // 9655 $25b7 'uni25B7' 0x00, 0x7c, 0x38, 0x10, 0x00, // 9656 $25b8 'uni25B8' 0x00, 0x7c, 0x28, 0x10, 0x00, // 9657 $25b9 'uni25B9' 0x7c, 0x38, 0x38, 0x10, 0x10, // 9658 $25ba 'triagrt' 0x7c, 0x28, 0x28, 0x10, 0x10, // 9659 $25bb 'uni25BB' 0x06, 0x1e, 0x7e, 0x1e, 0x06, // 9660 $25bc 'triagdn' 0x06, 0x1a, 0x62, 0x1a, 0x06, // 9661 $25bd 'uni25BD' 0x00, 0x0c, 0x3c, 0x0c, 0x00, // 9662 $25be 'uni25BE' 0x00, 0x0c, 0x34, 0x0c, 0x00, // 9663 $25bf 'uni25BF' 0x00, 0x18, 0x3c, 0x7e, 0x00, // 9664 $25c0 'uni25C0' 0x00, 0x18, 0x24, 0x7e, 0x00, // 9665 $25c1 'uni25C1' 0x00, 0x10, 0x38, 0x7c, 0x00, // 9666 $25c2 'uni25C2' 0x00, 0x10, 0x28, 0x7c, 0x00, // 9667 $25c3 'uni25C3' 0x10, 0x10, 0x38, 0x38, 0x7c, // 9668 $25c4 'triaglf' 0x10, 0x10, 0x28, 0x28, 0x7c, // 9669 $25c5 'uni25C5' 0x10, 0x38, 0x7c, 0x38, 0x10, // 9670 $25c6 'uni25C6' 0x10, 0x28, 0x44, 0x28, 0x10, // 9671 $25c7 'uni25C7' 0x08, 0x36, 0x41, 0x36, 0x08, // 9674 $25ca 'lozenge' 0x38, 0x44, 0x44, 0x44, 0x38, // 9675 $25cb 'circle' 0x10, 0x44, 0x00, 0x44, 0x10, // 9676 $25cc 'uni25CC' 0x38, 0x44, 0x7c, 0x44, 0x38, // 9677 $25cd 'uni25CD' 0x38, 0x54, 0x6c, 0x54, 0x38, // 9678 $25ce 'uni25CE' 0x38, 0x7c, 0x7c, 0x7c, 0x38, // 9679 $25cf 'H18533' 0x38, 0x7c, 0x7c, 0x44, 0x38, // 9680 $25d0 'uni25D0' 0x38, 0x44, 0x7c, 0x7c, 0x38, // 9681 $25d1 'uni25D1' 0x38, 0x74, 0x74, 0x74, 0x38, // 9682 $25d2 'uni25D2' 0x38, 0x5c, 0x5c, 0x5c, 0x38, // 9683 $25d3 'uni25D3' 0x38, 0x44, 0x5c, 0x5c, 0x38, // 9684 $25d4 'uni25D4' 0x38, 0x64, 0x64, 0x7c, 0x38, // 9685 $25d5 'uni25D5' 0xff, 0xe7, 0xc3, 0xe7, 0xff, // 9688 $25d8 'invbullet' 0xe7, 0xdb, 0xbd, 0xdb, 0xe7, // 9689 $25d9 'invcircle' 0x07, 0x0b, 0x0d, 0x0b, 0x07, // 9690 $25da 'uni25DA' 0xe0, 0xd0, 0xb0, 0xd0, 0xe0, // 9691 $25db 'uni25DB' 0x40, 0x60, 0x70, 0x78, 0x00, // 9698 $25e2 'uni25E2' 0x78, 0x70, 0x60, 0x40, 0x00, // 9699 $25e3 'uni25E3' 0x78, 0x38, 0x18, 0x08, 0x00, // 9700 $25e4 'uni25E4' 0x08, 0x18, 0x38, 0x78, 0x00, // 9701 $25e5 'uni25E5' 0x30, 0x48, 0x48, 0x30, 0x00, // 9702 $25e6 'openbullet' 0x78, 0x78, 0x48, 0x78, 0x00, // 9703 $25e7 'uni25E7' 0x78, 0x48, 0x78, 0x78, 0x00, // 9704 $25e8 'uni25E8' 0x78, 0x78, 0x58, 0x78, 0x00, // 9705 $25e9 'uni25E9' 0x78, 0x68, 0x78, 0x78, 0x00, // 9706 $25ea 'uni25EA' 0x08, 0x0a, 0xfd, 0x0a, 0x08, // 9765 $2625 'uni2625' 0x08, 0x4a, 0xff, 0x2a, 0x08, // 9766 $2626 'uni2626' 0x50, 0x20, 0x7f, 0x25, 0x52, // 9767 $2627 'uni2627' 0x08, 0x0a, 0xff, 0x0a, 0x08, // 9768 $2628 'uni2628' 0x1c, 0x49, 0x7f, 0x49, 0x1c, // 9769 $2629 'uni2629' 0x00, 0x54, 0x54, 0x54, 0x00, // 9776 $2630 'uni2630' 0x00, 0x54, 0x50, 0x54, 0x00, // 9777 $2631 'uni2631' 0x00, 0x54, 0x44, 0x54, 0x00, // 9778 $2632 'uni2632' 0x00, 0x54, 0x40, 0x54, 0x00, // 9779 $2633 'uni2633' 0x00, 0x54, 0x14, 0x54, 0x00, // 9780 $2634 'uni2634' 0x00, 0x54, 0x10, 0x54, 0x00, // 9781 $2635 'uni2635' 0x00, 0x54, 0x04, 0x54, 0x00, // 9782 $2636 'uni2636' 0x00, 0x54, 0x00, 0x54, 0x00, // 9783 $2637 'uni2637' 0x44, 0x38, 0xee, 0x38, 0x44, // 9784 $2638 'uni2638' 0x7c, 0x8a, 0xa2, 0x8a, 0x7c, // 9786 $263a 'smileface' 0x3c, 0x6a, 0x5e, 0x6a, 0x3c, // 9787 $263b 'invsmileface' 0x44, 0x10, 0xaa, 0x10, 0x44, // 9788 $263c 'sun' 0x24, 0x66, 0x5a, 0x42, 0x3c, // 9789 $263d 'uni263D' 0x3c, 0x42, 0x5a, 0x66, 0x24, // 9790 $263e 'uni263E' 0x0c, 0x52, 0xf2, 0x52, 0x0c, // 9792 $2640 'female' 0x60, 0x94, 0x9e, 0x94, 0x60, // 9793 $2641 'uni2641' 0x60, 0x90, 0x94, 0x6c, 0x1c, // 9794 $2642 'male' 0x10, 0x58, 0x7e, 0x58, 0x10, // 9824 $2660 'spade' 0x0c, 0x12, 0x64, 0x12, 0x0c, // 9825 $2661 'uni2661' 0x08, 0x14, 0x22, 0x14, 0x08, // 9826 $2662 'uni2662' 0x38, 0x54, 0x7e, 0x54, 0x38, // 9827 $2663 'club' 0x10, 0x5c, 0x72, 0x5c, 0x10, // 9828 $2664 'uni2664' 0x0c, 0x1e, 0x7c, 0x1e, 0x0c, // 9829 $2665 'heart' 0x08, 0x1c, 0x3e, 0x1c, 0x08, // 9830 $2666 'diamond' 0x08, 0x54, 0x7e, 0x54, 0x08, // 9831 $2667 'uni2667' 0x00, 0x20, 0x70, 0x7e, 0x00, // 9833 $2669 'uni2669' 0x20, 0x70, 0x7e, 0x02, 0x04, // 9834 $266a 'musicalnote' 0x18, 0x1f, 0x62, 0x7c, 0x00, // 9835 $266b 'musicalnotedbl' 0x18, 0x1f, 0x6a, 0x7c, 0x00, // 9836 $266c 'uni266C' 0x7e, 0x48, 0x24, 0x18, 0x00, // 9837 $266d 'uni266D' 0x3f, 0x28, 0x14, 0xfc, 0x00, // 9838 $266e 'uni266E' 0x28, 0x7e, 0x14, 0x3f, 0x12, // 9839 $266f 'uni266F' 0x00, 0x18, 0x66, 0x00, 0x00, // 10216 $27e8 'uni27E8' 0x00, 0x66, 0x18, 0x00, 0x00, // 10217 $27e9 'uni27E9' 0x00, 0x00, 0x00, 0x00, 0x00, // 10240 $2800 'uni2800' 0x00, 0x02, 0x00, 0x00, 0x00, // 10241 $2801 'uni2801' 0x00, 0x08, 0x00, 0x00, 0x00, // 10242 $2802 'uni2802' 0x00, 0x0a, 0x00, 0x00, 0x00, // 10243 $2803 'uni2803' 0x00, 0x20, 0x00, 0x00, 0x00, // 10244 $2804 'uni2804' 0x00, 0x22, 0x00, 0x00, 0x00, // 10245 $2805 'uni2805' 0x00, 0x28, 0x00, 0x00, 0x00, // 10246 $2806 'uni2806' 0x00, 0x2a, 0x00, 0x00, 0x00, // 10247 $2807 'uni2807' 0x00, 0x00, 0x00, 0x02, 0x00, // 10248 $2808 'uni2808' 0x00, 0x02, 0x00, 0x02, 0x00, // 10249 $2809 'uni2809' 0x00, 0x08, 0x00, 0x02, 0x00, // 10250 $280a 'uni280A' 0x00, 0x0a, 0x00, 0x02, 0x00, // 10251 $280b 'uni280B' 0x00, 0x20, 0x00, 0x02, 0x00, // 10252 $280c 'uni280C' 0x00, 0x22, 0x00, 0x02, 0x00, // 10253 $280d 'uni280D' 0x00, 0x28, 0x00, 0x02, 0x00, // 10254 $280e 'uni280E' 0x00, 0x2a, 0x00, 0x02, 0x00, // 10255 $280f 'uni280F' 0x00, 0x00, 0x00, 0x08, 0x00, // 10256 $2810 'uni2810' 0x00, 0x02, 0x00, 0x08, 0x00, // 10257 $2811 'uni2811' 0x00, 0x08, 0x00, 0x08, 0x00, // 10258 $2812 'uni2812' 0x00, 0x0a, 0x00, 0x08, 0x00, // 10259 $2813 'uni2813' 0x00, 0x20, 0x00, 0x08, 0x00, // 10260 $2814 'uni2814' 0x00, 0x22, 0x00, 0x08, 0x00, // 10261 $2815 'uni2815' 0x00, 0x28, 0x00, 0x08, 0x00, // 10262 $2816 'uni2816' 0x00, 0x2a, 0x00, 0x08, 0x00, // 10263 $2817 'uni2817' 0x00, 0x00, 0x00, 0x0a, 0x00, // 10264 $2818 'uni2818' 0x00, 0x02, 0x00, 0x0a, 0x00, // 10265 $2819 'uni2819' 0x00, 0x08, 0x00, 0x0a, 0x00, // 10266 $281a 'uni281A' 0x00, 0x0a, 0x00, 0x0a, 0x00, // 10267 $281b 'uni281B' 0x00, 0x20, 0x00, 0x0a, 0x00, // 10268 $281c 'uni281C' 0x00, 0x22, 0x00, 0x0a, 0x00, // 10269 $281d 'uni281D' 0x00, 0x28, 0x00, 0x0a, 0x00, // 10270 $281e 'uni281E' 0x00, 0x2a, 0x00, 0x0a, 0x00, // 10271 $281f 'uni281F' 0x00, 0x00, 0x00, 0x20, 0x00, // 10272 $2820 'uni2820' 0x00, 0x02, 0x00, 0x20, 0x00, // 10273 $2821 'uni2821' 0x00, 0x08, 0x00, 0x20, 0x00, // 10274 $2822 'uni2822' 0x00, 0x0a, 0x00, 0x20, 0x00, // 10275 $2823 'uni2823' 0x00, 0x20, 0x00, 0x20, 0x00, // 10276 $2824 'uni2824' 0x00, 0x22, 0x00, 0x20, 0x00, // 10277 $2825 'uni2825' 0x00, 0x28, 0x00, 0x20, 0x00, // 10278 $2826 'uni2826' 0x00, 0x2a, 0x00, 0x20, 0x00, // 10279 $2827 'uni2827' 0x00, 0x00, 0x00, 0x22, 0x00, // 10280 $2828 'uni2828' 0x00, 0x02, 0x00, 0x22, 0x00, // 10281 $2829 'uni2829' 0x00, 0x08, 0x00, 0x22, 0x00, // 10282 $282a 'uni282A' 0x00, 0x0a, 0x00, 0x22, 0x00, // 10283 $282b 'uni282B' 0x00, 0x20, 0x00, 0x22, 0x00, // 10284 $282c 'uni282C' 0x00, 0x22, 0x00, 0x22, 0x00, // 10285 $282d 'uni282D' 0x00, 0x28, 0x00, 0x22, 0x00, // 10286 $282e 'uni282E' 0x00, 0x2a, 0x00, 0x22, 0x00, // 10287 $282f 'uni282F' 0x00, 0x00, 0x00, 0x28, 0x00, // 10288 $2830 'uni2830' 0x00, 0x02, 0x00, 0x28, 0x00, // 10289 $2831 'uni2831' 0x00, 0x08, 0x00, 0x28, 0x00, // 10290 $2832 'uni2832' 0x00, 0x0a, 0x00, 0x28, 0x00, // 10291 $2833 'uni2833' 0x00, 0x20, 0x00, 0x28, 0x00, // 10292 $2834 'uni2834' 0x00, 0x22, 0x00, 0x28, 0x00, // 10293 $2835 'uni2835' 0x00, 0x28, 0x00, 0x28, 0x00, // 10294 $2836 'uni2836' 0x00, 0x2a, 0x00, 0x28, 0x00, // 10295 $2837 'uni2837' 0x00, 0x00, 0x00, 0x2a, 0x00, // 10296 $2838 'uni2838' 0x00, 0x02, 0x00, 0x2a, 0x00, // 10297 $2839 'uni2839' 0x00, 0x08, 0x00, 0x2a, 0x00, // 10298 $283a 'uni283A' 0x00, 0x0a, 0x00, 0x2a, 0x00, // 10299 $283b 'uni283B' 0x00, 0x20, 0x00, 0x2a, 0x00, // 10300 $283c 'uni283C' 0x00, 0x22, 0x00, 0x2a, 0x00, // 10301 $283d 'uni283D' 0x00, 0x28, 0x00, 0x2a, 0x00, // 10302 $283e 'uni283E' 0x00, 0x2a, 0x00, 0x2a, 0x00, // 10303 $283f 'uni283F' 0x00, 0x80, 0x00, 0x00, 0x00, // 10304 $2840 'uni2840' 0x00, 0x82, 0x00, 0x00, 0x00, // 10305 $2841 'uni2841' 0x00, 0x88, 0x00, 0x00, 0x00, // 10306 $2842 'uni2842' 0x00, 0x8a, 0x00, 0x00, 0x00, // 10307 $2843 'uni2843' 0x00, 0xa0, 0x00, 0x00, 0x00, // 10308 $2844 'uni2844' 0x00, 0xa2, 0x00, 0x00, 0x00, // 10309 $2845 'uni2845' 0x00, 0xa8, 0x00, 0x00, 0x00, // 10310 $2846 'uni2846' 0x00, 0xaa, 0x00, 0x00, 0x00, // 10311 $2847 'uni2847' 0x00, 0x80, 0x00, 0x02, 0x00, // 10312 $2848 'uni2848' 0x00, 0x82, 0x00, 0x02, 0x00, // 10313 $2849 'uni2849' 0x00, 0x88, 0x00, 0x02, 0x00, // 10314 $284a 'uni284A' 0x00, 0x8a, 0x00, 0x02, 0x00, // 10315 $284b 'uni284B' 0x00, 0xa0, 0x00, 0x02, 0x00, // 10316 $284c 'uni284C' 0x00, 0xa2, 0x00, 0x02, 0x00, // 10317 $284d 'uni284D' 0x00, 0xa8, 0x00, 0x02, 0x00, // 10318 $284e 'uni284E' 0x00, 0xaa, 0x00, 0x02, 0x00, // 10319 $284f 'uni284F' 0x00, 0x80, 0x00, 0x08, 0x00, // 10320 $2850 'uni2850' 0x00, 0x82, 0x00, 0x08, 0x00, // 10321 $2851 'uni2851' 0x00, 0x88, 0x00, 0x08, 0x00, // 10322 $2852 'uni2852' 0x00, 0x8a, 0x00, 0x08, 0x00, // 10323 $2853 'uni2853' 0x00, 0xa0, 0x00, 0x08, 0x00, // 10324 $2854 'uni2854' 0x00, 0xa2, 0x00, 0x08, 0x00, // 10325 $2855 'uni2855' 0x00, 0xa8, 0x00, 0x08, 0x00, // 10326 $2856 'uni2856' 0x00, 0xaa, 0x00, 0x08, 0x00, // 10327 $2857 'uni2857' 0x00, 0x80, 0x00, 0x0a, 0x00, // 10328 $2858 'uni2858' 0x00, 0x82, 0x00, 0x0a, 0x00, // 10329 $2859 'uni2859' 0x00, 0x88, 0x00, 0x0a, 0x00, // 10330 $285a 'uni285A' 0x00, 0x8a, 0x00, 0x0a, 0x00, // 10331 $285b 'uni285B' 0x00, 0xa0, 0x00, 0x0a, 0x00, // 10332 $285c 'uni285C' 0x00, 0xa2, 0x00, 0x0a, 0x00, // 10333 $285d 'uni285D' 0x00, 0xa8, 0x00, 0x0a, 0x00, // 10334 $285e 'uni285E' 0x00, 0xaa, 0x00, 0x0a, 0x00, // 10335 $285f 'uni285F' 0x00, 0x80, 0x00, 0x20, 0x00, // 10336 $2860 'uni2860' 0x00, 0x82, 0x00, 0x20, 0x00, // 10337 $2861 'uni2861' 0x00, 0x88, 0x00, 0x20, 0x00, // 10338 $2862 'uni2862' 0x00, 0x8a, 0x00, 0x20, 0x00, // 10339 $2863 'uni2863' 0x00, 0xa0, 0x00, 0x20, 0x00, // 10340 $2864 'uni2864' 0x00, 0xa2, 0x00, 0x20, 0x00, // 10341 $2865 'uni2865' 0x00, 0xa8, 0x00, 0x20, 0x00, // 10342 $2866 'uni2866' 0x00, 0xaa, 0x00, 0x20, 0x00, // 10343 $2867 'uni2867' 0x00, 0x80, 0x00, 0x22, 0x00, // 10344 $2868 'uni2868' 0x00, 0x82, 0x00, 0x22, 0x00, // 10345 $2869 'uni2869' 0x00, 0x88, 0x00, 0x22, 0x00, // 10346 $286a 'uni286A' 0x00, 0x8a, 0x00, 0x22, 0x00, // 10347 $286b 'uni286B' 0x00, 0xa0, 0x00, 0x22, 0x00, // 10348 $286c 'uni286C' 0x00, 0xa2, 0x00, 0x22, 0x00, // 10349 $286d 'uni286D' 0x00, 0xa8, 0x00, 0x22, 0x00, // 10350 $286e 'uni286E' 0x00, 0xaa, 0x00, 0x22, 0x00, // 10351 $286f 'uni286F' 0x00, 0x80, 0x00, 0x28, 0x00, // 10352 $2870 'uni2870' 0x00, 0x82, 0x00, 0x28, 0x00, // 10353 $2871 'uni2871' 0x00, 0x88, 0x00, 0x28, 0x00, // 10354 $2872 'uni2872' 0x00, 0x8a, 0x00, 0x28, 0x00, // 10355 $2873 'uni2873' 0x00, 0xa0, 0x00, 0x28, 0x00, // 10356 $2874 'uni2874' 0x00, 0xa2, 0x00, 0x28, 0x00, // 10357 $2875 'uni2875' 0x00, 0xa8, 0x00, 0x28, 0x00, // 10358 $2876 'uni2876' 0x00, 0xaa, 0x00, 0x28, 0x00, // 10359 $2877 'uni2877' 0x00, 0x80, 0x00, 0x2a, 0x00, // 10360 $2878 'uni2878' 0x00, 0x82, 0x00, 0x2a, 0x00, // 10361 $2879 'uni2879' 0x00, 0x88, 0x00, 0x2a, 0x00, // 10362 $287a 'uni287A' 0x00, 0x8a, 0x00, 0x2a, 0x00, // 10363 $287b 'uni287B' 0x00, 0xa0, 0x00, 0x2a, 0x00, // 10364 $287c 'uni287C' 0x00, 0xa2, 0x00, 0x2a, 0x00, // 10365 $287d 'uni287D' 0x00, 0xa8, 0x00, 0x2a, 0x00, // 10366 $287e 'uni287E' 0x00, 0xaa, 0x00, 0x2a, 0x00, // 10367 $287f 'uni287F' 0x00, 0x00, 0x00, 0x80, 0x00, // 10368 $2880 'uni2880' 0x00, 0x02, 0x00, 0x80, 0x00, // 10369 $2881 'uni2881' 0x00, 0x08, 0x00, 0x80, 0x00, // 10370 $2882 'uni2882' 0x00, 0x0a, 0x00, 0x80, 0x00, // 10371 $2883 'uni2883' 0x00, 0x20, 0x00, 0x80, 0x00, // 10372 $2884 'uni2884' 0x00, 0x22, 0x00, 0x80, 0x00, // 10373 $2885 'uni2885' 0x00, 0x28, 0x00, 0x80, 0x00, // 10374 $2886 'uni2886' 0x00, 0x2a, 0x00, 0x80, 0x00, // 10375 $2887 'uni2887' 0x00, 0x00, 0x00, 0x82, 0x00, // 10376 $2888 'uni2888' 0x00, 0x02, 0x00, 0x82, 0x00, // 10377 $2889 'uni2889' 0x00, 0x08, 0x00, 0x82, 0x00, // 10378 $288a 'uni288A' 0x00, 0x0a, 0x00, 0x82, 0x00, // 10379 $288b 'uni288B' 0x00, 0x20, 0x00, 0x82, 0x00, // 10380 $288c 'uni288C' 0x00, 0x22, 0x00, 0x82, 0x00, // 10381 $288d 'uni288D' 0x00, 0x28, 0x00, 0x82, 0x00, // 10382 $288e 'uni288E' 0x00, 0x2a, 0x00, 0x82, 0x00, // 10383 $288f 'uni288F' 0x00, 0x00, 0x00, 0x88, 0x00, // 10384 $2890 'uni2890' 0x00, 0x02, 0x00, 0x88, 0x00, // 10385 $2891 'uni2891' 0x00, 0x08, 0x00, 0x88, 0x00, // 10386 $2892 'uni2892' 0x00, 0x0a, 0x00, 0x88, 0x00, // 10387 $2893 'uni2893' 0x00, 0x20, 0x00, 0x88, 0x00, // 10388 $2894 'uni2894' 0x00, 0x22, 0x00, 0x88, 0x00, // 10389 $2895 'uni2895' 0x00, 0x28, 0x00, 0x88, 0x00, // 10390 $2896 'uni2896' 0x00, 0x2a, 0x00, 0x88, 0x00, // 10391 $2897 'uni2897' 0x00, 0x00, 0x00, 0x8a, 0x00, // 10392 $2898 'uni2898' 0x00, 0x02, 0x00, 0x8a, 0x00, // 10393 $2899 'uni2899' 0x00, 0x08, 0x00, 0x8a, 0x00, // 10394 $289a 'uni289A' 0x00, 0x0a, 0x00, 0x8a, 0x00, // 10395 $289b 'uni289B' 0x00, 0x20, 0x00, 0x8a, 0x00, // 10396 $289c 'uni289C' 0x00, 0x22, 0x00, 0x8a, 0x00, // 10397 $289d 'uni289D' 0x00, 0x28, 0x00, 0x8a, 0x00, // 10398 $289e 'uni289E' 0x00, 0x2a, 0x00, 0x8a, 0x00, // 10399 $289f 'uni289F' 0x00, 0x00, 0x00, 0xa0, 0x00, // 10400 $28a0 'uni28A0' 0x00, 0x02, 0x00, 0xa0, 0x00, // 10401 $28a1 'uni28A1' 0x00, 0x08, 0x00, 0xa0, 0x00, // 10402 $28a2 'uni28A2' 0x00, 0x0a, 0x00, 0xa0, 0x00, // 10403 $28a3 'uni28A3' 0x00, 0x20, 0x00, 0xa0, 0x00, // 10404 $28a4 'uni28A4' 0x00, 0x22, 0x00, 0xa0, 0x00, // 10405 $28a5 'uni28A5' 0x00, 0x28, 0x00, 0xa0, 0x00, // 10406 $28a6 'uni28A6' 0x00, 0x2a, 0x00, 0xa0, 0x00, // 10407 $28a7 'uni28A7' 0x00, 0x00, 0x00, 0xa2, 0x00, // 10408 $28a8 'uni28A8' 0x00, 0x02, 0x00, 0xa2, 0x00, // 10409 $28a9 'uni28A9' 0x00, 0x08, 0x00, 0xa2, 0x00, // 10410 $28aa 'uni28AA' 0x00, 0x0a, 0x00, 0xa2, 0x00, // 10411 $28ab 'uni28AB' 0x00, 0x20, 0x00, 0xa2, 0x00, // 10412 $28ac 'uni28AC' 0x00, 0x22, 0x00, 0xa2, 0x00, // 10413 $28ad 'uni28AD' 0x00, 0x28, 0x00, 0xa2, 0x00, // 10414 $28ae 'uni28AE' 0x00, 0x2a, 0x00, 0xa2, 0x00, // 10415 $28af 'uni28AF' 0x00, 0x00, 0x00, 0xa8, 0x00, // 10416 $28b0 'uni28B0' 0x00, 0x02, 0x00, 0xa8, 0x00, // 10417 $28b1 'uni28B1' 0x00, 0x08, 0x00, 0xa8, 0x00, // 10418 $28b2 'uni28B2' 0x00, 0x0a, 0x00, 0xa8, 0x00, // 10419 $28b3 'uni28B3' 0x00, 0x20, 0x00, 0xa8, 0x00, // 10420 $28b4 'uni28B4' 0x00, 0x22, 0x00, 0xa8, 0x00, // 10421 $28b5 'uni28B5' 0x00, 0x28, 0x00, 0xa8, 0x00, // 10422 $28b6 'uni28B6' 0x00, 0x2a, 0x00, 0xa8, 0x00, // 10423 $28b7 'uni28B7' 0x00, 0x00, 0x00, 0xaa, 0x00, // 10424 $28b8 'uni28B8' 0x00, 0x02, 0x00, 0xaa, 0x00, // 10425 $28b9 'uni28B9' 0x00, 0x08, 0x00, 0xaa, 0x00, // 10426 $28ba 'uni28BA' 0x00, 0x0a, 0x00, 0xaa, 0x00, // 10427 $28bb 'uni28BB' 0x00, 0x20, 0x00, 0xaa, 0x00, // 10428 $28bc 'uni28BC' 0x00, 0x22, 0x00, 0xaa, 0x00, // 10429 $28bd 'uni28BD' 0x00, 0x28, 0x00, 0xaa, 0x00, // 10430 $28be 'uni28BE' 0x00, 0x2a, 0x00, 0xaa, 0x00, // 10431 $28bf 'uni28BF' 0x00, 0x80, 0x00, 0x80, 0x00, // 10432 $28c0 'uni28C0' 0x00, 0x82, 0x00, 0x80, 0x00, // 10433 $28c1 'uni28C1' 0x00, 0x88, 0x00, 0x80, 0x00, // 10434 $28c2 'uni28C2' 0x00, 0x8a, 0x00, 0x80, 0x00, // 10435 $28c3 'uni28C3' 0x00, 0xa0, 0x00, 0x80, 0x00, // 10436 $28c4 'uni28C4' 0x00, 0xa2, 0x00, 0x80, 0x00, // 10437 $28c5 'uni28C5' 0x00, 0xa8, 0x00, 0x80, 0x00, // 10438 $28c6 'uni28C6' 0x00, 0xaa, 0x00, 0x80, 0x00, // 10439 $28c7 'uni28C7' 0x00, 0x80, 0x00, 0x82, 0x00, // 10440 $28c8 'uni28C8' 0x00, 0x82, 0x00, 0x82, 0x00, // 10441 $28c9 'uni28C9' 0x00, 0x88, 0x00, 0x82, 0x00, // 10442 $28ca 'uni28CA' 0x00, 0x8a, 0x00, 0x82, 0x00, // 10443 $28cb 'uni28CB' 0x00, 0xa0, 0x00, 0x82, 0x00, // 10444 $28cc 'uni28CC' 0x00, 0xa2, 0x00, 0x82, 0x00, // 10445 $28cd 'uni28CD' 0x00, 0xa8, 0x00, 0x82, 0x00, // 10446 $28ce 'uni28CE' 0x00, 0xaa, 0x00, 0x82, 0x00, // 10447 $28cf 'uni28CF' 0x00, 0x80, 0x00, 0x88, 0x00, // 10448 $28d0 'uni28D0' 0x00, 0x82, 0x00, 0x88, 0x00, // 10449 $28d1 'uni28D1' 0x00, 0x88, 0x00, 0x88, 0x00, // 10450 $28d2 'uni28D2' 0x00, 0x8a, 0x00, 0x88, 0x00, // 10451 $28d3 'uni28D3' 0x00, 0xa0, 0x00, 0x88, 0x00, // 10452 $28d4 'uni28D4' 0x00, 0xa2, 0x00, 0x88, 0x00, // 10453 $28d5 'uni28D5' 0x00, 0xa8, 0x00, 0x88, 0x00, // 10454 $28d6 'uni28D6' 0x00, 0xaa, 0x00, 0x88, 0x00, // 10455 $28d7 'uni28D7' 0x00, 0x80, 0x00, 0x8a, 0x00, // 10456 $28d8 'uni28D8' 0x00, 0x82, 0x00, 0x8a, 0x00, // 10457 $28d9 'uni28D9' 0x00, 0x88, 0x00, 0x8a, 0x00, // 10458 $28da 'uni28DA' 0x00, 0x8a, 0x00, 0x8a, 0x00, // 10459 $28db 'uni28DB' 0x00, 0xa0, 0x00, 0x8a, 0x00, // 10460 $28dc 'uni28DC' 0x00, 0xa2, 0x00, 0x8a, 0x00, // 10461 $28dd 'uni28DD' 0x00, 0xa8, 0x00, 0x8a, 0x00, // 10462 $28de 'uni28DE' 0x00, 0xaa, 0x00, 0x8a, 0x00, // 10463 $28df 'uni28DF' 0x00, 0x80, 0x00, 0xa0, 0x00, // 10464 $28e0 'uni28E0' 0x00, 0x82, 0x00, 0xa0, 0x00, // 10465 $28e1 'uni28E1' 0x00, 0x88, 0x00, 0xa0, 0x00, // 10466 $28e2 'uni28E2' 0x00, 0x8a, 0x00, 0xa0, 0x00, // 10467 $28e3 'uni28E3' 0x00, 0xa0, 0x00, 0xa0, 0x00, // 10468 $28e4 'uni28E4' 0x00, 0xa2, 0x00, 0xa0, 0x00, // 10469 $28e5 'uni28E5' 0x00, 0xa8, 0x00, 0xa0, 0x00, // 10470 $28e6 'uni28E6' 0x00, 0xaa, 0x00, 0xa0, 0x00, // 10471 $28e7 'uni28E7' 0x00, 0x80, 0x00, 0xa2, 0x00, // 10472 $28e8 'uni28E8' 0x00, 0x82, 0x00, 0xa2, 0x00, // 10473 $28e9 'uni28E9' 0x00, 0x88, 0x00, 0xa2, 0x00, // 10474 $28ea 'uni28EA' 0x00, 0x8a, 0x00, 0xa2, 0x00, // 10475 $28eb 'uni28EB' 0x00, 0xa0, 0x00, 0xa2, 0x00, // 10476 $28ec 'uni28EC' 0x00, 0xa2, 0x00, 0xa2, 0x00, // 10477 $28ed 'uni28ED' 0x00, 0xa8, 0x00, 0xa2, 0x00, // 10478 $28ee 'uni28EE' 0x00, 0xaa, 0x00, 0xa2, 0x00, // 10479 $28ef 'uni28EF' 0x00, 0x80, 0x00, 0xa8, 0x00, // 10480 $28f0 'uni28F0' 0x00, 0x82, 0x00, 0xa8, 0x00, // 10481 $28f1 'uni28F1' 0x00, 0x88, 0x00, 0xa8, 0x00, // 10482 $28f2 'uni28F2' 0x00, 0x8a, 0x00, 0xa8, 0x00, // 10483 $28f3 'uni28F3' 0x00, 0xa0, 0x00, 0xa8, 0x00, // 10484 $28f4 'uni28F4' 0x00, 0xa2, 0x00, 0xa8, 0x00, // 10485 $28f5 'uni28F5' 0x00, 0xa8, 0x00, 0xa8, 0x00, // 10486 $28f6 'uni28F6' 0x00, 0xaa, 0x00, 0xa8, 0x00, // 10487 $28f7 'uni28F7' 0x00, 0x80, 0x00, 0xaa, 0x00, // 10488 $28f8 'uni28F8' 0x00, 0x82, 0x00, 0xaa, 0x00, // 10489 $28f9 'uni28F9' 0x00, 0x88, 0x00, 0xaa, 0x00, // 10490 $28fa 'uni28FA' 0x00, 0x8a, 0x00, 0xaa, 0x00, // 10491 $28fb 'uni28FB' 0x00, 0xa0, 0x00, 0xaa, 0x00, // 10492 $28fc 'uni28FC' 0x00, 0xa2, 0x00, 0xaa, 0x00, // 10493 $28fd 'uni28FD' 0x00, 0xa8, 0x00, 0xaa, 0x00, // 10494 $28fe 'uni28FE' 0x00, 0xaa, 0x00, 0xaa, 0x00, // 10495 $28ff 'uni28FF' 0x7c, 0x12, 0x7c, 0x12, 0x04, // 64256 $fb00 'ff' 0x10, 0x7c, 0x12, 0x74, 0x00, // 64257 $fb01 'fi' 0x10, 0x7c, 0x12, 0x7e, 0x00 // 64258 $fb02 'fl' }; static struct font_info font1 = { 5, 7, 1, 0, (uint8_t *)font1_data }; static struct font_info font2 = { 6, 8, 0, 32, (uint8_t *)font2_data }; static struct font_info font3 = { 5, 8, 0, 31, (uint8_t *)font3_data }; #endif // FONT_H
51.232725
71
0.623468
[ "3d" ]
80962005014f338f0be0393987a6b17bac441517
5,033
h
C
lib/include/xnetwork/utils/rcm.h
luk036/xnetwork
462c25da3aead6b834e6027f4d679dc47965b134
[ "MIT" ]
1
2020-03-31T06:10:58.000Z
2020-03-31T06:10:58.000Z
lib/include/xnetwork/utils/rcm.h
luk036/xnetwork
462c25da3aead6b834e6027f4d679dc47965b134
[ "MIT" ]
null
null
null
lib/include/xnetwork/utils/rcm.h
luk036/xnetwork
462c25da3aead6b834e6027f4d679dc47965b134
[ "MIT" ]
1
2020-04-08T05:56:26.000Z
2020-04-08T05:56:26.000Z
/** Cuthill-McKee ordering of graph nodes to produce sparse matrices */ // Copyright (C) 2011-2014 by // Wai-Shing Luk <luk036@gmail.com> // All rights reserved. // BSD license. from collections import deque from operator import itemgetter #include <xnetwork.hpp> // as xn from ..utils import arbitrary_element __author__ = R"(\n)".join(["Wai-Shing Luk <luk036@gmail.com>"]); static const auto __all__ = ["cuthill_mckee_ordering", "reverse_cuthill_mckee_ordering"]; auto cuthill_mckee_ordering(G, heuristic=None) { /** Generate an ordering (permutation) of the graph nodes to make a sparse matrix. Uses the Cuthill-McKee heuristic (based on breadth-first search) [1]_. Parameters ---------- G : graph A XNetwork graph heuristic : function, optional Function to choose starting node for RCM algorithm. If None; a node from a pseudo-peripheral pair is used. A user-defined function can be supplied that takes a graph object && returns a single node. Returns ------- nodes : generator Generator of nodes : Cuthill-McKee ordering. Examples -------- >>> #include <xnetwork/utils.hpp> // import cuthill_mckee_ordering >>> G = xn::path_graph(4); >>> rcm = list(cuthill_mckee_ordering(G)); >>> A = xn::adjacency_matrix(G, nodelist=rcm) // doctest: +SKIP Smallest degree node as heuristic function) { >>> auto smallest_degree(G) { ... return min(G, key=G.degree); >>> rcm = list(cuthill_mckee_ordering(G, heuristic=smallest_degree)); See Also -------- reverse_cuthill_mckee_ordering Notes ----- The optimal solution the the bandwidth reduction is NP-complete [2]_. References ---------- .. [1] E. Cuthill && J. McKee. Reducing the bandwidth of sparse symmetric matrices, In Proc. 24th Nat. Conf. ACM, pages 157-172, 1969. http://doi.acm.org/10.1145/800195.805928 .. [2] Steven S. Skiena. 1997. The Algorithm Design Manual. Springer-Verlag New York, Inc., New York, NY, USA. */ for (auto c : xn::connected_components(G) { for (auto n : connected_cuthill_mckee_ordering(G.subgraph(c), heuristic) { yield n auto reverse_cuthill_mckee_ordering(G, heuristic=None) { /** Generate an ordering (permutation) of the graph nodes to make a sparse matrix. Uses the reverse Cuthill-McKee heuristic (based on breadth-first search); [1]_. Parameters ---------- G : graph A XNetwork graph heuristic : function, optional Function to choose starting node for RCM algorithm. If None; a node from a pseudo-peripheral pair is used. A user-defined function can be supplied that takes a graph object && returns a single node. Returns ------- nodes : generator Generator of nodes : reverse Cuthill-McKee ordering. Examples -------- >>> #include <xnetwork/utils.hpp> // import reverse_cuthill_mckee_ordering >>> G = xn::path_graph(4); >>> rcm = list(reverse_cuthill_mckee_ordering(G)); >>> A = xn::adjacency_matrix(G, nodelist=rcm) // doctest: +SKIP Smallest degree node as heuristic function) { >>> auto smallest_degree(G) { ... return min(G, key=G.degree); >>> rcm = list(reverse_cuthill_mckee_ordering(G, heuristic=smallest_degree)); See Also -------- cuthill_mckee_ordering Notes ----- The optimal solution the the bandwidth reduction is NP-complete [2]_. References ---------- .. [1] E. Cuthill && J. McKee. Reducing the bandwidth of sparse symmetric matrices, In Proc. 24th Nat. Conf. ACM, pages 157-72, 1969. http://doi.acm.org/10.1145/800195.805928 .. [2] Steven S. Skiena. 1997. The Algorithm Design Manual. Springer-Verlag New York, Inc., New York, NY, USA. */ return reversed(list(cuthill_mckee_ordering(G, heuristic=heuristic))); auto connected_cuthill_mckee_ordering(G, heuristic=None) { // the cuthill mckee algorithm for connected graphs if (heuristic.empty()) { start = pseudo_peripheral_node(G); } else { start = heuristic(G); visited = {start} queue = deque([start]); while (queue) { parent = queue.popleft(); yield parent nd = sorted(list(G.degree(set(G[parent]) - visited)), key=itemgetter(1)); children = [n for n, d : nd]; visited.update(children); queue.extend(children); auto pseudo_peripheral_node(G) { // helper for cuthill-mckee to find a node : a "pseudo peripheral pair" // to use as good starting node u = arbitrary_element(G); lp = 0.; v = u while (true) { spl = dict(xn::shortest_path_length(G, v)); l = max(spl.values()); if (l <= lp) { break; lp = l farthest = (n for n, dist : spl.items() if (dist == l); v, deg = min(G.degree(farthest), key=itemgetter(1)); return v
30.319277
82
0.629247
[ "object" ]
80968e5804cf8069a42b2777b621e02f5f3a60c1
832
h
C
src/SharableTarget.h
gooer135/appveyor-test
626be99203ac67a1a7fb26b12e45d0b167ffbbde
[ "MIT" ]
null
null
null
src/SharableTarget.h
gooer135/appveyor-test
626be99203ac67a1a7fb26b12e45d0b167ffbbde
[ "MIT" ]
null
null
null
src/SharableTarget.h
gooer135/appveyor-test
626be99203ac67a1a7fb26b12e45d0b167ffbbde
[ "MIT" ]
null
null
null
#ifndef _H_SHARABLETARGET_ #define _H_SHARABLETARGET_ enum SharableTargetType { window = 1, screen = 2 }; class SharableTarget : public Object { protected: SharableTarget(void); virtual ~SharableTarget(void) = 0; SharableTarget(SharableTarget&); public: virtual std::uint64_t getUniqueId(void) const = 0; virtual const Area& getArea(int dummy = 0) const = 0; virtual Area& getArea(void) = 0; virtual SharableTargetType getType(void) const = 0; virtual bool isWindow(void) const = 0; virtual bool isScreen(void) const = 0; public: virtual bool startCapture(nbind::Buffer buffer, float scaleFactor, int fps, nbind::cbFunction& callback) = 0; virtual void stopCapture(nbind::cbFunction& callback) = 0; virtual void takeScreenshot(nbind::Buffer buffer, float scaleFactor, nbind::cbFunction& callback) = 0; }; #endif
26
110
0.753606
[ "object" ]
80adf21103bd3fc4ece032d656eedf78c5345c4b
1,198
h
C
CMinus/CMinus/attribute/attribute_object.h
benbraide/CMinusMinus
6e32b825f192634538b3adde6ca579a548ca3f7e
[ "MIT" ]
null
null
null
CMinus/CMinus/attribute/attribute_object.h
benbraide/CMinusMinus
6e32b825f192634538b3adde6ca579a548ca3f7e
[ "MIT" ]
null
null
null
CMinus/CMinus/attribute/attribute_object.h
benbraide/CMinusMinus
6e32b825f192634538b3adde6ca579a548ca3f7e
[ "MIT" ]
null
null
null
#pragma once #include <string> #include <memory> #include "attribute_options.h" namespace cminus::storage{ class object; } namespace cminus::type{ class object; } namespace cminus::memory{ class reference; } namespace cminus::attribute{ class object{ public: object(const std::string &name, storage::object *parent); virtual ~object(); virtual const std::string &get_name() const; virtual std::string get_qname() const; virtual storage::object *get_parent() const; virtual bool is_primitive() const; virtual bool is_same(const object &other) const; virtual bool applies_to_type(const type::object &target_type) const; virtual std::string get_message() const; virtual query_result query(stage_type stage, std::shared_ptr<memory::reference> target, std::shared_ptr<memory::reference> arg) const = 0; static query_result handle_query_result(stage_type stage, const object &attr, std::shared_ptr<memory::reference> target, std::shared_ptr<memory::reference> arg); static query_result handle_query_result(query_result result, const object &target, std::shared_ptr<memory::reference> arg); protected: std::string name_; storage::object *parent_; }; }
23.038462
163
0.750417
[ "object" ]
80beac988f33c3005bf35a30a5b29a9ae1822517
36,407
c
C
usr/src/usr.sbin/afs/src/rx/rx_pkt.c
sizeofvoid/ifconfigd
bdff4b2cec6d572c1450cb44f32c0bdab1b49e5f
[ "BSD-2-Clause" ]
2
2020-04-15T13:39:01.000Z
2020-08-28T01:27:00.000Z
usr/src/usr.sbin/afs/src/rx/rx_pkt.c
sizeofvoid/ifconfigd
bdff4b2cec6d572c1450cb44f32c0bdab1b49e5f
[ "BSD-2-Clause" ]
null
null
null
usr/src/usr.sbin/afs/src/rx/rx_pkt.c
sizeofvoid/ifconfigd
bdff4b2cec6d572c1450cb44f32c0bdab1b49e5f
[ "BSD-2-Clause" ]
1
2020-08-28T01:25:41.000Z
2020-08-28T01:25:41.000Z
#include "rx_locl.h" RCSID("$arla: rx_pkt.c,v 1.22 2003/04/08 22:15:08 lha Exp $"); struct rx_packet *rx_mallocedP = 0; struct rx_cbuf *rx_mallocedC = 0; /* string to send to rxdebug */ #define CML_VERSION_NUMBER_SIZE 65 static char cml_version_number[CML_VERSION_NUMBER_SIZE]= PACKAGE "-" VERSION ; extern int (*rx_almostSent) (); /* * some rules about packets: * 1. When a packet is allocated, the final iov_buf contains room for * a security trailer, but iov_len masks that fact. If the security * package wants to add the trailer, it may do so, and then extend * iov_len appropriately. For this reason, packet's niovecs and * iov_len fields should be accurate before calling PreparePacket. */ /* * Preconditions: * all packet buffers (iov_base) are integral multiples of * the word size. * offset is an integral multiple of the word size. */ uint32_t rx_SlowGetLong(struct rx_packet *packet, int offset) { int i, l; for (l = 0, i = 1; i < packet->niovecs; i++) { if (l + packet->wirevec[i].iov_len > offset) { return *((uint32_t *) ((char *)packet->wirevec[i].iov_base + (offset - l))); } l += packet->wirevec[i].iov_len; } return 0; } /* Preconditions: * all packet buffers (iov_base) are integral multiples of the word * size. * offset is an integral multiple of the word size. */ int rx_SlowPutLong(struct rx_packet *packet, int offset, uint32_t data) { int i, l; for (l = 0, i = 1; i < packet->niovecs; i++) { if (l + packet->wirevec[i].iov_len > offset) { *((uint32_t *) ((char *)packet->wirevec[i].iov_base + (offset - l))) = data; return 0; } l += packet->wirevec[i].iov_len; } return 1; } /* * Preconditions: * all packet buffers (iov_base) are integral multiples of the * word size. * offset is an integral multiple of the word size. * Packet Invariants: * all buffers are contiguously arrayed in the iovec from 0..niovecs-1 */ size_t rx_SlowReadPacket(struct rx_packet *packet, int offset, int resid, void *out) { int i; unsigned char *p = out; size_t bytes; for(i = 1; (i < packet->niovecs) && (offset + (ssize_t)resid > 0); i++) { if(offset < packet->wirevec[i].iov_len) { /* at this point the intersection of this iovec and [offset, offset+resid) is non-empty, so we can copy min(base + len, base + offset + resid) - max(base, base + offset) bytes */ bytes = min(packet->wirevec[i].iov_len, offset + resid) - max(offset, 0); memcpy(p, (char *)packet->wirevec[i].iov_base + max(offset, 0), bytes); p += bytes; } offset -= packet->wirevec[i].iov_len; } return p - (unsigned char *)out; } /* * Preconditions: * all packet buffers (iov_base) are integral multiples of the * word size. * offset is an integral multiple of the word size. */ size_t rx_SlowWritePacket(struct rx_packet *packet, int offset, int resid, void *in) { int i; unsigned char *p = in; size_t bytes; for(i = 1; i < RX_MAXWVECS && offset + resid > 0; i++) { if(i >= packet->niovecs) if(rxi_AllocDataBuf(packet, resid)) break; if(offset < packet->wirevec[i].iov_len) { /* at this point the intersection of this iovec and [offset, offset+resid) is non-empty, so we can copy min(base + len, base + offset + resid) - max(base, base + offset) bytes */ bytes = min(packet->wirevec[i].iov_len, offset + resid) - max(offset, 0); memcpy((char *)(packet->wirevec[i].iov_base) + max(offset, 0), p, bytes); p += bytes; } offset -= packet->wirevec[i].iov_len; } return p - (unsigned char *)in; } static void freeCBuf(struct rx_cbuf *c) { SPLVAR; dpf(("Free cbuf %x\n", c)); NETPRI; MObtainWriteLock(&rx_freePktQ_lock); queue_Append(&rx_freeCbufQueue, c); rx_nFreeCbufs++; MReleaseWriteLock(&rx_freePktQ_lock); USERPRI; return; } static struct rx_cbuf * allocCBuf(void) { struct rx_cbuf *c; SPLVAR; NETPRI; MObtainWriteLock(&rx_freePktQ_lock); if (queue_IsEmpty(&rx_freeCbufQueue)) { #ifdef KERNEL c = NULL; rxi_NeedMoreCbufs = TRUE; goto done; #else /* KERNEL */ rxi_MoreCbufs(rx_Window); #endif /* KERNEL */ } rx_nFreeCbufs--; c = queue_First(&rx_freeCbufQueue, rx_cbuf); dpf(("Alloc cb %x\n", c)); queue_Remove(c); #ifdef KERNEL done: #endif MReleaseWriteLock(&rx_freePktQ_lock); USERPRI; return c; } /* Allocate more CBufs iff we need them */ /* * In kernel, can't page in memory with interrupts disabled, so we * don't use the event mechanism. */ void rx_CheckCbufs(unsigned long when) /* time when I should be called next */ { struct clock now; clock_GetTime(&now); if (rxi_NeedMoreCbufs) { rxi_MoreCbufs(rx_Window); } #ifndef KERNEL now.sec += RX_CBUF_TIME; rxevent_Post(&now, rx_CheckCbufs, (void *)now.sec, NULL); #endif } /* * this one is kind of awful. * In rxkad, the packet has been all shortened, and everything, ready for * sending. All of a sudden, we discover we need some of that space back. * This isn't terribly general, because it knows that the packets are only * rounded up to the EBS (userdata + security header). */ int rxi_RoundUpPacket(struct rx_packet *p, unsigned int nb) { int i; i = p->niovecs - 1; if (p->wirevec[i].iov_base == (caddr_t) p->localdata) { if (p->wirevec[i].iov_len <= RX_FIRSTBUFFERSIZE - nb) { p->wirevec[i].iov_len += nb; return 0; } } else { if (p->wirevec[i].iov_len <= RX_CBUFFERSIZE - nb) { p->wirevec[i].iov_len += nb; return 0; } } return 0; } /* get sufficient space to store nb bytes of data (or more), and hook * it into the supplied packet. Return nbytes<=0 if successful, otherwise * returns the number of bytes >0 which it failed to come up with. * Don't need to worry about locking on packet, since only * one thread can manipulate one at a time. Locking on cbufs is handled * by allocCBuf */ /* MTUXXX don't need to go throught the for loop if we can trust niovecs */ int rxi_AllocDataBuf(struct rx_packet *p, int nb) { int i; for (i = 0; nb > 0 && i < RX_MAXWVECS; i++) { if (p->wirevec[i].iov_base) continue; switch (i) { case 1: p->wirevec[i].iov_len = RX_FIRSTBUFFERSIZE; p->wirevec[i].iov_base = (caddr_t) p->localdata; nb -= RX_FIRSTBUFFERSIZE; p->length += RX_FIRSTBUFFERSIZE; break; default: { struct rx_cbuf *cb; if ((cb = allocCBuf()) != NULL) { p->wirevec[i].iov_base = (caddr_t) cb->data; p->wirevec[i].iov_len = RX_CBUFFERSIZE; nb -= RX_CBUFFERSIZE; p->length += RX_CBUFFERSIZE; p->niovecs++; } else i = RX_MAXWVECS; } break; } } return nb; } int rxi_FreeDataBufs(struct rx_packet *p, int first) { int i; if (first != 1) /* MTUXXX */ osi_Panic("FreeDataBufs 1: first must be 1"); for (i = first; i < RX_MAXWVECS; i++) { if (p->wirevec[i].iov_base) { if (p->wirevec[i].iov_base != (caddr_t) p->localdata) { freeCBuf((struct rx_cbuf *)((char *)p->wirevec[i].iov_base - sizeof(struct rx_queue))); } p->wirevec[i].iov_base = NULL; } else if (i == 1) /* MTUXXX */ osi_Panic("FreeDataBufs 4: vec 1 must not be NULL"); p->wirevec[i].iov_len = 0; } p->length = 0; return 0; } /* * add n more fragment buffers (continuation buffers) * Must be called at user priority or will crash RS/6000s */ void rxi_MoreCbufs(int n) { struct rx_cbuf *c, *e; int getme; SPLVAR; if (!n) return; getme = n * sizeof(struct rx_cbuf); c = rx_mallocedC = (struct rx_cbuf *) osi_Alloc(getme); if (!c) return; memset(c, 0, getme); PIN(c, getme); /* XXXXX */ NETPRI; MObtainWriteLock(&rx_freePktQ_lock); for (e = c + n; c < e; c++) { queue_Append(&rx_freeCbufQueue, c); } rxi_NeedMoreCbufs = FALSE; rx_nFreeCbufs += n; rx_nCbufs += n; MReleaseWriteLock(&rx_freePktQ_lock); USERPRI; return; } /* Add more packet buffers */ void rxi_MorePackets(int apackets) { struct rx_packet *p, *e; int getme; SPLVAR; getme = apackets * sizeof(struct rx_packet); p = rx_mallocedP = (struct rx_packet *) osi_Alloc(getme); PIN(p, getme); /* XXXXX */ memset((char *) p, 0, getme); NETPRI; MObtainWriteLock(&rx_freePktQ_lock); for (e = p + apackets; p < e; p++) { p->wirevec[0].iov_base = (char *) (p->wirehead); p->wirevec[0].iov_len = RX_HEADER_SIZE; p->wirevec[1].iov_base = (char *) (p->localdata); p->wirevec[1].iov_len = RX_FIRSTBUFFERSIZE; p->niovecs = 2; queue_Append(&rx_freePacketQueue, p); } rx_nFreePackets += apackets; MReleaseWriteLock(&rx_freePktQ_lock); USERPRI; /* * allocate enough cbufs that 1/4 of the packets will be able to hold * maximal amounts of data */ /* MTUXXX enable this -- currently disabled for testing rxi_MoreCbufs((apackets/4)*(rx_maxReceiveSize - RX_FIRSTBUFFERSIZE)/RX_CBUFFERSIZE); */ } void rxi_FreeAllPackets(void) { /* must be called at proper interrupt level, etcetera */ /* MTUXXX need to free all Cbufs */ osi_Free(rx_mallocedP, (rx_Window + 2) * sizeof(struct rx_packet)); UNPIN(rx_mallocedP, (rx_Window + 2) * sizeof(struct rx_packet)); return; } /* * In the packet freeing routine below, the assumption is that * we want all of the packets to be used equally frequently, so that we * don't get packet buffers paging out. It would be just as valid to * assume that we DO want them to page out if not many are being used. * In any event, we assume the former, and append the packets to the end * of the free list. */ /* * This explanation is bogus. The free list doesn't remain in any kind of * useful order for long: the packets in use get pretty much randomly scattered * across all the pages. In order to permit unused {packets,bufs} to page * out, they must be stored so that packets which are adjacent in memory are * adjacent in the free list. An array springs rapidly to mind. */ /* * Free the packet p. P is assumed not to be on any queue, i.e. * remove it yourself first if you call this routine. */ void rxi_FreePacket(struct rx_packet *p) { SPLVAR; dpf(("Free %x\n", p)); rxi_FreeDataBufs(p, 1); /* this gets the locks below, so must * call it first */ NETPRI; MObtainWriteLock(&rx_freePktQ_lock); rx_nFreePackets++; queue_Append(&rx_freePacketQueue, p); /* Wakeup anyone waiting for packets */ rxi_PacketsUnWait(); MReleaseWriteLock(&rx_freePktQ_lock); USERPRI; } /* * rxi_AllocPacket sets up p->length so it reflects the number of * bytes in the packet at this point, **not including** the header. * The header is absolutely necessary, besides, this is the way the * length field is usually used */ struct rx_packet * rxi_AllocPacket(int class) { struct rx_packet *p; if (rxi_OverQuota(class)) { rx_stats.noPackets[class]++; return NULL; } rx_stats.packetRequests++; MObtainWriteLock(&rx_freePktQ_lock); rx_nFreePackets--; if (queue_IsEmpty(&rx_freePacketQueue)) osi_Panic("rxi_AllocPacket error"); p = queue_First(&rx_freePacketQueue, rx_packet); dpf(("Alloc %x, class %d\n", queue_First(&rx_freePacketQueue, rx_packet), class)); queue_Remove(p); MReleaseWriteLock(&rx_freePktQ_lock); /* * have to do this here because rx_FlushWrite fiddles with the iovs in * order to truncate outbound packets. In the near future, may need to * allocate bufs from a static pool here, and/or in AllocSendPacket */ p->wirevec[0].iov_base = (char *) (p->wirehead); p->wirevec[0].iov_len = RX_HEADER_SIZE; p->wirevec[1].iov_base = (char *) (p->localdata); p->wirevec[1].iov_len = RX_FIRSTBUFFERSIZE; p->niovecs = 2; p->length = RX_FIRSTBUFFERSIZE; return p; } /* * This guy comes up with as many buffers as it {takes,can get} given * the MTU for this call. It also sets the packet length before * returning. caution: this is often called at NETPRI */ struct rx_packet * rxi_AllocSendPacket(struct rx_call *call, int want) { struct rx_packet *p = (struct rx_packet *) 0; int mud; SPLVAR; mud = call->conn->maxPacketSize - RX_HEADER_SIZE; while (!(call->error)) { /* if an error occurred, or we get the packet we want, we're done */ if ((p = rxi_AllocPacket(RX_PACKET_CLASS_SEND)) != NULL) { want += rx_GetSecurityHeaderSize(rx_ConnectionOf(call)) + rx_GetSecurityMaxTrailerSize(rx_ConnectionOf(call)); want = MIN(want, mud); if (want > p->length) (void) rxi_AllocDataBuf(p, (want - p->length)); if (p->length > mud) p->length = mud; p->length -= rx_GetSecurityHeaderSize(rx_ConnectionOf(call)) + rx_GetSecurityMaxTrailerSize(rx_ConnectionOf(call)); if (p->length <= 0) { rxi_FreePacket(p); p = NULL; } break; } /* * no error occurred, and we didn't get a packet, so we sleep. At * this point, we assume that packets will be returned sooner or * later, as packets are acknowledged, and so we just wait. */ NETPRI; RX_MUTEX_ENTER(&rx_waitingForPackets_lock); rx_waitingForPackets = 1; call->flags |= RX_CALL_WAIT_PACKETS; #ifdef RX_ENABLE_LOCKS cv_wait(&rx_waitingForPackets_cv, &rx_waitingForPackets_lock); #else osi_rxSleep(&rx_waitingForPackets); #endif call->flags &= ~RX_CALL_WAIT_PACKETS; RX_MUTEX_EXIT(&rx_waitingForPackets_lock); USERPRI; } return p; } #ifndef KERNEL /* count the number of used FDs */ static int CountFDs(int amax) { struct stat tstat; int i, code; int count; count = 0; for (i = 0; i < amax; i++) { code = fstat(i, &tstat); if (code == 0) count++; } return count; } /* * This function reads a single packet from the interface into the * supplied packet buffer (*p). Return 0 if the packet is bogus. The * (host,port) of the sender are stored in the supplied variables, and * the data length of the packet is stored in the packet structure. * The header is decoded. */ int rxi_ReadPacket(int socket, struct rx_packet *p, uint32_t *host, uint16_t *port) { struct sockaddr_in from; int nbytes; long rlen; long tlen; long _tlen; struct msghdr msg; uint32_t dummy; /* was using rlen but had aliasing * problems */ rx_computelen(p, tlen); rx_SetDataSize(p, tlen); /* this is the size of the user data * area */ tlen += RX_HEADER_SIZE; /* now this is the size of the entire * packet */ rlen = rx_maxReceiveSize; /* this is what I am advertising. * Only check it once in order to * avoid races. */ _tlen = rlen - tlen; if (_tlen > 0) { _tlen = rxi_AllocDataBuf(p, _tlen); if (_tlen >0) { _tlen = rlen - _tlen; } else _tlen = rlen; } else _tlen = rlen; tlen=(tlen>_tlen)?tlen:_tlen; /* * set up this one iovec for padding, it's just to make sure that the * read doesn't return more data than we expect, and is done to get * around our problems caused by the lack of a length field in the rx * header. */ p->wirevec[p->niovecs].iov_base = (caddr_t) & dummy; p->wirevec[p->niovecs++].iov_len = 4; memset(&msg, 0, sizeof(msg)); msg.msg_name = (char *) &from; msg.msg_namelen = sizeof(struct sockaddr_in); msg.msg_iov = p->wirevec; msg.msg_iovlen = p->niovecs; #if 0 msg.msg_accrights = NULL; msg.msg_accrightslen = 0; #endif nbytes = recvmsg(socket, &msg, 0); /* restore the vec to its correct state */ p->wirevec[--p->niovecs].iov_base = NULL; p->wirevec[p->niovecs].iov_len = 0; if (nbytes < 0) { /* ignore error? */ return 0; } p->length = (nbytes - RX_HEADER_SIZE); if ((nbytes > tlen) || (nbytes < (int)RX_HEADER_SIZE)) { /* Bogus packet */ if (nbytes > 0) rxi_MoreCbufs(rx_Window); if (nbytes > tlen) rxi_AllocDataBuf(p, nbytes - tlen); else if (nbytes < 0 && errno == EWOULDBLOCK) rx_stats.noPacketOnRead++; else { rx_stats.bogusPacketOnRead++; rx_stats.bogusHost = from.sin_addr.s_addr; dpf(("B: bogus packet from [%x,%d] nb=%d", from.sin_addr.s_addr, from.sin_port, nbytes)); } return 0; } else { /* Extract packet header. */ rxi_DecodePacketHeader(p); *host = from.sin_addr.s_addr; *port = from.sin_port; if (p->header.type > 0 && p->header.type < RX_N_PACKET_TYPES) rx_stats.packetsRead[p->header.type - 1]++; return 1; } } /* Send a udp datagram */ int osi_NetSend(osi_socket socket, char *addr, struct iovec *dvec, int nvecs, int length) { struct msghdr msg; memset(&msg, 0, sizeof(msg)); msg.msg_iov = dvec; msg.msg_iovlen = nvecs; msg.msg_name = addr; msg.msg_namelen = sizeof(struct sockaddr_in); #if 0 msg.msg_accrights = NULL; msg.msg_accrightslen = 0; #endif while (sendmsg(socket, &msg, 0) == -1) { int err; fd_set sfds; rx_stats.sendSelects++; if (errno != EWOULDBLOCK && errno != ENOBUFS && errno != ECONNREFUSED) { osi_Msg(("rx failed to send packet: %s ", strerror(errno))); return 3; } dpf(("rx_send failed with %d\n", errno)); FD_ZERO(&sfds); if (socket >= FD_SETSIZE) osi_Panic("osi_NetSend: fd too large"); FD_SET(socket, &sfds); while ((err = select(socket + 1, 0, &sfds, 0, 0)) != 1) { if (err >= 0 || errno != EINTR) osi_Panic("osi_NetSend: select error %d.%d", err, errno); } } return 0; } #else /* KERNEL */ /* * osi_NetSend is defined in afs/afs_osinet.c * message receipt is done in rxk_input or rx_put. */ #ifdef AFS_SUN5_ENV /* * Copy an mblock to the contiguous area pointed to by cp. * MTUXXX Supposed to skip <off> bytes and copy <len> bytes, * but it doesn't really. * Returns the number of bytes not transferred. * The message is NOT changed. */ static int cpytoc(mblk_t *mp, int off, int len, char *cp) { int n; for (; mp && len > 0; mp = mp->b_cont) { if (mp->b_datap->db_type != M_DATA) { return -1; } n = MIN(len, (mp->b_wptr - mp->b_rptr)); memcpy(cp, mp->b_rptr, n); cp += n; len -= n; mp->b_rptr += n; } return (len); } /* * MTUXXX Supposed to skip <off> bytes and copy <len> bytes, * but it doesn't really. * This sucks, anyway, do it like m_cpy.... below */ static int cpytoiovec(mblk_t *mp, int off, int len, struct iovec *iovs, int niovs) { int m, n, o, t, i; for (i = -1, t = 0; i < niovs && mp && len > 0; mp = mp->b_cont) { if (mp->b_datap->db_type != M_DATA) { return -1; } n = MIN(len, (mp->b_wptr - mp->b_rptr)); len -= n; while (n) { if (!t) { o = 0; i++; t = iovs[i].iov_len; } m = MIN(n, t); memcpy(iovs[i].iov_base + o, mp->b_rptr, m); mp->b_rptr += m; o += m; t -= m; n -= m; } } return (len); } #define m_cpytoc(a, b, c, d) cpytoc(a, b, c, d) #define m_cpytoiovec(a, b, c, d, e) cpytoiovec(a, b, c, d, e) #else static int m_cpytoiovec(struct mbuf *m, int off, int len, struct iovec iovs[], int niovs) { caddr_t p1, p2; unsigned int l1, l2, i, t; if (m == NULL || off < 0 || len < 0 || iovs == NULL) panic("m_cpytoiovec"); /* MTUXXX probably don't need this * check */ while (off && m) if (m->m_len <= off) { off -= m->m_len; m = m->m_next; continue; } else break; if (m == NULL) return len; p1 = mtod(m, caddr_t) + off; l1 = m->m_len - off; i = 0; p2 = iovs[0].iov_base; l2 = iovs[0].iov_len; while (len) { t = MIN(l1, MIN(l2, (unsigned int) len)); memcpy(p2, p1, t); p1 += t; p2 += t; l1 -= t; l2 -= t; len -= t; if (!l1) { m = m->m_next; if (!m) break; p1 = mtod(m, caddr_t); l1 = m->m_len; } if (!l2) { if (++i >= niovs) break; p2 = iovs[i].iov_base; l2 = iovs[i].iov_len; } } return len; } #endif /* AFS_SUN5_ENV */ int rx_mb_to_packet(char *amb, void (*free)(), int hdr_len, int data_len, struct rx_packet *phandle) { int code; code = m_cpytoiovec(amb, hdr_len, data_len, phandle->wirevec, phandle->niovecs); (*free) (amb); return code; } #define CountFDs(amax) amax #endif /* KERNEL */ /* send a response to a debug packet */ struct rx_packet * rxi_ReceiveDebugPacket(struct rx_packet *ap, osi_socket asocket, uint32_t ahost, uint16_t aport) { struct rx_debugIn tin; long tl; rx_packetread(ap, 0, sizeof(struct rx_debugIn), (char *) &tin); /* * all done with packet, now set length to the truth, so we can reuse * this packet */ rx_computelen(ap, ap->length); tin.type = ntohl(tin.type); tin.index = ntohl(tin.index); switch (tin.type) { case RX_DEBUGI_GETSTATS:{ struct rx_debugStats tstat; /* get basic stats */ memset((char *) &tstat, 0, sizeof(tstat)); /* make sure spares are * zero */ tstat.version = RX_DEBUGI_VERSION; #ifndef RX_ENABLE_LOCKS tstat.waitingForPackets = rx_waitingForPackets; #endif tstat.nFreePackets = htonl(rx_nFreePackets); tstat.callsExecuted = htonl(rxi_nCalls); tstat.packetReclaims = htonl(0); tstat.usedFDs = CountFDs(64); tstat.nWaiting = htonl(rx_nWaiting); tl = sizeof(struct rx_debugStats) - ap->length; if (tl > 0) tl = rxi_AllocDataBuf(ap, tl); if (tl <= 0) { rx_packetwrite(ap, 0, sizeof(struct rx_debugStats), (char *) &tstat); ap->length = sizeof(struct rx_debugStats); rxi_SendDebugPacket(ap, asocket, ahost, aport); rx_computelen(ap, ap->length); } break; } case RX_DEBUGI_GETALLCONN: case RX_DEBUGI_GETCONN:{ int i, j; struct rx_connection *tc; struct rx_call *tcall; struct rx_debugConn tconn; int all = (tin.type == RX_DEBUGI_GETALLCONN); tl = sizeof(struct rx_debugConn) - ap->length; if (tl > 0) tl = rxi_AllocDataBuf(ap, tl); if (tl > 0) return ap; memset((char *) &tconn, 0, sizeof(tconn)); /* make sure spares are * zero */ /* get N'th (maybe) "interesting" connection info */ for (i = 0; i < rx_hashTableSize; i++) { for (tc = rx_connHashTable[i]; tc; tc = tc->next) { if ((all || rxi_IsConnInteresting(tc)) && tin.index-- <= 0) { tconn.host = tc->peer->host; tconn.port = tc->peer->port; tconn.cid = htonl(tc->cid); tconn.epoch = htonl(tc->epoch); tconn.serial = htonl(tc->serial); for (j = 0; j < RX_MAXCALLS; j++) { tconn.callNumber[j] = htonl(tc->callNumber[j]); if ((tcall = tc->call[j]) != NULL) { tconn.callState[j] = tcall->state; tconn.callMode[j] = tcall->mode; tconn.callFlags[j] = tcall->flags; if (queue_IsNotEmpty(&tcall->rq)) tconn.callOther[j] |= RX_OTHER_IN; if (queue_IsNotEmpty(&tcall->tq)) tconn.callOther[j] |= RX_OTHER_OUT; } else tconn.callState[j] = RX_STATE_NOTINIT; } tconn.maxPacketSize = htonl(tc->maxPacketSize); tconn.error = htonl(tc->error); tconn.flags = tc->flags; tconn.type = tc->type; tconn.securityIndex = tc->securityIndex; if (tc->securityObject) { RXS_GetStats(tc->securityObject, tc, &tconn.secStats); #define DOHTONL(a) (tconn.secStats.a = htonl(tconn.secStats.a)) #define DOHTONS(a) (tconn.secStats.a = htons(tconn.secStats.a)) DOHTONL(flags); DOHTONL(expires); DOHTONL(packetsReceived); DOHTONL(packetsSent); DOHTONL(bytesReceived); DOHTONL(bytesSent); for (i = 0; i < sizeof(tconn.secStats.spares) / sizeof(int16_t); i++) DOHTONS(spares[i]); for (i = 0; i < sizeof(tconn.secStats.sparel) / 4; i++) DOHTONL(sparel[i]); } rx_packetwrite(ap, 0, sizeof(struct rx_debugConn), (char *) &tconn); tl = ap->length; ap->length = sizeof(struct rx_debugConn); rxi_SendDebugPacket(ap, asocket, ahost, aport); ap->length = tl; return ap; } } } /* if we make it here, there are no interesting packets */ tconn.cid = htonl(0xffffffff); /* means end */ rx_packetwrite(ap, 0, sizeof(struct rx_debugConn), &tconn); tl = ap->length; ap->length = sizeof(struct rx_debugConn); rxi_SendDebugPacket(ap, asocket, ahost, aport); ap->length = tl; break; } case RX_DEBUGI_RXSTATS:{ int i; uint32_t *s; tl = sizeof(rx_stats) - ap->length; if (tl > 0) tl = rxi_AllocDataBuf(ap, tl); if (tl > 0) return ap; /* Since its all longs convert to network order with a loop. */ s = (uint32_t *) &rx_stats; for (i = 0; i < sizeof(rx_stats) / 4; i++, s++) rx_SlowPutLong(ap, i * 4, htonl(*s)); tl = ap->length; ap->length = sizeof(rx_stats); rxi_SendDebugPacket(ap, asocket, ahost, aport); ap->length = tl; break; } default: /* error response packet */ tin.type = htonl(RX_DEBUGI_BADTYPE); tin.index = tin.type; rx_packetwrite(ap, 0, sizeof(struct rx_debugIn), &tin); tl = ap->length; ap->length = sizeof(struct rx_debugIn); rxi_SendDebugPacket(ap, asocket, ahost, aport); ap->length = tl; break; } return ap; } struct rx_packet * rxi_ReceiveVersionPacket(struct rx_packet *ap, osi_socket asocket, uint32_t ahost, uint16_t aport) { long tl; rx_packetwrite(ap, 0, CML_VERSION_NUMBER_SIZE, cml_version_number); tl = ap->length; ap->length = 65; rxi_SendDebugPacket(ap, asocket, ahost, aport); ap->length = tl; return ap; } /* send a debug packet back to the sender */ void rxi_SendDebugPacket(struct rx_packet *apacket, osi_socket asocket, uint32_t ahost, uint16_t aport) { struct sockaddr_in taddr; int i = 0; int savelen = 0; int saven = 0; int nbytes; taddr.sin_family = AF_INET; taddr.sin_port = aport; taddr.sin_addr.s_addr = ahost; nbytes = apacket->length; for (i = 1; i < apacket->niovecs; i++) { if (nbytes <= apacket->wirevec[i].iov_len) { savelen = apacket->wirevec[i].iov_len; saven = apacket->niovecs; apacket->wirevec[i].iov_len = nbytes; apacket->niovecs = i + 1; /* so condition fails because i == niovecs */ } else nbytes -= apacket->wirevec[i].iov_len; } GLOBAL_UNLOCK(); /* debug packets are not reliably delivered, hence the cast below. */ /* MTUXXX need to adjust lengths as in sendSpecial */ (void) osi_NetSend(asocket, (char *)&taddr, apacket->wirevec, apacket->niovecs, apacket->length + RX_HEADER_SIZE); GLOBAL_LOCK(); if (saven) { apacket->wirevec[i - 1].iov_len = savelen; apacket->niovecs = saven; } } /* * Send the packet to appropriate destination for the specified * connection. The header is first encoded and placed in the packet. */ void rxi_SendPacket(struct rx_connection *conn, struct rx_packet *p) { struct sockaddr_in addr; struct rx_peer *peer = conn->peer; osi_socket socket; #ifdef RXDEBUG char deliveryType = 'S'; #endif memset(&addr, 0, sizeof(addr)); /* The address we're sending the packet to */ addr.sin_family = AF_INET; addr.sin_port = peer->port; addr.sin_addr.s_addr = peer->host; /* * This stuff should be revamped, I think, so that most, if not all, of * the header stuff is always added here. We could probably do away with * the encode/decode routines. XXXXX */ /* * Stamp each packet with a unique serial number. The serial number is * maintained on a connection basis because some types of security may be * based on the serial number of the packet, and security is handled on a * per authenticated-connection basis. */ /* * Pre-increment, to guarantee no zero serial number; a zero serial * number means the packet was never sent. */ p->header.serial = ++conn->serial; /* * This is so we can adjust retransmit time-outs better in the face of * rapidly changing round-trip times. RTO estimation is not a la Karn. */ if (p->firstSerial == 0) { p->firstSerial = p->header.serial; } #ifdef RXDEBUG /* * If an output tracer function is defined, call it with the packet and * network address. Note this function may modify its arguments. */ if (rx_almostSent) { int drop = (*rx_almostSent) (p, &addr); /* drop packet if return value is non-zero? */ if (drop) deliveryType = 'D'; /* Drop the packet */ } #endif /* Get network byte order header */ rxi_EncodePacketHeader(p); /* XXX in the event of rexmit, etc, * don't need to touch ALL the fields */ /* * Send the packet out on the same socket that related packets are being * received on */ socket = (conn->type == RX_CLIENT_CONNECTION ? rx_socket : conn->service->socket); #ifdef RXDEBUG /* Possibly drop this packet, for testing purposes */ if ((deliveryType == 'D') || ((rx_intentionallyDroppedPacketsPer100 > 0) && (random() % 100 < rx_intentionallyDroppedPacketsPer100))) { deliveryType = 'D'; /* Drop the packet */ } else { deliveryType = 'S'; /* Send the packet */ #endif /* RXDEBUG */ /* * Loop until the packet is sent. We'd prefer just to use a blocking * socket, but unfortunately the interface doesn't allow us to have * the socket block in send mode, and not block in receive mode */ GLOBAL_UNLOCK(); if (osi_NetSend(socket, (char *)&addr, p->wirevec, p->niovecs, p->length + RX_HEADER_SIZE)) { /* send failed, so let's hurry up the resend, eh? */ rx_stats.netSendFailures++; clock_Zero(&p->retryTime); p->header.serial = 0; /* Another way of saying never * transmitted... */ } GLOBAL_LOCK(); #ifdef RXDEBUG } dpf(("%c %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %x resend %d.%0.3d", deliveryType, p->header.serial, rx_packetTypes[p->header.type - 1], peer->host, peer->port, p->header.serial, p->header.epoch, p->header.cid, p->header.callNumber, p->header.seq, p->header.flags, p, p->retryTime.sec, p->retryTime.usec / 1000)); #endif rx_stats.packetsSent[p->header.type - 1]++; } /* * Send a "special" packet to the peer connection. If call is * specified, then the packet is directed to a specific call channel * associated with the connection, otherwise it is directed to the * connection only. Uses optionalPacket if it is supplied, rather than * allocating a new packet buffer. Nbytes is the length of the data * portion of the packet. If data is non-null, nbytes of data are * copied into the packet. Type is the type of the packet, as defined * in rx.h. Bug: there's a lot of duplication between this and other * routines. This needs to be cleaned up. */ struct rx_packet * rxi_SendSpecial(struct rx_call *call, struct rx_connection *conn, struct rx_packet *optionalPacket, int type, char *data, int nbytes) { /* * Some of the following stuff should be common code for all packet sends * (it's repeated elsewhere) */ struct rx_packet *p; int i = 0; int savelen = 0; int saven = 0; int channel, callNumber; if (call) { channel = call->channel; callNumber = *call->callNumber; } else { channel = 0; callNumber = 0; } p = optionalPacket; if (!p) { p = rxi_AllocPacket(RX_PACKET_CLASS_SPECIAL); if (!p) osi_Panic("rxi_SendSpecial failure"); } if (nbytes != -1) p->length = nbytes; else nbytes = p->length; p->header.serviceId = conn->serviceId; p->header.securityIndex = conn->securityIndex; p->header.cid = (conn->cid | channel); p->header.callNumber = callNumber; p->header.seq = 0; p->header.epoch = conn->epoch; p->header.type = type; p->header.flags = 0; if (conn->type == RX_CLIENT_CONNECTION) p->header.flags |= RX_CLIENT_INITIATED; if (data) rx_packetwrite(p, 0, nbytes, data); for (i = 1; i < p->niovecs; i++) { if (nbytes <= p->wirevec[i].iov_len) { savelen = p->wirevec[i].iov_len; saven = p->niovecs; p->wirevec[i].iov_len = nbytes; p->niovecs = i + 1; /* so condition fails because i == * niovecs */ } else nbytes -= p->wirevec[i].iov_len; } if (call) rxi_Send(call, p); else rxi_SendPacket(conn, p); if (saven) { /* means we truncated the packet * above. We probably don't */ /* really need to do this, but it seems safer this way, given that */ /* sneaky optionalPacket... */ p->wirevec[i - 1].iov_len = savelen; p->niovecs = saven; } if (!optionalPacket) rxi_FreePacket(p); return optionalPacket; } static void put32 (unsigned char **p, uint32_t u) { (*p)[0] = (u >> 24) & 0xFF; (*p)[1] = (u >> 16) & 0xFF; (*p)[2] = (u >> 8) & 0xFF; (*p)[3] = (u >> 0) & 0xFF; (*p) += 4; } static uint32_t get32 (unsigned char **p) { uint32_t u; u = ((*p)[0] << 24) | ((*p)[1] << 16) | ((*p)[2] << 8) | (*p)[3]; (*p) += 4; return u; } /* Encode the packet's header (from the struct header in the packet to * the net byte order representation in the wire representation of the * packet, which is what is actually sent out on the wire) */ void rxi_EncodePacketHeader(struct rx_packet *p) { unsigned char *buf = (unsigned char *)p->wirevec[0].iov_base; memset(buf, 0, RX_HEADER_SIZE); put32(&buf, p->header.epoch); put32(&buf, p->header.cid); put32(&buf, p->header.callNumber); put32(&buf, p->header.seq); put32(&buf, p->header.serial); put32(&buf, ((((unsigned long) p->header.type) << 24) | (((unsigned long) p->header.flags) << 16) | (p->header.userStatus << 8) | p->header.securityIndex)); /* Note: top 16 bits of this next word were reserved */ put32(&buf, ((p->header.spare << 16) | (p->header.serviceId & 0xffff))); } /* Decode the packet's header (from net byte order to a struct header) */ void rxi_DecodePacketHeader(struct rx_packet *p) { unsigned char *buf = (unsigned char *)p->wirevec[0].iov_base; uint32_t temp; p->header.epoch = get32(&buf); p->header.cid = get32(&buf); p->header.callNumber = get32(&buf); p->header.seq = get32(&buf); p->header.serial = get32(&buf); temp = get32(&buf); /* C will truncate byte fields to bytes for me */ p->header.type = temp >> 24; p->header.flags = temp >> 16; p->header.userStatus = temp >> 8; p->header.securityIndex = temp >> 0; temp = get32(&buf); p->header.serviceId = (temp & 0xffff); p->header.spare = temp >> 16; /* Note: top 16 bits of this last word are the security checksum */ } void rxi_PrepareSendPacket(struct rx_call *call, struct rx_packet *p, int last) { struct rx_connection *conn = call->conn; int len, i; p->acked = 0; p->header.cid = (conn->cid | call->channel); p->header.serviceId = conn->serviceId; p->header.securityIndex = conn->securityIndex; p->header.callNumber = *call->callNumber; p->header.seq = call->tnext++; p->header.epoch = conn->epoch; p->header.type = RX_PACKET_TYPE_DATA; p->header.flags = 0; p->header.spare = 0; if (conn->type == RX_CLIENT_CONNECTION) p->header.flags |= RX_CLIENT_INITIATED; if (last) p->header.flags |= RX_LAST_PACKET; clock_Zero(&p->retryTime); /* Never yet transmitted */ p->header.serial = 0; /* Another way of saying never * transmitted... */ p->backoff = 0; /* * Now that we're sure this is the last data on the call, make sure that * the "length" and the sum of the iov_lens matches. */ len = p->length + call->conn->securityHeaderSize; for (i = 1; i < p->niovecs && len > 0; i++) { len -= p->wirevec[i].iov_len; } if (len > 0) { osi_Panic("PrepareSendPacket 1\n"); /* MTUXXX */ } else { p->niovecs = i; p->wirevec[i - 1].iov_len += len; } RXS_PreparePacket(conn->securityObject, call, p); }
26.173257
86
0.62249
[ "3d" ]
80c11a9f449177ced426fa3f57b8790fa2f41638
30,603
c
C
Source/objects/sofa~.c
APL-Huddersfield/SOFA-for-Max
55e2dbe4b6ffa9e948cfaae2f134fbc00f5b354f
[ "BSD-3-Clause" ]
15
2019-03-31T22:03:21.000Z
2022-02-25T04:15:49.000Z
Source/objects/sofa~.c
APL-Huddersfield/SOFA-for-Max
55e2dbe4b6ffa9e948cfaae2f134fbc00f5b354f
[ "BSD-3-Clause" ]
null
null
null
Source/objects/sofa~.c
APL-Huddersfield/SOFA-for-Max
55e2dbe4b6ffa9e948cfaae2f134fbc00f5b354f
[ "BSD-3-Clause" ]
2
2019-03-31T22:04:08.000Z
2020-12-31T08:49:54.000Z
/** @file sofa~ - A SOFA importer for Max Dale Johnson - Dale.Johnson@hud.ac.uk @ingroup examples */ #include "../dep/sofa_common.h" #include "ext.h" #include "ext_buffer.h" #include "ext_common.h" #include "ext_globalsymbol.h" void *sofa_max_new(t_symbol *s, long argc, t_atom *argv); void sofa_max_free(t_sofa_max *x); void sofa_max_read(t_sofa_max *x, t_symbol *s); void sofa_max_doRead(t_sofa_max* x, t_symbol* s); void sofa_max_open(t_sofa_max* x, char* filename, short path); void sofa_max_write(t_sofa_max* x, t_symbol* s); void sofa_max_doWrite(t_sofa_max* x, t_symbol* s); // Data manipulation methods void sofa_max_create(t_sofa_max* x, t_symbol* s, long argc, t_atom* argv); // Measurement acquisition methods t_buffer_ref* sofa_max_getNewBuffer(t_sofa_max* x, t_symbol* bufferName); void sofa_max_getPositions(t_sofa_max* x, t_symbol* s); void sofa_max_getDimension(t_sofa_max* x, t_symbol* s, long argc, t_atom *argv); void sofa_max_getSize(t_sofa_max* x); void sofa_max_getName(t_sofa_max* x); void sofa_max_get(t_sofa_max* x, t_symbol* s, long argc, t_atom *argv); void sofa_max_updateObjectAttributes(t_sofa_max* x); void sofa_max_updateSOFAAttributes(t_sofa_max* x); bool sofa_max_isFileLoaded(t_sofa_max* x, t_symbol* s); void sofa_max_notify(t_sofa_max *x, t_symbol *s, t_symbol *msg, void *sender, void *data); void sofa_max_assist(t_sofa_max *x, void *b, long m, long a, char *s); t_max_err sofa_max_setAttr(t_sofa_max *x, void *attr, long argc, t_atom *argv); void *sofa_max_class; static const char* kStrAttr[NUM_ATTR_TYPES] = { "convention", "version", "sofaconvention", "sofaconventionversion", "datatype", "roomtype", "title", "datecreated", "datemodified", "apiname", "apiversion", "author", "organization", "license", "applicationname", "applicationversion", "comment", "history", "references", "origin", "roomname", "roomdescription", "roomlocation", "listenername", "listenerdescription", "sourcename", "sourcedescription", "receivername", "receiverdescription", "emittername", "emitterdescription" }; void ext_main(void *r) { t_class *c; c = class_new("sofa~", (method)sofa_max_new, (method)sofa_max_free, (long)sizeof(t_sofa_max), 0L, A_GIMME, 0); class_addmethod(c, (method)sofa_max_read, "read", A_DEFSYM, 0); class_addmethod(c, (method)sofa_max_write, "write", A_DEFSYM, 0); class_addmethod(c, (method)sofa_max_create, "new", A_GIMME, 0); class_addmethod(c, (method)sofa_max_getPositions, "getpositions", A_SYM, 0); class_addmethod(c, (method)sofa_max_getDimension, "getdimension", A_GIMME, 0); class_addmethod(c, (method)sofa_max_getSize, "getsizesamps", A_NOTHING, 0); class_addmethod(c, (method)sofa_max_getName, "getname", A_NOTHING, 0); class_addmethod(c, (method)sofa_max_get, "get", A_GIMME, 0); class_addmethod(c, (method)sofa_max_assist, "assist", A_CANT, 0); // Read only attributes CLASS_STICKY_CATEGORY(c, 0, "Read-only Global Attributes"); CLASS_ATTR_SYM(c, kStrAttr[VERSION_ATTR_TYPE], ATTR_SET_OPAQUE_USER, t_sofa_max, attributes[VERSION_ATTR_TYPE]); CLASS_ATTR_LABEL(c, kStrAttr[VERSION_ATTR_TYPE], 0, "Specification Version"); CLASS_ATTR_SYM(c, kStrAttr[SOFA_CONVENTION_ATTR_TYPE], ATTR_SET_OPAQUE_USER, t_sofa_max, attributes[SOFA_CONVENTION_ATTR_TYPE]); CLASS_ATTR_LABEL(c, kStrAttr[SOFA_CONVENTION_ATTR_TYPE], 0, "SOFA Convention"); CLASS_ATTR_SYM(c, kStrAttr[SOFA_CONVENTION_VERSION_ATTR_TYPE], ATTR_SET_OPAQUE_USER, t_sofa_max, attributes[SOFA_CONVENTION_VERSION_ATTR_TYPE]); CLASS_ATTR_LABEL(c, kStrAttr[SOFA_CONVENTION_VERSION_ATTR_TYPE], 0, "SOFA Convention Version"); CLASS_ATTR_SYM(c, kStrAttr[DATA_ATTR_TYPE], ATTR_SET_OPAQUE_USER, t_sofa_max, attributes[DATA_ATTR_TYPE]); CLASS_ATTR_LABEL(c, kStrAttr[DATA_ATTR_TYPE], 0, "Data Type"); CLASS_ATTR_SYM(c, kStrAttr[DATE_CREATED_ATTR_TYPE], ATTR_SET_OPAQUE_USER, t_sofa_max, attributes[DATE_CREATED_ATTR_TYPE]); CLASS_ATTR_LABEL(c, kStrAttr[DATE_CREATED_ATTR_TYPE], 0, "Date Created"); CLASS_ATTR_SYM(c, kStrAttr[DATE_MODIFIED_ATTR_TYPE], ATTR_SET_OPAQUE_USER, t_sofa_max, attributes[DATE_MODIFIED_ATTR_TYPE]); CLASS_ATTR_LABEL(c, kStrAttr[DATE_MODIFIED_ATTR_TYPE], 0, "Date Modified"); CLASS_ATTR_SYM(c, kStrAttr[API_NAME_ATTR_TYPE], ATTR_SET_OPAQUE_USER, t_sofa_max, attributes[API_NAME_ATTR_TYPE]); CLASS_ATTR_LABEL(c, kStrAttr[API_NAME_ATTR_TYPE], 0, "API Name"); CLASS_ATTR_SYM(c, kStrAttr[API_VERSION_ATTR_TYPE], ATTR_SET_OPAQUE_USER, t_sofa_max, attributes[API_VERSION_ATTR_TYPE]); CLASS_ATTR_LABEL(c, kStrAttr[API_VERSION_ATTR_TYPE], 0, "API Version"); CLASS_STICKY_CATEGORY_CLEAR(c); // Required attributes CLASS_STICKY_CATEGORY(c, 0, "Required Global Attributes"); CLASS_ATTR_SYM(c, kStrAttr[ROOM_ATTR_TYPE], 0, t_sofa_max, attributes[ROOM_ATTR_TYPE]); CLASS_ATTR_SELFSAVE(c, kStrAttr[ROOM_ATTR_TYPE], 0); CLASS_ATTR_LABEL(c, kStrAttr[ROOM_ATTR_TYPE], 0, "Room Type"); CLASS_ATTR_SYM(c, kStrAttr[TITLE_ATTR_TYPE], 0, t_sofa_max, attributes[TITLE_ATTR_TYPE]); CLASS_ATTR_DEFAULTNAME_SAVE(c, kStrAttr[TITLE_ATTR_TYPE], 0, "Untitled"); CLASS_ATTR_LABEL(c, kStrAttr[TITLE_ATTR_TYPE], 0, "Title"); CLASS_ATTR_SYM(c, kStrAttr[AUTHOR_CONTACT_ATTR_TYPE], 0, t_sofa_max, attributes[AUTHOR_CONTACT_ATTR_TYPE]); CLASS_ATTR_SELFSAVE(c, kStrAttr[AUTHOR_CONTACT_ATTR_TYPE], 0); CLASS_ATTR_LABEL(c, kStrAttr[AUTHOR_CONTACT_ATTR_TYPE], 0, "Author Contact"); CLASS_ATTR_SYM(c, kStrAttr[ORGANIZATION_ATTR_TYPE], 0, t_sofa_max, attributes[ORGANIZATION_ATTR_TYPE]); CLASS_ATTR_SELFSAVE(c, kStrAttr[ORGANIZATION_ATTR_TYPE], 0); CLASS_ATTR_LABEL(c, kStrAttr[ORGANIZATION_ATTR_TYPE], 0, "Organization"); CLASS_ATTR_SYM(c, kStrAttr[LICENSE_ATTR_TYPE], 0, t_sofa_max, attributes[LICENSE_ATTR_TYPE]); CLASS_ATTR_DEFAULTNAME_SAVE(c, kStrAttr[LICENSE_ATTR_TYPE], 0, "\"No License provided, ask the author for permission\""); CLASS_ATTR_LABEL(c, kStrAttr[LICENSE_ATTR_TYPE], 0, "License"); CLASS_STICKY_CATEGORY_CLEAR(c); // Optional attributes CLASS_STICKY_CATEGORY(c, 0, "Optional Global Attributes"); CLASS_ATTR_SYM(c, kStrAttr[APPLICATION_NAME_ATTR_TYPE], 0, t_sofa_max, attributes[APPLICATION_NAME_ATTR_TYPE]); CLASS_ATTR_DEFAULTNAME_SAVE(c, kStrAttr[APPLICATION_NAME_ATTR_TYPE], 0, "Max"); CLASS_ATTR_LABEL(c, kStrAttr[APPLICATION_NAME_ATTR_TYPE], 0, "Application Name"); CLASS_ATTR_SYM(c, kStrAttr[APPLICATION_VERSION_ATTR_TYPE], 0, t_sofa_max, attributes[APPLICATION_VERSION_ATTR_TYPE]); CLASS_ATTR_SELFSAVE(c, kStrAttr[APPLICATION_VERSION_ATTR_TYPE], 0); CLASS_ATTR_LABEL(c, kStrAttr[APPLICATION_VERSION_ATTR_TYPE], 0, "Application Version"); CLASS_ATTR_SYM(c, kStrAttr[COMMENT_ATTR_TYPE], 0, t_sofa_max, attributes[COMMENT_ATTR_TYPE]); CLASS_ATTR_SELFSAVE(c, kStrAttr[COMMENT_ATTR_TYPE], 0); CLASS_ATTR_LABEL(c, kStrAttr[COMMENT_ATTR_TYPE], 0, "Comment"); CLASS_ATTR_SYM(c, kStrAttr[HISTORY_ATTR_TYPE], 0, t_sofa_max, attributes[HISTORY_ATTR_TYPE]); CLASS_ATTR_SELFSAVE(c, kStrAttr[HISTORY_ATTR_TYPE], 0); CLASS_ATTR_LABEL(c, kStrAttr[HISTORY_ATTR_TYPE], 0, "History"); CLASS_ATTR_SYM(c, kStrAttr[REFERENCES_ATTR_TYPE], 0, t_sofa_max, attributes[REFERENCES_ATTR_TYPE]); CLASS_ATTR_SELFSAVE(c, kStrAttr[REFERENCES_ATTR_TYPE], 0); CLASS_ATTR_LABEL(c, kStrAttr[REFERENCES_ATTR_TYPE], 0, "References"); CLASS_ATTR_SYM(c, kStrAttr[ORIGIN_ATTR_TYPE], 0, t_sofa_max, attributes[ORIGIN_ATTR_TYPE]); CLASS_ATTR_SELFSAVE(c, kStrAttr[ORIGIN_ATTR_TYPE], 0); CLASS_ATTR_LABEL(c, kStrAttr[ORIGIN_ATTR_TYPE], 0, "Origin"); CLASS_STICKY_CATEGORY_CLEAR(c); // Object attributes CLASS_STICKY_CATEGORY(c, 0, "SOFA Object Attributes"); CLASS_ATTR_SYM(c, kStrAttr[ROOM_SHORTNAME_ATTR_TYPE], 0, t_sofa_max, attributes[ROOM_SHORTNAME_ATTR_TYPE]); CLASS_ATTR_SELFSAVE(c, kStrAttr[ROOM_SHORTNAME_ATTR_TYPE], 0); CLASS_ATTR_LABEL(c, kStrAttr[ROOM_SHORTNAME_ATTR_TYPE], 0, "Room Short Name"); CLASS_ATTR_SYM(c, kStrAttr[ROOM_DESCRIPTION_ATTR_TYPE], 0, t_sofa_max, attributes[ROOM_DESCRIPTION_ATTR_TYPE]); CLASS_ATTR_SELFSAVE(c, kStrAttr[ROOM_DESCRIPTION_ATTR_TYPE], 0); CLASS_ATTR_LABEL(c, kStrAttr[ROOM_DESCRIPTION_ATTR_TYPE], 0, "Room Description"); CLASS_ATTR_SYM(c, kStrAttr[ROOM_LOCATION_ATTR_TYPE], 0, t_sofa_max, attributes[ROOM_LOCATION_ATTR_TYPE]); CLASS_ATTR_SELFSAVE(c, kStrAttr[ROOM_LOCATION_ATTR_TYPE], 0); CLASS_ATTR_LABEL(c, kStrAttr[ROOM_LOCATION_ATTR_TYPE], 0, "Room Location"); CLASS_ATTR_SYM(c, kStrAttr[LISTENER_SHORTNAME_ATTR_TYPE], 0, t_sofa_max, attributes[LISTENER_SHORTNAME_ATTR_TYPE]); CLASS_ATTR_SELFSAVE(c, kStrAttr[LISTENER_SHORTNAME_ATTR_TYPE], 0); CLASS_ATTR_LABEL(c, kStrAttr[LISTENER_SHORTNAME_ATTR_TYPE], 0, "Listener Short Name"); CLASS_ATTR_SYM(c, kStrAttr[LISTENER_DESCRIPTION_ATTR_TYPE], 0, t_sofa_max, attributes[LISTENER_DESCRIPTION_ATTR_TYPE]); CLASS_ATTR_SELFSAVE(c, kStrAttr[LISTENER_DESCRIPTION_ATTR_TYPE], 0); CLASS_ATTR_LABEL(c, kStrAttr[LISTENER_DESCRIPTION_ATTR_TYPE], 0, "Listener Description"); CLASS_ATTR_SYM(c, kStrAttr[SOURCE_SHORTNAME_ATTR_TYPE], 0, t_sofa_max, attributes[SOURCE_SHORTNAME_ATTR_TYPE]); CLASS_ATTR_SELFSAVE(c, kStrAttr[SOURCE_SHORTNAME_ATTR_TYPE], 0); CLASS_ATTR_LABEL(c, kStrAttr[SOURCE_SHORTNAME_ATTR_TYPE], 0, "Source Short Name"); CLASS_ATTR_SYM(c, kStrAttr[SOURCE_DESCRIPTION_ATTR_TYPE], 0, t_sofa_max, attributes[SOURCE_DESCRIPTION_ATTR_TYPE]); CLASS_ATTR_SELFSAVE(c, kStrAttr[SOURCE_DESCRIPTION_ATTR_TYPE], 0); CLASS_ATTR_LABEL(c, kStrAttr[SOURCE_DESCRIPTION_ATTR_TYPE], 0, "Source Description"); CLASS_ATTR_SYM(c, kStrAttr[RECEIVER_SHORTNAME_ATTR_TYPE], 0, t_sofa_max, attributes[RECEIVER_SHORTNAME_ATTR_TYPE]); CLASS_ATTR_SELFSAVE(c, kStrAttr[RECEIVER_SHORTNAME_ATTR_TYPE], 0); CLASS_ATTR_LABEL(c, kStrAttr[RECEIVER_SHORTNAME_ATTR_TYPE], 0, "Receiver Short Name"); CLASS_ATTR_SYM(c, kStrAttr[RECEIVER_DESCRIPTION_ATTR_TYPE], 0, t_sofa_max, attributes[RECEIVER_DESCRIPTION_ATTR_TYPE]); CLASS_ATTR_SELFSAVE(c, kStrAttr[RECEIVER_DESCRIPTION_ATTR_TYPE], 0); CLASS_ATTR_LABEL(c, kStrAttr[RECEIVER_DESCRIPTION_ATTR_TYPE], 0, "Receiver Description"); CLASS_ATTR_SYM(c, kStrAttr[EMITTER_SHORTNAME_ATTR_TYPE], 0, t_sofa_max, attributes[EMITTER_SHORTNAME_ATTR_TYPE]); CLASS_ATTR_SELFSAVE(c, kStrAttr[EMITTER_SHORTNAME_ATTR_TYPE], 0); CLASS_ATTR_LABEL(c, kStrAttr[EMITTER_SHORTNAME_ATTR_TYPE], 0, "Emitter Short Name"); CLASS_ATTR_SYM(c, kStrAttr[EMITTER_DESCRIPTION_ATTR_TYPE], 0, t_sofa_max, attributes[EMITTER_DESCRIPTION_ATTR_TYPE]); CLASS_ATTR_SELFSAVE(c, kStrAttr[EMITTER_DESCRIPTION_ATTR_TYPE], 0); CLASS_ATTR_LABEL(c, kStrAttr[EMITTER_DESCRIPTION_ATTR_TYPE], 0, "Emitter Description"); CLASS_STICKY_CATEGORY_CLEAR(c); class_register(CLASS_BOX, c); sofa_max_class = c; } //////////////////////////////////////////////////////////////////////////////////////////////////// void sofa_max_read(t_sofa_max* x, t_symbol* s) { defer(x, (method)sofa_max_doRead, s, 0, NULL); } void sofa_max_doRead(t_sofa_max* x, t_symbol* s) { t_fourcc filetype = 'NULL'; t_fourcc outtype; short path; char filename[MAX_PATH_CHARS]; if(s == gensym("")) { if(open_dialog(filename, &path, &outtype, &filetype, 0)) { return; } } else { strcpy(filename, s->s_name); object_post((t_object*)x, "%s", filename); if(locatefile_extended(filename, &path, &outtype, &filetype, 0)) { object_error((t_object*)x, "%s: file not found", s->s_name); return; } } unsigned long filenameLength = strlen(filename); if(strcmp(filename + (filenameLength - 4), "sofa")) { object_error((t_object*)x, "%s: %s is not a valid .sofa file", s->s_name, filename); return; } sofa_max_open(x, filename, path); } void sofa_max_open(t_sofa_max* x, char* filename, short path) { t_filehandle fh; if(path_opensysfile(filename, path, &fh, READ_PERM)) { object_error((t_object*)x, "error opening %s", filename); return; } sysfile_close(fh); char fullpath[MAX_PATH_CHARS]; path_toabsolutesystempath(path, filename, fullpath); if(*x->fileLoaded) { csofa_destroySofa(x->sofa); *x->fileLoaded = false; } critical_enter(0); *x->sofa = csofa_openFile(fullpath); critical_exit(0); *x->fileLoaded = true; sofa_max_updateObjectAttributes(x); object_notify((t_object*)x, gensym("sofaread"), 0L); outlet_bang(x->outlet_finishedLoading); } //////////////////////////////////////////////////////////////////////////////////////////////////// void sofa_max_write(t_sofa_max* x, t_symbol* s) { sofa_max_updateSOFAAttributes(x); if(!*x->fileLoaded) { object_error((t_object*)x, "No SOFA data to write"); return; } defer(x, (method)sofa_max_doWrite, s, 0, NULL); } void sofa_max_doWrite(t_sofa_max* x, t_symbol* s) { t_fourcc type = FOUR_CHAR_CODE('NULL'); t_fourcc outtype; char filename[MAX_FILENAME_CHARS]; char fullpath[MAX_PATH_CHARS]; short path; strcpy(filename, "untitled.sofa"); if(s == gensym("")) { if(saveasdialog_extended(filename, &path, &type, &outtype, -1)) { return; } } else { strcpy(filename, s->s_name); path = path_getdefault(); } path_toabsolutesystempath(path, filename, fullpath); critical_enter(0); t_sofaWriteErr err = csofa_writeFile(x->sofa, fullpath); critical_exit(0); switch(err) { case MISSING_ATTR_ERROR: object_error((t_object*)x, "%s: Missing required SOFA attributes. Check these have been filled out in the inspector", s->s_name); break; case GENERAL_WRITE_ERROR: object_error((t_object*)x, "%s: Unable to write SOFA file"); break; default: break; } } //////////////////////////////////////////////////////////////////////////////////////////////////// void sofa_max_create(t_sofa_max* x, t_symbol* s, long argc, t_atom* argv) { t_sofaConvention convention; long M = 1; long R = 1; long E = 1; long N = 1; if(argc < 4) { object_error((t_object*)x, "%s: not enough arguments. Expected at least 4", s->s_name); return; } if(!atomIsANumber(argv)) { object_error((t_object*)x, "%s: convention argument must be an integer", s->s_name); return; } convention = (t_sofaConvention)atom_getlong(argv); argv++; if(!atomIsANumber(argv)) { object_error((t_object*)x, "%s: M dimension argument must be an integer", s->s_name); return; } M = atom_getlong(argv); argv++; if(!atomIsANumber(argv)) { object_error((t_object*)x, "%s: R dimension argument must be an integer", s->s_name); return; } R = atom_getlong(argv); argv++; if(argc > 4) { if(!atomIsANumber(argv)) { object_error((t_object*)x, "%s: E dimension argument must be an integer", s->s_name); return; } if(convention != SOFA_GENERAL_FIRE && convention != SOFA_MULTISPEAKER_BRIR) { object_warn((t_object*)x, "%s: E dimension only required for GeneralFIRE or MultiSpeakerBRIR conventions", s->s_name); } else { E = atom_getlong(argv); } argv++; } if(!atomIsANumber(argv)) { object_error((t_object*)x, "%s: N dimension argument must be an integer", s->s_name); return; } N = atom_getlong(argv); argv++; if(argc > 5) { object_warn((t_object*)x, "extra arguments for message %s", s->s_name); } if(*x->fileLoaded) { csofa_destroySofa(x->sofa); } *x->sofa = csofa_newSofa(M, R, E, N, 44100); switch(convention) { case SOFA_SIMPLE_FREE_FIELD_HRIR: csofa_newSimpleFreeFieldHRIR(x->sofa, M, 0.17); break; default: csofa_newFIR(x->sofa, convention); } csofa_newAttributes(&x->sofa->attr); /////////////////////////////////////// Init attributes //////////////////////////////////////// // Convention char fileConvention[] = "SOFA"; char version[] = "0.6"; csofa_setAttributeValue(&x->sofa->attr, CONVENTIONS_ATTR_TYPE, fileConvention, strlen(fileConvention)); csofa_setAttributeValue(&x->sofa->attr, VERSION_ATTR_TYPE, version, strlen(version)); object_attr_setsym((t_object*)x, gensym(kStrAttr[VERSION_ATTR_TYPE]), gensym(version)); // Application name char appName[] = "Max"; csofa_setAttributeValue(&x->sofa->attr, APPLICATION_NAME_ATTR_TYPE, appName, strlen(appName)); object_attr_setsym((t_object*)x, gensym(kStrAttr[APPLICATION_NAME_ATTR_TYPE]), gensym(appName)); // Application version short maxVersion = maxversion(); short big = (maxVersion >> 8) & 15; short mid = (maxVersion >> 4) & 15; short sub = maxVersion & 15; char appVersion[6]; sprintf(appVersion, "%d.%d.%d", big, mid, sub); csofa_setAttributeValue(&x->sofa->attr, APPLICATION_VERSION_ATTR_TYPE, appVersion, strlen(appVersion)); object_attr_setsym((t_object*)x, gensym(kStrAttr[APPLICATION_VERSION_ATTR_TYPE]), gensym(appVersion)); // SOFA Convention char* strConvention = sofa_getConventionString(convention); char conventionVersion[] = "1.0"; t_symbol* symConvention = gensym(strConvention); t_symbol* symConventionVersion = gensym(conventionVersion); csofa_setAttributeValue(&x->sofa->attr, SOFA_CONVENTION_ATTR_TYPE, strConvention, strlen(strConvention)); csofa_setAttributeValue(&x->sofa->attr, SOFA_CONVENTION_VERSION_ATTR_TYPE, conventionVersion, strlen(conventionVersion)); object_attr_setsym((t_object*)x, gensym(kStrAttr[SOFA_CONVENTION_ATTR_TYPE]), symConvention); object_attr_setsym((t_object*)x, gensym(kStrAttr[SOFA_CONVENTION_VERSION_ATTR_TYPE]), symConventionVersion); // Title char title[] = "Untitled"; csofa_setAttributeValue(&x->sofa->attr, TITLE_ATTR_TYPE, title, strlen(title)); object_attr_setsym((t_object*)x, gensym(kStrAttr[TITLE_ATTR_TYPE]), gensym(title)); // Data type char dataType[] = "FIR"; csofa_setAttributeValue(&x->sofa->attr, DATA_ATTR_TYPE, dataType, strlen(dataType)); object_attr_setsym((t_object*)x, gensym(kStrAttr[DATA_ATTR_TYPE]), gensym(dataType)); // Date created t_datetime dateTime; systime_datetime(&dateTime); char strDateTime[20]; sprintf(strDateTime, "%04d-%02d-%02d %02d:%02d:%02d", dateTime.year, dateTime.month, dateTime.day, dateTime.hour, dateTime.minute, dateTime.second); csofa_setAttributeValue(&x->sofa->attr, DATE_CREATED_ATTR_TYPE, strDateTime, strlen(strDateTime)); object_attr_setsym((t_object*)x, gensym(kStrAttr[DATE_CREATED_ATTR_TYPE]), gensym(strDateTime)); // Date modified systime_datetime(&dateTime); sprintf(strDateTime, "%04d-%02d-%02d %02d:%02d:%02d", dateTime.year, dateTime.month, dateTime.day, dateTime.hour, dateTime.minute, dateTime.second); csofa_setAttributeValue(&x->sofa->attr, DATE_MODIFIED_ATTR_TYPE, strDateTime, strlen(strDateTime)); object_attr_setsym((t_object*)x, gensym(kStrAttr[DATE_MODIFIED_ATTR_TYPE]), gensym(strDateTime)); // API Name and Version char apiName[] = "SOFA for Max"; char apiVersion[] = "0.2"; csofa_setAttributeValue(&x->sofa->attr, API_NAME_ATTR_TYPE, apiName, strlen(apiName)); csofa_setAttributeValue(&x->sofa->attr, API_VERSION_ATTR_TYPE, apiVersion, strlen(apiVersion)); object_attr_setsym((t_object*)x, gensym(kStrAttr[API_NAME_ATTR_TYPE]), gensym(apiName)); object_attr_setsym((t_object*)x, gensym(kStrAttr[API_VERSION_ATTR_TYPE]), gensym(apiVersion)); // License char license[] = "Un-licensed"; csofa_setAttributeValue(&x->sofa->attr, LICENSE_ATTR_TYPE, license, strlen(license)); object_attr_setsym((t_object*)x, gensym(kStrAttr[LICENSE_ATTR_TYPE]), gensym(license)); *x->fileLoaded = true; } //////////////////////////////////////////////////////////////////////////////////////////////////// void sofa_max_getPositions(t_sofa_max* x, t_symbol* s) { if(sofa_max_isFileLoaded(x, gensym("getpositions"))) { sofa_getPositions(x, x->outlet_dump, s); } } void sofa_max_getDimension(t_sofa_max* x, t_symbol* s, long argc, t_atom *argv) { long kNumArgs = 1; if(argc < kNumArgs) { object_error((t_object*)x, "%s: not enough arguments. Expected %d", s->s_name, kNumArgs); return; } if(!sofa_max_isFileLoaded(x, s)) { return; } long dim = 0; if(!atomIsANumber(argv)) { object_error((t_object*)x, "%s: argument not a number", s->s_name); return; } dim = atom_getlong(argv); if(dim < 0 || dim > SOFA_NUM_DIMENSIONS - 1) { return; } if(argc > kNumArgs) { object_warn((t_object*)x, "extra arguments for message \"%s\"", s->s_name); } long size = 0; switch(dim) { case SOFA_M_DIMENSION: size = x->sofa->M; break; case SOFA_R_DIMENSION: size = x->sofa->R; break; case SOFA_E_DIMENSION: size = x->sofa->E; break; case SOFA_N_DIMENSION: size = x->sofa->N; break; case SOFA_S_DIMENSION: size = x->sofa->S; break; } outlet_int(x->outlet_dump, size); } void sofa_max_getSize(t_sofa_max* x) { if(sofa_max_isFileLoaded(x, gensym("getsizesamps"))) { t_atom argv; atom_setlong(&argv, x->sofa->N); outlet_anything(x->outlet_dump, gensym("sizesamps"), 1, &argv); } } void sofa_max_getName(t_sofa_max* x) { t_atom argv; atom_setsym(&argv, x->name); outlet_anything(x->outlet_dump, gensym("name"), 1, &argv); } void sofa_max_get(t_sofa_max* x, t_symbol* s, long argc, t_atom *argv) { // Check arguments if(argc < 1) { object_error((t_object*)x, "%s: not enough arguments, expecting at least 1", s->s_name); return; } if(!isSofaFileOpen((t_object*)x, x, s)) { return; } if(!atomIsANumber(argv)) { object_error((t_object*)x, "%s: data block should be a number", s->s_name); return; } long dataBlock = atom_getlong(argv); if(dataBlock < 0 || dataBlock > (x->sofa->numBlocks - 1)) { return; } argv++; t_symbol* optionalBufferName = NULL; bool optionalBufferIsGiven = false; if(argc > 1) { if(atom_gettype(argv) != A_SYM) { object_error((t_object*)x, "%s: destination buffer name should be a symbol"); return; } optionalBufferIsGiven = true; optionalBufferName = atom_getsym(argv); argv++; } long buffChanOffset = 0; bool optionalBuffChanGiven = false; if(argc > 2) { if(!atomIsANumber(argv)) { object_error((t_object*)x, "%s: buffer channel should be a number", s->s_name); return; } optionalBuffChanGiven = true; buffChanOffset = atom_getlong(argv); argv++; } if(argc > 3) { object_warn((t_object*)x, "extra arguments for message \"%s\"", s->s_name); } // Buffer Operations t_buffer_ref* buffRef = x->buffRef; t_buffer_obj* buffObj; if(optionalBufferIsGiven) { buffRef = buffer_ref_new((t_object*)x, optionalBufferName); if(buffer_ref_exists(buffRef) == 0) { object_error((t_object*)x, "%s: destination buffer \"%s\" does not exist", s->s_name, optionalBufferName->s_name); object_free(buffRef); return; } } else if(buffRef == NULL) { object_error((t_object*)x, "%s: no destination buffer has been set", s->s_name); return; } buffObj = buffer_ref_getobject(buffRef); long numBuffChans = buffer_getchannelcount(buffObj); long numBuffFrames = buffer_getframecount(buffObj); if(optionalBuffChanGiven) { if(buffChanOffset > (numBuffChans - 1) || buffChanOffset < 0 ) { if(optionalBufferIsGiven && buffRef) { object_free(buffRef); } return; } } if(numBuffFrames < x->sofa->N) { object_error((t_object*)x, "%s: destination buffer is too short", s->s_name); if(optionalBufferIsGiven && buffRef) { object_free(buffRef); } return; } // Do extraction double* d = csofa_getDataIR(x->sofa, dataBlock); if(d == NULL) { object_error((t_object*)x, "%s: data extraction was unsuccesful", s->s_name); if(optionalBufferIsGiven && buffRef) { object_free(buffRef); } return; } float* buffData = buffer_locksamples(buffObj); long buffIndex = 0; long N = x->sofa->N; if(buffData) { for(long i = 0; i < N; ++i) { buffIndex = (i * numBuffChans) + buffChanOffset; buffData[buffIndex] = d[i]; } buffer_unlocksamples(buffObj); buffer_setdirty(buffObj); } else { buffer_unlocksamples(buffObj); } if(optionalBufferIsGiven && buffRef) { object_free(buffRef); } } void sofa_max_updateObjectAttributes(t_sofa_max* x) { t_symbol* c; t_symbol* s; for(long i = 0; i < NUM_ATTR_TYPES; ++i) { s = gensym(kStrAttr[i]); c = gensym(x->sofa->attr.values[i]); object_attr_setsym((t_object*)x, s, c); } } void sofa_max_updateSOFAAttributes(t_sofa_max* x) { t_symbol* s; for(long i = 0; i < NUM_ATTR_TYPES; ++i) { s = object_attr_getsym((t_object*)x, gensym(kStrAttr[i])); if(s) { if(s->s_name) { csofa_setAttributeValue(&x->sofa->attr, (t_sofaAttributeTypes)i, s->s_name, strlen(s->s_name)); } } } } bool sofa_max_isFileLoaded(t_sofa_max* x, t_symbol* s) { if(!*x->fileLoaded) { object_error((t_object*) x, "%s: no SOFA file open", s->s_name); return false; } return true; } void sofa_max_assist(t_sofa_max *x, void *b, long m, long a, char *s) { if (m == ASSIST_INLET) { switch(a) { case 0: sprintf(s, "(anything) Message inlet"); break; } } else { switch(a) { case 0: sprintf(s, "Dump out"); break; case 1: sprintf(s, "(bang) File read complete"); break; } } } void sofa_max_free(t_sofa_max *x) { if(x->count) { if(*x->count) { *x->count -= 1; } if(*x->count < 1) { if(*x->fileLoaded) { csofa_destroySofa(x->sofa); *x->fileLoaded = false; } sysmem_freeptr(x->sofa); sysmem_freeptr(x->fileLoaded); sysmem_freeptr(x->count); globalsymbol_unbind((t_object*)x, x->name->s_name, 0); object_unregister(x); } } } void *sofa_max_new(t_symbol *s, long argc, t_atom *argv) { t_sofa_max *x = NULL; t_symbol* a; if((x = (t_sofa_max *)object_alloc((t_class*)sofa_max_class))) { a = symbol_unique(); x->sofa = (t_sofa*)sysmem_newptr(sizeof(t_sofa)); x->fileLoaded = (bool*)sysmem_newptr(sizeof(bool)); x->count = (long*)sysmem_newptr(sizeof(long)); *x->fileLoaded = false; *x->count = 1; if(argc) { if(argv->a_type == A_SYM) { a = atom_getsym(argv); t_sofa_max* ref = (t_sofa_max*)globalsymbol_reference((t_object*)x, a->s_name, "sofa~"); if(ref != NULL) { /*sysmem_freeptr(x->sofa); sysmem_freeptr(x->fileLoaded); sysmem_freeptr(x->count); x->sofa = ref->sofa; x->fileLoaded = ref->fileLoaded; x->count = ref->count; if(x->count) { *x->count += 1; }*/ sysmem_freeptr(x->sofa); sysmem_freeptr(x->fileLoaded); sysmem_freeptr(x->count); object_error((t_object*)x, "Only 1 sofa~ named %s can currently exist", a->s_name); return NULL; } else { //a->s_thing = (t_object*)x; object_register(APL_SOFA_NAMESPACE, a, x); globalsymbol_bind((t_object*)x, a->s_name, 0); } } } else { //a->s_thing = (t_object*)x; object_register(APL_SOFA_NAMESPACE, a, x); globalsymbol_bind((t_object*)x, a->s_name, 0); } x->name = a; x->outlet_finishedLoading = bangout((t_object *)x); x->outlet_dump = outlet_new((t_object*)x, NULL); } return (x); }
37.094545
118
0.622586
[ "object" ]
80ebf7cef05b6c7e97e854a6294d66e398e8185b
486
h
C
metadata.h
Izhido/test262_harness_cpp
9c42d878ac735081f9db5bd6dd51c0ec17df67ea
[ "MIT" ]
4
2018-08-21T14:53:47.000Z
2021-03-01T20:40:43.000Z
metadata.h
Izhido/test262_harness_cpp
9c42d878ac735081f9db5bd6dd51c0ec17df67ea
[ "MIT" ]
null
null
null
metadata.h
Izhido/test262_harness_cpp
9c42d878ac735081f9db5bd6dd51c0ec17df67ea
[ "MIT" ]
3
2020-05-18T05:36:53.000Z
2021-07-05T05:57:12.000Z
#pragma once #include <string> #include <vector> namespace test262_harness_cpp { struct metadata { bool is_negative = false; std::string negative_phase; std::string negative_type; std::vector<std::string> includes; bool only_strict = false; bool no_strict = false; bool module = false; bool raw = false; bool async = false; void get_metadata(std::string& contents); }; }
18
49
0.578189
[ "vector" ]
a7f74628c29ff283bedc58cdd28a7fdd8f917231
518
c
C
03_Third/transformDescription.c
estarpro1022/C-Modern-Method
b49bb3173925d9ee9a1d94036236387c678d4999
[ "Apache-2.0" ]
null
null
null
03_Third/transformDescription.c
estarpro1022/C-Modern-Method
b49bb3173925d9ee9a1d94036236387c678d4999
[ "Apache-2.0" ]
null
null
null
03_Third/transformDescription.c
estarpro1022/C-Modern-Method
b49bb3173925d9ee9a1d94036236387c678d4999
[ "Apache-2.0" ]
null
null
null
// Created by estar on 2022/1/29. #include <stdio.h> int main() { int a = 10, b = 10000000; float c = 3.0f, d = 10000000.0f; double e = 0.000011; // printf("%4.3d\n", a); // printf("%lf\n", e); // printf("%g\n==========\n", e); // printf("%f\n", c); // printf("%f\n", d); printf("hello"); scanf("%d", &a); printf("Item\tUnit\tPurchase\n\tPrice\tDate\n"); printf("\"hello\"\n"); printf("\\\n"); float a1; scanf("%f", &a1); printf("%f\n", a1); return 0; }
22.521739
52
0.476834
[ "3d" ]
a7f8d7e0eb5d47cac546283aabf739a7405051fc
6,888
c
C
heimdallr-terminal-emu.c
amzy-0/heimdallr
de5460bef7da283b80423a994f194b7d4c2aa6d4
[ "Apache-2.0" ]
16
2021-02-25T02:38:38.000Z
2021-12-06T04:39:58.000Z
heimdallr-terminal-emu.c
amzy-0/heimdallr
de5460bef7da283b80423a994f194b7d4c2aa6d4
[ "Apache-2.0" ]
1
2021-02-25T23:16:09.000Z
2021-02-25T23:16:09.000Z
heimdallr-terminal-emu.c
amzy-0/heimdallr
de5460bef7da283b80423a994f194b7d4c2aa6d4
[ "Apache-2.0" ]
2
2021-02-25T06:55:25.000Z
2021-03-26T03:22:02.000Z
/* * HEIMDALLR: * Copyright [2021] [M.Amin Azimi .K (amzy-0)] * * 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. * @author(s) : amzy-0 (Mohammad Amin Azimi .K) */ #include<stdio.h> #include<stdlib.h> #include<string.h> #include<strings.h> #include<sys/unistd.h> #include<vte/vte.h> #include<gtk/gtk.h> GtkWidget *win, *terminal, *first_box_terminal, *second_box_terminal, *third_box_terminal, *url_exec_btn_firefox, *url_exec_btn_chrome, *url_label, *url_entry; static void child_ready(VteTerminal *terminal, GPid pid, GError *error, gpointer user_data) { if (!terminal) return; if (pid == -1) gtk_main_quit(); } /* go to goto firefox */ static void open_url_firefox(void){ const gchar *entry = gtk_entry_get_text(GTK_ENTRY(url_entry)); const char *browser = "firefox "; const int len_of_browser = strlen(browser); const int len_of_entry = gtk_entry_get_text_length(GTK_ENTRY(url_entry)); const int finally_length = len_of_entry+len_of_browser+2; char *url_merge_with_brw = (char*)malloc(finally_length*sizeof(char)); g_print("%s <->%s\n", entry, browser); strcpy(url_merge_with_brw, browser); strcat(url_merge_with_brw, entry); strcat(url_merge_with_brw, "&"); if( (system(url_merge_with_brw) )!=0){ system("notify-send \"firefox command not found !\"&"); } free(url_merge_with_brw); } /* go to goto google chrome */ static void open_url_chrome(void){ const gchar *entry = gtk_entry_get_text(GTK_ENTRY(url_entry)); const char *browser = "google-chrome "; const int len_of_browser = strlen(browser); const int len_of_entry = gtk_entry_get_text_length(GTK_ENTRY(url_entry)); const int finally_length = len_of_entry+len_of_browser+2; char *url_merge_with_brw = (char*)malloc(finally_length*sizeof(char)); g_print("%s <-> %s \n", entry, browser); strcpy(url_merge_with_brw, browser); strcat(url_merge_with_brw, entry); strcat(url_merge_with_brw, "&"); if( (system(url_merge_with_brw) )!=0){ system("notify-send \"google-chrome command not found !\"&"); } free(url_merge_with_brw); } // int main initialization int main(int argc, char *argv[]) { // client home address char *home_addr = getenv("HOME"); char *logo_addr = "/.heimdallr/icon/heimdallr.png"; int home_addr_len = strlen(home_addr); int logo_addr_len = strlen(logo_addr); int finally_len = home_addr_len + logo_addr_len+1; /* icon path */ char *path = (char*)malloc(finally_len*sizeof(char)); strcpy(path, home_addr); strcat(path, logo_addr); /* create all widget */ /* initialize GTK, the window and the terminal */ gtk_init(&argc, &argv); // terminal instance and configuration terminal = vte_terminal_new(); vte_terminal_set_font_scale(VTE_TERMINAL(terminal), 1.3); // window instance win = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(win), "Heimdallr"); gtk_window_set_icon_from_file(GTK_WINDOW(win), path, NULL); /* go to all standard directories GUI */ url_exec_btn_firefox = gtk_button_new_with_label("firefox"); url_exec_btn_chrome = gtk_button_new_with_label("google chrome"); url_label = gtk_label_new("Enter your URL : "); url_entry = gtk_entry_new(); /* main boxes of terminal */ first_box_terminal = gtk_box_new(TRUE, 0); second_box_terminal = gtk_box_new(FALSE, 0); third_box_terminal = gtk_box_new(TRUE, 0); /* Start a new shell */ gchar **envp = g_get_environ(); gchar **command = (gchar *[]){g_strdup(g_environ_getenv(envp, "SHELL")), NULL }; g_strfreev(envp); vte_terminal_spawn_async(VTE_TERMINAL(terminal), VTE_PTY_DEFAULT, home_addr, /* working directory */ command, /* command */ NULL, /* environment */ 2, /* spawn flags */ NULL, NULL, /* child setup */ NULL, /* child pid */ -1, /* timeout */ NULL, /* cancellable */ child_ready, /* callback */ NULL); /* user_data */ /* Connect some signals */ g_signal_connect(win, "destroy", gtk_main_quit, NULL); g_signal_connect(terminal, "child-exited", gtk_main_quit, NULL); g_signal_connect(G_OBJECT(url_exec_btn_firefox), "clicked", G_CALLBACK(open_url_firefox), (gpointer)win ); g_signal_connect(G_OBJECT(url_exec_btn_chrome), "clicked", G_CALLBACK(open_url_chrome), (gpointer)win ); /* * add terminal to the first box (Main Box) */ gtk_box_pack_start(GTK_BOX(first_box_terminal), terminal, TRUE, TRUE, 0 ); /* * combine two box (first_box_terminal and second_box_terminal) */ gtk_box_pack_end(GTK_BOX(first_box_terminal), second_box_terminal, FALSE, FALSE, 0); /* * add third box to the first box (Main Box) */ gtk_box_pack_end(GTK_BOX(first_box_terminal), third_box_terminal, FALSE, FALSE, 0); /* * url exec button for firefox (GUI) */ gtk_box_pack_end(GTK_BOX(second_box_terminal), url_exec_btn_firefox, TRUE, TRUE, 4); /* * url exec button for google chrome (GUI) */ gtk_box_pack_end(GTK_BOX(second_box_terminal), url_exec_btn_chrome, TRUE, TRUE, 4); ////////////////////////////////third box///////////////////////////////////////// /* * add search label to the third box */ gtk_box_pack_start(GTK_BOX(third_box_terminal), url_label, FALSE, FALSE, 4); /* * add search entry to the third box */ gtk_box_pack_start(GTK_BOX(third_box_terminal), url_entry, TRUE, FALSE, 4); /* * maximize heimdallr terminal * you can comment this section * if you dont want to maximize your heimdallr terminal * and you can modify size or ... * NEXT STEP : Put widgets together and run the main loop */ gtk_container_add(GTK_CONTAINER(win), first_box_terminal); const char *text_url = gtk_entry_get_text(GTK_ENTRY(url_entry)); /* * render all */ // URL entry get text free(path); gtk_widget_show_all(win); gtk_main(); return 0; }
28.820084
91
0.644744
[ "render" ]
c50a2dbd0228bea835aaf479cc1e1b4347898b8c
1,689
h
C
src/html/html_li_element.h
prepare/netsurf_libdom
62849e6851925a55817f68601fa69b3727422b40
[ "MIT" ]
null
null
null
src/html/html_li_element.h
prepare/netsurf_libdom
62849e6851925a55817f68601fa69b3727422b40
[ "MIT" ]
null
null
null
src/html/html_li_element.h
prepare/netsurf_libdom
62849e6851925a55817f68601fa69b3727422b40
[ "MIT" ]
null
null
null
/* * This file is part of libdom. * Licensed under the MIT License, * http://www.opensource.org/licenses/mit-license.php * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com> * Copyright 2014 Rupinder Singh Khokhar <rsk1coder99@gmail.com> */ #ifndef dom_internal_html_li_element_h_ #define dom_internal_html_li_element_h_ #include <dom/html/html_li_element.h> #include "html/html_element.h" struct dom_html_li_element { struct dom_html_element base; /**< The base class */ }; /* Create a dom_html_li_element object */ dom_exception _dom_html_li_element_create(struct dom_html_document *doc, dom_string *namespace, dom_string *lifix, struct dom_html_li_element **ele); /* Initialise a dom_html_li_element object */ dom_exception _dom_html_li_element_initialise(struct dom_html_document *doc, dom_string *namespace, dom_string *lifix, struct dom_html_li_element *ele); /* Finalise a dom_html_li_element object */ void _dom_html_li_element_finalise(struct dom_html_li_element *ele); /* Destroy a dom_html_li_element object */ void _dom_html_li_element_destroy(struct dom_html_li_element *ele); /* The protected virtual functions */ dom_exception _dom_html_li_element_parse_attribute(dom_element *ele, dom_string *name, dom_string *value, dom_string **parsed); void _dom_virtual_html_li_element_destroy(dom_node_internal *node); dom_exception _dom_html_li_element_copy(dom_node_internal *old, dom_node_internal **copy); #define DOM_HTML_LI_ELEMENT_PROTECT_VTABLE \ _dom_html_li_element_parse_attribute #define DOM_NODE_PROTECT_VTABLE_HTML_LI_ELEMENT \ _dom_virtual_html_li_element_destroy, \ _dom_html_li_element_copy #endif
31.867925
76
0.799882
[ "object" ]
c5102ef8b4258ba2fbe64f1fa26d3d1f2a17f1b3
373
h
C
SDK/IJSPhotoSDK/Controllers/IJS3DTouchController.h
wangjinshan/IJSPhotoSDK
b1c696641f85793e5146f49a86aa3246f33d8a5b
[ "MIT" ]
142
2017-07-11T01:56:46.000Z
2022-02-10T07:05:18.000Z
AssetsSelect/Lib/QSAssetsSelect/SDK/IJSPhotoSDK/Controllers/IJS3DTouchController.h
Qson8/QSAssetsSelect
5cbd7a45c1a93b6e79662f74f173d386ca4e33dd
[ "MIT" ]
12
2017-09-16T08:39:36.000Z
2020-07-08T08:52:01.000Z
IJSPhotoSDKProject/SDK/Core/IJSPhotoSDK/Controllers/IJS3DTouchController.h
wangjinshan/IJSPhotoSDK
b1c696641f85793e5146f49a86aa3246f33d8a5b
[ "MIT" ]
17
2017-10-22T15:03:32.000Z
2021-02-08T03:27:45.000Z
// // IJS3DTouchController.h // JSPhotoSDK // // Created by shan on 2017/6/24. // Copyright © 2017年 shan. All rights reserved. // #import <UIKit/UIKit.h> #import "IJSAssetModel.h" /* * 3DTouch控制器 */ @interface IJS3DTouchController : UIViewController /* 模型数据 */ @property (nonatomic, strong) IJSAssetModel *model; @end // 日志 /* 0.1.2 考虑到内存性能问题,暂时不使用3DTouch */
13.814815
51
0.680965
[ "model" ]
c52934da026ae8f4caa101afb673c279c838f9f3
17,871
h
C
Engine/Source/Runtime/UMG/Public/Components/WidgetComponent.h
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
1
2022-01-29T18:36:12.000Z
2022-01-29T18:36:12.000Z
Engine/Source/Runtime/UMG/Public/Components/WidgetComponent.h
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
null
null
null
Engine/Source/Runtime/UMG/Public/Components/WidgetComponent.h
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
null
null
null
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "UObject/ObjectMacros.h" #include "Templates/SubclassOf.h" #include "Layout/ArrangedWidget.h" #include "WorldCollision.h" #include "Components/MeshComponent.h" #include "Blueprint/UserWidget.h" #include "WidgetComponent.generated.h" class FHittestGrid; class FPrimitiveSceneProxy; class FWidgetRenderer; class SVirtualWindow; class SWindow; class UBodySetup; class UMaterialInstanceDynamic; class UTextureRenderTarget2D; UENUM(BlueprintType) enum class EWidgetSpace : uint8 { /** The widget is rendered in the world as mesh, it can be occluded like any other mesh in the world. */ World, /** The widget is rendered in the screen, completely outside of the world, never occluded. */ Screen }; UENUM(BlueprintType) enum class EWidgetTimingPolicy : uint8 { /** The widget will tick using real time. When not ticking, real time will accumulate and be simulated on the next tick. */ RealTime, /** The widget will tick using game time, respecting pausing and time dilation. */ GameTime }; UENUM(BlueprintType) enum class EWidgetBlendMode : uint8 { Opaque, Masked, Transparent }; UENUM() enum class EWidgetGeometryMode : uint8 { /** The widget is mapped onto a plane */ Plane, /** The widget is mapped onto a cylinder */ Cylinder }; /** * The widget component provides a surface in the 3D environment on which to render widgets normally rendered to the screen. * Widgets are first rendered to a render target, then that render target is displayed in the world. * * Material Properties set by this component on whatever material overrides the default. * SlateUI [Texture] * BackColor [Vector] * TintColorAndOpacity [Vector] * OpacityFromTexture [Scalar] */ UCLASS(Blueprintable, ClassGroup="UserInterface", hidecategories=(Object,Activation,"Components|Activation",Sockets,Base,Lighting,LOD,Mesh), editinlinenew, meta=(BlueprintSpawnableComponent) ) class UMG_API UWidgetComponent : public UMeshComponent { GENERATED_UCLASS_BODY() public: /** UActorComponent Interface */ virtual void EndPlay(const EEndPlayReason::Type EndPlayReason); /* UPrimitiveComponent Interface */ virtual FPrimitiveSceneProxy* CreateSceneProxy() override; virtual FBoxSphereBounds CalcBounds(const FTransform & LocalToWorld) const override; virtual UBodySetup* GetBodySetup() override; virtual FCollisionShape GetCollisionShape(float Inflation) const override; virtual void OnRegister() override; virtual void OnUnregister() override; virtual void DestroyComponent(bool bPromoteChildren = false) override; UMaterialInterface* GetMaterial(int32 MaterialIndex) const override; int32 GetNumMaterials() const override; virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override; virtual FActorComponentInstanceData* GetComponentInstanceData() const override; void ApplyComponentInstanceData(class FWidgetComponentInstanceData* ComponentInstanceData); virtual void GetUsedMaterials(TArray<UMaterialInterface*>& OutMaterials, bool bGetDebugMaterials = false) const override; #if WITH_EDITOR virtual bool CanEditChange(const UProperty* InProperty) const override; virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override; #endif /** Ensures the user widget is initialized */ virtual void InitWidget(); /** Release resources associated with the widget. */ virtual void ReleaseResources(); /** Ensures the 3d window is created its size and content. */ virtual void UpdateWidget(); /** Ensure the render target is initialized and updates it if needed. */ virtual void UpdateRenderTarget(FIntPoint DesiredRenderTargetSize); /** * Ensures the body setup is initialized and updates it if needed. * @param bDrawSizeChanged Whether the draw size of this component has changed since the last update call. */ void UpdateBodySetup( bool bDrawSizeChanged = false ); /** * Converts a world-space hit result to a hit location on the widget * @param HitResult The hit on this widget in the world * @param (Out) The transformed 2D hit location on the widget */ virtual void GetLocalHitLocation(FVector WorldHitLocation, FVector2D& OutLocalHitLocation) const; /** * When using EWidgetGeometryMode::Cylinder, continues the trace from the front face * of the widget component into the cylindrical geometry and returns adjusted hit results information. * * @returns two hit locations FVector is in world space and a FVector2D is in widget-space. */ TTuple<FVector, FVector2D> GetCylinderHitLocation(FVector WorldHitLocation, FVector WorldHitDirection) const; /** @return Gets the last local location that was hit */ FVector2D GetLastLocalHitLocation() const { return LastLocalHitLocation; } /** @return The class of the user widget displayed by this component */ TSubclassOf<UUserWidget> GetWidgetClass() const { return WidgetClass; } /** @return The user widget object displayed by this component */ UFUNCTION(BlueprintCallable, Category=UserInterface, meta=(UnsafeDuringActorConstruction=true)) UUserWidget* GetUserWidgetObject() const; /** @return Returns the Slate widget that was assigned to this component, if any */ const TSharedPtr<SWidget>& GetSlateWidget() const; /** @return List of widgets with their geometry and the cursor position transformed into this Widget component's space. */ TArray<FWidgetAndPointer> GetHitWidgetPath(FVector WorldHitLocation, bool bIgnoreEnabledStatus, float CursorRadius = 0.0f); /** @return List of widgets with their geometry and the cursor position transformed into this Widget space. The widget space is expressed as a Vector2D. */ TArray<FWidgetAndPointer> GetHitWidgetPath(FVector2D WidgetSpaceHitCoordinate, bool bIgnoreEnabledStatus, float CursorRadius = 0.0f); /** @return The render target to which the user widget is rendered */ UFUNCTION(BlueprintCallable, Category=UserInterface) UTextureRenderTarget2D* GetRenderTarget() const; /** @return The dynamic material instance used to render the user widget */ UFUNCTION(BlueprintCallable, Category=UserInterface) UMaterialInstanceDynamic* GetMaterialInstance() const; /** @return The window containing the user widget content */ TSharedPtr<SWindow> GetSlateWindow() const; /** * Sets the widget to use directly. This function will keep track of the widget till the next time it's called * with either a newer widget or a nullptr */ UFUNCTION(BlueprintCallable, Category=UserInterface) virtual void SetWidget(UUserWidget* Widget); /** * Sets a Slate widget to be rendered. You can use this to draw native Slate widgets using a WidgetComponent, instead * of drawing user widgets. */ virtual void SetSlateWidget( const TSharedPtr<SWidget>& InSlateWidget); /** * Sets the local player that owns this widget component. Setting the owning player controls * which player's viewport the widget appears on in a split screen scenario. Additionally it * forwards the owning player to the actual UserWidget that is spawned. */ UFUNCTION(BlueprintCallable, Category=UserInterface) void SetOwnerPlayer(ULocalPlayer* LocalPlayer); /** Gets the local player that owns this widget component. */ UFUNCTION(BlueprintCallable, Category=UserInterface) ULocalPlayer* GetOwnerPlayer() const; /** @return The draw size of the quad in the world */ UFUNCTION(BlueprintCallable, Category=UserInterface) FVector2D GetDrawSize() const; /** Sets the draw size of the quad in the world */ UFUNCTION(BlueprintCallable, Category=UserInterface) void SetDrawSize(FVector2D Size); /** Requests that the widget be redrawn. */ UFUNCTION(BlueprintCallable, Category=UserInterface) virtual void RequestRedraw(); /** Gets the blend mode for the widget. */ EWidgetBlendMode GetBlendMode() const { return BlendMode; } /** Sets the blend mode to use for this widget */ void SetBlendMode( const EWidgetBlendMode NewBlendMode ); /** Sets whether the widget is two-sided or not */ void SetTwoSided( const bool bWantTwoSided ); /** Sets the background color and opacityscale for this widget */ UFUNCTION(BlueprintCallable, Category=UserInterface) void SetBackgroundColor( const FLinearColor NewBackgroundColor ); /** Sets the tint color and opacity scale for this widget */ UFUNCTION(BlueprintCallable, Category=UserInterface) void SetTintColorAndOpacity( const FLinearColor NewTintColorAndOpacity ); /** Sets how much opacity from the UI widget's texture alpha is used when rendering to the viewport (0.0-1.0) */ void SetOpacityFromTexture( const float NewOpacityFromTexture ); /** @return The pivot point where the UI is rendered about the origin. */ FVector2D GetPivot() const { return Pivot; } /** */ void SetPivot( const FVector2D& InPivot ) { Pivot = InPivot; } /** */ bool GetDrawAtDesiredSize() const { return bDrawAtDesiredSize; } /** */ void SetDrawAtDesiredSize(bool InbDrawAtDesiredSize) { bDrawAtDesiredSize = InbDrawAtDesiredSize; } /** */ float GetRedrawTime() const { return RedrawTime; } /** */ void SetRedrawTime(float bInRedrawTime) { RedrawTime = bInRedrawTime; } /** Get the fake window we create for widgets displayed in the world. */ TSharedPtr< SWindow > GetVirtualWindow() const; /** Updates the dynamic parameters on the material instance, without re-creating it */ void UpdateMaterialInstanceParameters(); /** Sets the widget class used to generate the widget for this component */ void SetWidgetClass(TSubclassOf<UUserWidget> InWidgetClass); EWidgetSpace GetWidgetSpace() const { return Space; } void SetWidgetSpace( EWidgetSpace NewSpace ) { Space = NewSpace; } bool GetEditTimeUsable() const { return bEditTimeUsable; } void SetEditTimeUsable(bool Value) { bEditTimeUsable = Value; } /** @see EWidgetGeometryMode, @see GetCylinderArcAngle() */ EWidgetGeometryMode GetGeometryMode() const { return GeometryMode; } bool GetReceiveHardwareInput() const { return bReceiveHardwareInput; } /** Defines the curvature of the widget component when using EWidgetGeometryMode::Cylinder; ignored otherwise. */ float GetCylinderArcAngle() const { return CylinderArcAngle; } protected: /** Just because the user attempts to receive hardware input does not mean it's possible. */ bool CanReceiveHardwareInput() const; void RegisterHitTesterWithViewport(TSharedPtr<SViewport> ViewportWidget); void UnregisterHitTesterWithViewport(TSharedPtr<SViewport> ViewportWidget); void RegisterWindow(); void UnregisterWindow(); void RemoveWidgetFromScreen(); /** Allows subclasses to control if the widget should be drawn. Called right before we draw the widget. */ virtual bool ShouldDrawWidget() const; /** Draws the current widget to the render target if possible. */ virtual void DrawWidgetToRenderTarget(float DeltaTime); /** @return the width of the widget component taking GeometryMode into account. */ float ComputeComponentWidth() const; protected: /** The coordinate space in which to render the widget */ UPROPERTY(EditAnywhere, Category=UserInterface) EWidgetSpace Space; /** How this widget should deal with timing, pausing, etc. */ UPROPERTY(EditAnywhere, Category=UserInterface) EWidgetTimingPolicy TimingPolicy; /** The class of User Widget to create and display an instance of */ UPROPERTY(EditAnywhere, Category=UserInterface) TSubclassOf<UUserWidget> WidgetClass; /** The size of the displayed quad. */ UPROPERTY(EditAnywhere, Category=UserInterface) FIntPoint DrawSize; /** Should we wait to be told to redraw to actually draw? */ UPROPERTY(EditAnywhere, Category=UserInterface) bool bManuallyRedraw; /** Has anyone requested we redraw? */ UPROPERTY() bool bRedrawRequested; /** * The time in between draws, if 0 - we would redraw every frame. If 1, we would redraw every second. * This will work with bManuallyRedraw as well. So you can say, manually redraw, but only redraw at this * maximum rate. */ UPROPERTY(EditAnywhere, Category=UserInterface) float RedrawTime; /** What was the last time we rendered the widget? */ double LastWidgetRenderTime; /** Returns current absolute time, respecting TimingPolicy. */ double GetCurrentTime() const; /** * The actual draw size, this changes based on DrawSize - or the desired size of the widget if * bDrawAtDesiredSize is true. */ UPROPERTY() FIntPoint CurrentDrawSize; /** * Causes the render target to automatically match the desired size. * * WARNING: If you change this every frame, it will be very expensive. If you need * that effect, you should keep the outer widget's sized locked and dynamically * scale or resize some inner widget. */ UPROPERTY(EditAnywhere, Category=UserInterface) bool bDrawAtDesiredSize; /** The Alignment/Pivot point that the widget is placed at relative to the position. */ UPROPERTY(EditAnywhere, Category=UserInterface) FVector2D Pivot; /** * Register with the viewport for hardware input from the true mouse and keyboard. These widgets * will more or less react like regular 2D widgets in the viewport, e.g. they can and will steal focus * from the viewport. * * WARNING: If you are making a VR game, definitely do not change this to true. This option should ONLY be used * if you're making what would otherwise be a normal menu for a game, just in 3D. If you also need the game to * remain responsive and for the player to be able to interact with UI and move around the world (such as a keypad on a door), * use the WidgetInteractionComponent instead. */ UPROPERTY(EditAnywhere, Category=Interaction) bool bReceiveHardwareInput; /** Is the virtual window created to host the widget focusable? */ UPROPERTY(EditAnywhere, Category=Interaction) bool bWindowFocusable; /** * The owner player for a widget component, if this widget is drawn on the screen, this controls * what player's screen it appears on for split screen, if not set, users player 0. */ UPROPERTY() ULocalPlayer* OwnerPlayer; /** The background color of the component */ UPROPERTY(EditAnywhere, Category=Rendering) FLinearColor BackgroundColor; /** Tint color and opacity for this component */ UPROPERTY(EditAnywhere, Category=Rendering) FLinearColor TintColorAndOpacity; /** Sets the amount of opacity from the widget's UI texture to use when rendering the translucent or masked UI to the viewport (0.0-1.0) */ UPROPERTY(EditAnywhere, Category=Rendering, meta=(ClampMin=0.0f, ClampMax=1.0f)) float OpacityFromTexture; /** The blend mode for the widget. */ UPROPERTY(EditAnywhere, Category=Rendering) EWidgetBlendMode BlendMode; /** Is the component visible from behind? */ UPROPERTY(EditAnywhere, Category=Rendering) bool bIsTwoSided; /** Should the component tick the widget when it's off screen? */ UPROPERTY(EditAnywhere, Category=Animation) bool TickWhenOffscreen; /** The User Widget object displayed and managed by this component */ UPROPERTY(Transient, DuplicateTransient) UUserWidget* Widget; /** The Slate widget to be displayed by this component. Only one of either Widget or SlateWidget can be used */ TSharedPtr<SWidget> SlateWidget; /** The slate widget currently being drawn. */ TWeakPtr<SWidget> CurrentSlateWidget; /** The body setup of the displayed quad */ UPROPERTY(Transient, DuplicateTransient) class UBodySetup* BodySetup; /** The material instance for translucent widget components */ UPROPERTY() UMaterialInterface* TranslucentMaterial; /** The material instance for translucent, one-sided widget components */ UPROPERTY() UMaterialInterface* TranslucentMaterial_OneSided; /** The material instance for opaque widget components */ UPROPERTY() UMaterialInterface* OpaqueMaterial; /** The material instance for opaque, one-sided widget components */ UPROPERTY() UMaterialInterface* OpaqueMaterial_OneSided; /** The material instance for masked widget components. */ UPROPERTY() UMaterialInterface* MaskedMaterial; /** The material instance for masked, one-sided widget components. */ UPROPERTY() UMaterialInterface* MaskedMaterial_OneSided; /** The target to which the user widget is rendered */ UPROPERTY(Transient, DuplicateTransient) UTextureRenderTarget2D* RenderTarget; /** The dynamic instance of the material that the render target is attached to */ UPROPERTY(Transient, DuplicateTransient) UMaterialInstanceDynamic* MaterialInstance; UPROPERTY(Transient, DuplicateTransient) bool bAddedToScreen; /** * Allows the widget component to be used at editor time. For use in the VR-Editor. */ UPROPERTY() bool bEditTimeUsable; protected: /** Layer Name the widget will live on */ UPROPERTY(EditDefaultsOnly, Category = Layers) FName SharedLayerName; /** ZOrder the layer will be created on, note this only matters on the first time a new layer is created, subsequent additions to the same layer will use the initially defined ZOrder */ UPROPERTY(EditDefaultsOnly, Category = Layers) int32 LayerZOrder; /** Controls the geometry of the widget component. See EWidgetGeometryMode. */ UPROPERTY(EditAnywhere, Category=UserInterface) EWidgetGeometryMode GeometryMode; /** Curvature of a cylindrical widget in degrees. */ UPROPERTY(EditAnywhere, Category=UserInterface, meta=(ClampMin=1.0f, ClampMax=180.0f)) float CylinderArcAngle; /** The slate window that contains the user widget content */ TSharedPtr<class SVirtualWindow> SlateWindow; /** The relative location of the last hit on this component */ FVector2D LastLocalHitLocation; /** The hit tester to use for this component */ static TSharedPtr<class FWidget3DHitTester> WidgetHitTester; /** Helper class for drawing widgets to a render target. */ TSharedPtr<class FWidgetRenderer> WidgetRenderer; };
37.308977
192
0.770858
[ "mesh", "geometry", "render", "object", "vector", "3d" ]
c532838763676f6d4e2de954923539db4a41cf63
2,197
h
C
cvc3/src/include/cdflags.h
kencheung/js-symbolic-executor
18266513cc9bc885434890c8612aa26f0e2eab8b
[ "Apache-2.0" ]
5
2015-10-11T08:32:50.000Z
2019-02-01T22:59:18.000Z
cvc3/src/include/cdflags.h
kencheung/js-symbolic-executor
18266513cc9bc885434890c8612aa26f0e2eab8b
[ "Apache-2.0" ]
null
null
null
cvc3/src/include/cdflags.h
kencheung/js-symbolic-executor
18266513cc9bc885434890c8612aa26f0e2eab8b
[ "Apache-2.0" ]
null
null
null
/*****************************************************************************/ /*! *\file cdflags.h *\brief Context Dependent Vector of Flags * * Author: Clark Barrett * * Created: Thu Jan 26 16:37:46 2006 * * <hr> * * License to use, copy, modify, sell and/or distribute this software * and its documentation for any purpose is hereby granted without * royalty, subject to the terms and conditions defined in the \ref * LICENSE file provided with this distribution. * * <hr> * */ /*****************************************************************************/ #ifndef _cvc3__include__cdflags_h_ #define _cvc3__include__cdflags_h_ #include "context.h" #include "os.h" namespace CVC3 { /////////////////////////////////////////////////////////////////////////////// // // // Class: CDFlags (Context Dependent Vector of Flags) // // Author: Clark Barrett // // Created: Thu Jan 26 16:37:46 2006 // // // /////////////////////////////////////////////////////////////////////////////// class CVC_DLL CDFlags :public ContextObj { unsigned d_flags; virtual ContextObj* makeCopy(ContextMemoryManager* cmm) { return new(cmm) CDFlags(*this); } virtual void restoreData(ContextObj* data) { d_flags = ((CDFlags*)data)->d_flags; } virtual void setNull(void) { FatalAssert(false, "Should never be called"); } void update(unsigned mask, int scope, bool setMask); // Disable copy constructor and operator= // If you need these, use smartcdo instead CDFlags(const CDFlags& cdflags): ContextObj(cdflags), d_flags(cdflags.d_flags) { } CDFlags& operator=(const CDFlags& cdflags) { return *this; } public: CDFlags(Context* context) : ContextObj(context), d_flags(0) { IF_DEBUG(setName("CDFlags");) } ~CDFlags() {} void set(unsigned mask, int scope=-1) { update(mask, scope, true); } void clear(unsigned mask, int scope=-1) { update(mask, scope, false); } bool get(unsigned mask) const { return (d_flags & mask) != 0; } }; } #endif
33.8
84
0.525717
[ "vector" ]
c536ccc0a359be339878d9281b81bf93b2bba8c9
4,880
h
C
algor.h
hoangcaominh/f-shortcut
49646b80a9830933e6ae91b28d6cbd93d881ef13
[ "Unlicense" ]
2
2018-02-22T07:12:24.000Z
2019-01-08T05:32:45.000Z
algor.h
hoangcaominh/f-shortcut
49646b80a9830933e6ae91b28d6cbd93d881ef13
[ "Unlicense" ]
2
2018-12-15T03:43:02.000Z
2019-01-08T06:19:51.000Z
algor.h
hoangcaominh/f-shortcut
49646b80a9830933e6ae91b28d6cbd93d881ef13
[ "Unlicense" ]
null
null
null
#include <string> #include <vector> #include <fstream> #include <algorithm> #include "json.hpp" #define DEBUG std::cout << "debug" << std::endl; using json = nlohmann::json; std::vector<std::string> tag_list; json data; bool string_compare(std::string s1, std::string s2) { std::string ss1 = "", ss2 = ""; for (size_t i = 0;i < s1.length();i++) if (s1[i] >= 65 && s1[i] <= 90) ss1 += char(s1[i] + 32); else ss1 += s1[i]; for (size_t i = 0;i < s2.length();i++) if (s2[i] >= 65 && s2[i] <= 90) ss2 += char(s2[i] + 32); else ss2 += s2[i]; return ss1 < ss2; } // check if a string name is valid const std::string non_char = "\\/:*?\"<>|"; bool is_string_valid(std::string &s) { return s.find_first_of(non_char) == std::string::npos; } void string_fix(std::string &s) { for (size_t i = 0;i < s.length();i++) if (s[i] == '\\') s[i] = '/'; } // main functions // string_compare between 2 path names void align() { for (size_t i = 0;i < data.size() - 1;i++) { json &tags = data[i]["Tags"]; std::sort(tags.begin(), tags.end(), string_compare); } for (size_t i = 0;i < data.size() - 1;i++) { for (size_t j = i+1;j < data.size();j++) { // if (data[i]["Name"].get<std::string>().string_compare(data[j].name) == 1 || data[i]["Name"].get<std::string>().empty()) //DEBUG if (!string_compare(data[i]["Name"].get<std::string>(), data[j]["Name"].get<std::string>())) { data[i].swap(data[j]); } } } std::sort(tag_list.begin(), tag_list.end(), string_compare); } void new_file() { std::fstream f("data.json", std::ios::out); f << "[]"; f.close(); } void scan_path() { std::fstream f("data.json", std::ios::in); if (f.fail()) { new_file(); std::cout << std::endl; std::cout << "Data file not found, created a new one." << std::endl; return; } else if (f.peek() == std::ifstream::traits_type::eof()) { new_file(); std::cout << std::endl; std::cout << "Attempted to open an empty data file." << std::endl; std::cout << "Deleted invalid file and created a new one." << std::endl; return; } // loading file std::cout << std::endl; std::cout << "Loading/Updating data file..." << std::endl; f >> data; if (data.empty()) { data[0]["Name"] = "Notepad"; data[0]["Path"] = "notepad"; data[0]["Tags"][0] = "(none)"; } f.close(); // add tags to tag_list tag_list.clear(); for (size_t i = 0;i < data.size();i++) { for (size_t j = 0;j < data[i]["Tags"].size();j++) { std::string tag = data[i]["Tags"][j].get<std::string>(); if (std::find(tag_list.begin(), tag_list.end(), tag) == tag_list.end()) { tag_list.push_back(tag); std::sort(tag_list.begin(), tag_list.end(), string_compare); } } } align(); // finishing loading std::cout << "Successully loaded data file." << std::endl; } void save_path() { std::fstream f("data.json", std::ios::out); f << data; f.close(); } bool already_exist(std::string &s) { for (size_t i = 0;i < data.size();i++) if (data[i]["Name"].get<std::string>() == s) return true; return false; } // specified for search_internet() #define url_symbol_number 14 struct url_symbol_list { char symbol; std::string id; }; const url_symbol_list url_symbol[url_symbol_number] = { {' ', "%20"}, {'+', "%2B"}, {'%', "%25"}, {'#', "%23"}, {'&', "%26"}, {'\'', "%27"}, {',', "%2C"}, {'.', "%2E"}, {'/', "%2F"}, {':', "%3A"}, {';', "%3B"}, {'<', "%3C"}, {'=', "&3D"}, {'>', "%3E"} }; std::string query_convert(std::string query) { unsigned int i = 0; while (i < query.length()) { bool found_symbol = false; for (int j = 0;j < url_symbol_number;j++) if (query[i] == url_symbol[j].symbol) { query.replace(i, 1, url_symbol[j].id.data()); i += 3; found_symbol = true; break; } if (!found_symbol) i++; } return query; } std::string search_url(std::string engine, std::string query) { std::string url = query_convert(query); // finalize url if (engine == "Google") url.insert(0, "www.google.com/search?q="); else if (engine == "Bing") url.insert(0, "www.bing.com/search?q="); else if (engine == "Coc Coc") url.insert(0, "www.coccoc.com/search#query="); return url; }
24.158416
129
0.485861
[ "vector", "3d" ]
c541c25d9d958e8c5f339e5247f2d6dc4b2e0036
2,610
h
C
include/backend/Vehicle.h
bpapaspyros/RobSim
b126e892910085fde4d14f50380b8db44fa7cd24
[ "MIT" ]
null
null
null
include/backend/Vehicle.h
bpapaspyros/RobSim
b126e892910085fde4d14f50380b8db44fa7cd24
[ "MIT" ]
null
null
null
include/backend/Vehicle.h
bpapaspyros/RobSim
b126e892910085fde4d14f50380b8db44fa7cd24
[ "MIT" ]
null
null
null
#ifndef VEHICLE_H #define VEHICLE_H #include "Map.h" #include <vector> class Vehicle { public: Vehicle(const int width, const int height); // costructor -> initializes important variables virtual ~Vehicle(); int move(Map m); // basic robot operation for moving, returns the dirextion virtual void operate(Map& m) = 0; // operate method for every robot // getters int get_pos_x(); // return robot x axis position int get_pos_y(); // return robot y axis position int get_velocity(); // return robot velocity int get_status(); // return robot remaining life int get_num_id(); // get the robot's unique num id float get_ability(); // return robot's ability to overcome obstacles char get_type(); // returns the type of the robot (A, S, R) int get_travelled(); // returns total distance travelled bool get_brokeQ(); // is the robot broken ? // setters void set_type(char type); // sets the robot's type void set_num_id(int num); // sets the unique num id void set_velocity(int num); // sets the velocity for the current robot void set_pos_x(int x); // implicitly sets the position of a robot void set_pos_y(int y); // implicitly sets the position of a robot void set_ability(float ab); // implicitly sets the ability of a robot void set_status(int n_status); // set the status of a robot void returnToMap(); // gets a robot that is in base back to map bool checkRobotDeath(); // if a robot is damaged for too long it dies bool gotoBase; // checks if the robot has to go back to the base int def_velocity; // robot's default velocity int def_status; // robot's default status int total_damages; // total damages taken by the robot virtual void export_info(float& p, float& g, float& i, float& remLoad); virtual void export_info(bool& successfulOperation); virtual void export_total_info(float& tp, float& tg, float& ti, float& total_res); virtual void export_total_info(int& total_successfullOps); private: // Basic robot variables void init_vars(); // initializes varibles int pos_x; // robot's x axis position int pos_y; // robot's y axis position int velocity; // robot's velocity int status; // robot's life status (up to 15) float ability; // robot's ability to overcome obstacles int num_id; // each robot has a num id char type; // each robot has a type int travelled; // distance that a robot has travelled int stayed_broken; // rounds that the robot has remained broken int _width; // map's width int _height; // map's height }; #endif
41.428571
94
0.698851
[ "vector" ]
c54c5f240dab27e31e6da4bc6e6fbadeba708145
5,560
c
C
loongson/soc_run_os/simu/soft/func/source/flash.c
Ewenwan/nontrivial-mips
13dce08bc61c5ccd166a5714372d83b126ee8212
[ "MIT" ]
524
2019-08-19T07:12:33.000Z
2022-03-20T19:28:40.000Z
loongson/soc_run_os/simu/soft/func/source/flash.c
dwy1991/nontrivial-mips
f18d2bbd8216dd1783044fb677471172e2355dba
[ "MIT" ]
2
2020-04-05T17:03:16.000Z
2021-06-22T07:59:00.000Z
loongson/soc_run_os/simu/soft/func/source/flash.c
dwy1991/nontrivial-mips
f18d2bbd8216dd1783044fb677471172e2355dba
[ "MIT" ]
107
2019-08-19T14:27:34.000Z
2022-03-31T09:36:55.000Z
#include "../config.h" extern unsigned int str2num (char str[30]); void mywait(void); /****************************** *Flash Test* CONFIDENTIAL >CAUTION< DO NOT add this program to ANY release version! Liu Su liusu-cpu@ict.ac.cn ******************************/ //#if FLASH_TEST static void flash_clearHVPL(void) { *(volatile _u32*)(0xbfe60000) = 0x40000000; } static void flash_erase(_u32 offset) { *(volatile _u32*)(0xbfe60000) = 0xa0000000|offset; } static void flash_page(_u32 offset) { *(volatile _u32*)(0xbfe60000) = 0xe0000000|offset; } static void flash_setca(_u32 cah, _u32 cal) { *(volatile _u32*)(0xbfe60008) = cal; *(volatile _u32*)(0xbfe60004) = cah; *(volatile _u32*)(0xbfe60000) = 0xf0000000; } int set_ca(int argc, char argv[][30]) { _u32 cah,cal; if(argc !=3 ) {printf("\nUsage: setca <cah> <cal>");return 1;} cah = str2num(argv[1]); cal = str2num(argv[2]); *(volatile _u32*)(0xbfe60008) = cal; *(volatile _u32*)(0xbfe60004) = cah; *(volatile _u32*)(0xbfe60000) = 0xf0000000; // mywait(); return 0; } static void flash_writepl() { int i; for(i=0; i<128; i+=4) *(volatile _u32*)(0xbf00e000 + i) = i; } int verif(int argc, char argv[][30]) { printf("\nverif"); _u32 page_offset; _u32 page_latch[33]; int i; page_offset = 0xe000; printf("\noffset"); // crypt flash_setca(0x1f00e100,0x1f00e000); printf("\nsetca\n"); // normal page flash_clearHVPL(); printf("clearHVPL\n"); flash_writepl(); printf("writepl\n"); flash_erase(page_offset); // mywait(); printf("erase\n"); flash_page(page_offset); // mywait(); printf("page\n"); // verif *(volatile _u32*)(0xbfe60010) = 0x14; *(volatile _u32*)(0xbfe60000) = 0x1000e014; while(*(volatile _u32*)(0xbfe60014) & 0x2 != 0x2){} if(*(volatile _u32*)(0xbfe60014) & 0x1) printf("verif correct\n"); else printf("verif error"); // flash_setca(0x1f000001,0x1f000001); return 0; } int set_pe_time_mode(int argc, char argv[][30]) { unsigned int mode; mode = str2num(argv[1]); *(volatile _u32*)(0xbfe60024) = mode; /**************************** mode: 0: 1.5ms 1: 2.0ms 2: 2.5ms 3: 3.0ms 4: 3.5ms ****************************/ return 0; } static void set_pe_time(int mode) { *(volatile _u32*)(0xbfe60024) = mode; } int flash_tk(int argc, char argv[][30]) { unsigned int i,num; num = str2num(argv[1]); for(i=0; i<num; i++) { *(volatile _u32*)(0xbfe60000) = 0x20000000; while(*(volatile _u32*)(0xbfe60014) & 0x4 != 0x4){} printf("\n%8x%8x",*(volatile _u32*)(0xbfe60018),*(volatile _u32*)(0xbfe6001c)); } return 0; } int flash_accg(int argc, char argv[][30]) { printf("\n%x\n",*(volatile _u32*)(0xbf010008)); *(volatile _u32*)(0xbfe60020) = 0x37116327; *(volatile _u32*)(0xbfe60020) = 0x90d112e5; *(volatile _u32*)(0xbfe60020) = 0x41237f48; *(volatile _u32*)(0xbfe60020) = 0xbeb9fb58; printf("%x",*(volatile _u32*)(0xbf010008)); return 0; } void mywait(void) { __asm__ volatile( ".set mips3\n" "wait;\n" ".set mips1\n" ); } int copy_flash(int argc, char argv[][30]) { _u32 i,j,k,cnt; flash_setca(0x1f000001,0x1f000000); mywait(); flash_clearHVPL(); printf("\n"); *(volatile _u8*)(0xbfea0000) = 0x10; // open int_en of flash in confreg for(i=511;; i=i-1) { for(j=0;j<128;j+=4){ k= *(volatile _u32*)(0xbfc00000+i*128+j); *(volatile _u32*)(0xbf000000+i*128+j) = k; } // if(i%0x80 == 0x7c) // { printf("page %3d\n",i); set_pe_time(2); flash_erase(i*128); mywait(); // while(*(volatile _u8*)(0xbfea0005) != 0x10) {} set_pe_time(2); flash_page(i*128); mywait(); // while(*(volatile _u8*)(0xbfea0005) != 0x10) {} flash_clearHVPL(); // } if(i==0) break; } printf("\n\r\n\r\n"); cnt = 0; for(i=0;i<0x10000;i+=4) { j = *(volatile _u32*)(0xbf000000+i); k = *(volatile _u32*)(0xbfc00000+i); cnt = (j==k) ? cnt : cnt + 1; // printf("@%4x : %8x %8x %1d\n",i,j,k,(j==k)); } printf("error count: %d\n",cnt); return 0; } int write_trim(int argc, char argv[][30]) { flash_clearHVPL(); *(volatile _u32*)(0xbfe60020) = 0x37116327; *(volatile _u32*)(0xbfe60020) = 0x90d112e5; *(volatile _u32*)(0xbfe60020) = 0x41237f48; *(volatile _u32*)(0xbfe60020) = 0xbeb9fb58; *(volatile _u32*)(0xbf0101f0) = 0x01aadd00; *(volatile _u32*)(0xbf0101f4) = 0x1f190106; *(volatile _u32*)(0xbf0101f8) = 0x091e5522; *(volatile _u32*)(0xbf0101fc) = 0x6d920606; set_pe_time(2); flash_erase(0x10180); mywait(); flash_page(0x10180); mywait(); printf("\ntrim write ok"); return 0; } int jump(int argc, char argv[][30]) { __asm__ volatile( "li $8, 0xbf000000;\n" "jalr $8;\n" "nop;\n" :::"$8"); return 0; } int flash_test(int argc, char argv[][30]) { _u32 i,j,k,cnt; k = str2num(argv[1]); *(volatile _u8*)(0xbfea0000) = 0x10; // open int_en of flash in confreg flash_setca(0x1f000001,0x1f000000); mywait(); flash_clearHVPL(); set_pe_time(2); printf("\npaging"); *(volatile _u32*)(0xbfe60000) = 0x80000000; // erase all mywait(); for(i=0;i<512;i++) { for(j=0;j<128;j+=4){ // k= *(volatile _u32*)(0xbfc00000+i*128+j); *(volatile _u32*)(0xbf000000+i*128+j) = k; } // printf("page %3d\n",i); flash_page(i*128); mywait(); // while(*(volatile _u8*)(0xbfea0005) != 0x10) {} flash_clearHVPL(); } printf("\nverifying\n"); cnt = 0; for(i=0;i<0x10000;i+=4) { j = *(volatile _u32*)(0xbf000000+i); // k = *(volatile _u32*)(0xbfc00000+i); cnt = (j==k) ? cnt : cnt + 1; if(j!=k) printf("@addr:0x%4x : j=0x%8x k=0x%8x\n",i,j,k); // printf("@%4x : %8x %8x %1d\n",i,j,k,(j==k)); } printf("error count: %d\n",cnt); return 0; } //#endif //FLASH_TEST
21.71875
81
0.621403
[ "3d" ]
68e9df84a0201c6fe6b356b7761c8386087a91a4
757
h
C
NativePluginProject/HDROutputPlugin/Mesh.h
aosoft/UnityHDROutputPlugin
15ba0ce20eadb237af42be576233dc8701943b04
[ "MIT" ]
18
2019-01-09T05:06:16.000Z
2021-12-05T02:33:49.000Z
NativePluginProject/HDROutputPlugin/Mesh.h
aosoft/UnityHDROutputPlugin
15ba0ce20eadb237af42be576233dc8701943b04
[ "MIT" ]
null
null
null
NativePluginProject/HDROutputPlugin/Mesh.h
aosoft/UnityHDROutputPlugin
15ba0ce20eadb237af42be576233dc8701943b04
[ "MIT" ]
1
2021-04-18T11:30:28.000Z
2021-04-18T11:30:28.000Z
#pragma once #include "common.h" #include <d3d11.h> #include <DirectXMath.h> #pragma pack(push) #pragma pack(4) struct MeshVertex { ::DirectX::XMFLOAT2 Pos; ::DirectX::XMFLOAT2 UV; static ComPtr<ID3D11InputLayout> CreateInputLayout( ComPtr<ID3D11Device> const& device, const void *vsByteCode, size_t vsByteCodeSize); }; #pragma pack(pop) class Mesh { private: size_t _indexCount; ComPtr<ID3D11Buffer> _indexBuffer; ComPtr<ID3D11Buffer> _vertexBuffer; public: Mesh(ComPtr<ID3D11Device> const& device, const MeshVertex *verticies, size_t vertCount, const uint16_t *indicies, size_t indexCount); void Draw(ComPtr<ID3D11DeviceContext> const& dc); static std::unique_ptr<Mesh> CreateRectangleMesh(ComPtr<ID3D11Device> const& device); };
19.921053
86
0.764861
[ "mesh" ]
68f741e98e809242e43e2e3200915350619cd426
6,039
h
C
Sankore-3.1/src/adaptors/UBCFFSubsetAdaptor.h
eaglezzb/rsdc
cce881f6542ff206bf286cf798c8ec8da3b51d50
[ "MIT" ]
null
null
null
Sankore-3.1/src/adaptors/UBCFFSubsetAdaptor.h
eaglezzb/rsdc
cce881f6542ff206bf286cf798c8ec8da3b51d50
[ "MIT" ]
null
null
null
Sankore-3.1/src/adaptors/UBCFFSubsetAdaptor.h
eaglezzb/rsdc
cce881f6542ff206bf286cf798c8ec8da3b51d50
[ "MIT" ]
null
null
null
/* * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour l'Education Numérique en Afrique (GIP ENA) * * This file is part of Open-Sankoré. * * Open-Sankoré is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License, * with a specific linking exception for the OpenSSL project's * "OpenSSL" library (or with modified versions of it that use the * same license as the "OpenSSL" library). * * Open-Sankoré 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 Open-Sankoré. If not, see <http://www.gnu.org/licenses/>. */ #ifndef UBCFFSUBSETADAPTOR_H #define UBCFFSUBSETADAPTOR_H #include <QtXml> #include <QString> #include <QStack> #include <QDomDocument> #include <QHash> class UBDocumentProxy; class UBGraphicsScene; class QSvgGenerator; class UBGraphicsSvgItem; class UBGraphicsPixmapItem; class UBGraphicsItemDelegate; class QTransform; class QPainter; class UBGraphicsItem; class QGraphicsItem; class QTextBlockFormat; class QTextCharFormat; class QTextCursor; class UBGraphicsStrokesGroup; class UBCFFSubsetAdaptor { public: UBCFFSubsetAdaptor(); static bool ConvertCFFFileToUbz(QString &cffSourceFile, UBDocumentProxy* pDocument); private: class UBCFFSubsetReader { public: UBCFFSubsetReader(UBDocumentProxy *proxy, QFile *content); ~UBCFFSubsetReader(); UBDocumentProxy *mProxy; QString pwdContent; bool parse(); private: QString mTempFilePath; UBGraphicsScene *mCurrentScene; QRectF mCurrentSceneRect; QString mIndent; QRectF mViewBox; QRectF mViewPort; qreal mVBTransFactor; QPointF mViewBoxCenter; QSize mSize; QPointF mShiftVector; bool mSvgGSectionIsOpened; UBGraphicsGroupContainerItem *mGSectionContainer; private: QDomDocument mDOMdoc; QDomNode mCurrentDOMElement; QHash<QString, UBGraphicsItem*> persistedItems; QMap<QString, QString> mRefToUuidMap; QDir mTmpFlashDir; void addItemToGSection(QGraphicsItem *item); bool hashElements(); void addExtentionsToHash(QDomElement *parent, QDomElement *topGroup); void hashSvg(QDomNode *parent, QString prefix = ""); void hashSiblingIwbElements(QDomElement *parent, QDomElement *topGroup = 0); inline void parseSvgSectionAttr(const QDomElement &); bool parseSvgPage(const QDomElement &parent); bool parseSvgPageset(const QDomElement &parent); bool parseSvgElement(const QDomElement &parent); bool parseIwbMeta(const QDomElement &element); bool parseSvg(const QDomElement &svgSection); inline bool parseGSection(const QDomElement &element); inline bool parseSvgSwitchSection(const QDomElement &element); inline bool parseSvgRect(const QDomElement &element); inline bool parseSvgEllipse(const QDomElement &element); inline bool parseSvgPolygon(const QDomElement &element); inline bool parseSvgPolyline(const QDomElement &element); inline bool parseSvgText(const QDomElement &element); inline bool parseSvgTextarea(const QDomElement &element); inline bool parseSvgImage(const QDomElement &element); inline bool parseSvgFlash(const QDomElement &element); inline bool parseSvgAudio(const QDomElement &element); inline bool parseSvgVideo(const QDomElement &element); inline UBGraphicsGroupContainerItem *parseIwbGroup(QDomElement &parent); inline bool parseIwbElement(QDomElement &element); inline void parseTSpan(const QDomElement &parent, QPainter &painter , qreal &curX, qreal &curY, qreal &width, qreal &height, qreal &linespacing, QRectF &lastDrawnTextBoundingRect , qreal &fontSize, QColor &fontColor, QString &fontFamily, QString &fontStretch, bool &italic , int &fontWeight, int &textAlign, QTransform &fontTransform); inline void parseTSpan(const QDomElement &element, QTextCursor &cursor , QTextBlockFormat &blockFormat, QTextCharFormat &charFormat); inline void hashSceneItem(const QDomElement &element, UBGraphicsItem *item); // to kill inline void parseTextAttributes(const QDomElement &element, qreal &fontSize, QColor &fontColor, QString &fontFamily, QString &fontStretch, bool &italic, int &fontWeight, int &textAlign, QTransform &fontTransform); inline void parseTextAttributes(const QDomElement &element, QFont &font, QColor); inline void readTextBlockAttr(const QDomElement &element, QTextBlockFormat &format); inline void readTextCharAttr(const QDomElement &element, QTextCharFormat &format); //elements parsing methods bool parseDoc(); bool createNewScene(); bool persistCurrentScene(); bool persistScenes(); // helper methods void repositionSvgItem(QGraphicsItem *item, qreal width, qreal height, qreal x, qreal y, QTransform &transform); QColor colorFromString(const QString& clrString); QTransform transformFromString(const QString trString, QGraphicsItem *item = 0); bool getViewBoxDimenstions(const QString& viewBox); QSvgGenerator* createSvgGenerator(qreal width, qreal height); bool getTempFileName(); inline bool strToBool(QString); bool createTempFlashPath(); }; }; #endif // UBCFFSUBSETADAPTOR_H
39.214286
141
0.697135
[ "transform" ]
ec0bbe1c2cd1fbf6550080d4d871f98b6a49b036
4,758
h
C
src/fork_guard.h
struct/forkguard
c7c0cc9374d17c189d7fb02af942dc2156b6626c
[ "Apache-2.0" ]
4
2018-05-30T18:13:22.000Z
2019-01-04T05:44:09.000Z
src/fork_guard.h
struct/forkguard
c7c0cc9374d17c189d7fb02af942dc2156b6626c
[ "Apache-2.0" ]
null
null
null
src/fork_guard.h
struct/forkguard
c7c0cc9374d17c189d7fb02af942dc2156b6626c
[ "Apache-2.0" ]
1
2020-03-09T11:03:04.000Z
2020-03-09T11:03:04.000Z
/* Reference implementation of fork guard. * Copyright Chris Rohlf - 2022 */ #define _GNU_SOURCE #include <stdio.h> #include <stdint.h> #include <string.h> #include <stdlib.h> #include <stdbool.h> #include <unistd.h> #include <errno.h> #include <dlfcn.h> #include <elf.h> #include <link.h> #include <pthread.h> #include <sys/ptrace.h> #include <sys/mman.h> #include <sys/wait.h> #include <sys/user.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> #include <libgen.h> #include "vector_t/vector.h" #define OK 0 #define ERROR -1 #define NO 0 #define YES 1 #define MAX_SYMBOL_NAME 512 #define MAX_LIBRARY_PATH 4096 /* Environment variables for controlling Fork Guard */ #define FG_WHITELIST "FG_WHITELIST" #define FG_TRACING_MODE "FG_TRACING_MODE" #define FG_PARSE_EXE_SYMS "FG_PARSE_EXE_SYMS" #define FG_DUMPSTATS "FG_DUMPSTATS" #if DEBUG #define LOG_ERROR(msg, ...) \ fprintf(stderr, "[LOG][%d](%s) (%s) - " msg "\n", getpid(), __FUNCTION__, strerror(errno), ##__VA_ARGS__); \ fflush(stderr); #define LOG(msg, ...) \ fprintf(stdout, "[LOG][%d](%s) " msg "\n", getpid(), __FUNCTION__, ##__VA_ARGS__); \ fflush(stdout); #else #define LOG_ERROR(...) #define LOG(...) #endif /* Symbol entries are derived from user inputs such * as a whitelist. But Fork Guard works * by removing entire pages of memory. These data * structures are for abstracting away symbol data, * and page information which we use internally. */ typedef struct _symbol_entry_t { /* Absolute memory address (base_addr + value) */ uintptr_t addr; /* Library base address */ uintptr_t base_addr; /* st_value as extracted from ELF section in memory */ uintptr_t value; /* st_size of the function */ size_t size; /* Whitelist flag */ bool whitelist; /* ASCII name of the symbol */ char name[MAX_SYMBOL_NAME]; /* true if by name, false if by offset */ bool has_real_symbol; /* Reference count */ int32_t ref_count; } symbol_entry_t; /* We store them seperately to speed up searching */ vector_t function_whitelist; /* Stored symbols from on disk .symtab parsing */ vector_t symtab_functions; bool g_symbols_parsed; bool g_whitelist_parsed; bool g_stats_dumped; char *g_parse_exe_syms; char *g_whitelist; uintptr_t g_ip_page_cache; /* Internally Fork Guard works at the page level. * Before any pages are dropped we check what * symbols point at functions in that page as * they may be on the whitelist. * Fork Guard does not track if the page is a * contiguous mapping or not. We intentionally * poke holes in library mappings. */ typedef struct _page_desc_t { /* The base page address we are tracking */ uintptr_t page; /* Was this page dropped? */ bool dropped; /* What library occupies this mapping? */ char library[MAX_LIBRARY_PATH]; /* Contains a whitelisted symbol */ bool contains_wls; /* What symbols represent functions on these * pages. This is a vector of symbol_entry_t */ vector_t symbols; } page_desc_t; /* Store information about each code page we find */ vector_t all_pages; /* This stores information about which * thread is tracing which child process */ typedef struct _tracer_thread_ctx_t { pthread_t ctx; pid_t child_pid; } tracer_thread_ctx_t; vector_t tracer_threads; /* Base address of the main exe */ uintptr_t g_exe_load_address; pthread_mutex_t whitelist_lock; const char program_name[1024]; inline __attribute__((always_inline)) uintptr_t get_base_page(uintptr_t addr); int32_t env_to_int(char *string); int32_t advise_page_on_fork(uintptr_t page, bool enforce); int32_t read_symbol_list(char *symbol_file); int32_t append_symbol_list(char *symbol_file, char *library, char *symbol); int32_t child_fork_trace(pid_t child_pid); int32_t handle_symbol(uintptr_t addr, symbol_entry_t *sd, const char *lib_name); int32_t parse_file_symtab(const char *path); void symbol_entry_copy(symbol_entry_t *to, symbol_entry_t *from); void vector_pointer_free(void *p); void vector_free_internal(void *p); void free_fg_vectors(); void *add_symbol_to_page(page_desc_t *page_desc, symbol_entry_t *sd, const char *lib_name); void *drop_pages(void *p, void *data); void *page_stats(void *p, void *data); void *add_whitelist_to_pages(void *p, void *data); void *check_dropped_pages(void *p, void *data); void *find_existing_page(void *p, void *data); void *is_symbol_whitelisted(void *p, void *data); void *each_symtab(void *p, void *data); static int32_t get_exe_load_address(struct dl_phdr_info *info, size_t size, void *data); static int32_t fork_guard_phdr_callback(struct dl_phdr_info *info, size_t size, void *data); static int32_t build_whitelist_callback(struct dl_phdr_info *info, size_t size, void *data); /* Overloaded libc functions */ pid_t(*g_original_fork)(void);
29.924528
110
0.752417
[ "vector" ]
ec0efdf17146a491f1a62098bfc2c1784bf9b368
1,556
h
C
Examples/include/asposecpplib/system/icustomformatter.h
kashifiqb/Aspose.PDF-for-C
13d49bba591c5704685820185741e64a462a5bdc
[ "MIT" ]
null
null
null
Examples/include/asposecpplib/system/icustomformatter.h
kashifiqb/Aspose.PDF-for-C
13d49bba591c5704685820185741e64a462a5bdc
[ "MIT" ]
null
null
null
Examples/include/asposecpplib/system/icustomformatter.h
kashifiqb/Aspose.PDF-for-C
13d49bba591c5704685820185741e64a462a5bdc
[ "MIT" ]
null
null
null
/// @file system/icustomformatter.h /// Contains the declaration of System::ICustomFormatter class. #ifndef _ICustomFormatter_h_ #define _ICustomFormatter_h_ #include "system/object.h" #include "system/iformatprovider.h" namespace System { class String; /// Defines a method that performs custom formatting of a string representation of a value represented by the specified object. /// Objects of this class should only be allocated using System::MakeObject() function. /// Never create instance of this type on stack or using operator new, as it will result in runtime errors and/or assertion faults. /// Always wrap this class into System::SmartPtr pointer and use this pointer to pass it to functions as argument. class ASPOSECPP_SHARED_CLASS ICustomFormatter : virtual public System::Object { RTTI_INFO(System::ICustomFormatter, ::System::BaseTypesInfo<System::Object>) public: /// Returns a string representation of a value represented by the current object using the specified format. /// @param format The string format /// @param arg The object to be formatted /// @param formatProvider The object providing the formatting information /// @returns The string representation of @p arg formatted according to the format specified by @p format and @p formatProvider virtual ASPOSECPP_SHARED_API System::String Format(System::String format, System::SharedPtr<System::Object> arg, System::SharedPtr<System::IFormatProvider> formatProvider) = 0; }; } #endif
50.193548
184
0.746144
[ "object" ]
ec35e111d5ca704465c7c7ae3fe02359b46ac6fb
2,266
h
C
include/onnxruntime/core/common/profiler_common.h
lchang20/onnxruntime
97b8f6f394ae02c73ed775f456fd85639c91ced1
[ "MIT" ]
6,036
2019-05-07T06:03:57.000Z
2022-03-31T17:59:54.000Z
include/onnxruntime/core/common/profiler_common.h
lchang20/onnxruntime
97b8f6f394ae02c73ed775f456fd85639c91ced1
[ "MIT" ]
5,730
2019-05-06T23:04:55.000Z
2022-03-31T23:55:56.000Z
include/onnxruntime/core/common/profiler_common.h
lchang20/onnxruntime
97b8f6f394ae02c73ed775f456fd85639c91ced1
[ "MIT" ]
1,566
2019-05-07T01:30:07.000Z
2022-03-31T17:06:50.000Z
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #pragma once #include "core/common/common.h" #include <unordered_map> namespace onnxruntime { namespace profiling { enum EventCategory { SESSION_EVENT = 0, NODE_EVENT, KERNEL_EVENT, EVENT_CATEGORY_MAX }; // Event descriptions for the above session events. static constexpr const char* event_categor_names_[EVENT_CATEGORY_MAX] = { "Session", "Node", "Kernel"}; // Timing record for all events. struct EventRecord { EventRecord(EventCategory category, int process_id, int thread_id, std::string event_name, long long time_stamp, long long duration, std::unordered_map<std::string, std::string>&& event_args) : cat(category), pid(process_id), tid(thread_id), name(std::move(event_name)), ts(time_stamp), dur(duration), args(event_args) {} EventCategory cat; int pid; int tid; std::string name; long long ts; long long dur; std::unordered_map<std::string, std::string> args; }; using Events = std::vector<EventRecord>; //Execution Provider Profiler class EpProfiler { public: virtual ~EpProfiler() = default; virtual bool StartProfiling() = 0; // called when profiling starts virtual void EndProfiling(TimePoint start_time, Events& events) = 0; // called when profiling ends, save all captures numbers to "events" virtual void Start(uint64_t){}; // called before op start, accept an id as argument to identify the op virtual void Stop(uint64_t){}; // called after op stop, accept an id as argument to identify the op }; } //namespace profiling } //namespace onnxruntime
36.548387
142
0.527802
[ "vector" ]
ec3676840aa47119d185803014a01aa9e2654ade
908
h
C
k-closest-points-to-origin.h
kiddliu/midnight-leetcode
1c5638102111ff7509b1bc125ba66741ba6b149e
[ "MIT" ]
null
null
null
k-closest-points-to-origin.h
kiddliu/midnight-leetcode
1c5638102111ff7509b1bc125ba66741ba6b149e
[ "MIT" ]
null
null
null
k-closest-points-to-origin.h
kiddliu/midnight-leetcode
1c5638102111ff7509b1bc125ba66741ba6b149e
[ "MIT" ]
null
null
null
#ifndef K_CLOSEST_POINTS_TO_ORIGIN_H_ #define K_CLOSEST_POINTS_TO_ORIGIN_H_ #include <algorithm> #include <vector> namespace solution { std::vector<std::vector<int>> kClosest(std::vector<std::vector<int>>& points, int k) { // should not be a medium problem // Runtime: 176 ms, faster than 61.53% of C++ online submissions for K Closest Points to Origin. // Memory Usage: 49.2 MB, less than 88.82% of C++ online submissions for K Closest Points to Origin. // std::sort(points.begin(), points.end(), [](const std::vector<int>& first, const std::vector<int>& second) { return (first[0] * first[0] + first[1] * first[1]) < (second[0] * second[0] + second[1] * second[1]); }); return std::vector<std::vector<int>>(points.begin(), points.begin() + k); } } #endif // !K_CLOSEST_POINTS_TO_ORIGIN_H_
33.62963
102
0.615639
[ "vector" ]
ec3ca58d4af3b6b568c12523285939e99702372d
3,156
h
C
frameworks/innerkitsimpl/converter/include/post_proc.h
openharmony-gitee-mirror/multimedia_image_standard
40b530603fe815ab9c845ac1633d369d4339b1d0
[ "Apache-2.0" ]
null
null
null
frameworks/innerkitsimpl/converter/include/post_proc.h
openharmony-gitee-mirror/multimedia_image_standard
40b530603fe815ab9c845ac1633d369d4339b1d0
[ "Apache-2.0" ]
null
null
null
frameworks/innerkitsimpl/converter/include/post_proc.h
openharmony-gitee-mirror/multimedia_image_standard
40b530603fe815ab9c845ac1633d369d4339b1d0
[ "Apache-2.0" ]
null
null
null
/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef POST_PROC_H #define POST_PROC_H #include <vector> #include "basic_transformer.h" #include "image_type.h" #include "pixel_map.h" #include "scan_line_filter.h" namespace OHOS { namespace Media { enum class CropValue : int32_t { INVALID, VALID, NOCROP }; class PostProc { public: uint32_t DecodePostProc(const DecodeOptions &opts, PixelMap &pixelMap, FinalOutputStep finalOutputStep = FinalOutputStep::NO_CHANGE); uint32_t ConvertProc(const Rect &cropRect, ImageInfo &dstImageInfo, PixelMap &pixelMap, ImageInfo &srcImageInfo); static bool IsHasCrop(const Rect &rect); bool HasPixelConvert(const ImageInfo &srcImageInfo, ImageInfo &dstImageInfo); bool RotatePixelMap(float rotateDegrees, PixelMap &pixelMap); bool ScalePixelMap(const Size &size, PixelMap &pixelMap); bool ScalePixelMap(float scaleX, float scaleY, PixelMap &pixelMap); bool CenterScale(const Size &size, PixelMap &pixelMap); static CropValue GetCropValue(const Rect &rect, const Size &size); private: static uint8_t *AllocSharedMemory(const Size &size, const uint64_t bufferSize, int &fd); uint32_t NeedScanlineFilter(const Rect &cropRect, const Size &srcSize, const bool &hasPixelConvert); void GetDstImageInfo(const DecodeOptions &opts, PixelMap &pixelMap, ImageInfo srcImageInfo, ImageInfo &dstImageInfo); uint32_t PixelConvertProc(ImageInfo &dstImageInfo, PixelMap &pixelMap, ImageInfo &srcImageInfo); uint32_t AllocBuffer(ImageInfo imageInfo, uint8_t **resultData, uint64_t &dataSize, int &fd); bool AllocHeapBuffer(uint64_t bufferSize, uint8_t **buffer); void ReleaseBuffer(AllocatorType allocatorType, int fd, uint64_t dataSize, uint8_t **buffer); bool Transform(BasicTransformer &trans, const PixmapInfo &input, PixelMap &pixelMap); void ConvertPixelMapToPixmapInfo(PixelMap &pixelMap, PixmapInfo &pixmapInfo); void SetScanlineCropAndConvert(const Rect &cropRect, ImageInfo &dstImageInfo, ImageInfo &srcImageInfo, ScanlineFilter &scanlineFilter, bool hasPixelConvert); bool CenterDisplay(PixelMap &pixelMap, int32_t srcWidth, int32_t srcHeight, int32_t targetWidth, int32_t targetHeight); uint32_t CheckScanlineFilter(const Rect &cropRect, ImageInfo &dstImageInfo, PixelMap &pixelMap, int32_t pixelBytes, ScanlineFilter &scanlineFilter); DecodeOptions decodeOpts_; }; } // namespace Media } // namespace OHOS #endif // POST_PROC_H
48.553846
117
0.739227
[ "vector", "transform" ]
ec45840caf6cd205b4dfc4a98fa5ba78e91eca01
196
h
C
src/fade2d/basic.h
Gigi1237/Bounce
6e674dd7babda0192b930cc532f692c75219d1fd
[ "MIT" ]
null
null
null
src/fade2d/basic.h
Gigi1237/Bounce
6e674dd7babda0192b930cc532f692c75219d1fd
[ "MIT" ]
2
2015-02-11T02:46:15.000Z
2015-02-26T14:41:30.000Z
src/fade2d/basic.h
Gigi1237/Bounce
6e674dd7babda0192b930cc532f692c75219d1fd
[ "MIT" ]
null
null
null
#ifndef BASIC_H #define BASIC_H #include <cstdio> #include <cstdlib> #include <string> #include <memory> #include <iostream> #include <vector> //#include <Windows.h> #include <GL/glew.h> #endif
14
22
0.719388
[ "vector" ]
ec4860cef300db9cfd1e3eeffb0549161fde2d75
1,646
h
C
code/planecalib_ui/tests/SceneGenerator.h
joshjo/planecalib
1d7cffac5cab39c7fbfb67e8e3a4b42340ef5e13
[ "BSD-3-Clause" ]
30
2016-05-29T14:30:51.000Z
2021-10-10T13:31:43.000Z
code/planecalib_ui/tests/SceneGenerator.h
TANHAIYU/planecalib
a3e7efa8cc3de1be1489891d81c0fb00b5b98777
[ "BSD-3-Clause" ]
2
2018-02-27T21:00:32.000Z
2019-01-28T22:02:03.000Z
code/planecalib_ui/tests/SceneGenerator.h
TANHAIYU/planecalib
a3e7efa8cc3de1be1489891d81c0fb00b5b98777
[ "BSD-3-Clause" ]
16
2016-08-05T14:35:08.000Z
2020-09-15T21:23:16.000Z
#ifndef SCENEGENERATOR_H_ #define SCENEGENERATOR_H_ #include <Eigen/Dense> #include <random> #include <memory> #include "planecalib/eutils.h" #include "planecalib/CameraModel.h" namespace planecalib { class PlaneCalibSystem; class Map; class FrameTrackingData; class PoseTracker; class SceneGenerator { public: SceneGenerator() : mNoiseStd(1), mCamera(NULL), mLogScene(false), mVerbose(false) {} EIGEN_MAKE_ALIGNED_OPERATOR_NEW CameraModel *getCamera() const { return mCamera; } void setCamera(CameraModel *value) { mCamera = value; } float getNoiseStd() const { return mNoiseStd; } void setNoiseStd(float value) { mNoiseStd = value; if (mNoiseStd <= 0) mNoiseStd = std::numeric_limits<float>::epsilon(); } std::unique_ptr<Map> generateSyntheticMap(); std::unique_ptr<Map> generateSyntheticMap(float normalAngle); std::unique_ptr<Map> generateRandomMap(int frameCount); std::unique_ptr<Map> generateRandomMap(int frameCount, float normalAngle); std::unique_ptr<Map> generateVariableNormal(float normalAngle); bool mLogScene; bool mVerbose; protected: std::random_device mRandomDevice; CameraModel *mCamera; float mNoiseStd; void generateSyntheticPoses(std::vector<Eigen::Matrix3fr> &posesR, std::vector<Eigen::Vector3f> &posesCenter); void generateRandomPoses(int frameCount, std::vector<Eigen::Matrix3fr> &posesR, std::vector<Eigen::Vector3f> &posesCenter); void generateRandomRef(float normalAngle, Eigen::Matrix3fr &R, Eigen::Vector3f &center); std::unique_ptr<Map> generateFromPoses(const std::vector<Eigen::Matrix3fr> &posesR, const std::vector<Eigen::Vector3f> &posesCenter); }; } #endif
26.548387
134
0.766707
[ "vector" ]
57a3de6a1b51c44057c1db441bf9fa2a17f43e64
12,684
h
C
cpp/lib/MathTools/BasicToolSet.h
yashsehgal/pluto
092565533475fd52c530c98a6fcbdb4a474dcc3c
[ "MIT" ]
2
2020-06-26T16:20:59.000Z
2020-06-26T16:23:01.000Z
cpp/lib/MathTools/BasicToolSet.h
yashsehgal/pluto
092565533475fd52c530c98a6fcbdb4a474dcc3c
[ "MIT" ]
3
2020-06-26T11:59:22.000Z
2020-06-26T20:15:54.000Z
cpp/lib/MathTools/BasicToolSet.h
yashsehgal/pluto
092565533475fd52c530c98a6fcbdb4a474dcc3c
[ "MIT" ]
2
2020-06-26T16:23:16.000Z
2020-10-12T15:23:20.000Z
#ifndef _MATH_TOOLS__BASIC_TOOL_SET_CPP_MACRO___ #define _MATH_TOOLS__BASIC_TOOL_SET_CPP_MACRO___ /** * Global declarations * */ #define PI 3.1415916 /** * This is the c++ version of BasicToolSet module * This is the most basic module of Pluto framework which contains the * basic math tools and functions. * ! This module is for user development use and does not conatains any out-sourced data. * Todo: To develop user friendly coding feature using basic class and function methods * Todo: Use inner function interchange to do specific tests * This is our main class for Basic Tools Set method of MathTools code bundle package * The class method has all the useful functions and methods that the user can use throughout this module. The list of all the functions inside this class method * Todo: Addition function - normal addition - array submission - addition of boolean values * Todo: Subtraction function - normal subtraction - array subtraction * Todo: Product function - normal product finding - vector product computer - array production computer * Todo: Divide function - normal division - array elemental division method - production of boolean values * Todo: Percentage function - calculates percentage with the given number value - calculates the percentage with the help of an array - computes average quantaties from the given array * Todo: Maximum and Minimum value computer - computes minimum value - computes maximum value - computes both max. and min. values from a given array list */ #include <iostream> #include <string> class BasicToolSet { private: char *command{}; public: explicit BasicToolSet(const char *command = "basic") { if (std::strcmp(command, "advanced") != 0) { // code for advanced feature option } else { std::cout << "Choose an option from basic or advanced" << std::endl; } } static double addNum(int num1, int num2) { return num1 + num2; } static double addNum(float num1, float num2) { return num1 + num2; } static double addNum(double num1, double num2) { return num1 + num2; } static double addArrayNumbers(const int *test_array, int size) { double total = 0; for ( int i = 0; i < size; i++) { total += test_array[i]; } return total; } static double addArrayNumbers(const float *test_array, int size) { double total = 0; for ( int i = 0; i < size; i++) { total += test_array[i]; } return total; } static double addArrayNumbers(const double *test_array, int size) { double sum = 0; for ( int i = 0; i < size; i++) { sum += test_array[i]; } return sum; } static bool addBoolean(bool input1, bool input2) { return input1 + input2; } static bool addBooleanList(const bool *input_list, int size) { bool result = false; for (int i = 0; i < size; i++) { result = result + input_list[i]; } return result; } static std::string getPercentage(double number) { // std::string percentageString = number + '%'; // return ; std::string numberString = std::to_string(number); std::string percentageSymbol = "%"; return numberString + percentageSymbol; } static std::string getPercentage(int number) { // std::string percentageString = number + '%'; // return ; std::string numberString = std::to_string(number); std::string percentageSymbol = "%"; return numberString + percentageSymbol; } static std::string getPercentage(float number) { // std::string percentageString = number + '%'; // return ; std::string numberString = std::to_string(number); std::string percentageSymbol = "%"; return numberString + percentageSymbol; } static double subtractNum(double num1, double num2) { return num1 - num2; } static double subtractNum(int num1, int num2) { return num1 - num2; } static double subtractNum(float num1, float num2) { return num1 - num2; } static double subtractArrayNumbers(const double *array_list, int size) { double negTotal = 0; for ( int i = 0; i < size; i++) { negTotal -= array_list[i]; } return negTotal; } static double subtractArrayNumbers(const int *array_list, int size) { double negTotal = 0; for ( int i = 0; i < size; i++) { negTotal -= array_list[i]; } return negTotal; } static double subtractArrayNumbers(const float *array_list, int size) { double negTotal = 0; for ( int i = 0; i < size; i++) { negTotal -= array_list[i]; } return negTotal; } static double productNum(double num1, double num2) { return num1 * num2; } static double productNum(int num1, int num2) { return num1 * num2; } static double productNum(float num1, float num2) { return num1 * num2; } static double productArrayNumbers(const double *array_list, int size) { double result = 1; for ( int i = 0; i < size; i++) { result *= array_list[i]; } return result; } static double productArrayNumbers(const int *array_list, int size) { double result = 1; for ( int i = 0; i < size; i++) { result *= array_list[i]; } return result; } static double productArrayNumbers(const float *array_list, int size) { double result = 1; for ( int i = 0; i < size; i++) { result *= array_list[i]; } return result; } static bool productBoolean(bool input1, bool input2) { return input1 * input2; } static bool productBooleanList(const bool *input_list, int size) { bool result = true; for ( int i = 0; i < size; i++) { result = result * input_list[i]; } return result; } static double divideNum(double num1, double num2) { return num1 / num2; } static double divideNum(int num1, int num2) { return ((double)num1 / (double )num2); } static double divideNum(float num1, float num2) { return num1 / num2; } static double divideArrayNumbers(const double *array_list, int size) { double total = 1; for ( int i = 0; i < size; i++) { total /= array_list[i] / total; } return total; } static double divideArrayNumbers(const int *array_list, int size) { double total = 1; for ( int i = 0; i < size; i++) { total /= array_list[i] / total; } return total; } static double divideArrayNumbers(const float *array_list, int size) { double total = 1; for ( int i = 0; i < size; i++) { total /= array_list[i] / total; } return total; } static std::string computePercentageFromArray(double number, const double *array_list, int size) { double total = 0; for ( int i = 0; i < size; i++) { total += array_list[i]; } double result = (number / total) * 100; std::string numberStringFormat = std::to_string(result); std::string percentageSymbol = "%"; return numberStringFormat + percentageSymbol; } static std::string computePercentageFromArray(int number, const int *array_list, int size) { double total = 0; for ( int i = 0; i < size; i++) { total += array_list[i]; } double result = (number / total) * 100; std::string numberStringFormat = std::to_string(result); std::string percentageSymbol = "%"; return numberStringFormat + percentageSymbol; } static std::string computePercentageFromArray(float number, const float *array_list, int size) { double total = 0; for ( int i = 0; i < size; i++) { total += array_list[i]; } double result = (number / total) * 100; std::string numberStringFormat = std::to_string(result); std::string percentageSymbol = "%"; return numberStringFormat + percentageSymbol; } static double computeMinimum(double num1, double num2) { if (num1 < num2) { return num1; } else if (num1 > num2) { return num2; } } static double computeMinimum(int num1, int num2) { if (num1 < num2) { return num1; } else if (num1 > num2) { return num2; } } static double computeMinimum(float num1, float num2) { if (num1 < num2) { return num1; } else if (num1 > num2) { return num2; } } static double computeMinimumFromArray(const double *array_list, int size) { double minValue = array_list[0]; for ( int i = 0; i < size; i++) { if (array_list[i] < minValue) { minValue = array_list[i]; } } return minValue; } static double computeMinimumFromArray(const int *array_list, int size) { double minValue = array_list[0]; for ( int i = 0; i < size; i++) { if (array_list[i] < minValue) { minValue = array_list[i]; } } return minValue; } static double computeMinimumFromArray(const float *array_list, int size) { double minValue = array_list[0]; for ( int i = 0; i < size; i++) { if (array_list[i] < minValue) { minValue = array_list[i]; } } return minValue; } static double computeMaximum(double num1, double num2) { if (num1 > num2) { return num1; } else if (num1 < num2) { return num2; } } static double computeMaximum(int num1, int num2) { if (num1 > num2) { return num1; } else if (num1 < num2) { return num2; } } static double computeMaximum(float num1, float num2) { if (num1 > num2) { return num1; } else if (num1 < num2) { return num2; } } static double computeMaximumFromArray(const double *array_list, int size) { double maxValue = array_list[0]; for ( int i = 0; i < size; i++) { if (array_list[i] > maxValue) { maxValue = array_list[i]; } } return maxValue; } static double computeMaximumFromArray(const int *array_list, int size) { double maxValue = array_list[0]; for ( int i = 0; i < size; i++) { if (array_list[i] > maxValue) { maxValue = array_list[i]; } } return maxValue; } static double computeMaximumFromArray(const float *array_list, int size) { double maxValue = array_list[0]; for ( int i = 0; i < size; i++) { if (array_list[i] > maxValue) { maxValue = array_list[i]; } } return maxValue; } static double computeRectangleArea(double length, double breadth) { return length * breadth; } static double computeRectangleArea(int length, double breadth) { return length * breadth; } static double computeRectangleArea(float length, double breadth) { return length * breadth; } static double computeRectanglePerimeter(double length, double breadth) { return 2 * (length + breadth); } static double computeRectanglePerimeter(int length, double breadth) { return 2 * (length + breadth); } static double computeRectanglePerimeter(float length, double breadth) { return 2 * (length + breadth); } static double computeSquareArea(double side) { return side * side; } static double computeSquareArea(int side) { return side * side; } static double computeSquareArea(float side) { return side * side; } static double computeSquarePerimeter(double side) { return 4 * side; } static double computeSquarePerimeter(int side) { return 4 * side; } static double computeSquarePerimeter(float side) { return 4 * side; } static double computeCircleCircumference(int radius) { return 2 * PI * radius; } static double computeCircleCircumference(float radius) { return 2 * PI * radius; } static double computeCircleCircumference(double radius) { return 2 * PI * radius; } static double computeCircleArea(int radius) { return PI * radius * radius; } static double computeCircleArea(double radius) { return PI * radius * radius; } static double computeCircleArea(float radius) { return PI * radius * radius; } static bool checkEven(int number) { return number % 2 == 0; } static bool checkEven(long int number) { return number % 2 == 0; } static bool checkOdd(int number) { return number % 2 != 0; } static bool checkOdd(long int number) { return number % 2 != 0; } protected: }; #endif // for _MATH_TOOLS__BASIC_TOOL_SET_CPP_MACRO___
22.854054
105
0.622044
[ "vector" ]
57ba673d6073d6d60a574db4f0dc9131895e21b4
3,754
h
C
src/libsshqtquestiondialog.h
artoka/libsshqt
5c69fbf478a1514380308e72815dbe02f2b290e6
[ "MIT" ]
6
2015-04-21T07:13:05.000Z
2022-03-08T01:26:49.000Z
src/libsshqtquestiondialog.h
artoka/libsshqt
5c69fbf478a1514380308e72815dbe02f2b290e6
[ "MIT" ]
null
null
null
src/libsshqtquestiondialog.h
artoka/libsshqt
5c69fbf478a1514380308e72815dbe02f2b290e6
[ "MIT" ]
4
2017-09-26T20:00:13.000Z
2021-11-10T18:54:02.000Z
#ifndef LIBSSHQTQUESTIONDIALOG_H #define LIBSSHQTQUESTIONDIALOG_H #include <QDialog> #include "libsshqtclient.h" namespace Ui { class LibsshQtQuestionDialog; } /*! LibsshQtQuestionDialog - Question and message dialog for LibsshQtClient LibsshQtQuestionDialog implements the standard question dialogs needed while connecting to a SSH server. Specifically LibsshQtQuestionDialog handles unknownHost, needPassword and needKbiAnswers signals emitted by LibsshQtClient and displays the appropriate dialog to the user. If the user types the wrong password then LibsshQtQuestionDialog re-enables the attempted authentication method and re-displays the authentication dialog. Specifically If LibsshQtClient emits authFailed signal and the failed authentication type is either UseAuthPassword or UseAuthKbi and if the server actually supports the attempted method, then LibsshQtQuestionDialog will re-enable the failed authentication method. If LibsshQtClient emits allAuthsFailed or error signal then LibsshQtQuestionDialog displays either "Authentication Failed" or "Error" messagebox. If you want to display these messages yourself, you can disable these messageboxes with setShowAuthsFailedDlg() and setShowErrorDlg() functions. If user cancels a dialog, LibsshQtClient::disconnectFromHost() is called. Use setClient() function to set which LibsshQtClient object is handled by LibsshQtQuestionDialog. */ class LibsshQtQuestionDialog : public QDialog { Q_OBJECT public: Q_ENUMS(State) enum State { StateHidden, StateUnknownHostDlg, StatePasswordAuthDlg, StateKbiAuthDlg }; explicit LibsshQtQuestionDialog(QWidget *parent = 0); ~LibsshQtQuestionDialog(); static const char *enumToString(const State value); void setClient(LibsshQtClient *client); void setUnknownHostIcon(QIcon icon); void setAuthIcon(QIcon icon); void setShowAuthsFailedDlg(bool enabled); void setShowErrorDlg(bool enabled); State state() const; void done(int code); void setVisible(bool visible); private slots: void handleDebugChanged(); void handleUnknownHost(); void handleNeedPassword(); void handleNeedKbiAnswers(); void showNextKbiQuestion(); void handleAuthFailed(int auth); void handleAllAuthsFailed(); void handleError(); private: void setState(State state); void showHostDlg(QString message, QString info); void showAuthDlg(QString message, bool show_answer = false); void showInfoDlg(QString message, QString title); private: QString debug_prefix_; bool debug_output_; Ui::LibsshQtQuestionDialog *ui_; LibsshQtClient *client_; State state_; QList<LibsshQtClient::KbiQuestion> kbi_questions_; QStringList kbi_answers_; int kbi_pos_; bool show_auths_failed_dlg_; bool show_error_dlg_; }; // Include <QDebug> before "libsshqt.h" if you want to use these operators #ifdef QDEBUG_H inline QDebug operator<<(QDebug dbg, const LibsshQtQuestionDialog *gui) { dbg.nospace() << "LibsshQtQuestionDialog( " << LibsshQtQuestionDialog::enumToString(gui->state()) << " )"; return dbg.space(); } inline QDebug operator<<(QDebug dbg, const LibsshQtQuestionDialog::State value) { dbg << LibsshQtQuestionDialog::enumToString(value); return dbg; } #endif #endif // LIBSSHQTQUESTIONDIALOG_H
24.376623
80
0.689664
[ "object" ]
57bd1acfb3b3c4a111729ab94a2202144bb8d907
1,459
h
C
src/objects/_objects.h
TravisWheelerLab/MMOREseqs
492eda6efa4fd95ac0a787405a40db5a860bf3dc
[ "BSD-3-Clause-Clear", "BSD-3-Clause" ]
null
null
null
src/objects/_objects.h
TravisWheelerLab/MMOREseqs
492eda6efa4fd95ac0a787405a40db5a860bf3dc
[ "BSD-3-Clause-Clear", "BSD-3-Clause" ]
null
null
null
src/objects/_objects.h
TravisWheelerLab/MMOREseqs
492eda6efa4fd95ac0a787405a40db5a860bf3dc
[ "BSD-3-Clause-Clear", "BSD-3-Clause" ]
null
null
null
/******************************************************************************* * - FILE: objects.h * - DESC: All /object/ folder headers. * NOTES: * - This include folder needs to respect inter-object folder dependencies. * - The plan is to extract most struct definitions and place them in the files with their function defs. * - Need unit tests. *******************************************************************************/ #ifndef _OBJECTS_H #define _OBJECTS_H /* declares all datatypes */ #include "structs.h" /* basic types (no dependencies) */ #include "basic/_basic.h" /* vector types (only dependent on basic types) */ #include "vectors/_vectors.h" /* normal matrix types */ #include "matrix/_matrix.h" /* sparse matrix */ #include "matrix_sparse/_matrix_sparse.h" /* complex objects (can be dependent on basics, vectors, and matrices) */ #include "alignment.h" #include "arg_opts.h" #include "args.h" #include "clock.h" #include "debugger.h" #include "domain_def.h" #include "f_index.h" #include "hmm_profile.h" #include "hmm_bg.h" #include "mystring.h" #include "results.h" #include "m8_results.h" #include "score_matrix.h" #include "sequence.h" #include "scriptrunner.h" #include "commandline.h" /* worker (dependent on most object types) */ #include "worker_thread.h" #include "worker.h" /* io (dependent on all so that it can read in / write any data type) */ #include "io/_io.h" #endif /* _OBJECTS_H */
27.018519
108
0.626456
[ "object", "vector" ]
57cf31322151ee61595002f74bd82049ef8fb1b7
407
h
C
Engine/Source/Physics/SphereCollider.h
olekolek1000/Fractal_Engine
1aa42e54c42fe834e4e28baac6ecab3283448660
[ "MIT" ]
150
2021-04-12T05:25:07.000Z
2022-03-31T21:23:51.000Z
Engine/Source/Physics/SphereCollider.h
olekolek1000/Fractal_Engine
1aa42e54c42fe834e4e28baac6ecab3283448660
[ "MIT" ]
17
2021-06-04T20:49:15.000Z
2022-03-04T09:09:43.000Z
Engine/Source/Physics/SphereCollider.h
olekolek1000/Fractal_Engine
1aa42e54c42fe834e4e28baac6ecab3283448660
[ "MIT" ]
19
2021-04-25T21:43:15.000Z
2022-03-05T12:29:32.000Z
#pragma once #include "Collider.h" namespace fr::Physics { class SphereCollider : Collider { public: SphereCollider(const Vec3& center, float radius) : Collider(FR_PHYSICS_COLLIDER_TYPE_SPHERE),_center(center), _radius(radius) {} IntersectData IntersectSphereCollider(SphereCollider& other); virtual void Transform(Vec3& translation); static void Test(); Vec3 _center; float _radius; }; }
25.4375
130
0.759214
[ "transform" ]
57deec87246b43c96778639a985e17639a1867eb
2,591
h
C
media/gpu/test/video_test_environment.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
14,668
2015-01-01T01:57:10.000Z
2022-03-31T23:33:32.000Z
media/gpu/test/video_test_environment.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
113
2015-05-04T09:58:14.000Z
2022-01-31T19:35:03.000Z
media/gpu/test/video_test_environment.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
5,941
2015-01-02T11:32:21.000Z
2022-03-31T16:35:46.000Z
// Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // This file contains helper classes for video accelerator unittests. #ifndef MEDIA_GPU_TEST_VIDEO_TEST_ENVIRONMENT_H_ #define MEDIA_GPU_TEST_VIDEO_TEST_ENVIRONMENT_H_ #include <memory> #include <vector> #include "base/at_exit.h" #include "base/files/file_path.h" #include "base/test/scoped_feature_list.h" #include "media/gpu/test/video_frame_file_writer.h" #include "testing/gtest/include/gtest/gtest.h" namespace base { namespace test { class TaskEnvironment; } // namespace test } // namespace base namespace media { namespace test { // The frame output mode allows controlling which video frames are written to // disk. Writing frames will greatly slow down the test and generate a lot of // test artifacts, so be careful when configuring other modes than kNone in // automated testing. enum class FrameOutputMode { kNone, // Don't output any frames. kCorrupt, // Only output corrupt frames. kAll // Output all frames. }; // Frame output configuration. struct FrameOutputConfig { // The frame output mode controls which frames will be output. FrameOutputMode output_mode = FrameOutputMode::kNone; // The maximum number of frames that will be output. uint64_t output_limit = std::numeric_limits<uint64_t>::max(); // The format of frames that are output. VideoFrameFileWriter::OutputFormat output_format = VideoFrameFileWriter::OutputFormat::kPNG; }; class VideoTestEnvironment : public ::testing::Environment { public: VideoTestEnvironment(); // Features are overridden by given features in this environment. VideoTestEnvironment(const std::vector<base::Feature>& enabled_features, const std::vector<base::Feature>& disabled_features); virtual ~VideoTestEnvironment(); // ::testing::Environment implementation. // Tear down video test environment, called once for entire test run. void TearDown() override; // Get the name of the test output file path (testsuitename/testname). base::FilePath GetTestOutputFilePath() const; private: // An exit manager is required to run callbacks on shutdown. base::AtExitManager at_exit_manager; std::unique_ptr<base::test::TaskEnvironment> task_environment_; // Features to override default feature settings in this environment. base::test::ScopedFeatureList scoped_feature_list_; }; } // namespace test } // namespace media #endif // MEDIA_GPU_TEST_VIDEO_TEST_ENVIRONMENT_H_
33.649351
77
0.75878
[ "vector" ]
57e18c564fe2226eef634071e22176635d929f21
8,662
h
C
Source/Projects/GoddamnCore/Source/GoddamnEngine/Core/Object/Struct.h
GoddamnIndustries/GoddamnEngine
018c6582f6a2ebcba2c59693c677744434d66b20
[ "MIT" ]
4
2015-07-05T16:46:12.000Z
2021-02-04T09:32:47.000Z
Source/Projects/GoddamnCore/Source/GoddamnEngine/Core/Object/Struct.h
GoddamnIndustries/GoddamnEngine
018c6582f6a2ebcba2c59693c677744434d66b20
[ "MIT" ]
null
null
null
Source/Projects/GoddamnCore/Source/GoddamnEngine/Core/Object/Struct.h
GoddamnIndustries/GoddamnEngine
018c6582f6a2ebcba2c59693c677744434d66b20
[ "MIT" ]
1
2017-01-27T22:49:12.000Z
2017-01-27T22:49:12.000Z
// ========================================================================================== // Copyright (C) Goddamn Industries 2018. All Rights Reserved. // // This software or any its part is distributed under terms of Goddamn Industries End User // License Agreement. By downloading or using this software or any its part you agree with // terms of Goddamn Industries End User License Agreement. // ========================================================================================== /*! * @file GoddamnEngine/Core/Object/StructInstanceInstance.h * File contains base declaration for structures in the entities system. */ #pragma once #include <GoddamnEngine/Include.h> #include <GoddamnEngine/Core/Object/ObjectVisitor.h> GD_NAMESPACE_BEGIN // **------------------------------------------------------------------------------------------** //! Zero-overhead base class for all reflectable structures. // **------------------------------------------------------------------------------------------** struct GD_OBJECT_KERNEL Struct { public: /*! * Visits all properties of this structure. * * @param objectVisitor Visitor to process this structure. * @see IObjectVisitor interface. */ GDINL void GD_OBJECT_GENERATED Reflect(ObjectVisitor& objectVisitor) { GD_NOT_USED(objectVisitor); GD_NOT_USED(this); } }; // struct Struct // **~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~** // ****** Very scary macros for generating boilerplate code. ****** // **~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~** /*! Declares very a base struct information. Implements reflection algorithms. */ #define GD_DECLARE_STRUCT_BASE(TThisClass, TSuperClass, ...) GD_OBJECT_KERNEL \ public: using This = TThisClass; using Super = TSuperClass; \ /*! Declares a very base property information. */ #define GD_PROPERTY_NO_DECL_BASE(TPropertyName) GD_OBJECT_KERNEL /*! Declares a very base function information. */ #define GD_FUNCTION_NO_DECL_BASE(TFunctionName) GD_OBJECT_KERNEL #if GD_COMPILER_MSVC // Visual Studio Compiler allows us to use explicit template specialization. // So using MSVC compiler we can generate less code and save some compilation time. /*! * Declares a struct information. Implements reflection algorithms. * * @param TThisClass Name of this class. * @param TSuperClass Name of super class. */ //! @{ #define GD_DECLARE_STRUCT(TThisClass, TSuperClass, ...) GD_OBJECT_KERNEL \ GD_DECLARE_STRUCT_BASE(TThisClass, TSuperClass, ##__VA_ARGS__) \ private: template<unsigned TFieldIndex> void ReflectPrivate(ObjectVisitor&) { } \ public: void GD_OBJECT_GENERATED Reflect(ObjectVisitor& objectVisitor) /*NOLINT*/ \ { \ TSuperClass::Reflect(objectVisitor); \ ReflectPrivate<__COUNTER__ + 1>(objectVisitor); \ } #define GD_DECLARE_STRUCT_VIRTUAL(TThisClass, TSuperClass, ...) GD_OBJECT_KERNEL \ GD_DECLARE_STRUCT_BASE(TThisClass, TSuperClass, ##__VA_ARGS__) \ private: template<unsigned TFieldIndex> void ReflectPrivate(ObjectVisitor&) { } \ public: virtual void GD_OBJECT_GENERATED Reflect(ObjectVisitor& objectVisitor) override /*NOLINT*/ \ { \ TSuperClass::Reflect(objectVisitor); \ ReflectPrivate<__COUNTER__ + 1>(objectVisitor); \ } //! @} /*! * Declares a reflectable property information. Can be used for both classes and structures. * @param TPropertyName Name of the property. */ #define GD_PROPERTY_NO_DECL(TPropertyName, ...) GD_OBJECT_KERNEL \ GD_PROPERTY_NO_DECL_BASE(TPropertyName); \ private: template<> void ReflectPrivate<__COUNTER__>(ObjectVisitor& objectVisitor) /*NOLINT*/ \ { \ static PropertyMetaInfo const propertyMetaInfo(#TPropertyName, ##__VA_ARGS__); \ objectVisitor.VisitProperty(&propertyMetaInfo, TPropertyName); \ ReflectPrivate<__COUNTER__ + 1>(objectVisitor); \ } \ /*! * Declares a reflectable function information. Can be used for both classes and structures. * @param TFunctionName Name of the function. */ #define GD_FUNCTION_NO_DECL(TFunctionName, ...) GD_OBJECT_KERNEL \ GD_FUNCTION_NO_DECL_BASE(TFunctionName); \ private: template<> void ReflectPrivate<__COUNTER__>(ObjectVisitor& objectVisitor) /*NOLINT*/ \ { \ static ObjectFunctionMetaInfo const objectFunctionMetaInfo(#TFunctionName, ##__VA_ARGS__); \ objectVisitor.VisitFunction(&objectFunctionMetaInfo, &This::TFunctionName); \ ReflectPrivate<__COUNTER__ + 1>(objectVisitor); \ } \ #else // if GD_COMPILER_MSVC // We cannot explicitly specialize template function. So we will have to declare inner struct // that replaces explicit template specialization with partial template specialization. // See https://gist.github.com/mejedi/5875719 /*! * Declares a struct information. Implements reflection algorithms. * * @param TThisClass Name of this class. * @param TSuperClass Name of super class. */ //! @{ #define GD_DECLARE_STRUCT(TThisClass, TSuperClass, ...) GD_OBJECT_KERNEL \ GD_DECLARE_STRUCT_BASE(TThisClass, TSuperClass, ##__VA_ARGS__) \ private: template<typename TObjectVisitor, unsigned TFieldIndex> struct ReflectPrivate { static void Invoke(TObjectVisitor&, This* const) { } };\ public: void GD_OBJECT_GENERATED Reflect(ObjectVisitor& objectVisitor) /*NOLINT*/ \ { \ TSuperClass::Reflect(objectVisitor); \ ReflectPrivate<ObjectVisitor, __COUNTER__ + 1>::Invoke(objectVisitor, this); \ } #define GD_DECLARE_STRUCT_VIRTUAL(TThisClass, TSuperClass, ...) GD_OBJECT_KERNEL \ GD_DECLARE_STRUCT_BASE(TThisClass, TSuperClass, ##__VA_ARGS__) \ private: template<typename TObjectVisitor, unsigned TFieldIndex> struct ReflectPrivate { static void Invoke(TObjectVisitor&, This* const) { } };\ public: virtual void GD_OBJECT_GENERATED Reflect(ObjectVisitor& objectVisitor) override /*NOLINT*/ \ { \ TSuperClass::Reflect(objectVisitor); \ ReflectPrivate<ObjectVisitor, __COUNTER__ + 1>::Invoke(objectVisitor, this); \ } //! @} /*! * Declares a reflectable property information. Can be used for both classes and structures. * @param TPropertyName Name of the property. */ #define GD_PROPERTY_NO_DECL(TPropertyName, ...) \ GD_PROPERTY_NO_DECL_BASE(TPropertyName); \ private: template<typename TObjectVisitor> struct ReflectPrivate<TObjectVisitor, __COUNTER__> \ { \ static void Invoke(TObjectVisitor& objectVisitor, This* const self) \ { \ static PropertyMetaInfo const propertyMetaInfo(#TPropertyName, ##__VA_ARGS__); \ objectVisitor.VisitProperty(&propertyMetaInfo, self->TPropertyName); \ ReflectPrivate<TObjectVisitor, __COUNTER__ + 1>::Invoke(objectVisitor, self); \ } \ }; \ /*! * Declares a reflectable function information. Can be used for both classes and structures. * @param TFunctionName Name of the function. */ #define GD_FUNCTION_NO_DECL(TFunctionName, ...) \ GD_PROPERTY_NO_DECL_BASE(TFunctionName); \ private: template<typename TObjectVisitor> struct ReflectPrivate<TObjectVisitor, __COUNTER__> \ { \ static void Invoke(TObjectVisitor& objectVisitor, This* const self) \ { \ static ObjectFunctionMetaInfo const objectFunctionMetaInfo(#TFunctionName, ##__VA_ARGS__); \ objectVisitor.VisitFunction(&objectFunctionMetaInfo, &This::TFunctionName); \ ReflectPrivate<__COUNTER__ + 1>::Invoke(objectVisitor, self); \ } \ }; \ #endif // if GD_COMPILER_MSVC /*! * Declares a reflectable property. Can be used for both classes and structures. * * @param TPropertyAccess Access modifier for this property. * @param TPropertyType Type of the property. * @param TPropertyName Name of the property. */ #define GD_PROPERTY(TPropertyAccess, TPropertyType, TPropertyName, ...) GD_OBJECT_KERNEL \ GD_PROPERTY_NO_DECL(TPropertyName, ##__VA_ARGS__); \ TPropertyAccess: TPropertyType TPropertyName /*! * Declares a reflectable function. Can be used for both classes and structures. * * @param TFunctionAccess Access modifier for this property. * @param TEAPI Export modifier for this property. * @param TFunctionReturnType Return type of the property. * @param TFunctionName Name of the function. */ #define GD_FUNCTION(TFunctionAccess, TEAPI, TFunctionReturnType, TFunctionName, ...) GD_OBJECT_KERNEL \ GD_FUNCTION_NO_DECL(TFunctionName, ##__VA_ARGS__); \ TFunctionAccess: TEAPI TFunctionReturnType TFunctionName GD_NAMESPACE_END
43.31
149
0.684369
[ "object" ]
57eed595718d05f76adfa76a4db8562c9b93e08a
783
h
C
Sail/src/Sail/graphics/postprocessing/stages/DOFStage.h
h3nx/Sail
96c13ee50bf9666c01bb8bb263e0c2dc3ba0eff9
[ "MIT" ]
9
2019-03-18T18:35:29.000Z
2020-10-26T06:30:18.000Z
Sail/src/Sail/graphics/postprocessing/stages/DOFStage.h
h3nx/Sail
96c13ee50bf9666c01bb8bb263e0c2dc3ba0eff9
[ "MIT" ]
11
2019-06-10T19:54:11.000Z
2020-04-14T08:50:47.000Z
Sail/src/Sail/graphics/postprocessing/stages/DOFStage.h
h3nx/Sail
96c13ee50bf9666c01bb8bb263e0c2dc3ba0eff9
[ "MIT" ]
5
2019-06-16T20:24:50.000Z
2020-03-03T09:27:18.000Z
#pragma once #include "PostProcessStage.h" #include "../../shader/ShaderSet.h" #include "../../shader/component/ConstantBuffer.h" #include "../../shader/component/Sampler.h" #include "../../../Application.h" class DOFStage : public PostProcessStage { public: DOFStage(UINT width, UINT height, Model* fullScreenQuad); virtual ~DOFStage(); void setDepthSRV(ID3D11ShaderResourceView** depthSRV); void run(RenderableTexture& inputTexture); void resize(UINT width, UINT height); private: void createOutputUAV(); private: std::unique_ptr<ComputeShader> m_CS; struct CBuffer { float zNear; float zFar; float padding[2]; }; ID3D11UnorderedAccessView* m_outputUAV; std::unique_ptr<ShaderComponent::ConstantBuffer> m_cBuffer; ID3D11ShaderResourceView** m_depthSRV; };
23.029412
60
0.748404
[ "model" ]
57fb181aaef5b6f67d89880c9fbcfd9968a4f02d
5,532
h
C
python/dartpy/eigen_geometry_pybind.h
alinen/dart
e84d236f40238654779a2c1541534906a8ad8b93
[ "BSD-2-Clause" ]
729
2015-01-05T22:01:30.000Z
2022-03-31T14:26:23.000Z
python/dartpy/eigen_geometry_pybind.h
alinen/dart
e84d236f40238654779a2c1541534906a8ad8b93
[ "BSD-2-Clause" ]
1,071
2015-01-01T05:48:33.000Z
2022-03-22T17:10:36.000Z
python/dartpy/eigen_geometry_pybind.h
alinen/dart
e84d236f40238654779a2c1541534906a8ad8b93
[ "BSD-2-Clause" ]
295
2015-01-09T01:50:25.000Z
2022-03-24T03:20:20.000Z
// // All components of Drake are licensed under the BSD 3-Clause License // shown below. Where noted in the source code, some portions may // be subject to other permissive, non-viral licenses. // // Copyright 2012-2016 Robot Locomotion Group @ CSAIL // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. Redistributions // in binary form must reproduce the above copyright notice, this list of // conditions and the following disclaimer in the documentation and/or // other materials provided with the distribution. Neither the name of // the Massachusetts Institute of Technology nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // #pragma once /// @file /// Provides pybind11 `type_caster`s for Eigen geometric types. /// N.B. This uses some of pybind's coding conventions. /// /// See http://pybind11.readthedocs.io/en/stable/advanced/cast/custom.html for /// more details on custom type casters. #include <string> #include <utility> #include <Eigen/Dense> #include "pybind11/eigen.h" namespace dart { namespace python { namespace detail { // Implements a `type_caster<>` specialization used to convert types using a // specific wrapping policy. // @tparam Wrapper // Struct which must provide `Type`, `WrappedType`, `unwrap`, and `wrap`. // @tparam copy_only // This may only pass between C++ and Python as copies, not references. // See `eigen_wrapper_*` structs below for more details. template <typename Wrapper> struct type_caster_wrapped { using Type = typename Wrapper::Type; using WrappedType = typename Wrapper::WrappedType; using WrappedTypeCaster = ::pybind11::detail::type_caster<WrappedType>; // Python to C++. bool load(::pybind11::handle src, bool converter) { WrappedTypeCaster caster; if (!caster.load(src, converter)) { return false; } value_ = Wrapper::unwrap(caster.operator WrappedType&()); loaded_ = true; return true; } // See `pybind11/eigen.h`, `type_caster<>` implementations. // N.B. Do not use `PYBIND11_TYPE_CASTER(...)` so we can avoid casting // garbage values. operator Type&() { assert(loaded_); return value_; } template <typename T> using cast_op_type = ::pybind11::detail::movable_cast_op_type<T>; static constexpr auto name = WrappedTypeCaster::props::descriptor; // C++ to Python. template <typename TType> static ::pybind11::handle cast(TType&& src, ::pybind11::return_value_policy policy, ::pybind11::handle parent) { if (policy == ::pybind11::return_value_policy::reference || policy == ::pybind11::return_value_policy::reference_internal) { // N.B. We must declare a local `static constexpr` here to prevent // linking errors. This does not appear achievable with // `constexpr char[]`, so we use `::pybind11::detail::descr`. // See `pybind11/pybind11.h`, `cpp_function::initialize(...)` for an // example. static constexpr auto original_name = Wrapper::original_name; throw ::pybind11::cast_error( std::string("Can only pass ") + original_name.text + " by value."); } return WrappedTypeCaster::cast( Wrapper::wrap(std::forward<TType>(src)), policy, parent); } private: bool loaded_{false}; Type value_; }; // Wrapper for Eigen::Translation<>, to be used as first parameter to // `type_caster_wrapped`. // Since there are not many special operations for a translation vector, we // shall return it as a nominal vector. template <typename T, int Dim> struct wrapper_eigen_translation { using Type = Eigen::Translation<T, Dim>; using WrappedType = Eigen::Matrix<T, Dim, 1>; static constexpr auto original_name = ::pybind11::detail::_("Eigen::Translation<>"); static Type unwrap(const WrappedType& arg_wrapped) { return Type(arg_wrapped); } static WrappedType wrap(const Type& arg) { return arg.vector(); } }; // N.B. Since `Isometry3<>` and `Eigen::Quaternion<>` have more // complicated structures, they are registered as types in `eigen_geometry_py`. } // namespace detail } // namespace python } // namespace dart namespace pybind11 { namespace detail { template <typename T, int Dim> struct type_caster<Eigen::Translation<T, Dim>> : public dart::python::detail::type_caster_wrapped< dart::python::detail::wrapper_eigen_translation<T, Dim>> {}; } // namespace detail } // namespace pybind11
37.378378
86
0.721077
[ "vector" ]