hexsha
stringlengths
40
40
size
int64
5
2.72M
ext
stringclasses
5 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
3
976
max_stars_repo_name
stringlengths
5
113
max_stars_repo_head_hexsha
stringlengths
40
78
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:01:43
2022-03-31 23:59:48
max_stars_repo_stars_event_max_datetime
stringdate
2015-01-01 00:06:24
2022-03-31 23:59:53
max_issues_repo_path
stringlengths
3
976
max_issues_repo_name
stringlengths
5
116
max_issues_repo_head_hexsha
stringlengths
40
78
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
976
max_forks_repo_name
stringlengths
5
116
max_forks_repo_head_hexsha
stringlengths
40
78
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:19
2022-03-31 23:59:49
max_forks_repo_forks_event_max_datetime
stringdate
2015-01-03 12:00:57
2022-03-31 23:59:49
content
stringlengths
5
2.72M
avg_line_length
float64
1.38
573k
max_line_length
int64
2
1.01M
alphanum_fraction
float64
0
1
26516d0fd8b7f58c34c02e171910131241f4cfab
2,510
h
C
ZAPDUtils/Utils/StringHelper.h
Dragorn421/ZAPD
e02e151c91d006279c4cb75636fead5d1663c7d3
[ "MIT" ]
null
null
null
ZAPDUtils/Utils/StringHelper.h
Dragorn421/ZAPD
e02e151c91d006279c4cb75636fead5d1663c7d3
[ "MIT" ]
9
2020-12-29T00:20:37.000Z
2020-12-29T01:57:42.000Z
ZAPDUtils/Utils/StringHelper.h
Dragorn421/ZAPD
e02e151c91d006279c4cb75636fead5d1663c7d3
[ "MIT" ]
1
2021-01-02T03:19:49.000Z
2021-01-02T03:19:49.000Z
#pragma once #include <algorithm> #include <cstring> #include <numeric> #include <stdarg.h> #include <string> #include <vector> #ifndef __PRETTY_FUNCTION__ #ifdef _MSC_VER #define __PRETTY_FUNCTION__ __FUNCSIG__ #else #define __PRETTY_FUNCTION__ __func__ #endif #endif class StringHelper { public: static std::vector<std::string> Split(std::string s, const std::string& delimiter) { std::vector<std::string> result; size_t pos = 0; std::string token; while ((pos = s.find(delimiter)) != std::string::npos) { token = s.substr(0, pos); result.push_back(token); s.erase(0, pos + delimiter.length()); } if (s.length() != 0) result.push_back(s); return result; } static std::string Strip(std::string s, const std::string& delimiter) { size_t pos = 0; std::string token; while ((pos = s.find(delimiter)) != std::string::npos) { token = s.substr(0, pos); s.erase(pos, pos + delimiter.length()); } return s; } static std::string Replace(std::string str, const std::string& from, const std::string& to) { size_t start_pos = str.find(from); if (start_pos == std::string::npos) return str; str.replace(start_pos, from.length(), to); return str; } static bool StartsWith(const std::string& s, const std::string& input) { return s.rfind(input, 0) == 0; } static bool Contains(const std::string& s, const std::string& input) { return s.find(input) != std::string::npos; } static bool EndsWith(const std::string& s, const std::string& input) { size_t inputLen = strlen(input.c_str()); return s.rfind(input) == (s.size() - inputLen); } static std::string Sprintf(const char* format, ...) { char buffer[32768]; // char buffer[2048]; std::string output = ""; va_list va; va_start(va, format); vsprintf(buffer, format, va); va_end(va); output = buffer; return output; } static std::string Implode(std::vector<std::string>& elements, const char* const separator) { return std::accumulate(std::begin(elements), std::end(elements), std::string(), [separator](std::string& ss, std::string& s) { return ss.empty() ? s : ss + separator + s; }); } static int64_t StrToL(const std::string& str, int32_t base = 10) { return std::strtoull(str.c_str(), nullptr, base); } static std::string BoolStr(bool b) { return b ? "true" : "false"; } static bool HasOnlyDigits(const std::string& str) { return std::all_of(str.begin(), str.end(), ::isdigit); } };
21.452991
92
0.647809
2652ce4e90d8ef9434f5af776259b2ac8645813f
3,959
h
C
include/nlpp/Newton/Factorizations.h
matheuspf/nlpp
5fdcf519ffd4dd1fa562f5d50957a6b0320ac389
[ "MIT" ]
2
2020-07-11T13:38:14.000Z
2020-08-19T08:23:03.000Z
include/nlpp/Newton/Factorizations.h
matheuspf/nlpp
5fdcf519ffd4dd1fa562f5d50957a6b0320ac389
[ "MIT" ]
null
null
null
include/nlpp/Newton/Factorizations.h
matheuspf/nlpp
5fdcf519ffd4dd1fa562f5d50957a6b0320ac389
[ "MIT" ]
null
null
null
#pragma once #include "../Helpers/Helpers.h" namespace nlpp { namespace fact { struct SimplyInvert { template <class V, class U> impl::Plain<V> operator () (const Eigen::MatrixBase<V>& grad, const Eigen::MatrixBase<U>& hess) { return -hess.colPivHouseholderQr().solve(grad); } }; template <typename Float = types::Float> struct SmallIdentity { SmallIdentity (Float alpha = 1e-5) : alpha(alpha) {} template <class V, class U> impl::Plain<V> operator () (const Eigen::MatrixBase<V>& grad, U hess) { auto minDiag = hess.diagonal().array().minCoeff(); if(minDiag < 0.0) hess.diagonal().array() += minDiag + alpha; return -hess.colPivHouseholderQr().solve(grad); } Float alpha; }; template <typename Float = types::Float> struct CholeskyIdentity { CholeskyIdentity (Float beta = 1e-3, Float c = 2.0, Float maxTau = 1e8) : beta(beta), c(c), maxTau(maxTau) {} template <class V, class U> impl::Plain<V> operator () (const Eigen::MatrixBase<V>& grad, U hess) { impl::PlainArray<U> orgDiag = hess.diagonal().array(); auto minDiag = orgDiag.minCoeff(); Float tau = minDiag < 0.0 ? beta - minDiag : 0.0; while(tau < maxTau) { Eigen::LLT<impl::Plain<U>> llt(hess); if(llt.info() == Eigen::Success) return -llt.solve(grad); hess.diagonal().array() = orgDiag + tau; tau = std::max(c * tau, beta); } return -grad; } Float beta; Float c; Float maxTau; }; template <typename Float = types::Float> struct CholeskyFactorization { CholeskyFactorization (Float delta = 1e-3) : delta(delta) {} Vec operator () (const Vec& grad, Mat hess) { int N = hess.rows(); double maxDiag = -1e20, maxOffDiag = -1e20; for(int i = 0; i < N; ++i) { maxDiag = std::max(maxDiag, std::abs(hess(i, i))); for(int j = 0; j < N; ++j) if(i != j) maxOffDiag = std::max(maxOffDiag, std::abs(hess(i, j))); } double beta = std::max(constants::eps, std::max(maxDiag, maxOffDiag / std::max(1.0, sqrt(N*N - 1.0)))); Mat L = Mat::Identity(N, N); Mat C = Mat::Identity(N, N); Mat D = Mat::Constant(N, N, 0.0); Mat E = Mat::Constant(N, N, 0.0); Mat Q = Mat::Identity(N, N); Mat O = Mat::Identity(N, N); for(int i = 0; i < N; ++i) C(i, i) = hess(i, i); for(int i = 0; i < N; ++i) { double val = -1e20; int p = 0; for(int j = i; j < N; ++j) if(std::abs(hess(j, j)) > val) val = std::abs(hess(j, j)), p = j; if(p != i) { Mat P = Mat::Identity(N, N); P(i, i) = P(p, p) = 0.0; P(i, p) = P(p, i) = 1.0; hess = P * hess * P.transpose(); Q = P * Q; O = O * P.transpose(); } double phi = -1e20; for(int j = 0; j < i; ++j) L(i, j) = C(i, j) / D(j, j); for(int j = i+1; j < N; ++j) { C(j, i) = hess(j, i); for(int k = 0; k < i; ++k) C(j, i) -= L(i, k) * C(j, k); phi = std::max(phi, std::abs(C(j, i))); } if(i == N-1) phi = 0.0; D(i, i) = std::max(delta, std::max(std::abs(C(i, i)), pow(phi, 2) / beta)); E(i, i) = D(i, i) - C(i, i); for(int j = i+1; j < N; ++j) C(j, j) = C(j, j) - pow(C(j, i), 2) / D(i, i); } hess = Q.inverse() * (hess + E) * O.inverse(); return -hess.colPivHouseholderQr().solve(grad); } double delta; }; struct IndefiniteFactorization { IndefiniteFactorization (double delta = 1e-2) : delta(delta) {} Vec operator () (const Vec& grad, Mat hess) { int N = hess.rows(); Eigen::RealSchur<Mat> schur(hess); Eigen::EigenSolver<Mat> eigen(schur.matrixT()); const Vec& eigVal = eigen.eigenvalues().real(); const Mat& eigVec = eigen.eigenvectors().real(); Mat F = Mat::Constant(N, N, 0.0); for(int i = 0; i < N; ++i) F(i, i) = (eigVal[i] < delta ? delta - eigVal[i] : 0.0); F = schur.matrixT() + eigVec * F * eigVec.transpose(); return -schur.matrixU() * F.llt().solve(Mat::Identity(N, N)) * schur.matrixU().transpose() * grad; } double delta; }; } // namespace fact } // namespace nlpp
18.674528
110
0.564789
2653557d22d7f7e3588a4df7f2a71b07d92cffb6
10,459
c
C
SerialWombat18A_18B/SerialWombat18A_18B.X/counter.c
BroadwellConsultingInc/SerialWombat
76157af96f2f68169d4e4116f9a199eb987d3b88
[ "MIT" ]
5
2021-01-25T01:16:35.000Z
2022-02-12T12:54:20.000Z
SerialWombat18A_18B/SerialWombat18A_18B.X/counter.c
BroadwellConsultingInc/SerialWombat
76157af96f2f68169d4e4116f9a199eb987d3b88
[ "MIT" ]
17
2021-01-22T22:09:08.000Z
2021-08-31T21:21:10.000Z
SerialWombat18A_18B/SerialWombat18A_18B.X/counter.c
BroadwellConsultingInc/SerialWombat
76157af96f2f68169d4e4116f9a199eb987d3b88
[ "MIT" ]
2
2022-01-30T15:05:14.000Z
2022-02-08T20:25:58.000Z
#ifndef COMPILING_FIRMWARE #include <stdio.h> #endif #include "types.h" #include "utilities.h" // rxbuffer[2] == INPUT_TRANSITION_COUNTER // rxbuffer[3] == debounce frames high // rxbuffer[4] == debounce frames low // rxbuffer[5] == 0 = Count Transition high to low // 1 = Count Transition low to high // 2 = Count both transitions // rxbuffer[6,7] max value void init_counter(void) { if (rxbuffer[0] == 200) { //TODO vpin_input(); txbuffer[3] = HIGH_BYTE_16(tp->generic.buffer); txbuffer[4] = LOW_BYTE_16(tp->generic.buffer); tp->generic.buffer = 0; ASSIGN_RXBUFFER16(tp->counter.debouncesamples,3); tp->counter.debouncecounter = 0; tp->counter.mode = rxbuffer[5] & 0x03; // If 1 bit is set, ignore high to low. If 2 bit is set, ignore low to high ASSIGN_RXBUFFER16(tp->counter.max,6); tp->counter.currentState = vpin_read(); tp->counter.increment = 1; } if (rxbuffer[0] == 201) { ASSIGN_RXBUFFER16(tp->counter.increment,3); } } void update_counter(void) { uint8_t lastDMA = tp->counter.lastNextDMA; uint8_t currentState = tp->counter.currentState; uint16_t bitmap = vpinBitmap(); uint16_t counter = tp->generic.buffer; switch(vpinPort()) { case 0: // Port A { //TODO add port a } break; case 1: // PORT B { while (DMACNT3 == 0); // Wait for reload int currentNextDMALocation = SIZE_OF_DMA_ARRAY - DMACNT3 ; // The next DMA location that will be written if (currentNextDMALocation < lastDMA) { // DMA rolled over. Finish the end. for (;lastDMA < SIZE_OF_DMA_ARRAY; ++lastDMA) { //Process data if (InputArrayB[lastDMA] & bitmap) { //Input High if (!currentState) { //Was low! ++ tp->counter.debouncecounter; if (tp->counter.debouncecounter > tp->counter.debouncesamples) { tp->counter.debouncecounter = 0; currentState = 1; if (tp->counter.mode & 0x01) { continue; } uint32_t sum; sum = counter + tp->counter.increment; if (tp->counter.max > 0 && sum > tp->counter.max ) { sum = tp->counter.max ; } counter = (uint16_t) sum; } } else { tp->counter.debouncecounter = 0; // Stayed the same. Do nothing } } else { //Input Low if (currentState) { ++ tp->counter.debouncecounter; if (tp->counter.debouncecounter > tp->counter.debouncesamples) { tp->counter.debouncecounter = 0; currentState = 0; if (tp->counter.mode & 0x02) { continue; } uint32_t sum; sum = counter + tp->counter.increment; if (tp->counter.max > 0 && sum > tp->counter.max ) { sum = tp->counter.max ; } counter = (uint16_t) sum; } } else { tp->counter.debouncecounter = 0; // Stayed the same. Do nothing } } } lastDMA = 0; } for (; lastDMA < currentNextDMALocation; ++lastDMA) { //Process data if (InputArrayB[lastDMA] & bitmap) { //Input High if (!currentState) { //Was low! ++ tp->counter.debouncecounter; if (tp->counter.debouncecounter > tp->counter.debouncesamples) { tp->counter.debouncecounter = 0; currentState = 1; if (tp->counter.mode & 0x01) { continue; } uint32_t sum; sum = counter + tp->counter.increment; if (tp->counter.max > 0 && sum > tp->counter.max ) { sum = tp->counter.max ; } counter = (uint16_t) sum; } } else { tp->counter.debouncecounter = 0; // Stayed the same. Do nothing } } else { //Input Low if (currentState) { ++ tp->counter.debouncecounter; if (tp->counter.debouncecounter > tp->counter.debouncesamples) { tp->counter.debouncecounter = 0; currentState = 0; if (tp->counter.mode & 0x02) { continue; } uint32_t sum; sum = counter + tp->counter.increment; if (tp->counter.max > 0 && sum > tp->counter.max ) { sum = tp->counter.max ; } counter = (uint16_t) sum; } } else { tp->counter.debouncecounter = 0; // Stayed the same. Do nothing } } } } break; } tp->counter.currentState = currentState ; tp->generic.buffer = counter; tp->counter.lastNextDMA = lastDMA; } ///////////////////////////////////////////////////////////////////////// // CODE FROM HERE DOWN IS TESTING CODE FOR USE ON PC, not FIRMWARE #ifdef TEST_COUNTER #define NUM_OF_DATA_INDEX 6 // Test 0, ___---___, count every change, 0 debounce int const test0_data[] = {0,100, 1,100, 0,100}; //debounce frames, mode, freeze, max, initial_val,result, # of data int const test0_init[] = {0,2,0,65535,0,2,sizeof(test0_data) / 8 }; // Test 1, _100_-100-_100_, count rising, 0 debounce int const test1_data[] = {0,100, 1,100, 0,100}; //debounce frames, mode, freeze, max, result, # of data int const test1_init[] = {0,1,0,65535,0,1,sizeof(test1_data) / 8 }; // Test 2, _100_-10-_100_, count rising, 10 debounce int const test2_data[] = {0,100, 1,10, 0,100}; //debounce frames, mode, freeze, max, result, # of data int const test2_init[] = {10, //Debounce frames 1, // MODE 0, //Freeze 65535,// Max 0, //Initial_val 1, //EXPECTED result sizeof(test2_data) / 8 }; // Test 3, _100_-9-_100_, count rising, 10 debounce int const test3_data[] = {0,100, 1,9, 0,100}; //debounce frames, mode, freeze, max, result, # of data int const test3_init[] = {10, //Debounce frames 1, // MODE 0, //Freeze 65535,// Max 0, //Initial_val 0, //EXPECTED result sizeof(test3_data) / 8 }; // Test 4, _100_-9-_100_, count falling, 10 debounce int const test4_data[] = {0,100, 1,9, 0,100}; //debounce frames, mode, freeze, max, result, # of data int const test4_init[] = {10, //Debounce frames 0, // MODE 0, //Freeze 65535,// Max 0, //Initial_val 0, //EXPECTED result sizeof(test4_data) / 8 }; // Test 5, _1_-1-_1_-1-, count rising, 0 debounce int const test5_data[] = {0,1, 1,1, 0,1, 1,1}; //debounce frames, mode, freeze, max, result, # of data int const test5_init[] = {0, //Debounce frames 0, // MODE 0, //Freeze 65535,// Max 0, //Initial_val 2, //EXPECTED result sizeof(test5_data) / 8 }; // Test 6, _1_-1-_1_-1-, count falling, 0 debounce int const test6_data[] = {0,1, 1,1, 0,1, 1,1}; int const test6_init[] = {0, //Debounce frames 1, // MODE 0, //Freeze 65535,// Max 0, //Initial_val 1, //EXPECTED result sizeof(test6_data) / 8 }; // Test 7, _1_-1-_1_-1-, count both, 0 debounce int const test7_data[] = {0,1, 1,1, 0,1, 1,1}; int const test7_init[] = {0, //Debounce frames 2, // MODE 0, //Freeze 65535,// Max 0, //Initial_val 3, //EXPECTED result sizeof(test7_data) / 8 }; // Test 8, _1_-1-_1_-1-, count both, 0 debounce, rollover int const test8_data[] = {0,1, 1,1, 0,1, 1,1}; int const test8_init[] = {0, //Debounce frames 2, // MODE 0, //Freeze 65535,// Max 65535, //Initial_val 2, //EXPECTED result sizeof(test8_data) / 8 }; // Test 9, _1_-1-_1_-1-, count both, 0 debounce, rollover, freeze int const test9_data[] = {0,1, 1,1, 0,1, 1,1}; int const test9_init[] = {0, //Debounce frames 2, // MODE 1, //Freeze 65535,// Max 65534, //Initial_val 65535, //EXPECTED result sizeof(test9_data) / 8 }; int const* test_vectors[]= {test0_init,test0_data, test1_init,test1_data, test2_init,test2_data, test3_init,test3_data, test4_init,test4_data, test5_init,test5_data, test6_init,test6_data, test7_init,test7_data, test8_init,test8_data, test9_init,test9_data }; #define NUMBER_OF_TESTS (sizeof(test_vectors) / 8) int data_point; int test = 0; int iteration = 0; int vpin_data_counter = 0; int const* vpin_data_vector; uint8 test_pin; int main(void) { int i; int const* init_data; int data_points; int returnval = 0; test_pin = 2; system_init(); for (test = 0;test < NUMBER_OF_TESTS; ++test) { vpin_data_vector = test_vectors[test * 2 + 1]; vpin_data_counter = 0; init_data = test_vectors[test *2]; data_points = init_data[NUM_OF_DATA_INDEX]; rxbuffer[0] = CONFIGURE_CHANNEL_MODE_0; rxbuffer[1] = test_pin; rxbuffer[2] = PIN_MODE_COUNTER; rxbuffer[3] = init_data[0]/256; rxbuffer[4] = init_data[0]%256; rxbuffer[5] = init_data[1]; if (init_data[2]) { rxbuffer[5] |= 0x10; } rxbuffer[6] = init_data[3]/256; rxbuffer[7] = init_data[3]%256; set_pin(map_pin(test_pin),vpin_data_vector[0]); process_rxbuffer(); set_buffer(map_pin(test_pin), init_data[4]); for (data_point = 0; data_point < data_points; ++ data_point) { for (iteration = 0; iteration < vpin_data_vector[data_point * 2 + 1]; ++iteration) { set_pin(map_pin(test_pin),vpin_data_vector[data_point * 2]); process_pins(); } } if (get_buffer(map_pin(test_pin)) == init_data[5]) { printf ("Test %d passed\n", test); } else { printf("Test %d expected %d, got %d\n",test, init_data[5],get_buffer(map_pin(test_pin)) ); returnval = 1 ; } } return (returnval); } #endif
23.933638
124
0.536285
2653888e30a247f14bc13f70b1535d2c1c4caef9
6,610
h
C
aimsalgo/src/aimsalgo/pyramid/splinesubsampler_d.h
brainvisa/aims-free
5852c1164292cadefc97cecace022d14ab362dc4
[ "CECILL-B" ]
4
2019-07-09T05:34:10.000Z
2020-10-16T00:03:15.000Z
aimsalgo/src/aimsalgo/pyramid/splinesubsampler_d.h
brainvisa/aims-free
5852c1164292cadefc97cecace022d14ab362dc4
[ "CECILL-B" ]
72
2018-10-31T14:52:50.000Z
2022-03-04T11:22:51.000Z
aimsalgo/src/aimsalgo/pyramid/splinesubsampler_d.h
brainvisa/aims-free
5852c1164292cadefc97cecace022d14ab362dc4
[ "CECILL-B" ]
null
null
null
/* This software and supporting documentation are distributed by * Institut Federatif de Recherche 49 * CEA/NeuroSpin, Batiment 145, * 91191 Gif-sur-Yvette cedex * France * * This software is governed by the CeCILL-B license under * French law and abiding by the rules of distribution of free software. * You can use, modify and/or redistribute the software under the * terms of the CeCILL-B license as circulated by CEA, CNRS * and INRIA at the following URL "http://www.cecill.info". * * As a counterpart to the access to the source code and rights to copy, * modify and redistribute granted by the license, users are provided only * with a limited warranty and the software's author, the holder of the * economic rights, and the successive licensors have only limited * liability. * * In this respect, the user's attention is drawn to the risks associated * with loading, using, modifying and/or developing or reproducing the * software by the user in light of its specific status of free software, * that may mean that it is complicated to manipulate, and that also * therefore means that it is reserved for developers and experienced * professionals having in-depth computer knowledge. Users are therefore * encouraged to load and test the software's suitability as regards their * requirements in conditions enabling the security of their systems and/or * data to be ensured and, more generally, to use and operate it in the * same conditions as regards security. * * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. */ #ifndef AIMS_PYRAMID_SPLINESUBSAMPLER_D_H #define AIMS_PYRAMID_SPLINESUBSAMPLER_D_H //--- aims ------------------------------------------------------------------- #include <aims/pyramid/splinesubsampler.h> #include <aims/pyramid/convolutionsubsampler_d.h> // aims::ConvolutionSubSampler #include <aims/math/bspline.h> // aims::TabulBSpline #include <aims/resampling/splineresampler.h> // aims::mirrorCoeff #include <aims/utility/progress.h> // aims::Progression //--- cartobase -------------------------------------------------------------- #include <cartobase/config/verbose.h> // carto::verbose //--- std -------------------------------------------------------------------- #include <cmath> // std::ceil/floor/isfinite/NAN #include <vector> #include <iostream> //---------------------------------------------------------------------------- namespace aims { //-------------------------------------------------------------------------- // CONSTRUCTORS //-------------------------------------------------------------------------- DirectBSplineSubSampler::DirectBSplineSubSampler( unsigned r, bool normalize, unsigned n ): ConvolutionSubSampler<DiscreteBSpline>(r), _normalize(normalize) { setFunctions( Point4du( r, r, r, r ), n ); } DirectBSplineSubSampler::DirectBSplineSubSampler( const Point4du & r, bool normalize, unsigned n ): ConvolutionSubSampler<DiscreteBSpline>(r), _normalize(normalize) { setFunctions( r, n ); } DirectBSplineSubSampler::~DirectBSplineSubSampler() {} DirectBSplineSubSampler::DirectBSplineSubSampler( const DirectBSplineSubSampler & other ): ConvolutionSubSampler<DiscreteBSpline>( other ), _normalize( other._normalize ) {} DirectBSplineSubSampler & DirectBSplineSubSampler::operator=( const DirectBSplineSubSampler & other ) { if( this != &other ) { ConvolutionSubSampler<DiscreteBSpline>::operator=( other ); _normalize = other._normalize; } return *this; } //-------------------------------------------------------------------------- // PARAMETERS //-------------------------------------------------------------------------- unsigned DirectBSplineSubSampler::order() const { return this->_func[0].order(); } bool DirectBSplineSubSampler::normalize() const { return _normalize; } void DirectBSplineSubSampler::setOrder( unsigned n ) { for( std::vector<DiscreteBSpline>::iterator f = this->_func.begin(); f != this->_func.end(); ++f ) f->setOrder( n ); } void DirectBSplineSubSampler::setNormalize( bool normalize ) { _normalize = normalize; } void DirectBSplineSubSampler::setFactor( unsigned r ) { ConvolutionSubSampler<DiscreteBSpline>::setFactor(r); for( std::vector<DiscreteBSpline>::iterator f = this->_func.begin(); f != this->_func.end(); ++f ) f->setScale( (float)r ); } void DirectBSplineSubSampler::setFactor( const Point4du & r ) { ConvolutionSubSampler<DiscreteBSpline>::setFactor(r); int i = 0; for( std::vector<DiscreteBSpline>::iterator f = this->_func.begin(); f != this->_func.end(); ++f, ++i ) f->setScale( (float)r[i] ); } //-------------------------------------------------------------------------- // HELPER //-------------------------------------------------------------------------- void DirectBSplineSubSampler::setFunctions( const Point4du & r, unsigned n ) { std::vector<DiscreteBSpline> f; f.reserve( 4 ); f.push_back( DiscreteBSpline( n, (float)r[0] ) ); f.push_back( DiscreteBSpline( n, (float)r[1] ) ); f.push_back( DiscreteBSpline( n, (float)r[2] ) ); f.push_back( DiscreteBSpline( n, (float)r[3] ) ); ConvolutionSubSampler<DiscreteBSpline>::setBasisFunction( f ); } //-------------------------------------------------------------------------- // Execution //-------------------------------------------------------------------------- template <typename OUT, typename IN> carto::VolumeRef<OUT> DirectBSplineSubSampler::execute( const carto::VolumeRef<IN> & in, carto::VolumeRef<OUT> & out ) const { ConvolutionSubSampler<DiscreteBSpline>::execute( in, out ); std::vector<int> size = in.getSize(); double div = 1; for( std::size_t i = 0; i < 4; ++i ) if( this->_dir[i] && size[i] > 1 ) div *= ( this->_func.size() > i ? this->_func[i].scale() : this->_func[0].scale() ); out /= div; return out; } } // namespace aims #endif // AIMS_PYRAMID_SPLINESUBSAMPLER_D_H
37.988506
92
0.56354
2653ebc0fa02ea7b341a004e383782d465a6e2fd
240
c
C
gcc-gcc-7_3_0-release/gcc/testsuite/gcc.target/i386/mpx/pr66568.c
best08618/asylo
5a520a9f5c461ede0f32acc284017b737a43898c
[ "Apache-2.0" ]
7
2020-05-02T17:34:05.000Z
2021-10-17T10:15:18.000Z
gcc-gcc-7_3_0-release/gcc/testsuite/gcc.target/i386/mpx/pr66568.c
best08618/asylo
5a520a9f5c461ede0f32acc284017b737a43898c
[ "Apache-2.0" ]
null
null
null
gcc-gcc-7_3_0-release/gcc/testsuite/gcc.target/i386/mpx/pr66568.c
best08618/asylo
5a520a9f5c461ede0f32acc284017b737a43898c
[ "Apache-2.0" ]
2
2020-07-27T00:22:36.000Z
2021-04-01T09:41:02.000Z
/* { dg-do compile } */ /* { dg-require-effective-target fpic } */ /* { dg-options "-O2 -fcheck-pointer-bounds -mmpx -O2 -fPIC" } */ extern void exit (int); int a, b, c; void *set_test () { if (b) a ? exit (0) : exit (1); b = c; }
20
65
0.541667
2656185556c6a07ab5ab64ebc5ecd90b6b14cb53
6,557
h
C
src/Frodo-core/core/math/vec4.h
JeppeSRC/Frodo
f3229c4601608254f16f4499052d8d03c94c0e86
[ "MIT" ]
19
2016-04-19T21:31:47.000Z
2018-02-28T19:28:43.000Z
src/Frodo-core/core/math/vec4.h
JeppeSRC/Frodo
f3229c4601608254f16f4499052d8d03c94c0e86
[ "MIT" ]
null
null
null
src/Frodo-core/core/math/vec4.h
JeppeSRC/Frodo
f3229c4601608254f16f4499052d8d03c94c0e86
[ "MIT" ]
null
null
null
#pragma once #include "mathcommon.h" namespace fd { namespace core { namespace math { class vec4 { public: float32 x; float32 y; float32 z; float32 w; public: vec4(); vec4(float32 x, float32 y, float32 z, float32 w); vec4& Add(const vec4& v); vec4& Add(float32 v); vec4& Sub(const vec4& v); vec4& Sub(float32 v); vec4& Mul(const vec4& v); vec4& Mul(float32 v); vec4& Div(const vec4& v); vec4& Div(float32 v); inline void operator+=(const vec4& right) { Add(right); } inline void operator-=(const vec4& right) { Sub(right); } inline void operator*=(const vec4& right) { Mul(right); } inline void operator/=(const vec4& right) { Div(right); } inline void operator+=(const float32 right) { Add(right); } inline void operator-=(const float32 right) { Sub(right); } inline void operator*=(const float32 right) { Mul(right); } inline void operator/=(const float32 right) { Div(right); } inline vec4 operator+(const vec4& right) const { return vec4(*this).Add(right); } inline vec4 operator-(const vec4& right) const { return vec4(*this).Sub(right); } inline vec4 operator*(const vec4& right) const { return vec4(*this).Mul(right); } inline vec4 operator/(const vec4& right) const { return vec4(*this).Div(right); } inline vec4 operator+(const float32 right) const { return vec4(*this).Add(right); } inline vec4 operator-(const float32 right) const { return vec4(*this).Sub(right); } inline vec4 operator*(const float32 right) const { return vec4(*this).Mul(right); } inline vec4 operator/(const float32 right) const { return vec4(*this).Div(right); } inline vec4 operator-() const { return vec4(-x, -y, -z, -w); } }; class vec4d { public: float64 x; float64 y; float64 z; float64 w; public: vec4d(); vec4d(float64 x, float64 y, float64 z, float64 w); vec4d& Add(const vec4d& v); vec4d& Add(float64 v); vec4d& Sub(const vec4d& v); vec4d& Sub(float64 v); vec4d& Mul(const vec4d& v); vec4d& Mul(float64 v); vec4d& Div(const vec4d& v); vec4d& Div(float64 v); inline void operator+=(const vec4d& right) { Add(right); } inline void operator-=(const vec4d& right) { Sub(right); } inline void operator*=(const vec4d& right) { Mul(right); } inline void operator/=(const vec4d& right) { Div(right); } inline void operator+=(const float64 right) { Add(right); } inline void operator-=(const float64 right) { Sub(right); } inline void operator*=(const float64 right) { Mul(right); } inline void operator/=(const float64 right) { Div(right); } inline vec4d operator+(const vec4d& right) const { return vec4d(*this).Add(right); } inline vec4d operator-(const vec4d& right) const { return vec4d(*this).Sub(right); } inline vec4d operator*(const vec4d& right) const { return vec4d(*this).Mul(right); } inline vec4d operator/(const vec4d& right) const { return vec4d(*this).Div(right); } inline vec4d operator+(const float64 right) const { return vec4d(*this).Add(right); } inline vec4d operator-(const float64 right) const { return vec4d(*this).Sub(right); } inline vec4d operator*(const float64 right) const { return vec4d(*this).Mul(right); } inline vec4d operator/(const float64 right) const { return vec4d(*this).Div(right); } inline vec4d operator-() const { return vec4d(-x, -y, -z, -w); } }; class vec4i { public: int32 x; int32 y; int32 z; int32 w; public: vec4i(); vec4i(int32 x, int32 y, int32 z, int32 w); vec4i& Add(const vec4i& v); vec4i& Add(int32 v); vec4i& Sub(const vec4i& v); vec4i& Sub(int32 v); vec4i& Mul(const vec4i& v); vec4i& Mul(int32 v); vec4i& Div(const vec4i& v); vec4i& Div(int32 v); inline void operator+=(const vec4i& right) { Add(right); } inline void operator-=(const vec4i& right) { Sub(right); } inline void operator*=(const vec4i& right) { Mul(right); } inline void operator/=(const vec4i& right) { Div(right); } inline void operator+=(const int32 right) { Add(right); } inline void operator-=(const int32 right) { Sub(right); } inline void operator*=(const int32 right) { Mul(right); } inline void operator/=(const int32 right) { Div(right); } inline vec4i operator+(const vec4i& right) const { return vec4i(*this).Add(right); } inline vec4i operator-(const vec4i& right) const { return vec4i(*this).Sub(right); } inline vec4i operator*(const vec4i& right) const { return vec4i(*this).Mul(right); } inline vec4i operator/(const vec4i& right) const { return vec4i(*this).Div(right); } inline vec4i operator+(const int32 right) const { return vec4i(*this).Add(right); } inline vec4i operator-(const int32 right) const { return vec4i(*this).Sub(right); } inline vec4i operator*(const int32 right) const { return vec4i(*this).Mul(right); } inline vec4i operator/(const int32 right) const { return vec4i(*this).Div(right); } inline vec4i operator-() const { return vec4i(-x, -y, -z, -w); } }; class vec4l { public: int64 x; int64 y; int64 z; int64 w; public: vec4l(); vec4l(int64 x, int64 y, int64 z, int64 w); vec4l& Add(const vec4l& v); vec4l& Add(int64 v); vec4l& Sub(const vec4l& v); vec4l& Sub(int64 v); vec4l& Mul(const vec4l& v); vec4l& Mul(int64 v); vec4l& Div(const vec4l& v); vec4l& Div(int64 v); inline void operator+=(const vec4l& right) { Add(right); } inline void operator-=(const vec4l& right) { Sub(right); } inline void operator*=(const vec4l& right) { Mul(right); } inline void operator/=(const vec4l& right) { Div(right); } inline void operator+=(const int64 right) { Add(right); } inline void operator-=(const int64 right) { Sub(right); } inline void operator*=(const int64 right) { Mul(right); } inline void operator/=(const int64 right) { Div(right); } inline vec4l operator+(const vec4l& right) const { return vec4l(*this).Add(right); } inline vec4l operator-(const vec4l& right) const { return vec4l(*this).Sub(right); } inline vec4l operator*(const vec4l& right) const { return vec4l(*this).Mul(right); } inline vec4l operator/(const vec4l& right) const { return vec4l(*this).Div(right); } inline vec4l operator+(const int64 right) const { return vec4l(*this).Add(right); } inline vec4l operator-(const int64 right) const { return vec4l(*this).Sub(right); } inline vec4l operator*(const int64 right) const { return vec4l(*this).Mul(right); } inline vec4l operator/(const int64 right) const { return vec4l(*this).Div(right); } inline vec4l operator-() const { return vec4l(-x, -y, -z, -w); } }; } } }
37.683908
87
0.671649
265743a04bcb794568f05f8bbd292da13a7c88ac
1,815
h
C
ExplosionPuzzle/ExplosionPuzzle/Button.h
jesseroffel/explosion-game
df8e1481072d7ea4ecc61997b39d0575d63386b3
[ "MIT" ]
null
null
null
ExplosionPuzzle/ExplosionPuzzle/Button.h
jesseroffel/explosion-game
df8e1481072d7ea4ecc61997b39d0575d63386b3
[ "MIT" ]
null
null
null
ExplosionPuzzle/ExplosionPuzzle/Button.h
jesseroffel/explosion-game
df8e1481072d7ea4ecc61997b39d0575d63386b3
[ "MIT" ]
null
null
null
#pragma once #ifndef BUTTON_H #define BUTTON_H #include <SDL/SDL.h> #include <SDL/SDL_image.h> #include <iostream> #include "texture.h" #include "music.h" #include "text.h" class Button { public: enum BTYPE { bNothing, bGoToAction, bGoToEditor, bDelete, bPlace, bEntity, }; enum ETYPE { eNothing, eBombHorizontal, eBombVertical }; Button(); //Constructor with a position as arguments Button(std::string path, SDL_Renderer* rRend, TTF_Font* FONT, int posX, int posY, BTYPE ButtonType); Button(std::string path, SDL_Renderer* rRend, int posX, int posY, BTYPE ButtonType, ETYPE EntityType); //Constructor with a position and button width/height arguments ~Button(); //Set topleft position void setPosition(int x, int y); //Handle mouse events void handleEvents(SDL_Event* eEvent, Music* oMusic); //Render button on screen void Render(SDL_Renderer* rRend); int getReturnType(); int getEntityType(); int getEntity(); void setInteractable(bool state); bool getInteractable(); void setAlpha(Uint8 newalpha); void Free(); private: Texture* tButtonIcon; Texture* tButtonTexture; Texture* tButtonEntityCount; Uint8 tTextureAlpha; BTYPE mButtonType; ETYPE mEntityType; Text* txtInfo; int mX; int mY; int mPosX; int mPosY; int mButtonWidth; int mButtonHeight; int mButtonIconPosX; int mButtonIconPosY; int mButtonIconWidth; int mButtonIconHeight; //int mButtonType; //int mEntityType; bool drawBorder; bool drawButton; bool mInteractable; bool interacted; bool curInteraction; bool renderOutlines; bool playsfx = true; bool renderText = false; int mReturnButtonType; int mReturnEntityType; bool checkMousePos(); void setText(SDL_Renderer* rRend, TTF_Font* FONT); //int getButtonType(); //int getEntityType(); }; #endif
16.651376
103
0.733333
265a77c66082d6561ce3b0081598e746d9cefe5e
8,105
c
C
projects/power_distribution/test/test_pd_fan_ctrl.c
Citrusboa/firmware_xiv
4379cefae900fd67bd14d930da6b8acfce625176
[ "MIT" ]
14
2019-11-12T00:11:29.000Z
2021-12-13T05:32:41.000Z
projects/power_distribution/test/test_pd_fan_ctrl.c
123Logan321/firmware_xiv
14468d55753ad62f8a63a9289511e72131443042
[ "MIT" ]
191
2019-11-12T05:36:58.000Z
2022-03-21T19:54:46.000Z
projects/power_distribution/test/test_pd_fan_ctrl.c
123Logan321/firmware_xiv
14468d55753ad62f8a63a9289511e72131443042
[ "MIT" ]
14
2020-06-06T14:43:14.000Z
2022-03-08T00:48:11.000Z
#include <stdbool.h> #include <string.h> #include "adc.h" #include "adt7476a_fan_controller.h" #include "adt7476a_fan_controller_defs.h" #include "can.h" #include "can_transmit.h" #include "can_unpack.h" #include "delay.h" #include "gpio.h" #include "gpio_it.h" #include "i2c.h" #include "interrupt.h" #include "log.h" #include "ms_test_helpers.h" #include "pd_error_defs.h" #include "pd_events.h" #include "pd_fan_ctrl.h" #include "pin_defs.h" #include "status.h" #include "test_helpers.h" #include "unity.h" #define TEST_I2C_PORT I2C_PORT_2 #define TEST_I2C_ADDRESS 0x1 #define TEST_CONFIG_PIN_I2C_SCL \ { GPIO_PORT_B, 10 } #define TEST_CONFIG_PIN_I2C_SDA \ { GPIO_PORT_B, 11 } #define TEST_PWM_1 ADT_PWM_PORT_1 #define TEST_PWM_2 ADT_PWM_PORT_2 #define ADT7476A_PWM_1 0x30 #define ADT7476A_PWM_3 0x32 #define OVERTEMP_FLAGS (FAN_OVERTEMP | DCDC_OVERTEMP | ENCLOSURE_OVERTEMP) #define OVERVOLT_FLAGS (VCC_EXCEEDED | VCCP_EXCEEDED) #define FAN_ERR_FLAGS (FAN1_STATUS | FAN2_STATUS | FAN3_STATUS | FAN4_STATUS) #define ADC_MAX_VAL 3300 #define FRONT_FAN_CTRL_MAX_VALUE_MV 1650 #define FAN_UNDERTEMP_VOLTAGE 1163 #define FAN_OVERTEMP_VOLTAGE 758 #define FAN_50_PERC_VOLTAGE 975 #define FAN_OVERTEMP_FRACTION_TRANSMIT (FAN_OVERTEMP_VOLTAGE * 1000) / ADC_MAX_VAL #define FAN_MAX_I2C_WRITE 0xFF // equates to (percent value)/0.39 -> adt7476A conversion #define FAN_50_PERC_I2C_WRITE 0x7F #define FAN_MIN_I2C_WRITE 0x0 static uint16_t s_fan_ctrl_msg[4]; static CanStorage s_can_storage; static FanCtrlSettings s_fan_settings = { .i2c_port = TEST_I2C_PORT, .fan_pwm1 = TEST_PWM_1, .fan_pwm2 = TEST_PWM_2, .i2c_address = TEST_I2C_ADDRESS, }; static uint16_t adc_ret_val; StatusCode TEST_MOCK(adc_read_converted_pin)(GpioAddress address, uint16_t *reading) { *reading = adc_ret_val; return STATUS_CODE_OK; } static uint8_t i2c_buf1[10]; static uint8_t i2c_buf2[10]; StatusCode TEST_MOCK(i2c_write)(I2CPort i2c, I2CAddress addr, uint8_t *tx_data, size_t tx_len) { // Save both temp values written over i2c if (tx_data[0] == ADT7476A_PWM_1) { memcpy(i2c_buf1, tx_data, tx_len); } else { memcpy(i2c_buf2, tx_data, tx_len); } return STATUS_CODE_OK; } StatusCode TEST_MOCK(i2c_read_reg)(I2CPort i2c, I2CAddress addr, uint8_t reg, uint8_t *rx_data, size_t rx_len) { if (reg == ADT7476A_INTERRUPT_STATUS_REGISTER_1) { *rx_data = OVERVOLT_FLAGS; } else if (reg == ADT7476A_INTERRUPT_STATUS_REGISTER_2) { *rx_data = FAN_ERR_FLAGS; } return STATUS_CODE_OK; } static StatusCode prv_front_can_fan_ctrl_rx_handler(const CanMessage *msg, void *context, CanAckStatus *ack_reply) { CAN_UNPACK_FRONT_PD_FAULT(msg, &s_fan_ctrl_msg[0], &s_fan_ctrl_msg[1]); return STATUS_CODE_OK; } static StatusCode prv_rear_can_fan_ctrl_rx_handler(const CanMessage *msg, void *context, CanAckStatus *ack_reply) { CAN_UNPACK_REAR_PD_FAULT(msg, &s_fan_ctrl_msg[0], &s_fan_ctrl_msg[1], &s_fan_ctrl_msg[2], &s_fan_ctrl_msg[3]); return STATUS_CODE_OK; } static void prv_initialize_can(SystemCanDevice can_device) { CanSettings can_settings = { .device_id = can_device, .loopback = true, .bitrate = CAN_HW_BITRATE_500KBPS, .rx_event = PD_CAN_EVENT_RX, .tx_event = PD_CAN_EVENT_TX, .fault_event = PD_CAN_EVENT_FAULT, .tx = { GPIO_PORT_A, 12 }, .rx = { GPIO_PORT_A, 11 }, }; can_init(&s_can_storage, &can_settings); } void setup_test(void) { gpio_init(); interrupt_init(); soft_timer_init(); event_queue_init(); adc_init(ADC_MODE_SINGLE); I2CSettings i2c_settings = { .speed = I2C_SPEED_FAST, .scl = TEST_CONFIG_PIN_I2C_SCL, .sda = TEST_CONFIG_PIN_I2C_SDA, }; i2c_init(TEST_I2C_PORT, &i2c_settings); gpio_it_init(); memset(s_fan_ctrl_msg, 0, 4 * sizeof(uint16_t)); } void teardown_test(void) {} void test_fan_ctrl_init(void) { TEST_ASSERT_NOT_OK(pd_fan_ctrl_init(NULL, true)); TEST_ASSERT_OK(pd_fan_ctrl_init(&s_fan_settings, true)); TEST_ASSERT_OK(pd_fan_ctrl_init(&s_fan_settings, false)); } // Test Gpio interrupt on rear smbalert pin triggered void test_fan_err_rear(void) { prv_initialize_can(SYSTEM_CAN_DEVICE_POWER_DISTRIBUTION_REAR); TEST_ASSERT_OK(pd_fan_ctrl_init(&s_fan_settings, false)); gpio_it_trigger_interrupt(&(GpioAddress)PD_SMBALERT_PIN); can_register_rx_handler(SYSTEM_CAN_MESSAGE_REAR_PD_FAULT, prv_rear_can_fan_ctrl_rx_handler, NULL); MS_TEST_HELPER_CAN_TX_RX(PD_CAN_EVENT_TX, PD_CAN_EVENT_RX); TEST_ASSERT_EQUAL(ERR_VCC_EXCEEDED, s_fan_ctrl_msg[0] & ERR_VCC_EXCEEDED); TEST_ASSERT_EQUAL(FAN_ERR_FLAGS, s_fan_ctrl_msg[0] & FAN_ERR_FLAGS); } // Test Gpio interrupt on front smbalert pin triggered void test_fan_err_front(void) { prv_initialize_can(SYSTEM_CAN_DEVICE_POWER_DISTRIBUTION_FRONT); TEST_ASSERT_OK(pd_fan_ctrl_init(&s_fan_settings, true)); gpio_it_trigger_interrupt(&(GpioAddress)PD_SMBALERT_PIN); can_register_rx_handler(SYSTEM_CAN_MESSAGE_FRONT_PD_FAULT, prv_front_can_fan_ctrl_rx_handler, NULL); MS_TEST_HELPER_CAN_TX_RX(PD_CAN_EVENT_TX, PD_CAN_EVENT_RX); TEST_ASSERT_EQUAL(ERR_VCC_EXCEEDED, s_fan_ctrl_msg[0] & ERR_VCC_EXCEEDED); TEST_ASSERT_EQUAL(FAN_ERR_FLAGS, s_fan_ctrl_msg[0] & FAN_ERR_FLAGS); } void test_rear_pd_fan_ctrl_temp(void) { // Check overtemp, undertemp, and 50% temp values transmit correct // values and execute properly // set adc to return temp that converts to 50% speed adc_ret_val = FAN_50_PERC_VOLTAGE; TEST_ASSERT_EQUAL(STATUS_CODE_OK, pd_fan_ctrl_init(&s_fan_settings, false)); delay_ms(REAR_FAN_CONTROL_REFRESH_PERIOD_MILLIS + 10); TEST_ASSERT_EQUAL(FAN_50_PERC_I2C_WRITE, i2c_buf1[1]); TEST_ASSERT_EQUAL(FAN_50_PERC_I2C_WRITE, i2c_buf2[1]); // set adc to return undertemp adc_ret_val = FAN_UNDERTEMP_VOLTAGE; delay_ms(REAR_FAN_CONTROL_REFRESH_PERIOD_MILLIS); TEST_ASSERT_EQUAL(FAN_MIN_I2C_WRITE, i2c_buf1[1]); TEST_ASSERT_EQUAL(FAN_MIN_I2C_WRITE, i2c_buf2[1]); MS_TEST_HELPER_ASSERT_NO_EVENT_RAISED(); // Test adc returns an overtemp value - CAN message with overtemp values transmitted adc_ret_val = FAN_OVERTEMP_VOLTAGE; prv_initialize_can(SYSTEM_CAN_DEVICE_POWER_DISTRIBUTION_REAR); delay_ms(REAR_FAN_CONTROL_REFRESH_PERIOD_MILLIS); TEST_ASSERT_EQUAL(FAN_MAX_I2C_WRITE, i2c_buf1[1]); TEST_ASSERT_EQUAL(FAN_MAX_I2C_WRITE, i2c_buf2[1]); can_register_rx_handler(SYSTEM_CAN_MESSAGE_REAR_PD_FAULT, prv_rear_can_fan_ctrl_rx_handler, NULL); MS_TEST_HELPER_CAN_TX_RX(PD_CAN_EVENT_TX, PD_CAN_EVENT_RX); TEST_ASSERT_EQUAL(s_fan_ctrl_msg[1], s_fan_ctrl_msg[2]); TEST_ASSERT_EQUAL(s_fan_ctrl_msg[1], FAN_OVERTEMP_FRACTION_TRANSMIT); // FAN_OVERTEMP_VOLTAGE as a fraction of v_ref // Check Overtemp byte set correctly TEST_ASSERT_EQUAL(OVERTEMP_FLAGS, ((s_fan_ctrl_msg[0]) & OVERTEMP_FLAGS)); } void test_front_pd_fan_ctrl_pot(void) { // Check max, min, and 50% potentiometer values transmit correct // values and execute properly // set adc to open value adc_ret_val = ADC_MAX_VAL; TEST_ASSERT_EQUAL(STATUS_CODE_OK, pd_fan_ctrl_init(&s_fan_settings, true)); delay_ms(REAR_FAN_CONTROL_REFRESH_PERIOD_MILLIS + 10); TEST_ASSERT_EQUAL(FAN_MIN_I2C_WRITE, i2c_buf1[1]); TEST_ASSERT_EQUAL(FAN_MIN_I2C_WRITE, i2c_buf2[1]); // set adc to return max value adc_ret_val = FRONT_FAN_CTRL_MAX_VALUE_MV; delay_ms(REAR_FAN_CONTROL_REFRESH_PERIOD_MILLIS + 10); TEST_ASSERT_EQUAL(FAN_MAX_I2C_WRITE, i2c_buf1[1]); TEST_ASSERT_EQUAL(FAN_MAX_I2C_WRITE, i2c_buf2[1]); // set adc to return mid value adc_ret_val = FRONT_FAN_CTRL_MAX_VALUE_MV / 2; delay_ms(REAR_FAN_CONTROL_REFRESH_PERIOD_MILLIS + 10); TEST_ASSERT_EQUAL(FAN_50_PERC_I2C_WRITE, i2c_buf1[1]); TEST_ASSERT_EQUAL(FAN_50_PERC_I2C_WRITE, i2c_buf2[1]); // set adc to return min value adc_ret_val = 0; delay_ms(REAR_FAN_CONTROL_REFRESH_PERIOD_MILLIS + 10); TEST_ASSERT_EQUAL(FAN_MIN_I2C_WRITE, i2c_buf1[1]); TEST_ASSERT_EQUAL(FAN_MIN_I2C_WRITE, i2c_buf2[1]); }
35.23913
100
0.770512
265b3c026b1c65ed5cef7e700dca29458b65dcbe
10,501
h
C
src/protos/Invoicing/SignatureRejectionInfo.pb.h
Andreev-Sergey/diadocsdk-cpp
01d9fa2b90bc6f42ef3d9c20f29207b3a5bf6eda
[ "MIT" ]
7
2016-05-31T17:37:54.000Z
2022-01-17T14:28:18.000Z
src/protos/Invoicing/SignatureRejectionInfo.pb.h
Andreev-Sergey/diadocsdk-cpp
01d9fa2b90bc6f42ef3d9c20f29207b3a5bf6eda
[ "MIT" ]
22
2017-02-07T09:34:02.000Z
2021-09-06T08:08:34.000Z
src/protos/Invoicing/SignatureRejectionInfo.pb.h
Andreev-Sergey/diadocsdk-cpp
01d9fa2b90bc6f42ef3d9c20f29207b3a5bf6eda
[ "MIT" ]
23
2016-06-07T06:11:47.000Z
2020-10-06T13:00:21.000Z
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: Invoicing/SignatureRejectionInfo.proto #ifndef PROTOBUF_Invoicing_2fSignatureRejectionInfo_2eproto__INCLUDED #define PROTOBUF_Invoicing_2fSignatureRejectionInfo_2eproto__INCLUDED #include <string> #include <google/protobuf/stubs/common.h> #if GOOGLE_PROTOBUF_VERSION < 2006000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif #if 2006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. #endif #include <google/protobuf/generated_message_util.h> #include <google/protobuf/message.h> #include <google/protobuf/repeated_field.h> #include <google/protobuf/extension_set.h> #include <google/protobuf/unknown_field_set.h> #include "Invoicing/Signer.pb.h" // @@protoc_insertion_point(includes) namespace Diadoc { namespace Api { namespace Proto { namespace Invoicing { // Internal implementation detail -- do not call these. void protobuf_AddDesc_Invoicing_2fSignatureRejectionInfo_2eproto(); void protobuf_AssignDesc_Invoicing_2fSignatureRejectionInfo_2eproto(); void protobuf_ShutdownFile_Invoicing_2fSignatureRejectionInfo_2eproto(); class SignatureRejectionInfo; // =================================================================== class SignatureRejectionInfo : public ::google::protobuf::Message { public: SignatureRejectionInfo(); virtual ~SignatureRejectionInfo(); SignatureRejectionInfo(const SignatureRejectionInfo& from); inline SignatureRejectionInfo& operator=(const SignatureRejectionInfo& from) { CopyFrom(from); return *this; } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _unknown_fields_; } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return &_unknown_fields_; } static const ::google::protobuf::Descriptor* descriptor(); static const SignatureRejectionInfo& default_instance(); void Swap(SignatureRejectionInfo* other); // implements Message ---------------------------------------------- SignatureRejectionInfo* New() const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const SignatureRejectionInfo& from); void MergeFrom(const SignatureRejectionInfo& from); void Clear(); bool IsInitialized() const; int ByteSize() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // optional string ErrorMessage = 1; inline bool has_errormessage() const; inline void clear_errormessage(); static const int kErrorMessageFieldNumber = 1; inline const ::std::string& errormessage() const; inline void set_errormessage(const ::std::string& value); inline void set_errormessage(const char* value); inline void set_errormessage(const char* value, size_t size); inline ::std::string* mutable_errormessage(); inline ::std::string* release_errormessage(); inline void set_allocated_errormessage(::std::string* errormessage); // required .Diadoc.Api.Proto.Invoicing.Signer Signer = 2; inline bool has_signer() const; inline void clear_signer(); static const int kSignerFieldNumber = 2; inline const ::Diadoc::Api::Proto::Invoicing::Signer& signer() const; inline ::Diadoc::Api::Proto::Invoicing::Signer* mutable_signer(); inline ::Diadoc::Api::Proto::Invoicing::Signer* release_signer(); inline void set_allocated_signer(::Diadoc::Api::Proto::Invoicing::Signer* signer); // @@protoc_insertion_point(class_scope:Diadoc.Api.Proto.Invoicing.SignatureRejectionInfo) private: inline void set_has_errormessage(); inline void clear_has_errormessage(); inline void set_has_signer(); inline void clear_has_signer(); ::google::protobuf::UnknownFieldSet _unknown_fields_; ::google::protobuf::uint32 _has_bits_[1]; mutable int _cached_size_; ::std::string* errormessage_; ::Diadoc::Api::Proto::Invoicing::Signer* signer_; friend void protobuf_AddDesc_Invoicing_2fSignatureRejectionInfo_2eproto(); friend void protobuf_AssignDesc_Invoicing_2fSignatureRejectionInfo_2eproto(); friend void protobuf_ShutdownFile_Invoicing_2fSignatureRejectionInfo_2eproto(); void InitAsDefaultInstance(); static SignatureRejectionInfo* default_instance_; }; // =================================================================== // =================================================================== // SignatureRejectionInfo // optional string ErrorMessage = 1; inline bool SignatureRejectionInfo::has_errormessage() const { return (_has_bits_[0] & 0x00000001u) != 0; } inline void SignatureRejectionInfo::set_has_errormessage() { _has_bits_[0] |= 0x00000001u; } inline void SignatureRejectionInfo::clear_has_errormessage() { _has_bits_[0] &= ~0x00000001u; } inline void SignatureRejectionInfo::clear_errormessage() { if (errormessage_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { errormessage_->clear(); } clear_has_errormessage(); } inline const ::std::string& SignatureRejectionInfo::errormessage() const { // @@protoc_insertion_point(field_get:Diadoc.Api.Proto.Invoicing.SignatureRejectionInfo.ErrorMessage) return *errormessage_; } inline void SignatureRejectionInfo::set_errormessage(const ::std::string& value) { set_has_errormessage(); if (errormessage_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { errormessage_ = new ::std::string; } errormessage_->assign(value); // @@protoc_insertion_point(field_set:Diadoc.Api.Proto.Invoicing.SignatureRejectionInfo.ErrorMessage) } inline void SignatureRejectionInfo::set_errormessage(const char* value) { set_has_errormessage(); if (errormessage_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { errormessage_ = new ::std::string; } errormessage_->assign(value); // @@protoc_insertion_point(field_set_char:Diadoc.Api.Proto.Invoicing.SignatureRejectionInfo.ErrorMessage) } inline void SignatureRejectionInfo::set_errormessage(const char* value, size_t size) { set_has_errormessage(); if (errormessage_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { errormessage_ = new ::std::string; } errormessage_->assign(reinterpret_cast<const char*>(value), size); // @@protoc_insertion_point(field_set_pointer:Diadoc.Api.Proto.Invoicing.SignatureRejectionInfo.ErrorMessage) } inline ::std::string* SignatureRejectionInfo::mutable_errormessage() { set_has_errormessage(); if (errormessage_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { errormessage_ = new ::std::string; } // @@protoc_insertion_point(field_mutable:Diadoc.Api.Proto.Invoicing.SignatureRejectionInfo.ErrorMessage) return errormessage_; } inline ::std::string* SignatureRejectionInfo::release_errormessage() { clear_has_errormessage(); if (errormessage_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { return NULL; } else { ::std::string* temp = errormessage_; errormessage_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); return temp; } } inline void SignatureRejectionInfo::set_allocated_errormessage(::std::string* errormessage) { if (errormessage_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { delete errormessage_; } if (errormessage) { set_has_errormessage(); errormessage_ = errormessage; } else { clear_has_errormessage(); errormessage_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } // @@protoc_insertion_point(field_set_allocated:Diadoc.Api.Proto.Invoicing.SignatureRejectionInfo.ErrorMessage) } // required .Diadoc.Api.Proto.Invoicing.Signer Signer = 2; inline bool SignatureRejectionInfo::has_signer() const { return (_has_bits_[0] & 0x00000002u) != 0; } inline void SignatureRejectionInfo::set_has_signer() { _has_bits_[0] |= 0x00000002u; } inline void SignatureRejectionInfo::clear_has_signer() { _has_bits_[0] &= ~0x00000002u; } inline void SignatureRejectionInfo::clear_signer() { if (signer_ != NULL) signer_->::Diadoc::Api::Proto::Invoicing::Signer::Clear(); clear_has_signer(); } inline const ::Diadoc::Api::Proto::Invoicing::Signer& SignatureRejectionInfo::signer() const { // @@protoc_insertion_point(field_get:Diadoc.Api.Proto.Invoicing.SignatureRejectionInfo.Signer) return signer_ != NULL ? *signer_ : *default_instance_->signer_; } inline ::Diadoc::Api::Proto::Invoicing::Signer* SignatureRejectionInfo::mutable_signer() { set_has_signer(); if (signer_ == NULL) signer_ = new ::Diadoc::Api::Proto::Invoicing::Signer; // @@protoc_insertion_point(field_mutable:Diadoc.Api.Proto.Invoicing.SignatureRejectionInfo.Signer) return signer_; } inline ::Diadoc::Api::Proto::Invoicing::Signer* SignatureRejectionInfo::release_signer() { clear_has_signer(); ::Diadoc::Api::Proto::Invoicing::Signer* temp = signer_; signer_ = NULL; return temp; } inline void SignatureRejectionInfo::set_allocated_signer(::Diadoc::Api::Proto::Invoicing::Signer* signer) { delete signer_; signer_ = signer; if (signer) { set_has_signer(); } else { clear_has_signer(); } // @@protoc_insertion_point(field_set_allocated:Diadoc.Api.Proto.Invoicing.SignatureRejectionInfo.Signer) } // @@protoc_insertion_point(namespace_scope) } // namespace Invoicing } // namespace Proto } // namespace Api } // namespace Diadoc #ifndef SWIG namespace google { namespace protobuf { } // namespace google } // namespace protobuf #endif // SWIG // @@protoc_insertion_point(global_scope) #endif // PROTOBUF_Invoicing_2fSignatureRejectionInfo_2eproto__INCLUDED
37.237589
113
0.739549
265b524cd2cfd3dd31fc4eb800e496e36aa988c8
735
h
C
chrome/browser/geolocation/gateway_data_provider_win.h
Gitman1989/chromium
2b1cceae1075ef012fb225deec8b4c8bbe4bc897
[ "BSD-3-Clause" ]
2
2017-09-02T19:08:28.000Z
2021-11-15T15:15:14.000Z
chrome/browser/geolocation/gateway_data_provider_win.h
Gitman1989/chromium
2b1cceae1075ef012fb225deec8b4c8bbe4bc897
[ "BSD-3-Clause" ]
null
null
null
chrome/browser/geolocation/gateway_data_provider_win.h
Gitman1989/chromium
2b1cceae1075ef012fb225deec8b4c8bbe4bc897
[ "BSD-3-Clause" ]
1
2020-04-13T05:45:10.000Z
2020-04-13T05:45:10.000Z
// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_GEOLOCATION_GATEWAY_DATA_PROVIDER_WIN_H_ #define CHROME_BROWSER_GEOLOCATION_GATEWAY_DATA_PROVIDER_WIN_H_ #pragma once #include "chrome/browser/geolocation/gateway_data_provider_common.h" class WinGatewayDataProvider : public GatewayDataProviderCommon { public: WinGatewayDataProvider(); private: virtual ~WinGatewayDataProvider(); // GatewayDataProviderCommon virtual GatewayApiInterface* NewGatewayApi(); DISALLOW_COPY_AND_ASSIGN(WinGatewayDataProvider); }; #endif //CHROME_BROWSER_GEOLOCATION_GATEWAY_DATA_PROVIDER_WIN_H_
29.4
73
0.829932
265b837ab082efbcc896f00b08f263aeecdd582b
1,316
h
C
com/netfx/src/clr/inc/nativevaraccessors.h
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
com/netfx/src/clr/inc/nativevaraccessors.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
com/netfx/src/clr/inc/nativevaraccessors.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== //***************************************************************************** // The following are used to read and write data given NativeVarInfo // for primitive types. Don't use these for VALUECLASSes. //***************************************************************************** #include "corjit.h" bool operator ==(const ICorDebugInfo::VarLoc &varLoc1, const ICorDebugInfo::VarLoc &varLoc2); SIZE_T NativeVarSize(const ICorDebugInfo::VarLoc & varLoc); DWORD *NativeVarStackAddr(const ICorDebugInfo::VarLoc & varLoc, PCONTEXT pCtx); bool GetNativeVarVal(const ICorDebugInfo::VarLoc & varLoc, PCONTEXT pCtx, DWORD * pVal1, DWORD * pVal2); bool SetNativeVarVal(const ICorDebugInfo::VarLoc & varLoc, PCONTEXT pCtx, DWORD val1, DWORD val2);
43.866667
87
0.386018
265c825044f3d9beb35d8b1e6b58c2f548f812f4
7,241
c
C
cmds/feats/s/_shadow_apotheosis.c
nm0i/shadowgate
e5d4b8ed2b4e1bac397fcb14a398851e28eb4803
[ "MIT" ]
1
2021-06-10T00:35:51.000Z
2021-06-10T00:35:51.000Z
cmds/feats/s/_shadow_apotheosis.c
nm0i/shadowgate
e5d4b8ed2b4e1bac397fcb14a398851e28eb4803
[ "MIT" ]
null
null
null
cmds/feats/s/_shadow_apotheosis.c
nm0i/shadowgate
e5d4b8ed2b4e1bac397fcb14a398851e28eb4803
[ "MIT" ]
null
null
null
#include <std.h> #include <daemons.h> #include <dirs.h> inherit FEAT; object* exclude = ({}); // might eventually make this a shadow form they shapeshift into that gives the // bonuses, but would have dig into the whole lib to find all the instances of // shapeshift so I could allow commands and such for a humanoid shapeshift that // didn't have the restrictions of animal form. Want to do it some day, just // not this day. void create() { ::create(); feat_type("instant"); feat_category("ShadowAdept"); feat_name("shadow apotheosis"); feat_prereq("Shadow adept L7"); feat_syntax("shadow_apotheosis"); feat_desc("A shadow adept with shadow apotheosis is able to project an aura of shadows about himself that will lash out at nearby enemies. The shadows will sometimes inflict damage on his enemies and sometimes harm them in other ways."); } int allow_shifted() { return 1; } int prerequisites(object ob) { if (!objectp(ob)) { return 0; } if ((int)ob->query_class_level("shadow_adept") < 7) { dest_effect(); return 0; } return ::prerequisites(ob); } int cmd_shadow_apotheosis(string str) { object feat; if (!objectp(TP)) { return 0; } feat = new(base_name(TO)); feat->setup_feat(TP, str); return 1; } string cm(string str) { return CRAYON_D->color_string(str, "very black"); } void execute_feat() { string YOU, YOUS; object obj; if (!objectp(caster)) { dest_effect(); return; } if (FEATS_D->is_active(caster, "shadow apotheosis")) { obj = query_active_feat("shadow apotheosis"); tell_object(caster, cm("You release your connection to the shadows around you and they slither away into the world.")); tell_room(place, cm("" + caster->QCN + " releases " + caster->QP + " connection to the shadows around " + caster->QO + " and the shadows slither out into the world!"), caster); caster = 0; obj->dest_effect(); dest_effect(); return; } tell_object(caster, cm("You focus on the darkness inside your soul, letting it seep into your very pores")); tell_object(caster, cm("You feel a torrent of shadows roll outwards from your body, blanketing the area in darkness.")); tell_object(caster, cm("A vortex of smoky blackness spins slowly around you.")); tell_room(place, cm("" + caster->QCN + "'s eyes glass over and " + caster->QS + " stares blankly at nothing."), caster); tell_room(place, cm("A torrent of shadows roll outwards from " + caster->QCN + "'s body, blanketing the area in darkness!"), caster); tell_room(place, cm("A vortex of smoky blackness spins slowly around " + caster->QCN + "."), caster); caster->remove_property_value("added short", ({ "%^RESET%^%^BOLD%^%^BLACK%^ (surrounded by a vortex of shadows)%^RESET%^" })); caster->set_property("added short", ({ "%^RESET%^%^BOLD%^%^BLACK%^ (surrounded by a vortex of shadows)%^RESET%^" })); caster->set_property("active_feats", ({ TO })); ::execute_feat(); return; } void execute_attack() { object* attackers = ({}); int i; if (!objectp(caster)) { dest_effect(); return; } if (caster->query_ghost() || caster->query_unconscious()) { dest_effect(); return; } place = environment(caster); attackers = caster->query_attackers(); if (sizeof(attackers)) { tell_object(caster, cm("A shadowy tendril lashes out at your enemies from vortex of shadows !")); tell_room(place, cm("A shadowy tendril lashes out from " + caster->QCN + "'s vortex of shadows and lashes out!"), ({ caster })); } for (i = 0; sizeof(attackers), i < sizeof(attackers); i++) { if (!objectp(attackers[i])) { continue; } if (place != environment(attackers[i])) { continue; } if (attackers[i]->query_unconscious()) { continue; } shadow_effects(attackers[i]); } if (!sizeof(attackers) && !random(100)) { tell_object(caster, cm("The shadow vortex stirs with eagerness!")); tell_room(place, cm("You can see twisted humanoid shapes clawing at the vortex surrounding ") + caster->QCN + cm(", as " "if they were trying to escape into the world!"), caster); } if (objectp(place)) { place->addObjectToCombatCycle(TO, 1); }else { dest_effect(); } } void shadow_effects(object obj) { int damage; if (!objectp(obj)) { return; } // damage, stun, trip, blind switch (random(15)) { case 0: // trip tell_object(obj, cm("A shadowy tendril lashes out from " + caster->QCN + "'s vortex of shadows and tries to grasp you!")); if (!obj->reflex_save(clevel) && !obj->query_property("no trip")) { tell_object(obj, cm("The shadowy tendril wraps around your ankle and pulls you from your feet!")); }else { tell_object(obj, cm("You managed to sidestep the grasping tendril!")); } break; case 1..3: // stun tell_object(obj, cm("A streak of darkness flies from " + caster->QCN + "'s shadow vortex and flies towards your head!")); if (!obj->reflex_save(clevel) && !obj->query_property("no stun")) { tell_object(obj, cm("You try to dodge but to no avail, the streak of darkness hits you in the head, staggering you with intense pain!")); obj->set_paralyzed(roll_dice(1, 2) * 8, cm("You are trying to recover your senses!")); }else { tell_object(obj, cm("You duck to the side, avoiding the streak of darkness at the last instant.")); } break; case 4..7: // blind tell_object(obj, cm("An inky black shadow flies towards you, threatening to envelop you!")); if (!obj->will_save(clevel) && !obj->query_property("no blind")) { tell_object(obj, cm("The shadowy figure wraps about you like a dense blanket of smoke, making it impossible to see!")); obj->set_temporary_blinded(clevel / 20 + 1); }else { tell_object(obj, cm("The shadowy figure tries to wrap around you but you shrug it off!")); } break; case 8..14: //damage damage = roll_dice(clevel, 4); // hits all targets if (obj->fort_save(clevel)) { damage = damage / 2; } tell_object(obj, cm("A bolt of black lightning strikes out from the vortex surrounding " + caster->QCN + " striking you painfully!")); obj->cause_typed_damage(obj, obj->return_target_limb(), damage, "untyped"); caster->add_hp(damage / 6); break; } return; } void dest_effect() { if (objectp(caster)) { tell_object(caster, "%^B_BLUE%^Your vortex of shadows dissipates."); caster->remove_property_value("added short", ({ "%^RESET%^%^BOLD%^%^BLACK%^ (surrounded by a vortex of shadows)%^RESET%^" })); caster->remove_property_value("active_feats", ({ TO })); } ::dest_effect(); remove_feat(TO); return; }
33.995305
241
0.609446
265de66f1b542a9606a54a7011aac049890c29a9
1,788
h
C
FuegoUniversalComponent/fuego/smartgame/SgMove.h
GSMgeeth/gameofgo
51563fea15fbdca797afb7cf9a29773a313e5697
[ "Apache-2.0" ]
13
2016-09-09T13:45:42.000Z
2021-12-17T08:42:28.000Z
FuegoUniversalComponent/fuego/smartgame/SgMove.h
GSMgeeth/gameofgo
51563fea15fbdca797afb7cf9a29773a313e5697
[ "Apache-2.0" ]
1
2016-06-18T05:19:58.000Z
2016-09-15T18:21:54.000Z
FuegoUniversalComponent/fuego/smartgame/SgMove.h
cbordeman/gameofgo
51563fea15fbdca797afb7cf9a29773a313e5697
[ "Apache-2.0" ]
5
2016-11-19T03:05:12.000Z
2022-01-31T12:20:40.000Z
//---------------------------------------------------------------------------- /** @file SgMove.h Definitions for game-independent moves. Useful for games that can encode moves as positive integers (including 0). Negative integers are reserved for special meanings, like pass or null move and defined in this file. Don't make an assumption about the exact values of the special moves (apart that they are negative). If you do, at least document it with a static assertion. Classes that can work with moves of different games should only include this header. */ //---------------------------------------------------------------------------- #ifndef SG_MOVE_H #define SG_MOVE_H //---------------------------------------------------------------------------- typedef int SgMove; /** A null move is an uninitialized move, not legal to execute. Not the same as a pass move or a null move in null-move-search. */ const SgMove SG_NULLMOVE = -1; /** Used for coupon search. Indicates that no move was made in the game, but a coupon taken from the coupon stack. */ const SgMove SG_COUPONMOVE = -2; /** Used for coupon search. Indicates that no move was made in the game, but a virtual coupon taken from the coupon stack. */ const SgMove SG_COUPONMOVE_VIRTUAL = -3; /** Resign. */ const SgMove SG_RESIGN = -4; //---------------------------------------------------------------------------- namespace SgMoveUtil { /** Is move SG_COUPONMOVE or SG_COUPONMOVE_VIRTUAL? */ bool IsCouponMove(SgMove move); } inline bool SgMoveUtil::IsCouponMove(SgMove move) { return (move == SG_COUPONMOVE || move == SG_COUPONMOVE_VIRTUAL); } //---------------------------------------------------------------------------- #endif // SG_MOVE_H
33.111111
78
0.560962
265f872e6ced12f3cb658cf41575854cd66972da
22,759
h
C
windows/core/ntgdi/client/gdiplus/gpprefix.h
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
windows/core/ntgdi/client/gdiplus/gpprefix.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
windows/core/ntgdi/client/gdiplus/gpprefix.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
/************************************************************************** * * gpprefix.h -- GDI+ header file which prepends all of the GDI+ exports * with a 'Gp' prefix. * * Copyright (c) 1998-1999 Microsoft Corp. All rights reserved. * **************************************************************************/ #if defined(_GDIPLUS_) #define GetTextFaceAliasW GpGetTextFaceAliasW #define AbortDoc GpAbortDoc #define AddFontResourceA GpAddFontResourceA #define AddFontResourceW GpAddFontResourceW #define AddFontResourceExA GpAddFontResourceExA #define AddFontResourceExW GpAddFontResourceExW #define AddFontMemResourceEx GpAddFontMemResourceEx #define AngleArc GpAngleArc #define Arc GpArc #define BitBlt GpBitBlt #define CancelDC GpCancelDC #define ChoosePixelFormat GpChoosePixelFormat #define Chord GpChord #define CloseMetaFile GpCloseMetaFile #define CloseEnhMetaFile GpCloseEnhMetaFile #define CombineRgn GpCombineRgn #define CombineTransform GpCombineTransform #define CopyMetaFileA GpCopyMetaFileA #define CopyMetaFileW GpCopyMetaFileW #define CopyEnhMetaFileA GpCopyEnhMetaFileA #define CopyEnhMetaFileW GpCopyEnhMetaFileW #define CreateCompatibleBitmap GpCreateCompatibleBitmap #define CreateCompatibleDC GpCreateCompatibleDC #define CreateDCA GpCreateDCA #define CreateDCW GpCreateDCW #define CreateDiscardableBitmap GpCreateDiscardableBitmap #define CreateEllipticRgn GpCreateEllipticRgn #define CreateEllipticRgnIndirect GpCreateEllipticRgnIndirect #define CreateFontA GpCreateFontA #define CreateFontW GpCreateFontW #define CreateFontIndirectA GpCreateFontIndirectA #define CreateFontIndirectW GpCreateFontIndirectW #define CreateFontIndirectExA GpCreateFontIndirectExA #define CreateFontIndirectExW GpCreateFontIndirectExW #define CreateHatchBrush GpCreateHatchBrush #define CreateICA GpCreateICA #define CreateICW GpCreateICW #define CreateMetaFileA GpCreateMetaFileA #define CreateMetaFileW GpCreateMetaFileW #define CreateEnhMetaFileA GpCreateEnhMetaFileA #define CreateEnhMetaFileW GpCreateEnhMetaFileW #define CreatePatternBrush GpCreatePatternBrush #define CreatePen GpCreatePen #define ExtCreatePen GpExtCreatePen #define CreatePenIndirect GpCreatePenIndirect #define CreateRectRgn GpCreateRectRgn #define CreateRectRgnIndirect GpCreateRectRgnIndirect #define CreateRoundRectRgn GpCreateRoundRectRgn #define CreateScalableFontResourceA GpCreateScalableFontResourceA #define CreateScalableFontResourceW GpCreateScalableFontResourceW #define CreateSolidBrush GpCreateSolidBrush #define DeleteDC GpDeleteDC #define DeleteMetaFile GpDeleteMetaFile #define DeleteEnhMetaFile GpDeleteEnhMetaFile #define DeleteObject GpDeleteObject #define DescribePixelFormat GpDescribePixelFormat #define DeviceCapabilitiesExA GpDeviceCapabilitiesExA #define DeviceCapabilitiesExW GpDeviceCapabilitiesExW #define DrawEscape GpDrawEscape #define EndDoc GpEndDoc #define EndPage GpEndPage #define EndFormPage GpEndFormPage #define EnumFontFamiliesA GpEnumFontFamiliesA #define EnumFontFamiliesW GpEnumFontFamiliesW #define EnumFontsA GpEnumFontsA #define EnumFontsW GpEnumFontsW #define EnumObjects GpEnumObjects #define Ellipse GpEllipse #define EqualRgn GpEqualRgn #define Escape GpEscape #define ExtEscape GpExtEscape #define ExcludeClipRect GpExcludeClipRect #define ExtFloodFill GpExtFloodFill #define ExtCreateRegion GpExtCreateRegion #define ExtSelectClipRgn GpExtSelectClipRgn #define FillRgn GpFillRgn #define FloodFill GpFloodFill #define FrameRgn GpFrameRgn #define GdiComment GpGdiComment #define GdiFlush GpGdiFlush #define GdiPlayScript GpGdiPlayScript #define GdiPlayDCScript GpGdiPlayDCScript #define GdiPlayJournal GpGdiPlayJournal #define GdiGetBatchLimit GpGdiGetBatchLimit #define GdiSetBatchLimit GpGdiSetBatchLimit #define GetAspectRatioFilterEx GpGetAspectRatioFilterEx #define GetBitmapDimensionEx GpGetBitmapDimensionEx #define GetBkColor GpGetBkColor #define GetBkMode GpGetBkMode #define GetBrushOrgEx GpGetBrushOrgEx #define GetCharABCWidthsA GpGetCharABCWidthsA #define GetCharABCWidthsW GpGetCharABCWidthsW #define GetCharABCWidthsFloatA GpGetCharABCWidthsFloatA #define GetCharABCWidthsFloatW GpGetCharABCWidthsFloatW #define GetCharABCWidthsI GpGetCharABCWidthsI #define GetClipBox GpGetClipBox #define GetClipRgn GpGetClipRgn #define GetColorAdjustment GpGetColorAdjustment #define GetCurrentObject GpGetCurrentObject #define GetCurrentPositionEx GpGetCurrentPositionEx #define GetDeviceCaps GpGetDeviceCaps #define GetFontResourceInfoW GpGetFontResourceInfoW #define GetFontUnicodeRanges GpGetFontUnicodeRanges #define GetGlyphIndicesA GpGetGlyphIndicesA #define GetGlyphIndicesW GpGetGlyphIndicesW #define GetGraphicsMode GpGetGraphicsMode #define GetMapMode GpGetMapMode #define GetMetaFileA GpGetMetaFileA #define GetMetaFileW GpGetMetaFileW #define GetMetaRgn GpGetMetaRgn #define GetEnhMetaFileA GpGetEnhMetaFileA #define GetEnhMetaFileW GpGetEnhMetaFileW #define GetEnhMetaFileDescriptionA GpGetEnhMetaFileDescriptionA #define GetEnhMetaFileDescriptionW GpGetEnhMetaFileDescriptionW #define GetEnhMetaFileHeader GpGetEnhMetaFileHeader #define GetEnhMetaFilePaletteEntries GpGetEnhMetaFilePaletteEntries #define GetEnhMetaFilePixelFormat GpGetEnhMetaFilePixelFormat #define GetFontData GpGetFontData #define GetGlyphOutlineA GpGetGlyphOutlineA #define GetGlyphOutlineW GpGetGlyphOutlineW #define GetKerningPairsA GpGetKerningPairsA #define GetKerningPairsW GpGetKerningPairsW #define GetNearestColor GpGetNearestColor #define GetNearestPaletteIndex GpGetNearestPaletteIndex #define GetOutlineTextMetricsA GpGetOutlineTextMetricsA #define GetOutlineTextMetricsW GpGetOutlineTextMetricsW #define GetPixel GpGetPixel #define GetPixelFormat GpGetPixelFormat #define GetPolyFillMode GpGetPolyFillMode #define GetRasterizerCaps GpGetRasterizerCaps #define GetRandomRgn GpGetRandomRgn #define GetRegionData GpGetRegionData #define GetRelAbs GpGetRelAbs #define GetRgnBox GpGetRgnBox #define GetROP2 GpGetROP2 #define GetStockObject GpGetStockObject #define GetStretchBltMode GpGetStretchBltMode #define GetSystemPaletteUse GpGetSystemPaletteUse #define GetTextAlign GpGetTextAlign #define GetTextCharacterExtra GpGetTextCharacterExtra #define GetTextColor GpGetTextColor #define GetDCBrushColor GpGetDCBrushColor #define GetDCPenColor GpGetDCPenColor #define GetTextExtentPointA GpGetTextExtentPointA #define GetTextExtentPointW GpGetTextExtentPointW #define GetTextExtentPoint32A GpGetTextExtentPoint32A #define GetTextExtentPoint32W GpGetTextExtentPoint32W #define GetTextExtentExPointA GpGetTextExtentExPointA #define GetTextExtentExPointW GpGetTextExtentExPointW #define GetTextExtentPointI GpGetTextExtentPointI #define GetTextExtentExPointI GpGetTextExtentExPointI #define GetTextFaceA GpGetTextFaceA #define GetTextFaceW GpGetTextFaceW #define GetTextMetricsA GpGetTextMetricsA #define GetTextMetricsW GpGetTextMetricsW #define GetViewportExtEx GpGetViewportExtEx #define GetViewportOrgEx GpGetViewportOrgEx #define GetWindowExtEx GpGetWindowExtEx #define GetWindowOrgEx GpGetWindowOrgEx #define GetWorldTransform GpGetWorldTransform #define IntersectClipRect GpIntersectClipRect #define InvertRgn GpInvertRgn #define LineDDA GpLineDDA #define LineTo GpLineTo #define MaskBlt GpMaskBlt #define ModifyWorldTransform GpModifyWorldTransform #define MoveToEx GpMoveToEx #define OffsetClipRgn GpOffsetClipRgn #define OffsetRgn GpOffsetRgn #define OffsetViewportOrgEx GpOffsetViewportOrgEx #define OffsetWindowOrgEx GpOffsetWindowOrgEx #define PaintRgn GpPaintRgn #define PatBlt GpPatBlt #define PolyPatBlt GpPolyPatBlt #define Pie GpPie #define PlayMetaFile GpPlayMetaFile #define PlayEnhMetaFile GpPlayEnhMetaFile #define PlgBlt GpPlgBlt #define PtInRegion GpPtInRegion #define PtVisible GpPtVisible #define RealizePalette GpRealizePalette #define Rectangle GpRectangle #define RectInRegion GpRectInRegion #define RectVisible GpRectVisible #define RemoveFontResourceA GpRemoveFontResourceA #define RemoveFontResourceW GpRemoveFontResourceW #define RemoveFontResourceExA GpRemoveFontResourceExA #define RemoveFontResourceExW GpRemoveFontResourceExW #define RemoveFontMemResourceEx GpRemoveFontMemResourceEx #define ResizePalette GpResizePalette #define RestoreDC GpRestoreDC #define RoundRect GpRoundRect #define SaveDC GpSaveDC #define ScaleViewportExtEx GpScaleViewportExtEx #define ScaleWindowExtEx GpScaleWindowExtEx #define SelectClipRgn GpSelectClipRgn #define SelectObject GpSelectObject #define SelectBrushLocal GpSelectBrushLocal #define SelectFontLocal GpSelectFontLocal #define SelectPalette GpSelectPalette #define SetBitmapDimensionEx GpSetBitmapDimensionEx #define SetBkColor GpSetBkColor #define SetBkMode GpSetBkMode #define SetBrushOrgEx GpSetBrushOrgEx #define SetColorAdjustment GpSetColorAdjustment #define SetFontEnumeration GpSetFontEnumeration #define SetGraphicsMode GpSetGraphicsMode #define SetMapMode GpSetMapMode #define SetMapperFlags GpSetMapperFlags #define SetPixel GpSetPixel #define SetPixelFormat GpSetPixelFormat #define SetPixelV GpSetPixelV #define SetPolyFillMode GpSetPolyFillMode #define SetRectRgn GpSetRectRgn #define SetRelAbs GpSetRelAbs #define SetROP2 GpSetROP2 #define SetStretchBltMode GpSetStretchBltMode #define SetSystemPaletteUse GpSetSystemPaletteUse #define SetTextAlign GpSetTextAlign #define SetTextCharacterExtra GpSetTextCharacterExtra #define SetTextColor GpSetTextColor #define SetDCBrushColor GpSetDCBrushColor #define SetDCPenColor GpSetDCPenColor #define SetTextJustification GpSetTextJustification #define SetLayout GpSetLayout #define GetLayout GpGetLayout #define SetLayoutWidth GpSetLayoutWidth #define MirrorRgn GpMirrorRgn #define SetViewportExtEx GpSetViewportExtEx #define SetViewportOrgEx GpSetViewportOrgEx #define SetWindowExtEx GpSetWindowExtEx #define SetWindowOrgEx GpSetWindowOrgEx #define SetWorldTransform GpSetWorldTransform #define StartDocA GpStartDocA #define StartDocW GpStartDocW #define StartPage GpStartPage #define StartFormPage GpStartFormPage #define StretchBlt GpStretchBlt #define SwapBuffers GpSwapBuffers #define TextOutA GpTextOutA #define TextOutW GpTextOutW #define UpdateColors GpUpdateColors #define UnrealizeObject GpUnrealizeObject #define FixBrushOrgEx GpFixBrushOrgEx #define GetDCOrgEx GpGetDCOrgEx #define AnimatePalette GpAnimatePalette #define ArcTo GpArcTo #define BeginPath GpBeginPath #define CloseFigure GpCloseFigure #define CreateBitmap GpCreateBitmap #define CreateBitmapIndirect GpCreateBitmapIndirect #define CreateBrushIndirect GpCreateBrushIndirect #define CreateDIBitmap GpCreateDIBitmap #define CreateDIBPatternBrush GpCreateDIBPatternBrush #define CreateDIBPatternBrushPt GpCreateDIBPatternBrushPt #define CreateDIBSection GpCreateDIBSection #define CreateHalftonePalette GpCreateHalftonePalette #define CreatePalette GpCreatePalette #define CreatePolygonRgn GpCreatePolygonRgn #define CreatePolyPolygonRgn GpCreatePolyPolygonRgn #define DPtoLP GpDPtoLP #define EndPath GpEndPath #define EnumMetaFile GpEnumMetaFile #define EnumEnhMetaFile GpEnumEnhMetaFile #define ExtTextOutA GpExtTextOutA #define ExtTextOutW GpExtTextOutW #define PolyTextOutA GpPolyTextOutA #define PolyTextOutW GpPolyTextOutW #define FillPath GpFillPath #define FlattenPath GpFlattenPath #define GetArcDirection GpGetArcDirection #define GetBitmapBits GpGetBitmapBits #define GetCharWidthA GpGetCharWidthA #define GetCharWidthW GpGetCharWidthW #define GetCharWidth32A GpGetCharWidth32A #define GetCharWidth32W GpGetCharWidth32W #define GetCharWidthFloatA GpGetCharWidthFloatA #define GetCharWidthFloatW GpGetCharWidthFloatW #define GetCharWidthI GpGetCharWidthI #define GetDIBColorTable GpGetDIBColorTable #define GetDIBits GpGetDIBits #define GetMetaFileBitsEx GpGetMetaFileBitsEx #define GetMiterLimit GpGetMiterLimit #define GetEnhMetaFileBits GpGetEnhMetaFileBits #define GetObjectA GpGetObjectA #define GetObjectW GpGetObjectW #define GetObjectType GpGetObjectType #define GetPaletteEntries GpGetPaletteEntries #define GetPath GpGetPath #define GetSystemPaletteEntries GpGetSystemPaletteEntries #define GetWinMetaFileBits GpGetWinMetaFileBits #define LPtoDP GpLPtoDP #define PathToRegion GpPathToRegion #define PlayMetaFileRecord GpPlayMetaFileRecord #define PlayEnhMetaFileRecord GpPlayEnhMetaFileRecord #define PolyBezier GpPolyBezier #define PolyBezierTo GpPolyBezierTo #define PolyDraw GpPolyDraw #define Polygon GpPolygon #define Polyline GpPolyline #define PolylineTo GpPolylineTo #define PolyPolygon GpPolyPolygon #define PolyPolyline GpPolyPolyline #define ResetDCA GpResetDCA #define ResetDCW GpResetDCW #define SelectClipPath GpSelectClipPath #define SetAbortProc GpSetAbortProc #define SetBitmapBits GpSetBitmapBits #define SetDIBColorTable GpSetDIBColorTable #define SetDIBits GpSetDIBits #define SetDIBitsToDevice GpSetDIBitsToDevice #define SetMetaFileBitsEx GpSetMetaFileBitsEx #define SetEnhMetaFileBits GpSetEnhMetaFileBits #define SetMiterLimit GpSetMiterLimit #define SetPaletteEntries GpSetPaletteEntries #define SetWinMetaFileBits GpSetWinMetaFileBits #define StretchDIBits GpStretchDIBits #define StrokeAndFillPath GpStrokeAndFillPath #define StrokePath GpStrokePath #define WidenPath GpWidenPath #define AbortPath GpAbortPath #define SetArcDirection GpSetArcDirection #define SetMetaRgn GpSetMetaRgn #define GetBoundsRect GpGetBoundsRect #define SetBoundsRect GpSetBoundsRect #define SetICMMode GpSetICMMode #define EnumICMProfilesA GpEnumICMProfilesA #define EnumICMProfilesW GpEnumICMProfilesW #define CheckColorsInGamut GpCheckColorsInGamut #define GetColorSpace GpGetColorSpace #define GetLogColorSpaceA GpGetLogColorSpaceA #define GetLogColorSpaceW GpGetLogColorSpaceW #define CreateColorSpaceA GpCreateColorSpaceA #define CreateColorSpaceW GpCreateColorSpaceW #define SetColorSpace GpSetColorSpace #define DeleteColorSpace GpDeleteColorSpace #define GetICMProfileA GpGetICMProfileA #define GetICMProfileW GpGetICMProfileW #define SetICMProfileA GpSetICMProfileA #define SetICMProfileW GpSetICMProfileW #define GetDeviceGammaRamp GpGetDeviceGammaRamp #define SetDeviceGammaRamp GpSetDeviceGammaRamp #define ColorMatchToTarget GpColorMatchToTarget #define UpdateICMRegKeyA GpUpdateICMRegKeyA #define UpdateICMRegKeyW GpUpdateICMRegKeyW #define ColorCorrectPalette GpColorCorrectPalette #define gdiPlaySpoolStream GpgdiPlaySpoolStream #define EnumFontFamiliesExA GpEnumFontFamiliesExA #define EnumFontFamiliesExW GpEnumFontFamiliesExW #define GetCharacterPlacementA GpGetCharacterPlacementA #define GetCharacterPlacementW GpGetCharacterPlacementW #define GetFontLanguageInfo GpGetFontLanguageInfo #define TranslateCharsetInfo GpTranslateCharsetInfo #define GetTextCharsetInfo GpGetTextCharsetInfo #define GetTextCharset GpGetTextCharset #define SetMagicColors GpSetMagicColors #define EnableEUDC GpEnableEUDC #define EudcLoadLinkW GpEudcLoadLinkW #define EudcUnloadLinkW GpEudcUnloadLinkW #define GetEUDCTimeStamp GpGetEUDCTimeStamp #define GetEUDCTimeStampExW GpGetEUDCTimeStampExW #define GetStringBitmapA GpGetStringBitmapA #define GetStringBitmapW GpGetStringBitmapW #define QueryFontAssocStatus GpQueryFontAssocStatus #define GetFontAssocStatus GpGetFontAssocStatus #define GdiGetPageCount GpGdiGetPageCount #define GdiGetDC GpGdiGetDC #define GdiDeleteSpoolFileHandle GpGdiDeleteSpoolFileHandle #define GdiGetPageHandle GpGdiGetPageHandle #define GdiGetSpoolFileHandle GpGdiGetSpoolFileHandle #define GdiPlayEMF GpGdiPlayEMF #define GdiStartDocEMF GpGdiStartDocEMF #define GdiStartPageEMF GpGdiStartPageEMF #define GdiPlayPageEMF GpGdiPlayPageEMF #define GdiPlayPageEMF GpGdiPlayPageEMF #define GdiEndPageEMF GpGdiEndPageEMF #define GdiEndDocEMF GpGdiEndDocEMF #define GdiGetDevmodeForPage GpGdiGetDevmodeForPage #define GdiResetDCEMF GpGdiResetDCEMF #endif
57.910941
76
0.615273
26610d4333ffae32b726147551b45bac04591a9b
441
h
C
DataVault/DataVault/DataSources/QuickLookDataSource.h
TheArchitect123/Xcode-Portfolio-Projects
4040dad2b7c982016fe2485a5998f8cd548a3210
[ "MIT" ]
null
null
null
DataVault/DataVault/DataSources/QuickLookDataSource.h
TheArchitect123/Xcode-Portfolio-Projects
4040dad2b7c982016fe2485a5998f8cd548a3210
[ "MIT" ]
null
null
null
DataVault/DataVault/DataSources/QuickLookDataSource.h
TheArchitect123/Xcode-Portfolio-Projects
4040dad2b7c982016fe2485a5998f8cd548a3210
[ "MIT" ]
null
null
null
// // QuickLookDataSource.h // DataVault // // Created by Assassin on 8/6/20. // Copyright © 2020 Dan Gerchcovich. All rights reserved. // #import <Foundation/Foundation.h> #import <QuickLook/QuickLook.h> NS_ASSUME_NONNULL_BEGIN @interface QuickLookDataSource : QLPreviewController<QLPreviewControllerDataSource, QLPreviewControllerDelegate> @property (strong, nonatomic, readwrite) NSString *_dataPath; @end NS_ASSUME_NONNULL_END
21
112
0.786848
2662cf3c1765c623019334e601d40bdbcb2eb478
5,557
h
C
wrapper/src/system/libmtk/include/vmtsdcl_i2c.h
gokr/ardunimo
61abf0822e6a4d19353bcef28ff9e6f5988e94e7
[ "MIT" ]
48
2016-02-13T14:55:42.000Z
2021-04-19T21:03:34.000Z
wrapper/src/system/libmtk/include/vmtsdcl_i2c.h
BaldEagleX02/Arduino-Nim
54b2e9101d5bef483782e0b93af83bbe1e184e7c
[ "MIT" ]
null
null
null
wrapper/src/system/libmtk/include/vmtsdcl_i2c.h
BaldEagleX02/Arduino-Nim
54b2e9101d5bef483782e0b93af83bbe1e184e7c
[ "MIT" ]
2
2016-12-20T20:22:02.000Z
2019-04-28T12:08:59.000Z
#ifndef __VM_TS_DCL_I2C_H__ #define __VM_TS_DCL_I2C_H__ /****************************************************************** * DESCRIPTION * This enum defines the device for I2C module,used in vm_ts_dcl_open as a parameter. * To control I2C, you should use DCL(Driver Common Layer) APIs. * EXAMPLE * <code> * #include "vmtsdcl.h" * VM_TS_DCL_HANDLE i2c_handle; // Declare a VM_TS_DCL_HANDLE variable. * i2c_handle = vm_ts_dcl_open(VM_TS_DCL_I2C,0); // Call vm_ts_dcl_open to get a handle. flag fill 0. * </code> *******************************************************************/ typedef enum { VM_TS_I2C_GROUP_START = VM_TS_DCL_I2C_GROUP_START, VM_TS_DCL_I2C }VM_TS_DCL_I2C_DEV; /****************************************************************** * DESCRIPTION * This enum defines the I2C transaction state, it will be given to user by lisr callback * For more details , refer the VM_TS_DCL_I2C_CTRL_CMD_T description. *******************************************************************/ typedef enum { VM_TS_DCL_I2C_TRANS_STA_FINISH = 1, /* transfer finish success */ VM_TS_DCL_I2C_TRANS_STA_ACK_ERR, /* an ack error happened */ VM_TS_DCL_I2C_TRANS_STA_NACK_ERR, /* an n-ack error happened */ VM_TS_DCL_I2C_TRANS_STA_FAIL, /* unexpected error happend*/ }VM_TS_DCL_I2C_TRANSACTION_STATE; /****************************************************************** * DESCRIPTION * This enum defines the I2C transaction mode. * For more details , refer the VM_TS_DCL_I2C_CTRL_CONFIG_T description. *******************************************************************/ typedef enum { VM_TS_DCL_I2C_TRANSACTION_FAST_MODE, /* Fast Mode: < 400kbps */ VM_TS_DCL_I2C_TRANSACTION_HIGH_SPEED_MODE /* Hign Speed Mode: > 400kbps */ }VM_TS_DCL_I2C_TRANSACTION_MODE; /****************************************************************** * DESCRIPTION * This enum define the control command for I2C module,used in vm_ts_dcl_control as parameter. * With different commands, user could control the different function of the I2C. * To control I2C, you should use DCL(Driver Common Layer) APIs. * EXAMPLE * <code> * #include "vmtsdcl.h" * VM_TS_DCL_HANDLE i2c_handle; // Declare a VM_TS_DCL_HANDLE variable. * VM_TS_DCL_I2C_CTRL_CONFIG_T i2c_config; * i2c_handle = vm_ts_dcl_open(VM_TS_DCL_I2C,0); // First, we call vm_ts_dcl_open to get a handle. 19 means eint19 * vm_ts_dcl_register_callback(i2c_handle,VM_TS_DCL_REGISTER_CALLBACK_LEVEL2,(void)i2c_lisr_cb); // register callback function,Note:i2c_lisr_cb is given by user * vm_ts_dcl_control(i2c_handle,VM_TS_DCL_I2C_CMD_CONFIG,(void *)&i2c_config); // Usually, before we config eint, we mask it firstly. * vm_ts_dcl_control(i2c_handle,VM_TS_DCL_I2C_CMD_SINGLE_WRITE_ASYNC,NULL); // Usually, before we config eint, we mask it firstly. * vm_ts_dcl_close(i2c_handle); // Finally, if you are sure you will not use eint, you call vm_dcl_close ,otherwise, not call this api. * </code> *******************************************************************/ typedef enum { RESERVE_VM_TS_DCL_I2C_CMD_SINGLE_WRITE_ASYNC, /* not support,Single write of none-blocking mode */ RESERVE_VM_TS_DCL_I2C_CMD_SINGLE_READ_ASYNC, /* not support,Single read of none-blocking mode */ RESERVE_VM_TS_DCL_I2C_CMD_CONT_WRITE_ASYNC, /* not support,Continue write of none-blocking mode */ RESERVE_VM_TS_DCL_I2C_CMD_CONT_READ_ASYNC, /* not support,Continue read of none-blocking mode */ RESERVE_VM_TS_DCL_I2C_CMD_WRITE_AND_READ_ASYNC, /* not support,Write and read of none-blocking mode */ VM_TS_DCL_I2C_CMD_SINGLE_WRITE_SYNC, /* Single write of blocking mode */ VM_TS_DCL_I2C_CMD_SINGLE_READ_SYNC, /* Single read of blocking mode */ VM_TS_DCL_I2C_CMD_CONT_WRITE_SYNC, /* Continue write of blocking mode */ VM_TS_DCL_I2C_CMD_CONT_READ_SYNC, /* Continue read of blocking mode */ VM_TS_DCL_I2C_CMD_WRITE_AND_READ_SYNC, /* Write and read of blocking mode */ VM_TS_DCL_I2C_CMD_CONFIG }VM_TS_DCL_I2C_CTRL_CMD_T; /* For I2C_CMD_SINGLE_WRITE, I2C_CMD_SINGLE_READ command. */ typedef struct { VMUINT8 *pu1Data; /* Pointer to the buffer of data */ VMUINT32 u4DataLen; /* Data length */ }VM_TS_DCL_I2C_CTRL_SINGLE_WRITE_T, VM_TS_DCL_I2C_CTRL_SINGLE_READ_T; /* For I2C_CMD_CONT_WRITE, I2C_CMD_CONT_READ command. */ typedef struct { VMUINT8 *pu1Data; /* Pointer to the buffer of data */ VMUINT32 u4DataLen; /* Data length of each transfer */ VMUINT32 u4TransferNum; /* Transfer number */ }VM_TS_DCL_I2C_CTRL_CONT_WRITE_T, VM_TS_DCL_I2C_CTRL_CONT_READ_T; /* For I2C_CMD_WRITE_AND_READ command. */ typedef struct { VMUINT8 *pu1InData; /* Pointer to the read data */ VMUINT32 u4InDataLen; /* Read data length */ VMUINT8 *pu1OutData; /* Pointer to the write data */ VMUINT32 u4OutDataLen; /* Write data length */ }VM_TS_DCL_I2C_CTRL_WRITE_AND_READE_T; /* DCL I2C configure structure */ typedef struct { VMUINT8 u1SlaveAddress; /* Slave address */ VMUINT8 u1DelayLen; /* Wait delay between consecutive transfers (the unit is half pulse width) */ VM_TS_DCL_I2C_TRANSACTION_MODE eTransactionMode; /* Fast mode or high speed mode */ VMUINT32 u4FastModeSpeed; /* The transfer speed under fast mode. But even under high speed mode, you should alse configure this parameter */ VMUINT32 u4HSModeSpeed; /* The transfer speed under high speed mode */ } VM_TS_DCL_I2C_CTRL_CONFIG_T; #endif
47.495726
162
0.678604
26633e4230ef99cf5dfb1f1551113a52fc24cca8
1,779
h
C
externals/YAKL/YAKL_alloc_free.h
meng630/GMD_E3SM_SCM
990f84598b79f9b4763c3a825a7d25f4e0f5a565
[ "FTL", "zlib-acknowledgement", "RSA-MD" ]
null
null
null
externals/YAKL/YAKL_alloc_free.h
meng630/GMD_E3SM_SCM
990f84598b79f9b4763c3a825a7d25f4e0f5a565
[ "FTL", "zlib-acknowledgement", "RSA-MD" ]
null
null
null
externals/YAKL/YAKL_alloc_free.h
meng630/GMD_E3SM_SCM
990f84598b79f9b4763c3a825a7d25f4e0f5a565
[ "FTL", "zlib-acknowledgement", "RSA-MD" ]
null
null
null
#pragma once #include "YAKL_error.h" namespace yakl { inline void set_alloc_free(std::function<void *( size_t )> &alloc , std::function<void ( void * )> &dealloc) { #if defined(__USE_CUDA__) #if defined (__MANAGED__) alloc = [] ( size_t bytes ) -> void* { void *ptr; cudaMallocManaged(&ptr,bytes); check_last_error(); cudaMemPrefetchAsync(ptr,bytes,0); check_last_error(); #ifdef _OPENMP45 omp_target_associate_ptr(ptr,ptr,bytes,0,0); #endif #ifdef _OPENACC acc_map_data(ptr,ptr,bytes); #endif return ptr; }; dealloc = [] ( void *ptr ) { cudaFree(ptr); check_last_error(); }; #else alloc = [] ( size_t bytes ) -> void* { void *ptr; cudaMalloc(&ptr,bytes); check_last_error(); return ptr; }; dealloc = [] ( void *ptr ) { cudaFree(ptr); check_last_error(); }; #endif #elif defined(__USE_HIP__) #if defined (__MANAGED__) alloc = [] ( size_t bytes ) -> void* { void *ptr; hipMallocHost(&ptr,bytes); check_last_error(); return ptr; }; dealloc = [] ( void *ptr ) { hipFree(ptr); check_last_error(); }; #else alloc = [] ( size_t bytes ) -> void* { void *ptr; hipMalloc(&ptr,bytes); check_last_error(); return ptr; }; dealloc = [] ( void *ptr ) { hipFree(ptr); check_last_error(); }; #endif #else alloc = ::malloc; dealloc = ::free; #endif } }
24.369863
112
0.4733
266535c2a72f21dc7309962542bd71b68fe9b98f
9,875
c
C
src/iodaLinux/drivers/platform/x86/silead_dmi.c
huaicheng/IODA-SOSP21-AE
153470e804b483d471c8d6b28c11ff88ebc53d58
[ "Linux-OpenIB" ]
5
2021-12-16T02:58:47.000Z
2022-03-27T12:05:33.000Z
src/iodaLinux/drivers/platform/x86/silead_dmi.c
huaicheng/IODA-SOSP21-AE
153470e804b483d471c8d6b28c11ff88ebc53d58
[ "Linux-OpenIB" ]
3
2021-09-06T09:14:42.000Z
2022-03-27T08:09:54.000Z
src/iodaLinux/drivers/platform/x86/silead_dmi.c
huaicheng/IODA-SOSP21-AE
153470e804b483d471c8d6b28c11ff88ebc53d58
[ "Linux-OpenIB" ]
1
2022-03-18T07:17:40.000Z
2022-03-18T07:17:40.000Z
/* * Silead touchscreen driver DMI based configuration code * * Copyright (c) 2017 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Red Hat authors: * Hans de Goede <hdegoede@redhat.com> */ #include <linux/acpi.h> #include <linux/device.h> #include <linux/dmi.h> #include <linux/i2c.h> #include <linux/notifier.h> #include <linux/property.h> #include <linux/string.h> struct silead_ts_dmi_data { const char *acpi_name; const struct property_entry *properties; }; static const struct property_entry cube_iwork8_air_props[] = { PROPERTY_ENTRY_U32("touchscreen-size-x", 1660), PROPERTY_ENTRY_U32("touchscreen-size-y", 900), PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"), PROPERTY_ENTRY_STRING("firmware-name", "gsl3670-cube-iwork8-air.fw"), PROPERTY_ENTRY_U32("silead,max-fingers", 10), { } }; static const struct silead_ts_dmi_data cube_iwork8_air_data = { .acpi_name = "MSSL1680:00", .properties = cube_iwork8_air_props, }; static const struct property_entry jumper_ezpad_mini3_props[] = { PROPERTY_ENTRY_U32("touchscreen-size-x", 1700), PROPERTY_ENTRY_U32("touchscreen-size-y", 1150), PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"), PROPERTY_ENTRY_STRING("firmware-name", "gsl3676-jumper-ezpad-mini3.fw"), PROPERTY_ENTRY_U32("silead,max-fingers", 10), { } }; static const struct silead_ts_dmi_data jumper_ezpad_mini3_data = { .acpi_name = "MSSL1680:00", .properties = jumper_ezpad_mini3_props, }; static const struct property_entry dexp_ursus_7w_props[] = { PROPERTY_ENTRY_U32("touchscreen-size-x", 890), PROPERTY_ENTRY_U32("touchscreen-size-y", 630), PROPERTY_ENTRY_STRING("firmware-name", "gsl1686-dexp-ursus-7w.fw"), PROPERTY_ENTRY_U32("silead,max-fingers", 10), PROPERTY_ENTRY_BOOL("silead,home-button"), { } }; static const struct silead_ts_dmi_data dexp_ursus_7w_data = { .acpi_name = "MSSL1680:00", .properties = dexp_ursus_7w_props, }; static const struct property_entry surftab_wintron70_st70416_6_props[] = { PROPERTY_ENTRY_U32("touchscreen-size-x", 884), PROPERTY_ENTRY_U32("touchscreen-size-y", 632), PROPERTY_ENTRY_STRING("firmware-name", "gsl1686-surftab-wintron70-st70416-6.fw"), PROPERTY_ENTRY_U32("silead,max-fingers", 10), PROPERTY_ENTRY_BOOL("silead,home-button"), { } }; static const struct silead_ts_dmi_data surftab_wintron70_st70416_6_data = { .acpi_name = "MSSL1680:00", .properties = surftab_wintron70_st70416_6_props, }; static const struct property_entry gp_electronic_t701_props[] = { PROPERTY_ENTRY_U32("touchscreen-size-x", 960), PROPERTY_ENTRY_U32("touchscreen-size-y", 640), PROPERTY_ENTRY_BOOL("touchscreen-inverted-x"), PROPERTY_ENTRY_BOOL("touchscreen-inverted-y"), PROPERTY_ENTRY_STRING("firmware-name", "gsl1680-gp-electronic-t701.fw"), { } }; static const struct silead_ts_dmi_data gp_electronic_t701_data = { .acpi_name = "MSSL1680:00", .properties = gp_electronic_t701_props, }; static const struct property_entry pipo_w2s_props[] = { PROPERTY_ENTRY_U32("touchscreen-size-x", 1660), PROPERTY_ENTRY_U32("touchscreen-size-y", 880), PROPERTY_ENTRY_BOOL("touchscreen-inverted-x"), PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"), PROPERTY_ENTRY_STRING("firmware-name", "gsl1680-pipo-w2s.fw"), { } }; static const struct silead_ts_dmi_data pipo_w2s_data = { .acpi_name = "MSSL1680:00", .properties = pipo_w2s_props, }; static const struct property_entry pov_mobii_wintab_p800w_props[] = { PROPERTY_ENTRY_U32("touchscreen-size-x", 1800), PROPERTY_ENTRY_U32("touchscreen-size-y", 1150), PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"), PROPERTY_ENTRY_STRING("firmware-name", "gsl3692-pov-mobii-wintab-p800w.fw"), PROPERTY_ENTRY_BOOL("silead,home-button"), { } }; static const struct silead_ts_dmi_data pov_mobii_wintab_p800w_data = { .acpi_name = "MSSL1680:00", .properties = pov_mobii_wintab_p800w_props, }; static const struct property_entry itworks_tw891_props[] = { PROPERTY_ENTRY_U32("touchscreen-size-x", 1600), PROPERTY_ENTRY_U32("touchscreen-size-y", 890), PROPERTY_ENTRY_BOOL("touchscreen-inverted-y"), PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"), PROPERTY_ENTRY_STRING("firmware-name", "gsl3670-itworks-tw891.fw"), { } }; static const struct silead_ts_dmi_data itworks_tw891_data = { .acpi_name = "MSSL1680:00", .properties = itworks_tw891_props, }; static const struct property_entry chuwi_hi8_pro_props[] = { PROPERTY_ENTRY_U32("touchscreen-size-x", 1728), PROPERTY_ENTRY_U32("touchscreen-size-y", 1148), PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"), PROPERTY_ENTRY_STRING("firmware-name", "gsl3680-chuwi-hi8-pro.fw"), PROPERTY_ENTRY_BOOL("silead,home-button"), { } }; static const struct silead_ts_dmi_data chuwi_hi8_pro_data = { .acpi_name = "MSSL1680:00", .properties = chuwi_hi8_pro_props, }; static const struct property_entry digma_citi_e200_props[] = { PROPERTY_ENTRY_U32("touchscreen-size-x", 1980), PROPERTY_ENTRY_U32("touchscreen-size-y", 1500), PROPERTY_ENTRY_BOOL("touchscreen-inverted-y"), PROPERTY_ENTRY_STRING("firmware-name", "gsl1686-digma_citi_e200.fw"), PROPERTY_ENTRY_U32("silead,max-fingers", 10), PROPERTY_ENTRY_BOOL("silead,home-button"), { } }; static const struct silead_ts_dmi_data digma_citi_e200_data = { .acpi_name = "MSSL1680:00", .properties = digma_citi_e200_props, }; static const struct dmi_system_id silead_ts_dmi_table[] = { { /* CUBE iwork8 Air */ .driver_data = (void *)&cube_iwork8_air_data, .matches = { DMI_MATCH(DMI_SYS_VENDOR, "cube"), DMI_MATCH(DMI_PRODUCT_NAME, "i1-TF"), DMI_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"), }, }, { /* Jumper EZpad mini3 */ .driver_data = (void *)&jumper_ezpad_mini3_data, .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Insyde"), /* jumperx.T87.KFBNEEA02 with the version-nr dropped */ DMI_MATCH(DMI_BIOS_VERSION, "jumperx.T87.KFBNEEA"), }, }, { /* DEXP Ursus 7W */ .driver_data = (void *)&dexp_ursus_7w_data, .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Insyde"), DMI_MATCH(DMI_PRODUCT_NAME, "7W"), }, }, { /* Trekstor Surftab Wintron 7.0 ST70416-6 */ .driver_data = (void *)&surftab_wintron70_st70416_6_data, .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Insyde"), DMI_MATCH(DMI_PRODUCT_NAME, "ST70416-6"), /* Exact match, different versions need different fw */ DMI_MATCH(DMI_BIOS_VERSION, "TREK.G.WI71C.JGBMRBA04"), }, }, { /* Ployer Momo7w (same hardware as the Trekstor ST70416-6) */ .driver_data = (void *)&surftab_wintron70_st70416_6_data, .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Shenzhen PLOYER"), DMI_MATCH(DMI_PRODUCT_NAME, "MOMO7W"), /* Exact match, different versions need different fw */ DMI_MATCH(DMI_BIOS_VERSION, "MOMO.G.WI71C.MABMRBA02"), }, }, { /* GP-electronic T701 */ .driver_data = (void *)&gp_electronic_t701_data, .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Insyde"), DMI_MATCH(DMI_PRODUCT_NAME, "T701"), DMI_MATCH(DMI_BIOS_VERSION, "BYT70A.YNCHENG.WIN.007"), }, }, { /* Pipo W2S */ .driver_data = (void *)&pipo_w2s_data, .matches = { DMI_MATCH(DMI_SYS_VENDOR, "PIPO"), DMI_MATCH(DMI_PRODUCT_NAME, "W2S"), }, }, { /* Point of View mobii wintab p800w */ .driver_data = (void *)&pov_mobii_wintab_p800w_data, .matches = { DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"), DMI_MATCH(DMI_BIOS_VERSION, "3BAIR1013"), /* Above matches are too generic, add bios-date match */ DMI_MATCH(DMI_BIOS_DATE, "08/22/2014"), }, }, { /* I.T.Works TW891 */ .driver_data = (void *)&itworks_tw891_data, .matches = { DMI_MATCH(DMI_SYS_VENDOR, "To be filled by O.E.M."), DMI_MATCH(DMI_PRODUCT_NAME, "TW891"), }, }, { /* Chuwi Hi8 Pro */ .driver_data = (void *)&chuwi_hi8_pro_data, .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Hampoo"), DMI_MATCH(DMI_PRODUCT_NAME, "X1D3_C806N"), }, }, { /* Digma Citi E200 */ .driver_data = (void *)&digma_citi_e200_data, .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Digma"), DMI_MATCH(DMI_PRODUCT_NAME, "CITI E200"), DMI_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"), }, }, { }, }; static const struct silead_ts_dmi_data *silead_ts_data; static void silead_ts_dmi_add_props(struct i2c_client *client) { struct device *dev = &client->dev; int error; if (has_acpi_companion(dev) && !strncmp(silead_ts_data->acpi_name, client->name, I2C_NAME_SIZE)) { error = device_add_properties(dev, silead_ts_data->properties); if (error) dev_err(dev, "failed to add properties: %d\n", error); } } static int silead_ts_dmi_notifier_call(struct notifier_block *nb, unsigned long action, void *data) { struct device *dev = data; struct i2c_client *client; switch (action) { case BUS_NOTIFY_ADD_DEVICE: client = i2c_verify_client(dev); if (client) silead_ts_dmi_add_props(client); break; default: break; } return 0; } static struct notifier_block silead_ts_dmi_notifier = { .notifier_call = silead_ts_dmi_notifier_call, }; static int __init silead_ts_dmi_init(void) { const struct dmi_system_id *dmi_id; int error; dmi_id = dmi_first_match(silead_ts_dmi_table); if (!dmi_id) return 0; /* Not an error */ silead_ts_data = dmi_id->driver_data; error = bus_register_notifier(&i2c_bus_type, &silead_ts_dmi_notifier); if (error) pr_err("%s: failed to register i2c bus notifier: %d\n", __func__, error); return error; } /* * We are registering out notifier after i2c core is initialized and i2c bus * itself is ready (which happens at postcore initcall level), but before * ACPI starts enumerating devices (at subsys initcall level). */ arch_initcall(silead_ts_dmi_init);
28.958944
76
0.731443
2665553c11aca1277ebb223d90d3429790b2bd67
1,016
c
C
sources/utils/setcnd.c
gmzorz/MiniRT
ce87cd1745036391f54503f25eb815273918d7e6
[ "MIT" ]
10
2021-04-13T15:48:34.000Z
2022-03-10T19:16:24.000Z
sources/utils/setcnd.c
gmzorz/MiniRT
ce87cd1745036391f54503f25eb815273918d7e6
[ "MIT" ]
null
null
null
sources/utils/setcnd.c
gmzorz/MiniRT
ce87cd1745036391f54503f25eb815273918d7e6
[ "MIT" ]
null
null
null
/* ************************************************************************** */ /* */ /* :::::::: */ /* setcnd.c :+: :+: */ /* +:+ */ /* By: goosterl <goosterl@student.codam.nl> +#+ */ /* +#+ */ /* Created: 2021/02/15 11:43:45 by goosterl #+# #+# */ /* Updated: 2021/04/12 14:17:27 by goosterl ######## odam.nl */ /* */ /* ************************************************************************** */ #include <alias.h> t_real setcnd(int condition, t_real pos, t_real neg) { if (condition) return (pos); return (neg); }
48.380952
80
0.187992
2665f1d5bdb13ed8e50ddab0f10b357fc8dac972
799
c
C
util/cpp/expr.c
Godzil/ack
ffe13a45830bf3fd310a1db9feff879031ed9b5c
[ "BSD-3-Clause" ]
6
2015-02-16T17:05:51.000Z
2022-01-10T20:28:11.000Z
util/cpp/expr.c
Godzil/ack
ffe13a45830bf3fd310a1db9feff879031ed9b5c
[ "BSD-3-Clause" ]
null
null
null
util/cpp/expr.c
Godzil/ack
ffe13a45830bf3fd310a1db9feff879031ed9b5c
[ "BSD-3-Clause" ]
null
null
null
/* $Id$ */ /* * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ /* OPERATOR HANDLING */ #include "Lpars.h" int rank_of(int oper) { /* The rank of the operator oper is returned. */ switch (oper) { default: return 0; case '(': return 1; case '!': return 2; case '*': case '/': case '%': return 3; case '+': case '-': return 4; case LEFT: case RIGHT: return 5; case '<': case '>': case LESSEQ: case GREATEREQ: return 6; case EQUAL: case NOTEQUAL: return 7; case '&': return 8; case '^': return 9; case '|': return 10; case AND: return 11; case OR: return 12; case '?': case ':': return 13; case ',': return 15; } /*NOTREACHED*/ }
14.017544
79
0.590738
2667ec4a92e1021ba4fdf21c103981ad590168a4
3,920
c
C
third_party/elfutils/src/backends/common-reloc.c
zipated/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
2,151
2020-04-18T07:31:17.000Z
2022-03-31T08:39:18.000Z
third_party/elfutils/src/backends/common-reloc.c
cangulcan/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
395
2020-04-18T08:22:18.000Z
2021-12-08T13:04:49.000Z
third_party/elfutils/src/backends/common-reloc.c
cangulcan/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
338
2020-04-18T08:03:10.000Z
2022-03-29T12:33:22.000Z
/* Common code for ebl reloc functions. Copyright (C) 2005, 2006 Red Hat, Inc. This file is part of elfutils. This file is free software; you can redistribute it and/or modify it under the terms of either * 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 or * 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 or both in parallel, as here. elfutils 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 copies of the GNU General Public License and the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "libebl_CPU.h" #include <assert.h> #define R_TYPE(name) PASTE (RELOC_PREFIX, name) #define PASTE(a, b) PASTE_1 (a, b) #define PASTE_1(a, b) a##b #define R_NAME(name) R_NAME_1 (RELOC_PREFIX, name) #define R_NAME_1(prefix, type) R_NAME_2 (prefix, type) #define R_NAME_2(prefix, type) #prefix #type #define RELOC_TYPES STRINGIFIED_PASTE (BACKEND, reloc.def) #define STRINGIFIED_PASTE(a, b) STRINGIFY (PASTE (a, b)) #define STRINGIFY(x) STRINGIFY_1 (x) #define STRINGIFY_1(x) #x /* Provide a table of reloc type names, in a PIC-friendly fashion. */ static const struct EBLHOOK(reloc_nametable) { char zero; #define RELOC_TYPE(type, uses) \ char name_##type[sizeof R_NAME (type)]; #include RELOC_TYPES #undef RELOC_TYPE } EBLHOOK(reloc_nametable) = { '\0', #define RELOC_TYPE(type, uses) R_NAME (type), #include RELOC_TYPES #undef RELOC_TYPE }; #define reloc_namestr (&EBLHOOK(reloc_nametable).zero) static const uint_fast16_t EBLHOOK(reloc_nameidx)[] = { #define RELOC_TYPE(type, uses) \ [R_TYPE (type)] = offsetof (struct EBLHOOK(reloc_nametable), name_##type), #include RELOC_TYPES #undef RELOC_TYPE }; #define nreloc \ ((int) (sizeof EBLHOOK(reloc_nameidx) / sizeof EBLHOOK(reloc_nameidx)[0])) #define REL (1 << (ET_REL - 1)) #define EXEC (1 << (ET_EXEC - 1)) #define DYN (1 << (ET_DYN - 1)) static const uint8_t EBLHOOK(reloc_valid)[] = { #define RELOC_TYPE(type, uses) [R_TYPE (type)] = uses, #include RELOC_TYPES #undef RELOC_TYPE }; #undef REL #undef EXEC #undef DYN const char * EBLHOOK(reloc_type_name) (int reloc, char *buf __attribute__ ((unused)), size_t len __attribute__ ((unused))) { if (reloc >= 0 && reloc < nreloc && EBLHOOK(reloc_nameidx)[reloc] != 0) return &reloc_namestr[EBLHOOK(reloc_nameidx)[reloc]]; return NULL; } bool EBLHOOK(reloc_type_check) (int reloc) { return reloc >= 0 && reloc < nreloc && EBLHOOK(reloc_nameidx)[reloc] != 0; } bool EBLHOOK(reloc_valid_use) (Elf *elf, int reloc) { uint8_t uses = EBLHOOK(reloc_valid)[reloc]; GElf_Ehdr ehdr_mem; GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem); assert (ehdr != NULL); uint8_t type = ehdr->e_type; return type > ET_NONE && type < ET_CORE && (uses & (1 << (type - 1))); } bool EBLHOOK(copy_reloc_p) (int reloc) { return reloc == R_TYPE (COPY); } bool EBLHOOK(none_reloc_p) (int reloc) { return reloc == R_TYPE (NONE); } #ifndef NO_RELATIVE_RELOC bool EBLHOOK(relative_reloc_p) (int reloc) { return reloc == R_TYPE (RELATIVE); } #endif static void EBLHOOK(init_reloc) (Ebl *ebl) { ebl->reloc_type_name = EBLHOOK(reloc_type_name); ebl->reloc_type_check = EBLHOOK(reloc_type_check); ebl->reloc_valid_use = EBLHOOK(reloc_valid_use); ebl->copy_reloc_p = EBLHOOK(copy_reloc_p); ebl->none_reloc_p = EBLHOOK(none_reloc_p); #ifndef NO_RELATIVE_RELOC ebl->relative_reloc_p = EBLHOOK(relative_reloc_p); #endif }
26.666667
76
0.714541
266840d38c25479c717efb8693969c8d6562462f
14,881
h
C
selfdrive/camerad/include/media/cam_isp.h
Neptos/openpilot
01914a1a91ade18bd7aead99e7d1bf38cd22ad89
[ "MIT" ]
37,508
2016-11-30T18:18:49.000Z
2022-03-31T23:52:00.000Z
selfdrive/camerad/include/media/cam_isp.h
Neptos/openpilot
01914a1a91ade18bd7aead99e7d1bf38cd22ad89
[ "MIT" ]
3,719
2016-11-30T19:25:03.000Z
2022-03-31T22:03:56.000Z
selfdrive/camerad/include/media/cam_isp.h
Neptos/openpilot
01914a1a91ade18bd7aead99e7d1bf38cd22ad89
[ "MIT" ]
7,859
2016-11-30T19:03:05.000Z
2022-03-31T22:56:37.000Z
#ifndef __UAPI_CAM_ISP_H__ #define __UAPI_CAM_ISP_H__ #include "cam_defs.h" #include "cam_isp_vfe.h" #include "cam_isp_ife.h" /* ISP driver name */ #define CAM_ISP_DEV_NAME "cam-isp" /* HW type */ #define CAM_ISP_HW_BASE 0 #define CAM_ISP_HW_CSID 1 #define CAM_ISP_HW_VFE 2 #define CAM_ISP_HW_IFE 3 #define CAM_ISP_HW_ISPIF 4 #define CAM_ISP_HW_MAX 5 /* Color Pattern */ #define CAM_ISP_PATTERN_BAYER_RGRGRG 0 #define CAM_ISP_PATTERN_BAYER_GRGRGR 1 #define CAM_ISP_PATTERN_BAYER_BGBGBG 2 #define CAM_ISP_PATTERN_BAYER_GBGBGB 3 #define CAM_ISP_PATTERN_YUV_YCBYCR 4 #define CAM_ISP_PATTERN_YUV_YCRYCB 5 #define CAM_ISP_PATTERN_YUV_CBYCRY 6 #define CAM_ISP_PATTERN_YUV_CRYCBY 7 #define CAM_ISP_PATTERN_MAX 8 /* Usage Type */ #define CAM_ISP_RES_USAGE_SINGLE 0 #define CAM_ISP_RES_USAGE_DUAL 1 #define CAM_ISP_RES_USAGE_MAX 2 /* Resource ID */ #define CAM_ISP_RES_ID_PORT 0 #define CAM_ISP_RES_ID_CLK 1 #define CAM_ISP_RES_ID_MAX 2 /* Resource Type - Type of resource for the resource id * defined in cam_isp_vfe.h, cam_isp_ife.h */ /* Lane Type in input resource for Port */ #define CAM_ISP_LANE_TYPE_DPHY 0 #define CAM_ISP_LANE_TYPE_CPHY 1 #define CAM_ISP_LANE_TYPE_MAX 2 /* ISP Resurce Composite Group ID */ #define CAM_ISP_RES_COMP_GROUP_NONE 0 #define CAM_ISP_RES_COMP_GROUP_ID_0 1 #define CAM_ISP_RES_COMP_GROUP_ID_1 2 #define CAM_ISP_RES_COMP_GROUP_ID_2 3 #define CAM_ISP_RES_COMP_GROUP_ID_3 4 #define CAM_ISP_RES_COMP_GROUP_ID_4 5 #define CAM_ISP_RES_COMP_GROUP_ID_5 6 #define CAM_ISP_RES_COMP_GROUP_ID_MAX 6 /* ISP packet opcode for ISP */ #define CAM_ISP_PACKET_OP_BASE 0 #define CAM_ISP_PACKET_INIT_DEV 1 #define CAM_ISP_PACKET_UPDATE_DEV 2 #define CAM_ISP_PACKET_OP_MAX 3 /* ISP packet meta_data type for command buffer */ #define CAM_ISP_PACKET_META_BASE 0 #define CAM_ISP_PACKET_META_LEFT 1 #define CAM_ISP_PACKET_META_RIGHT 2 #define CAM_ISP_PACKET_META_COMMON 3 #define CAM_ISP_PACKET_META_DMI_LEFT 4 #define CAM_ISP_PACKET_META_DMI_RIGHT 5 #define CAM_ISP_PACKET_META_DMI_COMMON 6 #define CAM_ISP_PACKET_META_CLOCK 7 #define CAM_ISP_PACKET_META_CSID 8 #define CAM_ISP_PACKET_META_DUAL_CONFIG 9 #define CAM_ISP_PACKET_META_GENERIC_BLOB_LEFT 10 #define CAM_ISP_PACKET_META_GENERIC_BLOB_RIGHT 11 #define CAM_ISP_PACKET_META_GENERIC_BLOB_COMMON 12 /* DSP mode */ #define CAM_ISP_DSP_MODE_NONE 0 #define CAM_ISP_DSP_MODE_ONE_WAY 1 #define CAM_ISP_DSP_MODE_ROUND 2 /* ISP Generic Cmd Buffer Blob types */ #define CAM_ISP_GENERIC_BLOB_TYPE_HFR_CONFIG 0 #define CAM_ISP_GENERIC_BLOB_TYPE_CLOCK_CONFIG 1 #define CAM_ISP_GENERIC_BLOB_TYPE_BW_CONFIG 2 /* Query devices */ /** * struct cam_isp_dev_cap_info - A cap info for particular hw type * * @hw_type: Hardware type for the cap info * @reserved: reserved field for alignment * @hw_version: Hardware version * */ struct cam_isp_dev_cap_info { uint32_t hw_type; uint32_t reserved; struct cam_hw_version hw_version; }; /** * struct cam_isp_query_cap_cmd - ISP query device capability payload * * @device_iommu: returned iommu handles for device * @cdm_iommu: returned iommu handles for cdm * @num_dev: returned number of device capabilities * @reserved: reserved field for alignment * @dev_caps: returned device capability array * */ struct cam_isp_query_cap_cmd { struct cam_iommu_handle device_iommu; struct cam_iommu_handle cdm_iommu; int32_t num_dev; uint32_t reserved; struct cam_isp_dev_cap_info dev_caps[CAM_ISP_HW_MAX]; }; /* Acquire Device */ /** * struct cam_isp_out_port_info - An output port resource info * * @res_type: output resource type defined in file * cam_isp_vfe.h or cam_isp_ife.h * @format: output format of the resource * @wdith: output width in pixels * @height: output height in lines * @comp_grp_id: composite group id for the resource. * @split_point: split point in pixels for the dual VFE. * @secure_mode: flag to tell if output should be run in secure * mode or not. See cam_defs.h for definition * @reserved: reserved field for alignment * */ struct cam_isp_out_port_info { uint32_t res_type; uint32_t format; uint32_t width; uint32_t height; uint32_t comp_grp_id; uint32_t split_point; uint32_t secure_mode; uint32_t reserved; }; /** * struct cam_isp_in_port_info - An input port resource info * * @res_type: input resource type define in file * cam_isp_vfe.h or cam_isp_ife.h * @lane_type: lane type: c-phy or d-phy. * @lane_num: active lane number * @lane_cfg: lane configurations: 4 bits per lane * @vc: input virtual channel number * @dt: input data type number * @format: input format * @test_pattern: test pattern for the testgen * @usage_type: whether dual vfe is required * @left_start: left input start offset in pixels * @left_stop: left input stop offset in pixels * @left_width: left input width in pixels * @right_start: right input start offset in pixels. * Only for Dual VFE * @right_stop: right input stop offset in pixels. * Only for Dual VFE * @right_width: right input width in pixels. * Only for dual VFE * @line_start: top of the line number * @line_stop: bottome of the line number * @height: input height in lines * @pixel_clk; sensor output clock * @batch_size: batch size for HFR mode * @dsp_mode: DSP stream mode (Defines as CAM_ISP_DSP_MODE_*) * @hbi_cnt: HBI count for the camif input * @reserved: Reserved field for alignment * @num_out_res: number of the output resource associated * @data: payload that contains the output resources * */ struct cam_isp_in_port_info { uint32_t res_type; uint32_t lane_type; uint32_t lane_num; uint32_t lane_cfg; uint32_t vc; uint32_t dt; uint32_t format; uint32_t test_pattern; uint32_t usage_type; uint32_t left_start; uint32_t left_stop; uint32_t left_width; uint32_t right_start; uint32_t right_stop; uint32_t right_width; uint32_t line_start; uint32_t line_stop; uint32_t height; uint32_t pixel_clk; uint32_t batch_size; uint32_t dsp_mode; uint32_t hbi_cnt; uint32_t custom_csid; uint32_t reserved; uint32_t num_out_res; struct cam_isp_out_port_info data[1]; }; /** * struct cam_isp_resource - A resource bundle * * @resoruce_id: resource id for the resource bundle * @length: length of the while resource blob * @handle_type: type of the resource handle * @reserved: reserved field for alignment * @res_hdl: resource handle that points to the * resource array; * */ struct cam_isp_resource { uint32_t resource_id; uint32_t length; uint32_t handle_type; uint32_t reserved; uint64_t res_hdl; }; /** * struct cam_isp_port_hfr_config - HFR configuration for this port * * @resource_type: Resource type * @subsample_pattern: Subsample pattern. Used in HFR mode. It * should be consistent with batchSize and * CAMIF programming. * @subsample_period: Subsample period. Used in HFR mode. It * should be consistent with batchSize and * CAMIF programming. * @framedrop_pattern: Framedrop pattern * @framedrop_period: Framedrop period * @reserved: Reserved for alignment */ struct cam_isp_port_hfr_config { uint32_t resource_type; uint32_t subsample_pattern; uint32_t subsample_period; uint32_t framedrop_pattern; uint32_t framedrop_period; uint32_t reserved; } __attribute__((packed)); /** * struct cam_isp_resource_hfr_config - Resource HFR configuration * * @num_ports: Number of ports * @reserved: Reserved for alignment * @port_hfr_config: HFR configuration for each IO port */ struct cam_isp_resource_hfr_config { uint32_t num_ports; uint32_t reserved; struct cam_isp_port_hfr_config port_hfr_config[1]; } __attribute__((packed)); /** * struct cam_isp_dual_split_params - dual isp spilt parameters * * @split_point: Split point information x, where (0 < x < width) * left ISP's input ends at x + righ padding and * Right ISP's input starts at x - left padding * @right_padding: Padding added past the split point for left * ISP's input * @left_padding: Padding added before split point for right * ISP's input * @reserved: Reserved filed for alignment * */ struct cam_isp_dual_split_params { uint32_t split_point; uint32_t right_padding; uint32_t left_padding; uint32_t reserved; }; /** * struct cam_isp_dual_stripe_config - stripe config per bus client * * @offset: Start horizontal offset relative to * output buffer * In UBWC mode, this value indicates the H_INIT * value in pixel * @width: Width of the stripe in bytes * @tileconfig Ubwc meta tile config. Contain the partial * tile info * @port_id: port id of ISP output * */ struct cam_isp_dual_stripe_config { uint32_t offset; uint32_t width; uint32_t tileconfig; uint32_t port_id; }; /** * struct cam_isp_dual_config - dual isp configuration * * @num_ports Number of isp output ports * @reserved Reserved field for alignment * @split_params: Inpput split parameters * @stripes: Stripe information * */ struct cam_isp_dual_config { uint32_t num_ports; uint32_t reserved; struct cam_isp_dual_split_params split_params; struct cam_isp_dual_stripe_config stripes[1]; } __attribute__((packed)); /** * struct cam_isp_clock_config - Clock configuration * * @usage_type: Usage type (Single/Dual) * @num_rdi: Number of RDI votes * @left_pix_hz: Pixel Clock for Left ISP * @right_pix_hz: Pixel Clock for Right ISP, valid only if Dual * @rdi_hz: RDI Clock. ISP clock will be max of RDI and * PIX clocks. For a particular context which ISP * HW the RDI is allocated to is not known to UMD. * Hence pass the clock and let KMD decide. */ struct cam_isp_clock_config { uint32_t usage_type; uint32_t num_rdi; uint64_t left_pix_hz; uint64_t right_pix_hz; uint64_t rdi_hz[1]; } __attribute__((packed)); /** * struct cam_isp_bw_vote - Bandwidth vote information * * @resource_id: Resource ID * @reserved: Reserved field for alignment * @cam_bw_bps: Bandwidth vote for CAMNOC * @ext_bw_bps: Bandwidth vote for path-to-DDR after CAMNOC */ struct cam_isp_bw_vote { uint32_t resource_id; uint32_t reserved; uint64_t cam_bw_bps; uint64_t ext_bw_bps; } __attribute__((packed)); /** * struct cam_isp_bw_config - Bandwidth configuration * * @usage_type: Usage type (Single/Dual) * @num_rdi: Number of RDI votes * @left_pix_vote: Bandwidth vote for left ISP * @right_pix_vote: Bandwidth vote for right ISP * @rdi_vote: RDI bandwidth requirements */ struct cam_isp_bw_config { uint32_t usage_type; uint32_t num_rdi; struct cam_isp_bw_vote left_pix_vote; struct cam_isp_bw_vote right_pix_vote; struct cam_isp_bw_vote rdi_vote[1]; } __attribute__((packed)); #endif /* __UAPI_CAM_ISP_H__ */
39.160526
80
0.550769
2668bfbacd6d8db6b5e86fea28fe1b2f4ac6d201
724
h
C
src/platform.h
Celicath/FLA
188178309415c022b519b9699a1fba72859b10ac
[ "MIT" ]
null
null
null
src/platform.h
Celicath/FLA
188178309415c022b519b9699a1fba72859b10ac
[ "MIT" ]
null
null
null
src/platform.h
Celicath/FLA
188178309415c022b519b9699a1fba72859b10ac
[ "MIT" ]
null
null
null
#pragma once #include "stdio.h" #include "string.h" #include "stdlib.h" #include "fxcg\display.h" #include "fxcg\keyboard.h" #include "fxcg\file.h" #include "fxcg\registers.h" #include "fxcg\rtc.h" #include "fxcg\system.h" #include "fxcg\serial.h" #if TARGET_WINSIM #include <windows.h> #define LITTLE_E #else #define BIG_E #define override #define nullptr NULL #endif void DmaWaitNext(void); void DoDMAlcdNonblockStrip(unsigned y1, unsigned y2); #if !TARGET_WINSIM inline void* operator new(size_t size){ return malloc(size); } inline void operator delete(void* addr) { free(addr); } inline void* operator new[](size_t size) { return malloc(size); } inline void operator delete[](void* addr) { free(addr); } #endif
18.1
53
0.733425
2669b39f9c4cbbf1421c72b1e9d9c61c1174bd97
381
c
C
Chapter 09/Exercises/9.18/9.18.c
tambow44/KNKing_C_Modern_Approach
91f8c727b712da095ab6474b7b43bdf76d5faffd
[ "CC-BY-4.0" ]
4
2021-03-21T12:39:29.000Z
2022-02-28T09:51:06.000Z
Chapter 09/Exercises/9.18/9.18.c
tambow44/KNKing_C_Modern_Approach
91f8c727b712da095ab6474b7b43bdf76d5faffd
[ "CC-BY-4.0" ]
null
null
null
Chapter 09/Exercises/9.18/9.18.c
tambow44/KNKing_C_Modern_Approach
91f8c727b712da095ab6474b7b43bdf76d5faffd
[ "CC-BY-4.0" ]
1
2021-10-03T01:14:01.000Z
2021-10-03T01:14:01.000Z
#include <stdio.h> int gcd(int m, int n) { return (n == 0) ? m : gcd(n, m % n) ; } /* int gcd(int m, int n) { int r; while (n != 0) { r = m % n; m = n; n = r; } return m; } */ int main(void) { int m, n, r; printf("Enter two integers: "); scanf("%d %d", &m, &n); printf("Greatest common divisor: %d\n", gcd (m, n)); return 0; }
11.90625
55
0.446194
266c7be5e519460b895f86e618820e29c00e84ed
1,308
h
C
HAL_AD7689.h
taogashi/AHRS
8e2db0d048830b06576e8a61182e2bef5d65d557
[ "BSD-3-Clause" ]
3
2016-06-17T13:01:50.000Z
2018-09-07T12:58:32.000Z
HAL_AD7689.h
taogashi/AHRS
8e2db0d048830b06576e8a61182e2bef5d65d557
[ "BSD-3-Clause" ]
null
null
null
HAL_AD7689.h
taogashi/AHRS
8e2db0d048830b06576e8a61182e2bef5d65d557
[ "BSD-3-Clause" ]
5
2016-08-02T06:38:57.000Z
2021-08-06T01:38:46.000Z
#ifndef _HAL_AD7689_H_ #define _HAL_AD7689_H_ #ifdef __cplusplus extern "C" { #endif /* Includes */ #include "stm32f10x.h" #define AD7689_SPI_CS_HIGH() GPIO_SetBits(AD7689_SPI_NSS_Pin_Port,AD7689_SPI_NSS_Pin) #define AD7689_SPI_CS_LOW() GPIO_ResetBits(AD7689_SPI_NSS_Pin_Port,AD7689_SPI_NSS_Pin) #define AD7689_SPI SPI2 #define AD7689_SPI_RCC_Periph RCC_APB1Periph_SPI2 #define AD7689_SPI_RCC_Port RCC_APB2Periph_GPIOB #define AD7689_SPI_NSS_Pin_Port GPIOA #define AD7689_SPI_NSS_Pin GPIO_Pin_15 #define AD7689_SPI_NSS_Pin_Source GPIO_PinSource15 #define AD7689_SPI_NSS_Pin_RCC_Port RCC_APB2Periph_GPIOA //#define AD7689_SPI_NSS_Pin_Port GPIOB //#define AD7689_SPI_NSS_Pin GPIO_Pin_12 //#define AD7689_SPI_NSS_Pin_Source GPIO_PinSource12 #define AD7689_SPI_CLK_Pin_Port GPIOB #define AD7689_SPI_CLK_Pin GPIO_Pin_13 #define AD7689_SPI_CLK_Pin_Source GPIO_PinSource13 #define AD7689_SPI_MISO_Pin_Port GPIOB #define AD7689_SPI_MISO_Pin GPIO_Pin_14 #define AD7689_SPI_MISO_Pin_Source GPIO_PinSource14 #define AD7689_SPI_MOSI_Pin_Port GPIOB #define AD7689_SPI_MOSI_Pin GPIO_Pin_15 #define AD7689_SPI_MOSI_Pin_Source GPIO_PinSource15 #define AD7689_SPI_BaudRatePrescaler SPI_BaudRatePrescaler_32 #endif
31.142857
86
0.811162
266d0cd2f6631f06b056594f9fdc33f1e53dfee1
2,818
h
C
Win32.Carberp/all source/BJWJ/include/thebes/gfxPDFSurface.h
010001111/Vx-Suites
6b4b90a60512cce48aa7b87aec5e5ac1c4bb9a79
[ "MIT" ]
2
2021-02-04T06:47:45.000Z
2021-07-28T10:02:10.000Z
Win32.Carberp/all source/BlackJoeWhiteJoe/include/thebes/gfxPDFSurface.h
010001111/Vx-Suites
6b4b90a60512cce48aa7b87aec5e5ac1c4bb9a79
[ "MIT" ]
null
null
null
Win32.Carberp/all source/BlackJoeWhiteJoe/include/thebes/gfxPDFSurface.h
010001111/Vx-Suites
6b4b90a60512cce48aa7b87aec5e5ac1c4bb9a79
[ "MIT" ]
null
null
null
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- * ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla 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.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is Mozilla Foundation Code. * * The Initial Developer of the Original Code is Mozilla Foundation. * Portions created by the Initial Developer are Copyright (C) 2006 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Stuart Parmenter <pavlov@pavlov.net> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #ifndef GFX_PDFSURFACE_H #define GFX_PDFSURFACE_H #include "gfxASurface.h" #include "gfxContext.h" /* for the output stream */ #include "nsCOMPtr.h" #include "nsIOutputStream.h" class THEBES_API gfxPDFSurface : public gfxASurface { public: gfxPDFSurface(nsIOutputStream *aStream, const gfxSize& aSizeInPoints); virtual ~gfxPDFSurface(); virtual nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName); virtual nsresult EndPrinting(); virtual nsresult AbortPrinting(); virtual nsresult BeginPage(); virtual nsresult EndPage(); virtual void Finish(); void SetDPI(double x, double y); void GetDPI(double *xDPI, double *yDPI); // this is in points! const gfxSize& GetSize() const { return mSize; } virtual PRInt32 GetDefaultContextFlags() const { return gfxContext::FLAG_DISABLE_SNAPPING; } private: nsCOMPtr<nsIOutputStream> mStream; double mXDPI; double mYDPI; gfxSize mSize; }; #endif /* GFX_PDFSURFACE_H */
37.078947
96
0.726047
266df14da2d5ee4dcc6a8fd0111382ed16cc036a
8,274
c
C
drivers/media/platform/atmel/atmel-sama5d2-isc.c
xqdzn/linux-bpi-p2z-dev
fc302d86fb16fff3a25894efd3d5dd9e8e379a82
[ "MIT" ]
null
null
null
drivers/media/platform/atmel/atmel-sama5d2-isc.c
xqdzn/linux-bpi-p2z-dev
fc302d86fb16fff3a25894efd3d5dd9e8e379a82
[ "MIT" ]
null
null
null
drivers/media/platform/atmel/atmel-sama5d2-isc.c
xqdzn/linux-bpi-p2z-dev
fc302d86fb16fff3a25894efd3d5dd9e8e379a82
[ "MIT" ]
null
null
null
// SPDX-License-Identifier: GPL-2.0 /* * Microchip Image Sensor Controller (ISC) driver * * Copyright (C) 2016-2019 Microchip Technology, Inc. * * Author: Songjun Wu * Author: Eugen Hristev <eugen.hristev@microchip.com> * * * Sensor-->PFE-->WB-->CFA-->CC-->GAM-->CSC-->CBC-->SUB-->RLP-->DMA * * ISC video pipeline integrates the following submodules: * PFE: Parallel Front End to sample the camera sensor input stream * WB: Programmable white balance in the Bayer domain * CFA: Color filter array interpolation module * CC: Programmable color correction * GAM: Gamma correction * CSC: Programmable color space conversion * CBC: Contrast and Brightness control * SUB: This module performs YCbCr444 to YCbCr420 chrominance subsampling * RLP: This module performs rounding, range limiting * and packing of the incoming data */ #include <linux/clk.h> #include <linux/clkdev.h> #include <linux/clk-provider.h> #include <linux/delay.h> #include <linux/interrupt.h> #include <linux/math64.h> #include <linux/module.h> #include <linux/of.h> #include <linux/of_graph.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> #include <linux/videodev2.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> #include <media/v4l2-event.h> #include <media/v4l2-image-sizes.h> #include <media/v4l2-ioctl.h> #include <media/v4l2-fwnode.h> #include <media/v4l2-subdev.h> #include <media/videobuf2-dma-contig.h> #include "atmel-isc-regs.h" #include "atmel-isc.h" #define ISC_MAX_SUPPORT_WIDTH 2592 #define ISC_MAX_SUPPORT_HEIGHT 1944 #define ISC_CLK_MAX_DIV 255 static int isc_parse_dt(struct device *dev, struct isc_device *isc) { struct device_node *np = dev->of_node; struct device_node *epn = NULL, *rem; struct isc_subdev_entity *subdev_entity; unsigned int flags; int ret; INIT_LIST_HEAD(&isc->subdev_entities); while (1) { struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type = 0 }; epn = of_graph_get_next_endpoint(np, epn); if (!epn) return 0; rem = of_graph_get_remote_port_parent(epn); if (!rem) { dev_notice(dev, "Remote device at %pOF not found\n", epn); continue; } ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(epn), &v4l2_epn); if (ret) { of_node_put(rem); ret = -EINVAL; dev_err(dev, "Could not parse the endpoint\n"); break; } subdev_entity = devm_kzalloc(dev, sizeof(*subdev_entity), GFP_KERNEL); if (!subdev_entity) { of_node_put(rem); ret = -ENOMEM; break; } /* asd will be freed by the subsystem once it's added to the * notifier list */ subdev_entity->asd = kzalloc(sizeof(*subdev_entity->asd), GFP_KERNEL); if (!subdev_entity->asd) { of_node_put(rem); ret = -ENOMEM; break; } flags = v4l2_epn.bus.parallel.flags; if (flags & V4L2_MBUS_HSYNC_ACTIVE_LOW) subdev_entity->pfe_cfg0 = ISC_PFE_CFG0_HPOL_LOW; if (flags & V4L2_MBUS_VSYNC_ACTIVE_LOW) subdev_entity->pfe_cfg0 |= ISC_PFE_CFG0_VPOL_LOW; if (flags & V4L2_MBUS_PCLK_SAMPLE_FALLING) subdev_entity->pfe_cfg0 |= ISC_PFE_CFG0_PPOL_LOW; if (v4l2_epn.bus_type == V4L2_MBUS_BT656) subdev_entity->pfe_cfg0 |= ISC_PFE_CFG0_CCIR_CRC | ISC_PFE_CFG0_CCIR656; subdev_entity->asd->match_type = V4L2_ASYNC_MATCH_FWNODE; subdev_entity->asd->match.fwnode = of_fwnode_handle(rem); list_add_tail(&subdev_entity->list, &isc->subdev_entities); } of_node_put(epn); return ret; } static int atmel_isc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct isc_device *isc; struct resource *res; void __iomem *io_base; struct isc_subdev_entity *subdev_entity; int irq; int ret; isc = devm_kzalloc(dev, sizeof(*isc), GFP_KERNEL); if (!isc) return -ENOMEM; platform_set_drvdata(pdev, isc); isc->dev = dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); io_base = devm_ioremap_resource(dev, res); if (IS_ERR(io_base)) return PTR_ERR(io_base); isc->regmap = devm_regmap_init_mmio(dev, io_base, &isc_regmap_config); if (IS_ERR(isc->regmap)) { ret = PTR_ERR(isc->regmap); dev_err(dev, "failed to init register map: %d\n", ret); return ret; } irq = platform_get_irq(pdev, 0); if (irq < 0) { ret = irq; dev_err(dev, "failed to get irq: %d\n", ret); return ret; } ret = devm_request_irq(dev, irq, isc_interrupt, 0, ATMEL_ISC_NAME, isc); if (ret < 0) { dev_err(dev, "can't register ISR for IRQ %u (ret=%i)\n", irq, ret); return ret; } ret = isc_pipeline_init(isc); if (ret) return ret; isc->hclock = devm_clk_get(dev, "hclock"); if (IS_ERR(isc->hclock)) { ret = PTR_ERR(isc->hclock); dev_err(dev, "failed to get hclock: %d\n", ret); return ret; } ret = clk_prepare_enable(isc->hclock); if (ret) { dev_err(dev, "failed to enable hclock: %d\n", ret); return ret; } ret = isc_clk_init(isc); if (ret) { dev_err(dev, "failed to init isc clock: %d\n", ret); goto unprepare_hclk; } isc->ispck = isc->isc_clks[ISC_ISPCK].clk; ret = clk_prepare_enable(isc->ispck); if (ret) { dev_err(dev, "failed to enable ispck: %d\n", ret); goto unprepare_hclk; } /* ispck should be greater or equal to hclock */ ret = clk_set_rate(isc->ispck, clk_get_rate(isc->hclock)); if (ret) { dev_err(dev, "failed to set ispck rate: %d\n", ret); goto unprepare_clk; } ret = v4l2_device_register(dev, &isc->v4l2_dev); if (ret) { dev_err(dev, "unable to register v4l2 device.\n"); goto unprepare_clk; } ret = isc_parse_dt(dev, isc); if (ret) { dev_err(dev, "fail to parse device tree\n"); goto unregister_v4l2_device; } if (list_empty(&isc->subdev_entities)) { dev_err(dev, "no subdev found\n"); ret = -ENODEV; goto unregister_v4l2_device; } list_for_each_entry(subdev_entity, &isc->subdev_entities, list) { v4l2_async_notifier_init(&subdev_entity->notifier); ret = v4l2_async_notifier_add_subdev(&subdev_entity->notifier, subdev_entity->asd); if (ret) { fwnode_handle_put(subdev_entity->asd->match.fwnode); kfree(subdev_entity->asd); goto cleanup_subdev; } subdev_entity->notifier.ops = &isc_async_ops; ret = v4l2_async_notifier_register(&isc->v4l2_dev, &subdev_entity->notifier); if (ret) { dev_err(dev, "fail to register async notifier\n"); goto cleanup_subdev; } if (video_is_registered(&isc->video_dev)) break; } pm_runtime_set_active(dev); pm_runtime_enable(dev); pm_request_idle(dev); return 0; cleanup_subdev: isc_subdev_cleanup(isc); unregister_v4l2_device: v4l2_device_unregister(&isc->v4l2_dev); unprepare_clk: clk_disable_unprepare(isc->ispck); unprepare_hclk: clk_disable_unprepare(isc->hclock); isc_clk_cleanup(isc); return ret; } static int atmel_isc_remove(struct platform_device *pdev) { struct isc_device *isc = platform_get_drvdata(pdev); pm_runtime_disable(&pdev->dev); isc_subdev_cleanup(isc); v4l2_device_unregister(&isc->v4l2_dev); clk_disable_unprepare(isc->ispck); clk_disable_unprepare(isc->hclock); isc_clk_cleanup(isc); return 0; } static int __maybe_unused isc_runtime_suspend(struct device *dev) { struct isc_device *isc = dev_get_drvdata(dev); clk_disable_unprepare(isc->ispck); clk_disable_unprepare(isc->hclock); return 0; } static int __maybe_unused isc_runtime_resume(struct device *dev) { struct isc_device *isc = dev_get_drvdata(dev); int ret; ret = clk_prepare_enable(isc->hclock); if (ret) return ret; ret = clk_prepare_enable(isc->ispck); if (ret) clk_disable_unprepare(isc->hclock); return ret; } static const struct dev_pm_ops atmel_isc_dev_pm_ops = { SET_RUNTIME_PM_OPS(isc_runtime_suspend, isc_runtime_resume, NULL) }; static const struct of_device_id atmel_isc_of_match[] = { { .compatible = "atmel,sama5d2-isc" }, { } }; MODULE_DEVICE_TABLE(of, atmel_isc_of_match); static struct platform_driver atmel_isc_driver = { .probe = atmel_isc_probe, .remove = atmel_isc_remove, .driver = { .name = ATMEL_ISC_NAME, .pm = &atmel_isc_dev_pm_ops, .of_match_table = of_match_ptr(atmel_isc_of_match), }, }; module_platform_driver(atmel_isc_driver); MODULE_AUTHOR("Songjun Wu"); MODULE_DESCRIPTION("The V4L2 driver for Atmel-ISC"); MODULE_LICENSE("GPL v2"); MODULE_SUPPORTED_DEVICE("video");
23.707736
73
0.714769
266f276feec6a12396f39542bdc8dfd773b63d2a
2,634
h
C
src/backend/gporca/libgpopt/include/gpopt/operators/CPhysicalLeftAntiSemiHashJoinNotIn.h
uglthinx/gpdb
ebe48bc7313d39f63b6ab668cb08908a698314ed
[ "PostgreSQL", "Apache-2.0" ]
null
null
null
src/backend/gporca/libgpopt/include/gpopt/operators/CPhysicalLeftAntiSemiHashJoinNotIn.h
uglthinx/gpdb
ebe48bc7313d39f63b6ab668cb08908a698314ed
[ "PostgreSQL", "Apache-2.0" ]
16
2020-10-21T18:37:47.000Z
2021-01-13T01:01:15.000Z
src/backend/gporca/libgpopt/include/gpopt/operators/CPhysicalLeftAntiSemiHashJoinNotIn.h
uglthinx/gpdb
ebe48bc7313d39f63b6ab668cb08908a698314ed
[ "PostgreSQL", "Apache-2.0" ]
null
null
null
//--------------------------------------------------------------------------- // Greenplum Database // Copyright (C) 2013 EMC Corp. // // @filename: // CPhysicalLeftAntiSemiHashJoinNotIn.h // // @doc: // Left anti semi hash join operator with NotIn semantics //--------------------------------------------------------------------------- #ifndef GPOPT_CPhysicalLeftAntiSemiHashJoinNotIn_H #define GPOPT_CPhysicalLeftAntiSemiHashJoinNotIn_H #include "gpos/base.h" #include "gpopt/operators/CPhysicalLeftAntiSemiHashJoin.h" namespace gpopt { //--------------------------------------------------------------------------- // @class: // CPhysicalLeftAntiSemiHashJoinNotIn // // @doc: // Left anti semi hash join operator with NotIn semantics // //--------------------------------------------------------------------------- class CPhysicalLeftAntiSemiHashJoinNotIn : public CPhysicalLeftAntiSemiHashJoin { private: // private copy ctor CPhysicalLeftAntiSemiHashJoinNotIn( const CPhysicalLeftAntiSemiHashJoinNotIn &); public: // ctor CPhysicalLeftAntiSemiHashJoinNotIn(CMemoryPool *mp, CExpressionArray *pdrgpexprOuterKeys, CExpressionArray *pdrgpexprInnerKeys, IMdIdArray *hash_opfamilies = NULL); // ident accessors virtual EOperatorId Eopid() const { return EopPhysicalLeftAntiSemiHashJoinNotIn; } // return a string for operator name virtual const CHAR * SzId() const { return "CPhysicalLeftAntiSemiHashJoinNotIn"; } //------------------------------------------------------------------------------------- // Required Plan Properties //------------------------------------------------------------------------------------- // compute required distribution of the n-th child virtual CDistributionSpec *PdsRequired(CMemoryPool *mp, CExpressionHandle &exprhdl, CDistributionSpec *pdsRequired, ULONG child_index, CDrvdPropArray *pdrgpdpCtxt, ULONG ulOptReq) const; //------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------- // conversion function static CPhysicalLeftAntiSemiHashJoinNotIn * PopConvert(COperator *pop) { GPOS_ASSERT(EopPhysicalLeftAntiSemiHashJoinNotIn == pop->Eopid()); return dynamic_cast<CPhysicalLeftAntiSemiHashJoinNotIn *>(pop); } }; // class CPhysicalLeftAntiSemiHashJoinNotIn } // namespace gpopt #endif // !GPOPT_CPhysicalLeftAntiSemiHashJoinNotIn_H // EOF
30.275862
88
0.534928
26700b55b1100ef07d983244367930ff885c660d
244
h
C
Example/Pods/MKCustomUIModule/MKCustomUIModule/Classes/View/MKSlider/MKSlider.h
BeaconX-Pro/IOS
561f460c762f2a339033d03c0352154821a09dbb
[ "MIT" ]
null
null
null
Example/Pods/MKCustomUIModule/MKCustomUIModule/Classes/View/MKSlider/MKSlider.h
BeaconX-Pro/IOS
561f460c762f2a339033d03c0352154821a09dbb
[ "MIT" ]
3
2020-11-19T12:04:40.000Z
2021-10-10T10:14:57.000Z
Example/Pods/MKCustomUIModule/MKCustomUIModule/Classes/View/MKSlider/MKSlider.h
BeaconX-Pro/IOS
561f460c762f2a339033d03c0352154821a09dbb
[ "MIT" ]
1
2020-02-17T16:06:51.000Z
2020-02-17T16:06:51.000Z
// // MKSlider.h // mokoLibrary_Example // // Created by aa on 2020/12/16. // Copyright © 2020 Chengang. All rights reserved. // #import <UIKit/UIKit.h> NS_ASSUME_NONNULL_BEGIN @interface MKSlider : UISlider @end NS_ASSUME_NONNULL_END
13.555556
51
0.721311
26727fd47b68760ce145c540c305ed0b019e87b1
246
c
C
roxe.cdt/libraries/libc/musl/src/math/remainderf.c
APFDev/actc
be5c1c0539d30a3745a725b0027767448ef8e1f6
[ "MIT" ]
12
2018-03-15T06:28:41.000Z
2021-05-21T06:29:52.000Z
roxe.cdt/libraries/libc/musl/src/math/remainderf.c
APFDev/actc
be5c1c0539d30a3745a725b0027767448ef8e1f6
[ "MIT" ]
2
2018-03-09T20:52:26.000Z
2021-09-28T18:41:03.000Z
roxe.cdt/libraries/libc/musl/src/math/remainderf.c
APFDev/actc
be5c1c0539d30a3745a725b0027767448ef8e1f6
[ "MIT" ]
49
2018-03-08T05:38:47.000Z
2020-12-03T08:45:09.000Z
#include <math.h> #include "libc.h" float remainderf(float x, float y) { int q; return remquof(x, y, &q); } #ifdef __APPLE__ float dremf(float x, float y) { return remainderf(x,y); } #else weak_alias(remainderf, dremf); #endif
14.470588
34
0.646341
26736ac9fa05c2bf470f4fad94480e3d2a8ab103
1,208
h
C
src/platform/win/win_volume_event_handler.h
captainurist/qnob
3cae9e17f5c266d9583d2e90253de65514d08a0d
[ "MIT" ]
1
2021-05-16T03:55:15.000Z
2021-05-16T03:55:15.000Z
src/platform/win/win_volume_event_handler.h
captainurist/qnob
3cae9e17f5c266d9583d2e90253de65514d08a0d
[ "MIT" ]
null
null
null
src/platform/win/win_volume_event_handler.h
captainurist/qnob
3cae9e17f5c266d9583d2e90253de65514d08a0d
[ "MIT" ]
null
null
null
#pragma once #include <endpointvolume.h> #include <mmdeviceapi.h> #include <QtCore/QObject> class WinVolumeEventHandler : public QObject, public IAudioEndpointVolumeCallback, public IMMNotificationClient { Q_OBJECT public: WinVolumeEventHandler(const GUID& localEventGuid); /* IUnknown. */ IFACEMETHODIMP QueryInterface(REFIID iid, void** object) override; IFACEMETHODIMP_(ULONG) AddRef() override; IFACEMETHODIMP_(ULONG) Release() override; /* IAudioEndpointVolumeCallback. */ IFACEMETHODIMP OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA data) override; /* IMMNotificationClient. */ IFACEMETHODIMP OnDeviceStateChanged(LPCWSTR pwstrDeviceId, DWORD dwNewState) override; IFACEMETHODIMP OnDeviceAdded(LPCWSTR pwstrDeviceId) override; IFACEMETHODIMP OnDeviceRemoved(LPCWSTR pwstrDeviceId) override; IFACEMETHODIMP OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR pwstrDefaultDeviceId) override; IFACEMETHODIMP OnPropertyValueChanged(LPCWSTR pwstrDeviceId, const PROPERTYKEY key) override; signals: void defaultDeviceChanged(); void volumeChangedExternally(); private: ULONG m_refCount = 1; GUID m_localEventGuid; };
26.844444
113
0.778974
2674292229908ee5e8f7570fc90512d3e43761b7
1,257
h
C
examples/http_get_mbedtls/include/mbedtls/config.h
JDRobotter/esp-open-rtos
1f6261887fb92936a8e5ea305c7d634b5b189534
[ "BSD-3-Clause" ]
1,510
2015-06-03T06:43:09.000Z
2022-03-12T01:57:41.000Z
examples/http_get_mbedtls/include/mbedtls/config.h
JDRobotter/esp-open-rtos
1f6261887fb92936a8e5ea305c7d634b5b189534
[ "BSD-3-Clause" ]
640
2015-06-02T21:57:36.000Z
2022-03-30T08:01:10.000Z
examples/http_get_mbedtls/include/mbedtls/config.h
JDRobotter/esp-open-rtos
1f6261887fb92936a8e5ea305c7d634b5b189534
[ "BSD-3-Clause" ]
608
2015-06-15T20:39:58.000Z
2022-03-31T09:24:07.000Z
/* Special mbedTLS config file for http_get_mbedtls example, overrides supported cipher suite list. Overriding the set of cipher suites saves small amounts of ROM and RAM, and is a good practice in general if you know what server(s) you want to connect to. However it's extra important here because the howsmyssl API sends back the list of ciphers we send it as a JSON list in the, and we only have a 4096kB receive buffer. If the server supported maximum fragment length option then we wouldn't have this problem either, but we do so this is a good workaround. The ciphers chosen below are common ECDHE ciphers, the same ones Firefox uses when connecting to a TLSv1.2 server. */ #ifndef MBEDTLS_CONFIG_H /* include_next picks up default config from extras/mbedtls/include/mbedtls/config.h */ #include_next<mbedtls/config.h> #define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA /* uncomment next line to include debug output from example */ //#define MBEDTLS_DEBUG_C #endif
44.892857
302
0.81782
2674382c2cebbef9c634c21ac473f23f04bd8509
2,154
h
C
aclswarm/include/aclswarm/localization_ros.h
mit-acl/aclswarm
2a4d1e0962a3e3bbc2568172f33f5b466e296647
[ "MIT" ]
28
2020-03-12T03:25:30.000Z
2022-02-21T07:22:44.000Z
aclswarm/include/aclswarm/localization_ros.h
mit-acl/aclswarm
2a4d1e0962a3e3bbc2568172f33f5b466e296647
[ "MIT" ]
2
2020-05-07T18:13:58.000Z
2021-01-07T20:26:00.000Z
aclswarm/include/aclswarm/localization_ros.h
mit-acl/aclswarm
2a4d1e0962a3e3bbc2568172f33f5b466e296647
[ "MIT" ]
10
2020-04-10T02:14:39.000Z
2021-01-17T14:00:53.000Z
/** * @file localization_ros.h * @brief ROS wrapper for localization components of aclswarm * @author Parker Lusk <parkerclusk@gmail.com> * @date 18 Oct 2019 */ #pragma once #include <map> #include <memory> #include <string> #include <vector> #include <Eigen/Dense> #include <ros/ros.h> #include <std_msgs/UInt8MultiArray.h> #include <std_msgs/MultiArrayDimension.h> #include <snapstack_msgs/State.h> #include <aclswarm_msgs/Formation.h> #include <aclswarm_msgs/VehicleEstimates.h> #include "aclswarm/vehicle_tracker.h" #include "aclswarm/utils.h" namespace acl { namespace aclswarm { class LocalizationROS { public: LocalizationROS(const ros::NodeHandle nh, const ros::NodeHandle nhp); ~LocalizationROS() = default; private: ros::NodeHandle nh_, nhp_; ros::Timer tim_tracking_; ros::Subscriber sub_formation_, sub_assignment_, sub_state_; ros::Publisher pub_tracker_; uint8_t n_; ///< number of vehicles in swarm uint8_t vehid_; ///< ID of vehicle (index in veh named list) std::string vehname_; ///< name of the vehicle this node is running on std::vector<std::string> vehs_; ///< list of all vehicles in swarm /// \brief Modules std::unique_ptr<VehicleTracker> tracker_; /// \brief Internal States std::map<int, ros::Subscriber> vehsubs_; ///< subscribers keyed by vehid AdjMat adjmat_; ///< current adjacency matrix for formation AssignmentPerm P_; ///< nxn assignment permutation (P: vehid --> formpt) AssignmentPerm Pt_; ///< nxn inv assign. permutation (Pt: formpt --> vehid) /// \brief Parameters double tracking_dt_; ///< period of mutual localization task void init(); void connectToNeighbors(); /// \brief ROS callback handlers void formationCb(const aclswarm_msgs::FormationConstPtr& msg); void assignmentCb(const std_msgs::UInt8MultiArrayConstPtr& msg); void stateCb(const snapstack_msgs::StateConstPtr& msg); void vehicleTrackerCb(const aclswarm_msgs::VehicleEstimatesConstPtr& msg, int vehid); void trackingCb(const ros::TimerEvent& event); }; } // ns aclswarm } // ns acl
28.72
79
0.7052
267546e9c1fda1a77a31cd99db819b996246b6bd
872
h
C
System/Library/PrivateFrameworks/TextInput.framework/TIStatisticChangeCache.h
lechium/tvOS142Headers
c7696f6d760e4822f61b9f2c2adcd18749700fda
[ "MIT" ]
1
2020-11-11T06:05:23.000Z
2020-11-11T06:05:23.000Z
System/Library/PrivateFrameworks/TextInput.framework/TIStatisticChangeCache.h
lechium/tvOS142Headers
c7696f6d760e4822f61b9f2c2adcd18749700fda
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/TextInput.framework/TIStatisticChangeCache.h
lechium/tvOS142Headers
c7696f6d760e4822f61b9f2c2adcd18749700fda
[ "MIT" ]
null
null
null
/* * This header is generated by classdump-dyld 1.5 * on Tuesday, November 10, 2020 at 10:11:42 PM Mountain Standard Time * Operating System: Version 14.2 (Build 18K57) * Image Source: /System/Library/PrivateFrameworks/TextInput.framework/TextInput * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley. */ @class NSMutableDictionary; @interface TIStatisticChangeCache : NSObject { NSMutableDictionary* _cacheWithoutInputMode; NSMutableDictionary* _cacheWithInputMode; } +(id)sharedInstance; -(id)init; -(id)flush; -(void)addValue:(int)arg1 toStatisticWithName:(id)arg2 andInputMode:(id)arg3 ; -(void)addValue:(int)arg1 toStatisticWithName:(id)arg2 inCache:(id)arg3 ; @end
34.88
130
0.655963
2676179d246db1cc0d9f4cb25ad252229cba7488
15,363
h
C
lib/MuM/MuVoice.h
LucianoPC/music_generator
6a759d2dad5d7735475c4f037d5446e6cb6fd586
[ "MIT" ]
null
null
null
lib/MuM/MuVoice.h
LucianoPC/music_generator
6a759d2dad5d7735475c4f037d5446e6cb6fd586
[ "MIT" ]
7
2017-05-30T11:52:55.000Z
2017-05-30T14:42:48.000Z
lib/MuM/MuVoice.h
LucianoPC/music_generator
6a759d2dad5d7735475c4f037d5446e6cb6fd586
[ "MIT" ]
null
null
null
//********************************************* //***************** NCM-UnB ******************* //******** (c) Carlos Eduardo Mello *********** //********************************************* // This softwre may be freely reproduced, // copied, modified, and reused, as long as // it retains, in all forms, the above credits. //********************************************* /** @file MuVoice.h * * @brief Voice Class Interface * * @author Carlos Eduardo Mello * @date 3/5/2009 * * @details * * a voice represents an individual sequence * of notes inside a music material object, which * in turn may contain any number of voices * * Besides the notes themselves, the voice contains * information about instrument choice: * an instrument number and an integer accounting for the * number of parameters required for each note in the sequence * to be correctly rendered by the referred instrument. * As explainned in note.h, the parameters are all floats * and should be contained in an MuParamBlock within each note * * Optionally, the voice may also contain a string with * the instrument's code, for Csound rendering. * **/ #ifndef _MU_VOICE_H_ #define _MU_VOICE_H_ #include "MuNote.h" const short FIRST_NOTE_INDEX = 0; // Sorting fields const short SORT_FIELD_INSTR = 0; const short SORT_FIELD_START = 1; const short SORT_FIELD_DUR = 2; const short SORT_FIELD_PITCH = 3; const short SORT_FIELD_AMP = 4; /** * @class MuVoice * * @brief Voice Class * * @details * An MuVoice object represents an individual sequence of notes inside an MuMaterial * (music material) object, which in turn may contain any number of voices. The voice, as * defined here, is analogous to a part in a musical score, but it may contain any number of * simultaneous notes. Therefore an MuVoice can contain the entire composition and may be * the only voice within a given material (see MuMaterial below). Tipically, however, voices * are used to store the notes to be played by individual instruments. Thus, besides the notes * themselves, a voice contains information about instrument choice -- an instrument number * and an integer accounting for the number of parameters required for each note in the * sequence, so that these can be correctly rendered by the referred instrument. As explained * in MuNote.h, parameters other than the ones directly defined in the note class, are always * floats and should be contained in an MuParamBlock within each note. * * The MuVoice class is an internal implementation detail and should not be used directly by * user code. It is documented here in oder to facilitate comprehension of MuM Library and * maintenance of internal code. All the voice functionality is acessessible through the * MuMaterial's interface. * **/ class MuVoice { private: MuNote * noteList; long numOfNotes; uShort instrumentNumber; uShort numOfParameters; string instrumentCode; public: // Constructors /** * @brief Default Constructor * * @details * This constructor sets internal voice fields to reasonable default values * **/ MuVoice(void); /** * @brief Copy Constructor * * @details * This constructor copies input voice's data to internal * member fields, performing deep copies when necessary * * @param * inVoice - voice object being copied * **/ MuVoice(const MuVoice & inVoice); /** * @brief Destructor Constructor * * @details * This constructor releases dynamically allocated memory * **/ ~MuVoice(void); /** * @brief Assignment Operator * * @details * Copies content of assigned object to local voice, field by field, * performing deep copy when necessary * * @param * inVoice - voice object being assigned * * @return * MuVoice& - the resulting voice * **/ MuVoice & operator=(const MuVoice & inVoice); /** * @brief Equality Operator * * @details * Compares the voice's content to that of input object. Returns true * if every field contains the same values. * * @param * inVoice - voice object being compared * * @return * <ul> * <li> true - if objects are identical * <li> false - otherwise * </ul> **/ bool operator==(const MuVoice & inVoice); /** * @brief Inequality Operator * * @details * Compares the voice's content to that of input object. Returns true * if any field contains a different value. * * @param * inVoice - voice object being compared * * @return * <ul> * <li> true - if any field is different * <li> false - otherwise * </ul> **/ bool operator!=(const MuVoice & inVoice); /** * @brief Clears internal members * * @details * Clear() resets voice members to default values and * releases note list * **/ void Clear(void); /** * @brief Returns number of notes * * @details * NumberOfNotes() returns the number of note objects contained in * the voice's internal note list. User code should call it before * attempting to access the voice's notes * * @return * long - number of notes in voice * **/ long NumberOfNotes(void) const; /** * * @brief returns starting point of voice in time * * @details * This method returns the start time for first note in note list * This works correctly as long as note list is allways ordered. * * @return * float - start time in seconds; zero if voice is empty. * **/ float Start(void); /** * * @brief returns ending point of voice in time * * @details * This method returns the end time for last note in note list * This works correctly as long as note list is allways ordered. * * @return * float - end time in seconds; zero if voice is empty * **/ float End(void); /** * * @brief returns total duration of voice * * @details * This method returns the time length between the start of first note * and the end of last note in voice's note list. * This works correctly as long as note list is allways ordered. * * @return * float - duration in seconds; zero if voice is empty. * **/ float Dur(void); /** * * @brief Adds note to voice's note list * * @details * This method adds input note to the voice's note list * Notes are inserted in time order * * @param * inNote (MuNote) - note to be added to voice * * @return * MuError * <ul> * <li> MuERROR_NONE upon success * <li> MuERROR_INSUF_MEM if memoery allocation fails * </ul> * **/ MuError AddNote(MuNote inNote); /** * * @brief places the new note at the end of voice's note list * * @details * This method places a copy of 'inNote' at the end of the * voice's note list, regardless of the note's start time * * @param * inNote (MuNote) - note to be included in voice * * @return * MuError * <ul> * <li> MuERROR_NONE upon success * <li> MuERROR_INSUF_MEM if memoery allocation fails * </ul> * **/ MuError IncludeNote(MuNote inNote); /** * * @brief Removes note from voice's note list * * @details * This method removes requested note from the voice's note list * If voice is empty, or if requested note index doesn't exist * in voice, RemoveNote() returns an error. Call NumberOfNotes() * before, in order to observe valid voice bounds. * * @attention * After a call to RemoveNote(), other notes may change indexes, so * placing this call in a sequential loop to remove notes may not work; * For example in order to remove all notes in a voice, user code would * need to either call RemoveNote(0) for NumberOfNotes() times, or do * the same calling to RemoveLastNote(); although in this particular case * it may be more efficient to call Clear(). * * @param * num (long) - index of note to be removed * * @return * MuError * <ul> * <li> MuERROR_NONE upon success * <li> MuERROR_NOTE_LIST_IS_EMPTY if voice contains no notes * <li> MuERROR_NOTE_NOT_FOUND if num contains invalid note index * </ul> * **/ MuError RemoveNote(long num); /** * * @brief Removes last note from voice's note list * * @details * This method removes last note from the voice's note list * If voice is empty, RemoveLastNote() returns an error. * * @return * MuError * <ul> * <li> MuERROR_NONE upon success * <li> MuERROR_NOTE_LIST_IS_EMPTY if voice contains no notes * </ul> * **/ MuError RemoveLastNote(void); /** * * @brief Returns a copy of requested note. * * @details * GetNote() returns a copy of the requested note. num must be a valid * note index (see NumberOfNotes()); outNote must contain the address * of a valid MuNote object. If note list is empty or num is not valid * GetNote() returns an error. * * @return * MuError * <ul> * <li> MuERROR_NONE upon success * <li> MuERROR_NOTE_LIST_IS_EMPTY if voice contains no notes * <li> MuERROR_NOTE_NOT_FOUND if num contains invalid note index * </ul> * **/ MuError GetNote(long num, MuNote * outNote) const; /** * * @brief Replaces note at requested location with input note * * @details * SetNote() copies input note to note list at requested index; * num must be a valid note index (see NumberOfNotes()). If note * list is empty or num is not valid, SetNote() returns an error. * * @return * MuError * <ul> * <li> MuERROR_NONE upon success * <li> MuERROR_NOTE_LIST_IS_EMPTY if voice contains no notes * <li> MuERROR_NOTE_NOT_FOUND if num contains invalid note index * </ul> * **/ MuError SetNote(long num, MuNote inNote); /** * * @brief Bubble-sorts the notes (according to start time) * * **/ void Sort(void); /** * * @brief Bubble-sorts the notes by requested field * * @details * By default, notes inside a voice are ordered by start time. * SortBy() orders the voice's note list by the parameter indicated * in the field argument. This argument must be one of the * sort constants defined in MuVoice.h: * * <ul> * <li> SORT_FIELD_INSTR * <li> SORT_FIELD_DUR * <li> SORT_FIELD_PITCH * <li> SORT_FIELD_AMP * </ul> * * @warning * When notes are sorted by parameteres other than start time * many methods in MuM will fail! * **/ void SortBy( short field ); /** * * @brief Extracts content of voice between times beg and end * * @details * Extract() goes through the voice's note list looking for notes which * occur within the requested time range and returns a copy of these notes * inside an MuVoice object. Notes that either start before * 'beg' or terminate after 'end', but are partially contained in the range, * are clipped to fit the range and included in the resulting extraction. * If voice is empty or anything goes wrong, Extract() returns an empty voice * object. * * @param beg (float) - a starting point in time (seconds) * @param end (float) - an ending point in time (seconds) * * @return * MuVoice - voice object containing notes extracted from this voice * **/ MuVoice Extract(float beg, float end); /** * @brief Returns the instrument number definition for this voice * * @details * InstrumentNumber() returns the instrument assigned to this voice; * a value of 0 means no instrument has been assigned to this voice yet. * A voice's instrument number is used to assign instrument definitions * to notes which are inserted in the voice and have no previous instrument * number. * * @return * uShort - instrument number * **/ uShort InstrumentNumber(void); /** * @brief Sets the instrument number definition for this voice * * @details * SetInstrumentNumber() updates the instrument number assigned to the * voice and changes the instrument choices for every note accordingly. * SetInstrumentNumber() will force every note inside the note list to reset * its instrument choice to the requested number, therefore eliminating * any previous instrument definitions in the existing notes. * Notes added after this call will also conform to the instrument number * defined by SetInstrumentNumber() if they had no prior instrument choice. * * Valid instrument range for inInstrNum is 1 through 128, to allow compatibility * with GM program change format used by MIDI output. If an instrument * number outside this range is provided, SetInstrumentNumber will default * to value 1. If SetInstrumentNumber() fails to Get or Set a note, when updating * instrument choices, it aborts and returns a corresponding error. * * param * inInstrNum (uShort) - new instrument number for the voice * * @return * MuError * **/ MuError SetInstrumentNumber(uShort inInstrNum); /** * @brief Transposes every note's pitch * * @details * Transpose() transposes the pitch of every note inside voice * according to the number of halfsteps requested in interval. * Positive values signal an ascending transposition, while negative * values mean the notes should be transposed down.If Transpose() * fails to Get or Set any notes, when transposing them, * it aborts and returns a corresponding error. * * param * inInstrNum (uShort) - new instrument number for the voice * * @return * MuError * **/ MuError Transpose(short interval); /** * @brief Transposes a specific note's pitch * * @details * This version of Transpose() changes the pitch of the requested note * according to the number of halfsteps requested in interval. * Positive values signal an ascending transposition, while negative * values mean the notes should be transposed down. If Transpose() * fails to Get or Set any notes, when transposing them, or noteNumber * does not contain a valid note index for this voice, it aborts and * returns a corresponding error. * * param noteNumber (uShort) - index of note to be transposed * param interval (short) - interval to use in transposition * * @return * MuError * **/ MuError Transpose(long noteNumber, short interval); /** * @brief Moves voice to start at point 'time' * * @details * Moves first sounding note in note list to point time. The remaining * notes are shifted by the same offset, in order to preserve rhythmic * distribuition. If Move() fails to Get or Set any notes, when * moving them, or time contains a negative value move aborts and * returns a corresponding error. * * @param time (float) - index of note to be transposed * * @return * MuError * <ul> * <li> MuERROR_INVALID_PARAMETER if time is negative * </ul> * **/ MuError Move(float time); /** * @brief Removes blank notes (rests) * * @details * Removes every note that contains pitch == 0 or amp == 0 from selected * voice. These notes are usually used to mark pauses in applications * that require explicit rests. Since MuM uses explicit start times for * every note, deleting these notes won't affect rhythm or performance... * * @param time (float) - index of note to be transposed * * @return * MuError * **/ MuError RemoveBlankNotes(void); }; #endif
27.932727
95
0.67272
2676bed6d7977d02cbb5ae11ad1d9fc800eed510
1,887
h
C
src/MFCExt/FormViewEx.h
segafan/wme1_jankavan_tlc_edition-repo
72163931f348d5a2132577930362d297cc375a26
[ "MIT" ]
3
2021-03-28T00:11:48.000Z
2022-01-12T13:10:52.000Z
src/MFCExt/FormViewEx.h
segafan/wme1_jankavan_tlc_edition-repo
72163931f348d5a2132577930362d297cc375a26
[ "MIT" ]
null
null
null
src/MFCExt/FormViewEx.h
segafan/wme1_jankavan_tlc_edition-repo
72163931f348d5a2132577930362d297cc375a26
[ "MIT" ]
null
null
null
#if !defined(AFX_FORMVIEWEX_H__231DACD7_DE5B_48D6_ABE7_2110D7AF503C__INCLUDED_) #define AFX_FORMVIEWEX_H__231DACD7_DE5B_48D6_ABE7_2110D7AF503C__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // FormViewEx.h : header file // ///////////////////////////////////////////////////////////////////////////// // CFormViewEx form view #ifndef __AFXEXT_H__ #include <afxext.h> #endif #include "BCMenu.h" class CFormViewEx : public CFormView { protected: CFormViewEx(UINT nIDTemplate); // protected constructor used by dynamic creation //DECLARE_DYNCREATE(CFormViewEx) DECLARE_DYNAMIC(CFormViewEx) // Form Data public: //{{AFX_DATA(CFormViewEx) // NOTE: the ClassWizard will add data members here //}}AFX_DATA // Attributes public: BCMenu m_PopupMenu; // Operations public: BOOL ShowPopupMenu(int MenuID, int ToolbarID=-1, LPRECT Rect=NULL); // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CFormViewEx) public: virtual void OnInitialUpdate(); protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: virtual ~CFormViewEx(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif // Generated message map functions //{{AFX_MSG(CFormViewEx) afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct); afx_msg LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_FORMVIEWEX_H__231DACD7_DE5B_48D6_ABE7_2110D7AF503C__INCLUDED_)
26.957143
98
0.684685
2676f11e89a34510e36b548428891610622d335b
15,368
c
C
stage0/stdlib/Lean/Parser/StrInterpolation.c
DanielFabian/lean4
0dfefb7b78452fe9c3af21a57ebf0cca96f4b7e8
[ "Apache-2.0" ]
null
null
null
stage0/stdlib/Lean/Parser/StrInterpolation.c
DanielFabian/lean4
0dfefb7b78452fe9c3af21a57ebf0cca96f4b7e8
[ "Apache-2.0" ]
null
null
null
stage0/stdlib/Lean/Parser/StrInterpolation.c
DanielFabian/lean4
0dfefb7b78452fe9c3af21a57ebf0cca96f4b7e8
[ "Apache-2.0" ]
null
null
null
// Lean compiler output // Module: Lean.Parser.StrInterpolation // Imports: Init Lean.Parser.Basic #include <lean/lean.h> #if defined(__clang__) #pragma clang diagnostic ignored "-Wunused-parameter" #pragma clang diagnostic ignored "-Wunused-label" #elif defined(__GNUC__) && !defined(__CLANG__) #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wunused-label" #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #ifdef __cplusplus extern "C" { #endif lean_object* l_Lean_Parser_ParserState_mkError(lean_object*, lean_object*); lean_object* l_Lean_Parser_quotedCharCoreFn(lean_object*, lean_object*, lean_object*); uint8_t l_Lean_Parser_isQuotableCharDefault(uint32_t); lean_object* l_Lean_Parser_ParserState_next(lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Parser_interpolatedStrNoAntiquot___closed__1; lean_object* l_Lean_Parser_ParserState_mkNode(lean_object*, lean_object*, lean_object*); lean_object* lean_array_get_size(lean_object*); extern lean_object* l_Lean_interpolatedStrKind; lean_object* l_Lean_Parser_mkAtomicInfo(lean_object*); lean_object* l_Lean_Parser_interpolatedStrFn_parse___lambda__1___boxed(lean_object*); lean_object* l_Lean_Parser_mkNodeToken(lean_object*, lean_object*, lean_object*, lean_object*); extern lean_object* l_Lean_Parser_strLitFnAux___closed__1; lean_object* l_Lean_Parser_satisfyFn(lean_object*, lean_object*, lean_object*, lean_object*); lean_object* lean_string_utf8_next(lean_object*, lean_object*); lean_object* l_Lean_Parser_interpolatedStr___elambda__1___closed__1; lean_object* l_Lean_Parser_interpolatedStr___elambda__1___closed__2; lean_object* l_Lean_Parser_ParserState_setPos(lean_object*, lean_object*); lean_object* l_Lean_Parser_interpolatedStrFn_parse___closed__2; lean_object* l_Lean_Parser_interpolatedStrFn___closed__1; lean_object* l_Lean_Parser_interpolatedStrFn_parse___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Parser_interpolatedStrFn_parse___closed__1; lean_object* l_Lean_Parser_interpolatedStrNoAntiquot(lean_object*); lean_object* l_Lean_Parser_interpolatedStrFn_parse___closed__3; uint8_t l_Lean_Parser_tryAnti(lean_object*, lean_object*); lean_object* l_Lean_Parser_orelseInfo(lean_object*, lean_object*); uint8_t l_Lean_Parser_isQuotableCharForStrInterpolant(uint32_t); extern lean_object* l_Lean_Parser_ParserState_mkEOIError___closed__1; extern lean_object* l_termS_x21_____closed__5; uint32_t lean_string_utf8_get(lean_object*, lean_object*); lean_object* l_Lean_Parser_interpolatedStr(lean_object*); lean_object* l_Lean_Parser_interpolatedStr___closed__1; uint8_t l_UInt32_decEq(uint32_t, uint32_t); uint8_t l_Lean_Parser_interpolatedStrFn_parse___lambda__1(uint32_t); lean_object* l_Lean_Parser_ParserState_mkUnexpectedErrorAt(lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Parser_interpolatedStr___elambda__1(lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Parser_orelseFnCore(lean_object*, lean_object*, uint8_t, lean_object*, lean_object*); uint8_t l___private_Init_Data_Option_Basic_0__beqOption____x40_Init_Data_Option_Basic___hyg_594____at_Lean_Parser_ParserState_hasError___spec__1(lean_object*, lean_object*); lean_object* l_Lean_Parser_interpolatedStrFn_parse(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Parser_mkAntiquot(lean_object*, lean_object*, uint8_t); lean_object* l_Lean_Parser_isQuotableCharForStrInterpolant___boxed(lean_object*); lean_object* l_Lean_Parser_interpolatedStrFn(lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Parser_ParserState_mkUnexpectedError(lean_object*, lean_object*); uint8_t lean_string_utf8_at_end(lean_object*, lean_object*); extern lean_object* l_Lean_interpolatedStrLitKind; uint8_t l_Lean_Parser_isQuotableCharForStrInterpolant(uint32_t x_1) { _start: { uint32_t x_2; uint8_t x_3; x_2 = 123; x_3 = x_1 == x_2; if (x_3 == 0) { uint8_t x_4; x_4 = l_Lean_Parser_isQuotableCharDefault(x_1); return x_4; } else { uint8_t x_5; x_5 = 1; return x_5; } } } lean_object* l_Lean_Parser_isQuotableCharForStrInterpolant___boxed(lean_object* x_1) { _start: { uint32_t x_2; uint8_t x_3; lean_object* x_4; x_2 = lean_unbox_uint32(x_1); lean_dec(x_1); x_3 = l_Lean_Parser_isQuotableCharForStrInterpolant(x_2); x_4 = lean_box(x_3); return x_4; } } uint8_t l_Lean_Parser_interpolatedStrFn_parse___lambda__1(uint32_t x_1) { _start: { uint32_t x_2; uint8_t x_3; x_2 = 125; x_3 = x_1 == x_2; return x_3; } } static lean_object* _init_l_Lean_Parser_interpolatedStrFn_parse___closed__1() { _start: { lean_object* x_1; x_1 = lean_alloc_closure((void*)(l_Lean_Parser_interpolatedStrFn_parse___lambda__1___boxed), 1, 0); return x_1; } } static lean_object* _init_l_Lean_Parser_interpolatedStrFn_parse___closed__2() { _start: { lean_object* x_1; x_1 = lean_mk_string("expected '}'"); return x_1; } } static lean_object* _init_l_Lean_Parser_interpolatedStrFn_parse___closed__3() { _start: { lean_object* x_1; x_1 = lean_alloc_closure((void*)(l_Lean_Parser_isQuotableCharForStrInterpolant___boxed), 1, 0); return x_1; } } lean_object* l_Lean_Parser_interpolatedStrFn_parse(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { lean_object* x_7; uint8_t x_8; x_7 = lean_ctor_get(x_6, 2); lean_inc(x_7); x_8 = lean_string_utf8_at_end(x_2, x_7); if (x_8 == 0) { uint32_t x_9; lean_object* x_10; lean_object* x_11; uint32_t x_12; uint8_t x_13; x_9 = lean_string_utf8_get(x_2, x_7); x_10 = lean_string_utf8_next(x_2, x_7); lean_dec(x_7); x_11 = l_Lean_Parser_ParserState_setPos(x_6, x_10); x_12 = 34; x_13 = x_9 == x_12; if (x_13 == 0) { uint32_t x_14; uint8_t x_15; x_14 = 92; x_15 = x_9 == x_14; if (x_15 == 0) { uint32_t x_16; uint8_t x_17; x_16 = 123; x_17 = x_9 == x_16; if (x_17 == 0) { x_6 = x_11; goto _start; } else { lean_object* x_19; lean_object* x_20; lean_object* x_21; lean_object* x_22; lean_object* x_23; uint8_t x_24; x_19 = l_Lean_interpolatedStrLitKind; x_20 = l_Lean_Parser_mkNodeToken(x_19, x_4, x_5, x_11); lean_inc(x_1); lean_inc(x_5); x_21 = lean_apply_2(x_1, x_5, x_20); x_22 = lean_ctor_get(x_21, 4); lean_inc(x_22); x_23 = lean_box(0); x_24 = l___private_Init_Data_Option_Basic_0__beqOption____x40_Init_Data_Option_Basic___hyg_594____at_Lean_Parser_ParserState_hasError___spec__1(x_22, x_23); lean_dec(x_22); if (x_24 == 0) { lean_dec(x_5); lean_dec(x_3); lean_dec(x_1); return x_21; } else { lean_object* x_25; lean_object* x_26; lean_object* x_27; lean_object* x_28; lean_object* x_29; uint8_t x_30; x_25 = lean_ctor_get(x_21, 2); lean_inc(x_25); x_26 = l_Lean_Parser_interpolatedStrFn_parse___closed__1; x_27 = l_Lean_Parser_interpolatedStrFn_parse___closed__2; x_28 = l_Lean_Parser_satisfyFn(x_26, x_27, x_5, x_21); x_29 = lean_ctor_get(x_28, 4); lean_inc(x_29); x_30 = l___private_Init_Data_Option_Basic_0__beqOption____x40_Init_Data_Option_Basic___hyg_594____at_Lean_Parser_ParserState_hasError___spec__1(x_29, x_23); lean_dec(x_29); if (x_30 == 0) { lean_dec(x_25); lean_dec(x_5); lean_dec(x_3); lean_dec(x_1); return x_28; } else { x_4 = x_25; x_6 = x_28; goto _start; } } } } else { lean_object* x_32; lean_object* x_33; lean_object* x_34; lean_object* x_35; uint8_t x_36; x_32 = l_Lean_Parser_interpolatedStrFn_parse___closed__3; x_33 = l_Lean_Parser_quotedCharCoreFn(x_32, x_5, x_11); x_34 = lean_ctor_get(x_33, 4); lean_inc(x_34); x_35 = lean_box(0); x_36 = l___private_Init_Data_Option_Basic_0__beqOption____x40_Init_Data_Option_Basic___hyg_594____at_Lean_Parser_ParserState_hasError___spec__1(x_34, x_35); lean_dec(x_34); if (x_36 == 0) { lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); return x_33; } else { x_6 = x_33; goto _start; } } } else { lean_object* x_38; lean_object* x_39; lean_object* x_40; lean_object* x_41; lean_dec(x_1); x_38 = l_Lean_interpolatedStrLitKind; x_39 = l_Lean_Parser_mkNodeToken(x_38, x_4, x_5, x_11); lean_dec(x_5); x_40 = l_Lean_interpolatedStrKind; x_41 = l_Lean_Parser_ParserState_mkNode(x_39, x_40, x_3); return x_41; } } else { lean_object* x_42; lean_object* x_43; lean_dec(x_7); lean_dec(x_5); lean_dec(x_3); lean_dec(x_1); x_42 = l_Lean_Parser_strLitFnAux___closed__1; x_43 = l_Lean_Parser_ParserState_mkUnexpectedErrorAt(x_6, x_42, x_4); return x_43; } } } lean_object* l_Lean_Parser_interpolatedStrFn_parse___lambda__1___boxed(lean_object* x_1) { _start: { uint32_t x_2; uint8_t x_3; lean_object* x_4; x_2 = lean_unbox_uint32(x_1); lean_dec(x_1); x_3 = l_Lean_Parser_interpolatedStrFn_parse___lambda__1(x_2); x_4 = lean_box(x_3); return x_4; } } lean_object* l_Lean_Parser_interpolatedStrFn_parse___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) { _start: { lean_object* x_7; x_7 = l_Lean_Parser_interpolatedStrFn_parse(x_1, x_2, x_3, x_4, x_5, x_6); lean_dec(x_2); return x_7; } } static lean_object* _init_l_Lean_Parser_interpolatedStrFn___closed__1() { _start: { lean_object* x_1; x_1 = lean_mk_string("interpolated string"); return x_1; } } lean_object* l_Lean_Parser_interpolatedStrFn(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; lean_object* x_6; lean_object* x_7; lean_object* x_8; uint8_t x_9; x_4 = lean_ctor_get(x_2, 0); lean_inc(x_4); x_5 = lean_ctor_get(x_4, 0); lean_inc(x_5); lean_dec(x_4); x_6 = lean_ctor_get(x_3, 0); lean_inc(x_6); x_7 = lean_array_get_size(x_6); lean_dec(x_6); x_8 = lean_ctor_get(x_3, 2); lean_inc(x_8); x_9 = lean_string_utf8_at_end(x_5, x_8); if (x_9 == 0) { uint32_t x_10; uint32_t x_11; uint8_t x_12; x_10 = lean_string_utf8_get(x_5, x_8); x_11 = 34; x_12 = x_10 == x_11; if (x_12 == 0) { lean_object* x_13; lean_object* x_14; lean_dec(x_8); lean_dec(x_7); lean_dec(x_5); lean_dec(x_2); lean_dec(x_1); x_13 = l_Lean_Parser_interpolatedStrFn___closed__1; x_14 = l_Lean_Parser_ParserState_mkError(x_3, x_13); return x_14; } else { lean_object* x_15; lean_object* x_16; x_15 = l_Lean_Parser_ParserState_next(x_3, x_5, x_8); x_16 = l_Lean_Parser_interpolatedStrFn_parse(x_1, x_5, x_7, x_8, x_2, x_15); lean_dec(x_5); return x_16; } } else { lean_object* x_17; lean_object* x_18; lean_dec(x_8); lean_dec(x_7); lean_dec(x_5); lean_dec(x_2); lean_dec(x_1); x_17 = l_Lean_Parser_ParserState_mkEOIError___closed__1; x_18 = l_Lean_Parser_ParserState_mkUnexpectedError(x_3, x_17); return x_18; } } } static lean_object* _init_l_Lean_Parser_interpolatedStrNoAntiquot___closed__1() { _start: { lean_object* x_1; lean_object* x_2; x_1 = l_termS_x21_____closed__5; x_2 = l_Lean_Parser_mkAtomicInfo(x_1); return x_2; } } lean_object* l_Lean_Parser_interpolatedStrNoAntiquot(lean_object* x_1) { _start: { lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_object* x_5; x_2 = lean_ctor_get(x_1, 1); lean_inc(x_2); lean_dec(x_1); x_3 = lean_alloc_closure((void*)(l_Lean_Parser_interpolatedStrFn), 3, 1); lean_closure_set(x_3, 0, x_2); x_4 = l_Lean_Parser_interpolatedStrNoAntiquot___closed__1; x_5 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_5, 0, x_4); lean_ctor_set(x_5, 1, x_3); return x_5; } } static lean_object* _init_l_Lean_Parser_interpolatedStr___elambda__1___closed__1() { _start: { lean_object* x_1; lean_object* x_2; x_1 = l_Lean_interpolatedStrKind; x_2 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_2, 0, x_1); return x_2; } } static lean_object* _init_l_Lean_Parser_interpolatedStr___elambda__1___closed__2() { _start: { lean_object* x_1; lean_object* x_2; uint8_t x_3; lean_object* x_4; x_1 = l_termS_x21_____closed__5; x_2 = l_Lean_Parser_interpolatedStr___elambda__1___closed__1; x_3 = 1; x_4 = l_Lean_Parser_mkAntiquot(x_1, x_2, x_3); return x_4; } } lean_object* l_Lean_Parser_interpolatedStr___elambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3) { _start: { lean_object* x_4; lean_object* x_5; uint8_t x_6; x_4 = l_Lean_Parser_interpolatedStr___elambda__1___closed__2; x_5 = lean_ctor_get(x_4, 1); lean_inc(x_5); lean_inc(x_3); lean_inc(x_2); x_6 = l_Lean_Parser_tryAnti(x_2, x_3); if (x_6 == 0) { lean_object* x_7; lean_dec(x_5); x_7 = lean_apply_2(x_1, x_2, x_3); return x_7; } else { uint8_t x_8; lean_object* x_9; x_8 = 1; x_9 = l_Lean_Parser_orelseFnCore(x_5, x_1, x_8, x_2, x_3); return x_9; } } } static lean_object* _init_l_Lean_Parser_interpolatedStr___closed__1() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; lean_object* x_4; x_1 = l_Lean_Parser_interpolatedStr___elambda__1___closed__2; x_2 = lean_ctor_get(x_1, 0); lean_inc(x_2); x_3 = l_Lean_Parser_interpolatedStrNoAntiquot___closed__1; x_4 = l_Lean_Parser_orelseInfo(x_2, x_3); return x_4; } } lean_object* l_Lean_Parser_interpolatedStr(lean_object* x_1) { _start: { lean_object* x_2; lean_object* x_3; lean_object* x_4; lean_object* x_5; lean_object* x_6; x_2 = lean_ctor_get(x_1, 1); lean_inc(x_2); lean_dec(x_1); x_3 = lean_alloc_closure((void*)(l_Lean_Parser_interpolatedStrFn), 3, 1); lean_closure_set(x_3, 0, x_2); x_4 = lean_alloc_closure((void*)(l_Lean_Parser_interpolatedStr___elambda__1), 3, 1); lean_closure_set(x_4, 0, x_3); x_5 = l_Lean_Parser_interpolatedStr___closed__1; x_6 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_6, 0, x_5); lean_ctor_set(x_6, 1, x_4); return x_6; } } lean_object* initialize_Init(lean_object*); lean_object* initialize_Lean_Parser_Basic(lean_object*); static bool _G_initialized = false; lean_object* initialize_Lean_Parser_StrInterpolation(lean_object* w) { lean_object * res; if (_G_initialized) return lean_io_result_mk_ok(lean_box(0)); _G_initialized = true; res = initialize_Init(lean_io_mk_world()); if (lean_io_result_is_error(res)) return res; lean_dec_ref(res); res = initialize_Lean_Parser_Basic(lean_io_mk_world()); if (lean_io_result_is_error(res)) return res; lean_dec_ref(res); l_Lean_Parser_interpolatedStrFn_parse___closed__1 = _init_l_Lean_Parser_interpolatedStrFn_parse___closed__1(); lean_mark_persistent(l_Lean_Parser_interpolatedStrFn_parse___closed__1); l_Lean_Parser_interpolatedStrFn_parse___closed__2 = _init_l_Lean_Parser_interpolatedStrFn_parse___closed__2(); lean_mark_persistent(l_Lean_Parser_interpolatedStrFn_parse___closed__2); l_Lean_Parser_interpolatedStrFn_parse___closed__3 = _init_l_Lean_Parser_interpolatedStrFn_parse___closed__3(); lean_mark_persistent(l_Lean_Parser_interpolatedStrFn_parse___closed__3); l_Lean_Parser_interpolatedStrFn___closed__1 = _init_l_Lean_Parser_interpolatedStrFn___closed__1(); lean_mark_persistent(l_Lean_Parser_interpolatedStrFn___closed__1); l_Lean_Parser_interpolatedStrNoAntiquot___closed__1 = _init_l_Lean_Parser_interpolatedStrNoAntiquot___closed__1(); lean_mark_persistent(l_Lean_Parser_interpolatedStrNoAntiquot___closed__1); l_Lean_Parser_interpolatedStr___elambda__1___closed__1 = _init_l_Lean_Parser_interpolatedStr___elambda__1___closed__1(); lean_mark_persistent(l_Lean_Parser_interpolatedStr___elambda__1___closed__1); l_Lean_Parser_interpolatedStr___elambda__1___closed__2 = _init_l_Lean_Parser_interpolatedStr___elambda__1___closed__2(); lean_mark_persistent(l_Lean_Parser_interpolatedStr___elambda__1___closed__2); l_Lean_Parser_interpolatedStr___closed__1 = _init_l_Lean_Parser_interpolatedStr___closed__1(); lean_mark_persistent(l_Lean_Parser_interpolatedStr___closed__1); return lean_io_result_mk_ok(lean_box(0)); } #ifdef __cplusplus } #endif
32.353684
173
0.816697
2677fccfb8bf456bc19c0e419179fb4406ba6d95
1,662
h
C
src/ast2ram/seminaive/TranslationStrategy.h
LittleLightLittleFire/souffle
468213129729fe2ac17d6e666105e5adb6dae5eb
[ "UPL-1.0" ]
null
null
null
src/ast2ram/seminaive/TranslationStrategy.h
LittleLightLittleFire/souffle
468213129729fe2ac17d6e666105e5adb6dae5eb
[ "UPL-1.0" ]
null
null
null
src/ast2ram/seminaive/TranslationStrategy.h
LittleLightLittleFire/souffle
468213129729fe2ac17d6e666105e5adb6dae5eb
[ "UPL-1.0" ]
null
null
null
/* * Souffle - A Datalog Compiler * Copyright (c) 2020 The Souffle Developers. All rights reserved * Licensed under the Universal Permissive License v 1.0 as shown at: * - https://opensource.org/licenses/UPL * - <souffle root>/licenses/SOUFFLE-UPL.txt */ /************************************************************************ * * @file TranslationStrategy.h * * Implementation of the Datalog semi-naive evaluation strategy. * ***********************************************************************/ #pragma once #include "ast2ram/TranslationStrategy.h" #include "souffle/utility/ContainerUtil.h" namespace souffle { class SymbolTable; } namespace souffle::ast2ram { class ClauseTranslator; class ConstraintTranslator; class UnitTranslator; class TranslatorContext; class ValueIndex; class ValueTranslator; } // namespace souffle::ast2ram namespace souffle::ast2ram::seminaive { class TranslationStrategy : public ast2ram::TranslationStrategy { public: std::string getName() const override { return "SeminaiveEvaluation"; } ast2ram::UnitTranslator* createUnitTranslator() const override; ast2ram::ClauseTranslator* createClauseTranslator( const TranslatorContext& context, SymbolTable& symbolTable) const override; ast2ram::ConstraintTranslator* createConstraintTranslator(const TranslatorContext& context, SymbolTable& symbolTable, const ValueIndex& index) const override; ast2ram::ValueTranslator* createValueTranslator(const TranslatorContext& context, SymbolTable& symbolTable, const ValueIndex& index) const override; }; } // namespace souffle::ast2ram::seminaive
31.358491
95
0.693141
2679641483657ffac6209dee04140d3320abf121
715
h
C
Chapter.5-7/QGalleryPlugin/operatingsystem.h
ioriayane/startqtquick
135a18b2685251a3f42dffd1a6eef02bd75f03f8
[ "Apache-2.0" ]
3
2015-11-20T09:44:28.000Z
2017-11-30T15:08:51.000Z
Chapter.5-7/QGalleryPlugin/operatingsystem.h
ioriayane/startqtquick
135a18b2685251a3f42dffd1a6eef02bd75f03f8
[ "Apache-2.0" ]
null
null
null
Chapter.5-7/QGalleryPlugin/operatingsystem.h
ioriayane/startqtquick
135a18b2685251a3f42dffd1a6eef02bd75f03f8
[ "Apache-2.0" ]
null
null
null
#ifndef OPERATINGSYSTEM_H #define OPERATINGSYSTEM_H #include <QQuickItem> class OperatingSystem : public QObject { Q_OBJECT Q_DISABLE_COPY(OperatingSystem) //列挙型の公開 Q_ENUMS(OperatingSystemType) //プロパティを公開 Q_PROPERTY(OperatingSystemType type READ type) Q_PROPERTY(QString pathPrefix READ pathPrefix) Q_PROPERTY(QString homeDirectory READ homeDirectory) public: explicit OperatingSystem(QObject *parent = 0); enum OperatingSystemType{ Windows , Linux , Mac , Other }; //プロパティの参照 OperatingSystemType type() const; QString pathPrefix() const; QString homeDirectory() const; signals: public slots: }; #endif // OPERATINGSYSTEM_H
18.815789
55
0.714685
b7d9ea1fee9684ab616b2d47a28f6d88b30718a5
369
h
C
src/lpcxpresso.h
Squantor/lpc_81x_frame
6ebfb14b98b3fabfa322764df146fe314fab1e5f
[ "MIT" ]
null
null
null
src/lpcxpresso.h
Squantor/lpc_81x_frame
6ebfb14b98b3fabfa322764df146fe314fab1e5f
[ "MIT" ]
null
null
null
src/lpcxpresso.h
Squantor/lpc_81x_frame
6ebfb14b98b3fabfa322764df146fe314fab1e5f
[ "MIT" ]
null
null
null
/* Lpcxpresso board definitions */ #ifndef BOARD_LPCXPRESSO_H_ #define BOARD_LPCXPRESSO_H_ #define LED_RED_PIN 7 #define LED_RED_PORT 0 #define LED_BLU_PIN 16 #define LED_BLU_PORT 0 #define LED_GRN_PIN 17 #define LED_GRN_PORT 0 #define UART_RX_PIN 0 #define UART_RX_PORT 0 #define UART_TX_PIN 4 #define UART_TX_PORT 0 #endif
16.772727
32
0.726287
b7dbfb94d1b571808a0ab0bf65f916478ffda245
160
h
C
src/headers/drawIssue.h
nevzatseferoglu/boulder-dash
0994d636bf3f9c756636f58e194afd71d4c60c06
[ "MIT" ]
1
2019-10-13T21:18:34.000Z
2019-10-13T21:18:34.000Z
src/headers/drawIssue.h
nevzatseferoglu/Boulder-Dash-C-Implementation
0994d636bf3f9c756636f58e194afd71d4c60c06
[ "MIT" ]
null
null
null
src/headers/drawIssue.h
nevzatseferoglu/Boulder-Dash-C-Implementation
0994d636bf3f9c756636f58e194afd71d4c60c06
[ "MIT" ]
2
2020-03-20T16:58:03.000Z
2021-06-06T20:01:55.000Z
#include "common.h" extern struct mainTools gameTools; extern struct gameState state; extern void drawInitialBackground(void); extern void loadBackground(void);
32
40
0.83125
b7dcf36d87df0ae83fe09ce44984950e69f8e9c1
39,454
c
C
kernel/linux-4.13/fs/nova/bbuild.c
ShawnZhong/SplitFS
7e21a6fc505ff70802e5666d097326ecb97a4ae3
[ "Apache-2.0" ]
1
2019-12-18T06:42:08.000Z
2019-12-18T06:42:08.000Z
kernel/linux-4.13/fs/nova/bbuild.c
braymill/SplitFS
00a42bb1b51718048e4c15dde31e9d358932575e
[ "Apache-2.0" ]
5
2020-04-04T09:24:09.000Z
2020-04-19T12:33:55.000Z
kernel/linux-4.13/fs/nova/bbuild.c
braymill/SplitFS
00a42bb1b51718048e4c15dde31e9d358932575e
[ "Apache-2.0" ]
1
2020-01-22T17:03:12.000Z
2020-01-22T17:03:12.000Z
/* * NOVA Recovery routines. * * Copyright 2015-2016 Regents of the University of California, * UCSD Non-Volatile Systems Lab, Andiry Xu <jix024@cs.ucsd.edu> * Copyright 2012-2013 Intel Corporation * Copyright 2009-2011 Marco Stornelli <marco.stornelli@gmail.com> * Copyright 2003 Sony Corporation * Copyright 2003 Matsushita Electric Industrial Co., Ltd. * 2003-2004 (c) MontaVista Software, Inc. , Steve Longerbeam * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. */ #include <linux/fs.h> #include <linux/bitops.h> #include <linux/slab.h> #include <linux/random.h> #include <linux/delay.h> #include "nova.h" #include "journal.h" #include "super.h" #include "inode.h" #include "log.h" void nova_init_header(struct super_block *sb, struct nova_inode_info_header *sih, u16 i_mode) { sih->log_pages = 0; sih->i_size = 0; sih->ino = 0; sih->i_blocks = 0; sih->pi_addr = 0; sih->alter_pi_addr = 0; INIT_RADIX_TREE(&sih->tree, GFP_ATOMIC); sih->rb_tree = RB_ROOT; sih->vma_tree = RB_ROOT; sih->num_vmas = 0; INIT_LIST_HEAD(&sih->list); sih->i_mode = i_mode; sih->i_flags = 0; sih->valid_entries = 0; sih->num_entries = 0; sih->last_setattr = 0; sih->last_link_change = 0; sih->last_dentry = 0; sih->trans_id = 0; sih->log_head = 0; sih->log_tail = 0; sih->alter_log_head = 0; sih->alter_log_tail = 0; sih->i_blk_type = NOVA_DEFAULT_BLOCK_TYPE; } static inline void set_scan_bm(unsigned long bit, struct single_scan_bm *scan_bm) { set_bit(bit, scan_bm->bitmap); } inline void set_bm(unsigned long bit, struct scan_bitmap *bm, enum bm_type type) { switch (type) { case BM_4K: set_scan_bm(bit, &bm->scan_bm_4K); break; case BM_2M: set_scan_bm(bit, &bm->scan_bm_2M); break; case BM_1G: set_scan_bm(bit, &bm->scan_bm_1G); break; default: break; } } static inline int get_block_cpuid(struct nova_sb_info *sbi, unsigned long blocknr) { return blocknr / sbi->per_list_blocks; } static int nova_failure_insert_inodetree(struct super_block *sb, unsigned long ino_low, unsigned long ino_high) { struct nova_sb_info *sbi = NOVA_SB(sb); struct inode_map *inode_map; struct nova_range_node *prev = NULL, *next = NULL; struct nova_range_node *new_node; unsigned long internal_low, internal_high; int cpu; struct rb_root *tree; int ret; if (ino_low > ino_high) { nova_err(sb, "%s: ino low %lu, ino high %lu\n", __func__, ino_low, ino_high); BUG(); } cpu = ino_low % sbi->cpus; if (ino_high % sbi->cpus != cpu) { nova_err(sb, "%s: ino low %lu, ino high %lu\n", __func__, ino_low, ino_high); BUG(); } internal_low = ino_low / sbi->cpus; internal_high = ino_high / sbi->cpus; inode_map = &sbi->inode_maps[cpu]; tree = &inode_map->inode_inuse_tree; mutex_lock(&inode_map->inode_table_mutex); ret = nova_find_free_slot(tree, internal_low, internal_high, &prev, &next); if (ret) { nova_dbg("%s: ino %lu - %lu already exists!: %d\n", __func__, ino_low, ino_high, ret); mutex_unlock(&inode_map->inode_table_mutex); return ret; } if (prev && next && (internal_low == prev->range_high + 1) && (internal_high + 1 == next->range_low)) { /* fits the hole */ rb_erase(&next->node, tree); inode_map->num_range_node_inode--; prev->range_high = next->range_high; nova_update_range_node_checksum(prev); nova_free_inode_node(next); goto finish; } if (prev && (internal_low == prev->range_high + 1)) { /* Aligns left */ prev->range_high += internal_high - internal_low + 1; nova_update_range_node_checksum(prev); goto finish; } if (next && (internal_high + 1 == next->range_low)) { /* Aligns right */ next->range_low -= internal_high - internal_low + 1; nova_update_range_node_checksum(next); goto finish; } /* Aligns somewhere in the middle */ new_node = nova_alloc_inode_node(sb); NOVA_ASSERT(new_node); new_node->range_low = internal_low; new_node->range_high = internal_high; nova_update_range_node_checksum(new_node); ret = nova_insert_inodetree(sbi, new_node, cpu); if (ret) { nova_err(sb, "%s failed\n", __func__); nova_free_inode_node(new_node); goto finish; } inode_map->num_range_node_inode++; finish: mutex_unlock(&inode_map->inode_table_mutex); return ret; } static void nova_destroy_blocknode_tree(struct super_block *sb, int cpu) { struct free_list *free_list; free_list = nova_get_free_list(sb, cpu); nova_destroy_range_node_tree(sb, &free_list->block_free_tree); } static void nova_destroy_blocknode_trees(struct super_block *sb) { struct nova_sb_info *sbi = NOVA_SB(sb); int i; for (i = 0; i < sbi->cpus; i++) nova_destroy_blocknode_tree(sb, i); } static int nova_init_blockmap_from_inode(struct super_block *sb) { struct nova_sb_info *sbi = NOVA_SB(sb); struct nova_inode *pi = nova_get_inode_by_ino(sb, NOVA_BLOCKNODE_INO); struct nova_inode_info_header sih; struct free_list *free_list; struct nova_range_node_lowhigh *entry; struct nova_range_node *blknode; size_t size = sizeof(struct nova_range_node_lowhigh); u64 curr_p; u64 cpuid; int ret = 0; /* FIXME: Backup inode for BLOCKNODE */ ret = nova_get_head_tail(sb, pi, &sih); if (ret) goto out; sih.ino = NOVA_BLOCKNODE_INO; curr_p = sih.log_head; if (curr_p == 0) { nova_dbg("%s: pi head is 0!\n", __func__); return -EINVAL; } while (curr_p != sih.log_tail) { if (is_last_entry(curr_p, size)) curr_p = next_log_page(sb, curr_p); if (curr_p == 0) { nova_dbg("%s: curr_p is NULL!\n", __func__); NOVA_ASSERT(0); ret = -EINVAL; break; } entry = (struct nova_range_node_lowhigh *)nova_get_block(sb, curr_p); blknode = nova_alloc_blocknode(sb); if (blknode == NULL) NOVA_ASSERT(0); blknode->range_low = le64_to_cpu(entry->range_low); blknode->range_high = le64_to_cpu(entry->range_high); nova_update_range_node_checksum(blknode); cpuid = get_block_cpuid(sbi, blknode->range_low); /* FIXME: Assume NR_CPUS not change */ free_list = nova_get_free_list(sb, cpuid); ret = nova_insert_blocktree(&free_list->block_free_tree, blknode); if (ret) { nova_err(sb, "%s failed\n", __func__); nova_free_blocknode(blknode); NOVA_ASSERT(0); nova_destroy_blocknode_trees(sb); goto out; } free_list->num_blocknode++; if (free_list->num_blocknode == 1) free_list->first_node = blknode; free_list->last_node = blknode; free_list->num_free_blocks += blknode->range_high - blknode->range_low + 1; curr_p += sizeof(struct nova_range_node_lowhigh); } out: nova_free_inode_log(sb, pi, &sih); return ret; } static void nova_destroy_inode_trees(struct super_block *sb) { struct nova_sb_info *sbi = NOVA_SB(sb); struct inode_map *inode_map; int i; for (i = 0; i < sbi->cpus; i++) { inode_map = &sbi->inode_maps[i]; nova_destroy_range_node_tree(sb, &inode_map->inode_inuse_tree); } } #define CPUID_MASK 0xff00000000000000 static int nova_init_inode_list_from_inode(struct super_block *sb) { struct nova_sb_info *sbi = NOVA_SB(sb); struct nova_inode *pi = nova_get_inode_by_ino(sb, NOVA_INODELIST_INO); struct nova_inode_info_header sih; struct nova_range_node_lowhigh *entry; struct nova_range_node *range_node; struct inode_map *inode_map; size_t size = sizeof(struct nova_range_node_lowhigh); unsigned long num_inode_node = 0; u64 curr_p; unsigned long cpuid; int ret; /* FIXME: Backup inode for INODELIST */ ret = nova_get_head_tail(sb, pi, &sih); if (ret) goto out; sih.ino = NOVA_INODELIST_INO; sbi->s_inodes_used_count = 0; curr_p = sih.log_head; if (curr_p == 0) { nova_dbg("%s: pi head is 0!\n", __func__); return -EINVAL; } while (curr_p != sih.log_tail) { if (is_last_entry(curr_p, size)) curr_p = next_log_page(sb, curr_p); if (curr_p == 0) { nova_dbg("%s: curr_p is NULL!\n", __func__); NOVA_ASSERT(0); } entry = (struct nova_range_node_lowhigh *)nova_get_block(sb, curr_p); range_node = nova_alloc_inode_node(sb); if (range_node == NULL) NOVA_ASSERT(0); cpuid = (entry->range_low & CPUID_MASK) >> 56; if (cpuid >= sbi->cpus) { nova_err(sb, "Invalid cpuid %lu\n", cpuid); nova_free_inode_node(range_node); NOVA_ASSERT(0); nova_destroy_inode_trees(sb); goto out; } range_node->range_low = entry->range_low & ~CPUID_MASK; range_node->range_high = entry->range_high; nova_update_range_node_checksum(range_node); ret = nova_insert_inodetree(sbi, range_node, cpuid); if (ret) { nova_err(sb, "%s failed, %d\n", __func__, cpuid); nova_free_inode_node(range_node); NOVA_ASSERT(0); nova_destroy_inode_trees(sb); goto out; } sbi->s_inodes_used_count += range_node->range_high - range_node->range_low + 1; num_inode_node++; inode_map = &sbi->inode_maps[cpuid]; inode_map->num_range_node_inode++; if (!inode_map->first_inode_range) inode_map->first_inode_range = range_node; curr_p += sizeof(struct nova_range_node_lowhigh); } nova_dbg("%s: %lu inode nodes\n", __func__, num_inode_node); out: nova_free_inode_log(sb, pi, &sih); return ret; } static u64 nova_append_range_node_entry(struct super_block *sb, struct nova_range_node *curr, u64 tail, unsigned long cpuid) { u64 curr_p; size_t size = sizeof(struct nova_range_node_lowhigh); struct nova_range_node_lowhigh *entry; curr_p = tail; if (!nova_range_node_checksum_ok(curr)) { nova_dbg("%s: range node checksum failure\n", __func__); goto out; } if (curr_p == 0 || (is_last_entry(curr_p, size) && next_log_page(sb, curr_p) == 0)) { nova_dbg("%s: inode log reaches end?\n", __func__); goto out; } if (is_last_entry(curr_p, size)) curr_p = next_log_page(sb, curr_p); entry = (struct nova_range_node_lowhigh *)nova_get_block(sb, curr_p); nova_memunlock_range(sb, entry, size); entry->range_low = cpu_to_le64(curr->range_low); if (cpuid) entry->range_low |= cpu_to_le64(cpuid << 56); entry->range_high = cpu_to_le64(curr->range_high); nova_memlock_range(sb, entry, size); nova_dbgv("append entry block low 0x%lx, high 0x%lx\n", curr->range_low, curr->range_high); nova_flush_buffer(entry, sizeof(struct nova_range_node_lowhigh), 0); out: return curr_p; } static u64 nova_save_range_nodes_to_log(struct super_block *sb, struct rb_root *tree, u64 temp_tail, unsigned long cpuid) { struct nova_range_node *curr; struct rb_node *temp; size_t size = sizeof(struct nova_range_node_lowhigh); u64 curr_entry = 0; /* Save in increasing order */ temp = rb_first(tree); while (temp) { curr = container_of(temp, struct nova_range_node, node); curr_entry = nova_append_range_node_entry(sb, curr, temp_tail, cpuid); temp_tail = curr_entry + size; temp = rb_next(temp); rb_erase(&curr->node, tree); nova_free_range_node(curr); } return temp_tail; } static u64 nova_save_free_list_blocknodes(struct super_block *sb, int cpu, u64 temp_tail) { struct free_list *free_list; free_list = nova_get_free_list(sb, cpu); temp_tail = nova_save_range_nodes_to_log(sb, &free_list->block_free_tree, temp_tail, 0); return temp_tail; } void nova_save_inode_list_to_log(struct super_block *sb) { struct nova_inode *pi = nova_get_inode_by_ino(sb, NOVA_INODELIST_INO); struct nova_inode_info_header sih; struct nova_sb_info *sbi = NOVA_SB(sb); unsigned long num_blocks; unsigned long num_nodes = 0; struct inode_map *inode_map; unsigned long i; u64 temp_tail; u64 new_block; int allocated; sih.ino = NOVA_INODELIST_INO; sih.i_blk_type = NOVA_DEFAULT_BLOCK_TYPE; sih.i_blocks = 0; for (i = 0; i < sbi->cpus; i++) { inode_map = &sbi->inode_maps[i]; num_nodes += inode_map->num_range_node_inode; } num_blocks = num_nodes / RANGENODE_PER_PAGE; if (num_nodes % RANGENODE_PER_PAGE) num_blocks++; allocated = nova_allocate_inode_log_pages(sb, &sih, num_blocks, &new_block, ANY_CPU, 0); if (allocated != num_blocks) { nova_dbg("Error saving inode list: %d\n", allocated); return; } temp_tail = new_block; for (i = 0; i < sbi->cpus; i++) { inode_map = &sbi->inode_maps[i]; temp_tail = nova_save_range_nodes_to_log(sb, &inode_map->inode_inuse_tree, temp_tail, i); } nova_memunlock_inode(sb, pi); pi->alter_log_head = pi->alter_log_tail = 0; pi->log_head = new_block; nova_update_tail(pi, temp_tail); nova_flush_buffer(&pi->log_head, CACHELINE_SIZE, 0); nova_memlock_inode(sb, pi); nova_dbg("%s: %lu inode nodes, pi head 0x%llx, tail 0x%llx\n", __func__, num_nodes, pi->log_head, pi->log_tail); } void nova_save_blocknode_mappings_to_log(struct super_block *sb) { struct nova_inode *pi = nova_get_inode_by_ino(sb, NOVA_BLOCKNODE_INO); struct nova_inode_info_header sih; struct nova_sb_info *sbi = NOVA_SB(sb); struct free_list *free_list; unsigned long num_blocknode = 0; unsigned long num_pages; int allocated; u64 new_block = 0; u64 temp_tail; int i; sih.ino = NOVA_BLOCKNODE_INO; sih.i_blk_type = NOVA_DEFAULT_BLOCK_TYPE; /* Allocate log pages before save blocknode mappings */ for (i = 0; i < sbi->cpus; i++) { free_list = nova_get_free_list(sb, i); num_blocknode += free_list->num_blocknode; nova_dbgv("%s: free list %d: %lu nodes\n", __func__, i, free_list->num_blocknode); } num_pages = num_blocknode / RANGENODE_PER_PAGE; if (num_blocknode % RANGENODE_PER_PAGE) num_pages++; allocated = nova_allocate_inode_log_pages(sb, &sih, num_pages, &new_block, ANY_CPU, 0); if (allocated != num_pages) { nova_dbg("Error saving blocknode mappings: %d\n", allocated); return; } temp_tail = new_block; for (i = 0; i < sbi->cpus; i++) temp_tail = nova_save_free_list_blocknodes(sb, i, temp_tail); /* Finally update log head and tail */ nova_memunlock_inode(sb, pi); pi->alter_log_head = pi->alter_log_tail = 0; pi->log_head = new_block; nova_update_tail(pi, temp_tail); nova_flush_buffer(&pi->log_head, CACHELINE_SIZE, 0); nova_memlock_inode(sb, pi); nova_dbg("%s: %lu blocknodes, %lu log pages, pi head 0x%llx, tail 0x%llx\n", __func__, num_blocknode, num_pages, pi->log_head, pi->log_tail); } static int nova_insert_blocknode_map(struct super_block *sb, int cpuid, unsigned long low, unsigned long high) { struct free_list *free_list; struct rb_root *tree; struct nova_range_node *blknode = NULL; unsigned long num_blocks = 0; int ret; num_blocks = high - low + 1; nova_dbgv("%s: cpu %d, low %lu, high %lu, num %lu\n", __func__, cpuid, low, high, num_blocks); free_list = nova_get_free_list(sb, cpuid); tree = &(free_list->block_free_tree); blknode = nova_alloc_blocknode(sb); if (blknode == NULL) return -ENOMEM; blknode->range_low = low; blknode->range_high = high; nova_update_range_node_checksum(blknode); ret = nova_insert_blocktree(tree, blknode); if (ret) { nova_err(sb, "%s failed\n", __func__); nova_free_blocknode(blknode); goto out; } if (!free_list->first_node) free_list->first_node = blknode; free_list->last_node = blknode; free_list->num_blocknode++; free_list->num_free_blocks += num_blocks; out: return ret; } static int __nova_build_blocknode_map(struct super_block *sb, unsigned long *bitmap, unsigned long bsize, unsigned long scale) { struct nova_sb_info *sbi = NOVA_SB(sb); struct free_list *free_list; unsigned long next = 0; unsigned long low = 0; unsigned long start, end; int cpuid = 0; free_list = nova_get_free_list(sb, cpuid); start = free_list->block_start; end = free_list->block_end + 1; while (1) { next = find_next_zero_bit(bitmap, end, start); if (next == bsize) break; if (next == end) { if (cpuid == sbi->cpus - 1) break; cpuid++; free_list = nova_get_free_list(sb, cpuid); start = free_list->block_start; end = free_list->block_end + 1; continue; } low = next; next = find_next_bit(bitmap, end, next); if (nova_insert_blocknode_map(sb, cpuid, low << scale, (next << scale) - 1)) { nova_dbg("Error: could not insert %lu - %lu\n", low << scale, ((next << scale) - 1)); } start = next; if (next == bsize) break; if (next == end) { if (cpuid == sbi->cpus - 1) break; cpuid++; free_list = nova_get_free_list(sb, cpuid); start = free_list->block_start; end = free_list->block_end + 1; } } return 0; } static void nova_update_4K_map(struct super_block *sb, struct scan_bitmap *bm, unsigned long *bitmap, unsigned long bsize, unsigned long scale) { unsigned long next = 0; unsigned long low = 0; int i; while (1) { next = find_next_bit(bitmap, bsize, next); if (next == bsize) break; low = next; next = find_next_zero_bit(bitmap, bsize, next); for (i = (low << scale); i < (next << scale); i++) set_bm(i, bm, BM_4K); if (next == bsize) break; } } struct scan_bitmap *global_bm[MAX_CPUS]; static int nova_build_blocknode_map(struct super_block *sb, unsigned long initsize) { struct nova_sb_info *sbi = NOVA_SB(sb); struct scan_bitmap *bm; struct scan_bitmap *final_bm; unsigned long *src, *dst; int i, j; int num; int ret; final_bm = kzalloc(sizeof(struct scan_bitmap), GFP_KERNEL); if (!final_bm) return -ENOMEM; final_bm->scan_bm_4K.bitmap_size = (initsize >> (PAGE_SHIFT + 0x3)); /* Alloc memory to hold the block alloc bitmap */ final_bm->scan_bm_4K.bitmap = kzalloc(final_bm->scan_bm_4K.bitmap_size, GFP_KERNEL); if (!final_bm->scan_bm_4K.bitmap) { kfree(final_bm); return -ENOMEM; } /* * We are using free lists. Set 2M and 1G blocks in 4K map, * and use 4K map to rebuild block map. */ for (i = 0; i < sbi->cpus; i++) { bm = global_bm[i]; nova_update_4K_map(sb, bm, bm->scan_bm_2M.bitmap, bm->scan_bm_2M.bitmap_size * 8, PAGE_SHIFT_2M - 12); nova_update_4K_map(sb, bm, bm->scan_bm_1G.bitmap, bm->scan_bm_1G.bitmap_size * 8, PAGE_SHIFT_1G - 12); } /* Merge per-CPU bms to the final single bm */ num = final_bm->scan_bm_4K.bitmap_size / sizeof(unsigned long); if (final_bm->scan_bm_4K.bitmap_size % sizeof(unsigned long)) num++; for (i = 0; i < sbi->cpus; i++) { bm = global_bm[i]; src = (unsigned long *)bm->scan_bm_4K.bitmap; dst = (unsigned long *)final_bm->scan_bm_4K.bitmap; for (j = 0; j < num; j++) dst[j] |= src[j]; } ret = __nova_build_blocknode_map(sb, final_bm->scan_bm_4K.bitmap, final_bm->scan_bm_4K.bitmap_size * 8, PAGE_SHIFT - 12); kfree(final_bm->scan_bm_4K.bitmap); kfree(final_bm); return ret; } static void free_bm(struct super_block *sb) { struct nova_sb_info *sbi = NOVA_SB(sb); struct scan_bitmap *bm; int i; for (i = 0; i < sbi->cpus; i++) { bm = global_bm[i]; if (bm) { kfree(bm->scan_bm_4K.bitmap); kfree(bm->scan_bm_2M.bitmap); kfree(bm->scan_bm_1G.bitmap); kfree(bm); } } } static int alloc_bm(struct super_block *sb, unsigned long initsize) { struct nova_sb_info *sbi = NOVA_SB(sb); struct scan_bitmap *bm; int i; for (i = 0; i < sbi->cpus; i++) { bm = kzalloc(sizeof(struct scan_bitmap), GFP_KERNEL); if (!bm) return -ENOMEM; global_bm[i] = bm; bm->scan_bm_4K.bitmap_size = (initsize >> (PAGE_SHIFT + 0x3)); bm->scan_bm_2M.bitmap_size = (initsize >> (PAGE_SHIFT_2M + 0x3)); bm->scan_bm_1G.bitmap_size = (initsize >> (PAGE_SHIFT_1G + 0x3)); /* Alloc memory to hold the block alloc bitmap */ bm->scan_bm_4K.bitmap = kzalloc(bm->scan_bm_4K.bitmap_size, GFP_KERNEL); bm->scan_bm_2M.bitmap = kzalloc(bm->scan_bm_2M.bitmap_size, GFP_KERNEL); bm->scan_bm_1G.bitmap = kzalloc(bm->scan_bm_1G.bitmap_size, GFP_KERNEL); if (!bm->scan_bm_4K.bitmap || !bm->scan_bm_2M.bitmap || !bm->scan_bm_1G.bitmap) return -ENOMEM; } return 0; } /************************** NOVA recovery ****************************/ #define MAX_PGOFF 262144 struct task_ring { u64 addr0[512]; u64 addr1[512]; /* Second inode address */ int num; int inodes_used_count; u64 *entry_array; u64 *nvmm_array; }; static struct task_ring *task_rings; static struct task_struct **threads; wait_queue_head_t finish_wq; int *finished; static int nova_traverse_inode_log(struct super_block *sb, struct nova_inode *pi, struct scan_bitmap *bm, u64 head) { u64 curr_p; u64 next; curr_p = head; if (curr_p == 0) return 0; BUG_ON(curr_p & (PAGE_SIZE - 1)); set_bm(curr_p >> PAGE_SHIFT, bm, BM_4K); next = next_log_page(sb, curr_p); while (next > 0) { curr_p = next; BUG_ON(curr_p & (PAGE_SIZE - 1)); set_bm(curr_p >> PAGE_SHIFT, bm, BM_4K); next = next_log_page(sb, curr_p); } return 0; } static void nova_traverse_dir_inode_log(struct super_block *sb, struct nova_inode *pi, struct scan_bitmap *bm) { nova_traverse_inode_log(sb, pi, bm, pi->log_head); if (metadata_csum) nova_traverse_inode_log(sb, pi, bm, pi->alter_log_head); } static unsigned int nova_check_old_entry(struct super_block *sb, struct nova_inode_info_header *sih, u64 entry_addr, unsigned long pgoff, unsigned int num_free, u64 epoch_id, struct task_ring *ring, unsigned long base, struct scan_bitmap *bm) { struct nova_file_write_entry *entry; struct nova_file_write_entry *entryc, entry_copy; unsigned long old_nvmm, nvmm; unsigned long index; int i; int ret; entry = (struct nova_file_write_entry *)entry_addr; if (!entry) return 0; if (metadata_csum == 0) entryc = entry; else { entryc = &entry_copy; if (!nova_verify_entry_csum(sb, entry, entryc)) return 0; } old_nvmm = get_nvmm(sb, sih, entryc, pgoff); ret = nova_append_data_to_snapshot(sb, entryc, old_nvmm, num_free, epoch_id); if (ret != 0) return ret; index = pgoff - base; for (i = 0; i < num_free; i++) { nvmm = ring->nvmm_array[index]; if (nvmm) set_bm(nvmm, bm, BM_4K); index++; } return ret; } static int nova_set_ring_array(struct super_block *sb, struct nova_inode_info_header *sih, struct nova_file_write_entry *entry, struct nova_file_write_entry *entryc, struct task_ring *ring, unsigned long base, struct scan_bitmap *bm) { unsigned long start, end; unsigned long pgoff, old_pgoff = 0; unsigned long index; unsigned int num_free = 0; u64 old_entry = 0; u64 epoch_id = entryc->epoch_id; start = entryc->pgoff; if (start < base) start = base; end = entryc->pgoff + entryc->num_pages; if (end > base + MAX_PGOFF) end = base + MAX_PGOFF; for (pgoff = start; pgoff < end; pgoff++) { index = pgoff - base; if (ring->nvmm_array[index]) { if (ring->entry_array[index] != old_entry) { if (old_entry) nova_check_old_entry(sb, sih, old_entry, old_pgoff, num_free, epoch_id, ring, base, bm); old_entry = ring->entry_array[index]; old_pgoff = pgoff; num_free = 1; } else { num_free++; } } } if (old_entry) nova_check_old_entry(sb, sih, old_entry, old_pgoff, num_free, epoch_id, ring, base, bm); for (pgoff = start; pgoff < end; pgoff++) { index = pgoff - base; ring->entry_array[index] = (u64)entry; ring->nvmm_array[index] = (u64)(entryc->block >> PAGE_SHIFT) + pgoff - entryc->pgoff; } return 0; } static int nova_set_file_bm(struct super_block *sb, struct nova_inode_info_header *sih, struct task_ring *ring, struct scan_bitmap *bm, unsigned long base, unsigned long last_blocknr) { unsigned long nvmm, pgoff; if (last_blocknr >= base + MAX_PGOFF) last_blocknr = MAX_PGOFF - 1; else last_blocknr -= base; for (pgoff = 0; pgoff <= last_blocknr; pgoff++) { nvmm = ring->nvmm_array[pgoff]; if (nvmm) { set_bm(nvmm, bm, BM_4K); ring->nvmm_array[pgoff] = 0; ring->entry_array[pgoff] = 0; } } return 0; } /* entry given to this function is a copy in dram */ static void nova_ring_setattr_entry(struct super_block *sb, struct nova_inode_info_header *sih, struct nova_setattr_logentry *entry, struct task_ring *ring, unsigned long base, unsigned int data_bits, struct scan_bitmap *bm) { unsigned long first_blocknr, last_blocknr; unsigned long pgoff, old_pgoff = 0; unsigned long index; unsigned int num_free = 0; u64 old_entry = 0; loff_t start, end; u64 epoch_id = entry->epoch_id; if (sih->i_size <= entry->size) goto out; start = entry->size; end = sih->i_size; first_blocknr = (start + (1UL << data_bits) - 1) >> data_bits; if (end > 0) last_blocknr = (end - 1) >> data_bits; else last_blocknr = 0; if (first_blocknr > last_blocknr) goto out; if (first_blocknr < base) first_blocknr = base; if (last_blocknr > base + MAX_PGOFF - 1) last_blocknr = base + MAX_PGOFF - 1; for (pgoff = first_blocknr; pgoff <= last_blocknr; pgoff++) { index = pgoff - base; if (ring->nvmm_array[index]) { if (ring->entry_array[index] != old_entry) { if (old_entry) nova_check_old_entry(sb, sih, old_entry, old_pgoff, num_free, epoch_id, ring, base, bm); old_entry = ring->entry_array[index]; old_pgoff = pgoff; num_free = 1; } else { num_free++; } } } if (old_entry) nova_check_old_entry(sb, sih, old_entry, old_pgoff, num_free, epoch_id, ring, base, bm); for (pgoff = first_blocknr; pgoff <= last_blocknr; pgoff++) { index = pgoff - base; ring->nvmm_array[index] = 0; ring->entry_array[index] = 0; } out: sih->i_size = entry->size; } static unsigned long nova_traverse_file_write_entry(struct super_block *sb, struct nova_inode_info_header *sih, struct nova_file_write_entry *entry, struct nova_file_write_entry *entryc, struct task_ring *ring, unsigned long base, struct scan_bitmap *bm) { unsigned long max_blocknr = 0; sih->i_size = entryc->size; if (entryc->num_pages != entryc->invalid_pages) { max_blocknr = entryc->pgoff + entryc->num_pages - 1; if (entryc->pgoff < base + MAX_PGOFF && entryc->pgoff + entryc->num_pages > base) nova_set_ring_array(sb, sih, entry, entryc, ring, base, bm); } return max_blocknr; } static int nova_traverse_file_inode_log(struct super_block *sb, struct nova_inode *pi, struct nova_inode_info_header *sih, struct task_ring *ring, struct scan_bitmap *bm) { char entry_copy[NOVA_MAX_ENTRY_LEN]; unsigned long base = 0; unsigned long last_blocknr = 0, curr_last; u64 ino = pi->nova_ino; void *entry, *entryc; unsigned int btype; unsigned int data_bits; u64 curr_p; u64 next; u8 type; btype = pi->i_blk_type; data_bits = blk_type_to_shift[btype]; if (metadata_csum) nova_traverse_inode_log(sb, pi, bm, pi->alter_log_head); entryc = (metadata_csum == 0) ? NULL : entry_copy; again: curr_p = pi->log_head; nova_dbg_verbose("Log head 0x%llx, tail 0x%llx\n", curr_p, pi->log_tail); if (curr_p == 0 && pi->log_tail == 0) return 0; if (base == 0) { BUG_ON(curr_p & (PAGE_SIZE - 1)); set_bm(curr_p >> PAGE_SHIFT, bm, BM_4K); } while (curr_p != pi->log_tail) { if (goto_next_page(sb, curr_p)) { curr_p = next_log_page(sb, curr_p); if (base == 0) { BUG_ON(curr_p & (PAGE_SIZE - 1)); set_bm(curr_p >> PAGE_SHIFT, bm, BM_4K); } } if (curr_p == 0) { nova_err(sb, "File inode %llu log is NULL!\n", ino); BUG(); } entry = (void *)nova_get_block(sb, curr_p); if (metadata_csum == 0) entryc = entry; else if (!nova_verify_entry_csum(sb, entry, entryc)) return 0; type = nova_get_entry_type(entryc); switch (type) { case SET_ATTR: nova_ring_setattr_entry(sb, sih, SENTRY(entryc), ring, base, data_bits, bm); curr_p += sizeof(struct nova_setattr_logentry); break; case LINK_CHANGE: curr_p += sizeof(struct nova_link_change_entry); break; case FILE_WRITE: curr_last = nova_traverse_file_write_entry(sb, sih, WENTRY(entry), WENTRY(entryc), ring, base, bm); curr_p += sizeof(struct nova_file_write_entry); if (last_blocknr < curr_last) last_blocknr = curr_last; break; case MMAP_WRITE: curr_p += sizeof(struct nova_mmap_entry); break; default: nova_dbg("%s: unknown type %d, 0x%llx\n", __func__, type, curr_p); NOVA_ASSERT(0); BUG(); } } if (base == 0) { /* Keep traversing until log ends */ curr_p &= PAGE_MASK; next = next_log_page(sb, curr_p); while (next > 0) { curr_p = next; BUG_ON(curr_p & (PAGE_SIZE - 1)); set_bm(curr_p >> PAGE_SHIFT, bm, BM_4K); next = next_log_page(sb, curr_p); } } nova_set_file_bm(sb, sih, ring, bm, base, last_blocknr); if (last_blocknr >= base + MAX_PGOFF) { base += MAX_PGOFF; goto again; } return 0; } /* Pi is DRAM fake version */ static int nova_recover_inode_pages(struct super_block *sb, struct nova_inode_info_header *sih, struct task_ring *ring, struct nova_inode *pi, struct scan_bitmap *bm) { unsigned long nova_ino; if (pi->deleted == 1) return 0; nova_ino = pi->nova_ino; ring->inodes_used_count++; sih->i_mode = __le16_to_cpu(pi->i_mode); sih->ino = nova_ino; nova_dbgv("%s: inode %lu, head 0x%llx, tail 0x%llx\n", __func__, nova_ino, pi->log_head, pi->log_tail); switch (__le16_to_cpu(pi->i_mode) & S_IFMT) { case S_IFDIR: nova_traverse_dir_inode_log(sb, pi, bm); break; case S_IFLNK: /* Treat symlink files as normal files */ /* Fall through */ case S_IFREG: /* Fall through */ default: /* In case of special inode, walk the log */ nova_traverse_file_inode_log(sb, pi, sih, ring, bm); break; } return 0; } static void free_resources(struct super_block *sb) { struct nova_sb_info *sbi = NOVA_SB(sb); struct task_ring *ring; int i; if (task_rings) { for (i = 0; i < sbi->cpus; i++) { ring = &task_rings[i]; vfree(ring->entry_array); vfree(ring->nvmm_array); ring->entry_array = NULL; ring->nvmm_array = NULL; } } kfree(task_rings); kfree(threads); kfree(finished); } static int failure_thread_func(void *data); static int allocate_resources(struct super_block *sb, int cpus) { struct task_ring *ring; int i; task_rings = kcalloc(cpus, sizeof(struct task_ring), GFP_KERNEL); if (!task_rings) goto fail; for (i = 0; i < cpus; i++) { ring = &task_rings[i]; ring->nvmm_array = vzalloc(sizeof(u64) * MAX_PGOFF); if (!ring->nvmm_array) goto fail; ring->entry_array = vmalloc(sizeof(u64) * MAX_PGOFF); if (!ring->entry_array) goto fail; } threads = kcalloc(cpus, sizeof(struct task_struct *), GFP_KERNEL); if (!threads) goto fail; finished = kcalloc(cpus, sizeof(int), GFP_KERNEL); if (!finished) goto fail; init_waitqueue_head(&finish_wq); for (i = 0; i < cpus; i++) { threads[i] = kthread_create(failure_thread_func, sb, "recovery thread"); kthread_bind(threads[i], i); } return 0; fail: free_resources(sb); return -ENOMEM; } static void wait_to_finish(int cpus) { int i; for (i = 0; i < cpus; i++) { while (finished[i] == 0) { wait_event_interruptible_timeout(finish_wq, false, msecs_to_jiffies(1)); } } } /*********************** Failure recovery *************************/ static inline int nova_failure_update_inodetree(struct super_block *sb, struct nova_inode *pi, unsigned long *ino_low, unsigned long *ino_high) { struct nova_sb_info *sbi = NOVA_SB(sb); if (*ino_low == 0) { *ino_low = *ino_high = pi->nova_ino; } else { if (pi->nova_ino == *ino_high + sbi->cpus) { *ino_high = pi->nova_ino; } else { /* A new start */ nova_failure_insert_inodetree(sb, *ino_low, *ino_high); *ino_low = *ino_high = pi->nova_ino; } } return 0; } static int failure_thread_func(void *data) { struct super_block *sb = data; struct nova_inode_info_header sih; struct task_ring *ring; struct nova_inode *pi, fake_pi; unsigned long num_inodes_per_page; unsigned long ino_low, ino_high; unsigned long last_blocknr; unsigned int data_bits; u64 curr, curr1; int cpuid = nova_get_cpuid(sb); unsigned long i; unsigned long max_size = 0; u64 pi_addr = 0; int ret = 0; int count; pi = nova_get_inode_by_ino(sb, NOVA_INODETABLE_INO); data_bits = blk_type_to_shift[pi->i_blk_type]; num_inodes_per_page = 1 << (data_bits - NOVA_INODE_BITS); ring = &task_rings[cpuid]; nova_init_header(sb, &sih, 0); for (count = 0; count < ring->num; count++) { curr = ring->addr0[count]; curr1 = ring->addr1[count]; ino_low = ino_high = 0; /* * Note: The inode log page is allocated in 2MB * granularity, but not aligned on 2MB boundary. */ for (i = 0; i < 512; i++) set_bm((curr >> PAGE_SHIFT) + i, global_bm[cpuid], BM_4K); if (metadata_csum) { for (i = 0; i < 512; i++) set_bm((curr1 >> PAGE_SHIFT) + i, global_bm[cpuid], BM_4K); } for (i = 0; i < num_inodes_per_page; i++) { pi_addr = curr + i * NOVA_INODE_SIZE; ret = nova_get_reference(sb, pi_addr, &fake_pi, (void **)&pi, sizeof(struct nova_inode)); if (ret) { nova_dbg("Recover pi @ 0x%llx failed\n", pi_addr); continue; } /* FIXME: Check inode checksum */ if (fake_pi.i_mode && fake_pi.deleted == 0) { if (fake_pi.valid == 0) { ret = nova_append_inode_to_snapshot(sb, pi); if (ret != 0) { /* Deleteable */ pi->deleted = 1; fake_pi.deleted = 1; continue; } } nova_recover_inode_pages(sb, &sih, ring, &fake_pi, global_bm[cpuid]); nova_failure_update_inodetree(sb, pi, &ino_low, &ino_high); if (sih.i_size > max_size) max_size = sih.i_size; } } if (ino_low && ino_high) nova_failure_insert_inodetree(sb, ino_low, ino_high); } /* Free radix tree */ if (max_size) { last_blocknr = (max_size - 1) >> PAGE_SHIFT; nova_delete_file_tree(sb, &sih, 0, last_blocknr, false, false, 0); } finished[cpuid] = 1; wake_up_interruptible(&finish_wq); do_exit(ret); return ret; } static int nova_failure_recovery_crawl(struct super_block *sb) { struct nova_sb_info *sbi = NOVA_SB(sb); struct nova_inode_info_header sih; struct inode_table *inode_table; struct task_ring *ring; struct nova_inode *pi, fake_pi; unsigned long curr_addr; u64 root_addr; u64 curr; int num_tables; int version; int ret = 0; int count; int cpuid; root_addr = nova_get_reserved_inode_addr(sb, NOVA_ROOT_INO); num_tables = 1; if (metadata_csum) num_tables = 2; for (cpuid = 0; cpuid < sbi->cpus; cpuid++) { ring = &task_rings[cpuid]; for (version = 0; version < num_tables; version++) { inode_table = nova_get_inode_table(sb, version, cpuid); if (!inode_table) return -EINVAL; count = 0; curr = inode_table->log_head; while (curr) { if (ring->num >= 512) { nova_err(sb, "%s: ring size too small\n", __func__); return -EINVAL; } if (version == 0) ring->addr0[count] = curr; else ring->addr1[count] = curr; count++; curr_addr = (unsigned long)nova_get_block(sb, curr); /* Next page resides at the last 8 bytes */ curr_addr += 2097152 - 8; curr = *(u64 *)(curr_addr); } if (count > ring->num) ring->num = count; } } for (cpuid = 0; cpuid < sbi->cpus; cpuid++) wake_up_process(threads[cpuid]); nova_init_header(sb, &sih, 0); /* Recover the root iode */ ret = nova_get_reference(sb, root_addr, &fake_pi, (void **)&pi, sizeof(struct nova_inode)); if (ret) { nova_dbg("Recover root pi failed\n"); return ret; } nova_recover_inode_pages(sb, &sih, &task_rings[0], &fake_pi, global_bm[1]); return ret; } int nova_failure_recovery(struct super_block *sb) { struct nova_sb_info *sbi = NOVA_SB(sb); struct task_ring *ring; struct nova_inode *pi; struct journal_ptr_pair *pair; int ret; int i; sbi->s_inodes_used_count = 0; /* Initialize inuse inode list */ if (nova_init_inode_inuse_list(sb) < 0) return -EINVAL; /* Handle special inodes */ pi = nova_get_inode_by_ino(sb, NOVA_BLOCKNODE_INO); pi->log_head = pi->log_tail = 0; nova_flush_buffer(&pi->log_head, CACHELINE_SIZE, 0); for (i = 0; i < sbi->cpus; i++) { pair = nova_get_journal_pointers(sb, i); set_bm(pair->journal_head >> PAGE_SHIFT, global_bm[i], BM_4K); } i = NOVA_SNAPSHOT_INO % sbi->cpus; pi = nova_get_inode_by_ino(sb, NOVA_SNAPSHOT_INO); /* Set snapshot info log pages */ nova_traverse_dir_inode_log(sb, pi, global_bm[i]); PERSISTENT_BARRIER(); ret = allocate_resources(sb, sbi->cpus); if (ret) return ret; ret = nova_failure_recovery_crawl(sb); wait_to_finish(sbi->cpus); for (i = 0; i < sbi->cpus; i++) { ring = &task_rings[i]; sbi->s_inodes_used_count += ring->inodes_used_count; } free_resources(sb); nova_dbg("Failure recovery total recovered %lu\n", sbi->s_inodes_used_count - NOVA_NORMAL_INODE_START); return ret; } /*********************** Recovery entrance *************************/ /* Return TRUE if we can do a normal unmount recovery */ static bool nova_try_normal_recovery(struct super_block *sb) { struct nova_sb_info *sbi = NOVA_SB(sb); struct nova_inode *pi = nova_get_inode_by_ino(sb, NOVA_BLOCKNODE_INO); int ret; if (pi->log_head == 0 || pi->log_tail == 0) return false; ret = nova_init_blockmap_from_inode(sb); if (ret) { nova_err(sb, "init blockmap failed, fall back to failure recovery\n"); return false; } ret = nova_init_inode_list_from_inode(sb); if (ret) { nova_err(sb, "init inode list failed, fall back to failure recovery\n"); nova_destroy_blocknode_trees(sb); return false; } if (sbi->mount_snapshot == 0) { ret = nova_restore_snapshot_table(sb, 0); if (ret) { nova_err(sb, "Restore snapshot table failed, fall back to failure recovery\n"); nova_destroy_snapshot_infos(sb); return false; } } return true; } /* * Recovery routine has three tasks: * 1. Restore snapshot table; * 2. Restore inuse inode list; * 3. Restore the NVMM allocator. */ int nova_recovery(struct super_block *sb) { struct nova_sb_info *sbi = NOVA_SB(sb); struct nova_super_block *super = sbi->nova_sb; unsigned long initsize = le64_to_cpu(super->s_size); bool value = false; int ret = 0; timing_t start, end; nova_dbgv("%s\n", __func__); /* Always check recovery time */ if (measure_timing == 0) getrawmonotonic(&start); NOVA_START_TIMING(recovery_t, start); sbi->num_blocks = ((unsigned long)(initsize) >> PAGE_SHIFT); /* initialize free list info */ nova_init_blockmap(sb, 1); value = nova_try_normal_recovery(sb); if (value) { nova_dbg("NOVA: Normal shutdown\n"); } else { nova_dbg("NOVA: Failure recovery\n"); ret = alloc_bm(sb, initsize); if (ret) goto out; if (sbi->mount_snapshot == 0) { /* Initialize the snapshot infos */ ret = nova_restore_snapshot_table(sb, 1); if (ret) { nova_dbg("Initialize snapshot infos failed\n"); nova_destroy_snapshot_infos(sb); goto out; } } sbi->s_inodes_used_count = 0; ret = nova_failure_recovery(sb); if (ret) goto out; ret = nova_build_blocknode_map(sb, initsize); } out: NOVA_END_TIMING(recovery_t, start); if (measure_timing == 0) { getrawmonotonic(&end); Timingstats[recovery_t] += (end.tv_sec - start.tv_sec) * 1000000000 + (end.tv_nsec - start.tv_nsec); } if (!value) free_bm(sb); sbi->s_epoch_id = le64_to_cpu(super->s_epoch_id); return ret; }
24.751568
82
0.688827
b7de7692cfcf516ff030594f442f396b15c494fd
272
h
C
UIButtonDemo/UIButtonDemo/Manager.h
leixiang1986/exercise_ios_projects
aafde468ba018115f3de233705e5e4683bced1b0
[ "MIT" ]
null
null
null
UIButtonDemo/UIButtonDemo/Manager.h
leixiang1986/exercise_ios_projects
aafde468ba018115f3de233705e5e4683bced1b0
[ "MIT" ]
null
null
null
UIButtonDemo/UIButtonDemo/Manager.h
leixiang1986/exercise_ios_projects
aafde468ba018115f3de233705e5e4683bced1b0
[ "MIT" ]
null
null
null
// // Manager.h // UIButtonDemo // // Created by mac on 2018/12/13. // Copyright © 2018年 mac. All rights reserved. // #import <Foundation/Foundation.h> NS_ASSUME_NONNULL_BEGIN @interface Manager : NSObject + (instancetype)shareInstance; @end NS_ASSUME_NONNULL_END
15.111111
47
0.731618
b7e0f9d05e23a1aef1f70fd3e126f36e4888e4f7
2,202
h
C
scene/texture/checkerboard.h
dinowernli/raytracer
b1af14b2d2a02fe679da392aaf25385b69efee1b
[ "MIT" ]
null
null
null
scene/texture/checkerboard.h
dinowernli/raytracer
b1af14b2d2a02fe679da392aaf25385b69efee1b
[ "MIT" ]
null
null
null
scene/texture/checkerboard.h
dinowernli/raytracer
b1af14b2d2a02fe679da392aaf25385b69efee1b
[ "MIT" ]
null
null
null
// The MIT License (MIT) // // Copyright (c) 2015 dinowernli // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. /* * A 2D texture which produces a checkerboard. * Author: Dino Wernli */ #ifndef CHECKERBOARD_H_ #define CHECKERBOARD_H_ #include <glog/logging.h> #include "scene/texture/texture_2d.h" class Checkerboard : public Texture2D { public: // Multiplies the supplied length by 2 in order to get the desired alternating // pattern. // TODO(dinow): In order to support arbitrary lengths, the tex coordinates // should not be in [0, 1] but in [-inf, inf]. Checkerboard(Color3 first = Color3(0, 0, 0), Color3 second = Color3(1, 1, 1), size_t length = 1) : first_(first), second_(second), length_(2 * length) {} virtual ~Checkerboard() {} protected: virtual Color3 Evaluate2D(const IntersectionData& data) const { long sss = floor(data.texture_coordinate.s * length_); long ttt = floor(data.texture_coordinate.t * length_); if ((sss & 1) == (ttt & 1)) { return first_; } else { return second_; } } private: Color3 first_; Color3 second_; size_t length_; }; #endif /* CHECKERBOARD_H_ */
33.876923
81
0.714805
b7e1203fe8d11235b911e70d98def07c78ca6d2e
17,112
c
C
source-embedded/CcspCwmpAcsConnection/ccsp_cwmp_acsco_base.c
lgirdk/ccsp-tr069-pa
bc97aba2630d9ed11f81b2442c35c7fcd60a650f
[ "Apache-2.0" ]
5
2018-01-05T04:18:55.000Z
2020-05-28T06:59:52.000Z
source-embedded/CcspCwmpAcsConnection/ccsp_cwmp_acsco_base.c
rdkcmf/rdkb-CcspTr069Pa
bc97aba2630d9ed11f81b2442c35c7fcd60a650f
[ "Apache-2.0" ]
null
null
null
source-embedded/CcspCwmpAcsConnection/ccsp_cwmp_acsco_base.c
rdkcmf/rdkb-CcspTr069Pa
bc97aba2630d9ed11f81b2442c35c7fcd60a650f
[ "Apache-2.0" ]
6
2017-07-30T15:42:55.000Z
2022-02-21T16:51:28.000Z
/* * If not stated otherwise in this file or this component's Licenses.txt file the * following copyright and licenses apply: * * Copyright 2015 RDK Management * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /********************************************************************** Copyright [2014] [Cisco Systems, Inc.] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. **********************************************************************/ /********************************************************************** module: ccsp_cwmp_acsco_base.c For CCSP CWMP protocol implementation --------------------------------------------------------------- description: This module implements the basic container object functions of the CCSP CWMP ACS Connection Object. * CcspCwmpAcscoCreate * CcspCwmpAcscoRemove * CcspCwmpAcscoEnrollObjects * CcspCwmpAcscoInitialize --------------------------------------------------------------- environment: platform independent --------------------------------------------------------------- author: Bin Zhu Kang Quan --------------------------------------------------------------- revision: 09/21/05 initial revision. 10/13/11 resolve name conflict with DM library **********************************************************************/ #include "ccsp_cwmp_acsco_global.h" #include <stdbool.h> #define TR069_HOSTS_CFG "/usr/ccsp/tr069pa/tr69Hosts.cfg" char **hostNames = NULL; int numHosts = 0; /********************************************************************** caller: owner of the object prototype: ANSC_HANDLE CcspCwmpAcscoCreate ( ANSC_HANDLE hContainerContext, ANSC_HANDLE hOwnerContext, ANSC_HANDLE hAnscReserved ); description: This function constructs the ACS Connection Object and initializes the member variables and functions. argument: ANSC_HANDLE hContainerContext This handle is used by the container object to interact with the outside world. It could be the real container or an target object. ANSC_HANDLE hOwnerContext This handle is passed in by the owner of this object. ANSC_HANDLE hAnscReserved This handle is passed in by the owner of this object. return: newly created container object. **********************************************************************/ ANSC_HANDLE CcspCwmpAcscoCreate ( ANSC_HANDLE hContainerContext, ANSC_HANDLE hOwnerContext, ANSC_HANDLE hAnscReserved ) { UNREFERENCED_PARAMETER(hAnscReserved); PANSC_COMPONENT_OBJECT pBaseObject = NULL; PCCSP_CWMP_ACS_CONNECTION_OBJECT pMyObject = NULL; /* * We create object by first allocating memory for holding the variables and member functions. */ pMyObject = (PCCSP_CWMP_ACS_CONNECTION_OBJECT)CcspTr069PaAllocateMemory(sizeof(CCSP_CWMP_ACS_CONNECTION_OBJECT)); if ( !pMyObject ) { return (ANSC_HANDLE)NULL; } else { pBaseObject = (PANSC_COMPONENT_OBJECT)pMyObject; } /* * Initialize the common variables and functions for a container object. */ /* AnscCopyString(pBaseObject->Name, CCSP_CWMP_ACS_CONNECTION_NAME); */ pBaseObject->hContainerContext = hContainerContext; pBaseObject->hOwnerContext = hOwnerContext; pBaseObject->Oid = CCSP_CWMP_ACS_CONNECTION_OID; pBaseObject->Create = CcspCwmpAcscoCreate; pBaseObject->Remove = CcspCwmpAcscoRemove; pBaseObject->EnrollObjects = CcspCwmpAcscoEnrollObjects; pBaseObject->Initialize = CcspCwmpAcscoInitialize; pBaseObject->EnrollObjects((ANSC_HANDLE)pBaseObject); pBaseObject->Initialize ((ANSC_HANDLE)pBaseObject); return (ANSC_HANDLE)pMyObject; } /********************************************************************** caller: owner of this object prototype: ANSC_STATUS CcspCwmpAcscoRemove ( ANSC_HANDLE hThisObject ); description: This function destroys the object. argument: ANSC_HANDLE hThisObject This handle is actually the pointer of this object itself. return: status of operation. **********************************************************************/ ANSC_STATUS CcspCwmpAcscoRemove ( ANSC_HANDLE hThisObject ) { PCCSP_CWMP_ACS_CONNECTION_OBJECT pMyObject = (PCCSP_CWMP_ACS_CONNECTION_OBJECT)hThisObject; PHTTP_BSP_INTERFACE pHttpBspIf = (PHTTP_BSP_INTERFACE )pMyObject->hHttpBspIf; PHTTP_ACM_INTERFACE pHttpAcmIf = (PHTTP_ACM_INTERFACE )pMyObject->hHttpAcmIf; PHTTP_SIMPLE_CLIENT_OBJECT pHttpClient = (PHTTP_SIMPLE_CLIENT_OBJECT)pMyObject->hHttpSimpleClient; pMyObject->Reset((ANSC_HANDLE)pMyObject); pMyObject->RemoveCookies(hThisObject); if( pMyObject->AcsUrl != NULL) { CcspTr069PaFreeMemory(pMyObject->AcsUrl); pMyObject->AcsUrl = NULL; } if( pMyObject->Username != NULL) { CcspTr069PaFreeMemory(pMyObject->Username); pMyObject->Username = NULL; } if( pMyObject->Password != NULL) { CcspTr069PaFreeMemory(pMyObject->Password); pMyObject->Password = NULL; } if ( pMyObject->AuthHeaderValue ) { CcspTr069PaFreeMemory(pMyObject->AuthHeaderValue); pMyObject->AuthHeaderValue = NULL; } if ( pHttpBspIf ) { CcspTr069PaFreeMemory(pHttpBspIf); pMyObject->hHttpBspIf = (ANSC_HANDLE)NULL; } if ( pHttpAcmIf ) { CcspTr069PaFreeMemory(pHttpAcmIf); pMyObject->hHttpAcmIf = (ANSC_HANDLE)NULL; } if( pHttpClient != NULL) { pHttpClient->Remove(pHttpClient); } AnscCoRemove((ANSC_HANDLE)pMyObject); return ANSC_STATUS_SUCCESS; } #define DEVICE_PROPERTIES "/etc/device.properties" static int bIsComcastImage( void) { static int isComcastImage = -1; if (isComcastImage == -1) { char PartnerId[255] = {'\0'}; errno_t rc = -1; int ind = -1; getPartnerId ( PartnerId ) ; rc = strcmp_s("comcast", strlen("comcast"), PartnerId, &ind); ERR_CHK(rc); if((rc == EOK) && (ind != 0)) isComcastImage = 0; else isComcastImage = 1; } return isComcastImage; } char **getHostNames() { static bool initialized = false; /* To load hostnames configuration file only once*/ if(!initialized) { FILE *fp; fp = fopen(TR069_HOSTS_CFG, "r"); if(fp != NULL) { char ch; char tempHost[128] = {'\0'}; while(!feof(fp)) { ch = fgetc(fp); if(ch == '\n') numHosts++; } if(numHosts > 0) { hostNames = (char **)malloc(sizeof(char *) * numHosts); int i = 0; fseek(fp, 0, SEEK_SET); while(fgets(tempHost, 128, fp) != NULL) { hostNames[i] = strndup(tempHost, strlen(tempHost)-1); i++; } } fclose(fp); } else { numHosts = 0; hostNames = NULL; } initialized = true; } return hostNames; } /********************************************************************** caller: owner of this object prototype: ANSC_STATUS CcspCwmpAcscoEnrollObjects ( ANSC_HANDLE hThisObject ); description: This function enrolls all the objects required by this object. argument: ANSC_HANDLE hThisObject This handle is actually the pointer of this object itself. return: status of operation. **********************************************************************/ ANSC_STATUS CcspCwmpAcscoEnrollObjects ( ANSC_HANDLE hThisObject ) { PCCSP_CWMP_ACS_CONNECTION_OBJECT pMyObject = (PCCSP_CWMP_ACS_CONNECTION_OBJECT)hThisObject; PHTTP_BSP_INTERFACE pHttpBspIf = (PHTTP_BSP_INTERFACE )pMyObject->hHttpBspIf; PHTTP_ACM_INTERFACE pHttpAcmIf = (PHTTP_ACM_INTERFACE )pMyObject->hHttpAcmIf; PHTTP_SIMPLE_CLIENT_OBJECT pHttpClient = (PHTTP_SIMPLE_CLIENT_OBJECT)NULL; errno_t rc = -1; HTTP_SCO_HOST_NAMES hosts; if ( !pHttpBspIf ) { pHttpBspIf = (PHTTP_BSP_INTERFACE)CcspTr069PaAllocateMemory(sizeof(HTTP_BSP_INTERFACE)); if ( !pHttpBspIf ) { return ANSC_STATUS_RESOURCES; } else { pMyObject->hHttpBspIf = (ANSC_HANDLE)pHttpBspIf; } rc = strcpy_s(pHttpBspIf->Name, sizeof(pHttpBspIf->Name), HTTP_BSP_INTERFACE_NAME); if(rc != EOK) { ERR_CHK(rc); return ANSC_STATUS_FAILURE; } pHttpBspIf->InterfaceId = HTTP_BSP_INTERFACE_ID; pHttpBspIf->hOwnerContext = (ANSC_HANDLE)pMyObject; pHttpBspIf->Size = sizeof(HTTP_BSP_INTERFACE); pHttpBspIf->Polish = CcspCwmpAcscoHttpBspPolish; pHttpBspIf->Browse = CcspCwmpAcscoHttpBspBrowse; pHttpBspIf->Notify = CcspCwmpAcscoHttpBspNotify; } if ( !pHttpAcmIf ) { pHttpAcmIf = (PHTTP_ACM_INTERFACE)CcspTr069PaAllocateMemory(sizeof(HTTP_ACM_INTERFACE)); if ( !pHttpAcmIf ) { return ANSC_STATUS_RESOURCES; } else { pMyObject->hHttpAcmIf = (ANSC_HANDLE)pHttpAcmIf; } pHttpAcmIf->hOwnerContext = (ANSC_HANDLE)pMyObject; pHttpAcmIf->Size = sizeof(HTTP_ACM_INTERFACE); pHttpAcmIf->GetCredential = CcspCwmpAcscoHttpGetCredential; } /* * Create Http Simple Client */ pHttpClient = (PHTTP_SIMPLE_CLIENT_OBJECT)HttpCreateSimpleClient ( (ANSC_HANDLE)pMyObject->hHttpHelpContainer, (ANSC_HANDLE)pMyObject, (ANSC_HANDLE)NULL ); if( pHttpClient == NULL) { return ANSC_STATUS_RESOURCES; } pHttpClient->SetProductName(pHttpClient, "HTTP Client V1.0"); pHttpClient->SetBspIf((ANSC_HANDLE)pHttpClient, pMyObject->hHttpBspIf); pHttpClient->SetClientMode(pHttpClient, HTTP_SCO_MODE_XSOCKET | HTTP_SCO_MODE_COMPACT | HTTP_SCO_MODE_NOTIFY_ON_ALL_CONN_ONCE); memset(&hosts, 0, sizeof(HTTP_SCO_HOST_NAMES)); if ( bIsComcastImage() && getHostNames() != NULL) { char **phostNames = NULL; int i = 0; phostNames = getHostNames(); CcspTraceInfo(("Adding hostnames for validation\n")); hosts.peerVerify = TRUE; hosts.numHosts = numHosts; hosts.hostNames = (char **)malloc(sizeof(char *)*numHosts); for(i = 0; i<numHosts; i++) { if(phostNames[i] != NULL) { hosts.hostNames[i] = strdup(phostNames[i]); } } } pHttpClient->SetHostNames(pHttpClient, &hosts); pMyObject->hHttpSimpleClient = (ANSC_HANDLE)pHttpClient; AnscCoEnrollObjects((ANSC_HANDLE)pMyObject); return ANSC_STATUS_SUCCESS; } /********************************************************************** caller: owner of this object prototype: ANSC_STATUS CcspCwmpAcscoInitialize ( ANSC_HANDLE hThisObject ); description: This function first calls the initialization member function of the base class object to set the common member fields inherited from the base class. It then initializes the member fields that are specific to this object. argument: ANSC_HANDLE hThisObject This handle is actually the pointer of this object itself. return: status of operation. **********************************************************************/ ANSC_STATUS CcspCwmpAcscoInitialize ( ANSC_HANDLE hThisObject ) { PCCSP_CWMP_ACS_CONNECTION_OBJECT pMyObject = (PCCSP_CWMP_ACS_CONNECTION_OBJECT)hThisObject; /* * Until you have to simulate C++ object-oriented programming style with standard C, you don't * appreciate all the nice little things come with C++ language and all the dirty works that * have been done by the C++ compilers. Member initialization is one of these things. While in * C++ you don't have to initialize all the member fields inherited from the base class since * the compiler will do it for you, such is not the case with C. */ AnscCoInitialize((ANSC_HANDLE)pMyObject); /* * Although we have initialized some of the member fields in the "create" member function, we * repeat the work here for completeness. While this simulation approach is pretty stupid from * a C++/Java programmer perspective, it's the best we can get for universal embedded network * programming. Before we develop our own operating system (don't expect that to happen any * time soon), this is the way things gonna be. */ pMyObject->Oid = CCSP_CWMP_ACS_CONNECTION_OID; pMyObject->Create = CcspCwmpAcscoCreate; pMyObject->Remove = CcspCwmpAcscoRemove; pMyObject->EnrollObjects = CcspCwmpAcscoEnrollObjects; pMyObject->Initialize = CcspCwmpAcscoInitialize; pMyObject->hCcspCwmpSession = NULL; pMyObject->AcsUrl = NULL; pMyObject->Username = NULL; pMyObject->Password = NULL; pMyObject->AuthHeaderValue = NULL; pMyObject->bActive = FALSE; AnscZeroMemory(pMyObject->Cookies, CCSP_CWMP_ACSCO_MAX_COOKIE * sizeof(char *)); pMyObject->NumCookies = 0; pMyObject->GetHttpSimpleClient = CcspCwmpAcscoGetHttpSimpleClient; pMyObject->GetCcspCwmpSession = CcspCwmpAcscoGetCcspCwmpSession; pMyObject->SetCcspCwmpSession = CcspCwmpAcscoSetCcspCwmpSession; pMyObject->GetAcsUrl = CcspCwmpAcscoGetAcsUrl; pMyObject->SetAcsUrl = CcspCwmpAcscoSetAcsUrl; pMyObject->GetUsername = CcspCwmpAcscoGetUsername; pMyObject->SetUsername = CcspCwmpAcscoSetUsername; pMyObject->GetPassword = CcspCwmpAcscoGetPassword; pMyObject->SetPassword = CcspCwmpAcscoSetPassword; pMyObject->Reset = CcspCwmpAcscoReset; pMyObject->Connect = CcspCwmpAcscoConnect; pMyObject->Request = CcspCwmpAcscoRequest; pMyObject->RequestOnly = CcspCwmpAcscoRequestOnly; pMyObject->Close = CcspCwmpAcscoClose; pMyObject->HttpBspPolish = CcspCwmpAcscoHttpBspPolish; pMyObject->HttpBspBrowse = CcspCwmpAcscoHttpBspBrowse; pMyObject->HttpBspNotify = CcspCwmpAcscoHttpBspNotify; pMyObject->HttpGetCredential = CcspCwmpAcscoHttpGetCredential; pMyObject->AddCookie = CcspCwmpAcscoHttpAddCookie; pMyObject->RemoveCookies = CcspCwmpAcscoHttpRemoveCookies; pMyObject->FindCookie = CcspCwmpAcscoHttpFindCookie; pMyObject->DelCookie = CcspCwmpAcscoHttpDelCookie; return ANSC_STATUS_SUCCESS; }
31.283364
131
0.580762
b7e1bd47184be5f7b67dcd2a2ef243a0e01f7df6
1,594
h
C
generic/rbcGrLegd.h
josp70/rbc
99c6f2fe436e74eb0798f6463c1c7cde9375207e
[ "BSD-2-Clause" ]
null
null
null
generic/rbcGrLegd.h
josp70/rbc
99c6f2fe436e74eb0798f6463c1c7cde9375207e
[ "BSD-2-Clause" ]
null
null
null
generic/rbcGrLegd.h
josp70/rbc
99c6f2fe436e74eb0798f6463c1c7cde9375207e
[ "BSD-2-Clause" ]
null
null
null
/* * rbcGrLegd.h -- * * TODO: Description * * Copyright (c) 2009 Samuel Green, Nicholas Hudson, Stanton Sievers, Jarrod Stormo * All rights reserved. * * See "license.terms" for details. */ #ifndef _RBCGRLEGEND #define _RBCGRLEGEND #define LEGEND_RIGHT (1<<0) /* Right margin */ #define LEGEND_LEFT (1<<1) /* Left margin */ #define LEGEND_BOTTOM (1<<2) /* Bottom margin */ #define LEGEND_TOP (1<<3) /* Top margin, below the graph title. */ #define LEGEND_PLOT (1<<4) /* Plot area */ #define LEGEND_XY (1<<5) /* Screen coordinates in the plotting * area. */ #define LEGEND_WINDOW (1<<6) /* External window. */ #define LEGEND_IN_MARGIN \ (LEGEND_RIGHT | LEGEND_LEFT | LEGEND_BOTTOM | LEGEND_TOP) #define LEGEND_IN_PLOT (LEGEND_PLOT | LEGEND_XY) int Rbc_CreateLegend _ANSI_ARGS_((Graph *graphPtr)); void Rbc_DestroyLegend _ANSI_ARGS_((Graph *graphPtr)); void Rbc_DrawLegend _ANSI_ARGS_((Legend *legendPtr, Drawable drawable)); void Rbc_MapLegend _ANSI_ARGS_((Legend *legendPtr, int width, int height)); int Rbc_LegendOp _ANSI_ARGS_((Graph *graphPtr, Tcl_Interp *interp, int argc, char **argv)); int Rbc_LegendSite _ANSI_ARGS_((Legend *legendPtr)); int Rbc_LegendWidth _ANSI_ARGS_((Legend *legendPtr)); int Rbc_LegendHeight _ANSI_ARGS_((Legend *legendPtr)); int Rbc_LegendIsHidden _ANSI_ARGS_((Legend *legendPtr)); int Rbc_LegendIsRaised _ANSI_ARGS_((Legend *legendPtr)); int Rbc_LegendX _ANSI_ARGS_((Legend *legendPtr)); int Rbc_LegendY _ANSI_ARGS_((Legend *legendPtr)); void Rbc_LegendRemoveElement _ANSI_ARGS_((Legend *legendPtr, Element *elemPtr)); #endif /* _RBCGRLEGEND */
38.878049
91
0.749686
b7e213b7ade0469afe5a633a4f48a85fb393a7d5
7,702
c
C
openbsd/sys/dev/isa/gus_isa.c
MarginC/kame
2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30
[ "BSD-3-Clause" ]
91
2015-01-05T15:18:31.000Z
2022-03-11T16:43:28.000Z
openbsd/sys/dev/isa/gus_isa.c
MarginC/kame
2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30
[ "BSD-3-Clause" ]
1
2016-02-25T15:57:55.000Z
2016-02-25T16:01:02.000Z
openbsd/sys/dev/isa/gus_isa.c
MarginC/kame
2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30
[ "BSD-3-Clause" ]
21
2015-02-07T08:23:07.000Z
2021-12-14T06:01:49.000Z
/* $OpenBSD: gus_isa.c,v 1.1 1999/07/05 20:08:37 deraadt Exp $ */ /* $NetBSD: gus.c,v 1.51 1998/01/25 23:48:06 mycroft Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Ken Hornstein and John Kohl. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. */ /* * * TODO: * . figure out why mixer activity while sound is playing causes problems * (phantom interrupts?) * . figure out a better deinterleave strategy that avoids sucking up * CPU, memory and cache bandwidth. (Maybe a special encoding? * Maybe use the double-speed sampling/hardware deinterleave trick * from the GUS SDK?) A 486/33 isn't quite fast enough to keep * up with 44.1kHz 16-bit stereo output without some drop-outs. * . use CS4231 for 16-bit sampling, for a-law and mu-law playback. * . actually test full-duplex sampling(recording) and playback. */ /* * Gravis UltraSound driver * * For more detailed information, see the GUS developers' kit * available on the net at: * * ftp://freedom.nmsu.edu/pub/ultrasound/gravis/util/ * gusdkXXX.zip (developers' kit--get rev 2.22 or later) * See ultrawrd.doc inside--it's MS Word (ick), but it's the bible * */ /* * The GUS Max has a slightly strange set of connections between the CS4231 * and the GF1 and the DMA interconnects. It's set up so that the CS4231 can * be playing while the GF1 is loading patches from the system. * * Here's a recreation of the DMA interconnect diagram: * * GF1 * +---------+ digital * | | record ASIC * | |--------------+ * | | | +--------+ * | | play (dram) | +----+ | | * | |--------------(------|-\ | | +-+ | * +---------+ | | >-|----|---|C|--|------ dma chan 1 * | +---|-/ | | +-+ | * | | +----+ | | | * | | +----+ | | | * +---------+ +-+ +--(---|-\ | | | | * | | play |8| | | >-|----|----+---|------ dma chan 2 * | ---C----|--------|/|------(---|-/ | | | * | ^ |record |1| | +----+ | | * | | | /----|6|------+ +--------+ * | ---+----|--/ +-+ * +---------+ * CS4231 8-to-16 bit bus conversion, if needed * * * "C" is an optional combiner. * */ #include <sys/param.h> #include <sys/systm.h> #include <sys/errno.h> #include <sys/ioctl.h> #include <sys/syslog.h> #include <sys/device.h> #include <sys/proc.h> #include <sys/buf.h> #include <sys/fcntl.h> #include <sys/malloc.h> #include <sys/kernel.h> #include <machine/cpu.h> #include <machine/intr.h> #include <machine/bus.h> #include <machine/cpufunc.h> #include <sys/audioio.h> #include <dev/audio_if.h> #include <dev/mulaw.h> #include <dev/auconv.h> #include <dev/isa/isavar.h> #include <dev/isa/isadmavar.h> #include <i386/isa/icu.h> #include <dev/ic/ics2101reg.h> #include <dev/ic/cs4231reg.h> #include <dev/ic/ad1848reg.h> #include <dev/isa/ics2101var.h> #include <dev/isa/ad1848var.h> #include <dev/isa/cs4231var.h> #include "gusreg.h" #include "gusvar.h" /* * ISA bus driver routines */ int gus_isa_match __P((struct device *, void *, void *)); void gus_isa_attach __P((struct device *, struct device *, void *)); struct cfattach gus_isa_ca = { sizeof(struct gus_softc), gus_isa_match, gus_isa_attach, }; int gus_isa_match(parent, match, aux) struct device *parent; void *match; void *aux; { struct isa_attach_args *ia = aux; int iobase = ia->ia_iobase; int recdrq = ia->ia_drq2; /* * Before we do anything else, make sure requested IRQ and DRQ are * valid for this card. */ /* XXX range check before indexing!! */ if (ia->ia_irq == IRQUNK || gus_irq_map[ia->ia_irq] == IRQUNK) { DPRINTF(("gus: invalid irq %d, card not probed\n", ia->ia_irq)); return 0; } if (ia->ia_drq == DRQUNK || gus_drq_map[ia->ia_drq] == DRQUNK) { DPRINTF(("gus: invalid drq %d, card not probed\n", ia->ia_drq)); return 0; } if (recdrq != DRQUNK) { if (recdrq > 7 || gus_drq_map[recdrq] == DRQUNK) { DPRINTF(("gus: invalid second DMA channel (%d), card not probed\n", recdrq)); return 0; } } else recdrq = ia->ia_drq; if (iobase == IOBASEUNK) { int i; for(i = 0; i < gus_addrs; i++) if (gus_test_iobase(ia->ia_iot, gus_base_addrs[i])) { iobase = gus_base_addrs[i]; goto done; } return 0; } else if (!gus_test_iobase(ia->ia_iot, iobase)) return 0; done: if ((ia->ia_drq != -1 && !isa_drq_isfree(parent, ia->ia_drq)) || (recdrq != -1 && !isa_drq_isfree(parent, recdrq))) return 0; ia->ia_iobase = iobase; ia->ia_iosize = GUS_NPORT1; return 1; } /* * Setup the GUS for use; called shortly after probe */ void gus_isa_attach(parent, self, aux) struct device *parent, *self; void *aux; { struct gus_softc *sc = (void *) self; struct isa_attach_args *ia = aux; sc->sc_iot = ia->ia_iot; sc->sc_iobase = ia->ia_iobase; /* Map i/o space */ if (bus_space_map(sc->sc_iot, sc->sc_iobase, GUS_NPORT1, 0, &sc->sc_ioh1)) panic("%s: can't map io port range 1", self->dv_xname); if (bus_space_map(sc->sc_iot, sc->sc_iobase+GUS_IOH2_OFFSET, GUS_NPORT2, 0, &sc->sc_ioh2)) panic("%s: can't map io port range 2", self->dv_xname); /* XXX Maybe we shouldn't fail on mapping this, but just assume * the card is of revision 0? */ if (bus_space_map(sc->sc_iot, sc->sc_iobase+GUS_IOH3_OFFSET, GUS_NPORT3, 0, &sc->sc_ioh3)) panic("%s: can't map io port range 3", self->dv_xname); if (bus_space_map(sc->sc_iot, sc->sc_iobase+GUS_IOH4_OFFSET, GUS_NPORT4, 0, &sc->sc_ioh4)) panic("%s: can't map io port range 4", self->dv_xname); sc->sc_irq = ia->ia_irq; sc->sc_drq = ia->ia_drq; sc->sc_recdrq = ia->ia_drq2; sc->sc_isa = parent; gus_subattach(sc, aux); }
32.361345
82
0.62737
b7e2b5ff21f867ec6254db5fa758021b873af8c0
898
h
C
ext/Certificate.h
weyhmueller/aws-certlint
e91a6e097a97a5d25515e37a2c00a448a9926e73
[ "Apache-2.0" ]
null
null
null
ext/Certificate.h
weyhmueller/aws-certlint
e91a6e097a97a5d25515e37a2c00a448a9926e73
[ "Apache-2.0" ]
null
null
null
ext/Certificate.h
weyhmueller/aws-certlint
e91a6e097a97a5d25515e37a2c00a448a9926e73
[ "Apache-2.0" ]
null
null
null
/* * Generated by asn1c-0.9.29 (http://lionet.info/asn1c) * From ASN.1 module "PKIX1Explicit88" * found in "rfc3280-PKIX1Explicit88.asn1" * `asn1c -S asn1c/skeletons -pdu=all -pdu=Certificate -fwide-types` */ #ifndef _Certificate_H_ #define _Certificate_H_ #include <asn_application.h> /* Including external dependencies */ #include "TBSCertificate.h" #include "AlgorithmIdentifier.h" #include <BIT_STRING.h> #include <constr_SEQUENCE.h> #ifdef __cplusplus extern "C" { #endif /* Certificate */ typedef struct Certificate { TBSCertificate_t tbsCertificate; AlgorithmIdentifier_t signatureAlgorithm; BIT_STRING_t signature; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } Certificate_t; /* Implementation */ extern asn_TYPE_descriptor_t asn_DEF_Certificate; #ifdef __cplusplus } #endif #endif /* _Certificate_H_ */ #include <asn_internal.h>
20.883721
69
0.762806
b7e483f7288592a3aa673ff8bb2b8020888791e0
5,321
h
C
Source/Drivers/PSLink/LinkProtoLib/XnLinkStatusCodes.h
liweimcc/OpenNI-Vive
bb8834d88b9869469760d2def19683226665ff10
[ "Apache-2.0" ]
7
2019-12-08T02:37:21.000Z
2022-02-12T02:38:52.000Z
Source/Drivers/PSLink/LinkProtoLib/XnLinkStatusCodes.h
liweimcc/OpenNI-Vive
bb8834d88b9869469760d2def19683226665ff10
[ "Apache-2.0" ]
2
2018-04-16T10:51:56.000Z
2018-04-24T06:35:09.000Z
Source/Drivers/PSLink/LinkProtoLib/XnLinkStatusCodes.h
liweimcc/OpenNI-Vive
bb8834d88b9869469760d2def19683226665ff10
[ "Apache-2.0" ]
4
2016-05-26T13:12:37.000Z
2019-12-10T11:53:05.000Z
/***************************************************************************** * * * OpenNI 2.x Alpha * * Copyright (C) 2012 PrimeSense Ltd. * * * * This file is part of OpenNI. * * * * 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 XNLINKSTATUSCODES_H #define XNLINKSTATUSCODES_H #include <XnStatus.h> #include "XnLinkProtoLibDefs.h" #define XN_ERROR_GROUP_LINKPROTOLIB 6000 #define XN_PS_STATUS_MESSAGE_MAP_START(module) \ XN_STATUS_MESSAGE_MAP_START_FROM(XN_ERROR_GROUP_PRIMESENSE, module) #define XN_PS_STATUS_MESSAGE_MAP_END(module) \ XN_STATUS_MESSAGE_MAP_END_FROM(XN_ERROR_GROUP_PRIMESENSE, module) XN_PS_STATUS_MESSAGE_MAP_START(XN_ERROR_GROUP_LINKPROTOLIB) //31770 XN_STATUS_MESSAGE(XN_STATUS_LINK_BAD_HEADER_SIZE, "Bad link layer header size") //31771 XN_STATUS_MESSAGE(XN_STATUS_LINK_BAD_MAGIC, "Bad link layer magic") //31772 XN_STATUS_MESSAGE(XN_STATUS_LINK_BAD_FRAGMENTATION, "Bad link layer fragmentation flags") //31773 XN_STATUS_MESSAGE(XN_STATUS_LINK_PARTIAL_PACKET, "Received a partial link layer packet") //31774 XN_STATUS_MESSAGE(XN_STATUS_LINK_BAD_STREAM_ID, "Bad stream ID in link layer packet") //31775 XN_STATUS_MESSAGE(XN_STATUS_LINK_PACKETS_LOST, "One or more Link layer packets were lost") //31776 XN_STATUS_MESSAGE(XN_STATUS_LINK_RESPONSE_MSG_TYPE_MISMATCH, "Response message type mismatch") //31777 XN_STATUS_MESSAGE(XN_STATUS_LINK_MISSING_RESPONSE_INFO, "Response info missing in response packet") //31778 XN_STATUS_MESSAGE(XN_STATUS_LINK_RESP_PENDING, "Link response: Response pending") //31779 XN_STATUS_MESSAGE(XN_STATUS_LINK_RESP_BAD_FILE_TYPE, "Link response: Bad file type") //31780 XN_STATUS_MESSAGE(XN_STATUS_LINK_RESP_CMD_ERROR, "Link response: General command error") //31781 XN_STATUS_MESSAGE(XN_STATUS_LINK_RESP_CMD_NOT_SUPPORTED, "Link response: Command not supported") //FW replied that command is not supported //31782 XN_STATUS_MESSAGE(XN_STATUS_LINK_RESP_BAD_CMD_SIZE, "Link response: Bad command size") //31783 XN_STATUS_MESSAGE(XN_STATUS_LINK_RESP_BAD_PARAMETERS, "Link response: bad parameters") //31784 XN_STATUS_MESSAGE(XN_STATUS_LINK_RESP_CORRUPT_PACKET, "Link response: Corrupt packet") //31785 XN_STATUS_MESSAGE(XN_STATUS_LINK_RESP_CORRUPT_FILE, "Link response: File is corrupt") //31786 XN_STATUS_MESSAGE(XN_STATUS_LINK_RESP_BAD_CRC, "Link response: Bad CRC") //31787 XN_STATUS_MESSAGE(XN_STATUS_LINK_RESP_INCORRECT_SIZE, "Link response: Incorrect size") //31788 XN_STATUS_MESSAGE(XN_STATUS_LINK_RESP_INPUT_BUFFER_OVERFLOW, "Link response: Input buffer overflow") //31789 XN_STATUS_MESSAGE(XN_STATUS_LINK_RESP_UNKNOWN, "Link response: Unknown response code") //31790 XN_STATUS_MESSAGE(XN_STATUS_LINK_INVALID_MAX_SHIFT, "Max shift value is too big") //31791 XN_STATUS_MESSAGE(XN_STATUS_LINK_INVALID_MAX_DEPTH, "Max depth value is too big") //31792 XN_STATUS_MESSAGE(XN_STATUS_LINK_MISSING_TIMESTAMP, "Missing timestamp in data unit") //31793 XN_STATUS_MESSAGE(XN_STATUS_LINK_BAD_RESPONSE_SIZE, "Response message has incorrect size") //31794 XN_STATUS_MESSAGE(XN_STATUS_LINK_RESERVED5, "RESERVED5") //31795 XN_STATUS_MESSAGE(XN_STATUS_LINK_UNKNOWN_GESTURE, "Unknown gesture") //31796 XN_STATUS_MESSAGE(XN_STATUS_LINK_UNKNOWN_POSE, "Unknown pose") //31796 XN_STATUS_MESSAGE(XN_STATUS_LINK_BAD_PACKET_FORMAT, "Bad packet format") //31797 XN_STATUS_MESSAGE(XN_STATUS_LINK_BAD_PROP_TYPE, "Bad property type") //31798 XN_STATUS_MESSAGE(XN_STATUS_LINK_BAD_PROP_ID, "Bad property ID") //31799 XN_STATUS_MESSAGE(XN_STATUS_LINK_CMD_NOT_SUPPORTED, "Command not supported") //Command not supported as indicated by supported msg types by FW //31800 XN_STATUS_MESSAGE(XN_STATUS_LINK_PROP_NOT_SUPPORTED, "Property not supported") //Property not supported as indicated by supported properties by FW //31801 XN_STATUS_MESSAGE(XN_STATUS_LINK_BAD_PROP_SIZE, "Bad property size") XN_PS_STATUS_MESSAGE_MAP_END(XN_ERROR_GROUP_LINKPROTOLIB) #endif // XNLINKSTATUSCODES_H
38.280576
146
0.678632
b7e596620db16c594a7ba3cc73c2bbd9643b0e43
6,105
c
C
release/src-rt-6.x.4708/linux/linux-2.6.36/drivers/pcmcia/pxa2xx_trizeps4.c
afeng11/tomato-arm
1ca18a88480b34fd495e683d849f46c2d47bb572
[ "FSFAP" ]
21
2021-01-22T06:47:38.000Z
2022-03-20T14:24:29.000Z
release/src-rt-6.x.4708/linux/linux-2.6.36/drivers/pcmcia/pxa2xx_trizeps4.c
afeng11/tomato-arm
1ca18a88480b34fd495e683d849f46c2d47bb572
[ "FSFAP" ]
1
2018-08-21T03:43:09.000Z
2018-08-21T03:43:09.000Z
release/src-rt-6.x.4708/linux/linux-2.6.36/drivers/pcmcia/pxa2xx_trizeps4.c
afeng11/tomato-arm
1ca18a88480b34fd495e683d849f46c2d47bb572
[ "FSFAP" ]
12
2021-01-22T14:59:28.000Z
2022-02-22T04:03:31.000Z
/* * linux/drivers/pcmcia/pxa2xx_trizeps4.c * * TRIZEPS PCMCIA specific routines. * * Author: Jürgen Schindele * Created: 20 02, 2006 * Copyright: Jürgen Schindele * * 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. */ #include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/gpio.h> #include <linux/interrupt.h> #include <linux/platform_device.h> #include <asm/mach-types.h> #include <asm/irq.h> #include <mach/pxa2xx-regs.h> #include <mach/trizeps4.h> #include "soc_common.h" extern void board_pcmcia_power(int power); static struct pcmcia_irqs irqs[] = { { 0, IRQ_GPIO(GPIO_PCD), "cs0_cd" } /* on other baseboards we can have more inputs */ }; static int trizeps_pcmcia_hw_init(struct soc_pcmcia_socket *skt) { int ret, i; /* we dont have voltage/card/ready detection * so we dont need interrupts for it */ switch (skt->nr) { case 0: if (gpio_request(GPIO_PRDY, "cf_irq") < 0) { pr_err("%s: sock %d unable to request gpio %d\n", __func__, skt->nr, GPIO_PRDY); return -EBUSY; } if (gpio_direction_input(GPIO_PRDY) < 0) { pr_err("%s: sock %d unable to set input gpio %d\n", __func__, skt->nr, GPIO_PRDY); gpio_free(GPIO_PRDY); return -EINVAL; } skt->socket.pci_irq = IRQ_GPIO(GPIO_PRDY); break; #ifndef CONFIG_MACH_TRIZEPS_CONXS case 1: #endif default: break; } /* release the reset of this card */ pr_debug("%s: sock %d irq %d\n", __func__, skt->nr, skt->socket.pci_irq); /* supplementory irqs for the socket */ for (i = 0; i < ARRAY_SIZE(irqs); i++) { if (irqs[i].sock != skt->nr) continue; if (gpio_request(IRQ_TO_GPIO(irqs[i].irq), irqs[i].str) < 0) { pr_err("%s: sock %d unable to request gpio %d\n", __func__, skt->nr, IRQ_TO_GPIO(irqs[i].irq)); ret = -EBUSY; goto error; } if (gpio_direction_input(IRQ_TO_GPIO(irqs[i].irq)) < 0) { pr_err("%s: sock %d unable to set input gpio %d\n", __func__, skt->nr, IRQ_TO_GPIO(irqs[i].irq)); ret = -EINVAL; goto error; } } return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs)); error: for (; i >= 0; i--) { gpio_free(IRQ_TO_GPIO(irqs[i].irq)); } return (ret); } static void trizeps_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) { int i; /* free allocated gpio's */ gpio_free(GPIO_PRDY); for (i = 0; i < ARRAY_SIZE(irqs); i++) gpio_free(IRQ_TO_GPIO(irqs[i].irq)); } static unsigned long trizeps_pcmcia_status[2]; static void trizeps_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state) { unsigned short status = 0, change; status = CFSR_readw(); change = (status ^ trizeps_pcmcia_status[skt->nr]) & ConXS_CFSR_BVD_MASK; if (change) { trizeps_pcmcia_status[skt->nr] = status; if (status & ConXS_CFSR_BVD1) { /* enable_irq empty */ } else { /* disable_irq empty */ } } switch (skt->nr) { case 0: /* just fill in fix states */ state->detect = gpio_get_value(GPIO_PCD) ? 0 : 1; state->ready = gpio_get_value(GPIO_PRDY) ? 1 : 0; state->bvd1 = (status & ConXS_CFSR_BVD1) ? 1 : 0; state->bvd2 = (status & ConXS_CFSR_BVD2) ? 1 : 0; state->vs_3v = (status & ConXS_CFSR_VS1) ? 0 : 1; state->vs_Xv = (status & ConXS_CFSR_VS2) ? 0 : 1; state->wrprot = 0; /* not available */ break; #ifndef CONFIG_MACH_TRIZEPS_CONXS /* on ConXS we only have one slot. Second is inactive */ case 1: state->detect = 0; state->ready = 0; state->bvd1 = 0; state->bvd2 = 0; state->vs_3v = 0; state->vs_Xv = 0; state->wrprot = 0; break; #endif } } static int trizeps_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state) { int ret = 0; unsigned short power = 0; /* we do nothing here just check a bit */ switch (state->Vcc) { case 0: power &= 0xfc; break; case 33: power |= ConXS_BCR_S0_VCC_3V3; break; case 50: pr_err("%s(): Vcc 5V not supported in socket\n", __func__); break; default: pr_err("%s(): bad Vcc %u\n", __func__, state->Vcc); ret = -1; } switch (state->Vpp) { case 0: power &= 0xf3; break; case 33: power |= ConXS_BCR_S0_VPP_3V3; break; case 120: pr_err("%s(): Vpp 12V not supported in socket\n", __func__); break; default: if (state->Vpp != state->Vcc) { pr_err("%s(): bad Vpp %u\n", __func__, state->Vpp); ret = -1; } } switch (skt->nr) { case 0: /* we only have 3.3V */ board_pcmcia_power(power); break; #ifndef CONFIG_MACH_TRIZEPS_CONXS /* on ConXS we only have one slot. Second is inactive */ case 1: #endif default: break; } return ret; } static void trizeps_pcmcia_socket_init(struct soc_pcmcia_socket *skt) { /* default is on */ board_pcmcia_power(0x9); } static void trizeps_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) { board_pcmcia_power(0x0); } static struct pcmcia_low_level trizeps_pcmcia_ops = { .owner = THIS_MODULE, .hw_init = trizeps_pcmcia_hw_init, .hw_shutdown = trizeps_pcmcia_hw_shutdown, .socket_state = trizeps_pcmcia_socket_state, .configure_socket = trizeps_pcmcia_configure_socket, .socket_init = trizeps_pcmcia_socket_init, .socket_suspend = trizeps_pcmcia_socket_suspend, #ifdef CONFIG_MACH_TRIZEPS_CONXS .nr = 1, #else .nr = 2, #endif .first = 0, }; static struct platform_device *trizeps_pcmcia_device; static int __init trizeps_pcmcia_init(void) { int ret; trizeps_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); if (!trizeps_pcmcia_device) return -ENOMEM; ret = platform_device_add_data(trizeps_pcmcia_device, &trizeps_pcmcia_ops, sizeof(trizeps_pcmcia_ops)); if (ret == 0) ret = platform_device_add(trizeps_pcmcia_device); if (ret) platform_device_put(trizeps_pcmcia_device); return ret; } static void __exit trizeps_pcmcia_exit(void) { platform_device_unregister(trizeps_pcmcia_device); } fs_initcall(trizeps_pcmcia_init); module_exit(trizeps_pcmcia_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Juergen Schindele"); MODULE_ALIAS("platform:pxa2xx-pcmcia");
23.847656
74
0.691237
b7e5a5acee6e6c01d8fb050fcfcf96d82bb1d11a
3,829
h
C
sdk-6.5.20/include/shared/swstate/access/sw_state_dpp_soc_jericho_tm_dram_rd_crc_interrupt_state_access.h
copslock/broadcom_cpri
8e2767676e26faae270cf485591902a4c50cf0c5
[ "Spencer-94" ]
null
null
null
sdk-6.5.20/include/shared/swstate/access/sw_state_dpp_soc_jericho_tm_dram_rd_crc_interrupt_state_access.h
copslock/broadcom_cpri
8e2767676e26faae270cf485591902a4c50cf0c5
[ "Spencer-94" ]
null
null
null
sdk-6.5.20/include/shared/swstate/access/sw_state_dpp_soc_jericho_tm_dram_rd_crc_interrupt_state_access.h
copslock/broadcom_cpri
8e2767676e26faae270cf485591902a4c50cf0c5
[ "Spencer-94" ]
null
null
null
/* * * 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. * * DO NOT EDIT THIS FILE! * This file is auto-generated. * Edits to this file will be lost when it is regenerated. * search for 'sw_state_cbs_t' for the root of the struct */ #ifndef _SHR_SW_STATE_DPP_SOC_JERICHO_TM_DRAM_RD_CRC_INTERRUPT_STATE_ACCESS_H_ #define _SHR_SW_STATE_DPP_SOC_JERICHO_TM_DRAM_RD_CRC_INTERRUPT_STATE_ACCESS_H_ /********************************* access calbacks definitions *************************************/ /* this set of callbacks, are the callbacks used in the access calbacks struct 'sw_state_cbs_t' to */ /* access the data in 'sw_state_t'. */ /* the calbacks are inserted into the access struct by 'sw_state_access_cb_init'. */ /***************************************************************************************************/ #ifdef BCM_PETRA_SUPPORT #if defined(BCM_PETRA_SUPPORT) /* implemented by: sw_state_dpp_soc_jericho_tm_dram_rd_crc_interrupt_state_set */ typedef int (*sw_state_dpp_soc_jericho_tm_dram_rd_crc_interrupt_state_set_cb)( int unit, int dram_rd_crc_interrupt_state_idx_0, int dram_rd_crc_interrupt_state); #endif /* defined(BCM_PETRA_SUPPORT)*/ #endif /* BCM_PETRA_SUPPORT*/ #ifdef BCM_PETRA_SUPPORT #if defined(BCM_PETRA_SUPPORT) /* implemented by: sw_state_dpp_soc_jericho_tm_dram_rd_crc_interrupt_state_get */ typedef int (*sw_state_dpp_soc_jericho_tm_dram_rd_crc_interrupt_state_get_cb)( int unit, int dram_rd_crc_interrupt_state_idx_0, int *dram_rd_crc_interrupt_state); #endif /* defined(BCM_PETRA_SUPPORT)*/ #endif /* BCM_PETRA_SUPPORT*/ #ifdef BCM_PETRA_SUPPORT #if defined(BCM_PETRA_SUPPORT) /* implemented by: sw_state_dpp_soc_jericho_tm_dram_rd_crc_interrupt_state_alloc */ typedef int (*sw_state_dpp_soc_jericho_tm_dram_rd_crc_interrupt_state_alloc_cb)( int unit, int nof_instances_to_alloc); #endif /* defined(BCM_PETRA_SUPPORT)*/ #endif /* BCM_PETRA_SUPPORT*/ #ifdef BCM_PETRA_SUPPORT #if defined(BCM_PETRA_SUPPORT) /* implemented by: sw_state_dpp_soc_jericho_tm_dram_rd_crc_interrupt_state_is_allocated */ typedef int (*sw_state_dpp_soc_jericho_tm_dram_rd_crc_interrupt_state_is_allocated_cb)( int unit, uint8 *is_allocated); #endif /* defined(BCM_PETRA_SUPPORT)*/ #endif /* BCM_PETRA_SUPPORT*/ #ifdef BCM_PETRA_SUPPORT #if defined(BCM_PETRA_SUPPORT) /* implemented by: sw_state_dpp_soc_jericho_tm_dram_rd_crc_interrupt_state_free */ typedef int (*sw_state_dpp_soc_jericho_tm_dram_rd_crc_interrupt_state_free_cb)( int unit); #endif /* defined(BCM_PETRA_SUPPORT)*/ #endif /* BCM_PETRA_SUPPORT*/ #ifdef BCM_PETRA_SUPPORT #if defined(BCM_PETRA_SUPPORT) /* implemented by: sw_state_dpp_soc_jericho_tm_dram_rd_crc_interrupt_state_verify */ typedef int (*sw_state_dpp_soc_jericho_tm_dram_rd_crc_interrupt_state_verify_cb)( int unit, int dram_rd_crc_interrupt_state_idx_0); #endif /* defined(BCM_PETRA_SUPPORT)*/ #endif /* BCM_PETRA_SUPPORT*/ /*********************************** access calbacks struct ****************************************/ /* this set of structs, rooted at 'sw_state_cbs_t' define the access layer for the entire SW state.*/ /* use this tree to alloc/free/set/get fields in the sw state rooted at 'sw_state_t'. */ /* NOTE: 'sw_state_t' data should not be accessed directly. */ /***************************************************************************************************/ int sw_state_dpp_soc_jericho_tm_dram_rd_crc_interrupt_state_access_cb_init(int unit); #endif /* _SHR_SW_STATE_DPP_SOC_JERICHO_TM_DRAM_RD_CRC_INTERRUPT_STATE_ACCESS_H_ */
47.8625
134
0.71298
b7eb7134ebd43f61c338b79f522a2e0c59755532
142
h
C
src/Kernel/DataInterfacePointer.h
irov/Mengine
b76e9f8037325dd826d4f2f17893ac2b236edad8
[ "MIT" ]
39
2016-04-21T03:25:26.000Z
2022-01-19T14:16:38.000Z
src/Kernel/DataInterfacePointer.h
irov/Mengine
b76e9f8037325dd826d4f2f17893ac2b236edad8
[ "MIT" ]
23
2016-06-28T13:03:17.000Z
2022-02-02T10:11:54.000Z
src/Kernel/DataInterfacePointer.h
irov/Mengine
b76e9f8037325dd826d4f2f17893ac2b236edad8
[ "MIT" ]
14
2016-06-22T20:45:37.000Z
2021-07-05T12:25:19.000Z
#pragma once #include "Kernel/Pointer.h" namespace Mengine { typedef PointerT<IntrusivePtr<class DataInterface>> DataInterfacePointer; }
17.75
77
0.788732
b7ed92b8eb25594707c2612fae1353b79439340a
1,820
h
C
Pixy/PixyI2C.h
brainchen98/Team-PI-Lib
fa6324c9bb3ea03b86a0ab49c683f3fc35084511
[ "MIT" ]
2
2015-09-30T05:27:57.000Z
2015-10-12T08:05:45.000Z
Pixy/PixyI2C.h
brainchen98/Team-PI-Lib
fa6324c9bb3ea03b86a0ab49c683f3fc35084511
[ "MIT" ]
null
null
null
Pixy/PixyI2C.h
brainchen98/Team-PI-Lib
fa6324c9bb3ea03b86a0ab49c683f3fc35084511
[ "MIT" ]
2
2018-07-16T22:37:49.000Z
2018-12-18T11:55:29.000Z
// // begin license header // // This file is part of Pixy CMUcam5 or "Pixy" for short // // All Pixy source code is provided under the terms of the // GNU General Public License v2 (http://www.gnu.org/licenses/gpl-2.0.html). // Those wishing to use Pixy source code, software and/or // technologies under different licensing terms should contact us at // cmucam@cs.cmu.edu. Such licensing terms are available for // all portions of the Pixy codebase presented here. // // end license header // // This file is for defining the link class for I2C communications. // // Note, the PixyI2C class takes an optional argument, which is the I2C address // of the Pixy you want to talk to. The default address is 0x54 (used when no // argument is used.) So, for example, if you wished to talk to Pixy at I2C // address 0x55, declare like this: // // PixyI2C pixy(0x55); // #ifndef _PIXYI2C_H #define _PIXYI2C_H #include "TPixy.h" #include "i2c_t3.h" #define PIXY_I2C_TIMOUT 500 #define PIXY_I2C_DEFAULT_ADDR 0x54 class LinkI2C { public: void init() { // scrap this // Wire.begin(); } void setArg(uint16_t arg) { if (arg==PIXY_DEFAULT_ARGVAL) addr = PIXY_I2C_DEFAULT_ADDR; else addr = arg; } uint16_t getWord() { uint16_t w; uint8_t c; Wire.requestFrom((int)addr, 2, I2C_STOP, PIXY_I2C_TIMOUT); c = Wire.read(); w = Wire.read(); w <<= 8; w |= c; return w; } uint8_t getByte() { if (Wire.requestFrom((int)addr, 1, I2C_STOP, PIXY_I2C_TIMOUT) == 0){ return 0; } return Wire.read(); } int8_t send(uint8_t *data, uint8_t len) { Wire.beginTransmission(addr); Wire.write(data, len); Wire.endTransmission(I2C_STOP, PIXY_I2C_TIMOUT); return len; } private: uint8_t addr; }; typedef TPixy<LinkI2C> PixyI2C; #endif
22.469136
83
0.677473
b7eea0a0765c26daef98b95d5f1dc5dab72b51ef
252
h
C
src/engine/collision/collision_system.h
Rewlion/Asteroids
3812d8e229e6feba86b17a62c6b41894becc776a
[ "MIT" ]
null
null
null
src/engine/collision/collision_system.h
Rewlion/Asteroids
3812d8e229e6feba86b17a62c6b41894becc776a
[ "MIT" ]
1
2021-10-03T22:59:52.000Z
2021-10-03T22:59:52.000Z
src/engine/collision/collision_system.h
Rewlion/Asteroids
3812d8e229e6feba86b17a62c6b41894becc776a
[ "MIT" ]
1
2021-11-12T17:24:21.000Z
2021-11-12T17:24:21.000Z
#pragma once #include <engine/ecs/BaseSystems.h> class Group; class CollisionSystem : public LogicSystem { public: CollisionSystem(Context* ecsContext); virtual void Update(const float dt) override; private: Group* m_CircleComponentGroup; };
15.75
47
0.769841
b7eedb9b5e2fa115a6b31bd79487e19fab068b40
12,075
h
C
cpp/include/Node.h
FlyingSamson/codeparser
7ee6377bd9938e4d63fba8adbf2216e0b5dc5c82
[ "MIT" ]
71
2020-04-08T19:07:50.000Z
2022-03-11T20:49:47.000Z
cpp/include/Node.h
FlyingSamson/codeparser
7ee6377bd9938e4d63fba8adbf2216e0b5dc5c82
[ "MIT" ]
22
2020-04-10T16:16:06.000Z
2021-03-22T13:30:21.000Z
cpp/include/Node.h
LaudateCorpus1/codeparser
48edba45bb403fb2a1175363ac5754199a34ea8d
[ "MIT" ]
12
2020-04-11T03:51:05.000Z
2021-12-31T07:40:37.000Z
#pragma once #include "Source.h" // for Source #include "Symbol.h" // for SymbolPtr #include "Token.h" // for Token #include <vector> #include <set> #include <memory> // for unique_ptr #include <ostream> class Node; class LeafNode; class NodeSeqNode; using NodePtr = std::unique_ptr<Node>; using LeafNodePtr = std::unique_ptr<LeafNode>; using NodeSeqNodePtr = std::unique_ptr<NodeSeqNode>; // // Used mainly for collecting trivia that has been eaten // class LeafSeq { std::vector<LeafNodePtr> vec; public: bool moved; LeafSeq() : vec(), moved(false) {} LeafSeq(LeafSeq&& other) : vec(std::move(other.vec)), moved(false) { other.moved = true; } ~LeafSeq(); bool empty() const; size_t size() const; const Node* first() const; const Node* last() const; void append(LeafNodePtr ); #if USE_MATHLINK void put0(MLINK ) const; #endif // USE_MATHLINK void print0(std::ostream& s) const; }; // // A sequence of Nodes // // When parsing a(**)+b we actually want to keep track of the comment. // But the comment does not affect the parsing: a(**) is still 1 "thing" to the parser // // So pass around a structure that contains all of the nodes from the left, including comments and whitespace. // class NodeSeq { std::vector<NodePtr> vec; public: NodeSeq() : vec() {} NodeSeq(size_t i) : vec() { vec.reserve(i); } bool empty() const; size_t size() const; void append(NodePtr ); void appendIfNonEmpty(LeafSeq ); const Node* first() const; const Node* last() const; #if USE_MATHLINK void put(MLINK ) const; void put0(MLINK ) const; #endif // USE_MATHLINK void print(std::ostream& s ) const; void print0(std::ostream& s ) const; bool check() const; }; // // An expression representing a node in the syntax tree // class Node { protected: NodeSeq Children; public: Node() : Children() {} Node(NodeSeq Children); virtual void print(std::ostream&) const = 0; virtual Source getSource() const; virtual size_t size() const; virtual const Node* first() const; virtual const Node* last() const; virtual Token lastToken() const; #if USE_MATHLINK virtual void put(MLINK mlp) const = 0; void putChildren(MLINK mlp) const; #endif // USE_MATHLINK void printChildren(std::ostream& s) const; const NodeSeq& getChildrenSafe() const { return Children; } virtual bool isExpectedOperandError() const { return false; } virtual bool check() const; virtual ~Node() {} }; // // Need to be able to treat a LeafSeq as a Node // class LeafSeqNode : public Node { LeafSeq Children; public: LeafSeqNode(LeafSeq ChildrenIn) : Children(std::move(ChildrenIn)) { // // Children is owned by this LeafSeqNode, so it has been "moved" // // Setting moved here helps to prevent adding LeafSeqs back to the parser queue // when nodes are being released // Children.moved = true; } size_t size() const override; const Node* first() const override; const Node* last() const override; #if USE_MATHLINK void put(MLINK mlp) const override; #endif // USE_MATHLINK void print(std::ostream&) const override; }; // // Need to be able to treat a NodeSeq as a Node // // For example, when parsing and we already have a NodeSeq Left and // need to insert into a NodeSeq of parent node // class NodeSeqNode : public Node { public: NodeSeqNode(NodeSeq Children) : Node(std::move(Children)) {} size_t size() const override; const Node* first() const override; const Node* last() const override; #if USE_MATHLINK void put(MLINK mlp) const override; #endif // USE_MATHLINK void print(std::ostream&) const override; }; // // Any kind of prefix, postfix, binary, or infix operator // class OperatorNode : public Node { SymbolPtr& Op; SymbolPtr& MakeSym; public: OperatorNode(SymbolPtr& Op, SymbolPtr& MakeSym, NodeSeq Args) : Node(std::move(Args)), Op(Op), MakeSym(MakeSym) {} #if USE_MATHLINK void put(MLINK mlp) const override; #endif // USE_MATHLINK void print(std::ostream&) const override; }; // // Leaf // // These are Symbols, String, Integers, Reals, etc. // class LeafNode : public Node { const Token Tok; public: LeafNode(Token& Tok) : Node(), Tok(Tok) {} LeafNode(Token&& Tok) : Node(), Tok(std::move(Tok)) {} #if USE_MATHLINK void put(MLINK mlp) const override; #endif // USE_MATHLINK void print(std::ostream&) const override; Source getSource() const override { return Tok.Src; } const Token getToken() const { return Tok; } Token lastToken() const override { return Tok; } bool check() const override { return true; } }; // // These are syntax errors similar to LeafNode // class ErrorNode : public Node { protected: const Token Tok; public: ErrorNode(Token& Tok) : Node(), Tok(Tok) { assert(Tok.Tok.isError()); } ErrorNode(Token&& Tok) : Node(), Tok(std::move(Tok)) { assert(Tok.Tok.isError()); } #if USE_MATHLINK void put(MLINK mlp) const override; #endif // USE_MATHLINK void print(std::ostream&) const override; Source getSource() const override { return Tok.Src; } Token lastToken() const override { return Tok; } bool check() const override { return false; } }; class ExpectedOperandErrorNode : public ErrorNode { public: ExpectedOperandErrorNode(Token& Tok) : ErrorNode(Tok) { assert(Tok.Tok == TOKEN_ERROR_EXPECTEDOPERAND); } ExpectedOperandErrorNode(Token&& Tok) : ErrorNode(Tok) { assert(Tok.Tok == TOKEN_ERROR_EXPECTEDOPERAND); } bool isExpectedOperandError() const override { return true; } }; class UnterminatedTokenErrorNeedsReparseNode : public ErrorNode { public: UnterminatedTokenErrorNeedsReparseNode(Token& Tok) : ErrorNode(Tok) {} UnterminatedTokenErrorNeedsReparseNode(Token&& Tok) : ErrorNode(Tok) {} #if USE_MATHLINK void put(MLINK mlp) const override; #endif // USE_MATHLINK void print(std::ostream&) const override; }; // // PrefixNode // // -a // class PrefixNode : public OperatorNode { public: PrefixNode(SymbolPtr& Op, NodeSeq Args) : OperatorNode(Op, SYMBOL_CODEPARSER_LIBRARY_MAKEPREFIXNODE, std::move(Args)) {} }; // // BinaryNode // // a @ b // class BinaryNode : public OperatorNode { public: BinaryNode(SymbolPtr& Op, NodeSeq Args) : OperatorNode(Op, SYMBOL_CODEPARSER_LIBRARY_MAKEBINARYNODE, std::move(Args)) {} }; // // InfixNode // // a + b + c // class InfixNode : public OperatorNode { public: InfixNode(SymbolPtr& Op, NodeSeq Args) : OperatorNode(Op, SYMBOL_CODEPARSER_LIBRARY_MAKEINFIXNODE, std::move(Args)) {} }; // // TernaryNode // // a /: b = c // class TernaryNode : public OperatorNode { public: TernaryNode(SymbolPtr& Op, NodeSeq Args) : OperatorNode(Op, SYMBOL_CODEPARSER_LIBRARY_MAKETERNARYNODE, std::move(Args)) {} }; // // TernaryNode // // a! // class PostfixNode : public OperatorNode { public: PostfixNode(SymbolPtr& Op, NodeSeq Args) : OperatorNode(Op, SYMBOL_CODEPARSER_LIBRARY_MAKEPOSTFIXNODE, std::move(Args)) {} }; // // PrefixBinaryNode // // \[Integral] f \[DifferentialD] x // class PrefixBinaryNode : public OperatorNode { public: PrefixBinaryNode(SymbolPtr& Op, NodeSeq Args) : OperatorNode(Op, SYMBOL_CODEPARSER_LIBRARY_MAKEPREFIXBINARYNODE, std::move(Args)) {} }; // // CallNode // // f[x] // class CallNode : public Node { NodeSeq Head; public: CallNode(NodeSeq Head, NodeSeq Body) : Node(std::move(Body)), Head(std::move(Head)) {} #if USE_MATHLINK void put(MLINK mlp) const override; #endif // USE_MATHLINK void print(std::ostream&) const override; Source getSource() const override; virtual bool check() const override; }; // // GroupNode // // {x} // class GroupNode : public OperatorNode { public: GroupNode(SymbolPtr& Op, NodeSeq Args) : OperatorNode(Op, SYMBOL_CODEPARSER_LIBRARY_MAKEGROUPNODE, std::move(Args)) {} }; // // Any "compound" of tokens: // // a_ // _b // a_. // #a // #abc // ##2 // %2 // class CompoundNode : public OperatorNode { public: CompoundNode(SymbolPtr& Op, NodeSeq Args) : OperatorNode(Op, SYMBOL_CODEPARSER_LIBRARY_MAKECOMPOUNDNODE, std::move(Args)) {} }; // // SyntaxErrorNode // // A syntax error that contains structure. // class SyntaxErrorNode : public Node { const SyntaxError Err; public: SyntaxErrorNode(SyntaxError Err, NodeSeq Args) : Node(std::move(Args)), Err(Err) {} #if USE_MATHLINK void put(MLINK mlp) const override; #endif // USE_MATHLINK void print(std::ostream&) const override; bool check() const override { return false; } }; // // GroupMissingCloserNode // // {] // class GroupMissingCloserNode : public OperatorNode { public: GroupMissingCloserNode(SymbolPtr& Op, NodeSeq Args) : OperatorNode(Op, SYMBOL_CODEPARSER_LIBRARY_MAKEGROUPMISSINGCLOSERNODE, std::move(Args)) {} bool check() const override { return false; } }; // // UnterminatedGroupNeedsReparseNode // // { // class UnterminatedGroupNeedsReparseNode : public OperatorNode { public: UnterminatedGroupNeedsReparseNode(SymbolPtr& Op, NodeSeq Args) : OperatorNode(Op, SYMBOL_CODEPARSER_LIBRARY_MAKEUNTERMINATEDGROUPNEEDSREPARSENODE, std::move(Args)) {} bool check() const override { return false; } }; // // // class CollectedExpressionsNode : public Node { std::vector<NodePtr> Exprs; public: CollectedExpressionsNode(std::vector<NodePtr> Exprs) : Node(), Exprs(std::move(Exprs)) {} #if USE_MATHLINK void put(MLINK mlp) const override; #endif // USE_MATHLINK void print(std::ostream&) const override; bool check() const override; }; // // // class CollectedIssuesNode : public Node { IssuePtrSet Issues; public: CollectedIssuesNode(IssuePtrSet Issues) : Node(), Issues(std::move(Issues)) {} #if USE_MATHLINK void put(MLINK mlp) const override; #endif // USE_MATHLINK void print(std::ostream&) const override; bool check() const override; }; // // // class CollectedSourceLocationsNode : public Node { std::set<SourceLocation> SourceLocs; public: CollectedSourceLocationsNode(std::set<SourceLocation> SourceLocs) : Node(), SourceLocs(std::move(SourceLocs)) {} #if USE_MATHLINK void put(MLINK mlp) const override; #endif // USE_MATHLINK void print(std::ostream&) const override; }; // // // class ListNode : public Node { std::vector<NodePtr> N; public: ListNode(std::vector<NodePtr> N) : Node(), N(std::move(N)) {} #if USE_MATHLINK void put(MLINK mlp) const override; #endif // USE_MATHLINK void print(std::ostream&) const override; bool check() const override; }; // // // class SourceCharacterNode : public Node { const SourceCharacter Char; public: SourceCharacterNode(SourceCharacter& Char) : Node(), Char(Char) {} SourceCharacterNode(SourceCharacter&& Char) : Node(), Char(std::move(Char)) {} #if USE_MATHLINK void put(MLINK mlp) const override; #endif // USE_MATHLINK void print(std::ostream&) const override; }; // // // class SafeStringNode : public Node { std::vector<unsigned char> safeBytes; public: SafeStringNode(std::vector<unsigned char>& safeBytes) : Node(), safeBytes(safeBytes) {} SafeStringNode(std::vector<unsigned char>&& safeBytes) : Node(), safeBytes(std::move(safeBytes)) {} #if USE_MATHLINK void put(MLINK mlp) const override; #endif // USE_MATHLINK void print(std::ostream&) const override; };
21.409574
170
0.651263
b7eee772f3fed77e0ce5bfb9f64acb47f517fbf7
3,927
h
C
linux/drivers/staging/wilc1000/wilc_wfi_netdevice.h
WUSTL-CSPL/RT-TEE
aafb3e9ff6c6e744c6bce1e42bcb198e1063efcc
[ "MIT" ]
3
2020-11-06T05:17:03.000Z
2020-11-06T07:32:34.000Z
linux/drivers/staging/wilc1000/wilc_wfi_netdevice.h
WUSTL-CSPL/RT-TEE
aafb3e9ff6c6e744c6bce1e42bcb198e1063efcc
[ "MIT" ]
null
null
null
linux/drivers/staging/wilc1000/wilc_wfi_netdevice.h
WUSTL-CSPL/RT-TEE
aafb3e9ff6c6e744c6bce1e42bcb198e1063efcc
[ "MIT" ]
1
2020-11-06T07:32:55.000Z
2020-11-06T07:32:55.000Z
/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. * All rights reserved. */ #ifndef WILC_WFI_NETDEVICE #define WILC_WFI_NETDEVICE #include <linux/tcp.h> #include <linux/ieee80211.h> #include <net/cfg80211.h> #include <net/ieee80211_radiotap.h> #include <linux/if_arp.h> #include <linux/gpio/consumer.h> #include "host_interface.h" #include "wilc_wlan.h" #define FLOW_CONTROL_LOWER_THRESHOLD 128 #define FLOW_CONTROL_UPPER_THRESHOLD 256 #define WILC_MAX_NUM_PMKIDS 16 #define PMKID_LEN 16 #define PMKID_FOUND 1 #define NUM_STA_ASSOCIATED 8 #define NUM_REG_FRAME 2 #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54 #define DEFAULT_LINK_SPEED 72 #define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff) struct wilc_wfi_stats { unsigned long rx_packets; unsigned long tx_packets; unsigned long rx_bytes; unsigned long tx_bytes; u64 rx_time; u64 tx_time; }; struct wilc_wfi_key { u8 *key; u8 *seq; int key_len; int seq_len; u32 cipher; }; struct wilc_wfi_wep_key { u8 *key; u8 key_len; u8 key_idx; }; struct sta_info { u8 sta_associated_bss[MAX_NUM_STA][ETH_ALEN]; }; /*Parameters needed for host interface for remaining on channel*/ struct wilc_wfi_p2p_listen_params { struct ieee80211_channel *listen_ch; u32 listen_duration; u64 listen_cookie; u32 listen_session_id; }; struct wilc_priv { struct wireless_dev *wdev; struct cfg80211_scan_request *scan_req; struct wilc_wfi_p2p_listen_params remain_on_ch_params; u64 tx_cookie; bool cfg_scanning; u32 rcvd_ch_cnt; u8 associated_bss[ETH_ALEN]; struct sta_info assoc_stainfo; struct sk_buff *skb; struct net_device *dev; struct host_if_drv *hif_drv; struct host_if_pmkid_attr pmkid_list; u8 wep_key[4][WLAN_KEY_LEN_WEP104]; u8 wep_key_len[4]; /* The real interface that the monitor is on */ struct net_device *real_ndev; struct wilc_wfi_key *wilc_gtk[MAX_NUM_STA]; struct wilc_wfi_key *wilc_ptk[MAX_NUM_STA]; u8 wilc_groupkey; /* mutexes */ struct mutex scan_req_lock; bool p2p_listen_state; }; struct frame_reg { u16 type; bool reg; }; struct wilc_vif { u8 idx; u8 iftype; int monitor_flag; int mac_opened; struct frame_reg frame_reg[NUM_REG_FRAME]; struct net_device_stats netstats; struct wilc *wilc; u8 src_addr[ETH_ALEN]; u8 bssid[ETH_ALEN]; struct host_if_drv *hif_drv; struct net_device *ndev; u8 mode; u8 ifc_id; }; struct wilc { const struct wilc_hif_func *hif_func; int io_type; int mac_status; struct gpio_desc *gpio_irq; bool initialized; int dev_irq_num; int close; u8 vif_num; struct wilc_vif *vif[NUM_CONCURRENT_IFC]; u8 open_ifcs; /*protect head of transmit queue*/ struct mutex txq_add_to_head_cs; /*protect txq_entry_t transmit queue*/ spinlock_t txq_spinlock; /*protect rxq_entry_t receiver queue*/ struct mutex rxq_cs; /* lock to protect hif access */ struct mutex hif_cs; struct completion cfg_event; struct completion sync_event; struct completion txq_event; struct completion txq_thread_started; struct task_struct *txq_thread; int quit; int cfg_frame_in_use; struct wilc_cfg_frame cfg_frame; u32 cfg_frame_offset; int cfg_seq_no; u8 *rx_buffer; u32 rx_buffer_offset; u8 *tx_buffer; struct txq_entry_t txq_head; int txq_entries; struct rxq_entry_t rxq_head; const struct firmware *firmware; struct device *dev; bool suspend_event; struct rf_info dummy_statistics; }; struct wilc_wfi_mon_priv { struct net_device *real_ndev; }; void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset); void wilc_mac_indicate(struct wilc *wilc); void wilc_netdev_cleanup(struct wilc *wilc); int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, const struct wilc_hif_func *ops); void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size); int wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode); #endif
21.342391
79
0.770053
b7ef16b28280d6c10db78e3e16113d49ab670195
20,759
c
C
net-next/drivers/iio/light/gp2ap002.c
CavalryXD/APN6_Repo
7a6af135ad936d52599b3ce59cf4f377a97a51d4
[ "Apache-2.0" ]
2
2020-09-18T07:01:49.000Z
2022-01-27T08:59:04.000Z
net-next/drivers/iio/light/gp2ap002.c
MaoJianwei/Mao_Linux_Network_Enhance
2ba9e6278e3f405dcb9fc807d9f9a8d4ff0356dd
[ "Apache-2.0" ]
null
null
null
net-next/drivers/iio/light/gp2ap002.c
MaoJianwei/Mao_Linux_Network_Enhance
2ba9e6278e3f405dcb9fc807d9f9a8d4ff0356dd
[ "Apache-2.0" ]
4
2020-06-29T04:09:48.000Z
2022-01-27T08:59:01.000Z
// SPDX-License-Identifier: GPL-2.0-only /* * These are the two Sharp GP2AP002 variants supported by this driver: * GP2AP002A00F Ambient Light and Proximity Sensor * GP2AP002S00F Proximity Sensor * * Copyright (C) 2020 Linaro Ltd. * Author: Linus Walleij <linus.walleij@linaro.org> * * Based partly on the code in Sony Ericssons GP2AP00200F driver by * Courtney Cavin and Oskar Andero in drivers/input/misc/gp2ap002a00f.c * Based partly on a Samsung misc driver submitted by * Donggeun Kim & Minkyu Kang in 2011: * https://lore.kernel.org/lkml/1315556546-7445-1-git-send-email-dg77.kim@samsung.com/ * Based partly on a submission by * Jonathan Bakker and Paweł Chmiel in january 2019: * https://lore.kernel.org/linux-input/20190125175045.22576-1-pawel.mikolaj.chmiel@gmail.com/ * Based partly on code from the Samsung GT-S7710 by <mjchen@sta.samsung.com> * Based partly on the code in LG Electronics GP2AP00200F driver by * Kenobi Lee <sungyoung.lee@lge.com> and EunYoung Cho <ey.cho@lge.com> */ #include <linux/module.h> #include <linux/i2c.h> #include <linux/regmap.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h> #include <linux/iio/events.h> #include <linux/iio/consumer.h> /* To get our ADC channel */ #include <linux/iio/types.h> /* To deal with our ADC channel */ #include <linux/init.h> #include <linux/delay.h> #include <linux/regulator/consumer.h> #include <linux/pm_runtime.h> #include <linux/interrupt.h> #include <linux/bits.h> #include <linux/math64.h> #include <linux/pm.h> #define GP2AP002_PROX_CHANNEL 0 #define GP2AP002_ALS_CHANNEL 1 /* ------------------------------------------------------------------------ */ /* ADDRESS SYMBOL DATA Init R/W */ /* D7 D6 D5 D4 D3 D2 D1 D0 */ /* ------------------------------------------------------------------------ */ /* 0 PROX X X X X X X X VO H'00 R */ /* 1 GAIN X X X X LED0 X X X H'00 W */ /* 2 HYS HYSD HYSC1 HYSC0 X HYSF3 HYSF2 HYSF1 HYSF0 H'00 W */ /* 3 CYCLE X X CYCL2 CYCL1 CYCL0 OSC2 X X H'00 W */ /* 4 OPMOD X X X ASD X X VCON SSD H'00 W */ /* 6 CON X X X OCON1 OCON0 X X X H'00 W */ /* ------------------------------------------------------------------------ */ /* VO :Proximity sensing result(0: no detection, 1: detection) */ /* LED0 :Select switch for LED driver's On-registence(0:2x higher, 1:normal)*/ /* HYSD/HYSF :Adjusts the receiver sensitivity */ /* OSC :Select switch internal clocl frequency hoppling(0:effective) */ /* CYCL :Determine the detection cycle(typically 8ms, up to 128x) */ /* SSD :Software Shutdown function(0:shutdown, 1:operating) */ /* VCON :VOUT output method control(0:normal, 1:interrupt) */ /* ASD :Select switch for analog sleep function(0:ineffective, 1:effective)*/ /* OCON :Select switch for enabling/disabling VOUT (00:enable, 11:disable) */ #define GP2AP002_PROX 0x00 #define GP2AP002_GAIN 0x01 #define GP2AP002_HYS 0x02 #define GP2AP002_CYCLE 0x03 #define GP2AP002_OPMOD 0x04 #define GP2AP002_CON 0x06 #define GP2AP002_PROX_VO_DETECT BIT(0) /* Setting this bit to 0 means 2x higher LED resistance */ #define GP2AP002_GAIN_LED_NORMAL BIT(3) /* * These bits adjusts the proximity sensitivity, determining characteristics * of the detection distance and its hysteresis. */ #define GP2AP002_HYS_HYSD_SHIFT 7 #define GP2AP002_HYS_HYSD_MASK BIT(7) #define GP2AP002_HYS_HYSC_SHIFT 5 #define GP2AP002_HYS_HYSC_MASK GENMASK(6, 5) #define GP2AP002_HYS_HYSF_SHIFT 0 #define GP2AP002_HYS_HYSF_MASK GENMASK(3, 0) #define GP2AP002_HYS_MASK (GP2AP002_HYS_HYSD_MASK | \ GP2AP002_HYS_HYSC_MASK | \ GP2AP002_HYS_HYSF_MASK) /* * These values determine the detection cycle response time * 0: 8ms, 1: 16ms, 2: 32ms, 3: 64ms, 4: 128ms, * 5: 256ms, 6: 512ms, 7: 1024ms */ #define GP2AP002_CYCLE_CYCL_SHIFT 3 #define GP2AP002_CYCLE_CYCL_MASK GENMASK(5, 3) /* * Select switch for internal clock frequency hopping * 0: effective, * 1: ineffective */ #define GP2AP002_CYCLE_OSC_EFFECTIVE 0 #define GP2AP002_CYCLE_OSC_INEFFECTIVE BIT(2) #define GP2AP002_CYCLE_OSC_MASK BIT(2) /* Analog sleep effective */ #define GP2AP002_OPMOD_ASD BIT(4) /* Enable chip */ #define GP2AP002_OPMOD_SSD_OPERATING BIT(0) /* IRQ mode */ #define GP2AP002_OPMOD_VCON_IRQ BIT(1) #define GP2AP002_OPMOD_MASK (BIT(0) | BIT(1) | BIT(4)) /* * Select switch for enabling/disabling Vout pin * 0: enable * 2: force to go Low * 3: force to go High */ #define GP2AP002_CON_OCON_SHIFT 3 #define GP2AP002_CON_OCON_ENABLE (0x0 << GP2AP002_CON_OCON_SHIFT) #define GP2AP002_CON_OCON_LOW (0x2 << GP2AP002_CON_OCON_SHIFT) #define GP2AP002_CON_OCON_HIGH (0x3 << GP2AP002_CON_OCON_SHIFT) #define GP2AP002_CON_OCON_MASK (0x3 << GP2AP002_CON_OCON_SHIFT) /** * struct gp2ap002 - GP2AP002 state * @map: regmap pointer for the i2c regmap * @dev: pointer to parent device * @vdd: regulator controlling VDD * @vio: regulator controlling VIO * @alsout: IIO ADC channel to convert the ALSOUT signal * @hys_far: hysteresis control from device tree * @hys_close: hysteresis control from device tree * @is_gp2ap002s00f: this is the GP2AP002F variant of the chip * @irq: the IRQ line used by this device * @enabled: we cannot read the status of the hardware so we need to * keep track of whether the event is enabled using this state variable */ struct gp2ap002 { struct regmap *map; struct device *dev; struct regulator *vdd; struct regulator *vio; struct iio_channel *alsout; u8 hys_far; u8 hys_close; bool is_gp2ap002s00f; int irq; bool enabled; }; static irqreturn_t gp2ap002_prox_irq(int irq, void *d) { struct iio_dev *indio_dev = d; struct gp2ap002 *gp2ap002 = iio_priv(indio_dev); u64 ev; int val; int ret; ret = regmap_read(gp2ap002->map, GP2AP002_PROX, &val); if (ret) { dev_err(gp2ap002->dev, "error reading proximity\n"); goto err_retrig; } if (val & GP2AP002_PROX_VO_DETECT) { /* Close */ dev_dbg(gp2ap002->dev, "close\n"); ret = regmap_write(gp2ap002->map, GP2AP002_HYS, gp2ap002->hys_far); if (ret) dev_err(gp2ap002->dev, "error setting up proximity hysteresis\n"); ev = IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, GP2AP002_PROX_CHANNEL, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING); } else { /* Far */ dev_dbg(gp2ap002->dev, "far\n"); ret = regmap_write(gp2ap002->map, GP2AP002_HYS, gp2ap002->hys_close); if (ret) dev_err(gp2ap002->dev, "error setting up proximity hysteresis\n"); ev = IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, GP2AP002_PROX_CHANNEL, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING); } iio_push_event(indio_dev, ev, iio_get_time_ns(indio_dev)); /* * After changing hysteresis, we need to wait for one detection * cycle to see if anything changed, or we will just trigger the * previous interrupt again. A detection cycle depends on the CYCLE * register, we are hard-coding ~8 ms in probe() so wait some more * than this, 20-30 ms. */ usleep_range(20000, 30000); err_retrig: ret = regmap_write(gp2ap002->map, GP2AP002_CON, GP2AP002_CON_OCON_ENABLE); if (ret) dev_err(gp2ap002->dev, "error setting up VOUT control\n"); return IRQ_HANDLED; } /* * This array maps current and lux. * * Ambient light sensing range is 3 to 55000 lux. * * This mapping is based on the following formula. * illuminance = 10 ^ (current[mA] / 10) * * When the ADC measures 0, return 0 lux. */ static const u16 gp2ap002_illuminance_table[] = { 0, 1, 1, 2, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 25, 32, 40, 50, 63, 79, 100, 126, 158, 200, 251, 316, 398, 501, 631, 794, 1000, 1259, 1585, 1995, 2512, 3162, 3981, 5012, 6310, 7943, 10000, 12589, 15849, 19953, 25119, 31623, 39811, 50119, }; static int gp2ap002_get_lux(struct gp2ap002 *gp2ap002) { int ret, res; u16 lux; ret = iio_read_channel_processed(gp2ap002->alsout, &res); if (ret < 0) return ret; dev_dbg(gp2ap002->dev, "read %d mA from ADC\n", res); /* ensure we don't under/overflow */ res = clamp(res, 0, (int)ARRAY_SIZE(gp2ap002_illuminance_table) - 1); lux = gp2ap002_illuminance_table[res]; return (int)lux; } static int gp2ap002_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) { struct gp2ap002 *gp2ap002 = iio_priv(indio_dev); int ret; switch (mask) { case IIO_CHAN_INFO_RAW: switch (chan->type) { case IIO_LIGHT: ret = gp2ap002_get_lux(gp2ap002); if (ret < 0) return ret; *val = ret; return IIO_VAL_INT; default: return -EINVAL; } default: return -EINVAL; } } static int gp2ap002_init(struct gp2ap002 *gp2ap002) { int ret; /* Set up the IR LED resistance */ ret = regmap_write(gp2ap002->map, GP2AP002_GAIN, GP2AP002_GAIN_LED_NORMAL); if (ret) { dev_err(gp2ap002->dev, "error setting up LED gain\n"); return ret; } ret = regmap_write(gp2ap002->map, GP2AP002_HYS, gp2ap002->hys_far); if (ret) { dev_err(gp2ap002->dev, "error setting up proximity hysteresis\n"); return ret; } /* Disable internal frequency hopping */ ret = regmap_write(gp2ap002->map, GP2AP002_CYCLE, GP2AP002_CYCLE_OSC_INEFFECTIVE); if (ret) { dev_err(gp2ap002->dev, "error setting up internal frequency hopping\n"); return ret; } /* Enable chip and IRQ, disable analog sleep */ ret = regmap_write(gp2ap002->map, GP2AP002_OPMOD, GP2AP002_OPMOD_SSD_OPERATING | GP2AP002_OPMOD_VCON_IRQ); if (ret) { dev_err(gp2ap002->dev, "error setting up operation mode\n"); return ret; } /* Interrupt on VOUT enabled */ ret = regmap_write(gp2ap002->map, GP2AP002_CON, GP2AP002_CON_OCON_ENABLE); if (ret) dev_err(gp2ap002->dev, "error setting up VOUT control\n"); return ret; } static int gp2ap002_read_event_config(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir) { struct gp2ap002 *gp2ap002 = iio_priv(indio_dev); /* * We just keep track of this internally, as it is not possible to * query the hardware. */ return gp2ap002->enabled; } static int gp2ap002_write_event_config(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, int state) { struct gp2ap002 *gp2ap002 = iio_priv(indio_dev); if (state) { /* * This will bring the regulators up (unless they are on * already) and reintialize the sensor by using runtime_pm * callbacks. */ pm_runtime_get_sync(gp2ap002->dev); gp2ap002->enabled = true; } else { pm_runtime_mark_last_busy(gp2ap002->dev); pm_runtime_put_autosuspend(gp2ap002->dev); gp2ap002->enabled = false; } return 0; } static const struct iio_info gp2ap002_info = { .read_raw = gp2ap002_read_raw, .read_event_config = gp2ap002_read_event_config, .write_event_config = gp2ap002_write_event_config, }; static const struct iio_event_spec gp2ap002_events[] = { { .type = IIO_EV_TYPE_THRESH, .dir = IIO_EV_DIR_EITHER, .mask_separate = BIT(IIO_EV_INFO_ENABLE), }, }; static const struct iio_chan_spec gp2ap002_channels[] = { { .type = IIO_PROXIMITY, .event_spec = gp2ap002_events, .num_event_specs = ARRAY_SIZE(gp2ap002_events), }, { .type = IIO_LIGHT, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .channel = GP2AP002_ALS_CHANNEL, }, }; /* * We need a special regmap because this hardware expects to * write single bytes to registers but read a 16bit word on some * variants and discard the lower 8 bits so combine * i2c_smbus_read_word_data() with i2c_smbus_write_byte_data() * selectively like this. */ static int gp2ap002_regmap_i2c_read(void *context, unsigned int reg, unsigned int *val) { struct device *dev = context; struct i2c_client *i2c = to_i2c_client(dev); int ret; ret = i2c_smbus_read_word_data(i2c, reg); if (ret < 0) return ret; *val = (ret >> 8) & 0xFF; return 0; } static int gp2ap002_regmap_i2c_write(void *context, unsigned int reg, unsigned int val) { struct device *dev = context; struct i2c_client *i2c = to_i2c_client(dev); return i2c_smbus_write_byte_data(i2c, reg, val); } static struct regmap_bus gp2ap002_regmap_bus = { .reg_read = gp2ap002_regmap_i2c_read, .reg_write = gp2ap002_regmap_i2c_write, }; static int gp2ap002_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct gp2ap002 *gp2ap002; struct iio_dev *indio_dev; struct device *dev = &client->dev; enum iio_chan_type ch_type; static const struct regmap_config config = { .reg_bits = 8, .val_bits = 8, .max_register = GP2AP002_CON, }; struct regmap *regmap; int num_chan; const char *compat; u8 val; int ret; indio_dev = devm_iio_device_alloc(dev, sizeof(*gp2ap002)); if (!indio_dev) return -ENOMEM; i2c_set_clientdata(client, indio_dev); gp2ap002 = iio_priv(indio_dev); gp2ap002->dev = dev; /* * Check the device compatible like this makes it possible to use * ACPI PRP0001 for registering the sensor using device tree * properties. */ ret = device_property_read_string(dev, "compatible", &compat); if (ret) { dev_err(dev, "cannot check compatible\n"); return ret; } gp2ap002->is_gp2ap002s00f = !strcmp(compat, "sharp,gp2ap002s00f"); regmap = devm_regmap_init(dev, &gp2ap002_regmap_bus, dev, &config); if (IS_ERR(regmap)) { dev_err(dev, "Failed to register i2c regmap %d\n", (int)PTR_ERR(regmap)); return PTR_ERR(regmap); } gp2ap002->map = regmap; /* * The hysteresis settings are coded into the device tree as values * to be written into the hysteresis register. The datasheet defines * modes "A", "B1" and "B2" with fixed values to be use but vendor * code trees for actual devices are tweaking these values and refer to * modes named things like "B1.5". To be able to support any devices, * we allow passing an arbitrary hysteresis setting for "near" and * "far". */ /* Check the device tree for the IR LED hysteresis */ ret = device_property_read_u8(dev, "sharp,proximity-far-hysteresis", &val); if (ret) { dev_err(dev, "failed to obtain proximity far setting\n"); return ret; } dev_dbg(dev, "proximity far setting %02x\n", val); gp2ap002->hys_far = val; ret = device_property_read_u8(dev, "sharp,proximity-close-hysteresis", &val); if (ret) { dev_err(dev, "failed to obtain proximity close setting\n"); return ret; } dev_dbg(dev, "proximity close setting %02x\n", val); gp2ap002->hys_close = val; /* The GP2AP002A00F has a light sensor too */ if (!gp2ap002->is_gp2ap002s00f) { gp2ap002->alsout = devm_iio_channel_get(dev, "alsout"); if (IS_ERR(gp2ap002->alsout)) { if (PTR_ERR(gp2ap002->alsout) == -ENODEV) { dev_err(dev, "no ADC, deferring...\n"); return -EPROBE_DEFER; } dev_err(dev, "failed to get ALSOUT ADC channel\n"); return PTR_ERR(gp2ap002->alsout); } ret = iio_get_channel_type(gp2ap002->alsout, &ch_type); if (ret < 0) return ret; if (ch_type != IIO_CURRENT) { dev_err(dev, "wrong type of IIO channel specified for ALSOUT\n"); return -EINVAL; } } gp2ap002->vdd = devm_regulator_get(dev, "vdd"); if (IS_ERR(gp2ap002->vdd)) { dev_err(dev, "failed to get VDD regulator\n"); return PTR_ERR(gp2ap002->vdd); } gp2ap002->vio = devm_regulator_get(dev, "vio"); if (IS_ERR(gp2ap002->vio)) { dev_err(dev, "failed to get VIO regulator\n"); return PTR_ERR(gp2ap002->vio); } /* Operating voltage 2.4V .. 3.6V according to datasheet */ ret = regulator_set_voltage(gp2ap002->vdd, 2400000, 3600000); if (ret) { dev_err(dev, "failed to sett VDD voltage\n"); return ret; } /* VIO should be between 1.65V and VDD */ ret = regulator_get_voltage(gp2ap002->vdd); if (ret < 0) { dev_err(dev, "failed to get VDD voltage\n"); return ret; } ret = regulator_set_voltage(gp2ap002->vio, 1650000, ret); if (ret) { dev_err(dev, "failed to set VIO voltage\n"); return ret; } ret = regulator_enable(gp2ap002->vdd); if (ret) { dev_err(dev, "failed to enable VDD regulator\n"); return ret; } ret = regulator_enable(gp2ap002->vio); if (ret) { dev_err(dev, "failed to enable VIO regulator\n"); goto out_disable_vdd; } msleep(20); /* * Initialize the device and signal to runtime PM that now we are * definately up and using power. */ ret = gp2ap002_init(gp2ap002); if (ret) { dev_err(dev, "initialization failed\n"); goto out_disable_vio; } pm_runtime_get_noresume(dev); pm_runtime_set_active(dev); pm_runtime_enable(dev); gp2ap002->enabled = false; ret = devm_request_threaded_irq(dev, client->irq, NULL, gp2ap002_prox_irq, IRQF_ONESHOT, "gp2ap002", indio_dev); if (ret) { dev_err(dev, "unable to request IRQ\n"); goto out_disable_vio; } gp2ap002->irq = client->irq; /* * As the device takes 20 ms + regulator delay to come up with a fresh * measurement after power-on, do not shut it down unnecessarily. * Set autosuspend to a one second. */ pm_runtime_set_autosuspend_delay(dev, 1000); pm_runtime_use_autosuspend(dev); pm_runtime_put(dev); indio_dev->dev.parent = dev; indio_dev->info = &gp2ap002_info; indio_dev->name = "gp2ap002"; indio_dev->channels = gp2ap002_channels; /* Skip light channel for the proximity-only sensor */ num_chan = ARRAY_SIZE(gp2ap002_channels); if (gp2ap002->is_gp2ap002s00f) num_chan--; indio_dev->num_channels = num_chan; indio_dev->modes = INDIO_DIRECT_MODE; ret = iio_device_register(indio_dev); if (ret) goto out_disable_pm; dev_dbg(dev, "Sharp GP2AP002 probed successfully\n"); return 0; out_disable_pm: pm_runtime_put_noidle(dev); pm_runtime_disable(dev); out_disable_vio: regulator_disable(gp2ap002->vio); out_disable_vdd: regulator_disable(gp2ap002->vdd); return ret; } static int gp2ap002_remove(struct i2c_client *client) { struct iio_dev *indio_dev = i2c_get_clientdata(client); struct gp2ap002 *gp2ap002 = iio_priv(indio_dev); struct device *dev = &client->dev; pm_runtime_get_sync(dev); pm_runtime_put_noidle(dev); pm_runtime_disable(dev); iio_device_unregister(indio_dev); regulator_disable(gp2ap002->vio); regulator_disable(gp2ap002->vdd); return 0; } static int __maybe_unused gp2ap002_runtime_suspend(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct gp2ap002 *gp2ap002 = iio_priv(indio_dev); int ret; /* Deactivate the IRQ */ disable_irq(gp2ap002->irq); /* Disable chip and IRQ, everything off */ ret = regmap_write(gp2ap002->map, GP2AP002_OPMOD, 0x00); if (ret) { dev_err(gp2ap002->dev, "error setting up operation mode\n"); return ret; } /* * As these regulators may be shared, at least we are now in * sleep even if the regulators aren't really turned off. */ regulator_disable(gp2ap002->vio); regulator_disable(gp2ap002->vdd); return 0; } static int __maybe_unused gp2ap002_runtime_resume(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct gp2ap002 *gp2ap002 = iio_priv(indio_dev); int ret; ret = regulator_enable(gp2ap002->vdd); if (ret) { dev_err(dev, "failed to enable VDD regulator in resume path\n"); return ret; } ret = regulator_enable(gp2ap002->vio); if (ret) { dev_err(dev, "failed to enable VIO regulator in resume path\n"); return ret; } msleep(20); ret = gp2ap002_init(gp2ap002); if (ret) { dev_err(dev, "re-initialization failed\n"); return ret; } /* Re-activate the IRQ */ enable_irq(gp2ap002->irq); return 0; } static const struct dev_pm_ops gp2ap002_dev_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) SET_RUNTIME_PM_OPS(gp2ap002_runtime_suspend, gp2ap002_runtime_resume, NULL) }; static const struct i2c_device_id gp2ap002_id_table[] = { { "gp2ap002", 0 }, { }, }; MODULE_DEVICE_TABLE(i2c, gp2ap002_id_table); static const struct of_device_id gp2ap002_of_match[] = { { .compatible = "sharp,gp2ap002a00f" }, { .compatible = "sharp,gp2ap002s00f" }, { }, }; MODULE_DEVICE_TABLE(of, gp2ap002_of_match); static struct i2c_driver gp2ap002_driver = { .driver = { .name = "gp2ap002", .of_match_table = gp2ap002_of_match, .pm = &gp2ap002_dev_pm_ops, }, .probe = gp2ap002_probe, .remove = gp2ap002_remove, .id_table = gp2ap002_id_table, }; module_i2c_driver(gp2ap002_driver); MODULE_AUTHOR("Linus Walleij <linus.walleij@linaro.org>"); MODULE_DESCRIPTION("GP2AP002 ambient light and proximity sensor driver"); MODULE_LICENSE("GPL v2");
28.791956
93
0.697481
b7f01d8b8192d91aaf37f9edcaee79387e50d56d
153
h
C
include/gf3d_map.h
taranack/gf3d
6daa91428597d94d72bd2812b1517c55c4a36a27
[ "MIT" ]
null
null
null
include/gf3d_map.h
taranack/gf3d
6daa91428597d94d72bd2812b1517c55c4a36a27
[ "MIT" ]
null
null
null
include/gf3d_map.h
taranack/gf3d
6daa91428597d94d72bd2812b1517c55c4a36a27
[ "MIT" ]
null
null
null
#ifndef GF3D_GF3D_MAP_H #define GF3D_GF3D_MAP_H #define X 17 #define Y 16 int manhattanDist(int x1, int y1, int x2, int y2); #endif //GF3D_GF3D_MAP_H
15.3
50
0.75817
b7f22032cf9c5af63b5010e8294063ad855a61d9
2,731
h
C
client/include/util/Logger.h
MayconFelipeA/sampvoiceatt
3fae8a2cf37dfad2e3925d56aebfbbcd4162b0ff
[ "MIT" ]
97
2019-01-13T20:19:19.000Z
2022-02-27T18:47:11.000Z
client/include/util/Logger.h
MayconFelipeA/sampvoiceatt
3fae8a2cf37dfad2e3925d56aebfbbcd4162b0ff
[ "MIT" ]
92
2019-01-23T23:02:31.000Z
2022-03-23T19:59:40.000Z
client/include/util/Logger.h
MayconFelipeA/sampvoiceatt
3fae8a2cf37dfad2e3925d56aebfbbcd4162b0ff
[ "MIT" ]
69
2019-01-13T22:01:40.000Z
2022-03-09T00:55:49.000Z
/* This is a SampVoice project file Developer: CyberMor <cyber.mor.2020@gmail.ru> See more here https://github.com/CyberMor/sampvoice Copyright (c) Daniel (CyberMor) 2020 All rights reserved */ #pragma once #include <ctime> #include <iostream> #include <algorithm> #include <mutex> #include <array> #include <d3d9.h> #include "Samp.h" #define DefineColor(name, rgb) \ constexpr auto k##name##Color = 0xff##rgb##u; \ constexpr auto k##name##ColorStr = #rgb; DefineColor(Debug, 6bbaed); DefineColor(Success, 6bbf17); DefineColor(Error, e65f39); DefineColor(Info, ffe0a5); #undef DefineColor class Logger { Logger() = delete; ~Logger() = delete; Logger(const Logger&) = delete; Logger(Logger&&) = delete; Logger& operator=(const Logger&) = delete; Logger& operator=(Logger&&) = delete; public: static bool Init(const char* fileName) noexcept; static bool Free() noexcept; template<class... ARGS> static bool LogToFile(const char* message, ARGS... args) noexcept { const std::scoped_lock lock { Logger::logFileMutex }; if (Logger::logFile == nullptr) return false; const auto cTime = std::time(nullptr); const auto timeOfDay = std::localtime(&cTime); if (timeOfDay == nullptr) return false; std::fprintf(Logger::logFile, "[%.2d:%.2d:%.2d] : ", timeOfDay->tm_hour, timeOfDay->tm_min, timeOfDay->tm_sec); std::fprintf(Logger::logFile, message, args...); std::fputc('\n', Logger::logFile); std::fflush(Logger::logFile); return true; } template<class... ARGS> static bool LogToChat(D3DCOLOR color, const char* message, ARGS... args) noexcept { constexpr auto kMaxLengthMessage = 144; std::array<char, kMaxLengthMessage> messageBuffer; if (const auto length = std::snprintf(messageBuffer.data(), messageBuffer.size(), message, args...); length != std::clamp(length, 0, static_cast<int>(messageBuffer.size() - 1))) { Logger::LogToFile("[inf:logger:logtochat] : message is too long to display in chat"); return false; } { const std::scoped_lock lock { Logger::logChatMutex }; Samp::AddMessageToChat(color, messageBuffer.data()); } return true; } template<class... ARGS> static inline void Log(D3DCOLOR color, const char* message, ARGS... args) noexcept { Logger::LogToFile(message, args...); Logger::LogToChat(color, message, args...); } private: static std::FILE* logFile; static std::mutex logFileMutex; static std::mutex logChatMutex; };
25.523364
108
0.623947
b7f4e81ef58386fe7d7669d23e4c22de8198140d
2,076
h
C
app/src/main/jni/SubWalletCallback.h
chunshulimao/Elastos.App.UnionSquare.Android
5ce2f327a938ae7554c6f3d53c1850a46f250304
[ "MIT" ]
null
null
null
app/src/main/jni/SubWalletCallback.h
chunshulimao/Elastos.App.UnionSquare.Android
5ce2f327a938ae7554c6f3d53c1850a46f250304
[ "MIT" ]
null
null
null
app/src/main/jni/SubWalletCallback.h
chunshulimao/Elastos.App.UnionSquare.Android
5ce2f327a938ae7554c6f3d53c1850a46f250304
[ "MIT" ]
null
null
null
// Copyright (c) 2012-2018 The Elastos Open Source Project // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef ELA_WALLET_ANDROID_SUBWALLETCALLBACK_H #define ELA_WALLET_ANDROID_SUBWALLETCALLBACK_H #include "ISubWalletCallback.h" #include "Utils.h" #include "ISubWallet.h" #include "nlohmann/json.hpp" namespace Elastos { namespace ElaWallet { class SubWalletCallback : public ISubWalletCallback { public: SubWalletCallback(JNIEnv *env, jobject jobj); public: virtual void OnTransactionStatusChanged( const std::string &txid, const std::string &status, const nlohmann::json &desc, uint32_t confirms); /** * Callback method fired when best block chain height increased. This callback could be used to show progress. * @param progressInfo progress info contain detail as below: * { * "Progress": 50, # 0% ~ 100% * "BytesPerSecond": 12345678, # 12.345678 MBytes / s * "LastBlockTime": 1573799697, # timestamp of last block * "DownloadPeer": "127.0.0.1" # IP address of node * } */ virtual void OnBlockSyncProgress(const nlohmann::json &progressInfo); virtual void OnBalanceChanged(const std::string &asset, const std::string &balance); virtual void OnTxPublished(const std::string &hash, const nlohmann::json &result); virtual void OnAssetRegistered(const std::string &asset, const nlohmann::json &info); virtual void OnConnectStatusChanged(const std::string &status); virtual ~SubWalletCallback(); private: JNIEnv *GetEnv(); private: JavaVM *_jvm; jobject _obj; }; } } #endif //ELA_WALLET_ANDROID_SUBWALLETCALLBACK_H
34.032787
122
0.603565
b7f60c074f24fabf4140491d4f5e39649db89965
31,779
h
C
XcodeClasses/Xcode6.0/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk/System/Library/PrivateFrameworks/PersistentConnection.h
teemobean/XVim
acd7c82665185140293c94efc7ab14328d29cf63
[ "MIT" ]
3,384
2015-01-01T16:20:45.000Z
2022-02-25T07:07:35.000Z
XcodeClasses/Xcode6.0/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk/System/Library/PrivateFrameworks/PersistentConnection.h
teemobean/XVim
acd7c82665185140293c94efc7ab14328d29cf63
[ "MIT" ]
405
2015-01-01T15:45:43.000Z
2021-03-03T01:25:17.000Z
XcodeClasses/Xcode6.0/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk/System/Library/PrivateFrameworks/PersistentConnection.h
teemobean/XVim
acd7c82665185140293c94efc7ab14328d29cf63
[ "MIT" ]
580
2015-01-01T14:25:54.000Z
2021-12-18T15:51:31.000Z
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #pragma mark Blocks typedef void (^CDUnknownBlockType)(void); // return type and parameters are unknown #pragma mark Named Structures struct __va_list_tag { unsigned int _field1; unsigned int _field2; void *_field3; void *_field4; }; #pragma mark - // // File: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PersistentConnection.framework/PersistentConnection // UUID: 78EE1B73-6FAC-3E8A-948B-800FC7858EBE // // Arch: x86_64 // Current version: 1.0.0 // Compatibility version: 1.0.0 // Source version: 290.0.0.0.0 // Minimum iOS version: 8.0.0 // SDK version: 8.0.0 // // Objective-C Garbage Collection: Unsupported // @protocol CUTPowerMonitorDelegate <NSObject> @optional - (void)cutPowerMonitorSystemHasPoweredOn:(CUTPowerMonitor *)arg1; - (void)cutPowerMonitorBatteryConnectedStateDidChange:(CUTPowerMonitor *)arg1; @end @protocol NSLocking - (void)unlock; - (void)lock; @end @protocol NSObject @property(readonly, copy) NSString *description; @property(readonly) Class superclass; @property(readonly) unsigned long long hash; - (struct _NSZone *)zone; - (unsigned long long)retainCount; - (id)autorelease; - (oneway void)release; - (id)retain; - (_Bool)respondsToSelector:(SEL)arg1; - (_Bool)conformsToProtocol:(Protocol *)arg1; - (_Bool)isMemberOfClass:(Class)arg1; - (_Bool)isKindOfClass:(Class)arg1; - (_Bool)isProxy; - (id)performSelector:(SEL)arg1 withObject:(id)arg2 withObject:(id)arg3; - (id)performSelector:(SEL)arg1 withObject:(id)arg2; - (id)performSelector:(SEL)arg1; - (id)self; - (Class)class; - (_Bool)isEqual:(id)arg1; @optional @property(readonly, copy) NSString *debugDescription; @end @protocol PCGrowthAlgorithm <PCLoggingDelegate, NSObject> @property(readonly, copy, nonatomic) NSDictionary *cacheInfo; @property(readonly, nonatomic) unsigned long long countOfGrowthActions; @property(nonatomic) double maximumKeepAliveInterval; @property(nonatomic) double minimumKeepAliveInterval; @property(readonly, nonatomic) double currentKeepAliveInterval; - (void)processNextAction:(int)arg1; - (_Bool)useIntervalIfImprovement:(double)arg1; - (id)initWithCacheInfo:(NSDictionary *)arg1 loggingIdentifier:(NSString *)arg2 algorithmName:(NSString *)arg3; @end @protocol PCInterfaceMonitorDelegate <NSObject> @optional - (void)interfaceRadioHotnessChanged:(PCInterfaceMonitor *)arg1; - (void)interfaceReachabilityChanged:(PCInterfaceMonitor *)arg1; - (void)interfaceLinkQualityChanged:(PCInterfaceMonitor *)arg1 previousLinkQuality:(int)arg2; @end @protocol PCInterfaceMonitorProtocol <NSObject> @property(readonly, nonatomic) _Bool isRadioHot; @property(readonly, nonatomic) _Bool isBadLinkQuality; @property(readonly, nonatomic) _Bool isPoorLinkQuality; @property(readonly, retain, nonatomic) NSString *linkQualityString; @property(readonly, nonatomic) _Bool isInternetReachable; @property(readonly, nonatomic) _Bool isInterfaceHistoricallyUsable; @property(readonly, nonatomic) _Bool isInterfaceUsable; @property(readonly, nonatomic) int linkQuality; @property(readonly, nonatomic) long long interfaceIdentifier; @optional @property(readonly, nonatomic) struct __CFString *wwanInterfaceName; @property(readonly, nonatomic) _Bool isLTEWithCDRX; @property(readonly, nonatomic) struct __CFString *currentRAT; @end @protocol PCInterfaceUsabilityMonitorDelegate <NSObject> @optional - (void)interfaceRadioHotnessChanged:(NSObject<PCInterfaceUsabilityMonitorProtocol> *)arg1; - (void)interfaceReachabilityChanged:(NSObject<PCInterfaceUsabilityMonitorProtocol> *)arg1; - (void)interfaceLinkQualityChanged:(NSObject<PCInterfaceUsabilityMonitorProtocol> *)arg1 previousLinkQuality:(int)arg2; @end @protocol PCInterfaceUsabilityMonitorProtocol <PCInterfaceMonitorProtocol> @property(nonatomic) id <PCInterfaceUsabilityMonitorDelegate> delegate; @property(readonly, nonatomic) _Bool isRadioHot; - (void)setTrackUsability:(_Bool)arg1; - (void)setThresholdOffTransitionCount:(unsigned long long)arg1; - (void)setTrackedTimeInterval:(double)arg1; @end @protocol PCLoggingDelegate <NSObject> @property(readonly, nonatomic) NSString *loggingIdentifier; @end __attribute__((visibility("hidden"))) @interface PCCancelAllProcessWakesOperation : NSOperation { } - (_Bool)doesPidMatchCurrentProcessName:(int)arg1; - (void)main; @end @interface PCConnectionManager : NSObject <PCLoggingDelegate, PCInterfaceMonitorDelegate> { int _connectionClass; id <PCConnectionManagerDelegate> _delegate; NSString *_serviceIdentifier; NSString *_duetIdentifier; int _prefsStyle; int _onlyAllowedStyle; _Bool _onlyAllowedStyleSet; long long _interfaceIdentifier; unsigned long long _guidancePriority; NSRunLoop *_delegateRunLoop; NSObject<OS_dispatch_queue> *_delegateQueue; id <PCGrowthAlgorithm> _wwanGrowthAlgorithm; id <PCGrowthAlgorithm> _wifiGrowthAlgorithm; id <PCGrowthAlgorithm> _lastScheduledGrowthAlgorithm; PCPersistentTimer *_intervalTimer; PCPersistentTimer *_reconnectWakeTimer; PCPersistentTimer *_delayTimer; unsigned int _powerAssertionID; double _onTimeKeepAliveTime; double _lastResumeTime; double _lastStopTime; double _lastReachableTime; double _lastReconnectTime; double _lastScheduledIntervalTime; double _timerGuidance; double _keepAliveGracePeriod; unsigned int _reconnectIteration; int _timerGuidanceToken; int _pushIsConnectedToken; int _prefsChangedToken; double _defaultPollingInterval; double _pollingIntervalOverride; _Bool _pollingIntervalOverrideSet; _Bool _hasStarted; _Bool _isRunning; _Bool _inCallback; _Bool _isInReconnectMode; _Bool _reconnectWithKeepAliveDelay; _Bool _forceManualWhenRoaming; _Bool _enableNonCellularConnections; _Bool _isReachable; _Bool _disableEarlyFire; } + (_Bool)_isCachedKeepAliveIntervalStillValid:(double)arg1 date:(id)arg2; + (id)_keepAliveCachePath; + (id)intervalCacheDictionaries; + (Class)growthAlgorithmClass; @property(readonly, nonatomic) NSString *loggingIdentifier; // @synthesize loggingIdentifier=_serviceIdentifier; @property(nonatomic) double keepAliveGracePeriod; // @synthesize keepAliveGracePeriod=_keepAliveGracePeriod; - (id)_stringForEvent:(int)arg1; - (id)_stringForAction:(int)arg1; - (id)_stringForStyle:(int)arg1; - (void)logAtLevel:(int)arg1 format:(id)arg2 arguments:(struct __va_list_tag [1])arg3; - (void)logAtLevel:(int)arg1 format:(id)arg2; - (void)log:(id)arg1; - (id)_getCachedWWANKeepAliveInterval; - (void)_saveWWANKeepAliveInterval; - (void)_releasePowerAssertion; - (void)_takePowerAssertionWithTimeout:(double)arg1; - (void)_adjustInterfaceAssertions; - (void)interfaceManagerInternetReachabilityChanged:(id)arg1; - (void)interfaceManagerInHomeCountryStatusChanged:(id)arg1; - (void)interfaceManagerWWANInterfaceStatusChanged:(id)arg1; - (void)interfaceLinkQualityChanged:(id)arg1 previousLinkQuality:(int)arg2; - (void)_setTimerGuidance:(double)arg1; - (void)_clearTimersReleasingPowerAssertion:(_Bool)arg1; - (void)_clearTimers; - (void)_calloutWithEvent:(int)arg1; - (void)_callDelegateWithEvent:(id)arg1; - (void)_delayTimerFired; - (void)_intervalTimerFired; - (_Bool)_hasBudgetRemaining; - (void)_setupKeepAliveForReconnect; - (void)_setupTimerForPollForAdjustment:(_Bool)arg1; - (void)_adjustPollTimerIfNecessary; - (void)_setupTimerForPushWithKeepAliveInterval:(double)arg1; @property(nonatomic) _Bool disableEarlyFire; - (void)setEnableNonCellularConnections:(_Bool)arg1; - (_Bool)shouldClientScheduleReconnectDueToFailure; - (void)cancelPollingIntervalOverride; - (void)setPollingIntervalOverride:(double)arg1; @property(readonly, nonatomic) double pollingInterval; - (_Bool)_isPushConnected; @property double maximumKeepAliveInterval; @property(nonatomic) double minimumKeepAliveInterval; @property(readonly, nonatomic) double currentKeepAliveInterval; @property(readonly, nonatomic) unsigned long long countOfGrowthActions; @property(readonly, nonatomic) _Bool isRunning; - (void)stopAndResetManager; - (void)stopManager; - (void)_resolveStateWithAction:(int)arg1; - (void)_validateActionForCurrentStyle:(int)arg1; - (void)resumeManagerWithAction:(int)arg1; - (void)startManager; - (id)_currentGrowthAlgorithm; - (void)setOnlyAllowedStyle:(int)arg1; - (int)currentStyle; - (void)_loadPreferencesGeneratingEvent:(_Bool)arg1; - (void)_preferencesChanged; - (void)dealloc; @property(copy, nonatomic) NSString *duetIdentifier; @property(nonatomic) id <PCConnectionManagerDelegate> delegate; - (id)initWithConnectionClass:(int)arg1 delegate:(id)arg2 serviceIdentifier:(id)arg3; - (id)initWithConnectionClass:(int)arg1 interfaceIdentifier:(long long)arg2 guidancePriority:(unsigned long long)arg3 delegate:(id)arg4 serviceIdentifier:(id)arg5; - (id)initWithConnectionClass:(int)arg1 delegate:(id)arg2 delegateQueue:(id)arg3 serviceIdentifier:(id)arg4; - (id)_initWithConnectionClass:(int)arg1 interfaceIdentifier:(long long)arg2 guidancePriority:(unsigned long long)arg3 delegate:(id)arg4 delegateQueue:(id)arg5 serviceIdentifier:(id)arg6; // Remaining properties @property(readonly, copy) NSString *debugDescription; @property(readonly, copy) NSString *description; @property(readonly) unsigned long long hash; @property(readonly) Class superclass; @end __attribute__((visibility("hidden"))) @interface PCDelegateInfo : NSObject { NSObject<OS_dispatch_queue> *_queue; } - (void)setQueue:(id)arg1; - (id)queue; - (void)dealloc; @end __attribute__((visibility("hidden"))) @interface PCDispatchTimer : NSObject { NSObject<OS_dispatch_source> *_timerSource; NSObject<OS_dispatch_queue> *_queue; unsigned long long _fireTime; NSDate *_fireDate; CUTWeakReference *_target; SEL _selector; _Bool _isValid; } - (void)invalidate; @property(retain, nonatomic) NSDate *fireDate; - (void)start; - (void)_cleanupTimer; @property(readonly, nonatomic) _Bool isValid; - (void)_callTarget; - (void)dealloc; - (id)initWithQueue:(id)arg1 target:(id)arg2 selector:(SEL)arg3 fireTime:(unsigned long long)arg4; @end __attribute__((visibility("hidden"))) @interface PCDistributedLock : NSObject <NSLocking> { NSString *_path; int _fd; } - (void)unlock; - (void)lock; - (_Bool)tryLock; - (_Bool)_lockBlocking:(_Bool)arg1; - (void)dealloc; - (id)initWithName:(id)arg1; - (id)initWithPath:(id)arg1; @end @interface PCInterfaceMonitor : NSObject <PCInterfaceUsabilityMonitorDelegate, PCInterfaceMonitorProtocol> { id <PCInterfaceUsabilityMonitorProtocol> _internal; NSMapTable *_delegateMap; } + (_Bool)isBadLinkQuality:(int)arg1; + (_Bool)isPoorLinkQuality:(int)arg1; + (id)stringForLinkQuality:(int)arg1; + (id)sharedInstanceForIdentifier:(long long)arg1; @property(readonly, nonatomic) _Bool isLTEWithCDRX; @property(readonly, nonatomic) struct __CFString *wwanInterfaceName; @property(readonly, nonatomic) struct __CFString *currentRAT; @property(readonly, nonatomic) _Bool isRadioHot; @property(readonly, nonatomic) _Bool isBadLinkQuality; @property(readonly, nonatomic) _Bool isPoorLinkQuality; @property(readonly, retain, nonatomic) NSString *linkQualityString; @property(readonly, nonatomic) _Bool isInternetReachable; @property(readonly, nonatomic) _Bool isInterfaceHistoricallyUsable; @property(readonly, nonatomic) _Bool isInterfaceUsable; @property(readonly, nonatomic) int linkQuality; @property(readonly, nonatomic) long long interfaceIdentifier; - (void)interfaceRadioHotnessChanged:(id)arg1; - (void)interfaceReachabilityChanged:(id)arg1; - (void)interfaceLinkQualityChanged:(id)arg1 previousLinkQuality:(int)arg2; - (void)removeDelegate:(id)arg1; - (void)addDelegate:(id)arg1 queue:(id)arg2; - (void)dealloc; - (id)initWithInterfaceIdentifier:(long long)arg1; // Remaining properties @property(readonly, copy) NSString *debugDescription; @property(readonly, copy) NSString *description; @property(readonly) unsigned long long hash; @property(readonly) Class superclass; @end __attribute__((visibility("hidden"))) @interface PCInterfaceUsabilityMonitor : NSObject <PCInterfaceUsabilityMonitorProtocol> { NSObject<OS_dispatch_queue> *_delegateQueue; NSObject<OS_dispatch_queue> *_ivarQueue; long long _interfaceIdentifier; NSString *_interfaceName; CUTWeakReference *_delegateReference; void *_reachability; _Bool _isInternetReachable; void *_dynamicStore; struct __CFRunLoopSource *_linkQualitySource; struct __CFString *_lqKey; int _linkQuality; _Bool _trackUsability; unsigned long long _thresholdOffTransitionCount; double _trackedTimeInterval; NSMutableArray *_offTransitions; } + (id)stringForLinkQuality:(int)arg1; + (_Bool)isBadLinkQuality:(int)arg1; + (_Bool)isPoorLinkQuality:(int)arg1; - (void)_createLinkQualityMonitor; - (void)_createLinkQualityMonitorOnIvarQueue; - (void)_dynamicStoreCallback:(id)arg1; - (void)_dynamicStoreCallbackOnIvarQueue:(id)arg1; - (void)_processLinkQualityUpdateOnIvarQueueWithUpdatedLinkQuality:(int)arg1; - (void)_unscheduleLinkQualityMonitorOnIvarQueue; - (void)_reachabilityCallbackOnIvarQueue:(unsigned int)arg1; - (void)_reachabilityCallback:(unsigned int)arg1; - (void)_createReachabilityMonitor; - (void)_createReachabilityMonitorOnIvarQueue; - (void)_unscheduleReachabilityMonitorOnIvarQueue; - (void)_callDelegateOnIvarQueueWithBlock:(CDUnknownBlockType)arg1; @property(nonatomic) id <PCInterfaceUsabilityMonitorDelegate> delegate; @property(readonly, nonatomic) long long interfaceIdentifier; @property(readonly, nonatomic) _Bool isRadioHot; @property(readonly, nonatomic) _Bool isInternetReachable; @property(readonly, nonatomic) int linkQuality; @property(readonly, nonatomic) _Bool isBadLinkQuality; @property(readonly, nonatomic) _Bool isPoorLinkQuality; @property(readonly, retain, nonatomic) NSString *linkQualityString; @property(readonly, nonatomic) _Bool isInterfaceHistoricallyUsable; - (_Bool)_isInterfaceHistoricallyUsableOnIvarQueue; @property(readonly, nonatomic) _Bool isInterfaceUsable; - (_Bool)_isInterfaceUsableOnIvarQueue; - (void)setTrackedTimeInterval:(double)arg1; - (void)setThresholdOffTransitionCount:(unsigned long long)arg1; - (void)setTrackUsability:(_Bool)arg1; - (void)_flushStaleTransitionsOnIvarQueue; - (void)_updateOffTransitionsForLinkQualityChangeOnIvarQueue; - (void)dealloc; - (id)initWithInterfaceName:(id)arg1 interfaceIdentifier:(long long)arg2 delegateQueue:(id)arg3; - (id)init; // Remaining properties @property(readonly, nonatomic) struct __CFString *currentRAT; @property(readonly, copy) NSString *debugDescription; @property(readonly, copy) NSString *description; @property(readonly) unsigned long long hash; @property(readonly, nonatomic) _Bool isLTEWithCDRX; @property(readonly) Class superclass; @property(readonly, nonatomic) struct __CFString *wwanInterfaceName; @end @interface PCLogging : NSObject { } + (void)enableLoggingForCustomHandler:(CDUnknownBlockType)arg1; + (void)enableFileLogging:(_Bool)arg1; + (void)enableConsoleLoggingForLevel:(int)arg1; + (void)_appendString:(id)arg1 toFileNamed:(id)arg2; + (id)logFileDirectory; + (void)logKeepAliveInterval:(double)arg1 forServiceIdentifier:(id)arg2; + (void)logAtLevel:(int)arg1 delegate:(id)arg2 format:(id)arg3 arguments:(struct __va_list_tag [1])arg4; + (CDUnknownBlockType)_formatBlock; + (void)logAtLevel:(int)arg1 delegate:(id)arg2 format:(id)arg3; + (_Bool)loggingEnabledForLevel:(int)arg1; + (id)getMainBundleId; + (void)_configureLogFacilityIfNeeded:(id)arg1; + (id)_facilityForIdentifier:(id)arg1; + (id)_fileNameForIdentifier:(id)arg1; + (void)initialize; @end __attribute__((visibility("hidden"))) @interface PCMultiStageGrowthAlgorithm : NSObject <PCGrowthAlgorithm> { double _currentKeepAliveInterval; double _minimumKeepAliveInterval; double _maximumKeepAliveInterval; double _lastKeepAliveInterval; int _growthStage; double _highWatermark; double _initialGrowthStageHighWatermark; double _initialGrowthStageLastAttempt; NSDate *_leaveSteadyStateDate; NSString *_loggingIdentifier; NSString *_algorithmName; unsigned long long _countOfGrowthActions; } + (void)_loadDefaultValue:(double *)arg1 forKey:(struct __CFString *)arg2; + (void)_loadDefaults; @property(readonly, nonatomic) NSString *loggingIdentifier; // @synthesize loggingIdentifier=_loggingIdentifier; @property(nonatomic) double maximumKeepAliveInterval; // @synthesize maximumKeepAliveInterval=_maximumKeepAliveInterval; @property(nonatomic) double minimumKeepAliveInterval; // @synthesize minimumKeepAliveInterval=_minimumKeepAliveInterval; @property(readonly, nonatomic) double currentKeepAliveInterval; // @synthesize currentKeepAliveInterval=_currentKeepAliveInterval; @property(readonly, nonatomic) unsigned long long countOfGrowthActions; // @synthesize countOfGrowthActions=_countOfGrowthActions; - (id)_stringForStage:(int)arg1; - (id)_stringForAction:(int)arg1; @property(readonly, copy) NSString *description; - (double)_steadyStateTimeout; - (void)_processRefinedGrowthAction:(int)arg1; - (void)_processSteadyStateAction:(int)arg1; - (void)_processBackoffAction:(int)arg1; - (void)_processInitialGrowthAction:(int)arg1; - (void)processNextAction:(int)arg1; - (void)_resetAlgorithmToInterval:(double)arg1; - (void)_resetAlgorithmToInterval:(double)arg1 stage:(int)arg2; @property(readonly, copy, nonatomic) NSDictionary *cacheInfo; - (_Bool)useIntervalIfImprovement:(double)arg1; - (void)_setCurrentKeepAliveInterval:(double)arg1; - (void)dealloc; - (id)initWithCacheInfo:(id)arg1 loggingIdentifier:(id)arg2 algorithmName:(id)arg3; // Remaining properties @property(readonly, copy) NSString *debugDescription; @property(readonly) unsigned long long hash; @property(readonly) Class superclass; @end __attribute__((visibility("hidden"))) @interface PCNonCellularUsabilityMonitor : NSObject <PCInterfaceUsabilityMonitorProtocol, PCInterfaceUsabilityMonitorDelegate> { NSObject<OS_dispatch_queue> *_delegateQueue; NSObject<OS_dispatch_queue> *_ivarQueue; NSObject<OS_dispatch_queue> *_monitorDelegateQueue; CUTWeakReference *_delegateReference; NSString *_demoOverrideInterface; int _previousLinkQuality; _Bool _trackUsability; unsigned long long _thresholdOffTransitionCount; double _trackedTimeInterval; NSMutableArray *_interfaceMonitors; } - (void)interfaceReachabilityChanged:(id)arg1; - (void)interfaceLinkQualityChanged:(id)arg1 previousLinkQuality:(int)arg2; - (void)_callDelegateOnIvarQueueWithBlock:(CDUnknownBlockType)arg1; @property(nonatomic) id <PCInterfaceUsabilityMonitorDelegate> delegate; @property(readonly, nonatomic) _Bool isRadioHot; @property(readonly, nonatomic) _Bool isBadLinkQuality; @property(readonly, nonatomic) _Bool isPoorLinkQuality; @property(readonly, retain, nonatomic) NSString *linkQualityString; @property(readonly, nonatomic) _Bool isInternetReachable; @property(readonly, nonatomic) _Bool isInterfaceHistoricallyUsable; @property(readonly, nonatomic) _Bool isInterfaceUsable; @property(readonly, nonatomic) int linkQuality; - (int)_linkQualityOnIvarQueue; @property(readonly, nonatomic) long long interfaceIdentifier; - (void)setTrackedTimeInterval:(double)arg1; - (void)setThresholdOffTransitionCount:(unsigned long long)arg1; - (void)setTrackUsability:(_Bool)arg1; - (void)_forwardConfigurationOnIvarQueue; - (void)_addMonitorWithInterfaceName:(id)arg1; - (void)dealloc; - (id)initWithDelegateQueue:(id)arg1; // Remaining properties @property(readonly, nonatomic) struct __CFString *currentRAT; @property(readonly, copy) NSString *debugDescription; @property(readonly, copy) NSString *description; @property(readonly) unsigned long long hash; @property(readonly, nonatomic) _Bool isLTEWithCDRX; @property(readonly) Class superclass; @property(readonly, nonatomic) struct __CFString *wwanInterfaceName; @end __attribute__((visibility("hidden"))) @interface PCPersistentIdentifiers : NSObject { } + (int)pidFromMatchingIdentifer:(id)arg1; + (id)processNamePidAndStringIdentifier:(id)arg1; + (id)processNameAndPidIdentifier; + (id)_processNamePrefix; + (unsigned long long)hostUniqueIdentifier; @end @interface PCPersistentInterfaceManager : NSObject <PCInterfaceMonitorDelegate> { NSRecursiveLock *_lock; NSMapTable *_delegatesAndQueues; struct __CFSet *_WiFiAutoAssociationDelegates; PCSimpleTimer *_WiFiAutoAssociationDisableTimer; struct __CFSet *_wakeOnWiFiDelegates; PCSimpleTimer *_wakeOnWiFiDisableTimer; void *_ctServerConnection; void *_interfaceAssertion; int _WWANContextIdentifier; NSString *_WWANInterfaceName; _Bool _isWWANInterfaceUp; NSTimer *_inCallWWANOverrideTimer; _Bool _isWWANInterfaceDataActive; _Bool _ctIsWWANInHomeCountry; _Bool _hasWWANStatusIndicator; _Bool _isPowerStateDetectionSupported; _Bool _isWWANInterfaceInProlongedHighPowerState; _Bool _isWWANInterfaceActivationPermitted; double _lastActivationTime; int _wwanRSSI; _Bool _isInCall; _Bool _isWakeOnWiFiSupported; _Bool _isWakeOnWiFiEnabled; _Bool _shouldOverrideOnCallBehavior; } + (id)sharedInstance; - (id)urlConnectionBoundToWWANInterfaceWithRequest:(id)arg1 delegate:(id)arg2 usesCache:(_Bool)arg3 maxContentLength:(long long)arg4 startImmediately:(_Bool)arg5 connectionProperties:(id)arg6; - (id)urlConnectionBoundToWWANInterface:(_Bool)arg1 withRequest:(id)arg2 delegate:(id)arg3 usesCache:(_Bool)arg4 maxContentLength:(long long)arg5 startImmediately:(_Bool)arg6 connectionProperties:(id)arg7; - (void)bindCFStreamToWWANInterface:(struct __CFReadStream *)arg1; - (void)bindCFStream:(struct __CFReadStream *)arg1 toWWANInterface:(_Bool)arg2; - (_Bool)_allowBindingToWWAN; - (void)_adjustWakeOnWiFiLocked; - (void)_adjustWakeOnWiFi; - (_Bool)_wantsWakeOnWiFiEnabled; - (void)enableWakeOnWiFi:(_Bool)arg1 forDelegate:(id)arg2; - (void)_adjustWiFiAutoAssociationLocked; - (void)_adjustWiFiAutoAssociation; - (void)enableWiFiAutoAssociation:(_Bool)arg1 forDelegate:(id)arg2; - (void)_updateWWANInterfaceAssertionsLocked; - (void)_updateWWANInterfaceAssertions; - (_Bool)_wantsWWANInterfaceAssertion; - (void)cutWiFiManagerDeviceAttached:(id)arg1; @property(readonly) _Bool areAllNetworkInterfacesDisabled; @property(readonly) _Bool isWakeOnWiFiSupported; - (_Bool)_isWiFiUsable; @property(readonly) _Bool isInternetReachableViaWiFi; @property(readonly) _Bool isInternetReachable; - (_Bool)_isInternetReachableLocked; @property(readonly) _Bool isInCall; @property(readonly) _Bool isWWANInHomeCountry; - (_Bool)_isWWANInHomeCountryLocked; @property(readonly) _Bool isWWANInterfaceActivationPermitted; @property(readonly) _Bool isWWANInterfaceInProlongedHighPowerState; @property(readonly) _Bool isPowerStateDetectionSupported; @property(readonly) _Bool doesWWANInterfaceExist; @property(readonly) NSString *WWANInterfaceName; @property(readonly) _Bool isWWANInterfaceUp; @property(readonly) _Bool isWWANBetterThanWiFi; - (void)_scheduleCalloutsForSelector:(SEL)arg1; - (_Bool)_wifiIsPoorLinkQuality; - (_Bool)_wwanIsPoorLinkQuality; @property(readonly, retain, nonatomic) NSString *currentLinkQualityString; - (void)_updateCTIsWWANInHomeCountry:(_Bool)arg1 isWWANInterfaceDataActive:(_Bool)arg2; - (void)_updateWWANInterfaceUpState; - (void)_updateWWANInterfaceUpStateLocked; - (void)_clearInCallWWANOverrideTimerLocked; - (void)_inCallWWANOverrideTimerFired; - (void)handleMachMessage:(void *)arg1; - (void)interfaceReachabilityChanged:(id)arg1; - (void)interfaceLinkQualityChanged:(id)arg1 previousLinkQuality:(int)arg2; - (void)_ctConnectionAttempt; - (void)_mainThreadCTConnectionAttempt; - (void)_createCTConnection; - (void)removeDelegate:(id)arg1; - (void)addDelegate:(id)arg1 queue:(id)arg2; - (void)dealloc; - (id)init; // Remaining properties @property(readonly, copy) NSString *debugDescription; @property(readonly, copy) NSString *description; @property(readonly) unsigned long long hash; @property(readonly) Class superclass; @end @interface PCPersistentTimer : NSObject <PCLoggingDelegate, CUTPowerMonitorDelegate> { double _fireTime; double _startTime; unsigned long long _guidancePriority; double _minimumEarlyFireProportion; _Bool _triggerOnGMTChange; _Bool _disableSystemWaking; NSString *_serviceIdentifier; id _target; SEL _selector; id _userInfo; PCSimpleTimer *_simpleTimer; NSObject<OS_dispatch_queue> *_queue; } + (void)_updateTime:(double)arg1 forGuidancePriority:(unsigned long long)arg2; + (double)_currentGuidanceTime; + (double)currentMachTimeInterval; + (id)lastSystemWakeDate; + (id)_backgroundUpdateQueue; @property(readonly, nonatomic) NSString *loggingIdentifier; // @synthesize loggingIdentifier=_serviceIdentifier; @property(nonatomic) _Bool disableSystemWaking; // @synthesize disableSystemWaking=_disableSystemWaking; @property(nonatomic) double minimumEarlyFireProportion; // @synthesize minimumEarlyFireProportion=_minimumEarlyFireProportion; @property(readonly, copy) NSString *debugDescription; - (double)_nextForcedAlignmentAbsoluteTime; - (void)interfaceManagerInternetReachabilityChanged:(id)arg1; - (void)interfaceManagerWWANInterfaceChangedPowerState:(id)arg1; - (void)interfaceManagerWWANInterfaceStatusChanged:(id)arg1; - (void)cutPowerMonitorBatteryConnectedStateDidChange:(id)arg1; - (void)_fireTimerFired; - (void)_updateTimers; - (double)_earlyFireTime; - (id)userInfo; - (_Bool)firingIsImminent; - (_Bool)isValid; @property(readonly, nonatomic) double fireTime; - (void)invalidate; - (void)scheduleInQueue:(id)arg1; - (void)scheduleInRunLoop:(id)arg1 inMode:(id)arg2; - (void)scheduleInRunLoop:(id)arg1; - (void)dealloc; - (id)_initWithAbsoluteTime:(double)arg1 serviceIdentifier:(id)arg2 guidancePriority:(unsigned long long)arg3 target:(id)arg4 selector:(SEL)arg5 userInfo:(id)arg6 triggerOnGMTChange:(_Bool)arg7; - (id)initWithTimeInterval:(double)arg1 serviceIdentifier:(id)arg2 guidancePriority:(unsigned long long)arg3 target:(id)arg4 selector:(SEL)arg5 userInfo:(id)arg6; - (id)initWithTimeInterval:(double)arg1 serviceIdentifier:(id)arg2 target:(id)arg3 selector:(SEL)arg4 userInfo:(id)arg5; - (id)initWithFireDate:(id)arg1 serviceIdentifier:(id)arg2 target:(id)arg3 selector:(SEL)arg4 userInfo:(id)arg5; // Remaining properties @property(readonly, copy) NSString *description; @property(readonly) unsigned long long hash; @property(readonly) Class superclass; @end __attribute__((visibility("hidden"))) @interface PCScheduleSystemWakeOperation : NSOperation { _Bool _scheduleOrCancel; NSDate *_wakeDate; NSString *_serviceIdentifier; void *_unqiueIdentifier; } - (void)dealloc; - (void)main; - (id)initForScheduledWake:(_Bool)arg1 wakeDate:(id)arg2 serviceIdentifier:(id)arg3 uniqueIdentifier:(void *)arg4; @end @interface PCSimpleTimer : NSObject <PCLoggingDelegate> { double _fireTime; double _startTime; double _lastUpdateTime; _Bool _triggerOnGMTChange; _Bool _disableSystemWaking; NSDate *_scheduledWakeDate; NSString *_serviceIdentifier; id _target; SEL _selector; id _userInfo; PCDispatchTimer *_preventSleepTimer; PCDispatchTimer *_fireTimer; _Bool _sleepIsImminent; unsigned int _powerAssertionID; id _timeChangeSource; NSRunLoop *_timerRunLoop; NSString *_timerMode; int _significantTimeChangeToken; NSObject<OS_dispatch_queue> *_queue; } + (double)currentMachTimeInterval; + (id)lastSystemWakeDate; @property(readonly, nonatomic) NSString *loggingIdentifier; // @synthesize loggingIdentifier=_serviceIdentifier; @property(nonatomic) _Bool disableSystemWaking; // @synthesize disableSystemWaking=_disableSystemWaking; @property(readonly, copy) NSString *debugDescription; - (void)_setSignificantTimeChangeMonitoringEnabled:(_Bool)arg1; - (void)_significantTimeChange; - (void)_powerNotificationSleepIsImminent; - (void)_powerNotificationSleepIsNotImminent; - (void)_setPowerMonitoringEnabled:(_Bool)arg1; - (void)_fireTimerFired; - (void)_preventSleepFired; - (void)_updateTimers; - (void)_performBlockOnQueue:(CDUnknownBlockType)arg1; - (id)_getTimerMode; - (id)_getTimerRunLoop; - (id)userInfo; - (_Bool)firingIsImminent; - (_Bool)isValid; - (void)invalidate; - (void)_scheduleTimer; - (void)scheduleInQueue:(id)arg1; - (void)scheduleInRunLoop:(id)arg1 inMode:(id)arg2; - (void)scheduleInRunLoop:(id)arg1; - (void)updateFireTime:(double)arg1 triggerOnGMTChange:(_Bool)arg2; - (void)dealloc; - (id)initWithAbsoluteTime:(double)arg1 serviceIdentifier:(id)arg2 target:(id)arg3 selector:(SEL)arg4 userInfo:(id)arg5 triggerOnGMTChange:(_Bool)arg6; - (id)initWithTimeInterval:(double)arg1 serviceIdentifier:(id)arg2 target:(id)arg3 selector:(SEL)arg4 userInfo:(id)arg5; - (id)initWithFireDate:(id)arg1 serviceIdentifier:(id)arg2 target:(id)arg3 selector:(SEL)arg4 userInfo:(id)arg5; // Remaining properties @property(readonly, copy) NSString *description; @property(readonly) unsigned long long hash; @property(readonly) Class superclass; @end __attribute__((visibility("hidden"))) @interface PCSystemWakeManager : NSObject { } + (void)scheduleWake:(_Bool)arg1 wakeDate:(id)arg2 serviceIdentifier:(id)arg3 uniqueIdentifier:(void *)arg4; @end __attribute__((visibility("hidden"))) @interface PCWWANUsabilityMonitor : NSObject <PCInterfaceUsabilityMonitorProtocol, PCInterfaceUsabilityMonitorDelegate> { NSObject<OS_dispatch_queue> *_delegateQueue; NSObject<OS_dispatch_queue> *_ivarQueue; NSObject<OS_dispatch_queue> *_monitorDelegateQueue; CUTWeakReference *_delegateReference; _Bool _isInCall; _Bool _isInHighPowerState; _Bool _trackUsability; unsigned long long _thresholdOffTransitionCount; double _trackedTimeInterval; NSString *_interfaceName; PCInterfaceUsabilityMonitor *_interfaceMonitor; struct __CFString *_currentRAT; int _powerlogCDRXToken; int _wwanContextID; NSObject<OS_dispatch_queue> *_ctServerQueue; } - (void)interfaceReachabilityChanged:(id)arg1; - (void)interfaceLinkQualityChanged:(id)arg1 previousLinkQuality:(int)arg2; - (void)_callDelegateOnIvarQueueWithBlock:(CDUnknownBlockType)arg1; @property(nonatomic) id <PCInterfaceUsabilityMonitorDelegate> delegate; @property(readonly, nonatomic) _Bool isRadioHot; @property(readonly, nonatomic) _Bool isBadLinkQuality; @property(readonly, nonatomic) _Bool isPoorLinkQuality; @property(readonly, retain, nonatomic) NSString *linkQualityString; @property(readonly, nonatomic) _Bool isInternetReachable; @property(readonly, nonatomic) _Bool isInterfaceHistoricallyUsable; @property(readonly, nonatomic) _Bool isInterfaceUsable; @property(readonly, nonatomic) int linkQuality; @property(readonly, nonatomic) long long interfaceIdentifier; - (void)setTrackedTimeInterval:(double)arg1; - (void)setThresholdOffTransitionCount:(unsigned long long)arg1; - (void)setTrackUsability:(_Bool)arg1; - (void)_forwardConfigurationOnIvarQueue; @property(readonly, nonatomic) struct __CFString *wwanInterfaceName; @property(readonly, nonatomic) struct __CFString *currentRAT; // @synthesize currentRAT=_currentRAT; @property(readonly, nonatomic) _Bool isLTEWithCDRX; - (void)_adjustInterfaceNameForWWANContextID:(int)arg1; - (void)_setupWWANMonitor; - (void)dealloc; - (id)initWithDelegateQueue:(id)arg1; // Remaining properties @property(readonly, copy) NSString *debugDescription; @property(readonly, copy) NSString *description; @property(readonly) unsigned long long hash; @property(readonly) Class superclass; @end
38.52
206
0.799836
b7f777e8cd2bf4cc9c2f602e6561c33c5d494092
2,654
h
C
include/cnl/_impl/scaled/binary_arithmetic_operator.h
decaf-emu/cnl
540df6f35a01c876567b46aa0a2ea54c06f415d4
[ "BSL-1.0" ]
null
null
null
include/cnl/_impl/scaled/binary_arithmetic_operator.h
decaf-emu/cnl
540df6f35a01c876567b46aa0a2ea54c06f415d4
[ "BSL-1.0" ]
null
null
null
include/cnl/_impl/scaled/binary_arithmetic_operator.h
decaf-emu/cnl
540df6f35a01c876567b46aa0a2ea54c06f415d4
[ "BSL-1.0" ]
null
null
null
// Copyright John McFarlane 2019. // 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) #if !defined(CNL_IMPL_SCALED_BINARY_OPERATOR_H) #define CNL_IMPL_SCALED_BINARY_OPERATOR_H #include "../num_traits/scale.h" #include "../operators/custom_operator.h" #include "../operators/tagged.h" #include "../type_traits/enable_if.h" #include "definition.h" #include <algorithm> /// compositional numeric library namespace cnl { template<_impl::binary_arithmetic_op Operator, typename Lhs, typename Rhs, int Exponent, int Radix> struct custom_operator<Operator, operand<Lhs, power<Exponent, Radix>>, operand<Rhs, power<Exponent, Radix>>> : Operator { }; namespace _impl { template<binary_arithmetic_op Operator> struct is_zero_degree : std::true_type { }; template<> struct is_zero_degree<multiply_op> : std::false_type { }; template<> struct is_zero_degree<divide_op> : std::false_type { }; template<> struct is_zero_degree<modulo_op> : std::false_type { }; } template<_impl::binary_arithmetic_op Operator, typename Lhs, int LhsExponent, int RhsExponent, typename Rhs, int Radix> requires(LhsExponent != RhsExponent && _impl::is_zero_degree<Operator>::value) struct custom_operator< Operator, operand<Lhs, power<LhsExponent, Radix>>, operand<Rhs, power<RhsExponent, Radix>>> { private: static constexpr int _common_exponent = std::min(LhsExponent, RhsExponent); using _common_power = power<_common_exponent, Radix>; static constexpr int _lhs_left_shift = LhsExponent - _common_exponent; static constexpr int _rhs_left_shift = RhsExponent - _common_exponent; public: [[nodiscard]] constexpr auto operator()(Lhs const& lhs, Rhs const& rhs) const { return _impl::binary_arithmetic_operate<Operator, _common_power>( _impl::scale<_lhs_left_shift, Radix>(lhs), _impl::scale<_rhs_left_shift, Radix>(rhs)); } }; template<_impl::binary_arithmetic_op Operator, typename Lhs, int LhsExponent, typename Rhs, int RhsExponent, int Radix> requires(LhsExponent != RhsExponent && !_impl::is_zero_degree<Operator>::value) struct custom_operator< Operator, operand<Lhs, power<LhsExponent, Radix>>, operand<Rhs, power<RhsExponent, Radix>>> : Operator { }; } #endif // CNL_IMPL_SCALED_BINARY_OPERATOR_H
37.914286
123
0.671439
b7f815ccddb302f700e8419442574162c6625cce
295
c
C
Iniciante/linguagem C/Intervalo 2/problema1072.c
Pchenrique/URI-Problems
9041b6f522e998fa1c06285fadcd7f36ad83cf3c
[ "MIT" ]
2
2021-02-10T12:47:57.000Z
2021-02-17T22:46:45.000Z
Iniciante/linguagem C/Intervalo 2/problema1072.c
Pchenrique/URI-Problems
9041b6f522e998fa1c06285fadcd7f36ad83cf3c
[ "MIT" ]
null
null
null
Iniciante/linguagem C/Intervalo 2/problema1072.c
Pchenrique/URI-Problems
9041b6f522e998fa1c06285fadcd7f36ad83cf3c
[ "MIT" ]
null
null
null
#include <stdio.h> int main(){ int n,i,valor,cont=0,fora=0; scanf("%d", &n); for(i=1;i<=n;i++){ scanf("%d", &valor); if((valor >= 10)&&(valor <= 20)){ cont++; }else{ fora++; } } printf("%d in\n", cont); printf("%d out\n", fora); return 0; }
13.409091
36
0.440678
b7f9bafc34cdb5230d3c4ad783632e909d6f4e83
10,325
h
C
include/qasm/lexer.h
donovan68/qpp
c011f9325ef6a67165a3fe93c2e33c5026b7f67c
[ "MIT" ]
1
2020-08-15T14:56:51.000Z
2020-08-15T14:56:51.000Z
include/qasm/lexer.h
donovan68/qpp
c011f9325ef6a67165a3fe93c2e33c5026b7f67c
[ "MIT" ]
null
null
null
include/qasm/lexer.h
donovan68/qpp
c011f9325ef6a67165a3fe93c2e33c5026b7f67c
[ "MIT" ]
1
2019-10-26T19:58:15.000Z
2019-10-26T19:58:15.000Z
/* * This file is part of Quantum++. * * MIT License * * Copyright (c) 2013 - 2019 Vlad Gheorghiu (vgheorgh@gmail.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Adapted from Bruno Schmitt's Tweedledee library */ /** * \file qasm/lexer.h * \brief Lexical analysis for openQASM */ #ifndef QASM_LEXER_H_ #define QASM_LEXER_H_ namespace qpp { namespace qasm { /** * \class qpp::qasm::Lexer * \brief openQASM lexer class */ class Lexer { public: /** * \brief Disables copying */ Lexer(const Lexer&) = delete; /** * \brief Disables assignment */ Lexer& operator=(const Lexer&) = delete; /** * \brief Constructs a lexer * * \param buffer Buffer to lex * \param fname The name of the file associated with buffer (optional) */ Lexer(std::shared_ptr<std::istream> buffer, const std::string& fname = "") : loc_(fname, 1, 1), buf_(buffer) {} /** * \brief Lex and return the next token * * \note Advances the buffer to the position after the consumed token * * \return The token that was lexed */ Token next_token() { return lex(); } private: Location loc_; ///< current location in the source stream std::shared_ptr<std::istream> buf_; ///< stream buffer being lexed /** * \brief Skips the specified number of characters * * \param n The number of characters to skip ahead (optional, default is 1) */ void skip_char(int n = 1) { buf_->ignore(n); loc_.advance_column(n); } /** * \brief Skips over whitespace * * \return True if and only if whitespace was actually consumed */ bool skip_whitespace() { int consumed = 0; while (buf_->peek() == ' ' || buf_->peek() == '\t') { buf_->ignore(); ++consumed; } loc_.advance_column(consumed); if (consumed != 0) return true; else return false; } /** * \brief Skips the rest of the line */ void skip_line_comment() { int consumed = 0; while (buf_->peek() != 0 && buf_->peek() != '\n' && buf_->peek() != '\r') { buf_->ignore(); ++consumed; } loc_.advance_column(consumed); } /** * \brief Lex a numeric constant * * \note [0-9]*(.[0-9]*) * * \param tok_start The location of the beginning of the token * \return An integer or real type token */ Token lex_numeric_constant(Location tok_start) { std::string str; str.reserve(64); // Reserve space to avoid reallocation while (std::isdigit(buf_->peek())) { str.push_back(buf_->peek()); skip_char(); } if (buf_->peek() != '.') { return Token(tok_start, Token::Kind::nninteger, str); } // lex decimal part str.push_back(buf_->peek()); skip_char(); while (std::isdigit(buf_->peek())) { str.push_back(buf_->peek()); skip_char(); } return Token(tok_start, Token::Kind::real, str); } /** * \brief Lex an identifier * * \note [A-Za-z][_A-Za-z0-9]* * * \param tok_start The location of the beginning of the token * \return An identifier type token */ Token lex_identifier(Location tok_start) { std::string str; str.reserve(64); // Reserve space to avoid reallocation while (std::isalpha(buf_->peek()) || std::isdigit(buf_->peek()) || buf_->peek() == '_') { str.push_back(buf_->peek()); skip_char(); } // Check if the identifier is a known keyword auto keyword = keywords.find(str); if (keyword != keywords.end()) { return Token(tok_start, keyword->second, str); } return Token(tok_start, Token::Kind::identifier, str); } /** * \brief Lex a string literal * * \note "[.]*" * * \param tok_start The location of the beginning of the token * \return A string type token */ Token lex_string(Location tok_start) { std::string str; str.reserve(64); // Reserve space to avoid reallocation while (buf_->peek() != '"' && buf_->peek() != '\n' && buf_->peek() != '\r') { str.push_back(buf_->peek()); skip_char(); } if (buf_->peek() != '"') { std::cerr << "Unmatched \", strings must on the same line\n"; return Token(tok_start, Token::Kind::unknown, str); } skip_char(); return Token(tok_start, Token::Kind::string, str); } /** * \brief Lex a token * * \note See arXiv:1707.03429 for the full grammar * * \return The lexed token */ Token lex() { Location tok_start = loc_; skip_whitespace(); switch (buf_->peek()) { case EOF: skip_char(); return Token(tok_start, Token::Kind::eof, ""); case '\r': skip_char(); if (buf_->peek() != '\n') { buf_->ignore(); loc_.advance_line(); return lex(); } // FALLTHROUGH case '\n': buf_->ignore(); loc_.advance_line(); return lex(); case '/': skip_char(); if (buf_->peek() == '/') { skip_line_comment(); return lex(); } return Token(tok_start, Token::Kind::slash, "/"); // clang-format off case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': return lex_numeric_constant(tok_start); // clang-format on case 'C': skip_char(); if (buf_->peek() == 'X') { skip_char(); return Token(tok_start, Token::Kind::kw_cx, "CX"); } loc_.advance_column(); return Token(tok_start, Token::Kind::unknown, std::string({'C', (char) buf_->get()})); case 'U': skip_char(); return Token(tok_start, Token::Kind::kw_u, "U"); // clang-format off case 'O': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': return lex_identifier(tok_start); // clang-format on case '[': skip_char(); return Token(tok_start, Token::Kind::l_square, "["); case ']': skip_char(); return Token(tok_start, Token::Kind::r_square, "]"); case '(': skip_char(); return Token(tok_start, Token::Kind::l_paren, "("); case ')': skip_char(); return Token(tok_start, Token::Kind::r_paren, ")"); case '{': skip_char(); return Token(tok_start, Token::Kind::l_brace, "{"); case '}': skip_char(); return Token(tok_start, Token::Kind::r_brace, "}"); case '*': skip_char(); return Token(tok_start, Token::Kind::star, "*"); case '+': skip_char(); return Token(tok_start, Token::Kind::plus, "+"); case '-': skip_char(); if (buf_->peek() == '>') { skip_char(); return Token(tok_start, Token::Kind::arrow, "->"); } return Token(tok_start, Token::Kind::minus, "-"); case '^': skip_char(); return Token(tok_start, Token::Kind::caret, "^"); case ';': skip_char(); return Token(tok_start, Token::Kind::semicolon, ";"); case '=': skip_char(); if (buf_->peek() == '=') { skip_char(); return Token(tok_start, Token::Kind::equalequal, "=="); } loc_.advance_column(); return Token(tok_start, Token::Kind::unknown, std::string({'=', (char) buf_->get()})); case ',': skip_char(); return Token(tok_start, Token::Kind::comma, ";"); case '"': skip_char(); return lex_string(tok_start); default: loc_.advance_column(); return Token(tok_start, Token::Kind::unknown, std::string({(char) buf_->get()})); } } }; } /* namespace qasm */ } /* namespace qpp */ #endif /* QASM_LEXER_H_ */
28.921569
80
0.500242
b7fac493052bf8d5cec0ec459c1fed059ad9d033
86,797
h
C
generation/WinSDK/RecompiledIdlHeaders/winrt/windows.ui.core.animationmetrics.h
forksnd/win32metadata
3e92612032578896ca3eebd543701c97a95d5214
[ "MIT" ]
984
2021-01-21T17:39:07.000Z
2022-03-30T16:29:34.000Z
generation/WinSDK/RecompiledIdlHeaders/winrt/windows.ui.core.animationmetrics.h
forksnd/win32metadata
3e92612032578896ca3eebd543701c97a95d5214
[ "MIT" ]
684
2021-01-21T20:24:26.000Z
2022-03-31T23:06:50.000Z
generation/WinSDK/RecompiledIdlHeaders/winrt/windows.ui.core.animationmetrics.h
forksnd/win32metadata
3e92612032578896ca3eebd543701c97a95d5214
[ "MIT" ]
65
2021-01-21T18:21:34.000Z
2022-03-24T05:08:12.000Z
#pragma warning( disable: 4049 ) /* more than 64k source lines */ /* verify that the <rpcndr.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCNDR_H_VERSION__ #define __REQUIRED_RPCNDR_H_VERSION__ 500 #endif /* verify that the <rpcsal.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCSAL_H_VERSION__ #define __REQUIRED_RPCSAL_H_VERSION__ 100 #endif #include <rpc.h> #include <rpcndr.h> #ifndef __RPCNDR_H_VERSION__ #error this stub requires an updated version of <rpcndr.h> #endif /* __RPCNDR_H_VERSION__ */ #ifndef COM_NO_WINDOWS_H #include <windows.h> #include <ole2.h> #endif /*COM_NO_WINDOWS_H*/ #ifndef __windows2Eui2Ecore2Eanimationmetrics_h__ #define __windows2Eui2Ecore2Eanimationmetrics_h__ #ifndef __windows2Eui2Ecore2Eanimationmetrics_p_h__ #define __windows2Eui2Ecore2Eanimationmetrics_p_h__ #pragma once // // Deprecated attribute support // #pragma push_macro("DEPRECATED") #undef DEPRECATED #if !defined(DISABLE_WINRT_DEPRECATION) #if defined(__cplusplus) #if __cplusplus >= 201402 #define DEPRECATED(x) [[deprecated(x)]] #define DEPRECATEDENUMERATOR(x) [[deprecated(x)]] #elif defined(_MSC_VER) #if _MSC_VER >= 1900 #define DEPRECATED(x) [[deprecated(x)]] #define DEPRECATEDENUMERATOR(x) [[deprecated(x)]] #else #define DEPRECATED(x) __declspec(deprecated(x)) #define DEPRECATEDENUMERATOR(x) #endif // _MSC_VER >= 1900 #else // Not Standard C++ or MSVC, ignore the construct. #define DEPRECATED(x) #define DEPRECATEDENUMERATOR(x) #endif // C++ deprecation #else // C - disable deprecation #define DEPRECATED(x) #define DEPRECATEDENUMERATOR(x) #endif #else // Deprecation is disabled #define DEPRECATED(x) #define DEPRECATEDENUMERATOR(x) #endif /* DEPRECATED */ // Disable Deprecation for this header, MIDL verifies that cross-type access is acceptable #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" #else #pragma warning(push) #pragma warning(disable: 4996) #endif // Ensure that the setting of the /ns_prefix command line switch is consistent for all headers. // If you get an error from the compiler indicating "warning C4005: 'CHECK_NS_PREFIX_STATE': macro redefinition", this // indicates that you have included two different headers with different settings for the /ns_prefix MIDL command line switch #if !defined(DISABLE_NS_PREFIX_CHECKS) #define CHECK_NS_PREFIX_STATE "always" #endif // !defined(DISABLE_NS_PREFIX_CHECKS) #pragma push_macro("MIDL_CONST_ID") #undef MIDL_CONST_ID #define MIDL_CONST_ID const __declspec(selectany) // API Contract Inclusion Definitions #if !defined(SPECIFIC_API_CONTRACT_DEFINITIONS) #if !defined(WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION) #define WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION 0x40000 #endif // defined(WINDOWS_FOUNDATION_FOUNDATIONCONTRACT_VERSION) #if !defined(WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION) #define WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION 0xe0000 #endif // defined(WINDOWS_FOUNDATION_UNIVERSALAPICONTRACT_VERSION) #if !defined(WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION) #define WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION 0x10000 #endif // defined(WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION) #endif // defined(SPECIFIC_API_CONTRACT_DEFINITIONS) // Header files for imported files #include "inspectable.h" #include "AsyncInfo.h" #include "EventToken.h" #include "windowscontracts.h" #include "Windows.Foundation.h" // Importing Collections header #include <windows.foundation.collections.h> #if defined(__cplusplus) && !defined(CINTERFACE) /* Forward Declarations */ #ifndef ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_FWD_DEFINED__ #define ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_FWD_DEFINED__ namespace ABI { namespace Windows { namespace UI { namespace Core { namespace AnimationMetrics { interface IAnimationDescription; } /* AnimationMetrics */ } /* Core */ } /* UI */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription ABI::Windows::UI::Core::AnimationMetrics::IAnimationDescription #endif // ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory_FWD_DEFINED__ #define ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory_FWD_DEFINED__ namespace ABI { namespace Windows { namespace UI { namespace Core { namespace AnimationMetrics { interface IAnimationDescriptionFactory; } /* AnimationMetrics */ } /* Core */ } /* UI */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory ABI::Windows::UI::Core::AnimationMetrics::IAnimationDescriptionFactory #endif // ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation_FWD_DEFINED__ #define ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation_FWD_DEFINED__ namespace ABI { namespace Windows { namespace UI { namespace Core { namespace AnimationMetrics { interface IOpacityAnimation; } /* AnimationMetrics */ } /* Core */ } /* UI */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation ABI::Windows::UI::Core::AnimationMetrics::IOpacityAnimation #endif // ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_FWD_DEFINED__ #define ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_FWD_DEFINED__ namespace ABI { namespace Windows { namespace UI { namespace Core { namespace AnimationMetrics { interface IPropertyAnimation; } /* AnimationMetrics */ } /* Core */ } /* UI */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation ABI::Windows::UI::Core::AnimationMetrics::IPropertyAnimation #endif // ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_FWD_DEFINED__ #define ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_FWD_DEFINED__ namespace ABI { namespace Windows { namespace UI { namespace Core { namespace AnimationMetrics { interface IScaleAnimation; } /* AnimationMetrics */ } /* Core */ } /* UI */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation ABI::Windows::UI::Core::AnimationMetrics::IScaleAnimation #endif // ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_FWD_DEFINED__ // Parameterized interface forward declarations (C++) // Collection interface definitions #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #ifndef DEF___FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_USE #define DEF___FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { namespace Collections { template <> struct __declspec(uuid("bb6799d3-9f1a-5a4e-a940-945f1ab8c4fe")) IIterator<ABI::Windows::UI::Core::AnimationMetrics::IPropertyAnimation*> : IIterator_impl<ABI::Windows::UI::Core::AnimationMetrics::IPropertyAnimation*> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.Collections.IIterator`1<Windows.UI.Core.AnimationMetrics.IPropertyAnimation>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IIterator<ABI::Windows::UI::Core::AnimationMetrics::IPropertyAnimation*> __FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_t; #define __FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation ABI::Windows::Foundation::Collections::__FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_t /* Collections */ } /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_USE */ #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #ifndef DEF___FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_USE #define DEF___FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { namespace Collections { template <> struct __declspec(uuid("c75f1bd1-a3c1-5881-9da0-1ecdb8e51bc3")) IIterable<ABI::Windows::UI::Core::AnimationMetrics::IPropertyAnimation*> : IIterable_impl<ABI::Windows::UI::Core::AnimationMetrics::IPropertyAnimation*> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.Collections.IIterable`1<Windows.UI.Core.AnimationMetrics.IPropertyAnimation>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IIterable<ABI::Windows::UI::Core::AnimationMetrics::IPropertyAnimation*> __FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_t; #define __FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation ABI::Windows::Foundation::Collections::__FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_t /* Collections */ } /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_USE */ #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #ifndef DEF___FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_USE #define DEF___FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { namespace Collections { template <> struct __declspec(uuid("3a6ed95d-6a50-5ead-a4c6-09f8babc632c")) IVectorView<ABI::Windows::UI::Core::AnimationMetrics::IPropertyAnimation*> : IVectorView_impl<ABI::Windows::UI::Core::AnimationMetrics::IPropertyAnimation*> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.Collections.IVectorView`1<Windows.UI.Core.AnimationMetrics.IPropertyAnimation>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IVectorView<ABI::Windows::UI::Core::AnimationMetrics::IPropertyAnimation*> __FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_t; #define __FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation ABI::Windows::Foundation::Collections::__FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_t /* Collections */ } /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_USE */ #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #ifndef DEF___FIReference_1_float_USE #define DEF___FIReference_1_float_USE #if !defined(RO_NO_TEMPLATE_NAME) namespace ABI { namespace Windows { namespace Foundation { template <> struct __declspec(uuid("719cc2ba-3e76-5def-9f1a-38d85a145ea8")) IReference<float> : IReference_impl<float> { static const wchar_t* z_get_rc_name_impl() { return L"Windows.Foundation.IReference`1<Single>"; } }; // Define a typedef for the parameterized interface specialization's mangled name. // This allows code which uses the mangled name for the parameterized interface to access the // correct parameterized interface specialization. typedef IReference<float> __FIReference_1_float_t; #define __FIReference_1_float ABI::Windows::Foundation::__FIReference_1_float_t /* Foundation */ } /* Windows */ } /* ABI */ } #endif // !defined(RO_NO_TEMPLATE_NAME) #endif /* DEF___FIReference_1_float_USE */ #ifndef ____x_ABI_CWindows_CFoundation_CIPropertyValue_FWD_DEFINED__ #define ____x_ABI_CWindows_CFoundation_CIPropertyValue_FWD_DEFINED__ namespace ABI { namespace Windows { namespace Foundation { interface IPropertyValue; } /* Foundation */ } /* Windows */ } /* ABI */ #define __x_ABI_CWindows_CFoundation_CIPropertyValue ABI::Windows::Foundation::IPropertyValue #endif // ____x_ABI_CWindows_CFoundation_CIPropertyValue_FWD_DEFINED__ namespace ABI { namespace Windows { namespace Foundation { typedef struct Point Point; } /* Foundation */ } /* Windows */ } /* ABI */ namespace ABI { namespace Windows { namespace Foundation { typedef struct TimeSpan TimeSpan; } /* Foundation */ } /* Windows */ } /* ABI */ namespace ABI { namespace Windows { namespace UI { namespace Core { namespace AnimationMetrics { typedef enum AnimationEffect : int AnimationEffect; } /* AnimationMetrics */ } /* Core */ } /* UI */ } /* Windows */ } /* ABI */ namespace ABI { namespace Windows { namespace UI { namespace Core { namespace AnimationMetrics { typedef enum AnimationEffectTarget : int AnimationEffectTarget; } /* AnimationMetrics */ } /* Core */ } /* UI */ } /* Windows */ } /* ABI */ namespace ABI { namespace Windows { namespace UI { namespace Core { namespace AnimationMetrics { typedef enum PropertyAnimationType : int PropertyAnimationType; } /* AnimationMetrics */ } /* Core */ } /* UI */ } /* Windows */ } /* ABI */ namespace ABI { namespace Windows { namespace UI { namespace Core { namespace AnimationMetrics { class AnimationDescription; } /* AnimationMetrics */ } /* Core */ } /* UI */ } /* Windows */ } /* ABI */ /* * * Struct Windows.UI.Core.AnimationMetrics.AnimationEffect * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 namespace ABI { namespace Windows { namespace UI { namespace Core { namespace AnimationMetrics { enum AnimationEffect : int { AnimationEffect_Expand = 0, AnimationEffect_Collapse = 1, AnimationEffect_Reposition = 2, AnimationEffect_FadeIn = 3, AnimationEffect_FadeOut = 4, AnimationEffect_AddToList = 5, AnimationEffect_DeleteFromList = 6, AnimationEffect_AddToGrid = 7, AnimationEffect_DeleteFromGrid = 8, AnimationEffect_AddToSearchGrid = 9, AnimationEffect_DeleteFromSearchGrid = 10, AnimationEffect_AddToSearchList = 11, AnimationEffect_DeleteFromSearchList = 12, AnimationEffect_ShowEdgeUI = 13, AnimationEffect_ShowPanel = 14, AnimationEffect_HideEdgeUI = 15, AnimationEffect_HidePanel = 16, AnimationEffect_ShowPopup = 17, AnimationEffect_HidePopup = 18, AnimationEffect_PointerDown = 19, AnimationEffect_PointerUp = 20, AnimationEffect_DragSourceStart = 21, AnimationEffect_DragSourceEnd = 22, AnimationEffect_TransitionContent = 23, AnimationEffect_Reveal = 24, AnimationEffect_Hide = 25, AnimationEffect_DragBetweenEnter = 26, AnimationEffect_DragBetweenLeave = 27, AnimationEffect_SwipeSelect = 28, AnimationEffect_SwipeDeselect = 29, AnimationEffect_SwipeReveal = 30, AnimationEffect_EnterPage = 31, AnimationEffect_TransitionPage = 32, AnimationEffect_CrossFade = 33, AnimationEffect_Peek = 34, AnimationEffect_UpdateBadge = 35, }; } /* AnimationMetrics */ } /* Core */ } /* UI */ } /* Windows */ } /* ABI */ #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Struct Windows.UI.Core.AnimationMetrics.AnimationEffectTarget * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 namespace ABI { namespace Windows { namespace UI { namespace Core { namespace AnimationMetrics { enum AnimationEffectTarget : int { AnimationEffectTarget_Primary = 0, AnimationEffectTarget_Added = 1, AnimationEffectTarget_Affected = 2, AnimationEffectTarget_Background = 3, AnimationEffectTarget_Content = 4, AnimationEffectTarget_Deleted = 5, AnimationEffectTarget_Deselected = 6, AnimationEffectTarget_DragSource = 7, AnimationEffectTarget_Hidden = 8, AnimationEffectTarget_Incoming = 9, AnimationEffectTarget_Outgoing = 10, AnimationEffectTarget_Outline = 11, AnimationEffectTarget_Remaining = 12, AnimationEffectTarget_Revealed = 13, AnimationEffectTarget_RowIn = 14, AnimationEffectTarget_RowOut = 15, AnimationEffectTarget_Selected = 16, AnimationEffectTarget_Selection = 17, AnimationEffectTarget_Shown = 18, AnimationEffectTarget_Tapped = 19, }; } /* AnimationMetrics */ } /* Core */ } /* UI */ } /* Windows */ } /* ABI */ #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Struct Windows.UI.Core.AnimationMetrics.PropertyAnimationType * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 namespace ABI { namespace Windows { namespace UI { namespace Core { namespace AnimationMetrics { enum PropertyAnimationType : int { PropertyAnimationType_Scale = 0, PropertyAnimationType_Translation = 1, PropertyAnimationType_Opacity = 2, }; } /* AnimationMetrics */ } /* Core */ } /* UI */ } /* Windows */ } /* ABI */ #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Interface Windows.UI.Core.AnimationMetrics.IAnimationDescription * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * * Interface is a part of the implementation of type Windows.UI.Core.AnimationMetrics.AnimationDescription * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_UI_Core_AnimationMetrics_IAnimationDescription[] = L"Windows.UI.Core.AnimationMetrics.IAnimationDescription"; namespace ABI { namespace Windows { namespace UI { namespace Core { namespace AnimationMetrics { MIDL_INTERFACE("7d11a549-be3d-41de-b081-05c149962f9b") IAnimationDescription : public IInspectable { public: virtual HRESULT STDMETHODCALLTYPE get_Animations( __FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation** value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_StaggerDelay( ABI::Windows::Foundation::TimeSpan* value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_StaggerDelayFactor( FLOAT* value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_DelayLimit( ABI::Windows::Foundation::TimeSpan* value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_ZOrder( INT32* value ) = 0; }; extern MIDL_CONST_ID IID& IID_IAnimationDescription = _uuidof(IAnimationDescription); } /* AnimationMetrics */ } /* Core */ } /* UI */ } /* Windows */ } /* ABI */ EXTERN_C const IID IID___x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription; #endif /* !defined(____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_INTERFACE_DEFINED__) */ #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Interface Windows.UI.Core.AnimationMetrics.IAnimationDescriptionFactory * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * * Interface is a part of the implementation of type Windows.UI.Core.AnimationMetrics.AnimationDescription * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_UI_Core_AnimationMetrics_IAnimationDescriptionFactory[] = L"Windows.UI.Core.AnimationMetrics.IAnimationDescriptionFactory"; namespace ABI { namespace Windows { namespace UI { namespace Core { namespace AnimationMetrics { MIDL_INTERFACE("c6e27abe-c1fb-48b5-9271-ecc70ac86ef0") IAnimationDescriptionFactory : public IInspectable { public: virtual HRESULT STDMETHODCALLTYPE CreateInstance( ABI::Windows::UI::Core::AnimationMetrics::AnimationEffect effect, ABI::Windows::UI::Core::AnimationMetrics::AnimationEffectTarget target, ABI::Windows::UI::Core::AnimationMetrics::IAnimationDescription** animation ) = 0; }; extern MIDL_CONST_ID IID& IID_IAnimationDescriptionFactory = _uuidof(IAnimationDescriptionFactory); } /* AnimationMetrics */ } /* Core */ } /* UI */ } /* Windows */ } /* ABI */ EXTERN_C const IID IID___x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory; #endif /* !defined(____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory_INTERFACE_DEFINED__) */ #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Interface Windows.UI.Core.AnimationMetrics.IOpacityAnimation * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * * Interface is a part of the implementation of type Windows.UI.Core.AnimationMetrics.OpacityAnimation * * Any object which implements this interface must also implement the following interfaces: * Windows.UI.Core.AnimationMetrics.IPropertyAnimation * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_UI_Core_AnimationMetrics_IOpacityAnimation[] = L"Windows.UI.Core.AnimationMetrics.IOpacityAnimation"; namespace ABI { namespace Windows { namespace UI { namespace Core { namespace AnimationMetrics { MIDL_INTERFACE("803aabe5-ee7e-455f-84e9-2506afb8d2b4") IOpacityAnimation : public IInspectable { public: virtual HRESULT STDMETHODCALLTYPE get_InitialOpacity( __FIReference_1_float** value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_FinalOpacity( FLOAT* value ) = 0; }; extern MIDL_CONST_ID IID& IID_IOpacityAnimation = _uuidof(IOpacityAnimation); } /* AnimationMetrics */ } /* Core */ } /* UI */ } /* Windows */ } /* ABI */ EXTERN_C const IID IID___x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation; #endif /* !defined(____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation_INTERFACE_DEFINED__) */ #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Interface Windows.UI.Core.AnimationMetrics.IPropertyAnimation * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_UI_Core_AnimationMetrics_IPropertyAnimation[] = L"Windows.UI.Core.AnimationMetrics.IPropertyAnimation"; namespace ABI { namespace Windows { namespace UI { namespace Core { namespace AnimationMetrics { MIDL_INTERFACE("3a01b4da-4d8c-411e-b615-1ade683a9903") IPropertyAnimation : public IInspectable { public: virtual HRESULT STDMETHODCALLTYPE get_Type( ABI::Windows::UI::Core::AnimationMetrics::PropertyAnimationType* value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_Delay( ABI::Windows::Foundation::TimeSpan* value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_Duration( ABI::Windows::Foundation::TimeSpan* value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_Control1( ABI::Windows::Foundation::Point* value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_Control2( ABI::Windows::Foundation::Point* value ) = 0; }; extern MIDL_CONST_ID IID& IID_IPropertyAnimation = _uuidof(IPropertyAnimation); } /* AnimationMetrics */ } /* Core */ } /* UI */ } /* Windows */ } /* ABI */ EXTERN_C const IID IID___x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation; #endif /* !defined(____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_INTERFACE_DEFINED__) */ #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Interface Windows.UI.Core.AnimationMetrics.IScaleAnimation * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * * Interface is a part of the implementation of type Windows.UI.Core.AnimationMetrics.ScaleAnimation * * Any object which implements this interface must also implement the following interfaces: * Windows.UI.Core.AnimationMetrics.IPropertyAnimation * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_UI_Core_AnimationMetrics_IScaleAnimation[] = L"Windows.UI.Core.AnimationMetrics.IScaleAnimation"; namespace ABI { namespace Windows { namespace UI { namespace Core { namespace AnimationMetrics { MIDL_INTERFACE("023552c7-71ab-428c-9c9f-d31780964995") IScaleAnimation : public IInspectable { public: virtual HRESULT STDMETHODCALLTYPE get_InitialScaleX( __FIReference_1_float** value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_InitialScaleY( __FIReference_1_float** value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_FinalScaleX( FLOAT* value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_FinalScaleY( FLOAT* value ) = 0; virtual HRESULT STDMETHODCALLTYPE get_NormalizedOrigin( ABI::Windows::Foundation::Point* value ) = 0; }; extern MIDL_CONST_ID IID& IID_IScaleAnimation = _uuidof(IScaleAnimation); } /* AnimationMetrics */ } /* Core */ } /* UI */ } /* Windows */ } /* ABI */ EXTERN_C const IID IID___x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation; #endif /* !defined(____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_INTERFACE_DEFINED__) */ #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Class Windows.UI.Core.AnimationMetrics.AnimationDescription * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * * RuntimeClass can be activated. * Type can be activated via the Windows.UI.Core.AnimationMetrics.IAnimationDescriptionFactory interface starting with version 1.0 of the Windows.UI.Core.AnimationMetrics.AnimationMetricsContract API contract * * Class implements the following interfaces: * Windows.UI.Core.AnimationMetrics.IAnimationDescription ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_UI_Core_AnimationMetrics_AnimationDescription_DEFINED #define RUNTIMECLASS_Windows_UI_Core_AnimationMetrics_AnimationDescription_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_UI_Core_AnimationMetrics_AnimationDescription[] = L"Windows.UI.Core.AnimationMetrics.AnimationDescription"; #endif #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Class Windows.UI.Core.AnimationMetrics.OpacityAnimation * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * * Class implements the following interfaces: * Windows.UI.Core.AnimationMetrics.IOpacityAnimation ** Default Interface ** * Windows.UI.Core.AnimationMetrics.IPropertyAnimation * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_UI_Core_AnimationMetrics_OpacityAnimation_DEFINED #define RUNTIMECLASS_Windows_UI_Core_AnimationMetrics_OpacityAnimation_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_UI_Core_AnimationMetrics_OpacityAnimation[] = L"Windows.UI.Core.AnimationMetrics.OpacityAnimation"; #endif #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Class Windows.UI.Core.AnimationMetrics.PropertyAnimation * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * * Class implements the following interfaces: * Windows.UI.Core.AnimationMetrics.IPropertyAnimation ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_UI_Core_AnimationMetrics_PropertyAnimation_DEFINED #define RUNTIMECLASS_Windows_UI_Core_AnimationMetrics_PropertyAnimation_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_UI_Core_AnimationMetrics_PropertyAnimation[] = L"Windows.UI.Core.AnimationMetrics.PropertyAnimation"; #endif #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Class Windows.UI.Core.AnimationMetrics.ScaleAnimation * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * * Class implements the following interfaces: * Windows.UI.Core.AnimationMetrics.IScaleAnimation ** Default Interface ** * Windows.UI.Core.AnimationMetrics.IPropertyAnimation * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_UI_Core_AnimationMetrics_ScaleAnimation_DEFINED #define RUNTIMECLASS_Windows_UI_Core_AnimationMetrics_ScaleAnimation_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_UI_Core_AnimationMetrics_ScaleAnimation[] = L"Windows.UI.Core.AnimationMetrics.ScaleAnimation"; #endif #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Class Windows.UI.Core.AnimationMetrics.TranslationAnimation * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * * Class implements the following interfaces: * Windows.UI.Core.AnimationMetrics.IPropertyAnimation ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_UI_Core_AnimationMetrics_TranslationAnimation_DEFINED #define RUNTIMECLASS_Windows_UI_Core_AnimationMetrics_TranslationAnimation_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_UI_Core_AnimationMetrics_TranslationAnimation[] = L"Windows.UI.Core.AnimationMetrics.TranslationAnimation"; #endif #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #else // !defined(__cplusplus) /* Forward Declarations */ #ifndef ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_FWD_DEFINED__ #define ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription; #endif // ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory_FWD_DEFINED__ #define ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory; #endif // ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation_FWD_DEFINED__ #define ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation; #endif // ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_FWD_DEFINED__ #define ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation; #endif // ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_FWD_DEFINED__ #ifndef ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_FWD_DEFINED__ #define ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation; #endif // ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_FWD_DEFINED__ // Parameterized interface forward declarations (C) // Collection interface definitions #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #if !defined(____FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_INTERFACE_DEFINED__) #define ____FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_INTERFACE_DEFINED__ typedef interface __FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation __FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation; typedef struct __FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimationVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This); ULONG (STDMETHODCALLTYPE* Release)(__FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* get_Current)(__FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This, __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation** result); HRESULT (STDMETHODCALLTYPE* get_HasCurrent)(__FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This, boolean* result); HRESULT (STDMETHODCALLTYPE* MoveNext)(__FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This, boolean* result); HRESULT (STDMETHODCALLTYPE* GetMany)(__FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This, UINT32 itemsLength, __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation** items, UINT32* result); END_INTERFACE } __FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimationVtbl; interface __FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation { CONST_VTBL struct __FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimationVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_get_Current(This, result) \ ((This)->lpVtbl->get_Current(This, result)) #define __FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_get_HasCurrent(This, result) \ ((This)->lpVtbl->get_HasCurrent(This, result)) #define __FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_MoveNext(This, result) \ ((This)->lpVtbl->MoveNext(This, result)) #define __FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_GetMany(This, itemsLength, items, result) \ ((This)->lpVtbl->GetMany(This, itemsLength, items, result)) #endif /* COBJMACROS */ #endif // ____FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_INTERFACE_DEFINED__ #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #if !defined(____FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_INTERFACE_DEFINED__) #define ____FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_INTERFACE_DEFINED__ typedef interface __FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation __FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation; typedef struct __FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimationVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This); ULONG (STDMETHODCALLTYPE* Release)(__FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* First)(__FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This, __FIIterator_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation** result); END_INTERFACE } __FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimationVtbl; interface __FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation { CONST_VTBL struct __FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimationVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_First(This, result) \ ((This)->lpVtbl->First(This, result)) #endif /* COBJMACROS */ #endif // ____FIIterable_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_INTERFACE_DEFINED__ #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #if !defined(____FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_INTERFACE_DEFINED__) #define ____FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_INTERFACE_DEFINED__ typedef interface __FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation __FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation; typedef struct __FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimationVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This); ULONG (STDMETHODCALLTYPE* Release)(__FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* GetAt)(__FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This, UINT32 index, __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation** result); HRESULT (STDMETHODCALLTYPE* get_Size)(__FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This, UINT32* result); HRESULT (STDMETHODCALLTYPE* IndexOf)(__FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This, __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation* value, UINT32* index, boolean* result); HRESULT (STDMETHODCALLTYPE* GetMany)(__FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation* This, UINT32 startIndex, UINT32 itemsLength, __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation** items, UINT32* result); END_INTERFACE } __FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimationVtbl; interface __FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation { CONST_VTBL struct __FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimationVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_GetAt(This, index, result) \ ((This)->lpVtbl->GetAt(This, index, result)) #define __FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_get_Size(This, result) \ ((This)->lpVtbl->get_Size(This, result)) #define __FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_IndexOf(This, value, index, result) \ ((This)->lpVtbl->IndexOf(This, value, index, result)) #define __FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_GetMany(This, startIndex, itemsLength, items, result) \ ((This)->lpVtbl->GetMany(This, startIndex, itemsLength, items, result)) #endif /* COBJMACROS */ #endif // ____FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation_INTERFACE_DEFINED__ #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #if !defined(____FIReference_1_float_INTERFACE_DEFINED__) #define ____FIReference_1_float_INTERFACE_DEFINED__ typedef interface __FIReference_1_float __FIReference_1_float; // Declare the parameterized interface IID. EXTERN_C const IID IID___FIReference_1_float; typedef struct __FIReference_1_floatVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__FIReference_1_float* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__FIReference_1_float* This); ULONG (STDMETHODCALLTYPE* Release)(__FIReference_1_float* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__FIReference_1_float* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__FIReference_1_float* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__FIReference_1_float* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* get_Value)(__FIReference_1_float* This, FLOAT* result); END_INTERFACE } __FIReference_1_floatVtbl; interface __FIReference_1_float { CONST_VTBL struct __FIReference_1_floatVtbl* lpVtbl; }; #ifdef COBJMACROS #define __FIReference_1_float_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __FIReference_1_float_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __FIReference_1_float_Release(This) \ ((This)->lpVtbl->Release(This)) #define __FIReference_1_float_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __FIReference_1_float_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __FIReference_1_float_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __FIReference_1_float_get_Value(This, result) \ ((This)->lpVtbl->get_Value(This, result)) #endif /* COBJMACROS */ #endif // ____FIReference_1_float_INTERFACE_DEFINED__ #ifndef ____x_ABI_CWindows_CFoundation_CIPropertyValue_FWD_DEFINED__ #define ____x_ABI_CWindows_CFoundation_CIPropertyValue_FWD_DEFINED__ typedef interface __x_ABI_CWindows_CFoundation_CIPropertyValue __x_ABI_CWindows_CFoundation_CIPropertyValue; #endif // ____x_ABI_CWindows_CFoundation_CIPropertyValue_FWD_DEFINED__ typedef struct __x_ABI_CWindows_CFoundation_CPoint __x_ABI_CWindows_CFoundation_CPoint; typedef struct __x_ABI_CWindows_CFoundation_CTimeSpan __x_ABI_CWindows_CFoundation_CTimeSpan; typedef enum __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CAnimationEffect __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CAnimationEffect; typedef enum __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CAnimationEffectTarget __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CAnimationEffectTarget; typedef enum __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CPropertyAnimationType __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CPropertyAnimationType; /* * * Struct Windows.UI.Core.AnimationMetrics.AnimationEffect * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 enum __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CAnimationEffect { AnimationEffect_Expand = 0, AnimationEffect_Collapse = 1, AnimationEffect_Reposition = 2, AnimationEffect_FadeIn = 3, AnimationEffect_FadeOut = 4, AnimationEffect_AddToList = 5, AnimationEffect_DeleteFromList = 6, AnimationEffect_AddToGrid = 7, AnimationEffect_DeleteFromGrid = 8, AnimationEffect_AddToSearchGrid = 9, AnimationEffect_DeleteFromSearchGrid = 10, AnimationEffect_AddToSearchList = 11, AnimationEffect_DeleteFromSearchList = 12, AnimationEffect_ShowEdgeUI = 13, AnimationEffect_ShowPanel = 14, AnimationEffect_HideEdgeUI = 15, AnimationEffect_HidePanel = 16, AnimationEffect_ShowPopup = 17, AnimationEffect_HidePopup = 18, AnimationEffect_PointerDown = 19, AnimationEffect_PointerUp = 20, AnimationEffect_DragSourceStart = 21, AnimationEffect_DragSourceEnd = 22, AnimationEffect_TransitionContent = 23, AnimationEffect_Reveal = 24, AnimationEffect_Hide = 25, AnimationEffect_DragBetweenEnter = 26, AnimationEffect_DragBetweenLeave = 27, AnimationEffect_SwipeSelect = 28, AnimationEffect_SwipeDeselect = 29, AnimationEffect_SwipeReveal = 30, AnimationEffect_EnterPage = 31, AnimationEffect_TransitionPage = 32, AnimationEffect_CrossFade = 33, AnimationEffect_Peek = 34, AnimationEffect_UpdateBadge = 35, }; #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Struct Windows.UI.Core.AnimationMetrics.AnimationEffectTarget * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 enum __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CAnimationEffectTarget { AnimationEffectTarget_Primary = 0, AnimationEffectTarget_Added = 1, AnimationEffectTarget_Affected = 2, AnimationEffectTarget_Background = 3, AnimationEffectTarget_Content = 4, AnimationEffectTarget_Deleted = 5, AnimationEffectTarget_Deselected = 6, AnimationEffectTarget_DragSource = 7, AnimationEffectTarget_Hidden = 8, AnimationEffectTarget_Incoming = 9, AnimationEffectTarget_Outgoing = 10, AnimationEffectTarget_Outline = 11, AnimationEffectTarget_Remaining = 12, AnimationEffectTarget_Revealed = 13, AnimationEffectTarget_RowIn = 14, AnimationEffectTarget_RowOut = 15, AnimationEffectTarget_Selected = 16, AnimationEffectTarget_Selection = 17, AnimationEffectTarget_Shown = 18, AnimationEffectTarget_Tapped = 19, }; #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Struct Windows.UI.Core.AnimationMetrics.PropertyAnimationType * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 enum __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CPropertyAnimationType { PropertyAnimationType_Scale = 0, PropertyAnimationType_Translation = 1, PropertyAnimationType_Opacity = 2, }; #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Interface Windows.UI.Core.AnimationMetrics.IAnimationDescription * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * * Interface is a part of the implementation of type Windows.UI.Core.AnimationMetrics.AnimationDescription * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_UI_Core_AnimationMetrics_IAnimationDescription[] = L"Windows.UI.Core.AnimationMetrics.IAnimationDescription"; typedef struct __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription* This); ULONG (STDMETHODCALLTYPE* Release)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* get_Animations)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription* This, __FIVectorView_1_Windows__CUI__CCore__CAnimationMetrics__CIPropertyAnimation** value); HRESULT (STDMETHODCALLTYPE* get_StaggerDelay)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription* This, struct __x_ABI_CWindows_CFoundation_CTimeSpan* value); HRESULT (STDMETHODCALLTYPE* get_StaggerDelayFactor)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription* This, FLOAT* value); HRESULT (STDMETHODCALLTYPE* get_DelayLimit)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription* This, struct __x_ABI_CWindows_CFoundation_CTimeSpan* value); HRESULT (STDMETHODCALLTYPE* get_ZOrder)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription* This, INT32* value); END_INTERFACE } __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionVtbl; interface __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription { CONST_VTBL struct __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionVtbl* lpVtbl; }; #ifdef COBJMACROS #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_Release(This) \ ((This)->lpVtbl->Release(This)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_get_Animations(This, value) \ ((This)->lpVtbl->get_Animations(This, value)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_get_StaggerDelay(This, value) \ ((This)->lpVtbl->get_StaggerDelay(This, value)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_get_StaggerDelayFactor(This, value) \ ((This)->lpVtbl->get_StaggerDelayFactor(This, value)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_get_DelayLimit(This, value) \ ((This)->lpVtbl->get_DelayLimit(This, value)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_get_ZOrder(This, value) \ ((This)->lpVtbl->get_ZOrder(This, value)) #endif /* COBJMACROS */ EXTERN_C const IID IID___x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription; #endif /* !defined(____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription_INTERFACE_DEFINED__) */ #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Interface Windows.UI.Core.AnimationMetrics.IAnimationDescriptionFactory * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * * Interface is a part of the implementation of type Windows.UI.Core.AnimationMetrics.AnimationDescription * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_UI_Core_AnimationMetrics_IAnimationDescriptionFactory[] = L"Windows.UI.Core.AnimationMetrics.IAnimationDescriptionFactory"; typedef struct __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactoryVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory* This); ULONG (STDMETHODCALLTYPE* Release)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* CreateInstance)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory* This, enum __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CAnimationEffect effect, enum __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CAnimationEffectTarget target, __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescription** animation); END_INTERFACE } __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactoryVtbl; interface __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory { CONST_VTBL struct __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactoryVtbl* lpVtbl; }; #ifdef COBJMACROS #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory_Release(This) \ ((This)->lpVtbl->Release(This)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory_CreateInstance(This, effect, target, animation) \ ((This)->lpVtbl->CreateInstance(This, effect, target, animation)) #endif /* COBJMACROS */ EXTERN_C const IID IID___x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory; #endif /* !defined(____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIAnimationDescriptionFactory_INTERFACE_DEFINED__) */ #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Interface Windows.UI.Core.AnimationMetrics.IOpacityAnimation * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * * Interface is a part of the implementation of type Windows.UI.Core.AnimationMetrics.OpacityAnimation * * Any object which implements this interface must also implement the following interfaces: * Windows.UI.Core.AnimationMetrics.IPropertyAnimation * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_UI_Core_AnimationMetrics_IOpacityAnimation[] = L"Windows.UI.Core.AnimationMetrics.IOpacityAnimation"; typedef struct __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimationVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation* This); ULONG (STDMETHODCALLTYPE* Release)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* get_InitialOpacity)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation* This, __FIReference_1_float** value); HRESULT (STDMETHODCALLTYPE* get_FinalOpacity)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation* This, FLOAT* value); END_INTERFACE } __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimationVtbl; interface __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation { CONST_VTBL struct __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimationVtbl* lpVtbl; }; #ifdef COBJMACROS #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation_Release(This) \ ((This)->lpVtbl->Release(This)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation_get_InitialOpacity(This, value) \ ((This)->lpVtbl->get_InitialOpacity(This, value)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation_get_FinalOpacity(This, value) \ ((This)->lpVtbl->get_FinalOpacity(This, value)) #endif /* COBJMACROS */ EXTERN_C const IID IID___x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation; #endif /* !defined(____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIOpacityAnimation_INTERFACE_DEFINED__) */ #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Interface Windows.UI.Core.AnimationMetrics.IPropertyAnimation * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_UI_Core_AnimationMetrics_IPropertyAnimation[] = L"Windows.UI.Core.AnimationMetrics.IPropertyAnimation"; typedef struct __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimationVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation* This); ULONG (STDMETHODCALLTYPE* Release)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* get_Type)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation* This, enum __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CPropertyAnimationType* value); HRESULT (STDMETHODCALLTYPE* get_Delay)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation* This, struct __x_ABI_CWindows_CFoundation_CTimeSpan* value); HRESULT (STDMETHODCALLTYPE* get_Duration)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation* This, struct __x_ABI_CWindows_CFoundation_CTimeSpan* value); HRESULT (STDMETHODCALLTYPE* get_Control1)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation* This, struct __x_ABI_CWindows_CFoundation_CPoint* value); HRESULT (STDMETHODCALLTYPE* get_Control2)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation* This, struct __x_ABI_CWindows_CFoundation_CPoint* value); END_INTERFACE } __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimationVtbl; interface __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation { CONST_VTBL struct __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimationVtbl* lpVtbl; }; #ifdef COBJMACROS #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_Release(This) \ ((This)->lpVtbl->Release(This)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_get_Type(This, value) \ ((This)->lpVtbl->get_Type(This, value)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_get_Delay(This, value) \ ((This)->lpVtbl->get_Delay(This, value)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_get_Duration(This, value) \ ((This)->lpVtbl->get_Duration(This, value)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_get_Control1(This, value) \ ((This)->lpVtbl->get_Control1(This, value)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_get_Control2(This, value) \ ((This)->lpVtbl->get_Control2(This, value)) #endif /* COBJMACROS */ EXTERN_C const IID IID___x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation; #endif /* !defined(____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIPropertyAnimation_INTERFACE_DEFINED__) */ #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Interface Windows.UI.Core.AnimationMetrics.IScaleAnimation * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * * Interface is a part of the implementation of type Windows.UI.Core.AnimationMetrics.ScaleAnimation * * Any object which implements this interface must also implement the following interfaces: * Windows.UI.Core.AnimationMetrics.IPropertyAnimation * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #if !defined(____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_INTERFACE_DEFINED__) #define ____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_INTERFACE_DEFINED__ extern const __declspec(selectany) _Null_terminated_ WCHAR InterfaceName_Windows_UI_Core_AnimationMetrics_IScaleAnimation[] = L"Windows.UI.Core.AnimationMetrics.IScaleAnimation"; typedef struct __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimationVtbl { BEGIN_INTERFACE HRESULT (STDMETHODCALLTYPE* QueryInterface)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation* This, REFIID riid, void** ppvObject); ULONG (STDMETHODCALLTYPE* AddRef)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation* This); ULONG (STDMETHODCALLTYPE* Release)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation* This); HRESULT (STDMETHODCALLTYPE* GetIids)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation* This, ULONG* iidCount, IID** iids); HRESULT (STDMETHODCALLTYPE* GetRuntimeClassName)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation* This, HSTRING* className); HRESULT (STDMETHODCALLTYPE* GetTrustLevel)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation* This, TrustLevel* trustLevel); HRESULT (STDMETHODCALLTYPE* get_InitialScaleX)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation* This, __FIReference_1_float** value); HRESULT (STDMETHODCALLTYPE* get_InitialScaleY)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation* This, __FIReference_1_float** value); HRESULT (STDMETHODCALLTYPE* get_FinalScaleX)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation* This, FLOAT* value); HRESULT (STDMETHODCALLTYPE* get_FinalScaleY)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation* This, FLOAT* value); HRESULT (STDMETHODCALLTYPE* get_NormalizedOrigin)(__x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation* This, struct __x_ABI_CWindows_CFoundation_CPoint* value); END_INTERFACE } __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimationVtbl; interface __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation { CONST_VTBL struct __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimationVtbl* lpVtbl; }; #ifdef COBJMACROS #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_QueryInterface(This, riid, ppvObject) \ ((This)->lpVtbl->QueryInterface(This, riid, ppvObject)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_AddRef(This) \ ((This)->lpVtbl->AddRef(This)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_Release(This) \ ((This)->lpVtbl->Release(This)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_GetIids(This, iidCount, iids) \ ((This)->lpVtbl->GetIids(This, iidCount, iids)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_GetRuntimeClassName(This, className) \ ((This)->lpVtbl->GetRuntimeClassName(This, className)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_GetTrustLevel(This, trustLevel) \ ((This)->lpVtbl->GetTrustLevel(This, trustLevel)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_get_InitialScaleX(This, value) \ ((This)->lpVtbl->get_InitialScaleX(This, value)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_get_InitialScaleY(This, value) \ ((This)->lpVtbl->get_InitialScaleY(This, value)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_get_FinalScaleX(This, value) \ ((This)->lpVtbl->get_FinalScaleX(This, value)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_get_FinalScaleY(This, value) \ ((This)->lpVtbl->get_FinalScaleY(This, value)) #define __x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_get_NormalizedOrigin(This, value) \ ((This)->lpVtbl->get_NormalizedOrigin(This, value)) #endif /* COBJMACROS */ EXTERN_C const IID IID___x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation; #endif /* !defined(____x_ABI_CWindows_CUI_CCore_CAnimationMetrics_CIScaleAnimation_INTERFACE_DEFINED__) */ #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Class Windows.UI.Core.AnimationMetrics.AnimationDescription * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * * RuntimeClass can be activated. * Type can be activated via the Windows.UI.Core.AnimationMetrics.IAnimationDescriptionFactory interface starting with version 1.0 of the Windows.UI.Core.AnimationMetrics.AnimationMetricsContract API contract * * Class implements the following interfaces: * Windows.UI.Core.AnimationMetrics.IAnimationDescription ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_UI_Core_AnimationMetrics_AnimationDescription_DEFINED #define RUNTIMECLASS_Windows_UI_Core_AnimationMetrics_AnimationDescription_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_UI_Core_AnimationMetrics_AnimationDescription[] = L"Windows.UI.Core.AnimationMetrics.AnimationDescription"; #endif #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Class Windows.UI.Core.AnimationMetrics.OpacityAnimation * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * * Class implements the following interfaces: * Windows.UI.Core.AnimationMetrics.IOpacityAnimation ** Default Interface ** * Windows.UI.Core.AnimationMetrics.IPropertyAnimation * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_UI_Core_AnimationMetrics_OpacityAnimation_DEFINED #define RUNTIMECLASS_Windows_UI_Core_AnimationMetrics_OpacityAnimation_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_UI_Core_AnimationMetrics_OpacityAnimation[] = L"Windows.UI.Core.AnimationMetrics.OpacityAnimation"; #endif #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Class Windows.UI.Core.AnimationMetrics.PropertyAnimation * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * * Class implements the following interfaces: * Windows.UI.Core.AnimationMetrics.IPropertyAnimation ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_UI_Core_AnimationMetrics_PropertyAnimation_DEFINED #define RUNTIMECLASS_Windows_UI_Core_AnimationMetrics_PropertyAnimation_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_UI_Core_AnimationMetrics_PropertyAnimation[] = L"Windows.UI.Core.AnimationMetrics.PropertyAnimation"; #endif #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Class Windows.UI.Core.AnimationMetrics.ScaleAnimation * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * * Class implements the following interfaces: * Windows.UI.Core.AnimationMetrics.IScaleAnimation ** Default Interface ** * Windows.UI.Core.AnimationMetrics.IPropertyAnimation * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_UI_Core_AnimationMetrics_ScaleAnimation_DEFINED #define RUNTIMECLASS_Windows_UI_Core_AnimationMetrics_ScaleAnimation_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_UI_Core_AnimationMetrics_ScaleAnimation[] = L"Windows.UI.Core.AnimationMetrics.ScaleAnimation"; #endif #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 /* * * Class Windows.UI.Core.AnimationMetrics.TranslationAnimation * * Introduced to Windows.UI.Core.AnimationMetrics.AnimationMetricsContract in version 1.0 * * Class implements the following interfaces: * Windows.UI.Core.AnimationMetrics.IPropertyAnimation ** Default Interface ** * * Class Marshaling Behavior: Agile - Class is agile * */ #if WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #ifndef RUNTIMECLASS_Windows_UI_Core_AnimationMetrics_TranslationAnimation_DEFINED #define RUNTIMECLASS_Windows_UI_Core_AnimationMetrics_TranslationAnimation_DEFINED extern const __declspec(selectany) _Null_terminated_ WCHAR RuntimeClass_Windows_UI_Core_AnimationMetrics_TranslationAnimation[] = L"Windows.UI.Core.AnimationMetrics.TranslationAnimation"; #endif #endif // WINDOWS_UI_CORE_ANIMATIONMETRICS_ANIMATIONMETRICSCONTRACT_VERSION >= 0x10000 #endif // defined(__cplusplus) #pragma pop_macro("MIDL_CONST_ID") // Restore the original value of the 'DEPRECATED' macro #pragma pop_macro("DEPRECATED") #ifdef __clang__ #pragma clang diagnostic pop // deprecated-declarations #else #pragma warning(pop) #endif #endif // __windows2Eui2Ecore2Eanimationmetrics_p_h__ #endif // __windows2Eui2Ecore2Eanimationmetrics_h__
47.66447
210
0.786041
b7fadb1678e93121c17536562e1aed33c9aef086
22,986
c
C
source/cyhal_utils_psoc.c
Infineon/mtb-hal-cat1
708a6b2542f0d8814c129a3141e78fd265826a0b
[ "Apache-2.0" ]
null
null
null
source/cyhal_utils_psoc.c
Infineon/mtb-hal-cat1
708a6b2542f0d8814c129a3141e78fd265826a0b
[ "Apache-2.0" ]
null
null
null
source/cyhal_utils_psoc.c
Infineon/mtb-hal-cat1
708a6b2542f0d8814c129a3141e78fd265826a0b
[ "Apache-2.0" ]
1
2022-01-06T02:01:37.000Z
2022-01-06T02:01:37.000Z
/***************************************************************************//** * \file cyhal_utils_psoc.c * * \brief * Provides utility functions for working with the CAT1/CAT2 HAL implementation. * ******************************************************************************** * \copyright * Copyright 2018-2021 Cypress Semiconductor Corporation (an Infineon company) or * an affiliate of Cypress Semiconductor Corporation * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ #include <stdlib.h> #include <stdarg.h> #include "cyhal_utils.h" #include "cyhal_utils_psoc.h" #include "cyhal_hwmgr.h" #include "cyhal_interconnect.h" #include "cyhal_clock.h" #if defined(__cplusplus) extern "C" { #endif #if !defined(SRSS_NUM_PLL) // TODO: To be fixed for CAT1D #if !defined(COMPONENT_CAT1D) #define SRSS_NUM_PLL (SRSS_NUM_PLL200M + SRSS_NUM_PLL400M) #else #define SRSS_NUM_PLL (0) #endif #endif #if defined(COMPONENT_CAT1B) || defined(COMPONENT_CAT1C) #define _CYHAL_MXSPERI_PCLK_DIV_CNT(gr) \ case CYHAL_CLOCK_BLOCK_PERIPHERAL##gr##_8BIT: return PERI_PERI_PCLK_PCLK_GROUP_NR##gr##_GR_DIV_8_VECT; \ case CYHAL_CLOCK_BLOCK_PERIPHERAL##gr##_16BIT: return PERI_PERI_PCLK_PCLK_GROUP_NR##gr##_GR_DIV_16_VECT; \ case CYHAL_CLOCK_BLOCK_PERIPHERAL##gr##_16_5BIT: return PERI_PERI_PCLK_PCLK_GROUP_NR##gr##_GR_DIV_16_5_VECT; \ case CYHAL_CLOCK_BLOCK_PERIPHERAL##gr##_24_5BIT: return PERI_PERI_PCLK_PCLK_GROUP_NR##gr##_GR_DIV_24_5_VECT; #endif cy_rslt_t _cyhal_utils_reserve_and_connect(const cyhal_resource_pin_mapping_t *mapping, uint8_t drive_mode) { cyhal_resource_inst_t pinRsc = _cyhal_utils_get_gpio_resource(mapping->pin); cy_rslt_t status = cyhal_hwmgr_reserve(&pinRsc); if (CY_RSLT_SUCCESS == status) { status = cyhal_connect_pin(mapping, drive_mode); if (CY_RSLT_SUCCESS != status) { cyhal_hwmgr_free(&pinRsc); } } return status; } void _cyhal_utils_disconnect_and_free(cyhal_gpio_t pin) { cy_rslt_t rslt = cyhal_disconnect_pin(pin); CY_UNUSED_PARAMETER(rslt); /* CY_ASSERT only processes in DEBUG, ignores for others */ CY_ASSERT(CY_RSLT_SUCCESS == rslt); cyhal_resource_inst_t rsc = _cyhal_utils_get_gpio_resource(pin); cyhal_hwmgr_free(&rsc); } cy_en_syspm_callback_mode_t _cyhal_utils_convert_haltopdl_pm_mode(cyhal_syspm_callback_mode_t mode) { switch (mode) { case CYHAL_SYSPM_CHECK_READY: return CY_SYSPM_CHECK_READY; case CYHAL_SYSPM_CHECK_FAIL: return CY_SYSPM_CHECK_FAIL; case CYHAL_SYSPM_BEFORE_TRANSITION: return CY_SYSPM_BEFORE_TRANSITION; case CYHAL_SYSPM_AFTER_TRANSITION: return CY_SYSPM_AFTER_TRANSITION; #if defined(COMPONENT_CAT1B) case CYHAL_SYSPM_AFTER_DS_WFI_TRANSITION: return CY_SYSPM_AFTER_DS_WFI_TRANSITION; #endif default: /* Should not get here */ CY_ASSERT(false); return CY_SYSPM_CHECK_READY; } } cyhal_syspm_callback_mode_t _cyhal_utils_convert_pdltohal_pm_mode(cy_en_syspm_callback_mode_t mode) { switch (mode) { case CY_SYSPM_CHECK_READY: return CYHAL_SYSPM_CHECK_READY; case CY_SYSPM_CHECK_FAIL: return CYHAL_SYSPM_CHECK_FAIL; case CY_SYSPM_BEFORE_TRANSITION: return CYHAL_SYSPM_BEFORE_TRANSITION; case CY_SYSPM_AFTER_TRANSITION: return CYHAL_SYSPM_AFTER_TRANSITION; #if defined(COMPONENT_CAT1B) case CY_SYSPM_AFTER_DS_WFI_TRANSITION: return CYHAL_SYSPM_AFTER_DS_WFI_TRANSITION; #endif default: /* Should not get here */ CY_ASSERT(false); return CYHAL_SYSPM_CHECK_READY; } } int32_t _cyhal_utils_calculate_tolerance(cyhal_clock_tolerance_unit_t type, uint32_t desired_hz, uint32_t actual_hz) { switch (type) { case CYHAL_TOLERANCE_HZ: return (int32_t)(desired_hz - actual_hz); case CYHAL_TOLERANCE_PPM: return (int32_t)(((int64_t)(desired_hz - actual_hz)) * 1000000) / ((int32_t)desired_hz); case CYHAL_TOLERANCE_PERCENT: return (int32_t)((((int64_t)desired_hz - actual_hz) * 100) / desired_hz); default: CY_ASSERT(false); return 0; } } static inline cy_rslt_t _cyhal_utils_allocate_peri(cyhal_clock_t *clock, uint8_t peri_group, cyhal_clock_block_t div, bool accept_larger) { static const cyhal_clock_block_t PERI_DIVIDERS[] = { CYHAL_CLOCK_BLOCK_PERIPHERAL_8BIT, CYHAL_CLOCK_BLOCK_PERIPHERAL_16BIT, CYHAL_CLOCK_BLOCK_PERIPHERAL_16_5BIT, CYHAL_CLOCK_BLOCK_PERIPHERAL_24_5BIT }; cy_rslt_t result = CYHAL_HWMGR_RSLT_ERR_NONE_FREE; bool found_minimum = false; // TODO: CAT1D to be confirmed here #if defined(COMPONENT_CAT1B) || defined(COMPONENT_CAT1C) || defined(COMPONENT_CAT1D) bool dividers_exist = false; #endif for(size_t i = 0; i < sizeof(PERI_DIVIDERS) / sizeof(PERI_DIVIDERS[0]); ++i) { if(PERI_DIVIDERS[i] == div) { found_minimum = true; } if(found_minimum) { #if defined(COMPONENT_CAT1A) CY_UNUSED_PARAMETER(peri_group); result = _cyhal_clock_allocate_peri(clock, PERI_DIVIDERS[i]); // TODO: CAT1D to be confirmed here #elif defined(COMPONENT_CAT1B) || defined(COMPONENT_CAT1C) || defined(COMPONENT_CAT1D) cyhal_clock_block_t adjusted_div = (cyhal_clock_block_t)_CYHAL_PERIPHERAL_GROUP_ADJUST(peri_group, PERI_DIVIDERS[i]); dividers_exist |= (_cyhal_utils_get_clock_count(adjusted_div) > 0); // TODO: Remove this ifdef once clock is available for CAT1D. #if !defined(COMPONENT_CAT1D) result = _cyhal_clock_allocate_peri(clock, adjusted_div); #else CY_UNUSED_PARAMETER(clock); #endif #elif defined(COMPONENT_CAT2) CY_UNUSED_PARAMETER(peri_group); result = cyhal_clock_allocate(clock, PERI_DIVIDERS[i]); #endif if(CY_RSLT_SUCCESS == result || !accept_larger) { break; } } } #if defined(COMPONENT_CAT1B) // If no dividers exist, try to reserve the hfclk that drives the peri group if(CY_RSLT_SUCCESS != result && false == dividers_exist) { uint8_t hfclk_idx = _cyhal_utils_get_hfclk_for_peri_group(peri_group); result = cyhal_clock_reserve(clock, &CYHAL_CLOCK_HF[hfclk_idx]); } #endif return result; } // TODO: CAT1D to be confirmed here #if defined(COMPONENT_CAT1B) || defined(COMPONENT_CAT1C) || defined(COMPONENT_CAT1D) uint8_t _cyhal_utils_get_hfclk_for_peri_group(uint8_t peri_group) { switch (peri_group) { /* Peripheral groups are device specific. */ #if defined(CY_DEVICE_CYW20829) case 0: case 2: return 0; case 1: case 3: case 6: return 1; case 4: return 2; case 5: return 3; #elif defined(CY_DEVICE_TVIIBH8M) || defined(CY_DEVICE_TVIIBH4M) case 0: return 0; case 1: return 2; // TODO: To be fixed #elif defined(CY_DEVICE_EXPLORER) case 0: return 0; #else #warning "Unsupported device" #endif /* defined(CY_DEVICE_CYW20829) */ default: CY_ASSERT(false); /* Use APIs provided by the clock driver */ break; } return 0; } uint8_t _cyhal_utils_get_peri_group(const cyhal_resource_inst_t *clocked_item) { switch (clocked_item->type) { /* Peripheral groups are device specific. */ #if defined(CY_DEVICE_CYW20829) case CYHAL_RSC_CAN: case CYHAL_RSC_LIN: case CYHAL_RSC_SCB: case CYHAL_RSC_TCPWM: return 1; case CYHAL_RSC_CRYPTO: return 2; case CYHAL_RSC_I2S: case CYHAL_RSC_TDM: case CYHAL_RSC_PDM: return 3; case CYHAL_RSC_BLESS: return 4; case CYHAL_RSC_ADCMIC: return 5; case CYHAL_RSC_SMIF: return 6; #elif defined(CY_DEVICE_TVIIBH8M) || defined(CY_DEVICE_TVIIBH4M) #if defined(CY_DEVICE_TVIIBH8M) case CYHAL_RSC_TCPWM: // 4 is the same as _CYHAL_TCPWM_MAX_GRPS_PER_IP_BLOCK if (clocked_item->block_num < 4) { return 0; } return 1; #else case CYHAL_RSC_TCPWM: #endif case CYHAL_RSC_ADC: case CYHAL_RSC_SCB: case CYHAL_RSC_CAN: case CYHAL_RSC_LIN: return 1; // TODO: To be fixed #elif defined(CY_DEVICE_EXPLORER) case CYHAL_RSC_TCPWM: return 0; #else #warning "Unsupported device" #endif default: CY_ASSERT(false); /* Use APIs provided by the clock driver */ break; } return 0; } #endif uint32_t _cyhal_utils_get_clock_count(cyhal_clock_block_t block) { //NOTE: This could potentially reuse the cyhal_hwmgr.c cyhal_block_offsets_clock array switch (block) { #if defined(COMPONENT_CAT1) #if defined(COMPONENT_CAT1A) case CYHAL_CLOCK_BLOCK_PERIPHERAL_8BIT: return PERI_DIV_8_NR; case CYHAL_CLOCK_BLOCK_PERIPHERAL_16BIT: return PERI_DIV_16_NR; case CYHAL_CLOCK_BLOCK_PERIPHERAL_16_5BIT: return PERI_DIV_16_5_NR; case CYHAL_CLOCK_BLOCK_PERIPHERAL_24_5BIT: return PERI_DIV_24_5_NR; case CYHAL_CLOCK_BLOCK_PLL: return SRSS_NUM_PLL; #elif defined(COMPONENT_CAT1B) || defined(COMPONENT_CAT1C) #if (PERI_PERI_PCLK_PCLK_GROUP_NR > 0) _CYHAL_MXSPERI_PCLK_DIV_CNT(0); #endif #if (PERI_PERI_PCLK_PCLK_GROUP_NR > 1) _CYHAL_MXSPERI_PCLK_DIV_CNT(1); #endif #if (PERI_PERI_PCLK_PCLK_GROUP_NR > 2) _CYHAL_MXSPERI_PCLK_DIV_CNT(2); #endif #if (PERI_PERI_PCLK_PCLK_GROUP_NR > 3) _CYHAL_MXSPERI_PCLK_DIV_CNT(3); #endif #if (PERI_PERI_PCLK_PCLK_GROUP_NR > 4) _CYHAL_MXSPERI_PCLK_DIV_CNT(4); #endif #if (PERI_PERI_PCLK_PCLK_GROUP_NR > 5) _CYHAL_MXSPERI_PCLK_DIV_CNT(5); #endif #if (PERI_PERI_PCLK_PCLK_GROUP_NR > 6) _CYHAL_MXSPERI_PCLK_DIV_CNT(6); #endif #if (PERI_PERI_PCLK_PCLK_GROUP_NR > 7) _CYHAL_MXSPERI_PCLK_DIV_CNT(7); #endif #if (PERI_PERI_PCLK_PCLK_GROUP_NR > 8) _CYHAL_MXSPERI_PCLK_DIV_CNT(8); #endif #if (PERI_PERI_PCLK_PCLK_GROUP_NR > 9) _CYHAL_MXSPERI_PCLK_DIV_CNT(9); #endif #if (PERI_PERI_PCLK_PCLK_GROUP_NR > 10) _CYHAL_MXSPERI_PCLK_DIV_CNT(10); #endif #if (PERI_PERI_PCLK_PCLK_GROUP_NR > 11) _CYHAL_MXSPERI_PCLK_DIV_CNT(11); #endif #if (PERI_PERI_PCLK_PCLK_GROUP_NR > 12) _CYHAL_MXSPERI_PCLK_DIV_CNT(12); #endif #if (PERI_PERI_PCLK_PCLK_GROUP_NR > 13) _CYHAL_MXSPERI_PCLK_DIV_CNT(13); #endif #if (PERI_PERI_PCLK_PCLK_GROUP_NR > 14) _CYHAL_MXSPERI_PCLK_DIV_CNT(14); #endif #if (PERI_PERI_PCLK_PCLK_GROUP_NR > 15) _CYHAL_MXSPERI_PCLK_DIV_CNT(15); #endif case CYHAL_CLOCK_BLOCK_PERI: return PERI_PCLK_GROUP_NR; case CYHAL_CLOCK_BLOCK_PLL200: return SRSS_NUM_PLL200M; case CYHAL_CLOCK_BLOCK_PLL400: return SRSS_NUM_PLL400M; #endif /* defined(COMPONENT_CAT1B) */ case CYHAL_CLOCK_BLOCK_PATHMUX: return SRSS_NUM_CLKPATH; case CYHAL_CLOCK_BLOCK_HF: return SRSS_NUM_HFROOT; #elif defined(COMPONENT_CAT2) /* defined(COMPONENT_CAT1) */ case CYHAL_CLOCK_BLOCK_PERIPHERAL_8BIT: return PERI_PCLK_DIV_8_NR; case CYHAL_CLOCK_BLOCK_PERIPHERAL_16BIT: return PERI_PCLK_DIV_16_NR; case CYHAL_CLOCK_BLOCK_PERIPHERAL_16_5BIT: return PERI_PCLK_DIV_16_5_NR; case CYHAL_CLOCK_BLOCK_PERIPHERAL_24_5BIT: return PERI_PCLK_DIV_24_5_NR; #endif /* defined(COMPONENT_CAT2) */ default: return 1; } } #if defined(COMPONENT_CAT1A) cy_rslt_t _cyhal_utils_allocate_clock(cyhal_clock_t *clock, const cyhal_resource_inst_t *clocked_item, cyhal_clock_block_t div, bool accept_larger) { CY_ASSERT(NULL != clocked_item); cyhal_clock_t clock_rsc; switch (clocked_item->type) { /* High frequency clock assignments are device specific. */ #if defined(CY_DEVICE_PSOC6ABLE2) || defined(CY_DEVICE_PSOC6A2M) case CYHAL_RSC_I2S: case CYHAL_RSC_PDM: clock_rsc = CYHAL_CLOCK_HF[1]; break; #endif #if defined(CY_DEVICE_PSOC6ABLE2) || defined(CY_DEVICE_PSOC6A2M) || defined(CY_DEVICE_PSOC6A512K) || defined(CY_DEVICE_PSOC6A256K) case CYHAL_RSC_SMIF: clock_rsc = CYHAL_CLOCK_HF[2]; break; case CYHAL_RSC_USB: clock_rsc = CYHAL_CLOCK_HF[3]; break; #endif #if defined(CY_DEVICE_PSOC6A2M) case CYHAL_RSC_SDHC: clock_rsc = (clocked_item->block_num == 0) ? CYHAL_CLOCK_HF[4] : CYHAL_CLOCK_HF[2]; break; #elif defined(CY_DEVICE_PSOC6A512K) case CYHAL_RSC_SDHC: clock_rsc = CYHAL_CLOCK_HF[4]; break; #endif case CYHAL_RSC_CLOCK: CY_ASSERT(false); /* Use APIs provided by the clock driver */ return CYHAL_CLOCK_RSLT_ERR_NOT_SUPPORTED; default: return _cyhal_utils_allocate_peri(clock, 0, div, accept_larger); } return cyhal_clock_reserve(clock, &clock_rsc); } #elif defined(COMPONENT_CAT1C) cy_rslt_t _cyhal_utils_allocate_clock(cyhal_clock_t *clock, const cyhal_resource_inst_t *clocked_item, cyhal_clock_block_t div, bool accept_larger) { CY_ASSERT(NULL != clocked_item); cyhal_clock_t clock_rsc; uint8_t peri_group; switch (clocked_item->type) { /* High frequency clock assignments are device specific. */ #if defined(CY_DEVICE_TVIIBH8M) || defined(CY_DEVICE_TVIIBH4M) case CYHAL_RSC_I2S: clock_rsc = CYHAL_CLOCK_HF[5]; break; case CYHAL_RSC_SMIF: case CYHAL_RSC_SDHC: clock_rsc = CYHAL_CLOCK_HF[6]; break; #endif case CYHAL_RSC_CLOCK: CY_ASSERT(false); /* Use APIs provided by the clock driver */ return CYHAL_CLOCK_RSLT_ERR_NOT_SUPPORTED; default: peri_group = _cyhal_utils_get_peri_group(clocked_item); return _cyhal_utils_allocate_peri(clock, peri_group, div, accept_larger); } return cyhal_clock_reserve(clock, &clock_rsc); } // TODO: CAT1D to be confirmed here #elif defined(COMPONENT_CAT1B) || defined(COMPONENT_CAT1D) cy_rslt_t _cyhal_utils_allocate_clock(cyhal_clock_t *clock, const cyhal_resource_inst_t *clocked_item, cyhal_clock_block_t div, bool accept_larger) { CY_ASSERT(NULL != clocked_item); uint8_t peri_group = _cyhal_utils_get_peri_group(clocked_item); return _cyhal_utils_allocate_peri(clock, peri_group, div, accept_larger); } #elif defined(COMPONENT_CAT2) cy_rslt_t _cyhal_utils_allocate_clock(cyhal_clock_t *clock, const cyhal_resource_inst_t *clocked_item, cyhal_clock_block_t div, bool accept_larger) { CY_ASSERT(NULL != clocked_item); CY_UNUSED_PARAMETER(clocked_item); return _cyhal_utils_allocate_peri(clock, 0, div, accept_larger); } #endif cy_rslt_t _cyhal_utils_set_clock_frequency(cyhal_clock_t* clock, uint32_t hz, const cyhal_clock_tolerance_t *tolerance) { #if defined(COMPONENT_CAT1A) || defined(COMPONENT_CAT1B) || defined(COMPONENT_CAT1C) if(clock->block == CYHAL_CLOCK_BLOCK_HF) { uint32_t divider; cy_en_clkhf_in_sources_t source = Cy_SysClk_ClkHfGetSource(clock->channel); uint32_t source_hz = Cy_SysClk_ClkPathGetFrequency((uint32_t)source); if (CY_RSLT_SUCCESS == _cyhal_utils_find_hf_clk_div(source_hz, hz, tolerance, false, &divider)) { return cyhal_clock_set_divider(clock, divider); } return CYHAL_CLOCK_RSLT_ERR_FREQ; } else { #endif // Defer to the clock driver return cyhal_clock_set_frequency(clock, hz, tolerance); #if defined(COMPONENT_CAT1A) || defined(COMPONENT_CAT1B) || defined(COMPONENT_CAT1C) } #endif } #if defined(COMPONENT_CAT1A) || defined(COMPONENT_CAT1B) || defined(COMPONENT_CAT1C) || defined(COMPONENT_CAT1D) cy_rslt_t _cyhal_utils_find_hf_clk_div(uint32_t hz_src, uint32_t desired_hz, const cyhal_clock_tolerance_t *tolerance, bool only_below_desired, uint32_t *div) { const uint8_t HFCLK_DIVIDERS[] = { 1, 2, 4, 8}; cy_rslt_t retval = CYHAL_CLOCK_RSLT_ERR_FREQ; uint32_t tolerance_check_value = (NULL != tolerance) ? tolerance->value : 0xFFFFFFFFU; cyhal_clock_tolerance_unit_t tolerance_type = (NULL != tolerance) ? tolerance->type : CYHAL_TOLERANCE_HZ; for(uint8_t i = 0; i < sizeof(HFCLK_DIVIDERS) / sizeof(HFCLK_DIVIDERS[0]); ++i) { const uint32_t divider = HFCLK_DIVIDERS[i]; uint32_t actual_freq = hz_src / divider; if ((actual_freq > desired_hz) && only_below_desired) continue; uint32_t achieved_tolerance = abs(_cyhal_utils_calculate_tolerance(tolerance_type, desired_hz, actual_freq)); if (achieved_tolerance < tolerance_check_value) { *div = divider; retval = CY_RSLT_SUCCESS; if ((NULL != tolerance) || (achieved_tolerance == 0)) break; tolerance_check_value = achieved_tolerance; } else if (only_below_desired) { /* We are going from smallest divider, to highest. If we've not achieved better tolerance in * this iteration, we will no achieve it in futher for sure. */ break; } } return retval; } cy_rslt_t _cyhal_utils_find_hf_source_n_divider(cyhal_clock_t *clock, uint32_t hz, const cyhal_clock_tolerance_t *tolerance, _cyhal_utils_clk_div_func_t div_find_func, cyhal_clock_t *hf_source, uint32_t *div) { CY_ASSERT(NULL != clock); CY_ASSERT(hz != 0); uint32_t count; const cyhal_resource_inst_t ** sources; cy_rslt_t retval = cyhal_clock_get_sources(clock, &sources, &count); if (CY_RSLT_SUCCESS != retval) return retval; uint32_t best_tolerance_hz = 0xFFFFFFFFU; cyhal_clock_t best_clock; uint32_t best_clock_freq = 0; uint32_t best_divider = 1; /* Go through all possible HFCLK clock sources and check what source fits best */ for (uint32_t i = 0; i < count; ++i) { cyhal_clock_t temp_clock; if (CY_RSLT_SUCCESS == cyhal_clock_get(&temp_clock, sources[i])) { uint32_t cur_hf_source_freq = cyhal_clock_get_frequency(&temp_clock); /* source frequency is much lower than desired, no reason to continue */ if ((0 == cur_hf_source_freq) || ((NULL != tolerance) && (_cyhal_utils_calculate_tolerance(tolerance->type, hz, cur_hf_source_freq) > (int32_t)tolerance->value))) { continue; } /* Covering situation when PATHMUX has enabled FLL / PLL on its way. In that case FLL / PLL frequency is observed on PATHMUX which is covered in other iterations of the sources loop */ if (CYHAL_CLOCK_BLOCK_PATHMUX == temp_clock.block) { if (((sources[i]->channel_num == 0) && Cy_SysClk_FllIsEnabled()) #if (SRSS_NUM_PLL > 0) || ((sources[i]->channel_num > 0) && (sources[i]->channel_num <= SRSS_NUM_PLL) && Cy_SysClk_PllIsEnabled(sources[i]->channel_num)) #endif /* SRSS_NUM_PLL > 0 */ #if (SRSS_NUM_PLL400M > 0) || ((sources[i]->channel_num > SRSS_NUM_PLL) && (sources[i]->channel_num <= SRSS_NUM_PLL + SRSS_NUM_PLL400M) && Cy_SysClk_PllIsEnabled(sources[i]->channel_num)) #endif /* SRSS_NUM_PLL400M > 0 */ ) { continue; } } uint32_t cur_clock_divider; if (CY_RSLT_SUCCESS == div_find_func(cur_hf_source_freq, hz, NULL, true, &cur_clock_divider)) { uint32_t cur_divided_freq = cur_hf_source_freq / cur_clock_divider; uint32_t cur_clock_tolerance = abs(_cyhal_utils_calculate_tolerance(CYHAL_TOLERANCE_HZ, hz, cur_divided_freq)); if (cur_clock_tolerance < best_tolerance_hz) { best_clock = temp_clock; best_tolerance_hz = cur_clock_tolerance; best_clock_freq = cur_divided_freq; best_divider = cur_clock_divider; if (cur_divided_freq == hz) break; } } } } if (0 == best_clock_freq) { retval = CYHAL_CLOCK_RSLT_ERR_SOURCE; } else if (NULL != tolerance) /* Verify within tolerance if one was provided. */ { uint32_t achieved_tolerance = abs(_cyhal_utils_calculate_tolerance(tolerance->type, hz, best_clock_freq)); if (achieved_tolerance > tolerance->value) retval = CYHAL_CLOCK_RSLT_ERR_FREQ; } if (CY_RSLT_SUCCESS == retval) { *hf_source = best_clock; *div = best_divider; } return retval; } cy_rslt_t _cyhal_utils_set_clock_frequency2(cyhal_clock_t *clock, uint32_t hz, const cyhal_clock_tolerance_t *tolerance) { CY_ASSERT(NULL != clock); CY_ASSERT(hz != 0); cyhal_clock_t hf_source; uint32_t divider = 0; cy_rslt_t retval = _cyhal_utils_find_hf_source_n_divider(clock, hz, tolerance, _cyhal_utils_find_hf_clk_div, &hf_source, &divider); if (CY_RSLT_SUCCESS == retval) { retval = cyhal_clock_set_source(clock, &hf_source); } if (CY_RSLT_SUCCESS == retval) { retval = cyhal_clock_set_divider(clock, divider); } return retval; } #endif #if defined(__cplusplus) } #endif
35.637209
147
0.656226
b7fae99daac970b150d554202ecfe320713e435c
138,895
c
C
xv.c
thekchang/xv
418e8a1fbc9e0e8fda35dbf8857ba88564fae1a1
[ "Unlicense" ]
9
2016-05-08T09:25:16.000Z
2021-12-24T13:42:08.000Z
xv.c
thekchang/xv
418e8a1fbc9e0e8fda35dbf8857ba88564fae1a1
[ "Unlicense" ]
16
2017-03-27T08:54:11.000Z
2017-05-20T10:16:17.000Z
xv.c
thekchang/xv
418e8a1fbc9e0e8fda35dbf8857ba88564fae1a1
[ "Unlicense" ]
7
2017-07-24T11:50:31.000Z
2021-07-23T04:44:56.000Z
/* * xv.c - main section of xv. X setup, window creation, etc. */ #include "copyright.h" #define MAIN #define NEEDSTIME #define NEEDSDIR /* for value of MAXPATHLEN */ #include "xv.h" #include "bits/icon" #include "bits/iconmask" #include "bits/runicon" #include "bits/runiconm" #include "bits/cboard50" #include "bits/gray25" #include <X11/Xatom.h> #ifdef VMS extern Window pseudo_root(); #endif /* program needs one of the following fonts. Trys them in ascending order */ #define FONT1 "-*-lucida-medium-r-*-*-12-*-*-*-*-*-*-*" #define FONT2 "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*" #define FONT3 "-*-helvetica-medium-r-*-*-11-*-*-*-*-*-*-*" #define FONT4 "6x13" #define FONT5 "fixed" /* a mono-spaced font needed for the 'pixel value tracking' feature */ #define MFONT1 "-misc-fixed-medium-r-normal-*-13-*" #define MFONT2 "6x13" #define MFONT3 "-*-courier-medium-r-*-*-12-*" #define MFONT4 "fixed" /* default positions for various windows */ #define DEFINFOGEOM "-10+10" /* default position of info window */ #define DEFCTRLGEOM "+170+380" /* default position of ctrl window */ #define DEFGAMGEOM "+10-10" /* default position of gamma window */ #define DEFBROWGEOM "-10-10" /* default position of browse window */ #define DEFTEXTGEOM "-10+320" /* default position of text window */ #define DEFCMTGEOM "-10+300" /* default position of comment window */ static int revvideo = 0; /* true if we should reverse video */ static int dfltkludge = 0; /* true if we want dfltpic dithered */ static int clearonload; /* clear window/root (on colormap visuals) */ static int randomShow = 0; /* do a 'random' slideshow */ static int startIconic = 0; /* '-iconic' option */ static int defaultVis = 0; /* true if using DefaultVisual */ #ifdef HAVE_G3 static int lowresfax = 0; /* temporary(?) kludge */ int highresfax = 0; #endif static double hexpand = 1.0; /* '-expand' argument */ static double vexpand = 1.0; /* '-expand' argument */ static const char *maingeom = NULL; static const char *icongeom = NULL; static Atom __SWM_VROOT = None; static char basefname[NAME_MAX + 1]; /* just the current fname, no path */ #ifdef TV_L10N # ifndef TV_FONTSET # define TV_FONTSET "-*-fixed-medium-r-normal--%d-*" # endif # ifndef TV_FONTSIZE # define TV_FONTSIZE 14,16 # endif static int mfontsize[] = { TV_FONTSIZE, 0 }; static char mfontset[256]; #endif #ifdef HAVE_JP2K static byte jp2k_magic[12] = { 0, 0, 0, 0x0c, 'j', 'P', ' ', ' ', 0x0d, 0x0a, 0x87, 0x0a }; #endif /* things to do upon successfully loading an image */ static int autoraw = 0; /* force raw if using stdcmap */ static int autodither = 0; /* dither */ static int autosmooth = 0; /* smooth */ static int auto4x3 = 0; /* do a 4x3 */ static int autorotate = 0; /* rotate 0, +-90, +-180, +-270 */ static int autohflip = 0; /* Flip Horizontally */ static int autovflip = 0; /* Flip Vertically */ static int autocrop = 0; /* do an 'AutoCrop' command */ static int acrop = 0; /* automatically do a 'Crop' */ static int acropX, acropY, acropW, acropH; static int autonorm = 0; /* normalize */ static int autohisteq = 0; /* Histogram equalization */ static int force8 = 0; /* force 8-bit mode */ static int force24 = 0; /* force 24-bit mode */ #ifdef HAVE_PCD static int PcdSize = -1; /* force dialog to ask */ #endif static float waitsec_nonfinal = -1; /* "normal" waitsec value */ static float waitsec_final = -1; /* final-image waitsec value */ /* used in DeleteCmd() and Quit() */ static char **mainargv; static int mainargc; /* local function pre-definitions */ int main PARM((int, char **)); static int highbit PARM((unsigned long)); static void makeDirectCmap PARM((void)); static void useOtherVisual PARM((XVisualInfo *, int)); static void parseResources PARM((int, char **)); static void parseCmdLine PARM((int, char **)); static void verifyArgs PARM((void)); static void printoption PARM((const char *)); static void cmdSyntax PARM((int)); static void rmodeSyntax PARM((void)); static int openPic PARM((int)); static int readpipe PARM((char *, char *)); static void openFirstPic PARM((void)); static void openNextPic PARM((void)); static void openNextQuit PARM((void)); static void openNextLoop PARM((void)); static void openPrevPic PARM((void)); static void openNamedPic PARM((void)); static void mainLoop PARM((void)); static void createMainWindow PARM((const char *, const char *)); static void setWinIconNames PARM((const char *)); static void makeDispNames PARM((void)); static void fixDispNames PARM((void)); static void deleteFromList PARM((int)); static int argcmp PARM((const char *, const char *, int, int, int *)); static void add_filelist_to_namelist PARM((char *, char **, int *, int)); #ifdef HAVE_XRR extern int RRevent_number, RRerror_number; #endif /* formerly local vars in main, made local to this module when parseResources() and parseCmdLine() were split out of main() */ static int imap, ctrlmap, gmap, browmap, cmtmap, clrroot, limit2x; static const char *histr, *lostr, *fgstr, *bgstr, *tmpstr; static const char *infogeom, *ctrlgeom, *gamgeom, *browgeom, *textgeom, *cmtgeom; static char *display, *whitestr, *blackstr; static char *rootfgstr, *rootbgstr, *imagebgstr, *visualstr; static char *monofontname, *flistName; #ifdef TV_L10N static char **misscharset, *defstr; static int nmisscharset; #endif static int curstype, stdinflag, browseMode, savenorm, preview, pscomp, preset, rmodeset, gamset, cgamset, perfect, owncmap, rwcolor, stdcmap; static int nodecor; static double gamval, rgamval, ggamval, bgamval; XtAppContext context; /*******************************************/ int main(argc, argv) int argc; char **argv; /*******************************************/ { int i; #ifdef TV_L10N int j; #endif #ifdef HAVE_XRR int major = -1, minor = -1; int nScreens; #endif XColor ecdef; Window rootReturn, parentReturn, *children; unsigned int numChildren, rootDEEP; int endian_test1 = 1; char *endian_test2 = (char *)&endian_test1; #ifdef AUTO_EXPAND signal(SIGHUP, SIG_IGN); #endif #ifndef NOSIGNAL signal(SIGQUIT, SIG_IGN); #endif #ifdef VMS /* convert VMS-style arguments to unix names and glob */ do_vms_wildcard(&argc, &argv); getredirection(&argc, &argv); #endif /*****************************************************/ /*** variable Initialization ***/ /*****************************************************/ #ifdef TV_L10N /* setlocale(LC_ALL, localeList[LOCALE_EUCJ]); */ setlocale(LC_ALL, ""); xlocale = (int)XSupportsLocale(); /* assume that (Bool) is (int) */ /* if X doesn't support ja_JP.ujis text viewer l10n doesn't work. */ #endif xv_getwd(initdir, sizeof(initdir)); searchdir[0] = '\0'; fullfname[0] = '\0'; mainargv = argv; mainargc = argc; /* init internal variables */ display = NULL; fgstr = bgstr = rootfgstr = rootbgstr = imagebgstr = NULL; histr = lostr = whitestr = blackstr = NULL; visualstr = monofontname = flistName = NULL; winTitle = NULL; pic = egampic = epic = cpic = NULL; theImage = NULL; picComments = (char *) NULL; if (picExifInfo) free(picExifInfo); picExifInfo = (byte *) NULL; picExifInfoSize = 0; numPages = 1; curPage = 0; pageBaseName[0] = '\0'; LocalCmap = browCmap = 0; stdinflag = 0; autoclose = autoDelete = 0; cmapInGam = 0; grabDelay = 0; startGrab = 0; showzoomcursor = 0; perfect = owncmap = stdcmap = rwcolor = 0; ignoreConfigs = 0; browPerfect = 1; gamval = rgamval = ggamval = bgamval = 1.0; picType = -1; /* gets set once file is loaded */ colorMapMode = CM_NORMAL; haveStdCmap = STD_NONE; allocMode = AM_READONLY; novbrowse = 0; #ifndef VMS strcpy(printCmd, "lpr"); #else strcpy(printCmd, "Print /Queue = XV_Queue"); #endif forceClipFile = 0; clearR = clearG = clearB = 0; InitSelection(); if (endian_test2[0] == 1) bigendian = 0; else bigendian = 1; /* default Ghostscript parameters */ gsDev = "ppmraw"; #ifdef GS_DEV gsDev = GS_DEV; #endif gsRes = 72; gsGeomStr = NULL; /* init default colors */ fgstr = "#000000"; bgstr = "#B2C0DC"; histr = "#C6D5E2"; lostr = "#8B99B5"; cmd = (char *) rindex(argv[0],'/'); if (!cmd) cmd = argv[0]; else cmd++; tmpstr = (const char *) getenv("TMPDIR"); if (!tmpstr) tmpstr = "/tmp"; tmpdir = (char *) malloc(strlen(tmpstr) + 1); if (!tmpdir) FatalError("can't malloc 'tmpdir'\n"); strcpy(tmpdir, tmpstr); /* init command-line options flags */ infogeom = DEFINFOGEOM; ctrlgeom = DEFCTRLGEOM; gamgeom = DEFGAMGEOM; browgeom = DEFBROWGEOM; textgeom = DEFTEXTGEOM; cmtgeom = DEFCMTGEOM; ncols = -1; mono = 0; ninstall = 0; fixedaspect = 0; noFreeCols = nodecor = 0; DEBUG = 0; bwidth = 2; nolimits = useroot = clrroot = noqcheck = 0; waitsec = waitsec_final = -1.0; waitloop = 0; automax = 0; rootMode = 0; hsvmode = 0; rmodeset = gamset = cgamset = 0; nopos = limit2x = 0; resetroot = 1; clearonload = 0; curstype = XC_top_left_arrow; browseMode = savenorm = nostat = 0; preview = 0; pscomp = 0; preset = 0; viewonly = 0; #ifdef ENABLE_FIXPIX_SMOOTH do_fixpix_smooth = 0; #endif /* init 'xormasks' array */ xorMasks[0] = 0x01010101; xorMasks[1] = 0x02020203; xorMasks[2] = 0x84848485; xorMasks[3] = 0x88888889; xorMasks[4] = 0x10101011; xorMasks[5] = 0x20202023; xorMasks[6] = 0xc4c4c4c5; xorMasks[7] = 0xffffffff; kludge_offx = kludge_offy = winCtrPosKludge = 0; conv24 = CONV24_SLOW; /* use 'slow' algorithm by default */ defaspect = normaspect = 1.0; mainW = dirW = infoW = ctrlW = gamW = psW = (Window) None; anyBrowUp = 0; incrementalSearchTimeout = 30; forcegeom = TRUE; #ifdef HAVE_JPEG jpegW = (Window) None; jpegUp = 0; #endif #ifdef HAVE_JP2K jp2kW = (Window) None; jp2kUp = 0; #endif #ifdef HAVE_TIFF tiffW = (Window) None; tiffUp = 0; #endif #ifdef HAVE_PNG pngW = (Window) None; pngUp = 0; #endif #ifdef HAVE_WEBP webpW = (Window) None; webpUp = 0; #endif pcdW = (Window) None; pcdUp = 0; #ifdef HAVE_PIC2 pic2W = (Window) None; pic2Up = 0; #endif #ifdef HAVE_PCD pcdW = (Window) None; pcdUp = 0; #endif #ifdef HAVE_MGCSFX mgcsfxW = (Window) None; mgcsfxUp = 0; #endif imap = ctrlmap = gmap = browmap = cmtmap = 0; ch_offx = ch_offy = p_offx = p_offy = 0; /* init info box variables */ infoUp = 0; infoMode = INF_STR; for (i=0; i<NISTR; i++) SetISTR(i,""); /* init ctrl box variables */ ctrlUp = 0; curname = -1; formatStr[0] ='\0'; gamUp = 0; psUp = 0; Init24to8(); /* handle user-specified resources and cmd-line arguments */ parseResources(argc,argv); parseCmdLine(argc, argv); verifyArgs(); #ifdef AUTO_EXPAND Vdinit(); vd_handler_setup(); #endif #if 0 #ifdef XVEXECPATH /* set up path to search for external executables */ { char *systempath = getenv("PATH"); char *xvexecpath = getenv("XVPATH"); if (xvexecpath == NULL) xvexecpath = XVEXECPATH; /* FIXME: can systempath == NULL? */ strcat(systempath, ":"); /* FIXME: writing to mem we don't own */ strcat(systempath, xvexecpath); /* FIXME: writing to mem we don't own */ /* FIXME: was there supposed to be a setenv() call in here? */ if (DEBUG) fprintf(stderr, "DEBUG: executable search path: %s\n", systempath); } #endif #endif /*****************************************************/ /*** X Setup ***/ /*****************************************************/ theScreen = DefaultScreen(theDisp); theCmap = DefaultColormap(theDisp, theScreen); if (spec_window) { rootW = spec_window; } else { rootW = RootWindow(theDisp,theScreen); } theGC = DefaultGC(theDisp,theScreen); theVisual = DefaultVisual(theDisp,theScreen); ncells = DisplayCells(theDisp, theScreen); dispDEEP = DisplayPlanes(theDisp,theScreen); maxWIDE = vrWIDE = dispWIDE = DisplayWidth(theDisp,theScreen); maxHIGH = vrHIGH = dispHIGH = DisplayHeight(theDisp,theScreen); rootDEEP = dispDEEP; /* things dependent on theVisual: * dispDEEP, theScreen, rootW, ncells, theCmap, theGC, * vrWIDE, dispWIDE, vrHIGH, dispHIGH, maxWIDE, maxHIGH */ /* if we *haven't* had a non-default visual specified, see if we have a TrueColor or DirectColor visual of 24 or 32 bits, and if so, use that as the default visual (prefer TrueColor) */ if (!visualstr && !useroot) { VisualID defvid; XVisualInfo *vinfo, rvinfo; int best, numvis; long flags; best = -1; rvinfo.class = TrueColor; rvinfo.screen = theScreen; flags = VisualClassMask | VisualScreenMask; defvid = XVisualIDFromVisual(DefaultVisual(theDisp, DefaultScreen(theDisp))); vinfo = XGetVisualInfo(theDisp, flags, &rvinfo, &numvis); if (vinfo) { /* Check list, use 'default', first 24-bit, or first >24-bit */ for (i=0; i<numvis && best==-1; i++) { /* default? */ if ((vinfo[i].visualid == defvid) && (vinfo[i].depth >= 24)) best=i; } for (i=0; i<numvis && best==-1; i++) { /* 24-bit ? */ if (vinfo[i].depth == 24) best = i; } for (i=0; i<numvis && best==-1; i++) { /* >24-bit ? */ if (vinfo[i].depth >= 24) best = i; } } if (best == -1) { /* look for a DirectColor, 24-bit or more (pref 24) */ rvinfo.class = DirectColor; if (vinfo) XFree((char *) vinfo); vinfo = XGetVisualInfo(theDisp, flags, &rvinfo, &numvis); if (vinfo) { for (i=0; i<numvis && best==-1; i++) { /* default? */ if ((vinfo[i].visualid == defvid) && (vinfo[i].depth >= 24)) best=i; } for (i=0; i<numvis && best==-1; i++) { /* 24-bit ? */ if (vinfo[i].depth == 24) best = i; } for (i=0; i<numvis && best==-1; i++) { /* >24-bit ? */ if (vinfo[i].depth >= 24) best = i; } } } if (best>=0 && best<numvis) useOtherVisual(vinfo, best); if (vinfo) XFree((char *) vinfo); } if (visualstr && useroot) { fprintf(stderr, "%s: %sUsing default visual.\n", cmd, "Warning: Can't use specified visual on root. "); visualstr = NULL; } if (visualstr && !useroot) { /* handle non-default visual */ int vclass = -1; int vid = -1; lower_str(visualstr); if (!strcmp(visualstr,"staticgray")) vclass = StaticGray; else if (!strcmp(visualstr,"staticcolor")) vclass = StaticColor; else if (!strcmp(visualstr,"truecolor")) vclass = TrueColor; else if (!strcmp(visualstr,"grayscale")) vclass = GrayScale; else if (!strcmp(visualstr,"pseudocolor")) vclass = PseudoColor; else if (!strcmp(visualstr,"directcolor")) vclass = DirectColor; else if (!strcmp(visualstr,"default")) {} /* recognize it as valid */ else if (!strncmp(visualstr,"0x",(size_t) 2)) { /* specified visual id */ if (sscanf(visualstr, "0x%x", &vid) != 1) vid = -1; } else { fprintf(stderr,"%s: Unrecognized visual type '%s'. %s\n", cmd, visualstr, "Using server default."); } /* if 'default', vclass and vid will both be '-1' */ if (vclass >= 0 || vid >= 0) { /* try to find asked-for visual type */ XVisualInfo *vinfo, rvinfo; long vinfomask; int numvis, best; if (vclass >= 0) { rvinfo.class = vclass; vinfomask = VisualClassMask; } else { rvinfo.visualid = vid; vinfomask = VisualIDMask; } rvinfo.screen = theScreen; vinfomask |= VisualScreenMask; vinfo = XGetVisualInfo(theDisp, vinfomask, &rvinfo, &numvis); if (vinfo) { /* choose the 'best' one, if multiple */ for (i=0, best = 0; i<numvis; i++) { if (vinfo[i].depth > vinfo[best].depth) best = i; } useOtherVisual(vinfo, best); XFree((char *) vinfo); } else fprintf(stderr,"%s: Visual type '%s' not available. %s\n", cmd, visualstr, "Using server default."); } } /* make linear colormap for DirectColor visual */ if (theVisual->class == DirectColor) makeDirectCmap(); defaultVis = (XVisualIDFromVisual(theVisual) == XVisualIDFromVisual(DefaultVisual(theDisp, DefaultScreen(theDisp)))); /* turn GraphicsExposures OFF in the default GC */ { XGCValues xgcv; xgcv.graphics_exposures = False; XChangeGC(theDisp, theGC, GCGraphicsExposures, &xgcv); } XSetErrorHandler(xvErrorHandler); /* always search for virtual root window */ vrootW = rootW; #ifndef VMS __SWM_VROOT = XInternAtom(theDisp, "__SWM_VROOT", False); XQueryTree(theDisp, rootW, &rootReturn, &parentReturn, &children, &numChildren); for (i = 0; i < numChildren; i++) { Atom actual_type; int actual_format; unsigned long nitems, bytesafter; byte *newRoot = NULL; /* byte instead of Window avoids type-pun warning */ XWindowAttributes xwa; if (XGetWindowProperty (theDisp, children[i], __SWM_VROOT, 0L, 1L, False, XA_WINDOW, &actual_type, &actual_format, &nitems, &bytesafter, (unsigned char **) &newRoot) == Success && newRoot) { vrootW = *(Window *)newRoot; /* FIXME: alignment and type aliasing violation (use memcpy()) */ XGetWindowAttributes(theDisp, vrootW, &xwa); maxWIDE = vrWIDE = xwa.width; maxHIGH = vrHIGH = xwa.height; dispDEEP = xwa.depth; break; } } #else /* VMS */ vrootW = pseudo_root(theDisp, theScreen); #endif if (!useroot && limit2x) { maxWIDE *= 2; maxHIGH *= 2; } if (nolimits) { maxWIDE = 65000; maxHIGH = 65000; } if (clrroot || useroot) { /* have enough info to do a '-clear' now */ KillOldRootInfo(); /* if any */ if (resetroot || clrroot) ClearRoot(); /* don't clear on '-noresetroot' */ if (clrroot) Quit(0); } arrow = XCreateFontCursor(theDisp,(u_int) curstype); cross = XCreateFontCursor(theDisp,XC_crosshair); tcross = XCreateFontCursor(theDisp,XC_tcross); tlcorner = XCreateFontCursor(theDisp,XC_top_left_corner); zoom = XCreateFontCursor(theDisp,XC_sizing); { XColor fc, bc; fc.red = fc.green = fc.blue = 0xffff; bc.red = bc.green = bc.blue = 0x0000; XRecolorCursor(theDisp, zoom, &fc, &bc); } { /* create inviso cursor */ Pixmap pix; static char bits[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; XColor cfg; cfg.red = cfg.green = cfg.blue = 0; pix = XCreateBitmapFromData(theDisp, rootW, bits, 8, 8); inviso = XCreatePixmapCursor(theDisp, pix, pix, &cfg, &cfg, 0,0); XFreePixmap(theDisp, pix); } /* set up white,black colors */ whtRGB = 0xffffff; blkRGB = 0x000000; if (defaultVis) { white = WhitePixel(theDisp,theScreen); black = BlackPixel(theDisp,theScreen); } else { ecdef.flags = DoRed | DoGreen | DoBlue; ecdef.red = ecdef.green = ecdef.blue = 0xffff; if (xvAllocColor(theDisp, theCmap, &ecdef)) white = ecdef.pixel; else white = 0xffffffff; /* probably evil... */ ecdef.red = ecdef.green = ecdef.blue = 0x0000; if (xvAllocColor(theDisp, theCmap, &ecdef)) black = ecdef.pixel; else black = 0x00000000; /* probably evil... */ } if (whitestr && XParseColor(theDisp, theCmap, whitestr, &ecdef) && xvAllocColor(theDisp, theCmap, &ecdef)) { white = ecdef.pixel; whtRGB = ((ecdef.red>>8)<<16) | (ecdef.green&0xff00) | (ecdef.blue>>8); } if (blackstr && XParseColor(theDisp, theCmap, blackstr, &ecdef) && xvAllocColor(theDisp, theCmap, &ecdef)) { black = ecdef.pixel; blkRGB = ((ecdef.red>>8)<<16) | (ecdef.green&0xff00) | (ecdef.blue>>8); } /* set up fg,bg colors */ fg = black; bg = white; if (fgstr && XParseColor(theDisp, theCmap, fgstr, &ecdef) && xvAllocColor(theDisp, theCmap, &ecdef)) { fg = ecdef.pixel; } if (bgstr && XParseColor(theDisp, theCmap, bgstr, &ecdef) && xvAllocColor(theDisp, theCmap, &ecdef)) { bg = ecdef.pixel; } /* set up root fg,bg colors */ rootfg = white; rootbg = black; if (rootfgstr && XParseColor(theDisp, theCmap, rootfgstr, &ecdef) && xvAllocColor(theDisp, theCmap, &ecdef)) rootfg = ecdef.pixel; if (rootbgstr && XParseColor(theDisp, theCmap, rootbgstr, &ecdef) && xvAllocColor(theDisp, theCmap, &ecdef)) rootbg = ecdef.pixel; /* GRR 19980308: set up image bg color (for transparent images) */ have_imagebg = 0; if (imagebgstr && XParseColor(theDisp, theCmap, imagebgstr, &ecdef) && xvAllocColor(theDisp, theCmap, &ecdef)) { /* imagebg = ecdef.pixel; */ have_imagebg = 1; imagebgR = ecdef.red; imagebgG = ecdef.green; imagebgB = ecdef.blue; } /* set up hi/lo colors */ i=0; if (dispDEEP > 1) { /* only if we're on a reasonable display */ if (histr && XParseColor(theDisp, theCmap, histr, &ecdef) && xvAllocColor(theDisp, theCmap, &ecdef)) { hicol = ecdef.pixel; i|=1; } if (lostr && XParseColor(theDisp, theCmap, lostr, &ecdef) && xvAllocColor(theDisp, theCmap, &ecdef)) { locol = ecdef.pixel; i|=2; } } if (i==0) ctrlColor = 0; else if (i==3) ctrlColor = 1; else { /* only got some of them */ if (i&1) xvFreeColors(theDisp, theCmap, &hicol, 1, 0L); if (i&2) xvFreeColors(theDisp, theCmap, &locol, 1, 0L); ctrlColor = 0; } if (!ctrlColor) { hicol = bg; locol = fg; } XSetForeground(theDisp,theGC,fg); XSetBackground(theDisp,theGC,bg); infofg = fg; infobg = bg; /* if '-mono' not forced, determine if we're on a grey or color monitor */ if (!mono) { if (theVisual->class == StaticGray || theVisual->class == GrayScale) mono = 1; } iconPix = MakePix1(rootW, icon_bits, icon_width, icon_height); iconmask = MakePix1(rootW, iconmask_bits, icon_width, icon_height); riconPix = MakePix1(rootW, runicon_bits, runicon_width, runicon_height); riconmask= MakePix1(rootW, runiconm_bits, runiconm_width,runiconm_height); if (!iconPix || !iconmask || !riconPix || !riconmask) FatalError("Unable to create icon pixmaps\n"); gray50Tile = XCreatePixmapFromBitmapData(theDisp, rootW, (char *) cboard50_bits, cboard50_width, cboard50_height, infofg, infobg, dispDEEP); if (!gray50Tile) FatalError("Unable to create gray50Tile bitmap\n"); gray25Tile = XCreatePixmapFromBitmapData(theDisp, rootW, (char *) gray25_bits, gray25_width, gray25_height, infofg, infobg, dispDEEP); if (!gray25Tile) FatalError("Unable to create gray25Tile bitmap\n"); /* try to load fonts */ if ( (mfinfo = XLoadQueryFont(theDisp,FONT1))==NULL && (mfinfo = XLoadQueryFont(theDisp,FONT2))==NULL && (mfinfo = XLoadQueryFont(theDisp,FONT3))==NULL && (mfinfo = XLoadQueryFont(theDisp,FONT4))==NULL && (mfinfo = XLoadQueryFont(theDisp,FONT5))==NULL) { sprintf(dummystr, "couldn't open the following fonts:\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s", FONT1, FONT2, FONT3, FONT4, FONT5); FatalError(dummystr); } mfont=mfinfo->fid; XSetFont(theDisp,theGC,mfont); monofinfo = (XFontStruct *) NULL; if (monofontname) { monofinfo = XLoadQueryFont(theDisp, monofontname); if (!monofinfo) fprintf(stderr,"xv: unable to load font '%s'\n", monofontname); } if (!monofinfo) { if ((monofinfo = XLoadQueryFont(theDisp,MFONT1))==NULL && (monofinfo = XLoadQueryFont(theDisp,MFONT2))==NULL && (monofinfo = XLoadQueryFont(theDisp,MFONT3))==NULL && (monofinfo = XLoadQueryFont(theDisp,MFONT4))==NULL) { sprintf(dummystr,"couldn't open %s fonts:\n\t%s\n\t%s\n\t%s\n\t%s", "any of the following", MFONT1, MFONT2, MFONT3, MFONT4); FatalError(dummystr); } } monofont=monofinfo->fid; #ifdef TV_L10N if (xlocale) { i = 0; while (mfontsize[i]) { xlocale = 1; /* True */ sprintf(mfontset, TV_FONTSET, mfontsize[i]); /*fprintf(stderr, "FontSet: %s\n", mfontset);*/ monofset = XCreateFontSet(theDisp, mfontset, &misscharset, &nmisscharset, &defstr); # if 0 /* not useful */ if (!monofset) { /* the current locale is not supported */ /*fprintf(stderr, "Current locale `%s' is not supported.\n", localeList[i]);*/ xlocale = 0; break; } # endif /*fprintf(stderr, "# of misscharset in mfontsize[%d]: %d\n", i,nmisscharset);*/ for (j = 0; j < nmisscharset; j++) { if (!strncmp(misscharset[j], "jisx0208", 8)) { /* font for JIS X 0208 is not found */ xlocale = 0; break; } } if (xlocale) { monofsetinfo = XExtentsOfFontSet(monofset); monofsetinfo->max_logical_extent.width = mfontsize[i]; /* correct size of TextViewer in case that JIS X 0208 is not found */ break; } i++; } /* while (mfontsize[i]) */ # if 0 if (nmisscharset > 0) { sprintf(dummystr,"missing %d charset:\n", nmisscharset); for (i = 0; i < nmisscharset; i++) { sprintf(dummystr, "%s\t%s\n", dummystr, misscharset[i]); } # if 0 FatalError(dummystr); # else fprintf(stderr, "%s", dummystr); # endif } # endif } #endif /* TV_L10N */ /* if ncols wasn't set, set it to 2^dispDEEP, unless dispDEEP=1, in which case ncols = 0; (ncols = max number of colors allocated. on 1-bit displays, no colors are allocated */ if (ncols == -1) { if (dispDEEP>1) ncols = 1 << ((dispDEEP>8) ? 8 : dispDEEP); else ncols = 0; } else if (ncols>256) ncols = 256; /* so program doesn't blow up */ GenerateFSGamma(); /* has to be done before 'OpenBrowse()' is called */ /* no filenames. build one-name (stdio) list (if stdinflag) */ if (numnames==0) { if (stdinflag) { /* have to malloc namelist[0] so we can free it in deleteFromList() */ namelist[0] = (char *) malloc(strlen(STDINSTR) + 1); if (!namelist[0]) FatalError("unable to to build namelist[0]"); strcpy(namelist[0], STDINSTR); numnames = 1; } else namelist[0] = NULL; } else if (randomShow) { int i, j; char *tmp; srandom((int)time((time_t *)0)); for (i = numnames; i > 1; i--) { j = random() % i; tmp = namelist[i-1]; namelist[i-1] = namelist[j]; namelist[j] = tmp; } } if (numnames) makeDispNames(); if (viewonly || autoquit) { imap = ctrlmap = gmap = browmap = cmtmap = 0; novbrowse = 1; } /* create the info box window */ CreateInfo(infogeom); XSelectInput(theDisp, infoW, ExposureMask | ButtonPressMask | KeyPressMask | StructureNotifyMask); InfoBox(imap); /* map it (or not) */ if (imap) { RedrawInfo(0,0,1000,1000); /* explicit draw if mapped */ XFlush(theDisp); } /* create the control box window */ CreateCtrl(ctrlgeom); epicMode = EM_RAW; SetEpicMode(); XSelectInput(theDisp, ctrlW, ExposureMask | ButtonPressMask | KeyPressMask | StructureNotifyMask); if (ctrlmap < 0) { /* map iconified */ XWMHints xwmh; xwmh.input = True; xwmh.initial_state = IconicState; xwmh.flags = (InputHint | StateHint); XSetWMHints(theDisp, ctrlW, &xwmh); ctrlmap = 1; } CtrlBox(ctrlmap); /* map it (or not) */ if (ctrlmap) { RedrawCtrl(0,0,1000,1000); /* explicit draw if mapped */ XFlush(theDisp); } fixDispNames(); ChangedCtrlList(); /* disable root modes if using non-default visual */ if (!defaultVis) { for (i=RMB_ROOT; i<RMB_MAX; i++) rootMB.dim[i] = 1; } /* create the directory window */ CreateDirW(); XSelectInput(theDisp, dirW, ExposureMask | StructureNotifyMask | ButtonPressMask | KeyPressMask); browseCB.val = browseMode; savenormCB.val = savenorm; /* create the gamma window */ CreateGam(gamgeom, (gamset) ? gamval : -1.0, (cgamset) ? rgamval : -1.0, (cgamset) ? ggamval : -1.0, (cgamset) ? bgamval : -1.0, preset); XSelectInput(theDisp, gamW, ExposureMask | ButtonPressMask | KeyPressMask | StructureNotifyMask | (cmapInGam ? ColormapChangeMask : 0)); GamBox(gmap); /* map it (or not) */ stdnfcols = 0; /* so we don't try to free any if we don't create any */ if (!novbrowse) { MakeBrowCmap(); /* create the visual browser window */ CreateBrowse(browgeom, browgeom != DEFBROWGEOM, fgstr, bgstr, histr, lostr); if (browmap) OpenBrowse(); } else windowMB.dim[WMB_BROWSE] = 1; /* disable visual schnauzer */ CreateTextWins(textgeom, cmtgeom); if (cmtmap) OpenCommentText(); /* create the ps window */ CreatePSD(NULL); XSetTransientForHint(theDisp, psW, dirW); encapsCB.val = preview; pscompCB.val = pscomp; #ifdef HAVE_JPEG CreateJPEGW(); XSetTransientForHint(theDisp, jpegW, dirW); #endif #ifdef HAVE_JP2K CreateJP2KW(); XSetTransientForHint(theDisp, jp2kW, dirW); #endif #ifdef HAVE_TIFF CreateTIFFW(); XSetTransientForHint(theDisp, tiffW, dirW); #endif #ifdef HAVE_PNG CreatePNGW(); XSetTransientForHint(theDisp, pngW, dirW); #endif #ifdef HAVE_WEBP CreateWEBPW(); XSetTransientForHint(theDisp, webpW, dirW); #endif #ifdef HAVE_PCD CreatePCDW(); XSetTransientForHint(theDisp, pcdW, dirW); #endif #ifdef HAVE_PIC2 CreatePIC2W(); XSetTransientForHint(theDisp, pic2W, dirW); #endif #ifdef HAVE_MGCSFX CreateMGCSFXW(); XSetTransientForHint(theDisp, mgcsfxW, dirW); #endif LoadFishCursors(); SetCursors(-1); /* if we're not on a colormapped display, turn off rwcolor */ if (!CMAPVIS(theVisual)) { if (rwcolor) fprintf(stderr, "xv: not a colormapped display. %s\n", "'rwcolor' turned off."); allocMode = AM_READONLY; dispMB.flags[DMB_COLRW] = 0; /* de-'check' */ dispMB.dim[DMB_COLRW] = 1; /* and dim it */ } if (force24) { Set824Menus(PIC24); conv24MB.flags[CONV24_LOCK] = 1; picType = PIC24; } else if (force8) { Set824Menus(PIC8); conv24MB.flags[CONV24_LOCK] = 1; picType = PIC8; } else { Set824Menus(PIC8); /* default mode */ picType = PIC8; } /* make std colormap, maybe */ ChangeCmapMode(colorMapMode, 0, 0); /* Xrandr */ #ifdef HAVE_XRR if (!XRRQueryExtension(theDisp, &RRevent_number, &RRerror_number)) { major = -1; } else { if (DEBUG) fprintf(stderr, "XRRQueryExtension: %d, %d\n", RRevent_number, RRerror_number); if (!XRRQueryVersion(theDisp, &major, &minor)) { if (DEBUG) fprintf(stderr, "XRRQueryVersion failed!\n"); } else { if (DEBUG) fprintf(stderr, "XRRQueryVersion: %d, %d\n", major, minor); } nScreens = ScreenCount(theDisp); for (i = 0; i < nScreens; i++) { XRRSelectInput(theDisp, RootWindow(theDisp, i), RRScreenChangeNotifyMask); } } #endif /* Do The Thing... */ mainLoop(); Quit(0); return(0); } /*****************************************************/ static void makeDirectCmap() { int i, cmaplen, numgot; byte origgot[256]; XColor c; u_long rmask, gmask, bmask; int rshift, gshift, bshift; rmask = theVisual->red_mask; gmask = theVisual->green_mask; bmask = theVisual->blue_mask; rshift = highbit(rmask) - 15; gshift = highbit(gmask) - 15; bshift = highbit(bmask) - 15; if (rshift<0) rmask = rmask << (-rshift); else rmask = rmask >> rshift; if (gshift<0) gmask = gmask << (-gshift); else gmask = gmask >> gshift; if (bshift<0) bmask = bmask << (-bshift); else bmask = bmask >> bshift; cmaplen = theVisual->map_entries; if (cmaplen>256) cmaplen=256; /* try to alloc a 'cmaplen' long grayscale colormap. May not get all entries for whatever reason. Build table 'directConv[]' that maps range [0..(cmaplen-1)] into set of colors we did get */ for (i=0; i<256; i++) { origgot[i] = 0; directConv[i] = 0; } for (i=numgot=0; i<cmaplen; i++) { c.red = c.green = c.blue = (i * 0xffff) / (cmaplen - 1); c.red = c.red & rmask; c.green = c.green & gmask; c.blue = c.blue & bmask; c.flags = DoRed | DoGreen | DoBlue; if (XAllocColor(theDisp, theCmap, &c)) { /* fprintf(stderr,"%3d: %4x,%4x,%4x\n", i, c.red,c.green,c.blue); */ directConv[i] = i; origgot[i] = 1; numgot++; } } if (numgot == 0) FatalError("Got no entries in DirectColor cmap!\n"); /* directConv may or may not have holes in it. */ for (i=0; i<cmaplen; i++) { if (!origgot[i]) { int numbak, numfwd; numbak = numfwd = 0; while ((i - numbak) >= 0 && !origgot[i-numbak]) numbak++; while ((i + numfwd) < cmaplen && !origgot[i+numfwd]) numfwd++; if (i-numbak<0 || !origgot[i-numbak]) numbak = 999; if (i+numfwd>=cmaplen || !origgot[i+numfwd]) numfwd = 999; if (numbak<numfwd) directConv[i] = directConv[i-numbak]; else if (numfwd<999) directConv[i] = directConv[i+numfwd]; else FatalError("DirectColor cmap: can't happen!"); } } } static int highbit(ul) unsigned long ul; { /* returns position of highest set bit in 'ul' as an integer (0-31), or -1 if none */ int i; unsigned long hb; hb = 0x8000; hb = (hb<<16); /* hb = 0x80000000UL */ for (i=31; ((ul & hb) == 0) && i>=0; i--, ul<<=1); return i; } /*****************************************************/ static void useOtherVisual(vinfo, best) XVisualInfo *vinfo; int best; { if (!vinfo || best<0) return; if (vinfo[best].visualid == XVisualIDFromVisual(DefaultVisual(theDisp, theScreen))) return; theVisual = vinfo[best].visual; if (DEBUG) { fprintf(stderr,"%s: using %s visual (0x%0x), depth = %d, screen = %d\n", cmd, (vinfo[best].class==StaticGray) ? "StaticGray" : (vinfo[best].class==StaticColor) ? "StaticColor" : (vinfo[best].class==TrueColor) ? "TrueColor" : (vinfo[best].class==GrayScale) ? "GrayScale" : (vinfo[best].class==PseudoColor) ? "PseudoColor" : (vinfo[best].class==DirectColor) ? "DirectColor" : "<unknown>", (int) vinfo[best].visualid, vinfo[best].depth, vinfo[best].screen); fprintf(stderr,"\tmasks: (0x%x,0x%x,0x%x), bits_per_rgb=%d\n", (int) vinfo[best].red_mask, (int) vinfo[best].green_mask, (int) vinfo[best].blue_mask, vinfo[best].bits_per_rgb); } dispDEEP = vinfo[best].depth; theScreen = vinfo[best].screen; if (spec_window) { rootW = spec_window; } else { rootW = RootWindow(theDisp,theScreen); } ncells = vinfo[best].colormap_size; theCmap = XCreateColormap(theDisp, rootW, theVisual, AllocNone); { /* create a temporary window using this visual so we can create a GC for this visual */ Window win; XSetWindowAttributes xswa; XGCValues xgcv; unsigned long xswamask; XFlush(theDisp); XSync(theDisp, False); xswa.background_pixmap = None; xswa.border_pixel = 1; xswa.colormap = theCmap; xswamask = CWBackPixmap | CWBorderPixel | CWColormap; win = XCreateWindow(theDisp, rootW, 0, 0, 100, 100, 2, (int) dispDEEP, InputOutput, theVisual, xswamask, &xswa); XFlush(theDisp); XSync(theDisp, False); theGC = XCreateGC(theDisp, win, 0L, &xgcv); XDestroyWindow(theDisp, win); } vrWIDE = dispWIDE = DisplayWidth(theDisp,theScreen); vrHIGH = dispHIGH = DisplayHeight(theDisp,theScreen); maxWIDE = dispWIDE; maxHIGH = dispHIGH; } /*****************************************************/ static void parseResources(argc, argv) int argc; char **argv; { int i, pm; /* once through the argument list to find the display name and DEBUG level, if any */ for (i=1; i<argc; ++i) { if (!strncmp(argv[i],"-help", (size_t) 5)) { /* help */ cmdSyntax(0); } else if (!argcmp(argv[i],"-display",4,0,&pm)) { ++i; if (i<argc) display = argv[i]; break; } #ifdef VMS /* in VMS, cmd-line opts are in lower case */ else if (!argcmp(argv[i],"-debug",3,0,&pm)) { if (++i<argc) DEBUG = atoi(argv[i]); } #else else if (!argcmp(argv[i],"-DEBUG",2,0,&pm)) { if (++i<argc) DEBUG = atoi(argv[i]); } #endif } /* open the display */ if ( (theDisp=XOpenDisplay(display)) == NULL) { fprintf(stderr, "%s: Can't open display\n",argv[0]); exit(1); } i = 0; XtToolkitInitialize(); context = XtCreateApplicationContext(); XtDisplayInitialize(context, theDisp, NULL, "XV", NULL, 0, &i, argv); if (rd_str ("aspect")) { int n,d; if (sscanf(def_str,"%d:%d",&n,&d)!=2 || n<1 || d<1) fprintf(stderr,"%s: unable to parse 'aspect' resource\n",cmd); else defaspect = (float) n / (float) d; } if (rd_flag("2xlimit")) limit2x = def_int; if (rd_flag("auto4x3")) auto4x3 = def_int; if (rd_flag("autoClose")) autoclose = def_int; if (rd_flag("autoCrop")) autocrop = def_int; if (rd_flag("autoDither")) autodither = def_int; if (rd_flag("autoHFlip")) autohflip = def_int; if (rd_flag("autoHistEq")) autohisteq = def_int; if (rd_flag("autoNorm")) autonorm = def_int; if (rd_flag("autoRaw")) autoraw = def_int; if (rd_int ("autoRotate")) autorotate = def_int; if (rd_flag("autoSmooth")) autosmooth = def_int; if (rd_flag("autoVFlip")) autovflip = def_int; if (rd_str ("background")) bgstr = def_str; if (rd_flag("best24") && def_int) conv24 = CONV24_BEST; if (rd_str ("black")) blackstr = def_str; if (rd_int ("borderWidth")) bwidth = def_int; if (rd_str ("ceditGeometry")) gamgeom = def_str; if (rd_flag("ceditMap")) gmap = def_int; if (rd_flag("ceditColorMap")) cmapInGam = def_int; if (rd_flag("clearOnLoad")) clearonload = def_int; if (rd_str ("commentGeometry")) cmtgeom = def_str; if (rd_flag("commentMap")) cmtmap = def_int; if (rd_str ("ctrlGeometry")) ctrlgeom = def_str; if (rd_flag("ctrlMap")) ctrlmap = def_int; if (rd_int ("cursor")) curstype = def_int; if (rd_int ("defaultPreset")) preset = def_int; if (rd_int ("incrementalSearchTimeout")) incrementalSearchTimeout = def_int; if (rd_str ("driftKludge")) { if (sscanf(def_str,"%d %d", &kludge_offx, &kludge_offy) != 2) { kludge_offx = kludge_offy = 0; } } if (rd_str ("expand")) { if (index(def_str, ':')) { if (sscanf(def_str, "%lf:%lf", &hexpand, &vexpand)!=2) { hexpand = vexpand = 1.0; } } else hexpand = vexpand = atof(def_str); } if (rd_str ("fileList")) flistName = def_str; if (rd_flag("fixed")) fixedaspect = def_int; #ifdef ENABLE_FIXPIX_SMOOTH if (rd_flag("fixpix")) do_fixpix_smooth = def_int; #endif if (rd_flag("force8")) force8 = def_int; if (rd_flag("force24")) force24 = def_int; if (rd_str ("foreground")) fgstr = def_str; if (rd_str ("geometry")) maingeom = def_str; if (rd_str ("gsDevice")) gsDev = def_str; if (rd_str ("gsGeometry")) gsGeomStr = def_str; if (rd_int ("gsResolution")) gsRes = def_int; if (rd_flag("hsvMode")) hsvmode = def_int; if (rd_str ("highlight")) histr = def_str; if (rd_str ("iconGeometry")) icongeom = def_str; if (rd_flag("iconic")) startIconic = def_int; if (rd_str ("imageBackground")) imagebgstr = def_str; if (rd_str ("infoGeometry")) infogeom = def_str; if (rd_flag("infoMap")) imap = def_int; if (rd_flag("loadBrowse")) browseMode = def_int; if (rd_str ("lowlight")) lostr = def_str; #ifdef MACBINARY if (rd_flag("macbinary")) handlemacb = def_int; #endif #ifdef HAVE_MGCSFX if (rd_flag("mgcsfx")) mgcsfx = def_int; #endif if (rd_flag("mono")) mono = def_int; if (rd_str ("monofont")) monofontname = def_str; if (rd_int ("ncols")) ncols = def_int; if (rd_flag("ninstall")) ninstall = def_int; if (rd_flag("nodecor")) nodecor = def_int; if (rd_flag("nolimits")) nolimits = def_int; #ifdef HAVE_MGCSFX if (rd_flag("nomgcsfx")) nomgcsfx = def_int; #endif #if defined(HAVE_PIC) || defined(HAVE_PIC2) if (rd_flag("nopicadjust")) nopicadjust = def_int; #endif if (rd_flag("nopos")) nopos = def_int; if (rd_flag("forcegeom]")) forcegeom = def_int; if (rd_flag("noqcheck")) noqcheck = def_int; if (rd_flag("nostat")) nostat = def_int; if (rd_flag("ownCmap")) owncmap = def_int; if (rd_flag("perfect")) perfect = def_int; #ifdef HAVE_PIC2 if (rd_flag("pic2split")) pic2split = def_int; #endif if (rd_flag("popupKludge")) winCtrPosKludge = def_int; if (rd_str ("print")) strncpy(printCmd, def_str, (size_t) PRINTCMDLEN); if (rd_flag("pscompress")) pscomp = def_int; if (rd_flag("pspreview")) preview = def_int; if (rd_flag("quick24") && def_int) conv24 = CONV24_FAST; if (rd_flag("resetroot")) resetroot = def_int; if (rd_flag("reverse")) revvideo = def_int; if (rd_str ("rootBackground")) rootbgstr = def_str; if (rd_str ("rootForeground")) rootfgstr = def_str; if (rd_int ("rootMode")) { rootMode = def_int; ++rmodeset; } if (rd_flag("rwColor")) rwcolor = def_int; if (rd_flag("saveNormal")) savenorm = def_int; if (rd_str ("searchDirectory")) strcpy(searchdir, def_str); if (rd_str ("textviewGeometry")) textgeom = def_str; if (rd_flag("useStdCmap")) stdcmap = def_int; if (rd_str ("visual")) visualstr = def_str; #ifdef VS_ADJUST if (rd_flag("vsadjust")) vsadjust = def_int; #endif if (rd_flag("vsDisable")) novbrowse = def_int; if (rd_str ("vsGeometry")) browgeom = def_str; if (rd_flag("vsMap")) browmap = def_int; if (rd_flag("vsPerfect")) browPerfect = def_int; if (rd_str ("white")) whitestr = def_str; /* Check for any command-bindings to the supported function keys */ #define TMPLEN 80 for (i=0; i<FSTRMAX; ++i) { char tmp[TMPLEN]; snprintf(tmp, TMPLEN, "F%dcommand", i+1); if (rd_str(tmp)) fkeycmds[i] = def_str; else fkeycmds[i] = NULL; } #undef TMPLEN } /*****************************************************/ static void parseCmdLine(argc, argv) int argc; char **argv; { int i, oldi, not_in_first_half, pm; orignumnames = 0; for (i=1, numnames=0; i<argc; i++) { oldi = i; not_in_first_half = 0; if (argv[i][0] != '-' && argv[i][0] != '+') { /* a file name. put it in list */ if (!nostat) { struct stat st; int ftype; if (stat(argv[i], &st) == 0) { ftype = st.st_mode; if (!S_ISREG(ftype)) continue; /* stat'd & isn't file. skip it */ } } if (numnames<MAXNAMES) { #ifdef AUTO_EXPAND if(Isarchive(argv[i]) == 0){ /* Not archive file */ namelist[numnames++] = argv[i]; } #else namelist[numnames++] = argv[i]; #endif if (numnames==MAXNAMES) { fprintf(stderr,"%s: too many filenames. Using only first %d.\n", cmd, MAXNAMES); } } } else if (!strcmp(argv[i], "-")) /* stdin flag */ stdinflag++; else if (!argcmp(argv[i],"-24", 3,1,&force24 )); /* force24 */ else if (!argcmp(argv[i],"-2xlimit",3,1,&limit2x )); /* 2xlimit */ else if (!argcmp(argv[i],"-4x3", 2,1,&auto4x3 )); /* 4x3 */ else if (!argcmp(argv[i],"-8", 2,1,&force8 )); /* force8 */ else if (!argcmp(argv[i],"-acrop", 3,1,&autocrop)); /* autocrop */ else if (!argcmp(argv[i],"-aspect",3,0,&pm)) { /* def. aspect */ int n,d; if (++i<argc) { if (sscanf(argv[i],"%d:%d",&n,&d)!=2 || n<1 || d<1) fprintf(stderr,"%s: bad aspect ratio '%s'\n",cmd,argv[i]); else defaspect = (float) n / (float) d; } } else if (!argcmp(argv[i],"-windowid",3,0,&pm)) { if (++i<argc) { if (sscanf(argv[i], "%ld", &spec_window) != 1) { fprintf(stderr,"%s: bad argument to -windowid '%s'\n",cmd,argv[i]); } } } else if (!argcmp(argv[i],"-best24",3,0,&pm)) /* -best */ conv24 = CONV24_BEST; else if (!argcmp(argv[i],"-bg",3,0,&pm)) /* bg color */ { if (++i<argc) bgstr = argv[i]; } else if (!argcmp(argv[i],"-black",3,0,&pm)) /* black color */ { if (++i<argc) blackstr = argv[i]; } else if (!argcmp(argv[i],"-bw",3,0,&pm)) /* border width */ { if (++i<argc) bwidth=atoi(argv[i]); } else if (!argcmp(argv[i],"-cecmap",4,1,&cmapInGam)); /* cmapInGam */ else if (!argcmp(argv[i],"-cegeometry",4,0,&pm)) /* gammageom */ { if (++i<argc) gamgeom = argv[i]; } else if (!argcmp(argv[i],"-cemap",4,1,&gmap)); /* gmap */ else if (!argcmp(argv[i],"-cgamma",4,0,&pm)) { /* color gamma */ if (i+3<argc) { rgamval = atof(argv[++i]); ggamval = atof(argv[++i]); bgamval = atof(argv[++i]); } cgamset++; } else if (!argcmp(argv[i],"-cgeometry",4,0,&pm)) /* ctrlgeom */ { if (++i<argc) ctrlgeom = argv[i]; } else if (!argcmp(argv[i],"-clear",4,1,&clrroot)); /* clear */ else if (!argcmp(argv[i],"-close",4,1,&autoclose)); /* close */ else if (!argcmp(argv[i],"-cmap", 3,1,&ctrlmap)); /* ctrlmap */ else if (!argcmp(argv[i],"-cmtgeometry",5,0,&pm)) /* comment geom */ { if (++i<argc) cmtgeom = argv[i]; } else if (!argcmp(argv[i],"-cmtmap",5,1,&cmtmap)); /* map cmt window */ else if (!argcmp(argv[i],"-crop",3,0,&pm)) { /* crop */ if (i+4<argc) { acropX = atoi(argv[++i]); acropY = atoi(argv[++i]); acropW = atoi(argv[++i]); acropH = atoi(argv[++i]); } acrop++; } else if (!argcmp(argv[i],"-cursor",3,0,&pm)) /* cursor */ { if (++i<argc) curstype = atoi(argv[i]); } #ifdef VMS /* in VMS, cmd-line-opts are in lower case */ else if (!argcmp(argv[i],"-debug",3,0,&pm)) { { if (++i<argc) DEBUG = atoi(argv[i]); } } #else else if (!argcmp(argv[i],"-DEBUG",2,0,&pm)) { { if (++i<argc) DEBUG = atoi(argv[i]); } } #endif else if (!argcmp(argv[i],"-dir",4,0,&pm)) /* search dir */ { if (++i<argc) strcpy(searchdir, argv[i]); } else if (!argcmp(argv[i],"-display",4,0,&pm)) /* display */ { if (++i<argc) display = argv[i]; } else if (!argcmp(argv[i],"-dither",4,1,&autodither)); /* autodither */ else if (!argcmp(argv[i],"-drift",3,0,&pm)) { /* drift kludge */ if (i<argc-2) { kludge_offx = atoi(argv[++i]); kludge_offy = atoi(argv[++i]); } } else if (!argcmp(argv[i],"-expand",2,0,&pm)) { /* expand factor */ if (++i<argc) { if (index(argv[i], ':')) { if (sscanf(argv[i], "%lf:%lf", &hexpand, &vexpand)!=2) { hexpand = vexpand = 1.0; } } else hexpand = vexpand = atof(argv[i]); } } else if (!argcmp(argv[i],"-fg",3,0,&pm)) /* fg color */ { if (++i<argc) fgstr = argv[i]; } else if (!argcmp(argv[i],"-fixed",5,1,&fixedaspect)); /* fix asp. ratio */ #ifdef ENABLE_FIXPIX_SMOOTH else if (!argcmp(argv[i],"-fixpix",5,1,&do_fixpix_smooth)); /* dithering */ #endif else if (!argcmp(argv[i],"-flist",3,0,&pm)) /* file list */ { if (++i<argc) flistName = argv[i]; } else if (!argcmp(argv[i],"-gamma",3,0,&pm)) /* gamma */ { if (++i<argc) gamval = atof(argv[i]); gamset++; } else if (!argcmp(argv[i],"-geometry",3,0,&pm)) /* geometry */ { if (++i<argc) maingeom = argv[i]; } else if (!argcmp(argv[i],"-grabdelay",3,0,&pm)) /* grabDelay */ { if (++i<argc) grabDelay = atoi(argv[i]); } else if (!argcmp(argv[i],"-gsdev",4,0,&pm)) /* gsDevice */ { if (++i<argc) gsDev = argv[i]; } else if (!argcmp(argv[i],"-gsgeom",4,0,&pm)) /* gsGeometry */ { if (++i<argc) gsGeomStr = argv[i]; } else if (!argcmp(argv[i],"-gsres",4,0,&pm)) /* gsResolution */ { if (++i<argc) gsRes=abs(atoi(argv[i])); } else if (!argcmp(argv[i],"-hflip",3,1,&autohflip)); /* hflip */ else if (!argcmp(argv[i],"-hi",3,0,&pm)) /* highlight */ { if (++i<argc) histr = argv[i]; } #ifdef HAVE_G3 else if (!argcmp(argv[i],"-fax",3,3,&highresfax)); /* high resolution fax */ else if (!argcmp(argv[i],"-lowresfax",4,0,&lowresfax)); /* low resolution fax */ else if (!argcmp(argv[i],"-highresfax",4,0,&highresfax));/* high res. fax */ #endif else if (!argcmp(argv[i],"-hist", 4,1,&autohisteq)); /* hist eq */ else if (!argcmp(argv[i],"-hsv", 3,1,&hsvmode)); /* hsvmode */ else if (!argcmp(argv[i],"-icgeometry",4,0,&pm)) /* icon geometry */ { if (++i<argc) icongeom = argv[i]; } else if (!argcmp(argv[i],"-iconic",4,1,&startIconic)); /* iconic */ else if (!argcmp(argv[i],"-igeometry",3,0,&pm)) /* infogeom */ { if (++i<argc) infogeom = argv[i]; } else if (!argcmp(argv[i],"-imap",3,1,&imap)); /* imap */ else if (!argcmp(argv[i],"-ibg",3,0,&pm)) /* image bkgd color */ { if (++i<argc) imagebgstr = argv[i]; } else if (!argcmp(argv[i],"-lbrowse",3,1,&browseMode)); /* browse mode */ else if (!argcmp(argv[i],"-lo",3,0,&pm)) /* lowlight */ { if (++i<argc) lostr = argv[i]; } else if (!argcmp(argv[i],"-loadclear",4,1,&clearonload)); /* clearonload */ else not_in_first_half = 1; if (i != oldi) continue; /* parsed something... */ /* split huge else-if group into two halves, as it breaks some compilers */ if (!argcmp(argv[i],"-max",4,1,&automax)); /* auto maximize */ else if (!argcmp(argv[i],"-maxpect",5,1,&pm)) /* auto maximize */ { automax=pm; fixedaspect=pm; } #ifdef MACBINARY else if (!argcmp(argv[i],"-macbinary",3,1,&handlemacb)); /* macbinary */ #endif else if (!argcmp(argv[i],"-mfn",3,0,&pm)) /* mono font name */ { if (++i<argc) monofontname = argv[i]; } #ifdef HAVE_MGCSFX else if (!argcmp(argv[i],"-mgcsfx", 4,1,&mgcsfx)); /* mgcsfx */ #endif else if (!argcmp(argv[i],"-mono",3,1,&mono)); /* mono */ else if (!argcmp(argv[i],"-name",3,0,&pm)) /* name */ { if (++i<argc) winTitle = argv[i]; } else if (!argcmp(argv[i],"-ncols",3,0,&pm)) /* ncols */ { if (++i<argc) ncols=abs(atoi(argv[i])); } else if (!argcmp(argv[i],"-ninstall", 3,1,&ninstall)); /* inst cmaps? */ else if (!argcmp(argv[i],"-nodecor", 4,1,&nodecor)); else if (!argcmp(argv[i],"-nofreecols",4,1,&noFreeCols)); else if (!argcmp(argv[i],"-nolimits", 4,1,&nolimits)); /* nolimits */ #ifdef HAVE_MGCSFX else if (!argcmp(argv[i],"-nomgcsfx", 4,1,&nomgcsfx)); /* nomgcsfx */ #endif #if defined(HAVE_PIC) || defined(HAVE_PIC2) else if (!argcmp(argv[i],"-nopicadjust", 4,1,&nopicadjust));/*nopicadjust*/ #endif else if (!argcmp(argv[i],"-nopos", 4,1,&nopos)); /* nopos */ else if (!argcmp(argv[i],"-forcegeom", 6,1,&forcegeom)); /* forcegeom */ else if (!argcmp(argv[i],"-noqcheck", 4,1,&noqcheck)); /* noqcheck */ else if (!argcmp(argv[i],"-noresetroot",5,1,&resetroot)); /* reset root */ else if (!argcmp(argv[i],"-norm", 5,1,&autonorm)); /* norm */ else if (!argcmp(argv[i],"-nostat", 4,1,&nostat)); /* nostat */ else if (!argcmp(argv[i],"-owncmap", 2,1,&owncmap)); /* own cmap */ #ifdef HAVE_PCD else if (!argcmp(argv[i],"-pcd", 4,0,&pm)) /* pcd with size */ { if (i+1<argc) PcdSize = atoi(argv[++i]); } #endif else if (!argcmp(argv[i],"-perfect", 3,1,&perfect)); /* -perfect */ #ifdef HAVE_PIC2 else if (!argcmp(argv[i],"-pic2split", 3,1,&pic2split)); /* pic2split */ #endif else if (!argcmp(argv[i],"-pkludge", 3,1,&winCtrPosKludge)); else if (!argcmp(argv[i],"-poll", 3,1,&polling)); /* chk mod? */ else if (!argcmp(argv[i],"-preset",3,0,&pm)) /* preset */ { if (++i<argc) preset=abs(atoi(argv[i])); } else if (!argcmp(argv[i],"-quick24",5,0,&pm)) /* quick 24-to-8 conv */ conv24 = CONV24_FAST; else if (!argcmp(argv[i],"-quit", 2,1,&autoquit)); /* auto-quit */ else if (!argcmp(argv[i],"-random", 4,1,&randomShow)); /* random */ else if (!argcmp(argv[i],"-raw", 4,1,&autoraw)); /* force raw */ else if (!argcmp(argv[i],"-rbg",3,0,&pm)) /* root background color */ { if (++i<argc) rootbgstr = argv[i]; } else if (!argcmp(argv[i],"-rfg",3,0,&pm)) /* root foreground color */ { if (++i<argc) rootfgstr = argv[i]; } else if (!argcmp(argv[i],"-rgb",4,1,&pm)) /* rgb mode */ hsvmode = !pm; else if (!argcmp(argv[i],"-RM",3,0,&pm)) /* auto-delete */ autoDelete = 1; else if (!argcmp(argv[i],"-rmode",3,0,&pm)) /* root pattern */ { if (++i<argc) rootMode = atoi(argv[i]); useroot++; rmodeset++; } else if (!argcmp(argv[i],"-root",4,1,&useroot)); /* use root window */ else if (!argcmp(argv[i],"-rotate",4,0,&pm)) /* rotate */ { if (++i<argc) autorotate = atoi(argv[i]); } else if (!argcmp(argv[i],"-rv",3,1,&revvideo)); /* reverse video */ else if (!argcmp(argv[i],"-rw",3,1,&rwcolor)); /* use r/w color */ else if (!argcmp(argv[i],"-slow24",3,0,&pm)) /* slow 24->-8 conv.*/ conv24 = CONV24_SLOW; else if (!argcmp(argv[i],"-smooth",3,1,&autosmooth)); /* autosmooth */ else if (!argcmp(argv[i],"-startgrab",3,1,&startGrab)); /* startGrab */ else if (!argcmp(argv[i],"-stdcmap",3,1,&stdcmap)); /* use stdcmap */ else if (!argcmp(argv[i],"-tgeometry",2,0,&pm)) /* textview geom */ { if (++i<argc) textgeom = argv[i]; } else if (!argcmp(argv[i],"-vflip",3,1,&autovflip)); /* vflip */ else if (!argcmp(argv[i],"-viewonly",4,1,&viewonly)); /* viewonly */ else if (!argcmp(argv[i],"-visual",4,0,&pm)) /* visual */ { if (++i<argc) visualstr = argv[i]; } #ifdef VS_ADJUST else if (!argcmp(argv[i],"-vsadjust", 3,1,&vsadjust)); /* vsadjust */ #endif else if (!argcmp(argv[i],"-vsdisable",4,1,&novbrowse)); /* disable sch? */ else if (!argcmp(argv[i],"-vsgeometry",4,0,&pm)) /* visSchnauzer geom */ { if (++i<argc) browgeom = argv[i]; } else if (!argcmp(argv[i],"-vsmap",4,1,&browmap)); /* visSchnauzer map */ else if (!argcmp(argv[i],"-vsperfect",3,1,&browPerfect)); /* vs perf. */ else if (!argcmp(argv[i],"-wait",3,0,&pm)) { /* secs betwn pics */ if (++i<argc) { char *comma = strchr(argv[i], ','); waitsec_nonfinal = fabs(atof(argv[i])); waitsec_final = comma? fabs(atof(comma+1)) : waitsec_nonfinal; } } else if (!argcmp(argv[i],"-white",3,0,&pm)) /* white color */ { if (++i<argc) whitestr = argv[i]; } else if (!argcmp(argv[i],"-wloop",3,1,&waitloop)); /* waitloop */ else if (not_in_first_half) cmdSyntax(1); } /* build origlist[], a copy of namelist that remains unmodified, for use with the 'autoDelete' option */ orignumnames = numnames; xvbcopy((char *) namelist, (char *) origlist, sizeof(origlist)); } /*****************************************************************/ static void verifyArgs() { /* check options for validity */ if (strlen(searchdir)) { /* got a search directory */ #ifdef AUTO_EXPAND if (Chvdir(searchdir)) { #else if (chdir(searchdir)) { #endif fprintf(stderr,"xv: unable to cd to directory '%s'.\n",searchdir); fprintf(stderr, " Ignoring '-dir' option and/or 'xv.searchDirectory' resource\n"); searchdir[0] = '\0'; } } if (flistName) add_filelist_to_namelist(flistName, namelist, &numnames, MAXNAMES); RANGE(curstype,0,254); curstype = curstype & 0xfe; /* clear low bit to make curstype even */ if (hexpand == 0.0 || vexpand == 0.0) cmdSyntax(1); if (rootMode < 0 || rootMode > RM_MAX) rmodeSyntax(); if (DEBUG) XSynchronize(theDisp, True); /* if using root, generally gotta map ctrl window, 'cause there won't be any way to ask for it. (no kbd or mouse events from rootW) */ if (useroot && !autoquit) ctrlmap = -1; if (abs(autorotate) != 0 && abs(autorotate) != 90 && abs(autorotate) != 180 && abs(autorotate) != 270) { fprintf(stderr,"Invalid auto rotation value (%d) ignored.\n", autorotate); fprintf(stderr," (Valid values: 0, +-90, +-180, +-270)\n"); autorotate = 0; } if (grabDelay < 0 || grabDelay > 15) { fprintf(stderr, "Invalid '-grabdelay' value ignored. Valid range is 0-15 seconds.\n"); grabDelay = 0; } if (preset<0 || preset>4) { fprintf(stderr,"Invalid default preset value (%d) ignored.\n", preset); fprintf(stderr," (Valid values: 1, 2, 3, 4)\n"); preset = 0; } if (waitsec < 0.0) noFreeCols = 0; /* disallow nfc if not doing slideshow */ if (noFreeCols && perfect) { perfect = 0; owncmap = 1; } /* decide what default color allocation stuff we've settled on */ if (rwcolor) allocMode = AM_READWRITE; if (perfect) colorMapMode = CM_PERFECT; if (owncmap) colorMapMode = CM_OWNCMAP; if (stdcmap) colorMapMode = CM_STDCMAP; defaultCmapMode = colorMapMode; /* default mode for 8-bit images */ /* if -root and -maxp, disallow 'integer' tiling modes */ if (useroot && fixedaspect && automax && !rmodeset && (rootMode == RM_TILE || rootMode == RM_IMIRROR)) rootMode = RM_CSOLID; } static int cpos = 0; /***********************************/ static void printoption(st) const char *st; { if (strlen(st) + cpos > 78) { fprintf(stderr,"\n "); cpos = 3; } fprintf(stderr,"%s ",st); cpos = cpos + strlen(st) + 1; } static void cmdSyntax(i) int i; { /* GRR 19980605: added version info for most common libraries */ fprintf(stderr, "XV - %s.\n", REVDATE); #ifdef HAVE_JPEG VersionInfoJPEG(); #endif #ifdef HAVE_JP2K VersionInfoJP2K(); #endif #ifdef HAVE_TIFF VersionInfoTIFF(); #endif #ifdef HAVE_PNG VersionInfoPNG(); #endif #ifdef HAVE_WEBP VersionInfoWEBP(); #endif /* pbm/pgm/ppm support is native, not via pbmplus/netpbm libraries */ fprintf(stderr, "\n"); fprintf(stderr, "Usage:\n"); printoption(cmd); printoption("[-]"); printoption("[-/+24]"); printoption("[-/+2xlimit]"); printoption("[-/+4x3]"); printoption("[-/+8]"); printoption("[-/+acrop]"); printoption("[-aspect w:h]"); printoption("[-best24]"); printoption("[-bg color]"); printoption("[-black color]"); printoption("[-bw width]"); printoption("[-/+cecmap]"); printoption("[-cegeometry geom]"); printoption("[-/+cemap]"); printoption("[-cgamma rval gval bval]"); printoption("[-cgeometry geom]"); printoption("[-/+clear]"); printoption("[-/+close]"); printoption("[-/+cmap]"); printoption("[-cmtgeometry geom]"); printoption("[-/+cmtmap]"); printoption("[-crop x y w h]"); printoption("[-cursor char#]"); #ifndef VMS printoption("[-DEBUG level]"); #else printoption("[-debug level]"); #endif printoption("[-dir directory]"); printoption("[-display disp]"); printoption("[-/+dither]"); printoption("[-drift dx dy]"); printoption("[-expand exp | hexp:vexp]"); printoption("[-fg color]"); printoption("[-/+fixed]"); #ifdef ENABLE_FIXPIX_SMOOTH printoption("[-/+fixpix]"); #endif printoption("[-flist fname]"); printoption("[-gamma val]"); printoption("[-geometry geom]"); printoption("[-grabdelay seconds]"); printoption("[-gsdev str]"); printoption("[-gsgeom geom]"); printoption("[-gsres int]"); printoption("[-help]"); printoption("[-/+hflip]"); printoption("[-hi color]"); printoption("[-/+hist]"); printoption("[-/+hsv]"); printoption("[-ibg color]"); /* GRR 19980314 */ printoption("[-icgeometry geom]"); printoption("[-/+iconic]"); printoption("[-igeometry geom]"); printoption("[-/+imap]"); printoption("[-/+lbrowse]"); printoption("[-lo color]"); printoption("[-/+loadclear]"); #ifdef MACBINARY printoption("[-/+macbinary]"); #endif printoption("[-/+max]"); printoption("[-/+maxpect]"); printoption("[-mfn font]"); #ifdef HAVE_MGCSFX printoption("[-/+mgcsfx]"); #endif printoption("[-/+mono]"); printoption("[-name str]"); printoption("[-ncols #]"); printoption("[-/+ninstall]"); printoption("[-/+nodecor]"); printoption("[-/+nofreecols]"); printoption("[-/+nolimits]"); #ifdef HAVE_MGCSFX printoption("[-/+nomgcsfx]"); #endif #if defined(HAVE_PIC) || defined(HAVE_PIC2) printoption("[-/+nopicadjust]"); #endif printoption("[-/+nopos]"); printoption("[-/+forcegeom]"); printoption("[-/+noqcheck]"); printoption("[-/+noresetroot]"); printoption("[-/+norm]"); printoption("[-/+nostat]"); printoption("[-/+owncmap]"); #ifdef HAVE_PCD printoption("[-pcd size(0=192*128,1,2,3,4=3072*2048)]"); #endif printoption("[-/+perfect]"); #ifdef HAVE_PIC2 printoption("[-/+pic2split]"); #endif printoption("[-/+pkludge]"); printoption("[-/+poll]"); printoption("[-preset #]"); printoption("[-quick24]"); printoption("[-/+quit]"); printoption("[-/+random]"); printoption("[-/+raw]"); printoption("[-rbg color]"); printoption("[-rfg color]"); printoption("[-/+rgb]"); printoption("[-RM]"); printoption("[-rmode #]"); printoption("[-/+root]"); printoption("[-rotate deg]"); printoption("[-/+rv]"); printoption("[-/+rw]"); printoption("[-slow24]"); printoption("[-/+smooth]"); printoption("[-/+startgrab]"); printoption("[-/+stdcmap]"); printoption("[-tgeometry geom]"); printoption("[-/+vflip]"); printoption("[-/+viewonly]"); printoption("[-visual type]"); #ifdef VS_ADJUST printoption("[-/+vsadjust]"); #endif printoption("[-/+vsdisable]"); printoption("[-vsgeometry geom]"); printoption("[-/+vsmap]"); printoption("[-/+vsperfect]"); printoption("[-wait secs[,final_secs]]"); printoption("[-white color]"); printoption("[-windowid windowid]"); printoption("[-/+wloop]"); #ifdef HAVE_G3 printoption("[-fax]"); printoption("[-lowresfax]"); printoption("[-highresfax]"); #endif printoption("[filename ...]"); fprintf(stderr,"\n\n"); Quit(i); } /***********************************/ static void rmodeSyntax() { fprintf(stderr,"%s: unknown root mode '%d'. Valid modes are:\n", cmd, rootMode); fprintf(stderr,"\t0: tiling\n"); fprintf(stderr,"\t1: integer tiling\n"); fprintf(stderr,"\t2: mirrored tiling\n"); fprintf(stderr,"\t3: integer mirrored tiling\n"); fprintf(stderr,"\t4: centered tiling\n"); fprintf(stderr,"\t5: centered on a solid background\n"); fprintf(stderr,"\t6: centered on a 'warp' background\n"); fprintf(stderr,"\t7: centered on a 'brick' background\n"); fprintf(stderr,"\t8: symmetrical tiling\n"); fprintf(stderr,"\t9: symmetrical mirrored tiling\n"); fprintf(stderr,"\t10: upper left corner\n"); fprintf(stderr,"\n"); Quit(1); } /***********************************/ static int argcmp(a1, a2, minlen, plusallowed, plusminus) const char *a1, *a2; int minlen, plusallowed; int *plusminus; { /* does a string compare between a1 and a2. To return '0', a1 and a2 must match to the length of a1, and that length has to be at least 'minlen'. Otherwise, return non-zero. plusminus set to '1' if '-option', '0' if '+option' */ if ((strlen(a1) < (size_t) minlen) || (strlen(a2) < (size_t) minlen)) return 1; if (strlen(a1) > strlen(a2)) return 1; if (strncmp(a1+1, a2+1, strlen(a1)-1)) return 1; if (a1[0]=='-' || (plusallowed && a1[0]=='+')) { /* only set if we match */ *plusminus = (a1[0] == '-'); return 0; } return 1; } /***********************************/ static int openPic(filenum) int filenum; { /* tries to load file #filenum (from 'namelist' list) * returns 0 on failure (cleans up after itself) * returns '-1' if caller should display DFLTPIC (shown as text) * if successful, returns 1, creates mainW * * By the way, I'd just like to point out that this procedure has gotten * *way* out of hand... */ PICINFO pinfo; int i,filetype,freename, frompipe, frompoll, fromint, killpage; int oldeWIDE, oldeHIGH, oldpWIDE, oldpHIGH; int oldCXOFF, oldCYOFF, oldCWIDE, oldCHIGH, wascropped; char *tmp; char *fullname, /* full name of the original file */ filename[MAXPATHLEN]; /* full name of file to load (could be /tmp/xxx)*/ #ifdef MACBINARY char origname[MAXPATHLEN]; /* file name of original file (NO processing) */ origname[0] = '\0'; #endif xvbzero((char *) &pinfo, sizeof(PICINFO)); /* init important fields of pinfo */ pinfo.pic = (byte *) NULL; pinfo.comment = (char *) NULL; pinfo.numpages = 1; pinfo.pagebname[0] = '\0'; normaspect = defaspect; freename = dfltkludge = frompipe = frompoll = fromint = wascropped = 0; oldpWIDE = oldpHIGH = oldCXOFF = oldCYOFF = oldCWIDE = oldCHIGH = 0; oldeWIDE = eWIDE; oldeHIGH = eHIGH; fullname = NULL; killpage = 0; WaitCursor(); SetISTR(ISTR_INFO,""); SetISTR(ISTR_WARNING,""); /* if we're not loading next or prev page in a multi-page doc, kill off page files */ if (strlen(pageBaseName) && filenum!=OP_PAGEDN && filenum!=OP_PAGEUP) killpage = 1; if (strlen(pageBaseName) && (filenum==OP_PAGEDN || filenum==OP_PAGEUP)) { if (filenum==OP_PAGEUP && curPage>0) curPage--; else if (filenum==OP_PAGEDN && curPage<numPages-1) curPage++; else { XBell(theDisp, 0); /* hit either end */ SetCursors(-1); return 0; } sprintf(filename, "%s%d", pageBaseName, curPage+1); fullname = filename; goto HAVE_FILENAME; } if (filenum == DFLTPIC) { filename[0] = '\0'; basefname[0] = '\0'; fullfname[0] = '\0'; fullname = ""; curname = -1; /* ??? */ LoadDfltPic(&pinfo); if (killpage) { /* kill old page files, if any */ KillPageFiles(pageBaseName, numPages); pageBaseName[0] = '\0'; numPages = 1; curPage = 0; } goto GOTIMAGE; } else if (filenum == GRABBED) { filename[0] = '\0'; basefname[0] = '\0'; fullfname[0] = '\0'; fullname = ""; i = LoadGrab(&pinfo); if (!i) goto FAILED; /* shouldn't happen */ if (killpage) { /* kill old page files, if any */ KillPageFiles(pageBaseName, numPages); pageBaseName[0] = '\0'; numPages = 1; curPage = 0; } goto GOTIMAGE; } else if (filenum == PADDED) { /* need fullfname (used for window/icon name), basefname(compute from fullfname) */ i = LoadPad(&pinfo, fullfname); if (!i) goto FAILED; /* shouldn't happen */ fullname = fullfname; strcpy(filename, fullfname); if (strlen(BaseName(fullfname)) > NAME_MAX) goto FAILED; strcpy(basefname, BaseName(fullfname)); if (killpage) { /* kill old page files, if any */ KillPageFiles(pageBaseName, numPages); pageBaseName[0] = '\0'; numPages = 1; curPage = 0; } goto GOTIMAGE; } if (filenum == POLLED) { frompoll = 1; oldpWIDE = pWIDE; oldpHIGH = pHIGH; wascropped = (cWIDE!=pWIDE || cHIGH!=pHIGH); oldCXOFF = cXOFF; oldCYOFF = cYOFF; oldCWIDE = cWIDE; oldCHIGH = cHIGH; filenum = curname; } if (filenum == RELOAD) { fromint = 1; filenum = nList.selected; } if (filenum != LOADPIC) { if (filenum >= nList.nstr || filenum < 0) goto FAILED; curname = filenum; nList.selected = curname; ScrollToCurrent(&nList); /* have scrl/list show current */ XFlush(theDisp); /* update NOW */ } /* set up fullname and basefname */ if (filenum == LOADPIC) { fullname = GetDirFullName(); if (ISPIPE(fullname[0])) { /* read from a pipe. */ strcpy(filename, fullname); if (readpipe(fullname, filename)) goto FAILED; frompipe = 1; } } #ifdef AUTO_EXPAND else { fullname = (char *) malloc(MAXPATHLEN+2); strcpy(fullname, namelist[filenum]); // 1 of 2 places fullname != const freename = 1; } tmp = (char *) rindex(fullname, '/'); if (tmp) { *tmp = '\0'; // 2 of 2 places fullname != const Mkvdir(fullname); *tmp = '/'; } Dirtovd(fullname); #else else fullname = namelist[filenum]; #endif strcpy(fullfname, fullname); if (strlen(BaseName(fullfname)) > NAME_MAX) goto FAILED; strcpy(basefname, BaseName(fullname)); /* chop off trailing ".Z", ".z", or ".gz" from displayed basefname, if any */ if (strlen(basefname)>2 && strcmp(basefname+strlen(basefname)-2,".Z")==0) basefname[strlen(basefname)-2]='\0'; else { #ifdef GUNZIP if (strlen(basefname)>2 && strcmp(basefname+strlen(basefname)-2,".z")==0) basefname[strlen(basefname)-2]='\0'; else if (strlen(basefname)>3 && strcmp(basefname+strlen(basefname)-3,".gz")==0) basefname[strlen(basefname)-3]='\0'; #endif #ifdef BUNZIP2 if (strlen(basefname)>4 && strcmp(basefname+strlen(basefname)-4,".bz2")==0) basefname[strlen(basefname)-4]='\0'; #endif } if (filenum == LOADPIC && ISPIPE(fullname[0])) { /* if we're reading from a pipe, 'filename' will have the /tmp/xvXXXXXX filename, and we can skip a lot of stuff: (such as prepending 'initdir' to relative paths, dealing with reading from stdin, etc. */ /* at this point, fullname = "! do some commands", filename = "/tmp/xv123456", and basefname= "xv123456" */ } else { /* NOT reading from a PIPE */ /* if fullname doesn't start with a '/' (ie, it's a relative path), (and it's not LOADPIC and it's not the special case '<stdin>') then we need to prepend a directory name to it: prepend 'initdir', if we have a searchdir (ie, we have multiple places to look), see if such a file exists (via fopen()), if it does, we're done. if it doesn't, and we have a searchdir, try prepending searchdir and see if file exists. if it does, we're done. if it doesn't, remove all prepended directories, and fall through to error code below. */ if (filenum!=LOADPIC && fullname[0]!='/' && strcmp(fullname,STDINSTR)!=0) { char *tmp1; /* stick 'initdir ' onto front of filename */ #ifndef VMS tmp1 = (char *) malloc(strlen(fullname) + strlen(initdir) + 2); if (!tmp1) FatalError("malloc 'filename' failed"); sprintf(tmp1,"%s/%s", initdir, fullname); #else /* it is VMS */ tmp1 = (char *) malloc(strlen(fullname) + 2); if (!tmp1) FatalError("malloc 'filename' failed"); sprintf(tmp1,"%s", fullname); #endif if (!strlen(searchdir)) { /* no searchdir, don't check */ fullname = tmp1; freename = 1; } else { /* see if said file exists */ FILE *fp; fp = fopen(tmp1, "r"); if (fp) { /* initpath/fullname exists */ fclose(fp); fullname = tmp1; freename = 1; } else { /* doesn't: try searchdir */ free(tmp1); #ifndef VMS tmp1 = (char *) malloc(strlen(fullname) + strlen(searchdir) + 2); if (!tmp1) FatalError("malloc 'filename' failed"); sprintf(tmp1,"%s/%s", searchdir, fullname); #else /* it is VMS */ tmp1 = (char *) malloc(strlen(fullname) + 2); if (!tmp1) FatalError("malloc 'filename' failed"); sprintf(tmp1,"%s", fullname); #endif fp = fopen(tmp1, "r"); if (fp) { /* searchpath/fullname exists */ fclose(fp); fullname = tmp1; freename = 1; } else free(tmp1); /* doesn't exist either... */ } } } strcpy(filename, fullname); /* if the file is STDIN, write it out to a temp file */ if (strcmp(filename,STDINSTR)==0) { FILE *fp = NULL; #ifndef USE_MKSTEMP int tmpfd; #endif #ifndef VMS sprintf(filename,"%s/xvXXXXXX",tmpdir); #else /* it is VMS */ sprintf(filename, "[]xvXXXXXX"); #endif #ifdef USE_MKSTEMP fp = fdopen(mkstemp(filename), "w"); #else mktemp(filename); tmpfd = open(filename,O_WRONLY|O_CREAT|O_EXCL,S_IRWUSR); if (tmpfd < 0) FatalError("openPic(): can't create temporary file"); fp = fdopen(tmpfd,"w"); #endif if (!fp) FatalError("openPic(): can't write temporary file"); clearerr(stdin); while ( (i=getchar()) != EOF) putc(i,fp); fclose(fp); #ifndef USE_MKSTEMP close(tmpfd); #endif /* and remove it from list, since we can never reload from stdin */ if (strcmp(namelist[0], STDINSTR)==0) deleteFromList(0); } } HAVE_FILENAME: /******* AT THIS POINT 'filename' is the name of an actual data file (no pipes or stdin, though it could be compressed) to be loaded */ filetype = ReadFileType(filename); #ifdef HAVE_MGCSFX if (mgcsfx && filetype == RFT_UNKNOWN){ /* force use MgcSfx */ if(getInputCom() != 0) filetype = RFT_MGCSFX; } #endif /* if it's a compressed file, uncompress it: */ if ((filetype == RFT_COMPRESS) || (filetype == RFT_BZIP2)) { char tmpname[128]; if ( #ifndef VMS UncompressFile(filename, tmpname, filetype) #else UncompressFile(basefname, tmpname, filetype) #endif ) { filetype = ReadFileType(tmpname); /* and try again */ /* if we made a /tmp file (from stdin, etc.) won't need it any more */ if (strcmp(fullname,filename)!=0) unlink(filename); strcpy(filename, tmpname); } else filetype = RFT_ERROR; WaitCursor(); } #ifdef MACBINARY if (handlemacb && macb_file == True) { char tmpname[128]; if (RemoveMacbinary(filename, tmpname)) { if (strcmp(fullname,filename)!=0) unlink(filename); strcpy(origname, filename); strcpy(filename, tmpname); } else filetype = RFT_ERROR; WaitCursor(); } #endif #ifdef HAVE_MGCSFX_AUTO if (filetype == RFT_MGCSFX) { char tmpname[128], tmp[256]; char *icom; if ((icom = mgcsfx_auto_input_com(filename)) != NULL) { sprintf(tmpname, "%s/xvmsautoXXXXXX", tmpdir); #ifdef USE_MKSTEMP close(mkstemp(tmpname)); #else mktemp(tmpname); #endif SetISTR(ISTR_INFO, "Converting to known format by MgcSfx auto..."); sprintf(tmp,"%s >%s", icom, tmpname); } else goto ms_auto_no; #ifndef VMS if (system(tmp)) #else if (!system(tmp)) #endif { SetISTR(ISTR_INFO, "Unable to convert '%s' by MgcSfx auto.", BaseName(filename)); Warning(); filetype = RFT_ERROR; goto ms_auto_no; } filetype = ReadFileType(tmpname); if (strcmp(fullname,filename)!=0) unlink(filename); strcpy(filename, tmpname); } ms_auto_no: #endif /* HAVE_MGCSFX_AUTO */ if (filetype == RFT_ERROR) { char foostr[512]; sprintf(foostr,"Can't open file '%s'\n\n %s.",filename, ERRSTR(errno)); if (!polling) ErrPopUp(foostr, "\nBummer!"); goto FAILED; /* couldn't get magic#, screw it! */ } if (filetype == RFT_UNKNOWN) { /* view as a text/hex file */ #ifdef MACBINARY if (origname[0]) i = TextView(origname); else #endif i = TextView(filename); SetISTR(ISTR_INFO,"'%s' not in a recognized format.", basefname); /* Warning(); */ if (i) goto SHOWN_AS_TEXT; else goto FAILED; } if (filetype < RFT_ERROR) { SetISTR(ISTR_INFO,"'%s' not in a readable format.", basefname); Warning(); goto FAILED; } /****** AT THIS POINT: the filetype is a known, readable format */ /* kill old page files, if any */ if (killpage) { KillPageFiles(pageBaseName, numPages); pageBaseName[0] = '\0'; numPages = 1; curPage = 0; } SetISTR(ISTR_INFO,"Loading..."); i = ReadPicFile(filename, filetype, &pinfo, 0); if (filetype == RFT_XBM && (!i || pinfo.w==0 || pinfo.h==0)) { /* probably just a '.h' file or something... */ SetISTR(ISTR_INFO," "); i = TextView(filename); if (i) goto SHOWN_AS_TEXT; else goto FAILED; } if (!i) { SetISTR(ISTR_INFO,"Couldn't load file '%s'.",filename); Warning(); goto FAILED; } WaitCursor(); if (pinfo.w==0 || pinfo.h==0) { /* shouldn't happen, but let's be safe */ SetISTR(ISTR_INFO,"Image size '0x0' not allowed."); Warning(); if (pinfo.pic) free(pinfo.pic); pinfo.pic = (byte *) NULL; if (pinfo.comment) free(pinfo.comment); pinfo.comment = (char *) NULL; goto FAILED; } /**************/ /* SUCCESS!!! */ /**************/ GOTIMAGE: /* successfully read this picture. No failures from here on out (well, once the pic has been converted if we're locked in a mode) */ state824 = 0; /* if we're locked into a mode, do appropriate conversion */ if (conv24MB.flags[CONV24_LOCK]) { /* locked */ if (pinfo.type==PIC24 && picType==PIC8) { /* 24 -> 8 bit */ byte *pic8; pic8 = Conv24to8(pinfo.pic, pinfo.w, pinfo.h, ncols, pinfo.r, pinfo.g, pinfo.b); free(pinfo.pic); pinfo.pic = pic8; pinfo.type = PIC8; state824 = 1; } else if (pinfo.type!=PIC24 && picType==PIC24) { /* 8 -> 24 bit */ byte *pic24; pic24 = Conv8to24(pinfo.pic, pinfo.w, pinfo.h, pinfo.r, pinfo.g, pinfo.b); free(pinfo.pic); pinfo.pic = pic24; pinfo.type = PIC24; } } else { /* not locked. switch 8/24 mode */ picType = pinfo.type; Set824Menus(picType); } if (!pinfo.pic) { /* must've failed in the 8-24 or 24-8 conversion */ SetISTR(ISTR_INFO,"Couldn't do %s conversion.", (picType==PIC24) ? "8->24" : "24->8"); if (pinfo.comment) free(pinfo.comment); pinfo.comment = (char *) NULL; Warning(); goto FAILED; } /* ABSOLUTELY no failures from here on out... */ if (strlen(pinfo.pagebname)) { strcpy(pageBaseName, pinfo.pagebname); numPages = pinfo.numpages; curPage = 0; } ignoreConfigs = 1; if (mainW && !useroot) { /* avoid generating excess configure events while we resize the window */ XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask | StructureNotifyMask | ButtonPressMask | KeyReleaseMask | EnterWindowMask | LeaveWindowMask); XFlush(theDisp); } /* kill off OLD picture, now that we've succesfully loaded a new one */ KillOldPics(); SetInfoMode(INF_STR); /* get info out of the PICINFO struct */ pic = pinfo.pic; pWIDE = pinfo.w; pHIGH = pinfo.h; if (pinfo.frmType >=0) SetDirSaveMode(F_FORMAT, pinfo.frmType); if (pinfo.colType >=0) SetDirSaveMode(F_COLORS, pinfo.colType); SetISTR(ISTR_FORMAT, pinfo.fullInfo); strcpy(formatStr, pinfo.shrtInfo); picComments = pinfo.comment; ChangeCommentText(); picExifInfo = pinfo.exifInfo; picExifInfoSize = pinfo.exifInfoSize; for (i=0; i<256; i++) { rMap[i] = pinfo.r[i]; gMap[i] = pinfo.g[i]; bMap[i] = pinfo.b[i]; } AlgInit(); /* stick this file in the 'ctrlW' name list */ if (filenum == LOADPIC && !frompipe) StickInCtrlList(1); if (polling && !frompoll) InitPoll(); /* turn off 'frompoll' if the pic has changed size */ if (frompoll && (pWIDE != oldpWIDE || pHIGH != oldpHIGH)) frompoll = 0; if (!browseCB.val && filenum == LOADPIC) DirBox(0); /* close the DirBox */ /* if we read a /tmp file, delete it. won't be needing it any more */ if (fullname && strcmp(fullname,filename)!=0) unlink(filename); SetISTR(ISTR_INFO, "%s", formatStr); SetInfoMode(INF_PART); if (filenum==DFLTPIC || filenum==GRABBED || frompipe) SetISTR(ISTR_FILENAME, "<none>"); else if (numPages > 1) SetISTR(ISTR_FILENAME, "%s Page %d of %d", basefname, curPage+1, numPages); else SetISTR(ISTR_FILENAME, "%s", basefname); SetISTR(ISTR_RES,"%d x %d",pWIDE,pHIGH); SetISTR(ISTR_COLOR, ""); SetISTR(ISTR_COLOR2,""); /* adjust button in/activity */ if (HaveSelection()) EnableSelection(0); SetSelectionString(); BTSetActive(&but[BCROP], 0); BTSetActive(&but[BUNCROP], 0); BTSetActive(&but[BCUT], 0); BTSetActive(&but[BCOPY], 0); BTSetActive(&but[BCLEAR], 0); ActivePrevNext(); /* handle various 'auto-whatever' command line options Note that if 'frompoll' is set, things that have to do with setting the expansion factor are skipped, as we'll want it to display in the (already-existing) window at the same size */ if (frompoll) { cpic = pic; cWIDE = pWIDE; cHIGH = pHIGH; cXOFF = cYOFF = 0; FreeEpic(); if (wascropped) DoCrop(oldCXOFF, oldCYOFF, oldCWIDE, oldCHIGH); FreeEpic(); eWIDE = oldeWIDE; eHIGH = oldeHIGH; SetCropString(); } else { int w,h,aspWIDE,aspHIGH,oldemode; oldemode = epicMode; epicMode = EM_RAW; /* be in raw mode for all intermediate conversions */ cpic = pic; cWIDE = pWIDE; cHIGH = pHIGH; cXOFF = cYOFF = 0; epic = cpic; eWIDE = cWIDE; eHIGH = cHIGH; SetCropString(); /*****************************************/ /* handle aspect options: -aspect, -4x3 */ /*****************************************/ if (normaspect != 1.0) { /* -aspect */ FixAspect(1, &w, &h); eWIDE = w; eHIGH = h; } if (auto4x3) { w = eWIDE; h = (w*3) / 4; eWIDE = w; eHIGH = h; } if (eWIDE != cWIDE || eHIGH != cHIGH) epic = (byte *) NULL; /**************************************/ /* handle cropping (-acrop and -crop) */ /**************************************/ if (autocrop) DoAutoCrop(); if (acrop) DoCrop(acropX, acropY, acropW, acropH); if (eWIDE != cWIDE || eHIGH != cHIGH) epic = (byte *) NULL; /********************************/ /* handle rotation and flipping */ /********************************/ if (autorotate) { /* figure out optimal rotation. (ie, instead of +270, do -90) */ if (autorotate == 270) autorotate = -90; else if (autorotate == -270) autorotate = 90; i = autorotate; while (i) { if (i < 0) { /* rotate CW */ DoRotate(0); i += 90; } else { /* rotate CCW */ DoRotate(1); i -= 90; } } } if (autohflip) Flip(0); /* horizontal flip */ if (autovflip) Flip(1); /* vertical flip */ /********************************************/ /* handle expansion options: */ /* -expand, -max, -maxpect, -fixed, -geom */ /********************************************/ /* at this point, treat whatever eWIDE,eHIGH is as 1x1 expansion, (due to earlier aspect-ratio option handling). Note that all that goes on here is that eWIDE/eHIGH are modified. No images are generated. */ aspWIDE = eWIDE; aspHIGH = eHIGH; /* aspect-corrected eWIDE,eHIGH */ if (hexpand < 0.0) eWIDE=(int)(aspWIDE / -hexpand); /* neg: reciprocal */ else eWIDE=(int)(aspWIDE * hexpand); if (vexpand < 0.0) eHIGH=(int)(aspHIGH / -vexpand); /* neg: reciprocal */ else eHIGH=(int)(aspHIGH * vexpand); if (maingeom) { /* deal with geometry spec. Note, they shouldn't have given us *both* an expansion factor and a geomsize. The geomsize wins out */ int i,x,y,gewide,gehigh; u_int w,h; gewide = eWIDE; gehigh = eHIGH; i = XParseGeometry(maingeom,&x,&y,&w,&h); if (i&WidthValue) gewide = (int) w; if (i&HeightValue) gehigh = (int) h; /* handle case where the pinheads only specified width *or * height */ if (( i&WidthValue && ~i&HeightValue) || (~i&WidthValue && i&HeightValue)) { if (i&WidthValue) { gehigh = (aspHIGH * gewide) / pWIDE; } else { gewide = (aspWIDE * gehigh) / pHIGH; } } /* specified a 'maximum size, but please keep your aspect ratio */ if (fixedaspect && i&WidthValue && i&HeightValue) { if (aspWIDE > gewide || aspHIGH > gehigh) { /* shrink aspWIDE,HIGH accordingly... */ double r,wr,hr; wr = ((double) aspWIDE) / gewide; hr = ((double) aspHIGH) / gehigh; r = (wr>hr) ? wr : hr; /* r is the max(wr,hr) */ aspWIDE = (int) ((aspWIDE / r) + 0.5); aspHIGH = (int) ((aspHIGH / r) + 0.5); } /* image is now definitely no larger than gewide,gehigh */ /* should now expand it so that one axis is of specified size */ if (aspWIDE != gewide && aspHIGH != gehigh) { /* is smaller */ /* grow aspWIDE,HIGH accordingly... */ double r,wr,hr; wr = ((double) aspWIDE) / gewide; hr = ((double) aspHIGH) / gehigh; r = (wr>hr) ? wr : hr; /* r is the max(wr,hr) */ aspWIDE = (int) ((aspWIDE / r) + 0.5); aspHIGH = (int) ((aspHIGH / r) + 0.5); } eWIDE = aspWIDE; eHIGH = aspHIGH; } else { eWIDE = gewide; eHIGH = gehigh; } } if (automax) { /* -max and -maxpect */ eWIDE = dispWIDE; eHIGH = dispHIGH; if (fixedaspect) FixAspect(0,&eWIDE,&eHIGH); } /* now, just make sure that eWIDE/eHIGH aren't too big... */ /* shrink eWIDE,eHIGH preserving aspect ratio, if so... */ if (eWIDE>maxWIDE || eHIGH>maxHIGH) { /* the numbers here can get big. use floats */ double r,wr,hr; wr = ((double) eWIDE) / maxWIDE; hr = ((double) eHIGH) / maxHIGH; r = (wr>hr) ? wr : hr; /* r is the max(wr,hr) */ eWIDE = (int) ((eWIDE / r) + 0.5); eHIGH = (int) ((eHIGH / r) + 0.5); } if (eWIDE < 1) eWIDE = 1; /* just to be safe... */ if (eHIGH < 1) eHIGH = 1; /* if we're using an integer tiled root mode, truncate eWIDE/eHIGH to be an integer divisor of the display size */ if (useroot && (rootMode == RM_TILE || rootMode == RM_IMIRROR)) { /* make picture size a divisor of the rootW size. round down */ i = (dispWIDE + eWIDE-1) / eWIDE; eWIDE = (dispWIDE + i-1) / i; i = (dispHIGH + eHIGH-1) / eHIGH; eHIGH = (dispHIGH + i-1) / i; } if (eWIDE != cWIDE || eHIGH != cHIGH) epic = (byte *) NULL; /********************************************/ /* handle epic generation options: */ /* -raw, -dith, -smooth */ /********************************************/ if (autodither && ncols>0) epicMode = EM_DITH; /* if in CM_STDCMAP mode, and *not* in '-wait 0', then autodither */ if (colorMapMode == CM_STDCMAP && waitsec != 0.0) epicMode = EM_DITH; /* if -smooth or image has been shrunk to fit screen */ if (autosmooth || (pWIDE >maxWIDE || pHIGH>maxHIGH) || (cWIDE != eWIDE || cHIGH != eHIGH)) epicMode = EM_SMOOTH; if (autoraw) epicMode = EM_RAW; /* 'dithering' makes no sense in 24-bit mode */ if (picType == PIC24 && epicMode == EM_DITH) epicMode = EM_RAW; SetEpicMode(); } /* end of !frompoll */ /* at this point eWIDE,eHIGH are correct, but a proper epic (particularly if in DITH or SMOOTH mode) doesn't exist yet. Will be made once the colors have been picked. */ /* clear old image (window/root) before we start changing colors... */ if (CMAPVIS(theVisual) && clearonload && picType == PIC8 && colorMapMode != CM_STDCMAP) { if (mainW && !useroot) { XClearArea(theDisp, mainW, 0,0, (u_int)oldeWIDE, (u_int)oldeHIGH, True); XFlush(theDisp); } if (useroot) { mainW = vrootW; ClearRoot(); } } if (useroot) mainW = vrootW; if (eWIDE != cWIDE || eHIGH != cHIGH) epic = (byte *) NULL; NewPicGetColors(autonorm, autohisteq); GenerateEpic(eWIDE, eHIGH); /* want to dither *after* color allocs */ CreateXImage(); WaitCursor(); HandleDispMode(); /* create root pic, or mainW, depending... */ if (LocalCmap) { XSetWindowAttributes xswa; xswa.colormap = LocalCmap; if (!ninstall) XInstallColormap(theDisp,LocalCmap); XChangeWindowAttributes(theDisp,mainW,CWColormap,&xswa); if (cmapInGam) XChangeWindowAttributes(theDisp,gamW,CWColormap,&xswa); } tmp = GetISTR(ISTR_COLOR); SetISTR(ISTR_INFO,"%s %s %s", formatStr, (picType==PIC8) ? "8-bit mode." : "24-bit mode.", tmp); SetInfoMode(INF_FULL); if (freename) free(fullname); SetCursors(-1); if (dirUp!=BLOAD) { /* put current filename into the 'save-as' filename */ if (strcmp(filename,STDINSTR)==0) SetDirFName("stdin"); else if (frompipe || filenum == LOADPIC || filenum == GRABBED || filenum == DFLTPIC || filenum == PADDED) {} /* leave it alone */ else SetDirFName(basefname); } /* force a redraw of the whole window, as I can't quite trust Config's to generate the correct exposes (particularly with 'BitGravity' turned on */ /*Brian T. Schellenberger: fix for X 4.2 refresh problem*/ if (mainW && !useroot) { XSync(theDisp, False); GenExpose(mainW, 0, 0, (u_int) eWIDE, (u_int) eHIGH); } return 1; FAILED: SetCursors(-1); KillPageFiles(pinfo.pagebname, pinfo.numpages); if (fullname && strcmp(fullname,filename)!=0) unlink(filename); /* kill /tmp file */ if (freename) free(fullname); if (!fromint && !polling && filenum>=0 && filenum<nList.nstr) deleteFromList(filenum); if (polling) sleep(1); return 0; SHOWN_AS_TEXT: /* file wasn't in recognized format... */ SetCursors(-1); if (strcmp(fullname,filename)!=0) unlink(filename); /* kill /tmp file */ if (freename) free(fullname); ActivePrevNext(); return 1; /* we've displayed the file 'ok' */ } extern byte ZXheader[128]; /* [JCE] Spectrum screen magic number is defined in xvzx.c */ /********************************/ int ReadFileType(fname) char *fname; { /* opens fname (which *better* be an actual file by this point!) and reads the first couple o' bytes. Figures out what the file's likely to be, and returns the appropriate RFT_*** code */ FILE *fp; byte magicno[30]; /* first 30 bytes of file */ int rv=RFT_UNKNOWN, n; #ifdef MACBINARY int macbin_alrchk = False; #endif if (!fname) return RFT_ERROR; /* shouldn't happen */ fp = xv_fopen(fname, "r"); if (!fp) return RFT_ERROR; if (strlen(fname) > 4 && strcasecmp(fname+strlen(fname)-5, ".wbmp")==0) rv = RFT_WBMP; n = fread(magicno, (size_t) 1, sizeof(magicno), fp); fclose(fp); if (n<=0) return RFT_UNKNOWN; /* it is just barely possible that a few files could legitimately be as small as 30 bytes (e.g., binary P{B,G,P}M format), so zero out rest of "magic number" buffer and don't quit immediately if we read something small but not empty */ if (n<30) memset(magicno+n, 0, sizeof(magicno)-n); #ifdef MACBINARY macb_file = False; while (1) { #endif #ifdef HAVE_MGCSFX if (is_mgcsfx(fname, magicno, 30) != 0) rv = RFT_MGCSFX; else #endif if (strncmp((char *) magicno,"GIF87a", (size_t) 6)==0 || strncmp((char *) magicno,"GIF89a", (size_t) 6)==0) rv = RFT_GIF; else if (strncmp((char *) magicno,"VIEW", (size_t) 4)==0 || strncmp((char *) magicno,"WEIV", (size_t) 4)==0) rv = RFT_PM; #ifdef HAVE_PIC2 else if (magicno[0]=='P' && magicno[1]=='2' && magicno[2]=='D' && magicno[3]=='T') rv = RFT_PIC2; #endif else if (magicno[0] == 'P' && magicno[1]>='1' && (magicno[1]<='6' || magicno[1]=='8')) rv = RFT_PBM; /* note: have to check XPM before XBM, as first 2 chars are the same */ else if (strncmp((char *) magicno, "/* XPM */", (size_t) 9)==0) rv = RFT_XPM; else if (strncmp((char *) magicno,"#define", (size_t) 7)==0 || (magicno[0] == '/' && magicno[1] == '*')) rv = RFT_XBM; else if (magicno[0]==0x59 && (magicno[1]&0x7f)==0x26 && magicno[2]==0x6a && (magicno[3]&0x7f)==0x15) rv = RFT_SUNRAS; else if (magicno[0] == 'B' && magicno[1] == 'M') rv = RFT_BMP; else if (magicno[0]==0x52 && magicno[1]==0xcc) rv = RFT_UTAHRLE; else if ((magicno[0]==0x01 && magicno[1]==0xda) || (magicno[0]==0xda && magicno[1]==0x01)) rv = RFT_IRIS; else if (magicno[0]==0x1f && magicno[1]==0x9d) rv = RFT_COMPRESS; #ifdef GUNZIP else if (magicno[0]==0x1f && magicno[1]==0x8b) rv = RFT_COMPRESS; #endif #ifdef BUNZIP2 else if (magicno[0]==0x42 && magicno[1]==0x5a) rv = RFT_BZIP2; #endif else if (magicno[0]==0x0a && magicno[1] <= 5) rv = RFT_PCX; else if (strncmp((char *) magicno, "FORM", (size_t) 4)==0 && strncmp((char *) magicno+8, "ILBM", (size_t) 4)==0) rv = RFT_IFF; else if (magicno[0]==0 && magicno[1]==0 && magicno[2]==2 && magicno[3]==0 && magicno[4]==0 && magicno[5]==0 && magicno[6]==0 && magicno[7]==0) rv = RFT_TARGA; else if (magicno[4]==0x00 && magicno[5]==0x00 && magicno[6]==0x00 && magicno[7]==0x07) rv = RFT_XWD; else if (strncmp((char *) magicno,"SIMPLE ", (size_t) 8)==0 && magicno[29] == 'T') rv = RFT_FITS; /* [JCE] Spectrum screen */ else if (memcmp(magicno, ZXheader, (size_t) 18)==0) rv = RFT_ZX; #ifdef HAVE_JPEG else if (magicno[0]==0xff && magicno[1]==0xd8 && magicno[2]==0xff) rv = RFT_JFIF; #endif #ifdef HAVE_JP2K else if (magicno[0]==0xff && magicno[1]==0x4f && magicno[2]==0xff && magicno[3]==0x51) rv = RFT_JPC; // else if (memcmp(magicno, jp2k_magic, sizeof(jp2k_magic))==0) rv = RFT_JP2; else if (((int *)magicno)[0]==0x0000000c && ((int *)magicno)[1]==0x6a502020 && ((int *)magicno)[2]==0x0d0a870a) rv = RFT_JP2; #endif #ifdef HAVE_TIFF else if ((magicno[0]=='M' && magicno[1]=='M') || (magicno[0]=='I' && magicno[1]=='I')) rv = RFT_TIFF; #endif #ifdef HAVE_PNG else if (magicno[0]==0x89 && magicno[1]=='P' && magicno[2]=='N' && magicno[3]=='G') rv = RFT_PNG; #endif #ifdef HAVE_WEBP else if (magicno[0]==0x52 && magicno[1]==0x49 && magicno[2]==0x46 && magicno[3]==0x46 && magicno[8]==0x57 && magicno[9]==0x45 && magicno[10]==0x42 && magicno[11]==0x50 && magicno[12]==0x56 && magicno[13]==0x50 && magicno[14]==0x38) rv = RFT_WEBP; #endif #ifdef HAVE_PDS else if (strncmp((char *) magicno, "NJPL1I00", (size_t) 8)==0 || strncmp((char *) magicno+2,"NJPL1I", (size_t) 6)==0 || strncmp((char *) magicno, "CCSD3ZF", (size_t) 7)==0 || strncmp((char *) magicno+2,"CCSD3Z", (size_t) 6)==0 || strncmp((char *) magicno, "LBLSIZE=", (size_t) 8)==0) rv = RFT_PDSVICAR; #endif #ifdef GS_PATH /* Ghostscript handles both PostScript and PDF */ else if (strncmp((char *) magicno, "%!", (size_t) 2)==0 || strncmp((char *) magicno, "\004%!", (size_t) 3)==0 || strncmp((char *) magicno, "%PDF", (size_t) 4)==0) rv = RFT_PS; #endif #ifdef HAVE_G3 else if ((magicno[0]== 1 && magicno[1]== 1 && magicno[2]== 77 && magicno[3]==154 && magicno[4]==128 && magicno[5]== 0 && magicno[6]== 1 && magicno[7]== 77 || magicno[6]== 1 && magicno[7]== 77) || highresfax || lowresfax || !strcmp(fname+strlen(fname)-3,".g3")) { if (!lowresfax) highresfax = 1; rv = RFT_G3; } #endif #ifdef HAVE_MAG else if (strncmp((char *) magicno,"MAKI02 ", (size_t) 8)==0) rv = RFT_MAG; #endif #ifdef HAVE_MAKI else if (strncmp((char *) magicno,"MAKI01A ", (size_t) 8)==0 || strncmp((char *) magicno,"MAKI01B ", (size_t) 8)==0) rv = RFT_MAKI; #endif #ifdef HAVE_PIC else if (magicno[0]=='P' && magicno[1]=='I'&&magicno[2]=='C') rv = RFT_PIC; #endif #ifdef HAVE_PI else if (magicno[0]=='P' && magicno[1]=='i') rv = RFT_PI; #endif #ifdef HAVE_HIPS else if (strstr((char *) magicno, "./digest")) rv = RFT_HIPS; #endif #ifdef HAVE_PCD else if (magicno[0]==0xff && magicno[1]==0xff && magicno[2]==0xff && magicno[3]==0xff) rv = RFT_PCD; #endif #ifdef MACBINARY /* Now we try to handle MacBinary files, but the method is VERY dirty... */ if (macbin_alrchk == True) { macb_file = True; break; } if (rv != RFT_UNKNOWN) break; /* Skip MACBSIZE and recheck */ macbin_alrchk = True; fp = xv_fopen(fname, "r"); if (!fp) return RFT_ERROR; fseek(fp, MACBSIZE, SEEK_SET); n = fread(magicno, (size_t) 1, (size_t) 30, fp); fclose(fp); if (n<30) return RFT_UNKNOWN; /* files less than 30 bytes long... */ } #endif return rv; } /********************************/ int ReadPicFile(fname, ftype, pinfo, quick) char *fname; int ftype, quick; PICINFO *pinfo; { /* if quick is set, we're being called to generate icons, or something like that. We should load the image as quickly as possible. Previously, this affected only the LoadPS routine, which, if quick is set, only generates the page file for the first page of the document. Now it also affects PCD, which loads only a thumbnail. */ int rv = 0; /* by default, most formats aren't multi-page */ pinfo->numpages = 1; pinfo->pagebname[0] = '\0'; switch (ftype) { case RFT_GIF: rv = LoadGIF (fname, pinfo); break; case RFT_PM: rv = LoadPM (fname, pinfo); break; #ifdef HAVE_MGCSFX case RFT_PBM: rv = LoadPBM (fname, pinfo, -1); break; #else case RFT_PBM: rv = LoadPBM (fname, pinfo); break; #endif case RFT_XBM: rv = LoadXBM (fname, pinfo); break; case RFT_SUNRAS: rv = LoadSunRas(fname, pinfo); break; case RFT_BMP: rv = LoadBMP (fname, pinfo); break; case RFT_UTAHRLE: rv = LoadRLE (fname, pinfo); break; case RFT_IRIS: rv = LoadIRIS (fname, pinfo); break; case RFT_PCX: rv = LoadPCX (fname, pinfo); break; case RFT_IFF: rv = LoadIFF (fname, pinfo); break; case RFT_TARGA: rv = LoadTarga (fname, pinfo); break; case RFT_XPM: rv = LoadXPM (fname, pinfo); break; case RFT_XWD: rv = LoadXWD (fname, pinfo); break; case RFT_FITS: rv = LoadFITS (fname, pinfo, quick); break; case RFT_ZX: rv = LoadZX (fname, pinfo); break; /* [JCE] */ case RFT_WBMP: rv = LoadWBMP (fname, pinfo); break; #ifdef HAVE_PCD /* if quick is switched on, use the smallest image size; don't ask the user */ case RFT_PCD: rv = LoadPCD (fname, pinfo, quick ? 0 : PcdSize); break; #endif #ifdef HAVE_JPEG case RFT_JFIF: rv = LoadJFIF (fname, pinfo, quick); break; #endif #ifdef HAVE_JP2K case RFT_JPC: rv = LoadJPC (fname, pinfo, quick); break; case RFT_JP2: rv = LoadJP2 (fname, pinfo, quick); break; #endif #ifdef HAVE_G3 case RFT_G3: rv = LoadG3 (fname, pinfo); break; #endif #ifdef HAVE_TIFF case RFT_TIFF: rv = LoadTIFF (fname, pinfo, quick); break; #endif #ifdef HAVE_PNG case RFT_PNG: rv = LoadPNG (fname, pinfo); break; #endif #ifdef HAVE_WEBP case RFT_WEBP: rv = LoadWEBP (fname, pinfo); break; #endif #ifdef HAVE_PDS case RFT_PDSVICAR: rv = LoadPDS (fname, pinfo); break; #endif #ifdef GS_PATH case RFT_PS: rv = LoadPS (fname, pinfo, quick); break; #endif #ifdef HAVE_MAG case RFT_MAG: rv = LoadMAG (fname, pinfo); break; #endif #ifdef HAVE_MAKI case RFT_MAKI: rv = LoadMAKI (fname, pinfo); break; #endif #ifdef HAVE_PIC case RFT_PIC: rv = LoadPIC (fname, pinfo); break; #endif #ifdef HAVE_PI case RFT_PI: rv = LoadPi (fname, pinfo); break; #endif #ifdef HAVE_PIC2 case RFT_PIC2: rv = LoadPIC2 (fname, pinfo, quick); break; #endif #ifdef HAVE_HIPS case RFT_HIPS: rv = LoadHIPS (fname, pinfo); break; #endif #ifdef HAVE_MGCSFX case RFT_MGCSFX: rv = LoadMGCSFX (fname, pinfo); break; #endif } return rv; } /********************************/ int UncompressFile(name, uncompname, filetype) char *name, *uncompname; int filetype; { /* returns '1' on success, with name of uncompressed file in uncompname returns '0' on failure */ char namez[128], *fname, buf[512]; #ifndef USE_MKSTEMP int tmpfd; #endif fname = name; namez[0] = '\0'; #if !defined(VMS) && !defined(GUNZIP) /* see if compressed file name ends with '.Z'. If it *doesn't* we need temporarily rename it so it *does*, uncompress it, and rename *back* to what it was. necessary because uncompress doesn't handle files that don't end with '.Z' */ if (strlen(name) >= (size_t) 2 && strcmp(name + strlen(name)-2,".Z")!=0 && strcmp(name + strlen(name)-2,".z")!=0) { strcpy(namez, name); strcat(namez,".Z"); if (rename(name, namez) < 0) { sprintf(buf, "Error renaming '%s' to '%s': %s", name, namez, ERRSTR(errno)); ErrPopUp(buf, "\nBummer!"); return 0; } fname = namez; } #endif /* not VMS and not GUNZIP */ #ifndef VMS sprintf(uncompname, "%s/xvuXXXXXX", tmpdir); #else strcpy(uncompname, "[]xvuXXXXXX"); #endif #ifdef USE_MKSTEMP close(mkstemp(uncompname)); #else mktemp(uncompname); tmpfd = open(uncompname,O_WRONLY|O_CREAT|O_EXCL,S_IRWUSR); if (tmpfd < 0) FatalError("UncompressFile(): can't create temporary file"); close(tmpfd); #endif /* FIXME: need to replace any ticks in filename (with the * ugly sequence '\"'\"' because backslash won't work inside * single quotes) before calling system(). Maybe one of the * exec() variants would be better... */ #ifndef VMS if (filetype == RFT_COMPRESS) sprintf(buf,"%s -c '%s' > '%s'", UNCOMPRESS, fname, uncompname); # ifdef BUNZIP2 else if (filetype == RFT_BZIP2) sprintf(buf,"%s -c '%s' > '%s'", BUNZIP2, fname, uncompname); # endif #else /* it IS VMS */ # ifdef GUNZIP sprintf(buf,"%s '%s' '%s'", UNCOMPRESS, fname, uncompname); # else sprintf(buf,"%s '%s'", UNCOMPRESS, fname); # endif #endif SetISTR(ISTR_INFO, "Uncompressing '%s'...", BaseName(fname)); #ifndef VMS if (system(buf)) #else if (!system(buf)) #endif { SetISTR(ISTR_INFO, "Unable to uncompress '%s'.", BaseName(fname)); Warning(); return 0; } #ifndef VMS /* if we renamed the file to end with a .Z for the sake of 'uncompress', rename it back to what it once was... */ if (strlen(namez)) { if (rename(namez, name) < 0) { sprintf(buf, "Error renaming '%s' to '%s': %s", namez, name, ERRSTR(errno)); ErrPopUp(buf, "\nBummer!"); } } #else /* sprintf(buf,"Rename %s %s", fname, uncompname); SetISTR(ISTR_INFO,"Renaming '%s'...", fname); if (!system(buf)) { SetISTR(ISTR_INFO,"Unable to rename '%s'.", fname); Warning(); return 0; } */ #endif /* not VMS */ return 1; } #ifdef MACBINARY /********************************/ int RemoveMacbinary(src, dst) char *src, *dst; { char buffer[8192]; /* XXX */ int n, eof; #ifndef USE_MKSTEMP int tmpfd; #endif FILE *sfp, *dfp; sprintf(dst, "%s/xvmXXXXXX", tmpdir); #ifdef USE_MKSTEMP close(mkstemp(dst)); #else mktemp(dst); tmpfd = open(dst,O_WRONLY|O_CREAT|O_EXCL,S_IRWUSR); if (tmpfd < 0) FatalError("RemoveMacbinary(): can't create temporary file"); #endif SetISTR(ISTR_INFO, "Removing MacBinary..."); sfp = xv_fopen(src, "r"); #ifdef USE_MKSTEMP dfp = xv_fopen(dst, "w"); #else dfp = fdopen(tmpfd, "w"); #endif if (!sfp || !dfp) { SetISTR(ISTR_INFO, "Unable to remove a InfoFile header form '%s'.", src); Warning(); return 0; } fseek(sfp, MACBSIZE, SEEK_SET); while ((n = fread(buffer, 1, sizeof(buffer), sfp)) == 8192) /* XXX */ fwrite(buffer, 1, n, dfp); if ((eof = feof(sfp))) fwrite(buffer, 1, n, dfp); fclose(sfp); fflush(dfp); fclose(dfp); #ifndef USE_MKSTEMP close(tmpfd); #endif if (!eof) { SetISTR(ISTR_INFO, "Unable to remove a InfoFile header form '%s'.", src); Warning(); return 0; } return 1; } #endif /********************************/ void KillPageFiles(bname, numpages) char *bname; int numpages; { /* deletes any page files (numbered 1 through numpages) that might exist */ char tmp[128]; int i; if (strlen(bname) == 0) return; /* no page files */ for (i=1; i<=numpages; i++) { sprintf(tmp, "%s%d", bname, i); unlink(tmp); } /* GRR 20070506: basename file doesn't go away, at least on Linux and for * GIF and TIFF images, so explicitly unlink() it, too */ unlink(bname); } /********************************/ void NewPicGetColors(donorm, dohist) int donorm, dohist; { int i; /* some stuff that necessary whenever running an algorithm or installing a new 'pic' (or switching 824 modes) */ numcols = 0; /* gets set by SortColormap: set to 0 for PIC24 images */ for (i=0; i<256; i++) cols[i]=infobg; if (picType == PIC8) { byte trans[256]; SortColormap(pic,pWIDE,pHIGH,&numcols,rMap,gMap,bMap,colAllocOrder,trans); ColorCompress8(trans); } if (picType == PIC8) { /* see if image is a b/w bitmap. If so, use '-black' and '-white' colors */ if (numcols == 2) { if ((rMap[0] == gMap[0] && rMap[0] == bMap[0] && rMap[0] == 255) && (rMap[1] == gMap[1] && rMap[1] == bMap[1] && rMap[1] == 0)) { /* 0=wht, 1=blk */ rMap[0] = (whtRGB>>16)&0xff; gMap[0] = (whtRGB>>8)&0xff; bMap[0] = whtRGB&0xff; rMap[1] = (blkRGB>>16)&0xff; gMap[1] = (blkRGB>>8)&0xff; bMap[1] = blkRGB&0xff; } else if ((rMap[0] == gMap[0] && rMap[0] == bMap[0] && rMap[0] == 0) && (rMap[1] == gMap[1] && rMap[1] == bMap[1] && rMap[1] == 255)) { /*0=blk,1=wht*/ rMap[0] = (blkRGB>>16)&0xff; gMap[0] = (blkRGB>>8)&0xff; bMap[0] = blkRGB&0xff; rMap[1] = (whtRGB>>16)&0xff; gMap[1] = (whtRGB>>8)&0xff; bMap[1]=whtRGB&0xff; } } } if (picType == PIC8) { /* reverse image, if desired */ if (revvideo) { for (i=0; i<numcols; i++) { rMap[i] = 255 - rMap[i]; gMap[i] = 255 - gMap[i]; bMap[i] = 255 - bMap[i]; } } /* save the desired RGB colormap (before dicking with it) */ for (i=0; i<numcols; i++) { rorg[i] = rcmap[i] = rMap[i]; gorg[i] = gcmap[i] = gMap[i]; borg[i] = bcmap[i] = bMap[i]; } } else if (picType == PIC24 && revvideo) { if (pic) InvertPic24(pic, pWIDE, pHIGH); if (cpic && cpic!=pic) InvertPic24(cpic, cWIDE, cHIGH); if (epic && epic!=cpic) InvertPic24(epic, eWIDE, eHIGH); if (egampic && egampic != epic) InvertPic24(egampic, eWIDE, eHIGH); } NewCMap(); if (donorm) DoNorm(); if (dohist) DoHistEq(); GammifyColors(); if (picType == PIC24) ChangeCmapMode(CM_STDCMAP, 0, 1); else ChangeCmapMode(defaultCmapMode, 0, 1); ChangeEC(0); } /***********************************/ static int readpipe(cmd, fname) char *cmd, *fname; { /* cmd is something like: "! bggen 100 0 0" * * runs command (with "> /tmp/xv******" appended). * returns "/tmp/xv******" in fname * returns '0' if everything's cool, '1' on error */ char fullcmd[512], tmpname[64], str[512]; int i; #ifndef USE_MKSTEMP int tmpfd; #endif if (!cmd || (strlen(cmd) < (size_t) 2)) return 1; sprintf(tmpname,"%s/xvXXXXXX", tmpdir); #ifdef USE_MKSTEMP close(mkstemp(tmpname)); #else mktemp(tmpname); tmpfd = open(tmpname,O_WRONLY|O_CREAT|O_EXCL,S_IRWUSR); if (tmpfd < 0) FatalError("openPic(): can't create temporary file"); close(tmpfd); #endif if (tmpname[0] == '\0') { /* mktemp() or mkstemp() blew up */ sprintf(str,"Unable to create temporary filename."); ErrPopUp(str, "\nHow unlikely!"); return 1; } /* build command */ strcpy(fullcmd, cmd+1); /* skip the leading '!' character in cmd */ strcat(fullcmd, " > "); strcat(fullcmd, tmpname); /* execute the command */ sprintf(str, "Doing command: '%s'", fullcmd); OpenAlert(str); i = system(fullcmd); if (i) { sprintf(str, "Unable to complete command:\n %s\n\n exit status: %d", fullcmd, i); CloseAlert(); ErrPopUp(str, "\nThat Sucks!"); unlink(tmpname); /* just in case it was created */ return 1; } CloseAlert(); strcpy(fname, tmpname); return 0; } /****************/ static void openFirstPic() { int i; waitsec = (numnames <= 1)? waitsec_final : waitsec_nonfinal; if (!numnames) { openPic(DFLTPIC); return; } i = 0; while (numnames>0) { if (openPic(0)) return; /* success */ else { if (polling && !i) fprintf(stderr,"%s: POLLING: Waiting for file '%s' \n\tto %s\n", cmd, namelist[0], "be created, or whatever..."); i = 1; } } if (numnames>1) FatalError("couldn't open any pictures"); else Quit(-1); } /****************/ static void openNextPic() { int i; if (curname>=0) i = curname+1; else if (nList.selected >= 0 && nList.selected < numnames) i = nList.selected; else i = 0; while (i<numnames && !openPic(i)); if (i<numnames) return; /* success */ openPic(DFLTPIC); } /****************/ static void openNextQuit() { int i; if (curname>=0) i = curname+1; else if (nList.selected >= 0 && nList.selected < numnames) i = nList.selected; else i = 0; waitsec = (i == numnames-1)? waitsec_final : waitsec_nonfinal; while (i<numnames && !openPic(i)); if (i<numnames) return; /* success */ Quit(0); } /****************/ static void openNextLoop() { int i,j,loop; j = loop = 0; while (1) { if (curname>=0) i = curname+1; else if (nList.selected >= 0 && nList.selected < numnames) i = nList.selected; else i = 0; if (loop) { i = 0; loop = 0; } waitsec = (i == numnames-1)? waitsec_final : waitsec_nonfinal; while (i<numnames && !openPic(i)); if (i<numnames) return; loop = 1; /* back to top of list */ if (j) break; /* we're in a 'failure loop' */ j++; } openPic(DFLTPIC); } /****************/ static void openPrevPic() { int i; if (curname>0) i = curname-1; else if (nList.selected>0 && nList.selected < numnames) i = nList.selected - 1; else i = numnames-1; for ( ; i>=0; i--) { if (openPic(i)) return; /* success */ } openPic(DFLTPIC); } /****************/ static void openNamedPic() { /* if (!openPic(LOADPIC)) openPic(DFLTPIC); */ openPic(LOADPIC); } /****************/ static void mainLoop() { /* search forward until we manage to display a picture, then call EventLoop. EventLoop will eventually return NEXTPIC, PREVPIC, NEXTQUIT, QUIT, or, if >= 0, a filenum to GOTO */ int i; /* if curname<0 (there is no 'current' file), 'Next' means view the selected file (or the 0th file, if no selection either), and 'Prev' means view the one right before the selected file */ /* find first displayable picture, exit if none */ if (!startGrab) openFirstPic(); if (!pic) { /* must've opened a text file... display dflt pic */ if (!startGrab) openPic(DFLTPIC); if (mainW && !useroot) RaiseTextWindows(); } if (useroot && autoquit) Quit(0); while ((i=EventLoop()) != QUIT) { if (i==NEXTPIC) { if ((curname<0 && numnames>0) || (curname<numnames-1)) openNextPic(); } else if (i==PREVPIC) { if (curname>0 || (curname<0 && nList.selected>0)) openPrevPic(); } else if (i==NEXTQUIT) openNextQuit(); else if (i==NEXTLOOP) openNextLoop(); else if (i==LOADPIC) openNamedPic(); else if (i==DELETE) { /* deleted currently-viewed image */ curname = -1; ActivePrevNext(); if (but[BNEXT].active) FakeButtonPress(&but[BNEXT]); else openPic(DFLTPIC); } else if (i==THISNEXT) { /* open current sel, 'next' until success */ int j; j = nList.selected; if (j<0) j = 0; while (j<numnames && !openPic(j)); if (!pic) openPic(DFLTPIC); } else if (i>=0 || i==GRABBED || i==POLLED || i==RELOAD || i==OP_PAGEUP || i==OP_PAGEDN || i==DFLTPIC || i==PADDED) { openPic(i); /* if (!openPic(i)) openPic(DFLTPIC); */ } } } /***********************************/ static void createMainWindow(geom, name) const char *geom, *name; { XSetWindowAttributes xswa; unsigned long xswamask; XWindowAttributes xwa; XWMHints xwmh; XSizeHints hints; XClassHint classh; int i,x,y; unsigned int w,h; static int firstTime = 1; /* * this function mainly deals with parsing the geometry spec correctly. * More trouble than it should be, and probably more trouble than * it has to be, but who can tell these days, what with all those * Widget-usin' Weenies out there... * * Note: eWIDE,eHIGH have the correct, desired window size. Ignore the * w,h fields in the geometry spec, as they've already been dealt with */ x = y = w = h = 1; i = XParseGeometry(geom,&x,&y,&w,&h); hints.flags = 0; if (i&XValue || i&YValue) hints.flags |= USPosition; hints.win_gravity = NorthWestGravity; if (i&XValue && i&XNegative) { hints.win_gravity = NorthEastGravity; x = vrWIDE - (eWIDE + 2 * bwidth) - x; } if (i&YValue && i&YNegative) { hints.win_gravity = (hints.win_gravity == NorthWestGravity) ? SouthWestGravity : SouthEastGravity; y = vrHIGH - (eHIGH + 2 * bwidth) - y; } hints.flags |= PWinGravity; /* keep on screen */ if (x+eWIDE > vrWIDE) x = vrWIDE - eWIDE; if (y+eHIGH > vrHIGH) y = vrHIGH - eHIGH; if (x < 0) x = 0; if (y < 0) y = 0; #define VROOT_TRANS #ifdef VROOT_TRANS if (vrootW != rootW && !(hints.flags & USPosition)) { /* virtual window manager running */ int x1,y1; Window child; XTranslateCoordinates(theDisp, rootW, vrootW, x, y, &x1, &y1, &child); if (DEBUG) fprintf(stderr,"translate: %d,%d -> %d,%d\n", x, y, x1, y1); x = x1; y = y1; } #endif hints.x = x; hints.y = y; hints.width = eWIDE; hints.height = eHIGH; hints.max_width = maxWIDE; hints.max_height = maxHIGH; hints.flags |= PSize | PMaxSize; xswa.bit_gravity = StaticGravity; xswa.background_pixmap = None; xswa.border_pixel = fg; xswa.colormap = theCmap; xswa.backing_store = WhenMapped; /* NOTE: I've turned 'backing-store' off on the image window, as some servers (HP 9000/300 series running X11R4) don't properly deal with things when the image window changes size. It isn't a big performance improvement anyway (for the image window), unless you're on a slow network. In any event, I'm not *turning off* backing store, I'm just not explicitly turning it *on*. If your X server is set up that windows, by default, have backing-store turned on, then the image window will, too */ /* CWBackPixel */ xswamask = CWBackPixmap | CWBorderPixel | CWColormap /* | CWBackingStore */; if (!clearonload) xswamask |= CWBitGravity; if (mainW) { GetWindowPos(&xwa); xwa.width = eWIDE; xwa.height = eHIGH; /* try to keep the damned thing on-screen, if possible */ if (xwa.x + xwa.width > vrWIDE) xwa.x = vrWIDE - xwa.width; if (xwa.y + xwa.height > vrHIGH) xwa.y = vrHIGH - xwa.height; if (xwa.x < 0) xwa.x = 0; if (xwa.y < 0) xwa.y = 0; SetWindowPos(&xwa); hints.flags = PSize | PMaxSize; } else { mainW = XCreateWindow(theDisp,rootW,x,y, (u_int) eWIDE, (u_int) eHIGH, (u_int) bwidth, (int) dispDEEP, InputOutput, theVisual, xswamask, &xswa); if (!mainW) FatalError("can't create window!"); XSetCommand(theDisp, mainW, mainargv, mainargc); if (LocalCmap) { xswa.colormap = LocalCmap; XChangeWindowAttributes(theDisp,mainW,CWColormap,&xswa); } } xwmh.input = True; xwmh.flags = InputHint; xwmh.icon_pixmap = iconPix; xwmh.icon_mask = iconmask; xwmh.flags |= (IconPixmapHint | IconMaskHint); if (startIconic && firstTime) { xwmh.initial_state = IconicState; xwmh.flags |= StateHint; if (icongeom) { int i,x,y; unsigned int w,h; i = XParseGeometry(icongeom, &x, &y, &w, &h); /* ignore w,h */ if (i&XValue && i&YValue) { if (i&XValue && i&XNegative) x = vrWIDE - icon_width - abs(x); if (i&YValue && i&YNegative) y = vrHIGH - icon_height - abs(y); xwmh.icon_x = x; xwmh.icon_y = y; xwmh.flags |= (IconPositionHint); } } } classh.res_name = "xv"; classh.res_class = "XVroot"; XmbSetWMProperties(theDisp, mainW, NULL, NULL, NULL, 0, &hints, &xwmh, &classh); setWinIconNames(name); if (nodecor) { /* turn of image window decorations (in MWM) */ Atom mwm_wm_hints; struct s_mwmhints { long flags; long functions; long decorations; u_long input_mode; long status; } mwmhints; mwm_wm_hints = XInternAtom(theDisp, "_MOTIF_WM_HINTS", False); if (mwm_wm_hints != None) { xvbzero((char *) &mwmhints, sizeof(mwmhints)); mwmhints.flags = 2; mwmhints.decorations = 4; XChangeProperty(theDisp, mainW, mwm_wm_hints, mwm_wm_hints, 32, PropModeReplace, (byte *) &mwmhints, (int) (sizeof(mwmhints))/4); XSync(theDisp, False); } } firstTime = 0; } /***********************************/ static void setWinIconNames(name) const char *name; { char winname[NAME_MAX+sizeof("xv : ")+sizeof(VERSTR)+sizeof(" <unregistered>")+1], iconname[NAME_MAX+1]; if (winTitle) { strcpy(winname, winTitle); strcpy(iconname, winTitle); } else if (name[0] == '\0') { sprintf(winname, "xv %s",VERSTR); sprintf(iconname,"xv"); } else { sprintf(winname,"xv %s: %s", VERSTR, name); sprintf(iconname,"%s",name); } #ifndef REGSTR strcat(winname, " <unregistered>"); #endif if (mainW) { XStoreName(theDisp, mainW, winname); XSetIconName(theDisp, mainW, iconname); } } /***********************************/ void FixAspect(grow,w,h) int grow; int *w, *h; { /* computes new values of eWIDE and eHIGH which will have aspect ratio 'normaspect'. If 'grow' it will preserve aspect by enlarging, otherwise, it will shrink to preserve aspect ratio. Returns these values in 'w' and 'h' */ float xr,yr,curaspect,a,exp; *w = eWIDE; *h = eHIGH; /* xr,yr are expansion factors */ xr = ((float) eWIDE) / cWIDE; yr = ((float) eHIGH) / cHIGH; curaspect = xr / yr; /* if too narrow & shrink, shrink height. too wide and grow, grow height */ if ((curaspect < normaspect && !grow) || (curaspect > normaspect && grow)) { /* modify height */ exp = curaspect / normaspect; *h = (int) (eHIGH * exp + .5); } /* if too narrow & grow, grow width. too wide and shrink, shrink width */ if ((curaspect < normaspect && grow) || (curaspect > normaspect && !grow)) { /* modify width */ exp = normaspect / curaspect; *w = (int) (eWIDE * exp + .5); } /* shrink to fit screen without changing aspect ratio */ if (*w>maxWIDE) { int i; a = (float) *w / maxWIDE; *w = maxWIDE; i = (int) (*h / a + .5); /* avoid freaking some optimizers */ *h = i; } if (*h>maxHIGH) { a = (float) *h / maxHIGH; *h = maxHIGH; *w = (int) (*w / a + .5); } if (*w < 1) *w = 1; if (*h < 1) *h = 1; } /***********************************/ static void makeDispNames() { int prelen, n, i, done; char *suffix; suffix = namelist[0]; prelen = 0; /* length of prefix to be removed */ n = i = 0; /* shut up pesky compiler warnings */ done = 0; while (!done) { suffix = (char *) index(suffix,'/'); /* find next '/' in file name */ if (!suffix) break; suffix++; /* go past it */ n = suffix - namelist[0]; for (i=1; i<numnames; i++) { if (strncmp(namelist[0], namelist[i], (size_t) n)!=0) { done=1; break; } } if (!done) prelen = n; } for (i=0; i<numnames; i++) dispnames[i] = namelist[i] + prelen; } /***********************************/ static void fixDispNames() { /* fix dispnames array so that names don't go off right edge */ int i,j; char *tmp; for (i=j=0; i<numnames; i++) { char *dname; dname = dispnames[i]; if (StringWidth(dname) > (nList.w-10-16)) { /* have to trunc. */ tmp = dname; while (1) { tmp = (char *) index(tmp,'/'); /* find next '/' in filename */ if (!tmp) { tmp = dname; break; } tmp++; /* move to char following the '/' */ if (StringWidth(tmp) <= (nList.w-10-16)) { /* is cool now */ j++; break; } } dispnames[i] = tmp; } } } /***********************************/ void StickInCtrlList(select) int select; { /* stick current name (from 'load/save' box) and current working directory into 'namelist'. Does redraw list. */ char *name; char cwd[MAXPATHLEN]; name = GetDirFName(); GetDirPath(cwd); AddFNameToCtrlList(cwd, name); if (select) { nList.selected = numnames-1; curname = numnames - 1; } ChangedCtrlList(); } /***********************************/ void AddFNameToCtrlList(fpath,fname) const char *fpath, *fname; { /* stick given path/name into 'namelist'. Doesn't redraw list */ char *fullname; char cwd[MAXPATHLEN], globnm[MAXPATHLEN+100]; int i; if (!fpath) fpath = ""; /* bulletproofing... */ if (!fname) fname = ""; if (numnames == MAXNAMES) return; /* full up */ /* handle globbing */ if (fname[0] == '~') { strcpy(globnm, fname); Globify(globnm); fname = globnm; } if (fname[0] != '/') { /* prepend path */ strcpy(cwd, fpath); /* copy it to a modifiable place */ /* make sure fpath has a trailing '/' char */ if (strlen(cwd)==0 || cwd[strlen(cwd)-1]!='/') strcat(cwd, "/"); fullname = (char *) malloc(strlen(cwd) + strlen(fname) + 2); if (!fullname) FatalError("couldn't alloc name in AddFNameToCtrlList()\n"); sprintf(fullname, "%s%s", cwd, fname); } else { /* copy name to fullname */ fullname = (char *) malloc(strlen(fname) + 1); if (!fullname) FatalError("couldn't alloc name in AddFNameToCtrlList()\n"); strcpy(fullname, fname); } /* see if this name is a duplicate. Don't add it if it is. */ for (i=0; i<numnames; i++) if (strcmp(fullname, namelist[i]) == 0) { free(fullname); return; } namelist[numnames] = fullname; numnames++; makeDispNames(); fixDispNames(); } /***********************************/ void ChangedCtrlList() { /* called when the namelist/dispnames arrays have changed, and list needs to be re-displayed */ int cname, lsel; if (numnames>0) BTSetActive(&but[BDELETE],1); windowMB.dim[WMB_TEXTVIEW] = (numnames==0); cname = curname; lsel = nList.selected; /* get blown away in LSNewData */ LSChangeData(&nList, dispnames, numnames); curname = cname; nList.selected = lsel; /* restore prev values */ ActivePrevNext(); ScrollToCurrent(&nList); DrawCtrlNumFiles(); } /***********************************/ void ActivePrevNext() { /* called to enable/disable the Prev/Next buttons whenever curname and/or numnames and/or nList.selected change */ /* if curname<0 (there is no 'current' file), 'Next' means view the selected file (or the 0th file, if no selection either), and 'Prev' means view the one right before the selected file */ if (curname<0) { /* light things based on nList.selected, instead */ BTSetActive(&but[BNEXT], (numnames>0)); BTSetActive(&but[BPREV], (nList.selected>0)); } else { BTSetActive(&but[BNEXT], (curname<numnames-1)); BTSetActive(&but[BPREV], (curname>0)); } } /***********************************/ int DeleteCmd() { /* 'delete' button was pressed. Pop up a dialog box to determine what should be deleted, then do it. returns '1' if THE CURRENTLY VIEWED entry was deleted from the list, in which case the 'selected' filename on the ctrl list is now different, and should be auto-loaded, or something */ static const char *bnames[] = { "\004Disk File", "\nList Entry", "\033Cancel" }; char str[512]; int del, i, delnum, rv; /* failsafe */ delnum = nList.selected; if (delnum < 0 || delnum >= numnames) return 0; sprintf(str, "Delete '%s'?\n\n%s%s", namelist[delnum], "'List Entry' deletes selection from list.\n", "'Disk File' deletes file associated with selection."); del = PopUp(str, bnames, 3); if (del == 2) return 0; /* cancel */ if (del == 0) { /* 'Disk File' */ char *name; if (namelist[delnum][0] != '/') { /* prepend 'initdir' */ name = (char *) malloc(strlen(namelist[delnum]) + strlen(initdir) + 2); if (!name) FatalError("malloc in DeleteCmd failed\n"); sprintf(name,"%s/%s", initdir, namelist[delnum]); } else name = namelist[delnum]; i = unlink(name); if (i) { sprintf(str,"Can't delete file '%s'\n\n %s.", name, ERRSTR(errno)); ErrPopUp(str, "\nPity"); if (name != namelist[delnum]) free(name); return 0; } XVDeletedFile(name); if (name != namelist[delnum]) free(name); } deleteFromList(delnum); rv = 0; if (delnum == curname) { /* deleted the viewed file */ curname = nList.selected; rv = 1; /* auto-load currently 'selected' filename */ } else if (delnum < curname) curname = (curname > 0) ? curname-1 : 0; return rv; } /********************************************/ static void deleteFromList(delnum) int delnum; { int i; /* remove from list on either 'List Entry' or (successful) 'Disk File' */ /* determine if namelist[delnum] needs to be freed or not */ for (i=0; i<mainargc && mainargv[i] != namelist[delnum]; i++) ; if (i == mainargc) { /* not found. free it */ free(namelist[delnum]); } if (delnum != numnames-1) { /* snip out of namelist and dispnames lists */ xvbcopy((char *) &namelist[delnum+1], (char *) &namelist[delnum], (numnames - delnum - 1) * sizeof(namelist[0])); xvbcopy((char *) &dispnames[delnum+1], (char *) &dispnames[delnum], (numnames - delnum - 1) * sizeof(dispnames[0])); } numnames--; if (numnames==0) BTSetActive(&but[BDELETE],0); windowMB.dim[WMB_TEXTVIEW] = (numnames==0); nList.nstr = numnames; nList.selected = delnum; if (nList.selected >= numnames) nList.selected = numnames-1; if (nList.selected < 0) nList.selected = 0; SCSetRange(&nList.scrl, 0, numnames - nList.nlines, nList.scrl.val, nList.nlines-1); ScrollToCurrent(&nList); DrawCtrlNumFiles(); ActivePrevNext(); } /***********************************/ void HandleDispMode() { /* handles a change in the display mode (windowed/root). Also, called to do the 'right' thing when opening a picture displays epic, in current size, UNLESS we've selected an 'integer' root tiling thingy, in which case we resize epic appropriately */ static int haveoldinfo = 0; static Window oldMainW; static int oldCmapMode; static XSizeHints oldHints; static XWindowAttributes oldXwa; int i; WaitCursor(); /****************************************************************/ /*** RMB_WINDOW windowed mode */ /****************************************************************/ if (dispMode == RMB_WINDOW) { /* windowed */ char fnam[256]; BTSetActive(&but[BANNOT], 1); if (fullfname[0] == '\0') fnam[0] = '\0'; else { char *tmp; int i, state; /* find beginning of next-to-last pathname component, ie, if fullfname is "/foo/bar/snausage", we'd like "bar/snausage" */ state = 0; for (i=strlen(fullfname); i>0 && state!=2; i--) { if (fullfname[i] == '/') state++; } if (state==2) tmp = fullfname + i + 2; else tmp = fullfname; strcpy(fnam, tmp); /* if we're viewing a multi-page doc, add page # to title */ if (strlen(pageBaseName) && numPages>1) { char foo[64]; sprintf(foo, " Page %d of %d", curPage+1, numPages); strcat(fnam, foo); } } if (useroot && resetroot) ClearRoot(); if (mainW == (Window) None || useroot) { /* window not visible */ useroot = 0; if (haveoldinfo) { /* just remap mainW and resize it */ XWMHints xwmh; mainW = oldMainW; /* enable 'perfect' and 'owncmap' options */ dispMB.dim[DMB_COLPERF] = (picType == PIC8) ? 0 : 1; dispMB.dim[DMB_COLOWNC] = (picType == PIC8) ? 0 : 1; XSetStandardProperties(theDisp,mainW,"","",None,NULL,0,&oldHints); setWinIconNames(fnam); xwmh.initial_state = NormalState; xwmh.input = True; xwmh.flags = InputHint; xwmh.icon_pixmap = iconPix; xwmh.icon_mask = iconmask; xwmh.flags |= ( IconPixmapHint | IconMaskHint) ; xwmh.flags |= StateHint; XSetWMHints(theDisp, mainW, &xwmh); oldXwa.width = eWIDE; oldXwa.height = eHIGH; SetWindowPos(&oldXwa); XResizeWindow(theDisp, mainW, (u_int) eWIDE, (u_int) eHIGH); XMapWindow(theDisp, mainW); } else { /* first time. need to create mainW */ mainW = (Window) None; createMainWindow(maingeom, fnam); XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask | StructureNotifyMask | ButtonPressMask | KeyReleaseMask | ColormapChangeMask | EnterWindowMask | LeaveWindowMask ); StoreDeleteWindowProp(mainW); XFlush(theDisp); XMapWindow(theDisp,mainW); XFlush(theDisp); if (startIconic) sleep(2); /* give it time to get the window up...*/ } } else { /* mainW already visible */ createMainWindow(maingeom, fnam); XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask | StructureNotifyMask | ButtonPressMask | KeyReleaseMask | ColormapChangeMask | EnterWindowMask | LeaveWindowMask ); if (LocalCmap) { /* AllocColors created local colormap */ XSetWindowColormap(theDisp, mainW, LocalCmap); } } useroot = 0; } /****************************************************************/ /*** ROOT mode */ /****************************************************************/ else if (dispMode > RMB_WINDOW && dispMode < RMB_MAX) { int ew, eh, regen; BTSetActive(&but[BANNOT], 0); regen = 0; if (!useroot) { /* have to hide mainW, etc. */ dispMB.dim[DMB_COLPERF] = 1; /* no perfect or owncmap in root mode */ dispMB.dim[DMB_COLOWNC] = 1; /* save current window stuff */ haveoldinfo = 1; oldMainW = mainW; oldCmapMode = colorMapMode; GetWindowPos(&oldXwa); if (!XGetNormalHints(theDisp, mainW, &oldHints)) oldHints.flags = 0; oldHints.x=oldXwa.x; oldHints.y=oldXwa.y; oldHints.flags|=USPosition; if (LocalCmap) regen=1; /* this reallocs the colors */ if (colorMapMode==CM_PERFECT || colorMapMode==CM_OWNCMAP) ChangeCmapMode(CM_NORMAL, 0, 0); XUnmapWindow(theDisp, mainW); mainW = vrootW; if (!ctrlUp) { /* make sure ctrl is up when going to 'root' mode */ XWMHints xwmh; xwmh.input = True; xwmh.initial_state = IconicState; xwmh.flags = (InputHint | StateHint); XSetWMHints(theDisp, ctrlW, &xwmh); CtrlBox(1); } } useroot = 1; rootMode = dispMode - RMB_ROOT; ew = eWIDE; eh = eHIGH; RANGE(ew,1,maxWIDE); RANGE(eh,1,maxHIGH); if (rootMode == RM_TILE || rootMode == RM_IMIRROR) { i = (dispWIDE + ew-1) / ew; ew = (dispWIDE + i-1) / i; i = (dispHIGH + eh-1) / eh; eh = (dispHIGH + i-1) / i; } if (ew != eWIDE || eh != eHIGH) { /* changed size... */ GenerateEpic(ew, eh); CreateXImage(); } else if (regen) CreateXImage(); KillOldRootInfo(); MakeRootPic(); SetCursors(-1); } else { fprintf(stderr,"unknown dispMB value '%d' in HandleDispMode()\n", dispMode); } SetCursors(-1); } /*******************************************************/ static void add_filelist_to_namelist(flist, nlist, numn, maxn) char *flist; char **nlist; int *numn, maxn; { /* written by Brian Gregory (bgregory@megatest.com) */ FILE *fp; fp = fopen(flist,"r"); if (!fp) { fprintf(stderr,"Can't open filelist '%s': %s\n", flist, ERRSTR(errno)); return; } while (*numn < maxn) { char *s, *nlp, fbuf[MAXPATHLEN]; if (!fgets(fbuf, MAXPATHLEN, fp) || !(s = (char *) malloc(strlen(fbuf)))) break; nlp = (char *) rindex(fbuf, '\n'); if (nlp) *nlp = '\0'; strcpy(s, fbuf); namelist[*numn] = s; (*numn)++; } if (*numn == maxn) { fprintf(stderr, "%s: too many filenames. Using only first %d.\n", flist, maxn); } fclose(fp); } /************************************************************************/ /***********************************/ char *lower_str(str) char *str; { char *p; for (p=str; *p; p++) if (isupper(*p)) *p = tolower(*p); return str; } /***********************************/ int rd_int(name) const char *name; { /* returns '1' if successful. result in def_int */ if (rd_str_cl(name, "", 0)) { /* sets def_str */ if (sscanf(def_str, "%d", &def_int) == 1) return 1; else { fprintf(stderr, "%s: couldn't read integer value for %s resource\n", cmd, name); return 0; } } else return 0; } /***********************************/ int rd_str(name) const char *name; { return rd_str_cl(name, "", 0); } /***********************************/ int rd_flag(name) const char *name; { /* returns '1' if successful. result in def_int */ char buf[256]; if (rd_str_cl(name, "", 0)) { /* sets def_str */ strcpy(buf, def_str); lower_str(buf); def_int = (strcmp(buf, "on")==0) || (strcmp(buf, "1")==0) || (strcmp(buf, "true")==0) || (strcmp(buf, "yes")==0); return 1; } else return 0; } static int xrm_initted = 0; /***********************************/ int rd_str_cl (name_str, class_str, reinit) const char *name_str; const char *class_str; int reinit; { /* note: *all* X resource reading goes through this routine... */ /* returns '1' if successful, result in def_str */ char q_name[BUFSIZ], q_class[BUFSIZ]; char *type; XrmValue result; int gotit; static XrmDatabase def_resource; if (reinit) { #ifndef vax11c if (xrm_initted && def_resource) XrmDestroyDatabase(def_resource); #endif xrm_initted = 0; } if (!xrm_initted) { Atom resAtom; char *xrm_str; XrmInitialize(); xrm_initted = 1; def_resource = (XrmDatabase) 0; gotit = 0; /* don't use XResourceManagerString, as it is a snapshot of the string when theDisp was opened, and doesn't change */ resAtom = XInternAtom(theDisp, "RESOURCE_MANAGER", True); if (resAtom != None) { Atom actType; int i, actFormat; unsigned long nitems, nleft; byte *data; if (spec_window) { i = XGetWindowProperty(theDisp, spec_window, resAtom, 0L, 1L, False, XA_STRING, &actType, &actFormat, &nitems, &nleft, (unsigned char **) &data); } else { i = XGetWindowProperty(theDisp, RootWindow(theDisp, 0), resAtom, 0L, 1L, False, XA_STRING, &actType, &actFormat, &nitems, &nleft, (unsigned char **) &data); } if (i==Success && actType==XA_STRING && actFormat==8) { if (nitems>0 && data) XFree(data); if (spec_window) { i = XGetWindowProperty(theDisp, spec_window, resAtom, 0L, (long) ((nleft+4+3)/4), False, XA_STRING, &actType, &actFormat, &nitems, &nleft, (unsigned char **) &data); } else { i = XGetWindowProperty(theDisp, RootWindow(theDisp, 0), resAtom, 0L, (long) ((nleft+4+3)/4), False, XA_STRING, &actType, &actFormat, &nitems, &nleft, (unsigned char **) &data); } if (i==Success && actType==XA_STRING && actFormat==8 && data) { def_resource = XrmGetStringDatabase((char *) data); XFree(data); gotit = 1; } } } if (!gotit) { xrm_str = XResourceManagerString(theDisp); if (xrm_str) { def_resource = XrmGetStringDatabase(xrm_str); if (DEBUG) fprintf(stderr,"rd_str_cl: Using RESOURCE_MANAGER prop.\n"); } else { /* no RESOURCE_MANAGER prop. read from 'likely' file */ char foo[256], *xenviron; const char *homedir; XrmDatabase res1; #ifdef VMS strcpy(foo, "SYS$LOGIN:DECW$XDEFAULTS.DAT"); #else homedir = (const char *) getenv("HOME"); if (!homedir) homedir = "."; sprintf(foo,"%s/.Xdefaults", homedir); #endif def_resource = XrmGetFileDatabase(foo); if (DEBUG) { fprintf(stderr,"rd_str_cl: No RESOURCE_MANAGER prop.\n"); fprintf(stderr,"rd_str_cl: Using file '%s' (%s) ", foo, (def_resource) ? "success" : "failure"); } /* merge file pointed to by XENVIRONMENT */ xenviron = (char *) getenv("XENVIRONMENT"); if (xenviron) { res1 = XrmGetFileDatabase(xenviron); if (DEBUG) { fprintf(stderr,"merging XENVIRONMENT='%s' (%s) ", xenviron, (res1) ? "success" : "failure"); } if (res1) { /* merge databases */ if (!def_resource) def_resource = res1; else XrmMergeDatabases(res1, &def_resource); } } if (DEBUG) fprintf(stderr,"\n\n"); } } } if (!def_resource) return 0; /* no resource database to search! */ strcpy (q_name, PROGNAME); strcat (q_name, "."); strcat (q_name, name_str); strcpy (q_class, "Program"); strcat (q_class, "."); strcat (q_class, class_str); (void) XrmGetResource(def_resource, q_name, q_class, &type, &result); def_str = result.addr; if (def_str) return 1; else return 0; }
28.38647
106
0.582714
b7fb0967845e7af8e2cf81ec72a218b154a86964
329
h
C
Pods/GMCommenKit/GMCommenKit/Classes/LoginManager/public/GMDLoginViewDelegate.h
ioszhanghui/HandleCookies
929222daa60038d7e38455af196635fa2f0c792d
[ "MIT" ]
1
2019-11-13T16:43:46.000Z
2019-11-13T16:43:46.000Z
Pods/GMCommenKit/GMCommenKit/Classes/LoginManager/public/GMDLoginViewDelegate.h
ioszhanghui/HandleCookies
929222daa60038d7e38455af196635fa2f0c792d
[ "MIT" ]
null
null
null
Pods/GMCommenKit/GMCommenKit/Classes/LoginManager/public/GMDLoginViewDelegate.h
ioszhanghui/HandleCookies
929222daa60038d7e38455af196635fa2f0c792d
[ "MIT" ]
null
null
null
// // GMDLoginViewDelegate.h // GMAFNetworking // // Created by lijian on 2018/4/12. // #import <Foundation/Foundation.h> @protocol GMDLoginViewDelegate <NSObject> @optional /// 登录成功的消失时调用 - (void)gmdOp_loginSuccessAndWillDismiss; /// 未登录时 - (void)gmdOp_noLoginAndCancel; /// 点击返回按钮 - (void)loginClickBackButton; @end
13.16
41
0.726444
b7fb3d10717178e8f359ceb8496653266840a03a
38
h
C
include/iot_config.h
lvlynn/aliyun_iot_sdk
17681bbba9a57dbcf340f10e9e1a3d74f9828520
[ "Apache-2.0" ]
2
2019-02-15T06:15:17.000Z
2019-04-25T07:14:23.000Z
include/iot_config.h
lvlynn/aliyun_iot_sdk
17681bbba9a57dbcf340f10e9e1a3d74f9828520
[ "Apache-2.0" ]
null
null
null
include/iot_config.h
lvlynn/aliyun_iot_sdk
17681bbba9a57dbcf340f10e9e1a3d74f9828520
[ "Apache-2.0" ]
1
2019-02-15T13:30:20.000Z
2019-02-15T13:30:20.000Z
#define IOT_VERSION "2.1.22-20190215"
19
37
0.763158
b7fbd414f69a21a250d1c31baffb88cdc293b2c6
3,663
h
C
rs_bindings_from_cc/cmdline.h
google/crubit
ff16f6442cb78ae79ab61bd3b6375480f6af28b3
[ "Apache-2.0" ]
23
2022-03-28T12:55:44.000Z
2022-03-31T07:52:02.000Z
rs_bindings_from_cc/cmdline.h
google/crubit
ff16f6442cb78ae79ab61bd3b6375480f6af28b3
[ "Apache-2.0" ]
null
null
null
rs_bindings_from_cc/cmdline.h
google/crubit
ff16f6442cb78ae79ab61bd3b6375480f6af28b3
[ "Apache-2.0" ]
null
null
null
// Part of the Crubit project, under the Apache License v2.0 with LLVM // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #ifndef CRUBIT_RS_BINDINGS_FROM_CC_CMDLINE_H_ #define CRUBIT_RS_BINDINGS_FROM_CC_CMDLINE_H_ #include <string> #include <vector> #include "absl/container/flat_hash_map.h" #include "absl/status/statusor.h" #include "absl/strings/string_view.h" #include "rs_bindings_from_cc/bazel_types.h" #include "rs_bindings_from_cc/ir.h" namespace crubit { // Parses and validates command line arguments. class Cmdline { public: // Creates `Cmdline` based on the actual cmdline arguments. static absl::StatusOr<Cmdline> Create(); // Creates `Cmdline` based on the provided cmdline arguments - `cc_out`, // `rs_out`, and so forth. static absl::StatusOr<Cmdline> CreateForTesting( std::string cc_out, std::string rs_out, std::string ir_out, std::string crubit_support_path, std::string rustfmt_exe_path, std::string rustfmt_config_path, bool do_nothing, std::vector<std::string> public_headers, std::string targets_and_headers_str, std::vector<std::string> rust_sources, std::string instantiations_out) { return CreateFromArgs( std::move(cc_out), std::move(rs_out), std::move(ir_out), std::move(crubit_support_path), std::move(rustfmt_exe_path), std::move(rustfmt_config_path), do_nothing, std::move(public_headers), std::move(targets_and_headers_str), std::move(rust_sources), std::move(instantiations_out)); } Cmdline(const Cmdline&) = delete; Cmdline& operator=(const Cmdline&) = delete; Cmdline(Cmdline&&) = default; Cmdline& operator=(Cmdline&&) = default; absl::string_view cc_out() const { return cc_out_; } absl::string_view rs_out() const { return rs_out_; } absl::string_view ir_out() const { return ir_out_; } absl::string_view crubit_support_path() const { return crubit_support_path_; } absl::string_view rustfmt_exe_path() const { return rustfmt_exe_path_; } absl::string_view rustfmt_config_path() const { return rustfmt_config_path_; } absl::string_view instantiations_out() const { return instantiations_out_; } bool do_nothing() const { return do_nothing_; } const std::vector<HeaderName>& public_headers() const { return public_headers_; } const std::vector<std::string>& rust_sources() const { return rust_sources_; } const BazelLabel& current_target() const { return current_target_; } const absl::flat_hash_map<const HeaderName, const BazelLabel>& headers_to_targets() const { return headers_to_targets_; } private: Cmdline(); static absl::StatusOr<Cmdline> CreateFromArgs( std::string cc_out, std::string rs_out, std::string ir_out, std::string crubit_support_path, std::string rustfmt_exe_path, std::string rustfmt_config_path, bool do_nothing, std::vector<std::string> public_headers, std::string targets_and_headers_str, std::vector<std::string> rust_sources, std::string instantiations_out); absl::StatusOr<BazelLabel> FindHeader(const HeaderName& header) const; std::string cc_out_; std::string rs_out_; std::string ir_out_; std::string crubit_support_path_; std::string rustfmt_exe_path_; std::string rustfmt_config_path_; bool do_nothing_ = true; BazelLabel current_target_; std::vector<HeaderName> public_headers_; absl::flat_hash_map<const HeaderName, const BazelLabel> headers_to_targets_; std::string instantiations_out_; std::vector<std::string> rust_sources_; }; } // namespace crubit #endif // CRUBIT_RS_BINDINGS_FROM_CC_CMDLINE_H_
36.267327
80
0.743653
b7fc9d11d7efceaa5fc665c4571677260be95c5f
29,437
h
C
nasal_vm.h
sidi762/Nasal-Interpreter
6a543f2aa76a0f4812600f4812590ca9c4f6bb94
[ "MIT" ]
null
null
null
nasal_vm.h
sidi762/Nasal-Interpreter
6a543f2aa76a0f4812600f4812590ca9c4f6bb94
[ "MIT" ]
null
null
null
nasal_vm.h
sidi762/Nasal-Interpreter
6a543f2aa76a0f4812600f4812590ca9c4f6bb94
[ "MIT" ]
null
null
null
#ifndef __NASAL_VM_H__ #define __NASAL_VM_H__ class nasal_vm { private: /* values of nasal_vm */ uint32_t pc; // program counter uint32_t offset; // used to load default parameters to a new function const double* num_table;// const numbers, ref from nasal_codegen const std::string* str_table;// const symbols, ref from nasal_codegen std::stack<nasal_func*> func_stk; // stack to store function, used to get upvalues std::vector<uint32_t> imm; // immediate number nasal_ref* mem_addr; // used for mem_call /* garbage collector */ nasal_gc gc; /* values used for debug */ const opcode* bytecode; // ref from nasal_codegen const std::string* files; // ref from nasal_import void init( const std::vector<std::string>&, const std::vector<double>&, const std::vector<std::string>&); /* debug functions */ bool detail_info; void valinfo(nasal_ref&); void bytecodeinfo(const uint32_t); void traceback(); void stackinfo(const uint32_t); void detail(); void opcallsort(const uint64_t*); void die(std::string); /* vm calculation functions*/ bool condition(nasal_ref); void opr_nop(); void opr_intg(); void opr_intl(); void opr_loadg(); void opr_loadl(); void opr_loadu(); void opr_pnum(); void opr_pone(); void opr_pzero(); void opr_pnil(); void opr_pstr(); void opr_newv(); void opr_newh(); void opr_newf(); void opr_happ(); void opr_para(); void opr_defpara(); void opr_dynpara(); void opr_unot(); void opr_usub(); void opr_add(); void opr_sub(); void opr_mul(); void opr_div(); void opr_lnk(); void opr_addc(); void opr_subc(); void opr_mulc(); void opr_divc(); void opr_lnkc(); void opr_addeq(); void opr_subeq(); void opr_muleq(); void opr_diveq(); void opr_lnkeq(); void opr_addeqc(); void opr_subeqc(); void opr_muleqc(); void opr_diveqc(); void opr_lnkeqc(); void opr_meq(); void opr_eq(); void opr_neq(); void opr_less(); void opr_leq(); void opr_grt(); void opr_geq(); void opr_lessc(); void opr_leqc(); void opr_grtc(); void opr_geqc(); void opr_pop(); void opr_jmp(); void opr_jt(); void opr_jf(); void opr_counter(); void opr_findex(); void opr_feach(); void opr_callg(); void opr_calll(); void opr_upval(); void opr_callv(); void opr_callvi(); void opr_callh(); void opr_callfv(); void opr_callfh(); void opr_callb(); void opr_slcbegin(); void opr_slcend(); void opr_slc(); void opr_slc2(); void opr_mcallg(); void opr_mcalll(); void opr_mupval(); void opr_mcallv(); void opr_mcallh(); void opr_ret(); public: void run( const nasal_codegen&, const nasal_import&, const bool, const bool); }; void nasal_vm::init( const std::vector<std::string>& strs, const std::vector<double>& nums, const std::vector<std::string>& filenames) { gc.init(strs); num_table=nums.data(); str_table=strs.data(); files=filenames.data(); } void nasal_vm::valinfo(nasal_ref& val) { const nasal_val* p=val.value.gcobj; switch(val.type) { case vm_none: printf("\t| null |\n");break; case vm_ret: printf("\t| addr | pc=0x%x\n",val.ret());break; case vm_cnt: printf("\t| cnt | %ld\n",val.cnt());break; case vm_nil: printf("\t| nil |\n");break; case vm_num: printf("\t| num | %lf\n",val.num());break; case vm_str: printf("\t| str | <0x%lx> %s\n",(uint64_t)p,rawstr(*val.str()).c_str());break; case vm_func: printf("\t| func | <0x%lx> entry=0x%x\n",(uint64_t)p,val.func()->entry);break; case vm_vec: printf("\t| vec | <0x%lx> [%lu val]\n",(uint64_t)p,val.vec()->elems.size());break; case vm_hash: printf("\t| hash | <0x%lx> {%lu member}\n",(uint64_t)p,val.hash()->elems.size());break; case vm_obj: printf("\t| obj | <0x%lx> object=0x%lx\n",(uint64_t)p,(uint64_t)val.obj()->ptr);break; default: printf("\t| ??? | <0x%lx>\n",(uint64_t)p);break; } } void nasal_vm::bytecodeinfo(const uint32_t p) { const opcode& code=bytecode[p]; printf("\t0x%.8x: %s 0x%x",p,code_table[code.op].name,code.num); if(code.op==op_callb) printf(" <%s@0x%lx>",builtin[code.num].name,(uint64_t)builtin[code.num].func); printf(" (<%s> line %d)\n",files[code.fidx].c_str(),code.line); } void nasal_vm::traceback() { uint32_t global_size=bytecode[0].num; // bytecode[0] is op_intg nasal_ref* top=gc.top; nasal_ref* bottom=gc.stack+global_size; std::stack<uint32_t> ret; for(nasal_ref* i=bottom;i<=top;++i) if(i->type==vm_ret) ret.push(i->ret()); // push pc to ret stack to store the position program crashed ret.push(pc); printf("trace back:\n"); uint32_t same=0,last=0xffffffff; for(uint32_t point=0;!ret.empty();last=point,ret.pop()) { if((point=ret.top())==last) { ++same; continue; } if(same) printf("\t0x%.8x: %d same call(s)\n",last,same); same=0; bytecodeinfo(point); } if(same) printf("\t0x%.8x: %d same call(s)\n",last,same); } void nasal_vm::stackinfo(const uint32_t limit=10) { uint32_t global_size=bytecode[0].num; // bytecode[0] is op_intg nasal_ref* top=gc.top; nasal_ref* bottom=gc.stack+global_size; printf("vm stack(limit %d, total %ld):\n",limit,top-bottom+1); for(uint32_t i=0;i<limit && top>=bottom;++i,--top) valinfo(top[0]); } void nasal_vm::detail() { printf("mcall address: 0x%lx\n",(uint64_t)mem_addr); if(bytecode[0].num) // bytecode[0] is op_intg { printf("global:\n"); for(uint32_t i=0;i<bytecode[0].num;++i) { printf("[0x%.8x]",i); valinfo(gc.stack[i]); } } if(!gc.local.empty()) { printf("local:\n"); auto& vec=gc.local.back().vec()->elems; for(uint32_t i=0;i<vec.size();++i) { printf("[0x%.8x]",i); valinfo(vec[i]); } } if(!func_stk.empty() && !func_stk.top()->upvalue.empty()) { printf("upvalue:\n"); auto& upval=func_stk.top()->upvalue; for(uint32_t i=0;i<upval.size();++i) { auto& vec=upval[i].vec()->elems; for(uint32_t j=0;j<vec.size();++j) { printf("[%.4x][%.4x]",i,j); valinfo(vec[j]); } } } } void nasal_vm::opcallsort(const uint64_t* arr) { typedef std::pair<uint32_t,uint64_t> op; std::vector<op> opcall; for(uint32_t i=0;i<=op_exit;++i) opcall.push_back({i,arr[i]}); std::sort( opcall.begin(), opcall.end(), [](op& a,op& b){return a.second>b.second;} ); std::cout<<'\n'; for(auto& i:opcall) { if(!i.second) break; std::cout<<code_table[i.first].name<<": "<<i.second<<'\n'; } } void nasal_vm::die(std::string str) { printf("[vm] %s\n",str.c_str()); traceback(); stackinfo(); if(detail_info) detail(); std::exit(1); } inline bool nasal_vm::condition(nasal_ref val) { if(val.type==vm_num) return val.value.num; else if(val.type==vm_str) { double num=str2num(val.str()->c_str()); if(std::isnan(num)) return !val.str()->empty(); return num; } return false; } inline void nasal_vm::opr_nop(){} inline void nasal_vm::opr_intg() { // global values store on stack for(uint32_t i=0;i<imm[pc];++i) (gc.top++)[0].type=vm_nil; --gc.top;// point to the top } inline void nasal_vm::opr_intl() { gc.top[0].func()->local.resize(imm[pc],gc.nil); } inline void nasal_vm::opr_loadg() { gc.stack[imm[pc]]=(gc.top--)[0]; } inline void nasal_vm::opr_loadl() { gc.local.back().vec()->elems[imm[pc]]=(gc.top--)[0]; } inline void nasal_vm::opr_loadu() { func_stk.top()->upvalue[(imm[pc]>>16)&0xffff].vec()->elems[imm[pc]&0xffff]=(gc.top--)[0]; } inline void nasal_vm::opr_pnum() { (++gc.top)[0]={vm_num,num_table[imm[pc]]}; } inline void nasal_vm::opr_pone() { (++gc.top)[0]={vm_num,(double)1}; } inline void nasal_vm::opr_pzero() { (++gc.top)[0]={vm_num,(double)0}; } inline void nasal_vm::opr_pnil() { (++gc.top)[0]={vm_nil,(double)0}; } inline void nasal_vm::opr_pstr() { (++gc.top)[0]=gc.strs[imm[pc]]; } inline void nasal_vm::opr_newv() { nasal_ref newv=gc.alloc(vm_vec); auto& vec=newv.vec()->elems; vec.resize(imm[pc]); // use top-=imm[pc]-1 here will cause error if imm[pc] is 0 gc.top=gc.top-imm[pc]+1; for(uint32_t i=0;i<imm[pc];++i) vec[i]=gc.top[i]; gc.top[0]=newv; } inline void nasal_vm::opr_newh() { (++gc.top)[0]=gc.alloc(vm_hash); } inline void nasal_vm::opr_newf() { offset=1; (++gc.top)[0]=gc.alloc(vm_func); gc.top[0].func()->entry=imm[pc]; if(!gc.local.empty()) { gc.top[0].func()->upvalue=func_stk.top()->upvalue; gc.top[0].func()->upvalue.push_back(gc.local.back()); } } inline void nasal_vm::opr_happ() { gc.top[-1].hash()->elems[str_table[imm[pc]]]=gc.top[0]; --gc.top; } inline void nasal_vm::opr_para() { nasal_func* func=gc.top[0].func(); size_t size=func->keys.size(); func->keys[str_table[imm[pc]]]=size; func->local[offset++]={vm_none}; } inline void nasal_vm::opr_defpara() { nasal_ref val=gc.top[0]; nasal_func* func=(--gc.top)[0].func(); size_t size=func->keys.size(); func->keys[str_table[imm[pc]]]=size; func->local[offset++]=val; } inline void nasal_vm::opr_dynpara() { gc.top[0].func()->dynpara=imm[pc]; } inline void nasal_vm::opr_unot() { nasal_ref val=gc.top[0]; switch(val.type) { case vm_nil:gc.top[0]=gc.one;break; case vm_num:gc.top[0]=val.num()?gc.zero:gc.one;break; case vm_str: { double num=str2num(val.str()->c_str()); if(std::isnan(num)) gc.top[0]={vm_num,(double)val.str()->empty()}; else gc.top[0]=num?gc.zero:gc.one; } break; default:die("unot: incorrect value type");break; } } inline void nasal_vm::opr_usub() { gc.top[0]={vm_num,-gc.top[0].to_number()}; } #define op_calc(type)\ nasal_ref val(vm_num,gc.top[-1].to_number() type gc.top[0].to_number());\ (--gc.top)[0]=val; inline void nasal_vm::opr_add(){op_calc(+);} inline void nasal_vm::opr_sub(){op_calc(-);} inline void nasal_vm::opr_mul(){op_calc(*);} inline void nasal_vm::opr_div(){op_calc(/);} inline void nasal_vm::opr_lnk() { nasal_ref val=gc.alloc(vm_str); *val.str()=gc.top[-1].to_string()+gc.top[0].to_string(); (--gc.top)[0]=val; } #define op_calc_const(type)\ nasal_ref val(vm_num,gc.top[0].to_number() type num_table[imm[pc]]);\ gc.top[0]=val; inline void nasal_vm::opr_addc(){op_calc_const(+);} inline void nasal_vm::opr_subc(){op_calc_const(-);} inline void nasal_vm::opr_mulc(){op_calc_const(*);} inline void nasal_vm::opr_divc(){op_calc_const(/);} inline void nasal_vm::opr_lnkc() { nasal_ref val=gc.alloc(vm_str); *val.str()=gc.top[0].to_string()+str_table[imm[pc]]; gc.top[0]=val; } #define op_calc_eq(type)\ nasal_ref val(vm_num,mem_addr[0].to_number() type gc.top[-1].to_number());\ (--gc.top)[0]=mem_addr[0]=val; inline void nasal_vm::opr_addeq(){op_calc_eq(+);} inline void nasal_vm::opr_subeq(){op_calc_eq(-);} inline void nasal_vm::opr_muleq(){op_calc_eq(*);} inline void nasal_vm::opr_diveq(){op_calc_eq(/);} inline void nasal_vm::opr_lnkeq() { nasal_ref val=gc.alloc(vm_str); *val.str()=mem_addr[0].to_string()+gc.top[-1].to_string(); (--gc.top)[0]=mem_addr[0]=val; } #define op_calc_eq_const(type)\ nasal_ref val(vm_num,mem_addr[0].to_number() type num_table[imm[pc]]);\ gc.top[0]=mem_addr[0]=val; inline void nasal_vm::opr_addeqc(){op_calc_eq_const(+);} inline void nasal_vm::opr_subeqc(){op_calc_eq_const(-);} inline void nasal_vm::opr_muleqc(){op_calc_eq_const(*);} inline void nasal_vm::opr_diveqc(){op_calc_eq_const(/);} inline void nasal_vm::opr_lnkeqc() { nasal_ref val=gc.alloc(vm_str); *val.str()=mem_addr[0].to_string()+str_table[imm[pc]]; gc.top[0]=mem_addr[0]=val; } inline void nasal_vm::opr_meq() { mem_addr[0]=(--gc.top)[0]; } inline void nasal_vm::opr_eq() { nasal_ref val2=gc.top[0]; nasal_ref val1=(--gc.top)[0]; if(val1.type==vm_nil && val2.type==vm_nil) gc.top[0]=gc.one; else if(val1.type==vm_str && val2.type==vm_str) gc.top[0]=(*val1.str()==*val2.str())?gc.one:gc.zero; else if(val1.type==vm_num || val2.type==vm_num) gc.top[0]=(val1.to_number()==val2.to_number())?gc.one:gc.zero; else gc.top[0]=(val1==val2)?gc.one:gc.zero; } inline void nasal_vm::opr_neq() { nasal_ref val2=gc.top[0]; nasal_ref val1=(--gc.top)[0]; if(val1.type==vm_nil && val2.type==vm_nil) gc.top[0]=gc.zero; else if(val1.type==vm_str && val2.type==vm_str) gc.top[0]=(*val1.str()!=*val2.str())?gc.one:gc.zero; else if(val1.type==vm_num || val2.type==vm_num) gc.top[0]=(val1.to_number()!=val2.to_number())?gc.one:gc.zero; else gc.top[0]=(val1!=val2)?gc.one:gc.zero; } #define op_cmp(type)\ --gc.top;\ gc.top[0]=(gc.top[0].to_number() type gc.top[1].to_number())?gc.one:gc.zero; inline void nasal_vm::opr_less(){op_cmp(<);} inline void nasal_vm::opr_leq(){op_cmp(<=);} inline void nasal_vm::opr_grt(){op_cmp(>);} inline void nasal_vm::opr_geq(){op_cmp(>=);} #define op_cmp_const(type)\ gc.top[0]=(gc.top[0].to_number() type num_table[imm[pc]])?gc.one:gc.zero; inline void nasal_vm::opr_lessc(){op_cmp_const(<);} inline void nasal_vm::opr_leqc(){op_cmp_const(<=);} inline void nasal_vm::opr_grtc(){op_cmp_const(>);} inline void nasal_vm::opr_geqc(){op_cmp_const(>=);} inline void nasal_vm::opr_pop() { --gc.top; } inline void nasal_vm::opr_jmp() { pc=imm[pc]-1; } inline void nasal_vm::opr_jt() { if(condition(gc.top[0])) pc=imm[pc]-1; } inline void nasal_vm::opr_jf() { if(!condition(gc.top[0])) pc=imm[pc]-1; --gc.top; } inline void nasal_vm::opr_counter() { (++gc.top)[0]={vm_cnt,(int64_t)-1}; if(gc.top[-1].type!=vm_vec) die("cnt: must use vector in forindex/foreach"); } inline void nasal_vm::opr_findex() { if(++gc.top[0].cnt()>=gc.top[-1].vec()->elems.size()) { pc=imm[pc]-1; return; } gc.top[1]={vm_num,(double)gc.top[0].cnt()}; ++gc.top; } inline void nasal_vm::opr_feach() { std::vector<nasal_ref>& ref=gc.top[-1].vec()->elems; if(++gc.top[0].cnt()>=ref.size()) { pc=imm[pc]-1; return; } gc.top[1]=ref[gc.top[0].cnt()]; ++gc.top; } inline void nasal_vm::opr_callg() { (++gc.top)[0]=gc.stack[imm[pc]]; } inline void nasal_vm::opr_calll() { (++gc.top)[0]=gc.local.back().vec()->elems[imm[pc]]; } inline void nasal_vm::opr_upval() { (++gc.top)[0]=func_stk.top()->upvalue[(imm[pc]>>16)&0xffff].vec()->elems[imm[pc]&0xffff]; } inline void nasal_vm::opr_callv() { nasal_ref val=gc.top[0]; nasal_ref vec=(--gc.top)[0]; if(vec.type==vm_vec) { gc.top[0]=vec.vec()->get_val(val.to_number()); if(gc.top[0].type==vm_none) die("callv: index out of range:"+std::to_string(val.to_number())); } else if(vec.type==vm_hash) { if(val.type!=vm_str) die("callv: must use string as the key"); gc.top[0]=vec.hash()->get_val(*val.str()); if(gc.top[0].type==vm_none) die("callv: cannot find member \""+*val.str()+"\" of this hash"); if(gc.top[0].type==vm_func) gc.top[0].func()->local[0]=val;// 'me' } else if(vec.type==vm_str) { std::string& str=*vec.str(); int num=val.to_number(); int str_size=str.length(); if(num<-str_size || num>=str_size) die("callv: index out of range:"+std::to_string(val.to_number())); gc.top[0]={vm_num,double((uint8_t)str[num>=0? num:num+str_size])}; } else die("callv: must call a vector/hash/string"); } inline void nasal_vm::opr_callvi() { nasal_ref val=gc.top[0]; if(val.type!=vm_vec) die("callvi: must use a vector"); // cannot use operator[],because this may cause overflow (++gc.top)[0]=val.vec()->get_val(imm[pc]); if(gc.top[0].type==vm_none) die("callvi: index out of range:"+std::to_string(imm[pc])); } inline void nasal_vm::opr_callh() { nasal_ref val=gc.top[0]; if(val.type!=vm_hash) die("callh: must call a hash"); gc.top[0]=val.hash()->get_val(str_table[imm[pc]]); if(gc.top[0].type==vm_none) die("callh: member \""+str_table[imm[pc]]+"\" does not exist"); if(gc.top[0].type==vm_func) gc.top[0].func()->local[0]=val;// 'me' } inline void nasal_vm::opr_callfv() { uint32_t args_size=imm[pc]; nasal_ref* args=gc.top-args_size+1; if(args[-1].type!=vm_func) die("callfv: must call a function"); // push function and new local scope func_stk.push(args[-1].func()); auto& func=*args[-1].func(); gc.local.push_back(gc.alloc(vm_vec)); gc.local.back().vec()->elems=func.local; auto& local=gc.local.back().vec()->elems; uint32_t para_size=func.keys.size(); // load arguments // if the first default value is not vm_none,then values after it are not nullptr if(args_size<para_size && func.local[args_size+1/*1 is reserved for 'me'*/].type==vm_none) die("callfv: lack argument(s)"); // if args_size>para_size,for 0 to args_size will cause corruption uint32_t min_size=std::min(para_size,args_size); for(uint32_t i=0;i<min_size;++i) local[i+1]=args[i]; // load dynamic argument if args_size>=para_size if(func.dynpara>=0) { nasal_ref vec=gc.alloc(vm_vec); for(uint32_t i=para_size;i<args_size;++i) vec.vec()->elems.push_back(args[i]); local.back()=vec; } gc.top-=args_size; // pop arguments (++gc.top)[0]={vm_ret,pc}; pc=func.entry-1; } inline void nasal_vm::opr_callfh() { auto& hash=gc.top[0].hash()->elems; if(gc.top[-1].type!=vm_func) die("callfh: must call a function"); // push function and new local scope func_stk.push(gc.top[-1].func()); auto& func=*gc.top[-1].func(); gc.local.push_back(gc.alloc(vm_vec)); gc.local.back().vec()->elems=func.local; auto& local=gc.local.back().vec()->elems; if(func.dynpara>=0) die("callfh: special call cannot use dynamic argument"); for(auto& i:func.keys) { if(hash.count(i.first)) local[i.second+1]=hash[i.first]; else if(func.local[i.second+1/*1 is reserved for 'me'*/].type==vm_none) die("callfh: lack argument(s): \""+i.first+"\""); } gc.top[0]={vm_ret,(uint32_t)pc}; // rewrite top with vm_ret pc=func.entry-1; } inline void nasal_vm::opr_callb() { (++gc.top)[0]=(*builtin[imm[pc]].func)(gc.local.back().vec()->elems,gc); if(gc.top[0].type==vm_none) die("native function error."); } inline void nasal_vm::opr_slcbegin() { // | slice_vector | <-- gc.top[0] // +--------------+ // | resource_vec | <-- gc.top[-1] // +--------------+ (++gc.top)[0]=gc.alloc(vm_vec); if(gc.top[-1].type!=vm_vec) die("slcbegin: must slice a vector"); } inline void nasal_vm::opr_slcend() { gc.top[-1]=gc.top[0]; --gc.top; } inline void nasal_vm::opr_slc() { nasal_ref val=(gc.top--)[0]; nasal_ref res=gc.top[-1].vec()->get_val(val.to_number()); if(res.type==vm_none) die("slc: index out of range:"+std::to_string(val.to_number())); gc.top[0].vec()->elems.push_back(res); } inline void nasal_vm::opr_slc2() { nasal_ref val2=(gc.top--)[0]; nasal_ref val1=(gc.top--)[0]; std::vector<nasal_ref>& ref=gc.top[-1].vec()->elems; std::vector<nasal_ref>& aim=gc.top[0].vec()->elems; uint8_t type1=val1.type,type2=val2.type; int num1=val1.to_number(); int num2=val2.to_number(); int size=ref.size(); if(type1==vm_nil && type2==vm_nil) { num1=0; num2=size-1; } else if(type1==vm_nil && type2!=vm_nil) num1=num2<0? -size:0; else if(type1!=vm_nil && type2==vm_nil) num2=num1<0? -1:size-1; if(num1>=num2) die("slc2: begin index must be less than end index"); else if(num1<-size || num1>=size) die("slc2: begin index out of range: "+std::to_string(num1)); else if(num2<-size || num2>=size) die("slc2: end index out of range: "+std::to_string(num2)); else for(int i=num1;i<=num2;++i) aim.push_back(i>=0?ref[i]:ref[i+size]); } inline void nasal_vm::opr_mcallg() { mem_addr=gc.stack+imm[pc]; (++gc.top)[0]=mem_addr[0]; } inline void nasal_vm::opr_mcalll() { mem_addr=&(gc.local.back().vec()->elems[imm[pc]]); (++gc.top)[0]=mem_addr[0]; } inline void nasal_vm::opr_mupval() { mem_addr=&func_stk.top()->upvalue[(imm[pc]>>16)&0xffff].vec()->elems[imm[pc]&0xffff]; (++gc.top)[0]=mem_addr[0]; } inline void nasal_vm::opr_mcallv() { nasal_ref val=gc.top[0]; nasal_ref vec=(--gc.top)[0]; if(vec.type==vm_vec) { mem_addr=vec.vec()->get_mem(val.to_number()); if(!mem_addr) die("mcallv: index out of range:"+std::to_string(val.to_number())); } else if(vec.type==vm_hash) { if(val.type!=vm_str) die("mcallv: must use string as the key"); nasal_hash& ref=*vec.hash(); std::string& str=*val.str(); mem_addr=ref.get_mem(str); if(!mem_addr) { ref.elems[str]={vm_nil}; mem_addr=ref.get_mem(str); } } else die("mcallv: cannot get memory space in other types"); } inline void nasal_vm::opr_mcallh() { nasal_ref hash=gc.top[0]; if(hash.type!=vm_hash) die("mcallh: must call a hash"); nasal_hash& ref=*hash.hash(); const std::string& str=str_table[imm[pc]]; mem_addr=ref.get_mem(str); if(!mem_addr) // create a new key { ref.elems[str]={vm_nil}; mem_addr=ref.get_mem(str); } } inline void nasal_vm::opr_ret() { // | return value | <- gc.top[0] // +-----------------+ // | return address | <- gc.top[-1] // +-----------------+ // | called function | <- gc.top[-2] funct is set on stack because gc may mark it // +-----------------+ pc=gc.top[-1].ret(); gc.top[-2].func()->local[0]={vm_nil,nullptr}; // get func and set 'me' to nil gc.top[-2]=gc.top[0]; // rewrite func with returned value gc.top-=2; func_stk.pop(); gc.local.pop_back(); } void nasal_vm::run( const nasal_codegen& gen, const nasal_import& linker, const bool opcnt, const bool debug) { detail_info=debug; init(gen.get_strs(),gen.get_nums(),linker.get_file()); uint64_t count[op_exit+1]={0}; const void* opr_table[]= { &&nop, &&intg, &&intl, &&loadg, &&loadl, &&loadu, &&pnum, &&pone, &&pzero, &&pnil, &&pstr, &&newv, &&newh, &&newf, &&happ, &&para, &&defpara, &&dynpara, &&unot, &&usub, &&add, &&sub, &&mul, &&div, &&lnk, &&addc, &&subc, &&mulc, &&divc, &&lnkc, &&addeq, &&subeq, &&muleq, &&diveq, &&lnkeq, &&addeqc, &&subeqc, &&muleqc, &&diveqc, &&lnkeqc, &&meq, &&eq, &&neq, &&less, &&leq, &&grt, &&geq, &&lessc, &&leqc, &&grtc, &&geqc, &&pop, &&jmp, &&jt, &&jf, &&counter, &&findex, &&feach, &&callg, &&calll, &&upval, &&callv, &&callvi, &&callh, &&callfv, &&callfh, &&callb, &&slcbegin, &&slcend, &&slc, &&slc2, &&mcallg, &&mcalll, &&mupval, &&mcallv, &&mcallh, &&ret, &&vmexit }; bytecode=gen.get_code().data(); std::vector<const void*> code; for(auto& i:gen.get_code()) { code.push_back(opr_table[i.op]); imm.push_back(i.num); } // set canary and program counter auto canary=gc.stack+STACK_MAX_DEPTH-1; pc=0; // goto the first operand goto *code[pc]; vmexit: if(gc.top>=canary) die("stack overflow"); if(opcnt) opcallsort(count); gc.clear(); imm.clear(); return; // may cause stackoverflow #define exec_operand(op,num) {op();++count[num];if(gc.top<canary)goto *code[++pc];goto vmexit;} // do not cause stackoverflow #define exec_opnodie(op,num) {op();++count[num];goto *code[++pc];} nop: exec_opnodie(opr_nop ,op_nop ); // 0 intg: exec_opnodie(opr_intg ,op_intg ); // +imm[pc] (detected at codegen) intl: exec_opnodie(opr_intl ,op_intl ); // -0 loadg: exec_opnodie(opr_loadg ,op_loadg ); // -1 loadl: exec_opnodie(opr_loadl ,op_loadl ); // -1 loadu: exec_opnodie(opr_loadu ,op_loadu ); // -1 pnum: exec_operand(opr_pnum ,op_pnum ); // +1 pone: exec_operand(opr_pone ,op_pone ); // +1 pzero: exec_operand(opr_pzero ,op_pzero ); // +1 pnil: exec_operand(opr_pnil ,op_pnil ); // +1 pstr: exec_operand(opr_pstr ,op_pstr ); // +1 newv: exec_operand(opr_newv ,op_newv ); // +1-imm[pc] newh: exec_operand(opr_newh ,op_newh ); // +1 newf: exec_operand(opr_newf ,op_newf ); // +1 happ: exec_opnodie(opr_happ ,op_happ ); // -1 para: exec_opnodie(opr_para ,op_para ); // -0 defpara: exec_opnodie(opr_defpara ,op_defpara ); // -1 dynpara: exec_opnodie(opr_dynpara ,op_dynpara ); // -0 unot: exec_opnodie(opr_unot ,op_unot ); // -0 usub: exec_opnodie(opr_usub ,op_usub ); // -0 add: exec_opnodie(opr_add ,op_add ); // -1 sub: exec_opnodie(opr_sub ,op_sub ); // -1 mul: exec_opnodie(opr_mul ,op_mul ); // -1 div: exec_opnodie(opr_div ,op_div ); // -1 lnk: exec_opnodie(opr_lnk ,op_lnk ); // -1 addc: exec_opnodie(opr_addc ,op_addc ); // -0 subc: exec_opnodie(opr_subc ,op_subc ); // -0 mulc: exec_opnodie(opr_mulc ,op_mulc ); // -0 divc: exec_opnodie(opr_divc ,op_divc ); // -0 lnkc: exec_opnodie(opr_lnkc ,op_lnkc ); // -0 addeq: exec_opnodie(opr_addeq ,op_addeq ); // -1 subeq: exec_opnodie(opr_subeq ,op_subeq ); // -1 muleq: exec_opnodie(opr_muleq ,op_muleq ); // -1 diveq: exec_opnodie(opr_diveq ,op_diveq ); // -1 lnkeq: exec_opnodie(opr_lnkeq ,op_lnkeq ); // -1 addeqc: exec_opnodie(opr_addeqc ,op_addeqc ); // -0 subeqc: exec_opnodie(opr_subeqc ,op_subeqc ); // -0 muleqc: exec_opnodie(opr_muleqc ,op_muleqc ); // -0 diveqc: exec_opnodie(opr_diveqc ,op_diveqc ); // -0 lnkeqc: exec_opnodie(opr_lnkeqc ,op_lnkeqc ); // -0 meq: exec_opnodie(opr_meq ,op_meq ); // -1 eq: exec_opnodie(opr_eq ,op_eq ); // -1 neq: exec_opnodie(opr_neq ,op_neq ); // -1 less: exec_opnodie(opr_less ,op_less ); // -1 leq: exec_opnodie(opr_leq ,op_leq ); // -1 grt: exec_opnodie(opr_grt ,op_grt ); // -1 geq: exec_opnodie(opr_geq ,op_geq ); // -1 lessc: exec_opnodie(opr_lessc ,op_lessc ); // -0 leqc: exec_opnodie(opr_leqc ,op_leqc ); // -0 grtc: exec_opnodie(opr_grtc ,op_grtc ); // -0 geqc: exec_opnodie(opr_geqc ,op_geqc ); // -0 pop: exec_opnodie(opr_pop ,op_pop ); // -1 jmp: exec_opnodie(opr_jmp ,op_jmp ); // -0 jt: exec_opnodie(opr_jt ,op_jt ); // -0 jf: exec_opnodie(opr_jf ,op_jf ); // -1 counter: exec_opnodie(opr_counter ,op_cnt ); // -0 findex: exec_operand(opr_findex ,op_findex ); // +1 feach: exec_operand(opr_feach ,op_feach ); // +1 callg: exec_operand(opr_callg ,op_callg ); // +1 calll: exec_operand(opr_calll ,op_calll ); // +1 upval: exec_operand(opr_upval ,op_upval ); // +1 callv: exec_opnodie(opr_callv ,op_callv ); // -0 callvi: exec_opnodie(opr_callvi ,op_callvi ); // -0 callh: exec_opnodie(opr_callh ,op_callh ); // -0 callfv: exec_operand(opr_callfv ,op_callfv ); // +1-imm[pc] call this will push >=0 arguments callfh: exec_opnodie(opr_callfh ,op_callfh ); // -0 call this will push one hash callb: exec_opnodie(opr_callb ,op_callb ); // -0 slcbegin:exec_operand(opr_slcbegin,op_slcbegin); // +1 slcend: exec_opnodie(opr_slcend ,op_slcend ); // -1 slc: exec_opnodie(opr_slc ,op_slc ); // -1 slc2: exec_opnodie(opr_slc2 ,op_slc2 ); // -2 mcallg: exec_operand(opr_mcallg ,op_mcallg ); // +1 mcalll: exec_operand(opr_mcalll ,op_mcalll ); // +1 mupval: exec_operand(opr_mupval ,op_mupval ); // +1 mcallv: exec_opnodie(opr_mcallv ,op_mcallv ); // -0 mcallh: exec_opnodie(opr_mcallh ,op_mcallh ); // -0 ret: exec_opnodie(opr_ret ,op_ret ); // -1 } #endif
31.315957
109
0.583347
b7fcdd9a6051b06c53be91d2e2dd621ee408947b
210
h
C
ios/GoGreen2/ContainerView.h
EdgeCaseBerg/GreenUp
c173298ee90ef7ed4a589cb24287607f1d614468
[ "MIT" ]
null
null
null
ios/GoGreen2/ContainerView.h
EdgeCaseBerg/GreenUp
c173298ee90ef7ed4a589cb24287607f1d614468
[ "MIT" ]
null
null
null
ios/GoGreen2/ContainerView.h
EdgeCaseBerg/GreenUp
c173298ee90ef7ed4a589cb24287607f1d614468
[ "MIT" ]
null
null
null
// // CustomContainerView.h // GoGreen // // Created by Aidan Melen on 7/12/13. // Copyright (c) 2013 Aidan Melen. All rights reserved. // #import <UIKit/UIKit.h> @interface ContainerView : UIView @end
14
56
0.67619
4d00db651c3a5e96afdef23825a221347fac3fb4
2,008
h
C
emr/include/alibabacloud/emr/model/ListFlowProjectClusterSettingResult.h
iamzken/aliyun-openapi-cpp-sdk
3c991c9ca949b6003c8f498ce7a672ea88162bf1
[ "Apache-2.0" ]
3
2020-01-06T08:23:14.000Z
2022-01-22T04:41:35.000Z
emr/include/alibabacloud/emr/model/ListFlowProjectClusterSettingResult.h
sdk-team/aliyun-openapi-cpp-sdk
d0e92f6f33126dcdc7e40f60582304faf2c229b7
[ "Apache-2.0" ]
null
null
null
emr/include/alibabacloud/emr/model/ListFlowProjectClusterSettingResult.h
sdk-team/aliyun-openapi-cpp-sdk
d0e92f6f33126dcdc7e40f60582304faf2c229b7
[ "Apache-2.0" ]
1
2020-11-27T09:13:12.000Z
2020-11-27T09:13:12.000Z
/* * Copyright 2009-2017 Alibaba Cloud All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ALIBABACLOUD_EMR_MODEL_LISTFLOWPROJECTCLUSTERSETTINGRESULT_H_ #define ALIBABACLOUD_EMR_MODEL_LISTFLOWPROJECTCLUSTERSETTINGRESULT_H_ #include <string> #include <vector> #include <utility> #include <alibabacloud/core/ServiceResult.h> #include <alibabacloud/emr/EmrExport.h> namespace AlibabaCloud { namespace Emr { namespace Model { class ALIBABACLOUD_EMR_EXPORT ListFlowProjectClusterSettingResult : public ServiceResult { public: struct ClusterSetting { long gmtCreate; std::string defaultUser; std::string defaultQueue; std::string clusterId; long gmtModified; std::string projectId; std::string clusterName; std::vector<std::string> hostList; std::vector<std::string> userList; std::vector<std::string> queueList; }; ListFlowProjectClusterSettingResult(); explicit ListFlowProjectClusterSettingResult(const std::string &payload); ~ListFlowProjectClusterSettingResult(); std::vector<ClusterSetting> getClusterSettings()const; int getPageSize()const; int getPageNumber()const; int getTotal()const; protected: void parse(const std::string &payload); private: std::vector<ClusterSetting> clusterSettings_; int pageSize_; int pageNumber_; int total_; }; } } } #endif // !ALIBABACLOUD_EMR_MODEL_LISTFLOWPROJECTCLUSTERSETTINGRESULT_H_
28.685714
91
0.74004
4d00e9329a7b6ad3b8a4dc19766b6b4b739cf4ab
278
h
C
Example/XOChatModule/XOChatAppDelegate.h
Hjt830/XOChatModule
d5dcf1f9e28acc162d45688687e888e11cd75fb9
[ "MIT" ]
null
null
null
Example/XOChatModule/XOChatAppDelegate.h
Hjt830/XOChatModule
d5dcf1f9e28acc162d45688687e888e11cd75fb9
[ "MIT" ]
null
null
null
Example/XOChatModule/XOChatAppDelegate.h
Hjt830/XOChatModule
d5dcf1f9e28acc162d45688687e888e11cd75fb9
[ "MIT" ]
null
null
null
// // XOChatAppDelegate.h // XOChatModule // // Created by kenter on 07/03/2019. // Copyright (c) 2019 kenter. All rights reserved. // @import UIKit; @interface XOChatAppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end
17.375
66
0.723022
4d012d7ac2e2f9f38f1835f024af7188b1caddce
5,982
h
C
source/utils/network/network_serializer.h
gummikana/poro
70162aca06ca5a1d4f92b8d01728e1764e4c6873
[ "Zlib" ]
3
2015-02-09T15:31:32.000Z
2022-03-06T20:49:48.000Z
source/utils/network/network_serializer.h
gummikana/poro
70162aca06ca5a1d4f92b8d01728e1764e4c6873
[ "Zlib" ]
null
null
null
source/utils/network/network_serializer.h
gummikana/poro
70162aca06ca5a1d4f92b8d01728e1764e4c6873
[ "Zlib" ]
2
2019-09-26T22:00:16.000Z
2019-10-03T22:02:43.000Z
/*************************************************************************** * * Copyright (c) 2003 - 2011 Petri Purho * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. * ***************************************************************************/ #ifndef INC_NETWORK_SERIALIZER_H #define INC_NETWORK_SERIALIZER_H #include "network_utils.h" #include <vector> namespace network_utils { class ISerializer { public: virtual ~ISerializer() { } virtual bool IsSaving() const = 0; virtual bool IsLoading() const { return !IsSaving(); } virtual bool HasOverflowed() const = 0; virtual void IO( uint8 &value ) = 0; virtual void IO( uint32 &value ) = 0; virtual void IO( int32 &value ) = 0; virtual void IO( float32 &value ) = 0; virtual void IO( bool &value ) = 0; virtual void IO( types::ustring& str ) = 0; template< typename T > void IO( std::vector< T >& vector ) { uint32 size = vector.size(); IO( size ); if( HasOverflowed() ) return; if( IsLoading() ) vector.resize( size ); for( uint32 i = 0; i < size; ++i ) { T temp_var = vector[ i ]; this->IO( temp_var ); if( IsLoading() ) vector[ i ] = temp_var; } } #ifdef NETWORK_USE_VECTOR2 template< typename T > void IO( ceng::math::CVector2< T >& vector2 ) { T x = vector2.x; T y = vector2.y; IO( x ); IO( y ); if( IsLoading() ) { vector2.x = x; vector2.y = y; } } #endif }; //------------------------------------------------------------------------- class CSerialSaver : virtual public ISerializer { protected: types::ustring mBuffer; uint32 mLength; uint32 mBytesUsed; bool mHasOverflowed; public: CSerialSaver() { // buffer=buf; length=size; bytesUsed=0; bHasOverflowed=false; mLength = 1024; mBytesUsed = 0; mHasOverflowed = false; } void IO( uint8& value ) { if( mHasOverflowed ) return; //stop writing when overflowed mBuffer += value; ++mBytesUsed; } void IO( uint32& value ) { if( mHasOverflowed ) return; //stop writing when overflowed mBuffer += ConvertUint32ToHex( value ); mBytesUsed += 4; } virtual void IO( int32& value ) { if( mHasOverflowed ) return; //stop writing when overflowed mBuffer += ConvertInt32ToHex( value ); mBytesUsed += 4; } void IO( float32& value ) { if( mHasOverflowed ) return; //stop writing when overflowed mBuffer += FloatToHexString( value ); mBytesUsed += 4; } void IO( bool& value ) { if( mHasOverflowed ) return; //stop writing when overflowed uint8 v = (value)?1:0; IO( v ); } void IO( types::ustring& str ) { uint32 l = str.length(); IO(l); if( mHasOverflowed ) return; mBuffer += str; mBytesUsed +=l; } void IO( const types::ustring& str ) { uint32 l = str.length(); IO(l); if( mHasOverflowed ) return; mBuffer += str; mBytesUsed +=l; } bool HasOverflowed() const { return mHasOverflowed; } bool IsSaving() const { return true; } const types::ustring& GetData() const { return mBuffer; } }; //------------------------------------------------------------------------- class CSerialLoader : virtual public ISerializer { protected: types::ustring mBuffer; uint32 mBytesUsed; uint32 mLength; bool mHasOverflowed; public: CSerialLoader( const types::ustring& buf ) { mBuffer = buf; mBytesUsed = 0; mHasOverflowed = false; mLength = mBuffer.size(); } void Reset() { mBytesUsed = 0; mHasOverflowed = false; } void IO( uint8& value ) { if( mHasOverflowed ) return; if( mBytesUsed+1 > mLength ) { mHasOverflowed = true; return; } value = mBuffer[ mBytesUsed ]; ++mBytesUsed; } void IO( uint32& value ) { if( mHasOverflowed ) return; if( mBytesUsed + 4 > mLength ) { mHasOverflowed = true; return; } value = ConvertHexToUint32( mBuffer.substr( mBytesUsed, 4 ) ); mBytesUsed += 4; } virtual void IO( int32& value ) { if( mHasOverflowed ) return; if( mBytesUsed + 4 > mLength ) { mHasOverflowed = true; return; } value = ConvertHexToInt32( mBuffer.substr( mBytesUsed, 4 ) ); mBytesUsed += 4; } void IO( float32& value ) { if( mHasOverflowed ) return; if( mBytesUsed + 4 > mLength ) { mHasOverflowed = true; return; } value = HexStringToFloat( mBuffer.substr( mBytesUsed, 4 ) ); mBytesUsed += 4; } void IO( bool& value ) { uint8 v = 0; IO( v ); if( mHasOverflowed ) return; value = (v != 0)?1:0; } void IO( types::ustring& str ) { uint32 len = 0; IO( len ); if( mHasOverflowed ) return; if( mBytesUsed + len > mLength ) { mHasOverflowed = true; return; } str = mBuffer.substr( mBytesUsed, len ); mBytesUsed += len; } bool HasOverflowed() const { return mHasOverflowed; } bool IsSaving() const { return false; } }; //------------------------------------------------------------------------- } // end o namespace network utils // -------------- types --------------------------- namespace types { typedef network_utils::ISerializer bit_serialize; } // end of namespace types #endif
23.186047
77
0.59562
4d014d6e806835e15e5dcacb614dacb8b21fef8c
2,244
h
C
src/Emulators/vice/root/embedded.h
slajerek/RetroDebugger
e761e4f9efd103a05e65ef283423b142fa4324c7
[ "Apache-2.0", "MIT" ]
34
2021-05-29T07:04:17.000Z
2022-03-10T20:16:03.000Z
src/Emulators/vice/root/embedded.h
slajerek/RetroDebugger
e761e4f9efd103a05e65ef283423b142fa4324c7
[ "Apache-2.0", "MIT" ]
6
2021-12-25T13:05:21.000Z
2022-01-19T17:35:17.000Z
src/Emulators/vice/root/embedded.h
slajerek/RetroDebugger
e761e4f9efd103a05e65ef283423b142fa4324c7
[ "Apache-2.0", "MIT" ]
6
2021-12-24T18:37:41.000Z
2022-02-06T23:06:02.000Z
/* * embedded.h - Code for embedding data files * * This feature is only active when --enable-embedded is given to the * configure script, its main use is to make developing new ports easier * and to allow ports for platforms which don't have a filesystem, or a * filesystem which is hard/impossible to load data files from. * * Written by * Marco van den Heuvel <blackystardust68@yahoo.com> * * This file is part of VICE, the Versatile Commodore Emulator. * See README for copyright notice. * * 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 VICE_EMBEDDED_H #define VICE_EMBEDDED_H #include "vice.h" #include "types.h" #include "palette.h" #ifdef USE_EMBEDDED extern size_t embedded_check_file(const char *name, BYTE *dest, int minsize, int maxsize); extern size_t embedded_check_extra(const char *name, BYTE *dest, int minsize, int maxsize); extern int embedded_palette_load(const char *file_name, palette_t *palette_return); #else #define embedded_check_file(w, x, y, z) (0) #define embedded_palette_load(x, y) (-1) #endif typedef struct embedded_s { char *name; int minsize; int maxsize; size_t size; BYTE *esrc; } embedded_t; typedef struct embedded_palette_s { char *name1; char *name2; int num_entries; unsigned char *palette; } embedded_palette_t; /** \brief Proper terminator for embedded_t lists */ #define EMBEDDED_LIST_END { NULL, 0, 0, 0, NULL } /** \brief Proper terminator for embedded_palette_t lists */ #define EMBEDDED_PALETTE_LIST_END { NULL, NULL, 0, NULL } #endif
29.92
91
0.73262
4d0150c242242538c2f1556c5185b1e861b4df06
12,448
h
C
sources/cipher.h
akscf/mod_udptun
16b45d7f910b57c0eff4ed60d70e4504ce6d1d02
[ "BSD-3-Clause" ]
5
2021-04-23T10:48:42.000Z
2022-01-18T11:17:43.000Z
sources/cipher.h
akscf/mod_udptun
16b45d7f910b57c0eff4ed60d70e4504ce6d1d02
[ "BSD-3-Clause" ]
1
2021-04-23T10:49:37.000Z
2021-04-23T12:47:02.000Z
sources/cipher.h
akscf/mod_udptun
16b45d7f910b57c0eff4ed60d70e4504ce6d1d02
[ "BSD-3-Clause" ]
null
null
null
/** * a simple stream cipher based on RC4 * * Copyright (C) AlexandrinKS * https://akscf.me/ **/ #ifndef UDPTUN_CIPHER_H #define UDPTUN_CIPHER_H #include <string.h> #include <unistd.h> #include <stdint.h> static const uint32_t bf_s_box[4][256] = { { 0xD1310BA6,0x98DFB5AC,0x2FFD72DB,0xD01ADFB7,0xB8E1AFED,0x6A267E96,0xBA7C9045,0xF12C7F99, 0x24A19947,0xB3916CF7,0x0801F2E2,0x858EFC16,0x636920D8,0x71574E69,0xA458FEA3,0xF4933D7E, 0x0D95748F,0x728EB658,0x718BCD58,0x82154AEE,0x7B54A41D,0xC25A59B5,0x9C30D539,0x2AF26013, 0xC5D1B023,0x286085F0,0xCA417918,0xB8DB38EF,0x8E79DCB0,0x603A180E,0x6C9E0E8B,0xB01E8A3E, 0xD71577C1,0xBD314B27,0x78AF2FDA,0x55605C60,0xE65525F3,0xAA55AB94,0x57489862,0x63E81440, 0x55CA396A,0x2AAB10B6,0xB4CC5C34,0x1141E8CE,0xA15486AF,0x7C72E993,0xB3EE1411,0x636FBC2A, 0x2BA9C55D,0x741831F6,0xCE5C3E16,0x9B87931E,0xAFD6BA33,0x6C24CF5C,0x7A325381,0x28958677, 0x3B8F4898,0x6B4BB9AF,0xC4BFE81B,0x66282193,0x61D809CC,0xFB21A991,0x487CAC60,0x5DEC8032, 0xEF845D5D,0xE98575B1,0xDC262302,0xEB651B88,0x23893E81,0xD396ACC5,0x0F6D6FF3,0x83F44239, 0x2E0B4482,0xA4842004,0x69C8F04A,0x9E1F9B5E,0x21C66842,0xF6E96C9A,0x670C9C61,0xABD388F0, 0x6A51A0D2,0xD8542F68,0x960FA728,0xAB5133A3,0x6EEF0B6C,0x137A3BE4,0xBA3BF050,0x7EFB2A98, 0xA1F1651D,0x39AF0176,0x66CA593E,0x82430E88,0x8CEE8619,0x456F9FB4,0x7D84A5C3,0x3B8B5EBE, 0xE06F75D8,0x85C12073,0x401A449F,0x56C16AA6,0x4ED3AA62,0x363F7706,0x1BFEDF72,0x429B023D, 0x37D0D724,0xD00A1248,0xDB0FEAD3,0x49F1C09B,0x075372C9,0x80991B7B,0x25D479D8,0xF6E8DEF7, 0xE3FE501A,0xB6794C3B,0x976CE0BD,0x04C006BA,0xC1A94FB6,0x409F60C4,0x5E5C9EC2,0x196A2463, 0x68FB6FAF,0x3E6C53B5,0x1339B2EB,0x3B52EC6F,0x6DFC511F,0x9B30952C,0xCC814544,0xAF5EBD09, 0xBEE3D004,0xDE334AFD,0x660F2807,0x192E4BB3,0xC0CBA857,0x45C8740F,0xD20B5F39,0xB9D3FBDB, 0x5579C0BD,0x1A60320A,0xD6A100C6,0x402C7279,0x679F25FE,0xFB1FA3CC,0x8EA5E9F8,0xDB3222F8, 0x3C7516DF,0xFD616B15,0x2F501EC8,0xAD0552AB,0x323DB5FA,0xFD238760,0x53317B48,0x3E00DF82, 0x9E5C57BB,0xCA6F8CA0,0x1A87562E,0xDF1769DB,0xD542A8F6,0x287EFFC3,0xAC6732C6,0x8C4F5573, 0x695B27B0,0xBBCA58C8,0xE1FFA35D,0xB8F011A0,0x10FA3D98,0xFD2183B8,0x4AFCB56C,0x2DD1D35B, 0x9A53E479,0xB6F84565,0xD28E49BC,0x4BFB9790,0xE1DDF2DA,0xA4CB7E33,0x62FB1341,0xCEE4C6E8, 0xEF20CADA,0x36774C01,0xD07E9EFE,0x2BF11FB4,0x95DBDA4D,0xAE909198,0xEAAD8E71,0x6B93D5A0, 0xD08ED1D0,0xAFC725E0,0x8E3C5B2F,0x8E7594B7,0x8FF6E2FB,0xF2122B64,0x8888B812,0x900DF01C, 0x4FAD5EA0,0x688FC31C,0xD1CFF191,0xB3A8C1AD,0x2F2F2218,0xBE0E1777,0xEA752DFE,0x8B021FA1, 0xE5A0CC0F,0xB56F74E8,0x18ACF3D6,0xCE89E299,0xB4A84FE0,0xFD13E0B7,0x7CC43B81,0xD2ADA8D9, 0x165FA266,0x80957705,0x93CC7314,0x211A1477,0xE6AD2065,0x77B5FA86,0xC75442F5,0xFB9D35CF, 0xEBCDAF0C,0x7B3E89A0,0xD6411BD3,0xAE1E7E49,0x00250E2D,0x2071B35E,0x226800BB,0x57B8E0AF, 0x2464369B,0xF009B91E,0x5563911D,0x59DFA6AA,0x78C14389,0xD95A537F,0x207D5BA2,0x02E5B9C5, 0x83260376,0x6295CFA9,0x11C81968,0x4E734A41,0xB3472DCA,0x7B14A94A,0x1B510052,0x9A532915, 0xD60F573F,0xBC9BC6E4,0x2B60A476,0x81E67400,0x08BA6FB5,0x571BE91F,0xF296EC6B,0x2A0DD915, 0xB6636521,0xE7B9F9B6,0xFF34052E,0xC5855664,0x53B02D5D,0xA99F8FA1,0x08BA4799,0x6E85076A },{ 0x4B7A70E9,0xB5B32944,0xDB75092E,0xC4192623,0xAD6EA6B0,0x49A7DF7D,0x9CEE60B8,0x8FEDB266, 0xECAA8C71,0x699A17FF,0x5664526C,0xC2B19EE1,0x193602A5,0x75094C29,0xA0591340,0xE4183A3E, 0x3F54989A,0x5B429D65,0x6B8FE4D6,0x99F73FD6,0xA1D29C07,0xEFE830F5,0x4D2D38E6,0xF0255DC1, 0x4CDD2086,0x8470EB26,0x6382E9C6,0x021ECC5E,0x09686B3F,0x3EBAEFC9,0x3C971814,0x6B6A70A1, 0x687F3584,0x52A0E286,0xB79C5305,0xAA500737,0x3E07841C,0x7FDEAE5C,0x8E7D44EC,0x5716F2B8, 0xB03ADA37,0xF0500C0D,0xF01C1F04,0x0200B3FF,0xAE0CF51A,0x3CB574B2,0x25837A58,0xDC0921BD, 0xD19113F9,0x7CA92FF6,0x94324773,0x22F54701,0x3AE5E581,0x37C2DADC,0xC8B57634,0x9AF3DDA7, 0xA9446146,0x0FD0030E,0xECC8C73E,0xA4751E41,0xE238CD99,0x3BEA0E2F,0x3280BBA1,0x183EB331, 0x4E548B38,0x4F6DB908,0x6F420D03,0xF60A04BF,0x2CB81290,0x24977C79,0x5679B072,0xBCAF89AF, 0xDE9A771F,0xD9930810,0xB38BAE12,0xDCCF3F2E,0x5512721F,0x2E6B7124,0x501ADDE6,0x9F84CD87, 0x7A584718,0x7408DA17,0xBC9F9ABC,0xE94B7D8C,0xEC7AEC3A,0xDB851DFA,0x63094366,0xC464C3D2, 0xEF1C1847,0x3215D908,0xDD433B37,0x24C2BA16,0x12A14D43,0x2A65C451,0x50940002,0x133AE4DD, 0x71DFF89E,0x10314E55,0x81AC77D6,0x5F11199B,0x043556F1,0xD7A3C76B,0x3C11183B,0x5924A509, 0xF28FE6ED,0x97F1FBFA,0x9EBABF2C,0x1E153C6E,0x86E34570,0xEAE96FB1,0x860E5E0A,0x5A3E2AB3, 0x771FE71C,0x4E3D06FA,0x2965DCB9,0x99E71D0F,0x803E89D6,0x5266C825,0x2E4CC978,0x9C10B36A, 0xC6150EBA,0x94E2EA78,0xA5FC3C53,0x1E0A2DF4,0xF2F74EA7,0x361D2B3D,0x1939260F,0x19C27960, 0x5223A708,0xF71312B6,0xEBADFE6E,0xEAC31F66,0xE3BC4595,0xA67BC883,0xB17F37D1,0x018CFF28, 0xC332DDEF,0xBE6C5AA5,0x65582185,0x68AB9802,0xEECEA50F,0xDB2F953B,0x2AEF7DAD,0x5B6E2F84, 0x1521B628,0x29076170,0xECDD4775,0x619F1510,0x13CCA830,0xEB61BD96,0x0334FE1E,0xAA0363CF, 0xB5735C90,0x4C70A239,0xD59E9E0B,0xCBAADE14,0xEECC86BC,0x60622CA7,0x9CAB5CAB,0xB2F3846E, 0x648B1EAF,0x19BDF0CA,0xA02369B9,0x655ABB50,0x40685A32,0x3C2AB4B3,0x319EE9D5,0xC021B8F7, 0x9B540B19,0x875FA099,0x95F7997E,0x623D7DA8,0xF837889A,0x97E32D77,0x11ED935F,0x16681281, 0x0E358829,0xC7E61FD6,0x96DEDFA1,0x7858BA99,0x57F584A5,0x1B227263,0x9B83C3FF,0x1AC24696, 0xCDB30AEB,0x532E3054,0x8FD948E4,0x6DBC3128,0x58EBF2EF,0x34C6FFEA,0xFE28ED61,0xEE7C3C73, 0x5D4A14D9,0xE864B7E3,0x42105D14,0x203E13E0,0x45EEE2B6,0xA3AAABEA,0xDB6C4F15,0xFACB4FD0, 0xC742F442,0xEF6ABBB5,0x654F3B1D,0x41CD2105,0xD81E799E,0x86854DC7,0xE44B476A,0x3D816250, 0xCF62A1F2,0x5B8D2646,0xFC8883A0,0xC1C7B6A3,0x7F1524C3,0x69CB7492,0x47848A0B,0x5692B285, 0x095BBF00,0xAD19489D,0x1462B174,0x23820E00,0x58428D2A,0x0C55F5EA,0x1DADF43E,0x233F7061, 0x3372F092,0x8D937E41,0xD65FECF1,0x6C223BDB,0x7CDE3759,0xCBEE7460,0x4085F2A7,0xCE77326E, 0xA6078084,0x19F8509E,0xE8EFD855,0x61D99735,0xA969A7AA,0xC50C06C2,0x5A04ABFC,0x800BCADC, 0x9E447A2E,0xC3453484,0xFDD56705,0x0E1E9EC9,0xDB73DBD3,0x105588CD,0x675FDA79,0xE3674340, 0xC5C43465,0x713E38D8,0x3D28F89E,0xF16DFF20,0x153E21E7,0x8FB03D4A,0xE6E39F2B,0xDB83ADF7 },{ 0xE93D5A68,0x948140F7,0xF64C261C,0x94692934,0x411520F7,0x7602D4F7,0xBCF46B2E,0xD4A20068, 0xD4082471,0x3320F46A,0x43B7D4B7,0x500061AF,0x1E39F62E,0x97244546,0x14214F74,0xBF8B8840, 0x4D95FC1D,0x96B591AF,0x70F4DDD3,0x66A02F45,0xBFBC09EC,0x03BD9785,0x7FAC6DD0,0x31CB8504, 0x96EB27B3,0x55FD3941,0xDA2547E6,0xABCA0A9A,0x28507825,0x530429F4,0x0A2C86DA,0xE9B66DFB, 0x68DC1462,0xD7486900,0x680EC0A4,0x27A18DEE,0x4F3FFEA2,0xE887AD8C,0xB58CE006,0x7AF4D6B6, 0xAACE1E7C,0xD3375FEC,0xCE78A399,0x406B2A42,0x20FE9E35,0xD9F385B9,0xEE39D7AB,0x3B124E8B, 0x1DC9FAF7,0x4B6D1856,0x26A36631,0xEAE397B2,0x3A6EFA74,0xDD5B4332,0x6841E7F7,0xCA7820FB, 0xFB0AF54E,0xD8FEB397,0x454056AC,0xBA489527,0x55533A3A,0x20838D87,0xFE6BA9B7,0xD096954B, 0x55A867BC,0xA1159A58,0xCCA92963,0x99E1DB33,0xA62A4A56,0x3F3125F9,0x5EF47E1C,0x9029317C, 0xFDF8E802,0x04272F70,0x80BB155C,0x05282CE3,0x95C11548,0xE4C66D22,0x48C1133F,0xC70F86DC, 0x07F9C9EE,0x41041F0F,0x404779A4,0x5D886E17,0x325F51EB,0xD59BC0D1,0xF2BCC18F,0x41113564, 0x257B7834,0x602A9C60,0xDFF8E8A3,0x1F636C1B,0x0E12B4C2,0x02E1329E,0xAF664FD1,0xCAD18115, 0x6B2395E0,0x333E92E1,0x3B240B62,0xEEBEB922,0x85B2A20E,0xE6BA0D99,0xDE720C8C,0x2DA2F728, 0xD0127845,0x95B794FD,0x647D0862,0xE7CCF5F0,0x5449A36F,0x877D48FA,0xC39DFD27,0xF33E8D1E, 0x0A476341,0x992EFF74,0x3A6F6EAB,0xF4F8FD37,0xA812DC60,0xA1EBDDF8,0x991BE14C,0xDB6E6B0D, 0xC67B5510,0x6D672C37,0x2765D43B,0xDCD0E804,0xF1290DC7,0xCC00FFA3,0xB5390F92,0x690FED0B, 0x667B9FFB,0xCEDB7D9C,0xA091CF0B,0xD9155EA3,0xBB132F88,0x515BAD24,0x7B9479BF,0x763BD6EB, 0x37392EB3,0xCC115979,0x8026E297,0xF42E312D,0x6842ADA7,0xC66A2B3B,0x12754CCC,0x782EF11C, 0x6A124237,0xB79251E7,0x06A1BBE6,0x4BFB6350,0x1A6B1018,0x11CAEDFA,0x3D25BDD8,0xE2E1C3C9, 0x44421659,0x0A121386,0xD90CEC6E,0xD5ABEA2A,0x64AF674E,0xDA86A85F,0xBEBFE988,0x64E4C3FE, 0x9DBC8057,0xF0F7C086,0x60787BF8,0x6003604D,0xD1FD8346,0xF6381FB0,0x7745AE04,0xD736FCCC, 0x83426B33,0xF01EAB71,0xB0804187,0x3C005E5F,0x77A057BE,0xBDE8AE24,0x55464299,0xBF582E61, 0x4E58F48F,0xF2DDFDA2,0xF474EF38,0x8789BDC2,0x5366F9C3,0xC8B38E74,0xB475F255,0x46FCD9B9, 0x7AEB2661,0x8B1DDF84,0x846A0E79,0x915F95E2,0x466E598E,0x20B45770,0x8CD55591,0xC902DE4C, 0xB90BACE1,0xBB8205D0,0x11A86248,0x7574A99E,0xB77F19B6,0xE0A9DC09,0x662D09A1,0xC4324633, 0xE85A1F02,0x09F0BE8C,0x4A99A025,0x1D6EFE10,0x1AB93D1D,0x0BA5A4DF,0xA186F20F,0x2868F169, 0xDCB7DA83,0x573906FE,0xA1E2CE9B,0x4FCD7F52,0x50115E01,0xA70683FA,0xA002B5C4,0x0DE6D027, 0x9AF88C27,0x773F8641,0xC3604C06,0x61A806B5,0xF0177A28,0xC0F586E0,0x006058AA,0x30DC7D62, 0x11E69ED7,0x2338EA63,0x53C2DD94,0xC2C21634,0xBBCBEE56,0x90BCB6DE,0xEBFC7DA1,0xCE591D76, 0x6F05E409,0x4B7C0188,0x39720A3D,0x7C927C24,0x86E3725F,0x724D9DB9,0x1AC15BB4,0xD39EB8FC, 0xED545578,0x08FCA5B5,0xD83D7CD3,0x4DAD0FC4,0x1E50EF5E,0xB161E6F8,0xA28514D9,0x6C51133C, 0x6FD5C7E7,0x56E14EC4,0x362ABFCE,0xDDC6C837,0xD79A3234,0x92638212,0x670EFA8E,0x406000E0 },{ 0x3A39CE37,0xD3FAF5CF,0xABC27737,0x5AC52D1B,0x5CB0679E,0x4FA33742,0xD3822740,0x99BC9BBE, 0xD5118E9D,0xBF0F7315,0xD62D1C7E,0xC700C47B,0xB78C1B6B,0x21A19045,0xB26EB1BE,0x6A366EB4, 0x5748AB2F,0xBC946E79,0xC6A376D2,0x6549C2C8,0x530FF8EE,0x468DDE7D,0xD5730A1D,0x4CD04DC6, 0x2939BBDB,0xA9BA4650,0xAC9526E8,0xBE5EE304,0xA1FAD5F0,0x6A2D519A,0x63EF8CE2,0x9A86EE22, 0xC089C2B8,0x43242EF6,0xA51E03AA,0x9CF2D0A4,0x83C061BA,0x9BE96A4D,0x8FE51550,0xBA645BD6, 0x2826A2F9,0xA73A3AE1,0x4BA99586,0xEF5562E9,0xC72FEFD3,0xF752F7DA,0x3F046F69,0x77FA0A59, 0x80E4A915,0x87B08601,0x9B09E6AD,0x3B3EE593,0xE990FD5A,0x9E34D797,0x2CF0B7D9,0x022B8B51, 0x96D5AC3A,0x017DA67D,0xD1CF3ED6,0x7C7D2D28,0x1F9F25CF,0xADF2B89B,0x5AD6B472,0x5A88F54C, 0xE029AC71,0xE019A5E6,0x47B0ACFD,0xED93FA9B,0xE8D3C48D,0x283B57CC,0xF8D56629,0x79132E28, 0x785F0191,0xED756055,0xF7960E44,0xE3D35E8C,0x15056DD4,0x88F46DBA,0x03A16125,0x0564F0BD, 0xC3EB9E15,0x3C9057A2,0x97271AEC,0xA93A072A,0x1B3F6D9B,0x1E6321F5,0xF59C66FB,0x26DCF319, 0x7533D928,0xB155FDF5,0x03563482,0x8ABA3CBB,0x28517711,0xC20AD9F8,0xABCC5167,0xCCAD925F, 0x4DE81751,0x3830DC8E,0x379D5862,0x9320F991,0xEA7A90C2,0xFB3E7BCE,0x5121CE64,0x774FBE32, 0xA8B6E37E,0xC3293D46,0x48DE5369,0x6413E680,0xA2AE0810,0xDD6DB224,0x69852DFD,0x09072166, 0xB39A460A,0x6445C0DD,0x586CDECF,0x1C20C8AE,0x5BBEF7DD,0x1B588D40,0xCCD2017F,0x6BB4E3BB, 0xDDA26A7E,0x3A59FF45,0x3E350A44,0xBCB4CDD5,0x72EACEA8,0xFA6484BB,0x8D6612AE,0xBF3C6F47, 0xD29BE463,0x542F5D9E,0xAEC2771B,0xF64E6370,0x740E0D8D,0xE75B1357,0xF8721671,0xAF537D5D, 0x4040CB08,0x4EB4E2CC,0x34D2466A,0x0115AF84,0xE1B00428,0x95983A1D,0x06B89FB4,0xCE6EA048, 0x6F3F3B82,0x3520AB82,0x011A1D4B,0x277227F8,0x611560B1,0xE7933FDC,0xBB3A792B,0x344525BD, 0xA08839E1,0x51CE794B,0x2F32C9B7,0xA01FBAC9,0xE01CC87E,0xBCC7D1F6,0xCF0111C3,0xA1E8AAC7, 0x1A908749,0xD44FBD9A,0xD0DADECB,0xD50ADA38,0x0339C32A,0xC6913667,0x8DF9317C,0xE0B12B4F, 0xF79E59B7,0x43F5BB3A,0xF2D519FF,0x27D9459C,0xBF97222C,0x15E6FC2A,0x0F91FC71,0x9B941525, 0xFAE59361,0xCEB69CEB,0xC2A86459,0x12BAA8D1,0xB6C1075E,0xE3056A0C,0x10D25065,0xCB03A442, 0xE0EC6E0E,0x1698DB3B,0x4C98A0BE,0x3278E964,0x9F1F9532,0xE0D392DF,0xD3A0342B,0x8971F21E, 0x1B0A7441,0x4BA3348C,0xC5BE7120,0xC37632D8,0xDF359F8D,0x9B992F2E,0xE60B6F47,0x0FE3F11D, 0xE54CDA54,0x1EDAD891,0xCE6279CF,0xCD3E7E6F,0x1618B166,0xFD2C1D05,0x848FD2C5,0xF6FB2299, 0xF523F357,0xA6327623,0x93A83531,0x56CCCD02,0xACF08162,0x5A75EBB5,0x6E163697,0x88D273CC, 0xDE966292,0x81B949D0,0x4C50901B,0x71C65614,0xE6C6C7BD,0x327A140A,0x45E1D006,0xC3F27B9A, 0xC9AA53FD,0x62A80F00,0xBB25BFE2,0x35BDD2F6,0x71126905,0xB2040222,0xB6CBCF7C,0xCD769C2B, 0x53113EC0,0x1640E3D3,0x38ABBD60,0x2547ADF0,0xBA38209C,0xF746CE76,0x77AFA1C5,0x20756060, 0x85CBFE4E,0x8AE88DD8,0x7AAAF9B0,0x4CF9AA7E,0x1948C25C,0x02FB8A8C,0x01C36AE4,0xD6EBE1F9, 0x90D4F869,0xA65CDEA0,0x3F09252D,0xC208E69F,0xB74E6132,0xCE77E25B,0x578FDFE3,0x3AC372E6 } }; typedef struct { uint8_t x,y; uint8_t m[256]; uint32_t s[4][256]; } cipher_ctx_t; void cipher_update(cipher_ctx_t *ctx); void cipher_init(cipher_ctx_t *ctx, const char* key, size_t key_len); void cipher_encrypt(cipher_ctx_t *ctx, uint32_t packet_id, uint8_t *buffer, size_t len); void cipher_decrypt(cipher_ctx_t *ctx, uint32_t packet_id, uint8_t *buffer, size_t len); #endif
77.8
91
0.86054
4d01792a27986dbdc2abb592ddc2d1dbbf129d97
10,728
c
C
sorttemplates.c
assyrian7/BlantV2
ce296f70dcc3764c76054ed94ba187f42525ba5b
[ "Apache-2.0" ]
null
null
null
sorttemplates.c
assyrian7/BlantV2
ce296f70dcc3764c76054ed94ba187f42525ba5b
[ "Apache-2.0" ]
null
null
null
sorttemplates.c
assyrian7/BlantV2
ce296f70dcc3764c76054ed94ba187f42525ba5b
[ "Apache-2.0" ]
null
null
null
/* sorttemplates.c version 1.1, Oct 9, 2013. * Author: Brendan McKay; bdm@cs.anu.edu.au * * This file contains templates for creating in-place sorting procedures * for different data types. It cannot be compiled separately but * should be #included after defining a few preprocessor variables. * SORT_OF_SORT, SORT_NAME and SORT_TYPE1 are required, and * SORT_TYPE2 is needed for SORT_OF_SORT > 1. * * SORT_OF_SORT = 1: Creates a procedure * static void SORT_NAME(SORT_TYPE1 *x, int n) * which permutes x[0..n-1] so that x[0] <= ... <= x[n-1]. * SORT_OF_SORT = 2: Creates a procedure * static void SORT_NAME(SORT_TYPE1 *x, SORT_TYPE2 *y, int n) * which permutes x[0..n-1] so that x[0] <= ... <= x[n-1] * and also permutes y[0..n-1] by the same permutation. * SORT_OF_SORT = 3: Creates a procedure * static void SORT_NAME(SORT_TYPE1 *x, SORT_TYPE2 *y, int n) * which permutes x[0..n-1] so that y[x[0]] <= ... <= y[x[n-1]]. * The array y[] is not changed. * * SORT_NAME = the name of the procedure to be created * * SORT_TYPE1 = type of the first or only array (no default) * This can be any numeric type for SORT_OF_SORT=1,2, but * should be an integer type for SORT_OF_SORT=3. * SORT_TYPE2 = type of the second array if needed (no default) * This can be any assignable type (including a structure) for * SORT_OF_SORT=2, but must be a numeric type for SORT_OF_SORT=3. * * SORT_MINPARTITION = least number of elements for using quicksort * partitioning, otherwise insertion sort is used (default "11") * SORT_MINMEDIAN9 = least number of elements for using the median of 3 * medians of 3 for partitioning (default "320") * SORT_FUNCTYPE = type of sort function (default "static void") * * This file can be included any number of times provided the value * of SORT_NAME is different each time. */ #define SORT_MEDIAN_OF_3(a,b,c) \ ((a) <= (b) ? ((b) <= (c) ? (b) : (c) <= (a) ? (a) : (c)) \ : ((a) <= (c) ? (a) : (c) <= (b) ? (b) : (c))) #if !defined(SORT_OF_SORT) || !defined(SORT_NAME) // #error Either SORT_OF_SORT or SORT_NAME is undefined #endif #if (SORT_OF_SORT < 1) || (SORT_OF_SORT > 3) // #error Unknown value of SORT_OF_SORT #endif #ifndef SORT_TYPE1 // #error "SORT_TYPE1 must be defined before including sorttemplates.c" #endif #ifndef SORT_MINPARTITION #define SORT_MINPARTITION 11 #endif #ifndef SORT_MINMEDIAN9 #define SORT_MINMEDIAN9 320 #endif #ifndef SORT_FUNCTYPE #define SORT_FUNCTYPE static void #endif #define SORT_SWAP1(x,y) tmp1 = x; x = y; y = tmp1; #define SORT_SWAP2(x,y) tmp2 = x; x = y; y = tmp2; /*******************************************************************/ #if SORT_OF_SORT == 1 SORT_FUNCTYPE SORT_NAME(SORT_TYPE1 *x, int n) { int i,j; int a,d,ba,dc,s,nn; SORT_TYPE1 tmp1,v,v1,v2,v3; SORT_TYPE1 *x0,*xa,*xb,*xc,*xd,*xh,*xl; struct {SORT_TYPE1 *addr; int len;} stack[40]; int top; top = 0; if (n > 1) { stack[top].addr = x; stack[top].len = n; ++top; } while (top > 0) { --top; x0 = stack[top].addr; nn = stack[top].len; if (nn < SORT_MINPARTITION) { for (i = 1; i < nn; ++i) { tmp1 = x0[i]; for (j = i; x0[j-1] > tmp1; ) { x0[j] = x0[j-1]; if (--j == 0) break; } x0[j] = tmp1; } continue; } if (nn < SORT_MINMEDIAN9) v = SORT_MEDIAN_OF_3(x0[0],x0[nn/2],x0[nn-1]); else { v1 = SORT_MEDIAN_OF_3(x0[0],x0[1],x0[2]); v2 = SORT_MEDIAN_OF_3(x0[nn/2-1],x0[nn/2],x0[nn/2+1]); v3 = SORT_MEDIAN_OF_3(x0[nn-3],x0[nn-2],x0[nn-1]); v = SORT_MEDIAN_OF_3(v1,v2,v3); } xa = xb = x0; xc = xd = x0+(nn-1); for (;;) { while (xb <= xc && *xb <= v) { if (*xb == v) { *xb = *xa; *xa = v; ++xa; } ++xb; } while (xc >= xb && *xc >= v) { if (*xc == v) { *xc = *xd; *xd = v; --xd; } --xc; } if (xb > xc) break; SORT_SWAP1(*xb,*xc); ++xb; --xc; } a = xa - x0; ba = xb - xa; if (ba > a) s = a; else s = ba; for (xl = x0, xh = xb-s; s > 0; --s) { *xl = *xh; *xh = v; ++xl; ++xh; } d = xd - x0; dc = xd - xc; if (dc > nn-1-d) s = nn-1-d; else s = dc; for (xl = xb, xh = x0 + (nn-s); s > 0; --s) { *xh = *xl; *xl = v; ++xl; ++xh; } if (ba > dc) { if (ba > 1) { stack[top].addr = x0; stack[top].len = ba; ++top; } if (dc > 1) { stack[top].addr = x0+(nn-dc); stack[top].len = dc; ++top; } } else { if (dc > 1) { stack[top].addr = x0+(nn-dc); stack[top].len = dc; ++top; } if (ba > 1) { stack[top].addr = x0; stack[top].len = ba; ++top; } } } } #endif #if SORT_OF_SORT == 2 #ifndef SORT_TYPE2 #error "SORT_TYPE2 must be defined before including sorttemplates.c" #endif SORT_FUNCTYPE SORT_NAME(SORT_TYPE1 *x, SORT_TYPE2 *y, int n) { int i,j; int a,d,ba,dc,s,nn; SORT_TYPE2 tmp2,*y0,*ya,*yb,*yc,*yd,*yl,*yh; SORT_TYPE1 tmp1,v,v1,v2,v3; SORT_TYPE1 *x0,*xa,*xb,*xc,*xd,*xh,*xl; struct {SORT_TYPE1 *addr; int len;} stack[40]; int top; top = 0; if (n > 1) { stack[top].addr = x; stack[top].len = n; ++top; } while (top > 0) { --top; x0 = stack[top].addr; y0 = y + (x0-x); nn = stack[top].len; if (nn < SORT_MINPARTITION) { for (i = 1; i < nn; ++i) { tmp1 = x0[i]; tmp2 = y0[i]; for (j = i; x0[j-1] > tmp1; ) { x0[j] = x0[j-1]; y0[j] = y0[j-1]; if (--j == 0) break; } x0[j] = tmp1; y0[j] = tmp2; } continue; } if (nn < SORT_MINMEDIAN9) v = SORT_MEDIAN_OF_3(x0[0],x0[nn/2],x0[nn-1]); else { v1 = SORT_MEDIAN_OF_3(x0[0],x0[1],x0[2]); v2 = SORT_MEDIAN_OF_3(x0[nn/2-1],x0[nn/2],x0[nn/2+1]); v3 = SORT_MEDIAN_OF_3(x0[nn-3],x0[nn-2],x0[nn-1]); v = SORT_MEDIAN_OF_3(v1,v2,v3); } xa = xb = x0; xc = xd = x0+(nn-1); ya = yb = y0; yc = yd = y0+(nn-1); for (;;) { while (xb <= xc && *xb <= v) { if (*xb == v) { *xb = *xa; *xa = v; ++xa; SORT_SWAP2(*ya,*yb); ++ya; } ++xb; ++yb; } while (xc >= xb && *xc >= v) { if (*xc == v) { *xc = *xd; *xd = v; --xd; SORT_SWAP2(*yc,*yd); --yd; } --xc; --yc; } if (xb > xc) break; SORT_SWAP1(*xb,*xc); SORT_SWAP2(*yb,*yc); ++xb; ++yb; --xc; --yc; } a = xa - x0; ba = xb - xa; if (ba > a) s = a; else s = ba; for (xl = x0, xh = xb-s, yl = y0, yh = yb-s; s > 0; --s) { *xl = *xh; *xh = v; ++xl; ++xh; SORT_SWAP2(*yl,*yh); ++yl; ++yh; } d = xd - x0; dc = xd - xc; if (dc > nn-1-d) s = nn-1-d; else s = dc; for (xl = xb, xh = x0+(nn-s), yl = yb, yh = y0+(nn-s); s > 0; --s) { *xh = *xl; *xl = v; ++xl; ++xh; SORT_SWAP2(*yl,*yh); ++yl; ++yh; } if (ba > dc) { if (ba > 1) { stack[top].addr = x0; stack[top].len = ba; ++top; } if (dc > 1) { stack[top].addr = x0+(nn-dc); stack[top].len = dc; ++top; } } else { if (dc > 1) { stack[top].addr = x0+(nn-dc); stack[top].len = dc; ++top; } if (ba > 1) { stack[top].addr = x0; stack[top].len = ba; ++top; } } } } #endif #if SORT_OF_SORT == 3 #ifndef SORT_TYPE2 #error "SORT_TYPE2 must be defined before including sorttemplates.c" #endif SORT_FUNCTYPE SORT_NAME(SORT_TYPE1 *x, SORT_TYPE2 *y, int n) { int i,j; int a,d,ba,dc,s,nn; SORT_TYPE2 tmp2,v,v1,v2,v3; SORT_TYPE1 tmp1,*x0,*xa,*xb,*xc,*xd,*xh,*xl; struct {SORT_TYPE1 *addr; int len;} stack[40]; int top; top = 0; if (n > 1) { stack[top].addr = x; stack[top].len = n; ++top; } while (top > 0) { --top; x0 = stack[top].addr; nn = stack[top].len; if (nn < SORT_MINPARTITION) { for (i = 1; i < nn; ++i) { tmp1 = x0[i]; tmp2 = y[tmp1]; for (j = i; y[x0[j-1]] > tmp2; ) { x0[j] = x0[j-1]; if (--j == 0) break; } x0[j] = tmp1; } continue; } if (nn < SORT_MINMEDIAN9) v = SORT_MEDIAN_OF_3(y[x0[0]],y[x0[nn/2]],y[x0[nn-1]]); else { v1 = SORT_MEDIAN_OF_3(y[x0[0]],y[x0[1]],y[x0[2]]); v2 = SORT_MEDIAN_OF_3(y[x0[nn/2-1]],y[x0[nn/2]],y[x0[nn/2+1]]); v3 = SORT_MEDIAN_OF_3(y[x0[nn-3]],y[x0[nn-2]],y[x0[nn-1]]); v = SORT_MEDIAN_OF_3(v1,v2,v3); } xa = xb = x0; xc = xd = x0+(nn-1); for (;;) { while (xb <= xc && y[*xb] <= v) { if (y[*xb] == v) { SORT_SWAP1(*xa,*xb); ++xa; } ++xb; } while (xc >= xb && y[*xc] >= v) { if (y[*xc] == v) { SORT_SWAP1(*xc,*xd); --xd; } --xc; } if (xb > xc) break; SORT_SWAP1(*xb,*xc); ++xb; --xc; } a = xa - x0; ba = xb - xa; if (ba > a) s = a; else s = ba; for (xl = x0, xh = xb-s; s > 0; --s) { SORT_SWAP1(*xl,*xh); ++xl; ++xh; } d = xd - x0; dc = xd - xc; if (dc > nn-1-d) s = nn-1-d; else s = dc; for (xl = xb, xh = x0 + (nn-s); s > 0; --s) { SORT_SWAP1(*xl,*xh); ++xl; ++xh; } if (ba > dc) { if (ba > 1) { stack[top].addr = x0; stack[top].len = ba; ++top; } if (dc > 1) { stack[top].addr = x0+(nn-dc); stack[top].len = dc; ++top; } } else { if (dc > 1) { stack[top].addr = x0+(nn-dc); stack[top].len = dc; ++top; } if (ba > 1) { stack[top].addr = x0; stack[top].len = ba; ++top; } } } } #endif #undef SORT_NAME #undef SORT_OF_SORT #undef SORT_TYPE1 #undef SORT_TYPE2
24.107865
74
0.450876
4d054c62a29ca60b8adff5c98e7dc36c6e5db541
277
h
C
ScrollViewKeyboard/ScrollViewKeyboard/TableViewCell.h
hnxczk/ScrollViewAutoAdjust
6a6047fe6e8538c3f5214d2b3bf7461fb7488d27
[ "MIT" ]
1
2019-04-06T16:04:33.000Z
2019-04-06T16:04:33.000Z
ScrollViewKeyboard/ScrollViewKeyboard/TableViewCell.h
hnxczk/ScrollViewAutoAdjust
6a6047fe6e8538c3f5214d2b3bf7461fb7488d27
[ "MIT" ]
null
null
null
ScrollViewKeyboard/ScrollViewKeyboard/TableViewCell.h
hnxczk/ScrollViewAutoAdjust
6a6047fe6e8538c3f5214d2b3bf7461fb7488d27
[ "MIT" ]
null
null
null
// // TableViewCell.h // ScrollViewKeyboard // // Created by zhouke on 2018/10/13. // Copyright © 2018年 zhouke. All rights reserved. // #import <UIKit/UIKit.h> @interface TableViewCell : UITableViewCell @property (weak, nonatomic) IBOutlet UITextField *textField; @end
17.3125
60
0.722022
4d0828bd12be81c555a249156482323fbe24662f
1,358
h
C
src/plugins/lldb/LLDB/SBStringList.h
PleXone2019/ProDBG
c7042f32da9e54662c3c575725c4cd24a878a2de
[ "MIT" ]
445
2015-01-04T16:30:56.000Z
2022-03-30T02:27:05.000Z
src/plugins/lldb/LLDB/SBStringList.h
PleXone2019/ProDBG
c7042f32da9e54662c3c575725c4cd24a878a2de
[ "MIT" ]
305
2015-01-04T09:20:03.000Z
2020-10-01T08:45:45.000Z
src/plugins/lldb/LLDB/SBStringList.h
PleXone2019/ProDBG
c7042f32da9e54662c3c575725c4cd24a878a2de
[ "MIT" ]
49
2015-02-14T01:43:38.000Z
2022-02-15T17:03:55.000Z
//===-- SBStringList.h ------------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef LLDB_SBStringList_h_ #define LLDB_SBStringList_h_ #include <LLDB/SBDefines.h> namespace lldb { class LLDB_API SBStringList { public: SBStringList (); SBStringList (const lldb::SBStringList &rhs); const SBStringList & operator = (const SBStringList &rhs); ~SBStringList (); bool IsValid() const; void AppendString (const char *str); void AppendList (const char **strv, int strc); void AppendList (const lldb::SBStringList &strings); uint32_t GetSize () const; const char * GetStringAtIndex (size_t idx); void Clear (); protected: friend class SBCommandInterpreter; friend class SBDebugger; SBStringList (const lldb_private::StringList *lldb_strings); const lldb_private::StringList * operator->() const; const lldb_private::StringList & operator*() const; private: std::unique_ptr<lldb_private::StringList> m_opaque_ap; }; } // namespace lldb #endif // LLDB_SBStringList_h_
18.861111
80
0.603829
4d08ae358bed97c820a7ad10d9ec2d96bc0f5057
5,422
h
C
TernaryMath.h
JohnSully/Trinity
247b8af80dc752ac3bcdecb545f9a08e4f942c0c
[ "MIT" ]
12
2015-01-01T07:17:32.000Z
2021-07-20T12:38:10.000Z
TernaryMath.h
JohnSully/Trinity
247b8af80dc752ac3bcdecb545f9a08e4f942c0c
[ "MIT" ]
1
2017-10-24T13:44:11.000Z
2017-10-24T13:44:11.000Z
TernaryMath.h
JohnSully/Trinity
247b8af80dc752ac3bcdecb545f9a08e4f942c0c
[ "MIT" ]
1
2019-06-13T02:10:30.000Z
2019-06-13T02:10:30.000Z
#pragma once class Trit { public: Trit() { m_ch = '0'; } Trit(char ch) { switch (ch) { case '0': case '+': case '-': m_ch = ch; break; default: assert(false); } } explicit operator const char() const { return m_ch; } explicit operator bool() const { return m_ch == '+'; } Trit operator~() const { if (m_ch == '+') return '-'; if (m_ch == '-') return '+'; return *this; } Trit operator&(Trit other) const { if (m_ch == '+' && other.m_ch == '+') return '+'; if (m_ch == '0' || other.m_ch == '0') // UNKNOWN return '0'; return '-'; } Trit operator|(Trit other) const { if (m_ch == '+' || other == '+') return '+'; if (m_ch == '-' || other == '-') return '-'; if (m_ch == '0' || other == '0') return '0'; return '-'; } Trit operator^(Trit other) const { return (*this | other) & ~(*this & other); } bool operator==(Trit other) const { return (m_ch == other.m_ch); } Trit HalfAdd(Trit other) const { if (m_ch == '+' && other.m_ch == '+') return '-'; if (m_ch == '-' && other.m_ch == '-') return '+'; if (m_ch == '0') return other; if (other.m_ch == '0') return *this; return '0'; } Trit SaturationAdd(Trit other) const { if (m_ch == '+' && other.m_ch != '-') return '+'; else if (m_ch == '+') return '0'; if (m_ch == '0') return other; if (m_ch == '-' && other.m_ch != '+') return '-'; else if (m_ch == '-') return '0'; } Trit NoDissentWQuorum(Trit other1, Trit other2) const { int cpos = (m_ch == '+') + (other1.m_ch == '+') + (other2.m_ch == '+'); int cneg = (m_ch == '-') + (other1.m_ch == '-') + (other2.m_ch == '-'); if (cpos >= 2 && cneg == 0) return '+'; if (cneg >= 2 && cpos == 0) return '-'; return '0'; } Trit Carry(Trit other) const { if (m_ch == other.m_ch) return *this; return '0'; } Trit IncOp() const { switch (m_ch) { case '-': return '0'; case '0': return '+'; case '+': return '-'; } assert(false); return '0'; } Trit DecOp() const { switch (m_ch) { case '-': return '+'; case '0': return '-'; case '+': return '0'; } assert(false); return '0'; } private: char m_ch; }; class Trite { // We define a trite as 4 trits, this is for efficient binary packing to 6 bits when necessary public: static const int CTRIT = 6; static const int TRITE_MAX = 729; Trite() {} Trite(int int8) { int ival = int8; bool fneg = ival < 0; if (fneg) ival = -ival; for (int idigit = 0; idigit < CTRIT; ++idigit) { switch (ival % 3) { case 0: rgdigit[idigit] = '0'; break; case 1: rgdigit[idigit] = '+'; break; case 2: rgdigit[idigit] = '-'; ++ival; break; } ival /= 3; } assert(ival == 0); if (fneg) *this = ~(*this); } Trite(const char *sz) { int cch = strlen(sz); assert(cch <= CTRIT); int itrit = 0; while (cch > 0) { --cch; rgdigit[itrit] = sz[cch]; ++itrit; } } int to_int() const { int iret = 0; for (int idigit = CTRIT - 1; idigit >= 0; --idigit) { iret *= 3; switch ((char)rgdigit[idigit]) { case '+': iret++; break; case '-': iret--; break; } } return iret; } Trit &operator[](int idx) { assert(idx >= 0 && idx < CTRIT); return rgdigit[idx]; } Trite operator~() const { Trite trite; for (int idigit = 0; idigit < CTRIT; ++idigit) { trite.rgdigit[idigit] = ~rgdigit[idigit]; } return trite; } Trite operator&(const Trite &other) const { Trite trite; for (int idigit = 0; idigit < CTRIT; ++idigit) trite[idigit] = rgdigit[idigit] & other.rgdigit[idigit]; return trite; } Trite operator|(const Trite &other) const { Trite trite; for (int idigit = 0; idigit < CTRIT; ++idigit) trite[idigit] = rgdigit[idigit] | other.rgdigit[idigit]; return trite; } Trite operator^(const Trite &other) const { Trite trite; for (int idigit = 0; idigit < CTRIT; ++idigit) trite[idigit] = rgdigit[idigit] ^ other.rgdigit[idigit]; return trite; } Trite operator+(const Trite &other) const { //return Trite(to_int() + other.to_int()); Trite result; CarryAdd(other, result); return result; } Trit CarryAdd(const Trite &other, Trite &result) const { Trit carry = '0'; Trite resultT; for (int idigit = 0; idigit < CTRIT; ++idigit) { Trit halfIn = rgdigit[idigit].HalfAdd(other.rgdigit[idigit]); resultT.rgdigit[idigit] = halfIn.HalfAdd(carry); carry = carry.NoDissentWQuorum(rgdigit[idigit], other.rgdigit[idigit]); } #ifdef _DEBUG if (carry == '0') { if (resultT.to_int() != (this->to_int() + other.to_int())) assert(false); } #endif result = resultT; return carry; } Trit OrReduce() const { Trit trit('0'); for (int idigit = 0; idigit < CTRIT; ++idigit) { trit = trit | rgdigit[idigit]; } return trit; } bool operator==(const Trite &other) const { for (int idigit = 0; idigit < CTRIT; ++idigit) { if (((char)rgdigit[idigit] != (char)other.rgdigit[idigit])) return false; } return true; } operator bool() const { return to_int() != 0; } operator int() const = delete; std::string str() { reinterpret_cast<char&>(rgdigit[CTRIT]) = '\0'; std::string str((char*)rgdigit); std::reverse(str.begin(), str.end()); return str; } private: Trit rgdigit[CTRIT + 1]; };
16.331325
95
0.550535
4d091f98a3586e5a686f1ad5aca02ca634d7b990
319
h
C
iOSPerformanceKit/Performance/PerformanceManager.h
wumeijun/iOSPerformanceK
eba512f72b79f008159598083fff9290ec8157cf
[ "MIT" ]
2
2019-08-19T02:04:17.000Z
2020-08-31T01:17:58.000Z
iOSPerformanceKit/Performance/PerformanceManager.h
wumeijun/iOSPerformanceK
eba512f72b79f008159598083fff9290ec8157cf
[ "MIT" ]
null
null
null
iOSPerformanceKit/Performance/PerformanceManager.h
wumeijun/iOSPerformanceK
eba512f72b79f008159598083fff9290ec8157cf
[ "MIT" ]
1
2021-02-25T06:12:06.000Z
2021-02-25T06:12:06.000Z
// // PerformanceManager.h // iOSPerformanceKit // // Created by Maggie on 2019/8/14. // Copyright © 2019 soul. All rights reserved. // #import <Foundation/Foundation.h> NS_ASSUME_NONNULL_BEGIN @interface PerformanceManager : NSObject + (instancetype)shareManager; - (void)install; @end NS_ASSUME_NONNULL_END
15.190476
47
0.746082
4d0c262f16a5b59abe5a9f89cc3316c5ce6149f1
33,119
c
C
futility/cmd_sign.c
9elements/vboot
b021a9619722a397de9910bd0422b2e7c6ebb7f0
[ "BSD-3-Clause" ]
2
2021-08-28T02:29:04.000Z
2021-11-17T10:50:42.000Z
futility/cmd_sign.c
9elements/vboot
b021a9619722a397de9910bd0422b2e7c6ebb7f0
[ "BSD-3-Clause" ]
null
null
null
futility/cmd_sign.c
9elements/vboot
b021a9619722a397de9910bd0422b2e7c6ebb7f0
[ "BSD-3-Clause" ]
null
null
null
/* * Copyright 2014 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include <errno.h> #include <fcntl.h> #include <getopt.h> #include <inttypes.h> #include <limits.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include "2common.h" #include "file_type.h" #include "file_type_bios.h" #include "fmap.h" #include "futility.h" #include "futility_options.h" #include "host_common.h" #include "host_key2.h" #include "kernel_blob.h" #include "util_misc.h" #include "vb1_helper.h" #include "vb2_common.h" #include "vb2_struct.h" #include "vb21_common.h" #include "vboot_common.h" /* Options */ struct sign_option_s sign_option = { .version = 1, .arch = ARCH_UNSPECIFIED, .kloadaddr = CROS_32BIT_ENTRY_ADDR, .padding = 65536, .type = FILE_TYPE_UNKNOWN, .hash_alg = VB2_HASH_SHA256, /* default */ .ro_size = 0xffffffff, .rw_size = 0xffffffff, .ro_offset = 0xffffffff, .rw_offset = 0xffffffff, .sig_size = 1024, }; /* Helper to complain about invalid args. Returns num errors discovered */ static int no_opt_if(int expr, const char *optname) { if (expr) { fprintf(stderr, "Missing --%s option\n", optname); return 1; } return 0; } /* This wraps/signs a public key, producing a keyblock. */ int ft_sign_pubkey(const char *name, uint8_t *buf, uint32_t len, void *data) { struct vb2_packed_key *data_key = (struct vb2_packed_key *)buf; struct vb2_keyblock *block; if (!packed_key_looks_ok(data_key, len)) { fprintf(stderr, "Public key looks bad.\n"); return 1; } if (sign_option.pem_signpriv) { if (sign_option.pem_external) { /* External signing uses the PEM file directly. */ block = vb2_create_keyblock_external( data_key, sign_option.pem_signpriv, sign_option.pem_algo, sign_option.flags, sign_option.pem_external); } else { sign_option.signprivate = vb2_read_private_key_pem( sign_option.pem_signpriv, sign_option.pem_algo); if (!sign_option.signprivate) { fprintf(stderr, "Unable to read PEM signing key: %s\n", strerror(errno)); return 1; } block = vb2_create_keyblock(data_key, sign_option.signprivate, sign_option.flags); } } else { /* Not PEM. Should already have a signing key. */ block = vb2_create_keyblock(data_key, sign_option.signprivate, sign_option.flags); } /* Write it out */ return WriteSomeParts(sign_option.outfile, block, block->keyblock_size, NULL, 0); } int ft_sign_raw_kernel(const char *name, uint8_t *buf, uint32_t len, void *data) { uint8_t *vmlinuz_data, *kblob_data, *vblock_data; uint32_t vmlinuz_size, kblob_size, vblock_size; int rv; vmlinuz_data = buf; vmlinuz_size = len; kblob_data = CreateKernelBlob( vmlinuz_data, vmlinuz_size, sign_option.arch, sign_option.kloadaddr, sign_option.config_data, sign_option.config_size, sign_option.bootloader_data, sign_option.bootloader_size, &kblob_size); if (!kblob_data) { fprintf(stderr, "Unable to create kernel blob\n"); return 1; } VB2_DEBUG("kblob_size = 0x%x\n", kblob_size); vblock_data = SignKernelBlob(kblob_data, kblob_size, sign_option.padding, sign_option.version, sign_option.kloadaddr, sign_option.keyblock, sign_option.signprivate, sign_option.flags, &vblock_size); if (!vblock_data) { fprintf(stderr, "Unable to sign kernel blob\n"); free(kblob_data); return 1; } VB2_DEBUG("vblock_size = 0x%x\n", vblock_size); /* We should be creating a completely new output file. * If not, something's wrong. */ if (!sign_option.create_new_outfile) DIE; if (sign_option.vblockonly) rv = WriteSomeParts(sign_option.outfile, vblock_data, vblock_size, NULL, 0); else rv = WriteSomeParts(sign_option.outfile, vblock_data, vblock_size, kblob_data, kblob_size); free(vblock_data); free(kblob_data); return rv; } int ft_sign_kern_preamble(const char *name, uint8_t *buf, uint32_t len, void *data) { uint8_t *kpart_data, *kblob_data, *vblock_data; uint32_t kpart_size, kblob_size, vblock_size; struct vb2_keyblock *keyblock = NULL; struct vb2_kernel_preamble *preamble = NULL; int rv = 0; kpart_data = buf; kpart_size = len; /* Note: This just sets some static pointers. It doesn't malloc. */ kblob_data = unpack_kernel_partition(kpart_data, kpart_size, sign_option.padding, &keyblock, &preamble, &kblob_size); if (!kblob_data) { fprintf(stderr, "Unable to unpack kernel partition\n"); return 1; } /* * We don't let --kloadaddr change when resigning, because the original * vbutil_kernel program didn't do it right. Since obviously no one * ever noticed, we'll maintain bug-compatibility by just not allowing * it here either. To enable it, we'd need to update the zeropage * table's cmd_line_ptr as well as the preamble. */ sign_option.kloadaddr = preamble->body_load_address; /* Replace the config if asked */ if (sign_option.config_data && 0 != UpdateKernelBlobConfig(kblob_data, kblob_size, sign_option.config_data, sign_option.config_size)) { fprintf(stderr, "Unable to update config\n"); return 1; } /* Preserve the version unless a new one is given */ if (!sign_option.version_specified) sign_option.version = preamble->kernel_version; /* Preserve the flags if not specified */ uint32_t kernel_flags = vb2_kernel_get_flags(preamble); if (sign_option.flags_specified == 0) sign_option.flags = kernel_flags; /* Replace the keyblock if asked */ if (sign_option.keyblock) keyblock = sign_option.keyblock; /* Compute the new signature */ vblock_data = SignKernelBlob(kblob_data, kblob_size, sign_option.padding, sign_option.version, sign_option.kloadaddr, keyblock, sign_option.signprivate, sign_option.flags, &vblock_size); if (!vblock_data) { fprintf(stderr, "Unable to sign kernel blob\n"); return 1; } VB2_DEBUG("vblock_size = 0x%" PRIx64 "\n", vblock_size); if (sign_option.create_new_outfile) { /* Write out what we've been asked for */ if (sign_option.vblockonly) rv = WriteSomeParts(sign_option.outfile, vblock_data, vblock_size, NULL, 0); else rv = WriteSomeParts(sign_option.outfile, vblock_data, vblock_size, kblob_data, kblob_size); } else { /* If we're modifying an existing file, it's mmap'ed so that * all our modifications to the buffer will get flushed to * disk when we close it. */ memcpy(kpart_data, vblock_data, vblock_size); } free(vblock_data); return rv; } int ft_sign_raw_firmware(const char *name, uint8_t *buf, uint32_t len, void *data) { struct vb2_signature *body_sig; struct vb2_fw_preamble *preamble; int rv; body_sig = vb2_calculate_signature(buf, len, sign_option.signprivate); if (!body_sig) { fprintf(stderr, "Error calculating body signature\n"); return 1; } preamble = vb2_create_fw_preamble( sign_option.version, (struct vb2_packed_key *)sign_option.kernel_subkey, body_sig, sign_option.signprivate, sign_option.flags); if (!preamble) { fprintf(stderr, "Error creating firmware preamble.\n"); free(body_sig); return 1; } rv = WriteSomeParts(sign_option.outfile, sign_option.keyblock, sign_option.keyblock->keyblock_size, preamble, preamble->preamble_size); free(preamble); free(body_sig); return rv; } static const char usage_pubkey[] = "\n" "To sign a public key / create a new keyblock:\n" "\n" "Required PARAMS:\n" " [--datapubkey] INFILE The public key to wrap\n" " [--outfile] OUTFILE The resulting keyblock\n" "\n" "Optional PARAMS:\n" " A private signing key, specified as either\n" " -s|--signprivate FILE.vbprivk Signing key in .vbprivk format\n" " Or\n" " --pem_signpriv FILE.pem Signing key in PEM format...\n" " --pem_algo NUM AND the algorithm to use (0 - %d)\n" "\n" " If a signing key is not given, the keyblock will not be signed." "\n\n" "And these, too:\n\n" " -f|--flags NUM Flags specifying use conditions\n" " --pem_external PROGRAM" " External program to compute the signature\n" " (requires a PEM signing key)\n" "\n"; static void print_help_pubkey(int argc, char *argv[]) { printf(usage_pubkey, VB2_ALG_COUNT - 1); } static const char usage_fw_main[] = "\n" "To sign a raw firmware blob (FW_MAIN_A/B):\n" "\n" "Required PARAMS:\n" " -s|--signprivate FILE.vbprivk The private firmware data key\n" " -b|--keyblock FILE.keyblock The keyblock containing the\n" " public firmware data key\n" " -k|--kernelkey FILE.vbpubk The public kernel subkey\n" " -v|--version NUM The firmware version number\n" " [--fv] INFILE" " The raw firmware blob (FW_MAIN_A/B)\n" " [--outfile] OUTFILE Output VBLOCK_A/B\n" "\n" "Optional PARAMS:\n" " -f|--flags NUM The preamble flags value" " (default is 0)\n" "\n"; static void print_help_raw_firmware(int argc, char *argv[]) { puts(usage_fw_main); } static const char usage_bios[] = "\n" "To sign a complete firmware image (bios.bin):\n" "\n" "Required PARAMS:\n" " -s|--signprivate FILE.vbprivk The private firmware data key\n" " -b|--keyblock FILE.keyblock The keyblock containing the\n" " public firmware data key\n" " -k|--kernelkey FILE.vbpubk The public kernel subkey\n" " [--infile] INFILE Input firmware image (modified\n" " in place if no OUTFILE given)\n" "\n" "These are required if the A and B firmware differ:\n" " -S|--devsign FILE.vbprivk The DEV private firmware data key\n" " -B|--devkeyblock FILE.keyblock The keyblock containing the\n" " DEV public firmware data key\n" "\n" "Optional PARAMS:\n" " -v|--version NUM The firmware version number" " (default %d)\n" " -f|--flags NUM The preamble flags value" " (default is\n" " unchanged, or 0 if unknown)\n" " -d|--loemdir DIR Local OEM output vblock directory\n" " -l|--loemid STRING Local OEM vblock suffix\n" " [--outfile] OUTFILE Output firmware image\n" "\n"; static void print_help_bios_image(int argc, char *argv[]) { printf(usage_bios, sign_option.version); } static const char usage_new_kpart[] = "\n" "To create a new kernel partition image (/dev/sda2, /dev/mmcblk0p2):\n" "\n" "Required PARAMS:\n" " -s|--signprivate FILE.vbprivk" " The private key to sign the kernel blob\n" " -b|--keyblock FILE.keyblock Keyblock containing the public\n" " key to verify the kernel blob\n" " -v|--version NUM The kernel version number\n" " --bootloader FILE Bootloader stub\n" " --config FILE The kernel commandline file\n" " --arch ARCH The CPU architecture (one of\n" " x86|amd64, arm|aarch64, mips)\n" " [--vmlinuz] INFILE Linux kernel bzImage file\n" " [--outfile] OUTFILE Output kernel partition or vblock\n" "\n" "Optional PARAMS:\n" " --kloadaddr NUM" " RAM address to load the kernel body\n" " (default 0x%x)\n" " --pad NUM The vblock padding size in bytes\n" " (default 0x%x)\n" " --vblockonly Emit just the vblock (requires a\n" " distinct outfile)\n" " -f|--flags NUM The preamble flags value\n" "\n"; static void print_help_raw_kernel(int argc, char *argv[]) { printf(usage_new_kpart, sign_option.kloadaddr, sign_option.padding); } static const char usage_old_kpart[] = "\n" "To resign an existing kernel partition (/dev/sda2, /dev/mmcblk0p2):\n" "\n" "Required PARAMS:\n" " -s|--signprivate FILE.vbprivk" " The private key to sign the kernel blob\n" " [--infile] INFILE Input kernel partition (modified\n" " in place if no OUTFILE given)\n" "\n" "Optional PARAMS:\n" " -b|--keyblock FILE.keyblock Keyblock containing the public\n" " key to verify the kernel blob\n" " -v|--version NUM The kernel version number\n" " --config FILE The kernel commandline file\n" " --pad NUM The vblock padding size in bytes\n" " (default 0x%x)\n" " [--outfile] OUTFILE Output kernel partition or vblock\n" " --vblockonly Emit just the vblock (requires a\n" " distinct OUTFILE)\n" " -f|--flags NUM The preamble flags value\n" "\n"; static void print_help_kern_preamble(int argc, char *argv[]) { printf(usage_old_kpart, sign_option.padding); } static void print_help_usbpd1(int argc, char *argv[]) { const struct vb2_text_vs_enum *entry; printf("\n" "Usage: " MYNAME " %s --type %s [options] INFILE [OUTFILE]\n" "\n" "This signs a %s.\n" "\n" "The INFILE is assumed to consist of equal-sized RO and RW" " sections,\n" "with the public key at the end of of the RO section and the" " signature\n" "at the end of the RW section (both in an opaque binary" " format).\n" "Signing the image will update both binary blobs, so both" " public and\n" "private keys are required.\n" "\n" "The signing key is specified with:\n" "\n" " --pem " "FILE Signing keypair in PEM format\n" "\n" " --hash_alg " "NUM Hash algorithm to use:\n", argv[0], futil_file_type_name(FILE_TYPE_USBPD1), futil_file_type_desc(FILE_TYPE_USBPD1)); for (entry = vb2_text_vs_hash; entry->name; entry++) printf(" %d / %s%s\n", entry->num, entry->name, entry->num == VB2_HASH_SHA256 ? " (default)" : ""); printf("\n" "The size and offset assumptions can be overridden. " "All numbers are in bytes.\n" "Specify a size of 0 to ignore that section.\n" "\n" " --ro_size NUM" " Size of the RO section (default half)\n" " --rw_size NUM" " Size of the RW section (default half)\n" " --ro_offset NUM" " Start of the RO section (default 0)\n" " --rw_offset NUM" " Start of the RW section (default half)\n" "\n"); } static void print_help_rwsig(int argc, char *argv[]) { printf("\n" "Usage: " MYNAME " %s --type %s [options] INFILE [OUTFILE]\n" "\n" "This signs a %s.\n" "\n" "Data only mode\n" "This mode requires OUTFILE.\n" "The INFILE is a binary blob of arbitrary size. It is signed using the\n" "private key and the vb21_signature blob emitted.\n" "\n" "Data + Signature mode\n" "If no OUTFILE is specified, the INFILE should contain an existing\n" "vb21_signature blob near its end. The data_size from that signature is\n" "used to re-sign a portion of the INFILE, and the old signature blob is\n" "replaced.\n" "\n" "Key + Data + Signature mode\n" "This mode also takes no output file.\n" "If INFILE contains an FMAP, RW and signatures offsets are read from\n" "FMAP. These regions must be named EC_RW and SIG_RW respectively.\n" "If a public key is found in the region named KEY_RO, it will be replaced\n" "in the RO image. This mode also produces EC_RW.bin which is a EC_RW\n" "region image (same as the input file for 'Data + Signature mode').\n" "\n" "Options:\n" "\n" " --prikey FILE.vbprik2 Private key in vb2 format. Required\n" " if INFILE is a binary blob. If not\n" " provided, previous signature is copied\n" " and a public key won't be replaced.\n" " --version NUM Public key version if we are replacing\n" " the key in INFILE (default: 1)\n" " --sig_size NUM Offset from the end of INFILE where the\n" " signature blob should be located, if\n" " the file does not contain an FMAP.\n" " (default 1024 bytes)\n" " --data_size NUM Number of bytes of INFILE to sign\n" "\n", argv[0], futil_file_type_name(FILE_TYPE_RWSIG), futil_file_type_desc(FILE_TYPE_RWSIG)); } static void (*help_type[NUM_FILE_TYPES])(int argc, char *argv[]) = { [FILE_TYPE_PUBKEY] = &print_help_pubkey, [FILE_TYPE_RAW_FIRMWARE] = &print_help_raw_firmware, [FILE_TYPE_BIOS_IMAGE] = &print_help_bios_image, [FILE_TYPE_RAW_KERNEL] = &print_help_raw_kernel, [FILE_TYPE_KERN_PREAMBLE] = &print_help_kern_preamble, [FILE_TYPE_USBPD1] = &print_help_usbpd1, [FILE_TYPE_RWSIG] = &print_help_rwsig, }; static const char usage_default[] = "\n" "Usage: " MYNAME " %s [PARAMS] INFILE [OUTFILE]\n" "\n" "The following signing operations are supported:\n" "\n" " INFILE OUTFILE\n" " public key (.vbpubk) keyblock\n" " raw firmware blob (FW_MAIN_A/B) firmware preamble (VBLOCK_A/B)\n" " full firmware image (bios.bin) same, or signed in-place\n" " raw linux kernel (vmlinuz) kernel partition image\n" " kernel partition (/dev/sda2) same, or signed in-place\n" " usbpd1 firmware image same, or signed in-place\n" " RW device image same, or signed in-place\n" "\n" "For more information, use \"" MYNAME " help %s TYPE\", where\n" "TYPE is one of:\n\n"; static void print_help_default(int argc, char *argv[]) { enum futil_file_type type; printf(usage_default, argv[0], argv[0]); for (type = 0; type < NUM_FILE_TYPES; type++) if (help_type[type]) printf(" %s", futil_file_type_name(type)); printf("\n\n"); } static void print_help(int argc, char *argv[]) { enum futil_file_type type = FILE_TYPE_UNKNOWN; if (argc > 1) futil_str_to_file_type(argv[1], &type); if (help_type[type]) help_type[type](argc, argv); else print_help_default(argc, argv); } enum no_short_opts { OPT_FV = 1000, OPT_INFILE, OPT_OUTFILE, OPT_BOOTLOADER, OPT_CONFIG, OPT_ARCH, OPT_KLOADADDR, OPT_PADDING, OPT_PEM_SIGNPRIV, OPT_PEM_ALGO, OPT_PEM_EXTERNAL, OPT_TYPE, OPT_HASH_ALG, OPT_RO_SIZE, OPT_RW_SIZE, OPT_RO_OFFSET, OPT_RW_OFFSET, OPT_DATA_SIZE, OPT_SIG_SIZE, OPT_PRIKEY, OPT_HELP, }; static const struct option long_opts[] = { /* name hasarg *flag val */ {"signprivate", 1, NULL, 's'}, {"keyblock", 1, NULL, 'b'}, {"kernelkey", 1, NULL, 'k'}, {"devsign", 1, NULL, 'S'}, {"devkeyblock", 1, NULL, 'B'}, {"version", 1, NULL, 'v'}, {"flags", 1, NULL, 'f'}, {"loemdir", 1, NULL, 'd'}, {"loemid", 1, NULL, 'l'}, {"fv", 1, NULL, OPT_FV}, {"infile", 1, NULL, OPT_INFILE}, {"datapubkey", 1, NULL, OPT_INFILE}, /* alias */ {"vmlinuz", 1, NULL, OPT_INFILE}, /* alias */ {"outfile", 1, NULL, OPT_OUTFILE}, {"bootloader", 1, NULL, OPT_BOOTLOADER}, {"config", 1, NULL, OPT_CONFIG}, {"arch", 1, NULL, OPT_ARCH}, {"kloadaddr", 1, NULL, OPT_KLOADADDR}, {"pad", 1, NULL, OPT_PADDING}, {"pem_signpriv", 1, NULL, OPT_PEM_SIGNPRIV}, {"pem", 1, NULL, OPT_PEM_SIGNPRIV}, /* alias */ {"pem_algo", 1, NULL, OPT_PEM_ALGO}, {"pem_external", 1, NULL, OPT_PEM_EXTERNAL}, {"type", 1, NULL, OPT_TYPE}, {"vblockonly", 0, &sign_option.vblockonly, 1}, {"hash_alg", 1, NULL, OPT_HASH_ALG}, {"ro_size", 1, NULL, OPT_RO_SIZE}, {"rw_size", 1, NULL, OPT_RW_SIZE}, {"ro_offset", 1, NULL, OPT_RO_OFFSET}, {"rw_offset", 1, NULL, OPT_RW_OFFSET}, {"data_size", 1, NULL, OPT_DATA_SIZE}, {"sig_size", 1, NULL, OPT_SIG_SIZE}, {"prikey", 1, NULL, OPT_PRIKEY}, {"privkey", 1, NULL, OPT_PRIKEY}, /* alias */ {"help", 0, NULL, OPT_HELP}, {NULL, 0, NULL, 0}, }; static const char *short_opts = ":s:b:k:S:B:v:f:d:l:"; /* Return zero on success */ static int parse_number_opt(const char *arg, const char *name, uint32_t *dest) { char *e; uint32_t val = strtoul(arg, &e, 0); if (!*arg || (e && *e)) { fprintf(stderr, "Invalid --%s \"%s\"\n", name, arg); return 1; } *dest = val; return 0; } static int do_sign(int argc, char *argv[]) { char *infile = 0; int i; int ifd = -1; int errorcnt = 0; uint8_t *buf; uint32_t buf_len; char *e = 0; int mapping; int helpind = 0; int longindex; opterr = 0; /* quiet, you */ while ((i = getopt_long(argc, argv, short_opts, long_opts, &longindex)) != -1) { switch (i) { case 's': sign_option.signprivate = vb2_read_private_key(optarg); if (!sign_option.signprivate) { fprintf(stderr, "Error reading %s\n", optarg); errorcnt++; } break; case 'b': sign_option.keyblock = vb2_read_keyblock(optarg); if (!sign_option.keyblock) { fprintf(stderr, "Error reading %s\n", optarg); errorcnt++; } break; case 'k': sign_option.kernel_subkey = vb2_read_packed_key(optarg); if (!sign_option.kernel_subkey) { fprintf(stderr, "Error reading %s\n", optarg); errorcnt++; } break; case 'S': sign_option.devsignprivate = vb2_read_private_key(optarg); if (!sign_option.devsignprivate) { fprintf(stderr, "Error reading %s\n", optarg); errorcnt++; } break; case 'B': sign_option.devkeyblock = vb2_read_keyblock(optarg); if (!sign_option.devkeyblock) { fprintf(stderr, "Error reading %s\n", optarg); errorcnt++; } break; case 'v': sign_option.version_specified = 1; sign_option.version = strtoul(optarg, &e, 0); if (!*optarg || (e && *e)) { fprintf(stderr, "Invalid --version \"%s\"\n", optarg); errorcnt++; } break; case 'f': sign_option.flags_specified = 1; errorcnt += parse_number_opt(optarg, "flags", &sign_option.flags); break; case 'd': sign_option.loemdir = optarg; break; case 'l': sign_option.loemid = optarg; break; case OPT_FV: sign_option.fv_specified = 1; /* fallthrough */ case OPT_INFILE: sign_option.inout_file_count++; infile = optarg; break; case OPT_OUTFILE: sign_option.inout_file_count++; sign_option.outfile = optarg; break; case OPT_BOOTLOADER: sign_option.bootloader_data = ReadFile( optarg, &sign_option.bootloader_size); if (!sign_option.bootloader_data) { fprintf(stderr, "Error reading bootloader file: %s\n", strerror(errno)); errorcnt++; } VB2_DEBUG("bootloader file size=0x%" PRIx64 "\n", sign_option.bootloader_size); break; case OPT_CONFIG: sign_option.config_data = ReadConfigFile( optarg, &sign_option.config_size); if (!sign_option.config_data) { fprintf(stderr, "Error reading config file: %s\n", strerror(errno)); errorcnt++; } break; case OPT_ARCH: /* check the first 3 characters to also match x86_64 */ if ((!strncasecmp(optarg, "x86", 3)) || (!strcasecmp(optarg, "amd64"))) sign_option.arch = ARCH_X86; else if ((!strcasecmp(optarg, "arm")) || (!strcasecmp(optarg, "aarch64"))) sign_option.arch = ARCH_ARM; else if (!strcasecmp(optarg, "mips")) sign_option.arch = ARCH_MIPS; else { fprintf(stderr, "Unknown architecture: \"%s\"\n", optarg); errorcnt++; } break; case OPT_KLOADADDR: errorcnt += parse_number_opt(optarg, "kloadaddr", &sign_option.kloadaddr); break; case OPT_PADDING: errorcnt += parse_number_opt(optarg, "padding", &sign_option.padding); break; case OPT_RO_SIZE: errorcnt += parse_number_opt(optarg, "ro_size", &sign_option.ro_size); break; case OPT_RW_SIZE: errorcnt += parse_number_opt(optarg, "rw_size", &sign_option.rw_size); break; case OPT_RO_OFFSET: errorcnt += parse_number_opt(optarg, "ro_offset", &sign_option.ro_offset); break; case OPT_RW_OFFSET: errorcnt += parse_number_opt(optarg, "rw_offset", &sign_option.rw_offset); break; case OPT_DATA_SIZE: errorcnt += parse_number_opt(optarg, "data_size", &sign_option.data_size); break; case OPT_SIG_SIZE: errorcnt += parse_number_opt(optarg, "sig_size", &sign_option.sig_size); break; case OPT_PEM_SIGNPRIV: sign_option.pem_signpriv = optarg; break; case OPT_PEM_ALGO: sign_option.pem_algo_specified = 1; sign_option.pem_algo = strtoul(optarg, &e, 0); if (!*optarg || (e && *e) || (sign_option.pem_algo >= VB2_ALG_COUNT)) { fprintf(stderr, "Invalid --pem_algo \"%s\"\n", optarg); errorcnt++; } break; case OPT_HASH_ALG: if (!vb2_lookup_hash_alg(optarg, &sign_option.hash_alg)) { fprintf(stderr, "invalid hash_alg \"%s\"\n", optarg); errorcnt++; } break; case OPT_PEM_EXTERNAL: sign_option.pem_external = optarg; break; case OPT_TYPE: if (!futil_str_to_file_type(optarg, &sign_option.type)) { if (!strcasecmp("help", optarg)) print_file_types_and_exit(errorcnt); fprintf(stderr, "Invalid --type \"%s\"\n", optarg); errorcnt++; } break; case OPT_PRIKEY: if (vb21_private_key_read(&sign_option.prikey, optarg)) { fprintf(stderr, "Error reading %s\n", optarg); errorcnt++; } break; case OPT_HELP: helpind = optind - 1; break; case '?': if (optopt) fprintf(stderr, "Unrecognized option: -%c\n", optopt); else fprintf(stderr, "Unrecognized option: %s\n", argv[optind - 1]); errorcnt++; break; case ':': fprintf(stderr, "Missing argument to -%c\n", optopt); errorcnt++; break; case 0: /* handled option */ break; default: VB2_DEBUG("i=%d\n", i); DIE; } } if (helpind) { /* Skip all the options we've already parsed */ optind--; argv[optind] = argv[0]; argc -= optind; argv += optind; print_help(argc, argv); return !!errorcnt; } /* If we don't have an input file already, we need one */ if (!infile) { if (argc - optind <= 0) { errorcnt++; fprintf(stderr, "ERROR: missing input filename\n"); goto done; } else { sign_option.inout_file_count++; infile = argv[optind++]; } } /* Look for an output file if we don't have one, just in case. */ if (!sign_option.outfile && argc - optind > 0) { sign_option.inout_file_count++; sign_option.outfile = argv[optind++]; } /* What are we looking at? */ if (sign_option.type == FILE_TYPE_UNKNOWN && futil_file_type(infile, &sign_option.type)) { errorcnt++; goto done; } /* We may be able to infer the type based on the other args */ if (sign_option.type == FILE_TYPE_UNKNOWN) { if (sign_option.bootloader_data || sign_option.config_data || sign_option.arch != ARCH_UNSPECIFIED) sign_option.type = FILE_TYPE_RAW_KERNEL; else if (sign_option.kernel_subkey || sign_option.fv_specified) sign_option.type = FILE_TYPE_RAW_FIRMWARE; } VB2_DEBUG("type=%s\n", futil_file_type_name(sign_option.type)); /* Check the arguments for the type of thing we want to sign */ switch (sign_option.type) { case FILE_TYPE_PUBKEY: sign_option.create_new_outfile = 1; if (sign_option.signprivate && sign_option.pem_signpriv) { fprintf(stderr, "Only one of --signprivate and --pem_signpriv" " can be specified\n"); errorcnt++; } if ((sign_option.signprivate && sign_option.pem_algo_specified) || (sign_option.pem_signpriv && !sign_option.pem_algo_specified)) { fprintf(stderr, "--pem_algo must be used with" " --pem_signpriv\n"); errorcnt++; } if (sign_option.pem_external && !sign_option.pem_signpriv) { fprintf(stderr, "--pem_external must be used with" " --pem_signpriv\n"); errorcnt++; } /* We'll wait to read the PEM file, since the external signer * may want to read it instead. */ break; case FILE_TYPE_BIOS_IMAGE: case FILE_TYPE_OLD_BIOS_IMAGE: errorcnt += no_opt_if(!sign_option.signprivate, "signprivate"); errorcnt += no_opt_if(!sign_option.keyblock, "keyblock"); errorcnt += no_opt_if(!sign_option.kernel_subkey, "kernelkey"); break; case FILE_TYPE_KERN_PREAMBLE: errorcnt += no_opt_if(!sign_option.signprivate, "signprivate"); if (sign_option.vblockonly || sign_option.inout_file_count > 1) sign_option.create_new_outfile = 1; break; case FILE_TYPE_RAW_FIRMWARE: sign_option.create_new_outfile = 1; errorcnt += no_opt_if(!sign_option.signprivate, "signprivate"); errorcnt += no_opt_if(!sign_option.keyblock, "keyblock"); errorcnt += no_opt_if(!sign_option.kernel_subkey, "kernelkey"); errorcnt += no_opt_if(!sign_option.version_specified, "version"); break; case FILE_TYPE_RAW_KERNEL: sign_option.create_new_outfile = 1; errorcnt += no_opt_if(!sign_option.signprivate, "signprivate"); errorcnt += no_opt_if(!sign_option.keyblock, "keyblock"); errorcnt += no_opt_if(!sign_option.version_specified, "version"); errorcnt += no_opt_if(!sign_option.bootloader_data, "bootloader"); errorcnt += no_opt_if(!sign_option.config_data, "config"); errorcnt += no_opt_if(sign_option.arch == ARCH_UNSPECIFIED, "arch"); break; case FILE_TYPE_USBPD1: errorcnt += no_opt_if(!sign_option.pem_signpriv, "pem"); errorcnt += no_opt_if(sign_option.hash_alg == VB2_HASH_INVALID, "hash_alg"); break; case FILE_TYPE_RWSIG: if (sign_option.inout_file_count > 1) /* Signing raw data. No signature pre-exists. */ errorcnt += no_opt_if(!sign_option.prikey, "prikey"); break; default: /* Anything else we don't care */ break; } VB2_DEBUG("infile=%s\n", infile); VB2_DEBUG("sign_option.inout_file_count=%d\n", sign_option.inout_file_count); VB2_DEBUG("sign_option.create_new_outfile=%d\n", sign_option.create_new_outfile); /* Make sure we have an output file if one is needed */ if (!sign_option.outfile) { if (sign_option.create_new_outfile) { errorcnt++; fprintf(stderr, "Missing output filename\n"); goto done; } else { sign_option.outfile = infile; } } VB2_DEBUG("sign_option.outfile=%s\n", sign_option.outfile); if (argc - optind > 0) { errorcnt++; fprintf(stderr, "ERROR: too many arguments left over\n"); } if (errorcnt) goto done; if (sign_option.create_new_outfile) { /* The input is read-only, the output is write-only. */ mapping = MAP_RO; VB2_DEBUG("open RO %s\n", infile); ifd = open(infile, O_RDONLY); if (ifd < 0) { errorcnt++; fprintf(stderr, "Can't open %s for reading: %s\n", infile, strerror(errno)); goto done; } } else { /* We'll read-modify-write the output file */ mapping = MAP_RW; if (sign_option.inout_file_count > 1) futil_copy_file_or_die(infile, sign_option.outfile); VB2_DEBUG("open RW %s\n", sign_option.outfile); infile = sign_option.outfile; ifd = open(sign_option.outfile, O_RDWR); if (ifd < 0) { errorcnt++; fprintf(stderr, "Can't open %s for writing: %s\n", sign_option.outfile, strerror(errno)); goto done; } } if (0 != futil_map_file(ifd, mapping, &buf, &buf_len)) { errorcnt++; goto done; } errorcnt += futil_file_type_sign(sign_option.type, infile, buf, buf_len); errorcnt += futil_unmap_file(ifd, mapping, buf, buf_len); done: if (ifd >= 0 && close(ifd)) { errorcnt++; fprintf(stderr, "Error when closing ifd: %s\n", strerror(errno)); } if (sign_option.signprivate) free(sign_option.signprivate); if (sign_option.keyblock) free(sign_option.keyblock); if (sign_option.kernel_subkey) free(sign_option.kernel_subkey); if (sign_option.prikey) vb2_private_key_free(sign_option.prikey); if (errorcnt) fprintf(stderr, "Use --help for usage instructions\n"); return !!errorcnt; } DECLARE_FUTIL_COMMAND(sign, do_sign, VBOOT_VERSION_ALL, "Sign / resign various binary components");
30.77974
85
0.630514
4d0c483a007e72afbcd625ec239b28455540cf63
629
h
C
core/utility/materialreader.h
yslib/isosurfacerender
f4c6c592ffbf9ceec940eb46a83b4f388a89e51b
[ "MIT" ]
null
null
null
core/utility/materialreader.h
yslib/isosurfacerender
f4c6c592ffbf9ceec940eb46a83b4f388a89e51b
[ "MIT" ]
null
null
null
core/utility/materialreader.h
yslib/isosurfacerender
f4c6c592ffbf9ceec940eb46a83b4f388a89e51b
[ "MIT" ]
null
null
null
#ifndef _MATERIALREADER_H_ #define _MATERIALREADER_H_ #include <unordered_map> #include <string> #include "../mathematics/spectrum.h" namespace ysl { class MaterialReader { public: typedef std::unordered_map<std::string, RGBASpectrum> PropertyMap; typedef std::unordered_map<std::string, PropertyMap> MaterialLib; private: bool m_loaded; MaterialLib m_mLib; int test; public: explicit MaterialReader(const std::string& fileName); MaterialReader(); bool loadFromFile(const std::string& fileName); PropertyMap& operator[](const std::string& name); bool isLoaded() const; }; } #endif/*_MATERIAL_H_*/
19.65625
68
0.747218
4d0d5735bc3046a1291a49ff3c4f5e01b9669317
4,985
h
C
src/Installers/Windows/AspNetCoreModule-Setup/IIS-Setup/IIS-Common/Include/hybrid_array.h
legistek/AspNetCore
f8368097a909ba2618efbec5efa5e7e036d3a2e8
[ "Apache-2.0" ]
13,846
2020-01-07T21:33:57.000Z
2022-03-31T20:28:11.000Z
src/Installers/Windows/AspNetCoreModule-Setup/IIS-Setup/IIS-Common/Include/hybrid_array.h
legistek/AspNetCore
f8368097a909ba2618efbec5efa5e7e036d3a2e8
[ "Apache-2.0" ]
20,858
2020-01-07T21:28:23.000Z
2022-03-31T23:51:40.000Z
src/Installers/Windows/AspNetCoreModule-Setup/IIS-Setup/IIS-Common/Include/hybrid_array.h
legistek/AspNetCore
f8368097a909ba2618efbec5efa5e7e036d3a2e8
[ "Apache-2.0" ]
4,871
2020-01-07T21:27:37.000Z
2022-03-31T21:22:44.000Z
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. template<typename TYPE, SIZE_T SIZE> class HYBRID_ARRAY { public: HYBRID_ARRAY( VOID ) : m_pArray(m_InlineArray), m_Capacity(ARRAYSIZE(m_InlineArray)) { } ~HYBRID_ARRAY() { if ( !QueryUsesInlineArray() ) { delete [] m_pArray; m_pArray = NULL; } } SIZE_T QueryCapacity( VOID ) const { // // Number of elements available in the array. // return m_Capacity; } TYPE * QueryArray( VOID ) const { // // Raw pointer to the current array. // return m_pArray; } TYPE & QueryItem( __in const SIZE_T Index ) { // // Gets the array item giving the index. // return m_pArray[Index]; } TYPE & operator [] (const SIZE_T Index) { // // Operator override for convenience. // Please don't add other overloads like '++' '--' // in order to keep it simple. // return m_pArray[Index]; } const TYPE & operator [] (const SIZE_T Index) const { return m_pArray[Index]; } template<SIZE_T SourceSize> HRESULT Copy( __in TYPE const (&SourceArray)[SourceSize], __in bool fHasTrivialAssign = false ) /*++ Routine Description: Copies a source array like: int source[] = { 1, 2, 3 }; hr = hybridArray.Copy( source ); It will statically determinate the length of the source array. Arguments: SourceArray - The array to copy. SourceSize - The number of array elements. fHasTrivialAssign - True if safe to perform buffer copy. Return Value: HRESULT --*/ { return Copy( SourceArray, SourceSize, fHasTrivialAssign ); } HRESULT Copy( __in_ecount(SourceSize) const TYPE * pSourceArray, __in const SIZE_T SourceSize, __in bool fHasTrivialAssign = false ) /*++ Routine Description: Copies a source array. Arguments: pSourceArray - The array to copy. SourceSize - The number of array elements. fHasTrivialAssign - True if safe to perform buffer copy. Return Value: HRESULT --*/ { HRESULT hr; hr = EnsureCapacity( SourceSize, FALSE, // fCopyPrevious FALSE ); // fHasTrivialAssign if ( FAILED( hr ) ) { return hr; } if ( fHasTrivialAssign ) // Future Work: use std::tr1::has_trivial_assign { CopyMemory(m_pArray, pSourceArray, m_Capacity * sizeof(TYPE)); } else { for ( SIZE_T Index = 0; Index < SourceSize; ++Index ) { m_pArray[Index] = pSourceArray[Index]; } } return S_OK; } HRESULT EnsureCapacity( __in const SIZE_T MinimumCapacity, __in bool fCopyPrevious, __in bool fHasTrivialAssign = false ) /*++ Routine Description: Copies a source array. Arguments: MinimumCapacity - The expected length of the array. fCopyPrevious - Must be always explicit parameter. True if copy previous array data. fHasTrivialAssign - True if safe to perform buffer copy. Return Value: HRESULT --*/ { // // Caller is responsible for calculating a length that won't cause // too many reallocations in the future. // if ( MinimumCapacity <= ARRAYSIZE(m_InlineArray) ) { return S_OK; } TYPE * pNewArray; pNewArray = new TYPE[ MinimumCapacity ]; if ( pNewArray == NULL ) { return E_OUTOFMEMORY; } if ( fCopyPrevious ) { if ( fHasTrivialAssign ) { CopyMemory(pNewArray, m_pArray, m_Capacity * sizeof(TYPE)); } else { for ( SIZE_T Index = 0; Index < m_Capacity; ++Index ) { pNewArray[Index] = m_pArray[Index]; } } } if ( QueryUsesInlineArray() ) { m_pArray = pNewArray; } else { delete [] m_pArray; m_pArray = pNewArray; } m_Capacity = MinimumCapacity; return S_OK; } private: bool QueryUsesInlineArray( VOID ) const { return m_pArray == m_InlineArray; } TYPE m_InlineArray[SIZE]; TYPE * m_pArray; SIZE_T m_Capacity; };
20.514403
81
0.507924
4d0e25d40739efae9fbaa1a88ebf2f5aacaf5cb4
3,833
h
C
lib/nvmf/session.h
weber-wenbo-wang/spdk
33b38310d6a59652709d9d538669aa232133cdf1
[ "BSD-3-Clause" ]
null
null
null
lib/nvmf/session.h
weber-wenbo-wang/spdk
33b38310d6a59652709d9d538669aa232133cdf1
[ "BSD-3-Clause" ]
null
null
null
lib/nvmf/session.h
weber-wenbo-wang/spdk
33b38310d6a59652709d9d538669aa232133cdf1
[ "BSD-3-Clause" ]
null
null
null
/*- * BSD LICENSE * * Copyright (c) Intel Corporation. * 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 Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef NVMF_SESSION_H #define NVMF_SESSION_H #include <stdint.h> #include <stdbool.h> #include "spdk/nvmf_spec.h" #include "spdk/queue.h" /* define a virtual controller limit to the number of QPs supported */ #define MAX_SESSION_IO_QUEUES 64 struct spdk_nvmf_transport; enum conn_type { CONN_TYPE_AQ = 0, CONN_TYPE_IOQ = 1, }; struct spdk_nvmf_conn { const struct spdk_nvmf_transport *transport; struct spdk_nvmf_session *sess; enum conn_type type; uint16_t sq_head; uint16_t sq_head_max; TAILQ_ENTRY(spdk_nvmf_conn) link; }; /* * This structure maintains the NVMf virtual controller session * state. Each NVMf session permits some number of connections. * At least one admin connection and additional IOQ connections. */ struct spdk_nvmf_session { uint32_t id; struct spdk_nvmf_subsystem *subsys; struct { union spdk_nvme_cap_register cap; union spdk_nvme_vs_register vs; union spdk_nvme_cc_register cc; union spdk_nvme_csts_register csts; } vcprop; /* virtual controller properties */ struct spdk_nvme_ctrlr_data vcdata; /* virtual controller data */ TAILQ_HEAD(connection_q, spdk_nvmf_conn) connections; int num_connections; int max_connections_allowed; uint32_t kato; const struct spdk_nvmf_transport *transport; /* This is filled in by calling the transport's * session_init function. */ void *trctx; TAILQ_ENTRY(spdk_nvmf_session) link; }; void spdk_nvmf_session_connect(struct spdk_nvmf_conn *conn, struct spdk_nvmf_fabric_connect_cmd *cmd, struct spdk_nvmf_fabric_connect_data *data, struct spdk_nvmf_fabric_connect_rsp *rsp); void spdk_nvmf_session_disconnect(struct spdk_nvmf_conn *conn); void spdk_nvmf_property_get(struct spdk_nvmf_session *session, struct spdk_nvmf_fabric_prop_get_cmd *cmd, struct spdk_nvmf_fabric_prop_get_rsp *response); void spdk_nvmf_property_set(struct spdk_nvmf_session *session, struct spdk_nvmf_fabric_prop_set_cmd *cmd, struct spdk_nvme_cpl *rsp); int spdk_nvmf_session_poll(struct spdk_nvmf_session *session); void spdk_nvmf_session_destruct(struct spdk_nvmf_session *session); #endif
32.760684
74
0.756848
4d0e4c80836c3c0680655702c0204329b7c0f262
201
h
C
Pods/Target Support Files/Pods-NZHPositionCalenderView/Pods-NZHPositionCalenderView-umbrella.h
iiyumewo/NZHPositionCalenderView
9cc195c718314e850148b1651e62f18a9ce1ddd1
[ "MIT" ]
2
2018-12-19T10:48:33.000Z
2018-12-28T12:14:42.000Z
Pods/Target Support Files/Pods-NZHPositionCalenderView/Pods-NZHPositionCalenderView-umbrella.h
iiyumewo/NZHPositionCalenderView
9cc195c718314e850148b1651e62f18a9ce1ddd1
[ "MIT" ]
null
null
null
Pods/Target Support Files/Pods-NZHPositionCalenderView/Pods-NZHPositionCalenderView-umbrella.h
iiyumewo/NZHPositionCalenderView
9cc195c718314e850148b1651e62f18a9ce1ddd1
[ "MIT" ]
null
null
null
#ifdef __OBJC__ #import <UIKit/UIKit.h> #endif FOUNDATION_EXPORT double Pods_NZHPositionCalenderViewVersionNumber; FOUNDATION_EXPORT const unsigned char Pods_NZHPositionCalenderViewVersionString[];
22.333333
82
0.865672
4d0f027e5bd3a347a057a6cef250da82d1cf0976
7,414
c
C
drivers/usb/cdns3/cdns3-plat.c
jainsakshi2395/linux
7ccb860232bb83fb60cd6bcf5aaf0c008d903acb
[ "Linux-OpenIB" ]
null
null
null
drivers/usb/cdns3/cdns3-plat.c
jainsakshi2395/linux
7ccb860232bb83fb60cd6bcf5aaf0c008d903acb
[ "Linux-OpenIB" ]
1
2021-01-27T01:29:47.000Z
2021-01-27T01:29:47.000Z
drivers/usb/cdns3/cdns3-plat.c
jainsakshi2395/linux
7ccb860232bb83fb60cd6bcf5aaf0c008d903acb
[ "Linux-OpenIB" ]
null
null
null
// SPDX-License-Identifier: GPL-2.0 /* * Cadence USBSS DRD Driver. * * Copyright (C) 2018-2020 Cadence. * Copyright (C) 2017-2018 NXP * Copyright (C) 2019 Texas Instruments * * * Author: Peter Chen <peter.chen@nxp.com> * Pawel Laszczak <pawell@cadence.com> * Roger Quadros <rogerq@ti.com> */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> #include "core.h" #include "gadget-export.h" #include "drd.h" static int set_phy_power_on(struct cdns *cdns) { int ret; ret = phy_power_on(cdns->usb2_phy); if (ret) return ret; ret = phy_power_on(cdns->usb3_phy); if (ret) phy_power_off(cdns->usb2_phy); return ret; } static void set_phy_power_off(struct cdns *cdns) { phy_power_off(cdns->usb3_phy); phy_power_off(cdns->usb2_phy); } /** * cdns3_plat_probe - probe for cdns3 core device * @pdev: Pointer to cdns3 core platform device * * Returns 0 on success otherwise negative errno */ static int cdns3_plat_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct resource *res; struct cdns *cdns; void __iomem *regs; int ret; cdns = devm_kzalloc(dev, sizeof(*cdns), GFP_KERNEL); if (!cdns) return -ENOMEM; cdns->dev = dev; cdns->pdata = dev_get_platdata(dev); platform_set_drvdata(pdev, cdns); res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "host"); if (!res) { dev_err(dev, "missing host IRQ\n"); return -ENODEV; } cdns->xhci_res[0] = *res; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "xhci"); if (!res) { dev_err(dev, "couldn't get xhci resource\n"); return -ENXIO; } cdns->xhci_res[1] = *res; cdns->dev_irq = platform_get_irq_byname(pdev, "peripheral"); if (cdns->dev_irq < 0) return cdns->dev_irq; regs = devm_platform_ioremap_resource_byname(pdev, "dev"); if (IS_ERR(regs)) return PTR_ERR(regs); cdns->dev_regs = regs; cdns->otg_irq = platform_get_irq_byname(pdev, "otg"); if (cdns->otg_irq < 0) return cdns->otg_irq; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "otg"); if (!res) { dev_err(dev, "couldn't get otg resource\n"); return -ENXIO; } cdns->phyrst_a_enable = device_property_read_bool(dev, "cdns,phyrst-a-enable"); cdns->otg_res = *res; cdns->wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup"); if (cdns->wakeup_irq == -EPROBE_DEFER) return cdns->wakeup_irq; else if (cdns->wakeup_irq == 0) return -EINVAL; if (cdns->wakeup_irq < 0) { dev_dbg(dev, "couldn't get wakeup irq\n"); cdns->wakeup_irq = 0x0; } cdns->usb2_phy = devm_phy_optional_get(dev, "cdns3,usb2-phy"); if (IS_ERR(cdns->usb2_phy)) return PTR_ERR(cdns->usb2_phy); ret = phy_init(cdns->usb2_phy); if (ret) return ret; cdns->usb3_phy = devm_phy_optional_get(dev, "cdns3,usb3-phy"); if (IS_ERR(cdns->usb3_phy)) return PTR_ERR(cdns->usb3_phy); ret = phy_init(cdns->usb3_phy); if (ret) goto err_phy3_init; ret = set_phy_power_on(cdns); if (ret) goto err_phy_power_on; cdns->gadget_init = cdns3_gadget_init; ret = cdns_init(cdns); if (ret) goto err_cdns_init; device_set_wakeup_capable(dev, true); pm_runtime_set_active(dev); pm_runtime_enable(dev); if (!(cdns->pdata && (cdns->pdata->quirks & CDNS3_DEFAULT_PM_RUNTIME_ALLOW))) pm_runtime_forbid(dev); /* * The controller needs less time between bus and controller suspend, * and we also needs a small delay to avoid frequently entering low * power mode. */ pm_runtime_set_autosuspend_delay(dev, 20); pm_runtime_mark_last_busy(dev); pm_runtime_use_autosuspend(dev); return 0; err_cdns_init: set_phy_power_off(cdns); err_phy_power_on: phy_exit(cdns->usb3_phy); err_phy3_init: phy_exit(cdns->usb2_phy); return ret; } /** * cdns3_plat_remove() - unbind drd driver and clean up * @pdev: Pointer to Linux platform device * * Returns 0 on success otherwise negative errno */ static int cdns3_plat_remove(struct platform_device *pdev) { struct cdns *cdns = platform_get_drvdata(pdev); struct device *dev = cdns->dev; pm_runtime_get_sync(dev); pm_runtime_disable(dev); pm_runtime_put_noidle(dev); cdns_remove(cdns); set_phy_power_off(cdns); phy_exit(cdns->usb2_phy); phy_exit(cdns->usb3_phy); return 0; } #ifdef CONFIG_PM static int cdns3_set_platform_suspend(struct device *dev, bool suspend, bool wakeup) { struct cdns *cdns = dev_get_drvdata(dev); int ret = 0; if (cdns->pdata && cdns->pdata->platform_suspend) ret = cdns->pdata->platform_suspend(dev, suspend, wakeup); return ret; } static int cdns3_controller_suspend(struct device *dev, pm_message_t msg) { struct cdns *cdns = dev_get_drvdata(dev); bool wakeup; unsigned long flags; if (cdns->in_lpm) return 0; if (PMSG_IS_AUTO(msg)) wakeup = true; else wakeup = device_may_wakeup(dev); cdns3_set_platform_suspend(cdns->dev, true, wakeup); set_phy_power_off(cdns); spin_lock_irqsave(&cdns->lock, flags); cdns->in_lpm = true; spin_unlock_irqrestore(&cdns->lock, flags); dev_dbg(cdns->dev, "%s ends\n", __func__); return 0; } static int cdns3_controller_resume(struct device *dev, pm_message_t msg) { struct cdns *cdns = dev_get_drvdata(dev); int ret; unsigned long flags; if (!cdns->in_lpm) return 0; if (cdns_power_is_lost(cdns)) { phy_exit(cdns->usb2_phy); ret = phy_init(cdns->usb2_phy); if (ret) return ret; phy_exit(cdns->usb3_phy); ret = phy_init(cdns->usb3_phy); if (ret) return ret; } ret = set_phy_power_on(cdns); if (ret) return ret; cdns3_set_platform_suspend(cdns->dev, false, false); spin_lock_irqsave(&cdns->lock, flags); cdns_resume(cdns, !PMSG_IS_AUTO(msg)); cdns->in_lpm = false; spin_unlock_irqrestore(&cdns->lock, flags); if (cdns->wakeup_pending) { cdns->wakeup_pending = false; enable_irq(cdns->wakeup_irq); } dev_dbg(cdns->dev, "%s ends\n", __func__); return ret; } static int cdns3_plat_runtime_suspend(struct device *dev) { return cdns3_controller_suspend(dev, PMSG_AUTO_SUSPEND); } static int cdns3_plat_runtime_resume(struct device *dev) { return cdns3_controller_resume(dev, PMSG_AUTO_RESUME); } #ifdef CONFIG_PM_SLEEP static int cdns3_plat_suspend(struct device *dev) { struct cdns *cdns = dev_get_drvdata(dev); int ret; cdns_suspend(cdns); ret = cdns3_controller_suspend(dev, PMSG_SUSPEND); if (ret) return ret; if (device_may_wakeup(dev) && cdns->wakeup_irq) enable_irq_wake(cdns->wakeup_irq); return ret; } static int cdns3_plat_resume(struct device *dev) { return cdns3_controller_resume(dev, PMSG_RESUME); } #endif /* CONFIG_PM_SLEEP */ #endif /* CONFIG_PM */ static const struct dev_pm_ops cdns3_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(cdns3_plat_suspend, cdns3_plat_resume) SET_RUNTIME_PM_OPS(cdns3_plat_runtime_suspend, cdns3_plat_runtime_resume, NULL) }; #ifdef CONFIG_OF static const struct of_device_id of_cdns3_match[] = { { .compatible = "cdns,usb3" }, { }, }; MODULE_DEVICE_TABLE(of, of_cdns3_match); #endif static struct platform_driver cdns3_driver = { .probe = cdns3_plat_probe, .remove = cdns3_plat_remove, .driver = { .name = "cdns-usb3", .of_match_table = of_match_ptr(of_cdns3_match), .pm = &cdns3_pm_ops, }, }; module_platform_driver(cdns3_driver); MODULE_ALIAS("platform:cdns3"); MODULE_AUTHOR("Pawel Laszczak <pawell@cadence.com>"); MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("Cadence USB3 DRD Controller Driver");
22
80
0.723226
4d104f74fa714f192103f587587c759ea1b6dec5
605
h
C
TuSdk-xh/Frameworks/TuSDK.framework/Versions/A/Headers/TuSDKICGuideRegionView.h
Joygo-Technology/TuSdk-xh
d96cdcbcdfea2a62fb8930a002ceadb638c2e7dd
[ "MIT" ]
474
2017-05-05T03:45:03.000Z
2022-03-16T09:46:27.000Z
ShortVideoUIDemo/ShortVideo/Effects/TuSDK/TuSDK-framework/TuSDK.framework/Versions/A/Headers/TuSDKICGuideRegionView.h
shiyulong-ios/PLShortVideoKit
393c21dc5ed1a581d42d600e89b43c0edf8dac1b
[ "Apache-2.0" ]
108
2017-05-05T11:54:06.000Z
2021-09-28T03:27:47.000Z
ShortVideoUIDemo/ShortVideo/Effects/TuSDK/TuSDK-framework/TuSDK.framework/Versions/A/Headers/TuSDKICGuideRegionView.h
shiyulong-ios/PLShortVideoKit
393c21dc5ed1a581d42d600e89b43c0edf8dac1b
[ "Apache-2.0" ]
138
2017-05-05T03:52:58.000Z
2021-11-03T08:58:19.000Z
// // TuSDKICGuideRegionView.h // TuSDK // // Created by Yanlin on 10/15/15. // Copyright © 2015 tusdk.com. All rights reserved. // #import <UIKit/UIKit.h> @interface TuSDKICGuideRegionView : UIView { // 选区信息 CGRect _regionRect; // 是否显示辅助线 BOOL _displayGuideLine; } /** * 辅助线颜色 (默认:lsqRGBA(255, 255, 255, 0.6)) */ @property (nonatomic, retain) UIColor *guideLineColor; /** * 辅助线宽度 (默认:1) */ @property (nonatomic) CGFloat guideLineWidth; /** * 是否显示辅助线 */ @property (nonatomic) BOOL displayGuideLine; /** * 显示区域 */ @property (nonatomic) CGRect displayRect; @end
14.404762
54
0.647934
4d120cc689bcc45a933cbcb63378a284fb00db69
298
h
C
Pods/Headers/Public/DoraemonKit/DoraemonAppSettingPlugin.h
jc-wu-s-ios-materials/PractiseApp
8bb9085ae077a90b57dbdfe566c67c18940032c7
[ "Apache-2.0" ]
2
2019-09-04T02:55:43.000Z
2019-12-18T07:48:42.000Z
Pods/Headers/Public/DoraemonKit/DoraemonAppSettingPlugin.h
chong2vv/yd-general-ios-app
10f319008027d1c5bd3a2a8ba01d8d2fcbc5b9f6
[ "MIT" ]
null
null
null
Pods/Headers/Public/DoraemonKit/DoraemonAppSettingPlugin.h
chong2vv/yd-general-ios-app
10f319008027d1c5bd3a2a8ba01d8d2fcbc5b9f6
[ "MIT" ]
null
null
null
// // DoraemonAppSettingPlugin.h // DoraemonKit-DoraemonKit // // Created by didi on 2020/2/28. // #import <Foundation/Foundation.h> #import "DoraemonPluginProtocol.h" NS_ASSUME_NONNULL_BEGIN @interface DoraemonAppSettingPlugin : NSObject<DoraemonPluginProtocol> @end NS_ASSUME_NONNULL_END
16.555556
70
0.788591
4d123c0603c8cac6f1c8c9673b77e4b116c6ccfa
2,034
h
C
libraries/shared/src/BillboardMode.h
paranoimia/vircadia
bb9460f6d9e8fe6046a9e8c410add21a275bc641
[ "Apache-2.0" ]
null
null
null
libraries/shared/src/BillboardMode.h
paranoimia/vircadia
bb9460f6d9e8fe6046a9e8c410add21a275bc641
[ "Apache-2.0" ]
null
null
null
libraries/shared/src/BillboardMode.h
paranoimia/vircadia
bb9460f6d9e8fe6046a9e8c410add21a275bc641
[ "Apache-2.0" ]
null
null
null
// // Created by Sam Gondelman on 11/30/18. // Copyright 2018 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifndef hifi_BillboardMode_h #define hifi_BillboardMode_h #include <functional> #include "QString" #include "glm/glm.hpp" #include "glm/gtc/quaternion.hpp" /**jsdoc * <p>How an entity is billboarded.</p> * <table> * <thead> * <tr><th>Value</th><th>Description</th></tr> * </thead> * <tbody> * <tr><td><code>"none"</code></td><td>The entity will not be billboarded.</td></tr> * <tr><td><code>"yaw"</code></td><td>The entity will yaw, but not pitch, to face the camera. Its actual rotation will be * ignored.</td></tr> * <tr><td><code>"full"</code></td><td>The entity will yaw and pitch to face the camera. Its actual rotation will be * ignored.</td></tr> * </tbody> * </table> * @typedef {string} BillboardMode */ enum class BillboardMode { NONE = 0, YAW, FULL }; class BillboardModeHelpers { public: static QString getNameForBillboardMode(BillboardMode mode); static void setBillboardRotationOperator(std::function<glm::quat(const glm::vec3&, const glm::quat&, BillboardMode, const glm::vec3&, bool)> getBillboardRotationOperator); static glm::quat getBillboardRotation(const glm::vec3& position, const glm::quat& rotation, BillboardMode billboardMode, const glm::vec3& frustumPos, bool rotate90x = false); static void setPrimaryViewFrustumPositionOperator(std::function<glm::vec3()> getPrimaryViewFrustumPositionOperator); static glm::vec3 getPrimaryViewFrustumPosition() { return _getPrimaryViewFrustumPositionOperator(); } private: static std::function<glm::quat(const glm::vec3&, const glm::quat&, BillboardMode, const glm::vec3&, bool)> _getBillboardRotationOperator; static std::function<glm::vec3()> _getPrimaryViewFrustumPositionOperator; }; #endif // hifi_BillboardMode_h
34.474576
141
0.702557
4d14431bd720d762fc32502b69ddd719deb500b9
1,107
c
C
code/neurons/go.c
mlerner/CBootCamp
e96260f2e2b00f3444f92b2899f836ee47aae71a
[ "CC-BY-4.0" ]
138
2015-01-02T16:07:12.000Z
2022-01-17T03:24:23.000Z
code/neurons/go.c
mlerner/CBootCamp
e96260f2e2b00f3444f92b2899f836ee47aae71a
[ "CC-BY-4.0" ]
5
2016-01-15T10:31:20.000Z
2020-03-09T10:42:58.000Z
code/neurons/go.c
mlerner/CBootCamp
e96260f2e2b00f3444f92b2899f836ee47aae71a
[ "CC-BY-4.0" ]
38
2015-02-05T18:31:43.000Z
2021-12-20T21:36:01.000Z
// gcc -std=c99 -o go go.c neuron.c -lm #include <stdio.h> #include <stdlib.h> #include <string.h> #include "neuron.h" int main(int argc, char *argv[]) { int ncells = 100; // # cells to process char fnum[4], fname[128]; // filename strings double celldirs[40], cellspks[40]; // data for each cell double PD[ncells], plate_out[9]; // store cell PDs // loop to process each cell int i; for (i=1; i<=ncells; i++) { // construct the numeric part of the filename if (i<10) sprintf(fnum, "00%d", i); else if (i<100) sprintf(fnum, "0%d", i); else sprintf(fnum, "%d", i); // read in a dirs data file sprintf(fname, "data/cell_dirs_%s.txt", fnum); readcell(fname, celldirs, 40, 0); // read in a spks data file sprintf(fname, "data/cell_spks_%s.txt", fnum); readcell(fname, cellspks, 40, 0); // compute PD PD[i-1] = compute_PD(celldirs, cellspks, 40); } // print vector of PDs to screen and write to a file show_double_vec(PD, ncells); write_double_vec(PD, ncells, "PDs.txt"); return 0; }
25.159091
61
0.600723
4d144adb8e091959a0e7793e0e7a27e8f8d9dcee
7,986
h
C
code/CascadeEffect/CenterGoal.h
trc492/Ftc2015CascadeEffect
5c0fb2de3ddf364fef0c9f4bfcf33cf0ea146b29
[ "MIT" ]
null
null
null
code/CascadeEffect/CenterGoal.h
trc492/Ftc2015CascadeEffect
5c0fb2de3ddf364fef0c9f4bfcf33cf0ea146b29
[ "MIT" ]
null
null
null
code/CascadeEffect/CenterGoal.h
trc492/Ftc2015CascadeEffect
5c0fb2de3ddf364fef0c9f4bfcf33cf0ea146b29
[ "MIT" ]
null
null
null
void DoCenterGoal(SM &sm, unsigned long delay, int kickStandOption) { static float distTable1[] = {-63.0, -29.0, -18.0}; static float angleTable1[] = {-20.0, -45.0, 45.0}; static float irAngleTable[] = {9.8, 9.5, 9.5, 9.5}; static float sonarDistTable[] = {7.0, 8.5, 8.0}; PIDCtrlDisplayInfo(1, g_sonarPidCtrl); PIDCtrlDisplayInfo(3, g_irPidCtrl); if (SMIsReady(sm)) { int currState = SMGetState(sm); switch (currState) { case SMSTATE_STARTED: // // Raise the elevator and optionally wait delay. // PIDCtrlSetPowerLimits(g_encoderDrivePidCtrl, -30, 30); PIDCtrlSetPowerLimits(g_sonarPidCtrl, -20, 20); if (g_centerGoalPos == 0) { PIDCtrlSetPowerLimits(g_gyroTurnPidCtrl, -70, 70); } PIDCtrlSetPowerLimits(g_irPidCtrl, -50, 50); PIDMotorSetTarget(g_elevatorMotor, ELEVATOR_CENTERGOAL_HEIGHT, false); if (delay != 0) { TimerSet(g_timer, delay, &sm, EVTTYPE_TIMER); SMAddWaitEvent(sm, EVTTYPE_TIMER); SMWaitEvents(sm, currState + 1); } else { SMSetState(sm, currState + 1); } break; case SMSTATE_STARTED + 1: PIDDriveSetTarget(g_encoderPidDrive, distTable1[g_centerGoalPos], angleTable1[g_centerGoalPos], false, &sm, EVTTYPE_PIDDRIVE, 6000); SMAddWaitEvent(sm, EVTTYPE_PIDDRIVE); SMWaitEvents(sm, currState + 1); break; case SMSTATE_STARTED + 2: if (g_centerGoalPos == 0) { PIDDriveSetTarget(g_encoderPidDrive, 0.0, 110.0, false, &sm, EVTTYPE_PIDDRIVE, 3000); SMAddWaitEvent(sm, EVTTYPE_PIDDRIVE); SMWaitEvents(sm, currState + 1); } else { SMSetState(sm, currState + 1); } break; case SMSTATE_STARTED + 3: PIDDriveSetTarget(g_sonarIrPidDrive, 0.0, irAngleTable[g_centerGoalPos], false, &sm, EVTTYPE_PIDDRIVE, 3000); SMAddWaitEvent(sm, EVTTYPE_PIDDRIVE); SMWaitEvents(sm, currState + 1); break; case SMSTATE_STARTED + 4: PIDDriveSetTarget(g_sonarPidDrive, sonarDistTable[g_centerGoalPos], 0.0, false, &sm, EVTTYPE_PIDDRIVE, 5000); SMAddWaitEvent(sm, EVTTYPE_PIDDRIVE); SMWaitEvents(sm, currState + 1); break; case SMSTATE_STARTED + 5: TimerSet(g_timer, 1000, &sm, EVTTYPE_TIMER); SMAddWaitEvent(sm, EVTTYPE_TIMER); SMWaitEvents(sm, currState + 1); break; case SMSTATE_STARTED + 6: // // Dump the ball. // ServoSetAngle(g_drawBridgeServo, DRAWBRIDGE_RELEASE); TimerSet(g_timer, 3000, &sm, EVTTYPE_TIMER); SMAddWaitEvent(sm, EVTTYPE_TIMER); SMWaitEvents(sm, currState + 1); break; case SMSTATE_STARTED + 7: // // Raise Drawbridge, lower elevator and back up a bit. // ServoSetAngle(g_drawBridgeServo, DRAWBRIDGE_CAPTURE); PIDMotorSetTarget(g_elevatorMotor, ELEVATOR_DOWN_POS, false); PIDDriveSetTarget(g_encoderPidDrive, 12.0, 0.0, false, &sm, EVTTYPE_PIDDRIVE, 3000); SMAddWaitEvent(sm, EVTTYPE_PIDDRIVE); SMWaitEvents(sm, currState + 1); break; case SMSTATE_STARTED + 8: PIDDriveSetTarget(g_encoderPidDrive, 0.0, 45.0, false, &sm, EVTTYPE_PIDDRIVE, 3000); SMAddWaitEvent(sm, EVTTYPE_PIDDRIVE); if (kickStandOption == KICKSTAND_YES) { // // Go knock down kickstand. // SMWaitEvents(sm, currState + 1); } else { // // We are done. // SMWaitEvents(sm, 1000); } break; case SMSTATE_STARTED + 9: PIDDriveSetTarget(g_encoderPidDrive, -18.0, 0.0, false, &sm, EVTTYPE_PIDDRIVE, 3000); SMAddWaitEvent(sm, EVTTYPE_PIDDRIVE); SMWaitEvents(sm, currState + 1); break; case SMSTATE_STARTED + 10: PIDDriveSetTarget(g_encoderPidDrive, 0.0, -45.0, false, &sm, EVTTYPE_PIDDRIVE, 3000); SMAddWaitEvent(sm, EVTTYPE_PIDDRIVE); SMWaitEvents(sm, currState + 1); break; case SMSTATE_STARTED + 11: PIDDriveSetTarget(g_encoderPidDrive, -30.0, 0.0, false, &sm, EVTTYPE_PIDDRIVE, 3000); SMAddWaitEvent(sm, EVTTYPE_PIDDRIVE); SMWaitEvents(sm, currState + 1); break; case SMSTATE_STARTED + 12: PIDDriveSetTarget(g_encoderPidDrive, 0.0, 45.0, false, &sm, EVTTYPE_PIDDRIVE, 3000); SMAddWaitEvent(sm, EVTTYPE_PIDDRIVE); SMWaitEvents(sm, currState + 1); break; default: // // We are done, stop! // SMStop(sm); PlayTone(440, 50); break; } } } //DoCenterGoal
37.144186
70
0.362885
4d14dee80505ab22ad0f27b209e8c9819bd2f8a3
683
h
C
NetWork/httpmanager.h
fakegit/KLive
490fc56e3c32f30fce5a2e956355cd2d53777bda
[ "Apache-2.0" ]
87
2018-07-26T11:50:56.000Z
2022-02-23T03:19:46.000Z
NetWork/httpmanager.h
barry-ran/KLive
490fc56e3c32f30fce5a2e956355cd2d53777bda
[ "Apache-2.0" ]
null
null
null
NetWork/httpmanager.h
barry-ran/KLive
490fc56e3c32f30fce5a2e956355cd2d53777bda
[ "Apache-2.0" ]
40
2018-07-30T06:14:22.000Z
2022-03-31T07:43:49.000Z
#ifndef HTTPMANAGER_H #define HTTPMANAGER_H #include <QObject> #include "Global/global.h" #include <QNetworkAccessManager> class HttpManager : public QObject { Q_OBJECT public: explicit HttpManager(QObject *parent = nullptr); ~HttpManager(); APPCONFIG appConfig; //App配置 private: QNetworkAccessManager *m_NetManger = NULL; READCMD currentCmd; signals: void sig_ReadFinish(QByteArray data,READCMD cmd); //读取数据完成 public slots: void get(QUrl url,READCMD cmd); void post(QUrl url,QByteArray data,READCMD cmd); QString getTimeStamp(QDateTime time); private slots: void finished(QNetworkReply *reply); }; #endif // HTTPMANAGER_H
18.459459
64
0.727672
4d15ed3ef58bef33807ff0278093062a456bed9b
2,786
h
C
src/mongo/db/index/s2_simple_cursor.h
edaniels/mongo
60f9f92f966d7bfabe722d96bc6e196292a4d051
[ "Apache-2.0" ]
1
2015-12-19T08:02:37.000Z
2015-12-19T08:02:37.000Z
src/mongo/db/index/s2_simple_cursor.h
andremussche/minimongo
820d678f3561abb5660e27ff3204bd0e69dfe66c
[ "Apache-2.0" ]
null
null
null
src/mongo/db/index/s2_simple_cursor.h
andremussche/minimongo
820d678f3561abb5660e27ff3204bd0e69dfe66c
[ "Apache-2.0" ]
null
null
null
/** * Copyright (C) 2013 10gen Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <vector> #include "mongo/db/btreecursor.h" #include "mongo/db/geo/geoquery.h" #include "mongo/db/geo/s2common.h" #include "mongo/db/index/index_cursor.h" #include "mongo/db/index/index_descriptor.h" #include "mongo/db/jsobj.h" #include "mongo/db/pdfile.h" #include "mongo/platform/unordered_set.h" #include "third_party/s2/s2cap.h" #include "third_party/s2/s2regionintersection.h" namespace mongo { class S2SimpleCursor : public IndexCursor { public: S2SimpleCursor(IndexDescriptor* descriptor, const S2IndexingParams& params); virtual ~S2SimpleCursor() { } // Not implemented virtual Status seek(const BSONObj& position); Status setOptions(const CursorOptions& options); // Implemented: // Not part of the IndexCursor spec. void seek(const BSONObj& query, const vector<GeoQuery>& regions); bool isEOF() const; BSONObj getKey() const; DiskLoc getValue() const; void next(); virtual string toString(); virtual Status savePosition(); virtual Status restorePosition(); private: IndexDescriptor* _descriptor; // The query with the geo stuff taken out. We use this with a matcher. BSONObj _filteredQuery; // What geo regions are we looking for? vector<GeoQuery> _fields; // How were the keys created? We need this to search for the right stuff. S2IndexingParams _params; // What have we checked so we don't repeat it and waste time? unordered_set<DiskLoc, DiskLoc::Hasher> _seen; // This really does all the work/points into the btree. scoped_ptr<BtreeCursor> _btreeCursor; // Stat counters/debug information goes below: // How many items did we look at in the btree? long long _nscanned; // How many did we try to match? long long _matchTested; // How many did we geo-test? long long _geoTested; // How many cells were in our cover? long long _cellsInCover; }; } // namespace mongo
30.615385
84
0.670136
4d17e7124adf11ad7fa06baeb894a5662a61c2a2
619
h
C
thirdparty/libkafka_asio/detail/impl/bytes_streambuf.h
geesugar/front_server
b9c503e452dd4b3301f360c211a55f71bb363fbe
[ "MIT" ]
null
null
null
thirdparty/libkafka_asio/detail/impl/bytes_streambuf.h
geesugar/front_server
b9c503e452dd4b3301f360c211a55f71bb363fbe
[ "MIT" ]
null
null
null
thirdparty/libkafka_asio/detail/impl/bytes_streambuf.h
geesugar/front_server
b9c503e452dd4b3301f360c211a55f71bb363fbe
[ "MIT" ]
null
null
null
// // detail/impl/bytes_streambuf.h // ----------------------------- // // Copyright (c) 2015 Daniel Joos // // Distributed under MIT license. (See file LICENSE) // namespace libkafka_asio { namespace detail { inline BytesStreambuf::BytesStreambuf(Bytes data) : data_(data) { if (data_ && !data->empty()) { char_type* buffer_begin = reinterpret_cast<char_type*>(&(*data_)[0]); char_type* buffer_end = buffer_begin + data->size(); setg(buffer_begin, buffer_begin, buffer_end); } } inline Bytes BytesStreambuf::data() const { return data_; } } // namespace detail } // namespace libkafka_asio
18.757576
73
0.655897
4d18abb834033eb7e97dde8def116326e4cbd278
255
h
C
resource-manager/include/core.h
kitdallege/walden
99930f05c081ff489443bca44df36f218d92f2bd
[ "BSD-3-Clause" ]
null
null
null
resource-manager/include/core.h
kitdallege/walden
99930f05c081ff489443bca44df36f218d92f2bd
[ "BSD-3-Clause" ]
null
null
null
resource-manager/include/core.h
kitdallege/walden
99930f05c081ff489443bca44df36f218d92f2bd
[ "BSD-3-Clause" ]
null
null
null
#ifndef CORE_H #define CORE_H typedef struct Watcher Watcher; // defined in watcher.h typedef struct Configurator Configurator; // defined in config.h struct AppState { // system handles Configurator *configurator; Watcher *watcher; }; #endif
15.9375
64
0.74902
4d19446aecac8dc08f1e0c432814a423fe8aa7de
3,852
h
C
src/DlibDotNet.Native/dlib/gui_widgets/canvas_drawing.h
ejoebstl/DlibDotNet
47436a573c931fc9c9107442b10cf32524805378
[ "MIT" ]
387
2017-10-14T23:08:59.000Z
2022-03-28T05:26:44.000Z
src/DlibDotNet.Native/dlib/gui_widgets/canvas_drawing.h
ejoebstl/DlibDotNet
47436a573c931fc9c9107442b10cf32524805378
[ "MIT" ]
246
2017-10-09T11:40:20.000Z
2022-03-22T08:04:08.000Z
src/DlibDotNet.Native/dlib/gui_widgets/canvas_drawing.h
ejoebstl/DlibDotNet
47436a573c931fc9c9107442b10cf32524805378
[ "MIT" ]
113
2017-10-18T12:04:53.000Z
2022-03-28T09:05:27.000Z
#ifndef DLIB_NO_GUI_SUPPORT #ifndef _CPP_CANVAS_DRAWING_H_ #define _CPP_CANVAS_DRAWING_H_ #include "../export.h" #include <dlib/gui_widgets/canvas_drawing.h> #include <dlib/gui_core.h> #include <dlib/geometry/rectangle.h> #include <dlib/geometry/vector.h> #include <dlib/matrix.h> #include <dlib/pixel.h> #include "../shared.h" #include "../template.h" #pragma region template #define draw_line_canvas_template(__TYPE__, error, type, ...) \ dlib::draw_line(*c, *p1, *p2, *((__TYPE__*)p), *area); #define draw_line_canvas_infinity_template(__TYPE__, error, type, ...) \ dlib::draw_line(*c, *p1, *p2, *((__TYPE__*)p)); #define draw_rectangle_canvas_template(__TYPE__, error, type, ...) \ dlib::draw_rectangle(*c, *rect, *((__TYPE__*)p), *area); #define draw_rectangle_canvas_infinity_template(__TYPE__, error, type, ...) \ dlib::draw_rectangle(*c, *rect, *((__TYPE__*)p)); #define fill_rect_canvas_template(__TYPE__, error, type, ...) \ dlib::fill_rect(*c, *rect, *((__TYPE__*)p)); #pragma endregion template DLLEXPORT int draw_line_canvas(void* canvas, dlib::point* p1, dlib::point* p2, array2d_type type, void* p, dlib::rectangle* area) { int error = ERR_OK; dlib::canvas* c = static_cast<dlib::canvas*>(canvas); array2d_template(type, error, draw_line_canvas_template, c, p1, p2, p, area); return error; } DLLEXPORT int draw_line_canvas_infinity(void* canvas, dlib::point* p1, dlib::point* p2, array2d_type type, void* p) { int error = ERR_OK; dlib::canvas* c = static_cast<dlib::canvas*>(canvas); array2d_template(type, error, draw_line_canvas_infinity_template, c, p1, p2, p); return error; } DLLEXPORT int draw_rectangle_canvas(void* canvas, dlib::rectangle* rect, dlib::rectangle* area, array2d_type type, void* p) { int error = ERR_OK; dlib::canvas* c = static_cast<dlib::canvas*>(canvas); array2d_template(type, error, draw_rectangle_canvas_template, c, rect, p, area); return error; } DLLEXPORT int draw_rectangle_canvas_infinity(void* canvas, dlib::rectangle* rect, array2d_type type, void* p) { int error = ERR_OK; dlib::canvas* c = static_cast<dlib::canvas*>(canvas); array2d_template(type, error, draw_rectangle_canvas_infinity_template, c, rect, p); return error; } DLLEXPORT int fill_rect_canvas(void* canvas, dlib::rectangle* rect, array2d_type type, void* p) { int error = ERR_OK; dlib::canvas* c = static_cast<dlib::canvas*>(canvas); array2d_template(type, error, fill_rect_canvas_template, c, rect, p); return error; } #endif #endif
28.533333
77
0.474818
4d1ad4d8d723cc9ec6ad4a2472efc5cad39e0f41
5,454
h
C
Source/Nvidia/Blast/Include/extensions/authoring/include/NvBlastExtAuthoringMeshNoiser.h
Project-3-UPC-DDV-BCN/Project3
3fb345ce49485ccbc7d03fb320623df6114b210c
[ "MIT" ]
10
2018-01-16T16:18:42.000Z
2019-02-19T19:51:45.000Z
Source/Nvidia/Blast/Include/extensions/authoring/include/NvBlastExtAuthoringMeshNoiser.h
Project-3-UPC-DDV-BCN/Project3
3fb345ce49485ccbc7d03fb320623df6114b210c
[ "MIT" ]
136
2018-05-10T08:47:58.000Z
2018-06-15T09:38:10.000Z
Source/Nvidia/Blast/Include/extensions/authoring/include/NvBlastExtAuthoringMeshNoiser.h
Project-3-UPC-DDV-BCN/Project3
3fb345ce49485ccbc7d03fb320623df6114b210c
[ "MIT" ]
1
2018-06-04T17:18:40.000Z
2018-06-04T17:18:40.000Z
// This code contains NVIDIA Confidential Information and is disclosed to you // under a form of NVIDIA software license agreement provided separately to you. // // Notice // NVIDIA Corporation and its licensors retain all intellectual property and // proprietary rights in and to this software and related documentation and // any modifications thereto. Any use, reproduction, disclosure, or // distribution of this software and related documentation without an express // license agreement from NVIDIA Corporation is strictly prohibited. // // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. // // Information and code furnished is believed to be accurate and reliable. // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such // information or for any infringement of patents or other rights of third parties that may // result from its use. No license is granted by implication or otherwise under any patent // or patent rights of NVIDIA Corporation. Details are subject to change without notice. // This code supersedes and replaces all information previously supplied. // NVIDIA Corporation products are not authorized for use as critical // components in life support devices or systems without express written approval of // NVIDIA Corporation. // // Copyright (c) 2016-2018 NVIDIA Corporation. All rights reserved. #ifndef NVBLASTEXTAUTHORINGMESHNOISER_H #define NVBLASTEXTAUTHORINGMESHNOISER_H #include <vector> #include <map> #include "NvBlastExtAuthoringInternalCommon.h" namespace Nv { namespace Blast { class SimplexNoise; /** Structure used on tesselation stage. Maps edge to two neighboor triangles */ struct EdgeToTriangles { int32_t tr[2]; int32_t c; EdgeToTriangles() { c = 0; } /** Add triangle to edge. Should not be called more than twice for one edge!!!!. */ void add(int32_t t) { tr[c] = t; ++c; } /** Replaces mapping from one triangle to another. */ void replace(int32_t from, int32_t to) { if (tr[0] == from) { tr[0] = to; } else { if (c == 2 && tr[1] == from) { tr[1] = to; } } } /** Get triangle which is mapped by this edge and which index is different than provided. */ int32_t getNot(int32_t id) { if (tr[0] != id) { return tr[0]; } if (c == 2 && tr[1] != id) { return tr[1]; } return -1; } }; /** Tool for graphic mesh tesselation and adding noise to internal surface. Each triangle must have initialized Triangle::userInfo field (0 for external surface triangles and != 0 for internal) */ class MeshNoiser { public: MeshNoiser() { reset(); } void reset(); /** Edge flags */ enum EdgeFlag { INTERNAL_EDGE, EXTERNAL_BORDER_EDGE, INTERNAL_BORDER_EDGE, EXTERNAL_EDGE, NONE }; /** Set mesh to tesselate and apply noise */ void setMesh(const std::vector<Triangle>& mesh); /** Tesselate internal surface. \param[in] maxLen - maximal length of edge on internal surface. */ void tesselateInternalSurface(float maxLen); /** Apply noise to internal surface. Must be called only after tesselation!!! \param[in] noise - noise generator \param[in] falloff - damping of noise around of external surface \param[in] relaxIterations - number of smoothing iterations before applying noise \param[in] relaxFactor - amount of smooting before applying noise. */ void applyNoise(SimplexNoise& noise, float falloff, int32_t relaxIterations, float relaxFactor); std::vector<Triangle> getMesh(); private: PxVec3 mOffset; float mScale; bool isTesselated; /** Mesh data */ std::vector<Vertex> mVertices; std::vector<TriangleIndexed> mTriangles; std::vector<Edge> mEdges; std::map<Vertex, int32_t, VrtComp> mVertMap; std::map<Edge, int32_t> mEdgeMap; /** Final triangles. */ std::vector<Triangle> mResultTriangles; int32_t addVerticeIfNotExist(const Vertex& p); int32_t addEdge(const Edge& e); int32_t findEdge(const Edge& e); void collapseEdge(int32_t id); void divideEdge(int32_t id); void updateVertEdgeInfo(); void updateEdgeTriangleInfo(); void relax(int32_t iterations, float factor, std::vector<Vertex>& vertices); void recalcNoiseDirs(); std::vector<bool> mRestrictionFlag; std::vector<EdgeFlag> mEdgeFlag; std::vector<EdgeToTriangles> mTrMeshEdToTr; std::vector<int32_t> mVertexValence; std::vector<std::vector<int32_t> > mVertexToTriangleMap; std::vector<float> mVerticesDistances; std::vector<physx::PxVec3> mVerticesNormalsSmoothed; std::vector<int32_t> mPositionMappedVrt; std::vector<std::vector<int32_t> > mGeometryGraph; void prebuildEdgeFlagArray(); void computePositionedMapping(); void computeFalloffAndNormals(); void prebuildTesselatedTriangles(); }; } // namespace Blast } // namespace Nv #endif // ! NVBLASTEXTAUTHORINGMESHNOISER_H
28.113402
111
0.681518
4d1cac6357cde95280b8416f4af7009613c25395
1,252
h
C
System/Library/Frameworks/PhotosUI.framework/PUTilingDataSource.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
1
2020-11-04T15:43:01.000Z
2020-11-04T15:43:01.000Z
System/Library/Frameworks/PhotosUI.framework/PUTilingDataSource.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
System/Library/Frameworks/PhotosUI.framework/PUTilingDataSource.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
/* * This header is generated by classdump-dyld 1.0 * on Monday, September 28, 2020 at 5:54:55 PM Mountain Standard Time * Operating System: Version 14.0 (Build 18A373) * Image Source: /System/Library/Frameworks/PhotosUI.framework/PhotosUI * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ @class NSString, NSHashTable; @interface PUTilingDataSource : NSObject { NSString* _identifier; NSHashTable* __changeObservers; } @property (nonatomic,readonly) NSHashTable * _changeObservers; //@synthesize _changeObservers=__changeObservers - In the implementation block @property (nonatomic,retain) NSString * identifier; //@synthesize identifier=_identifier - In the implementation block -(NSString *)identifier; -(long long)numberOfSubItemsAtIndexPath:(id)arg1 ; -(void)setIdentifier:(NSString *)arg1 ; -(id)init; -(void)enumerateIndexPathsStartingAtIndexPath:(id)arg1 reverseDirection:(BOOL)arg2 usingBlock:(/*^block*/id)arg3 ; -(BOOL)isEqual:(id)arg1 ; -(unsigned long long)hash; -(id)description; -(NSHashTable *)_changeObservers; @end
39.125
154
0.66853