hexsha
stringlengths
40
40
size
int64
5
1.05M
ext
stringclasses
588 values
lang
stringclasses
305 values
max_stars_repo_path
stringlengths
3
363
max_stars_repo_name
stringlengths
5
118
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
10
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringdate
2015-01-01 00:00:35
2022-03-31 23:43:49
max_stars_repo_stars_event_max_datetime
stringdate
2015-01-01 12:37:38
2022-03-31 23:59:52
max_issues_repo_path
stringlengths
3
363
max_issues_repo_name
stringlengths
5
118
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
10
max_issues_count
float64
1
134k
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
363
max_forks_repo_name
stringlengths
5
135
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
10
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringdate
2015-01-01 00:01:02
2022-03-31 23:27:27
max_forks_repo_forks_event_max_datetime
stringdate
2015-01-03 08:55:07
2022-03-31 23:59:24
content
stringlengths
5
1.05M
avg_line_length
float64
1.13
1.04M
max_line_length
int64
1
1.05M
alphanum_fraction
float64
0
1
a046f9d90d5f490a4983be77d92ec441d54f67de
857
h
C
src/xop/media.h
5455945/RtspServer
56eb826215ad2be5533154676c354f43f013cef1
[ "MIT" ]
null
null
null
src/xop/media.h
5455945/RtspServer
56eb826215ad2be5533154676c354f43f013cef1
[ "MIT" ]
null
null
null
src/xop/media.h
5455945/RtspServer
56eb826215ad2be5533154676c354f43f013cef1
[ "MIT" ]
1
2020-01-03T08:31:16.000Z
2020-01-03T08:31:16.000Z
// PHZ // 2018-5-16 #ifndef XOP_MEDIA_H #define XOP_MEDIA_H #include <memory> namespace xop { // RTSP服务支持的媒体类型 enum MediaType { //PCMU = 0, PCMA = 8, H264 = 96, AAC = 37, H265 = 265, NONE }; enum FrameType { VIDEO_FRAME_I = 0x01, VIDEO_FRAME_P = 0x02, VIDEO_FRAME_B = 0x03, AUDIO_FRAME = 0x11, }; struct AVFrame { AVFrame(uint32_t size = 0) :buffer(new uint8_t[size + 1]) { this->size = size; type = 0; timestamp = 0; } std::shared_ptr<uint8_t> buffer; /* 帧数据 */ uint32_t size; /* 帧大小 */ uint8_t type; /* 帧类型 */ uint32_t timestamp; /* 时间戳 */ }; #define MAX_MEDIA_CHANNEL 2 typedef enum __MediaChannel_Id { channel_0, channel_1 } MediaChannelId; typedef uint32_t MediaSessionId; } #endif
14.04918
46
0.563594
53b874b370bd44fd453576debdd8a09efa531b48
6,934
c
C
src/Logikanalysator/sigrok-integration/libsigrokdecode/tests/check_session.c
dm7h/fpga-event-recorder
4e53babbbb514ee375f4b5585b1d24e5b40f8df7
[ "0BSD" ]
null
null
null
src/Logikanalysator/sigrok-integration/libsigrokdecode/tests/check_session.c
dm7h/fpga-event-recorder
4e53babbbb514ee375f4b5585b1d24e5b40f8df7
[ "0BSD" ]
null
null
null
src/Logikanalysator/sigrok-integration/libsigrokdecode/tests/check_session.c
dm7h/fpga-event-recorder
4e53babbbb514ee375f4b5585b1d24e5b40f8df7
[ "0BSD" ]
null
null
null
/* * This file is part of the libsigrokdecode project. * * Copyright (C) 2013 Uwe Hermann <uwe@hermann-uwe.de> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "../libsigrokdecode.h" /* First, to avoid compiler warning. */ #include "../libsigrokdecode-internal.h" #include <stdlib.h> #include <check.h> static void setup(void) { /* Silence libsigrokdecode while the unit tests run. */ srd_log_loglevel_set(SRD_LOG_NONE); } static void teardown(void) { } /* * Check whether srd_session_new() works. * If it returns != SRD_OK (or segfaults) this test will fail. */ START_TEST(test_session_new) { int ret; struct srd_session *sess; srd_init(NULL); ret = srd_session_new(&sess); fail_unless(ret == SRD_OK, "srd_session_new() failed: %d.", ret); srd_exit(); } END_TEST /* * Check whether srd_session_new() fails for bogus parameters. * If it returns SRD_OK (or segfaults) this test will fail. */ START_TEST(test_session_new_bogus) { int ret; srd_init(NULL); ret = srd_session_new(NULL); fail_unless(ret != SRD_OK, "srd_session_new(NULL) worked."); srd_exit(); } END_TEST /* * Check whether multiple srd_session_new() calls work. * If any call returns != SRD_OK (or segfaults) this test will fail. */ START_TEST(test_session_new_multiple) { int ret; struct srd_session *sess1, *sess2, *sess3; sess1 = sess2 = sess3 = NULL; srd_init(NULL); /* Multiple srd_session_new() calls must work. */ ret = srd_session_new(&sess1); fail_unless(ret == SRD_OK, "srd_session_new() 1 failed: %d.", ret); ret = srd_session_new(&sess2); fail_unless(ret == SRD_OK, "srd_session_new() 2 failed: %d.", ret); ret = srd_session_new(&sess3); fail_unless(ret == SRD_OK, "srd_session_new() 3 failed: %d.", ret); /* The returned session pointers must all be non-NULL. */ fail_unless(sess1 != NULL); fail_unless(sess2 != NULL); fail_unless(sess3 != NULL); /* The returned session pointers must not be the same. */ fail_unless(sess1 != sess2); fail_unless(sess1 != sess3); fail_unless(sess2 != sess3); /* Each session must have another ID than any other session. */ fail_unless(sess1->session_id != sess2->session_id); fail_unless(sess1->session_id != sess3->session_id); fail_unless(sess2->session_id != sess3->session_id); /* Destroying any of the sessions must work. */ ret = srd_session_destroy(sess1); fail_unless(ret == SRD_OK, "srd_session_destroy() 1 failed: %d.", ret); ret = srd_session_destroy(sess2); fail_unless(ret == SRD_OK, "srd_session_destroy() 2 failed: %d.", ret); ret = srd_session_destroy(sess3); fail_unless(ret == SRD_OK, "srd_session_destroy() 3 failed: %d.", ret); srd_exit(); } END_TEST /* * Check whether srd_session_destroy() works. * If it returns != SRD_OK (or segfaults) this test will fail. */ START_TEST(test_session_destroy) { int ret; struct srd_session *sess; srd_init(NULL); srd_session_new(&sess); ret = srd_session_destroy(sess); fail_unless(ret == SRD_OK, "srd_session_destroy() failed: %d.", ret); srd_exit(); } END_TEST /* * Check whether srd_session_destroy() fails for bogus sessions. * If it returns SRD_OK (or segfaults) this test will fail. */ START_TEST(test_session_destroy_bogus) { int ret; srd_init(NULL); ret = srd_session_destroy(NULL); fail_unless(ret != SRD_OK, "srd_session_destroy() failed: %d.", ret); srd_exit(); } END_TEST static void conf_check_ok(struct srd_session *sess, int key, uint64_t x) { int ret; ret = srd_session_metadata_set(sess, key, g_variant_new_uint64(x)); fail_unless(ret == SRD_OK, "srd_session_metadata_set(%p, %d, %" PRIu64 ") failed: %d.", sess, key, x, ret); } static void conf_check_fail(struct srd_session *sess, int key, uint64_t x) { int ret; ret = srd_session_metadata_set(sess, key, g_variant_new_uint64(x)); fail_unless(ret != SRD_OK, "srd_session_metadata_set(%p, %d, %" PRIu64 ") worked.", sess, key, x); } static void conf_check_fail_null(struct srd_session *sess, int key) { int ret; ret = srd_session_metadata_set(sess, key, NULL); fail_unless(ret != SRD_OK, "srd_session_metadata_set(NULL) for key %d worked.", key); } static void conf_check_fail_str(struct srd_session *sess, int key, const char *s) { int ret; ret = srd_session_metadata_set(sess, key, g_variant_new_string(s)); fail_unless(ret != SRD_OK, "srd_session_metadata_set() for key %d " "failed: %d.", key, ret); } /* * Check whether srd_session_metadata_set() works. * If it returns != SRD_OK (or segfaults) this test will fail. */ START_TEST(test_session_metadata_set) { uint64_t i; struct srd_session *sess; srd_init(NULL); srd_session_new(&sess); /* Try a bunch of values. */ for (i = 0; i < 1000; i++) { conf_check_ok(sess, SRD_CONF_SAMPLERATE, i); } /* Try the max. possible value. */ conf_check_ok(sess, SRD_CONF_SAMPLERATE, 18446744073709551615ULL); srd_session_destroy(sess); srd_exit(); } END_TEST /* * Check whether srd_session_metadata_set() fails with invalid input. * If it returns SRD_OK (or segfaults) this test will fail. */ START_TEST(test_session_metadata_set_bogus) { struct srd_session *sess; srd_init(NULL); srd_session_new(&sess); /* Incorrect gvariant type (currently only uint64 is used). */ conf_check_fail_str(sess, SRD_CONF_SAMPLERATE, ""); conf_check_fail_str(sess, SRD_CONF_SAMPLERATE, "Foo"); /* NULL data pointer. */ conf_check_fail_null(sess, SRD_CONF_SAMPLERATE); /* NULL session. */ conf_check_fail(NULL, SRD_CONF_SAMPLERATE, 0); /* Invalid keys. */ conf_check_fail(sess, -1, 0); conf_check_fail(sess, 9, 0); conf_check_fail(sess, 123, 0); srd_session_destroy(sess); srd_exit(); } END_TEST Suite *suite_session(void) { Suite *s; TCase *tc; s = suite_create("session"); tc = tcase_create("new_destroy"); tcase_add_checked_fixture(tc, setup, teardown); tcase_add_test(tc, test_session_new); tcase_add_test(tc, test_session_new_bogus); tcase_add_test(tc, test_session_new_multiple); tcase_add_test(tc, test_session_destroy); tcase_add_test(tc, test_session_destroy_bogus); suite_add_tcase(s, tc); tc = tcase_create("config"); tcase_add_checked_fixture(tc, setup, teardown); tcase_add_test(tc, test_session_metadata_set); tcase_add_test(tc, test_session_metadata_set_bogus); suite_add_tcase(s, tc); return s; }
26.669231
81
0.726997
5b1738dc90373a04632bae2b75771bc5043a994f
685
c
C
1012/1012.c
isac322/BOJ
35959dd1a63d75ebca9ed606051f7a649d5c0c7b
[ "MIT" ]
14
2017-05-02T02:00:42.000Z
2021-11-16T07:25:29.000Z
1012/1012.c
isac322/BOJ
35959dd1a63d75ebca9ed606051f7a649d5c0c7b
[ "MIT" ]
1
2017-12-25T14:18:14.000Z
2018-02-07T06:49:44.000Z
1012/1012.c
isac322/BOJ
35959dd1a63d75ebca9ed606051f7a649d5c0c7b
[ "MIT" ]
9
2016-03-03T22:06:52.000Z
2020-04-30T22:06:24.000Z
#include <stdio.h> #include <memory.h> char mat[50][50] = { 0 }; int n, m, k; void re(int i, int j) { mat[i][j] = 0; if (i && mat[i - 1][j]) re(i - 1, j); if (i != n - 1 && mat[i + 1][j]) re(i + 1, j); if (j && mat[i][j - 1]) re(i, j - 1); if (j != m - 1 && mat[i][j + 1]) re(i, j + 1); return; } int main() { int t; scanf("%d", &t); while (t--) { memset(mat, 0, sizeof(char) * 50 * 50); int i = 0, j, y, x, cnt = 0; scanf("%d %d %d", &m, &n, &k); for (; i < k; i++) { scanf("%d %d", &x, &y); mat[y][x] = 1; } for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { if (mat[i][j]) { cnt++; re(i, j); } } } printf("%d\n", cnt); } }
18.513514
47
0.385401
8bbab6a5d4876ec1834e0cc874d38905ade5cbe7
643
h
C
src/client/gui/WidgetScroll.h
bqqbarbhg/spear
727f41fa5197f9681337d1ff37ea63c44708f0d4
[ "BSD-3-Clause" ]
29
2020-07-27T09:56:02.000Z
2022-03-28T01:38:07.000Z
src/client/gui/WidgetScroll.h
bqqbarbhg/spear
727f41fa5197f9681337d1ff37ea63c44708f0d4
[ "BSD-3-Clause" ]
3
2020-05-29T11:43:20.000Z
2020-09-04T09:56:56.000Z
src/client/gui/WidgetScroll.h
bqqbarbhg/spear
727f41fa5197f9681337d1ff37ea63c44708f0d4
[ "BSD-3-Clause" ]
2
2020-05-29T11:34:46.000Z
2021-03-08T08:39:07.000Z
#pragma once #include "client/gui/Gui.h" #include "sp/Canvas.h" namespace cl { namespace gui { struct WidgetScroll : WidgetBase<'s','c','r','l'> { Direction direction = DirY; float scrollOffset = 0.0f; float smoothVelocity = 0.0f; float dragVelocity = 0.0f; float scrollSpeed = 150.0f; float overshootAmount = 20.0f; float scrollTarget = 0.0f; float prevScrollOffset = 0.0f; bool prevDragged = false; bool dragged = false; virtual void layout(GuiLayout &layout, const sf::Vec2 &min, const sf::Vec2 &max) override; virtual void paint(GuiPaint &paint) override; virtual bool onPointer(GuiPointer &pointer) override; }; } }
20.741935
91
0.715397
fef903c4ceb2489af98db7a8deccd3b68cc6c101
3,063
h
C
Engine/Source/Runtime/SlateCore/Public/Layout/Visibility.h
PopCap/GameIdea
201e1df50b2bc99afc079ce326aa0a44b178a391
[ "BSD-2-Clause" ]
null
null
null
Engine/Source/Runtime/SlateCore/Public/Layout/Visibility.h
PopCap/GameIdea
201e1df50b2bc99afc079ce326aa0a44b178a391
[ "BSD-2-Clause" ]
2
2015-06-21T17:38:11.000Z
2015-06-22T20:54:42.000Z
Engine/Source/Runtime/SlateCore/Public/Layout/Visibility.h
PopCap/GameIdea
201e1df50b2bc99afc079ce326aa0a44b178a391
[ "BSD-2-Clause" ]
null
null
null
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. #pragma once /** Is an entity visible? */ struct SLATECORE_API EVisibility { /** Default widget visibility - visible and can interactive with the cursor */ static const EVisibility Visible; /** Not visible and takes up no space in the layout; can never be clicked on because it takes up no space. */ static const EVisibility Collapsed; /** Not visible, but occupies layout space. Not interactive for obvious reasons. */ static const EVisibility Hidden; /** Visible to the user, but only as art. The cursors hit tests will never see this widget. */ static const EVisibility HitTestInvisible; /** Same as HitTestInvisible, but doesn't apply to child widgets. */ static const EVisibility SelfHitTestInvisible; /** Any visibility will do */ static const EVisibility All; public: /** * Default constructor. * * The default visibility is 'visible'. */ EVisibility( ) : Value(VIS_Visible) { } public: bool operator==( const EVisibility& Other ) const { return this->Value == Other.Value; } bool operator!=( const EVisibility& Other ) const { return this->Value != Other.Value; } public: bool AreChildrenHitTestVisible( ) const { return 0 != (Value & VISPRIVATE_ChildrenHitTestVisible); } bool IsHitTestVisible( ) const { return 0 != (Value & VISPRIVATE_SelfHitTestVisible); } bool IsVisible() const { return 0 != (Value & VIS_Visible); } FString ToString() const; private: enum Private { /** Entity is visible */ VISPRIVATE_Visible = 0x1 << 0, /** Entity is invisible and takes up no space */ VISPRIVATE_Collapsed = 0x1 << 1, /** Entity is invisible, but still takes up space (layout pretends it is visible) */ VISPRIVATE_Hidden = 0x1 << 2, /** Can we click on this widget or is it just non-interactive decoration? */ VISPRIVATE_SelfHitTestVisible = 0x1 << 3, /** Can we click on this widget's child widgets? */ VISPRIVATE_ChildrenHitTestVisible = 0x1 << 4, /** Default widget visibility - visible and can interactive with the cursor */ VIS_Visible = VISPRIVATE_Visible | VISPRIVATE_SelfHitTestVisible | VISPRIVATE_ChildrenHitTestVisible, /** Not visible and takes up no space in the layout; can never be clicked on because it takes up no space. */ VIS_Collapsed = VISPRIVATE_Collapsed, /** Not visible, but occupies layout space. Not interactive for obvious reasons. */ VIS_Hidden = VISPRIVATE_Hidden, /** Visible to the user, but only as art. The cursors hit tests will never see this widget. */ VIS_HitTestInvisible = VISPRIVATE_Visible, /** Same as HitTestInvisible, but doesn't apply to child widgets. */ VIS_SelfHitTestInvisible = VISPRIVATE_Visible | VISPRIVATE_ChildrenHitTestVisible, /** Any visibility will do */ VIS_All = VISPRIVATE_Visible | VISPRIVATE_Hidden | VISPRIVATE_Collapsed | VISPRIVATE_SelfHitTestVisible | VISPRIVATE_ChildrenHitTestVisible }; /** * Private constructor. */ EVisibility( Private InValue ) : Value(InValue) { } public: Private Value; };
27.348214
141
0.724127
3a500d6ac35380e3b9a9466dbe16b15d0ac3d40e
46,335
c
C
vendors/realtek/sdk/amebaZ2/component/common/bluetooth/realtek/sdk/example/bt_mesh/provisioner/provisioner_app.c
Ameba8195/amazon-freertos
ef61d5f521de921cc931d9262e3d5af9b75fbd2e
[ "MIT" ]
8
2019-10-24T03:22:27.000Z
2022-01-11T07:16:52.000Z
vendors/realtek/sdk/amebaZ2/component/common/bluetooth/realtek/sdk/example/bt_mesh/provisioner/provisioner_app.c
Ameba8195/amazon-freertos
ef61d5f521de921cc931d9262e3d5af9b75fbd2e
[ "MIT" ]
6
2020-01-08T06:50:30.000Z
2021-03-17T05:44:50.000Z
vendors/realtek/sdk/amebaZ2/component/common/bluetooth/realtek/sdk/example/bt_mesh/provisioner/provisioner_app.c
Ameba8195/amazon-freertos
ef61d5f521de921cc931d9262e3d5af9b75fbd2e
[ "MIT" ]
10
2019-09-20T00:10:21.000Z
2021-04-09T01:09:22.000Z
/** ********************************************************************************************************* * Copyright(c) 2015, Realtek Semiconductor Corporation. All rights reserved. ********************************************************************************************************* * @file device_app.c * @brief Smart mesh demo application * @details * @author bill * @date 2015-11-12 * @version v0.1 * ********************************************************************************************************* */ #include <string.h> #include <app_msg.h> #include <trace.h> #include <gap_scan.h> #include <gap.h> #include <gap_msg.h> #include <gap_adv.h> #include <gap_bond_le.h> #include <profile_server.h> #if defined(CONFIG_PLATFORM_8721D) #include "ameba_soc.h" #endif #include "provisioner_app.h" #include "trace_app.h" #include "gap_wrapper.h" #include "mesh_api.h" #include "mesh_data_uart.h" #include "mesh_user_cmd_parse.h" #include "mesh_cmd.h" #include "ping_app.h" #include "provisioner_cmd.h" #include "provision_provisioner.h" #include "provision_client.h" #include "proxy_client.h" #include "bt_flags.h" #include "bt_mesh_provisioner_app_flags.h" #include "platform_opts.h" #include "vendor_cmd.h" #include "vendor_cmd_bt.h" #if defined(CONFIG_BT_MESH_USER_API) && CONFIG_BT_MESH_USER_API #include "bt_mesh_user_api.h" #include "bt_mesh_provisioner_api.h" #endif #if defined(CONFIG_EXAMPLE_BT_MESH_DEMO) && CONFIG_EXAMPLE_BT_MESH_DEMO #include "bt_mesh_app_lib_intf.h" extern struct BT_MESH_LIB_PRIV bt_mesh_lib_priv; #endif bool prov_manual; uint32_t prov_start_time; prov_auth_value_type_t prov_auth_value_type; /** * @brief Application Link control block defination. */ typedef struct { T_GAP_CONN_STATE conn_state; /**< Connection state. */ T_GAP_REMOTE_ADDR_TYPE bd_type; /**< remote BD type*/ uint8_t bd_addr[GAP_BD_ADDR_LEN]; /**< remote BD */ } T_APP_LINK; T_GAP_DEV_STATE bt_mesh_provisioner_gap_dev_state = {0, 0, 0, 0, 0}; /**< GAP device state */ T_APP_LINK app_link_table[APP_MAX_LINKS]; void bt_mesh_provisioner_app_handle_gap_msg(T_IO_MSG *p_gap_msg); /** * @brief All the application messages are pre-handled in this function * @note All the IO MSGs are sent to this function, then the event handling * function shall be called according to the MSG type. * @param[in] io_msg IO message data * @return void */ void bt_mesh_provisioner_app_handle_io_msg(T_IO_MSG io_msg) { uint16_t msg_type = io_msg.type; switch (msg_type) { case IO_MSG_TYPE_BT_STATUS: bt_mesh_provisioner_app_handle_gap_msg(&io_msg); break; case IO_MSG_TYPE_UART: { /* We handle user command informations from Data UART in this branch. */ uint8_t data = io_msg.subtype; mesh_user_cmd_collect(&data, sizeof(data), provisioner_cmd_table); } break; case PING_TIMEOUT_MSG: ping_handle_timeout(); break; case PING_APP_TIMEOUT_MSG: ping_app_handle_timeout(); break; default: break; } } /** * @brief Handle msg GAP_MSG_LE_DEV_STATE_CHANGE * @note All the gap device state events are pre-handled in this function. * Then the event handling function shall be called according to the new_state * @param[in] new_state New gap device state * @param[in] cause GAP device state change cause * @return void */ void bt_mesh_provisioner_app_handle_dev_state_evt(T_GAP_DEV_STATE new_state, uint16_t cause) { APP_PRINT_INFO4("bt_mesh_provisioner_app_handle_dev_state_evt: init state %d, adv state %d, scan state %d, cause 0x%x", new_state.gap_init_state, new_state.gap_adv_state, new_state.gap_scan_state, cause); if (bt_mesh_provisioner_gap_dev_state.gap_scan_state != new_state.gap_scan_state) { if (new_state.gap_scan_state == GAP_SCAN_STATE_IDLE) { APP_PRINT_INFO0("GAP scan stop"); //data_uart_print("GAP scan stop\r\n"); } else if (new_state.gap_scan_state == GAP_SCAN_STATE_SCANNING) { APP_PRINT_INFO0("GAP scan start"); //data_uart_print("GAP scan start\r\n"); } } bt_mesh_provisioner_gap_dev_state = new_state; } /** * @brief Handle msg GAP_MSG_LE_CONN_STATE_CHANGE * @note All the gap conn state events are pre-handled in this function. * Then the event handling function shall be called according to the new_state * @param[in] conn_id Connection ID * @param[in] new_state New gap connection state * @param[in] disc_cause Use this cause when new_state is GAP_CONN_STATE_DISCONNECTED * @return void */ void bt_mesh_provisioner_app_handle_conn_state_evt(uint8_t conn_id, T_GAP_CONN_STATE new_state, uint16_t disc_cause) { if (conn_id >= APP_MAX_LINKS) { return; } APP_PRINT_INFO4("bt_mesh_provisioner_app_handle_conn_state_evt: conn_id %d, conn_state(%d -> %d), disc_cause 0x%x", conn_id, app_link_table[conn_id].conn_state, new_state, disc_cause); app_link_table[conn_id].conn_state = new_state; switch (new_state) { case GAP_CONN_STATE_DISCONNECTED: { if ((disc_cause != (HCI_ERR | HCI_ERR_REMOTE_USER_TERMINATE)) && (disc_cause != (HCI_ERR | HCI_ERR_LOCAL_HOST_TERMINATE))) { APP_PRINT_ERROR2("bt_mesh_provisioner_app_handle_conn_state_evt: connection lost, conn_id %d, cause 0x%x", conn_id, disc_cause); } data_uart_debug("Disconnect conn_id %d\r\n", conn_id); #if defined(CONFIG_BT_MESH_USER_API) && CONFIG_BT_MESH_USER_API uint8_t ret = USER_API_RESULT_ERROR; ret = bt_mesh_indication(GEN_MESH_CODE(_connect), BT_MESH_USER_CMD_FAIL, NULL); if (ret != USER_API_RESULT_OK) { if (ret != USER_API_RESULT_INCORRECT_CODE) { data_uart_debug("[BT_MESH] %s(): user cmd %d fail !\r\n", __func__, GEN_MESH_CODE(_connect)); memset(&app_link_table[conn_id], 0, sizeof(T_APP_LINK)); break; } } else { memset(&app_link_table[conn_id], 0, sizeof(T_APP_LINK)); break; } ret = bt_mesh_indication(GEN_MESH_CODE(_disconnect), BT_MESH_USER_CMD_FAIL, NULL); if (ret != USER_API_RESULT_OK) { if (ret != USER_API_RESULT_INCORRECT_CODE) { data_uart_debug("[BT_MESH] %s(): user cmd %d fail !\r\n", __func__, GEN_MESH_CODE(_disconnect)); memset(&app_link_table[conn_id], 0, sizeof(T_APP_LINK)); break; } } else { memset(&app_link_table[conn_id], 0, sizeof(T_APP_LINK)); break; } #endif memset(&app_link_table[conn_id], 0, sizeof(T_APP_LINK)); } break; case GAP_CONN_STATE_CONNECTED: { uint16_t conn_interval; uint16_t conn_latency; uint16_t conn_supervision_timeout; le_get_conn_param(GAP_PARAM_CONN_INTERVAL, &conn_interval, conn_id); le_get_conn_param(GAP_PARAM_CONN_LATENCY, &conn_latency, conn_id); le_get_conn_param(GAP_PARAM_CONN_TIMEOUT, &conn_supervision_timeout, conn_id); le_get_conn_addr(conn_id, app_link_table[conn_id].bd_addr, &app_link_table[conn_id].bd_type); APP_PRINT_INFO5("GAP_CONN_STATE_CONNECTED:remote_bd %s, remote_addr_type %d, conn_interval 0x%x, conn_latency 0x%x, conn_supervision_timeout 0x%x", TRACE_BDADDR(app_link_table[conn_id].bd_addr), app_link_table[conn_id].bd_type, conn_interval, conn_latency, conn_supervision_timeout); data_uart_debug("Connected success conn_id %d\r\n", conn_id); #if defined(CONFIG_BT_MESH_USER_API) && CONFIG_BT_MESH_USER_API if (bt_mesh_indication(GEN_MESH_CODE(_connect), BT_MESH_USER_CMD_SUCCESS, NULL) != USER_API_RESULT_OK) { data_uart_debug("[BT_MESH] %s(): user cmd %d fail !\r\n", __func__, GEN_MESH_CODE(_connect)); } #endif #if F_BT_LE_5_0_SET_PHY_SUPPORT { uint8_t tx_phy; uint8_t rx_phy; le_get_conn_param(GAP_PARAM_CONN_RX_PHY_TYPE, &rx_phy, conn_id); le_get_conn_param(GAP_PARAM_CONN_TX_PHY_TYPE, &tx_phy, conn_id); APP_PRINT_INFO2("GAP_CONN_STATE_CONNECTED: tx_phy %d, rx_phy %d", tx_phy, rx_phy); } #endif #if F_BT_LE_4_2_DATA_LEN_EXT_SUPPORT le_set_data_len(conn_id, 251, 2120); #endif } break; default: break; } } /** * @brief Handle msg GAP_MSG_LE_AUTHEN_STATE_CHANGE * @note All the gap authentication state events are pre-handled in this function. * Then the event handling function shall be called according to the new_state * @param[in] conn_id Connection ID * @param[in] new_state New authentication state * @param[in] cause Use this cause when new_state is GAP_AUTHEN_STATE_COMPLETE * @return void */ void bt_mesh_provisioner_app_handle_authen_state_evt(uint8_t conn_id, uint8_t new_state, uint16_t cause) { APP_PRINT_INFO2("bt_mesh_provisioner_app_handle_authen_state_evt:conn_id %d, cause 0x%x", conn_id, cause); switch (new_state) { case GAP_AUTHEN_STATE_STARTED: { APP_PRINT_INFO0("bt_mesh_provisioner_app_handle_authen_state_evt: GAP_AUTHEN_STATE_STARTED"); } break; case GAP_AUTHEN_STATE_COMPLETE: { if (cause == GAP_SUCCESS) { data_uart_debug("Pair success\r\n"); APP_PRINT_INFO0("bt_mesh_provisioner_app_handle_authen_state_evt: GAP_AUTHEN_STATE_COMPLETE pair success"); } else { data_uart_debug("Pair failed: cause 0x%x\r\n", cause); APP_PRINT_INFO0("bt_mesh_provisioner_app_handle_authen_state_evt: GAP_AUTHEN_STATE_COMPLETE pair failed"); } } break; default: { APP_PRINT_ERROR1("bt_mesh_provisioner_app_handle_authen_state_evt: unknown newstate %d", new_state); } break; } } /** * @brief Handle msg GAP_MSG_LE_CONN_MTU_INFO * @note This msg is used to inform APP that exchange mtu procedure is completed. * @param[in] conn_id Connection ID * @param[in] mtu_size New mtu size * @return void */ void bt_mesh_provisioner_app_handle_conn_mtu_info_evt(uint8_t conn_id, uint16_t mtu_size) { APP_PRINT_INFO2("bt_mesh_provisioner_app_handle_conn_mtu_info_evt: conn_id %d, mtu_size %d", conn_id, mtu_size); } /** * @brief Handle msg GAP_MSG_LE_CONN_PARAM_UPDATE * @note All the connection parameter update change events are pre-handled in this function. * @param[in] conn_id Connection ID * @param[in] status New update state * @param[in] cause Use this cause when status is GAP_CONN_PARAM_UPDATE_STATUS_FAIL * @return void */ void bt_mesh_provisioner_app_handle_conn_param_update_evt(uint8_t conn_id, uint8_t status, uint16_t cause) { switch (status) { case GAP_CONN_PARAM_UPDATE_STATUS_SUCCESS: { uint16_t conn_interval; uint16_t conn_slave_latency; uint16_t conn_supervision_timeout; le_get_conn_param(GAP_PARAM_CONN_INTERVAL, &conn_interval, conn_id); le_get_conn_param(GAP_PARAM_CONN_LATENCY, &conn_slave_latency, conn_id); le_get_conn_param(GAP_PARAM_CONN_TIMEOUT, &conn_supervision_timeout, conn_id); APP_PRINT_INFO4("bt_mesh_provisioner_app_handle_conn_param_update_evt update success:conn_id %d, conn_interval 0x%x, conn_slave_latency 0x%x, conn_supervision_timeout 0x%x", conn_id, conn_interval, conn_slave_latency, conn_supervision_timeout); } break; case GAP_CONN_PARAM_UPDATE_STATUS_FAIL: { APP_PRINT_ERROR2("bt_mesh_provisioner_app_handle_conn_param_update_evt update failed: conn_id %d, cause 0x%x", conn_id, cause); } break; case GAP_CONN_PARAM_UPDATE_STATUS_PENDING: { APP_PRINT_INFO1("bt_mesh_provisioner_app_handle_conn_param_update_evt update pending: conn_id %d", conn_id); } break; default: break; } } bool mesh_initial_state = FALSE; /** * @brief All the BT GAP MSG are pre-handled in this function. * @note Then the event handling function shall be called according to the * sub_type of T_IO_MSG * @param[in] p_gap_msg Pointer to GAP msg * @return void */ void bt_mesh_provisioner_app_handle_gap_msg(T_IO_MSG *p_gap_msg) { T_LE_GAP_MSG gap_msg; uint8_t conn_id; memcpy(&gap_msg, &p_gap_msg->u.param, sizeof(p_gap_msg->u.param)); APP_PRINT_TRACE1("bt_mesh_provisioner_app_handle_gap_msg: sub_type %d", p_gap_msg->subtype); mesh_inner_msg_t mesh_inner_msg; mesh_inner_msg.type = MESH_BT_STATUS_UPDATE; mesh_inner_msg.sub_type = p_gap_msg->subtype; mesh_inner_msg.parm = p_gap_msg->u.param; gap_sched_handle_bt_status_msg(&mesh_inner_msg); switch (p_gap_msg->subtype) { case GAP_MSG_LE_DEV_STATE_CHANGE: { static bool start = FALSE; if (!mesh_initial_state) { mesh_initial_state = TRUE; /** set device uuid according to bt address */ uint8_t bt_addr[6]; uint8_t dev_uuid[16] = MESH_DEVICE_UUID; gap_get_param(GAP_PARAM_BD_ADDR, bt_addr); memcpy(dev_uuid, bt_addr, sizeof(bt_addr)); device_uuid_set(dev_uuid); /** configure provisioner */ mesh_node.unicast_addr = bt_addr[0] % 99 + 1; } bt_mesh_provisioner_app_handle_dev_state_evt(gap_msg.msg_data.gap_dev_state_change.new_state, gap_msg.msg_data.gap_dev_state_change.cause); } break; case GAP_MSG_LE_CONN_STATE_CHANGE: { bt_mesh_provisioner_app_handle_conn_state_evt(gap_msg.msg_data.gap_conn_state_change.conn_id, (T_GAP_CONN_STATE)gap_msg.msg_data.gap_conn_state_change.new_state, gap_msg.msg_data.gap_conn_state_change.disc_cause); } break; case GAP_MSG_LE_CONN_MTU_INFO: { bt_mesh_provisioner_app_handle_conn_mtu_info_evt(gap_msg.msg_data.gap_conn_mtu_info.conn_id, gap_msg.msg_data.gap_conn_mtu_info.mtu_size); } break; case GAP_MSG_LE_CONN_PARAM_UPDATE: { bt_mesh_provisioner_app_handle_conn_param_update_evt(gap_msg.msg_data.gap_conn_param_update.conn_id, gap_msg.msg_data.gap_conn_param_update.status, gap_msg.msg_data.gap_conn_param_update.cause); } break; case GAP_MSG_LE_AUTHEN_STATE_CHANGE: { bt_mesh_provisioner_app_handle_authen_state_evt(gap_msg.msg_data.gap_authen_state.conn_id, gap_msg.msg_data.gap_authen_state.new_state, gap_msg.msg_data.gap_authen_state.status); } break; case GAP_MSG_LE_BOND_JUST_WORK: { conn_id = gap_msg.msg_data.gap_bond_just_work_conf.conn_id; le_bond_just_work_confirm(conn_id, GAP_CFM_CAUSE_ACCEPT); APP_PRINT_INFO0("GAP_MSG_LE_BOND_JUST_WORK"); } break; case GAP_MSG_LE_BOND_PASSKEY_DISPLAY: { uint32_t display_value = 0; conn_id = gap_msg.msg_data.gap_bond_passkey_display.conn_id; le_bond_get_display_key(conn_id, &display_value); APP_PRINT_INFO2("GAP_MSG_LE_BOND_PASSKEY_DISPLAY: conn_id %d, passkey %d", conn_id, display_value); le_bond_passkey_display_confirm(conn_id, GAP_CFM_CAUSE_ACCEPT); data_uart_debug("GAP_MSG_LE_BOND_PASSKEY_DISPLAY: conn_id %d, passkey %d\r\n", conn_id, display_value); } break; case GAP_MSG_LE_BOND_USER_CONFIRMATION: { uint32_t display_value = 0; conn_id = gap_msg.msg_data.gap_bond_user_conf.conn_id; le_bond_get_display_key(conn_id, &display_value); APP_PRINT_INFO2("GAP_MSG_LE_BOND_USER_CONFIRMATION: conn_id %d, passkey %d", conn_id, display_value); data_uart_debug("GAP_MSG_LE_BOND_USER_CONFIRMATION: conn_id %d, passkey %d\r\n", conn_id, display_value); //le_bond_user_confirm(conn_id, GAP_CFM_CAUSE_ACCEPT); } break; case GAP_MSG_LE_BOND_PASSKEY_INPUT: { //uint32_t passkey = 888888; conn_id = gap_msg.msg_data.gap_bond_passkey_input.conn_id; APP_PRINT_INFO2("GAP_MSG_LE_BOND_PASSKEY_INPUT: conn_id %d, key_press %d", conn_id, gap_msg.msg_data.gap_bond_passkey_input.key_press); data_uart_debug("GAP_MSG_LE_BOND_PASSKEY_INPUT: conn_id %d\r\n", conn_id); //le_bond_passkey_input_confirm(conn_id, passkey, GAP_CFM_CAUSE_ACCEPT); } break; #if F_BT_LE_SMP_OOB_SUPPORT case GAP_MSG_LE_BOND_OOB_INPUT: { uint8_t oob_data[GAP_OOB_LEN] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; conn_id = gap_msg.msg_data.gap_bond_oob_input.conn_id; APP_PRINT_INFO1("GAP_MSG_LE_BOND_OOB_INPUT: conn_id %d", conn_id); le_bond_set_param(GAP_PARAM_BOND_OOB_DATA, GAP_OOB_LEN, oob_data); le_bond_oob_input_confirm(conn_id, GAP_CFM_CAUSE_ACCEPT); } break; #endif default: APP_PRINT_ERROR1("bt_mesh_provisioner_app_handle_gap_msg: unknown sub_type %d", p_gap_msg->subtype); break; } } /** * @brief Callback for gap le to notify app * @param[in] cb_type callback msy type @ref GAP_LE_MSG_Types. * @param[in] p_cb_data point to callback data @ref T_LE_CB_DATA. * @retval result @ref T_APP_RESULT */ T_APP_RESULT bt_mesh_provisioner_app_gap_callback(uint8_t cb_type, void *p_cb_data) { T_APP_RESULT result = APP_RESULT_SUCCESS; T_LE_CB_DATA *p_data = (T_LE_CB_DATA *)p_cb_data; switch (cb_type) { /* common msg*/ case GAP_MSG_LE_READ_RSSI: APP_PRINT_INFO3("GAP_MSG_LE_READ_RSSI:conn_id 0x%x cause 0x%x rssi %d", p_data->p_le_read_rssi_rsp->conn_id, p_data->p_le_read_rssi_rsp->cause, p_data->p_le_read_rssi_rsp->rssi); break; #if F_BT_LE_4_2_DATA_LEN_EXT_SUPPORT case GAP_MSG_LE_DATA_LEN_CHANGE_INFO: APP_PRINT_INFO3("GAP_MSG_LE_DATA_LEN_CHANGE_INFO: conn_id %d, tx octets 0x%x, max_tx_time 0x%x", p_data->p_le_data_len_change_info->conn_id, p_data->p_le_data_len_change_info->max_tx_octets, p_data->p_le_data_len_change_info->max_tx_time); break; #endif case GAP_MSG_LE_BOND_MODIFY_INFO: APP_PRINT_INFO1("GAP_MSG_LE_BOND_MODIFY_INFO: type 0x%x", p_data->p_le_bond_modify_info->type); break; case GAP_MSG_LE_MODIFY_WHITE_LIST: APP_PRINT_INFO2("GAP_MSG_LE_MODIFY_WHITE_LIST: operation %d, cause 0x%x", p_data->p_le_modify_white_list_rsp->operation, p_data->p_le_modify_white_list_rsp->cause); break; /* central reference msg*/ case GAP_MSG_LE_SCAN_INFO: APP_PRINT_INFO5("GAP_MSG_LE_SCAN_INFO:adv_type 0x%x, bd_addr %s, remote_addr_type %d, rssi %d, data_len %d", p_data->p_le_scan_info->adv_type, TRACE_BDADDR(p_data->p_le_scan_info->bd_addr), p_data->p_le_scan_info->remote_addr_type, p_data->p_le_scan_info->rssi, p_data->p_le_scan_info->data_len); gap_sched_handle_adv_report(p_data->p_le_scan_info); break; #if F_BT_LE_GAP_CENTRAL_SUPPORT case GAP_MSG_LE_CONN_UPDATE_IND: APP_PRINT_INFO5("GAP_MSG_LE_CONN_UPDATE_IND: conn_id %d, conn_interval_max 0x%x, conn_interval_min 0x%x, conn_latency 0x%x,supervision_timeout 0x%x", p_data->p_le_conn_update_ind->conn_id, p_data->p_le_conn_update_ind->conn_interval_max, p_data->p_le_conn_update_ind->conn_interval_min, p_data->p_le_conn_update_ind->conn_latency, p_data->p_le_conn_update_ind->supervision_timeout); /* if reject the proposed connection parameter from peer device, use APP_RESULT_REJECT. */ result = APP_RESULT_ACCEPT; break; case GAP_MSG_LE_SET_HOST_CHANN_CLASSIF: APP_PRINT_INFO1("GAP_MSG_LE_SET_HOST_CHANN_CLASSIF: cause 0x%x", p_data->p_le_set_host_chann_classif_rsp->cause); break; #endif /* peripheral reference msg*/ case GAP_MSG_LE_ADV_UPDATE_PARAM: APP_PRINT_INFO1("GAP_MSG_LE_ADV_UPDATE_PARAM: cause 0x%x", p_data->p_le_adv_update_param_rsp->cause); gap_sched_adv_params_set_done(); break; /* case GAP_MSG_LE_VENDOR_ONE_SHOT_ADV: APP_PRINT_INFO1("GAP_MSG_LE_VENDOR_ONE_SHOT_ADV: cause 0x%x", p_data->le_cause.cause); gap_sched_adv_done(GAP_SCHED_ADV_END_TYPE_SUCCESS); break; case GAP_MSG_LE_DISABLE_SLAVE_LATENCY: APP_PRINT_INFO1("GAP_MSG_LE_DISABLE_SLAVE_LATENCY: cause 0x%x", p_data->p_le_disable_slave_latency_rsp->cause); break; case GAP_MSG_LE_UPDATE_PASSED_CHANN_MAP: APP_PRINT_INFO1("GAP_MSG_LE_UPDATE_PASSED_CHANN_MAP:cause 0x%x", p_data->p_le_update_passed_chann_map_rsp->cause); break; */ #if F_BT_LE_5_0_SET_PHY_SUPPORT case GAP_MSG_LE_PHY_UPDATE_INFO: APP_PRINT_INFO4("GAP_MSG_LE_PHY_UPDATE_INFO:conn_id %d, cause 0x%x, rx_phy %d, tx_phy %d", p_data->p_le_phy_update_info->conn_id, p_data->p_le_phy_update_info->cause, p_data->p_le_phy_update_info->rx_phy, p_data->p_le_phy_update_info->tx_phy); break; case GAP_MSG_LE_REMOTE_FEATS_INFO: { uint8_t remote_feats[8]; APP_PRINT_INFO3("GAP_MSG_LE_REMOTE_FEATS_INFO: conn id %d, cause 0x%x, remote_feats %b", p_data->p_le_remote_feats_info->conn_id, p_data->p_le_remote_feats_info->cause, TRACE_BINARY(8, p_data->p_le_remote_feats_info->remote_feats)); if (p_data->p_le_remote_feats_info->cause == GAP_SUCCESS) { memcpy(remote_feats, p_data->p_le_remote_feats_info->remote_feats, 8); if (remote_feats[LE_SUPPORT_FEATURES_MASK_ARRAY_INDEX1] & LE_SUPPORT_FEATURES_LE_2M_MASK_BIT) { APP_PRINT_INFO0("GAP_MSG_LE_REMOTE_FEATS_INFO: support 2M"); } if (remote_feats[LE_SUPPORT_FEATURES_MASK_ARRAY_INDEX1] & LE_SUPPORT_FEATURES_LE_CODED_PHY_MASK_BIT) { APP_PRINT_INFO0("GAP_MSG_LE_REMOTE_FEATS_INFO: support CODED"); } } } break; #endif default: APP_PRINT_ERROR1("bt_mesh_provisioner_app_gap_callback: unhandled cb_type 0x%x", cb_type); break; } return result; } /** * @brief Callback will be called when data sent from profile client layer. * @param client_id the ID distinguish which module sent the data. * @param conn_id connection ID. * @param p_data pointer to data. * @retval result @ref T_APP_RESULT */ T_APP_RESULT bt_mesh_provisioner_app_client_callback(T_CLIENT_ID client_id, uint8_t conn_id, void *p_data) { T_APP_RESULT result = APP_RESULT_SUCCESS; APP_PRINT_INFO2("bt_mesh_provisioner_app_client_callback: client_id %d, conn_id %d", client_id, conn_id); if (client_id == CLIENT_PROFILE_GENERAL_ID) { T_CLIENT_APP_CB_DATA *p_client_app_cb_data = (T_CLIENT_APP_CB_DATA *)p_data; switch (p_client_app_cb_data->cb_type) { case CLIENT_APP_CB_TYPE_DISC_STATE: if (p_client_app_cb_data->cb_content.disc_state_data.disc_state == DISC_STATE_SRV_DONE) { APP_PRINT_INFO0("Discovery All Service Procedure Done."); } else { APP_PRINT_INFO0("Discovery state send to application directly."); } break; case CLIENT_APP_CB_TYPE_DISC_RESULT: if (p_client_app_cb_data->cb_content.disc_result_data.result_type == DISC_RESULT_ALL_SRV_UUID16) { APP_PRINT_INFO3("Discovery All Primary Service: UUID16 0x%x, start handle 0x%x, end handle 0x%x.", p_client_app_cb_data->cb_content.disc_result_data.result_data.p_srv_uuid16_disc_data->uuid16, p_client_app_cb_data->cb_content.disc_result_data.result_data.p_srv_uuid16_disc_data->att_handle, p_client_app_cb_data->cb_content.disc_result_data.result_data.p_srv_uuid16_disc_data->end_group_handle); } else { APP_PRINT_INFO0("Discovery result send to application directly."); } break; default: break; } } else if (client_id == prov_client_id) { prov_client_cb_data_t *pcb_data = (prov_client_cb_data_t *)p_data; switch (pcb_data->cb_type) { case PROV_CLIENT_CB_TYPE_DISC_STATE: switch (pcb_data->cb_content.disc_state) { case PROV_DISC_DONE: /* Discovery Simple BLE service procedure successfully done. */ data_uart_debug("Prov service discovery end!\r\n"); #if defined(CONFIG_BT_MESH_USER_API) && CONFIG_BT_MESH_USER_API if (bt_mesh_indication(GEN_MESH_CODE(_prov_discover), BT_MESH_USER_CMD_SUCCESS, NULL) != USER_API_RESULT_OK) { data_uart_debug("[BT_MESH] %s(): user cmd %d fail !\r\n", __func__, GEN_MESH_CODE(_prov_discover)); } #endif break; case PROV_DISC_FAIL: /* Discovery Request failed. */ data_uart_debug("Prov service discovery fail!\r\n"); #if defined(CONFIG_BT_MESH_USER_API) && CONFIG_BT_MESH_USER_API if (bt_mesh_indication(GEN_MESH_CODE(_prov_discover), BT_MESH_USER_CMD_FAIL, NULL) != USER_API_RESULT_OK) { data_uart_debug("[BT_MESH] %s(): user cmd %d fail !\r\n", __func__, GEN_MESH_CODE(_prov_discover)); } #endif break; case PROV_DISC_NOT_FOUND: /* Discovery Request failed. */ data_uart_debug("Prov service not found!\r\n"); #if defined(CONFIG_BT_MESH_USER_API) && CONFIG_BT_MESH_USER_API if (bt_mesh_indication(GEN_MESH_CODE(_prov_discover), BT_MESH_USER_CMD_FAIL, NULL) != USER_API_RESULT_OK) { data_uart_debug("[BT_MESH] %s(): user cmd %d fail !\r\n", __func__, GEN_MESH_CODE(_prov_discover)); } #endif break; default: break; } break; case PROV_CLIENT_CB_TYPE_READ_RESULT: switch (pcb_data->cb_content.read_result.type) { case PROV_READ_DATA_OUT_CCCD: if (pcb_data->cb_content.read_result.cause == 0) { data_uart_debug("Prov data out cccd = %d.\r\n", pcb_data->cb_content.read_result.data.prov_data_out_cccd); } break; default: break; } break; case PROV_CLIENT_CB_TYPE_WRITE_RESULT: break; default: break; } } else if (client_id == proxy_client_id) { proxy_client_cb_data_t *pcb_data = (proxy_client_cb_data_t *)p_data; switch (pcb_data->cb_type) { case PROXY_CLIENT_CB_TYPE_DISC_STATE: switch (pcb_data->cb_content.disc_state) { case PROXY_DISC_DONE: /* Discovery Simple BLE service procedure successfully done. */ data_uart_debug("Proxy service discovery end!\r\n"); #if defined(CONFIG_BT_MESH_USER_API) && CONFIG_BT_MESH_USER_API if (bt_mesh_indication(GEN_MESH_CODE(_proxy_discover), BT_MESH_USER_CMD_SUCCESS, NULL) != USER_API_RESULT_OK) { data_uart_debug("[BT_MESH] %s(): user cmd %d fail !\r\n", __func__, GEN_MESH_CODE(_proxy_discover)); } #endif break; case PROXY_DISC_FAIL: /* Discovery Request failed. */ data_uart_debug("Proxy service discovery fail!\r\n"); #if defined(CONFIG_BT_MESH_USER_API) && CONFIG_BT_MESH_USER_API if (bt_mesh_indication(GEN_MESH_CODE(_proxy_discover), BT_MESH_USER_CMD_FAIL, NULL) != USER_API_RESULT_OK) { data_uart_debug("[BT_MESH] %s(): user cmd %d fail !\r\n", __func__, GEN_MESH_CODE(_proxy_discover)); } #endif break; case PROXY_DISC_NOT_FOUND: /* Discovery Request failed. */ data_uart_debug("Proxy service not found!\r\n"); #if defined(CONFIG_BT_MESH_USER_API) && CONFIG_BT_MESH_USER_API if (bt_mesh_indication(GEN_MESH_CODE(_proxy_discover), BT_MESH_USER_CMD_FAIL, NULL) != USER_API_RESULT_OK) { data_uart_debug("[BT_MESH] %s(): user cmd %d fail !\r\n", __func__, GEN_MESH_CODE(_proxy_discover)); } #endif break; default: break; } break; case PROXY_CLIENT_CB_TYPE_READ_RESULT: switch (pcb_data->cb_content.read_result.type) { case PROXY_READ_DATA_OUT_CCCD: if (pcb_data->cb_content.read_result.cause == 0) { data_uart_debug("Proxy data out cccd = %d.\r\n", pcb_data->cb_content.read_result.data.proxy_data_out_cccd); } break; default: break; } break; case PROXY_CLIENT_CB_TYPE_WRITE_RESULT: break; default: break; } } return result; } /** * @brief All the BT Profile service callback events are handled in this function * @note Then the event handling function shall be called according to the * service_id * @param service_id Profile service ID * @param p_data Pointer to callback data * @return T_APP_RESULT, which indicates the function call is successful or not * @retval APP_RESULT_SUCCESS Function run successfully * @retval others Function run failed, and return number indicates the reason */ T_APP_RESULT bt_mesh_provisioner_app_profile_callback(T_SERVER_ID service_id, void *p_data) { T_APP_RESULT app_result = APP_RESULT_SUCCESS; if (service_id == SERVICE_PROFILE_GENERAL_ID) { T_SERVER_APP_CB_DATA *p_param = (T_SERVER_APP_CB_DATA *)p_data; switch (p_param->eventId) { case PROFILE_EVT_SRV_REG_COMPLETE:// srv register result event. APP_PRINT_INFO1("PROFILE_EVT_SRV_REG_COMPLETE: result %d", p_param->event_data.service_reg_result); break; case PROFILE_EVT_SEND_DATA_COMPLETE: APP_PRINT_INFO5("PROFILE_EVT_SEND_DATA_COMPLETE: conn_id %d, cause 0x%x, service_id %d, attrib_idx 0x%x, credits %d", p_param->event_data.send_data_result.conn_id, p_param->event_data.send_data_result.cause, p_param->event_data.send_data_result.service_id, p_param->event_data.send_data_result.attrib_idx, p_param->event_data.send_data_result.credits); if (p_param->event_data.send_data_result.cause == GAP_SUCCESS) { APP_PRINT_INFO0("PROFILE_EVT_SEND_DATA_COMPLETE success"); } else { APP_PRINT_ERROR0("PROFILE_EVT_SEND_DATA_COMPLETE failed"); } break; default: break; } } return app_result; } /****************************************************************** * @fn device_info_cb * @brief device_info_cb callbacks are handled in this function. * * @param cb_data - @ref prov_cb_data_t * @return void */ void device_info_cb(uint8_t bt_addr[6], uint8_t bt_addr_type, int8_t rssi, device_info_t *pinfo) { if (!dev_info_show_flag) { return; } data_uart_debug("bt addr=0x%02x%02x%02x%02x%02x%02x type=%d rssi=%d ", bt_addr[5], bt_addr[4], bt_addr[3], bt_addr[2], bt_addr[1], bt_addr[0], bt_addr_type, rssi); switch (pinfo->type) { case DEVICE_INFO_UDB: data_uart_debug("udb="); data_uart_dump(pinfo->pbeacon_udb->dev_uuid, 16); break; case DEVICE_INFO_PROV_ADV: data_uart_debug("prov="); data_uart_dump(pinfo->pservice_data->provision.dev_uuid, 16); break; case DEVICE_INFO_PROXY_ADV: data_uart_debug("proxy="); data_uart_dump((uint8_t *)&pinfo->pservice_data->proxy, pinfo->len); break; default: break; } } /****************************************************************** * @fn prov_cb * @brief Provisioning callbacks are handled in this function. * * @param cb_data - @ref prov_cb_data_t * @return the operation result */ bool prov_cb(prov_cb_type_t cb_type, prov_cb_data_t cb_data) { APP_PRINT_INFO1("prov_cb: type = %d", cb_type); switch (cb_type) { case PROV_CB_TYPE_PB_ADV_LINK_STATE: switch (cb_data.pb_generic_cb_type) { case PB_GENERIC_CB_LINK_OPENED: data_uart_debug("PB-ADV Link Opened!\r\n>"); #if defined(CONFIG_EXAMPLE_BT_MESH_DEMO) && CONFIG_EXAMPLE_BT_MESH_DEMO if (bt_mesh_lib_priv.connect_device_sema) { bt_mesh_lib_priv.connect_device_flag = 1; rtw_up_sema(&bt_mesh_lib_priv.connect_device_sema); } #endif #if defined(CONFIG_BT_MESH_USER_API) && CONFIG_BT_MESH_USER_API if (bt_mesh_indication(GEN_MESH_CODE(_pb_adv_con), BT_MESH_USER_CMD_SUCCESS, NULL) != USER_API_RESULT_OK) { data_uart_debug("[BT_MESH] %s(): user cmd %d fail !\r\n", __func__, GEN_MESH_CODE(_pb_adv_con)); } #endif break; case PB_GENERIC_CB_LINK_OPEN_FAILED: data_uart_debug("PB-ADV Link Open Failed!\r\n>"); #if defined(CONFIG_EXAMPLE_BT_MESH_DEMO) && CONFIG_EXAMPLE_BT_MESH_DEMO if (bt_mesh_lib_priv.connect_device_sema) { bt_mesh_lib_priv.connect_device_flag = 0; rtw_up_sema(&bt_mesh_lib_priv.connect_device_sema); } #endif #if defined(CONFIG_BT_MESH_USER_API) && CONFIG_BT_MESH_USER_API if (bt_mesh_indication(GEN_MESH_CODE(_pb_adv_con), BT_MESH_USER_CMD_FAIL, NULL) != USER_API_RESULT_OK) { data_uart_debug("[BT_MESH] %s(): user cmd %d fail !\r\n", __func__, GEN_MESH_CODE(_pb_adv_con)); } #endif break; case PB_GENERIC_CB_LINK_CLOSED: data_uart_debug("PB-ADV Link Closed!\r\n>"); break; default: break; } break; case PROV_CB_TYPE_PATH_CHOOSE: { if (prov_manual) { /* use cmd "authpath" to select oob/no oob public key and no oob/static oob/input oob/output oob auth data according to the device capabilities */ prov_capabilities_p pprov_capabilities = cb_data.pprov_capabilities; data_uart_debug("prov capabilities: en-%d al-%d pk-%d so-%d os-%d oa-%d is-%d ia-%d\r\n", pprov_capabilities->element_num, pprov_capabilities->algorithm, pprov_capabilities->public_key, pprov_capabilities->static_oob, pprov_capabilities->output_oob_size, pprov_capabilities->output_oob_action, pprov_capabilities->input_oob_size, pprov_capabilities->input_oob_action); } else { /* select no oob public key and no oob auth data as default provision method */ prov_start_t prov_start; memset(&prov_start, 0, sizeof(prov_start_t)); prov_path_choose(&prov_start); } } break; case PROV_CB_TYPE_PUBLIC_KEY: { APP_PRINT_INFO0("prov_cb: get the public key from the device"); uint8_t public_key[64] = {0xf4, 0x65, 0xe4, 0x3f, 0xf2, 0x3d, 0x3f, 0x1b, 0x9d, 0xc7, 0xdf, 0xc0, 0x4d, 0xa8, 0x75, 0x81, 0x84, 0xdb, 0xc9, 0x66, 0x20, 0x47, 0x96, 0xec, 0xcf, 0x0d, 0x6c, 0xf5, 0xe1, 0x65, 0x00, 0xcc, 0x02, 0x01, 0xd0, 0x48, 0xbc, 0xbb, 0xd8, 0x99, 0xee, 0xef, 0xc4, 0x24, 0x16, 0x4e, 0x33, 0xc2, 0x01, 0xc2, 0xb0, 0x10, 0xca, 0x6b, 0x4d, 0x43, 0xa8, 0xa1, 0x55, 0xca, 0xd8, 0xec, 0xb2, 0x79}; prov_device_public_key_set(public_key); } break; case PROV_CB_TYPE_AUTH_DATA: { prov_start_p pprov_start = cb_data.pprov_start; prov_auth_value_type = prov_auth_value_type_get(pprov_start); /* use cmd to set auth data */ data_uart_debug("auth method=%d[nsoi] action=%d size=%d type=%d[nbNa]\r\n>", pprov_start->auth_method, pprov_start->auth_action, pprov_start->auth_size, prov_auth_value_type); //uint8_t auth_data[16] = {1}; switch (pprov_start->auth_method) { case PROV_AUTH_METHOD_STATIC_OOB: //prov_auth_value_set(auth_data, sizeof(auth_data)); APP_PRINT_INFO0("prov_cb: Please share the oob data with the device"); break; case PROV_AUTH_METHOD_OUTPUT_OOB: //prov_auth_value_set(auth_data, pprov_start->auth_size.output_oob_size); APP_PRINT_INFO2("prov_cb: Please input the oob data provided by the device, output size = %d, action = %d", pprov_start->auth_size.output_oob_size, pprov_start->auth_action.output_oob_action); break; case PROV_AUTH_METHOD_INPUT_OOB: //prov_auth_value_set(auth_data, pprov_start->auth_size.input_oob_size); APP_PRINT_INFO2("prov_cb: Please output the oob data to the device, input size = %d, action = %d", pprov_start->auth_size.input_oob_size, pprov_start->auth_action.input_oob_action); break; default: break; } } break; case PROV_CB_TYPE_COMPLETE: { prov_data_p pprov_data = cb_data.pprov_data; data_uart_debug("Has provisioned device with addr 0x%04x in %dms!\r\n", pprov_data->unicast_address, plt_time_read_ms() - prov_start_time); /* the spec requires to disconnect, but you can remove it as you like! :) */ prov_disconnect(PB_ADV_LINK_CLOSE_SUCCESS); #if defined(CONFIG_EXAMPLE_BT_MESH_DEMO) && CONFIG_EXAMPLE_BT_MESH_DEMO if (bt_mesh_lib_priv.connect_device_sema) { bt_mesh_lib_priv.connect_device_mesh_addr = pprov_data->unicast_address; rtw_up_sema(&bt_mesh_lib_priv.connect_device_sema); } #endif #if defined(CONFIG_BT_MESH_USER_API) && CONFIG_BT_MESH_USER_API printf("\r\n %s() pprov_data->unicast_address = %x",__func__,pprov_data->unicast_address); if (bt_mesh_indication(GEN_MESH_CODE(_prov), BT_MESH_USER_CMD_SUCCESS, (void *)&pprov_data->unicast_address) != USER_API_RESULT_OK) { data_uart_debug("[BT_MESH] %s(): user cmd %d fail !\r\n", __func__, GEN_MESH_CODE(_prov)); } #endif } break; case PROV_CB_TYPE_FAIL: data_uart_debug("provision fail, type=%d!\r\n", cb_data.prov_fail.fail_type); #if defined(CONFIG_EXAMPLE_BT_MESH_DEMO) && CONFIG_EXAMPLE_BT_MESH_DEMO if (bt_mesh_lib_priv.connect_device_sema) { bt_mesh_lib_priv.connect_device_mesh_addr = 0; rtw_up_sema(&bt_mesh_lib_priv.connect_device_sema); } #endif #if defined(CONFIG_BT_MESH_USER_API) && CONFIG_BT_MESH_USER_API if (bt_mesh_indication(GEN_MESH_CODE(_prov), BT_MESH_USER_CMD_FAIL, NULL) != USER_API_RESULT_OK) { data_uart_debug("[BT_MESH] %s(): user cmd %d fail !\r\n", __func__, GEN_MESH_CODE(_prov)); } #endif break; case PROV_CB_TYPE_PROV: /* stack ready */ data_uart_debug("ms addr: 0x%04x\r\n>", mesh_node.unicast_addr); break; default: break; } return true; } /****************************************************************** * @fn fn_cb * @brief fn callbacks are handled in this function. * * @param frnd_index * @param type * @param fn_addr * @return void */ void fn_cb(uint8_t frnd_index, fn_cb_type_t type, uint16_t lpn_addr) { char *string[] = {"establishing with lpn 0x%04x\r\n", "no poll from 0x%04x\r\n", "established with lpn 0x%04x\r\n", "lpn 0x%04x lost\r\n"}; data_uart_debug(string[type], lpn_addr); if (type == FN_CB_TYPE_ESTABLISH_SUCCESS || type == FN_CB_TYPE_FRND_LOST) { user_cmd_time(NULL); } } /****************************************************************** * @fn hb_cb * @brief heartbeat callbacks are handled in this function. * * @param type * @param pdata * @return void */ void hb_cb(hb_data_type_t type, void *pargs) { switch (type) { case HB_DATA_PUB_TIMER_STATE: { hb_data_timer_state_t *pdata = pargs; if (HB_TIMER_STATE_START == pdata->state) { data_uart_debug("heartbeat publish timer start, period = %d\r\n", pdata->period); } else { data_uart_debug("heartbeat publish timer stop\r\n"); } } break; case HB_DATA_SUB_TIMER_STATE: { hb_data_timer_state_t *pdata = pargs; if (HB_TIMER_STATE_START == pdata->state) { data_uart_debug("heartbeat subscription timer start, period = %d\r\n", pdata->period); } else { data_uart_debug("heartbeat subscription timer stop\r\n"); } } break; case HB_DATA_PUB_COUNT_UPDATE: { hb_data_pub_count_update_t *pdata = pargs; data_uart_debug("heartbeat publish count update: %d\r\n", pdata->count); } break; case HB_DATA_SUB_PERIOD_UPDATE: { hb_data_sub_period_update_t *pdata = pargs; data_uart_debug("heartbeat subscription period update: %d\r\n", pdata->period); } break; case HB_DATA_SUB_RECEIVE: { hb_data_sub_receive_t *pdata = pargs; data_uart_debug("receive heartbeat: src = %d, init_ttl = %d, features = %d-%d-%d-%d, ttl = %d\r\n", pdata->src, pdata->init_ttl, pdata->features.relay, pdata->features.proxy, pdata->features.frnd, pdata->features.lpn, pdata->ttl); } break; default: break; } } void app_vendor_callback(uint8_t cb_type, void *p_cb_data) { T_GAP_VENDOR_CB_DATA cb_data; memcpy(&cb_data, p_cb_data, sizeof(T_GAP_VENDOR_CB_DATA)); APP_PRINT_INFO1("app_vendor_callback: command 0x%x", cb_data.p_gap_vendor_cmd_rsp->command); switch (cb_type) { case GAP_MSG_VENDOR_CMD_RSP: switch(cb_data.p_gap_vendor_cmd_rsp->command) { #if BT_VENDOR_CMD_ONE_SHOT_SUPPORT case HCI_LE_VENDOR_EXTENSION_FEATURE2: //if(cb_data.p_gap_vendor_cmd_rsp->param[0] == HCI_EXT_SUB_ONE_SHOT_ADV) { APP_PRINT_INFO1("One shot adv resp: cause 0x%x", cb_data.p_gap_vendor_cmd_rsp->cause); gap_sched_adv_done(GAP_SCHED_ADV_END_TYPE_SUCCESS); } break; #endif case HCI_LE_VENDOR_EXTENSION_FEATURE: switch(cb_data.p_gap_vendor_cmd_rsp->param[0]) { #if BT_VENDOR_CMD_ADV_TX_POWER_SUPPORT case HCI_EXT_SUB_SET_ADV_TX_POWER: APP_PRINT_INFO1("HCI_EXT_SUB_SET_ADV_TX_POWER: cause 0x%x", cb_data.p_gap_vendor_cmd_rsp->cause); break; #endif #if BT_VENDOR_CMD_CONN_TX_POWER_SUPPORT case HCI_EXT_SUB_SET_LINK_TX_POW: APP_PRINT_INFO1("HCI_EXT_SUB_SET_LINK_TX_POW: cause 0x%x", cb_data.p_gap_vendor_cmd_rsp->cause); break; #endif } break; default: break; } break; default: break; } return; }
40.787852
422
0.619143
6b4d98b97b18108f2e2be32c7a8d58281b2474e7
3,808
h
C
Twitter-Dumped/7.60.6/T1StatusPhotoVideoDetailsView.h
ichitaso/TwitterListEnabler
d4d9ba973e59ff7f0d97ae74fc473bdd0aea54df
[ "MIT" ]
1
2019-10-15T09:26:49.000Z
2019-10-15T09:26:49.000Z
Twitter-Dumped/7.52/T1StatusPhotoVideoDetailsView.h
ichitaso/TwitterListEnabler
d4d9ba973e59ff7f0d97ae74fc473bdd0aea54df
[ "MIT" ]
null
null
null
Twitter-Dumped/7.52/T1StatusPhotoVideoDetailsView.h
ichitaso/TwitterListEnabler
d4d9ba973e59ff7f0d97ae74fc473bdd0aea54df
[ "MIT" ]
1
2019-11-17T06:06:49.000Z
2019-11-17T06:06:49.000Z
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 17 2017 16:24:48). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard. // #import <UIKit/UIView.h> @class NSArray, NSLayoutConstraint, TFNTappableHighlightView, TFNTwitterUser, TFSTwitterEntityMedia, UIImageView, UILabel, UIStackView; @protocol T1StatusPhotoVideoDetailsViewDelegate; @interface T1StatusPhotoVideoDetailsView : UIView { id <T1StatusPhotoVideoDetailsViewDelegate> _delegate; TFSTwitterEntityMedia *_mediaEntity; TFNTwitterUser *_user; unsigned long long _displayStyle; UIStackView *_stackView; TFNTappableHighlightView *_highlightView; UILabel *_viewCountLabel; UILabel *_viewCountSeparatorLabel; UILabel *_fromLabel; UILabel *_fullNameLabel; UILabel *_usernameLabel; UIImageView *_verifiedBadgeImageView; UIView *_spacerView; NSArray *_highlightViewConstraints; NSLayoutConstraint *_stackViewTopConstraint; NSLayoutConstraint *_stackViewBottomConstraint; NSLayoutConstraint *_stackViewWidthConstraint; } + (id)prefixFontForDisplayStyle:(unsigned long long)arg1; + (struct CGSize)preferredSizeForMaxWidth:(unsigned long long)arg1 displayStyle:(unsigned long long)arg2; + (struct CGSize)preferredSizeForMaxWidth:(unsigned long long)arg1; @property(readonly, nonatomic) NSLayoutConstraint *stackViewWidthConstraint; // @synthesize stackViewWidthConstraint=_stackViewWidthConstraint; @property(readonly, nonatomic) NSLayoutConstraint *stackViewBottomConstraint; // @synthesize stackViewBottomConstraint=_stackViewBottomConstraint; @property(readonly, nonatomic) NSLayoutConstraint *stackViewTopConstraint; // @synthesize stackViewTopConstraint=_stackViewTopConstraint; @property(retain, nonatomic) NSArray *highlightViewConstraints; // @synthesize highlightViewConstraints=_highlightViewConstraints; @property(retain, nonatomic) UIView *spacerView; // @synthesize spacerView=_spacerView; @property(retain, nonatomic) UIImageView *verifiedBadgeImageView; // @synthesize verifiedBadgeImageView=_verifiedBadgeImageView; @property(retain, nonatomic) UILabel *usernameLabel; // @synthesize usernameLabel=_usernameLabel; @property(retain, nonatomic) UILabel *fullNameLabel; // @synthesize fullNameLabel=_fullNameLabel; @property(retain, nonatomic) UILabel *fromLabel; // @synthesize fromLabel=_fromLabel; @property(retain, nonatomic) UILabel *viewCountSeparatorLabel; // @synthesize viewCountSeparatorLabel=_viewCountSeparatorLabel; @property(retain, nonatomic) UILabel *viewCountLabel; // @synthesize viewCountLabel=_viewCountLabel; @property(retain, nonatomic) TFNTappableHighlightView *highlightView; // @synthesize highlightView=_highlightView; @property(retain, nonatomic) UIStackView *stackView; // @synthesize stackView=_stackView; @property(nonatomic) unsigned long long displayStyle; // @synthesize displayStyle=_displayStyle; @property(retain, nonatomic) TFNTwitterUser *user; // @synthesize user=_user; @property(retain, nonatomic) TFSTwitterEntityMedia *mediaEntity; // @synthesize mediaEntity=_mediaEntity; @property(nonatomic) __weak id <T1StatusPhotoVideoDetailsViewDelegate> delegate; // @synthesize delegate=_delegate; - (void).cxx_destruct; - (void)_t1_updateDisplayStyle; - (void)_t1_didTapAttribution; - (void)_t1_setPrefixString:(id)arg1 displayName:(id)arg2 username:(id)arg3 isVerified:(_Bool)arg4; - (id)_t1_stringForViewCount:(unsigned long long)arg1; - (void)reset; - (void)configureWithViewCount:(unsigned long long)arg1; - (void)configureWithAdString:(id)arg1; - (void)configureWithUser:(id)arg1 prefixString:(id)arg2; - (void)configureWithMediaEntity:(id)arg1 displayViewCount:(_Bool)arg2; - (id)initWithFrame:(struct CGRect)arg1; - (id)initWithDisplayStyle:(unsigned long long)arg1; @end
56
146
0.810662
5c3fc99e44431dd105bb903742609f49880abb7a
650
h
C
src/ofPBO.h
ciisoz/VJ_Yourself
7ff3c746778984766c4bdead227feb3d5508bc95
[ "MIT" ]
null
null
null
src/ofPBO.h
ciisoz/VJ_Yourself
7ff3c746778984766c4bdead227feb3d5508bc95
[ "MIT" ]
null
null
null
src/ofPBO.h
ciisoz/VJ_Yourself
7ff3c746778984766c4bdead227feb3d5508bc95
[ "MIT" ]
1
2021-08-05T10:34:52.000Z
2021-08-05T10:34:52.000Z
/* * ofPBO.h * * Created on: 08/04/2012 * Author: arturo */ #pragma once #include "ofConstants.h" #include "ofTexture.h" #include "ofThread.h" #include "Poco/Condition.h" class ofPBO: public ofThread { public: ofPBO(); virtual ~ofPBO(); void allocate(ofTexture & tex, int numPBOs); void loadData(const ofPixels & pixels, bool threaded=true); void updateTexture(); void threadedFunction(); private: ofTexture texture; vector<GLuint> pboIds; size_t indexUploading, indexToUpdate; unsigned int dataSize; Poco::Condition condition; GLubyte* gpu_ptr; const unsigned char* cpu_ptr; bool pboUpdated; bool lastDataUploaded; };
18.055556
60
0.723077
8a94af966066922ed407805e79973d7ade834a6e
3,847
h
C
src/rapl-impl.h
rkmax/cpu-energy-meter
51d0da2411855323d851bd438306aee1b9f7e8dd
[ "BSD-2-Clause" ]
null
null
null
src/rapl-impl.h
rkmax/cpu-energy-meter
51d0da2411855323d851bd438306aee1b9f7e8dd
[ "BSD-2-Clause" ]
null
null
null
src/rapl-impl.h
rkmax/cpu-energy-meter
51d0da2411855323d851bd438306aee1b9f7e8dd
[ "BSD-2-Clause" ]
null
null
null
/* Copyright (c) 2012, Intel Corporation Copyright (c) 2015-2018, Dirk Beyer 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 Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* Replacement for pow() where the base is 2 and the power is unsigned and less than 31 (will get * invalid numbers if 31 or greater) */ #define B2POW(e) (((e) == 0) ? 1 : (2 << ((e)-1))) #define RAW_UNIT_TO_DOUBLE(e) (1.0 / (double)(B2POW(e))) /* General */ #define MSR_RAPL_POWER_UNIT 0x606 /* Unit Multiplier used in RAPL Interfaces (R/O) */ /* Package RAPL Domain */ #define MSR_RAPL_PKG_ENERGY_STATUS 0x611 /* PKG Energy Status (R/O) */ #define MSR_RAPL_PKG_POWER_INFO 0x614 /* PKG RAPL Parameters (R/O) */ /* DRAM RAPL Domain */ #define MSR_RAPL_DRAM_ENERGY_STATUS 0x619 /* DRAM Energy Status (R/O) */ /* PP0 RAPL Domain */ #define MSR_RAPL_PP0_ENERGY_STATUS 0x639 /* PP0 Energy Status (R/O) */ /* PP1 RAPL Domain */ #define MSR_RAPL_PP1_ENERGY_STATUS 0x641 /* PP1 Energy Status (R/O) */ /* PSYS RAPL Domain */ #define MSR_RAPL_PLATFORM_ENERGY_STATUS 0x64d /* PSYS Energy Status */ /* Common MSR Structures */ /* General */ typedef union { uint64_t as_uint64_t; struct rapl_unit_multiplier_msr_t { uint64_t power : 4; uint64_t : 4; uint64_t energy : 5; uint64_t : 3; uint64_t time : 4; uint64_t : 32; uint64_t : 12; } fields; } rapl_unit_multiplier_msr_t; /* Updated every ~1ms. Wraparound time of 60s under load. */ typedef union { uint64_t as_uint64_t; struct energy_status_msr_t { uint64_t total_energy_consumed : 32; uint64_t : 32; } fields; } energy_status_msr_t; /* PKG domain */ typedef union { uint64_t as_uint64_t; struct rapl_parameters_msr_t { unsigned int thermal_spec_power : 15; unsigned int : 1; unsigned int minimum_power : 15; unsigned int : 1; unsigned int maximum_power : 15; unsigned int : 1; unsigned int maximum_limit_time_window : 6; unsigned int : 10; } fields; } rapl_parameters_msr_t; extern double RAPL_TIME_UNIT; extern double RAPL_ENERGY_UNIT; extern double RAPL_DRAM_ENERGY_UNIT; extern double RAPL_POWER_UNIT; void config_msr_table(); /** * Check if MSR is supported on this machine. */ int is_supported_msr(off_t msr); int get_total_energy_consumed_via_msr( int node, off_t msr_address, double *total_energy_consumed_joules); /** * Get the maximum power that the given node can consume in watts. */ double get_max_power(int node); int read_rapl_units(uint32_t processor_signature);
34.657658
100
0.751235
5c0ba0d4b8d4a6581ffc8b4e6798e74be756371a
2,444
c
C
vendor/ruby/2.3.0/gems/ffi-1.9.18/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte2.c
epfl-lasa/TutorialICRA2018
a7e03f6ee0c5ffc0cbb9d01ece40c8b23780f30f
[ "Unlicense" ]
141
2015-01-12T12:02:17.000Z
2022-03-06T15:52:27.000Z
vendor/ruby/2.3.0/gems/ffi-1.9.18/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte2.c
epfl-lasa/TutorialICRA2018
a7e03f6ee0c5ffc0cbb9d01ece40c8b23780f30f
[ "Unlicense" ]
371
2020-03-04T21:51:56.000Z
2022-03-31T20:59:11.000Z
vendor/ruby/2.3.0/gems/ffi-1.9.18/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte2.c
epfl-lasa/TutorialICRA2018
a7e03f6ee0c5ffc0cbb9d01ece40c8b23780f30f
[ "Unlicense" ]
299
2015-01-23T10:06:24.000Z
2022-02-02T06:34:51.000Z
/* Area: ffi_call, closure_call Purpose: Check structure passing with different structure size. Depending on the ABI. Darwin/AIX do double-word alignment of the struct if the first element is a double. Check that it does here. Limitations: none. PR: none. Originator: <andreast@gcc.gnu.org> 20030914 */ /* { dg-do run } */ #include "ffitest.h" typedef struct cls_struct_9byte { double a; int b; } cls_struct_9byte; cls_struct_9byte cls_struct_9byte_fn(struct cls_struct_9byte b1, struct cls_struct_9byte b2) { struct cls_struct_9byte result; result.a = b1.a + b2.a; result.b = b1.b + b2.b; printf("%g %d %g %d: %g %d\n", b1.a, b1.b, b2.a, b2.b, result.a, result.b); return result; } static void cls_struct_9byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__) { struct cls_struct_9byte b1, b2; b1 = *(struct cls_struct_9byte*)(args[0]); b2 = *(struct cls_struct_9byte*)(args[1]); *(cls_struct_9byte*)resp = cls_struct_9byte_fn(b1, b2); } int main (void) { ffi_cif cif; void *code; ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); void* args_dbl[3]; ffi_type* cls_struct_fields[3]; ffi_type cls_struct_type; ffi_type* dbl_arg_types[3]; cls_struct_type.size = 0; cls_struct_type.alignment = 0; cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.elements = cls_struct_fields; struct cls_struct_9byte h_dbl = { 7.0, 8}; struct cls_struct_9byte j_dbl = { 1.0, 9}; struct cls_struct_9byte res_dbl; cls_struct_fields[0] = &ffi_type_double; cls_struct_fields[1] = &ffi_type_sint; cls_struct_fields[2] = NULL; dbl_arg_types[0] = &cls_struct_type; dbl_arg_types[1] = &cls_struct_type; dbl_arg_types[2] = NULL; CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type, dbl_arg_types) == FFI_OK); args_dbl[0] = &h_dbl; args_dbl[1] = &j_dbl; args_dbl[2] = NULL; ffi_call(&cif, FFI_FN(cls_struct_9byte_fn), &res_dbl, args_dbl); /* { dg-output "7 8 1 9: 8 17" } */ printf("res: %g %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 8 17" } */ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_9byte_gn, NULL, code) == FFI_OK); res_dbl = ((cls_struct_9byte(*)(cls_struct_9byte, cls_struct_9byte))(code))(h_dbl, j_dbl); /* { dg-output "\n7 8 1 9: 8 17" } */ printf("res: %g %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 8 17" } */ exit(0); }
26.565217
92
0.682897
c044453f6fff42c19bf776f6023182d3a81592d2
1,429
h
C
include/display/mouseclick.h
tomtix/penguins
0b5daa6fc3ee6b72c7793b0d3098ae63c3d8cf0b
[ "Apache-2.0" ]
null
null
null
include/display/mouseclick.h
tomtix/penguins
0b5daa6fc3ee6b72c7793b0d3098ae63c3d8cf0b
[ "Apache-2.0" ]
null
null
null
include/display/mouseclick.h
tomtix/penguins
0b5daa6fc3ee6b72c7793b0d3098ae63c3d8cf0b
[ "Apache-2.0" ]
null
null
null
#ifndef MOUSECLICK_H #define MOUSECLICK_H #define INVALID_CLICK -1 #define DISPLAY_THREAD_STOP -2 #define INVALID_MOUSECLICK_STRUCT -3 #define SURRENDER -4 enum mc_object_type { MC_TILE, MC_PENGUIN }; struct mouseclick { int validclick; enum mc_object_type t; int tile_id; int peng_id; }; int display_mc_get(struct mouseclick *mc); // return the id of the tile where was located the object // that the player clicked one // either a tile or a penguin. void display_mc_init(int (*coord_on_tile)(double x, double z), double z_shoes, double z_feet, double z_head); /* side view: *-----------------* z_head | | | | | | | penguin | | | | | | | *-----------------* z_feet | | | tile | | | | | *-----------------* z_shoes top view: tile: *-----------------* | X P | | | | X O | O is origin of the tile | | P is any point in the world *-----------------* pointed out by the user coord_on_tile : (x, z) = OP vector (projected on x and z axis) must returns 1 if P is on tile, 0 otherwise for an !!unscaled!! tile */ #endif //MOUSECLICK_H
21.984615
62
0.463961
c08627b6c4bae5901077731cf5cffb487a4b5284
52
h
C
src/human/compute_b.h
rmanak/bssn_spher
b91104fd6b9b7cf1ba08e35efd65ff219ab7a5a9
[ "MIT" ]
null
null
null
src/human/compute_b.h
rmanak/bssn_spher
b91104fd6b9b7cf1ba08e35efd65ff219ab7a5a9
[ "MIT" ]
null
null
null
src/human/compute_b.h
rmanak/bssn_spher
b91104fd6b9b7cf1ba08e35efd65ff219ab7a5a9
[ "MIT" ]
null
null
null
void compute_b_(double *A,int *Nx,double *B);
26
51
0.634615
dbc79a32073b4993f087041e69eda044780510f4
22,459
h
C
Texture_Mapping/glvu/vaomesh.h
cyzkrau/CG_2022s
600481a76f0de416fc6e097314910c4a2537e49e
[ "MIT" ]
null
null
null
Texture_Mapping/glvu/vaomesh.h
cyzkrau/CG_2022s
600481a76f0de416fc6e097314910c4a2537e49e
[ "MIT" ]
null
null
null
Texture_Mapping/glvu/vaomesh.h
cyzkrau/CG_2022s
600481a76f0de416fc6e097314910c4a2537e49e
[ "MIT" ]
null
null
null
#pragma once #include <algorithm> #include <vector> #include <array> #include <Eigen/Core> #include <Eigen/Geometry> #include <Eigen/LU> #include "glprogram.h" #include "glarray.h" Eigen::Matrix3f quaternaion2matrix(const float *q) { double s = Eigen::Map<const Eigen::Vector4f>(q).squaredNorm(); Eigen::Matrix3f res; float *m = res.data(); m[0] = 1.f - 2.f * (q[1] * q[1] + q[2] * q[2]); m[1] = 2.f * (q[0] * q[1] - q[2] * q[3]); m[2] = 2.f * (q[2] * q[0] + q[1] * q[3]); m[3 + 0] = 2.f * (q[0] * q[1] + q[2] * q[3]); m[3 + 1] = 1.f - 2.f * (q[2] * q[2] + q[0] * q[0]); m[3 + 2] = 2.f * (q[1] * q[2] - q[0] * q[3]); m[6 + 0] = 2.f * (q[2] * q[0] - q[1] * q[3]); m[6 + 1] = 2.f * (q[1] * q[2] + q[0] * q[3]); m[6 + 2] = 1.f - 2.f * (q[1] * q[1] + q[0] * q[0]); return res.transpose(); } Eigen::Matrix4f perspective(float fovy, float aspect, float zNear, float zFar) { assert(aspect > 0); assert(zFar > zNear); float radf = fovy / 180 * M_PI; float tanHalfFovy = tan(radf / 2); Eigen::Matrix4f res = Eigen::Matrix4f::Zero(); res(0, 0) = 1 / (aspect * tanHalfFovy); res(1, 1) = 1 / (tanHalfFovy); res(2, 2) = -(zFar + zNear) / (zFar - zNear); res(3, 2) = -1; res(2, 3) = -(2 * zFar * zNear) / (zFar - zNear); return res; } Eigen::Matrix4f lookAt(const float* eye, const float* center, const float* up) { using Vec = Eigen::RowVector3f; using MapVec = Eigen::Map<const Vec>; Vec f = (MapVec(center) - MapVec(eye)).normalized(); Vec u = MapVec(up).normalized(); Vec s = f.cross(u).normalized(); u = s.cross(f); Eigen::Matrix4f res; res.leftCols(3) << s, u, -f, 0, 0, 0; res.rightCols(1) << -res.topLeftCorner(3, 3)*MapVec(eye).transpose(), 1; return res; } template<typename R = float, int dimension = 3> struct GLMesh { enum { dim = dimension }; using MapMat4 = Eigen::Map < Eigen::Matrix < float, 4, 4, Eigen::RowMajor > >; using ConstMat4 = Eigen::Map < const Eigen::Matrix < float, 4, 4, Eigen::RowMajor > >; enum PickingElements { PE_NONE = 0, PE_VERTEX, PE_FACE }; enum PickingOperations { PO_NONE = 0, PO_ADD, PO_REMOVE }; struct Mesh { std::vector<R> X, UV; std::vector<int> T; size_t nVertex() const { return X.size() / dim; } size_t nFace() const { return T.size() / 3; } }; Mesh mesh; GLTexture tex; static GLTexture colormapTex; typedef std::array<R, 4> vec4; typedef std::array<R, dim> vec; int nVertex; int nFace; GLuint vaoHandle; GLArray<R, dim> gpuX; GLArray<int, 3, true> gpuT; GLArray<R, 2> gpuUV; GLArray<R, 1> gpuVertexData; GLArray<R, 1> gpuFaceData; R vtxDataMinMax[2]; bool vizVtxData; std::map<int, vec> constrainVertices; std::vector<R> vertexData; std::vector<R> faceData; std::vector<R> vertexVF; int actVertex; int actFace; int actConstrainVertex; vec4 faceColor = { 1.f, 1.f, 1.f, 1.f }; vec4 edgeColor = { 0.f, 0.f, 0.f, 0.8f }; vec4 vertexColor = { 1.f, 0.f, 0.f, .8f }; int depthMode = 0; float edgeWidth = 1.f; float pointSize = 0.f; float auxPointSize; float vertexDataDrawScale; float faceDataDrawScale; float VFDrawScale = 0.f; float mMeshScale = 1.f; float mTextureScale = 1.f; std::vector<int> auxVtxIdxs; vec mTranslate = { 0, 0, 0 }; float mQRotate[4] = { 0,0,0,1 }; float mViewCenter[3] = { 0, 0, 0 }; R bbox[dim * 2]; bool showTexture = false; bool drawTargetP2P = true; static GLProgram prog, pickProg, pointSetProg; ~GLMesh() { glDeleteVertexArrays(1, &vaoHandle); } GLMesh() :vaoHandle(0), actVertex(-1), actFace(-1), actConstrainVertex(-1), vertexDataDrawScale(0.f), faceDataDrawScale(0.f), vizVtxData(0), auxPointSize(0.f) {} void allocateStorage(int nv, int nf) { if (nv == nVertex && nf == nFace) return; nVertex = nv; nFace = nf; if (!vaoHandle) glGenVertexArrays(1, &vaoHandle); glBindVertexArray(vaoHandle); gpuX.allocateStorage(nv); glVertexAttribPointer(0, dim, GLType<R>::val, GL_FALSE, 0, nullptr); glEnableVertexAttribArray(0); // Vertex position gpuUV.allocateStorage(nv); glVertexAttribPointer(2, 2, GLType<R>::val, GL_FALSE, 0, nullptr); glEnableVertexAttribArray(2); // Texture coords gpuVertexData.allocateStorage(nv); glVertexAttribPointer(4, 1, GLType<R>::val, GL_FALSE, 0, nullptr); glEnableVertexAttribArray(4); // Vertex data gpuT.allocateStorage(nf); glBindVertexArray(0); } std::vector<int> getConstrainVertexIds() const { std::vector<int> idxs; idxs.reserve(constrainVertices.size()); for (auto it : constrainVertices) idxs.push_back(it.first); return idxs; } std::vector<R> getConstrainVertexCoords() const { std::vector<R> x; x.reserve(constrainVertices.size()*dim); for (auto it : constrainVertices) { x.insert(x.end(), { it.second[0], it.second[1], it.second[2] }); } return x; } void getTriangulation(int *t) { gpuT.downloadData(t, nFace); } void getTriangulation(int ti, int *t) { gpuT.at(ti, t); } void getVertex(R *x) { gpuX.downloadData(x, nVertex); } void getVertex(int vi, R *x) { gpuX.at(vi, x); } void setVertex(int vi, const R *x) { //for (int i = 0; i < dim; i++) mesh.X[vi*dim + i] = x[i]; gpuX.setAt(vi, x); } void setConstraintVertices(const int *ids, const R* pos, size_t nc) { constrainVertices.clear(); for (size_t i = 0; i < nc; i++) constrainVertices.insert({ ids[i], vec{ pos[i * 2], pos[i * 2 + 1], 0 } }); } void setVertexDataViz(const R* val) { if (val) { gpuVertexData.uploadData(val, mesh.nVertex()); glBindVertexArray(vaoHandle); gpuVertexData.bind(); glVertexAttribPointer(5, 1, GLType<R>::val, GL_FALSE, 0, nullptr); glEnableVertexAttribArray(5); auto mm = std::minmax_element(val, val + mesh.nVertex()); vtxDataMinMax[0] = *mm.first; vtxDataMinMax[1] = *mm.second; prog.bind(); prog.setUniform("dataMinMax", vtxDataMinMax[0], vtxDataMinMax[1]); } else { glBindVertexArray(vaoHandle); glDisableVertexAttribArray(5); } } void updateDataVizMinMax() { prog.bind(); prog.setUniform("dataMinMax", vtxDataMinMax[0], vtxDataMinMax[1]); } template<class MatrixR, class MatrixI> void upload(const MatrixR &x, const MatrixI &t, const R *uv) { upload(x.data(), (int)x.rows(), t.count() ? t.data() : nullptr, (int)t.rows(), uv); } void upload(const R *x, int nv, const int *t, int nf, const R *uv) { allocateStorage(x ? nv : nVertex, t ? nf : nFace); if (x) { gpuX.uploadData(x, nv, false); mesh.X.assign(x, x + nv*dim); } if (uv) { gpuUV.uploadData(uv, nv, false); mesh.UV.assign(uv, uv + nv * 2); } if (t) { gpuT.uploadData(t, nf, false); mesh.T.assign(t, t + nf * 3); } if (x&&t) { boundingbox(x, nv, bbox); // update bounding box for the initialization constrainVertices.clear(); auxVtxIdxs.clear(); actVertex = -1; actFace = -1; actConstrainVertex = -1; vertexData = std::vector<R>(nv, 0); faceData = std::vector<R>(nf, 1); gpuVertexData.uploadData(vertexData.data(), nVertex, false); gpuFaceData.uploadData(faceData.data(), nFace); } } void updateBBox() { boundingbox(mesh.X.data(), nVertex, bbox); } std::vector<R> baryCenters(const R* X) { std::vector<R> x(nFace * dim); for (int i = 0; i < nFace; i++) { const R *px[] = { &X[mesh.T[i * 3] * dim], &X[mesh.T[i * 3 + 1] * dim], &X[mesh.T[i * 3 + 2] * dim] }; for (int j = 0; j < dim; j++) x[i*dim + j] = (px[0][j] + px[1][j] + px[2][j]) / 3; } return x; } float actVertexData() const { return (actVertex >= 0 && actVertex < nVertex) ? vertexData[actVertex] : std::numeric_limits<float>::infinity(); } float actFaceData() const { return (actFace >= 0 && actFace < nFace) ? faceData[actFace] : std::numeric_limits<float>::infinity(); } void incActVertexData(float pct) { setVertexData(actVertex, (vertexData[actVertex] + 1e-3f) * (1 + pct)); } void incActFaceData(float pct) { setFaceData(actFace, (faceData[actFace] + 1e-3f) * (1 + pct)); } void setVertexData(int i, R v) { MAKESURE(i < nVertex && i >= 0); gpuVertexData.setAt(i, &v); vertexData[i] = v; } void setFaceData(int i, R v) { MAKESURE(i < nFace && i >= 0); gpuFaceData.setAt(i, &v); faceData[i] = v; } void setVertexData(const R *vtxData) { gpuVertexData.uploadData(vtxData, nVertex, false); } void setFaceData(const R *vtxData) { gpuFaceData.uploadData(vtxData, nFace, false); } bool showWireframe() const { return edgeWidth > 0; } bool showVertices() const { return pointSize > 0; } R drawscale() const { R scale0 = 1.9f / std::max(std::max(bbox[dim] - bbox[0], bbox[1 + dim] - bbox[1]), bbox[2 + dim] - bbox[2]); return mMeshScale*scale0; } std::array<R, 16> matMVP(const int *vp, bool offsetDepth = false, bool colmajor = false) const { R trans[] = { (bbox[0] + bbox[dim]) / 2, (bbox[1] + bbox[1 + dim]) / 2, (bbox[2] + bbox[2 + dim]) / 2 }; R ss = drawscale(); R t[] = { mTranslate[0] - trans[0], mTranslate[1] - trans[1], mTranslate[2] - trans[2] }; using Mat4 = Eigen::Matrix<float, 4, 4, Eigen::RowMajor>; Mat4 proj = perspective(45.f, vp[2] / float(vp[3]), 0.1f, 100.0f); if(offsetDepth) proj(2, 2) += 1e-4; float campos[] = { 0, 0, 4 }, up[] = { 0, 1, 0 };// Head is up (set to 0,-1,0 to look upside-down) Mat4 view = lookAt(campos, mViewCenter, up); Mat4 model; model<<ss*quaternaion2matrix(mQRotate), Eigen::Map<Eigen::Array3f>(t)*ss, 0, 0, 0, 1; std::array<R,16> mvp; Eigen::Map<Mat4>(mvp.data()) = proj*view*model; if (colmajor) Eigen::Map<Mat4>(mvp.data()).transposeInPlace(); return mvp; } void moveInScreen(int x0, int y0, int x1, int y1, int *vp) { float dx = (x1 - x0) * 2.f / vp[2]; float dy = -(y1 - y0) * 2.f / vp[3]; mViewCenter[0] -= dx; mViewCenter[1] -= dy; } void draw(const int *vp) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glActiveTexture(GL_TEXTURE0); tex.bind(); prog.bind(); prog.setUniform("textureScale", mTextureScale); prog.setUniform("MVP", matMVP(vp).data()); prog.setUniform("useTexMap", int(showTexture)); prog.setUniform("color", faceColor.data()); glBindVertexArray(vaoHandle); if (vizVtxData) { prog.setUniform("colorCoding", int(vizVtxData)); prog.setUniform("useTexMap", 1); colormapTex.bind(); } glDrawElements(GL_TRIANGLES, 3 * nFace, GL_UNSIGNED_INT, nullptr); // not GL_INT if (vizVtxData) { prog.setUniform("colorCoding", 0); prog.setUniform("useTexMap", int(showTexture)); tex.bind(); } //glDisable(GL_DEPTH_TEST); prog.setUniform("MVP", matMVP(vp, true).data()); if (showWireframe()) { glLineWidth(edgeWidth); prog.setUniform("color", edgeColor.data()); prog.setUniform("useTexMap", 0); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glDrawElements(GL_TRIANGLES, 3 * nFace, GL_UNSIGNED_INT, nullptr); // not GL_INT glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } if (showVertices()) { glPointSize(pointSize*mMeshScale); prog.setUniform("useTexMap", 0); prog.setUniform("color", vertexColor.data()); glDrawArrays(GL_POINTS, 0, nVertex); } glBindVertexArray(0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); prog.bind(); if (!constrainVertices.empty()) { prog.setUniform("useTexMap", 0); glDisable(GL_PROGRAM_POINT_SIZE); glPointSize(pointSize + 12); const auto idxs = getConstrainVertexIds(); GLArray<R, dim> consX(getConstrainVertexCoords().data(), idxs.size()); glVertexAttribPointer(0, dim, GLType<R>::val, GL_FALSE, 0, nullptr); glEnableVertexAttribArray(0); // Vertex position prog.setUniform("color", 0.f, 1.f, 1.f, .8f); if (drawTargetP2P) glDrawArrays(GL_POINTS, 0, (GLsizei)idxs.size()); gpuX.bind(); glVertexAttribPointer(0, dim, GLType<R>::val, GL_FALSE, 0, nullptr); glEnableVertexAttribArray(0); // Vertex position // make sure this is before the next draw if (actConstrainVertex >= 0) { prog.setUniform("color", 1.f, 0.f, 1.f, .8f); const int id = idxs[actConstrainVertex]; glDrawElements(GL_POINTS, 1, GL_UNSIGNED_INT, &id); } glPointSize(pointSize + 5); prog.setUniform("color", 0.f, 0.f, 0.f, .8f); glDrawElements(GL_POINTS, (GLsizei)idxs.size(), GL_UNSIGNED_INT, idxs.data()); glPointSize(1.f); } prog.unbind(); } int moveCurrentVertex(int x, int y, const int* vp) { if (actVertex < 0 || actVertex >= nVertex) return -1; auto mv = matMVP(vp); ConstMat4 MVP(mv.data()); Eigen::Vector4f v; v[3] = 1; getVertex(actVertex, v.data()); //mesh.X[actVertex*3] v = MVP*v; Eigen::Vector4f x1 = MVP.inverse().eval()*Eigen::Vector4f(x / R(vp[2]) * 2 - 1, 1 - y / R(vp[3]) * 2, v[2]/v[3], 1); // Make Sure call eval before topRows x1 = x1 / x1[3]; //R v0[] = { mesh.X[pickVertex*dim], mesh.X[pickVertex*dim + 1], 0, 1 }; //auto v1 = ConstMat4(mv.data()).transpose()*Eigen::Map<Eigen::Vector4f>(v0); //mesh.X[pickVertex*dim] = x1[0]; //mesh.X[pickVertex*dim+1] = x1[1]; //Eigen::Vector4f x2 = Eigen::Map<Eigen::Matrix4f>(mv.data()).transpose()*x1; setVertex(actVertex, x1.data()); if (constrainVertices.find(actVertex) != constrainVertices.end()) constrainVertices[actVertex] = { x1[0], x1[1], x1[2] }; return 0; } int pick(int x, int y, const int *vp, int pickElem, int operation) { int idx = -1; if (idx < 0) { //ensure(nFace < 16777216, "not implemented for big mesh"); //glDrawBuffer(GL_BACK); glDisable(GL_MULTISAMPLE); // make sure the color will not be interpolated glClearColor(1.f, 1.f, 1.f, 0.f); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); pickProg.bind(); pickProg.setUniform("MVP", matMVP(vp).data()); pickProg.setUniform("pickElement", pickElem); // 0/1 for pick vertex/face glBindVertexArray(vaoHandle); float pickdist = 12.f; glPointSize(pickdist); if (pickElem == PE_VERTEX) { // write depth for the whole shape glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glDrawElements(GL_TRIANGLES, 3 * nFace, GL_UNSIGNED_INT, nullptr); // not GL_INT glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); pickProg.setUniform("MVP", matMVP(vp,true).data()); glDrawArrays(GL_POINTS, 0, nVertex); } else glDrawElements(GL_TRIANGLES, 3 * nFace, GL_UNSIGNED_INT, nullptr); // not GL_INT unsigned char pixel[4]; glReadPixels(x, vp[3] - y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel); // y is inverted in OpenGL idx = (pixel[0] + pixel[1] * 256 + pixel[2] * 256 * 256) - 1; // -1 to get true index, 0 means background glBindVertexArray(0); pickProg.unbind(); //glDrawBuffer(GL_FRONT); glClearColor(1.f, 1.f, 1.f, 0.f); } if (pickElem == PE_VERTEX) actVertex = idx; else if (pickElem == PE_FACE) actFace = idx; int res = 0; // return how many vertex are added/deleted if (idx >= 0) { //printf("vertex %d is picked\n", idx); if (pickElem == PE_VERTEX) { auto it = constrainVertices.find(idx); if (it == constrainVertices.end()) { if (operation == PO_ADD && idx < nVertex) { // add constrain vec v; getVertex(idx, v.data()); constrainVertices[idx] = v; res = 1; } } else if (operation == PO_REMOVE) { constrainVertices.erase(it); res = -1; } } } auto i = getConstrainVertexIds(); auto it = std::find(i.cbegin(), i.cend(), actVertex); actConstrainVertex = int((it == i.cend()) ? -1 : (it - i.cbegin())); return res; } static void boundingbox(const R* x, int nv, R *bbox) { if (nv < 1) { printf("empty point set!\n"); return; } for (int i = 0; i < dim; i++) bbox[i] = bbox[i + dim] = x[i]; for (int i = 1; i < nv; i++) { for (int j = 0; j < dim; j++) { bbox[j] = std::min(bbox[j], x[i*dim + j]); bbox[j + dim] = std::max(bbox[j + dim], x[i*dim + j]); } } } static void buildShaders() { const char* vertexShaderStr = R"( #version 330 layout (location = 0) in vec3 VertexPosition; layout (location = 2) in vec2 VertexTexCoord; layout (location = 5) in float VertexData; out vec2 TexCoord; uniform mat4 MVP; uniform bool colorCoding = false; uniform vec2 dataMinMax = vec2(0, 1); void main(){ gl_Position = MVP*vec4(VertexPosition, 1); if(colorCoding) TexCoord = vec2((VertexData-dataMinMax.x)/(dataMinMax.y-dataMinMax.x), 0.5); else TexCoord = VertexTexCoord; })"; const char* fragShaderStr = R"( #version 330 in vec2 TexCoord; out vec4 FragColor; uniform sampler2D img; uniform float textureScale; uniform vec4 color; uniform bool useTexMap; void main(){ FragColor = useTexMap?texture(img, textureScale*TexCoord):color; if(FragColor.a<1e-1) discard; // important for transpancy with self overlapping })"; prog.compileAndLinkAllShadersFromString(vertexShaderStr, fragShaderStr); prog.bind(); prog.setUniform("img", 0); prog.setUniform("textureScale", 1.f); pointSetProg.compileAndLinkAllShadersFromString( R"( #version 330 layout (location = 0) in vec3 VertexPosition; layout (location = 1) in float VertexData; uniform float scale; uniform mat4 MVP; void main(){ gl_PointSize = VertexData*scale; gl_Position = MVP*vec4(VertexPosition, 1); })", R"( #version 330 out vec4 FragColor; uniform vec4 color; void main(){ FragColor = color; })"); ////////////////////////////////////////////////////////////////////////// pickProg.compileAndLinkAllShadersFromString( R"( #version 330 layout (location = 0) in vec3 VertexPosition; flat out int vertexId; uniform mat4 MVP; void main(){ gl_Position = MVP*vec4(VertexPosition, 1); vertexId = gl_VertexID; })", R"( #version 330 uniform int pickElement; flat in int vertexId; out vec4 FragColor; void main(){ int id = ( (pickElement==0)?vertexId:gl_PrimitiveID ) + 1; // Convert the integer id into an RGB color FragColor = vec4( (id & 0x000000FF) >> 0, (id & 0x0000FF00) >> 8, (id & 0x00FF0000) >> 16, 255.f)/255.f; })"); const unsigned char jetmaprgb[] = { 0, 0,144, 0, 0,160, 0, 0,176, 0, 0,192, 0, 0,208, 0, 0,224, 0, 0,240, 0, 0,255, 0, 16,255, 0, 32,255, 0, 48,255, 0, 64,255, 0, 80,255, 0, 96,255, 0,112,255, 0,128,255, 0,144,255, 0,160,255, 0,176,255, 0,192,255, 0,208,255, 0,224,255, 0,240,255, 0,255,255, 16,255,240, 32,255,224, 48,255,208, 64,255,192, 80,255,176, 96,255,160, 112,255,144, 128,255,128, 144,255,112, 160,255, 96, 176,255, 80, 192,255, 64, 208,255, 48, 224,255, 32, 240,255, 16, 255,255, 0, 255,240, 0, 255,224, 0, 255,208, 0, 255,192, 0, 255,176, 0, 255,160, 0, 255,144, 0, 255,128, 0, 255,112, 0, 255, 96, 0, 255, 80, 0, 255, 64, 0, 255, 48, 0, 255, 32, 0, 255, 16, 0, 255, 0, 0, 240, 0, 0, 224, 0, 0, 208, 0, 0, 192, 0, 0, 176, 0, 0, 160, 0, 0, 144, 0, 0, 128, 0, 0 }; colormapTex.setImage(MyImage((BYTE*)jetmaprgb, sizeof(jetmaprgb) / 3, 1, sizeof(jetmaprgb), 3)); // bug fix, pitch should be w*3 colormapTex.setClamping(GL_CLAMP_TO_EDGE); } }; typedef GLMesh<> MyMesh;
31.543539
163
0.532749
ef052588a6777cecf866ffb5982d4db775625ac3
1,348
h
C
pubg/PrivateHeaders/HsAnalyticsEvent.h
cara-ksa-so4/PUBC
1065b983d7bb1c4ad2104c2c4943487c7f17fa44
[ "MIT" ]
14
2019-07-23T20:33:14.000Z
2022-03-09T23:29:36.000Z
fc/PrivateHeaders/HsAnalyticsEvent.h
lechium/FControl
1203a3d6345b5ce9c738d238e0e7075e27c4d21c
[ "MIT" ]
5
2019-07-22T03:59:20.000Z
2020-03-02T14:50:48.000Z
fc/PrivateHeaders/HsAnalyticsEvent.h
lechium/FControl
1203a3d6345b5ce9c738d238e0e7075e27c4d21c
[ "MIT" ]
8
2019-07-23T20:35:34.000Z
2022-03-03T05:51:30.000Z
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #import "NSObject.h" @class NSString; @interface HsAnalyticsEvent : NSObject { _Bool _isGoalComplete; // 8 = 0x8 NSString *_eventId; // 16 = 0x10 NSString *_userId; // 24 = 0x18 NSString *_campaignId; // 32 = 0x20 long long _timestamp; // 40 = 0x28 long long _type; // 48 = 0x30 } @property(nonatomic) _Bool isGoalComplete; // @synthesize isGoalComplete=_isGoalComplete; @property(nonatomic) long long type; // @synthesize type=_type; @property(nonatomic) long long timestamp; // @synthesize timestamp=_timestamp; @property(retain, nonatomic) NSString *campaignId; // @synthesize campaignId=_campaignId; @property(retain, nonatomic) NSString *userId; // @synthesize userId=_userId; @property(retain, nonatomic) NSString *eventId; // @synthesize eventId=_eventId; - (void).cxx_destruct; // IMP=0x00000001014abcac - (void)encodeWithCoder:(id)arg1; // IMP=0x00000001014aba30 - (id)initWithCoder:(id)arg1; // IMP=0x00000001014ab868 - (id)toData; // IMP=0x00000001014ab5ac - (id)initEventWithType:(long long)arg1 forCampaign:(id)arg2; // IMP=0x00000001014ab59c - (id)initEventWithType:(long long)arg1 forCampaign:(id)arg2 withGoalCompletion:(_Bool)arg3; // IMP=0x00000001014ab3d0 @end
37.444444
118
0.72997
8971a03dc974de1bc4ad1eabe7078bbe75b536ca
2,001
h
C
Unix Family/Linux.Q.b/issl/issl.h
fengjixuchui/Family
2abe167082817d70ff2fd6567104ce4bcf0fe304
[ "MIT" ]
3
2021-05-15T15:57:13.000Z
2022-03-16T09:11:05.000Z
Unix Family/Linux.Q.b/issl/issl.h
fengjixuchui/Family
2abe167082817d70ff2fd6567104ce4bcf0fe304
[ "MIT" ]
null
null
null
Unix Family/Linux.Q.b/issl/issl.h
fengjixuchui/Family
2abe167082817d70ff2fd6567104ce4bcf0fe304
[ "MIT" ]
3
2021-05-15T15:57:15.000Z
2022-01-08T20:51:04.000Z
/* iSSL - independent secure sockets layer issl.h - iSSL API prototypes Copyright (C) 2001 by Mixter <mixter@newyorkoffice.com> Free use of the iSSL library is limited to noncommercial applications. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef ISSL_H #define ISSL_H #define ISSL_VERSION 1 #define ISSL_REVISION 3 #include "rsa.h" #include "rij.h" /* global key exchange key */ extern RSA_secret_key nodekey; /* iSSL connection descriptor = socket descriptor + AES key the iSSL RSA public peer key is not saved here; it is only used for temporary AES key exchange */ typedef struct { int fd; unsigned short init; /* connection established and keys exchanged? */ BYTE aes_key[321]; } issl_t; void issl_init_global(int nbytes); int issl_connect(issl_t *q); /* 1: success -1: failure */ int issl_accept(issl_t *q); /* 1: success -1: failure */ int issl_read(issl_t q, char *buf, int count); int issl_write(issl_t q, char *buf, int count); #define issl_close(q) close(q->fd) #endif
36.381818
76
0.621689
e68bbb023fe2ff5939a1f121571d8daa6e3f733b
6,272
h
C
Time-dependent simulation/processes.h
JackyHan/Human-Body-Temperature-Simulation
82294c826d9b39162daf0cff3f59037c2705bc89
[ "MIT" ]
null
null
null
Time-dependent simulation/processes.h
JackyHan/Human-Body-Temperature-Simulation
82294c826d9b39162daf0cff3f59037c2705bc89
[ "MIT" ]
null
null
null
Time-dependent simulation/processes.h
JackyHan/Human-Body-Temperature-Simulation
82294c826d9b39162daf0cff3f59037c2705bc89
[ "MIT" ]
null
null
null
/* MIT License Copyright (c) 2016 - Jacky Han 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 PROC_H #define PROC_H #include <iostream> #include <iomanip> #include <string> #include <cmath> /* ** NOTE: Not every function in this header file is used. Some of them ** were used in older versions of the program and so they were kept ** in case any comparisons needed to be made or switches were done. */ const int COL_W = 13; //output column width //Resting Energy Expenditure (Basal Metabolic Rate) (Watts) //arguments: mass in kg, height in cm, age in years, and sex (male==true, female==false) double REE(double m, double h, double a, bool male) { if(male) { return 0.0484*(10.0*m + 6.2*h - 5.0*a + 5); } else { return 0.0484*(10.0*m + 6.2*h - 5.0*a - 161); } } //convective heat transfer (W) //arguments: BSA (m^2), skin temp (celcius), ambient temp (C), wind speed (m/s) double convH(double A, double Ts, double Ta, double v) { //8.0 is the approximate convective coefficient (wheeler) return A * 8.0 * (Ts - Ta) * std::sqrt(v); } /* //DuBois Body Surface Area (m^2) //arguments: mass in kg, height in cm double BSA(double m, double h) { return 0.007184 * std::pow(m, 0.425) * std::pow(h, 0.725); } */ //Mosteller formula, as recommended by Verbraecken, et al //arguments: mass in kg, height in cm double BSA(double m, double h) { return std::sqrt(m*h/3600); } //heat lost through evaporation of sweat (Watts) //arguments: BSA (m^2), wind speed (m/s), ambient vapor pressure, //saturation vapor pressure at skin temp, ambient air pressure double Esw(double A, double v, double VPa, double SVPts, double P) { return A * 2416 * 0.00277 * v * 0.662 * (VPa - SVPts)/P; } //Black-Body radiation formula //arguments: BSA, temperature (C), skin temp (C) double bbRad(double A, double T, double Ts) { return 0.0000000567 * (std::pow(T + 273.15, 4) - std::pow(Ts + 273.15, 4) ); } //solar radiation heat //arguments: BSA (m^2), skin reflectivity double solarRad(double A, double refl) { //the 0.25 term comes from cross-sectional area return 0.25 * A * 1000 * (1.0 - refl); } //sherwood & huber sensible heat double sherS(double v, double Ts, double T) { return 12.5*v*(T - Ts); } //saturation vapor pressure at T (deg C) double satVP(double T) { return 6.108 * (std::exp((17.27 * T) / (237.3 + T))); } //vapor pressure (partial pressure of h2o) at given conditions double vapP(double T, double Tw) { double Es, Ew; Es = satVP(T); Ew = satVP(Tw); return Ew - (0.00066 * (1 + 0.00115 * Tw) * (T - Tw) * 101.3); } //kerslake evaporation heat loss double evap(double v, double T, double Ts, double Tw) { return 12.4 * std::sqrt(v) * (vapP(T, Tw) - satVP(Ts) ); } //kerslake convection double conv(double v, double T, double Ts) { return 8.3 * std::sqrt(v) * (T - Ts); } //sherwood & huber latent heat double sherL(double v, double T, double Tw) { return 12.5*v*(Tw - T); } //blood flow in liters/hm^2 double vb(double Tc, double Ts) { // /*Hope 1993*/ return (6.3 + 75*(Tc - 36.6))/(1 + 0.5*(34 - Ts)); return 0.7*((2.07*Tc)-75.44)*( (100.0/3.14159)*std::atan(0.75*(Ts-34.7)) + 53); } //ratio of shell volume to body volume double alpha(double vb) { return 0.044 + (0.35/(vb - 0.1386)); } //core surface area double coreA(double alpha, double BSA) { return std::pow(1 - alpha, 2.0/3.0) * BSA; } //energy exchange between core and shell //positive is core -> shell double fc(double Tc, double Ts, double BSA) { double flow = vb(Tc, Ts); return coreA(alpha(flow), BSA) * flow * (10e-7) * 1060 * 3860*(Tc - Ts) + bbRad(coreA(alpha(flow), BSA), Tc, Ts); } //sweat rate (hoppe 1993) double SW(double A, double Ts, double Tc) { return A * 8.47 * (10e-5) * ((0.1*Ts + 0.9*Tc) - 36.6); } //convection between core and shell double coreConv(double Tc, double Ts, double BSA) { return coreA(alpha(1), BSA)*10*(Tc - Ts); } //output numbers, used in the main loop to output the numerical values void outputN(std::ostream &o, double _1, double _2, double _3, double _4, double _5, double _6, double _7, double _8 = 0, double _9 = 0, double _10 = 0, double _11 = 0) { o << std::left << std::setw(COL_W) << _1 << std::setw(COL_W) << _2 << std::setw(COL_W) << _3 << std::setw(COL_W) << _4 << std::setw(COL_W) << _5 << std::setw(COL_W) << _6 << std::setw(COL_W) << _7 << std::setw(COL_W) << _8 << std::setw(COL_W) << _9 << std::setw(COL_W) << _10 << std::setw(COL_W) << _11 << std::endl; } //output strings, used in the main loop to output string values void outputS(std::ostream &o, std::string _1, std::string _2, std::string _3, std::string _4, std::string _5, std::string _6, std::string _7, std::string _8 = " ", std::string _9 = " ", std::string _10 = " ", std::string _11 = " ") { o << std::left << std::setw(COL_W) << _1 << std::setw(COL_W) << _2 << std::setw(COL_W) << _3 << std::setw(COL_W) << _4 << std::setw(COL_W) << _5 << std::setw(COL_W) << _6 << std::setw(COL_W) << _7 << std::setw(COL_W) << _8 << std::setw(COL_W) << _9 << std::setw(COL_W) << _10 << std::setw(COL_W) << _11 << std::endl; } #endif
30.595122
125
0.644452
e4f18f9f7777baa0a73daacb76b6e3ac2f953b58
1,513
h
C
GeometryLib/inc/Box.h
wangfeilong321/PDMS_ExportModel
4d61d11d53fe253054cb4cd23afbeb012fb6e386
[ "Apache-2.0" ]
6
2020-01-09T07:22:34.000Z
2021-11-12T11:28:44.000Z
GeometryLib/inc/Box.h
xxxmen/PDMS_ExportModel
4d61d11d53fe253054cb4cd23afbeb012fb6e386
[ "Apache-2.0" ]
null
null
null
GeometryLib/inc/Box.h
xxxmen/PDMS_ExportModel
4d61d11d53fe253054cb4cd23afbeb012fb6e386
[ "Apache-2.0" ]
4
2019-04-22T02:44:37.000Z
2020-07-20T01:01:11.000Z
#pragma once #include "BaseGeometry.h" namespace Geometry { class Box : public BaseGeometry { public: Box(); ~Box(); void setOrg(const osg::Vec3 &org); const osg::Vec3 &getOrg() const; void setXLen(const osg::Vec3 &xLen); const osg::Vec3 &getXLen() const; void setYLen(const osg::Vec3 &yLen); const osg::Vec3 &getYLen() const; void setZLen(const osg::Vec3 &zLen); const osg::Vec3 &getZLen() const; void setColor(const osg::Vec4 &color); const osg::Vec4 &getColor() const; protected: virtual void subDraw(); virtual bool doCullAndUpdate(const osg::CullStack &cullStack); void computeAssistVar(); private: osg::Vec3 m_org; osg::Vec3 m_xLen; osg::Vec3 m_yLen; osg::Vec3 m_zLen; osg::Vec4 m_color; double m_dblXLen; double m_dblYLen; double m_dblZLen; osg::Vec3 m_center; }; inline void Box::setOrg(const osg::Vec3 &org) { m_org = org; } inline const osg::Vec3 & Box::getOrg() const { return m_org; } inline void Box::setXLen(const osg::Vec3 &xLen) { m_xLen = xLen; } inline const osg::Vec3 & Box::getXLen() const { return m_xLen; } inline void Box::setYLen(const osg::Vec3 &yLen) { m_yLen = yLen; } inline const osg::Vec3 & Box::getYLen() const { return m_yLen; } inline void Box::setZLen(const osg::Vec3 &zLen) { m_zLen = zLen; } inline const osg::Vec3 & Box::getZLen() const { return m_zLen; } inline void Box::setColor(const osg::Vec4 &color) { m_color = color; } inline const osg::Vec4 & Box::getColor() const { return m_color; } } // namespace Geometry
15.13
63
0.689359
8e647ad5f4d260c29eb1fd9757ae40507985257f
916
h
C
src/brookbox/wm2/WmlIntrLin3Tor3.h
darwin/inferno
e87017763abae0cfe09d47987f5f6ac37c4f073d
[ "Zlib" ]
2
2016-05-09T11:57:28.000Z
2021-07-28T16:46:08.000Z
src/brookbox/wm2/WmlIntrLin3Tor3.h
darwin/inferno
e87017763abae0cfe09d47987f5f6ac37c4f073d
[ "Zlib" ]
null
null
null
src/brookbox/wm2/WmlIntrLin3Tor3.h
darwin/inferno
e87017763abae0cfe09d47987f5f6ac37c4f073d
[ "Zlib" ]
null
null
null
// Magic Software, Inc. // http://www.magic-software.com // http://www.wild-magic.com // Copyright (c) 2003. All Rights Reserved // // The Wild Magic Library (WML) source code is supplied under the terms of // the license agreement http://www.magic-software.com/License/WildMagic.pdf // and may not be copied or disclosed except in accordance with the terms of // that agreement. #ifndef WMLINTRLIN3TOR3_H #define WMLINTRLIN3TOR3_H #include "WmlRay3.h" #include "WmlTorus3.h" namespace Wml { // The ray is p*dir+eye, p >= 0. The intersection is determined by // p^4+c3*p^3+c2*p^2+c1*p+c0 = 0. The direction is assumed to be towards // the object from the observer so that the minimum p solution gives the // nearest intersection. template <class Real> WML_ITEM bool FindIntersection (const Ray3<Real>& rkRay, const Torus3<Real>& rkTorus, Real& rfS, Real& rfT); } #endif
28.625
77
0.703057
90acafa9c8b54d7cd380ca52a56a0b7148faa9b1
712
h
C
BBReadTheWorld/YoutuExtension/YTTagModel.h
Mosquito1123/SmartHappyBabyReading
ad41e6e9a174c2d25d2f487b42696e4f89f18e70
[ "BSD-2-Clause" ]
null
null
null
BBReadTheWorld/YoutuExtension/YTTagModel.h
Mosquito1123/SmartHappyBabyReading
ad41e6e9a174c2d25d2f487b42696e4f89f18e70
[ "BSD-2-Clause" ]
1
2019-07-19T02:20:45.000Z
2019-07-19T02:20:45.000Z
BBReadTheWorld/YoutuExtension/YTTagModel.h
Mosquito1123/SmartHappyBabyReading
ad41e6e9a174c2d25d2f487b42696e4f89f18e70
[ "BSD-2-Clause" ]
null
null
null
// // YTTagModel.h // Youtu // // Created by Kino on 19/01/5. // Copyright © 2019年 Kino. All rights reserved. // #import <Foundation/Foundation.h> @interface YTTagModel : NSObject @property (nonatomic, copy ) NSString *tag_name; @property (nonatomic, assign) NSInteger tag_confidence; - (id)initWithInfoDic:(NSDictionary *)infoDic; /** * 排好序的数组,以tag_confidence降序排列 * * @param rawArray <#rawArray description#> * * @return <#return value description#> */ + (NSArray *)orderedTAGsWithRawArray:(NSArray *)rawArray; /** * 置信度最高的TAG * * @param rawArray <#rawArray description#> * * @return <#return value description#> */ + (YTTagModel *)mostPossibleTAG:(NSArray *)orderedArray; @end
18.736842
57
0.688202
b84741973b2814161cdaf85f164b0510f4983464
952
h
C
tools/NSIS/Contrib/NSISdl/netinc.h
MikeAScott/testifywizard
74b767f35d4b1e163ce5437593f61f5a1d75e1c2
[ "MIT" ]
null
null
null
tools/NSIS/Contrib/NSISdl/netinc.h
MikeAScott/testifywizard
74b767f35d4b1e163ce5437593f61f5a1d75e1c2
[ "MIT" ]
null
null
null
tools/NSIS/Contrib/NSISdl/netinc.h
MikeAScott/testifywizard
74b767f35d4b1e163ce5437593f61f5a1d75e1c2
[ "MIT" ]
null
null
null
/* ** JNetLib ** Copyright (C) 2000-2001 Nullsoft, Inc. ** Author: Justin Frankel ** File: netinc.h - network includes and portability defines (used internally) ** License: see jnetlib.h */ #ifndef _NETINC_H_ #define _NETINC_H_ #include <windows.h> #include "util.h" #define strcasecmp(x,y) stricmp(x,y) #define ERRNO (WSAGetLastError()) #define SET_SOCK_BLOCK(s,block) { unsigned long __i=block?0:1; ioctlsocket(s,FIONBIO,&__i); } #define EWOULDBLOCK WSAEWOULDBLOCK #define EINPROGRESS WSAEWOULDBLOCK #define memset mini_memset #define memcpy mini_memcpy #define strcpy lstrcpy #define strncpy lstrcpyn #define strcat lstrcat #define strlen lstrlen #define malloc(x) (new char[x]) #define free(x) {delete x;} typedef int socklen_t; #ifndef INADDR_NONE #define INADDR_NONE 0xffffffff #endif #ifndef INADDR_ANY #define INADDR_ANY 0 #endif #ifndef SHUT_RDWR #define SHUT_RDWR 2 #endif #endif //_NETINC_H_
22.139535
94
0.733193
692ec1af337250242985748b546222292ba289f3
4,958
h
C
Model/ARotBondedInteraction.h
danielfrascarelli/esys-particle
e56638000fd9c4af77e21c75aa35a4f8922fd9f0
[ "Apache-2.0" ]
null
null
null
Model/ARotBondedInteraction.h
danielfrascarelli/esys-particle
e56638000fd9c4af77e21c75aa35a4f8922fd9f0
[ "Apache-2.0" ]
null
null
null
Model/ARotBondedInteraction.h
danielfrascarelli/esys-particle
e56638000fd9c4af77e21c75aa35a4f8922fd9f0
[ "Apache-2.0" ]
null
null
null
///////////////////////////////////////////////////////////// // // // Copyright (c) 2003-2019 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.apache.org/licenses/LICENSE-2.0 // // // ///////////////////////////////////////////////////////////// #ifndef __AROTBONDEDINTERACTION_H #define __AROTBONDEDINTERACTION_H // -- project includes -- #include "Model/RotPairInteraction.h" #include "Model/RotParticle.h" #include "Model/BondedInteractionCpData.h" #include "Model/IGParam.h" #include "Foundation/vec3.h" // -- I/O includes -- #include <iostream> using std::ostream; double calc_angle( double , double ) ; /*! \struct ARotBondedIGP \brief Interaction parameters for bonded interaction between rotational particles \author Shane Latham, Steffen Abe This structure only contains the parameters common to all rotational bonded interactions. Additional parameters for specific interactions are contained in derived classes $Revision$ $Date$ */ class ARotBondedIGP : public AIGParam { public: ARotBondedIGP(); ARotBondedIGP( const std::string &name, double kr, double ks, double kt, double kb, int tag, bool scaling ); ARotBondedIGP( const std::string &name, double youngsModulus, double poissonsRatio, int tag ); virtual std::string getTypeString() const { return "ARotBonded"; } double kr,ks,kt,kb ; int tag; bool scaling; }; /*! \class ARotBondedInteraction \brief Base class for a bonded interaction between bonded particles between rotational particles \author Shane Latham, Steffen Abe Contains only the part common to all rotational bonded interactions, i.e. force & stress calculations. Specifics of parameterisation and bond breaking are handled in derived classes. $Revision$ $Date$ */ class ARotBondedInteraction : public ARotPairInteraction { public: // types typedef ARotBondedIGP ParameterType; typedef double (ARotBondedInteraction::* ScalarFieldFunction)() const; typedef pair<bool,double> (ARotBondedInteraction::* CheckedScalarFieldFunction)() const; typedef Vec3 (ARotBondedInteraction::* VectorFieldFunction)() const; // type & dummy implementation for parameter setting function typedef void (ARotBondedInteraction::* ScalarSetFunction)(double); static ScalarSetFunction getScalarSetFunction(const string&){return NULL;}; protected: // protected: double m_dist; //!< current distance, cached from last calcForces() double m_r0; //!< equilibrium separation double m_kr ; //!< spring constant double m_ks ; double m_kb ; double m_kt ; double m_nForce; // >0, pulling; <0 , compressing double m_shForce ; // always >0 double m_tMoment ; double m_bMoment ; Vec3 m_force; //!< current force, cached for E_pot calculation Vec3 m_moment ; Vec3 m_cpos; // ? Vec3 m_D; //!< initial positions of the particles int m_tag; bool m_scaling; public: ARotBondedInteraction(); ARotBondedInteraction(CRotParticle*,CRotParticle*,const ARotBondedIGP&); virtual ~ARotBondedInteraction(); static ScalarFieldFunction getScalarFieldFunction(const string&); static CheckedScalarFieldFunction getCheckedScalarFieldFunction(const string&); static VectorFieldFunction getVectorFieldFunction(const string&); static string getType(){return "RotBonded";}; int getTag() const; void setTag(int tag); void calcForces(); //void setBreak(double); virtual bool broken() =0; // pure virtual - defined in derived classes double getPotentialEnergy() const; double getNormalPotentialEnergy() const; double getShearPotentialEnergy() const; double getTwistPotentialEnergy() const; double getBendPotentialEnergy() const; Vec3 getForce() const; Vec3 getNormalForce() const; Vec3 getTangentialForce() const; virtual Vec3 getPos() const {return m_cpos;}; Vec3 getCentrePtDiff() const; Vec3 getInitialCentrePtDiff() const; Vec3 getInitialMidPoint() const; Vec3 getP2ShearForcePt() const; Vec3 getP1ShearForcePt() const; Vec3 getContactPoint() const; Vec3 getShearDiff() const; virtual void saveCheckPointData(std::ostream &oStream)=0; virtual void loadCheckPointData(std::istream &iStream)=0; // save/load of restart parameters virtual void saveRestartData(std::ostream &oStream)=0; virtual void loadRestartData(std::istream &iStream)=0; }; #endif //__BONDEDINTERACTION_H
29.511905
105
0.671238
509958e59316c813a8ad678212c15f1fd40bc7ee
748
h
C
src/stkwebapp/StkWebAppExec.h
s-takeuchi/YaizuComLib
de1c881a4b743bafec22f7ea2d263572c474cbfe
[ "MIT" ]
4
2017-02-21T23:25:23.000Z
2022-01-30T20:17:22.000Z
src/stkwebapp/StkWebAppExec.h
Aekras1a/YaizuComLib
470d33376add0d448002221b75f7efd40eec506f
[ "MIT" ]
161
2015-05-16T14:26:36.000Z
2021-11-25T05:07:56.000Z
src/stkwebapp/StkWebAppExec.h
Aekras1a/YaizuComLib
470d33376add0d448002221b75f7efd40eec506f
[ "MIT" ]
1
2019-12-06T10:24:45.000Z
2019-12-06T10:24:45.000Z
#pragma once #include "../commonfunc/StkObject.h" class StkWebAppExec { public: static const unsigned char STKWEBAPP_METHOD_UNDEFINED = 0x00; static const unsigned char STKWEBAPP_METHOD_GET = 0x01; static const unsigned char STKWEBAPP_METHOD_HEAD = 0x02; static const unsigned char STKWEBAPP_METHOD_POST = 0x04; static const unsigned char STKWEBAPP_METHOD_PUT = 0x08; static const unsigned char STKWEBAPP_METHOD_DELETE = 0x10; static const unsigned char STKWEBAPP_METHOD_OPTIONS = 0x20; static const unsigned char STKWEBAPP_METHOD_INVALID = 0x40; static const int URL_PATH_LENGTH = 1024; public: virtual StkObject* Execute(StkObject*, int, wchar_t[StkWebAppExec::URL_PATH_LENGTH], int*, wchar_t*) = 0; };
35.619048
106
0.770053
da1d870a7d7f17928b748b95ed63a434053a1f8c
1,515
h
C
board.h
TediCreations/systick
2fc6f5be2e84089728505b61c967f79b6e435e60
[ "MIT" ]
null
null
null
board.h
TediCreations/systick
2fc6f5be2e84089728505b61c967f79b6e435e60
[ "MIT" ]
null
null
null
board.h
TediCreations/systick
2fc6f5be2e84089728505b61c967f79b6e435e60
[ "MIT" ]
null
null
null
/****************************************************************************** About ******************************************************************************/ //TODO: Doxygen the about section in file board.h /** * \file board.h * * \brief TODO: Write brief * * Created: 08/12/2017 * * \author Ilias Kanelis hkanelhs@yahoo.gr */ /** * \defgroup Ungrouped Ungrouped * * \code #include <board.h> \endcode */ /****************************************************************************** Code ******************************************************************************/ #ifndef BOARD_H_ONLY_ONE_INCLUDE_SAFETY #define BOARD_H_ONLY_ONE_INCLUDE_SAFETY #ifdef __cplusplus extern "C" { #endif /******************************************************************************* Include files *******************************************************************************/ #include <stdint.h> /* uint32_t */ /****************************************************************************** Function declarations ******************************************************************************/ void bsp_init( void ); const char* bsp_getName( void ); uint32_t bsp_getTicks( void ); void bsp_resetTicks( void ); int8_t bsp_setSysTick( void ); void bsp_setup_led( void ); void bsp_led_on( void ); void bsp_led_off( void ); void bsp_led_toggle( void ); #ifdef __cplusplus } #endif #endif /* BOARD_H_ONLY_ONE_INCLUDE_SAFETY */
24.435484
81
0.380858
dd7e8709638d8440236f39c8ce6704c6c9ec0d6e
8,412
h
C
unittests/DebugInfo/DWARF/DwarfGenerator.h
vangthao95/llvm
7161a90f679d8d52ab57a3166361a7ebd1ba5459
[ "Apache-2.0" ]
171
2018-09-17T13:15:12.000Z
2022-03-18T03:47:04.000Z
FRProtector/unittests/DebugInfo/DWARF/DwarfGenerator.h
whucs303/randomizationlib
07a1f495e1cf878ad9dd4c79b7ff1c6b48cff876
[ "MIT" ]
27
2018-09-17T17:49:49.000Z
2021-11-03T04:31:51.000Z
FRProtector/unittests/DebugInfo/DWARF/DwarfGenerator.h
whucs303/randomizationlib
07a1f495e1cf878ad9dd4c79b7ff1c6b48cff876
[ "MIT" ]
55
2018-02-01T07:11:49.000Z
2022-03-04T01:20:23.000Z
//===--- unittests/DebugInfo/DWARF/DwarfGenerator.h -------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // A file that can generate DWARF debug info for unit tests. // //===----------------------------------------------------------------------===// #ifndef LLVM_UNITTESTS_DEBUG_INFO_DWARF_DWARFGENERATOR_H #define LLVM_UNITTESTS_DEBUG_INFO_DWARF_DWARFGENERATOR_H #include "llvm/ADT/StringRef.h" #include "llvm/CodeGen/DIE.h" #include "llvm/DebugInfo/DWARF/DWARFDebugLine.h" #include "llvm/Support/Error.h" #include <memory> #include <string> #include <tuple> #include <vector> namespace llvm { class AsmPrinter; class DIE; class DIEAbbrev; class DwarfStringPool; class MCAsmBackend; class MCAsmInfo; class MCCodeEmitter; class MCContext; struct MCDwarfLineTableParams; class MCInstrInfo; class MCObjectFileInfo; class MCRegisterInfo; class MCStreamer; class MCSubtargetInfo; class raw_fd_ostream; class TargetMachine; class Triple; namespace dwarfgen { class Generator; class CompileUnit; /// A DWARF debug information entry class used to generate DWARF DIEs. /// /// This class is used to quickly generate DWARF debug information by creating /// child DIEs or adding attributes to the current DIE. Instances of this class /// are created from the compile unit (dwarfgen::CompileUnit::getUnitDIE()) or /// by calling dwarfgen::DIE::addChild(...) and using the returned DIE object. class DIE { dwarfgen::CompileUnit *CU; llvm::DIE *Die; protected: friend class Generator; friend class CompileUnit; DIE(CompileUnit *U = nullptr, llvm::DIE *D = nullptr) : CU(U), Die(D) {} /// Called with a compile/type unit relative offset prior to generating the /// DWARF debug info. /// /// \param CUOffset the compile/type unit relative offset where the /// abbreviation code for this DIE will be encoded. unsigned computeSizeAndOffsets(unsigned CUOffset); public: /// Add an attribute value that has no value. /// /// \param Attr a dwarf::Attribute enumeration value or any uint16_t that /// represents a user defined DWARF attribute. /// \param Form the dwarf::Form to use when encoding the attribute. This is /// only used with the DW_FORM_flag_present form encoding. void addAttribute(uint16_t Attr, dwarf::Form Form); /// Add an attribute value to be encoded as a DIEInteger /// /// \param Attr a dwarf::Attribute enumeration value or any uint16_t that /// represents a user defined DWARF attribute. /// \param Form the dwarf::Form to use when encoding the attribute. /// \param U the unsigned integer to encode. void addAttribute(uint16_t Attr, dwarf::Form Form, uint64_t U); /// Add an attribute value to be encoded as a DIEString or DIEInlinedString. /// /// \param Attr a dwarf::Attribute enumeration value or any uint16_t that /// represents a user defined DWARF attribute. /// \param Form the dwarf::Form to use when encoding the attribute. The form /// must be one of DW_FORM_strp or DW_FORM_string. /// \param String the string to encode. void addAttribute(uint16_t Attr, dwarf::Form Form, StringRef String); /// Add an attribute value to be encoded as a DIEEntry. /// /// DIEEntry attributes refer to other llvm::DIE objects that have been /// created. /// /// \param Attr a dwarf::Attribute enumeration value or any uint16_t that /// represents a user defined DWARF attribute. /// \param Form the dwarf::Form to use when encoding the attribute. The form /// must be one of DW_FORM_strp or DW_FORM_string. /// \param RefDie the DIE that this attriute refers to. void addAttribute(uint16_t Attr, dwarf::Form Form, dwarfgen::DIE &RefDie); /// Add an attribute value to be encoded as a DIEBlock. /// /// DIEBlock attributes refers to binary data that is stored as the /// attribute's value. /// /// \param Attr a dwarf::Attribute enumeration value or any uint16_t that /// represents a user defined DWARF attribute. /// \param Form the dwarf::Form to use when encoding the attribute. The form /// must be one of DW_FORM_strp or DW_FORM_string. /// \param P a pointer to the data to store as the attribute value. /// \param S the size in bytes of the data pointed to by P . void addAttribute(uint16_t Attr, dwarf::Form Form, const void *P, size_t S); /// Add a new child to this DIE object. /// /// \param Tag the dwarf::Tag to assing to the llvm::DIE object. /// \returns the newly created DIE object that is now a child owned by this /// object. dwarfgen::DIE addChild(dwarf::Tag Tag); }; /// A DWARF compile unit used to generate DWARF compile/type units. /// /// Instances of these classes are created by instances of the Generator /// class. All information required to generate a DWARF compile unit is /// contained inside this class. class CompileUnit { Generator &DG; BasicDIEUnit DU; public: CompileUnit(Generator &D, uint16_t V, uint8_t A) : DG(D), DU(V, A, dwarf::DW_TAG_compile_unit) {} DIE getUnitDIE(); Generator &getGenerator() { return DG; } uint64_t getOffset() const { return DU.getDebugSectionOffset(); } uint64_t getLength() const { return DU.getLength(); } uint16_t getVersion() const { return DU.getDwarfVersion(); } uint16_t getAddressSize() const { return DU.getAddressSize(); } void setOffset(uint64_t Offset) { DU.setDebugSectionOffset(Offset); } void setLength(uint64_t Length) { DU.setLength(Length); } }; /// A DWARF generator. /// /// Generate DWARF for unit tests by creating any instance of this class and /// calling Generator::addCompileUnit(), and then getting the dwarfgen::DIE from /// the returned compile unit and adding attributes and children to each DIE. class Generator { std::unique_ptr<MCRegisterInfo> MRI; std::unique_ptr<MCAsmInfo> MAI; std::unique_ptr<MCObjectFileInfo> MOFI; std::unique_ptr<MCContext> MC; MCAsmBackend *MAB; // Owned by MCStreamer std::unique_ptr<MCInstrInfo> MII; std::unique_ptr<MCSubtargetInfo> MSTI; MCCodeEmitter *MCE; // Owned by MCStreamer MCStreamer *MS; // Owned by AsmPrinter std::unique_ptr<TargetMachine> TM; std::unique_ptr<AsmPrinter> Asm; BumpPtrAllocator Allocator; std::unique_ptr<DwarfStringPool> StringPool; // Entries owned by Allocator. std::vector<std::unique_ptr<CompileUnit>> CompileUnits; DIEAbbrevSet Abbreviations; SmallString<4096> FileBytes; /// The stream we use to generate the DWARF into as an ELF file. std::unique_ptr<raw_svector_ostream> Stream; /// The DWARF version to generate. uint16_t Version; /// Private constructor, call Generator::Create(...) to get a DWARF generator /// expected. Generator(); /// Create the streamer and setup the output buffer. llvm::Error init(Triple TheTriple, uint16_t DwarfVersion); public: /// Create a DWARF generator or get an appropriate error. /// /// \param TheTriple the triple to use when creating any required support /// classes needed to emit the DWARF. /// \param DwarfVersion the version of DWARF to emit. /// /// \returns a llvm::Expected that either contains a unique_ptr to a Generator /// or a llvm::Error. static llvm::Expected<std::unique_ptr<Generator>> create(Triple TheTriple, uint16_t DwarfVersion); ~Generator(); /// Generate all DWARF sections and return a memory buffer that /// contains an ELF file that contains the DWARF. StringRef generate(); /// Add a compile unit to be generated. /// /// \returns a dwarfgen::CompileUnit that can be used to retrieve the compile /// unit dwarfgen::DIE that can be used to add attributes and add child DIE /// objedts to. dwarfgen::CompileUnit &addCompileUnit(); BumpPtrAllocator &getAllocator() { return Allocator; } AsmPrinter *getAsmPrinter() const { return Asm.get(); } MCContext *getMCContext() const { return MC.get(); } DIEAbbrevSet &getAbbrevSet() { return Abbreviations; } DwarfStringPool &getStringPool() { return *StringPool; } /// Save the generated DWARF file to disk. /// /// \param Path the path to save the ELF file to. bool saveFile(StringRef Path); }; } // end namespace dwarfgen } // end namespace llvm #endif // LLVM_UNITTESTS_DEBUG_INFO_DWARF_DWARFGENERATOR_H
36.103004
80
0.711484
202c2b8dfe288e1eb35e358ecb2592a1c6f399dc
158
h
C
source/engine/mainloop.h
lukaklar/Khan-Engine
2496366759649d282d725fa637b25fb1e0d4fdfa
[ "Apache-2.0" ]
null
null
null
source/engine/mainloop.h
lukaklar/Khan-Engine
2496366759649d282d725fa637b25fb1e0d4fdfa
[ "Apache-2.0" ]
null
null
null
source/engine/mainloop.h
lukaklar/Khan-Engine
2496366759649d282d725fa637b25fb1e0d4fdfa
[ "Apache-2.0" ]
null
null
null
#pragma once #include "system/timer.hpp" namespace Khan { class MainLoop { public: void Run(); private: Timer m_UpdateTimer; bool m_Running; }; }
10.533333
27
0.683544
59e6c58bb198cdb0587fa1296a0681a5b0b1c84d
411
h
C
Classes/Sorts/Models/SortListItem.h
XYGDeveloper/GlobalFrog
aac846dca5817b9eb2efc0e73bad5bdca6225fa8
[ "MIT" ]
1
2019-04-24T07:42:29.000Z
2019-04-24T07:42:29.000Z
Classes/Sorts/Models/SortListItem.h
XYGDeveloper/GlobalFrog
aac846dca5817b9eb2efc0e73bad5bdca6225fa8
[ "MIT" ]
null
null
null
Classes/Sorts/Models/SortListItem.h
XYGDeveloper/GlobalFrog
aac846dca5817b9eb2efc0e73bad5bdca6225fa8
[ "MIT" ]
null
null
null
// // SortListItem.h // Qqw // // Created by zagger on 16/8/31. // Copyright © 2016年 quanqiuwa. All rights reserved. // #import <Foundation/Foundation.h> /** * 分类列表模型 */ @interface SortListItem : NSObject @property (nonatomic, copy) NSString *cat_id; @property (nonatomic, copy) NSString *cat_name; @property (nonatomic, copy) NSString *cat_img; @property (nonatomic, strong) NSArray *child; @end
16.44
53
0.695864
ea3cc38a0e3181c0bcca3e4fb6a2a9cf7ad670f7
3,923
c
C
XFree86-3.3/xc/programs/Xserver/dix/pixmap.c
tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective
1b0172cdb78757fd17898503aaf6ce03d940ef28
[ "Apache-1.1" ]
46
2015-12-04T17:12:58.000Z
2022-03-11T04:30:49.000Z
XFree86-3.3/xc/programs/Xserver/dix/pixmap.c
tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective
1b0172cdb78757fd17898503aaf6ce03d940ef28
[ "Apache-1.1" ]
null
null
null
XFree86-3.3/xc/programs/Xserver/dix/pixmap.c
tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective
1b0172cdb78757fd17898503aaf6ce03d940ef28
[ "Apache-1.1" ]
23
2016-10-24T09:18:14.000Z
2022-02-25T02:11:35.000Z
/* $XConsortium: pixmap.c /main/4 1996/08/12 22:04:49 dpw $ */ /* $XFree86: xc/programs/Xserver/dix/pixmap.c,v 3.1 1996/12/23 06:29:47 dawes Exp $ */ /* Copyright (c) 1993 X Consortium 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium. */ #include "X.h" #include "scrnintstr.h" #include "misc.h" #include "os.h" #include "windowstr.h" #include "resource.h" #include "dixstruct.h" #include "gcstruct.h" #include "servermd.h" #include "site.h" /* * Scratch pixmap management and device independent pixmap allocation * function. */ /* callable by ddx */ PixmapPtr GetScratchPixmapHeader(pScreen, width, height, depth, bitsPerPixel, devKind, pPixData) ScreenPtr pScreen; int width; int height; int depth; int bitsPerPixel; int devKind; pointer pPixData; { PixmapPtr pPixmap = pScreen->pScratchPixmap; if (pPixmap) pScreen->pScratchPixmap = NULL; else /* width and height of 0 means don't allocate any pixmap data */ pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth); if (pPixmap) if ((*pScreen->ModifyPixmapHeader)(pPixmap, width, height, depth, bitsPerPixel, devKind, pPixData)) return pPixmap; return NullPixmap; } /* callable by ddx */ void FreeScratchPixmapHeader(pPixmap) PixmapPtr pPixmap; { if (pPixmap) { ScreenPtr pScreen = pPixmap->drawable.pScreen; pPixmap->devPrivate.ptr = NULL; /* lest ddx chases bad ptr */ if (pScreen->pScratchPixmap) (*pScreen->DestroyPixmap)(pPixmap); else pScreen->pScratchPixmap = pPixmap; } } Bool CreateScratchPixmapsForScreen(scrnum) int scrnum; { /* let it be created on first use */ screenInfo.screens[scrnum]->pScratchPixmap = NULL; return TRUE; } void FreeScratchPixmapsForScreen(scrnum) int scrnum; { FreeScratchPixmapHeader(screenInfo.screens[scrnum]->pScratchPixmap); } /* callable by ddx */ PixmapPtr AllocatePixmap(pScreen, pixDataSize) ScreenPtr pScreen; int pixDataSize; { PixmapPtr pPixmap; #ifdef PIXPRIV char *ptr; DevUnion *ppriv; unsigned *sizes; unsigned size; int i; pPixmap = (PixmapPtr)xalloc(pScreen->totalPixmapSize + pixDataSize); if (!pPixmap) return NullPixmap; ppriv = (DevUnion *)(pPixmap + 1); pPixmap->devPrivates = ppriv; sizes = pScreen->PixmapPrivateSizes; ptr = (char *)(ppriv + pScreen->PixmapPrivateLen); for (i = pScreen->PixmapPrivateLen; --i >= 0; ppriv++, sizes++) { if ((size = *sizes) != 0) { ppriv->ptr = (pointer)ptr; ptr += size; } else ppriv->ptr = (pointer)NULL; } #else pPixmap = (PixmapPtr)xalloc(sizeof(PixmapRec) + pixDataSize); #endif return pPixmap; }
25.980132
86
0.705837
2d57663cb5b46895ea68d4c6ad1fec0f3b6c545b
1,887
h
C
inc/elf.h
A1va/MIT6.828
9d569808573f5b1df04f22927f18507c004278c9
[ "MIT" ]
1
2020-12-23T06:45:01.000Z
2020-12-23T06:45:01.000Z
inc/elf.h
A1va/MIT6.828
9d569808573f5b1df04f22927f18507c004278c9
[ "MIT" ]
null
null
null
inc/elf.h
A1va/MIT6.828
9d569808573f5b1df04f22927f18507c004278c9
[ "MIT" ]
null
null
null
#ifndef JOS_INC_ELF_H #define JOS_INC_ELF_H #define ELF_MAGIC 0x464C457FU /* "\x7FELF" in little endian */ // ELF file // Header(识别+执行): ELF Header (ELF) + Program Header Table (Proghdr) // Section: 可执行的内容: Code + Data + Section's Name // Header(链接 执行可忽略): Section Header Table // 1. 解析 Header 1 // 2. 根据 Segment 属性字段将文件映射到内存 // 3. 执行: a.调用 entry, (Elf->e_entry) 执行开始的地址 // b.系统调用: R7 寄存器的系统调用, 并调用 SVC 指令 struct Elf { uint32_t e_magic; // must equal ELF_MAGIC uint8_t e_elf[12]; uint16_t e_type; // 可执行/可链接 uint16_t e_machine; // 处理器类型 uint32_t e_version; // 版本: 1 uint32_t e_entry; // 执行开始的地址 uint32_t e_phoff; // 程序头部的偏移 uint32_t e_shoff; // 段(section)头部的偏移 uint32_t e_flags; // 权限: 可执行 和 可链接 uint16_t e_ehsize; // ELF 头部的大小 uint16_t e_phentsize; // 单个程序头部的大小 uint16_t e_phnum; // 程序头部的数量 uint16_t e_shentsize; // 单个段(section)头部的大小 uint16_t e_shnum; // 段(section)头部的数量 uint16_t e_shstrndx; // 表中 name 段(section)的索引 }; struct Proghdr { uint32_t p_type; // 是否应该加载进内存的段(segment), 假设 yes uint32_t p_offset; // 被读取时的偏移 uint32_t p_va; // 期望被加载的虚拟地址 uint32_t p_pa; // 期望被加载的物理地址 uint32_t p_filesz; // 文件大小 uint32_t p_memsz; // 在内存中的大小 uint32_t p_flags; // 权限: 可执行 和 可链接 uint32_t p_align; // 字节对齐协议 }; struct Secthdr { uint32_t sh_name; // "" .shrtrtab .text .rodata ...... uint32_t sh_type; uint32_t sh_flags; uint32_t sh_addr; uint32_t sh_offset; uint32_t sh_size; uint32_t sh_link; uint32_t sh_info; uint32_t sh_addralign; uint32_t sh_entsize; }; // Values for Proghdr::p_type #define ELF_PROG_LOAD 1 // Flag bits for Proghdr::p_flags #define ELF_PROG_FLAG_EXEC 1 #define ELF_PROG_FLAG_WRITE 2 #define ELF_PROG_FLAG_READ 4 // Values for Secthdr::sh_type #define ELF_SHT_NULL 0 #define ELF_SHT_PROGBITS 1 #define ELF_SHT_SYMTAB 2 #define ELF_SHT_STRTAB 3 // Values for Secthdr::sh_name #define ELF_SHN_UNDEF 0 #endif /* !JOS_INC_ELF_H */
25.5
67
0.72973
31c9f67adf73049a33aa67ef91bf6e8ed22f2b40
80
h
C
client-lite/src/config/network_monitor.h
QPC-database/do-client
8966861204e09961f0db33728e500cd7346cd5dd
[ "MIT" ]
1
2021-07-06T14:12:34.000Z
2021-07-06T14:12:34.000Z
client-lite/src/config/network_monitor.h
QPC-database/do-client
8966861204e09961f0db33728e500cd7346cd5dd
[ "MIT" ]
null
null
null
client-lite/src/config/network_monitor.h
QPC-database/do-client
8966861204e09961f0db33728e500cd7346cd5dd
[ "MIT" ]
null
null
null
#pragma once class NetworkMonitor { public: static bool IsConnected(); };
8.888889
30
0.7
677623c5519ceb59bf6227c06b977474ac80b2e1
1,818
c
C
src/utils/buffer.c
TristanBilot/42sh
9e956c59e2efdbd35ad17367fda30ae78c772abe
[ "MIT" ]
null
null
null
src/utils/buffer.c
TristanBilot/42sh
9e956c59e2efdbd35ad17367fda30ae78c772abe
[ "MIT" ]
null
null
null
src/utils/buffer.c
TristanBilot/42sh
9e956c59e2efdbd35ad17367fda30ae78c772abe
[ "MIT" ]
null
null
null
#include <stdlib.h> #include <string.h> #include "../lexer/lexer.h" #include "../utils/buffer.h" #include "../utils/xalloc.h" struct buffer *new_buffer(void) { struct buffer *buffer = xcalloc(sizeof(struct buffer), 1); buffer->buf = xcalloc(BUFFER_SIZE, 1); buffer->index = 0; return buffer; } struct buffer *new_huge_buffer(void) { struct buffer *buffer = xcalloc(sizeof(struct buffer), 1); buffer->buf = xcalloc(1, HUGE_BUFFER_SIZE); buffer->index = 0; return buffer; } void append_buffer(struct buffer *buffer, char c) { if (buffer->index >= BUFFER_SIZE) return; buffer->buf[buffer->index++] = c; } void append_huge_buffer(struct buffer *buffer, char c) { if (buffer->index >= HUGE_BUFFER_SIZE) return; buffer->buf[buffer->index++] = c; } void append_string_to_buffer(struct buffer *buffer, char *str) { if (!str || !buffer) return; for (size_t j = 0; j < strlen(str); j++) if (!(j == strlen(str) - 1 && str[j] == '\n')) append_buffer(buffer, str[j]); } void append_string_to_huge_buffer(struct buffer *buffer, char *str) { if (!str || !buffer) return; for (size_t j = 0; j < strlen(str); j++) if (!(j == strlen(str) - 1 && str[j] == '\n')) append_huge_buffer(buffer, str[j]); } size_t buffer_len(struct buffer *buffer) { return strlen(buffer->buf); } void append_word_if_needed(struct lexer *lexer, struct buffer *buffer) { if (buffer_len(buffer) > 0) { append(lexer, new_token_word(buffer->buf)); flush(buffer); } } void free_buffer(struct buffer *buffer) { free(buffer->buf); free(buffer); } void flush(struct buffer *buffer) { buffer->index = 0; for (int i = 0; i < BUFFER_SIZE; i++) buffer->buf[i] = '\0'; }
22.444444
70
0.610011
915aaf3b33d60b093fb514f52b052aed753cf416
4,134
h
C
programmer/stm32/lib/io.h
jburks/vera-module
403b4179fb6ce2e6d454d9fd103823520889856d
[ "MIT" ]
23
2022-03-11T13:37:01.000Z
2022-03-29T08:06:17.000Z
programmer/stm32/lib/io.h
jburks/vera-module
403b4179fb6ce2e6d454d9fd103823520889856d
[ "MIT" ]
2
2022-03-14T10:54:50.000Z
2022-03-28T05:59:25.000Z
programmer/stm32/lib/io.h
fvdhoef/vera-module
403b4179fb6ce2e6d454d9fd103823520889856d
[ "MIT" ]
12
2022-03-11T08:46:43.000Z
2022-03-27T07:24:46.000Z
#pragma once #include "common.h" #define IO_BANK(x) ((x) << 4) #define IO_INVERT (1 << 8) enum iobank { IOBANK_A = 0, IOBANK_B = 1, IOBANK_C = 2, IOBANK_D = 3, IOBANK_F = 5, }; enum iospeed { IOSPEED_LOW = 0, // max 2MHz (125ns rise/fall time) IOSPEED_MEDIUM = 1, // max 10MHz ( 25ns rise/fall time) IOSPEED_FAST = 3 // max 50MHz ( 5ns rise/fall time) }; enum iomode { IOMODE_IN = 0, IOMODE_OUT = 1, IOMODE_ALT = 2, IOMODE_ANALOG = 3 }; enum iopull { IOPULL_NONE = 0, IOPULL_UP = 1, IOPULL_DOWN = 2 }; static inline GPIO_TypeDef *io_get_gpio_regs(uint32_t io) { return (GPIO_TypeDef *)(GPIOA_BASE + (((io >> 4) & 0xF) * 0x400)); } static inline void io_set_mode(uint32_t io, enum iomode mode) { GPIO_TypeDef *gpio = io_get_gpio_regs(io); int shift = (io & 15) * 2; gpio->MODER = (gpio->MODER & ~(3 << shift)) | (mode & 3) << shift; } static inline enum iomode io_get_mode(uint32_t io) { GPIO_TypeDef *gpio = io_get_gpio_regs(io); int shift = (io & 15) * 2; return (enum iomode)((gpio->MODER >> shift) & 3); } static inline void io_set_opendrain(uint32_t io, bool val) { GPIO_TypeDef *gpio = io_get_gpio_regs(io); int shift = (io & 15); gpio->OTYPER = (uint16_t)( (gpio->OTYPER & ~(1 << shift)) | ((val ? 1 : 0) << shift)); } static inline void io_set_outputspeed(uint32_t io, enum iospeed speed) { GPIO_TypeDef *gpio = io_get_gpio_regs(io); int shift = (io & 15) * 2; gpio->OSPEEDR = (gpio->OSPEEDR & ~(3 << shift)) | (speed << shift); } static inline void io_set_pullupdown(uint32_t io, enum iopull val) { GPIO_TypeDef *gpio = io_get_gpio_regs(io); int shift = (io & 15) * 2; gpio->PUPDR = (gpio->PUPDR & ~(3 << shift)) | ((val & 3) << shift); } static inline void io_out(uint32_t io, bool on) { GPIO_TypeDef *gpio = io_get_gpio_regs(io); uint32_t bitmask = (1 << (io & 15)); if (io & IO_INVERT) { on = !on; } if (!on) { bitmask <<= 16; } gpio->BSRR = bitmask; } static inline bool io_in(uint32_t io) { GPIO_TypeDef *gpio = io_get_gpio_regs(io); uint32_t bitmask = (1 << (io & 15)); bool val = (gpio->IDR & bitmask); if (io & IO_INVERT) { return !val; } else { return val; } } static inline void io_set_alternate_function(uint32_t io, int function) { GPIO_TypeDef *gpio = io_get_gpio_regs(io); int afr_idx = (io & 0xF) / 8; int shift = (io & 7) * 4; gpio->AFR[afr_idx] = (gpio->AFR[afr_idx] & ~(0xF << shift)) | ((function & 0xF) << shift); } static inline clock_t io_clock_for_io(uint32_t io) { switch ((io >> 4) & 0xF) { case IOBANK_A: return CLK_GPIOA; case IOBANK_B: return CLK_GPIOB; case IOBANK_C: return CLK_GPIOC; case IOBANK_D: return CLK_GPIOD; case IOBANK_F: return CLK_GPIOF; default: return (clock_t)0; } } #define IO_DEFINE(name, bank, io, invert, mode, initial_value, is_opendrain, speed, pullupdown, function) \ name = IO_BANK(bank) | (io) | (((invert)&1) << 8), enum IO { __IO_ENUM_DUMMY, // Allow for empty iopins.h #include "iopins.h" }; #undef IO_DEFINE static inline void io_config(uint32_t io, enum iomode mode, bool initial_value, bool is_opendrain, enum iospeed speed, enum iopull pullupdown, int function) { io_set_mode(io, mode); io_set_opendrain(io, is_opendrain); io_set_outputspeed(io, speed); io_set_pullupdown(io, pullupdown); io_set_alternate_function(io, function); io_out(io, initial_value); } static inline void io_configure_all_pins() { #define IO_DEFINE(name, bank, io, invert, mode, initial_value, is_opendrain, speed, pullupdown, function) \ clock_enable(io_clock_for_io(IO_BANK(bank))); \ io_config(name, mode, initial_value, is_opendrain, speed, pullupdown, function); #include "iopins.h" #undef IO_DEFINE }
26.33121
158
0.598936
eff544226c29723e109f458b822e6574df244af8
268
h
C
Example/YYBundle/YYAppDelegate.h
baozhoua/YYBundle
33afaa8d1a1f8c283ba58664aa06cf3f63c5e1b2
[ "MIT" ]
null
null
null
Example/YYBundle/YYAppDelegate.h
baozhoua/YYBundle
33afaa8d1a1f8c283ba58664aa06cf3f63c5e1b2
[ "MIT" ]
null
null
null
Example/YYBundle/YYAppDelegate.h
baozhoua/YYBundle
33afaa8d1a1f8c283ba58664aa06cf3f63c5e1b2
[ "MIT" ]
null
null
null
// // YYAppDelegate.h // YYBundle // // Created by baozhou on 06/16/2020. // Copyright (c) 2020 baozhou. All rights reserved. // @import UIKit; @interface YYAppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end
16.75
62
0.712687
0b27f505f4284d7aa636156cc6c9a1f501191a0d
32
h
C
AMOS/Developer/include/pragmas/keymap_pragmas.h
fatman2021/AMOSProfessional
e4b00e561c4af708d1f1006ec833d5cc9aef91df
[ "MIT" ]
2
2020-01-23T17:33:10.000Z
2020-11-01T20:19:42.000Z
AMOS/Developer/include/pragmas/keymap_pragmas.h
fatman2021/AMOSProfessional
e4b00e561c4af708d1f1006ec833d5cc9aef91df
[ "MIT" ]
null
null
null
AMOS/Developer/include/pragmas/keymap_pragmas.h
fatman2021/AMOSProfessional
e4b00e561c4af708d1f1006ec833d5cc9aef91df
[ "MIT" ]
1
2020-08-23T17:06:59.000Z
2020-08-23T17:06:59.000Z
#include <clib/keymap_protos.h>
16
31
0.78125
295eda386e638e5182e586c6970a51984591c91d
268
h
C
CoconutKit-demo/Sources/Demos/View/TableViewCells/HeaderView.h
Akylas/CoconutKit
fe4cd2c001583124723d6e740d06cead3e24985c
[ "MIT" ]
null
null
null
CoconutKit-demo/Sources/Demos/View/TableViewCells/HeaderView.h
Akylas/CoconutKit
fe4cd2c001583124723d6e740d06cead3e24985c
[ "MIT" ]
null
null
null
CoconutKit-demo/Sources/Demos/View/TableViewCells/HeaderView.h
Akylas/CoconutKit
fe4cd2c001583124723d6e740d06cead3e24985c
[ "MIT" ]
null
null
null
// // HeaderView.h // CoconutKit-demo // // Created by Samuel Défago on 2/11/11. // Copyright 2011 Hortis. All rights reserved. // @interface HeaderView : HLSNibView { @private UILabel *m_label; } @property (nonatomic, retain) IBOutlet UILabel *label; @end
15.764706
54
0.690299
711d3ab38169fa06a342e01982cce0396ac8fe18
240
h
C
iOSOpenDev/frameworks/AssistantServices.framework/Headers/AFServiceHelper.h
bzxy/cydia
f8c838cdbd86e49dddf15792e7aa56e2af80548d
[ "MIT" ]
678
2017-11-17T08:33:19.000Z
2022-03-26T10:40:20.000Z
iOSOpenDev/frameworks/AssistantServices.framework/Headers/AFServiceHelper.h
chenfanfang/Cydia
5efce785bfd5f1064b9c0f0e29a9cc05aa24cad0
[ "MIT" ]
22
2019-04-16T05:51:53.000Z
2021-11-08T06:18:45.000Z
iOSOpenDev/frameworks/AssistantServices.framework/Headers/AFServiceHelper.h
chenfanfang/Cydia
5efce785bfd5f1064b9c0f0e29a9cc05aa24cad0
[ "MIT" ]
170
2018-06-10T07:59:20.000Z
2022-03-22T16:19:33.000Z
/** * This header is generated by class-dump-z 0.2b. * * Source: (null) */ @protocol AFServiceHelper <NSObject> - (id)assistantLocalizedStringForKey:(id)key table:(id)table bundle:(id)bundle; - (BOOL)openSensitiveURL:(id)url; @end
16
79
0.7
8685a7293a68ac8c6cbf984fea8bb6d1c24b060b
309
h
C
src/game/aistate.h
illogica/Qtesseract
8575735f053711412579353d6bc95bb9e908104e
[ "Zlib" ]
1
2016-07-02T19:53:36.000Z
2016-07-02T19:53:36.000Z
src/game/aistate.h
illogica/Qtesseract
8575735f053711412579353d6bc95bb9e908104e
[ "Zlib" ]
null
null
null
src/game/aistate.h
illogica/Qtesseract
8575735f053711412579353d6bc95bb9e908104e
[ "Zlib" ]
null
null
null
#ifndef AISTATE_H #define AISTATE_H namespace ai{ class aistate { public: aistate(); ~aistate(); aistate(int m, int t, int r = -1, int v = -1); void reset(); int type, millis, targtype, target, idle; bool override; }; } #endif // AISTATE_H
14.714286
54
0.530744
8e08b214a8c594d40f0e4d33e837541451db043a
244
h
C
nConsvr.h
fstltna/conquest_bbs_source
dde8aa0de681aa445f7cf5173524d85193cf170c
[ "Artistic-2.0" ]
null
null
null
nConsvr.h
fstltna/conquest_bbs_source
dde8aa0de681aa445f7cf5173524d85193cf170c
[ "Artistic-2.0" ]
null
null
null
nConsvr.h
fstltna/conquest_bbs_source
dde8aa0de681aa445f7cf5173524d85193cf170c
[ "Artistic-2.0" ]
null
null
null
/* * server connect node * * $Id$ * * Copyright 1999-2004 Jon Trulson under the ARTISTIC LICENSE. (See LICENSE). */ #ifndef _NCONSVR_H #define _NCONSVR_H void nConsvrInit(char *remotehost, Unsgn16 remoteport); #endif /* _NCONSVR_H */
16.266667
77
0.704918
e50e900531799633fd823c9f40178b41ac95335d
227
c
C
contrib/libf2c/libI77/dolio.c
TrustedBSD/sebsd
fd5de6f587183087cf930779701d5713e8ca64cc
[ "Naumen", "Condor-1.1", "MS-PL" ]
4
2017-04-06T21:39:15.000Z
2019-10-09T17:34:14.000Z
contrib/libf2c/libI77/dolio.c
TrustedBSD/sebsd
fd5de6f587183087cf930779701d5713e8ca64cc
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
contrib/libf2c/libI77/dolio.c
TrustedBSD/sebsd
fd5de6f587183087cf930779701d5713e8ca64cc
[ "Naumen", "Condor-1.1", "MS-PL" ]
1
2020-01-04T06:36:39.000Z
2020-01-04T06:36:39.000Z
#include "config.h" #include "f2c.h" extern int (*f__lioproc) (ftnint *, char *, ftnlen, ftnint); integer do_lio (ftnint * type, ftnint * number, char *ptr, ftnlen len) { return ((*f__lioproc) (number, ptr, len, *type)); }
20.636364
62
0.656388
ab496587463df9e8e1af8e58c8cb95c2445edfc4
227
h
C
timery.h
Bochemix/Measure-RMS-with-ATmega16
08f8b716c2660e67e97779963651c660839dea72
[ "MIT" ]
null
null
null
timery.h
Bochemix/Measure-RMS-with-ATmega16
08f8b716c2660e67e97779963651c660839dea72
[ "MIT" ]
null
null
null
timery.h
Bochemix/Measure-RMS-with-ATmega16
08f8b716c2660e67e97779963651c660839dea72
[ "MIT" ]
null
null
null
/* * timery.h * * Created on: Apr 9, 2015 * Author: juju */ #ifndef TIMERY_H_ #define TIMERY_H_ volatile uint16_t licznik; volatile uint8_t flag; volatile uint8_t czas; void init_timera(); #endif /* TIMERY_H_ */
12.611111
27
0.678414
3902ebff9da3744bb9b185efd16914e7add6dcb5
70
h
C
main/opus_test.h
commarmi76/libopus_for_esp32
97714fe97f9459a42f3bfa57b93fe27ff4bfdf79
[ "Apache-2.0" ]
41
2017-05-11T04:43:13.000Z
2022-03-17T04:18:27.000Z
main/opus_test.h
pavestru/libopus_for_esp32
3aae513fdaa1fbedd72d8676d175b10bd968a565
[ "Apache-2.0" ]
3
2017-07-08T01:20:30.000Z
2020-02-07T16:20:39.000Z
main/opus_test.h
commarmi76/libopus_for_esp32
97714fe97f9459a42f3bfa57b93fe27ff4bfdf79
[ "Apache-2.0" ]
10
2017-05-21T02:52:34.000Z
2020-08-18T04:25:20.000Z
#ifndef OPUS_TEST #define OPUS_TEST void opus_test(); #endif
10
19
0.685714
586eb7ef869db6105c145d2343825bddcead5855
2,368
h
C
main/vcl/inc/vcl/lstbox.h
Grosskopf/openoffice
93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7
[ "Apache-2.0" ]
679
2015-01-06T06:34:58.000Z
2022-03-30T01:06:03.000Z
main/vcl/inc/vcl/lstbox.h
Grosskopf/openoffice
93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7
[ "Apache-2.0" ]
102
2017-11-07T08:51:31.000Z
2022-03-17T12:13:49.000Z
main/vcl/inc/vcl/lstbox.h
Grosskopf/openoffice
93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7
[ "Apache-2.0" ]
331
2015-01-06T11:40:55.000Z
2022-03-14T04:07:51.000Z
/************************************************************** * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 _SV_LSTBOX_H #define _SV_LSTBOX_H #define LISTBOX_APPEND ((sal_uInt16)0xFFFF) #define LISTBOX_ENTRY_NOTFOUND ((sal_uInt16)0xFFFF) #define LISTBOX_ERROR ((sal_uInt16)0xFFFF) #define LISTBOX_USERDRAW_SELECTED ((sal_uInt16)0x0001) // -------------------------------------------------------------------- // the following defines can be used for the SetEntryFlags() // and GetEntryFlags() methods // !! Do not use these flags for user data as they are reserved !! // !! to change the internal behaviour of the ListBox implementation !! // !! for specific entries. !! /** this flag disables a selection of an entry completly. It is not possible to select such entries either from the user interface nor from the ListBox methods. Cursor traveling is handled correctly. This flag can be used to add titles to a ListBox. */ #define LISTBOX_ENTRY_FLAG_DISABLE_SELECTION 0x0000001 /** this flag can be used to make an entry multine capable A normal entry is single line and will therefore be clipped at the right listbox border. Setting this flag enables word breaks for the entry text. */ #define LISTBOX_ENTRY_FLAG_MULTILINE 0x0000002 /** this flags lets the item be drawn disabled (e.g. in grey text) usage only guaranteed with LISTBOX_ENTRY_FLAG_DISABLE_SELECTION */ #define LISTBOX_ENTRY_FLAG_DRAW_DISABLED 0x0000004 #endif // _SV_LSTBOX_H
38.193548
71
0.683699
b56c5d4c6f2e0998448f9d009cb52e8332647043
77
c
C
libpi-fake/fake-dev-barrier.c
aym-v/cs140e-21spr
cb8460f5e4517ed03d47db40f81dd25470e1dab6
[ "MIT" ]
23
2022-01-05T00:06:04.000Z
2022-03-29T06:14:31.000Z
libpi-fake/fake-dev-barrier.c
aym-v/cs140e-21spr
cb8460f5e4517ed03d47db40f81dd25470e1dab6
[ "MIT" ]
null
null
null
libpi-fake/fake-dev-barrier.c
aym-v/cs140e-21spr
cb8460f5e4517ed03d47db40f81dd25470e1dab6
[ "MIT" ]
16
2021-03-31T06:30:25.000Z
2021-12-08T23:06:35.000Z
#include "fake-pi.h" void dev_barrier(void) { trace("dev_barrier\n"); }
12.833333
27
0.649351
44058bd1e284e485be14137bf1c9afa6aa8d42a5
3,839
h
C
Source/SkyEngine/include/Render/ShaderProgram.h
SilangQuan/SkyEngine
2a31932bc9b03507771c216ca97362c32804eff3
[ "MIT" ]
2
2017-11-26T18:57:58.000Z
2018-02-02T08:40:38.000Z
Source/SkyEngine/include/Render/ShaderProgram.h
SilangQuan/SkyEngine
2a31932bc9b03507771c216ca97362c32804eff3
[ "MIT" ]
null
null
null
Source/SkyEngine/include/Render/ShaderProgram.h
SilangQuan/SkyEngine
2a31932bc9b03507771c216ca97362c32804eff3
[ "MIT" ]
1
2019-05-21T03:03:09.000Z
2019-05-21T03:03:09.000Z
#pragma once #include "Base.h" #include "Shader.h" #include "Lighting/Light.h" #include "UniformVariable.h" class RenderContext; class ShaderProgram { GLuint m_programID; Shader* shaders[Shader::NUM_SHADER_TYPES]; //ShaderProgram has ownership of its shaders map<const string, IUniform*> uniformsMap; vector<IUniform*> m_uniforms; //ShaderProgram does not have ownership of its UniformVariables public: ShaderProgram(const std::string& vsFile, const std::string& fsFile); ShaderProgram(ShaderProgram& shaderProgram); virtual ~ShaderProgram(); template<typename T> inline void AddUniform(const string& uniformName, const T& uniformData); template<typename T> inline void SetUniform(const string& uniformName, const T& uniformData); //template<typename T> inline void SetTestUniform(const string& uniformName, const T& uniformData); template<typename T> inline UniformVariable<T>* TryGetUniform(const string& uniformName); void Bind(RenderContext* renderContext); void Use(); GLuint GetProgramID() const; uint32 GetNumUniforms() const; uint32 FindUniform(const string& uniformName) const; bool HasUniform(const string& uniformName) const; IUniform* GetUniform(const string& uniformName); void SetDirectionLightUniform(Light& light); void SetPointLightsUniform(vector<Light>& light); UniformVariable<Matrix4x4>* modelUniform; UniformVariable<Matrix4x4>* viewUniform; UniformVariable<Vector3>* viewPosUniform; UniformVariable<Matrix4x4>* projectionUniform; UniformVariable<Matrix4x4>* viewProjectionUniform; protected: virtual void init(const std::string& vsFile, const std::string& fsFile); Shader* addShader(Shader* shader); void create(); void link(); void validate(); void detectUniforms(); template<typename T> inline void AddUniform(const string& uniformName); void destroy(); private: bool hasViewPosUniform; bool hasViewUniform; bool hasModelUniform; bool hasProjectionUniform; bool hasViewProjectionUniform; }; template<typename T> void ShaderProgram::AddUniform(const string& uniformName) { UniformVariable<T>* uniform = new UniformVariable<T>(uniformName); uniform->attachToShader(this->GetProgramID()); m_uniforms.push_back(uniform); uniformsMap.insert(make_pair(uniformName, uniform)); } template<typename T> void ShaderProgram::AddUniform(const string& uniformName, const T& uniformData) { UniformVariable<T>* uniform = new UniformVariable<T>(uniformName); uniform->attachToShader(this->GetProgramID()); uniform->setData(uniformData); m_uniforms.push_back(uniform); uniformsMap.insert(make_pair(uniformName, uniform)); } template<typename T> void ShaderProgram::SetUniform(const string& uniformName, const T& uniformData) { IUniform* iuniform = this->GetUniform(uniformName); if (iuniform == 0) { string message = " Error:This ShaderProgram does not have an IUniform with name '"; message += uniformName; message += "'."; qDebug()<<message; } UniformVariable<T>* uniform = dynamic_cast<UniformVariable<T>*>(iuniform); if (uniform == 0) { string message = "Invalid type conversion for UniformVariable<T> with name '"; message += uniformName; message += "'."; qDebug() << message; } uniform->setData(uniformData); } template<typename T> UniformVariable<T>* ShaderProgram::TryGetUniform(const string& uniformName) { IUniform* iuniform = this->GetUniform(uniformName); if (iuniform == 0) { string message = "Info:This ShaderProgram does not have an IUniform with name '"; message += uniformName; message += "'."; qDebug() << message; return NULL; } UniformVariable<T>* uniform = dynamic_cast<UniformVariable<T>*>(iuniform); if (uniform == 0) { string message = "Info :Invalid type conversion for UniformVariable<T> with name '"; message += uniformName; message += "'."; qDebug() << message; } return uniform; }
28.649254
100
0.756707
be3af4af03f001e23a0c0a38cbe34d6c141005ad
274
c
C
Challenges/flipping_bits.c
softctrl/hackerrank_codes
b67684a82906ee9176297d786137c07f9df2b195
[ "Apache-2.0" ]
null
null
null
Challenges/flipping_bits.c
softctrl/hackerrank_codes
b67684a82906ee9176297d786137c07f9df2b195
[ "Apache-2.0" ]
null
null
null
Challenges/flipping_bits.c
softctrl/hackerrank_codes
b67684a82906ee9176297d786137c07f9df2b195
[ "Apache-2.0" ]
null
null
null
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> #include <stdint.h> int main() { int count = 0; scanf("%d", &count); uint32_t t = 0; while (count--) { scanf("%u", &t); printf("%u\n", ~t); } return 0; }
14.421053
27
0.5
71b48274aa1e71457a90342307dc4047aff2b81f
1,657
h
C
cpp-primer/ch12/str_blob.h
sylsaint/cpp_learning
158bdf6186a38838ef16f9739e436b17518a56ba
[ "MIT" ]
null
null
null
cpp-primer/ch12/str_blob.h
sylsaint/cpp_learning
158bdf6186a38838ef16f9739e436b17518a56ba
[ "MIT" ]
null
null
null
cpp-primer/ch12/str_blob.h
sylsaint/cpp_learning
158bdf6186a38838ef16f9739e436b17518a56ba
[ "MIT" ]
null
null
null
#include<vector> #include<string> #include<stdexcept> #ifndef STR_BLOB_H #define STR_BLOB_H class StrBlobPtr; class StrBlob { public: friend class StrBlobPtr; StrBlobPtr begin(); StrBlobPtr end(); using size_type = std::vector<std::string>::size_type; StrBlob(); StrBlob(std::initializer_list<std::string> il); size_type size() { return data->size(); }; bool empty() { return data->empty(); }; void push_back(const std::string &s) { data->push_back(s); }; void pop_back(); std::string& front(); std::string& front() const; std::string& back(); std::string& back() const; private: std::shared_ptr<std::vector<std::string>> data; void check(size_type i, const std::string &msg) const; }; StrBlob::StrBlob(): data(std::make_shared<std::vector<std::string>>()) {}; StrBlob::StrBlob(std::initializer_list<std::string> il): data(std::make_shared<std::vector<std::string>>(il)) {}; void StrBlob::check(size_type i, const std::string &msg) const { if(i > data->size()) throw std::out_of_range(msg); } std::string& StrBlob::front() { check(0, "front on empty StrBlob"); return data->front(); } std::string& StrBlob::front() const { check(0, "front on empty StrBlob"); return data->front(); } std::string& StrBlob::back() { check(0, "back on empty StrBlob"); return data->back(); } std::string& StrBlob::back() const { check(0, "back on empty StrBlob"); return data->back(); } void StrBlob::pop_back() { check(0, "pop_back on empty StrBlob"); data->pop_back(); } #endif
23.671429
113
0.614967
ce02b4bc663a99f07242b298541253814d6542fb
466
h
C
autoware.ai/src/autoware/core_perception/vision_darknet_detect/darknet/src/activation_layer.h
Jihwan-Kimm/Autoware_On_Embedded
dc45b70a355fdd26a65007e9c1d9246090f06373
[ "MIT" ]
4
2018-02-05T10:52:14.000Z
2020-02-26T17:51:02.000Z
autoware.ai/src/autoware/core_perception/vision_darknet_detect/darknet/src/activation_layer.h
Jihwan-Kimm/Autoware_On_Embedded
dc45b70a355fdd26a65007e9c1d9246090f06373
[ "MIT" ]
1
2018-06-12T10:15:04.000Z
2018-06-12T10:15:04.000Z
src/activation_layer.h
Aaron5210/yolo_seq_nms
6484176ea998f50df38b83d8d16ffe009ec52929
[ "MIT" ]
3
2021-07-12T06:38:00.000Z
2022-03-21T07:27:17.000Z
#ifndef ACTIVATION_LAYER_H #define ACTIVATION_LAYER_H #include "activations.h" #include "layer.h" #include "network.h" layer make_activation_layer(int batch, int inputs, ACTIVATION activation); void forward_activation_layer(layer l, network net); void backward_activation_layer(layer l, network net); #ifdef GPU void forward_activation_layer_gpu(layer l, network net); void backward_activation_layer_gpu(layer l, network net); #endif #endif
23.3
75
0.776824
7da5db248c1f39456f972e990cb574e254dede88
4,499
c
C
src/vtun.c
kei-g/vtun
25a1d590400df0b517089e9ad276024272871f50
[ "BSD-3-Clause" ]
null
null
null
src/vtun.c
kei-g/vtun
25a1d590400df0b517089e9ad276024272871f50
[ "BSD-3-Clause" ]
null
null
null
src/vtun.c
kei-g/vtun
25a1d590400df0b517089e9ad276024272871f50
[ "BSD-3-Clause" ]
null
null
null
#include "vtun.h" #include "base64.h" #include "codec.h" #include "conf.h" #include "xfer.h" #include <fcntl.h> #include <getopt.h> #include <libgen.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #if defined(__FreeBSD__) #include <sys/event.h> #elif defined(__linux__) #include <sys/epoll.h> #endif #include <unistd.h> static void vtun_info_init(vtun_info_t *info, const vtun_conf_t *conf, struct timespec *w) { info->addr = conf->addr; info->dev = conf->dev; strncpy(info->devname, conf->ifr_name, sizeof(info->devname)); info->ignore = conf->mode == VTUN_MODE_SERVER; info->sock = conf->sock; info->keepalive = conf->mode == VTUN_MODE_CLIENT ? w : NULL; info->xfer_p2l = conf->xfer_p2l; if (conf->mode == VTUN_MODE_CLIENT) vtun_xfer_keepalive(info); info->dec = EVP_CIPHER_CTX_new(); info->enc = EVP_CIPHER_CTX_new(); EVP_CIPHER_CTX_init(info->dec); EVP_CIPHER_CTX_init(info->enc); EVP_DecryptInit_ex(info->dec, EVP_aes_256_gcm(), NULL, conf->key, conf->iv); EVP_EncryptInit_ex(info->enc, EVP_aes_256_gcm(), NULL, conf->key, conf->iv); } static int vtun_main(vtun_info_t *info) { #if defined(__FreeBSD__) int kq, n = 0; if ((kq = kqueue()) < 0) { perror("kqueue"); exit(1); } struct kevent kev[2]; EV_SET(&kev[n++], info->dev, EVFILT_READ, EV_ADD, 0, 0, NULL); EV_SET(&kev[n++], info->sock, EVFILT_READ, EV_ADD, 0, 0, NULL); for (;;) { if ((n = kevent(kq, kev, n, kev, 1, info->keepalive)) < 0) { perror("kevent"); exit(1); } void (*func)(vtun_info_t *info); if (n == 0) func = vtun_xfer_keepalive; else func = kev->ident == info->dev ? vtun_xfer_l2p : vtun_xfer_p2l; (*func)(info); n = 0; } #elif defined(__linux__) int epl, n = 0; if ((epl = epoll_create1(0)) < 0) { perror("epoll_create1"); exit(1); } struct epoll_event eev[2]; eev[n].data.fd = info->dev; eev[n].events = EPOLLIN; if (epoll_ctl(epl, EPOLL_CTL_ADD, info->dev, &eev[n++]) < 0) { perror("epoll_ctl(EPOLL_CTL_ADD)"); exit(1); } eev[n].data.fd = info->sock; eev[n].events = EPOLLIN; if (epoll_ctl(epl, EPOLL_CTL_ADD, info->sock, &eev[n++]) < 0) { perror("epoll_ctl(EPOLL_CTL_ADD)"); exit(1); } int timeout = info->keepalive ? (info->keepalive->tv_sec * 1000 + info->keepalive->tv_nsec / 1000000) : -1; for (;;) { int r; if ((r = epoll_wait(epl, eev, n, timeout)) < 0) { perror("epoll_wait"); exit(1); } void (*func)(vtun_info_t *info); if (r == 0) func = vtun_xfer_keepalive; else func = eev->data.fd == info->dev ? vtun_xfer_l2p : vtun_xfer_p2l; (*func)(info); } #endif return 0; } static int vtun_bn_generate_key(void) { unsigned char iv[12], key[32]; vtun_generate_iv(iv); vtun_generate_key(key); base64_t b = base64_alloc(); char *msg = base64_encode(b, iv, sizeof(iv)); printf("iv: %s\n", msg); free(msg); msg = base64_encode(b, key, sizeof(key)); printf("key: %s\n", msg); free(msg); base64_free(&b); return 0; } int main(int argc, char *argv[]) { char *bn = basename(*argv); if (strcmp(bn, "vtun-keygen") == 0) return vtun_bn_generate_key(); int opt, idx, verbose = 0; struct option opts[] = { { "background", no_argument, NULL, 'b' }, { "conffile", required_argument, NULL, 'c' }, { "pidfile", required_argument, NULL, 'p' }, { "verbose", no_argument, NULL, 'v' }, { "version", no_argument, NULL, 'V' }, }; pid_t pid; char *confpath = NULL, *pidpath = NULL; while ((opt = getopt_long(argc, argv, "Vbc:p:v", opts, &idx)) != -1) switch (opt) { case 'V': printf("%s version 1.0.0\n", bn); exit(EXIT_SUCCESS); break; case 'b': if ((pid = fork()) < 0) { perror("fork"); exit(EXIT_FAILURE); } if (pid != 0) return (0); break; case 'c': confpath = strdup(optarg); break; case 'p': pidpath = strdup(optarg); break; case 'v': verbose++; break; } if (!confpath) confpath = strdup("/usr/local/etc/vtun/vtun.conf"); vtun_conf_t conf; vtun_conf_init(&conf, confpath); free(confpath); if (pidpath) { int fd; fd = open(pidpath, O_CREAT | O_TRUNC | O_WRONLY, 0644); if (fd < 0) { perror("open"); (void)fprintf(stderr, "Unable to create %s\n", pidpath); exit(EXIT_FAILURE); } dprintf(fd, "%d", getpid()); close(fd); free(pidpath); } vtun_info_t *info = malloc(sizeof(*info)); if (!info) { perror("malloc"); exit(1); } info->verbose = verbose; struct timespec w = {.tv_sec = 30, .tv_nsec = 0}; vtun_info_init(info, &conf, &w); return vtun_main(info); }
22.383085
108
0.627695
7ac82c61dffa0c6058036949f2f21a2d412203b2
468
h
C
base/selectable.h
eLong-INF/pyxis
304820eb72bd62d3c211c3423f62dc87b535bb3c
[ "BSD-3-Clause" ]
9
2016-07-21T01:45:17.000Z
2016-08-26T03:20:25.000Z
base/selectable.h
eLong-opensource/pyxis
304820eb72bd62d3c211c3423f62dc87b535bb3c
[ "BSD-3-Clause" ]
null
null
null
base/selectable.h
eLong-opensource/pyxis
304820eb72bd62d3c211c3423f62dc87b535bb3c
[ "BSD-3-Clause" ]
null
null
null
#ifndef PYXIS_BASE_SELECTABLE_H #define PYXIS_BASE_SELECTABLE_H #include <string> #include <boost/shared_ptr.hpp> namespace pyxis { // 可以被selector select的接口。设计为select少量接口,不适合大量的。 // 目前只支持可读事件 // 由于可读的时刻和最终读的时刻不一致,会发生竞争,不适合多个reader。 class Selectable { public: Selectable() { } virtual ~Selectable() { } virtual int Fd() const = 0; virtual bool IsReadable() = 0; }; typedef boost::shared_ptr<Selectable> SelectablePtr; } // end of namespace #endif
16.714286
52
0.732906
4df5bc1fc46f345330de3af3b6031a59f1f0dc46
5,115
h
C
vlc_linux/vlc-3.0.16/modules/codec/webvtt/css_parser.h
Brook1711/biubiu_Qt6
5c4d22a1d1beef63bc6c7738dce6c477c4642803
[ "MIT" ]
null
null
null
vlc_linux/vlc-3.0.16/modules/codec/webvtt/css_parser.h
Brook1711/biubiu_Qt6
5c4d22a1d1beef63bc6c7738dce6c477c4642803
[ "MIT" ]
null
null
null
vlc_linux/vlc-3.0.16/modules/codec/webvtt/css_parser.h
Brook1711/biubiu_Qt6
5c4d22a1d1beef63bc6c7738dce6c477c4642803
[ "MIT" ]
null
null
null
/***************************************************************************** * css_parser.h : CSS parser interface ***************************************************************************** * Copyright (C) 2017 VideoLabs, VLC authors and VideoLAN * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ #ifndef CSS_PARSER_H #define CSS_PARSER_H //#define YYDEBUG 1 //#define CSS_PARSER_DEBUG typedef struct vlc_css_parser_t vlc_css_parser_t; typedef struct vlc_css_selector_t vlc_css_selector_t; typedef struct vlc_css_declaration_t vlc_css_declaration_t; typedef struct vlc_css_rule_t vlc_css_rule_t; typedef struct vlc_css_expr_t vlc_css_expr_t; typedef struct { float val; char *psz; vlc_css_expr_t *function; enum { TYPE_NONE = 0, TYPE_EMS, TYPE_EXS, TYPE_PIXELS, TYPE_POINTS, TYPE_MILLIMETERS, TYPE_PERCENT, TYPE_MILLISECONDS, TYPE_HERTZ, TYPE_DEGREES, TYPE_DIMENSION, TYPE_STRING = 0x20, TYPE_FUNCTION, TYPE_IDENTIFIER, TYPE_HEXCOLOR, TYPE_UNICODERANGE, TYPE_URI, } type; } vlc_css_term_t; struct vlc_css_expr_t { struct { char op; vlc_css_term_t term; } *seq; size_t i_alloc; size_t i_count; }; struct vlc_css_declaration_t { char *psz_property; vlc_css_expr_t *expr; vlc_css_declaration_t *p_next; }; enum vlc_css_match_e { MATCH_EQUALS, MATCH_INCLUDES, MATCH_DASHMATCH, MATCH_BEGINSWITH, MATCH_ENDSWITH, MATCH_CONTAINS, }; enum vlc_css_relation_e { RELATION_SELF = 0, RELATION_DESCENDENT = ' ', RELATION_DIRECTADJACENT = '+', RELATION_INDIRECTADJACENT = '~', RELATION_CHILD = '>', }; struct vlc_css_selector_t { char *psz_name; enum { SELECTOR_SIMPLE = 0, SELECTOR_PSEUDOCLASS, SELECTOR_PSEUDOELEMENT, /* SELECTOR_PSEUDONTHCHILD, SELECTOR_PSEUDONTHTYPE, SELECTOR_PSEUDONTHLASTCHILD, SELECTOR_PSEUDONTHLASTTYPE,*/ SPECIFIER_ID, SPECIFIER_CLASS, SPECIFIER_ATTRIB, } type; struct { vlc_css_selector_t *p_first; vlc_css_selector_t **pp_append; } specifiers; enum vlc_css_match_e match; vlc_css_selector_t *p_matchsel; enum vlc_css_relation_e combinator; vlc_css_selector_t *p_next; }; struct vlc_css_rule_t { bool b_valid; vlc_css_selector_t *p_selectors; vlc_css_declaration_t *p_declarations; vlc_css_rule_t *p_next; }; struct vlc_css_parser_t { struct { vlc_css_rule_t *p_first; vlc_css_rule_t **pp_append; } rules; }; #define CHAIN_APPEND_DECL(n, t) void n( t *p_a, t *p_b ) void vlc_css_term_Clean( vlc_css_term_t a ); bool vlc_css_expression_AddTerm( vlc_css_expr_t *p_expr, char op, vlc_css_term_t a ); void vlc_css_expression_Delete( vlc_css_expr_t *p_expr ); vlc_css_expr_t * vlc_css_expression_New( vlc_css_term_t term ); CHAIN_APPEND_DECL(vlc_css_declarations_Append, vlc_css_declaration_t); void vlc_css_declarations_Delete( vlc_css_declaration_t *p_decl ); vlc_css_declaration_t * vlc_css_declaration_New( const char *psz ); CHAIN_APPEND_DECL(vlc_css_selector_Append, vlc_css_selector_t); void vlc_css_selector_AddSpecifier( vlc_css_selector_t *p_sel, vlc_css_selector_t *p_spec ); void vlc_css_selectors_Delete( vlc_css_selector_t *p_sel ); vlc_css_selector_t * vlc_css_selector_New( int type, const char *psz ); void vlc_css_rules_Delete( vlc_css_rule_t *p_rule ); vlc_css_rule_t * vlc_css_rule_New( void ); void vlc_css_parser_AddRule( vlc_css_parser_t *p_parser, vlc_css_rule_t *p_rule ); void vlc_css_parser_Debug( const vlc_css_parser_t *p_parser ); void vlc_css_parser_Clean( vlc_css_parser_t *p_parser ); void vlc_css_parser_Init( vlc_css_parser_t *p_parser ); bool vlc_css_parser_ParseBytes( vlc_css_parser_t *p_parser, const uint8_t *, size_t ); bool vlc_css_parser_ParseString( vlc_css_parser_t *p_parser, const char * ); void vlc_css_unescape( char *psz ); char * vlc_css_unquoted( const char *psz ); char * vlc_css_unescaped( const char *psz ); char * vlc_css_unquotedunescaped( const char *psz ); # ifdef CSS_PARSER_DEBUG void css_selector_Debug( const vlc_css_selector_t *p_sel ); void css_rule_Debug( const vlc_css_rule_t *p_rule ); # endif #endif
27.95082
92
0.699902
06489c0bb0015347ad83a7708032ba310930fd8b
834
h
C
Utils/objc-utils/Common/ThemeManager.h
moxian1993/Utils
d4960d228243e09446d6627e763ce56dd74f06c6
[ "MIT" ]
null
null
null
Utils/objc-utils/Common/ThemeManager.h
moxian1993/Utils
d4960d228243e09446d6627e763ce56dd74f06c6
[ "MIT" ]
null
null
null
Utils/objc-utils/Common/ThemeManager.h
moxian1993/Utils
d4960d228243e09446d6627e763ce56dd74f06c6
[ "MIT" ]
null
null
null
// // ThemeManager.h // Utils // // Created by Xian Mo on 2020/8/29. // Copyright © 2020 Mo. All rights reserved. // #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #import "ZWSingleton.h" #define _ThemeManager ([ThemeManager sharedInstance]) #define LANGUAGE(__KEY__) ([_ThemeManager localizedStringWithKey:(__KEY__)]) #define IMAGE(__NAME__) ([_ThemeManager imageName: (__NAME__)]) NS_ASSUME_NONNULL_BEGIN @interface ThemeManager : NSObject INTERFACE_SINGLETON(ThemeManager) @property (nonatomic, strong) UIColor *themeColor; - (NSString *)localizedStringWithKey:(NSString *)key; - (UIImage *)imageName:(NSString *)imageName; /// 检测多语言文件是否缺少LanguageKey(DEBUG环境) /// @param tablePath 当前.string 文件路径 + (void)checkMissingLanguageKeyWithCurrentTablePath:(NSString *)tablePath; @end NS_ASSUME_NONNULL_END
22.540541
78
0.758993
ff3c1ef26b16ad5b6800e0725d308ef9b63d6e7c
2,299
h
C
dev/Code/Tools/RC/ResourceCompilerImage/UIBumpmapPanel.h
jeikabu/lumberyard
07228c605ce16cbf5aaa209a94a3cb9d6c1a4115
[ "AML" ]
8
2019-10-07T16:33:47.000Z
2020-12-07T03:59:58.000Z
dev/Code/Tools/RC/ResourceCompilerImage/UIBumpmapPanel.h
jeikabu/lumberyard
07228c605ce16cbf5aaa209a94a3cb9d6c1a4115
[ "AML" ]
null
null
null
dev/Code/Tools/RC/ResourceCompilerImage/UIBumpmapPanel.h
jeikabu/lumberyard
07228c605ce16cbf5aaa209a94a3cb9d6c1a4115
[ "AML" ]
5
2020-08-27T20:44:18.000Z
2021-08-21T22:54:11.000Z
/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ // Original file Copyright Crytek GMBH or its affiliates, used under license. #ifndef CRYINCLUDE_TOOLS_RC_RESOURCECOMPILERIMAGE_UIBUMPMAPPANEL_H #define CRYINCLUDE_TOOLS_RC_RESOURCECOMPILERIMAGE_UIBUMPMAPPANEL_H #pragma once #include <platform.h> #include "SliderView.h" #include "FloatEditView.h" #include "CheckBoxView.h" #include "ImageProperties.h" #include <set> class CBumpProperties; class CUIBumpmapPanel { public: // constructor CUIBumpmapPanel(); void InitDialog(QWidget* hWndParent, const bool bShowBumpmapFileName); void GetDataFromDialog(CBumpProperties& rBumpProp); void SetDataToDialog(const CBumpProperties& rBumpProp, const bool bInitalUpdate); void ChooseAddBump(QWidget* hParentWnd); class CImageUserDialog* m_pDlg; TinyDocument<float> m_bumpStrengthValue; TinyDocument<float> m_bumpBlurValue; TinyDocument<bool> m_bumpInvertValue; private: // --------------------------------------------------------------------------------------- QWidget* m_hTab_Normalmapgen; // window handle SliderView m_bumpStrengthSlider; FloatEditView m_bumpStrengthEdit; SliderView m_bumpBlurSlider; FloatEditView m_bumpBlurEdit; CheckBoxView m_bumpInvertCheckBox; int m_GenIndexToControl[eWindowFunction_Num]; int m_GenControlToIndex[eWindowFunction_Num]; void UpdateBumpStrength(const CBumpProperties& rBumpProp); void UpdateBumpBlur(const CBumpProperties& rBumpProp); void UpdateBumpInvert(const CBumpProperties& rBumpProp); std::set<int> reflectIDs; }; #endif // CRYINCLUDE_TOOLS_RC_RESOURCECOMPILERIMAGE_UIBUMPMAPPANEL_H
32.842857
99
0.703349
9e51bd8f55dfc743a1590ff66fa02d8f9457ba14
8,639
c
C
examples/rkmedia_vi_double_cameras_test.c
rockchip-linux/rkmedia
992663e9069e8426f5a71f4045666786b3bd4bcf
[ "BSD-3-Clause" ]
23
2020-02-29T10:47:22.000Z
2022-01-20T01:52:21.000Z
examples/rkmedia_vi_double_cameras_test.c
rockchip-linux/rkmedia
992663e9069e8426f5a71f4045666786b3bd4bcf
[ "BSD-3-Clause" ]
13
2020-05-12T15:11:04.000Z
2021-12-02T05:48:39.000Z
examples/rkmedia_vi_double_cameras_test.c
rockchip-linux/rkmedia
992663e9069e8426f5a71f4045666786b3bd4bcf
[ "BSD-3-Clause" ]
19
2020-01-12T04:07:33.000Z
2022-02-18T08:43:19.000Z
// Copyright 2020 Fuzhou Rockchip Electronics Co., Ltd. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <assert.h> #include <fcntl.h> #include <signal.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <unistd.h> #include "common/sample_double_cam_isp.h" #include "rkmedia_api.h" #include <rga/RgaApi.h> static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static MEDIA_BUFFER ir_mb; static MEDIA_BUFFER rgb_mb; static int video_width = 1920; static int video_height = 1080; static int disp_width = 720; static int disp_height = 1280; static int scale_width = 720; static int scale_height = 640; static bool quit = false; static void sigterm_handler(int sig) { fprintf(stderr, "signal %d\n", sig); quit = true; } static void scale_buffer(void *src_p, int src_w, int src_h, int src_fmt, void *dst_p, int dst_w, int dst_h, int dst_fmt, int rotation) { rga_info_t src, dst; memset(&src, 0, sizeof(rga_info_t)); src.fd = -1; src.virAddr = src_p; src.mmuFlag = 1; src.rotation = rotation; rga_set_rect(&src.rect, 0, 0, src_w, src_h, src_w, src_h, src_fmt); memset(&dst, 0, sizeof(rga_info_t)); dst.fd = -1; dst.virAddr = dst_p; dst.mmuFlag = 1; rga_set_rect(&dst.rect, 0, 0, dst_w, dst_h, dst_w, dst_h, dst_fmt); if (c_RkRgaBlit(&src, &dst, NULL)) printf("%s: rga fail\n", __func__); } static void compose_buffer(void *src_p, int src_w, int src_h, int src_fmt, void *dst_p, int dst_w, int dst_h, int dst_fmt, int x, int y, int w, int h) { rga_info_t src, dst; memset(&src, 0, sizeof(rga_info_t)); src.fd = -1; src.virAddr = src_p; src.mmuFlag = 1; rga_set_rect(&src.rect, 0, 0, src_w, src_h, src_w, src_h, src_fmt); memset(&dst, 0, sizeof(rga_info_t)); dst.fd = -1; dst.virAddr = dst_p; dst.mmuFlag = 1; rga_set_rect(&dst.rect, x, y, w, h, dst_w, dst_h, dst_fmt); if (c_RkRgaBlit(&src, &dst, NULL)) printf("%s: rga fail\n", __func__); } static void *GetRgbBuffer(void *arg) { MEDIA_BUFFER mb = NULL; (void)arg; while (!quit) { mb = RK_MPI_SYS_GetMediaBuffer(RK_ID_RGA, 0, -1); if (!mb) { printf("RK_MPI_SYS_GetMediaBuffer get null buffer!\n"); break; } scale_buffer(RK_MPI_MB_GetPtr(mb), disp_width, disp_height, RK_FORMAT_YCbCr_420_SP, RK_MPI_MB_GetPtr(rgb_mb), scale_width, scale_height, RK_FORMAT_YCbCr_420_SP, 0); compose_buffer(RK_MPI_MB_GetPtr(rgb_mb), scale_width, scale_height, RK_FORMAT_YCbCr_420_SP, RK_MPI_MB_GetPtr(mb), disp_width, disp_height, RK_FORMAT_YCbCr_420_SP, 0, 0, scale_width, scale_height); pthread_mutex_lock(&mutex); compose_buffer(RK_MPI_MB_GetPtr(ir_mb), scale_width, scale_height, RK_FORMAT_YCbCr_420_SP, RK_MPI_MB_GetPtr(mb), disp_width, disp_height, RK_FORMAT_YCbCr_420_SP, 0, scale_height, scale_width, scale_height); pthread_mutex_unlock(&mutex); RK_MPI_SYS_SendMediaBuffer(RK_ID_VO, 0, mb); RK_MPI_MB_ReleaseBuffer(mb); } return NULL; } static void *GetIrBuffer(void *arg) { MEDIA_BUFFER mb = NULL; (void)arg; while (!quit) { mb = RK_MPI_SYS_GetMediaBuffer(RK_ID_VI, 1, -1); if (!mb) { printf("RK_MPI_SYS_GetMediaBuffer get null buffer!\n"); break; } pthread_mutex_lock(&mutex); scale_buffer(RK_MPI_MB_GetPtr(mb), video_width, video_height, RK_FORMAT_YCbCr_420_SP, RK_MPI_MB_GetPtr(ir_mb), scale_width, scale_height, RK_FORMAT_YCbCr_420_SP, HAL_TRANSFORM_ROT_270); pthread_mutex_unlock(&mutex); RK_MPI_MB_ReleaseBuffer(mb); } return NULL; } int main(int argc, char *argv[]) { int ret = 0; pthread_t trgb, tir; MB_IMAGE_INFO_S disp_info = {scale_width, scale_height, scale_width, scale_height, IMAGE_TYPE_NV12}; char *iq_dir = NULL; if (argc >= 2) { iq_dir = argv[1]; if (access(iq_dir, R_OK)) { printf("Usage: %s [/etc/iqfiles]\n", argv[0]); exit(0); } } rk_aiq_sys_ctx_t *ctx0 = aiq_double_cam_init(0, RK_AIQ_WORKING_MODE_NORMAL, iq_dir); if (!ctx0) return -1; rk_aiq_sys_ctx_t *ctx1 = aiq_double_cam_init(1, RK_AIQ_WORKING_MODE_NORMAL, iq_dir); if (!ctx1) return -1; rgb_mb = RK_MPI_MB_CreateImageBuffer(&disp_info, RK_TRUE, 0); if (!rgb_mb) { printf("ERROR: no space left!\n"); return -1; } ir_mb = RK_MPI_MB_CreateImageBuffer(&disp_info, RK_TRUE, 0); if (!ir_mb) { printf("ERROR: no space left!\n"); return -1; } RK_MPI_SYS_Init(); VI_CHN_ATTR_S vi_chn_attr; memset(&vi_chn_attr, 0, sizeof(vi_chn_attr)); vi_chn_attr.pcVideoNode = "rkispp_scale1"; vi_chn_attr.u32BufCnt = 3; vi_chn_attr.u32Width = video_width; vi_chn_attr.u32Height = video_height; vi_chn_attr.enPixFmt = IMAGE_TYPE_NV12; vi_chn_attr.enWorkMode = VI_WORK_MODE_NORMAL; ret = RK_MPI_VI_SetChnAttr(0, 0, &vi_chn_attr); ret |= RK_MPI_VI_EnableChn(0, 0); if (ret) { printf("Create vi[0] failed! ret=%d\n", ret); return -1; } memset(&vi_chn_attr, 0, sizeof(vi_chn_attr)); vi_chn_attr.pcVideoNode = "rkispp_scale1"; vi_chn_attr.u32BufCnt = 3; vi_chn_attr.u32Width = video_width; vi_chn_attr.u32Height = video_height; vi_chn_attr.enPixFmt = IMAGE_TYPE_NV12; vi_chn_attr.enWorkMode = VI_WORK_MODE_NORMAL; ret = RK_MPI_VI_SetChnAttr(1, 1, &vi_chn_attr); ret |= RK_MPI_VI_EnableChn(1, 1); if (ret) { printf("Create vi[1] failed! ret=%d\n", ret); return -1; } RGA_ATTR_S stRgaAttr; memset(&stRgaAttr, 0, sizeof(stRgaAttr)); stRgaAttr.bEnBufPool = RK_TRUE; stRgaAttr.u16BufPoolCnt = 12; stRgaAttr.u16Rotaion = 90; stRgaAttr.stImgIn.u32X = 0; stRgaAttr.stImgIn.u32Y = 0; stRgaAttr.stImgIn.imgType = IMAGE_TYPE_NV12; stRgaAttr.stImgIn.u32Width = video_width; stRgaAttr.stImgIn.u32Height = video_height; stRgaAttr.stImgIn.u32HorStride = video_width; stRgaAttr.stImgIn.u32VirStride = video_height; stRgaAttr.stImgOut.u32X = 0; stRgaAttr.stImgOut.u32Y = 0; stRgaAttr.stImgOut.imgType = IMAGE_TYPE_NV12; stRgaAttr.stImgOut.u32Width = disp_width; stRgaAttr.stImgOut.u32Height = disp_height; stRgaAttr.stImgOut.u32HorStride = disp_width; stRgaAttr.stImgOut.u32VirStride = disp_height; ret = RK_MPI_RGA_CreateChn(0, &stRgaAttr); if (ret) { printf("Create rga[0] falied! ret=%d\n", ret); return -1; } VO_CHN_ATTR_S stVoAttr = {0}; stVoAttr.emPlaneType = VO_PLANE_OVERLAY; stVoAttr.enImgType = IMAGE_TYPE_NV12; stVoAttr.u16Zpos = 0; stVoAttr.stImgRect.s32X = 0; stVoAttr.stImgRect.s32Y = 0; stVoAttr.stImgRect.u32Width = disp_width; stVoAttr.stImgRect.u32Height = disp_height; stVoAttr.stDispRect.s32X = 0; stVoAttr.stDispRect.s32Y = 0; stVoAttr.stDispRect.u32Width = disp_width; stVoAttr.stDispRect.u32Height = disp_height; ret = RK_MPI_VO_CreateChn(0, &stVoAttr); if (ret) { printf("Create vo[0] failed! ret=%d\n", ret); return -1; } MPP_CHN_S stSrcChn = {0}; MPP_CHN_S stDestChn = {0}; stSrcChn.enModId = RK_ID_VI; stSrcChn.s32ChnId = 0; stDestChn.enModId = RK_ID_RGA; stDestChn.s32ChnId = 0; ret = RK_MPI_SYS_Bind(&stSrcChn, &stDestChn); if (ret) { printf("Bind vi[0] to rga[0] failed! ret=%d\n", ret); return -1; } if (pthread_create(&trgb, NULL, GetRgbBuffer, NULL)) { printf("create GetRgbBuffer thread failed!\n"); return -1; } if (pthread_create(&tir, NULL, GetIrBuffer, NULL)) { printf("create GetIrBuffer thread failed!\n"); return -1; } ret = RK_MPI_VI_StartStream(0, 1); if (ret) { printf("Start Vi[1] failed! ret=%d\n", ret); return -1; } printf("%s initial finish\n", __func__); signal(SIGINT, sigterm_handler); while (!quit) { usleep(100); } printf("%s exit!\n", __func__); pthread_join(trgb, NULL); pthread_join(tir, NULL); stSrcChn.enModId = RK_ID_VI; stSrcChn.s32ChnId = 0; stDestChn.enModId = RK_ID_RGA; stDestChn.s32ChnId = 0; ret = RK_MPI_SYS_UnBind(&stSrcChn, &stDestChn); if (ret) { printf("UnBind vi[0] to rga[0] failed! ret=%d\n", ret); return -1; } RK_MPI_VO_DestroyChn(0); RK_MPI_VI_DisableChn(0, 0); RK_MPI_VI_DisableChn(1, 1); RK_MPI_RGA_DestroyChn(0); RK_MPI_RGA_DestroyChn(1); RK_MPI_MB_ReleaseBuffer(rgb_mb); RK_MPI_MB_ReleaseBuffer(ir_mb); aiq_double_cam_exit(ctx0); aiq_double_cam_exit(ctx1); return 0; }
29.484642
79
0.676583
c7504e4772fd596b96316c44c260b07b8b721bad
7,206
h
C
src/test/TestSimpleNumberExpressionTokeniser.h
markbush/comal-tools
d8b6affb0f31e40f6f85c39be48844ceb8aba863
[ "MIT" ]
null
null
null
src/test/TestSimpleNumberExpressionTokeniser.h
markbush/comal-tools
d8b6affb0f31e40f6f85c39be48844ceb8aba863
[ "MIT" ]
null
null
null
src/test/TestSimpleNumberExpressionTokeniser.h
markbush/comal-tools
d8b6affb0f31e40f6f85c39be48844ceb8aba863
[ "MIT" ]
null
null
null
#include <cxxtest/TestSuite.h> #include <vector> #include <string> #include "../parsers/ExprTokeniser.h" using namespace std::string_literals; class SimpleNumberExprTokeniserTestSuite : public CxxTest::TestSuite { public: void testAdd(void) { // a + b => a b + std::string value1 {"123"s}; std::string value2 {"23.45"s}; std::string op {"+"s}; std::string expr {value1+op+value2}; ExprTokeniser tokeniser {expr}; std::vector<std::string> tokens = tokeniser.getTokens(); TS_ASSERT_EQUALS(tokens.size(), 3); TS_ASSERT_EQUALS(tokens[0], "N"+value1); TS_ASSERT_EQUALS(tokens[1], "N"+value2); TS_ASSERT_EQUALS(tokens[2], "O"+op); } void testNegAdd(void) { // - a + b => a neg b + std::string value1 {"12"s}; std::string value2 {"34"s}; std::string op {"+"s}; std::string neg {"-"s}; std::string expr {neg+value1+op+value2}; ExprTokeniser tokeniser {expr}; std::vector<std::string> tokens = tokeniser.getTokens(); TS_ASSERT_EQUALS(tokens.size(), 4); TS_ASSERT_EQUALS(tokens[0], "N"+value1); TS_ASSERT_EQUALS(tokens[1], "U"+neg); TS_ASSERT_EQUALS(tokens[2], "N"+value2); TS_ASSERT_EQUALS(tokens[3], "O"+op); } void testAddNeg(void) { // a + - b => a b neg + std::string value1 {"12"s}; std::string value2 {"34"s}; std::string op {"+"s}; std::string neg {"-"s}; std::string expr {value1+op+neg+value2}; ExprTokeniser tokeniser {expr}; std::vector<std::string> tokens = tokeniser.getTokens(); TS_ASSERT_EQUALS(tokens.size(), 4); TS_ASSERT_EQUALS(tokens[0], "N"+value1); TS_ASSERT_EQUALS(tokens[1], "N"+value2); TS_ASSERT_EQUALS(tokens[2], "U"+neg); TS_ASSERT_EQUALS(tokens[3], "O"+op); } void testMultiply(void) { // a * b => a b * std::string value1 {"123e13"s}; std::string value2 {".45"s}; std::string op {"*"s}; std::string expr {value1+op+value2}; ExprTokeniser tokeniser {expr}; std::vector<std::string> tokens = tokeniser.getTokens(); TS_ASSERT_EQUALS(tokens.size(), 3); TS_ASSERT_EQUALS(tokens[0], "N"+value1); TS_ASSERT_EQUALS(tokens[1], "N"+value2); TS_ASSERT_EQUALS(tokens[2], "O"+op); } void testSubtract(void) { // a - b => a b - std::string value1 {"0"s}; std::string value2 {"23"s}; std::string op {"-"s}; std::string expr {value1+op+value2}; ExprTokeniser tokeniser {expr}; std::vector<std::string> tokens = tokeniser.getTokens(); TS_ASSERT_EQUALS(tokens.size(), 3); TS_ASSERT_EQUALS(tokens[0], "N"+value1); TS_ASSERT_EQUALS(tokens[1], "N"+value2); TS_ASSERT_EQUALS(tokens[2], "O"+op); } void testDivide(void) { // a / b => a b / std::string value1 {"123"s}; std::string value2 {"2"s}; std::string op {"/"s}; std::string expr {value1+op+value2}; ExprTokeniser tokeniser {expr}; std::vector<std::string> tokens = tokeniser.getTokens(); TS_ASSERT_EQUALS(tokens.size(), 3); TS_ASSERT_EQUALS(tokens[0], "N"+value1); TS_ASSERT_EQUALS(tokens[1], "N"+value2); TS_ASSERT_EQUALS(tokens[2], "O"+op); } void testPower(void) { // a ^ b => a b ^ std::string value1 {"4"s}; std::string value2 {"3"s}; std::string op {"^"s}; std::string expr {value1+op+value2}; ExprTokeniser tokeniser {expr}; std::vector<std::string> tokens = tokeniser.getTokens(); TS_ASSERT_EQUALS(tokens.size(), 3); TS_ASSERT_EQUALS(tokens[0], "N"+value1); TS_ASSERT_EQUALS(tokens[1], "N"+value2); TS_ASSERT_EQUALS(tokens[2], "O"+op); } void testMod(void) { // a ^ b => a b ^ std::string value1 {"4"s}; std::string value2 {"3"s}; std::string op {"mod"s}; std::string expr {value1+op+value2}; ExprTokeniser tokeniser {expr}; std::vector<std::string> tokens = tokeniser.getTokens(); TS_ASSERT_EQUALS(tokens.size(), 3); TS_ASSERT_EQUALS(tokens[0], "N"+value1); TS_ASSERT_EQUALS(tokens[1], "N"+value2); TS_ASSERT_EQUALS(tokens[2], "O"+op); } void testDiv(void) { // a ^ b => a b ^ std::string value1 {"4"s}; std::string value2 {"3"s}; std::string op {"div"s}; std::string expr {value1+op+value2}; ExprTokeniser tokeniser {expr}; std::vector<std::string> tokens = tokeniser.getTokens(); TS_ASSERT_EQUALS(tokens.size(), 3); TS_ASSERT_EQUALS(tokens[0], "N"+value1); TS_ASSERT_EQUALS(tokens[1], "N"+value2); TS_ASSERT_EQUALS(tokens[2], "O"+op); } void testEq(void) { // a = b => a b = std::string value1 {"4"s}; std::string value2 {"3"s}; std::string op {"="s}; std::string expr {value1+op+value2}; ExprTokeniser tokeniser {expr}; std::vector<std::string> tokens = tokeniser.getTokens(); TS_ASSERT_EQUALS(tokens.size(), 3); TS_ASSERT_EQUALS(tokens[0], "N"+value1); TS_ASSERT_EQUALS(tokens[1], "N"+value2); TS_ASSERT_EQUALS(tokens[2], "O"+op); } void testNotEq(void) { // a <> b => a b <> std::string value1 {"4"s}; std::string value2 {"3"s}; std::string op {"<>"s}; std::string expr {value1+op+value2}; ExprTokeniser tokeniser {expr}; std::vector<std::string> tokens = tokeniser.getTokens(); TS_ASSERT_EQUALS(tokens.size(), 3); TS_ASSERT_EQUALS(tokens[0], "N"+value1); TS_ASSERT_EQUALS(tokens[1], "N"+value2); TS_ASSERT_EQUALS(tokens[2], "O"+op); } void testLess(void) { // a < b => a b < std::string value1 {"4"s}; std::string value2 {"3"s}; std::string op {"<"s}; std::string expr {value1+op+value2}; ExprTokeniser tokeniser {expr}; std::vector<std::string> tokens = tokeniser.getTokens(); TS_ASSERT_EQUALS(tokens.size(), 3); TS_ASSERT_EQUALS(tokens[0], "N"+value1); TS_ASSERT_EQUALS(tokens[1], "N"+value2); TS_ASSERT_EQUALS(tokens[2], "O"+op); } void testGreater(void) { // a > b => a b > std::string value1 {"4"s}; std::string value2 {"3"s}; std::string op {">"s}; std::string expr {value1+op+value2}; ExprTokeniser tokeniser {expr}; std::vector<std::string> tokens = tokeniser.getTokens(); TS_ASSERT_EQUALS(tokens.size(), 3); TS_ASSERT_EQUALS(tokens[0], "N"+value1); TS_ASSERT_EQUALS(tokens[1], "N"+value2); TS_ASSERT_EQUALS(tokens[2], "O"+op); } void testLessEq(void) { // a <= b => a b <= std::string value1 {"4"s}; std::string value2 {"3"s}; std::string op {"<="s}; std::string expr {value1+op+value2}; ExprTokeniser tokeniser {expr}; std::vector<std::string> tokens = tokeniser.getTokens(); TS_ASSERT_EQUALS(tokens.size(), 3); TS_ASSERT_EQUALS(tokens[0], "N"+value1); TS_ASSERT_EQUALS(tokens[1], "N"+value2); TS_ASSERT_EQUALS(tokens[2], "O"+op); } void testGreaterEq(void) { // a >= b => a b >= std::string value1 {"4"s}; std::string value2 {"3"s}; std::string op {">="s}; std::string expr {value1+op+value2}; ExprTokeniser tokeniser {expr}; std::vector<std::string> tokens = tokeniser.getTokens(); TS_ASSERT_EQUALS(tokens.size(), 3); TS_ASSERT_EQUALS(tokens[0], "N"+value1); TS_ASSERT_EQUALS(tokens[1], "N"+value2); TS_ASSERT_EQUALS(tokens[2], "O"+op); } };
28.258824
70
0.613933
0ff5954b72349ed7ea843bcfb1f2ec67efa6a000
10,844
c
C
roxterm/src/optsfile.c
Yisus7u7/extra-builds
a64a132dc91f0cfeddf50506d07bbec6964427a5
[ "MIT" ]
null
null
null
roxterm/src/optsfile.c
Yisus7u7/extra-builds
a64a132dc91f0cfeddf50506d07bbec6964427a5
[ "MIT" ]
null
null
null
roxterm/src/optsfile.c
Yisus7u7/extra-builds
a64a132dc91f0cfeddf50506d07bbec6964427a5
[ "MIT" ]
null
null
null
/* roxterm - VTE/GTK terminal emulator with tabs Copyright (C) 2004-2015 Tony Houghton <h@realh.co.uk> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "defns.h" #include <errno.h> #include <stdarg.h> #include <string.h> #include "dlg.h" #include "globalopts.h" #include "optsfile.h" static char **options_pathv = NULL; /* Append 2 NULL-terminated arrays of strings, avoiding duplicates; the strings * themselves are copied */ static char **options_file_join_strvs(const char * const *v1, const char * const *v2) { size_t n, v_end; char **result; for (n = 0; v1 && v1[n]; ++n); v_end = n; for (n = 0; v2 && v2[n]; ++n); if (n == 0 && v_end == 0) return NULL; result = g_new(char *, v_end + n + 1); for (n = 0; n < v_end; ++n) { result[n] = g_strdup(v1[n]); } for (n = 0; v2 && v2[n]; ++n) { size_t m; for (m = 0; m < v_end; ++m) { if (!strcmp(v2[n], result[m])) { break; } } if (m == v_end) { result[v_end++] = g_strdup(v2[n]); } } result[v_end] = NULL; /* Could realloc array in case it's larger than necessary due to * duplicates, but I don't think it's worth the hassle */ return result; } #if 0 static void options_file_debug_options_pathv(void) { int n; if (!options_pathv) { g_debug("options_pathv NULL"); return; } g_debug("options_pathv contains:"); for (n = 0; options_pathv[n]; ++n) { g_debug(options_pathv[n]); } } #endif static void options_file_append_leaf_to_pathv(char **pathv, const char *leaf) { int n; g_return_if_fail(pathv); for (n = 0; pathv[n]; ++n) { char *old_path = pathv[n]; pathv[n] = g_build_filename(old_path, leaf, NULL); g_free(old_path); } } /* Frees s */ static void options_file_prepend_str_to_v(char *s) { char **old_pathv; const char * const str_v[2] = { s, NULL }; old_pathv = options_pathv; options_pathv = options_file_join_strvs(str_v, (const char * const *) old_pathv); g_free(s); g_strfreev(old_pathv); } static void options_file_init_paths(void) { if (options_pathv) return; /* Add in reverse order of priority because we prepend */ /* XDG system conf dirs */ options_pathv = options_file_join_strvs(g_get_system_config_dirs(), NULL); if (options_pathv) options_file_append_leaf_to_pathv(options_pathv, ROXTERM_LEAF_DIR); /* AppDir or datadir */ if (global_options_appdir) { options_file_prepend_str_to_v(g_build_filename(global_options_appdir, "Config", NULL)); } else { options_file_prepend_str_to_v(g_build_filename(PKG_DATA_DIR, "Config", NULL)); } /* XDG home conf dir (highest priority) */ options_file_prepend_str_to_v(g_build_filename(g_get_user_config_dir(), ROXTERM_LEAF_DIR, NULL)); } const char * const *options_file_get_pathv(void) { if (!options_pathv) options_file_init_paths(); return (const char * const *) options_pathv; } /* Finds first element in pathv containing an object called leafname and * returns full filename, or NULL if not found */ static char *options_file_filename_from_pathv(const char *leafname, char **pathv) { int n; for (n = 0; pathv[n]; ++n) { char *filename = g_build_filename(pathv[n], leafname, NULL); if (g_file_test(filename, G_FILE_TEST_EXISTS)) return filename; g_free(filename); } return NULL; } static char *build_filename_from_valist(const char *first_element, va_list ap) { const char *s; char *result = g_strdup(first_element); while ((s = va_arg(ap, const char *)) != NULL) { char *old = result; result = g_build_filename(old, s, NULL); g_free(old); } return result; } char *options_file_build_filename(const char *first_element, ...) { char *filename; char *result; va_list ap; va_start(ap, first_element); filename = build_filename_from_valist(first_element, ap); va_end(ap); result = options_file_filename_from_pathv(filename, options_pathv); g_free(filename); return result; } GKeyFile *options_file_open(const char *leafname, const char *group_name) { char *filename; GKeyFile *kf = g_key_file_new(); GError *err = NULL; char *first_group; options_file_init_paths(); filename = options_file_build_filename(leafname, NULL); if (!filename) return kf; if (!g_key_file_load_from_file(kf, filename, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &err)) { if (err && !STR_EMPTY(err->message)) dlg_critical(NULL, _("Can't read options file %s: %s"), filename, err->message); else dlg_critical(NULL, _("Can't read options file %s"), filename); if (err) g_error_free(err); g_free(filename); return kf; } first_group = g_key_file_get_start_group(kf); if (!first_group || strcmp(first_group, group_name)) { dlg_critical(NULL, _("Options file %s does not start with group '%s'"), filename, group_name); g_key_file_free(kf); kf = g_key_file_new(); } g_free(first_group); g_free(filename); return kf; } gboolean options_file_mkdir_with_parents(const char *dirname) { if (!dirname || !dirname[0] || (!dirname[1] && (dirname[0] == '.' || dirname[0] == '/'))) { g_critical(_("Invalid directory name '%s'"), dirname); return FALSE; } if (g_mkdir_with_parents(dirname, 0755) == -1) { dlg_critical(NULL, _("Failed to create directory '%s': %s"), dirname, strerror(errno)); return FALSE; } return TRUE; } char *options_file_filename_for_saving(const char *leafname, ...) { static char *xdg_dir = NULL; va_list ap; char *result; char *partial; if (!xdg_dir) { xdg_dir = g_build_filename(g_get_user_config_dir(), ROXTERM_LEAF_DIR, NULL); if (!g_file_test(xdg_dir, G_FILE_TEST_IS_DIR)) options_file_mkdir_with_parents(xdg_dir); } va_start(ap, leafname); partial = build_filename_from_valist(leafname, ap); result = g_build_filename(xdg_dir, partial, NULL); g_free(partial); va_end(ap); return result; } void options_file_save(GKeyFile *kf, const char *leafname) { char *pathname = options_file_filename_for_saving(leafname, NULL); char *file_data; gsize data_len; GError *err = NULL; if (!pathname) return; /* leafname may actually be a relative path, so make sure any directories * in it exist */ if (strchr(leafname, G_DIR_SEPARATOR)) { char *dirname = g_path_get_dirname(pathname); options_file_mkdir_with_parents(dirname); g_free(dirname); } file_data = g_key_file_to_data(kf, &data_len, &err); if (err) { if (err && !STR_EMPTY(err->message)) { dlg_critical(NULL, _("Unable to generate options file %s: %s"), pathname, err->message); } else { dlg_critical(NULL, _("Unable to generate options file %s"), pathname); } g_error_free(err); } else if (file_data) { if (!g_file_set_contents(pathname, file_data, data_len, &err)) { if (err && !STR_EMPTY(err->message)) { dlg_critical(NULL, _("Unable to save options file %s: %s"), pathname, err->message); } else { dlg_critical(NULL, _("Unable to save options file %s"), pathname); } if (err) g_error_free(err); } } g_free(pathname); g_free(file_data); } static void report_lookup_err(GError *err, const char *key, const char *group_name) { if (err && err->code != G_KEY_FILE_ERROR_KEY_NOT_FOUND && err->code != G_KEY_FILE_ERROR_GROUP_NOT_FOUND) { dlg_critical(NULL, _("Error looking up option '%s' in '%s': %s"), key, group_name, err->message); } if (err) g_error_free(err); } char *options_file_lookup_string_with_default( GKeyFile *kf, const char *group_name, const char *key, const char *default_value) { GError *err = NULL; char *result = g_key_file_get_string(kf, group_name, key, &err); if (result && !result[0]) { g_free(result); result = NULL; } if (!result) { if (default_value) result = g_strdup(default_value); report_lookup_err(err, key, group_name); } return result; } int options_file_lookup_int_with_default( GKeyFile *kf, const char *group_name, const char *key, int default_value) { GError *err = NULL; int result = g_key_file_get_integer(kf, group_name, key, &err); if (err) { result = default_value; report_lookup_err(err, key, group_name); } return result; } gboolean options_file_copy_to_user_dir(GtkWindow *window, const char *src_path, const char *family, const char *new_leaf) { char *new_path = options_file_filename_for_saving(family, NULL); char *buffer = NULL; gsize size; GError *error = NULL; gboolean success = FALSE; if (!g_file_test(new_path, G_FILE_TEST_IS_DIR)) { if (g_mkdir_with_parents(new_path, 0755) == -1) { dlg_warning(window, _("Unable to create directory '%s'"), new_path); return FALSE; } } g_free(new_path); new_path = options_file_filename_for_saving(family, new_leaf, NULL); if (g_file_test(src_path, G_FILE_TEST_IS_REGULAR)) { if (g_file_get_contents(src_path, &buffer, &size, &error)) success = g_file_set_contents(new_path, buffer, size, &error); g_free(buffer); } else { const char *content = ""; if (!strcmp(family, "Profiles")) content = "[roxterm profile]"; else if (!strcmp(family, "Colours")) content = "[roxterm colour scheme]"; else if (!strcmp(family, "Shortcuts")) content = "[roxterm shortcuts scheme]"; success = g_file_set_contents(new_path, content, -1, &error); } if (!success) { dlg_warning(window, _("Unable to copy profile/scheme: %s"), error && error->message ? error->message : _("unknown reason")); } if (error) g_error_free(error); g_free(new_path); return success; } char *options_file_make_editable(GtkWindow *window, const char *family_name, const char *name) { char *path = options_file_filename_for_saving(family_name, name, NULL); if (!g_file_test(path, G_FILE_TEST_EXISTS)) { char *src = options_file_build_filename(family_name, name, NULL); if (src) { options_file_copy_to_user_dir(window, src, family_name, name); g_free(src); } } return path; } /* vi:set sw=4 ts=4 noet cindent cino= */
24.097778
80
0.676872
db0ca98aafc17655bd26528e113d3b25c943a753
5,615
h
C
blades/gnunet/src/include/gnunet_helper_lib.h
krattai/AEBL
a7b12c97479e1236d5370166b15ca9f29d7d4265
[ "BSD-2-Clause" ]
4
2016-04-26T03:43:54.000Z
2016-11-17T08:09:04.000Z
blades/gnunet/src/include/gnunet_helper_lib.h
krattai/AEBL
a7b12c97479e1236d5370166b15ca9f29d7d4265
[ "BSD-2-Clause" ]
17
2015-01-05T21:06:22.000Z
2015-12-07T20:45:44.000Z
blades/gnunet/src/include/gnunet_helper_lib.h
krattai/AEBL
a7b12c97479e1236d5370166b15ca9f29d7d4265
[ "BSD-2-Clause" ]
3
2016-04-26T03:43:55.000Z
2020-11-06T11:02:08.000Z
/* This file is part of GNUnet. Copyright (C) 2011, 2012 Christian Grothoff GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNUnet; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @author Philipp Toelke * @author Christian Grothoff * * @file * API for dealing with SUID helper processes * * @defgroup helper Helper library * Dealing with SUID helper processes. * * Provides an API for dealing with (SUID) helper processes * that communicate via GNUNET_MessageHeaders on STDIN/STDOUT. * * @{ */ #ifndef GNUNET_HELPER_LIB_H #define GNUNET_HELPER_LIB_H #include "gnunet_scheduler_lib.h" #include "gnunet_server_lib.h" /** * The handle to a helper process. */ struct GNUNET_HELPER_Handle; /** * Callback that will be called when the helper process dies. This is not called * when the helper process is stoped using GNUNET_HELPER_stop() * * @param cls the closure from GNUNET_HELPER_start() */ typedef void (*GNUNET_HELPER_ExceptionCallback) (void *cls); /** * Starts a helper and begins reading from it. The helper process is * restarted when it dies except when it is stopped using GNUNET_HELPER_stop() * or when the exp_cb callback is not NULL. * * @param with_control_pipe does the helper support the use of a control pipe for signalling? * @param binary_name name of the binary to run * @param binary_argv NULL-terminated list of arguments to give when starting the binary (this * argument must not be modified by the client for * the lifetime of the helper handle) * @param cb function to call if we get messages from the helper * @param exp_cb the exception callback to call. Set this to NULL if the helper * process has to be restarted automatically when it dies/crashes * @param cb_cls closure for the above callbacks * @return the new Handle, NULL on error */ struct GNUNET_HELPER_Handle * GNUNET_HELPER_start (int with_control_pipe, const char *binary_name, char *const binary_argv[], GNUNET_SERVER_MessageTokenizerCallback cb, GNUNET_HELPER_ExceptionCallback exp_cb, void *cb_cls); /** * Sends termination signal to the helper process. The helper process is not * reaped; call GNUNET_HELPER_wait() for reaping the dead helper process. * * @param h the helper handle * @param soft_kill if #GNUNET_YES, signals termination by closing the helper's * stdin; #GNUNET_NO to signal termination by sending SIGTERM to helper * @return #GNUNET_OK on success; #GNUNET_SYSERR on error */ int GNUNET_HELPER_kill (struct GNUNET_HELPER_Handle *h, int soft_kill); /** * Reap the helper process. This call is blocking (!). The helper process * should either be sent a termination signal before or should be dead before * calling this function * * @param h the helper handle * @return #GNUNET_OK on success; #GNUNET_SYSERR on error */ int GNUNET_HELPER_wait (struct GNUNET_HELPER_Handle *h); /** * Free's the resources occupied by the helper handle * * @param h the helper handle to free */ void GNUNET_HELPER_destroy (struct GNUNET_HELPER_Handle *h); /** * Kills the helper, closes the pipe, frees the handle and calls wait() on the * helper process * * @param h handle to helper to stop * @param soft_kill if #GNUNET_YES, signals termination by closing the helper's * stdin; #GNUNET_NO to signal termination by sending SIGTERM to helper */ void GNUNET_HELPER_stop (struct GNUNET_HELPER_Handle *h, int soft_kill); /** * Continuation function. * * @param cls closure * @param result #GNUNET_OK on success, * #GNUNET_NO if helper process died * #GNUNET_SYSERR during GNUNET_HELPER_destroy */ typedef void (*GNUNET_HELPER_Continuation)(void *cls, int result); /** * Handle to cancel 'send' */ struct GNUNET_HELPER_SendHandle; /** * Send an message to the helper. * * @param h helper to send message to * @param msg message to send * @param can_drop can the message be dropped if there is already one in the queue? * @param cont continuation to run once the message is out (#GNUNET_OK on succees, #GNUNET_NO * if the helper process died, #GNUNET_SYSERR during #GNUNET_HELPER_destroy). * @param cont_cls closure for @a cont * @return NULL if the message was dropped, * otherwise handle to cancel @a cont (actual transmission may * not be abortable) */ struct GNUNET_HELPER_SendHandle * GNUNET_HELPER_send (struct GNUNET_HELPER_Handle *h, const struct GNUNET_MessageHeader *msg, int can_drop, GNUNET_HELPER_Continuation cont, void *cont_cls); /** * Cancel a #GNUNET_HELPER_send operation. If possible, transmitting * the message is also aborted, but at least 'cont' won't be called. * * @param sh operation to cancel */ void GNUNET_HELPER_send_cancel (struct GNUNET_HELPER_SendHandle *sh); #endif /* end of include guard: GNUNET_HELPER_LIB_H */ /** @} */ /* end of group */
30.851648
94
0.721104
8484af833780347db6770ef3414563913161962c
489
h
C
catowser/HttpKit/HttpKit.h
kyzmitch/catowser
3848053458e3910fd34d60929c42493654e56036
[ "BSD-3-Clause" ]
1
2022-03-11T16:42:50.000Z
2022-03-11T16:42:50.000Z
catowser/HttpKit/HttpKit.h
kyzmitch/catowser
3848053458e3910fd34d60929c42493654e56036
[ "BSD-3-Clause" ]
null
null
null
catowser/HttpKit/HttpKit.h
kyzmitch/catowser
3848053458e3910fd34d60929c42493654e56036
[ "BSD-3-Clause" ]
null
null
null
// // HttpKit.h // HttpKit // // Created by Andrei Ermoshin on 10/11/19. // Copyright © 2019 andreiermoshin. All rights reserved. // #import <UIKit/UIKit.h> //! Project version number for HttpKit. FOUNDATION_EXPORT double HttpKitVersionNumber; //! Project version string for HttpKit. FOUNDATION_EXPORT const unsigned char HttpKitVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import <HttpKit/PublicHeader.h>
24.45
132
0.756646
d5cafb98b34271da651244b2b6728cee2f3b7e20
2,949
h
C
Classes/data/MKMDataCoder.h
dimchat/mkm-objc
b76fccfb3d23b358a14cc8a499980415f650de2c
[ "MIT" ]
null
null
null
Classes/data/MKMDataCoder.h
dimchat/mkm-objc
b76fccfb3d23b358a14cc8a499980415f650de2c
[ "MIT" ]
null
null
null
Classes/data/MKMDataCoder.h
dimchat/mkm-objc
b76fccfb3d23b358a14cc8a499980415f650de2c
[ "MIT" ]
1
2019-03-09T06:20:08.000Z
2019-03-09T06:20:08.000Z
// license: https://mit-license.org // // Ming-Ke-Ming : Decentralized User Identity Authentication // // Written in 2020 by Moky <albert.moky@gmail.com> // // ============================================================================= // The MIT License (MIT) // // Copyright (c) 2020 Albert Moky // // 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. // ============================================================================= // // MKMDataCoder.h // MingKeMing // // Created by Albert Moky on 2020/4/7. // Copyright © 2020 DIM Group. All rights reserved. // #import <Foundation/Foundation.h> NS_ASSUME_NONNULL_BEGIN @protocol MKMDataCoder <NSObject> /** * Encode binary data to text string * * @param data - binary data * @return Base58/64 string */ - (nullable NSString *)encode:(NSData *)data; /** * Decode text string to binary data * * @param string - base58/64 string * @return binary data */ - (nullable NSData *)decode:(NSString *)string; @end #pragma mark - @interface MKMHex : NSObject + (void)setCoder:(id<MKMDataCoder>)coder; + (nullable NSString *)encode:(NSData *)data; + (nullable NSData *)decode:(NSString *)string; @end @interface MKMBase58 : NSObject + (void)setCoder:(id<MKMDataCoder>)coder; + (nullable NSString *)encode:(NSData *)data; + (nullable NSData *)decode:(NSString *)string; @end @interface MKMBase64 : NSObject + (void)setCoder:(id<MKMDataCoder>)coder; + (nullable NSString *)encode:(NSData *)data; + (nullable NSData *)decode:(NSString *)string; @end #define MKMHexEncode(data) [MKMHex encode:(data)] #define MKMHexDecode(string) [MKMHex decode:(string)] #define MKMBase58Encode(data) [MKMBase58 encode:(data)] #define MKMBase58Decode(string) [MKMBase58 decode:(string)] #define MKMBase64Encode(data) [MKMBase64 encode:(data)] #define MKMBase64Decode(string) [MKMBase64 decode:(string)] NS_ASSUME_NONNULL_END
30.091837
80
0.6843
7d8e421e56d4377b3addd61210ddc52c1f731911
1,440
h
C
PSInputLimitDemo/PSInputLimitDemo/UITextField+PSInputLimit.h
passing101/PSInputLimitDemo
01dc64fc04ce3364d6343cf2e857e6f22dc9d2c2
[ "MIT" ]
2
2017-09-07T13:33:42.000Z
2017-09-08T02:40:43.000Z
PSInputLimitDemo/PSInputLimitDemo/UITextField+PSInputLimit.h
passing101/PSInputLimitDemo
01dc64fc04ce3364d6343cf2e857e6f22dc9d2c2
[ "MIT" ]
1
2019-05-31T06:45:57.000Z
2019-05-31T08:03:56.000Z
PSInputLimitDemo/PSInputLimitDemo/UITextField+PSInputLimit.h
passing101/PSInputLimitDemo
01dc64fc04ce3364d6343cf2e857e6f22dc9d2c2
[ "MIT" ]
1
2019-05-31T08:07:26.000Z
2019-05-31T08:07:26.000Z
// // UITextField+PSInputLimit.h // PSInputLimitDemo // // Created by 冯广勇 on 2017/9/1. // Copyright © 2017年 Passing. All rights reserved. // #import <UIKit/UIKit.h> typedef NS_ENUM(NSUInteger, PSInputLimitType) { PSInputLimitTypeNone = 0, //只判断字符个数是否超出 ps_limitDigit PSInputLimitTypeFloat = 1, //默认限制整数9位,小数点后两位 PSInputLimitTypeInteger = 2, //配合limitDigit使用,limitDigit默认9; PSInputLimitTypePhone = 3, //手机号码输入框,直接调用, PSInputLimitTypeEmail = 4, //无法使用 PSInputLimitTypeChinese = 5, //添加一个属性来限制输入的字体个数 PSInputLimitTypeMoney = 6, //金额(TypeFloat添加处理特殊输入(.01=0.01 / 01.4=1.4)) }; typedef NS_ENUM(NSUInteger, PSInputLimitErrorType) { PSInputLimitErrorTypeCharLacking, PSInputLimitErrorTypeCharSurplus, }; @interface UITextField (PSInputLimit) /** 限制输入的类型, 默认不限制类型 */ @property (nonatomic , assign) PSInputLimitType ps_limitType; /** 限制输入的字符个数, 默认9个 */ @property (nonatomic , assign) NSInteger ps_limitDigit; /** 限制小数点后几位, 默认2位 */ @property (nonatomic , assign) NSInteger ps_limitPoint; /** 首位是否可以为 0 (整型时), 默认NO */ @property (nonatomic , assign) BOOL ps_integerPrimacyZero; /** 是否可以粘贴复制, 默认NO */ @property (nonatomic , assign) BOOL ps_openMenu; /** 触发限制操作时的提示信息 */ @property(nonatomic, strong) NSString *(^ps_tipTextForLimitType)(void); /** 触发限制操作时的提示信息 */ @property(nonatomic, strong) void(^ps_didTriggerLimitationBlock)(void); @end
25.714286
83
0.704167
7b16651ce32d0e92d038fec02178dbbcf5f64807
1,589
h
C
src/d3d12/D3D12GpuWriteGuard.h
amc522/DX12Scrap
d00aa6ae27a9a0594ce08739af564992f773d916
[ "MIT" ]
1
2022-03-23T23:50:58.000Z
2022-03-23T23:50:58.000Z
src/d3d12/D3D12GpuWriteGuard.h
amc522/DX12Scrap
d00aa6ae27a9a0594ce08739af564992f773d916
[ "MIT" ]
null
null
null
src/d3d12/D3D12GpuWriteGuard.h
amc522/DX12Scrap
d00aa6ae27a9a0594ce08739af564992f773d916
[ "MIT" ]
null
null
null
#pragma once namespace scrap::d3d12 { template<class T> class GpuWriteGuard { public: GpuWriteGuard() = default; GpuWriteGuard(T& gpuBuffer, ID3D12GraphicsCommandList* commandList) : mGpuBuffer(&gpuBuffer) , mCommandList(commandList) { mWriteBuffer = mGpuBuffer->map(); } GpuWriteGuard(const GpuWriteGuard<T>&) = delete; GpuWriteGuard(GpuWriteGuard<T>&& other) : mGpuBuffer(other.mGpuBuffer) , mCommandList(other.mCommandList) , mWriteBuffer(std::move(other.mWriteBuffer)) { other.mGpuBuffer = nullptr; other.mCommandList = nullptr; } ~GpuWriteGuard() { if(mGpuBuffer != nullptr) { mGpuBuffer->unmap(mCommandList); } } GpuWriteGuard& operator=(const GpuWriteGuard<T>&) = delete; GpuWriteGuard& operator=(GpuWriteGuard<T>&& other) { if(mGpuBuffer != nullptr) { mGpuBuffer->unmap(mCommandList); } mGpuBuffer = other.mGpuBuffer; other.mGpuBuffer = nullptr; mCommandList = other.mCommandList; other.mCommandList = nullptr; mWriteBuffer = std::move(other.mWriteBuffer); return *this; } std::span<std::byte> getWriteBuffer() { return mWriteBuffer; } template<class U> std::span<U> getWriteBufferAs() { return std::span<U>(reinterpret_cast<U*>(mWriteBuffer.data()), mWriteBuffer.size_bytes() / sizeof(U)); } private: T* mGpuBuffer = nullptr; ID3D12GraphicsCommandList* mCommandList = nullptr; std::span<std::byte> mWriteBuffer; }; } // namespace scrap::d3d12
26.483333
110
0.648206
70177b6c9fe7f35e052dd1fe47911f39bebde980
3,648
h
C
libecc/src/elk/sys/arm/pl011.h
ghsecuritylab/ellcc-mirror
b03a4afac74d50cf0987554b8c0cd8209bcb92a2
[ "BSD-2-Clause" ]
null
null
null
libecc/src/elk/sys/arm/pl011.h
ghsecuritylab/ellcc-mirror
b03a4afac74d50cf0987554b8c0cd8209bcb92a2
[ "BSD-2-Clause" ]
null
null
null
libecc/src/elk/sys/arm/pl011.h
ghsecuritylab/ellcc-mirror
b03a4afac74d50cf0987554b8c0cd8209bcb92a2
[ "BSD-2-Clause" ]
null
null
null
/*- * Copyright (c) 2008-2009, Kohsuke Ohtani * 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 author nor the names of any co-contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. */ /* * pl011.h - ARM PrimeCell PL011 UART */ #ifndef _pl011_h_ #define _pl011_h_ #include "config.h" CONF_IMPORT(__pl011_physical_base__); CONF_IMPORT(__pl011_base__); CONF_IMPORT(__pl011_size__); CONF_IMPORT(__pl011_irq__); CONF_IMPORT(__pl011_clock__); CONF_IMPORT(__pl011_baud_rate__); #define PL011_PHYSICAL_BASE CONF_ADDRESS(__pl011_physical_base__) #define PL011_BASE CONF_ADDRESS(__pl011_base__) #define PL011_SIZE CONF_ADDRESS(__pl011_size__) #define PL011_IRQ CONF_UNSIGNED(__pl011_irq__) #define PL011_CLOCK CONF_UNSIGNED(__pl011_clock__) #define PL011_BAUD_RATE CONF_UNSIGNED(__pl011_baud_rate__) /* UART Registers */ #define UART_DR (PL011_BASE + 0x00) #define UART_RSR (PL011_BASE + 0x04) #define UART_ECR (PL011_BASE + 0x04) #define UART_FR (PL011_BASE + 0x18) #define UART_IBRD (PL011_BASE + 0x24) #define UART_FBRD (PL011_BASE + 0x28) #define UART_LCRH (PL011_BASE + 0x2c) #define UART_CR (PL011_BASE + 0x30) #define UART_IMSC (PL011_BASE + 0x38) #define UART_MIS (PL011_BASE + 0x40) #define UART_ICR (PL011_BASE + 0x44) // Flag register. #define FR_RXFE 0x10 // Receive FIFO empty. #define FR_TXFF 0x20 // Transmit FIFO full. // Masked interrupt status register. #define MIS_RX 0x10 // Receive interrupt. #define MIS_TX 0x20 // Transmit interrupt. // Interrupt clear register. #define ICR_RX 0x10 // Clear receive interrupt. #define ICR_TX 0x20 // Clear transmit interrupt. // Line control register (High). #define LCRH_WLEN8 0x60 // 8 bits. #define LCRH_FEN 0x10 // Enable FIFO. // Control register. #define CR_UARTEN 0x0001 // UART enable. #define CR_TXE 0x0100 // Transmit enable. #define CR_RXE 0x0200 // Receive enable. // Interrupt mask set/clear register. #define IMSC_RX 0x10 // Receive interrupt mask. #define IMSC_TX 0x20 // Transmit interrupt mask. #endif // _pl011_h_
39.652174
77
0.713816
4a103e6332b8d54714c1d0068c525d3dfb51d8ca
17,107
h
C
libif2k/old/if2k_admin.h
jdkoftinoff/if2kv2
167631c34b684001c2d5b762bdfd3e45e2699cad
[ "BSD-2-Clause" ]
null
null
null
libif2k/old/if2k_admin.h
jdkoftinoff/if2kv2
167631c34b684001c2d5b762bdfd3e45e2699cad
[ "BSD-2-Clause" ]
null
null
null
libif2k/old/if2k_admin.h
jdkoftinoff/if2kv2
167631c34b684001c2d5b762bdfd3e45e2699cad
[ "BSD-2-Clause" ]
1
2021-04-24T07:07:19.000Z
2021-04-24T07:07:19.000Z
#ifndef _IF2K_ADMIN_H #define _IF2K_ADMIN_H #include "if2k_config.h" #include "if2k_serial.h" #include "if2k_svc.h" #include "jdk_questions.h" #include "jdk_html.h" #include "jdk_http_server.h" #include "jdk_util.h" #include "jdk_string.h" class if2k_html_style : public jdk_html_style_simple { public: if2k_html_style( jdk_settings &settings, const jdk_string &hostnameport_ ) : text_font( settings, "text_font" ), text_css( settings, "text_css" ), product_title( settings, "text_product_title1" ), product_homepage( settings, "text_product_homepage" ), product_logo( settings, "text_product_logo" ), product_links( settings, "text_product_links" ), body_options( settings, "text_body_options" ), internal_hostname( hostnameport_ ) { } virtual ~if2k_html_style(); const jdk_string &get_internal_hostname() const { return internal_hostname; } jdk_html_chunk *head( jdk_html_chunk *contents, jdk_html_chunk *next ) const; jdk_html_chunk *body( const char *options, jdk_html_chunk *contents, jdk_html_chunk *next ) const; virtual jdk_html_chunk *navigation_bar( jdk_html_chunk *next=0 ) const; jdk_html_chunk *header( jdk_html_chunk *next ) const; jdk_html_chunk *footer( jdk_html_chunk *next ) const; private: static const char * my_stylesheet; jdk_live_string< jdk_str<128> > text_font; jdk_live_string< jdk_str<4096> > text_css; jdk_live_string< jdk_str<1024> > product_title; jdk_live_string_url product_homepage; jdk_live_string_url product_logo; jdk_live_long product_links; jdk_live_string< jdk_str<1024> > body_options; jdk_str<256> internal_hostname; }; class if2k_generator_lua : public jdk_http_server_generator { public: if2k_generator_lua( if2k_lua_interpreter &lua_, const char *prefix_ ) : lua(lua_), prefix( prefix_ ) { } virtual ~if2k_generator_lua() { } // handle_request returns true if it knows how to handle this request // returns false if it should be given to a different generator virtual bool handle_request( const jdk_http_request_header &request, const jdk_dynbuf &request_data, jdk_http_response_header &response, jdk_dynbuf &response_data, const jdk_string &connection_id ) { if( request.get_request_type() != jdk_http_request_header::REQUEST_GET && request.get_request_type() != jdk_http_request_header::REQUEST_POST && request.get_request_type() != jdk_http_request_header::REQUEST_PUT ) { return false; } // copy the filename jdk_str<4096> fname( request.get_url().path ); if( fname.ncmp( prefix, prefix.len() )!=0 ) { return false; } // skip the prefix fname.cpy( fname.c_str()+prefix.len() ); if2k_lua_web_response lua_response(response,response_data); // try call the selected script bool script_success = false; // find the start of cgi parameters char *rawcgi=fname.chr('?'); jdk_settings_text cgiinfo; if( rawcgi ) { jdk_cgi_loadsettings( &cgiinfo, rawcgi+1 ); // nullify the '?' to get just the plain cgi function name *rawcgi='\0'; } if( request.get_request_type() == jdk_http_request_header::REQUEST_GET ) { script_success = lua.if_cgi_get( fname, lua_response, connection_id, request, cgiinfo ); } else if( request.get_request_type() == jdk_http_request_header::REQUEST_POST ) { script_success = lua.if_cgi_post( fname, lua_response, connection_id, request, request_data ); } else if( request.get_request_type() == jdk_http_request_header::REQUEST_PUT ) { script_success = lua.if_cgi_put( fname, lua_response, connection_id, request, request_data, cgiinfo ); } if( script_success ) { response.add_entry( "Pragma:", "no-cache" ); response.add_entry( "Cache-Control:", "no-cache" ); response.add_entry( "Expires:", "-1" ); jdk_log_debug1( "response length is %d", lua_response.contents.get_data_length() ); return true; } else { return false; } } private: if2k_lua_interpreter &lua; const jdk_str<512> prefix; }; class if2k_generator_lua_error : public jdk_http_server_generator { public: if2k_generator_lua_error( if2k_lua_interpreter &lua_, const char *error_type_ ) : lua(lua_), error_type( error_type_ ) { } virtual ~if2k_generator_lua_error() { } // handle_request returns true if it knows how to handle this request // returns false if it should be given to a different generator virtual bool handle_request( const jdk_http_request_header &request, const jdk_dynbuf &request_data, jdk_http_response_header &response, jdk_dynbuf &response_data, const jdk_string &connection_id ) { // try call the selected script bool script_success = false; if2k_lua_web_response lua_response(response,response_data); script_success = lua.if_url_error( error_type, lua_response, connection_id, request ); if( script_success ) { response.add_entry( "Pragma:", "no-cache" ); response.add_entry( "Cache-Control:", "no-cache" ); response.add_entry( "Expires:", "-1" ); jdk_log_debug1( "response length is %d", lua_response.contents.get_data_length() ); return true; } else { return false; } } private: if2k_lua_interpreter &lua; const jdk_str<512> error_type; }; class if2k_generator_404 : public jdk_http_server_generator_404 { public: if2k_generator_404( jdk_html_style *style_, jdk_settings &settings ) : jdk_http_server_generator_404( style_ ), errormsg( settings, "text_404_page_errormsg" ), loginmsg( settings, "text_loginmsg" ), loginlink( settings, "text_loginlink" ), enable_login( settings, "enable_login" ) { } protected: jdk_live_string< jdk_str<1024> > errormsg; jdk_live_string< jdk_str<1024> > loginmsg; jdk_live_string< jdk_str<1024> > loginlink; jdk_live_long enable_login; protected: virtual jdk_html_chunk * create_contents(const char *fname, jdk_html_chunk *next) { return style.center( style.p( style.font("SIZE=+4", style.text( errormsg.get())), enable_login ? style.p( style.font("SIZE=+2", style.link( loginlink.get().c_str(), style.text( loginmsg.get()))), next) : next)); } }; class if2k_blockpage_document_generator : public jdk_html_document_generator { public: if2k_blockpage_document_generator( const jdk_html_style &style_, const jdk_settings &cgiparams_, const jdk_http_request_header &request_, const jdk_settings &settings_, const jdk_string &override_url_ ) : jdk_html_document_generator( style_ ), cgiparams( cgiparams_ ), request(request_), settings(settings_), override_url(override_url_), login_url(), loginmsg( settings, "text_loginmsg" ), loginlink( settings, "text_loginlink" ), text_block_invalid( settings, "text_block_invalid" ), block_info1( settings, "text_block_info1" ), block_info2( settings, "text_block_info2" ), block_info3( settings, "text_block_info3" ), text_block_override( settings, "text_block_override" ), text_block_override_click( settings, "text_block_override_click" ), text_block_override_warn(settings, "text_block_override_warn" ) { } virtual jdk_html_chunk *generate_head( jdk_html_chunk *next ); jdk_html_chunk *generate_violation_info( jdk_html_chunk *next ); virtual jdk_html_chunk *generate_admin_section( jdk_html_chunk *next ); jdk_html_chunk *generate_content( jdk_html_chunk *next ); jdk_html_chunk *generate_header( jdk_html_chunk *next ); jdk_html_chunk *generate_footer( jdk_html_chunk *next ); private: const jdk_settings &cgiparams; const jdk_http_request_header &request; const jdk_settings &settings; jdk_string_url override_url; jdk_string_url login_url; jdk_live_string< jdk_str<1024> > loginmsg; jdk_live_string< jdk_str<1024> > loginlink; jdk_live_string< jdk_str<1024> > text_block_invalid; jdk_live_string< jdk_str<1024> > block_info1; jdk_live_string< jdk_str<1024> > block_info2; jdk_live_string< jdk_str<1024> > block_info3; jdk_live_string< jdk_str<1024> > text_block_override; jdk_live_string< jdk_str<1024> > text_block_override_click; jdk_live_string< jdk_str<1024> > text_block_override_warn; }; class if2k_http_generator_getsettings : public jdk_http_server_generator { public: if2k_http_generator_getsettings( const char *prefix_, const jdk_settings &settings_ ) : prefix( prefix_ ), settings( settings_ ) { } virtual ~if2k_http_generator_getsettings() { } // handle_request returns true if it knows how to handle this request // returns false if it should be given to a different generator virtual bool handle_request( const jdk_http_request_header &request, const jdk_dynbuf &request_data, jdk_http_response_header &response, jdk_dynbuf &response_data, const jdk_string &connection_id ); private: jdk_str<256> prefix; const jdk_settings &settings; }; class if2k_http_generator_getfile : public jdk_http_server_generator { public: if2k_http_generator_getfile( const char *prefix_, const jdk_settings &settings_ ) : prefix( prefix_ ), settings( settings_ ) { } virtual ~if2k_http_generator_getfile() { } // handle_request returns true if it knows how to handle this request // returns false if it should be given to a different generator virtual bool handle_request( const jdk_http_request_header &request, const jdk_dynbuf &request_data, jdk_http_response_header &response, jdk_dynbuf &response_data, const jdk_string &connection_id ); private: jdk_str<256> prefix; const jdk_settings &settings; }; class if2k_http_generator_blockpage : public jdk_http_server_generator_html { public: if2k_http_generator_blockpage( const char *prefix_, jdk_html_style *style_, const jdk_settings &settings_ ) : jdk_http_server_generator_html( prefix_, style_ ), settings(settings_), override_url( settings, "blocked_page_override_url" ), login_url( settings, "text_loginlink" ) { } protected: jdk_html_chunk * create_html( const char *fname, const jdk_http_request_header &request, const jdk_dynbuf &request_data, jdk_http_response_header &response, const jdk_string &connection_id ); const jdk_settings &settings; jdk_live_string_url override_url; jdk_live_string_url login_url; }; class if2k_http_generator_override : public jdk_http_server_generator { public: if2k_http_generator_override( jdk_settings &settings_, const char *prefix_ ) : settings( settings_ ), prefix( prefix_ ) { } // handle_request returns true if it knows how to handle this request // returns false if it should be given to a different generator bool handle_request( const jdk_http_request_header &request, const jdk_dynbuf &request_data, jdk_http_response_header &response, jdk_dynbuf &response_data, const jdk_string &connection_id ); private: jdk_settings &settings; jdk_str<256> prefix; }; class if2k_adminlogin_document_generator : public jdk_html_document_generator { public: if2k_adminlogin_document_generator( const jdk_html_style &style_, const jdk_settings &cgiparams_, const jdk_http_request_header &request_, const jdk_settings &settings_, const jdk_string &action_url_ ) : jdk_html_document_generator( style_ ), cgiparams( cgiparams_ ), request(request_), settings(settings_), action_url(action_url_), product_name( settings, "product_name" ), text_login_title( settings, "text_login_title" ), text_login_username( settings, "text_login_username" ), text_login_password( settings, "text_login_password" ) { } jdk_html_chunk *generate_head( jdk_html_chunk *next ); jdk_html_chunk *generate_content( jdk_html_chunk *next ); jdk_html_chunk *generate_header( jdk_html_chunk *next ); jdk_html_chunk *generate_footer( jdk_html_chunk *next ); private: const jdk_settings &cgiparams; const jdk_http_request_header &request; const jdk_settings &settings; const jdk_str<1024> action_url; jdk_live_string< jdk_str<1024> > product_name; jdk_live_string< jdk_str<1024> > text_login_title; jdk_live_string< jdk_str<1024> > text_login_username; jdk_live_string< jdk_str<1024> > text_login_password; }; class if2k_http_generator_adminlogin : public jdk_http_server_generator_html { public: if2k_http_generator_adminlogin( const char *prefix_, jdk_html_style *style_, const jdk_settings &settings_, const char *action_url_ ) : jdk_http_server_generator_html( prefix_, style_ ), settings(settings_), action_url( action_url_ ) { } protected: jdk_html_chunk * create_html( const char *fname, const jdk_http_request_header &request, const jdk_dynbuf &request_data, jdk_http_response_header &response, const jdk_string &connection_id ); const jdk_settings &settings; jdk_str<4096> action_url; }; class if2k_questions_asker : public jdk_questions_asker_html_generator_simple { public: if2k_questions_asker( const jdk_html_style &style_, const jdk_settings_text &cgiparams_, const jdk_http_request_header &request_, const jdk_question *question_list_, const jdk_settings_text &defaults_, const jdk_string &action_url_, const jdk_string &submit_label_, const jdk_settings &settings ) : jdk_questions_asker_html_generator_simple( style_, cgiparams_, request_, question_list_, defaults_, action_url_, submit_label_ ), text_title(settings,"text_filter_settings_title"), text_header(settings,"text_filter_settings_header") { } jdk_html_chunk *generate_head( jdk_html_chunk *next ); jdk_html_chunk *generate_header( jdk_html_chunk *next ); jdk_html_chunk *generate_footer( jdk_html_chunk *next ); protected: jdk_live_string< jdk_str<1024> > text_title; jdk_live_string< jdk_str<1024> > text_header; }; class if2k_http_administration : public jdk_http_server_post_validator { public: if2k_http_administration( const jdk_settings_text &settings_, const char *submit_url_ ) : settings( settings_ ), submit_url( submit_url_ ), login_url( settings, "text_loginlink" ), text_loginmsg( settings, "text_loginmsg" ), text_login_reject( settings, "text_login_reject" ), text_login_error( settings, "text_login_error" ) { } validation_response post_validate( const jdk_html_style &style, const jdk_settings_text &postinfo, const jdk_http_request_header &request, const jdk_string &connection_id ); protected: const jdk_settings_text &settings; const jdk_string_url submit_url; jdk_live_string_url login_url; jdk_live_string< jdk_str<1024> > text_loginmsg; jdk_live_string< jdk_str<1024> > text_login_reject; jdk_live_string< jdk_str<1024> > text_login_error; }; class if2k_http_generator_adminset : public jdk_http_server_generator_html { public: if2k_http_generator_adminset( const char *prefix_, jdk_html_style *style_, const jdk_settings &settings_ ) : jdk_http_server_generator_html( prefix_, style_ ), settings(settings_), login_url( settings, "text_loginlink" ), text_loginmsg( settings, "text_loginmsg" ), text_set_demo( settings, "text_set_demo" ), text_set_good( settings, "text_set_good" ) { } protected: jdk_html_chunk * create_html( const char *fname, const jdk_http_request_header &request, const jdk_dynbuf &request_data, jdk_http_response_header &response, const jdk_string &connection_id ); const jdk_settings &settings; jdk_live_string_url login_url; jdk_live_string< jdk_str<1024> > text_loginmsg; jdk_live_string< jdk_str<1024> > text_set_demo; jdk_live_string< jdk_str<1024> > text_set_good; }; #endif
26.98265
100
0.687906
f2ddd1017d7f0886df17fc760eb3adae18039a77
443
c
C
src/client/core/cmd/names.c
thibautcornolti/MyIRC
05597431090d9ac1d23d296a35734227db623c74
[ "MIT" ]
null
null
null
src/client/core/cmd/names.c
thibautcornolti/MyIRC
05597431090d9ac1d23d296a35734227db623c74
[ "MIT" ]
null
null
null
src/client/core/cmd/names.c
thibautcornolti/MyIRC
05597431090d9ac1d23d296a35734227db623c74
[ "MIT" ]
null
null
null
/* ** EPITECH PROJECT, 2018 ** myirc ** File description: ** myirc */ #include "client.h" bool cmd_names(sess_t *sess, char *line) { commander_t *cmder = sess->serv->commander; if (strlen(line)) cmder->push(cmder, "NAMES %s", line); else if (strcmp(sess->cur_chan->name, "master")) cmder->push(cmder, "NAMES %s", sess->cur_chan->name); else sess->printChan( sess, "master", "You cannot list master's users"); return (true); }
19.26087
55
0.65237
780fb9a307347b5774ef4df9f6bb71301e1414f8
3,469
c
C
eval.c
mpu/lambda
accced6300fd130d7a2ee3897dfd578f7b9ba490
[ "MIT" ]
33
2015-03-03T22:23:53.000Z
2022-02-07T04:23:10.000Z
eval.c
mpu/lambda
accced6300fd130d7a2ee3897dfd578f7b9ba490
[ "MIT" ]
null
null
null
eval.c
mpu/lambda
accced6300fd130d7a2ee3897dfd578f7b9ba490
[ "MIT" ]
4
2016-04-08T14:59:24.000Z
2022-01-11T09:59:12.000Z
#include <assert.h> #include <stdlib.h> #include <stdio.h> #include <stdbool.h> #include "eval.h" #include "parse.h" #include "subst.h" #define EVAL_STACK 1024 static inline bool eval_is_value(const struct term *); static inline bool eval_is_value(const struct term * pterm) { return pterm->type == Tlam || pterm->type == Tvar; } void eval_cbn(struct term ** ppterm) { struct term ** stack[EVAL_STACK] = { ppterm }; int stackp = 0; while (stackp >= 0) { struct term * pterm = *stack[stackp]; switch (pterm->type) { case Tlam: { stackp--; continue; } case Tvar: { return; } case Tapp: { if (pterm->data.app.left->type == Tlam) { struct term * lam = pterm->data.app.left; subst_substitute(lam->data.lam.body, lam->data.lam.var, pterm->data.app.right); *stack[stackp] = lam->data.lam.body; parse_free_term(pterm->data.app.right); free(pterm); free(lam); continue; } if (++stackp >= EVAL_STACK) { puts("Stack overflow."); return; } stack[stackp] = &pterm->data.app.left; continue; } default: abort(); } } } void eval_cbv(struct term ** ppterm) { struct term ** stack[EVAL_STACK] = { ppterm }; int stackp = 0; while (stackp >= 0) { struct term * pterm = *stack[stackp]; switch (pterm->type) { case Tvar: case Tlam: { stackp--; continue; } case Tapp: { if (eval_is_value(pterm->data.app.right)) { struct term * lam = pterm->data.app.left; if (lam->type != Tlam) { if (lam->type == Tvar) return; if (++stackp >= EVAL_STACK) { puts("Stack overflow."); return; } stack[stackp] = &pterm->data.app.left; continue; } subst_substitute(lam->data.lam.body, lam->data.lam.var, pterm->data.app.right); *stack[stackp] = lam->data.lam.body; parse_free_term(pterm->data.app.right); free(pterm); free(lam); continue; } if (++stackp >= EVAL_STACK) { puts("Stack overflow."); return; } stack[stackp] = &pterm->data.app.right; continue; } default: abort(); } } } void eval_deep(struct term ** ppterm) { while (1) { struct term * pterm = *ppterm; switch(pterm->type) { case Tvar: { return; } case Tlam: { eval_deep(&pterm->data.lam.body); return; } case Tapp: { struct term * left; eval_deep(&pterm->data.app.left); left = pterm->data.app.left; eval_deep(&pterm->data.app.right); if (left->type == Tlam) { eval_cbn(ppterm); continue; } return; } default: abort(); } } }
22.673203
71
0.437878
785000742bfdbcaa6d3bee0ae25bb48a96dbcc58
2,314
h
C
Engine/Source/Editor/MeshPaint/Public/MeshPaintSettings.h
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
1
2022-01-29T18:36:12.000Z
2022-01-29T18:36:12.000Z
Engine/Source/Editor/MeshPaint/Public/MeshPaintSettings.h
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
null
null
null
Engine/Source/Editor/MeshPaint/Public/MeshPaintSettings.h
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
null
null
null
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. #pragma once #include "MeshPaintTypes.h" #include "MeshPaintSettings.generated.h" /** Mesh paint color view modes (somewhat maps to EVertexColorViewMode engine enum.) */ UENUM() enum class EMeshPaintColorViewMode : uint8 { /** Normal view mode (vertex color visualization off) */ Normal UMETA(DisplayName = "Off"), /** RGB only */ RGB UMETA(DisplayName = "RGB Channels"), /** Alpha only */ Alpha UMETA(DisplayName = "Alpha Channel"), /** Red only */ Red UMETA(DisplayName = "Red Channel"), /** Green only */ Green UMETA(DisplayName = "Green Channel"), /** Blue only */ Blue UMETA(DisplayName = "Blue Channel"), }; UCLASS() class MESHPAINT_API UPaintBrushSettings : public UObject { GENERATED_UCLASS_BODY() public: virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override; ~UPaintBrushSettings(); float GetBrushRadius() const { return BrushRadius; } void SetBrushRadius(float InRadius); protected: /** Radius of the Brush used for Painting */ UPROPERTY(EditAnywhere, Category = Brush, meta = (DisplayName = "Radius")) float BrushRadius; public: /** Min and Max brush radius retrieved from config */ float BrushRadiusMin; float BrushRadiusMax; /** Strength of the brush (0.0 - 1.0) */ UPROPERTY(EditAnywhere, Category = Brush, meta = (DisplayName = "Strength", UIMin = "0.0", UIMax = "1.0", ClampMin= "0.0", ClampMax = "1.0")) float BrushStrength; /** Amount of falloff to apply (0.0 - 1.0) */ UPROPERTY(EditAnywhere, Category = Brush, meta = (DisplayName = "Falloff", UIMin = "0.0", UIMax = "1.0", ClampMin = "0.0", ClampMax = "1.0")) float BrushFalloffAmount; /** Enables "Flow" painting where paint is continually applied from the brush every tick */ UPROPERTY(EditAnywhere, Category = Brush, meta = (DisplayName = "Enable Brush Flow")) bool bEnableFlow; /** Whether back-facing triangles should be ignored */ UPROPERTY(EditAnywhere, Category = Brush, meta = (DisplayName = "Ignore back-facing")) bool bOnlyFrontFacingTriangles; /** Color view mode used to display Vertex Colors */ UPROPERTY(EditAnywhere, Category = View) EMeshPaintColorViewMode ColorViewMode; }; UCLASS() class MESHPAINT_API UMeshPaintSettings : public UObject { GENERATED_BODY() };
29.291139
142
0.721262
d8a33ade7ef70e53bb7a88206cecec6bfe83eb32
473
h
C
cpp/examples/PushDemo/PushClient/TestRecvThread.h
yangg37/Tars
a4ed7b1706a800175dd02775c12ba3afb89a07ee
[ "Apache-2.0" ]
7
2019-04-04T23:50:24.000Z
2019-09-02T01:21:41.000Z
cpp/examples/PushDemo/PushClient/TestRecvThread.h
yangg37/Tars
a4ed7b1706a800175dd02775c12ba3afb89a07ee
[ "Apache-2.0" ]
null
null
null
cpp/examples/PushDemo/PushClient/TestRecvThread.h
yangg37/Tars
a4ed7b1706a800175dd02775c12ba3afb89a07ee
[ "Apache-2.0" ]
9
2019-03-26T23:56:00.000Z
2020-07-05T03:30:47.000Z
#ifndef __TEST_RECV_THREAD_H #define __TEST_RECV_THREAD_H #include "servant/Application.h" class TestPushCallBack : public ServantProxyCallback { public: virtual int onDispatch(ReqMessagePtr msg); }; typedef tars::TC_AutoPtr<TestPushCallBack> TestPushCallBackPtr; class RecvThread : public TC_Thread, public TC_ThreadLock { public: RecvThread(); virtual void run(); void terminate(); private: bool _bTerminate; Communicator _comm; ServantPrx _prx; }; #endif
16.310345
63
0.788584
2c6e983e8a1125c933d749259d2ca972d1a54f3e
2,161
h
C
prod/attestation_server/include/C_CkAuthUtilW.h
aanciaes/secure-redis-container
405a34a3a6ab493dbbb21e2ea6d70837b27facbf
[ "BSD-2-Clause" ]
4
2021-04-16T14:46:05.000Z
2021-07-02T20:14:29.000Z
prod/attestation_server/include/C_CkAuthUtilW.h
aanciaes/secure-redis-container
405a34a3a6ab493dbbb21e2ea6d70837b27facbf
[ "BSD-2-Clause" ]
9
2021-04-16T14:05:58.000Z
2021-07-21T19:46:34.000Z
SIMSmeCoreLib/__SIMSme__/ObjC/Chilkat/ChilkatHeaders/C++ Headers/C_CkAuthUtilW.h
cdskev/ginlo-ios
458d0eea0519f055e013ae1f2f6d7b051e9bc23a
[ "Apache-2.0" ]
null
null
null
// This is a generated source file for Chilkat version 9.5.0.83 #ifndef _C_CkAuthUtilWH #define _C_CkAuthUtilWH #include "chilkatDefs.h" #include "Chilkat_C.h" CK_C_VISIBLE_PUBLIC HCkAuthUtilW CkAuthUtilW_Create(void); CK_C_VISIBLE_PUBLIC void CkAuthUtilW_Dispose(HCkAuthUtilW handle); CK_C_VISIBLE_PUBLIC void CkAuthUtilW_getDebugLogFilePath(HCkAuthUtilW cHandle, HCkString retval); CK_C_VISIBLE_PUBLIC void CkAuthUtilW_putDebugLogFilePath(HCkAuthUtilW cHandle, const wchar_t *newVal); CK_C_VISIBLE_PUBLIC const wchar_t *CkAuthUtilW_debugLogFilePath(HCkAuthUtilW cHandle); CK_C_VISIBLE_PUBLIC void CkAuthUtilW_getLastErrorHtml(HCkAuthUtilW cHandle, HCkString retval); CK_C_VISIBLE_PUBLIC const wchar_t *CkAuthUtilW_lastErrorHtml(HCkAuthUtilW cHandle); CK_C_VISIBLE_PUBLIC void CkAuthUtilW_getLastErrorText(HCkAuthUtilW cHandle, HCkString retval); CK_C_VISIBLE_PUBLIC const wchar_t *CkAuthUtilW_lastErrorText(HCkAuthUtilW cHandle); CK_C_VISIBLE_PUBLIC void CkAuthUtilW_getLastErrorXml(HCkAuthUtilW cHandle, HCkString retval); CK_C_VISIBLE_PUBLIC const wchar_t *CkAuthUtilW_lastErrorXml(HCkAuthUtilW cHandle); CK_C_VISIBLE_PUBLIC BOOL CkAuthUtilW_getLastMethodSuccess(HCkAuthUtilW cHandle); CK_C_VISIBLE_PUBLIC void CkAuthUtilW_putLastMethodSuccess(HCkAuthUtilW cHandle, BOOL newVal); CK_C_VISIBLE_PUBLIC BOOL CkAuthUtilW_getVerboseLogging(HCkAuthUtilW cHandle); CK_C_VISIBLE_PUBLIC void CkAuthUtilW_putVerboseLogging(HCkAuthUtilW cHandle, BOOL newVal); CK_C_VISIBLE_PUBLIC void CkAuthUtilW_getVersion(HCkAuthUtilW cHandle, HCkString retval); CK_C_VISIBLE_PUBLIC const wchar_t *CkAuthUtilW_version(HCkAuthUtilW cHandle); CK_C_VISIBLE_PUBLIC BOOL CkAuthUtilW_SaveLastError(HCkAuthUtilW cHandle, const wchar_t *path); CK_C_VISIBLE_PUBLIC BOOL CkAuthUtilW_WalmartSignature(HCkAuthUtilW cHandle, const wchar_t *requestUrl, const wchar_t *consumerId, const wchar_t *privateKey, const wchar_t *requestMethod, HCkString outStr); CK_C_VISIBLE_PUBLIC const wchar_t *CkAuthUtilW_walmartSignature(HCkAuthUtilW cHandle, const wchar_t *requestUrl, const wchar_t *consumerId, const wchar_t *privateKey, const wchar_t *requestMethod); #endif
72.033333
206
0.863026
9643145ce878652bab5c3a19502866b7e7c9398b
1,032
h
C
_FBKVOInfo.h
yihongmingfeng/Fruitday
981f6ecdb03a42d95210b249590505db18195dfd
[ "MIT" ]
null
null
null
_FBKVOInfo.h
yihongmingfeng/Fruitday
981f6ecdb03a42d95210b249590505db18195dfd
[ "MIT" ]
null
null
null
_FBKVOInfo.h
yihongmingfeng/Fruitday
981f6ecdb03a42d95210b249590505db18195dfd
[ "MIT" ]
null
null
null
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #import "NSObject.h" @class FBKVOController, NSString; @interface _FBKVOInfo : NSObject { FBKVOController *_controller; NSString *_keyPath; unsigned long long _options; SEL _action; void *_context; CDUnknownBlockType _block; } - (void).cxx_destruct; - (id)debugDescription; - (_Bool)isEqual:(id)arg1; - (unsigned long long)hash; - (id)initWithController:(id)arg1 keyPath:(id)arg2; - (id)initWithController:(id)arg1 keyPath:(id)arg2 options:(unsigned long long)arg3 context:(void *)arg4; - (id)initWithController:(id)arg1 keyPath:(id)arg2 options:(unsigned long long)arg3 action:(SEL)arg4; - (id)initWithController:(id)arg1 keyPath:(id)arg2 options:(unsigned long long)arg3 block:(CDUnknownBlockType)arg4; - (id)initWithController:(id)arg1 keyPath:(id)arg2 options:(unsigned long long)arg3 block:(CDUnknownBlockType)arg4 action:(SEL)arg5 context:(void *)arg6; @end
31.272727
153
0.731589
327e10af512e2c066fc84e5ff893cdc1e65d57ac
5,250
c
C
libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L053R8/stm32l0xx_hal_pcd_ex.c
mjrgh/mbed
966bf9577a1d3280df75a0ddd452393d1e8fb97e
[ "Apache-2.0" ]
1
2015-01-02T06:55:31.000Z
2015-01-02T06:55:31.000Z
libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L053R8/stm32l0xx_hal_pcd_ex.c
x893/mbed
103a6a5bc6da7db33c723c278ef08ee491b92cb5
[ "Apache-2.0" ]
null
null
null
libraries/mbed/targets/cmsis/TARGET_STM/TARGET_NUCLEO_L053R8/stm32l0xx_hal_pcd_ex.c
x893/mbed
103a6a5bc6da7db33c723c278ef08ee491b92cb5
[ "Apache-2.0" ]
1
2018-11-22T02:59:15.000Z
2018-11-22T02:59:15.000Z
/** ****************************************************************************** * @file stm32l0xx_hal_pcd_ex.c * @author MCD Application Team * @version V1.0.0 * @date 22-April-2014 * @brief Extended PCD HAL module driver. * This file provides firmware functions to manage the following * functionalities of the USB Peripheral Controller: * + Configururation of the PMA for EP * ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2> * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "stm32l0xx_hal.h" /** @addtogroup STM32L0xx_HAL_Driver * @{ */ /** @defgroup PCDEx * @brief PCDEx HAL module driver * @{ */ #ifdef HAL_PCD_MODULE_ENABLED /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /** @defgroup PCDEx_Private_Functions * @{ */ /** @defgroup PCDEx_Group1 Initialization and de-initialization functions * @brief Initialization and Configuration functions * @verbatim =============================================================================== ##### Peripheral extended features methods ##### =============================================================================== @endverbatim * @{ */ /** * @brief Configure PMA for EP * @param pdev : Device instance * @param ep_addr: endpoint address * @param ep_Kind: endpoint Kind * @arg USB_SNG_BUF: Single Buffer used * @arg USB_DBL_BUF: Double Buffer used * @param pmaadress: EP address in The PMA: In case of single buffer endpoint * this parameter is 16-bit value providing the address * in PMA allocated to endpoint. * In case of double buffer endpoint this parameter * is a 32-bit value providing the endpoint buffer 0 address * in the LSB part of 32-bit value and endpoint buffer 1 address * in the MSB part of 32-bit value. * @retval : status */ HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, uint16_t ep_addr, uint16_t ep_kind, uint32_t pmaadress) { PCD_EPTypeDef *ep; /* initialize ep structure*/ if ((0x80 & ep_addr) == 0x80) { ep = &hpcd->IN_ep[ep_addr & 0x7F]; } else { ep = &hpcd->OUT_ep[ep_addr]; } /* Here we check if the endpoint is single or double Buffer*/ if (ep_kind == PCD_SNG_BUF) { /*Single Buffer*/ ep->doublebuffer = 0; /*Configure te PMA*/ ep->pmaadress = (uint16_t)pmaadress; } else /*USB_DBL_BUF*/ { /*Double Buffer Endpoint*/ ep->doublebuffer = 1; /*Configure the PMA*/ ep->pmaaddr0 = pmaadress & 0xFFFF; ep->pmaaddr1 = (pmaadress & 0xFFFF0000) >> 16; } return HAL_OK; } /** * @} */ /** * @} */ #endif /* HAL_PCD_MODULE_ENABLED */ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
34.539474
84
0.544762
3295e0f2a0889c1bae433746fbb4355f044e4f98
3,942
h
C
src/algorithm/dlist.h
AnkerC/codecomplete
84a5db2f4de904156622429e10c81349ab7a26d6
[ "Apache-2.0" ]
null
null
null
src/algorithm/dlist.h
AnkerC/codecomplete
84a5db2f4de904156622429e10c81349ab7a26d6
[ "Apache-2.0" ]
null
null
null
src/algorithm/dlist.h
AnkerC/codecomplete
84a5db2f4de904156622429e10c81349ab7a26d6
[ "Apache-2.0" ]
null
null
null
#ifndef _DLIST_H_ #define _DLIST_H_ #include <iostream> #include <assert.h> using namespace std; /** *@brief: 双向链表模板实现 *@author skyie *@date 2018/04/01 */ template<typename T> struct Dlist_node { T element; Dlist_node<T>* next; Dlist_node<T>* prev; Dlist_node(): element(), next(nullptr), prev(nullptr){} explicit Dlist_node(const T& element): element(element), next(nullptr), prev(nullptr){} ~Dlist_node() { next = nullptr; prev = nullptr; } }; template<typename T> class Dlist { public: Dlist(); ~Dlist(); bool empty() const {return length > 0 ? true : false;} size_t size() const {return length;} T value(int pos); void push_front(const T& element); T pop_front(); void push_back(const T& element); T pop_back(); void clear(); T erase(int pos); void erase(int begin, int end); void dump(); private: Dlist_node<T>* find(int pos); void insert_after(int pos, const T& element); private: Dlist_node<T>* head; Dlist_node<T>* tail; int length; }; template<typename T> Dlist<T>::Dlist() { head = new Dlist_node<T>(); tail = new Dlist_node<T>(); head->next = tail; tail->prev = head; length = 0; } template<typename T> Dlist<T> ::~Dlist() { clear(); delete head; delete tail; } template<typename T> void Dlist<T>::clear() { if (length != 0) { erase(1, length); } } template<typename T> T Dlist<T>::value(int pos) { Dlist_node<T>* node = find(pos); if (node == nullptr) { return -1; } return node->element; } template<typename T> void Dlist<T>::push_front(const T& element) { insert_after(0, element); } template<typename T> T Dlist<T>::pop_front() { Dlist_node<T>* node = find(1); return node->element; } template<typename T> void Dlist<T>::push_back(const T& element) { insert_after(length, element); } template<typename T> T Dlist<T>::pop_back() { Dlist_node<T>* node = find(length); return node->element; } template<typename T> void Dlist<T>::insert_after(int pos, const T& element) { if (pos < 0 || pos > length) { cout<< "out of bound"<<endl; return; } Dlist_node<T>* new_node = new Dlist_node<T>(element); assert(new_node); Dlist_node<T>* pre_node = find(pos); pre_node->next->prev = new_node; new_node->next = pre_node->next; new_node->prev = pre_node; pre_node->next = new_node; length++; } template<typename T> Dlist_node<T>* Dlist<T>::find(int pos) { if (pos < 0 || pos > length) { cout<< "find:out of bound"<<endl; return nullptr; } Dlist_node<T>* node = head; int i = 0; while (i != pos) { node = node->next; i++; } return node; } template<typename T> T Dlist<T>::erase(int pos) { Dlist_node<T>* del_node = find(pos); if (del_node == nullptr) { return; } T element = del_node->element; del_node->prev->next = del_node->next; del_node->next->prev = del_node->prev; delete del_node; length--; return element; //return nullptr; } template<typename T> void Dlist<T>::erase(int begin, int end) { Dlist_node<T>* pbegin = find(begin); Dlist_node<T>* pend = find(end); pbegin->prev->next = pend->next; pend->next->prev = pbegin->prev; Dlist_node<T>* stop = pend->next; while (pbegin != stop) { Dlist_node<T>* tmp = pbegin; pbegin = pbegin->next; delete tmp; length--; } } template<typename T> void Dlist<T>::dump() { Dlist_node<T>* node = head->next; while (node != tail) { cout<<node->element<<endl; node = node->next; } } #endif
19.323529
92
0.561898
3297b6281850264dd7ade39bd9cc04d8bb940064
2,600
h
C
sources/Renderer/Direct3D12/D3D12Types.h
beldenfox/LLGL
3a54125ebfa79bb06fccf8c413d308ff22186b52
[ "BSD-3-Clause" ]
1,403
2016-09-28T21:48:07.000Z
2022-03-31T23:58:57.000Z
sources/Renderer/Direct3D12/D3D12Types.h
beldenfox/LLGL
3a54125ebfa79bb06fccf8c413d308ff22186b52
[ "BSD-3-Clause" ]
70
2016-10-13T20:15:58.000Z
2022-01-12T23:51:12.000Z
sources/Renderer/Direct3D12/D3D12Types.h
beldenfox/LLGL
3a54125ebfa79bb06fccf8c413d308ff22186b52
[ "BSD-3-Clause" ]
122
2016-10-23T15:33:44.000Z
2022-03-07T07:41:23.000Z
/* * D3D12Types.h * * This file is part of the "LLGL" project (Copyright (c) 2015-2019 by Lukas Hermanns) * See "LICENSE.txt" for license information. */ #ifndef LLGL_D3D12_TYPES_H #define LLGL_D3D12_TYPES_H #include <LLGL/VertexAttribute.h> #include <LLGL/PipelineStateFlags.h> #include <LLGL/RenderContextFlags.h> #include <LLGL/TextureFlags.h> #include <LLGL/SamplerFlags.h> #include <LLGL/QueryHeapFlags.h> #include <d3d12.h> namespace LLGL { namespace D3D12Types { DXGI_FORMAT Map( const DataType dataType ); DXGI_FORMAT Map( const Format format ); D3D_PRIMITIVE_TOPOLOGY Map( const PrimitiveTopology topology ); D3D12_FILL_MODE Map( const PolygonMode polygonMode ); D3D12_CULL_MODE Map( const CullMode cullMode ); D3D12_BLEND Map( const BlendOp blendOp ); D3D12_BLEND_OP Map( const BlendArithmetic blendArithmetic ); D3D12_COMPARISON_FUNC Map( const CompareOp compareOp ); D3D12_STENCIL_OP Map( const StencilOp stencilOp ); D3D12_FILTER Map( const SamplerDescriptor& samplerDesc ); D3D12_TEXTURE_ADDRESS_MODE Map( const SamplerAddressMode addressMode ); D3D12_LOGIC_OP Map( const LogicOp logicOp ); D3D12_SHADER_COMPONENT_MAPPING Map( const TextureSwizzle textureSwizzle ); UINT Map( const TextureSwizzleRGBA& textureSwizzle ); D3D12_SRV_DIMENSION MapSrvDimension ( const TextureType textureType ); D3D12_UAV_DIMENSION MapUavDimension ( const TextureType textureType ); D3D12_RESOURCE_DIMENSION MapResourceDimension( const TextureType textureType ); D3D12_QUERY_TYPE MapQueryType ( const QueryType queryType ); D3D12_QUERY_HEAP_TYPE MapQueryHeapType ( const QueryType queryType ); Format Unmap( const DXGI_FORMAT format ); DXGI_FORMAT ToDXGIFormatDSV(const DXGI_FORMAT format); DXGI_FORMAT ToDXGIFormatSRV(const DXGI_FORMAT format); DXGI_FORMAT ToDXGIFormatUAV(const DXGI_FORMAT format); DXGI_FORMAT ToDXGIFormatUInt(const DXGI_FORMAT format); } // /namespace D3D12Types } // /namespace LLGL #endif // ================================================================================
38.235294
86
0.601923
d2a78ece63a495c5e304ece9ad3bd310c2e802a3
23,026
c
C
lib/pubnub_dns_codec.c
mrtryhard/c-core
4c3c7009a133bf770c255243a2fc580f1629110e
[ "MIT" ]
null
null
null
lib/pubnub_dns_codec.c
mrtryhard/c-core
4c3c7009a133bf770c255243a2fc580f1629110e
[ "MIT" ]
null
null
null
lib/pubnub_dns_codec.c
mrtryhard/c-core
4c3c7009a133bf770c255243a2fc580f1629110e
[ "MIT" ]
null
null
null
/* -*- c-file-style:"stroustrup"; indent-tabs-mode: nil -*- */ #include "lib/pubnub_dns_codec.h" #include "core/pubnub_assert.h" #include "core/pubnub_log.h" #include <string.h> /** Size of DNS header, in octets */ #define HEADER_SIZE 12 /** Offset of the ID field in the DNS header */ #define HEADER_ID_OFFSET 0 /** Offset of the options field in the DNS header */ #define HEADER_OPTIONS_OFFSET 2 /** Offset of the query count field in the DNS header */ #define HEADER_QUERY_COUNT_OFFSET 4 /** Offset of the answer count field in the DNS header */ #define HEADER_ANSWER_COUNT_OFFSET 6 /** Offset of the authoritive servers count field in the DNS header */ #define HEADER_AUTHOR_COUNT_OFFSET 8 /** Offset of the additional records count field in the DNS header */ #define HEADER_ADDITI_COUNT_OFFSET 10 /** Bits for the options field of the DNS header - two octets in total. */ enum DNSoptionsMask { /* Response type; 0: no error, 1: format error, 2: server fail, 3: name eror, 4: not implemented, 5: refused */ dnsoptRCODEmask = 0x000F, /** Checking disabled */ dnsoptCDmask = 0x0010, /** Authentication data */ dnsoptADmask = 0x0020, /** Recursion available */ dnsoptRAmask = 0x0080, /** Recursion desired */ dnsoptRDmask = 0x0100, /** Truncation (1 - message was truncated, 0 - was not) */ dnsoptTCmask = 0x0200, /** Authorative answer */ dnsoptAAmask = 0x0400, /** 0: query, 1: inverse query, 2: status */ dnsoptOPCODEmask = 0x7800, /** 0: query, 1: response */ dnsoptQRmask = 0x8000, }; /** Size of non-name data in the QUESTION field of a DNS mesage, in octets */ #define QUESTION_DATA_SIZE 4 /** Size of non-name data in the RESOURCE DATA field of a DNS mesage, in octets */ #define RESOURCE_DATA_SIZE 10 /** Offset of the type sub-field of the RESOURCE DATA */ #define RESOURCE_DATA_TYPE_OFFSET -10 /** Offset of the data length sub-field of the RESOURCE DATA */ #define RESOURCE_DATA_DATA_LEN_OFFSET -2 /** Question/query class */ enum DNSqclass { dnsqclassInternet = 1 }; /* Maximum number of characters until the next dot('.'), or finishing NULL('\0') in array of bytes */ #define MAX_ALPHABET_STRETCH_LENGTH 63 /* Maximum passes through the loop allowed while decoding label, considering that it may contain up to five or six dots. Defined in order to detect erroneous offset pointers infinite loops. (Represents maximum #offsets detected while decoding) */ #define MAXIMUM_LOOP_PASSES 10 /** Do the DNS QNAME (host) encoding. This strange kind of "run-time length encoding" will convert `"www.google.com"` to `"\3www\6google\3com"`. @param dns Pointer to the buffer where encoded host label will be placed @param n Maximum buffer length provided @param host Label to encode @return 'Encoded-dns-label-length' on success, -1 on error */ static int dns_qname_encode(uint8_t* dns, size_t n, char const* host) { uint8_t* dest = dns + 1; uint8_t* lpos; PUBNUB_ASSERT_OPT(n > 0); PUBNUB_ASSERT_OPT(host != NULL); PUBNUB_ASSERT_OPT(dns != NULL); lpos = dns; *lpos = '\0'; for(;;) { char hc = *host++; if ((hc != '.') && (hc != '\0')) { *dest++ = hc; } else { size_t d = dest - lpos; *dest++ = '\0'; if ((1 == d) || (MAX_ALPHABET_STRETCH_LENGTH < d - 1)) { PUBNUB_LOG_ERROR("Error: in DNS label/name encoding.\n" "host ='%s',\n" "encoded ='%s',\n", host - (dest - 1 - dns), dns); if (d > 1) { PUBNUB_LOG_ERROR("Label too long: stretch_length=%zu > MAX_ALPHABET_STRETCH_LENGTH=%d\n", d - 1, MAX_ALPHABET_STRETCH_LENGTH); } else { PUBNUB_LOG_ERROR("Label stretch has no length.\n"); } return -1; } *lpos = (uint8_t)(d - 1); lpos += d; if ('\0' == hc) { break; } } } return dest - dns; } int pbdns_prepare_dns_request(uint8_t* buf, size_t buf_size, char const* host, int *to_send, enum DNSqueryType query_type) { int qname_encoded_length; int len = 0; PUBNUB_ASSERT_OPT(buf != NULL); PUBNUB_ASSERT_OPT(host != NULL); PUBNUB_ASSERT_OPT(to_send != NULL); /* First encoded_length + label_end('\0') make 2 extra bytes */ if (HEADER_SIZE + strlen((char*)host) + 2 + QUESTION_DATA_SIZE > buf_size) { *to_send = 0; PUBNUB_LOG_ERROR( "Error: While preparing DNS request - Buffer too small! buf_size=%zu, required_size=%zu\n" "host_name=%s\n", buf_size, HEADER_SIZE + strlen((char*)host) + 2 + QUESTION_DATA_SIZE, (char*)host); return -1; } buf[HEADER_ID_OFFSET] = 0; buf[HEADER_ID_OFFSET + 1] = 33; /* in lack of a better ID */ buf[HEADER_OPTIONS_OFFSET] = dnsoptRDmask >> 8; buf[HEADER_OPTIONS_OFFSET + 1] = 0; buf[HEADER_QUERY_COUNT_OFFSET] = 0; buf[HEADER_QUERY_COUNT_OFFSET + 1] = 1; memset(buf + HEADER_ANSWER_COUNT_OFFSET, 0, HEADER_SIZE - HEADER_ANSWER_COUNT_OFFSET); len += HEADER_SIZE; qname_encoded_length = dns_qname_encode(buf + HEADER_SIZE, buf_size - HEADER_SIZE, host); if (qname_encoded_length <= 0) { *to_send = len; return -1; } len += qname_encoded_length; buf[len] = 0; buf[len + 1] = query_type; buf[len + 2] = 0; buf[len + 3] = dnsqclassInternet; *to_send = len + QUESTION_DATA_SIZE; return 0; } static int handle_offset(uint8_t pass, uint8_t const** o_reader, uint8_t const* buffer, size_t buffer_size) { uint16_t offset; uint8_t const* reader; PUBNUB_ASSERT_OPT(buffer != NULL); PUBNUB_ASSERT_OPT(o_reader != NULL); reader = *o_reader; PUBNUB_ASSERT_OPT(buffer < reader); if ((reader + 1) >= (buffer + buffer_size)) { PUBNUB_LOG_ERROR("Error: in DNS label/name decoding - " "pointer in encoded label points outside the message while reading offset:\n" "reader=%p + 1 >= buffer=%p + buffer_size=%zu\n", reader, buffer, buffer_size); return -1; } if (pass > MAXIMUM_LOOP_PASSES) { PUBNUB_LOG_ERROR("Error: in DNS label/name decoding - " "Too many offset jumps(%hhu).\n", pass); return +1; } offset = (reader[0] & 0x3F) * 256 + reader[1]; if (offset < HEADER_SIZE) { PUBNUB_LOG_ERROR("Error: in DNS label/name decoding - " "Offset within header : offset=%hu, HEADER_SIZE=%d\n", offset, HEADER_SIZE); return +1; } if (offset >= buffer_size) { PUBNUB_LOG_ERROR("Error: in DNS label/name decoding - offset=%hu >= buffer_size=%zu\n", offset, buffer_size); return +1; } *o_reader = buffer + offset; return 0; } static int forced_skip(uint8_t pass, uint8_t const** o_reader, uint8_t const* buffer, size_t buffer_size) { uint8_t const* reader; PUBNUB_ASSERT_OPT(buffer != NULL); PUBNUB_ASSERT_OPT(o_reader != NULL); PUBNUB_ASSERT_OPT(buffer < *o_reader); PUBNUB_ASSERT_OPT(*o_reader < (buffer + buffer_size)); reader = *o_reader; for(;;) { uint8_t b = *reader; if (0xC0 == (b & 0xC0)) { *o_reader = reader + 2; return 0; } else if (0 == b) { *o_reader = reader + 1; return 0; } else if (0 == (b & 0xC0)) { /* (buffer + buffer_size) points to the first octet outside the buffer, while (reader + b + 1) has to be inside of it */ if ((reader + b + 1) >= (buffer + buffer_size)) { PUBNUB_LOG_ERROR( "Error: reading DNS response - forced_skip() - " "Pointer in encoded label points outside the message:\n" "reader=%p + b=%d + 1 >= buffer=%p + buffer_size=%zu\n", reader, b, buffer, buffer_size); return -1; } reader += b + 1; } else { PUBNUB_LOG_ERROR("Error: reading DNS response - forced_skip() - " "Bad offset format: b & 0xC0=%d, &b=%p\n", b & 0xC0, &b); return -1; } } return -1; } /* Do the DNS label decoding. Apart from the RLE decoding of `3www6google3com0` -> `www.google.com`, it also has a "(de)compression" scheme in which a label can be shared with another in the same buffer. @param decoded Pointer to memory section for decoded label @param n Maximum length of the section in bytes @param src address of the container with the offset(position within shared buffer from where reading starts) @param buffer Beginning of the buffer @param buffer_size Complete buffer size @param o_bytes_to_skip If function succeeds, points to the offset(position within buffer) available for 'next' buffer access @return 0 on success, -1 on error */ static int dns_label_decode(uint8_t* decoded, size_t n, uint8_t const* src, uint8_t const* buffer, size_t buffer_size, size_t* o_bytes_to_skip) { uint8_t* dest = decoded; uint8_t const* const end = decoded + n; uint8_t const* reader = src; uint8_t pass = 0; PUBNUB_ASSERT_OPT(n > 0); PUBNUB_ASSERT_OPT(src != NULL); PUBNUB_ASSERT_OPT(buffer != NULL); PUBNUB_ASSERT_OPT(src < (buffer + buffer_size)); PUBNUB_ASSERT_OPT(decoded != NULL); PUBNUB_ASSERT_OPT(o_bytes_to_skip != NULL); *o_bytes_to_skip = 0; for(;;) { uint8_t b = *reader; if (0xC0 == (b & 0xC0)) { if (0 == *o_bytes_to_skip) { *o_bytes_to_skip = reader - src + 2; } if(handle_offset(++pass, &reader, buffer, buffer_size) != 0) { *dest = '\0'; return -1; } } else if (0 == b) { if (0 == *o_bytes_to_skip) { *o_bytes_to_skip = reader - src + 1; } return 0; } else if (0 == (b & 0xC0)) { if (dest != decoded) { *dest++ = '.'; } if (dest + b >= end) { PUBNUB_LOG_ERROR("Error: in DNS label/name decoding - dest=%p + b=%d >= end=%p - " "Destination for decoded label/name too small, n=%zu\n", dest, b, end, n); if (0 == *o_bytes_to_skip) { if (forced_skip(pass, &reader, buffer, buffer_size) == 0) { *o_bytes_to_skip = reader - src; } } *dest = '\0'; return -1; } /* (buffer + buffer_size) points to the first octet outside the buffer, while (reader + b + 1) has to be inside of it */ if ((reader + b + 1) >= (buffer + buffer_size)) { PUBNUB_LOG_ERROR("Error: in DNS label/name decoding - " "Pointer in encoded label points outside the message:\n" "reader=%p + b=%d + 1 >= buffer=%p + buffer_size=%zu\n", reader, b, buffer, buffer_size); *dest = '\0'; return -1; } memcpy(dest, reader + 1, b); dest[b] = '\0'; dest += b; reader += b + 1; } else { PUBNUB_LOG_ERROR("Error: in DNS label/name decoding - " "Bad offset format: b & 0xC0=%d, &b=%p\n", b & 0xC0, &b); *dest = '\0'; return -1; } } /* The only way to reach this code, at the time of this writing, is if n == 0, which we check with an 'assert', but it is left here 'just in case'*/ PUBNUB_LOG_ERROR("Error: in DNS label/name decoding - " "Destination for decoding label/name too small, n=%zu\n", n); return -1; } static int read_header(uint8_t const* buf, size_t msg_size, size_t* o_q_count, size_t* o_ans_count) { uint16_t options; PUBNUB_ASSERT_OPT(buf != NULL); PUBNUB_ASSERT_OPT(o_q_count != NULL); PUBNUB_ASSERT_OPT(o_ans_count != NULL); if (HEADER_SIZE > msg_size) { PUBNUB_LOG_ERROR( "Error: DNS response is shorter than its header - msg_size=%zu, HEADER_SIZE=%d\n", msg_size, HEADER_SIZE); return -1; } options = ((uint16_t)buf[HEADER_OPTIONS_OFFSET] << 8) | (uint16_t)buf[HEADER_OPTIONS_OFFSET + 1]; if (!(options & dnsoptQRmask)) { PUBNUB_LOG_ERROR("Error: DNS response doesn't have QR flag set!\n"); return -1; } if (options & dnsoptRCODEmask) { PUBNUB_LOG_ERROR("Error: DNS response reports an error - RCODE = %d\n", buf[HEADER_OPTIONS_OFFSET + 1] & dnsoptRCODEmask); return -1; } *o_q_count = buf[HEADER_QUERY_COUNT_OFFSET] * 256 + buf[HEADER_QUERY_COUNT_OFFSET + 1]; *o_ans_count = buf[HEADER_ANSWER_COUNT_OFFSET] * 256 + buf[HEADER_ANSWER_COUNT_OFFSET + 1]; PUBNUB_LOG_TRACE( "DNS response has: %zu Questions, %zu Answers.\n", *o_q_count, *o_ans_count); return 0; } static int skip_questions(uint8_t const** o_reader, uint8_t const* buf, uint8_t const* end, size_t q_count) { size_t i; uint8_t const* reader; PUBNUB_ASSERT_OPT(buf != NULL); PUBNUB_ASSERT_OPT(end != NULL); PUBNUB_ASSERT_OPT(buf < end); PUBNUB_ASSERT_OPT(o_reader != NULL); reader = *o_reader; for (i = 0; i < q_count; ++i) { uint8_t name[256]; size_t to_skip; if (reader + QUESTION_DATA_SIZE > end) { PUBNUB_LOG_ERROR("Error: DNS response erroneous, or incomplete:\n" "reader=%p + QUESTION_DATA_SIZE=%d > buf=%p + msg_size=%ld\n", reader, QUESTION_DATA_SIZE, buf, end - buf + 1); return -1; } /* Even if label decoding reports an error(having offsets messed up, maybe, or buffer too small for decoded label), 'bytes_to_skip' may be set and we can keep looking usable answer */ if (dns_label_decode(name, sizeof name, reader, buf, (end - buf + 1), &to_skip) != 0) { if (0 == to_skip) { return -1; } } PUBNUB_LOG_TRACE("DNS response, %zu. question name: %s, to_skip=%zu\n", i+1, name, to_skip); /* Could check for QUESTION data format (QType and QClass), but even if it's wrong, we don't know what to do with it, so, there's no use */ reader += to_skip + QUESTION_DATA_SIZE; } *o_reader = reader; return 0; } static int check_answer(const uint8_t** o_reader, unsigned r_data_type, size_t r_data_len, struct pubnub_ipv4_address* resolved_addr_ipv4 IPV6_ADDR_ARGUMENT_DECLARATION) { PUBNUB_ASSERT_OPT(o_reader != NULL); if ((dnsA == r_data_type) && (resolved_addr_ipv4 != NULL)) { const uint8_t* reader = *o_reader; *o_reader += r_data_len; if (r_data_len != 4) { PUBNUB_LOG_ERROR("Error: Unexpected answer R_DATA length:%zu " "for DNS resolved Ipv4 address.\n", r_data_len); return -1; } PUBNUB_LOG_TRACE("Got IPv4: %u.%u.%u.%u\n", reader[0], reader[1], reader[2], reader[3]); memcpy(resolved_addr_ipv4->ipv4, reader, 4); return 0; } #if PUBNUB_USE_IPV6 else if ((dnsAAAA == r_data_type) && (resolved_addr_ipv6 != NULL)) { const uint8_t* reader = *o_reader; *o_reader += r_data_len; if (r_data_len != 16) { PUBNUB_LOG_ERROR("Error: Unexpected answer R_DATA length:%zu " "for DNS resolved Ipv6 address.\n", r_data_len); return -1; } /* Address representation is big endian(network byte order) */ PUBNUB_LOG_TRACE("Got IPv6: %X:%X:%X:%X:%X:%X:%X:%X\n", reader[0]*256 + reader[1], reader[2]*256 + reader[3], reader[4]*256 + reader[5], reader[6]*256 + reader[7], reader[8]*256 + reader[9], reader[10]*256 + reader[11], reader[12]*256 + reader[13], reader[14]*256 + reader[15]); memcpy(resolved_addr_ipv6->ipv6, reader, 16); return 0; } #endif /* PUBNUB_USE_IPV6 */ *o_reader += r_data_len; /* Don't care about other resource types, for now */ return -1; } static int find_the_answer(uint8_t const* reader, uint8_t const* buf, uint8_t const* end, size_t ans_count, struct pubnub_ipv4_address* resolved_addr_ipv4 IPV6_ADDR_ARGUMENT_DECLARATION) { size_t i; PUBNUB_ASSERT_OPT(buf != NULL); PUBNUB_ASSERT_OPT(reader != NULL); PUBNUB_ASSERT_OPT(end != NULL); PUBNUB_ASSERT_OPT(buf < reader); PUBNUB_ASSERT_OPT(reader < end); for (i = 0; i < ans_count; ++i) { uint8_t name[256]; size_t to_skip; size_t r_data_len; unsigned r_data_type; if (dns_label_decode(name, sizeof name, reader, buf, (end - buf + 1), &to_skip) != 0) { if (0 == to_skip) { return -1; } } reader += to_skip + RESOURCE_DATA_SIZE; if (reader > end) { PUBNUB_LOG_ERROR("Error: DNS response erroneous, or incomplete:\n" "reader=%p > buf=%p + msg_size=%ld :\n" "to_skip=%zu, RESOURCE_DATA_SIZE=%d\n", reader, buf, end - buf + 1, to_skip, RESOURCE_DATA_SIZE); return -1; } /* Resource record data offsets are negative. Network byte order - big endian. */ r_data_len = reader[RESOURCE_DATA_DATA_LEN_OFFSET] * 256 + reader[RESOURCE_DATA_DATA_LEN_OFFSET + 1]; if ((reader + r_data_len) > end) { PUBNUB_LOG_ERROR("Error: DNS response erroneous, or incomplete:\n" "reader=%p + r_data_len=%zu > buf=%p + msg_size=%ld\n", reader, r_data_len, buf, end - buf + 1); return -1; } r_data_type = reader[RESOURCE_DATA_TYPE_OFFSET] * 256 + reader[RESOURCE_DATA_TYPE_OFFSET + 1]; PUBNUB_LOG_TRACE("DNS %zu. answer: %s, to_skip:%zu, type=%u, data_len=%zu\n", i+1, name, to_skip, r_data_type, r_data_len); if(check_answer(&reader, r_data_type, r_data_len, resolved_addr_ipv4 IPV6_ADDR_ARGUMENT) == 0) { return 0; } } /* Don't care about Authoritative Servers or Additional records, for now */ return -1; } int pbdns_pick_resolved_address(uint8_t const* buf, size_t msg_size, struct pubnub_ipv4_address* resolved_addr_ipv4 IPV6_ADDR_ARGUMENT_DECLARATION) { size_t q_count; size_t ans_count; uint8_t const* reader; uint8_t const* end; PUBNUB_ASSERT_OPT(buf != NULL); #if PUBNUB_USE_IPV6 PUBNUB_ASSERT_OPT((resolved_addr_ipv4 != NULL) || (resolved_addr_ipv6 != NULL)); #else PUBNUB_ASSERT_OPT(resolved_addr_ipv4 != NULL); #endif if (read_header(buf, msg_size, &q_count, &ans_count) != 0) { return -1; } if (0 == ans_count) { return -1; } reader = buf + HEADER_SIZE; end = buf + msg_size; if (skip_questions(&reader, buf, end, q_count) != 0) { return -1; } if (reader > end) { PUBNUB_LOG_ERROR("Error: DNS message incomplete - answers missing." "reader=%p > buf=%p + msg_size=%zu\n", reader, buf, msg_size); return -1; } return find_the_answer(reader, buf, end, ans_count, resolved_addr_ipv4 IPV6_ADDR_ARGUMENT); }
35.3702
109
0.502432
d2e4232a237f8411d12fa753e89918cca5cb245f
2,742
h
C
Example/Pods/ObjectiveDropboxOfficial/Source/ObjectiveDropboxOfficial/Shared/Generated/ApiObjects/Team/Headers/DBTEAMTeamNamespacesListResult.h
truebucha/TBDropboxKit
f771ee3a76ea98efe1361822055984584e4fbe97
[ "MIT" ]
null
null
null
Example/Pods/ObjectiveDropboxOfficial/Source/ObjectiveDropboxOfficial/Shared/Generated/ApiObjects/Team/Headers/DBTEAMTeamNamespacesListResult.h
truebucha/TBDropboxKit
f771ee3a76ea98efe1361822055984584e4fbe97
[ "MIT" ]
1
2019-05-01T18:13:39.000Z
2019-05-01T18:22:08.000Z
Pods/ObjectiveDropboxOfficial/Source/ObjectiveDropboxOfficial/Shared/Generated/ApiObjects/Team/Headers/DBTEAMTeamNamespacesListResult.h
yangerasimuk/Ledger
96b4e30270f797d6da563fc13d42d13a4410b02c
[ "MIT" ]
2
2017-06-01T14:57:44.000Z
2017-06-06T17:14:44.000Z
/// /// Copyright (c) 2016 Dropbox, Inc. All rights reserved. /// /// Auto-generated by Stone, do not modify. /// #import <Foundation/Foundation.h> #import "DBSerializableProtocol.h" @class DBTEAMNamespaceMetadata; @class DBTEAMTeamNamespacesListResult; NS_ASSUME_NONNULL_BEGIN #pragma mark - API Object /// /// The `TeamNamespacesListResult` struct. /// /// Result for `namespacesList`. /// /// This class implements the `DBSerializable` protocol (serialize and /// deserialize instance methods), which is required for all Obj-C SDK API route /// objects. /// @interface DBTEAMTeamNamespacesListResult : NSObject <DBSerializable, NSCopying> #pragma mark - Instance fields /// List of all namespaces the team can access. @property (nonatomic, readonly) NSArray<DBTEAMNamespaceMetadata *> *namespaces; /// Pass the cursor into `namespacesListContinue` to obtain additional /// namespaces. Note that duplicate namespaces may be returned. @property (nonatomic, readonly, copy) NSString *cursor; /// Is true if there are additional namespaces that have not been returned yet. @property (nonatomic, readonly) NSNumber *hasMore; #pragma mark - Constructors /// /// Full constructor for the struct (exposes all instance variables). /// /// @param namespaces List of all namespaces the team can access. /// @param cursor Pass the cursor into `namespacesListContinue` to obtain /// additional namespaces. Note that duplicate namespaces may be returned. /// @param hasMore Is true if there are additional namespaces that have not been /// returned yet. /// /// @return An initialized instance. /// - (instancetype)initWithNamespaces:(NSArray<DBTEAMNamespaceMetadata *> *)namespaces cursor:(NSString *)cursor hasMore:(NSNumber *)hasMore; - (instancetype)init NS_UNAVAILABLE; @end #pragma mark - Serializer Object /// /// The serialization class for the `TeamNamespacesListResult` struct. /// @interface DBTEAMTeamNamespacesListResultSerializer : NSObject /// /// Serializes `DBTEAMTeamNamespacesListResult` instances. /// /// @param instance An instance of the `DBTEAMTeamNamespacesListResult` API /// object. /// /// @return A json-compatible dictionary representation of the /// `DBTEAMTeamNamespacesListResult` API object. /// + (nullable NSDictionary *)serialize:(DBTEAMTeamNamespacesListResult *)instance; /// /// Deserializes `DBTEAMTeamNamespacesListResult` instances. /// /// @param dict A json-compatible dictionary representation of the /// `DBTEAMTeamNamespacesListResult` API object. /// /// @return An instantiation of the `DBTEAMTeamNamespacesListResult` object. /// + (DBTEAMTeamNamespacesListResult *)deserialize:(NSDictionary *)dict; @end NS_ASSUME_NONNULL_END
29.483871
83
0.7469
c5d02613ea185dc6209d8d7aca6a902add0e8f61
4,859
h
C
fw/bootloader/bootloader_dfu/dfu.h
foldedtoad/nRF51_IR_Temperature
9015f74794b8e5356c12c1c5909fd20afaf34191
[ "Apache-2.0" ]
7
2016-01-22T10:28:00.000Z
2021-03-20T19:23:58.000Z
fw/bootloader/bootloader_dfu/dfu.h
foldedtoad/nRF51_IR_Temperature
9015f74794b8e5356c12c1c5909fd20afaf34191
[ "Apache-2.0" ]
null
null
null
fw/bootloader/bootloader_dfu/dfu.h
foldedtoad/nRF51_IR_Temperature
9015f74794b8e5356c12c1c5909fd20afaf34191
[ "Apache-2.0" ]
2
2016-06-04T08:31:44.000Z
2018-01-03T14:38:10.000Z
/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. * * The information contained herein is property of Nordic Semiconductor ASA. * Terms and conditions of usage are described in detail in NORDIC * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. * * Licensees are granted free, non-transferable use of the information. NO * WARRANTY of ANY KIND is provided. This heading must NOT be removed from * the file. * */ /**@file * * @defgroup nrf_dfu Device Firmware Update API. * @{ * * @brief Device Firmware Update module interface. */ #ifndef DFU_H__ #define DFU_H__ #include "dfu_types.h" #include <stdbool.h> #include <stdint.h> /**@brief DFU event callback for asynchronous calls. * * @param[in] packet Packet type for which this callback is related. START_PACKET, DATA_PACKET. * @param[in] result Operation result code. NRF_SUCCESS when a queued operation was successful. * @param[in] p_data Pointer to the data to which the operation is related. */ typedef void (*dfu_callback_t)(uint32_t packet, uint32_t result, uint8_t * p_data); /**@brief Function for initializing the Device Firmware Update module. * * @return NRF_SUCCESS on success, an error_code otherwise. */ uint32_t dfu_init(void); /**@brief Function for registering a callback listener for \ref dfu_data_pkt_handle callbacks. * * @param[in] callback_handler Callback handler for receiving DFU events on completed operations * of DFU packets. */ void dfu_register_callback(dfu_callback_t callback_handler); /**@brief Function for setting the DFU image size. * * @details Function sets the DFU image size. This function must be called when an update is started * in order to notify the DFU of the new image size. If multiple images are to be * transferred within the same update context then this function must be called with size * information for each image being transfered. * If an image type is not being transfered, e.g. SoftDevice but no Application , then the * image size for application must be zero. * * @param[in] p_packet Pointer to the DFU packet containing information on DFU update process to * be started. * * @return NRF_SUCCESS on success, an error_code otherwise. */ uint32_t dfu_start_pkt_handle(dfu_update_packet_t * p_packet); /**@brief Function for handling DFU data packets. * * @param[in] p_packet Pointer to the DFU packet. * * @return NRF_SUCCESS on success, an error_code otherwise. */ uint32_t dfu_data_pkt_handle(dfu_update_packet_t * p_packet); /**@brief Function for handling DFU init packets. * * @return NRF_SUCCESS on success, an error_code otherwise. */ uint32_t dfu_init_pkt_handle(dfu_update_packet_t * p_packet); /**@brief Function for validating a transferred image after the transfer has completed. * * @return NRF_SUCCESS on success, an error_code otherwise. */ uint32_t dfu_image_validate(void); /**@brief Function for activating the transfered image after validation has successfully completed. * * @return NRF_SUCCESS on success, an error_code otherwise. */ uint32_t dfu_image_activate(void); /**@brief Function for reseting the current update procedure and return to initial state. * * @details This function call will result in a system reset to ensure correct system behavior. * The reset will might be scheduled to execute at a later point in time to ensure pending * flash operations has completed. */ void dfu_reset(void); /**@brief Function for validating that new bootloader has been correctly installed. * * @return NRF_SUCCESS if install was successful. NRF_ERROR_NULL if the images differs. */ uint32_t dfu_bl_image_validate(void); /**@brief Function for validating that new SoftDevicehas been correctly installed. * * @return NRF_SUCCESS if install was successful. NRF_ERROR_NULL if the images differs. */ uint32_t dfu_sd_image_validate(void); /**@brief Function for swapping existing bootloader with newly received. * * @return NRF_SUCCESS on succesfull swapping. For error code please refer to * \ref sd_mbr_command_copy_bl_t. */ uint32_t dfu_bl_image_swap(void); /**@brief Function for swapping existing SoftDevice with newly received. * * @return NRF_SUCCESS on succesfull swapping. For error code please refer to * \ref sd_mbr_command_copy_sd_t. */ uint32_t dfu_sd_image_swap(void); /**@brief Function for handling DFU init packet complete. * * @return NRF_SUCCESS on success, an error_code otherwise. */ uint32_t dfu_init_pkt_complete(void); #endif // DFU_H__ /** @} */
35.992593
102
0.710228
306680ad579130514dae8c876b21a57195e3b497
195
h
C
OneYuan/Class/Login/Controller/FindPswVC.h
taylorwen/Duobaodaka-master
36c551d2410338dd01ff79dc4fe3dbc9557eb1bd
[ "MIT" ]
null
null
null
OneYuan/Class/Login/Controller/FindPswVC.h
taylorwen/Duobaodaka-master
36c551d2410338dd01ff79dc4fe3dbc9557eb1bd
[ "MIT" ]
null
null
null
OneYuan/Class/Login/Controller/FindPswVC.h
taylorwen/Duobaodaka-master
36c551d2410338dd01ff79dc4fe3dbc9557eb1bd
[ "MIT" ]
null
null
null
// // FindPswVC.h // MasterDuoBao // // Created by zhan wen on 15/8/28. // Copyright (c) 2015年 wenzhan. All rights reserved. // #import "OneBaseVC.h" @interface FindPswVC : OneBaseVC @end
13.928571
53
0.666667
309a7628b6da19e1efff5818b4fc1f4a68500964
361
c
C
If-else/maxmin2digits.c
roysammy123/C-programs
260d669366f89989f7e4c0a0063319bf471b018d
[ "MIT" ]
2
2022-01-16T15:49:14.000Z
2022-01-20T07:41:05.000Z
If-else/maxmin2digits.c
roysammy123/C-Programs
260d669366f89989f7e4c0a0063319bf471b018d
[ "MIT" ]
null
null
null
If-else/maxmin2digits.c
roysammy123/C-Programs
260d669366f89989f7e4c0a0063319bf471b018d
[ "MIT" ]
null
null
null
//Program to display the maximum and minimum of 2 digits #include<stdio.h> int main() { int a,b; printf("Enter two numbers\n"); scanf("%d%d",&a,&b); if(a>b){ printf("Max is %d\n",a); printf("Min is %d",b); } else{ printf("Max is %d\n",b); printf("Min is %d",a); } return 0; }
18.05
57
0.470914
cf6eadc61245b1563454a7532724252ac351574e
8,136
h
C
copasi/model/CMoiety.h
bmoreau/COPASI
d0bbec8947b1266ffd2b0ecf2566da7cf2c3e5ba
[ "Artistic-2.0" ]
null
null
null
copasi/model/CMoiety.h
bmoreau/COPASI
d0bbec8947b1266ffd2b0ecf2566da7cf2c3e5ba
[ "Artistic-2.0" ]
null
null
null
copasi/model/CMoiety.h
bmoreau/COPASI
d0bbec8947b1266ffd2b0ecf2566da7cf2c3e5ba
[ "Artistic-2.0" ]
null
null
null
// Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual // Properties, Inc., University of Heidelberg, and The University // of Manchester. // All rights reserved. // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual // Properties, Inc., EML Research, gGmbH, University of Heidelberg, // and The University of Manchester. // All rights reserved. // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual // Properties, Inc. and EML Research, gGmbH. // All rights reserved. /** * CMoiety * * New class created for Copasi by Stefan Hoops * (C) Stefan Hoops 2001 */ #ifndef COPASI_CMoiety #define COPASI_CMoiety #include <string> #include <vector> #include "copasi/model/CChemEqElement.h" #include "copasi/utilities/CCopasiVector.h" #include "copasi/report/CCopasiObjectReference.h" class CMetab; class CTotalNumberReference : public CCopasiObjectReference< C_FLOAT64 > { /** * Hidden default constructor */ CTotalNumberReference(); public: /** * Specific constructor * @param const std::string & name * @param const CCopasiContainer * pParent, * @param C_FLOAT64 & reference, */ CTotalNumberReference(const std::string & name, const CCopasiContainer * pParent, C_FLOAT64 & reference); /** * Copy constructor * @param const CTotalNumberReference & src * @param const CCopasiContainer * pParent, */ CTotalNumberReference(const CTotalNumberReference & src, const CCopasiContainer * pParent); /** * Destructor */ ~CTotalNumberReference(); /** * Check whether a given object is a prerequisite for a context. * @param const CObjectInterface * pObject * @param const CMath::SimulationContextFlag & context * @param const CObjectInterface::ObjectSet & changedObjects * @return bool isPrerequisiteForContext */ virtual bool isPrerequisiteForContext(const CObjectInterface * pObject, const CMath::SimulationContextFlag & context, const CObjectInterface::ObjectSet & changedObjects) const; }; class CDependentNumberReference : public CCopasiObjectReference< C_FLOAT64 > { /** * Hidden default constructor */ CDependentNumberReference(); public: /** * Specific constructor * @param const std::string & name * @param const CCopasiContainer * pParent, * @param C_FLOAT64 & reference, */ CDependentNumberReference(const std::string & name, const CCopasiContainer * pParent, C_FLOAT64 & reference); /** * Copy constructor * @param const CDependentNumberReference & src * @param const CCopasiContainer * pParent, */ CDependentNumberReference(const CDependentNumberReference & src, const CCopasiContainer * pParent); /** * Destructor */ ~CDependentNumberReference(); /** * Check whether a given object is a prerequisite for a context. * @param const CObjectInterface * pObject * @param const CMath::SimulationContextFlag & context * @param const CObjectInterface::ObjectSet & changedObjects * @return bool isPrerequisiteForContext */ virtual bool isPrerequisiteForContext(const CObjectInterface * pObject, const CMath::SimulationContextFlag & context, const CObjectInterface::ObjectSet & changedObjects) const; }; class CMoiety : public CCopasiContainer { // Attributes private: /** * The default conversion factor used if the moiety is not part of a model */ static const C_FLOAT64 DefaultFactor; /** * The key of the moiety */ std::string mKey; //By G /** * Number of Particles of Moiety. */ C_FLOAT64 mNumber; /** * Initial Number of Particles of Moiety. */ C_FLOAT64 mINumber; /** * The total Amount of the Moiety. */ C_FLOAT64 mIAmount; /** * Vector of linear dependent CChemEqElement * @supplierCardinality 0..* */ /** @dia:route 7,3; h,41.0337,110.831,46.5202,117.862,52.0066 */ // CCopasiVector < CChemEqElement > mEquation; std::vector<std::pair< C_FLOAT64, CMetab * > > mEquation; /** * A pointer to the object for the initial total particle number */ CTotalNumberReference *mpINumberReference; /** * A pointer to the object for the total particle number * This is used during events */ CTotalNumberReference *mpNumberReference; /** * A pointer to the object for the dependent particle number */ CDependentNumberReference *mpDNumberReference; /** * A pointer to the conversion factor between the particle number and the amount. */ const C_FLOAT64 * mpConversionFactor; // Operations public: /** * Default constructor * @param const std::string & name (default: "NoName") * @param const CCopasiContainer * pParent (default: NULL) */ CMoiety(const std::string & name = "NoName", const CCopasiContainer * pParent = NULL); /** * Copy constructor * @param "const CMoiety &" src * @param const CCopasiContainer * pParent (default: NULL) */ CMoiety(const CMoiety & src, const CCopasiContainer * pParent = NULL); /** * Destructor */ ~CMoiety(); /** * Add a metabolite to a moiety * @param C_FLOAT64 value * @param CMetab * metabolite */ void add(C_FLOAT64 value, CMetab * metabolite); /** * */ void cleanup(); /** * Refresh the initial total particle number */ void refreshInitialValue(); /** * Retrieve the object for the total particle number * @return CCopasiObject * initialValueReference */ CCopasiObject * getInitialValueReference() const; /** * Refresh the total particle number */ void refreshValue(); /** * Retrieve the object for the total particle number * @return CCopasiObject * valueReference */ CCopasiObject * getValueReference() const; /** * get the string representation of the moiety using the CMetabNameInterface */ std::string getDescription(const CModel* model) const; /** * Retrieve and refresh the dependent number; * @return const C_FLOAT64 & dependentNumber */ const C_FLOAT64 & dependentNumber(); /** * Retrieve the dependent number; * @return const C_FLOAT64 & dependentNumber */ const C_FLOAT64 & getDependentNumber() const; /** * Retrieve the object for the dependent particle number * @return CCopasiObject * totalNumberReference */ CCopasiObject * getTotalNumberReference() const; /** * Retrieve the object for the dependent particle number * @return CCopasiObject * dependentNumberReference */ CCopasiObject * getDependentNumberReference() const; /** * */ C_FLOAT64 getNumber() const; /** * Returns a string with the name of this compartment. * @return std::string key */ virtual const std::string & getKey() const; //By G /** * Sets the parent of the moiety; * @param const CCopasiContainer * pParent * @return bool success */ virtual bool setObjectParent(const CCopasiContainer * pParent); /** * Refreshes the value of the dependent number */ void refreshDependentNumber(); /** * Retrieve the infix expression, which can be used to calculate the * total amount. * @return std::string expression */ std::string getExpression() const; /** * Retrieve the total amount * @return const C_FLOAT64 & amount */ const C_FLOAT64 & getAmount() const; /** * Refresh the total amount */ void refreshAmount(); /** * Retrieve the components of the total mass equation * @return const std::vector<std::pair< C_FLOAT64, CMetab * > > & equation */ const std::vector<std::pair< C_FLOAT64, CMetab * > > & getEquation() const; private: /** * Initialize the contained CCopasiObjects */ void initObjects(); /** * Initialize the number to amount conversion factor */ void initConversionFactor(); }; #endif // COPASI_CMoiety
25.188854
98
0.662979
d68d911196e5a7e957c136046cfe8a9a743b9b6c
1,072
h
C
encfs/i18n.h
penma/findvolkey
a7f70e856fe2f03761e4967246a6ffa5bab7f2d8
[ "OpenSSL" ]
6
2020-04-08T11:50:00.000Z
2021-08-08T03:23:58.000Z
encfs/i18n.h
penma/findvolkey
a7f70e856fe2f03761e4967246a6ffa5bab7f2d8
[ "OpenSSL" ]
3
2020-04-08T11:54:37.000Z
2020-04-10T22:39:13.000Z
encfs/i18n.h
penma/findvolkey
a7f70e856fe2f03761e4967246a6ffa5bab7f2d8
[ "OpenSSL" ]
2
2020-04-08T16:14:28.000Z
2020-04-08T16:15:55.000Z
/***************************************************************************** * Author: Valient Gough <vgough@pobox.com> * ***************************************************************************** * Copyright (c) 2004, Valient Gough * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _i18n_incl_ #define _i18n_incl_ #include "config.h" #include "intl/gettext.h" // make shortcut for gettext #define _(STR) gettext(STR) #endif
34.580645
79
0.630597
fdc26b8fc360ec87ecf2242590ceb3f421eb2483
2,234
h
C
psol/include/net/instaweb/rewriter/public/single_rewrite_context.h
creativeprogramming/ngx_pagespeed
85a36b8133a1dc8fbb24afecacfb0a2c05616605
[ "Apache-2.0" ]
1
2019-06-12T19:54:57.000Z
2019-06-12T19:54:57.000Z
psol/include/net/instaweb/rewriter/public/single_rewrite_context.h
creativeprogramming/ngx_pagespeed
85a36b8133a1dc8fbb24afecacfb0a2c05616605
[ "Apache-2.0" ]
null
null
null
psol/include/net/instaweb/rewriter/public/single_rewrite_context.h
creativeprogramming/ngx_pagespeed
85a36b8133a1dc8fbb24afecacfb0a2c05616605
[ "Apache-2.0" ]
null
null
null
/* * Copyright 2011 Google 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. */ // Author: jmarantz@google.com (Joshua Marantz) #ifndef NET_INSTAWEB_REWRITER_PUBLIC_SINGLE_REWRITE_CONTEXT_H_ #define NET_INSTAWEB_REWRITER_PUBLIC_SINGLE_REWRITE_CONTEXT_H_ #include "net/instaweb/rewriter/public/resource.h" #include "net/instaweb/rewriter/public/server_context.h" #include "net/instaweb/rewriter/public/rewrite_context.h" #include "net/instaweb/util/public/basictypes.h" namespace net_instaweb { class CachedResult; class OutputPartitions; class ResourceContext; class RewriteDriver; // Class that unifies tasks common to building rewriters for filters // that only do one-for-one URL substitutions. class SingleRewriteContext : public RewriteContext { public: // Transfers ownership of resource_context, which must be NULL or // allocated with 'new'. SingleRewriteContext(RewriteDriver* driver, RewriteContext* parent, ResourceContext* resource_context); virtual ~SingleRewriteContext(); protected: // Subclasses of SingleRewriteContext must override this: virtual void RewriteSingle(const ResourcePtr& input, const OutputResourcePtr& output) = 0; // SingleRewriteContext takes care of these methods from RewriteContext: virtual bool Partition(OutputPartitions* partitions, OutputResourceVector* outputs); virtual void Rewrite(int partition_index, CachedResult* partition, const OutputResourcePtr& output); private: DISALLOW_COPY_AND_ASSIGN(SingleRewriteContext); }; } // namespace net_instaweb #endif // NET_INSTAWEB_REWRITER_PUBLIC_SINGLE_REWRITE_CONTEXT_H_
35.460317
75
0.749776
a971a532227f9e4a3b309836e3761b6b4b5a1819
3,906
h
C
cinnrt/host_context/value.h
Aurelius84/CINN
2de029387f7526f0a46d5bed9060d7e8f7a70767
[ "Apache-2.0" ]
null
null
null
cinnrt/host_context/value.h
Aurelius84/CINN
2de029387f7526f0a46d5bed9060d7e8f7a70767
[ "Apache-2.0" ]
null
null
null
cinnrt/host_context/value.h
Aurelius84/CINN
2de029387f7526f0a46d5bed9060d7e8f7a70767
[ "Apache-2.0" ]
null
null
null
#pragma once #include <glog/logging.h> #include <llvm/ADT/SmallVector.h> #include <utility> #include <vector> #include "cinnrt/common/object.h" #include "cinnrt/common/shared.h" #include "cinnrt/host_context/function.h" #include "cinnrt/support/variant.h" #include "cinnrt/tensor/dense_host_tensor.h" #include "cinnrt/tensor/dense_tensor_view.h" #include "cinnrt/tensor/tensor_shape.h" namespace cinnrt { namespace host_context { struct MlirFunctionExecutable; using ValueVariantType = cinnrt::Variant<int16_t, int32_t, int64_t, float, double, bool, tensor::TensorShape, tensor::DenseHostTensor, MlirFunctionExecutable*, std::vector<int16_t>, std::vector<int32_t>, std::vector<int64_t>, std::vector<float>, std::vector<double>>; //! Copy content from \param from to \param to. void CopyTo(const Value& from, Value* to); /** * Represents any data type for value in host context. */ class Value : public cinnrt::common::Object { public: using variant_type = ValueVariantType; explicit Value() {} // NOLINT explicit Value(int32_t x) : data(x) {} explicit Value(int64_t x) : data(x) {} explicit Value(float x) : data(x) {} explicit Value(double x) : data(x) {} explicit Value(bool x) : data(x) {} explicit Value(std::vector<int16_t>&& x) : data(x) {} explicit Value(std::vector<int32_t>&& x) : data(x) {} explicit Value(std::vector<int64_t>&& x) : data(x) {} explicit Value(std::vector<float>&& x) : data(x) {} explicit Value(std::vector<double>&& x) : data(x) {} explicit Value(tensor::TensorShape&& x) : data(std::move(x)) {} explicit Value(tensor::DenseHostTensor&& x) : data(std::move(x)) {} explicit Value(MlirFunctionExecutable* x) : data(x) {} template <typename T> const T& get() const { return data.get<T>(); } template <typename T> T& get() { return data.get<T>(); } template <typename T> void set(T&& v) { data = std::move(v); } void set(Value* v) { data = std::move(v->data); } bool valid() const { return true; } const char* type_info() const override; friend void CopyTo(const Value& from, Value* to); private: ValueVariantType data; static constexpr const char* __type_info__ = "host_context_value"; }; /** * Represents a counted reference of a Value. */ class ValueRef : cinnrt::common::Shared<Value> { public: ValueRef() = default; explicit ValueRef(Value* n) : cinnrt::common::Shared<Value>(n) {} explicit ValueRef(int32_t val); explicit ValueRef(int64_t val); explicit ValueRef(float val); explicit ValueRef(double val); explicit ValueRef(bool val); using cinnrt::common::Shared<Value>::get; using cinnrt::common::Shared<Value>::Reset; using cinnrt::common::Shared<Value>::operator->; using cinnrt::common::Shared<Value>::operator*; //! Get a readonly data. template <typename T> const T& get() const { CHECK(p_); return p_->get<T>(); } template <typename T> T& get() { CHECK(p_); return p_->get<T>(); } //! Assign a data. template <typename T> void Assign(const T& x) { if (!p_) { p_ = cinnrt::common::make_shared<Value>(); } *p_ = x; } template <typename T, typename... Args> void Assign(Args... args) { p_ = cinnrt::common::make_shared<T>(std::forward<Args>(args)...); } inline bool IsValid() { return p_; } }; } // namespace host_context } // namespace cinnrt
28.510949
69
0.577829
a98a4bcc7f2e05de44620dd20e7b2f65b03d3c79
7,272
c
C
tf/adst/aom_dsp/prob.c
luctrudeau/VideoExperiments
4c44007886c64e40c9204c9d4617df158dc6c18f
[ "MIT" ]
4
2018-11-23T02:04:13.000Z
2021-06-08T13:49:16.000Z
tf/adst/aom_dsp/prob.c
luctrudeau/VideoExperiments
4c44007886c64e40c9204c9d4617df158dc6c18f
[ "MIT" ]
1
2016-05-18T17:03:30.000Z
2016-05-19T18:01:38.000Z
tf/adst/aom_dsp/prob.c
luctrudeau/VideoExperiments
4c44007886c64e40c9204c9d4617df158dc6c18f
[ "MIT" ]
3
2016-04-07T14:40:11.000Z
2017-01-27T17:46:08.000Z
/* * Copyright (c) 2016, Alliance for Open Media. All rights reserved * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License * was not distributed with this source code in the LICENSE file, you can * obtain it at www.aomedia.org/license/software. If the Alliance for Open * Media Patent License 1.0 was not distributed with this source code in the * PATENTS file, you can obtain it at www.aomedia.org/license/patent. */ #include "./aom_config.h" #if CONFIG_EC_MULTISYMBOL #include <string.h> #endif #include "aom_dsp/prob.h" #if CONFIG_DAALA_EC #include "aom_dsp/entcode.h" #endif const uint8_t aom_norm[256] = { 0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static unsigned int tree_merge_probs_impl(unsigned int i, const aom_tree_index *tree, const aom_prob *pre_probs, const unsigned int *counts, aom_prob *probs) { const int l = tree[i]; const unsigned int left_count = (l <= 0) ? counts[-l] : tree_merge_probs_impl(l, tree, pre_probs, counts, probs); const int r = tree[i + 1]; const unsigned int right_count = (r <= 0) ? counts[-r] : tree_merge_probs_impl(r, tree, pre_probs, counts, probs); const unsigned int ct[2] = { left_count, right_count }; probs[i >> 1] = mode_mv_merge_probs(pre_probs[i >> 1], ct); return left_count + right_count; } void aom_tree_merge_probs(const aom_tree_index *tree, const aom_prob *pre_probs, const unsigned int *counts, aom_prob *probs) { tree_merge_probs_impl(0, tree, pre_probs, counts, probs); } #if CONFIG_EC_MULTISYMBOL typedef struct tree_node tree_node; struct tree_node { aom_tree_index index; uint8_t probs[16]; uint8_t prob; int path; int len; int l; int r; aom_cdf_prob pdf; }; /* Compute the probability of this node in Q23 */ static uint32_t tree_node_prob(tree_node n, int i) { uint32_t prob; /* 1.0 in Q23 */ prob = 16777216; for (; i < n.len; i++) { prob = prob * n.probs[i] >> 8; } return prob; } static int tree_node_cmp(tree_node a, tree_node b) { int i; uint32_t pa; uint32_t pb; for (i = 0; i < AOMMIN(a.len, b.len) && a.probs[i] == b.probs[i]; i++) { } pa = tree_node_prob(a, i); pb = tree_node_prob(b, i); return pa > pb ? 1 : pa < pb ? -1 : 0; } /* Given a Q15 probability for symbol subtree rooted at tree[n], this function computes the probability of each symbol (defined as a node that has no children). */ static aom_cdf_prob tree_node_compute_probs(tree_node *tree, int n, aom_cdf_prob pdf) { if (tree[n].l == 0) { /* This prevents probability computations in Q15 that underflow from producing a symbol that has zero probability. */ if (pdf == 0) pdf = 1; tree[n].pdf = pdf; return pdf; } else { /* We process the smaller probability first, */ if (tree[n].prob < 128) { aom_cdf_prob lp; aom_cdf_prob rp; lp = (((uint32_t)pdf) * tree[n].prob + 128) >> 8; lp = tree_node_compute_probs(tree, tree[n].l, lp); rp = tree_node_compute_probs(tree, tree[n].r, lp > pdf ? 0 : pdf - lp); return lp + rp; } else { aom_cdf_prob rp; aom_cdf_prob lp; rp = (((uint32_t)pdf) * (256 - tree[n].prob) + 128) >> 8; rp = tree_node_compute_probs(tree, tree[n].r, rp); lp = tree_node_compute_probs(tree, tree[n].l, rp > pdf ? 0 : pdf - rp); return lp + rp; } } } static int tree_node_extract(tree_node *tree, int n, int symb, aom_cdf_prob *pdf, aom_tree_index *index, int *path, int *len) { if (tree[n].l == 0) { pdf[symb] = tree[n].pdf; if (index != NULL) index[symb] = tree[n].index; if (path != NULL) path[symb] = tree[n].path; if (len != NULL) len[symb] = tree[n].len; return symb + 1; } else { symb = tree_node_extract(tree, tree[n].l, symb, pdf, index, path, len); return tree_node_extract(tree, tree[n].r, symb, pdf, index, path, len); } } int tree_to_cdf(const aom_tree_index *tree, const aom_prob *probs, aom_tree_index root, aom_cdf_prob *cdf, aom_tree_index *index, int *path, int *len) { tree_node symb[2 * 16 - 1]; int nodes; int next[16]; int size; int nsymbs; int i; /* Create the root node with probability 1 in Q15. */ symb[0].index = root; symb[0].path = 0; symb[0].len = 0; symb[0].l = symb[0].r = 0; nodes = 1; next[0] = 0; size = 1; nsymbs = 1; while (size > 0 && nsymbs < 16) { int m; tree_node n; aom_tree_index j; uint8_t prob; m = 0; /* Find the internal node with the largest probability. */ for (i = 1; i < size; i++) { if (tree_node_cmp(symb[next[i]], symb[next[m]]) > 0) m = i; } i = next[m]; memmove(&next[m], &next[m + 1], sizeof(*next) * (size - (m + 1))); size--; /* Split this symbol into two symbols */ n = symb[i]; j = n.index; prob = probs[j >> 1]; /* Left */ n.index = tree[j]; n.path <<= 1; n.len++; n.probs[n.len - 1] = prob; symb[nodes] = n; if (n.index > 0) { next[size++] = nodes; } /* Right */ n.index = tree[j + 1]; n.path += 1; n.probs[n.len - 1] = 256 - prob; symb[nodes + 1] = n; if (n.index > 0) { next[size++] = nodes + 1; } symb[i].prob = prob; symb[i].l = nodes; symb[i].r = nodes + 1; nodes += 2; nsymbs++; } /* Compute the probabilities of each symbol in Q15 */ tree_node_compute_probs(symb, 0, 32768); /* Extract the cdf, index, path and length */ tree_node_extract(symb, 0, 0, cdf, index, path, len); /* Convert to CDF */ for (i = 1; i < nsymbs; i++) { cdf[i] = cdf[i - 1] + cdf[i]; } return nsymbs; } /* This code assumes that tree contains as unique leaf nodes the integer values 0 to len - 1 and produces the forward and inverse mapping tables in ind[] and inv[] respectively. */ void av1_indices_from_tree(int *ind, int *inv, int len, const aom_tree_index *tree) { int i; int index; for (i = index = 0; i < TREE_SIZE(len); i++) { const aom_tree_index j = tree[i]; if (j <= 0) { inv[index] = -j; ind[-j] = index++; } } } #endif
32.035242
80
0.555418
458e0fff9385f7f0075d556f8bc2e969c910f094
862
h
C
c-core/tests/pepon-teston/teston/src/c_teston.h
yuneta/tests-y
8324355748eb402382126223705939da4a9bbb42
[ "MIT" ]
null
null
null
c-core/tests/pepon-teston/teston/src/c_teston.h
yuneta/tests-y
8324355748eb402382126223705939da4a9bbb42
[ "MIT" ]
null
null
null
c-core/tests/pepon-teston/teston/src/c_teston.h
yuneta/tests-y
8324355748eb402382126223705939da4a9bbb42
[ "MIT" ]
null
null
null
/**************************************************************************** * C_TESTON.H * Teston GClass. * * Teston, yuno client de pruebas * * Copyright (c) 2018 by Niyamaka. * All Rights Reserved. ****************************************************************************/ #pragma once #include <yuneta.h> #ifdef __cplusplus extern "C"{ #endif /*************************************************************** * Constants ***************************************************************/ #define GCLASS_TESTON_NAME "Teston" #define GCLASS_TESTON gclass_teston() /*************************************************************** * Prototypes ***************************************************************/ PUBLIC GCLASS *gclass_teston(void); #ifdef __cplusplus } #endif
26.9375
78
0.313225
04c5c359693847d40455307c317a2dc4a9575ee3
3,911
c
C
src/syscall.c
owhao/syscall
baed4456f7423f8391af533b128f6c5bb13e8ca2
[ "MIT" ]
1
2019-03-24T10:54:13.000Z
2019-03-24T10:54:13.000Z
src/syscall.c
owhao/syscall
baed4456f7423f8391af533b128f6c5bb13e8ca2
[ "MIT" ]
null
null
null
src/syscall.c
owhao/syscall
baed4456f7423f8391af533b128f6c5bb13e8ca2
[ "MIT" ]
null
null
null
#include "syscall.h" #define BUF_SIZE 256 static void** syscall_tables = NULL; static struct syscall_hook* syscall_hooks = NULL; static char* syscall_get_kernel_version(char* buf, size_t length) { char *kernel_version = NULL; struct file *file = NULL; file = filp_open("/proc/version", O_RDONLY, 0); if (IS_ERR(file) || NULL == file) { return NULL; } memset(buf, 0, length); vfs_read(file, buf, length, &(file->f_pos)); kernel_version = strsep(&buf, " "); kernel_version = strsep(&buf, " "); kernel_version = strsep(&buf, " "); filp_close(file, 0); return kernel_version; } static void** syscall_get_syscall_tables(char* kernel_version) { char buf[BUF_SIZE]; size_t buf_offset = 0; const char filename_prefix[] = "/boot/System.map-"; struct file *file = NULL; char *filename = NULL; void *table = NULL; int ret; size_t filename_length = strlen(kernel_version) + strlen(filename_prefix) + 1; filename = kmalloc(filename_length, GFP_KERNEL); if (NULL == filename) { return NULL; } memset(filename, 0, filename_length); strncpy(filename, filename_prefix, strlen(filename_prefix)); strncat(filename, kernel_version, strlen(kernel_version)); file = filp_open(filename, O_RDONLY, 0); if (IS_ERR(file) || NULL == file) { kfree(filename); return NULL; } memset(buf, 0, BUF_SIZE); while (vfs_read(file, buf + buf_offset, 1, &file->f_pos) == 1) { if (buf_offset == BUF_SIZE - 1 || buf[buf_offset] == '\n') { if (strstr(buf, "sys_call_table") != NULL) { char *ptr = buf; char *addr = strsep(&ptr, " "); if (NULL != addr) { ret = kstrtoul(addr, 16, (unsigned long*)&table); } break; } memset(buf, 0, BUF_SIZE); buf_offset = 0; continue; } ++buf_offset; } filp_close(file, 0); kfree(filename); return (void **)table; } static int syscall_lazy(void) { if (NULL == syscall_tables) { char buf[BUF_SIZE], *kernel_version = NULL; mm_segment_t seg; seg = get_fs(); set_fs(KERNEL_DS); kernel_version = syscall_get_kernel_version(buf, BUF_SIZE); if (NULL != kernel_version) { syscall_tables = syscall_get_syscall_tables(kernel_version); } set_fs(seg); } return (syscall_tables ? 0 : -EFAULT); } int syscall_hook(struct syscall_hook hooks[]) { int ret; struct syscall_hook *entry; if (syscall_hooks) { return -EALREADY; } ret = syscall_lazy(); if (ret) { return ret; } syscall_hooks = hooks; write_cr0 (read_cr0 () & (~ 0x10000)); for (entry = hooks; entry->name; ++entry) { if (!entry->hooked) { entry->old_addr = (void *)syscall_tables[entry->nr]; syscall_tables[entry->nr] = entry->new_addr; entry->hooked = true; } } write_cr0 (read_cr0 () | 0x10000); return 0; } int syscall_unhook(void) { if (syscall_tables && syscall_hooks) { struct syscall_hook *entry; write_cr0 (read_cr0 () & (~ 0x10000)); for (entry = syscall_hooks; entry->name; ++entry) { if (entry->hooked) { syscall_tables[entry->nr] = entry->old_addr; entry->hooked = false; } } write_cr0 (read_cr0 () | 0x10000); } return 0; } struct syscall_hook* syscall_hook_get(int nr) { if (syscall_hooks) { struct syscall_hook *entry; for (entry = syscall_hooks; entry->name; ++entry) { if (entry->nr == nr) return entry; } } return NULL; }
23.70303
72
0.556635
e79449c5ad76d102e7e41044079f6e889960c310
1,283
h
C
Source/Storm-ModelBase/include/SceneSimulationConfig.h
SunlayGGX/Storm
83a34c14cc7d936347b6b8193a64cd13ccbf00a8
[ "MIT" ]
3
2021-11-27T04:56:12.000Z
2022-02-14T04:02:10.000Z
Source/Storm-ModelBase/include/SceneSimulationConfig.h
SunlayGGX/Storm
83a34c14cc7d936347b6b8193a64cd13ccbf00a8
[ "MIT" ]
null
null
null
Source/Storm-ModelBase/include/SceneSimulationConfig.h
SunlayGGX/Storm
83a34c14cc7d936347b6b8193a64cd13ccbf00a8
[ "MIT" ]
null
null
null
#pragma once namespace Storm { enum class SimulationMode; enum class KernelMode; enum class ViscosityMethod; enum class ParticleRemovalMode; struct SceneSimulationConfig { public: SceneSimulationConfig(); public: Storm::Vector3 _gravity; float _particleRadius; Storm::KernelMode _kernelMode; float _kernelCoefficient; float _kernelIncrementSpeedInSeconds; float _maxKernelIncrementCoeff; float _cflCoeff; float _maxCFLTime; int _maxCFLIteration; bool _computeCFL; float _physicsTimeInSec; float _expectedFps; bool _midUpdateViscosity; bool _startPaused; bool _simulationNoWait; unsigned char _recomputeNeighborhoodStep; Storm::SimulationMode _simulationMode; std::string _simulationModeStr; Storm::ViscosityMethod _fluidViscoMethod; Storm::ViscosityMethod _rbViscoMethod; bool _hasFluid; bool _fixRigidBodyAtStartTime; float _freeRbAtPhysicsTime; float _endSimulationPhysicsTimeInSeconds; bool _shouldRemoveRbCollidingPAtStateFileLoad; bool _considerRbWallAtCollingingPStateFileLoad; bool _removeFluidForVolumeConsistency; Storm::ParticleRemovalMode _fluidParticleRemovalMode; bool _noStickConstraint; bool _applyDragEffect; bool _useCoendaEffect; float _exitSimulationFloorLevel; }; }
19.149254
55
0.806703
315579877f259a2a147a839d004b8ff2d2da57a6
95
h
C
version.h
cleiner/quickjs
8786a5101e7d7e52c8c4bfd980ed5cbfe0315310
[ "MIT" ]
null
null
null
version.h
cleiner/quickjs
8786a5101e7d7e52c8c4bfd980ed5cbfe0315310
[ "MIT" ]
null
null
null
version.h
cleiner/quickjs
8786a5101e7d7e52c8c4bfd980ed5cbfe0315310
[ "MIT" ]
null
null
null
#ifndef _GUARD_H_PORT_H_ #define _GUARD_H_PORT_H_ #define CONFIG_VERSION "2020-11-08" #endif
13.571429
35
0.810526
2e84778815c1edd32e73d890334a4fd73dbc4f6e
2,564
h
C
PrivateFrameworks/HomeKitDaemon/HMDAccessoryProfile.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
17
2018-11-13T04:02:58.000Z
2022-01-20T09:27:13.000Z
PrivateFrameworks/HomeKitDaemon/HMDAccessoryProfile.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
3
2018-04-06T02:02:27.000Z
2018-10-02T01:12:10.000Z
PrivateFrameworks/HomeKitDaemon/HMDAccessoryProfile.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
1
2018-09-28T13:54:23.000Z
2018-09-28T13:54:23.000Z
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #import "HMFObject.h" #import "HMDBulletinIdentifiers.h" #import "HMDHomeMessageReceiver.h" #import "HMFDumpState.h" #import "HMFLogging.h" #import "NSSecureCoding.h" @class HMDAccessory, HMFMessageDispatcher, NSArray, NSObject<OS_dispatch_queue>, NSSet, NSString, NSUUID; @interface HMDAccessoryProfile : HMFObject <HMDBulletinIdentifiers, HMDHomeMessageReceiver, HMFDumpState, HMFLogging, NSSecureCoding> { HMFMessageDispatcher *_msgDispatcher; NSObject<OS_dispatch_queue> *_workQueue; NSUUID *_uniqueIdentifier; NSString *_logID; HMDAccessory *_accessory; NSArray *_services; } + (BOOL)supportsSecureCoding; + (BOOL)hasMessageReceiverChildren; + (id)logCategory; @property(readonly, nonatomic) NSArray *services; // @synthesize services=_services; @property(readonly) __weak HMDAccessory *accessory; // @synthesize accessory=_accessory; @property(readonly, nonatomic) NSString *logID; // @synthesize logID=_logID; @property(readonly, copy, nonatomic) NSUUID *uniqueIdentifier; // @synthesize uniqueIdentifier=_uniqueIdentifier; @property(readonly, nonatomic) HMFMessageDispatcher *msgDispatcher; // @synthesize msgDispatcher=_msgDispatcher; @property(readonly, nonatomic) NSObject<OS_dispatch_queue> *workQueue; // @synthesize workQueue=_workQueue; - (void).cxx_destruct; - (void)_encodeWithCoder:(id)arg1; - (void)encodeWithCoder:(id)arg1; - (id)initWithCoder:(id)arg1; - (id)findServiceWithType:(id)arg1; - (id)runtimeState; - (void)removeCloudData; - (void)unconfigure; - (void)configureWithMessageDispatcher:(id)arg1 configurationTracker:(id)arg2; - (void)handleInitialState; - (void)registerForMessages; @property(readonly, nonatomic) NSObject<OS_dispatch_queue> *messageReceiveQueue; @property(readonly, nonatomic) NSUUID *messageTargetUUID; - (id)logIdentifier; - (id)dumpState; - (BOOL)isEqual:(id)arg1; @property(readonly) unsigned long long hash; - (id)initWithAccessory:(id)arg1 uniqueIdentifier:(id)arg2 services:(id)arg3 workQueue:(id)arg4; - (id)initWithAccessory:(id)arg1 uniqueIdentifier:(id)arg2 services:(id)arg3; @property(readonly, copy, nonatomic) NSUUID *contextSPIUniqueIdentifier; @property(readonly, copy, nonatomic) NSString *contextID; // Remaining properties @property(readonly, copy) NSString *debugDescription; @property(readonly, copy) NSString *description; @property(readonly, copy) NSSet *messageReceiverChildren; @property(readonly) Class superclass; @end
38.848485
133
0.781981
c87d74daea3d64e0f8b0764e94af410d11fc262d
9,604
c
C
crypto/x509/x509_err.c
user-none/openssl
7a2027240e1d01f7f5b209998d1de36af221b34b
[ "Apache-2.0" ]
null
null
null
crypto/x509/x509_err.c
user-none/openssl
7a2027240e1d01f7f5b209998d1de36af221b34b
[ "Apache-2.0" ]
1
2019-07-07T12:15:57.000Z
2019-07-07T12:15:57.000Z
crypto/x509/x509_err.c
user-none/openssl
7a2027240e1d01f7f5b209998d1de36af221b34b
[ "Apache-2.0" ]
null
null
null
/* * Generated by util/mkerr.pl DO NOT EDIT * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #include <openssl/err.h> #include <openssl/x509err.h> #ifndef OPENSSL_NO_ERR static const ERR_STRING_DATA X509_str_functs[] = { {ERR_PACK(ERR_LIB_X509, X509_F_ADD_CERT_DIR, 0), "add_cert_dir"}, {ERR_PACK(ERR_LIB_X509, X509_F_BUILD_CHAIN, 0), "build_chain"}, {ERR_PACK(ERR_LIB_X509, X509_F_BY_FILE_CTRL, 0), "by_file_ctrl"}, {ERR_PACK(ERR_LIB_X509, X509_F_CHECK_NAME_CONSTRAINTS, 0), "check_name_constraints"}, {ERR_PACK(ERR_LIB_X509, X509_F_CHECK_POLICY, 0), "check_policy"}, {ERR_PACK(ERR_LIB_X509, X509_F_COMMON_VERIFY_SM2, 0), "common_verify_sm2"}, {ERR_PACK(ERR_LIB_X509, X509_F_DANE_I2D, 0), "dane_i2d"}, {ERR_PACK(ERR_LIB_X509, X509_F_DIR_CTRL, 0), "dir_ctrl"}, {ERR_PACK(ERR_LIB_X509, X509_F_GET_CERT_BY_SUBJECT, 0), "get_cert_by_subject"}, {ERR_PACK(ERR_LIB_X509, X509_F_I2D_X509_AUX, 0), "i2d_X509_AUX"}, {ERR_PACK(ERR_LIB_X509, X509_F_LOOKUP_CERTS_SK, 0), "lookup_certs_sk"}, {ERR_PACK(ERR_LIB_X509, X509_F_NETSCAPE_SPKI_B64_DECODE, 0), "NETSCAPE_SPKI_b64_decode"}, {ERR_PACK(ERR_LIB_X509, X509_F_NETSCAPE_SPKI_B64_ENCODE, 0), "NETSCAPE_SPKI_b64_encode"}, {ERR_PACK(ERR_LIB_X509, X509_F_NEW_DIR, 0), "new_dir"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509AT_ADD1_ATTR, 0), "X509at_add1_attr"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509V3_ADD_EXT, 0), "X509v3_add_ext"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_ATTRIBUTE_CREATE_BY_NID, 0), "X509_ATTRIBUTE_create_by_NID"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ, 0), "X509_ATTRIBUTE_create_by_OBJ"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_ATTRIBUTE_CREATE_BY_TXT, 0), "X509_ATTRIBUTE_create_by_txt"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_ATTRIBUTE_GET0_DATA, 0), "X509_ATTRIBUTE_get0_data"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_ATTRIBUTE_SET1_DATA, 0), "X509_ATTRIBUTE_set1_data"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_CHECK_PRIVATE_KEY, 0), "X509_check_private_key"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_CRL_DIFF, 0), "X509_CRL_diff"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_CRL_METHOD_NEW, 0), "X509_CRL_METHOD_new"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_CRL_PRINT_FP, 0), "X509_CRL_print_fp"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_EXTENSION_CREATE_BY_NID, 0), "X509_EXTENSION_create_by_NID"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_EXTENSION_CREATE_BY_OBJ, 0), "X509_EXTENSION_create_by_OBJ"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_GET_PUBKEY_PARAMETERS, 0), "X509_get_pubkey_parameters"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_LOAD_CERT_CRL_FILE, 0), "X509_load_cert_crl_file"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_LOAD_CERT_FILE, 0), "X509_load_cert_file"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_LOAD_CRL_FILE, 0), "X509_load_crl_file"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_LOOKUP_METH_NEW, 0), "X509_LOOKUP_meth_new"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_LOOKUP_NEW, 0), "X509_LOOKUP_new"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_NAME_ADD_ENTRY, 0), "X509_NAME_add_entry"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_NAME_CANON, 0), "x509_name_canon"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_NAME_ENTRY_CREATE_BY_NID, 0), "X509_NAME_ENTRY_create_by_NID"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_NAME_ENTRY_CREATE_BY_TXT, 0), "X509_NAME_ENTRY_create_by_txt"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_NAME_ENTRY_SET_OBJECT, 0), "X509_NAME_ENTRY_set_object"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_NAME_ONELINE, 0), "X509_NAME_oneline"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_NAME_PRINT, 0), "X509_NAME_print"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_OBJECT_NEW, 0), "X509_OBJECT_new"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_PRINT_EX_FP, 0), "X509_print_ex_fp"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_PUBKEY_DECODE, 0), "x509_pubkey_decode"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_PUBKEY_GET0, 0), "X509_PUBKEY_get0"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_PUBKEY_SET, 0), "X509_PUBKEY_set"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_REQ_CHECK_PRIVATE_KEY, 0), "X509_REQ_check_private_key"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_REQ_PRINT_EX, 0), "X509_REQ_print_ex"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_REQ_PRINT_FP, 0), "X509_REQ_print_fp"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_REQ_TO_X509, 0), "X509_REQ_to_X509"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_REQ_VERIFY, 0), "X509_REQ_verify"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_REQ_VERIFY_SM2, 0), "x509_req_verify_sm2"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_ADD_CERT, 0), "X509_STORE_add_cert"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_ADD_CRL, 0), "X509_STORE_add_crl"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_ADD_LOOKUP, 0), "X509_STORE_add_lookup"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_CTX_GET1_ISSUER, 0), "X509_STORE_CTX_get1_issuer"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_CTX_INIT, 0), "X509_STORE_CTX_init"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_CTX_NEW, 0), "X509_STORE_CTX_new"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_CTX_PURPOSE_INHERIT, 0), "X509_STORE_CTX_purpose_inherit"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_NEW, 0), "X509_STORE_new"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_TO_X509_REQ, 0), "X509_to_X509_REQ"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_TRUST_ADD, 0), "X509_TRUST_add"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_TRUST_SET, 0), "X509_TRUST_set"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_VERIFY, 0), "X509_verify"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_VERIFY_CERT, 0), "X509_verify_cert"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_VERIFY_PARAM_NEW, 0), "X509_VERIFY_PARAM_new"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_VERIFY_SM2, 0), "x509_verify_sm2"}, {0, NULL} }; static const ERR_STRING_DATA X509_str_reasons[] = { {ERR_PACK(ERR_LIB_X509, 0, X509_R_AKID_MISMATCH), "akid mismatch"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_BAD_SELECTOR), "bad selector"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_BAD_X509_FILETYPE), "bad x509 filetype"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_BASE64_DECODE_ERROR), "base64 decode error"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_CANT_CHECK_DH_KEY), "cant check dh key"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_CERT_ALREADY_IN_HASH_TABLE), "cert already in hash table"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_CRL_ALREADY_DELTA), "crl already delta"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_CRL_VERIFY_FAILURE), "crl verify failure"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_IDP_MISMATCH), "idp mismatch"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_INVALID_DIRECTORY), "invalid directory"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_INVALID_FIELD_NAME), "invalid field name"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_INVALID_TRUST), "invalid trust"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_ISSUER_MISMATCH), "issuer mismatch"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_KEY_TYPE_MISMATCH), "key type mismatch"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_KEY_VALUES_MISMATCH), "key values mismatch"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_LOADING_CERT_DIR), "loading cert dir"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_LOADING_DEFAULTS), "loading defaults"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_METHOD_NOT_SUPPORTED), "method not supported"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_NAME_TOO_LONG), "name too long"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_NEWER_CRL_NOT_NEWER), "newer crl not newer"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_NO_CERTIFICATE_FOUND), "no certificate found"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_NO_CERTIFICATE_OR_CRL_FOUND), "no certificate or crl found"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_NO_CERT_SET_FOR_US_TO_VERIFY), "no cert set for us to verify"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_NO_CRL_FOUND), "no crl found"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_NO_CRL_NUMBER), "no crl number"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_PUBLIC_KEY_DECODE_ERROR), "public key decode error"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_PUBLIC_KEY_ENCODE_ERROR), "public key encode error"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_SHOULD_RETRY), "should retry"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN), "unable to find parameters in chain"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY), "unable to get certs public key"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_UNKNOWN_KEY_TYPE), "unknown key type"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_UNKNOWN_NID), "unknown nid"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_UNKNOWN_PURPOSE_ID), "unknown purpose id"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_UNKNOWN_TRUST_ID), "unknown trust id"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_UNSUPPORTED_ALGORITHM), "unsupported algorithm"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_WRONG_LOOKUP_TYPE), "wrong lookup type"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_WRONG_TYPE), "wrong type"}, {0, NULL} }; #endif int ERR_load_X509_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(X509_str_functs[0].error) == NULL) { ERR_load_strings_const(X509_str_functs); ERR_load_strings_const(X509_str_reasons); } #endif return 1; }
51.085106
79
0.749792
085771c7639b6a4aaed005dcef5f305dc3fe7e4e
34,033
c
C
a10-soc-devkit-ghrd/software/uboot_bsp/uboot-socfpga/common/image.c
att-innovate/firework
0b9e03b8f9f7204c94362957210cb60f6080c74c
[ "MIT" ]
11
2020-11-12T15:24:45.000Z
2022-01-09T18:50:10.000Z
a10-soc-devkit-ghrd/software/uboot_bsp/uboot-socfpga/common/image.c
att-innovate/firework
0b9e03b8f9f7204c94362957210cb60f6080c74c
[ "MIT" ]
null
null
null
a10-soc-devkit-ghrd/software/uboot_bsp/uboot-socfpga/common/image.c
att-innovate/firework
0b9e03b8f9f7204c94362957210cb60f6080c74c
[ "MIT" ]
3
2019-07-25T18:41:15.000Z
2021-12-09T14:46:19.000Z
/* * (C) Copyright 2008 Semihalf * * (C) Copyright 2000-2006 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * SPDX-License-Identifier: GPL-2.0+ */ #ifndef USE_HOSTCC #include <common.h> #include <watchdog.h> #ifdef CONFIG_SHOW_BOOT_PROGRESS #include <status_led.h> #endif #ifdef CONFIG_HAS_DATAFLASH #include <dataflash.h> #endif #ifdef CONFIG_LOGBUFFER #include <logbuff.h> #endif #include <rtc.h> #include <environment.h> #include <image.h> #if defined(CONFIG_FIT) || defined(CONFIG_OF_LIBFDT) #include <libfdt.h> #include <fdt_support.h> #endif #include <u-boot/md5.h> #include <u-boot/sha1.h> #include <asm/errno.h> #include <asm/io.h> #ifdef CONFIG_CMD_BDI extern int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); #endif DECLARE_GLOBAL_DATA_PTR; #if defined(CONFIG_IMAGE_FORMAT_LEGACY) static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch, int verify); #endif #else #include "mkimage.h" #include <u-boot/md5.h> #include <time.h> #include <image.h> #endif /* !USE_HOSTCC*/ #include <u-boot/crc.h> #ifndef CONFIG_SYS_BARGSIZE #define CONFIG_SYS_BARGSIZE 512 #endif static const table_entry_t uimage_arch[] = { { IH_ARCH_INVALID, NULL, "Invalid ARCH", }, { IH_ARCH_ALPHA, "alpha", "Alpha", }, { IH_ARCH_ARM, "arm", "ARM", }, { IH_ARCH_I386, "x86", "Intel x86", }, { IH_ARCH_IA64, "ia64", "IA64", }, { IH_ARCH_M68K, "m68k", "M68K", }, { IH_ARCH_MICROBLAZE, "microblaze", "MicroBlaze", }, { IH_ARCH_MIPS, "mips", "MIPS", }, { IH_ARCH_MIPS64, "mips64", "MIPS 64 Bit", }, { IH_ARCH_NIOS2, "nios2", "NIOS II", }, { IH_ARCH_PPC, "powerpc", "PowerPC", }, { IH_ARCH_PPC, "ppc", "PowerPC", }, { IH_ARCH_S390, "s390", "IBM S390", }, { IH_ARCH_SH, "sh", "SuperH", }, { IH_ARCH_SPARC, "sparc", "SPARC", }, { IH_ARCH_SPARC64, "sparc64", "SPARC 64 Bit", }, { IH_ARCH_BLACKFIN, "blackfin", "Blackfin", }, { IH_ARCH_AVR32, "avr32", "AVR32", }, { IH_ARCH_NDS32, "nds32", "NDS32", }, { IH_ARCH_OPENRISC, "or1k", "OpenRISC 1000",}, { IH_ARCH_SANDBOX, "sandbox", "Sandbox", }, { IH_ARCH_ARM64, "arm64", "AArch64", }, { IH_ARCH_ARC, "arc", "ARC", }, { -1, "", "", }, }; static const table_entry_t uimage_os[] = { { IH_OS_INVALID, NULL, "Invalid OS", }, { IH_OS_LINUX, "linux", "Linux", }, #if defined(CONFIG_LYNXKDI) || defined(USE_HOSTCC) { IH_OS_LYNXOS, "lynxos", "LynxOS", }, #endif { IH_OS_NETBSD, "netbsd", "NetBSD", }, { IH_OS_OSE, "ose", "Enea OSE", }, { IH_OS_PLAN9, "plan9", "Plan 9", }, { IH_OS_RTEMS, "rtems", "RTEMS", }, { IH_OS_U_BOOT, "u-boot", "U-Boot", }, { IH_OS_VXWORKS, "vxworks", "VxWorks", }, #if defined(CONFIG_CMD_ELF) || defined(USE_HOSTCC) { IH_OS_QNX, "qnx", "QNX", }, #endif #if defined(CONFIG_INTEGRITY) || defined(USE_HOSTCC) { IH_OS_INTEGRITY,"integrity", "INTEGRITY", }, #endif #ifdef USE_HOSTCC { IH_OS_4_4BSD, "4_4bsd", "4_4BSD", }, { IH_OS_DELL, "dell", "Dell", }, { IH_OS_ESIX, "esix", "Esix", }, { IH_OS_FREEBSD, "freebsd", "FreeBSD", }, { IH_OS_IRIX, "irix", "Irix", }, { IH_OS_NCR, "ncr", "NCR", }, { IH_OS_OPENBSD, "openbsd", "OpenBSD", }, { IH_OS_PSOS, "psos", "pSOS", }, { IH_OS_SCO, "sco", "SCO", }, { IH_OS_SOLARIS, "solaris", "Solaris", }, { IH_OS_SVR4, "svr4", "SVR4", }, #endif { -1, "", "", }, }; static const table_entry_t uimage_type[] = { { IH_TYPE_AISIMAGE, "aisimage", "Davinci AIS image",}, { IH_TYPE_FILESYSTEM, "filesystem", "Filesystem Image", }, { IH_TYPE_FIRMWARE, "firmware", "Firmware", }, { IH_TYPE_FLATDT, "flat_dt", "Flat Device Tree", }, { IH_TYPE_GPIMAGE, "gpimage", "TI Keystone SPL Image",}, { IH_TYPE_KERNEL, "kernel", "Kernel Image", }, { IH_TYPE_KERNEL_NOLOAD, "kernel_noload", "Kernel Image (no loading done)", }, { IH_TYPE_KWBIMAGE, "kwbimage", "Kirkwood Boot Image",}, { IH_TYPE_IMXIMAGE, "imximage", "Freescale i.MX Boot Image",}, { IH_TYPE_INVALID, NULL, "Invalid Image", }, { IH_TYPE_MULTI, "multi", "Multi-File Image", }, { IH_TYPE_OMAPIMAGE, "omapimage", "TI OMAP SPL With GP CH",}, { IH_TYPE_PBLIMAGE, "pblimage", "Freescale PBL Boot Image",}, { IH_TYPE_RAMDISK, "ramdisk", "RAMDisk Image", }, { IH_TYPE_SCRIPT, "script", "Script", }, { IH_TYPE_SOCFPGAIMAGE, "socfpgaimage", "Altera SOCFPGA preloader",}, { IH_TYPE_STANDALONE, "standalone", "Standalone Program", }, { IH_TYPE_UBLIMAGE, "ublimage", "Davinci UBL image",}, { IH_TYPE_MXSIMAGE, "mxsimage", "Freescale MXS Boot Image",}, { IH_TYPE_ATMELIMAGE, "atmelimage", "ATMEL ROM-Boot Image",}, { -1, "", "", }, }; static const table_entry_t uimage_comp[] = { { IH_COMP_NONE, "none", "uncompressed", }, { IH_COMP_BZIP2, "bzip2", "bzip2 compressed", }, { IH_COMP_GZIP, "gzip", "gzip compressed", }, { IH_COMP_LZMA, "lzma", "lzma compressed", }, { IH_COMP_LZO, "lzo", "lzo compressed", }, { -1, "", "", }, }; /*****************************************************************************/ /* Legacy format routines */ /*****************************************************************************/ int image_check_hcrc(const image_header_t *hdr) { ulong hcrc; ulong len = image_get_header_size(); image_header_t header; /* Copy header so we can blank CRC field for re-calculation */ memmove(&header, (char *)hdr, image_get_header_size()); image_set_hcrc(&header, 0); hcrc = crc32(0, (unsigned char *)&header, len); return (hcrc == image_get_hcrc(hdr)); } int image_check_dcrc(const image_header_t *hdr) { ulong data = image_get_data(hdr); ulong len = image_get_data_size(hdr); ulong dcrc = crc32_wd(0, (unsigned char *)data, len, CHUNKSZ_CRC32); return (dcrc == image_get_dcrc(hdr)); } /** * image_multi_count - get component (sub-image) count * @hdr: pointer to the header of the multi component image * * image_multi_count() returns number of components in a multi * component image. * * Note: no checking of the image type is done, caller must pass * a valid multi component image. * * returns: * number of components */ ulong image_multi_count(const image_header_t *hdr) { ulong i, count = 0; uint32_t *size; /* get start of the image payload, which in case of multi * component images that points to a table of component sizes */ size = (uint32_t *)image_get_data(hdr); /* count non empty slots */ for (i = 0; size[i]; ++i) count++; return count; } /** * image_multi_getimg - get component data address and size * @hdr: pointer to the header of the multi component image * @idx: index of the requested component * @data: pointer to a ulong variable, will hold component data address * @len: pointer to a ulong variable, will hold component size * * image_multi_getimg() returns size and data address for the requested * component in a multi component image. * * Note: no checking of the image type is done, caller must pass * a valid multi component image. * * returns: * data address and size of the component, if idx is valid * 0 in data and len, if idx is out of range */ void image_multi_getimg(const image_header_t *hdr, ulong idx, ulong *data, ulong *len) { int i; uint32_t *size; ulong offset, count, img_data; /* get number of component */ count = image_multi_count(hdr); /* get start of the image payload, which in case of multi * component images that points to a table of component sizes */ size = (uint32_t *)image_get_data(hdr); /* get address of the proper component data start, which means * skipping sizes table (add 1 for last, null entry) */ img_data = image_get_data(hdr) + (count + 1) * sizeof(uint32_t); if (idx < count) { *len = uimage_to_cpu(size[idx]); offset = 0; /* go over all indices preceding requested component idx */ for (i = 0; i < idx; i++) { /* add up i-th component size, rounding up to 4 bytes */ offset += (uimage_to_cpu(size[i]) + 3) & ~3 ; } /* calculate idx-th component data address */ *data = img_data + offset; } else { *len = 0; *data = 0; } } static void image_print_type(const image_header_t *hdr) { const char *os, *arch, *type, *comp; os = genimg_get_os_name(image_get_os(hdr)); arch = genimg_get_arch_name(image_get_arch(hdr)); type = genimg_get_type_name(image_get_type(hdr)); comp = genimg_get_comp_name(image_get_comp(hdr)); printf("%s %s %s (%s)\n", arch, os, type, comp); } /** * image_print_contents - prints out the contents of the legacy format image * @ptr: pointer to the legacy format image header * @p: pointer to prefix string * * image_print_contents() formats a multi line legacy image contents description. * The routine prints out all header fields followed by the size/offset data * for MULTI/SCRIPT images. * * returns: * no returned results */ void image_print_contents(const void *ptr) { const image_header_t *hdr = (const image_header_t *)ptr; const char *p; p = IMAGE_INDENT_STRING; printf("%sImage Name: %.*s\n", p, IH_NMLEN, image_get_name(hdr)); if (IMAGE_ENABLE_TIMESTAMP) { printf("%sCreated: ", p); genimg_print_time((time_t)image_get_time(hdr)); } printf("%sImage Type: ", p); image_print_type(hdr); printf("%sData Size: ", p); genimg_print_size(image_get_data_size(hdr)); printf("%sLoad Address: %08x\n", p, image_get_load(hdr)); printf("%sEntry Point: %08x\n", p, image_get_ep(hdr)); if (image_check_type(hdr, IH_TYPE_MULTI) || image_check_type(hdr, IH_TYPE_SCRIPT)) { int i; ulong data, len; ulong count = image_multi_count(hdr); printf("%sContents:\n", p); for (i = 0; i < count; i++) { image_multi_getimg(hdr, i, &data, &len); printf("%s Image %d: ", p, i); genimg_print_size(len); if (image_check_type(hdr, IH_TYPE_SCRIPT) && i > 0) { /* * the user may need to know offsets * if planning to do something with * multiple files */ printf("%s Offset = 0x%08lx\n", p, data); } } } } #ifndef USE_HOSTCC #if defined(CONFIG_IMAGE_FORMAT_LEGACY) /** * image_get_ramdisk - get and verify ramdisk image * @rd_addr: ramdisk image start address * @arch: expected ramdisk architecture * @verify: checksum verification flag * * image_get_ramdisk() returns a pointer to the verified ramdisk image * header. Routine receives image start address and expected architecture * flag. Verification done covers data and header integrity and os/type/arch * fields checking. * * If dataflash support is enabled routine checks for dataflash addresses * and handles required dataflash reads. * * returns: * pointer to a ramdisk image header, if image was found and valid * otherwise, return NULL */ static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch, int verify) { const image_header_t *rd_hdr = (const image_header_t *)rd_addr; if (!image_check_magic(rd_hdr)) { puts("Bad Magic Number\n"); bootstage_error(BOOTSTAGE_ID_RD_MAGIC); return NULL; } if (!image_check_hcrc(rd_hdr)) { puts("Bad Header Checksum\n"); bootstage_error(BOOTSTAGE_ID_RD_HDR_CHECKSUM); return NULL; } bootstage_mark(BOOTSTAGE_ID_RD_MAGIC); image_print_contents(rd_hdr); if (verify) { puts(" Verifying Checksum ... "); if (!image_check_dcrc(rd_hdr)) { puts("Bad Data CRC\n"); bootstage_error(BOOTSTAGE_ID_RD_CHECKSUM); return NULL; } puts("OK\n"); } bootstage_mark(BOOTSTAGE_ID_RD_HDR_CHECKSUM); if (!image_check_os(rd_hdr, IH_OS_LINUX) || !image_check_arch(rd_hdr, arch) || !image_check_type(rd_hdr, IH_TYPE_RAMDISK)) { printf("No Linux %s Ramdisk Image\n", genimg_get_arch_name(arch)); bootstage_error(BOOTSTAGE_ID_RAMDISK); return NULL; } return rd_hdr; } #endif #endif /* !USE_HOSTCC */ /*****************************************************************************/ /* Shared dual-format routines */ /*****************************************************************************/ #ifndef USE_HOSTCC ulong load_addr = CONFIG_SYS_LOAD_ADDR; /* Default Load Address */ ulong save_addr; /* Default Save Address */ ulong save_size; /* Default Save Size (in bytes) */ static int on_loadaddr(const char *name, const char *value, enum env_op op, int flags) { switch (op) { case env_op_create: case env_op_overwrite: load_addr = simple_strtoul(value, NULL, 16); break; default: break; } return 0; } U_BOOT_ENV_CALLBACK(loadaddr, on_loadaddr); ulong getenv_bootm_low(void) { char *s = getenv("bootm_low"); if (s) { ulong tmp = simple_strtoul(s, NULL, 16); return tmp; } #if defined(CONFIG_SYS_SDRAM_BASE) return CONFIG_SYS_SDRAM_BASE; #elif defined(CONFIG_ARM) return gd->bd->bi_dram[0].start; #else return 0; #endif } phys_size_t getenv_bootm_size(void) { phys_size_t tmp; char *s = getenv("bootm_size"); if (s) { tmp = (phys_size_t)simple_strtoull(s, NULL, 16); return tmp; } s = getenv("bootm_low"); if (s) tmp = (phys_size_t)simple_strtoull(s, NULL, 16); else tmp = 0; #if defined(CONFIG_ARM) return gd->bd->bi_dram[0].size - tmp; #else return gd->bd->bi_memsize - tmp; #endif } phys_size_t getenv_bootm_mapsize(void) { phys_size_t tmp; char *s = getenv("bootm_mapsize"); if (s) { tmp = (phys_size_t)simple_strtoull(s, NULL, 16); return tmp; } #if defined(CONFIG_SYS_BOOTMAPSZ) return CONFIG_SYS_BOOTMAPSZ; #else return getenv_bootm_size(); #endif } void memmove_wd(void *to, void *from, size_t len, ulong chunksz) { if (to == from) return; #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG) while (len > 0) { size_t tail = (len > chunksz) ? chunksz : len; WATCHDOG_RESET(); memmove(to, from, tail); to += tail; from += tail; len -= tail; } #else /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */ memmove(to, from, len); #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */ } #endif /* !USE_HOSTCC */ void genimg_print_size(uint32_t size) { #ifndef USE_HOSTCC printf("%d Bytes = ", size); print_size(size, "\n"); #else printf("%d Bytes = %.2f kB = %.2f MB\n", size, (double)size / 1.024e3, (double)size / 1.048576e6); #endif } #if IMAGE_ENABLE_TIMESTAMP void genimg_print_time(time_t timestamp) { #ifndef USE_HOSTCC struct rtc_time tm; to_tm(timestamp, &tm); printf("%4d-%02d-%02d %2d:%02d:%02d UTC\n", tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); #else printf("%s", ctime(&timestamp)); #endif } #endif /** * get_table_entry_name - translate entry id to long name * @table: pointer to a translation table for entries of a specific type * @msg: message to be returned when translation fails * @id: entry id to be translated * * get_table_entry_name() will go over translation table trying to find * entry that matches given id. If matching entry is found, its long * name is returned to the caller. * * returns: * long entry name if translation succeeds * msg otherwise */ char *get_table_entry_name(const table_entry_t *table, char *msg, int id) { for (; table->id >= 0; ++table) { if (table->id == id) #if defined(USE_HOSTCC) || !defined(CONFIG_NEEDS_MANUAL_RELOC) return table->lname; #else return table->lname + gd->reloc_off; #endif } return (msg); } const char *genimg_get_os_name(uint8_t os) { return (get_table_entry_name(uimage_os, "Unknown OS", os)); } const char *genimg_get_arch_name(uint8_t arch) { return (get_table_entry_name(uimage_arch, "Unknown Architecture", arch)); } const char *genimg_get_type_name(uint8_t type) { return (get_table_entry_name(uimage_type, "Unknown Image", type)); } const char *genimg_get_comp_name(uint8_t comp) { return (get_table_entry_name(uimage_comp, "Unknown Compression", comp)); } /** * get_table_entry_id - translate short entry name to id * @table: pointer to a translation table for entries of a specific type * @table_name: to be used in case of error * @name: entry short name to be translated * * get_table_entry_id() will go over translation table trying to find * entry that matches given short name. If matching entry is found, * its id returned to the caller. * * returns: * entry id if translation succeeds * -1 otherwise */ int get_table_entry_id(const table_entry_t *table, const char *table_name, const char *name) { const table_entry_t *t; #ifdef USE_HOSTCC int first = 1; for (t = table; t->id >= 0; ++t) { if (t->sname && strcasecmp(t->sname, name) == 0) return(t->id); } fprintf(stderr, "\nInvalid %s Type - valid names are", table_name); for (t = table; t->id >= 0; ++t) { if (t->sname == NULL) continue; fprintf(stderr, "%c %s", (first) ? ':' : ',', t->sname); first = 0; } fprintf(stderr, "\n"); #else for (t = table; t->id >= 0; ++t) { #ifdef CONFIG_NEEDS_MANUAL_RELOC if (t->sname && strcmp(t->sname + gd->reloc_off, name) == 0) #else if (t->sname && strcmp(t->sname, name) == 0) #endif return (t->id); } debug("Invalid %s Type: %s\n", table_name, name); #endif /* USE_HOSTCC */ return (-1); } int genimg_get_os_id(const char *name) { return (get_table_entry_id(uimage_os, "OS", name)); } int genimg_get_arch_id(const char *name) { return (get_table_entry_id(uimage_arch, "CPU", name)); } int genimg_get_type_id(const char *name) { return (get_table_entry_id(uimage_type, "Image", name)); } int genimg_get_comp_id(const char *name) { return (get_table_entry_id(uimage_comp, "Compression", name)); } #ifndef USE_HOSTCC /** * genimg_get_kernel_addr_fit - get the real kernel address and return 2 * FIT strings * @img_addr: a string might contain real image address * @fit_uname_config: double pointer to a char, will hold pointer to a * configuration unit name * @fit_uname_kernel: double pointer to a char, will hold pointer to a subimage * name * * genimg_get_kernel_addr_fit get the real kernel start address from a string * which is normally the first argv of bootm/bootz * * returns: * kernel start address */ ulong genimg_get_kernel_addr_fit(char * const img_addr, const char **fit_uname_config, const char **fit_uname_kernel) { ulong kernel_addr; /* find out kernel image address */ if (!img_addr) { kernel_addr = load_addr; debug("* kernel: default image load address = 0x%08lx\n", load_addr); #if defined(CONFIG_FIT) } else if (fit_parse_conf(img_addr, load_addr, &kernel_addr, fit_uname_config)) { debug("* kernel: config '%s' from image at 0x%08lx\n", *fit_uname_config, kernel_addr); } else if (fit_parse_subimage(img_addr, load_addr, &kernel_addr, fit_uname_kernel)) { debug("* kernel: subimage '%s' from image at 0x%08lx\n", *fit_uname_kernel, kernel_addr); #endif } else { kernel_addr = simple_strtoul(img_addr, NULL, 16); debug("* kernel: cmdline image address = 0x%08lx\n", kernel_addr); } return kernel_addr; } /** * genimg_get_kernel_addr() is the simple version of * genimg_get_kernel_addr_fit(). It ignores those return FIT strings */ ulong genimg_get_kernel_addr(char * const img_addr) { const char *fit_uname_config = NULL; const char *fit_uname_kernel = NULL; return genimg_get_kernel_addr_fit(img_addr, &fit_uname_config, &fit_uname_kernel); } /** * genimg_get_format - get image format type * @img_addr: image start address * * genimg_get_format() checks whether provided address points to a valid * legacy or FIT image. * * New uImage format and FDT blob are based on a libfdt. FDT blob * may be passed directly or embedded in a FIT image. In both situations * genimg_get_format() must be able to dectect libfdt header. * * returns: * image format type or IMAGE_FORMAT_INVALID if no image is present */ int genimg_get_format(const void *img_addr) { #if defined(CONFIG_IMAGE_FORMAT_LEGACY) const image_header_t *hdr; hdr = (const image_header_t *)img_addr; if (image_check_magic(hdr)) return IMAGE_FORMAT_LEGACY; #endif #if defined(CONFIG_FIT) || defined(CONFIG_OF_LIBFDT) if (fdt_check_header(img_addr) == 0) return IMAGE_FORMAT_FIT; #endif #ifdef CONFIG_ANDROID_BOOT_IMAGE if (android_image_check_header(img_addr) == 0) return IMAGE_FORMAT_ANDROID; #endif return IMAGE_FORMAT_INVALID; } /** * genimg_get_image - get image from special storage (if necessary) * @img_addr: image start address * * genimg_get_image() checks if provided image start adddress is located * in a dataflash storage. If so, image is moved to a system RAM memory. * * returns: * image start address after possible relocation from special storage */ ulong genimg_get_image(ulong img_addr) { ulong ram_addr = img_addr; #ifdef CONFIG_HAS_DATAFLASH ulong h_size, d_size; if (addr_dataflash(img_addr)) { void *buf; /* ger RAM address */ ram_addr = CONFIG_SYS_LOAD_ADDR; /* get header size */ h_size = image_get_header_size(); #if defined(CONFIG_FIT) if (sizeof(struct fdt_header) > h_size) h_size = sizeof(struct fdt_header); #endif /* read in header */ debug(" Reading image header from dataflash address " "%08lx to RAM address %08lx\n", img_addr, ram_addr); buf = map_sysmem(ram_addr, 0); read_dataflash(img_addr, h_size, buf); /* get data size */ switch (genimg_get_format(buf)) { #if defined(CONFIG_IMAGE_FORMAT_LEGACY) case IMAGE_FORMAT_LEGACY: d_size = image_get_data_size(buf); debug(" Legacy format image found at 0x%08lx, " "size 0x%08lx\n", ram_addr, d_size); break; #endif #if defined(CONFIG_FIT) case IMAGE_FORMAT_FIT: d_size = fit_get_size(buf) - h_size; debug(" FIT/FDT format image found at 0x%08lx, " "size 0x%08lx\n", ram_addr, d_size); break; #endif default: printf(" No valid image found at 0x%08lx\n", img_addr); return ram_addr; } /* read in image data */ debug(" Reading image remaining data from dataflash address " "%08lx to RAM address %08lx\n", img_addr + h_size, ram_addr + h_size); read_dataflash(img_addr + h_size, d_size, (char *)(buf + h_size)); } #endif /* CONFIG_HAS_DATAFLASH */ return ram_addr; } /** * fit_has_config - check if there is a valid FIT configuration * @images: pointer to the bootm command headers structure * * fit_has_config() checks if there is a FIT configuration in use * (if FTI support is present). * * returns: * 0, no FIT support or no configuration found * 1, configuration found */ int genimg_has_config(bootm_headers_t *images) { #if defined(CONFIG_FIT) if (images->fit_uname_cfg) return 1; #endif return 0; } /** * boot_get_ramdisk - main ramdisk handling routine * @argc: command argument count * @argv: command argument list * @images: pointer to the bootm images structure * @arch: expected ramdisk architecture * @rd_start: pointer to a ulong variable, will hold ramdisk start address * @rd_end: pointer to a ulong variable, will hold ramdisk end * * boot_get_ramdisk() is responsible for finding a valid ramdisk image. * Curently supported are the following ramdisk sources: * - multicomponent kernel/ramdisk image, * - commandline provided address of decicated ramdisk image. * * returns: * 0, if ramdisk image was found and valid, or skiped * rd_start and rd_end are set to ramdisk start/end addresses if * ramdisk image is found and valid * * 1, if ramdisk image is found but corrupted, or invalid * rd_start and rd_end are set to 0 if no ramdisk exists */ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, uint8_t arch, ulong *rd_start, ulong *rd_end) { ulong rd_addr, rd_load; ulong rd_data, rd_len; #if defined(CONFIG_IMAGE_FORMAT_LEGACY) const image_header_t *rd_hdr; #endif void *buf; #ifdef CONFIG_SUPPORT_RAW_INITRD char *end; #endif #if defined(CONFIG_FIT) const char *fit_uname_config = images->fit_uname_cfg; const char *fit_uname_ramdisk = NULL; ulong default_addr; int rd_noffset; #endif const char *select = NULL; *rd_start = 0; *rd_end = 0; if (argc >= 2) select = argv[1]; /* * Look for a '-' which indicates to ignore the * ramdisk argument */ if (select && strcmp(select, "-") == 0) { debug("## Skipping init Ramdisk\n"); rd_len = rd_data = 0; } else if (select || genimg_has_config(images)) { #if defined(CONFIG_FIT) if (select) { /* * If the init ramdisk comes from the FIT image and * the FIT image address is omitted in the command * line argument, try to use os FIT image address or * default load address. */ if (images->fit_uname_os) default_addr = (ulong)images->fit_hdr_os; else default_addr = load_addr; if (fit_parse_conf(select, default_addr, &rd_addr, &fit_uname_config)) { debug("* ramdisk: config '%s' from image at " "0x%08lx\n", fit_uname_config, rd_addr); } else if (fit_parse_subimage(select, default_addr, &rd_addr, &fit_uname_ramdisk)) { debug("* ramdisk: subimage '%s' from image at " "0x%08lx\n", fit_uname_ramdisk, rd_addr); } else #endif { rd_addr = simple_strtoul(select, NULL, 16); debug("* ramdisk: cmdline image address = " "0x%08lx\n", rd_addr); } #if defined(CONFIG_FIT) } else { /* use FIT configuration provided in first bootm * command argument. If the property is not defined, * quit silently. */ rd_addr = map_to_sysmem(images->fit_hdr_os); rd_noffset = fit_get_node_from_config(images, FIT_RAMDISK_PROP, rd_addr); if (rd_noffset == -ENOLINK) return 0; else if (rd_noffset < 0) return 1; } #endif /* copy from dataflash if needed */ rd_addr = genimg_get_image(rd_addr); /* * Check if there is an initrd image at the * address provided in the second bootm argument * check image type, for FIT images get FIT node. */ buf = map_sysmem(rd_addr, 0); switch (genimg_get_format(buf)) { #if defined(CONFIG_IMAGE_FORMAT_LEGACY) case IMAGE_FORMAT_LEGACY: printf("## Loading init Ramdisk from Legacy " "Image at %08lx ...\n", rd_addr); bootstage_mark(BOOTSTAGE_ID_CHECK_RAMDISK); rd_hdr = image_get_ramdisk(rd_addr, arch, images->verify); if (rd_hdr == NULL) return 1; rd_data = image_get_data(rd_hdr); rd_len = image_get_data_size(rd_hdr); rd_load = image_get_load(rd_hdr); break; #endif #if defined(CONFIG_FIT) case IMAGE_FORMAT_FIT: rd_noffset = fit_image_load(images, rd_addr, &fit_uname_ramdisk, &fit_uname_config, arch, IH_TYPE_RAMDISK, BOOTSTAGE_ID_FIT_RD_START, FIT_LOAD_OPTIONAL_NON_ZERO, &rd_data, &rd_len); if (rd_noffset < 0) return 1; images->fit_hdr_rd = map_sysmem(rd_addr, 0); images->fit_uname_rd = fit_uname_ramdisk; images->fit_noffset_rd = rd_noffset; break; #endif default: #ifdef CONFIG_SUPPORT_RAW_INITRD end = NULL; if (select) end = strchr(select, ':'); if (end) { rd_len = simple_strtoul(++end, NULL, 16); rd_data = rd_addr; } else #endif { puts("Wrong Ramdisk Image Format\n"); rd_data = rd_len = rd_load = 0; return 1; } } } else if (images->legacy_hdr_valid && image_check_type(&images->legacy_hdr_os_copy, IH_TYPE_MULTI)) { /* * Now check if we have a legacy mult-component image, * get second entry data start address and len. */ bootstage_mark(BOOTSTAGE_ID_RAMDISK); printf("## Loading init Ramdisk from multi component " "Legacy Image at %08lx ...\n", (ulong)images->legacy_hdr_os); image_multi_getimg(images->legacy_hdr_os, 1, &rd_data, &rd_len); } #ifdef CONFIG_ANDROID_BOOT_IMAGE else if ((genimg_get_format(images) == IMAGE_FORMAT_ANDROID) && (!android_image_get_ramdisk((void *)images->os.start, &rd_data, &rd_len))) { /* empty */ } #endif else { /* * no initrd image */ bootstage_mark(BOOTSTAGE_ID_NO_RAMDISK); rd_len = rd_data = 0; } if (!rd_data) { debug("## No init Ramdisk\n"); } else { *rd_start = rd_data; *rd_end = rd_data + rd_len; } debug(" ramdisk start = 0x%08lx, ramdisk end = 0x%08lx\n", *rd_start, *rd_end); return 0; } #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH /** * boot_ramdisk_high - relocate init ramdisk * @lmb: pointer to lmb handle, will be used for memory mgmt * @rd_data: ramdisk data start address * @rd_len: ramdisk data length * @initrd_start: pointer to a ulong variable, will hold final init ramdisk * start address (after possible relocation) * @initrd_end: pointer to a ulong variable, will hold final init ramdisk * end address (after possible relocation) * * boot_ramdisk_high() takes a relocation hint from "initrd_high" environment * variable and if requested ramdisk data is moved to a specified location. * * Initrd_start and initrd_end are set to final (after relocation) ramdisk * start/end addresses if ramdisk image start and len were provided, * otherwise set initrd_start and initrd_end set to zeros. * * returns: * 0 - success * -1 - failure */ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len, ulong *initrd_start, ulong *initrd_end) { char *s; ulong initrd_high; int initrd_copy_to_ram = 1; if ((s = getenv("initrd_high")) != NULL) { /* a value of "no" or a similar string will act like 0, * turning the "load high" feature off. This is intentional. */ initrd_high = simple_strtoul(s, NULL, 16); if (initrd_high == ~0) initrd_copy_to_ram = 0; } else { /* not set, no restrictions to load high */ initrd_high = ~0; } #ifdef CONFIG_LOGBUFFER /* Prevent initrd from overwriting logbuffer */ lmb_reserve(lmb, logbuffer_base() - LOGBUFF_OVERHEAD, LOGBUFF_RESERVE); #endif debug("## initrd_high = 0x%08lx, copy_to_ram = %d\n", initrd_high, initrd_copy_to_ram); if (rd_data) { if (!initrd_copy_to_ram) { /* zero-copy ramdisk support */ debug(" in-place initrd\n"); *initrd_start = rd_data; *initrd_end = rd_data + rd_len; lmb_reserve(lmb, rd_data, rd_len); } else { if (initrd_high) *initrd_start = (ulong)lmb_alloc_base(lmb, rd_len, 0x1000, initrd_high); else *initrd_start = (ulong)lmb_alloc(lmb, rd_len, 0x1000); if (*initrd_start == 0) { puts("ramdisk - allocation error\n"); goto error; } bootstage_mark(BOOTSTAGE_ID_COPY_RAMDISK); *initrd_end = *initrd_start + rd_len; printf(" Loading Ramdisk to %08lx, end %08lx ... ", *initrd_start, *initrd_end); memmove_wd((void *)*initrd_start, (void *)rd_data, rd_len, CHUNKSZ); #ifdef CONFIG_MP /* * Ensure the image is flushed to memory to handle * AMP boot scenarios in which we might not be * HW cache coherent */ flush_cache((unsigned long)*initrd_start, rd_len); #endif puts("OK\n"); } } else { *initrd_start = 0; *initrd_end = 0; } debug(" ramdisk load start = 0x%08lx, ramdisk load end = 0x%08lx\n", *initrd_start, *initrd_end); return 0; error: return -1; } #endif /* CONFIG_SYS_BOOT_RAMDISK_HIGH */ #ifdef CONFIG_SYS_BOOT_GET_CMDLINE /** * boot_get_cmdline - allocate and initialize kernel cmdline * @lmb: pointer to lmb handle, will be used for memory mgmt * @cmd_start: pointer to a ulong variable, will hold cmdline start * @cmd_end: pointer to a ulong variable, will hold cmdline end * * boot_get_cmdline() allocates space for kernel command line below * BOOTMAPSZ + getenv_bootm_low() address. If "bootargs" U-boot environemnt * variable is present its contents is copied to allocated kernel * command line. * * returns: * 0 - success * -1 - failure */ int boot_get_cmdline(struct lmb *lmb, ulong *cmd_start, ulong *cmd_end) { char *cmdline; char *s; cmdline = (char *)(ulong)lmb_alloc_base(lmb, CONFIG_SYS_BARGSIZE, 0xf, getenv_bootm_mapsize() + getenv_bootm_low()); if (cmdline == NULL) return -1; if ((s = getenv("bootargs")) == NULL) s = ""; strcpy(cmdline, s); *cmd_start = (ulong) & cmdline[0]; *cmd_end = *cmd_start + strlen(cmdline); debug("## cmdline at 0x%08lx ... 0x%08lx\n", *cmd_start, *cmd_end); return 0; } #endif /* CONFIG_SYS_BOOT_GET_CMDLINE */ #ifdef CONFIG_SYS_BOOT_GET_KBD /** * boot_get_kbd - allocate and initialize kernel copy of board info * @lmb: pointer to lmb handle, will be used for memory mgmt * @kbd: double pointer to board info data * * boot_get_kbd() allocates space for kernel copy of board info data below * BOOTMAPSZ + getenv_bootm_low() address and kernel board info is initialized * with the current u-boot board info data. * * returns: * 0 - success * -1 - failure */ int boot_get_kbd(struct lmb *lmb, bd_t **kbd) { *kbd = (bd_t *)(ulong)lmb_alloc_base(lmb, sizeof(bd_t), 0xf, getenv_bootm_mapsize() + getenv_bootm_low()); if (*kbd == NULL) return -1; **kbd = *(gd->bd); debug("## kernel board info at 0x%08lx\n", (ulong)*kbd); #if defined(DEBUG) && defined(CONFIG_CMD_BDI) do_bdinfo(NULL, 0, 0, NULL); #endif return 0; } #endif /* CONFIG_SYS_BOOT_GET_KBD */ #ifdef CONFIG_LMB int image_setup_linux(bootm_headers_t *images) { ulong of_size = images->ft_len; char **of_flat_tree = &images->ft_addr; ulong *initrd_start = &images->initrd_start; ulong *initrd_end = &images->initrd_end; struct lmb *lmb = &images->lmb; ulong rd_len; int ret; if (IMAGE_ENABLE_OF_LIBFDT) boot_fdt_add_mem_rsv_regions(lmb, *of_flat_tree); if (IMAGE_BOOT_GET_CMDLINE) { ret = boot_get_cmdline(lmb, &images->cmdline_start, &images->cmdline_end); if (ret) { puts("ERROR with allocation of cmdline\n"); return ret; } } if (IMAGE_ENABLE_RAMDISK_HIGH) { rd_len = images->rd_end - images->rd_start; ret = boot_ramdisk_high(lmb, images->rd_start, rd_len, initrd_start, initrd_end); if (ret) return ret; } if (IMAGE_ENABLE_OF_LIBFDT) { ret = boot_relocate_fdt(lmb, of_flat_tree, &of_size); if (ret) return ret; } if (IMAGE_ENABLE_OF_LIBFDT && of_size) { ret = image_setup_libfdt(images, *of_flat_tree, of_size, lmb); if (ret) return ret; } return 0; } #endif /* CONFIG_LMB */ #endif /* !USE_HOSTCC */
27.031771
81
0.677636
d9afface8db7c84961c37799f98364ef91410cb7
588
h
C
ios/Pods/Headers/Public/ReactABI25_0_0/ABI25_0_0EXOAuthViewController.h
mauriciord/expo
c0a4dc89a3a74836cdc88440645313eadfc40e4a
[ "Apache-2.0", "MIT" ]
1
2019-04-18T07:37:33.000Z
2019-04-18T07:37:33.000Z
ios/Pods/Headers/Public/ReactABI25_0_0/ABI25_0_0EXOAuthViewController.h
mauriciord/expo
c0a4dc89a3a74836cdc88440645313eadfc40e4a
[ "Apache-2.0", "MIT" ]
null
null
null
ios/Pods/Headers/Public/ReactABI25_0_0/ABI25_0_0EXOAuthViewController.h
mauriciord/expo
c0a4dc89a3a74836cdc88440645313eadfc40e4a
[ "Apache-2.0", "MIT" ]
null
null
null
// Copyright 2015-present 650 Industries. All rights reserved. #import <UIKit/UIKit.h> @class ABI25_0_0EXOAuthViewController; @protocol ABI25_0_0EXOAuthViewControllerDelegate <NSObject> -(void)oAuthViewControlerDidCancel:(ABI25_0_0EXOAuthViewController *)viewController; -(void)oAuthViewControler:(ABI25_0_0EXOAuthViewController *)viewController didReceiveResult:(NSString *)result; @end @interface ABI25_0_0EXOAuthViewController : UIViewController @property (nonatomic, strong) NSString *url; @property (nonatomic, weak) id<ABI25_0_0EXOAuthViewControllerDelegate> delegate; @end
29.4
111
0.835034
1e16b77f3242c9a298c61322e63369acfe76f466
298
h
C
src/class/Entity.h
lobinuxsoft/Flappy-Bird-xD
8a1e252c617ae48c1b50ca894ced1e27f8800696
[ "MIT" ]
null
null
null
src/class/Entity.h
lobinuxsoft/Flappy-Bird-xD
8a1e252c617ae48c1b50ca894ced1e27f8800696
[ "MIT" ]
7
2021-10-05T15:38:56.000Z
2021-10-14T23:45:10.000Z
src/class/Entity.h
lobinuxsoft/Flappy-Bird-xD
8a1e252c617ae48c1b50ca894ced1e27f8800696
[ "MIT" ]
null
null
null
#pragma once #include "Utils/Vector2Utils.h" using namespace GameUtils; namespace GameCore { class Entity { protected: Vector2 position; public: Entity(Vector2 position); virtual ~Entity(); void setPosition(Vector2 position); Vector2 getPosition(); virtual void draw() = 0; }; }
14.9
37
0.718121
969459a4a4dab1efd3d44618830c3f607b01ea83
1,589
h
C
libjpeg/jpeg_start_decompress/jpeg_start_decompress/src/jpeg_start_decompress/bitmap.h
bg1bgst333/Sample
68e3a5c26c6d9bc1906ce0cca2fd586f0790fa52
[ "MIT" ]
9
2016-12-22T20:24:09.000Z
2021-05-08T08:48:24.000Z
libpng/png_write_png/png_write_png/src/png_write_png/bitmap.h
bg1bgst333/Sample
68e3a5c26c6d9bc1906ce0cca2fd586f0790fa52
[ "MIT" ]
36
2018-08-16T06:43:36.000Z
2022-03-25T19:01:34.000Z
libjpeg/jpeg_start_decompress/jpeg_start_decompress/src/jpeg_start_decompress/bitmap.h
bg1bgst333/Sample
68e3a5c26c6d9bc1906ce0cca2fd586f0790fa52
[ "MIT" ]
9
2016-09-03T02:57:31.000Z
2021-09-09T02:42:26.000Z
/* 二重インクルードの防止 */ #ifndef BITMAP_H #define BITMAP_H /* ワード境界を一時的に2にする. */ #pragma pack(2) /* ビットマップファイルヘッダ構造体 */ typedef struct tag_bitmap_file_header{ unsigned short type; /* タイプ */ unsigned int size; /* ファイルサイズ */ unsigned short reserved1; /* 予約済み */ unsigned short reserved2; /* 予約済み */ unsigned int off_bits; /* ビット配列までのオフセット */ } bitmap_file_header_t; /* ワード境界を元に戻す. */ #pragma pack() /* ビットマップ情報ヘッダ構造体 */ typedef struct tag_bitmap_info_header{ unsigned int size; /* 構造体サイズ */ int width; /* 幅 */ int height; /* 高さ */ unsigned short planes; /* プレーンの数 */ unsigned short bit_count; /* ピクセルあたりの色数 */ unsigned int compression; /* 圧縮方式 */ unsigned int size_image; /* ビットマップのサイズ */ int x_pels_per_meter; /* 水平解像度 */ int y_pels_per_meter; /* 垂直解像度 */ unsigned int clr_used; /* イメージで使われている色数 */ unsigned int clr_important; /* 重要な色の数 */ } bitmap_info_header_t; /* カラーテーブル構造体(今回は24bitビットマップのみ扱うので使わない.) */ typedef struct tag_rgb_quad{ unsigned char blue; /* 青 */ unsigned char green; /* 緑 */ unsigned char red; /* 赤 */ unsigned char reserved; /* 予約済み */ } rgb_quad_t; /* ビットマップ(今回はカラーテーブルを含まない.) */ typedef struct tag_bitmap{ bitmap_file_header_t file_header; /* ビットマップファイルヘッダ */ bitmap_info_header_t info_header; /* ピットマップ情報ヘッダ */ unsigned char *buf; /* ピクセルバッファへのポインタ */ } bitmap_t; /* 関数のプロトタイプ宣言 */ int load_bitmap(const char *filename, bitmap_t *bitmap_ptr); /* ビットマップのロード */ int save_bitmap(const char *filename, bitmap_t *bitmap_ptr, int buf_size); /* ビットマップのセーブ */ void destroy_bitmap(bitmap_t *bitmap_ptr); /* ビットマップの破棄 */ #endif
28.375
91
0.702329
cafb3c65f9494bd5765351143a9e9fa4b1169e5f
5,801
h
C
src/boards/bsf_pico.h
Chiumanfu/LMIC-node
b982bdcfeccae29501e32730fce982dc0df1644c
[ "MIT" ]
4
2022-01-10T14:05:31.000Z
2022-03-27T21:13:00.000Z
src/boards/bsf_pico.h
Chiumanfu/LMIC-node
b982bdcfeccae29501e32730fce982dc0df1644c
[ "MIT" ]
null
null
null
src/boards/bsf_pico.h
Chiumanfu/LMIC-node
b982bdcfeccae29501e32730fce982dc0df1644c
[ "MIT" ]
2
2022-01-17T05:39:52.000Z
2022-03-12T18:25:58.000Z
/******************************************************************************* * * File: bsf_pico.h * * Note: This file cannot be called pico.h due to conflict * with identical named file in Arduino-embed core. * * Function: Board Support File for Raspberry Pi Pico * with external SPI LoRa module. * * Copyright: Copyright (c) 2021 Leonel Lopes Parente * * License: MIT License. See accompanying LICENSE file. * * Author: Leonel Lopes Parente * * Description: This board has onboard USB (provided by the MCU). * It supports automatic firmware upload and serial over USB. * No onboard display. Optionally an external display con be connected. * * IMPORTANT information for firmware upload: * ------------------------------------------ * Device must be in BOOTSEL mode to upload firmware. * (To put in BOOTSEL mode: press BOOTSEL button, power on or reset board, release BOOTSEL button.) * In platformio.ini: * For Windows specify: upload_protocol = picotool (appears not needed for Mac and Linux). * upload_port is operating system and hardware dependent. * For convenience, to set upload_port: set upload_port in [pico] section (on top). * Examples: * Windows: upload_port = E: * Mac: upload_port = /Volumes/RPI-RP2 * Linux: upload_port = /media/<user>/RSPI-RP2 * On Windows USB driver for Pico [RP2 Boot (interface 1)] needs be installed with Zadig, * see: https://community.platformio.org/t/official-platformio-arduino-ide-support-for-the-raspberry-pi-pico-is-now-available/20792 * * Connect the LoRa module and optional display * according to below connection details. * * CONNECTIONS AND PIN DEFINITIONS: * * Indentifiers between parentheses are defined in the board's * Board Support Package (BSP) which is part of the Arduino core. * * Leds GPIO * ---- ---- * LED <――――――――――> 25 (LED_BUILTIN) (PIN_LED) * * I2C [display] GPIO * --- ---- * SDA <――――――――――> 6 (PIN_WIRE_SDA) * SCL <――――――――――> 7 (PIN_WIRE_SCL) * * SPI/LoRa module GPIO * --- ---- * SCK <――――――――――> 2 (SCK) (PIN_SPI_SCK) * MOSI <――――――――――> 3 (MOSI) (PIN_SPI_MOSI) * MISO <――――――――――> 4 (MISO) (PIN_SPI_MISO) * NSS <――――――――――> 5 (SS) (PIN_SPI_SS) * RST <――――――――――> 8 * DIO0 <――――――――――> 9 * DIO1 <――――――――――> 10 * DIO2 - Not needed for LoRa. * * Docs: https://docs.platformio.org/en/latest/boards/atmelsam/zeroUSB.html * * Identifiers: LMIC-node * board: pico * PlatformIO * board: pico * platform: raspberrypi * Arduino * board: * architecture: * ******************************************************************************/ #pragma once #ifndef BSF_PICO_H_ #define BSF_PICO_H_ #include "LMIC-node.h" #ifndef SDA #define SDA PIN_WIRE_SDA #endif #ifndef SCL #define SCL PIN_WIRE_SCL #endif #define DEVICEID_DEFAULT "rpi-pico" // Default deviceid value // Wait for Serial // Can be useful for boards with MCU with integrated USB support. #define WAITFOR_SERIAL_SECONDS_DEFAULT 10 // -1 waits indefinitely // LMIC Clock Error // This is only needed for slower 8-bit MCUs (e.g. 8MHz ATmega328 and ATmega32u4). // Value is defined in parts per million (of MAX_CLOCK_ERROR). // #ifndef LMIC_CLOCK_ERROR_PPM // #define LMIC_CLOCK_ERROR_PPM 0 // #endif // Pin mappings for LoRa tranceiver const lmic_pinmap lmic_pins = { .nss = SS, .rxtx = LMIC_UNUSED_PIN, .rst = 8, .dio = { /*dio0*/ 9, /*dio1*/ 10, /*dio2*/ LMIC_UNUSED_PIN } #ifdef MCCI_LMIC , .rxtx_rx_active = 0, .rssi_cal = 10, .spi_freq = 8000000 /* 8 MHz */ #endif }; #ifdef USE_SERIAL UART& serial = SerialUSB; #endif #ifdef USE_LED EasyLed led(LED_BUILTIN, EasyLed::ActiveLevel::High); #endif #ifdef USE_DISPLAY // Create U8x8 instance for SSD1306 OLED display (no reset) using hardware I2C. U8X8_SSD1306_128X64_NONAME_HW_I2C display(/*rst*/ U8X8_PIN_NONE, /*scl*/ SCL, /*sda*/ SDA); #endif bool boardInit(InitType initType) { // This function is used to perform board specific initializations. // Required as part of standard template. // InitType::Hardware Must be called at start of setup() before anything else. // InitType::PostInitSerial Must be called after initSerial() before other initializations. bool success = true; switch (initType) { case InitType::Hardware: // Note: Serial port and display are not yet initialized and cannot be used use here. // No actions required for this board. break; case InitType::PostInitSerial: // Note: If enabled Serial port and display are already initialized here. // No actions required for this board. break; } return success; } #endif // BSF_PICO_H_
36.949045
146
0.52422
f05eec3e00273063c35fc36313197b6ba7c17ba4
174
h
C
ext/zendframework/http/client/adapter/exception/runtimeexception.zep.h
adorabuddy/php-ext-zendframework
a3d382c734d7f4dd65cca812b0e41b28bfc95555
[ "MIT" ]
null
null
null
ext/zendframework/http/client/adapter/exception/runtimeexception.zep.h
adorabuddy/php-ext-zendframework
a3d382c734d7f4dd65cca812b0e41b28bfc95555
[ "MIT" ]
null
null
null
ext/zendframework/http/client/adapter/exception/runtimeexception.zep.h
adorabuddy/php-ext-zendframework
a3d382c734d7f4dd65cca812b0e41b28bfc95555
[ "MIT" ]
null
null
null
extern zend_class_entry *zendframework_http_client_adapter_exception_runtimeexception_ce; ZEPHIR_INIT_CLASS(ZendFramework_Http_Client_Adapter_Exception_RuntimeException);
29
89
0.931034
4b1bf5061ffdf190400d7f10d6c90179de90c26b
3,085
c
C
programs/encode_file.c
StegoPhone/quiet
65075513f475901f92a47bae7702211211c037dd
[ "BSD-3-Clause" ]
1
2021-03-03T13:30:47.000Z
2021-03-03T13:30:47.000Z
programs/encode_file.c
StegoPhone/quiet
65075513f475901f92a47bae7702211211c037dd
[ "BSD-3-Clause" ]
null
null
null
programs/encode_file.c
StegoPhone/quiet
65075513f475901f92a47bae7702211211c037dd
[ "BSD-3-Clause" ]
null
null
null
#include <math.h> #include <string.h> #include "quiet.h" #include <sndfile.h> float freq2rad(float freq) { return freq * 2 * M_PI; } const int sample_rate = 44100; float normalize_freq(float freq, float sample_rate) { return freq2rad(freq / (float)(sample_rate)); } SNDFILE *wav_open(const char *fname, float sample_rate) { SF_INFO sfinfo; memset(&sfinfo, 0, sizeof(sfinfo)); sfinfo.samplerate = sample_rate; sfinfo.channels = 1; sfinfo.format = (SF_FORMAT_WAV | SF_FORMAT_FLOAT); return sf_open(fname, SFM_WRITE, &sfinfo); } size_t wav_write(SNDFILE *wav, const quiet_sample_t *samples, size_t sample_len) { return sf_write_float(wav, samples, sample_len); } void wav_close(SNDFILE *wav) { sf_close(wav); } int encode_to_wav(FILE *payload, const char *out_fname, const quiet_encoder_options *opt) { SNDFILE *wav = wav_open(out_fname, sample_rate); if (wav == NULL) { printf("failed to open wav file for writing\n"); return 1; } quiet_encoder *e = quiet_encoder_create(opt, sample_rate); size_t block_len = 16384; uint8_t *readbuf = malloc(block_len * sizeof(uint8_t)); size_t samplebuf_len = 16384; quiet_sample_t *samplebuf = malloc(samplebuf_len * sizeof(quiet_sample_t)); bool done = false; if (readbuf == NULL) { return 1; } if (samplebuf == NULL) { return 1; } while (!done) { size_t nread = fread(readbuf, sizeof(uint8_t), block_len, payload); if (nread == 0) { break; } else if (nread < block_len) { done = true; } size_t frame_len = quiet_encoder_get_frame_len(e); for (size_t i = 0; i < nread; i += frame_len) { frame_len = (frame_len > (nread - i)) ? (nread - i) : frame_len; quiet_encoder_send(e, readbuf + i, frame_len); } ssize_t written = samplebuf_len; while (written == samplebuf_len) { written = quiet_encoder_emit(e, samplebuf, samplebuf_len); if (written > 0) { wav_write(wav, samplebuf, written); } } } quiet_encoder_destroy(e); free(readbuf); free(samplebuf); wav_close(wav); return 0; } int main(int argc, char **argv) { if (argc < 2 || argc > 4) { printf("usage: encode_file <profilename> [<input_source>]\n"); exit(1); } FILE *input; if ((argc == 2) || strncmp(argv[2], "-", 2) == 0) { input = stdin; } else { input = fopen(argv[2], "rb"); if (!input) { fprintf(stderr, "failed to open %s: ", argv[2]); perror(NULL); exit(1); } } quiet_encoder_options *encodeopt = quiet_encoder_profile_filename(QUIET_PROFILES_LOCATION, argv[1]); if (!encodeopt) { printf("failed to read profile %s from %s\n", argv[1], QUIET_PROFILES_LOCATION); exit(1); } encode_to_wav(input, "encoded.wav", encodeopt); fclose(input); free(encodeopt); return 0; }
25.92437
88
0.592545
af4649856261cccd9073952f915c4ac2e0396624
2,421
h
C
pyreBloom/bloom.h
thecrackofdawn/pyreBloom
66b5485b307077f9e1671fe9f7d299534be9508e
[ "MIT" ]
1
2020-05-26T06:34:29.000Z
2020-05-26T06:34:29.000Z
pyreBloom/bloom.h
thecrackofdawn/pyreBloom
66b5485b307077f9e1671fe9f7d299534be9508e
[ "MIT" ]
null
null
null
pyreBloom/bloom.h
thecrackofdawn/pyreBloom
66b5485b307077f9e1671fe9f7d299534be9508e
[ "MIT" ]
null
null
null
/* Copyright (c) 2011 SEOmoz * * 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 PYRE_BLOOM_H #define PYRE_BLOOM_H #include <stdint.h> #include <stdlib.h> #include <hiredis/hiredis.h> /* Some return values */ enum { PYREBLOOM_OK = 0, PYREBLOOM_ERROR = -1 }; // And now for some redis stuff typedef struct { uint32_t capacity; uint32_t hashes; uint32_t num_keys; uint64_t bits; double error; uint32_t * seeds; char * key; char * key_counter; char counter_value[32]; char * password; redisContext * ctxt; char ** keys; uint32_t count; char errstr[128]; } pyrebloomctxt; int init_pyrebloom(pyrebloomctxt * ctxt, char * key, uint32_t capacity, double error, char* host, uint32_t port, char* password, uint32_t db, uint32_t count); int free_pyrebloom(pyrebloomctxt * ctxt); int add(pyrebloomctxt * ctxt, const char * data, uint32_t len); int add_complete(pyrebloomctxt * ctxt, uint32_t count); int check(pyrebloomctxt * ctxt, const char * data, uint32_t len); int check_next(pyrebloomctxt * ctxt); int delete(pyrebloomctxt * ctxt); uint64_t hash(const char* data, uint32_t len, uint64_t seed, uint64_t bits); uint32_t incr_counter(pyrebloomctxt * ctxt, uint32_t num); uint32_t get_counter(pyrebloomctxt * ctxt); #endif
33.164384
158
0.709624
af4854e0773509c518d8b42f2d6649ad4d8835d2
641
h
C
src/SpecularBTDF.h
MulattoKid/BrhanRenderer
0376e64eeb3e75a0f36bb7e17ace0cfd0e7ce39d
[ "MIT" ]
2
2018-11-01T11:32:33.000Z
2019-05-24T01:30:00.000Z
src/SpecularBTDF.h
MulattoKid/BrhanRenderer
0376e64eeb3e75a0f36bb7e17ace0cfd0e7ce39d
[ "MIT" ]
null
null
null
src/SpecularBTDF.h
MulattoKid/BrhanRenderer
0376e64eeb3e75a0f36bb7e17ace0cfd0e7ce39d
[ "MIT" ]
null
null
null
#ifndef SPECULARBTDF_H #define SPECULARBTDF_H #include "BxDF.h" #include "FresnelDielectric.h" struct SpecularBTDF : BxDF { glm::vec3 T; float eta_outside; float eta_inside; FresnelDielectric fresnel_dielectric; SpecularBTDF(const glm::vec3& T, const float eta_i, const float eta_t); ~SpecularBTDF(); float Pdf(const glm::vec3& wo, const glm::vec3& wi, const glm::vec3& normal) const; glm::vec3 f(const glm::vec3& wo, const glm::vec3& normal, const glm::vec3& wi) const; glm::vec3 Samplef(const glm::vec3& wo, const float u[2], const glm::vec3& normal, glm::vec3* wi, float* pdf, BxDFType* sampled_type) const; }; #endif
27.869565
86
0.722309
af9f7391135447521d0b0d74db839e2079890bda
13,145
h
C
modules/console/term_actions.c.h
CyberFlameGO/tilck
4c32541874102e524374ab79d46b68af9d759390
[ "BSD-2-Clause" ]
1,059
2018-07-30T14:48:42.000Z
2022-03-30T19:54:49.000Z
modules/console/term_actions.c.h
CyberFlameGO/tilck
4c32541874102e524374ab79d46b68af9d759390
[ "BSD-2-Clause" ]
15
2019-06-17T13:58:08.000Z
2021-10-16T18:19:25.000Z
modules/console/term_actions.c.h
CyberFlameGO/tilck
4c32541874102e524374ab79d46b68af9d759390
[ "BSD-2-Clause" ]
47
2020-03-09T16:54:07.000Z
2022-03-12T08:53:56.000Z
/* SPDX-License-Identifier: BSD-2-Clause */ #define DEFINE_TERM_ACTION_0(name) \ static void \ __term_action_##name(term *_t, ulong __u1, ulong __u2, ulong __u3) { \ struct vterm *const t = _t; \ term_action_##name(t); \ } #define DEFINE_TERM_ACTION_1(name, t1) \ static void \ __term_action_##name(term *_t, ulong __a1, ulong __u1, ulong __u2) { \ struct vterm *const t = _t; \ term_action_##name(t, (t1)__a1); \ } #define DEFINE_TERM_ACTION_2(name, t1, t2) \ static void \ __term_action_##name(term *_t, ulong __a1, ulong __a2, ulong __u1) { \ struct vterm *const t = _t; \ term_action_##name(t, (t1)__a1, (t2)__a2); \ } #define DEFINE_TERM_ACTION_3(name, t1, t2, t3) \ static void \ __term_action_##name(term *_t, ulong __a1, ulong __a2, ulong __a3) { \ struct vterm *const t = _t; \ term_action_##name(t, (t1)__a1, (t2)__a2, (t3)__a3); \ } #define CALL_ACTION_FUNC_0(func, t) \ (func)((t), 0, 0, 0) #define CALL_ACTION_FUNC_1(func, t, a1) \ (func)((t), (ulong)(a1), 0, 0) #define CALL_ACTION_FUNC_2(func, t, a1, a2) \ (func)((t), (ulong)(a1), (ulong)(a2), 0) #define CALL_ACTION_FUNC_3(func, t, a1, a2, a3) \ (func)((t), (ulong)(a1), (ulong)(a2), (ulong)(a3)) static void term_action_none(struct vterm *const t) { /* do nothing */ } DEFINE_TERM_ACTION_0(none) static void term_action_enable_cursor(struct vterm *const t, bool val) { term_int_enable_cursor(t, val); } DEFINE_TERM_ACTION_1(enable_cursor, bool) static void term_action_scroll(struct vterm *const t, u32 lines, enum term_scroll_type st) { ASSERT(st == term_scroll_up || st == term_scroll_down); if (st == term_scroll_up) term_int_scroll_up(t, lines); else term_int_scroll_down(t, lines); } DEFINE_TERM_ACTION_2(scroll, u32, enum term_scroll_type) static void term_action_non_buf_scroll(struct vterm *const t, u16 n, enum term_scroll_type st) { ASSERT(st == term_scroll_up || st == term_scroll_down); if (st == term_scroll_up) term_internal_non_buf_scroll_up(t, n); else term_internal_non_buf_scroll_down(t, n); } DEFINE_TERM_ACTION_2(non_buf_scroll, u16, enum term_scroll_type) static void term_action_move_cur(struct vterm *const t, int row, int col) { term_int_move_cur(t, row, col); } DEFINE_TERM_ACTION_2(move_cur, int, int) static void term_action_write(struct vterm *const t, const char *buf, u32 len, u8 color) { const struct video_interface *const vi = t->vi; ts_scroll_to_bottom(t); vi->enable_cursor(); for (u32 i = 0; i < len; i++) { if (UNLIKELY(t->filter == NULL)) { /* Early term use by printk(), before tty has been initialized */ term_internal_write_char2(t, buf[i], color); continue; } /* * NOTE: We MUST store buf[i] in a local variable because the filter * function is absolutely allowed to modify its contents!! * * (Of course, buf is *not* required to point to writable memory.) */ char c = buf[i]; struct term_action a = { .type1 = a_none }; enum term_fret r = t->filter((u8 *)&c, &color, &a, t->filter_ctx); if (LIKELY(r == TERM_FILTER_WRITE_C)) term_internal_write_char2(t, c, color); term_execute_action(t, &a); } if (t->cursor_enabled) vi->move_cursor(t->r, t->c, get_curr_cell_fg_color(t)); } DEFINE_TERM_ACTION_3(write, const char *, u32, u8) /* Direct write without any filter nor move_cursor/flush */ static void term_action_direct_write(struct vterm *const t, char *buf, u32 len, u8 color) { for (u32 i = 0; i < len; i++) term_internal_write_char2(t, buf[i], color); } DEFINE_TERM_ACTION_3(direct_write, char *, u32, u8) static void term_action_set_col_offset(struct vterm *const t, u16 off) { t->col_offset = off; } DEFINE_TERM_ACTION_1(set_col_offset, u16) static void term_action_move_cur_rel(struct vterm *const t, s16 dr, s16 dc) { if (!t->buffer) return; t->r = (u16) CLAMP((int)t->r + dr, 0, t->rows - 1); t->c = (u16) CLAMP((int)t->c + dc, 0, t->cols - 1); if (t->cursor_enabled) t->vi->move_cursor(t->r, t->c, get_curr_cell_fg_color(t)); } DEFINE_TERM_ACTION_2(move_cur_rel, s16, s16) static void term_action_reset(struct vterm *const t) { t->vi->enable_cursor(); term_int_move_cur(t, 0, 0); t->scroll = t->max_scroll = 0; for (u16 i = 0; i < t->rows; i++) ts_clear_row(t, i, DEFAULT_COLOR16); if (t->tabs_buf) memset(t->tabs_buf, 0, t->cols * t->rows); } DEFINE_TERM_ACTION_0(reset) static void term_action_erase_in_display(struct vterm *const t, int mode) { const u16 entry = make_vgaentry(' ', DEFAULT_COLOR16); switch (mode) { case 0: /* Clear the screen from the cursor position up to the end */ for (u16 col = t->c; col < t->cols; col++) { buf_set_entry(t, t->r, col, entry); t->vi->set_char_at(t->r, col, entry); } for (u16 i = t->r + 1; i < t->rows; i++) ts_clear_row(t, i, DEFAULT_COLOR16); break; case 1: /* Clear the screen from the beginning up to cursor's position */ for (u16 i = 0; i < t->r; i++) ts_clear_row(t, i, DEFAULT_COLOR16); for (u16 col = 0; col < t->c; col++) { buf_set_entry(t, t->r, col, entry); t->vi->set_char_at(t->r, col, entry); } break; case 2: /* Clear the whole screen */ for (u16 i = 0; i < t->rows; i++) ts_clear_row(t, i, DEFAULT_COLOR16); break; case 3: /* Clear the whole screen and erase the scroll buffer */ { u16 row = t->r; u16 col = t->c; term_action_reset(t); if (t->cursor_enabled) t->vi->move_cursor(row, col, DEFAULT_COLOR16); } break; default: return; } } DEFINE_TERM_ACTION_1(erase_in_display, int) static void term_action_erase_in_line(struct vterm *const t, int mode) { const u16 entry = make_vgaentry(' ', DEFAULT_COLOR16); switch (mode) { case 0: for (u16 col = t->c; col < t->cols; col++) { buf_set_entry(t, t->r, col, entry); t->vi->set_char_at(t->r, col, entry); } break; case 1: for (u16 col = 0; col < t->c; col++) { buf_set_entry(t, t->r, col, entry); t->vi->set_char_at(t->r, col, entry); } break; case 2: ts_clear_row(t, t->r, vgaentry_get_color(entry)); break; default: return; } } DEFINE_TERM_ACTION_1(erase_in_line, int) static void term_action_del(struct vterm *const t, enum term_del_type del_type, int m) { switch (del_type) { case TERM_DEL_PREV_CHAR: term_internal_write_backspace(t, get_curr_cell_color(t)); break; case TERM_DEL_PREV_WORD: term_internal_delete_last_word(t, get_curr_cell_color(t)); break; case TERM_DEL_ERASE_IN_DISPLAY: term_action_erase_in_display(t, m); break; case TERM_DEL_ERASE_IN_LINE: term_action_erase_in_line(t, m); break; default: NOT_REACHED(); } } DEFINE_TERM_ACTION_2(del, enum term_del_type, int) static void term_action_ins_blank_chars(struct vterm *const t, u16 n) { const u16 row = t->r; u16 *const buf_row = get_buf_row(t, row); n = (u16)MIN(n, t->cols - t->c); memmove(&buf_row[t->c + n], &buf_row[t->c], 2 * (t->cols - t->c - n)); for (u16 c = t->c; c < t->c + n; c++) buf_row[c] = make_vgaentry(' ', vgaentry_get_color(buf_row[c])); for (u16 c = t->c; c < t->cols; c++) t->vi->set_char_at(row, c, buf_row[c]); } DEFINE_TERM_ACTION_1(ins_blank_chars, u16) static void term_action_del_chars_in_line(struct vterm *const t, u16 n) { const u16 row = t->r; u16 *const buf_row = get_buf_row(t, row); const u16 maxN = (u16)MIN(n, t->cols - t->c); const u16 cN = t->cols - t->c - maxN; /* copied count */ memmove(&buf_row[t->c], &buf_row[t->c + maxN], 2 * cN); for (u16 c = t->c + cN; c < MIN(t->c + cN + n - maxN, t->cols); c++) buf_row[c] = make_vgaentry(' ', vgaentry_get_color(buf_row[c])); for (u16 c = t->c; c < t->cols; c++) t->vi->set_char_at(row, c, buf_row[c]); } DEFINE_TERM_ACTION_1(del_chars_in_line, u16) static void term_action_erase_chars_in_line(struct vterm *const t, u16 n) { const u16 row = t->r; u16 *const buf_row = get_buf_row(t, row); for (u16 c = t->c; c < MIN(t->cols, t->c + n); c++) buf_row[c] = make_vgaentry(' ', vgaentry_get_color(buf_row[c])); for (u16 c = t->c; c < t->cols; c++) t->vi->set_char_at(row, c, buf_row[c]); } DEFINE_TERM_ACTION_1(erase_chars_in_line, u16) static void term_action_pause_output(struct vterm *const t) { if (t->vi->disable_static_elems_refresh) t->vi->disable_static_elems_refresh(); t->vi->disable_cursor(); t->saved_vi = t->vi; t->vi = &no_output_vi; } DEFINE_TERM_ACTION_0(pause_output) static void term_action_restart_output(struct vterm *const t) { t->vi = t->saved_vi; term_redraw(t); if (t->scroll == t->max_scroll) term_int_enable_cursor(t, t->cursor_enabled); if (!in_panic()) { if (t->vi->redraw_static_elements) t->vi->redraw_static_elements(); if (t->vi->enable_static_elems_refresh) t->vi->enable_static_elems_refresh(); } } DEFINE_TERM_ACTION_0(restart_output) static void term_action_use_alt_buffer(struct vterm *const t, bool use_alt_buffer) { u16 *b = get_buf_row(t, 0); if (t->using_alt_buffer == use_alt_buffer) return; if (use_alt_buffer) { if (!t->screen_buf_copy) { if (term_allocate_alt_buffers(t) < 0) return; /* just do nothing: the main buffer will be used */ } t->start_scroll_region = &t->alt_scroll_region_start; t->end_scroll_region = &t->alt_scroll_region_end; t->tabs_buf = t->alt_tabs_buf; t->saved_cur_row = t->r; t->saved_cur_col = t->c; memcpy(t->screen_buf_copy, b, sizeof(u16) * t->rows * t->cols); } else { ASSERT(t->screen_buf_copy != NULL); memcpy(b, t->screen_buf_copy, sizeof(u16) * t->rows * t->cols); t->r = t->saved_cur_row; t->c = t->saved_cur_col; t->tabs_buf = t->main_tabs_buf; t->start_scroll_region = &t->main_scroll_region_start; t->end_scroll_region = &t->main_scroll_region_end; } t->using_alt_buffer = use_alt_buffer; t->vi->disable_cursor(); term_redraw(t); term_int_enable_cursor(t, t->cursor_enabled); } DEFINE_TERM_ACTION_1(use_alt_buffer, bool) static void term_action_ins_blank_lines(struct vterm *const t, u32 n) { const u16 eR = *t->end_scroll_region + 1; if (!t->buffer || !n) return; if (t->r >= eR) return; /* we're outside the scrolling region: do nothing */ t->c = 0; n = MIN(n, (u32)(eR - t->r)); for (u32 row = eR - n; row > t->r; row--) buf_copy_row(t, row - 1 + n, row - 1); for (u16 row = t->r; row < t->r + n; row++) ts_buf_clear_row(t, row, DEFAULT_COLOR16); term_redraw_scroll_region(t); } DEFINE_TERM_ACTION_1(ins_blank_lines, u32) static void term_action_del_lines(struct vterm *const t, u32 n) { const u16 eR = *t->end_scroll_region + 1; if (!t->buffer || !n) return; if (t->r >= eR) return; /* we're outside the scrolling region: do nothing */ n = MIN(n, (u32)(eR - t->r)); for (u32 row = t->r; row <= t->r + n; row++) buf_copy_row(t, row, row + n); for (u32 row = eR - n; row < eR; row++) ts_buf_clear_row(t, (u16)row, DEFAULT_COLOR16); term_redraw_scroll_region(t); } DEFINE_TERM_ACTION_1(del_lines, u32) static void term_action_set_scroll_region(struct vterm *const t, u16 start, u16 end) { start = (u16) CLAMP(start, 0u, t->rows - 1u); end = (u16) CLAMP(end, 0u, t->rows - 1u); if (start >= end) return; *t->start_scroll_region = start; *t->end_scroll_region = end; term_int_move_cur(t, 0, 0); } DEFINE_TERM_ACTION_2(set_scroll_region, u16, u16)
26.29
77
0.573602
bba2eb02c10bb13c6479976112b6079b2aa890be
3,206
h
C
Source/TDRouter.h
amco/TouchDB-iOS
9296c47cc822f4d8a7f4b513603b4f623c4a3b8f
[ "Apache-2.0", "MIT" ]
null
null
null
Source/TDRouter.h
amco/TouchDB-iOS
9296c47cc822f4d8a7f4b513603b4f623c4a3b8f
[ "Apache-2.0", "MIT" ]
null
null
null
Source/TDRouter.h
amco/TouchDB-iOS
9296c47cc822f4d8a7f4b513603b4f623c4a3b8f
[ "Apache-2.0", "MIT" ]
null
null
null
// // TDRouter.h // TouchDB // // Created by Jens Alfke on 11/30/11. // Copyright (c) 2011 Couchbase, Inc. All rights reserved. // #import <TouchDB/TD_Database.h> @class TD_Server, TD_DatabaseManager, TDResponse, TD_Body, TDMultipartWriter; typedef TDStatus (^OnAccessCheckBlock)(TD_Database*, NSString *docID, SEL action); typedef void (^OnResponseReadyBlock)(TDResponse*); typedef void (^OnDataAvailableBlock)(NSData* data, BOOL finished); typedef void (^OnFinishedBlock)(); @interface TDRouter : NSObject { @private TD_Server* _server; TD_DatabaseManager* _dbManager; NSURLRequest* _request; NSMutableArray* _path; NSDictionary* _queries; TDResponse* _response; TD_Database* _db; BOOL _local; BOOL _waiting; BOOL _responseSent; BOOL _processRanges; OnAccessCheckBlock _onAccessCheck; OnResponseReadyBlock _onResponseReady; OnDataAvailableBlock _onDataAvailable; OnFinishedBlock _onFinished; BOOL _running; BOOL _longpoll; TD_FilterBlock _changesFilter; NSDictionary* _changesFilterParams; BOOL _changesIncludeDocs; BOOL _changesIncludeConflicts; } - (id) initWithServer: (TD_Server*)server request: (NSURLRequest*)request isLocal: (BOOL)isLocal; @property BOOL processRanges; @property (copy) OnAccessCheckBlock onAccessCheck; @property (copy) OnResponseReadyBlock onResponseReady; @property (copy) OnDataAvailableBlock onDataAvailable; @property (copy) OnFinishedBlock onFinished; @property (readonly) NSURLRequest* request; @property (readonly) TDResponse* response; - (void) start; - (void) stop; + (NSString*) versionString; @end @interface TDRouter (Internal) - (NSString*) query: (NSString*)param; - (BOOL) boolQuery: (NSString*)param; - (int) intQuery: (NSString*)param defaultValue: (int)defaultValue; - (id) jsonQuery: (NSString*)param error: (NSError**)outError; - (NSMutableDictionary*) jsonQueries; - (BOOL) cacheWithEtag: (NSString*)etag; - (TDContentOptions) contentOptions; - (BOOL) getQueryOptions: (struct TDQueryOptions*)options; @property (readonly) NSString* multipartRequestType; @property (readonly) NSDictionary* bodyAsDictionary; @property (readonly) NSString* ifMatch; - (TDStatus) openDB; - (void) sendResponseHeaders; - (void) sendResponseBodyAndFinish: (BOOL)finished; - (void) finished; @end @interface TDResponse : NSObject { @private TDStatus _internalStatus; int _status; NSString* _statusMsg; NSString* _statusReason; NSMutableDictionary* _headers; TD_Body* _body; } @property (nonatomic) TDStatus internalStatus; @property (nonatomic) int status; @property (nonatomic, readonly) NSString* statusMsg; @property (nonatomic, copy) NSString* statusReason; @property (nonatomic, strong) NSMutableDictionary* headers; @property (nonatomic, strong) TD_Body* body; @property (nonatomic, copy) id bodyObject; @property (nonatomic, readonly) NSString* baseContentType; - (void) reset; - (NSString*) objectForKeyedSubscript: (NSString*)header; - (void) setObject: (NSString*)value forKeyedSubscript:(NSString*)header; - (void) setMultipartBody: (TDMultipartWriter*)mp; - (void) setMultipartBody: (NSArray*)parts type: (NSString*)type; @end
28.625
97
0.752963
497635ebb30bbaf5a8ca2ee3bda97ef7f735815a
79
h
C
Source/CPUTemp/Plugins/PluginCPUTemp/sys.h
Lssg97/DetailedSystemMonitor
6a3411998a600e4a3bf025212bb827478a3dab02
[ "Intel" ]
87
2020-05-08T13:03:18.000Z
2022-03-29T08:12:15.000Z
Source/CPUTemp/Plugins/PluginCPUTemp/sys.h
Lssg97/DetailedSystemMonitor
6a3411998a600e4a3bf025212bb827478a3dab02
[ "Intel" ]
8
2021-01-02T10:25:42.000Z
2022-03-23T03:23:46.000Z
Source/CPUTemp/Plugins/PluginCPUTemp/sys.h
Lssg97/DetailedSystemMonitor
6a3411998a600e4a3bf025212bb827478a3dab02
[ "Intel" ]
9
2020-05-14T07:13:20.000Z
2021-08-24T11:53:14.000Z
#pragma once char WinRing0_sys[]; char WinRing0_vxd[]; char WinRing0X64_sys[];
15.8
23
0.772152
b507f699604620dad66fb200855f952958118a95
41,262
h
C
src/umouse_object/sound/robotol.h
GanonKuppa/kuwaganon
91ef0b0021e2fc4474f4f439d697f53e02872b44
[ "MIT" ]
null
null
null
src/umouse_object/sound/robotol.h
GanonKuppa/kuwaganon
91ef0b0021e2fc4474f4f439d697f53e02872b44
[ "MIT" ]
2
2019-09-19T00:02:52.000Z
2019-09-19T00:03:39.000Z
src/umouse_object/sound/robotol.h
GanonKuppa/kuwaganon
91ef0b0021e2fc4474f4f439d697f53e02872b44
[ "MIT" ]
null
null
null
//====================== const uint16_t robotol0[][2]= { {nR,384}, {57,48}, {56,144}, {57,48}, {69,48}, {57,48}, {57,96}, {69,48}, {57,48}, {69,48}, {57,48}, {57,48}, {59,48}, {60,240}, {57,48}, {69,48}, {57,48}, {57,96}, {69,48}, {57,48}, {69,48}, {57,48}, {57,48}, {59,48}, {60,240}, {59,144}, {60,144}, {62,96}, {60,144}, {62,144}, {60,96}, {59,384}, {64,48}, {52,48}, {54,48}, {56,48}, {57,48}, {59,48}, {60,48}, {62,48}, {57,48}, {69,48}, {57,48}, {57,96}, {69,48}, {57,48}, {69,48}, {57,48}, {57,48}, {59,48}, {60,240}, {57,48}, {69,48}, {57,48}, {57,96}, {69,48}, {57,48}, {69,48}, {57,48}, {57,48}, {59,48}, {60,240}, {59,144}, {60,144}, {62,96}, {64,144}, {65,48}, {53,48}, {67,96}, {65,48}, {64,96}, {52,48}, {64,48}, {52,48}, {64,48}, {52,48}, {64,48}, {76,336}, {69,12}, {71,12}, {72,12}, {76,12}, {77,384}, {79,288}, {77,48}, {79,48}, {81,144}, {76,144}, {72,144}, {71,144}, {69,96}, {67,96}, {69,384}, {72,240}, {71,48}, {69,48}, {67,48}, {69,96}, {57,48}, {71,144}, {72,144}, {74,144}, {76,96}, {79,48}, {69,12}, {71,12}, {72,12}, {76,12}, {77,384}, {79,288}, {77,48}, {79,48}, {81,144}, {76,144}, {72,144}, {71,144}, {69,96}, {67,96}, {69,48}, {69,48}, {53,48}, {69,48}, {69,48}, {65,48}, {69,48}, {69,48}, {53,48}, {69,48}, {69,48}, {65,48}, {69,48}, {65,48}, {69,48}, {65,48}, {68,48}, {64,48}, {62,48}, {71,48}, {68,48}, {64,48}, {74,48}, {71,48}, {68,48}, {80,48}, {74,48}, {71,48}, {80,48}, {74,48}, {71,48}, {55,48}, {57,48}, {69,48}, {57,48}, {57,96}, {69,48}, {57,48}, {69,48}, {57,48}, {57,48}, {59,48}, {60,240}, {57,48}, {69,48}, {57,48}, {57,96}, {69,48}, {57,48}, {69,48}, {57,48}, {57,48}, {59,48}, {60,240}, {59,144}, {60,144}, {62,96}, {60,144}, {62,144}, {60,96}, {59,384}, {64,48}, {52,48}, {54,48}, {56,48}, {57,48}, {59,48}, {60,48}, {62,48}, {57,48}, {69,48}, {57,48}, {57,96}, {69,48}, {57,48}, {69,48}, {57,48}, {57,48}, {59,48}, {60,240}, {57,48}, {69,48}, {57,48}, {57,96}, {69,48}, {57,48}, {69,48}, {57,48}, {57,48}, {59,48}, {60,240}, {59,144}, {60,144}, {62,96}, {64,144}, {65,48}, {53,48}, {67,96}, {65,48}, {64,96}, {52,48}, {64,48}, {52,48}, {64,48}, {52,48}, {64,48}, {76,336}, {69,12}, {71,12}, {72,12}, {76,12}, {77,384}, {79,288}, {77,48}, {79,48}, {81,144}, {76,144}, {72,144}, {71,144}, {69,96}, {67,96}, {69,384}, {72,240}, {71,48}, {69,48}, {67,48}, {69,96}, {57,48}, {71,144}, {72,144}, {74,144}, {76,96}, {79,48}, {69,12}, {71,12}, {72,12}, {76,12}, {77,384}, {79,288}, {77,48}, {79,48}, {81,144}, {76,144}, {72,144}, {71,144}, {69,96}, {67,96}, {69,48}, {69,48}, {53,48}, {69,48}, {69,48}, {65,48}, {69,48}, {69,48}, {53,48}, {69,48}, {69,48}, {65,48}, {69,48}, {65,48}, {69,48}, {65,48}, {68,48}, {64,48}, {62,48}, {71,48}, {68,48}, {64,48}, {74,48}, {71,48}, {68,48}, {80,48}, {74,48}, {71,48}, {80,48}, {74,48}, {71,48} //{55,432} }; //====================== const uint16_t robotol1[][2]= { {nR,384}, {57,48}, {56,144}, {57,96}, {45,48}, {57,240}, {45,48}, {57,48}, {59,48}, {60,240}, {57,96}, {45,48}, {57,240}, {45,48}, {57,48}, {59,48}, {60,240}, {59,144}, {60,144}, {62,96}, {60,144}, {62,144}, {60,96}, {59,384}, {37,96}, {54,48}, {56,48}, {57,48}, {59,48}, {60,48}, {62,48}, {57,96}, {45,48}, {57,240}, {45,48}, {57,48}, {59,48}, {60,240}, {57,96}, {45,48}, {57,240}, {45,48}, {57,48}, {59,48}, {60,240}, {59,144}, {60,144}, {62,96}, {64,144}, {65,96}, {67,96}, {65,48}, {64,384}, {76,336}, {69,12}, {71,12}, {72,12}, {76,12}, {77,384}, {79,288}, {77,48}, {79,48}, {81,144}, {76,144}, {72,144}, {71,144}, {69,96}, {67,96}, {69,384}, {72,240}, {71,48}, {69,48}, {67,48}, {69,144}, {71,144}, {72,144}, {74,144}, {76,96}, {79,48}, {69,12}, {71,12}, {72,12}, {76,12}, {77,384}, {79,288}, {77,48}, {79,48}, {81,144}, {76,144}, {72,144}, {71,144}, {69,96}, {67,96}, {69,48}, {69,48}, {81,48}, {69,48}, {69,48}, {81,48}, {69,48}, {69,48}, {81,48}, {69,48}, {69,48}, {81,48}, {69,48}, {81,48}, {69,48}, {81,48}, {68,48}, {64,48}, {62,48}, {71,48}, {68,48}, {64,48}, {74,48}, {71,48}, {68,48}, {80,48}, {74,48}, {71,48}, {80,48}, {74,48}, {71,48}, {38,48}, {57,96}, {45,48}, {57,240}, {45,48}, {57,48}, {59,48}, {60,240}, {57,96}, {45,48}, {57,240}, {45,48}, {57,48}, {59,48}, {60,240}, {59,144}, {60,144}, {62,96}, {60,144}, {62,144}, {60,96}, {59,384}, {37,96}, {54,48}, {56,48}, {57,48}, {59,48}, {60,48}, {62,48}, {57,96}, {45,48}, {57,240}, {45,48}, {57,48}, {59,48}, {60,240}, {57,96}, {45,48}, {57,240}, {45,48}, {57,48}, {59,48}, {60,240}, {59,144}, {60,144}, {62,96}, {64,144}, {65,96}, {67,96}, {65,48}, {64,384}, {76,336}, {69,12}, {71,12}, {72,12}, {76,12}, {77,384}, {79,288}, {77,48}, {79,48}, {81,144}, {76,144}, {72,144}, {71,144}, {69,96}, {67,96}, {69,384}, {72,240}, {71,48}, {69,48}, {67,48}, {69,144}, {71,144}, {72,144}, {74,144}, {76,96}, {79,48}, {69,12}, {71,12}, {72,12}, {76,12}, {77,384}, {79,288}, {77,48}, {79,48}, {81,144}, {76,144}, {72,144}, {71,144}, {69,96}, {67,96}, {69,48}, {69,48}, {81,48}, {69,48}, {69,48}, {81,48}, {69,48}, {69,48}, {81,48}, {69,48}, {69,48}, {81,48}, {69,48}, {81,48}, {69,48}, {81,48}, {68,48}, {64,48}, {62,48}, {71,48}, {68,48}, {64,48}, {74,48}, {71,48}, {68,48}, {80,48}, {74,48}, {71,48}, {80,48}, {74,48}, {71,48} //{38,432} }; //====================== const uint16_t robotol2[][2]= { {nR,384}, {52,48}, {52,144}, {57,96}, {55,48}, {69,48}, {57,192}, {37,96}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,96}, {55,48}, {69,48}, {57,192}, {37,96}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {52,48}, {64,48}, {52,48}, {64,48}, {52,48}, {64,48}, {52,48}, {64,48}, {53,48}, {65,48}, {53,48}, {65,48}, {53,48}, {65,48}, {53,48}, {65,48}, {52,48}, {64,48}, {52,48}, {64,48}, {52,48}, {64,48}, {52,48}, {64,48}, {32,96}, {50,48}, {52,48}, {53,48}, {55,48}, {57,48}, {59,48}, {57,96}, {55,48}, {69,48}, {57,192}, {37,96}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,96}, {55,48}, {69,48}, {57,192}, {37,96}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {52,48}, {64,48}, {52,48}, {64,48}, {52,48}, {64,48}, {52,48}, {64,48}, {53,48}, {65,48}, {53,48}, {65,96}, {65,48}, {53,48}, {65,48}, {52,48}, {64,336}, {52,48}, {64,48}, {52,48}, {64,48}, {52,48}, {64,48}, {52,48}, {64,48}, {53,48}, {65,48}, {53,48}, {65,48}, {53,48}, {65,48}, {53,48}, {65,48}, {55,48}, {67,48}, {55,48}, {67,48}, {55,48}, {67,48}, {55,48}, {67,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {53,48}, {65,48}, {53,48}, {65,48}, {53,48}, {65,48}, {53,48}, {65,48}, {55,48}, {67,48}, {55,48}, {67,48}, {55,48}, {67,48}, {55,48}, {67,48}, {57,48}, {69,96}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {53,48}, {65,48}, {53,48}, {65,48}, {53,48}, {65,48}, {53,48}, {65,48}, {55,48}, {67,48}, {55,48}, {67,48}, {55,48}, {67,48}, {55,48}, {67,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {53,48}, {65,48}, {41,48}, {65,48}, {53,48}, {41,48}, {53,48}, {65,48}, {41,48}, {65,48}, {53,48}, {41,48}, {53,48}, {41,48}, {53,48}, {41,48}, {62,48}, {59,48}, {59,48}, {65,48}, {62,48}, {62,48}, {68,48}, {65,48}, {65,48}, {71,48}, {68,48}, {68,48}, {71,48}, {68,48}, {68,48}, {42,48}, {57,96}, {55,48}, {69,48}, {57,192}, {37,96}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,96}, {55,48}, {69,48}, {57,192}, {37,96}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {52,48}, {64,48}, {52,48}, {64,48}, {52,48}, {64,48}, {52,48}, {64,48}, {53,48}, {65,48}, {53,48}, {65,48}, {53,48}, {65,48}, {53,48}, {65,48}, {52,48}, {64,48}, {52,48}, {64,48}, {52,48}, {64,48}, {52,48}, {64,48}, {32,96}, {50,48}, {52,48}, {53,48}, {55,48}, {57,48}, {59,48}, {57,96}, {55,48}, {69,48}, {57,192}, {37,96}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,96}, {55,48}, {69,48}, {57,192}, {37,96}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {52,48}, {64,48}, {52,48}, {64,48}, {52,48}, {64,48}, {52,48}, {64,48}, {53,48}, {65,48}, {53,48}, {65,96}, {65,48}, {53,48}, {65,48}, {52,48}, {64,336}, {52,48}, {64,48}, {52,48}, {64,48}, {52,48}, {64,48}, {52,48}, {64,48}, {53,48}, {65,48}, {53,48}, {65,48}, {53,48}, {65,48}, {53,48}, {65,48}, {55,48}, {67,48}, {55,48}, {67,48}, {55,48}, {67,48}, {55,48}, {67,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {53,48}, {65,48}, {53,48}, {65,48}, {53,48}, {65,48}, {53,48}, {65,48}, {55,48}, {67,48}, {55,48}, {67,48}, {55,48}, {67,48}, {55,48}, {67,48}, {57,48}, {69,96}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {53,48}, {65,48}, {53,48}, {65,48}, {53,48}, {65,48}, {53,48}, {65,48}, {55,48}, {67,48}, {55,48}, {67,48}, {55,48}, {67,48}, {55,48}, {67,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {57,48}, {69,48}, {53,48}, {65,48}, {41,48}, {65,48}, {53,48}, {41,48}, {53,48}, {65,48}, {41,48}, {65,48}, {53,48}, {41,48}, {53,48}, {41,48}, {53,48}, {41,48}, {62,48}, {59,48}, {59,48}, {65,48}, {62,48}, {62,48}, {68,48}, {65,48}, {65,48}, {71,48}, {68,48}, {68,48}, {71,48}, {68,48}, {68,48} //{42,432} }; //====================== const uint16_t robotol3[][2]= { {nR,384}, {45,48}, {44,144}, {45,48}, {45,48}, {38,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {32,96}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {38,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {32,96}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {32,96}, {42,48}, {44,48}, {45,48}, {47,48}, {48,48}, {50,48}, {45,48}, {45,48}, {38,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {32,96}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {38,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {32,96}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {71,48}, {40,48}, {71,48}, {40,48}, {71,48}, {40,48}, {71,48}, {40,48}, {72,48}, {71,48}, {69,48}, {74,48}, {72,48}, {71,48}, {72,48}, {74,96}, {72,48}, {71,48}, {72,48}, {71,48}, {69,48}, {67,48}, {64,48}, {72,48}, {71,48}, {69,48}, {71,48}, {69,48}, {67,48}, {69,48}, {67,48}, {65,48}, {67,48}, {65,48}, {64,48}, {65,48}, {64,48}, {62,48}, {60,48}, {65,48}, {64,48}, {65,48}, {65,96}, {64,48}, {65,96}, {67,48}, {65,48}, {67,48}, {67,96}, {67,48}, {62,48}, {62,48}, {57,48}, {57,48}, {57,48}, {64,48}, {57,48}, {57,48}, {57,48}, {57,48}, {57,48}, {60,48}, {57,48}, {64,48}, {57,48}, {57,48}, {57,48}, {57,48}, {72,48}, {71,48}, {69,48}, {74,48}, {72,48}, {71,48}, {72,48}, {74,96}, {72,48}, {71,48}, {72,48}, {71,48}, {69,48}, {67,48}, {64,48}, {72,48}, {71,48}, {69,48}, {71,48}, {69,48}, {67,48}, {69,48}, {67,48}, {65,48}, {67,48}, {65,48}, {64,48}, {65,48}, {64,48}, {62,48}, {60,48}, {64,48}, {64,48}, {38,96}, {64,48}, {37,48}, {64,48}, {64,48}, {37,96}, {64,48}, {42,48}, {64,48}, {37,48}, {64,48}, {42,48}, {44,96}, {37,48}, {44,96}, {37,48}, {44,96}, {37,48}, {44,96}, {37,48}, {44,192}, {45,48}, {45,48}, {38,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {32,96}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {38,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {32,96}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {32,96}, {42,48}, {44,48}, {45,48}, {47,48}, {48,48}, {50,48}, {45,48}, {45,48}, {38,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {32,96}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {38,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {32,96}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {40,48}, {71,48}, {40,48}, {71,48}, {40,48}, {71,48}, {40,48}, {71,48}, {40,48}, {72,48}, {71,48}, {69,48}, {74,48}, {72,48}, {71,48}, {72,48}, {74,96}, {72,48}, {71,48}, {72,48}, {71,48}, {69,48}, {67,48}, {64,48}, {72,48}, {71,48}, {69,48}, {71,48}, {69,48}, {67,48}, {69,48}, {67,48}, {65,48}, {67,48}, {65,48}, {64,48}, {65,48}, {64,48}, {62,48}, {60,48}, {65,48}, {64,48}, {65,48}, {65,96}, {64,48}, {65,96}, {67,48}, {65,48}, {67,48}, {67,96}, {67,48}, {62,48}, {62,48}, {57,48}, {57,48}, {57,48}, {64,48}, {57,48}, {57,48}, {57,48}, {57,48}, {57,48}, {60,48}, {57,48}, {64,48}, {57,48}, {57,48}, {57,48}, {57,48}, {72,48}, {71,48}, {69,48}, {74,48}, {72,48}, {71,48}, {72,48}, {74,96}, {72,48}, {71,48}, {72,48}, {71,48}, {69,48}, {67,48}, {64,48}, {72,48}, {71,48}, {69,48}, {71,48}, {69,48}, {67,48}, {69,48}, {67,48}, {65,48}, {67,48}, {65,48}, {64,48}, {65,48}, {64,48}, {62,48}, {60,48}, {64,48}, {64,48}, {38,96}, {64,48}, {37,48}, {64,48}, {64,48}, {37,96}, {64,48}, {42,48}, {64,48}, {37,48}, {64,48}, {42,48}, {44,96}, {37,48}, {44,96}, {37,48}, {44,96}, {37,48}, {44,96}, {37,48} //{44,192} }; //====================== const uint16_t robotol4[][2]= { {nR,384}, {55,48}, {55,144}, {37,96}, {42,48}, {37,48}, {37,96}, {55,96}, {42,48}, {69,48}, {55,48}, {32,48}, {37,96}, {55,96}, {37,96}, {42,48}, {37,48}, {37,96}, {55,96}, {42,48}, {69,48}, {55,48}, {32,48}, {37,96}, {55,96}, {37,96}, {55,48}, {32,48}, {37,96}, {55,96}, {37,96}, {55,48}, {37,48}, {37,96}, {55,96}, {37,96}, {55,48}, {32,48}, {37,96}, {55,96}, {37,96}, {42,96}, {42,96}, {42,96}, {37,96}, {42,48}, {37,48}, {37,96}, {55,96}, {42,48}, {69,48}, {55,48}, {32,48}, {37,96}, {55,96}, {37,96}, {42,48}, {37,48}, {37,96}, {55,96}, {42,48}, {69,48}, {55,48}, {32,48}, {37,96}, {55,96}, {37,96}, {55,48}, {32,48}, {37,96}, {55,96}, {37,96}, {55,48}, {37,48}, {37,96}, {55,96}, {37,96}, {55,48}, {32,48}, {37,96}, {55,96}, {40,48}, {42,48}, {40,48}, {37,96}, {37,48}, {40,48}, {42,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {41,48}, {41,48}, {55,96}, {41,48}, {32,48}, {41,48}, {41,48}, {32,96}, {41,48}, {nR,48}, {41,48}, {32,48}, {41,48}, {nR,48}, {38,48}, {37,48}, {32,48}, {55,48}, {37,48}, {32,48}, {55,48}, {37,48}, {32,48}, {38,48}, {37,48}, {32,48}, {38,48}, {55,48}, {38,48}, {nR,48}, {37,96}, {42,48}, {37,48}, {37,96}, {55,96}, {42,48}, {69,48}, {55,48}, {32,48}, {37,96}, {55,96}, {37,96}, {42,48}, {37,48}, {37,96}, {55,96}, {42,48}, {69,48}, {55,48}, {32,48}, {37,96}, {55,96}, {37,96}, {55,48}, {32,48}, {37,96}, {55,96}, {37,96}, {55,48}, {37,48}, {37,96}, {55,96}, {37,96}, {55,48}, {32,48}, {37,96}, {55,96}, {37,96}, {42,96}, {42,96}, {42,96}, {37,96}, {42,48}, {37,48}, {37,96}, {55,96}, {42,48}, {69,48}, {55,48}, {32,48}, {37,96}, {55,96}, {37,96}, {42,48}, {37,48}, {37,96}, {55,96}, {42,48}, {69,48}, {55,48}, {32,48}, {37,96}, {55,96}, {37,96}, {55,48}, {32,48}, {37,96}, {55,96}, {37,96}, {55,48}, {37,48}, {37,96}, {55,96}, {37,96}, {55,48}, {32,48}, {37,96}, {55,96}, {40,48}, {42,48}, {40,48}, {37,96}, {37,48}, {40,48}, {42,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {41,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {43,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {45,48}, {41,48}, {41,48}, {55,96}, {41,48}, {32,48}, {41,48}, {41,48}, {32,96}, {41,48}, {nR,48}, {41,48}, {32,48}, {41,48}, {nR,48}, {38,48}, {37,48}, {32,48}, {55,48}, {37,48}, {32,48}, {55,48}, {37,48}, {32,48}, {38,48}, {37,48}, {32,48}, {38,48}, {55,48}, {38,48} }; //====================== const uint16_t robotol5[][2]= { {nR,384}, {38,48}, {38,144}, {32,96}, {nR,48}, {32,48}, {32,96}, {38,96}, {nR,48}, {45,48}, {38,48}, {37,48}, {32,96}, {38,96}, {32,96}, {nR,48}, {32,48}, {32,96}, {38,96}, {nR,48}, {45,48}, {38,48}, {37,48}, {32,96}, {38,96}, {32,96}, {38,48}, {37,48}, {32,96}, {38,96}, {32,96}, {38,48}, {32,48}, {32,96}, {38,96}, {32,96}, {38,48}, {37,48}, {32,96}, {38,96}, {nR,48}, {52,48}, {42,96}, {42,96}, {42,96}, {32,96}, {nR,48}, {32,48}, {32,96}, {38,96}, {nR,48}, {45,48}, {38,48}, {37,48}, {32,96}, {38,96}, {32,96}, {nR,48}, {32,48}, {32,96}, {38,96}, {nR,48}, {45,48}, {38,48}, {37,48}, {32,96}, {38,96}, {32,96}, {38,48}, {37,48}, {32,96}, {38,96}, {32,96}, {38,48}, {32,48}, {32,96}, {38,96}, {32,96}, {38,48}, {37,48}, {32,96}, {38,96}, {37,96}, {38,48}, {32,96}, {32,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {42,48}, {64,48}, {37,48}, {42,48}, {55,96}, {42,48}, {64,48}, {38,96}, {37,48}, {42,48}, {55,96}, {55,48}, {32,48}, {42,48}, {38,48}, {32,48}, {42,48}, {38,48}, {32,48}, {42,48}, {55,48}, {32,48}, {42,48}, {55,48}, {38,48}, {55,48}, {nR,48}, {32,96}, {nR,48}, {32,48}, {32,96}, {38,96}, {nR,48}, {45,48}, {38,48}, {37,48}, {32,96}, {38,96}, {32,96}, {nR,48}, {32,48}, {32,96}, {38,96}, {nR,48}, {45,48}, {38,48}, {37,48}, {32,96}, {38,96}, {32,96}, {38,48}, {37,48}, {32,96}, {38,96}, {32,96}, {38,48}, {32,48}, {32,96}, {38,96}, {32,96}, {38,48}, {37,48}, {32,96}, {38,96}, {nR,48}, {52,48}, {42,96}, {42,96}, {42,96}, {32,96}, {nR,48}, {32,48}, {32,96}, {38,96}, {nR,48}, {45,48}, {38,48}, {37,48}, {32,96}, {38,96}, {32,96}, {nR,48}, {32,48}, {32,96}, {38,96}, {nR,48}, {45,48}, {38,48}, {37,48}, {32,96}, {38,96}, {32,96}, {38,48}, {37,48}, {32,96}, {38,96}, {32,96}, {38,48}, {32,48}, {32,96}, {38,96}, {32,96}, {38,48}, {37,48}, {32,96}, {38,96}, {37,96}, {38,48}, {32,96}, {32,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {38,96}, {37,48}, {37,48}, {55,96}, {37,96}, {42,48}, {64,48}, {37,48}, {42,48}, {55,96}, {42,48}, {64,48}, {38,96}, {37,48}, {42,48}, {55,96}, {55,48}, {32,48}, {42,48}, {38,48}, {32,48}, {42,48}, {38,48}, {32,48}, {42,48}, {55,48}, {32,48}, {42,48}, {55,48}, {38,48}, {55,48} }; //====================== const uint16_t robotol6[][2]= { {nR,384}, {55,48}, {55,144}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {nR,48}, {52,48}, {nR,288}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {32,96}, {55,48}, {42,48}, {40,48}, {42,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {nR,48}, {41,48}, {32,48}, {nR,48}, {38,96}, {nR,48}, {41,48}, {55,96}, {32,48}, {nR,48}, {38,96}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {nR,48}, {52,48}, {nR,288}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {32,96}, {55,48}, {42,48}, {40,48}, {42,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {55,96}, {32,48}, {32,48}, {38,96}, {32,96}, {nR,48}, {41,48}, {32,48}, {nR,48}, {38,96}, {nR,48}, {41,48}, {55,96}, {32,48}, {nR,48}, {38,96}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {42,48} }; //====================== const uint16_t robotol7[][2]= { {nR,384}, {38,48}, {38,144}, {nR,2736}, {40,48}, {nR,2976}, {42,48}, {nR,48}, {42,48}, {nR,48}, {42,48}, {nR,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {nR,48}, {42,48}, {nR,3552}, {40,48}, {nR,2976}, {42,48}, {nR,48}, {42,48}, {nR,48}, {42,48}, {nR,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {42,48}, {nR,48}, {42,48}, {nR,48}, {42,48} }; void robotol(void) { Note note; BGMM.enable=false; BGMM.wave_form_data[0] = KUKEI12_5; BGMM.wave_volume_data[0] = 12; //各トラックのボリューム volume_resolution段階 BGMM.wave_form_data[1] = KUKEI12_5; BGMM.wave_volume_data[1] = 6; //各トラックのボリューム volume_resolution段階 BGMM.wave_form_data[2] = KUKEI12_5; BGMM.wave_volume_data[2] = 6; //各トラックのボリューム volume_resolution段階 BGMM.wave_form_data[3] = KUKEI12_5; BGMM.wave_volume_data[3] = 6; //各トラックのボリューム volume_resolution段階 BGMM.wave_form_data[4] = KUKEI12_5; BGMM.wave_volume_data[4] = 6; //各トラックのボリューム volume_resolution段階 BGMM.wave_form_data[5] = KUKEI12_5; BGMM.wave_volume_data[5] = 6; //各トラックのボリューム volume_resolution段階 BGMM.wave_form_data[6] = KUKEI12_5; BGMM.wave_volume_data[6] = 6; //各トラックのボリューム volume_resolution段階 BGMM.wave_form_data[7] = KUKEI12_5; BGMM.wave_volume_data[7] = 6; //各トラックのボリューム volume_resolution段階 //8,8,12,10 BGMM.bpm = 40; //myprintf3("bpm:%d\n",BGMM.bpm); uint16_t len0 = sizeof(robotol0)/sizeof(robotol0[0]); for(int i=0; i<len0; i++) { note.pitch = robotol0[i][0]; note.len = robotol0[i][1]; BGMM.noteBuff[0].push(note); } uint16_t len1 = sizeof(robotol1)/sizeof(robotol1[0]); for(int i=0; i<len1; i++) { note.pitch = robotol1[i][0] ; note.len = robotol1[i][1]; BGMM.noteBuff[1].push(note); } uint16_t len2 = sizeof(robotol2)/sizeof(robotol2[0]); for(int i=0; i<len2; i++) { note.pitch = robotol2[i][0] ; note.len = robotol2[i][1]; BGMM.noteBuff[2].push(note); } uint16_t len3 = sizeof(robotol3)/sizeof(robotol3[0]); for(int i=0; i<len3; i++) { note.pitch = robotol3[i][0]; note.len = robotol3[i][1]; BGMM.noteBuff[3].push(note); } uint16_t len4 = sizeof(robotol4)/sizeof(robotol4[0]); for(int i=0; i<len4; i++) { note.pitch = robotol4[i][0] ; note.len = robotol4[i][1]; BGMM.noteBuff[4].push(note); } uint16_t len5 = sizeof(robotol5)/sizeof(robotol5[0]); for(int i=0; i<len5; i++) { note.pitch = robotol5[i][0] ; note.len = robotol5[i][1]; BGMM.noteBuff[5].push(note); } uint16_t len6 = sizeof(robotol6)/sizeof(robotol6[0]); for(int i=0; i<len6; i++) { note.pitch = robotol6[i][0] ; note.len = robotol6[i][1]; BGMM.noteBuff[6].push(note); } uint16_t len7 = sizeof(robotol7)/sizeof(robotol7[0]); for(int i=0; i<len7; i++) { note.pitch = robotol7[i][0] ; note.len = robotol7[i][1]; BGMM.noteBuff[7].push(note); } BGMM.enable=true; }
13.631318
72
0.330425
77d483873b777e5e687795d0cd903886256fd7af
782
h
C
src/client/ClientState.h
bqqbarbhg/spear
727f41fa5197f9681337d1ff37ea63c44708f0d4
[ "BSD-3-Clause" ]
29
2020-07-27T09:56:02.000Z
2022-03-28T01:38:07.000Z
src/client/ClientState.h
bqqbarbhg/spear
727f41fa5197f9681337d1ff37ea63c44708f0d4
[ "BSD-3-Clause" ]
3
2020-05-29T11:43:20.000Z
2020-09-04T09:56:56.000Z
src/client/ClientState.h
bqqbarbhg/spear
727f41fa5197f9681337d1ff37ea63c44708f0d4
[ "BSD-3-Clause" ]
2
2020-05-29T11:34:46.000Z
2021-03-08T08:39:07.000Z
#pragma once #include "client/System.h" #include "server/ServerState.h" #include "sf/HashSet.h" namespace sf { struct Ray; } namespace cl { struct ClientState { uint32_t localClientId = 0; Systems systems; ClientState(const SystemsDesc &desc); void applyEventImmediate(const sv::Event &event); void applyEventQueued(const sf::Box<sv::Event> &event); void writePersist(ClientPersist &persist); void editorPick(sf::Array<EntityHit> &hits, const sf::Ray &ray) const; void editorHighlight(uint32_t entityId, EditorHighlight type); void updateCamera(FrameArgs &frameArgs); void update(const sv::ServerState *svState, const FrameArgs &frameArgs); void renderShadows(); void renderMain(const RenderArgs &renderArgs); void handleGui(const GuiArgs &guiArgs); }; }
20.578947
73
0.755754