hexsha stringlengths 40 40 | size int64 5 1.05M | ext stringclasses 588
values | lang stringclasses 305
values | max_stars_repo_path stringlengths 3 363 | max_stars_repo_name stringlengths 5 118 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 10 | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringdate 2015-01-01 00:00:35 2022-03-31 23:43:49 ⌀ | max_stars_repo_stars_event_max_datetime stringdate 2015-01-01 12:37:38 2022-03-31 23:59:52 ⌀ | max_issues_repo_path stringlengths 3 363 | max_issues_repo_name stringlengths 5 118 | max_issues_repo_head_hexsha stringlengths 40 40 | max_issues_repo_licenses listlengths 1 10 | max_issues_count float64 1 134k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 363 | max_forks_repo_name stringlengths 5 135 | max_forks_repo_head_hexsha stringlengths 40 40 | max_forks_repo_licenses listlengths 1 10 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringdate 2015-01-01 00:01:02 2022-03-31 23:27:27 ⌀ | max_forks_repo_forks_event_max_datetime stringdate 2015-01-03 08:55:07 2022-03-31 23:59:24 ⌀ | content stringlengths 5 1.05M | avg_line_length float64 1.13 1.04M | max_line_length int64 1 1.05M | alphanum_fraction float64 0 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
fa2cbb550339a3cfd66bbea6ecc8c1ec665409f1 | 2,116 | h | C | paddle/fluid/framework/details/nan_inf_utils_detail.h | wwjiang007/Paddle | bdeb479c0edd1ab9bb5f696df3573dad63d67885 | [
"Apache-2.0"
] | 1 | 2022-02-07T05:37:49.000Z | 2022-02-07T05:37:49.000Z | paddle/fluid/framework/details/nan_inf_utils_detail.h | heiziiiii/Paddle | c6950ab2573aece1fa0728aef1446bd8b0b8c1a0 | [
"Apache-2.0"
] | null | null | null | paddle/fluid/framework/details/nan_inf_utils_detail.h | heiziiiii/Paddle | c6950ab2573aece1fa0728aef1446bd8b0b8c1a0 | [
"Apache-2.0"
] | 1 | 2021-08-21T06:57:20.000Z | 2021-08-21T06:57:20.000Z | // Copyright (c) 2019 PaddlePaddle Authors. 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.
#pragma once
#include <string>
#include "paddle/fluid/framework/scope.h"
#include "paddle/fluid/platform/place.h"
namespace pten {
class DenseTensor;
} // namespace pten
namespace paddle {
namespace framework {
namespace details {
template <typename DeviceContext>
struct TensorCheckerVisitor {
TensorCheckerVisitor(const std::string& op_type, const std::string& var_name,
const framework::Tensor& tensor,
const platform::Place& place)
: op_type_(op_type),
var_name_(var_name),
tensor_(tensor),
place_(place) {}
template <typename T>
void apply(
typename std::enable_if<std::is_integral<T>::value>::type* = 0) const {
VLOG(10) << var_name_ << " need not to check, it's type is not float point";
}
template <typename T>
void apply(
typename std::enable_if<
std::is_floating_point<T>::value ||
std::is_same<T, ::paddle::platform::complex<float>>::value ||
std::is_same<T, ::paddle::platform::complex<double>>::value>::type* =
0) const;
std::string op_type_;
std::string var_name_;
const framework::Tensor& tensor_;
const platform::Place& place_;
};
template <typename DeviceContext>
void tensor_check(const std::string& op_type, const std::string& var_name,
const framework::Tensor& tensor,
const platform::Place& place);
} // namespace details
} // namespace framework
} // namespace paddle
| 31.117647 | 80 | 0.677694 |
2c6e3bfece0f890b4e4aaaa322ff9023439b5137 | 2,022 | h | C | include/graphics/ui_bg_renderer.h | zhiyaluo/LongUI | af15e0594317c53375774ca69a0d769ec6e1866e | [
"MIT"
] | null | null | null | include/graphics/ui_bg_renderer.h | zhiyaluo/LongUI | af15e0594317c53375774ca69a0d769ec6e1866e | [
"MIT"
] | null | null | null | include/graphics/ui_bg_renderer.h | zhiyaluo/LongUI | af15e0594317c53375774ca69a0d769ec6e1866e | [
"MIT"
] | 1 | 2022-03-20T05:03:26.000Z | 2022-03-20T05:03:26.000Z | #pragma once
#include "../luiconf.h"
#ifndef LUI_DISABLE_STYLE_SUPPORT
#include "ui_renderer_decl.h"
#include "../core/ui_color.h"
#include "../core/ui_object.h"
#include "../core/ui_basic_type.h"
#include "../style/ui_attribute.h"
#include "../graphics/ui_graphics_decl.h"
namespace LongUI {
// box
struct Box;
// background renderer
class CUIRendererBackground : public CUISmallObject {
public:
// ctor
CUIRendererBackground() noexcept;
// dtor
~CUIRendererBackground() noexcept;
// move ctor
CUIRendererBackground(CUIRendererBackground&&) = delete;
// copy ctor
CUIRendererBackground(const CUIRendererBackground&) = delete;
// render color
void RenderColor(const Box& box, Size2F) const noexcept;
// render image
void RenderImage(const Box& box, Size2F) const noexcept;
// refresh image
auto RefreshImage() noexcept->Result;
// create device data
auto CreateDeviceData() noexcept->Result;
// release device data
void ReleaseDeviceData();
private:
// release brush
void release_brush() noexcept;
// ----------- CACHE-DATA -----------
// image size
Size2F m_szImage = {};
// ------------- GPU-RES ------------
// image brush
I::Brush* m_pImageBrush = nullptr;
public:
// ------------- CPU-RES ------------
// background-color
ColorF color;
// background-size
//Size2F size;
// background-image
uint32_t image_id = 0;
// background-clip
AttributeBox clip = Box_BorderBox;
// background-repeat
AttributeRepeat repeat = Repeat_Repeat;
// background-origin
AttributeBox origin = Box_PaddingBox;
// background-attachment
AttributeAttachment attachment = Attachment_Scroll;
};
}
#endif | 32.095238 | 69 | 0.568744 |
2cc8246ad668b27988948d4347e7df52b98ee730 | 29,718 | c | C | src/main/aerospike/as_predexp.c | ramunasd/aerospike-client-c | d94d2bc63e4ff7ae84e366f3590a83b18968bf82 | [
"Apache-2.0"
] | 78 | 2015-01-28T00:55:38.000Z | 2021-12-07T18:38:58.000Z | src/main/aerospike/as_predexp.c | ramunasd/aerospike-client-c | d94d2bc63e4ff7ae84e366f3590a83b18968bf82 | [
"Apache-2.0"
] | 104 | 2015-01-26T16:17:19.000Z | 2022-03-22T18:18:29.000Z | src/main/aerospike/as_predexp.c | ramunasd/aerospike-client-c | d94d2bc63e4ff7ae84e366f3590a83b18968bf82 | [
"Apache-2.0"
] | 102 | 2015-01-22T12:28:28.000Z | 2022-03-15T21:54:44.000Z | /*
* Copyright 2008-2020 Aerospike, Inc.
*
* Portions may be licensed to Aerospike, Inc. under one or more contributor
* license agreements.
*
* 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 <aerospike/aerospike_index.h>
#include <aerospike/as_bin.h>
#include <aerospike/as_command.h>
#include <aerospike/as_key.h>
#include <aerospike/as_log_macros.h>
#include <aerospike/as_predexp.h>
#include <citrusleaf/cf_byte_order.h>
/*
Wire Protocol Notes
Predicate expressions are marshaled into a message field with
type AS_MSG_FIELD_TYPE_PREDEXP.
The field data consists of a sequence of TLV (Tag-Length-Value)
encoded expressions. All values are represented in network byte order
(big-endian). The tag field is 2 bytes and descriminates the
expression type. The length field is 4 bytes long and describes the
length of the value field. The value field is expression-specific.
For example a predexp string value of "foo" would be encoded as:
TAG: 0x00 0x0b
LEN: 0x00 0x00 0x00 0x03
VAL: 0x66 0x6f 0x6f
*/
// Predicate Expression Tag Values
#define AS_PREDEXP_AND 1
#define AS_PREDEXP_OR 2
#define AS_PREDEXP_NOT 3
#define AS_PREDEXP_INTEGER_VALUE 10
#define AS_PREDEXP_STRING_VALUE 11
#define AS_PREDEXP_GEOJSON_VALUE 12
#define AS_PREDEXP_INTEGER_BIN 100
#define AS_PREDEXP_STRING_BIN 101
#define AS_PREDEXP_GEOJSON_BIN 102
#define AS_PREDEXP_LIST_BIN 103
#define AS_PREDEXP_MAP_BIN 104
#define AS_PREDEXP_INTEGER_VAR 120
#define AS_PREDEXP_STRING_VAR 121
#define AS_PREDEXP_GEOJSON_VAR 122
#define AS_PREDEXP_REC_DEVICE_SIZE 150
#define AS_PREDEXP_REC_LAST_UPDATE 151
#define AS_PREDEXP_REC_VOID_TIME 152
#define AS_PREDEXP_REC_DIGEST_MODULO 153
#define AS_PREDEXP_INTEGER_EQUAL 200
#define AS_PREDEXP_INTEGER_UNEQUAL 201
#define AS_PREDEXP_INTEGER_GREATER 202
#define AS_PREDEXP_INTEGER_GREATEREQ 203
#define AS_PREDEXP_INTEGER_LESS 204
#define AS_PREDEXP_INTEGER_LESSEQ 205
#define AS_PREDEXP_STRING_EQUAL 210
#define AS_PREDEXP_STRING_UNEQUAL 211
#define AS_PREDEXP_STRING_REGEX 212
#define AS_PREDEXP_GEOJSON_WITHIN 220
#define AS_PREDEXP_GEOJSON_CONTAINS 221
#define AS_PREDEXP_LIST_ITERATE_OR 250
#define AS_PREDEXP_MAPKEY_ITERATE_OR 251
#define AS_PREDEXP_MAPVAL_ITERATE_OR 252
#define AS_PREDEXP_LIST_ITERATE_AND 253
#define AS_PREDEXP_MAPKEY_ITERATE_AND 254
#define AS_PREDEXP_MAPVAL_ITERATE_AND 255
// ----------------------------------------------------------------
// predexp list
// ----------------------------------------------------------------
void
as_predexp_list_destroy(as_predexp_list* predexp)
{
if (! predexp) {
return;
}
as_vector* list = &predexp->list;
uint32_t max = list->size;
for (uint32_t i = 0; i < max; i++) {
as_predexp_base* bp = as_vector_get_ptr(list, i);
if (bp->dtor_fn) {
(*bp->dtor_fn)(bp);
}
}
as_vector_destroy(list);
}
size_t
as_predexp_list_size(as_predexp_list* predexp, uint32_t* predexp_size)
{
as_vector* list = &predexp->list;
uint32_t size = 0;
uint32_t max = list->size;
for (uint32_t i = 0; i < max; i++) {
as_predexp_base* bp = as_vector_get_ptr(list, i);
size += (uint32_t)(*bp->size_fn)(bp);
}
*predexp_size = size;
return (size_t)(size + AS_FIELD_HEADER_SIZE);
}
uint8_t*
as_predexp_list_write(as_predexp_list* predexp, uint32_t predexp_size, uint8_t* p)
{
p = as_command_write_field_header(p, AS_FIELD_FILTER, predexp_size);
as_vector* list = &predexp->list;
uint32_t max = list->size;
for (uint32_t i = 0; i < max; i++) {
as_predexp_base* bp = as_vector_get_ptr(list, i);
p = (*bp->write_fn)(bp, p);
}
return p;
}
// ----------------------------------------------------------------
// as_predexp_and
// ----------------------------------------------------------------
typedef struct {
as_predexp_base base;
uint16_t nexpr;
} as_predexp_and_t;
void as_predexp_and_dtor(as_predexp_base * bp)
{
as_predexp_and_t * dp = (as_predexp_and_t *) bp;
cf_free(dp);
}
size_t as_predexp_and_size(as_predexp_base * bp)
{
size_t sz = sizeof(uint16_t) + sizeof(uint32_t); // TAG + LEN
sz += sizeof(uint16_t); // nexpr
return sz;
}
uint8_t * as_predexp_and_write(as_predexp_base * bp, uint8_t * p)
{
as_predexp_and_t * dp = (as_predexp_and_t *) bp;
// TAG
uint16_t * tag_ptr = (uint16_t *) p;
p += sizeof(uint16_t);
*tag_ptr = cf_swap_to_be16(AS_PREDEXP_AND);
// LEN
uint32_t * len_ptr = (uint32_t *) p;
p += sizeof(uint32_t);
*len_ptr = cf_swap_to_be32(sizeof(uint16_t));
// nexpr
uint16_t * nexpr_ptr = (uint16_t *) p;
p += sizeof(uint16_t);
*nexpr_ptr = cf_swap_to_be16(dp->nexpr);
return p;
}
as_predexp_base * as_predexp_and(uint16_t nexpr)
{
as_predexp_and_t * dp =
(as_predexp_and_t *)
cf_malloc(sizeof(as_predexp_and_t));
dp->base.dtor_fn = as_predexp_and_dtor;
dp->base.size_fn = as_predexp_and_size;
dp->base.write_fn = as_predexp_and_write;
dp->nexpr = nexpr;
return (as_predexp_base *) dp;
}
// ----------------------------------------------------------------
// as_predexp_or
// ----------------------------------------------------------------
typedef struct {
as_predexp_base base;
uint16_t nexpr;
} as_predexp_or_t;
void as_predexp_or_dtor(as_predexp_base * bp)
{
as_predexp_or_t * dp = (as_predexp_or_t *) bp;
cf_free(dp);
}
size_t as_predexp_or_size(as_predexp_base * bp)
{
size_t sz = sizeof(uint16_t) + sizeof(uint32_t); // TAG + LEN
sz += sizeof(uint16_t); // nexpr
return sz;
}
uint8_t * as_predexp_or_write(as_predexp_base * bp, uint8_t * p)
{
as_predexp_or_t * dp = (as_predexp_or_t *) bp;
// TAG
uint16_t * tag_ptr = (uint16_t *) p;
p += sizeof(uint16_t);
*tag_ptr = cf_swap_to_be16(AS_PREDEXP_OR);
// LEN
uint32_t * len_ptr = (uint32_t *) p;
p += sizeof(uint32_t);
*len_ptr = cf_swap_to_be32(sizeof(uint16_t));
// nexpr
uint16_t * nexpr_ptr = (uint16_t *) p;
p += sizeof(uint16_t);
*nexpr_ptr = cf_swap_to_be16(dp->nexpr);
return p;
}
as_predexp_base * as_predexp_or(uint16_t nexpr)
{
as_predexp_or_t * dp =
(as_predexp_or_t *)
cf_malloc(sizeof(as_predexp_or_t));
dp->base.dtor_fn = as_predexp_or_dtor;
dp->base.size_fn = as_predexp_or_size;
dp->base.write_fn = as_predexp_or_write;
dp->nexpr = nexpr;
return (as_predexp_base *) dp;
}
// ----------------------------------------------------------------
// as_predexp_not
// ----------------------------------------------------------------
typedef struct {
as_predexp_base base;
} as_predexp_not_t;
void as_predexp_not_dtor(as_predexp_base * bp)
{
as_predexp_not_t * dp = (as_predexp_not_t *) bp;
cf_free(dp);
}
size_t as_predexp_not_size(as_predexp_base * bp)
{
size_t sz = sizeof(uint16_t) + sizeof(uint32_t); // TAG + LEN
return sz;
}
uint8_t * as_predexp_not_write(as_predexp_base * bp, uint8_t * p)
{
// as_predexp_not_t * dp = (as_predexp_not_t *) bp;
// TAG
uint16_t * tag_ptr = (uint16_t *) p;
p += sizeof(uint16_t);
*tag_ptr = cf_swap_to_be16(AS_PREDEXP_NOT);
// LEN
uint32_t * len_ptr = (uint32_t *) p;
p += sizeof(uint32_t);
*len_ptr = cf_swap_to_be32(0);
return p;
}
as_predexp_base * as_predexp_not()
{
as_predexp_not_t * dp =
(as_predexp_not_t *)
cf_malloc(sizeof(as_predexp_not_t));
dp->base.dtor_fn = as_predexp_not_dtor;
dp->base.size_fn = as_predexp_not_size;
dp->base.write_fn = as_predexp_not_write;
return (as_predexp_base *) dp;
}
// ----------------------------------------------------------------
// as_predexp_integer_value
// ----------------------------------------------------------------
typedef struct {
as_predexp_base base;
int64_t value;
} as_predexp_integer_value_t;
void as_predexp_integer_value_dtor(as_predexp_base * bp)
{
as_predexp_integer_value_t * dp = (as_predexp_integer_value_t *) bp;
cf_free(dp);
}
size_t as_predexp_integer_value_size(as_predexp_base * bp)
{
// as_predexp_integer_value_t * dp = (as_predexp_integer_value_t *) bp;
size_t sz = sizeof(uint16_t) + sizeof(uint32_t); // TAG + LEN
sz += sizeof(int64_t); // value
return sz;
}
uint8_t * as_predexp_integer_value_write(as_predexp_base * bp, uint8_t * p)
{
as_predexp_integer_value_t * dp = (as_predexp_integer_value_t *) bp;
// TAG
uint16_t * tag_ptr = (uint16_t *) p;
p += sizeof(uint16_t);
*tag_ptr = cf_swap_to_be16(AS_PREDEXP_INTEGER_VALUE);
// LEN
uint32_t * len_ptr = (uint32_t *) p;
p += sizeof(uint32_t);
*len_ptr = cf_swap_to_be32(sizeof(int64_t));
// value
int64_t * value_ptr = (int64_t *) p;
p += sizeof(int64_t);
*value_ptr = cf_swap_to_be64(dp->value);
return p;
}
as_predexp_base * as_predexp_integer_value(int64_t value)
{
as_predexp_integer_value_t * dp =
(as_predexp_integer_value_t *)
cf_malloc(sizeof(as_predexp_integer_value_t));
dp->base.dtor_fn = as_predexp_integer_value_dtor;
dp->base.size_fn = as_predexp_integer_value_size;
dp->base.write_fn = as_predexp_integer_value_write;
dp->value = value;
return (as_predexp_base *) dp;
}
// ----------------------------------------------------------------
// as_predexp_string_value
// ----------------------------------------------------------------
typedef struct {
as_predexp_base base;
char const * value;
} as_predexp_string_value_t;
void as_predexp_string_value_dtor(as_predexp_base * bp)
{
as_predexp_string_value_t * dp = (as_predexp_string_value_t *) bp;
if (dp->value) {
cf_free((char *) dp->value);
}
cf_free(dp);
}
size_t as_predexp_string_value_size(as_predexp_base * bp)
{
as_predexp_string_value_t * dp = (as_predexp_string_value_t *) bp;
size_t sz = sizeof(uint16_t) + sizeof(uint32_t); // TAG + LEN
sz += strlen(dp->value); // value
return sz;
}
uint8_t * as_predexp_string_value_write(as_predexp_base * bp, uint8_t * p)
{
as_predexp_string_value_t * dp = (as_predexp_string_value_t *) bp;
uint32_t vlen = (uint32_t)strlen(dp->value);
// TAG
uint16_t * tag_ptr = (uint16_t *) p;
p += sizeof(uint16_t);
*tag_ptr = cf_swap_to_be16(AS_PREDEXP_STRING_VALUE);
// LEN
uint32_t * len_ptr = (uint32_t *) p;
p += sizeof(uint32_t);
*len_ptr = cf_swap_to_be32(vlen);
// value
char * vptr = (char *) p;
p += vlen;
memcpy(vptr, dp->value, vlen);
return p;
}
as_predexp_base * as_predexp_string_value(char const * value)
{
as_predexp_string_value_t * dp =
(as_predexp_string_value_t *)
cf_malloc(sizeof(as_predexp_string_value_t));
dp->base.dtor_fn = as_predexp_string_value_dtor;
dp->base.size_fn = as_predexp_string_value_size;
dp->base.write_fn = as_predexp_string_value_write;
dp->value = cf_strdup(value);
return (as_predexp_base *) dp;
}
// ----------------------------------------------------------------
// as_predexp_geojson_value
// ----------------------------------------------------------------
typedef struct {
as_predexp_base base;
char const * value;
} as_predexp_geojson_value_t;
void as_predexp_geojson_value_dtor(as_predexp_base * bp)
{
as_predexp_geojson_value_t * dp = (as_predexp_geojson_value_t *) bp;
if (dp->value) {
cf_free((char *) dp->value);
}
cf_free(dp);
}
size_t as_predexp_geojson_value_size(as_predexp_base * bp)
{
as_predexp_geojson_value_t * dp = (as_predexp_geojson_value_t *) bp;
size_t sz = sizeof(uint16_t) + sizeof(uint32_t); // TAG + LEN
sz += sizeof(uint8_t); // flags
sz += sizeof(uint16_t); // ncells
sz += strlen(dp->value); // value
return sz;
}
uint8_t * as_predexp_geojson_value_write(as_predexp_base * bp, uint8_t * p)
{
as_predexp_geojson_value_t * dp = (as_predexp_geojson_value_t *) bp;
size_t slen = strlen(dp->value);
uint32_t vlen = (uint32_t)(sizeof(uint8_t) + sizeof(uint16_t) + slen);
// TAG
uint16_t * tag_ptr = (uint16_t *) p;
p += sizeof(uint16_t);
*tag_ptr = cf_swap_to_be16(AS_PREDEXP_GEOJSON_VALUE);
// LEN
uint32_t * len_ptr = (uint32_t *) p;
p += sizeof(uint32_t);
*len_ptr = cf_swap_to_be32(vlen);
// flags
uint8_t * flags_ptr = (uint8_t *) p;
p += sizeof(uint8_t);
*flags_ptr = 0;
// ncells
uint16_t * ncells_ptr = (uint16_t *) p;
p += sizeof(uint16_t);
*ncells_ptr = cf_swap_to_be16(0);
// value
char * vptr = (char *) p;
p += slen;
memcpy(vptr, dp->value, slen);
return p;
}
as_predexp_base * as_predexp_geojson_value(char const * value)
{
as_predexp_geojson_value_t * dp =
(as_predexp_geojson_value_t *)
cf_malloc(sizeof(as_predexp_geojson_value_t));
dp->base.dtor_fn = as_predexp_geojson_value_dtor;
dp->base.size_fn = as_predexp_geojson_value_size;
dp->base.write_fn = as_predexp_geojson_value_write;
dp->value = cf_strdup(value);
return (as_predexp_base *) dp;
}
// ----------------------------------------------------------------
// as_predexp_*_bin
// ----------------------------------------------------------------
typedef struct {
as_predexp_base base;
char * binname;
uint16_t tag; // Not written to wire
} as_predexp_bin_t;
void as_predexp_bin_dtor(as_predexp_base * bp)
{
as_predexp_bin_t * dp = (as_predexp_bin_t *) bp;
if (dp->binname)
cf_free(dp->binname);
cf_free(dp);
}
size_t as_predexp_bin_size(as_predexp_base * bp)
{
as_predexp_bin_t * dp = (as_predexp_bin_t *) bp;
size_t sz = sizeof(uint16_t) + sizeof(uint32_t); // TAG + LEN
sz += strlen(dp->binname); // binname
return sz;
}
uint8_t * as_predexp_bin_write(as_predexp_base * bp, uint8_t * p)
{
as_predexp_bin_t * dp = (as_predexp_bin_t *) bp;
uint32_t len = (uint32_t)strlen(dp->binname);
// TAG
uint16_t * tag_ptr = (uint16_t *) p;
p += sizeof(uint16_t);
*tag_ptr = cf_swap_to_be16(dp->tag);
// LEN
uint32_t * len_ptr = (uint32_t *) p;
p += sizeof(uint32_t);
*len_ptr = cf_swap_to_be32(len);
// binname value
char * bnptr = (char *) p;
p += len;
memcpy(bnptr, dp->binname, len);
return p;
}
static as_predexp_base * as_predexp_bin(char const * binname, uint16_t tag)
{
if (!binname) {
as_log_error("missing bin name argument");
return NULL;
}
else if (strlen(binname) >= AS_BIN_NAME_MAX_SIZE) {
as_log_error("bin name \"%s\" too long", binname);
return NULL;
}
as_predexp_bin_t * dp =
(as_predexp_bin_t *)
cf_malloc(sizeof(as_predexp_bin_t));
dp->base.dtor_fn = as_predexp_bin_dtor;
dp->base.size_fn = as_predexp_bin_size;
dp->base.write_fn = as_predexp_bin_write;
dp->binname = cf_strdup(binname);
dp->tag = tag;
return (as_predexp_base *) dp;
}
as_predexp_base * as_predexp_integer_bin(char const * binname)
{
return as_predexp_bin(binname, AS_PREDEXP_INTEGER_BIN);
}
as_predexp_base * as_predexp_string_bin(char const * binname)
{
return as_predexp_bin(binname, AS_PREDEXP_STRING_BIN);
}
as_predexp_base * as_predexp_geojson_bin(char const * binname)
{
return as_predexp_bin(binname, AS_PREDEXP_GEOJSON_BIN);
}
as_predexp_base * as_predexp_list_bin(char const * binname)
{
return as_predexp_bin(binname, AS_PREDEXP_LIST_BIN);
}
as_predexp_base * as_predexp_map_bin(char const * binname)
{
return as_predexp_bin(binname, AS_PREDEXP_MAP_BIN);
}
// ----------------------------------------------------------------
// as_predexp_*_var
// ----------------------------------------------------------------
typedef struct {
as_predexp_base base;
char * varname;
uint16_t tag; // Not written to wire
} as_predexp_var_t;
void as_predexp_var_dtor(as_predexp_base * bp)
{
as_predexp_var_t * dp = (as_predexp_var_t *) bp;
if (dp->varname)
cf_free(dp->varname);
cf_free(dp);
}
size_t as_predexp_var_size(as_predexp_base * bp)
{
as_predexp_var_t * dp = (as_predexp_var_t *) bp;
size_t sz = sizeof(uint16_t) + sizeof(uint32_t); // TAG + LEN
sz += strlen(dp->varname); // varname
return sz;
}
uint8_t * as_predexp_var_write(as_predexp_base * bp, uint8_t * p)
{
as_predexp_var_t * dp = (as_predexp_var_t *) bp;
uint32_t len = (uint32_t)strlen(dp->varname);
// TAG
uint16_t * tag_ptr = (uint16_t *) p;
p += sizeof(uint16_t);
*tag_ptr = cf_swap_to_be16(dp->tag);
// LEN
uint32_t * len_ptr = (uint32_t *) p;
p += sizeof(uint32_t);
*len_ptr = cf_swap_to_be32(len);
// varname value
char * bnptr = (char *) p;
p += len;
memcpy(bnptr, dp->varname, len);
return p;
}
static as_predexp_base * as_predexp_var(char const * varname, uint16_t tag)
{
if (!varname) {
as_log_error("missing var name argument");
return NULL;
}
else if (strlen(varname) >= AS_BIN_NAME_MAX_SIZE) {
as_log_error("var name \"%s\" too long", varname);
return NULL;
}
as_predexp_var_t * dp =
(as_predexp_var_t *)
cf_malloc(sizeof(as_predexp_var_t));
dp->base.dtor_fn = as_predexp_var_dtor;
dp->base.size_fn = as_predexp_var_size;
dp->base.write_fn = as_predexp_var_write;
dp->varname = cf_strdup(varname);
dp->tag = tag;
return (as_predexp_base *) dp;
}
as_predexp_base * as_predexp_integer_var(char const * varname)
{
return as_predexp_var(varname, AS_PREDEXP_INTEGER_VAR);
}
as_predexp_base * as_predexp_string_var(char const * varname)
{
return as_predexp_var(varname, AS_PREDEXP_STRING_VAR);
}
as_predexp_base * as_predexp_geojson_var(char const * varname)
{
return as_predexp_var(varname, AS_PREDEXP_GEOJSON_VAR);
}
// ----------------------------------------------------------------
// as_predexp_rec_device_size
// ----------------------------------------------------------------
typedef struct {
as_predexp_base base;
} as_predexp_rec_device_size_t;
void as_predexp_rec_device_size_dtor(as_predexp_base * bp)
{
as_predexp_rec_device_size_t * dp = (as_predexp_rec_device_size_t *) bp;
cf_free(dp);
}
size_t as_predexp_rec_device_size_size(as_predexp_base * bp)
{
// as_predexp_rec_device_size_t * dp = (as_predexp_rec_device_size_t *) bp;
size_t sz = sizeof(uint16_t) + sizeof(uint32_t); // TAG + LEN
return sz;
}
uint8_t * as_predexp_rec_device_size_write(as_predexp_base * bp, uint8_t * p)
{
// as_predexp_rec_device_size_t * dp = (as_predexp_rec_device_size_t *) bp;
// TAG
uint16_t * tag_ptr = (uint16_t *) p;
p += sizeof(uint16_t);
*tag_ptr = cf_swap_to_be16(AS_PREDEXP_REC_DEVICE_SIZE);
// LEN
uint32_t * len_ptr = (uint32_t *) p;
p += sizeof(uint32_t);
*len_ptr = cf_swap_to_be32(0);
return p;
}
as_predexp_base * as_predexp_rec_device_size()
{
as_predexp_rec_device_size_t * dp =
(as_predexp_rec_device_size_t *)
cf_malloc(sizeof(as_predexp_rec_device_size_t));
dp->base.dtor_fn = as_predexp_rec_device_size_dtor;
dp->base.size_fn = as_predexp_rec_device_size_size;
dp->base.write_fn = as_predexp_rec_device_size_write;
return (as_predexp_base *) dp;
}
// ----------------------------------------------------------------
// as_predexp_rec_last_update
// ----------------------------------------------------------------
typedef struct {
as_predexp_base base;
} as_predexp_rec_last_update_t;
void as_predexp_rec_last_update_dtor(as_predexp_base * bp)
{
as_predexp_rec_last_update_t * dp = (as_predexp_rec_last_update_t *) bp;
cf_free(dp);
}
size_t as_predexp_rec_last_update_size(as_predexp_base * bp)
{
// as_predexp_rec_last_update_t * dp = (as_predexp_rec_last_update_t *) bp;
size_t sz = sizeof(uint16_t) + sizeof(uint32_t); // TAG + LEN
return sz;
}
uint8_t * as_predexp_rec_last_update_write(as_predexp_base * bp, uint8_t * p)
{
// as_predexp_rec_last_update_t * dp = (as_predexp_rec_last_update_t *) bp;
// TAG
uint16_t * tag_ptr = (uint16_t *) p;
p += sizeof(uint16_t);
*tag_ptr = cf_swap_to_be16(AS_PREDEXP_REC_LAST_UPDATE);
// LEN
uint32_t * len_ptr = (uint32_t *) p;
p += sizeof(uint32_t);
*len_ptr = cf_swap_to_be32(0);
return p;
}
as_predexp_base * as_predexp_rec_last_update()
{
as_predexp_rec_last_update_t * dp =
(as_predexp_rec_last_update_t *)
cf_malloc(sizeof(as_predexp_rec_last_update_t));
dp->base.dtor_fn = as_predexp_rec_last_update_dtor;
dp->base.size_fn = as_predexp_rec_last_update_size;
dp->base.write_fn = as_predexp_rec_last_update_write;
return (as_predexp_base *) dp;
}
// ----------------------------------------------------------------
// as_predexp_rec_void_time
// ----------------------------------------------------------------
typedef struct {
as_predexp_base base;
} as_predexp_rec_void_time_t;
void as_predexp_rec_void_time_dtor(as_predexp_base * bp)
{
as_predexp_rec_void_time_t * dp = (as_predexp_rec_void_time_t *) bp;
cf_free(dp);
}
size_t as_predexp_rec_void_time_size(as_predexp_base * bp)
{
// as_predexp_rec_void_time_t * dp = (as_predexp_rec_void_time_t *) bp;
size_t sz = sizeof(uint16_t) + sizeof(uint32_t); // TAG + LEN
return sz;
}
uint8_t * as_predexp_rec_void_time_write(as_predexp_base * bp, uint8_t * p)
{
// as_predexp_rec_void_time_t * dp = (as_predexp_rec_void_time_t *) bp;
// TAG
uint16_t * tag_ptr = (uint16_t *) p;
p += sizeof(uint16_t);
*tag_ptr = cf_swap_to_be16(AS_PREDEXP_REC_VOID_TIME);
// LEN
uint32_t * len_ptr = (uint32_t *) p;
p += sizeof(uint32_t);
*len_ptr = cf_swap_to_be32(0);
return p;
}
as_predexp_base * as_predexp_rec_void_time()
{
as_predexp_rec_void_time_t * dp =
(as_predexp_rec_void_time_t *)
cf_malloc(sizeof(as_predexp_rec_void_time_t));
dp->base.dtor_fn = as_predexp_rec_void_time_dtor;
dp->base.size_fn = as_predexp_rec_void_time_size;
dp->base.write_fn = as_predexp_rec_void_time_write;
return (as_predexp_base *) dp;
}
// ----------------------------------------------------------------
// as_predexp_rec_digest_modulo
// ----------------------------------------------------------------
typedef struct {
as_predexp_base base;
int32_t mod;
} as_predexp_rec_digest_modulo_t;
void as_predexp_rec_digest_modulo_dtor(as_predexp_base * bp)
{
as_predexp_rec_digest_modulo_t * dp = (as_predexp_rec_digest_modulo_t *) bp;
cf_free(dp);
}
size_t as_predexp_rec_digest_modulo_size(as_predexp_base * bp)
{
// as_predexp_rec_digest_modulo_t * dp = (as_predexp_rec_digest_modulo_t *) bp;
size_t sz = sizeof(uint16_t) + sizeof(uint32_t); // TAG + LEN
sz += sizeof(int32_t);
return sz;
}
uint8_t * as_predexp_rec_digest_modulo_write(as_predexp_base * bp, uint8_t * p)
{
as_predexp_rec_digest_modulo_t * dp = (as_predexp_rec_digest_modulo_t *) bp;
// TAG
uint16_t * tag_ptr = (uint16_t *) p;
p += sizeof(uint16_t);
*tag_ptr = cf_swap_to_be16(AS_PREDEXP_REC_DIGEST_MODULO);
// LEN
uint32_t * len_ptr = (uint32_t *) p;
p += sizeof(uint32_t);
*len_ptr = cf_swap_to_be32(sizeof(int32_t));
// value
int32_t * mod_ptr = (int32_t *) p;
p += sizeof(int32_t);
*mod_ptr = cf_swap_to_be32(dp->mod);
return p;
}
as_predexp_base * as_predexp_rec_digest_modulo(int32_t mod)
{
as_predexp_rec_digest_modulo_t * dp =
(as_predexp_rec_digest_modulo_t *)
cf_malloc(sizeof(as_predexp_rec_digest_modulo_t));
dp->base.dtor_fn = as_predexp_rec_digest_modulo_dtor;
dp->base.size_fn = as_predexp_rec_digest_modulo_size;
dp->base.write_fn = as_predexp_rec_digest_modulo_write;
dp->mod = mod;
return (as_predexp_base *) dp;
}
// ----------------------------------------------------------------
// as_predexp_*_compare
// ----------------------------------------------------------------
typedef struct {
as_predexp_base base;
uint16_t tag; // Not written to the wire
} as_predexp_compare_t;
void as_predexp_compare_dtor(as_predexp_base * bp)
{
as_predexp_compare_t * dp = (as_predexp_compare_t *) bp;
cf_free(dp);
}
size_t as_predexp_compare_size(as_predexp_base * bp)
{
// as_predexp_compare_t * dp = (as_predexp_compare_t *) bp;
size_t sz = sizeof(uint16_t) + sizeof(uint32_t); // TAG + LEN
return sz;
}
uint8_t * as_predexp_compare_write(as_predexp_base * bp, uint8_t * p)
{
as_predexp_compare_t * dp = (as_predexp_compare_t *) bp;
// TAG
uint16_t * tag_ptr = (uint16_t *) p;
p += sizeof(uint16_t);
*tag_ptr = cf_swap_to_be16(dp->tag);
// LEN
uint32_t * len_ptr = (uint32_t *) p;
p += sizeof(uint32_t);
*len_ptr = cf_swap_to_be32(0);
return p;
}
// This routine is static, helpers below are used.
static as_predexp_base * as_predexp_compare(uint16_t tag)
{
as_predexp_compare_t * dp =
(as_predexp_compare_t *)
cf_malloc(sizeof(as_predexp_compare_t));
dp->base.dtor_fn = as_predexp_compare_dtor;
dp->base.size_fn = as_predexp_compare_size;
dp->base.write_fn = as_predexp_compare_write;
dp->tag = tag;
return (as_predexp_base *) dp;
}
as_predexp_base * as_predexp_integer_equal()
{
return as_predexp_compare(AS_PREDEXP_INTEGER_EQUAL);
}
as_predexp_base * as_predexp_integer_unequal()
{
return as_predexp_compare(AS_PREDEXP_INTEGER_UNEQUAL);
}
as_predexp_base * as_predexp_integer_greater()
{
return as_predexp_compare(AS_PREDEXP_INTEGER_GREATER);
}
as_predexp_base * as_predexp_integer_greatereq()
{
return as_predexp_compare(AS_PREDEXP_INTEGER_GREATEREQ);
}
as_predexp_base * as_predexp_integer_less()
{
return as_predexp_compare(AS_PREDEXP_INTEGER_LESS);
}
as_predexp_base * as_predexp_integer_lesseq()
{
return as_predexp_compare(AS_PREDEXP_INTEGER_LESSEQ);
}
as_predexp_base * as_predexp_string_equal()
{
return as_predexp_compare(AS_PREDEXP_STRING_EQUAL);
}
as_predexp_base * as_predexp_string_unequal()
{
return as_predexp_compare(AS_PREDEXP_STRING_UNEQUAL);
}
as_predexp_base * as_predexp_geojson_within()
{
return as_predexp_compare(AS_PREDEXP_GEOJSON_WITHIN);
}
as_predexp_base * as_predexp_geojson_contains()
{
return as_predexp_compare(AS_PREDEXP_GEOJSON_CONTAINS);
}
// ----------------------------------------------------------------
// as_predexp_string_regex
// ----------------------------------------------------------------
typedef struct {
as_predexp_base base;
uint32_t cflags;
} as_predexp_string_regex_t;
void as_predexp_string_regex_dtor(as_predexp_base * bp)
{
as_predexp_string_regex_t * dp = (as_predexp_string_regex_t *) bp;
cf_free(dp);
}
size_t as_predexp_string_regex_size(as_predexp_base * bp)
{
// as_predexp_string_regex_t * dp = (as_predexp_string_regex_t *) bp;
size_t sz = sizeof(uint16_t) + sizeof(uint32_t); // TAG + LEN
sz += sizeof(uint32_t); // cflags
return sz;
}
uint8_t * as_predexp_string_regex_write(as_predexp_base * bp, uint8_t * p)
{
as_predexp_string_regex_t * dp = (as_predexp_string_regex_t *) bp;
// TAG
uint16_t * tag_ptr = (uint16_t *) p;
p += sizeof(uint16_t);
*tag_ptr = cf_swap_to_be16(AS_PREDEXP_STRING_REGEX);
// LEN
uint32_t * len_ptr = (uint32_t *) p;
p += sizeof(uint32_t);
*len_ptr = cf_swap_to_be32(sizeof(uint32_t));
// value
uint32_t * cflags_ptr = (uint32_t *) p;
p += sizeof(uint32_t);
*cflags_ptr = cf_swap_to_be32(dp->cflags);
return p;
}
as_predexp_base * as_predexp_string_regex(uint32_t cflags)
{
as_predexp_string_regex_t * dp =
(as_predexp_string_regex_t *)
cf_malloc(sizeof(as_predexp_string_regex_t));
dp->base.dtor_fn = as_predexp_string_regex_dtor;
dp->base.size_fn = as_predexp_string_regex_size;
dp->base.write_fn = as_predexp_string_regex_write;
dp->cflags = cflags;
return (as_predexp_base *) dp;
}
// ----------------------------------------------------------------
// as_predexp_*_iterate_*
// ----------------------------------------------------------------
typedef struct {
as_predexp_base base;
char * varname;
uint16_t tag; // Not written to wire
} as_predexp_iter_t;
void as_predexp_iter_dtor(as_predexp_base * bp)
{
as_predexp_iter_t * dp = (as_predexp_iter_t *) bp;
if (dp->varname)
cf_free(dp->varname);
cf_free(dp);
}
size_t as_predexp_iter_size(as_predexp_base * bp)
{
as_predexp_iter_t * dp = (as_predexp_iter_t *) bp;
size_t sz = sizeof(uint16_t) + sizeof(uint32_t); // TAG + LEN
sz += strlen(dp->varname); // varname
return sz;
}
uint8_t * as_predexp_iter_write(as_predexp_base * bp, uint8_t * p)
{
as_predexp_iter_t * dp = (as_predexp_iter_t *) bp;
uint32_t len = (uint32_t)strlen(dp->varname);
// TAG
uint16_t * tag_ptr = (uint16_t *) p;
p += sizeof(uint16_t);
*tag_ptr = cf_swap_to_be16(dp->tag);
// LEN
uint32_t * len_ptr = (uint32_t *) p;
p += sizeof(uint32_t);
*len_ptr = cf_swap_to_be32(len);
// varname value
char * bnptr = (char *) p;
p += len;
memcpy(bnptr, dp->varname, len);
return p;
}
static as_predexp_base * as_predexp_iter(char const * varname, uint16_t tag)
{
if (!varname) {
as_log_error("missing var name argument");
return NULL;
}
else if (strlen(varname) >= AS_BIN_NAME_MAX_SIZE) {
as_log_error("var name \"%s\" too long", varname);
return NULL;
}
as_predexp_iter_t * dp =
(as_predexp_iter_t *)
cf_malloc(sizeof(as_predexp_iter_t));
dp->base.dtor_fn = as_predexp_iter_dtor;
dp->base.size_fn = as_predexp_iter_size;
dp->base.write_fn = as_predexp_iter_write;
dp->varname = cf_strdup(varname);
dp->tag = tag;
return (as_predexp_base *) dp;
}
as_predexp_base * as_predexp_list_iterate_or(char const * varname)
{
return as_predexp_iter(varname, AS_PREDEXP_LIST_ITERATE_OR);
}
as_predexp_base * as_predexp_mapkey_iterate_or(char const * varname)
{
return as_predexp_iter(varname, AS_PREDEXP_MAPKEY_ITERATE_OR);
}
as_predexp_base * as_predexp_mapval_iterate_or(char const * varname)
{
return as_predexp_iter(varname, AS_PREDEXP_MAPVAL_ITERATE_OR);
}
as_predexp_base * as_predexp_list_iterate_and(char const * varname)
{
return as_predexp_iter(varname, AS_PREDEXP_LIST_ITERATE_AND);
}
as_predexp_base * as_predexp_mapkey_iterate_and(char const * varname)
{
return as_predexp_iter(varname, AS_PREDEXP_MAPKEY_ITERATE_AND);
}
as_predexp_base * as_predexp_mapval_iterate_and(char const * varname)
{
return as_predexp_iter(varname, AS_PREDEXP_MAPVAL_ITERATE_AND);
}
| 25.356655 | 82 | 0.688135 |
9633c56703c7d0101c5a0f9691ec7511dec35068 | 14,551 | h | C | header6.6.1/WCPayPayMoneyLogic.h | CrackerCat/iWeChat | 7b3dbc48090e2d60cb72417563c554777eded15f | [
"MIT"
] | 1,694 | 2018-05-04T12:34:53.000Z | 2022-03-23T10:33:46.000Z | header6.6.1/WCPayPayMoneyLogic.h | CrackerCat/iWeChat | 7b3dbc48090e2d60cb72417563c554777eded15f | [
"MIT"
] | 6 | 2018-09-22T16:32:43.000Z | 2020-04-20T02:10:19.000Z | header6.6.1/WCPayPayMoneyLogic.h | CrackerCat/iWeChat | 7b3dbc48090e2d60cb72417563c554777eded15f | [
"MIT"
] | 236 | 2018-05-05T11:00:28.000Z | 2022-03-09T03:57:28.000Z | //
// Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 17 2017 16:24:48).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard.
//
#import "WCPayControlLogic.h"
#import "IWCPayControlLogicExt-Protocol.h"
#import "LocationRetrieveDelegate-Protocol.h"
#import "WCBaseControlMgrExt-Protocol.h"
#import "WCPayAutoDeductSettingViewControllerDelegate-Protocol.h"
#import "WCPayAvaliablePayCardListViewDelegate-Protocol.h"
#import "WCPayBalanceFetchMoneyViewControllerDelegate-Protocol.h"
#import "WCPayBalanceSaveMoneyViewControllerDelegate-Protocol.h"
#import "WCPayBindedCardListViewControllerDelegate-Protocol.h"
#import "WCPayCancelPayCgiDelegate-Protocol.h"
#import "WCPayCouponsListViewDelegate-Protocol.h"
#import "WCPayFillCardInfoViewControllerDelegate-Protocol.h"
#import "WCPayFillCardNumberViewControllerDelegate-Protocol.h"
#import "WCPayGenDigitalCertCgiDelegate-Protocol.h"
#import "WCPayOrderDetailViewControllerDelegate-Protocol.h"
#import "WCPayOrderPayConfirmViewDelegate-Protocol.h"
#import "WCPayOverseasCarTipDelegate-Protocol.h"
#import "WCPayPaidOrderDetailViewControllerDelegate-Protocol.h"
#import "WCPayPaidSuccessStatusViewControllerDelegate-Protocol.h"
#import "WCPayPayPwdViewControllerDelegate-Protocol.h"
#import "WCPayResetBalanceTelephoneViewControllerDelegate-Protocol.h"
#import "WCPayResetBindedCardInfoViewControllerDelegate-Protocol.h"
#import "WCPayResetPhoneViewViewControllerDelegate-Protocol.h"
#import "WCPaySpecifySelectePayCardListViewDelegate-Protocol.h"
#import "WCPayTranferMoneyPaidSuccessViewControllerDelegate-Protocol.h"
#import "WCPayVerifyCardNumberViewControllerDelegate-Protocol.h"
#import "WCPayVerifyPayCardViewControllerDelegate-Protocol.h"
@class ABTestItem, LocationRetriever, MMLoadingView, NSCache, NSString, UIView, WCPayAddPayCardLogic, WCPayAvaliablePayCardListView, WCPayCancelPayCgi, WCPayGenDigitalCertCgi, WCPayOverseasCardTipView, WCPayPayResponseRetryInfo, WCPaySetUserExInfoCgi;
@protocol WCPayPayMoneyLogicDelegate;
@interface WCPayPayMoneyLogic : WCPayControlLogic <WCPayGenDigitalCertCgiDelegate, WCPayCancelPayCgiDelegate, WCPayPaidSuccessStatusViewControllerDelegate, WCPayVerifyCardNumberViewControllerDelegate, WCPayFillCardInfoViewControllerDelegate, WCPayFillCardNumberViewControllerDelegate, WCPayPayPwdViewControllerDelegate, WCPayVerifyPayCardViewControllerDelegate, WCPayOrderDetailViewControllerDelegate, WCPayPaidOrderDetailViewControllerDelegate, WCPayResetPhoneViewViewControllerDelegate, WCPayResetBindedCardInfoViewControllerDelegate, WCPayBindedCardListViewControllerDelegate, WCPayResetBalanceTelephoneViewControllerDelegate, WCPayOrderPayConfirmViewDelegate, WCPayOverseasCarTipDelegate, WCPayBalanceSaveMoneyViewControllerDelegate, WCPayBalanceFetchMoneyViewControllerDelegate, WCPayAvaliablePayCardListViewDelegate, WCPayTranferMoneyPaidSuccessViewControllerDelegate, WCPayCouponsListViewDelegate, WCPaySpecifySelectePayCardListViewDelegate, WCBaseControlMgrExt, IWCPayControlLogicExt, WCPayAutoDeductSettingViewControllerDelegate, LocationRetrieveDelegate>
{
id <WCPayPayMoneyLogicDelegate> m_payMoneyLogicDelegate;
WCPayOverseasCardTipView *m_overseasCardTipView;
WCPayAddPayCardLogic *m_oWCPayAddPayCardLogic;
LocationRetriever *locationReceiver;
_Bool m_bUsingTouchIDAuth;
_Bool m_bResetBalanceTeling;
ABTestItem *_payABTestItem;
_Bool m_bRetryPWD;
UIView *oSubView;
NSCache *internalCache;
_Bool m_bIsUploadIdBack;
WCPayAvaliablePayCardListView *m_avaliablePayCardView;
_Bool m_shouldShowConfirmViewAfterGetOrderDetail;
_Bool m_bResetBalanceTelingBySelectNewNumber;
_Bool m_hasGoneToPaidDetailView;
_Bool m_isOrderPaySuccessOrUncertain;
_Bool m_bNeedPreShowOrderDetailToGetPayCardList;
_Bool m_bNeedForceDissmissSuccessViewNotAnimation;
_Bool m_bPresentSuccessViewController;
_Bool m_bNotShowSuccessViewController;
_Bool _bIsCancelFromOrderConfirmView;
Class m_oStartedClass;
WCPayGenDigitalCertCgi *_m_genDigitalCertCgi;
WCPayCancelPayCgi *_m_cancelPayCgi;
MMLoadingView *_m_webViewReturnLoadingView;
NSString *_m_touchFingerData;
WCPaySetUserExInfoCgi *_setUserExInfoCgi;
WCPayPayResponseRetryInfo *_retry_pay_info;
long long _currentRetryCount;
}
@property(nonatomic) long long currentRetryCount; // @synthesize currentRetryCount=_currentRetryCount;
@property(retain, nonatomic) WCPayPayResponseRetryInfo *retry_pay_info; // @synthesize retry_pay_info=_retry_pay_info;
@property(retain, nonatomic) WCPaySetUserExInfoCgi *setUserExInfoCgi; // @synthesize setUserExInfoCgi=_setUserExInfoCgi;
@property(retain, nonatomic) NSString *m_touchFingerData; // @synthesize m_touchFingerData=_m_touchFingerData;
@property(retain, nonatomic) MMLoadingView *m_webViewReturnLoadingView; // @synthesize m_webViewReturnLoadingView=_m_webViewReturnLoadingView;
@property(retain, nonatomic) WCPayCancelPayCgi *m_cancelPayCgi; // @synthesize m_cancelPayCgi=_m_cancelPayCgi;
@property(nonatomic) _Bool bIsCancelFromOrderConfirmView; // @synthesize bIsCancelFromOrderConfirmView=_bIsCancelFromOrderConfirmView;
@property(retain, nonatomic) WCPayGenDigitalCertCgi *m_genDigitalCertCgi; // @synthesize m_genDigitalCertCgi=_m_genDigitalCertCgi;
@property(retain, nonatomic) Class m_oStartedClass; // @synthesize m_oStartedClass;
@property(nonatomic) _Bool m_bNotShowSuccessViewController; // @synthesize m_bNotShowSuccessViewController;
@property(nonatomic) _Bool m_bPresentSuccessViewController; // @synthesize m_bPresentSuccessViewController;
@property(nonatomic) _Bool m_bNeedForceDissmissSuccessViewNotAnimation; // @synthesize m_bNeedForceDissmissSuccessViewNotAnimation;
@property(nonatomic) _Bool m_bNeedPreShowOrderDetailToGetPayCardList; // @synthesize m_bNeedPreShowOrderDetailToGetPayCardList;
@property(nonatomic) __weak id <WCPayPayMoneyLogicDelegate> m_payMoneyLogicDelegate; // @synthesize m_payMoneyLogicDelegate;
- (void).cxx_destruct;
- (void)onBeforePayRemindContinuePay:(id)arg1;
- (void)onBeforePayRemindCancelPay:(id)arg1;
- (void)onBeforePayBlockConfirm:(id)arg1;
- (_Bool)beforePayBlockShowAlertWith:(id)arg1;
- (void)reportOfflinePayTimeUsingEvent:(int)arg1;
- (void)stopPaymoneyLogicAfterAuthenError;
- (void)onGetWCPayCancelPayCgiResp:(id)arg1;
- (void)onWCPayGenDigitalCertCgiWithResp:(id)arg1;
- (_Bool)checkRealNameBlockWithData:(id)arg1;
- (void)OnResetPasswordCancel:(id)arg1;
- (void)onRetrieveLocationError:(int)arg1;
- (void)onRetrieveLocationTimeOut:(id)arg1;
- (void)onRetrieveLocationOK:(id)arg1;
- (void)webViewReturn:(id)arg1;
- (void)OnUploadIdSuccess:(id)arg1;
- (void)OnRealnameVerifySuccessNotification:(id)arg1;
- (void)OnAutoDeductSettingCancel;
- (void)OnFooterButtonClick:(id)arg1;
- (void)OnFinishedWCPayLogic:(id)arg1 CompleteStatus:(int)arg2;
- (void)gotoRootViewControllerIfNotInDetailView:(_Bool)arg1;
- (void)OnAuthenticationResetBalanceTelPayVerifySMS:(id)arg1 PayStatus:(id)arg2 Error:(id)arg3;
- (void)OnAuthenticationResetBalanceTelPay:(id)arg1 PayStatus:(id)arg2 Error:(id)arg3;
- (void)OnHandleSpecialPayError:(id)arg1 ErrorType:(unsigned int)arg2;
- (void)OnSelectOtherCardToPay;
- (void)OnNewCardToPay;
- (void)OnValidError:(id)arg1;
- (void)OnCVVError:(id)arg1;
- (void)OnPhoneNumberError:(id)arg1;
- (void)OnCVVAndValidError:(id)arg1;
- (void)onAlertResetCVVAndValidDate;
- (void)OnAlertResetPhoneNumber;
- (void)onAlertResetValidDate;
- (void)onAlertResetCVV;
- (void)OnHandleVerifiedSMSString:(id)arg1;
- (void)OnAuthenticationPayVerifyBind:(id)arg1;
- (void)StartPayOrderQuery;
- (void)RetryGetOrderDetailInfoAfterPaidError:(id)arg1;
- (void)NoRetryGetOrderDetailInfoAfterPaidError:(id)arg1;
- (void)OnPayCgiErrorWithError:(id)arg1;
- (void)OnPayCgiErrorWithErrorCode:(unsigned int)arg1;
- (void)OnVerifyRegCgiNetError:(id)arg1;
- (void)OnVerifyCgiNetError:(id)arg1;
- (void)OnAuthenCgiNetError:(id)arg1;
- (void)OnQueryOrderNoRetryWhenPaidErrorWithErrorCode:(unsigned int)arg1;
- (unsigned int)qrcodeUseQueryOrderInfoMaxCount;
- (unsigned int)qrcodeUseQueryOrderInfoDelayTime;
- (id)qrcodeUseQueryOrderInfoDefaultErrorWithErrorCode:(unsigned int)arg1;
- (id)getPayQueryOrderParams;
- (id)getRetryQueryOrderCacheKey:(id)arg1;
- (void)OnGetOrderDetailInfoAfterPaidError:(id)arg1 Error:(id)arg2;
- (void)OnSetWCPayPasswordInPay:(id)arg1 Error:(id)arg2;
- (void)OnAuthenticationPayVerifySMS:(id)arg1 PayStatus:(id)arg2 Error:(id)arg3;
- (void)OnAuthenticationPay:(id)arg1 PayStatus:(id)arg2 Error:(id)arg3;
- (void)OnGetBindingCardBin:(id)arg1 AvailableBank:(id)arg2 userExInfoResponse:(id)arg3 Error:(id)arg4;
- (void)OnPayPasswordError:(id)arg1 ErrorCount:(int)arg2 LockTotalCount:(unsigned int)arg3;
- (void)OnPayNeedToSwitchToPasswordPay;
- (void)OnVerifyPayPassword:(id)arg1;
- (void)OnGetBindQueryInfo:(id)arg1 Error:(id)arg2;
- (void)OnGetOrderDetailInfo:(id)arg1 BindQueryInfo:(id)arg2 Error:(id)arg3;
- (void)OnWCPayBaseRequestNoKnownError:(id)arg1 TenPayCmdType:(int)arg2;
- (id)favDesc:(id)arg1;
- (id)getTouchIDReasonFromData:(id)arg1;
- (void)onActionSheetEndPay;
- (void)onActionSheetCancelTouchId;
- (void)onActionSheetChangingOtherCards;
- (void)onActionSheetUsingPwdAuth;
- (void)internalShowConfirmTouchIDOrConfirmViewWithData:(id)arg1;
- (void)showConfirmTouchIDOrConfirmViewWithData:(id)arg1;
- (void)showSafariWithData:(id)arg1;
- (void)disabelTouchIDAuthForCurrentOrder;
- (void)performTouchID;
- (void)showTouchIDAuthView:(id)arg1;
- (void)onTouhcAuthConfirmAlertOK:(id)arg1;
- (void)onTouhcAuthConfirmAlertCancel:(id)arg1;
- (void)OnPayMoneyPayRetry;
- (void)onErrorAlertViewDismiss:(id)arg1;
- (void)WCPayTranferMoneyPaidSuccessViewControllerViewDidAppear;
- (void)WCPayTranferMoneyPaidSuccessViewControllerBack:(_Bool)arg1;
- (void)WCPayBalanceFetchMoneyViewControllerBack:(_Bool)arg1;
- (void)statusViewControlleDidClickDone:(id)arg1;
- (void)WCPayBalanceSaveMoneyViewControllerBack:(_Bool)arg1;
- (void)onCancelOpenTouchIDAuth;
- (void)onOpenTouchIDAuth;
- (void)showOpenTouchIDConfirmIfNeed;
- (void)OnWCPayPaidOrderDetailViewControllerShowOpenTouchIDConfirmViewIfNeed;
- (void)OnWCPayPaidOrderDetailViewControllerRightActionBack:(id)arg1;
- (void)OnWCPayPaidOrderDetailViewControllerBack:(id)arg1;
- (void)PayPwdRightActionBack;
- (void)PayPwdBack;
- (void)SetPayPwdNext:(id)arg1;
- (void)OnResetBindedCardInfoNext:(id)arg1;
- (void)OnResetBindedCardInfoCancel;
- (void)OnResetPhoneNext:(id)arg1;
- (void)OnResetPhoneCancel;
- (void)VerifyPayCardModifyPhone:(id)arg1;
- (void)VerifyPayCardAgain:(id)arg1;
- (void)VerifyPayCardNext:(id)arg1;
- (void)VerifyPayCardBack;
- (void)FillCardInfoReadAgreement;
- (void)FillCardInfoNext:(id)arg1;
- (void)FillCardInfoCancel;
- (_Bool)NeedShowServiceAppInfo;
- (void)FillCardNumberShowedAllFavorInfo;
- (void)FillCardNumberConfirmWithImage:(id)arg1 cardNumber:(id)arg2 data:(id)arg3;
- (void)FillCardNumberNext:(id)arg1;
- (void)FillCardNumberCancel:(_Bool)arg1;
- (void)WCPayResetBalanceTelephoneViewControllerNext:(id)arg1;
- (void)WCPayResetBalanceTelephoneViewControllerBack;
- (void)verifyCardNumberVC:(id)arg1 didGetNumber:(id)arg2;
- (void)ONBindedCardListVCVerifyByCardNumber:(id)arg1;
- (void)ONBindedCardListResetBankTel:(id)arg1;
- (void)ONBindedCardListResetBalanceTel:(id)arg1;
- (void)OnBindedCardListNewCardClicked;
- (void)OnBindedCardListBack;
- (void)RepeatInputPayPwd:(id)arg1;
- (void)VerifyPayPwdNext:(id)arg1;
- (void)onOrderPayConfirmViewPerformTouchID;
- (void)onOrderPayConfirmViewGotoPasswordAuth;
- (void)onOrderPayConfirmViewGotoTouchIDAuth;
- (void)onOrderPayConfirmViewCancel;
- (void)OnOrderPayChangeConpons;
- (void)onOrderPayChangeCard;
- (void)doAuthenticationPayWithPwd:(id)arg1 isTouchIDAuth:(_Bool)arg2;
- (void)onOrderPayConfirmViewPay:(id)arg1;
- (void)orderDetailPay:(id)arg1 checkTouchID:(_Bool)arg2;
- (void)OrderDetailAddOrderCard:(id)arg1;
- (void)OrderDetailClickCoupousInfo;
- (void)OrderDetailBack;
- (void)OrderDetailPay:(id)arg1;
- (void)OrderDetailAdd:(id)arg1;
- (void)onPushWebView:(id)arg1;
- (void)onDisagree;
- (void)onAgree:(_Bool)arg1;
- (_Bool)needShowOverseasCardProtocalView;
- (void)OnWCPayCouponsListViewNext:(id)arg1;
- (void)OnWCPayCouponsListViewBack;
- (void)OnWCPaySpecifySelectePayCardListViewBackAddCard;
- (void)OnWCPaySpecifySelectePayCardListViewNext:(id)arg1;
- (void)OnWCPaySpecifySelectePayCardListViewBack;
- (void)OnWCPayAvaliablePayCardListViewWebViewReturn:(id)arg1;
- (void)OnWCPayAvaliablePayCardListViewPushWebView:(id)arg1;
- (void)OnWCPayAvaliablePayCardListViewAddPayCard;
- (void)OnWCPayAvaliablePayCardListViewNext:(id)arg1;
- (void)OnWCPayAvaliablePayCardListViewBack;
- (void)OnWCPayAvaliablePayCardListViewCancel;
- (_Bool)checkHandlePrepayErrorPath;
- (_Bool)checkBankAvailable:(id)arg1;
- (id)getWCPayAuthenticationResetBalanceTelPayVerifySMSStruct:(id)arg1;
- (id)getWCPayAuthenticationResetBalanceTelPay:(id)arg1;
- (id)getVerifyBindStruct;
- (id)GetWCPaySetWCPayPasswordStruct:(id)arg1;
- (id)getWCPayAuthenticationPayVerifySMSStruct:(id)arg1;
- (id)getWCPayAuthenticationPay:(id)arg1;
- (void)showOrderPaySuccess;
- (void)preShowOrderPaySuccess;
- (void)showResetBindedCardInfoWithCVV:(_Bool)arg1 ValidDate:(_Bool)arg2;
- (void)startBindCardToPay:(id)arg1;
- (void)startBindCardToVerifiedUser:(id)arg1;
- (void)startBindCardToSafariPay:(id)arg1;
- (void)onWCBaseLogicDidStop:(unsigned int)arg1;
- (void)OnHandleSafariJumpedLogic;
- (void)OnRetryPayMoneyFromPwdError;
- (id)getTransactionId;
- (int)getABTestType;
- (void)showGiveUpBindAlert;
- (void)OnAlertGiveUpBind;
- (void)mergeOrderDetail:(id)arg1;
- (void)mergePaymentOrderDetail:(id)arg1;
- (void)mergeBalanceMoneyContorlOrderDetail:(id)arg1;
- (void)startLoadingBlocked;
- (void)stopLoading;
- (void)webviewReturnStopLoading;
- (void)webviewReturnStartLoadingBlocked;
- (void)WCPayViewControllerDidBeRemoved:(id)arg1;
- (void)_cancelPay;
- (void)_checkCancelPay:(_Bool)arg1;
- (void)checkStopLogic;
- (void)stopLogic;
- (void)startLogic;
- (void)internalRetryVerifyRegAgain;
- (void)retryVerifyRegAgain;
- (void)internalRetryVerifyAgain;
- (void)retryVerifyAgain;
- (void)internalRetryAuthenAgain;
- (void)retryAuthenAgain;
- (_Bool)needRetryPay:(id)arg1 Error:(id)arg2;
- (void)updateRetryInfo:(id)arg1;
- (_Bool)isLogicJumpedToSafari;
- (void)dealloc;
- (id)initWithData:(id)arg1;
- (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
| 50.700348 | 1,064 | 0.831421 |
1924d3412d15d325852940fc360cfa113ea51f14 | 6,322 | c | C | 3ds/modules/citrus/apt.c | Katistic/3ds_monty | bf072f8065ff2b2683cc71eb8f7fb3133b098927 | [
"MIT"
] | 16 | 2016-11-03T11:25:59.000Z | 2022-02-20T23:13:51.000Z | 3ds/modules/citrus/apt.c | Katistic/3ds_monty | bf072f8065ff2b2683cc71eb8f7fb3133b098927 | [
"MIT"
] | 2 | 2016-11-07T00:45:47.000Z | 2019-06-12T14:54:30.000Z | 3ds/modules/citrus/apt.c | Katistic/3ds_monty | bf072f8065ff2b2683cc71eb8f7fb3133b098927 | [
"MIT"
] | 6 | 2016-12-08T13:45:29.000Z | 2021-09-18T10:28:52.000Z | #include <3ds.h>
#include "py/runtime.h"
#include "../init_helper.h"
#define METHOD_OBJ_N(__args, __n) \
STATIC MP_DEFINE_CONST_FUN_OBJ_##__args(mod_citrus_apt_##__n##_obj, mod_citrus_apt_##__n)
#define LOCAL_METHOD(__n) \
{MP_OBJ_NEW_QSTR(MP_QSTR_##__n), (mp_obj_t) &mod_citrus_apt_##__n##_obj}
#define LOCAL_INT(__n, __v) \
{MP_ROM_QSTR(MP_QSTR_##__n), MP_ROM_INT(__v)}
extern const mp_obj_type_t mod_citrus_apt_Hook_type;
static int _mod_citrus_apt_is_init = 0;
STATIC APT_AppStatus _mod_citrus_apt_get_app_status(mp_obj_t status) {
if (mp_obj_is_integer(status)) {
int _status = mp_obj_get_int(status);
if (_status >= APP_NOTINITIALIZED && _status <= APP_APPLETCLOSED) {
return _status;
}
}
nlr_raise(mp_obj_new_exception(&mp_type_TypeError));
}
STATIC mp_obj_t mod_citrus_apt_init(void) {
INIT_ONCE(_mod_citrus_apt_is_init);
return mp_obj_new_int(aptInit());
}
mp_obj_t mod_citrus_apt_exit(void) {
EXIT_ONCE(_mod_citrus_apt_is_init);
aptExit();
return mp_const_none;
}
STATIC mp_obj_t mod_citrus_apt_open_session(void) {
aptOpenSession();
return mp_const_none;
}
STATIC mp_obj_t mod_citrus_apt_close_session(void) {
aptCloseSession();
return mp_const_none;
}
STATIC mp_obj_t mod_citrus_apt_set_status(mp_obj_t status) {
APT_AppStatus _status = _mod_citrus_apt_get_app_status(status);
aptSetStatus(_status);
return mp_const_none;
}
STATIC mp_obj_t mod_citrus_apt_get_status(void) {
return mp_obj_new_int(aptGetStatus());
}
STATIC mp_obj_t mod_citrus_apt_get_status_power(void) {
return mp_obj_new_int(aptGetStatusPower());
}
STATIC mp_obj_t mod_citrus_apt_set_status_power(mp_obj_t status) {
u32 _status = mp_obj_get_int(status);
aptSetStatusPower(_status);
return mp_const_none;
}
STATIC mp_obj_t mod_citrus_apt_return_to_menu(void) {
aptReturnToMenu();
return mp_const_none;
}
STATIC mp_obj_t mod_citrus_apt_wait_status_event(void) {
aptWaitStatusEvent();
return mp_const_none;
}
STATIC mp_obj_t mod_citrus_apt_signal_ready_for_sleep(void) {
aptSignalReadyForSleep();
return mp_const_none;
}
STATIC mp_obj_t mod_citrus_apt_get_menu_app_id(void) {
return mp_obj_new_int(aptGetMenuAppID());
}
STATIC mp_obj_t mod_citrus_apt_main_loop(void) {
return mp_obj_new_bool(aptMainLoop());
}
METHOD_OBJ_N(0, init);
METHOD_OBJ_N(0, exit);
METHOD_OBJ_N(0, open_session);
METHOD_OBJ_N(0, close_session);
METHOD_OBJ_N(1, set_status);
METHOD_OBJ_N(0, get_status);
METHOD_OBJ_N(0, get_status_power);
METHOD_OBJ_N(1, set_status_power);
METHOD_OBJ_N(0, return_to_menu);
METHOD_OBJ_N(0, wait_status_event);
METHOD_OBJ_N(0, signal_ready_for_sleep);
METHOD_OBJ_N(0, get_menu_app_id);
METHOD_OBJ_N(0, main_loop);
STATIC const mp_rom_map_elem_t mp_module_citrus_apt_globals_table[] = {
// Package Info
{MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_apt)},
// Classes
{MP_ROM_QSTR(MP_QSTR_Hook), MP_ROM_PTR(&mod_citrus_apt_Hook_type)},
// Functions
LOCAL_METHOD(init),
LOCAL_METHOD(exit),
LOCAL_METHOD(open_session),
LOCAL_METHOD(close_session),
LOCAL_METHOD(set_status),
LOCAL_METHOD(get_status),
LOCAL_METHOD(get_status_power),
LOCAL_METHOD(set_status_power),
LOCAL_METHOD(return_to_menu),
LOCAL_METHOD(wait_status_event),
LOCAL_METHOD(signal_ready_for_sleep),
LOCAL_METHOD(get_menu_app_id),
LOCAL_METHOD(main_loop),
// NS_APPID
LOCAL_INT(APPID_HOMEMENU, APPID_HOMEMENU),
LOCAL_INT(APPID_CAMERA, APPID_CAMERA),
LOCAL_INT(APPID_FRIENDS_LIST, APPID_FRIENDS_LIST),
LOCAL_INT(APPID_GAME_NOTES, APPID_GAME_NOTES),
LOCAL_INT(APPID_WEB, APPID_WEB),
LOCAL_INT(APPID_INSTRUCTION_MANUAL, APPID_INSTRUCTION_MANUAL),
LOCAL_INT(APPID_NOTIFICATIONS, APPID_NOTIFICATIONS),
LOCAL_INT(APPID_MIIVERSE, APPID_MIIVERSE),
LOCAL_INT(APPID_MIIVERSE_POSTING, APPID_MIIVERSE_POSTING),
LOCAL_INT(APPID_AMIIBO_SETTINGS, APPID_AMIIBO_SETTINGS),
LOCAL_INT(APPID_APPLICATION, APPID_APPLICATION),
LOCAL_INT(APPID_ESHOP, APPID_ESHOP),
LOCAL_INT(APPID_SOFTWARE_KEYBOARD, APPID_SOFTWARE_KEYBOARD),
LOCAL_INT(APPID_APPLETED, APPID_APPLETED),
LOCAL_INT(APPID_PNOTE_AP, APPID_PNOTE_AP),
LOCAL_INT(APPID_SNOTE_AP, APPID_SNOTE_AP),
LOCAL_INT(APPID_ERROR, APPID_ERROR),
LOCAL_INT(APPID_MINT, APPID_MINT),
LOCAL_INT(APPID_EXTRAPAD, APPID_EXTRAPAD),
LOCAL_INT(APPID_MEMOLIB, APPID_MEMOLIB),
// APT_AppStatus
LOCAL_INT(STATUS_NOTINITIALIZED, APP_NOTINITIALIZED),
LOCAL_INT(STATUS_RUNNING, APP_RUNNING),
LOCAL_INT(STATUS_SUSPENDED, APP_SUSPENDED),
LOCAL_INT(STATUS_EXITING, APP_EXITING),
LOCAL_INT(STATUS_SUSPENDING, APP_SUSPENDING),
LOCAL_INT(STATUS_SLEEPMODE, APP_SLEEPMODE),
LOCAL_INT(STATUS_PREPARE_SLEEPMODE, APP_PREPARE_SLEEPMODE),
LOCAL_INT(STATUS_APPLETSTARTED, APP_APPLETSTARTED),
LOCAL_INT(STATUS_APPLETCLOSED, APP_APPLETCLOSED),
// APT_Signal
LOCAL_INT(SIGNAL_HOMEBUTTON, APTSIGNAL_HOMEBUTTON),
LOCAL_INT(SIGNAL_PREPARESLEEP, APTSIGNAL_PREPARESLEEP),
LOCAL_INT(SIGNAL_ENTERSLEEP, APTSIGNAL_ENTERSLEEP),
LOCAL_INT(SIGNAL_WAKEUP, APTSIGNAL_WAKEUP),
LOCAL_INT(SIGNAL_ENABLE, APTSIGNAL_ENABLE),
LOCAL_INT(SIGNAL_POWERBUTTON, APTSIGNAL_POWERBUTTON),
LOCAL_INT(SIGNAL_UTILITY, APTSIGNAL_UTILITY),
LOCAL_INT(SIGNAL_SLEEPSYSTEM, APTSIGNAL_SLEEPSYSTEM),
LOCAL_INT(SIGNAL_ERROR, APTSIGNAL_ERROR),
// APT_HookType
LOCAL_INT(HOOK_ONSUSPEND, APTHOOK_ONSUSPEND),
LOCAL_INT(HOOK_ONRESTORE, APTHOOK_ONRESTORE),
LOCAL_INT(HOOK_ONSLEEP, APTHOOK_ONSLEEP),
LOCAL_INT(HOOK_ONWAKEUP, APTHOOK_ONWAKEUP),
LOCAL_INT(HOOK_ONEXIT, APTHOOK_ONEXIT),
LOCAL_INT(HOOK_COUNT, APTHOOK_COUNT),
};
STATIC MP_DEFINE_CONST_DICT(mp_module_citrus_apt_globals, mp_module_citrus_apt_globals_table);
const mp_obj_module_t mp_module_citrus_apt = {
.base = {&mp_type_module},
.name = MP_QSTR_apt,
.globals = (mp_obj_dict_t *) &mp_module_citrus_apt_globals,
};
| 31.768844 | 94 | 0.739798 |
d2e4cc9b540c697810cceee2da68342f16418547 | 127 | c | C | patch/x_include.c | Elyk8/st | 5f4d07eb7e346695c3496b33117cfb31ec3105e4 | [
"MIT"
] | null | null | null | patch/x_include.c | Elyk8/st | 5f4d07eb7e346695c3496b33117cfb31ec3105e4 | [
"MIT"
] | null | null | null | patch/x_include.c | Elyk8/st | 5f4d07eb7e346695c3496b33117cfb31ec3105e4 | [
"MIT"
] | null | null | null | /* Patches */
#include "boxdraw.c"
#include "opencopied.c"
#include "font2.c"
#include "xresources.c"
#include "changealpha.c"
| 18.142857 | 24 | 0.708661 |
65cff88b047a9c138a05597bb458102daa922740 | 10,386 | h | C | kernel/include/chipset_common/bfmr/common/bfmr_common.h | wonderful666/marx-10.1.0 | a8be8880fe31bff4f94d6e3fad17c455666ff60f | [
"MIT"
] | null | null | null | kernel/include/chipset_common/bfmr/common/bfmr_common.h | wonderful666/marx-10.1.0 | a8be8880fe31bff4f94d6e3fad17c455666ff60f | [
"MIT"
] | null | null | null | kernel/include/chipset_common/bfmr/common/bfmr_common.h | wonderful666/marx-10.1.0 | a8be8880fe31bff4f94d6e3fad17c455666ff60f | [
"MIT"
] | null | null | null | /*
* copyright: Huawei Technologies Co., Ltd. 2016-2019. All rights reserved.
*
* file: bfmr_common.h
*
* define the common external public enum/macros/interface for BFMR
* (Boot Fail Monitor and Recovery)
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* 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.
*
*/
#ifndef BFMR_COMMON_H
#define BFMR_COMMON_H
#include <linux/vmalloc.h>
#include <linux/types.h>
#include <linux/semaphore.h>
#ifdef __cplusplus
extern "C" {
#endif
#define LOG_PATH_SIZE 1024
#define DETAIL_INFO_LEN 512
#define RESERVED_INFO_SIZE 2556
#define PARAM_COMMAND_LEN 32
#define PARAM_RESERVED_SIZE 948
#define INFO_RESERVED_SIZE 240
#define LDO_NUM_SIZE 16
#define MOUNT_POINT_SIZE 32
enum bfmr_log_type {
LOG_TYPE_BOOTLOADER_1 = 0,
LOG_TYPE_BOOTLOADER_2,
LOG_TYPE_BFMR_TEMP_BUF,
LOG_TYPE_KMSG,
LOG_TYPE_ANDROID_KMSG = LOG_TYPE_KMSG,
LOG_TYPE_TEXT_KMSG,
LOG_TYPE_RAMOOPS,
LOG_TYPE_BETA_APP_LOGCAT,
LOG_TYPE_CRITICAL_PROCESS_CRASH,
LOG_TYPE_VM_TOMBSTONES,
LOG_TYPE_VM_CRASH,
LOG_TYPE_VM_WATCHDOG,
LOG_TYPE_NORMAL_FRAMEWORK_BOOTFAIL_LOG,
LOG_TYPE_FIXED_FRAMEWORK_BOOTFAIL_LOG,
LOG_TYPE_BFM_BFI_LOG,
LOG_TYPE_BFM_RECOVERY_LOG,
LOG_TYPE_MAX_COUNT,
};
enum bfmr_dst_type {
DST_FILE = 0,
DST_RAW_PART,
DST_MEMORY_BUFFER,
};
struct bfmr_log_dst {
enum bfmr_dst_type type;
union {
char *filename;
struct {
char *addr;
int len;
} buffer;
struct {
char *raw_part_name;
int offset;
} raw_part;
} dst_info;
};
struct bfmr_log_src {
enum bfmr_log_type log_type;
char *src_log_file_path;
void *log_save_context;
void *log_save_additional_context;
bool save_log_after_reboot;
};
#if BITS_PER_LONG == 32
typedef struct stat64 bfm_stat_t;
#define bfm_sys_lstat sys_lstat64
#else
typedef struct stat bfm_stat_t;
#define bfm_sys_lstat sys_newlstat
#endif
enum bfmr_hw_fault_type {
HW_FAULT_OCP = 0,
HW_FAULT_MAX_COUNT,
};
enum bfmr_hw_fault_stage {
HW_FAULT_STAGE_DURING_BOOTUP = 0,
HW_FAULT_STAGE_AFTER_BOOT_SUCCESS,
HW_FAULT_STAGE_MAX_COUNT,
};
/* bootfail additional info */
struct bfmr_bf_addl_info {
char log_path[LOG_PATH_SIZE];
char detail_info[DETAIL_INFO_LEN];
enum bfmr_hw_fault_type hardware_fault_type;
char reserved[RESERVED_INFO_SIZE];
};
struct bfmr_rrecord_misc_param {
/* "boot-erecovery" */
char command[PARAM_COMMAND_LEN];
/* main reason */
int enter_erecovery_reason;
/* sub reason need for BI */
int enter_erecovery_reason_number;
/* boot stage when boot fail occurs */
int boot_fail_stage_for_erecovery;
unsigned int boot_fail_no;
unsigned int recovery_method;
/* mark if the misc write success,yes:0xAA55AA55 */
unsigned int sync_misc_flag;
/* abnormal shutdown flag */
unsigned int abns_flag;
unsigned int format_data_flag;
unsigned int original_recovery_method;
unsigned long long bopd_mode_value;
/* reserved for future usage */
char reserved[PARAM_RESERVED_SIZE];
} __attribute__((__packed__));
struct ocp_excp_info {
char ldo_num[LDO_NUM_SIZE];
char reserved[INFO_RESERVED_SIZE];
};
struct bfm_ocp_excp_info {
struct ocp_excp_info excp_info;
enum bfmr_hw_fault_type fault_type;
struct semaphore sem;
};
struct bfmr_hw_fault_info_param {
enum bfmr_hw_fault_stage fault_stage;
union {
struct ocp_excp_info ocp_excp_info;
} hw_excp_info;
};
struct bfmr_part_mount_result {
char mount_point[MOUNT_POINT_SIZE];
bool mount_result;
};
#define BFMR_AID_ROOT 0
#define BFMR_AID_SYSTEM 1000
#define BFMR_DIR_LIMIT 0775
#define BFMR_FILE_LIMIT 0664
#ifdef __KERNEL__
#define bfmr_malloc vmalloc
#define bfmr_free vfree
#else
#define bfmr_malloc malloc
#define bfmr_free free
#endif
#define BFMR_SIZE_32 ((unsigned int)32)
#define BFMR_SIZE_64 ((unsigned int)64)
#define BFMR_SIZE_128 ((unsigned int)128)
#define BFMR_SIZE_256 ((unsigned int)256)
#define BFMR_SIZE_512 ((unsigned int)512)
#define BFMR_SIZE_1K ((unsigned int)1024)
#define BFMR_SIZE_2K ((unsigned int)2048)
#define BFMR_SIZE_4K ((unsigned int)4096)
#define BFMR_SIZE_32K ((unsigned int)32768)
#define BFMR_DEV_FULL_PATH_MAX_LEN BFMR_SIZE_256
#define BFMR_TEMP_BUF_LEN BFMR_SIZE_32K
#define BFMR_MAX_PATH BFMR_SIZE_4K
#define ENTER_ERECOVERY_BY_PRESS_KEY 2001
#define ENTER_ERECOVERY_BY_ADB_CMD 2002
#define ENTER_ERECOVERY_BECAUSE_UNLOCK 2004
#define ENTER_ERECOVERY_BECAUSE_SYSTEM_DAMAGED 2005
#define ENTER_ERECOVERY_BECAUSE_HUAWEI_VERIFY_FAILED 2006
#define ENTER_ERECOVERY_BECAUSE_HUAWEI_GOOGLE_VERIFY_FAILED 2007
#define ENTER_ERECOVERY_REASON_BECAUSE_BOOTLOADER_BOOT_FAIL 2008
#define ENTER_ERECOVERY_REASON_BECAUSE_KERNEL_BOOT_FAIL 2009
#define ENTER_ERECOVERY_BECAUSE_SYSTEM_MOUNT_FAILED 2010
#define ENTER_ERECOVERY_BECAUSE_DATA_MOUNT_FAILED 2011
#define ENTER_ERECOVERY_BECAUSE_DATA_MOUNT_RO 2012
#define ENTER_ERECOVERY_BECAUSE_KEY_PROCESS_START_FAILED 2013
#define ENTER_ERECOVERY_BECAUSE_RECOVERY_PROCESS_CRASH 2014
#define ENTER_ERECOVERY_BECAUSE_AP_CRASH_REPEATEDLY 2015
#define ENTER_ERECOVERY_BECAUSE_NON_AP_CRASH_REPEATEDLY 2016
#define ENTER_ERECOVERY_BECAUSE_APP_BOOT_FAIL 2017
#define ENTER_ERECOVERY_BECAUSE_SECURITY_FAIL 2018
#define ENTER_ERECOVERY_BECAUSE_VENDOR_MOUNT_FAILED 2019
#define ENTER_ERECOVERY_BECAUSE_CUST_MOUNT_FAILED 2020
#define ENTER_ERECOVERY_BECAUSE_PRODUCT_MOUNT_FAILED 2021
#define ENTER_ERECOVERY_BECAUSE_VERSION_MOUNT_FAILED 2022
#define ENTER_ERECOVERY_BECAUSE_HW_DEGRADE_BOOT_FAIL 2040
#define ENTER_ERECOVERY_UNKNOWN 2099
#define BFMR_PRINT_INVALID_PARAMS(format, ...) \
pr_err("func: %s line: %d invalid parameters: "\
format, __func__, __LINE__, ##__VA_ARGS__)
#define BFMR_PRINT_ERR(format, ...) \
pr_err("func: %s line: %d, "\
format, __func__, __LINE__, ##__VA_ARGS__)
#define BFMR_PRINT_INFO(format, ...) \
pr_info("func: %s line: %d, "\
format, __func__, __LINE__, ##__VA_ARGS__)
#define BFMR_PRINT_KEY_INFO(format, ...) \
pr_err("func: %s line: %d, "\
format, __func__, __LINE__, ##__VA_ARGS__)
#define BFMR_PRINT_SIMPLE_INFO(args...) pr_err(args)
#define BFMR_PRINT_DBG(format, ...) \
pr_devel("func: %s line: %d, "\
format, __func__, __LINE__, ##__VA_ARGS__)
#define BFMR_PRINT_ENTER(format, ...) \
pr_info(">>>>enter func: %s, line: %d\n"\
format, __func__, __LINE__, ##__VA_ARGS__)
#define BFMR_PRINT_EXIT(format, ...) \
pr_info("<<<<exit func: %s, line: %d\n"\
format, __func__, __LINE__, ##__VA_ARGS__)
#define BFMR_BOOTLOCK_FIELD_NAME "bootlock"
#define BFMR_ENABLE_FIELD_NAME "hw_bfm_enable"
#define BFR_ENABLE_FIELD_NAME "hw_bfr_enable"
#define BFR_RRECORD_PART_NAME "rrecord"
#define BFR_MISC_PART_OFFSET ((unsigned int)0x0)
#define BFR_RRECORD_PART_MAX_COUNT 2
#define BFMR_DEV_NAME "hw_bfm"
#define BFMR_DEV_PATH "/dev/hw_bfm"
#define BFM_LOG_MAX_COUNT 10
#define BFM_LOG_MAX_COUNT_PER_DIR 10
#define BFM_MAX_INT_NUMBER_LEN 21
#define BFMR_BOPD_MODE_FIELD_NAME "bopd.mode"
#define BFMR_MOUNT_NAME_SIZE 32
#define BFMR_SHA256_HASH_LEN 32
int bfmr_sha256(unsigned char *pout, unsigned int out_len,
const void *pin, unsigned long in_len);
/*
* @brief: get full path of the "dev_name".
*
* @param: dev_name [in] device name such as: boot/recovery/rrecord.
* @param: path_buf [out] buffer will store the full path of "dev_name".
* @param: path_buf_len [in] length of the path_buf.
*
* @return: 0 - succeeded; -1 - failed.
*
*/
int bfmr_get_device_full_path(char *dev_name, char *path_buf,
unsigned int path_buf_len);
int bfmr_read_emmc_raw_part(const char *dev_path,
unsigned long long offset, char *buf,
unsigned long long buf_size);
int bfmr_write_emmc_raw_part(const char *dev_path,
unsigned long long offset, char *buf,
unsigned long long buf_size);
void bfmr_change_own_mode(char *path, int uid, int gid, int mode);
void bfmr_change_file_ownership(char *path, uid_t uid, gid_t gid);
void bfmr_change_file_mode(char *path, umode_t mode);
int bfmr_get_file_ownership(char *pfile_path, uid_t *puid, gid_t *pgid);
bool bfmr_is_file_existed(const char *pfile_path);
bool bfmr_is_dir_existed(const char *pdir_path);
int bfmr_save_log(const char *logpath, const char *filename, void *buf,
unsigned int len, unsigned int is_append);
long bfmr_get_proc_file_length(const char *pfile_path);
bool bfmr_is_part_mounted_rw(const char *pmount_point);
long bfmr_get_file_length(const char *pfile_path);
long long bfmr_get_fs_available_space(const char *pmount_point);
bool bfmr_is_part_ready_without_timeout(char *dev_name);
int bfmr_wait_for_part_mount_without_timeout(const char *pmount_point);
int bfmr_wait_for_part_mount_with_timeout(const char *pmount_point,
int timeouts);
int bfmr_create_log_path(char *path);
char *bfmr_convert_rtc_time_to_asctime(unsigned long long rtc_time);
char *bfm_get_bootlock_value_from_cmdline(void);
bool bfmr_has_been_enabled(void);
bool bfr_has_been_enabled(void);
void bfmr_enable_ctl(int enable_flag);
char *bfmr_reverse_find_string(char *psrc, const char *pstr_to_be_found);
bool bfm_get_symbol_link_path(const char *file_path, char *psrc_path,
size_t src_path_size);
long bfmr_full_read(int fd, char *buf, size_t buf_size);
long bfmr_full_write(int fd, char *buf, size_t buf_size);
long bfmr_full_read_with_file_path(const char *pfile_path, char *buf,
size_t buf_size);
long bfmr_full_write_with_file_path(const char *pfile_path, char *buf,
size_t buf_size);
void bfmr_unlink_file(char *pfile_path);
int bfmr_get_uid_gid(uid_t *puid, gid_t *pgid);
int bfmr_read_rrecord_misc_msg(struct bfmr_rrecord_misc_param *pparam);
int bfmr_write_rrecord_misc_msg(struct bfmr_rrecord_misc_param *pparam);
unsigned int bfmr_get_bootup_time(void);
char *bfm_get_boot_stage_name(unsigned int boot_stage);
bool bfm_is_beta_version(void);
bool bfmr_is_oversea_commercail_version(void);
int bfm_write_sub_bootfail_magic_num(unsigned int magic_num, void *phys_addr);
int bfm_write_sub_bootfail_num(unsigned int bootfail_errno, void *phys_addr);
int bfm_write_sub_bootfail_count(unsigned int bootfail_count, void *phys_addr);
int bfmr_common_init(void);
void bfmr_set_mount_state(const char *bfmr_mount_point, bool mount_result,
unsigned int size);
#ifdef __cplusplus
}
#endif
#endif
| 31.189189 | 79 | 0.807048 |
fdc05450e4b2e5fb9ad0832ce640fd13480e6cd2 | 4,484 | h | C | System/Library/PrivateFrameworks/AuthKitUI.framework/AKAuthorizationScopeDetailTableViewCell.h | lechium/iOS1351Headers | 6bed3dada5ffc20366b27f7f2300a24a48a6284e | [
"MIT"
] | 2 | 2021-11-02T09:23:27.000Z | 2022-03-28T08:21:57.000Z | System/Library/PrivateFrameworks/AuthKitUI.framework/AKAuthorizationScopeDetailTableViewCell.h | lechium/iOS1351Headers | 6bed3dada5ffc20366b27f7f2300a24a48a6284e | [
"MIT"
] | null | null | null | System/Library/PrivateFrameworks/AuthKitUI.framework/AKAuthorizationScopeDetailTableViewCell.h | lechium/iOS1351Headers | 6bed3dada5ffc20366b27f7f2300a24a48a6284e | [
"MIT"
] | 1 | 2022-03-28T08:21:59.000Z | 2022-03-28T08:21:59.000Z | /*
* This header is generated by classdump-dyld 1.5
* on Friday, April 30, 2021 at 11:36:31 AM Mountain Standard Time
* Operating System: Version 13.5.1 (Build 17F80)
* Image Source: /System/Library/PrivateFrameworks/AuthKitUI.framework/AuthKitUI
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley.
*/
#import <UIKitCore/UITableViewCell.h>
@class UILabel, UIImageView, UILayoutGuide, NSLayoutConstraint;
@interface AKAuthorizationScopeDetailTableViewCell : UITableViewCell {
BOOL _internalChecked;
UILabel* _scopeLabel;
UILabel* _mainLabel;
UILabel* _mainDetailLabel;
UIImageView* _leadingCheckmarkView;
UILayoutGuide* _mainGuide;
UILayoutGuide* _mainLabelFirstLineGuide;
UILayoutGuide* _scopeLabelFirstLineGuide;
NSLayoutConstraint* _minimumHeightConstraint;
NSLayoutConstraint* _mainLabelLeadingConstraint;
unsigned long long _internalCheckmarkStyle;
}
@property (nonatomic,retain) UIImageView * leadingCheckmarkView; //@synthesize leadingCheckmarkView=_leadingCheckmarkView - In the implementation block
@property (nonatomic,readonly) UILayoutGuide * mainGuide; //@synthesize mainGuide=_mainGuide - In the implementation block
@property (nonatomic,readonly) UILayoutGuide * mainLabelFirstLineGuide; //@synthesize mainLabelFirstLineGuide=_mainLabelFirstLineGuide - In the implementation block
@property (nonatomic,readonly) UILayoutGuide * scopeLabelFirstLineGuide; //@synthesize scopeLabelFirstLineGuide=_scopeLabelFirstLineGuide - In the implementation block
@property (nonatomic,readonly) NSLayoutConstraint * minimumHeightConstraint; //@synthesize minimumHeightConstraint=_minimumHeightConstraint - In the implementation block
@property (nonatomic,readonly) NSLayoutConstraint * mainLabelLeadingConstraint; //@synthesize mainLabelLeadingConstraint=_mainLabelLeadingConstraint - In the implementation block
@property (assign,nonatomic) unsigned long long internalCheckmarkStyle; //@synthesize internalCheckmarkStyle=_internalCheckmarkStyle - In the implementation block
@property (assign,getter=internalIsChecked,nonatomic) BOOL internalChecked; //@synthesize internalChecked=_internalChecked - In the implementation block
@property (assign,nonatomic) double minimumHeight;
@property (assign,nonatomic) unsigned long long checkmarkStyle;
@property (assign,getter=isChecked,nonatomic) BOOL checked;
@property (nonatomic,readonly) UILabel * scopeLabel; //@synthesize scopeLabel=_scopeLabel - In the implementation block
@property (nonatomic,readonly) UILabel * mainLabel; //@synthesize mainLabel=_mainLabel - In the implementation block
@property (nonatomic,readonly) UILabel * mainDetailLabel; //@synthesize mainDetailLabel=_mainDetailLabel - In the implementation block
-(void)layoutSubviews;
-(NSLayoutConstraint *)minimumHeightConstraint;
-(id)_newLabel;
-(double)minimumHeight;
-(void)setMinimumHeight:(double)arg1 ;
-(id)initWithStyle:(long long)arg1 reuseIdentifier:(id)arg2 ;
-(id)_checkmarkImage;
-(void)setChecked:(BOOL)arg1 ;
-(BOOL)isChecked;
-(void)_setupViews;
-(id)_checkmarkImageView;
-(UILabel *)scopeLabel;
-(UILabel *)mainLabel;
-(UILabel *)mainDetailLabel;
-(void)setCheckmarkStyle:(unsigned long long)arg1 ;
-(void)_setSeparatorIndentToMainLabel;
-(id)_clearImage;
-(void)_setupLayout;
-(UILayoutGuide *)mainGuide;
-(UILayoutGuide *)mainLabelFirstLineGuide;
-(UILayoutGuide *)scopeLabelFirstLineGuide;
-(NSLayoutConstraint *)mainLabelLeadingConstraint;
-(BOOL)_isLTR;
-(UIImageView *)leadingCheckmarkView;
-(unsigned long long)internalCheckmarkStyle;
-(void)_setCheckMarkStyleLeadingChecked:(BOOL)arg1 ;
-(void)setInternalCheckmarkStyle:(unsigned long long)arg1 ;
-(void)_setCheckmarkStyleTrailingChecked:(BOOL)arg1 ;
-(BOOL)internalIsChecked;
-(void)setInternalChecked:(BOOL)arg1 ;
-(unsigned long long)checkmarkStyle;
-(id)_checkmarkCircleImageViewChecked:(BOOL)arg1 ;
-(id)_selectedCheckmarkCircleImageView;
-(id)_unselectedCheckmarkCircleImageView;
-(id)_checkmarkCircleImage;
-(id)_circleImage;
-(void)setLeadingCheckmarkView:(UIImageView *)arg1 ;
@end
| 54.682927 | 191 | 0.745094 |
ca093a582510fad9f0465e6f31fadbfaeecde580 | 1,251 | h | C | PrivateFrameworks/CoreCDPInternal/CDPDBackupErrorProviderImpl.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 17 | 2018-11-13T04:02:58.000Z | 2022-01-20T09:27:13.000Z | PrivateFrameworks/CoreCDPInternal/CDPDBackupErrorProviderImpl.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 3 | 2018-04-06T02:02:27.000Z | 2018-10-02T01:12:10.000Z | PrivateFrameworks/CoreCDPInternal/CDPDBackupErrorProviderImpl.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 1 | 2018-09-28T13:54:23.000Z | 2018-09-28T13:54:23.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "NSObject.h"
#import "CDPDBackupRecoveryErrorProvider.h"
@class CDPContext, NSString;
@interface CDPDBackupErrorProviderImpl : NSObject <CDPDBackupRecoveryErrorProvider>
{
CDPContext *_context;
id <CDPStateUIProviderInternal> _uiProvider;
unsigned long long _prevailingSecret;
}
- (void).cxx_destruct;
- (void)handleSoftLimitError:(id)arg1 completion:(CDUnknownBlockType)arg2;
- (void)handleHardLimitError:(id)arg1 completion:(CDUnknownBlockType)arg2;
- (id)recordNotFoundErrorWithUnderlyingError:(id)arg1;
- (id)verficationFailedErrorwithUnderlyingError:(id)arg1;
- (id)hardLimitErrorForRecord:(id)arg1;
- (id)globalHardLimitErrorWithRecord:(id)arg1;
- (id)globalHardLimitError;
- (id)cooldownErrorWithUnderlyingError:(id)arg1;
- (void)setPrevailingSecret:(unsigned long long)arg1;
- (BOOL)supportsErrorPresentation;
- (id)initWithContext:(id)arg1 uiProvider:(id)arg2;
// Remaining properties
@property(readonly, copy) NSString *debugDescription;
@property(readonly, copy) NSString *description;
@property(readonly) unsigned long long hash;
@property(readonly) Class superclass;
@end
| 30.512195 | 83 | 0.779376 |
aa4a86c8a47df6a6eb6a6ae17136e15d01b1caa3 | 6,314 | h | C | LEGOrobot-white-ht12/Project12/startup/config.h | PetrusKiendys/MAH-DA123T-Robot | b4e1d0cd5be1b9a45bf78f22c40a82671f5f2554 | [
"MIT"
] | null | null | null | LEGOrobot-white-ht12/Project12/startup/config.h | PetrusKiendys/MAH-DA123T-Robot | b4e1d0cd5be1b9a45bf78f22c40a82671f5f2554 | [
"MIT"
] | null | null | null | LEGOrobot-white-ht12/Project12/startup/config.h | PetrusKiendys/MAH-DA123T-Robot | b4e1d0cd5be1b9a45bf78f22c40a82671f5f2554 | [
"MIT"
] | null | null | null | /******************************************************************************
*
* Copyright:
* (C) 2000 - 2005 Embedded Artists AB
*
* Description:
* Framework for ARM7 processor
*
*****************************************************************************/
#ifndef _config_h_
#define _config_h_
/******************************************************************************
* Defines, macros, and typedefs
*****************************************************************************/
#define FOSC 12000000 /* External clock input frequency (must be between 10 MHz and 25 MHz) */
#define USE_PLL 1 /* 0 = do not use on-chip PLL,
1 = use on-chip PLL) */
#define PLL_MUL 5 /* PLL multiplication factor (1 to 32) */
#define PLL_DIV 2 /* PLL division factor (1, 2, 4, or 8) */
#define PBSD 1 /* Peripheral bus speed divider (1, 2, or 4) */
/* initialize the MAM (Memory Accelerator Module) */
#if USE_PLL == 1
#define CORE_FREQ (FOSC * PLL_MUL)
#else
#define CORE_FREQ (FOSC)
#endif
#if CORE_FREQ < 20000000
#define MAM_TIMING 1 /* number of CCLK to read from the FLASH */
#elif CORE_FREQ < 40000000
#define MAM_TIMING 2 /* number of CCLK to read from the FLASH */
#else
#define MAM_TIMING 3 /* number of CCLK to read from the FLASH */
#endif
#define MAM_SETTING 2 /* 0=disabled,
1=partly enabled (enabled for code prefetch, but not for data),
2=fully enabled */
#define IRQ_HANDLER 0 /* 0 = Jump to common IRQ handler
1 = Load vector directly from VIC, i.e., LDR PC,[PC,#-0xFF0] */
/* initialize the exception vector mapping */
#ifndef RAM_EXEC
#define MAM_MAP 1 /* 1 = exception vectors are in FLASH at 0x0000 0000,
2 = exception vectors are in SRAM at 0x4000 0000 */
#else
#define MAM_MAP 2 /* When executing from RAM, MAM_MAP should always be 2 */
#endif
/* setup stack sizes */
#define stackSize_SYS 600
#define stackSize_SVC 64
#define stackSize_UND 64
#define stackSize_ABT 64
#define stackSize_IRQ 600
#define stackSize_FIQ 64
/* define consol settings */
#define CONSOL_UART 0
#define CONSOL_BITRATE 115200
/*#define USE_UART_FIFO FALSE */ /* Will be added in a future release */
/*#define UART_API_NONBLOCKING FALSE */ /* Will be added in a future release */
/*#define UART_API_NONBLOCKING_SIZE 512 */ /* Will be added in a future release */
#define CONSOL_STARTUP_DELAY /* Short startup delay in order to remove
risk for false startbit detection,
timer #1 will be used in polled mode */
#define CONSOL_STARTUP_DELAY_LENGTH 100 /* 100 us is slightly more than one character at 115200 bps */
#define USE_NEWLIB 0 /* 0 = do not use newlib (= save about 22k FLASH),
1 = use newlib = full implementation of printf(), scanf(), and malloc() */
#define CONSOLE_API_PRINTF 1 /* 0 = printf() = sendString,
1 = simple, own implementation of printf() */
#define CONSOLE_API_SCANF 0 /* 0 = none,
1 = simple, own implementation of scanf() */
/* define SRAM size */
#ifdef LPC2101
#define SRAM_SIZE (2 * 1024) /* LPC2101 */
#elif defined (LPC2102)
#define SRAM_SIZE (4 * 1024) /* LPC2102 */
#elif defined (LPC2103)
#define SRAM_SIZE (8 * 1024) /* LPC2103 */
#elif defined (LPC2104)
#define SRAM_SIZE (16 * 1024) /* LPC2104 */
#elif defined (LPC2105)
#define SRAM_SIZE (32 * 1024) /* LPC2105 */
#elif defined (LPC2106)
#define SRAM_SIZE (64 * 1024) /* LPC2106 */
#elif defined (LPC2114)
#define SRAM_SIZE (16 * 1024) /* LPC2114 */
#elif defined (LPC2124)
#define SRAM_SIZE (16 * 1024) /* LPC2124 */
#elif defined (LPC2119)
#define SRAM_SIZE (16 * 1024) /* LPC2119 */
#elif defined (LPC2129)
#define SRAM_SIZE (16 * 1024) /* LPC2129 */
#elif defined (LPC2131)
#define SRAM_SIZE (8 * 1024) /* LPC2131 */
#elif defined (LPC2132)
#define SRAM_SIZE (16 * 1024) /* LPC2132 */
#elif defined (LPC2134)
#define SRAM_SIZE (16 * 1024) /* LPC2134 */
#elif defined (LPC2136)
#define SRAM_SIZE (32 * 1024) /* LPC2136 */
#elif defined (LPC2138)
#define SRAM_SIZE (32 * 1024) /* LPC2138 */
#elif defined (LPC2141)
#define SRAM_SIZE (8 * 1024) /* LPC2141 */
#elif defined (LPC2142)
#define SRAM_SIZE (16 * 1024) /* LPC2142 */
#elif defined (LPC2144)
#define SRAM_SIZE (16 * 1024) /* LPC2144 */
#elif defined (LPC2146)
#define SRAM_SIZE (32 * 1024) /* LPC2146 */
#elif defined (LPC2148)
#define SRAM_SIZE (32 * 1024) /* LPC2148 */
#elif defined (LPC2194)
#define SRAM_SIZE (16 * 1024) /* LPC2194 */
#elif defined (LPC2210)
#define SRAM_SIZE (16 * 1024) /* LPC2210 */
#elif defined (LPC2220)
#define SRAM_SIZE (64 * 1024) /* LPC2220 */
#elif defined (LPC2212)
#define SRAM_SIZE (16 * 1024) /* LPC2212 */
#elif defined (LPC2214)
#define SRAM_SIZE (16 * 1024) /* LPC2214 */
#elif defined (LPC2290)
#define SRAM_SIZE (16 * 1024) /* LPC2290 */
#elif defined (LPC2292)
#define SRAM_SIZE (16 * 1024) /* LPC2292 */
#elif defined (LPC2294)
#define SRAM_SIZE (16 * 1024) /* LPC2294 */
#else
#error CPU_VARIANT not defined in the makefile, or illegal value
#endif
#define SRAM_SADDR 0x40000000 /* SRAM starting address */
#define SRAM_TOP (SRAM_SADDR+SRAM_SIZE) /* SRAM end address + 1 */
#define SRAM_EADDR (SRAM_SADDR+SRAM_SIZE-1) /* SRAM end address */
#define STK_SIZE (stackSize_SYS+stackSize_SVC+stackSize_UND+stackSize_ABT+stackSize_IRQ+stackSize_FIQ)
#define STK_SADDR (SRAM_EADDR+1-STK_SIZE) /* Stack start address */
#endif /* _config_h_ */
| 39.962025 | 114 | 0.553057 |
e75994715d057a65e1e2caa030c342b69cf778dd | 576 | h | C | include/utils/FbxReader.h | dom380/IMAT3606-Coursework-2 | 36f50b25823cd3170a403a2e2ef50e3019fcd73b | [
"FTL",
"Zlib",
"Apache-2.0",
"MIT"
] | null | null | null | include/utils/FbxReader.h | dom380/IMAT3606-Coursework-2 | 36f50b25823cd3170a403a2e2ef50e3019fcd73b | [
"FTL",
"Zlib",
"Apache-2.0",
"MIT"
] | null | null | null | include/utils/FbxReader.h | dom380/IMAT3606-Coursework-2 | 36f50b25823cd3170a403a2e2ef50e3019fcd73b | [
"FTL",
"Zlib",
"Apache-2.0",
"MIT"
] | null | null | null | #pragma once
#ifndef FBXREADER_H
#define FBXREADER_H
#include "ModelFileReader.h"
/*
Utility class to parse .fbx file types.
TODO
*/
class FbxReader : public ModelFileReader
{
void readFile(const char * filePath, vector<glm::vec4>& vertices, vector<glm::vec3>& normals, vector<glm::vec2>& textures, vector<unsigned short>&indices, Material& material, vector<glm::vec4>& points) {};
void readFile(const char * filePath, shared_ptr<vector<ConvexHull>>& convexHulls) {};
shared_ptr<ModelData> readFile(const char * filePath) { return nullptr; };
};
#endif // !FBXREADER_H
| 33.882353 | 206 | 0.743056 |
c8f15695755d11e6b6a8a2faa8424991599bf3ed | 2,095 | h | C | ash/system/tray/tray_bubble_wrapper.h | sarang-apps/darshan_browser | 173649bb8a7c656dc60784d19e7bb73e07c20daa | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | ash/system/tray/tray_bubble_wrapper.h | sarang-apps/darshan_browser | 173649bb8a7c656dc60784d19e7bb73e07c20daa | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | ash/system/tray/tray_bubble_wrapper.h | sarang-apps/darshan_browser | 173649bb8a7c656dc60784d19e7bb73e07c20daa | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 2 | 2021-01-05T23:43:46.000Z | 2021-01-07T23:36:34.000Z | // Copyright (c) 2012 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 ASH_SYSTEM_TRAY_TRAY_BUBBLE_WRAPPER_H_
#define ASH_SYSTEM_TRAY_TRAY_BUBBLE_WRAPPER_H_
#include "ash/ash_export.h"
#include "ash/system/tray/tray_bubble_base.h"
#include "base/macros.h"
#include "ui/views/widget/widget_observer.h"
#include "ui/wm/public/activation_change_observer.h"
namespace ash {
class TrayBackgroundView;
class TrayBubbleView;
// Creates and manages the Widget and EventFilter components of a bubble.
// TODO(tetsui): Remove this and use TrayBubbleBase for all bubbles.
class ASH_EXPORT TrayBubbleWrapper : public TrayBubbleBase,
public views::WidgetObserver,
public ::wm::ActivationChangeObserver {
public:
TrayBubbleWrapper(TrayBackgroundView* tray,
TrayBubbleView* bubble_view,
bool is_persistent);
~TrayBubbleWrapper() override;
// TrayBubbleBase overrides:
TrayBackgroundView* GetTray() const override;
TrayBubbleView* GetBubbleView() const override;
views::Widget* GetBubbleWidget() const override;
// views::WidgetObserver overrides:
void OnWidgetDestroying(views::Widget* widget) override;
void OnWidgetBoundsChanged(views::Widget* widget,
const gfx::Rect& new_bounds) override;
// ::wm::ActivationChangeObserver overrides:
void OnWindowActivated(ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override;
TrayBackgroundView* tray() { return tray_; }
TrayBubbleView* bubble_view() { return bubble_view_; }
views::Widget* bubble_widget() { return bubble_widget_; }
private:
TrayBackgroundView* tray_;
TrayBubbleView* bubble_view_; // unowned
views::Widget* bubble_widget_;
bool is_persistent_;
DISALLOW_COPY_AND_ASSIGN(TrayBubbleWrapper);
};
} // namespace ash
#endif // ASH_SYSTEM_TRAY_TRAY_BUBBLE_WRAPPER_H_
| 34.344262 | 76 | 0.714081 |
237c5bb6f67cfe224a502e53c5ab8f2f5d1d72af | 4,458 | h | C | ImportantExample/cuteReportView/cutereport/src/core/printerinterface.h | xiaohaijin/Qt | 54d961c6a8123d8e4daf405b7996aba4be9ab7ed | [
"MIT"
] | 3 | 2018-12-24T19:35:52.000Z | 2022-02-04T14:45:59.000Z | ImportantExample/cuteReportView/cutereport/src/core/printerinterface.h | xiaohaijin/Qt | 54d961c6a8123d8e4daf405b7996aba4be9ab7ed | [
"MIT"
] | null | null | null | ImportantExample/cuteReportView/cutereport/src/core/printerinterface.h | xiaohaijin/Qt | 54d961c6a8123d8e4daf405b7996aba4be9ab7ed | [
"MIT"
] | 1 | 2019-05-09T02:42:40.000Z | 2019-05-09T02:42:40.000Z | /***************************************************************************
* This file is part of the CuteReport project *
* Copyright (C) 2012-2015 by Alexander Mikhalov *
* alexander.mikhalov@gmail.com *
* *
** GNU General Public License Usage **
* *
* This library is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
** GNU Lesser General Public License **
* *
* This library is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
****************************************************************************/
#ifndef PRINTERINTERFACE_H
#define PRINTERINTERFACE_H
#include "reportplugininterface.h"
#include "reportinterface.h"
#include "cutereport_globals.h"
#include <QtGui>
#include <QWidget>
namespace CuteReport {
class PrinterHelperInterface;
class CUTEREPORT_EXPORTS PrinterInterface : public ReportPluginInterface
{
Q_OBJECT
Q_INTERFACES(CuteReport::ReportPluginInterface)
Q_PROPERTY(QString printerName READ printerName WRITE setPrinterName NOTIFY printerNameChanged)
Q_PROPERTY(int _current_property READ _currentProperty WRITE _setCurrentProperty DESIGNABLE false)
Q_PROPERTY(QString _current_property_description READ _current_property_description DESIGNABLE false)
public:
explicit PrinterInterface(QObject *parent = 0);
virtual ~PrinterInterface();
virtual PrinterHelperInterface * helper() = 0;
virtual PrinterInterface * createInstance(QObject * parent = 0) const = 0;
virtual PrinterInterface * clone() const = 0;
virtual bool print(CuteReport::ReportInterface * report) = 0;
QString printerName() const;
void setPrinterName(const QString & printerName);
virtual QString lastError() = 0;
virtual void _setCurrentProperty(int num) { m_currentProperty = num; }
virtual int _currentProperty() { return m_currentProperty; }
virtual QString _current_property_description() const;
signals:
void printerNameChanged(const QString &);
protected:
explicit PrinterInterface(const PrinterInterface &dd, QObject * parent);
QString m_printerName;
int m_currentProperty;
friend class ReportCore;
};
class CUTEREPORT_EXPORTS PrinterHelperInterface: public QWidget
{
Q_OBJECT
public:
enum VisibleOptions{ReportsOptions, ObjectsOptions, AllOptions};
PrinterHelperInterface(PrinterInterface * /*printer*/, VisibleOptions = AllOptions){}
virtual void load() = 0;
virtual void save() = 0;
};
}
Q_DECLARE_INTERFACE(CuteReport::PrinterInterface, "CuteReport.PrinterInterface/1.0")
Q_DECLARE_INTERFACE(CuteReport::PrinterHelperInterface, "CuteReport.PrinterHelperInterface/1.0")
//Q_DECLARE_INTERFACE(CuteReport::PrinterOptionsInterface, "CuteReport.PrinterOptionsInterface/1.0")
#endif // PRINTERINTERFACE_H
| 42.865385 | 105 | 0.601839 |
8ad1b5debd347a760347a8eb748d102486ce91d5 | 6,525 | c | C | lib/am335x_sdk/ti/board/src/j721e_evm/board_power.c | brandonbraun653/Apollo | a1ece2cc3f1d3dae48fdf8fe94f0bbb59d405fce | [
"MIT"
] | 2 | 2021-12-27T10:19:01.000Z | 2022-03-15T07:09:06.000Z | lib/am335x_sdk/ti/board/src/j721e_evm/board_power.c | brandonbraun653/Apollo | a1ece2cc3f1d3dae48fdf8fe94f0bbb59d405fce | [
"MIT"
] | null | null | null | lib/am335x_sdk/ti/board/src/j721e_evm/board_power.c | brandonbraun653/Apollo | a1ece2cc3f1d3dae48fdf8fe94f0bbb59d405fce | [
"MIT"
] | null | null | null | /*
* Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/**
* \file board_power.c
*
* \brief Implements functions to control the power on the board.
*
*/
#include <ti/csl/cslr_device.h>
#include <ti/drv/i2c/I2C.h>
#include <ti/drv/i2c/soc/I2C_soc.h>
#include <ti/osal/osal.h>
#include <ti/board/board.h>
#include <ti/board/src/devices/common/common.h>
#include "board_internal.h"
#include "board_power.h"
#include "board_utils.h"
/**
* \brief Function to configure SD card voltage gpio configuration.
*
* \param gpioValue [IN] GPIO pin value.
* 1 for GPIO pin high
* 0 for GPIO pin low
*
* \return BOARD_SOK in case of success or appropriate error code
*
*/
static void Board_sdVoltageCtrlGpioCfg(uint8_t gpioValue)
{
uint32_t regVal;
/* Setting the GPIO direction to output */
regVal = HW_RD_REG32(CSL_GPIO0_BASE + 0x88);
regVal &= ~(0x01 << (BOARD_SDIO_1V8_EN_PIN_NUM % 32));
HW_WR_REG32((CSL_GPIO0_BASE + 0x88), regVal);
/* Setting the GPIO value */
regVal = HW_RD_REG32(CSL_GPIO0_BASE + 0x90);
if(gpioValue == 0)
{
regVal &= ~(0x01 << (BOARD_SDIO_1V8_EN_PIN_NUM % 32));
HW_WR_REG32((CSL_GPIO0_BASE + 0x90), regVal);
}
else
{
regVal |= (gpioValue << (BOARD_SDIO_1V8_EN_PIN_NUM % 32));
HW_WR_REG32((CSL_GPIO0_BASE + 0x90), regVal);
}
}
/**
* \brief Function to programs VDD_CORE to 0.9V.
*
* \return BOARD_SOK in case of success or appropriate error code
*
*/
Board_STATUS Board_pmVDDCoreVoltageCfg(void)
{
I2C_Handle handle = NULL;
Board_STATUS retVal = BOARD_SOK;
uint8_t regData;
/* VDD voltage is 0.9v by default for Leo PMIC SoM */
if(Board_detectBoard(BOARD_ID_SOM) != TRUE)
{
handle = Board_getI2CHandle(BOARD_SOC_DOMAIN_WKUP,
BOARD_PMIC_LP87561_I2C_INSTANCE);
if(handle == NULL)
{
retVal = BOARD_I2C_OPEN_FAIL;
}
else
{
regData = BOARD_PMIC_LP87561_VOLTAGE_0V9_VAL;
retVal= Board_i2c8BitRegWr(handle,
BOARD_PMIC_LP87561_I2C_SLAVE_ADDR,
BOARD_PMIC_LP87561_BUCK0_VOUT_REG,
®Data,
1U,
I2C_WAIT_FOREVER);
if(retVal != BOARD_SOK)
{
retVal = BOARD_I2C_TRANSFER_FAIL;
}
}
/* Wait for some time to ensure voltage ramp is complete */
BOARD_delay(100000);
Board_i2cDeInit();
}
return retVal;
}
/**
* \brief Function to configure SD card voltage.
*
* \param vsel [IN] SD voltage selection. 0 for 3.3v, 1 for 1.8v
*
* \return BOARD_SOK in case of success or appropriate error code
*
*/
Board_STATUS Board_pmSdVoltageCtrl(uint8_t vsel)
{
I2C_Handle handle = NULL;
Board_STATUS retVal = -1;
uint8_t voltage;
uint8_t regData;
uint8_t leoPMIC = 0;
/* Detecting SoM board */
if(Board_detectBoard(BOARD_ID_SOM) == TRUE)
{
leoPMIC = 1;
if(vsel == 0)
{
Board_sdVoltageCtrlGpioCfg(1);
}
else
{
Board_sdVoltageCtrlGpioCfg(0);
}
}
else
{
handle = Board_getI2CHandle(BOARD_SOC_DOMAIN_WKUP,
BOARD_PMIC_I2C_INSTANCE);
if(handle == NULL)
{
retVal = BOARD_I2C_OPEN_FAIL;
goto voltage_switch_exit;
}
if(vsel == 0)
{
voltage = BOARD_PMIC_LDO1_VSEL_3V3;
}
else
{
voltage = BOARD_PMIC_LDO1_VSEL_1V8;
}
/* Write voltage */
retVal = Board_i2c8BitRegWr(handle,
BOARD_PMIC_I2C_SLAVE_ADDR,
BOARD_PMIC_LDO1_VOLTAGE_REG,
&voltage,
1U,
I2C_WAIT_FOREVER);
if(retVal != 0)
{
retVal = BOARD_I2C_TRANSFER_FAIL;
goto voltage_switch_exit;
}
BOARD_delay(10000);
/* Enable LDO */
regData = 0x1;
retVal = Board_i2c8BitRegWr(handle,
BOARD_PMIC_I2C_SLAVE_ADDR,
BOARD_PMIC_LDO1_CTRL_REG,
®Data,
1U,
I2C_WAIT_FOREVER);
if(retVal != 0)
{
retVal = BOARD_I2C_TRANSFER_FAIL;
goto voltage_switch_exit;
}
}
/* Wait for some time to ensure voltage ramp is complete */
BOARD_delay(100000);
retVal = BOARD_SOK; /* Success */
voltage_switch_exit:
if(leoPMIC == 0)
{
Board_i2cDeInit();
}
return retVal;
}
| 29.659091 | 73 | 0.59295 |
c133449026de5505b2e81e1697f672078bd89fce | 12,221 | h | C | MAME4all/trunk/src/drivers/megasys1.h | lofunz/mieme | 4226c2960b46121ec44fa8eab9717d2d644bff04 | [
"Unlicense"
] | 51 | 2015-11-22T14:53:28.000Z | 2021-12-14T07:17:42.000Z | MAME4all/trunk/src/drivers/megasys1.h | lofunz/mieme | 4226c2960b46121ec44fa8eab9717d2d644bff04 | [
"Unlicense"
] | 8 | 2018-01-14T07:19:06.000Z | 2021-08-22T15:29:59.000Z | src/drivers/megasys1.h | raytlin/iMameAtariArcadeDuo | 24adc56d1a6080822a6c9d1770ddbc607814373a | [
"Unlicense"
] | 35 | 2017-02-15T09:39:00.000Z | 2021-12-14T07:17:43.000Z | /***************************************************************************
-= Jaleco Mega System 1 =-
driver by Luca Elia (eliavit@unina.it)
This file contains definitions used across multiple megasys1
and non megasys1 Jaleco games:
* Gfx layouts
* Input ports
* Read and write errors logging
* Scrolling layers handling
***************************************************************************/
/***************************************************************************
Sound Chips Access
***************************************************************************/
WRITE_HANDLER( ms_soundlatch_w );
WRITE_HANDLER( ms_soundlatch2_w );
WRITE_HANDLER( ms_YM2151_register_port_0_w );
WRITE_HANDLER( ms_YM2151_data_port_0_w );
WRITE_HANDLER( ms_OKIM6295_data_0_w );
WRITE_HANDLER( ms_OKIM6295_data_1_w );
/***************************************************************************
Code Decryption
***************************************************************************/
/*
This macro is used to decrypt the code roms:
the first parameter is the encrypted word, the other parameters specify
the bits layout to build the word in clear from the encrypted one
*/
#define BITSWAP(_x,_f,_e,_d,_c,_b,_a,_9,_8,_7,_6,_5,_4,_3,_2,_1,_0)\
(((_x & (1 << _0))?(1<<0x0):0) + \
((_x & (1 << _1))?(1<<0x1):0) + \
((_x & (1 << _2))?(1<<0x2):0) + \
((_x & (1 << _3))?(1<<0x3):0) + \
((_x & (1 << _4))?(1<<0x4):0) + \
((_x & (1 << _5))?(1<<0x5):0) + \
((_x & (1 << _6))?(1<<0x6):0) + \
((_x & (1 << _7))?(1<<0x7):0) + \
((_x & (1 << _8))?(1<<0x8):0) + \
((_x & (1 << _9))?(1<<0x9):0) + \
((_x & (1 << _a))?(1<<0xa):0) + \
((_x & (1 << _b))?(1<<0xb):0) + \
((_x & (1 << _c))?(1<<0xc):0) + \
((_x & (1 << _d))?(1<<0xd):0) + \
((_x & (1 << _e))?(1<<0xe):0) + \
((_x & (1 << _f))?(1<<0xf):0))
void astyanax_rom_decode(int cpu);
void phantasm_rom_decode(int cpu);
void rodland_rom_decode(int cpu);
/***************************************************************************
Gfx Layouts
***************************************************************************/
/* 8x8x4 layout - straightforward arrangement */
#define MEGASYS1_LAYOUT_8x8(_name_,_romsize_)\
static struct GfxLayout _name_ =\
{\
8,8,\
(_romsize_)*8/(8*8*4),\
4,\
{0, 1, 2, 3},\
{0*4,1*4,2*4,3*4,4*4,5*4,6*4,7*4},\
{0*32,1*32,2*32,3*32,4*32,5*32,6*32,7*32},\
8*8*4\
};
/* 16x16x4 layout - straightforward arrangement */
#define MEGASYS1_LAYOUT_16x16(_name_,_romsize_) \
static struct GfxLayout _name_ =\
{\
16,16,\
(_romsize_)*8/(16*16*4),\
4,\
{0, 1, 2, 3},\
{0*4,1*4,2*4,3*4,4*4,5*4,6*4,7*4, \
8*4,9*4,10*4,11*4,12*4,13*4,14*4,15*4}, \
{0*64,1*64,2*64,3*64,4*64,5*64,6*64,7*64,\
8*64,9*64,10*64,11*64,12*64,13*64,14*64,15*64},\
16*16*4\
};
/* 16x16x4 layout - formed by four 8x8x4 tiles */
#define MEGASYS1_LAYOUT_16x16_QUAD(_name_,_romsize_)\
static struct GfxLayout _name_ =\
{\
16,16,\
(_romsize_)*8/(16*16*4),\
4,\
{0, 1, 2, 3},\
{0*4,1*4,2*4,3*4,4*4,5*4,6*4,7*4,\
0*4+32*16,1*4+32*16,2*4+32*16,3*4+32*16,4*4+32*16,5*4+32*16,6*4+32*16,7*4+32*16},\
{0*32,1*32,2*32,3*32,4*32,5*32,6*32,7*32,\
8*32,9*32,10*32,11*32,12*32,13*32,14*32,15*32},\
16*16*4\
};
/***************************************************************************
Input Ports
***************************************************************************/
/* IN0 - COINS */
#define COINS \
PORT_START\
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )\
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )\
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3 )\
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )\
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 )
/* IN1/3 - PLAYER 1/2 */
#define JOY_4BUTTONS(_flag_) \
PORT_START\
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | _flag_ )\
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | _flag_ )\
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | _flag_ )\
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | _flag_ )\
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | _flag_ )\
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | _flag_ )\
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | _flag_ )\
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4 | _flag_ )
#define JOY_3BUTTONS(_flag_) \
PORT_START\
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | _flag_ )\
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | _flag_ )\
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | _flag_ )\
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | _flag_ )\
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | _flag_ )\
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | _flag_ )\
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | _flag_ )\
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
#define JOY_2BUTTONS(_flag_) \
PORT_START\
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | _flag_ )\
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | _flag_ )\
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | _flag_ )\
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | _flag_ )\
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | _flag_ )\
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | _flag_ )\
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
/* IN2 - RESERVE */
#define RESERVE \
PORT_START\
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* Reserve 1P */\
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* Reserve 2P */\
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
/* IN4 - Coinage DSWs */
// 1] 01-41 02-31 03-21 07-11 06-12 05-13 04-14 00-FC * 2
// 2] 04-31 02-21 07-11 03-12 05-13 01-14 06-15 00-FC
// 00-41 20-31 10-21 38-11 18-12 28-13 08-14 30-15
#define COINAGE_6BITS \
PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) )\
PORT_DIPSETTING( 0x04, DEF_STR( 3C_1C ) )\
PORT_DIPSETTING( 0x02, DEF_STR( 2C_1C ) )\
PORT_DIPSETTING( 0x07, DEF_STR( 1C_1C ) )\
PORT_DIPSETTING( 0x03, DEF_STR( 1C_2C ) )\
PORT_DIPSETTING( 0x05, DEF_STR( 1C_3C ) )\
PORT_DIPSETTING( 0x01, DEF_STR( 1C_4C ) )\
PORT_DIPSETTING( 0x06, DEF_STR( 1C_5C ) )\
PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) )\
PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) )\
PORT_DIPSETTING( 0x00, DEF_STR( 4C_1C ) )\
PORT_DIPSETTING( 0x20, DEF_STR( 3C_1C ) )\
PORT_DIPSETTING( 0x10, DEF_STR( 2C_1C ) )\
PORT_DIPSETTING( 0x38, DEF_STR( 1C_1C ) )\
PORT_DIPSETTING( 0x18, DEF_STR( 1C_2C ) )\
PORT_DIPSETTING( 0x28, DEF_STR( 1C_3C ) )\
PORT_DIPSETTING( 0x08, DEF_STR( 1C_4C ) )\
PORT_DIPSETTING( 0x30, DEF_STR( 1C_5C ) )\
#define COINAGE_6BITS_2 \
PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) )\
PORT_DIPSETTING( 0x01, DEF_STR( 4C_1C ) )\
PORT_DIPSETTING( 0x02, DEF_STR( 3C_1C ) )\
PORT_DIPSETTING( 0x03, DEF_STR( 2C_1C ) )\
PORT_DIPSETTING( 0x07, DEF_STR( 1C_1C ) )\
PORT_DIPSETTING( 0x06, DEF_STR( 1C_2C ) )\
PORT_DIPSETTING( 0x05, DEF_STR( 1C_3C ) )\
PORT_DIPSETTING( 0x04, DEF_STR( 1C_4C ) )\
PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) )\
PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) )\
PORT_DIPSETTING( 0x08, DEF_STR( 4C_1C ) )\
PORT_DIPSETTING( 0x10, DEF_STR( 3C_1C ) )\
PORT_DIPSETTING( 0x18, DEF_STR( 2C_1C ) )\
PORT_DIPSETTING( 0x38, DEF_STR( 1C_1C ) )\
PORT_DIPSETTING( 0x30, DEF_STR( 1C_2C ) )\
PORT_DIPSETTING( 0x28, DEF_STR( 1C_3C ) )\
PORT_DIPSETTING( 0x20, DEF_STR( 1C_4C ) )\
PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) )\
#define COINAGE_8BITS \
PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) )\
PORT_DIPSETTING( 0x07, DEF_STR( 4C_1C ) )\
PORT_DIPSETTING( 0x08, DEF_STR( 3C_1C ) )\
PORT_DIPSETTING( 0x09, DEF_STR( 2C_1C ) )\
PORT_DIPSETTING( 0x0f, DEF_STR( 1C_1C ) )\
/* PORT_DIPSETTING( 0x05, DEF_STR( 1C_1C ) )*/ \
/* PORT_DIPSETTING( 0x04, DEF_STR( 1C_1C ) )*/ \
/* PORT_DIPSETTING( 0x03, DEF_STR( 1C_1C ) )*/ \
/* PORT_DIPSETTING( 0x02, DEF_STR( 1C_1C ) )*/ \
/* PORT_DIPSETTING( 0x01, DEF_STR( 1C_1C ) )*/ \
PORT_DIPSETTING( 0x06, DEF_STR( 2C_3C ) )\
PORT_DIPSETTING( 0x0e, DEF_STR( 1C_2C ) )\
PORT_DIPSETTING( 0x0d, DEF_STR( 1C_3C ) )\
PORT_DIPSETTING( 0x0c, DEF_STR( 1C_4C ) )\
PORT_DIPSETTING( 0x0b, DEF_STR( 1C_5C ) )\
PORT_DIPSETTING( 0x0a, DEF_STR( 1C_6C ) )\
PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) )\
PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )\
PORT_DIPSETTING( 0x70, DEF_STR( 4C_1C ) )\
PORT_DIPSETTING( 0x80, DEF_STR( 3C_1C ) )\
PORT_DIPSETTING( 0x90, DEF_STR( 2C_1C ) )\
PORT_DIPSETTING( 0xf0, DEF_STR( 1C_1C ) )\
/* PORT_DIPSETTING( 0x50, DEF_STR( 1C_1C ) )*/ \
/* PORT_DIPSETTING( 0x40, DEF_STR( 1C_1C ) )*/ \
/* PORT_DIPSETTING( 0x30, DEF_STR( 1C_1C ) )*/ \
/* PORT_DIPSETTING( 0x20, DEF_STR( 1C_1C ) )*/ \
/* PORT_DIPSETTING( 0x10, DEF_STR( 1C_1C ) )*/ \
PORT_DIPSETTING( 0x60, DEF_STR( 2C_3C ) )\
PORT_DIPSETTING( 0xe0, DEF_STR( 1C_2C ) )\
PORT_DIPSETTING( 0xd0, DEF_STR( 1C_3C ) )\
PORT_DIPSETTING( 0xc0, DEF_STR( 1C_4C ) )\
PORT_DIPSETTING( 0xb0, DEF_STR( 1C_5C ) )\
PORT_DIPSETTING( 0xa0, DEF_STR( 1C_6C ) )\
PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) )
/***************************************************************************
Scrolling Layers Handling
***************************************************************************/
/* Variables */
extern struct tilemap *megasys1_tmap_0, *megasys1_tmap_1, *megasys1_tmap_2;
extern unsigned char *megasys1_scrollram_0, *megasys1_scrollram_1, *megasys1_scrollram_2;
extern unsigned char *megasys1_objectram, *megasys1_vregs, *megasys1_ram;
extern int megasys1_scroll_flag[3], megasys1_scrollx[3], megasys1_scrolly[3], megasys1_pages_per_tmap_x[3], megasys1_pages_per_tmap_y[3];
extern int megasys1_active_layers, megasys1_sprite_bank;
extern int megasys1_screen_flag, megasys1_sprite_flag;
extern int megasys1_bits_per_color_code;
extern int megasys1_8x8_scroll_0_factor, megasys1_16x16_scroll_0_factor;
extern int megasys1_8x8_scroll_1_factor, megasys1_16x16_scroll_1_factor;
extern int megasys1_8x8_scroll_2_factor, megasys1_16x16_scroll_2_factor;
/* Functions */
int megasys1_vh_start(void);
READ_HANDLER( megasys1_scrollram_0_r );
READ_HANDLER( megasys1_scrollram_1_r );
READ_HANDLER( megasys1_scrollram_2_r );
WRITE_HANDLER( megasys1_scrollram_0_w );
WRITE_HANDLER( megasys1_scrollram_1_w );
WRITE_HANDLER( megasys1_scrollram_2_w );
void megasys1_scroll_0_flag_w(int data);
void megasys1_scroll_1_flag_w(int data);
void megasys1_scroll_2_flag_w(int data);
#define MEGASYS1_VREG_FLAG(_n_) \
megasys1_scroll_##_n_##_flag_w(new_data);
#define MEGASYS1_VREG_SCROLL(_n_, _dir_) megasys1_scroll##_dir_[_n_] = new_data;
#define MEGASYS1_TMAP_SET_SCROLL(_n_) \
if (megasys1_tmap_##_n_) \
{ \
tilemap_set_scrollx(megasys1_tmap_##_n_, 0, megasys1_scrollx[_n_]); \
tilemap_set_scrolly(megasys1_tmap_##_n_, 0, megasys1_scrolly[_n_]); \
}
#define MEGASYS1_TMAP_UPDATE(_n_) \
if ( (megasys1_tmap_##_n_) && (megasys1_active_layers & (1 << _n_) ) ) \
tilemap_update(megasys1_tmap_##_n_);
#define MEGASYS1_TMAP_RENDER(_n_) \
if ( (megasys1_tmap_##_n_) && (megasys1_active_layers & (1 << _n_) ) )\
tilemap_render(megasys1_tmap_##_n_);
#define MEGASYS1_TMAP_DRAW(_n_) \
if ( (megasys1_tmap_##_n_) && (megasys1_active_layers & (1 << _n_) ) ) \
{ \
tilemap_draw(bitmap, megasys1_tmap_##_n_, flag ); \
flag = 0; \
}
| 36.58982 | 138 | 0.611816 |
fce54170c03464abe1c80c181c665e6e400d25e1 | 4,545 | h | C | trunk/modules/h4tl/api/h4tl.h | HESUPING/JmeshBLE-StaticLib | cf0900f004026c7e2e3448ffde07e21d4af8e387 | [
"Apache-2.0"
] | null | null | null | trunk/modules/h4tl/api/h4tl.h | HESUPING/JmeshBLE-StaticLib | cf0900f004026c7e2e3448ffde07e21d4af8e387 | [
"Apache-2.0"
] | null | null | null | trunk/modules/h4tl/api/h4tl.h | HESUPING/JmeshBLE-StaticLib | cf0900f004026c7e2e3448ffde07e21d4af8e387 | [
"Apache-2.0"
] | 3 | 2019-08-27T17:11:42.000Z | 2021-02-04T06:38:35.000Z | /**
****************************************************************************************
*
* @file h4tl.h
*
* @brief H4 UART Transport Layer header file.
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef H4TL_H_
#define H4TL_H_
/**
****************************************************************************************
* @addtogroup H4TL H4 UART Transport Layer
* @ingroup H4TL
* @brief H4 UART Transport Layer
*
* This module creates the abstraction between External UART driver and HCI generic functions
* (designed for H4 UART transport layer).
*
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_config.h" // stack configuration
#if (H4TL_SUPPORT)
#include "rwip.h" // SW interface
#include <stdint.h> // standard integer definition
#include <stdbool.h> // standard boolean definition
/*
* DEFINES
****************************************************************************************
*/
#define H4TL_LOGICAL_CHANNEL_LEN (1)
/// Type of transport layer
enum h4tl_type
{
#if (BLE_HOST_PRESENT)
#if (BLE_EMB_PRESENT) // FULL HOST
/// Application Controller Interface Transport Layer
H4TL_TYPE_AHI = 0,
#if(HCI_TL_SUPPORT)
/// Host Controller Interface Transport Layer
H4TL_TYPE_HCI = 0,
#endif // (HCI_TL_SUPPORT)
#else // !(BLE_EMB_PRESENT) // SPLIT HOST
#if(AHI_TL_SUPPORT)
/// Application Controller Interface Transport Layer
H4TL_TYPE_AHI,
#endif // AHI_TL_SUPPORT
/// Host Controller Interface Transport Layer
H4TL_TYPE_HCI,
#endif // (BLE_EMB_PRESENT)
#else // !(BLE_HOST_PRESENT) // SPLIT EMB
/// Host Controller Interface Transport Layer
H4TL_TYPE_HCI = 0,
#endif // (BLE_HOST_PRESENT)
H4TL_TYPE_MAX,
};
/*
* GLOBAL VARIABLE DECLARATIONS
****************************************************************************************
*/
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief H4TL transport initialization.
*
* Puts the External Interface driver in reception, waiting for simple 1 byte message type. Space for
* reception is allocated with ke_msg_alloc and the pointer is handed to env.rx. RX
* interrupt is enabled.
*
* @param[in] tl_type Transport Layer Type (@see enum h4tl_type)
* @param[in] len Length of the buffer to be transmitted.
*
*****************************************************************************************
*/
void h4tl_init(uint8_t tl_type, const struct rwip_eif_api* eif);
/**
****************************************************************************************
* @brief H4TL write function.
*
* @param[in] type Type of the buffer to be transmitted. It can take one of the following
* values:
* - @ref HCI_EVT_MSG_TYPE for event message
* - @ref HCI_ACL_MSG_TYPE for ACL data
* - @ref HCI_SYNC_MSG_TYPE for synchronous data
*
* @param[in] buf Pointer to the buffer to be transmitted. @note The buffer passed as
* parameter must have one free byte before the first payload byte, so that the H4TL
* module can put the type byte as first transmitted data.
*
* @param[in] len Length of the buffer to be transmitted.
* @param[in] tx_callback Callback for indicating the end of transfer
*****************************************************************************************
*/
void h4tl_write(uint8_t type, uint8_t *buf, uint16_t len, void (*tx_callback)(void));
#if DEEP_SLEEP
/**
****************************************************************************************
* @brief Start External Interface input flow
*
*****************************************************************************************
*/
void h4tl_start(void);
/**
****************************************************************************************
* @brief Stop External Interface input flow if possible
*
* @return true if External Interface flow was stopped, false otherwise
*****************************************************************************************
*/
bool h4tl_stop(void);
#endif //DEEP_SLEEP
#endif //H4TL_SUPPORT
/// @} H4TL
#endif // H4TL_H_
| 30.503356 | 101 | 0.474587 |
9cc8d22ebe2425ab541fcba1e830f68668813121 | 2,969 | c | C | e2studio_project_freeRTOS/ra_gen/common_data.c | micro-ROS/micro_ros_renesas_testbench | 56a25d9e7340eb902b697f68261eb607b2bd0587 | [
"Apache-2.0"
] | null | null | null | e2studio_project_freeRTOS/ra_gen/common_data.c | micro-ROS/micro_ros_renesas_testbench | 56a25d9e7340eb902b697f68261eb607b2bd0587 | [
"Apache-2.0"
] | 24 | 2021-08-31T06:47:23.000Z | 2022-03-23T07:25:48.000Z | e2studio_project_freeRTOS/ra_gen/common_data.c | micro-ROS/micro_ros_renesas_testbench | 56a25d9e7340eb902b697f68261eb607b2bd0587 | [
"Apache-2.0"
] | 1 | 2022-03-18T13:59:23.000Z | 2022-03-18T13:59:23.000Z | /* generated common source file - do not edit */
#include "common_data.h"
ether_phy_instance_ctrl_t g_ether_phy0_ctrl;
const ether_phy_cfg_t g_ether_phy0_cfg =
{
.channel = 0,
.phy_lsi_address = 0, .phy_reset_wait_time = 0x00020000, .mii_bit_access_wait_time = 8, .flow_control =
ETHER_PHY_FLOW_CONTROL_DISABLE,
.mii_type = ETHER_PHY_MII_TYPE_RMII, .p_context = NULL, .p_extend = NULL,
};
/* Instance structure to use this module. */
const ether_phy_instance_t g_ether_phy0 =
{ .p_ctrl = &g_ether_phy0_ctrl, .p_cfg = &g_ether_phy0_cfg, .p_api = &g_ether_phy_on_ether_phy };
ether_instance_ctrl_t g_ether0_ctrl;
uint8_t g_ether0_mac_address[6] =
{ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
__attribute__((__aligned__(16))) ether_instance_descriptor_t g_ether0_tx_descriptors[1] ETHER_BUFFER_PLACE_IN_SECTION;
__attribute__((__aligned__(16))) ether_instance_descriptor_t g_ether0_rx_descriptors[4] ETHER_BUFFER_PLACE_IN_SECTION;
__attribute__((__aligned__(32)))uint8_t g_ether0_ether_buffer0[1536]ETHER_BUFFER_PLACE_IN_SECTION;
__attribute__((__aligned__(32)))uint8_t g_ether0_ether_buffer1[1536]ETHER_BUFFER_PLACE_IN_SECTION;
__attribute__((__aligned__(32)))uint8_t g_ether0_ether_buffer2[1536]ETHER_BUFFER_PLACE_IN_SECTION;
__attribute__((__aligned__(32)))uint8_t g_ether0_ether_buffer3[1536]ETHER_BUFFER_PLACE_IN_SECTION;
__attribute__((__aligned__(32)))uint8_t g_ether0_ether_buffer4[1536]ETHER_BUFFER_PLACE_IN_SECTION;
uint8_t *pp_g_ether0_ether_buffers[5] =
{ (uint8_t*) &g_ether0_ether_buffer0[0],
(uint8_t*) &g_ether0_ether_buffer1[0],
(uint8_t*) &g_ether0_ether_buffer2[0],
(uint8_t*) &g_ether0_ether_buffer3[0],
(uint8_t*) &g_ether0_ether_buffer4[0], };
const ether_cfg_t g_ether0_cfg =
{ .channel = 0, .zerocopy = ETHER_ZEROCOPY_DISABLE, .multicast = ETHER_MULTICAST_ENABLE, .promiscuous =
ETHER_PROMISCUOUS_DISABLE,
.flow_control = ETHER_FLOW_CONTROL_DISABLE, .padding = ETHER_PADDING_DISABLE, .padding_offset = 0, .broadcast_filter =
0,
.p_mac_address = g_ether0_mac_address,
.p_rx_descriptors = g_ether0_rx_descriptors,
.p_tx_descriptors = g_ether0_tx_descriptors,
.num_tx_descriptors = 1,
.num_rx_descriptors = 4,
.pp_ether_buffers = pp_g_ether0_ether_buffers,
.ether_buffer_size = 1536,
#if defined(VECTOR_NUMBER_EDMAC0_EINT)
.irq = VECTOR_NUMBER_EDMAC0_EINT,
#else
.irq = FSP_INVALID_VECTOR,
#endif
.interrupt_priority = (12),
.p_callback = vEtherISRCallback,
.p_ether_phy_instance = &g_ether_phy0, .p_context = NULL, .p_extend = NULL, };
/* Instance structure to use this module. */
const ether_instance_t g_ether0 =
{ .p_ctrl = &g_ether0_ctrl, .p_cfg = &g_ether0_cfg, .p_api = &g_ether_on_ether };
ether_instance_t const *gp_freertos_ether = &g_ether0;
ioport_instance_ctrl_t g_ioport_ctrl;
const ioport_instance_t g_ioport =
{ .p_api = &g_ioport_on_ioport, .p_ctrl = &g_ioport_ctrl, .p_cfg = &g_bsp_pin_cfg, };
void g_common_init(void)
{
}
| 38.064103 | 120 | 0.780734 |
9b3a300bcbdb28ad58b5aedef6ea1470785c9d28 | 1,642 | c | C | Algorithms/Midpoint Circle.c | KeerthanaPravallika/OpenOctober | e93c120c90ce6c298b7052a2f7759560a2a2761c | [
"Apache-2.0"
] | 32 | 2020-10-17T09:58:41.000Z | 2021-10-13T04:43:35.000Z | Algorithms/Midpoint Circle.c | KeerthanaPravallika/OpenOctober | e93c120c90ce6c298b7052a2f7759560a2a2761c | [
"Apache-2.0"
] | 380 | 2020-10-18T15:35:49.000Z | 2021-12-25T05:03:50.000Z | Algorithms/Midpoint Circle.c | KeerthanaPravallika/OpenOctober | e93c120c90ce6c298b7052a2f7759560a2a2761c | [
"Apache-2.0"
] | 68 | 2020-10-17T17:29:54.000Z | 2021-10-13T04:43:35.000Z | #include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
void draw(float xc, float yc, float r)
{
float x = 0;
float y = r;
float pk;
pk = 1 - r;
while(x < y){
delay(10);
putpixel((xc+x),(yc+y),WHITE);
putpixel((xc+x),(yc-y),WHITE);
putpixel((xc-x),(yc+y),WHITE);
putpixel((xc-x),(yc-y),WHITE);
putpixel((xc+y),(yc+x),WHITE);
putpixel((xc+y),(yc-x),WHITE);
putpixel((xc-y),(yc+x),WHITE);
putpixel((xc-y),(yc-x),WHITE);
if(pk<0){
x += 1;
pk = pk + (2 * x) + 1;
}
else{
x += 1; y -= 1;
pk = pk + (2 * x) + 1 - (2 * y);
}
}
line (xc,yc+r,xc,yc-r);
line (xc+r,yc,xc-r,yc);
line (xc+x,yc+y,xc-x,yc-y);
line (xc-x,yc+y,xc+x,yc-y);
setfillstyle(1,1);
floodfill(xc+1, yc+(r/2), WHITE);
setfillstyle(1,2);
floodfill(xc-1, yc+(r/2), WHITE);
setfillstyle(1,3);
floodfill(xc+1, yc-(r/2), WHITE);
setfillstyle(1,4);
floodfill(xc-1, yc-(r/2), WHITE)
;
setfillstyle(1,5);
floodfill(xc+(r/2), yc+1, WHITE);
setfillstyle(1,6);
floodfill(xc+(r/2), yc-1, WHITE);
setfillstyle(1,7);
floodfill(xc-(r/2), yc+1, WHITE);
setfillstyle(1,8);
floodfill(xc-(r/2), yc-1, WHITE);
}
void main()
{
clrscr();
int gdriver = DETECT, gmode;
float xc, yc,r;
initgraph(&gdriver,&gmode,"C:\\TC\\BGI");
printf("Enter the center coordinate : ");
scanf("%f %f",&xc,&yc);
printf("Enter the Radius : ");
scanf("%f",&r);
draw(xc,yc,r);
getch();
closegraph();
}
| 21.324675 | 45 | 0.5 |
e44f67de7720a37d725b67eca66c5c8262911cca | 3,397 | h | C | game/world.h | graphitemaster/neothyne | 101dd7f96e5c62e32e797105d9fb23f975986626 | [
"MIT"
] | 77 | 2015-02-07T09:08:35.000Z | 2022-03-29T11:36:25.000Z | game/world.h | graphitemaster/neothyne | 101dd7f96e5c62e32e797105d9fb23f975986626 | [
"MIT"
] | 45 | 2015-02-23T07:24:27.000Z | 2017-01-05T13:39:34.000Z | game/world.h | graphitemaster/neothyne | 101dd7f96e5c62e32e797105d9fb23f975986626 | [
"MIT"
] | 20 | 2015-01-03T16:46:25.000Z | 2021-09-16T02:44:56.000Z | #ifndef WORLD_HDR
#define WORLD_HDR
#include "r_light.h"
#include "r_skybox.h"
#include "r_world.h"
// a map model
struct mapModel {
mapModel();
m::vec3 position;
m::vec3 scale;
m::vec3 rotate;
u::string name;
bool highlight;
float curFrame;
};
inline mapModel::mapModel()
: highlight(false)
, curFrame(0.0f)
{
}
struct playerStart {
m::vec3 position;
m::vec3 direction;
bool highlight;
};
struct teleport {
m::vec3 position;
m::vec3 direction;
bool highlight;
};
struct jumppad {
m::vec3 position;
m::vec3 direction;
m::vec3 velocity;
bool highlight;
};
enum class entity {
kMapModel,
kPlayerStart,
kDirectionalLight,
kPointLight,
kSpotLight,
kTeleport,
kJumppad
};
struct world {
world() : m_renderer(nullptr) { }
~world();
bool load(const u::string &map);
bool upload(const m::perspective &p);
void render(const r::pipeline &pl);
bool setRenderer(r::World &renderer) {
m_renderer = &renderer;
return true;
}
void setFog(const r::fog &f);
void unload(bool destroy = true);
bool isLoaded() const;
// World entity descriptor
struct descriptor {
entity type;
size_t index;
size_t where;
};
struct trace {
struct hit {
m::vec3 position; // Position of what was hit
m::vec3 normal; // Normal of what was hit
descriptor *ent; // The entity hit or null if level geometry
float fraction; // normalized [0, 1] fraction of distance made before hit
};
struct query {
m::vec3 start;
m::vec3 direction;
float radius;
};
};
bool trace(const trace::query &q, trace::hit *result, float maxDistance, bool entities = true, descriptor *ignore = nullptr);
descriptor *insert(const r::spotLight &it);
descriptor *insert(const r::pointLight &it);
descriptor *insert(const mapModel &it);
descriptor *insert(const playerStart &it);
descriptor *insert(const teleport &it);
descriptor *insert(const jumppad &it);
void erase(size_t where); // Erase an entity
r::directionalLight *getDirectionalLight();
r::spotLight &getSpotLight(size_t index);
r::pointLight &getPointLight(size_t index);
mapModel &getMapModel(size_t index);
playerStart &getPlayerStart(size_t index);
teleport &getTeleport(size_t index);
jumppad &getJumppad(size_t index);
ColorGrader *getColorGrader();
const u::vector<mapModel*> &getMapModels() const;
protected:
friend struct r::World;
static constexpr float kMaxTraceDistance = 99999.9f;
// Load from compressed data
bool load(const u::vector<unsigned char> &data);
private:
kdMap m_map; // The map for this world
r::World *m_renderer;
u::vector<descriptor> m_entities;
// The following are populated via insert/erase
u::vector<r::billboard*> m_billboards;
u::vector<r::spotLight*> m_spotLights;
u::vector<r::pointLight*> m_pointLights;
u::vector<mapModel*> m_mapModels;
u::vector<playerStart*> m_playerStarts;
u::vector<teleport*> m_teleports;
u::vector<jumppad*> m_jumppads;
// internal rendering state for the world
u::map<u::string, r::texture2D*> m_textures;
u::map<u::string, r::model*> m_models;
};
#endif
| 23.590278 | 129 | 0.639388 |
c0ddef5efb1d6400a61fee60f463213aa149a0ab | 17,792 | c | C | source/dao_font.c | sanyaade-teachings/DaoGraphics | 604952cd8c5b9e59e416f98b1ea08488cdc61bf1 | [
"BSD-2-Clause"
] | 1 | 2017-04-30T04:48:42.000Z | 2017-04-30T04:48:42.000Z | source/dao_font.c | sanyaade-teachings/DaoGraphics | 604952cd8c5b9e59e416f98b1ea08488cdc61bf1 | [
"BSD-2-Clause"
] | null | null | null | source/dao_font.c | sanyaade-teachings/DaoGraphics | 604952cd8c5b9e59e416f98b1ea08488cdc61bf1 | [
"BSD-2-Clause"
] | null | null | null | /*
// Dao Graphics Engine
// http://www.daovm.net
//
// Copyright (c) 2012,2013, Limin Fu
// 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.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <math.h>
#include <string.h>
#include "dao_font.h"
typedef unsigned long ulong_t;
enum DaoxTTPlatformIDs
{
DAOTT_PLATFORM_ID_UNICODE = 0,
DAOTT_PLATFORM_ID_MAC = 1,
DAOTT_PLATFORM_ID_ISO = 2,
DAOTT_PLATFORM_ID_MICROSOFT = 3
};
enum DaoxTTUnicodeEncodings
{
DAOTT_UNICODE_DEFAULT = 0,
DAOTT_UNICODE_1_1 = 1,
DAOTT_UNICODE_ISO = 2,
DAOTT_UNICODE_2_0 = 3
};
short daox_tt_short( uchar_t *data )
{
return (data[0]<<8) + data[1];
}
ushort_t daox_tt_ushort( uchar_t *data )
{
return (data[0]<<8) + data[1];
}
long daox_tt_long( uchar_t *data )
{
return (data[0]<<24) + (data[1]<<16) + (data[2]<<8) + data[3];
}
ulong_t daox_tt_ulong( uchar_t *data )
{
return (data[0]<<24) + (data[1]<<16) + (data[2]<<8) + data[3];
}
DaoxFont* DaoxFont_New()
{
DaoxFont *self = (DaoxFont*) calloc( 1, sizeof(DaoxFont) );
DaoCstruct_Init( (DaoCstruct*)self, daox_type_font );
self->buffer = DString_New(0);
self->glyphs = DMap_New(0,0);
self->glyphs2 = DMap_New(0,0);
self->triangulator = DaoxTriangulator_New();
return self;
}
void DaoxFont_Delete( DaoxFont *self )
{
DNode *it;
for(it=DMap_First(self->glyphs); it; it=DMap_Next(self->glyphs,it)){
DaoxGlyph_Delete( (DaoxGlyph*) it->value.pVoid );
}
if( self->points ) free( self->points );
DMap_Delete( self->glyphs );
DMap_Delete( self->glyphs2 );
DString_Delete( self->buffer );
DaoxTriangulator_Delete( self->triangulator );
DaoCstruct_Free( (DaoCstruct*) self );
dao_free( self );
}
void DaoxFont_ResetGlyphs( DaoxFont *self )
{
DNode *it;
for(it=DMap_First(self->glyphs); it; it=DMap_Next(self->glyphs,it)){
DaoxGlyph *glyph = (DaoxGlyph*) it->value.pVoid;
// TODO: reset glyph shape;
}
}
int DaoxFont_Open( DaoxFont *self, const char *file )
{
FILE *fin = fopen( file, "r" );
char tag[5] = {0};
uchar_t *cmap;
int numberSubtables;
int i, numTables;
DaoxFont_ResetGlyphs( self );
DString_Reset( self->buffer, 0 );
if( fin == NULL ) return 0;
DaoFile_ReadAll( fin, self->buffer, 1 );
self->fontData = (uchar_t*)DString_GetMBS( self->buffer );
self->fontStart = 0;
if( strncmp( (char*)self->fontData, "ttcf", 4 ) == 0 ){
int v = daox_tt_ulong( self->fontData + 4 );
if( v == 0x00010000 || v == 0x00020000 ){
int n = daox_tt_ulong( self->fontData + 8 );
if( n > 0 ) self->fontStart = daox_tt_ulong( self->fontData + 12 + 14*0 );
printf( "n = %i\n", n );
}
}
numTables = daox_tt_ushort( self->fontData + 4 );
printf( "numTables = %i\n", numTables );
for(i=0; i<numTables; ++i){
uchar_t *dir = self->fontData + 12 + 16*i;
strncpy( tag, (char*) dir, 4 );
printf( "%3i: %s\n", (int)i, tag );
}
#if 0
#endif
self->head = DaoxFont_FindTable( self, "head" );
self->cmap = DaoxFont_FindTable( self, "cmap" );
self->loca = DaoxFont_FindTable( self, "loca" );
self->glyf = DaoxFont_FindTable( self, "glyf" );
self->hhea = DaoxFont_FindTable( self, "hhea" );
self->hmtx = DaoxFont_FindTable( self, "hmtx" );
if( self->head == 0 || self->cmap == 0 || self->loca == 0 || self->glyf == 0 ) return 0;
self->fontHeight = daox_tt_short( self->fontData + self->hhea + 2 );
self->fontHeight += daox_tt_short( self->fontData + self->hhea + 4 );
self->lineSpace = self->fontHeight + daox_tt_short( self->fontData + self->hhea + 8 );
self->indexToLocFormat = daox_tt_ushort( self->fontData + self->head + 50 );
printf( "cmap: %i\n", self->cmap );
printf( "indexToLocFormat: %i\n", self->indexToLocFormat );
printf( "fontHeight: %i\n", self->fontHeight );
self->enc_map = -1;
cmap = self->fontData + self->cmap;
numberSubtables = daox_tt_ushort( cmap + 2 );
printf( "numberSubtables = %i\n", numberSubtables );
for(i=0; i<numberSubtables; ++i){
ushort_t pid = daox_tt_ushort( cmap + 4 + 8*i );
ushort_t enc = daox_tt_ushort( cmap + 4 + 8*i + 2 );
printf( "%3i: %3i %3i\n", i, (int)pid, (int)enc );
if( pid == DAOTT_PLATFORM_ID_UNICODE && enc == DAOTT_UNICODE_2_0 ){
self->enc_map = self->cmap + daox_tt_ulong( cmap + 4 + 8*i + 4 );
break;
}else if( pid == DAOTT_PLATFORM_ID_MICROSOFT && enc == DAOTT_UNICODE_DEFAULT ){
self->enc_map = self->cmap + daox_tt_ulong( cmap + 4 + 8*i + 4 );
break;
}else if( pid == DAOTT_PLATFORM_ID_MAC && enc == DAOTT_UNICODE_DEFAULT ){
self->enc_map = self->cmap + daox_tt_ulong( cmap + 4 + 8*i + 4 );
break;
}
}
printf( "enc_map = %i\n", self->enc_map );
if( self->enc_map < 0 ) return 0;
self->enc_format = daox_tt_ushort( self->fontData + self->enc_map );
printf( "format = %i\n", (int) self->enc_format );
return 1;
}
int DaoxFont_FindTable( DaoxFont *self, const char *tag )
{
uchar_t *fontData = self->fontData + self->fontStart;
int numTables = daox_tt_ushort( fontData + 4 );
int cmp, mid, first = 0, last = numTables - 1;
while( first <= last ){
mid = (first + last) / 2;
cmp = strncmp( tag, (char*) fontData + 12 + 16*mid, 4 );
if( cmp == 0 ){
return daox_tt_ulong( fontData + 12 + 16 * mid + 8 );
}else if( cmp < 0 ){
last = mid - 1;
}else{
first = mid + 1;
}
}
return 0;
}
int DaoxFont_FindGlyphIndexF0( DaoxFont *self, wchar_t ch )
{
return 0;
}
int DaoxFont_FindGlyphIndexF2( DaoxFont *self, wchar_t ch )
{
return 0;
}
int DaoxFont_FindGlyphIndexF4( DaoxFont *self, wchar_t ch )
{
uchar_t *enc_map = self->fontData + self->enc_map;
ushort_t segCount = daox_tt_ushort( enc_map + 6 ) >> 1;
uchar_t *endCodes = enc_map + 14;
uchar_t *startCodes = enc_map + 16 + 2*segCount;
uchar_t *idDeltas = enc_map + 16 + 4*segCount;
uchar_t *idRangeOffsets = enc_map + 16 + 6*segCount;
ushort_t code = (ushort_t) ch;
int first = 0, last = segCount - 1;
if( ch > 0xffff ) return 0;
while( first <= last ){
int i = (first + last) / 2;
ushort_t startCode = daox_tt_ushort( startCodes + 2*i );
ushort_t endCode = daox_tt_ushort( endCodes + 2*i );
printf( "%6i: %6i %6i\n", i, (int)startCode, (int)endCode );
if( code < startCode ){
last = i - 1;
}else if( code > endCode ){
first = i + 1;
}else{
ushort_t idRangeOffset = daox_tt_ushort( idRangeOffsets + 2*i );
ushort_t idDelta = daox_tt_ushort( idDeltas + 2*i );
if( idRangeOffset == 0 ) return (idDelta + code) & 0xffff;
return daox_tt_ushort(idRangeOffsets + 2*i + idRangeOffset / 2 + (code - startCode));
}
}
return 0;
}
int DaoxFont_FindGlyphIndexF6( DaoxFont *self, wchar_t ch )
{
return 0;
}
int DaoxFont_FindGlyphIndexF12( DaoxFont *self, wchar_t ch )
{
return 0;
}
int DaoxFont_FindGlyphIndex( DaoxFont *self, wchar_t ch )
{
switch( self->enc_format ){
case 0 : return DaoxFont_FindGlyphIndexF0( self, ch );
case 2 : return DaoxFont_FindGlyphIndexF2( self, ch );
case 4 : return DaoxFont_FindGlyphIndexF4( self, ch );
case 6 : return DaoxFont_FindGlyphIndexF6( self, ch );
case 12 : return DaoxFont_FindGlyphIndexF12( self, ch );
}
return 0;
}
int DaoxFont_FindGlyphLocation( DaoxFont *self, int glyph_index )
{
int location = 0;
int location2 = 0;
uchar_t *loca = self->fontData + self->loca;
if( self->indexToLocFormat ){
location = daox_tt_ulong( loca + 4*glyph_index );
location2 = daox_tt_ulong( loca + 4*glyph_index + 4 );
}else{
location = daox_tt_ushort( loca + 2*glyph_index ) * 2;
location2 = daox_tt_ushort( loca + 2*glyph_index + 2 ) * 2;
}
return location == location2 ? -1 : location;
}
int DaoxFont_MakeGlyph2( DaoxFont *self, int glyph_index, DaoxGlyph *glyph )
{
int gloc = DaoxFont_FindGlyphLocation( self, glyph_index );
uchar_t *glyf = self->fontData + self->glyf + gloc;
uchar_t *cpart = glyf + 10;
int i, more = 1;
if( gloc < 0 ) return 1;
while( more ){
DaoxGlyph *subglyph = DaoxFont_GetGlyph( self, daox_tt_ushort(cpart+2) );
ushort_t flags = daox_tt_ushort( cpart );
DaoxMatrix3D tmat = { 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 };
double m, n;
more = flags & (1<<5);
cpart += 4;
if( flags & 2 ){ /* ARGS_ARE_XY_VALUES */
if( flags & 1 ){ /* ARG_1_AND_2_ARE_WORDS */
tmat.B1 = daox_tt_short( cpart );
tmat.B2 = daox_tt_short( cpart+2 );
cpart += 4;
}else{
//tmat.B1 = (char)*cpart++;
//tmat.B2 = (char)*cpart++;
tmat.B1 = *(char*)cpart;
tmat.B2 = *(char*)(cpart+1);
cpart += 2;
}
}else{
printf( "!!!!!!!!!!!!!!!!!!!!!!!!!!\n" );
return 0;
}
if( flags & (1<<3) ){ /* WE_HAVE_A_SCALE */
printf( "here: %i\n", daox_tt_short( cpart ) );
tmat.A11 = tmat.A22 = daox_tt_short( cpart ) / 16384.0f;
cpart += 2;
}else if( flags & (1<<6) ){ /* WE_HAVE_AN_X_AND_Y_SCALE */
tmat.A11 = daox_tt_short( cpart+0 ) / 16384.0f;
tmat.A22 = daox_tt_short( cpart+2 ) / 16384.0f;
cpart += 4;
}else if( flags & (1<<7) ){ /* WE_HAVE_A_TWO_BY_TWO */
tmat.A11 = daox_tt_short( cpart+0 ) / 16384.0f;
tmat.A21 = daox_tt_short( cpart+2 ) / 16384.0f;
tmat.A12 = daox_tt_short( cpart+4 ) / 16384.0f;
tmat.A22 = daox_tt_short( cpart+6 ) / 16384.0f;
cpart += 8;
}
m = fabs(tmat.A11) > fabs(tmat.A21) ? fabs(tmat.A11) : fabs(tmat.A21);
n = fabs(tmat.A12) > fabs(tmat.A22) ? fabs(tmat.A12) : fabs(tmat.A22);
if( fabs( fabs(tmat.A11) - fabs(tmat.A21) ) < 33.0/65536.0 ) m = m + m;
if( fabs( fabs(tmat.A12) - fabs(tmat.A22) ) < 33.0/65536.0 ) n = n + n;
tmat.B1 *= m;
tmat.B2 *= n;
DaoxPath_ImportPath( glyph->shape, subglyph->shape, & tmat );
printf( "%5.3f %5.3f %5.3f %5.3f %5.3f %5.3f\n", tmat.A11, tmat.A21, tmat.A12, tmat.A22, tmat.B1, tmat.B2 );
}
DaoxPath_Preprocess( glyph->shape, self->triangulator );
return 1;
}
int DaoxFont_MakeGlyph( DaoxFont *self, int glyph_index, DaoxGlyph *glyph )
{
int gloc = DaoxFont_FindGlyphLocation( self, glyph_index );
uchar_t *hmtx = self->fontData + self->hmtx;
uchar_t *glyf = self->fontData + self->glyf + gloc;
uchar_t *simdata = glyf + 10;
uchar_t *endPtsOfContours, *flags, *points, *xCoordinates, *yCoordinates;
ushort_t numOfLongHorMetrics = daox_tt_ushort( self->fontData + self->hhea + 34 );
short numberOfContours, instructionLength, pointCount;
short i, dx, dy, x = 0, y = 0, flagCount = 0;
uchar_t flag = 0;
printf( "DaoxFont_MakeGlyph: %i\n", glyph_index );
DaoxPath_Reset( glyph->shape );
if( glyph_index < numOfLongHorMetrics ){
glyph->advanceWidth = daox_tt_short( hmtx + 4*glyph_index );
glyph->leftSideBearing = daox_tt_short( hmtx + 4*glyph_index + 2 );
}else{
glyph->advanceWidth = daox_tt_short( hmtx + 4*(numOfLongHorMetrics - 1) );
glyph->leftSideBearing = daox_tt_short( hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics) );
}
if( gloc < 0 ) return 1;
numberOfContours = daox_tt_short( glyf );
if( numberOfContours < 0 ) return DaoxFont_MakeGlyph2( self, glyph_index, glyph );
instructionLength = daox_tt_ushort( simdata + 2*numberOfContours );
endPtsOfContours = simdata;
flags = simdata + 2*numberOfContours + 2 + instructionLength;
pointCount = 1 + daox_tt_ushort( endPtsOfContours + 2*numberOfContours - 2 );
printf( "glyph index = %i\n", glyph_index );
printf( "glyph loation = %i\n", gloc );
printf( "numberOfContours = %i\n", numberOfContours );
printf( "pointCount = %i\n", pointCount );
/* load flags and coordinates into the self->points: */
self->points = (DaoxGlyphPoint*) realloc( self->points, pointCount*sizeof(DaoxGlyphPoint) );
for(i=0; i<pointCount; ++i){
if( flagCount == 0 ){
flag = *flags++;
if( flag & 8 ) flagCount = *flags++; /* repeats; */
}else{
flagCount -= 1;
}
self->points[i].flag = flag;
}
points = flags;
for(i=0; i<pointCount; ++i){
flag = self->points[i].flag;
if( flag & 2 ){ /* 1 byte long x-coordinate: */
dx = *points++;
x += (flag & 16) ? dx : -dx; /* ??? */
}else{
if( !(flag & 16) ){
x += daox_tt_short( points );
points += 2;
}
}
self->points[i].x = x;
}
for(i=0; i<pointCount; ++i){
flag = self->points[i].flag;
if( flag & 4 ){ /* 1 byte long x-coordinate: */
dy = *points++;
y += (flag & 32) ? dy : -dy;
}else{
if( !(flag & 32) ){
y += daox_tt_short( points );
points += 2;
}
}
self->points[i].y = y;
}
DaoxPath_SetRelativeMode( glyph->shape, 0 );
for(i=0; i<numberOfContours; ++i){
int start = i == 0 ? 0 : 1 + daox_tt_ushort( endPtsOfContours + 2*(i-1) );
int end = daox_tt_ushort( endPtsOfContours + 2*i );
int xnext, ynext;
int j, x0, y0, start2 = start;
int cx0 = -1, cy0 = -1;
flag = self->points[start].flag;
x0 = self->points[start].x;
y0 = self->points[start].y;
if( ! (flag & 1) ){ /* off curve point: */
cx0 = x0;
cy0 = y0;
x = self->points[start].x;
y = self->points[start].y;
if( self->points[start].flag & 1 ){ /* on curve: */
x0 = x;
y0 = y;
start2 += 1;
}else{ /* also off curve, interpolate on-curve point: */
x0 = (cx0 + x) >> 1;
y0 = (cy0 + y) >> 1;
}
}
DaoxPath_MoveTo( glyph->shape, x0, y0 );
for(j=start2+1; j<=end; j++){
ushort_t next = start + ((j+1-start) % (end - start + 1));
flag = self->points[j].flag;
x = self->points[j].x;
y = self->points[j].y;
if( flag & 1 ){ /* on curve point: */
DaoxPath_LineTo( glyph->shape, x, y );
}else if( self->points[next].flag & 1 ){ /* on curve point: */
xnext = self->points[next].x;
ynext = self->points[next].y;
DaoxPath_QuadTo( glyph->shape, x, y, xnext, ynext );
j += 1;
}else{ /* off curve point, interpolate on-curve point: */
xnext = (x + self->points[next].x) >> 1;
ynext = (y + self->points[next].y) >> 1;
DaoxPath_QuadTo( glyph->shape, x, y, xnext, ynext );
}
}
if( cx0 >= 0 ){
DaoxPath_QuadTo( glyph->shape, cx0, cy0, x0, y0 );
}
DaoxPath_Close( glyph->shape );
}
#if 0
for(i=0; i<pointCount; ++i){
flag = self->points[i].flag;
x = self->points[i].x;
y = self->points[i].y;
printf( "%3i: %2i %5i %5i\n", i, flag&1, x, y );
}
#endif
DaoxPath_Preprocess( glyph->shape, self->triangulator );
return 1;
}
DaoxGlyph* DaoxFont_GetGlyph( DaoxFont *self, int glyph_index )
{
DNode *node = DMap_Find( self->glyphs, (void*)(size_t) glyph_index );
DaoxGlyph *glyph = node ? (DaoxGlyph*) node->value.pVoid : NULL;
if( glyph && glyph->shape->mesh->triangles->size ) return glyph;
if( self->buffer->size == 0 ) return NULL;
if( glyph == NULL ){
glyph = DaoxGlyph_New();
DMap_Insert( self->glyphs, (void*)(size_t) glyph_index, glyph );
}
DaoxFont_MakeGlyph( self, glyph_index, glyph );
return glyph;
}
DaoxGlyph* DaoxFont_GetCharGlyph( DaoxFont *self, wchar_t ch )
{
DNode *node = DMap_Find( self->glyphs2, (void*)(size_t) ch );
DaoxGlyph *glyph = node ? (DaoxGlyph*) node->value.pVoid : NULL;
if( glyph && glyph->shape->mesh->triangles->size ) return glyph;
glyph = DaoxFont_GetGlyph( self, DaoxFont_FindGlyphIndex( self, ch ) );
if( glyph == NULL ) return NULL;
glyph->codepoint = ch;
if( node == NULL ) DMap_Insert( self->glyphs2, (void*)(size_t) ch, glyph );
return glyph;
}
DaoxGlyph* DaoxGlyph_New()
{
DaoxGlyph *self = (DaoxGlyph*) calloc(1,sizeof(DaoxGlyph));
DaoCstruct_Init( (DaoCstruct*)self, daox_type_glyph );
self->codepoint = 0;
self->shape = DaoxPath_New();
DaoGC_IncRC( (DaoValue*) self->shape );
return self;
}
void DaoxGlyph_Delete( DaoxGlyph *self )
{
DaoCstruct_Free( (DaoCstruct*) self );
DaoGC_DecRC( (DaoValue*) self->shape );
free( self );
}
static void FONT_New( DaoProcess *proc, DaoValue *p[], int N )
{
DaoxFont *self = DaoxFont_New();
DaoProcess_PutValue( proc, (DaoValue*) self );
if( N ) DaoxFont_Open( self, DaoValue_TryGetMBString( p[0] ) );
}
static void FONT_Open( DaoProcess *proc, DaoValue *p[], int N )
{
DaoxFont *self = (DaoxFont*) p[0];
DaoProcess_PutInteger( proc, DaoxFont_Open( self, DaoValue_TryGetMBString( p[1] ) ) );
}
static DaoFuncItem DaoxFontMeths[]=
{
{ FONT_New, "Font( file = '' )" },
{ FONT_Open, "Open( self : Font, file : string ) => int" },
{ NULL, NULL }
};
DaoTypeBase DaoxFont_Typer =
{
"Font", NULL, NULL, (DaoFuncItem*) DaoxFontMeths, { NULL }, { NULL },
(FuncPtrDel)DaoxFont_Delete, NULL
};
static DaoFuncItem DaoxGlyphMeths[]=
{
{ NULL, NULL }
};
DaoTypeBase DaoxGlyph_Typer =
{
"Glyph", NULL, NULL, (DaoFuncItem*) DaoxGlyphMeths, { NULL }, { NULL },
(FuncPtrDel)DaoxGlyph_Delete, NULL
};
DaoType* daox_type_font = NULL;
DaoType* daox_type_glyph = NULL;
DAO_DLL int DaoFont_OnLoad( DaoVmSpace *vmSpace, DaoNamespace *ns )
{
daox_type_font = DaoNamespace_WrapType( ns, & DaoxFont_Typer, 0 );
daox_type_glyph = DaoNamespace_WrapType( ns, & DaoxGlyph_Typer, 0 );
return 0;
}
| 31.214035 | 113 | 0.651135 |
a528fee0f155f94e4ff3d3a9bcb9ed32c7643548 | 1,587 | h | C | src/memory/memory_pool.h | aparesse/Lightswing | 0d28c9996c13f2e9928d84451352cf5ff4ec8133 | [
"MIT"
] | null | null | null | src/memory/memory_pool.h | aparesse/Lightswing | 0d28c9996c13f2e9928d84451352cf5ff4ec8133 | [
"MIT"
] | null | null | null | src/memory/memory_pool.h | aparesse/Lightswing | 0d28c9996c13f2e9928d84451352cf5ff4ec8133 | [
"MIT"
] | null | null | null | // Copyright (C)
//
// 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 GeneratorExiteral Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., Free Road, Shanghai 000000, China.
//
/// @file memory_pool.h
/// @synopsis
/// @author Lan Jian, air.petrichor@gmail.com
/// @version v0.0.1
/// @date 2017-06-17
#ifndef MEMORY_POOL_H
#define MEMORY_POOL_H
#include <cstddef>
#include <vector>
#include <list>
#include "central.h"
#include "cache.h"
namespace lightswing
{
class memorypool
{
typedef char* pointer;
typedef std::list<pointer> pointerlist;
public:
static memorypool* instance();
public:
memorypool();
void init(std::size_t size);
void* allocate(std::size_t size);
void deallocate(void* addr, std::size_t len);
private:
void* ajust(std::size_t n);
std::size_t free_size() const;
memorypool& operator=(const memorypool&) = delete;
memorypool(const memorypool&) = delete;
private:
std::vector<central> centrals_;
std::vector<cache> caches_;
};
}
#endif // MEMORY_POOL_H
| 25.190476 | 78 | 0.710775 |
9d91a2ed2bd0ffbae80bb818b5ecc093f12f6614 | 927 | c | C | c/media3.c | Ellian-aragao/URI | e53b9380c5be0e59fdd002553ea33a04a7c35439 | [
"Unlicense"
] | null | null | null | c/media3.c | Ellian-aragao/URI | e53b9380c5be0e59fdd002553ea33a04a7c35439 | [
"Unlicense"
] | null | null | null | c/media3.c | Ellian-aragao/URI | e53b9380c5be0e59fdd002553ea33a04a7c35439 | [
"Unlicense"
] | null | null | null | #include <stdio.h>
int main()
{
float notas[] = {2, 3, 4, 1};
float media = 0;
for (int i = 0; i < 4; i++)
{
float aux;
scanf("%f", &aux);
notas[i] *= aux;
media += notas[i];
}
media /= 10.0;
if (media < 5.0)
{
printf("Media: %.1f\n", media);
printf("Aluno reprovado.\n");
}
else if (media >= 7.0)
{
printf("Media: %.1f\n", media);
printf("Aluno aprovado.\n");
}
else
{
float aux;
scanf("%f", &aux);
printf("Media: %.1f\n", media);
printf("Aluno em exame.\n");
printf("Nota do exame: %.1f\n", aux);
media = (media + aux) / 2.0;
if (media >= 5)
{
printf("Aluno aprovado.\n");
}
else
{
printf("Aluno reprovado.\n");
}
printf("Media final: %.1f\n", media);
}
return 0;
} | 19.723404 | 45 | 0.413161 |
77f9e1abdfafa5f17ed94956c48b664f847aab2f | 109 | c | C | caribbean/1237.c | aldriguz/competitive-programming | a0a129c80d6c06ce3056c873511cce65602567db | [
"MIT"
] | null | null | null | caribbean/1237.c | aldriguz/competitive-programming | a0a129c80d6c06ce3056c873511cce65602567db | [
"MIT"
] | 1 | 2020-03-31T01:33:22.000Z | 2020-04-04T20:59:40.000Z | caribbean/1237.c | aldriguz/competitive-programming | a0a129c80d6c06ce3056c873511cce65602567db | [
"MIT"
] | null | null | null | #include<stdio.h>
main(){int a,b;while(1){scanf("%d %d",&a,&b);if(a==0&&b==0)break;printf("%d\n",(a+a)-b);}}
| 36.333333 | 90 | 0.541284 |
c4cb68800c7115775fc35844ddb7cb0d6e451e04 | 1,904 | c | C | locitest/src/test_list_limits.c | floodlight/loxigen-artifacts | 1822ec984cb6da342bbaa381677071cbbe53cee6 | [
"Apache-2.0"
] | 1 | 2017-06-01T09:41:07.000Z | 2017-06-01T09:41:07.000Z | ofagent/indigo/submodules/loxigen-artifacts/locitest/src/test_list_limits.c | lanpinguo/apple-sauce | b16e7b78e58d0d17ad7f05476f38704a6b519ece | [
"Apache-2.0"
] | 2 | 2017-07-03T08:50:56.000Z | 2018-03-12T16:16:19.000Z | locitest/src/test_list_limits.c | floodlight/loxigen-artifacts | 1822ec984cb6da342bbaa381677071cbbe53cee6 | [
"Apache-2.0"
] | 20 | 2015-02-16T15:23:04.000Z | 2022-03-15T20:06:10.000Z | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University */
/* Copyright (c) 2011, 2012 Open Networking Foundation */
/* Copyright (c) 2012, 2013 Big Switch Networks, Inc. */
/* See the file LICENSE.loci which should have been included in the source distribution */
/**
* Test that list append fails gracefully when running out of wire buffer
* space.
*/
#include <locitest/test_common.h>
static int
test_list_limits(void)
{
of_flow_stats_reply_t *obj = of_flow_stats_reply_new(OF_VERSION_1_0);
of_list_flow_stats_entry_t list;
of_flow_stats_entry_t *element = of_flow_stats_entry_new(OF_VERSION_1_0);
int i = 0;
of_flow_stats_reply_entries_bind(obj, &list);
LOCI_ASSERT(element != NULL);
while (1) {
int rv = of_list_flow_stats_entry_append(&list, element);
LOCI_ASSERT(rv == OF_ERROR_NONE || rv == OF_ERROR_RESOURCE);
if (rv != OF_ERROR_NONE) {
break;
}
i++;
}
LOCI_ASSERT(i == 744);
of_flow_stats_entry_delete(element);
of_flow_stats_reply_delete(obj);
return TEST_PASS;
}
static int
test_list_limits_bind(void)
{
of_flow_stats_reply_t *obj = of_flow_stats_reply_new(OF_VERSION_1_0);
of_list_flow_stats_entry_t list;
int i = 0;
of_flow_stats_reply_entries_bind(obj, &list);
while (1) {
of_flow_stats_entry_t element;
int rv;
of_flow_stats_entry_init(&element, OF_VERSION_1_0, -1, 1);
rv = of_list_flow_stats_entry_append_bind(&list, &element);
LOCI_ASSERT(rv == OF_ERROR_NONE || rv == OF_ERROR_RESOURCE);
if (rv != OF_ERROR_NONE) {
break;
}
i++;
}
LOCI_ASSERT(i == 744);
of_flow_stats_reply_delete(obj);
return TEST_PASS;
}
int
run_list_limits_tests(void)
{
RUN_TEST(list_limits);
RUN_TEST(list_limits_bind);
return TEST_PASS;
}
| 24.727273 | 90 | 0.677521 |
85e480e87c692cc049f386dbe0372f895f9f28e7 | 647 | h | C | vmm/src/roms/ipxe/src/include/ipxe/asn1.h | rssys/snowboard | 7935438a5ee72e922e7077bcf70a9c43e4368fd7 | [
"Apache-2.0"
] | 6 | 2021-11-03T06:43:52.000Z | 2022-02-13T22:54:02.000Z | vmm/src/roms/ipxe/src/include/ipxe/asn1.h | rssys/snowboard | 7935438a5ee72e922e7077bcf70a9c43e4368fd7 | [
"Apache-2.0"
] | null | null | null | vmm/src/roms/ipxe/src/include/ipxe/asn1.h | rssys/snowboard | 7935438a5ee72e922e7077bcf70a9c43e4368fd7 | [
"Apache-2.0"
] | 1 | 2021-11-23T02:02:05.000Z | 2021-11-23T02:02:05.000Z | #ifndef _IPXE_ASN1_H
#define _IPXE_ASN1_H
/** @file
*
* ASN.1 encoding
*
*/
FILE_LICENCE ( GPL2_OR_LATER );
#define ASN1_INTEGER 0x02
#define ASN1_BIT_STRING 0x03
#define ASN1_OCTET_STRING 0x04
#define ASN1_NULL 0x05
#define ASN1_OID 0x06
#define ASN1_SEQUENCE 0x30
#define ASN1_IP_ADDRESS 0x40
#define ASN1_EXPLICIT_TAG 0xa0
/**
* A DER-encoded ASN.1 object cursor
*/
struct asn1_cursor {
/** Start of data */
void *data;
/** Length of data */
size_t len;
};
extern int asn1_enter ( struct asn1_cursor *cursor, unsigned int type );
extern int asn1_skip ( struct asn1_cursor *cursor, unsigned int type );
#endif /* _IPXE_ASN1_H */
| 18.485714 | 72 | 0.737249 |
e27100d3fb49a9cc468e9f2a14cf030e7947b0ca | 5,319 | h | C | drivers/hal/beken/beken72XX_HAL/driver/ble/beken_ble_sdk/mesh/include/m_lay_friend.h | flyghost/OneOS-V2.1.0 | 6fedab0558c07fe679d63ba1eb8ee9992c044d86 | [
"Apache-2.0"
] | 4 | 2020-02-29T08:45:14.000Z | 2021-01-13T12:31:58.000Z | drivers/hal/beken/beken72XX_HAL/driver/ble/beken_ble_sdk/mesh/include/m_lay_friend.h | flyghost/OneOS-V2.1.0 | 6fedab0558c07fe679d63ba1eb8ee9992c044d86 | [
"Apache-2.0"
] | null | null | null | drivers/hal/beken/beken72XX_HAL/driver/ble/beken_ble_sdk/mesh/include/m_lay_friend.h | flyghost/OneOS-V2.1.0 | 6fedab0558c07fe679d63ba1eb8ee9992c044d86 | [
"Apache-2.0"
] | 8 | 2020-02-29T08:45:31.000Z | 2021-06-01T06:18:45.000Z | /**
****************************************************************************************
* @file m_lay_friend.h
*
* @brief Header file for Mesh Friend Features Defines
*
* Copyright (C) RivieraWaves 2017-2019
*
****************************************************************************************
*/
#ifndef _M_LAY_FRIEND_H_
#define _M_LAY_FRIEND_H_
/**
****************************************************************************************
* @defgroup M_FRIEND Mesh Friend Features Defines
* @ingroup MESH
* @brief Mesh Friend Features Defines
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "m_lay_int.h" // Mesh layer internals
/*
* DEFINES
****************************************************************************************
*/
/// Length of Friend Request message
#define M_FRIEND_MSG_REQ_LEN (10)
/// Length of Friend Offer message
#define M_FRIEND_MSG_OFFER_LEN (6)
/// Length of Friend Poll message
#define M_FRIEND_MSG_POLL_LEN (1)
/// Length of Friend Update message
#define M_FRIEND_MSG_UPDATE_LEN (6)
/// Length of Friend Clear message
#define M_FRIEND_MSG_CLEAR_LEN (4)
/// Length of Friend Clear Confirm message
#define M_FRIEND_MSG_CLEAR_CFM_LEN (4)
/// Minimal length of Friend Subscription List Add message
#define M_FRIEND_MSG_SUBS_LIST_ADD_LEN (3)
/// Minimal length of Friend Subscription List Remove message
#define M_FRIEND_MSG_SUBS_LIST_REM_LEN (3)
/// Length of Friend Request message
#define M_FRIEND_MSG_SUBS_LIST_CFM_LEN (1)
/// Format of Friend Request message
#define M_FRIEND_MSG_REQ_FORMAT (">BBDHBH")
/// Length of Friend Offer message
#define M_FRIEND_MSG_OFFER_FORMAT (">BBBBH")
/// Length of Friend Poll message
#define M_FRIEND_MSG_POLL_FORMAT (">B")
/// Length of Friend Update message
#define M_FRIEND_MSG_UPDATE_FORMAT (">BLB")
/// Length of Friend Clear message
#define M_FRIEND_MSG_CLEAR_FORMAT (">HH")
/// Length of Friend Clear Confirm message
#define M_FRIEND_MSG_CLEAR_CFM_FORMAT (">HH")
/// Length of Friend Request message
#define M_FRIEND_MSG_SUBS_LIST_CFM_FORMAT (">B")
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/// Friend Request message content
typedef struct m_friend_req
{
/// Criteria (@see enum m_friend_criteria)
uint8_t criteria;
/// Receive Delay
uint8_t rx_delay;
/// Poll Timeout
uint32_t poll_timeout;
/// Previous Address
uint16_t prev_addr;
/// Number of elements
uint8_t nb_elem;
/// LPN Counter
uint16_t lpn_cnt;
} m_friend_req_t;
/// Friend Offer message content
typedef struct m_friend_offer
{
/// Receive Window
uint8_t rx_window;
/// Queue size
uint8_t queue_size;
/// Subscription list size
uint8_t subs_list_size;
/// RSSI
int8_t rssi;
/// Friend Counter
uint16_t friend_cnt;
} m_friend_offer_t;
/// Friend Poll message content
typedef struct m_friend_poll
{
/// FSN (@see enum m_friend_fsn)
uint8_t fsn;
} m_friend_poll_t;
/// Friend Update message content
typedef struct m_friend_upd
{
/// Flags
uint8_t flags;
/// IV index
uint32_t iv_index;
/// More Data (@see enum m_friend_md)
uint8_t md;
} m_friend_upd_t;
/// Friend Clear message content
typedef struct m_friend_clear
{
/// LPN Address
uint16_t lpn_addr;
/// LPN Counter
uint16_t lpn_cnt;
} m_friend_clear_t;
/// Friend Clear Confirm message content
typedef struct m_friend_clear_cfm
{
/// LPN Address
uint16_t lpn_addr;
/// LPN Counter
uint16_t lpn_cnt;
} m_friend_clear_cfm_t;
/// Friend Subscription List Add message content
typedef struct m_friend_subs_list_add
{
/// Transaction Number
uint8_t transac_nb;
/// List of group addresses and virtual addresses
uint16_t list[__ARRAY_EMPTY];
} m_friend_subs_list_add_t;
/// Friend Subscription List Remove message content
typedef struct m_friend_subs_list_rem
{
/// Transaction Number
uint8_t transac_nb;
/// List of group addresses and virtual addresses
uint16_t list[__ARRAY_EMPTY];
} m_friend_subs_list_rem_t;
/// Friend Subscription List Confirm message content
typedef struct m_friend_subs_list_cfm
{
/// Transaction Number
uint8_t transac_nb;
} m_friend_subs_list_cfm_t;
/// Friend message definition
union m_friend_msg
{
/// Friend Request
m_friend_req_t req;
/// Friend Offer
m_friend_offer_t offer;
/// Friend Poll
m_friend_poll_t poll;
/// Friend Update
m_friend_upd_t upd;
/// Friend Clear
m_friend_clear_t clear;
/// Friend Clear Confirm
m_friend_clear_cfm_t clear_cfm;
/// Friend Subscription List Add
m_friend_subs_list_add_t subs_list_add;
/// Friend Subscription List Remove
m_friend_subs_list_rem_t subs_list_rem;
/// Friend Subscription List Confirm
m_friend_subs_list_cfm_t subs_list_cfm;
};
/// @} end of group
#endif //_M_LAY_FRIEND_H_
| 27.417526 | 89 | 0.611769 |
12f809de4f3bd36f204ba16229fc0051ac217fca | 2,432 | c | C | source/bonus/render_cub/background_gradient_b.c | paulahemsi/cub3d | b8d8f6107715cf92a6f6d3985ce58aca3827b43e | [
"MIT"
] | 18 | 2021-04-24T23:36:34.000Z | 2022-03-01T04:37:32.000Z | source/bonus/render_cub/background_gradient_b.c | paulahemsi/cub3d | b8d8f6107715cf92a6f6d3985ce58aca3827b43e | [
"MIT"
] | null | null | null | source/bonus/render_cub/background_gradient_b.c | paulahemsi/cub3d | b8d8f6107715cf92a6f6d3985ce58aca3827b43e | [
"MIT"
] | 2 | 2021-05-14T17:53:25.000Z | 2022-02-09T09:52:24.000Z | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* background_gradient_b.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: phemsi-a <phemsi-a@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/04/24 15:20:05 by phemsi-a #+# #+# */
/* Updated: 2021/05/07 02:27:27 by phemsi-a ### ########.fr */
/* */
/* ************************************************************************** */
#include "../../../includes/bonus/cub.h"
void activate_gradient(t_rgb *color, t_rgb *opposite_surface,
t_gradient *gradient)
{
if (gradient->increment.red > 0)
{
if (color->red < opposite_surface->red)
color->red += gradient->increment.red;
}
else
if (color->red > opposite_surface->red)
color->red += gradient->increment.red;
if (gradient->increment.green > 0)
{
if (color->green < opposite_surface->green)
color->green += gradient->increment.green;
}
else
if (color->green > opposite_surface->green)
color->green += gradient->increment.green;
if (gradient->increment.blue > 0)
{
if (color->blue < opposite_surface->blue)
color->blue += gradient->increment.blue;
}
else
if (color->blue > opposite_surface->blue)
color->blue += gradient->increment.blue;
}
void define_gradient(t_rgb *ceil, t_rgb *floor, t_gradient *gradient)
{
gradient->increment.red = 1;
gradient->increment.green = 1;
gradient->increment.blue = 1;
gradient->color_distance.red = ceil->red - floor->red;
if (gradient->color_distance.red > 0)
gradient->increment.red *= TOGGLE;
gradient->color_distance.green = ceil->green - floor->green;
if (gradient->color_distance.green > 0)
gradient->increment.green *= TOGGLE;
gradient->color_distance.blue = ceil->blue - floor->blue;
if (gradient->color_distance.blue > 0)
gradient->increment.blue *= TOGGLE;
}
void toggle_increment(t_gradient *gradient)
{
gradient->increment.red *= TOGGLE;
gradient->increment.green *= TOGGLE;
gradient->increment.blue *= TOGGLE;
}
| 36.848485 | 80 | 0.492599 |
ac962861c9f7cee68bcf6111095302ad4b770334 | 5,006 | h | C | Win32.Carberp/all source/BJWJ/include/plugin/nsIFileUtilities.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/plugin/nsIFileUtilities.h | 010001111/Vx-Suites | 6b4b90a60512cce48aa7b87aec5e5ac1c4bb9a79 | [
"MIT"
] | null | null | null | Win32.Carberp/all source/BlackJoeWhiteJoe/include/plugin/nsIFileUtilities.h | 010001111/Vx-Suites | 6b4b90a60512cce48aa7b87aec5e5ac1c4bb9a79 | [
"MIT"
] | null | null | null | /*
* DO NOT EDIT. THIS FILE IS GENERATED FROM e:/builds/moz2_slave/mozilla-1.9.1-win32-xulrunner/build/modules/plugin/base/public/nsIFileUtilities.idl
*/
#ifndef __gen_nsIFileUtilities_h__
#define __gen_nsIFileUtilities_h__
#ifndef __gen_nsISupports_h__
#include "nsISupports.h"
#endif
#ifndef __gen_nspluginroot_h__
#include "nspluginroot.h"
#endif
/* For IDL files that don't want to include root IDL files. */
#ifndef NS_NO_VTABLE
#define NS_NO_VTABLE
#endif
#include "nsplugindefs.h"
/* starting interface: nsIFileUtilities */
#define NS_IFILEUTILITIES_IID_STR "89a31ce0-019a-11d2-815b-006008119d7a"
#define NS_IFILEUTILITIES_IID \
{0x89a31ce0, 0x019a, 0x11d2, \
{ 0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a }}
/**
* The nsIFileUtilities interface provides access to random file operations.
* To obtain: QueryInterface on nsIPluginManager.
*/
class NS_NO_VTABLE nsIFileUtilities : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IFILEUTILITIES_IID)
/**
* Returns the name of the browser executable program.
*
* @param aProgramPath - the returned path to the program
* @result - NS_OK if this operation was successful
*/
/* void getProgramPath (out constCharPtr aProgramPath); */
NS_IMETHOD GetProgramPath(const char * *aProgramPath NS_OUTPARAM) = 0;
/**
* Returns the name of the temporary directory.
*
* @param aTempDirPath - the returned path to the temp directory
* @result - NS_OK if this operation was successful
*/
/* void getTempDirPath (out constCharPtr aTempDirPath); */
NS_IMETHOD GetTempDirPath(const char * *aTempDirPath NS_OUTPARAM) = 0;
/**
* Returns a unique temporary file name.
*
* @param aPrefix - a string to prefix to the temporary file name
* @param aLength - the length of the resulting buffer to receive the data
* @param aBuffer - the returned temp file name
* @result - NS_OK if this operation was successful
*/
/* void newTempFileName (in string aPrefix, in unsigned long aLength, in charPtr aBuffer); */
NS_IMETHOD NewTempFileName(const char *aPrefix, PRUint32 aLength, char * aBuffer) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIFileUtilities, NS_IFILEUTILITIES_IID)
/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_NSIFILEUTILITIES \
NS_IMETHOD GetProgramPath(const char * *aProgramPath NS_OUTPARAM); \
NS_IMETHOD GetTempDirPath(const char * *aTempDirPath NS_OUTPARAM); \
NS_IMETHOD NewTempFileName(const char *aPrefix, PRUint32 aLength, char * aBuffer);
/* Use this macro to declare functions that forward the behavior of this interface to another object. */
#define NS_FORWARD_NSIFILEUTILITIES(_to) \
NS_IMETHOD GetProgramPath(const char * *aProgramPath NS_OUTPARAM) { return _to GetProgramPath(aProgramPath); } \
NS_IMETHOD GetTempDirPath(const char * *aTempDirPath NS_OUTPARAM) { return _to GetTempDirPath(aTempDirPath); } \
NS_IMETHOD NewTempFileName(const char *aPrefix, PRUint32 aLength, char * aBuffer) { return _to NewTempFileName(aPrefix, aLength, aBuffer); }
/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
#define NS_FORWARD_SAFE_NSIFILEUTILITIES(_to) \
NS_IMETHOD GetProgramPath(const char * *aProgramPath NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetProgramPath(aProgramPath); } \
NS_IMETHOD GetTempDirPath(const char * *aTempDirPath NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetTempDirPath(aTempDirPath); } \
NS_IMETHOD NewTempFileName(const char *aPrefix, PRUint32 aLength, char * aBuffer) { return !_to ? NS_ERROR_NULL_POINTER : _to->NewTempFileName(aPrefix, aLength, aBuffer); }
#if 0
/* Use the code below as a template for the implementation class for this interface. */
/* Header file */
class nsFileUtilities : public nsIFileUtilities
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIFILEUTILITIES
nsFileUtilities();
private:
~nsFileUtilities();
protected:
/* additional members */
};
/* Implementation file */
NS_IMPL_ISUPPORTS1(nsFileUtilities, nsIFileUtilities)
nsFileUtilities::nsFileUtilities()
{
/* member initializers and constructor code */
}
nsFileUtilities::~nsFileUtilities()
{
/* destructor code */
}
/* void getProgramPath (out constCharPtr aProgramPath); */
NS_IMETHODIMP nsFileUtilities::GetProgramPath(const char * *aProgramPath NS_OUTPARAM)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void getTempDirPath (out constCharPtr aTempDirPath); */
NS_IMETHODIMP nsFileUtilities::GetTempDirPath(const char * *aTempDirPath NS_OUTPARAM)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void newTempFileName (in string aPrefix, in unsigned long aLength, in charPtr aBuffer); */
NS_IMETHODIMP nsFileUtilities::NewTempFileName(const char *aPrefix, PRUint32 aLength, char * aBuffer)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* End of implementation class template. */
#endif
#endif /* __gen_nsIFileUtilities_h__ */
| 34.524138 | 175 | 0.757491 |
b19eb27ad4bf3ae4c6566ec6deebe490ffddd0b2 | 803 | h | C | Development/External/wxWindows_2.4.0/include/wx/xrc/xh_dlg.h | addstone/unrealengine3 | 4579d360dfd52b12493292120b27bb430f978fc8 | [
"FSFAP"
] | 37 | 2020-05-22T18:18:47.000Z | 2022-03-19T06:51:54.000Z | Development/External/wxWindows_2.4.0/include/wx/xrc/xh_dlg.h | AdanosGotoman/unrealengine3 | 4579d360dfd52b12493292120b27bb430f978fc8 | [
"FSFAP"
] | null | null | null | Development/External/wxWindows_2.4.0/include/wx/xrc/xh_dlg.h | AdanosGotoman/unrealengine3 | 4579d360dfd52b12493292120b27bb430f978fc8 | [
"FSFAP"
] | 27 | 2020-05-17T01:03:30.000Z | 2022-03-06T19:10:14.000Z | /////////////////////////////////////////////////////////////////////////////
// Name: xh_dlg.h
// Purpose: XML resource handler for dialogs
// Author: Vaclav Slavik
// Created: 2000/03/05
// RCS-ID: $Id: xh_dlg.h,v 1.2 2002/09/07 12:10:21 GD Exp $
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_XH_DLG_H_
#define _WX_XH_DLG_H_
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "xh_dlg.h"
#endif
#include "wx/xrc/xmlres.h"
class WXXMLDLLEXPORT wxDialogXmlHandler : public wxXmlResourceHandler
{
public:
wxDialogXmlHandler();
virtual wxObject *DoCreateResource();
virtual bool CanHandle(wxXmlNode *node);
};
#endif // _WX_XH_DLG_H_
| 26.766667 | 77 | 0.560399 |
0e7162f5633fc37e4786364c797b49ce6dadbf4e | 1,018 | c | C | asm_msp430x.c | vekkt0r/radare2-msp430x | 450875ed744d5a7a3d0281100104c12258064cec | [
"MIT"
] | null | null | null | asm_msp430x.c | vekkt0r/radare2-msp430x | 450875ed744d5a7a3d0281100104c12258064cec | [
"MIT"
] | null | null | null | asm_msp430x.c | vekkt0r/radare2-msp430x | 450875ed744d5a7a3d0281100104c12258064cec | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <string.h>
//#include <r_types.h>
#include <r_lib.h>
#include <r_asm.h>
#include "msp430x_disas.h"
static int disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
int ret;
struct msp430_cmd cmd = {0};
ret = msp430x_decode_command (buf, &cmd);
if (ret > 0) {
if (cmd.prefix[0]) {
snprintf (op->buf_asm, R_ASM_BUFSIZE, "%s %s %s", cmd.prefix,
cmd.instr, cmd.operands);
} else if (cmd.operands[0]) {
snprintf (op->buf_asm, R_ASM_BUFSIZE, "%s %s", cmd.instr,
cmd.operands);
} else {
snprintf (op->buf_asm, R_ASM_BUFSIZE, "%s", cmd.instr);
}
}
op->size = ret;
return ret;
}
RAsmPlugin r_asm_plugin_msp430x = {
.name = "msp430x",
.license = "MIT",
.desc = "msp430x disassembly plugin",
.arch = "msp430x",
.bits = 16,
.init = NULL,
.fini = NULL,
.disassemble = &disassemble,
.modify = NULL,
.assemble = NULL,
};
#ifndef CORELIB
struct r_lib_struct_t radare_plugin = {
.type = R_LIB_TYPE_ASM,
.data = &r_asm_plugin_msp430x,
};
#endif
| 19.960784 | 71 | 0.642436 |
d9cf0971d773349d8f783a26c9040bf41948f849 | 219 | h | C | Example/Pods/Headers/Public/YanFirstCommonKit/WQMD5.h | yuhe1989/YanFirstCommonKit | f2cc27611ea59abe4c49b4bc2d5b68c74200ac54 | [
"MIT"
] | null | null | null | Example/Pods/Headers/Public/YanFirstCommonKit/WQMD5.h | yuhe1989/YanFirstCommonKit | f2cc27611ea59abe4c49b4bc2d5b68c74200ac54 | [
"MIT"
] | null | null | null | Example/Pods/Headers/Public/YanFirstCommonKit/WQMD5.h | yuhe1989/YanFirstCommonKit | f2cc27611ea59abe4c49b4bc2d5b68c74200ac54 | [
"MIT"
] | null | null | null | //
// WQMD5.h
// MAF
//
// Created by victor on 14-4-15.
// Copyright (c) 2014年 ctnq. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface WQMD5 : NSObject
+(NSString *)md5:(NSString *)str;
@end
| 13.6875 | 50 | 0.643836 |
3d4022bd60aaea153e64f95e95f984b9901e3dd8 | 251 | c | C | solved/C++/selection_test_1035.c | Ahmad-Fahad/URI | 8b649e757f60aa5ae3c918f1361b3a642894503b | [
"Apache-2.0"
] | null | null | null | solved/C++/selection_test_1035.c | Ahmad-Fahad/URI | 8b649e757f60aa5ae3c918f1361b3a642894503b | [
"Apache-2.0"
] | null | null | null | solved/C++/selection_test_1035.c | Ahmad-Fahad/URI | 8b649e757f60aa5ae3c918f1361b3a642894503b | [
"Apache-2.0"
] | null | null | null | #include<stdio.h>
int main(){
int a=0,b=0,c=0,d=0;
scanf("%d %d %d %d",&a,&b,&c,&d);
if(b>c && d>a && c+d>a+b && c>0 && d>0 && a%2==0){
printf("Valores aceitos\n");
}
else{
printf("Valores nao aceitos\n");
}
}
| 19.307692 | 54 | 0.438247 |
0e52fa6039d8f8462e4e22c84dced1bab1350a9b | 1,128 | h | C | UnderstandingCpp11/src/compatibility.h | elloop/algorithm | 5485be0aedbc18968f775cff9533a2d444dbdcb5 | [
"MIT"
] | 15 | 2015-11-04T12:53:23.000Z | 2021-08-10T09:53:12.000Z | UnderstandingCpp11/src/compatibility.h | elloop/algorithm | 5485be0aedbc18968f775cff9533a2d444dbdcb5 | [
"MIT"
] | null | null | null | UnderstandingCpp11/src/compatibility.h | elloop/algorithm | 5485be0aedbc18968f775cff9533a2d444dbdcb5 | [
"MIT"
] | 6 | 2015-11-13T10:17:01.000Z | 2020-05-14T07:25:48.000Z | #ifdef _MSC_VER
#pragma once
#else
_Pragma("once")
#endif // _MSC_VER
#include "inc.h"
#include "messi.h"
NS_ELLOOP_BEGIN
#ifdef _MSC_VER
#if __cplusplus < 201103L
#endif
#else
#if __cplusplus < 201103L
#error "should use c++11 complier."
#endif
#endif// _MSC_VER
static_assert(sizeof(int) == 4, "sizeof int should be 4 bytes.");
template <typename T> class Printer;
class Compatibility : public Messi {
public:
// using BaseTest::BaseTest(10);
Compatibility * run() final override;
private:
// local init.
int i_ = 0;
float f_{ 1.1f };
// new friend grammar.
friend Printer<Compatibility>;
};
// test final keyword.
class Dc : public Compatibility {
public:
// Dc * run() {return this;} // error: run() is final in base-class Compatibility.
};
// total template definition.
template <typename T>
class Printer {
public:
void p(const T & t) {
pcln("in Printer<T>");
}
};
// partial specialization.
template <>
class Printer<Compatibility> {
public:
void p(const Compatibility & t) {
psln(t.i_);
psln(t.f_);
}
};
NS_ELLOOP_END
| 16.588235 | 85 | 0.64539 |
6dfc7febb486f62415c578f1431d417c0dd9e478 | 9,737 | h | C | plugins/gui/src/WindowCollection.h | reinago/megamol | 0438e26e5134a0050a00c6d8d747175a08f85fd9 | [
"BSD-3-Clause"
] | null | null | null | plugins/gui/src/WindowCollection.h | reinago/megamol | 0438e26e5134a0050a00c6d8d747175a08f85fd9 | [
"BSD-3-Clause"
] | null | null | null | plugins/gui/src/WindowCollection.h | reinago/megamol | 0438e26e5134a0050a00c6d8d747175a08f85fd9 | [
"BSD-3-Clause"
] | null | null | null | /*
* WindowCollection.h
*
* Copyright (C) 2019 by Universitaet Stuttgart (VIS).
* Alle Rechte vorbehalten.
*/
#ifndef MEGAMOL_GUI_WINDOWCOLLECTION_INCLUDED
#define MEGAMOL_GUI_WINDOWCOLLECTION_INCLUDED
#include "GUIUtils.h"
namespace megamol {
namespace gui {
/**
* This class controls the placement and appearance of windows tied to one GUIView.
*/
class WindowCollection {
public:
/** Identifiers for the window draw callbacks. */
enum DrawCallbacks {
NONE = 0,
MAIN_PARAMETERS = 1,
PARAMETERS = 2,
PERFORMANCE = 3,
FONT = 4,
TRANSFER_FUNCTION = 5,
CONFIGURATOR = 6
};
/** Performance mode for fps/ms windows. */
enum TimingModes { FPS = 0, MS = 1 };
/** Module filter mode for parameter windows. */
enum FilterModes { ALL = 0, INSTANCE = 1, VIEW = 2 };
/** Struct holding a window configuration. */
struct WindowConfiguration {
std::string win_name; // name of the window
bool win_show; // show/hide window
bool win_store_config; // flag indicates whether consiguration of window should be stored or not
ImGuiWindowFlags win_flags; // imgui window flags
DrawCallbacks win_callback; // ID of the callback drawing the window content
core::view::KeyCode win_hotkey; // hotkey for opening/closing window
ImVec2 win_position; // position for reset on state loading (current position)
ImVec2 win_size; // size for reset on state loading (current size)
bool win_soft_reset; // soft reset of window position and size
ImVec2 win_reset_size; // minimum window size for soft reset
bool win_reset; // flag for reset window position and size on state loading [NOT SAVED]
// ---------- Parameter specific configuration ----------
bool param_show_hotkeys; // flag to toggle showing only parameter hotkeys
std::vector<std::string> param_modules_list; // modules to show in a parameter window (show all if empty)
FilterModes param_module_filter; // module filter
bool param_extended_mode; // Flag toggling between Expert and Basic parameter mode.
// ---------- FPS/MS specific configuration ----------
bool ms_show_options; // show/hide fps/ms options.
int ms_max_history_count; // maximum count of values in value array
float ms_refresh_rate; // maximum delay when fps/ms value should be renewed.
TimingModes ms_mode; // mode for displaying either FPS or MS
float buf_current_delay; // current delay between frames [NOT SAVED]
std::vector<float> buf_values; // current ms values [NOT SAVED]
float buf_plot_ms_scaling; // current ms plot scaling factor [NOT SAVED]
float buf_plot_fps_scaling; // current fps plot scaling factor [NOT SAVED]
// ---------- Font specific configuration ---------
std::string font_name; // font name (only already loaded font names will be restored)
bool buf_font_reset; // flag for reset of font on state loading [NOT SAVED]
std::string buf_font_file; // current font file name [NOT SAVED]
float buf_font_size; // current font size [NOT SAVED]
// ---------- Transfer Function Editor specific configuration ---------
bool tfe_view_minimized; // flag indicating minimized window state
bool tfe_view_vertical; // flag indicating vertical window state
std::string tfe_active_param; // last active parameter connected to editor
bool buf_tfe_reset; // flag for reset of tfe window on state loading [NOT SAVED]
// Ctor for default values
WindowConfiguration(void)
: win_show(false)
, win_store_config(true)
, win_flags(0)
, win_callback(DrawCallbacks::NONE)
, win_hotkey(megamol::core::view::KeyCode())
, win_position(ImVec2(0.0f, 0.0f))
, win_size(ImVec2(0.0f, 0.0f))
, win_soft_reset(true)
, win_reset_size(ImVec2(0.0f, 0.0f))
, win_reset(true)
// Window specific configurations
, param_show_hotkeys(false)
, param_modules_list()
, param_module_filter(FilterModes::ALL)
, param_extended_mode(false)
, ms_show_options(false)
, ms_max_history_count(20)
, ms_refresh_rate(2.0f)
, ms_mode(TimingModes::FPS)
, buf_current_delay(0.0f)
, buf_values()
, buf_plot_ms_scaling(1.0f)
, buf_plot_fps_scaling(1.0f)
, font_name()
, buf_font_reset(false)
, buf_font_file()
, buf_font_size(13.0f)
, tfe_view_minimized(false)
, tfe_view_vertical(false)
, tfe_active_param("")
, buf_tfe_reset(false) {}
};
/** Type for callback function. */
typedef std::function<void(WindowConfiguration& window_config)> GuiCallbackFunc;
// --------------------------------------------------------------------
// WINDOWs
WindowCollection() = default;
~WindowCollection(void) = default;
/**
* Register callback function for given callback id.
*
* @param cbid The callback id.
* @param id The callback function that should be matched to callback id.
*/
inline bool RegisterDrawWindowCallback(DrawCallbacks cbid, GuiCallbackFunc cb) {
// Overwrites existing entry with same WindowDrawCallback id.
this->callbacks[cbid] = cb;
return true;
}
/**
* Draw window content by calling registered callback function in window configuration.
*
* @param window_name The name of the calling window.
*/
inline GuiCallbackFunc WindowCallback(DrawCallbacks cbid) {
// Creates new entry if no callback for cbid is registered (default ctor)
return this->callbacks[cbid];
}
/**
* Reset position and size of currently active window to fit into current viewport.
* Should be triggered via the window configuration flag: soft_reset
* Processes window configuration flag: soft_reset_size
* Should be called between ImGui::Begin() and ImGui::End().
*
* @param window_config The window configuration.
*/
void SoftResetWindowSizePosition(WindowConfiguration& window_config);
/**
* Reset position and size after new state has been loaded.
* Should be triggered via the window configuration flag: state_reset
* Processes window configuration flags: state_position and state_size
* Should be called between ImGui::Begin() and ImGui::End().
*
* @param window_config The window configuration.
*/
void ResetWindowSizePosition(WindowConfiguration& window_config);
// --------------------------------------------------------------------
// CONFIGURATIONs
/**
* Add new window.
*
* @param window_name The window name.
* @param window_config The window configuration.
*/
bool AddWindowConfiguration(WindowConfiguration& window_config);
/**
* Enumerate windows and call given function.
*
* @param cb The function to call for enumerated windows.
*/
inline void EnumWindows(std::function<void(WindowConfiguration&)> cb) {
// Needs fixed size if window is added while looping
auto window_count = this->windows.size();
for (size_t i = 0; i < window_count; i++) {
cb(this->windows[i]);
}
}
/**
* Delete window.
*
* @param window_name The window name.
*/
bool DeleteWindowConfiguration(const std::string& window_name);
// --------------------------------------------------------------------
// STATE
/**
* Deserializes a window configuration state.
* Should be called before(!) ImGui::Begin() because existing window configurations are overwritten.
*
* @param json The string to deserialize from.
*
* @return True on success, false otherwise.
*/
bool StateFromJsonString(const std::string& in_json_string);
/**
* Serializes the current window configurations.
*
* @param json The json to serialize to.
*
* @return True on success, false otherwise.
*/
bool StateToJSON(nlohmann::json& out_json);
private:
/**
* Check if a window configuration for the given window name exists.
*
* @param window_name The window name.
*
* @return True if there is a window configuration for the given name, false otherwise.
*/
inline bool windowConfigurationExists(const std::string& window_name) const {
for (auto& wc : this->windows) {
if (wc.win_name == window_name) return true;
}
return false;
}
// VARIABLES ------------------------------------------------------
/** The list of the window names and their configurations. */
std::map<DrawCallbacks, GuiCallbackFunc> callbacks;
/** The list of the window names and their configurations. */
std::vector<WindowConfiguration> windows;
};
} // namespace gui
} // namespace megamol
#endif // MEGAMOL_GUI_WINDOWCOLLECTION_INCLUDED
| 39.262097 | 113 | 0.595255 |
ef1314493f471bd152ab6b4798a97a51aa32b769 | 164 | h | C | lib/test/tree_hashing/tree.h | A1Liu/tcc | 441ff516d974faec922a73daa02c074a2f0ec21c | [
"MIT"
] | 11 | 2020-09-04T19:35:38.000Z | 2021-03-28T09:47:17.000Z | lib/test/tree_hashing/tree.h | A1Liu/tcc | 441ff516d974faec922a73daa02c074a2f0ec21c | [
"MIT"
] | 21 | 2020-10-26T16:57:42.000Z | 2021-05-13T11:08:53.000Z | lib/test/tree_hashing/tree.h | A1Liu/tcc | 441ff516d974faec922a73daa02c074a2f0ec21c | [
"MIT"
] | 1 | 2020-11-19T22:56:03.000Z | 2020-11-19T22:56:03.000Z | typedef struct node {
char *word;
struct node *left;
struct node *right;
} NODE;
extern NODE *root;
void insert_node(char *word);
void print_tree(NODE *n);
| 14.909091 | 29 | 0.695122 |
338515ff646368b23526eb58c9d970f6dbc06551 | 893 | h | C | bytra/source/Position.h | ArneWouters/BYTRA | aadd50cff349af45f6b46d695538bfa31b913bbf | [
"MIT"
] | 5 | 2020-10-03T22:12:52.000Z | 2021-12-19T22:53:00.000Z | bytra/source/Position.h | ArneWouters/BYTRA | aadd50cff349af45f6b46d695538bfa31b913bbf | [
"MIT"
] | 3 | 2020-08-25T14:15:56.000Z | 2021-04-01T20:52:36.000Z | bytra/source/Position.h | ArneWouters/BYTRA | aadd50cff349af45f6b46d695538bfa31b913bbf | [
"MIT"
] | 3 | 2020-10-03T22:12:54.000Z | 2021-11-02T05:16:03.000Z | //
// Created by Arne Wouters on 09/08/2020.
//
#ifndef MEXTRA_POSITION_H
#define MEXTRA_POSITION_H
#include <string>
#include "Candle.h"
#include "Order.h"
class Position {
public:
long qty = 0;
double entryPrice = 0;
double stopLossPercentage = 0.03;
double stopLossPrice = 0;
std::shared_ptr<Order> activeOrder;
Position() = default;
[[nodiscard]] bool isShort() const { return qty < 0; }
[[nodiscard]] bool isLong() const { return qty > 0; }
void update(const long &newQty, const double &newPrice) {
qty = newQty;
entryPrice = newPrice;
if (qty == 0) {
return;
} else if (isLong()) {
stopLossPrice = entryPrice - entryPrice * stopLossPercentage;
} else {
stopLossPrice = entryPrice + entryPrice * stopLossPercentage;
}
}
};
#endif // MEXTRA_POSITION_H
| 21.261905 | 73 | 0.608063 |
6fcd7dc1bd6eb56b8448ee1cdc0397b6fd8cce74 | 3,446 | c | C | model_server/driver_aset/src/dialog_set_current_window.c | kit-transue/software-emancipation-discover | bec6f4ef404d72f361d91de954eae9a3bd669ce3 | [
"BSD-2-Clause"
] | 2 | 2015-11-24T03:31:12.000Z | 2015-11-24T16:01:57.000Z | model_server/driver_aset/src/dialog_set_current_window.c | radtek/software-emancipation-discover | bec6f4ef404d72f361d91de954eae9a3bd669ce3 | [
"BSD-2-Clause"
] | null | null | null | model_server/driver_aset/src/dialog_set_current_window.c | radtek/software-emancipation-discover | bec6f4ef404d72f361d91de954eae9a3bd669ce3 | [
"BSD-2-Clause"
] | 1 | 2019-05-19T02:26:08.000Z | 2019-05-19T02:26:08.000Z | /*************************************************************************
* Copyright (c) 2015, Synopsys, Inc. *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions are *
* met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*************************************************************************/
/*
// dialog_set_current_window
//------------------------------------------
// synopsis:
// sets uimx window global
//
// description:
// Method to set the global current_root_window:
// dialog_set_current_window
//------------------------------------------
// $Log: dialog_set_current_window.c $
// Revision 1.3 1994/07/27 12:15:31EDT jethran
// comment is in RCS log
* Revision 1.2.1.2 1994/07/26 23:47:02 jethran
* changed #include uimx to #include X
*
* Revision 1.2.1.1 1992/10/07 20:37:23 smit
* *** empty log message ***
*
* Revision 1.2 92/10/07 20:37:22 smit
* *** empty log message ***
*
* Revision 1.1 92/10/07 18:20:15 smit
* Initial revision
*
* Revision 1.1 92/10/07 17:55:52 smit
* Initial revision
*
* Revision 1.2 92/08/23 17:46:23 builder
* defined Object
*
* Revision 1.1 91/09/01 23:32:41 kws
* Initial revision
*
//------------------------------------------
// Restrictions:
// ...
//------------------------------------------
*/
/* include files */
#include <X11/Xlib.h>
/* global variable declaration */
Window current_root_window;
/*
//------------------------------------------
// dialog_set_current_window
//
// This functions setsup the parent window so InterViews can apply some
// parenting magic
//------------------------------------------
*/
void dialog_set_current_window(win)
void* win;
{
current_root_window = (Window)win;
}
| 38.719101 | 74 | 0.52989 |
6fcf1726ea4a839b019373e489bac45d48798278 | 179 | h | C | Example/ExampleYWProfile/Pods/Target Support Files/YWNamePlaceholder/YWNamePlaceholder-umbrella.h | nsnull0/YWNamePlaceholder | 29ddc537db465e8915f52dfd664f246c8b3954b5 | [
"MIT"
] | 1 | 2017-07-03T12:15:55.000Z | 2017-07-03T12:15:55.000Z | Example/ExampleYWProfile/Pods/Target Support Files/YWNamePlaceholder/YWNamePlaceholder-umbrella.h | nsnull0/YWNamePlaceholder | 29ddc537db465e8915f52dfd664f246c8b3954b5 | [
"MIT"
] | null | null | null | Example/ExampleYWProfile/Pods/Target Support Files/YWNamePlaceholder/YWNamePlaceholder-umbrella.h | nsnull0/YWNamePlaceholder | 29ddc537db465e8915f52dfd664f246c8b3954b5 | [
"MIT"
] | null | null | null | #ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif
FOUNDATION_EXPORT double YWNamePlaceholderVersionNumber;
FOUNDATION_EXPORT const unsigned char YWNamePlaceholderVersionString[];
| 19.888889 | 71 | 0.849162 |
1758222f01fae84ce41c78257d3126aa6dc78aee | 5,344 | c | C | riscv-blink/src/usb-dev.c | david-sawatzke/fomu-workshop | ce8efa7d0515684c0be3c602976c803e78207980 | [
"Apache-2.0"
] | 127 | 2019-08-20T09:45:51.000Z | 2022-02-28T10:04:13.000Z | riscv-blink/src/usb-dev.c | tcal-x/fomu-workshop | 9ffa4bfa46c6fefdea63a7d62bb3be2823aafa5d | [
"Apache-2.0"
] | 452 | 2019-08-19T12:45:52.000Z | 2022-03-28T12:07:40.000Z | riscv-blink/src/usb-dev.c | tcal-x/fomu-workshop | 9ffa4bfa46c6fefdea63a7d62bb3be2823aafa5d | [
"Apache-2.0"
] | 67 | 2019-08-21T18:46:27.000Z | 2022-03-06T22:41:08.000Z | #include <stdint.h>
#include <stddef.h>
#include <string.h>
#include <usb.h>
struct usb_setup_request {
union {
struct {
uint8_t bmRequestType;
uint8_t bRequest;
};
uint16_t wRequestAndType;
};
uint16_t wValue;
uint16_t wIndex;
uint16_t wLength;
};
static const uint8_t usb_device_descriptor[] = {
0x12, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x40,
0x09, 0x12, 0xf0, 0x5b, 0x01, 0x01, 0x01, 0x02,
0x00, 0x01
};
static const uint8_t usb_config_descriptor[] = {
0x09, 0x02, 0x12, 0x00, 0x01, 0x01, 0x01, 0x80,
0x32, 0x09, 0x04, 0x00, 0x00, 0x00, 0xfe, 0x00,
0x00, 0x02
};
static const uint8_t usb_string0_descriptor[] = {
0x04, 0x03, 0x09, 0x04
};
static const uint8_t usb_string1_descriptor[] = {
0x0c, 0x03, 0x46, 0x00, 0x6f, 0x00, 0x6f, 0x00,
0x73, 0x00, 0x6e, 0x00
};
static const uint8_t usb_string2_descriptor[] = {
0x16, 0x03, 0x46, 0x00, 0x6f, 0x00, 0x6d, 0x00,
0x75, 0x00, 0x20, 0x00, 0x42, 0x00, 0x6c, 0x00,
0x69, 0x00, 0x6e, 0x00, 0x6b, 0x00
};
static const uint8_t usb_bos_descriptor[] = {
0x05, 0x0f, 0x1d, 0x00, 0x01, 0x18, 0x10, 0x05,
0x00, 0x38, 0xb6, 0x08, 0x34, 0xa9, 0x09, 0xa0,
0x47, 0x8b, 0xfd, 0xa0, 0x76, 0x88, 0x15, 0xb6,
0x65, 0x00, 0x01, 0x02, 0x01,
};
static const uint8_t usb_ms_compat_id_descriptor[] = {
0x28, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x57, 0x49, 0x4e, 0x55, 0x53, 0x42,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
#define MSFT_VENDOR_CODE '~' // Arbitrary, but should be printable ASCII
static const uint8_t usb_string_microsoft[18] = {
18, 3, 'M','S','F','T','1','0','0', MSFT_VENDOR_CODE,
0, 0, 0, 0, 0, 0, 0, 0,
};
static uint8_t reply_buffer[8];
static uint8_t usb_configuration = 0;
static uint8_t data_buffer[64];
__attribute__((section(".ramtext")))
void usb_setup(const struct usb_setup_request *setup, uint32_t size)
{
const uint8_t *data = NULL;
uint32_t datalen = 0;
uint8_t ep_dir_is_in = setup->bmRequestType >> 7;
(void)size;
switch (setup->wRequestAndType)
{
case 0x0500: // SET_ADDRESS
usb_set_address(setup->wValue);
break;
case 0x0b01: // SET_INTERFACE
break;
case 0x0900: // SET_CONFIGURATION
usb_configuration = setup->wValue;
break;
case 0x0880: // GET_CONFIGURATION
reply_buffer[0] = usb_configuration;
datalen = 1;
data = reply_buffer;
break;
case 0x0080: // GET_STATUS (device)
reply_buffer[0] = 0;
reply_buffer[1] = 0;
datalen = 2;
data = reply_buffer;
break;
case 0x0082: // GET_STATUS (endpoint)
if (setup->wIndex > 0)
{
usb_err_in(0);
return;
}
reply_buffer[0] = 0;
reply_buffer[1] = 0;
data = reply_buffer;
datalen = 2;
break;
case 0x0102: // CLEAR_FEATURE (endpoint)
if (setup->wIndex > 0 || setup->wValue != 0)
{
usb_err_out(0);
return;
}
break;
case 0x0302: // SET_FEATURE (endpoint)
if (setup->wIndex > 0 || setup->wValue != 0)
{
usb_err_out(0);
return;
}
break;
case 0x0680: // GET_DESCRIPTOR
case 0x0681:
#define CASE_VALUE(match, result) case match: data = result; datalen = sizeof(result); break
switch (setup->wValue) {
CASE_VALUE(0x0100, usb_device_descriptor);
CASE_VALUE(0x0200, usb_config_descriptor);
CASE_VALUE(0x0300, usb_string0_descriptor);
CASE_VALUE(0x0301, usb_string1_descriptor);
CASE_VALUE(0x0302, usb_string2_descriptor);
CASE_VALUE(0x03ee, usb_string_microsoft);
CASE_VALUE(0x0f00, usb_bos_descriptor);
default: usb_err_in(0); return;
}
#undef CASE_VALUE
goto send;
case (MSFT_VENDOR_CODE << 8) | 0xC0: // Get Microsoft descriptor
case (MSFT_VENDOR_CODE << 8) | 0xC1:
if (setup->wIndex == 0x0004)
{
// Return WCID descriptor
data = usb_ms_compat_id_descriptor;
datalen = sizeof(usb_ms_compat_id_descriptor);
break;
}
usb_err_in(0);
return;
#ifdef LANDING_PAGE_URL
case (WEBUSB_VENDOR_CODE << 8) | 0xC0: // Get WebUSB descriptor
if (setup->wIndex == 0x0002)
{
if (setup->wValue == 0x0001)
{
data = get_landing_url_descriptor(&datalen);
break;
}
}
usb_err_in(0);
return;
#endif
default:
usb_err_in(0);
return;
}
send:
if (data && datalen) {
if (datalen > setup->wLength)
datalen = setup->wLength;
if (datalen > sizeof(data_buffer))
datalen = sizeof(data_buffer);
memcpy(data_buffer, data, datalen);
usb_send(data_buffer, datalen);
usb_ack_out(0);
}
else {
// Ack the opposite endpoint type
if (ep_dir_is_in)
usb_ack_out(0);
else
usb_ack_in(0);
}
return;
}
| 26.587065 | 100 | 0.580277 |
cbf8a9512bb92ac508ffacfb72e78a4e021bf923 | 1,816 | h | C | firmware/Marlin-2.0.x/Marlin/src/HAL/platforms.h | DDilshani/CO326-project | f136a52206d41a437f9046c78e41923bb6681185 | [
"Apache-2.0"
] | 1 | 2020-11-29T18:04:31.000Z | 2020-11-29T18:04:31.000Z | firmware/Marlin-2.0.x/Marlin/src/HAL/platforms.h | DDilshani/CO326-project | f136a52206d41a437f9046c78e41923bb6681185 | [
"Apache-2.0"
] | 1 | 2020-09-27T14:53:34.000Z | 2020-09-27T14:53:34.000Z | src/HAL/platforms.h | Sundancer78/Marlin-2.0.4_SKR_14_turbo_ender3 | d9dbef52e6fb4e110908a6d09d0af00fc0ac9b20 | [
"MIT"
] | 2 | 2020-10-05T15:08:13.000Z | 2020-10-20T06:21:59.000Z | /**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#ifdef __AVR__
#define HAL_PLATFORM HAL_AVR
#elif defined(ARDUINO_ARCH_SAM)
#define HAL_PLATFORM HAL_DUE
#elif defined(__MK20DX256__)
#define HAL_PLATFORM HAL_TEENSY31_32
#elif defined(__MK64FX512__) || defined(__MK66FX1M0__)
#define HAL_PLATFORM HAL_TEENSY35_36
#elif defined(TARGET_LPC1768)
#define HAL_PLATFORM HAL_LPC1768
#elif defined(__STM32F1__) || defined(TARGET_STM32F1)
#define HAL_PLATFORM HAL_STM32F1
#elif defined(STM32GENERIC) && (defined(STM32F4) || defined(STM32F7))
#define HAL_PLATFORM HAL_STM32_F4_F7
#elif defined(ARDUINO_ARCH_STM32)
#define HAL_PLATFORM HAL_STM32
#elif defined(ARDUINO_ARCH_ESP32)
#define HAL_PLATFORM HAL_ESP32
#elif defined(__PLAT_LINUX__)
#define HAL_PLATFORM HAL_LINUX
#elif defined(__SAMD51__)
#define HAL_PLATFORM HAL_SAMD51
#else
#error "Unsupported Platform!"
#endif
#define XSTR_(M) #M
#define XSTR(M) XSTR_(M)
#define HAL_PATH(PATH, NAME) XSTR(PATH/HAL_PLATFORM/NAME)
| 34.264151 | 79 | 0.770374 |
c4b808dbe72f26c5e6b548389548f929f33ebaa9 | 649 | h | C | Live/Classes/Common/UIColor+Extension.h | chengzongxin/Live | 26fe22d7f591e1c2bfa7f20891e73090077f60b0 | [
"MIT"
] | null | null | null | Live/Classes/Common/UIColor+Extension.h | chengzongxin/Live | 26fe22d7f591e1c2bfa7f20891e73090077f60b0 | [
"MIT"
] | null | null | null | Live/Classes/Common/UIColor+Extension.h | chengzongxin/Live | 26fe22d7f591e1c2bfa7f20891e73090077f60b0 | [
"MIT"
] | null | null | null | //
// UIColor+Extend.h
// Live
//
// Created by Cheng on 2017/5/8.
// Copyright © 2017年 Joe. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ColorModel : NSObject
@property (nonatomic,assign) int R;
@property (nonatomic,assign) int G;
@property (nonatomic,assign) int B;
@property (nonatomic,assign) CGFloat alpha;
@end
@interface UIColor (Extension)
// color = #FFFFFF 或者 0xFFFFFF [UIColor ColorWithHexString:@"#cccccc" withAlpha:1];
+ (UIColor *)ColorWithHexString: (NSString *)color withAlpha:(CGFloat)alpha;
+ (ColorModel *)ColorWithRGBHexString: (NSString *)color withAlpha:(CGFloat)alpha;
+ (UIColor *)randomColor;
@end
| 23.178571 | 84 | 0.72265 |
c4d292e5966a0ba689db9bc3dcf7e39ab5656a98 | 16,771 | h | C | head/contrib/tcpdump/icmp6.h | dplbsd/soc2013 | c134f5e2a5725af122c94005c5b1af3720706ce3 | [
"BSD-2-Clause"
] | null | null | null | head/contrib/tcpdump/icmp6.h | dplbsd/soc2013 | c134f5e2a5725af122c94005c5b1af3720706ce3 | [
"BSD-2-Clause"
] | null | null | null | head/contrib/tcpdump/icmp6.h | dplbsd/soc2013 | c134f5e2a5725af122c94005c5b1af3720706ce3 | [
"BSD-2-Clause"
] | null | null | null | /* @(#) $Header: /tcpdump/master/tcpdump/icmp6.h,v 1.18 2007-08-29 02:31:44 mcr Exp $ (LBL) */
/* NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp */
/* $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project 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 PROJECT 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 PROJECT 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.
*/
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
*
* @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
*/
#ifndef _NETINET_ICMP6_H_
#define _NETINET_ICMP6_H_
struct icmp6_hdr {
u_int8_t icmp6_type; /* type field */
u_int8_t icmp6_code; /* code field */
u_int16_t icmp6_cksum; /* checksum field */
union {
u_int32_t icmp6_un_data32[1]; /* type-specific field */
u_int16_t icmp6_un_data16[2]; /* type-specific field */
u_int8_t icmp6_un_data8[4]; /* type-specific field */
} icmp6_dataun;
};
#define icmp6_data32 icmp6_dataun.icmp6_un_data32
#define icmp6_data16 icmp6_dataun.icmp6_un_data16
#define icmp6_data8 icmp6_dataun.icmp6_un_data8
#define icmp6_pptr icmp6_data32[0] /* parameter prob */
#define icmp6_mtu icmp6_data32[0] /* packet too big */
#define icmp6_id icmp6_data16[0] /* echo request/reply */
#define icmp6_seq icmp6_data16[1] /* echo request/reply */
#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
#define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
#define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
#define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
#define ICMP6_PARAM_PROB 4 /* ip6 header bad */
#define ICMP6_ECHO_REQUEST 128 /* echo service */
#define ICMP6_ECHO_REPLY 129 /* echo reply */
#define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
#define MLD6_LISTENER_QUERY 130 /* multicast listener query */
#define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
#define MLD6_LISTENER_REPORT 131 /* multicast listener report */
#define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
#define MLD6_LISTENER_DONE 132 /* multicast listener done */
#define ND_ROUTER_SOLICIT 133 /* router solicitation */
#define ND_ROUTER_ADVERT 134 /* router advertisement */
#define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
#define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */
#define ND_REDIRECT 137 /* redirect */
#define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
#define ICMP6_WRUREQUEST 139 /* who are you request */
#define ICMP6_WRUREPLY 140 /* who are you reply */
#define ICMP6_FQDN_QUERY 139 /* FQDN query */
#define ICMP6_FQDN_REPLY 140 /* FQDN reply */
#define ICMP6_NI_QUERY 139 /* node information request */
#define ICMP6_NI_REPLY 140 /* node information reply */
#define IND_SOLICIT 141 /* inverse neighbor solicitation */
#define IND_ADVERT 142 /* inverse neighbor advertisement */
#define ICMP6_V2_MEMBERSHIP_REPORT 143 /* v2 membership report */
#define MLDV2_LISTENER_REPORT 143 /* v2 multicast listener report */
#define ICMP6_HADISCOV_REQUEST 144
#define ICMP6_HADISCOV_REPLY 145
#define ICMP6_MOBILEPREFIX_SOLICIT 146
#define ICMP6_MOBILEPREFIX_ADVERT 147
#define MLD6_MTRACE_RESP 200 /* mtrace response(to sender) */
#define MLD6_MTRACE 201 /* mtrace messages */
#define ICMP6_MAXTYPE 201
#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
#define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
#define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
#define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
#define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
#define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
#define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
#define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
#define ICMP6_NI_SUCCESS 0 /* node information successful reply */
#define ICMP6_NI_REFUSED 1 /* node information request is refused */
#define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
#define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
#define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
/* Used in kernel only */
#define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
#define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
/*
* Multicast Listener Discovery
*/
struct mld6_hdr {
struct icmp6_hdr mld6_hdr;
struct in6_addr mld6_addr; /* multicast address */
};
#define mld6_type mld6_hdr.icmp6_type
#define mld6_code mld6_hdr.icmp6_code
#define mld6_cksum mld6_hdr.icmp6_cksum
#define mld6_maxdelay mld6_hdr.icmp6_data16[0]
#define mld6_reserved mld6_hdr.icmp6_data16[1]
#define MLD_MINLEN 24
#define MLDV2_MINLEN 28
/*
* Neighbor Discovery
*/
struct nd_router_solicit { /* router solicitation */
struct icmp6_hdr nd_rs_hdr;
/* could be followed by options */
};
#define nd_rs_type nd_rs_hdr.icmp6_type
#define nd_rs_code nd_rs_hdr.icmp6_code
#define nd_rs_cksum nd_rs_hdr.icmp6_cksum
#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
struct nd_router_advert { /* router advertisement */
struct icmp6_hdr nd_ra_hdr;
u_int32_t nd_ra_reachable; /* reachable time */
u_int32_t nd_ra_retransmit; /* retransmit timer */
/* could be followed by options */
};
#define nd_ra_type nd_ra_hdr.icmp6_type
#define nd_ra_code nd_ra_hdr.icmp6_code
#define nd_ra_cksum nd_ra_hdr.icmp6_cksum
#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
#define ND_RA_FLAG_MANAGED 0x80
#define ND_RA_FLAG_OTHER 0x40
#define ND_RA_FLAG_HOME_AGENT 0x20
/*
* Router preference values based on draft-draves-ipngwg-router-selection-01.
* These are non-standard definitions.
*/
#define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
#define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
#define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
#define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
#define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
struct nd_neighbor_solicit { /* neighbor solicitation */
struct icmp6_hdr nd_ns_hdr;
struct in6_addr nd_ns_target; /*target address */
/* could be followed by options */
};
#define nd_ns_type nd_ns_hdr.icmp6_type
#define nd_ns_code nd_ns_hdr.icmp6_code
#define nd_ns_cksum nd_ns_hdr.icmp6_cksum
#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
struct nd_neighbor_advert { /* neighbor advertisement */
struct icmp6_hdr nd_na_hdr;
struct in6_addr nd_na_target; /* target address */
/* could be followed by options */
};
#define nd_na_type nd_na_hdr.icmp6_type
#define nd_na_code nd_na_hdr.icmp6_code
#define nd_na_cksum nd_na_hdr.icmp6_cksum
#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
#define ND_NA_FLAG_ROUTER 0x80000000
#define ND_NA_FLAG_SOLICITED 0x40000000
#define ND_NA_FLAG_OVERRIDE 0x20000000
struct nd_redirect { /* redirect */
struct icmp6_hdr nd_rd_hdr;
struct in6_addr nd_rd_target; /* target address */
struct in6_addr nd_rd_dst; /* destination address */
/* could be followed by options */
};
#define nd_rd_type nd_rd_hdr.icmp6_type
#define nd_rd_code nd_rd_hdr.icmp6_code
#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
struct nd_opt_hdr { /* Neighbor discovery option header */
u_int8_t nd_opt_type;
u_int8_t nd_opt_len;
/* followed by option specific data*/
};
#define ND_OPT_SOURCE_LINKADDR 1
#define ND_OPT_TARGET_LINKADDR 2
#define ND_OPT_PREFIX_INFORMATION 3
#define ND_OPT_REDIRECTED_HEADER 4
#define ND_OPT_MTU 5
#define ND_OPT_ADVINTERVAL 7
#define ND_OPT_HOMEAGENT_INFO 8
#define ND_OPT_ROUTE_INFO 9 /* draft-ietf-ipngwg-router-preference, not officially assigned yet */
#define ND_OPT_RDNSS 25
#define ND_OPT_DNSSL 31
struct nd_opt_prefix_info { /* prefix information */
u_int8_t nd_opt_pi_type;
u_int8_t nd_opt_pi_len;
u_int8_t nd_opt_pi_prefix_len;
u_int8_t nd_opt_pi_flags_reserved;
u_int8_t nd_opt_pi_valid_time[4];
u_int8_t nd_opt_pi_preferred_time[4];
u_int8_t nd_opt_pi_reserved2[4];
struct in6_addr nd_opt_pi_prefix;
};
#define ND_OPT_PI_FLAG_ONLINK 0x80
#define ND_OPT_PI_FLAG_AUTO 0x40
#define ND_OPT_PI_FLAG_ROUTER 0x20 /*2292bis*/
struct nd_opt_rd_hdr { /* redirected header */
u_int8_t nd_opt_rh_type;
u_int8_t nd_opt_rh_len;
u_int16_t nd_opt_rh_reserved1;
u_int32_t nd_opt_rh_reserved2;
/* followed by IP header and data */
};
struct nd_opt_mtu { /* MTU option */
u_int8_t nd_opt_mtu_type;
u_int8_t nd_opt_mtu_len;
u_int16_t nd_opt_mtu_reserved;
u_int32_t nd_opt_mtu_mtu;
};
struct nd_opt_rdnss { /* RDNSS RFC 6106 5.1 */
u_int8_t nd_opt_rdnss_type;
u_int8_t nd_opt_rdnss_len;
u_int16_t nd_opt_rdnss_reserved;
u_int32_t nd_opt_rdnss_lifetime;
struct in6_addr nd_opt_rdnss_addr[1]; /* variable-length */
};
struct nd_opt_dnssl { /* DNSSL RFC 6106 5.2 */
u_int8_t nd_opt_dnssl_type;
u_int8_t nd_opt_dnssl_len;
u_int16_t nd_opt_dnssl_reserved;
u_int32_t nd_opt_dnssl_lifetime;
/* followed by list of DNS search domains, variable-length */
};
struct nd_opt_advinterval { /* Advertisement interval option */
u_int8_t nd_opt_adv_type;
u_int8_t nd_opt_adv_len;
u_int16_t nd_opt_adv_reserved;
u_int32_t nd_opt_adv_interval;
};
struct nd_opt_homeagent_info { /* Home Agent info */
u_int8_t nd_opt_hai_type;
u_int8_t nd_opt_hai_len;
u_int16_t nd_opt_hai_reserved;
int16_t nd_opt_hai_preference;
u_int16_t nd_opt_hai_lifetime;
};
struct nd_opt_route_info { /* route info */
u_int8_t nd_opt_rti_type;
u_int8_t nd_opt_rti_len;
u_int8_t nd_opt_rti_prefixlen;
u_int8_t nd_opt_rti_flags;
u_int32_t nd_opt_rti_lifetime;
/* prefix follows */
};
/*
* icmp6 namelookup
*/
struct icmp6_namelookup {
struct icmp6_hdr icmp6_nl_hdr;
u_int8_t icmp6_nl_nonce[8];
int32_t icmp6_nl_ttl;
#if 0
u_int8_t icmp6_nl_len;
u_int8_t icmp6_nl_name[3];
#endif
/* could be followed by options */
};
/*
* icmp6 node information
*/
struct icmp6_nodeinfo {
struct icmp6_hdr icmp6_ni_hdr;
u_int8_t icmp6_ni_nonce[8];
/* could be followed by reply data */
};
#define ni_type icmp6_ni_hdr.icmp6_type
#define ni_code icmp6_ni_hdr.icmp6_code
#define ni_cksum icmp6_ni_hdr.icmp6_cksum
#define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
#define ni_flags icmp6_ni_hdr.icmp6_data16[1]
#define NI_QTYPE_NOOP 0 /* NOOP */
#define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
#define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
#define NI_QTYPE_DNSNAME 2 /* DNS Name */
#define NI_QTYPE_NODEADDR 3 /* Node Addresses */
#define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
/* network endian */
#define NI_SUPTYPE_FLAG_COMPRESS ((u_int16_t)htons(0x1))
#define NI_FQDN_FLAG_VALIDTTL ((u_int16_t)htons(0x1))
/* network endian */
#define NI_NODEADDR_FLAG_TRUNCATE ((u_int16_t)htons(0x1))
#define NI_NODEADDR_FLAG_ALL ((u_int16_t)htons(0x2))
#define NI_NODEADDR_FLAG_COMPAT ((u_int16_t)htons(0x4))
#define NI_NODEADDR_FLAG_LINKLOCAL ((u_int16_t)htons(0x8))
#define NI_NODEADDR_FLAG_SITELOCAL ((u_int16_t)htons(0x10))
#define NI_NODEADDR_FLAG_GLOBAL ((u_int16_t)htons(0x20))
#define NI_NODEADDR_FLAG_ANYCAST ((u_int16_t)htons(0x40)) /* just experimental. not in spec */
struct ni_reply_fqdn {
u_int32_t ni_fqdn_ttl; /* TTL */
u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
};
/*
* Router Renumbering. as router-renum-08.txt
*/
struct icmp6_router_renum { /* router renumbering header */
struct icmp6_hdr rr_hdr;
u_int8_t rr_segnum;
u_int8_t rr_flags;
u_int16_t rr_maxdelay;
u_int32_t rr_reserved;
};
#define ICMP6_RR_FLAGS_TEST 0x80
#define ICMP6_RR_FLAGS_REQRESULT 0x40
#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
#define ICMP6_RR_FLAGS_SPECSITE 0x10
#define ICMP6_RR_FLAGS_PREVDONE 0x08
#define rr_type rr_hdr.icmp6_type
#define rr_code rr_hdr.icmp6_code
#define rr_cksum rr_hdr.icmp6_cksum
#define rr_seqnum rr_hdr.icmp6_data32[0]
struct rr_pco_match { /* match prefix part */
u_int8_t rpm_code;
u_int8_t rpm_len;
u_int8_t rpm_ordinal;
u_int8_t rpm_matchlen;
u_int8_t rpm_minlen;
u_int8_t rpm_maxlen;
u_int16_t rpm_reserved;
struct in6_addr rpm_prefix;
};
#define RPM_PCO_ADD 1
#define RPM_PCO_CHANGE 2
#define RPM_PCO_SETGLOBAL 3
#define RPM_PCO_MAX 4
struct rr_pco_use { /* use prefix part */
u_int8_t rpu_uselen;
u_int8_t rpu_keeplen;
u_int8_t rpu_ramask;
u_int8_t rpu_raflags;
u_int32_t rpu_vltime;
u_int32_t rpu_pltime;
u_int32_t rpu_flags;
struct in6_addr rpu_prefix;
};
#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
/* network endian */
#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME ((u_int32_t)htonl(0x80000000))
#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME ((u_int32_t)htonl(0x40000000))
struct rr_result { /* router renumbering result message */
u_int16_t rrr_flags;
u_int8_t rrr_ordinal;
u_int8_t rrr_matchedlen;
u_int32_t rrr_ifid;
struct in6_addr rrr_prefix;
};
/* network endian */
#define ICMP6_RR_RESULT_FLAGS_OOB ((u_int16_t)htons(0x0002))
#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN ((u_int16_t)htons(0x0001))
#endif /* not _NETINET_ICMP6_H_ */
| 35.381857 | 99 | 0.776579 |
8b0b4e33c5c955fb71d09d452282a9c919231a37 | 1,158 | h | C | ExampleCodes/MonteCarlo/timerstuff.h | esiegmann/Ookami | a4d11cbfd888ce96b6149f1c0434ce8c6f7d59d5 | [
"BSD-3-Clause"
] | 1 | 2021-08-18T10:07:01.000Z | 2021-08-18T10:07:01.000Z | ExampleCodes/MonteCarlo/timerstuff.h | esiegmann/Ookami | a4d11cbfd888ce96b6149f1c0434ce8c6f7d59d5 | [
"BSD-3-Clause"
] | null | null | null | ExampleCodes/MonteCarlo/timerstuff.h | esiegmann/Ookami | a4d11cbfd888ce96b6149f1c0434ce8c6f7d59d5 | [
"BSD-3-Clause"
] | null | null | null | #include <chrono>
#include <cstdint>
#include <stdint.h>
#include <ctime>
#include <sys/time.h>
#include <papi.h>
#define HAVE_PAPI
// Returns current cycle count for this thread
static inline uint64_t cycle_count() {
return PAPI_get_real_cyc()*18; // <<<<<<<<<<<<<<<<<<<<<
}
// Returns wall time in seconds from arbitrary origin, accurate to circa a few us.
static inline double wall_time() {
static bool first_call = true;
static double start_time;
struct timeval tv;
gettimeofday(&tv,0);
double now = tv.tv_sec + 1e-6*tv.tv_usec;
if (first_call) {
first_call = false;
start_time = now;
}
return now - start_time;
}
// Returns estimate of the cpu frequency.
static double cpu_frequency() {
return 1.8e9;
}
static inline double cpu_time() {
#if defined(HAVE_PAPI)
return PAPI_get_real_usec()*1e-6;
#else
const auto now = std::chrono::steady_clock::now();
const auto seconds_since_epoch = std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch()).count();
return seconds_since_epoch;
#endif
}
| 25.733333 | 123 | 0.639896 |
e30f8e9620a33335e20d120ac080f43c929f8c0c | 26,645 | c | C | ble-mesh-profile/sources/provisioning/mesh_prv_sr_main.c | schneider42/stacks | 34e728bdd181c20fb7dd8e0db192c4a19fcdcfcd | [
"Apache-2.0"
] | 62 | 2020-05-13T14:05:20.000Z | 2022-03-23T16:10:34.000Z | ble-mesh-profile/sources/provisioning/mesh_prv_sr_main.c | schneider42/stacks | 34e728bdd181c20fb7dd8e0db192c4a19fcdcfcd | [
"Apache-2.0"
] | 2 | 2020-05-13T00:44:10.000Z | 2020-11-17T15:50:41.000Z | ble-mesh-profile/sources/provisioning/mesh_prv_sr_main.c | schneider42/stacks | 34e728bdd181c20fb7dd8e0db192c4a19fcdcfcd | [
"Apache-2.0"
] | 56 | 2020-05-13T00:54:16.000Z | 2022-01-19T12:09:35.000Z | /*************************************************************************************************/
/*!
* \file mesh_prv_sr_main.c
*
* \brief Mesh Provisioning Server module implementation.
*
* Copyright (c) 2010-2019 Arm Ltd. All Rights Reserved.
*
* Copyright (c) 2019-2020 Packetcraft, 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.
*
*/
/*************************************************************************************************/
#include <string.h>
#include "wsf_types.h"
#include "wsf_msg.h"
#include "wsf_os.h"
#include "wsf_assert.h"
#include "wsf_buf.h"
#include "wsf_trace.h"
#include "mesh_defs.h"
#include "mesh_types.h"
#include "mesh_api.h"
#include "mesh_prv_defs.h"
#include "mesh_prv.h"
#include "mesh_prv_sr_main.h"
#include "mesh_prv_sr_api.h"
#include "mesh_prv_br_main.h"
#include "mesh_prv_common.h"
#include "mesh_utils.h"
#if ((defined MESH_ENABLE_TEST) && (MESH_ENABLE_TEST == 1))
#include "mesh_test_api.h"
#endif
/**************************************************************************************************
Local Variables
**************************************************************************************************/
/*! Module initialization flag */
static bool_t prvSrInitialized = FALSE;
/*! Mesh Provisioning Server callback event length table */
static const uint16_t meshPrvSrEvtCbackLen[] =
{
sizeof(wsfMsgHdr_t), /*!< MESH_PRV_SR_LINK_OPENED_EVENT */
sizeof(meshPrvSrEvtOutputOob_t), /*!< MESH_PRV_SR_OUTPUT_OOB_EVENT */
sizeof(wsfMsgHdr_t), /*!< MESH_PRV_SR_OUTPUT_CONFIRMED_EVENT */
sizeof(meshPrvSrEvtInputOob_t), /*!< MESH_PRV_SR_INPUT_OOB_EVENT */
sizeof(meshPrvSrEvtPrvComplete_t), /*!< MESH_PRV_SR_PROVISIONING_COMPLETE_EVENT */
sizeof(meshPrvSrEvtPrvFailed_t), /*!< MESH_PRV_SR_PROVISIONING_FAILED_EVENT */
};
/**************************************************************************************************
Global Variables
**************************************************************************************************/
/*! Control block */
meshPrvSrCb_t meshPrvSrCb;
/**************************************************************************************************
Local Functions
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Validates parameters for the incoming Provisioning Start PDU.
*
* \param[in] pParams Pointer to the Provisioning Start PDU parameters.
*
* \return TRUE if parameters are valid, FALSE otherwise.
*/
/*************************************************************************************************/
static bool_t meshPrvSrValidateStartParams(meshPrvSrRecvStart_t *pParams)
{
/* Range validation for Algorithm, Public Key and Authentication Method */
if (pParams->algorithm >= MESH_PRV_START_ALGO_RFU_START ||
pParams->oobPubKeyUsed >= MESH_PRV_START_PUB_KEY_PROHIBITED_START ||
pParams->authMethod >= MESH_PRV_START_AUTH_METHOD_PROHIBITED_START)
{
return FALSE;
}
/* Range validation for Authentication Action and Authentication Size
* when using Output OOB */
if (pParams->authMethod == MESH_PRV_START_AUTH_METHOD_OUTPUT_OOB &&
(pParams->authAction >= MESH_PRV_START_OUT_OOB_ACTION_RFU_START ||
pParams->authSize == MESH_PRV_START_OOB_SIZE_PROHIBITED ||
pParams->authSize >= MESH_PRV_START_OOB_SIZE_RFU_START))
{
return FALSE;
}
/* Range validation for Authentication Action and Authentication Size
* when using Input OOB */
if (pParams->authMethod == MESH_PRV_START_AUTH_METHOD_INPUT_OOB &&
(pParams->authAction >= MESH_PRV_START_IN_OOB_ACTION_RFU_START ||
pParams->authSize == MESH_PRV_START_OOB_SIZE_PROHIBITED ||
pParams->authSize >= MESH_PRV_START_OOB_SIZE_RFU_START))
{
return FALSE;
}
/* Range validation for Authentication Action and Authentication Size
* when using Static or No OOB */
if ((pParams->authMethod == MESH_PRV_START_AUTH_METHOD_STATIC_OOB ||
pParams->authMethod == MESH_PRV_START_AUTH_METHOD_NO_OOB) &&
(pParams->authAction != MESH_PRV_START_OOB_NO_SIZE_NO_ACTION ||
pParams->authSize != MESH_PRV_START_OOB_NO_SIZE_NO_ACTION))
{
return FALSE;
}
/* Public Key validation against capabilities */
if (pParams->oobPubKeyUsed == MESH_PRV_START_PUB_KEY_OOB_AVAILABLE &&
!(meshPrvSrCb.pUpdInfo->pCapabilities->publicKeyType & MESH_PRV_PUB_KEY_OOB))
{
return FALSE;
}
/* Authentication Method, Action and Size validation against capabilities
* when using Output OOB */
if (pParams->authMethod == MESH_PRV_START_AUTH_METHOD_OUTPUT_OOB &&
(meshPrvSrCb.pUpdInfo->pCapabilities->outputOobSize == MESH_PRV_OUTPUT_OOB_NOT_SUPPORTED ||
meshPrvSrCb.pUpdInfo->pCapabilities->outputOobSize < pParams->authSize ||
!(meshPrvSrCb.pUpdInfo->pCapabilities->outputOobAction & (1 << pParams->authAction))))
{
return FALSE;
}
/* Authentication Method, Action and Size validation against capabilities
* when using Input OOB */
if (pParams->authMethod == MESH_PRV_START_AUTH_METHOD_INPUT_OOB &&
(meshPrvSrCb.pUpdInfo->pCapabilities->inputOobSize == MESH_PRV_INPUT_OOB_NOT_SUPPORTED ||
meshPrvSrCb.pUpdInfo->pCapabilities->inputOobSize < pParams->authSize ||
!(meshPrvSrCb.pUpdInfo->pCapabilities->inputOobAction & (1 << pParams->authAction))))
{
return FALSE;
}
return TRUE;
}
/*************************************************************************************************/
/*!
* \brief Mesh Provisioning Bearer PDU received callback.
*
* \param[in] pPdu Pointer to the Provisioning Bearer PDU received.
* \param[in] pduLen Size of the Provisioning Bearer PDU received.
*
* \return None.
*/
/*************************************************************************************************/
static void meshPrvSrPduRecvCback(const uint8_t *pPrvPdu, uint8_t pduLen)
{
meshPrvSrSmMsg_t *pMsg;
if (meshPrvSrCb.pSessionData == NULL)
{
MESH_TRACE_ERR0("MESH PRV SR: Session data not allocated when receiving PDU!");
return;
}
if (pduLen < MESH_PRV_PDU_OPCODE_SIZE)
{
MESH_TRACE_ERR0("MESH PRV SR: No Opcode in Provisioning PDU!");
return;
}
pMsg = WsfMsgAlloc(sizeof (meshPrvSrSmMsg_t));
if (pMsg == NULL)
{
/* Should never happen if buffers are properly configured */
return;
}
switch (pPrvPdu[MESH_PRV_PDU_OPCODE_INDEX])
{
case MESH_PRV_PDU_INVITE:
if (pduLen != MESH_PRV_PDU_INVITE_PDU_SIZE)
{
MESH_TRACE_WARN1("MESH PRV SR: Received invalid Provisioning Invite PDU length: %d", pduLen);
pMsg->hdr.event = PRV_SR_EVT_RECV_BAD_PDU;
pMsg->hdr.param = MESH_PRV_ERR_INVALID_FORMAT;
}
else
{
/* Copy parameters to the ConfirmationInputs */
memcpy(meshPrvSrCb.pSessionData->authParams.confirmationInputs,
&pPrvPdu[MESH_PRV_PDU_PARAM_INDEX],
MESH_PRV_PDU_INVITE_PARAM_SIZE);
pMsg->recvInvite.hdr.event = PRV_SR_EVT_RECV_INVITE;
pMsg->recvInvite.attentionTimer = pPrvPdu[MESH_PRV_PDU_INVITE_ATTENTION_INDEX];
}
break;
case MESH_PRV_PDU_START:
if (pduLen != MESH_PRV_PDU_START_PDU_SIZE)
{
MESH_TRACE_WARN1("MESH PRV SR: Received invalid Provisioning Start PDU length: %d", pduLen);
pMsg->hdr.event = PRV_SR_EVT_RECV_BAD_PDU;
pMsg->hdr.param = MESH_PRV_ERR_INVALID_FORMAT;
}
else
{
/* Unpack parameters */
pMsg->recvStart.hdr.event = PRV_SR_EVT_RECV_START;
pMsg->recvStart.algorithm = pPrvPdu[MESH_PRV_PDU_START_ALGORITHM_INDEX];
pMsg->recvStart.oobPubKeyUsed = pPrvPdu[MESH_PRV_PDU_START_PUB_KEY_INDEX];
pMsg->recvStart.authMethod = pPrvPdu[MESH_PRV_PDU_START_AUTH_METHOD_INDEX];
pMsg->recvStart.authAction = pPrvPdu[MESH_PRV_PDU_START_AUTH_ACTION_INDEX];
pMsg->recvStart.authSize = pPrvPdu[MESH_PRV_PDU_START_AUTH_SIZE_INDEX];
/* Parameter validation */
if (!meshPrvSrValidateStartParams(&pMsg->recvStart))
{
pMsg->hdr.event = PRV_SR_EVT_RECV_BAD_PDU;
pMsg->hdr.param = MESH_PRV_ERR_INVALID_FORMAT;
}
else
{
/* Copy packed parameters required by the ConfirmationInputs */
memcpy(pMsg->recvStart.packedPduParam,
&pPrvPdu[MESH_PRV_PDU_PARAM_INDEX],
MESH_PRV_PDU_START_PARAM_SIZE);
}
}
break;
case MESH_PRV_PDU_PUB_KEY:
if (pduLen != MESH_PRV_PDU_PUB_KEY_PDU_SIZE)
{
MESH_TRACE_WARN1("MESH PRV SR: Received invalid Provisioning Public Key PDU length: %d", pduLen);
pMsg->hdr.event = PRV_SR_EVT_RECV_BAD_PDU;
pMsg->hdr.param = MESH_PRV_ERR_INVALID_FORMAT;
}
else
{
pMsg->hdr.event = PRV_SR_EVT_RECV_PUBLIC_KEY;
memcpy(pMsg->recvPubKey.pubKeyPdu,
pPrvPdu,
MESH_PRV_PDU_PUB_KEY_PDU_SIZE);
}
break;
case MESH_PRV_PDU_CONFIRMATION:
if (pduLen != MESH_PRV_PDU_CONFIRM_PDU_SIZE)
{
MESH_TRACE_WARN1("MESH PRV SR: Received invalid Provisioning Confirmation PDU length: %d", pduLen);
pMsg->hdr.event = PRV_SR_EVT_RECV_BAD_PDU;
pMsg->hdr.param = MESH_PRV_ERR_INVALID_FORMAT;
}
else
{
pMsg->recvConfirm.hdr.event = PRV_SR_EVT_RECV_CONFIRMATION;
memcpy(pMsg->recvConfirm.confirm,
&pPrvPdu[MESH_PRV_PDU_CONFIRM_CONFIRM_INDEX],
MESH_PRV_PDU_CONFIRM_CONFIRM_SIZE);
}
break;
case MESH_PRV_PDU_RANDOM:
if (pduLen != MESH_PRV_PDU_RANDOM_PDU_SIZE)
{
MESH_TRACE_WARN1("MESH PRV SR: Received invalid Provisioning Random PDU length: %d", pduLen);
pMsg->hdr.event = PRV_SR_EVT_RECV_BAD_PDU;
pMsg->hdr.param = MESH_PRV_ERR_INVALID_FORMAT;
}
else
{
pMsg->recvRandom.hdr.event = PRV_SR_EVT_RECV_RANDOM;
memcpy(pMsg->recvRandom.random,
&pPrvPdu[MESH_PRV_PDU_RANDOM_RANDOM_INDEX],
MESH_PRV_PDU_RANDOM_RANDOM_SIZE);
}
break;
case MESH_PRV_PDU_DATA:
if (pduLen != MESH_PRV_PDU_DATA_PDU_SIZE)
{
MESH_TRACE_WARN1("MESH PRV SR: Received invalid Provisioning Data PDU length: %d", pduLen);
pMsg->hdr.event = PRV_SR_EVT_RECV_BAD_PDU;
pMsg->hdr.param = MESH_PRV_ERR_INVALID_FORMAT;
}
else
{
pMsg->recvData.hdr.event = PRV_SR_EVT_RECV_DATA;
memcpy(pMsg->recvData.encryptedDataAndMic,
&pPrvPdu[MESH_PRV_PDU_DATA_ENC_DATA_INDEX],
MESH_PRV_PDU_DATA_PARAM_SIZE);
}
break;
case MESH_PRV_PDU_CAPABILITIES: /* Fallthrough */
case MESH_PRV_PDU_INPUT_COMPLETE: /* Fallthrough */
case MESH_PRV_PDU_COMPLETE: /* Fallthrough */
case MESH_PRV_PDU_FAILED:
MESH_TRACE_WARN1("MESH PRV SR: Received unexpected Provisioning PDU type: 0x%02X", pPrvPdu[0]);
pMsg->hdr.event = PRV_SR_EVT_RECV_BAD_PDU;
pMsg->hdr.param = MESH_PRV_ERR_UNEXPECTED_PDU;
break;
default:
MESH_TRACE_WARN1("MESH PRV SR: Received invalid Provisioning PDU type: 0x%02X", pPrvPdu[0]);
pMsg->hdr.event = PRV_SR_EVT_RECV_BAD_PDU;
pMsg->hdr.param = MESH_PRV_ERR_INVALID_PDU;
break;
}
WsfMsgSend(meshPrvSrCb.timer.handlerId, pMsg);
}
/*************************************************************************************************/
/*!
* \brief Mesh Provisioning Bearer event notification callback.
*
* \param[in] evt Reason the callback is being invoked. See ::meshPrvBrEvent_t
* \param[in] pEventParams Pointer to the event parameters structure passed to the function.
* See ::meshPrvBrEventParams_t
*
* \return None.
*/
/*************************************************************************************************/
static void meshPrvSrBrEventNotifyCback(meshPrvBrEvent_t evt,
const meshPrvBrEventParams_t *pEvtParams)
{
wsfMsgHdr_t *pMsg = WsfMsgAlloc(sizeof (wsfMsgHdr_t));
if (pMsg == NULL)
{
/* Should never happen if buffers are properly configured */
return;
}
switch (evt)
{
case MESH_PRV_BR_LINK_OPENED:
pMsg->event = PRV_SR_EVT_LINK_OPENED;
WsfMsgSend(meshPrvSrCb.timer.handlerId, pMsg);
break;
case MESH_PRV_BR_LINK_CLOSED_BY_PEER:
if (pEvtParams->linkCloseReason == MESH_PRV_BR_REASON_SUCCESS)
{
pMsg->event = PRV_SR_EVT_LINK_CLOSED_SUCCESS;
}
else
{
pMsg->event = PRV_SR_EVT_LINK_CLOSED_FAIL;
}
WsfMsgSend(meshPrvSrCb.timer.handlerId, pMsg);
break;
case MESH_PRV_BR_CONN_CLOSED:
/* This event is ignored in the IDLE state, so it will signal a failure
* to the upper layer only if the connection is closed before provisioning
* is complete (i.e., in a state different than IDLE). */
pMsg->event = PRV_SR_EVT_LINK_CLOSED_FAIL;
WsfMsgSend(meshPrvSrCb.timer.handlerId, pMsg);
break;
case MESH_PRV_BR_SEND_TIMEOUT:
pMsg->event = PRV_SR_EVT_SEND_TIMEOUT;
WsfMsgSend(meshPrvSrCb.timer.handlerId, pMsg);
break;
case MESH_PRV_BR_PDU_SENT:
switch (pEvtParams->pduSentOpcode)
{
case MESH_PRV_PDU_FAILED:
MESH_TRACE_INFO0("MESH PRV SR: Provisioning Failed PDU sent successfully.");
/* No event needed after sending a Provisioning Failed PDU */
WsfMsgFree(pMsg);
break;
case MESH_PRV_PDU_CAPABILITIES:
pMsg->event = PRV_SR_EVT_SENT_CAPABILITIES;
WsfMsgSend(meshPrvSrCb.timer.handlerId, pMsg);
break;
case MESH_PRV_PDU_PUB_KEY:
pMsg->event = PRV_SR_EVT_SENT_PUBLIC_KEY;
WsfMsgSend(meshPrvSrCb.timer.handlerId, pMsg);
break;
case MESH_PRV_PDU_INPUT_COMPLETE:
pMsg->event = PRV_SR_EVT_SENT_INPUT_COMPLETE;
WsfMsgSend(meshPrvSrCb.timer.handlerId, pMsg);
break;
case MESH_PRV_PDU_CONFIRMATION:
pMsg->event = PRV_SR_EVT_SENT_CONFIRMATION;
WsfMsgSend(meshPrvSrCb.timer.handlerId, pMsg);
break;
case MESH_PRV_PDU_RANDOM:
pMsg->event = PRV_SR_EVT_SENT_RANDOM;
WsfMsgSend(meshPrvSrCb.timer.handlerId, pMsg);
break;
case MESH_PRV_PDU_COMPLETE:
pMsg->event = PRV_SR_EVT_SENT_COMPLETE;
WsfMsgSend(meshPrvSrCb.timer.handlerId, pMsg);
break;
default:
MESH_TRACE_WARN0("MESH PRV SR: Received PDU Sent event with invalid opcode.");
WsfMsgFree(pMsg);
break;
}
break;
default:
MESH_TRACE_WARN1("MESH PRV SR: Received PRV BR event with invalid type: %d.", evt);
WsfMsgFree(pMsg);
break;
}
}
/*************************************************************************************************/
/*!
* \brief Empty event notification callback.
*
* \param[in] pEvent Pointer to the event.
* See ::meshPrvSrEvent_t
*
* \return None.
*/
/*************************************************************************************************/
static void meshPrvSrEventNotifyEmptyCback(meshPrvSrEvt_t *pEvent)
{
(void)pEvent;
MESH_TRACE_WARN0("MESH PRV SR: Event notification callback not installed!");
}
/**************************************************************************************************
Global Functions
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Initializes and configures the Provisioning Server.
*
* \param[in] pUpdInfo Sets the unprovisioned device information.
*
* \return None.
*/
/*************************************************************************************************/
void MeshPrvSrInit(const meshPrvSrUnprovisionedDeviceInfo_t* pUpdInfo)
{
if (prvSrInitialized)
{
MESH_TRACE_ERR0("MESH PRV SR: Attempting multiple initialization sequences!");
return;
}
if (pUpdInfo == NULL)
{
MESH_TRACE_ERR0("MESH PRV SR: Unprovisioned Device information parameter is NULL!");
return;
}
if ((pUpdInfo->pCapabilities->publicKeyType == MESH_PRV_PUB_KEY_OOB) &&
(pUpdInfo->pAppOobEccKeys == NULL))
{
MESH_TRACE_ERR0("MESH PRV SR: App OOB Key is NULL!");
return;
}
/* Initialize timer event value */
meshPrvSrCb.timer.msg.event = PRV_SR_EVT_RECV_TIMEOUT;
/* Link state machine instance */
meshPrvSrCb.pSm = &meshPrvSrSmIf;
/* Store capabilities */
meshPrvSrCb.pUpdInfo = pUpdInfo;
/* Set empty callback */
meshPrvSrCb.prvSrEvtNotifyCback = meshPrvSrEventNotifyEmptyCback;
/* Initialize empty session data */
meshPrvSrCb.pSessionData = NULL;
/* Initialize the provisioning bearer module and register callbacks */
MeshPrvBrInit();
MeshPrvBrRegisterCback(meshPrvSrPduRecvCback, meshPrvSrBrEventNotifyCback);
/* Set initial state */
meshPrvSrCb.state = PRV_SR_ST_IDLE;
/* Set flag */
prvSrInitialized = TRUE;
}
/*************************************************************************************************/
/*!
* \brief Initializes the Mesh Provisioning Server WSF handler.
*
* \param[in] handlerId WSF handler ID.
*
* \return None.
*/
/*************************************************************************************************/
void MeshPrvSrHandlerInit(wsfHandlerId_t handlerId)
{
/* Store Handler ID */
meshPrvSrCb.timer.handlerId = handlerId;
}
/*************************************************************************************************/
/*!
* \brief WSF event handler for Mesh Provisioning Server API.
*
* \param[in] event WSF event mask.
* \param[in] pMsg WSF message.
*
* \return None.
*/
/*************************************************************************************************/
void MeshPrvSrHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg)
{
/* Handle messages */
if (pMsg != NULL)
{
meshPrvSrSmExecute(&meshPrvSrCb, (meshPrvSrSmMsg_t*)pMsg);
}
/* Handle events */
else if (event)
{
}
}
/*************************************************************************************************/
/*!
* \brief Registers the Provisioning Server event callback function.
*
* \param[in] eventCback Pointer to the callback to be invoked on provisioning events.
*
* \return None.
*/
/*************************************************************************************************/
void MeshPrvSrRegister(meshPrvSrEvtNotifyCback_t eventCback)
{
if (eventCback != NULL)
{
meshPrvSrCb.prvSrEvtNotifyCback = eventCback;
}
else
{
MESH_TRACE_ERR0("MESH PRV SR: Attempting to install NULL event notification callback!");
}
}
/*************************************************************************************************/
/*!
* \brief Begins provisioning over PB-ADV by waiting for a PB-ADV link.
*
* \param[in] ifId ID of the PB-ADV bearer interface.
* \param[in] beaconInterval Unprovisioned Device beacon interval in ms.
*
* \return None.
*/
/*************************************************************************************************/
void MeshPrvSrEnterPbAdvProvisioningMode(uint8_t ifId, uint32_t beaconInterval)
{
meshPrvSrEnterPbAdv_t *pMsg;
/* Check module is initialized */
if (prvSrInitialized == FALSE)
{
MESH_TRACE_ERR0("MESH PRV SR: Mesh Provisioning Server not initialized!");
return;
}
/* Check session data is not already allocated */
if (meshPrvSrCb.pSessionData != NULL)
{
MESH_TRACE_ERR0("MESH PRV SR: Session data already allocated!");
return;
}
/* Allocate session data */
meshPrvSrCb.pSessionData = WsfBufAlloc(sizeof(meshPrvSrSessionData_t));
if (meshPrvSrCb.pSessionData == NULL)
{
/* Should not happen if buffers are properly configured */
return;
}
/* Allocate the Stack Message and additional size for message parameters. */
if ((pMsg = WsfMsgAlloc(sizeof(meshPrvSrEnterPbAdv_t))) != NULL)
{
/* Set event type. */
pMsg->hdr.event = PRV_SR_EVT_BEGIN_NO_LINK;
/* Copy parameters */
pMsg->ifId = ifId;
pMsg->beaconInterval = beaconInterval;
/* Send Message. */
WsfMsgSend(meshPrvSrCb.timer.handlerId, pMsg);
}
else
{
/* Should not happen if buffers are properly configured. */
WsfBufFree(meshPrvSrCb.pSessionData);
}
}
/*************************************************************************************************/
/*!
* \brief Begins provisioning over PB-GATT.
*
* \param[in] connId ID of the GATT connection.
*
* \return None.
*/
/*************************************************************************************************/
void MeshPrvSrEnterPbGattProvisioningMode(uint8_t connId)
{
meshPrvSrEnterPbGatt_t *pMsg;
/* Check module is initialized */
if (prvSrInitialized == FALSE)
{
MESH_TRACE_ERR0("MESH PRV SR: Mesh Provisioning Server not initialized!");
return;
}
/* Check session data is not already allocated */
if (meshPrvSrCb.pSessionData != NULL)
{
MESH_TRACE_ERR0("MESH PRV SR: Session data already allocated!");
return;
}
/* Allocate session data */
meshPrvSrCb.pSessionData = WsfBufAlloc(sizeof(meshPrvSrSessionData_t));
if (meshPrvSrCb.pSessionData == NULL)
{
/* Should not happen if buffers are properly configured */
return;
}
/* Allocate the Stack Message and additional size for message parameters. */
if ((pMsg = WsfMsgAlloc(sizeof(meshPrvSrEnterPbGatt_t))) != NULL)
{
/* Set event type. */
pMsg->hdr.event = PRV_SR_EVT_BEGIN_LINK_OPEN;
/* Copy parameters */
pMsg->connId = connId;
/* Send Message. */
WsfMsgSend(meshPrvSrCb.timer.handlerId, pMsg);
}
else
{
/* Should not happen if buffers are properly configured. */
WsfBufFree(meshPrvSrCb.pSessionData);
}
}
/*************************************************************************************************/
/*!
* \brief Provisioner Server application calls this function when it obtains the OOB input
* numbers or characters from the user.
*
* \param[in] inputOobSize Size of alphanumeric Input OOB data, used only when the Input OOB
* Action was MESH_PRV_INPUT_OOB_ACTION_INPUT_ALPHANUM; otherwise,
* the Input OOB data is numeric, and this parameter shall be set to 0.
*
* \param[in] inputOobData Array of inputOobSize octets containing the alphanumeric Input OOB
* data, if the Input OOB action selected by the Provisioner was
* MESH_PRV_INPUT_OOB_ACTION_INPUT_ALPHANUM action; otherwise,
* this is a numeric 8-octet value and inputOobSize is ignored.
*
* \return None.
*/
/*************************************************************************************************/
void MeshPrvSrInputComplete(meshPrvInputOobSize_t inputOobSize, meshPrvInOutOobData_t inputOobData)
{
meshPrvSrInputOob_t *pMsg;
if (prvSrInitialized == FALSE)
{
MESH_TRACE_ERR0("MESH PRV SR: Mesh Provisioning Server not initialized!");
return;
}
/* Validate parameters */
if (inputOobSize >= MESH_PRV_INPUT_OOB_SIZE_RFU_START ||
(inputOobSize > 0 &&
!meshPrvIsAlphanumericArray(inputOobData.alphanumericOob, inputOobSize)))
{
MESH_TRACE_ERR0("MESH PRV CL: Invalid parameters in MeshPrvSrInputComplete!");
return;
}
/* Allocate the Stack Message and additional size for message parameters. */
if ((pMsg = WsfMsgAlloc(sizeof(meshPrvSrInputOob_t))) != NULL)
{
/* Set event type. */
pMsg->hdr.event = PRV_SR_EVT_INPUT_READY;
pMsg->inputOobSize = inputOobSize;
pMsg->inputOobData = inputOobData;
/* Send Message. */
WsfMsgSend(meshPrvSrCb.timer.handlerId, pMsg);
}
/* Else should not happen if buffers are properly configured. */
}
/*************************************************************************************************/
/*!
* \brief Return size of a Mesh Provisioning Server callback event.
*
* \param[in] pMeshPrvSrEvt Mesh Provisioning Server callback event.
*
* \return Size of Mesh Provisioning Server callback event.
*/
/*************************************************************************************************/
uint16_t MeshPrvSrSizeOfEvt(meshPrvSrEvt_t *pMeshPrvSrEvt)
{
uint16_t len;
/* If a valid Provisioning Server event ID */
if ((pMeshPrvSrEvt->hdr.event == MESH_PRV_SR_EVENT) &&
(pMeshPrvSrEvt->hdr.param <= MESH_PRV_SR_MAX_EVENT))
{
len = meshPrvSrEvtCbackLen[pMeshPrvSrEvt->hdr.param];
}
else
{
len = sizeof(wsfMsgHdr_t);
}
return len;
}
/*************************************************************************************************/
/*!
* \brief Send Provisioning Failed PDU.
*
* \param[in] errorCode Error code, see ::meshPrvErrorCodeValues_tag.
*
* \return None.
*
* \remarks The function can be called at any moment during the protocol; it does not affect the
* state machine.
*/
/*************************************************************************************************/
void meshPrvSrSendFailedPdu(uint8_t errorCode)
{
WSF_ASSERT(errorCode != MESH_PRV_ERR_PROHIBITED && errorCode < MESH_PRV_ERR_RFU_START);
/* Allocate buffer for the Provisioning Failed PDU */
uint8_t *pBuf = WsfBufAlloc(MESH_PRV_PDU_FAILED_PDU_SIZE);
if (pBuf != NULL)
{
pBuf[MESH_PRV_PDU_OPCODE_INDEX] = MESH_PRV_PDU_FAILED;
pBuf[MESH_PRV_PDU_FAILED_ERROR_CODE_INDEX] = errorCode;
(void)MeshPrvBrSendProvisioningPdu(pBuf, MESH_PRV_PDU_FAILED_PDU_SIZE);
}
}
| 33.985969 | 107 | 0.592006 |
8f70f6951e9be798ebf761af0c0a176d0514dc4b | 332 | c | C | CPE_matchstick_2017/src/base/my_revstr.c | ltabis/epitech-projects | e38b3f00a4ac44c969d5e4880cd65084dc2c870a | [
"MIT"
] | null | null | null | CPE_matchstick_2017/src/base/my_revstr.c | ltabis/epitech-projects | e38b3f00a4ac44c969d5e4880cd65084dc2c870a | [
"MIT"
] | null | null | null | CPE_matchstick_2017/src/base/my_revstr.c | ltabis/epitech-projects | e38b3f00a4ac44c969d5e4880cd65084dc2c870a | [
"MIT"
] | 1 | 2021-01-07T17:41:14.000Z | 2021-01-07T17:41:14.000Z | /*
** EPITECH PROJECT, 2017
** my_revstr.c
** File description:
** task03 Day06
*/
char *my_revstr(char *str)
{
unsigned int i = 0;
for (; str[i] != '\0'; i++);
for (unsigned int count = 0; count != i / 2; count++) {
char save = str[count];
str[count] = str[i - count - 1];
str[i - count - 1] = save;
}
return (str);
}
| 16.6 | 56 | 0.557229 |
6bef05eda8c4c912615cb27fa11cebf6e72b49d5 | 6,780 | h | C | cpp/interface/cpu_operations_interface.h | yiskylee/NICE | bdd625bf431fe29919b39207ca20a06cc7399ff9 | [
"MIT"
] | 4 | 2016-04-28T14:17:58.000Z | 2018-07-28T01:37:25.000Z | cpp/interface/cpu_operations_interface.h | yiskylee/NICE | bdd625bf431fe29919b39207ca20a06cc7399ff9 | [
"MIT"
] | 48 | 2016-05-04T12:47:02.000Z | 2017-12-14T19:58:49.000Z | cpp/interface/cpu_operations_interface.h | yiskylee/NICE | bdd625bf431fe29919b39207ca20a06cc7399ff9 | [
"MIT"
] | 19 | 2016-05-03T14:22:42.000Z | 2017-07-06T19:01:49.000Z | // The MIT License (MIT)
//
// Copyright (c) 2016 Northeastern University
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef CPP_INTERFACE_CPU_OPERATIONS_INTERFACE_H_
#define CPP_INTERFACE_CPU_OPERATIONS_INTERFACE_H_
#include <boost/python.hpp>
#include <iostream>
#include <string>
#include "Eigen/Core"
#include "Eigen/Dense"
#include "include/cpu_operations.h"
#include "include/kernel_types.h"
namespace Nice {
template<typename T>
using MatrixMap = Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic,
Eigen::Dynamic, Eigen::RowMajor> >;
template<typename T>
class CPUOperationsInterface {
public:
static void GenKernelMatrix(PyObject *input_obj, int row, int col,
std::string kernel_type,
float constant,
PyObject *kernel_matrix_obj) {
Py_buffer input_buf, kernel_matrix_buf;
PyObject_GetBuffer(input_obj, &input_buf, PyBUF_SIMPLE);
PyObject_GetBuffer(kernel_matrix_obj, &kernel_matrix_buf, PyBUF_SIMPLE);
MatrixMap <T> input(reinterpret_cast<T *>(input_buf.buf), row, col);
MatrixMap <T> kernel_matrix(reinterpret_cast<T *>
(kernel_matrix_buf.buf), row, row);
if (kernel_type == "Gaussian") {
kernel_matrix =
CpuOperations<T>::GenKernelMatrix(input,
kGaussianKernel,
constant);
PyBuffer_Release(&input_buf);
PyBuffer_Release(&kernel_matrix_buf);
} else {
std::cout << kernel_type << " not yet supported\n";
exit(1);
}
}
void MultiplyMatrix(PyObject *a_obj, int row_a, int col_a,
PyObject *b_obj, int row_b, int col_b,
PyObject *c_obj) {
Py_buffer a_buf, b_buf, c_buf;
PyObject_GetBuffer(a_obj, &a_buf, PyBUF_SIMPLE);
PyObject_GetBuffer(b_obj, &b_buf, PyBUF_SIMPLE);
PyObject_GetBuffer(c_obj, &c_buf, PyBUF_SIMPLE);
MatrixMap <T> a(reinterpret_cast<T *>(a_buf.buf), row_a, col_a);
MatrixMap <T> b(reinterpret_cast<T *>(b_buf.buf), row_b, col_b);
MatrixMap <T> c(reinterpret_cast<T *>(c_buf.buf), row_a, col_b);
c = CpuOperations<T>::Multiply(a, b);
PyBuffer_Release(&a_buf);
PyBuffer_Release(&b_buf);
PyBuffer_Release(&c_buf);
}
void MultiplyMatrix(PyObject *a_obj,
int row_a, int col_a,
PyObject *b_obj,
float scalar) {
Py_buffer a_buf, b_buf;
PyObject_GetBuffer(a_obj, &a_buf, PyBUF_SIMPLE);
PyObject_GetBuffer(b_obj, &b_buf, PyBUF_SIMPLE);
MatrixMap <T> a(reinterpret_cast<T *>(a_buf.buf), row_a, col_a);
MatrixMap <T> b(reinterpret_cast<T *>(b_buf.buf), row_a, col_a);
b = CpuOperations<T>::Multiply(a, scalar);
PyBuffer_Release(&a_buf);
PyBuffer_Release(&b_buf);
}
void InverseMatrix(PyObject *a_obj, int row_a, int col_a,
PyObject *b_obj) {
Py_buffer a_buf, b_buf;
PyObject_GetBuffer(a_obj, &a_buf, PyBUF_SIMPLE);
PyObject_GetBuffer(b_obj, &b_buf, PyBUF_SIMPLE);
MatrixMap <T> a(reinterpret_cast<T *>(a_buf.buf), row_a, col_a);
MatrixMap <T> b(reinterpret_cast<T *>(b_buf.buf), row_a, col_a);
b = CpuOperations<T>::Inverse(a);
PyBuffer_Release(&a_buf);
PyBuffer_Release(&b_buf);
}
void NormMatrix(PyObject *m_obj, int row_m, int col_m,
int p, int axis,
PyObject *v_obj) {
Py_buffer m_buf, v_buf;
PyObject_GetBuffer(m_obj, &m_buf, PyBUF_SIMPLE);
PyObject_GetBuffer(v_obj, &v_buf, PyBUF_SIMPLE);
MatrixMap <T> m(reinterpret_cast<T *>(m_buf.buf), row_m, col_m);
int row_v = 0;
if (axis == 0) {
row_v = col_m;
} else if (axis == 1) {
row_v = row_m;
}
MatrixMap <T> v(reinterpret_cast<T *>(v_buf.buf), row_v, 1);
v = CpuOperations<T>::Norm(m, p, axis);
PyBuffer_Release(&m_buf);
PyBuffer_Release(&v_buf);
}
void CenterMatrix(PyObject *m_obj, int row_m, int col_m,
int axis,
PyObject *c_obj) {
Py_buffer m_buf, c_buf;
PyObject_GetBuffer(m_obj, &m_buf, PyBUF_SIMPLE);
PyObject_GetBuffer(c_obj, &c_buf, PyBUF_SIMPLE);
MatrixMap <T> m(reinterpret_cast<T *>(m_buf.buf), row_m, col_m);
MatrixMap <T> c(reinterpret_cast<T *>(c_buf.buf), row_m, col_m);
c = CpuOperations<T>::Center(m, axis);
PyBuffer_Release(&m_buf);
PyBuffer_Release(&c_buf);
}
void NormalizeMatrix(PyObject *m_obj, int row_m, int col_m,
int p, int axis,
PyObject *n_obj) {
Py_buffer m_buf, n_buf;
PyObject_GetBuffer(m_obj, &m_buf, PyBUF_SIMPLE);
PyObject_GetBuffer(n_obj, &n_buf, PyBUF_SIMPLE);
MatrixMap <T> m(reinterpret_cast<T *>(m_buf.buf), row_m, col_m);
MatrixMap <T> n(reinterpret_cast<T *>(n_buf.buf), row_m, col_m);
n = CpuOperations<T>::Normalize(m, p, axis);
PyBuffer_Release(&m_buf);
PyBuffer_Release(&n_buf);
}
void StandardDeviationMatrix(PyObject *m_obj, int row_m, int col_m,
int axis,
PyObject *s_obj) {
Py_buffer m_buf, s_buf;
PyObject_GetBuffer(m_obj, &m_buf, PyBUF_SIMPLE);
PyObject_GetBuffer(s_obj, &s_buf, PyBUF_SIMPLE);
MatrixMap <T> m(reinterpret_cast<T *>(m_buf.buf), row_m, col_m);
int row_s = 0;
if (axis == 0) {
row_s = col_m;
} else if (axis == 1) {
row_s = row_m;
}
MatrixMap <T> s(reinterpret_cast<T *>(s_buf.buf), row_s, 1);
s = CpuOperations<T>::StandardDeviation(m, axis);
PyBuffer_Release(&m_buf);
PyBuffer_Release(&s_buf);
}
};
} // namespace Nice
#endif // CPP_INTERFACE_CPU_OPERATIONS_INTERFACE_H_
| 40.843373 | 80 | 0.65059 |
6adc2e7ca7ce4619bc54880bb7a5ad386f669dec | 1,343 | h | C | src/modules/comp/e_mod_comp_update.h | tizenorg/framework.uifw.e17 | da657a5ef0c9d2b780cbd7e26880058fe09acf4a | [
"BSD-2-Clause"
] | 3 | 2019-03-16T11:11:24.000Z | 2021-03-23T17:10:52.000Z | src/modules/comp/e_mod_comp_update.h | tizenorg/framework.uifw.e17 | da657a5ef0c9d2b780cbd7e26880058fe09acf4a | [
"BSD-2-Clause"
] | 2 | 2017-03-03T06:45:52.000Z | 2018-04-22T20:11:17.000Z | src/modules/comp/e_mod_comp_update.h | tizenorg/framework.uifw.e17 | da657a5ef0c9d2b780cbd7e26880058fe09acf4a | [
"BSD-2-Clause"
] | 1 | 2018-04-06T10:06:39.000Z | 2018-04-06T10:06:39.000Z | #ifdef E_TYPEDEFS
#else
#ifndef E_MOD_COMP_UPDATE_H
#define E_MOD_COMP_UPDATE_H
typedef struct _E_Update E_Update;
typedef struct _E_Update_Rect E_Update_Rect;
typedef enum _E_Update_Policy
{
E_UPDATE_POLICY_RAW,
E_UPDATE_POLICY_HALF_WIDTH_OR_MORE_ROUND_UP_TO_FULL_WIDTH,
} E_Update_Policy;
struct _E_Update_Rect
{
int x, y, w, h;
};
struct _E_Update
{
int w, h;
int tw, th;
int tsw, tsh;
unsigned char *tiles;
E_Update_Policy pol;
};
E_Update *e_mod_comp_update_new(void);
void e_mod_comp_update_free(E_Update *up);
void e_mod_comp_update_policy_set(E_Update *up,
E_Update_Policy pol);
void e_mod_comp_update_tile_size_set(E_Update *up,
int tsw,
int tsh);
void e_mod_comp_update_resize(E_Update *up,
int w,
int h);
void e_mod_comp_update_add(E_Update *up,
int x,
int y,
int w,
int h);
E_Update_Rect *e_mod_comp_update_rects_get(E_Update *up);
void e_mod_comp_update_clear(E_Update *up);
#endif
#endif
| 27.979167 | 61 | 0.547282 |
aca6239c13188c8ffae4965cd2b0c2803d138bc5 | 16,596 | c | C | Source/dll/sys/OpenLibSys.c | SuperHDD/WinRing0-v3.0.20-Source-ResDrv | 1571712f27687dbc9cd283c57e4b84e29176184f | [
"BSD-2-Clause"
] | 1 | 2021-11-15T18:54:18.000Z | 2021-11-15T18:54:18.000Z | Source/dll/sys/OpenLibSys.c | SuperHDD/WinRing0-v3.0.20-Source-ResDrv | 1571712f27687dbc9cd283c57e4b84e29176184f | [
"BSD-2-Clause"
] | null | null | null | Source/dll/sys/OpenLibSys.c | SuperHDD/WinRing0-v3.0.20-Source-ResDrv | 1571712f27687dbc9cd283c57e4b84e29176184f | [
"BSD-2-Clause"
] | 3 | 2020-05-11T04:09:31.000Z | 2022-02-22T13:10:28.000Z | //-----------------------------------------------------------------------------
// Author : hiyohiyo
// Mail : hiyohiyo@crystalmark.info
// Web : http://openlibsys.org/
// License : The modified BSD license
//
// Copyright 2007-2020 OpenLibSys.org. All rights reserved.
//-----------------------------------------------------------------------------
#include <ntddk.h>
#include <stddef.h>
#include "OpenLibSys.h"
//-----------------------------------------------------------------------------
//
// Global
//
//-----------------------------------------------------------------------------
static ULONG refCount;
//-----------------------------------------------------------------------------
//
// Classic NT driver
// DriverEntry / OlsDispatch / Unload
//
//-----------------------------------------------------------------------------
NTSTATUS
DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
/*
Return Value:
STATUS_SUCCESS if the driver initialized correctly, otherwise an erroror
indicating the reason for failure.
*/
{
NTSTATUS status;
UNICODE_STRING ntDeviceName;
UNICODE_STRING win32DeviceName;
PDEVICE_OBJECT deviceObject = NULL;
RtlInitUnicodeString(&ntDeviceName, NT_DEVICE_NAME);
status = IoCreateDevice(
DriverObject, // Our Driver Object
0, // We don't use a device extension
&ntDeviceName, // Device name
OLS_TYPE, // Device type
FILE_DEVICE_SECURE_OPEN, // Device characteristics
FALSE, // Not an exclusive device
&deviceObject ); // Returned ptr to Device Object
if(!NT_SUCCESS(status))
{
refCount = (ULONG)-1;
return status;
}
else
{
refCount = 0;
}
// Initialize the driver object with this driver's entry points.
DriverObject->MajorFunction[IRP_MJ_CREATE] = OlsDispatch;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = OlsDispatch;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = OlsDispatch;
DriverObject->DriverUnload = Unload;
// Initialize a Unicode String containing the Win32 name for our device.
RtlInitUnicodeString(&win32DeviceName, DOS_DEVICE_NAME);
// Create a symbolic link between our device name and the Win32 name
status = IoCreateSymbolicLink(&win32DeviceName, &ntDeviceName);
if (!NT_SUCCESS(status))
{
// Delete everything that this routine has allocated.
IoDeleteDevice( deviceObject );
}
return status;
}
NTSTATUS
OlsDispatch(
IN PDEVICE_OBJECT pDO,
IN PIRP pIrp
)
/*++
Routine Description:
This routine is the dispatch handler for the driver. It is responsible
for processing the IRPs.
Arguments:
pDO - Pointer to device object.
pIrp - Pointer to the current IRP.
Return Value:
STATUS_SUCCESS if the IRP was processed successfully, otherwise an erroror
indicating the reason for failure.
--*/
{
PIO_STACK_LOCATION pIrpStack;
NTSTATUS status;
int index;
// Initialize the irp info field.
// This is used to return the number of bytes transfered.
pIrp->IoStatus.Information = 0;
pIrpStack = IoGetCurrentIrpStackLocation(pIrp);
// Set default return status
status = STATUS_NOT_IMPLEMENTED;
// Dispatch based on major fcn code.
switch(pIrpStack->MajorFunction)
{
case IRP_MJ_CREATE:
if(refCount != (ULONG)-1){refCount++;}
status = STATUS_SUCCESS;
break;
case IRP_MJ_CLOSE:
if(refCount != (ULONG)-1){refCount--;}
status = STATUS_SUCCESS;
break;
case IRP_MJ_DEVICE_CONTROL:
// Dispatch on IOCTL
switch(pIrpStack->Parameters.DeviceIoControl.IoControlCode)
{
case IOCTL_OLS_GET_DRIVER_VERSION:
*(PULONG)pIrp->AssociatedIrp.SystemBuffer = OLS_DRIVER_VERSION;
pIrp->IoStatus.Information = 4;
status = STATUS_SUCCESS;
break;
case IOCTL_OLS_GET_REFCOUNT:
*(PULONG)pIrp->AssociatedIrp.SystemBuffer = refCount;
pIrp->IoStatus.Information = sizeof(refCount);
status = STATUS_SUCCESS;
break;
case IOCTL_OLS_READ_MSR:
status = ReadMsr(
pIrp->AssociatedIrp.SystemBuffer,
pIrpStack->Parameters.DeviceIoControl.InputBufferLength,
pIrp->AssociatedIrp.SystemBuffer,
pIrpStack->Parameters.DeviceIoControl.OutputBufferLength,
(ULONG*)&pIrp->IoStatus.Information
);
break;
case IOCTL_OLS_WRITE_MSR:
status = WriteMsr(
pIrp->AssociatedIrp.SystemBuffer,
pIrpStack->Parameters.DeviceIoControl.InputBufferLength,
pIrp->AssociatedIrp.SystemBuffer,
pIrpStack->Parameters.DeviceIoControl.OutputBufferLength,
(ULONG*)&pIrp->IoStatus.Information
);
break;
case IOCTL_OLS_READ_PMC:
status = ReadPmc(
pIrp->AssociatedIrp.SystemBuffer,
pIrpStack->Parameters.DeviceIoControl.InputBufferLength,
pIrp->AssociatedIrp.SystemBuffer,
pIrpStack->Parameters.DeviceIoControl.OutputBufferLength,
(ULONG*)&pIrp->IoStatus.Information
);
break;
case IOCTL_OLS_HALT:
__halt();
status = STATUS_SUCCESS;
break;
case IOCTL_OLS_READ_IO_PORT:
case IOCTL_OLS_READ_IO_PORT_BYTE:
case IOCTL_OLS_READ_IO_PORT_WORD:
case IOCTL_OLS_READ_IO_PORT_DWORD:
status = ReadIoPort(
pIrpStack->Parameters.DeviceIoControl.IoControlCode,
pIrp->AssociatedIrp.SystemBuffer,
pIrpStack->Parameters.DeviceIoControl.InputBufferLength,
pIrp->AssociatedIrp.SystemBuffer,
pIrpStack->Parameters.DeviceIoControl.OutputBufferLength,
(ULONG*)&pIrp->IoStatus.Information
);
break;
case IOCTL_OLS_WRITE_IO_PORT:
case IOCTL_OLS_WRITE_IO_PORT_BYTE:
case IOCTL_OLS_WRITE_IO_PORT_WORD:
case IOCTL_OLS_WRITE_IO_PORT_DWORD:
status = WriteIoPort(
pIrpStack->Parameters.DeviceIoControl.IoControlCode,
pIrp->AssociatedIrp.SystemBuffer,
pIrpStack->Parameters.DeviceIoControl.InputBufferLength,
pIrp->AssociatedIrp.SystemBuffer,
pIrpStack->Parameters.DeviceIoControl.OutputBufferLength,
(ULONG*)&pIrp->IoStatus.Information
);
break;
case IOCTL_OLS_READ_PCI_CONFIG:
status = ReadPciConfig(
pIrp->AssociatedIrp.SystemBuffer,
pIrpStack->Parameters.DeviceIoControl.InputBufferLength,
pIrp->AssociatedIrp.SystemBuffer,
pIrpStack->Parameters.DeviceIoControl.OutputBufferLength,
(ULONG*)&pIrp->IoStatus.Information
);
break;
case IOCTL_OLS_WRITE_PCI_CONFIG:
status = WritePciConfig(
pIrp->AssociatedIrp.SystemBuffer,
pIrpStack->Parameters.DeviceIoControl.InputBufferLength,
pIrp->AssociatedIrp.SystemBuffer,
pIrpStack->Parameters.DeviceIoControl.OutputBufferLength,
(ULONG*)&pIrp->IoStatus.Information
);
break;
case IOCTL_OLS_READ_MEMORY:
status = ReadMemory(
pIrp->AssociatedIrp.SystemBuffer,
pIrpStack->Parameters.DeviceIoControl.InputBufferLength,
pIrp->AssociatedIrp.SystemBuffer,
pIrpStack->Parameters.DeviceIoControl.OutputBufferLength,
(ULONG*)&pIrp->IoStatus.Information
);
break;
case IOCTL_OLS_WRITE_MEMORY:
status = WriteMemory(
pIrp->AssociatedIrp.SystemBuffer,
pIrpStack->Parameters.DeviceIoControl.InputBufferLength,
pIrp->AssociatedIrp.SystemBuffer,
pIrpStack->Parameters.DeviceIoControl.OutputBufferLength,
(ULONG*)&pIrp->IoStatus.Information
);
break;
}
break;
}
// We're done with I/O request. Record the status of the I/O action.
pIrp->IoStatus.Status = status;
// Don't boost priority when returning since this took little time.
IoCompleteRequest(pIrp, IO_NO_INCREMENT);
return status;
}
VOID
Unload(
IN PDRIVER_OBJECT DriverObject
)
/*++
Routine Description:
This routine is called by the I/O system to unload the driver.
Any resources previously allocated must be freed.
Arguments:
DriverObject - a pointer to the object that represents our driver.
Return Value:
None
--*/
{
PDEVICE_OBJECT deviceObject = DriverObject->DeviceObject;
UNICODE_STRING win32NameString;
PAGED_CODE();
// Create counted string version of our Win32 device name.
RtlInitUnicodeString(&win32NameString, DOS_DEVICE_NAME);
// Delete the link from our device name to a name in the Win32 namespace.
IoDeleteSymbolicLink(&win32NameString);
if(deviceObject != NULL)
{
IoDeleteDevice(deviceObject);
}
}
//-----------------------------------------------------------------------------
//
// CPU
//
//-----------------------------------------------------------------------------
NTSTATUS
ReadMsr( void *lpInBuffer,
ULONG nInBufferSize,
void *lpOutBuffer,
ULONG nOutBufferSize,
ULONG *lpBytesReturned)
{
__try
{
ULONGLONG data = __readmsr(*(ULONG*)lpInBuffer);
memcpy((PULONG)lpOutBuffer, &data, 8);
*lpBytesReturned = 8;
return STATUS_SUCCESS;
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
*lpBytesReturned = 0;
return STATUS_UNSUCCESSFUL;
}
}
NTSTATUS
WriteMsr( void *lpInBuffer,
ULONG nInBufferSize,
void *lpOutBuffer,
ULONG nOutBufferSize,
ULONG *lpBytesReturned)
{
__try
{
OLS_WRITE_MSR_INPUT* param;
param = (OLS_WRITE_MSR_INPUT*)lpInBuffer;
__writemsr(param->Register, param->Value.QuadPart);
*lpBytesReturned = 0;
return STATUS_SUCCESS;
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
*lpBytesReturned = 0;
return STATUS_UNSUCCESSFUL;
}
}
NTSTATUS
ReadPmc( void *lpInBuffer,
ULONG nInBufferSize,
void *lpOutBuffer,
ULONG nOutBufferSize,
ULONG *lpBytesReturned)
{
__try
{
ULONGLONG data = __readpmc(*(ULONG*)lpInBuffer);
memcpy((PULONG)lpOutBuffer, &data, 8);
*lpBytesReturned = 8;
return STATUS_SUCCESS;
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
*lpBytesReturned = 0;
return STATUS_UNSUCCESSFUL;
}
}
//-----------------------------------------------------------------------------
//
// IO Port
//
//-----------------------------------------------------------------------------
NTSTATUS
ReadIoPort( ULONG ioControlCode,
void *lpInBuffer,
ULONG nInBufferSize,
void *lpOutBuffer,
ULONG nOutBufferSize,
ULONG *lpBytesReturned)
{
ULONG nPort = *(ULONG*)lpInBuffer;
switch(ioControlCode)
{
case IOCTL_OLS_READ_IO_PORT_BYTE:
*(PUCHAR)lpOutBuffer = READ_PORT_UCHAR((PUCHAR)(ULONG_PTR)nPort);
break;
case IOCTL_OLS_READ_IO_PORT_WORD:
*(PUSHORT)lpOutBuffer = READ_PORT_USHORT((PUSHORT)(ULONG_PTR)nPort);
break;
case IOCTL_OLS_READ_IO_PORT_DWORD:
*(PULONG)lpOutBuffer = READ_PORT_ULONG((PULONG)(ULONG_PTR)nPort);
break;
default:
*lpBytesReturned = 0;
return STATUS_INVALID_PARAMETER;
break;
}
*lpBytesReturned = nInBufferSize;
return STATUS_SUCCESS;
}
NTSTATUS
WriteIoPort(ULONG ioControlCode,
void *lpInBuffer,
ULONG nInBufferSize,
void *lpOutBuffer,
ULONG nOutBufferSize,
ULONG *lpBytesReturned)
{
ULONG nPort;
OLS_WRITE_IO_PORT_INPUT* param;
param = (OLS_WRITE_IO_PORT_INPUT*)lpInBuffer;
nPort = param->PortNumber;
switch(ioControlCode)
{
case IOCTL_OLS_WRITE_IO_PORT_BYTE:
WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)nPort, param->CharData);
break;
case IOCTL_OLS_WRITE_IO_PORT_WORD:
WRITE_PORT_USHORT((PUSHORT)(ULONG_PTR)nPort, param->ShortData);
break;
case IOCTL_OLS_WRITE_IO_PORT_DWORD:
WRITE_PORT_ULONG((PULONG)(ULONG_PTR)nPort, param->LongData);
break;
default:
return STATUS_INVALID_PARAMETER;
break;
}
return STATUS_SUCCESS;
}
//-----------------------------------------------------------------------------
//
// PCI
//
//-----------------------------------------------------------------------------
NTSTATUS
ReadPciConfig( void *lpInBuffer,
ULONG nInBufferSize,
void *lpOutBuffer,
ULONG nOutBufferSize,
ULONG *lpBytesReturned)
{
OLS_READ_PCI_CONFIG_INPUT *param;
NTSTATUS status;
if(nInBufferSize != sizeof(OLS_READ_PCI_CONFIG_INPUT))
{
return STATUS_INVALID_PARAMETER;
}
param = (OLS_READ_PCI_CONFIG_INPUT *)lpInBuffer;
status = pciConfigRead(param->PciAddress, param->PciOffset,
lpOutBuffer, nOutBufferSize);
if(status == STATUS_SUCCESS)
{
*lpBytesReturned = nOutBufferSize;
}
else
{
*lpBytesReturned = 0;
}
return status;
}
NTSTATUS
WritePciConfig( void *lpInBuffer,
ULONG nInBufferSize,
void *lpOutBuffer,
ULONG nOutBufferSize,
ULONG *lpBytesReturned)
{
OLS_WRITE_PCI_CONFIG_INPUT *param;
ULONG writeSize;
NTSTATUS status;
if(nInBufferSize < offsetof(OLS_WRITE_PCI_CONFIG_INPUT, Data))
{
return STATUS_INVALID_PARAMETER;
}
param = (OLS_WRITE_PCI_CONFIG_INPUT *)lpInBuffer;
writeSize = nInBufferSize - offsetof(OLS_WRITE_PCI_CONFIG_INPUT, Data);
*lpBytesReturned = 0;
return pciConfigWrite(param->PciAddress, param->PciOffset,
¶m->Data, writeSize);
}
//-----------------------------------------------------------------------------
//
// Support Function
//
//-----------------------------------------------------------------------------
NTSTATUS pciConfigRead(ULONG pciAddress, ULONG offset, void *data, int length)
{
PCI_SLOT_NUMBER slot;
int error;
ULONG busNumber;
busNumber = PciGetBus(pciAddress);
slot.u.AsULONG = 0;
slot.u.bits.DeviceNumber = PciGetDev(pciAddress);
slot.u.bits.FunctionNumber = PciGetFunc(pciAddress);
error = HalGetBusDataByOffset(PCIConfiguration, busNumber, slot.u.AsULONG,
data, offset, length);
if(error == 0)
{
return OLS_ERROR_PCI_BUS_NOT_EXIST;
}
else if(length != 2 && error == 2)
{
return OLS_ERROR_PCI_NO_DEVICE;
}
else if(length != error)
{
return OLS_ERROR_PCI_READ_CONFIG;
}
return STATUS_SUCCESS;
}
NTSTATUS pciConfigWrite(ULONG pciAddress, ULONG offset, void *data, int length)
{
PCI_SLOT_NUMBER slot;
int error;
ULONG busNumber;
busNumber = PciGetBus(pciAddress);
slot.u.AsULONG = 0;
slot.u.bits.DeviceNumber = PciGetDev(pciAddress);
slot.u.bits.FunctionNumber = PciGetFunc(pciAddress);
error = HalSetBusDataByOffset(PCIConfiguration, busNumber, slot.u.AsULONG,
data, offset, length);
if(error != length)
{
return OLS_ERROR_PCI_WRITE_CONFIG;
}
return STATUS_SUCCESS;
}
//-----------------------------------------------------------------------------
//
// Physical Memory
//
//-----------------------------------------------------------------------------
NTSTATUS
ReadMemory( void *lpInBuffer,
ULONG nInBufferSize,
void *lpOutBuffer,
ULONG nOutBufferSize,
ULONG *lpBytesReturned)
{
OLS_READ_MEMORY_INPUT *param;
ULONG size;
PHYSICAL_ADDRESS address;
PVOID maped;
BOOLEAN error;
if(nInBufferSize != sizeof(OLS_READ_MEMORY_INPUT))
{
return STATUS_INVALID_PARAMETER;
}
param = (OLS_READ_MEMORY_INPUT *)lpInBuffer;
size = param->UnitSize * param->Count;
if(nOutBufferSize < size)
{
return STATUS_INVALID_PARAMETER;
}
address.QuadPart = param->Address.QuadPart;
#ifndef _PHYSICAL_MEMORY_SUPPORT
if(0x000C0000 > address.QuadPart
|| (address.QuadPart + size - 1) > 0x000FFFFF)
{
return STATUS_INVALID_PARAMETER;
}
#endif
maped = MmMapIoSpace(address, size, FALSE);
error = FALSE;
switch(param->UnitSize){
case 1:
READ_REGISTER_BUFFER_UCHAR(maped, lpOutBuffer, param->Count);
break;
case 2:
READ_REGISTER_BUFFER_USHORT(maped, lpOutBuffer, param->Count);
break;
case 4:
READ_REGISTER_BUFFER_ULONG(maped, lpOutBuffer, param->Count);
break;
default:
error = TRUE;
break;
}
MmUnmapIoSpace(maped, size);
if(error)
{
return STATUS_INVALID_PARAMETER;
}
*lpBytesReturned = nOutBufferSize;
return STATUS_SUCCESS;
}
NTSTATUS
WriteMemory(void *lpInBuffer,
ULONG nInBufferSize,
void *lpOutBuffer,
ULONG nOutBufferSize,
ULONG *lpBytesReturned)
{
#ifdef _PHYSICAL_MEMORY_SUPPORT
OLS_WRITE_MEMORY_INPUT *param;
ULONG size;
PHYSICAL_ADDRESS address;
PVOID maped;
BOOLEAN error;
if(nInBufferSize < offsetof(OLS_WRITE_MEMORY_INPUT, Data))
{
return STATUS_INVALID_PARAMETER;
}
param = (OLS_WRITE_MEMORY_INPUT *)lpInBuffer;
size = param->UnitSize * param->Count;
if (nInBufferSize < size + offsetof(OLS_WRITE_MEMORY_INPUT, Data))
{
return STATUS_INVALID_PARAMETER;
}
address.QuadPart = param->Address.QuadPart;
maped = MmMapIoSpace(address, size, FALSE);
error = FALSE;
switch(param->UnitSize){
case 1:
WRITE_REGISTER_BUFFER_UCHAR(maped,
(UCHAR*)¶m->Data, param->Count);
break;
case 2:
WRITE_REGISTER_BUFFER_USHORT(maped,
(USHORT*)¶m->Data, param->Count);
break;
case 4:
WRITE_REGISTER_BUFFER_ULONG(maped,
(ULONG*)¶m->Data, param->Count);
break;
default:
error = TRUE;
break;
}
MmUnmapIoSpace(maped, size);
if(error)
{
return STATUS_INVALID_PARAMETER;
}
*lpBytesReturned = 0;
return STATUS_SUCCESS;
#else
*lpBytesReturned = 0;
return STATUS_INVALID_PARAMETER;
#endif
}
| 23.211189 | 79 | 0.67444 |
3a8bbe8ce6cb2338cd54f38071a36c9cfe0e6221 | 4,287 | h | C | Tools/WebKitTestRunner/PlatformWebView.h | jacadcaps/webkitty | 9aebd2081349f9a7b5d168673c6f676a1450a66d | [
"BSD-2-Clause"
] | 6 | 2021-07-05T16:09:39.000Z | 2022-03-06T22:44:42.000Z | Tools/WebKitTestRunner/PlatformWebView.h | jacadcaps/webkitty | 9aebd2081349f9a7b5d168673c6f676a1450a66d | [
"BSD-2-Clause"
] | 7 | 2022-03-15T13:25:39.000Z | 2022-03-15T13:25:44.000Z | Tools/WebKitTestRunner/PlatformWebView.h | jacadcaps/webkitty | 9aebd2081349f9a7b5d168673c6f676a1450a66d | [
"BSD-2-Clause"
] | null | null | null | /*
* Copyright (C) 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "TestOptions.h"
#include <wtf/FastMalloc.h>
#if PLATFORM(COCOA) && !defined(BUILDING_GTK__)
#include <WebKit/WKFoundation.h>
#include <wtf/RetainPtr.h>
OBJC_CLASS NSView;
OBJC_CLASS UIView;
OBJC_CLASS TestRunnerWKWebView;
OBJC_CLASS WKWebViewConfiguration;
OBJC_CLASS WebKitTestRunnerWindow;
typedef struct CGImage *CGImageRef;
typedef TestRunnerWKWebView *PlatformWKView;
typedef WebKitTestRunnerWindow *PlatformWindow;
typedef RetainPtr<CGImageRef> PlatformImage;
#elif defined(BUILDING_GTK__)
typedef struct _GtkWidget GtkWidget;
typedef WKViewRef PlatformWKView;
typedef GtkWidget* PlatformWindow;
#elif PLATFORM(WPE)
namespace WPEToolingBackends {
class HeadlessViewBackend;
}
typedef WKViewRef PlatformWKView;
typedef WPEToolingBackends::HeadlessViewBackend* PlatformWindow;
#elif PLATFORM(WIN)
#if USE(DIRECT2D)
#include <d2d1_1.h>
#else
#include <cairo.h>
#endif
class TestRunnerWindow;
typedef HWND PlatformWindow;
typedef WKViewRef PlatformWKView;
#endif
#if USE(CAIRO)
typedef cairo_surface_t* PlatformImage;
#elif USE(DIRECT2D)
interface ID2D1Bitmap;
typedef ID2D1Bitmap* PlatformImage;
#endif
namespace WTR {
class PlatformWebView {
WTF_MAKE_FAST_ALLOCATED;
public:
#if PLATFORM(COCOA)
PlatformWebView(WKWebViewConfiguration*, const TestOptions&);
#else
PlatformWebView(WKPageConfigurationRef, const TestOptions&);
#endif
~PlatformWebView();
WKPageRef page();
PlatformWKView platformView() { return m_view; }
PlatformWindow platformWindow() { return m_window; }
static PlatformWindow keyWindow();
enum class WebViewSizingMode {
Default,
HeightRespectsStatusBar
};
void resizeTo(unsigned width, unsigned height, WebViewSizingMode = WebViewSizingMode::Default);
void focus();
WKRect windowFrame();
void setWindowFrame(WKRect, WebViewSizingMode = WebViewSizingMode::Default);
void didInitializeClients();
void addChromeInputField();
void removeChromeInputField();
void makeWebViewFirstResponder();
void setWindowIsKey(bool);
bool windowIsKey() const { return m_windowIsKey; }
bool drawsBackground() const;
void setDrawsBackground(bool);
void setEditable(bool);
void removeFromWindow();
void addToWindow();
bool viewSupportsOptions(const TestOptions& options) const { return !options.runSingly && m_options.hasSameInitializationOptions(options); }
PlatformImage windowSnapshotImage();
const TestOptions& options() const { return m_options; }
void changeWindowScaleIfNeeded(float newScale);
void setNavigationGesturesEnabled(bool);
#if PLATFORM(GTK)
void dismissAllPopupMenus();
#endif
private:
void forceWindowFramesChanged();
PlatformWKView m_view;
PlatformWindow m_window;
bool m_windowIsKey;
const TestOptions m_options;
#if PLATFORM(GTK)
GtkWidget* m_otherWindow { nullptr };
#endif
};
} // namespace WTR
| 30.190141 | 144 | 0.767203 |
b1bcb21b3a111ffb2f1c7fea98886ace9cf57762 | 60 | h | C | extlibs/freetype-2.5.2/src/otvalid/PaxHeaders.20920/otvalid.h | halak/bibim | ad01efa8aac4f074f64bf033ac0f1ed382060334 | [
"curl"
] | 3 | 2016-08-28T06:48:11.000Z | 2019-12-04T13:04:34.000Z | extlibs/freetype-2.5.2/src/otvalid/PaxHeaders.20920/otvalid.h | Darkttd/Bibim | 9dec24529ef89536f7686abc1245ea5fc7fa9474 | [
"curl"
] | 8 | 2016-04-24T13:07:28.000Z | 2016-06-01T10:04:42.000Z | extlibs/freetype-2.5.2/src/otvalid/PaxHeaders.20920/otvalid.h | Darkttd/Bibim | 9dec24529ef89536f7686abc1245ea5fc7fa9474 | [
"curl"
] | 1 | 2016-08-28T06:47:43.000Z | 2016-08-28T06:47:43.000Z | 30 atime=1386526222.085502923
30 ctime=1374498495.884317616
| 20 | 29 | 0.866667 |
5570cfbafc508241f108626abe8065edd65043ca | 1,281 | c | C | 00_graph_bench/src/structures/worklist.c | atmughrabi/OpenGraph | 12e7f8632f86b89ca360ff58a20c5a39009a22e5 | [
"BSD-2-Clause"
] | 6 | 2019-12-15T02:37:57.000Z | 2021-02-02T05:10:01.000Z | 00_graph_bench/src/structures/worklist.c | atmughrabi/OpenGraph | 12e7f8632f86b89ca360ff58a20c5a39009a22e5 | [
"BSD-2-Clause"
] | null | null | null | 00_graph_bench/src/structures/worklist.c | atmughrabi/OpenGraph | 12e7f8632f86b89ca360ff58a20c5a39009a22e5 | [
"BSD-2-Clause"
] | 1 | 2020-12-16T05:52:50.000Z | 2020-12-16T05:52:50.000Z | // -----------------------------------------------------------------------------
//
// "00_AccelGraph"
//
// -----------------------------------------------------------------------------
// Copyright (c) 2014-2019 All rights reserved
// -----------------------------------------------------------------------------
// Author : Abdullah Mughrabi
// Email : atmughra@ncsu.edu||atmughrabi@gmail.com
// File : bitmap.c
// Create : 2019-06-21 17:15:17
// Revise : 2019-09-28 15:36:13
// Editor : Abdullah Mughrabi
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdint.h>
#include <omp.h>
#include "myMalloc.h"
#include "worklist.h"
void swapWorkLists (uint8_t **workList1, uint8_t **workList2)
{
uint8_t *workList_temp = *workList1;
*workList1 = *workList2;
*workList2 = workList_temp;
}
void resetWorkList(uint8_t *workList, uint32_t size)
{
uint32_t i;
#pragma omp parallel for
for(i = 0; i < size ; i++)
{
workList[i] = 0;
}
}
void setWorkList(uint8_t *workList, uint32_t size)
{
uint32_t i;
#pragma omp parallel for
for(i = 0; i < size ; i++)
{
workList[i] = 1;
}
} | 20.333333 | 80 | 0.466042 |
cd9c6d0f39c741f57edf09f98827ddaa3aceef8b | 35 | h | C | Engine/Source/ThirdParty/MCPP/mcpp-2.7.2/test-l/nest98.h | windystrife/UnrealEngine_NVIDIAGameWork | b50e6338a7c5b26374d66306ebc7807541ff815e | [
"MIT"
] | 34 | 2021-06-15T10:24:49.000Z | 2022-03-22T19:20:23.000Z | Engine/Source/ThirdParty/MCPP/mcpp-2.7.2/test-l/nest98.h | windystrife/UnrealEngine_NVIDIAGameWork | b50e6338a7c5b26374d66306ebc7807541ff815e | [
"MIT"
] | 9 | 2021-03-04T21:34:03.000Z | 2021-05-04T18:33:47.000Z | Engine/Source/ThirdParty/MCPP/mcpp-2.7.2/test-l/nest98.h | PopCap/GameIdea | 201e1df50b2bc99afc079ce326aa0a44b178a391 | [
"BSD-2-Clause"
] | 2 | 2021-12-29T01:15:22.000Z | 2022-02-01T10:53:15.000Z | /* nest98.h */
#include "nest99.h"
| 11.666667 | 19 | 0.6 |
35b7bc6c369935e96c726cde10dfc91d83672b13 | 16,013 | h | C | fboss/agent/SwSwitch.h | NunoEdgarGFlowHub/fboss | b665a1dac4917dd8984573ef5a471e4825d506f9 | [
"BSD-3-Clause"
] | 1 | 2015-03-12T11:40:43.000Z | 2015-03-12T11:40:43.000Z | fboss/agent/SwSwitch.h | NunoEdgarGFlowHub/fboss | b665a1dac4917dd8984573ef5a471e4825d506f9 | [
"BSD-3-Clause"
] | null | null | null | fboss/agent/SwSwitch.h | NunoEdgarGFlowHub/fboss | b665a1dac4917dd8984573ef5a471e4825d506f9 | [
"BSD-3-Clause"
] | null | null | null | /*
* Copyright (c) 2004-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#pragma once
#include "fboss/agent/HwSwitch.h"
#include "fboss/agent/state/StateUpdate.h"
#include "fboss/agent/types.h"
#include "fboss/agent/NeighborUpdater.h"
#include <folly/SpinLock.h>
#include <folly/IntrusiveList.h>
#include <folly/Range.h>
#include <folly/ThreadLocal.h>
#include <folly/io/async/EventBase.h>
#include <atomic>
#include <memory>
#include <mutex>
#include <thread>
namespace facebook { namespace fboss {
class ArpHandler;
class IPv4Handler;
class IPv6Handler;
class PktCaptureManager;
class Platform;
class Port;
class PortStats;
class RxPacket;
class SwitchState;
class SwitchStats;
class TunManager;
class SfpModule;
class SfpMap;
class SfpImpl;
class LldpManager;
/*
* A software representation of a switch.
*
* This represents an entire switch in the network (as opposed to a single
* switch ASIC).
*
* SwSwitch is the primary entry point into the FBOSS controller. It provides
* all of the hardware-independent logic for switching and routing packets. It
* must be used in conjunction with a HwSwitch object, which provides an
* interface to the switch hardware.
*/
class SwSwitch : public HwSwitch::Callback {
// Ordered set of run states for SwSwitch,
// SwSwitch can only move forward from a
// lower numbered state to the next
enum class SwitchRunState: int {
UNINITIALIZED,
INITIALIZED,
CONFIGURED,
FIB_SYNCED,
EXITING
};
public:
typedef std::function<
std::shared_ptr<SwitchState>(const std::shared_ptr<SwitchState>&)>
StateUpdateFn;
explicit SwSwitch(std::unique_ptr<Platform> platform);
virtual ~SwSwitch();
HwSwitch* getHw() const {
return hw_;
}
const Platform* getPlatform() const { return platform_.get(); }
Platform* getPlatform() { return platform_.get(); }
/**
* Return the vlan where the CPU sits
*
* This vlan ID is used to encode the l2 vlan info when CPU sends traffic
* through the HW.
* Note: It does not mean the HW will send the packet with this vlan value.
* For example, Broadcom HW will overwrite this value based on its egress
* programming.
*/
VlanID getCPUVlan() const {
return VlanID(4095);
}
/*
* Initialize the switch.
*
* This initializes the underlying hardware, and populates the current
* SwitchState to reflect the hardware state.
*
* Note that this function is generally slow, and may take many seconds to
* complete.
*
* @param enableIntfSync By default, interface sync to system is disabled,
* since unittest code does not have the permission to
* create/delete interface in the system.
*/
void init(bool enableIntfSync = false);
bool isFullyInitialized() const;
bool isConfigured() const;
bool isFibSynced() const;
bool isExiting() const;
void applyConfig(const std::string& configPath);
/*
* Get a pointer to the current switch state.
*
* This returns a pointer to the current state. However, note that the state
* may be modified by another thread immediately after getState() returns,
* in which case the caller may now have an out-of-date copy of the state.
* See the comments in SwitchState.h for more details about the copy-on-write
* semantics of SwitchState.
*/
std::shared_ptr<SwitchState> getState() const {
folly::SpinLockGuard guard(stateLock_);
return stateDontUseDirectly_;
}
/**
* Schedule an update to the switch state.
*
* This schedules the specified StateUpdate to be invoked in the update
* thread in order to update the SwitchState.
*/
void updateState(std::unique_ptr<StateUpdate> update);
/**
* Schedule an update to the switch state.
*
* @param name A name to identify the source of this update. This is
* primarily used for logging and debugging purposes.
* @param fn The function that will prepare the new SwitchState.
*
* The StateUpdateFn takes a single argument -- the current SwitchState
* object to modify. It should return a new SwitchState object, or null if
* it decides that no update needs to be performed.
*
* Note that the update function will not be called immediately--it wil be
* invoked later from the update thread. Therefore if you supply a lambda
* with bound arguments, make sure that any bound arguments will still be
* valid later when the function is invoked. (e.g., Don't capture local
* variables from your current call frame by reference.)
*
* The StateUpdateFn must not throw any exceptions.
*
* The update thread may choose to batch updates in some cases--if it has
* multiple update functions to run it may run them all at once and only
* send a single update notification to the HwSwitch and other update
* subscribers. Therefore the StateUpdateFn may be called with an
* unpublished SwitchState in some cases.
*/
void updateState(folly::StringPiece name, StateUpdateFn fn);
/*
* A version of updateState() that doesn't return until the update has been
* applied.
*
* This should only be called in situations where it is safe to block the
* current thread until the operation completes.
*
* Note: Currently this code applies the update in the current thread.
* However, don't rely on this behavior. We may change this in the future to
* apply all updates from a the single thread. In this case
* updateStateBlocking() would schedule the update to happen in the update
* thread, and would simply block the calling thread until the operation
* completes.
*/
void updateStateBlocking(folly::StringPiece name, StateUpdateFn fn);
/*
* Signal to the switch that initial config is applied.
* The switch may then use this to start certain functions
* which make sense only after the initial config has been
* applied. As an example it makes sense to start the packet
* receieve only after applying the initial config, else in
* case of a warm boot this causes us to receive packets tagged
* with a vlan which software switch state does not even know
* about. OTOH in case of a cold boot it causes host entries
* to be created in the wrong (default VLAN).
*/
void initialConfigApplied();
void fibSynced();
/*
* Publish all thread-local stats to the main fbData singleton,
* so they will be visible via fb303 thrift calls.
*
* This method should be called once per second. It can be called from any
* thread.
*/
void publishStats();
/*
* Get the SwitchStats for the current thread.
*
* This object should only be used from the current thread. It should never
* be stored and used in other threads.
*/
SwitchStats* stats() {
SwitchStats* s = stats_.get();
if (s) {
return s;
}
return createSwitchStats();
}
/*
* Get the PortStats for the specified port.
*
* Note that this returns a thread-local object specific to the current
* thread.
*/
PortStats* portStats(PortID port);
/*
* Get PortStatus for all the ports.
*/
std::map<int32_t, PortStatus> getPortStatus();
/*
* Get PortStatus of the specified port.
*/
PortStatus getPortStatus(PortID port);
/*
* Get the Sfp for the specified port.
*/
SfpModule* getSfp(PortID port) const;
/*
* Get SfpDoms for all the ports.
*/
std::map<int32_t, SfpDom> getSfpDoms() const;
/*
* Get SfpDom of the specified port.
*/
SfpDom getSfpDom(PortID port) const;
/*
* Create Sfp mapping for the port in the SFP map.
*/
void createSfp(PortID portID, std::unique_ptr<SfpImpl>& sfpImpl);
/*
* This function is used to detect all the SFPs in the SFP Map
*/
void detectSfp();
/*
* This function is update the SFP Dom realtime cache values
*/
void updateSfpDomFields();
/*
* Get the PortStats for the ingress port of this packet.
*/
PortStats* portStats(const RxPacket* pkt);
PortStats* portStats(const std::unique_ptr<RxPacket>& pkt) {
return portStats(pkt.get());
}
/*
* Get the EventBase for the background thread
*/
folly::EventBase* getBackgroundEVB() {
return &backgroundEventBase_;
}
/*
* Get the EventBase for the update thread
*/
folly::EventBase* getUpdateEVB() {
return &updateEventBase_;
}
// HwSwitch::Callback methods
void packetReceived(std::unique_ptr<RxPacket> pkt) noexcept override;
void linkStateChanged(PortID port, bool up) noexcept override;
void exitFatal() const noexcept override;
/*
* Allocate a new TxPacket.
*/
std::unique_ptr<TxPacket> allocatePacket(uint32_t size);
/**
* Allocate a TxPacket, which is used to send out through HW
*
* The caller of the function provides the minimum size of space needed
* in the packet to store L3 packet. The function adds L2 header size and
* also makes sure packet size meeting minimum packet size.
*
* The IOBuf returned through the packet will have some headroom reserved
* already which can be used to write L2 header. The caller is expected
* to write the L3 contents starting from writableTail().
*
* @param l3Len L3 packet size
* @return The unique pointer to a Tx packet
*/
std::unique_ptr<TxPacket> allocateL3TxPacket(uint32_t l3Len);
void sendPacketOutOfPort(std::unique_ptr<TxPacket> pkt,
PortID portID) noexcept;
/*
* Send a packet, using switching logic to send it out the correct port(s)
* for the specified VLAN and destination MAC.
*/
void sendPacketSwitched(std::unique_ptr<TxPacket> pkt) noexcept;
/**
* Send out L3 packet through HW
*
* The L3 packet is supposed to be stored starting from pkt->buf()->data(),
* whose length is provided through pkt->buf()->length().
*
* The caller of the function has to make sure the IOBuf in the packet has
* enough headroom (EthHdr::SIZE) to store the L2 header. Also the
* IOBuf is bigger enough to hold a minimum size of packet (68). The packet
* allocated by allocateL3TxPacket() is guaranteed for the above requirements.
* If any of the above reuqirements is not met, the packet will be dropped.
*
* The function will prepend the L2 header to the L3 packet before it is
* sent out.
*
* @param pkt The packet that has L3 packet stored to send out
*/
void sendL3Packet(RouterID rid, std::unique_ptr<TxPacket> pkt) noexcept;
/**
* method to send out a packet from HW to host.
*
* @return true The packet is sent to host
* false The packet is dropped due to errors
*/
bool sendPacketToHost(std::unique_ptr<RxPacket> pkt);
/**
* Get the ArpHandler object.
*
* The ArpHandler returned is owned by the SwSwitch, and is only valid as
* long as the SwSwitch object.
*/
ArpHandler* getArpHandler() {
return arp_.get();
}
/**
* Get the IPv6Handler object.
*
* The IPv6Handler returned is owned by the SwSwitch, and is only valid as
* long as the SwSwitch object.
*/
IPv6Handler* getIPv6Handler() {
return ipv6_.get();
}
/**
* Get the NeighborUpdater object.
*
* The NeighborUpdater returned is owned by the SwSwitch, and is only valid as
* long as the SwSwitch object.
*/
NeighborUpdater* getNeighborUpdater() {
return nUpdater_.get();
}
/*
* Get the PktCaptureManager object.
*/
PktCaptureManager* getCaptureMgr() {
return pcapMgr_.get();
}
/*
* Allow hardware to perform any warm boot related cleanup
* before we exit the application.
*/
void gracefulExit();
/*
* Done with programming.
* This is primarily used to signal to warm boot code
* to delete entries from h/w tables for which this was
* the last owner.
*/
void clearWarmBootCache();
BootType getBootType() const { return bootType_; }
/*
* Serializes the switch and dumps the result into the given file.
*/
void dumpStateToFile(const std::string& filename) const;
/*
* Get port operational state
*/
bool isPortUp(PortID port) const;
private:
typedef folly::IntrusiveList<StateUpdate, &StateUpdate::listHook_>
StateUpdateList;
// Forbidden copy constructor and assignment operator
SwSwitch(SwSwitch const &) = delete;
SwSwitch& operator=(SwSwitch const &) = delete;
/*
* Update the current state pointer.
*/
void setStateInternal(std::shared_ptr<SwitchState> newState);
/*
* This function publishes the SFP Dom data (real time values
* and thresholds to the local in-memory ServiceData Structure
* along with the presence and dom supported status flags.
* These values are published by the fbagent to the ODS based
* on the Monitoring configuration.
*/
void publishSfpInfo();
void publishRouteStats();
void syncTunInterfaces();
void publishBootType();
SwitchRunState getSwitchRunState() const;
void setSwitchRunState(SwitchRunState desiredState);
SwitchStats* createSwitchStats();
void handlePacket(std::unique_ptr<RxPacket> pkt);
static void handlePendingUpdatesHelper(SwSwitch* sw);
void handlePendingUpdates();
void applyUpdate(const std::shared_ptr<SwitchState>& oldState,
const std::shared_ptr<SwitchState>& newState);
void startThreads();
void stopThreads();
void stop();
void threadLoop(folly::StringPiece name, folly::EventBase* eventBase);
/*
* File where switch state gets dumped on exit
*/
std::string getSwitchStateFile() const;
// The HwSwitch object. This object is owned by the Platform.
HwSwitch* hw_;
std::unique_ptr<Platform> platform_;
std::atomic<SwitchRunState> runState_{SwitchRunState::UNINITIALIZED};
folly::ThreadLocalPtr<SwitchStats, SwSwitch> stats_;
/**
* The object to sync the interfaces to the system. This pointer could
* be nullptr if interface sync is not enabled during init()
*/
std::unique_ptr<TunManager> tunMgr_;
/*
* A list of pending state updates to be applied.
*/
folly::SpinLock pendingUpdatesLock_;
StateUpdateList pendingUpdates_;
/*
* hwMutex_ is held around all modifying calls that we make to hw_.
*
* This is primarily provided as a convenience so that the individual
* HwSwitch implementations do not need to provide their own internal
* locking.
*
* TODO: It might be better in the future to just move the locking to the
* HwSwitch, so that the HwSwitch only needs to hold a lock when really
* necessary.
*/
std::mutex hwMutex_;
/*
* The current switch state.
*
* BEWARE: You generally shouldn't access this directly, even internally
* within SwSwitch private methods. This should only be accessed while
* holding stateLock_. You almost certainly should call getState() or
* setStateInternal() instead of directly accessing this.
*
* This intentionally has an awkward name so people won't forget and try to
* directly access this pointer.
*/
std::shared_ptr<SwitchState> stateDontUseDirectly_;
mutable folly::SpinLock stateLock_;
std::unique_ptr<ArpHandler> arp_;
std::unique_ptr<IPv4Handler> ipv4_;
std::unique_ptr<IPv6Handler> ipv6_;
std::unique_ptr<NeighborUpdater> nUpdater_;
std::unique_ptr<PktCaptureManager> pcapMgr_;
std::unique_ptr<SfpMap> sfpMap_;
/*
* A thread for performing various background tasks.
*/
std::unique_ptr<std::thread> backgroundThread_;
folly::EventBase backgroundEventBase_;
/*
* A thread for processing SwitchState updates.
*/
std::unique_ptr<std::thread> updateThread_;
folly::EventBase updateEventBase_;
BootType bootType_{BootType::UNINITIALIZED};
std::unique_ptr<LldpManager> lldpManager_;
};
}} // facebook::fboss
| 30.327652 | 80 | 0.702866 |
c2d02a80c1f7d16218aad85aec6304a2247bc669 | 1,533 | c | C | bot-master/src/conn_handler.c | Anex007/Cyberries | 330fcbcddff46caf96fa06ebdc632049d69ca186 | [
"MIT"
] | 3 | 2018-01-07T19:10:49.000Z | 2018-01-19T13:50:14.000Z | bot-master/src/conn_handler.c | Anex007/Cyberries | 330fcbcddff46caf96fa06ebdc632049d69ca186 | [
"MIT"
] | null | null | null | bot-master/src/conn_handler.c | Anex007/Cyberries | 330fcbcddff46caf96fa06ebdc632049d69ca186 | [
"MIT"
] | null | null | null | #include "conn_handler.h"
extern CONNS cons;
extern int main_sock;
extern short port;
int make_socket(void)
{
int s;
if((s = socket(AF_INET , SOCK_STREAM , 0)) == ERROR) {
perror("Failed to create socket");
exit(1);
}
return s;
}
void *accept_handler(void)
{
struct connections *connects = &cons;
struct timeval timeout={4,0};
int tr = 1;
if (setsockopt(main_sock, SOL_SOCKET, SO_REUSEADDR, &tr, sizeof(int)) == ERROR) {
perror("setsockopt");
}
while(1){
int addrlen = sizeof(struct sockaddr);
if((connects->sock = accept(main_sock, (struct sockaddr *)&connects->client_conn, &addrlen)) == ERROR){
perror("accept failed");
continue;
}
connects->next = (struct connections *) malloc(sizeof (struct connections));
connects = connects->next;
}
}
void send_to_bots(char *data)
{
struct connections *connects = &cons;
while(connects != NULL && connects->sock != 0){
int ret = write(connects->sock, data, strlen(data));
// DEBUG
printf("%d\n", ret);
connects = connects->next;
}
}
void bind_socket(struct sockaddr_in *serverAddr)
{
memset(serverAddr, 0, sizeof(struct sockaddr_in));
serverAddr->sin_family = AF_INET;
serverAddr->sin_port = htons(port);
serverAddr->sin_addr.s_addr = htonl(INADDR_ANY);
if (bind(main_sock, (struct sockaddr *)serverAddr, sizeof(struct sockaddr)) == ERROR){
perror("Failed to bind the Socket");
exit(1);
}
}
/*
server.sin_addr.s_addr = inet_addr("74.125.235.20");
server.sin_family = AF_INET;
server.sin_port = htons( 80 );
*/ | 22.544118 | 105 | 0.677756 |
8e83cb4db6e7a7210edd3e580ffcd96153516c60 | 50,301 | c | C | mapdata.c | hansonry/openslay | bbafaa255b8acd57044dfe0ce459a082ec6410ac | [
"MIT"
] | null | null | null | mapdata.c | hansonry/openslay | bbafaa255b8acd57044dfe0ce459a082ec6410ac | [
"MIT"
] | null | null | null | mapdata.c | hansonry/openslay | bbafaa255b8acd57044dfe0ce459a082ec6410ac | [
"MIT"
] | null | null | null | #include "mapdata.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define GROWBY 32
#define FLAGS_SEARCHED 0x01
#define FLAGS_CANMOVE 0x02
struct mdplayerdata
{
int owner;
};
struct mdundoevent
{
int moneypayed;
int src_x;
int src_y;
int dest_x;
int dest_y;
int prevcap_x;
int prevcap_y;
int dest_owner;
enum mapentity src_unit;
enum mapentity dest_unit;
int caps_count;
struct mdundocapital
{
int destroyed_flag;
int money;
enum mapentity replacedunit;
int x;
int y;
} caps[6];
};
struct mapdata
{
struct mdtilelist
{
struct maptile * base;
size_t size;
size_t count;
} tiles;
struct mdcapitallist
{
struct mapcapital * base;
size_t size;
size_t count;
} caps;
struct mdplayer
{
int current;
struct mdplayerdata * base;
size_t count;
size_t size;
} players;
struct mdundo
{
struct mdundoevent * base;
size_t count;
size_t size;
} undo;
};
static struct mapdata data;
void mapdata_init(void)
{
data.tiles.size = GROWBY;
data.tiles.base = malloc(sizeof(struct maptile) * data.tiles.size);
data.tiles.count = 0;
data.caps.size = GROWBY;
data.caps.base = malloc(sizeof(struct mapcapital) * data.caps.size);
data.caps.count = 0;
data.players.size = GROWBY;
data.players.base = malloc(sizeof(struct mdplayerdata) * data.players.size);
data.players.count = 0;
data.players.current = 0;
data.undo.size = GROWBY;
data.undo.base = malloc(sizeof(struct mdundoevent) * data.undo.size);
data.undo.count = 0;
}
void mapdata_destroy(void)
{
free(data.tiles.base);
data.tiles.base = NULL;
data.tiles.size = 0;
data.tiles.count = 0;
free(data.caps.base);
data.caps.base = NULL;
data.caps.size = 0;
data.caps.count = 0;
free(data.players.base);
data.players.base = NULL;
data.players.size = 0;
data.players.count = 0;
free(data.undo.base);
data.undo.base = NULL;
data.undo.size = 0;
data.undo.count = 0;
}
int mapdata_count(void)
{
return data.tiles.count;
}
int mapdata_getcurrentplayer(void)
{
return data.players.current;
}
void mapdata_setcurrentplayer(int player)
{
if(player >= -1 && player < (int)data.players.count)
{
data.players.current = player;
}
}
int mapdata_getplayercount(void)
{
return data.players.count;
}
void mapdata_setplayercount(int count)
{
if(count >= data.players.size)
{
data.players.size = count + GROWBY;
data.players.base = realloc(data.players.base,
sizeof(struct mdplayerdata) *
data.players.size);
}
data.players.count = count;
}
void mapdata_setplayerowner(int playerindex, int owner)
{
if(playerindex >= 0 && playerindex < data.players.count)
{
data.players.base[playerindex].owner = owner;
}
}
int mapdata_getplayerowner(int playerindex)
{
if(playerindex >= 0 && playerindex < data.players.count)
{
return data.players.base[playerindex].owner;
}
return 0;
}
int mapdata_getplayerfromowner(int owner)
{
struct mdplayerdata * d;
size_t i;
for(i = 0; i < data.players.count; i++)
{
d = &data.players.base[i];
if(d->owner == owner)
{
return i;
}
}
return -1;
}
static struct maptile * mapdata_findtile(int x, int y, size_t * index)
{
size_t i;
for(i = 0; i < data.tiles.count; i++)
{
if(data.tiles.base[i].x == x &&
data.tiles.base[i].y == y)
{
if(index != NULL)
{
*index = i;
}
return &data.tiles.base[i];
}
}
return NULL;
}
struct maptile * mapdata_addtile(int x, int y)
{
struct maptile * tile;
tile = mapdata_findtile(x, y, NULL);
if(tile != NULL)
{
return tile;
}
if(data.tiles.count >= data.tiles.size)
{
data.tiles.size = data.tiles.count + GROWBY;
data.tiles.base = realloc(data.tiles.base,
sizeof(struct maptile) * data.tiles.size);
}
tile = &data.tiles.base[data.tiles.count];
data.tiles.count ++;
tile->x = x;
tile->y = y;
tile->owner = 0;
tile->entity = e_ME_none;
return tile;
}
struct maptile * mapdata_gettile(int x, int y)
{
return mapdata_findtile(x, y, NULL);
}
struct maptile * mapdata_getindex(int index)
{
if(index >= 0 && index < data.tiles.count)
{
return &data.tiles.base[index];
}
return NULL;
}
void mapdata_removetile(int x, int y)
{
struct maptile * tile;
size_t rindex;
tile = mapdata_findtile(x, y, &rindex);
if(tile != NULL)
{
data.tiles.count --;
memcpy(&data.tiles.base[rindex],
&data.tiles.base[data.tiles.count],
sizeof(struct maptile));
}
}
void mapdata_clear(void)
{
data.tiles.count = 0;
data.caps.count = 0;
}
void mapdata_get6suroundingCoordinates(int x, int y,
int * xs_out, int * ys_out)
{
static int xevenoffsets[] = { 0, 1, 1, 0, -1, -1 };
static int yevenoffsets[] = { -1, -1, 0, 1, 0, -1 };
static int xoddoffsets[] = { 0, 1, 1, 0, -1, -1 };
static int yoddoffsets[] = { -1, 0, 1, 1, 1, 0 };
int * xoffset, * yoffset, i;
if(x % 2 == 0) // Check for even
{
xoffset = xevenoffsets;
yoffset = yevenoffsets;
}
else
{
xoffset = xoddoffsets;
yoffset = yoddoffsets;
}
for(i = 0; i < 6; i++)
{
xs_out[i] = x + xoffset[i];
ys_out[i] = y + yoffset[i];
}
}
static void mapdata_updateupkeep(void)
{
size_t i, k;
struct mapcapital * cap;
struct maptile * tile;
for(i = 0; i < data.caps.count; i++)
{
cap = &data.caps.base[i];
cap->upkeep = 0;
}
for(i = 0; i < data.tiles.count; i++)
{
int upkeep;
tile = &data.tiles.base[i];
switch(tile->entity)
{
default:
upkeep = 0;
break;
case e_ME_peasant:
upkeep = 2;
break;
case e_ME_spearman:
upkeep = 6;
break;
case e_ME_knight:
upkeep = 18;
break;
case e_ME_baron:
upkeep = 54;
break;
}
if(upkeep > 0)
{
for(k = 0; k < data.caps.count; k++)
{
cap = &data.caps.base[k];
if(cap->x == tile->cap_x && cap->y == tile->cap_y)
{
cap->upkeep += upkeep;
break;
}
}
}
}
}
static void mapdata_updateincome(void)
{
size_t i, k;
struct mapcapital * cap;
struct maptile * tile;
for(i = 0; i < data.caps.count; i++)
{
cap = &data.caps.base[i];
cap->income = 0;
}
for(i = 0; i < data.tiles.count; i++)
{
tile = &data.tiles.base[i];
switch(tile->entity)
{
default:
// Do nothing on purpose
break;
case e_ME_none:
case e_ME_capital:
case e_ME_castle:
case e_ME_grave: // Not sure if this matches the original game
case e_ME_peasant:
case e_ME_spearman:
case e_ME_knight:
case e_ME_baron:
for(k = 0; k < data.caps.count; k++)
{
cap = &data.caps.base[k];
if(cap->x == tile->cap_x && cap->y == tile->cap_y)
{
cap->income ++;
break;
}
}
break;
}
}
}
static struct mapcapital * mapdata_addcapital(size_t * index)
{
struct mapcapital * cap;
if(data.caps.count >= data.caps.size)
{
data.caps.size = data.caps.count + GROWBY;
data.caps.base = realloc(data.caps.base,
sizeof(struct mapcapital) * data.caps.size);
}
cap = &data.caps.base[data.caps.count];
if(index != NULL)
{
*index = data.caps.count;
}
data.caps.count ++;
return cap;
}
static void mapdata_removecapital(size_t index)
{
data.caps.count --;
memcpy(&data.caps.base[index],
&data.caps.base[data.caps.count],
sizeof(struct mapcapital));
}
static int mapdata_paintcapital(struct maptile * tile)
{
struct maptile * subtile;
int next_x[6];
int next_y[6];
int i;
int count = 1;
//printf("Enter %d, %d\n", tile->x, tile->y);
// Mark this as searched
tile->flags |= FLAGS_SEARCHED;
mapdata_get6suroundingCoordinates(tile->x, tile->y, next_x, next_y);
for(i = 0; i < 6; i++)
{
subtile = mapdata_gettile(next_x[i], next_y[i]);
//printf("%d, %d\n", next_x[i], next_y[i]);
if(subtile != NULL &&
(subtile->flags & FLAGS_SEARCHED) == 0 && // not searched
subtile->owner == tile->owner)
{
// Remove captials
if(subtile->entity == e_ME_capital)
{
subtile->entity = e_ME_none;
}
// set captial to parent
subtile->cap_x = tile->cap_x;
subtile->cap_y = tile->cap_y;
count += mapdata_paintcapital(subtile);
}
}
//printf("count: %d\n", count);
return count;
}
static int mapdata_computecaptialscore(struct maptile * tile)
{
int score;
int i;
int xs[6], ys[6];
struct maptile * ltile;
if(tile->entity == e_ME_none)
{
// Lets figure out how well defended this thing is
score = 12;
mapdata_get6suroundingCoordinates(tile->x, tile->y, xs, ys);
for(i = 0; i < 6; i++)
{
ltile = mapdata_gettile(xs[i], ys[i]);
if(ltile == NULL)
{
score += 6;
}
else if(ltile->cap_x == tile->cap_x &&
ltile->cap_y == tile->cap_y)
{
switch(ltile->entity)
{
default:
// Do nothing on purpose (Add 0)
break;
case e_ME_peasant: score += 1; break;
case e_ME_spearman: score += 2; break;
case e_ME_castle: score += 3; break;
case e_ME_knight: score += 4; break;
case e_ME_baron: score += 5; break;
}
}
else
{
// This is a hostile tile. It's best to put some room between
score -= 2;
}
}
}
else
{
// Try not to remove anything
// Even trees, That would give you a benifit
switch(tile->entity)
{
case e_ME_baron: score = -6; break;
case e_ME_knight: score = -5; break;
case e_ME_castle: score = -4; break;
case e_ME_spearman: score = -3; break;
case e_ME_peasant: score = -2; break;
case e_ME_tree: score = -1; break;
case e_ME_palmtree: score = -1; break;
case e_ME_grave: score = -1; break;
default: score = 0; break;
}
}
return score;
}
// cap_x and cap_y are the current temperary capital of the
// terratory
static struct maptile * mapdata_findgoodcapitalplace(int cap_x, int cap_y)
{
struct maptile * tile, *best;
size_t i;
int bestscore;
best = NULL;
for(i = 0; i < data.tiles.count; i++)
{
tile = &data.tiles.base[i];
if(tile->cap_x == cap_x &&
tile->cap_y == cap_y)
{
int thisscore;
thisscore = mapdata_computecaptialscore(tile);
if(best == NULL || thisscore > bestscore)
{
best = tile;
bestscore = thisscore;
}
}
}
return best;
}
static void mapdata_shiftcaptial(int src_x, int src_y, int dest_x, int dest_y)
{
struct maptile * tile;
size_t i;
for(i = 0; i < data.tiles.count; i++)
{
tile = &data.tiles.base[i];
if(tile->cap_x == src_x && tile->cap_y == src_y)
{
tile->cap_x = dest_x;
tile->cap_y = dest_y;
}
}
}
// In this function we are trusting tile owners, positions, trees, and units
// Everything else this function will clean up
void mapdata_fullclean(void)
{
size_t i, k;
struct maptile * tile;
struct mapcapital * cap;
// Verify all capitals and
// remove capitals that don't match a tile
for(i = data.caps.count - 1; i < data.caps.count; i--)
{
cap = &data.caps.base[i];
tile = mapdata_gettile(cap->x, cap->y);
if(tile == NULL ||
tile->entity != e_ME_capital)
{
// It's a fake capital, lets remove it
mapdata_removecapital(i);
}
}
// Go though all tiles and self assign as a capital
// Set them all as unsearched and moved
for(i = 0; i < data.tiles.count; i++)
{
tile = &data.tiles.base[i];
tile->cap_x = tile->x;
tile->cap_y = tile->y;
tile->flags = FLAGS_CANMOVE;
}
// Find each captial and paint out. Remove captials that
// are in the same area. Also remove captials that don't have a large
// area
for(i = 0; i < data.tiles.count; i++)
{
tile = &data.tiles.base[i];
if(tile->entity == e_ME_capital)
{
int count;
count = mapdata_paintcapital(tile);
if(count <= 1)
{
// Area is too small. Remove the building. Also see if we can
// find a capital data entry and remove that too
tile->entity = e_ME_none;
for(k = 0; k < data.caps.count; k ++)
{
cap = &data.caps.base[k];
if(cap->x == tile->x &&
cap->y == tile->y)
{
mapdata_removecapital(k);
break;
}
}
}
}
}
// Find areas that should have a capital but don't
for(i = 0; i < data.tiles.count; i++)
{
tile = &data.tiles.base[i];
if(tile->entity != e_ME_capital &&
tile->cap_x == tile->x &&
tile->cap_y == tile->y)
{
// We have found a possiblity. Let's map the area and
// see if it has enugh size to support a capital.
int count;
count = mapdata_paintcapital(tile);
if(count > 1)
{
struct maptile * best;
best = mapdata_findgoodcapitalplace(tile->x, tile->y);
mapdata_shiftcaptial(tile->x, tile->y, best->x, best->y);
//printf("Make Captial\n");
// We should have a capital here, so add a capital
cap = mapdata_addcapital(NULL);
cap->money = 0;
cap->x = best->x;
cap->y = best->y;
best->entity = e_ME_capital;
}
}
}
// make sure each capital has a captial data entry
for(i = 0; i < data.tiles.count; i++)
{
tile = &data.tiles.base[i];
if(tile->entity == e_ME_capital)
{
int found;
// Search for matching entry in captial list
found = 0;
for(k = 0; k < data.caps.count; k++)
{
cap = &data.caps.base[k];
if(cap->x == tile->cap_x &&
cap->y == tile->cap_y)
{
found = 1;
break;
}
}
// If we didn't find a matching captial entity,
// we need to create that entity
if(found == 0)
{
// Grow the data if nessary
cap = mapdata_addcapital(NULL);
cap->money = 0;
cap->x = tile->x;
cap->y = tile->y;
}
}
}
// Go though all tiles and set them to unsearched
for(i = 0; i < data.tiles.count; i++)
{
tile = &data.tiles.base[i];
tile->flags = FLAGS_CANMOVE;
}
// Count The area for each captital and setup the income
// Also mark the can move flags on the capital
for(i = 0; i < data.caps.count; i++)
{
cap = &data.caps.base[i];
tile = mapdata_gettile(cap->x, cap->y);
if(tile == NULL)
{
fprintf(stderr, "mapdata_fullclean: Error Unexpected NULL Tile\n");
return;
}
cap->size = mapdata_paintcapital(tile);
if(cap->money >= 10)
{
tile->flags |= FLAGS_CANMOVE;
}
else
{
tile->flags &= ~FLAGS_CANMOVE;
}
}
// update the incomes
mapdata_updateincome();
mapdata_updateupkeep();
// Count the number of players
mapdata_setplayercount(0);
for(i = 0; i < data.tiles.count; i++)
{
int found;
tile = &data.tiles.base[i];
found = 0;
for(k = 0; k < data.players.count; k++)
{
if(data.players.base[k].owner == tile->owner)
{
found = 1;
break;
}
}
if(found == 0)
{
mapdata_setplayercount(data.players.count + 1);
data.players.base[data.players.count - 1].owner = tile->owner;
//printf("Player %d uses owner %d\n", data.players.count -1, tile->owner);
}
}
}
struct mapcapital * mapdata_getcapital(int x, int y)
{
struct mapcapital * cap, *t;
size_t i;
cap = NULL;
for(i = 0; i < data.caps.count; i++)
{
t = &data.caps.base[i];
if(t->x == x && t->y == y)
{
cap = t;
break;
}
}
return cap;
}
void mapdata_setmoneyallcapitals(int amount)
{
struct mapcapital * cap;
struct maptile * tile;
size_t i;
for(i = 0; i < data.caps.count; i++)
{
cap = &data.caps.base[i];
cap->money = amount;
tile = mapdata_gettile(cap->x, cap->y);
if(tile != NULL)
{
if(amount >= 10)
{
tile->flags |= FLAGS_CANMOVE;
}
else
{
tile->flags &= ~FLAGS_CANMOVE;
}
}
}
}
int mapdata_getcanmove(struct maptile * tile)
{
if((tile->flags & FLAGS_CANMOVE) == FLAGS_CANMOVE)
{
return 1;
}
else
{
return 0;
}
}
int mapdata_getentitycost(enum mapentity entity)
{
int cost;
switch(entity)
{
case e_ME_peasant: cost = 10; break;
case e_ME_spearman: cost = 20; break;
case e_ME_knight: cost = 30; break;
case e_ME_baron: cost = 40; break;
case e_ME_castle: cost = 25; break;
default: cost = 0; break;
}
return cost;
}
static void mapdata_placetree(struct maptile * tile)
{
struct maptile * ltile;
int sx[6], sy[6];
int i;
int foundwater;
mapdata_get6suroundingCoordinates(tile->x, tile->y, sx, sy);
foundwater = 0;
for(i = 0; i < 6; i++)
{
ltile = mapdata_gettile(sx[i], sy[i]);
if(ltile == NULL)
{
foundwater = 1;
break;
}
}
if(foundwater == 1)
{
tile->entity = e_ME_palmtree;
}
else
{
tile->entity = e_ME_tree;
}
}
// This function assumes you have not messed with any of the tile
// entities before you run this.
// After this is run you can place any unit in the taken spot.
static void mapdata_taketile(struct maptile * tile, int new_owner,
int new_cap_x, int new_cap_y,
struct mdundoevent * event)
{
size_t i, k;
struct maptile * ltile;
struct mapcapital * cap, * largest_cap;
int old_cap_x, old_cap_y;
int money;
size_t largest_cap_index;
// Init Event
event->caps_count = 0;
event->prevcap_x = tile->cap_x;
event->prevcap_y = tile->cap_y;
// 1. Handel the opponent losses
// 1.a. Check to see if we split the oppent's terratory
// start by unmarking all terratory
for(i = 0; i < data.tiles.count; i++)
{
ltile = &data.tiles.base[i];
ltile->flags &= ~FLAGS_SEARCHED;
}
// set the tile to the new owner
old_cap_x = tile->cap_x;
old_cap_y = tile->cap_y;
tile->owner = new_owner;
tile->cap_x = new_cap_x;
tile->cap_y = new_cap_y;
// Check to see if we have killed a capital
if(tile->entity == e_ME_capital)
{
// If we have, we need to remove the capital
for(i = 0; i < data.caps.count; i++)
{
cap = &data.caps.base[i];
if(cap->x == tile->x &&
cap->y == tile->y)
{
event->caps[event->caps_count].x = cap->x;
event->caps[event->caps_count].y = cap->y;
event->caps[event->caps_count].money = cap->money;
event->caps[event->caps_count].replacedunit = e_ME_none;
event->caps[event->caps_count].destroyed_flag = 1;
event->caps_count ++;
mapdata_removecapital(i);
break;
}
}
}
// Search the old owner captial, if we find it, then recalculate
// the area.
cap = mapdata_getcapital(old_cap_x, old_cap_y);
if(cap != NULL)
{
ltile = mapdata_gettile(cap->x, cap->y);
if(ltile != NULL)
{
cap->size = mapdata_paintcapital(ltile);
// Check to see if there is enughf room left to have a capital.
if(cap->size < 2)
{
mapdata_placetree(ltile);
event->caps[event->caps_count].x = cap->x;
event->caps[event->caps_count].y = cap->y;
event->caps[event->caps_count].money = cap->money;
event->caps[event->caps_count].replacedunit = ltile->entity;
event->caps[event->caps_count].destroyed_flag = 1;
event->caps_count ++;
// Find the captial and remove it
for(k = 0; k < data.caps.count; k++)
{
if(cap == &data.caps.base[k])
{
mapdata_removecapital(k);
break;
}
}
}
}
}
// Now there could be some tiles that have the old captial, but are
// not marked as searched. These tiles need to have a new capital
for(i = 0; i < data.tiles.count; i++)
{
ltile = &data.tiles.base[i];
if(ltile->cap_x == old_cap_x &&
ltile->cap_y == old_cap_y &&
(ltile->flags & FLAGS_SEARCHED) == 0)
{
int size;
ltile->cap_x = ltile->x;
ltile->cap_y = ltile->y;
size = mapdata_paintcapital(ltile);
if(size > 1)
{
struct maptile * best;
best = mapdata_findgoodcapitalplace(ltile->x, ltile->y);
mapdata_shiftcaptial(ltile->x, ltile->y, best->x, best->y);
event->caps[event->caps_count].x = best->x;
event->caps[event->caps_count].y = best->y;
event->caps[event->caps_count].money = 0;
event->caps[event->caps_count].replacedunit = best->entity;
event->caps[event->caps_count].destroyed_flag = 0;
event->caps_count ++;
best->entity = e_ME_capital;
cap = mapdata_addcapital(NULL);
cap->x = best->x;
cap->y = best->y;
cap->money = 0;
cap->size = size;
best->flags &= ~FLAGS_CANMOVE;
}
}
}
// 2. Handel the gains from the move
// To start we are going to switch all tiles to point to the capital
// that the attacking unit came from. We will also remove all the captial
// tiles
ltile = mapdata_gettile(new_cap_x, new_cap_y);
cap = mapdata_getcapital(new_cap_x, new_cap_y);
if(cap != NULL && ltile != NULL)
{
// This removes all other captial tiles and sets all connected tiles
// to the source capital
//printf("Reset all capitals to %d %d\n", cap->x, cap->y);
(void)mapdata_paintcapital(ltile);
ltile->entity = e_ME_none;
}
else
{
fprintf(stderr, "mapdata_taketile: Capital or tile is unexpectedly NULL\n");
}
// Now we will loop though all the captials, Find the tiles that are
// pointing to the original captial. Find the one with the most
// terratory and set that one
money = 0;
largest_cap = NULL;
for(i = data.caps.count - 1; i < data.caps.count; i--)
{
cap = &data.caps.base[i];
ltile = mapdata_gettile(cap->x, cap->y);
if(ltile != NULL &&
ltile->cap_x == new_cap_x &&
ltile->cap_y == new_cap_y)
{
struct mapcapital *smaller_cap;
int smaller_index;
money += cap->money;
smaller_cap = cap;
smaller_index = i;
//printf("Found Cap %d %d at size %d\n", cap->x, cap->y, cap->size);
if(largest_cap == NULL || cap->size > largest_cap->size)
{
smaller_cap = largest_cap;
smaller_index = largest_cap_index;
largest_cap_index = i;
largest_cap = cap;
}
if(smaller_cap != NULL)
{
// A smaller capital has been picked
// So we will remove it from the capital list
//printf("Removeing Cap %d %d at size %d\n", smaller_cap->x, smaller_cap->y, smaller_cap->size);
event->caps[event->caps_count].x = smaller_cap->x;
event->caps[event->caps_count].y = smaller_cap->y;
event->caps[event->caps_count].money = smaller_cap->money;;
event->caps[event->caps_count].replacedunit = e_ME_none;
event->caps[event->caps_count].destroyed_flag = 1;
event->caps_count ++;
mapdata_removecapital(smaller_index);
}
}
}
// Reset all the search tiles once more for a final paint
for(i = 0; i < data.tiles.count; i++)
{
ltile = &data.tiles.base[i];
ltile->flags &= ~FLAGS_SEARCHED;
}
// We now have the larget_capital. Give it all the money and set the
// entity to a capital and then repaint everything to this capital coordinat
largest_cap->money = money;
ltile = mapdata_gettile(largest_cap->x, largest_cap->y);
if(ltile != NULL)
{
ltile->entity = e_ME_capital;
ltile->cap_x = ltile->x;
ltile->cap_y = ltile->y;
largest_cap->size = mapdata_paintcapital(ltile);
if(largest_cap->money >= 10)
{
ltile->flags |= FLAGS_CANMOVE;
}
else
{
ltile->flags &= ~FLAGS_CANMOVE;
}
}
mapdata_updateincome();
}
static int mapdata_wincheck(enum mapentity attacker,
enum mapentity defender)
{
int win;
if(attacker == e_ME_baron)
{
switch(defender)
{
default:
win = 1;
break;
case e_ME_baron:
win = 0;
break;
}
}
else if(attacker == e_ME_knight)
{
switch(defender)
{
default:
win = 1;
break;
case e_ME_baron:
case e_ME_knight:
win = 0;
break;
}
}
else if(attacker == e_ME_spearman)
{
switch(defender)
{
default:
win = 1;
break;
case e_ME_baron:
case e_ME_knight:
case e_ME_spearman:
case e_ME_castle:
win = 0;
break;
}
}
else if(attacker == e_ME_peasant)
{
switch(defender)
{
default:
win = 1;
break;
case e_ME_baron:
case e_ME_knight:
case e_ME_spearman:
case e_ME_castle:
case e_ME_peasant:
case e_ME_capital:
win = 0;
break;
}
}
else
{
win = 0;
}
return win;
}
static enum mapentity mapdata_sumunit(enum mapentity e1, enum mapentity e2)
{
enum mapentity result;
enum mapentity e[2];
int v[2];
int vr;
int i;
e[0] = e1;
e[1] = e2;
for(i = 0; i < 2; i++)
{
switch(e[i])
{
default: v[i] = 0; break;
case e_ME_peasant: v[i] = 1; break;
case e_ME_spearman: v[i] = 2; break;
case e_ME_knight: v[i] = 3; break;
case e_ME_baron: v[i] = 4; break;
}
}
vr = v[0] + v[1];
switch(vr)
{
case 0: result = e_ME_none; break;
case 1: result = e_ME_peasant; break;
case 2: result = e_ME_spearman; break;
case 3: result = e_ME_knight; break;
case 4: result = e_ME_baron; break;
default: result = e_ME_grave; break;
}
return result;
}
static int mapdata_commonmove(struct mapcommandresult * result, int owner,
struct maptile * src_tile,
struct maptile * dest_tile,
enum mapentity * entity,
int * cost, struct mapcapital ** cap)
{
enum mapentity lentity;
int sx[6], sy[6];
struct maptile * stile[6];
int i;
int found;
if(result != NULL)
{
result->mapchanged_flag = 0;
}
// Check our entity to see if it is valid
if((*entity) != e_ME_castle &&
(*entity) != e_ME_peasant &&
(*entity) != e_ME_spearman &&
(*entity) != e_ME_knight &&
(*entity) != e_ME_baron)
{
if(result != NULL)
{
result->type = e_MCRT_notvalidentity;
}
return 0;
}
// Check our source entity to see if it is valid
if(src_tile->entity != e_ME_capital && // used to create units
src_tile->entity != e_ME_peasant &&
src_tile->entity != e_ME_spearman &&
src_tile->entity != e_ME_knight &&
src_tile->entity != e_ME_baron)
{
if(result != NULL)
{
result->type = e_MCRT_sourcenotvalidunit;
}
return 0;
}
// Check to see if you own the unit
if(src_tile->owner != owner)
{
if(result != NULL)
{
result->type = e_MCRT_notyourunit;
}
return 0;
}
// Check to see if the source unit has move capablities
if(src_tile->entity != e_ME_capital && // New units can move
(src_tile->flags & FLAGS_CANMOVE) != FLAGS_CANMOVE)
{
if(result != NULL)
{
result->type = e_MCRT_sourceunitcantmove;
}
return 0;
}
// Are we just moving a unit or upgrading it too?
if(src_tile->entity != *entity)
{
// We are upgrading or buying the unit. Compute the cost
(*cost) = mapdata_getentitycost(*entity) -
mapdata_getentitycost(src_tile->entity);
// Check to see if we have the money and a capital
(*cap) = mapdata_getcapital(src_tile->cap_x, src_tile->cap_y);
if((*cap) == NULL)
{
if(result != NULL)
{
result->type = e_MCRT_notacapital;
}
return 0;
}
if((*cap)->money < (*cost))
{
if(result != NULL)
{
result->type = e_MCRT_notenoughmoney;
}
return 0;
}
}
else
{
(*cap) = NULL;
(*cost) = 0;
}
// Castle specific stuff
if((*entity) == e_ME_castle)
{
// You can only buy castles, not upgrade to them
if(src_tile->entity != e_ME_capital)
{
if(result != NULL)
{
result->type = e_MCRT_cantupgradetocastle;
}
return 0;
}
// Check to see if we are placing castles in our own territory
if(src_tile->cap_x != dest_tile->cap_x ||
src_tile->cap_y != dest_tile->cap_y)
{
if(result != NULL)
{
result->type = e_MCRT_cantcastleattack;
}
return 0;
}
// We can only place castls on empty tiles
if(dest_tile->entity != e_ME_none)
{
if(result != NULL)
{
result->type = e_MCRT_blocked;
result->blockedby = dest_tile->entity;
result->blockedby_x = dest_tile->x;
result->blockedby_y = dest_tile->y;
}
return 0;
}
// Ok we can place the castle now
if(result != NULL)
{
result->type = e_MCRT_success;
}
return 1;
}
// Check to see if we are placing the unit right back down
if(src_tile == dest_tile)
{
if(result != NULL)
{
result->type = e_MCRT_success;
}
return 1;
}
// Check to see if we are moving within our terratory
if(src_tile->cap_x == dest_tile->cap_x &&
src_tile->cap_y == dest_tile->cap_y)
{
switch(dest_tile->entity)
{
case e_ME_none:
// Nothing here, just move the unit and mark it as good to move again
dest_tile->flags |= FLAGS_CANMOVE;
if(result != NULL)
{
result->type = e_MCRT_success;
}
return 1;
break;
case e_ME_tree:
case e_ME_palmtree:
case e_ME_grave:
// Cleanup the blockers and mark the unit as moved
dest_tile->flags &= ~FLAGS_CANMOVE;
if(result != NULL)
{
result->type = e_MCRT_success;
}
return 1;
break;
case e_ME_peasant:
case e_ME_spearman:
case e_ME_knight:
case e_ME_baron:
// Combine the two units. Use the movement state of
// the destination unit.
lentity = mapdata_sumunit(*entity, dest_tile->entity);
if(lentity == e_ME_grave) // Grave indicates larger than barron
{
if(result != NULL)
{
result->type = e_MCRT_combinedunitabovemax;
}
return 0;
}
else if(lentity == e_ME_none)
{
fprintf(stderr, "mapdata_moveunit: The sum of two units shouldn't be nothing\n");
if(result != NULL)
{
result->type = e_MCRT_error;
}
return 0;
}
else
{
*entity = lentity;
if(result != NULL)
{
result->type = e_MCRT_success;
}
return 1;
}
break;
default:
if(result != NULL)
{
result->type = e_MCRT_destblockedbybuilding;
}
return 0;
break;
}
}
// We are not moving onto our terrain if we get here
// Gather information about the surrounding tiles
mapdata_get6suroundingCoordinates(dest_tile->x, dest_tile->y, sx, sy);
for(i = 0; i < 6; i++)
{
stile[i] = mapdata_gettile(sx[i], sy[i]);
}
// Check to see if we are one away from our attacking terratory
found = 0;
for(i = 0; i < 6; i++)
{
if(stile[i] != NULL &&
stile[i]->cap_x == src_tile->cap_x &&
stile[i]->cap_y == src_tile->cap_y)
{
found = 1;
break;
}
}
if(found == 0)
{
if(result != NULL)
{
result->type = e_MCRT_notreachable;
}
return 0;
}
// Can we win a fight with what is in the destination tile
if(!mapdata_wincheck(*entity, dest_tile->entity))
{
if(result != NULL)
{
result->type = e_MCRT_blocked;
result->blockedby = dest_tile->entity;
result->blockedby_x = dest_tile->x;
result->blockedby_x = dest_tile->y;
}
return 0;
}
// Ok we can win that fight, but can we win against anything else near by
// (Withing their own terratory)
for(i = 0; i < 6; i++)
{
if(stile[i] != NULL &&
dest_tile->cap_x == stile[i]->cap_x && // Check to see if this is the same cap as
dest_tile->cap_y == stile[i]->cap_y && // the defending tile
!mapdata_wincheck(*entity, stile[i]->entity)) // See if we lose
{
// So we lost a fight with something one away from the defending tile
// that is the same capital. So we can make this move
if(result != NULL)
{
result->type = e_MCRT_blocked;
result->blockedby = stile[i]->entity;
result->blockedby_x = sx[i];
result->blockedby_x = sy[i];
}
return 0;
}
}
// At this point there is nothing stopping the attacker from taking this
// spot. So take it.
dest_tile->flags &= ~FLAGS_CANMOVE;
if(result != NULL)
{
result->type = e_MCRT_success;
result->mapchanged_flag = 1;
}
return 1;
}
// Buying the unit set the to_x and to_y to the capital
int mapdata_moveunit(struct mapcommandresult * result, int owner,
int from_x, int from_y, int to_x, int to_y,
enum mapentity entity)
{
int cost;
int rvalue;
struct mapcapital * cap;
struct maptile * src_tile;
struct maptile * dest_tile;
struct maptile * cap_tile;
struct mdundoevent event;
event.src_x = from_x;
event.src_y = from_y;
event.dest_x = to_x;
event.dest_y = to_y;
if(data.players.current != -1 &&
data.players.base[data.players.current].owner != owner)
{
if(result != NULL)
{
result->type = e_MCRT_wrongowner;
}
return 0;
}
// Check our source tile to see if it exists
src_tile = mapdata_gettile(from_x, from_y);
if(src_tile == NULL)
{
if(result != NULL)
{
result->type = e_MCRT_sourcenottile;
}
return 0;
}
// Check the destination tile
dest_tile = mapdata_gettile(to_x, to_y);
if(dest_tile == NULL)
{
if(result != NULL)
{
result->type = e_MCRT_destnottile;
}
return 0;
}
rvalue = mapdata_commonmove(result, owner,
src_tile,
dest_tile,
&entity, &cost, &cap);
if(rvalue == 1)
{
event.dest_unit = dest_tile->entity;
event.dest_owner = dest_tile->owner;
event.src_unit = src_tile->entity;
// Note: The order of this block of code is very important
// and strange
// First clear old tile if nessary
if(src_tile->entity != e_ME_capital)
{
src_tile->entity = e_ME_none;
}
// Charge the money if nessary
if(cap != NULL)
{
cap->money -= cost;
event.moneypayed = cost;
cap_tile = mapdata_gettile(cap->x, cap->y);
if(cap_tile == NULL)
{
fprintf(stderr, "mapdata_moveunit: Error, captial has no tile\n");
}
else
{
if(cap->money >= 10)
{
cap_tile->flags |= FLAGS_CANMOVE;
}
else
{
cap_tile->flags &= ~FLAGS_CANMOVE;
}
}
}
else
{
event.moneypayed = 0;
}
// Take the tile if we land in terrory that isn't ours
if(dest_tile->owner != owner)
{
cap = mapdata_getcapital(dest_tile->x, dest_tile->y);
mapdata_taketile(dest_tile, src_tile->owner,
src_tile->cap_x, src_tile->cap_y,
&event);
}
// Finaly set the entity
dest_tile->entity = entity;
mapdata_updateupkeep();
// Add the event to the undo stack
if(data.undo.count >= data.undo.size)
{
data.undo.size = data.undo.count + GROWBY;
data.undo.base = realloc(data.undo.base,
sizeof(struct mdundoevent) *
data.undo.size);
}
memcpy(&data.undo.base[data.undo.count], &event,
sizeof(struct mdundoevent));
data.undo.count ++;
}
return rvalue;
}
void mapdata_clearundo(void)
{
data.undo.count = 0;
}
int mapdata_endturn(void)
{
if(data.players.current >= 0)
{
data.players.current ++;
if(data.players.current >= data.players.count)
{
data.players.current = 0;
}
mapdata_startturn(data.players.base[data.players.current].owner);
mapdata_clearundo();
}
return data.players.current;
}
int mapdata_startturn(int owner)
{
struct mapcapital * cap;
struct maptile * tile, * ltile;
size_t i, k;
int z;
int sx[6], sy[6];
// Grow Trees
// To Grow trees, we are going to use the seached flag to indicate
// trees from last round. That way we dont grow a bunch of trees in one
// round
for(i = 0; i < data.tiles.count; i++)
{
tile = &data.tiles.base[i];
if(tile->entity == e_ME_tree ||
tile->entity == e_ME_palmtree)
{
tile->flags |= FLAGS_SEARCHED;
}
else
{
tile->flags &= ~FLAGS_SEARCHED;
}
}
for(k = 0; k < data.tiles.count; k++)
{
tile = &data.tiles.base[k];
if(tile->owner == owner &&
(tile->entity == e_ME_none ||
tile->entity == e_ME_grave))
{
// We can grow a tree here
// Count nearby trees and water
int palmtree_count;
int tree_count;
int water_count;
palmtree_count = 0;
tree_count = 0;
water_count = 0;
mapdata_get6suroundingCoordinates(tile->x, tile->y, sx, sy);
for(z = 0; z < 6; z++)
{
ltile = mapdata_gettile(sx[z], sy[z]);
if(ltile == NULL)
{
water_count ++;
}
else if(ltile->entity == e_ME_tree &&
(ltile->flags & FLAGS_SEARCHED) == FLAGS_SEARCHED)
{
tree_count ++;
}
else if(ltile->entity == e_ME_palmtree &&
(ltile->flags & FLAGS_SEARCHED) == FLAGS_SEARCHED)
{
palmtree_count ++;
}
}
// Now if we have 2 trees, grow a tree.
// Not sure if we grow a palm tree next to the water or not
if(tree_count >= 2)
{
if(water_count > 0)
{
tile->entity = e_ME_palmtree;
}
else
{
tile->entity = e_ME_tree;
}
}
else if (water_count >= 1 && palmtree_count >= 1)
{
// If we are next to water and a palm tree, grow a palmtree
tile->entity = e_ME_palmtree;
}
}
}
// Transform Graves into Trees
for(k = 0; k < data.tiles.count; k++)
{
tile = &data.tiles.base[k];
if(tile->owner == owner &&
tile->entity == e_ME_grave)
{
mapdata_placetree(tile);
}
}
// Loop though all the capitals and find the owners
for(i = 0; i < data.caps.count; i++)
{
cap = &data.caps.base[i];
tile = mapdata_gettile(cap->x, cap->y);
if(tile == NULL)
{
fprintf(stderr, "mapdata_startturn: Unxpected Null Tile\n");
return 0;
}
if(tile->owner == owner)
{
// TODO: Maybe move this into it's own function
// Add the income to the money
cap->money += cap->income;
// Check to see if we are bankruped
if(cap->money < cap->upkeep)
{
// The terratory went bankrup everyone dies
cap->money = 0;
tile->flags &= ~FLAGS_CANMOVE;
for(k = 0; k < data.tiles.count; k++)
{
ltile = &data.tiles.base[k];
if((ltile->entity == e_ME_peasant ||
ltile->entity == e_ME_spearman ||
ltile->entity == e_ME_knight ||
ltile->entity == e_ME_baron) &&
ltile->cap_x == cap->x &&
ltile->cap_y == cap->y)
{
ltile->entity = e_ME_grave;
}
}
}
else
{
// Yay we have money to live, subract the upkeep from the money
cap->money -= cap->upkeep;
if(cap->money >= 10)
{
tile->flags |= FLAGS_CANMOVE;
}
else
{
tile->flags &= ~FLAGS_CANMOVE;
}
}
}
}
// Kill all units that don't have a capital
for(k = 0; k < data.tiles.count; k++)
{
ltile = &data.tiles.base[k];
if(ltile->owner == owner &&
(ltile->entity == e_ME_peasant ||
ltile->entity == e_ME_spearman ||
ltile->entity == e_ME_knight ||
ltile->entity == e_ME_baron))
{
cap = mapdata_getcapital(ltile->cap_x, ltile->cap_y);
if(cap == NULL)
{
ltile->entity = e_ME_grave;
}
}
}
// Finaly give all the units move positions
for(k = 0; k < data.tiles.count; k++)
{
ltile = &data.tiles.base[k];
if(ltile->owner == owner &&
(ltile->entity == e_ME_peasant ||
ltile->entity == e_ME_spearman ||
ltile->entity == e_ME_knight ||
ltile->entity == e_ME_baron))
{
ltile->flags |= FLAGS_CANMOVE;
}
}
mapdata_updateupkeep();
mapdata_updateincome();
return 1;
}
int mapdata_undomove(void)
{
struct mdundoevent * event;
struct maptile * src_tile, * dest_tile, * tile;
struct mapcapital * cap;
int src_cap_x, src_cap_y;
size_t i, k;
int money;
// Grab the lastest event
if(data.undo.count == 0)
{
return 0;
}
data.undo.count --;
event = &data.undo.base[data.undo.count];
// Grab the source and destiation tiles
src_tile = mapdata_gettile(event->src_x, event->src_y);
dest_tile = mapdata_gettile(event->dest_x, event->dest_y);
if(src_tile == NULL || dest_tile == NULL)
{
fprintf(stderr, "mapdata_undomove: Null Source or Destination Tile\n");
}
src_cap_x = src_tile->cap_x;
src_cap_y = src_tile->cap_y;
money = 0;
// Check to see if we captured area
if(dest_tile->owner != event->dest_owner)
{
// We did capture area
// Clear the search flag
for(i = 0; i < data.tiles.count; i++)
{
tile = &data.tiles.base[i];
tile->flags &= ~FLAGS_SEARCHED;
}
// Give it back it's tile
dest_tile->owner = event->dest_owner;
dest_tile->cap_x = event->prevcap_x;
dest_tile->cap_y = event->prevcap_y;
// Destroy all built captials
for(i = 0; i < event->caps_count; i++)
{
struct mdundocapital * ucap;
ucap = &event->caps[i];
if(ucap->destroyed_flag == 0)
{
// Remove the capital from capitals
for(k = 0; k < data.caps.count; k++)
{
cap = &data.caps.base[k];
if(cap->x == ucap->x &&
cap->y == ucap->y)
{
mapdata_removecapital(k);
break;
}
}
// Find the tile and return it
tile = mapdata_gettile(ucap->x, ucap->y);
if(tile != NULL)
{
tile->entity = ucap->replacedunit;
}
}
}
// Paint the old capital that we took
cap = mapdata_getcapital(event->prevcap_x, event->prevcap_y);
if(cap != NULL) // May be null if we took a tile without a capital
{
tile = mapdata_gettile(cap->x, cap->y);
cap->size = mapdata_paintcapital(tile);
}
// Rebuild all destroyed capitals
for(i = 0; i < event->caps_count; i++)
{
struct mdundocapital * ucap;
ucap = &event->caps[i];
if(ucap->destroyed_flag == 1)
{
cap = mapdata_addcapital(NULL);
cap->x = ucap->x;
cap->y = ucap->y;
cap->money = ucap->money;
if(ucap->money > 0)
{
// To get here this captial needed to be combined with the
// attacking captial. So add this to the money pile
money += ucap->money;
}
tile = mapdata_gettile(cap->x, cap->y);
tile->cap_x = cap->x;
tile->cap_y = cap->y;
cap->size = mapdata_paintcapital(tile);
tile->entity = e_ME_capital;
//printf("Restored %d %d\n", cap->x, cap->y);
}
}
// Resize owner of original lands so that is is accurate
cap = mapdata_getcapital(src_cap_x, src_cap_y);
tile = mapdata_gettile(src_cap_x, src_cap_y);
if(tile == NULL || cap == NULL)
{
fprintf(stderr, "mapdata_undomove: Null capital and capital tile\n");
}
cap->size = mapdata_paintcapital(tile);
mapdata_updateincome();
}
// Restor the tiles
dest_tile->entity = event->dest_unit;
src_tile->entity = event->src_unit;
// Refund the attacking cappital if nessary
cap = mapdata_getcapital(src_tile->cap_x, src_tile->cap_y);
if(cap == NULL)
{
fprintf(stderr, "mapdata_undomove: Null capital\n");
}
// Handle Money of the attacing capital
cap->money += event->moneypayed;
tile = mapdata_gettile(cap->x, cap->y);
if(tile == NULL)
{
fprintf(stderr, "mapdata_undomove: Null capital tile\n");
}
if(cap->money >= 10)
{
tile->flags |= FLAGS_CANMOVE;
}
else
{
tile->flags &= ~FLAGS_CANMOVE;
}
// Handle money for the captial that was merged, but now is split
if(money > 0)
{
cap = mapdata_getcapital(src_cap_x, src_cap_y);
tile = mapdata_gettile(src_cap_x, src_cap_y);
if(tile == NULL || cap == NULL)
{
fprintf(stderr, "mapdata_undomove: Null capital and capital tile\n");
}
cap->money -= money;
if(cap->money >= 10)
{
tile->flags |= FLAGS_CANMOVE;
}
else
{
tile->flags &= ~FLAGS_CANMOVE;
}
}
mapdata_updateupkeep();
return 1;
}
int mapdata_cancurrentplayermove(void)
{
int owner;
size_t i;
struct maptile * tile;
owner = mapdata_getplayerowner(data.players.current);
for(i = 0; i < data.tiles.count; i++)
{
tile = &data.tiles.base[i];
if((tile->owner == owner ||
data.players.current == -1) &&
(tile->flags | FLAGS_CANMOVE) == FLAGS_CANMOVE &&
(tile->entity == e_ME_capital ||
tile->entity == e_ME_peasant ||
tile->entity == e_ME_spearman ||
tile->entity == e_ME_knight ||
tile->entity == e_ME_baron))
{
return 1;
}
}
return 0;
}
| 24.194805 | 108 | 0.52484 |
32beb1a91420d086b7e83e5daf574c24c9b7ceaa | 194 | h | C | DropdownTerminal/fApp.h | Hochgesand/DropdownTerminal | f6457b29204735d87ce3fd0645c92d294dbda298 | [
"MIT"
] | 2 | 2021-08-04T05:15:25.000Z | 2021-08-07T12:26:51.000Z | DropdownTerminal/fApp.h | Hochgesand/DropdownTerminal | f6457b29204735d87ce3fd0645c92d294dbda298 | [
"MIT"
] | 1 | 2021-08-20T12:49:27.000Z | 2021-08-23T12:47:51.000Z | DropdownTerminal/fApp.h | Hochgesand/DropdownTerminal | f6457b29204735d87ce3fd0645c92d294dbda298 | [
"MIT"
] | null | null | null | #pragma once
#include <wx/wx.h>
#include "fMainFrame.h"
class fApp : public wxApp
{
public:
fApp();
~fApp();
private:
fMainFrame* m_frame1 = nullptr;
public:
bool OnInit() override;
};
| 10.210526 | 32 | 0.670103 |
32cc0de3a62c60394cb308ea4466ef8f3c71769f | 1,700 | c | C | components/amp/engine/quickjs_engine/addons/network/module_network.c | wstong999/AliOS-Things | 6554769cb5b797e28a30a4aa89b3f4cb2ef2f5d9 | [
"Apache-2.0"
] | 4,538 | 2017-10-20T05:19:03.000Z | 2022-03-30T02:29:30.000Z | components/amp/engine/quickjs_engine/addons/network/module_network.c | wstong999/AliOS-Things | 6554769cb5b797e28a30a4aa89b3f4cb2ef2f5d9 | [
"Apache-2.0"
] | 1,088 | 2017-10-21T07:57:22.000Z | 2022-03-31T08:15:49.000Z | components/amp/engine/quickjs_engine/addons/network/module_network.c | willianchanlovegithub/AliOS-Things | 637c0802cab667b872d3b97a121e18c66f256eab | [
"Apache-2.0"
] | 1,860 | 2017-10-20T05:22:35.000Z | 2022-03-27T10:54:14.000Z | /*
* Copyright (C) 2015-2019 Alibaba Group Holding Limited
*/
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "amp_config.h"
#include "aos_system.h"
#include "amp_defines.h"
#include "aos_network.h"
#include "amp_task.h"
#include "aos/list.h"
#include "quickjs.h"
#include "quickjs_addon_common.h"
#define MOD_STR "module_network"
static JSClassID js_network_class_id;
static JSValue native_network_get_type(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
{
int ret = -1;
ret = aos_get_network_type();
return JS_NewInt32(ctx, ret);
}
static JSClassDef js_network_class = {
"NETWORK",
};
static const JSCFunctionListEntry js_network_funcs[] = {
JS_CFUNC_DEF("getType", 0, native_network_get_type)
};
static int js_network_init(JSContext *ctx, JSModuleDef *m)
{
JSValue proto;
JS_NewClassID(&js_network_class_id);
JS_NewClass(JS_GetRuntime(ctx), js_network_class_id, &js_network_class);
proto = JS_NewObject(ctx);
JS_SetPropertyFunctionList(ctx, proto, js_network_funcs, countof(js_network_funcs));
JS_SetClassProto(ctx, js_network_class_id, proto);
return JS_SetModuleExportList(ctx, m, js_network_funcs, countof(js_network_funcs));
}
JSModuleDef *js_init_module_network(JSContext *ctx, const char *module_name)
{
JSModuleDef *m;
m = JS_NewCModule(ctx, module_name, js_network_init);
if (!m)
return NULL;
JS_AddModuleExportList(ctx, m, js_network_funcs, countof(js_network_funcs));
return m;
}
void module_network_register(void)
{
amp_debug(MOD_STR, "module_network_register");
JSContext *ctx = js_get_context();
js_init_module_network(ctx, "NETWORK");
}
| 24.637681 | 107 | 0.741765 |
b8558d43c2fa2706ef329ac8f746d5c27fbc7124 | 4,651 | h | C | termsrv/drivers/rdp/rdpperf/rdpcount/utildll.h | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | termsrv/drivers/rdp/rdpperf/rdpcount/utildll.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | termsrv/drivers/rdp/rdpperf/rdpcount/utildll.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | /*******************************************************************************
* utildll.h
*
* UTILDLL WinStation utility support functions header file (export stuff)
*
* Copyright (C) 1997, Citrix Systems Inc.
* Copyright (C) 1997-1999 Microsoft Corp.
*
* $Author: butchd $ Butch Davis
*******************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/*
* UTILDLL defines and typedefs
*/
typedef struct _ELAPSEDTIME {
USHORT days;
USHORT hours;
USHORT minutes;
USHORT seconds;
} ELAPSEDTIME, * PELAPSEDTIME;
#define MAX_PROCESSNAME 18
#define UTILDLL_NAME TEXT("UTILDLL.DLL")
#define SYSTEM_MESSAGE_MAX 256
#define MAX_ELAPSED_TIME_LENGTH 15
#define MAX_DATE_TIME_LENGTH 16
/*
* UTILDLL function prototypes
*/
void StandardErrorMessage( LPCTSTR pszAppName,
HWND hwndApp,
HINSTANCE hinstApp,
ULONG LogonId,
UINT nId,
int nErrorResourceID, ...);
LPWSTR WINAPI GetSystemMessageW( ULONG LogonId, UINT nId, LPWSTR chBuffer, int chBuffSize );
LPSTR WINAPI GetSystemMessageA( ULONG LogonId, UINT nId, LPSTR chBuffer, int chBuffSize );
#ifdef UNICODE
#define GetSystemMessage GetSystemMessageW
#else
#define GetSystemMessage GetSystemMessageA
#endif
PPDPARAMS WINAPI WinEnumerateDevices( HWND hWnd,
PPDCONFIG3 pPdConfig,
PULONG pEntries,
BOOL bInSetup );
BOOL WINAPI NetworkDeviceEnumerate( PPDCONFIG3, PULONG, PPDPARAMS,
PULONG, BOOL );
BOOL WINAPI QueryCurrentWinStation( PWINSTATIONNAME pWSName, LPTSTR pUserName,
PULONG pLogonId, PULONG pWSFlags );
LONG WINAPI RegGetNetworkDeviceName( HANDLE hServer, PPDCONFIG3 pPdConfig,
PPDPARAMS pPdParams, LPTSTR szDeviceName,
int nDeviceName );
LONG WINAPI RegGetNetworkServiceName( HANDLE hServer,
LPTSTR szServiceKey,
LPTSTR szServiceName,
int nServiceName );
BOOL WINAPI AsyncDeviceEnumerate( PPDCONFIG3, PULONG, PPDPARAMS,
PULONG, BOOL );
BOOL WINAPI NetBIOSDeviceEnumerate( PPDCONFIG3, PULONG, PPDPARAMS,
PULONG, BOOL );
void WINAPI FormDecoratedAsyncDeviceName( LPTSTR pDeviceName,
PASYNCCONFIG pAsyncConfig );
void WINAPI ParseDecoratedAsyncDeviceName( LPCTSTR pDeviceName,
PASYNCCONFIG pAsyncConfig );
void WINAPI SetupAsyncCdConfig( PASYNCCONFIG pAsyncConfig,
PCDCONFIG pCdConfig );
BOOL WINAPI InstallModem( HWND hwndOwner );
BOOL WINAPI ConfigureModem( LPCTSTR pModemName, HWND hwndOwner );
BOOL GetAssociatedPortName(char *szKeyName, WCHAR *wszPortName);
void WINAPI InitializeAnonymousUserCompareList( const WCHAR *pszServer );
BOOL WINAPI HaveAnonymousUsersChanged();
void WINAPI GetUserFromSid( PSID pSid, LPTSTR pUserName, DWORD cbUserName );
void WINAPI CachedGetUserFromSid( PSID pSid, PWCHAR pUserName, PULONG cbUserName );
BOOL WINAPI TestUserForAdmin( BOOL dom );
BOOL WINAPI IsPartOfDomain( VOID );
LPCTSTR WINAPI StrSdClass( SDCLASS SdClass );
LPCTSTR WINAPI StrConnectState( WINSTATIONSTATECLASS ConnectState,
BOOL bShortString );
LPCTSTR WINAPI StrProcessState( ULONG State );
LPCTSTR WINAPI StrSystemWaitReason( ULONG WaitReason );
LPCTSTR WINAPI GetUnknownString();
void WINAPI CalculateElapsedTime( LARGE_INTEGER *pTime,
ELAPSEDTIME *pElapsedTime );
int WINAPI CompareElapsedTime( ELAPSEDTIME *pElapsedTime1,
ELAPSEDTIME *pElapsedTime2,
BOOL bCompareSeconds );
void WINAPI ElapsedTimeString( ELAPSEDTIME *pElapsedTime,
BOOL bIncludeSeconds,
LPTSTR pString );
void WINAPI DateTimeString( LARGE_INTEGER *pTime, LPTSTR pString );
void WINAPI CurrentDateTimeString( LPTSTR pString );
LARGE_INTEGER WINAPI CalculateDiffTime( LARGE_INTEGER, LARGE_INTEGER );
LPWSTR WINAPI EnumerateMultiUserServers( LPWSTR pDomain );
#ifdef __cplusplus
}
#endif
| 43.877358 | 93 | 0.599011 |
fcbd8f49be2ebaa4327ec2e6e99cef24307d780b | 285 | c | C | src/lib/ansi/strcpy.c | macminix/MacMinix | 12262051184fb2fe10ad0a2156546454e38a3e57 | [
"BSD-3-Clause"
] | 30 | 2015-02-17T23:26:16.000Z | 2022-02-22T19:40:04.000Z | src/lib/ansi/strcpy.c | macminix/MacMinix | 12262051184fb2fe10ad0a2156546454e38a3e57 | [
"BSD-3-Clause"
] | null | null | null | src/lib/ansi/strcpy.c | macminix/MacMinix | 12262051184fb2fe10ad0a2156546454e38a3e57 | [
"BSD-3-Clause"
] | 7 | 2016-07-02T20:33:49.000Z | 2022-02-23T14:03:58.000Z | #include <lib.h>
/* strcpy - copy string src to dst */
#include <string.h>
char *strcpy(dst, src)
char *dst;
_CONST char *src;
{
register char *dscan;
register _CONST char *sscan;
dscan = dst;
sscan = src;
while ((*dscan++ = *sscan++) != '\0') continue;
return(dst);
}
| 15.833333 | 49 | 0.610526 |
119c070a9059f42d2a73fe693e5c15c43d2c3b1e | 1,595 | h | C | Engine/Dependences/Framework/Helper/inc/Types/List.h | GlebShikovec/SREngine | bb806c3e4da06ef6fddee5b46ed5d2fca231be43 | [
"MIT"
] | 7 | 2020-10-16T11:34:27.000Z | 2022-03-12T17:53:15.000Z | Engine/Dependences/Framework/Helper/inc/Types/List.h | Kiper220/SREngine | f1fa36b5ded1f489a9fdb59d8d4b40eb294ba9ec | [
"MIT"
] | 1 | 2022-03-07T14:42:22.000Z | 2022-03-07T14:42:22.000Z | Engine/Dependences/Framework/Helper/inc/Types/List.h | GlebShikovec/SREngine | bb806c3e4da06ef6fddee5b46ed5d2fca231be43 | [
"MIT"
] | 6 | 2021-05-06T15:09:52.000Z | 2022-03-12T17:57:14.000Z | //
// Created by Nikita on 04.03.2021.
//
#ifndef GAMEENGINE_LIST_H
#define GAMEENGINE_LIST_H
#include <vector>
#include <mutex>
namespace Framework::Helper::Types {
template <typename T> class List {
private:
std::vector<T> self = std::vector<T>();
std::mutex m_mutex = std::mutex();
public:
List() {
}
List(List& list) {
this->self = list.self;
}
List(const List& list) {
this->self = list.self;
}
explicit List(std::vector<T> list) {
this->self = list;
}
~List() {
//m_mutex.lock();
//self.clear();
//m_mutex.unlock();
}
public:
[[nodiscard]] inline size_t Size() const {
return self.size();
}
inline const T &operator[](size_t id) const {
return self[id];
}
inline T &operator[](size_t id) {
return self[id];
}
[[nodiscard]] inline T Get(unsigned int id) {
//std::cout << self.size() << std::endl;
//std::cout << id << std::endl;
m_mutex.lock();
T t = self[id];
m_mutex.unlock();
return t;
}
inline void Set(unsigned int id, T value) {
m_mutex.lock();
self[id] = value;
m_mutex.unlock();
}
inline void PushBack(T value) {
m_mutex.lock();
self.push_back(value);
m_mutex.unlock();
}
};
}
#endif //GAMEENGINE_LIST_H
| 21.266667 | 53 | 0.467085 |
527c757aa6374705b05cd8c5c576e2bfa042a0e9 | 11,514 | h | C | libpixelflinger/codeflinger/Arm64Assembler.h | imranpopz/android_bootable_recovery-1 | ec4512ad1e20f640b3dcd6faf8c04cae711e4f30 | [
"Apache-2.0"
] | 3 | 2018-04-01T18:35:29.000Z | 2020-12-18T21:09:53.000Z | libpixelflinger/codeflinger/Arm64Assembler.h | imranpopz/android_bootable_recovery-1 | ec4512ad1e20f640b3dcd6faf8c04cae711e4f30 | [
"Apache-2.0"
] | 2 | 2017-04-24T12:29:05.000Z | 2017-05-09T12:27:10.000Z | libpixelflinger/codeflinger/Arm64Assembler.h | imranpopz/android_bootable_recovery-1 | ec4512ad1e20f640b3dcd6faf8c04cae711e4f30 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (C) 2013 The Android Open Source Project
* 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.
*
* 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 ANDROID_ARMTOARM64ASSEMBLER_H
#define ANDROID_ARMTOARM64ASSEMBLER_H
#include <stdint.h>
#include <sys/types.h>
#include "tinyutils/smartpointer.h"
#include "utils/Vector.h"
#include "utils/KeyedVector.h"
#include "tinyutils/smartpointer.h"
#include "codeflinger/ARMAssemblerInterface.h"
#include "codeflinger/CodeCache.h"
namespace android {
// ----------------------------------------------------------------------------
class ArmToArm64Assembler : public ARMAssemblerInterface
{
public:
explicit ArmToArm64Assembler(const sp<Assembly>& assembly);
explicit ArmToArm64Assembler(void *base);
virtual ~ArmToArm64Assembler();
uint32_t* base() const;
uint32_t* pc() const;
void disassemble(const char* name);
// ------------------------------------------------------------------------
// ARMAssemblerInterface...
// ------------------------------------------------------------------------
virtual void reset();
virtual int generate(const char* name);
virtual int getCodegenArch();
virtual void prolog();
virtual void epilog(uint32_t touched);
virtual void comment(const char* string);
// -----------------------------------------------------------------------
// shifters and addressing modes
// -----------------------------------------------------------------------
// shifters...
virtual bool isValidImmediate(uint32_t immed);
virtual int buildImmediate(uint32_t i, uint32_t& rot, uint32_t& imm);
virtual uint32_t imm(uint32_t immediate);
virtual uint32_t reg_imm(int Rm, int type, uint32_t shift);
virtual uint32_t reg_rrx(int Rm);
virtual uint32_t reg_reg(int Rm, int type, int Rs);
// addressing modes...
virtual uint32_t immed12_pre(int32_t immed12, int W=0);
virtual uint32_t immed12_post(int32_t immed12);
virtual uint32_t reg_scale_pre(int Rm, int type=0, uint32_t shift=0, int W=0);
virtual uint32_t reg_scale_post(int Rm, int type=0, uint32_t shift=0);
virtual uint32_t immed8_pre(int32_t immed8, int W=0);
virtual uint32_t immed8_post(int32_t immed8);
virtual uint32_t reg_pre(int Rm, int W=0);
virtual uint32_t reg_post(int Rm);
virtual void dataProcessing(int opcode, int cc, int s,
int Rd, int Rn,
uint32_t Op2);
virtual void MLA(int cc, int s,
int Rd, int Rm, int Rs, int Rn);
virtual void MUL(int cc, int s,
int Rd, int Rm, int Rs);
virtual void UMULL(int cc, int s,
int RdLo, int RdHi, int Rm, int Rs);
virtual void UMUAL(int cc, int s,
int RdLo, int RdHi, int Rm, int Rs);
virtual void SMULL(int cc, int s,
int RdLo, int RdHi, int Rm, int Rs);
virtual void SMUAL(int cc, int s,
int RdLo, int RdHi, int Rm, int Rs);
virtual void B(int cc, uint32_t* pc);
virtual void BL(int cc, uint32_t* pc);
virtual void BX(int cc, int Rn);
virtual void label(const char* theLabel);
virtual void B(int cc, const char* label);
virtual void BL(int cc, const char* label);
virtual uint32_t* pcForLabel(const char* label);
virtual void ADDR_LDR(int cc, int Rd,
int Rn, uint32_t offset = 0);
virtual void ADDR_ADD(int cc, int s, int Rd,
int Rn, uint32_t Op2);
virtual void ADDR_SUB(int cc, int s, int Rd,
int Rn, uint32_t Op2);
virtual void ADDR_STR (int cc, int Rd,
int Rn, uint32_t offset = 0);
virtual void LDR (int cc, int Rd,
int Rn, uint32_t offset = 0);
virtual void LDRB(int cc, int Rd,
int Rn, uint32_t offset = 0);
virtual void STR (int cc, int Rd,
int Rn, uint32_t offset = 0);
virtual void STRB(int cc, int Rd,
int Rn, uint32_t offset = 0);
virtual void LDRH (int cc, int Rd,
int Rn, uint32_t offset = 0);
virtual void LDRSB(int cc, int Rd,
int Rn, uint32_t offset = 0);
virtual void LDRSH(int cc, int Rd,
int Rn, uint32_t offset = 0);
virtual void STRH (int cc, int Rd,
int Rn, uint32_t offset = 0);
virtual void LDM(int cc, int dir,
int Rn, int W, uint32_t reg_list);
virtual void STM(int cc, int dir,
int Rn, int W, uint32_t reg_list);
virtual void SWP(int cc, int Rn, int Rd, int Rm);
virtual void SWPB(int cc, int Rn, int Rd, int Rm);
virtual void SWI(int cc, uint32_t comment);
virtual void PLD(int Rn, uint32_t offset);
virtual void CLZ(int cc, int Rd, int Rm);
virtual void QADD(int cc, int Rd, int Rm, int Rn);
virtual void QDADD(int cc, int Rd, int Rm, int Rn);
virtual void QSUB(int cc, int Rd, int Rm, int Rn);
virtual void QDSUB(int cc, int Rd, int Rm, int Rn);
virtual void SMUL(int cc, int xy,
int Rd, int Rm, int Rs);
virtual void SMULW(int cc, int y,
int Rd, int Rm, int Rs);
virtual void SMLA(int cc, int xy,
int Rd, int Rm, int Rs, int Rn);
virtual void SMLAL(int cc, int xy,
int RdHi, int RdLo, int Rs, int Rm);
virtual void SMLAW(int cc, int y,
int Rd, int Rm, int Rs, int Rn);
virtual void UXTB16(int cc, int Rd, int Rm, int rotate);
virtual void UBFX(int cc, int Rd, int Rn, int lsb, int width);
private:
ArmToArm64Assembler(const ArmToArm64Assembler& rhs);
ArmToArm64Assembler& operator = (const ArmToArm64Assembler& rhs);
// -----------------------------------------------------------------------
// helper functions
// -----------------------------------------------------------------------
void dataTransfer(int operation, int cc, int Rd, int Rn,
uint32_t operand_type, uint32_t size = 32);
void dataProcessingCommon(int opcode, int s,
int Rd, int Rn, uint32_t Op2);
// -----------------------------------------------------------------------
// Arm64 instructions
// -----------------------------------------------------------------------
uint32_t A64_B_COND(uint32_t cc, uint32_t offset);
uint32_t A64_RET(uint32_t Rn);
uint32_t A64_LDRSTR_Wm_SXTW_0(uint32_t operation,
uint32_t size, uint32_t Rt,
uint32_t Rn, uint32_t Rm);
uint32_t A64_STR_IMM_PreIndex(uint32_t Rt, uint32_t Rn, int32_t simm);
uint32_t A64_LDR_IMM_PostIndex(uint32_t Rt,uint32_t Rn, int32_t simm);
uint32_t A64_ADD_X_Wm_SXTW(uint32_t Rd, uint32_t Rn, uint32_t Rm,
uint32_t amount);
uint32_t A64_SUB_X_Wm_SXTW(uint32_t Rd, uint32_t Rn, uint32_t Rm,
uint32_t amount);
uint32_t A64_ADD_IMM_X(uint32_t Rd, uint32_t Rn,
uint32_t imm, uint32_t shift = 0);
uint32_t A64_SUB_IMM_X(uint32_t Rd, uint32_t Rn,
uint32_t imm, uint32_t shift = 0);
uint32_t A64_ADD_X(uint32_t Rd, uint32_t Rn,
uint32_t Rm, uint32_t shift = 0, uint32_t amount = 0);
uint32_t A64_ADD_W(uint32_t Rd, uint32_t Rn, uint32_t Rm,
uint32_t shift = 0, uint32_t amount = 0);
uint32_t A64_SUB_W(uint32_t Rd, uint32_t Rn, uint32_t Rm,
uint32_t shift = 0, uint32_t amount = 0,
uint32_t setflag = 0);
uint32_t A64_AND_W(uint32_t Rd, uint32_t Rn,
uint32_t Rm, uint32_t shift = 0, uint32_t amount = 0);
uint32_t A64_ORR_W(uint32_t Rd, uint32_t Rn,
uint32_t Rm, uint32_t shift = 0, uint32_t amount = 0);
uint32_t A64_ORN_W(uint32_t Rd, uint32_t Rn,
uint32_t Rm, uint32_t shift = 0, uint32_t amount = 0);
uint32_t A64_MOVZ_W(uint32_t Rd, uint32_t imm, uint32_t shift);
uint32_t A64_MOVZ_X(uint32_t Rd, uint32_t imm, uint32_t shift);
uint32_t A64_MOVK_W(uint32_t Rd, uint32_t imm, uint32_t shift);
uint32_t A64_SMADDL(uint32_t Rd, uint32_t Rn, uint32_t Rm, uint32_t Ra);
uint32_t A64_MADD_W(uint32_t Rd, uint32_t Rn, uint32_t Rm, uint32_t Ra);
uint32_t A64_SBFM_W(uint32_t Rd, uint32_t Rn,
uint32_t immr, uint32_t imms);
uint32_t A64_UBFM_W(uint32_t Rd, uint32_t Rn,
uint32_t immr, uint32_t imms);
uint32_t A64_UBFM_X(uint32_t Rd, uint32_t Rn,
uint32_t immr, uint32_t imms);
uint32_t A64_EXTR_W(uint32_t Rd, uint32_t Rn, uint32_t Rm, uint32_t lsb);
uint32_t A64_CSEL_X(uint32_t Rd, uint32_t Rn, uint32_t Rm, uint32_t cond);
uint32_t A64_CSEL_W(uint32_t Rd, uint32_t Rn, uint32_t Rm, uint32_t cond);
uint32_t* mBase;
uint32_t* mPC;
uint32_t* mPrologPC;
int64_t mDuration;
uint32_t mTmpReg1, mTmpReg2, mTmpReg3, mZeroReg;
struct branch_target_t {
inline branch_target_t() : label(0), pc(0) { }
inline branch_target_t(const char* l, uint32_t* p)
: label(l), pc(p) { }
const char* label;
uint32_t* pc;
};
sp<Assembly> mAssembly;
Vector<branch_target_t> mBranchTargets;
KeyedVector< const char*, uint32_t* > mLabels;
KeyedVector< uint32_t*, const char* > mLabelsInverseMapping;
KeyedVector< uint32_t*, const char* > mComments;
enum operand_type_t
{
OPERAND_REG = 0x20,
OPERAND_IMM,
OPERAND_REG_IMM,
OPERAND_REG_OFFSET,
OPERAND_UNSUPPORTED
};
struct addr_mode_t {
int32_t immediate;
bool writeback;
bool preindex;
bool postindex;
int32_t reg_imm_Rm;
int32_t reg_imm_type;
uint32_t reg_imm_shift;
int32_t reg_offset;
} mAddrMode;
};
}; // namespace android
#endif //ANDROID_ARM64ASSEMBLER_H
| 39.56701 | 85 | 0.593104 |
26e35723139823f50286a1756adcbc4f21807a34 | 444 | h | C | snippets/include/network_apn_settings.h | jbrryhooves/lwgsm | 98924cfb5008e290f15f617755bdc8ca54c9ca04 | [
"MIT"
] | 130 | 2020-07-15T01:12:52.000Z | 2022-03-24T09:34:57.000Z | snippets/include/network_apn_settings.h | jbrryhooves/lwgsm | 98924cfb5008e290f15f617755bdc8ca54c9ca04 | [
"MIT"
] | 31 | 2020-08-05T12:43:08.000Z | 2022-03-21T10:21:08.000Z | snippets/include/network_apn_settings.h | jbrryhooves/lwgsm | 98924cfb5008e290f15f617755bdc8ca54c9ca04 | [
"MIT"
] | 57 | 2018-02-09T10:49:30.000Z | 2019-12-05T08:35:38.000Z | #ifndef SNIPPET_HDR_NETWORK_APN_SETTINGS_H
#define SNIPPET_HDR_NETWORK_APN_SETTINGS_H
#include "lwgsm/lwgsm_network_api.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* APN settings to attach to network */
#define NETWORK_APN "internet"
#define NETWORK_APN_USER ""
#define NETWORK_APN_PASS ""
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* SNIPPET_HDR_NETWORK_APN_SETTINGS_H */
| 22.2 | 47 | 0.713964 |
f7021536ea38f4cad52b5aa534ccd41fa2ae153c | 4,977 | h | C | sp/src/game/server/hl2/vehicle_apc.h | tingtom/Fodder | 3250572dbc56547709f564ba68e451b21660cdb4 | [
"Unlicense"
] | 15 | 2016-04-07T21:29:55.000Z | 2022-03-18T08:03:31.000Z | sp/src/game/server/hl2/vehicle_apc.h | tingtom/Fodder | 3250572dbc56547709f564ba68e451b21660cdb4 | [
"Unlicense"
] | 31 | 2016-11-27T14:38:02.000Z | 2020-06-03T11:11:29.000Z | sp/src/game/server/hl2/vehicle_apc.h | tingtom/Fodder | 3250572dbc56547709f564ba68e451b21660cdb4 | [
"Unlicense"
] | 6 | 2015-02-20T06:11:13.000Z | 2018-11-15T08:22:01.000Z | //========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef VEHICLE_APC_H
#define VEHICLE_APC_H
#ifdef _WIN32
#pragma once
#endif
#include "vehicle_base.h"
#include "smoke_trail.h"
//-----------------------------------------------------------------------------
// Purpose: Four wheel physics vehicle server vehicle with weaponry
//-----------------------------------------------------------------------------
class CAPCFourWheelServerVehicle : public CFourWheelServerVehicle
{
typedef CFourWheelServerVehicle BaseClass;
// IServerVehicle
public:
bool NPC_HasPrimaryWeapon( void ) { return true; }
void NPC_AimPrimaryWeapon( Vector vecTarget );
bool NPC_HasSecondaryWeapon( void ) { return true; }
void NPC_AimSecondaryWeapon( Vector vecTarget );
// Weaponry
void Weapon_PrimaryRanges( float *flMinRange, float *flMaxRange );
void Weapon_SecondaryRanges( float *flMinRange, float *flMaxRange );
float Weapon_PrimaryCanFireAt( void ); // Return the time at which this vehicle's primary weapon can fire again
float Weapon_SecondaryCanFireAt( void ); // Return the time at which this vehicle's secondary weapon can fire again
};
//-----------------------------------------------------------------------------
// A driveable vehicle with a gun that shoots wherever the driver looks.
//-----------------------------------------------------------------------------
class CPropAPC : public CPropVehicleDriveable
{
DECLARE_CLASS( CPropAPC, CPropVehicleDriveable );
public:
// CBaseEntity
virtual void Precache( void );
void Think( void );
virtual void Spawn(void);
virtual void Activate();
virtual void UpdateOnRemove( void );
virtual void OnRestore( void );
// CPropVehicle
virtual void CreateServerVehicle( void );
virtual void DriveVehicle( float flFrameTime, CUserCmd *ucmd, int iButtonsDown, int iButtonsReleased );
virtual void ProcessMovement( CBasePlayer *pPlayer, CMoveData *pMoveData );
virtual Class_T ClassifyPassenger( CBaseCombatCharacter *pPassenger, Class_T defaultClassification );
virtual int OnTakeDamage( const CTakeDamageInfo &info );
virtual float PassengerDamageModifier( const CTakeDamageInfo &info );
// Weaponry
const Vector &GetPrimaryGunOrigin( void );
void AimPrimaryWeapon( const Vector &vecForward );
void AimSecondaryWeaponAt( CBaseEntity *pTarget );
float PrimaryWeaponFireTime( void ) { return m_flMachineGunTime; }
float SecondaryWeaponFireTime( void ) { return m_flRocketTime; }
float MaxAttackRange() const;
bool IsInPrimaryFiringCone() const { return m_bInFiringCone; }
// Muzzle flashes
const char *GetTracerType( void ) ;
void DoImpactEffect( trace_t &tr, int nDamageType );
void DoMuzzleFlash( void );
virtual Vector EyePosition( ); // position of eyes
Vector BodyTarget( const Vector &posSrc, bool bNoisy );
virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
private:
enum
{
MAX_SMOKE_TRAILS = 4,
MAX_EXPLOSIONS = 4,
};
// Should we trigger a damage effect?
bool ShouldTriggerDamageEffect( int nPrevHealth, int nEffectCount ) const;
// Add a smoke trail since we've taken more damage
void AddSmokeTrail( const Vector &vecPos );
// Creates the breakable husk of an attack chopper
void CreateChopperHusk();
// Pow!
void ExplodeAndThrowChunk( const Vector &vecExplosionPos );
void Event_Killed( const CTakeDamageInfo &info );
// Purpose:
void GetRocketShootPosition( Vector *pPosition );
void FireMachineGun( void );
void FireRocket( void );
// Death volley
void FireDying( );
// Create a corpse
void CreateCorpse( );
// Blows da shizzle up
void InputDestroy( inputdata_t &inputdata );
void InputFireMissileAt( inputdata_t &inputdata );
void CreateAPCLaserDot( void );
virtual bool ShouldAttractAutoAim( CBaseEntity *pAimingEnt );
private:
// Danger sounds made by the APC
float m_flDangerSoundTime;
// handbrake after the fact to keep vehicles from rolling
float m_flHandbrakeTime;
bool m_bInitialHandbrake;
// Damage effects
int m_nSmokeTrailCount;
// Machine gun attacks
int m_nMachineGunMuzzleAttachment;
int m_nMachineGunBaseAttachment;
float m_flMachineGunTime;
int m_iMachineGunBurstLeft;
Vector m_vecBarrelPos;
bool m_bInFiringCone;
// Rocket attacks
EHANDLE m_hLaserDot;
EHANDLE m_hRocketTarget;
int m_iRocketSalvoLeft;
float m_flRocketTime;
int m_nRocketAttachment;
int m_nRocketSide;
EHANDLE m_hSpecificRocketTarget;
string_t m_strMissileHint;
COutputEvent m_OnDeath;
COutputEvent m_OnFiredMissile;
COutputEvent m_OnDamaged;
COutputEvent m_OnDamagedByPlayer;
DECLARE_DATADESC();
};
#endif // VEHICLE_APC_H
| 30.533742 | 119 | 0.677316 |
9277905ac2bdfaee635bebfb780e6f3c332ca381 | 8,845 | c | C | src/conn_handler.c | lyft/statsite | e93e527e834ddb37defb9f0c143780dea39b1c13 | [
"BSD-3-Clause"
] | 7 | 2015-10-28T18:04:46.000Z | 2019-12-11T17:41:46.000Z | src/conn_handler.c | theatrus/statsite | e93e527e834ddb37defb9f0c143780dea39b1c13 | [
"BSD-3-Clause"
] | 20 | 2016-01-15T03:22:49.000Z | 2020-07-28T17:30:12.000Z | src/conn_handler.c | lyft/statsite | e93e527e834ddb37defb9f0c143780dea39b1c13 | [
"BSD-3-Clause"
] | 4 | 2018-03-07T18:42:42.000Z | 2020-11-27T11:25:28.000Z | #include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <regex.h>
#include <assert.h>
#include <pthread.h>
#include <signal.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <math.h>
#include "likely.h"
#include "metrics.h"
#include "sink.h"
#include "streaming.h"
#include "conn_handler.h"
/* Static method declarations */
static int handle_ascii_client_connect(statsite_conn_handler *handle);
static int buffer_after_terminator(char *buf, int buf_len, char terminator, char **after_term, int *after_len, bool reverse_lookup);
/**
* This is the current metrics object we are using
*/
static metrics *GLOBAL_METRICS;
static statsite_config *GLOBAL_CONFIG;
/**
* Invoked to initialize the conn handler layer.
*/
void init_conn_handler(statsite_config *config) {
// Make the initial metrics object
metrics *m = malloc(sizeof(metrics));
int res = init_metrics(config->timer_eps, config->quantiles,
config->num_quantiles, config->histograms, config->set_precision, m);
assert(res == 0);
GLOBAL_METRICS = m;
// Store the config
GLOBAL_CONFIG = config;
}
/**
* A struct passed to the flush thread which contains an instance of
* metrics and any currently configured sinks.
*/
struct flush_op {
metrics* m;
sink* sinks;
};
/**
* This is the thread that is invoked to handle flushing metrics
*/
static void* flush_thread(void *arg) {
// Cast the args
struct flush_op* ops = arg;
metrics *m = ops->m;
sink* sinks = ops->sinks;
// Get the current time
struct timeval tv;
gettimeofday(&tv, NULL);
for (sink* s = sinks; s != NULL; s = s->next) {
int res = s->command(s, m, &tv);
if (res != 0) {
syslog(LOG_WARNING, "Streaming command %s exited with status %d", s->sink_config->name, res);
}
}
// Cleanup
destroy_metrics(m);
free(m);
free(ops);
return NULL;
}
/**
* Invoked to when we've reached the flush interval timeout
*/
void flush_interval_trigger(sink* sinks) {
// Make a new metrics object
metrics *m = malloc(sizeof(metrics));
init_metrics(GLOBAL_CONFIG->timer_eps, GLOBAL_CONFIG->quantiles,
GLOBAL_CONFIG->num_quantiles, GLOBAL_CONFIG->histograms,
GLOBAL_CONFIG->set_precision, m);
// Swap with the new one
struct flush_op* ops = calloc(1, sizeof(struct flush_op));
ops->m = GLOBAL_METRICS;
ops->sinks = sinks;
GLOBAL_METRICS = m;
// Start a flush thread
pthread_t thread;
sigset_t oldset;
sigset_t newset;
sigfillset(&newset);
pthread_sigmask(SIG_BLOCK, &newset, &oldset);
int err = pthread_create(&thread, NULL, flush_thread, ops);
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
if (err == 0) {
pthread_detach(thread);
return;
}
syslog(LOG_WARNING, "Failed to spawn flush thread: %s", strerror(err));
GLOBAL_METRICS = ops->m;
destroy_metrics(m);
free(m);
}
/**
* Called when statsite is terminating to flush the
* final set of metrics
*/
void final_flush(sink* sinks) {
// Get the last set of metrics
metrics *old = GLOBAL_METRICS;
GLOBAL_METRICS = NULL;
/* We heap allocate this in order to allow it to be freed by the function */
struct flush_op* ops = calloc(1, sizeof(struct flush_op));
ops->m = old;
ops->sinks = sinks;
flush_thread(ops);
for (sink* sink = sinks; sink != NULL; sink = sink->next) {
if (sink->close)
sink->close(sink);
}
}
/**
* Invoked by the networking layer when there is new
* data to be handled. The connection handler should
* consume all the input possible, and generate responses
* to all requests.
* @arg handle The connection related information
* @return 0 on success.
*/
int handle_client_connect(statsite_conn_handler *handle) {
// Try to read the magic character, bail if no data
unsigned char magic;
if (unlikely(peek_client_byte(handle->conn, &magic) == -1)) return 0;
return handle_ascii_client_connect(handle);
}
/**
* Invoked to handle ASCII commands. This is the default
* mode for statsite, to be backwards compatible with statsd
* @arg handle The connection related information
* @return 0 on success.
*/
static int handle_ascii_client_connect(statsite_conn_handler *handle) {
// Look for the next command line
char *buf, *key, *val_str, *type_str, *sample_str, *endptr;
metric_type type;
int buf_len, should_free, status, i, after_len;
double val;
double sample_rate = 1.0;
while (1) {
sample_rate = 1.0;
status = extract_to_terminator(handle->conn, '\n', &buf, &buf_len, &should_free);
if (status == -1) return 0; // Return if no command is available
// Check for a valid metric
// Scan for the colon
status = buffer_after_terminator(buf, buf_len, ':', &val_str, &after_len, true);
if (likely(!status)) status |= buffer_after_terminator(val_str, after_len, '|', &type_str, &after_len, false);
if (unlikely(status)) {
syslog(LOG_WARNING, "Failed parse metric! Input: %s", buf);
goto ERR_RET;
}
// Convert the type
switch (*type_str) {
case 'c':
type = COUNTER;
break;
case 'h':
case 'm':
type = TIMER;
break;
case 'k': // Formerly K_V
case 'G':
type = GAUGE_DIRECT;
break;
case 'g':
type = GAUGE;
// Check if this is a delta update
switch (*val_str) {
case '+':
case '-':
type = GAUGE_DELTA;
}
break;
case 's':
type = SET;
break;
default:
type = UNKNOWN;
syslog(LOG_WARNING, "Received unknown metric type! Input: %c", *type_str);
goto ERR_RET;
}
// Increment the number of inputs received
if (GLOBAL_CONFIG->input_counter)
metrics_add_sample(GLOBAL_METRICS, COUNTER, GLOBAL_CONFIG->input_counter, 1, sample_rate);
// Fast track the set-updates
if (type == SET) {
metrics_set_update(GLOBAL_METRICS, buf, val_str);
goto END_LOOP;
}
// Convert the value to a double
val = strtod(val_str, &endptr);
if (unlikely(endptr == val_str)) {
syslog(LOG_WARNING, "Failed value conversion! Input: %s", val_str);
goto ERR_RET;
}
// Handle counter sampling if applicable
if ((type == COUNTER || type == TIMER) && !buffer_after_terminator(type_str, after_len, '@', &sample_str, &after_len, false)) {
double unchecked_rate = strtod(sample_str, &endptr);
if (unlikely(endptr == sample_str)) {
syslog(LOG_WARNING, "Failed sample rate conversion! Input: %s", sample_str);
goto ERR_RET;
}
if (likely(unchecked_rate > 0 && unchecked_rate <= 1)) {
sample_rate = unchecked_rate;
// Magnify the value
if (type == COUNTER) {
val = val * (1.0 / sample_rate);
}
}
}
// Store the sample
metrics_add_sample(GLOBAL_METRICS, type, buf, val, sample_rate);
END_LOOP:
// Make sure to free the command buffer if we need to
if (should_free) free(buf);
}
return 0;
ERR_RET:
if (should_free) free(buf);
return -1;
}
/**
* Scans the input buffer of a given length up to a terminator.
* Then sets the start of the buffer after the terminator including
* the length of the after buffer.
* @arg buf The input buffer
* @arg buf_len The length of the input buffer
* @arg terminator The terminator to scan to. Replaced with the null terminator.
* @arg after_term Output. Set to the byte after the terminator.
* @arg after_len Output. Set to the length of the output buffer.
* @arg reverse_lookup scan the input string in reverse order
* @return 0 if terminator found. -1 otherwise.
*/
static int buffer_after_terminator(char *buf, int buf_len, char terminator, char **after_term, int *after_len, bool reverse_lookup) {
char* term_addr = reverse_lookup ? memrchr(buf, terminator, buf_len)
: memchr(buf, terminator, buf_len);
if (!term_addr) {
*after_term = NULL;
return -1;
}
// Convert the space to a null-seperator
*term_addr = '\0';
// Provide the arg buffer, and arg_len
*after_term = term_addr+1;
*after_len = buf_len - (term_addr - buf + 1);
return 0;
}
| 30.291096 | 135 | 0.610967 |
59c32f04f3332c5f3d182fdb343b301c22e6e8f2 | 536 | h | C | Userland/Libraries/LibGfx/Filters/GrayscaleFilter.h | densogiaichned/serenity | 99c0b895fed02949b528437d6b450d85befde7a5 | [
"BSD-2-Clause"
] | 2 | 2022-02-16T02:12:38.000Z | 2022-02-20T18:40:41.000Z | Userland/Libraries/LibGfx/Filters/GrayscaleFilter.h | densogiaichned/serenity | 99c0b895fed02949b528437d6b450d85befde7a5 | [
"BSD-2-Clause"
] | null | null | null | Userland/Libraries/LibGfx/Filters/GrayscaleFilter.h | densogiaichned/serenity | 99c0b895fed02949b528437d6b450d85befde7a5 | [
"BSD-2-Clause"
] | null | null | null | /*
* Copyright (c) 2021, David Savary <david.savarymartinez@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/StringView.h>
#include <LibGfx/Filters/ColorFilter.h>
namespace Gfx {
class GrayscaleFilter : public ColorFilter {
public:
GrayscaleFilter() = default;
virtual ~GrayscaleFilter() = default;
virtual StringView class_name() const override { return "GrayscaleFilter"sv; }
protected:
Color convert_color(Color original) override { return original.to_grayscale(); };
};
}
| 20.615385 | 85 | 0.723881 |
1ce256babe5408037d5a66bd98507accc71f9ed5 | 8,826 | h | C | adium/Frameworks/libpurple.framework/Versions/2.10.7r5340f4a9bd6a/Headers/snactypes.h | sin-ivan/AdiumPipeEvent | 1f3b215a07729868d25197c40200e181e06f6de5 | [
"BSD-3-Clause"
] | null | null | null | adium/Frameworks/libpurple.framework/Versions/2.10.7r5340f4a9bd6a/Headers/snactypes.h | sin-ivan/AdiumPipeEvent | 1f3b215a07729868d25197c40200e181e06f6de5 | [
"BSD-3-Clause"
] | null | null | null | adium/Frameworks/libpurple.framework/Versions/2.10.7r5340f4a9bd6a/Headers/snactypes.h | sin-ivan/AdiumPipeEvent | 1f3b215a07729868d25197c40200e181e06f6de5 | [
"BSD-3-Clause"
] | null | null | null | /*
* Purple's oscar protocol plugin
* This file is the legal property of its developers.
* Please see the AUTHORS file distributed alongside this file.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
/*
* AIM Callback Types
*
*/
#ifndef _SNACTYPES_H_
#define _SNACTYPES_H_
/*
* SNAC Families.
*/
#define SNAC_FAMILY_OSERVICE 0x0001
#define SNAC_FAMILY_LOCATE 0x0002
#define SNAC_FAMILY_BUDDY 0x0003
#define SNAC_FAMILY_ICBM 0x0004
#define SNAC_FAMILY_ADVERT 0x0005
#define SNAC_FAMILY_INVITE 0x0006
#define SNAC_FAMILY_ADMIN 0x0007
#define SNAC_FAMILY_POPUP 0x0008
#define SNAC_FAMILY_BOS 0x0009
#define SNAC_FAMILY_USERLOOKUP 0x000a
#define SNAC_FAMILY_STATS 0x000b
#define SNAC_FAMILY_TRANSLATE 0x000c
#define SNAC_FAMILY_CHATNAV 0x000d
#define SNAC_FAMILY_CHAT 0x000e
#define SNAC_FAMILY_ODIR 0x000f
#define SNAC_FAMILY_BART 0x0010
#define SNAC_FAMILY_FEEDBAG 0x0013
#define SNAC_FAMILY_ICQ 0x0015
#define SNAC_FAMILY_AUTH 0x0017
#define SNAC_FAMILY_ALERT 0x0018
#define AIM_CB_FAM_SPECIAL 0xffff /* Internal libfaim use */
/*
* SNAC Family: Ack.
*
* Not really a family, but treating it as one really
* helps it fit into the libfaim callback structure better.
*
*/
#define AIM_CB_ACK_ACK 0x0001
/*
* SNAC Family: General.
*/
#define SNAC_SUBTYPE_OSERVICE_ERROR 0x0001
#define SNAC_SUBTYPE_OSERVICE_CLIENTREADY 0x0002
#define SNAC_SUBTYPE_OSERVICE_SERVERREADY 0x0003
#define SNAC_SUBTYPE_OSERVICE_SERVICEREQ 0x0004
#define SNAC_SUBTYPE_OSERVICE_REDIRECT 0x0005
#define SNAC_SUBTYPE_OSERVICE_RATEINFOREQ 0x0006
#define SNAC_SUBTYPE_OSERVICE_RATEINFO 0x0007
#define SNAC_SUBTYPE_OSERVICE_RATEINFOACK 0x0008
#define SNAC_SUBTYPE_OSERVICE_RATECHANGE 0x000a
#define SNAC_SUBTYPE_OSERVICE_SERVERPAUSE 0x000b
#define SNAC_SUBTYPE_OSERVICE_SERVERRESUME 0x000d
#define SNAC_SUBTYPE_OSERVICE_REQSELFINFO 0x000e
#define SNAC_SUBTYPE_OSERVICE_SELFINFO 0x000f
#define SNAC_SUBTYPE_OSERVICE_EVIL 0x0010
#define SNAC_SUBTYPE_OSERVICE_SETIDLE 0x0011
#define SNAC_SUBTYPE_OSERVICE_MIGRATIONREQ 0x0012
#define SNAC_SUBTYPE_OSERVICE_MOTD 0x0013
#define SNAC_SUBTYPE_OSERVICE_SETPRIVFLAGS 0x0014
#define SNAC_SUBTYPE_OSERVICE_WELLKNOWNURL 0x0015
#define SNAC_SUBTYPE_OSERVICE_NOP 0x0016
#define SNAC_SUBTYPE_OSERVICE_DEFAULT 0xffff
/*
* SNAC Family: Location Services.
*/
#define SNAC_SUBTYPE_LOCATE_ERROR 0x0001
#define SNAC_SUBTYPE_LOCATE_REQRIGHTS 0x0002
#define SNAC_SUBTYPE_LOCATE_RIGHTSINFO 0x0003
#define SNAC_SUBTYPE_LOCATE_SETUSERINFO 0x0004
#define SNAC_SUBTYPE_LOCATE_REQUSERINFO 0x0005
#define SNAC_SUBTYPE_LOCATE_USERINFO 0x0006
#define SNAC_SUBTYPE_LOCATE_WATCHERSUBREQ 0x0007
#define SNAC_SUBTYPE_LOCATE_WATCHERNOT 0x0008
#define SNAC_SUBTYPE_LOCATE_DEFAULT 0xffff
/*
* SNAC Family: Buddy List Management Services.
*/
#define SNAC_SUBTYPE_BUDDY_ERROR 0x0001
#define SNAC_SUBTYPE_BUDDY_REQRIGHTS 0x0002
#define SNAC_SUBTYPE_BUDDY_RIGHTSINFO 0x0003
#define SNAC_SUBTYPE_BUDDY_ADDBUDDY 0x0004
#define SNAC_SUBTYPE_BUDDY_REMBUDDY 0x0005
#define SNAC_SUBTYPE_BUDDY_REJECT 0x000a
#define SNAC_SUBTYPE_BUDDY_ONCOMING 0x000b
#define SNAC_SUBTYPE_BUDDY_OFFGOING 0x000c
#define SNAC_SUBTYPE_BUDDY_DEFAULT 0xffff
/*
* SNAC Family: Messaging Services.
*/
#define SNAC_SUBTYPE_ICBM_ERROR 0x0001
#define SNAC_SUBTYPE_ICBM_PARAMINFO 0x0005
#define SNAC_SUBTYPE_ICBM_INCOMING 0x0007
#define SNAC_SUBTYPE_ICBM_EVIL 0x0009
#define SNAC_SUBTYPE_ICBM_MISSEDCALL 0x000a
#define SNAC_SUBTYPE_ICBM_CLIENTAUTORESP 0x000b
#define SNAC_SUBTYPE_ICBM_ACK 0x000c
#define SNAC_SUBTYPE_ICBM_MTN 0x0014
#define SNAC_SUBTYPE_ICBM_DEFAULT 0xffff
/*
* SNAC Family: Advertisement Services
*/
#define SNAC_SUBTYPE_ADVERT_ERROR 0x0001
#define SNAC_SUBTYPE_ADVERT_DEFAULT 0xffff
/*
* SNAC Family: Invitation Services.
*/
#define SNAC_SUBTYPE_INVITE_ERROR 0x0001
#define SNAC_SUBTYPE_INVITE_DEFAULT 0xffff
/*
* SNAC Family: Administrative Services.
*/
#define SNAC_SUBTYPE_ADMIN_ERROR 0x0001
#define SNAC_SUBTYPE_ADMIN_INFOCHANGE_REPLY 0x0005
#define SNAC_SUBTYPE_ADMIN_DEFAULT 0xffff
/*
* SNAC Family: Popup Messages
*/
#define SNAC_SUBTYPE_POPUP_ERROR 0x0001
#define SNAC_SUBTYPE_POPUP_DEFAULT 0xffff
/*
* SNAC Family: Misc BOS Services.
*/
#define SNAC_SUBTYPE_BOS_ERROR 0x0001
#define SNAC_SUBTYPE_BOS_RIGHTSQUERY 0x0002
#define SNAC_SUBTYPE_BOS_RIGHTS 0x0003
#define SNAC_SUBTYPE_BOS_DEFAULT 0xffff
/*
* SNAC Family: User Lookup Services
*/
#define SNAC_SUBTYPE_USERLOOKUP_ERROR 0x0001
#define SNAC_SUBTYPE_USERLOOKUP_DEFAULT 0xffff
/*
* SNAC Family: User Status Services
*/
#define SNAC_SUBTYPE_STATS_ERROR 0x0001
#define SNAC_SUBTYPE_STATS_SETREPORTINTERVAL 0x0002
#define SNAC_SUBTYPE_STATS_REPORTACK 0x0004
#define SNAC_SUBTYPE_STATS_DEFAULT 0xffff
/*
* SNAC Family: Translation Services
*/
#define SNAC_SUBTYPE_TRANSLATE_ERROR 0x0001
#define SNAC_SUBTYPE_TRANSLATE_DEFAULT 0xffff
/*
* SNAC Family: Chat Navigation Services
*/
#define SNAC_SUBTYPE_CHATNAV_ERROR 0x0001
#define SNAC_SUBTYPE_CHATNAV_CREATE 0x0008
#define SNAC_SUBTYPE_CHATNAV_INFO 0x0009
#define SNAC_SUBTYPE_CHATNAV_DEFAULT 0xffff
/*
* SNAC Family: Chat Services
*/
#define SNAC_SUBTYPE_CHAT_ERROR 0x0001
#define SNAC_SUBTYPE_CHAT_ROOMINFOUPDATE 0x0002
#define SNAC_SUBTYPE_CHAT_USERJOIN 0x0003
#define SNAC_SUBTYPE_CHAT_USERLEAVE 0x0004
#define SNAC_SUBTYPE_CHAT_OUTGOINGMSG 0x0005
#define SNAC_SUBTYPE_CHAT_INCOMINGMSG 0x0006
#define SNAC_SUBTYPE_CHAT_DEFAULT 0xffff
/*
* SNAC Family: "New" Search
*/
#define SNAC_SUBTYPE_ODIR_ERROR 0x0001
#define SNAC_SUBTYPE_ODIR_SEARCH 0x0002
#define SNAC_SUBTYPE_ODIR_RESULTS 0x0003
/*
* SNAC Family: Buddy icons
*/
#define SNAC_SUBTYPE_BART_ERROR 0x0001
#define SNAC_SUBTYPE_BART_REQUEST 0x0004
#define SNAC_SUBTYPE_BART_RESPONSE 0x0005
/*
* SNAC Family: Server-Stored Buddy Lists
*/
#define SNAC_SUBTYPE_FEEDBAG_ERROR 0x0001
#define SNAC_SUBTYPE_FEEDBAG_REQRIGHTS 0x0002
#define SNAC_SUBTYPE_FEEDBAG_RIGHTSINFO 0x0003
#define SNAC_SUBTYPE_FEEDBAG_REQDATA 0x0004
#define SNAC_SUBTYPE_FEEDBAG_REQIFCHANGED 0x0005
#define SNAC_SUBTYPE_FEEDBAG_LIST 0x0006
#define SNAC_SUBTYPE_FEEDBAG_ACTIVATE 0x0007
#define SNAC_SUBTYPE_FEEDBAG_ADD 0x0008
#define SNAC_SUBTYPE_FEEDBAG_MOD 0x0009
#define SNAC_SUBTYPE_FEEDBAG_DEL 0x000A
#define SNAC_SUBTYPE_FEEDBAG_SRVACK 0x000E
#define SNAC_SUBTYPE_FEEDBAG_NOLIST 0x000F
#define SNAC_SUBTYPE_FEEDBAG_EDITSTART 0x0011
#define SNAC_SUBTYPE_FEEDBAG_EDITSTOP 0x0012
#define SNAC_SUBTYPE_FEEDBAG_SENDAUTH 0x0014
#define SNAC_SUBTYPE_FEEDBAG_RECVAUTH 0x0015
#define SNAC_SUBTYPE_FEEDBAG_SENDAUTHREQ 0x0018
#define SNAC_SUBTYPE_FEEDBAG_RECVAUTHREQ 0x0019
#define SNAC_SUBTYPE_FEEDBAG_SENDAUTHREP 0x001a
#define SNAC_SUBTYPE_FEEDBAG_RECVAUTHREP 0x001b
#define SNAC_SUBTYPE_FEEDBAG_ADDED 0x001c
/*
* SNAC Family: ICQ
*
* Most of these are actually special.
*/
#define SNAC_SUBTYPE_ICQ_ERROR 0x0001
#define SNAC_SUBTYPE_ICQ_OFFLINEMSG 0x00f0
#define SNAC_SUBTYPE_ICQ_OFFLINEMSGCOMPLETE 0x00f1
#define SNAC_SUBTYPE_ICQ_INFO 0x00f2
#define SNAC_SUBTYPE_ICQ_ALIAS 0x00f3
#define SNAC_SUBTYPE_ICQ_DEFAULT 0xffff
/*
* SNAC Family: Authorizer
*
* Used only in protocol versions three and above.
*/
#define SNAC_SUBTYPE_AUTH_ERROR 0x0001
#define SNAC_SUBTYPE_AUTH_LOGINREQEST 0x0002
#define SNAC_SUBTYPE_AUTH_LOGINRESPONSE 0x0003
#define SNAC_SUBTYPE_AUTH_AUTHREQ 0x0006
#define SNAC_SUBTYPE_AUTH_AUTHRESPONSE 0x0007
#define SNAC_SUBTYPE_AUTH_SECURID_REQUEST 0x000a
#define SNAC_SUBTYPE_AUTH_SECURID_RESPONSE 0x000b
/*
* SNAC Family: Email
*
* Used for getting information on the email address
* associated with your username.
*/
#define SNAC_SUBTYPE_ALERT_ERROR 0x0001
#define SNAC_SUBTYPE_ALERT_SENDCOOKIES 0x0006
#define SNAC_SUBTYPE_ALERT_MAILSTATUS 0x0007
#define SNAC_SUBTYPE_ALERT_INIT 0x0016
/*
* SNAC Family: Internal Messages
*
* This isn't truly a SNAC family either, but using
* these, we can integrated non-SNAC services into
* the SNAC-centered libfaim callback structure.
*/
#define AIM_CB_SPECIAL_CONNERR 0x0003
#define AIM_CB_SPECIAL_CONNINITDONE 0x0006
/* SNAC flags */
#define AIM_SNACFLAGS_DESTRUCTOR 0x0001
#endif /* _SNACTYPES_H_ */
| 30.645833 | 81 | 0.83458 |
f7c8bfda85bdf54330fb6323e5d1a85410cbb999 | 2,395 | c | C | src/vnet/dpo/interface_tx_dpo.c | shacharbe/VPP.org | 5f22f4ddded8ac41487dab3069ff8d77c3916205 | [
"Apache-2.0"
] | 9 | 2018-07-25T07:43:09.000Z | 2022-03-11T09:55:03.000Z | src/vnet/dpo/interface_tx_dpo.c | shacharbe/VPP.org | 5f22f4ddded8ac41487dab3069ff8d77c3916205 | [
"Apache-2.0"
] | null | null | null | src/vnet/dpo/interface_tx_dpo.c | shacharbe/VPP.org | 5f22f4ddded8ac41487dab3069ff8d77c3916205 | [
"Apache-2.0"
] | 15 | 2018-05-07T04:56:40.000Z | 2021-11-21T09:06:29.000Z | /*
* Copyright (c) 2016 Cisco and/or its affiliates.
* 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 <vnet/dpo/interface_tx_dpo.h>
#include <vnet/adj/rewrite.h>
/*
* We do not lock nor unlock these DPOs since there is nothing to lock
* all we do is construct DPO object wrappers around a sw_if_index
*/
static void
interface_tx_dpo_lock (dpo_id_t *dpo)
{
}
static void
interface_tx_dpo_unlock (dpo_id_t *dpo)
{
}
/*
* interface_tx_dpo_add_or_lock
*
* construct DPO object wrappers around a sw_if_index
*/
void
interface_tx_dpo_add_or_lock (dpo_proto_t proto,
u32 sw_if_index,
dpo_id_t *dpo)
{
dpo_set(dpo, DPO_INTERFACE_TX, proto, sw_if_index);
}
u8*
format_interface_tx_dpo (u8* s, va_list *ap)
{
index_t index = va_arg(*ap, index_t);
CLIB_UNUSED(u32 indent) = va_arg(*ap, u32);
vnet_main_t * vnm = vnet_get_main();
return (format(s, "%U-dpo:",
format_vnet_sw_interface_name,
vnm,
vnet_get_sw_interface(vnm, index)));
}
static void
interface_tx_dpo_mem_show (void)
{
}
u32*
interface_tx_dpo_get_next_node (const dpo_id_t *dpo)
{
u32 *node_indices = NULL;
/*
* return the interface's TX node for the wrapped sw_if_index
*/
vec_add1(node_indices,
vnet_tx_node_index_for_sw_interface(vnet_get_main(),
dpo->dpoi_index));
return (node_indices);
}
const static dpo_vft_t interface_tx_dpo_vft = {
.dv_lock = interface_tx_dpo_lock,
.dv_unlock = interface_tx_dpo_unlock,
.dv_format = format_interface_tx_dpo,
.dv_mem_show = interface_tx_dpo_mem_show,
.dv_get_next_node = interface_tx_dpo_get_next_node,
};
void
interface_tx_dpo_module_init (void)
{
dpo_register(DPO_INTERFACE_TX, &interface_tx_dpo_vft, NULL);
}
| 25.752688 | 75 | 0.686013 |
97433ed2ca8c43d767e1de2ee600c2094a6dde3c | 1,321 | h | C | third_party/vulkanmemoryallocator/GrVulkanMemoryAllocator.h | psyirius/skia | 3d6493a63d28877c2734c36541fd47a07c69d569 | [
"BSD-3-Clause"
] | null | null | null | third_party/vulkanmemoryallocator/GrVulkanMemoryAllocator.h | psyirius/skia | 3d6493a63d28877c2734c36541fd47a07c69d569 | [
"BSD-3-Clause"
] | null | null | null | third_party/vulkanmemoryallocator/GrVulkanMemoryAllocator.h | psyirius/skia | 3d6493a63d28877c2734c36541fd47a07c69d569 | [
"BSD-3-Clause"
] | null | null | null | /*
* Copyright 2018 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
// We use this header to include vk_mem_alloc.h to make sure we always include GrVkDefines.h first.
// We need to do this so that the corect defines are setup before we include vulkan.h inside of
// vk_mem_alloc.h
#ifndef GrVulkanMemoryAllocator_DEFINED
#define GrVulkanMemoryAllocator_DEFINED
// We only ever include this from src files which have already included vulkan.
#ifndef VULKAN_CORE_H_
#error "vulkan_core.h has not been included before trying to include the GrVulkanMemoryAllocator"
#endif
// vk_mem_alloc.h checks to see if VULKAN_H_ has been included before trying to include vulkan.h.
// However, some builds of Skia may not have access to vulkan.h and just have access to
// vulkan_core.h. So we pretend we've already included vulkan.h (if it already hasn't been) which
// will be fine for building internal skia files. If we do fake it out by defining VULKAN_H_ we
// need to make sure to undefine it incase outside client code does later try to include the
// real vulkan.h
#ifndef VULKAN_H_
#define VULKAN_H_
#define GR_NEEDED_TO_DEFINE_VULKAN_H
#endif
#include "include/vk_mem_alloc.h"
#ifdef GR_NEEDED_TO_DEFINE_VULKAN_H
#undef VULKAN_H_
#endif
#endif
| 37.742857 | 99 | 0.786525 |
3e102236c3212b2c93139988e50a086948a3311d | 24,859 | c | C | components/fonts-tdf/gohufont_11b.c | dermotduffy/flipdots | e108191b0ef6d44f1d0282ae6e4b15a49ec04648 | [
"Apache-2.0"
] | 2 | 2017-07-13T03:27:48.000Z | 2017-07-13T03:27:52.000Z | components/fonts-tdf/gohufont_11b.c | dermotduffy/flipdots | e108191b0ef6d44f1d0282ae6e4b15a49ec04648 | [
"Apache-2.0"
] | null | null | null | components/fonts-tdf/gohufont_11b.c | dermotduffy/flipdots | e108191b0ef6d44f1d0282ae6e4b15a49ec04648 | [
"Apache-2.0"
] | null | null | null | #include "gohufont_11b.h"
/*
** Font data for gohufont 11b (http://font.gohu.org/)
*/
/* Character bitmaps for GohuFont 11b */
const uint8_t gohufont_11b_bitmaps[] =
{
/* @0 ' ' (2 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
/* @11 '!' (2 pixels wide) */
0x00, //
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0x00, //
0xC0, // ##
0x00, //
0x00, //
/* @22 '"' (4 pixels wide) */
0x00, //
0xF0, // ####
0xF0, // ####
0xF0, // ####
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
/* @33 '#' (6 pixels wide) */
0x00, //
0x78, // ####
0x78, // ####
0xFC, // ######
0x78, // ####
0xFC, // ######
0x78, // ####
0x78, // ####
0x00, //
0x00, //
0x00, //
/* @44 '$' (6 pixels wide) */
0x00, //
0x30, // ##
0x78, // ####
0xFC, // ######
0xF0, // ####
0x78, // ####
0x3C, // ####
0xFC, // ######
0x78, // ####
0x30, // ##
0x00, //
/* @55 '%' (6 pixels wide) */
0x00, //
0x00, //
0x6C, // ## ##
0xFC, // ######
0x78, // ####
0x30, // ##
0x78, // ####
0xFC, // ######
0xD8, // ## ##
0x00, //
0x00, //
/* @66 '&' (6 pixels wide) */
0x00, //
0x00, //
0x70, // ###
0xD8, // ## ##
0xF0, // ####
0x60, // ##
0xFC, // ######
0xD8, // ## ##
0x7C, // #####
0x00, //
0x00, //
/* @77 ''' (2 pixels wide) */
0x00, //
0xC0, // ##
0xC0, // ##
0xC0, // ##
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
/* @88 '(' (4 pixels wide) */
0x00, //
0x30, // ##
0x60, // ##
0x60, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0x60, // ##
0x60, // ##
0x30, // ##
0x00, //
/* @99 ')' (4 pixels wide) */
0x00, //
0xC0, // ##
0x60, // ##
0x60, // ##
0x30, // ##
0x30, // ##
0x30, // ##
0x60, // ##
0x60, // ##
0xC0, // ##
0x00, //
/* @110 '*' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x30, // ##
0xFC, // ######
0x78, // ####
0xFC, // ######
0x30, // ##
0x00, //
0x00, //
0x00, //
/* @121 '+' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x30, // ##
0x30, // ##
0xFC, // ######
0x30, // ##
0x30, // ##
0x00, //
0x00, //
0x00, //
/* @132 ',' (3 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0xE0, // ###
0xE0, // ###
0x60, // ##
0xC0, // ##
/* @143 '-' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0xFC, // ######
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
/* @154 '.' (3 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0xE0, // ###
0xE0, // ###
0x00, //
0x00, //
/* @165 '/' (6 pixels wide) */
0x00, //
0x0C, // ##
0x0C, // ##
0x18, // ##
0x18, // ##
0x30, // ##
0x30, // ##
0x60, // ##
0x60, // ##
0xC0, // ##
0xC0, // ##
/* @176 '0' (6 pixels wide) */
0x00, //
0x00, //
0x78, // ####
0xCC, // ## ##
0xDC, // ## ###
0xFC, // ######
0xEC, // ### ##
0xCC, // ## ##
0x78, // ####
0x00, //
0x00, //
/* @187 '1' (4 pixels wide) */
0x00, //
0x00, //
0x30, // ##
0x70, // ###
0xF0, // ####
0x30, // ##
0x30, // ##
0x30, // ##
0x30, // ##
0x00, //
0x00, //
/* @198 '2' (6 pixels wide) */
0x00, //
0x00, //
0x78, // ####
0xCC, // ## ##
0x0C, // ##
0x18, // ##
0x30, // ##
0x60, // ##
0xFC, // ######
0x00, //
0x00, //
/* @209 '3' (6 pixels wide) */
0x00, //
0x00, //
0x78, // ####
0xCC, // ## ##
0x0C, // ##
0x38, // ###
0x0C, // ##
0xCC, // ## ##
0x78, // ####
0x00, //
0x00, //
/* @220 '4' (6 pixels wide) */
0x00, //
0x00, //
0x18, // ##
0x38, // ###
0x78, // ####
0xD8, // ## ##
0xFC, // ######
0x18, // ##
0x18, // ##
0x00, //
0x00, //
/* @231 '5' (6 pixels wide) */
0x00, //
0x00, //
0xFC, // ######
0xC0, // ##
0xF8, // #####
0x0C, // ##
0x0C, // ##
0xCC, // ## ##
0x78, // ####
0x00, //
0x00, //
/* @242 '6' (6 pixels wide) */
0x00, //
0x00, //
0x78, // ####
0xC0, // ##
0xF8, // #####
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0x78, // ####
0x00, //
0x00, //
/* @253 '7' (6 pixels wide) */
0x00, //
0x00, //
0xFC, // ######
0x0C, // ##
0x18, // ##
0x18, // ##
0x30, // ##
0x30, // ##
0x30, // ##
0x00, //
0x00, //
/* @264 '8' (6 pixels wide) */
0x00, //
0x00, //
0x78, // ####
0xCC, // ## ##
0xCC, // ## ##
0x78, // ####
0xCC, // ## ##
0xCC, // ## ##
0x78, // ####
0x00, //
0x00, //
/* @275 '9' (6 pixels wide) */
0x00, //
0x00, //
0x78, // ####
0xCC, // ## ##
0xCC, // ## ##
0x7C, // #####
0x0C, // ##
0x0C, // ##
0x78, // ####
0x00, //
0x00, //
/* @286 ':' (3 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0xE0, // ###
0xE0, // ###
0x00, //
0xE0, // ###
0xE0, // ###
0x00, //
0x00, //
/* @297 ';' (3 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0xE0, // ###
0xE0, // ###
0x00, //
0xE0, // ###
0xE0, // ###
0x60, // ##
0xC0, // ##
/* @308 '<' (5 pixels wide) */
0x00, //
0x00, //
0x18, // ##
0x30, // ##
0x60, // ##
0xC0, // ##
0x60, // ##
0x30, // ##
0x18, // ##
0x00, //
0x00, //
/* @319 '=' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0xFC, // ######
0x00, //
0xFC, // ######
0x00, //
0x00, //
0x00, //
0x00, //
/* @330 '>' (5 pixels wide) */
0x00, //
0x00, //
0xC0, // ##
0x60, // ##
0x30, // ##
0x18, // ##
0x30, // ##
0x60, // ##
0xC0, // ##
0x00, //
0x00, //
/* @341 '?' (6 pixels wide) */
0x00, //
0x00, //
0x78, // ####
0xCC, // ## ##
0x0C, // ##
0x18, // ##
0x30, // ##
0x00, //
0x30, // ##
0x00, //
0x00, //
/* @352 '@' (6 pixels wide) */
0x00, //
0x00, //
0x78, // ####
0xCC, // ## ##
0xFC, // ######
0xFC, // ######
0xFC, // ######
0xC0, // ##
0x7C, // #####
0x00, //
0x00, //
/* @363 'A' (6 pixels wide) */
0x00, //
0x78, // ####
0xCC, // ## ##
0xCC, // ## ##
0xFC, // ######
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0x00, //
0x00, //
/* @374 'B' (6 pixels wide) */
0x00, //
0xF8, // #####
0xCC, // ## ##
0xCC, // ## ##
0xF8, // #####
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xF8, // #####
0x00, //
0x00, //
/* @385 'C' (6 pixels wide) */
0x00, //
0x78, // ####
0xCC, // ## ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xCC, // ## ##
0x78, // ####
0x00, //
0x00, //
/* @396 'D' (6 pixels wide) */
0x00, //
0xF8, // #####
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xF8, // #####
0x00, //
0x00, //
/* @407 'E' (6 pixels wide) */
0x00, //
0xFC, // ######
0xC0, // ##
0xC0, // ##
0xF8, // #####
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xFC, // ######
0x00, //
0x00, //
/* @418 'F' (6 pixels wide) */
0x00, //
0xFC, // ######
0xC0, // ##
0xC0, // ##
0xF8, // #####
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0x00, //
0x00, //
/* @429 'G' (6 pixels wide) */
0x00, //
0x78, // ####
0xCC, // ## ##
0xC0, // ##
0xFC, // ######
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0x78, // ####
0x00, //
0x00, //
/* @440 'H' (6 pixels wide) */
0x00, //
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xFC, // ######
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0x00, //
0x00, //
/* @451 'I' (4 pixels wide) */
0x00, //
0xF0, // ####
0x60, // ##
0x60, // ##
0x60, // ##
0x60, // ##
0x60, // ##
0x60, // ##
0xF0, // ####
0x00, //
0x00, //
/* @462 'J' (6 pixels wide) */
0x00, //
0x0C, // ##
0x0C, // ##
0x0C, // ##
0x0C, // ##
0x0C, // ##
0xCC, // ## ##
0xCC, // ## ##
0x78, // ####
0x00, //
0x00, //
/* @473 'K' (6 pixels wide) */
0x00, //
0xCC, // ## ##
0xD8, // ## ##
0xF0, // ####
0xE0, // ###
0xF0, // ####
0xD8, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0x00, //
0x00, //
/* @484 'L' (6 pixels wide) */
0x00, //
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xFC, // ######
0x00, //
0x00, //
/* @495 'M' (6 pixels wide) */
0x00, //
0xCC, // ## ##
0xFC, // ######
0xFC, // ######
0xFC, // ######
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0x00, //
0x00, //
/* @506 'N' (6 pixels wide) */
0x00, //
0xCC, // ## ##
0xEC, // ### ##
0xEC, // ### ##
0xFC, // ######
0xFC, // ######
0xDC, // ## ###
0xDC, // ## ###
0xCC, // ## ##
0x00, //
0x00, //
/* @517 'O' (6 pixels wide) */
0x00, //
0x78, // ####
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0x78, // ####
0x00, //
0x00, //
/* @528 'P' (6 pixels wide) */
0x00, //
0xF8, // #####
0xCC, // ## ##
0xCC, // ## ##
0xF8, // #####
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0x00, //
0x00, //
/* @539 'Q' (6 pixels wide) */
0x00, //
0x78, // ####
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xFC, // ######
0xD8, // ## ##
0x7C, // #####
0x0C, // ##
0x00, //
/* @550 'R' (6 pixels wide) */
0x00, //
0xF8, // #####
0xCC, // ## ##
0xCC, // ## ##
0xF8, // #####
0xD8, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0x00, //
0x00, //
/* @561 'S' (6 pixels wide) */
0x00, //
0x78, // ####
0xCC, // ## ##
0xC0, // ##
0x78, // ####
0x0C, // ##
0x0C, // ##
0xCC, // ## ##
0x78, // ####
0x00, //
0x00, //
/* @572 'T' (6 pixels wide) */
0x00, //
0xFC, // ######
0x30, // ##
0x30, // ##
0x30, // ##
0x30, // ##
0x30, // ##
0x30, // ##
0x30, // ##
0x00, //
0x00, //
/* @583 'U' (6 pixels wide) */
0x00, //
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0x78, // ####
0x00, //
0x00, //
/* @594 'V' (6 pixels wide) */
0x00, //
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0x78, // ####
0x78, // ####
0x30, // ##
0x30, // ##
0x00, //
0x00, //
/* @605 'W' (6 pixels wide) */
0x00, //
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xFC, // ######
0xFC, // ######
0xFC, // ######
0x78, // ####
0x78, // ####
0x00, //
0x00, //
/* @616 'X' (6 pixels wide) */
0x00, //
0xCC, // ## ##
0xCC, // ## ##
0x78, // ####
0x30, // ##
0x78, // ####
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0x00, //
0x00, //
/* @627 'Y' (6 pixels wide) */
0x00, //
0xCC, // ## ##
0xCC, // ## ##
0x78, // ####
0x30, // ##
0x30, // ##
0x30, // ##
0x30, // ##
0x30, // ##
0x00, //
0x00, //
/* @638 'Z' (6 pixels wide) */
0x00, //
0xFC, // ######
0x0C, // ##
0x18, // ##
0x30, // ##
0x60, // ##
0xC0, // ##
0xC0, // ##
0xFC, // ######
0x00, //
0x00, //
/* @649 '[' (4 pixels wide) */
0x00, //
0xF0, // ####
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xF0, // ####
0x00, //
/* @660 '\' (6 pixels wide) */
0x00, //
0xC0, // ##
0xC0, // ##
0x60, // ##
0x60, // ##
0x30, // ##
0x30, // ##
0x18, // ##
0x18, // ##
0x0C, // ##
0x0C, // ##
/* @671 ']' (4 pixels wide) */
0x00, //
0xF0, // ####
0x30, // ##
0x30, // ##
0x30, // ##
0x30, // ##
0x30, // ##
0x30, // ##
0x30, // ##
0xF0, // ####
0x00, //
/* @682 '^' (6 pixels wide) */
0x00, //
0x00, //
0x30, // ##
0x78, // ####
0xCC, // ## ##
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
/* @693 '_' (7 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0xFE, // #######
0x00, //
/* @704 '`' (4 pixels wide) */
0x00, //
0xC0, // ##
0x60, // ##
0x30, // ##
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
0x00, //
/* @715 'a' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0x78, // ####
0x0C, // ##
0x7C, // #####
0xCC, // ## ##
0x7C, // #####
0x00, //
0x00, //
/* @726 'b' (6 pixels wide) */
0x00, //
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xF8, // #####
0xEC, // ### ##
0xCC, // ## ##
0xCC, // ## ##
0xF8, // #####
0x00, //
0x00, //
/* @737 'c' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0x7C, // #####
0xC0, // ##
0xC0, // ##
0xC0, // ##
0x7C, // #####
0x00, //
0x00, //
/* @748 'd' (6 pixels wide) */
0x00, //
0x0C, // ##
0x0C, // ##
0x0C, // ##
0x7C, // #####
0xCC, // ## ##
0xCC, // ## ##
0xDC, // ## ###
0x7C, // #####
0x00, //
0x00, //
/* @759 'e' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0x78, // ####
0xCC, // ## ##
0xFC, // ######
0xC0, // ##
0x7C, // #####
0x00, //
0x00, //
/* @770 'f' (4 pixels wide) */
0x00, //
0x70, // ###
0xC0, // ##
0xC0, // ##
0xF0, // ####
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0x00, //
0x00, //
/* @781 'g' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0x7C, // #####
0xCC, // ## ##
0xCC, // ## ##
0xDC, // ## ###
0x7C, // #####
0x0C, // ##
0x78, // ####
/* @792 'h' (6 pixels wide) */
0x00, //
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xF8, // #####
0xEC, // ### ##
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0x00, //
0x00, //
/* @803 'i' (4 pixels wide) */
0x00, //
0x00, //
0x60, // ##
0x00, //
0xE0, // ###
0x60, // ##
0x60, // ##
0x60, // ##
0x70, // ###
0x00, //
0x00, //
/* @814 'j' (4 pixels wide) */
0x00, //
0x00, //
0x30, // ##
0x00, //
0x70, // ###
0x30, // ##
0x30, // ##
0x30, // ##
0x30, // ##
0x30, // ##
0xE0, // ###
/* @825 'k' (6 pixels wide) */
0x00, //
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xD8, // ## ##
0xF0, // ####
0xF0, // ####
0xD8, // ## ##
0xCC, // ## ##
0x00, //
0x00, //
/* @836 'l' (5 pixels wide) */
0x00, //
0xE0, // ###
0x60, // ##
0x60, // ##
0x60, // ##
0x60, // ##
0x60, // ##
0x60, // ##
0x38, // ###
0x00, //
0x00, //
/* @847 'm' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0xF8, // #####
0xFC, // ######
0xFC, // ######
0xFC, // ######
0xFC, // ######
0x00, //
0x00, //
/* @858 'n' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0xF8, // #####
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0x00, //
0x00, //
/* @869 'o' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0x78, // ####
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0x78, // ####
0x00, //
0x00, //
/* @880 'p' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0xF8, // #####
0xEC, // ### ##
0xCC, // ## ##
0xCC, // ## ##
0xF8, // #####
0xC0, // ##
0xC0, // ##
/* @891 'q' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0x7C, // #####
0xCC, // ## ##
0xCC, // ## ##
0xDC, // ## ###
0x7C, // #####
0x0C, // ##
0x0C, // ##
/* @902 'r' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0xF8, // #####
0xEC, // ### ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0x00, //
0x00, //
/* @913 's' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0x78, // ####
0xC0, // ##
0x78, // ####
0x0C, // ##
0xF8, // #####
0x00, //
0x00, //
/* @924 't' (5 pixels wide) */
0x00, //
0x60, // ##
0x60, // ##
0x60, // ##
0xF8, // #####
0x60, // ##
0x60, // ##
0x60, // ##
0x38, // ###
0x00, //
0x00, //
/* @935 'u' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xDC, // ## ###
0x7C, // #####
0x00, //
0x00, //
/* @946 'v' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0xCC, // ## ##
0xCC, // ## ##
0x78, // ####
0x78, // ####
0x30, // ##
0x00, //
0x00, //
/* @957 'w' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0xCC, // ## ##
0xFC, // ######
0xFC, // ######
0xFC, // ######
0x78, // ####
0x00, //
0x00, //
/* @968 'x' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0xCC, // ## ##
0x78, // ####
0x30, // ##
0x78, // ####
0xCC, // ## ##
0x00, //
0x00, //
/* @979 'y' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0xCC, // ## ##
0xCC, // ## ##
0xCC, // ## ##
0xDC, // ## ###
0x7C, // #####
0x0C, // ##
0x78, // ####
/* @990 'z' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0xFC, // ######
0x18, // ##
0x30, // ##
0x60, // ##
0xFC, // ######
0x00, //
0x00, //
/* @1001 '{' (6 pixels wide) */
0x1C, // ###
0x30, // ##
0x30, // ##
0x30, // ##
0x30, // ##
0xE0, // ###
0x30, // ##
0x30, // ##
0x30, // ##
0x30, // ##
0x1C, // ###
/* @1012 '|' (2 pixels wide) */
0x00, //
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0xC0, // ##
0x00, //
/* @1023 '}' (6 pixels wide) */
0xE0, // ###
0x30, // ##
0x30, // ##
0x30, // ##
0x30, // ##
0x1C, // ###
0x30, // ##
0x30, // ##
0x30, // ##
0x30, // ##
0xE0, // ###
/* @1034 '~' (6 pixels wide) */
0x00, //
0x00, //
0x00, //
0x00, //
0x60, // ##
0xFC, // ######
0x18, // ##
0x00, //
0x00, //
0x00, //
0x00, //
};
/* Character descriptors for gohufont 11b */
/* { [Char width in bits], [Char height in bits], [Offset into
* gohufont_11b_bitmaps in bytes] } */
const font_char_info_t gohufont_11b_descriptors[] =
{
{2, 11, 0}, /* */
{2, 11, 11}, /* ! */
{4, 11, 22}, /* " */
{6, 11, 33}, /* # */
{6, 11, 44}, /* $ */
{6, 11, 55}, /* % */
{6, 11, 66}, /* & */
{2, 11, 77}, /* ' */
{4, 11, 88}, /* ( */
{4, 11, 99}, /* ) */
{6, 11, 110}, /* * */
{6, 11, 121}, /* + */
{3, 11, 132}, /* , */
{6, 11, 143}, /* - */
{3, 11, 154}, /* . */
{6, 11, 165}, /* / */
{6, 11, 176}, /* 0 */
{4, 11, 187}, /* 1 */
{6, 11, 198}, /* 2 */
{6, 11, 209}, /* 3 */
{6, 11, 220}, /* 4 */
{6, 11, 231}, /* 5 */
{6, 11, 242}, /* 6 */
{6, 11, 253}, /* 7 */
{6, 11, 264}, /* 8 */
{6, 11, 275}, /* 9 */
{3, 11, 286}, /* : */
{3, 11, 297}, /* ; */
{5, 11, 308}, /* < */
{6, 11, 319}, /* = */
{5, 11, 330}, /* > */
{6, 11, 341}, /* ? */
{6, 11, 352}, /* @ */
{6, 11, 363}, /* A */
{6, 11, 374}, /* B */
{6, 11, 385}, /* C */
{6, 11, 396}, /* D */
{6, 11, 407}, /* E */
{6, 11, 418}, /* F */
{6, 11, 429}, /* G */
{6, 11, 440}, /* H */
{4, 11, 451}, /* I */
{6, 11, 462}, /* J */
{6, 11, 473}, /* K */
{6, 11, 484}, /* L */
{6, 11, 495}, /* M */
{6, 11, 506}, /* N */
{6, 11, 517}, /* O */
{6, 11, 528}, /* P */
{6, 11, 539}, /* Q */
{6, 11, 550}, /* R */
{6, 11, 561}, /* S */
{6, 11, 572}, /* T */
{6, 11, 583}, /* U */
{6, 11, 594}, /* V */
{6, 11, 605}, /* W */
{6, 11, 616}, /* X */
{6, 11, 627}, /* Y */
{6, 11, 638}, /* Z */
{4, 11, 649}, /* [ */
{6, 11, 660}, /* \ */
{4, 11, 671}, /* ] */
{6, 11, 682}, /* ^ */
{7, 11, 693}, /* _ */
{4, 11, 704}, /* ` */
{6, 11, 715}, /* a */
{6, 11, 726}, /* b */
{6, 11, 737}, /* c */
{6, 11, 748}, /* d */
{6, 11, 759}, /* e */
{4, 11, 770}, /* f */
{6, 11, 781}, /* g */
{6, 11, 792}, /* h */
{4, 11, 803}, /* i */
{4, 11, 814}, /* j */
{6, 11, 825}, /* k */
{5, 11, 836}, /* l */
{6, 11, 847}, /* m */
{6, 11, 858}, /* n */
{6, 11, 869}, /* o */
{6, 11, 880}, /* p */
{6, 11, 891}, /* q */
{6, 11, 902}, /* r */
{6, 11, 913}, /* s */
{5, 11, 924}, /* t */
{6, 11, 935}, /* u */
{6, 11, 946}, /* v */
{6, 11, 957}, /* w */
{6, 11, 968}, /* x */
{6, 11, 979}, /* y */
{6, 11, 990}, /* z */
{6, 11, 1001}, /* { */
{2, 11, 1012}, /* | */
{6, 11, 1023}, /* } */
{6, 11, 1034}, /* ~ */
};
/* Font information for GohuFont 11b */
const font_info_t gohufont_11b_font_info =
{
11, /* Character height */
' ', /* Start character */
'~', /* End character */
gohufont_11b_descriptors, /* Character descriptor array */
gohufont_11b_bitmaps, /* Character bitmap array */
};
| 18.319086 | 62 | 0.26775 |
e36ba69e278b34b99c0741b98bf469bbc0c33ae6 | 251 | h | C | project/src/cuda_event.h | isikmustafa/kinectfusion-cuda | 7937a94d6a328af77aee9daa0024c9fe8db82d68 | [
"MIT"
] | 13 | 2020-08-05T06:07:38.000Z | 2021-12-14T09:47:18.000Z | project/src/cuda_event.h | isikmustafa/kinectfusion-cuda | 7937a94d6a328af77aee9daa0024c9fe8db82d68 | [
"MIT"
] | 1 | 2021-01-15T01:29:25.000Z | 2021-01-16T23:11:36.000Z | project/src/cuda_event.h | isikmustafa/kinectfusion-cuda | 7937a94d6a328af77aee9daa0024c9fe8db82d68 | [
"MIT"
] | 6 | 2019-07-19T14:28:48.000Z | 2021-06-16T15:48:10.000Z | #pragma once
#include <cuda_runtime.h>
class CudaEvent
{
public:
CudaEvent();
~CudaEvent();
void record();
void synchronize();
static float calculateElapsedTime(const CudaEvent& start, const CudaEvent& end);
private:
cudaEvent_t m_event;
}; | 13.944444 | 81 | 0.737052 |
31cc0a9e277b25b956a8168c5fd5d79e773e34c4 | 25,847 | c | C | avsys-audio.c | tizenorg/platform.core.multimedia.avsystem | b943bc1a799f4a5bc702d45b90ec39e3d5d837c8 | [
"Apache-2.0"
] | null | null | null | avsys-audio.c | tizenorg/platform.core.multimedia.avsystem | b943bc1a799f4a5bc702d45b90ec39e3d5d837c8 | [
"Apache-2.0"
] | null | null | null | avsys-audio.c | tizenorg/platform.core.multimedia.avsystem | b943bc1a799f4a5bc702d45b90ec39e3d5d837c8 | [
"Apache-2.0"
] | null | null | null | /*
* avsystem
*
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Jonghyuk Choi <jhchoi.choi@samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <time.h>
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <signal.h>
#include <string.h>
#include <fcntl.h>
#include "avsys-types.h"
#include "avsys-error.h"
#include "avsys-debug.h"
#include "avsys-audio.h"
#include "avsys-audio-logical-volume.h"
#include "avsys-common.h"
#include "avsys-audio-path.h"
#include "avsys-audio-alsa.h"
#include "avsys-audio-pasimple.h"
#include "avsys-audio-pactrl.h"
/**
* Internal functions definition
*/
#define FADEUP_CALC_BIAS (1)
static int __avsys_audio_set_info(avsys_audio_handle_t *p, avsys_audio_param_t *param);
void __init_module(void);
void __fini_module(void);
#define AVSYS_GET_HANDLE_PTR(MODE) do { \
err = avsys_audio_handle_get_ptr((int)handle, &p, MODE); \
if (AVSYS_FAIL(err)) { \
return err; \
} \
} while (0)
#define AVSYS_RELEASE_HANDLE_PTR(MODE) do { \
if (AVSYS_FAIL(avsys_audio_handle_release_ptr((int)handle, MODE))) { \
avsys_error(AVAUDIO, "audio handle release failed\n"); \
return AVSYS_STATE_ERR_INTERNAL; \
} \
} while (0)
#define AVSYS_STREAM_LOCK() do { \
pthread_mutex_lock(&gmutex);\
avsys_info(AVAUDIO, "(+) LOCKED\n"); \
} while (0)
#define AVSYS_STREAM_UNLOCK() do { \
pthread_mutex_unlock(&gmutex);\
avsys_info(AVAUDIO, "(-) UNLOCKED\n"); \
} while (0)
/**
* Internal global variable
*/
static pthread_mutex_t gmutex = PTHREAD_MUTEX_INITIALIZER;
/****************************************************************************
*
* Interface
*
***************************************************************************/
EXPORT_API
int avsys_audio_open(avsys_audio_param_t *param, avsys_handle_t *phandle, int *size)
{
int handle = -1;
avsys_audio_handle_t *p = NULL;
int err = AVSYS_STATE_ERR_UNKNOWN;
avsys_info(AVAUDIO, "%s\n", __func__);
if (param == NULL || phandle == NULL) {
avsys_error(AVAUDIO, "param or phandle is null\n");
return AVSYS_STATE_ERR_NULL_POINTER;
}
if (param->channels > 2 || param->channels < 1) {
return AVSYS_STATE_ERR_INVALID_CHANNEL;
}
if (param->mode < AVSYS_AUDIO_MODE_OUTPUT || param->mode >= AVSYS_AUDIO_MODE_NUM) {
return AVSYS_STATE_ERR_INVALID_MODE;
}
if (param->format < AVSYS_AUDIO_FORMAT_MIN || param->format > AVSYS_AUDIO_FORMAT_MAX) {
return AVSYS_STATE_ERR_INVALID_FORMAT;
}
AVSYS_STREAM_LOCK();
err = avsys_audio_handle_rejuvenation();
if (AVSYS_FAIL(err)) {
avsys_error(AVAUDIO, "Unused handle cleanup before handle allocation failed in %s\n", __func__);
goto error;
}
err = avsys_audio_handle_alloc(&handle);
if (AVSYS_STATE_ERR_RANGE_OVER == err) {
avsys_error(AVAUDIO, "audio handle is fully allocated..try cleanup\n");
err = avsys_audio_handle_rejuvenation();
if (AVSYS_FAIL(err)) {
avsys_error(AVAUDIO, "Unused handle cleanup failed in %s\n", __func__);
goto error;
}
avsys_error(AVAUDIO, "one more try...to allocate audio handle\n");
err = avsys_audio_handle_alloc(&handle);
if (AVSYS_FAIL(err)) {
avsys_error(AVAUDIO, "handle alloc failed 1 in %s\n", __func__);
goto error;
}
} else if ((AVSYS_FAIL(err)) && (err != AVSYS_STATE_ERR_RANGE_OVER)) {
avsys_error(AVAUDIO, "handle alloc failed 2 in %s\n", __func__);
goto error;
}
err = avsys_audio_handle_get_ptr(handle, &p, HANDLE_PTR_MODE_NORMAL);
if (AVSYS_FAIL(err)) {
goto error;
}
/* set information to handle */
err = __avsys_audio_set_info(p, param);
if (AVSYS_FAIL(err)) {
goto error;
}
if (p->mode == AVSYS_AUDIO_MODE_OUTPUT || p->mode == AVSYS_AUDIO_MODE_OUTPUT_CLOCK ||
p->mode == AVSYS_AUDIO_MODE_OUTPUT_LOW_LATENCY || p->mode == AVSYS_AUDIO_MODE_OUTPUT_AP_CALL || p->mode == AVSYS_AUDIO_MODE_OUTPUT_VIDEO) {
/* set volume table */
err = avsys_audio_path_set_volume(handle);
if (AVSYS_FAIL(err)) {
goto error;
}
/* update volume by type */
err = avsys_audio_handle_update_volume(p, p->gain_setting.vol_type);
if (AVSYS_FAIL(err)) {
goto error;
}
err = avsys_audio_handle_update_priority(handle, param->priority, param->handle_route, AVSYS_AUDIO_SET_PRIORITY);
if (AVSYS_FAIL(err)) {
goto error;
}
}
/* open device */
err = avsys_audio_pasimple_open_device(p->mode, p->format, p->channels, p->samplerate, p, param->handle_route);
if (AVSYS_FAIL(err)) {
goto error;
}
switch (p->mode) {
case AVSYS_AUDIO_MODE_OUTPUT:
case AVSYS_AUDIO_MODE_OUTPUT_CLOCK:
case AVSYS_AUDIO_MODE_OUTPUT_LOW_LATENCY:
case AVSYS_AUDIO_MODE_OUTPUT_VIDEO:
case AVSYS_AUDIO_MODE_OUTPUT_AP_CALL:
if (AVSYS_FAIL(avsys_audio_pasimple_set_volume(p, p->working_vol.level[AVSYS_AUDIO_CHANNEL_LEFT]))) {
avsys_error(AVAUDIO, "can not set volume in %s\n", __func__);
}
break;
default:
break;
}
*phandle = (avsys_handle_t) handle;
/* set recommended buffer size */
if (size != NULL)
*size = p->period;
else
avsys_warning(AVAUDIO, "Size is null\n");
err = avsys_audio_handle_release_ptr(handle, HANDLE_PTR_MODE_NORMAL);
if (AVSYS_FAIL(err)) {
goto error;
}
AVSYS_STREAM_UNLOCK();
return AVSYS_STATE_SUCCESS;
error:
if (p) {
avsys_audio_handle_release_ptr(handle, HANDLE_PTR_MODE_NORMAL);
}
if (handle != -1) {
if (AVSYS_FAIL(avsys_audio_handle_free(handle))) {
avsys_error(AVAUDIO, "Can not free handle %d\n", handle);
}
}
avsys_error(AVAUDIO, "failed to open : RESION %x\n", err);
*phandle = (avsys_handle_t)-1;
AVSYS_STREAM_UNLOCK();
return err;
}
EXPORT_API
int avsys_audio_close(avsys_handle_t handle)
{
avsys_audio_handle_t *p = NULL;
int err = AVSYS_STATE_ERR_UNKNOWN;
bool cp_audio = false;
bool bt_path = false;
AVSYS_STREAM_LOCK();
avsys_info(AVAUDIO, "%s, handle=[%d]\n", __func__, (int)handle);
err = avsys_audio_handle_get_ptr((int)handle, &p, HANDLE_PTR_MODE_NORMAL);
if (AVSYS_FAIL(err)) {
AVSYS_STREAM_UNLOCK();
return err;
}
if (AVSYS_FAIL(avsys_audio_handle_update_priority((int)handle, p->priority, AVSYS_AUDIO_HANDLE_ROUTE_FOLLOWING_POLICY, AVSYS_AUDIO_UNSET_PRIORITY))) {
avsys_error(AVAUDIO, "unset priority of handle %d error: %x\n", handle, err);
}
err = avsys_audio_pasimple_close_device(p);
if (AVSYS_FAIL(err)) {
avsys_error_r(AVAUDIO, "audio device close error : %x\n", err);
}
if (AVSYS_FAIL(avsys_audio_path_check_cp_audio(&cp_audio, &bt_path))) {
avsys_error(AVAUDIO, "Can not check cp audio status\n");
}
if (p->during_cp_audio && cp_audio && bt_path) {
/* set cp bt path again */
avsys_audio_path_set_single_ascn("cp_to_bt");
}
if (AVSYS_FAIL(avsys_audio_handle_release_ptr((int)handle, HANDLE_PTR_MODE_NORMAL))) {
avsys_error(AVAUDIO, "audio handle release failed\n");
AVSYS_STREAM_UNLOCK();
return AVSYS_STATE_ERR_INTERNAL;
}
avsys_audio_handle_free((int)handle);
AVSYS_STREAM_UNLOCK();
return err;
}
EXPORT_API
int avsys_audio_ampon(void)
{
avsys_info(AVAUDIO, "%s\n", __func__);
return avsys_audio_path_ex_set_amp(AVSYS_AUDIO_AMP_ON);
}
EXPORT_API
int avsys_audio_ampoff(void)
{
avsys_info(AVAUDIO, "%s\n", __func__);
return avsys_audio_path_ex_set_amp(AVSYS_AUDIO_AMP_OFF);
}
EXPORT_API
int avsys_audio_ext_device_ampon(avsysaudio_ext_device_t device_type)
{
avsys_info(AVAUDIO, "%s\n", __func__);
return avsys_audio_handle_ext_dev_set_mute(device_type, AVSYS_AUDIO_UNMUTE);
}
EXPORT_API
int avsys_audio_ext_device_ampoff(avsysaudio_ext_device_t device_type)
{
avsys_info(AVAUDIO, "%s\n", __func__);
return avsys_audio_handle_ext_dev_set_mute(device_type, AVSYS_AUDIO_MUTE);
}
EXPORT_API
int avsys_audio_set_ext_device_status(avsysaudio_ext_device_t device_type, int onoff)
{
avsys_info(AVAUDIO, "%s\n", __func__);
return avsys_audio_handle_ext_dev_status_update(device_type, onoff);
}
EXPORT_API
int avsys_audio_get_ext_device_status(avsysaudio_ext_device_t device_type, int *onoff)
{
avsys_info(AVAUDIO, "%s\n", __func__);
return avsys_audio_handle_ext_dev_status(device_type, onoff);
}
EXPORT_API
int avsys_audio_flush(avsys_handle_t handle)
{
int err = AVSYS_STATE_SUCCESS;
avsys_audio_handle_t *p = NULL;
avsys_info(AVAUDIO, "%s\n", __func__);
AVSYS_GET_HANDLE_PTR(HANDLE_PTR_MODE_NORMAL);
err = avsys_audio_pasimple_reset(p);
AVSYS_RELEASE_HANDLE_PTR(HANDLE_PTR_MODE_NORMAL);
return err;
}
EXPORT_API
int avsys_audio_drain(avsys_handle_t handle)
{
int err = AVSYS_STATE_SUCCESS;
avsys_audio_handle_t *p = NULL;
avsys_info(AVAUDIO, "%s\n", __func__);
AVSYS_GET_HANDLE_PTR(HANDLE_PTR_MODE_NORMAL);
err = avsys_audio_pasimple_drain(p);
AVSYS_RELEASE_HANDLE_PTR(HANDLE_PTR_MODE_NORMAL);
return err;
}
EXPORT_API
int avsys_audio_read(avsys_handle_t handle, void *buf, int size)
{
int err = AVSYS_STATE_SUCCESS;
avsys_audio_handle_t *p = NULL;
avsys_info(AVAUDIO, "%s\n", __func__);
if (buf == NULL) {
avsys_error(AVAUDIO, "input buffer pointer is null\n");
return AVSYS_STATE_ERR_NULL_POINTER;
}
AVSYS_GET_HANDLE_PTR(HANDLE_PTR_MODE_FAST);
if (p->mode != AVSYS_AUDIO_MODE_INPUT && p->mode != AVSYS_AUDIO_MODE_INPUT_LOW_LATENCY &&
p->mode != AVSYS_AUDIO_MODE_INPUT_HIGH_LATENCY && p->mode != AVSYS_AUDIO_MODE_INPUT_AP_CALL) {
avsys_error(AVAUDIO, "opened output mode\n");
return AVSYS_STATE_ERR_INVALID_MODE;
}
err = avsys_audio_pasimple_read(p, buf, size);
AVSYS_RELEASE_HANDLE_PTR(HANDLE_PTR_MODE_FAST);
return err;
}
EXPORT_API
int avsys_audio_write(avsys_handle_t handle, void *buf, int size)
{
int err = AVSYS_STATE_SUCCESS;
avsys_audio_handle_t *p = NULL;
avsys_info(AVAUDIO, "%s\n", __func__);
if (buf == NULL) {
avsys_error(AVAUDIO, "buf is null\n");
return AVSYS_STATE_ERR_NULL_POINTER;
}
AVSYS_GET_HANDLE_PTR(HANDLE_PTR_MODE_FAST);
if (p->mode != AVSYS_AUDIO_MODE_OUTPUT && p->mode != AVSYS_AUDIO_MODE_OUTPUT_CLOCK &&
p->mode != AVSYS_AUDIO_MODE_OUTPUT_LOW_LATENCY && p->mode != AVSYS_AUDIO_MODE_OUTPUT_AP_CALL && p->mode != AVSYS_AUDIO_MODE_OUTPUT_VIDEO) {
avsys_error(AVAUDIO, "opened input mode\n");
avsys_audio_handle_release_ptr((int)handle, HANDLE_PTR_MODE_FAST);
return AVSYS_STATE_ERR_INVALID_MODE;
}
if (p->fadeup_vol > 1) {
if (p->fadeup_multiplier == 0) {
avsys_audio_volume_t fade_volume;
fade_volume.level[AVSYS_AUDIO_CHANNEL_LEFT] = p->setting_vol.level[AVSYS_AUDIO_CHANNEL_LEFT] - (p->fadeup_vol - FADEUP_CALC_BIAS);
fade_volume.level[AVSYS_AUDIO_CHANNEL_RIGHT] = p->setting_vol.level[AVSYS_AUDIO_CHANNEL_LEFT] - (p->fadeup_vol - FADEUP_CALC_BIAS);
if (fade_volume.level[AVSYS_AUDIO_CHANNEL_LEFT] < 0) {
fade_volume.level[AVSYS_AUDIO_CHANNEL_LEFT] = 0;
}
if (fade_volume.level[AVSYS_AUDIO_CHANNEL_RIGHT] < 0) {
fade_volume.level[AVSYS_AUDIO_CHANNEL_RIGHT] = 0;
}
avsys_info(AVAUDIO, "fade_volume : %d (%d-(%d)+%d) p->fadeup_m = %d, p->msec_per_period = %d\n",
fade_volume.level[AVSYS_AUDIO_CHANNEL_LEFT],p->setting_vol.level[AVSYS_AUDIO_CHANNEL_LEFT],p->fadeup_vol,FADEUP_CALC_BIAS,
p->fadeup_multiplier, p->msec_per_period
);
avsys_audio_logical_volume_convert(&fade_volume, &p->working_vol, &p->gain_setting);
avsys_audio_pasimple_set_volume(p, p->working_vol.level[AVSYS_AUDIO_CHANNEL_LEFT]);
p->fadeup_vol--;
if (p->msec_per_period > 50)
p->fadeup_multiplier = 0;
else
p->fadeup_multiplier = FADE_UP_MULTIPLIER;
} else {
p->fadeup_multiplier--;
}
} else if (p->fadeup_vol <= -1) {
if (p->fadeup_multiplier == 0) {
int fadedown_vol = 0;
avsys_audio_volume_t fade_volume;
fadedown_vol = (-1) * (p->fadeup_vol) - FADEUP_CALC_BIAS;
fade_volume.level[AVSYS_AUDIO_CHANNEL_LEFT] = fadedown_vol;
fade_volume.level[AVSYS_AUDIO_CHANNEL_RIGHT] = fadedown_vol;
if (fade_volume.level[AVSYS_AUDIO_CHANNEL_LEFT] < 0) {
fade_volume.level[AVSYS_AUDIO_CHANNEL_LEFT] = 0;
}
if (fade_volume.level[AVSYS_AUDIO_CHANNEL_RIGHT] < 0) {
fade_volume.level[AVSYS_AUDIO_CHANNEL_RIGHT] = 0;
}
avsys_info(AVAUDIO, "fade_volume : %d (%d-%d) p->fadeup_m = %d, p->msec_per_period = %d\n",
fade_volume.level[AVSYS_AUDIO_CHANNEL_LEFT],p->fadeup_vol,FADEUP_CALC_BIAS,
p->fadeup_multiplier, p->msec_per_period);
avsys_audio_logical_volume_convert(&fade_volume, &p->working_vol, &p->gain_setting);
avsys_audio_pasimple_set_volume(p, p->working_vol.level[AVSYS_AUDIO_CHANNEL_LEFT]);
if (p->fadeup_vol < -1) {
p->fadeup_vol++;
} else if (p->fadeup_vol == -1) {
p->mute = AVSYS_AUDIO_MUTE;
}
if (p->msec_per_period > 50)
p->fadeup_multiplier = 0;
else
p->fadeup_multiplier = FADE_DOWN_MULTIPLIER;
} else {
p->fadeup_multiplier--;
}
}
err = avsys_audio_pasimple_write(p, buf, size);
AVSYS_RELEASE_HANDLE_PTR(HANDLE_PTR_MODE_FAST);
return err;
}
EXPORT_API
int avsys_audio_set_volume_fadeup(avsys_handle_t handle)
{
int err = AVSYS_STATE_SUCCESS;
avsys_audio_handle_t *p = NULL;
avsys_warning(AVAUDIO, "%s\n", __func__);
AVSYS_GET_HANDLE_PTR(HANDLE_PTR_MODE_NORMAL);
if (p->setting_vol.level[AVSYS_AUDIO_CHANNEL_LEFT] >= p->setting_vol.level[AVSYS_AUDIO_CHANNEL_RIGHT]) {
p->fadeup_vol = p->setting_vol.level[AVSYS_AUDIO_CHANNEL_LEFT]; /* + FADEUP_CALC_BIAS */
} else {
p->fadeup_vol = p->setting_vol.level[AVSYS_AUDIO_CHANNEL_RIGHT]; /* + FADEUP_CALC_BIAS; */
}
p->fadeup_multiplier = 0;
AVSYS_RELEASE_HANDLE_PTR(HANDLE_PTR_MODE_NORMAL);
return err;
}
EXPORT_API
int avsys_audio_set_mute_fadedown(avsys_handle_t handle)
{
int err = AVSYS_STATE_SUCCESS;
avsys_audio_handle_t *p = NULL;
avsys_warning(AVAUDIO, "%s\n", __func__);
AVSYS_GET_HANDLE_PTR(HANDLE_PTR_MODE_NORMAL);
if (p->setting_vol.level[AVSYS_AUDIO_CHANNEL_LEFT] >= p->setting_vol.level[AVSYS_AUDIO_CHANNEL_RIGHT]) {
p->fadeup_vol = (-1) * p->setting_vol.level[AVSYS_AUDIO_CHANNEL_LEFT];
} else {
p->fadeup_vol = (-1) * p->setting_vol.level[AVSYS_AUDIO_CHANNEL_RIGHT];
}
p->fadeup_multiplier = 0;
AVSYS_RELEASE_HANDLE_PTR(HANDLE_PTR_MODE_NORMAL);
return err;
}
/* Tuning part */
EXPORT_API
int avsys_audio_set_volume_table(int gain_type, int dev_type, int step, int lv, int rv)
{
int ret = avsys_audio_logical_volume_set_to_table(gain_type, dev_type, step, lv, rv);
avsys_audio_handle_t *ptr = NULL;
int handle = -1;
if (AVSYS_FAIL(ret)) {
return ret;
}
while(++handle < AVSYS_AUDIO_HANDLE_MAX) {
ptr = NULL;
if (AVSYS_SUCCESS(avsys_audio_handle_get_ptr(handle, &ptr, HANDLE_PTR_MODE_NORMAL))) {
avsys_audio_logical_volume_convert(&ptr->setting_vol, &ptr->working_vol, &ptr->gain_setting);
avsys_audio_handle_release_ptr(handle, HANDLE_PTR_MODE_NORMAL);
}
}
return AVSYS_STATE_SUCCESS;
}
EXPORT_API
int avsys_audio_get_volume_table(int gain_type, int dev_type, int step, int *lv, int *rv)
{
return avsys_audio_logical_volume_get_from_table(gain_type, dev_type, step, lv, rv);
}
EXPORT_API
int avsys_audio_get_volume_max_ex(int volume_type, int *max_step)
{
int volume_table = 0;
if (max_step == NULL) {
return AVSYS_STATE_ERR_NULL_POINTER;
}
volume_table = volume_type;
return avsys_audio_logical_volume_get_max(volume_table, AVSYS_AUDIO_LVOL_DEV_TYPE_SPK, max_step);
}
EXPORT_API
int avsys_audio_set_mute(avsys_handle_t handle, int mute)
{
avsys_info(AVAUDIO, "%s\n", __func__);
if (mute > AVSYS_AUDIO_MUTE || mute < AVSYS_AUDIO_UNMUTE) {
return AVSYS_STATE_ERR_INVALID_PARAMETER;
}
if (AVSYS_FAIL(avsys_audio_handle_set_mute((int)handle, mute))) {
avsys_error(AVAUDIO, "failed to set handle mute\n");
}
return AVSYS_STATE_SUCCESS;
}
EXPORT_API
int avsys_audio_get_mute(avsys_handle_t handle, int *pmute)
{
int err = AVSYS_STATE_SUCCESS;
avsys_audio_handle_t *p = NULL;
avsys_info(AVAUDIO, "%s\n", __func__);
if (pmute == NULL) {
avsys_error(AVAUDIO, "pvolume is null\n");
return AVSYS_STATE_ERR_NULL_POINTER;
}
AVSYS_GET_HANDLE_PTR(HANDLE_PTR_MODE_NORMAL);
*pmute = p->mute;
AVSYS_RELEASE_HANDLE_PTR(HANDLE_PTR_MODE_NORMAL);
return AVSYS_STATE_SUCCESS;
}
/*
* Option : AVSYS_AUDIO_PATH_OPTION_LEGACY_MODE support NowPlus style sound path function
* Option : AVSYS_AUDIO_PATH_OPTION_DUAL_OUT will effect only when out is speaker.
* Option : AVSYS_AUDIO_PATH_OPTION_JACK_AUTO will effect only when out is speaker or receiver.
* Option : AVSYS_AUDIO_PATH_OPTION_FORCED is avail only for shutdown animation
*
* Limitation : Only FORCED option can be used same time with other options (exclude LEGACY_MODE)
*/
EXPORT_API
int avsys_audio_set_path_ex(int gain, int out, int in, int option)
{
if (AVSYS_AUDIO_GAIN_EX_KEYTONE > gain || AVSYS_AUDIO_GAIN_EX_MAX <= gain ||
AVSYS_AUDIO_PATH_EX_NONE > out || AVSYS_AUDIO_PATH_EX_OUTMAX <= out ||
AVSYS_AUDIO_PATH_EX_NONE > in || AVSYS_AUDIO_PATH_EX_INMAX <= in) {
avsys_error(AVAUDIO, "Your input parameter is invalid. Please check\n");
avsys_error(AVAUDIO, " gain %d, out %d, in %d\n", gain, out, in);
return AVSYS_STATE_ERR_INVALID_PARAMETER;
}
return avsys_audio_path_ex_set_path(gain, out, in, option);
}
EXPORT_API
int avsys_audio_get_path_ex(int *gain, int *out, int *in, int *option)
{
if (!gain || !out || !in || !option) {
avsys_warning(AVAUDIO, "Your input parameter is NULL pointer. Please check.\n");
avsys_warning(AVAUDIO, " gain %p, out %p, in %p, option %p\n", gain, out, in, option);
return AVSYS_STATE_ERR_INVALID_PARAMETER;
}
return avsys_audio_path_ex_get_path(gain, out, in, option);
}
EXPORT_API
int avsys_audio_set_global_mute(int mute)
{
int err = AVSYS_STATE_SUCCESS;
avsys_info(AVAUDIO, "%s : mute=%d\n", __func__, mute);
if (mute < AVSYS_AUDIO_UNMUTE && mute > AVSYS_AUDIO_MUTE_NOLOCK) {
err = AVSYS_STATE_ERR_INVALID_PARAMETER;
} else {
err = avsys_audio_path_ex_set_mute(mute);
}
return err;
}
EXPORT_API
int avsys_audio_get_global_mute(int *pmute)
{
int err = AVSYS_STATE_SUCCESS;
avsys_info(AVAUDIO, "%s\n", __func__);
if (pmute == NULL) {
err = AVSYS_STATE_ERR_NULL_POINTER;
} else {
err = avsys_audio_path_ex_get_mute(pmute);
}
return err;
}
/**
* Internal functions implementation
*/
static int __avsys_audio_set_info(avsys_audio_handle_t *p, avsys_audio_param_t *param)
{
avsys_info(AVAUDIO, "%s\n", __func__);
avsys_info(AVAUDIO, "=============================================\n");
avsys_info(AVAUDIO, " Input Parameters (Basic Information)\n");
avsys_info(AVAUDIO, "=============================================\n");
avsys_info(AVAUDIO, " Op Mode = %d (0:out, 1:input)\n", param->mode);
avsys_info(AVAUDIO, " format = %d (0: 8bits, 1:16bits, 2:32bits)\n", param->format);
avsys_info(AVAUDIO, " channel = %d\n", param->channels);
avsys_info(AVAUDIO, " samplerate = %d\n", param->samplerate);
avsys_info(AVAUDIO, " route = %d (0: default, 1: handset)\n", param->handle_route);
avsys_info(AVAUDIO, " Vol type = %d\n", param->vol_type);
avsys_info(AVAUDIO, "=============================================\n");
p->mode = param->mode;
p->channels = param->channels;
p->samplerate = param->samplerate;
p->format = param->format;
p->priority = param->priority;
if ((param->vol_type < 0) || (param->vol_type >= AVSYS_AUDIO_VOLUME_TYPE_MAX)) {
avsys_error(AVAUDIO, "[%s] Invalid volume type %d. use default system type\n", __func__, param->vol_type);
p->gain_setting.vol_type = AVSYS_AUDIO_VOLUME_TYPE_SYSTEM;
} else {
p->gain_setting.vol_type = param->vol_type;
}
/* trivial volume value */
p->setting_vol.level[AVSYS_AUDIO_CHANNEL_LEFT] = 0;
p->setting_vol.level[AVSYS_AUDIO_CHANNEL_RIGHT] = 0;
p->working_vol.level[AVSYS_AUDIO_CHANNEL_LEFT] = 0;
p->working_vol.level[AVSYS_AUDIO_CHANNEL_RIGHT] = 0;
p->fadeup_vol = 0;
return AVSYS_STATE_SUCCESS;
}
EXPORT_API
int avsys_audio_earjack_manager_init(int *earjack_type, int *waitfd)
{
return avsys_audio_path_earjack_init(earjack_type, waitfd);
}
EXPORT_API
int avsys_audio_earjack_manager_wait(int waitfd, int *current_earjack_type, int *new_earjack_type, int *need_mute)
{
return avsys_audio_path_earjack_wait(waitfd, current_earjack_type, new_earjack_type, need_mute);
}
EXPORT_API
int avsys_audio_earjack_manager_process(int new_earjack_type)
{
return avsys_audio_path_earjack_process(new_earjack_type);
}
EXPORT_API
int avsys_audio_earjack_manager_deinit(int waitfd)
{
return avsys_audio_path_earjack_deinit(waitfd);
}
EXPORT_API
int avsys_audio_earjack_manager_get_type(void)
{
return avsys_audio_path_earjack_get_type();
}
EXPORT_API
int avsys_audio_earjack_manager_unlock(void)
{
return avsys_audio_path_earjack_unlock();
}
EXPORT_API
int avsys_audio_set_route_policy(avsys_audio_route_policy_t route)
{
/* Deprecated */
return 0;
}
EXPORT_API
int avsys_audio_get_route_policy(avsys_audio_route_policy_t *route)
{
/* Deprecated */
return 0;
}
EXPORT_API
int avsys_audio_get_current_playing_volume_type(int *volume_type)
{
if (volume_type == NULL)
return AVSYS_STATE_ERR_NULL_POINTER;
return avsys_audio_handle_current_playing_volume_type(volume_type);
}
static inline int __avsys_audio_validate_volume(const int type, const int value)
{
if (value < 0)
return -1;
switch (type) {
case AVSYS_AUDIO_VOLUME_TYPE_CALL:
if (value >= LVOLUME_MAX_BASIC) {
return -1;
}
break;
case AVSYS_AUDIO_VOLUME_TYPE_ALARM:
case AVSYS_AUDIO_VOLUME_TYPE_RINGTONE:
case AVSYS_AUDIO_VOLUME_TYPE_NOTIFICATION:
case AVSYS_AUDIO_VOLUME_TYPE_SYSTEM:
case AVSYS_AUDIO_VOLUME_TYPE_MEDIA:
case AVSYS_AUDIO_VOLUME_TYPE_MEDIA_HL:
case AVSYS_AUDIO_VOLUME_TYPE_EXT_SYSTEM_JAVA:
if (value >= LVOLUME_MAX_MULTIMEDIA) {
return -1;
}
break;
case AVSYS_AUDIO_VOLUME_TYPE_EXT_SYSTEM_ANDROID:
if (value >= LVOLUME_MAX_SINGLE) {
return -1;
}
break;
default:
return -1;
break;
}
return 0;
}
EXPORT_API
int avsys_audio_set_volume_by_type(const int type, const int value)
{
if (type < 0 || type >= AVSYS_AUDIO_VOLUME_TYPE_MAX)
return AVSYS_STATE_ERR_INVALID_PARAMETER;
if (0 > __avsys_audio_validate_volume(type, value))
return AVSYS_STATE_ERR_INVALID_PARAMETER;
return avsys_audio_handle_update_volume_by_type(type, value);
}
EXPORT_API
int avsys_audio_set_primary_volume(const int pid, const int type)
{
return avsys_audio_handle_set_primary_volume_type(pid, type, AVSYS_AUDIO_PRIMARY_VOLUME_SET);
}
EXPORT_API
int avsys_audio_clear_primary_volume(const int pid)
{
return avsys_audio_handle_set_primary_volume_type(pid, 0, AVSYS_AUDIO_PRIMARY_VOLUME_CLEAR);
}
EXPORT_API
int avsys_audio_hibernation_reset(int *vol)
{
int err = AVSYS_STATE_SUCCESS;
err = avsys_audio_path_ex_reset(1);
if (AVSYS_FAIL(err)) {
avsys_error(AVAUDIO, "avsys_audio_path_ex_reset(forced) failed 0x%x\n", err);
return err;
}
err = avsys_audio_handle_reset(vol);
if (AVSYS_FAIL(err)) {
avsys_error(AVAUDIO, "avsys_audio_handle_reset() failed 0x%x\n", err);
return err;
}
return err;
}
EXPORT_API
int avsys_audio_delay(avsys_handle_t handle, int *delay)
{
int err = AVSYS_STATE_SUCCESS;
int frame_delay = 0;
avsys_audio_handle_t *p = NULL;
AVSYS_GET_HANDLE_PTR(HANDLE_PTR_MODE_NORMAL);
err = avsys_audio_pasimple_delay(p, &frame_delay);
if (AVSYS_SUCCESS(err)) {
*delay = frame_delay;
}
AVSYS_RELEASE_HANDLE_PTR(HANDLE_PTR_MODE_NORMAL);
return err;
}
EXPORT_API
int avsys_audio_reset(avsys_handle_t handle)
{
int err = AVSYS_STATE_SUCCESS;
avsys_audio_handle_t *p = NULL;
AVSYS_GET_HANDLE_PTR(HANDLE_PTR_MODE_NORMAL);
err = avsys_audio_pasimple_reset(p);
if (AVSYS_FAIL(err)) {
avsys_error(AVAUDIO, "avsys_audio_reset() failed, 0x%X\n", err);
}
AVSYS_RELEASE_HANDLE_PTR(HANDLE_PTR_MODE_NORMAL);
return err;
}
EXPORT_API
int avsys_audio_get_period_buffer_time(avsys_handle_t handle, unsigned int *period_time, unsigned int *buffer_time)
{
int err = AVSYS_STATE_SUCCESS;
avsys_audio_handle_t *p = NULL;
unsigned int p_time = 0, b_time=0;
AVSYS_GET_HANDLE_PTR(HANDLE_PTR_MODE_NORMAL);
err = avsys_audio_pasimple_get_period_buffer_time(p, &p_time, &b_time);
if(AVSYS_FAIL(err)) {
avsys_error(AVAUDIO, "avsys_audio_get_period_buffer_time() failed, 0x%X\n",err);
}
else
{
*period_time = p_time;
*buffer_time = b_time;
avsys_info(AVAUDIO,"period time : %u, buffer_time : %u\n", p_time, b_time);
}
AVSYS_RELEASE_HANDLE_PTR(HANDLE_PTR_MODE_NORMAL);
return err;
}
EXPORT_API
int avsys_audio_cork (avsys_handle_t handle, int cork)
{
int err = AVSYS_STATE_SUCCESS;
avsys_audio_handle_t *p = NULL;
AVSYS_GET_HANDLE_PTR(HANDLE_PTR_MODE_NORMAL);
err = avsys_audio_pasimple_cork(p, cork);
if(AVSYS_FAIL(err)) {
avsys_error(AVAUDIO, "avsys_audio_pasimple_cork() failed, 0x%X\n",err);
}
AVSYS_RELEASE_HANDLE_PTR(HANDLE_PTR_MODE_NORMAL);
return err;
}
EXPORT_API
int avsys_audio_is_corked (avsys_handle_t handle, int *is_corked)
{
int err = AVSYS_STATE_SUCCESS;
avsys_audio_handle_t *p = NULL;
if (is_corked == NULL) {
return AVSYS_STATE_ERR_NULL_POINTER;
}
AVSYS_GET_HANDLE_PTR(HANDLE_PTR_MODE_NORMAL);
err = avsys_audio_pasimple_is_corked(p, is_corked);
if(AVSYS_FAIL(err)) {
avsys_error(AVAUDIO, "avsys_audio_pasimple_cork() failed, 0x%X\n",err);
}
AVSYS_RELEASE_HANDLE_PTR(HANDLE_PTR_MODE_NORMAL);
return err;
}
EXPORT_API
int avsys_audio_get_capture_status(int *on_capture)
{
return avsys_audio_handle_current_capture_status(on_capture);
}
__attribute__ ((constructor))
void __init_module(void)
{
}
__attribute__ ((destructor))
void __fini_module(void)
{
}
| 27.380297 | 151 | 0.745425 |
2da6a67c5fa2316ef23ced9f24d0eb310dc6cc30 | 2,388 | c | C | srcs/directory.c | sqatim/minishell_42 | 531dff620c3369df910beb1b396aafdfbbcf943b | [
"MIT"
] | null | null | null | srcs/directory.c | sqatim/minishell_42 | 531dff620c3369df910beb1b396aafdfbbcf943b | [
"MIT"
] | null | null | null | srcs/directory.c | sqatim/minishell_42 | 531dff620c3369df910beb1b396aafdfbbcf943b | [
"MIT"
] | null | null | null | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* directory.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: helkhatr <helkhatr@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/02/11 10:34:58 by helkhatr #+# #+# */
/* Updated: 2021/02/15 14:27:40 by helkhatr ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int check_link(char *cmd)
{
int i;
i = 0;
while (cmd[i])
{
if (cmd[i] == '/')
return (127);
i++;
}
return (0);
}
int bash_err(char *cmd)
{
ft_putstr_fd("\e[1;31mbash: ", 2);
ft_putstr_fd(cmd, 2);
ft_putendl_fd(": command not found", 2);
return (127);
}
char *directory_(t_path *path, char *cmd)
{
char *tmps;
char *link;
tmps = NULL;
if (check_link((cmd)))
{
if (!(path->dollar = check_paths((cmd))))
return (ft_strdup(cmd));
path->dollar = bash_err(cmd);
}
else
{
link = ft_strjoin(getcwd(NULL, 100), "/");
link = ft_strjoin(link, (cmd));
if (!(path->dollar = check_paths(link)))
return (link);
else
path->dollar = bash_err(cmd);
frees(&link);
}
return (NULL);
}
char *get_directory_two(t_path *path, char *cmd, char *tmp)
{
char **paths;
int i;
char *link;
char *tmps;
i = 0;
paths = ft_split(tmp, ':');
while (paths[i])
{
link = ft_strjoin(paths[i], "/");
tmps = link;
link = ft_strjoin(link, cmd);
frees(&tmps);
tmps = link;
if (!(path->dollar = check_paths(link)))
{
free_tab(&paths);
return (link);
}
frees(&link);
i++;
}
free_tab(&paths);
path->dollar = bash_err(cmd);
return (NULL);
}
char *get_directory(t_path *path, char *cmd)
{
char *tmp;
int i;
i = 0;
if (cmd)
{
tmp = search_env(path->env->fullenv, "PATH");
if (tmp && !check_link((cmd)))
return (get_directory_two(path, cmd, tmp));
else
return (directory_(path, cmd));
}
return (NULL);
}
| 22.317757 | 80 | 0.41206 |
672e29bea05b32137d079ed5f18259f1b38e427c | 1,162 | h | C | Source/Pineapple/Engine/Prefab/Game/Entity.h | JoshYaxley/Pineapple | 490b0ccdfa26e2bb6fd9ec290b43b355462dd9ec | [
"Zlib"
] | 11 | 2017-04-15T14:44:19.000Z | 2022-02-04T13:16:04.000Z | Source/Pineapple/Engine/Prefab/Game/Entity.h | JoshYaxley/Pineapple | 490b0ccdfa26e2bb6fd9ec290b43b355462dd9ec | [
"Zlib"
] | 25 | 2017-04-19T12:48:42.000Z | 2020-05-09T05:28:29.000Z | Source/Pineapple/Engine/Prefab/Game/Entity.h | JoshYaxley/Pineapple | 490b0ccdfa26e2bb6fd9ec290b43b355462dd9ec | [
"Zlib"
] | 1 | 2019-04-21T21:14:04.000Z | 2019-04-21T21:14:04.000Z | /*------------------------------------------------------------------------------
Pineapple Game Engine - Copyright (c) 2011-2017 Adam Yaxley
This software is licensed under the Zlib license (see license.txt for details)
------------------------------------------------------------------------------*/
#pragma once
#include <Pineapple/Engine/Graphics/Sprite.h>
#include <Pineapple/Engine/Physics/AABB.h>
#include <Pineapple/Engine/Physics/Particle.h>
#include <Pineapple/Engine/System/Object.h>
#include <memory>
namespace pa
{
class Entity : public Object, public Particle
{
public:
Entity(World& world);
void updatePhysics(Time deltaTime);
void updateSprite();
std::shared_ptr<Sprite> getSprite();
const std::shared_ptr<Sprite> getSprite() const;
void setSprite(std::shared_ptr<Sprite> sprite);
const AABB& getAABB() const;
AABB& getAABB();
void setAABBSizeFromSprite();
#ifdef PA_DEBUG
void enableDebugAABB();
void disableDebugAABB();
#endif
virtual void onStep(Time deltaTime) override;
private:
AABB m_aabb;
std::shared_ptr<Sprite> m_sprite;
#ifdef PA_DEBUG
std::unique_ptr<Sprite> m_aabbDebug;
#endif
};
}
| 23.24 | 80 | 0.638554 |
91794377621fe3f7269df4d8de3e2f8bd02a075e | 624 | h | C | ITProgressIndicator/ITProgressIndicatorKit/ITProgressIndicatorKit.h | iluuu1994/ITProgressIndicator | c2fe94f4b6a57fb623592e4cd7ea3243f8322452 | [
"Apache-2.0"
] | 70 | 2015-01-06T20:49:12.000Z | 2021-10-06T12:12:22.000Z | ITProgressIndicator/ITProgressIndicatorKit/ITProgressIndicatorKit.h | sb15utah/ITProgressIndicator | c2fe94f4b6a57fb623592e4cd7ea3243f8322452 | [
"Apache-2.0"
] | 6 | 2015-02-04T21:23:45.000Z | 2017-04-27T12:57:21.000Z | ITProgressIndicator/ITProgressIndicatorKit/ITProgressIndicatorKit.h | sb15utah/ITProgressIndicator | c2fe94f4b6a57fb623592e4cd7ea3243f8322452 | [
"Apache-2.0"
] | 16 | 2015-01-06T18:35:50.000Z | 2022-02-08T03:59:23.000Z | //
// ITProgressIndicatorKit.h
// ITProgressIndicatorKit
//
// Created by Matias Piipari on 27/03/2016.
// Copyright © 2016 Ilija Tovilo. All rights reserved.
//
#import <Cocoa/Cocoa.h>
//! Project version number for ITProgressIndicatorKit.
FOUNDATION_EXPORT double ITProgressIndicatorKitVersionNumber;
//! Project version string for ITProgressIndicatorKit.
FOUNDATION_EXPORT const unsigned char ITProgressIndicatorKitVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <ITProgressIndicatorKit/PublicHeader.h>
#import "ITProgressIndicator.h"
| 31.2 | 147 | 0.799679 |
bcec257a46f75c0086517e4b7abb82e89c2a4418 | 4,888 | c | C | libdisk/format/amiga/special_fx.c | davide125/Disk-Utilities | 1b2ad04f8260dd1acc83eb2334a522cb83cd95c6 | [
"Unlicense"
] | 126 | 2015-01-03T19:03:02.000Z | 2021-12-21T18:07:47.000Z | libdisk/format/amiga/special_fx.c | bsdimp/Disk-Utilities | ce19c7b6ba690bc76f25b6597eed81adf8ff4a02 | [
"Unlicense"
] | 47 | 2015-01-07T06:11:49.000Z | 2021-12-08T09:40:47.000Z | libdisk/format/amiga/special_fx.c | bsdimp/Disk-Utilities | ce19c7b6ba690bc76f25b6597eed81adf8ff4a02 | [
"Unlicense"
] | 43 | 2015-01-07T03:01:39.000Z | 2021-12-07T07:37:38.000Z | /*
* format/amiga/special_fx.c
*
* Custom longtrack format developed by Special FX and used on titles such as
* Batman The Caped Crusader, published by Ocean.
*
* Written in 2012 by Keir Fraser
*
* RAW TRACK LAYOUT:
* 12 sectors back-to-back (0x418 raw mfm bytes each):
* u16 0x8944
* u8 0
* u8 (tracknr-2)^1, sector, to_gap, mbz :: encoded as even/odd long
* u32 csum :: encoded as even/odd long
* u8 dat[512] :: encoded as even/odd block
* u16 0
*
* TRKTYP_special_fx data layout:
* u8 sector_data[12][512]
* u8 first_sector
*/
#include <libdisk/util.h>
#include <private/disk.h>
struct hdr {
uint8_t track, sector, to_gap, mbz;
};
static uint32_t checksum(uint16_t *dat)
{
unsigned int i;
uint32_t sum;
for (i = sum = 0; i < 256; i++) {
uint32_t x = be16toh(dat[i]);
x <<= i & 15;
x |= x >> 16;
sum += x;
}
sum = (int16_t)sum;
sum <<= 8;
if (sum & 0x80000000u)
sum |= 0xffu;
return sum;
}
static void init_hdr(
const struct track_info *ti, unsigned int tracknr, struct hdr *hdr)
{
memset(hdr, 0, sizeof(*hdr));
switch (ti->type) {
case TRKTYP_head_over_heels:
hdr->track = tracknr-2;
hdr->mbz = 1;
break;
default:
hdr->track = (tracknr-2)^1;
hdr->mbz = 0;
break;
}
}
static void *special_fx_write_raw(
struct disk *d, unsigned int tracknr, struct stream *s)
{
struct track_info *ti = &d->di->track[tracknr];
char *block;
unsigned int nr_valid_blocks = 0, max_to_gap = 0;
block = memalloc((12*512) + 1);
while ((stream_next_bit(s) != -1) &&
(nr_valid_blocks != ti->nr_sectors)) {
struct hdr hdr, exp;
uint32_t csum, idx_off;
uint16_t dat[512];
if (s->word != 0x8944aaaa)
continue;
idx_off = s->index_offset_bc - 31;
if (stream_next_bytes(s, dat, 8) == -1)
break;
mfm_decode_bytes(bc_mfm_even_odd, 4, dat, &hdr);
init_hdr(ti, tracknr, &exp);
if ((hdr.track != exp.track) ||
(hdr.mbz != exp.mbz) ||
(hdr.to_gap < 1) || (hdr.to_gap > 12) ||
(hdr.sector >= ti->nr_sectors) ||
(is_valid_sector(ti, hdr.sector)))
continue;
if (stream_next_bytes(s, dat, 8) == -1)
break;
mfm_decode_bytes(bc_mfm_even_odd, 4, dat, dat);
csum = be32toh(*(uint32_t *)dat);
if (stream_next_bytes(s, dat, 2*512) == -1)
break;
mfm_decode_bytes(bc_mfm_even_odd, 512, dat, dat);
if (checksum(dat) != csum)
continue;
memcpy(&block[hdr.sector*512], dat, 512);
set_sector_valid(ti, hdr.sector);
nr_valid_blocks++;
/* Look for the first written sector after track gap (or close to it as
* possible) to determine the track-data offset and first sector. */
if (hdr.to_gap > max_to_gap) {
max_to_gap = hdr.to_gap;
ti->data_bitoff = idx_off - (12-hdr.to_gap)*1048*8;
block[12*512] = (hdr.sector + hdr.to_gap) % 12;
}
}
if (nr_valid_blocks == 0) {
memfree(block);
return NULL;
}
ti->total_bits = 105500;
return block;
}
static void special_fx_read_raw(
struct disk *d, unsigned int tracknr, struct tbuf *tbuf)
{
struct track_info *ti = &d->di->track[tracknr];
struct hdr hdr;
uint32_t csum;
uint16_t *dat = (uint16_t *)ti->dat;
unsigned int i, first_sector = ti->dat[12*512];
for (i = 0; i < ti->nr_sectors; i++) {
/* sync mark */
tbuf_bits(tbuf, SPEED_AVG, bc_raw, 16, 0x8944);
/* filler */
tbuf_bits(tbuf, SPEED_AVG, bc_mfm, 8, 0);
/* header info */
init_hdr(ti, tracknr, &hdr);
hdr.sector = (first_sector + i) % 12;
hdr.to_gap = 12-i;
tbuf_bytes(tbuf, SPEED_AVG, bc_mfm_even_odd, 4, &hdr);
/* data checksum */
dat = (uint16_t *)&ti->dat[512*hdr.sector];
csum = checksum(dat);
if (!is_valid_sector(ti, i))
csum ^= 1; /* bad checksum for an invalid sector */
tbuf_bits(tbuf, SPEED_AVG, bc_mfm_even_odd, 32, csum);
/* data */
tbuf_bytes(tbuf, SPEED_AVG, bc_mfm_even_odd, 512, dat);
/* gap */
tbuf_bits(tbuf, SPEED_AVG, bc_mfm, 16, 0);
}
}
struct track_handler special_fx_handler = {
.bytes_per_sector = 512,
.nr_sectors = 12,
.write_raw = special_fx_write_raw,
.read_raw = special_fx_read_raw
};
struct track_handler head_over_heels_handler = {
.bytes_per_sector = 512,
.nr_sectors = 12,
.write_raw = special_fx_write_raw,
.read_raw = special_fx_read_raw
};
/*
* Local variables:
* mode: C
* c-file-style: "Linux"
* c-basic-offset: 4
* tab-width: 4
* indent-tabs-mode: nil
* End:
*/
| 25.862434 | 80 | 0.573241 |
87e126130fefccc0459c00a7f919f4c07d793a61 | 382 | h | C | src/wilddog_payload.h | YaoQ/wilddog-sdk-on-pcduino | e93ed39f8a2d9431c0c287e71962771dd61714ca | [
"MIT"
] | null | null | null | src/wilddog_payload.h | YaoQ/wilddog-sdk-on-pcduino | e93ed39f8a2d9431c0c287e71962771dd61714ca | [
"MIT"
] | null | null | null | src/wilddog_payload.h | YaoQ/wilddog-sdk-on-pcduino | e93ed39f8a2d9431c0c287e71962771dd61714ca | [
"MIT"
] | null | null | null |
#ifndef _WILDDOG_PAYLOAD_H_
#define _WILDDOG_PAYLOAD_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include "wilddog.h"
extern Wilddog_Payload_T * _wilddog_node2Payload
(
Wilddog_Node_T * p_node
);
extern Wilddog_Node_T *_wilddog_payload2Node
(
Wilddog_Payload_T* p_data
);
#ifdef __cplusplus
}
#endif
#endif /*_WILDDOG_PAYLOAD_H_*/
| 15.28 | 49 | 0.696335 |
f429e316c2c9da0a0d6891db1533b7e8b4d93aa1 | 19,844 | c | C | src/apps/wm/window.c | GrieferAtWork/KOS | 5376a813854b35e3a3532a6e3b8dbb168478b40f | [
"Zlib"
] | 2 | 2017-02-24T17:14:19.000Z | 2017-10-12T19:26:13.000Z | src/apps/wm/window.c | GrieferAtWork/KOS | 5376a813854b35e3a3532a6e3b8dbb168478b40f | [
"Zlib"
] | 1 | 2019-11-02T10:21:11.000Z | 2019-11-02T10:21:11.000Z | src/apps/wm/window.c | GabrielRavier/KOSmk3 | 5376a813854b35e3a3532a6e3b8dbb168478b40f | [
"Zlib"
] | 1 | 2019-11-02T10:20:19.000Z | 2019-11-02T10:20:19.000Z | /* Copyright (c) 2018 Griefer@Work *
* *
* 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 acknowledgement 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 GUARD_APPS_WM_WINDOW_C
#define GUARD_APPS_WM_WINDOW_C 1
#define _KOS_SOURCE 1
#define _EXCEPT_SOURCE 1
#include <hybrid/compiler.h>
#include <hybrid/list/list.h>
#include <hybrid/align.h>
#include <hybrid/minmax.h>
#include <kos/types.h>
#include <malloc.h>
#include <assert.h>
#include <string.h>
#include <stdbool.h>
#include <syslog.h>
#include "window.h"
DECL_BEGIN
PRIVATE void KCALL window_update_display_area(struct window *__restrict self);
/* Claim visibility within `window_rect' from other windows
* with a lower Z-order, as well as the background layer.
* This function is called to acquire visibility from other
* windows and the background when a window is moved. */
PRIVATE void KCALL
window_claim_visi(struct window *__restrict self,
struct rect window_rect,
bool render_immediatly);
/* Remove everything that was visible within `window_rect'
* and let that area be inherited by other windows with a
* lower Z-order.
* This function is called to release visibility to other
* windows and the background when a window is moved. */
PRIVATE void KCALL
window_remove_visi_and_inherit(struct window *__restrict self,
struct rect window_rect);
/* Copy window memory from `window_rect' directly onto the screen. */
PRIVATE void KCALL window_render_rect(struct window *__restrict self, struct rect window_rect);
PRIVATE void KCALL display_render_background(struct display *__restrict self, struct rect display_rect);
INTDEF unsigned int KCALL
window_getpixel(struct window *__restrict self,
unsigned int x, unsigned int y) {
unsigned int result;
byte_t *ptr;
assert(x < self->w_sizex);
assert(y < self->w_sizey);
ptr = self->w_screen;
ptr += y * self->w_stride; /* XXX: Use shifts here? */
x *= self->w_display->d_bpp;
ptr += x/8;
switch (self->w_display->d_bpp) {
case 32:
result = *(u32 *)ptr;
break;
case 16:
result = *(u16 *)ptr;
break;
case 8:
result = *(u8 *)ptr;
break;
case 4:
x %= 8;
assert(x == 0 || x == 4);
result = *(u8 *)ptr >> x;
result &= 0xf;
break;
case 2:
x %= 8;
assert(x == 0 || x == 2 || x == 4 || x == 6);
result = *(u8 *)ptr >> x;
result &= 0x3;
break;
case 1:
result = *(u8 *)ptr >> (x % 8);
result &= 0x1;
break;
default: assert(0);
}
return result;
}
INTERN void KCALL
window_putpixel(struct window *__restrict self,
unsigned int x, unsigned int y,
unsigned int pixel) {
byte_t *ptr;
assert(x < self->w_sizex);
assert(y < self->w_sizey);
ptr = self->w_screen;
ptr += y * self->w_stride; /* XXX: Use shifts here? */
x *= self->w_display->d_bpp;
ptr += x/8;
switch (self->w_display->d_bpp) {
case 32:
*(u32 *)ptr = (u32)pixel;
break;
case 16:
*(u16 *)ptr = (u16)pixel;
break;
case 8:
*(u8 *)ptr = (u8)pixel;
break;
case 4:
x %= 8;
assert(x == 0 || x == 4);
*(u8 *)ptr &= ~(0xf << x);
*(u8 *)ptr |= (pixel & 0xf) << x;
break;
case 2:
x %= 8;
assert(x == 0 || x == 2 || x == 4 || x == 6);
*(u8 *)ptr &= ~(0x3 << x);
*(u8 *)ptr |= (pixel & 0x3) << x;
break;
case 1:
*(u8 *)ptr &= ~(0x1 << x);
*(u8 *)ptr |= (pixel & 0x1) << x;
break;
default: assert(0);
}
}
PRIVATE void KCALL
window_update_display_area(struct window *__restrict self) {
struct rect area;
struct display *disp = self->w_display;
area.r_xmin = self->w_posx <= 0 ? 0 : self->w_posx;
area.r_ymin = self->w_posy <= 0 ? 0 : self->w_posy;
area.r_xsiz = self->w_sizex;
area.r_ysiz = self->w_sizey;
/* Clamp negative window coords. */
if (self->w_posx < 0) area.r_xsiz = area.r_xsiz > (unsigned int)-self->w_posx ? area.r_xsiz - -self->w_posx : 0;
if (self->w_posy < 0) area.r_ysiz = area.r_ysiz > (unsigned int)-self->w_posy ? area.r_ysiz - -self->w_posy : 0;
/* Clamp positive window coords. */
/**/ if (area.r_xmin >= disp->d_sizex) area.r_xsiz = 0;
else if (area.r_xmin+area.r_xsiz > disp->d_sizex) {
area.r_xsiz = disp->d_sizex-area.r_xmin;
}
/**/ if (area.r_ymin >= disp->d_sizey) area.r_ysiz = 0;
else if (area.r_ymin+area.r_ysiz > disp->d_sizey) {
area.r_ysiz = disp->d_sizey-area.r_ymin;
}
self->w_disparea = area;
}
/* Claim visibility within `display_rect' from other windows
* with a lower Z-order, as well as the background layer.
* This function is called to acquire visibility from other
* windows and the background when a window is moved. */
PRIVATE void KCALL
window_claim_visi(struct window *__restrict self,
struct rect display_rect,
bool render_immediatly) {
struct window *iter;
struct display *d = self->w_display;
struct rect r;
assert(display_rect.r_xsiz && display_rect.r_ysiz);
/* Steal from windows with a lower Z-order. */
for (iter = self->w_zlink.le_next;
iter != NULL;
iter = iter->w_zlink.le_next) {
again_window_visi:
RECTS_FOREACH(r,iter->w_visi) {
struct rect common;
r.r_xmin += iter->w_posx;
r.r_ymin += iter->w_posy;
common = rect_intersect(r,display_rect);
r.r_xmin -= iter->w_posx;
r.r_ymin -= iter->w_posy;
if (!common.r_xsiz || !common.r_ysiz) continue;
/* Steal this visibility rectangle. */
common.r_xmin -= iter->w_posx;
common.r_ymin -= iter->w_posy;
rects_remove(&iter->w_visi,common);
common.r_xmin += iter->w_posx;
common.r_ymin += iter->w_posy;
common.r_xmin -= self->w_posx;
common.r_ymin -= self->w_posy;
/* Add the visible portion to our own
* window and render the affected area. */
rects_insert(&self->w_visi,common);
if (render_immediatly)
window_render_rect(self,common);
goto again_window_visi;
}
}
again_background_visi:
/* Steal from the background layer. */
RECTS_FOREACH(r,d->d_backvisi) {
struct rect common_rect;
common_rect = rect_intersect(r,display_rect);
if (!common_rect.r_xsiz || !common_rect.r_ysiz) continue;
/* Steal this visibility rectangle. */
rects_remove(&d->d_backvisi,common_rect);
common_rect.r_xmin -= self->w_posx;
common_rect.r_ymin -= self->w_posy;
/* Add the visible portion to our own
* window and render the affected area. */
rects_insert(&self->w_visi,common_rect);
if (render_immediatly)
window_render_rect(self,common_rect);
goto again_background_visi;
}
}
/* Remove everything that was visible within `window_rect'
* and let that area be inherited by other windows with a
* lower Z-order.
* This function is called to release visibility to other
* windows and the background when a window is moved. */
PRIVATE void KCALL
window_remove_visi_and_inherit(struct window *__restrict self,
struct rect window_rect) {
struct rect r;
struct rects parts;
struct display *d = self->w_display;
assert(window_rect.r_xsiz && window_rect.r_ysiz);
parts.r_strips = NULL;
/* Extract the intersection of all visible rectangles and `window_rect' */
RECTS_FOREACH(r,self->w_visi) {
struct rect common;
common = rect_intersect(r,window_rect);
common.r_xmin += self->w_posx;
common.r_ymin += self->w_posy;
rects_insert(&parts,common);
}
/* Remove everything that wasn't inherited by child windows. */
rects_remove(&self->w_visi,window_rect);
/* Now let lower-order windows, or the background layer
* inherit everything that got removed from the visibility. */
again_parts:
RECTS_FOREACH(r,parts) {
struct window *iter;
for (iter = self->w_zlink.le_next;
iter != NULL;
iter = iter->w_zlink.le_next) {
struct rect common;
common = rect_intersect(r,iter->w_disparea);
if (!common.r_xsiz || !common.r_ysiz)
continue;
/* Inherit this part. */
common.r_xmin -= iter->w_posx;
common.r_ymin -= iter->w_posy;
rects_insert(&iter->w_visi,common);
/* Render the inherited part immediately. */
window_render_rect(iter,common);
/* Remove the common part from the set of rects that must be inherited. */
common.r_xmin += iter->w_posx;
common.r_ymin += iter->w_posy;
rects_remove(&parts,common);
goto again_parts;
}
}
/* Anything still left must be inherited by the background layer. */
RECTS_FOREACH(r,parts) {
rects_insert(&d->d_backvisi,r);
display_render_background(d,r);
}
rects_fini(&parts);
}
/* Construct a new window. */
INTERN struct window *KCALL
window_create(struct display *__restrict disp,
int posx, unsigned int sizex,
int posy, unsigned int sizey,
unsigned int flags) {
struct window *result;
result = (struct window *)Xmalloc(sizeof(struct window));
result->w_posx = posx;
result->w_posy = posy;
result->w_flags = flags;
result->w_sizey = sizey;
result->w_sizex = sizex;
result->w_stride = CEIL_ALIGN(sizex,16);
result->w_display = disp;
result->w_visi.r_strips = NULL;
window_update_display_area(result);
result->w_screen = (byte_t *)Xmalloc(sizey*
result->w_stride*
CEILDIV(disp->d_bpp,8));
/* Clamp the visible portion of the window to the display size. */
if (posx < 0) sizex = sizex > (unsigned int)-posx ? sizex - -posx : 0,posx = 0;
if (posy < 0) sizey = sizey > (unsigned int)-posy ? sizey - -posy : 0,posy = 0;
/**/ if ((unsigned int)posx > disp->d_sizex) sizex = 0;
else if ((unsigned int)posx+sizex > disp->d_sizex) sizex = disp->d_sizex-(unsigned int)posx;
/**/ if ((unsigned int)posy > disp->d_sizey) sizey = 0;
else if ((unsigned int)posy+sizey > disp->d_sizey) sizey = disp->d_sizey-(unsigned int)posy;
/* Insert the new window in front of all others. */
LIST_INSERT(disp->d_zorder,result,w_zlink);
/* Construct the initial visibility setup of the window. */
if (sizex && sizey && !(flags & WINDOW_FHIDDEN)) {
/* Add the window to the visible part of the display render list. */
LIST_INSERT(disp->d_windows,result,w_vlink);
window_claim_visi(result,result->w_disparea,false);
}
return result;
}
/* Copy window memory from `window_rect' directly onto the screen. */
PRIVATE void KCALL
window_render_rect(struct window *__restrict self,
struct rect window_rect) {
struct display *d = self->w_display;
copy_rect(d->d_screen,
window_rect.r_xmin+self->w_posx,
window_rect.r_ymin+self->w_posy,
d->d_stride,
self->w_screen,
window_rect.r_xmin,
window_rect.r_ymin,
self->w_stride,
window_rect.r_xsiz,
window_rect.r_ysiz,
d->d_bpp);
}
PRIVATE void KCALL
display_render_background(struct display *__restrict self,
struct rect display_rect) {
copy_rect(self->d_screen,
display_rect.r_xmin,
display_rect.r_ymin,
self->d_stride,
self->d_backgrnd,
display_rect.r_xmin,
display_rect.r_ymin,
self->d_stride,
display_rect.r_xsiz,
display_rect.r_ysiz,
self->d_bpp);
}
INTERN void KCALL
window_draw_rects(struct window *__restrict self,
size_t count, struct rect *__restrict vec) {
struct rect visi;
RECTS_FOREACH(visi,self->w_visi) {
size_t i;
for (i = 0; i < count; ++i) {
struct rect common = rect_intersect(visi,vec[i]);
if (common.r_xsiz && common.r_ysiz)
window_render_rect(self,common);
}
}
}
INTERN void KCALL
window_draw_rect(struct window *__restrict self, struct rect r) {
struct rect visi;
RECTS_FOREACH(visi,self->w_visi) {
struct rect common = rect_intersect(visi,r);
if (common.r_xsiz && common.r_ysiz)
window_render_rect(self,common);
}
}
/* Destroy the given window. */
INTERN void KCALL
window_destroy(struct window *__restrict self) {
/* Hide the window prior to its destruction to ensure
* that it doesn't leave behind any artifacts. */
window_hide(self);
/* TODO */
free(self);
}
/* Move around the given window. */
INTERN void KCALL
window_move(struct window *__restrict self,
int new_posx, int new_posy) {
int old_posx = self->w_posx;
int old_posy = self->w_posy;
int rel_movx = new_posx - old_posx;
int rel_movy = new_posy - old_posy;
struct rect r,old_display_area;
struct rects reclaim_area;
if (!rel_movx && !rel_movy) return;
old_display_area = self->w_disparea;
if (self->w_flags & WINDOW_FHIDDEN) {
self->w_posx = new_posx;
self->w_posy = new_posy;
return;
}
/* Adjust the set of visible window
* rects to apply to the new location. */
if (rel_movx != 0) {
self->w_posx = new_posx;
window_update_display_area(self);
rects_move(&self->w_visi,-rel_movx,0);
if (rel_movx < 0) {
r.r_xmin = self->w_sizex - -rel_movx;
r.r_xsiz = -rel_movx;
} else {
r.r_xmin = 0;
r.r_xsiz = rel_movx;
}
r.r_ymin = 0;
r.r_ysiz = self->w_sizey;
/* Release visibility following a horizontal move */
window_remove_visi_and_inherit(self,r);
}
if (rel_movy != 0) {
self->w_posy = new_posy;
window_update_display_area(self);
rects_move(&self->w_visi,0,-rel_movy);
if (rel_movy < 0) {
r.r_ymin = self->w_sizey - -rel_movy;
r.r_ysiz = -rel_movy;
} else {
r.r_ymin = 0;
r.r_ysiz = rel_movy;
}
r.r_xmin = 0;
r.r_xsiz = self->w_sizex;
/* Release visibility following a vertical move */
window_remove_visi_and_inherit(self,r);
}
/* Claim visibility for everything apart of the new
* display area, that isn't part of the old display
* area. */
reclaim_area.r_strips = NULL;
rects_insert(&reclaim_area,self->w_disparea);
rects_remove(&reclaim_area,old_display_area);
RECTS_FOREACH(r,reclaim_area) {
window_claim_visi(self,r,true);
}
rects_fini(&reclaim_area);
}
/* Set active window flags. */
INTERN void KCALL
window_hide(struct window *__restrict self) {
struct window *lower;
struct display *d;
struct rect r;
if (self->w_flags & WINDOW_FHIDDEN) return;
LIST_REMOVE(self,w_vlink);
d = self->w_display;
/* Adjust the windows visibility set to become display-relative. */
rects_move(&self->w_visi,-self->w_posx,-self->w_posy);
/* Let windows with a lower Z order inherit visibility. */
for (lower = self->w_zlink.le_next;
lower != NULL;
lower = lower->w_zlink.le_next) {
restart_foreach:
RECTS_FOREACH(r,self->w_visi) {
struct rect common_area;
common_area = rect_intersect(r,lower->w_disparea);
if (!common_area.r_xsiz || !common_area.r_ysiz)
continue;
/* Any single rect can only be inherited once. */
rects_remove(&self->w_visi,common_area);
/* Move visible parts of this window to windows with a lower z-order. */
common_area.r_xmin -= lower->w_posx;
common_area.r_ymin -= lower->w_posy;
rects_insert(&lower->w_visi,common_area);
/* Copy window data of the underlying window onto the display. */
window_render_rect(lower,common_area);
goto restart_foreach;
}
}
/* Anything that's still left in the set of remaining rects
* cannot be inherited by another window, meaning it needs to
* be inherited by the background plane. */
RECTS_FOREACH(r,self->w_visi) {
rects_insert(&d->d_backvisi,r);
/* Render the background for the affected area. */
display_render_background(d,r);
}
/* Free what's left of our rects-copy buffer. */
rects_fini(&self->w_visi);
self->w_visi.r_strips = NULL;
/* Finally, set the hidden flag. */
self->w_flags |= WINDOW_FHIDDEN;
}
INTERN void KCALL
window_show(struct window *__restrict self) {
struct rect r;
if (!(self->w_flags & WINDOW_FHIDDEN)) return;
r.r_xmin = 0;
r.r_ymin = 0;
r.r_xsiz = self->w_sizex;
r.r_ysiz = self->w_sizey;
window_claim_visi(self,r,true);
LIST_INSERT(self->w_display->d_windows,self,w_vlink);
self->w_flags &= ~WINDOW_FHIDDEN;
}
/* Copy visible window portions also covered by `vec' onto the display buffer. */
INTERN void KCALL
window_draw(struct window *__restrict self,
size_t count, struct rect *__restrict vec) {
/* TODO */
}
/* Do a full redraw of all visible windows. */
INTERN void KCALL
display_redraw(struct display *__restrict self) {
struct rect r;
struct window *win;
#if 1
/* Copy the background first. */
RECTS_FOREACH(r,self->d_backvisi) {
copy_rect(self->d_screen,
r.r_xmin,
r.r_ymin,
self->d_stride,
self->d_backgrnd,
r.r_xmin,
r.r_ymin,
self->d_stride,
r.r_xsiz,
r.r_ysiz,
self->d_bpp);
}
#endif
/* Then copy all visible window portions. */
for (win = self->d_windows;
win != NULL; win = win->w_vlink.le_next) {
RECTS_FOREACH(r,win->w_visi) {
copy_rect(self->d_screen,
win->w_posx+r.r_xmin,
win->w_posy+r.r_ymin,
self->d_stride,
win->w_screen,
r.r_xmin,
r.r_ymin,
win->w_stride,
r.r_xsiz,
r.r_ysiz,
self->d_bpp);
}
}
}
#undef CONFIG_COPYRECT_DO_OUTLINE
#if 1
#define CONFIG_COPYRECT_DO_OUTLINE 4
#endif
INTERN void KCALL
copy_rect(byte_t *__restrict dst_buffer,
unsigned int dst_x, unsigned int dst_y, unsigned int dst_stride,
byte_t const *__restrict src_buffer,
unsigned int src_x, unsigned int src_y, unsigned int src_stride,
unsigned int size_x, unsigned int size_y,
unsigned int bpp) {
assert(size_x || size_y);
#if 1
syslog(LOG_DEBUG,"copyrect(%u,%u*%u <-- %u,%u*%u w=%u,h=%u)\n",
dst_x,dst_y,dst_stride,src_x,src_y,src_stride,size_x,size_y);
#endif
dst_buffer += dst_y*dst_stride;
src_buffer += src_y*src_stride;
if (bpp == 8) {
do_bytewise_copy:
assert(dst_x+size_x <= dst_stride);
assert(src_x+size_x <= src_stride);
dst_buffer += dst_x;
src_buffer += src_x;
/* Copy line-wise */
#ifdef CONFIG_COPYRECT_DO_OUTLINE
--size_y;
memset(dst_buffer,CONFIG_COPYRECT_DO_OUTLINE,size_x);
src_buffer += src_stride;
dst_buffer += dst_stride;
#endif
for (; size_y; --size_y) {
memcpy(dst_buffer,
src_buffer,
size_x);
#ifdef CONFIG_COPYRECT_DO_OUTLINE
dst_buffer[0] = CONFIG_COPYRECT_DO_OUTLINE;
dst_buffer[size_x-1] = CONFIG_COPYRECT_DO_OUTLINE;
#endif
dst_buffer += dst_stride;
src_buffer += src_stride;
}
#ifdef CONFIG_COPYRECT_DO_OUTLINE
memset(dst_buffer-dst_stride,
CONFIG_COPYRECT_DO_OUTLINE,size_x);
#endif
} else if (!(bpp & 7)) {
dst_x *= bpp/8;
src_x *= bpp/8;
size_x *= bpp/8;
goto do_bytewise_copy;
} else {
assertf(0,"TODO");
}
}
DECL_END
#endif /* !GUARD_APPS_WM_WINDOW_C */
| 30.861586 | 113 | 0.653044 |
730c6d76f707441daaaa7c9b6129355378888578 | 2,094 | c | C | autoinit_kittyCompact_main.c | khval/kittycompact.library | 4ea732ad1f878a9c3e13227462c088e9d0ac7c2d | [
"MIT"
] | 1 | 2020-05-17T18:24:06.000Z | 2020-05-17T18:24:06.000Z | autoinit_kittyCompact_main.c | khval/kittycompact.library | 4ea732ad1f878a9c3e13227462c088e9d0ac7c2d | [
"MIT"
] | null | null | null | autoinit_kittyCompact_main.c | khval/kittycompact.library | 4ea732ad1f878a9c3e13227462c088e9d0ac7c2d | [
"MIT"
] | null | null | null | /*
** $Id$
** Generated by IDLTool 53.6
** Do not edit
**
** AutoInit stub for kittyCompact
**
** Copyright (c) 2010 Hyperion Entertainment CVBA.
** All Rights Reserved.
*/
#include <exec/types.h>
#include <libraries/kittyCompact.h>
#include <interfaces/kittyCompact.h>
#include <proto/exec.h>
#include <assert.h>
struct kittyCompactIFace * IkittyCompact = NULL;
static struct Library * __kittyCompactBase;
static struct kittyCompactIFace * __IkittyCompact;
/****************************************************************************/
extern struct Library * kittyCompactBase;
/****************************************************************************/
void kittyCompact_main_constructor(void)
{
if (kittyCompactBase == NULL) /* Library base is NULL, we need to open it */
{
/* We were called before the base constructor.
* This means we will be called _after_ the base destructor.
* So we cant drop the interface _after_ closing the last library base,
* we just open the library here which ensures that.
*/
__kittyCompactBase = kittyCompactBase = (struct Library *)IExec->OpenLibrary("kittycompact.library", 0L);
assert(kittyCompactBase != NULL);
}
__IkittyCompact = IkittyCompact = (struct kittyCompactIFace *)IExec->GetInterface((struct Library *)kittyCompactBase, "main", 1, NULL);
assert(IkittyCompact != NULL);
}
__attribute__((section(".ctors.zzzy"))) static void
(*kittyCompact_main_constructor_ptr)(void) USED = kittyCompact_main_constructor;
/****************************************************************************/
void kittyCompact_main_destructor(void)
{
if (__IkittyCompact)
{
IExec->DropInterface ((struct Interface *)__IkittyCompact);
}
if (__kittyCompactBase)
{
IExec->CloseLibrary((struct Library *)__kittyCompactBase);
}
}
__attribute__((section(".dtors.zzzy"))) static void
(*kittyCompact_main_destructor_ptr)(void) USED = kittyCompact_main_destructor;
/****************************************************************************/
| 31.727273 | 139 | 0.606972 |
1ec87fc4e867a38b7fdfa7b843ee9f5d9118f36b | 2,252 | h | C | TAO/tests/CSD_Strategy_Tests/TP_Foo_B/CSD_TP_Foo_B_Export.h | cflowe/ACE | 5ff60b41adbe1772372d1a43bcc1f2726ff8f810 | [
"DOC"
] | 36 | 2015-01-10T07:27:33.000Z | 2022-03-07T03:32:08.000Z | TAO/tests/CSD_Strategy_Tests/TP_Foo_B/CSD_TP_Foo_B_Export.h | cflowe/ACE | 5ff60b41adbe1772372d1a43bcc1f2726ff8f810 | [
"DOC"
] | 2 | 2018-08-13T07:30:51.000Z | 2019-02-25T03:04:31.000Z | TAO/tests/CSD_Strategy_Tests/TP_Foo_B/CSD_TP_Foo_B_Export.h | cflowe/ACE | 5ff60b41adbe1772372d1a43bcc1f2726ff8f810 | [
"DOC"
] | 38 | 2015-01-08T14:12:06.000Z | 2022-01-19T08:33:00.000Z |
// -*- C++ -*-
// $Id: CSD_TP_Foo_B_Export.h 68816 2005-10-19 00:27:51Z dai_y $
// Definition for Win32 Export directives.
// This file is generated automatically by generate_export_file.pl -s CSD_TP_Foo_B
// ------------------------------
#ifndef CSD_TP_FOO_B_EXPORT_H
#define CSD_TP_FOO_B_EXPORT_H
#include "ace/config-all.h"
#if defined (ACE_AS_STATIC_LIBS) && !defined (CSD_TP_FOO_B_HAS_DLL)
# define CSD_TP_FOO_B_HAS_DLL 0
#endif /* ACE_AS_STATIC_LIBS && CSD_TP_FOO_B_HAS_DLL */
#if !defined (CSD_TP_FOO_B_HAS_DLL)
# define CSD_TP_FOO_B_HAS_DLL 1
#endif /* ! CSD_TP_FOO_B_HAS_DLL */
#if defined (CSD_TP_FOO_B_HAS_DLL) && (CSD_TP_FOO_B_HAS_DLL == 1)
# if defined (CSD_TP_FOO_B_BUILD_DLL)
# define CSD_TP_Foo_B_Export ACE_Proper_Export_Flag
# define CSD_TP_FOO_B_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T)
# define CSD_TP_FOO_B_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
# else /* CSD_TP_FOO_B_BUILD_DLL */
# define CSD_TP_Foo_B_Export ACE_Proper_Import_Flag
# define CSD_TP_FOO_B_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T)
# define CSD_TP_FOO_B_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
# endif /* CSD_TP_FOO_B_BUILD_DLL */
#else /* CSD_TP_FOO_B_HAS_DLL == 1 */
# define CSD_TP_Foo_B_Export
# define CSD_TP_FOO_B_SINGLETON_DECLARATION(T)
# define CSD_TP_FOO_B_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
#endif /* CSD_TP_FOO_B_HAS_DLL == 1 */
// Set CSD_TP_FOO_B_NTRACE = 0 to turn on library specific tracing even if
// tracing is turned off for ACE.
#if !defined (CSD_TP_FOO_B_NTRACE)
# if (ACE_NTRACE == 1)
# define CSD_TP_FOO_B_NTRACE 1
# else /* (ACE_NTRACE == 1) */
# define CSD_TP_FOO_B_NTRACE 0
# endif /* (ACE_NTRACE == 1) */
#endif /* !CSD_TP_FOO_B_NTRACE */
#if (CSD_TP_FOO_B_NTRACE == 1)
# define CSD_TP_FOO_B_TRACE(X)
#else /* (CSD_TP_FOO_B_NTRACE == 1) */
# if !defined (ACE_HAS_TRACE)
# define ACE_HAS_TRACE
# endif /* ACE_HAS_TRACE */
# define CSD_TP_FOO_B_TRACE(X) ACE_TRACE_IMPL(X)
# include "ace/Trace.h"
#endif /* (CSD_TP_FOO_B_NTRACE == 1) */
#endif /* CSD_TP_FOO_B_EXPORT_H */
// End of auto generated file.
| 38.169492 | 129 | 0.751332 |
485b4ef9653c08fc1bbe12d95f55fb6c5eafdc72 | 1,180 | h | C | include/al/rail/RailPart.h | 3096/starlight | 7056a81cbf9756b68392be0cadfab5c27570de54 | [
"MIT"
] | 385 | 2019-05-09T21:46:48.000Z | 2022-02-18T18:19:40.000Z | include/al/rail/RailPart.h | 3096/starlight | 7056a81cbf9756b68392be0cadfab5c27570de54 | [
"MIT"
] | 11 | 2019-05-20T01:17:38.000Z | 2022-01-19T18:03:18.000Z | include/al/rail/RailPart.h | 3096/starlight | 7056a81cbf9756b68392be0cadfab5c27570de54 | [
"MIT"
] | 36 | 2019-05-09T22:29:29.000Z | 2021-12-27T18:20:32.000Z | /**
* @file RailPart.h
* @brief A node contained in a rail, which can include curves.
*/
#pragma once
#include "curve/BezierCurve.h"
#include "curve/LinearCurve.h"
#include "types.h"
namespace al
{
class RailPart
{
public:
RailPart();
void init(sead::Vector3<f32> const &, sead::Vector3<f32> const &, sead::Vector3<f32> const &, sead::Vector3<f32> const &);
void calcPos(sead::Vector3<f32> *, f32) const;
void calcVelocity(sead::Vector3<f32> *, f32) const;
void calcDir(sead::Vector3<f32> *, f32) const;
void calcStartPos(sead::Vector3<f32> *) const;
void calcEndPos(sead::Vector3<f32> *) const;
f32 calcLength(f32, f32, s32) const;
f32 calcCurveParam(f32) const;
f32 calcNearestParam(sead::Vector3<f32> const &, f32) const;
void calcNearestPos(sead::Vector3<f32> *, sead::Vector3<f32> const &, f32) const;
void calcNearestLength(f32 *outLength, sead::Vector3<f32> const &, f32, f32) const;
f32 getPartLength() const;
al::BezierCurve* mBezierCurve; // _0
al::LinearCurve* mLinearCurve; // _8
u32 _10;
u32 reserved;
};
}; | 31.891892 | 130 | 0.624576 |
90bb2d45ff4156f89e7619d7c3c752131da1f75c | 490 | h | C | Staff/StaffViewController+PrivateExtension.h | KKLater/Staff | 38a396ff4d9685b769b9687d04b22d71916b636c | [
"MIT"
] | 12 | 2019-01-07T08:53:11.000Z | 2019-06-05T03:27:11.000Z | Staff/StaffViewController+PrivateExtension.h | KKLater/Staff | 38a396ff4d9685b769b9687d04b22d71916b636c | [
"MIT"
] | 3 | 2019-01-08T02:56:32.000Z | 2019-06-27T05:04:35.000Z | Staff/StaffViewController+PrivateExtension.h | KKLater/Staff | 38a396ff4d9685b769b9687d04b22d71916b636c | [
"MIT"
] | 2 | 2019-02-15T04:33:56.000Z | 2021-01-22T03:57:17.000Z | //
// StaffViewController+PrivateExtension.h
// Staff
//
// Created by 罗树新 on 2018/12/24.
// Copyright © 2018 罗树新. All rights reserved.
//
#import "StaffViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface StaffViewController ()
- (void)showStaffItemViewOnView:(UIView *)view;
- (void)swapMain;
- (void)cleanStaffItemViews;
- (void)showStaffItemViewOnView:(UIView *)view isMain:(BOOL)isMain;
@property (nonatomic, assign) NSInteger staffItemViewsCount;
@end
NS_ASSUME_NONNULL_END
| 20.416667 | 67 | 0.761224 |
a4001db3cb8bfd0c878aaf0ba4b570d4a4f468d5 | 635 | h | C | File.h | TiBxq/otus_cpp_h5 | 712b4059ec0cce67ef97c448510a18c85c78d052 | [
"MIT"
] | null | null | null | File.h | TiBxq/otus_cpp_h5 | 712b4059ec0cce67ef97c448510a18c85c78d052 | [
"MIT"
] | null | null | null | File.h | TiBxq/otus_cpp_h5 | 712b4059ec0cce67ef97c448510a18c85c78d052 | [
"MIT"
] | null | null | null | #pragma once
#include <string>
class Shape;
enum class FileType
{
SVG, EPS
};
class File
{
public:
virtual ~File() = default;
virtual void Save(Shape* shape) = 0;
virtual void Load(Shape* shape) = 0;
virtual void Open(const std::string&) {}
virtual void SaveTo(const std::string&) {}
};
class FileSVG : public File
{
public:
FileSVG() = default;
virtual void Save(Shape* shape) override;
virtual void Load(Shape* shape) override;
};
class FileEPS : public File
{
public:
FileEPS() = default;
virtual void Save(Shape* shape) override;
virtual void Load(Shape* shape) override;
}; | 16.282051 | 46 | 0.656693 |
05e829f37f49314715277a0178a2455963cc3296 | 402 | h | C | daikiri/support/GSEnemyHero.h | BadChoice/daikiri | 8a844c901c58de247909551390a08f5b0c145973 | [
"MIT"
] | 5 | 2016-07-04T21:14:47.000Z | 2020-04-23T08:26:40.000Z | daikiri/support/GSEnemyHero.h | BadChoice/daikiri | 8a844c901c58de247909551390a08f5b0c145973 | [
"MIT"
] | 1 | 2018-11-23T20:07:05.000Z | 2018-11-24T16:04:33.000Z | daikiri/support/GSEnemyHero.h | BadChoice/daikiri | 8a844c901c58de247909551390a08f5b0c145973 | [
"MIT"
] | 5 | 2016-07-04T21:14:47.000Z | 2020-04-23T11:30:21.000Z | //
// GSEnemyHero.h
// daikiri
//
// Created by Badchoice on 20/4/16.
// Copyright © 2016 revo. All rights reserved.
//
#import "Daikiri.h"
#import "GSHero.h"
#import "GSEnemy.h"
@interface GSEnemyHero : Daikiri
@property (strong,nonatomic) NSNumber* hero_id;
@property (strong,nonatomic) NSNumber* enemy_id;
@property (strong,nonatomic) NSNumber* level;
-(GSEnemy*)enemy;
-(GSHero*)hero;
@end
| 18.272727 | 48 | 0.706468 |
660a6c5f9f99d2a94a2bd645c3d2a825a335b6bd | 5,267 | c | C | proxy/src/tools/pgmd5/pool_passwd.c | hzy9819/GreenPlum_WooKongDB | 9dca9b3bcd15f29b2a0136acc818064222220059 | [
"PostgreSQL",
"Apache-2.0"
] | 33 | 2021-06-02T03:20:48.000Z | 2021-12-31T07:27:55.000Z | proxy/src/tools/pgmd5/pool_passwd.c | hzy9819/GreenPlum_WooKongDB | 9dca9b3bcd15f29b2a0136acc818064222220059 | [
"PostgreSQL",
"Apache-2.0"
] | null | null | null | proxy/src/tools/pgmd5/pool_passwd.c | hzy9819/GreenPlum_WooKongDB | 9dca9b3bcd15f29b2a0136acc818064222220059 | [
"PostgreSQL",
"Apache-2.0"
] | null | null | null | /* -*-pgsql-c-*- */
/*
*
* $Header$
*
* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
*
* Copyright (c) 2003-2015 PgPool Global Development Group
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby
* granted, provided that the above copyright notice appear in all
* copies and that both that copyright notice and this permission
* notice appear in supporting documentation, and that the name of the
* author not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior
* permission. The author makes no representations about the
* suitability of this software for any purpose. It is provided "as
* is" without express or implied warranty.
*
* Module to handle pool_passwd
*/
#include <string.h>
#include <errno.h>
#include "pool.h"
#include "auth/pool_passwd.h"
#include "auth/md5.h"
#ifndef POOL_PRIVATE
#include "utils/elog.h"
#else
#include "utils/fe_ports.h"
#endif
static FILE *passwd_fd = NULL; /* File descriptor for pool_passwd */
static char saved_passwd_filename[POOLMAXPATHLEN+1];
static POOL_PASSWD_MODE pool_passwd_mode;
/*
* Initialize this module.
* If pool_passwd does not exist yet, create it.
* Open pool_passwd.
*/
void pool_init_pool_passwd(char *pool_passwd_filename, POOL_PASSWD_MODE mode)
{
char *openmode;
if (passwd_fd)
return;
pool_passwd_mode = mode;
if (saved_passwd_filename[0] == '\0')
{
int len = strlen(pool_passwd_filename);
memcpy(saved_passwd_filename, pool_passwd_filename, len);
saved_passwd_filename[len] = '\0';
}
if (mode == POOL_PASSWD_R)
openmode = "r";
else
openmode = "r+";
passwd_fd = fopen(pool_passwd_filename, openmode);
if (!passwd_fd)
{
if (errno == ENOENT)
{
/* The file does not exist yet. Create it. */
passwd_fd = fopen(pool_passwd_filename, "w+");
if (passwd_fd)
return;
}
ereport(ERROR,
(errmsg("initializing pool password, failed to open file:\"%s\"",pool_passwd_filename),
errdetail("file open failed with error:\"%s\"",strerror(errno))));
}
}
/*
* Update passwd. If the user does not exist, create a new entry.
* Returns 0 on success non 0 otherwise.
*/
int pool_create_passwdent(char *username, char *passwd)
{
int len;
int c;
char name[MAX_USER_NAME_LEN];
char *p;
int readlen;
if (!passwd_fd)
ereport(ERROR,
(errmsg("error updating password, password file descriptor is NULL")));
if (pool_passwd_mode != POOL_PASSWD_RW)
ereport(ERROR,
(errmsg("pool_create_passwdent should be called with pool_passwd opened with read/write mode")));
len = strlen(passwd);
if (len != POOL_PASSWD_LEN)
ereport(ERROR,
(errmsg("error updating password, invalid password length:%d",len)));
rewind(passwd_fd);
name[0] = '\0';
while (!feof(passwd_fd))
{
p = name;
readlen = 0;
while (readlen < sizeof(name))
{
c = fgetc(passwd_fd);
if (c == EOF)
break;
else if (c == ':')
break;
readlen++;
*p++ = c;
}
*p = '\0';
if (!strcmp(username, name))
{
/* User name found. Update password. */
while ((c = *passwd++))
{
fputc(c, passwd_fd);
}
fputc('\n', passwd_fd);
return 0;
}
else
{
/* Skip password */
while((c = fgetc(passwd_fd)) != EOF &&
c != '\n')
;
}
}
fseek(passwd_fd, 0, SEEK_END);
/*
* Not found the user name.
* Create a new entry.
*/
while ((c = *username++))
{
fputc(c, passwd_fd);
}
fputc(':', passwd_fd);
while ((c = *passwd++))
{
fputc(c, passwd_fd);
}
fputc('\n', passwd_fd);
return 0;
}
/*
* Get password in pool_passwd by username. Returns NULL if specified
* entry does not exist or error occurred.
* Returned password is on the static memory.
*/
char *pool_get_passwd(char *username)
{
int c;
char name[MAX_USER_NAME_LEN+1];
static char passwd[POOL_PASSWD_LEN+1];
char *p;
int readlen;
if (!username)
ereport(ERROR,
(errmsg("unable to get password, username is NULL")));
if (!passwd_fd)
ereport(ERROR,
(errmsg("unable to get password, password file descriptor is NULL")));
rewind(passwd_fd);
name[0] = '\0';
while (!feof(passwd_fd))
{
p = name;
readlen = 0;
while (readlen < (sizeof(name)-1))
{
c = fgetc(passwd_fd);
if (c == EOF)
break;
else if (c == ':')
break;
readlen++;
*p++ = c;
}
*p = '\0';
if (!strcmp(username, name))
{
/* User name found. Return password. */
p = passwd;
readlen = 0;
while((c = fgetc(passwd_fd)) != EOF &&
c != '\n' && readlen < (sizeof(passwd)-1))
{
*p++ = c;
readlen++;
}
*p = '\0';
return passwd;
}
else
{
/* Skip password */
while((c = fgetc(passwd_fd)) != EOF &&
c != '\n')
;
}
}
return NULL;
}
/*
* Delete the entry by username. If specified entry does not exist,
* does nothing.
*/
void pool_delete_passwdent(char *username)
{
}
/*
* Finish this moil. Close pool_passwd.
*/
void pool_finish_pool_passwd(void)
{
if (passwd_fd)
{
fclose(passwd_fd);
passwd_fd = NULL;
}
}
void pool_reopen_passwd_file(void)
{
pool_finish_pool_passwd();
pool_init_pool_passwd(saved_passwd_filename, pool_passwd_mode);
}
| 20.180077 | 101 | 0.653883 |
61cf8ce6eeb69aea283865f2cf6a5a0ea003ac8c | 243 | h | C | DDFavourites/DDFavourites/Classes/DDFavourites.h | syedqamara/Dastak | e4016e0d43cfd782f99708339331c8ed37eaaf5e | [
"MIT"
] | null | null | null | DDFavourites/DDFavourites/Classes/DDFavourites.h | syedqamara/Dastak | e4016e0d43cfd782f99708339331c8ed37eaaf5e | [
"MIT"
] | null | null | null | DDFavourites/DDFavourites/Classes/DDFavourites.h | syedqamara/Dastak | e4016e0d43cfd782f99708339331c8ed37eaaf5e | [
"MIT"
] | null | null | null | //
// DDFavourites.h
// DDFavourites
//
// Created by Zubair Ahmad on 24/02/2020.
// Copyright © 2020 zubair-ets. All rights reserved.
//
#import "DDFavouritesConstants.h"
#import "DDFavouritesManager.h"
#import "DDFavouritesApiManager.h"
| 22.090909 | 53 | 0.728395 |
795e234a232b9c4c64d1fd7839a66fce344ba3cb | 743 | c | C | lib/wizards/shadow/shadow.c | vlehtola/questmud | 8bc3099b5ad00a9e0261faeb6637c76b521b6dbe | [
"MIT"
] | null | null | null | lib/wizards/shadow/shadow.c | vlehtola/questmud | 8bc3099b5ad00a9e0261faeb6637c76b521b6dbe | [
"MIT"
] | null | null | null | lib/wizards/shadow/shadow.c | vlehtola/questmud | 8bc3099b5ad00a9e0261faeb6637c76b521b6dbe | [
"MIT"
] | null | null | null | #include "room.h"
#undef EXTRA_RESET
#define EXTRA_RESET no_castle_flag=1;
FOUR_EXIT("players/shadow/guard_ro", "down",
"players/shadow/eat_room", "north",
"players/shadow/shadow1", "east",
"players/shadow/workroom", "west",
"Shadows castle",
"YOu are in Shadow castle. To your north you see Shadows kitchen\n"+
"where shadows cooks. To your east you see a massive hall\n"+
"probably done for ceremonies. And to your west you see a door.\n"+
"There is a sign on the door:\n"+
" * * * * SHADOW'S OFFICE, PERSONEL ONLY * * * *\n"+
"In front of you is stairs leading down to the guard post. \n"+
"There is a big mirror that seems to be filled with water.\n"+
"In it you see the shape of the town church.\n",
1)
| 37.15 | 68 | 0.679677 |
e85a0c392eaa784e2ec59fea1413213326ddba5a | 2,543 | h | C | Applications/MobilePhone/PHUIConfiguration.h | lechium/iPhoneOS_12.1.1_Headers | aac688b174273dfcbade13bab104461f463db772 | [
"MIT"
] | 12 | 2019-06-02T02:42:41.000Z | 2021-04-13T07:22:20.000Z | Applications/MobilePhone/PHUIConfiguration.h | lechium/iPhoneOS_12.1.1_Headers | aac688b174273dfcbade13bab104461f463db772 | [
"MIT"
] | null | null | null | Applications/MobilePhone/PHUIConfiguration.h | lechium/iPhoneOS_12.1.1_Headers | aac688b174273dfcbade13bab104461f463db772 | [
"MIT"
] | 3 | 2019-06-11T02:46:10.000Z | 2019-12-21T14:58:16.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "NSObject.h"
@interface PHUIConfiguration : NSObject
{
}
+ (_Bool)preferShorterStrings; // IMP=0x000000010004d210
+ (unsigned long long)voicemailLayoutSpacing; // IMP=0x000000010004d148
+ (unsigned long long)tableViewCellVerticalSpacing; // IMP=0x000000010004d090
+ (unsigned long long)inCallFaceTimeOverlayUISize; // IMP=0x000000010004cfc4
+ (_Bool)shouldUseFullScreenPeoplePicker; // IMP=0x000000010004cf80
+ (unsigned long long)pipStatusBarPadding; // IMP=0x000000010004ceb8
+ (double)pipRadius; // IMP=0x000000010004ce04
+ (double)pipPartialHomeOffset; // IMP=0x000000010004cd50
+ (double)pipWallInset; // IMP=0x000000010004cc8c
+ (double)pipWidth; // IMP=0x000000010004cbc8
+ (double)bottomOffsetForFaceTimeUIInLandscapeMode; // IMP=0x000000010004cb14
+ (double)topOffsetForFaceTimeUIInLandscapeMode; // IMP=0x000000010004ca5c
+ (unsigned long long)contentViewSizeForFaceTime; // IMP=0x000000010004c9a4
+ (_Bool)canRotateInCallUIOverlayForFaceTime; // IMP=0x000000010004c99c
+ (_Bool)canAutoRotateInCallUIForFaceTimeAudio; // IMP=0x000000010004c8f4
+ (_Bool)canAutoRotateInCallUIForFaceTime; // IMP=0x000000010004c84c
+ (double)yParticipantsViewAdjustmentForKeypad; // IMP=0x000000010004c7d4
+ (double)yOffsetForParticipantsView; // IMP=0x000000010004c704
+ (double)yOffsetForDialerLCDView; // IMP=0x000000010004c678
+ (unsigned long long)handsetDialerSize; // IMP=0x000000010000d398
+ (unsigned long long)handsetDialerSpacing; // IMP=0x000000010000d2e0
+ (unsigned long long)inCallBottomBarAssetSize; // IMP=0x000000010004c5ac
+ (unsigned long long)inCallSlideToAnswerSize; // IMP=0x000000010004c4f0
+ (unsigned long long)inCallControlSize; // IMP=0x000000010004c430
+ (unsigned long long)inCallBottomBarMaxTitleSize; // IMP=0x000000010004c378
+ (unsigned long long)inCallBottomBarLowerOffset; // IMP=0x000000010004c2b8
+ (unsigned long long)inCallBottomBarSpacing; // IMP=0x000000010004c1f8
+ (unsigned long long)inCallControlSpacing; // IMP=0x000000010004c138
+ (unsigned long long)inCallControlAlignment; // IMP=0x000000010004c074
+ (unsigned long long)screenSize; // IMP=0x000000010000bf50
+ (id)dialerColor; // IMP=0x000000010000bdb0
+ (double)dialerLCDLabelFontSizeInCall; // IMP=0x000000010001111c
+ (double)dialerLCDLabelFontSize; // IMP=0x000000010000ca84
+ (double)dialerLCDFontSizeInCall; // IMP=0x0000000100011050
+ (double)dialerLCDFontSize; // IMP=0x000000010000bec4
@end
| 49.862745 | 83 | 0.806134 |
9f7e0bc9864429b8153184a1baf0546a7ad45cde | 242 | h | C | src/tai8590.h | jh4xsy/oww | b95412060666e05e62a58ef96e7124c13394d761 | [
"Artistic-1.0"
] | 1 | 2020-09-29T20:48:07.000Z | 2020-09-29T20:48:07.000Z | src/tai8590.h | jh4xsy/oww | b95412060666e05e62a58ef96e7124c13394d761 | [
"Artistic-1.0"
] | null | null | null | src/tai8590.h | jh4xsy/oww | b95412060666e05e62a58ef96e7124c13394d761 | [
"Artistic-1.0"
] | null | null | null | #ifndef TAI8590_H
#define TAI8590_H 1
void tai8590_New(devices_struct *devp) ;
void *tai8590_message(wsstruct *wd, int *len) ;
int tai8590_SendMessage(int dev, const char *message, int clear) ;
int tai8590_ClearDisplay(int dev) ;
#endif
| 18.615385 | 66 | 0.764463 |
0f45e7a0ac3182a846009c607f99bf96b49ede87 | 6,902 | h | C | 3rdparty/wxThings/wx/things/menubtn.h | Russ76/mrpt | 4a59edd8b3250acea27fcb94bf8e29bee1ba8e1c | [
"BSD-3-Clause"
] | 1,372 | 2015-07-25T00:33:22.000Z | 2022-03-30T12:55:33.000Z | 3rdparty/wxThings/wx/things/menubtn.h | Russ76/mrpt | 4a59edd8b3250acea27fcb94bf8e29bee1ba8e1c | [
"BSD-3-Clause"
] | 772 | 2015-07-18T19:18:54.000Z | 2022-03-27T02:45:51.000Z | 3rdparty/wxThings/wx/things/menubtn.h | Russ76/mrpt | 4a59edd8b3250acea27fcb94bf8e29bee1ba8e1c | [
"BSD-3-Clause"
] | 588 | 2015-07-23T01:13:18.000Z | 2022-03-31T08:05:40.000Z | /////////////////////////////////////////////////////////////////////////////
// Name: wxMenuButton
// Purpose: A button with a dropdown wxMenu
// Author: John Labenski
// Modified by:
// Created: 11/05/2002
// Copyright: (c) John Labenski
// Licence: wxWidgets licence
/////////////////////////////////////////////////////////////////////////////
/*
wxMenuButton is a button that drops down an assigned wxMenu
Create the button with either a text or bitmap label.
Create a new wxMenu and call AssignMenu and thats it. When you press the
dropdown button the menu appears. When you press the label button the next
wxITEM_RADIO (ie wxMenuItem::GetKind) in the menu is selected round robin.
If there are no radio items then it really just acts like a menubar, though
this is probably not too useful. The events sent in this case are EVT_MENUs
either generated by the menu when you click on it or created when you click
on the label to select the next radio item.
*/
#ifndef _WX_MENUBTN_H_
#define _WX_MENUBTN_H_
#include "wx/things/thingdef.h"
#include "wx/things/toggle.h"
class WXDLLEXPORT wxMenu;
class WXDLLEXPORT wxBitmap;
class WXDLLIMPEXP_THINGS wxCustomButton;
//-----------------------------------------------------------------------------
// wxMenuButton styles
//-----------------------------------------------------------------------------
#define wxMENUBUTTON_DROP_WIDTH 10
#define wxMENUBUTTON_DROP_HEIGHT 22
enum wxMenuButton_Styles
{
wxMENUBUT_FLAT = wxCUSTBUT_FLAT
};
//-----------------------------------------------------------------------------
// wxMenuButton
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_THINGS wxMenuButton : public wxControl
{
public:
wxMenuButton() : wxControl() { Init(); }
// Use this constructor if you need one compatible with a wxButton
// setup the button later with AssignMenu
wxMenuButton( wxWindow* parent,
wxWindowID id,
const wxString &label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxT("wxMenuButton"))
: wxControl()
{
Init();
Create(parent,id,label,wxNullBitmap,pos,size,style,val,name);
}
// Use this constructor if you need one compatible with a wxBitmapButton
// setup the button later with AssignMenu
wxMenuButton( wxWindow* parent, wxWindowID id,
const wxBitmap &bitmap,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxT("wxMenuButton"))
: wxControl()
{
Init();
Create(parent,id,wxEmptyString,bitmap,pos,size,style,val,name);
}
// wxComboBox constructor, completely setup later
wxMenuButton( wxWindow *parent, wxWindowID id,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = (const wxString *) nullptr,
long style = 0,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxT("wxMenuButton"))
: wxControl()
{
n = n; choices = choices; // get rid of unused warning
Init();
Create(parent, id, value, wxNullBitmap, pos, size, style, val, name);
}
// Native constructor
wxMenuButton( wxWindow* parent, wxWindowID id,
const wxString &label, const wxBitmap &bitmap,
wxMenu *menu, bool static_menu = false,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxT("wxMenuButton"))
: wxControl()
{
Init();
AssignMenu(menu, static_menu);
Create(parent,id,label,bitmap,pos,size,style,val,name);
}
virtual ~wxMenuButton();
bool Create( wxWindow* parent,
wxWindowID id,
const wxString &label,
const wxBitmap &bitmap,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxT("wxMenuButton"));
// Gets the id of the first selected radio item or wxNOT_FOUND (-1) if none
int GetSelection() const;
// This menu will be displayed when the dropdown button is pressed.
// if static_menu is false it will be deleted when the buttton is destroyed.
void AssignMenu(wxMenu *menu, bool static_menu = false);
wxMenu *GetMenu() const { return m_menu; }
// get a pointer to the label button, for turning it into a toggle perhaps
wxCustomButton *GetLabelButton() const { return m_labelButton; }
wxCustomButton *GetDropDownButton() const { return m_dropdownButton; }
void SetToolTip(const wxString &tip);
void SetToolTip(wxToolTip *tip);
protected:
void OnButton(wxCommandEvent &event);
virtual void DoSetSize(int x, int y, int width, int height,
int sizeFlags = wxSIZE_AUTO);
virtual wxSize DoGetBestSize();
// FIXME! - in MSW the radio items don't check themselves
#ifdef __WXMSW__
void OnMenu( wxCommandEvent &event );
#endif
wxCustomButton *m_labelButton;
wxCustomButton *m_dropdownButton;
wxMenu *m_menu;
bool m_menu_static;
long m_style;
private:
void Init();
DECLARE_DYNAMIC_CLASS(wxMenuButton)
DECLARE_EVENT_TABLE()
};
//-----------------------------------------------------------------------------
// wxMenuButtonEvents
//
// EVT_MENUBUTTON_OPEN(id, fn) - menu is about to be opened, (dis)(en)able items
// or call Veto() to stop menu from popping up
// this is a wxNotifyEvent
//-----------------------------------------------------------------------------
BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_THINGS, wxEVT_MENUBUTTON_OPEN, 0)
END_DECLARE_EVENT_TYPES()
#define EVT_MENUBUTTON_OPEN(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_MENUBUTTON_OPEN, id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxNotifyEventFunction) & fn, (wxObject *) nullptr ),
#endif // _WX_MENUBTN_H_
| 36.326316 | 219 | 0.581281 |
0f6f7ad283bd530f2675e1e6bc367e285f96baee | 129 | h | C | AADC/src/aadcDemo/datafilter/FisheyeUndistortion/stdafx.h | AlexanderVenetidis/aadc2018 | 53227597d47254e191ac836298c00f3226477f3d | [
"MIT"
] | null | null | null | AADC/src/aadcDemo/datafilter/FisheyeUndistortion/stdafx.h | AlexanderVenetidis/aadc2018 | 53227597d47254e191ac836298c00f3226477f3d | [
"MIT"
] | null | null | null | AADC/src/aadcDemo/datafilter/FisheyeUndistortion/stdafx.h | AlexanderVenetidis/aadc2018 | 53227597d47254e191ac836298c00f3226477f3d | [
"MIT"
] | null | null | null | version https://git-lfs.github.com/spec/v1
oid sha256:ce450b64c2a59498afb77caa60121ad5eb3fcd7433e6751c4ac343cbd4550e7c
size 2206
| 32.25 | 75 | 0.883721 |
58c169c204882f1256e47915cc8f5ffab820d363 | 975 | h | C | include/iocomponents/channel.h | LiamMayfair/EMU65 | 0d9540fd25ed84d501068becc71a11281fd6b01b | [
"MIT"
] | 4 | 2021-01-31T05:23:48.000Z | 2021-11-04T11:35:20.000Z | include/iocomponents/channel.h | LiamMayfair/EMU65 | 0d9540fd25ed84d501068becc71a11281fd6b01b | [
"MIT"
] | null | null | null | include/iocomponents/channel.h | LiamMayfair/EMU65 | 0d9540fd25ed84d501068becc71a11281fd6b01b | [
"MIT"
] | 3 | 2018-10-11T01:15:36.000Z | 2020-12-18T05:36:14.000Z | #ifndef CHANNEL_H
#define CHANNEL_H
#include <memory>
#include "../globals.h"
class IOBus;
/**
* ABC which defines the interface of any channel.
*/
class Channel
{
public:
/**
* Default constructor.
* @param bus Pointer to the IOBus singleton with which the channel will communicate.
*/
Channel(IOBus *bus);
/**
* Default destructor.
*/
virtual ~Channel();
/**
* Stores a byte in memory.
* @param address Address where \a value will be stored.
* @param value Value to store in \a address.
*/
virtual void Write(word address, byte value) const = 0;
/**
* Reads a byte from memory.
* @param address Address from which the byte is to be retrieved.
* @return The read byte from memory.
*/
virtual byte Read(word address) = 0;
protected:
/**
* Pointer to the IOBus instance with which the channel communicates.
*/
IOBus *m_bus;
};
#endif /* CHANNEL_H */
| 21.666667 | 89 | 0.620513 |
d7bf5ac9ae9febdfa604410dce973728f170fb9f | 2,012 | h | C | ophidian/parser/Net.h | sheiny/ophidian | 037ae44357e0093d60b379513615b467c1f841cf | [
"Apache-2.0"
] | 40 | 2016-04-22T14:42:42.000Z | 2021-05-25T23:14:23.000Z | ophidian/parser/Net.h | sheiny/ophidian | 037ae44357e0093d60b379513615b467c1f841cf | [
"Apache-2.0"
] | 64 | 2016-04-28T21:10:47.000Z | 2017-11-07T11:33:17.000Z | ophidian/parser/Net.h | eclufsc/openeda | 037ae44357e0093d60b379513615b467c1f841cf | [
"Apache-2.0"
] | 25 | 2016-04-18T19:31:48.000Z | 2021-05-05T15:50:41.000Z | /*
* Copyright 2018 Ophidian
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
#ifndef OPHIDIAN_PARSER_NET_H
#define OPHIDIAN_PARSER_NET_H
#include <ophidian/util/Units.h>
namespace ophidian::parser
{
class Net
{
public:
// Class member types
using name_type = std::string;
using pin_name_type = std::string;
using component_name_type = std::string;
using pin_type = std::pair<component_name_type, pin_name_type>;
using pin_container_type = std::vector<pin_type>;
// Class constructors
Net() = delete;
Net(const Net &) = default;
Net & operator=(const Net &) = default;
Net(Net &&) = default;
Net & operator=(Net &&) = default;
template<class Arg1, class Arg2>
Net(Arg1&& name, Arg2&& pins):
m_name{std::forward<Arg1>(name)},
m_pins{std::forward<Arg2>(pins)}
{ }
const name_type& name() const noexcept;
const pin_container_type& pins() const noexcept;
bool operator==(const Net& rhs) const noexcept;
friend std::ostream& operator<<(std::ostream& os, const Net& net);
private:
name_type m_name;
pin_container_type m_pins;
};
}
#endif
| 27.944444 | 74 | 0.664513 |
bf2891426d2ec7a7a5ccb4a6dc5935bde46f50ad | 1,823 | h | C | AzureIotPnpDps.X/platform/led.h | keianasnell/Microchip-PIC-IoT-Wx | c284d69c98722ffdf2b7f156fe06083953e90bdf | [
"MIT"
] | null | null | null | AzureIotPnpDps.X/platform/led.h | keianasnell/Microchip-PIC-IoT-Wx | c284d69c98722ffdf2b7f156fe06083953e90bdf | [
"MIT"
] | 1 | 2021-02-24T01:47:17.000Z | 2021-02-24T01:47:17.000Z | AzureIotPnpDps.X/platform/led.h | isabella232/Microchip-PIC-IoT-Wx | e400c0242eea9268bc859a826613b6dee85f0a98 | [
"MIT"
] | null | null | null | /*
\file led.h
\brief led header file.
(c) 2018 Microchip Technology Inc. and its subsidiaries.
Subject to your compliance with these terms, you may use Microchip software and any
derivatives exclusively with Microchip products. It is your responsibility to comply with third party
license terms applicable to your use of third party software (including open source software) that
may accompany Microchip software.
THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
FOR A PARTICULAR PURPOSE.
IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
SOFTWARE.
*/
#ifndef LED_H_
#define LED_H_
#include <stdint.h>
#include <stdbool.h>
#define LED_ON false
#define LED_OFF true
void LED_test(void);
void LED_flashYellow(void);
void LED_holdYellowOn(bool holdHigh);
void LED_holdGreenOn(bool holdHigh);
void LED_holdRedOn(bool holdHigh);
void LED_flashRed(double interval_seconds);
bool LED_isBlinkingRed(void);
void LED_blinkingBlue(bool amBlinking);
void LED_startBlinkingGreen(void);
void LED_stopBlinkingGreen(void);
bool LED_isBlinkingGreen(void);
void LED_startBlinkingRed(void);
void LED_stopBlinkingRed(void);
#endif /* LED_H_ */
| 35.057692 | 105 | 0.769611 |
9c38bc4a536616416090e692fb61468b89004c86 | 556 | h | C | cpp-qt/2021-07-15--qt-qml-filters-apply/src/distortion/pixel/horizontal_drop_pixels.h | Dreamykass/bitsofkass | b43f726b4d12784075eec998ebf5fff908f87c35 | [
"MIT"
] | 2 | 2021-09-22T15:04:29.000Z | 2021-11-22T06:30:48.000Z | cpp-qt/2021-07-15--qt-qml-filters-with-arguments/src/distortion/pixel/horizontal_drop_pixels.h | Dreamykass/bitsofkass | b43f726b4d12784075eec998ebf5fff908f87c35 | [
"MIT"
] | null | null | null | cpp-qt/2021-07-15--qt-qml-filters-with-arguments/src/distortion/pixel/horizontal_drop_pixels.h | Dreamykass/bitsofkass | b43f726b4d12784075eec998ebf5fff908f87c35 | [
"MIT"
] | null | null | null | #ifndef HORIZONTALDROPPIXELS_H
#define HORIZONTALDROPPIXELS_H
#include "distortion.h"
#include "opencv2/opencv.hpp"
namespace distortion::pixel {
class HorizontalDropPixels : public Distortion {
public:
HorizontalDropPixels();
Distortion* cloneFromDescription(DistortionDescription) const override;
QString stringOfInternalValues() const;
void distort(cv::Mat&) const override;
private:
double stepDeleteMin = -9999;
double stepDeleteMax = -9999;
};
}
#endif // HORIZONTALDROPPIXELS_H
| 26.47619 | 79 | 0.710432 |
c530ec3c3a587fd4b2fa11ea8a71662edba3ee07 | 1,364 | h | C | MITK/Modules/OIGTLSystemTimeService/Internal/niftkOIGTLSystemTimeService.h | NifTK/NifTK | 2358b333c89ff1bba1c232eecbbcdc8003305dfe | [
"BSD-3-Clause"
] | 13 | 2018-07-28T13:36:38.000Z | 2021-11-01T19:17:39.000Z | MITK/Modules/OIGTLSystemTimeService/Internal/niftkOIGTLSystemTimeService.h | NifTK/NifTK | 2358b333c89ff1bba1c232eecbbcdc8003305dfe | [
"BSD-3-Clause"
] | null | null | null | MITK/Modules/OIGTLSystemTimeService/Internal/niftkOIGTLSystemTimeService.h | NifTK/NifTK | 2358b333c89ff1bba1c232eecbbcdc8003305dfe | [
"BSD-3-Clause"
] | 10 | 2018-08-20T07:06:00.000Z | 2021-07-07T07:55:27.000Z | /*=============================================================================
NifTK: A software platform for medical image computing.
Copyright (c) University College London (UCL). All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
See LICENSE.txt in the top level directory for details.
=============================================================================*/
#ifndef niftkOIGTLSystemTimeService_h
#define niftkOIGTLSystemTimeService_h
#include <niftkSystemTimeServiceI.h>
#include <igtlTimeStamp.h>
#include <itkFastMutexLock.h>
namespace niftk
{
/**
* \class OIGTLSystemTimeService
* \brief Implements SystemTimeServiceI using igtl::TimeStamp.
*/
class OIGTLSystemTimeService : public SystemTimeServiceI
{
public:
OIGTLSystemTimeService();
~OIGTLSystemTimeService();
/**
* \see SystemTimeServiceI::GetSystemTimeInNanoseconds()
*/
virtual TimeType GetSystemTimeInNanoseconds() const override;
private:
OIGTLSystemTimeService(const OIGTLSystemTimeService&); // deliberately not implemented
OIGTLSystemTimeService& operator=(const OIGTLSystemTimeService&); // deliberately not implemented
itk::FastMutexLock::Pointer m_Mutex;
igtl::TimeStamp::Pointer m_TimeStamp;
};
} // end namespace
#endif
| 25.735849 | 99 | 0.693548 |
7dd9fb8717865d952d4f3cbc077227ceaaeef8cf | 923 | c | C | lib/wizards/nalle/potshad1.c | vlehtola/questmud | 8bc3099b5ad00a9e0261faeb6637c76b521b6dbe | [
"MIT"
] | null | null | null | lib/wizards/nalle/potshad1.c | vlehtola/questmud | 8bc3099b5ad00a9e0261faeb6637c76b521b6dbe | [
"MIT"
] | null | null | null | lib/wizards/nalle/potshad1.c | vlehtola/questmud | 8bc3099b5ad00a9e0261faeb6637c76b521b6dbe | [
"MIT"
] | null | null | null | object aijys;
int str;
start(ob) {
aijys = ob;
shadow(aijys, 1);
str = 4;
update_stats();
call_out("normal", 119);
call_out("definate_loop", 25);
return 1;
}
definate_loop() {
write("You rub your muscles in an attempt to make them function correcly again.\n");
say(call_other(this_player(), "query_name", 0) + " rubs his muscles as they fail to work properly.\n"); call_out("definate_loop",random(20)+30);
}
update_stats() {
aijys->update_stats();
aijys->set_str(4);
}
normal() {
object puuh;
puuh = allocate(1);
puuh[0] = aijys;
tell_object(aijys, "You feel like the effect of the potion is wearing off.\n");
tell_room(environment(aijys), aijys->query_name()+" seems to feel a bit better.\n", puuh);
str=0;
aijys->update_stats();
destruct(this_object());
return 1;
}
death(arg) {
str=0;
aijys->update_stats();
aijys->death(arg);
destruct(this_object());
return 1;
}
| 21.97619 | 148 | 0.661972 |
7b0f2d9215fec287eed37fe25ad1fd3bd9327d95 | 24,411 | c | C | src/wpapcap2john.c | sanjukholia/JohnTheRipper | fb8c7795cc11b8094109907c948a2f29f1976773 | [
"OLDAP-2.4"
] | 1 | 2020-07-23T16:33:27.000Z | 2020-07-23T16:33:27.000Z | src/wpapcap2john.c | sanjukholia/JohnTheRipper | fb8c7795cc11b8094109907c948a2f29f1976773 | [
"OLDAP-2.4"
] | null | null | null | src/wpapcap2john.c | sanjukholia/JohnTheRipper | fb8c7795cc11b8094109907c948a2f29f1976773 | [
"OLDAP-2.4"
] | null | null | null | /*
* This software is Copyright (c) 2013 Jim Fougeron jfoug AT cox dot net,
* Copyright (c) 2013 Dhiru Kholia <dhiru.kholia at gmail.com>
* and Copyright (c) 2014 magnum, and it is hereby released
* to the general public under the following terms: Redistribution and use in
* source and binary forms, with or without modification, are permitted.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "wpapcap2john.h"
#include "jumbo.h"
#include "memdbg.h"
/*
* Max. number of ESSID's we can collect from all files combined.
* Just bump this if you need more. We should use a linked list instead
* and drop this limitation
*/
#define MAX_ESSIDS 10000
static int GetNextPacket(FILE *in);
static int ProcessPacket();
static void HandleBeacon();
static void Handle4Way(int bIsQOS);
static void DumpKey(int idx, int one_three, int bIsQOS);
static uint32 start_t, start_u, cur_t, cur_u;
static pcaprec_hdr_t pkt_hdr;
static uint8 *full_packet;
static uint8 *packet;
static int bROT;
static WPA4way_t wpa[MAX_ESSIDS];
static int nwpa = 0;
static char *unVerified[MAX_ESSIDS];
static int nunVer = 0;
static const char cpItoa64[64] =
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
static const char *filename;
static unsigned int link_type, ShowIncomplete = 1;
// These 2 functions output data properly for JtR, in base-64 format. These
// were taken from hccap2john.c source, and modified for this project.
static int code_block(unsigned char *in, unsigned char b, char *cp)
{
int cnt = 0;
*cp++ = cpItoa64[in[0] >> 2];
*cp++ = cpItoa64[((in[0] & 0x03) << 4) | (in[1] >> 4)];
if (b) {
*cp++ = cpItoa64[((in[1] & 0x0f) << 2) | (in[2] >> 6)];
*cp++ = cpItoa64[in[2] & 0x3f];
++cnt;
} else
*cp++ = cpItoa64[((in[1] & 0x0f) << 2)];
*cp = 0;
return cnt+3;
}
static void to_bssid(char bssid[18], uint8 *p)
{
sprintf(bssid, "%02X:%02X:%02X:%02X:%02X:%02X",
p[0],p[1],p[2],p[3],p[4],p[5]);
}
static void to_dashed(char bssid[18], uint8 *p)
{
sprintf(bssid, "%02x-%02x-%02x-%02x-%02x-%02x",
p[0],p[1],p[2],p[3],p[4],p[5]);
}
static void to_compact(char bssid[13], uint8 *p)
{
sprintf(bssid, "%02x%02x%02x%02x%02x%02x",
p[0],p[1],p[2],p[3],p[4],p[5]);
}
// Convert WPA handshakes from aircrack-ng (airodump-ng) IVS2 to JtR format
static int convert_ivs(FILE *f_in)
{
struct ivs2_filehdr fivs2;
struct ivs2_pkthdr ivs2;
struct ivs2_WPA_hdsk *wivs2;
hccap_t hccap;
unsigned int i;
unsigned char buffer[66000];
size_t length, pos;
unsigned int pktlen;
unsigned char bssid[6];
int bssidFound = 0;
char essid[500];
int essidFound = 0;
unsigned char *p, *w;
fseek(f_in, 0, SEEK_END);
length = ftell(f_in);
fseek(f_in, 0, SEEK_SET);
if(fread(buffer, 1, 4, f_in) != 4) {
fprintf(stderr, "%s: fread file header failed\n", filename);
return(1);
}
if(memcmp(buffer, IVSONLY_MAGIC, 4) == 0) {
fprintf(stderr, "%s: old version .ivs file, no WPA2 handshakes\n", filename);
return(1);
}
if(memcmp(buffer, IVS2_MAGIC, 4) != 0) {
fprintf(stderr, "%s: not an .%s file\n", filename, IVS2_EXTENSION);
return(1);
}
if(fread(&fivs2, 1, sizeof(struct ivs2_filehdr), f_in) != (size_t) sizeof(struct ivs2_filehdr)) {
fprintf(stderr, "%s: fread file header failed", filename);
return(1);
}
if(fivs2.version > IVS2_VERSION) {
fprintf(stderr, "%s: wrong %s version: %d. Supported up to version %d.\n", filename, IVS2_EXTENSION, fivs2.version, IVS2_VERSION);
return(1);
}
pos = ftell(f_in);
while (pos < length) {
if (fread(&ivs2, 1, sizeof(struct ivs2_pkthdr), f_in) != sizeof(struct ivs2_pkthdr)) {
fprintf(stderr, "%s: Error reading header at pos "Zu" of "Zu"\n", filename, pos, length);
return 1;
}
pos += sizeof(struct ivs2_pkthdr);
pktlen = (unsigned int)ivs2.len;
if (pktlen+pos > length) {
fprintf(stderr, "%s: Invalid packet length %u at "Zu"\n", filename, pktlen, pos-sizeof(struct ivs2_pkthdr));
return 1;
}
if (fread(&buffer, 1, pktlen, f_in) != pktlen) {
fprintf(stderr, "%s: Error reading data (%u) at pos "Zu" of "Zu"\n", filename, pktlen, pos, length);
return 1;
}
// Show "packet" headers
// printf("%ld : %d - %02x\n", pos, pktlen, (unsigned int)ivs2.flags);
p = buffer;
if (ivs2.flags & IVS2_BSSID) {
memcpy(bssid, p, 6);
p += 6;
fprintf(stderr, "%s: BSSID: %02x:%02x:%02x:%02x:%02x:%02x\n", filename, p[0], p[1], p[2], p[3], p[4], p[5]);
bssidFound = 1;
}
if (ivs2.flags & IVS2_ESSID) {
unsigned int ofs = (p - buffer);
unsigned int len = pktlen - ofs;
if (len <= 0 || len+1 > sizeof(essid)) {
printf("Invalid ESSID length (%d)\n", len);
return 1;
}
memcpy(essid, p, len);
essid[len] = 0;
essidFound = 1;
fprintf(stderr,"ESSID: '%s' (%d bytes)\n", essid, len);
p += len;
}
if (ivs2.flags & IVS2_WPA) {
char buf[8];
int ofs = (p - buffer);
int len = pktlen - ofs;
char sta_mac[18], ap_mac[18], gecos[13];
if (len != sizeof(struct ivs2_WPA_hdsk)) {
fprintf(stderr, "%s: Invalid WPA handshake length (%d vs %d)\n", filename, len, (int)sizeof(struct ivs2_WPA_hdsk));
return 1;
}
if (!bssidFound) {
fprintf(stderr, "%s: Got WPA handshake but we don't have BSSID\n", filename);
return 1;
}
if (!essidFound) {
fprintf(stderr, "%s: Got WPA handshake but we don't have SSID\n", filename);
return 1;
}
wivs2 = (struct ivs2_WPA_hdsk*)p;
fprintf(stderr, "WPA handshake keyver=%d eapolSize=%d\n\n", wivs2->keyver, wivs2->eapol_size);
printf ("%s:$WPAPSK$%s#", essid, essid);
memset(&hccap, 0, sizeof(hccap_t));
hccap.keyver = wivs2->keyver;
memcpy(hccap.mac1, bssid, 6);
memcpy(hccap.mac2, wivs2->stmac, 6);
memcpy(hccap.nonce1, wivs2->snonce,32);
memcpy(hccap.nonce2, wivs2->anonce,32);
memcpy(hccap.keymic, wivs2->keymic, 16);
hccap.eapol_size = wivs2->eapol_size;
if (hccap.eapol_size > sizeof(((hccap_t*)(NULL))->eapol)) {
fprintf(stderr,
"%s: eapol size %u (too large), skipping packet\n",
filename, hccap.eapol_size);
return 1;
}
memcpy(hccap.eapol, wivs2->eapol, wivs2->eapol_size);
// print struct in base64 format
w = (unsigned char*)&hccap;
for (i=36; i+3 < sizeof(hccap_t); i += 3) {
code_block(&w[i], 1, buf);
printf ("%s", buf);
}
code_block(&w[i], 0, buf);
printf ("%s", buf);
to_compact(gecos, hccap.mac1);
to_dashed(ap_mac, hccap.mac1);
to_dashed(sta_mac, hccap.mac2);
printf(":%s:%s:%s::WPA", sta_mac, ap_mac, gecos);
if (hccap.keyver > 1)
printf("%d", hccap.keyver);
printf("::%s\n", filename);
fflush(stdout);
p += len;
}
if (p < buffer+pktlen) {
fprintf(stderr, "%s: Unable to parse all data, unsupported flag? (%02x)\n", filename, (int)ivs2.flags);
}
pos += pktlen;
}
return 0;
}
static void dump_any_unver() {
if (nunVer) {
int i;
fprintf(stderr, "Dumping %d unverified keys, which were not verified\n", nunVer);
for (i = 0; i < nunVer; ++i) {
printf("%s\n", unVerified[i]);
MEM_FREE(unVerified[i]);
}
}
nunVer = 0;
}
static int Process(FILE *in)
{
pcap_hdr_t main_hdr;
if (fread(&main_hdr, 1, sizeof(pcap_hdr_t), in) != sizeof(pcap_hdr_t)) {
fprintf(stderr,
"%s: Error, could not read enough bytes to get a common 'main' pcap header\n",
filename);
return 0;
}
if (main_hdr.magic_number == 0xa1b2c3d4)
bROT = 0;
else if (main_hdr.magic_number == 0xd4c3b2a1)
bROT = 1;
else {
if (convert_ivs(in)) {
fprintf(stderr, "%s: not a pcap file\n", filename);
return 0;
}
return 1;
}
if (bROT) {
main_hdr.magic_number = swap32u(main_hdr.magic_number);
main_hdr.version_major = swap16u(main_hdr.version_major);
main_hdr.version_minor = swap16u(main_hdr.version_minor);
main_hdr.sigfigs = swap32u(main_hdr.sigfigs);
main_hdr.snaplen = swap32u(main_hdr.snaplen);
main_hdr.network = swap32u(main_hdr.network);
}
link_type = main_hdr.network;
if (link_type == LINKTYPE_IEEE802_11)
fprintf(stderr, "%s: raw 802.11\n", filename);
else if (link_type == LINKTYPE_PRISM_HEADER)
fprintf(stderr, "%s: Prism headers stripped\n", filename);
else if (link_type == LINKTYPE_RADIOTAP_HDR)
fprintf(stderr, "%s: Radiotap headers stripped\n", filename);
else if (link_type == LINKTYPE_PPI_HDR)
fprintf(stderr, "%s: PPI headers stripped\n", filename);
else {
fprintf(stderr, "%s: No 802.11 wireless traffic data (network %d)\n", filename, link_type);
return 0;
}
while (GetNextPacket(in)) {
if (!ProcessPacket()) {
dump_any_unver();
return 1;
}
}
dump_any_unver();
return 1;
}
static int GetNextPacket(FILE *in)
{
size_t read_size;
if (fread(&pkt_hdr, 1, sizeof(pkt_hdr), in) != sizeof(pkt_hdr)) return 0;
if (bROT) {
pkt_hdr.ts_sec = swap32u(pkt_hdr.ts_sec);
pkt_hdr.ts_usec = swap32u(pkt_hdr.ts_usec);
pkt_hdr.incl_len = swap32u(pkt_hdr.incl_len);
pkt_hdr.orig_len = swap32u(pkt_hdr.orig_len);
}
if (!start_t) {
start_t = pkt_hdr.ts_sec;
start_u = pkt_hdr.ts_usec;
}
cur_t = pkt_hdr.ts_sec-start_t;
if (start_u > pkt_hdr.ts_usec) {
--cur_t;
cur_u = 1000000-(start_u-pkt_hdr.ts_usec);
} else
cur_u = pkt_hdr.ts_usec-start_u;
MEM_FREE(full_packet);
full_packet = NULL;
full_packet = (uint8 *)malloc(pkt_hdr.incl_len);
if (NULL == full_packet) {
fprintf(stderr, "%s:%d: malloc of "Zu" bytes failed\n",
__FILE__, __LINE__, sizeof(uint8) * pkt_hdr.orig_len);
exit(EXIT_FAILURE);
}
read_size = fread(full_packet, 1, pkt_hdr.incl_len, in);
if (read_size < pkt_hdr.incl_len)
fprintf(stderr, "%s: truncated last packet\n", filename);
return (read_size == pkt_hdr.incl_len);
}
// Ok, this function is the main packet processor. NOTE, when we are done
// reading packets (i.e. we have done what we want), we return 0, and
// the program will exit gracefully. It is not an error, it is just an
// indication we have completed (or that the data we want is not here).
static int ProcessPacket()
{
ether_frame_hdr_t *pkt;
ether_frame_ctl_t *ctl;
unsigned int frame_skip = 0;
packet = full_packet;
// Skip Prism frame if present
if (link_type == LINKTYPE_PRISM_HEADER) {
if (packet[7] == 0x40)
frame_skip = 64;
else {
frame_skip = *(unsigned int*)&packet[4];
#if !ARCH_LITTLE_ENDIAN
frame_skip = JOHNSWAP(frame_skip);
#endif
}
if (frame_skip < 8 || frame_skip >= pkt_hdr.incl_len)
return 0;
packet += frame_skip;
pkt_hdr.incl_len -= frame_skip;
pkt_hdr.orig_len -= frame_skip;
}
// Skip Radiotap frame if present
if (link_type == LINKTYPE_RADIOTAP_HDR) {
frame_skip = *(unsigned short*)&packet[2];
#if !ARCH_LITTLE_ENDIAN
frame_skip = JOHNSWAP(frame_skip);
#endif
if (frame_skip == 0 || frame_skip >= pkt_hdr.incl_len)
return 0;
packet += frame_skip;
pkt_hdr.incl_len -= frame_skip;
pkt_hdr.orig_len -= frame_skip;
}
// Skip PPI frame if present
if (link_type == LINKTYPE_PPI_HDR) {
frame_skip = *(unsigned short*)&packet[2];
#if !ARCH_LITTLE_ENDIAN
frame_skip = JOHNSWAP(frame_skip);
#endif
if(frame_skip <= 0 || frame_skip >= pkt_hdr.incl_len)
return 0;
// Kismet logged broken PPI frames for a period
if (frame_skip == 24 && *(unsigned short*)&packet[8] == 2)
frame_skip = 32;
if (frame_skip == 0 || frame_skip >= pkt_hdr.incl_len)
return 0;
packet += frame_skip;
pkt_hdr.incl_len -= frame_skip;
pkt_hdr.orig_len -= frame_skip;
}
// our data is in *packet with pkt_hdr being the pcap packet header for this packet.
pkt = (ether_frame_hdr_t*)packet;
ctl = (ether_frame_ctl_t *)&pkt->frame_ctl;
if (ctl->type == 0 && ctl->subtype == 8) { // beacon Type 0 is management, subtype 8 is beacon
HandleBeacon();
return 1;
}
// if not beacon, then only look data, looking for EAPOL 'type'
if (ctl->type == 2) { // type 2 is data
uint8 *p = packet;
int bQOS = (ctl->subtype & 8) != 0;
if ((ctl->toDS ^ ctl->fromDS) != 1)// eapol will ONLY be direct toDS or direct fromDS.
return 1;
// Ok, find out if this is a EAPOL packet or not.
p += sizeof(ether_frame_hdr_t);
if (bQOS)
p += 2;
// p now points to the start of the LLC (logical link control) structure.
// this is 8 bytes long, and the last 2 bytes are the 'type' field. What
// we are looking for is 802.11X authentication packets. These are 0x888e
// in value. We are running from an LE point of view, so should look for 0x8e88
p += 6;
if (*((uint16*)p) == 0x8e88)
Handle4Way(bQOS); // this packet was a eapol packet.
}
return 1;
}
static void e_fail(void)
{
fprintf(stderr, "Incorrect -e option.\n");
exit(EXIT_FAILURE);
}
static void ManualBeacon(char *essid_bssid)
{
char *essid = essid_bssid;
char *bssid = strchr(essid_bssid, ':');
if (!bssid)
e_fail();
*bssid++ = 0;
if (strlen(essid) > 32 || strlen(bssid) != 17)
e_fail();
bssid = strupr(bssid);
fprintf(stderr, "Manually adding ESSID '%s' BSSID '%s'\n", essid, bssid);
strcpy(wpa[nwpa].essid, essid);
strcpy(wpa[nwpa].bssid, bssid);
if (++nwpa >= MAX_ESSIDS) {
fprintf(stderr, "ERROR: Too many ESSIDs seen (%d)\n", MAX_ESSIDS);
exit(EXIT_FAILURE);
}
}
static void HandleBeacon()
{
ether_frame_hdr_t *pkt = (ether_frame_hdr_t*)packet;
int i;
ether_beacon_data_t *pDat = (ether_beacon_data_t*)&packet[sizeof(ether_frame_hdr_t)];
ether_beacon_tag_t *tag = pDat->tags;
uint8 *pFinal = &packet[pkt_hdr.incl_len];
char essid[36] = { 0 };
char bssid[18];
// addr1 should be broadcast
// addr2 is source addr (should be same as BSSID)
// addr3 is BSSID (routers MAC)
// ok, walk the tags
while (((uint8*)tag) < pFinal) {
char *x = (char*)tag;
if (tag->tagtype == 0 && tag->taglen < sizeof(essid))
memcpy(essid, tag->tag, tag->taglen);
x += tag->taglen + 2;
tag = (ether_beacon_tag_t *)x;
}
to_bssid(bssid, pkt->addr3);
for (i = 0; i < nwpa; ++i) {
if (!strcmp(bssid, wpa[i].bssid) && !strcmp(essid, wpa[i].essid))
return;
}
strcpy(wpa[nwpa].essid, essid);
strcpy(wpa[nwpa].bssid, bssid);
fprintf(stderr, "Learned ESSID '%s' with BSSID '%s'\n", essid, bssid);
if (++nwpa >= MAX_ESSIDS) {
fprintf(stderr, "ERROR: Too many ESSIDs seen (%d)\n", MAX_ESSIDS);
exit(EXIT_FAILURE);
}
}
static void Handle4Way(int bIsQOS)
{
ether_frame_hdr_t *pkt = (ether_frame_hdr_t*)packet;
int i, ess=-1;
uint8 *orig_2 = NULL;
uint8 *p = (uint8*)&packet[sizeof(ether_frame_hdr_t)];
ether_auto_802_1x_t *auth;
int msg = 0;
char bssid[18];
// ok, first thing, find the beacon. If we can NOT find the beacon, then
// do not proceed. Also, if we find the becon, we may determine that
// we already HAVE fully cracked this
to_bssid(bssid, pkt->addr3);
for (i = 0; i < nwpa; ++i) {
if (!strcmp(bssid, wpa[i].bssid)) {
ess=i;
break;
}
}
if (ess==-1) goto out;
if (wpa[ess].fully_cracked)
goto out; // no reason to go on.
orig_2 = (uint8 *)malloc(pkt_hdr.incl_len);
if (NULL == orig_2) {
fprintf(stderr, "%s:%d: malloc of "Zu" bytes failed\n",
__FILE__, __LINE__, sizeof(uint8) * pkt_hdr.orig_len);
exit(EXIT_FAILURE);
}
memcpy(orig_2, packet, pkt_hdr.incl_len);
// Ok, after pkt, uint16 QOS control (should be 00 00)
if (bIsQOS)
p += 2;
// we are now at Logical-Link Control. (8 bytes long).
// LLC check not needed here any more. We do it in the packet cracker section, b4
// calling this function. We just need to skip the 8 byte LLC.
//if (memcmp(p, "\xaa\xaa\x3\0\0\0\x88\x8e", 8)) return; // not a 4way
p += 8;
// p now points to the 802.1X Authentication structure.
auth = (ether_auto_802_1x_t*)p;
auth->length = swap16u(auth->length);
//*(uint16*)&(auth->key_info) = swap16u(*(uint16*)&(auth->key_info));
auth->key_info_u16 = swap16u(auth->key_info_u16);
auth->key_len = swap16u(auth->key_len);
auth->replay_cnt = swap64u(auth->replay_cnt);
auth->wpa_keydatlen = swap16u(auth->wpa_keydatlen);
if (!auth->key_info.KeyACK) {
// msg 2 or 4
if (auth->key_info.Secure) {
// msg = 4;
// is this useful?
goto out;
}
else
msg = 2;
} else {
if (auth->key_info.Install)
msg = 3;
else
msg = 1;
}
// Ok, we look for a 1 followed immediately by a 2 which have exact same replay_cnt, we have
// a 'likely' key. Or we want a 2 followed by a 3 that are 1 replay count apart) which means
// we DO have a key. The 3 is not returned unless the 2 (which came from the client), IS
// valid. So, we get the anonce from either the 1 or the 3 packet.
// for our first run, we output ALL valid keys found in the file. That way, I can validate that
// any keys which were produced by aircrack-ng are 'valid' or not. aircrack-ng WILL generate some
// invalid keys. Also, I want to flag "unknown" keys as just that, unk. These are 1-2's which
// do not have valid 3 4's. They 'may' be valid, but may also be a client with the wrong password.
if (msg == 1) {
MEM_FREE(wpa[ess].packet1);
wpa[ess].packet1 = (uint8 *)malloc(sizeof(uint8) * pkt_hdr.incl_len);
if (wpa[ess].packet1 == NULL) {
fprintf(stderr, "%s:%d: malloc of "Zu" bytes failed\n",
__FILE__, __LINE__, sizeof(uint8) * pkt_hdr.orig_len);
exit(EXIT_FAILURE);
}
memcpy(wpa[ess].packet1, packet, pkt_hdr.incl_len);
MEM_FREE(wpa[ess].packet2);
MEM_FREE(wpa[ess].orig_2);
MEM_FREE(wpa[ess].packet3);
}
else if (msg == 2) {
// Some sanitiy checks
if (pkt_hdr.incl_len < sizeof(ether_frame_hdr_t) + (bIsQOS ? 10 : 8)) {
fprintf(stderr, "%s: header len %u, wanted to subtract "Zu", skipping packet\n",
filename, pkt_hdr.incl_len, sizeof(ether_frame_hdr_t) + (bIsQOS ? 10 : 8));
goto out;
}
// see if we have a msg1 that 'matches'.
MEM_FREE(wpa[ess].packet3);
wpa[ess].packet2 = (uint8 *)malloc(sizeof(uint8) * pkt_hdr.incl_len);
if (wpa[ess].packet2 == NULL) {
fprintf(stderr, "%s:%d: malloc of "Zu" bytes failed\n",
__FILE__, __LINE__, sizeof(uint8) * pkt_hdr.orig_len);
exit(EXIT_FAILURE);
}
wpa[ess].orig_2 = (uint8 *)malloc(sizeof(uint8) * pkt_hdr.incl_len);
if (wpa[ess].orig_2 == NULL) {
fprintf(stderr, "%s:%d: malloc of "Zu" bytes failed\n",
__FILE__, __LINE__, sizeof(uint8) * pkt_hdr.orig_len);
exit(EXIT_FAILURE);
}
memcpy(wpa[ess].packet2, packet, pkt_hdr.incl_len);
memcpy(wpa[ess].orig_2, orig_2, pkt_hdr.incl_len);
// This is canonical for any encapsulations
wpa[ess].eapol_sz = auth->length + 4;
if (wpa[ess].eapol_sz > sizeof(((hccap_t*)(NULL))->eapol)) {
fprintf(stderr, "%s: eapol size %u (too large), skipping packet\n",
filename, wpa[ess].eapol_sz);
wpa[ess].eapol_sz = 0;
MEM_FREE(wpa[ess].packet2);
MEM_FREE(wpa[ess].orig_2);
goto out;
}
if (wpa[ess].packet1 && ShowIncomplete) {
ether_auto_802_1x_t *auth2 = auth, *auth1;
p = (uint8*)wpa[ess].packet1;
if (bIsQOS)
p += 2;
p += 8;
p += sizeof(ether_frame_hdr_t);
auth1 = (ether_auto_802_1x_t*)p;
if (auth1->replay_cnt == auth2->replay_cnt) {
fprintf (stderr, "\nKey1/Key2 hit (unverified), for ESSID:%s (%s)\n", wpa[ess].essid, filename);
DumpKey(ess, 1, bIsQOS);
}
}
}
else if (msg == 3) {
// see if we have a msg2 that 'matches', which is 1 less than our replay count.
wpa[ess].packet3 = (uint8 *)malloc(sizeof(uint8) * pkt_hdr.incl_len);
if (wpa[ess].packet3 == NULL) {
fprintf(stderr, "%s:%d: malloc of "Zu" bytes failed\n",
__FILE__, __LINE__, sizeof(uint8) * pkt_hdr.orig_len);
exit(EXIT_FAILURE);
}
memcpy(wpa[ess].packet3, packet, pkt_hdr.incl_len);
if (wpa[ess].packet2) {
ether_auto_802_1x_t *auth3 = auth, *auth2;
p = (uint8*)wpa[ess].packet2;
if (bIsQOS)
p += 2;
p += 8;
p += sizeof(ether_frame_hdr_t);
auth2 = (ether_auto_802_1x_t*)p;
if (auth2->replay_cnt+1 == auth3->replay_cnt) {
ether_auto_802_1x_t *auth1;
if (wpa[ess].packet1) {
p = (uint8*)wpa[ess].packet1;
if (bIsQOS)
p += 2;
p += 8;
p += sizeof(ether_frame_hdr_t);
auth1 = (ether_auto_802_1x_t*)p;
}
// If we saw the first packet, its nonce must
// match the third's nonce and we are 100% sure.
// If we didn't see it, we are only 99% sure.
if (!wpa[ess].packet1 || !memcmp(auth1->wpa_nonce, auth3->wpa_nonce, 32)) {
fprintf (stderr, "\nKey2/Key3 hit (%s verified), for ESSID:%s (%s)\n",
wpa[ess].packet1 ? "100%" : "99%", wpa[ess].essid, filename);
DumpKey(ess, 3, bIsQOS);
wpa[ess].fully_cracked = 1;
}
}
}
// clear this, so we do not hit the same 3 packet and output exact same 2/3 combo.
MEM_FREE(wpa[ess].packet1);
MEM_FREE(wpa[ess].packet3);
MEM_FREE(wpa[ess].packet2);
MEM_FREE(wpa[ess].orig_2);
}
out:
MEM_FREE(orig_2);
}
static void DumpKey(int ess, int one_three, int bIsQOS)
{
ether_auto_802_1x_t *auth13, *auth2;
uint8 *p = (uint8*)wpa[ess].packet2;
uint8 *pkt2 = p;
uint8 *p13;
hccap_t hccap;
int i;
uint8 *w;
char sta_mac[18+1], ap_mac[18+1], gecos[13+1];
char TmpKey[2048], *cp = TmpKey;
int search_len;
fprintf (stderr, "Dumping key %d at time: %d.%d BSSID %s ESSID=%s\n", one_three, cur_t, cur_u, wpa[ess].bssid, wpa[ess].essid);
cp += sprintf (cp, "%s:$WPAPSK$%s#", wpa[ess].essid, wpa[ess].essid);
if (!wpa[ess].packet2) { printf ("ERROR, msg2 null\n"); return; }
if (bIsQOS)
p += 2;
p += 8;
p += sizeof(ether_frame_hdr_t);
auth2 = (ether_auto_802_1x_t*)p;
if (one_three==1) {
if (!wpa[ess].packet1) { printf ("ERROR, msg1 null\n"); return; }
p = wpa[ess].packet1;
} else {
if (!wpa[ess].packet3) { printf ("ERROR, msg3 null\n"); return; }
p = wpa[ess].packet3;
}
p13 = p;
if (bIsQOS)
p += 2;
p += 8;
p += sizeof(ether_frame_hdr_t);
auth13 = (ether_auto_802_1x_t*)p;
memset(&hccap, 0, sizeof(hccap_t));
hccap.keyver = auth2->key_info.KeyDescr;
memcpy(hccap.mac1, ((ether_frame_hdr_t*)pkt2)->addr1, 6);
memcpy(hccap.mac2, ((ether_frame_hdr_t*)(p13))->addr1, 6);
memcpy(hccap.nonce1, auth2->wpa_nonce,32);
memcpy(hccap.nonce2, auth13->wpa_nonce,32);
memcpy(hccap.keymic, auth2->wpa_keymic, 16);
p = wpa[ess].orig_2;
if (bIsQOS)
p += 2;
p += 8;
p += sizeof(ether_frame_hdr_t);
auth2 = (ether_auto_802_1x_t*)p;
memset(auth2->wpa_keymic, 0, 16);
hccap.eapol_size = wpa[ess].eapol_sz;
memcpy(hccap.eapol, auth2, hccap.eapol_size);
w = (uint8 *)&hccap;
for (i = 36; i + 3 < sizeof(hccap_t); i += 3)
cp += code_block(&w[i], 1, cp);
cp += code_block(&w[i], 0, cp);
to_compact(gecos, hccap.mac1);
to_dashed(ap_mac, hccap.mac1);
to_dashed(sta_mac, hccap.mac2);
cp += sprintf(cp, ":%s:%s:%s::WPA", ap_mac, sta_mac, gecos);
if (hccap.keyver > 1)
cp += sprintf(cp, "%d", hccap.keyver);
search_len = cp-TmpKey;
cp += sprintf(cp, ":password %sverified:%s", (one_three == 1) ? "not " : "", filename);
if (one_three == 1) {
fprintf (stderr, "unVerified key stored, pending verification");
unVerified[nunVer++] = strdup(TmpKey);
fprintf(stderr, "\n");
return;
} else {
for (i = 0; i < nunVer; ++i) {
if (!strncmp(TmpKey, unVerified[i], search_len)) {
fprintf (stderr, "Key now verified\n");
MEM_FREE(unVerified[i]);
unVerified[i] = unVerified[--nunVer];
break;
}
}
}
fprintf(stderr, "\n");
printf ("%s\n", TmpKey);
fflush(stdout);
}
int main(int argc, char **argv)
{
FILE *in;
int i;
char *base;
if (sizeof(struct ivs2_filehdr) != 2 || sizeof(struct ivs2_pkthdr) != 4 ||
sizeof(struct ivs2_WPA_hdsk) != 356 || sizeof(hccap_t) != 356+36) {
fprintf(stderr, "Internal error: struct sizes wrong.\n");
return 2;
}
if (argc > 1 && !strcmp(argv[1], "-c")) {
ShowIncomplete = 0;
argv[1] = argv[0];
argv++; argc--;
}
while (argc > 2 && !strcmp(argv[1], "-e")) {
argv[1] = argv[0];
argv++; argc--;
ManualBeacon(argv[1]);
argv[1] = argv[0];
argv++; argc--;
}
if (argc < 2)
return !!fprintf(stderr,
"Converts PCAP or IVS2 files to JtR format.\n"
"Supported encapsulations: 802.11, Prism, Radiotap and PPI.\n"
"Usage: %s [-c] [-e essid:bssid [-e ...]] <file[s]>\n"
"\n-c\tShow only complete auths (incomplete ones might be wrong passwords\n"
"\tbut we can crack what passwords were tried).\n"
"-e\tManually add Name:MAC pair(s) in case the file lacks beacons.\n\n",
argv[0]);
for (i = 1; i < argc; i++) {
in = fopen(filename = argv[i], "rb");
if (in) {
if ((base = strrchr(filename, '/')))
filename = ++base;
Process(in);
fclose(in);
} else
fprintf(stderr, "Error, file %s not found\n", argv[i]);
}
return 0;
}
| 29.164875 | 132 | 0.647987 |
461b0e9faf000ce5b13fef8bfe2f2cdbd22a8f42 | 705 | h | C | src/objects/player.h | ForAmir/bongerman | 429b064efbd988d74841e45836823715972d0654 | [
"MIT"
] | 10 | 2017-03-12T15:36:38.000Z | 2020-01-05T15:39:38.000Z | src/objects/player.h | neprune/bongerman | 429b064efbd988d74841e45836823715972d0654 | [
"MIT"
] | null | null | null | src/objects/player.h | neprune/bongerman | 429b064efbd988d74841e45836823715972d0654 | [
"MIT"
] | 3 | 2016-10-25T13:50:15.000Z | 2020-10-21T12:17:40.000Z | #ifndef PLAYER_H
#define PLAYER_H
#include <stdbool.h>
#include "position.h"
#include "bomb.h"
#include "direction.h"
#define DEFAULT_MOVE_SPEED 2
#define DEFAULT_DIRECTION DIRECTION_DOWN
#define DEFAULT_MAX_BOMBS 1
typedef enum {
PLAYER_ONE = 0,
PLAYER_TWO = 1,
PLAYER_THREE = 2,
PLAYER_FOUR = 3,
PLAYER_NONE
} player_id;
typedef struct {
player_id id;
bool alive;
Position tile_position;
Position screen_position;
Bomb bomb;
bool moving;
int8_t move_speed;
direction move_direction;
bool plant_bomb;
int8_t max_bomb_number;
int8_t current_bomb_number;
uint8_t current_frame;
uint8_t number_of_wins;
} Player;
#endif
| 16.395349 | 40 | 0.706383 |
cc5879451d13a89a044777806dd9e4cdb4610f15 | 532 | h | C | System/Library/Assistant/Plugins/ClientFlowService.assistantBundle/CFLogQueuer.h | lechium/tvOS10Headers | f0c99993da6cc502d36fdc5cb4ff90d94b12bf67 | [
"MIT"
] | 4 | 2017-03-23T00:01:54.000Z | 2018-08-04T20:16:32.000Z | System/Library/Assistant/Plugins/ClientFlowService.assistantBundle/CFLogQueuer.h | lechium/tvOS10Headers | f0c99993da6cc502d36fdc5cb4ff90d94b12bf67 | [
"MIT"
] | null | null | null | System/Library/Assistant/Plugins/ClientFlowService.assistantBundle/CFLogQueuer.h | lechium/tvOS10Headers | f0c99993da6cc502d36fdc5cb4ff90d94b12bf67 | [
"MIT"
] | 4 | 2017-05-14T16:23:26.000Z | 2019-12-21T15:07:59.000Z | /*
* This header is generated by classdump-dyld 1.0
* on Wednesday, March 22, 2017 at 9:08:58 AM Mountain Standard Time
* Operating System: Version 10.1 (Build 14U593)
* Image Source: /System/Library/Assistant/Plugins/ClientFlowService.assistantBundle/ClientFlowService
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos.
*/
@class NSMutableArray;
@interface CFLogQueuer : NSObject {
NSMutableArray* logQueue;
}
-(id)init;
-(void)addLogMessage:(id)arg1 ;
-(id)queuedLogs;
-(void)clearLogs;
@end
| 23.130435 | 101 | 0.759398 |
4a0c7c09a4ba6a369750f72bd57868337dc217d0 | 359 | h | C | Classes/TeamEliminatedCondition.h | shenkevin/FlameDragon | 02f86da70f1429410160ce55ebbeb3e9c59631d3 | [
"MIT"
] | 1 | 2022-02-26T04:56:40.000Z | 2022-02-26T04:56:40.000Z | Classes/TeamEliminatedCondition.h | shenkevin/FlameDragon | 02f86da70f1429410160ce55ebbeb3e9c59631d3 | [
"MIT"
] | null | null | null | Classes/TeamEliminatedCondition.h | shenkevin/FlameDragon | 02f86da70f1429410160ce55ebbeb3e9c59631d3 | [
"MIT"
] | null | null | null | //
// TeamEliminatedCondition.h
// FlameDragon
//
// Created by sui toney on 12-1-20.
// Copyright 2012 ms. All rights reserved.
//
#import "cocos2d.h"
#import "FDEventCondition.h"
#import "FDCreature.h"
@interface TeamEliminatedCondition : FDEventCondition {
CreatureType teamType;
int previousCount;
}
-(id) initWithTeam:(CreatureType)t;
@end
| 15.608696 | 55 | 0.721448 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.