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
d230eac83803469616a25e9a51be9609a97e8828
723
h
C
cinn/optim/fold_cinn_call_arguments.h
edithgogo/CINN
bed13f4752d80d01a3e1d96a4cc4f5aa56b1e292
[ "Apache-2.0" ]
1
2019-10-23T09:16:23.000Z
2019-10-23T09:16:23.000Z
cinn/optim/fold_cinn_call_arguments.h
edithgogo/CINN
bed13f4752d80d01a3e1d96a4cc4f5aa56b1e292
[ "Apache-2.0" ]
null
null
null
cinn/optim/fold_cinn_call_arguments.h
edithgogo/CINN
bed13f4752d80d01a3e1d96a4cc4f5aa56b1e292
[ "Apache-2.0" ]
null
null
null
#pragma once #include <string> #include "cinn/ir/ir.h" namespace cinn { namespace optim { /** * \brief Rewrite the Call Nodes marked type as CINN, pack their arguments into `void*, int` so that they can trigger a * `LoweredFunc`. * * For example, input the IR * \code * Call(some_lowered_func, a:cinn_buffer_t*, b:cinn_buffer_t*, c:cinn_buffer_t*) * \endcode * * This pass will rewrite it to * \code * cinn_pod_value_t a_(a); * cinn_pod_value_t b_(b); * cinn_pod_value_t c_(c); * * cinn_args_construct(packed_args, a_, b_, c_); * Call(some_lowered_func, packed_args, 3); // 3 is the number of arguments * \endcode */ void FoldCINNCallArguments(Expr* expr); } // namespace optim } // namespace cinn
21.909091
119
0.697095
9a83ca284c0ef90a240136ffe24fc18bcc30fc00
2,131
h
C
Onyx2D/include/Onyx2D/O2Paint_ramp.h
mrolappe/darling-cocotron
d7cc4e3ff153f8986b911fbb0a7f7b9d6d74022c
[ "MIT" ]
32
2018-01-17T16:25:13.000Z
2021-12-04T20:28:31.000Z
Onyx2D/include/Onyx2D/O2Paint_ramp.h
mrolappe/darling-cocotron
d7cc4e3ff153f8986b911fbb0a7f7b9d6d74022c
[ "MIT" ]
11
2019-06-11T03:31:30.000Z
2021-06-29T03:08:59.000Z
Onyx2D/include/Onyx2D/O2Paint_ramp.h
mrolappe/darling-cocotron
d7cc4e3ff153f8986b911fbb0a7f7b9d6d74022c
[ "MIT" ]
16
2019-06-11T01:49:14.000Z
2021-06-29T03:10:59.000Z
/*------------------------------------------------------------------------ * * Derivative of the OpenVG 1.0.1 Reference Implementation * ------------------------------------- * * Copyright (c) 2007 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and /or associated documentation files * (the "Materials "), to deal in the Materials without restriction, * including without limitation the rights to use, copy, modify, merge, * publish, distribute, sublicense, and/or sell copies of the Materials, * and to permit persons to whom the Materials are 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 Materials. * * THE MATERIALS ARE 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 MATERIALS OR * THE USE OR OTHER DEALINGS IN THE MATERIALS. * *-------------------------------------------------------------------*/ #import <Onyx2D/O2Paint.h> @class O2Shading; typedef struct { O2Float offset; O2argb32f color32f; O2argb8u color8u; } GradientStop; @interface O2Paint_ramp : O2Paint { O2Point _startPoint; O2Point _endPoint; BOOL _extendStart; BOOL _extendEnd; size_t _numberOfColorStops; GradientStop *_colorStops; } O2argb32f O2PaintIntegrateColorRamp(O2Paint_ramp *self, O2Float gmin, O2Float gmax); O2argb32f O2PaintColorRamp(O2Paint_ramp *self, O2Float gradient, O2Float rho, int *skip); - initWithShading: (O2Shading *) shading deviceTransform: (O2AffineTransform) deviceTransform numberOfSamples: (int) numberOfSamples; @end
36.741379
78
0.666354
9adb7cf2bf7d3ef3ddb61c7b60ea9dfbf7b9920e
7,841
h
C
.upstream-tests/test/std/numerics/complex.number/cases.h
veictry/libcudacxx
1458b2ca899d07bbb1c6126a260c02d9c1961be8
[ "Apache-2.0" ]
null
null
null
.upstream-tests/test/std/numerics/complex.number/cases.h
veictry/libcudacxx
1458b2ca899d07bbb1c6126a260c02d9c1961be8
[ "Apache-2.0" ]
null
null
null
.upstream-tests/test/std/numerics/complex.number/cases.h
veictry/libcudacxx
1458b2ca899d07bbb1c6126a260c02d9c1961be8
[ "Apache-2.0" ]
null
null
null
//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // <complex> // test cases #ifndef CASES_H #define CASES_H #include <cuda/std/complex> #include <cuda/std/cassert> #ifdef __CUDA_ARCH__ __constant__ #else const #endif cuda::std::complex<double> testcases[] = { cuda::std::complex<double>( 1.e-6, 1.e-6), cuda::std::complex<double>(-1.e-6, 1.e-6), cuda::std::complex<double>(-1.e-6, -1.e-6), cuda::std::complex<double>( 1.e-6, -1.e-6), cuda::std::complex<double>( 1.e+6, 1.e-6), cuda::std::complex<double>(-1.e+6, 1.e-6), cuda::std::complex<double>(-1.e+6, -1.e-6), cuda::std::complex<double>( 1.e+6, -1.e-6), cuda::std::complex<double>( 1.e-6, 1.e+6), cuda::std::complex<double>(-1.e-6, 1.e+6), cuda::std::complex<double>(-1.e-6, -1.e+6), cuda::std::complex<double>( 1.e-6, -1.e+6), cuda::std::complex<double>( 1.e+6, 1.e+6), cuda::std::complex<double>(-1.e+6, 1.e+6), cuda::std::complex<double>(-1.e+6, -1.e+6), cuda::std::complex<double>( 1.e+6, -1.e+6), cuda::std::complex<double>(NAN, NAN), cuda::std::complex<double>(-INFINITY, NAN), cuda::std::complex<double>(-2, NAN), cuda::std::complex<double>(-1, NAN), cuda::std::complex<double>(-0.5, NAN), cuda::std::complex<double>(-0., NAN), cuda::std::complex<double>(+0., NAN), cuda::std::complex<double>(0.5, NAN), cuda::std::complex<double>(1, NAN), cuda::std::complex<double>(2, NAN), cuda::std::complex<double>(INFINITY, NAN), cuda::std::complex<double>(NAN, -INFINITY), cuda::std::complex<double>(-INFINITY, -INFINITY), cuda::std::complex<double>(-2, -INFINITY), cuda::std::complex<double>(-1, -INFINITY), cuda::std::complex<double>(-0.5, -INFINITY), cuda::std::complex<double>(-0., -INFINITY), cuda::std::complex<double>(+0., -INFINITY), cuda::std::complex<double>(0.5, -INFINITY), cuda::std::complex<double>(1, -INFINITY), cuda::std::complex<double>(2, -INFINITY), cuda::std::complex<double>(INFINITY, -INFINITY), cuda::std::complex<double>(NAN, -2), cuda::std::complex<double>(-INFINITY, -2), cuda::std::complex<double>(-2, -2), cuda::std::complex<double>(-1, -2), cuda::std::complex<double>(-0.5, -2), cuda::std::complex<double>(-0., -2), cuda::std::complex<double>(+0., -2), cuda::std::complex<double>(0.5, -2), cuda::std::complex<double>(1, -2), cuda::std::complex<double>(2, -2), cuda::std::complex<double>(INFINITY, -2), cuda::std::complex<double>(NAN, -1), cuda::std::complex<double>(-INFINITY, -1), cuda::std::complex<double>(-2, -1), cuda::std::complex<double>(-1, -1), cuda::std::complex<double>(-0.5, -1), cuda::std::complex<double>(-0., -1), cuda::std::complex<double>(+0., -1), cuda::std::complex<double>(0.5, -1), cuda::std::complex<double>(1, -1), cuda::std::complex<double>(2, -1), cuda::std::complex<double>(INFINITY, -1), cuda::std::complex<double>(NAN, -0.5), cuda::std::complex<double>(-INFINITY, -0.5), cuda::std::complex<double>(-2, -0.5), cuda::std::complex<double>(-1, -0.5), cuda::std::complex<double>(-0.5, -0.5), cuda::std::complex<double>(-0., -0.5), cuda::std::complex<double>(+0., -0.5), cuda::std::complex<double>(0.5, -0.5), cuda::std::complex<double>(1, -0.5), cuda::std::complex<double>(2, -0.5), cuda::std::complex<double>(INFINITY, -0.5), cuda::std::complex<double>(NAN, -0.), cuda::std::complex<double>(-INFINITY, -0.), cuda::std::complex<double>(-2, -0.), cuda::std::complex<double>(-1, -0.), cuda::std::complex<double>(-0.5, -0.), cuda::std::complex<double>(-0., -0.), cuda::std::complex<double>(+0., -0.), cuda::std::complex<double>(0.5, -0.), cuda::std::complex<double>(1, -0.), cuda::std::complex<double>(2, -0.), cuda::std::complex<double>(INFINITY, -0.), cuda::std::complex<double>(NAN, +0.), cuda::std::complex<double>(-INFINITY, +0.), cuda::std::complex<double>(-2, +0.), cuda::std::complex<double>(-1, +0.), cuda::std::complex<double>(-0.5, +0.), cuda::std::complex<double>(-0., +0.), cuda::std::complex<double>(+0., +0.), cuda::std::complex<double>(0.5, +0.), cuda::std::complex<double>(1, +0.), cuda::std::complex<double>(2, +0.), cuda::std::complex<double>(INFINITY, +0.), cuda::std::complex<double>(NAN, 0.5), cuda::std::complex<double>(-INFINITY, 0.5), cuda::std::complex<double>(-2, 0.5), cuda::std::complex<double>(-1, 0.5), cuda::std::complex<double>(-0.5, 0.5), cuda::std::complex<double>(-0., 0.5), cuda::std::complex<double>(+0., 0.5), cuda::std::complex<double>(0.5, 0.5), cuda::std::complex<double>(1, 0.5), cuda::std::complex<double>(2, 0.5), cuda::std::complex<double>(INFINITY, 0.5), cuda::std::complex<double>(NAN, 1), cuda::std::complex<double>(-INFINITY, 1), cuda::std::complex<double>(-2, 1), cuda::std::complex<double>(-1, 1), cuda::std::complex<double>(-0.5, 1), cuda::std::complex<double>(-0., 1), cuda::std::complex<double>(+0., 1), cuda::std::complex<double>(0.5, 1), cuda::std::complex<double>(1, 1), cuda::std::complex<double>(2, 1), cuda::std::complex<double>(INFINITY, 1), cuda::std::complex<double>(NAN, 2), cuda::std::complex<double>(-INFINITY, 2), cuda::std::complex<double>(-2, 2), cuda::std::complex<double>(-1, 2), cuda::std::complex<double>(-0.5, 2), cuda::std::complex<double>(-0., 2), cuda::std::complex<double>(+0., 2), cuda::std::complex<double>(0.5, 2), cuda::std::complex<double>(1, 2), cuda::std::complex<double>(2, 2), cuda::std::complex<double>(INFINITY, 2), cuda::std::complex<double>(NAN, INFINITY), cuda::std::complex<double>(-INFINITY, INFINITY), cuda::std::complex<double>(-2, INFINITY), cuda::std::complex<double>(-1, INFINITY), cuda::std::complex<double>(-0.5, INFINITY), cuda::std::complex<double>(-0., INFINITY), cuda::std::complex<double>(+0., INFINITY), cuda::std::complex<double>(0.5, INFINITY), cuda::std::complex<double>(1, INFINITY), cuda::std::complex<double>(2, INFINITY), cuda::std::complex<double>(INFINITY, INFINITY) }; enum {zero, non_zero, inf, NaN, non_zero_nan}; template <class T> __host__ __device__ int classify(const cuda::std::complex<T>& x) { if (x == cuda::std::complex<T>()) return zero; if (cuda::std::isinf(x.real()) || cuda::std::isinf(x.imag())) return inf; if (cuda::std::isnan(x.real()) && cuda::std::isnan(x.imag())) return NaN; if (cuda::std::isnan(x.real())) { if (x.imag() == T(0)) return NaN; return non_zero_nan; } if (cuda::std::isnan(x.imag())) { if (x.real() == T(0)) return NaN; return non_zero_nan; } return non_zero; } inline __host__ __device__ int classify(double x) { if (x == 0) return zero; if (cuda::std::isinf(x)) return inf; if (cuda::std::isnan(x)) return NaN; return non_zero; } __host__ __device__ void is_about(float x, float y) { assert(cuda::std::abs((x-y)/(x+y)) < 1.e-6); } __host__ __device__ void is_about(double x, double y) { assert(cuda::std::abs((x-y)/(x+y)) < 1.e-14); } // CUDA treats long double as double /* __host__ __device__ void is_about(long double x, long double y) { assert(cuda::std::abs((x-y)/(x+y)) < 1.e-14); } */ #endif // CASES_H
33.084388
80
0.572886
965bd21e4b5c34ea44d719b56b51ba10dcd126a4
2,140
h
C
thirdparty/cgal/CGAL-4.13/include/CGAL/predicates/Polygon_offset_pred_ftC2.h
st4ll1/dust3d
c1de02f7ddcfdacc730cc96740f8073f87e7818c
[ "MIT" ]
null
null
null
thirdparty/cgal/CGAL-4.13/include/CGAL/predicates/Polygon_offset_pred_ftC2.h
st4ll1/dust3d
c1de02f7ddcfdacc730cc96740f8073f87e7818c
[ "MIT" ]
null
null
null
thirdparty/cgal/CGAL-4.13/include/CGAL/predicates/Polygon_offset_pred_ftC2.h
st4ll1/dust3d
c1de02f7ddcfdacc730cc96740f8073f87e7818c
[ "MIT" ]
null
null
null
// Copyright (c) 2006 Fernando Luis Cacciola Carballal. All rights reserved. // // This file is part of CGAL (www.cgal.org). // You can redistribute it and/or modify it under the terms of the GNU // General Public License as published by the Free Software Foundation, // either version 3 of the License, or (at your option) any later version. // // Licensees holding a valid commercial license may use this file in // accordance with the commercial license agreement provided with the software. // // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0+ // // Author(s) : Fernando Cacciola <fernando_cacciola@ciudad.com.ar> // #ifndef CGAL_POLYGON_OFFSET_PRED_FTC2_H #define CGAL_POLYGON_OFFSET_PRED_FTC2_H 1 #include <CGAL/license/Straight_skeleton_2.h> #include <CGAL/constructions/Straight_skeleton_cons_ftC2.h> namespace CGAL { namespace CGAL_SS_i { // Given a triple of oriented straight line segments: (e0,e1,e2) such that // there exists a distance 'et' for which the offsets lines at 'et' (e0',e1',e2') intersect in a single point; // returns the relative order of 't' w.r.t 'et'. // PRECONDITION: There exist a positive distance et for which the offset triple intersect at a single point. template<class K> Uncertain<Comparison_result> compare_offset_against_isec_timeC2 ( typename K::FT const& t, intrusive_ptr< Trisegment_2<K> > const& tri ) { typedef typename K::FT FT ; typedef Rational<FT> Rational ; typedef Quotient<FT> Quotient ; typedef optional<Rational> Optional_rational ; Uncertain<Comparison_result> rResult = Uncertain<Comparison_result>::indeterminate(); Optional_rational et_ = compute_offset_lines_isec_timeC2(tri); if ( et_ ) { Quotient et = et_->to_quotient(); CGAL_assertion ( CGAL_NTS certified_is_positive(et) ) ; rResult = CGAL_NTS certified_compare( Quotient(t), et); } return rResult ; } } // namespace CGAL_SS_i } // end namespace CGAL #endif // CGAL_POLYGON_OFFSET_PRED_FTC2_H // // EOF //
30.571429
136
0.743925
1908484b79b51a1546b6763ab29b8625ff73313a
2,669
c
C
test/ecdsa_test.c
TommasoBruni/cry
ebe11269cd505f0837930d991e3e4477dfbb77bb
[ "MIT" ]
null
null
null
test/ecdsa_test.c
TommasoBruni/cry
ebe11269cd505f0837930d991e3e4477dfbb77bb
[ "MIT" ]
null
null
null
test/ecdsa_test.c
TommasoBruni/cry
ebe11269cd505f0837930d991e3e4477dfbb77bb
[ "MIT" ]
null
null
null
#include "test.h" #include <cry/ecdsa.h> static cry_ecdsa_ctx ecdsa; static cry_ecdsa_sig sig; /* key */ static const unsigned char d_dat[] = { 0x16, 0x79, 0x7b, 0x5c, 0x0c, 0x7e, 0xd5, 0x46, 0x1e, 0x2f, 0xf1, 0xb8, 0x8e, 0x6e, 0xaf, 0xa0, 0x3c, 0x0f, 0x46, 0xbf, 0x07, 0x20, 0x00, 0xdf, 0xc8, 0x30, 0xd6, 0x15, }; static const unsigned char sha[] = { 0x69, 0x93, 0x25, 0xd6, 0xfc, 0x8f, 0xbb, 0xb4, 0x98, 0x1a, 0x6d, 0xed, 0x3c, 0x3a, 0x54, 0xad, 0x2e, 0x4e, 0x3d, 0xb8, 0xa5, 0x66, 0x92, 0x01, 0x91, 0x20, 0x64, 0xc6, 0x4e, 0x70, 0x0c, 0x13, 0x92, 0x48, 0xcd, 0xc1, }; static void sign_verify(void) { /* Load a well known curve params */ cry_ecp_grp_clear(&ecdsa.grp); ASSERT_OK(cry_ecp_grp_load(&ecdsa.grp, CRY_ECP_GRP_SECP224R1)); #if 0 ASSERT_OK(cry_ecdsa_keygen(&ecdsa.grp, &ecdsa.d, &ecdsa.q)); #else cry_mpi_load_bin(&ecdsa.d, d_dat, sizeof(d_dat)); cry_ecp_mul(&ecdsa.q, &ecdsa.grp.g, &ecdsa.d, &ecdsa.grp); #endif ASSERT_OK(cry_ecdsa_sign(&ecdsa, &sig, sha, sizeof(sha))); #if 0 PRINT_MPI("p", &ecdsa.grp.p, 16); PRINT_MPI("a", &ecdsa.grp.a, 16); PRINT_MPI("b", &ecdsa.grp.b, 16); PRINT_MPI("g.x", &ecdsa.grp.g.x, 16); PRINT_MPI("g.y", &ecdsa.grp.g.y, 16); PRINT_MPI("n", &ecdsa.grp.n, 16); PRINT_MPI("d", &ecdsa.d, 16); PRINT_MPI("q.x", &ecdsa.q.x, 16); PRINT_MPI("q.y", &ecdsa.q.y, 16); PRINT_MPI("r", &sig.r, 16); PRINT_MPI("s", &sig.s, 16); #endif ASSERT_OK(cry_ecdsa_verify(&ecdsa, &sig, sha, sizeof(sha))); } static void sign_verify_small(void) { unsigned char v = 26; /* Load a well known curve params */ cry_mpi_set_int(&ecdsa.grp.p, 17); cry_mpi_set_int(&ecdsa.grp.a, 2); cry_mpi_set_int(&ecdsa.grp.b, 10); cry_mpi_set_int(&ecdsa.grp.n, 19); cry_mpi_set_int(&ecdsa.grp.g.x, 5); cry_mpi_set_int(&ecdsa.grp.g.y, 1); cry_mpi_set_int(&ecdsa.grp.g.z, 1); #if 0 ASSERT_OK(cry_ecdsa_keygen(&ecdsa.grp, &ecdsa.d, &ecdsa.q)); #else cry_mpi_set_int(&ecdsa.d, 7); cry_ecp_mul(&ecdsa.q, &ecdsa.grp.g, &ecdsa.d, &ecdsa.grp); #endif ASSERT_OK(cry_ecdsa_sign(&ecdsa, &sig, &v, 1)); ASSERT_OK(cry_ecdsa_verify(&ecdsa, &sig, &v, 1)); } static void setup(void) { cry_ecdsa_init(&ecdsa, -1); cry_mpi_init_list(&sig.r, &sig.s, NULL); } static void teardown(void) { cry_ecdsa_clear(&ecdsa); cry_mpi_clear_list(&sig.r, &sig.s, NULL); } #define MYRUN(name, test) run(name, test, setup, teardown) void ecdsa_test(void) { TRACE("* ECDSA\n"); MYRUN("Sign and verify (trivially small)", sign_verify_small); MYRUN("Sign and verify", sign_verify); TRACE("\n"); }
26.69
67
0.637692
65e1c18e1a816317f714126a89cfd243f8f5af87
8,974
c
C
l2tpd-0.69+codebay/avpsend.c
nakedible/vpnease-l2tp
0fcda6a757f2bc5c37f4753b3cd8b1c6d282db5c
[ "WTFPL" ]
5
2015-04-16T08:36:17.000Z
2017-05-12T17:20:12.000Z
l2tpd-0.69+codebay/avpsend.c
nakedible/vpnease-l2tp
0fcda6a757f2bc5c37f4753b3cd8b1c6d282db5c
[ "WTFPL" ]
null
null
null
l2tpd-0.69+codebay/avpsend.c
nakedible/vpnease-l2tp
0fcda6a757f2bc5c37f4753b3cd8b1c6d282db5c
[ "WTFPL" ]
4
2015-03-19T14:39:51.000Z
2019-01-23T08:22:55.000Z
/* * Layer Two Tunnelling Protocol Daemon * Copyright (C) 1998 Adtran, Inc. * Copyright (C) 2002 Jeff McAdams * * Mark Spencer * * This software is distributed under the terms * of the GPL, which you should have received * along with this source. * * Attribute Value Pair creating routines */ #include <stdlib.h> #include <string.h> #include <netinet/in.h> #include "l2tp.h" /* * These routines should add avp's to a buffer * to be sent */ /* FIXME: If SANITY is on, we should check for buffer overruns */ /* FIXME: Can't this be condensed alot? */ int add_message_type_avp (struct buffer *buf, _u16 type) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons (0x8 | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = 0; raw[3] = htons (type); buf->len += 8; return 0; } int add_protocol_avp (struct buffer *buf) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons (0x8 | MBIT); /* Length and M bit */ raw[1] = htons (VENDOR_ID); raw[2] = htons (0x2); /* Value of our AVP */ raw[3] = htons (OUR_L2TP_VERSION); buf->len += 8; return 0; } int add_frame_caps_avp (struct buffer *buf, _u16 caps) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons (0xA | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = htons (0x3); raw[3] = 0; raw[4] = htons (caps); buf->len += 10; return 0; } int add_bearer_caps_avp (struct buffer *buf, _u16 caps) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons (0xA | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = htons (0x4); raw[3] = 0; raw[4] = htons (caps); buf->len += 10; return 0; } /* FIXME: I need to send tie breaker AVP's */ int add_firmware_avp (struct buffer *buf) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons (0x8); raw[1] = htons (VENDOR_ID); raw[2] = htons (0x6); raw[3] = htons (FIRMWARE_REV); buf->len += 8; return 0; } /* int add_hostname_avp(struct buffer *buf) { _u16 *raw = (_u16 *)(buf->start + buf->len); raw[0] = htons((0x6 + strlen(hostname)) | MBIT); raw[1] = htons(VENDOR_ID); raw[2] = htons(0x7); strcpy((char *)(&raw[3]), hostname); buf->len += 6 + strlen(hostname); return 0; } */ int add_hostname_avp (struct buffer *buf) { char names[6] = "eriwan"; _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons (0xC | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = htons (0x7); strcpy ((char *) (&raw[3]), names); buf->len += 12; return 0; } int add_vendor_avp (struct buffer *buf) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons (0x6 + strlen (VENDOR_NAME)); raw[1] = htons (VENDOR_ID); raw[2] = htons (0x8); strcpy ((char *) (&raw[3]), VENDOR_NAME); buf->len += 6 + strlen (VENDOR_NAME); return 0; } int add_tunnelid_avp (struct buffer *buf, _u16 tid) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons (0x8 | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = htons (0x9); raw[3] = htons (tid); buf->len += 8; return 0; } int add_avp_rws (struct buffer *buf, _u16 rws) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons (0x8 | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = htons (0xA); raw[3] = htons (rws); buf->len += 8; return 0; } int add_challenge_avp (struct buffer *buf, char *c, int len) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons ((0x6 + len) | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = htons (0xB); bcopy (c, (char *) (&raw[3]), len); buf->len += 6 + len; return 0; } int add_chalresp_avp (struct buffer *buf, char *c, int len) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons ((0x6 + len) | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = htons (0xD); bcopy (c, (char *) (&raw[3]), len); buf->len += 6 + len; return 0; } int add_randvect_avp (struct buffer *buf, char *c, int len) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons ((0x6 + len) | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = htons (0x24); bcopy (c, (char *) (&raw[3]), len); buf->len += 6 + len; return 0; } int add_result_code_avp (struct buffer *buf, _u16 result, _u16 error, char *msg, int len) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons ((0xA + len) | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = htons (0x1); raw[3] = htons (result); raw[4] = htons (error); bcopy (msg, (char *) &raw[5], len); buf->len += (10 + len); return 0; } #ifdef TEST_HIDDEN int add_callid_avp (struct buffer *buf, _u16 callid, struct tunnel *t) { #else int add_callid_avp (struct buffer *buf, _u16 callid) { #endif _u16 *raw = (_u16 *) (buf->start + buf->len); #ifdef TEST_HIDDEN if (t->hbit) raw++; #endif raw[0] = htons (0x8 | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = htons (0xE); raw[3] = htons (callid); buf->len += 8; #ifdef TEST_HIDDEN if (t->hbit) encrypt_avp (buf, 8, t); #endif return 0; } int add_serno_avp (struct buffer *buf, unsigned int serno) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons (0xA | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = htons (0xF); raw[3] = htons ((serno >> 16) & 0xFFFF); raw[4] = htons (serno & 0xFFFF); buf->len += 10; return 0; } int add_bearer_avp (struct buffer *buf, int bearer) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons (0xA | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = htons (0x12); raw[3] = htons ((bearer >> 16) & 0xFFFF); raw[4] = htons (bearer & 0xFFFF); buf->len += 10; return 0; } int add_frame_avp (struct buffer *buf, int frame) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons (0xA | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = htons (0x13); raw[3] = htons ((frame >> 16) & 0xFFFF); raw[4] = htons (frame & 0xFFFF); buf->len += 10; return 0; } int add_txspeed_avp (struct buffer *buf, int speed) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons (0xA | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = htons (0x18); raw[3] = htons ((speed >> 16) & 0xFFFF); raw[4] = htons (speed & 0xFFFF); buf->len += 10; return 0; } /* FIXME: this is not mandatory according to openl2tp: type: 38 */ #error "fixme: check mandatory AVPs from spec!" int add_rxspeed_avp (struct buffer *buf, int speed) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons (0xA | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = htons (0x26); raw[3] = htons ((speed >> 16) & 0xFFFF); raw[4] = htons (speed & 0xFFFF); buf->len += 10; return 0; } /* FIXME: this is not mandatory according to openl2tp: type: 25 */ #error "fixme: check mandatory AVPs from spec!" int add_physchan_avp (struct buffer *buf, unsigned int physchan) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons (0x8 | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = htons (0x19); raw[3] = htons ((physchan >> 16) & 0xFFFF); raw[4] = htons (physchan & 0xFFFF); buf->len += 10; return 0; } /* FIXME: dratf value, ignored but should not be mandatory: type: 20 */ #error "fixme: check mandatory AVPs from spec!" int add_ppd_avp (struct buffer *buf, _u16 ppd) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons (0x8 | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = htons (0x14); raw[3] = htons (ppd); buf->len += 8; return 0; } int add_seqreqd_avp (struct buffer *buf) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons (0x6 | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = htons (0x27); buf->len += 6; return 0; } /* jz: options dor the outgoing call */ /* jz: Minimum BPS - 16 */ int add_minbps_avp (struct buffer *buf, int speed) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons (0xA | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = htons (0x10); raw[3] = htons ((speed >> 16) & 0xFFFF); raw[4] = htons (speed & 0xFFFF); buf->len += 10; return 0; } /* jz: Maximum BPS - 17 */ int add_maxbps_avp (struct buffer *buf, int speed) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons (0xA | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = htons (0x11); raw[3] = htons ((speed >> 16) & 0xFFFF); raw[4] = htons (speed & 0xFFFF); buf->len += 10; return 0; } /* jz: Dialed Number 21 */ int add_number_avp (struct buffer *buf, char *no) { _u16 *raw = (_u16 *) (buf->start + buf->len); raw[0] = htons ((0x6 + strlen (no)) | MBIT); raw[1] = htons (VENDOR_ID); raw[2] = htons (0x15); strncpy ((char *) (&(raw[3])), no, strlen (no)); buf->len += 6 + strlen (no); return 0; }
25.278873
71
0.559394
b7d9c842c3739675d37cf178a40415610f070f19
102
h
C
AHN.Buildings.Verify/Coverage.h
mcserep/PointCloudTools
c8cd0c5915cc3802b68164f1732f93dc11efb0d5
[ "BSD-3-Clause" ]
6
2020-12-30T03:47:43.000Z
2022-03-01T16:24:27.000Z
AHN.Buildings.Verify/Coverage.h
mcserep/PointCloudTools
c8cd0c5915cc3802b68164f1732f93dc11efb0d5
[ "BSD-3-Clause" ]
null
null
null
AHN.Buildings.Verify/Coverage.h
mcserep/PointCloudTools
c8cd0c5915cc3802b68164f1732f93dc11efb0d5
[ "BSD-3-Clause" ]
3
2021-03-20T14:54:25.000Z
2022-02-23T12:55:41.000Z
#pragma once #include <ogr_core.h> enum Coverage : GByte { NoData = 0, Accept = 1, Reject = 2 };
9.272727
21
0.627451
318eeaa7029af1aa12d549ed89f5caa231588334
1,469
h
C
iOS/10.0.2/Frameworks/HomeKit.framework/_HMCameraStreamControl.h
onmyway133/Runtime-Headers
e9b80e7ab9103f37ad421ad6b8b58ee06369d21f
[ "MIT" ]
30
2016-10-09T20:13:00.000Z
2022-01-24T04:14:57.000Z
iOS/10.0.2/Frameworks/HomeKit.framework/_HMCameraStreamControl.h
onmyway133/Runtime-Headers
e9b80e7ab9103f37ad421ad6b8b58ee06369d21f
[ "MIT" ]
null
null
null
iOS/10.0.2/Frameworks/HomeKit.framework/_HMCameraStreamControl.h
onmyway133/Runtime-Headers
e9b80e7ab9103f37ad421ad6b8b58ee06369d21f
[ "MIT" ]
7
2017-08-29T14:41:25.000Z
2022-01-19T17:14:54.000Z
/* Generated by RuntimeBrowser Image: /System/Library/Frameworks/HomeKit.framework/HomeKit */ @interface _HMCameraStreamControl : _HMCameraControl { HMCameraStream * _cameraStream; <_HMCameraStreamControlDelegate> * _delegate; NSString * _streamSessionID; unsigned long long _streamState; } @property (nonatomic, readonly) HMCameraStream *cameraStream; @property (nonatomic) <_HMCameraStreamControlDelegate> *delegate; @property (nonatomic, retain) NSString *streamSessionID; @property (nonatomic) unsigned long long streamState; - (void).cxx_destruct; - (void)_callVideoStartedDelegate; - (void)_callVideoStoppedDelegate:(id)arg1; - (void)_handleNegotiateStreamResponse:(id)arg1 error:(id)arg2; - (void)_handleVideoStreamStartResponse:(id)arg1 error:(id)arg2; - (void)_handleVideoStreamStopped:(id)arg1; - (void)_registerNotificationHandlers; - (void)_resetState:(id)arg1; - (void)_startStream; - (void)_stopStream; - (id)cameraStream; - (void)dealloc; - (id)delegate; - (void)homedRestarted; - (id)initWithCameraProfile:(id)arg1 service:(id)arg2 clientQueue:(id)arg3 delegateCaller:(id)arg4 msgDispatcher:(id)arg5 home:(id)arg6 profileUniqueIdentifier:(id)arg7; - (bool)isEqual:(id)arg1; - (void)setCameraStream:(id)arg1; - (void)setDelegate:(id)arg1; - (void)setStreamSessionID:(id)arg1; - (void)setStreamState:(unsigned long long)arg1; - (void)startStream; - (void)stopStream; - (id)streamSessionID; - (unsigned long long)streamState; @end
34.162791
169
0.772634
2e9006c1e240884b5f5fa28e0b4e442f39d412c4
1,828
c
C
arch/x86/kernel/pci-iommu_table.c
fergy/aplit_linux-5
a6ef4cb0e17e1eec9743c064e65f730c49765711
[ "MIT" ]
31
2021-04-27T08:50:40.000Z
2022-03-01T02:26:21.000Z
arch/x86/kernel/pci-iommu_table.c
fergy/aplit_linux-5
a6ef4cb0e17e1eec9743c064e65f730c49765711
[ "MIT" ]
13
2021-07-10T04:36:17.000Z
2022-03-03T10:50:05.000Z
arch/x86/kernel/pci-iommu_table.c
fergy/aplit_linux-5
a6ef4cb0e17e1eec9743c064e65f730c49765711
[ "MIT" ]
12
2021-04-06T02:23:10.000Z
2022-02-28T11:43:19.000Z
// SPDX-License-Identifier: GPL-2.0 #include <linux/dma-mapping.h> #include <asm/iommu_table.h> #include <linux/string.h> #include <linux/kallsyms.h> #define DEBUG 1 static struct iommu_table_entry * __init find_dependents_of(struct iommu_table_entry *start, struct iommu_table_entry *finish, struct iommu_table_entry *q) { struct iommu_table_entry *p; if (!q) return NULL; for (p = start; p < finish; p++) if (p->detect == q->depend) return p; return NULL; } void __init sort_iommu_table(struct iommu_table_entry *start, struct iommu_table_entry *finish) { struct iommu_table_entry *p, *q, tmp; for (p = start; p < finish; p++) { again: q = find_dependents_of(start, finish, p); /* We are bit sneaky here. We use the memory address to figure * out if the node we depend on is past our point, if so, swap. */ if (q > p) { tmp = *p; memmove(p, q, sizeof(*p)); *q = tmp; goto again; } } } #ifdef DEBUG void __init check_iommu_entries(struct iommu_table_entry *start, struct iommu_table_entry *finish) { struct iommu_table_entry *p, *q, *x; /* Simple cyclic dependency checker. */ for (p = start; p < finish; p++) { q = find_dependents_of(start, finish, p); x = find_dependents_of(start, finish, q); if (p == x) { printk(KERN_ERR "CYCLIC DEPENDENCY FOUND! %pS depends on %pS and vice-versa. BREAKING IT.\n", p->detect, q->detect); /* Heavy handed way..*/ x->depend = NULL; } } for (p = start; p < finish; p++) { q = find_dependents_of(p, finish, p); if (q && q > p) { printk(KERN_ERR "EXECUTION ORDER INVALID! %pS should be called before %pS!\n", p->detect, q->detect); } } } #else void __init check_iommu_entries(struct iommu_table_entry *start, struct iommu_table_entry *finish) { } #endif
22.567901
96
0.655361
fffe01d3f32fc34d9cd16752915cd9f6d60b7af9
2,490
h
C
src/asn1.h
zaza568/yo
7e32382280647a0f07f74cd5fd54fb6ba68afd6e
[ "OLDAP-2.4" ]
1
2020-07-23T16:33:27.000Z
2020-07-23T16:33:27.000Z
src/asn1.h
zaza568/yo
7e32382280647a0f07f74cd5fd54fb6ba68afd6e
[ "OLDAP-2.4" ]
null
null
null
src/asn1.h
zaza568/yo
7e32382280647a0f07f74cd5fd54fb6ba68afd6e
[ "OLDAP-2.4" ]
null
null
null
/* * ASN.1 DER parsing * Copyright (c) 2006, Jouni Malinen <j@w1.fi> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Alternatively, this software may be distributed under the terms of BSD * license. * * See README and COPYING for more details. */ #include <stdio.h> #include <string.h> #include "stdint.h" #ifndef ASN1_H #define ASN1_H #define ASN1_TAG_EOC 0x00 /* not used with DER */ #define ASN1_TAG_BOOLEAN 0x01 #define ASN1_TAG_INTEGER 0x02 #define ASN1_TAG_BITSTRING 0x03 #define ASN1_TAG_OCTETSTRING 0x04 #define ASN1_TAG_NULL 0x05 #define ASN1_TAG_OID 0x06 #define ASN1_TAG_OBJECT_DESCRIPTOR 0x07 /* not yet parsed */ #define ASN1_TAG_EXTERNAL 0x08 /* not yet parsed */ #define ASN1_TAG_REAL 0x09 /* not yet parsed */ #define ASN1_TAG_ENUMERATED 0x0A /* not yet parsed */ #define ASN1_TAG_UTF8STRING 0x0C /* not yet parsed */ #define ANS1_TAG_RELATIVE_OID 0x0D #define ASN1_TAG_SEQUENCE 0x10 /* shall be constructed */ #define ASN1_TAG_SET 0x11 #define ASN1_TAG_NUMERICSTRING 0x12 /* not yet parsed */ #define ASN1_TAG_PRINTABLESTRING 0x13 #define ASN1_TAG_TG1STRING 0x14 /* not yet parsed */ #define ASN1_TAG_VIDEOTEXSTRING 0x15 /* not yet parsed */ #define ASN1_TAG_IA5STRING 0x16 #define ASN1_TAG_UTCTIME 0x17 #define ASN1_TAG_GENERALIZEDTIME 0x18 /* not yet parsed */ #define ASN1_TAG_GRAPHICSTRING 0x19 /* not yet parsed */ #define ASN1_TAG_VISIBLESTRING 0x1A #define ASN1_TAG_GENERALSTRING 0x1B /* not yet parsed */ #define ASN1_TAG_UNIVERSALSTRING 0x1C /* not yet parsed */ #define ASN1_TAG_BMPSTRING 0x1D /* not yet parsed */ #define ASN1_CLASS_UNIVERSAL 0 #define ASN1_CLASS_APPLICATION 1 #define ASN1_CLASS_CONTEXT_SPECIFIC 2 #define ASN1_CLASS_PRIVATE 3 struct asn1_hdr { const uint8_t *payload; uint8_t identifier, class, constructed; unsigned int tag, length; }; #define ASN1_MAX_OID_LEN 20 struct asn1_oid { unsigned long oid[ASN1_MAX_OID_LEN]; size_t len; }; int asn1_get_next(const uint8_t *buf, size_t len, struct asn1_hdr *hdr); int asn1_parse_oid(const uint8_t *buf, size_t len, struct asn1_oid *oid); int asn1_get_oid(const uint8_t *buf, size_t len, struct asn1_oid *oid, const uint8_t **next); void asn1_oid_to_str(struct asn1_oid *oid, char *buf, size_t len); unsigned long asn1_bit_string_to_long(const uint8_t *buf, size_t len); #endif /* ASN1_H */
32.337662
73
0.764659
837b95eb448a8cdf300fbcce34ba212544f276a0
25,268
h
C
proton-c/include/proton/message.h
mbroadst/qpid-proton-packaging
3b66acfd5b3e91fa405f63449985d5e769035bf8
[ "Apache-2.0" ]
2
2020-04-28T13:33:06.000Z
2020-06-01T14:51:05.000Z
proton-c/include/proton/message.h
mbroadst/qpid-proton-packaging
3b66acfd5b3e91fa405f63449985d5e769035bf8
[ "Apache-2.0" ]
null
null
null
proton-c/include/proton/message.h
mbroadst/qpid-proton-packaging
3b66acfd5b3e91fa405f63449985d5e769035bf8
[ "Apache-2.0" ]
4
2015-10-17T20:44:45.000Z
2021-06-08T19:00:56.000Z
#ifndef PROTON_MESSAGE_H #define PROTON_MESSAGE_H 1 /* * * 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. * */ #include <proton/import_export.h> #include <proton/types.h> #include <proton/codec.h> #include <proton/error.h> #include <proton/type_compat.h> #ifdef __cplusplus extern "C" { #endif /** @file * Message API for encoding/decoding AMQP Messages. * * @defgroup message Message * @{ */ /** * An AMQP Message object. * * An AMQP Message object is a mutable holder of message content that * may be used to generate and encode or decode and access AMQP * formatted message data. */ typedef struct pn_message_t pn_message_t; /** * Default priority for messages. */ #define PN_DEFAULT_PRIORITY (4) /** * Construct a new ::pn_message_t. * * Every message that is constructed must be freed using * ::pn_message_free(). * * @return pointer to a new ::pn_message_t */ PN_EXTERN pn_message_t * pn_message(void); /** * Free a previously constructed ::pn_message_t. * * @param[in] msg pointer to a ::pn_message_t or NULL */ PN_EXTERN void pn_message_free(pn_message_t *msg); /** * Clears the content of a ::pn_message_t. * * When pn_message_clear returns, the supplied ::pn_message_t will be * emptied of all content and effectively returned to the same state * as if it was just created. * * @param[in] msg pointer to the ::pn_message_t to be cleared */ PN_EXTERN void pn_message_clear(pn_message_t *msg); /** * Access the error code of a message. * * Every operation on a message that can result in an error will set * the message's error code in case of error. The pn_message_errno() * call will access the error code of the most recent failed * operation. * * @param[in] msg a message * @return the message's error code */ PN_EXTERN int pn_message_errno(pn_message_t *msg); /** * Access the error information for a message. * * Every operation on a message that can result in an error will * update the error information held by its error descriptor should * that operation fail. The pn_message_error() call will access the * error information of the most recent failed operation. The pointer * returned by this call is valid until the message is freed. * * @param[in] msg a message * @return the message's error descriptor */ PN_EXTERN pn_error_t *pn_message_error(pn_message_t *msg); /** * Get the inferred flag for a message. * * The inferred flag for a message indicates how the message content * is encoded into AMQP sections. If inferred is true then binary and * list values in the body of the message will be encoded as AMQP DATA * and AMQP SEQUENCE sections, respectively. If inferred is false, * then all values in the body of the message will be encoded as AMQP * VALUE sections regardless of their type. Use * ::pn_message_set_inferred to set the value. * * @param[in] msg a message object * @return the value of the inferred flag for the message */ PN_EXTERN bool pn_message_is_inferred(pn_message_t *msg); /** * Set the inferred flag for a message. * * See ::pn_message_is_inferred() for a description of what the * inferred flag is. * * @param[in] msg a message object * @param[in] inferred the new value of the inferred flag * @return zero on success or an error code on failure */ PN_EXTERN int pn_message_set_inferred(pn_message_t *msg, bool inferred); // standard message headers and properties /** * Get the durable flag for a message. * * The durable flag indicates that any parties taking responsibility * for the message must durably store the content. * * @param[in] msg a message object * @return the value of the durable flag */ PN_EXTERN bool pn_message_is_durable (pn_message_t *msg); /** * Set the durable flag for a message. * * See ::pn_message_is_durable() for a description of the durable * flag. * * @param[in] msg a message object * @param[in] durable the new value of the durable flag * @return zero on success or an error code on failure */ PN_EXTERN int pn_message_set_durable (pn_message_t *msg, bool durable); /** * Get the priority for a message. * * The priority of a message impacts ordering guarantees. Within a * given ordered context, higher priority messages may jump ahead of * lower priority messages. * * @param[in] msg a message object * @return the message priority */ PN_EXTERN uint8_t pn_message_get_priority (pn_message_t *msg); /** * Set the priority for a message. * * See ::pn_message_get_priority() for details on message priority. * * @param[in] msg a message object * @param[in] priority the new priority for the message * @return zero on success or an error code on failure */ PN_EXTERN int pn_message_set_priority (pn_message_t *msg, uint8_t priority); /** * Get the ttl for a message. * * The ttl for a message determines how long a message is considered * live. When a message is held for retransmit, the ttl is * decremented. Once the ttl reaches zero, the message is considered * dead. Once a message is considered dead it may be dropped. Use * ::pn_message_set_ttl() to set the ttl for a message. * * @param[in] msg a message object * @return the ttl in milliseconds */ PN_EXTERN pn_millis_t pn_message_get_ttl (pn_message_t *msg); /** * Set the ttl for a message. * * See ::pn_message_get_ttl() for a detailed description of message ttl. * * @param[in] msg a message object * @param[in] ttl the new value for the message ttl * @return zero on success or an error code on failure */ PN_EXTERN int pn_message_set_ttl (pn_message_t *msg, pn_millis_t ttl); /** * Get the first acquirer flag for a message. * * When set to true, the first acquirer flag for a message indicates * that the recipient of the message is the first recipient to acquire * the message, i.e. there have been no failed delivery attempts to * other acquirers. Note that this does not mean the message has not * been delivered to, but not acquired, by other recipients. * * @param[in] msg a message object * @return the first acquirer flag for the message */ PN_EXTERN bool pn_message_is_first_acquirer (pn_message_t *msg); /** * Set the first acquirer flag for a message. * * See ::pn_message_is_first_acquirer() for details on the first * acquirer flag. * * @param[in] msg a message object * @param[in] first the new value for the first acquirer flag * @return zero on success or an error code on failure */ PN_EXTERN int pn_message_set_first_acquirer (pn_message_t *msg, bool first); /** * Get the delivery count for a message. * * The delivery count field tracks how many attempts have been made to * delivery a message. Use ::pn_message_set_delivery_count() to set * the delivery count for a message. * * @param[in] msg a message object * @return the delivery count for the message */ PN_EXTERN uint32_t pn_message_get_delivery_count (pn_message_t *msg); /** * Set the delivery count for a message. * * See ::pn_message_get_delivery_count() for details on what the * delivery count means. * * @param[in] msg a message object * @param[in] count the new delivery count * @return zero on success or an error code on failure */ PN_EXTERN int pn_message_set_delivery_count (pn_message_t *msg, uint32_t count); /** * Get/set the id for a message. * * The message id provides a globally unique identifier for a message. * A message id can be an a string, an unsigned long, a uuid or a * binary value. This operation returns a pointer to a ::pn_data_t * that can be used to access and/or modify the value of the message * id. The pointer is valid until the message is freed. See * ::pn_data_t for details on how to get/set the value. * * @param[in] msg a message object * @return pointer to a ::pn_data_t holding the id */ PN_EXTERN pn_data_t * pn_message_id (pn_message_t *msg); /** * Get the id for a message. * * The message id provides a globally unique identifier for a message. * A message id can be an a string, an unsigned long, a uuid or a * binary value. This operation returns the value of the id using the * ::pn_atom_t descriminated union. See ::pn_atom_t for details on how * to access the value. * * @param[in] msg a message object * @return the message id */ PN_EXTERN pn_atom_t pn_message_get_id (pn_message_t *msg); /** * Set the id for a message. * * See ::pn_message_get_id() for more details on the meaning of the * message id. Note that only string, unsigned long, uuid, or binary * values are permitted. * * @param[in] msg a message object * @param[in] id the new value of the message id * @return zero on success or an error code on failure */ PN_EXTERN int pn_message_set_id (pn_message_t *msg, pn_atom_t id); /** * Get the user id for a message. * * The pointer referenced by the ::pn_bytes_t struct will be valid * until any one of the following operations occur: * * - ::pn_message_free() * - ::pn_message_clear() * - ::pn_message_set_user_id() * * @param[in] msg a message object * @return a pn_bytes_t referencing the message's user_id */ PN_EXTERN pn_bytes_t pn_message_get_user_id (pn_message_t *msg); /** * Set the user id for a message. * * This operation copies the bytes referenced by the provided * ::pn_bytes_t struct. * * @param[in] msg a message object * @param[in] user_id the new user_id for the message * @return zero on success or an error code on failure */ PN_EXTERN int pn_message_set_user_id (pn_message_t *msg, pn_bytes_t user_id); /** * Get the address for a message. * * This operation will return NULL if no address has been set or if * the address has been set to NULL. The pointer returned by this * operation is valid until any one of the following operations occur: * * - ::pn_message_free() * - ::pn_message_clear() * - ::pn_message_set_address() * * @param[in] msg a message object * @return a pointer to the address of the message (or NULL) */ PN_EXTERN const char * pn_message_get_address (pn_message_t *msg); /** * Set the address for a message. * * The supplied address pointer must either be NULL or reference a NUL * terminated string. When the pointer is NULL, the address of the * message is set to NULL. When the pointer is non NULL, the contents * are copied into the message. * * @param[in] msg a message object * @param[in] address a pointer to the new address (or NULL) * @return zero on success or an error code on failure */ PN_EXTERN int pn_message_set_address (pn_message_t *msg, const char *address); /** * Get the subject for a message. * * This operation will return NULL if no subject has been set or if * the subject has been set to NULL. The pointer returned by this * operation is valid until any one of the following operations occur: * * - ::pn_message_free() * - ::pn_message_clear() * - ::pn_message_set_subject() * * @param[in] msg a message object * @return a pointer to the subject of the message (or NULL) */ PN_EXTERN const char * pn_message_get_subject (pn_message_t *msg); /** * Set the subject for a message. * * The supplied subject pointer must either be NULL or reference a NUL * terminated string. When the pointer is NULL, the subject is set to * NULL. When the pointer is non NULL, the contents are copied into * the message. * * @param[in] msg a message object * @param[in] subject a pointer to the new subject (or NULL) * @return zero on success or an error code on failure */ PN_EXTERN int pn_message_set_subject (pn_message_t *msg, const char *subject); /** * Get the reply_to for a message. * * This operation will return NULL if no reply_to has been set or if * the reply_to has been set to NULL. The pointer returned by this * operation is valid until any one of the following operations occur: * * - ::pn_message_free() * - ::pn_message_clear() * - ::pn_message_set_reply_to() * * @param[in] msg a message object * @return a pointer to the reply_to of the message (or NULL) */ PN_EXTERN const char * pn_message_get_reply_to (pn_message_t *msg); /** * Set the reply_to for a message. * * The supplied reply_to pointer must either be NULL or reference a NUL * terminated string. When the pointer is NULL, the reply_to is set to * NULL. When the pointer is non NULL, the contents are copied into * the message. * * @param[in] msg a message object * @param[in] reply_to a pointer to the new reply_to (or NULL) * @return zero on success or an error code on failure */ PN_EXTERN int pn_message_set_reply_to (pn_message_t *msg, const char *reply_to); /** * Get/set the correlation id for a message. * * A correlation id can be an a string, an unsigned long, a uuid or a * binary value. This operation returns a pointer to a ::pn_data_t * that can be used to access and/or modify the value of the * correlation id. The pointer is valid until the message is freed. * See ::pn_data_t for details on how to get/set the value. * * @param[in] msg a message object * @return pointer to a ::pn_data_t holding the correlation id */ PN_EXTERN pn_data_t * pn_message_correlation_id (pn_message_t *msg); /** * Get the correlation id for a message. * * A correlation id can be an a string, an unsigned long, a uuid or a * binary value. This operation returns the value of the id using the * ::pn_atom_t descriminated union. See ::pn_atom_t for details on how * to access the value. * * @param[in] msg a message object * @return the message id */ PN_EXTERN pn_atom_t pn_message_get_correlation_id (pn_message_t *msg); /** * Set the correlation id for a message. * * See ::pn_message_get_correlation_id() for more details on the * meaning of the correlation id. Note that only string, unsigned * long, uuid, or binary values are permitted. * * @param[in] msg a message object * @param[in] id the new value of the message id * @return zero on success or an error code on failure */ PN_EXTERN int pn_message_set_correlation_id (pn_message_t *msg, pn_atom_t id); /** * Get the content_type for a message. * * This operation will return NULL if no content_type has been set or if * the content_type has been set to NULL. The pointer returned by this * operation is valid until any one of the following operations occur: * * - ::pn_message_free() * - ::pn_message_clear() * - ::pn_message_set_content_type() * * @param[in] msg a message object * @return a pointer to the content_type of the message (or NULL) */ PN_EXTERN const char * pn_message_get_content_type (pn_message_t *msg); /** * Set the content_type for a message. * * The supplied content_type pointer must either be NULL or reference a NUL * terminated string. When the pointer is NULL, the content_type is set to * NULL. When the pointer is non NULL, the contents are copied into * the message. * * @param[in] msg a message object * @param[in] type a pointer to the new content_type (or NULL) * @return zero on success or an error code on failure */ PN_EXTERN int pn_message_set_content_type (pn_message_t *msg, const char *type); /** * Get the content_encoding for a message. * * This operation will return NULL if no content_encoding has been set or if * the content_encoding has been set to NULL. The pointer returned by this * operation is valid until any one of the following operations occur: * * - ::pn_message_free() * - ::pn_message_clear() * - ::pn_message_set_content_encoding() * * @param[in] msg a message object * @return a pointer to the content_encoding of the message (or NULL) */ PN_EXTERN const char * pn_message_get_content_encoding (pn_message_t *msg); /** * Set the content_encoding for a message. * * The supplied content_encoding pointer must either be NULL or reference a NUL * terminated string. When the pointer is NULL, the content_encoding is set to * NULL. When the pointer is non NULL, the contents are copied into * the message. * * @param[in] msg a message object * @param[in] encoding a pointer to the new content_encoding (or NULL) * @return zero on success or an error code on failure */ PN_EXTERN int pn_message_set_content_encoding (pn_message_t *msg, const char *encoding); /** * Get the expiry time for a message. * * A zero value for the expiry time indicates that the message will * never expire. This is the default value. * * @param[in] msg a message object * @return the expiry time for the message */ PN_EXTERN pn_timestamp_t pn_message_get_expiry_time (pn_message_t *msg); /** * Set the expiry time for a message. * * See ::pn_message_get_expiry_time() for more details. * * @param[in] msg a message object * @param[in] time the new expiry time for the message * @return zero on success or an error code on failure */ PN_EXTERN int pn_message_set_expiry_time (pn_message_t *msg, pn_timestamp_t time); /** * Get the creation time for a message. * * A zero value for the creation time indicates that the creation time * has not been set. This is the default value. * * @param[in] msg a message object * @return the creation time for the message */ PN_EXTERN pn_timestamp_t pn_message_get_creation_time (pn_message_t *msg); /** * Set the creation time for a message. * * See ::pn_message_get_creation_time() for more details. * * @param[in] msg a message object * @param[in] time the new creation time for the message * @return zero on success or an error code on failure */ PN_EXTERN int pn_message_set_creation_time (pn_message_t *msg, pn_timestamp_t time); /** * Get the group_id for a message. * * This operation will return NULL if no group_id has been set or if * the group_id has been set to NULL. The pointer returned by this * operation is valid until any one of the following operations occur: * * - ::pn_message_free() * - ::pn_message_clear() * - ::pn_message_set_group_id() * * @param[in] msg a message object * @return a pointer to the group_id of the message (or NULL) */ PN_EXTERN const char * pn_message_get_group_id (pn_message_t *msg); /** * Set the group_id for a message. * * The supplied group_id pointer must either be NULL or reference a NUL * terminated string. When the pointer is NULL, the group_id is set to * NULL. When the pointer is non NULL, the contents are copied into * the message. * * @param[in] msg a message object * @param[in] group_id a pointer to the new group_id (or NULL) * @return zero on success or an error code on failure */ PN_EXTERN int pn_message_set_group_id (pn_message_t *msg, const char *group_id); /** * Get the group sequence for a message. * * The group sequence of a message identifies the relative ordering of * messages within a group. The default value for the group sequence * of a message is zero. * * @param[in] msg a message object * @return the group sequence for the message */ PN_EXTERN pn_sequence_t pn_message_get_group_sequence (pn_message_t *msg); /** * Set the group sequence for a message. * * See ::pn_message_get_group_sequence() for details on what the group * sequence means. * * @param[in] msg a message object * @param[in] n the new group sequence for the message * @return zero on success or an error code on failure */ PN_EXTERN int pn_message_set_group_sequence (pn_message_t *msg, pn_sequence_t n); /** * Get the reply_to_group_id for a message. * * This operation will return NULL if no reply_to_group_id has been set or if * the reply_to_group_id has been set to NULL. The pointer returned by this * operation is valid until any one of the following operations occur: * * - ::pn_message_free() * - ::pn_message_clear() * - ::pn_message_set_reply_to_group_id() * * @param[in] msg a message object * @return a pointer to the reply_to_group_id of the message (or NULL) */ PN_EXTERN const char * pn_message_get_reply_to_group_id (pn_message_t *msg); /** * Set the reply_to_group_id for a message. * * The supplied reply_to_group_id pointer must either be NULL or reference a NUL * terminated string. When the pointer is NULL, the reply_to_group_id is set to * NULL. When the pointer is non NULL, the contents are copied into * the message. * * @param[in] msg a message object * @param[in] reply_to_group_id a pointer to the new reply_to_group_id (or NULL) * @return zero on success or an error code on failure */ PN_EXTERN int pn_message_set_reply_to_group_id (pn_message_t *msg, const char *reply_to_group_id); /** * Get/set the delivery instructions for a message. * * This operation returns a pointer to a ::pn_data_t representing the * content of the delivery instructions section of a message. The * pointer is valid until the message is freed and may be used to both * access and modify the content of the delivery instructions section * of a message. * * The ::pn_data_t must either be empty or consist of a symbol keyed * map in order to be considered valid delivery instructions. * * @param[in] msg a message object * @return a pointer to the delivery instructions */ PN_EXTERN pn_data_t *pn_message_instructions(pn_message_t *msg); /** * Get/set the annotations for a message. * * This operation returns a pointer to a ::pn_data_t representing the * content of the annotations section of a message. The pointer is * valid until the message is freed and may be used to both access and * modify the content of the annotations section of a message. * * The ::pn_data_t must either be empty or consist of a symbol keyed * map in order to be considered valid message annotations. * * @param[in] msg a message object * @return a pointer to the message annotations */ PN_EXTERN pn_data_t *pn_message_annotations(pn_message_t *msg); /** * Get/set the properties for a message. * * This operation returns a pointer to a ::pn_data_t representing the * content of the properties section of a message. The pointer is * valid until the message is freed and may be used to both access and * modify the content of the properties section of a message. * * The ::pn_data_t must either be empty or consist of a string keyed * map in order to be considered valid message properties. * * @param[in] msg a message object * @return a pointer to the message properties */ PN_EXTERN pn_data_t *pn_message_properties(pn_message_t *msg); /** * Get/set the body of a message. * * This operation returns a pointer to a ::pn_data_t representing the * body of a message. The pointer is valid until the message is freed * and may be used to both access and modify the content of the * message body. * * @param[in] msg a message object * @return a pointer to the message body */ PN_EXTERN pn_data_t *pn_message_body(pn_message_t *msg); /** * Decode/load message content from AMQP formatted binary data. * * Upon invoking this operation, any existing message content will be * cleared and replaced with the content from the provided binary * data. * * @param[in] msg a message object * @param[in] bytes the start of the encoded AMQP data * @param[in] size the size of the encoded AMQP data * @return zero on success or an error code on failure */ PN_EXTERN int pn_message_decode(pn_message_t *msg, const char *bytes, size_t size); /** * Encode/save message content as AMQP formatted binary data. * * If the buffer space provided is insufficient to store the content * held in the message, the operation will fail and return a * ::PN_OVERFLOW error code. * * @param[in] msg a message object * @param[in] bytes the start of empty buffer space * @param[in] size the amount of empty buffer space * @param[out] size the amount of data written * @return zero on success or an error code on failure */ PN_EXTERN int pn_message_encode(pn_message_t *msg, char *bytes, size_t *size); /** * Save message content into a pn_data_t object data. The data object will first be cleared. */ PN_EXTERN int pn_message_data(pn_message_t *msg, pn_data_t *data); /** @} */ #ifdef __cplusplus } #endif #endif /* message.h */
33.556441
109
0.715727
035993bbff3742d235be08ddd7d4778dc7cce192
1,759
h
C
Day1/build/iOS/Preview/include/Fuse.Input.TraverseNodeExtensions.h
sauvikatinnofied/ExploringFuse
cc272d55c7221d88ba773494f571b6528e5279f8
[ "Apache-2.0" ]
null
null
null
Day1/build/iOS/Preview/include/Fuse.Input.TraverseNodeExtensions.h
sauvikatinnofied/ExploringFuse
cc272d55c7221d88ba773494f571b6528e5279f8
[ "Apache-2.0" ]
null
null
null
Day1/build/iOS/Preview/include/Fuse.Input.TraverseNodeExtensions.h
sauvikatinnofied/ExploringFuse
cc272d55c7221d88ba773494f571b6528e5279f8
[ "Apache-2.0" ]
null
null
null
// This file was generated based on '/usr/local/share/uno/Packages/FuseCore/0.24.6/Input/$.uno'. // WARNING: Changes might be lost if you edit this file directly. #pragma once #include <Uno.h> namespace g{namespace Fuse{namespace Input{struct TraverseNodeExtensions;}}} namespace g{namespace Fuse{struct Node;}} namespace g{ namespace Fuse{ namespace Input{ // internal static class TraverseNodeExtensions :87 // { uClassType* TraverseNodeExtensions_typeof(); void TraverseNodeExtensions__FindNextChild_fn(::g::Fuse::Node* node, ::g::Fuse::Node* currentChild, ::g::Fuse::Node** __retval); void TraverseNodeExtensions__FindNextChild1_fn(::g::Fuse::Node* node, uDelegate* filter, ::g::Fuse::Node** __retval); void TraverseNodeExtensions__FindNextSibling_fn(::g::Fuse::Node* node, ::g::Fuse::Node** __retval); void TraverseNodeExtensions__FindPreviousChild_fn(::g::Fuse::Node* node, ::g::Fuse::Node* currentChild, ::g::Fuse::Node** __retval); void TraverseNodeExtensions__FindPreviousChild1_fn(::g::Fuse::Node* node, uDelegate* filter, ::g::Fuse::Node** __retval); void TraverseNodeExtensions__FindPreviousSibling_fn(::g::Fuse::Node* node, ::g::Fuse::Node** __retval); struct TraverseNodeExtensions : uObject { static ::g::Fuse::Node* FindNextChild(::g::Fuse::Node* node, ::g::Fuse::Node* currentChild); static ::g::Fuse::Node* FindNextChild1(::g::Fuse::Node* node, uDelegate* filter); static ::g::Fuse::Node* FindNextSibling(::g::Fuse::Node* node); static ::g::Fuse::Node* FindPreviousChild(::g::Fuse::Node* node, ::g::Fuse::Node* currentChild); static ::g::Fuse::Node* FindPreviousChild1(::g::Fuse::Node* node, uDelegate* filter); static ::g::Fuse::Node* FindPreviousSibling(::g::Fuse::Node* node); }; // } }}} // ::g::Fuse::Input
50.257143
132
0.724275
83db62446c8e4a5dd80414493b04ff8e78e0f93c
1,726
h
C
include/survive/survive_config.h
ngiftsun/vive_tracker_loc
fce9210a413a5b7c2d0b5d8b63c2493035e143fc
[ "MIT" ]
26
2017-08-07T19:41:48.000Z
2022-03-25T20:48:42.000Z
include/survive/survive_config.h
ngiftsun/vive_tracker_loc
fce9210a413a5b7c2d0b5d8b63c2493035e143fc
[ "MIT" ]
3
2018-03-07T13:31:28.000Z
2019-10-17T03:46:23.000Z
include/survive/survive_config.h
ngiftsun/vive_tracker_loc
fce9210a413a5b7c2d0b5d8b63c2493035e143fc
[ "MIT" ]
5
2018-01-31T13:28:40.000Z
2020-10-19T14:49:14.000Z
// (C) 2017 <>< Joshua Allen, Under MIT/x11 License. #ifndef _SURVIVE_CONFIG_H #define _SURVIVE_CONFIG_H #include "survive_internal.h" typedef enum { CONFIG_UNKNOWN = 0, CONFIG_FLOAT = 1, CONFIG_UINT32 = 2, CONFIG_STRING = 3, CONFIG_FLOAT_ARRAY = 4, } cval_type; typedef struct { char *tag; cval_type type; union { uint32_t i; FLT f; } numeric; char *data; uint32_t elements; } config_entry; typedef struct config_group { config_entry *config_entries; uint16_t used_entries; uint16_t max_entries; } config_group; //extern config_group global_config_values; //extern config_group lh_config[2]; //lighthouse configs void init_config_group(config_group *cg, uint8_t count); void destroy_config_group(config_group* cg); //void config_init(); //void config_open(const char* path, const char* mode); //void config_write_lighthouse(struct BaseStationData* bsd, uint8_t length); void config_set_lighthouse(config_group* lh_config, BaseStationData* bsd, uint8_t idx); void config_read(SurviveContext* sctx, const char* path); void config_save(SurviveContext* sctx, const char* path); const FLT config_set_float(config_group *cg, const char *tag, const FLT value); const uint32_t config_set_uint32(config_group *cg, const char *tag, const uint32_t value); const char* config_set_str(config_group *cg, const char *tag, const char* value); FLT config_read_float(config_group *cg, const char *tag, const FLT def); uint16_t config_read_float_array(config_group *cg, const char *tag, const FLT** values, const FLT* def, uint8_t count); uint32_t config_read_uint32(config_group *cg, const char *tag, const uint32_t def); const char* config_read_str(config_group *cg, const char *tag, const char *def); #endif
28.766667
119
0.773465
d9ad1d2364861ece9ca67c2dcb2185e9a3d046fa
12,674
c
C
abc/src/bdd/cudd/cuddAndAbs.c
HackerFoo/vtr-verilog-to-routing
9bf3c1004e8a7c9f3756167905fd2e71218158d0
[ "MIT" ]
682
2015-07-10T00:39:26.000Z
2022-03-30T05:24:53.000Z
abc/src/bdd/cudd/cuddAndAbs.c
HackerFoo/vtr-verilog-to-routing
9bf3c1004e8a7c9f3756167905fd2e71218158d0
[ "MIT" ]
1,399
2015-07-24T22:09:09.000Z
2022-03-29T06:22:48.000Z
abc/src/bdd/cudd/cuddAndAbs.c
HackerFoo/vtr-verilog-to-routing
9bf3c1004e8a7c9f3756167905fd2e71218158d0
[ "MIT" ]
311
2015-07-09T13:59:48.000Z
2022-03-28T00:15:20.000Z
/**CFile*********************************************************************** FileName [cuddAndAbs.c] PackageName [cudd] Synopsis [Combined AND and existential abstraction for BDDs] Description [External procedures included in this module: <ul> <li> Cudd_bddAndAbstract() <li> Cudd_bddAndAbstractLimit() </ul> Internal procedures included in this module: <ul> <li> cuddBddAndAbstractRecur() </ul>] Author [Fabio Somenzi] Copyright [Copyright (c) 1995-2004, Regents of the University of Colorado All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the University of Colorado 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.] ******************************************************************************/ #include "misc/util/util_hack.h" #include "cuddInt.h" ABC_NAMESPACE_IMPL_START /*---------------------------------------------------------------------------*/ /* Constant declarations */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* Stucture declarations */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* Type declarations */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* Variable declarations */ /*---------------------------------------------------------------------------*/ #ifndef lint static char rcsid[] DD_UNUSED = "$Id: cuddAndAbs.c,v 1.19 2004/08/13 18:04:46 fabio Exp $"; #endif /*---------------------------------------------------------------------------*/ /* Macro declarations */ /*---------------------------------------------------------------------------*/ /**AutomaticStart*************************************************************/ /*---------------------------------------------------------------------------*/ /* Static function prototypes */ /*---------------------------------------------------------------------------*/ /**AutomaticEnd***************************************************************/ /*---------------------------------------------------------------------------*/ /* Definition of exported functions */ /*---------------------------------------------------------------------------*/ /**Function******************************************************************** Synopsis [Takes the AND of two BDDs and simultaneously abstracts the variables in cube.] Description [Takes the AND of two BDDs and simultaneously abstracts the variables in cube. The variables are existentially abstracted. Returns a pointer to the result is successful; NULL otherwise. Cudd_bddAndAbstract implements the semiring matrix multiplication algorithm for the boolean semiring.] SideEffects [None] SeeAlso [Cudd_addMatrixMultiply Cudd_addTriangle Cudd_bddAnd] ******************************************************************************/ DdNode * Cudd_bddAndAbstract( DdManager * manager, DdNode * f, DdNode * g, DdNode * cube) { DdNode *res; do { manager->reordered = 0; res = cuddBddAndAbstractRecur(manager, f, g, cube); } while (manager->reordered == 1); return(res); } /* end of Cudd_bddAndAbstract */ /**Function******************************************************************** Synopsis [Takes the AND of two BDDs and simultaneously abstracts the variables in cube. Returns NULL if too many nodes are required.] Description [Takes the AND of two BDDs and simultaneously abstracts the variables in cube. The variables are existentially abstracted. Returns a pointer to the result is successful; NULL otherwise. In particular, if the number of new nodes created exceeds <code>limit</code>, this function returns NULL.] SideEffects [None] SeeAlso [Cudd_bddAndAbstract] ******************************************************************************/ DdNode * Cudd_bddAndAbstractLimit( DdManager * manager, DdNode * f, DdNode * g, DdNode * cube, unsigned int limit) { DdNode *res; unsigned int saveLimit = manager->maxLive; manager->maxLive = (manager->keys - manager->dead) + (manager->keysZ - manager->deadZ) + limit; do { manager->reordered = 0; res = cuddBddAndAbstractRecur(manager, f, g, cube); } while (manager->reordered == 1); manager->maxLive = saveLimit; return(res); } /* end of Cudd_bddAndAbstractLimit */ /*---------------------------------------------------------------------------*/ /* Definition of internal functions */ /*---------------------------------------------------------------------------*/ /**Function******************************************************************** Synopsis [Takes the AND of two BDDs and simultaneously abstracts the variables in cube.] Description [Takes the AND of two BDDs and simultaneously abstracts the variables in cube. The variables are existentially abstracted. Returns a pointer to the result is successful; NULL otherwise.] SideEffects [None] SeeAlso [Cudd_bddAndAbstract] ******************************************************************************/ DdNode * cuddBddAndAbstractRecur( DdManager * manager, DdNode * f, DdNode * g, DdNode * cube) { DdNode *F, *ft, *fe, *G, *gt, *ge; DdNode *one, *zero, *r, *t, *e; unsigned int topf, topg, topcube, top, index; statLine(manager); one = DD_ONE(manager); zero = Cudd_Not(one); /* Terminal cases. */ if (f == zero || g == zero || f == Cudd_Not(g)) return(zero); if (f == one && g == one) return(one); if (cube == one) { return(cuddBddAndRecur(manager, f, g)); } if (f == one || f == g) { return(cuddBddExistAbstractRecur(manager, g, cube)); } if (g == one) { return(cuddBddExistAbstractRecur(manager, f, cube)); } /* At this point f, g, and cube are not constant. */ if (f > g) { /* Try to increase cache efficiency. */ DdNode *tmp = f; f = g; g = tmp; } /* Here we can skip the use of cuddI, because the operands are known ** to be non-constant. */ F = Cudd_Regular(f); G = Cudd_Regular(g); topf = manager->perm[F->index]; topg = manager->perm[G->index]; top = ddMin(topf, topg); topcube = manager->perm[cube->index]; while (topcube < top) { cube = cuddT(cube); if (cube == one) { return(cuddBddAndRecur(manager, f, g)); } topcube = manager->perm[cube->index]; } /* Now, topcube >= top. */ /* Check cache. */ if (F->ref != 1 || G->ref != 1) { r = cuddCacheLookup(manager, DD_BDD_AND_ABSTRACT_TAG, f, g, cube); if (r != NULL) { return(r); } } if ( manager->TimeStop && Abc_Clock() > manager->TimeStop ) return NULL; if (topf == top) { index = F->index; ft = cuddT(F); fe = cuddE(F); if (Cudd_IsComplement(f)) { ft = Cudd_Not(ft); fe = Cudd_Not(fe); } } else { index = G->index; ft = fe = f; } if (topg == top) { gt = cuddT(G); ge = cuddE(G); if (Cudd_IsComplement(g)) { gt = Cudd_Not(gt); ge = Cudd_Not(ge); } } else { gt = ge = g; } if (topcube == top) { /* quantify */ DdNode *Cube = cuddT(cube); t = cuddBddAndAbstractRecur(manager, ft, gt, Cube); if (t == NULL) return(NULL); /* Special case: 1 OR anything = 1. Hence, no need to compute ** the else branch if t is 1. Likewise t + t * anything == t. ** Notice that t == fe implies that fe does not depend on the ** variables in Cube. Likewise for t == ge. */ if (t == one || t == fe || t == ge) { if (F->ref != 1 || G->ref != 1) cuddCacheInsert(manager, DD_BDD_AND_ABSTRACT_TAG, f, g, cube, t); return(t); } cuddRef(t); /* Special case: t + !t * anything == t + anything. */ if (t == Cudd_Not(fe)) { e = cuddBddExistAbstractRecur(manager, ge, Cube); } else if (t == Cudd_Not(ge)) { e = cuddBddExistAbstractRecur(manager, fe, Cube); } else { e = cuddBddAndAbstractRecur(manager, fe, ge, Cube); } if (e == NULL) { Cudd_IterDerefBdd(manager, t); return(NULL); } if (t == e) { r = t; cuddDeref(t); } else { cuddRef(e); r = cuddBddAndRecur(manager, Cudd_Not(t), Cudd_Not(e)); if (r == NULL) { Cudd_IterDerefBdd(manager, t); Cudd_IterDerefBdd(manager, e); return(NULL); } r = Cudd_Not(r); cuddRef(r); Cudd_DelayedDerefBdd(manager, t); Cudd_DelayedDerefBdd(manager, e); cuddDeref(r); } } else { t = cuddBddAndAbstractRecur(manager, ft, gt, cube); if (t == NULL) return(NULL); cuddRef(t); e = cuddBddAndAbstractRecur(manager, fe, ge, cube); if (e == NULL) { Cudd_IterDerefBdd(manager, t); return(NULL); } if (t == e) { r = t; cuddDeref(t); } else { cuddRef(e); if (Cudd_IsComplement(t)) { r = cuddUniqueInter(manager, (int) index, Cudd_Not(t), Cudd_Not(e)); if (r == NULL) { Cudd_IterDerefBdd(manager, t); Cudd_IterDerefBdd(manager, e); return(NULL); } r = Cudd_Not(r); } else { r = cuddUniqueInter(manager,(int)index,t,e); if (r == NULL) { Cudd_IterDerefBdd(manager, t); Cudd_IterDerefBdd(manager, e); return(NULL); } } cuddDeref(e); cuddDeref(t); } } if (F->ref != 1 || G->ref != 1) cuddCacheInsert(manager, DD_BDD_AND_ABSTRACT_TAG, f, g, cube, r); return (r); } /* end of cuddBddAndAbstractRecur */ /*---------------------------------------------------------------------------*/ /* Definition of static functions */ /*---------------------------------------------------------------------------*/ ABC_NAMESPACE_IMPL_END
32.919481
91
0.467808
fcdf6ebfe517381e888f16960ba84124eba4e2c0
714
h
C
Programs/ResourceEditor/Classes/TextModule/Private/TextModuleData.h
Serviak/dava.engine
d51a26173a3e1b36403f846ca3b2e183ac298a1a
[ "BSD-3-Clause" ]
1
2020-11-14T10:18:24.000Z
2020-11-14T10:18:24.000Z
Programs/ResourceEditor/Classes/TextModule/Private/TextModuleData.h
Serviak/dava.engine
d51a26173a3e1b36403f846ca3b2e183ac298a1a
[ "BSD-3-Clause" ]
null
null
null
Programs/ResourceEditor/Classes/TextModule/Private/TextModuleData.h
Serviak/dava.engine
d51a26173a3e1b36403f846ca3b2e183ac298a1a
[ "BSD-3-Clause" ]
1
2020-09-05T21:16:17.000Z
2020-09-05T21:16:17.000Z
#pragma once #include <TArc/DataProcessing/DataNode.h> #include <Reflection/ReflectionRegistrator.h> #include <memory> class EditorTextSystem; class TextModuleData : public DAVA::TArc::DataNode { public: static const char* drawingEnabledPropertyName; void SetDrawingEnabled(bool enabled); bool IsDrawingEnabled() const; private: friend class TextModule; std::unique_ptr<EditorTextSystem> editorTextSystem; DAVA_VIRTUAL_REFLECTION_IN_PLACE(TextModuleData, DAVA::TArc::DataNode) { DAVA::ReflectionRegistrator<TextModuleData>::Begin() .Field(drawingEnabledPropertyName, &TextModuleData::IsDrawingEnabled, &TextModuleData::SetDrawingEnabled) .End(); } };
24.62069
113
0.7507
6cfa70895c257743d4dfa798b8686c916594b140
351
h
C
APServiceBox/NSObject+APServiceBox.h
aspyct/APServiceBox
ed58f7a5ad4364d876400b42e3d4ce6b975a1694
[ "MIT" ]
null
null
null
APServiceBox/NSObject+APServiceBox.h
aspyct/APServiceBox
ed58f7a5ad4364d876400b42e3d4ce6b975a1694
[ "MIT" ]
null
null
null
APServiceBox/NSObject+APServiceBox.h
aspyct/APServiceBox
ed58f7a5ad4364d876400b42e3d4ce6b975a1694
[ "MIT" ]
null
null
null
// // NSObject+APServiceBox.h // ManPad // // Created by Antoine d'Otreppe on 31/08/12. // Copyright (c) 2012 Aspyct.org. All rights reserved. // #import <Foundation/Foundation.h> @interface NSObject (APServiceBox) - (void)injectDependencies; - (void)fillWithDependencies __deprecated_msg("Use -[NSObject injectDependencies] instead."); @end
19.5
93
0.729345
1b7b9ccac6ab90a06f1957a53b0c5bd665ebd944
3,544
h
C
kernel/generic/include/debug.h
narke/Einherjar.tmp
8c2c6385e1280907fa081a767572c4ccd6c32a82
[ "BSD-3-Clause" ]
3
2016-04-17T18:24:31.000Z
2021-06-05T16:59:40.000Z
kernel/generic/include/debug.h
narke/Einherjar.tmp
8c2c6385e1280907fa081a767572c4ccd6c32a82
[ "BSD-3-Clause" ]
null
null
null
kernel/generic/include/debug.h
narke/Einherjar.tmp
8c2c6385e1280907fa081a767572c4ccd6c32a82
[ "BSD-3-Clause" ]
null
null
null
/* * Copyright (c) 2005 Martin Decky * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. */ /** @addtogroup genericdebug * @{ */ /** @file */ #ifndef KERN_DEBUG_H_ #define KERN_DEBUG_H_ #include <panic.h> #include <log.h> #include <symtab_lookup.h> #define CALLER ((uintptr_t) __builtin_return_address(0)) #ifdef CONFIG_DEBUG /** Debugging ASSERT macro * * If CONFIG_DEBUG is set, the ASSERT() macro * evaluates expr and if it is false raises * kernel panic. * * @param expr Expression which is expected to be true. * */ #define ASSERT(expr) \ do { \ if (!(expr)) \ panic_assert("%s() at %s:%u:\n%s", \ __func__, __FILE__, __LINE__, #expr); \ } while (0) /** Debugging verbose ASSERT macro * * If CONFIG_DEBUG is set, the ASSERT() macro * evaluates expr and if it is false raises * kernel panic. The panic message contains also * the supplied message. * * @param expr Expression which is expected to be true. * @param msg Additional message to show (string). * */ #define ASSERT_VERBOSE(expr, msg) \ do { \ if (!(expr)) \ panic_assert("%s() at %s:%u:\n%s, %s", \ __func__, __FILE__, __LINE__, #expr, msg); \ } while (0) /** Static assert macro * */ #define STATIC_ASSERT(expr) \ _Static_assert(expr, "") #define STATIC_ASSERT_VERBOSE(expr, msg) \ _Static_assert(expr, msg) #else /* CONFIG_DEBUG */ #define ASSERT(expr) #define ASSERT_VERBOSE(expr, msg) #define STATIC_ASSERT(expr) #define STATIC_ASSERT_VERBOSE(expr, msg) #endif /* CONFIG_DEBUG */ #ifdef CONFIG_LOG /** Extensive logging output macro * * If CONFIG_LOG is set, the LOG() macro * will print whatever message is indicated plus * an information about the location. * */ #define LOG(format, ...) \ do { \ log(LF_OTHER, LVL_DEBUG, \ "%s() from %s at %s:%u: " format,__func__, \ symtab_fmt_name_lookup(CALLER), __FILE__, __LINE__, \ ##__VA_ARGS__); \ } while (0) #else /* CONFIG_LOG */ #define LOG(format, ...) #endif /* CONFIG_LOG */ #ifdef CONFIG_TRACE extern void __cyg_profile_func_enter(void *, void *); extern void __cyg_profile_func_exit(void *, void *); #endif /* CONFIG_TRACE */ #endif /** @} */
26.646617
76
0.705418
9b5f672d679dc3eebd08987619939c3294be0635
458
c
C
deps/jemalloc/test/src/mq.c
zh1029/redis
f3dd33489834de01392dfed8e0ad5e2e8de0894d
[ "BSD-3-Clause" ]
38,047
2015-01-01T00:47:33.000Z
2020-06-30T13:06:50.000Z
deps/jemalloc/test/src/mq.c
zh1029/redis
f3dd33489834de01392dfed8e0ad5e2e8de0894d
[ "BSD-3-Clause" ]
4,730
2015-01-01T11:01:37.000Z
2020-06-30T12:31:28.000Z
deps/jemalloc/test/src/mq.c
zh1029/redis
f3dd33489834de01392dfed8e0ad5e2e8de0894d
[ "BSD-3-Clause" ]
12,210
2015-01-01T04:09:46.000Z
2020-06-30T06:30:58.000Z
#include "test/jemalloc_test.h" /* * Sleep for approximately ns nanoseconds. No lower *nor* upper bound on sleep * time is guaranteed. */ void mq_nanosleep(unsigned ns) { assert(ns <= 1000*1000*1000); #ifdef _WIN32 Sleep(ns / 1000); #else { struct timespec timeout; if (ns < 1000*1000*1000) { timeout.tv_sec = 0; timeout.tv_nsec = ns; } else { timeout.tv_sec = 1; timeout.tv_nsec = 0; } nanosleep(&timeout, NULL); } #endif }
16.357143
79
0.652838
15efc7bfc69127fd7569e0c8dbbde88ba189bb06
234
h
C
ch07/example.h
beautiful-boyyy/Cpp-Primer
7802029df51bcac4a029044fc4fd38c3a9ff6177
[ "CC0-1.0" ]
null
null
null
ch07/example.h
beautiful-boyyy/Cpp-Primer
7802029df51bcac4a029044fc4fd38c3a9ff6177
[ "CC0-1.0" ]
null
null
null
ch07/example.h
beautiful-boyyy/Cpp-Primer
7802029df51bcac4a029044fc4fd38c3a9ff6177
[ "CC0-1.0" ]
null
null
null
#ifndef EXAMPLE_H #define EXAMPLE_H #include <vector> class Example { public: Example(); static constexpr double rate = 6.5; static const int vecSize = 20; static std::vector<double> vec; }; #endif /* EXAMPLE_H */
13.764706
39
0.666667
76582ac0bc4ddbf452162a38c76370dd671f501c
2,301
h
C
src/cpp-ethereum/libethcore/Precompiled.h
nexalt-project/nexalt-core
e0c2f3f8ee0eb3ab298dfbbdb1e9d5426c65670f
[ "MIT" ]
7
2021-01-30T11:20:46.000Z
2021-12-04T02:21:19.000Z
src/cpp-ethereum/libethcore/Precompiled.h
nexalt-project/nexalt-core
e0c2f3f8ee0eb3ab298dfbbdb1e9d5426c65670f
[ "MIT" ]
null
null
null
src/cpp-ethereum/libethcore/Precompiled.h
nexalt-project/nexalt-core
e0c2f3f8ee0eb3ab298dfbbdb1e9d5426c65670f
[ "MIT" ]
7
2021-01-17T11:48:40.000Z
2021-05-10T12:15:00.000Z
/* This file is part of cpp-ethereum. cpp-ethereum is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. cpp-ethereum 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 cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. */ /** @file Precompiled.h * @author Gav Wood <i@gavwood.com> * @date 2014 */ #pragma once #include <unordered_map> #include <functional> #include <cpp-ethereum/libdevcore/CommonData.h> #include <cpp-ethereum/libdevcore/Exceptions.h> namespace dev { namespace eth { using PrecompiledExecutor = std::function<std::pair<bool, bytes>(bytesConstRef _in)>; DEV_SIMPLE_EXCEPTION(ExecutorNotFound); class PrecompiledRegistrar { public: /// Get the executor object for @a _name function or @throw ExecutorNotFound if not found. static PrecompiledExecutor const& executor(std::string const& _name); /// Register an executor. In general just use ETH_REGISTER_PRECOMPILED. static PrecompiledExecutor registerPrecompiled(std::string const& _name, PrecompiledExecutor const& _exec) { return (get()->m_execs[_name] = _exec); } /// Unregister an executor. Shouldn't generally be necessary. static void unregisterPrecompiled(std::string const& _name) { get()->m_execs.erase(_name); } private: static PrecompiledRegistrar* get() { if (!s_this) s_this = new PrecompiledRegistrar; return s_this; } std::unordered_map<std::string, PrecompiledExecutor> m_execs; static PrecompiledRegistrar* s_this; }; // TODO: unregister on unload with a static object. #define ETH_REGISTER_PRECOMPILED(Name) static std::pair<bool, bytes> __eth_registerPrecompiledFunction ## Name(bytesConstRef _in); static PrecompiledExecutor __eth_registerPrecompiledFactory ## Name = ::dev::eth::PrecompiledRegistrar::registerPrecompiled(#Name, &__eth_registerPrecompiledFunction ## Name); static std::pair<bool, bytes> __eth_registerPrecompiledFunction ## Name } }
37.721311
378
0.776619
498ece3af7e5e68b652f8e152cf93b55dcfa7e49
477
h
C
src/ast/PostfixExpression.h
skylang/sky
518add25e6a101ca2701b3c6bea977b0e76b340e
[ "MIT" ]
3
2020-07-17T05:10:56.000Z
2020-08-02T22:13:50.000Z
src/ast/PostfixExpression.h
skylang/sky
518add25e6a101ca2701b3c6bea977b0e76b340e
[ "MIT" ]
null
null
null
src/ast/PostfixExpression.h
skylang/sky
518add25e6a101ca2701b3c6bea977b0e76b340e
[ "MIT" ]
null
null
null
// Copyright (c) 2018 Stephan Unverwerth // This code is licensed under MIT license (See LICENSE for details) #ifndef ast_PostfixExpression_h #define ast_PostfixExpression_h #include "Expression.h" namespace Sky { class PostfixExpression: public Expression { public: SKY_GET_TYPE(Sky::PostfixExpression, Sky::Expression); SKY_IMPLEMENTATION_EXPRESSION_VISITOR; public: TokenType op; Expression* target = nullptr; }; } #endif
22.714286
68
0.719078
5b8702e6e25e0dc7f7c504f5923170dd003e8db9
331
c
C
arch-rtems/gdslogger.c
amontilla24/AndroidFixMe
0e4c7599beaf87e62be441fd30ba6b57500ca1b0
[ "Unlicense" ]
2
2018-10-20T12:41:45.000Z
2018-10-20T14:48:21.000Z
arch-rtems/gdslogger.c
amontilla24/AndroidFixMe
0e4c7599beaf87e62be441fd30ba6b57500ca1b0
[ "Unlicense" ]
null
null
null
arch-rtems/gdslogger.c
amontilla24/AndroidFixMe
0e4c7599beaf87e62be441fd30ba6b57500ca1b0
[ "Unlicense" ]
2
2018-10-20T14:16:39.000Z
2020-10-21T16:27:52.000Z
static void writeMemoToStdout(char *text) { time_t currentTime = getUTCTime(); char timestampBuffer[20]; char msgbuf[256]; writeTimestampLocal(currentTime, timestampBuffer); isprintf(msgbuf, sizeof msgbuf, "[%s] %s", timestampBuffer, text); puts(msgbuf); } static void ionRedirectMemos() { setLogger(writeMemoToStdout); }
20.6875
67
0.755287
8d70603c06652e58decfd0bc910f97e5ae79291e
731
h
C
Header/ParticleManager.h
yuhongyi/HazelEngine
fad6eb1f42ad7ac06b8a0e9e2d3154147b3a7c9c
[ "MIT" ]
null
null
null
Header/ParticleManager.h
yuhongyi/HazelEngine
fad6eb1f42ad7ac06b8a0e9e2d3154147b3a7c9c
[ "MIT" ]
null
null
null
Header/ParticleManager.h
yuhongyi/HazelEngine
fad6eb1f42ad7ac06b8a0e9e2d3154147b3a7c9c
[ "MIT" ]
null
null
null
#pragma once #include <list> using namespace std; #include "GameObject.h" #include "Singleton.h" #include "Particle.h" class ParticleManager : public Singleton<ParticleManager>, public GameObject { public: // ctor & dtor ParticleManager() {} // GameObject virtual bool Initialize(LPDIRECT3DDEVICE9 d3dDevice) override; virtual void Deinitialize() override; virtual void Render(LPDIRECT3DDEVICE9 d3dDevice, ID3DXEffect* effect) override; virtual void Tick(float deltaTime) override; // Methods void SpawnParticle(Cell* cellTemplate, float particleLifeTime); void ReturnParticleToPool(Particle* particleToReturn); void StopAllParticles(); private: list<Particle*> mActiveParticles; list<Particle*> mFreeParticles; };
27.074074
80
0.786594
cb94be3c30123a69bd171de92b58da5be92abb0c
4,735
h
C
release/src/linux/linux/drivers/acpi/ospm/include/ec.h
enfoTek/tomato.linksys.e2000.nvram-mod
2ce3a5217def49d6df7348522e2bfda702b56029
[ "FSFAP" ]
80
2015-01-02T10:14:04.000Z
2021-06-07T06:29:49.000Z
release/src/linux/linux/drivers/acpi/ospm/include/ec.h
unforgiven512/tomato
96f09fab4929c6ddde5c9113f1b2476ad37133c4
[ "FSFAP" ]
9
2015-05-14T11:03:12.000Z
2018-01-04T07:12:58.000Z
release/src/linux/linux/drivers/acpi/ospm/include/ec.h
unforgiven512/tomato
96f09fab4929c6ddde5c9113f1b2476ad37133c4
[ "FSFAP" ]
69
2015-01-02T10:45:56.000Z
2021-09-06T07:52:13.000Z
/***************************************************************************** * * Module Name: ec.h * $Revision: 1.1.1.2 $ * *****************************************************************************/ /* * Copyright (C) 2000, 2001 Andrew Grover * * 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 __EC_H__ #define __EC_H__ #include <linux/spinlock.h> #include <asm/semaphore.h> #include <actypes.h> #include <acexcep.h> #include <bm.h> /***************************************************************************** * Types & Other Defines *****************************************************************************/ #define EC_DEFAULT_TIMEOUT 1000 /* 1 second */ #define EC_GPE_UNKNOWN 0xFFFFFFFF #define EC_PORT_UNKNOWN 0x00000000 #define EC_BURST_ENABLE_ACKNOWLEDGE 0x90 /* * Commands: * --------- */ typedef u8 EC_COMMAND; #define EC_COMMAND_UNKNOWN ((EC_COMMAND) 0x00) #define EC_COMMAND_READ ((EC_COMMAND) 0x80) #define EC_COMMAND_WRITE ((EC_COMMAND) 0x81) #define EC_COMMAND_QUERY ((EC_COMMAND) 0x84) /* * EC_STATUS: * ---------- * The encoding of the EC status register is illustrated below. * Note that a set bit (1) indicates the property is TRUE * (e.g. if bit 0 is set then the output buffer is full). * +-+-+-+-+-+-+-+-+ * |7|6|5|4|3|2|1|0| * +-+-+-+-+-+-+-+-+ * | | | | | | | | * | | | | | | | +- Output Buffer Full (OBF)? * | | | | | | +--- Input Buffer Full (IBF)? * | | | | | +----- <reserved> * | | | | +------- data Register is command Byte? * | | | +--------- Burst Mode Enabled? * | | +----------- SCI event? * | +------------- SMI event? * +--------------- <Reserved> * */ typedef u32 EC_STATUS; #define EC_FLAG_OUTPUT_BUFFER ((EC_STATUS) 0x01) #define EC_FLAG_INPUT_BUFFER ((EC_STATUS) 0x02) #define EC_FLAG_BURST_MODE ((EC_STATUS) 0x10) #define EC_FLAG_SCI ((EC_STATUS) 0x20) /* * EC_EVENT: * --------- */ typedef u32 EC_EVENT; #define EC_EVENT_UNKNOWN ((EC_EVENT) 0x00) #define EC_EVENT_NONE ((EC_EVENT) 0x00) #define EC_EVENT_OUTPUT_BUFFER_FULL ((EC_EVENT) 0x01) #define EC_EVENT_INPUT_BUFFER_EMPTY ((EC_EVENT) 0x02) #define EC_EVENT_SCI ((EC_EVENT) 0x03) /* * Hardware IDs: * ------------- */ #define EC_HID_EC "PNP0C09" /* * EC_REQUEST: * ----------- */ typedef struct { EC_COMMAND command; u8 address; u8 data; } EC_REQUEST; /* * Device Context: * --------------- */ typedef struct { BM_HANDLE device_handle; acpi_handle acpi_handle; u32 gpe_bit; u32 status_port; u32 command_port; u32 data_port; u32 use_global_lock; u8 query_data; acpi_handle mutex; } EC_CONTEXT; /***************************************************************************** * Function Prototypes *****************************************************************************/ /* ec.c */ acpi_status ec_initialize(void); acpi_status ec_terminate(void); acpi_status ec_notify ( u32 notify_type, u32 device, void **context); acpi_status ec_request( BM_REQUEST *request_info, void *context); /* ectransx.c */ acpi_status ec_transaction ( EC_CONTEXT *ec, EC_REQUEST *ec_request); acpi_status ec_io_read ( EC_CONTEXT *ec, u32 io_port, u8 *data, EC_EVENT wait_event); acpi_status ec_io_write ( EC_CONTEXT *ec, u32 io_port, u8 data, EC_EVENT wait_event); /* ecgpe.c */ acpi_status ec_install_gpe_handler ( EC_CONTEXT *ec); acpi_status ec_remove_gpe_handler ( EC_CONTEXT *ec); /* ecspace.c */ acpi_status ec_install_space_handler ( EC_CONTEXT *ec); acpi_status ec_remove_space_handler ( EC_CONTEXT *ec); #endif /* __EC_H__ */
23.325123
79
0.533474
cbe6399ee2a29dda278f6a702a5b2cbbe5eb37a0
2,630
h
C
TradPlusAdSDK/TradPlusAds.framework/Headers/TradPlusAdRewarded.h
tradplus/pod_tradplus_sdk
366b1bc6bdabe536d9893ecd1d0bd9f1fd748c62
[ "MIT" ]
null
null
null
TradPlusAdSDK/TradPlusAds.framework/Headers/TradPlusAdRewarded.h
tradplus/pod_tradplus_sdk
366b1bc6bdabe536d9893ecd1d0bd9f1fd748c62
[ "MIT" ]
1
2022-02-21T07:40:41.000Z
2022-03-10T13:45:24.000Z
TradPlusAdSDK/TradPlusAds.framework/Headers/TradPlusAdRewarded.h
tradplus/pod_tradplus_sdk
366b1bc6bdabe536d9893ecd1d0bd9f1fd748c62
[ "MIT" ]
null
null
null
// // TradPlusAdRewarded.h // TradPlusAds // // Created by xuejun on 2021/9/6. // Copyright © 2021 TradPlus. All rights reserved. // #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> NS_ASSUME_NONNULL_BEGIN @protocol TradPlusADRewardedDelegate; @interface TradPlusAdRewarded : NSObject /// 设置广告位ID - (void)setAdUnitID:(NSString *)adUnitID; /// 设置广告位ID /// @param adUnitID 广告位ID /// @param isAutoLoad 是否开启自动加载模式 - (void)setAdUnitID:(NSString *)adUnitID isAutoLoad:(BOOL)isAutoLoad; ///返回下一个Ready的AD信息 无广告时返回nil - (nullable NSDictionary *)getReadyAdInfo; ///返回当前显示的AD信息 - (nullable NSDictionary *)getCurrentAdInfo; ///加载广告 - (void)loadAd; /// 显示广告 /// @param rootViewController rootViewController /// @param sceneId 广告位ID - (void)showAdFromRootViewController:(UIViewController *)rootViewController sceneId:(nullable NSString *)sceneId; /// 进入广告场景 /// @param sceneId 场景ID 没有则设置为nil - (void)entryAdScenario:(nullable NSString *)sceneId; /// 设置服务器端奖励验证用户数据 /// @param userID 用户唯一识别码 必填 /// @param customData 附加信息 根据平台要求填写 - (void)setServerSideVerificationOptionsWithUserID:(nonnull NSString *)userID customData:(nullable NSString *)customData; @property (nonatomic, readonly) BOOL isAdReady; @property (nonatomic, strong) NSString *segmentTag; //TradPlus后台 中介组 tag @property (nonatomic, strong) NSDictionary *dicCustomValue; @property (nonatomic,weak) id <TradPlusADRewardedDelegate> delegate; @end @protocol TradPlusADRewardedDelegate <NSObject> ///AD加载完成 - (void)tpRewardedAdLoaded:(NSDictionary *)adInfo; ///AD加载失败 - (void)tpRewardedAdLoadFailWithError:(NSError *)error; ///AD展现 - (void)tpRewardedAdImpression:(NSDictionary *)adInfo; ///AD展现失败 - (void)tpRewardedAdShow:(NSDictionary *)adInfo didFailWithError:(NSError *)error; ///AD被点击 - (void)tpRewardedAdClicked:(NSDictionary *)adInfo; ///AD关闭 - (void)tpRewardedAdDismissed:(NSDictionary *)adInfo; ///完成奖励 - (void)tpRewardedAdReward:(NSDictionary *)adInfo; @optional ///bidding开始 - (void)tpRewardedAdBidStart:(NSDictionary *)adInfo; ///bidding结束 - (void)tpRewardedAdBidEnd:(NSDictionary *)adInfo success:(BOOL)success; ///开始加载 - (void)tpRewardedAdLoadStart:(NSDictionary *)adInfo; //多缓存情况下,当每个广告源加载成功后会都会回调一次。 - (void)tpRewardedAdOneLayerLoaded:(NSDictionary *)adInfo; //多缓存情况下,当每个广告源加载失败后会都会回调一次。 - (void)tpRewardedAdOneLayerLoad:(NSDictionary *)adInfo didFailWithError:(NSError *)error; ///加载流程全部结束 - (void)tpRewardedAdAllLoaded:(BOOL)success; ///开始播放 - (void)tpRewardedAdPlayStart:(NSDictionary *)adInfo; ///播放结束 - (void)tpRewardedAdPlayEnd:(NSDictionary *)adInfo; - (void)tpRewardedAdNoReward:(NSDictionary *)adInfo; @end NS_ASSUME_NONNULL_END
27.978723
121
0.771483
4fd5d9e3d5b32287fb949d611b06e901a480907c
796
h
C
src/prod/src/Reliability/Failover/ra/FailoverUnitPreCommitValidator.h
gridgentoo/ServiceFabricAzure
c3e7a07617e852322d73e6cc9819d266146866a4
[ "MIT" ]
2,542
2018-03-14T21:56:12.000Z
2019-05-06T01:18:20.000Z
src/prod/src/Reliability/Failover/ra/FailoverUnitPreCommitValidator.h
gridgentoo/ServiceFabricAzure
c3e7a07617e852322d73e6cc9819d266146866a4
[ "MIT" ]
994
2019-05-07T02:39:30.000Z
2022-03-31T13:23:04.000Z
src/prod/src/Reliability/Failover/ra/FailoverUnitPreCommitValidator.h
gridgentoo/ServiceFabricAzure
c3e7a07617e852322d73e6cc9819d266146866a4
[ "MIT" ]
300
2018-03-14T21:57:17.000Z
2019-05-06T20:07:00.000Z
// ------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. // ------------------------------------------------------------ #pragma once namespace Reliability { namespace ReconfigurationAgentComponent { class FailoverUnitPreCommitValidator : public Infrastructure::EntityPreCommitNotificationSink<FailoverUnit> { DENY_COPY(FailoverUnitPreCommitValidator); public: FailoverUnitPreCommitValidator() {} void OnPreCommit(Infrastructure::EntityEntryBaseSPtr entry, Infrastructure::CommitDescription<FailoverUnit> const & description) override; }; } }
33.166667
150
0.60804
53f0772b6e7e70a461ce519d5b4648b28a7f5b72
733
h
C
formula_tree/Tree.h
w1ldy0uth/LMoP_VSU
52e511332947c31607dd1cf6203af736ae4cdb81
[ "MIT" ]
2
2021-09-20T20:37:38.000Z
2021-11-19T09:38:24.000Z
formula_tree/Tree.h
w1ldy0uth/LMoP_VSU_labs
52e511332947c31607dd1cf6203af736ae4cdb81
[ "MIT" ]
null
null
null
formula_tree/Tree.h
w1ldy0uth/LMoP_VSU_labs
52e511332947c31607dd1cf6203af736ae4cdb81
[ "MIT" ]
null
null
null
#pragma once #include <iostream> class Tree { public: struct TreeNode { char val; TreeNode* left; TreeNode* right; TreeNode() : val(0), left(nullptr), right(nullptr) {} TreeNode(char x) : val(x), left(nullptr), right(nullptr) {} }; typedef TreeNode* pTree; private: pTree root; void print(std::string, pTree, bool); void clear(pTree&); void openBrackets(pTree); void multiplyBrackets(pTree); std::string treeToString(pTree); public: Tree(); ~Tree(); void clear(); void print(); void stringToTree(std::string); std::string treeToString(); pTree copyInOrder(pTree); void openBrackets(); void multiplyBrackets(); };
18.794872
67
0.607094
3edd3907074d4d4c9cea0b0aba1850f2fd0b3fac
767
c
C
source/dma.c
KittenBot/codal-rp2040
d17cfdded1112521089be6ddf3fde088cb0536d9
[ "MIT" ]
null
null
null
source/dma.c
KittenBot/codal-rp2040
d17cfdded1112521089be6ddf3fde088cb0536d9
[ "MIT" ]
null
null
null
source/dma.c
KittenBot/codal-rp2040
d17cfdded1112521089be6ddf3fde088cb0536d9
[ "MIT" ]
null
null
null
#include "dma.h" #include "CodalDmesg.h" #include "ErrorNo.h" #include "hardware/dma.h" #include "hardware/irq.h" static DMAHandler dmaHandler[12]; // max channel 12 void isr_dma_0 (){ uint mask = dma_hw->ints0; // write to clear dma_hw->ints0 = mask; for (uint8_t ch=0;ch<12;ch++){ if ((1<<ch) & mask){ if (dmaHandler[ch].handler){ dma_channel_set_irq0_enabled(ch, false); dmaHandler[ch].handler(dmaHandler[ch].context); } } } } void DMA_SetChannelCallback(uint8_t channel, DMAChannelCallback handler, void * context){ if (channel >= 12) return; dmaHandler[channel].handler = handler; dmaHandler[channel].context = context; dma_channel_set_irq0_enabled(channel, true); irq_set_enabled(DMA_IRQ_0, true); }
23.96875
89
0.684485
ac7368f507e6102462a9bf101658d1701e795814
855
h
C
Homeworks/9_PathTracing/Ubpa/UScene_0_5_0/include/UScene/core.h
CieloNeet/CG-project
664747c7599636f46d2ff9758f38283658c85c08
[ "MIT" ]
null
null
null
Homeworks/9_PathTracing/Ubpa/UScene_0_5_0/include/UScene/core.h
CieloNeet/CG-project
664747c7599636f46d2ff9758f38283658c85c08
[ "MIT" ]
null
null
null
Homeworks/9_PathTracing/Ubpa/UScene_0_5_0/include/UScene/core.h
CieloNeet/CG-project
664747c7599636f46d2ff9758f38283658c85c08
[ "MIT" ]
null
null
null
#pragma once #include "core/Scene.h" #include "core/SObj.h" #include "core/Cmpt/Camera.h" #include "core/Cmpt/Geometry.h" #include "core/Cmpt/L2W.h" #include "core/Cmpt/Light.h" #include "core/Cmpt/Material.h" #include "core/Cmpt/Position.h" #include "core/Cmpt/Root.h" #include "core/Cmpt/Rotation.h" #include "core/Cmpt/Scale.h" #include "core/Cmpt/SObjPtr.h" #include "core/Cmpt/Transform.h" #include "core/Light/Light.h" #include "core/Light/AreaLight.h" #include "core/Light/DirLight.h" #include "core/Light/EnvLight.h" #include "core/Light/PointLight.h" #include "core/Material/Material.h" #include "core/Material/stdBRDF.h" #include "core/Material/texture2D.h" #include "core/Primitive/Primitive.h" #include "core/Primitive/Sphere.h" #include "core/Primitive/TriMesh.h" #include "core/Primitive/Triangle.h" #include "core/Primitive/Square.h"
25.147059
37
0.748538
3a1fc1d60388f99cef0f97c24ae9b73efc8e4ba6
28,608
c
C
usr.sbin/sysinstall/disks.c
TrustedBSD/sebsd
fd5de6f587183087cf930779701d5713e8ca64cc
[ "Naumen", "Condor-1.1", "MS-PL" ]
4
2017-04-06T21:39:15.000Z
2019-10-09T17:34:14.000Z
usr.sbin/sysinstall/disks.c
TrustedBSD/sebsd
fd5de6f587183087cf930779701d5713e8ca64cc
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
usr.sbin/sysinstall/disks.c
TrustedBSD/sebsd
fd5de6f587183087cf930779701d5713e8ca64cc
[ "Naumen", "Condor-1.1", "MS-PL" ]
1
2020-01-04T06:36:39.000Z
2020-01-04T06:36:39.000Z
/* * The new sysinstall program. * * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * * $FreeBSD: src/usr.sbin/sysinstall/disks.c,v 1.157 2006/02/28 21:49:32 jhb Exp $ * * Copyright (c) 1995 * Jordan Hubbard. 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, * verbatim and that no modifications are made prior to this * point in the file. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include "sysinstall.h" #include <ctype.h> #include <fcntl.h> #include <inttypes.h> #include <libdisk.h> #include <sys/stat.h> #include <sys/disklabel.h> #ifdef WITH_SLICES enum size_units_t { UNIT_BLOCKS, UNIT_KILO, UNIT_MEG, UNIT_GIG, UNIT_SIZE }; #ifdef PC98 #define SUBTYPE_FREEBSD 50324 #define SUBTYPE_FAT 37218 #else #define SUBTYPE_FREEBSD 165 #define SUBTYPE_FAT 6 #endif #define SUBTYPE_EFI 239 #ifdef PC98 #define OTHER_SLICE_VALUES \ "Other popular values are 37218 for a\n" \ "DOS FAT partition.\n\n" #else #define OTHER_SLICE_VALUES \ "Other popular values are 6 for a\n" \ "DOS FAT partition, 131 for a Linux ext2fs partition, or\n" \ "130 for a Linux swap partition.\n\n" #endif #define NON_FREEBSD_NOTE \ "Note: If you choose a non-FreeBSD partition type, it will not\n" \ "be formatted or otherwise prepared, it will simply reserve space\n" \ "for you to use another tool, such as DOS format, to later format\n" \ "and actually use the partition." /* Where we start displaying chunk information on the screen */ #define CHUNK_START_ROW 5 /* Where we keep track of MBR chunks */ #define CHUNK_INFO_ENTRIES 16 static struct chunk *chunk_info[CHUNK_INFO_ENTRIES]; static int current_chunk; static void diskPartitionNonInteractive(Device *dev); static u_char * bootalloc(char *name, size_t *size); static void record_chunks(Disk *d) { struct chunk *c1 = NULL; int i = 0; daddr_t last_free = 0; if (!d->chunks) msgFatal("No chunk list found for %s!", d->name); for (c1 = d->chunks->part; c1; c1 = c1->next) { if (c1->type == unused && c1->size > last_free) { last_free = c1->size; current_chunk = i; } chunk_info[i++] = c1; } chunk_info[i] = NULL; if (current_chunk >= i) current_chunk = i - 1; } static daddr_t Total; static void print_chunks(Disk *d, int u) { int row; int i; daddr_t sz; char *szstr; szstr = (u == UNIT_GIG ? "GB" : (u == UNIT_MEG ? "MB" : (u == UNIT_KILO ? "KB" : "ST"))); Total = 0; for (i = 0; chunk_info[i]; i++) Total += chunk_info[i]->size; #ifdef PC98 if (d->bios_cyl >= 65536 || d->bios_hd > 256 || d->bios_sect >= 256) { #else if (d->bios_cyl > 65536 || d->bios_hd > 256 || d->bios_sect >= 64) { #endif dialog_clear_norefresh(); msgConfirm("WARNING: A geometry of %lu/%lu/%lu for %s is incorrect. Using\n" "a more likely geometry. If this geometry is incorrect or you\n" "are unsure as to whether or not it's correct, please consult\n" "the Hardware Guide in the Documentation submenu or use the\n" "(G)eometry command to change it now.\n\n" "Remember: you need to enter whatever your BIOS thinks the\n" "geometry is! For IDE, it's what you were told in the BIOS\n" "setup. For SCSI, it's the translation mode your controller is\n" "using. Do NOT use a ``physical geometry''.", d->bios_cyl, d->bios_hd, d->bios_sect, d->name); Sanitize_Bios_Geom(d); } attrset(A_NORMAL); mvaddstr(0, 0, "Disk name:\t"); clrtobot(); attrset(A_REVERSE); addstr(d->name); attrset(A_NORMAL); attrset(A_REVERSE); mvaddstr(0, 55, "FDISK Partition Editor"); attrset(A_NORMAL); mvprintw(1, 0, "DISK Geometry:\t%lu cyls/%lu heads/%lu sectors = %jd sectors (%jdMB)", d->bios_cyl, d->bios_hd, d->bios_sect, (intmax_t)d->bios_cyl * d->bios_hd * d->bios_sect, (intmax_t)d->bios_cyl * d->bios_hd * d->bios_sect / (1024/512) / 1024); mvprintw(3, 0, "%6s %10s(%s) %10s %8s %6s %10s %8s %8s", "Offset", "Size", szstr, "End", "Name", "PType", "Desc", "Subtype", "Flags"); for (i = 0, row = CHUNK_START_ROW; chunk_info[i]; i++, row++) { switch(u) { default: /* fall thru */ case UNIT_BLOCKS: sz = chunk_info[i]->size; break; case UNIT_KILO: sz = chunk_info[i]->size / (1024/512); break; case UNIT_MEG: sz = chunk_info[i]->size / (1024/512) / 1024; break; case UNIT_GIG: sz = chunk_info[i]->size / (1024/512) / 1024 / 1024; break; } if (i == current_chunk) attrset(ATTR_SELECTED); mvprintw(row, 0, "%10jd %10jd %10jd %8s %6d %10s %8d\t%-6s", (intmax_t)chunk_info[i]->offset, (intmax_t)sz, (intmax_t)chunk_info[i]->end, chunk_info[i]->name, chunk_info[i]->type, slice_type_name(chunk_info[i]->type, chunk_info[i]->subtype), chunk_info[i]->subtype, ShowChunkFlags(chunk_info[i])); if (i == current_chunk) attrset(A_NORMAL); } } static void print_command_summary(void) { mvprintw(14, 0, "The following commands are supported (in upper or lower case):"); mvprintw(16, 0, "A = Use Entire Disk G = set Drive Geometry C = Create Slice F = `DD' mode"); mvprintw(17, 0, "D = Delete Slice Z = Toggle Size Units S = Set Bootable | = Wizard m."); mvprintw(18, 0, "T = Change Type U = Undo All Changes Q = Finish"); if (!RunningAsInit) mvprintw(18, 47, "W = Write Changes"); mvprintw(21, 0, "Use F1 or ? to get more help, arrow keys to select."); move(0, 0); } #ifdef PC98 static void getBootMgr(char *dname, u_char **bootipl, size_t *bootipl_size, u_char **bootmenu, size_t *bootmenu_size) { static u_char *boot0; static size_t boot0_size; static u_char *boot05; static size_t boot05_size; char str[80]; char *cp; int i = 0; cp = variable_get(VAR_BOOTMGR); if (!cp) { /* Figure out what kind of IPL the user wants */ sprintf(str, "Install Boot Manager for drive %s?", dname); MenuIPLType.title = str; i = dmenuOpenSimple(&MenuIPLType, FALSE); } else { if (!strncmp(cp, "boot", 4)) BootMgr = 0; else BootMgr = 1; } if (cp || i) { switch (BootMgr) { case 0: if (!boot0) boot0 = bootalloc("boot0", &boot0_size); *bootipl = boot0; *bootipl_size = boot0_size; if (!boot05) boot05 = bootalloc("boot0.5", &boot05_size); *bootmenu = boot05; *bootmenu_size = boot05_size; return; case 1: default: break; } } *bootipl = NULL; *bootipl_size = 0; *bootmenu = NULL; *bootmenu_size = 0; } #else static void getBootMgr(char *dname, u_char **bootCode, size_t *bootCodeSize) { #if defined(__i386__) || defined(__amd64__) /* only meaningful on x86 */ static u_char *mbr, *boot0; static size_t mbr_size, boot0_size; char str[80]; char *cp; int i = 0; cp = variable_get(VAR_BOOTMGR); if (!cp) { /* Figure out what kind of MBR the user wants */ sprintf(str, "Install Boot Manager for drive %s?", dname); MenuMBRType.title = str; i = dmenuOpenSimple(&MenuMBRType, FALSE); } else { if (!strncmp(cp, "boot", 4)) BootMgr = 0; else if (!strcmp(cp, "standard")) BootMgr = 1; else BootMgr = 2; } if (cp || i) { switch (BootMgr) { case 0: if (!boot0) boot0 = bootalloc("boot0", &boot0_size); *bootCode = boot0; *bootCodeSize = boot0_size; return; case 1: if (!mbr) mbr = bootalloc("mbr", &mbr_size); *bootCode = mbr; *bootCodeSize = mbr_size; return; case 2: default: break; } } #endif *bootCode = NULL; *bootCodeSize = 0; } #endif #endif /* WITH_SLICES */ int diskGetSelectCount(Device ***devs) { int i, cnt, enabled; char *cp; Device **dp; cp = variable_get(VAR_DISK); dp = *devs = deviceFind(cp, DEVICE_TYPE_DISK); cnt = deviceCount(dp); if (!cnt) return -1; for (i = 0, enabled = 0; i < cnt; i++) { if (dp[i]->enabled) ++enabled; } return enabled; } #ifdef WITH_SLICES void diskPartition(Device *dev) { char *cp, *p; int rv, key = 0; int i; Boolean chunking; char *msg = NULL; #ifdef PC98 u_char *bootipl; size_t bootipl_size; u_char *bootmenu; size_t bootmenu_size; #else u_char *mbrContents; size_t mbrSize; #endif WINDOW *w = savescr(); Disk *d = (Disk *)dev->private; int size_unit; size_unit = UNIT_BLOCKS; chunking = TRUE; keypad(stdscr, TRUE); /* Flush both the dialog and curses library views of the screen since we don't always know who called us */ dialog_clear_norefresh(), clear(); current_chunk = 0; /* Set up the chunk array */ record_chunks(d); while (chunking) { char *val, geometry[80]; /* Now print our overall state */ if (d) print_chunks(d, size_unit); print_command_summary(); if (msg) { attrset(title_attr); mvprintw(23, 0, msg); attrset(A_NORMAL); beep(); msg = NULL; } else { move(23, 0); clrtoeol(); } /* Get command character */ key = getch(); switch (toupper(key)) { case '\014': /* ^L (redraw) */ clear(); msg = NULL; break; case '\020': /* ^P */ case KEY_UP: case '-': if (current_chunk != 0) --current_chunk; break; case '\016': /* ^N */ case KEY_DOWN: case '+': case '\r': case '\n': if (chunk_info[current_chunk + 1]) ++current_chunk; break; case KEY_HOME: current_chunk = 0; break; case KEY_END: while (chunk_info[current_chunk + 1]) ++current_chunk; break; case KEY_F(1): case '?': systemDisplayHelp("slice"); clear(); break; case 'A': case 'F': /* Undocumented magic Dangerously Dedicated mode */ #if !defined(__i386__) && !defined(__amd64__) rv = 1; #else /* The rest is only relevant on x86 */ cp = variable_get(VAR_DEDICATE_DISK); if (cp && !strcasecmp(cp, "always")) rv = 1; else if (toupper(key) == 'A') rv = 0; else { rv = msgYesNo("Do you want to do this with a true partition entry\n" "so as to remain cooperative with any future possible\n" "operating systems on the drive(s)?\n" "(See also the section about ``dangerously dedicated''\n" "disks in the FreeBSD FAQ.)"); if (rv == -1) rv = 0; } #endif All_FreeBSD(d, rv); variable_set2(DISK_PARTITIONED, "yes", 0); record_chunks(d); clear(); break; case 'C': if (chunk_info[current_chunk]->type != unused) msg = "Slice in use, delete it first or move to an unused one."; else { char *val, tmp[20], name[16], *cp; daddr_t size; int subtype; chunk_e partitiontype; #ifdef PC98 snprintf(name, sizeof (name), "%s", "FreeBSD"); val = msgGetInput(name, "Please specify the name for new FreeBSD slice."); if (val) strncpy(name, val, sizeof (name)); #else name[0] = '\0'; #endif snprintf(tmp, 20, "%jd", (intmax_t)chunk_info[current_chunk]->size); val = msgGetInput(tmp, "Please specify the size for new FreeBSD slice in blocks\n" "or append a trailing `M' for megabytes (e.g. 20M)."); if (val && (size = strtoimax(val, &cp, 0)) > 0) { if (*cp && toupper(*cp) == 'M') size *= ONE_MEG; else if (*cp && toupper(*cp) == 'G') size *= ONE_GIG; sprintf(tmp, "%d", SUBTYPE_FREEBSD); val = msgGetInput(tmp, "Enter type of partition to create:\n\n" "Pressing Enter will choose the default, a native FreeBSD\n" "slice (type %u). " OTHER_SLICE_VALUES NON_FREEBSD_NOTE, SUBTYPE_FREEBSD); if (val && (subtype = strtol(val, NULL, 0)) > 0) { if (subtype == SUBTYPE_FREEBSD) partitiontype = freebsd; else if (subtype == SUBTYPE_FAT) partitiontype = fat; else if (subtype == SUBTYPE_EFI) partitiontype = efi; else #ifdef PC98 partitiontype = pc98; #else partitiontype = mbr; #endif Create_Chunk(d, chunk_info[current_chunk]->offset, size, partitiontype, subtype, (chunk_info[current_chunk]->flags & CHUNK_ALIGN), name); variable_set2(DISK_PARTITIONED, "yes", 0); record_chunks(d); } } clear(); } break; case KEY_DC: case 'D': if (chunk_info[current_chunk]->type == unused) msg = "Slice is already unused!"; else { Delete_Chunk(d, chunk_info[current_chunk]); variable_set2(DISK_PARTITIONED, "yes", 0); record_chunks(d); } break; case 'T': if (chunk_info[current_chunk]->type == unused) msg = "Slice is currently unused (use create instead)"; else { char *val, tmp[20]; int subtype; chunk_e partitiontype; sprintf(tmp, "%d", chunk_info[current_chunk]->subtype); val = msgGetInput(tmp, "New partition type:\n\n" "Pressing Enter will use the current type. To choose a native\n" "FreeBSD slice enter %u. " OTHER_SLICE_VALUES NON_FREEBSD_NOTE, SUBTYPE_FREEBSD); if (val && (subtype = strtol(val, NULL, 0)) > 0) { if (subtype == SUBTYPE_FREEBSD) partitiontype = freebsd; else if (subtype == SUBTYPE_FAT) partitiontype = fat; else if (subtype == SUBTYPE_EFI) partitiontype = efi; else #ifdef PC98 partitiontype = pc98; #else partitiontype = mbr; #endif chunk_info[current_chunk]->type = partitiontype; chunk_info[current_chunk]->subtype = subtype; } } break; case 'G': snprintf(geometry, 80, "%lu/%lu/%lu", d->bios_cyl, d->bios_hd, d->bios_sect); val = msgGetInput(geometry, "Please specify the new geometry in cyl/hd/sect format.\n" "Don't forget to use the two slash (/) separator characters!\n" "It's not possible to parse the field without them."); if (val) { long nc, nh, ns; nc = strtol(val, &val, 0); nh = strtol(val + 1, &val, 0); ns = strtol(val + 1, 0, 0); Set_Bios_Geom(d, nc, nh, ns); } clear(); break; case 'S': /* Clear active states so we won't have two */ for (i = 0; (chunk_info[i] != NULL) && (i < CHUNK_INFO_ENTRIES); i++) chunk_info[i]->flags &= !CHUNK_ACTIVE; /* Set Bootable */ chunk_info[current_chunk]->flags |= CHUNK_ACTIVE; break; case 'U': if (!variable_cmp(DISK_LABELLED, "written")) { msgConfirm("You've already written this information out - you\n" "can't undo it."); } else if (!msgNoYes("Are you SURE you want to Undo everything?")) { char cp[BUFSIZ]; sstrncpy(cp, d->name, sizeof cp); Free_Disk(dev->private); d = Open_Disk(cp); if (!d) msgConfirm("Can't reopen disk %s! Internal state is probably corrupted", cp); dev->private = d; variable_unset(DISK_PARTITIONED); variable_unset(DISK_LABELLED); if (d) record_chunks(d); } clear(); break; case 'W': if (!msgNoYes("WARNING: This should only be used when modifying an EXISTING\n" "installation. If you are installing FreeBSD for the first time\n" "then you should simply type Q when you're finished here and your\n" "changes will be committed in one batch automatically at the end of\n" "these questions. If you're adding a disk, you should NOT write\n" "from this screen, you should do it from the label editor.\n\n" "Are you absolutely sure you want to do this now?")) { variable_set2(DISK_PARTITIONED, "yes", 0); #ifdef PC98 /* * Don't trash the IPL if the first (and therefore only) chunk * is marked for a truly dedicated disk (i.e., the disklabel * starts at sector 0), even in cases where the user has * requested a FreeBSD Boot Manager -- both would be fatal in * this case. */ /* * Don't offer to update the IPL on this disk if the first * "real" chunk looks like a FreeBSD "all disk" partition, * or the disk is entirely FreeBSD. */ if ((d->chunks->part->type != freebsd) || (d->chunks->part->offset > 1)) getBootMgr(d->name, &bootipl, &bootipl_size, &bootmenu, &bootmenu_size); else { bootipl = NULL; bootipl_size = 0; bootmenu = NULL; bootmenu_size = 0; } Set_Boot_Mgr(d, bootipl, bootipl_size, bootmenu, bootmenu_size); #else /* * Don't trash the MBR if the first (and therefore only) chunk * is marked for a truly dedicated disk (i.e., the disklabel * starts at sector 0), even in cases where the user has * requested booteasy or a "standard" MBR -- both would be * fatal in this case. */ /* * Don't offer to update the MBR on this disk if the first * "real" chunk looks like a FreeBSD "all disk" partition, * or the disk is entirely FreeBSD. */ if ((d->chunks->part->type != freebsd) || (d->chunks->part->offset > 1)) getBootMgr(d->name, &mbrContents, &mbrSize); else { mbrContents = NULL; mbrSize = 0; } Set_Boot_Mgr(d, mbrContents, mbrSize); #endif if (DITEM_STATUS(diskPartitionWrite(NULL)) != DITEM_SUCCESS) msgConfirm("Disk partition write returned an error status!"); else msgConfirm("Wrote FDISK partition information out successfully."); } clear(); break; case '|': if (!msgNoYes("Are you SURE you want to go into Wizard mode?\n" "No seat belts whatsoever are provided!")) { clear(); refresh(); slice_wizard(d); variable_set2(DISK_PARTITIONED, "yes", 0); record_chunks(d); } else msg = "Wise choice!"; clear(); break; case '\033': /* ESC */ case 'Q': chunking = FALSE; #ifdef PC98 /* * Don't trash the IPL if the first (and therefore only) chunk * is marked for a truly dedicated disk (i.e., the disklabel * starts at sector 0), even in cases where the user has requested * a FreeBSD Boot Manager -- both would be fatal in this case. */ /* * Don't offer to update the IPL on this disk if the first "real" * chunk looks like a FreeBSD "all disk" partition, or the disk is * entirely FreeBSD. */ if ((d->chunks->part->type != freebsd) || (d->chunks->part->offset > 1)) { if (variable_cmp(DISK_PARTITIONED, "written")) { getBootMgr(d->name, &bootipl, &bootipl_size, &bootmenu, &bootmenu_size); if (bootipl != NULL && bootmenu != NULL) Set_Boot_Mgr(d, bootipl, bootipl_size, bootmenu, bootmenu_size); } } #else /* * Don't trash the MBR if the first (and therefore only) chunk * is marked for a truly dedicated disk (i.e., the disklabel * starts at sector 0), even in cases where the user has requested * booteasy or a "standard" MBR -- both would be fatal in this case. */ /* * Don't offer to update the MBR on this disk if the first "real" * chunk looks like a FreeBSD "all disk" partition, or the disk is * entirely FreeBSD. */ if ((d->chunks->part->type != freebsd) || (d->chunks->part->offset > 1)) { if (variable_cmp(DISK_PARTITIONED, "written")) { getBootMgr(d->name, &mbrContents, &mbrSize); if (mbrContents != NULL) Set_Boot_Mgr(d, mbrContents, mbrSize); } } #endif break; case 'Z': size_unit = (size_unit + 1) % UNIT_SIZE; break; default: beep(); msg = "Type F1 or ? for help"; break; } } p = CheckRules(d); if (p) { char buf[FILENAME_MAX]; use_helpline("Press F1 to read more about disk slices."); use_helpfile(systemHelpFile("partition", buf)); if (!variable_get(VAR_NO_WARN)) dialog_mesgbox("Disk slicing warning:", p, -1, -1); free(p); } restorescr(w); } #endif /* WITH_SLICES */ static u_char * bootalloc(char *name, size_t *size) { char buf[FILENAME_MAX]; struct stat sb; snprintf(buf, sizeof buf, "/boot/%s", name); if (stat(buf, &sb) != -1) { int fd; fd = open(buf, O_RDONLY); if (fd != -1) { u_char *cp; cp = malloc(sb.st_size); if (read(fd, cp, sb.st_size) != sb.st_size) { free(cp); close(fd); msgDebug("bootalloc: couldn't read %ld bytes from %s\n", (long)sb.st_size, buf); return NULL; } close(fd); if (size != NULL) *size = sb.st_size; return cp; } msgDebug("bootalloc: couldn't open %s\n", buf); } else msgDebug("bootalloc: can't stat %s\n", buf); return NULL; } #ifdef WITH_SLICES static int partitionHook(dialogMenuItem *selected) { Device **devs = NULL; devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK); if (!devs) { msgConfirm("Unable to find disk %s!", selected->prompt); return DITEM_FAILURE; } /* Toggle enabled status? */ if (!devs[0]->enabled) { devs[0]->enabled = TRUE; diskPartition(devs[0]); } else devs[0]->enabled = FALSE; return DITEM_SUCCESS; } static int partitionCheck(dialogMenuItem *selected) { Device **devs = NULL; devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK); if (!devs || devs[0]->enabled == FALSE) return FALSE; return TRUE; } int diskPartitionEditor(dialogMenuItem *self) { DMenu *menu; Device **devs; int i, cnt, devcnt; cnt = diskGetSelectCount(&devs); devcnt = deviceCount(devs); if (cnt == -1) { msgConfirm("No disks found! Please verify that your disk controller is being\n" "properly probed at boot time. See the Hardware Guide on the\n" "Documentation menu for clues on diagnosing this type of problem."); return DITEM_FAILURE; } else if (cnt) { /* Some are already selected */ for (i = 0; i < devcnt; i++) { if (devs[i]->enabled) { if (variable_get(VAR_NONINTERACTIVE) && !variable_get(VAR_DISKINTERACTIVE)) diskPartitionNonInteractive(devs[i]); else diskPartition(devs[i]); } } } else { /* No disks are selected, fall-back case now */ if (devcnt == 1) { devs[0]->enabled = TRUE; if (variable_get(VAR_NONINTERACTIVE) && !variable_get(VAR_DISKINTERACTIVE)) diskPartitionNonInteractive(devs[0]); else diskPartition(devs[0]); return DITEM_SUCCESS; } else { menu = deviceCreateMenu(&MenuDiskDevices, DEVICE_TYPE_DISK, partitionHook, partitionCheck); if (!menu) { msgConfirm("No devices suitable for installation found!\n\n" "Please verify that your disk controller (and attached drives)\n" "were detected properly. This can be done by pressing the\n" "[Scroll Lock] key and using the Arrow keys to move back to\n" "the boot messages. Press [Scroll Lock] again to return."); return DITEM_FAILURE; } else { i = dmenuOpenSimple(menu, FALSE) ? DITEM_SUCCESS : DITEM_FAILURE; free(menu); } return i; } } return DITEM_SUCCESS; } #endif /* WITH_SLICES */ int diskPartitionWrite(dialogMenuItem *self) { Device **devs; int i; if (!variable_cmp(DISK_PARTITIONED, "written")) return DITEM_SUCCESS; devs = deviceFind(NULL, DEVICE_TYPE_DISK); if (!devs) { msgConfirm("Unable to find any disks to write to??"); return DITEM_FAILURE; } if (isDebug()) msgDebug("diskPartitionWrite: Examining %d devices\n", deviceCount(devs)); for (i = 0; devs[i]; i++) { Disk *d = (Disk *)devs[i]->private; static u_char *boot1; #if defined(__i386__) || defined(__amd64__) static u_char *boot2; #endif if (!devs[i]->enabled) continue; #if defined(__i386__) || defined(__amd64__) if (!boot1) boot1 = bootalloc("boot1", NULL); if (!boot2) boot2 = bootalloc("boot2", NULL); Set_Boot_Blocks(d, boot1, boot2); #elif !defined(__ia64__) if (!boot1) boot1 = bootalloc("boot1", NULL); Set_Boot_Blocks(d, boot1, NULL); #endif msgNotify("Writing partition information to drive %s", d->name); if (!Fake && Write_Disk(d)) { msgConfirm("ERROR: Unable to write data to disk %s!", d->name); return DITEM_FAILURE; } } /* Now it's not "yes", but "written" */ variable_set2(DISK_PARTITIONED, "written", 0); return DITEM_SUCCESS | DITEM_RESTORE; } #ifdef WITH_SLICES /* Partition a disk based wholly on which variables are set */ static void diskPartitionNonInteractive(Device *dev) { char *cp; int i, all_disk = 0; daddr_t sz; #ifdef PC98 u_char *bootipl; size_t bootipl_size; u_char *bootmenu; size_t bootmenu_size; #else u_char *mbrContents; size_t mbrSize; #endif Disk *d = (Disk *)dev->private; record_chunks(d); cp = variable_get(VAR_GEOMETRY); if (cp) { msgDebug("Setting geometry from script to: %s\n", cp); d->bios_cyl = strtol(cp, &cp, 0); d->bios_hd = strtol(cp + 1, &cp, 0); d->bios_sect = strtol(cp + 1, 0, 0); } #ifdef PC98 if (d->bios_cyl >= 65536 || d->bios_hd > 256 || d->bios_sect >= 256) { #else if (d->bios_cyl > 65536 || d->bios_hd > 256 || d->bios_sect >= 64) { #endif msgDebug("Warning: A geometry of %lu/%lu/%lu for %s is incorrect.\n", d->bios_cyl, d->bios_hd, d->bios_sect, d->name); Sanitize_Bios_Geom(d); msgDebug("Sanitized geometry for %s is %lu/%lu/%lu.\n", d->name, d->bios_cyl, d->bios_hd, d->bios_sect); } cp = variable_get(VAR_PARTITION); if (cp) { if (!strcmp(cp, "free")) { /* Do free disk space case */ for (i = 0; chunk_info[i]; i++) { /* If a chunk is at least 10MB in size, use it. */ if (chunk_info[i]->type == unused && chunk_info[i]->size > (10 * ONE_MEG)) { Create_Chunk(d, chunk_info[i]->offset, chunk_info[i]->size, freebsd, 3, (chunk_info[i]->flags & CHUNK_ALIGN), "FreeBSD"); variable_set2(DISK_PARTITIONED, "yes", 0); break; } } if (!chunk_info[i]) { msgConfirm("Unable to find any free space on this disk!"); return; } } else if (!strcmp(cp, "all")) { /* Do all disk space case */ msgDebug("Warning: Devoting all of disk %s to FreeBSD.\n", d->name); All_FreeBSD(d, FALSE); } else if (!strcmp(cp, "exclusive")) { /* Do really-all-the-disk-space case */ msgDebug("Warning: Devoting all of disk %s to FreeBSD.\n", d->name); All_FreeBSD(d, all_disk = TRUE); } else if ((sz = strtoimax(cp, &cp, 0))) { /* Look for sz bytes free */ if (*cp && toupper(*cp) == 'M') sz *= ONE_MEG; else if (*cp && toupper(*cp) == 'G') sz *= ONE_GIG; for (i = 0; chunk_info[i]; i++) { /* If a chunk is at least sz MB, use it. */ if (chunk_info[i]->type == unused && chunk_info[i]->size >= sz) { Create_Chunk(d, chunk_info[i]->offset, sz, freebsd, 3, (chunk_info[i]->flags & CHUNK_ALIGN), "FreeBSD"); variable_set2(DISK_PARTITIONED, "yes", 0); break; } } if (!chunk_info[i]) { msgConfirm("Unable to find %jd free blocks on this disk!", (intmax_t)sz); return; } } else if (!strcmp(cp, "existing")) { /* Do existing FreeBSD case */ for (i = 0; chunk_info[i]; i++) { if (chunk_info[i]->type == freebsd) break; } if (!chunk_info[i]) { msgConfirm("Unable to find any existing FreeBSD partitions on this disk!"); return; } } else { msgConfirm("`%s' is an invalid value for %s - is config file valid?", cp, VAR_PARTITION); return; } if (!all_disk) { #ifdef PC98 getBootMgr(d->name, &bootipl, &bootipl_size, &bootmenu, &bootmenu_size); Set_Boot_Mgr(d, bootipl, bootipl_size, bootmenu, bootmenu_size); #else getBootMgr(d->name, &mbrContents, &mbrSize); Set_Boot_Mgr(d, mbrContents, mbrSize); #endif } variable_set2(DISK_PARTITIONED, "yes", 0); } } #endif /* WITH_SLICES */
28.213018
103
0.628356
5f9771799a8d61d02c729e812f43408347c2c6a9
293
h
C
Classes/Controllers/Navigation Controllers/ARContentControllers.h
artsy/energy
e3543ff0a87029dbd171af7b0e09c9fa13b5536a
[ "MIT" ]
231
2015-08-06T18:40:19.000Z
2022-03-27T20:40:03.000Z
Classes/Controllers/Navigation Controllers/ARContentControllers.h
artsy/energy
e3543ff0a87029dbd171af7b0e09c9fa13b5536a
[ "MIT" ]
313
2015-08-06T19:04:17.000Z
2022-01-14T15:42:36.000Z
Classes/Controllers/Navigation Controllers/ARContentControllers.h
artsy/energy
e3543ff0a87029dbd171af7b0e09c9fa13b5536a
[ "MIT" ]
54
2015-08-06T19:01:14.000Z
2022-02-10T12:19:50.000Z
#import "ARGridViewController.h" #import "ARArtistViewController.h" #import "ARAlbumViewController.h" #import "ARArtworkSetViewController.h" #import "ARShowViewController.h" #import "ARModernDocumentPreviewViewController.h" #import "ARTopViewController.h" #import "ARImageSetViewController.h"
32.555556
49
0.836177
5c7972f91ef648ab58c99e168309dce73abbe9f3
11,398
h
C
linux-3.0.1/drivers/staging/westbridge/astoria/include/linux/westbridge/cyaslowlevel.h
tonghua209/samsun6410_linux_3_0_0_1_for_aws
31aa0dc27c4aab51a92309a74fd84ca65e8c6a58
[ "Apache-2.0" ]
4
2016-07-01T04:50:02.000Z
2021-11-14T21:29:42.000Z
linux-3.0/drivers/staging/westbridge/astoria/include/linux/westbridge/cyaslowlevel.h
spartan263/vizio_oss
74270002d874391148119b48882db6816e7deedc
[ "Linux-OpenIB" ]
null
null
null
linux-3.0/drivers/staging/westbridge/astoria/include/linux/westbridge/cyaslowlevel.h
spartan263/vizio_oss
74270002d874391148119b48882db6816e7deedc
[ "Linux-OpenIB" ]
1
2020-04-03T14:00:39.000Z
2020-04-03T14:00:39.000Z
/* Cypress West Bridge API header file (cyaslowlevel.h) ## =========================== ## Copyright (C) 2010 Cypress Semiconductor ## ## This program is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License ## as published by the Free Software Foundation; either version 2 ## of the License, or (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 51 Franklin Street ## Fifth Floor, Boston, MA 02110-1301, USA. ## =========================== */ #ifndef _INCLUDED_CYASLOWLEVEL_H_ #define _INCLUDED_CYASLOWLEVEL_H_ /*@@Low Level Communications Summary The low level communications module is responsible for communications between the West Bridge device and the P port processor. Communications is organized as a series of requests and subsequent responses. For each request there is a one and only one response. Requests may go from the West Bridge device to the P port processor, or from the P Port processor to the West Bridge device. Description Requests are issued across what is called a context. A context is a single channel of communications from one processor to another processor. There can be only a single request outstanding on a context at a given time. Contexts are used to identify subsystems that can only process a single request at a time, but are independent of other contexts in the system. For instance, there is a context for communicating storage commands from the P port processor to the West Bridge device. There is also a context for communicating USB commands from the P port processor to the West Bridge device. Requests and responses are identical with the exception of the type bit in the request/response header. If the type bit is one, the packet is a request. If this bit is zero, the packet is a response. Also encoded within the header of the request/response is the code. The code is a command code for a request, or a response code for a response. For a request, the code is a function of the context. The code 0 has one meaning for the storage context and a different meaning for the USB context. The code is treated differently in the response. If the code in the response is less than 16, then the meaning of the response is global across all contexts. If the response is greater than or equal to 16, then the response is specific to the associated context. Requests and responses are transferred between processors through the mailbox registers. It may take one or more cycles to transmit a complete request or response. The context is encoded into each cycle of the transfer to insure the receiving processor can route the data to the appropriate context for processing. In this way, the traffic from multiple contexts can be multiplexed into a single data stream through the mailbox registers by the sending processor, and demultiplexed from the mailbox registers by the receiving processor. * Firmware Assumptions * The firmware assumes that mailbox contents will be consumed immediately. Therefore for multi-cycle packets, the data is sent in a tight polling loop from the firmware. This implies that the data must be read from the mailbox register on the P port side and processed immediately or performance of the firmware will suffer. In order to insure this is the case, the data from the mailboxes is read and stored immediately in a per context buffer. This occurs until the entire packet is received at which time the request packet is processed. Since the protocol is designed to allow for only one outstanding packet at a time, the firmware can never be in a position of waiting on the mailbox registers while the P port is processing a request. Only after the response to the previous request is sent will another request be sent. */ #include "cyashal.h" #include "cyasdevice.h" #include "cyas_cplus_start.h" /* * Constants */ #define CY_AS_REQUEST_RESPONSE_CODE_MASK (0x00ff) #define CY_AS_REQUEST_RESPONSE_CONTEXT_MASK (0x0F00) #define CY_AS_REQUEST_RESPONSE_CONTEXT_SHIFT (8) #define CY_AS_REQUEST_RESPONSE_TYPE_MASK (0x4000) #define CY_AS_REQUEST_RESPONSE_LAST_MASK (0x8000) #define CY_AS_REQUEST_RESPONSE_CLEAR_STR_FLAG (0x1000) /* * These macros extract the data from a 16 bit value */ #define cy_as_mbox_get_code(c) \ ((uint8_t)((c) & CY_AS_REQUEST_RESPONSE_CODE_MASK)) #define cy_as_mbox_get_context(c) \ ((uint8_t)(((c) & CY_AS_REQUEST_RESPONSE_CONTEXT_MASK) \ >> CY_AS_REQUEST_RESPONSE_CONTEXT_SHIFT)) #define cy_as_mbox_is_last(c) \ ((c) & CY_AS_REQUEST_RESPONSE_LAST_MASK) #define cy_as_mbox_is_request(c) \ (((c) & CY_AS_REQUEST_RESPONSE_TYPE_MASK) != 0) #define cy_as_mbox_is_response(c) \ (((c) & CY_AS_REQUEST_RESPONSE_TYPE_MASK) == 0) /* * These macros (not yet written) pack data into or extract data * from the m_box0 field of the request or response */ #define cy_as_ll_request_response__set_code(req, code) \ ((req)->box0 = \ ((req)->box0 & ~CY_AS_REQUEST_RESPONSE_CODE_MASK) | \ (code & CY_AS_REQUEST_RESPONSE_CODE_MASK)) #define cy_as_ll_request_response__get_code(req) \ cy_as_mbox_get_code((req)->box0) #define cy_as_ll_request_response__set_context(req, context) \ ((req)->box0 |= ((context) << \ CY_AS_REQUEST_RESPONSE_CONTEXT_SHIFT)) #define cy_as_ll_request_response__set_clear_storage_flag(req) \ ((req)->box0 |= CY_AS_REQUEST_RESPONSE_CLEAR_STR_FLAG) #define cy_as_ll_request_response__get_context(req) \ cy_as_mbox_get_context((req)->box0) #define cy_as_ll_request_response__is_last(req) \ cy_as_mbox_is_last((req)->box0) #define CY_an_ll_request_response___set_last(req) \ ((req)->box0 |= CY_AS_REQUEST_RESPONSE_LAST_MASK) #define cy_as_ll_request_response__is_request(req) \ cy_as_mbox_is_request((req)->box0) #define cy_as_ll_request_response__set_request(req) \ ((req)->box0 |= CY_AS_REQUEST_RESPONSE_TYPE_MASK) #define cy_as_ll_request_response__set_response(req) \ ((req)->box0 &= ~CY_AS_REQUEST_RESPONSE_TYPE_MASK) #define cy_as_ll_request_response__is_response(req) \ cy_as_mbox_is_response((req)->box0) #define cy_as_ll_request_response__get_word(req, offset) \ ((req)->data[(offset)]) #define cy_as_ll_request_response__set_word(req, offset, \ value) ((req)->data[(offset)] = value) typedef enum cy_as_remove_request_result_t { cy_as_remove_request_sucessful, cy_as_remove_request_in_transit, cy_as_remove_request_not_found } cy_as_remove_request_result_t; /* Summary Start the low level communications module Description */ cy_as_return_status_t cy_as_ll_start( cy_as_device *dev_p ); cy_as_return_status_t cy_as_ll_stop( cy_as_device *dev_p ); cy_as_ll_request_response * cy_as_ll_create_request( cy_as_device *dev_p, uint16_t code, uint8_t context, /* Length of the request in 16 bit words */ uint16_t length ); void cy_as_ll_init_request( cy_as_ll_request_response *req_p, uint16_t code, uint16_t context, uint16_t length); void cy_as_ll_init_response( cy_as_ll_request_response *req_p, uint16_t length); void cy_as_ll_destroy_request( cy_as_device *dev_p, cy_as_ll_request_response *); cy_as_ll_request_response * cy_as_ll_create_response( cy_as_device *dev_p, /* Length of the request in 16 bit words */ uint16_t length ); cy_as_remove_request_result_t cy_as_ll_remove_request( cy_as_device *dev_p, cy_as_context *ctxt_p, cy_as_ll_request_response *req_p, cy_bool force ); void cy_as_ll_remove_all_requests(cy_as_device *dev_p, cy_as_context *ctxt_p); void cy_as_ll_destroy_response( cy_as_device *dev_p, cy_as_ll_request_response *); cy_as_return_status_t cy_as_ll_send_request( /* The West Bridge device */ cy_as_device *dev_p, /* The request to send */ cy_as_ll_request_response *req, /* Storage for a reply, must be sure it is of sufficient size */ cy_as_ll_request_response *resp, /* If true, this is a sync request */ cy_bool sync, /* Callback to call when reply is received */ cy_as_response_callback cb ); cy_as_return_status_t cy_as_ll_send_request_wait_reply( /* The West Bridge device */ cy_as_device *dev_p, /* The request to send */ cy_as_ll_request_response *req, /* Storage for a reply, must be sure it is of sufficient size */ cy_as_ll_request_response *resp ); /* Summary This function registers a callback function to be called when a request arrives on a given context. Description Returns * CY_AS_ERROR_SUCCESS */ extern cy_as_return_status_t cy_as_ll_register_request_callback( cy_as_device *dev_p, uint8_t context, cy_as_response_callback cb ); /* Summary This function packs a set of bytes given by the data_p pointer into a request, reply structure. */ extern void cy_as_ll_request_response__pack( /* The destintation request or response */ cy_as_ll_request_response *req, /* The offset of where to pack the data */ uint32_t offset, /* The length of the data to pack in bytes */ uint32_t length, /* The data to pack */ void *data_p ); /* Summary This function unpacks a set of bytes from a request/reply structure into a segment of memory given by the data_p pointer. */ extern void cy_as_ll_request_response__unpack( /* The source of the data to unpack */ cy_as_ll_request_response *req, /* The offset of the data to unpack */ uint32_t offset, /* The length of the data to unpack in bytes */ uint32_t length, /* The destination of the unpack operation */ void *data_p ); /* Summary This function sends a status response back to the West Bridge device in response to a previously send request */ extern cy_as_return_status_t cy_as_ll_send_status_response( /* The West Bridge device */ cy_as_device *dev_p, /* The context to send the response on */ uint8_t context, /* The success/failure code to send */ uint16_t code, /* Flag to clear wait on storage context */ uint8_t clear_storage); /* Summary This function sends a response back to the West Bridge device. Description This function sends a response back to the West Bridge device. The response is sent on the context given by the 'context' variable. The code for the response is given by the 'code' argument. The data for the response is given by the data and length arguments. */ extern cy_as_return_status_t cy_as_ll_send_data_response( /* The West Bridge device */ cy_as_device *dev_p, /* The context to send the response on */ uint8_t context, /* The response code to use */ uint16_t code, /* The length of the data for the response */ uint16_t length, /* The data for the response */ void *data ); /* Summary This function removes any requests of the given type from the given context. Description This function removes requests of a given type from the context given via the context number. */ extern cy_as_return_status_t cy_as_ll_remove_ep_data_requests( /* The West Bridge device */ cy_as_device *dev_p, cy_as_end_point_number_t ep ); #include "cyas_cplus_end.h" #endif /* _INCLUDED_CYASLOWLEVEL_H_ */
31.057221
68
0.770047
583cdec313c9ea44792e616c878b6a3c29c89649
1,607
h
C
TTFrameWork/TTOtherPayManager/TTPayManager.h
zhangfurun/TT
17f43acdf564f288ab303d26c71f56b6a41e7b10
[ "MIT" ]
50
2017-03-01T07:09:23.000Z
2021-08-09T15:34:49.000Z
TTFrameWork/TTOtherPayManager/TTPayManager.h
zhangfurun/TT
17f43acdf564f288ab303d26c71f56b6a41e7b10
[ "MIT" ]
null
null
null
TTFrameWork/TTOtherPayManager/TTPayManager.h
zhangfurun/TT
17f43acdf564f288ab303d26c71f56b6a41e7b10
[ "MIT" ]
11
2017-03-24T08:46:19.000Z
2018-05-15T00:58:15.000Z
// // TTPayManager.h // StoryShip // // Created by 张福润 on 2017/4/23. // Copyright © 2017年 ifenghui. All rights reserved. // #import <Foundation/Foundation.h> #import "TTBaseModel.h" #define TTPAY_MANAGER [TTPayManager sharedManager] @class WeChatPayModel; typedef enum : NSUInteger { ErrorCodeType_Success, ErrorCodeType_Failure, ErrorCodeType_Cancel, } ErrorCodeType; typedef void(^SuccessBlock)(); typedef void(^CancelBlock)(); typedef void(^FailureBlock)(NSString *errStr); @interface TTPayManager : NSObject + (instancetype)sharedManager; /** 注册微信和支付宝 */ - (void)registerApp; /** 处理跳转url,回到应用,需要在delegate中实现 */ - (BOOL)handleUrl:(NSURL *)url; /** 支付 @param orderMessage 支付信息 微信为OrderPayModel 支付宝为NSString @param successBlock 成功的回调 @param cancelBlock 取消的回调 @param failureBlock 失败的回调 */ - (void)payWithOrderMessage:(id)orderMessage successBlock:(SuccessBlock)successBlock cancelBlock:(CancelBlock)cancelBlock failureBlock:(FailureBlock)failureBlock; @end @interface WeChatPayModel : TTBaseModel @property (copy, nonatomic) NSString *payTitle; @property (copy, nonatomic) NSString *orderNo; // orderCode @property (copy, nonatomic) NSString *price; @property (copy, nonatomic) NSString *notifyUrl; // 微信的回调地址 @end @interface AliPayModel : TTBaseModel @property (copy, nonatomic) NSString *payTitle; @property (copy, nonatomic) NSString *orderNo; // orderCode @property (copy, nonatomic) NSString *price; @property (copy, nonatomic) NSString *notifyUrl; // 微信的回调地址 @property (copy, nonatomic) NSString *body; // 描述 @end
22.957143
59
0.734287
d4ec3a755e2cc8e0fe65ae7fc149c7511c3a54a4
938
h
C
scipy/special/_faddeeva.h
FranzForstmayr/scipy
9a12908f843aed87203b32e45d1001353d90c548
[ "BSD-3-Clause" ]
1
2019-07-12T16:40:35.000Z
2019-07-12T16:40:35.000Z
scipy/special/_faddeeva.h
FranzForstmayr/scipy
9a12908f843aed87203b32e45d1001353d90c548
[ "BSD-3-Clause" ]
1
2019-07-24T19:52:07.000Z
2019-07-24T19:52:07.000Z
scipy/special/_faddeeva.h
FranzForstmayr/scipy
9a12908f843aed87203b32e45d1001353d90c548
[ "BSD-3-Clause" ]
2
2019-12-29T20:29:20.000Z
2020-06-08T14:39:49.000Z
#ifndef FADDEEVA_H_ #define FADDEEVA_H_ #ifdef __cplusplus #define EXTERN_C_START extern "C" { #define EXTERN_C_END } #else #define EXTERN_C_START #define EXTERN_C_END #endif #include <complex> #include <Python.h> #include "Faddeeva.hh" EXTERN_C_START #include <numpy/npy_math.h> npy_cdouble faddeeva_w(npy_cdouble zp); npy_cdouble faddeeva_erf(npy_cdouble zp); double faddeeva_erfc(double x); npy_cdouble faddeeva_erfc_complex(npy_cdouble zp); double faddeeva_erfcx(double x); npy_cdouble faddeeva_erfcx_complex(npy_cdouble zp); double faddeeva_erfi(double zp); npy_cdouble faddeeva_erfi_complex(npy_cdouble zp); double faddeeva_dawsn(double zp); npy_cdouble faddeeva_dawsn_complex(npy_cdouble zp); npy_cdouble faddeeva_ndtr(npy_cdouble zp); double faddeeva_log_ndtr(double x); npy_cdouble faddeeva_log_ndtr_complex(npy_cdouble zp); double faddeeva_voigt_profile(double x, double sigma, double gamma); EXTERN_C_END #endif
20.391304
68
0.823028
5c0042a1311e60d437fc9334cb373832bebfe3da
101
h
C
debug_911.h
zorbathut/d-net
61f610ca71270c6a95cf57dc3acaeab8559a234b
[ "MIT" ]
1
2016-11-02T06:47:52.000Z
2016-11-02T06:47:52.000Z
debug_911.h
zorbathut/d-net
61f610ca71270c6a95cf57dc3acaeab8559a234b
[ "MIT" ]
null
null
null
debug_911.h
zorbathut/d-net
61f610ca71270c6a95cf57dc3acaeab8559a234b
[ "MIT" ]
null
null
null
#ifndef DNET_DEBUG_911 #define DNET_DEBUG_911 void Prepare911(const char *fname, int line); #endif
14.428571
45
0.792079
ce0e733f73b82043524bc3c576cad4337a62a938
15,399
h
C
VirtoolsNMOLoader/VirtoolsNMOLoader/Virtools-SDK-2.1/Include/XClassArray.h
imengyu/Ballance
3975238876ce7095eb5592d49a624ae728552385
[ "MIT" ]
16
2021-11-12T12:42:04.000Z
2022-03-30T07:56:39.000Z
VirtoolsNMOLoader/VirtoolsNMOLoader/Virtools-SDK-2.1/Include/XClassArray.h
imengyu/Ballance
3975238876ce7095eb5592d49a624ae728552385
[ "MIT" ]
null
null
null
VirtoolsNMOLoader/VirtoolsNMOLoader/Virtools-SDK-2.1/Include/XClassArray.h
imengyu/Ballance
3975238876ce7095eb5592d49a624ae728552385
[ "MIT" ]
1
2022-03-18T04:42:49.000Z
2022-03-18T04:42:49.000Z
/*************************************************************************/ /* File : XClassArray.h */ /* Author : Aymeric Bard */ /* */ /* Virtools SDK */ /* Copyright (c) Virtools 2000, All Rights Reserved. */ /*************************************************************************/ #ifndef _XCLASSARRAY_H_ #define _XCLASSARRAY_H_ "$Id:$" #include "XUtil.h" #ifdef _WIN32 #pragma warning(disable : 4786) #endif /************************************************ {filename:XClassArray} Name: XClassArray Summary: Class representation of an array. Remarks: This array is designed to hold structure or class which have something specific to do on the construction, deletion or recopy, like allocating/destroying pointers. See Also : XArray, XSArray ************************************************/ template <class T> class XClassArray { public: typedef T *Iterator; /************************************************ Summary: Constructors. Input Arguments: ss: Default number of reserved elements. a: An array to copy from. ************************************************/ XClassArray(int ss = 0) { // Allocated if (ss > 0) { m_Begin = Allocate(ss); m_End = m_Begin; m_AllocatedEnd = m_Begin + ss; } else { m_AllocatedEnd = 0; m_Begin = m_End = 0; } } XClassArray(const XClassArray<T> &a) { // the resize int size = a.Size(); m_Begin = Allocate(size); m_End = m_Begin + size; m_AllocatedEnd = m_End; // The copy XCopy(m_Begin, a.m_Begin, a.m_End); } /************************************************ Summary: Destructor. Remarks: Release the elements contained in the array. If you were storing pointers, you need first to iterate on the array and call delete on each pointer. ************************************************/ ~XClassArray() { Clear(); } /************************************************ Summary: Affectation operator. Remarks: The content of the array is enterely overwritten by the given array. ************************************************/ XClassArray<T> &operator=(const XClassArray<T> &a) { if (this != &a) { if (Allocated() >= a.Size()) { // No need to allocate // The copy XCopy(m_Begin, a.m_Begin, a.m_End); m_End = m_Begin + a.Size(); } else { Free(); // the resize int size = a.Size(); m_Begin = Allocate(size); m_End = m_Begin + size; m_AllocatedEnd = m_End; // The copy XCopy(m_Begin, a.m_Begin, a.m_End); } } return *this; } /************************************************ Summary: Removes all the elements from an array. Remarks: There is no more space reserved after this call. ************************************************/ void Clear() { Free(); m_Begin = 0; m_End = 0; m_AllocatedEnd = 0; } /************************************************ Summary: Reserves n elements fot an array. Remarks: The elements beyond the reserved limit are discarded. ************************************************/ void Reserve(int size) { // allocation of new size T *newdata = Allocate(size); // Recopy of old elements T *last = XMin(m_Begin + size, m_End); XCopy(newdata, m_Begin, last); // new Pointers Free(); m_End = newdata + (last - m_Begin); m_Begin = newdata; m_AllocatedEnd = newdata + size; } /************************************************ Summary: Resizes th elements numbers of an array. Remarks: If the size is greater than the reserved size, the array is reallocated at the exact needed size. If not, threr is no reallocation at all. Resize(0) is faster than Clear() if you know you will probably push some more elements after. ************************************************/ void Resize(int size) { // we check if the array has enough capacity int oldsize = (m_AllocatedEnd - m_Begin); // If not, we allocate extra data if (size > oldsize) Reserve(size); // We set the end cursor m_End = m_Begin + size; } /************************************************ Summary: Inserts an element at the end of an array. Input Arguments: o: object to insert. ************************************************/ void PushBack(const T &o) { XInsert(m_End, o); } /************************************************ Summary: Expands an array of e elements. Input Arguments: e: size to expand. ************************************************/ void Expand(int e = 1) { // we check if the array has enough capacity // If not, we allocate extra data while (Size() + e > Allocated()) { Reserve(Allocated() ? Allocated() * 2 : 2); } // We set the end cursor m_End += e; } /************************************************ Summary: Inserts an element at the start of an array. Input Arguments: o: object to insert. ************************************************/ void PushFront(const T &o) { XInsert(m_Begin, o); } /************************************************ Summary: Inserts an element before another one. Input Arguments: i: iterator on the element to insert before. pos: position to insert the object o: object to insert. Remarks: The element to insert before is given as an iterator on it, i.e. a pointer on it in this case. ************************************************/ void Insert(T *i, const T &o) { // TODO : s'assurer que i est dans les limites... if (i < m_Begin || i > m_End) return; // The Call XInsert(i, o); } void Insert(int pos, const T &o) { Insert(m_Begin + pos, o); } /************************************************ Summary: Removes the last element of an array. ************************************************/ void PopBack() { // we remove the last element only if it exists if (m_End > m_Begin) XRemove(m_End - 1); } /************************************************ Summary: Removes the first element of an array. ************************************************/ void PopFront() { // we remove the first element only if it exists if (m_Begin != m_End) XRemove(m_Begin); } /************************************************ Summary: Removes an element. Input Arguments: i: iterator on the element to remove. pos: position of the object to remove. Return Value: an iterator on the next element after the element removed (to go on with an iteration). Remarks: The elements are given by iterators on them, i.e. pointer on them in this case. ************************************************/ T *Remove(T *i) { // we ensure i is in boundary... if (i < m_Begin || i >= m_End) return 0; // the Call return XRemove(i); } T *RemoveAt(int pos) { // we ensure i is in boundary... if (pos >= Size()) return NULL; // the Call return XRemove(m_Begin + pos); } void FastRemove(const T &o) { FastRemove(Find(o)); } void FastRemove(const Iterator &iT) { // we ensure i is in boundary... if (iT < m_Begin || iT >= m_End) return; m_End--; if (iT < m_End) *iT = *m_End; } /************************************************ Summary: Access to an array element. Input Arguments: i: index of the element to access. Return Value: a reference on the object accessed. Remarks: No test are provided on i. ************************************************/ T &operator[](int i) const { XASSERT(i >= 0 && i < Size()); return *(m_Begin + i); } /************************************************ Summary: Access to an array element. Input Arguments: i: index of the element to access. Return Value: a pointer on the object accessed. Remarks: End() is returned if i is outside the array limits. ************************************************/ T *At(unsigned int i) const { if (i >= (unsigned int)Size()) return m_End; return m_Begin + i; } /************************************************ Summary: Swaps two items in array. Input Arguments: pos1: position of first item to swap pos2: position of second item to swap. ************************************************/ void Swap(int pos1, int pos2) { char buffer[sizeof(T)]; memcpy(buffer, m_Begin + pos1, sizeof(T)); memcpy(m_Begin + pos1, m_Begin + pos2, sizeof(T)); memcpy(m_Begin + pos2, buffer, sizeof(T)); } /************************************************ Summary: Swaps two arrays. Input Arguments: o: second array to swap. ************************************************/ void Swap(XClassArray<T> &a) { XSwap(m_Begin, a.m_Begin); XSwap(m_End, a.m_End); XSwap(m_AllocatedEnd, a.m_AllocatedEnd); } /************************************************ Summary: Returns the last element of an array. Remarks: No test are provided to see if there is an element. ************************************************/ T &Back() { return *(End() - 1); } const T &Back() const { return *(End() - 1); } /************************************************ Summary: Returns an iterator on the first element. Example: Typically, an algorithm iterating on an array looks like: for(T* t = a.Begin(); t != a.End(); ++t) { // do something with *t } ************************************************/ T *Begin() const { return m_Begin; } /************************************************ Summary: Returns an iterator after the last element. ************************************************/ T *End() const { return m_End; } /************************************************ Summary: Returns the elements number. ************************************************/ int Size() const { return m_End - m_Begin; } /************************************************ Summary: Returns the elements allocated. ************************************************/ int Allocated() const { return m_AllocatedEnd - m_Begin; } /************************************************ Summary: Returns the occupied size in memory in bytes Parameters: addstatic: TRUE if you want to add the size occupied by the class itself. ************************************************/ int GetMemoryOccupation(XBOOL addstatic = FALSE) const { return Allocated() * sizeof(T) + (addstatic ? sizeof(*this) : 0); } /************************************************ Summary: Finds an element. Input Arguments: o: element to find. Return Value: a pointer on the first object found or End() if the object is not found. ************************************************/ T *Find(const T &o) const { // If the array is empty if (!(m_End - m_Begin)) return m_End; T *t = m_Begin; while (t < m_End && *t != o) ++t; return t; } /************************************************ Summary: Returns the position of an element. Input Arguments: o: element to find. Return Value: position or -1 if not found. ************************************************/ int GetPosition(const T &o) const { T *t = Find(o); // If the element is not found if (t == m_End) return -1; // else return the position return t - m_Begin; } static int XCompare(const void *elem1, const void *elem2) { return *(T *)elem1 - *(T *)elem2; } /************************************************ Summary: Sorts an array with a quick sort. Input Arguments: compare: The function comparing two elements. Remarks: Two sorts algorithm are available : BubbleSort and (quick)Sort. ************************************************/ void Sort(VxSortFunc Fct = XCompare) { qsort(m_Begin, Size(), sizeof(T), Fct); } protected: /// // Methods void XCopy(T *dest, T *start, T *end) { while (start != end) { *dest = *start; start++; dest++; } } void XMove(T *dest, T *start, T *end) { if (dest > start) { dest += end - start; while (start != end) { --dest; --end; *dest = *end; } } else XCopy(dest, start, end); } void XInsert(T *i, const T &o) { // Test For Reallocation if (m_End + 1 > m_AllocatedEnd) { int newsize = (m_AllocatedEnd - m_Begin) * 2; //+m_AllocationSize; if (!newsize) newsize = 1; T *newdata = Allocate(newsize); // copy before insertion point XCopy(newdata, m_Begin, i); // copy the new element T *insertionpoint = newdata + (i - m_Begin); *(insertionpoint) = o; // copy after insertion point XCopy(insertionpoint + 1, i, m_End); // New Pointers m_End = newdata + (m_End - m_Begin); Free(); m_Begin = newdata; m_AllocatedEnd = newdata + newsize; } else { // copy after insertion point XMove(i + 1, i, m_End); // copy the new element *i = o; } m_End++; } T *XRemove(T *i) { // copy after insertion point XMove(i, i + 1, m_End); m_End--; return i; } /// // Allocation and deallocation methods : to be override for alignement purposes T *Allocate(int size) { if (size) return new T[size]; else return 0; } void Free() { delete[] m_Begin; } /// // Members T *m_Begin; T *m_End; T *m_AllocatedEnd; }; #endif
26.011824
83
0.4273
c01e146aaa0658498cbc5e0ae6ab814b8464fe73
141
c
C
vendor/uncrustify-0.59/tests/output/c/00620-indent-assign.c
b4hand/sauce
8e1528944bc1bd42f4c1cb36d1bebd04e4f0447b
[ "MIT" ]
null
null
null
vendor/uncrustify-0.59/tests/output/c/00620-indent-assign.c
b4hand/sauce
8e1528944bc1bd42f4c1cb36d1bebd04e4f0447b
[ "MIT" ]
null
null
null
vendor/uncrustify-0.59/tests/output/c/00620-indent-assign.c
b4hand/sauce
8e1528944bc1bd42f4c1cb36d1bebd04e4f0447b
[ "MIT" ]
null
null
null
void foo(void) { int a; junk(a = 3); } void f() { int x = size_t(1.0) + 2; int y = (size_t(1.0) + 5); }
9.4
25
0.368794
a34f3deb89375776addf6bc4b8132f43a9206285
93
h
C
ios/Classes/AgoraFpaServicePlugin.h
AgoraIO-Community/Agora-Flutter-FPA-SDK
e5b336ff25f8c9e17e767d930efbffe29756819e
[ "MIT" ]
1
2022-01-20T15:16:38.000Z
2022-01-20T15:16:38.000Z
ios/Classes/AgoraFpaServicePlugin.h
AgoraIO-Community/Agora-Flutter-FPA-SDK
e5b336ff25f8c9e17e767d930efbffe29756819e
[ "MIT" ]
null
null
null
ios/Classes/AgoraFpaServicePlugin.h
AgoraIO-Community/Agora-Flutter-FPA-SDK
e5b336ff25f8c9e17e767d930efbffe29756819e
[ "MIT" ]
null
null
null
#import <Flutter/Flutter.h> @interface AgoraFpaServicePlugin : NSObject<FlutterPlugin> @end
18.6
58
0.806452
b88963e06b53fe1a22cd35e8669488e8615d0768
3,807
c
C
tests/check_protobuf.c
jbamlee/blue-app-hycon
628d4d7d373a2cf2a4d4705499eaa141c1560881
[ "Apache-2.0" ]
2
2018-06-20T13:15:54.000Z
2018-09-13T17:59:45.000Z
tests/check_protobuf.c
jbamlee/blue-app-hycon
628d4d7d373a2cf2a4d4705499eaa141c1560881
[ "Apache-2.0" ]
null
null
null
tests/check_protobuf.c
jbamlee/blue-app-hycon
628d4d7d373a2cf2a4d4705499eaa141c1560881
[ "Apache-2.0" ]
4
2018-06-27T08:32:15.000Z
2019-02-20T02:43:29.000Z
#include <check.h> #include <math.h> #include "../src/hycon_api.h" #include "test_data.h" void setup(void) { } void teardown(void) { } START_TEST(test_protobuf_small) { const uint8_t const encoded_tx[] = {0x12, 0x14, 0xdb, 0x66, 0x12, 0xb3, 0x09, 0xd2, 0x57, 0xa2, 0xae, 0xbd, 0x59, 0xb7, 0x44, 0x5a, 0x90, 0x0e, 0xd7, 0x75, 0xd9, 0x21, 0x18, 0x90, 0x4e, 0x20, 0x64, 0x28, 0xd2, 0x09}; hycon_tx tx = {0}; ck_assert_int_eq(decode_tx(encoded_tx, sizeof(encoded_tx), &tx), 1); ck_assert_int_eq(tx.amount, 10000); ck_assert_int_eq(tx.fee, 100); } END_TEST START_TEST(test_protobuf_medium) { const uint8_t const encoded_tx[] = {0x0a, 0x14, 0x62, 0x20, 0xef, 0xa7, 0xb2, 0xbd, 0x85, 0x50, 0xc3, 0x3d, 0xa0, 0x79, 0x6c, 0x77, 0x91, 0x70, 0xd3, 0xfb, 0x9d, 0xc2, 0x12, 0x14, 0xe1, 0x61, 0x12, 0x4d, 0x4a, 0xa4, 0x1c, 0xa0, 0xdf, 0x6b, 0xaf, 0xec, 0xb0, 0x40, 0x89, 0x71, 0xcf, 0xf6, 0xc0, 0x96, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x00}; hycon_tx tx = {0}; ck_assert_int_eq(decode_tx(encoded_tx, sizeof(encoded_tx), &tx), 1); ck_assert_int_eq(tx.amount, 10); ck_assert_int_eq(tx.fee, 1); } END_TEST START_TEST(test_protobuf_large) { const uint8_t const encoded_tx[] = {0x0a, 0x14, 0xe7, 0xbc, 0x78, 0x74, 0xee, 0xbe, 0x21, 0xbb, 0x46, 0x08, 0xf4, 0xb6, 0xb5, 0xd5, 0x2e, 0x29, 0xab, 0x8f, 0xd6, 0x01, 0x12, 0x14, 0xe1, 0x61, 0x12, 0x4d, 0x4a, 0xa4, 0x1c, 0xa0, 0xdf, 0x6b, 0xaf, 0xec, 0xb0, 0x40, 0x89, 0x71, 0xcf, 0xf6, 0xc0, 0x96, 0x18, 0x95, 0xbe, 0xc1, 0xe6, 0xba, 0xe9, 0xa6, 0xdb, 0x01, 0x20, 0x95, 0xbe, 0xc1, 0xe6, 0xba, 0xe9, 0xa6, 0xdb, 0x01, 0x28, 0x95, 0x9a, 0xef, 0x3a}; hycon_tx tx = {0}; ck_assert_int_eq(decode_tx(encoded_tx, sizeof(encoded_tx), &tx), 1); ck_assert_int_eq(tx.amount, 123456789123456789); ck_assert_int_eq(tx.fee, 123456789123456789); } END_TEST START_TEST(test_decode_varint_small) { uint8_t skip_bytes; uint64_t decoded_amount; uint8_t encoded_amount_small[] = {0x90, 0x4e}; decoded_amount = decode_varint(encoded_amount_small, &skip_bytes); ck_assert_int_eq(decoded_amount, 10000); uint8_t encoded_amount_medium[] = {0x95, 0xbe, 0xc3, 0x8b, 0xa8, 0xee, 0x67}; decoded_amount = decode_varint(encoded_amount_medium, &skip_bytes); ck_assert_int_eq(decoded_amount, 456789123456789); } END_TEST START_TEST(test_decode_varint_medium) { uint8_t skip_bytes; uint64_t decoded_amount; uint8_t encoded_amount_medium[] = {0x95, 0xbe, 0xc3, 0x8b, 0xa8, 0xee, 0x67}; decoded_amount = decode_varint(encoded_amount_medium, &skip_bytes); ck_assert_int_eq(decoded_amount, 456789123456789); } END_TEST START_TEST(test_decode_varint_large) { uint8_t skip_bytes; uint64_t decoded_amount; uint8_t encoded_amount_medium[] = {0x95, 0xbe, 0xc1, 0xe6, 0xba, 0xe9, 0xa6, 0xdb, 0x01}; decoded_amount = decode_varint(encoded_amount_medium, &skip_bytes); ck_assert_int_eq(decoded_amount, 123456789123456789); } END_TEST Suite *hash_suite(void) { Suite *s; TCase *tc_1, *tc_2; s = suite_create("Protobuf"); tc_1 = tcase_create("Encoded Tx"); tcase_add_checked_fixture(tc_1, setup, teardown); tcase_add_test(tc_1, test_protobuf_small); tcase_add_test(tc_1, test_protobuf_medium); tcase_add_test(tc_1, test_protobuf_large); tc_2 = tcase_create("Decode varint"); tcase_add_checked_fixture(tc_2, setup, teardown); tcase_add_test(tc_2, test_decode_varint_small); tcase_add_test(tc_2, test_decode_varint_medium); tcase_add_test(tc_2, test_decode_varint_large); suite_add_tcase(s, tc_1); suite_add_tcase(s, tc_2); return s; } int main() { int number_failed; Suite *s; SRunner *sr; s = hash_suite(); sr = srunner_create(s); srunner_run_all(sr, CK_NORMAL); number_failed = srunner_ntests_failed(sr); srunner_free(sr); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; }
27.586957
78
0.731284
d483070a3becd55ffb87afa32ed10dc8cf557368
1,016
h
C
gpio_demo_frdmk64f/main.h
0xc0170/kinetis_klxx_gcc_pgen
62e457bcb63376ae19dffed1dd68867b3096f874
[ "Apache-2.0" ]
null
null
null
gpio_demo_frdmk64f/main.h
0xc0170/kinetis_klxx_gcc_pgen
62e457bcb63376ae19dffed1dd68867b3096f874
[ "Apache-2.0" ]
null
null
null
gpio_demo_frdmk64f/main.h
0xc0170/kinetis_klxx_gcc_pgen
62e457bcb63376ae19dffed1dd68867b3096f874
[ "Apache-2.0" ]
null
null
null
/* * Copyright (c) 12.2013, Martin Kojtal (0xc0170) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MAIN_H #define MAIN_H #if defined (__cplusplus) extern "C" { #endif /** * \brief LED1 Toggle with a delay * \param void * \return void */ int main(void); /** * \brief Silly delay * \param void * \return void */ void delay(void); /** * \brief Button and LED initialization * \param void * \return void */ void gpio_init_(void); #if defined (__cplusplus) } #endif #endif
20.734694
75
0.695866
81d67258d014652528cf512553f6399ff8d538a2
1,401
h
C
esp32/blekb2qmk.h
zinziroge/split_keyboard
2f858bf4fc877bcf7a9f9fe960e6acbf3ace6792
[ "MIT" ]
null
null
null
esp32/blekb2qmk.h
zinziroge/split_keyboard
2f858bf4fc877bcf7a9f9fe960e6acbf3ace6792
[ "MIT" ]
null
null
null
esp32/blekb2qmk.h
zinziroge/split_keyboard
2f858bf4fc877bcf7a9f9fe960e6acbf3ace6792
[ "MIT" ]
null
null
null
#pragma once ////BleKeyboard name -> QMK name #include <BleKeyboard.h> #if 0 /* modifiers key はコードが違うので合わせる */ /* QMK BleKeyboard */ /* 0xE0 0x80 */ #define KC_LCTL KEY_LEFT_CTRL #define KC_LSFT KEY_LEFT_SHIFT #define KC_LALT KEY_LEFT_ALT #define KC_LGUI KEY_LEFT_GUI #define KC_RCTL KEY_RIGHT_CTRL #define KC_RSFT KEY_RIGHT_SHIFT #define KC_RALT KEY_RIGHT_ALT #define KC_RGUI KEY_RIGHT_GUI /* 0xDA */ #define KC_UP KEY_UP_ARROW #define KC_DOWN KEY_DOWN_ARROW #define KC_LEFT KEY_LEFT_ARROW #define KC_RGHT KEY_RIGHT_ARROW #define KC_BSPC KEY_BACKSPACE #define KC_TAB KEY_TAB #define KC_ENT KEY_RETURN #define KC_ESC KEY_ESC #define KC_INS KEY_INSERT #define KC_DEL KEY_DELETE #define KC_PGUP KEY_PAGE_UP #define KC_PGDN KEY_PAGE_DOWN #define KC_HOME KEY_HOME #define KC_END KEY_END #define KC_CAPS KEY_CAPS_LOCK #define KC_F1 KEY_F1 #define KC_F2 KEY_F2 #define KC_F3 KEY_F3 #define KC_F4 KEY_F4 #define KC_F5 KEY_F5 #define KC_F6 KEY_F6 #define KC_F7 KEY_F7 #define KC_F8 KEY_F8 #define KC_F9 KEY_F9 #define KC_FC10 KEY_F10 #define KC_FC11 KEY_F11 #define KC_FC12 KEY_F12 #define KC_FC13 KEY_F13 #define KC_FC14 KEY_F14 #define KC_FC15 KEY_F15 #define KC_FC16 KEY_F16 #define KC_FC17 KEY_F17 #define KC_FC18 KEY_F18 #define KC_FC19 KEY_F19 #define KC_FC20 KEY_F20 #define KC_FC21 KEY_F21 #define KC_FC22 KEY_F22 #define KC_FC23 KEY_F23 #define KC_FC24 KEY_F24 #endif
22.967213
33
0.802284
81e2138f4ab12102a82eb06cda55b86f3ec74b5c
301
h
C
includes/okra/config.h
fpascutti/okra
e4ebf13cd047be48988c541078bbdfd9220a508d
[ "BSL-1.0" ]
null
null
null
includes/okra/config.h
fpascutti/okra
e4ebf13cd047be48988c541078bbdfd9220a508d
[ "BSL-1.0" ]
1
2016-12-07T12:03:00.000Z
2016-12-07T12:03:00.000Z
includes/okra/config.h
fpascutti/okra
e4ebf13cd047be48988c541078bbdfd9220a508d
[ "BSL-1.0" ]
null
null
null
#ifndef OKRA_CONFIG_H #define OKRA_CONFIG_H // Copyright Franck Pascutti 2016-2017. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include <okra/compiler_detection.h> #endif // OKRA_CONFIG_H
27.363636
90
0.780731
373921b93cb4b076b4a7cde105830e87b2c357d9
521
h
C
SBD2/record.h
rubikshift/SBD_2
03f031bfaf5225d94320d7cd525e0bd2fc864791
[ "MIT" ]
null
null
null
SBD2/record.h
rubikshift/SBD_2
03f031bfaf5225d94320d7cd525e0bd2fc864791
[ "MIT" ]
null
null
null
SBD2/record.h
rubikshift/SBD_2
03f031bfaf5225d94320d7cd525e0bd2fc864791
[ "MIT" ]
null
null
null
#pragma once #include <limits> #include <iostream> struct Record { Record(int key = 0, double v = UNINIT, double m = UNINIT); // v == UNINIT or m == UNINIT => uninitialized record bool isInitialized() const; int key, ptr; double v, m; static constexpr const double UNINIT = -1 * std::numeric_limits<double>::infinity(); static const int NO_PTR = -1; static const unsigned int RECORD_SIZE = sizeof(v) + sizeof(m) + sizeof(key) + sizeof(ptr); }; std::ostream& operator<<(std::ostream& os, const Record& record);
27.421053
113
0.690979
69627313a572872d1b44d741270a2ec9c4e5e70b
1,335
c
C
protocol/z-wave/Apps/SerialAPI/cmd_get_capabilities.c
SiliconLabs/gecko_sdk
310814a9016b60a8012d50c62cc168a783ac102b
[ "Zlib" ]
69
2021-12-16T01:34:09.000Z
2022-03-31T08:27:39.000Z
protocol/z-wave/Apps/SerialAPI/cmd_get_capabilities.c
SiliconLabs/gecko_sdk
310814a9016b60a8012d50c62cc168a783ac102b
[ "Zlib" ]
6
2022-01-12T18:22:08.000Z
2022-03-25T10:19:27.000Z
protocol/z-wave/Apps/SerialAPI/cmd_get_capabilities.c
SiliconLabs/gecko_sdk
310814a9016b60a8012d50c62cc168a783ac102b
[ "Zlib" ]
21
2021-12-20T09:05:45.000Z
2022-03-28T02:52:28.000Z
/** * @file * @copyright 2022 Silicon Laboratories Inc. */ #include <stdint.h> #include "cmd_handlers.h" #include "config_app.h" #include "serialappl.h" #define CAPABILITIES_SIZE (8 + 32) // Info + supported commands static uint8_t SERIALAPI_CAPABILITIES[CAPABILITIES_SIZE] = { APP_VERSION, APP_REVISION, SERIALAPI_MANUFACTURER_ID1, SERIALAPI_MANUFACTURER_ID2, SERIALAPI_MANUFACTURER_PRODUCT_TYPE1, SERIALAPI_MANUFACTURER_PRODUCT_TYPE2, SERIALAPI_MANUFACTURER_PRODUCT_ID1, SERIALAPI_MANUFACTURER_PRODUCT_ID2 }; static bool add_cmd_to_capabilities(cmd_handler_map_t const * const p_cmd_entry, cmd_context_t context) { ZW_NodeMaskSetBit(context, p_cmd_entry->cmd); return false; } ZW_ADD_CMD(FUNC_ID_SERIAL_API_GET_CAPABILITIES) { cmd_foreach(add_cmd_to_capabilities, &SERIALAPI_CAPABILITIES[8]); /* HOST->ZW: no params defined */ /* ZW->HOST: RES | 0x07 | */ /* SERIAL_APPL_VERSION | SERIAL_APPL_REVISION | SERIALAPI_MANUFACTURER_ID1 | SERIALAPI_MANUFACTURER_ID2 | */ /* SERIALAPI_MANUFACTURER_PRODUCT_TYPE1 | SERIALAPI_MANUFACTURER_PRODUCT_TYPE2 | */ /* SERIALAPI_MANUFACTURER_PRODUCT_ID1 | SERIALAPI_MANUFACTURER_PRODUCT_ID2 | FUNCID_SUPPORTED_BITMASK[] */ Respond(frame->cmd, SERIALAPI_CAPABILITIES, sizeof(SERIALAPI_CAPABILITIES)); }
34.230769
112
0.763296
da427af07ba8be012f9ccef4d3237ce6b62d8a47
4,225
h
C
myy601l2/config.h
sageorgisn/601l2
4b5c928d849d4dbd9c34b9547372c19efb156355
[ "MIT" ]
null
null
null
myy601l2/config.h
sageorgisn/601l2
4b5c928d849d4dbd9c34b9547372c19efb156355
[ "MIT" ]
null
null
null
myy601l2/config.h
sageorgisn/601l2
4b5c928d849d4dbd9c34b9547372c19efb156355
[ "MIT" ]
null
null
null
#ifndef _CONFIG_H #define _CONFIG_H /* Minix release and version numbers. */ #define OS_RELEASE "3" #define OS_VERSION "2.0" /* This file sets configuration parameters for the MINIX kernel, FS, and PM. * It is divided up into two main sections. The first section contains * user-settable parameters. In the second section, various internal system * parameters are set based on the user-settable parameters. * * Parts of config.h have been moved to sys_config.h, which can be included * by other include files that wish to get at the configuration data, but * don't want to pollute the users namespace. Some editable values have * gone there. * */ /* The MACHINE (called _MINIX_MACHINE) setting can be done * in <minix/machine.h>. */ #include <minix/sys_config.h> #define MACHINE _MINIX_MACHINE #define IBM_PC _MACHINE_IBM_PC /* Number of slots in the process table for non-kernel processes. The number * of system processes defines how many processes with special privileges * there can be. User processes share the same properties and count for one. * * These can be changed in sys_config.h. */ #define NR_PROCS _NR_PROCS #define NR_SYS_PROCS _NR_SYS_PROCS #define NR_SYS_CHUNKS BITMAP_CHUNKS(NR_SYS_PROCS) /* Number of controller tasks (/dev/cN device classes). */ #define NR_CTRLRS 2 /* DMA_SECTORS may be increased to speed up DMA based drivers. */ #define DMA_SECTORS 1 /* DMA buffer size (must be >= 1) */ /* Which processes should receive diagnostics from the kernel and system? * Directly sending it to TTY only displays the output. Sending it to the * log driver will cause the diagnostics to be buffered and displayed. * Messages are sent by src/lib/sysutil/kputc.c to these processes, in * the order of this array, which must be terminated by NONE. This is used * by drivers and servers that printf(). * The kernel does this for its own kprintf() in kernel/utility.c, also using * this array, but a slightly different mechanism. */ #define OUTPUT_PROCS_ARRAY { TTY_PROC_NR, LOG_PROC_NR, NONE } /* NR_CONS, NR_RS_LINES, and NR_PTYS determine the number of terminals the * system can handle. */ #define NR_CONS 4 /* # system consoles (1 to 8) */ #define NR_RS_LINES 4 /* # rs232 terminals (0 to 4) */ #define NR_PTYS 32 /* # pseudo terminals (0 to 64) */ /* This feature enable the counting of system calls in PM and FS */ #define ENABLE_SYSCALL_STATS 0 /* Max. number of I/O ranges that can be assigned to a process */ #define NR_IO_RANGE 64 /* Max. number of device memory ranges that can be assigned to a process */ #define NR_MEM_RANGE 20 /* Max. number of IRQs that can be assigned to a process */ #define NR_IRQ 8 /* Scheduling priorities. Values must start at zero (highest * priority) and increment. */ #define NR_SCHED_QUEUES 9 /* MUST equal minimum priority + 1 */ #define TASK_Q 0 /* highest, used for kernel tasks */ #define MAX_USER_Q 0 /* highest priority for user processes */ #define USER_Q 7 #define MIN_USER_Q (NR_SCHED_QUEUES - 1) /* minimum priority for user processes */ /* default scheduling quanta */ #define USER_QUANTUM 200 /* defualt user process cpu */ #define USER_DEFAULT_CPU -1 /* use the default cpu or do not change the current one */ /*===========================================================================* * There are no user-settable parameters after this line * *===========================================================================*/ /* Set the FP_FORMAT type based on the machine selected, either hw or sw */ #define FP_NONE _FP_NONE /* no floating point support */ #define FP_IEEE _FP_IEEE /* conform IEEE floating point standard */ /* _MINIX_FP_FORMAT is defined in sys_config.h. */ #define FP_FORMAT _MINIX_FP_FORMAT /* _ASKDEV and _FASTLOAD are defined in sys_config.h. */ #define ASKDEV _ASKDEV #define FASTLOAD _FASTLOAD /* Enable or disable system profiling. */ #define SPROFILE 0 /* statistical profiling */ #define CPROFILE 0 /* call profiling */ /* PCI configuration parameters */ #define NR_PCIBUS 40 #define NR_PCIDEV 50 #endif /* _CONFIG_H */
36.422414
79
0.691361
fb7ff7c096feda47ffff422dc9555ef91d641858
1,807
c
C
tracker.c
t6/simplestrok
7fd705b315b244b3b912d9d17b8afbf87878fcac
[ "0BSD" ]
1
2019-09-16T20:26:24.000Z
2019-09-16T20:26:24.000Z
tracker.c
t6/simplestrok
7fd705b315b244b3b912d9d17b8afbf87878fcac
[ "0BSD" ]
1
2020-05-22T09:09:59.000Z
2020-05-22T17:15:51.000Z
tracker.c
t6/simplestroke
7fd705b315b244b3b912d9d17b8afbf87878fcac
[ "0BSD" ]
null
null
null
/* * Copyright (c) 2019 Tobias Kortkamp <t@tobik.me> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "config.h" #if HAVE_ERR # include <err.h> #endif #include <sys/wait.h> #include <unistd.h> #include "tracker.h" static const char *command; static void tracker_run_command_internal(void); #if HAVE_EVDEV #include "tracker_evdev.c" #endif void tracker_init(const char *command_) { command = command_; #if HAVE_EVDEV if (!evdev_init()) #endif errx(1, "failed to initialize mouse tracker"); } int tracker_record_stroke(struct stroke *stroke) { if (stroke != NULL) { memset(stroke, 0, sizeof(struct stroke)); } #if HAVE_EVDEV if (!evdev_record_stroke(stroke)) #endif return 0; return 1; } void tracker_run_command() { #if HAVE_CAPSICUM && HAVE_EVDEV evdev_run_command(); #else tracker_run_command_internal(); #endif } static void tracker_run_command_internal() { pid_t child = fork(); if (child == 0) { execlp(command, command, NULL); err(1, "execlp"); } else if (child == -1) { err(1, "fork"); } int status; if (waitpid(child, &status, 0) == -1) { err(1, "waitpid"); } }
21.258824
79
0.721085
d3117a81fbc78cc2a4150389799ed26f4776f51f
861
h
C
MCObserverKit/MCObserverKit.h
MC-Studio/MCObserverKit
6ee229c928ec141e1d15774be98986953cc1b261
[ "MIT" ]
1
2020-09-28T13:53:33.000Z
2020-09-28T13:53:33.000Z
MCObserverKit/MCObserverKit.h
BinaryParadise/MCObserverKit
6ee229c928ec141e1d15774be98986953cc1b261
[ "MIT" ]
1
2018-11-16T14:03:53.000Z
2018-11-17T03:32:20.000Z
MCObserverKit/MCObserverKit.h
MC-Studio/MCObserverKit
6ee229c928ec141e1d15774be98986953cc1b261
[ "MIT" ]
null
null
null
// // MCObserverKit.h // // Created by Rake Yang on 17/2/9. // Copyright © 2017年 BinaryParadise. All rights reserved. // /** 对象KVO快速注册关联,单利模式请手动移除观察者 */ #import <MCFoundation/MCFoundation.h> #import "MOKBinding.h" #define MCBinding(TARGET, ...) \ macro_if_eq(1, macro_argcount(__VA_ARGS__))(_OKit_(TARGET, __VA_ARGS__))(_OKit_(TARGET, __VA_ARGS__)) #define _OKit_(TARGET, KEYPATH) \ [[MOKBinding alloc] initWithTarget:(TARGET)][@keypath(TARGET, KEYPATH)] #define MCObserver(TARGET, KEYPATH) \ [[MOKObject alloc] initWithTarget:TARGET keyPath:@keypath(TARGET, KEYPATH) mode:MOKBindingModeNone] #define MCObserverCC(TARGET, KEYPATH) \ [[MOKObject alloc] initWithTarget:TARGET keyPath:@keypath(TARGET, KEYPATH) mode:MOKBindingModeReversible] @interface MCObserverKit : NSObject /** 调试模式 */ @property (class, nonatomic, assign) BOOL debugMode; @end
24.6
105
0.751452
1c7dfaf1e5d1a071a36709387469fd7243818830
336
c
C
install_dependencies/xianyi-OpenBLAS-6d2da63/interface/CMakeFiles/cblas_dspr2.c
lanl/DnMFkCPP
a6bca290bf7d57be07f7a80d049d6b7714fbdc61
[ "BSD-3-Clause", "Unlicense" ]
1
2021-07-29T21:56:02.000Z
2021-07-29T21:56:02.000Z
install_dependencies/xianyi-OpenBLAS-6d2da63/interface/CMakeFiles/cblas_dspr2.c
rvangara/DnMFk
a6bca290bf7d57be07f7a80d049d6b7714fbdc61
[ "BSD-3-Clause", "Unlicense" ]
null
null
null
install_dependencies/xianyi-OpenBLAS-6d2da63/interface/CMakeFiles/cblas_dspr2.c
rvangara/DnMFk
a6bca290bf7d57be07f7a80d049d6b7714fbdc61
[ "BSD-3-Clause", "Unlicense" ]
2
2021-07-29T21:55:33.000Z
2021-08-02T21:30:15.000Z
#define CBLAS #define ASMNAME cblas_dspr2 #define ASMFNAME cblas_dspr2_ #define NAME cblas_dspr2_ #define CNAME cblas_dspr2 #define CHAR_NAME "cblas_dspr2_" #define CHAR_CNAME "cblas_dspr2" #define DOUBLE #include "/lustre/scratch3/turquoise/rvangara/RD100/distnnmfkcpp_Src/install_dependencies/xianyi-OpenBLAS-6d2da63/interface/spr2.c"
37.333333
131
0.848214
46f7d90da57d2cb7d15cee8c60614a49a832e955
3,446
c
C
openair2/LAYER2/rlc_v2/asn1_utils.c
shadansari/onos-cu-cp
16cbf4828bd11e4c7319e7a009a26b6f39fde628
[ "Apache-2.0" ]
6
2019-12-27T00:55:47.000Z
2021-11-16T11:36:20.000Z
openair2/LAYER2/rlc_v2/asn1_utils.c
shadansari/onos-cu-cp
16cbf4828bd11e4c7319e7a009a26b6f39fde628
[ "Apache-2.0" ]
2
2021-06-17T05:01:55.000Z
2021-11-24T14:23:54.000Z
openair2/LAYER2/rlc_v2/asn1_utils.c
shadansari/onos-cu-cp
16cbf4828bd11e4c7319e7a009a26b6f39fde628
[ "Apache-2.0" ]
15
2019-12-27T00:55:51.000Z
2022-03-28T02:13:45.000Z
/* * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The OpenAirInterface Software Alliance licenses this file to You under * the OAI Public License, Version 1.1 (the "License"); you may not use this file * except in compliance with the License. * You may obtain a copy of the License at * * http://www.openairinterface.org/?page_id=698 * * 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. *------------------------------------------------------------------------------- * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org */ #include "rlc.h" int decode_t_reordering(int v) { static int tab[32] = { 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 1600 }; if (v < 0 || v > 31) { LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); exit(1); } return tab[v]; } int decode_t_status_prohibit(int v) { static int tab[62] = { 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200, 205, 210, 215, 220, 225, 230, 235, 240, 245, 250, 300, 350, 400, 450, 500, 800, 1000, 1200, 1600, 2000, 2400 }; if (v < 0 || v > 61) { LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); exit(1); } return tab[v]; } int decode_t_poll_retransmit(int v) { static int tab[59] = { 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200, 205, 210, 215, 220, 225, 230, 235, 240, 245, 250, 300, 350, 400, 450, 500, 800, 1000, 2000, 4000 }; if (v < 0 || v > 58) { LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); exit(1); } return tab[v]; } int decode_poll_pdu(int v) { static int tab[8] = { 4, 8, 16, 32, 64, 128, 256, -1 /* -1 means infinity */ }; if (v < 0 || v > 7) { LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); exit(1); } return tab[v]; } int decode_poll_byte(int v) { static int tab[15] = { 25, 50, 75, 100, 125, 250, 375, 500, 750, 1000, 1250, 1500, 2000, 3000, -1 /* -1 means infinity */ }; if (v < 0 || v > 14) { LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); exit(1); } if (tab[v] == -1) return -1; return tab[v] * 1024; } int decode_max_retx_threshold(int v) { static int tab[8] = { 1, 2, 3, 4, 6, 8, 16, 32 }; if (v < 0 || v > 7) { LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); exit(1); } return tab[v]; } int decode_sn_field_length(int v) { static int tab[2] = { 5, 10 }; if (v < 0 || v > 1) { LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); exit(1); } return tab[v]; }
26.507692
82
0.587928
208b0c5493748c2cfed99c4f9fe13911071f1664
240
c
C
cmake/try_compile/HAVE_PWRITEV.c
rtchack/utils_cmake
2e37f45696b8d256b42b47c2474194c94657956b
[ "MIT" ]
null
null
null
cmake/try_compile/HAVE_PWRITEV.c
rtchack/utils_cmake
2e37f45696b8d256b42b47c2474194c94657956b
[ "MIT" ]
null
null
null
cmake/try_compile/HAVE_PWRITEV.c
rtchack/utils_cmake
2e37f45696b8d256b42b47c2474194c94657956b
[ "MIT" ]
null
null
null
/* * Created by Meissa project team in 2020. */ #include <sys/uio.h> int main() { char buf[1]; struct iovec vec[1]; ssize_t n; vec[0].iov_base = buf; vec[0].iov_len = 1; n = pwritev(1, vec, 1, 0); if (n == -1) return 1; }
13.333333
42
0.566667
5a2476c2be5a3d36061c433d8b460bbbef333079
456
h
C
include/ashm.h
PavelAtr/android-shm
7792279ee174a67e68f9eee277b7febcd12b0fc0
[ "BSD-2-Clause" ]
null
null
null
include/ashm.h
PavelAtr/android-shm
7792279ee174a67e68f9eee277b7febcd12b0fc0
[ "BSD-2-Clause" ]
null
null
null
include/ashm.h
PavelAtr/android-shm
7792279ee174a67e68f9eee277b7febcd12b0fc0
[ "BSD-2-Clause" ]
null
null
null
#include <sys/types.h> #include <stddef.h> #ifdef __cplusplus extern "C" { #endif int shm_init(); //Used only by parent process int shm_open(const char *name, int oflag, mode_t mode); int shm_unlink(const char *name); void* shm_mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset); extern int shm_ftruncate(int fd, off_t length); extern int shm_close(int fd); int reset_cloexec(int fd); #ifdef __cplusplus } #endif
20.727273
62
0.714912
5a281c1585019192ce37ba71c65e1ff7687f228b
9,962
c
C
src/graphics/model.c
ten3roberts/cuttle
b4b828c2fdace5e54c8f4806b32cc78b8d40cc85
[ "BSD-3-Clause" ]
2
2020-12-14T15:58:13.000Z
2021-12-29T13:20:47.000Z
src/graphics/model.c
ten3roberts/cuttle
b4b828c2fdace5e54c8f4806b32cc78b8d40cc85
[ "BSD-3-Clause" ]
1
2020-06-13T09:14:43.000Z
2020-06-13T09:14:43.000Z
src/graphics/model.c
ten3roberts/cuttle
b4b828c2fdace5e54c8f4806b32cc78b8d40cc85
[ "BSD-3-Clause" ]
null
null
null
#include "graphics/model.h" #include "utils.h" #include "graphics/vertexbuffer.h" #include "graphics/indexbuffer.h" #include "xmlparser.h" #include "log.h" #include "utils.h" #include "hashtable.h" hashtable_t* model_table = NULL; struct Mesh { // The mesh id char name[256]; VertexBuffer* vb; IndexBuffer* ib; uint32_t index_count; uint32_t vertex_count; float max_distance; Model* model_parent; }; struct Model { // The filename without extension char name[256]; Mesh** meshes; uint32_t mesh_count; }; struct Face { uint32_t pos_index, normal_index, uv_index; }; void model_load_collada(const char* filepath) { LOG("Loading model %s", filepath); XMLNode* root = xml_loadfile(filepath); if (root == NULL) { LOG_E("Failed to open COLLADA model file %s", filepath); return; } Model* model = malloc(sizeof(Model)); model->meshes = NULL; model->mesh_count = 0; // Load the name from the filename get_filename(filepath, model->name, sizeof model->name); // Insert into table // Create table if it doesn't exist if (model_table == NULL) { model_table = hashtable_create_string(); } // Insert material into tracking table after name is acquired if (hashtable_find(model_table, model->name) != NULL) { LOG_W("Duplicate model %s", model->name); model_destroy(model); return; } // Insert into table hashtable_insert(model_table, model->name, model); XMLNode* lib_geometries = xml_get_child(root, "library_geometries"); XMLNode* geometries = xml_get_children(lib_geometries); XMLNode* xml_up_axis = xml_get_child(xml_get_child(root, "asset"), "up_axis"); vec3 (*axis_swap)(vec3) = vec3_swap_identity; if (xml_up_axis) { const char* up_axis = xml_get_content(xml_up_axis); if (strcmp(up_axis, "Z_UP") == 0) axis_swap = vec3_swap_yz; if (strcmp(up_axis, "X_UP") == 0) axis_swap = vec3_swap_xy; } // Load all meshes/geometries while (geometries) { const char* name = xml_get_attribute(geometries, "name"); const char* id = xml_get_attribute(geometries, "id"); size_t id_len = strlen(id); XMLNode* xml_mesh = xml_get_child(geometries, "mesh"); geometries = xml_get_next(geometries); // Load the sources XMLNode* sources = xml_get_children(xml_mesh); XMLNode* triangles_node = xml_get_child(xml_mesh, "triangles"); char* source_names[3]; source_names[0] = malloc(id_len + strlen("-positions") + 1); memcpy(source_names[0], id, strlen(id) + 1); strcat(source_names[0], "-positions"); source_names[1] = malloc(id_len + strlen("-map-0") + 1); memcpy(source_names[1], id, strlen(id) + 1); strcat(source_names[1], "-map-0"); source_names[2] = malloc(id_len + strlen("-normals") + 1); memcpy(source_names[2], id, strlen(id) + 1); strcat(source_names[2], "-normals"); float* positions = NULL; float* uvs = NULL; float* normals = NULL; // Load all sources while (sources != NULL) { char* attribute = xml_get_attribute(sources, "id"); if (attribute == NULL) { sources = xml_get_next(sources); continue; }; // Positions if (strcmp(attribute, source_names[0]) == 0) { XMLNode* array = xml_get_child(sources, "float_array"); uint32_t count = atoi(xml_get_attribute(array, "count")); positions = malloc(count * sizeof(*positions)); char* cont = xml_get_content(array); for (uint32_t i = 0; i < count; i++) { positions[i] = atof(cont); cont = strchr(cont + 1, ' '); } } // Uvs else if (strcmp(attribute, source_names[1]) == 0) { XMLNode* array = xml_get_child(sources, "float_array"); uint32_t count = atoi(xml_get_attribute(array, "count")); uvs = malloc(count * sizeof(*uvs)); char* cont = xml_get_content(array); for (uint32_t i = 0; i < count; i++) { uvs[i] = atof(cont); cont = strchr(cont + 1, ' '); } } // Normals if (strcmp(attribute, source_names[2]) == 0) { XMLNode* array = xml_get_child(sources, "float_array"); uint32_t count = atoi(xml_get_attribute(array, "count")); normals = malloc(count * sizeof(*normals)); char* cont = xml_get_content(array); for (uint32_t i = 0; i < count; i++) { normals[i] = atof(cont); cont = strchr(cont + 1, ' '); } } sources = xml_get_next(sources); } free(source_names[0]); free(source_names[1]); free(source_names[2]); // Check what got loaded if (positions == NULL) { LOG_W("Mesh %s:%s contains no vertex position data", model->name, name); } if (normals == NULL) { LOG_W("Mesh %s:%s contains no normal data", model->name, name); } if (uvs == NULL) { LOG_W("Mesh %s:%s contains no uv data", model->name, name); } // Triangles // How many sets there are, each set contains 3 ints uint32_t triangle_count = atoi(xml_get_attribute(triangles_node, "count")); char* triangle_cont = xml_get_content(xml_get_child(triangles_node, "p")); // Max number of sets expected // Three vertices per face // A set describes the index of the set of positions, normals, and uvs struct Face* sets = malloc(triangle_count * sizeof(struct Face) * 3); uint32_t set_count = 0; // Max number of indices expected if no reusage uint32_t* indices = malloc(triangle_count * sizeof(uint32_t) * 3); uint32_t index_count = 0; for (uint32_t i = 0; i < triangle_count * 3; i++) { uint32_t pos_index = atoi(triangle_cont); triangle_cont = strchr(triangle_cont + 1, ' '); uint32_t normal_index = atoi(triangle_cont); triangle_cont = strchr(triangle_cont + 1, ' '); uint32_t uv_index = atoi(triangle_cont); triangle_cont = strchr(triangle_cont + 1, ' '); int found = 0; for (uint32_t j = 0; j < 1; j++) { // Already existing pair found if (sets[j].pos_index == pos_index && sets[j].uv_index == uv_index) { // Reuse index indices[index_count++] = j; found = 1; LOG("Reusing index"); break; } } if (!found) { // Add new unique index indices[index_count++] = set_count; sets[set_count++] = (struct Face){pos_index, normal_index, uv_index}; } } // Create the vertices Vertex* vertices = malloc(set_count * sizeof(Vertex)); // Loop through all unique faces for (uint32_t i = 0; i < set_count; i++) { // Construct the vertex and swap axes to get the correct up axis vertices[i].position = axis_swap(*(vec3*)&positions[3 * sets[i].pos_index]); vertices[i].uv = *(vec2*)&uvs[2 * sets[i].uv_index]; } Mesh* mesh = mesh_create(name, vertices, set_count, indices, index_count); model_add_mesh(model, mesh); free(positions); free(uvs); free(normals); free(sets); free(indices); free(vertices); } xml_destroy(root); } Mesh* mesh_create(const char* name, Vertex* vertices, uint32_t vertex_count, uint32_t* indices, uint32_t index_count) { Mesh* mesh = malloc(sizeof(Mesh)); snprintf(mesh->name, sizeof mesh->name, "%s", name); mesh->max_distance = 0; // Find max distance for (uint32_t i = 0; i < vertex_count; i++) { if (vec3_sqrmag(vertices[i].position) > mesh->max_distance * mesh->max_distance) { mesh->max_distance = vec3_mag(vertices[i].position); } } mesh->vb = vb_create(vertices, vertex_count); mesh->ib = ib_create(indices, index_count); mesh->index_count = index_count; mesh->vertex_count = vertex_count; mesh->model_parent = NULL; return mesh; } Model* model_get(const char* name) { // No materials loaded if (model_table == NULL) return NULL; return hashtable_find(model_table, name); } Mesh* model_get_mesh(Model* model, uint32_t index) { if (index >= model->mesh_count) { return NULL; } return model->meshes[index]; } Mesh* model_find_mesh(Model* model, const char* name) { for (uint32_t i = 0; i < model->mesh_count; i++) { if (strcmp(model->meshes[i]->name, name) == 0) { return model->meshes[i]; } } return NULL; } // Adds a mesh to a model void model_add_mesh(Model* model, Mesh* mesh) { model->meshes = realloc(model->meshes, ++model->mesh_count * sizeof(Mesh*)); model->meshes[model->mesh_count - 1] = mesh; mesh->model_parent = model; } void model_destroy(Model* model) { // Remove from table if it exists hashtable_remove(model_table, model->name); // Last texture was removed if (hashtable_get_count(model_table) == 0) { hashtable_destroy(model_table); model_table = NULL; } for (uint32_t i = 0; i < model->mesh_count; i++) { mesh_destroy(model->meshes[i]); } free(model->meshes); model->mesh_count = 0; free(model); } void model_destroy_all() { Model* model = NULL; while (model_table && (model = hashtable_pop(model_table))) { model_destroy(model); } } void mesh_bind(Mesh* mesh, Commandbuffer commandbuffer) { vb_bind(mesh->vb, commandbuffer); ib_bind(mesh->ib, commandbuffer); } void mesh_draw(Mesh* mesh, Commandbuffer commandbuffer) { vkCmdDrawIndexed(commandbuffer_vk(commandbuffer), mesh->vertex_count, 1, 0, 0, 0); } float mesh_max_distance(Mesh* mesh) { return mesh->max_distance; } uint32_t mesh_get_index_count(Mesh* mesh) { return mesh->index_count; } uint32_t mesh_get_vertex_count(Mesh* mesh) { return mesh->vertex_count; } Mesh* mesh_find(const char* name) { char* delimiter = strchr(name, ':'); char modelname[256]; char meshname[256]; size_t len = sizeof modelname; len = delimiter ? (size_t)(delimiter - name + 1) : sizeof modelname; len = len > sizeof modelname ? sizeof modelname : len; snprintf(modelname, len, "%s", name); Model* model = model_get(modelname); if (model == NULL) { LOG_E("Unknown model %s", modelname); return NULL; } // Get first mesh if (delimiter == NULL) { return model_get_mesh(model, 0); } snprintf(meshname, sizeof meshname, "%s", delimiter + 1); Mesh* mesh = model_find_mesh(model, meshname); if (mesh == NULL) { LOG_E("Unknown mesh %s:%s", modelname, meshname); } return mesh; } void mesh_destroy(Mesh* mesh) { vb_destroy(mesh->vb); ib_destroy(mesh->ib); free(mesh); }
24.121065
117
0.669344
c6e1876bfe1855ba1e3e7a0ebf97a796d67b8d48
697
h
C
dOC/CommentViewDemo/CommentViewDemo/CommentView/supportFile/UITextView+CQAdd.h
MartinOSix/DemoKit
3d8c6267ef1782a2688fcf25dd2223595074c4ff
[ "Apache-2.0" ]
null
null
null
dOC/CommentViewDemo/CommentViewDemo/CommentView/supportFile/UITextView+CQAdd.h
MartinOSix/DemoKit
3d8c6267ef1782a2688fcf25dd2223595074c4ff
[ "Apache-2.0" ]
null
null
null
dOC/CommentViewDemo/CommentViewDemo/CommentView/supportFile/UITextView+CQAdd.h
MartinOSix/DemoKit
3d8c6267ef1782a2688fcf25dd2223595074c4ff
[ "Apache-2.0" ]
null
null
null
// // UITextView+CQAdd.h // CarServiceLeague // // Created by runo on 16/8/10. // Copyright © 2016年 com.runo. All rights reserved. // #import <UIKit/UIKit.h> @interface UITextView (CQAdd) /** * @author huangyibiao * * 给UITextView添加placeholder * * @note 注意,此扩展有点小问题,如果在添加placeholder后,又直接赋值Text属性,则不会自动消失 * 解决办法是:如果有初始值,先给text,再设置holder */ /** * 占位提示语 */ @property (nonatomic, copy) NSString *hdf_placeholder; /** * 占位提示语的字体颜色 */ @property (nonatomic, strong) UIColor *hdf_placeholderColor; /** * 占位提示语的字体 */ @property (nonatomic, strong) UIFont *hdf_placeholderFont; /** * 占位提示语标签 */ @property (nonatomic, strong, readonly) UILabel *hdf_placeholderLabel; @end
15.488889
70
0.688666
101bf23c9c461d4a950bd3a979886795a992e6b3
686
h
C
Userland/main_app/include/kernel_messages.h
matias-apablaza/arqui-tpe
328eb4b5dbe397557fbf9e98348bc469893a1978
[ "BSD-3-Clause" ]
null
null
null
Userland/main_app/include/kernel_messages.h
matias-apablaza/arqui-tpe
328eb4b5dbe397557fbf9e98348bc469893a1978
[ "BSD-3-Clause" ]
null
null
null
Userland/main_app/include/kernel_messages.h
matias-apablaza/arqui-tpe
328eb4b5dbe397557fbf9e98348bc469893a1978
[ "BSD-3-Clause" ]
null
null
null
/*--------------------------------------------------------------------------------------------------- | KERNEL_MESSAGES.H | | |---------------------- | | This file defines numbers that are used by the kernel to send messages to userspace apps. | ---------------------------------------------------------------------------------------------------*/ #define START 0 #define IRQ_PRODUCED 1 #define EXCEPTION_PRODUCED 2 #define TIMER_TICK_IRQ 0 #define KEYBOARD_IRQ 1 #define DIV_ZERO_EXCEPTION 0 #define INV_OPCODE_EXCEPTION 6
45.733333
101
0.345481
10411c1fd81edd99a2868538cca345f5cef05dba
5,093
h
C
Modules_Rebuild/to_string.h
IgarashiYuka/msp430f5529lp_workspace
09aa6c297330202c700fbc7bc1d8ad6da660ba15
[ "MIT" ]
null
null
null
Modules_Rebuild/to_string.h
IgarashiYuka/msp430f5529lp_workspace
09aa6c297330202c700fbc7bc1d8ad6da660ba15
[ "MIT" ]
null
null
null
Modules_Rebuild/to_string.h
IgarashiYuka/msp430f5529lp_workspace
09aa6c297330202c700fbc7bc1d8ad6da660ba15
[ "MIT" ]
null
null
null
/* * Author: YukaCR * Native C++ warpper for Arduino Streaming. */ #ifndef TO_STRING_H #define TO_STRING_H #include "stdlib.h" #include "stdint.h" #include "string.h" #define DEC 10 #define HEX 16 #define OCT 8 #define BIN 2 char* to_string(char data){ static char p_data[2]={0,0}; p_data[0]= data; return p_data; } inline char* to_string(const char* data){ return (char*)data; } inline char* to_string(char* data){ return data; } char* to_string(uint8_t n, int8_t base = 10) { static char buf[8 * sizeof(long) + 2]; // Assumes 8-bit chars plus zero byte. char *str= &buf[sizeof(buf) - 1]; bool neg_flag = 0; *str = '\0'; if (base == 0){return 0;} if (base < 2)base = 10; if (n < 0) { neg_flag = 1; n = -1 * n; } // prevent crash if called with base == 1 do { uint8_t m = n; n /= base; char c = m - base * n; *--str = c < 10 ? c + '0' : c + 'A' - 10; } while (n); if(neg_flag){*--str = '-';}; return str; } char* to_string(uint16_t n, int8_t base = 10) { static char buf[8 * sizeof(long) + 2]; // Assumes 8-bit chars plus zero byte. char *str= &buf[sizeof(buf) - 1]; bool neg_flag = 0; *str = '\0'; if (base == 0){return 0;} if (base < 2)base = 10; if (n < 0) { neg_flag = 1; n = -1 * n; } // prevent crash if called with base == 1 do { uint16_t m = n; n /= base; char c = m - base * n; *--str = c < 10 ? c + '0' : c + 'A' - 10; } while (n); if(neg_flag){*--str = '-';}; return str; } char* to_string(uint32_t n, int8_t base = 10) { static char buf[8 * sizeof(long) + 2]; // Assumes 8-bit chars plus zero byte. char *str= &buf[sizeof(buf) - 1]; bool neg_flag = 0; *str = '\0'; if (base == 0){return 0;} if (base < 2)base = 10; if (n < 0) { neg_flag = 1; n = -1 * n; } // prevent crash if called with base == 1 do { uint32_t m = n; n /= base; char c = m - base * n; *--str = c < 10 ? c + '0' : c + 'A' - 10; } while (n); if(neg_flag){*--str = '-';}; return str; } char* to_string(int8_t n, int8_t base = 10) { static char buf[8 * sizeof(long) + 2]; // Assumes 8-bit chars plus zero byte. char *str= &buf[sizeof(buf) - 1]; bool neg_flag = 0; *str = '\0'; if (base == 0){return 0;} if (base < 2)base = 10; if (n < 0) { neg_flag = 1; n = -1 * n; } // prevent crash if called with base == 1 do { int8_t m = n; n /= base; char c = m - base * n; *--str = c < 10 ? c + '0' : c + 'A' - 10; } while (n); if(neg_flag){*--str = '-';}; return str; } char* to_string(int16_t n, int8_t base = 10) { static char buf[8 * sizeof(long) + 2]; // Assumes 8-bit chars plus zero byte. char *str= &buf[sizeof(buf) - 1]; bool neg_flag = 0; *str = '\0'; if (base == 0){return 0;} if (base < 2)base = 10; if (n < 0) { neg_flag = 1; n = -1 * n; } // prevent crash if called with base == 1 do { int16_t m = n; n /= base; char c = m - base * n; *--str = c < 10 ? c + '0' : c + 'A' - 10; } while (n); if(neg_flag){*--str = '-';}; return str; } char* to_string(int32_t n, int8_t base = 10) { static char buf[8 * sizeof(long) + 2]; // Assumes 8-bit chars plus zero byte. char *str= &buf[sizeof(buf) - 1]; bool neg_flag = 0; *str = '\0'; if (base == 0){return 0;} if (base < 2)base = 10; if (n < 0) { neg_flag = 1; n = -1 * n; } // prevent crash if called with base == 1 do { int32_t m = n; n /= base; char c = m - base * n; *--str = c < 10 ? c + '0' : c + 'A' - 10; } while (n); if(neg_flag){*--str = '-';}; return str; } char* to_string(float, int8_t = 2); inline char* to_string(double number, int8_t digits = 2){ return to_string((float)number,digits); } char* to_string(float number, int8_t digits) { static char result[20]; bool neg_flag = 0; char* str = result; // Handle negative numbers if (number < 0.0) { neg_flag = 1; number = -1*number; } // Round correctly so that print(1.999, 2) prints as "2.00" float rounding = 0.5; for (uint8_t i=0; i<digits; ++i)rounding/=10.0; number += rounding; // Extract the integer part of the number and print it unsigned long int_part = (unsigned long)number; float remainder = number - (float)int_part; char* int_part_str = to_string((int32_t)int_part); memcpy(str,int_part_str,strlen(int_part_str)); str += strlen(int_part_str); // Print the decimal point, but only if there are digits beyond *str++ = '.'; // Extract digits from the remainder one at a time while (digits-- > 0) { remainder *= 10.0; int toPrint = int(remainder); *str++ = (char)(toPrint + 48); remainder -= toPrint; } *str++ = '\0'; return result; } #endif
24.485577
81
0.514628
87b42eb05dd71ada2d4a182556578dd62a616bad
235
h
C
Source/Device/DeviceManager.h
phisn/DigitalDetectives
2f279b4856cea0ce1933301c24683a2c0f34a2f8
[ "Unlicense" ]
1
2020-05-28T20:13:10.000Z
2020-05-28T20:13:10.000Z
Source/Device/DeviceManager.h
phisn/DigitalDetectives
2f279b4856cea0ce1933301c24683a2c0f34a2f8
[ "Unlicense" ]
null
null
null
Source/Device/DeviceManager.h
phisn/DigitalDetectives
2f279b4856cea0ce1933301c24683a2c0f34a2f8
[ "Unlicense" ]
null
null
null
#pragma once namespace Device { namespace GameManager { enum class GameState { Collect, Setup, Running }; void Initialize(); void Uninitialize(); void Process(); void SetCurrentState(const GameState); } }
10.681818
40
0.66383
40371d4f587b80ac62f6a7c454061f078597c969
217
h
C
IELTS/Main/Guide/GuideViewController.h
sophiemarceau/NEDIELTS_iOS_IPAD
5d23f51c7ff0cbfc0e0127f54dc438ca13551666
[ "MIT" ]
null
null
null
IELTS/Main/Guide/GuideViewController.h
sophiemarceau/NEDIELTS_iOS_IPAD
5d23f51c7ff0cbfc0e0127f54dc438ca13551666
[ "MIT" ]
null
null
null
IELTS/Main/Guide/GuideViewController.h
sophiemarceau/NEDIELTS_iOS_IPAD
5d23f51c7ff0cbfc0e0127f54dc438ca13551666
[ "MIT" ]
null
null
null
// // GuideViewController.h // IELTS // // Created by 李牛顿 on 14-11-12. // Copyright (c) 2014年 Neworiental. All rights reserved. // #import <UIKit/UIKit.h> @interface GuideViewController : UIViewController @end
15.5
57
0.700461
f0da618204a614282428673bc5d7e9442aaef908
7,796
h
C
src/Moon/160/mask_10_160.h
MHotchin/RLEBitmap
ebea6f7f032c235ff2301e2aced1e6180b71882e
[ "MIT" ]
8
2020-07-05T17:00:15.000Z
2022-02-08T04:34:50.000Z
src/Moon/160/mask_10_160.h
Bodmer/RLEBitmap
ed2bf7ec6497371415878a7a5a07b7938294aad6
[ "MIT" ]
2
2020-07-04T21:11:49.000Z
2020-08-11T20:23:06.000Z
src/Moon/160/mask_10_160.h
Bodmer/RLEBitmap
ed2bf7ec6497371415878a7a5a07b7938294aad6
[ "MIT" ]
3
2020-07-05T17:00:22.000Z
2020-11-03T11:18:34.000Z
// // This file is AUTOMATICALLY GENERATED, and should not be edited unless you are certain // that it will not be re-generated anytime in the future. As generated code, the // copyright owner(s) of the generating program do NOT claim any copyright on the code // generated. // // Run Length Encoded (RLE) bitmaps. Each run is encoded as either one or two bytes, // with NO PADDING. Thus, the data for each line of the bitmap is VARIABLE LENGTH, and // there is no way of determining where any line other than the first starts without // walking though the data. // // Note that one byte encoding ONLY occurs if the total number of colors is 16 or less, // and in that case the 'flags' member of the 'RLEBitmapInfo' will have the first bit // (0x01) set. // // In that case, if the high 4 bits of the first byte are ZERO, then this is a 2 byte // run. The first byte is the index of the color in the color palette, and the second // byte is the length. // // Else, the lower 4 bits are the color index, and the upper 4 bits are the run length. // // If the 'flags' member first bit is zero, then ALL runs are 2 byte runs. The first // byte is the palette index, and the second is the run length. // // In order to save PROGMEM for other uses, the bitmap data is placed in a section that // occurs near the END of the used FLASH. So, this data should only be accessed using // the 'far' versions of the progmem functions - the usual versions are limited to the // first 64K of FLASH. // // Data is from file 'images\160\mask_10_160.bmp'. // const byte mask_10_160_RLEBM_data[] PROGMEM_LATE = { 0x00, 0x4d, 0xd1, 0x00, 0x46, 0x00, 0x4a, 0x01, 0x16, 0x00, 0x40, 0x00, 0x49, 0x01, 0x1b, 0x00, 0x3c, 0x00, 0x47, 0x01, 0x21, 0x00, 0x38, 0x00, 0x46, 0x01, 0x25, 0x00, 0x35, 0x00, 0x45, 0x01, 0x28, 0x00, 0x33, 0x00, 0x44, 0x01, 0x2c, 0x00, 0x30, 0x00, 0x43, 0x01, 0x2f, 0x00, 0x2e, 0x00, 0x43, 0x01, 0x31, 0x00, 0x2c, 0x00, 0x42, 0x01, 0x34, 0x00, 0x2a, 0x00, 0x41, 0x01, 0x37, 0x00, 0x28, 0x00, 0x41, 0x01, 0x38, 0x00, 0x27, 0x00, 0x40, 0x01, 0x3b, 0x00, 0x25, 0x00, 0x3f, 0x01, 0x3d, 0x00, 0x24, 0x00, 0x3f, 0x01, 0x3f, 0x00, 0x22, 0x00, 0x3e, 0x01, 0x41, 0x00, 0x21, 0x00, 0x3e, 0x01, 0x43, 0x00, 0x1f, 0x00, 0x3d, 0x01, 0x45, 0x00, 0x1e, 0x00, 0x3d, 0x01, 0x46, 0x00, 0x1d, 0x00, 0x3c, 0x01, 0x48, 0x00, 0x1c, 0x00, 0x3c, 0x01, 0x49, 0x00, 0x1b, 0x00, 0x3b, 0x01, 0x4b, 0x00, 0x1a, 0x00, 0x3b, 0x01, 0x4c, 0x00, 0x19, 0x00, 0x3b, 0x01, 0x4d, 0x00, 0x18, 0x00, 0x3a, 0x01, 0x4f, 0x00, 0x17, 0x00, 0x3a, 0x01, 0x50, 0x00, 0x16, 0x00, 0x3a, 0x01, 0x51, 0x00, 0x15, 0x00, 0x39, 0x01, 0x53, 0x00, 0x14, 0x00, 0x39, 0x01, 0x54, 0x00, 0x13, 0x00, 0x39, 0x01, 0x55, 0x00, 0x12, 0x00, 0x38, 0x01, 0x57, 0x00, 0x11, 0x00, 0x38, 0x01, 0x57, 0x00, 0x11, 0x00, 0x38, 0x01, 0x58, 0x00, 0x10, 0x00, 0x37, 0x01, 0x5a, 0xf0, 0x00, 0x37, 0x01, 0x5b, 0xe0, 0x00, 0x37, 0x01, 0x5b, 0xe0, 0x00, 0x37, 0x01, 0x5c, 0xd0, 0x00, 0x36, 0x01, 0x5d, 0xd0, 0x00, 0x36, 0x01, 0x5e, 0xc0, 0x00, 0x36, 0x01, 0x5f, 0xb0, 0x00, 0x36, 0x01, 0x5f, 0xb0, 0x00, 0x36, 0x01, 0x60, 0xa0, 0x00, 0x35, 0x01, 0x61, 0xa0, 0x00, 0x35, 0x01, 0x62, 0x90, 0x00, 0x35, 0x01, 0x62, 0x90, 0x00, 0x35, 0x01, 0x63, 0x80, 0x00, 0x35, 0x01, 0x63, 0x80, 0x00, 0x34, 0x01, 0x65, 0x70, 0x00, 0x34, 0x01, 0x65, 0x70, 0x00, 0x34, 0x01, 0x66, 0x60, 0x00, 0x34, 0x01, 0x66, 0x60, 0x00, 0x34, 0x01, 0x66, 0x60, 0x00, 0x34, 0x01, 0x67, 0x50, 0x00, 0x33, 0x01, 0x68, 0x50, 0x00, 0x33, 0x01, 0x68, 0x50, 0x00, 0x33, 0x01, 0x69, 0x40, 0x00, 0x33, 0x01, 0x69, 0x40, 0x00, 0x33, 0x01, 0x69, 0x40, 0x00, 0x33, 0x01, 0x6a, 0x30, 0x00, 0x33, 0x01, 0x6a, 0x30, 0x00, 0x33, 0x01, 0x6a, 0x30, 0x00, 0x33, 0x01, 0x6a, 0x30, 0x00, 0x33, 0x01, 0x6b, 0x20, 0x00, 0x32, 0x01, 0x6c, 0x20, 0x00, 0x32, 0x01, 0x6c, 0x20, 0x00, 0x32, 0x01, 0x6c, 0x20, 0x00, 0x32, 0x01, 0x6c, 0x20, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6e, 0x00, 0x32, 0x01, 0x6e, 0x00, 0x32, 0x01, 0x6e, 0x00, 0x32, 0x01, 0x6e, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6d, 0x10, 0x00, 0x32, 0x01, 0x6c, 0x20, 0x00, 0x32, 0x01, 0x6c, 0x20, 0x00, 0x32, 0x01, 0x6c, 0x20, 0x00, 0x32, 0x01, 0x6c, 0x20, 0x00, 0x33, 0x01, 0x6b, 0x20, 0x00, 0x33, 0x01, 0x6a, 0x30, 0x00, 0x33, 0x01, 0x6a, 0x30, 0x00, 0x33, 0x01, 0x6a, 0x30, 0x00, 0x33, 0x01, 0x6a, 0x30, 0x00, 0x33, 0x01, 0x69, 0x40, 0x00, 0x33, 0x01, 0x69, 0x40, 0x00, 0x33, 0x01, 0x69, 0x40, 0x00, 0x33, 0x01, 0x68, 0x50, 0x00, 0x33, 0x01, 0x68, 0x50, 0x00, 0x34, 0x01, 0x67, 0x50, 0x00, 0x34, 0x01, 0x66, 0x60, 0x00, 0x34, 0x01, 0x66, 0x60, 0x00, 0x34, 0x01, 0x66, 0x60, 0x00, 0x34, 0x01, 0x65, 0x70, 0x00, 0x34, 0x01, 0x65, 0x70, 0x00, 0x35, 0x01, 0x63, 0x80, 0x00, 0x35, 0x01, 0x63, 0x80, 0x00, 0x35, 0x01, 0x62, 0x90, 0x00, 0x35, 0x01, 0x62, 0x90, 0x00, 0x35, 0x01, 0x61, 0xa0, 0x00, 0x36, 0x01, 0x60, 0xa0, 0x00, 0x36, 0x01, 0x5f, 0xb0, 0x00, 0x36, 0x01, 0x5f, 0xb0, 0x00, 0x36, 0x01, 0x5e, 0xc0, 0x00, 0x36, 0x01, 0x5d, 0xd0, 0x00, 0x37, 0x01, 0x5c, 0xd0, 0x00, 0x37, 0x01, 0x5b, 0xe0, 0x00, 0x37, 0x01, 0x5b, 0xe0, 0x00, 0x37, 0x01, 0x5a, 0xf0, 0x00, 0x38, 0x01, 0x58, 0x00, 0x10, 0x00, 0x38, 0x01, 0x57, 0x00, 0x11, 0x00, 0x38, 0x01, 0x57, 0x00, 0x11, 0x00, 0x39, 0x01, 0x55, 0x00, 0x12, 0x00, 0x39, 0x01, 0x54, 0x00, 0x13, 0x00, 0x39, 0x01, 0x53, 0x00, 0x14, 0x00, 0x3a, 0x01, 0x51, 0x00, 0x15, 0x00, 0x3a, 0x01, 0x50, 0x00, 0x16, 0x00, 0x3a, 0x01, 0x4f, 0x00, 0x17, 0x00, 0x3b, 0x01, 0x4d, 0x00, 0x18, 0x00, 0x3b, 0x01, 0x4c, 0x00, 0x19, 0x00, 0x3b, 0x01, 0x4b, 0x00, 0x1a, 0x00, 0x3c, 0x01, 0x49, 0x00, 0x1b, 0x00, 0x3c, 0x01, 0x48, 0x00, 0x1c, 0x00, 0x3d, 0x01, 0x46, 0x00, 0x1d, 0x00, 0x3d, 0x01, 0x45, 0x00, 0x1e, 0x00, 0x3e, 0x01, 0x43, 0x00, 0x1f, 0x00, 0x3e, 0x01, 0x41, 0x00, 0x21, 0x00, 0x3f, 0x01, 0x3f, 0x00, 0x22, 0x00, 0x3f, 0x01, 0x3d, 0x00, 0x24, 0x00, 0x40, 0x01, 0x3b, 0x00, 0x25, 0x00, 0x41, 0x01, 0x38, 0x00, 0x27, 0x00, 0x41, 0x01, 0x37, 0x00, 0x28, 0x00, 0x42, 0x01, 0x34, 0x00, 0x2a, 0x00, 0x43, 0x01, 0x31, 0x00, 0x2c, 0x00, 0x43, 0x01, 0x2f, 0x00, 0x2e, 0x00, 0x44, 0x01, 0x2c, 0x00, 0x30, 0x00, 0x45, 0x01, 0x28, 0x00, 0x33, 0x00, 0x46, 0x01, 0x25, 0x00, 0x35, 0x00, 0x47, 0x01, 0x21, 0x00, 0x38, 0x00, 0x49, 0x01, 0x1b, 0x00, 0x3c, 0x00, 0x4a, 0x01, 0x16, 0x00, 0x40, 0x00, 0x4d, 0xd1, 0x00, 0x46, }; // 160x160 Bitmap (25600 pixels) in 860 bytes const uint16_t mask_10_160_RLEBM_palette[] PROGMEM_LATE = { // Palette has 2 entries 0x0000, 0xffff, }; // Some platforms don't fully implement the pgmspace.h interface. Assume ordinary // addresses will do. #if not defined pgm_get_far_address #define pgm_get_far_address(x) ((uint32_t)(&(x))) #endif // Returns the info needed to render the bitmap. inline void get_mask_10_160_RLEBM( RLEBitmapInfo &bmInfo) { bmInfo.pRLEBM_data_far = pgm_get_far_address(mask_10_160_RLEBM_data); bmInfo.pRLEBM_palette_far = pgm_get_far_address(mask_10_160_RLEBM_palette); bmInfo.width = 160; bmInfo.height = 160; bmInfo.flags = 0x01; }
34.959641
89
0.658671
293c6bb986e8d571b6f3612e380597208f6f9e77
5,083
h
C
src/C/corecrypto/ccaes/src/gladman/gladman_aes.h
GaloisInc/hacrypto
5c99d7ac73360e9b05452ac9380c1c7dc6784849
[ "BSD-3-Clause" ]
34
2015-02-04T18:03:14.000Z
2020-11-10T06:45:28.000Z
src/C/corecrypto/ccaes/src/gladman/gladman_aes.h
GaloisInc/hacrypto
5c99d7ac73360e9b05452ac9380c1c7dc6784849
[ "BSD-3-Clause" ]
5
2015-06-30T21:17:00.000Z
2016-06-14T22:31:51.000Z
src/C/corecrypto/ccaes/src/gladman/gladman_aes.h
GaloisInc/hacrypto
5c99d7ac73360e9b05452ac9380c1c7dc6784849
[ "BSD-3-Clause" ]
15
2015-10-29T14:21:58.000Z
2022-01-19T07:33:14.000Z
/* --------------------------------------------------------------------------- Copyright (c) 2003, Dr Brian Gladman, Worcester, UK. All rights reserved. LICENSE TERMS The free distribution and use of this software in both source and binary form is allowed (with or without changes) provided that: 1. distributions of this source code include the above copyright notice, this list of conditions and the following disclaimer; 2. distributions in binary form include the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other associated materials; 3. the copyright holder's name is not used to endorse products built using this software without specific written permission. ALTERNATIVELY, provided that this notice is retained in full, this product may be distributed under the terms of the GNU General Public License (GPL), in which case the provisions of the GPL apply INSTEAD OF those given above. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. --------------------------------------------------------------------------- Issue 28/01/2004 This file contains the definitions required to use AES in C. See aesopt.h for optimisation details. */ #ifndef _CORECRYPTO_GLADMAN_AES_H_ #define _CORECRYPTO_GLADMAN_AES_H_ #include <corecrypto/ccmode.h> #include <stdint.h> #if defined(__cplusplus) extern "C" { #endif #define AES_128 /* define if AES with 128 bit keys is needed */ #define AES_192 /* define if AES with 192 bit keys is needed */ #define AES_256 /* define if AES with 256 bit keys is needed */ #define AES_VAR /* define if a variable key size is needed */ /* The following must also be set in assembler files if being used */ #define AES_ENCRYPT /* if support for encryption is needed */ #define AES_DECRYPT /* if support for decryption is needed */ typedef uint8_t aes_08t; typedef uint32_t aes_32t; #define AES_BLOCK_SIZE 16 /* the AES block size in bytes */ #define N_COLS 4 /* the number of columns in the state */ /* The key schedule length is 11, 13 or 15 16-byte blocks for 128, */ /* 192 or 256-bit keys respectively. That is 176, 208 or 240 bytes */ /* or 44, 52 or 60 32-bit words. For simplicity this code allocates */ /* the maximum 60 word array for the key schedule for all key sizes */ #if defined( AES_VAR ) || defined( AES_256 ) #define KS_LENGTH 60 #elif defined( AES_192 ) #define KS_LENGTH 52 #else #define KS_LENGTH 44 #endif #define aes_ret void #define aes_rval aes_ret typedef struct { aes_32t ks[KS_LENGTH]; aes_32t rn; uint8_t chainBuf[AES_BLOCK_SIZE]; aes_32t cbcEnable; } ccaes_gladman_encrypt_ctx; typedef struct { aes_32t ks[KS_LENGTH]; aes_32t rn; uint8_t chainBuf[AES_BLOCK_SIZE]; aes_32t cbcEnable; } ccaes_gladman_decrypt_ctx; typedef struct { ccaes_gladman_decrypt_ctx decrypt; ccaes_gladman_encrypt_ctx encrypt; } ccaes_gladman_ctx; /* This routine must be called before first use if non-static */ /* tables are being used */ void gen_tabs(void); /* The key length (klen) is input in bytes when it is in the range */ /* 16 <= klen <= 32 or in bits when in the range 128 <= klen <= 256 */ #if defined( AES_ENCRYPT ) #if defined(AES_128) || defined(AES_VAR) aes_rval ccaes_gladman_encrypt_key128(const unsigned char *in_key, ccaes_gladman_encrypt_ctx cx[1]); #endif #if defined(AES_192) || defined(AES_VAR) aes_rval ccaes_gladman_encrypt_key192(const unsigned char *in_key, ccaes_gladman_encrypt_ctx cx[1]); #endif #if defined(AES_256) || defined(AES_VAR) aes_rval ccaes_gladman_encrypt_key256(const unsigned char *in_key, ccaes_gladman_encrypt_ctx cx[1]); #endif #if defined(AES_VAR) aes_rval ccaes_gladman_encrypt_key(const unsigned char *in_key, size_t key_len, ccaes_gladman_encrypt_ctx cx[1]); #endif void ccaes_gladman_encrypt(const cccbc_ctx *ctx, cccbc_iv *iv, unsigned long num_blks, const void *in, void *out); #endif #if defined( AES_DECRYPT ) #if defined(AES_128) || defined(AES_VAR) aes_rval ccaes_gladman_decrypt_key128(const unsigned char *in_key, ccaes_gladman_decrypt_ctx cx[1]); #endif #if defined(AES_192) || defined(AES_VAR) aes_rval ccaes_gladman_decrypt_key192(const unsigned char *in_key, ccaes_gladman_decrypt_ctx cx[1]); #endif #if defined(AES_256) || defined(AES_VAR) aes_rval ccaes_gladman_decrypt_key256(const unsigned char *in_key, ccaes_gladman_decrypt_ctx cx[1]); #endif #if defined(AES_VAR) aes_rval ccaes_gladman_decrypt_key(const unsigned char *in_key, size_t key_len, ccaes_gladman_decrypt_ctx cx[1]); #endif void ccaes_gladman_decrypt(const cccbc_ctx *ctx, cccbc_iv *iv, unsigned long num_blks, const void *in, void *out); #endif #if defined(__cplusplus) } #endif #endif /* _CC_AES_H_ */
31.76875
113
0.711194
ad9b6f9ec2b1df79a01e763502356af29878adb0
15,685
h
C
dmc/dlls/player.h
SmileyAG/dmc-rebased
579b3cd0c8c6690421246e9f0b3381d1f6ceb2f6
[ "Unlicense" ]
1
2022-01-05T09:42:14.000Z
2022-01-05T09:42:14.000Z
dmc/dlls/player.h
SmileyAG/ag-dmc
579b3cd0c8c6690421246e9f0b3381d1f6ceb2f6
[ "Unlicense" ]
10
2022-01-04T14:15:33.000Z
2022-01-04T16:16:21.000Z
dmc/dlls/player.h
SmileyAG/dmc-rebased
579b3cd0c8c6690421246e9f0b3381d1f6ceb2f6
[ "Unlicense" ]
1
2022-01-05T07:44:20.000Z
2022-01-05T07:44:20.000Z
/*** * * Copyright (c) 1999, Valve LLC. All rights reserved. * * This product contains software technology licensed from Id * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * All Rights Reserved. * * Use, distribution, and modification of this source code and/or resulting * object code is restricted to non-commercial enhancements to products from * Valve LLC. All other use, distribution, or modification is prohibited * without written permission from Valve LLC. * ****/ #ifndef PLAYER_H #define PLAYER_H #define PLAYER_FATAL_FALL_SPEED 1024 // approx 60 feet #define PLAYER_MAX_SAFE_FALL_SPEED 580 // approx 20 feet #define DAMAGE_FOR_FALL_SPEED (float)100 / (PLAYER_FATAL_FALL_SPEED - PLAYER_MAX_SAFE_FALL_SPEED) // damage per unit per second. #define PLAYER_MIN_BOUNCE_SPEED 200 #define PLAYER_FALL_PUNCH_THRESHHOLD (float)350 // won't punch player's screen/make scrape noise unless player falling at least this fast. // // Player PHYSICS FLAGS bits // #define PFLAG_ONLADDER (1 << 0) #define PFLAG_ONSWING (1 << 0) #define PFLAG_ONTRAIN (1 << 1) #define PFLAG_ONBARNACLE (1 << 2) #define PFLAG_DUCKING (1 << 3) // In the process of ducking, but totally squatted yet #define PFLAG_USING (1 << 4) // Using a continuous entity #define PFLAG_OBSERVER (1 << 5) // player is locked in stationary cam mode. Spectators can move, observers can't. // // generic player // //----------------------------------------------------- // This is Half-Life player entity //----------------------------------------------------- #define CSUITPLAYLIST 4 // max of 4 suit sentences queued up at any time #define SUIT_GROUP TRUE #define SUIT_SENTENCE FALSE #define SUIT_REPEAT_OK 0 #define SUIT_NEXT_IN_30SEC 30 #define SUIT_NEXT_IN_1MIN 60 #define SUIT_NEXT_IN_5MIN 300 #define SUIT_NEXT_IN_10MIN 600 #define SUIT_NEXT_IN_30MIN 1800 #define SUIT_NEXT_IN_1HOUR 3600 #define CSUITNOREPEAT 32 #define SOUND_FLASHLIGHT_ON "items/flashlight1.wav" #define SOUND_FLASHLIGHT_OFF "items/flashlight1.wav" #define TEAM_NAME_LENGTH 16 typedef enum { PLAYER_IDLE, PLAYER_WALK, PLAYER_JUMP, PLAYER_SUPERJUMP, PLAYER_DIE, PLAYER_ATTACK1, } PLAYER_ANIM; #ifdef THREEWAVE enum Player_Menu { Team_Menu, Team_Menu_IG, }; #endif #define MAX_ID_RANGE 2048 #define SBAR_STRING_SIZE 128 enum sbar_data { SBAR_ID_TARGETNAME = 1, SBAR_ID_TARGETHEALTH, SBAR_ID_TARGETARMOR, SBAR_ID_TARGETRUNE, SBAR_ID_TARGETTEAM, SBAR_END, }; #define PLAYER_MAX_SPEED 300 class CBasePlayer: public CBaseMonster { public: int random_seed; // See that is shared between client & server for shared weapons code int m_iPlayerSound; // the index of the sound list slot reserved for this player int m_iTargetVolume; // ideal sound volume. int m_iWeaponVolume; // how loud the player's weapon is right now. int m_iExtraSoundTypes; // additional classification for this weapon's sound int m_iWeaponFlash; // brightness of the weapon flash float m_flStopExtraSoundTime; float m_flFlashLightTime; // Time until next battery draw/Recharge int m_iFlashBattery; // Flashlight Battery Draw int m_afButtonLast; int m_afButtonPressed; int m_afButtonReleased; edict_t* m_pentSndLast; // last sound entity to modify player room type float m_flSndRoomtype; // last roomtype set by sound entity float m_flSndRange; // dist from player to sound entity float m_flFallVelocity; int m_rgItems[MAX_ITEMS]; int m_fKnownItem; // True when a new item needs to be added int m_fNewAmmo; // True when a new item has been added unsigned int m_afPhysicsFlags; // physics flags - set when 'normal' physics should be revisited or overriden float m_fNextSuicideTime; // the time after which the player can next use the suicide command // these are time-sensitive things that we keep track of float m_flTimeStepSound; // when the last stepping sound was made float m_flTimeWeaponIdle; // when to play another weapon idle animation. float m_flSwimTime; // how long player has been underwater float m_flDuckTime; // how long we've been ducking float m_flWallJumpTime; // how long until next walljump float m_flSuitUpdate; // when to play next suit update int m_rgSuitPlayList[CSUITPLAYLIST]; // next sentencenum to play for suit update int m_iSuitPlayNext; // next sentence slot for queue storage; int m_rgiSuitNoRepeat[CSUITNOREPEAT]; // suit sentence no repeat list float m_rgflSuitNoRepeatTime[CSUITNOREPEAT]; // how long to wait before allowing repeat int m_lastDamageAmount; // Last damage taken float m_tbdPrev; // Time-based damage timer float m_flgeigerRange; // range to nearest radiation source float m_flgeigerDelay; // delay per update of range msg to client int m_igeigerRangePrev; int m_iStepLeft; // alternate left/right foot stepping sound char m_szTextureName[CBTEXTURENAMEMAX]; // current texture name we're standing on char m_chTextureType; // current texture type int m_idrowndmg; // track drowning damage taken int m_idrownrestored; // track drowning damage restored int m_bitsHUDDamage; // Damage bits for the current fame. These get sent to // the hude via the DAMAGE message BOOL m_fInitHUD; // True when deferred HUD restart msg needs to be sent BOOL m_fGameHUDInitialized; int m_iTrain; // Train control position BOOL m_fWeapon; // Set this to FALSE to force a reset of the current weapon HUD info EHANDLE m_pTank; // the tank which the player is currently controlling, NULL if no tank float m_fDeadTime; // the time at which the player died (used in PlayerDeathThink()) BOOL m_fNoPlayerSound; // a debugging feature. Player makes no sound if this is true. BOOL m_fLongJump; // does this player have the longjump module? float m_tSneaking; int m_iUpdateTime; // stores the number of frame ticks before sending HUD update messages int m_iClientHealth; // the health currently known by the client. If this changes, send a new int m_iClientBattery; // the Battery currently known by the client. If this changes, send a new int m_iHideHUD; // the players hud weapon info is to be hidden int m_iClientHideHUD; int m_iFOV; // field of view int m_iClientFOV; // client's known FOV // usable player items CBasePlayerItem* m_rgpPlayerItems[MAX_ITEM_TYPES]; CBasePlayerItem* m_pActiveItem; CBasePlayerItem* m_pClientActiveItem; // client version of the active item CBasePlayerItem* m_pLastItem; // shared ammo slots int m_rgAmmo[MAX_AMMO_SLOTS]; int m_rgAmmoLast[MAX_AMMO_SLOTS]; Vector m_vecAutoAim; BOOL m_fOnTarget; int m_iDeaths; float m_iRespawnFrames; // used in PlayerDeathThink() to make sure players can always respawn int m_lastx, m_lasty; // These are the previous update's crosshair angles, DON"T SAVE/RESTORE int m_nCustomSprayFrames; // Custom clan logo frames for this player float m_flNextDecalTime; // next time this player can spray a decal char m_szTeamName[TEAM_NAME_LENGTH]; virtual void Spawn(void); // virtual void Think( void ); virtual void Jump(void); virtual void Duck(void); virtual void PreThink(void); virtual void PostThink(void); virtual Vector GetGunPosition(void); virtual int TakeHealth(float flHealth, int bitsDamageType); virtual void TraceAttack(entvars_t* pevAttacker, float flDamage, Vector vecDir, TraceResult* ptr, int bitsDamageType); virtual int TakeDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType); virtual void Killed(entvars_t* pevAttacker, int iGib); virtual Vector BodyTarget(const Vector& posSrc) { return Center() + pev->view_ofs * RANDOM_FLOAT(0.5, 1.1); }; // position to shoot at virtual void StartSneaking(void) { m_tSneaking = gpGlobals->time - 1; } virtual void StopSneaking(void) { m_tSneaking = gpGlobals->time + 30; } virtual BOOL IsSneaking(void) { return m_tSneaking <= gpGlobals->time; } virtual BOOL IsAlive(void) { return (pev->deadflag == DEAD_NO) && pev->health > 0; } virtual BOOL ShouldFadeOnDeath(void) { return FALSE; } virtual BOOL IsPlayer(void) { return TRUE; } // Spectators should return FALSE for this, they aren't "players" as far as game logic is concerned virtual BOOL IsNetClient(void) { return TRUE; } // Bots should return FALSE for this, they can't receive NET messages // Spectators should return TRUE for this virtual const char* TeamID(void); virtual int Save(CSave& save); virtual int Restore(CRestore& restore); void RenewItems(void); void RemoveAllItems(BOOL removeSuit); BOOL SwitchWeapon(CBasePlayerItem* pWeapon); // JOHN: sends custom messages if player HUD data has changed (eg health, ammo) virtual void UpdateClientData(void); static TYPEDESCRIPTION m_playerSaveData[]; // Player is moved across the transition by other means virtual int ObjectCaps(void) { return CBaseMonster::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } virtual void Precache(void); BOOL IsOnLadder(void); BOOL FlashlightIsOn(void); void FlashlightTurnOn(void); void FlashlightTurnOff(void); void DeathSound(void); int Classify(void); void SetAnimation(PLAYER_ANIM playerAnim); void SetWeaponAnimType(const char* szExtention); char m_szAnimExtention[32]; // custom player functions virtual void ImpulseCommands(void); void CheatImpulseCommands(int iImpulse); void StartDeathCam(void); void StartObserver(Vector vecPosition, Vector vecViewAngle); void AddPoints(int score, BOOL bAllowNegativeScore); void AddPointsToTeam(int score, BOOL bAllowNegativeScore); BOOL AddPlayerItem(CBasePlayerItem* pItem); BOOL RemovePlayerItem(CBasePlayerItem* pItem); void DropPlayerItem(char* pszItemName); BOOL HasPlayerItem(CBasePlayerItem* pCheckItem); BOOL HasNamedPlayerItem(const char* pszItemName); BOOL HasWeapons(void); // do I have ANY weapons? void SelectPrevItem(int iItem); void SelectNextItem(int iItem); void SelectLastItem(void); void SelectItem(const char* pstr); void ItemPreFrame(void); void ItemPostFrame(void); void GiveNamedItem(const char* szName); void EnableControl(BOOL fControl); int GiveAmmo(int iAmount, char* szName, int iMax); void SendAmmoUpdate(void); void WaterMove(void); void EXPORT PlayerDeathThink(void); void PlayerUse(void); void CheckSuitUpdate(); void SetSuitUpdate(char* name, int fgroup, int iNoRepeat); void UpdateGeigerCounter(void); void CheckTimeBasedDamage(void); void UpdateStepSound(void); void PlayStepSound(int step, float fvol); BOOL FBecomeProne(void); void BarnacleVictimBitten(entvars_t* pevBarnacle); void BarnacleVictimReleased(void); static int GetAmmoIndex(const char* psz); int AmmoInventory(int iAmmoIndex); int Illumination(void); void ResetAutoaim(void); Vector GetAutoaimVector(float flDelta); Vector AutoaimDeflection(Vector& vecSrc, float flDist, float flDelta); void ForceClientDllUpdate(void); // Forces all client .dll specific data to be resent to client. void DeathMessage(entvars_t* pevKiller); void SetCustomDecalFrames(int nFrames); int GetCustomDecalFrames(void); // Observer camera void Observer_FindNextPlayer(); void Observer_HandleButtons(); void Observer_SetMode(int iMode); EHANDLE m_hObserverTarget; float m_flNextObserverInput; int IsObserver() { return pev->iuser1; }; // QUAKECLASSIC // Player void Pain(CBaseEntity* pAttacker); float m_flPainSoundFinished; BOOL m_bHadFirstSpawn; // used to handle the MOTD // Weapon selection int W_BestWeapon(void); void W_SetCurrentAmmo(int sendanim = 1); BOOL W_CheckNoAmmo(void); void W_ChangeWeapon(int iWeaponNumber); void W_CycleWeaponCommand(void); void W_CycleWeaponReverseCommand(void); // Weapon functionality void Q_FireBullets(int iShots, Vector vecDir, Vector vecSpread); void LightningDamage(Vector p1, Vector p2, CBaseEntity* pAttacker, float flDamage, Vector vecDir); // Weapons void W_Attack(int iQuadSound); void W_FireAxe(void); void W_FireShotgun(int QuadSound); void W_FireSuperShotgun(int QuadSound); void W_FireRocket(int QuadSound); void W_FireLightning(int QuadSound); void W_FireGrenade(int QuadSound); void W_FireSuperSpikes(int QuadSound); void W_FireSpikes(int QuadSound); // Ammunition void CheckAmmo(void); int* m_pCurrentAmmo; // Always points to one of the four ammo counts below int m_iAmmoRockets; int m_iAmmoCells; int m_iAmmoShells; int m_iAmmoNails; // Backpacks void DropBackpack(void); // Weapons void Deathmatch_Weapon(int iOldWeapon, int iNewWeapon); int m_iQuakeWeapon; int m_iClientQuakeWeapon; // The last status of the m_iQuakeWeapon sent to the client. int m_iQuakeItems; int m_iClientQuakeItems; // The last status of the m_iQuakeItems sent to the client. int m_iWeaponSwitch; int m_iBackpackSwitch; int m_iAutoWepSwitch; // Weapon Data float m_flAxeFire; float m_flLightningTime; int m_iNailOffset; float m_flNextQuadSound; // Powerups float m_flSuperDamageFinished; float m_flInvincibleFinished; float m_flInvisibleFinished; float m_flRadsuitFinished; void PowerUpThink(void); // Checks powerup timers and hadles their effects char m_chOldModel[64]; // Save the player's model here bool m_bPlayedQuadSound; bool m_bPlayedEnvSound; bool m_bPlayedInvSound; bool m_bPlayedProtectSound; BOOL m_bLostInvincSound; BOOL m_bLostInvisSound; BOOL m_bLostSuperSound; BOOL m_bLostRadSound; float m_fInvincSound; float m_fSuperSound; void InitStatusBar(void); void UpdateStatusBar(void); int m_izSBarState[SBAR_END]; float m_flNextSBarUpdateTime; float m_flStatusBarDisappearDelay; char m_SbarString0[SBAR_STRING_SIZE]; char m_SbarString1[SBAR_STRING_SIZE]; unsigned short m_usShotgunSingle; unsigned short m_usShotgunDouble; unsigned short m_usAxe; unsigned short m_usAxeSwing; unsigned short m_usRocket; unsigned short m_usGrenade; unsigned short m_usLightning; unsigned short m_usSpike; unsigned short m_usSuperSpike; #ifdef THREEWAVE int m_bHasFlag; void ShowMenu(int bitsValidSlots, int nDisplayTime, BOOL fNeedMore, char* pszText); int m_iMenu; float m_flNextTeamChange; CBasePlayer* pFlagCarrierKiller; CBasePlayer* pFlagReturner; CBasePlayer* pCarrierHurter; float m_flCarrierHurtTime; float m_flCarrierPickupTime; float m_flFlagCarrierKillTime; float m_flFlagReturnTime; float m_flFlagStatusTime; float m_flRegenTime; int m_iRuneStatus; void W_FireHook(void); void Throw_Grapple(void); bool m_bHook_Out; bool m_bOn_Hook; CBaseEntity* m_ppHook; void Service_Grapple(void); #endif //#ifdef THREEWAVE //#endif }; #define AUTOAIM_2DEGREES 0.0348994967025 #define AUTOAIM_5DEGREES 0.08715574274766 #define AUTOAIM_8DEGREES 0.1391731009601 #define AUTOAIM_10DEGREES 0.1736481776669 // QUAKECLASSIC #define Q_SMALL_PUNCHANGLE_KICK -2 #define Q_BIG_PUNCHANGLE_KICK -4 #define IT_AXE (1 << 0) #define IT_SHOTGUN (1 << 1) #define IT_SUPER_SHOTGUN (1 << 2) #define IT_NAILGUN (1 << 3) #define IT_SUPER_NAILGUN (1 << 4) #define IT_GRENADE_LAUNCHER (1 << 5) #define IT_ROCKET_LAUNCHER (1 << 6) #define IT_LIGHTNING (1 << 7) #define IT_EXTRA_WEAPON (1 << 8) #define IT_SHELLS (1 << 9) #define IT_NAILS (1 << 10) #define IT_ROCKETS (1 << 11) #define IT_CELLS (1 << 12) #define IT_ARMOR1 (1 << 13) #define IT_ARMOR2 (1 << 14) #define IT_ARMOR3 (1 << 15) #define IT_SUPERHEALTH (1 << 16) #define IT_KEY1 (1 << 17) #define IT_KEY2 (1 << 18) #define IT_INVISIBILITY (1 << 19) #define IT_INVULNERABILITY (1 << 20) #define IT_SUIT (1 << 21) #define IT_QUAD (1 << 22) #define ITEM_RUNE1_FLAG 1 #define ITEM_RUNE2_FLAG 2 #define ITEM_RUNE3_FLAG 3 #define ITEM_RUNE4_FLAG 4 extern int gmsgHudText; extern BOOL gInitHUD; #define MAX_TELES 256 #endif // PLAYER_H
31.495984
145
0.76519
091897328563f3bccf40aabdb41094d892be111a
1,255
h
C
Engine/GameObject.h
JoanBarduena/VideogameEngines
cd868a8e495d736c325a3b3f095b9b23118569e0
[ "MIT" ]
null
null
null
Engine/GameObject.h
JoanBarduena/VideogameEngines
cd868a8e495d736c325a3b3f095b9b23118569e0
[ "MIT" ]
null
null
null
Engine/GameObject.h
JoanBarduena/VideogameEngines
cd868a8e495d736c325a3b3f095b9b23118569e0
[ "MIT" ]
null
null
null
#pragma once #include "Globals.h" #include "Component.h" #include "ComponentMesh.h" #include "ComponentTexture.h" #include "ComponentTransform.h" #include "ComponentCanvas.h" #include "ComponentImage.h" #include "ComponentButton.h" class GameObject { public: GameObject(string name); ~GameObject(); bool CleanUp(); Component* CreateComponent(Component::Type type); void DefineChilds(GameObject* GO); bool HasChildren() const; bool Update(float dt); void UpdateTransformation(GameObject* GO); void DeleteGO(GameObject* GO, bool original); void RemoveChild(GameObject* go); ComponentTransform* GetComponentTransform(); ComponentMesh* GetComponentMesh(); ComponentTexture* GetComponentTexture(); ComponentCanvas* GetComponentCanvas(); ComponentImage* GetComponentImage(); ComponentButton* GetComponentButton(); public: string name; string unactive_name; bool active = true; bool was_unactive = false; int id = -1; bool go_static = false; //Values to reset initial pos, scale and rotation float3 reset_pos = float3::zero; float3 reset_scale = float3::one; Quat reset_rotation = Quat::identity; std::vector<Component*> components; GameObject* parent = nullptr; std::vector<GameObject*> childs; };
19.920635
50
0.74741
f6569fe095dfc0417924bb6691dd073915a4e322
4,353
h
C
libs/RopLib/RopLib.h
trailofbits/codereason
5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2
[ "MIT" ]
129
2015-06-18T01:24:22.000Z
2019-05-21T01:00:56.000Z
libs/RopLib/RopLib.h
zeezocode/codereason
5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2
[ "MIT" ]
5
2015-06-19T05:09:37.000Z
2015-07-13T18:57:18.000Z
libs/RopLib/RopLib.h
zeezocode/codereason
5c9d51fe61895ebe29cd9b6d8e60dc49d0162ea2
[ "MIT" ]
28
2015-06-18T02:02:03.000Z
2019-06-28T03:48:15.000Z
#ifndef _ROPLIB_H #define _ROPLIB_H #include <BasicIR.h> #include <getExec.h> #include <list> #include <boost/cstdint.hpp> #include <boost/shared_ptr.hpp> enum VisitorResult { Discard, Keep, Accept }; /* This is a virtual class that has no meaning to the analysis framework other * than "state that I should give to the client". it should be copyable and * deep-movable, because one of these will be maintained for every node in the * state space. Ideally it should also be compact ... */ class CodeExplorationState { public: CodeExplorationState() { } virtual CodeExplorationState *clone()=0; }; typedef boost::shared_ptr<CodeExplorationState> CodeExplorationStatePtr; /* this is the result function that the explorers give back when we have visited * a block with state. It tells us whether or not we should stop the exploration * here, whether we should add everything to the set, or whether we should add * a subset of everything to the set. */ class CodeExplorationResult { public: CodeExplorationStatePtr newState; bool doAll; bool stop; std::set<boost::uint64_t> addrs; VisitorResult res; CodeExplorationResult() : doAll(false), stop(false), res(Discard) { } }; class RopLibVisitor { public: RopLibVisitor(void) { return; } virtual VisitorResult keepBlock(BlockPtr b)=0; virtual CodeExplorationStatePtr initialState(void)=0; virtual CodeExplorationResult exploreBlock(BlockPtr b, CodeExplorationStatePtr s)=0; }; typedef boost::shared_ptr<RopLibVisitor> RopLibVisitorPtr; class RopLibSearcher { protected: secVT execCode; RopLibVisitorPtr visitor; std::list<BlockPtr> decodedBlocks; std::map<boost::uint64_t, BlockPtr> blockMap; std::list<std::list<BlockPtr> > foundBlocks; boost::uint64_t totalBlocks; boost::uint64_t translatedBlocks; boost::uint64_t evaluatedBlocks; TargetArch tarch; void *decodeCtx; ExecCodeProviderPtr codeProvider; unsigned int maxNumStatements; public: RopLibSearcher(ExecCodeProvider * codeProvider, FileFormat fmt, TargetArch t, unsigned int m); RopLibSearcher(RopLibVisitorPtr v, ExecCodeProvider * codeProvider, FileFormat fmt, TargetArch t, unsigned int m); RopLibSearcher(RopLibVisitorPtr v, std::list<BlockPtr>, void *, TargetArch, unsigned int m); boost::uint64_t getNumBlocks(void) { return this->totalBlocks; } boost::uint64_t getBlocksDone(void) { return this->evaluatedBlocks; } boost::uint64_t getBlocksLeft(void) { return this->totalBlocks-this->evaluatedBlocks; } bool needsMoreBlocks(void) { return this->decodedBlocks.size() == 0; } bool canSearch(void) { return this->totalBlocks != this->evaluatedBlocks; } std::list<BlockPtr> getDecodedBlocks(void) { return this->decodedBlocks; } void getBlocks(void); bool getBlocks(boost::uint32_t blockCount); virtual void evalOneBlock(void); std::list<std::list<BlockPtr> > getBlocksFound(void) { return this->foundBlocks; } secVT getSections(void) { return this->execCode; } BlockPtr getBlockWithBaseVA(uint64_t VA) { BlockPtr b; std::map<boost::uint64_t, BlockPtr>::iterator f = this->blockMap.find(VA); if( f != this->blockMap.end() ) { b = (*f).second; } return b; } std::map<boost::uint64_t, BlockPtr> getBlockMap(void) { return this->blockMap; } static std::list<BlockPtr> decodeBlocks(void *, secVT, std::ostream &, unsigned int); }; typedef boost::shared_ptr<RopLibSearcher> RopLibSearcherPtr; /* we'll subclass the RopLibSearcher for each new search tactic that we * think of that doesn't fit into a stateless search. */ class StatefulRopLibSearcher : public RopLibSearcher { private: public: StatefulRopLibSearcher(RopLibVisitorPtr, ExecCodeProvider *, FileFormat, TargetArch, unsigned int); StatefulRopLibSearcher(RopLibVisitorPtr, std::list<BlockPtr>, void *, TargetArch, unsigned int); virtual void evalOneBlock(); }; #endif
35.390244
118
0.669194
b68f21f680742a6494bc1fc9c12a402fc123d4a2
2,052
h
C
Alignment/MuonAlignmentAlgorithms/plugins/CSCChamberFitter.h
nistefan/cmssw
ea13af97f7f2117a4f590a5e654e06ecd9825a5b
[ "Apache-2.0" ]
3
2018-08-24T19:10:26.000Z
2019-02-19T11:45:32.000Z
Alignment/MuonAlignmentAlgorithms/plugins/CSCChamberFitter.h
nistefan/cmssw
ea13af97f7f2117a4f590a5e654e06ecd9825a5b
[ "Apache-2.0" ]
3
2018-08-23T13:40:24.000Z
2019-12-05T21:16:03.000Z
Alignment/MuonAlignmentAlgorithms/plugins/CSCChamberFitter.h
nistefan/cmssw
ea13af97f7f2117a4f590a5e654e06ecd9825a5b
[ "Apache-2.0" ]
5
2018-08-21T16:37:52.000Z
2020-01-09T13:33:17.000Z
#ifndef Alignment_MuonAlignmentAlgorithms_CSCChamberFitter_H #define Alignment_MuonAlignmentAlgorithms_CSCChamberFitter_H /** \class CSCChamberFitter * $Date: 2010/05/06 05:57:33 $ * $Revision: 1.2 $ * \author J. Pivarski - Texas A&M University <pivarski@physics.tamu.edu> */ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/DetId/interface/DetId.h" #include "DataFormats/MuonDetId/interface/CSCDetId.h" #include "DataFormats/CLHEP/interface/AlgebraicObjects.h" #include "Alignment/CommonAlignment/interface/Alignable.h" #include "Alignment/CommonAlignment/interface/AlignableNavigator.h" #include "Alignment/CommonAlignment/interface/AlignableObjectId.h" #include "Alignment/CommonAlignment/interface/AlignmentParameters.h" #include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterStore.h" #include "Alignment/MuonAlignmentAlgorithms/interface/CSCPairConstraint.h" #include "Alignment/MuonAlignmentAlgorithms/plugins/CSCPairResidualsConstraint.h" #include "Alignment/MuonAlignmentAlgorithms/plugins/CSCAlignmentCorrections.h" class CSCChamberFitter { public: CSCChamberFitter(const edm::ParameterSet &iConfig, std::vector<CSCPairResidualsConstraint*> &residualsConstraints); virtual ~CSCChamberFitter() {}; bool fit(std::vector<CSCAlignmentCorrections*> &corrections) const; void radiusCorrection(AlignableNavigator *alignableNavigator, AlignmentParameterStore *alignmentParameterStore, bool combineME11) const; protected: int index(std::string alignable) const; void walk(std::map<int,bool> &touched, int alignable) const; long alignableId(std::string alignable) const; bool isFrame(int i) const; double chi2(const AlgebraicVector& A, double lambda) const; double lhsVector(int k) const; double hessian(int k, int l, double lambda) const; std::string m_name; std::vector<std::string> m_alignables; std::vector<int> m_frames; int m_fixed; std::vector<CSCPairConstraint*> m_constraints; }; #endif // Alignment_MuonAlignmentAlgorithms_CSCChamberFitter_H
41.04
138
0.807018
6625618f4e37a79e764bfe4aa5d007c7fa837481
1,134
h
C
src/pair_yukawa.h
qikaifzj/ludwig
e16d2d3472772fb3a36c1ee1bde028029c9ecd2d
[ "BSD-3-Clause" ]
34
2018-10-05T11:54:23.000Z
2022-03-21T06:40:49.000Z
src/pair_yukawa.h
yangyang14641/ludwig
25905b523bc67bc8f88bc757503f7e89362042af
[ "BSD-3-Clause" ]
108
2018-07-26T11:01:23.000Z
2022-03-31T07:51:10.000Z
src/pair_yukawa.h
yangyang14641/ludwig
25905b523bc67bc8f88bc757503f7e89362042af
[ "BSD-3-Clause" ]
24
2018-12-21T19:05:00.000Z
2022-03-31T07:51:32.000Z
/***************************************************************************** * * pair_yukawa.h * * Edinburgh Soft Matter and Statistical Physics Group and * Edinburgh Parallel Computing Centre * * (c) 2014-2017 The University of Edinburgh * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) * *****************************************************************************/ #ifndef LUDWIG_PAIR_YUKAWA_H #define LUDWIG_PAIR_YUKAWA_H typedef struct pair_yukawa_s pair_yukawa_t; #include "pe.h" #include "coords.h" #include "colloids.h" #include "interaction.h" int pair_yukawa_create(pe_t * pe, cs_t * cs, pair_yukawa_t ** pobj); int pair_yukawa_free(pair_yukawa_t * obj); int pair_yukawa_info(pair_yukawa_t * obj); int pair_yukawa_param_set(pair_yukawa_t * obj, double epsilon, double kappa, double rc); int pair_yukawa_register(pair_yukawa_t * obj, interact_t * parent); int pair_yukawa_compute(colloids_info_t * cinfo, void * self); int pair_yukawa_stats(void * self, double * stat); int pair_yukawa_single(pair_yukawa_t * obj, double r, double * v, double * f); #endif
31.5
79
0.635802
05b171aa46d8dda39ecf6ac0eb1d7777fc448f15
420
h
C
population_abm_package3/Quarantine_breach_model.h
aus-covid-modelling/NationalCabinetModelling-OctNov21
17f248098806cfd1b187d5e1b14a54aea45d07c9
[ "MIT" ]
8
2021-11-08T03:58:45.000Z
2021-11-16T17:02:48.000Z
population_abm_package3/Quarantine_breach_model.h
aus-covid-modelling/NationalCabinetModelling-OctNov21
17f248098806cfd1b187d5e1b14a54aea45d07c9
[ "MIT" ]
null
null
null
population_abm_package3/Quarantine_breach_model.h
aus-covid-modelling/NationalCabinetModelling-OctNov21
17f248098806cfd1b187d5e1b14a54aea45d07c9
[ "MIT" ]
null
null
null
#ifndef QUARANTINE_BREACH_MODEL #define QUARANTINE_BREACH_MODEL #include <vector> #include "../nlohmann/json.hpp" #include "../vaccine_abm/individual.h" #include "../vaccine_abm/households.h" #include "../vaccine_abm/ibm_simulation.h" #include "../vaccine_abm/USER_random.h" #include "../vaccine_abm/vaccine.h" std::vector<individual> run_model(int sim_number, std::string scenario_name, nlohmann::json & inputs); #endif
38.181818
102
0.77619
b241400ec944e1e9f3fd5d8814af23e09e341f20
1,129
h
C
project_code/of_v0.11.0_osx_release/apps/myApps/laserBomb/src/sidebar/receiveUI.h
Vamoss/devart-template
3c276f5967c24365c04dd00ed36933cc19b6f8bb
[ "Apache-2.0" ]
null
null
null
project_code/of_v0.11.0_osx_release/apps/myApps/laserBomb/src/sidebar/receiveUI.h
Vamoss/devart-template
3c276f5967c24365c04dd00ed36933cc19b6f8bb
[ "Apache-2.0" ]
null
null
null
project_code/of_v0.11.0_osx_release/apps/myApps/laserBomb/src/sidebar/receiveUI.h
Vamoss/devart-template
3c276f5967c24365c04dd00ed36933cc19b6f8bb
[ "Apache-2.0" ]
null
null
null
#pragma once #include "config.h" #include "sidebarUI.h" class receiveUI : public sidebarUI { public: ofxUILabel * incomingDataCounterLabel; double incomingDataCounter; void setup(ofxIlda::RenderTarget * ildaFbo, ofxIlda::Frame * ildaFrame) { sidebarUI::setup(220, 800, ildaFbo, ildaFrame); incomingDataCounter = 0; setGUI1(); gui1->loadSettings("GUI/settings.xml"); } void setGUI1() { gui1->addLabel("RECEIVE", OFX_UI_FONT_LARGE); gui1->addWidgetDown(new ofxUILabel("Send to port " + ofToString(config::receiverPort), OFX_UI_FONT_SMALL)); incomingDataCounterLabel = (ofxUILabel *) gui1->addWidgetDown(new ofxUILabel("Received: " + ofToString(incomingDataCounter), OFX_UI_FONT_SMALL)); ofAddListener(gui1->newGUIEvent,this,&receiveUI::guiEvent); } void guiEvent(ofxUIEventArgs &e) { string name = e.widget->getName(); int kind = e.widget->getKind(); cout << "got event from: " << name << endl; } void save() { gui1->saveSettings("GUI/settings.xml"); } };
23.520833
147
0.635075
d77f6b50d4b4afa0457c3952675afa463128a9d9
387
h
C
library/binaryIntegers/binaryIntegers.h
alexdtat/SPbU-Homework-1-semester
25070ccfba7be14766b667de1894fbc3825add0e
[ "Apache-2.0" ]
2
2021-09-14T13:17:17.000Z
2021-10-12T18:43:42.000Z
library/binaryIntegers/binaryIntegers.h
alexdtat/SPbU-Homework-1-semester
25070ccfba7be14766b667de1894fbc3825add0e
[ "Apache-2.0" ]
8
2021-09-19T14:52:33.000Z
2021-12-25T13:47:01.000Z
library/binaryIntegers/binaryIntegers.h
alexdtat/SPbU-Homework-1-semester
25070ccfba7be14766b667de1894fbc3825add0e
[ "Apache-2.0" ]
null
null
null
#ifndef HOMEWORK3_BINARYINTEGERS_H #define HOMEWORK3_BINARYINTEGERS_H #include <stdbool.h> void getBinaryForm(int number, bool* numberBinary); int getDecimalForm(bool* numberBinary); void addBinaryNumbers(bool* firstNumber, bool* secondNumber, bool* result); void multiplyBinaryNumbers(bool* firstNumber, bool* secondNumber, bool* resultNumber); #endif // HOMEWORK3_BINARYINTEGERS_H
29.769231
86
0.821705
a76dfe860e1fff710d811a06e27cf000d3528874
3,279
h
C
include/org/apache/lucene/queryparser/flexible/standard/builders/DummyQueryNodeBuilder.h
lukhnos/objclucene
29c7189a0b30ab3d3dd4c8ed148235ee296128b7
[ "MIT" ]
9
2016-01-13T05:38:05.000Z
2020-06-04T23:05:03.000Z
include/org/apache/lucene/queryparser/flexible/standard/builders/DummyQueryNodeBuilder.h
lukhnos/objclucene
29c7189a0b30ab3d3dd4c8ed148235ee296128b7
[ "MIT" ]
4
2016-05-12T10:40:53.000Z
2016-06-11T19:08:33.000Z
include/org/apache/lucene/queryparser/flexible/standard/builders/DummyQueryNodeBuilder.h
lukhnos/objclucene
29c7189a0b30ab3d3dd4c8ed148235ee296128b7
[ "MIT" ]
5
2016-01-13T05:37:39.000Z
2019-07-27T16:53:10.000Z
// // Generated by the J2ObjC translator. DO NOT EDIT! // source: ./queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/builders/DummyQueryNodeBuilder.java // #include "J2ObjC_header.h" #pragma push_macro("INCLUDE_ALL_OrgApacheLuceneQueryparserFlexibleStandardBuildersDummyQueryNodeBuilder") #ifdef RESTRICT_OrgApacheLuceneQueryparserFlexibleStandardBuildersDummyQueryNodeBuilder #define INCLUDE_ALL_OrgApacheLuceneQueryparserFlexibleStandardBuildersDummyQueryNodeBuilder 0 #else #define INCLUDE_ALL_OrgApacheLuceneQueryparserFlexibleStandardBuildersDummyQueryNodeBuilder 1 #endif #undef RESTRICT_OrgApacheLuceneQueryparserFlexibleStandardBuildersDummyQueryNodeBuilder #if __has_feature(nullability) #pragma clang diagnostic push #pragma GCC diagnostic ignored "-Wnullability" #pragma GCC diagnostic ignored "-Wnullability-completeness" #endif #if !defined (OrgApacheLuceneQueryparserFlexibleStandardBuildersDummyQueryNodeBuilder_) && (INCLUDE_ALL_OrgApacheLuceneQueryparserFlexibleStandardBuildersDummyQueryNodeBuilder || defined(INCLUDE_OrgApacheLuceneQueryparserFlexibleStandardBuildersDummyQueryNodeBuilder)) #define OrgApacheLuceneQueryparserFlexibleStandardBuildersDummyQueryNodeBuilder_ #define RESTRICT_OrgApacheLuceneQueryparserFlexibleStandardBuildersStandardQueryBuilder 1 #define INCLUDE_OrgApacheLuceneQueryparserFlexibleStandardBuildersStandardQueryBuilder 1 #include "org/apache/lucene/queryparser/flexible/standard/builders/StandardQueryBuilder.h" @class OrgApacheLuceneSearchTermQuery; @protocol OrgApacheLuceneQueryparserFlexibleCoreNodesQueryNode; /*! @brief This builder does nothing.Commonly used for <code>QueryNode</code> objects that are built by its parent's builder. - seealso: StandardQueryBuilder - seealso: QueryTreeBuilder */ @interface OrgApacheLuceneQueryparserFlexibleStandardBuildersDummyQueryNodeBuilder : NSObject < OrgApacheLuceneQueryparserFlexibleStandardBuildersStandardQueryBuilder > #pragma mark Public /*! @brief Constructs a <code>DummyQueryNodeBuilder</code> object. */ - (instancetype __nonnull)init; /*! @brief Always return <code>null</code>. return <code>null</code> */ - (OrgApacheLuceneSearchTermQuery *)buildWithOrgApacheLuceneQueryparserFlexibleCoreNodesQueryNode:(id<OrgApacheLuceneQueryparserFlexibleCoreNodesQueryNode>)queryNode; @end J2OBJC_EMPTY_STATIC_INIT(OrgApacheLuceneQueryparserFlexibleStandardBuildersDummyQueryNodeBuilder) FOUNDATION_EXPORT void OrgApacheLuceneQueryparserFlexibleStandardBuildersDummyQueryNodeBuilder_init(OrgApacheLuceneQueryparserFlexibleStandardBuildersDummyQueryNodeBuilder *self); FOUNDATION_EXPORT OrgApacheLuceneQueryparserFlexibleStandardBuildersDummyQueryNodeBuilder *new_OrgApacheLuceneQueryparserFlexibleStandardBuildersDummyQueryNodeBuilder_init(void) NS_RETURNS_RETAINED; FOUNDATION_EXPORT OrgApacheLuceneQueryparserFlexibleStandardBuildersDummyQueryNodeBuilder *create_OrgApacheLuceneQueryparserFlexibleStandardBuildersDummyQueryNodeBuilder_init(void); J2OBJC_TYPE_LITERAL_HEADER(OrgApacheLuceneQueryparserFlexibleStandardBuildersDummyQueryNodeBuilder) #endif #if __has_feature(nullability) #pragma clang diagnostic pop #endif #pragma pop_macro("INCLUDE_ALL_OrgApacheLuceneQueryparserFlexibleStandardBuildersDummyQueryNodeBuilder")
45.541667
268
0.891125
44330aa7ec5359f23e62a41261821034fce998c9
357
h
C
SpotNews/SpotNews/Src/Commons/Categoty/NSString+Str.h
huangwenguang/SpotNews
7d9a6076e20fed5e2796dfcd73737a44e085c61f
[ "Apache-2.0" ]
null
null
null
SpotNews/SpotNews/Src/Commons/Categoty/NSString+Str.h
huangwenguang/SpotNews
7d9a6076e20fed5e2796dfcd73737a44e085c61f
[ "Apache-2.0" ]
null
null
null
SpotNews/SpotNews/Src/Commons/Categoty/NSString+Str.h
huangwenguang/SpotNews
7d9a6076e20fed5e2796dfcd73737a44e085c61f
[ "Apache-2.0" ]
1
2019-06-12T11:42:31.000Z
2019-06-12T11:42:31.000Z
// // NSString+SY.h // SanYouDemo // // Created by hwg on 15/9/22. // Copyright (c) 2015年 sanyou. All rights reserved. // #import <Foundation/Foundation.h> #import <CommonCrypto/CommonDigest.h> @interface NSString (Str) - (BOOL) isEmptyString; - (NSString *) trim; - (CGSize)sizeWithFont:(UIFont *)font maxSize:(CGSize)maxSize; - (NSString *)md5; @end
21
62
0.691877
67fa0d9807b88c45a1246b454b9531132365310b
1,571
h
C
apps/generated_areas/include/mc_conversion_polyconversiondetails_list.h
georgeslabreche/ccsdsmo-malc
c22389af78ddc8ceddcbb262afcb213ef50226ff
[ "MIT" ]
null
null
null
apps/generated_areas/include/mc_conversion_polyconversiondetails_list.h
georgeslabreche/ccsdsmo-malc
c22389af78ddc8ceddcbb262afcb213ef50226ff
[ "MIT" ]
65
2021-08-30T23:10:05.000Z
2022-03-27T19:50:33.000Z
apps/generated_areas/include/mc_conversion_polyconversiondetails_list.h
tanagraspace/ccsdsmo-malc-sepp-apps
f616b3e06522ea995e12904161ce3d298e96f6ff
[ "MIT" ]
null
null
null
#ifndef __MC_CONVERSION_POLYCONVERSIONDETAILS_LIST_H_INCLUDED__ #define __MC_CONVERSION_POLYCONVERSIONDETAILS_LIST_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // __cplusplus // default constructor mc_conversion_polyconversiondetails_list_t * mc_conversion_polyconversiondetails_list_new(unsigned int element_count); // destructor, free the list, its content and its elements void mc_conversion_polyconversiondetails_list_destroy(mc_conversion_polyconversiondetails_list_t ** self_p); // fields accessors for composite list mc_conversion_polyconversiondetails_list unsigned int mc_conversion_polyconversiondetails_list_get_element_count(mc_conversion_polyconversiondetails_list_t * self); mc_conversion_polyconversiondetails_t ** mc_conversion_polyconversiondetails_list_get_content(mc_conversion_polyconversiondetails_list_t * self); // encoding functions related to transport malbinary int mc_conversion_polyconversiondetails_list_add_encoding_length_malbinary(mc_conversion_polyconversiondetails_list_t * self, mal_encoder_t * encoder, void * cursor); int mc_conversion_polyconversiondetails_list_encode_malbinary(mc_conversion_polyconversiondetails_list_t * self, mal_encoder_t * encoder, void * cursor); int mc_conversion_polyconversiondetails_list_decode_malbinary(mc_conversion_polyconversiondetails_list_t * self, mal_decoder_t * decoder, void * cursor); // test function void mc_conversion_polyconversiondetails_list_test(bool verbose); #ifdef __cplusplus } #endif // __cplusplus #endif // __MC_CONVERSION_POLYCONVERSIONDETAILS_LIST_H_INCLUDED__
49.09375
166
0.880968
9c8533594bb7c9395cee0335dcc42f3a75b40eb3
1,162
c
C
siod_progress.c
ssmore98/siod
5e1bd2691710ebaf49223d52894c2b08aa958112
[ "Unlicense" ]
null
null
null
siod_progress.c
ssmore98/siod
5e1bd2691710ebaf49223d52894c2b08aa958112
[ "Unlicense" ]
null
null
null
siod_progress.c
ssmore98/siod
5e1bd2691710ebaf49223d52894c2b08aa958112
[ "Unlicense" ]
null
null
null
#include <stdio.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> #include "siod.h" /* * exit codes * 0 : no error * 1 : no SIOD running * 2 : lockfile error * 3 : shm error */ int main(int argc, char **argv) { FILE * const fp = fopen(lockfile, "r"); if (!fp) { if (ENOENT == errno) { return 1; } fprintf(stderr, "lockfile(fopen): %s\n", strerror(errno)); return 2; } pid_t pid = 0; if (1 != fscanf(fp, "%d", &pid)) { fprintf(stderr, "lockfile(fscanf): %s\n", strerror(errno)); return 2; } const int shmd = shmget(pid, 0, 0); if (0 > shmd) { fprintf(stderr, "shmget: %s", strerror(errno)); return 3; } struct shmid_ds buf; shmctl(shmd, IPC_STAT, &buf); const size_t realSize = buf.shm_segsz; const char * const shm_status = (char *)shmat(shmd, NULL, 0); if ((char *)-1 == shm_status) { fprintf(stderr, "shmat: %s", strerror(errno)); return 3; } for (size_t i = 0; i < realSize; i++) { printf("%u ", (unsigned int)(shm_status[i])); } printf("\n"); if (shmdt(shm_status)) { fprintf(stderr, "shmdt: %s", strerror(errno)); return 3; } return 0; }
21.518519
62
0.601549
f352abe86f2dddada7569ad1575f86da986723e1
6,772
h
C
src/RIOT/sys/include/suit.h
ARte-team/ARte
19f17f57522e1b18ba390718fc94be246451837b
[ "MIT" ]
2
2020-04-30T08:17:45.000Z
2020-05-23T08:46:54.000Z
src/RIOT/sys/include/suit.h
ARte-team/ARte
19f17f57522e1b18ba390718fc94be246451837b
[ "MIT" ]
null
null
null
src/RIOT/sys/include/suit.h
ARte-team/ARte
19f17f57522e1b18ba390718fc94be246451837b
[ "MIT" ]
null
null
null
/* * Copyright (C) 2019 Koen Zandberg * 2019 Kaspar Schleiser <kaspar@schleiser.de> * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level * directory for more details. */ /** * @defgroup sys_suit SUIT secure firmware OTA upgrade infrastructure * @ingroup sys * @brief SUIT manifest handling * * @experimental * * @note The current implementation of this specification is based on the * IETF-SUIT-v3 draft. The module is still experimental and will change to * match future draft specifications * * @see https://tools.ietf.org/html/draft-ietf-suit-manifest-03 * * @{ * * @brief Handler functions for SUIT manifests * @author Koen Zandberg <koen@bergzand.net> * @author Kaspar Schleiser <kaspar@schleiser.de> * */ #ifndef SUIT_H #define SUIT_H #include <stddef.h> #include <stdint.h> #include "cose/sign.h" #include "nanocbor/nanocbor.h" #include "uuid.h" #include "riotboot/flashwrite.h" #ifdef __cplusplus extern "C" { #endif /** * @brief Buffer size used for Cose */ #ifndef SUIT_COSE_BUF_SIZE #define SUIT_COSE_BUF_SIZE (180U) #endif /** * @brief Maximum number of components supported in a SUIT manifest */ #define SUIT_COMPONENT_MAX (1U) /** * @brief Current SUIT serialization format version * * see https://tools.ietf.org/html/draft-ietf-suit-manifest-03#section-7 for * details */ #define SUIT_VERSION (1) /** * @brief COSE signature OK */ #define SUIT_STATE_COSE_AUTHENTICATED (1 << 1) /** * @brief COSE payload matches SUIT manifest digest */ #define SUIT_STATE_FULLY_AUTHENTICATED (1 << 2) /** * @brief SUIT error codes */ typedef enum { SUIT_OK = 0, /**< Manifest parsed and validated */ SUIT_ERR_INVALID_MANIFEST = -1, /**< Unexpected CBOR structure detected */ SUIT_ERR_UNSUPPORTED = -2, /**< Unsupported SUIT feature detected */ SUIT_ERR_NOT_SUPPORTED = -3, /**< Unsupported features detected */ SUIT_ERR_COND = -4, /**< Conditionals evaluate to false */ SUIT_ERR_SEQUENCE_NUMBER = -5, /**< Sequence number less or equal to current sequence number */ SUIT_ERR_SIGNATURE = -6, /**< Unable to verify signature */ SUIT_ERR_DIGEST_MISMATCH = -7, /**< Digest mismatch with COSE and SUIT */ } suit_error_t; /** * @brief SUIT payload digest algorithms * * Unofficial list from * [suit-manifest-generator](https://github.com/ARMmbed/suit-manifest-generator) */ typedef enum { SUIT_DIGEST_NONE = 0, /**< No digest algo supplied */ SUIT_DIGEST_SHA256 = 1, /**< SHA256 */ SUIT_DIGEST_SHA384 = 2, /**< SHA384 */ SUIT_DIGEST_SHA512 = 3, /**< SHA512 */ } suit_digest_t; /** * @brief SUIT payload digest types * * Unofficial list from * [suit-manifest-generator](https://github.com/ARMmbed/suit-manifest-generator) */ typedef enum { SUIT_DIGEST_TYPE_RAW = 1, /**< Raw payload digest */ SUIT_DIGEST_TYPE_INSTALLED = 2, /**< Installed firmware digest */ SUIT_DIGEST_TYPE_CIPHERTEXT = 3, /**< Ciphertext digest */ SUIT_DIGEST_TYPE_PREIMAGE = 4 /**< Pre-image digest */ } suit_digest_type_t; /** * @brief SUIT component types * * Unofficial list from * [suit-manifest-generator](https://github.com/ARMmbed/suit-manifest-generator) */ enum { SUIT_COMPONENT_IDENTIFIER = 1, /**< Identifier component */ SUIT_COMPONENT_SIZE = 2, /**< Size component */ SUIT_COMPONENT_DIGEST = 3, /**< Digest component */ }; /** * @brief SUIT component struct */ typedef struct { uint32_t size; /**< Size */ nanocbor_value_t identifier; /**< Identifier */ nanocbor_value_t url; /**< Url */ nanocbor_value_t digest; /**< Digest */ } suit_component_t; /** * @brief SUIT manifest struct */ typedef struct { const uint8_t *buf; /**< ptr to the buffer of the manifest */ size_t len; /**< length of the manifest */ const uint8_t *cose_payload; /**< ptr to the payload of the COSE sign */ size_t cose_payload_len; /**< length of the COSE payload */ uint32_t validated; /**< bitfield of validated policies */ uint32_t state; /**< bitfield holding state information */ /** List of components in the manifest */ suit_component_t components[SUIT_COMPONENT_MAX]; unsigned components_len; /**< Current number of components */ uint32_t component_current; /**< Current component index */ riotboot_flashwrite_t *writer; /**< Pointer to the riotboot flash writer */ /** Manifest validation buffer */ uint8_t validation_buf[SUIT_COSE_BUF_SIZE]; char *urlbuf; /**< Buffer containing the manifest url */ size_t urlbuf_len; /**< Length of the manifest url */ } suit_manifest_t; /** * @brief Bit flags used to determine if SUIT manifest contains components */ #define SUIT_MANIFEST_HAVE_COMPONENTS (0x1) /** * @brief Bit flags used to determine if SUIT manifest contains an image */ #define SUIT_MANIFEST_HAVE_IMAGE (0x2) /** * @brief Parse a manifest * * @note The buffer is still required after parsing, please don't reuse the * buffer while the @p manifest is used * * @param[in] manifest manifest context to store information in * @param[in] buf buffer to parse the manifest from * @param[in] len length of the manifest data in the buffer * * @return SUIT_OK on parseable manifest * @return negative @ref suit_error_t code on error */ int suit_parse(suit_manifest_t *manifest, const uint8_t *buf, size_t len); /** * @brief Check a manifest policy * * @param[in] manifest manifest context to check the policy for * * @return 0 on valid manifest policy * @return -1 on invalid manifest policy */ int suit_policy_check(suit_manifest_t *manifest); /** * @brief Helper function for writing bytes on flash a specified offset * * @param[in] arg ptr to the SUIT manifest * @param[in] offset offset to write to on flash * @param[in] buf bytes to write * @param[in] len length of bytes to write * @param[in] more whether more data is coming * * @return 0 on success * @return <0 on error */ int suit_flashwrite_helper(void *arg, size_t offset, uint8_t *buf, size_t len, int more); #ifdef __cplusplus } #endif #endif /* SUIT_H */ /** @} */
31.64486
80
0.635558
476ccaccf71e98b51bc68001e924e8e20de9dd98
1,063
h
C
embedded-development/motordriver/include/motordriver.h
Halodi/halodi-recruitment-challenges
72976e6271dbd9b4e132e670bbb10ab3bec9fbd8
[ "Apache-2.0" ]
3
2021-08-19T15:05:25.000Z
2021-11-04T16:49:40.000Z
embedded-development/motordriver/include/motordriver.h
Halodi/halodi-recruitment-challenges
72976e6271dbd9b4e132e670bbb10ab3bec9fbd8
[ "Apache-2.0" ]
null
null
null
embedded-development/motordriver/include/motordriver.h
Halodi/halodi-recruitment-challenges
72976e6271dbd9b4e132e670bbb10ab3bec9fbd8
[ "Apache-2.0" ]
1
2021-09-29T21:01:31.000Z
2021-09-29T21:01:31.000Z
#ifndef MOTORDRIVER_H #define MOTORDRIVER_H #include <cstdint> enum MotorDriverRegisters { UNDEFINED = 0x0, STATUSWORD = 0x1, CONTROLWORD = 0x2, ENCODER_VALUE = 0x3, MOTOR_VELOCITY_COMMAND = 0x4, OUTPUT_ENABLE = 0x5, FAULT = 0x6, RESET = 0x7, REGISTERS_MAX_VALUE }; enum MotorState { STATE_BOOT = 0x0, STATE_PREOP = 0x1, STATE_SAFEOP = 0x11, STATE_OP = 0x20 }; const uint16_t STATUS_ERROR = 0x8000; /** * @brief The MotorDriver class * * This is the main class implementing the motor driver communication * */ class MotorDriver { public: /** * @brief MotorDriver * * Constructor. Creates the MotorDriver * */ MotorDriver(); /** * @brief transferData Transfer data over the Synchronous Protocol * @param data Data to send * @return Received data */ uint32_t transferData(uint32_t data); /** * @brief update Call this function cyclically to simulate a seperate slave */ void update(); }; #endif /* MOTORDRIVER_H */
16.106061
79
0.64158
7050d5ad25dc3acf20533e55a0aabb328dadf8e0
1,532
h
C
printscan/print/drivers/usermode/lib/ufl/api/ufocff.h
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
printscan/print/drivers/usermode/lib/ufl/api/ufocff.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
printscan/print/drivers/usermode/lib/ufl/api/ufocff.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
/* * Adobe Universal Font Library * * Copyright (c) 1996 Adobe Systems Inc. * All Rights Reserved * * UFOCFF.h -- Universal Font Object to be used w/ CFF font. * * * $Header: */ #ifndef _H_UFOCFF #define _H_UFOCFF /* * Special postfix, CDevProc, and guestimation value for Metrics2 size * used when printing on %hostfont% RIP with bug #388111. */ #define HFPOSTFIX "-hf" #define HFCIDCDEVPROC "{pop 4 index add}bind" #define HFVMM2SZ 20 /* About 4% of kVMTTT1Char; this, too, is a guestmation value. */ /*============================================================================* * Include files used by this interface * *============================================================================*/ #include "UFO.h" #include "xcf_pub.h" typedef struct tagCFFFontStruct { XFhandle hFont; UFLCFFFontInfo info; UFLCFFReadBuf *pReadBuf; } CFFFontStruct; UFOStruct* CFFFontInit( const UFLMemObj* pMem, const UFLStruct* pUFL, const UFLRequest* pRequest, UFLBool* pTestRestricted ); UFLErrCode CFFCreateBaseFont( UFOStruct *pUFObj, const UFLGlyphsInfo *pGlyphs, unsigned long *pVMUsage, char *pHostFontName ); UFLErrCode CFFGIDsToCIDs( const CFFFontStruct* pFont, const short cGlyphs, const UFLGlyphID* pGIDs, unsigned short* pCIDs ); #endif
23.569231
87
0.537206
f2de4b71e44fc5e2766761ecf4abcda194d2c1a9
176
h
C
Carthage/Checkouts/MWPhotoBrowser/Example/Pods/Target Support Files/Pods-MWPhotoBrowser_Example/Pods-MWPhotoBrowser_Example-umbrella.h
EasySwift/EasySwift
898647e4540bb89913530c6ae285db2cd8fa3397
[ "Apache-2.0" ]
16
2016-08-19T09:55:49.000Z
2021-08-24T01:55:36.000Z
Carthage/Checkouts/MWPhotoBrowser/Example/Pods/Target Support Files/Pods-MWPhotoBrowser_Example/Pods-MWPhotoBrowser_Example-umbrella.h
mohsinalimat/EasySwift
898647e4540bb89913530c6ae285db2cd8fa3397
[ "Apache-2.0" ]
2
2016-10-22T17:12:12.000Z
2018-09-25T08:11:23.000Z
Carthage/Checkouts/MWPhotoBrowser/Example/Pods/Target Support Files/Pods-MWPhotoBrowser_Example/Pods-MWPhotoBrowser_Example-umbrella.h
mohsinalimat/EasySwift
898647e4540bb89913530c6ae285db2cd8fa3397
[ "Apache-2.0" ]
3
2016-09-25T07:45:14.000Z
2018-12-12T08:09:56.000Z
#import <UIKit/UIKit.h> FOUNDATION_EXPORT double Pods_MWPhotoBrowser_ExampleVersionNumber; FOUNDATION_EXPORT const unsigned char Pods_MWPhotoBrowser_ExampleVersionString[];
25.142857
81
0.875
d169713a81f53f20a568c5c64cec5da2d4e8c039
390
h
C
Sailing/TBEnums.h
liubin9959/sailing
00998cc0d65a7d892224d09c46763178dc3c75e4
[ "MIT" ]
1
2015-12-19T13:40:12.000Z
2015-12-19T13:40:12.000Z
Sailing/TBEnums.h
liubin9959/sailing
00998cc0d65a7d892224d09c46763178dc3c75e4
[ "MIT" ]
null
null
null
Sailing/TBEnums.h
liubin9959/sailing
00998cc0d65a7d892224d09c46763178dc3c75e4
[ "MIT" ]
null
null
null
// // enums.h // Sailing // // Created by tomaszbrue on 03.11.13. // Copyright (c) 2013 Thomas Brüggemann. All rights reserved. // #ifndef Sailing_enums_h #define Sailing_enums_h enum SIDE { Portside = 0, Starboard = 1, Either = 2, Spilling = 3 }; enum COURSE { InIrons = 0, CloseHauled = 1, BeamReach = 2, BroadReach = 3, Running = 4 }; #endif
12.580645
62
0.605128
4ae72adcdeaa980f899396c571328a4d397f2981
242
h
C
Artificial I/Classes/Artificial/Mirage/MirageEnums.h
BostjanSkok/TINR
e348fc1df58ed13e3924fd98a89201b3d4a25832
[ "MIT" ]
null
null
null
Artificial I/Classes/Artificial/Mirage/MirageEnums.h
BostjanSkok/TINR
e348fc1df58ed13e3924fd98a89201b3d4a25832
[ "MIT" ]
null
null
null
Artificial I/Classes/Artificial/Mirage/MirageEnums.h
BostjanSkok/TINR
e348fc1df58ed13e3924fd98a89201b3d4a25832
[ "MIT" ]
null
null
null
typedef enum { HorizontalAlignCustom, HorizontalAlignLeft, HorizontalAlignCenter, HorizontalAlignRight } HorizontalAlign; typedef enum { VerticalAlignCustom, VerticalAlignTop, VerticalAlignMiddle, VerticalAlignBottom } VerticalAlign;
18.615385
23
0.842975
2be50914dd3a190b0934c44dcadf827436e4d528
182
h
C
Chapter07/sim/test/devices/mhz19.h
PacktPublishing/Hands-On-Embedded-Programming-with-CPP-17
a9e11ab66bbe1e022c3c620b58e8599305dfaa64
[ "MIT" ]
37
2019-03-04T14:01:19.000Z
2022-03-27T22:53:49.000Z
Chapter07/sim/test/devices/mhz19.h
PacktPublishing/Hands-On-Embedded-Programming-with-CPP-17
a9e11ab66bbe1e022c3c620b58e8599305dfaa64
[ "MIT" ]
1
2019-03-11T13:40:13.000Z
2020-09-21T05:31:23.000Z
Chapter07/sim/test/devices/mhz19.h
PacktPublishing/Hands-On-Embedded-Programming-with-CPP-17
a9e11ab66bbe1e022c3c620b58e8599305dfaa64
[ "MIT" ]
16
2019-03-08T15:27:01.000Z
2021-12-27T08:45:32.000Z
/* mhz19.h - Header file for the MHZ19 class. Revision 0 Notes: - 2018/09/18, Maya Posch */ #include "sensor.h" class MHZ19 : public Sensor { // public: // };
8.666667
43
0.576923
00edd38cb29d92fe8ee96bcd5395eb9f68cd6363
343
h
C
tetra.h
tflovorn/ctetra
1a788d6c36d4a0773d4a2fca4d23a8e4d1fd87a1
[ "MIT" ]
null
null
null
tetra.h
tflovorn/ctetra
1a788d6c36d4a0773d4a2fca4d23a8e4d1fd87a1
[ "MIT" ]
1
2016-11-19T22:44:14.000Z
2016-11-30T15:23:35.000Z
tetra.h
tflovorn/ctetra
1a788d6c36d4a0773d4a2fca4d23a8e4d1fd87a1
[ "MIT" ]
null
null
null
#ifndef CTETRA_TETRA_H #define CTETRA_TETRA_H #include <stdlib.h> #include <gsl/gsl_vector.h> #include "ecache.h" typedef double (*tetra_SumFn)(double E, double E1, double E2, double E3, double E4, double num_tetra); double tetra_SumTetra(tetra_SumFn F, double E, EnergyCache *Ecache); void sortEs(double Es[4]); #endif // CTETRA_TETRA_H
22.866667
102
0.760933
785209cb0e55607bb2e9d37ba01a0cfda2d08251
7,020
h
C
gui/settings_stats.h
makkrnic/simutrans-extended
8afbbce5b88c79bfea1760cf6c7662d020757b6a
[ "Artistic-1.0" ]
null
null
null
gui/settings_stats.h
makkrnic/simutrans-extended
8afbbce5b88c79bfea1760cf6c7662d020757b6a
[ "Artistic-1.0" ]
null
null
null
gui/settings_stats.h
makkrnic/simutrans-extended
8afbbce5b88c79bfea1760cf6c7662d020757b6a
[ "Artistic-1.0" ]
null
null
null
/* * This file is part of the Simutrans-Extended project under the Artistic License. * (see LICENSE.txt) */ #ifndef GUI_SETTINGS_STATS_H #define GUI_SETTINGS_STATS_H #include <math.h> #include "../tpl/vector_tpl.h" #include "../tpl/array_tpl.h" #include "../utils/cbuffer_t.h" #include "components/gui_container.h" #include "components/gui_component.h" #include "components/gui_numberinput.h" #include "components/gui_component_table.h" #include "components/gui_label.h" #include "components/gui_textarea.h" #include "components/action_listener.h" #include "components/gui_combobox.h" class settings_t; /* With the following macros, elements could be added to the property lists. * ATTENTION: In the init and read procedures, the order of the items MUST be identical! */ // call this before any init is done ... #define INIT_INIT \ width = 18;\ height = 0;\ sint16 ypos = 4;\ remove_all();\ free_all();\ separator = 0;\ new_world = (win_get_magic( magic_welt_gui_t )!=NULL);\ #define INIT_NUM(t,a,b,c,d,e) \ {\ width = max(width, proportional_string_width(t)+68);\ gui_numberinput_t *ni = new gui_numberinput_t();\ ni->init( (sint32)(a), (b), (c), (d), (e) );\ ni->set_pos( scr_coord( 0, ypos ) );\ ni->set_size( scr_size( 37+7*max(1,(sint16)(log10((double)(c)+1.0)+0.5)), D_EDIT_HEIGHT ) );\ numinp.append( ni );\ add_component( ni );\ gui_label_t *lb = new gui_label_t();\ lb->set_text_pointer(t);\ lb->align_to(ni, ALIGN_CENTER_V + ALIGN_EXTERIOR_H + ALIGN_LEFT, scr_coord(D_H_SPACE,0) );\ label.append( lb );\ add_component( lb );\ ypos += D_EDIT_HEIGHT;\ }\ #define INIT_NUM_NEW(t,a,b,c,d,e) if( new_world ) INIT_NUM( (t), (a), (b), (c), (d) , (e) ) #define INIT_COST(t,a,b,c,d,e) \ {\ width = max(width, proportional_string_width(t)+68);\ gui_numberinput_t *ni = new gui_numberinput_t();\ ni->init( (sint32)( (a)/(sint64)100 ), (b), (c), (d), (e) );\ ni->set_pos( scr_coord( 0, ypos ) );\ ni->set_size( scr_size( 37+7*max(1,(sint16)(log10((double)(c)+1.0)+0.5)), D_EDIT_HEIGHT ) );\ numinp.append( ni );\ add_component( ni );\ gui_label_t *lb = new gui_label_t();\ lb->set_text_pointer(t);\ lb->align_to(ni, ALIGN_CENTER_V + ALIGN_EXTERIOR_H + ALIGN_LEFT, scr_coord(D_H_SPACE,0) );\ label.append( lb );\ add_component( lb );\ ypos += D_EDIT_HEIGHT;\ }\ #define INIT_COST_NEW(t,a,b,c,d,e) if( new_world ) INIT_COST( (t), (a), (b), (c), (d) , (e) ) #define INIT_LB(t) \ {\ width = max(width, proportional_string_width(t)+6);\ gui_label_t *lb = new gui_label_t();\ lb->set_text_pointer(t);\ lb->set_pos( scr_coord( 0, ypos ) );\ label.append( lb );\ add_component( lb );\ ypos += LINESPACE;\ }\ #define INIT_LB_NEW(t) if( new_world ) INIT_LB( (t) ) #define INIT_BOOL(t,a) \ {\ width = max(width, proportional_string_width(t)+22);\ button_t *bt = new button_t();\ bt->init( button_t::square_automatic, (t), scr_coord( 0, ypos ) );\ bt->pressed = (a);\ button.append( bt );\ add_component( bt );\ ypos += D_CHECKBOX_HEIGHT;\ }\ #define INIT_BOOL_NEW(t,a) if( new_world ) INIT_BOOL( (t), (a) ) #define SEPERATOR \ ypos += D_V_SPACE;\ separator += 1;\ // call this before and READ_... #define READ_INIT \ slist_tpl<gui_numberinput_t*>::const_iterator numiter = numinp.begin(); \ slist_tpl<button_t*>::const_iterator booliter = button.begin(); #define READ_NUM(t) (t)((*numiter++)->get_value()) #define READ_NUM2(t,expr) (t)( numiter.get_current()->get_value() expr) #define READ_NUM_NEW(t) if(new_world) { READ_NUM(t); } #define READ_COST(t) (t)((sint64)((*numiter++)->get_value()) * 100) #define READ_NUM_ARRAY(t, i) (t)((i), numiter.get_current()->get_value() ) #define READ_NUM_VALUE(t) (t) = (*numiter++)->get_value() #define READ_NUM_VALUE_TENTHS(t) (t) = (*numiter++)->get_value() * 10 #define READ_NUM_VALUE_NEW(t) if(new_world) { READ_NUM_VALUE(t); } #define READ_COST_VALUE(t) (t) = (sint64)((*numiter++)->get_value()) * 100 #define READ_COST_VALUE_NEW(t) if(new_world) { READ_COST_VALUE(t); } #define READ_BOOL(t) (t)((*booliter++)->pressed) #define READ_BOOL_NEW(t) if(new_world) { READ_BOOL(t); } #define READ_BOOL_VALUE(t) (t) = (*booliter++)->pressed #define READ_BOOL_VALUE_NEW(t) if(new_world) { READ_BOOL_VALUE(t); } /** * Settings for property lists ... * @author Hj. Malthaner */ class settings_stats_t : public gui_container_t { protected: sint16 width, height, separator; bool new_world; // since the copy constructor will no copy the right action listener => pointer slist_tpl<gui_label_t *> label; slist_tpl<gui_numberinput_t *> numinp; slist_tpl<button_t *> button; slist_tpl<gui_component_table_t *> table; list_tpl<gui_component_t> others; gui_label_t& new_label(const scr_coord& pos, const char *text); gui_textarea_t& new_textarea(const scr_coord& pos, const char *text); gui_numberinput_t& new_numinp(const scr_coord& pos, sint32 value, sint32 min, sint32 max, sint32 mode = gui_numberinput_t::AUTOLINEAR, bool wrap = false); button_t& new_button(const scr_coord& pos, const char *text, bool pressed); gui_component_table_t& new_table(const scr_coord& pos, coordinate_t columns, coordinate_t rows); void set_cell_component(gui_component_table_t &tbl, gui_component_t &c, coordinate_t x, coordinate_t y); void free_all(); public: settings_stats_t() { width = 18; } virtual ~settings_stats_t() { free_all(); } void init(settings_t const*); void read(settings_t const*); scr_size get_size() const { return scr_size(width,height); } }; // the only task left are the respective init/reading routines class settings_general_stats_t : public settings_stats_t, public action_listener_t { gui_combobox_t savegame; gui_combobox_t savegame_ex; gui_combobox_t savegame_ex_rev; public: // needed for savegame combobox bool action_triggered(gui_action_creator_t*, value_t) OVERRIDE; void init(settings_t const*); void read(settings_t*); }; class settings_display_stats_t : public settings_stats_t { public: void init(settings_t const*); void read(settings_t*); }; class settings_routing_stats_t : public settings_stats_t { public: void init(settings_t const*); void read(settings_t*); }; class settings_economy_stats_t : public settings_stats_t { public: void init(settings_t const*); void read(settings_t*); }; class settings_costs_stats_t : public settings_stats_t { public: void init(settings_t const*); void read(settings_t*); }; class settings_climates_stats_t : public settings_stats_t, public action_listener_t { private: cbuffer_t buf; settings_t* local_sets; public: void init(settings_t*); void read(settings_t*); bool action_triggered(gui_action_creator_t*, value_t) OVERRIDE; }; class settings_extended_general_stats_t : public settings_stats_t { public: void init( settings_t *sets ); void read( settings_t *sets ); }; class settings_extended_revenue_stats_t : public settings_stats_t { public: void init( settings_t *sets ); void read( settings_t *sets ); }; #endif
29.495798
155
0.707977
7ac9e29b88bc63d6c3c15476a4b43477e80c68c1
341
h
C
include/jspec2/rms_dynamic.h
mbruker/jspec2-python
c82b41cf0a314f15eb84ab15b0de96ac2992bf9c
[ "Unlicense" ]
null
null
null
include/jspec2/rms_dynamic.h
mbruker/jspec2-python
c82b41cf0a314f15eb84ab15b0de96ac2992bf9c
[ "Unlicense" ]
null
null
null
include/jspec2/rms_dynamic.h
mbruker/jspec2-python
c82b41cf0a314f15eb84ab15b0de96ac2992bf9c
[ "Unlicense" ]
null
null
null
#ifndef RMS_DYNAMIC_H_INCLUDED #define RMS_DYNAMIC_H_INCLUDED #include "jspec2/simulator.h" class RMSModel:public Simulator { private: void update_ibeam(IonBeam& ionBeam, ElectronBeam& ebeam, double dt) override; void adjust_rf_voltage() override; public: using Simulator::Simulator; }; #endif // RMS_DYNAMIC_H_INCLUDED
18.944444
82
0.768328
93958b5c71d9c20c1f0eb73645f6f44bc1837ac2
4,205
h
C
hal/include/hthread/mutex/hardware.h
eugenecartwright/hthreads
826c495dd855f8fcc1e12e1ac01845c2983ecf04
[ "BSD-3-Clause" ]
3
2018-02-14T23:24:45.000Z
2022-03-30T18:48:06.000Z
include/hthread/mutex/hardware.h
eugenecartwright/hthreads
826c495dd855f8fcc1e12e1ac01845c2983ecf04
[ "BSD-3-Clause" ]
null
null
null
include/hthread/mutex/hardware.h
eugenecartwright/hthreads
826c495dd855f8fcc1e12e1ac01845c2983ecf04
[ "BSD-3-Clause" ]
null
null
null
/************************************************************************************ * Copyright (c) 2015, University of Arkansas - Hybridthreads Group * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * Neither the name of the University of Arkansas nor the name of the * Hybridthreads Group 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. ************************************************************************************/ /** \file hardware.h */ #ifndef _HYBRID_THREADS_MUTEX_HARDWARE_H_ #define _HYBRID_THREADS_MUTEX_HARDWARE_H_ #include <debug.h> #include <util/rops.h> #include <mutex/commands.h> #include <htconst.h> #define HT_SEM_RESERVE 5 #define HT_SEM_MAXNUM (((1 << MUTEX_BITS) - 1) - HT_SEM_RESERVE) static inline Hint _mutex_acquire( Huint tid, Huint mid ) { Huint cmd; Huint sta; cmd = mutex_cmd( HT_MUTEX_LOCK, tid, mid ); sta = read_reg( cmd ); TRACE_PRINTF(TRACE_FINE,TRACE_MUTEX,"LOCK: (CMD=0x%8.8x) (TID=%u) (MID=%u) (STA=0x%8.8x)\n",cmd,tid,mid,sta); return sta; } static inline Hint _mutex_tryacquire( Huint tid, Huint mid ) { Huint cmd; Huint sta; cmd = mutex_cmd( HT_MUTEX_TRY, tid, mid ); sta = read_reg( cmd ); TRACE_PRINTF(TRACE_FINE,TRACE_MUTEX,"TRYLOCK: (CMD=0x%8.8x) (TID=%u) (MID=%u) (STA=0x%8.8x)\n",cmd,tid,mid,sta); if( mutex_error(sta) ) return FAILURE; else return SUCCESS; } static inline void _mutex_release( Huint tid, Huint mid ) { Huint cmd; Huint sta; cmd = mutex_cmd( HT_MUTEX_UNLOCK, tid, mid ); sta = read_reg( cmd ); TRACE_PRINTF(TRACE_FINE,TRACE_MUTEX,"UNLOCK: (CMD=0x%8.8x) (TID=%u) (MID=%u) (STA=0x%8.8x)\n",cmd,tid,mid,sta); } static inline Huint _mutex_owner( Huint mid ) { Huint cmd; Huint sta; cmd = mutex_cmd( HT_MUTEX_OWNER, 0, mid ); sta = read_reg( cmd ); TRACE_PRINTF(TRACE_FINE,TRACE_MUTEX,"OWNER: (CMD=0x%8.8x) (MID=%u) (STA=0x%8.8x)\n",cmd,mid,sta); return mutex_owner(sta); } static inline Huint _mutex_count( Huint mid ) { Huint cmd; Huint sta; cmd = mutex_cmd( HT_MUTEX_COUNT, 0, mid ); sta = read_reg( cmd ); TRACE_PRINTF(TRACE_FINE,TRACE_MUTEX,"COUNT: (CMD=0x%8.8x) (MID=%u) (STA=0x%8.8x)\n",cmd,mid,sta); return mutex_count(sta); } static inline Huint _mutex_kind( Huint mid ) { Huint cmd; Huint sta; cmd = mutex_cmd( HT_MUTEX_KIND, 0, mid ); sta = read_reg( cmd ); TRACE_PRINTF(TRACE_FINE,TRACE_MUTEX,"KIND: (CMD=0x%8.8x) (MID=%u) (STA=0x%8.8x)\n",cmd,mid,sta); return mutex_kind(sta); } static inline void _mutex_setkind( Huint mid, Huint kind ) { Huint cmd; cmd = mutex_cmd( HT_MUTEX_KIND, 0, mid ); write_reg( cmd, kind ); TRACE_PRINTF(TRACE_FINE,TRACE_MUTEX,"SETKIND: (CMD=0x%8.8x) (MID=%u)\n",cmd,mid); } #endif
33.110236
116
0.669917
1acf952377b6467eb113366f90c33ed9a0c77579
3,468
h
C
SRC/COMMON/ITTI_ANALYZER/libui/ui_tree_view.h
zhouxiang93123/openair-cn
18c5858887d73ee811161a28fde3cb7da8af458c
[ "Apache-2.0" ]
4
2020-09-25T05:54:47.000Z
2022-02-22T08:06:21.000Z
SRC/COMMON/ITTI_ANALYZER/libui/ui_tree_view.h
zhouxiang93123/openair-cn
18c5858887d73ee811161a28fde3cb7da8af458c
[ "Apache-2.0" ]
null
null
null
SRC/COMMON/ITTI_ANALYZER/libui/ui_tree_view.h
zhouxiang93123/openair-cn
18c5858887d73ee811161a28fde3cb7da8af458c
[ "Apache-2.0" ]
5
2020-11-11T01:20:50.000Z
2021-04-15T08:25:36.000Z
/* * Copyright (c) 2015, EURECOM (www.eurecom.fr) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 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. * * The views and conclusions contained in the software and documentation are those * of the authors and should not be interpreted as representing official policies, * either expressed or implied, of the FreeBSD Project. */ #ifndef UI_TREE_VIEW_H_ #define UI_TREE_VIEW_H_ #include "ui_filters.h" #include "ui_notifications.h" typedef enum col_type_e { COL_MSG_NUM = 0, COL_LTE_TIME, COL_MESSAGE, COL_FROM_TASK, COL_TO_TASK, COL_INSTANCE, COL_MESSAGE_ID, COL_FROM_TASK_ID, COL_TO_TASK_ID, COL_INSTANCE_ID, COL_FOREGROUND, COL_BACKGROUND, COL_STRIKETHROUGH, COL_STYLE, COL_WEIGHT, COL_UNDERLINE, COL_BUFFER, NUM_COLS } col_type_t; typedef enum ui_tree_view_menu_type_e { MENU_MESSAGE = 0, MENU_FROM_TASK, MENU_TO_TASK, MENU_INSTANCE, NUM_MENU_TYPE, } ui_tree_view_menu_type_t; typedef struct ui_tree_view_menu_enable_s { GtkWidget *menu_enable; ui_filter_item_t *filter_item; } ui_tree_view_menu_enable_t; typedef struct ui_tree_view_menu_color_s { gboolean foreground; ui_tree_view_menu_enable_t *menu_enable; } ui_tree_view_menu_color_t; extern GtkWidget *ui_tree_view_menu; extern ui_tree_view_menu_enable_t ui_tree_view_menu_enable[NUM_MENU_TYPE]; extern GdkEventButton *ui_tree_view_last_event; int ui_tree_view_create(GtkWidget *window, GtkWidget *vbox); int ui_tree_view_new_signal_ind(const uint32_t message_number, const gchar *lte_time, const uint32_t message_id, const char *message_name, const uint32_t origin_task_id, const char *origin_task, const uint32_t destination_task_id, const char *to_task, uint32_t instance, gpointer buffer); void ui_tree_view_destroy_list(GtkWidget *list); void ui_tree_view_select_row(gint row); void ui_tree_view_refilter(void); void ui_tree_view_foreach_message(message_write_callback_t callback, gboolean filter); guint ui_tree_view_get_filtered_number(void); #endif /* UI_TREE_VIEW_H_ */
33.028571
88
0.754037
d8b78884599ae29d6943aad619937280cf93ba9a
847
c
C
packages/PIPS/validation/Scilab/COLD-1.0.5.sub/t258.c
DVSR1966/par4all
86b33ca9da736e832b568c5637a2381f360f1996
[ "MIT" ]
51
2015-01-31T01:51:39.000Z
2022-02-18T02:01:50.000Z
packages/PIPS/validation/Scilab/COLD-1.0.5.sub/t258.c
DVSR1966/par4all
86b33ca9da736e832b568c5637a2381f360f1996
[ "MIT" ]
7
2017-05-29T09:29:00.000Z
2019-03-11T16:01:39.000Z
packages/PIPS/validation/Scilab/COLD-1.0.5.sub/t258.c
DVSR1966/par4all
86b33ca9da736e832b568c5637a2381f360f1996
[ "MIT" ]
12
2015-03-26T08:05:38.000Z
2022-02-18T02:01:51.000Z
/* * (c) HPC Project - 2010-2011 - All rights reserved * */ #include "scilab_rt.h" int __lv0; int __lv1; int __lv2; int __lv3; /*----------------------------------------------------*/ /*----------------------------------------------------*/ int main(int argc, char* argv[]) { scilab_rt_init(argc, argv, COLD_MODE_STANDALONE); /* t258.sce: ones, zeros, rand with 3D matrices */ double _u_a[3][3][3]; scilab_rt_ones_i0i0i0_d3(3,3,3,3,3,3,_u_a); double _u_t1[3][3][3]; scilab_rt_ones_d3_d3(3,3,3,_u_a,3,3,3,_u_t1); scilab_rt_display_s0d3_("t1",3,3,3,_u_t1); double _u_t2[3][3][3]; scilab_rt_zeros_d3_d3(3,3,3,_u_a,3,3,3,_u_t2); scilab_rt_display_s0d3_("t2",3,3,3,_u_t2); double _u_t3[3][3][3]; scilab_rt_rand_d3_d3(3,3,3,_u_a,3,3,3,_u_t3); scilab_rt_display_s0d3_("t3",3,3,3,_u_t3); scilab_rt_terminate(); }
21.717949
56
0.585596
94fe9d260986b9fed9ac38d39dea895b275658ac
2,441
h
C
mugsy-seqan/projects/library/seqan/store/store_annotation.h
kloetzl/mugsy
8ccdf32858a7a5ab2f7b9b084d2190970feb97ec
[ "Artistic-2.0" ]
null
null
null
mugsy-seqan/projects/library/seqan/store/store_annotation.h
kloetzl/mugsy
8ccdf32858a7a5ab2f7b9b084d2190970feb97ec
[ "Artistic-2.0" ]
null
null
null
mugsy-seqan/projects/library/seqan/store/store_annotation.h
kloetzl/mugsy
8ccdf32858a7a5ab2f7b9b084d2190970feb97ec
[ "Artistic-2.0" ]
null
null
null
/*========================================================================== SeqAn - The Library for Sequence Analysis http://www.seqan.de ============================================================================ Copyright (C) 2007 This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. ============================================================================ $Id$ ==========================================================================*/ #ifndef SEQAN_HEADER_STORE_ANNOTATION_H #define SEQAN_HEADER_STORE_ANNOTATION_H namespace SEQAN_NAMESPACE_MAIN { ////////////////////////////////////////////////////////////////////////////// // Annotation Store ////////////////////////////////////////////////////////////////////////////// template <typename TPos, typename TSpec = void> struct AnnotationStoreElement { typedef typename Id<AnnotationStoreElement>::Type TId; static const TId INVALID_ID; static const TPos INVALID_POS; TId parentId; TId contigId; TPos beginPos; // begin position of the gapped sequence in gapped contig sequence TPos endPos; // end position of ..., for reverse aligned reads holds end < begin AnnotationStoreElement() : parentId(INVALID_ID), contigId(INVALID_ID), beginPos(INVALID_POS), endPos(INVALID_POS) {} }; ////////////////////////////////////////////////////////////////////////////// template <typename TPos, typename TSpec> const typename Id<AnnotationStoreElement<TPos, TSpec> >::Type AnnotationStoreElement<TPos, TSpec>::INVALID_ID = SupremumValue<typename Id<AnnotationStoreElement<TPos, TSpec> >::Type>::VALUE; template <typename TPos, typename TSpec> const TPos AnnotationStoreElement<TPos, TSpec>::INVALID_POS = SupremumValue<TPos>::VALUE; ////////////////////////////////////////////////////////////////////////////// }// namespace SEQAN_NAMESPACE_MAIN #endif //#ifndef SEQAN_HEADER_...
38.746032
129
0.542401
a20b9570e3e418ccaff314ea0f5a05dfb864244c
467
c
C
base/numeral_system.c
VinkDong/c-example
cbfb240a3e4af9786a3b1f7844556dc20eae9cc2
[ "MIT" ]
null
null
null
base/numeral_system.c
VinkDong/c-example
cbfb240a3e4af9786a3b1f7844556dc20eae9cc2
[ "MIT" ]
null
null
null
base/numeral_system.c
VinkDong/c-example
cbfb240a3e4af9786a3b1f7844556dc20eae9cc2
[ "MIT" ]
null
null
null
# include <stdio.h> // this is show `进制` but i don't know how to translate it int main() { int a = 050; int b = 50; int c = 0x50; //there has no method to define printf("this is decimal %%o -> %%d number %d\n",a); printf("this is a octonary %o\n",a); printf("this is a octonary number and start with 1 :%#o\n",b); printf("this is a hexadecima number %x\n",c); printf("this is a hexadecima number and start with 0x: %#x\n",b); }
27.470588
69
0.599572
d3b8db052b9d460bf9581c8f43d0a21166593280
1,949
h
C
SCTK/src/asclite/core/sgml_generic_reportgenerator.h
IIP-Sogang/Audio-Visual-Speech-Recognition
bd03be91135acbc6162b83092d462b7fe71dd007
[ "MIT" ]
113
2018-11-20T06:00:39.000Z
2022-03-29T06:01:55.000Z
SCTK/src/asclite/core/sgml_generic_reportgenerator.h
IIP-Sogang/Audio-Visual-Speech-Recognition
bd03be91135acbc6162b83092d462b7fe71dd007
[ "MIT" ]
28
2017-09-11T16:20:26.000Z
2022-02-13T14:16:33.000Z
SCTK/src/asclite/core/sgml_generic_reportgenerator.h
IIP-Sogang/Audio-Visual-Speech-Recognition
bd03be91135acbc6162b83092d462b7fe71dd007
[ "MIT" ]
47
2015-01-27T06:22:57.000Z
2021-11-11T20:59:04.000Z
/* * ASCLITE * Author: Jerome Ajot, Jon Fiscus, Nicolas Radde, Chris Laprun * * This software was developed at the National Institute of Standards and Technology by * employees of the Federal Government in the course of their official duties. Pursuant * to title 17 Section 105 of the United States Code this software is not subject to * copyright protection and is in the public domain. ASCLITE is an experimental system. * NIST assumes no responsibility whatsoever for its use by other parties, and makes no * guarantees, expressed or implied, about its quality, reliability, or any other * characteristic. We would appreciate acknowledgement if the software is used. * * THIS SOFTWARE IS PROVIDED "AS IS." With regard to this software, NIST MAKES NO EXPRESS * OR IMPLIED WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING MERCHANTABILITY, * OR FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef SGML_GENERIC_REPORTGENERATOR_H #define SGML_GENERIC_REPORTGENERATOR_H #include "segment.h" #include "segment.h" #include "logger.h" #include "dateutils.h" #include "token.h" #include "speechset.h" #include "graphalignedtoken.h" #include "graphalignedsegment.h" class SGMLGenericReportGenerator { private: vector<GraphAlignedSegment*> m_vGAS; vector<string> m_vTitle; vector<string> m_vFilename; static Logger* m_pLogger; public: /** class constructor */ SGMLGenericReportGenerator() {} /** class destructor */ ~SGMLGenericReportGenerator(); /** Generate the SGML report */ void Generate(int where); void AddTitleAndFilename(const string& _filename, const string& _title) { m_vFilename.push_back(_filename); m_vTitle.push_back(_title); } void AddGraphAlignSegment(GraphAlignedSegment* gas) { m_vGAS.push_back(gas); } string GetTitle(const size_t& i) { return m_vTitle[i]; } string GetFilename(const size_t& i) { return m_vFilename[i]; } size_t GetNbOfSystems() { return m_vTitle.size(); } }; #endif
36.092593
139
0.759364
2356ddd77462c458360e9b850a0d31f7a98d7dd1
5,763
h
C
parallel_dsu.h
abarankab/parallel_boruvka
0310f8fcf1dd93732e83e2bf9ecc0d80e36f6637
[ "MIT" ]
10
2020-05-14T20:31:31.000Z
2020-05-30T04:13:35.000Z
parallel_dsu.h
abarankab/parallel_boruvka
0310f8fcf1dd93732e83e2bf9ecc0d80e36f6637
[ "MIT" ]
null
null
null
parallel_dsu.h
abarankab/parallel_boruvka
0310f8fcf1dd93732e83e2bf9ecc0d80e36f6637
[ "MIT" ]
1
2021-07-28T17:52:10.000Z
2021-07-28T17:52:10.000Z
#ifndef __DSU_H #define __DSU_H #include <atomic> #include <omp.h> #include <stdexcept> #include "defs.h" #include "parallel_array.h" /** * INTERFACE: * * ParallelDSU(uint32_t N, uint32_t NUM_THREADS) - constructs a DSU of size N using NUM_THREADS * uint32_t find_root(uint32_t id) - finds root node of id * bool same_set(uint32_t id1, uint32_t id2) - checks if id1 and id2 are in the same set * void unite(uint32_t id1, uint32_t id2) - unites sets of id1 and id2 * * DETAILS: * * Implementation was inspired by this repo * https://github.com/wjakob/dset/blob/master/dset.h * and this paper * http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.56.8354&rep=rep1&type=pdf * It uses both rank and path heuristics in parallel * which should allow for O(\alpha S) time on both find_root and unite operations * * Data is stored in unsigned 64 bit integers * The first 32 bits encode node parent * The last 32 bits encode node rank * This allows for easier compare and swap and should work slightly faster * * E.g. if X is the stored value: * X & 0x00000000FFFFFFFF <- parent * X & 0xFFFFFFFF00000000 <- rank * * To decode these values from u64 one should use get_parent() and get_rank() * * I also check if id is within range and throw an exception otherwise, * this slows the code down a little bit but should save you some time debugging */ struct ParallelDSU { const u32 NUM_THREADS; u32 dsu_size; atomic_u64* data; const u32 BINARY_BUCKET_SIZE = 32; const u64 RANK_MASK = 0xFFFFFFFF00000000ULL; ParallelDSU(u32 size, u32 NUM_THREADS = omp_get_max_threads()) : NUM_THREADS(NUM_THREADS), dsu_size(size) { if (size == 0) { throw std::invalid_argument("DSU size cannot be zero"); } data = static_cast<atomic_u64*>(operator new[] (size * sizeof(atomic_u64)));; #pragma omp parallel for shared(data) num_threads(NUM_THREADS) for (u32 i = 0; i < size; ++i) data[i] = i; } u32 size() const { return dsu_size; } void check_out_of_range(u32 id) const { if (id >= size()) { throw std::out_of_range("Node id out of range"); } } u64 encode_node(u32 parent, u32 rank) { return (static_cast<u64>(rank) << BINARY_BUCKET_SIZE) | parent; } u32 get_parent(u32 id) const { return static_cast<u32>(data[id]); } u32 get_rank(u32 id) const { return static_cast<u32>(data[id] >> BINARY_BUCKET_SIZE); } /** * On each step we try to apply path heuristic using CAS * and then move closer to the root and * * The loop breaks when a node's parent is equal to itself * E.g. when we find the root */ u32 find_root(u32 id) { check_out_of_range(id); while (id != get_parent(id)) { u64 value = data[id]; u32 grandparent = get_parent(static_cast<u32>(value)); u64 new_value = (value & RANK_MASK) | grandparent; /* Path heuristic */ if (value != new_value) { data[id].compare_exchange_strong(value, new_value); } id = grandparent; } return id; } /** * We try to check if two nodes are in the same set * by checking if their roots are the same * * Since it is a parallel structure, node roots may change during runtime * In order to account for this we do a while loop and repeat if * our current node is no longer the root of its set * * In general, you should call this after synchronization, * It still works during parallel segments, but the results will make no sense */ bool same_set(u32 id1, u32 id2) { check_out_of_range(id1); check_out_of_range(id2); while (true) { id1 = find_root(id1); id2 = find_root(id2); if (id1 == id2) { return true; } else if (get_parent(id1) == id1) { return false; } } } /** * We try to hang the smaller component onto the bigger one * * Since it is a parallel structure, node roots may change during runtime * In order to account for this we do a while loop and repeat if * the smaller node was updated e.g. when CAS failed */ void unite(u32 id1, u32 id2) { check_out_of_range(id1); check_out_of_range(id2); while (true) { id1 = find_root(id1); id2 = find_root(id2); /* Nodes are already in the same set */ if (id1 == id2) return; u32 rank1 = get_rank(id1); u32 rank2 = get_rank(id2); /* Hanging the smaller set to the bigger one, rank heuristic */ if (rank1 < rank2 || (rank1 == rank2 && id1 > id2)) { std::swap(rank1, rank2); std::swap(id1, id2); } u64 old_value = encode_node(id2, rank2); u64 new_value = encode_node(id1, rank2); /* If CAS fails we need to repeat the same step once again */ if (!data[id2].compare_exchange_strong(old_value, new_value)) { continue; } /* Updating rank */ if (rank1 == rank2) { old_value = encode_node(id1, rank1); new_value = encode_node(id1, rank1 + 1); data[id1].compare_exchange_strong(old_value, new_value); } break; } } }; #endif
30.983871
112
0.57713
d6c82b8502ea74b64b17eb3526ee2ff0ed47cc51
2,827
h
C
ParticleLearn/lib/OLED_Display_128X64/src/SeeedOLED.h
ballastdigital/lwIOT
084e92ae6db9eb71dd0d70f405a53af3b4de4320
[ "Apache-2.0" ]
null
null
null
ParticleLearn/lib/OLED_Display_128X64/src/SeeedOLED.h
ballastdigital/lwIOT
084e92ae6db9eb71dd0d70f405a53af3b4de4320
[ "Apache-2.0" ]
6
2021-03-09T19:17:55.000Z
2022-02-26T18:32:09.000Z
argon-firmware/lib/OLED_Display_128X64/src/SeeedOLED.h
bsatrom/iot-js-commandery
1615471ac537219c1b27629d7c7828ca1993bb10
[ "MIT" ]
null
null
null
/* * SeeedOLED.h * SSD130x OLED Driver Library * * Copyright (c) 2011 seeed technology inc. * Author : Visweswara R * Create Time : Dec 2011 * Change Log : * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef SeeedOLED_data_H #define SeeedOLED_data_H // SeeedOLED Instruction set addresses #if defined(ARDUINO) && ARDUINO >= 100 #include "Arduino.h" #else #include "Particle.h" #endif #define SeeedOLED_Max_X 127 //128 Pixels #define SeeedOLED_Max_Y 63 //64 Pixels #define PAGE_MODE 01 #define HORIZONTAL_MODE 02 #define SeeedOLED_Address 0x3c #define SeeedOLED_Command_Mode 0x80 #define SeeedOLED_Data_Mode 0x40 #define SeeedOLED_Display_Off_Cmd 0xAE #define SeeedOLED_Display_On_Cmd 0xAF #define SeeedOLED_Normal_Display_Cmd 0xA6 #define SeeedOLED_Inverse_Display_Cmd 0xA7 #define SeeedOLED_Activate_Scroll_Cmd 0x2F #define SeeedOLED_Dectivate_Scroll_Cmd 0x2E #define SeeedOLED_Set_Brightness_Cmd 0x81 #define Scroll_Left 0x00 #define Scroll_Right 0x01 #define Scroll_2Frames 0x7 #define Scroll_3Frames 0x4 #define Scroll_4Frames 0x5 #define Scroll_5Frames 0x0 #define Scroll_25Frames 0x6 #define Scroll_64Frames 0x1 #define Scroll_128Frames 0x2 #define Scroll_256Frames 0x3 class SeeedOLED { public: char addressingMode; void init(void); void setNormalDisplay(); void setInverseDisplay(); void sendCommand(unsigned char command); void sendData(unsigned char Data); void setPageMode(); void setHorizontalMode(); void setTextXY(unsigned char Row, unsigned char Column); void clearDisplay(); void setBrightness(unsigned char Brightness); void putChar(unsigned char c); void putString(const char *String); unsigned char putNumber(long n); unsigned char putFloat(float floatNumber, unsigned char decimal); unsigned char putFloat(float floatNumber); void drawBitmap(unsigned char *bitmaparray, int bytes); void setHorizontalScrollProperties(unsigned char direction, unsigned char startPage, unsigned char endPage, unsigned char scrollSpeed); void activateScroll(); void deactivateScroll(); }; extern SeeedOLED SeeedOled; // SeeedOLED object #endif
28.27
137
0.77821
03703f6dc1a5c0fc0195844fdebb6bd7916f27e3
2,392
h
C
Labyrint/Temp/il2cppOutput/il2cppOutput/mscorlib_System_Runtime_Remoting_Channels_SinkProv2493973872.h
mimietti/Labyball
c4b03f5b5d5ec1a1cae5831d22391bc2a171230f
[ "MIT" ]
null
null
null
Labyrint/Temp/il2cppOutput/il2cppOutput/mscorlib_System_Runtime_Remoting_Channels_SinkProv2493973872.h
mimietti/Labyball
c4b03f5b5d5ec1a1cae5831d22391bc2a171230f
[ "MIT" ]
23
2016-07-21T13:03:02.000Z
2016-10-03T12:43:01.000Z
Labyrint/labyrinti1/Classes/Native/mscorlib_System_Runtime_Remoting_Channels_SinkProv2493973872.h
mimietti/Labyball
c4b03f5b5d5ec1a1cae5831d22391bc2a171230f
[ "MIT" ]
1
2019-09-08T17:32:17.000Z
2019-09-08T17:32:17.000Z
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> // System.String struct String_t; // System.Collections.ArrayList struct ArrayList_t2121638921; // System.Collections.Hashtable struct Hashtable_t3875263730; #include "mscorlib_System_Object837106420.h" #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Runtime.Remoting.Channels.SinkProviderData struct SinkProviderData_t2493973872 : public Il2CppObject { public: // System.String System.Runtime.Remoting.Channels.SinkProviderData::sinkName String_t* ___sinkName_0; // System.Collections.ArrayList System.Runtime.Remoting.Channels.SinkProviderData::children ArrayList_t2121638921 * ___children_1; // System.Collections.Hashtable System.Runtime.Remoting.Channels.SinkProviderData::properties Hashtable_t3875263730 * ___properties_2; public: inline static int32_t get_offset_of_sinkName_0() { return static_cast<int32_t>(offsetof(SinkProviderData_t2493973872, ___sinkName_0)); } inline String_t* get_sinkName_0() const { return ___sinkName_0; } inline String_t** get_address_of_sinkName_0() { return &___sinkName_0; } inline void set_sinkName_0(String_t* value) { ___sinkName_0 = value; Il2CppCodeGenWriteBarrier(&___sinkName_0, value); } inline static int32_t get_offset_of_children_1() { return static_cast<int32_t>(offsetof(SinkProviderData_t2493973872, ___children_1)); } inline ArrayList_t2121638921 * get_children_1() const { return ___children_1; } inline ArrayList_t2121638921 ** get_address_of_children_1() { return &___children_1; } inline void set_children_1(ArrayList_t2121638921 * value) { ___children_1 = value; Il2CppCodeGenWriteBarrier(&___children_1, value); } inline static int32_t get_offset_of_properties_2() { return static_cast<int32_t>(offsetof(SinkProviderData_t2493973872, ___properties_2)); } inline Hashtable_t3875263730 * get_properties_2() const { return ___properties_2; } inline Hashtable_t3875263730 ** get_address_of_properties_2() { return &___properties_2; } inline void set_properties_2(Hashtable_t3875263730 * value) { ___properties_2 = value; Il2CppCodeGenWriteBarrier(&___properties_2, value); } }; #ifdef __clang__ #pragma clang diagnostic pop #endif
33.690141
141
0.80811
c11cd1bd5ab15ce05067bdcbba833d30b53d0e7f
398
h
C
UniqDay/UniqDay/View/UNDCardViewCell.h
J4ckChan/UniqDay
004a50eab11852063079ff38d9116420cdf7dbbf
[ "MIT" ]
null
null
null
UniqDay/UniqDay/View/UNDCardViewCell.h
J4ckChan/UniqDay
004a50eab11852063079ff38d9116420cdf7dbbf
[ "MIT" ]
null
null
null
UniqDay/UniqDay/View/UNDCardViewCell.h
J4ckChan/UniqDay
004a50eab11852063079ff38d9116420cdf7dbbf
[ "MIT" ]
null
null
null
// // UNDCardViewCell.h // UniqDay // // Created by ChanLiang on 17/03/2017. // Copyright © 2017 ChanLiang. All rights reserved. // #import <UIKit/UIKit.h> @class UNDCardViewModel; @interface UNDCardViewCell : UICollectionViewCell @property (nonatomic,strong) UNDCardViewModel *viewModel; @property (nonatomic,strong) UIView *frontView; @property (nonatomic,strong) UIView *backView; @end
19.9
57
0.748744
26b2fe7f564a421cda7ddbc3035865bcd01cdc7f
819
h
C
Date.h
Stibius/IndexTreeSearch
45c295164b9e3fbe66fb776acdb1038dd083f9d2
[ "Unlicense" ]
null
null
null
Date.h
Stibius/IndexTreeSearch
45c295164b9e3fbe66fb776acdb1038dd083f9d2
[ "Unlicense" ]
null
null
null
Date.h
Stibius/IndexTreeSearch
45c295164b9e3fbe66fb776acdb1038dd083f9d2
[ "Unlicense" ]
null
null
null
#pragma once #include <string> //class representing a date class Date { private: int m_day; int m_month; int m_year; public: explicit Date(int day = 0, int month = 0, int year = 0); //constructs a date from a string format (YYYY-MM-DD) explicit Date(const std::string& str); void setDay(int day); void setMonth(int month); void setYear(int year); int getDay() const; int getMonth() const; int getYear() const; //converts this date to a string format (YYYY-MM-DD) std::string toString() const; //comparison operators for the Date class, used for sorting and searching bool operator==(const Date& date2) const; bool operator<(const Date& date2) const; bool operator>(const Date& date2) const; bool operator<=(const Date& date2) const; bool operator>=(const Date& date2) const; };
16.38
74
0.700855
c1b9b2d16982e1b22f54da10bd8c8e3bf7bbff05
12,147
h
C
Common/DataModel/vtkDispatcher_Private.h
keithroe/vtkoptix
c5bbfa0105552af3022811a7c81efec640fb810f
[ "BSD-3-Clause" ]
null
null
null
Common/DataModel/vtkDispatcher_Private.h
keithroe/vtkoptix
c5bbfa0105552af3022811a7c81efec640fb810f
[ "BSD-3-Clause" ]
null
null
null
Common/DataModel/vtkDispatcher_Private.h
keithroe/vtkoptix
c5bbfa0105552af3022811a7c81efec640fb810f
[ "BSD-3-Clause" ]
null
null
null
/*========================================================================= Program: Visualization Toolkit Module: vtkDispatcher.h Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ //////////////////////////////////////////////////////////////////////////////// // The Loki Library // Copyright (c) 2001 by Andrei Alexandrescu // This code accompanies the book: // Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design // Patterns Applied". Copyright (c) 2001. Addison-Wesley. // Permission to use, copy, modify, distribute and sell this software for any // purpose is hereby granted without fee, provided that the above copyright // notice appear in all copies and that both that copyright notice and this // permission notice appear in supporting documentation. // The author or Addison-Wesley Longman make no representations about the // suitability of this software for any purpose. It is provided "as is" // without express or implied warranty. //////////////////////////////////////////////////////////////////////////////// #ifndef vtkDispatcher_Private_h #define vtkDispatcher_Private_h #include <typeinfo> #include <cassert> #include <memory> namespace vtkDispatcherPrivate { //////////////////////////////////////////////////////////////////////////////// // Dispatch helper for reference functors //////////////////////////////////////////////////////////////////////////////// template <class BaseLhs, class SomeLhs, typename RT, class CastLhs, class Fun> class FunctorRefDispatcherHelper { Fun& fun_; public: typedef RT ResultType; FunctorRefDispatcherHelper(const FunctorRefDispatcherHelper& rhs) : fun_(rhs.fun_) {} FunctorRefDispatcherHelper(Fun& f) : fun_(f) {} ResultType operator()(BaseLhs& lhs) { return fun_(CastLhs::Cast(lhs)); } private: FunctorRefDispatcherHelper& operator =(const FunctorRefDispatcherHelper& b); }; //////////////////////////////////////////////////////////////////////////////// // Dispatch helper //////////////////////////////////////////////////////////////////////////////// template <class BaseLhs, class SomeLhs, typename RT, class CastLhs, class Fun> class FunctorDispatcherHelper { Fun fun_; public: typedef RT ResultType; FunctorDispatcherHelper(const FunctorDispatcherHelper& rhs) : fun_(rhs.fun_) {} FunctorDispatcherHelper(Fun fun) : fun_(fun) {} ResultType operator()(BaseLhs& lhs) { return fun_(CastLhs::Cast(lhs)); } }; //////////////////////////////////////////////////////////////////////////////// // Parent class for all FunctorImpl, helps hide functor template args //////////////////////////////////////////////////////////////////////////////// template <typename R, typename P1> class FunctorImpl{ public: typedef R ResultType; typedef P1 Parm1; virtual ~FunctorImpl() {} virtual R operator()(P1&) = 0; virtual FunctorImpl* DoClone() const = 0; template <class U> static U* Clone(U* pObj) { if (!pObj) return 0; U* pClone = static_cast<U*>(pObj->DoClone()); assert(typeid(*pClone) == typeid(*pObj)); return pClone; } protected: FunctorImpl() {} FunctorImpl(const FunctorImpl&) {} private: FunctorImpl& operator =(const FunctorImpl&) VTK_DELETE_FUNCTION; }; //////////////////////////////////////////////////////////////////////////////// // Impl functor that calls a user functor //////////////////////////////////////////////////////////////////////////////// template <class ParentFunctor,typename Fun> class FunctorHandler: public ParentFunctor::Impl { typedef typename ParentFunctor::Impl Base; public: typedef typename Base::ResultType ResultType; typedef typename Base::Parm1 Parm1; FunctorHandler(Fun& fun) : f_(fun) {} virtual ~FunctorHandler() {} ResultType operator()(Parm1& p1) { return f_(p1); } virtual FunctorHandler* DoClone() const { return new FunctorHandler(*this); } private: Fun f_; FunctorHandler(const FunctorHandler &b) : ParentFunctor::Impl(b), f_(b.f_) {} FunctorHandler& operator =(const FunctorHandler& b) VTK_DELETE_FUNCTION; }; //////////////////////////////////////////////////////////////////////////////// // Functor wrapper class //////////////////////////////////////////////////////////////////////////////// template <typename R,typename Parm1> class Functor { public: typedef FunctorImpl<R, Parm1> Impl; typedef R ResultType; #if defined(VTK_HAS_STD_UNIQUE_PTR) Functor() : spImpl_() #else Functor() : spImpl_(0) #endif {} Functor(const Functor& rhs) : spImpl_(Impl::Clone(rhs.spImpl_.get())) {} template <typename Fun> Functor(Fun fun) : spImpl_(new FunctorHandler<Functor,Fun>(fun)) {} Functor& operator=(const Functor& rhs) { Functor copy(rhs); #if defined(VTK_HAS_STD_UNIQUE_PTR) spImpl_.swap(copy.spImpl_); #else // swap auto_ptrs by hand Impl* p = spImpl_.release(); spImpl_.reset(copy.spImpl_.release()); copy.spImpl_.reset(p); #endif return *this; } ResultType operator()(Parm1& p1) { return (*spImpl_)(p1); } private: #if defined(VTK_HAS_STD_UNIQUE_PTR) std::unique_ptr<Impl> spImpl_; #else std::auto_ptr<Impl> spImpl_; #endif }; } namespace vtkDoubleDispatcherPrivate { //////////////////////////////////////////////////////////////////////////////// // Dispatch helper //////////////////////////////////////////////////////////////////////////////// template <class BaseLhs, class BaseRhs, class SomeLhs, class SomeRhs, typename RT, class CastLhs, class CastRhs, class Fun> class FunctorRefDispatcherHelper { Fun& fun_; public: typedef RT ResultType; FunctorRefDispatcherHelper(const FunctorRefDispatcherHelper& rhs) : fun_(rhs.fun_) {} FunctorRefDispatcherHelper(Fun& fun) : fun_(fun) {} ResultType operator()(BaseLhs& lhs, BaseRhs& rhs) { return fun_(CastLhs::Cast(lhs), CastRhs::Cast(rhs)); } private: FunctorRefDispatcherHelper& operator =(const FunctorRefDispatcherHelper& b); }; template <class BaseLhs, class BaseRhs, class SomeLhs, class SomeRhs, typename RT, class CastLhs, class CastRhs, class Fun> class FunctorDoubleDispatcherHelper { Fun fun_; public: typedef RT ResultType; FunctorDoubleDispatcherHelper(const FunctorDoubleDispatcherHelper& rhs) : fun_(rhs.fun_) {} FunctorDoubleDispatcherHelper(Fun fun) : fun_(fun) {} ResultType operator()(BaseLhs& lhs, BaseRhs& rhs) { return fun_(CastLhs::Cast(lhs), CastRhs::Cast(rhs)); } }; //////////////////////////////////////////////////////////////////////////////// // Parent class for all FunctorImpl, helps hide functor template args //////////////////////////////////////////////////////////////////////////////// template <typename R, typename P1, typename P2> class FunctorImpl{ public: typedef R ResultType; typedef P1 Parm1; typedef P2 Parm2; virtual ~FunctorImpl() {} virtual R operator()(P1&,P2&) = 0; virtual FunctorImpl* DoClone() const = 0; template <class U> static U* Clone(U* pObj) { if (!pObj) return 0; U* pClone = static_cast<U*>(pObj->DoClone()); assert(typeid(*pClone) == typeid(*pObj)); return pClone; } protected: FunctorImpl() {} FunctorImpl(const FunctorImpl&) {} private: FunctorImpl& operator =(const FunctorImpl&) VTK_DELETE_FUNCTION; }; //////////////////////////////////////////////////////////////////////////////// // Impl functor that calls a user functor //////////////////////////////////////////////////////////////////////////////// template <class ParentFunctor,typename Fun> class FunctorHandler: public ParentFunctor::Impl { typedef typename ParentFunctor::Impl Base; public: typedef typename Base::ResultType ResultType; typedef typename Base::Parm1 Parm1; typedef typename Base::Parm2 Parm2; FunctorHandler(const Fun& fun) : f_(fun) {} virtual ~FunctorHandler() {} ResultType operator()(Parm1& p1,Parm2& p2) { return f_(p1,p2); } virtual FunctorHandler* DoClone() const { return new FunctorHandler(*this); } private: Fun f_; FunctorHandler(const FunctorHandler &b) : ParentFunctor::Impl(b), f_(b.f_) {} FunctorHandler& operator =(const FunctorHandler& b) VTK_DELETE_FUNCTION; }; //////////////////////////////////////////////////////////////////////////////// // Functor wrapper class //////////////////////////////////////////////////////////////////////////////// template <typename R,typename Parm1, typename Parm2> class Functor { public: typedef FunctorImpl<R, Parm1,Parm2> Impl; typedef R ResultType; #if defined(VTK_HAS_STD_UNIQUE_PTR) Functor() : spImpl_() #else Functor() : spImpl_(0) #endif {} Functor(const Functor& rhs) : spImpl_(Impl::Clone(rhs.spImpl_.get())) {} template <typename Fun> Functor(const Fun& fun) : spImpl_(new FunctorHandler<Functor,Fun>(fun)) {} Functor& operator=(const Functor& rhs) { Functor copy(rhs); #if defined(VTK_HAS_STD_UNIQUE_PTR) spImpl_.swap(copy.spImpl_); #else // swap auto_ptrs by hand Impl* p = spImpl_.release(); spImpl_.reset(copy.spImpl_.release()); copy.spImpl_.reset(p); #endif return *this; } ResultType operator()(Parm1& p1,Parm2& p2) { return (*spImpl_)(p1,p2); } private: #if defined(VTK_HAS_STD_UNIQUE_PTR) std::unique_ptr<Impl> spImpl_; #else std::auto_ptr<Impl> spImpl_; #endif }; } namespace vtkDispatcherCommon { template <class To, class From> struct DynamicCaster { static To& Cast(From& obj) { return dynamic_cast<To&>(obj); } static To* Cast(From* obj) { return dynamic_cast<To*>(obj); } }; template <class To, class From> struct vtkCaster { static To& Cast(From& obj) { return *(To::SafeDownCast(&obj)); } static To* Cast(From* obj) { return To::SafeDownCast(obj); } }; class TypeInfo { public: // Constructors TypeInfo(); // needed for containers TypeInfo(const std::type_info&); // non-explicit // Access for the wrapped std::type_info const std::type_info& Get() const; // Compatibility functions bool before(const TypeInfo& rhs) const; const char* name() const; private: const std::type_info* pInfo_; }; // Implementation inline TypeInfo::TypeInfo() { class Nil {}; pInfo_ = &typeid(Nil); assert(pInfo_); } inline TypeInfo::TypeInfo(const std::type_info& ti) : pInfo_(&ti) { assert(pInfo_); } inline bool TypeInfo::before(const TypeInfo& rhs) const { assert(pInfo_); // type_info::before return type is int in some VC libraries return pInfo_->before(*rhs.pInfo_) != 0; } inline const std::type_info& TypeInfo::Get() const { assert(pInfo_); return *pInfo_; } inline const char* TypeInfo::name() const { assert(pInfo_); return pInfo_->name(); } // Comparison operators inline bool operator==(const TypeInfo& lhs, const TypeInfo& rhs) // type_info::operator== return type is int in some VC libraries { return (lhs.Get() == rhs.Get()) != 0; } inline bool operator<(const TypeInfo& lhs, const TypeInfo& rhs) { return lhs.before(rhs); } inline bool operator!=(const TypeInfo& lhs, const TypeInfo& rhs) { return !(lhs == rhs); } inline bool operator>(const TypeInfo& lhs, const TypeInfo& rhs) { return rhs < lhs; } inline bool operator<=(const TypeInfo& lhs, const TypeInfo& rhs) { return !(lhs > rhs); } inline bool operator>=(const TypeInfo& lhs, const TypeInfo& rhs) { return !(lhs < rhs); } } #endif // vtkDispatcherPrivate_h // VTK-HeaderTest-Exclude: vtkDispatcher_Private.h
26.933481
93
0.589364
96c68ea6d9b7c199d7a27716ed6a3f50596664db
2,666
c
C
vendor/nrf51/nrf51_uart.c
pavelskipenes/microBit-C-template
1629962af06b0afaa26e93d216dd31b11be5aff4
[ "MIT" ]
1
2022-01-03T01:08:07.000Z
2022-01-03T01:08:07.000Z
vendor/nrf51/nrf51_uart.c
pavelskipenes/microBit-C-template
1629962af06b0afaa26e93d216dd31b11be5aff4
[ "MIT" ]
null
null
null
vendor/nrf51/nrf51_uart.c
pavelskipenes/microBit-C-template
1629962af06b0afaa26e93d216dd31b11be5aff4
[ "MIT" ]
1
2022-01-03T01:09:48.000Z
2022-01-03T01:09:48.000Z
#include "nrf51_uart.h" #include "nrf51_gpio.h" #define PIN_TX 24 #define PIN_RX 25 #define PIN_DISABLE 0xFFFFFFFF #define BAUD_1200 0x0004F000 #define BAUD_2400 0x0009D000 #define BAUD_4900 0x0013B000 #define BAUD_9600 0x00275000 // standard #define BAUD_14400 0x003B0000 #define BAUD_19200 0x004EA000 #define BAUD_28800 0x0075F000 #define BAUD_48400 0x009D5000 #define BAUD_57600 0x00EBF000 #define BAUD_76800 0x013A9000 #define BAUD_115200 0x01D7E000 #define BAUD_230400 0x03AFB000 #define BAUD_250000 0x04000000 #define BAUD_460800 0x075F7000 #define BAUD_921600 0x0EBEDFA4 #define BAUD_1M 0x10000000 #define UART_DISABLE 0 #define UART_ENABLE 4 #define UART ((NRF51_UART_REG*)0x40002000) #define INPUT 0 #define OUTPUT 1 typedef struct { /* Tasks */ volatile uint32_t STARTRX; volatile uint32_t STOPRX; volatile uint32_t STARTTX; volatile uint32_t STOPTX; volatile uint32_t RESERVED0[3]; volatile uint32_t SUSPEND; /* Events */ volatile uint32_t RESERVED1[56]; volatile uint32_t CTS; volatile uint32_t NCTS; volatile uint32_t RXDRDY; volatile uint32_t RESERVED2[4]; volatile uint32_t TXDRDY; volatile uint32_t RESERVED3; volatile uint32_t ERROR; volatile uint32_t RESERVED4[7]; volatile uint32_t RXTO; /* Registers */ volatile uint32_t RESERVED5[110]; volatile uint32_t INTEN; volatile uint32_t INTENSET; volatile uint32_t INTENCLR; volatile uint32_t RESERVED6[93]; volatile uint32_t ERRORSRC; volatile uint32_t RESERVED7[31]; volatile uint32_t ENABLE; volatile uint32_t RESERVED8; volatile uint32_t PSELRTS; volatile uint32_t PSELTXD; volatile uint32_t PSELCTS; volatile uint32_t PSELRXD; volatile uint32_t RXD; volatile uint32_t TXD; volatile uint32_t RESERVED9; volatile uint32_t BAUDRATE; volatile uint32_t RESERVED10[17]; volatile uint32_t CONFIG; } NRF51_UART_REG; void nrf51_uart_init() { UART->ENABLE = UART_DISABLE; GPIO->PIN_CNF[PIN_TX] = OUTPUT; GPIO->PIN_CNF[PIN_RX] = INPUT; UART->PSELTXD = PIN_TX; UART->PSELRXD = PIN_RX; UART->PSELRTS = PIN_DISABLE; UART->PSELCTS = PIN_DISABLE; UART->BAUDRATE = BAUD_9600; UART->ENABLE = UART_ENABLE; UART->STARTRX = 1; } void nrf51_uart_send_byte(uint8_t byte) { // Section 29.4 UART->STARTTX = 1; UART->TXD = byte; while (!UART->TXDRDY) ; UART->TXDRDY = 0; UART->STOPTX = 1; } void nrf51_uart_send_message(const char *message) { int i = 0; while (message[i] != '\0') { nrf51_uart_send_byte((uint8_t) message[i]); i++; } nrf51_uart_send_byte('\n'); nrf51_uart_send_byte('\r'); } uint8_t nrf51_uart_receive(uint8_t * p_byte) { // Section 29.5 if (!UART->RXDRDY) return 0; UART->RXDRDY = 0; *p_byte = UART->RXD; return 1; }
21.674797
51
0.763316
e7f72a929f94fcdcc99167cea6296bd7d5e9b752
1,273
h
C
HLEditImage/Classes/AnimateImageView/SLImage.h
alin94/HLEditImage
72a9ffed5df7b46299ea51c8c9649a50bb2e6271
[ "MIT" ]
1,118
2019-09-19T03:01:57.000Z
2022-03-30T01:08:04.000Z
iOS_Tips/DarkMode/General/SLAnimateImageView/SLImage.h
ll728373688/iOS_Tips
bc5cf4eb894604c1b61fbc422dd4dc7e1471aad6
[ "MIT" ]
16
2019-11-06T01:05:36.000Z
2021-11-23T09:13:58.000Z
iOS_Tips/DarkMode/General/SLAnimateImageView/SLImage.h
ll728373688/iOS_Tips
bc5cf4eb894604c1b61fbc422dd4dc7e1471aad6
[ "MIT" ]
304
2019-11-04T04:21:17.000Z
2022-03-30T14:04:18.000Z
// // SLImage.h // WSLImageView // // Created by 王双龙 on 2018/10/26. // Copyright © 2018年 https://www.jianshu.com/u/e15d1f644bea. All rights reserved. // #import <UIKit/UIKit.h> #import "SLImageDecoder.h" NS_ASSUME_NONNULL_BEGIN //利用解码工具进行解码并存储解码后的信息 @interface SLImage : UIImage /** 图片类型 */ @property (nonatomic, assign, readonly) SLImageType imageType; /** 图像帧总个数 */ @property (nonatomic, assign, readonly) NSInteger frameCount; /** 循环次数 0:无限循环 */ @property (nonatomic, assign, readonly) NSInteger loopCount; /// 循环一次的时长 @property (nonatomic, assign, readonly) NSTimeInterval totalTime; /** 图片所占的内存大小 */ @property (nonatomic, readonly) NSUInteger animatedImageMemorySize; /** 是否预加载所有的帧 注意内存大小 默认NO */ @property (nonatomic, assign) BOOL preloadAllAnimatedImageFrames; /** 重写系统方法,用法尽量和原来保持一致 */ + (SLImage *)imageNamed:(NSString *)name; + (SLImage *)imageWithContentsOfFile:(NSString *)path; + (SLImage *)imageWithData:(NSData *)data; /** 某一帧的图片信息:索引、持续时长、宽高、方向、解码后的image */ - (SLImageFrame *)imageFrameAtIndex:(NSInteger)index; /** 动图中的某一帧image */ - (UIImage *)imageAtIndex:(NSUInteger)index; /** 某一帧持续时长 */ - (NSTimeInterval)imageDurationAtIndex:(NSUInteger)index; /** 一帧所占的内存大小 假设每一帧大小相同 */ - (NSUInteger)imageFrameBytes; @end NS_ASSUME_NONNULL_END
22.333333
82
0.735271
9b64465a2fa171019540ff4c948d740ef0313ce2
1,079
c
C
Data/Juliet-C/Juliet-C-v102/testcases/CWE197_Numeric_Truncation_Error/CWE197_Numeric_Truncation_Error__short_large_61b.c
b19e93n/PLC-Pyramid
6d5b57be6995a94ef7402144cee965862713b031
[ "MIT" ]
null
null
null
Data/Juliet-C/Juliet-C-v102/testcases/CWE197_Numeric_Truncation_Error/CWE197_Numeric_Truncation_Error__short_large_61b.c
b19e93n/PLC-Pyramid
6d5b57be6995a94ef7402144cee965862713b031
[ "MIT" ]
null
null
null
Data/Juliet-C/Juliet-C-v102/testcases/CWE197_Numeric_Truncation_Error/CWE197_Numeric_Truncation_Error__short_large_61b.c
b19e93n/PLC-Pyramid
6d5b57be6995a94ef7402144cee965862713b031
[ "MIT" ]
null
null
null
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE197_Numeric_Truncation_Error__short_large_61b.c Label Definition File: CWE197_Numeric_Truncation_Error__short.label.xml Template File: sources-sink-61b.tmpl.c */ /* * @description * CWE: 197 Numeric Truncation Error * BadSource: large Set data to a number larger than CHAR_MAX * GoodSource: Less than CHAR_MAX * Sinks: * BadSink : Convert data to a char * Flow Variant: 61 Data flow: data returned from one function to another in different source files * * */ #include "std_testcase.h" #ifndef OMITBAD short CWE197_Numeric_Truncation_Error__short_large_61b_bad_source(short data) { /* FLAW: Use a number larger than CHAR_MAX */ data = CHAR_MAX + 1; return data; } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B() uses the GoodSource with the BadSink */ short CWE197_Numeric_Truncation_Error__short_large_61b_goodG2B_source(short data) { /* FIX: Use a positive integer less than CHAR_MAX*/ data = CHAR_MAX-5; return data; } #endif /* OMITGOOD */
26.317073
100
0.722892
bb454e378a7257eac8dca409c0799e76cf203c56
7,040
h
C
sdk-6.5.20/include/bcm_int/ltsw/ifa_uc.h
copslock/broadcom_cpri
8e2767676e26faae270cf485591902a4c50cf0c5
[ "Spencer-94" ]
null
null
null
sdk-6.5.20/include/bcm_int/ltsw/ifa_uc.h
copslock/broadcom_cpri
8e2767676e26faae270cf485591902a4c50cf0c5
[ "Spencer-94" ]
null
null
null
sdk-6.5.20/include/bcm_int/ltsw/ifa_uc.h
copslock/broadcom_cpri
8e2767676e26faae270cf485591902a4c50cf0c5
[ "Spencer-94" ]
null
null
null
/*! \file ifa_uc.h * * IFA module internal header file. * This file contains definitions internal to IFA module to interface with the * IFA embedded app. */ /* * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. * * Copyright 2007-2020 Broadcom Inc. All rights reserved. */ #ifndef BCMINT_LTSW_IFA_UC_H #define BCMINT_LTSW_IFA_UC_H #include <bcm/types.h> #define BSL_LOG_MODULE BSL_LS_BCM_IFA /*! * \brief Set the IFA EApp config info. * * Set the IFA EApp config info. * * \param [in] unit Unit number. * \param [in] cfg_info Configuration info. * * \retval SHR_E_NONE Success. * \retval !SHR_E_NONE Failure. */ extern int bcmi_ltsw_ifa_uc_config_info_set(int unit, bcm_ifa_config_info_t *cfg_info); /*! * \brief Get the IFA EApp config info. * * Get the IFA EApp config info. * * \param [in] unit Unit number. * \param [out] cfg_info Configuration info. * * \retval SHR_E_NONE Success. * \retval !SHR_E_NONE Failure. */ extern int bcmi_ltsw_ifa_uc_config_info_get(int unit, bcm_ifa_config_info_t *cfg_info); /*! * \brief Set the IFA EApp stats. * * Set the IFA EApp stats. * * \param [in] unit Unit number. * \param [in] stats Statistics. * * \retval SHR_E_NONE Success. * \retval !SHR_E_NONE Failure. */ extern int bcmi_ltsw_ifa_uc_stats_set(int unit, bcm_ifa_stat_info_t *stats); /*! * \brief Get the IFA EApp stats. * * Get the IFA EApp stats. * * \param [in] unit Unit number. * \param [out] stats Statistics. * * \retval SHR_E_NONE Success. * \retval !SHR_E_NONE Failure. */ extern int bcmi_ltsw_ifa_uc_stats_get(int unit, bcm_ifa_stat_info_t *stats); /*! * \brief Create the IFA IPFIX template. * * Create the IFA IPFIX template. * * \param [in] unit Unit number. * \param [in] options Options. * \param [inout] Id Template Id. * \param [in] set_id IPFIX Set ID. * \param [in] num_export_elements Number of export elements. * \param [in] export_elements List of export elements. * * \retval SHR_E_NONE Success. * \retval !SHR_E_NONE Failure. */ extern int bcmi_ltsw_ifa_uc_template_create(int unit, uint32 options, bcm_ifa_export_template_t *id, uint16_t set_id, int num_export_elements, bcm_ifa_export_element_info_t *export_elements); /*! * \brief Get the IFA IPFIX template. * * Get the IFA IPFIX template. * * \param [in] unit Unit number. * \param [in] Id Template Id. * \param [out] set_id IPFIX Set ID. * \param [in] max_size Size of the export_elements array. * \param [out] export_elements List of export elements. * \param [out] num_export_elements Number of export elements. * * \retval SHR_E_NONE Success. * \retval !SHR_E_NONE Failure. */ extern int bcmi_ltsw_ifa_uc_template_get(int unit, bcm_ifa_export_template_t id, uint16_t *set_id, int max_export_elements, bcm_ifa_export_element_info_t *export_elements, int *num_export_elements); /*! * \brief Destroy the IFA IPFIX template. * * Destroy the IFA IPFIX template. * * \param [in] unit Unit number. * \param [in] Id Template Id. * * \retval SHR_E_NONE Success. * \retval !SHR_E_NONE Failure. */ extern int bcmi_ltsw_ifa_uc_template_destroy(int unit, bcm_ifa_export_template_t id); /*! * \brief Attach the IFA collector. * * Attach the IFA IPFIX collector. * * \param [in] unit Unit number. * \param [in] collector_id Collector ID * \param [in] export_profile_id Export profile ID * \param [in] template_id Template Id. * * \retval SHR_E_NONE Success. * \retval !SHR_E_NONE Failure. */ extern int bcmi_ltsw_ifa_uc_collector_attach(int unit, bcm_collector_t collector_id, int export_profile_id, bcm_ifa_export_template_t template_id); /*! * \brief Get the IFA collector details. * * Get the attached IFA collector, export profile and IPFIX template. * * \param [in] unit Unit number. * \param [out] collector_id Collector ID * \param [out] export_profile_id Export profile ID * \param [out] template_id Template Id. * * \retval SHR_E_NONE Success. * \retval !SHR_E_NONE Failure. */ extern int bcmi_ltsw_ifa_uc_collector_attach_get(int unit, bcm_collector_t *collector_id, int *export_profile_id, bcm_ifa_export_template_t *template_id); /*! * \brief Detach the IFA collector. * * Detach the IFA collector. * * \param [in] unit Unit number. * \param [out] collector_id Collector ID * \param [out] export_profile_id Export profile ID * \param [out] template_id Template Id. * * \retval SHR_E_NONE Success. * \retval !SHR_E_NONE Failure. */ extern int bcmi_ltsw_ifa_uc_collector_detach(int unit, bcm_collector_t collector_id, int export_profile_id, bcm_ifa_export_template_t template_id); /*! * \brief Set the template transmit configuration. * * Set the template transmit configuration. * * \param [in] unit Unit number. * \param [in] template_id Template ID * \param [in] collector_id Collector ID * \param [in] config Template transmit config. * * \retval SHR_E_NONE Success. * \retval !SHR_E_NONE Failure. */ extern int bcmi_ltsw_ifa_uc_template_transmit_config_set(int unit, bcm_ifa_export_template_t template_id, bcm_collector_t collector_id, bcm_ifa_template_transmit_config_t *config); /*! * \brief Get the template transmit configuration. * * Get the template transmit configuration. * * \param [in] unit Unit number. * \param [in] template_id Template ID * \param [in] collector_id Collector ID * \param [out] config Template transmit config. * * \retval SHR_E_NONE Success. * \retval !SHR_E_NONE Failure. */ extern int bcmi_ltsw_ifa_uc_template_transmit_config_get(int unit, bcm_ifa_export_template_t template_id, bcm_collector_t collector_id, bcm_ifa_template_transmit_config_t *config); /*! * \brief Detach the IFA EApp. * * Detach the IFA EApp related logical tables if it is already initalized. * * \param [in] unit Unit number. * * \retval SHR_E_NONE Success. * \retval !SHR_E_NONE Failure. */ extern int bcmi_ltsw_ifa_uc_detach(int unit); /*! * \brief Initialize the IFA EApp. * * Initialize IFA EApp related logical tables. * * \param [in] unit Unit number. * * \retval SHR_E_NONE Success. * \retval !SHR_E_NONE Failure. */ extern int bcmi_ltsw_ifa_uc_init(int unit); #endif /* BCMINT_LTSW_IFA_UC_H */
27.716535
134
0.655256
63fb76c0529fdeb30436aac71355755d42d9f2c9
9,324
h
C
src/hcode/compacttv.h
metabasenet/metabasenet
e9bc89b22c11981bcf1d71b63b9b66df3a4e54e1
[ "MIT" ]
null
null
null
src/hcode/compacttv.h
metabasenet/metabasenet
e9bc89b22c11981bcf1d71b63b9b66df3a4e54e1
[ "MIT" ]
null
null
null
src/hcode/compacttv.h
metabasenet/metabasenet
e9bc89b22c11981bcf1d71b63b9b66df3a4e54e1
[ "MIT" ]
null
null
null
// Copyright (c) 2021-2022 The MetabaseNet developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef HCODE_COMPACTTV_H #define HCODE_COMPACTTV_H #include <boost/type_traits.hpp> #include <boost/variant.hpp> #include <exception> #include <map> #include <string> #include <vector> namespace hcode { class CCompactTagValue { public: typedef boost::variant<boost::int64_t, std::vector<unsigned char>> CCompactTVType; enum { COMPACT_TYPE_FALSE = (0 << 5), COMPACT_TYPE_TRUE = (1 << 5), COMPACT_TYPE_INT8 = (2 << 5), COMPACT_TYPE_INT16 = (3 << 5), COMPACT_TYPE_INT32 = (4 << 5), COMPACT_TYPE_INT64 = (5 << 5), COMPACT_TYPE_INT256 = (6 << 5), COMPACT_TYPE_BINARY = (7 << 5), }; CCompactTagValue() {} void Push(int nTag, const std::vector<unsigned char>& vch, const boost::false_type&) { if (vch.size() > 255) { throw std::range_error("out of range"); } mapTagValue.insert(std::make_pair(nTag, std::make_pair(COMPACT_TYPE_BINARY, vch))); } void Push(int nTag, const std::string& str, const boost::false_type&) { Push(nTag, std::vector<unsigned char>(str.begin(), str.end())); } void Push(int nTag, bool f, const boost::true_type&) { int type = (f ? COMPACT_TYPE_TRUE : COMPACT_TYPE_FALSE); mapTagValue.insert(std::make_pair(nTag, std::make_pair(type, (boost::int64_t)0))); } template <typename T> void Push(int nTag, const T& t, const boost::false_type&) { if (sizeof(T) != 32) { throw std::range_error("unknown type"); } std::vector<unsigned char> vch((const unsigned char*)&t, (const unsigned char*)(&t + 1)); mapTagValue.insert(std::make_pair(nTag, std::make_pair(COMPACT_TYPE_INT256, vch))); } template <typename T> void Push(int nTag, const T& t, const boost::true_type&) { int type = 0; switch (sizeof(T)) { case 1: type = COMPACT_TYPE_INT8; break; case 2: type = COMPACT_TYPE_INT16; break; case 4: type = COMPACT_TYPE_INT32; break; case 8: type = COMPACT_TYPE_INT64; break; default: throw std::range_error("unknown type"); break; } mapTagValue.insert(std::make_pair(nTag, std::make_pair(type, (boost::int64_t)t))); } template <typename T> void Push(int nTag, const T& t) { if (nTag > 31) { throw std::range_error("invalid tag"); } if (mapTagValue.count(nTag)) { throw std::range_error("duplicated tag"); } Push(nTag, t, boost::is_fundamental<T>()); } bool Get(int nTag, std::vector<unsigned char>& vch) { std::map<int, std::pair<int, CCompactTVType>>::iterator it = mapTagValue.find(nTag); if (it == mapTagValue.end()) { return false; } if ((*it).second.first != COMPACT_TYPE_BINARY) { throw std::range_error("type error"); } vch = boost::get<std::vector<unsigned char>>((*it).second.second); return true; } bool Get(int nTag, std::string& str) { std::map<int, std::pair<int, CCompactTVType>>::iterator it = mapTagValue.find(nTag); if (it == mapTagValue.end()) { return false; } if ((*it).second.first != COMPACT_TYPE_BINARY) { throw std::range_error("type error"); } std::vector<unsigned char>& vch = boost::get<std::vector<unsigned char>>((*it).second.second); str = std::string(vch.begin(), vch.end()); return true; } bool Get(int nTag, bool& f) { std::map<int, std::pair<int, CCompactTVType>>::iterator it = mapTagValue.find(nTag); if (it == mapTagValue.end()) { return false; } if ((*it).second.first != COMPACT_TYPE_TRUE && (*it).second.first != COMPACT_TYPE_FALSE) { throw std::range_error("type error"); } f = ((*it).second.first == COMPACT_TYPE_TRUE); return true; } template <typename T> bool Get(int nTag, T& t) { std::map<int, std::pair<int, CCompactTVType>>::iterator it = mapTagValue.find(nTag); if (it == mapTagValue.end()) { return false; } int type = (*it).second.first; if ((type == COMPACT_TYPE_INT256 && sizeof(T) != 32) || (type != COMPACT_TYPE_INT256 && sizeof(T) > 8)) { throw std::range_error("type error"); } if (type == COMPACT_TYPE_INT256) { std::vector<unsigned char>& vch = boost::get<std::vector<unsigned char>>((*it).second.second); t = *(T*)(&vch[0]); } else { t = *(T*)&(boost::get<boost::int64_t>((*it).second.second)); } return true; } void Encode(std::vector<unsigned char>& vchEncode) { for (std::map<int, std::pair<int, CCompactTVType>>::iterator it = mapTagValue.begin(); it != mapTagValue.end(); ++it) { int type = (*it).second.first; vchEncode.push_back((unsigned char)((*it).first | type)); if (type == COMPACT_TYPE_BINARY) { std::vector<unsigned char>& vch = boost::get<std::vector<unsigned char>>((*it).second.second); vchEncode.push_back((unsigned char)vch.size()); vchEncode.insert(vchEncode.end(), vch.begin(), vch.end()); } else if (type == COMPACT_TYPE_INT256) { std::vector<unsigned char>& vch = boost::get<std::vector<unsigned char>>((*it).second.second); vchEncode.insert(vchEncode.end(), vch.begin(), vch.end()); } else { boost::int64_t value = boost::get<boost::int64_t>((*it).second.second); int len = 0; switch (type) { case COMPACT_TYPE_INT8: len = 1; break; case COMPACT_TYPE_INT16: len = 2; break; case COMPACT_TYPE_INT32: len = 4; break; case COMPACT_TYPE_INT64: len = 8; break; default: break; } vchEncode.insert(vchEncode.end(), (unsigned char*)&value, ((unsigned char*)&value) + len); } } } void Decode(const std::vector<unsigned char>& vchEncoded) { mapTagValue.clear(); std::size_t offset = 0; while (offset != vchEncoded.size()) { unsigned char c = vchEncoded[offset++]; int tag = (c & 0x1f); int type = (c & 0xe0); if (type == COMPACT_TYPE_BINARY) { std::size_t size = vchEncoded[offset++]; std::vector<unsigned char> vch(vchEncoded.begin() + offset, vchEncoded.begin() + offset + size); if (!mapTagValue.insert(std::make_pair(tag, std::make_pair(COMPACT_TYPE_BINARY, vch))).second) { throw std::range_error("duplicated tag"); } offset += size; } else if (type == COMPACT_TYPE_INT256) { std::vector<unsigned char> vch(&vchEncoded[offset], &vchEncoded[offset + 32]); if (!mapTagValue.insert(std::make_pair(tag, std::make_pair(COMPACT_TYPE_INT256, vch))).second) { throw std::range_error("duplicated tag"); } offset += 32; } else { boost::int64_t value = 0; switch (type) { case COMPACT_TYPE_INT8: value = *(unsigned char*)(&vchEncoded[offset]); offset += 1; break; case COMPACT_TYPE_INT16: value = *(unsigned short*)(&vchEncoded[offset]); offset += 2; break; case COMPACT_TYPE_INT32: value = *(unsigned int*)(&vchEncoded[offset]); offset += 4; break; case COMPACT_TYPE_INT64: value = *(boost::int64_t*)(&vchEncoded[offset]); offset += 8; break; default: break; } if (!mapTagValue.insert(std::make_pair(tag, std::make_pair(type, (boost::int64_t)value))).second) { throw std::range_error("duplicated tag"); } } } } protected: std::map<int, std::pair<int, CCompactTVType>> mapTagValue; }; } // namespace hcode #endif //HCODE_COMPACTTV_H
33.66065
113
0.505255
eb97b9c8e31219f32bee5093ccb354e5add77fcb
38,288
c
C
wpa_supplicant/robust_av.c
blocktrron/hostap
6c2d13e12b05b0b74a4bf9cb8549ca6ab57d110a
[ "Unlicense" ]
null
null
null
wpa_supplicant/robust_av.c
blocktrron/hostap
6c2d13e12b05b0b74a4bf9cb8549ca6ab57d110a
[ "Unlicense" ]
null
null
null
wpa_supplicant/robust_av.c
blocktrron/hostap
6c2d13e12b05b0b74a4bf9cb8549ca6ab57d110a
[ "Unlicense" ]
null
null
null
/* * wpa_supplicant - Robust AV procedures * Copyright (c) 2020, The Linux Foundation * * This software may be distributed under the terms of the BSD license. * See README for more details. */ #include "utils/includes.h" #include "utils/common.h" #include "utils/eloop.h" #include "common/wpa_ctrl.h" #include "common/ieee802_11_common.h" #include "wpa_supplicant_i.h" #include "driver_i.h" #include "bss.h" #define SCS_RESP_TIMEOUT 1 #define DSCP_REQ_TIMEOUT 5 void wpas_populate_mscs_descriptor_ie(struct robust_av_data *robust_av, struct wpabuf *buf) { u8 *len, *len1; /* MSCS descriptor element */ wpabuf_put_u8(buf, WLAN_EID_EXTENSION); len = wpabuf_put(buf, 1); wpabuf_put_u8(buf, WLAN_EID_EXT_MSCS_DESCRIPTOR); wpabuf_put_u8(buf, robust_av->request_type); wpabuf_put_u8(buf, robust_av->up_bitmap); wpabuf_put_u8(buf, robust_av->up_limit); wpabuf_put_le32(buf, robust_av->stream_timeout); if (robust_av->request_type != SCS_REQ_REMOVE) { /* TCLAS mask element */ wpabuf_put_u8(buf, WLAN_EID_EXTENSION); len1 = wpabuf_put(buf, 1); wpabuf_put_u8(buf, WLAN_EID_EXT_TCLAS_MASK); /* Frame classifier */ wpabuf_put_data(buf, robust_av->frame_classifier, robust_av->frame_classifier_len); *len1 = (u8 *) wpabuf_put(buf, 0) - len1 - 1; } *len = (u8 *) wpabuf_put(buf, 0) - len - 1; } static int wpas_populate_type4_classifier(struct type4_params *type4_param, struct wpabuf *buf) { /* classifier parameters */ wpabuf_put_u8(buf, type4_param->classifier_mask); if (type4_param->ip_version == IPV4) { wpabuf_put_u8(buf, IPV4); /* IP version */ wpabuf_put_data(buf, &type4_param->ip_params.v4.src_ip.s_addr, 4); wpabuf_put_data(buf, &type4_param->ip_params.v4.dst_ip.s_addr, 4); wpabuf_put_be16(buf, type4_param->ip_params.v4.src_port); wpabuf_put_be16(buf, type4_param->ip_params.v4.dst_port); wpabuf_put_u8(buf, type4_param->ip_params.v4.dscp); wpabuf_put_u8(buf, type4_param->ip_params.v4.protocol); wpabuf_put_u8(buf, 0); /* Reserved octet */ } else { wpabuf_put_u8(buf, IPV6); wpabuf_put_data(buf, &type4_param->ip_params.v6.src_ip.s6_addr, 16); wpabuf_put_data(buf, &type4_param->ip_params.v6.dst_ip.s6_addr, 16); wpabuf_put_be16(buf, type4_param->ip_params.v6.src_port); wpabuf_put_be16(buf, type4_param->ip_params.v6.dst_port); wpabuf_put_u8(buf, type4_param->ip_params.v6.dscp); wpabuf_put_u8(buf, type4_param->ip_params.v6.next_header); wpabuf_put_data(buf, type4_param->ip_params.v6.flow_label, 3); } return 0; } static int wpas_populate_type10_classifier(struct type10_params *type10_param, struct wpabuf *buf) { /* classifier parameters */ wpabuf_put_u8(buf, type10_param->prot_instance); wpabuf_put_u8(buf, type10_param->prot_number); wpabuf_put_data(buf, type10_param->filter_value, type10_param->filter_len); wpabuf_put_data(buf, type10_param->filter_mask, type10_param->filter_len); return 0; } static int wpas_populate_scs_descriptor_ie(struct scs_desc_elem *desc_elem, struct wpabuf *buf) { u8 *len, *len1; struct tclas_element *tclas_elem; unsigned int i; /* SCS Descriptor element */ wpabuf_put_u8(buf, WLAN_EID_SCS_DESCRIPTOR); len = wpabuf_put(buf, 1); wpabuf_put_u8(buf, desc_elem->scs_id); wpabuf_put_u8(buf, desc_elem->request_type); if (desc_elem->request_type == SCS_REQ_REMOVE) goto end; if (desc_elem->intra_access_priority || desc_elem->scs_up_avail) { wpabuf_put_u8(buf, WLAN_EID_INTRA_ACCESS_CATEGORY_PRIORITY); wpabuf_put_u8(buf, 1); wpabuf_put_u8(buf, desc_elem->intra_access_priority); } tclas_elem = desc_elem->tclas_elems; if (!tclas_elem) return -1; for (i = 0; i < desc_elem->num_tclas_elem; i++, tclas_elem++) { int ret; /* TCLAS element */ wpabuf_put_u8(buf, WLAN_EID_TCLAS); len1 = wpabuf_put(buf, 1); wpabuf_put_u8(buf, 255); /* User Priority: not compared */ /* Frame Classifier */ wpabuf_put_u8(buf, tclas_elem->classifier_type); /* Frame classifier parameters */ switch (tclas_elem->classifier_type) { case 4: ret = wpas_populate_type4_classifier( &tclas_elem->frame_classifier.type4_param, buf); break; case 10: ret = wpas_populate_type10_classifier( &tclas_elem->frame_classifier.type10_param, buf); break; default: return -1; } if (ret == -1) { wpa_printf(MSG_ERROR, "Failed to populate frame classifier"); return -1; } *len1 = (u8 *) wpabuf_put(buf, 0) - len1 - 1; } if (desc_elem->num_tclas_elem > 1) { /* TCLAS Processing element */ wpabuf_put_u8(buf, WLAN_EID_TCLAS_PROCESSING); wpabuf_put_u8(buf, 1); wpabuf_put_u8(buf, desc_elem->tclas_processing); } end: *len = (u8 *) wpabuf_put(buf, 0) - len - 1; return 0; } int wpas_send_mscs_req(struct wpa_supplicant *wpa_s) { struct wpabuf *buf; size_t buf_len; int ret; if (wpa_s->wpa_state != WPA_COMPLETED || !wpa_s->current_ssid) return 0; if (!wpa_bss_ext_capab(wpa_s->current_bss, WLAN_EXT_CAPAB_MSCS)) { wpa_dbg(wpa_s, MSG_INFO, "AP does not support MSCS - could not send MSCS Req"); return -1; } if (!wpa_s->mscs_setup_done && wpa_s->robust_av.request_type != SCS_REQ_ADD) { wpa_msg(wpa_s, MSG_INFO, "MSCS: Failed to send MSCS Request: request type invalid"); return -1; } buf_len = 3 + /* Action frame header */ 3 + /* MSCS descriptor IE header */ 1 + /* Request type */ 2 + /* User priority control */ 4 + /* Stream timeout */ 3 + /* TCLAS Mask IE header */ wpa_s->robust_av.frame_classifier_len; buf = wpabuf_alloc(buf_len); if (!buf) { wpa_printf(MSG_ERROR, "Failed to allocate MSCS req"); return -1; } wpabuf_put_u8(buf, WLAN_ACTION_ROBUST_AV_STREAMING); wpabuf_put_u8(buf, ROBUST_AV_MSCS_REQ); wpa_s->robust_av.dialog_token++; wpabuf_put_u8(buf, wpa_s->robust_av.dialog_token); /* MSCS descriptor element */ wpas_populate_mscs_descriptor_ie(&wpa_s->robust_av, buf); wpa_hexdump_buf(MSG_MSGDUMP, "MSCS Request", buf); ret = wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid, wpa_s->own_addr, wpa_s->bssid, wpabuf_head(buf), wpabuf_len(buf), 0); if (ret < 0) wpa_dbg(wpa_s, MSG_INFO, "MSCS: Failed to send MSCS Request"); wpabuf_free(buf); return ret; } static size_t tclas_elem_len(const struct tclas_element *elem) { size_t buf_len = 0; buf_len += 2 + /* TCLAS element header */ 1 + /* User Priority */ 1 ; /* Classifier Type */ if (elem->classifier_type == 4) { enum ip_version ip_ver; buf_len += 1 + /* Classifier mask */ 1 + /* IP version */ 1 + /* user priority */ 2 + /* src_port */ 2 + /* dst_port */ 1 ; /* dscp */ ip_ver = elem->frame_classifier.type4_param.ip_version; if (ip_ver == IPV4) { buf_len += 4 + /* src_ip */ 4 + /* dst_ip */ 1 + /* protocol */ 1 ; /* Reserved */ } else if (ip_ver == IPV6) { buf_len += 16 + /* src_ip */ 16 + /* dst_ip */ 1 + /* next_header */ 3 ; /* flow_label */ } else { wpa_printf(MSG_ERROR, "%s: Incorrect IP version %d", __func__, ip_ver); return 0; } } else if (elem->classifier_type == 10) { buf_len += 1 + /* protocol instance */ 1 + /* protocol number */ 2 * elem->frame_classifier.type10_param.filter_len; } else { wpa_printf(MSG_ERROR, "%s: Incorrect classifier type %u", __func__, elem->classifier_type); return 0; } return buf_len; } static struct wpabuf * allocate_scs_buf(struct scs_desc_elem *desc_elem, unsigned int num_scs_desc) { struct wpabuf *buf; size_t buf_len = 0; unsigned int i, j; buf_len = 3; /* Action frame header */ for (i = 0; i < num_scs_desc; i++, desc_elem++) { struct tclas_element *tclas_elem; buf_len += 2 + /* SCS descriptor IE header */ 1 + /* SCSID */ 1 ; /* Request type */ if (desc_elem->request_type == SCS_REQ_REMOVE) continue; if (desc_elem->intra_access_priority || desc_elem->scs_up_avail) buf_len += 3; tclas_elem = desc_elem->tclas_elems; if (!tclas_elem) { wpa_printf(MSG_ERROR, "%s: TCLAS element null", __func__); return NULL; } for (j = 0; j < desc_elem->num_tclas_elem; j++, tclas_elem++) { size_t elen; elen = tclas_elem_len(tclas_elem); if (elen == 0) return NULL; buf_len += elen; } if (desc_elem->num_tclas_elem > 1) { buf_len += 1 + /* TCLAS Processing eid */ 1 + /* length */ 1 ; /* processing */ } } buf = wpabuf_alloc(buf_len); if (!buf) { wpa_printf(MSG_ERROR, "Failed to allocate SCS req"); return NULL; } return buf; } static void scs_request_timer(void *eloop_ctx, void *timeout_ctx) { struct wpa_supplicant *wpa_s = eloop_ctx; struct active_scs_elem *scs_desc, *prev; if (wpa_s->wpa_state != WPA_COMPLETED || !wpa_s->current_ssid) return; /* Once timeout is over, remove all SCS descriptors with no response */ dl_list_for_each_safe(scs_desc, prev, &wpa_s->active_scs_ids, struct active_scs_elem, list) { u8 bssid[ETH_ALEN] = { 0 }; const u8 *src; if (scs_desc->status == SCS_DESC_SUCCESS) continue; if (wpa_s->current_bss) src = wpa_s->current_bss->bssid; else src = bssid; wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SCS_RESULT "bssid=" MACSTR " SCSID=%u status_code=timedout", MAC2STR(src), scs_desc->scs_id); dl_list_del(&scs_desc->list); wpa_printf(MSG_INFO, "%s: SCSID %d removed after timeout", __func__, scs_desc->scs_id); os_free(scs_desc); } eloop_cancel_timeout(scs_request_timer, wpa_s, NULL); wpa_s->ongoing_scs_req = false; } int wpas_send_scs_req(struct wpa_supplicant *wpa_s) { struct wpabuf *buf = NULL; struct scs_desc_elem *desc_elem = NULL; int ret = -1; unsigned int i; if (wpa_s->wpa_state != WPA_COMPLETED || !wpa_s->current_ssid) return -1; if (!wpa_bss_ext_capab(wpa_s->current_bss, WLAN_EXT_CAPAB_SCS)) { wpa_dbg(wpa_s, MSG_INFO, "AP does not support SCS - could not send SCS Request"); return -1; } desc_elem = wpa_s->scs_robust_av_req.scs_desc_elems; if (!desc_elem) return -1; buf = allocate_scs_buf(desc_elem, wpa_s->scs_robust_av_req.num_scs_desc); if (!buf) return -1; wpabuf_put_u8(buf, WLAN_ACTION_ROBUST_AV_STREAMING); wpabuf_put_u8(buf, ROBUST_AV_SCS_REQ); wpa_s->scs_dialog_token++; if (wpa_s->scs_dialog_token == 0) wpa_s->scs_dialog_token++; wpabuf_put_u8(buf, wpa_s->scs_dialog_token); for (i = 0; i < wpa_s->scs_robust_av_req.num_scs_desc; i++, desc_elem++) { /* SCS Descriptor element */ if (wpas_populate_scs_descriptor_ie(desc_elem, buf) < 0) goto end; } wpa_hexdump_buf(MSG_DEBUG, "SCS Request", buf); ret = wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid, wpa_s->own_addr, wpa_s->bssid, wpabuf_head(buf), wpabuf_len(buf), 0); if (ret < 0) { wpa_dbg(wpa_s, MSG_ERROR, "SCS: Failed to send SCS Request"); wpa_s->scs_dialog_token--; goto end; } desc_elem = wpa_s->scs_robust_av_req.scs_desc_elems; for (i = 0; i < wpa_s->scs_robust_av_req.num_scs_desc; i++, desc_elem++) { struct active_scs_elem *active_scs_elem; if (desc_elem->request_type != SCS_REQ_ADD) continue; active_scs_elem = os_malloc(sizeof(struct active_scs_elem)); if (!active_scs_elem) break; active_scs_elem->scs_id = desc_elem->scs_id; active_scs_elem->status = SCS_DESC_SENT; dl_list_add(&wpa_s->active_scs_ids, &active_scs_elem->list); } /* * Register a timeout after which this request will be removed from * the cache. */ eloop_register_timeout(SCS_RESP_TIMEOUT, 0, scs_request_timer, wpa_s, NULL); wpa_s->ongoing_scs_req = true; end: wpabuf_free(buf); free_up_scs_desc(&wpa_s->scs_robust_av_req); return ret; } void free_up_tclas_elem(struct scs_desc_elem *elem) { struct tclas_element *tclas_elems = elem->tclas_elems; unsigned int num_tclas_elem = elem->num_tclas_elem; struct tclas_element *tclas_data; unsigned int j; elem->tclas_elems = NULL; elem->num_tclas_elem = 0; if (!tclas_elems) return; tclas_data = tclas_elems; for (j = 0; j < num_tclas_elem; j++, tclas_data++) { if (tclas_data->classifier_type != 10) continue; os_free(tclas_data->frame_classifier.type10_param.filter_value); os_free(tclas_data->frame_classifier.type10_param.filter_mask); } os_free(tclas_elems); } void free_up_scs_desc(struct scs_robust_av_data *data) { struct scs_desc_elem *desc_elems = data->scs_desc_elems; unsigned int num_scs_desc = data->num_scs_desc; struct scs_desc_elem *desc_data; unsigned int i; data->scs_desc_elems = NULL; data->num_scs_desc = 0; if (!desc_elems) return; desc_data = desc_elems; for (i = 0; i < num_scs_desc; i++, desc_data++) { if (desc_data->request_type == SCS_REQ_REMOVE || !desc_data->tclas_elems) continue; free_up_tclas_elem(desc_data); } os_free(desc_elems); } void wpas_handle_robust_av_recv_action(struct wpa_supplicant *wpa_s, const u8 *src, const u8 *buf, size_t len) { u8 dialog_token; u16 status_code; if (len < 3) return; dialog_token = *buf++; if (dialog_token != wpa_s->robust_av.dialog_token) { wpa_printf(MSG_INFO, "MSCS: Drop received frame due to dialog token mismatch: received:%u expected:%u", dialog_token, wpa_s->robust_av.dialog_token); return; } status_code = WPA_GET_LE16(buf); wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_MSCS_RESULT "bssid=" MACSTR " status_code=%u", MAC2STR(src), status_code); wpa_s->mscs_setup_done = status_code == WLAN_STATUS_SUCCESS; } void wpas_handle_assoc_resp_mscs(struct wpa_supplicant *wpa_s, const u8 *bssid, const u8 *ies, size_t ies_len) { const u8 *mscs_desc_ie, *mscs_status; u16 status; /* Process optional MSCS Status subelement when MSCS IE is in * (Re)Association Response frame */ if (!ies || ies_len == 0 || !wpa_s->robust_av.valid_config) return; mscs_desc_ie = get_ie_ext(ies, ies_len, WLAN_EID_EXT_MSCS_DESCRIPTOR); if (!mscs_desc_ie || mscs_desc_ie[1] <= 8) return; /* Subelements start after (ie_id(1) + ie_len(1) + ext_id(1) + * request type(1) + upc(2) + stream timeout(4) =) 10. */ mscs_status = get_ie(&mscs_desc_ie[10], mscs_desc_ie[1] - 8, MCSC_SUBELEM_STATUS); if (!mscs_status || mscs_status[1] < 2) return; status = WPA_GET_LE16(mscs_status + 2); wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_MSCS_RESULT "bssid=" MACSTR " status_code=%u", MAC2STR(bssid), status); wpa_s->mscs_setup_done = status == WLAN_STATUS_SUCCESS; } static void wpas_wait_for_dscp_req_timer(void *eloop_ctx, void *timeout_ctx) { struct wpa_supplicant *wpa_s = eloop_ctx; /* Once timeout is over, reset wait flag and allow sending DSCP query */ wpa_printf(MSG_DEBUG, "QM: Wait time over for sending DSCP request - allow DSCP query"); wpa_s->wait_for_dscp_req = 0; wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DSCP_POLICY "request_wait end"); } void wpas_handle_assoc_resp_qos_mgmt(struct wpa_supplicant *wpa_s, const u8 *ies, size_t ies_len) { const u8 *wfa_capa; wpa_s->connection_dscp = 0; if (wpa_s->wait_for_dscp_req) eloop_cancel_timeout(wpas_wait_for_dscp_req_timer, wpa_s, NULL); if (!ies || ies_len == 0 || !wpa_s->enable_dscp_policy_capa) return; wfa_capa = get_vendor_ie(ies, ies_len, WFA_CAPA_IE_VENDOR_TYPE); if (!wfa_capa || wfa_capa[1] < 6 || wfa_capa[6] < 1 || !(wfa_capa[7] & WFA_CAPA_QM_DSCP_POLICY)) return; /* AP does not enable QM DSCP Policy */ wpa_s->connection_dscp = 1; wpa_s->wait_for_dscp_req = !!(wfa_capa[7] & WFA_CAPA_QM_UNSOLIC_DSCP); if (!wpa_s->wait_for_dscp_req) return; /* Register a timeout after which dscp query can be sent to AP. */ wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DSCP_POLICY "request_wait start"); eloop_register_timeout(DSCP_REQ_TIMEOUT, 0, wpas_wait_for_dscp_req_timer, wpa_s, NULL); } void wpas_handle_robust_av_scs_recv_action(struct wpa_supplicant *wpa_s, const u8 *src, const u8 *buf, size_t len) { u8 dialog_token; unsigned int i, count; struct active_scs_elem *scs_desc, *prev; if (len < 2) return; if (!wpa_s->ongoing_scs_req) { wpa_printf(MSG_INFO, "SCS: Drop received response due to no ongoing request"); return; } dialog_token = *buf++; len--; if (dialog_token != wpa_s->scs_dialog_token) { wpa_printf(MSG_INFO, "SCS: Drop received frame due to dialog token mismatch: received:%u expected:%u", dialog_token, wpa_s->scs_dialog_token); return; } /* This Count field does not exist in the IEEE Std 802.11-2020 * definition of the SCS Response frame. However, it was accepted to * be added into REVme per REVme/D0.0 CC35 CID 49 (edits in document * 11-21-0688-07). */ count = *buf++; len--; if (count == 0 || count * 3 > len) { wpa_printf(MSG_INFO, "SCS: Drop received frame due to invalid count: %u (remaining %zu octets)", count, len); return; } for (i = 0; i < count; i++) { u8 id; u16 status; bool scs_desc_found = false; id = *buf++; status = WPA_GET_LE16(buf); buf += 2; len -= 3; dl_list_for_each(scs_desc, &wpa_s->active_scs_ids, struct active_scs_elem, list) { if (id == scs_desc->scs_id) { scs_desc_found = true; break; } } if (!scs_desc_found) { wpa_printf(MSG_INFO, "SCS: SCS ID invalid %u", id); continue; } if (status != WLAN_STATUS_SUCCESS) { dl_list_del(&scs_desc->list); os_free(scs_desc); } else if (status == WLAN_STATUS_SUCCESS) { scs_desc->status = SCS_DESC_SUCCESS; } wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SCS_RESULT "bssid=" MACSTR " SCSID=%u status_code=%u", MAC2STR(src), id, status); } eloop_cancel_timeout(scs_request_timer, wpa_s, NULL); wpa_s->ongoing_scs_req = false; dl_list_for_each_safe(scs_desc, prev, &wpa_s->active_scs_ids, struct active_scs_elem, list) { if (scs_desc->status != SCS_DESC_SUCCESS) { wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SCS_RESULT "bssid=" MACSTR " SCSID=%u status_code=response_not_received", MAC2STR(src), scs_desc->scs_id); dl_list_del(&scs_desc->list); os_free(scs_desc); } } } static void wpas_clear_active_scs_ids(struct wpa_supplicant *wpa_s) { struct active_scs_elem *scs_elem; while ((scs_elem = dl_list_first(&wpa_s->active_scs_ids, struct active_scs_elem, list))) { dl_list_del(&scs_elem->list); os_free(scs_elem); } } void wpas_scs_deinit(struct wpa_supplicant *wpa_s) { free_up_scs_desc(&wpa_s->scs_robust_av_req); wpa_s->scs_dialog_token = 0; wpas_clear_active_scs_ids(wpa_s); eloop_cancel_timeout(scs_request_timer, wpa_s, NULL); wpa_s->ongoing_scs_req = false; } static int write_ipv4_info(char *pos, int total_len, const struct ipv4_params *v4) { int res, rem_len; char addr[INET_ADDRSTRLEN]; rem_len = total_len; if (v4->param_mask & BIT(1)) { if (!inet_ntop(AF_INET, &v4->src_ip, addr, INET_ADDRSTRLEN)) { wpa_printf(MSG_ERROR, "QM: Failed to set IPv4 source address"); return -1; } res = os_snprintf(pos, rem_len, " src_ip=%s", addr); if (os_snprintf_error(rem_len, res)) return -1; pos += res; rem_len -= res; } if (v4->param_mask & BIT(2)) { if (!inet_ntop(AF_INET, &v4->dst_ip, addr, INET_ADDRSTRLEN)) { wpa_printf(MSG_ERROR, "QM: Failed to set IPv4 destination address"); return -1; } res = os_snprintf(pos, rem_len, " dst_ip=%s", addr); if (os_snprintf_error(rem_len, res)) return -1; pos += res; rem_len -= res; } if (v4->param_mask & BIT(3)) { res = os_snprintf(pos, rem_len, " src_port=%d", v4->src_port); if (os_snprintf_error(rem_len, res)) return -1; pos += res; rem_len -= res; } if (v4->param_mask & BIT(4)) { res = os_snprintf(pos, rem_len, " dst_port=%d", v4->dst_port); if (os_snprintf_error(rem_len, res)) return -1; pos += res; rem_len -= res; } if (v4->param_mask & BIT(6)) { res = os_snprintf(pos, rem_len, " protocol=%d", v4->protocol); if (os_snprintf_error(rem_len, res)) return -1; pos += res; rem_len -= res; } return total_len - rem_len; } static int write_ipv6_info(char *pos, int total_len, const struct ipv6_params *v6) { int res, rem_len; char addr[INET6_ADDRSTRLEN]; rem_len = total_len; if (v6->param_mask & BIT(1)) { if (!inet_ntop(AF_INET6, &v6->src_ip, addr, INET6_ADDRSTRLEN)) { wpa_printf(MSG_ERROR, "QM: Failed to set IPv6 source addr"); return -1; } res = os_snprintf(pos, rem_len, " src_ip=%s", addr); if (os_snprintf_error(rem_len, res)) return -1; pos += res; rem_len -= res; } if (v6->param_mask & BIT(2)) { if (!inet_ntop(AF_INET6, &v6->dst_ip, addr, INET6_ADDRSTRLEN)) { wpa_printf(MSG_ERROR, "QM: Failed to set IPv6 destination addr"); return -1; } res = os_snprintf(pos, rem_len, " dst_ip=%s", addr); if (os_snprintf_error(rem_len, res)) return -1; pos += res; rem_len -= res; } if (v6->param_mask & BIT(3)) { res = os_snprintf(pos, rem_len, " src_port=%d", v6->src_port); if (os_snprintf_error(rem_len, res)) return -1; pos += res; rem_len -= res; } if (v6->param_mask & BIT(4)) { res = os_snprintf(pos, rem_len, " dst_port=%d", v6->dst_port); if (os_snprintf_error(rem_len, res)) return -1; pos += res; rem_len -= res; } if (v6->param_mask & BIT(6)) { res = os_snprintf(pos, rem_len, " protocol=%d", v6->next_header); if (os_snprintf_error(rem_len, res)) return -1; pos += res; rem_len -= res; } return total_len - rem_len; } struct dscp_policy_data { u8 policy_id; u8 req_type; u8 dscp; bool dscp_info; const u8 *frame_classifier; u8 frame_classifier_len; struct type4_params type4_param; const u8 *domain_name; u8 domain_name_len; u16 start_port; u16 end_port; bool port_range_info; }; static int set_frame_classifier_type4_ipv4(struct dscp_policy_data *policy) { u8 classifier_mask; const u8 *frame_classifier = policy->frame_classifier; struct type4_params *type4_param = &policy->type4_param; if (policy->frame_classifier_len < 18) { wpa_printf(MSG_ERROR, "QM: Received IPv4 frame classifier with insufficient length %d", policy->frame_classifier_len); return -1; } classifier_mask = frame_classifier[1]; /* Classifier Mask - bit 1 = Source IP Address */ if (classifier_mask & BIT(1)) { type4_param->ip_params.v4.param_mask |= BIT(1); os_memcpy(&type4_param->ip_params.v4.src_ip, &frame_classifier[3], 4); } /* Classifier Mask - bit 2 = Destination IP Address */ if (classifier_mask & BIT(2)) { if (policy->domain_name) { wpa_printf(MSG_ERROR, "QM: IPv4: Both domain name and destination IP address not expected"); return -1; } type4_param->ip_params.v4.param_mask |= BIT(2); os_memcpy(&type4_param->ip_params.v4.dst_ip, &frame_classifier[7], 4); } /* Classifier Mask - bit 3 = Source Port */ if (classifier_mask & BIT(3)) { type4_param->ip_params.v4.param_mask |= BIT(3); type4_param->ip_params.v4.src_port = WPA_GET_BE16(&frame_classifier[11]); } /* Classifier Mask - bit 4 = Destination Port */ if (classifier_mask & BIT(4)) { if (policy->port_range_info) { wpa_printf(MSG_ERROR, "QM: IPv4: Both port range and destination port not expected"); return -1; } type4_param->ip_params.v4.param_mask |= BIT(4); type4_param->ip_params.v4.dst_port = WPA_GET_BE16(&frame_classifier[13]); } /* Classifier Mask - bit 5 = DSCP (ignored) */ /* Classifier Mask - bit 6 = Protocol */ if (classifier_mask & BIT(6)) { type4_param->ip_params.v4.param_mask |= BIT(6); type4_param->ip_params.v4.protocol = frame_classifier[16]; } return 0; } static int set_frame_classifier_type4_ipv6(struct dscp_policy_data *policy) { u8 classifier_mask; const u8 *frame_classifier = policy->frame_classifier; struct type4_params *type4_param = &policy->type4_param; if (policy->frame_classifier_len < 44) { wpa_printf(MSG_ERROR, "QM: Received IPv6 frame classifier with insufficient length %d", policy->frame_classifier_len); return -1; } classifier_mask = frame_classifier[1]; /* Classifier Mask - bit 1 = Source IP Address */ if (classifier_mask & BIT(1)) { type4_param->ip_params.v6.param_mask |= BIT(1); os_memcpy(&type4_param->ip_params.v6.src_ip, &frame_classifier[3], 16); } /* Classifier Mask - bit 2 = Destination IP Address */ if (classifier_mask & BIT(2)) { if (policy->domain_name) { wpa_printf(MSG_ERROR, "QM: IPv6: Both domain name and destination IP address not expected"); return -1; } type4_param->ip_params.v6.param_mask |= BIT(2); os_memcpy(&type4_param->ip_params.v6.dst_ip, &frame_classifier[19], 16); } /* Classifier Mask - bit 3 = Source Port */ if (classifier_mask & BIT(3)) { type4_param->ip_params.v6.param_mask |= BIT(3); type4_param->ip_params.v6.src_port = WPA_GET_BE16(&frame_classifier[35]); } /* Classifier Mask - bit 4 = Destination Port */ if (classifier_mask & BIT(4)) { if (policy->port_range_info) { wpa_printf(MSG_ERROR, "IPv6: Both port range and destination port not expected"); return -1; } type4_param->ip_params.v6.param_mask |= BIT(4); type4_param->ip_params.v6.dst_port = WPA_GET_BE16(&frame_classifier[37]); } /* Classifier Mask - bit 5 = DSCP (ignored) */ /* Classifier Mask - bit 6 = Next Header */ if (classifier_mask & BIT(6)) { type4_param->ip_params.v6.param_mask |= BIT(6); type4_param->ip_params.v6.next_header = frame_classifier[40]; } return 0; } static int wpas_set_frame_classifier_params(struct dscp_policy_data *policy) { const u8 *frame_classifier = policy->frame_classifier; u8 frame_classifier_len = policy->frame_classifier_len; if (frame_classifier_len < 3) { wpa_printf(MSG_ERROR, "QM: Received frame classifier with insufficient length %d", frame_classifier_len); return -1; } /* Only allowed Classifier Type: IP and higher layer parameters (4) */ if (frame_classifier[0] != 4) { wpa_printf(MSG_ERROR, "QM: Received frame classifier with invalid classifier type %d", frame_classifier[0]); return -1; } /* Classifier Mask - bit 0 = Version */ if (!(frame_classifier[1] & BIT(0))) { wpa_printf(MSG_ERROR, "QM: Received frame classifier without IP version"); return -1; } /* Version (4 or 6) */ if (frame_classifier[2] == 4) { if (set_frame_classifier_type4_ipv4(policy)) { wpa_printf(MSG_ERROR, "QM: Failed to set IPv4 parameters"); return -1; } policy->type4_param.ip_version = IPV4; } else if (frame_classifier[2] == 6) { if (set_frame_classifier_type4_ipv6(policy)) { wpa_printf(MSG_ERROR, "QM: Failed to set IPv6 parameters"); return -1; } policy->type4_param.ip_version = IPV6; } else { wpa_printf(MSG_ERROR, "QM: Received unknown IP version %d", frame_classifier[2]); return -1; } return 0; } static bool dscp_valid_domain_name(const char *str) { if (!str[0]) return false; while (*str) { if (is_ctrl_char(*str) || *str == ' ' || *str == '=') return false; str++; } return true; } static void wpas_add_dscp_policy(struct wpa_supplicant *wpa_s, struct dscp_policy_data *policy) { int ip_ver = 0, res; char policy_str[1000], *pos; int len; if (!policy->frame_classifier && !policy->domain_name && !policy->port_range_info) { wpa_printf(MSG_ERROR, "QM: Invalid DSCP policy - no attributes present"); goto fail; } policy_str[0] = '\0'; pos = policy_str; len = sizeof(policy_str); if (policy->frame_classifier) { struct type4_params *type4 = &policy->type4_param; if (wpas_set_frame_classifier_params(policy)) { wpa_printf(MSG_ERROR, "QM: Failed to set frame classifier parameters"); goto fail; } if (type4->ip_version == IPV4) res = write_ipv4_info(pos, len, &type4->ip_params.v4); else res = write_ipv6_info(pos, len, &type4->ip_params.v6); if (res <= 0) { wpa_printf(MSG_ERROR, "QM: Failed to write IP parameters"); goto fail; } ip_ver = type4->ip_version; pos += res; len -= res; } if (policy->port_range_info) { res = os_snprintf(pos, len, " start_port=%u end_port=%u", policy->start_port, policy->end_port); if (os_snprintf_error(len, res)) { wpa_printf(MSG_ERROR, "QM: Failed to write port range attributes for policy id = %d", policy->policy_id); goto fail; } pos += res; len -= res; } if (policy->domain_name) { char domain_name_str[250]; if (policy->domain_name_len >= sizeof(domain_name_str)) { wpa_printf(MSG_ERROR, "QM: Domain name length higher than max expected"); goto fail; } os_memcpy(domain_name_str, policy->domain_name, policy->domain_name_len); domain_name_str[policy->domain_name_len] = '\0'; if (!dscp_valid_domain_name(domain_name_str)) { wpa_printf(MSG_ERROR, "QM: Invalid domain name string"); goto fail; } res = os_snprintf(pos, len, " domain_name=%s", domain_name_str); if (os_snprintf_error(len, res)) { wpa_printf(MSG_ERROR, "QM: Failed to write domain name attribute for policy id = %d", policy->policy_id); goto fail; } } wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DSCP_POLICY "add policy_id=%u dscp=%u ip_version=%d%s", policy->policy_id, policy->dscp, ip_ver, policy_str); return; fail: wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DSCP_POLICY "reject policy_id=%u", policy->policy_id); } void wpas_dscp_deinit(struct wpa_supplicant *wpa_s) { wpa_printf(MSG_DEBUG, "QM: Clear all active DSCP policies"); wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DSCP_POLICY "clear_all"); wpa_s->dscp_req_dialog_token = 0; wpa_s->dscp_query_dialog_token = 0; wpa_s->connection_dscp = 0; if (wpa_s->wait_for_dscp_req) { wpa_s->wait_for_dscp_req = 0; eloop_cancel_timeout(wpas_wait_for_dscp_req_timer, wpa_s, NULL); } } static void wpas_fill_dscp_policy(struct dscp_policy_data *policy, u8 attr_id, u8 attr_len, const u8 *attr_data) { switch (attr_id) { case QM_ATTR_PORT_RANGE: if (attr_len < 4) { wpa_printf(MSG_ERROR, "QM: Received Port Range attribute with insufficient length %d", attr_len); break; } policy->start_port = WPA_GET_BE16(attr_data); policy->end_port = WPA_GET_BE16(attr_data + 2); policy->port_range_info = true; break; case QM_ATTR_DSCP_POLICY: if (attr_len < 3) { wpa_printf(MSG_ERROR, "QM: Received DSCP Policy attribute with insufficient length %d", attr_len); return; } policy->policy_id = attr_data[0]; policy->req_type = attr_data[1]; policy->dscp = attr_data[2]; policy->dscp_info = true; break; case QM_ATTR_TCLAS: if (attr_len < 1) { wpa_printf(MSG_ERROR, "QM: Received TCLAS attribute with insufficient length %d", attr_len); return; } policy->frame_classifier = attr_data; policy->frame_classifier_len = attr_len; break; case QM_ATTR_DOMAIN_NAME: if (attr_len < 1) { wpa_printf(MSG_ERROR, "QM: Received domain name attribute with insufficient length %d", attr_len); return; } policy->domain_name = attr_data; policy->domain_name_len = attr_len; break; default: wpa_printf(MSG_ERROR, "QM: Received invalid QoS attribute %d", attr_id); break; } } void wpas_handle_qos_mgmt_recv_action(struct wpa_supplicant *wpa_s, const u8 *src, const u8 *buf, size_t len) { int rem_len; const u8 *qos_ie, *attr; int more, reset; if (!wpa_s->enable_dscp_policy_capa) { wpa_printf(MSG_ERROR, "QM: Ignore DSCP Policy frame since the capability is not enabled"); return; } if (!pmf_in_use(wpa_s, src)) { wpa_printf(MSG_ERROR, "QM: Ignore DSCP Policy frame since PMF is not in use"); return; } if (!wpa_s->connection_dscp) { wpa_printf(MSG_DEBUG, "QM: DSCP Policy capability not enabled for the current association - ignore QoS Management Action frames"); return; } if (len < 1) return; /* Handle only DSCP Policy Request frame */ if (buf[0] != QM_DSCP_POLICY_REQ) { wpa_printf(MSG_ERROR, "QM: Received unexpected QoS action frame %d", buf[0]); return; } if (len < 3) { wpa_printf(MSG_ERROR, "Received QoS Management DSCP Policy Request frame with invalid length %zu", len); return; } /* Clear wait_for_dscp_req on receiving first DSCP request from AP */ if (wpa_s->wait_for_dscp_req) { wpa_s->wait_for_dscp_req = 0; eloop_cancel_timeout(wpas_wait_for_dscp_req_timer, wpa_s, NULL); } wpa_s->dscp_req_dialog_token = buf[1]; more = buf[2] & DSCP_POLICY_CTRL_MORE; reset = buf[2] & DSCP_POLICY_CTRL_RESET; wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DSCP_POLICY "request_start%s%s", reset ? " clear_all" : "", more ? " more" : ""); qos_ie = buf + 3; rem_len = len - 3; while (rem_len > 2) { struct dscp_policy_data policy; int rem_attrs_len, ie_len; ie_len = 2 + qos_ie[1]; if (rem_len < ie_len) break; if (rem_len < 6 || qos_ie[0] != WLAN_EID_VENDOR_SPECIFIC || qos_ie[1] < 4 || WPA_GET_BE32(&qos_ie[2]) != QM_IE_VENDOR_TYPE) { rem_len -= ie_len; qos_ie += ie_len; continue; } os_memset(&policy, 0, sizeof(struct dscp_policy_data)); attr = qos_ie + 6; rem_attrs_len = qos_ie[1] - 4; while (rem_attrs_len > 2) { u8 attr_id, attr_len; attr_id = *attr++; attr_len = *attr++; rem_attrs_len -= 2; if (attr_len > rem_attrs_len) break; wpas_fill_dscp_policy(&policy, attr_id, attr_len, attr); rem_attrs_len -= attr_len; attr += attr_len; } rem_len -= ie_len; qos_ie += ie_len; if (!policy.dscp_info) { wpa_printf(MSG_ERROR, "QM: Received QoS IE without DSCP Policy attribute"); continue; } if (policy.req_type == DSCP_POLICY_REQ_ADD) wpas_add_dscp_policy(wpa_s, &policy); else if (policy.req_type == DSCP_POLICY_REQ_REMOVE) wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DSCP_POLICY "remove policy_id=%u", policy.policy_id); else wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DSCP_POLICY "reject policy_id=%u", policy.policy_id); } wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DSCP_POLICY "request_end"); } int wpas_send_dscp_response(struct wpa_supplicant *wpa_s, struct dscp_resp_data *resp_data) { struct wpabuf *buf = NULL; size_t buf_len; int ret = -1, i; u8 resp_control = 0; if (wpa_s->wpa_state != WPA_COMPLETED || !wpa_s->current_ssid) { wpa_printf(MSG_ERROR, "QM: Failed to send DSCP response - not connected to AP"); return -1; } if (resp_data->solicited && !wpa_s->dscp_req_dialog_token) { wpa_printf(MSG_ERROR, "QM: No ongoing DSCP request"); return -1; } if (!wpa_s->connection_dscp) { wpa_printf(MSG_ERROR, "QM: Failed to send DSCP response - DSCP capability not enabled for the current association"); return -1; } buf_len = 1 + /* Category */ 3 + /* OUI */ 1 + /* OUI Type */ 1 + /* OUI Subtype */ 1 + /* Dialog Token */ 1 + /* Response Control */ 1 + /* Count */ 2 * resp_data->num_policies; /* Status list */ buf = wpabuf_alloc(buf_len); if (!buf) { wpa_printf(MSG_ERROR, "QM: Failed to allocate DSCP policy response"); return -1; } wpabuf_put_u8(buf, WLAN_ACTION_VENDOR_SPECIFIC_PROTECTED); wpabuf_put_be24(buf, OUI_WFA); wpabuf_put_u8(buf, QM_ACTION_OUI_TYPE); wpabuf_put_u8(buf, QM_DSCP_POLICY_RESP); wpabuf_put_u8(buf, resp_data->solicited ? wpa_s->dscp_req_dialog_token : 0); if (resp_data->more) resp_control |= DSCP_POLICY_CTRL_MORE; if (resp_data->reset) resp_control |= DSCP_POLICY_CTRL_RESET; wpabuf_put_u8(buf, resp_control); wpabuf_put_u8(buf, resp_data->num_policies); for (i = 0; i < resp_data->num_policies; i++) { wpabuf_put_u8(buf, resp_data->policy[i].id); wpabuf_put_u8(buf, resp_data->policy[i].status); } wpa_hexdump_buf(MSG_MSGDUMP, "DSCP response frame: ", buf); ret = wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid, wpa_s->own_addr, wpa_s->bssid, wpabuf_head(buf), wpabuf_len(buf), 0); if (ret < 0) { wpa_msg(wpa_s, MSG_INFO, "QM: Failed to send DSCP response"); goto fail; } /* * Mark DSCP request complete whether response sent is solicited or * unsolicited */ wpa_s->dscp_req_dialog_token = 0; fail: wpabuf_free(buf); return ret; } int wpas_send_dscp_query(struct wpa_supplicant *wpa_s, const char *domain_name, size_t domain_name_length) { struct wpabuf *buf = NULL; int ret, dscp_query_size; if (wpa_s->wpa_state != WPA_COMPLETED || !wpa_s->current_ssid) return -1; if (!wpa_s->connection_dscp) { wpa_printf(MSG_ERROR, "QM: Failed to send DSCP query - DSCP capability not enabled for the current association"); return -1; } if (wpa_s->wait_for_dscp_req) { wpa_printf(MSG_INFO, "QM: Wait until AP sends a DSCP request"); return -1; } #define DOMAIN_NAME_OFFSET (4 /* OUI */ + 1 /* Attr Id */ + 1 /* Attr len */) if (domain_name_length > 255 - DOMAIN_NAME_OFFSET) { wpa_printf(MSG_ERROR, "QM: Too long domain name"); return -1; } dscp_query_size = 1 + /* Category */ 4 + /* OUI Type */ 1 + /* OUI subtype */ 1; /* Dialog Token */ if (domain_name && domain_name_length) dscp_query_size += 1 + /* Element ID */ 1 + /* IE Length */ DOMAIN_NAME_OFFSET + domain_name_length; buf = wpabuf_alloc(dscp_query_size); if (!buf) { wpa_printf(MSG_ERROR, "QM: Failed to allocate DSCP query"); return -1; } wpabuf_put_u8(buf, WLAN_ACTION_VENDOR_SPECIFIC_PROTECTED); wpabuf_put_be32(buf, QM_ACTION_VENDOR_TYPE); wpabuf_put_u8(buf, QM_DSCP_POLICY_QUERY); wpa_s->dscp_query_dialog_token++; if (wpa_s->dscp_query_dialog_token == 0) wpa_s->dscp_query_dialog_token++; wpabuf_put_u8(buf, wpa_s->dscp_query_dialog_token); if (domain_name && domain_name_length) { /* Domain Name attribute */ wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC); wpabuf_put_u8(buf, DOMAIN_NAME_OFFSET + domain_name_length); wpabuf_put_be32(buf, QM_IE_VENDOR_TYPE); wpabuf_put_u8(buf, QM_ATTR_DOMAIN_NAME); wpabuf_put_u8(buf, domain_name_length); wpabuf_put_data(buf, domain_name, domain_name_length); } #undef DOMAIN_NAME_OFFSET ret = wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid, wpa_s->own_addr, wpa_s->bssid, wpabuf_head(buf), wpabuf_len(buf), 0); if (ret < 0) { wpa_dbg(wpa_s, MSG_ERROR, "QM: Failed to send DSCP query"); wpa_s->dscp_query_dialog_token--; } wpabuf_free(buf); return ret; }
25.627845
115
0.690138
6fc20304510f34dc416312c41f1424195d57d6d7
1,878
c
C
projects/lab1/src/configuracion.c
SantiagoGianotti/Lab-Transmision-Datos
f0daa02117bc327012c9dba3f052a6464b552d76
[ "BSD-3-Clause" ]
null
null
null
projects/lab1/src/configuracion.c
SantiagoGianotti/Lab-Transmision-Datos
f0daa02117bc327012c9dba3f052a6464b552d76
[ "BSD-3-Clause" ]
null
null
null
projects/lab1/src/configuracion.c
SantiagoGianotti/Lab-Transmision-Datos
f0daa02117bc327012c9dba3f052a6464b552d76
[ "BSD-3-Clause" ]
null
null
null
#include "configuracion.h" void ConfigurarInterrupcion(void) { __asm__ volatile ("cpsid i"); /* Activate SysTick */ SystemCoreClockUpdate(); SysTick_Config(SystemCoreClock/1000); /* Update priority set by SysTick_Config */ NVIC_SetPriority(SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); __asm__ volatile ("cpsie i"); } void ConfigurarPuertosLaboratorio(void) { #define SCU_MODE_SAL (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS) #define SCU_MODE_ENT (SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN) /* Puerto Led RGB */ /* Chip_SCU_PinMux(port, pin, options, function); */ Chip_SCU_PinMux(2, 0, SCU_MODE_SAL, SCU_MODE_FUNC4); Chip_SCU_PinMux(2, 1, SCU_MODE_SAL, SCU_MODE_FUNC4); Chip_SCU_PinMux(2, 2, SCU_MODE_SAL, SCU_MODE_FUNC4); /* Chip_GPIO_ClearValue(LPC_GPIO_PORT, port, mask); */ Chip_GPIO_ClearValue(LPC_GPIO_PORT, 5, (1 << 0) | (1 << 1) | (1 << 2)); /* Chip_GPIO_SetDir(LPC_GPIO_PORT, port, mask, output); */ Chip_GPIO_SetDir(LPC_GPIO_PORT, 5, (1 << 0) | (1 << 1) | (1 << 2), 1); /* Puerto Leds 1 a 3 */ Chip_SCU_PinMux(2, 10, SCU_MODE_SAL, SCU_MODE_FUNC0); Chip_SCU_PinMux(2, 11, SCU_MODE_SAL, SCU_MODE_FUNC0); Chip_SCU_PinMux(2, 12, SCU_MODE_SAL, SCU_MODE_FUNC0); Chip_GPIO_ClearValue(LPC_GPIO_PORT, 0, (1 << 14)); Chip_GPIO_ClearValue(LPC_GPIO_PORT, 1, (1 << 11) | (1 << 12)); Chip_GPIO_SetDir(LPC_GPIO_PORT, 0, (1 << 14), true); Chip_GPIO_SetDir(LPC_GPIO_PORT, 1, (1 << 11) | (1 << 12), true); /* Puerto Teclas 1 a 4 */ Chip_SCU_PinMux(1, 0, SCU_MODE_ENT, SCU_MODE_FUNC0); Chip_SCU_PinMux(1, 1, SCU_MODE_ENT, SCU_MODE_FUNC0); Chip_SCU_PinMux(1, 2, SCU_MODE_ENT, SCU_MODE_FUNC0); Chip_SCU_PinMux(1, 6, SCU_MODE_ENT, SCU_MODE_FUNC0); Chip_GPIO_SetDir(LPC_GPIO_PORT, 0, (1 << 4) | (1 << 8) | (1 << 9), false); Chip_GPIO_SetDir(LPC_GPIO_PORT, 1, (1 << 9), false); }
39.125
80
0.690628