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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
06544780bbd1b320e53afff5c035bffb968d03a1 | 31,890 | c | C | ngx_http_json_var_module.c | RekGRpth/ngx_http_json_var_module | 384323caa04cff932ea731f386c8a16cb79bedca | [
"MIT"
] | null | null | null | ngx_http_json_var_module.c | RekGRpth/ngx_http_json_var_module | 384323caa04cff932ea731f386c8a16cb79bedca | [
"MIT"
] | null | null | null | ngx_http_json_var_module.c | RekGRpth/ngx_http_json_var_module | 384323caa04cff932ea731f386c8a16cb79bedca | [
"MIT"
] | null | null | null | #include <ngx_http.h>
ngx_module_t ngx_http_json_var_module;
typedef struct {
ngx_array_t *fields;
ngx_flag_t enable;
} ngx_http_json_var_loc_conf_t;
typedef struct {
ngx_flag_t enable;
} ngx_http_json_var_main_conf_t;
typedef struct {
ngx_flag_t done;
ngx_flag_t waiting_more_body;
} ngx_http_json_var_ctx_t;
typedef struct {
ngx_http_complex_value_t cv;
ngx_str_t name;
ngx_uint_t index;
ngx_uint_t json;
} ngx_http_json_var_field_t;
typedef struct {
ngx_str_t key;
ngx_array_t value;
} ngx_http_json_var_key_value_t;
static ngx_str_t *ngx_http_json_var_value(ngx_http_request_t *r, ngx_array_t *array, ngx_str_t *key) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s", __func__);
ngx_http_json_var_key_value_t *elts = array->elts;
ngx_uint_t j;
for (j = 0; j < array->nelts; j++) if (key->len == elts[j].key.len && !ngx_strncasecmp(key->data, elts[j].key.data, key->len)) { elts = &elts[j]; break; }
if (j == array->nelts) elts = NULL;
if (!elts) {
if (!(elts = ngx_array_push(array))) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_array_push"); return NULL; }
ngx_memzero(elts, sizeof(*elts));
}
if (!elts->value.elts && ngx_array_init(&elts->value, r->pool, 1, sizeof(ngx_str_t)) != NGX_OK) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "ngx_array_init != NGX_OK"); return NULL; }
ngx_str_t *value = ngx_array_push(&elts->value);
if (!value) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_array_push"); return NULL; }
elts->key = *key;
return value;
}
static ngx_array_t *ngx_http_json_var_headers_array(ngx_http_request_t *r, ngx_list_part_t *part) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s", __func__);
ngx_array_t *array = ngx_array_create(r->pool, 1, sizeof(ngx_http_json_var_key_value_t));
if (!array) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_array_create"); return NULL; }
for (; part; part = part->next) {
ngx_table_elt_t *elts = part->elts;
for (ngx_uint_t i = 0; i < part->nelts; i++) {
if (!elts[i].key.len) continue;
if (!elts[i].value.len) continue;
ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "elts[%i] = %V:%V", i, &elts[i].key, &elts[i].value);
ngx_str_t *value = ngx_http_json_var_value(r, array, &elts[i].key);
if (!value) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_http_json_var_value"); return NULL; }
*value = elts[i].value;
}
}
return array;
}
static size_t ngx_http_json_var_array_len(ngx_http_request_t *r, ngx_array_t *array) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s", __func__);
size_t len = 0;
ngx_http_json_var_key_value_t *elts = array->elts;
for (ngx_uint_t i = 0; i < array->nelts; i++) {
if (i) len += sizeof(",") - 1;
len += sizeof("\"\":") - 1 + elts[i].key.len + ngx_escape_json(NULL, elts[i].key.data, elts[i].key.len);
ngx_str_t *value = elts[i].value.elts;
switch (elts[i].value.nelts) {
case 1: {
if (!value[0].data) len += sizeof("null") - 1;
else len += sizeof("\"\"") - 1 + value[0].len + ngx_escape_json(NULL, value[0].data, value[0].len);
} break;
default: {
len += sizeof("[]") - 1;
for (ngx_uint_t j = 0; j < elts[i].value.nelts; j++) {
if (j) len += sizeof(",") - 1;
if (!value[j].data) len += sizeof("null") - 1;
else len += sizeof("\"\"") - 1 + value[j].len + ngx_escape_json(NULL, value[j].data, value[j].len);
}
} break;
}
}
return len;
}
static u_char *ngx_http_json_var_array_data(ngx_http_request_t *r, ngx_array_t *array, u_char *p) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s", __func__);
*p++ = '{';
ngx_http_json_var_key_value_t *elts = array->elts;
for (ngx_uint_t i = 0; i < array->nelts; i++) {
if (i) *p++ = ',';
*p++ = '"';
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "elts[%i].key = %V", i, &elts[i].key);
p = (u_char *)ngx_escape_json(p, elts[i].key.data, elts[i].key.len);
*p++ = '"'; *p++ = ':';
ngx_str_t *value = elts[i].value.elts;
switch (elts[i].value.nelts) {
case 1: {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "value = %V", &value[0]);
if (!value[0].data) p = ngx_copy(p, "null", sizeof("null") - 1); else {
*p++ = '"';
p = (u_char *)ngx_escape_json(p, value[0].data, value[0].len);
*p++ = '"';
}
} break;
default: {
*p++ = '[';
for (ngx_uint_t j = 0; j < elts[i].value.nelts; j++) {
if (j) *p++ = ',';
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "value[%i] = %V", j, &value[j]);
if (!value[j].data) p = ngx_copy(p, "null", sizeof("null") - 1); else {
*p++ = '"';
p = (u_char *)ngx_escape_json(p, value[j].data, value[j].len);
*p++ = '"';
}
}
*p++ = ']';
} break;
}
}
*p++ = '}';
return p;
}
static ngx_int_t ngx_http_json_var_response_headers(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s", __func__);
ngx_array_t *array = ngx_http_json_var_headers_array(r, &r->headers_out.headers.part);
if (!array) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_http_json_var_headers_array"); return NGX_ERROR; }
if (!r->headers_out.date) {
ngx_str_t key = ngx_string("Date");
ngx_str_t *value = ngx_http_json_var_value(r, array, &key);
if (!value) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_http_json_var_value"); return NGX_ERROR; }
*value = ngx_cached_http_time;
}
if (r->headers_out.content_type.len) {
ngx_str_t key = ngx_string("Content-Type");
ngx_str_t *value = ngx_http_json_var_value(r, array, &key);
if (!value) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_http_json_var_value"); return NGX_ERROR; }
*value = r->headers_out.content_type;
}
if (!(v->len = ngx_http_json_var_array_len(r, array))) { ngx_str_set(v, "null"); return NGX_OK; }
v->len += sizeof("{}") - 1;
if (!(v->data = ngx_pnalloc(r->pool, v->len))) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_pnalloc"); return NGX_ERROR; }
if (ngx_http_json_var_array_data(r, array, v->data) != v->data + v->len) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "ngx_http_json_var_array_data != v->data + v->len"); return NGX_ERROR; }
v->valid = 1;
v->no_cacheable = 0;
v->not_found = 0;
return NGX_OK;
}
static ngx_int_t ngx_http_json_var_headers(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s", __func__);
ngx_array_t *array = ngx_http_json_var_headers_array(r, &r->headers_in.headers.part);
if (!array) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_http_json_var_headers_array"); return NGX_ERROR; }
if (!(v->len = ngx_http_json_var_array_len(r, array))) { ngx_str_set(v, "null"); return NGX_OK; }
v->len += sizeof("{}") - 1;
if (!(v->data = ngx_pnalloc(r->pool, v->len))) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_pnalloc"); return NGX_ERROR; }
if (ngx_http_json_var_array_data(r, array, v->data) != v->data + v->len) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "ngx_http_json_var_array_data != v->data + v->len"); return NGX_ERROR; }
v->valid = 1;
v->no_cacheable = 0;
v->not_found = 0;
return NGX_OK;
}
static ngx_array_t *ngx_http_json_var_cookies_array(ngx_http_request_t *r) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s", __func__);
ngx_array_t *array = ngx_array_create(r->pool, 1, sizeof(ngx_http_json_var_key_value_t));
if (!array) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_array_create"); return NULL; }
ngx_table_elt_t **elts = r->headers_in.cookies.elts;
for (ngx_uint_t i = 0; i < r->headers_in.cookies.nelts; i++) {
if (!elts[i]->value.len) continue;
ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "elts[%i] = %V:%V", i, &elts[i]->key, &elts[i]->value);
for (u_char *start = elts[i]->value.data, *end = elts[i]->value.data + elts[i]->value.len; start < end; ) {
ngx_str_t key;
for (key.data = start; start < end && *start != '='; start++);
key.len = start - key.data;
start++;
ngx_str_t *value = ngx_http_json_var_value(r, array, &key);
if (!value) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_http_json_var_value"); return NULL; }
for (value->data = start; start < end && *start != ';'; start++);
value->len = start - value->data;
start++;
}
}
return array;
}
static ngx_int_t ngx_http_json_var_cookies(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s", __func__);
ngx_array_t *array = ngx_http_json_var_cookies_array(r);
if (!array) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_http_json_var_cookies_array"); return NGX_ERROR; }
if (!(v->len = ngx_http_json_var_array_len(r, array))) { ngx_str_set(v, "null"); return NGX_OK; }
v->len += sizeof("{}") - 1;
if (!(v->data = ngx_pnalloc(r->pool, v->len))) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_pnalloc"); return NGX_ERROR; }
if (ngx_http_json_var_array_data(r, array, v->data) != v->data + v->len) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "ngx_http_json_var_array_data != v->data + v->len"); return NGX_ERROR; }
v->valid = 1;
v->no_cacheable = 0;
v->not_found = 0;
return NGX_OK;
}
static ngx_array_t *ngx_http_json_var_get_vars_array(ngx_http_request_t *r, u_char *start, u_char *end, ngx_array_t *array) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s", __func__);
if (!array && !(array = ngx_array_create(r->pool, 1, sizeof(ngx_http_json_var_key_value_t)))) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_array_create"); return NULL; }
while (start < end) {
for (; start < end && (*start == '=' || *start == '&'); start++);
ngx_str_t key;
for (key.data = start; start < end && *start != '=' && *start != '&'; start++);
key.len = start - key.data;
u_char *src = key.data;
u_char *dst = ngx_pnalloc(r->pool, key.len);
if (!dst) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_pnalloc"); return NULL; }
ngx_memcpy(dst, key.data, key.len);
key.data = dst;
ngx_unescape_uri(&dst, &src, key.len, NGX_UNESCAPE_URI);
key.len = dst - key.data;
ngx_str_t *value = ngx_http_json_var_value(r, array, &key);
if (!value) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_http_json_var_value"); return NULL; }
ngx_str_null(value);
if (start < end && *start++ != '&') {
for (value->data = start; start < end && *start != '&'; start++);
value->len = start - value->data;
src = value->data;
dst = ngx_pnalloc(r->pool, value->len);
if (!dst) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_pnalloc"); return NULL; }
ngx_memcpy(dst, value->data, value->len);
value->data = dst;
ngx_unescape_uri(&dst, &src, value->len, NGX_UNESCAPE_URI);
value->len = dst - value->data;
}
}
return array;
}
static ngx_int_t ngx_http_json_var_get_vars(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s", __func__);
ngx_array_t *array = ngx_http_json_var_get_vars_array(r, r->args.data, r->args.data + r->args.len, NULL);
if (!array) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_http_json_var_get_vars_array"); return NGX_ERROR; }
if (!(v->len = ngx_http_json_var_array_len(r, array))) { ngx_str_set(v, "null"); return NGX_OK; }
v->len += sizeof("{}") - 1;
if (!(v->data = ngx_pnalloc(r->pool, v->len))) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_pnalloc"); return NGX_ERROR; }
if (ngx_http_json_var_array_data(r, array, v->data) != v->data + v->len) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "ngx_http_json_var_array_data != v->data + v->len"); return NGX_ERROR; }
v->valid = 1;
v->no_cacheable = 0;
v->not_found = 0;
return NGX_OK;
}
static ngx_array_t *ngx_http_json_var_post_vars_array(ngx_http_request_t *r, ngx_str_t *boundary, u_char *start, u_char *end, ngx_array_t *array) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s", __func__);
if (!array && !(array = ngx_array_create(r->pool, 1, sizeof(ngx_http_json_var_key_value_t)))) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_array_create"); return NULL; }
for (u_char *val; start < end; start += 2) {
if (ngx_strncmp(start, boundary->data + 2, boundary->len - 2)) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "ngx_strncmp"); return NULL; }
start += boundary->len - 2;
if (ngx_strncmp(start, (u_char *)"\r\nContent-Disposition: form-data; name=\"=", sizeof("\r\nContent-Disposition: form-data; name=\"") - 1)) break;
start += sizeof("\r\nContent-Disposition: form-data; name=\"") - 1;
ngx_str_t key;
if ((val = ngx_strstrn(start, "\";", sizeof("\";") - 1 - 1))) {
key.len = val - start;
key.data = start;
if (!(val = ngx_strstrn(start, "\r\n\r\n", sizeof("\r\n\r\n") - 1 - 1))) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_strstrn"); return NULL; }
val += sizeof("\r\n\r\n") - 1;
} else if ((val = ngx_strstrn(start, "\"\r\n\r\n", sizeof("\"\r\n\r\n") - 1 - 1))) {
key.len = val - start;
key.data = start;
val += sizeof("\"\r\n\r\n") - 1;
} else { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_strstrn"); return NULL; }
ngx_str_t *value = ngx_http_json_var_value(r, array, &key);
if (!value) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_http_json_var_value"); return NULL; }
if (!(start = ngx_strstrn(val, (char *)boundary->data, boundary->len - 1))) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_strstrn"); return NULL; }
value->data = val;
value->len = start - val;
}
return array;
}
static ngx_buf_t *ngx_http_json_var_read_request_body_to_buffer(ngx_http_request_t *r) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s", __func__);
if (!r->request_body) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!r->request_body"); return NULL; }
ngx_buf_t *buf = ngx_create_temp_buf(r->pool, r->headers_in.content_length_n + 1);
if (!buf) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_create_temp_buf"); return NULL; }
buf->memory = 1;
buf->temporary = 0;
ngx_memset(buf->start, '\0', r->headers_in.content_length_n + 1);
for (ngx_chain_t *chain = r->request_body->bufs; chain && chain->buf; chain = chain->next) {
off_t len = ngx_buf_size(chain->buf);
if (len >= r->headers_in.content_length_n) {
buf->start = buf->pos;
buf->last = buf->pos;
len = r->headers_in.content_length_n;
}
if (chain->buf->in_file) {
ssize_t n = ngx_read_file(chain->buf->file, buf->start, len, 0);
if (n == NGX_FILE_ERROR) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "ngx_read_file == NGX_FILE_ERROR"); return NULL; }
buf->last = buf->last + len;
ngx_delete_file(chain->buf->file->name.data);
chain->buf->file->fd = NGX_INVALID_FILE;
} else {
buf->last = ngx_copy(buf->start, chain->buf->pos, len);
}
buf->start = buf->last;
}
return buf;
}
static ngx_int_t ngx_http_json_var_post_vars(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s", __func__);
if (r->headers_in.content_length_n <= 0) { ngx_str_set(v, "null"); return NGX_OK; }
ngx_buf_t *buf = ngx_http_json_var_read_request_body_to_buffer(r);
if (!buf) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_http_json_var_read_request_body_to_buffer"); return NGX_ERROR; }
if (!r->headers_in.content_type) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!r->headers_in.content_type"); return NGX_ERROR; }
if (r->headers_in.content_type->value.len == sizeof("application/x-www-form-urlencoded") - 1 && !ngx_strncasecmp(r->headers_in.content_type->value.data, (u_char *)"application/x-www-form-urlencoded", sizeof("application/x-www-form-urlencoded") - 1)) {
ngx_array_t *array = ngx_http_json_var_get_vars_array(r, buf->pos, buf->last, NULL);
if (!array) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_http_json_var_get_vars_array"); return NGX_ERROR; }
if (!(v->len = ngx_http_json_var_array_len(r, array))) { ngx_str_set(v, "null"); return NGX_OK; }
v->len += sizeof("{}") - 1;
if (!(v->data = ngx_pnalloc(r->pool, v->len))) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_pnalloc"); return NGX_ERROR; }
if (ngx_http_json_var_array_data(r, array, v->data) != v->data + v->len) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "ngx_http_json_var_array_data != v->data + v->len"); return NGX_ERROR; }
} else if (r->headers_in.content_type->value.len >= sizeof("application/json") - 1 && !ngx_strncasecmp(r->headers_in.content_type->value.data, (u_char *)"application/json", sizeof("application/json") - 1)) {
v->len = ngx_buf_size(buf);
if (!(v->data = ngx_pnalloc(r->pool, v->len))) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_pnalloc"); return NGX_ERROR; }
if (ngx_copy(v->data, buf->pos, v->len) != v->data + v->len) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "ngx_copy != v->data + v->len"); return NGX_ERROR; }
} else if (r->headers_in.content_type->value.len > sizeof("multipart/form-data") - 1 && !ngx_strncasecmp(r->headers_in.content_type->value.data, (u_char *)"multipart/form-data", sizeof("multipart/form-data") - 1)) {
if (ngx_strncmp(r->headers_in.content_type->value.data, (u_char *)"multipart/form-data; boundary=", sizeof("multipart/form-data; boundary=") - 1)) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "ngx_strncmp"); return NGX_ERROR; }
size_t boundary_len = r->headers_in.content_type->value.len - (sizeof("multipart/form-data; boundary=") - 1);
u_char *boundary_data = ngx_pnalloc(r->pool, boundary_len + 4);
if (!boundary_data) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_pnalloc"); return NGX_ERROR; }
ngx_memcpy(boundary_data, "\r\n--", sizeof("\r\n--") - 1);
ngx_memcpy(boundary_data + 4, r->headers_in.content_type->value.data + sizeof("multipart/form-data; boundary=") - 1, boundary_len);
boundary_len += 4;
ngx_str_t boundary = {boundary_len, boundary_data};
ngx_array_t *array = ngx_http_json_var_post_vars_array(r, &boundary, buf->pos, buf->last, NULL);
if (!array) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_http_json_var_post_vars_array"); return NGX_ERROR; }
if (!(v->len = ngx_http_json_var_array_len(r, array))) { ngx_str_set(v, "null"); return NGX_OK; }
v->len += sizeof("{}") - 1;
if (!(v->data = ngx_pnalloc(r->pool, v->len))) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_pnalloc"); return NGX_ERROR; }
if (ngx_http_json_var_array_data(r, array, v->data) != v->data + v->len) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "ngx_http_json_var_array_data != v->data + v->len"); return NGX_ERROR; }
} else { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "unsupported content type %V", &r->headers_in.content_type->value); ngx_str_set(v, "{}"); }
v->valid = 1;
v->no_cacheable = 0;
v->not_found = 0;
return NGX_OK;
}
static ngx_http_variable_t ngx_http_json_var_variables[] = {
{ ngx_string("json_response_headers"), NULL, ngx_http_json_var_response_headers, 0, NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_CHANGEABLE, 0 },
{ ngx_string("json_headers"), NULL, ngx_http_json_var_headers, 0, NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_CHANGEABLE, 0 },
{ ngx_string("json_cookies"), NULL, ngx_http_json_var_cookies, 0, NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_CHANGEABLE, 0 },
{ ngx_string("json_get_vars"), NULL, ngx_http_json_var_get_vars, 0, NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_CHANGEABLE, 0 },
{ ngx_string("json_post_vars"), NULL, ngx_http_json_var_post_vars, 0, NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_CHANGEABLE, 0 },
ngx_http_null_variable
};
static ngx_int_t ngx_http_json_var_preconfiguration(ngx_conf_t *cf) {
for (ngx_http_variable_t *v = ngx_http_json_var_variables; v->name.len; v++) {
ngx_http_variable_t *var = ngx_http_add_variable(cf, &v->name, v->flags);
if (!var) return NGX_ERROR;
*var = *v;
if (var->get_handler == ngx_http_json_var_post_vars) {
ngx_http_json_var_main_conf_t *hjmc = ngx_http_conf_get_module_main_conf(cf, ngx_http_json_var_module);
hjmc->enable = 1;
}
}
return NGX_OK;
}
static void ngx_http_json_var_post_read(ngx_http_request_t *r) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s", __func__);
ngx_http_json_var_ctx_t *ctx = ngx_http_get_module_ctx(r, ngx_http_json_var_module);
ctx->done = 1;
r->main->count--;
if (ctx->waiting_more_body) { ctx->waiting_more_body = 0; ngx_http_core_run_phases(r); }
}
static ngx_int_t ngx_http_json_var_handler(ngx_http_request_t *r) {
ngx_http_json_var_loc_conf_t *hjlc = ngx_http_get_module_loc_conf(r, ngx_http_json_var_module);
if (!hjlc->enable) return NGX_DECLINED;
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s", __func__);
ngx_http_json_var_ctx_t *ctx = ngx_http_get_module_ctx(r, ngx_http_json_var_module);
if (ctx) {
if (ctx->done) { ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "ctx->done"); return NGX_DECLINED; }
return NGX_DONE;
}
if (r->headers_in.content_type == NULL || r->headers_in.content_type->value.data == NULL) return NGX_DECLINED;
if (!(ctx = ngx_pcalloc(r->pool, sizeof(*ctx)))) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_pcalloc"); return NGX_ERROR; }
ngx_http_set_ctx(r, ctx, ngx_http_json_var_module);
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "start to read client request body");
ngx_int_t rc = ngx_http_read_client_request_body(r, ngx_http_json_var_post_read);
if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "ngx_http_read_client_request_body = %i", rc); return rc; }
if (rc == NGX_AGAIN) { ctx->waiting_more_body = 1; return NGX_DONE; }
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "has read the request body in one run");
return NGX_DECLINED;
}
static ngx_int_t ngx_http_json_var_postconfiguration(ngx_conf_t *cf) {
ngx_http_json_var_main_conf_t *hjmc = ngx_http_conf_get_module_main_conf(cf, ngx_http_json_var_module);
if (!hjmc->enable) return NGX_OK;
ngx_http_core_main_conf_t *core_main_conf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
ngx_http_handler_pt *handler = ngx_array_push(&core_main_conf->phases[NGX_HTTP_REWRITE_PHASE].handlers);
if (!handler) return NGX_ERROR;
*handler = ngx_http_json_var_handler;
ngx_http_core_loc_conf_t *core_loc_conf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
core_loc_conf->client_body_in_single_buffer = 1;
return NGX_OK;
}
static size_t ngx_http_json_var_len(ngx_http_request_t *r, ngx_array_t *fields) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s", __func__);
size_t len = 0;
ngx_http_json_var_field_t *args = fields->elts;
for (ngx_uint_t i = 0; i < fields->nelts; i++) {
if (!args[i].name.len) continue;
ngx_str_t value;
if (ngx_http_complex_value(r, &args[i].cv, &value) != NGX_OK) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "ngx_http_complex_value != NGX_OK"); return NGX_ERROR; }
if (!value.len) continue;
if (len) len++;
len += sizeof("\"\":") - 1 + args[i].name.len;
if (args[i].json) len += value.len;
else len += sizeof("\"\"") - 1 + value.len + ngx_escape_json(NULL, value.data, value.len);
}
len += sizeof("{}") - 1;
return len;
}
static u_char *ngx_http_json_var_data(ngx_http_request_t *r, u_char *p, ngx_array_t *fields) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s", __func__);
*p++ = '{';
u_char *var = p;
ngx_http_json_var_field_t *args = fields->elts;
for (ngx_uint_t i = 0; i < fields->nelts; i++) {
if (!args[i].name.len) continue;
ngx_str_t value;
if (ngx_http_complex_value(r, &args[i].cv, &value) != NGX_OK) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "ngx_http_complex_value != NGX_OK"); return p; }
if (!value.len) continue;
if (p != var) *p++ = ',';
*p++ = '"';
p = ngx_copy(p, args[i].name.data, args[i].name.len);
*p++ = '"';
*p++ = ':';
if (args[i].json) p = ngx_copy(p, value.data, value.len); else {
*p++ = '"';
if (args[i].json) p = ngx_copy(p, value.data, value.len);
else p = (u_char *)ngx_escape_json(p, value.data, value.len);
*p++ = '"';
}
}
*p++ = '}';
return p;
}
static ngx_int_t ngx_http_json_var_get_handler(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s", __func__);
*v = ngx_http_variable_null_value;
ngx_http_json_var_loc_conf_t *hjlc = ngx_http_get_module_loc_conf(r, ngx_http_json_var_module);
ngx_array_t *fields = hjlc->fields;
if (!fields) { ngx_str_set(v, "null"); return NGX_OK; }
if (!fields->nelts) { ngx_str_set(v, "{}"); return NGX_OK; }
v->len = ngx_http_json_var_len(r, fields);
if (!(v->data = ngx_pnalloc(r->pool, v->len))){ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "!ngx_pnalloc"); return NGX_ERROR; }
if (ngx_http_json_var_data(r, v->data, fields) != v->data + v->len) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "ngx_http_json_var_data != v->data + v->len"); return NGX_ERROR; }
v->valid = 1;
v->no_cacheable = 0;
v->not_found = 0;
return NGX_OK;
}
static char *ngx_http_json_var_conf_handler(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
ngx_str_t *args = cf->args->elts;
if (cf->args->nelts != 2) return "cf->args->nelts != 2";
ngx_http_json_var_loc_conf_t *hjlc = conf;
ngx_http_json_var_field_t *field = ngx_array_push(hjlc->fields);
if (!field) return "!ngx_array_push";
ngx_str_t value = args[1];
field->json = value.data[0] == '$'
&& ((value.len - 1 == sizeof("json_response_headers") - 1 && !ngx_strncasecmp(value.data + 1, (u_char *)"json_response_headers", sizeof("json_response_headers") - 1))
|| (value.len - 1 == sizeof("json_headers") - 1 && !ngx_strncasecmp(value.data + 1, (u_char *)"json_headers", sizeof("json_headers") - 1))
|| (value.len - 1 == sizeof("json_cookies") - 1 && !ngx_strncasecmp(value.data + 1, (u_char *)"json_cookies", sizeof("json_cookies") - 1))
|| (value.len - 1 == sizeof("json_get_vars") - 1 && !ngx_strncasecmp(value.data + 1, (u_char *)"json_get_vars", sizeof("json_get_vars") - 1))
|| (value.len - 1 == sizeof("json_post_vars") - 1 && !ngx_strncasecmp(value.data + 1, (u_char *)"json_post_vars", sizeof("json_post_vars") - 1)));
if (value.data[0] == '$' && value.len - 1 == sizeof("json_post_vars") - 1 && !ngx_strncasecmp(value.data + 1, (u_char *)"json_post_vars", sizeof("json_post_vars") - 1)) hjlc->enable = 1;
ngx_http_compile_complex_value_t ccv = {cf->ctx, &value, &field->cv, 0, 0, 0};
if (ngx_http_compile_complex_value(&ccv) != NGX_OK) return "ngx_http_compile_complex_value != NGX_OK";
field->name = args[0];
return NGX_CONF_OK;
}
static char *ngx_http_json_var_conf(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
ngx_http_json_var_loc_conf_t *hjlc = conf;
if (hjlc->fields) return "is duplicate";
if (!(hjlc->fields = ngx_array_create(cf->pool, 1, sizeof(ngx_http_json_var_field_t)))) return "!ngx_array_create";
ngx_str_t *args = cf->args->elts;
ngx_str_t name = args[1];
if (name.data[0] != '$') return "invalid variable name";
name.len--;
name.data++;
ngx_http_variable_t *var = ngx_http_add_variable(cf, &name, NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_CHANGEABLE);
if (!var) return "!ngx_http_add_variable";
var->get_handler = ngx_http_json_var_get_handler;
ngx_conf_t save = *cf;
cf->ctx = &save;
cf->handler = ngx_http_json_var_conf_handler;
cf->handler_conf = conf;
char *rv = ngx_conf_parse(cf, NULL);
*cf = save;
return rv;
}
static ngx_command_t ngx_http_json_var_commands[] = {
{ ngx_string("json_var"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_BLOCK|NGX_CONF_TAKE1, ngx_http_json_var_conf, NGX_HTTP_LOC_CONF_OFFSET, 0, NULL },
ngx_null_command
};
static void *ngx_http_json_var_create_main_conf(ngx_conf_t *cf) {
ngx_http_json_var_main_conf_t *hjmc = ngx_pcalloc(cf->pool, sizeof(*hjmc));
if (!hjmc) { ngx_log_error(NGX_LOG_EMERG, cf->log, 0, "!ngx_pcalloc"); return NULL; }
return hjmc;
}
static void *ngx_http_json_var_create_loc_conf(ngx_conf_t *cf) {
ngx_http_json_var_loc_conf_t *hjlc = ngx_pcalloc(cf->pool, sizeof(*hjlc));
if (!hjlc) { ngx_log_error(NGX_LOG_EMERG, cf->log, 0, "!ngx_pcalloc"); return NULL; }
hjlc->enable = NGX_CONF_UNSET;
return hjlc;
}
static char *ngx_http_json_var_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) {
ngx_http_json_var_loc_conf_t *prev = parent;
ngx_http_json_var_loc_conf_t *conf = child;
ngx_conf_merge_value(conf->enable, prev->enable, 0);
if (!conf->fields) conf->fields = prev->fields;
return NGX_CONF_OK;
}
static ngx_http_module_t ngx_http_json_var_ctx = {
.preconfiguration = ngx_http_json_var_preconfiguration,
.postconfiguration = ngx_http_json_var_postconfiguration,
.create_main_conf = ngx_http_json_var_create_main_conf,
.init_main_conf = NULL,
.create_srv_conf = NULL,
.merge_srv_conf = NULL,
.create_loc_conf = ngx_http_json_var_create_loc_conf,
.merge_loc_conf = ngx_http_json_var_merge_loc_conf
};
ngx_module_t ngx_http_json_var_module = {
NGX_MODULE_V1,
.ctx = &ngx_http_json_var_ctx,
.commands = ngx_http_json_var_commands,
.type = NGX_HTTP_MODULE,
.init_master = NULL,
.init_module = NULL,
.init_process = NULL,
.init_thread = NULL,
.exit_thread = NULL,
.exit_process = NULL,
.exit_master = NULL,
NGX_MODULE_V1_PADDING
};
| 56.442478 | 255 | 0.647288 |
ff131f666a675e3f8bafcd158ebaf3cbb57ad4a8 | 403 | h | C | include/core/rank_permutation.h | rayastoyanova/ext_mpi_collectives | 9f9e48cf40238d3e91af6471c32f620630365b7d | [
"BSD-3-Clause"
] | null | null | null | include/core/rank_permutation.h | rayastoyanova/ext_mpi_collectives | 9f9e48cf40238d3e91af6471c32f620630365b7d | [
"BSD-3-Clause"
] | null | null | null | include/core/rank_permutation.h | rayastoyanova/ext_mpi_collectives | 9f9e48cf40238d3e91af6471c32f620630365b7d | [
"BSD-3-Clause"
] | null | null | null | #ifndef EXT_MPI_RANK_PERMUTATION_H_
#define EXT_MPI_RANK_PERMUTATION_H_
#ifdef __cplusplus
extern "C"
{
#endif
void ext_mpi_rank_perm_heuristic(int num_nodes, int *node_recvcounts, int *rank_perm);
int ext_mpi_generate_rank_permutation_forward(char *buffer_in, char *buffer_out);
int ext_mpi_generate_rank_permutation_backward(char *buffer_in, char *buffer_out);
#ifdef __cplusplus
}
#endif
#endif
| 21.210526 | 86 | 0.833747 |
9e83e31571668070a31f276ec14cf562435e07a9 | 7,137 | h | C | libraries/shared/src/ShapeCollider.h | judasshuffle/hifi | f6778588914f803f63bd0e965fae9dfcbd22fd6d | [
"Apache-2.0"
] | null | null | null | libraries/shared/src/ShapeCollider.h | judasshuffle/hifi | f6778588914f803f63bd0e965fae9dfcbd22fd6d | [
"Apache-2.0"
] | null | null | null | libraries/shared/src/ShapeCollider.h | judasshuffle/hifi | f6778588914f803f63bd0e965fae9dfcbd22fd6d | [
"Apache-2.0"
] | null | null | null | //
// ShapeCollider.h
// libraries/shared/src
//
// Created by Andrew Meadows on 02/20/2014.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_ShapeCollider_h
#define hifi_ShapeCollider_h
#include "CapsuleShape.h"
#include "CollisionInfo.h"
#include "ListShape.h"
#include "PlaneShape.h"
#include "SharedUtil.h"
#include "SphereShape.h"
namespace ShapeCollider {
/// \param shapeA pointer to first shape
/// \param shapeB pointer to second shape
/// \param collisions[out] collision details
/// \return true if shapes collide
bool collideShapes(const Shape* shapeA, const Shape* shapeB, CollisionList& collisions);
/// \param shapesA list of shapes
/// \param shapeB list of shapes
/// \param collisions[out] average collision details
/// \return true if any shapes collide
bool collideShapesCoarse(const QVector<const Shape*>& shapesA, const QVector<const Shape*>& shapesB, CollisionInfo& collision);
/// \param shapeA a pointer to a shape
/// \param cubeCenter center of cube
/// \param cubeSide lenght of side of cube
/// \param collisions[out] average collision details
/// \return true if shapeA collides with axis aligned cube
bool collideShapeWithAACube(const Shape* shapeA, const glm::vec3& cubeCenter, float cubeSide, CollisionList& collisions);
/// \param sphereA pointer to first shape
/// \param sphereB pointer to second shape
/// \param[out] collisions where to append collision details
/// \return true if shapes collide
bool sphereSphere(const SphereShape* sphereA, const SphereShape* sphereB, CollisionList& collisions);
/// \param sphereA pointer to first shape
/// \param capsuleB pointer to second shape
/// \param[out] collisions where to append collision details
/// \return true if shapes collide
bool sphereCapsule(const SphereShape* sphereA, const CapsuleShape* capsuleB, CollisionList& collisions);
/// \param sphereA pointer to first shape
/// \param planeB pointer to second shape
/// \param[out] collisions where to append collision details
/// \return true if shapes collide
bool spherePlane(const SphereShape* sphereA, const PlaneShape* planeB, CollisionList& collisions);
/// \param capsuleA pointer to first shape
/// \param sphereB pointer to second shape
/// \param[out] collisions where to append collision details
/// \return true if shapes collide
bool capsuleSphere(const CapsuleShape* capsuleA, const SphereShape* sphereB, CollisionList& collisions);
/// \param capsuleA pointer to first shape
/// \param capsuleB pointer to second shape
/// \param[out] collisions where to append collision details
/// \return true if shapes collide
bool capsuleCapsule(const CapsuleShape* capsuleA, const CapsuleShape* capsuleB, CollisionList& collisions);
/// \param capsuleA pointer to first shape
/// \param planeB pointer to second shape
/// \param[out] collisions where to append collision details
/// \return true if shapes collide
bool capsulePlane(const CapsuleShape* capsuleA, const PlaneShape* planeB, CollisionList& collisions);
/// \param planeA pointer to first shape
/// \param sphereB pointer to second shape
/// \param[out] collisions where to append collision details
/// \return true if shapes collide
bool planeSphere(const PlaneShape* planeA, const SphereShape* sphereB, CollisionList& collisions);
/// \param planeA pointer to first shape
/// \param capsuleB pointer to second shape
/// \param[out] collisions where to append collision details
/// \return true if shapes collide
bool planeCapsule(const PlaneShape* planeA, const CapsuleShape* capsuleB, CollisionList& collisions);
/// \param planeA pointer to first shape
/// \param planeB pointer to second shape
/// \param[out] collisions where to append collision details
/// \return true if shapes collide
bool planePlane(const PlaneShape* planeA, const PlaneShape* planeB, CollisionList& collisions);
/// \param sphereA pointer to first shape
/// \param listB pointer to second shape
/// \param[out] collisions where to append collision details
/// \return true if shapes collide
bool sphereList(const SphereShape* sphereA, const ListShape* listB, CollisionList& collisions);
/// \param capuleA pointer to first shape
/// \param listB pointer to second shape
/// \param[out] collisions where to append collision details
/// \return true if shapes collide
bool capsuleList(const CapsuleShape* capsuleA, const ListShape* listB, CollisionList& collisions);
/// \param planeA pointer to first shape
/// \param listB pointer to second shape
/// \param[out] collisions where to append collision details
/// \return true if shapes collide
bool planeList(const PlaneShape* planeA, const ListShape* listB, CollisionList& collisions);
/// \param listA pointer to first shape
/// \param sphereB pointer to second shape
/// \param[out] collisions where to append collision details
/// \return true if shapes collide
bool listSphere(const ListShape* listA, const SphereShape* sphereB, CollisionList& collisions);
/// \param listA pointer to first shape
/// \param capsuleB pointer to second shape
/// \param[out] collisions where to append collision details
/// \return true if shapes collide
bool listCapsule(const ListShape* listA, const CapsuleShape* capsuleB, CollisionList& collisions);
/// \param listA pointer to first shape
/// \param planeB pointer to second shape
/// \param[out] collisions where to append collision details
/// \return true if shapes collide
bool listPlane(const ListShape* listA, const PlaneShape* planeB, CollisionList& collisions);
/// \param listA pointer to first shape
/// \param capsuleB pointer to second shape
/// \param[out] collisions where to append collision details
/// \return true if shapes collide
bool listList(const ListShape* listA, const ListShape* listB, CollisionList& collisions);
/// \param sphereA pointer to sphere
/// \param cubeCenter center of cube
/// \param cubeSide lenght of side of cube
/// \param[out] collisions where to append collision details
/// \return true if sphereA collides with axis aligned cube
bool sphereAACube(const SphereShape* sphereA, const glm::vec3& cubeCenter, float cubeSide, CollisionList& collisions);
/// \param capsuleA pointer to capsule
/// \param cubeCenter center of cube
/// \param cubeSide lenght of side of cube
/// \param[out] collisions where to append collision details
/// \return true if capsuleA collides with axis aligned cube
bool capsuleAACube(const CapsuleShape* capsuleA, const glm::vec3& cubeCenter, float cubeSide, CollisionList& collisions);
} // namespace ShapeCollider
#endif // hifi_ShapeCollider_h
| 45.75 | 131 | 0.71893 |
fa240c7c4320b192fafcbcea4686f6bbda53c37e | 9,998 | h | C | groups/bsl/bslmf/bslmf_metaint.h | adambde/bde | a2efe118da642be42b25e81ca986a0fe56078305 | [
"Apache-2.0"
] | 26 | 2015-05-07T04:22:06.000Z | 2022-01-26T09:10:12.000Z | groups/bsl/bslmf/bslmf_metaint.h | adambde/bde | a2efe118da642be42b25e81ca986a0fe56078305 | [
"Apache-2.0"
] | 3 | 2015-05-07T21:06:36.000Z | 2015-08-28T20:02:18.000Z | groups/bsl/bslmf/bslmf_metaint.h | adambde/bde | a2efe118da642be42b25e81ca986a0fe56078305 | [
"Apache-2.0"
] | 12 | 2015-05-06T08:41:07.000Z | 2021-11-09T12:52:19.000Z | // bslmf_metaint.h -*-C++-*-
#ifndef INCLUDED_BSLMF_METAINT
#define INCLUDED_BSLMF_METAINT
#ifndef INCLUDED_BSLS_IDENT
#include <bsls_ident.h>
#endif
BSLS_IDENT("$Id: $")
//@PURPOSE: Provide a meta-function to map integral constants to unique types.
//
//@DEPRECATED: Use 'bslmf_integralconstant' instead.
//
//@CLASSES:
// bslmf::MetaInt: meta-function mapping integral constants to C++ types
//
//@DESCRIPTION: This component defines a simple template structure used to map
// an integral constant to a C++ type. 'bslmf::MetaInt<int>' defines a
// different type for each distinct compile-time constant integral parameter.
// That is, instantiations with different integer values form distinct types,
// so that 'bslmf::MetaInt<0>' is a distinct type from 'bslmf::MetaInt<1>',
// which is also distinct from 'bslmf::MetaInt<2>', and so on.
//
///Usage
///-----
// This section illustrates intended usage of this component
//
///Example 1: Compile-Time Function Dispatching
/// - - - - - - - - - - - - - - - - - - - - - -
// The most common use of this structure is to perform static function
// dispatching based on a compile-time calculation. Often the calculation is
// nothing more than a simple predicate, allowing us to select one of two
// functions. The following function, 'doSomething', uses a fast
// implementation (e.g., 'memcpy') if the parameterized type allows for such
// operations, otherwise it will use a more generic and slower implementation
// (e.g., copy constructor).
//..
// template <class T>
// void doSomethingImp(T *t, bslmf::MetaInt<0>)
// {
// // slow generic implementation
// (void) t;
// // ...
// }
//
// template <class T>
// void doSomethingImp(T *t, bslmf::MetaInt<1>)
// {
// // fast implementation (works only for some T's)
// (void) t;
// // ...
// }
//
// template <class T, bool IsFast>
// void doSomething(T *t)
// {
// doSomethingImp(t, bslmf::MetaInt<IsFast>());
// }
//..
// The power of this approach is that the compiler will compile only the
// implementation selected by the 'MetaInt' argument. For some parameter
// types, the fast version of 'doSomethingImp' would be ill-formed. This kind
// of compile-time dispatch prevents the ill-formed version from ever being
// instantiated.
//..
// int main()
// {
// int i;
// doSomething<int, true>(&i); // fast version selected for int
//
// double m;
// doSomething<double, false>(&m); // slow version selected for double
//
// return 0;
// }
//..
///Example 2: Reading the 'VALUE' member
/// - - - - - - - - - - - - - - - - - -
// In addition to forming new types, the value of the integral paramameter to
// 'MetaInt' is "saved" in the enum member 'VALUE', and is accessible for use
// in compile-time or run-time operations.
//..
// template <int V>
// unsigned g()
// {
// bslmf::MetaInt<V> i;
// assert(V == i.VALUE);
// assert(V == bslmf::MetaInt<V>::VALUE);
// return bslmf::MetaInt<V>::VALUE;
// }
//
// int main()
// {
// int v = g<1>();
// assert(1 == v);
// return 0;
// }
//..
#ifndef INCLUDED_BSLSCM_VERSION
#include <bslscm_version.h>
#endif
#ifndef INCLUDED_BSLMF_INTEGRALCONSTANT
#include <bslmf_integralconstant.h>
#endif
#ifndef INCLUDED_BSLMF_TAG
#include <bslmf_tag.h>
#endif
#ifndef INCLUDED_BSLS_COMPILERFEATURES
#include <bsls_compilerfeatures.h>
#endif
namespace BloombergLP {
namespace bslmf {
// ==============
// struct MetaInt
// ==============
template <int INT_VALUE>
struct MetaInt : public bsl::integral_constant<int, INT_VALUE> {
// Instantiating this template produces a distinct type for each
// non-negative integer value. This template has been deprecated in favor
// of the standard 'integral_constant' template.
#if defined(BSLS_COMPILERFEATURES_SUPPORT_STATIC_ASSERT)
static_assert(INT_VALUE >= 0, "INT_VALUE must be non-negative");
#endif
// TYPES
typedef MetaInt<INT_VALUE> Type;
typedef bslmf::Tag<INT_VALUE> Tag;
enum { VALUE = INT_VALUE };
// CREATORS
MetaInt();
// Does nothing ('MetaInt' is stateless).
MetaInt(bsl::integral_constant<int, INT_VALUE>); // IMPLICIT
// Convert from a 'bsl::integral_constant<int, INT_VALUE>'.
//! MetaInt(const MetaInt&) = default;
//! MetaInt& operator=(const MetaInt&) = default;
//! ~MetaInt() = default;
// CLASS METHODS
static Tag& tag();
// Declared but not defined. Meta-function use only. The tag can be
// used to recover meta-information from an expression. Example:
// 'sizeof(f(expr).tag())' returns a different compile-time value
// depending on the type of the result of calling the 'f' function but
// does not actually call the 'f' function or the 'tag' method at
// run-time. Note that 'f(expr)::VALUE' or 'sizeof(f(expr)::Type)'
// would be ill-formed and that 'f(expr).value' is not a compile-time
// expression.
};
template <>
struct MetaInt<0> : public bsl::false_type {
// This specialization of 'MetaInt' has a 'VAL' of zero and is convertible
// to and from 'bsl::false_type'.
// TYPES
typedef MetaInt<0> Type;
typedef bslmf::Tag<0> Tag;
enum { VALUE = 0 };
// CREATORS
MetaInt();
// Does nothing ('MetaInt' is stateless).
MetaInt(bsl::false_type); // IMPLICIT
// Convert from a 'bsl::false_type'.
//! MetaInt(const MetaInt&) = default;
//! MetaInt& operator=(const MetaInt&) = default;
//! ~MetaInt() = default;
// CLASS METHODS
static Tag& tag();
// Declared but not defined. Meta-function use only. The tag can be
// used to recover meta-information from an expression. Example:
// 'sizeof(f(expr).tag())' returns a different compile-time value
// depending on the type of the result of calling the 'f' function but
// does not actually call the 'f' function or the 'tag' method at
// run-time. Note that 'f(expr)::VALUE' or 'sizeof(f(expr)::Type)'
// would be ill-formed and that 'f(expr).value' is not a compile-time
// expression.
// ACCESSORS
operator bool() const;
// Return 'false'. (This operator is conversion operator to 'bool'.)
};
template <>
struct MetaInt<1> : public bsl::true_type {
// This specialization of 'MetaInt' has a 'VAL' of one and is convertible
// to and from 'bsl::true_type'.
// TYPES
typedef MetaInt<1> Type;
typedef bslmf::Tag<1> Tag;
enum { VALUE = 1 };
// CREATORS
MetaInt();
// Does nothing ('MetaInt' is stateless).
MetaInt(bsl::true_type); // IMPLICIT
// Convert from a 'bsl::true_type'.
//! MetaInt(const MetaInt&) = default;
//! MetaInt& operator=(const MetaInt&) = default;
//! ~MetaInt() = default;
// CLASS METHODS
static Tag& tag();
// Declared but not defined. Meta-function use only. The tag can be
// used to recover meta-information from an expression. Example:
// 'sizeof(f(expr).tag())' returns a different compile-time value
// depending on the type of the result of calling the 'f' function but
// does not actually call the 'f' function or the 'tag' method at
// run-time. Note that 'f(expr)::VALUE' or 'sizeof(f(expr)::Type)'
// would be ill-formed and that 'f(expr).value' is not a compile-time
// expression.
// ACCESSORS
operator bool() const;
// Return 'true'. (This operator is conversion operator to 'bool'.)
};
#define BSLMF_METAINT_TO_INT(expr) BSLMF_TAG_TO_INT((expr).tag())
// Given an integral value, 'V', and an expression, 'expr', of type
// 'bslmf::MetaInt<V>', this macro returns a compile-time constant with
// value, 'V'. The expression, 'expr', is not evaluated at run-time.
#define BSLMF_METAINT_TO_BOOL(expr) BSLMF_TAG_TO_BOOL((expr).tag())
// Given an integral value, 'V', and an expression, 'expr', of type
// 'bslmf::MetaInt<V>', this macro returns a compile-time constant with
// value, 'true' or 'false', according to the Boolean value of 'V'. The
// expression, 'expr', is not evaluated at run-time.
// ===========================================================================
// INLINE FUNCTIONS
// ===========================================================================
// CREATORS
template <int INT_VALUE>
inline
MetaInt<INT_VALUE>::MetaInt()
{
}
template <int INT_VALUE>
inline
MetaInt<INT_VALUE>::MetaInt(bsl::integral_constant<int, INT_VALUE>)
{
}
inline
MetaInt<0>::MetaInt()
{
}
inline
MetaInt<0>::MetaInt(bsl::false_type)
{
}
inline
MetaInt<1>::MetaInt()
{
}
inline
MetaInt<1>::MetaInt(bsl::true_type)
{
}
// ACCESSORS
inline
MetaInt<0>::operator bool() const
{
return false;
}
inline
MetaInt<1>::operator bool() const
{
return true;
}
} // close package namespace
} // close enterprise namespace
#endif
// ----------------------------------------------------------------------------
// Copyright 2013 Bloomberg Finance L.P.
//
// 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.
// ----------------------------- END-OF-FILE ----------------------------------
| 31.049689 | 79 | 0.615123 |
9a91643d677230faa87d5d8a490bc96188c03caf | 479 | h | C | src/filters/EdgeTangentFilter.h | dasl-/ofxFilterLibrary | 6e43d33b205f04706b72747e5b4ce7f45cab3e88 | [
"MIT"
] | 98 | 2015-01-28T23:23:06.000Z | 2021-03-27T16:29:17.000Z | src/filters/EdgeTangentFilter.h | dasl-/ofxFilterLibrary | 6e43d33b205f04706b72747e5b4ce7f45cab3e88 | [
"MIT"
] | 5 | 2015-04-17T17:19:21.000Z | 2017-10-27T15:46:55.000Z | src/filters/EdgeTangentFilter.h | dasl-/ofxFilterLibrary | 6e43d33b205f04706b72747e5b4ce7f45cab3e88 | [
"MIT"
] | 18 | 2015-07-23T02:44:31.000Z | 2020-02-24T12:52:15.000Z | //
// EdgeTangentFilter.h
// ofxFilterLibraryExample
//
// Created by Matthew Fargo on 2014/07/22.
//
//
#ifndef __EdgeTangentFilter__
#define __EdgeTangentFilter__
#include "Abstract3x3TextureSamplingFilter.h"
class EdgeTangentFilter : public Abstract3x3TextureSamplingFilter {
public:
EdgeTangentFilter(float width, float height);
virtual ~EdgeTangentFilter();
private:
virtual string _getFragSrc();
};
#endif /* defined(__EdgeTangentFilter__) */
| 17.740741 | 67 | 0.74739 |
2ceac669c6326686f77c1e78989918115596c140 | 16,584 | h | C | Components/Components/Overlay/include/OgreFont.h | liang47009/ndk_sources | 88155286084d1ebd1c4f34456d84812a46aba212 | [
"MIT"
] | null | null | null | Components/Components/Overlay/include/OgreFont.h | liang47009/ndk_sources | 88155286084d1ebd1c4f34456d84812a46aba212 | [
"MIT"
] | null | null | null | Components/Components/Overlay/include/OgreFont.h | liang47009/ndk_sources | 88155286084d1ebd1c4f34456d84812a46aba212 | [
"MIT"
] | null | null | null | /*-------------------------------------------------------------------------
This source file is a part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2014 Torus Knot Software Ltd
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 _Font_H__
#define _Font_H__
#include "OgreOverlayPrerequisites.h"
#include "OgreResource.h"
#include "OgreCommon.h"
#include "OgreSharedPtr.h"
namespace Ogre
{
/** \addtogroup Core
* @{
*/
/** \addtogroup Resources
* @{
*/
/** Enumerates the types of Font usable in the engine. */
enum FontType
{
/// Generated from a truetype (.ttf) font
FT_TRUETYPE = 1,
/// Loaded from an image created by an artist
FT_IMAGE = 2
};
/** Class representing a font in the system.
@remarks
This class is simply a way of getting a font texture into the OGRE system and
to easily retrieve the texture coordinates required to accurately render them.
Fonts can either be loaded from precreated textures, or the texture can be generated
using a truetype font. You can either create the texture manually in code, or you
can use a .fontdef script to define it (probably more practical since you can reuse
the definition more easily)
@note
This class extends both Resource and ManualResourceLoader since it is
both a resource in it's own right, but it also provides the manual load
implementation for the Texture it creates.
*/
class _OgreOverlayExport Font : public Resource, public ManualResourceLoader
{
protected:
/// Command object for Font - see ParamCommand
class _OgreOverlayExport CmdType : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/// Command object for Font - see ParamCommand
class _OgreOverlayExport CmdSource : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
class _OgreOverlayExport CmdCharSpacer : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/// Command object for Font - see ParamCommand
class _OgreOverlayExport CmdSize : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/// Command object for Font - see ParamCommand
class _OgreOverlayExport CmdResolution : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/// Command object for Font - see ParamCommand
class _OgreOverlayExport CmdCodePoints : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
// Command object for setting / getting parameters
static CmdType msTypeCmd;
static CmdSource msSourceCmd;
static CmdCharSpacer msCharacterSpacerCmd;
static CmdSize msSizeCmd;
static CmdResolution msResolutionCmd;
static CmdCodePoints msCodePointsCmd;
/// The type of font
FontType mType;
/// Source of the font (either an image name or a truetype font)
String mSource;
/** Add a gap between letters vertically and horizonally
prevents nasty artifacts caused by fonts atypically wide or tall characters. */
uint mCharacterSpacer;
/// Size of the truetype font, in points
Real mTtfSize;
/// Resolution (dpi) of truetype font
uint mTtfResolution;
/// Max distance to baseline of this (truetype) font
int mTtfMaxBearingY;
public:
typedef Ogre::uint32 CodePoint;
typedef Ogre::FloatRect UVRect;
/// Information about the position and size of a glyph in a texture
struct GlyphInfo
{
CodePoint codePoint;
UVRect uvRect;
Real aspectRatio;
GlyphInfo(CodePoint id, const UVRect& rect, Real aspect)
: codePoint(id), uvRect(rect), aspectRatio(aspect)
{
}
};
/// A range of code points, inclusive on both ends
typedef std::pair<CodePoint, CodePoint> CodePointRange;
typedef vector<CodePointRange>::type CodePointRangeList;
protected:
/// Map from unicode code point to texture coordinates
typedef map<CodePoint, GlyphInfo>::type CodePointMap;
CodePointMap mCodePointMap;
/// The material which is generated for this font
MaterialPtr mMaterial;
/// Texture pointer
TexturePtr mTexture;
/// For TRUE_TYPE font only
bool mAntialiasColour;
/// Range of code points to generate glyphs for (truetype only)
CodePointRangeList mCodePointRangeList;
/// Internal method for loading from ttf
void createTextureFromFont(void);
/// @copydoc Resource::loadImpl
virtual void loadImpl();
/// @copydoc Resource::unloadImpl
virtual void unloadImpl();
/// @copydoc Resource::calculateSize
size_t calculateSize(void) const { return 0; } // permanent resource is in the texture
public:
/** Constructor.
@see Resource
*/
Font(ResourceManager* creator, const String& name, ResourceHandle handle,
const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
virtual ~Font();
/** Sets the type of font. Must be set before loading. */
void setType(FontType ftype);
/** Gets the type of font. */
FontType getType(void) const;
/** Sets the source of the font.
@remarks
If you have created a font of type FT_IMAGE, this method tells the
Font which image to use as the source for the characters. So the parameter
should be the name of an appropriate image file. Note that when using an image
as a font source, you will also need to tell the font where each character is
located using setGlyphTexCoords (for each character).
@par
If you have created a font of type FT_TRUETYPE, this method tells the
Font which .ttf file to use to generate the text. You will also need to call
setTrueTypeSize and setTrueTypeResolution, and call addCodePointRange
as many times as required to define the range of glyphs you want to be
available.
@param source An image file or a truetype font, depending on the type of this font
*/
void setSource(const String& source);
/** Gets the source this font (either an image or a truetype font).
*/
const String& getSource(void) const;
/** Sets the spacing to allocate for font characters to overlap each other.
@param charSpacer The size of the character spacer, in points. Increasing it
allows for more stretched-out fonts; decreasing it reduces memory and processing
time. The default is "5".
*/
void setCharacterSpacer(uint charSpacer);
/** Gets the spacing to allocate for font characters to overlap each other.
@remarks Returns the size of the character spacer, in points. A higher value
allows for more stretched-out fonts. A low value reduces memory and processing
time. The default is "5".
*/
uint getCharacterSpacer(void) const;
/** Sets the size of a truetype font (only required for FT_TRUETYPE).
@param ttfSize The size of the font in points. Note that the
size of the font does not affect how big it is on the screen, just how large it is in
the texture and thus how detailed it is.
*/
void setTrueTypeSize(Real ttfSize);
/** Gets the resolution (dpi) of the font used to generate the texture
(only required for FT_TRUETYPE).
@param ttfResolution The resolution in dpi
*/
void setTrueTypeResolution(uint ttfResolution);
/** Gets the point size of the font used to generate the texture.
@remarks
Only applicable for FT_TRUETYPE Font objects.
Note that the size of the font does not affect how big it is on the screen,
just how large it is in the texture and thus how detailed it is.
*/
Real getTrueTypeSize(void) const;
/** Gets the resolution (dpi) of the font used to generate the texture.
@remarks
Only applicable for FT_TRUETYPE Font objects.
*/
uint getTrueTypeResolution(void) const;
/** Gets the maximum baseline distance of all glyphs used in the texture.
@remarks
Only applicable for FT_TRUETYPE Font objects.
The baseline is the vertical origin of horizontal based glyphs. The bearingY
attribute is the distance from the baseline (origin) to the top of the glyph's
bounding box.
@note
This value is only available after the font has been loaded.
*/
int getTrueTypeMaxBearingY() const;
/** Returns the texture coordinates of the associated glyph.
@remarks Parameter is a short to allow both ASCII and wide chars.
@param id The code point (unicode)
@return A rectangle with the UV coordinates, or null UVs if the
code point was not present
*/
inline const UVRect& getGlyphTexCoords(CodePoint id) const
{
CodePointMap::const_iterator i = mCodePointMap.find(id);
if (i != mCodePointMap.end())
{
return i->second.uvRect;
}
else
{
static UVRect nullRect(0.0, 0.0, 0.0, 0.0);
return nullRect;
}
}
/** Sets the texture coordinates of a glyph.
@remarks
You only need to call this if you're setting up a font loaded from a texture manually.
@note
Also sets the aspect ratio (width / height) of this character. textureAspect
is the width/height of the texture (may be non-square)
*/
inline void setGlyphTexCoords(CodePoint id, Real u1, Real v1, Real u2, Real v2, Real textureAspect)
{
CodePointMap::iterator i = mCodePointMap.find(id);
if (i != mCodePointMap.end())
{
i->second.uvRect.left = u1;
i->second.uvRect.top = v1;
i->second.uvRect.right = u2;
i->second.uvRect.bottom = v2;
i->second.aspectRatio = textureAspect * (u2 - u1) / (v2 - v1);
}
else
{
mCodePointMap.insert(
CodePointMap::value_type(id,
GlyphInfo(id, UVRect(u1, v1, u2, v2),
textureAspect * (u2 - u1) / (v2 - v1))));
}
}
/** Gets the aspect ratio (width / height) of this character. */
inline Real getGlyphAspectRatio(CodePoint id) const
{
CodePointMap::const_iterator i = mCodePointMap.find(id);
if (i != mCodePointMap.end())
{
return i->second.aspectRatio;
}
else
{
return 1.0;
}
}
/** Sets the aspect ratio (width / height) of this character.
@remarks
You only need to call this if you're setting up a font loaded from a
texture manually.
*/
inline void setGlyphAspectRatio(CodePoint id, Real ratio)
{
CodePointMap::iterator i = mCodePointMap.find(id);
if (i != mCodePointMap.end())
{
i->second.aspectRatio = ratio;
}
}
/** Gets the information available for a glyph corresponding to a
given code point, or throws an exception if it doesn't exist;
*/
const GlyphInfo& getGlyphInfo(CodePoint id) const;
/** Adds a range of code points to the list of code point ranges to generate
glyphs for, if this is a truetype based font.
@remarks
In order to save texture space, only the glyphs which are actually
needed by the application are generated into the texture. Before this
object is loaded you must call this method as many times as necessary
to define the code point range that you need.
*/
void addCodePointRange(const CodePointRange& range)
{
mCodePointRangeList.push_back(range);
}
/** Clear the list of code point ranges.
*/
void clearCodePointRanges()
{
mCodePointRangeList.clear();
}
/** Get a const reference to the list of code point ranges to be used to
generate glyphs from a truetype font.
*/
const CodePointRangeList& getCodePointRangeList() const
{
return mCodePointRangeList;
}
/** Gets the material generated for this font, as a weak reference.
@remarks
This will only be valid after the Font has been loaded.
*/
inline const MaterialPtr& getMaterial() const
{
return mMaterial;
}
/** Gets the material generated for this font, as a weak reference.
@remarks
This will only be valid after the Font has been loaded.
*/
inline const MaterialPtr& getMaterial()
{
return mMaterial;
}
/** Sets whether or not the colour of this font is antialiased as it is generated
from a true type font.
@remarks
This is valid only for a FT_TRUETYPE font. If you are planning on using
alpha blending to draw your font, then it is a good idea to set this to
false (which is the default), otherwise the darkening of the font will combine
with the fading out of the alpha around the edges and make your font look thinner
than it should. However, if you intend to blend your font using a colour blending
mode (add or modulate for example) then it's a good idea to set this to true, in
order to soften your font edges.
*/
inline void setAntialiasColour(bool enabled)
{
mAntialiasColour = enabled;
}
/** Gets whether or not the colour of this font is antialiased as it is generated
from a true type font.
*/
inline bool getAntialiasColour(void) const
{
return mAntialiasColour;
}
/** Implementation of ManualResourceLoader::loadResource, called
when the Texture that this font creates needs to (re)load.
*/
void loadResource(Resource* resource);
};
/** @} */
/** @} */
}
#endif
| 39.205674 | 107 | 0.611312 |
89d16c4a9111518a77d755efc267d4f15b66e2ae | 679 | c | C | Lab5/lab5-1/src/main.c | banne2266/NCTU-MSPL-2020 | b42221fd31fe239aa58518e8ef0b299c55bfe08a | [
"MIT"
] | null | null | null | Lab5/lab5-1/src/main.c | banne2266/NCTU-MSPL-2020 | b42221fd31fe239aa58518e8ef0b299c55bfe08a | [
"MIT"
] | null | null | null | Lab5/lab5-1/src/main.c | banne2266/NCTU-MSPL-2020 | b42221fd31fe239aa58518e8ef0b299c55bfe08a | [
"MIT"
] | null | null | null | //These functions inside the asm file
extern void GPIO_init();
extern void max7219_init();
extern void max7219_send(unsigned char address, unsigned char
data);
/**
* TODO: Show data on 7-seg via max7219_send
* Input:
* data: decimal value
* num_digs: number of digits will show on 7-seg
* Return:
* 0: success
* -1: illegal data range(out of 8 digits range)
*/
int display(int data, int num_digs){
if(num_digs > 8 || data > 99999999 || data < 0)
return -1;
for(int i = 0; i < num_digs; i++){
int data_i = data % 10;
max7219_send(i+1, data_i);
data /= 10;
}
return 0;
};
int main(){
int student_id = 716325;
GPIO_init();
max7219_init();
display(student_id, 8);
}
| 21.21875 | 61 | 0.677467 |
965635d41ed8831e88875c8678b4b9fd8ab933f2 | 1,029 | h | C | System/Library/PrivateFrameworks/CoreCDPInternal.framework/CDPTTSUPayloadProvider.h | lechium/tvOS135Headers | 46cd30d3f0f7962eaa0c3f925cd71f414c65e2ac | [
"MIT"
] | 2 | 2020-07-26T20:30:54.000Z | 2020-08-10T04:26:23.000Z | System/Library/PrivateFrameworks/CoreCDPInternal.framework/CDPTTSUPayloadProvider.h | lechium/tvOS135Headers | 46cd30d3f0f7962eaa0c3f925cd71f414c65e2ac | [
"MIT"
] | 1 | 2020-07-26T20:45:31.000Z | 2020-08-09T09:30:46.000Z | System/Library/PrivateFrameworks/CoreCDPInternal.framework/CDPTTSUPayloadProvider.h | lechium/tvOS135Headers | 46cd30d3f0f7962eaa0c3f925cd71f414c65e2ac | [
"MIT"
] | null | null | null | /*
* This header is generated by classdump-dyld 1.0
* on Sunday, June 7, 2020 at 11:26:01 AM Mountain Standard Time
* Operating System: Version 13.4.5 (Build 17L562)
* Image Source: /System/Library/PrivateFrameworks/CoreCDPInternal.framework/CoreCDPInternal
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos.
*/
#import <libobjc.A.dylib/CDPKeychainCircleProxy.h>
@protocol CDPDCircleProxy;
@class KCPairingChannel, NSString;
@interface CDPTTSUPayloadProvider : NSObject <CDPKeychainCircleProxy> {
KCPairingChannel* _pairingChannel;
BOOL _complete;
id<CDPDCircleProxy> _circleProxy;
}
@property (readonly) unsigned long long hash;
@property (readonly) Class superclass;
@property (copy,readonly) NSString * description;
@property (copy,readonly) NSString * debugDescription;
-(BOOL)isComplete;
-(id)initiatingPayload:(id*)arg1 ;
-(id)processIncomingPayload:(id)arg1 error:(id*)arg2 ;
-(BOOL)supportsInteractiveAuth;
-(BOOL)requiresInitialSync;
-(id)initWithCircleProxy:(id)arg1 ;
@end
| 30.264706 | 91 | 0.781341 |
c59aecc36c0748720ffe6fbafff1d17d172194aa | 1,591 | c | C | src/error.c | hiroeorz/mrubyc_Wio3G_Soracom_Edition | 80443ebf5128a07007417840c149e3bd678393ca | [
"BSD-3-Clause"
] | 330 | 2016-03-24T04:13:28.000Z | 2022-03-31T16:30:31.000Z | src/error.c | hiroeorz/mrubyc_Wio3G_Soracom_Edition | 80443ebf5128a07007417840c149e3bd678393ca | [
"BSD-3-Clause"
] | 78 | 2016-04-04T17:01:18.000Z | 2022-03-04T07:13:19.000Z | src/error.c | hiroeorz/mrubyc_Wio3G_Soracom_Edition | 80443ebf5128a07007417840c149e3bd678393ca | [
"BSD-3-Clause"
] | 63 | 2016-03-24T04:12:17.000Z | 2022-03-04T01:42:45.000Z | /*! @file
@brief
exception classes
<pre>
Copyright (C) 2015-2019 Kyushu Institute of Technology.
Copyright (C) 2015-2019 Shimane IT Open-Innovation Center.
This file is distributed under BSD 3-Clause License.
Fetch mruby VM bytecodes, decode and execute.
</pre>
*/
#include "vm_config.h"
#include <stddef.h>
#include <string.h>
#include "vm.h"
#include "error.h"
#include "c_string.h"
static void c_exception_message(struct VM *vm, mrbc_value v[], int argc)
{
mrbc_decref( &v[0] );
if( vm->exc_message.tt == MRBC_TT_NIL ){
v[0] = mrbc_string_new(vm, "", 0);
} else {
v[0] = vm->exc_message;
}
}
void mrbc_raiseX(mrbc_vm *vm, mrbc_error_code err, char *msg)
{
vm->exc = mrbc_class_runtimeerror;
vm->exc_message = mrbc_nil_value();
if( vm->exception_tail == NULL ) return;
}
void mrbc_init_class_exception(struct VM *vm)
{
mrbc_class_exception = mrbc_define_class(vm, "Exception", mrbc_class_object);
mrbc_define_method(vm, mrbc_class_exception, "message", c_exception_message);
mrbc_class_standarderror = mrbc_define_class(vm, "StandardError", mrbc_class_exception);
mrbc_class_runtimeerror = mrbc_define_class(vm, "RuntimeError", mrbc_class_standarderror);
mrbc_class_zerodivisionerror = mrbc_define_class(vm, "ZeroDivisionError", mrbc_class_standarderror);
mrbc_class_argumenterror = mrbc_define_class(vm, "ArgumentError", mrbc_class_standarderror);
mrbc_class_indexerror = mrbc_define_class(vm, "IndexError", mrbc_class_standarderror);
mrbc_class_typeerror = mrbc_define_class(vm, "TypeError", mrbc_class_standarderror);
}
| 28.927273 | 102 | 0.750471 |
3025eabec564a969c2899b9d42294aaf3e156c47 | 2,523 | h | C | tests/testapp_cluster/cluster.h | gsauere/kv_engine | 233945fe4ddb033c2292e51f5845ab630c33276f | [
"BSD-3-Clause"
] | null | null | null | tests/testapp_cluster/cluster.h | gsauere/kv_engine | 233945fe4ddb033c2292e51f5845ab630c33276f | [
"BSD-3-Clause"
] | null | null | null | tests/testapp_cluster/cluster.h | gsauere/kv_engine | 233945fe4ddb033c2292e51f5845ab630c33276f | [
"BSD-3-Clause"
] | null | null | null | /*
* Copyright 2019 Couchbase, 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.
*/
#pragma once
#include <memcached/vbucket.h>
#include <nlohmann/json_fwd.hpp>
#include <memory>
class MemcachedConnection;
namespace cb {
namespace test {
class Node;
class Bucket;
/**
* The Cluster class represents a running cluster
*
* See readme.md for information on how to use the cluster
*
*/
class Cluster {
public:
virtual ~Cluster();
/**
* Create a Couchbase bucket
*
* @param name The name of the bucket to create
* @param attributes A JSON object containing properties for the
* bucket.
* @return a bucket object representing the bucket
*/
virtual std::shared_ptr<Bucket> createBucket(
const std::string& name, const nlohmann::json& attributes) = 0;
/**
* Delete the named bucket
*
* @param name the bucket to delete
*/
virtual void deleteBucket(const std::shared_ptr<Bucket>& bucket) = 0;
/**
* Lookup the named bucket
*
* @param name The name of the bucket
* @return THe handle to the named bucket (if exist)
*/
virtual std::shared_ptr<Bucket> getBucket(
const std::string& name) const = 0;
/**
* Get a connetion to the specified node (note that node index starts
* at 0)
*
* @param node the node number
* @return a connection towards the specified node
*/
virtual std::unique_ptr<MemcachedConnection> getConnection(
size_t node) const = 0;
/**
* Fetch the size of the cluster
*
* @return the number of nodes this cluster is built up of
*/
virtual size_t size() const = 0;
/**
* Factory method to create a cluster
*
* @param nodes The number of nodes in the cluster
* @return a handle to the newly created cluster
*/
static std::unique_ptr<Cluster> create(size_t nodes);
};
} // namespace test
} // namespace cb
| 26.28125 | 77 | 0.646453 |
309e7aa340d66fd8f5e021b87c864a3177f9a278 | 1,599 | c | C | src_checker/parser.c | ColdRainbow/ft_push_swap | 1f88840caa24fc9db1bebfd4c9e8d193cf2e539b | [
"MIT"
] | null | null | null | src_checker/parser.c | ColdRainbow/ft_push_swap | 1f88840caa24fc9db1bebfd4c9e8d193cf2e539b | [
"MIT"
] | null | null | null | src_checker/parser.c | ColdRainbow/ft_push_swap | 1f88840caa24fc9db1bebfd4c9e8d193cf2e539b | [
"MIT"
] | null | null | null | #include "../include/checker.h"
static int char_to_int(char *str)
{
int i;
int a;
int b;
i = 0;
a = 1;
b = 0;
if (str[0] == '-')
a = -1;
while (str[i])
{
if (str[i] >= '0' && str[i] <= '9')
b = b * 10 + (str[i] - 48);
i++;
}
return (a * b);
}
static int check_duplicates(t_elem *head)
{
t_elem *temp;
unsigned int i;
i = 0;
if (!head)
return (0);
while (head)
{
temp = head->next;
while (temp)
{
if (head->number == temp->number)
return (0);
temp = temp->next;
}
head = head->next;
}
return (1);
}
static int check_char_isalnum(char *str)
{
int i;
i = 0;
if (!str)
return (0);
if (str[i] == '-' || str[i] == '+')
i++;
while (str[i])
{
if (str[i] >= '0' && str[i] <= '9')
i++;
else
return (0);
}
return (1);
}
static int check_str_is_int(char *str)
{
int len;
len = ft_strlen(str);
if (len > 11 || check_char_isalnum(str) == 0)
return (0);
if (len == 11)
{
if (str[0] == '-')
{
if (ft_strncmp(str, MIN_INT, len) > 0)
return (0);
}
else if (str[0] == '+')
{
if (ft_strncmp(str, MAX_INT_P, len) > 0)
return (0);
}
}
else if (len == 10)
{
if (ft_strncmp(str, MAX_INT, len) > 0)
return (0);
}
return (1);
}
int parse_args(t_st *stack, char **nums)
{
int i;
i = 0;
while (nums[i])
{
if (check_str_is_int(nums[i]) == 1)
{
stack->last = list_add_back(&stack->head, stack->last);
if (!stack->last)
return (0);
stack->last->number = char_to_int(nums[i]);
}
else
return (0);
i++;
}
if (check_duplicates(stack->head) == 0)
return (0);
return (1);
}
| 14.026316 | 58 | 0.515322 |
cf4b929b7995cfcb3fd77063d0c29b309da76f73 | 2,622 | c | C | minix/usr.bin/trace/service/vm.c | calmsacibis995/minix | dfba95598f553b6560131d35a76658f1f8c9cf38 | [
"Unlicense"
] | null | null | null | minix/usr.bin/trace/service/vm.c | calmsacibis995/minix | dfba95598f553b6560131d35a76658f1f8c9cf38 | [
"Unlicense"
] | null | null | null | minix/usr.bin/trace/service/vm.c | calmsacibis995/minix | dfba95598f553b6560131d35a76658f1f8c9cf38 | [
"Unlicense"
] | null | null | null |
#include "inc.h"
#include <sys/mman.h>
#include <sys/resource.h>
static int
vm_brk_out(struct trace_proc * proc, const message * m_out)
{
put_ptr(proc, "addr", (vir_bytes)m_out->m_lc_vm_brk.addr);
return CT_DONE;
}
static const struct flags mmap_prot[] = {
FLAG_ZERO(PROT_NONE),
FLAG(PROT_READ),
FLAG(PROT_WRITE),
FLAG(PROT_EXEC),
};
static const struct flags mmap_flags[] = {
FLAG(MAP_SHARED),
FLAG(MAP_PRIVATE),
FLAG(MAP_FIXED),
FLAG(MAP_RENAME),
FLAG(MAP_NORESERVE),
FLAG(MAP_INHERIT),
FLAG(MAP_HASSEMAPHORE),
FLAG(MAP_TRYFIXED),
FLAG(MAP_WIRED),
FLAG_MASK(MAP_ANON | MAP_STACK, MAP_FILE),
FLAG(MAP_ANON),
FLAG(MAP_STACK),
FLAG(MAP_UNINITIALIZED),
FLAG(MAP_PREALLOC),
FLAG(MAP_CONTIG),
FLAG(MAP_LOWER16M),
FLAG(MAP_LOWER1M),
FLAG(MAP_THIRDPARTY),
/* TODO: interpret alignments for which there is no constant */
FLAG_MASK(MAP_ALIGNMENT_MASK, MAP_ALIGNMENT_64KB),
FLAG_MASK(MAP_ALIGNMENT_MASK, MAP_ALIGNMENT_16MB),
FLAG_MASK(MAP_ALIGNMENT_MASK, MAP_ALIGNMENT_4GB),
FLAG_MASK(MAP_ALIGNMENT_MASK, MAP_ALIGNMENT_1TB),
FLAG_MASK(MAP_ALIGNMENT_MASK, MAP_ALIGNMENT_256TB),
FLAG_MASK(MAP_ALIGNMENT_MASK, MAP_ALIGNMENT_64PB),
};
static int
vm_mmap_out(struct trace_proc * proc, const message * m_out)
{
if (m_out->m_mmap.flags & MAP_THIRDPARTY)
put_endpoint(proc, "forwhom", m_out->m_mmap.forwhom);
put_ptr(proc, "addr", (vir_bytes)m_out->m_mmap.addr);
put_value(proc, "len", "%zu", m_out->m_mmap.len);
put_flags(proc, "prot", mmap_prot, COUNT(mmap_prot), "0x%x",
m_out->m_mmap.prot);
put_flags(proc, "flags", mmap_flags, COUNT(mmap_flags), "0x%x",
m_out->m_mmap.flags);
put_fd(proc, "fd", m_out->m_mmap.fd);
put_value(proc, "offset", "%"PRId64, m_out->m_mmap.offset);
return CT_DONE;
}
static void
vm_mmap_in(struct trace_proc * proc, const message * __unused m_out,
const message * m_in, int failed)
{
if (!failed)
put_ptr(proc, NULL, (vir_bytes)m_in->m_mmap.retaddr);
else
/* TODO: consider printing MAP_FAILED in the right cases */
put_result(proc);
}
static int
vm_munmap_out(struct trace_proc * proc, const message * m_out)
{
put_ptr(proc, "addr", (vir_bytes)m_out->m_mmap.addr);
put_value(proc, "len", "%zu", m_out->m_mmap.len);
return CT_DONE;
}
#define VM_CALL(c) [((VM_ ## c) - VM_RQ_BASE)]
static const struct call_handler vm_map[] = {
VM_CALL(BRK) = HANDLER("brk", vm_brk_out, default_in),
VM_CALL(MMAP) = HANDLER("mmap", vm_mmap_out, vm_mmap_in),
VM_CALL(MUNMAP) = HANDLER("munmap", vm_munmap_out, default_in),
};
const struct calls vm_calls = {
.endpt = VM_PROC_NR,
.base = VM_RQ_BASE,
.map = vm_map,
.count = COUNT(vm_map)
};
| 24.971429 | 68 | 0.728833 |
cf7b696360226c5b327c131f89622dbc3bf88b18 | 442 | h | C | MeetTheTeam/MeetTheTeam/TeammateTableViewCell.h | TylerKuster/MeetTheTeam | 46649d22bc1cfda3d9df4cc8238ec48b11545422 | [
"MIT"
] | null | null | null | MeetTheTeam/MeetTheTeam/TeammateTableViewCell.h | TylerKuster/MeetTheTeam | 46649d22bc1cfda3d9df4cc8238ec48b11545422 | [
"MIT"
] | null | null | null | MeetTheTeam/MeetTheTeam/TeammateTableViewCell.h | TylerKuster/MeetTheTeam | 46649d22bc1cfda3d9df4cc8238ec48b11545422 | [
"MIT"
] | null | null | null | //
// TeammateTableViewCell.h
// MeetTheTeam
//
// Created by Tyler Kuster on 4/14/17.
// Copyright © 2017 TylerKuster. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface TeammateTableViewCell : UITableViewCell
@property (nonatomic, retain) IBOutlet UIImageView* teammateImageView;
@property (nonatomic, retain) IBOutlet UILabel* teammateNameLabel;
@property (nonatomic, retain) IBOutlet UILabel* teammatePositionLabel;
@end
| 23.263158 | 70 | 0.766968 |
5cf0c5afb86a5c235d831dd2228713116a3355b3 | 9,821 | h | C | src/gpu/tessellate/MiddleOutPolygonTriangulator.h | rohankumardubey/skia | cd7220e7686c7484eda63ea651c182a31f05366d | [
"BSD-3-Clause"
] | null | null | null | src/gpu/tessellate/MiddleOutPolygonTriangulator.h | rohankumardubey/skia | cd7220e7686c7484eda63ea651c182a31f05366d | [
"BSD-3-Clause"
] | null | null | null | src/gpu/tessellate/MiddleOutPolygonTriangulator.h | rohankumardubey/skia | cd7220e7686c7484eda63ea651c182a31f05366d | [
"BSD-3-Clause"
] | null | null | null | /*
* Copyright 2020 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef tessellate_MiddleOutPolygonTriangulator_DEFINED
#define tessellate_MiddleOutPolygonTriangulator_DEFINED
#include "include/core/SkPath.h"
#include "include/core/SkPoint.h"
#include "include/private/SkTemplates.h"
#include "src/core/SkMathPriv.h"
#include "src/core/SkPathPriv.h"
#include <tuple>
namespace skgpu {
// This class generates a middle-out triangulation of a polygon. Conceptually, middle-out emits one
// large triangle with vertices on both endpoints and a middle point, then recurses on both sides of
// the new triangle. i.e.:
//
// void emit_middle_out_triangulation(int startIdx, int endIdx) {
// if (startIdx + 1 == endIdx) {
// return;
// }
// int middleIdx = startIdx + SkNextPow2(endIdx - startIdx) / 2;
//
// // Recurse on the left half.
// emit_middle_out_triangulation(startIdx, middleIdx);
//
// // Emit a large triangle with vertices on both endpoints and a middle point.
// emit_triangle(vertices[startIdx], vertices[middleIdx], vertices[endIdx - 1]);
//
// // Recurse on the right half.
// emit_middle_out_triangulation(middleIdx, endIdx);
// }
//
// Middle-out produces drastically less work for the rasterizer as compared a linear triangle strip
// or fan.
//
// This class is designed to not know or store all the vertices in the polygon at once. The caller
// pushes each vertex in linear order (perhaps while parsing a path), then rather than relying on
// recursion, we manipulate an O(log N) stack to determine the correct middle-out triangulation.
class MiddleOutPolygonTriangulator {
private:
// Internal representation of how we store vertices on our stack.
struct StackVertex {
SkPoint fPoint;
// How many polygon vertices away is this vertex from the previous vertex on the stack?
// i.e., the ith stack element's vertex index in the original polygon is:
//
// fVertexStack[i].fVertexIdxDelta + fVertexStack[i - 1].fVertexIdxDelta + ... +
// fVertexStack[1].fVertexIdxDelta.
//
// NOTE: fVertexStack[0].fVertexIdxDelta always == 0.
int fVertexIdxDelta;
};
public:
// RAII. This class is designed to first allow the caller to iterate the triangles that will be
// popped off our stack, and then (during the destructor) it actually pops the finished vertices
// and pushes a new one. Example usage:
//
// for (auto [p0, p1, p2] : middleOut.pushVertex(pt)) {
// vertexWriter << p0 << p1 << p2;
// }
//
// The above code iterates over the triangles being popped, and then once iteration is finished,
// the PoppedTriangleStack is destroyed, triggering the pending stack update.
class PoppedTriangleStack {
public:
PoppedTriangleStack(MiddleOutPolygonTriangulator* middleOut,
SkPoint lastPoint,
StackVertex* end,
StackVertex* newTopVertex,
StackVertex newTopValue)
: fMiddleOut(middleOut)
, fLastPoint(lastPoint)
, fEnd(end)
, fNewTopVertex(newTopVertex)
, fNewTopValue(newTopValue) {
}
PoppedTriangleStack(PoppedTriangleStack&& that) {
memcpy(this, &that, sizeof(*this));
that.fMiddleOut = nullptr; // Don't do a stack update during our destructor.
}
~PoppedTriangleStack() {
if (fMiddleOut) {
fMiddleOut->fTop = fNewTopVertex;
*fNewTopVertex = fNewTopValue;
}
}
struct Iter {
bool operator!=(const Iter& iter) { return fVertex != iter.fVertex; }
void operator++() { --fVertex; }
std::tuple<SkPoint, SkPoint, SkPoint> operator*() {
return {fVertex[-1].fPoint, fVertex[0].fPoint, fLastPoint};
}
StackVertex* fVertex;
SkPoint fLastPoint;
};
Iter begin() const { return {fMiddleOut ? fMiddleOut->fTop : fEnd, fLastPoint}; }
Iter end() const { return {fEnd, fLastPoint}; }
private:
MiddleOutPolygonTriangulator* fMiddleOut;
SkPoint fLastPoint;
StackVertex* fEnd;
StackVertex* fNewTopVertex;
StackVertex fNewTopValue;
};
// maxPushVertexCalls is an upper bound on the number of times the caller will call
// pushVertex(). The caller must not call it more times than this. (Beware of int overflow.)
MiddleOutPolygonTriangulator(int maxPushVertexCalls, SkPoint startPoint = {0,0}) {
SkASSERT(maxPushVertexCalls >= 0);
// Determine the deepest our stack can ever go.
int maxStackDepth = SkNextLog2(maxPushVertexCalls) + 1;
if (maxStackDepth > kStackPreallocCount) {
fVertexStack.reset(maxStackDepth);
}
SkDEBUGCODE(fStackAllocCount = maxStackDepth;)
// The stack will always contain a starting point. This is an implicit moveTo(0, 0)
// initially, but will be overridden if moveTo() gets called before adding geometry.
fVertexStack[0] = {startPoint, 0};
fTop = fVertexStack;
}
// Returns an RAII object that first allows the caller to iterate the triangles we will pop,
// pops those triangles, and finally pushes 'pt' onto the vertex stack.
SK_WARN_UNUSED_RESULT PoppedTriangleStack pushVertex(SkPoint pt) {
if (pt == fVertexStack[0].fPoint) {
return this->close();
}
// Our topology wants triangles that have the same vertexIdxDelta on both sides:
// e.g., a run of 9 points should be triangulated as:
//
// [0, 1, 2], [2, 3, 4], [4, 5, 6], [6, 7, 8] // vertexIdxDelta == 1
// [0, 2, 4], [4, 6, 8] // vertexIdxDelta == 2
// [0, 4, 8] // vertexIdxDelta == 4
//
// Find as many new triangles as we can pop off the stack that have equal-delta sides. (This
// is a stack-based implementation of the recursive example method from the class comment.)
StackVertex* endVertex = fTop;
int vertexIdxDelta = 1;
while (endVertex->fVertexIdxDelta == vertexIdxDelta) {
--endVertex;
vertexIdxDelta *= 2;
}
// Once the above triangles are popped, push 'pt' to the top of the stack.
StackVertex* newTopVertex = endVertex + 1;
StackVertex newTopValue = {pt, vertexIdxDelta};
SkASSERT(newTopVertex < fVertexStack + fStackAllocCount); // Is fStackAllocCount enough?
return PoppedTriangleStack(this, pt, endVertex, newTopVertex, newTopValue);
}
// Returns an RAII object that first allows the caller to iterate the remaining triangles, then
// resets the vertex stack with newStartPoint.
SK_WARN_UNUSED_RESULT PoppedTriangleStack closeAndMove(SkPoint newStartPoint) {
// Add an implicit line back to the starting point.
SkPoint startPt = fVertexStack[0].fPoint;
// Triangulate the rest of the polygon. Since we simply have to finish now, we can't be
// picky anymore about getting a pure middle-out topology.
StackVertex* endVertex = std::min(fTop, fVertexStack + 1);
// Once every remaining triangle is popped, reset the vertex stack with newStartPoint.
StackVertex* newTopVertex = fVertexStack;
StackVertex newTopValue = {newStartPoint, 0};
return PoppedTriangleStack(this, startPt, endVertex, newTopVertex, newTopValue);
}
// Returns an RAII object that first allows the caller to iterate the remaining triangles, then
// resets the vertex stack with the same starting point as it had before.
SK_WARN_UNUSED_RESULT PoppedTriangleStack close() {
return this->closeAndMove(fVertexStack[0].fPoint);
}
private:
constexpr static int kStackPreallocCount = 32;
SkAutoSTMalloc<kStackPreallocCount, StackVertex> fVertexStack;
SkDEBUGCODE(int fStackAllocCount;)
StackVertex* fTop;
};
// This is a helper class that transforms and pushes a path's inner fan vertices onto a
// MiddleOutPolygonTriangulator. Example usage:
//
// for (PathMiddleOutFanIter it(pathMatrix, path); !it.done();) {
// for (auto [p0, p1, p2] : it.nextStack()) {
// vertexWriter << p0 << p1 << p2;
// }
// }
//
class PathMiddleOutFanIter {
public:
PathMiddleOutFanIter(const SkPath& path) : fMiddleOut(path.countVerbs()) {
SkPathPriv::Iterate it(path);
fPathIter = it.begin();
fPathEnd = it.end();
}
bool done() const { return fDone; }
MiddleOutPolygonTriangulator::PoppedTriangleStack nextStack() {
SkASSERT(!fDone);
if (fPathIter == fPathEnd) {
fDone = true;
return fMiddleOut.close();
}
switch (auto [verb, pts, w] = *fPathIter++; verb) {
SkPoint pt;
case SkPathVerb::kMove:
return fMiddleOut.closeAndMove(pts[0]);
case SkPathVerb::kLine:
case SkPathVerb::kQuad:
case SkPathVerb::kConic:
case SkPathVerb::kCubic:
pt = pts[SkPathPriv::PtsInIter((unsigned)verb) - 1];
return fMiddleOut.pushVertex(pt);
case SkPathVerb::kClose:
return fMiddleOut.close();
}
SkUNREACHABLE;
}
private:
MiddleOutPolygonTriangulator fMiddleOut;
SkPathPriv::RangeIter fPathIter;
SkPathPriv::RangeIter fPathEnd;
bool fDone = false;
};
} // namespace skgpu
#endif // tessellate_MiddleOutPolygonTriangulator_DEFINED
| 39.922764 | 100 | 0.640159 |
cf2df5363b73b49d27f757592b4c118d0a607713 | 2,027 | h | C | src/windows/native/sun/nio/ch/nio_util.h | dbac/jdk8 | abfce42ff6d4b8b77d622157519ecd211ba0aa8f | [
"MIT"
] | null | null | null | src/windows/native/sun/nio/ch/nio_util.h | dbac/jdk8 | abfce42ff6d4b8b77d622157519ecd211ba0aa8f | [
"MIT"
] | null | null | null | src/windows/native/sun/nio/ch/nio_util.h | dbac/jdk8 | abfce42ff6d4b8b77d622157519ecd211ba0aa8f | [
"MIT"
] | 1 | 2020-11-04T07:02:06.000Z | 2020-11-04T07:02:06.000Z | /*
* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include "jni.h"
/**
* The maximum buffer size for WSASend/WSARecv. Microsoft recommendation for
* blocking operations is to use buffers no larger than 64k. We need the
* maximum to be less than 128k to support asynchronous close on Windows
* Server 2003 and newer editions of Windows.
*/
#define MAX_BUFFER_SIZE ((128*1024)-1)
jint fdval(JNIEnv *env, jobject fdo);
jlong handleval(JNIEnv *env, jobject fdo);
jint convertReturnVal(JNIEnv *env, jint n, jboolean r);
jlong convertLongReturnVal(JNIEnv *env, jlong n, jboolean r);
jboolean purgeOutstandingICMP(JNIEnv *env, jclass clazz, jint fd);
jint handleSocketError(JNIEnv *env, int errorValue);
#ifdef _WIN64
struct iovec {
jlong iov_base;
jint iov_len;
};
#else
struct iovec {
jint iov_base;
jint iov_len;
};
#endif
| 34.948276 | 79 | 0.742477 |
fde883391604d13468fa384a24f5ae58a1276349 | 427 | h | C | headers/func.h | vanyingenzi/kmeans | 5a24f614e460d6e58bda0e3c01926063f7c1bab1 | [
"MIT"
] | null | null | null | headers/func.h | vanyingenzi/kmeans | 5a24f614e460d6e58bda0e3c01926063f7c1bab1 | [
"MIT"
] | null | null | null | headers/func.h | vanyingenzi/kmeans | 5a24f614e460d6e58bda0e3c01926063f7c1bab1 | [
"MIT"
] | null | null | null | #ifndef FUNC_H
#define FUNC_H
#include <stdio.h>
#include <stdint.h>
#include "arrayofpoints.h"
#include "arrayofclusters.h"
#include "filehandler.h"
typedef struct {
array_of_centroids *finalCentroids;
array_of_clusters *finalClusters;
}list_of_centroids_and_clusters_only;
int k_means(list_of_centroids_and_clusters_only * ptr,
array_of_centroids *,
uint32_t , file_t *);
#endif //FUNC_H | 21.35 | 54 | 0.737705 |
10869b15ee84fb2f5ba9e02fc3e04304046f8d70 | 6,610 | h | C | src/Moon/128/mask_26_128.h | MHotchin/RLEBitmap | ebea6f7f032c235ff2301e2aced1e6180b71882e | [
"MIT"
] | 8 | 2020-07-05T17:00:15.000Z | 2022-02-08T04:34:50.000Z | src/Moon/128/mask_26_128.h | Bodmer/RLEBitmap | ed2bf7ec6497371415878a7a5a07b7938294aad6 | [
"MIT"
] | 2 | 2020-07-04T21:11:49.000Z | 2020-08-11T20:23:06.000Z | src/Moon/128/mask_26_128.h | Bodmer/RLEBitmap | ed2bf7ec6497371415878a7a5a07b7938294aad6 | [
"MIT"
] | 3 | 2020-07-05T17:00:22.000Z | 2020-11-03T11:18:34.000Z |
//
// This file is AUTOMATICALLY GENERATED, and should not be edited unless you are certain
// that it will not be re-generated anytime in the future. As generated code, the
// copyright owner(s) of the generating program do NOT claim any copyright on the code
// generated.
//
// Run Length Encoded (RLE) bitmaps. Each run is encoded as either one or two bytes,
// with NO PADDING. Thus, the data for each line of the bitmap is VARIABLE LENGTH, and
// there is no way of determining where any line other than the first starts without
// walking though the data.
//
// Note that one byte encoding ONLY occurs if the total number of colors is 16 or less,
// and in that case the 'flags' member of the 'RLEBitmapInfo' will have the first bit
// (0x01) set.
//
// In that case, if the high 4 bits of the first byte are ZERO, then this is a 2 byte
// run. The first byte is the index of the color in the color palette, and the second
// byte is the length.
//
// Else, the lower 4 bits are the color index, and the upper 4 bits are the run length.
//
// If the 'flags' member first bit is zero, then ALL runs are 2 byte runs. The first
// byte is the palette index, and the second is the run length.
//
// In order to save PROGMEM for other uses, the bitmap data is placed in a section that
// occurs near the END of the used FLASH. So, this data should only be accessed using
// the 'far' versions of the progmem functions - the usual versions are limited to the
// first 64K of FLASH.
//
// Data is from file 'images\128\mask_26_128.bmp'.
//
const byte mask_26_128_RLEBM_data[] PROGMEM_LATE =
{
0x00, 0x38, 0x91, 0x00, 0x3f,
0x00, 0x32, 0xc1, 0x00, 0x42,
0x00, 0x2f, 0xc1, 0x00, 0x45,
0x00, 0x2b, 0xf1, 0x00, 0x46,
0x00, 0x29, 0xf1, 0x00, 0x48,
0x00, 0x26, 0x01, 0x11, 0x00, 0x49,
0x00, 0x24, 0x01, 0x13, 0x00, 0x49,
0x00, 0x22, 0x01, 0x14, 0x00, 0x4a,
0x00, 0x21, 0x01, 0x14, 0x00, 0x4b,
0x00, 0x1f, 0x01, 0x15, 0x00, 0x4c,
0x00, 0x1d, 0x01, 0x17, 0x00, 0x4c,
0x00, 0x1c, 0x01, 0x17, 0x00, 0x4d,
0x00, 0x1a, 0x01, 0x18, 0x00, 0x4e,
0x00, 0x19, 0x01, 0x19, 0x00, 0x4e,
0x00, 0x18, 0x01, 0x19, 0x00, 0x4f,
0x00, 0x17, 0x01, 0x1a, 0x00, 0x4f,
0x00, 0x16, 0x01, 0x1a, 0x00, 0x50,
0x00, 0x14, 0x01, 0x1c, 0x00, 0x50,
0x00, 0x13, 0x01, 0x1d, 0x00, 0x50,
0x00, 0x12, 0x01, 0x1d, 0x00, 0x51,
0x00, 0x12, 0x01, 0x1d, 0x00, 0x51,
0x00, 0x11, 0x01, 0x1d, 0x00, 0x52,
0x00, 0x10, 0x01, 0x1e, 0x00, 0x52,
0xf0, 0x01, 0x1f, 0x00, 0x52,
0xe0, 0x01, 0x1f, 0x00, 0x53,
0xd0, 0x01, 0x20, 0x00, 0x53,
0xd0, 0x01, 0x20, 0x00, 0x53,
0xc0, 0x01, 0x20, 0x00, 0x54,
0xb0, 0x01, 0x21, 0x00, 0x54,
0xb0, 0x01, 0x21, 0x00, 0x54,
0xa0, 0x01, 0x22, 0x00, 0x54,
0x90, 0x01, 0x22, 0x00, 0x55,
0x90, 0x01, 0x22, 0x00, 0x55,
0x80, 0x01, 0x23, 0x00, 0x55,
0x80, 0x01, 0x23, 0x00, 0x55,
0x70, 0x01, 0x24, 0x00, 0x55,
0x70, 0x01, 0x23, 0x00, 0x56,
0x60, 0x01, 0x24, 0x00, 0x56,
0x60, 0x01, 0x24, 0x00, 0x56,
0x50, 0x01, 0x25, 0x00, 0x56,
0x50, 0x01, 0x25, 0x00, 0x56,
0x50, 0x01, 0x24, 0x00, 0x57,
0x40, 0x01, 0x25, 0x00, 0x57,
0x40, 0x01, 0x25, 0x00, 0x57,
0x30, 0x01, 0x26, 0x00, 0x57,
0x30, 0x01, 0x26, 0x00, 0x57,
0x30, 0x01, 0x26, 0x00, 0x57,
0x30, 0x01, 0x26, 0x00, 0x57,
0x20, 0x01, 0x27, 0x00, 0x57,
0x20, 0x01, 0x27, 0x00, 0x57,
0x20, 0x01, 0x26, 0x00, 0x58,
0x20, 0x01, 0x26, 0x00, 0x58,
0x10, 0x01, 0x27, 0x00, 0x58,
0x10, 0x01, 0x27, 0x00, 0x58,
0x10, 0x01, 0x27, 0x00, 0x58,
0x10, 0x01, 0x27, 0x00, 0x58,
0x10, 0x01, 0x27, 0x00, 0x58,
0x10, 0x01, 0x27, 0x00, 0x58,
0x10, 0x01, 0x27, 0x00, 0x58,
0x10, 0x01, 0x27, 0x00, 0x58,
0x10, 0x01, 0x27, 0x00, 0x58,
0x10, 0x01, 0x27, 0x00, 0x58,
0x01, 0x28, 0x00, 0x58,
0x01, 0x28, 0x00, 0x58,
0x10, 0x01, 0x27, 0x00, 0x58,
0x01, 0x28, 0x00, 0x58,
0x10, 0x01, 0x27, 0x00, 0x58,
0x10, 0x01, 0x27, 0x00, 0x58,
0x10, 0x01, 0x27, 0x00, 0x58,
0x10, 0x01, 0x27, 0x00, 0x58,
0x10, 0x01, 0x27, 0x00, 0x58,
0x10, 0x01, 0x27, 0x00, 0x58,
0x10, 0x01, 0x27, 0x00, 0x58,
0x10, 0x01, 0x27, 0x00, 0x58,
0x10, 0x01, 0x27, 0x00, 0x58,
0x10, 0x01, 0x27, 0x00, 0x58,
0x20, 0x01, 0x26, 0x00, 0x58,
0x20, 0x01, 0x26, 0x00, 0x58,
0x20, 0x01, 0x27, 0x00, 0x57,
0x20, 0x01, 0x27, 0x00, 0x57,
0x30, 0x01, 0x26, 0x00, 0x57,
0x30, 0x01, 0x26, 0x00, 0x57,
0x30, 0x01, 0x26, 0x00, 0x57,
0x30, 0x01, 0x26, 0x00, 0x57,
0x40, 0x01, 0x25, 0x00, 0x57,
0x40, 0x01, 0x25, 0x00, 0x57,
0x50, 0x01, 0x24, 0x00, 0x57,
0x50, 0x01, 0x25, 0x00, 0x56,
0x50, 0x01, 0x25, 0x00, 0x56,
0x60, 0x01, 0x24, 0x00, 0x56,
0x60, 0x01, 0x24, 0x00, 0x56,
0x70, 0x01, 0x23, 0x00, 0x56,
0x70, 0x01, 0x24, 0x00, 0x55,
0x80, 0x01, 0x23, 0x00, 0x55,
0x80, 0x01, 0x23, 0x00, 0x55,
0x90, 0x01, 0x22, 0x00, 0x55,
0x90, 0x01, 0x22, 0x00, 0x55,
0xa0, 0x01, 0x22, 0x00, 0x54,
0xb0, 0x01, 0x21, 0x00, 0x54,
0xb0, 0x01, 0x21, 0x00, 0x54,
0xc0, 0x01, 0x20, 0x00, 0x54,
0xd0, 0x01, 0x20, 0x00, 0x53,
0xd0, 0x01, 0x20, 0x00, 0x53,
0xe0, 0x01, 0x1f, 0x00, 0x53,
0xf0, 0x01, 0x1f, 0x00, 0x52,
0x00, 0x10, 0x01, 0x1e, 0x00, 0x52,
0x00, 0x11, 0x01, 0x1d, 0x00, 0x52,
0x00, 0x12, 0x01, 0x1d, 0x00, 0x51,
0x00, 0x12, 0x01, 0x1d, 0x00, 0x51,
0x00, 0x13, 0x01, 0x1d, 0x00, 0x50,
0x00, 0x14, 0x01, 0x1c, 0x00, 0x50,
0x00, 0x16, 0x01, 0x1a, 0x00, 0x50,
0x00, 0x17, 0x01, 0x1a, 0x00, 0x4f,
0x00, 0x18, 0x01, 0x19, 0x00, 0x4f,
0x00, 0x19, 0x01, 0x19, 0x00, 0x4e,
0x00, 0x1a, 0x01, 0x18, 0x00, 0x4e,
0x00, 0x1c, 0x01, 0x17, 0x00, 0x4d,
0x00, 0x1d, 0x01, 0x17, 0x00, 0x4c,
0x00, 0x1f, 0x01, 0x15, 0x00, 0x4c,
0x00, 0x21, 0x01, 0x14, 0x00, 0x4b,
0x00, 0x22, 0x01, 0x14, 0x00, 0x4a,
0x00, 0x24, 0x01, 0x13, 0x00, 0x49,
0x00, 0x26, 0x01, 0x11, 0x00, 0x49,
0x00, 0x29, 0xf1, 0x00, 0x48,
0x00, 0x2b, 0xf1, 0x00, 0x46,
0x00, 0x2f, 0xc1, 0x00, 0x45,
0x00, 0x32, 0xc1, 0x00, 0x42,
0x00, 0x38, 0x91, 0x00, 0x3f,
}; // 128x128 Bitmap (16384 pixels) in 673 bytes
const uint16_t mask_26_128_RLEBM_palette[] PROGMEM_LATE =
{
// Palette has 2 entries
0x0000, 0xffff,
};
// Some platforms don't fully implement the pgmspace.h interface. Assume ordinary
// addresses will do.
#if not defined pgm_get_far_address
#define pgm_get_far_address(x) ((uint32_t)(&(x)))
#endif
// Returns the info needed to render the bitmap.
inline void get_mask_26_128_RLEBM(
RLEBitmapInfo &bmInfo)
{
bmInfo.pRLEBM_data_far = pgm_get_far_address(mask_26_128_RLEBM_data);
bmInfo.pRLEBM_palette_far = pgm_get_far_address(mask_26_128_RLEBM_palette);
bmInfo.width = 128;
bmInfo.height = 128;
bmInfo.flags = 0x01;
}
| 34.60733 | 89 | 0.663691 |
340a404598f51bd1fe8b124c05193a1bc89c365a | 12,035 | h | C | WRK-V1.2/clr/src/fusion/inc/nodefact.h | intj-t/openvmsft | 0d17fbce8607ab2b880be976c2e86d8cfc3e83bb | [
"Intel"
] | null | null | null | WRK-V1.2/clr/src/fusion/inc/nodefact.h | intj-t/openvmsft | 0d17fbce8607ab2b880be976c2e86d8cfc3e83bb | [
"Intel"
] | null | null | null | WRK-V1.2/clr/src/fusion/inc/nodefact.h | intj-t/openvmsft | 0d17fbce8607ab2b880be976c2e86d8cfc3e83bb | [
"Intel"
] | null | null | null | // ==++==
//
//
// Copyright (c) 2006 Microsoft Corporation. All rights reserved.
//
// The use and distribution terms for this software are contained in the file
// named license.txt, which can be found in the root of this distribution.
// By using this software in any fashion, you are agreeing to be bound by the
// terms of this license.
//
// You must not remove this notice, or any other, from this software.
//
//
// ==--==
#ifndef __NODEFACT_H_
#define __NODEFACT_H_
#include "list.h"
#include "xmlns.h"
#include "dbglog.h"
typedef enum tagParseState {
PSTATE_LOOKUP_CONFIGURATION,
PSTATE_CONFIGURATION,
PSTATE_RUNTIME,
PSTATE_ASSEMBLYBINDING_ROOT,
PSTATE_ASSEMBLYBINDING,
PSTATE_ASSEMBLYBINDINGV2,
PSTATE_DEPENDENTASSEMBLY,
} ParseState;
#define CFG_CULTURE_NEUTRAL L"neutral"
#define XML_CONFIGURATION_DEPTH 1
#define XML_RUNTIME_DEPTH 2
#define XML_ASSEMBLYBINDINGV2_DEPTH 2
#define XML_ASSEMBLYBINDING_DEPTH 3
#define XML_ASSEMBLY_STORE_DEPTH 3
#define XML_DEVOVERRIDE_PATH_DEPTH 3
#define XML_ASSEMBLYBINDING_ROOT_DEPTH 2
#define XML_LINKED_CONFIGURATION_DEPTH 3
#define XML_PROBING_DEPTH 4
#define XML_DEPENDENTASSEMBLY_DEPTH 4
#define XML_GLOBAL_PUBLISHERPOLICY_DEPTH 4
#define XML_ASSEMBLYIDENTITY_DEPTH 5
#define XML_BINDINGREDIRECT_DEPTH 5
#define XML_CODEBASE_DEPTH 5
#define XML_PUBLISHERPOLICY_DEPTH 5
#define XML_QUALIFYASSEMBLY_DEPTH 4
#define POLICY_TAG_QUALIFYASSEMBLY L"urn:schemas-microsoft-com:asm.v1^qualifyAssembly"
#define XML_ATTRIBUTE_PARTIALNAME L"partialName"
#define XML_ATTRIBUTE_FULLNAME L"fullName"
// maximum length of policy tag with namespace.
// An optimization to not allocate unnecessary memory when parsing.
#define MAX_POLICY_TAG_LENGTH 128
#define POLICY_TAG_CONFIGURATION L"configuration"
#define POLICY_TAG_RUNTIME L"runtime"
#define POLICY_TAG_ASSEMBLYBINDING L"urn:schemas-microsoft-com:asm.v1^assemblyBinding"
#define POLICY_TAG_ASSEMBLYBINDINGV2 L"urn:schemas-microsoft-com:asm.v2^assemblyBinding"
#define POLICY_TAG_PROBING L"urn:schemas-microsoft-com:asm.v1^probing"
#define POLICY_TAG_DEPENDENTASSEMBLY L"urn:schemas-microsoft-com:asm.v1^dependentAssembly"
#define POLICY_TAG_ASSEMBLYIDENTITY L"urn:schemas-microsoft-com:asm.v1^assemblyIdentity"
#define POLICY_TAG_BINDINGREDIRECT L"urn:schemas-microsoft-com:asm.v1^bindingRedirect"
#define POLICY_TAG_CODEBASE L"urn:schemas-microsoft-com:asm.v1^codeBase"
#define POLICY_TAG_PUBLISHERPOLICY L"urn:schemas-microsoft-com:asm.v1^publisherPolicy"
#define POLICY_TAG_LINKEDCONFIGURATION L"urn:schemas-microsoft-com:asm.v1^linkedConfiguration"
#define POLICY_TAG_ASSEMBLYSTORE L"urn:schemas-microsoft-com:asm.v2^assemblyStore"
#define POLICY_TAG_DEVOVERRIDE_PATH L"urn:schemas-microsoft-com:asm.v2^devOverridePath"
#define XML_ATTRIBUTE_NAME L"name"
#define XML_ATTRIBUTE_PUBLICKEYTOKEN L"publicKeyToken"
#define XML_ATTRIBUTE_CULTURE L"culture"
#define XML_ATTRIBUTE_PROCESSORARCHITECTURE L"processorArchitecture"
#define XML_ATTRIBUTE_VERSION L"version"
#define XML_ATTRIBUTE_OLDVERSION L"oldVersion"
#define XML_ATTRIBUTE_NEWVERSION L"newVersion"
#define XML_ATTRIBUTE_HREF L"href"
#define XML_ATTRIBUTE_APPLY L"apply"
#define XML_ATTRIBUTE_PRIVATEPATH L"privatePath"
#define XML_ATTRIBUTE_NEWPUBLICKEYTOKEN L"newPublicKeyToken"
#define XML_ATTRIBUTE_APPLIESTO L"appliesTo"
#define XML_ATTRIBUTE_NEWNAME L"newName"
#define XML_ATTRIBUTE_LOCATION L"location"
class CAsmBindingInfo;
class CQualifyAssembly;
class CCodebaseHint;
class CBindingRedir;
class CDebugLog;
class CNamespaceManager;
class CNodeFactory : public IXMLNodeFactory
{
friend class CPublisherPolicy;
public:
enum ParseCtl {
parseAll, // parse entire config file
stopAfterRuntimeSection // stop after <runtime>...</runtime> section
};
CNodeFactory(CDebugLog *pdbglog, ParseCtl parseCtl = parseAll);
virtual ~CNodeFactory();
// IUnknown methods
STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
// IXMLNodeFactory methods
STDMETHODIMP NotifyEvent(IXMLNodeSource *pSource, XML_NODEFACTORY_EVENT iEvt);
STDMETHODIMP BeginChildren(IXMLNodeSource *pSource, XML_NODE_INFO *pNodeInfo);
STDMETHODIMP EndChildren(IXMLNodeSource *pSource, BOOL fEmpty, XML_NODE_INFO *pNodeInfo);
STDMETHODIMP Error(IXMLNodeSource *pSource, HRESULT hrErrorCode, USHORT cNumRecs, XML_NODE_INFO __RPC_FAR **aNodeInfo);
STDMETHODIMP CreateNode(IXMLNodeSource __RPC_FAR *pSource, PVOID pNodeParent, USHORT cNumRecs, XML_NODE_INFO __RPC_FAR **aNodeInfo);
// methods to retrieve various properties
HRESULT GetPolicyVersion(LPCWSTR wzAssemblyName,
LPCWSTR wzPublicKeyToken,
LPCWSTR wzCulture,
LPCWSTR wzVersionIn,
PEKIND peIn,
__out_ecount(*pdwSizeVer) LPWSTR pwzVersionOut,
__inout LPDWORD pdwSizeVer,
PEKIND *peOut);
HRESULT GetSafeMode(LPCWSTR wzAssemblyName, LPCWSTR wzPublicKeyToken,
LPCWSTR wzCulture, LPCWSTR wzVersion, PEKIND pe,
BOOL *pbSafeMode);
HRESULT GetCodebaseHint(LPCWSTR pwzAsmName, LPCWSTR pwzVersion,
LPCWSTR pwzPublicKeyToken, LPCWSTR pwzCulture, PEKIND pe,
LPCWSTR pwzAppBase, __deref_out LPWSTR *ppwzCodebase);
HRESULT GetPrivatePath(__deref_out LPWSTR *ppwzPrivatePath);
HRESULT QualifyAssembly(LPCWSTR pwzDisplayName, IAssemblyName **ppNameQualified, CDebugLog *pdbglog);
HRESULT ProcessLinkedConfiguration(LPCWSTR pwzRootConfigPath);
HRESULT GetAssemblyStorePath(__deref_out LPWSTR *ppwzAssemblyStore);
HRESULT GetDevOverridePath(__deref_out LPWSTR *ppwzDevOverridePath);
HRESULT HasFrameworkRedirect(BOOL *pbHasFxRedirect);
HRESULT OutputToUTF8(DWORD *pcbBufferSize,
BYTE *pbBuffer);
HRESULT AddPolicy( LPCWSTR wzAsmName,
LPCWSTR wzOldVersion,
LPCWSTR wzCulture,
LPCWSTR wzPublicKeyToken,
PEKIND pe,
LPCWSTR wzNewVersion,
DWORD dwModifyPolicyFlags);
HRESULT RemovePolicy(LPCWSTR wzAsmName,
LPCWSTR wzVersion, // This is the target version
LPCWSTR wzCulture,
LPCWSTR wzPublicKeyToken,
PEKIND pe);
void ReleaseLogObject() {SAFERELEASE(_pdbglog);}
private:
HRESULT ProcessAssemblyStoreTag(XML_NODE_INFO **aNodeInfo, USHORT cNumRecs);
HRESULT ProcessDevOverrideTag(XML_NODE_INFO **aNodeInfo, USHORT cNumRecs);
HRESULT ProcessProbingTag(XML_NODE_INFO **aNodeInfo, USHORT cNumRecs);
HRESULT ProcessLinkedConfigurationTag(XML_NODE_INFO **aNodeInfo, USHORT cNumRecs);
HRESULT ProcessQualifyAssemblyTag(XML_NODE_INFO **aNodeInfo, USHORT cNumRecs);
HRESULT ProcessBindingRedirectTag(XML_NODE_INFO **aNodeInfo,
USHORT cNumRecs, CBindingRedir *pRedir);
HRESULT ProcessAssemblyBindingTag(XML_NODE_INFO **aNodeInfo, USHORT cNumRecs);
HRESULT ProcessCodebaseTag(XML_NODE_INFO **aNodeInfo, USHORT cNumRecs,
CCodebaseHint *pCB);
HRESULT ProcessPublisherPolicyTag(XML_NODE_INFO **aNodeInfo,
USHORT cNumRecs,
BOOL bGlobal);
HRESULT ProcessAssemblyIdentityTag(XML_NODE_INFO **aNodeInfo, USHORT cNumRecs);
HRESULT ApplyNamespace(XML_NODE_INFO *pNodeInfo,
__out_ecount_opt(*pdwSize) LPWSTR pwzTokenNS,
__inout LPDWORD pdwSize,
DWORD dwFlags);
HRESULT CheckProcessedConfigurations(LPCWSTR pwzCanonicalUrl,
BOOL *pbProcessed);
HRESULT AddToResult();
private:
DWORD _dwSig;
LONG _cRef;
DWORD _dwState;
DWORD _dwCurDepth;
BOOL _bGlobalSafeMode;
LPWSTR _pwzPrivatePath;
List<LPWSTR> _listLinkedConfiguration;
List<CAsmBindingInfo *> _listAsmInfo;
List<CQualifyAssembly *> _listQualifyAssembly;
List<LPCWSTR> _listProcessedCfgs;
CDebugLog *_pdbglog;
CAsmBindingInfo *_pAsmInfo;
CNamespaceManager _nsmgr;
// Is current runtime version matching the ones specified in "appliesTo"?
BOOL _bCorVersionMatch;
ParseCtl _parseCtl;
LPWSTR _pwzAssemblyStore;
LPWSTR _pwzDevOverridePath;
};
// all size in wchar_t
HRESULT GetSerializeRequiredSize(CAsmBindingInfo *pAsmBindInfo, DWORD *pdwSize);
HRESULT GetSerializeRequiredSize(CQualifyAssembly *pQualifyAssembly, DWORD *pdwSize);
HRESULT GetSerializeRequiredSize(CBindingRedir *pRedir, DWORD *pdwSize);
HRESULT GetSerializeRequiredSize(CCodebaseHint *pCBHint, DWORD *pdwSize);
HRESULT Serialize(CAsmBindingInfo *pAsmBindInfo,
__out_ecount(*pdwSize) LPWSTR pwzBuffer,
__inout DWORD *pdwSize);
HRESULT Serialize(CQualifyAssembly *pQualifyAssembly,
__out_ecount(*pdwSize) LPWSTR pwzBuffer,
__inout DWORD *pdwSize);
HRESULT Serialize(CBindingRedir *pRedir,
__out_ecount(*pdwSize) LPWSTR pwzBuffer,
__inout DWORD *pdwSize);
HRESULT Serialize(CCodebaseHint *pCBHint,
__out_ecount(*pdwSize) LPWSTR pwzBuffer,
__inout DWORD *pdwSize);
BOOL IsMatch(CAsmBindingInfo *pAsmInfo,
LPCWSTR pwzName,
LPCWSTR pwzCulture,
LPCWSTR pwzPublicKeyToken,
PEKIND pe);
BOOL IsMatch(CAsmBindingInfo *pAsmInfo,
CAsmBindingInfo *pAsmInfo2);
BOOL IsDuplicate(CAsmBindingInfo *pAsmInfoExist,
CAsmBindingInfo *pAsmInfo);
HRESULT AddRedirToBindInfo(CBindingRedir *pRedir,
CAsmBindingInfo *pAsmInfo);
HRESULT AddCodebaseHintToBindInfo(CCodebaseHint *pCodebase,
CAsmBindingInfo *pAsmInfo);
HRESULT MergeBindInfo(CAsmBindingInfo *pAsmInfo,
CAsmBindingInfo *pAsmInfoNew);
#endif // __NODEFACT_H_
| 45.415094 | 140 | 0.615953 |
b788481fea49a8a4abe9c8952573e8998aae3dd7 | 991 | h | C | iterator.h | pcjdean/rocksdbgo | 7171df43cba6dcdf71f222edfdfc6185e6d2493d | [
"MIT"
] | 2 | 2018-12-10T06:34:12.000Z | 2021-02-03T18:51:42.000Z | iterator.h | pcjdean/rocksdb-golang | 7171df43cba6dcdf71f222edfdfc6185e6d2493d | [
"MIT"
] | null | null | null | iterator.h | pcjdean/rocksdb-golang | 7171df43cba6dcdf71f222edfdfc6185e6d2493d | [
"MIT"
] | null | null | null | // Copyright (c) 2015, Dean ChaoJun Pan. 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.
//
#ifndef GO_ROCKSDB_INCLUDE_ITERATOR_H_
#define GO_ROCKSDB_INCLUDE_ITERATOR_H_
#include "types.h"
#include "slice.h"
#include "status.h"
#ifdef __cplusplus
extern "C" {
#endif
DEFINE_C_WRAP_STRUCT(Iterator)
DEFINE_C_WRAP_CONSTRUCTOR_DEC(Iterator)
DEFINE_C_WRAP_DESTRUCTOR_DEC(Iterator)
DEFINE_C_WRAP_DESTRUCTOR_ARRAY_DEC(Iterator)
bool IteratorValid(Iterator_t *it);
void IteratorSeekToFirst(Iterator_t *it);
void IteratorSeekToLast(Iterator_t *it);
void IteratorSeek(Iterator_t *it, const Slice_t* target);
void IteratorNext(Iterator_t *it);
void IteratorPrev(Iterator_t *it);
Slice_t IteratorKey(Iterator_t *it);
Slice_t IteratorValue(Iterator_t *it);
Status_t IteratorStatus(Iterator_t *it);
#ifdef __cplusplus
} /* end extern "C" */
#endif
#endif // GO_ROCKSDB_INCLUDE_ITERATOR_H_
| 26.783784 | 72 | 0.799193 |
b7cf32b49d20f3c64d4ef0c9d80c0f015947d93e | 315 | h | C | PrivateFrameworks/PhotoPrintProduct/KHPanelBox.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 17 | 2018-11-13T04:02:58.000Z | 2022-01-20T09:27:13.000Z | PrivateFrameworks/PhotoPrintProduct/KHPanelBox.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 3 | 2018-04-06T02:02:27.000Z | 2018-10-02T01:12:10.000Z | PrivateFrameworks/PhotoPrintProduct/KHPanelBox.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 "NSBox.h"
@interface KHPanelBox : NSBox
{
}
- (id)accessibilityAttributeValue:(id)arg1;
- (id)accessibilityAttributeNames;
- (id)hitTest:(struct CGPoint)arg1;
@end
| 16.578947 | 83 | 0.679365 |
082b5aff4be83f7be278581e9396c1d84761e1da | 6,188 | c | C | 1. pthreads/src/simulation.c | luisblazquezm/mii1-hpc-projects | 9e281bab5f826f4a1deeaade9fa9a4a364cbe213 | [
"MIT"
] | null | null | null | 1. pthreads/src/simulation.c | luisblazquezm/mii1-hpc-projects | 9e281bab5f826f4a1deeaade9fa9a4a364cbe213 | [
"MIT"
] | null | null | null | 1. pthreads/src/simulation.c | luisblazquezm/mii1-hpc-projects | 9e281bab5f826f4a1deeaade9fa9a4a364cbe213 | [
"MIT"
] | 2 | 2021-08-25T07:04:14.000Z | 2021-11-19T08:35:45.000Z | #include "utils.h"
#include "plate.h"
#include "logging.h"
#include "simulation.h"
#include "paralellUtils.h"
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <pthread.h>
#include <sys/time.h>
#include <semaphore.h>
void * calculateSubMatrix(void* arg);
long measureTime(){
struct timeval time;
gettimeofday(&time, NULL);
long micros = (time.tv_sec * 1000000) + time.tv_usec;
return micros;
}
void serialSimulation(int numIterations, int numRows, int numCols, TimeResultRef timeResult){
Value newValue;
int iteration, i, j;
PlateRef oldPlate = NULL, currentPlate = NULL, switchPlate = NULL;
doLog(DEBUG, "starting serial simulation");
// define holes
Hole holes [1];
initializeHole(&(holes[0]),3,6,3,6);
// create and initialize plates
doLog(DEBUG, "creating plates structures");
oldPlate = createPlate(numRows, numCols);
currentPlate = createPlate(numRows, numCols);
doLog(DEBUG, "initlializing plate structure");
initializePlate(oldPlate, 1, holes);
if(LOG_LEVEL == DEBUG){
printPlate(oldPlate);
}
// measure total time
timeResult->totaltime = measureTime();
// update num iterations times
for(iteration=0; iteration<numIterations; iteration++){
doLog(INFO, "new iteration");
// measure iteration time
timeResult->times[iteration] = measureTime();
// update plate values
for(i=0; i < currentPlate->rows; i++){
for(j=0; j < currentPlate->cols; j++){
if(isHole(oldPlate, i, j)){
setPlateValue(currentPlate, i, j, HOLE_VALUE);
continue;
}
newValue = calculateNewTemperature(oldPlate, i, j);
setPlateValue(currentPlate, i, j, newValue);
}
}
// switch plates
switchPlate = oldPlate;
oldPlate = currentPlate;
currentPlate = switchPlate;
if(LOG_LEVEL == DEBUG){
printPlate(oldPlate);
}
// measure iteration time
timeResult->times[iteration] = measureTime() - timeResult->times[iteration];
}
// measure total time
timeResult->numThreads = 1;
timeResult->totaltime = measureTime() - timeResult->totaltime;
doLog(DEBUG, "ending serial simulation");
}
void paralellSimulation(int numIterations, int numRows, int numCols, int numThreads, DivisionStructure division, TimeResultRef timeResult){
Value newValue;
int iteration, i, j;
pthread_barrier_t barrier;
pthread_barrierattr_t attr;
pthread_t * threadIds = NULL;
MatrixSubTaskRef subtasks = NULL;
PlateRef oldPlate = NULL, currentPlate = NULL, switchPlate = NULL;
doLog(DEBUG, "starting paralell simulation");
// define holes
Hole holes [1];
initializeHole(&(holes[0]),3,6,3,6);
// create and initialize plates
doLog(DEBUG, "creating plates structures");
oldPlate = createPlate(numRows, numCols);
currentPlate = createPlate(numRows, numCols);
doLog(DEBUG, "initlializing plate structure");
initializePlate(oldPlate, 1, holes);
if(LOG_LEVEL == DEBUG){
printPlate(oldPlate);
}
// create thread id containers
doLog(DEBUG, "creating thread id array");
threadIds = (pthread_t *) calloc(numThreads,sizeof(pthread_t));
if(threadIds == NULL){
doLog(ERROR, "Unable to reserve memory to the thread id array, aborting the execution");
exit(IO_ERROR_CODE);
}
// create and initialize barrier
doLog(DEBUG, "creating barrier");
if(0 != pthread_barrier_init(&barrier, &attr, numThreads-1)){
doLog(ERROR, "Unable to create barrier for threads");
exit(IO_ERROR_CODE);
}
// define matrix divisions
subtasks = buildMatrixDivisions(numRows, numCols, numThreads, division);
// update plate values
doLog(DEBUG, "starting threads");
for(i=0; i < numThreads; i++){
// assign plates
subtasks[i].barrier = barrier;
subtasks[i].oldPlate = oldPlate;
subtasks[i].timeResult = timeResult;
subtasks[i].currentPlate = currentPlate;
subtasks[i].numIterations = numIterations;
// invoke thread except for main thread (last)
if(i < (numThreads-1)){
pthread_create(&(threadIds[i]), NULL, calculateSubMatrix, (void *) &(subtasks[i]));
}
}
// run application for main thread
calculateSubMatrix((void *) &(subtasks[numThreads-1]));
// wait for threads
doLog(DEBUG, "waiting for threads to finish");
for(i=0; i < (numThreads-1); i++){
pthread_join(threadIds[i], NULL);
}
// measure total time
timeResult->totaltime = measureTime();
// measure total time
timeResult->numThreads = numThreads;
timeResult->totaltime = measureTime() - timeResult->totaltime;
if(LOG_LEVEL == DEBUG){
printPlate(oldPlate);
}
doLog(DEBUG, "ending paralell simulation");
}
void waitForFinishCalculation(MatrixSubTaskRef threadArgs){
doLog(DEBUG, "waiting for threads");
int ret = pthread_barrier_wait(&(threadArgs->barrier));
if( (0 != ret) && (PTHREAD_BARRIER_SERIAL_THREAD != ret) ){
doLog(ERROR, "Unable to wait for barrier for threads");
exit(IO_ERROR_CODE);
}
doLog(DEBUG, "finished wait for threads");
}
void * calculateSubMatrix(void* arg){
Value newValue;
int i, j, iteration;
PlateRef switchPlate;
long iterationTime = 0;
MatrixSubTaskRef threadArgs = (MatrixSubTaskRef) arg;
doLog(INFO, "calculating submatrix");
// update num iterations times
for(iteration=0; iteration < threadArgs->numIterations; iteration++){
doLog(INFO, "new iteration");
// measure iteration time
iterationTime = measureTime();
for(i=threadArgs->fromRow; i <= threadArgs->toRow; i++){
for(j=threadArgs->fromCol; j <= threadArgs->toCol; j++){
if(isHole(threadArgs->oldPlate, i, j)){
setPlateValue(threadArgs->currentPlate, i, j, HOLE_VALUE);
continue;
}
newValue = calculateNewTemperature(threadArgs->oldPlate, i, j);
setPlateValue(threadArgs->currentPlate, i, j, newValue);
}
}
// switch plates
doLog(DEBUG, "switching plates");
switchPlate = threadArgs->oldPlate;
threadArgs->oldPlate = threadArgs->currentPlate;
threadArgs->currentPlate = switchPlate;
// measure iteration time
iterationTime = measureTime() - iterationTime;
threadArgs->timeResult->times[iteration] = iterationTime;
// wait for all threads to start the calculation (between iterations)
if (iteration < (threadArgs->numIterations-1)){
waitForFinishCalculation(threadArgs);
}
doLog(INFO, "finished iteration");
}
}
| 27.021834 | 139 | 0.712993 |
083bf93803fb5d43cebe49a82bb4bc7ebf65209c | 1,697 | c | C | src/math/fixed/rounding.c | LexouDuck/libft | af06b5b8f0ac51e1a461cbe58a7be6410c4348d5 | [
"MIT"
] | 6 | 2021-02-09T08:50:35.000Z | 2021-09-15T14:29:31.000Z | src/math/fixed/rounding.c | LexouDuck/libccc | 73a923a484ceb1fa6eaa863a151614d1327b4af8 | [
"MIT"
] | 16 | 2021-03-13T23:13:35.000Z | 2022-03-29T08:42:14.000Z | src/math/fixed/rounding.c | LexouDuck/libccc | 73a923a484ceb1fa6eaa863a151614d1327b4af8 | [
"MIT"
] | 2 | 2020-06-09T03:10:56.000Z | 2020-11-04T12:40:04.000Z |
#include "libccc/fixed.h"
#include "libccc/math/fixed.h"
#include "libccc/math/math.h"
#include LIBCONFIG_ERROR_INCLUDE
#define DEFINEFUNC_FIXED_ROUND(BITS) \
inline t_q##BITS Q##BITS##_Round(t_q##BITS number) \
{ \
t_q##BITS fraction = Q##BITS##_FractionPart(number); \
if (fraction < FIXED_DENOMINATOR / 2) \
return (number - fraction); \
else return (number + (FIXED_DENOMINATOR - fraction)); \
}
#define DEFINEFUNC_FIXED_TRUNC(BITS) \
inline t_q##BITS Q##BITS##_Truncate(t_q##BITS number) \
{ \
return (number & ~Q##BITS##_FractionPart(number)); \
} // TODO test this
#define DEFINEFUNC_FIXED_FLOOR(BITS) \
inline t_q##BITS Q##BITS##_Floor(t_q##BITS number) \
{ \
return ((number < 0) ? \
(number + Q##BITS##_FractionPart(number)) : \
(number - Q##BITS##_FractionPart(number))); \
} // TODO test this
#define DEFINEFUNC_FIXED_CEIL(BITS) \
inline t_q##BITS Q##BITS##_Ceiling(t_q##BITS number) \
{ \
return ((number < 0) ? \
(number - (FIXED_DENOMINATOR - Q##BITS##_FractionPart(number))) : \
(number + (FIXED_DENOMINATOR - Q##BITS##_FractionPart(number)))); \
} // TODO test this
DEFINEFUNC_FIXED_ROUND( 16)
DEFINEFUNC_FIXED_TRUNC( 16)
DEFINEFUNC_FIXED_FLOOR( 16)
DEFINEFUNC_FIXED_CEIL( 16)
DEFINEFUNC_FIXED_ROUND( 32)
DEFINEFUNC_FIXED_TRUNC( 32)
DEFINEFUNC_FIXED_FLOOR( 32)
DEFINEFUNC_FIXED_CEIL( 32)
DEFINEFUNC_FIXED_ROUND( 64)
DEFINEFUNC_FIXED_TRUNC( 64)
DEFINEFUNC_FIXED_FLOOR( 64)
DEFINEFUNC_FIXED_CEIL( 64)
#ifdef __int128
DEFINEFUNC_FIXED_ROUND( 128)
DEFINEFUNC_FIXED_TRUNC( 128)
DEFINEFUNC_FIXED_FLOOR( 128)
DEFINEFUNC_FIXED_CEIL( 128)
#endif
| 24.242857 | 69 | 0.681202 |
bd5be3dd38feaa24858daf587a72180dd7f4900e | 770 | h | C | TrainingGround/src/third_party/rapid_json_test.h | elloop/algorithm | 5485be0aedbc18968f775cff9533a2d444dbdcb5 | [
"MIT"
] | 15 | 2015-11-04T12:53:23.000Z | 2021-08-10T09:53:12.000Z | TrainingGround/src/third_party/rapid_json_test.h | elloop/algorithm | 5485be0aedbc18968f775cff9533a2d444dbdcb5 | [
"MIT"
] | null | null | null | TrainingGround/src/third_party/rapid_json_test.h | elloop/algorithm | 5485be0aedbc18968f775cff9533a2d444dbdcb5 | [
"MIT"
] | 6 | 2015-11-13T10:17:01.000Z | 2020-05-14T07:25:48.000Z | #pragma once
#include "inc.h"
#include "rapidjson/document.h"
#include <string>
NS_BEGIN(elloop);
NS_BEGIN(third_party);
class RapidJsonUtil {
public:
static const char * getString(rapidjson::Value& value, const std::string& key) {
if (value.IsObject()) {
if (value.HasMember(key.c_str()) && value[key.c_str()].IsString()) {
return value[key.c_str()].GetString();
}
}
return "";
//return (value.HasMember(key.c_str()) && value[key.c_str()].IsString()) ? value[key.c_str()].IsString() : "";
}
/*static const char * getString(rapidjson::Value& value, const std::string& key) {
return value.IsString() ? value.GetString() : "";
}*/
};
NS_END(third_party);
NS_END(elloop); | 26.551724 | 118 | 0.6 |
3209a9a6feb8f381e80a5a1de81764ddaa2ffd69 | 23,164 | h | C | include/urweb/urweb_cpp.h | mdempsky/urweb | 026883de8a8c80a1dc5fa3e51a95e951db4b2b6a | [
"BSD-3-Clause"
] | 5 | 2016-05-24T14:21:55.000Z | 2020-11-02T18:38:27.000Z | include/urweb/urweb_cpp.h | mdempsky/urweb | 026883de8a8c80a1dc5fa3e51a95e951db4b2b6a | [
"BSD-3-Clause"
] | null | null | null | include/urweb/urweb_cpp.h | mdempsky/urweb | 026883de8a8c80a1dc5fa3e51a95e951db4b2b6a | [
"BSD-3-Clause"
] | 3 | 2020-11-02T18:38:28.000Z | 2020-12-09T16:15:37.000Z | #ifndef URWEB_CPP_H
#define URWEB_CPP_H
#include <sys/types.h>
#include "types_cpp.h"
int uw_really_send(int sock, const void *buf, ssize_t len);
int uw_really_write(int fd, const void *buf, size_t len);
extern uw_unit uw_unit_v;
void uw_global_init(void);
void uw_app_init(uw_app*);
void uw_client_connect(unsigned id, int pass, int sock,
int (*send)(int sockfd, const void *buf, ssize_t len),
int (*close)(int fd),
void *logger_data, uw_logger log_error);
void uw_prune_clients(struct uw_context *);
failure_kind uw_initialize(struct uw_context *);
struct uw_context * uw_init(int id, uw_loggers *lg);
void uw_close(struct uw_context *);
int uw_set_app(struct uw_context *, uw_app*);
uw_app *uw_get_app(struct uw_context *);
void uw_set_db(struct uw_context *, void*);
void *uw_get_db(struct uw_context *);
void uw_free(struct uw_context *);
void uw_reset(struct uw_context *);
void uw_reset_keep_request(struct uw_context *);
void uw_reset_keep_error_message(struct uw_context *);
char *uw_get_url_prefix(struct uw_context *);
failure_kind uw_begin_init(struct uw_context *);
void uw_set_on_success(char *);
void uw_set_headers(struct uw_context *, char *(*get_header)(void *, const char *), void *get_header_data);
void uw_set_env(struct uw_context *, char *(*get_env)(void *, const char *), void *get_env_data);
uw_loggers* uw_get_loggers(struct uw_context *ctx);
uw_loggers* uw_get_loggers(struct uw_context *ctx);
failure_kind uw_begin(struct uw_context *, char *path);
void uw_ensure_transaction(struct uw_context *);
void uw_try_reconnecting_and_restarting(struct uw_context *);
failure_kind uw_begin_onError(struct uw_context *, char *msg);
void uw_login(struct uw_context *);
int uw_commit(struct uw_context *);
// ^-- returns nonzero if the transaction should be restarted
int uw_rollback(struct uw_context *, int will_retry);
__attribute__((noreturn)) void uw_error(struct uw_context *, failure_kind, const char *fmt, ...);
char *uw_error_message(struct uw_context *);
void uw_set_error_message(struct uw_context *, const char *fmt, ...);
uw_Basis_string uw_dup_and_clear_error_message(struct uw_context *);
int uw_has_error(struct uw_context *);
void uw_push_cleanup(struct uw_context *, void (*func)(void *), void *arg);
void uw_pop_cleanup(struct uw_context *);
void *uw_malloc(struct uw_context *, size_t);
void uw_begin_region(struct uw_context *);
void uw_end_region(struct uw_context *);
void uw_memstats(struct uw_context *);
int uw_send(struct uw_context *, int sock);
int uw_print(struct uw_context *, int fd);
int uw_output(struct uw_context * ctx, int (*output)(void *data, const char *buf, size_t len), void *data);
int uw_pagelen(struct uw_context *);
int uw_set_input(struct uw_context *, const char *name, char *value);
int uw_set_file_input(struct uw_context *, char *name, uw_Basis_file);
char *uw_get_input(struct uw_context *, int name);
char *uw_get_optional_input(struct uw_context *, int name);
uw_Basis_file uw_get_file_input(struct uw_context *, int name);
void uw_enter_subform(struct uw_context *, int name);
void uw_leave_subform(struct uw_context *);
int uw_enter_subforms(struct uw_context *, int name);
int uw_next_entry(struct uw_context *);
void uw_write(struct uw_context *, const char*);
// For caching.
void uw_recordingStart(struct uw_context *);
char *uw_recordingRead(struct uw_context *);
char *uw_recordingReadScript(struct uw_context *);
uw_Basis_source uw_Basis_new_client_source(struct uw_context *, uw_Basis_string);
uw_unit uw_Basis_set_client_source(struct uw_context *, uw_Basis_source, uw_Basis_string);
void uw_set_script_header(struct uw_context *, const char*);
char *uw_Basis_get_settings(struct uw_context *, uw_unit);
char *uw_get_real_script(struct uw_context *);
uw_Basis_string uw_Basis_maybe_onload(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_maybe_onunload(struct uw_context *, uw_Basis_string);
void uw_set_needs_push(struct uw_context *, int);
void uw_set_needs_sig(struct uw_context *, int);
void uw_set_could_write_db(struct uw_context *, int);
void uw_set_at_most_one_query(struct uw_context *, int);
char *uw_Basis_htmlifyInt(struct uw_context *, uw_Basis_int);
char *uw_Basis_htmlifyFloat(struct uw_context *, uw_Basis_float);
char *uw_Basis_htmlifyString(struct uw_context *, uw_Basis_string);
char *uw_Basis_htmlifyBool(struct uw_context *, uw_Basis_bool);
char *uw_Basis_htmlifyTime(struct uw_context *, uw_Basis_time);
char *uw_Basis_htmlifySpecialChar(struct uw_context *, uw_Basis_char);
char *uw_Basis_htmlifySource(struct uw_context *, uw_Basis_source);
uw_unit uw_Basis_htmlifyInt_w(struct uw_context *, uw_Basis_int);
uw_unit uw_Basis_htmlifyFloat_w(struct uw_context *, uw_Basis_float);
uw_unit uw_Basis_htmlifyString_w(struct uw_context *, uw_Basis_string);
uw_unit uw_Basis_htmlifyBool_w(struct uw_context *, uw_Basis_bool);
uw_unit uw_Basis_htmlifyTime_w(struct uw_context *, uw_Basis_time);
uw_unit uw_Basis_htmlifySpecialChar_w(struct uw_context *, uw_Basis_char);
uw_unit uw_Basis_htmlifySource_w(struct uw_context *, uw_Basis_source);
char *uw_Basis_attrifyInt(struct uw_context *, uw_Basis_int);
char *uw_Basis_attrifyFloat(struct uw_context *, uw_Basis_float);
char *uw_Basis_attrifyString(struct uw_context *, uw_Basis_string);
char *uw_Basis_attrifyChar(struct uw_context *, uw_Basis_char);
char *uw_Basis_attrifyTime(struct uw_context *, uw_Basis_time);
char *uw_Basis_attrifyChannel(struct uw_context *, uw_Basis_channel);
char *uw_Basis_attrifyClient(struct uw_context *, uw_Basis_client);
char *uw_Basis_attrifyCss_class(struct uw_context *, uw_Basis_css_class);
uw_unit uw_Basis_attrifyInt_w(struct uw_context *, uw_Basis_int);
uw_unit uw_Basis_attrifyFloat_w(struct uw_context *, uw_Basis_float);
uw_unit uw_Basis_attrifyString_w(struct uw_context *, uw_Basis_string);
uw_unit uw_Basis_attrifyChar_w(struct uw_context *, uw_Basis_char);
char *uw_Basis_urlifyInt(struct uw_context *, uw_Basis_int);
char *uw_Basis_urlifyFloat(struct uw_context *, uw_Basis_float);
char *uw_Basis_urlifyString(struct uw_context *, uw_Basis_string);
char *uw_Basis_urlifyBool(struct uw_context *, uw_Basis_bool);
char *uw_Basis_urlifyTime(struct uw_context *, uw_Basis_time);
char *uw_Basis_urlifyChannel(struct uw_context *, uw_Basis_channel);
char *uw_Basis_urlifySource(struct uw_context *, uw_Basis_source);
uw_unit uw_Basis_urlifyInt_w(struct uw_context *, uw_Basis_int);
uw_unit uw_Basis_urlifyFloat_w(struct uw_context *, uw_Basis_float);
uw_unit uw_Basis_urlifyChar_w(struct uw_context *, uw_Basis_char);
uw_unit uw_Basis_urlifyString_w(struct uw_context *, uw_Basis_string);
uw_unit uw_Basis_urlifyBool_w(struct uw_context *, uw_Basis_bool);
uw_unit uw_Basis_urlifyTime_w(struct uw_context *, uw_Basis_time);
uw_unit uw_Basis_urlifyChannel_w(struct uw_context *, uw_Basis_channel);
uw_unit uw_Basis_urlifySource_w(struct uw_context *, uw_Basis_source);
uw_Basis_unit uw_Basis_unurlifyUnit(struct uw_context * ctx, char **s);
uw_Basis_int uw_Basis_unurlifyInt(struct uw_context *, char **);
uw_Basis_float uw_Basis_unurlifyFloat(struct uw_context *, char **);
uw_Basis_string uw_Basis_unurlifyString(struct uw_context *, char **);
uw_Basis_char uw_Basis_unurlifyChar(struct uw_context *, char **);
uw_Basis_string uw_Basis_unurlifyString_fromClient(struct uw_context *, char **);
uw_Basis_bool uw_Basis_unurlifyBool(struct uw_context *, char **);
uw_Basis_time uw_Basis_unurlifyTime(struct uw_context *, char **);
uw_Basis_int uw_Basis_strlen(struct uw_context *, const char *);
uw_Basis_bool uw_Basis_strlenGe(struct uw_context *, uw_Basis_string, uw_Basis_int);
uw_Basis_char uw_Basis_strsub(struct uw_context *, const char *, uw_Basis_int);
uw_Basis_string uw_Basis_strsuffix(struct uw_context *, const char *, uw_Basis_int);
uw_Basis_string uw_Basis_strcat(struct uw_context *, const char *, const char *);
uw_Basis_string uw_Basis_mstrcat(struct uw_context * ctx, ...);
uw_Basis_int *uw_Basis_strindex(struct uw_context *, const char *, uw_Basis_char);
uw_Basis_int *uw_Basis_strsindex(struct uw_context *, const char *, const char *needle);
uw_Basis_string uw_Basis_strchr(struct uw_context *, const char *, uw_Basis_char);
uw_Basis_int uw_Basis_strcspn(struct uw_context *, const char *, const char *);
uw_Basis_string uw_Basis_substring(struct uw_context *, const char *, uw_Basis_int, uw_Basis_int);
uw_Basis_string uw_Basis_str1(struct uw_context *, uw_Basis_char);
uw_Basis_string uw_Basis_ofUnicode(struct uw_context *, uw_Basis_int);
uw_Basis_string uw_strdup(struct uw_context *, const char *);
uw_Basis_string uw_maybe_strdup(struct uw_context *, const char *);
char *uw_memdup(struct uw_context *, const char *, size_t);
uw_Basis_string uw_Basis_sqlifyInt(struct uw_context *, uw_Basis_int);
uw_Basis_string uw_Basis_sqlifyFloat(struct uw_context *, uw_Basis_float);
uw_Basis_string uw_Basis_sqlifyString(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_sqlifyChar(struct uw_context *, uw_Basis_char);
uw_Basis_string uw_Basis_sqlifyBool(struct uw_context *, uw_Basis_bool);
uw_Basis_string uw_Basis_sqlifyTime(struct uw_context *, uw_Basis_time);
uw_Basis_string uw_Basis_sqlifyBlob(struct uw_context *, uw_Basis_blob);
uw_Basis_string uw_Basis_sqlifyChannel(struct uw_context *, uw_Basis_channel);
uw_Basis_string uw_Basis_sqlifyClient(struct uw_context *, uw_Basis_client);
uw_Basis_string uw_Basis_sqlifyIntN(struct uw_context *, uw_Basis_int*);
uw_Basis_string uw_Basis_sqlifyFloatN(struct uw_context *, uw_Basis_float*);
uw_Basis_string uw_Basis_sqlifyStringN(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_sqlifyBoolN(struct uw_context *, uw_Basis_bool*);
uw_Basis_string uw_Basis_sqlifyTimeN(struct uw_context *, uw_Basis_time*);
char *uw_Basis_ensqlBool(uw_Basis_bool);
char *uw_Basis_ensqlTime(struct uw_context * ctx, uw_Basis_time);
char *uw_Basis_jsifyString(struct uw_context *, uw_Basis_string);
char *uw_Basis_jsifyChar(struct uw_context *, uw_Basis_char);
char *uw_Basis_jsifyChannel(struct uw_context *, uw_Basis_channel);
char *uw_Basis_jsifyTime(struct uw_context *, uw_Basis_time);
uw_Basis_string uw_Basis_intToString(struct uw_context *, uw_Basis_int);
uw_Basis_string uw_Basis_floatToString(struct uw_context *, uw_Basis_float);
uw_Basis_string uw_Basis_charToString(struct uw_context *, uw_Basis_char);
uw_Basis_string uw_Basis_boolToString(struct uw_context *, uw_Basis_bool);
uw_Basis_string uw_Basis_timeToString(struct uw_context *, uw_Basis_time);
uw_Basis_int *uw_Basis_stringToInt(struct uw_context *, uw_Basis_string);
uw_Basis_float *uw_Basis_stringToFloat(struct uw_context *, uw_Basis_string);
uw_Basis_char *uw_Basis_stringToChar(struct uw_context *, uw_Basis_string);
uw_Basis_bool *uw_Basis_stringToBool(struct uw_context *, uw_Basis_string);
uw_Basis_time *uw_Basis_stringToTime(struct uw_context *, const char *);
uw_Basis_int uw_Basis_stringToInt_error(struct uw_context *, uw_Basis_string);
uw_Basis_float uw_Basis_stringToFloat_error(struct uw_context *, uw_Basis_string);
uw_Basis_char uw_Basis_stringToChar_error(struct uw_context *, uw_Basis_string);
uw_Basis_bool uw_Basis_stringToBool_error(struct uw_context *, uw_Basis_string);
uw_Basis_time uw_Basis_stringToTime_error(struct uw_context *, const char *);
uw_Basis_blob uw_Basis_stringToBlob_error(struct uw_context *, uw_Basis_string, size_t);
uw_Basis_channel uw_Basis_stringToChannel_error(struct uw_context *, uw_Basis_string);
uw_Basis_client uw_Basis_stringToClient_error(struct uw_context *, uw_Basis_string);
uw_Basis_time uw_Basis_unsqlTime(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_requestHeader(struct uw_context *, uw_Basis_string);
void uw_write_header(struct uw_context *, uw_Basis_string);
void uw_clear_headers(struct uw_context *);
int uw_has_contentLength(struct uw_context *);
void uw_Basis_clear_page(struct uw_context *);
void uw_write_script(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_get_cookie(struct uw_context *, uw_Basis_string c);
uw_unit uw_Basis_set_cookie(struct uw_context *, uw_Basis_string prefix, uw_Basis_string c, uw_Basis_string v, uw_Basis_time *expires, uw_Basis_bool secure);
uw_unit uw_Basis_clear_cookie(struct uw_context *, uw_Basis_string prefix, uw_Basis_string c);
uw_Basis_channel uw_Basis_new_channel(struct uw_context *, uw_unit);
uw_unit uw_Basis_send(struct uw_context *, uw_Basis_channel, uw_Basis_string);
uw_Basis_client uw_Basis_self(struct uw_context *);
uw_Basis_string uw_Basis_bless(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_blessMime(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_blessRequestHeader(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_blessResponseHeader(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_blessEnvVar(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_blessMeta(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_checkUrl(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_anchorUrl(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_checkMime(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_checkRequestHeader(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_checkResponseHeader(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_checkEnvVar(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_checkMeta(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_getHeader(struct uw_context *, uw_Basis_string name);
uw_unit uw_Basis_setHeader(struct uw_context *, uw_Basis_string name, uw_Basis_string value);
uw_Basis_string uw_Basis_getenv(struct uw_context *, uw_Basis_string name);
uw_Basis_string uw_unnull(uw_Basis_string);
uw_Basis_string uw_Basis_makeSigString(struct uw_context *, uw_Basis_string);
int uw_streq(uw_Basis_string, uw_Basis_string);
uw_Basis_string uw_Basis_sigString(struct uw_context *, uw_unit);
uw_Basis_string uw_Basis_fileName(struct uw_context *, uw_Basis_file);
uw_Basis_string uw_Basis_fileMimeType(struct uw_context *, uw_Basis_file);
uw_Basis_blob uw_Basis_fileData(struct uw_context *, uw_Basis_file);
uw_Basis_int uw_Basis_blobSize(struct uw_context *, uw_Basis_blob);
uw_Basis_blob uw_Basis_textBlob(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_textOfBlob(struct uw_context *, uw_Basis_blob);
uw_Basis_string uw_Basis_postType(struct uw_context *, uw_Basis_postBody);
uw_Basis_string uw_Basis_postData(struct uw_context *, uw_Basis_postBody);
void uw_noPostBody(struct uw_context *);
void uw_postBody(struct uw_context *, uw_Basis_postBody);
int uw_hasPostBody(struct uw_context *);
uw_Basis_postBody uw_getPostBody(struct uw_context *);
void uw_mayReturnIndirectly(struct uw_context *);
__attribute__((noreturn)) void uw_return_blob(struct uw_context *, uw_Basis_blob, uw_Basis_string mimeType);
__attribute__((noreturn)) void uw_return_blob_from_page(struct uw_context *, uw_Basis_string mimeType);
__attribute__((noreturn)) void uw_redirect(struct uw_context *, uw_Basis_string url);
void uw_replace_page(struct uw_context *, const char *data, size_t size);
uw_Basis_time uw_Basis_now(struct uw_context *);
uw_Basis_time uw_Basis_addSeconds(struct uw_context *, uw_Basis_time, uw_Basis_int);
uw_Basis_int uw_Basis_diffInSeconds(struct uw_context *, uw_Basis_time, uw_Basis_time);
uw_Basis_int uw_Basis_toSeconds(struct uw_context *, uw_Basis_time);
uw_Basis_int uw_Basis_diffInMilliseconds(struct uw_context *, uw_Basis_time, uw_Basis_time);
uw_Basis_int uw_Basis_toMilliseconds(struct uw_context *, uw_Basis_time);
uw_Basis_time uw_Basis_fromMilliseconds(struct uw_context *, uw_Basis_int);
uw_Basis_time uw_Basis_fromDatetime(struct uw_context *, uw_Basis_int, uw_Basis_int, uw_Basis_int, uw_Basis_int, uw_Basis_int, uw_Basis_int);
uw_Basis_int uw_Basis_datetimeYear(struct uw_context *, uw_Basis_time);
uw_Basis_int uw_Basis_datetimeMonth(struct uw_context *, uw_Basis_time);
uw_Basis_int uw_Basis_datetimeDay(struct uw_context *, uw_Basis_time);
uw_Basis_int uw_Basis_datetimeHour(struct uw_context *, uw_Basis_time);
uw_Basis_int uw_Basis_datetimeMinute(struct uw_context *, uw_Basis_time);
uw_Basis_int uw_Basis_datetimeSecond(struct uw_context *, uw_Basis_time);
uw_Basis_int uw_Basis_datetimeDayOfWeek(struct uw_context *, uw_Basis_time);
extern const uw_Basis_time uw_Basis_minTime;
int uw_register_transactional(struct uw_context *, void *data, uw_callback commit, uw_callback rollback, uw_callback_with_retry free);
void uw_check_heap(struct uw_context *, size_t extra);
char *uw_heap_front(struct uw_context *);
void uw_set_heap_front(struct uw_context *, char*);
uw_Basis_string uw_Basis_unAs(struct uw_context *, uw_Basis_string);
extern char *uw_sqlfmtInt;
extern char *uw_sqlfmtFloat;
extern int uw_Estrings, uw_sql_type_annotations;
extern char *uw_sqlsuffixString;
extern char *uw_sqlsuffixChar;
extern char *uw_sqlsuffixBlob;
extern char *uw_sqlfmtUint4;
void *uw_get_global(struct uw_context *, char *name);
void uw_set_global(struct uw_context *, char *name, void *data, uw_callback free);
uw_Basis_bool uw_Basis_isalnum(struct uw_context *, uw_Basis_char);
uw_Basis_bool uw_Basis_isalpha(struct uw_context *, uw_Basis_char);
uw_Basis_bool uw_Basis_isblank(struct uw_context *, uw_Basis_char);
uw_Basis_bool uw_Basis_iscntrl(struct uw_context *, uw_Basis_char);
uw_Basis_bool uw_Basis_isdigit(struct uw_context *, uw_Basis_char);
uw_Basis_bool uw_Basis_isgraph(struct uw_context *, uw_Basis_char);
uw_Basis_bool uw_Basis_islower(struct uw_context *, uw_Basis_char);
uw_Basis_bool uw_Basis_isprint(struct uw_context *, uw_Basis_char);
uw_Basis_bool uw_Basis_ispunct(struct uw_context *, uw_Basis_char);
uw_Basis_bool uw_Basis_isspace(struct uw_context *, uw_Basis_char);
uw_Basis_bool uw_Basis_isupper(struct uw_context *, uw_Basis_char);
uw_Basis_bool uw_Basis_isxdigit(struct uw_context *, uw_Basis_char);
uw_Basis_char uw_Basis_tolower(struct uw_context *, uw_Basis_char);
uw_Basis_char uw_Basis_toupper(struct uw_context *, uw_Basis_char);
uw_Basis_bool uw_Basis_iscodepoint(struct uw_context *, uw_Basis_int);
uw_Basis_int uw_Basis_ord(struct uw_context *, uw_Basis_char);
uw_Basis_char uw_Basis_chr(struct uw_context *, uw_Basis_int);
uw_Basis_string uw_Basis_currentUrl(struct uw_context *);
void uw_set_currentUrl(struct uw_context *, char *);
extern size_t uw_messages_max, uw_clients_max, uw_headers_max, uw_page_max, uw_heap_max, uw_script_max;
extern size_t uw_inputs_max, uw_cleanup_max, uw_subinputs_max, uw_deltas_max, uw_transactionals_max, uw_globals_max;
extern size_t uw_database_max;
extern int uw_time;
void uw_set_deadline(struct uw_context *, int);
void uw_check_deadline(struct uw_context *);
uw_Basis_unit uw_Basis_debug(struct uw_context *, uw_Basis_string);
uw_Basis_int uw_Basis_naughtyDebug(struct uw_context *, uw_Basis_string);
void uw_set_client_data(struct uw_context *, void *);
uw_Basis_int uw_Basis_rand(struct uw_context *);
extern int uw_time_max, uw_supports_direct_status, uw_min_heap;
failure_kind uw_runCallback(struct uw_context *, void (*callback)(struct uw_context *));
uw_Basis_string uw_Basis_timef(struct uw_context *, const char *fmt, uw_Basis_time);
uw_Basis_time uw_Basis_stringToTimef(struct uw_context *, const char *fmt, uw_Basis_string);
uw_Basis_time uw_Basis_stringToTimef_error(struct uw_context *, const char *fmt, uw_Basis_string);
uw_Basis_bool uw_Basis_eq_time(struct uw_context *, uw_Basis_time, uw_Basis_time);
uw_Basis_bool uw_Basis_lt_time(struct uw_context *, uw_Basis_time, uw_Basis_time);
uw_Basis_bool uw_Basis_le_time(struct uw_context *, uw_Basis_time, uw_Basis_time);
void uw_buffer_init(size_t max, uw_buffer *, size_t initial);
void uw_buffer_free(uw_buffer *);
void uw_buffer_reset(uw_buffer *);
int uw_buffer_check(uw_buffer *, size_t extra);
size_t uw_buffer_used(uw_buffer *);
size_t uw_buffer_avail(uw_buffer *);
int uw_buffer_append(uw_buffer *, const char *, size_t);
void uw_setQueryString(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_queryString(struct uw_context *);
uw_Basis_time *uw_Basis_readUtc(struct uw_context *, uw_Basis_string);
void uw_isPost(struct uw_context *);
uw_Basis_bool uw_Basis_currentUrlHasPost(struct uw_context *);
uw_Basis_bool uw_Basis_currentUrlHasQueryString(struct uw_context *);
uw_Basis_string uw_Basis_fresh(struct uw_context *);
uw_Basis_float uw_Basis_floatFromInt(struct uw_context *, uw_Basis_int);
uw_Basis_int uw_Basis_ceil(struct uw_context *, uw_Basis_float);
uw_Basis_int uw_Basis_trunc(struct uw_context *, uw_Basis_float);
uw_Basis_int uw_Basis_round(struct uw_context *, uw_Basis_float);
uw_Basis_int uw_Basis_floor(struct uw_context *, uw_Basis_float);
uw_Basis_float uw_Basis_pow(struct uw_context *, uw_Basis_float, uw_Basis_float);
uw_Basis_float uw_Basis_sqrt(struct uw_context *, uw_Basis_float);
uw_Basis_float uw_Basis_sin(struct uw_context *, uw_Basis_float);
uw_Basis_float uw_Basis_cos(struct uw_context *, uw_Basis_float);
uw_Basis_float uw_Basis_log(struct uw_context *, uw_Basis_float);
uw_Basis_float uw_Basis_exp(struct uw_context *, uw_Basis_float);
uw_Basis_float uw_Basis_asin(struct uw_context *, uw_Basis_float);
uw_Basis_float uw_Basis_acos(struct uw_context *, uw_Basis_float);
uw_Basis_float uw_Basis_atan(struct uw_context *, uw_Basis_float);
uw_Basis_float uw_Basis_atan2(struct uw_context *, uw_Basis_float, uw_Basis_float);
uw_Basis_float uw_Basis_abs(struct uw_context *, uw_Basis_float);
uw_Basis_string uw_Basis_atom(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_css_url(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_property(struct uw_context *, uw_Basis_string);
void uw_begin_initializing(struct uw_context *);
void uw_end_initializing(struct uw_context *);
uw_Basis_string uw_Basis_fieldName(struct uw_context *, uw_Basis_postField);
uw_Basis_string uw_Basis_fieldValue(struct uw_context *, uw_Basis_postField);
uw_Basis_string uw_Basis_remainingFields(struct uw_context *, uw_Basis_postField);
uw_Basis_postField *uw_Basis_firstFormField(struct uw_context *, uw_Basis_string);
uw_Basis_string uw_Basis_blessData(struct uw_context *, uw_Basis_string);
extern const char uw_begin_xhtml[], uw_begin_html5[];
int uw_remoteSock(struct uw_context *);
void uw_set_remoteSock(struct uw_context *, int sock);
void uw_Basis_writec(struct uw_context *, char);
// Sqlcache.
void *uw_Sqlcache_rlock(struct uw_context *, uw_Sqlcache_Cache *);
void *uw_Sqlcache_wlock(struct uw_context *, uw_Sqlcache_Cache *);
uw_Sqlcache_Value *uw_Sqlcache_check(struct uw_context *, uw_Sqlcache_Cache *, char **);
void *uw_Sqlcache_store(struct uw_context *, uw_Sqlcache_Cache *, char **, uw_Sqlcache_Value *);
void *uw_Sqlcache_flush(struct uw_context *, uw_Sqlcache_Cache *, char **);
int strcmp_nullsafe(const char *, const char *);
uw_unit uw_Basis_cache_file(struct uw_context *, uw_Basis_blob contents);
uw_Basis_blob uw_Basis_check_filecache(struct uw_context *, uw_Basis_string hash);
uw_Basis_bool uw_Basis_filecache_missed(struct uw_context *);
#endif
| 52.171171 | 157 | 0.829045 |
9a61bc88b61ecce0e881df965f10a93e05f86985 | 1,676 | h | C | stm32/libraries/SdFat/src/FreeStack.h | BSFrance/BSFrance | db1da987a84a60f568c5a4c79635d596e8ceb88b | [
"MIT"
] | 8 | 2018-02-23T18:48:24.000Z | 2021-02-13T23:57:27.000Z | stm32/libraries/SdFat/src/FreeStack.h | BSFrance/BSFrance | db1da987a84a60f568c5a4c79635d596e8ceb88b | [
"MIT"
] | 5 | 2018-09-17T00:53:08.000Z | 2018-12-30T22:02:41.000Z | stm32/libraries/SdFat/src/FreeStack.h | BSFrance/BSFrance | db1da987a84a60f568c5a4c79635d596e8ceb88b | [
"MIT"
] | 4 | 2018-05-01T14:53:34.000Z | 2021-04-06T12:31:05.000Z | /* Arduino SdFat Library
* Copyright (C) 2015 by William Greiman
*
* This file is part of the Arduino SdFat Library
*
* 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.
*
* 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.
* You should have received a copy of the GNU General Public License
* along with the Arduino SdFat Library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef FreeStack_h
#define FreeStack_h
/**
* \file
* \brief FreeStack() function.
*/
#if defined(__AVR__) || defined(DOXYGEN)
/** boundary between stack and heap. */
extern char *__brkval;
/** End of bss section.*/
extern char __bss_end;
/** Amount of free stack space.
* \return The number of free bytes.
*/
static int FreeStack() {
char* sp = reinterpret_cast<char*>(SP);
return __brkval ? sp - __brkval : sp - &__bss_end;
// char top;
// return __brkval ? &top - __brkval : &top - &__bss_end;
}
#elif defined(PLATFORM_ID) // Particle board
static int FreeStack() {
return System.freeMemory();
}
#elif defined(__arm__)
extern "C" char* sbrk(int incr);
static int FreeStack() {
char top = 't';
return &top - reinterpret_cast<char*>(sbrk(0));
}
#else
#warning FreeStack is not defined for this system.
static int FreeStack() {
return 0;
}
#endif
#endif // FreeStack_h
| 29.403509 | 71 | 0.711217 |
9a95f5facf05b6b1860dd4b95eccfdc59daafbf0 | 1,496 | h | C | libtest/float/intel/LibTestHelper.h | jpl169/PLDI2021Artifact | 49cea72b2084ce265189881d7da69c8ed93a8f15 | [
"MIT"
] | null | null | null | libtest/float/intel/LibTestHelper.h | jpl169/PLDI2021Artifact | 49cea72b2084ce265189881d7da69c8ed93a8f15 | [
"MIT"
] | null | null | null | libtest/float/intel/LibTestHelper.h | jpl169/PLDI2021Artifact | 49cea72b2084ce265189881d7da69c8ed93a8f15 | [
"MIT"
] | null | null | null | #include "float_math.h"
#include "stdio.h"
#include "mathimf.h"
#include "stdlib.h"
float fMlibTest(float x);
float dMlibTest(float x);
float rlibmTest(float x);
void RunCorrectnessTest(char const* FunctionName, char* resFileName) {
unsigned long wrongFMlibCount = 0;
unsigned long wrongDMlibCount = 0;
unsigned long count = 0;
unsigned int maxUlpFMlib = 0;
unsigned int maxUlpDMlib = 0;
float maxXFMlib = 0;
float maxXDMlib = 0;
float x;
floatX xbase;
for (count = 0x0; count < 0x100000000; count++) {
xbase.x = count;
x = xbase.f;
float bres = rlibmTest(x);
float bfy = fMlibTest(x);
float bdy = dMlibTest(x);
// if bres is nan and bmy is nan, continue
if (bres != bres && bfy != bfy && bdy != bdy) continue;
if (bfy != bres) wrongFMlibCount++;
if (bdy != bres) wrongDMlibCount++;
}
FILE* f = fopen(resFileName, "w");
if (wrongFMlibCount == 0) {
fprintf(f, "Intel's float library correct result for all inputs\n");
} else {
fprintf(f, "Intel's float library: Found %lu/%lu inputs with wrong result\n", wrongFMlibCount, count);
}
if (wrongDMlibCount == 0) {
fprintf(f, "Intel's double library returns correct result for all inputs\n");
} else {
fprintf(f, "Intel's double library: Found %lu/%lu inputs with wrong result\n", wrongDMlibCount, count);
}
fclose(f);
}
| 28.226415 | 111 | 0.600267 |
89c796f5f9a7a73f8ab8d3a686b38448b574d224 | 2,135 | h | C | headless/lib/browser/policy/headless_mode_policy.h | iridium-browser/iridium-browser | 907e31cf5ce5ad14d832796e3a7c11e496828959 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 575 | 2015-06-18T23:58:20.000Z | 2022-03-23T09:32:39.000Z | headless/lib/browser/policy/headless_mode_policy.h | iridium-browser/iridium-browser | 907e31cf5ce5ad14d832796e3a7c11e496828959 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 113 | 2015-05-04T09:58:14.000Z | 2022-01-31T19:35:03.000Z | headless/lib/browser/policy/headless_mode_policy.h | iridium-browser/iridium-browser | 907e31cf5ce5ad14d832796e3a7c11e496828959 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 52 | 2015-07-14T10:40:50.000Z | 2022-03-15T01:11:49.000Z | // Copyright 2021 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 HEADLESS_LIB_BROWSER_POLICY_HEADLESS_MODE_POLICY_H_
#define HEADLESS_LIB_BROWSER_POLICY_HEADLESS_MODE_POLICY_H_
#include "components/policy/core/browser/configuration_policy_handler.h"
#include "headless/public/headless_export.h"
class PrefService;
class PrefRegistrySimple;
namespace prefs {
extern const char kHeadlessMode[];
}
namespace policy {
// Headless mode policy helpers.
class HEADLESS_EXPORT HeadlessModePolicy {
public:
// Headless mode as set by policy. The values must match the
// HeadlessMode policy template in
// components/policy/resources/policy_templates.json
enum class HeadlessMode {
// Headless mode is enabled.
kEnabled = 1,
// Headless mode is disabled.
kDisabled = 2,
// Default value to ensure consistency.
kDefaultValue = kEnabled,
// Min and max values for range checking.
kMinValue = kEnabled,
kMaxValue = kDisabled
};
// Registers headless mode policy prefs in |registry|.
static void RegisterLocalPrefs(PrefRegistrySimple* registry);
// Returns the current HeadlessMode policy according to the values in
// |pref_service|. If no HeadlessMode policy is set, the default will be
// |HeadlessMode::kEnabled|.
static HeadlessMode GetPolicy(const PrefService* pref_service);
// Returns positive if current HeadlessMode policy in |pref_service| is set to
// |HeadlessMode::kEnabled| or is unset.
static bool IsHeadlessDisabled(const PrefService* pref_service);
};
// Handles the HeadlessMode policy. Controls the managed values of the
// |kHeadlessMode| pref.
class HeadlessModePolicyHandler : public IntRangePolicyHandler {
public:
HeadlessModePolicyHandler();
~HeadlessModePolicyHandler() override;
HeadlessModePolicyHandler(const HeadlessModePolicyHandler&) = delete;
HeadlessModePolicyHandler& operator=(const HeadlessModePolicyHandler&) =
delete;
};
} // namespace policy
#endif // HEADLESS_LIB_BROWSER_POLICY_HEADLESS_MODE_POLICY_H_
| 32.348485 | 80 | 0.773302 |
d0fc598319a9b84d24d9a985b37f50871be70aaf | 2,045 | h | C | machine/qemu/sources/u-boot/include/configs/rk3399_common.h | muddessir/framework | 5b802b2dd7ec9778794b078e748dd1f989547265 | [
"MIT"
] | 1 | 2021-11-21T19:56:29.000Z | 2021-11-21T19:56:29.000Z | machine/qemu/sources/u-boot/include/configs/rk3399_common.h | muddessir/framework | 5b802b2dd7ec9778794b078e748dd1f989547265 | [
"MIT"
] | null | null | null | machine/qemu/sources/u-boot/include/configs/rk3399_common.h | muddessir/framework | 5b802b2dd7ec9778794b078e748dd1f989547265 | [
"MIT"
] | null | null | null | /* SPDX-License-Identifier: GPL-2.0+ */
/*
* (C) Copyright 2016 Rockchip Electronics Co., Ltd
*/
#ifndef __CONFIG_RK3399_COMMON_H
#define __CONFIG_RK3399_COMMON_H
#include "rockchip-common.h"
#define CONFIG_SYS_CBSIZE 1024
#define CONFIG_SKIP_LOWLEVEL_INIT
#define COUNTER_FREQUENCY 24000000
#define CONFIG_ROCKCHIP_STIMER_BASE 0xff8680a0
#define CONFIG_IRAM_BASE 0xff8c0000
#define CONFIG_SYS_INIT_SP_ADDR 0x00300000
#define CONFIG_SYS_LOAD_ADDR 0x00800800
#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_TPL_BOOTROM_SUPPORT)
#define CONFIG_SPL_STACK 0x00400000
#define CONFIG_SPL_MAX_SIZE 0x40000
#define CONFIG_SPL_BSS_START_ADDR 0x00400000
#define CONFIG_SPL_BSS_MAX_SIZE 0x2000
#else
#define CONFIG_SPL_STACK 0xff8effff
#define CONFIG_SPL_MAX_SIZE 0x30000 - 0x2000
/* BSS setup */
#define CONFIG_SPL_BSS_START_ADDR 0xff8e0000
#define CONFIG_SPL_BSS_MAX_SIZE 0x10000
#endif
#define CONFIG_SYS_BOOTM_LEN (64 << 20) /* 64M */
/* MMC/SD IP block */
#define CONFIG_ROCKCHIP_SDHCI_MAX_FREQ 200000000
/* RAW SD card / eMMC locations. */
/* FAT sd card locations. */
#define CONFIG_SYS_SDRAM_BASE 0
#define SDRAM_MAX_SIZE 0xf8000000
#ifndef CONFIG_SPL_BUILD
#define ENV_MEM_LAYOUT_SETTINGS \
"scriptaddr=0x00500000\0" \
"script_offset_f=0xffe000\0" \
"script_size_f=0x2000\0" \
"pxefile_addr_r=0x00600000\0" \
"fdt_addr_r=0x01f00000\0" \
"kernel_addr_r=0x02080000\0" \
"ramdisk_addr_r=0x06000000\0" \
"kernel_comp_addr_r=0x08000000\0" \
"kernel_comp_size=0x2000000\0"
#ifndef ROCKCHIP_DEVICE_SETTINGS
#define ROCKCHIP_DEVICE_SETTINGS
#endif
#include <config_distro_bootcmd.h>
#include <environment/distro/sf.h>
#define CONFIG_EXTRA_ENV_SETTINGS \
ENV_MEM_LAYOUT_SETTINGS \
"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
"partitions=" PARTS_DEFAULT \
ROCKCHIP_DEVICE_SETTINGS \
BOOTENV \
BOOTENV_SF \
"altbootcmd=" \
"setenv boot_syslinux_conf extlinux/extlinux-rollback.conf;" \
"run distro_bootcmd\0"
#endif
/* enable usb config for usb ether */
#endif
| 25.246914 | 68 | 0.776039 |
c5865b1f4f08d5bbcc4afe6cefe1d218902fa5cd | 9,781 | h | C | Modelica/Resources/C-Sources/exact-int.h | pkangowski/ModelicaStandardLibrary | 2dc388ba96088b98af1d9d0a3eb67432dfdfb164 | [
"BSD-3-Clause"
] | null | null | null | Modelica/Resources/C-Sources/exact-int.h | pkangowski/ModelicaStandardLibrary | 2dc388ba96088b98af1d9d0a3eb67432dfdfb164 | [
"BSD-3-Clause"
] | null | null | null | Modelica/Resources/C-Sources/exact-int.h | pkangowski/ModelicaStandardLibrary | 2dc388ba96088b98af1d9d0a3eb67432dfdfb164 | [
"BSD-3-Clause"
] | null | null | null | /* Exact-width integer types
* Portable Snippets - https://github.com/nemequ/portable-snippets
* Created by Evan Nemerson <evan@nemerson.com>
*
* To the extent possible under law, the authors have waived all
* copyright and related or neighboring rights to this code. For
* details, see the Creative Commons Zero 1.0 Universal license at
* https://creativecommons.org/publicdomain/zero/1.0/
*
* This header tries to define psnip_(u)int(8|16|32|64)_t to
* appropriate types given your system. For most systems this means
* including <stdint.h> and adding a few preprocessor definitions.
*
* If you prefer, you can define any necessary types yourself.
* Snippets in this repository which rely on these types will not
* attempt to include this header if you have already defined the
* types it uses.
*/
#if !defined(PSNIP_EXACT_INT_H)
# define PSNIP_EXACT_INT_H
# if !defined(PSNIP_EXACT_INT_HAVE_STDINT)
# if defined(_STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
# define PSNIP_EXACT_INT_HAVE_STDINT
# elif defined(__has_include)
# if __has_include(<stdint.h>)
# define PSNIP_EXACT_INT_HAVE_STDINT
# endif
# elif \
defined(HAVE_STDINT_H) || \
defined(_STDINT_H_INCLUDED) || \
defined(_STDINT_H) || \
defined(_STDINT_H_)
# define PSNIP_EXACT_INT_HAVE_STDINT
# elif \
(defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))) || \
(defined(_MSC_VER) && (_MSC_VER >= 1600)) || \
(defined(__SUNPRO_C) && (__SUNPRO_C >= 0x570)) || \
(defined(__WATCOMC__) && (__WATCOMC__ >= 1250))
# define PSNIP_EXACT_INT_HAVE_STDINT
# endif
# endif
# if \
defined(__INT8_TYPE__) && defined(__INT16_TYPE__) && defined(__INT32_TYPE__) && defined(__INT64_TYPE__) && \
defined(__UINT8_TYPE__) && defined(__UINT16_TYPE__) && defined(__UINT32_TYPE__) && defined(__UINT64_TYPE__)
# define psnip_int8_t __INT8_TYPE__
# define psnip_int16_t __INT16_TYPE__
# define psnip_int32_t __INT32_TYPE__
# define psnip_int64_t __INT64_TYPE__
# define psnip_uint8_t __UINT8_TYPE__
# define psnip_uint16_t __UINT16_TYPE__
# define psnip_uint32_t __UINT32_TYPE__
# define psnip_uint64_t __UINT64_TYPE__
# elif defined(PSNIP_EXACT_INT_HAVE_STDINT)
# include <stdint.h>
# if !defined(psnip_int8_t)
# define psnip_int8_t int8_t
# endif
# if !defined(psnip_uint8_t)
# define psnip_uint8_t uint8_t
# endif
# if !defined(psnip_int16_t)
# define psnip_int16_t int16_t
# endif
# if !defined(psnip_uint16_t)
# define psnip_uint16_t uint16_t
# endif
# if !defined(psnip_int32_t)
# define psnip_int32_t int32_t
# endif
# if !defined(psnip_uint32_t)
# define psnip_uint32_t uint32_t
# endif
# if !defined(psnip_int64_t)
# define psnip_int64_t int64_t
# endif
# if !defined(psnip_uint64_t)
# define psnip_uint64_t uint64_t
# endif
# elif defined(_MSC_VER)
# if !defined(psnip_int8_t)
# define psnip_int8_t __int8
# endif
# if !defined(psnip_uint8_t)
# define psnip_uint8_t unsigned __int8
# endif
# if !defined(psnip_int16_t)
# define psnip_int16_t __int16
# endif
# if !defined(psnip_uint16_t)
# define psnip_uint16_t unsigned __int16
# endif
# if !defined(psnip_int32_t)
# define psnip_int32_t __int32
# endif
# if !defined(psnip_uint32_t)
# define psnip_uint32_t unsigned __int32
# endif
# if !defined(psnip_int64_t)
# define psnip_int64_t __int64
# endif
# if !defined(psnip_uint64_t)
# define psnip_uint64_t unsigned __int64
# endif
# else
# include <limits.h>
# if !defined(psnip_int8_t)
# if defined(CHAR_MIN) && defined(CHAR_MAX) && (CHAR_MIN == (-127-1)) && (CHAR_MAX == 127)
# define psnip_int8_t char
# elif defined(SHRT_MIN) && defined(SHRT_MAX) && (SHRT_MIN == (-127-1)) && (SHRT_MAX == 127)
# define psnip_int8_t short
# elif defined(INT_MIN) && defined(INT_MAX) && (INT_MIN == (-127-1)) && (INT_MAX == 127)
# define psnip_int8_t int
# elif defined(LONG_MIN) && defined(LONG_MAX) && (LONG_MIN == (-127-1)) && (LONG_MAX == 127)
# define psnip_int8_t long
# elif defined(LLONG_MIN) && defined(LLONG_MAX) && (LLONG_MIN == (-127-1)) && (LLONG_MAX == 127)
# define psnip_int8_t long long
# else
# error Unable to locate 8-bit signed integer type.
# endif
# endif
# if !defined(psnip_uint8_t)
# if defined(UCHAR_MAX) && (UCHAR_MAX == 255)
# define psnip_uint8_t unsigned char
# elif defined(USHRT_MAX) && (USHRT_MAX == 255)
# define psnip_uint8_t unsigned short
# elif defined(UINT_MAX) && (UINT_MAX == 255)
# define psnip_uint8_t unsigned int
# elif defined(ULONG_MAX) && (ULONG_MAX == 255)
# define psnip_uint8_t unsigned long
# elif defined(ULLONG_MAX) && (ULLONG_MAX == 255)
# define psnip_uint8_t unsigned long long
# else
# error Unable to locate 8-bit unsigned integer type.
# endif
# endif
# if !defined(psnip_int16_t)
# if defined(CHAR_MIN) && defined(CHAR_MAX) && (CHAR_MIN == (-32767-1)) && (CHAR_MAX == 32767)
# define psnip_int16_t char
# elif defined(SHRT_MIN) && defined(SHRT_MAX) && (SHRT_MIN == (-32767-1)) && (SHRT_MAX == 32767)
# define psnip_int16_t short
# elif defined(INT_MIN) && defined(INT_MAX) && (INT_MIN == (-32767-1)) && (INT_MAX == 32767)
# define psnip_int16_t int
# elif defined(LONG_MIN) && defined(LONG_MAX) && (LONG_MIN == (-32767-1)) && (LONG_MAX == 32767)
# define psnip_int16_t long
# elif defined(LLONG_MIN) && defined(LLONG_MAX) && (LLONG_MIN == (-32767-1)) && (LLONG_MAX == 32767)
# define psnip_int16_t long long
# else
# error Unable to locate 16-bit signed integer type.
# endif
# endif
# if !defined(psnip_uint16_t)
# if defined(UCHAR_MAX) && (UCHAR_MAX == 65535)
# define psnip_uint16_t unsigned char
# elif defined(USHRT_MAX) && (USHRT_MAX == 65535)
# define psnip_uint16_t unsigned short
# elif defined(UINT_MAX) && (UINT_MAX == 65535)
# define psnip_uint16_t unsigned int
# elif defined(ULONG_MAX) && (ULONG_MAX == 65535)
# define psnip_uint16_t unsigned long
# elif defined(ULLONG_MAX) && (ULLONG_MAX == 65535)
# define psnip_uint16_t unsigned long long
# else
# error Unable to locate 16-bit unsigned integer type.
# endif
# endif
# if !defined(psnip_int32_t)
# if defined(CHAR_MIN) && defined(CHAR_MAX) && (CHAR_MIN == (-2147483647-1)) && (CHAR_MAX == 2147483647)
# define psnip_int32_t char
# elif defined(SHRT_MIN) && defined(SHRT_MAX) && (SHRT_MIN == (-2147483647-1)) && (SHRT_MAX == 2147483647)
# define psnip_int32_t short
# elif defined(INT_MIN) && defined(INT_MAX) && (INT_MIN == (-2147483647-1)) && (INT_MAX == 2147483647)
# define psnip_int32_t int
# elif defined(LONG_MIN) && defined(LONG_MAX) && (LONG_MIN == (-2147483647-1)) && (LONG_MAX == 2147483647)
# define psnip_int32_t long
# elif defined(LLONG_MIN) && defined(LLONG_MAX) && (LLONG_MIN == (-2147483647-1)) && (LLONG_MAX == 2147483647)
# define psnip_int32_t long long
# else
# error Unable to locate 32-bit signed integer type.
# endif
# endif
# if !defined(psnip_uint32_t)
# if defined(UCHAR_MAX) && (UCHAR_MAX == 4294967295)
# define psnip_uint32_t unsigned char
# elif defined(USHRT_MAX) && (USHRT_MAX == 4294967295)
# define psnip_uint32_t unsigned short
# elif defined(UINT_MAX) && (UINT_MAX == 4294967295)
# define psnip_uint32_t unsigned int
# elif defined(ULONG_MAX) && (ULONG_MAX == 4294967295)
# define psnip_uint32_t unsigned long
# elif defined(ULLONG_MAX) && (ULLONG_MAX == 4294967295)
# define psnip_uint32_t unsigned long long
# else
# error Unable to locate 32-bit unsigned integer type.
# endif
# endif
# if !defined(psnip_int64_t)
# if defined(CHAR_MIN) && defined(CHAR_MAX) && (CHAR_MIN == (-9223372036854775807LL-1)) && (CHAR_MAX == 9223372036854775807LL)
# define psnip_int64_t char
# elif defined(SHRT_MIN) && defined(SHRT_MAX) && (SHRT_MIN == (-9223372036854775807LL-1)) && (SHRT_MAX == 9223372036854775807LL)
# define psnip_int64_t short
# elif defined(INT_MIN) && defined(INT_MAX) && (INT_MIN == (-9223372036854775807LL-1)) && (INT_MAX == 9223372036854775807LL)
# define psnip_int64_t int
# elif defined(LONG_MIN) && defined(LONG_MAX) && (LONG_MIN == (-9223372036854775807LL-1)) && (LONG_MAX == 9223372036854775807LL)
# define psnip_int64_t long
# elif defined(LLONG_MIN) && defined(LLONG_MAX) && (LLONG_MIN == (-9223372036854775807LL-1)) && (LLONG_MAX == 9223372036854775807LL)
# define psnip_int64_t long long
# else
# error Unable to locate 64-bit signed integer type.
# endif
# endif
# if !defined(psnip_uint64_t)
# if defined(UCHAR_MAX) && (UCHAR_MAX == 18446744073709551615ULL)
# define psnip_uint64_t unsigned char
# elif defined(USHRT_MAX) && (USHRT_MAX == 18446744073709551615ULL)
# define psnip_uint64_t unsigned short
# elif defined(UINT_MAX) && (UINT_MAX == 18446744073709551615ULL)
# define psnip_uint64_t unsigned int
# elif defined(ULONG_MAX) && (ULONG_MAX == 18446744073709551615ULL)
# define psnip_uint64_t unsigned long
# elif defined(ULLONG_MAX) && (ULLONG_MAX == 18446744073709551615ULL)
# define psnip_uint64_t unsigned long long
# else
# error Unable to locate 64-bit unsigned integer type.
# endif
# endif
# endif
#endif
| 42.526087 | 137 | 0.666599 |
3057639e2c4ede44cba086641d793a434c45b0e3 | 841 | h | C | questions/47803531/splitdialgauge.h | sesu089/stackoverflow | 6fae69be6fa74fba9d554e6b5f387e5d3c1aad73 | [
"MIT"
] | 302 | 2017-03-04T00:05:23.000Z | 2022-03-28T22:51:29.000Z | questions/47803531/splitdialgauge.h | sesu089/stackoverflow | 6fae69be6fa74fba9d554e6b5f387e5d3c1aad73 | [
"MIT"
] | 30 | 2017-12-02T19:26:43.000Z | 2022-03-28T07:40:36.000Z | questions/47803531/splitdialgauge.h | sesu089/stackoverflow | 6fae69be6fa74fba9d554e6b5f387e5d3c1aad73 | [
"MIT"
] | 388 | 2017-07-04T16:53:12.000Z | 2022-03-18T22:20:19.000Z | #ifndef SPLITDIALGAUGE_H
#define SPLITDIALGAUGE_H
#include "limits_t.h"
#include <QPainter>
#include <QQuickPaintedItem>
class SplitDialGauge : public QQuickPaintedItem {
Q_OBJECT
Q_PROPERTY(
LIMITS_T *limits READ getLimits WRITE setLimits NOTIFY limitsChanged)
public:
SplitDialGauge(QQuickItem *parent = 0) : QQuickPaintedItem(parent) {}
void paint(QPainter *painter) {
painter->fillRect(contentsBoundingRect(), Qt::red);
// test
painter->drawRect(0, 0, limits->readMin(), limits->readMin());
}
LIMITS_T *getLimits() const { return limits; }
void setLimits(LIMITS_T *value) {
limits = value;
connect(limits, &LIMITS_T::minChanged, [this]() { update(); });
update();
emit limitsChanged();
}
private:
LIMITS_T *limits;
signals:
void limitsChanged();
};
#endif // SPLITDIALGAUGE_H
| 22.72973 | 75 | 0.702735 |
658dffd87644349d3be55efde00b7ee6365017b8 | 4,223 | h | C | PrivateFrameworks/GeoServices.framework/GEOPDVendorSpecificPlaceRefinementParameters.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | 36 | 2016-04-20T04:19:04.000Z | 2018-10-08T04:12:25.000Z | PrivateFrameworks/GeoServices.framework/GEOPDVendorSpecificPlaceRefinementParameters.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | null | null | null | PrivateFrameworks/GeoServices.framework/GEOPDVendorSpecificPlaceRefinementParameters.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | 10 | 2016-06-16T02:40:44.000Z | 2019-01-15T03:31:45.000Z | /* Generated by RuntimeBrowser
Image: /System/Library/PrivateFrameworks/GeoServices.framework/GeoServices
*/
@interface GEOPDVendorSpecificPlaceRefinementParameters : PBCodable <NSCopying> {
int _addressGeocodeAccuracyHint;
GEOStructuredAddress * _addressHint;
NSData * _addressObjectHint;
NSString * _externalItemId;
NSMutableArray * _formattedAddressLineHints;
struct {
unsigned int muid : 1;
unsigned int addressGeocodeAccuracyHint : 1;
unsigned int placeTypeHint : 1;
unsigned int resultProviderId : 1;
} _has;
GEOLatLng * _locationHint;
unsigned long long _muid;
NSString * _placeNameHint;
int _placeTypeHint;
int _resultProviderId;
NSString * _vendorId;
}
@property (nonatomic) int addressGeocodeAccuracyHint;
@property (nonatomic, retain) GEOStructuredAddress *addressHint;
@property (nonatomic, retain) NSData *addressObjectHint;
@property (nonatomic, retain) NSString *externalItemId;
@property (nonatomic, retain) NSMutableArray *formattedAddressLineHints;
@property (nonatomic) bool hasAddressGeocodeAccuracyHint;
@property (nonatomic, readonly) bool hasAddressHint;
@property (nonatomic, readonly) bool hasAddressObjectHint;
@property (nonatomic, readonly) bool hasExternalItemId;
@property (nonatomic, readonly) bool hasLocationHint;
@property (nonatomic) bool hasMuid;
@property (nonatomic, readonly) bool hasPlaceNameHint;
@property (nonatomic) bool hasPlaceTypeHint;
@property (nonatomic) bool hasResultProviderId;
@property (nonatomic, readonly) bool hasVendorId;
@property (nonatomic, retain) GEOLatLng *locationHint;
@property (nonatomic) unsigned long long muid;
@property (nonatomic, retain) NSString *placeNameHint;
@property (nonatomic) int placeTypeHint;
@property (nonatomic) int resultProviderId;
@property (nonatomic, retain) NSString *vendorId;
+ (Class)formattedAddressLineHintType;
- (int)StringAsAddressGeocodeAccuracyHint:(id)arg1;
- (int)StringAsPlaceTypeHint:(id)arg1;
- (void)addFormattedAddressLineHint:(id)arg1;
- (int)addressGeocodeAccuracyHint;
- (id)addressGeocodeAccuracyHintAsString:(int)arg1;
- (id)addressHint;
- (id)addressObjectHint;
- (void)clearFormattedAddressLineHints;
- (void)copyTo:(id)arg1;
- (id)copyWithZone:(struct _NSZone { }*)arg1;
- (void)dealloc;
- (id)description;
- (id)dictionaryRepresentation;
- (id)externalItemId;
- (id)formattedAddressLineHintAtIndex:(unsigned long long)arg1;
- (id)formattedAddressLineHints;
- (unsigned long long)formattedAddressLineHintsCount;
- (bool)hasAddressGeocodeAccuracyHint;
- (bool)hasAddressHint;
- (bool)hasAddressObjectHint;
- (bool)hasExternalItemId;
- (bool)hasLocationHint;
- (bool)hasMuid;
- (bool)hasPlaceNameHint;
- (bool)hasPlaceTypeHint;
- (bool)hasResultProviderId;
- (bool)hasVendorId;
- (unsigned long long)hash;
- (id)initWithExternalBusinessID:(id)arg1 contentProvider:(id)arg2;
- (id)initWithMapItemToRefine:(id)arg1 coordinate:(struct { double x1; double x2; })arg2 contentProvider:(id)arg3;
- (id)initWithMuid:(unsigned long long)arg1 locationHint:(struct { double x1; double x2; })arg2 placeNameHint:(id)arg3 resultProviderId:(int)arg4 contentProvider:(id)arg5;
- (id)initWithSearchURLQuery:(id)arg1 coordinate:(struct { double x1; double x2; })arg2 muid:(unsigned long long)arg3 resultProviderId:(int)arg4 contentProvider:(id)arg5;
- (bool)isEqual:(id)arg1;
- (id)locationHint;
- (void)mergeFrom:(id)arg1;
- (unsigned long long)muid;
- (id)placeNameHint;
- (int)placeTypeHint;
- (id)placeTypeHintAsString:(int)arg1;
- (bool)readFrom:(id)arg1;
- (int)resultProviderId;
- (void)setAddressGeocodeAccuracyHint:(int)arg1;
- (void)setAddressHint:(id)arg1;
- (void)setAddressObjectHint:(id)arg1;
- (void)setExternalItemId:(id)arg1;
- (void)setFormattedAddressLineHints:(id)arg1;
- (void)setHasAddressGeocodeAccuracyHint:(bool)arg1;
- (void)setHasMuid:(bool)arg1;
- (void)setHasPlaceTypeHint:(bool)arg1;
- (void)setHasResultProviderId:(bool)arg1;
- (void)setLocationHint:(id)arg1;
- (void)setMuid:(unsigned long long)arg1;
- (void)setPlaceNameHint:(id)arg1;
- (void)setPlaceTypeHint:(int)arg1;
- (void)setResultProviderId:(int)arg1;
- (void)setVendorId:(id)arg1;
- (id)vendorId;
- (void)writeTo:(id)arg1;
@end
| 38.743119 | 171 | 0.771726 |
45cf7596f32d577e199b9a97b41d7c73cc1cb6cc | 1,470 | h | C | include/pure64/core/error.h | the-grue/Pure64 | de1be99f2b2071ae09e2b7cb2b8e3456a3ea93e1 | [
"BSD-3-Clause"
] | 1 | 2021-11-05T12:19:28.000Z | 2021-11-05T12:19:28.000Z | include/pure64/core/error.h | feds01/Pure64 | 2ae42e0af5144442c46fdcbf4db1ca404c8f4708 | [
"BSD-3-Clause"
] | null | null | null | include/pure64/core/error.h | feds01/Pure64 | 2ae42e0af5144442c46fdcbf4db1ca404c8f4708 | [
"BSD-3-Clause"
] | null | null | null | /* =============================================================================
* Pure64 -- a 64-bit OS/software loader written in Assembly for x86-64 systems
* Copyright (C) 2008-2017 Return Infinity -- see LICENSE.TXT
* =============================================================================
*/
/** @file error.h API related to error codes. */
#ifndef PURE64_ERROR_H
#define PURE64_ERROR_H
/** A bad address was passed to a function. */
#define PURE64_EFAULT 0x01
/** No more memory available. */
#define PURE64_ENOMEM 0x02
/** The entry is a directory (and it shouldn't be). */
#define PURE64_EISDIR 0x03
/** The entry is not a directory (but it should be). */
#define PURE64_ENOTDIR 0x04
/** No such file or directory. */
#define PURE64_ENOENT 0x05
/** The file or directory already exists. */
#define PURE64_EEXIST 0x06
/** Invalid argument */
#define PURE64_EINVAL 0x07
/** Function not implemented. */
#define PURE64_ENOSYS 0x08
/** Input/Output error occured. */
#define PURE64_EIO 0x09
/** Not enough storage space for
* the operation to complete. */
#define PURE64_ENOSPC 0x0a
#ifdef __cplusplus
extern "C" {
#endif
/** Get a string representation of an
* error that occured in the Pure64 library.
* @param err The error code that was returned.
* @returns A human-readable error description.
* */
const char *pure64_strerror(int err);
#ifdef __cplusplus
} /* extern "C" { */
#endif
#endif /* PURE64_ERROR_H */
| 21 | 80 | 0.629252 |
04f1c75cee9685dfe37a2e3ea922fd470729081c | 841 | c | C | test/oj_tests.c | noahp/ojc | 9132ad02a6cd15c7f6f199640b7d8bb85a80cbbc | [
"MIT"
] | 25 | 2016-03-15T10:58:29.000Z | 2022-03-11T14:20:38.000Z | test/oj_tests.c | noahp/ojc | 9132ad02a6cd15c7f6f199640b7d8bb85a80cbbc | [
"MIT"
] | 3 | 2020-07-05T19:46:35.000Z | 2021-10-20T16:15:15.000Z | test/oj_tests.c | noahp/ojc | 9132ad02a6cd15c7f6f199640b7d8bb85a80cbbc | [
"MIT"
] | 5 | 2016-02-03T23:12:00.000Z | 2020-09-27T13:56:02.000Z | // Copyright (c) 2020, Peter Ohler, All rights reserved.
#include <string.h>
#include "ut.h"
extern void append_validate_tests(Test tests);
extern void append_pushpop_tests(Test tests);
extern void append_parse_tests(Test tests);
extern void append_chunk_tests(Test tests);
extern void append_write_tests(Test tests);
extern void append_build_tests(Test tests);
extern void debug_report();
int
main(int argc, char **argv) {
struct _Test tests[1024] = { { NULL, NULL } };
append_validate_tests(tests);
append_pushpop_tests(tests);
append_parse_tests(tests);
append_chunk_tests(tests);
append_write_tests(tests);
append_build_tests(tests);
bool display_mem_report = ut_init(argc, argv, "oj", tests);
ut_done();
oj_cleanup();
if (display_mem_report) {
debug_report();
}
return 0;
}
| 22.72973 | 63 | 0.72176 |
30dbb2c300054bb5dfa49aa783219b02cf4e0acd | 729 | h | C | prom/test/prom_test_helpers.h | SammyEnigma/libprom | 0e7755cf8886b98524372dcb4f7b344a597ab55d | [
"Apache-2.0"
] | null | null | null | prom/test/prom_test_helpers.h | SammyEnigma/libprom | 0e7755cf8886b98524372dcb4f7b344a597ab55d | [
"Apache-2.0"
] | null | null | null | prom/test/prom_test_helpers.h | SammyEnigma/libprom | 0e7755cf8886b98524372dcb4f7b344a597ab55d | [
"Apache-2.0"
] | 1 | 2021-02-03T19:28:43.000Z | 2021-02-03T19:28:43.000Z |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "prom.h"
#include "prom_collector_registry_t.h"
#include "prom_collector_t.h"
#include "prom_linked_list_i.h"
#include "prom_linked_list_t.h"
#include "prom_map_i.h"
#include "prom_map_t.h"
#include "prom_metric_formatter_i.h"
#include "prom_metric_formatter_t.h"
#include "prom_metric_i.h"
#include "prom_metric_sample_histogram_i.h"
#include "prom_metric_sample_histogram_t.h"
#include "prom_metric_sample_i.h"
#include "prom_metric_sample_t.h"
#include "prom_metric_t.h"
#include "prom_process_fds_i.h"
#include "prom_process_limits_i.h"
#include "prom_process_stat_i.h"
#include "prom_process_stat_t.h"
#include "prom_string_builder.h"
#include "unity.h"
| 27 | 43 | 0.799726 |
aa4a350240c3f005d45be161d7231b88261e8701 | 122 | h | C | include/stdlib.h | finwo/matter | 7baa8a5694ca5ba97c2e878e2eeafc0828d8840f | [
"MIT"
] | null | null | null | include/stdlib.h | finwo/matter | 7baa8a5694ca5ba97c2e878e2eeafc0828d8840f | [
"MIT"
] | 1 | 2021-08-11T22:06:24.000Z | 2021-08-18T16:17:43.000Z | include/stdlib.h | finwo/matter | 7baa8a5694ca5ba97c2e878e2eeafc0828d8840f | [
"MIT"
] | null | null | null | #ifndef _STDLIB_H_
#define _STDLIB_H_
#include <stdint.h>
void srand(unsigned s);
int rand(void);
#endif // _STDLIB_H_
| 12.2 | 23 | 0.737705 |
43e136d2119345df0bb8c3314c451ec96df475ce | 95 | c | C | usr/src/cmd/uucp/pkon.c | doolinius/unix-v7-galileo | 403dfb4fbb875095e84763553a952cfbc8d558fd | [
"MIT"
] | null | null | null | usr/src/cmd/uucp/pkon.c | doolinius/unix-v7-galileo | 403dfb4fbb875095e84763553a952cfbc8d558fd | [
"MIT"
] | null | null | null | usr/src/cmd/uucp/pkon.c | doolinius/unix-v7-galileo | 403dfb4fbb875095e84763553a952cfbc8d558fd | [
"MIT"
] | null | null | null | /* UNIX V7 source code: see /COPYRIGHT or www.tuhs.org for details. */
pkon() { }
pkoff() { }
| 19 | 70 | 0.621053 |
a1636c482ac7b27d7ff1efe0726d518bb575feab | 812 | h | C | src/inform-1.0.0/include/inform/utilities/partitions.h | ELIFE-ASU/rinform | c8050f1fa6ea586ac641f7ab76b15c5b2542de26 | [
"MIT"
] | 1 | 2018-08-01T13:51:16.000Z | 2018-08-01T13:51:16.000Z | src/inform-1.0.0/include/inform/utilities/partitions.h | cran/rinform | c3631b2d9f7922f778644f29052f5200532c7c37 | [
"MIT"
] | 19 | 2017-06-21T00:58:59.000Z | 2019-04-16T00:05:26.000Z | src/inform-1.0.0/include/inform/utilities/partitions.h | cran/rinform | c3631b2d9f7922f778644f29052f5200532c7c37 | [
"MIT"
] | 3 | 2017-12-01T08:22:26.000Z | 2021-02-04T01:09:01.000Z | // Copyright 2016-2017 ELIFE. All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
#pragma once
#include <inform/export.h>
#ifdef __cplusplus
extern "C"
{
#endif
/**
* Compute the first partitioning of a given size
*
* This partitioning will be the coarsest partitioning: one partition with all
* of the elements.
*
* @param[in] size the number of elements
* @return an array of partition numbers (all zeros)
*/
EXPORT size_t *inform_first_partitioning(size_t size);
/**
* Compute the next partition in place
*
* @param[in,out] xs the current partition
* @param[in] size the number of elements
* @return the number of partitions
*/
EXPORT size_t inform_next_partitioning(size_t *xs, size_t size);
#ifdef __cplusplus
}
#endif
| 22.555556 | 78 | 0.731527 |
a27829d9901e53ab7791abb4d2be7e6051f5102b | 7,959 | c | C | bankers.c | freym827/BankersAlgorithm | 030aae34e212b38d6198bda4deb7b7b46153a894 | [
"MIT"
] | null | null | null | bankers.c | freym827/BankersAlgorithm | 030aae34e212b38d6198bda4deb7b7b46153a894 | [
"MIT"
] | null | null | null | bankers.c | freym827/BankersAlgorithm | 030aae34e212b38d6198bda4deb7b7b46153a894 | [
"MIT"
] | null | null | null | /*********************************************
bankers.c
Matthew Frey
**********************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
struct systemData {
int numProcesses;
int numResources;
int* allocationMatrix;
int* maxMatrix;
int* availableMatrix;
int* needsMatrix;
int* safeMatrix;
int* orderMatrix;
int* workMatrix;
};
struct systemData getSystemData(char* filePath);
int getBankersMetrics(FILE* filePath, char* metricType);
int getBankersMatrix(FILE * fp, int* matrix, char* matrixType, int matrixHeight, int matrixWidth);
int* getNeedsMatrix(struct systemData sysData);
int* initProcessMatrix(int matrixSize);
int* initWorkMatrix(int* availableMatrix, int matrixSize);
void getOrderMatrix(struct systemData sysData);
void printResults(struct systemData sysData);
void freeMatrices(struct systemData sysData, int isError);
void freeMatrix(int* matrix, int isError);
int main(int argc, char *argv[]) {
if(argc != 2) {
fprintf(stderr, "usage: %s <filename>\n", argv[0]);
exit(-1);
}
char* filePath = argv[1];
struct systemData sysData = getSystemData(filePath);
sysData.needsMatrix = getNeedsMatrix(sysData);
sysData.safeMatrix = initProcessMatrix(sysData.numProcesses);
sysData.orderMatrix = initProcessMatrix(sysData.numProcesses);
sysData.workMatrix = initWorkMatrix(sysData.availableMatrix, sysData.numResources);
getOrderMatrix(sysData);
printResults(sysData);
freeMatrices(sysData, 0);
return 0;
}
struct systemData getSystemData(char* filePath) {
struct systemData sysData;
char* numProcessesTag = "numProcesses";
char* numResourcesTag = "numResources";
char* allocationTag = "Allocation";
char* maxTag = "Max";
char* availableTag = "Available";
FILE * fp;
fp = fopen(filePath, "r");
if(!fp) {
fprintf(stderr, "Failed to open file location %s.\n", filePath);
exit(-1);
}
sysData.numProcesses = getBankersMetrics(fp, numProcessesTag);
sysData.numResources = getBankersMetrics(fp, numResourcesTag);
int matrixSize = sysData.numProcesses * sysData.numResources;
sysData.allocationMatrix = (int*)calloc(matrixSize, sizeof(int));
if(getBankersMatrix(fp, sysData.allocationMatrix, allocationTag, sysData.numProcesses, sysData.numResources) == -1) {
fclose(fp);
freeMatrix(sysData.allocationMatrix, 1);
exit(-1);
}
sysData.maxMatrix = (int*)calloc(matrixSize, sizeof(int));
if(getBankersMatrix(fp, sysData.maxMatrix, maxTag, sysData.numProcesses, sysData.numResources) == -1) {
fclose(fp);
freeMatrix(sysData.allocationMatrix, 1);
freeMatrix(sysData.maxMatrix, 1);
exit(-1);
}
sysData.availableMatrix = (int*)calloc(sysData.numResources, sizeof(int));
if(getBankersMatrix(fp, sysData.availableMatrix, availableTag, 1, sysData.numResources) == -1) {
fclose(fp);
freeMatrix(sysData.allocationMatrix, 1);
freeMatrix(sysData.maxMatrix, 1);
freeMatrix(sysData.availableMatrix, 1);
exit(-1);
}
fclose(fp);
return sysData;
}
int getBankersMetrics(FILE * fp, char* metricType) {
char lines[150];
int metric = -1;
int typeFound = 0;
while(!feof(fp)) {
fgets(lines, 150, fp);
if(strstr(lines, metricType)) {
typeFound = 1;
char* num = strtok(lines, "=");
while(num != NULL) {
metric = atoi(num);
num = strtok(NULL, "=");
}
break;
}
}
if (typeFound == 0) {
fprintf(stderr, "%s not found in input file.\n", metricType);
exit(-1);
}
return metric;
}
int getBankersMatrix(FILE * fp, int* matrix, char* matrixType, int matrixHeight, int matrixWidth) {
char lines[150];
int matrixIdentifier = 0;
int i;
int j;
int k = 0;
while(!feof(fp)) {
fgets(lines, 150, fp);
if(strstr(lines, matrixType)) {
matrixIdentifier = 1;
break;
}
}
if(matrixIdentifier == 0) {
fprintf(stderr, "%s matrix not found in input file.\n", matrixType);
return(-1);
}
for(i = 0; i < matrixHeight; i++) {
fgets(lines, 150, fp);
if(strstr(lines, "]")) {
break;
}
char* num = strtok(lines, " ");
for(j = 0; j < matrixWidth; j++) {
matrix[k] = atoi(num);
num = strtok(NULL, " ");
k++;
}
}
return 0;
}
int* getNeedsMatrix(struct systemData sysData) {
int matrixSize = sysData.numProcesses * sysData.numResources;
sysData.needsMatrix = (int*)calloc(matrixSize, sizeof(int));
int i;
for(i=0; i<matrixSize; i++) {
sysData.needsMatrix[i] = sysData.maxMatrix[i] - sysData.allocationMatrix[i];
if(sysData.needsMatrix[i] < 0) {
fprintf(stderr, "Allocation Matrix cannot contain value for a resource greater than Max Matrix.\n");
freeMatrix(sysData.allocationMatrix, 1);
exit(-1);
}
}
return sysData.needsMatrix;
}
int* initProcessMatrix(int matrixSize) {
int* processMatrix = (int*)calloc(matrixSize, sizeof(int));
return processMatrix;
}
int* initWorkMatrix(int* allocationMatrix, int matrixSize) {
int* workMatrix = (int*)calloc(matrixSize, sizeof(int));
int i;
for(i=0;i<matrixSize;i++) {
workMatrix[i] = allocationMatrix[i];
}
return workMatrix;
}
void getOrderMatrix(struct systemData sysData) {
int i;
int j;
int k;
int meetsNeeds;
int processesCompleted = 0;
int lastCompleted = -1;
while(1) {
if(processesCompleted == sysData.numProcesses) {
printf("%s", "System is in safe state.\n");
printf("%s", "Safe process order: ");
break;
}
if(processesCompleted == lastCompleted) {
printf("%s", "System is in unsafe state.\nNumber of processes completed: ");
printf("%d\n", processesCompleted);
printf("%s", "Partial process order: ");
break;
}
lastCompleted = processesCompleted;
for(i=0;i<sysData.numProcesses;i++) {
if(!sysData.safeMatrix[i]) {
meetsNeeds = 1;
for(j=0;j<sysData.numResources;j++) {
k = i*sysData.numResources + j;
if(sysData.needsMatrix[k] > sysData.workMatrix[j]) {
meetsNeeds = 0;
}
}
if(meetsNeeds) {
sysData.safeMatrix[i] = 1;
sysData.orderMatrix[processesCompleted] = i;
processesCompleted++;
for(j=0;j<sysData.numResources;j++) {
k = i*sysData.numResources + j;
sysData.workMatrix[j] += sysData.allocationMatrix[k];
}
}
}
}
}
return;
}
void printResults(struct systemData sysData) {
int i;
for(i=0;i<sysData.numProcesses;i++) {
if(sysData.safeMatrix[i] == 1) {
printf("P(%d) ", sysData.orderMatrix[i]);
}
}
printf("\n");
}
void freeMatrices (struct systemData sysData, int isError) {
if(sysData.allocationMatrix) {free(sysData.allocationMatrix);}
if(sysData.maxMatrix) {free(sysData.maxMatrix);}
if(sysData.availableMatrix) {free(sysData.availableMatrix);}
if(sysData.needsMatrix) {free(sysData.needsMatrix);}
if(sysData.safeMatrix) {free(sysData.safeMatrix);}
if(sysData.orderMatrix) {free(sysData.orderMatrix);}
if(sysData.workMatrix) {free(sysData.workMatrix);}
if(isError) {
exit(-1);
}
}
void freeMatrix (int* matrix, int isError) {
free(matrix);
}
| 29.369004 | 121 | 0.591532 |
0c03cdd2927ff60cabff4897e073d052fe95bc86 | 183 | h | C | ZZZ_OtherDemo/00-dyld-832.7.3/testing/test-cases/weak-coalesce.dtest/base.h | 1079278593/TreasureChest | 8b1ebe04ed7c2ed399c4ecf3b75b3fee0a1aced8 | [
"MIT"
] | 672 | 2019-10-09T11:15:13.000Z | 2021-09-21T10:02:33.000Z | dyld-635.2/testing/test-cases/weak-coalesce.dtest/base.h | KaiserFeng/KFAppleOpenSource | 7ea6ab19f1492a2da262d3554f90882393f975a4 | [
"MIT"
] | 19 | 2019-11-05T03:32:31.000Z | 2021-07-15T11:16:25.000Z | dyld-635.2/testing/test-cases/weak-coalesce.dtest/base.h | KaiserFeng/KFAppleOpenSource | 7ea6ab19f1492a2da262d3554f90882393f975a4 | [
"MIT"
] | 216 | 2019-10-10T01:47:36.000Z | 2021-09-23T07:56:54.000Z |
extern void baseCheck();
extern int coal1;
extern int coal2;
extern void baseVerifyCoal1(const char* where, int* addr);
extern void baseVerifyCoal2(const char* where, int* addr);
| 18.3 | 58 | 0.759563 |
0c28127a1b50a0fe72b630e66a555cd482f92679 | 5,533 | h | C | Delfino/SingleCore/SmartWinch/device/driverlib/inc/hw_dac.h | vlad314/FYP_SmartWinch | fca9c23e89d5ea14bfcd18b6565c0a241d7cf3ab | [
"MIT"
] | null | null | null | Delfino/SingleCore/SmartWinch/device/driverlib/inc/hw_dac.h | vlad314/FYP_SmartWinch | fca9c23e89d5ea14bfcd18b6565c0a241d7cf3ab | [
"MIT"
] | 5 | 2018-02-15T10:21:58.000Z | 2018-09-21T10:33:36.000Z | Delfino/SingleCore/SmartWinch/device/driverlib/inc/hw_dac.h | vlad314/FYP_SmartWinch | fca9c23e89d5ea14bfcd18b6565c0a241d7cf3ab | [
"MIT"
] | 2 | 2018-05-24T16:47:00.000Z | 2019-10-05T15:11:32.000Z | //###########################################################################
//
// FILE: hw_dac.h
//
// TITLE: Definitions for the DAC registers.
//
//###########################################################################
// $TI Release: F2837xS Support Library v3.03.00.00 $
// $Release Date: Thu Dec 7 18:53:06 CST 2017 $
// $Copyright:
// Copyright (C) 2014-2017 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.
// $
//###########################################################################
#ifndef HW_DAC_H
#define HW_DAC_H
//*****************************************************************************
//
// The following are defines for the DAC register offsets
//
//*****************************************************************************
#define DAC_O_REV 0x0U // DAC Revision Register
#define DAC_O_CTL 0x1U // DAC Control Register
#define DAC_O_VALA 0x2U // DAC Value Register - Active
#define DAC_O_VALS 0x3U // DAC Value Register - Shadow
#define DAC_O_OUTEN 0x4U // DAC Output Enable Register
#define DAC_O_LOCK 0x5U // DAC Lock Register
#define DAC_O_TRIM 0x6U // DAC Trim Register
//*****************************************************************************
//
// The following are defines for the bit fields in the DACREV register
//
//*****************************************************************************
#define DAC_REV_REV_S 0U
#define DAC_REV_REV_M 0xFFU // DAC Revision Register
//*****************************************************************************
//
// The following are defines for the bit fields in the DACCTL register
//
//*****************************************************************************
#define DAC_CTL_DACREFSEL 0x1U // DAC Reference Select
#define DAC_CTL_LOADMODE 0x4U // DACVALA Load Mode
#define DAC_CTL_SYNCSEL_S 4U
#define DAC_CTL_SYNCSEL_M 0xF0U // DAC PWMSYNC Select
//*****************************************************************************
//
// The following are defines for the bit fields in the DACVALA register
//
//*****************************************************************************
#define DAC_VALA_DACVALA_S 0U
#define DAC_VALA_DACVALA_M 0xFFFU // DAC Active Output Code
//*****************************************************************************
//
// The following are defines for the bit fields in the DACVALS register
//
//*****************************************************************************
#define DAC_VALS_DACVALS_S 0U
#define DAC_VALS_DACVALS_M 0xFFFU // DAC Shadow Output Code
//*****************************************************************************
//
// The following are defines for the bit fields in the DACOUTEN register
//
//*****************************************************************************
#define DAC_OUTEN_DACOUTEN 0x1U // DAC Output Code
//*****************************************************************************
//
// The following are defines for the bit fields in the DACLOCK register
//
//*****************************************************************************
#define DAC_LOCK_DACCTL 0x1U // DAC Control Register Lock
#define DAC_LOCK_DACVAL 0x2U // DAC Value Register Lock
#define DAC_LOCK_DACOUTEN 0x4U // DAC Output Enable Register
// Lock
//*****************************************************************************
//
// The following are defines for the bit fields in the DACTRIM register
//
//*****************************************************************************
#define DAC_TRIM_OFFSET_TRIM_S 0U
#define DAC_TRIM_OFFSET_TRIM_M 0xFFU // DAC Offset Trim
#endif
| 46.889831 | 79 | 0.49503 |
8364b8ca15fbb588fb2673841a1dc269f97101d7 | 7,609 | c | C | c-examples/colbrowser.c | ericu/fltkhs | 3ca521ca30d51a84f8ec87938932f2ce5af8a7c0 | [
"MIT"
] | 222 | 2015-01-11T19:01:16.000Z | 2022-03-25T14:47:26.000Z | c-examples/colbrowser.c | ericu/fltkhs | 3ca521ca30d51a84f8ec87938932f2ce5af8a7c0 | [
"MIT"
] | 143 | 2015-01-13T19:08:33.000Z | 2021-10-10T20:43:46.000Z | c-examples/colbrowser.c | ericu/fltkhs | 3ca521ca30d51a84f8ec87938932f2ce5af8a7c0 | [
"MIT"
] | 36 | 2015-01-14T15:30:18.000Z | 2021-08-11T13:04:28.000Z | #include <Fl_C.h>
#include <Fl_Double_WindowC.h>
#include <Fl_WindowC.h>
#include <Fl_ButtonC.h>
#include <Fl_Value_SliderC.h>
#include <Fl_Hold_BrowserC.h>
#include <Fl_BoxC.h>
#include <Fl_BrowserC.h>
#include <Fl_WidgetC.h>
#include <Fl_AskC.h>
#include <filenameC.h>
#include <FL/fl_utf8.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define MAX_RGB 3000
#define FL_FREE_COL4 ((Fl_Color)(FL_FREE_COLOR+3))
#define FL_INDIANRED ((Fl_Color)(164))
fl_Double_Window cl;
fl_Box rescol;
fl_Button dbobj;
fl_Hold_Browser colbr;
fl_Value_Slider rs;
fl_Value_Slider gs;
fl_Value_Slider bs;
char dbname[FL_PATH_MAX];
void create_form_cl(void);
int load_browser(char *);
typedef struct { int r, g, b; } RGBdb;
RGBdb rgbdb[MAX_RGB];
int main(int argc, char *argv[])
{
create_form_cl();
#ifdef USING_XCODE
// Xcode apps do not set the current directory
strcpy(dbname, argv[0]);
char *slash = strrchr(dbname, '/');
if (slash)
strcpy(slash, "/../Resources/rgb.txt");
#else
strcpy(dbname, "./rgb.txt");
#endif
if (load_browser(dbname))
Fl_Button_set_label(dbobj,dbname);
else
Fl_Button_set_label(dbobj,"None");
Fl_Button_redraw(dbobj);
// cl->size_range(cl->w(),cl->h(),2*cl->w(),2*cl->h());
fl_Window_size_range_args* sizes = Fl_Window_default_size_range_args();
sizes->maxw = 2 * Fl_Double_Window_w(cl);
sizes->maxh = 2 * Fl_Double_Window_h(cl);;
Fl_Double_Window_size_range_with_args(cl, Fl_Double_Window_w(cl), Fl_Double_Window_h(cl),sizes);
Fl_Double_Window_set_label(cl,"RGB Browser");
Fl_Double_Window_free_position(cl);
Fl_Double_Window_show_with_args(cl,argc,argv);
return Fl_run();
}
void set_entry(int i)
{
RGBdb *db = rgbdb + i;
Fl_set_color_rgb(FL_FREE_COL4, db->r, db->g, db->b);
Fl_Value_Slider_set_value(rs,db->r);
Fl_Value_Slider_set_value(gs,db->g);
Fl_Value_Slider_set_value(bs,db->b);
Fl_Box_redraw(rescol);
}
void br_cb(fl_Widget ob, void* user_data)
{
int r = Fl_Browser_value((fl_Browser)ob);
if (r <= 0)
return;
set_entry(r - 1);
}
int read_entry(FILE * fp, int *r, int *g, int *b, char *name)
{
int n;
char buf[512], *p;
if (!fgets(buf, sizeof(buf) - 1, fp))
return 0;
if(buf[0] == '!') {
if (fgets(buf,sizeof(buf)-1,fp)==0) {
/* ignore */
}
}
if(sscanf(buf, " %d %d %d %n", r, g, b, &n) < 3)
return 0;
p = buf + n;
/* squeeze out all spaces */
while (*p)
{
if (*p != ' ' && *p != '\n')
*name++ = *p;
p++;
}
*name = 0;
return (feof(fp) || ferror(fp)) ? 0 : 1;
}
int load_browser(char *fname)
{
FILE *fp;
RGBdb *db = rgbdb, *dbs = db + MAX_RGB;
int r, g, b, lr = -1 , lg = -1, lb = -1;
char name[256], buf[256];
#ifdef __EMX__
if (!(fp = fl_fopen(__XOS2RedirRoot(fname), "r")))
#else
if (!(fp = fl_fopen(fname, "r")))
#endif
{
printf("%s\n%s\n%s","Load", fname, "Can't open");
return 0;
}
/* read the items */
for (; db < dbs && read_entry(fp, &r, &g, &b, name);)
{
db->r = r;
db->g = g;
db->b = b;
/* unique the entries on the fly */
if (lr != r || lg != g || lb != b)
{
db++;
lr = r;
lg = g;
lb = b;
sprintf(buf, "(%3d %3d %3d) %s", r, g, b, name);
Fl_Hold_Browser_add(colbr,buf);
}
}
fclose(fp);
if (db < dbs)
db->r = 1000; /* sentinel */
else
{
db--;
db->r = 1000;
}
Fl_Hold_Browser_set_topline(colbr,1);
Fl_Hold_Browser_select_with_val(colbr,1,1);
set_entry(0);
return 1;
}
int search_entry(int r, int g, int b)
{
register RGBdb *db = rgbdb;
int i, j, diffr, diffg, diffb;
unsigned int diff, mindiff;
mindiff = (unsigned int)~0;
for (i = j = 0; db->r < 256; db++, i++)
{
diffr = r - db->r;
diffg = g - db->g;
diffb = b - db->b;
#ifdef FL_LINEAR
diff = (unsigned)((3.0 * (FL_abs(r - db->r)) +
(5.9 * FL_abs(g - db->g)) +
(1.1 * (FL_abs(b - db->b)))));
#else
diff = (unsigned)((3.0 * (diffr *diffr) +
5.9 * (diffg *diffg) +
1.1 * (diffb *diffb)));
#endif
if (mindiff > diff)
{
mindiff = diff;
j = i;
}
}
return j;
}
void search_rgb(fl_Widget w, void* user_data)
{
int r, g, b, i;
int top = Fl_Hold_Browser_topline(colbr);
r = (int)(Fl_Value_Slider_value(rs));
g = (int)(Fl_Value_Slider_value(gs));
b = (int)(Fl_Value_Slider_value(bs));
// fl_freeze_form(cl);
Fl_set_color_rgb(FL_FREE_COL4, r, g, b);
Fl_Box_redraw(rescol);
i = search_entry(r, g, b);
/* change topline only if necessary */
if(i < top || i > (top+15))
Fl_Hold_Browser_set_topline(colbr,i-8);
Fl_Hold_Browser_select_with_val(colbr,i+1, 1);
// fl_unfreeze_form(cl);
}
/* change database */
void db_cb(fl_Widget ob, void* user_data)
{
const char *p = flc_input_with_deflt("Enter New Database Name", dbname);
char buf[512];
if (!p || strcmp(p, dbname) == 0)
return;
strcpy(buf, p);
if (load_browser(buf))
strcpy(dbname, buf);
else
Fl_Widget_set_label(ob,dbname);
}
void done_cb(fl_Widget w, void* user_data)
{
exit(0);
}
void create_form_cl(void)
{
if (cl)
return;
cl = Fl_Double_Window_New(400,385);
Fl_Double_Window_set_box(cl,FL_UP_BOX);
Fl_Double_Window_set_color_with_bg_sel(cl,FL_INDIANRED, FL_GRAY);
fl_Box title = Fl_Box_New_WithLabel(40, 10, 300, 30, "Color Browser");
Fl_Box_set_box(title,FL_NO_BOX);
Fl_Box_set_labelcolor(title,FL_RED);
Fl_Box_set_labelsize(title,32);
Fl_Box_set_labelfont(title,FL_HELVETICA_BOLD);
Fl_Box_set_labeltype(title,FL_SHADOW_LABEL);
dbobj = Fl_Button_New_WithLabel(40, 50, 300, 25, "");
Fl_Button_set_type(dbobj,FL_NORMAL_BUTTON);
Fl_Button_set_box(dbobj,FL_BORDER_BOX);
Fl_Button_set_color_with_bg_sel(dbobj,FL_INDIANRED,FL_INDIANRED);
Fl_Button_set_callback_with_user_data(dbobj,db_cb, 0);
colbr = Fl_Hold_Browser_New_WithLabel(10, 90, 280, 240, "");
Fl_Hold_Browser_set_textfont(colbr,FL_COURIER);
Fl_Hold_Browser_set_callback_with_user_data(colbr,br_cb, 0);
Fl_Hold_Browser_set_box(colbr,FL_DOWN_BOX);
rescol = Fl_Box_New_WithLabel(300, 90, 90, 35, "");
Fl_Box_set_color_with_bg_sel(rescol,FL_FREE_COL4, FL_FREE_COL4);
Fl_Box_set_box(rescol,FL_BORDER_BOX);
rs = Fl_Value_Slider_New_WithLabel(300, 130, 30, 200, "");
Fl_Value_Slider_set_type(rs,FL_VERT_FILL_SLIDER);
Fl_Value_Slider_set_color_with_bg_sel(rs,FL_INDIANRED, FL_RED);
Fl_Value_Slider_bounds(rs,0, 255);
Fl_Value_Slider_precision(rs,0);
Fl_Value_Slider_set_callback_with_user_data(rs,search_rgb, 0);
Fl_Value_Slider_set_when(rs,FL_WHEN_RELEASE);
gs = Fl_Value_Slider_New_WithLabel(330, 130, 30, 200, "");
Fl_Value_Slider_set_type(gs,FL_VERT_FILL_SLIDER);
Fl_Value_Slider_set_color_with_bg_sel(gs,FL_INDIANRED, FL_GREEN);
Fl_Value_Slider_bounds(gs,0, 255);
Fl_Value_Slider_precision(gs,0);
Fl_Value_Slider_set_callback_with_user_data(gs,search_rgb, (void*)1);
Fl_Value_Slider_set_when(gs,FL_WHEN_RELEASE);
bs = Fl_Value_Slider_New_WithLabel(360, 130, 30, 200, "");
Fl_Value_Slider_set_type(bs,FL_VERT_FILL_SLIDER);
Fl_Value_Slider_set_color_with_bg_sel(bs,FL_INDIANRED, FL_BLUE);
Fl_Value_Slider_bounds(bs,0, 255);
Fl_Value_Slider_precision(bs,0);
Fl_Value_Slider_set_callback_with_user_data(bs,search_rgb, (void*)2);
Fl_Value_Slider_set_when(bs,FL_WHEN_RELEASE);
fl_Button done = Fl_Button_New_WithLabel(160, 345, 80, 30, "Done");
Fl_Button_set_type(done,FL_NORMAL_BUTTON);
Fl_Button_set_callback_with_user_data(done,done_cb, 0);
Fl_Double_Window_end(cl);
Fl_Double_Window_set_resizable(cl,cl);
}
| 23.630435 | 98 | 0.667236 |
4d07f66aaa35e534fa274a1dfcf651240dc6fefd | 1,297 | c | C | C/hard/h353.c | tlgs/dailyprogrammer | 6e7d3352616fa54a8e9caf8564a9cfb951eb0af9 | [
"Unlicense"
] | 4 | 2017-10-18T02:17:02.000Z | 2022-02-02T01:19:02.000Z | C/hard/h353.c | tlseabra/dailyprogrammer | 6e7d3352616fa54a8e9caf8564a9cfb951eb0af9 | [
"Unlicense"
] | 4 | 2016-01-24T20:30:02.000Z | 2017-01-18T16:01:23.000Z | C/hard/h353.c | tlgs/dailyprogrammer | 6e7d3352616fa54a8e9caf8564a9cfb951eb0af9 | [
"Unlicense"
] | null | null | null | /* 09/03/2018 */
// helpful: https://homes.cs.washington.edu/~armin/ACM_TECS_2013.pdf
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <time.h>
typedef int8_t stream;
#define N_BITS (sizeof(stream)*8)
#define N_RUNS 10e3
stream add(stream a, stream b, stream s){
return (a & s) | (~s & b);
}
stream multiply(stream a, stream b){
return (a & b);
}
stream SNG(int x){
stream n = 0;
for (int i = 0; i < N_BITS; i++)
n |= ((rand()%N_BITS < x) << i);
return n;
}
float BNG(stream x){
int n = 0;
for (int i = 0; i < N_BITS; i++)
n += (x >> i) & 1;
return (float) n/N_BITS;
}
void printStream(stream x){
for (int i = N_BITS - 1; i >= 0; i--){
putchar('0' + ((x >> i) & 1));
if (i%8 == 0) putchar(' ');
}
}
int main(void){
srand(time(0));
int a, b;
while (scanf("%d %d", &a, &b) == 2){
float results[2] = {0};
for (int i = 0; i < N_RUNS; i++){
results[0] += BNG(multiply(SNG(a), SNG(b)));
results[1] += BNG(add(SNG(a), SNG(b), SNG(N_BITS/2)))*2;
}
printf("%.3f * %.3f = %.3f\n", (float) a/N_BITS, (float) b/N_BITS, results[0]/N_RUNS);
printf("%.3f + %.3f = %.3f\n", (float) a/N_BITS, (float) b/N_BITS, results[1]/N_RUNS);
}
} | 24.018519 | 94 | 0.508867 |
b33236fb56d5fe2b2e889a485fdeced8a25e6307 | 1,137 | h | C | include/paint/background.h | tralf-strues/simple-gui-library | cf72b11d0d245d1a1fefbae10e4aa7fb9e763bff | [
"MIT"
] | null | null | null | include/paint/background.h | tralf-strues/simple-gui-library | cf72b11d0d245d1a1fefbae10e4aa7fb9e763bff | [
"MIT"
] | null | null | null | include/paint/background.h | tralf-strues/simple-gui-library | cf72b11d0d245d1a1fefbae10e4aa7fb9e763bff | [
"MIT"
] | null | null | null | /**
* @author Nikita Mochalov (github.com/tralf-strues)
* @file background.h
* @date 2021-11-06
*
* @copyright Copyright (c) 2021
*/
#pragma once
#include <vector>
#include "sml/math/rectangle.h"
#include "fill.h"
#include "../media/image.h"
namespace Sgl
{
class Fill;
class Image;
class Background
{
public:
static void fillArea(const Background* background,
const Sml::Rectangle<int32_t>& targetRegion);
public:
Background() = default;
Background(const std::initializer_list<const Fill*>& fills,
const std::initializer_list<const Image*>& images);
Background(const std::initializer_list<const Fill*>& fills);
Background(const Fill* fill);
void addFill(const Fill* fill);
void addImage(const Image* image);
void clearFills();
void clearImages();
const std::vector<const Fill*>& getFills() const;
const std::vector<const Image*> getImages() const;
private:
std::vector<const Fill*> m_Fills;
std::vector<const Image*> m_Images;
};
} | 22.74 | 74 | 0.609499 |
8888624188367b7a3a508a3ba6d48a6403485624 | 23,373 | c | C | engine/NQ/view.c | QUINTIX/blinky | ebd69b3181e645542de1fbd6d7a38a161e092ae3 | [
"MIT"
] | 4 | 2020-08-07T07:25:14.000Z | 2020-09-05T21:03:03.000Z | engine/NQ/view.c | QUINTIX/blinky | ebd69b3181e645542de1fbd6d7a38a161e092ae3 | [
"MIT"
] | 1 | 2021-06-21T04:35:51.000Z | 2021-06-23T00:24:28.000Z | engine/NQ/view.c | QUINTIX/blinky | ebd69b3181e645542de1fbd6d7a38a161e092ae3 | [
"MIT"
] | 1 | 2020-08-05T16:39:14.000Z | 2020-08-05T16:39:14.000Z | /*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// view.c -- player eye positioning
#include "bspfile.h"
#include "client.h"
#include "cmd.h"
#include "console.h"
#include "cvar.h"
#include "draw.h"
#include "fisheye.h"
#include "host.h"
#include "quakedef.h"
#include "screen.h"
#include "view.h"
/*
* The view is allowed to move slightly from it's true position for bobbing,
* but if it exceeds 8 pixels linear distance (spherical, not box), the list
* of entities sent from the server may not include everything in the pvs,
* especially when crossing a water boudnary.
*/
cvar_t scr_ofsx = { "scr_ofsx", "0", false };
cvar_t scr_ofsy = { "scr_ofsy", "0", false };
cvar_t scr_ofsz = { "scr_ofsz", "0", false };
cvar_t cl_rollspeed = { "cl_rollspeed", "200" };
cvar_t cl_rollangle = { "cl_rollangle", "2.0" };
cvar_t cl_bob = { "cl_bob", "0.02", false };
cvar_t cl_bobcycle = { "cl_bobcycle", "0.6", false };
cvar_t cl_bobup = { "cl_bobup", "0.5", false };
cvar_t v_kicktime = { "v_kicktime", "0.5", false };
cvar_t v_kickroll = { "v_kickroll", "0.6", false };
cvar_t v_kickpitch = { "v_kickpitch", "0.6", false };
cvar_t v_iyaw_cycle = { "v_iyaw_cycle", "2", false };
cvar_t v_iroll_cycle = { "v_iroll_cycle", "0.5", false };
cvar_t v_ipitch_cycle = { "v_ipitch_cycle", "1", false };
cvar_t v_iyaw_level = { "v_iyaw_level", "0.3", false };
cvar_t v_iroll_level = { "v_iroll_level", "0.1", false };
cvar_t v_ipitch_level = { "v_ipitch_level", "0.3", false };
cvar_t v_idlescale = { "v_idlescale", "0", false };
cvar_t crosshair = { "crosshair", "0", true };
cvar_t crosshaircolor = { "crosshaircolor", "79", true };
cvar_t cl_crossx = { "cl_crossx", "0", false };
cvar_t cl_crossy = { "cl_crossy", "0", false };
#ifdef GLQUAKE
cvar_t gl_cshiftpercent = { "gl_cshiftpercent", "100", false };
#endif
float v_dmg_time, v_dmg_roll, v_dmg_pitch;
/*
===============
V_CalcRoll
Used by view and sv_user
===============
*/
vec3_t forward, right, up;
float
V_CalcRoll(vec3_t angles, vec3_t velocity)
{
float sign;
float side;
float value;
AngleVectors(angles, forward, right, up);
side = DotProduct(velocity, right);
sign = side < 0 ? -1 : 1;
side = fabsf(side);
value = cl_rollangle.value;
// if (cl.inwater)
// value *= 6;
if (side < cl_rollspeed.value)
side = side * value / cl_rollspeed.value;
else
side = value;
return side * sign;
}
/*
===============
V_CalcBob
===============
*/
float
V_CalcBob(void)
{
float bob;
float cycle;
/* Avoid divide-by-zero, don't bob */
if (!cl_bobcycle.value)
return 0.0f;
cycle = cl.time - (int)(cl.time / cl_bobcycle.value) * cl_bobcycle.value;
cycle /= cl_bobcycle.value;
if (cycle < cl_bobup.value)
cycle = M_PI * cycle / cl_bobup.value;
else
cycle =
M_PI + M_PI * (cycle - cl_bobup.value) / (1.0 - cl_bobup.value);
// bob is proportional to velocity in the xy plane
// (don't count Z, or jumping messes it up)
bob = sqrtf(cl.velocity[0] * cl.velocity[0] +
cl.velocity[1] * cl.velocity[1]) * cl_bob.value;
//Con_Printf ("speed: %5.1f\n", Length(cl.velocity));
bob = bob * 0.3 + bob * 0.7 * sin(cycle);
if (bob > 4)
bob = 4;
else if (bob < -7)
bob = -7;
return bob;
}
//=============================================================================
cvar_t v_centermove = { "v_centermove", "0.15", false };
cvar_t v_centerspeed = { "v_centerspeed", "500" };
void
V_StartPitchDrift(void)
{
#if 1
if (cl.laststop == cl.time) {
return; // something else is keeping it from drifting
}
#endif
if (cl.nodrift || !cl.pitchvel) {
cl.pitchvel = v_centerspeed.value;
cl.nodrift = false;
cl.driftmove = 0;
}
}
void
V_StopPitchDrift(void)
{
cl.laststop = cl.time;
cl.nodrift = true;
cl.pitchvel = 0;
}
/*
===============
V_DriftPitch
Moves the client pitch angle towards cl.idealpitch sent by the server.
If the user is adjusting pitch manually, either with lookup/lookdown,
mlook and mouse, or klook and keyboard, pitch drifting is constantly stopped.
Drifting is enabled when the center view key is hit, mlook is released and
lookspring is non 0, or when
===============
*/
void
V_DriftPitch(void)
{
float delta, move;
if (noclip_anglehack || !cl.onground || cls.demoplayback) {
cl.driftmove = 0;
cl.pitchvel = 0;
return;
}
// don't count small mouse motion
if (cl.nodrift) {
if (fabsf(cl.cmd.forwardmove) < cl_forwardspeed.value)
cl.driftmove = 0;
else
cl.driftmove += host_frametime;
if (cl.driftmove > v_centermove.value)
if (lookspring.value)
V_StartPitchDrift();
return;
}
delta = cl.idealpitch - cl.viewangles[PITCH];
if (!delta) {
cl.pitchvel = 0;
return;
}
move = host_frametime * cl.pitchvel;
cl.pitchvel += host_frametime * v_centerspeed.value;
if (delta > 0) {
if (move > delta) {
cl.pitchvel = 0;
move = delta;
}
cl.viewangles[PITCH] += move;
} else if (delta < 0) {
if (move > -delta) {
cl.pitchvel = 0;
move = -delta;
}
cl.viewangles[PITCH] -= move;
}
}
/*
==============================================================================
PALETTE FLASHES
==============================================================================
*/
cshift_t cshift_empty = { {130, 80, 50}, 0 };
cshift_t cshift_water = { {130, 80, 50}, 128 };
cshift_t cshift_slime = { {0, 25, 5}, 150 };
cshift_t cshift_lava = { {255, 80, 0}, 150 };
cvar_t v_gamma = { "gamma", "1", CVAR_CONFIG };
byte gammatable[256]; // palette is sent through this
#ifdef GLQUAKE
unsigned short ramps[3][256];
float v_blend[4]; // rgba 0.0 - 1.0
#endif
void
BuildGammaTable(float g)
{
int i, inf;
if (g == 1.0) {
for (i = 0; i < 256; i++)
gammatable[i] = i;
return;
}
for (i = 0; i < 256; i++) {
inf = 255 * pow((i + 0.5) / 255.5, g) + 0.5;
if (inf < 0)
inf = 0;
if (inf > 255)
inf = 255;
gammatable[i] = inf;
}
}
/*
=================
V_CheckGamma
=================
*/
qboolean
V_CheckGamma(void)
{
static float oldgammavalue;
if (v_gamma.value == oldgammavalue)
return false;
oldgammavalue = v_gamma.value;
BuildGammaTable(v_gamma.value);
vid.recalc_refdef = 1; // force a surface cache flush
return true;
}
/*
===============
V_ParseDamage
===============
*/
void
V_ParseDamage(void)
{
int armor, blood;
vec3_t from;
int i;
vec3_t forward, right, up;
const entity_t *ent;
float side;
float count;
armor = MSG_ReadByte();
blood = MSG_ReadByte();
for (i = 0; i < 3; i++)
from[i] = MSG_ReadCoord();
count = blood * 0.5 + armor * 0.5;
if (count < 10)
count = 10;
cl.faceanimtime = cl.time + 0.2; // but sbar face into pain frame
cl.cshifts[CSHIFT_DAMAGE].percent += 3 * count;
if (cl.cshifts[CSHIFT_DAMAGE].percent < 0)
cl.cshifts[CSHIFT_DAMAGE].percent = 0;
if (cl.cshifts[CSHIFT_DAMAGE].percent > 150)
cl.cshifts[CSHIFT_DAMAGE].percent = 150;
if (armor > blood) {
cl.cshifts[CSHIFT_DAMAGE].destcolor[0] = 200;
cl.cshifts[CSHIFT_DAMAGE].destcolor[1] = 100;
cl.cshifts[CSHIFT_DAMAGE].destcolor[2] = 100;
} else if (armor) {
cl.cshifts[CSHIFT_DAMAGE].destcolor[0] = 220;
cl.cshifts[CSHIFT_DAMAGE].destcolor[1] = 50;
cl.cshifts[CSHIFT_DAMAGE].destcolor[2] = 50;
} else {
cl.cshifts[CSHIFT_DAMAGE].destcolor[0] = 255;
cl.cshifts[CSHIFT_DAMAGE].destcolor[1] = 0;
cl.cshifts[CSHIFT_DAMAGE].destcolor[2] = 0;
}
//
// calculate view angle kicks
//
ent = &cl_entities[cl.viewentity];
VectorSubtract(from, ent->origin, from);
VectorNormalize(from);
AngleVectors(ent->angles, forward, right, up);
side = DotProduct(from, right);
v_dmg_roll = count * side * v_kickroll.value;
side = DotProduct(from, forward);
v_dmg_pitch = count * side * v_kickpitch.value;
v_dmg_time = v_kicktime.value;
}
/*
==================
V_cshift_f
==================
*/
void
V_cshift_f(void)
{
cshift_empty.destcolor[0] = atoi(Cmd_Argv(1));
cshift_empty.destcolor[1] = atoi(Cmd_Argv(2));
cshift_empty.destcolor[2] = atoi(Cmd_Argv(3));
cshift_empty.percent = atoi(Cmd_Argv(4));
}
/*
==================
V_BonusFlash_f
When you run over an item, the server sends this command
==================
*/
void
V_BonusFlash_f(void)
{
cl.cshifts[CSHIFT_BONUS].destcolor[0] = 215;
cl.cshifts[CSHIFT_BONUS].destcolor[1] = 186;
cl.cshifts[CSHIFT_BONUS].destcolor[2] = 69;
cl.cshifts[CSHIFT_BONUS].percent = 50;
}
/*
=============
V_SetContentsColor
Underwater, lava, etc each has a color shift
=============
*/
void
V_SetContentsColor(int contents)
{
switch (contents) {
case CONTENTS_EMPTY:
case CONTENTS_SOLID:
cl.cshifts[CSHIFT_CONTENTS] = cshift_empty;
break;
case CONTENTS_LAVA:
cl.cshifts[CSHIFT_CONTENTS] = cshift_lava;
break;
case CONTENTS_SLIME:
cl.cshifts[CSHIFT_CONTENTS] = cshift_slime;
break;
default:
cl.cshifts[CSHIFT_CONTENTS] = cshift_water;
}
}
/*
=============
V_CalcPowerupCshift
=============
*/
void
V_CalcPowerupCshift(void)
{
if (cl.stats[STAT_ITEMS] & IT_QUAD) {
cl.cshifts[CSHIFT_POWERUP].destcolor[0] = 0;
cl.cshifts[CSHIFT_POWERUP].destcolor[1] = 0;
cl.cshifts[CSHIFT_POWERUP].destcolor[2] = 255;
cl.cshifts[CSHIFT_POWERUP].percent = 30;
} else if (cl.stats[STAT_ITEMS] & IT_SUIT) {
cl.cshifts[CSHIFT_POWERUP].destcolor[0] = 0;
cl.cshifts[CSHIFT_POWERUP].destcolor[1] = 255;
cl.cshifts[CSHIFT_POWERUP].destcolor[2] = 0;
cl.cshifts[CSHIFT_POWERUP].percent = 20;
} else if (cl.stats[STAT_ITEMS] & IT_INVISIBILITY) {
cl.cshifts[CSHIFT_POWERUP].destcolor[0] = 100;
cl.cshifts[CSHIFT_POWERUP].destcolor[1] = 100;
cl.cshifts[CSHIFT_POWERUP].destcolor[2] = 100;
cl.cshifts[CSHIFT_POWERUP].percent = 100;
} else if (cl.stats[STAT_ITEMS] & IT_INVULNERABILITY) {
cl.cshifts[CSHIFT_POWERUP].destcolor[0] = 255;
cl.cshifts[CSHIFT_POWERUP].destcolor[1] = 255;
cl.cshifts[CSHIFT_POWERUP].destcolor[2] = 0;
cl.cshifts[CSHIFT_POWERUP].percent = 30;
} else
cl.cshifts[CSHIFT_POWERUP].percent = 0;
}
/*
=============
V_CalcBlend
=============
*/
#ifdef GLQUAKE
void
V_CalcBlend(void)
{
float r, g, b, a, a2;
int j;
r = g = b = a = 0;
if (gl_cshiftpercent.value) {
for (j = 0; j < NUM_CSHIFTS; j++) {
a2 = ((cl.cshifts[j].percent * gl_cshiftpercent.value) / 100.0) /
255.0;
if (!a2)
continue;
a = a + a2 * (1 - a);
a2 = a2 / a;
r = r * (1 - a2) + cl.cshifts[j].destcolor[0] * a2;
g = g * (1 - a2) + cl.cshifts[j].destcolor[1] * a2;
b = b * (1 - a2) + cl.cshifts[j].destcolor[2] * a2;
}
}
v_blend[0] = r / 255.0;
v_blend[1] = g / 255.0;
v_blend[2] = b / 255.0;
v_blend[3] = a;
if (v_blend[3] > 1)
v_blend[3] = 1;
if (v_blend[3] < 0)
v_blend[3] = 0;
}
#endif
/*
=============
V_UpdatePalette
=============
*/
#ifdef GLQUAKE
void
V_UpdatePalette(void)
{
int i;
qboolean force;
V_CalcPowerupCshift();
/* drop the damage value */
cl.cshifts[CSHIFT_DAMAGE].percent -= host_frametime * 150;
if (cl.cshifts[CSHIFT_DAMAGE].percent < 0)
cl.cshifts[CSHIFT_DAMAGE].percent = 0;
/* drop the bonus value */
cl.cshifts[CSHIFT_BONUS].percent -= host_frametime * 100;
if (cl.cshifts[CSHIFT_BONUS].percent < 0)
cl.cshifts[CSHIFT_BONUS].percent = 0;
force = V_CheckGamma();
if (force) {
for (i = 0; i < 256; i++) {
ramps[0][i] = gammatable[i] << 8;
ramps[1][i] = gammatable[i] << 8;
ramps[2][i] = gammatable[i] << 8;
}
if (VID_IsFullScreen() && VID_SetGammaRamp)
VID_SetGammaRamp(ramps);
//VID_ShiftPalette(NULL);
}
}
#else // !GLQUAKE
void
V_UpdatePalette(void)
{
int i, j;
qboolean new;
byte *basepal, *newpal;
byte pal[768];
int r, g, b;
qboolean force;
V_CalcPowerupCshift();
new = false;
for (i = 0; i < NUM_CSHIFTS; i++) {
if (cl.cshifts[i].percent != cl.prev_cshifts[i].percent) {
new = true;
cl.prev_cshifts[i].percent = cl.cshifts[i].percent;
}
for (j = 0; j < 3; j++)
if (cl.cshifts[i].destcolor[j] != cl.prev_cshifts[i].destcolor[j]) {
new = true;
cl.prev_cshifts[i].destcolor[j] = cl.cshifts[i].destcolor[j];
}
}
// drop the damage value
cl.cshifts[CSHIFT_DAMAGE].percent -= host_frametime * 150;
if (cl.cshifts[CSHIFT_DAMAGE].percent <= 0)
cl.cshifts[CSHIFT_DAMAGE].percent = 0;
// drop the bonus value
cl.cshifts[CSHIFT_BONUS].percent -= host_frametime * 100;
if (cl.cshifts[CSHIFT_BONUS].percent <= 0)
cl.cshifts[CSHIFT_BONUS].percent = 0;
force = V_CheckGamma();
if (!new && !force)
return;
basepal = host_basepal;
newpal = pal;
for (i = 0; i < 256; i++) {
r = basepal[0];
g = basepal[1];
b = basepal[2];
basepal += 3;
for (j = 0; j < NUM_CSHIFTS; j++) {
r += (cl.cshifts[j].percent *
(cl.cshifts[j].destcolor[0] - r)) >> 8;
g += (cl.cshifts[j].percent *
(cl.cshifts[j].destcolor[1] - g)) >> 8;
b += (cl.cshifts[j].percent *
(cl.cshifts[j].destcolor[2] - b)) >> 8;
}
newpal[0] = gammatable[r];
newpal[1] = gammatable[g];
newpal[2] = gammatable[b];
newpal += 3;
}
VID_ShiftPalette(pal);
}
#endif // !GLQUAKE
/*
==============================================================================
VIEW RENDERING
==============================================================================
*/
float
angledelta(float a)
{
a = anglemod(a);
if (a >= 180)
a -= 360;
return a;
}
/*
==================
CalcGunAngle
==================
*/
void
CalcGunAngle(void)
{
float yaw, pitch, move;
static float oldyaw = 0;
static float oldpitch = 0;
yaw = r_refdef.viewangles[YAW];
pitch = -r_refdef.viewangles[PITCH];
yaw = angledelta(yaw - r_refdef.viewangles[YAW]) * 0.4;
if (yaw > 10)
yaw = 10;
if (yaw < -10)
yaw = -10;
pitch = angledelta(-pitch - r_refdef.viewangles[PITCH]) * 0.4;
if (pitch > 10)
pitch = 10;
if (pitch < -10)
pitch = -10;
move = host_frametime * 20;
if (yaw > oldyaw) {
if (oldyaw + move < yaw)
yaw = oldyaw + move;
} else {
if (oldyaw - move > yaw)
yaw = oldyaw - move;
}
if (pitch > oldpitch) {
if (oldpitch + move < pitch)
pitch = oldpitch + move;
} else {
if (oldpitch - move > pitch)
pitch = oldpitch - move;
}
oldyaw = yaw;
oldpitch = pitch;
cl.viewent.angles[YAW] = r_refdef.viewangles[YAW] + yaw;
cl.viewent.angles[PITCH] = -(r_refdef.viewangles[PITCH] + pitch);
cl.viewent.angles[ROLL] -=
v_idlescale.value * sin(cl.time * v_iroll_cycle.value) *
v_iroll_level.value;
cl.viewent.angles[PITCH] -=
v_idlescale.value * sin(cl.time * v_ipitch_cycle.value) *
v_ipitch_level.value;
cl.viewent.angles[YAW] -=
v_idlescale.value * sin(cl.time * v_iyaw_cycle.value) *
v_iyaw_level.value;
}
/*
==============
V_BoundOffsets
==============
*/
void
V_BoundOffsets(void)
{
const entity_t *ent;
ent = &cl_entities[cl.viewentity];
// absolutely bound refresh reletive to entity clipping hull
// so the view can never be inside a solid wall
if (r_refdef.vieworg[0] < ent->origin[0] - 14)
r_refdef.vieworg[0] = ent->origin[0] - 14;
else if (r_refdef.vieworg[0] > ent->origin[0] + 14)
r_refdef.vieworg[0] = ent->origin[0] + 14;
if (r_refdef.vieworg[1] < ent->origin[1] - 14)
r_refdef.vieworg[1] = ent->origin[1] - 14;
else if (r_refdef.vieworg[1] > ent->origin[1] + 14)
r_refdef.vieworg[1] = ent->origin[1] + 14;
if (r_refdef.vieworg[2] < ent->origin[2] - 22)
r_refdef.vieworg[2] = ent->origin[2] - 22;
else if (r_refdef.vieworg[2] > ent->origin[2] + 30)
r_refdef.vieworg[2] = ent->origin[2] + 30;
}
/*
==============
V_AddIdle
Idle swaying
==============
*/
void
V_AddIdle(void)
{
r_refdef.viewangles[ROLL] +=
v_idlescale.value * sin(cl.time * v_iroll_cycle.value) *
v_iroll_level.value;
r_refdef.viewangles[PITCH] +=
v_idlescale.value * sin(cl.time * v_ipitch_cycle.value) *
v_ipitch_level.value;
r_refdef.viewangles[YAW] +=
v_idlescale.value * sin(cl.time * v_iyaw_cycle.value) *
v_iyaw_level.value;
}
/*
==============
V_CalcViewRoll
Roll is induced by movement and damage
==============
*/
void
V_CalcViewRoll(void)
{
float side;
side = V_CalcRoll(cl_entities[cl.viewentity].angles, cl.velocity);
r_refdef.viewangles[ROLL] += side;
if (v_dmg_time > 0) {
r_refdef.viewangles[ROLL] +=
v_dmg_time / v_kicktime.value * v_dmg_roll;
r_refdef.viewangles[PITCH] +=
v_dmg_time / v_kicktime.value * v_dmg_pitch;
v_dmg_time -= host_frametime;
}
if (cl.stats[STAT_HEALTH] <= 0) {
r_refdef.viewangles[ROLL] = 80; // dead view angle
return;
}
}
/*
==================
V_CalcIntermissionRefdef
==================
*/
void
V_CalcIntermissionRefdef(void)
{
entity_t *ent, *view;
float old;
// ent is the player model (visible when out of body)
ent = &cl_entities[cl.viewentity];
// view is the weapon model (only visible from inside body)
view = &cl.viewent;
VectorCopy(ent->origin, r_refdef.vieworg);
VectorCopy(ent->angles, r_refdef.viewangles);
view->model = NULL;
// always idle in intermission
old = v_idlescale.value;
v_idlescale.value = 1;
V_AddIdle();
v_idlescale.value = old;
}
/*
==================
V_CalcRefdef
==================
*/
void
V_CalcRefdef(void)
{
entity_t *ent, *view;
int i;
vec3_t forward, right, up;
vec3_t angles;
float bob;
static float oldz = 0;
V_DriftPitch();
// ent is the player model (visible when out of body)
ent = &cl_entities[cl.viewentity];
// view is the weapon model (only visible from inside body)
view = &cl.viewent;
// transform the view offset by the model's matrix to get the offset from
// model origin for the view
ent->angles[YAW] = cl.viewangles[YAW]; // the model should face
// the view dir
ent->angles[PITCH] = -cl.viewangles[PITCH]; // the model should face
// the view dir
bob = V_CalcBob();
// refresh position
VectorCopy(ent->origin, r_refdef.vieworg);
r_refdef.vieworg[2] += cl.viewheight + bob;
// never let it sit exactly on a node line, because a water plane can
// dissapear when viewed with the eye exactly on it.
// the server protocol only specifies to 1/16 pixel, so add 1/32 in each axis
r_refdef.vieworg[0] += 1.0 / 32;
r_refdef.vieworg[1] += 1.0 / 32;
r_refdef.vieworg[2] += 1.0 / 32;
VectorCopy(cl.viewangles, r_refdef.viewangles);
V_CalcViewRoll();
V_AddIdle();
// offsets
angles[PITCH] = -ent->angles[PITCH]; // because entity pitches are
// actually backward
angles[YAW] = ent->angles[YAW];
angles[ROLL] = ent->angles[ROLL];
AngleVectors(angles, forward, right, up);
for (i = 0; i < 3; i++)
r_refdef.vieworg[i] += scr_ofsx.value * forward[i]
+ scr_ofsy.value * right[i]
+ scr_ofsz.value * up[i];
V_BoundOffsets();
// set up gun position
VectorCopy(cl.viewangles, view->angles);
CalcGunAngle();
VectorCopy(ent->origin, view->origin);
view->origin[2] += cl.viewheight;
for (i = 0; i < 3; i++) {
view->origin[i] += forward[i] * bob * 0.4;
// view->origin[i] += right[i]*bob*0.4;
// view->origin[i] += up[i]*bob*0.8;
}
view->origin[2] += bob;
// fudge position around to keep amount of weapon visible
// roughly equal with different FOV
if (scr_viewsize.value == 110)
view->origin[2] += 1;
else if (scr_viewsize.value == 100)
view->origin[2] += 2;
else if (scr_viewsize.value == 90)
view->origin[2] += 1;
else if (scr_viewsize.value == 80)
view->origin[2] += 0.5;
view->model = cl.model_precache[cl.stats[STAT_WEAPON]];
view->frame = cl.stats[STAT_WEAPONFRAME];
view->colormap = vid.colormap;
// set up the refresh position
VectorAdd(r_refdef.viewangles, cl.punchangle, r_refdef.viewangles);
// smooth out stair step ups
if (cl.onground && ent->origin[2] - oldz > 0) {
float steptime;
steptime = cl.time - cl.oldtime;
if (steptime < 0)
//FIXME I_Error ("steptime < 0");
steptime = 0;
oldz += steptime * 80;
if (oldz > ent->origin[2])
oldz = ent->origin[2];
if (ent->origin[2] - oldz > 12)
oldz = ent->origin[2] - 12;
r_refdef.vieworg[2] += oldz - ent->origin[2];
view->origin[2] += oldz - ent->origin[2];
} else
oldz = ent->origin[2];
if (chase_active.value)
Chase_Update();
}
/*
==================
V_RenderView
The player's clipping box goes from (-16 -16 -24) to (16 16 32) from
the entity origin, so any view position inside that will be valid
==================
*/
void
V_RenderView(void)
{
if (con_forcedup)
return;
// don't allow cheats in multiplayer
if (cl.maxclients > 1) {
Cvar_Set("scr_ofsx", "0");
Cvar_Set("scr_ofsy", "0");
Cvar_Set("scr_ofsz", "0");
}
if (cl.intermission) { // intermission / finale rendering
V_CalcIntermissionRefdef();
} else {
if (!cl.paused /* && (sv.maxclients > 1 || key_dest == key_game) */ )
V_CalcRefdef();
}
if (fisheye_enabled) {
F_RenderView();
}
else {
R_PushDlights();
R_RenderView();
}
#ifndef GLQUAKE
if (crosshair.value)
Draw_Crosshair();
#endif
}
//============================================================================
/*
=============
V_Init
=============
*/
void
V_Init(void)
{
Cmd_AddCommand("v_cshift", V_cshift_f);
Cmd_AddCommand("bf", V_BonusFlash_f);
Cmd_AddCommand("centerview", V_StartPitchDrift);
Cvar_RegisterVariable(&v_centermove);
Cvar_RegisterVariable(&v_centerspeed);
Cvar_RegisterVariable(&v_iyaw_cycle);
Cvar_RegisterVariable(&v_iroll_cycle);
Cvar_RegisterVariable(&v_ipitch_cycle);
Cvar_RegisterVariable(&v_iyaw_level);
Cvar_RegisterVariable(&v_iroll_level);
Cvar_RegisterVariable(&v_ipitch_level);
Cvar_RegisterVariable(&v_idlescale);
Cvar_RegisterVariable(&crosshair);
Cvar_RegisterVariable(&crosshaircolor);
Cvar_RegisterVariable(&cl_crossx);
Cvar_RegisterVariable(&cl_crossy);
#ifdef GLQUAKE
Cvar_RegisterVariable(&gl_cshiftpercent);
#endif
Cvar_RegisterVariable(&scr_ofsx);
Cvar_RegisterVariable(&scr_ofsy);
Cvar_RegisterVariable(&scr_ofsz);
Cvar_RegisterVariable(&cl_rollspeed);
Cvar_RegisterVariable(&cl_rollangle);
Cvar_RegisterVariable(&cl_bob);
Cvar_RegisterVariable(&cl_bobcycle);
Cvar_RegisterVariable(&cl_bobup);
Cvar_RegisterVariable(&v_kicktime);
Cvar_RegisterVariable(&v_kickroll);
Cvar_RegisterVariable(&v_kickpitch);
BuildGammaTable(1.0); // no gamma yet
Cvar_RegisterVariable(&v_gamma);
}
| 23.141584 | 79 | 0.617465 |
889be05a9cb1d6a5bcfb8fdc112c6373b57a9f9c | 14,284 | h | C | s32v234_sdk/libs/isp/cam_generic/kernel/include/ov10635_config_viu.h | intesight/Panorama4AIWAYS | 46e1988e54a5155be3b3b47c486b3f722be00b5c | [
"WTFPL"
] | null | null | null | s32v234_sdk/libs/isp/cam_generic/kernel/include/ov10635_config_viu.h | intesight/Panorama4AIWAYS | 46e1988e54a5155be3b3b47c486b3f722be00b5c | [
"WTFPL"
] | null | null | null | s32v234_sdk/libs/isp/cam_generic/kernel/include/ov10635_config_viu.h | intesight/Panorama4AIWAYS | 46e1988e54a5155be3b3b47c486b3f722be00b5c | [
"WTFPL"
] | 2 | 2021-01-21T02:06:16.000Z | 2021-01-28T10:47:37.000Z | /*
* Copyright (c) 2015-2016 Freescale Semiconductor
* Copyright 2017 NXP
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o 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.
*
* o Neither the name of NXP nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \file ov10635_config_viu.h
* \brief definition of ov10635 camera registers configuration for viu
* \author Tomas Babinec
* \version 0.1
* \date 31.3.2015
* \note
****************************************************************************/
#ifndef OV10635CONFIGVIU_H
#define OV10635CONFIGVIU_H
static uint8_t Ov10635Viu_Table[] = {
0x01,0x03,0x01,
0x30,0x1b,0xff,
0x30,0x1c,0xff,
0x30,0x1a,0xff,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x0c,0x61,
0x30,0x21,0x03,
0x30,0x11,0x02,
0x69,0x00,0x0c,
0x69,0x01,0x01,
0x30,0x33,0x08,
0x35,0x03,0x10,
0x30,0x2d,0x2f,
0x30,0x25,0x03,
0x30,0x03,0x20,
0x30,0x04,0x23,
0x30,0x05,0x20,
0x30,0x06,0x91,
0x36,0x00,0x74,
0x36,0x01,0x2b,
0x36,0x12,0x00,
0x36,0x11,0x67,
0x36,0x33,0xba,
0x36,0x02,0x2f,
0x36,0x03,0x00,
0x36,0x30,0xa8,
0x36,0x31,0x16,
0x37,0x14,0x10,
0x37,0x1d,0x01,
0x43,0x00,0x38,
0x30,0x07,0x01,
0x30,0x24,0x01,
0x30,0x20,0x0b,
0x37,0x02,0x10,
0x37,0x03,0x24,
0x37,0x04,0x19,
0x37,0x09,0x28,
0x37,0x0d,0x00,
0x37,0x12,0x00,
0x37,0x13,0x20,
0x37,0x15,0x04,
0x38,0x1d,0x40,
0x38,0x1c,0x00,
0x38,0x24,0x10,
0x38,0x15,0x8c,
0x38,0x04,0x05,
0x38,0x05,0x1f,
0x38,0x00,0x00,
0x38,0x01,0x00,
0x38,0x06,0x03,
0x38,0x07,0x29,
0x38,0x02,0x00,
0x38,0x03,0x06,
0x38,0x08,0x05,
0x38,0x09,0x00,
0x38,0x0a,0x03,
0x38,0x0b,0x20,
0x38,0x0c,0x07,
0x38,0x0d,0x71,
0x38,0x0e,0x03,
0x38,0x0f,0x48,
0x38,0x11,0x08,
0x38,0x1f,0x0c,
0x36,0x21,0x63,
0x50,0x05,0x08,
0x56,0xd5,0x00,
0x56,0xd6,0x80,
0x56,0xd7,0x00,
0x56,0xd8,0x00,
0x56,0xd9,0x00,
0x56,0xda,0x80,
0x56,0xdb,0x00,
0x56,0xdc,0x00,
0x56,0xe8,0x00,
0x56,0xe9,0x7f,
0x56,0xea,0x00,
0x56,0xeb,0x7f,
0x51,0x00,0x00,
0x51,0x01,0x80,
0x51,0x02,0x00,
0x51,0x03,0x80,
0x51,0x04,0x00,
0x51,0x05,0x80,
0x51,0x06,0x00,
0x51,0x07,0x80,
0x51,0x08,0x00,
0x51,0x09,0x00,
0x51,0x0a,0x00,
0x51,0x0b,0x00,
0x51,0x0c,0x00,
0x51,0x0d,0x00,
0x51,0x0e,0x00,
0x51,0x0f,0x00,
0x51,0x10,0x00,
0x51,0x11,0x80,
0x51,0x12,0x00,
0x51,0x13,0x80,
0x51,0x14,0x00,
0x51,0x15,0x80,
0x51,0x16,0x00,
0x51,0x17,0x80,
0x51,0x18,0x00,
0x51,0x19,0x00,
0x51,0x1a,0x00,
0x51,0x1b,0x00,
0x51,0x1c,0x00,
0x51,0x1d,0x00,
0x51,0x1e,0x00,
0x51,0x1f,0x00,
0x56,0xd0,0x00,
0x50,0x06,0x24,
0x56,0x08,0x00,
0x52,0xd7,0x06,
0x52,0x8d,0x08,
0x52,0x93,0x12,
0x52,0xd3,0x12,
0x52,0x88,0x06,
0x52,0x89,0x20,
0x52,0xc8,0x06,
0x52,0xc9,0x20,
0x52,0xcd,0x04,
0x53,0x81,0x00,
0x53,0x82,0xff,
0x55,0x89,0x76,
0x55,0x8a,0x47,
0x55,0x8b,0xef,
0x55,0x8c,0xc9,
0x55,0x8d,0x49,
0x55,0x8e,0x30,
0x55,0x8f,0x67,
0x55,0x90,0x3f,
0x55,0x91,0xf0,
0x55,0x92,0x10,
0x55,0xa2,0x6d,
0x55,0xa3,0x55,
0x55,0xa4,0xc3,
0x55,0xa5,0xb5,
0x55,0xa6,0x43,
0x55,0xa7,0x38,
0x55,0xa8,0x5f,
0x55,0xa9,0x4b,
0x55,0xaa,0xf0,
0x55,0xab,0x10,
0x55,0x81,0x52,
0x53,0x00,0x01,
0x53,0x01,0x00,
0x53,0x02,0x00,
0x53,0x03,0x0e,
0x53,0x04,0x00,
0x53,0x05,0x0e,
0x53,0x06,0x00,
0x53,0x07,0x36,
0x53,0x08,0x00,
0x53,0x09,0xd9,
0x53,0x0a,0x00,
0x53,0x0b,0x0f,
0x53,0x0c,0x00,
0x53,0x0d,0x2c,
0x53,0x0e,0x00,
0x53,0x0f,0x59,
0x53,0x10,0x00,
0x53,0x11,0x7b,
0x53,0x12,0x00,
0x53,0x13,0x22,
0x53,0x14,0x00,
0x53,0x15,0xd5,
0x53,0x16,0x00,
0x53,0x17,0x13,
0x53,0x18,0x00,
0x53,0x19,0x18,
0x53,0x1a,0x00,
0x53,0x1b,0x26,
0x53,0x1c,0x00,
0x53,0x1d,0xdc,
0x53,0x1e,0x00,
0x53,0x1f,0x02,
0x53,0x20,0x00,
0x53,0x21,0x24,
0x53,0x22,0x00,
0x53,0x23,0x56,
0x53,0x24,0x00,
0x53,0x25,0x85,
0x53,0x26,0x00,
0x53,0x27,0x20,
0x56,0x09,0x01,
0x56,0x0a,0x40,
0x56,0x0b,0x01,
0x56,0x0c,0x40,
0x56,0x0d,0x00,
0x56,0x0e,0xfa,
0x56,0x0f,0x00,
0x56,0x10,0xfa,
0x56,0x11,0x02,
0x56,0x12,0x80,
0x56,0x13,0x02,
0x56,0x14,0x80,
0x56,0x15,0x01,
0x56,0x16,0x2c,
0x56,0x17,0x01,
0x56,0x18,0x2c,
0x56,0x3b,0x01,
0x56,0x3c,0x01,
0x56,0x3d,0x01,
0x56,0x3e,0x01,
0x56,0x3f,0x03,
0x56,0x40,0x03,
0x56,0x41,0x03,
0x56,0x42,0x05,
0x56,0x43,0x09,
0x56,0x44,0x05,
0x56,0x45,0x05,
0x56,0x46,0x05,
0x56,0x47,0x05,
0x56,0x51,0x00,
0x56,0x52,0x80,
0x52,0x1a,0x01,
0x52,0x1b,0x03,
0x52,0x1c,0x06,
0x52,0x1d,0x0a,
0x52,0x1e,0x0e,
0x52,0x1f,0x12,
0x52,0x20,0x16,
0x52,0x23,0x02,
0x52,0x25,0x04,
0x52,0x27,0x08,
0x52,0x29,0x0c,
0x52,0x2b,0x12,
0x52,0x2d,0x18,
0x52,0x2f,0x1e,
0x52,0x41,0x04,
0x52,0x42,0x01,
0x52,0x43,0x03,
0x52,0x44,0x06,
0x52,0x45,0x0a,
0x52,0x46,0x0e,
0x52,0x47,0x12,
0x52,0x48,0x16,
0x52,0x4a,0x03,
0x52,0x4c,0x04,
0x52,0x4e,0x08,
0x52,0x50,0x0c,
0x52,0x52,0x12,
0x52,0x54,0x18,
0x52,0x56,0x1e,
0x46,0x05,0x08,
0x46,0x06,0x07,
0x46,0x07,0x71,
0x46,0x0a,0x02,
0x46,0x0b,0x70,
0x46,0x0c,0x00,
0x46,0x20,0x0e,
0x47,0x00,0x04,
0x47,0x01,0x00,
0x47,0x02,0x01,
0x47,0x08,0x01,
0x40,0x04,0x08,
0x40,0x05,0x18,
0x40,0x01,0x04,
0x40,0x50,0x20,
0x40,0x51,0x22,
0x40,0x57,0x9c,
0x40,0x5a,0x00,
0x42,0x02,0x02,
0x30,0x23,0x10,
0x01,0x00,0x01,
0x01,0x00,0x01,
0x6f,0x0e,0x00,
0x6f,0x0f,0x00,
0x46,0x0e,0x08,
0x46,0x0f,0x01,
0x46,0x10,0x00,
0x46,0x11,0x01,
0x46,0x12,0x00,
0x46,0x13,0x01,
0x46,0x05,0x08,
0x46,0x08,0x00,
0x46,0x09,0x08,
0x68,0x04,0x00,
0x68,0x05,0x06,
0x68,0x06,0x00,
0x51,0x20,0x00,
0x35,0x10,0x00,
0x35,0x04,0x00,
0x68,0x00,0x00,
0x6f,0x0d,0x00,
0x50,0x00,0xff,
0x50,0x01,0xbf,
0x50,0x02,0xfe,
0x50,0x3d,0x00,
0xc4,0x50,0x01,
0xc4,0x52,0x04,
0xc4,0x53,0x00,
0xc4,0x54,0x00,
0xc4,0x55,0x00,
0xc4,0x56,0x00,
0xc4,0x57,0x00,
0xc4,0x58,0x00,
0xc4,0x59,0x00,
0xc4,0x5b,0x00,
0xc4,0x5c,0x00,
0xc4,0x5d,0x00,
0xc4,0x5e,0x00,
0xc4,0x5f,0x00,
0xc4,0x60,0x00,
0xc4,0x61,0x01,
0xc4,0x62,0x01,
0xc4,0x64,0x88,
0xc4,0x65,0x00,
0xc4,0x66,0x8a,
0xc4,0x67,0x00,
0xc4,0x68,0x86,
0xc4,0x69,0x00,
0xc4,0x6a,0x40,
0xc4,0x6b,0x50,
0xc4,0x6c,0x30,
0xc4,0x6d,0x28,
0xc4,0x6e,0x60,
0xc4,0x6f,0x40,
0xc4,0x7c,0x01,
0xc4,0x7d,0x38,
0xc4,0x7e,0x00,
0xc4,0x7f,0x00,
0xc4,0x80,0x00,
0xc4,0x81,0xff,
0xc4,0x82,0x00,
0xc4,0x83,0x40,
0xc4,0x84,0x00,
0xc4,0x85,0x18,
0xc4,0x86,0x00,
0xc4,0x87,0x18,
0xc4,0x88,0x34,
0xc4,0x89,0x00,
0xc4,0x8a,0x34,
0xc4,0x8b,0x00,
0xc4,0x8c,0x00,
0xc4,0x8d,0x04,
0xc4,0x8e,0x00,
0xc4,0x8f,0x04,
0xc4,0x90,0x07,
0xc4,0x92,0x20,
0xc4,0x93,0x08,
0xc4,0x98,0x02,
0xc4,0x99,0x00,
0xc4,0x9a,0x02,
0xc4,0x9b,0x00,
0xc4,0x9c,0x02,
0xc4,0x9d,0x00,
0xc4,0x9e,0x02,
0xc4,0x9f,0x60,
0xc4,0xa0,0x04,
0xc4,0xa1,0x00,
0xc4,0xa2,0x06,
0xc4,0xa3,0x00,
0xc4,0xa4,0x00,
0xc4,0xa5,0x10,
0xc4,0xa6,0x00,
0xc4,0xa7,0x40,
0xc4,0xa8,0x00,
0xc4,0xa9,0x80,
0xc4,0xaa,0x0d,
0xc4,0xab,0x00,
0xc4,0xac,0x0f,
0xc4,0xad,0xc0,
0xc4,0xb4,0x01,
0xc4,0xb5,0x01,
0xc4,0xb6,0x00,
0xc4,0xb7,0x01,
0xc4,0xb8,0x00,
0xc4,0xb9,0x01,
0xc4,0xba,0x01,
0xc4,0xbb,0x00,
0xc4,0xbe,0x02,
0xc4,0xbf,0x33,
0xc4,0xc8,0x03,
0xc4,0xc9,0xd0,
0xc4,0xca,0x0e,
0xc4,0xcb,0x00,
0xc4,0xcc,0x10,
0xc4,0xcd,0x18,
0xc4,0xce,0x10,
0xc4,0xcf,0x18,
0xc4,0xd0,0x04,
0xc4,0xd1,0x80,
0xc4,0xe0,0x04,
0xc4,0xe1,0x02,
0xc4,0xe2,0x01,
0xc4,0xe4,0x10,
0xc4,0xe5,0x20,
0xc4,0xe6,0x30,
0xc4,0xe7,0x40,
0xc4,0xe8,0x50,
0xc4,0xe9,0x60,
0xc4,0xea,0x70,
0xc4,0xeb,0x80,
0xc4,0xec,0x90,
0xc4,0xed,0xa0,
0xc4,0xee,0xb0,
0xc4,0xef,0xc0,
0xc4,0xf0,0xd0,
0xc4,0xf1,0xe0,
0xc4,0xf2,0xf0,
0xc4,0xf3,0x80,
0xc4,0xf4,0x00,
0xc4,0xf5,0x20,
0xc4,0xf6,0x02,
0xc4,0xf7,0x00,
0xc4,0xf8,0x04,
0xc4,0xf9,0x0b,
0xc4,0xfa,0x00,
0xc4,0xfb,0x01,
0xc4,0xfc,0x01,
0xc4,0xfd,0x00,
0xc4,0xfe,0x04,
0xc4,0xff,0x02,
0xc5,0x00,0x68,
0xc5,0x01,0x74,
0xc5,0x02,0x70,
0xc5,0x03,0x80,
0xc5,0x04,0x05,
0xc5,0x05,0x80,
0xc5,0x06,0x03,
0xc5,0x07,0x80,
0xc5,0x08,0x01,
0xc5,0x09,0xc0,
0xc5,0x0a,0x01,
0xc5,0x0b,0xa0,
0xc5,0x0c,0x01,
0xc5,0x0d,0x2c,
0xc5,0x0e,0x01,
0xc5,0x0f,0x0a,
0xc5,0x10,0x00,
0xc5,0x11,0x01,
0xc5,0x12,0x01,
0xc5,0x13,0x80,
0xc5,0x14,0x04,
0xc5,0x15,0x00,
0xc5,0x18,0x03,
0xc5,0x19,0x48,
0xc5,0x1a,0x07,
0xc5,0x1b,0x70,
0xc2,0xe0,0x00,
0xc2,0xe1,0x51,
0xc2,0xe2,0x00,
0xc2,0xe3,0xd6,
0xc2,0xe4,0x01,
0xc2,0xe5,0x5e,
0xc2,0xe9,0x01,
0xc2,0xea,0x7a,
0xc2,0xeb,0x90,
0xc2,0xed,0x00,
0xc2,0xee,0x7a,
0xc2,0xef,0x64,
0xc3,0x08,0x00,
0xc3,0x09,0x00,
0xc3,0x0a,0x00,
0xc3,0x0c,0x00,
0xc3,0x0d,0x01,
0xc3,0x0e,0x00,
0xc3,0x0f,0x00,
0xc3,0x10,0x01,
0xc3,0x11,0x60,
0xc3,0x12,0xff,
0xc3,0x13,0x08,
0xc3,0x14,0x01,
0xc3,0x15,0x7f,
0xc3,0x16,0xff,
0xc3,0x17,0x0b,
0xc3,0x18,0x00,
0xc3,0x19,0x0c,
0xc3,0x1a,0x00,
0xc3,0x1b,0xe0,
0xc3,0x1c,0x00,
0xc3,0x1d,0x14,
0xc3,0x1e,0x00,
0xc3,0x1f,0xc5,
0xc3,0x20,0xff,
0xc3,0x21,0x4b,
0xc3,0x22,0xff,
0xc3,0x23,0xf0,
0xc3,0x24,0xff,
0xc3,0x25,0xe8,
0xc3,0x26,0x00,
0xc3,0x27,0x46,
0xc3,0x28,0xff,
0xc3,0x29,0xd2,
0xc3,0x2a,0xff,
0xc3,0x2b,0xe4,
0xc3,0x2c,0xff,
0xc3,0x2d,0xbb,
0xc3,0x2e,0x00,
0xc3,0x2f,0x61,
0xc3,0x30,0xff,
0xc3,0x31,0xf9,
0xc3,0x32,0x00,
0xc3,0x33,0xd9,
0xc3,0x34,0x00,
0xc3,0x35,0x2e,
0xc3,0x36,0x00,
0xc3,0x37,0xb1,
0xc3,0x38,0xff,
0xc3,0x39,0x64,
0xc3,0x3a,0xff,
0xc3,0x3b,0xeb,
0xc3,0x3c,0xff,
0xc3,0x3d,0xe8,
0xc3,0x3e,0x00,
0xc3,0x3f,0x48,
0xc3,0x40,0xff,
0xc3,0x41,0xd0,
0xc3,0x42,0xff,
0xc3,0x43,0xed,
0xc3,0x44,0xff,
0xc3,0x45,0xad,
0xc3,0x46,0x00,
0xc3,0x47,0x66,
0xc3,0x48,0x01,
0xc3,0x49,0x00,
0x67,0x00,0x04,
0x67,0x01,0x7b,
0x67,0x02,0xfd,
0x67,0x03,0xf9,
0x67,0x04,0x3d,
0x67,0x05,0x71,
0x67,0x06,0x71,
0x67,0x08,0x05,
0x38,0x22,0x50,
0x6f,0x06,0x6f,
0x6f,0x07,0x00,
0x6f,0x0a,0x6f,
0x6f,0x0b,0x00,
0x6f,0x00,0x03,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x42,0xf0,
0x30,0x1b,0xf0,
0x30,0x1c,0xf0,
0x30,0x1a,0xf0,
0xc4,0xbc,0x01,
0xc4,0xbd,0x60,
0xc4,0xa0,0x03,
0xc4,0xa2,0x04,
0x30,0x11,0x42,
0x30,0x04,0x21,
0x37,0x02,0x20,
0x37,0x03,0x48,
0x37,0x04,0x32,
// additions
//pixel clock = 94.5sMHz
0x30,0x04,0x01,
0x30,0x03,0x0E,
//VSYNC length
0x47,0x01,0x04,
// Change of format
0x43,0x00,0x3A,
#if 0
// Test Pattern
0x30,0x42,0xF9, // to do after sw reset and before enabling test pattern (see p38)
0x50,0x00,0x78, // Turn off certain ISP blocks for consistent patterns
// Colour bar
0x50,0x3D,0x80 // enabling digital pattern + choice of pattern
#endif
}; //Ov10635Viu_Table[]
#endif /* OV10635CONFIGVIU_H */
| 21.642424 | 87 | 0.618944 |
002d759bacace575c2461156d3a10c17f359e00b | 1,208 | h | C | extensions/concatrangescript.h | yzhang123/pynini | 46d9e5b7eaead76c6b29ba57b039fdde9cdf0d20 | [
"Apache-2.0"
] | 1 | 2021-04-09T22:57:07.000Z | 2021-04-09T22:57:07.000Z | extensions/concatrangescript.h | yzhang123/pynini | 46d9e5b7eaead76c6b29ba57b039fdde9cdf0d20 | [
"Apache-2.0"
] | null | null | null | extensions/concatrangescript.h | yzhang123/pynini | 46d9e5b7eaead76c6b29ba57b039fdde9cdf0d20 | [
"Apache-2.0"
] | null | null | null | // Copyright 2016-2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef PYNINI_CONCATRANGESCRIPT_H_
#define PYNINI_CONCATRANGESCRIPT_H_
#include <utility>
#include <fst/script/fst-class.h>
#include "concatrange.h"
namespace fst {
namespace script {
using ConcatRangeArgs = std::tuple<MutableFstClass *, int32, int32>;
template <class Arc>
void ConcatRange(ConcatRangeArgs *args) {
MutableFst<Arc> *fst = std::get<0>(*args)->GetMutableFst<Arc>();
ConcatRange(fst, std::get<1>(*args), std::get<2>(*args));
}
void ConcatRange(MutableFstClass *fst, int32 lower = 0, int32 upper = 0);
} // namespace script
} // namespace fst
#endif // PYNINI_CONCATRANGESCRIPT_H_
| 28.093023 | 75 | 0.735927 |
29d47d81a6e8f534fe84ffbf646574276ec7a22f | 2,318 | h | C | Source/StrategyPrototype/Public/Objects/SP_ItemFactory.h | ualikhansars/strategyPrototype | 3fbd7a067b1e38ed1862dfb044d55bbcbf1144dc | [
"MIT"
] | 4 | 2020-05-27T00:50:05.000Z | 2020-11-01T06:19:15.000Z | Source/StrategyPrototype/Public/Objects/SP_ItemFactory.h | ualikhansars/strategyPrototype | 3fbd7a067b1e38ed1862dfb044d55bbcbf1144dc | [
"MIT"
] | null | null | null | Source/StrategyPrototype/Public/Objects/SP_ItemFactory.h | ualikhansars/strategyPrototype | 3fbd7a067b1e38ed1862dfb044d55bbcbf1144dc | [
"MIT"
] | null | null | null | #pragma once
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "UObject/ConstructorHelpers.h"
#include "Engine/Texture2D.h"
#include "Templates/SharedPointer.h"
#include "SP_ItemFactory.generated.h"
UENUM(BlueprintType)
enum class SP_ItemCategory : uint8
{
Armory,
Food,
Jewelry,
Resource,
Weapon
};
UENUM(BlueprintType)
enum class SP_ItemOwner : uint8
{
Player,
NPC,
Town
};
UENUM(BlueprintType)
enum class SP_ItemType : uint8
{
Apple,
Axe,
Bread,
Copper,
Helmet,
Iron,
Sword,
Necklace,
Wood
};
USTRUCT(BlueprintType)
struct FSP_Item
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadOnly)
FString Name;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
SP_ItemType Type;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
float Cost;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
SP_ItemCategory Category;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
SP_ItemOwner Owner;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
bool Consumable = false;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
float NutritionalValue = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
bool bEmpty = true;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
TWeakObjectPtr<UTexture2D> ItemTexture;
FSP_Item() {}
~FSP_Item() {}
FSP_Item(FString Name, SP_ItemType Type, float Cost, SP_ItemCategory Category, SP_ItemOwner Owner, UTexture2D* Texture)
:Name(Name), Type(Type), Cost(Cost), Category(Category), Owner(Owner)
{
bEmpty = false;
ItemTexture = Texture;
}
FSP_Item(FString Name, SP_ItemType Type, float Cost, SP_ItemCategory Category, SP_ItemOwner Owner, bool Consumable, float NutritionalValue, UTexture2D* Texture)
:Name(Name), Type(Type), Cost(Cost), Category(Category), Owner(Owner), Consumable(Consumable), NutritionalValue(NutritionalValue), bEmpty(false)
{
ItemTexture = Texture;
}
bool operator==(const FSP_Item& OtherItem) const
{
if (Name == OtherItem.Name && Type == OtherItem.Type && Cost == OtherItem.Cost && Category == OtherItem.Category)
{
return true;
}
else
{
return false;
}
}
void SetOwner(SP_ItemOwner NewOwner)
{
Owner = NewOwner;
}
};
UCLASS()
class STRATEGYPROTOTYPE_API USP_ItemFactory : public UObject
{
GENERATED_BODY()
UTexture2D* Texture;
public:
static FSP_Item CreateItem(SP_ItemType Type, SP_ItemOwner Owner);
};
| 20.513274 | 161 | 0.75755 |
4b5d4c4200e215affc6515e0c8088520707d5dd9 | 396 | h | C | src/texture_cache.h | RamblingIndieGames/openjamgame-2019 | 2ce913d1324f6648e9434c4346888adf210bfdde | [
"MIT"
] | null | null | null | src/texture_cache.h | RamblingIndieGames/openjamgame-2019 | 2ce913d1324f6648e9434c4346888adf210bfdde | [
"MIT"
] | null | null | null | src/texture_cache.h | RamblingIndieGames/openjamgame-2019 | 2ce913d1324f6648e9434c4346888adf210bfdde | [
"MIT"
] | null | null | null | #ifndef __TEXTURE_H__
struct cachedtexture_t {
int id;
int width;
int height;
void* raw_data;
};
extern struct cachedtexture_t* textures;
extern int texture_count;
extern void add_texture_to_cache(int id, char* filename);
extern struct cachedtexture_t* get_texture_by_id(int id);
extern void unload_texture_by_id(int id);
extern void destroy_texture_cache();
#endif // !__TEXTURE_H__
| 20.842105 | 57 | 0.785354 |
e4111cc4646a814a45a4f32bbea5cd0bf6eab753 | 1,783 | h | C | Shared/PredictionMethods.h | mdejong/MetalMED | d570a46150b3ea4f6b3d53d3a3d7abc404e75324 | [
"MIT"
] | null | null | null | Shared/PredictionMethods.h | mdejong/MetalMED | d570a46150b3ea4f6b3d53d3a3d7abc404e75324 | [
"MIT"
] | 1 | 2021-07-29T09:29:12.000Z | 2021-07-29T18:33:34.000Z | Shared/PredictionMethods.h | mdejong/MetalMED | d570a46150b3ea4f6b3d53d3a3d7abc404e75324 | [
"MIT"
] | null | null | null | //
// PredictionMethods.h
//
// Created by Mo DeJong on 6/4/18.
// Copyright © 2018 helpurock. All rights reserved.
//
#ifndef _PredictionMethods_hpp
#define _PredictionMethods_hpp
#include <stdlib.h>
// Encode N byte symbols into and output buffer of at least n.
// Returns the number of bytes written to encodedBytes, this
// number of bytes should be less than the original???
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
// Read n bytes from inBytePtr and emit n symbols with fixed bit width
// calculated from input power of 2 value k (0 = 1, 1 = 2, 2 = 4).
// The returned buffer is dynamically allocated with malloc() and
// must be released via free(). NULL is returned if memory cannot be allocted.
void med_encode_pred32_error(
const uint32_t *inSamplesPtr,
uint32_t *outPredErrPtr,
const int width,
const int height,
int originX,
int originY,
int regionWidth,
int regionHeight
);
void med_decode_pred32_error(
const uint32_t *inPredErrPtr,
uint32_t *outSamplesPtr,
const int width,
const int height,
int originX,
int originY,
int regionWidth,
int regionHeight
);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // _PredictionMethods_hpp
| 33.641509 | 78 | 0.496915 |
5b7e11bc6f748ab6d04f4056c361fcc4f21293c2 | 2,296 | h | C | MGSDKDemo/Pods/MGUnionSDK/MGUnionSDK/MGUnionSDK.framework/Headers/MGApi.h | StartEnd/MGUnionSDK | 8d5b610e73e6eacfd0abc471418ae1a0feb458b2 | [
"MIT"
] | null | null | null | MGSDKDemo/Pods/MGUnionSDK/MGUnionSDK/MGUnionSDK.framework/Headers/MGApi.h | StartEnd/MGUnionSDK | 8d5b610e73e6eacfd0abc471418ae1a0feb458b2 | [
"MIT"
] | null | null | null | MGSDKDemo/Pods/MGUnionSDK/MGUnionSDK/MGUnionSDK.framework/Headers/MGApi.h | StartEnd/MGUnionSDK | 8d5b610e73e6eacfd0abc471418ae1a0feb458b2 | [
"MIT"
] | null | null | null | //
// MGApi.h
// MGUnionSDK
//
// Created by Mr.Song on 2020/4/7.
// Copyright © 2020 StartEnd. All rights reserved.
//
#import <Foundation/Foundation.h>
@protocol MGUnionSDKDelegate;
/// 支付错误
typedef NS_ENUM (NSInteger,MGPayErrCode) {
MGSDKPay_Err_Ok = 0, //Pay成功
MGSDKPay_Err_OrderErr = -1, //获取订单失败
MGSDKPay_Err_ProductErr = -2, //获取产品失败
MGSDKPay_Err_PaymentErr = -3, //支付失败
MGSDKPay_Err_VerifyErr = -4 //校验订单失败
};
typedef void (^MGPaymentBlock)(NSString *orderNum,NSString *cpext, MGPayErrCode error);
typedef NS_ENUM (NSInteger,MGAuthErrCode) {
MGSDKAuth_Err_Ok = 0, //Auth成功
MGSDKAuth_Err_NormalErr = -1, //普通错误
MGSDKAuth_Err_NetworkErr = -2, //网络错误
};
@interface MGApi : NSObject
/**
注册SDK
@param appid 游戏的appid
@parame weiboAppid 微博appid
@parame wechatAppid 微信appid
@parame wechatUniversalLink 微信universalLink
@param delegate SDK代理(推荐用AppDelegate)
*/
+ (void)registerApp:(NSString *)appid weiboApp:(NSString *)weiboAppid wechatAppid:(NSString *)wechatAppid wechatUniversalLink:(NSString *)wechatUniversalLink delegate:(id<MGUnionSDKDelegate>)delegate;
/// 登陆
+ (void)login;
/// 用户信息界面,未登录用户会弹出绑定窗口
+ (void)userCenter;
/**
支付
@param productid 下单的产品id
@param price 产品价格,单位分,字符串形式传递
@param cpext 透传参数,游戏订单校验用
@param paymentBlock 支付回调
*/
+ (void)paymentWithProductid:(NSString *)productid
price:(NSString *)price
cpext:(NSString *)cpext
callback:(MGPaymentBlock)paymentBlock;
/// 打开调试模式
+ (void)enableDebugMode:(BOOL)enabled;
/// 测试内部功能页面
+ (void) testInternalFunc;
/// 处理回调
+ (BOOL)handleOpenURL:(NSURL *)url;
/// 处理回调 新版微信适用
+ (BOOL)handleOpenUniversalLink:(NSUserActivity *)userActivity;
@end
@protocol MGUnionSDKDelegate
@required
/**
账号退出(用户切换账号成功后调用)
@param uid 退出账号的uid
*/
- (void)mg_logout:(NSString *)uid;
/**
账号登录
@param userInfo 用户信息
@param err 错误信息
*/
- (void)mg_login:(NSDictionary *)userInfo error:(MGAuthErrCode )err;
/**
旧订单验证回调
初次下单付款后因某些原因验证失败,后续中订单被验证通过
@param orderid 订单标识
*/
- (void)mg_oldOrderVerficationSuccess:(NSString *)orderid;
@end
| 19.965217 | 201 | 0.652875 |
a0df0fd2ea791523d306c659293fadfe45a05a06 | 7,125 | h | C | src/glyphwidths.h | AllanCameron/PDFR | 15abe85d853295258a30f63a8aaa09f40c772e6f | [
"MIT"
] | 20 | 2019-02-14T12:22:17.000Z | 2022-02-17T02:52:01.000Z | src/glyphwidths.h | AllanCameron/PDFR | 15abe85d853295258a30f63a8aaa09f40c772e6f | [
"MIT"
] | 2 | 2018-12-04T21:36:01.000Z | 2019-07-25T21:17:02.000Z | src/glyphwidths.h | AllanCameron/PDFR | 15abe85d853295258a30f63a8aaa09f40c772e6f | [
"MIT"
] | 1 | 2020-03-19T20:16:59.000Z | 2020-03-19T20:16:59.000Z | //---------------------------------------------------------------------------//
// //
// PDFR GlyphWidths header file //
// //
// Copyright (C) 2018 - 2019 by Allan Cameron //
// //
// Licensed under the MIT license - see https://mit-license.org //
// or the LICENSE file in the project root directory //
// //
//---------------------------------------------------------------------------//
#ifndef PDFR_WIDTH
//---------------------------------------------------------------------------//
#define PDFR_WIDTH
/* This is the joint 6th in a series of daisy-chained headers that build up the
* tools to read and parse pdfs. It is logically paired with encoding.h
* in that they both come after document.h and together form the basis for the
* next step, which is font creation.
*
* Calculating the width of each glyph is necessary for working out the spacing
* between letters, words, paragraphs and other text elements. The glyph widths
* in pdf are given in units of text space, where 1000 = 1 point = 1/72 inch in
* 1-point font size.
*
* Getting the glyph widths is one of the more complex tasks in extracting text,
* since there are various ways for pdf files to describe them. The most
* explicit way is by listing the font widths at each code point in an array.
* The array is preceeded by the first code point that is being described,
* then the array itself comprises numbers for the widths of sequential code
* points. Often there are several consecutive arrays like this specifying
* groups of sequential code points. Sometimes the entry is just an array of
* widths, and the first code point is given seperately in the font
* dictionary. Sometimes there is a default width for missing glyphs. Sometimes
* the width array is in the font dictionary; sometimes it is in a descendant
* font dictionary; other times it is in an encoded stream; still other times
* it comprises an entire non-dictionary object on its own.
*
* In older pdfs, the widths may not be specified at all if the font used is
* one of 14 core fonts in the pdf specification. A conforming reader is
* supposed to know the glyph widths for these fonts.
*
* The glyphwidth class attempts to work out the method used to describe
* glyph widths and produce a map of the intended glyphs to their intended
* widths, without bothering any other classes with its implementation.
*
* Among the tools it needs to do this, it requires navigating the document,
* reading dictionaries and streams, and parsing a width description array.
* It therefore needs the document.h header which wraps most of these
* capabilities. The class defines its own lexer for interpreting the special
* width arrays.
*
* It also needs a group of static objects listing the widths of each of the
* characters used in the 'built-in' fonts used in pdfs. In theory, later
* versions of pdf require specification of all glyph widths, but for back-
* compatibility, the widths of the 14 core fonts still need to be defined.
*
* The widths are available as an open online resource from Adobe.
*
* To preserve encapsulation, this header is included only by the fonts
* class. The fonts class merges its width map with the encoding map to
* produce the glyphmap, which gives the intended Unicode code point and
* width as a paired value for any given input character in a pdf string.
*/
//---------------------------------------------------------------------------//
#include<string>
#include<vector>
#include<unordered_map>
#include<memory>
class Dictionary;
class Document;
using Unicode = uint16_t;
using RawChar = uint16_t;
//---------------------------------------------------------------------------//
// The GlyphWidths class contains private methods to find the description of
// widths for each character in a font. It only makes sense to the font class,
// from whence it is created and accessed.
//
// The core font widths are declared static private because they are only
// needed by this class, and we don't want an extra copy of all of them if
// several fonts are created. This also prevents them polluting the global
// namespace.
class GlyphWidths
{
public:
// Constructor
GlyphWidths(Dictionary& font_dictionary_ptr,
std::shared_ptr<Document> document_ptr);
// public methods
float GetWidth(const RawChar& code_point); // Get width of character code
std::vector<RawChar> WidthKeys(); // Returns all map keys
inline bool WidthsAreForRaw() const { return width_is_pre_interpretation_; }
private:
// This enum is used in the width array lexer
enum WidthState {NEWSYMB, READFIRSTCHAR, READSECONDCHAR,
READWIDTH, INSUBARRAY, END};
// private data
std::unordered_map<RawChar, float> width_map_; // The main data member
Dictionary& font_dictionary_; // The font dictionary
std::shared_ptr<Document> document_; // Pointer to document
std::string base_font_; // The base font (if any)
bool width_is_pre_interpretation_; // Are widths for code points
// pre- or post- translation?
// private methods
void ParseWidthArray_(const std::string&); // Width lexer
void ReadCoreFont_(); // Core font getter
void ParseDescendants_(); // Gets descendant dictionary
void ParseWidths_(); // Parses the width array
void ReadWidthTable_(); // Co-ordinates construction
//-- The core fonts as defined in corefonts.cpp ------------------------------//
//
static const std::unordered_map<Unicode, float> courier_widths_; //
static const std::unordered_map<Unicode, float> helvetica_widths_; //
static const std::unordered_map<Unicode, float> helvetica_bold_widths_; //
static const std::unordered_map<Unicode, float> symbol_widths_; //
static const std::unordered_map<Unicode, float> times_bold_widths_; //
static const std::unordered_map<Unicode, float> times_bold_italic_widths_; //
static const std::unordered_map<Unicode, float> times_italic_widths_; //
static const std::unordered_map<Unicode, float> times_roman_widths_; //
static const std::unordered_map<Unicode, float> dingbats_widths_; //
//
//----------------------------------------------------------------------------//
};
//---------------------------------------------------------------------------//
#endif
| 50.531915 | 82 | 0.597053 |
024cdd209f9e543cfee37a5a834934ee70699968 | 2,702 | c | C | Trojan.Win32.Gozi/dll.c | 010001111/Vx-Suites | 6b4b90a60512cce48aa7b87aec5e5ac1c4bb9a79 | [
"MIT"
] | 2 | 2021-02-04T06:47:45.000Z | 2021-07-28T10:02:10.000Z | Trojan.Win32.Gozi/dll.c | 010001111/Vx-Suites | 6b4b90a60512cce48aa7b87aec5e5ac1c4bb9a79 | [
"MIT"
] | null | null | null | Trojan.Win32.Gozi/dll.c | 010001111/Vx-Suites | 6b4b90a60512cce48aa7b87aec5e5ac1c4bb9a79 | [
"MIT"
] | null | null | null | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ISFB project. Version 2.13.24.1
//
// module: dll.c
// $Revision: 265 $
// $Date: 2014-07-09 18:33:23 +0400 (Ср, 09 июл 2014) $
// description:
// ISFB installer DLL entry point. Library initialization and cleanup routines.
#include "common\common.h"
#include "crm.h"
LONG volatile g_AttachCount = 0; // number of process attaches
// ----- Function predefinitions ---------------------------------------------------------------------------------------
WINERROR CrmSetup(LPTSTR pCmdLine);
//
// Entry point function to start it using rundll32 command.
//
VOID CALLBACK DllRegisterServer(
HWND hWnd,
HINSTANCE hInst,
LPTSTR lpszCmdLine,
LONG nCmdShow
)
{
WINERROR Status;
#ifdef _START_ON_DLL_LOAD
Status = ERROR_CALL_NOT_IMPLEMENTED;
#else
Status = CrmSetup(NULL);
#endif
DbgPrint("ISFB_%04x: Installer DLL finished with status %u.\n", GetCurrentProcessId(), Status);
UNREFERENCED_PARAMETER(hWnd);
UNREFERENCED_PARAMETER(hInst);
UNREFERENCED_PARAMETER(lpszCmdLine);
UNREFERENCED_PARAMETER(nCmdShow);
}
//
// Our client DLL entry point.
//
BOOL APIENTRY DllMain(
HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
BOOL Ret = TRUE;
WINERROR Status = NO_ERROR;
switch(ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
if (InterlockedIncrement(&g_AttachCount) == 1)
{
DbgPrint("ISFB_%04x: ISFB installer DLL Version 2.13.24.1\n", GetCurrentProcessId());
#ifdef _WIN64
DbgPrint("ISFB_%04x: Attached to a 64-bit process at 0x%x.\n", GetCurrentProcessId(), (ULONG_PTR)hModule);
#else
DbgPrint("ISFB_%04x: Attached to a 32-bit process at 0x%x.\n", GetCurrentProcessId(), (ULONG_PTR)hModule);
#endif
// Creating out DLL heap
if ((g_AppHeap = HeapCreate(0, 0x400000, 0)))
{
g_CurrentModule = hModule;
#ifdef _START_ON_DLL_LOAD
Status = CrmSetup(NULL);
#endif
}
else
Ret = FALSE;
} // if (InterlockedIncrement(&g_AttachCount) == 1)
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
if (InterlockedDecrement(&g_AttachCount) == 0)
{
ASSERT(g_AppHeap);
HeapDestroy(g_AppHeap);
#ifdef _WIN64
DbgPrint("ISFB_%04x: Detached from a 64-bit process.\n", g_CurrentProcessId);
#else
DbgPrint("ISFB_%04x: Detached from a 32-bit process.\n", g_CurrentProcessId);
#endif
} // if (InterlockedDecrement(&g_AttachCount) == 0)
break;
default:
ASSERT(FALSE);
} // switch(ul_reason_for_call)
return(Ret);
}
// just a stub to bypass CRT entry
LONG _cdecl main(VOID)
{
}
// Required to link with ntdll.lib
ULONG __security_cookie;
| 23.495652 | 120 | 0.660622 |
9d17560ebe3308d7061241103cbd8650ce7668fa | 2,353 | h | C | src/php_http_encoding_zlib.h | mmokhi/ext-http | c17987e25b6558974e60d20c4c10be9fd5221094 | [
"BSD-2-Clause"
] | 70 | 2015-06-12T06:41:24.000Z | 2022-03-28T03:25:16.000Z | src/php_http_encoding_zlib.h | dreamsxin/ext-http | 3e78e7f08803311d8680c00986d39870067665fd | [
"BSD-2-Clause"
] | 117 | 2015-07-09T13:38:16.000Z | 2022-02-25T19:02:44.000Z | src/php_http_encoding_zlib.h | dreamsxin/ext-http | 3e78e7f08803311d8680c00986d39870067665fd | [
"BSD-2-Clause"
] | 32 | 2015-08-20T10:34:08.000Z | 2021-05-18T17:53:48.000Z | /*
+--------------------------------------------------------------------+
| PECL :: http |
+--------------------------------------------------------------------+
| Redistribution and use in source and binary forms, with or without |
| modification, are permitted provided that the conditions mentioned |
| in the accompanying LICENSE file are met. |
+--------------------------------------------------------------------+
| Copyright (c) 2004-2014, Michael Wallner <mike@php.net> |
+--------------------------------------------------------------------+
*/
#ifndef PHP_HTTP_ENCODING_ZLIB_H
#define PHP_HTTP_ENCODING_ZLIB_H
#include "php_http_encoding.h"
#include <zlib.h>
#ifndef Z_FIXED
/* Z_FIXED does not exist prior 1.2.2.2 */
# define Z_FIXED 0
#endif
extern PHP_MINIT_FUNCTION(http_encoding_zlib);
zend_class_entry *php_http_get_deflate_stream_class_entry(void);
zend_class_entry *php_http_get_inflate_stream_class_entry(void);
PHP_HTTP_API php_http_encoding_stream_ops_t *php_http_encoding_stream_get_deflate_ops(void);
PHP_HTTP_API php_http_encoding_stream_ops_t *php_http_encoding_stream_get_inflate_ops(void);
PHP_HTTP_API ZEND_RESULT_CODE php_http_encoding_deflate(int flags, const char *data, size_t data_len, char **encoded, size_t *encoded_len);
PHP_HTTP_API ZEND_RESULT_CODE php_http_encoding_inflate(const char *data, size_t data_len, char **decoded, size_t *decoded_len);
#define PHP_HTTP_DEFLATE_LEVEL_DEF 0x00000000
#define PHP_HTTP_DEFLATE_LEVEL_MIN 0x00000001
#define PHP_HTTP_DEFLATE_LEVEL_MAX 0x00000009
#define PHP_HTTP_DEFLATE_TYPE_ZLIB 0x00000000
#define PHP_HTTP_DEFLATE_TYPE_GZIP 0x00000010
#define PHP_HTTP_DEFLATE_TYPE_RAW 0x00000020
#define PHP_HTTP_DEFLATE_STRATEGY_DEF 0x00000000
#define PHP_HTTP_DEFLATE_STRATEGY_FILT 0x00000100
#define PHP_HTTP_DEFLATE_STRATEGY_HUFF 0x00000200
#define PHP_HTTP_DEFLATE_STRATEGY_RLE 0x00000300
#define PHP_HTTP_DEFLATE_STRATEGY_FIXED 0x00000400
#define PHP_HTTP_INFLATE_TYPE_ZLIB 0x00000000
#define PHP_HTTP_INFLATE_TYPE_GZIP 0x00000000
#define PHP_HTTP_INFLATE_TYPE_RAW 0x00000001
#endif
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
| 37.349206 | 139 | 0.679983 |
4fe1ea1bbcd2f3d5e1eb9c404d6757ff24057bd1 | 871 | h | C | svn_sensor/sensor/yogurt/trunk/yogurt_a_function.h | GliderWinchItems/embed | cc72aa7d8208db3871a15e38185e1e125fa7de47 | [
"MIT"
] | 1 | 2019-07-18T07:22:19.000Z | 2019-07-18T07:22:19.000Z | svn_sensor/sensor/yogurt/trunk/yogurt_a_function.h | GliderWinchItems/embed | cc72aa7d8208db3871a15e38185e1e125fa7de47 | [
"MIT"
] | null | null | null | svn_sensor/sensor/yogurt/trunk/yogurt_a_function.h | GliderWinchItems/embed | cc72aa7d8208db3871a15e38185e1e125fa7de47 | [
"MIT"
] | 2 | 2019-04-03T01:44:46.000Z | 2020-04-01T07:41:41.000Z | /******************************************************************************
* File Name : yogurt_a_function.h
* Date First Issued : 03/26/2015
* Board : f103
* Description : Tension function
*******************************************************************************/
#ifndef __YOGURT_A_FUNCTION
#define __YOGURT_A_FUNCTION
#include <stdint.h>
#include "common_misc.h"
#include "common_can.h"
// -----------------------------------------------------------------------------------------------
/* **************************************************************************************/
int yogurt_a_function_init(void);
/* @brief : Initialize
* return : + = table size count of mismatch
* : 0 = OK
* : -1 = count is zero
****************************************************************************************/
#endif
| 31.107143 | 99 | 0.320321 |
99794823782e061029bf3a8d67afcb9b8b4460d6 | 11,390 | h | C | bayestracking/include/bayes_tracking/multitracker.h | NEU-ZJX/online_learning | 6c08b18837c24c78971837a1fdacabcaab0bc475 | [
"MIT"
] | 3 | 2019-04-20T13:03:35.000Z | 2021-01-16T02:38:20.000Z | bayestracking/include/bayes_tracking/multitracker.h | LidarPerception/online_learning | 58f158104f46c6a7744f7d942db847618bd2da98 | [
"MIT"
] | 1 | 2018-01-31T06:39:01.000Z | 2018-01-31T07:50:57.000Z | bayestracking/include/bayes_tracking/multitracker.h | LidarPerception/online_learning | 58f158104f46c6a7744f7d942db847618bd2da98 | [
"MIT"
] | 3 | 2018-09-30T08:48:36.000Z | 2020-05-06T09:04:07.000Z | //
// C++ Interface: multitracker
//
// Description:
//
// Author: Nicola Bellotto <nbellotto@lincoln.ac.uk>, (C) 2011
//
// Copyright: See COPYING file that comes with this distribution
//
#ifndef MULTITRACKER_H
#define MULTITRACKER_H
#include "bayes_tracking/BayesFilter/bayesFlt.hpp"
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <boost/numeric/ublas/io.hpp>
#include "bayes_tracking/associationmatrix.h"
#include "bayes_tracking/jpda.h"
#include <float.h>
#define OL // online learning (@yz17iros)
using namespace Bayesian_filter;
namespace MTRK {
struct observation_t {
FM::Vec vec;
double time;
string flag;
string name;
// constructors
observation_t() : vec(Empty), time(0.) {}
observation_t(FM::Vec v) : vec(v) {}
observation_t(FM::Vec v, double t) : vec(v), time(t) {}
observation_t(FM::Vec v, double t, string f) : vec(v), time(t), flag(f) {}
observation_t(FM::Vec v, double t, string f, string n) : vec(v), time(t), flag(f), name(n) {}
};
typedef std::vector<observation_t> sequence_t;
typedef enum {NN, /*JPDA,*/ NNJPDA} association_t;
typedef enum {CARTESIAN, POLAR} observ_model_t;
// to be defined by user
template<class FilterType>
extern bool isLost(const FilterType* filter, double stdLimit = 1.0);
template<class FilterType>
extern bool initialize(FilterType* &filter, sequence_t& obsvSeq, observ_model_t om_flag);
/**
@author Nicola Bellotto <nick@robots.ox.ac.uk>
*/
template<class FilterType, int xSize>
class MultiTracker {
public:
typedef struct {
unsigned long id;
FilterType* filter;
#ifdef OL
string pose_id;
string detector_name;
#endif
} filter_t;
private:
std::vector<filter_t> m_filters;
int m_filterNum;
sequence_t m_observations; // observations
std::vector<size_t> m_unmatched; // unmatched observations
std::map<int, int> m_assignments; // assignment < observation, target >
std::vector<sequence_t> m_sequences; // vector of unmatched observation sequences
public:
/**
* Constructor
*/
MultiTracker()
{
m_filterNum = 0;
}
/**
* Destructor
*/
~MultiTracker()
{
typename std::vector<filter_t>::iterator fi, fiEnd = m_filters.end();
for (fi = m_filters.begin(); fi != fiEnd; fi++)
delete fi->filter;
}
/**
* Add a new observation
* @param z Observation vector
* @param time Timestamp
* @param flag Additional flags
* @param name Detector name
*/
void addObservation(const FM::Vec& z, double time, string flag = "", string name = "")
{
m_observations.push_back(observation_t(z, time, flag, name));
}
/**
* Remove observations
*/
void cleanup()
{
// clean current vectors
m_observations.clear();
m_assignments.clear();
}
/**
* Size of the multitracker
* @return Current number of filters
*/
int size()
{
return m_filters.size();
}
/**
* Return a particular filter of the multitracker
* @param i Index of the filter
* @return Reference to the filter
*/
const filter_t& operator[](int i)
{
return m_filters[i];
}
/**
* Perform prediction step for all the current filters
* @param pm Prediction model
*/
template<class PredictionModelType>
void predict(PredictionModelType& pm)
{
typename std::vector<filter_t>::iterator fi, fiEnd = m_filters.end();
for (fi = m_filters.begin(); fi != fiEnd; fi++) {
fi->filter->predict(pm);
}
}
/**
* Perform data association and update step for all the current filters, create new ones and remove those which are no more necessary
* @param om Observation model
* @param om_flag Observation model flag (CARTESIAN or POLAR)
* @param alg Data association algorithm (NN or NNJPDA)
* @param seqSize Minimum number of observations necessary for new track creation
* @param seqTime Minimum interval between observations for new track creation
* @param stdLimit Upper limit for the standard deviation of the estimated position
*/
template<class ObservationModelType>
void process(ObservationModelType& om, observ_model_t om_flag = CARTESIAN, association_t alg = NN, unsigned int seqSize = 5, double seqTime = 0.2, double stdLimit = 1.0)
{
// data association
if (dataAssociation(om, alg)) {
// update
observe(om);
}
pruneTracks(stdLimit);
if (m_observations.size())
createTracks(om, om_flag, seqSize, seqTime);
// finished
cleanup();
}
/**
* Returns the vector of indexes of unmatched observations
*/
const std::vector<size_t>* getUnmatched()
{
return &m_unmatched;
}
/**
* Print state and covariance of all the current filters
*/
void print()
{
int i = 0;
typename std::vector<filter_t>::iterator fi, fiEnd = m_filters.end();
for (fi = m_filters.begin(); fi != fiEnd; fi++) {
cout << "Filter[" << i++ << "]\n\tx = " << fi->filter->x << "\n\tX = " << fi->filter->X << endl;
}
}
private:
void addFilter(const FM::Vec& initState, const FM::SymMatrix& initCov)
{
FilterType* filter = new FilterType(xSize);
filter.init(initState, initCov);
addFilter(filter);
}
void addFilter(FilterType* filter)
{
filter_t f = {m_filterNum++, filter};
m_filters.push_back(f);
}
template<class ObservationModelType>
bool dataAssociation(ObservationModelType& om, association_t alg = NN)
{
const size_t M = m_observations.size(), N = m_filters.size();
if (M == 0) // no observation, do nothing
return false;
if (N != 0) { // observations and tracks, associate
jpda::JPDA* jpda;
vector< size_t > znum; // this would contain the number of observations for each sensor
if (alg == NNJPDA) { /// NNJPDA data association (one sensor)
znum.push_back(M); // only one in this case
jpda = new jpda::JPDA(znum, N);
}
AssociationMatrix amat(M, N);
int dim = om.z_size;
Vec zp(dim), s(dim);
SymMatrix Zp(dim, dim), S(dim, dim);
for (int j = 0; j < N; j++) {
m_filters[j].filter->predict_observation(om, zp, Zp);
S = Zp + om.Z; // H*P*H' + R
for (int i = 0; i < M; i++) {
s = zp - m_observations[i].vec;
om.normalise(s, zp);
try {
if (AM::mahalanobis(s, S) > AM::gate(s.size())) {
amat[i][j] = DBL_MAX; // gating
}
else {
amat[i][j] = AM::correlation_log(s, S);
if (alg == NNJPDA) {
jpda->Omega[0][i][j+1] = true;
jpda->Lambda[0][i][j+1] = jpda::logGauss(s, S);
}
}
} catch (Bayesian_filter::Filter_exception& e) {
cerr << "###### Exception in AssociationMatrix #####\n";
cerr << "Message: " << e.what() << endl;
amat[i][j] = DBL_MAX; // set to maximum
}
}
}
if (alg == NN) { /// NN data association
amat.computeNN(CORRELATION_LOG);
// record unmatched observations for possible candidates creation
m_unmatched = amat.URow;
// data assignment
for (size_t n = 0; n < amat.NN.size(); n++) {
m_assignments.insert(std::make_pair(amat.NN[n].row, amat.NN[n].col));
}
}
else if (alg == NNJPDA) { /// NNJPDA data association (one sensor)
// compute associations
jpda->getAssociations();
jpda->getProbabilities();
vector< jpda::Association > association(znum.size());
jpda->getMultiNNJPDA(association);
// jpda->getMonoNNJPDA(association);
// data assignment
jpda::Association::iterator ai, aiEnd = association[0].end();
for (ai = association[0].begin(); ai != aiEnd; ai++) {
if (ai->t) { // not a clutter
m_assignments.insert(std::make_pair(ai->z, ai->t - 1));
}
else { // add clutter to unmatched list
m_unmatched.push_back(ai->z);
}
}
delete jpda;
}
else {
cerr << "###### Unknown association algorithm: " << alg << " #####\n";
return false;
}
return true;
}
for (int i = 0; i < M; i++) // simply record unmatched
m_unmatched.push_back(i);
return false;
}
void pruneTracks(double stdLimit = 1.0)
{
// remove lost tracks
typename std::vector<filter_t>::iterator fi = m_filters.begin(), fiEnd = m_filters.end();
while (fi != fiEnd) {
if (isLost(fi->filter, stdLimit)) {
delete fi->filter;
fi = m_filters.erase(fi);
fiEnd = m_filters.end();
}
else {
fi++;
}
}
}
// seqSize = Minimum number of unmatched observations to create new track hypothesis
// seqTime = Maximum time interval between these observations
template<class ObservationModelType>
void createTracks(ObservationModelType& om, observ_model_t om_flag, unsigned int seqSize, double seqTime)
{
// create new tracks from unmatched observations
std::vector<size_t>::iterator ui = m_unmatched.begin();
while (ui != m_unmatched.end()) {
std::vector<sequence_t>::iterator si = m_sequences.begin();
bool matched = false;
while (si != m_sequences.end()) {
if (m_observations[*ui].time - si->back().time > seqTime) { // erase old unmatched observations
si = m_sequences.erase(si);
}
else if (AM::mahalanobis(m_observations[*ui].vec, om.Z, si->back().vec, om.Z) <= AM::gate(om.z_size)) { // observation close to a previous one
// add new track
si->push_back(m_observations[*ui]);
FilterType* filter;
if (si->size() >= seqSize && initialize(filter, *si, om_flag)) { // there's a minimum number of sequential observations
addFilter(filter);
#ifdef OL
m_filters.back().pose_id = si->back().flag;
m_filters.back().detector_name = si->back().name;
#endif
// remove sequence
si = m_sequences.erase(si);
matched = true;
}
else {
si++;
}
}
else {
si++;
}
}
if (matched) {
// remove from unmatched list
ui = m_unmatched.erase(ui);
}
else {
ui++;
}
}
// memorize remaining unmatched observations
std::vector<size_t>::iterator uiEnd = m_unmatched.end();
for (ui = m_unmatched.begin() ; ui != uiEnd; ui++) {
sequence_t s;
s.push_back(m_observations[*ui]);
m_sequences.push_back(s);
}
// reset vector of (indexes of) unmatched observations
m_unmatched.clear();
}
template<class ObservationModelType>
void observe(ObservationModelType& om)
{
typename std::map<int, int>::iterator ai, aiEnd = m_assignments.end();
for (ai = m_assignments.begin(); ai != aiEnd; ai++) {
m_filters[ai->second].filter->observe(om, m_observations[ai->first].vec);
#ifdef OL
m_filters[ai->second].pose_id = m_observations[ai->first].flag;
m_filters[ai->second].detector_name = m_observations[ai->first].name;
#endif
}
}
};
} // namespace MTRK
#endif
| 29.816754 | 176 | 0.598683 |
125ba5e46c4fa22686b1c4d65061b80d29712b19 | 466 | h | C | LeanChat/LeanChat/AlbumViewCell.h | ArtisanSay/ArtisaSay | 7e24ebfd691f3ac5c3d4b4826a114cc2dc6d93f8 | [
"MIT"
] | null | null | null | LeanChat/LeanChat/AlbumViewCell.h | ArtisanSay/ArtisaSay | 7e24ebfd691f3ac5c3d4b4826a114cc2dc6d93f8 | [
"MIT"
] | null | null | null | LeanChat/LeanChat/AlbumViewCell.h | ArtisanSay/ArtisaSay | 7e24ebfd691f3ac5c3d4b4826a114cc2dc6d93f8 | [
"MIT"
] | null | null | null | //
// AlbumViewCell.h
// sc
//
// Created by 吴逢山 on 18/02/16.
// Copyright © 2016年 wufengshan. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AlbumViewCell : UICollectionViewCell
@property (nonatomic,strong) UIImageView *imageView;
@property (nonatomic,strong) UIView *bgView;
@property (nonatomic,strong) UILabel *titleLabel;
@property (nonatomic,strong) UIActivityIndicatorView *loadIndicatorView;
- (void)startAnimate;
- (void)stopAnimate;
@end
| 24.526316 | 72 | 0.753219 |
129bcb2b39af32621d3475a6af4adc5ac11134f1 | 1,620 | h | C | Game/engine/include/eventsmanager.h | ShutUpPaulo/Mana_Team | e47d84cb27ffc05b6e9996b9ed1d5cf0f091b4e0 | [
"MIT"
] | null | null | null | Game/engine/include/eventsmanager.h | ShutUpPaulo/Mana_Team | e47d84cb27ffc05b6e9996b9ed1d5cf0f091b4e0 | [
"MIT"
] | null | null | null | Game/engine/include/eventsmanager.h | ShutUpPaulo/Mana_Team | e47d84cb27ffc05b6e9996b9ed1d5cf0f091b4e0 | [
"MIT"
] | null | null | null | /*
* Classe que gerencia os eventos de input do jogo.
*
* Autor: Carlos Oliveira
* Data: 17/04/2015
* Licença: LGPL. Sem copyright.
*/
#ifndef EVENTS_MANAGER_H
#define EVENTS_MANAGER_H
#include <SDL2/SDL.h>
#include <list>
#include "mousemotioneventlistener.h"
using std::list;
class SystemEventListener;
class KeyboardEventListener;
class MouseButtonEventListener;
class JoyStickEventListener;
class EventsManager
{
public:
void dispatch_pending_events();
void register_system_event_listener(SystemEventListener *listener);
void register_keyboard_event_listener(KeyboardEventListener *listener);
void register_mouse_button_event_listener(MouseButtonEventListener *ls);
void register_mouse_motion_event_listener(MouseMotionEventListener *ls);
void register_joystick_event_listener(JoyStickEventListener *listener);
void unregister_system_event_listener(SystemEventListener *listener);
void unregister_keyboard_event_listener(KeyboardEventListener *listener);
void unregister_mouse_button_event_listener(MouseButtonEventListener *ls);
void unregister_mouse_motion_event_listener(MouseMotionEventListener *ls);
void unregister_joystick_event_listener(JoyStickEventListener *listener);
private:
list<SystemEventListener *> m_system_event_listeners;
list<KeyboardEventListener *> m_keyboard_event_listeners;
list<MouseButtonEventListener *> m_mouse_button_event_listeners;
list<MouseMotionEventListener *> m_mouse_motion_event_listeners;
list<JoyStickEventListener *> m_joystick_event_listeners;
list<SDL_Event> grab_SDL_events();
};
#endif
| 32.4 | 78 | 0.817284 |
3f902b194b56cf9d41b3d347f8463c4c377c47af | 1,178 | h | C | src/developer/debug/third_party/libunwindstack/include/unwindstack/MachineArm.h | allansrc/fuchsia | a2c235b33fc4305044d496354a08775f30cdcf37 | [
"BSD-2-Clause"
] | 2,377 | 2020-08-10T08:00:19.000Z | 2022-03-31T07:44:29.000Z | src/developer/debug/third_party/libunwindstack/include/unwindstack/MachineArm.h | allansrc/fuchsia | a2c235b33fc4305044d496354a08775f30cdcf37 | [
"BSD-2-Clause"
] | 1,100 | 2020-03-24T19:41:13.000Z | 2022-03-31T14:27:09.000Z | src/developer/debug/third_party/libunwindstack/include/unwindstack/MachineArm.h | allansrc/fuchsia | a2c235b33fc4305044d496354a08775f30cdcf37 | [
"BSD-2-Clause"
] | 298 | 2020-08-10T08:09:48.000Z | 2022-03-25T07:50:27.000Z | /*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LIBUNWINDSTACK_MACHINE_ARM_H
#define _LIBUNWINDSTACK_MACHINE_ARM_H
#include <stdint.h>
namespace unwindstack {
enum ArmReg : uint16_t {
ARM_REG_R0 = 0,
ARM_REG_R1,
ARM_REG_R2,
ARM_REG_R3,
ARM_REG_R4,
ARM_REG_R5,
ARM_REG_R6,
ARM_REG_R7,
ARM_REG_R8,
ARM_REG_R9,
ARM_REG_R10,
ARM_REG_R11,
ARM_REG_R12,
ARM_REG_R13,
ARM_REG_R14,
ARM_REG_R15,
ARM_REG_LAST,
ARM_REG_SP = ARM_REG_R13,
ARM_REG_LR = ARM_REG_R14,
ARM_REG_PC = ARM_REG_R15,
};
} // namespace unwindstack
#endif // _LIBUNWINDSTACK_MACHINE_ARM_H
| 23.098039 | 75 | 0.742784 |
8b8781fee8887b79f6b4b1cd256356237a44d042 | 1,694 | c | C | UnitTest/UnitTest/driver_init.c | martinabr/pydgilib | 9e27b11e74518375ae78959a71f896e92a51cdb1 | [
"BSD-3-Clause"
] | 2 | 2019-04-05T13:27:54.000Z | 2020-10-09T22:56:22.000Z | UnitTest/UnitTest/driver_init.c | martinabr/pydgilib | 9e27b11e74518375ae78959a71f896e92a51cdb1 | [
"BSD-3-Clause"
] | null | null | null | UnitTest/UnitTest/driver_init.c | martinabr/pydgilib | 9e27b11e74518375ae78959a71f896e92a51cdb1 | [
"BSD-3-Clause"
] | 1 | 2019-09-11T07:48:45.000Z | 2019-09-11T07:48:45.000Z | /*
* Code generated from Atmel Start.
*
* This file will be overwritten when reconfiguring your Atmel Start project.
* Please copy examples or other code you want to keep to a separate file
* to avoid losing it when reconfiguring.
*/
#include "driver_init.h"
#include <peripheral_clk_config.h>
#include <utils.h>
#include <hal_init.h>
#if (defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE != 3U))
/* Weak Non-secure callable function. Real one should be in secure gateway library. */
WEAK int32_t nsc_periph_clock_init(uint32_t gclk_id, uint32_t gclk_src)
{
(void)gclk_id;
(void)gclk_src;
return 0;
}
#endif
struct usart_sync_descriptor TARGET_IO;
void TARGET_IO_PORT_init(void)
{
gpio_set_pin_function(PA24, PINMUX_PA24C_SERCOM0_PAD2);
gpio_set_pin_function(PA25, PINMUX_PA25C_SERCOM0_PAD3);
}
void TARGET_IO_CLOCK_init(void)
{
#if (defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U))
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM0_GCLK_ID_CORE, CONF_GCLK_SERCOM0_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM0_GCLK_ID_SLOW, CONF_GCLK_SERCOM0_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
hri_mclk_set_APBCMASK_SERCOM0_bit(MCLK);
#else
nsc_periph_clock_init(SERCOM0_GCLK_ID_CORE, CONF_GCLK_SERCOM0_CORE_SRC);
nsc_periph_clock_init(SERCOM0_GCLK_ID_SLOW, CONF_GCLK_SERCOM0_SLOW_SRC);
#endif
}
void TARGET_IO_init(void)
{
TARGET_IO_CLOCK_init();
usart_sync_init(&TARGET_IO, SERCOM0, (void *)NULL);
TARGET_IO_PORT_init();
}
void system_init(void)
{
#if (defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U))
/* Only initialize MCU clock when the project is TrustZone secure project */
init_mcu();
#endif
TARGET_IO_init();
}
| 27.322581 | 115 | 0.787485 |
e91a547b4af97dea982ee42203b86e7704ba7bd0 | 3,398 | h | C | components/consent_auditor/consent_auditor.h | zipated/src | 2b8388091c71e442910a21ada3d97ae8bc1845d3 | [
"BSD-3-Clause"
] | 2,151 | 2020-04-18T07:31:17.000Z | 2022-03-31T08:39:18.000Z | components/consent_auditor/consent_auditor.h | cangulcan/src | 2b8388091c71e442910a21ada3d97ae8bc1845d3 | [
"BSD-3-Clause"
] | 395 | 2020-04-18T08:22:18.000Z | 2021-12-08T13:04:49.000Z | components/consent_auditor/consent_auditor.h | cangulcan/src | 2b8388091c71e442910a21ada3d97ae8bc1845d3 | [
"BSD-3-Clause"
] | 338 | 2020-04-18T08:03:10.000Z | 2022-03-29T12:33:22.000Z | // Copyright 2017 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 COMPONENTS_CONSENT_AUDITOR_CONSENT_AUDITOR_H_
#define COMPONENTS_CONSENT_AUDITOR_CONSENT_AUDITOR_H_
#include <memory>
#include <string>
#include <vector>
#include "base/macros.h"
#include "components/keyed_service/core/keyed_service.h"
namespace syncer {
class UserEventService;
}
namespace sync_pb {
class UserEventSpecifics;
}
class PrefService;
class PrefRegistrySimple;
namespace consent_auditor {
// Feature for which a consent moment is to be recorded.
//
// This enum is used in histograms. Entries should not be renumbered and
// numeric values should never be reused.
//
// A Java counterpart will be generated for this enum.
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.consent_auditor
// GENERATED_JAVA_CLASS_NAME_OVERRIDE: ConsentAuditorFeature
enum class Feature {
CHROME_SYNC = 0,
PLAY_STORE = 1,
BACKUP_AND_RESTORE = 2,
GOOGLE_LOCATION_SERVICE = 3,
FEATURE_LAST = GOOGLE_LOCATION_SERVICE
};
// Whether a consent is given or not given.
//
// A Java counterpart will be generated for this enum.
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.consent_auditor
enum class ConsentStatus { NOT_GIVEN, GIVEN };
class ConsentAuditor : public KeyedService {
public:
ConsentAuditor(PrefService* pref_service,
syncer::UserEventService* user_event_service,
const std::string& app_version,
const std::string& app_locale);
~ConsentAuditor() override;
// KeyedService:
void Shutdown() override;
// Registers the preferences needed by this service.
static void RegisterProfilePrefs(PrefRegistrySimple* registry);
// Records a consent for |feature| for the signed-in GAIA account with
// the ID |account_id| (as defined in AccountInfo).
// Consent text consisted of strings with |consent_grd_ids|, and the UI
// element the user clicked had the ID |confirmation_grd_id|.
// Whether the consent was GIVEN or NOT_GIVEN is passed as |status|.
virtual void RecordGaiaConsent(const std::string& account_id,
Feature feature,
const std::vector<int>& description_grd_ids,
int confirmation_grd_id,
ConsentStatus status);
// Records that the user consented to a |feature|. The user was presented with
// |description_text| and accepted it by interacting |confirmation_text|
// (e.g. clicking on a button; empty if not applicable).
// Returns true if successful.
void RecordLocalConsent(const std::string& feature,
const std::string& description_text,
const std::string& confirmation_text);
private:
std::unique_ptr<sync_pb::UserEventSpecifics> ConstructUserConsent(
const std::string& account_id,
Feature feature,
const std::vector<int>& description_grd_ids,
int confirmation_grd_id,
ConsentStatus status);
PrefService* pref_service_;
syncer::UserEventService* user_event_service_;
std::string app_version_;
std::string app_locale_;
DISALLOW_COPY_AND_ASSIGN(ConsentAuditor);
};
} // namespace consent_auditor
#endif // COMPONENTS_CONSENT_AUDITOR_CONSENT_AUDITOR_H_
| 32.990291 | 80 | 0.721601 |
6a7b0d4fc5b235941f81acbb5a26cd7bcf972148 | 1,063 | c | C | test_lib.c | drrost/c-testlib | c8367c61d7f350368fcd175f7a2a56f0d51b3fd3 | [
"MIT"
] | null | null | null | test_lib.c | drrost/c-testlib | c8367c61d7f350368fcd175f7a2a56f0d51b3fd3 | [
"MIT"
] | null | null | null | test_lib.c | drrost/c-testlib | c8367c61d7f350368fcd175f7a2a56f0d51b3fd3 | [
"MIT"
] | null | null | null | //
// test_lib.c
// c-testlib
//
// Created by Rostyslav Druzhchenko on 14/4/20.
// Copyright © 2020 Rostyslav Druzhchenko. All rights reserved.
//
#include "test_lib.h"
#include <unistd.h>
#include <stdio.h>
int stdout_bk;
int pipefd[2];
char STDOUT_BUFF[101];
// Prints
void test_print_fail(const char *message) {
printf("%s | ", tXX);
printf("\033[0;31m");
printf("%s", "FAILED:");
printf("\033[0m |");
printf("\033[1m %s\033[0m\n", test_case_name);
printf("%s", message);
is_failed = 1;
}
void test_print_ok() {
printf("%s | ", tXX);
printf("\033[0;32m");
printf("%s", " OK \033[0m");
printf(" |\033[1m %s\033[0m\n", test_case_name);
}
void test_finalize() {
if (!is_failed) {
test_print_ok();
}
}
// Itercept stdout
void intercept_stdout() {
stdout_bk = dup(fileno(stdout));
pipe(pipefd);
dup2(pipefd[1], fileno(stdout));
}
void restore_stdout() {
fflush(stdout);
close(pipefd[1]);
dup2(stdout_bk, fileno(stdout));
read(pipefd[0], STDOUT_BUFF, 100);
}
| 18.327586 | 64 | 0.60207 |
3a02801c75df4e93970849f9bfa6f07aa0f7e885 | 1,479 | h | C | include/script/typedefs.h | strandfield/libscript | 5d413762ad8ce88ff887642f6947032017dd284c | [
"MIT"
] | 3 | 2020-12-28T01:40:45.000Z | 2021-05-18T01:47:07.000Z | include/script/typedefs.h | strandfield/libscript | 5d413762ad8ce88ff887642f6947032017dd284c | [
"MIT"
] | 4 | 2019-06-29T12:23:11.000Z | 2020-07-25T15:38:46.000Z | include/script/typedefs.h | strandfield/libscript | 5d413762ad8ce88ff887642f6947032017dd284c | [
"MIT"
] | 1 | 2021-11-17T01:49:42.000Z | 2021-11-17T01:49:42.000Z | // Copyright (C) 2018 Vincent Chambrin
// This file is part of the libscript library
// For conditions of distribution and use, see copyright notice in LICENSE
#ifndef LIBSCRIPT_TYPEDEFS_H
#define LIBSCRIPT_TYPEDEFS_H
#include "script/symbol.h"
#include "script/types.h"
namespace script
{
class LIBSCRIPT_API Typedef
{
public:
Typedef() = default;
Typedef(const Typedef &) = default;
~Typedef() = default;
Typedef(const std::string & name, const Type & t)
: mName(name)
, mType(t)
{
}
inline const std::string & name() const { return mName; }
inline const Type & type() const { return mType; }
Typedef & operator=(const Typedef &) = default;
private:
std::string mName;
Type mType;
};
inline bool operator==(const Typedef & lhs, const Typedef & rhs)
{
return lhs.type() == rhs.type() && lhs.name() == rhs.name();
}
inline bool operator!=(const Typedef & lhs, const Typedef & rhs)
{
return !(lhs == rhs);
}
class LIBSCRIPT_API TypedefBuilder
{
public:
Symbol symbol_;
std::string name_;
Type type_;
public:
TypedefBuilder(const Symbol & s, const std::string & name, const Type & type)
: symbol_(s), name_(name), type_(type) {}
TypedefBuilder(const Symbol & s, std::string && name, const Type & type)
: symbol_(s), name_(std::move(name)), type_(type) {}
TypedefBuilder(const TypedefBuilder &) = default;
~TypedefBuilder() = default;
void create();
};
} // namespace script
#endif // LIBSCRIPT_TYPEDEFS_H
| 20.830986 | 79 | 0.679513 |
753b3f208b9530828d2ca49a7eae067785c5aa6e | 380 | c | C | org.conqat.engine.sourcecode/test-data/org.conqat.engine.sourcecode.shallowparser/cpp/ancient_c.c | assessorgeneral/ConQAT | 2a462f23f22c22aa9d01a7a204453d1be670ba60 | [
"Apache-2.0"
] | 4 | 2016-06-26T01:13:39.000Z | 2022-03-04T16:42:35.000Z | org.conqat.engine.sourcecode/test-data/org.conqat.engine.sourcecode.shallowparser/cpp/ancient_c.c | brynary/conqat | 52172907ec76c4b0915091343f0975dc0cf4891c | [
"Apache-2.0"
] | null | null | null | org.conqat.engine.sourcecode/test-data/org.conqat.engine.sourcecode.shallowparser/cpp/ancient_c.c | brynary/conqat | 52172907ec76c4b0915091343f0975dc0cf4891c | [
"Apache-2.0"
] | 7 | 2015-04-01T03:50:54.000Z | 2021-11-11T05:19:48.000Z | // This example uses K&R style functions, which are usually not used today,
// but supported by most compilers still.
// Also see http://en.wikipedia.org/wiki/C_%28programming_language%29#K.26R_C
char *someVar;
int foo (a, b)
int a;
char *b;
{
printf ("do something useful");
}
main (argc, argv)
char **argv;
{
printf ("This is a very ancient style of method decl!");
}
| 19 | 77 | 0.692105 |
ce560162d89d41be61338db1dc986562c197b238 | 2,340 | h | C | src/plugins/intel_gpu/src/kernel_selector/core/actual_kernels/normalize/normalize_kernel_base.h | pazamelin/openvino | b7e8ef910d7ed8e52326d14dc6fd53b71d16ed48 | [
"Apache-2.0"
] | 2,406 | 2020-04-22T15:47:54.000Z | 2022-03-31T10:27:37.000Z | inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/normalize/normalize_kernel_base.h | thomas-yanxin/openvino | 031e998a15ec738c64cc2379d7f30fb73087c272 | [
"Apache-2.0"
] | 4,948 | 2020-04-22T15:12:39.000Z | 2022-03-31T18:45:42.000Z | inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/normalize/normalize_kernel_base.h | thomas-yanxin/openvino | 031e998a15ec738c64cc2379d7f30fb73087c272 | [
"Apache-2.0"
] | 991 | 2020-04-23T18:21:09.000Z | 2022-03-31T18:40:57.000Z | // Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include "kernel_base_opencl.h"
#include "kernel_selector_params.h"
namespace kernel_selector {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// normalize_params
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct normalize_params : public base_params {
normalize_params() : base_params(KernelType::NORMALIZE) {}
NormalizeMode normMode = NormalizeMode::ACROSS_SPATIAL;
float epsilon = 1e-10f;
DataTensor scaleTable;
ParamsKey GetParamsKey() const override {
ParamsKey k = base_params::GetParamsKey();
k.EnableNormalizeMode(normMode);
return k;
}
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// normalize_optional_params
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct normalize_optional_params : optional_params {
normalize_optional_params() : optional_params(KernelType::NORMALIZE) {}
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// NormalizeKernelBase
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class NormalizeKernelBase : public KernelBaseOpenCL {
public:
using KernelBaseOpenCL::KernelBaseOpenCL;
virtual ~NormalizeKernelBase() {}
using DispatchData = CommonDispatchData;
protected:
JitConstants GetJitConstants(const normalize_params& params) const;
DispatchData SetDefault(const normalize_params& params) const;
KernelsData GetCommonKernelsData(const Params& params, const optional_params&) const;
std::vector<FusedOpType> GetSupportedFusedOps() const override {
return { FusedOpType::QUANTIZE,
FusedOpType::ACTIVATION,
FusedOpType::SCALE };
}
bool Validate(const Params& params, const optional_params&) const override;
Datatype GetActivationType(const normalize_params& params) const;
};
} // namespace kernel_selector
| 39 | 120 | 0.509829 |
cec901e0533e9a6bf45d7d520147117ebf27782c | 140 | h | C | MicroCode/src/sys/registers/registers.h | JeppeSRC/PowerSupply | 4c966b91dc3eef39464e4d974f29ae8abd7dc109 | [
"MIT"
] | 6 | 2019-03-25T18:10:52.000Z | 2020-12-28T08:10:14.000Z | MicroCode/src/sys/registers/registers.h | JeppeSRC/PowerSupply | 4c966b91dc3eef39464e4d974f29ae8abd7dc109 | [
"MIT"
] | null | null | null | MicroCode/src/sys/registers/registers.h | JeppeSRC/PowerSupply | 4c966b91dc3eef39464e4d974f29ae8abd7dc109 | [
"MIT"
] | null | null | null | #ifndef SYS_REGISTERS_H_
#define SYS_REGISTERS_H_
#include "ahb2.h"
#include "ahb1.h"
#include "apb2.h"
#include "apb1.h"
#endif
| 14 | 25 | 0.692857 |
ced9c1f15df5ffe835db94a6d9d963d9625aae7c | 334 | c | C | src/norm.c | jakeinater/spectralILU | 825dbd5c5495b0ce0a0d14a5bed865b9bfdda98d | [
"MIT"
] | null | null | null | src/norm.c | jakeinater/spectralILU | 825dbd5c5495b0ce0a0d14a5bed865b9bfdda98d | [
"MIT"
] | null | null | null | src/norm.c | jakeinater/spectralILU | 825dbd5c5495b0ce0a0d14a5bed865b9bfdda98d | [
"MIT"
] | null | null | null | #include <gsl/gsl_vector.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_blas.h>
#include <gsl/gsl_linalg.h>
int normalizeVector( gsl_vector *vector )
{
double min = gsl_vector_min( vector );
double norm = gsl_vector_max( vector ) - min;
gsl_vector_add_constant( vector, -min );
gsl_vector_scale( vector, 1/norm );
return 0;
}
| 23.857143 | 46 | 0.730539 |
c0055269608761501a6b5642b5818ca8b8334354 | 1,528 | h | C | Wrappers/Paraview/CCPiAccessibleVolumeParaviewImpl.h | vais-ral/CCPi-Quantification | cb53ff9abf865c48b1cf240932f6aa0f647b6a4f | [
"Apache-2.0"
] | null | null | null | Wrappers/Paraview/CCPiAccessibleVolumeParaviewImpl.h | vais-ral/CCPi-Quantification | cb53ff9abf865c48b1cf240932f6aa0f647b6a4f | [
"Apache-2.0"
] | 1 | 2019-01-30T12:42:14.000Z | 2019-02-14T16:17:03.000Z | Wrappers/Paraview/CCPiAccessibleVolumeParaviewImpl.h | vais-ral/CCPi-Quantification | cb53ff9abf865c48b1cf240932f6aa0f647b6a4f | [
"Apache-2.0"
] | null | null | null | /**
* CCPi Paraview plugin of Accessible Volume
* The implementation of algorithm is in the CCPi core folder
*
* Author : Mr. Srikanth Nagella
* Date : 22.05.2014
*/
#ifndef CCPIACCESSIBLEVOLUMEPARAVIEWIMPL_H
#define CCPIACCESSIBLEVOLUMEPARAVIEWIMPL_H
#include "vtkImageAlgorithm.h"
#include <string>
class VTK_EXPORT CCPiAccessibleVolumeParaviewImpl : public vtkImageAlgorithm
{
public:
static CCPiAccessibleVolumeParaviewImpl* New();
vtkTypeMacro(CCPiAccessibleVolumeParaviewImpl, vtkImageAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
vtkGetMacro(MinSphereDiameter, double);
vtkSetMacro(MinSphereDiameter, double);
vtkGetMacro(MaxSphereDiameter, double);
vtkSetMacro(MaxSphereDiameter, double);
vtkGetMacro(ImageResolution, double);
vtkSetMacro(ImageResolution, double);
vtkGetMacro(NumberOfSpheres, int);
vtkSetMacro(NumberOfSpheres, int);
protected:
CCPiAccessibleVolumeParaviewImpl();
~CCPiAccessibleVolumeParaviewImpl();
int RequestData(vtkInformation *, vtkInformationVector **,
vtkInformationVector *);
double MinSphereDiameter;
double MaxSphereDiameter;
double ImageResolution;
int NumberOfSpheres;
int FillInputPortInformation(int port, vtkInformation* info);
int FillOutputPortInformation(int port, vtkInformation* info);
private:
CCPiAccessibleVolumeParaviewImpl(const CCPiAccessibleVolumeParaviewImpl&); // Not implemented.
void operator=(const CCPiAccessibleVolumeParaviewImpl&); // Not implemented.
};
#endif
| 27.285714 | 97 | 0.78534 |
c00fc12a6ae03b620239d968664a35f0cc877b24 | 30 | h | C | OpenGL-Gui/Mesh.h | pinojojo/DockingOpenGL | abea0abe860f70c78249cc2a65b08dcc39967550 | [
"Apache-2.0"
] | null | null | null | OpenGL-Gui/Mesh.h | pinojojo/DockingOpenGL | abea0abe860f70c78249cc2a65b08dcc39967550 | [
"Apache-2.0"
] | null | null | null | OpenGL-Gui/Mesh.h | pinojojo/DockingOpenGL | abea0abe860f70c78249cc2a65b08dcc39967550 | [
"Apache-2.0"
] | null | null | null | #pragma once
class Mesh
{
};
| 5 | 12 | 0.633333 |
a301aca493b3de0143dbe331cb1bbee0114da952 | 840 | h | C | src/3rdPartyLibraries/qrose/Framework/QRWidgetX.h | maurizioabba/rose | 7597292cf14da292bdb9a4ef573001b6c5b9b6c0 | [
"BSD-3-Clause"
] | 488 | 2015-01-09T08:54:48.000Z | 2022-03-30T07:15:46.000Z | src/3rdPartyLibraries/qrose/Framework/QRWidgetX.h | sujankh/rose-matlab | 7435d4fa1941826c784ba97296c0ec55fa7d7c7e | [
"BSD-3-Clause"
] | 174 | 2015-01-28T18:41:32.000Z | 2022-03-31T16:51:05.000Z | src/3rdPartyLibraries/qrose/Framework/QRWidgetX.h | sujankh/rose-matlab | 7435d4fa1941826c784ba97296c0ec55fa7d7c7e | [
"BSD-3-Clause"
] | 146 | 2015-04-27T02:48:34.000Z | 2022-03-04T07:32:53.000Z | /***************************************************************************
Jose Gabriel de Figueiredo Coutinho
jgfc@doc.ic.ac.uk
Class: QROSE
Description:
***************************************************************************/
#ifndef QRWIDGETCLASS_H
#define QRWIDGETCLASS_H
#include <QRMacros.h>
#include <QWidget>
namespace qrs {
class QRTiledWidget;
class QRWidget: public QWidget {
Q_OBJECT
public:
QRWidget ( QWidget * parent = 0, Qt::WindowFlags f = 0 );
std::string getName() const;
public:
virtual void childIsAttached(QRTiledWidget *parent);
};
// setEnabled(true/false)
// hide(); show();
//
} // namespace qrs
#endif
| 21 | 77 | 0.428571 |
ed3ae4fbb3168e5ca3907da35ed2a1403a04d659 | 2,861 | h | C | virtual-UE-eNB/srsLTE-5d82f19988bc148d7f4cec7a0f29184375a64b40/srsue/hdr/upper/gw.h | Joanguitar/docker-nextepc | 2b606487968fe63ce19a8acf58938a84d97ffb89 | [
"MIT"
] | null | null | null | virtual-UE-eNB/srsLTE-5d82f19988bc148d7f4cec7a0f29184375a64b40/srsue/hdr/upper/gw.h | Joanguitar/docker-nextepc | 2b606487968fe63ce19a8acf58938a84d97ffb89 | [
"MIT"
] | null | null | null | virtual-UE-eNB/srsLTE-5d82f19988bc148d7f4cec7a0f29184375a64b40/srsue/hdr/upper/gw.h | Joanguitar/docker-nextepc | 2b606487968fe63ce19a8acf58938a84d97ffb89 | [
"MIT"
] | 3 | 2020-04-04T18:26:04.000Z | 2021-09-24T18:41:01.000Z | /**
*
* \section COPYRIGHT
*
* Copyright 2013-2015 Software Radio Systems Limited
*
* \section LICENSE
*
* This file is part of the srsUE library.
*
* srsUE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsUE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#ifndef SRSUE_GW_H
#define SRSUE_GW_H
#include "srslte/common/buffer_pool.h"
#include "srslte/common/log.h"
#include "srslte/common/common.h"
#include "srslte/common/interfaces_common.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/common/threads.h"
#include "gw_metrics.h"
#include <linux/if.h>
namespace srsue {
class gw
:public gw_interface_pdcp
,public gw_interface_nas
,public gw_interface_rrc
,public thread
{
public:
gw();
void init(pdcp_interface_gw *pdcp_, nas_interface_gw *nas_, srslte::log *gw_log_, srslte::srslte_gw_config_t);
void stop();
void get_metrics(gw_metrics_t &m);
void set_netmask(std::string netmask);
void set_tundevname(const std::string & devname);
// PDCP interface
void write_pdu(uint32_t lcid, srslte::byte_buffer_t *pdu);
void write_pdu_mch(uint32_t lcid, srslte::byte_buffer_t *pdu);
// NAS interface
srslte::error_t setup_if_addr(uint32_t ip_addr, char *err_str);
// RRC interface
void add_mch_port(uint32_t lcid, uint32_t port);
private:
bool default_netmask;
std::string netmask;
std::string tundevname;
static const int GW_THREAD_PRIO = 7;
pdcp_interface_gw *pdcp;
nas_interface_gw *nas;
srslte::byte_buffer_pool *pool;
srslte::log *gw_log;
srslte::srslte_gw_config_t cfg;
bool running;
bool run_enable;
int32 tun_fd;
struct ifreq ifr;
int32 sock;
bool if_up;
uint32_t current_ip_addr;
long ul_tput_bytes;
long dl_tput_bytes;
struct timeval metrics_time[3];
void run_thread();
srslte::error_t init_if(char *err_str);
// MBSFN
int mbsfn_sock_fd; // Sink UDP socket file descriptor
struct sockaddr_in mbsfn_sock_addr; // Target address
uint32_t mbsfn_ports[SRSLTE_N_MCH_LCIDS]; // Target ports for MBSFN data
};
} // namespace srsue
#endif // SRSUE_GW_H
| 26.009091 | 112 | 0.689269 |
352c1137504a055e54f312af9cc2e1d6d28e6b55 | 296 | h | C | MYZWebHybrid/MYZWebViewController.h | MA806P/MYZWebHybrid | e4f7b88a94269b5f1cedb01df60572f22914efef | [
"Apache-2.0"
] | 4 | 2019-02-23T07:08:48.000Z | 2021-03-13T03:31:13.000Z | MYZWebHybrid/MYZWebViewController.h | MA806P/MYZWebHybrid | e4f7b88a94269b5f1cedb01df60572f22914efef | [
"Apache-2.0"
] | null | null | null | MYZWebHybrid/MYZWebViewController.h | MA806P/MYZWebHybrid | e4f7b88a94269b5f1cedb01df60572f22914efef | [
"Apache-2.0"
] | null | null | null | //
// MYZWebViewController.h
// MYZWebHybrid
//
// Created by MA806P on 2019/2/23.
// Copyright © 2019 myz. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <WebKit/WebKit.h>
@interface MYZWebViewController : UIViewController
@property (nonatomic, strong) WKWebView *webView;
@end
| 17.411765 | 50 | 0.719595 |
dccf044650aedaf53f0cca2d352a1fe9b7c757b3 | 1,850 | h | C | SupervisionTypeEntity.h | apsoftwaredev/psytrack | 0af1b733c93ae0ebcecb0908b04ae3b9f79330c5 | [
"MIT",
"Unlicense"
] | null | null | null | SupervisionTypeEntity.h | apsoftwaredev/psytrack | 0af1b733c93ae0ebcecb0908b04ae3b9f79330c5 | [
"MIT",
"Unlicense"
] | null | null | null | SupervisionTypeEntity.h | apsoftwaredev/psytrack | 0af1b733c93ae0ebcecb0908b04ae3b9f79330c5 | [
"MIT",
"Unlicense"
] | null | null | null | //
// SupervisionTypeEntity.h
// PsyTrack Clinician Tools
// Version: 1.5.4
//
// Created by Daniel Boice on 1/1/13.
// Copyright (c) 2013 PsycheWeb LLC. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@class ExistingSupervisionEntity, SupervisionGivenEntity, SupervisionReceivedEntity, SupervisionTypeSubtypeEntity;
@interface SupervisionTypeEntity : NSManagedObject
@property (nonatomic, retain) NSNumber *order;
@property (nonatomic, retain) NSString *notes;
@property (nonatomic, retain) NSString *supervisionType;
@property (nonatomic, retain) NSSet *existingSupervision;
@property (nonatomic, retain) NSSet *supervisionRecieved;
@property (nonatomic, retain) NSSet *supervisionGiven;
@property (nonatomic, retain) NSSet *subTypes;
@end
@interface SupervisionTypeEntity (CoreDataGeneratedAccessors)
- (void) addExistingSupervisionObject:(ExistingSupervisionEntity *)value;
- (void) removeExistingSupervisionObject:(ExistingSupervisionEntity *)value;
- (void) addExistingSupervision:(NSSet *)values;
- (void) removeExistingSupervision:(NSSet *)values;
- (void) addSupervisionRecievedObject:(SupervisionReceivedEntity *)value;
- (void) removeSupervisionRecievedObject:(SupervisionReceivedEntity *)value;
- (void) addSupervisionRecieved:(NSSet *)values;
- (void) removeSupervisionRecieved:(NSSet *)values;
- (void) addSupervisionGivenObject:(SupervisionGivenEntity *)value;
- (void) removeSupervisionGivenObject:(SupervisionGivenEntity *)value;
- (void) addSupervisionGiven:(NSSet *)values;
- (void) removeSupervisionGiven:(NSSet *)values;
- (void) addSubTypesObject:(SupervisionTypeSubtypeEntity *)value;
- (void) removeSubTypesObject:(SupervisionTypeSubtypeEntity *)value;
- (void) addSubTypes:(NSSet *)values;
- (void) removeSubTypes:(NSSet *)values;
-(BOOL)associatedWithTimeRecords;
@end
| 37 | 114 | 0.792432 |
724a43c8879c2d7fdea64b0e5b7132bf70524831 | 5,468 | c | C | examples/c/mcc152/analog_output_write_all/analog_output_write_all.c | antariandel/daqhats_dev | 3adb97d9f75131842620fcbf16d34588f728b965 | [
"MIT"
] | 88 | 2018-08-21T17:40:04.000Z | 2022-02-16T05:34:51.000Z | examples/c/mcc152/analog_output_write_all/analog_output_write_all.c | antariandel/daqhats_dev | 3adb97d9f75131842620fcbf16d34588f728b965 | [
"MIT"
] | 30 | 2019-02-20T17:47:01.000Z | 2021-11-17T21:40:17.000Z | examples/c/mcc152/analog_output_write_all/analog_output_write_all.c | antariandel/daqhats_dev | 3adb97d9f75131842620fcbf16d34588f728b965 | [
"MIT"
] | 59 | 2018-08-13T18:00:16.000Z | 2022-03-11T16:12:34.000Z | /*****************************************************************************
MCC 152 Functions Demonstrated:
mcc152_a_out_write_all
mcc152_info
Purpose:
Write values to both analog outputs in a loop.
Description:
This example demonstrates writing output data to both outputs
simultaneously.
*****************************************************************************/
#include <stdbool.h>
#include "../../daqhats_utils.h"
#define OPTIONS OPTS_DEFAULT // default output options (voltage), set to
// OPTS_NOSCALEDATA to use DAC codes
#define BUFFER_SIZE 32
bool get_channel_value(double* p_value, int channel)
{
char buffer[BUFFER_SIZE];
double min;
double max;
double value;
if (p_value == NULL)
{
return false;
}
// Get the min and max voltage/code values for the analog outputs to
// validate the user input.
if ((OPTIONS & OPTS_NOSCALEDATA) == 0)
{
min = mcc152_info()->AO_MIN_RANGE;
max = mcc152_info()->AO_MAX_RANGE;
}
else
{
min = (double)mcc152_info()->AO_MIN_CODE;
max = (double)mcc152_info()->AO_MAX_CODE;
}
while (1)
{
printf(" Ch %d: ", channel);
if (fgets(buffer, BUFFER_SIZE, stdin) == NULL)
{
// Empty string or input error.
return false;
}
else
{
if (buffer[0] == '\n')
{
// Enter.
return false;
}
// Got a string - convert to a number.
if (sscanf(buffer, "%lf", &value) == 0)
{
// Not a number.
return false;
}
// Compare the number to min and max allowed.
if ((value < min) || (value > max))
{
// Out of range, ask again.
printf("Value out of range.\n");
}
else
{
// Valid value.
*p_value = value;
return true;
}
}
}
}
bool get_input_values(double* p_values, int count)
{
int channel;
if (p_values == NULL)
{
return false;
}
if ((OPTIONS & OPTS_NOSCALEDATA) == 0)
{
printf("Enter values between %.1f and %.1f, non-numeric character to "
"exit:\n",
mcc152_info()->AO_MIN_RANGE,
mcc152_info()->AO_MAX_RANGE);
}
else
{
printf("Enter values between %u and %u, non-numeric character to "
"exit:\n",
mcc152_info()->AO_MIN_CODE,
mcc152_info()->AO_MAX_CODE);
}
for (channel = 0; channel < count; channel++)
{
if (!get_channel_value(&p_values[channel], channel))
{
return false;
}
}
return true;
}
int main()
{
uint8_t address;
int result = RESULT_SUCCESS;
double *values;
bool error;
bool run_loop;
int channel;
int num_channels;
char options_str[256];
printf("\nMCC 152 all channel analog output example.\n");
printf("Writes the specified voltages to the analog outputs.\n");
printf(" Functions demonstrated:\n");
printf(" mcc152_a_out_write_all\n");
printf(" mcc152_info\n");
convert_options_to_string(OPTIONS, options_str);
printf(" Options: %s\n\n", options_str);
// Select the device to be used.
if (select_hat_device(HAT_ID_MCC_152, &address) != 0)
{
return 1;
}
printf("\nUsing address %d.\n", address);
// Open a connection to the device.
result = mcc152_open(address);
print_error(result);
if (result != RESULT_SUCCESS)
{
// Could not open the device - exit.
printf("Unable to open device at address %d\n", address);
return 1;
}
// Allocate memory for the values.
num_channels = mcc152_info()->NUM_AO_CHANNELS;
values = (double*)malloc(num_channels * sizeof(double));
if (values == NULL)
{
mcc152_close(address);
printf("Could not allocate memory.\n");
return 1;
}
error = false;
run_loop = true;
// Loop until the user terminates or we get a library error.
while (run_loop && !error)
{
if (get_input_values(values, num_channels))
{
result = mcc152_a_out_write_all(address, OPTIONS, values);
if (result != RESULT_SUCCESS)
{
print_error(result);
error = true;
}
}
else
{
run_loop = false;
}
}
// If there was no library error reset the output to 0V.
if (!error)
{
for (channel = 0; channel < mcc152_info()->NUM_AO_CHANNELS; channel++)
{
values[channel] = 0.0;
}
result = mcc152_a_out_write_all(address, OPTIONS, values);
print_error(result);
}
// Close the device.
result = mcc152_close(address);
print_error(result);
// Free allocated memory.
free(values);
return (int)error;
}
| 25.914692 | 81 | 0.490673 |
a6fb17dd1bfabce91ee0a7de9773be8854674a29 | 1,653 | h | C | PWGCF/FEMTOSCOPY/PLamAnalysisPP/AliFemtoProtonParticle.h | wiechula/AliPhysics | 6c5c45a5c985747ee82328d8fd59222b34529895 | [
"BSD-3-Clause"
] | null | null | null | PWGCF/FEMTOSCOPY/PLamAnalysisPP/AliFemtoProtonParticle.h | wiechula/AliPhysics | 6c5c45a5c985747ee82328d8fd59222b34529895 | [
"BSD-3-Clause"
] | null | null | null | PWGCF/FEMTOSCOPY/PLamAnalysisPP/AliFemtoProtonParticle.h | wiechula/AliPhysics | 6c5c45a5c985747ee82328d8fd59222b34529895 | [
"BSD-3-Clause"
] | null | null | null | #ifndef ALIFEMTOProtonParticle_H
#define ALIFEMTOProtonParticle_H
//
//Class AliFemtoLambdaParticle, AliFemtoLambdaEvent, AliFemtoLambdaEventCollection
//
//AliFemtoLambdaParticle, AliFemtoLambdaEvent, AliFemtoLambdaEventCollection
//authors:
// Dhevan Gangadharan (dhevan.raja.gangadharan@cern.ch)
// Matthew Steinpreis (matthew.steinpreis@cern.ch)
//
#include <iostream>
#include <string>
#include "TH1.h"
#include "TH2.h"
#include "TH3.h"
#include "TBits.h"
#include "TObject.h"
#include "AliESDtrack.h"
#include "TVector3.h"
using namespace std;
//class TVector3;
class AliFemtoProtonParticle // Proton parameters are stored in this class
{
public:
AliFemtoProtonParticle();
virtual ~AliFemtoProtonParticle();
//AliFemtoProtonParticle(const AliFemtoProtonParticle &obj);
AliFemtoProtonParticle &operator=(const AliFemtoProtonParticle &obj);
TVector3 fMomentum; //proton momentum
TVector3 fMomentumMC; //proton monte carlo momentum
TVector3 fMomentumMCMother; //momentum of mother particle of proton
TVector3 fMomentumMCMotherParton;
int fPDGCode;
int fPDGCodeMother; // PDG code of the weakly decaying mother resonance in the case of feed-down
int fPDGCodePartonMother; //PDG code of the parton that created the proton
int fPartonMotherLabel; //Label of the particle of the corresponding mother parton defined a line above
double fPt; //proton transverse momentum
short fID; //Daughter (pion) AODtrack ID
double fPhi;
double fPhistar[9];
double fEta;
double fPrimPosTPC[9][3];
Bool_t fReal;
#ifdef __ROOT__
ClassDef(AliFemtoProtonParticle, 1);
#endif
};
#endif
| 27.55 | 105 | 0.762855 |
edaaee92e6525abf292f2e5133eb21d27c0738d2 | 15,512 | c | C | ABB/pruebas_abb.c | joaqogomez/Algoritmos2_mendez_fiuba | 87aceb9a6709228e7d9473deeb9d8d8761386de2 | [
"MIT"
] | 1 | 2020-01-03T00:44:15.000Z | 2020-01-03T00:44:15.000Z | ABB/pruebas_abb.c | joaqogomez/Algoritmos2_mendez_fiuba | 87aceb9a6709228e7d9473deeb9d8d8761386de2 | [
"MIT"
] | null | null | null | ABB/pruebas_abb.c | joaqogomez/Algoritmos2_mendez_fiuba | 87aceb9a6709228e7d9473deeb9d8d8761386de2 | [
"MIT"
] | null | null | null | #include "abb.h"
#include "testing.h"
#include <stdio.h>
#include <time.h>
typedef struct alumno{
int padron;
char nombre[10];
}alumno_t;
alumno_t* crear_alumno(int padron){
alumno_t* alumno= (alumno_t*)malloc(sizeof(alumno_t));
if(alumno!=NULL){
alumno->padron = padron;
}
return alumno;
}
void destruir_alumno(alumno_t* alumno){
if(alumno!=NULL){
free(alumno);
}
}
int comparar_alumnos(void* elemento1, void* elemento2){
if(!elemento1 || !elemento2){
return 0;
}
if(((alumno_t*)elemento1)->padron>((alumno_t*)elemento2)->padron){
return 1;
}else if(((alumno_t*)elemento1)->padron<((alumno_t*)elemento2)->padron){
return -1;
}else{
return 0;
}
}
void destructor_de_alumnos(void* elemento){
if(elemento==NULL){
return;
}
destruir_alumno((alumno_t*)elemento);
}
bool mostrar_elemento(void* elemento, void* extra){
extra=extra;
if(elemento)
printf("%i ", ((alumno_t*)elemento)->padron);
return false;
}
bool mostrar_hasta_5(void* elemento, void* extra){
extra=extra;
if(elemento){
printf("%i ", ((alumno_t*)elemento)->padron);
if(((alumno_t*)elemento)->padron == 5)
return true;
}
return false;
}
void mostrar_arbol(abb_t* arbol, nodo_abb_t* nodo_arbol, int contador){
if(nodo_arbol == NULL){
for(int i=0; i<contador;i++){
printf(" ");
}printf("N\n");
return;
}
mostrar_arbol(arbol,nodo_arbol->derecha, contador+1);
for(int i=0; i<contador;i++){
printf(" ");
}
printf("%i\n", ((alumno_t*)nodo_arbol->elemento)->padron);
mostrar_arbol(arbol,nodo_arbol->izquierda, contador+1);
}
int casos_arbol_null(abb_t* arbol,int* pruebas_totales){
printf("\n");
int pruebas_pasadas=0;
int elemento=0;
int vector[2];//el tamaño del vector puede ser cualquier valor, ya que se quiere chequear otras cosas
int tamanio=2;
printf("Pruebas con el arbol sin crear: \n");
printf("Intento insertar un elemento: ");
pruebas_pasadas+=resultados_prueba((comparador_enteros(arbol_insertar(arbol,&elemento),-1)));
(*pruebas_totales)++;
printf("Intento borrar un elemento: ");
pruebas_pasadas+=resultados_prueba((comparador_enteros(arbol_borrar(arbol,&elemento),-1)));
(*pruebas_totales)++;
printf("Intento buscar un elemento: ");
pruebas_pasadas+=resultados_prueba(arbol_buscar(arbol,&elemento)==NULL);
(*pruebas_totales)++;
printf("Intento ver cual es la raiz del arbol: ");
pruebas_pasadas+=resultados_prueba(arbol_raiz(arbol)==NULL);
(*pruebas_totales)++;
printf("Chequeo que el arbol este vacio: ");
pruebas_pasadas+=resultados_prueba(arbol_vacio(arbol));
(*pruebas_totales)++;
printf("Intento recorrer el arbol:\n");
printf("Inorden: ");
pruebas_pasadas+=resultados_prueba((comparador_enteros(arbol_recorrido_inorden(arbol,(void**)vector,tamanio),0)));
(*pruebas_totales)++;
printf("Preorden: ");
pruebas_pasadas+=resultados_prueba((comparador_enteros(arbol_recorrido_preorden(arbol,(void**)vector,tamanio),0)));
(*pruebas_totales)++;
printf("Postorden: ");
pruebas_pasadas+=resultados_prueba((comparador_enteros(arbol_recorrido_postorden(arbol,(void**)vector,tamanio),0)));
(*pruebas_totales)++;
return pruebas_pasadas;
}
int casos_arbol_vacio(abb_t* arbol,int* pruebas_totales){
printf("\n");
int pruebas_pasadas=0;
int elemento=0;
int vector[2];//el tamaño del vector puede ser cualquier valor, ya que se quiere chequear otras cosas
int tamanio=2;
printf("Creo un arbol\n");
arbol=arbol_crear(comparar_alumnos, destructor_de_alumnos);
printf("Pruebas con el arbol vacio: \n");
printf("Intento borrar un elemento: ");
pruebas_pasadas+=resultados_prueba((comparador_enteros(arbol_borrar(arbol,&elemento),-1)));
(*pruebas_totales)++;
printf("Intento buscar un elemento: ");
pruebas_pasadas+=resultados_prueba(arbol_buscar(arbol,&elemento)==NULL);
(*pruebas_totales)++;
printf("Intento ver cual es la raiz del arbol: ");
pruebas_pasadas+=resultados_prueba(arbol_raiz(arbol)==NULL);
(*pruebas_totales)++;
printf("Chequeo que el arbol este vacio: ");
pruebas_pasadas+=resultados_prueba(arbol_vacio(arbol));
(*pruebas_totales)++;
printf("Intento recorrer el arbol:\n");
printf("Inorden: ");
pruebas_pasadas+=resultados_prueba((comparador_enteros(arbol_recorrido_inorden(arbol,(void**)vector,tamanio),0)));
(*pruebas_totales)++;
printf("Preorden: ");
pruebas_pasadas+=resultados_prueba((comparador_enteros(arbol_recorrido_preorden(arbol,(void**)vector,tamanio),0)));
(*pruebas_totales)++;
printf("Postorden: ");
pruebas_pasadas+=resultados_prueba((comparador_enteros(arbol_recorrido_postorden(arbol,(void**)vector,tamanio),0)));
(*pruebas_totales)++;
arbol_destruir(arbol);
return pruebas_pasadas;
}
int casos_borde_recorridos(abb_t* arbol,int* pruebas_totales){
int pruebas_pasadas=0;
printf("\n");
printf("Chequeo los recorridos\n");
printf("Creo un arbol\n");
arbol=arbol_crear(comparar_alumnos, destructor_de_alumnos);
printf("Inserto 7 elementos y el tope de mi array es 5\n");
alumno_t* elementos[5];
arbol_insertar(arbol, crear_alumno(4));
arbol_insertar(arbol, crear_alumno(2));
arbol_insertar(arbol, crear_alumno(6));
arbol_insertar(arbol, crear_alumno(1));
arbol_insertar(arbol, crear_alumno(3));
arbol_insertar(arbol, crear_alumno(5));
arbol_insertar(arbol, crear_alumno(7));
printf("Pruebo que no se recorrieron todos los elementos e imprimo el recorrido\n");
printf("Recorrido inorden: ");
int cantidad = arbol_recorrido_inorden(arbol, (void**)elementos, 5);
for(int i=0;i<cantidad;i++)
printf("%i ", elementos[i]->padron);
printf("\n");
printf("No se recorrieron todos los elementos: ");
pruebas_pasadas+=resultados_prueba(!comparador_enteros(cantidad,7));
(*pruebas_totales)++;
printf("Recorrido preorden: ");
cantidad = arbol_recorrido_preorden(arbol, (void**)elementos, 5);
for(int i=0;i<cantidad;i++)
printf("%i ", elementos[i]->padron);
printf("\n");
printf("No se recorrieron todos los elementos: ");
pruebas_pasadas+=resultados_prueba(!comparador_enteros(cantidad,7));
(*pruebas_totales)++;
printf("Recorrido postorden: ");
cantidad = arbol_recorrido_postorden(arbol, (void**)elementos, 5);
for(int i=0;i<cantidad;i++)
printf("%i ", elementos[i]->padron);
printf("\n");
printf("No se recorrieron todos los elementos: ");
pruebas_pasadas+=resultados_prueba(!comparador_enteros(cantidad,7));
(*pruebas_totales)++;
arbol_destruir(arbol);
return pruebas_pasadas;
}
int pruebas_casos_borde(abb_t* arbol,int* pruebas_totales){
int pruebas_pasadas=0;
printf("\nPrimero, chequeo casos borde: \n");
pruebas_pasadas+=casos_arbol_null(arbol,pruebas_totales);
pruebas_pasadas+=casos_arbol_vacio(arbol,pruebas_totales);
pruebas_pasadas+=casos_borde_recorridos(arbol,pruebas_totales);
return pruebas_pasadas;
}
int pruebas_elementos_NULL(abb_t* arbol,int* pruebas_totales){
printf("\n");
int pruebas_pasadas=0;
printf("\nChequeo un caso con elementos NULL: \n");
printf("Creo un arbol con destructor NULL\n");
arbol=arbol_crear(comparar_alumnos, NULL);
printf("Se creo correctamente el arbol: ");
pruebas_pasadas+=resultados_prueba(arbol!=NULL);
(*pruebas_totales)++;
printf("El destructor es NULL: ");
pruebas_pasadas+=resultados_prueba(arbol->destructor==NULL);
(*pruebas_totales)++;
printf("Inserto un elemento NULL: ");
pruebas_pasadas+=resultados_prueba(comparador_enteros((arbol_insertar(arbol,NULL)),0));
(*pruebas_totales)++;
printf("El arbol no esta vacio: ");
pruebas_pasadas+=resultados_prueba(!arbol_vacio(arbol));
(*pruebas_totales)++;
printf("NULL es la raiz del arbol: ");
pruebas_pasadas+=resultados_prueba(arbol_raiz(arbol)==NULL);
(*pruebas_totales)++;
printf("Busco el elemento NULL: ");
pruebas_pasadas+=resultados_prueba(arbol_buscar(arbol,NULL)==NULL);
(*pruebas_totales)++;
arbol_destruir(arbol);
return pruebas_pasadas;
}
int pruebas_caso_promedio(abb_t* arbol,int* pruebas_totales){
printf("\n");
int pruebas_pasadas=0;
alumno_t* auxiliar = crear_alumno(1);
printf("\nChequeo un caso promedio: \n");
printf("Creo un arbol\n");
arbol=arbol_crear(comparar_alumnos, destructor_de_alumnos);
printf("Se creo correctamente el arbol: ");
pruebas_pasadas+=resultados_prueba(arbol!=NULL);
(*pruebas_totales)++;
printf("Inserto varios elementos\n");
arbol_insertar(arbol, crear_alumno(4));
arbol_insertar(arbol, crear_alumno(2));
arbol_insertar(arbol, crear_alumno(6));
arbol_insertar(arbol, crear_alumno(1));
arbol_insertar(arbol, crear_alumno(3));
arbol_insertar(arbol, crear_alumno(5));
arbol_insertar(arbol, crear_alumno(7));
printf("Muestro el arbol\n");
mostrar_arbol(arbol, arbol->nodo_raiz, 0);
printf("El arbol no esta vacio: ");
pruebas_pasadas+=resultados_prueba(!arbol_vacio(arbol));
(*pruebas_totales)++;
printf("El 4 es la raiz del arbol: ");
pruebas_pasadas+=resultados_prueba(comparador_enteros(((alumno_t*)arbol_raiz(arbol))->padron,4));
(*pruebas_totales)++;
printf("El 1 esta en el arbol: ");
pruebas_pasadas+=resultados_prueba(comparador_enteros(((alumno_t*)arbol_buscar(arbol,auxiliar))->padron,1));
(*pruebas_totales)++;
printf("Elimino la raiz: ");
auxiliar->padron = 4;
pruebas_pasadas+=resultados_prueba(comparador_enteros((arbol_borrar(arbol,auxiliar)),0));
(*pruebas_totales)++;
printf("Muestro el arbol\n");
mostrar_arbol(arbol, arbol->nodo_raiz, 0);
printf("El 4 ya no es la raiz del arbol: ");
pruebas_pasadas+=resultados_prueba(!comparador_enteros(((alumno_t*)arbol_raiz(arbol))->padron,4));
(*pruebas_totales)++;
printf("Elimino el 6: ");
auxiliar->padron = 6;
pruebas_pasadas+=resultados_prueba(comparador_enteros((arbol_borrar(arbol,auxiliar)),0));
(*pruebas_totales)++;
printf("Muestro el arbol\n");
mostrar_arbol(arbol, arbol->nodo_raiz, 0);
printf("El 6 ya no esta en el arbol: ");
pruebas_pasadas+=resultados_prueba(arbol_buscar(arbol,auxiliar)==NULL);
(*pruebas_totales)++;
printf("Inserto varios elementos\n");
arbol_insertar(arbol, crear_alumno(0));
arbol_insertar(arbol, crear_alumno(2));
arbol_insertar(arbol, crear_alumno(12));
arbol_insertar(arbol, crear_alumno(6));
arbol_insertar(arbol, crear_alumno(10));
arbol_insertar(arbol, crear_alumno(11));
arbol_insertar(arbol, crear_alumno(9));
printf("Muestro el arbol\n");
mostrar_arbol(arbol, arbol->nodo_raiz, 0);
printf("Elimino el 2: ");
auxiliar->padron = 2;
pruebas_pasadas+=resultados_prueba(comparador_enteros((arbol_borrar(arbol,auxiliar)),0));
(*pruebas_totales)++;
printf("Muestro el arbol\n");
mostrar_arbol(arbol, arbol->nodo_raiz, 0);
printf("Elimino el 11: ");
auxiliar->padron = 11;
pruebas_pasadas+=resultados_prueba(comparador_enteros((arbol_borrar(arbol,auxiliar)),0));
(*pruebas_totales)++;
printf("Muestro el arbol\n");
mostrar_arbol(arbol, arbol->nodo_raiz, 0);
printf("Elimino el 12: ");
auxiliar->padron = 12;
pruebas_pasadas+=resultados_prueba(comparador_enteros((arbol_borrar(arbol,auxiliar)),0));
(*pruebas_totales)++;
printf("Muestro el arbol\n");
mostrar_arbol(arbol, arbol->nodo_raiz, 0);
printf("Pruebo los recorridos\n");
alumno_t* elementos[10];
printf("Recorrido inorden: ");
int cantidad = arbol_recorrido_inorden(arbol, (void**)elementos, 10);
for(int i=0;i<cantidad;i++)
printf("%i ", elementos[i]->padron);
printf("\n");
printf("Recorrido preorden: ");
cantidad = arbol_recorrido_preorden(arbol, (void**)elementos, 10);
for(int i=0;i<cantidad;i++)
printf("%i ", elementos[i]->padron);
printf("\n");
printf("Recorrido postorden: ");
cantidad = arbol_recorrido_postorden(arbol, (void**)elementos, 10);
for(int i=0;i<cantidad;i++)
printf("%i ", elementos[i]->padron);
printf("\n");
printf("Pruebo el iterador interno\n");
printf("Recorrido inorden iterador interno: ");
abb_con_cada_elemento(arbol, ABB_RECORRER_INORDEN, mostrar_elemento, NULL);
printf("\n");
printf("Recorrido preorden iterador interno: ");
abb_con_cada_elemento(arbol, ABB_RECORRER_PREORDEN, mostrar_elemento, NULL);
printf("\n");
printf("Recorrido postorden iterador interno: ");
abb_con_cada_elemento(arbol, ABB_RECORRER_POSTORDEN, mostrar_elemento, NULL);
printf("\n");
free(auxiliar);
arbol_destruir(arbol);
return pruebas_pasadas;
}
int pruebas_volumen(abb_t* arbol,int* pruebas_totales){
int pruebas_pasadas=0;
printf("\n");
printf("Chequeo un caso en el que se insertan muchos elementos: \n");
printf("Creo un arbol\n");
arbol=arbol_crear(comparar_alumnos, destructor_de_alumnos);
printf("Se creo correctamente el arbol: ");
pruebas_pasadas+=resultados_prueba(arbol!=NULL);
(*pruebas_totales)++;
printf("Inserto 1000 elementos\n");
for (int i = 0; i < 1000; ++i){
arbol_insertar(arbol, crear_alumno(rand()%50));
}
printf("El arbol no esta vacio: ");
pruebas_pasadas+=resultados_prueba(!arbol_vacio(arbol));
(*pruebas_totales)++;
printf("Pruebo los recorridos, mostrando solo 10 elementos\n");
alumno_t* elementos[10];
printf("Recorrido inorden: ");
int cantidad = arbol_recorrido_inorden(arbol, (void**)elementos, 10);
for(int i=0;i<cantidad;i++)
printf("%i ", elementos[i]->padron);
printf("\n");
printf("Recorrido preorden: ");
cantidad = arbol_recorrido_preorden(arbol, (void**)elementos, 10);
for(int i=0;i<cantidad;i++)
printf("%i ", elementos[i]->padron);
printf("\n");
printf("Recorrido postorden: ");
cantidad = arbol_recorrido_postorden(arbol, (void**)elementos, 10);
for(int i=0;i<cantidad;i++)
printf("%i ", elementos[i]->padron);
printf("\n");
printf("Pruebo el iterador interno\n");
printf("Recorro hasta que encuentre el numero 5\n");
printf("Recorrido inorden iterador interno: ");
abb_con_cada_elemento(arbol, ABB_RECORRER_INORDEN, mostrar_hasta_5, NULL);
printf("\n");
printf("Recorrido preorden iterador interno: ");
abb_con_cada_elemento(arbol, ABB_RECORRER_PREORDEN, mostrar_hasta_5, NULL);
printf("\n");
printf("Recorrido postorden iterador interno: ");
abb_con_cada_elemento(arbol, ABB_RECORRER_POSTORDEN, mostrar_hasta_5, NULL);
printf("\n");
arbol_destruir(arbol);
return pruebas_pasadas;
}
int main(){
int pruebas_totales=0;
int pruebas_pasadas=0;
abb_t* arbol = NULL;
printf("\t\t\t\tPruebas ABB\n\n");
pruebas_pasadas+=pruebas_casos_borde(arbol,&pruebas_totales);
pruebas_pasadas+=pruebas_elementos_NULL(arbol,&pruebas_totales);
pruebas_pasadas+=pruebas_caso_promedio(arbol,&pruebas_totales);
pruebas_pasadas+=pruebas_volumen(arbol,&pruebas_totales);
arbol_destruir(arbol);
printf("\nFin de las pruebas\n");
printf("\nPasaron %i pruebas de %i totales.\n",pruebas_pasadas,pruebas_totales);
return 0;
}
| 39.171717 | 120 | 0.687919 |
60e58c4d087425b25a7d60f37257956983c996e4 | 4,578 | h | C | rvip/include/rvip/rvip_main.h | cardboardcode/rvip-1 | 8f429c4bd86f4cf544f30b427389bed2a63df810 | [
"BSD-3-Clause"
] | 2 | 2020-03-03T00:52:34.000Z | 2020-03-03T04:58:35.000Z | rvip/include/rvip/rvip_main.h | cardboardcode/rvip-1 | 8f429c4bd86f4cf544f30b427389bed2a63df810 | [
"BSD-3-Clause"
] | 2 | 2020-09-17T09:16:34.000Z | 2020-09-17T09:17:15.000Z | rvip/include/rvip/rvip_main.h | cardboardcode/rvip-1 | 8f429c4bd86f4cf544f30b427389bed2a63df810 | [
"BSD-3-Clause"
] | 3 | 2020-03-02T15:25:34.000Z | 2020-04-29T08:32:29.000Z | /* Copyright (C) 2019 by Bey Hao Yun <beyhy@artc.a-star.edu.sg>
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef RVIP_RVIP_MAIN_H // head guards
#define RVIP_RVIP_MAIN_H
#include <string>
#include <vector>
#include <tf/transform_broadcaster.h>
#include <visualization_msgs/Marker.h>
#include <visualization_msgs/MarkerArray.h>
#include <sensor_msgs/RegionOfInterest.h>
#include <rvip_roi_parser/ROIArray.h>
/*! \class RVIPobj
\brief A Robotic Vision Integration Package (RVIP) class object.
The RVIPobj class object conducts object localization functionalities using a 2D-3D hybrid
approach. Within this class, functions defined with the cuboid_generation and pose_alignment
library are utilized.
*/
class RVIPobj
{
public:
/*! \constructor Default constructor
*
* Empty function. No class attributes initialized with default values.
*/
RVIPobj(void);
// Output topics
// ros::Publisher pcl_pub; // DEBUG - Not used
// ros::Publisher scene_pcl_pub; // DEBUG - Not used
/*! \brief A ROS topic that outputs both position and orientation of detected object. */
ros::Publisher marker_pub;
int xmin; /*!< \brief Minimum pixel x-coordinate value of the 2D bounding boxes */
int xmax; /*!< \brief Maximum pixel x-coordinate value of the 2D bounding boxes */
int ymin; /*!< \brief Minimum pixel y-coordinate value of the 2D bounding boxes */
int ymax; /*!< \brief Maximum pixel y-coordinate value of the 2D bounding boxes */
std::string frame_id; /*!< \brief The Fixed Frame value that will be read by RVIZ to be displayed. */
float obj_x; /*!< \brief Euclidean x value of object centroid. */
float obj_y; /*!< \brief Euclidean y value of object centroid. */
float obj_z; /*!< \brief Euclidean z value of object centroid. */
float obj_height; /*!< \brief Estimated height of object.*/
float obj_width; /*!< \brief Estimated width of object. */
float obj_length; /*!< \brief Estimated length of object.*/
std::vector<tf::Transform> obj_tfs; // Array of multiple transforms for detected objects.
/*! \brief A tf::TransformBroadcaster object.
*
* This tf::TransformBroadcaster will broadcast the final deduced tf::Transform, containing position and
* orientation object.
*
* Refer to this link for more details: https://docs.ros.org/melodic/api/tf/html/c++/classtf_1_1TransformBroadcaster.html
*/
tf::TransformBroadcaster br; // TF Broadcaster of the deduced position and orientation of detected objects.
pcl::PointCloud<pcl::PointXYZ> modelCloud; /*!< \brief PointCloud cluster of generated estimated cuboid.*/
sensor_msgs::PointCloud2 raw_pointcloud; /*!< \brief PointCloud cluster of raw input PointCloud.*/
std::vector<sensor_msgs::RegionOfInterest> boxes; /*!< \brief A vector containing filtered sensor_msgs RegionOfInterest objects.*/
visualization_msgs::MarkerArray obj_markers; /*!< \brief An array of output visualization_msgs Markers*/
/*! \brief A CallBack Function to receive PointCloud of scene.*/
void pclCallBack(const sensor_msgs::PointCloud2ConstPtr& pcd);
/*! \brief A CallBack Function to receive 2D Bounding Box pixel coordinates value of detected object in rectified image.*/
void roiCallBack(const rvip_roi_parser::ROIArrayConstPtr& msg);
/*! \brief A function that broadcast the output tf::Tranform and publish the output the visualization_msgs MarkerArray*/
void visualizeDetectionOutput(void);
/*! \brief Checks if an existing RegionOfInterest box in the boxes vector is within or a duplicate of the RegionOfInterest box that is to be added */
bool isWithinBoundingBox(sensor_msgs::RegionOfInterest box_in_list, sensor_msgs::RegionOfInterest box_added);
/*! \brief A function that runs Pose Estimation algorithm based on 2D Bounding Box and 3D PointCloud input*/
void run(void);
};
#include "rvip_main.hpp"
#endif // RVIP_RVIP_MAIN_H
| 48.189474 | 153 | 0.733508 |
8e5f3d30ce8fe8975aefe509555c22686149c761 | 7,309 | h | C | backend/map-resources/include/map-resources/resource-conversion-inl.h | AdronTech/maplab | 1340e01466fc1c02994860723b8117daf9ad226d | [
"Apache-2.0"
] | 1,936 | 2017-11-27T23:11:37.000Z | 2022-03-30T14:24:14.000Z | backend/map-resources/include/map-resources/resource-conversion-inl.h | AdronTech/maplab | 1340e01466fc1c02994860723b8117daf9ad226d | [
"Apache-2.0"
] | 353 | 2017-11-29T18:40:39.000Z | 2022-03-30T15:53:46.000Z | backend/map-resources/include/map-resources/resource-conversion-inl.h | AdronTech/maplab | 1340e01466fc1c02994860723b8117daf9ad226d | [
"Apache-2.0"
] | 661 | 2017-11-28T07:20:08.000Z | 2022-03-28T08:06:29.000Z | #ifndef MAP_RESOURCES_RESOURCE_CONVERSION_INL_H_
#define MAP_RESOURCES_RESOURCE_CONVERSION_INL_H_
#include <vector>
#include <aslam/cameras/camera.h>
#include <aslam/cameras/distortion.h>
#include <glog/logging.h>
#include <maplab-common/pose_types.h>
#include <opencv2/core.hpp>
#include <voxblox/core/common.h>
#include "map-resources/resource-typedefs.h"
namespace backend {
// Adds a point to a point cloud at a specific index. This function assumes that
// the point cloud has already been resized to allow for direct insertion at
// this index.
template <typename PointCloudType>
void addPointToPointCloud(
const Eigen::Vector3d& point_C, const resources::RgbaColor& color,
const size_t index, PointCloudType* point_cloud);
template <typename PointCloudType>
void addPointToPointCloud(
const Eigen::Vector3d& point_C, const size_t index,
PointCloudType* point_cloud);
template <>
void addPointToPointCloud(
const Eigen::Vector3d& point_C, const resources::RgbaColor& color,
const size_t index, pose::Position3DVector* point_cloud);
template <>
void addPointToPointCloud(
const Eigen::Vector3d& point_C, const resources::RgbaColor& color,
const size_t index, resources::VoxbloxColorPointCloud* point_cloud);
template <>
void addPointToPointCloud(
const Eigen::Vector3d& point_C, const resources::RgbaColor& color,
const size_t index, resources::PointCloud* point_cloud);
template <>
void addPointToPointCloud(
const Eigen::Vector3d& point_C, const size_t index,
pose::Position3DVector* point_cloud);
template <>
void addPointToPointCloud(
const Eigen::Vector3d& point_C, const size_t index,
resources::VoxbloxColorPointCloud* point_cloud);
template <>
void addPointToPointCloud(
const Eigen::Vector3d& point_C, const size_t index,
resources::PointCloud* point_cloud);
template <typename PointCloudType>
bool hasColorInformation(const PointCloudType& point_cloud);
template <>
bool hasColorInformation(const pose::Position3DVector& point_cloud);
template <>
bool hasColorInformation(const resources::VoxbloxColorPointCloud& point_cloud);
template <>
bool hasColorInformation(const resources::PointCloud& point_cloud);
template <typename PointCloudType>
void resizePointCloud(const size_t size, PointCloudType* point_cloud);
template <>
void resizePointCloud(const size_t size, pose::Position3DVector* point_cloud);
template <>
void resizePointCloud(
const size_t size, resources::VoxbloxColorPointCloud* point_cloud);
template <>
void resizePointCloud(const size_t size, resources::PointCloud* point_cloud);
template <typename PointCloudType>
size_t getPointCloudSize(const PointCloudType& point_cloud);
template <>
size_t getPointCloudSize(const pose::Position3DVector& point_cloud);
template <>
size_t getPointCloudSize(const resources::VoxbloxColorPointCloud& point_cloud);
template <>
size_t getPointCloudSize(const resources::PointCloud& point_cloud);
template <typename PointCloudType>
void getPointFromPointCloud(
const PointCloudType& point_cloud, const size_t index,
Eigen::Vector3d* point_C, resources::RgbaColor* color);
template <typename PointCloudType>
void getPointFromPointCloud(
const PointCloudType& point_cloud, const size_t index,
Eigen::Vector3d* point_C) {
getPointFromPointCloud(point_cloud, index, point_C, nullptr);
}
template <>
void getPointFromPointCloud(
const pose::Position3DVector& point_cloud, const size_t index,
Eigen::Vector3d* point_C, resources::RgbaColor* color);
template <>
void getPointFromPointCloud(
const resources::VoxbloxColorPointCloud& point_cloud, const size_t index,
Eigen::Vector3d* point_C, resources::RgbaColor* color);
template <>
void getPointFromPointCloud(
const resources::PointCloud& point_cloud, const size_t index,
Eigen::Vector3d* point_C, resources::RgbaColor* color);
template <typename PointCloudType>
bool convertDepthMapToPointCloud(
const cv::Mat& depth_map, const cv::Mat& image, const aslam::Camera& camera,
PointCloudType* point_cloud) {
CHECK_NOTNULL(point_cloud);
CHECK(!depth_map.empty());
CHECK_GT(depth_map.rows, 0);
CHECK_GT(depth_map.cols, 0);
CHECK_EQ(CV_MAT_TYPE(depth_map.type()), CV_16U);
// Image should either be grayscale 8bit image or color 3x8bit.
CHECK(
CV_MAT_TYPE(image.type()) == CV_8UC1 ||
CV_MAT_TYPE(image.type()) == CV_8UC3);
const bool has_image =
(depth_map.rows == image.rows) && (depth_map.cols == image.cols);
const bool has_three_channels = CV_MAT_TYPE(image.type()) == CV_8UC3;
const size_t valid_depth_entries = cv::countNonZero(depth_map);
if (valid_depth_entries == 0u) {
VLOG(3) << "Depth map has no valid depth measurements!";
return false;
}
resizePointCloud(valid_depth_entries, point_cloud);
constexpr double kMillimetersToMeters = 1e-3;
constexpr double kEpsilon = 1e-6;
resources::RgbaColor color(255u, 255u, 255u, 255u);
const uint16_t* depth_map_ptr;
size_t num_points = 0u;
for (int v = 0; v < depth_map.rows; ++v) {
depth_map_ptr = depth_map.ptr<uint16_t>(v);
for (int u = 0; u < depth_map.cols; ++u) {
const uint16_t depth = depth_map_ptr[u];
if (depth == 0u) {
continue;
}
Eigen::Vector3d point_C;
Eigen::Vector2d image_point;
image_point << u, v;
camera.backProject3(image_point, &point_C);
const double depth_in_meters =
static_cast<double>(depth) * kMillimetersToMeters;
if (point_C.z() < kEpsilon) {
continue;
}
point_C /= point_C.z();
point_C = depth_in_meters * point_C;
if (has_image) {
if (has_three_channels) {
const cv::Vec3b& cv_color = image.at<cv::Vec3b>(v, u);
// NOTE: Assumes the image are stored as BGR.
color[0] = cv_color[2];
color[1] = cv_color[1];
color[2] = cv_color[0];
} else {
color[0] = image.at<uint8_t>(v, u);
color[1] = color[0];
color[2] = color[0];
}
color[3] = 255u;
}
addPointToPointCloud(point_C, color, num_points, point_cloud);
++num_points;
}
}
VLOG(3) << "Converted depth map to a point cloud of size " << num_points
<< ".";
if (num_points == 0u) {
VLOG(3) << "Depth map has no valid depth measurements!";
return false;
}
return true;
}
template <typename InputPointCloud, typename OutputPointCloud>
bool convertPointCloudType(
const InputPointCloud& input_cloud, OutputPointCloud* output_cloud) {
CHECK_NOTNULL(output_cloud);
const bool input_has_color = hasColorInformation(input_cloud);
const size_t num_points = getPointCloudSize(input_cloud);
resizePointCloud(num_points, output_cloud);
for (size_t point_idx = 0u; point_idx < num_points; ++point_idx) {
Eigen::Vector3d point_C;
resources::RgbaColor color;
if (input_has_color) {
getPointFromPointCloud(input_cloud, point_idx, &point_C, &color);
addPointToPointCloud(point_C, color, point_idx, output_cloud);
} else {
getPointFromPointCloud(input_cloud, point_idx, &point_C);
addPointToPointCloud(point_C, point_idx, output_cloud);
}
}
return true;
}
} // namespace backend
#endif // MAP_RESOURCES_RESOURCE_CONVERSION_INL_H_
| 31.102128 | 80 | 0.72787 |
32aac7ecf79d44a922953c0f78467b732f1685a0 | 8,981 | h | C | src/ClientServer/services/bgenc/session_mgr.h | workerVA/S2OPC | 9a5b6008559501f46a4bc079beea2d6655b1bfe5 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | src/ClientServer/services/bgenc/session_mgr.h | workerVA/S2OPC | 9a5b6008559501f46a4bc079beea2d6655b1bfe5 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | src/ClientServer/services/bgenc/session_mgr.h | workerVA/S2OPC | 9a5b6008559501f46a4bc079beea2d6655b1bfe5 | [
"ECL-2.0",
"Apache-2.0"
] | 1 | 2020-04-28T08:32:27.000Z | 2020-04-28T08:32:27.000Z | /*
* Licensed to Systerel under one or more contributor license
* agreements. See the NOTICE file distributed with this work
* for additional information regarding copyright ownership.
* Systerel 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.
*/
/******************************************************************************
File Name : session_mgr.h
Date : 06/03/2020 14:49:21
C Translator Version : tradc Java V1.0 (14/03/2012)
******************************************************************************/
#ifndef _session_mgr_h
#define _session_mgr_h
/*--------------------------
Added by the Translator
--------------------------*/
#include "b2c.h"
/*-----------------
IMPORTS Clause
-----------------*/
#include "session_core.h"
#include "session_mgr_it.h"
#include "session_request_handle_bs.h"
#include "user_authentication.h"
/*--------------
SEES Clause
--------------*/
#include "channel_mgr.h"
#include "constants.h"
#include "constants_statuscodes_bs.h"
#include "message_in_bs.h"
#include "message_out_bs.h"
#include "request_handle_bs.h"
/*------------------------
INITIALISATION Clause
------------------------*/
extern void session_mgr__INITIALISATION(void);
/*-------------------------------
PROMOTES and EXTENDS Clauses
-------------------------------*/
#define session_mgr__client_secure_channel_lost_session_sm session_core__client_secure_channel_lost_session_sm
#define session_mgr__find_channel_to_close session_core__find_channel_to_close
#define session_mgr__get_local_user user_authentication__get_local_user
#define session_mgr__get_server_session_preferred_locales session_core__get_server_session_preferred_locales
#define session_mgr__get_session_user_server session_core__get_session_user_server
#define session_mgr__getall_valid_session_channel session_core__getall_valid_session_channel
#define session_mgr__is_valid_session session_core__is_valid_session
#define session_mgr__server_close_session_sm session_core__server_close_session_sm
#define session_mgr__server_secure_channel_lost_session_sm session_core__server_secure_channel_lost_session_sm
/*--------------------------
LOCAL_OPERATIONS Clause
--------------------------*/
extern void session_mgr__local_client_activate_sessions_on_SC_connection(
const constants__t_channel_config_idx_i session_mgr__channel_config_idx);
extern void session_mgr__local_client_close_session(
const constants__t_session_i session_mgr__session,
const constants_statuscodes_bs__t_StatusCode_i session_mgr__sc_reason);
extern void session_mgr__local_client_close_session_if_needed(
const t_bool session_mgr__cond,
const constants__t_session_i session_mgr__session,
const constants_statuscodes_bs__t_StatusCode_i session_mgr__sc_reason);
extern void session_mgr__local_client_close_sessions_on_SC_final_connection_failure(
const constants__t_channel_config_idx_i session_mgr__channel_config_idx);
/*--------------------
OPERATIONS Clause
--------------------*/
extern void session_mgr__client_async_activate_new_session_with_channel(
const constants__t_channel_config_idx_i session_mgr__channel_config_idx,
const constants__t_channel_i session_mgr__channel,
const constants__t_user_token_i session_mgr__p_user_token,
const constants__t_application_context_i session_mgr__app_context,
t_bool * const session_mgr__bres);
extern void session_mgr__client_async_activate_new_session_without_channel(
const constants__t_channel_config_idx_i session_mgr__channel_config_idx,
const constants__t_user_token_i session_mgr__p_user_token,
const constants__t_application_context_i session_mgr__app_context,
t_bool * const session_mgr__bres);
extern void session_mgr__client_channel_connected_event_session(
const constants__t_channel_config_idx_i session_mgr__channel_config_idx,
const constants__t_channel_i session_mgr__channel);
extern void session_mgr__client_close_session(
const constants__t_session_i session_mgr__session,
const constants_statuscodes_bs__t_StatusCode_i session_mgr__sc_reason);
extern void session_mgr__client_close_session_req(
const constants__t_session_i session_mgr__session,
const constants__t_client_request_handle_i session_mgr__req_handle,
const constants__t_msg_i session_mgr__close_req_msg,
constants_statuscodes_bs__t_StatusCode_i * const session_mgr__ret,
constants__t_channel_i * const session_mgr__channel,
constants__t_session_token_i * const session_mgr__session_token);
extern void session_mgr__client_close_sessions_on_final_connection_failure(
const constants__t_channel_config_idx_i session_mgr__channel_config_idx);
extern void session_mgr__client_create_session_req(
const constants__t_session_i session_mgr__session,
const constants__t_channel_i session_mgr__channel,
const constants__t_client_request_handle_i session_mgr__req_handle,
const constants__t_msg_i session_mgr__create_req_msg,
t_bool * const session_mgr__bret);
extern void session_mgr__client_receive_session_resp(
const constants__t_channel_i session_mgr__channel,
const constants__t_client_request_handle_i session_mgr__req_handle,
const constants__t_msg_type_i session_mgr__resp_typ,
const constants__t_msg_header_i session_mgr__resp_header,
const constants__t_msg_i session_mgr__resp_msg,
constants__t_session_i * const session_mgr__session);
extern void session_mgr__client_sc_activate_session_req(
const constants__t_session_i session_mgr__session,
const constants__t_client_request_handle_i session_mgr__req_handle,
const constants__t_channel_i session_mgr__channel,
const constants__t_msg_i session_mgr__activate_req_msg,
constants_statuscodes_bs__t_StatusCode_i * const session_mgr__ret,
constants__t_session_token_i * const session_mgr__session_token);
extern void session_mgr__client_user_activate_session_req(
const constants__t_session_i session_mgr__session,
const constants__t_client_request_handle_i session_mgr__req_handle,
const constants__t_user_token_i session_mgr__p_user_token,
const constants__t_msg_i session_mgr__activate_req_msg,
constants_statuscodes_bs__t_StatusCode_i * const session_mgr__ret,
constants__t_channel_i * const session_mgr__channel,
constants__t_session_token_i * const session_mgr__session_token);
extern void session_mgr__client_validate_session_service_req(
const constants__t_session_i session_mgr__session,
const constants__t_client_request_handle_i session_mgr__req_handle,
constants_statuscodes_bs__t_StatusCode_i * const session_mgr__ret,
constants__t_channel_i * const session_mgr__channel,
constants__t_session_token_i * const session_mgr__session_token);
extern void session_mgr__client_validate_session_service_resp(
const constants__t_channel_i session_mgr__channel,
const constants__t_client_request_handle_i session_mgr__req_handle,
t_bool * const session_mgr__bres,
constants__t_session_i * const session_mgr__session);
extern void session_mgr__server_evaluate_session_timeout(
const constants__t_session_i session_mgr__session);
extern void session_mgr__server_receive_session_req(
const constants__t_channel_i session_mgr__channel,
const constants__t_session_token_i session_mgr__session_token,
const constants__t_msg_i session_mgr__req_msg,
const constants__t_msg_type_i session_mgr__req_typ,
const constants__t_msg_i session_mgr__resp_msg,
constants__t_session_i * const session_mgr__session,
constants_statuscodes_bs__t_StatusCode_i * const session_mgr__service_ret);
extern void session_mgr__server_validate_session_service_req(
const constants__t_channel_i session_mgr__channel,
const constants__t_session_token_i session_mgr__session_token,
t_bool * const session_mgr__is_valid_res,
constants__t_session_i * const session_mgr__session,
constants_statuscodes_bs__t_StatusCode_i * const session_mgr__status_code_err);
extern void session_mgr__server_validate_session_service_resp(
const constants__t_session_i session_mgr__session,
t_bool * const session_mgr__is_valid_res,
constants_statuscodes_bs__t_StatusCode_i * const session_mgr__status_code_err,
constants__t_channel_i * const session_mgr__channel);
extern void session_mgr__session_get_endpoint_config(
const constants__t_session_i session_mgr__p_session,
constants__t_endpoint_config_idx_i * const session_mgr__endpoint_config_idx);
#endif
| 49.076503 | 110 | 0.815054 |
0a2d320d159e5ebe06b299de5f7066ffa5a89a26 | 129 | h | C | ivory-bsp-stm32/support/ref_to_uint32.h | mmilata/ivory-tower-stm32 | 350ec81025fd20c92d18934b15bc9caa5546caa2 | [
"BSD-3-Clause"
] | 11 | 2015-02-12T13:54:32.000Z | 2022-03-19T00:13:07.000Z | templates/support/ref_to_uint32.h | sorki/data-stm32 | 204aff53eaae422d30516039719a6ec7522a6ab7 | [
"BSD-3-Clause"
] | 7 | 2015-02-27T23:35:19.000Z | 2019-04-10T17:06:16.000Z | templates/support/ref_to_uint32.h | sorki/data-stm32 | 204aff53eaae422d30516039719a6ec7522a6ab7 | [
"BSD-3-Clause"
] | 4 | 2017-03-19T00:48:35.000Z | 2019-05-13T23:31:53.000Z |
#ifndef REF_TO_UINT32_H
#define REF_TO_UINT32_H
#include <stdint.h>
uint32_t ref_to_uint32(void*);
#endif // REF_TO_UINT32_H
| 12.9 | 30 | 0.782946 |
a1edc702f8a0d6c1d19b9629e7a72bbc22ff9c8d | 582 | c | C | testCharLed1/testLed.c | lukeliuli/learningLiinuxDriversAndCores | 9667c366f170f15861b85415f4110c3d2feb50ee | [
"Apache-2.0"
] | null | null | null | testCharLed1/testLed.c | lukeliuli/learningLiinuxDriversAndCores | 9667c366f170f15861b85415f4110c3d2feb50ee | [
"Apache-2.0"
] | null | null | null | testCharLed1/testLed.c | lukeliuli/learningLiinuxDriversAndCores | 9667c366f170f15861b85415f4110c3d2feb50ee | [
"Apache-2.0"
] | 3 | 2021-01-06T02:16:23.000Z | 2022-01-06T10:16:10.000Z | #include<stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <fcntl.h>
int main(int argc, char **argv)
{
int on;
int led_no =0;
int fd;
int i;
fd = open("/dev/pi_Led", 0);
if (fd < 0) {
fd = open("/dev/pi_Led", 0);
}
if (fd < 0) {
printf("pen device led failed\n");
perror("open device led");
exit(1);
}
for(i=0;i<=20;i++){
on = i%2;
ioctl(fd, on, led_no);
printf("led blinking \n");
sleep(1);
}
close(fd);
return 0;
}
| 18.1875 | 40 | 0.494845 |
de6105e03df7b18f2681206ba7514350d49dd0a8 | 1,403 | h | C | src/engineClass/scene.h | TheSpyGeek/Green-Engine | cdfbd55410ee5d90cbeb51390f2ae9a4e84f4792 | [
"MIT"
] | 1 | 2021-07-04T12:33:49.000Z | 2021-07-04T12:33:49.000Z | src/engineClass/scene.h | TheSpyGeek/Green-Engine | cdfbd55410ee5d90cbeb51390f2ae9a4e84f4792 | [
"MIT"
] | 2 | 2019-10-29T11:46:09.000Z | 2019-11-21T20:44:02.000Z | src/engineClass/scene.h | TheSpyGeek/Green-Engine | cdfbd55410ee5d90cbeb51390f2ae9a4e84f4792 | [
"MIT"
] | null | null | null |
#ifndef SCENE_H
#define SCENE_H
#ifndef GLM_H
#define GLM_H
#include <glm/gtx/perpendicular.hpp>
#include <glm/glm.hpp>
#include <glm/ext/matrix_transform.hpp>
#include <glm/ext/matrix_clip_space.hpp>
#include <glm/gtc/matrix_inverse.hpp>
#endif
#include <string>
#include <vector>
#include "../tools/lights/light.h"
#include "../tools/camera.h"
#include "engineObject.h"
class Scene {
public:
Scene();
~Scene();
void createUI();
Camera *getCamera();
Light *getLight();
void createUIAtID(int indexItem, char *ID);
void drawUIAtID(std::vector<EngineObject*> objs, int indexItem, char *ID);
void getAllObjects(std::vector<std::string> & names, std::vector<int> & ids);
void update();
void updateObj(EngineObject *obj);
void addMeshObject();
void addPlane();
void addEngineObject();
void addSphere();
void addTerrain();
void deleteObject(int id);
void loadSolarSystem();
void loadTerrainPlayer();
void loadDefaultScene();
std::vector<EngineObject*> objectsEngine;
int addNewId();
void togglePause();
private:
void deleteScene();
Camera *getCameraRecursive(EngineObject *obj);
Light *getLightRecursive(EngineObject *obj);
int IDObject = 0;
bool pause;
};
#endif
| 20.333333 | 85 | 0.621525 |
25da755dbeb756f741e80f33aaa5c2f5a0602805 | 700 | h | C | XamoomSDK/Classes/mapping/PushHelper.h | xamoom/xamoom-ios-sdk | e78f35b27d6b961345e6adb758cf46931a1f486c | [
"MIT"
] | 4 | 2015-11-18T10:49:22.000Z | 2018-07-11T16:33:03.000Z | XamoomSDK/Classes/mapping/PushHelper.h | xamoom/xamoom-ios-sdk | e78f35b27d6b961345e6adb758cf46931a1f486c | [
"MIT"
] | 2 | 2020-01-16T12:10:03.000Z | 2020-01-16T12:31:43.000Z | XamoomSDK/Classes/mapping/PushHelper.h | xamoom/xamoom-ios-sdk | e78f35b27d6b961345e6adb758cf46931a1f486c | [
"MIT"
] | 3 | 2016-04-09T09:24:23.000Z | 2017-09-07T14:19:48.000Z | //
// PushHelper.h
// XamoomSDK
//
// Created by Thomas Krainz-Mischitz on 05.03.19.
// Copyright © 2019 xamoom GmbH. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UserNotifications/UserNotifications.h>
#import <Firebase/Firebase.h>
#import "XMMEnduserApi.h"
extern NSString *const XAMOOM_NOTIFICATION_RECEIVE;
@interface PushHelper : NSObject<UNUserNotificationCenterDelegate, FIRMessagingDelegate>
@property (nonatomic, retain) id<FIRMessagingDelegate> messagingDelegate;
@property (nonatomic, retain) id <UNUserNotificationCenterDelegate> notificationDelegate;
@property (nonatomic, strong) XMMEnduserApi *api;
- (instancetype)initWithApi:(XMMEnduserApi *)api;
@end
| 28 | 89 | 0.79 |
9720f70466312089119e99102af790af88a28092 | 3,554 | c | C | cs392a/assignments/cachelab-02-handout/trans.c | joshgrib/2017S-coursework | 3c50d40997b4942bca8baa50f6aaec366229ee04 | [
"MIT"
] | null | null | null | cs392a/assignments/cachelab-02-handout/trans.c | joshgrib/2017S-coursework | 3c50d40997b4942bca8baa50f6aaec366229ee04 | [
"MIT"
] | null | null | null | cs392a/assignments/cachelab-02-handout/trans.c | joshgrib/2017S-coursework | 3c50d40997b4942bca8baa50f6aaec366229ee04 | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <getopt.h>
#include "omatrix.h"
#define MAX_ITER 16
static int g_matrix_n = 0,
g_block = 0,
g_parallel = 0,
g_iterations = 1;
/* Print usage information */
static void usage(const char *bin_name){
printf("Usage: %s [OPTIONS] <matrix dimension>\n", bin_name);
printf(" -h Print this message\n");
printf(" -b <size> Blocked transposition with block size\n");
printf(" -n <number> Run number of iterations"
" (Max: %d)\n", MAX_ITER);
printf(" -p Run in parallel\n");
}
/* Print elapsed time */
static void print_time_delta(const char *msg, const struct timespec *t2, const struct timespec *t1){
struct timespec delta;
delta.tv_sec = t2->tv_sec - t1->tv_sec;
delta.tv_nsec = t2->tv_nsec - t1->tv_nsec;
if (delta.tv_nsec < 0) {
delta.tv_sec--;;
delta.tv_nsec += 1000 * 1000 * 1000; /* 1 sec in ns */
}
printf("%s: \t%02lus %08ldns\n", msg, delta.tv_sec, delta.tv_nsec);
}
/* Parses command-line arguments and returns 0 on success or -1 on error */
static int parse_arguments(int argc, char **argv){
int c;
while ((c = getopt(argc, argv, "b:n:ph")) != -1) {
switch (c) {
case 'b':
g_block = atoi(optarg);
break;
case 'p':
g_parallel = 1;
break;
case 'n':
g_iterations = atoi(optarg);
break;
case 'h':
case '?':
return -1;
default:
abort();
}
}
if (optind >= argc) {
fprintf(stderr, "Missing argument\n");
return -1;
}
g_matrix_n = atoi(argv[optind]);
if (g_matrix_n <= 0) {
fprintf(stderr, "Matrix dimension needs to be "
"a positive number\n");
return -1;
}
if (g_block < 0) {
fprintf(stderr, "Block size needs to be a positive number\n");
return -1;
} else if (g_block > 0) {
/* Needs to be a power of two */
if ((g_block & (g_block - 1)) != 0) {
fprintf(stderr, "Block size needs to be a power of 2\n");
return -1;
}
/* Matrix x & y must be a multiple of the block size */
if ((g_matrix_n % g_block) != 0) {
fprintf(stderr, "Block needs to divide matrix dimension\n");
return -1;
}
}
if (!(g_iterations > 0 && g_iterations <= MAX_ITER)) {
fprintf(stderr, "Number of iterations need to be between 0 and %d\n", MAX_ITER);
return -1;
}
if (g_iterations == 1)
g_parallel = 0;
return 0;
}
static int do_job(void){
int r = 0;
omatrix_t m;
struct timespec t1, t2;
clock_gettime(CLOCK_MONOTONIC, &t1);
r = omatrix_create(&m, (unsigned int)g_matrix_n);
clock_gettime(CLOCK_MONOTONIC, &t2);
if (r != 0) {
perror("cannot create matrix");
return -1;
}
print_time_delta("Matrix creation", &t2, &t1);
if (g_block == 0)
g_block = g_matrix_n;
clock_gettime(CLOCK_MONOTONIC, &t1);
omatrix_transpose(&m, (unsigned int)g_block);
clock_gettime(CLOCK_MONOTONIC, &t2);
print_time_delta("Matrix trasposition", &t2, &t1);
r = omatrix_check(&m);
omatrix_destroy(&m);
if (r) {
printf("Transposition successful!\n");
return 0;
}
printf("Transposition failed!\n");
return -1;
}
int main(int argc, char **argv){
int r = EXIT_SUCCESS;
if (parse_arguments(argc, argv) != 0) {
usage(argv[0]);
return -1;
}
if (g_parallel) {
printf("Running in parallel!");
} else {
while (g_iterations-- > 0) {
if (do_job() != 0) {
r = EXIT_FAILURE;
break;
}
}
}
return r;
}
| 24.680556 | 100 | 0.589195 |
201d699da3cead3c5a7d3b2103b0e07222aae110 | 1,404 | h | C | igvc_perception/include/pointcloud_filter/actual_barrel_segmentation.h | pradumn203/igvc-software | cfe5ad5ae06199030544560af7e4ebf732cd3004 | [
"MIT"
] | 100 | 2015-01-28T23:53:27.000Z | 2022-01-27T05:31:36.000Z | igvc_perception/include/pointcloud_filter/actual_barrel_segmentation.h | pradumn203/igvc-software | cfe5ad5ae06199030544560af7e4ebf732cd3004 | [
"MIT"
] | 600 | 2015-01-11T20:27:06.000Z | 2022-02-20T21:53:01.000Z | igvc_perception/include/pointcloud_filter/actual_barrel_segmentation.h | RoboJackets/igvc-software | 997eb9ac8c5232c5a7ea82e29528199e216c451c | [
"MIT"
] | 157 | 2015-01-29T00:02:27.000Z | 2022-01-13T01:12:20.000Z | #ifndef SRC_ACTUAL_BARREL_SEGMENTATION_H
#define SRC_ACTUAL_BARREL_SEGMENTATION_H
#include <ros/ros.h>
#include <tf/transform_listener.h>
#include <pointcloud_filter/back_filter/back_filter.h>
#include <pointcloud_filter/ground_filter/ground_filter.h>
#include <pointcloud_filter/pointcloud_filter_config.h>
#include <pointcloud_filter/radius_filter/radius_filter.h>
#include <pointcloud_filter/raycast_filter/raycast_filter.h>
#include <pointcloud_filter/tf_transform_filter/tf_transform_filter.h>
namespace pointcloud_filter
{
class PointcloudFilter
{
public:
using PointCloud = pcl::PointCloud<velodyne_pcl::PointXYZIRT>;
PointcloudFilter(const ros::NodeHandle& nh = {}, const ros::NodeHandle& private_nh = { "~" });
private:
ros::NodeHandle nh_;
ros::NodeHandle private_nh_;
PointcloudFilterConfig config_;
tf2_ros::Buffer buffer_;
tf2_ros::TransformListener listener_;
BackFilter back_filter_;
RadiusFilter radius_filter_;
TFTransformFilter tf_transform_filter_;
GroundFilter ground_filter_;
RaycastFilter raycast_filter_;
ros::Subscriber raw_pointcloud_sub_;
ros::Publisher transformed_pointcloud_pub_;
ros::Publisher occupied_pointcloud_pub_;
ros::Publisher free_pointcloud_pub_;
void setupPubSub();
void pointcloudCallback(const PointCloud::ConstPtr& raw_pointcloud);
};
} // namespace pointcloud_filter
#endif // SRC_ACTUAL_BARREL_SEGMENTATION_H
| 28.653061 | 96 | 0.814815 |
f675376556ce8b7a3a431e34bab236aeb6949150 | 6,073 | h | C | usr/src/uts/intel/io/scsi/adapters/pvscsi/pvscsi_var.h | AsahiOS/gate | 283d47da4e17a5871d9d575e7ffb81e8f6c52e51 | [
"MIT"
] | null | null | null | usr/src/uts/intel/io/scsi/adapters/pvscsi/pvscsi_var.h | AsahiOS/gate | 283d47da4e17a5871d9d575e7ffb81e8f6c52e51 | [
"MIT"
] | null | null | null | usr/src/uts/intel/io/scsi/adapters/pvscsi/pvscsi_var.h | AsahiOS/gate | 283d47da4e17a5871d9d575e7ffb81e8f6c52e51 | [
"MIT"
] | 1 | 2020-12-30T00:04:16.000Z | 2020-12-30T00:04:16.000Z | /*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*/
/*
* Copyright 2016 Nexenta Systems, Inc.
*/
#ifndef _PVSCSI_VAR_H_
#define _PVSCSI_VAR_H_
typedef struct pvscsi_dma_buf {
ddi_dma_handle_t dma_handle;
caddr_t addr;
uint64_t pa;
size_t real_length;
ddi_acc_handle_t acc_handle;
} pvscsi_dma_buf_t;
#define PVSCSI_TGT_PRIV_SIZE 2
#define PVSCSI_FLAG_CDB_EXT 0x0001
#define PVSCSI_FLAG_SCB_EXT 0x0002
#define PVSCSI_FLAG_PRIV_EXT 0x0004
#define PVSCSI_FLAG_TAG 0x0008
#define PVSCSI_FLAG_IO_READ 0x0010
#define PVSCSI_FLAG_IO_IOPB 0x0040
#define PVSCSI_FLAG_DONE 0x0080
#define PVSCSI_FLAG_DMA_VALID 0x0100
#define PVSCSI_FLAG_XARQ 0x0200
#define PVSCSI_FLAG_HW_STATUS 0x0400
#define PVSCSI_FLAG_TIMED_OUT 0x0800
#define PVSCSI_FLAG_ABORTED 0x1000
#define PVSCSI_FLAG_RESET_BUS 0x2000
#define PVSCSI_FLAG_RESET_DEV 0x4000
#define PVSCSI_FLAG_TRANSPORT 0x8000
/* Flags that must remain during SCSI packet retransmission */
#define PVSCSI_FLAGS_PERSISTENT \
(PVSCSI_FLAG_CDB_EXT |\
PVSCSI_FLAG_SCB_EXT |\
PVSCSI_FLAG_PRIV_EXT |\
PVSCSI_FLAG_TAG |\
PVSCSI_FLAG_IO_READ |\
PVSCSI_FLAG_IO_IOPB |\
PVSCSI_FLAG_DMA_VALID |\
PVSCSI_FLAG_XARQ)
#define PVSCSI_FLAGS_RESET \
(PVSCSI_FLAG_RESET_BUS |\
PVSCSI_FLAG_RESET_DEV)
#define PVSCSI_FLAGS_NON_HW_COMPLETION \
(PVSCSI_FLAG_TIMED_OUT |\
PVSCSI_FLAG_ABORTED |\
PVSCSI_FLAGS_RESET)
#define PVSCSI_FLAGS_COMPLETION \
(PVSCSI_FLAG_HW_STATUS |\
PVSCSI_FLAGS_NON_HW_COMPLETION)
#define PVSCSI_FLAGS_EXT \
(PVSCSI_FLAG_CDB_EXT |\
PVSCSI_FLAG_SCB_EXT |\
PVSCSI_FLAG_PRIV_EXT)
typedef struct pvscsi_cmd_ctx {
pvscsi_dma_buf_t dma_buf;
struct pvscsi_cmd *cmd;
list_node_t list;
} pvscsi_cmd_ctx_t;
typedef struct pvscsi_cmp_desc_stat {
uchar_t scsi_status;
uint32_t host_status;
uint64_t data_len;
} pvscsi_cmp_desc_stat_t;
#define PVSCSI_MAX_IO_PAGES 256
#define PVSCSI_MAX_IO_SIZE (PVSCSI_MAX_IO_PAGES * PAGE_SIZE)
#define PVSCSI_MAX_SG_SIZE (PVSCSI_MAX_IO_PAGES + 1)
typedef struct pvscsi_cmd {
struct scsi_pkt *pkt;
uint8_t cmd_cdb[SCSI_CDB_SIZE];
struct scsi_arq_status cmd_scb;
uint64_t tgt_priv[PVSCSI_TGT_PRIV_SIZE];
size_t tgtlen;
size_t cmdlen;
size_t statuslen;
uint8_t tag;
int flags;
ulong_t dma_count;
pvscsi_cmp_desc_stat_t cmp_stat;
pvscsi_cmd_ctx_t *ctx;
ddi_dma_handle_t cmd_dmahdl;
ddi_dma_cookie_t cmd_dmac;
uint_t cmd_dmaccount;
uint_t cmd_winindex;
uint_t cmd_nwin;
off_t cmd_dma_offset;
size_t cmd_dma_len;
uint_t cmd_dma_count;
uint_t cmd_total_dma_count;
int cmd_target;
list_node_t cmd_queue_node;
clock_t timeout_lbolt;
struct pvscsi_softc *cmd_pvs;
struct pvscsi_cmd *next_cmd;
struct pvscsi_cmd *tail_cmd;
struct buf *arqbuf;
ddi_dma_cookie_t arqc;
ddi_dma_handle_t arqhdl;
int cmd_rqslen;
struct scsi_pkt cached_pkt;
ddi_dma_cookie_t cached_cookies[PVSCSI_MAX_SG_SIZE];
} pvscsi_cmd_t;
#define AP2PRIV(ap) ((ap)->a_hba_tran->tran_hba_private)
#define CMD2PKT(cmd) ((struct scsi_pkt *)((cmd)->pkt))
#define PKT2CMD(pkt) ((pvscsi_cmd_t *)((pkt)->pkt_ha_private))
#define SDEV2PRIV(sd) ((sd)->sd_address.a_hba_tran->tran_hba_private)
#define TRAN2PRIV(tran) ((pvscsi_softc_t *)(tran)->tran_hba_private)
#define CMD_CTX_SGLIST_VA(cmd_ctx) \
((struct PVSCSISGElement *) \
(((pvscsi_cmd_ctx_t *)(cmd_ctx))->dma_buf.addr))
#define CMD_CTX_SGLIST_PA(cmd_ctx) \
((((pvscsi_cmd_ctx_t *)(cmd_ctx))->dma_buf.pa))
typedef struct pvscsi_msg {
struct pvscsi_softc *msg_pvs;
int type;
int target;
} pvscsi_msg_t;
/* Driver-wide flags */
#define PVSCSI_DRIVER_SHUTDOWN 0x01
#define PVSCSI_HBA_QUIESCED 0x02
#define PVSCSI_HBA_QUIESCE_PENDING 0x04
#define PVSCSI_HBA_AUTO_REQUEST_SENSE 0x08
#define HBA_IS_QUIESCED(pvs) (((pvs)->flags & PVSCSI_HBA_QUIESCED) != 0)
#define HBA_QUIESCE_PENDING(pvs) \
(((pvs)->flags & PVSCSI_HBA_QUIESCE_PENDING) != 0 && \
((pvs)->cmd_queue_len == 0))
typedef struct pvscsi_softc {
dev_info_t *dip;
int instance;
scsi_hba_tran_t *tran;
ddi_dma_attr_t hba_dma_attr;
ddi_dma_attr_t io_dma_attr;
ddi_dma_attr_t ring_dma_attr;
pvscsi_dma_buf_t rings_state_buf;
pvscsi_dma_buf_t req_ring_buf;
uint_t req_pages;
uint_t req_depth;
pvscsi_dma_buf_t cmp_ring_buf;
uint_t cmp_pages;
pvscsi_dma_buf_t msg_ring_buf;
uint_t msg_pages;
ddi_acc_handle_t pci_config_handle;
ddi_acc_handle_t mmio_handle;
caddr_t mmio_base;
int intr_type;
int intr_size;
int intr_cnt;
int intr_pri;
int flags;
ddi_intr_handle_t *intr_htable;
pvscsi_cmd_ctx_t *cmd_ctx;
list_t cmd_ctx_pool;
list_t cmd_queue;
int cmd_queue_len;
kcondvar_t wd_condvar;
kmutex_t mutex;
kmutex_t rx_mutex;
kmutex_t tx_mutex;
kmutex_t intr_mutex;
struct kmem_cache *cmd_cache;
list_t devnodes;
kcondvar_t syncvar;
kcondvar_t quiescevar;
kthread_t *wd_thread;
int intr_lock_counter;
int num_pollers;
ddi_taskq_t *comp_tq;
ddi_taskq_t *msg_tq;
} pvscsi_softc_t;
typedef struct pvscsi_device {
list_node_t list;
int target;
dev_info_t *pdip;
dev_info_t *parent;
} pvscsi_device_t;
#define REQ_RING(pvs) \
((struct PVSCSIRingReqDesc *) \
(((pvscsi_softc_t *)(pvs))->req_ring_buf.addr))
#define CMP_RING(pvs) \
((struct PVSCSIRingCmpDesc *) \
(((pvscsi_softc_t *)(pvs))->cmp_ring_buf.addr))
#define MSG_RING(pvs) \
((struct PVSCSIRingMsgDesc *) \
(((pvscsi_softc_t *)(pvs))->msg_ring_buf.addr))
#define RINGS_STATE(pvs) \
((struct PVSCSIRingsState *)(((pvscsi_softc_t *)\
(pvs))->rings_state_buf.addr))
#define PVSCSI_INITIAL_SSTATE_ITEMS 16
#define SENSE_BUFFER_SIZE SENSE_LENGTH
#define USECS_TO_WAIT 1000
#define PVSCSI_MAXTGTS 16
#define PAGE_SIZE 4096
#define PAGE_SHIFT 12
#define PVSCSI_DEFAULT_NUM_PAGES_PER_RING 8
#define PVSCSI_DEFAULT_NUM_PAGES_MSG_RING 1
#endif /* _PVSCSI_VAR_H_ */
| 25.624473 | 72 | 0.788078 |
6b21eafc671943c6505667c0a4e0f6a4dd340fd7 | 622 | h | C | Protocol/OptionGroupParser.h | muddledmanaged/Protocol | a15892958d02a644cbc9eb274db1e0a03a6bb1e9 | [
"MIT"
] | 1 | 2015-04-28T14:23:27.000Z | 2015-04-28T14:23:27.000Z | Protocol/OptionGroupParser.h | muddledmanaged/Protocol | a15892958d02a644cbc9eb274db1e0a03a6bb1e9 | [
"MIT"
] | null | null | null | Protocol/OptionGroupParser.h | muddledmanaged/Protocol | a15892958d02a644cbc9eb274db1e0a03a6bb1e9 | [
"MIT"
] | null | null | null | //
// OptionGroupParser.h
// Protocol
//
// Created by Wahid Tanner on 10/10/14.
//
#ifndef Protocol_OptionGroupParser_h
#define Protocol_OptionGroupParser_h
#include "ParserInterface.h"
namespace MuddledManaged
{
namespace Protocol
{
class OptionGroupParser : public ParserInterface
{
public:
OptionGroupParser ();
virtual bool parse (TokenReader::iterator current, TokenReader::iterator end, bool firstChance, std::shared_ptr<ProtoModel> model);
};
} // namespace Protocol
} // namespace MuddledManaged
#endif // Protocol_OptionGroupParser_h
| 20.733333 | 143 | 0.692926 |
490241ff0108916092a53ba4db1bb36014a4ee0c | 649 | h | C | FlyingCrane3D/MeshElementFace.h | reclue/FlyingCrane3D | 6d5aa1cc146a9afb31230f296165d0b898eedf9a | [
"MIT"
] | 2 | 2020-04-25T16:43:34.000Z | 2020-07-22T09:40:33.000Z | FlyingCrane3D/MeshElementFace.h | insoLLLent/FlyingCrane3D | 6d5aa1cc146a9afb31230f296165d0b898eedf9a | [
"MIT"
] | null | null | null | FlyingCrane3D/MeshElementFace.h | insoLLLent/FlyingCrane3D | 6d5aa1cc146a9afb31230f296165d0b898eedf9a | [
"MIT"
] | null | null | null | #pragma once
#include "MeshElement.h"
#include "Vertex.h"
#include "Face.h"
class MeshElementFace final : public MeshElement {
public:
static const GLenum DEFAULT_MESH_TYPE;
private:
std::vector<Vertex> markPoints {};
GLuint vaoMark, vboMark;
void updateMarkList();
void initMark();
void drawMark();
void freeMark();
public:
MeshElementFace() = delete;
MeshElementFace(Face& _face);
MeshElementFace(Vertex& first, Vertex& second, Vertex& third);
virtual ~MeshElementFace() = default;
virtual void updateBufferedVertices() override;
virtual void init() override;
virtual void draw() override;
virtual void free() override;
};
| 19.088235 | 63 | 0.742681 |
7b4e67dd9113936ae2cd5e490f59bd6b16a0d950 | 681 | h | C | sdks/ht_ios/HTSDK.framework/Headers/HTIAPManager.h | l1fan/GameAne | 2778f5daecdb92b1b51d5b3ccfd0e79639dd7796 | [
"MIT"
] | 13 | 2015-10-28T07:39:41.000Z | 2020-05-28T11:22:11.000Z | sdks/ht_ios/HTSDK.framework/Headers/HTIAPManager.h | game-platform-awaresome/GameAne | 2778f5daecdb92b1b51d5b3ccfd0e79639dd7796 | [
"MIT"
] | null | null | null | sdks/ht_ios/HTSDK.framework/Headers/HTIAPManager.h | game-platform-awaresome/GameAne | 2778f5daecdb92b1b51d5b3ccfd0e79639dd7796 | [
"MIT"
] | 10 | 2015-10-28T09:42:21.000Z | 2021-05-12T11:53:51.000Z | //
// HTIAPManager.h
// 正式内购开整
//
// Created by 王璟鑫 on 16/5/20.
// Copyright © 2016年 王璟鑫. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <StoreKit/StoreKit.h>
@interface HTIAPManager : NSObject
@property (nonatomic, retain) SKProductsRequest *productRequest;
@property(nonatomic,strong)NSString*extra;
@property(nonatomic,copy)void(^IAPBlock)(NSString*status);
+(instancetype)defaultManager;
/**
* IAP支付
*
* @param productId 传入商品ID
*/
- (void)requestProductWithId:(NSString *)productId;
//新接口
//- (void)requestProductWithId:(NSString *)productId withblock:(void(^)(NSString *str))block;
/**
* 与服务器连接失败重连的定时器
*/
-(void)createTimer;
@end
| 16.609756 | 93 | 0.712188 |
7366b59026105c1e36badd4b8722675dd0f14346 | 2,992 | h | C | Classes/CurrencyManager.h | sirnacnud/AppSales-Mobile | de84a5f2c8001b8f397c74cab532a6a97a4a0b6e | [
"BSD-2-Clause",
"Unlicense"
] | 43 | 2015-12-20T00:18:08.000Z | 2019-07-14T18:17:50.000Z | Classes/CurrencyManager.h | sirnacnud/AppSales-Mobile | de84a5f2c8001b8f397c74cab532a6a97a4a0b6e | [
"BSD-2-Clause",
"Unlicense"
] | 52 | 2015-12-22T17:26:31.000Z | 2021-07-22T06:33:12.000Z | Classes/CurrencyManager.h | sirnacnud/AppSales-Mobile | de84a5f2c8001b8f397c74cab532a6a97a4a0b6e | [
"BSD-2-Clause",
"Unlicense"
] | 14 | 2016-01-12T03:26:33.000Z | 2020-10-10T08:35:26.000Z | /*
CurrencyManager.h
AppSalesMobile
* Copyright (c) 2008, omz:software
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> 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 omz:software ''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 <copyright holder> 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.
*/
#define CurrencyManagerDidUpdateNotification @"CurrencyManagerDidUpdate"
#define CurrencyManagerErrorNotification @"CurrencyManagerError"
#define CurrencyManagerDidChangeBaseCurrencyNotification @"CurrencyManagerDidChangeBaseCurrency"
@interface CurrencyManager : NSObject {
NSString *baseCurrency;
NSMutableDictionary *exchangeRates;
NSDate *lastRefresh;
BOOL isRefreshing;
NSArray *availableCurrencies;
NSDictionary *currencySymbols;
NSMutableDictionary *conversionDict;
NSNumberFormatter *numberFormatterWithFraction;
NSNumberFormatter *numberFormatterWithoutFraction;
}
@property (strong) NSString *baseCurrency;
@property (nonatomic, strong) NSDate *lastRefresh;
@property (strong) NSMutableDictionary *exchangeRates;
@property (strong) NSArray *availableCurrencies;
@property (strong) NSMutableDictionary *conversionDict;
+ (CurrencyManager *)sharedManager;
- (NSString *)baseCurrencyDescription;
- (NSString *)currencySymbolForCurrency:(NSString *)currencyCode;
- (NSString *)baseCurrencyDescriptionForAmount:(NSString *)amount;
- (NSString *)baseCurrencyDescriptionForAmount:(NSNumber *)amount withFraction:(BOOL)withFraction;
- (void)forceRefresh;
- (void)refreshIfNeeded;
- (void)refreshExchangeRates;
- (void)refreshFailed;
- (void)finishRefreshWithExchangeRates:(NSMutableDictionary *)newExchangeRates;
- (float)convertValue:(float)sourceValue fromCurrency:(NSString *)sourceCurrency;
@end
| 44 | 98 | 0.793449 |
0b2384cc99fdb17180cabe8b6631ebd3693f686a | 167 | h | C | release/src-rt/linux/linux-2.6/include/asm-um/calling.h | ghsecuritylab/tomato_egg | 50473a46347f4631eb4878a0f47955cc64c87293 | [
"FSFAP"
] | 278 | 2015-11-03T03:01:20.000Z | 2022-01-20T18:21:05.000Z | release/src-rt/linux/linux-2.6/include/asm-um/calling.h | ghsecuritylab/tomato_egg | 50473a46347f4631eb4878a0f47955cc64c87293 | [
"FSFAP"
] | 374 | 2015-11-03T12:37:22.000Z | 2021-12-17T14:18:08.000Z | include/asm-um/calling.h | KylinskyChen/linuxCore_2.6.24 | 11e90b14386491cc80477d4015e0c8f673f6d020 | [
"MIT"
] | 96 | 2015-11-22T07:47:26.000Z | 2022-01-20T19:52:19.000Z | # Copyright 2003 - 2004 Pathscale, Inc
# Released under the GPL
#ifndef __UM_CALLING_H /* XXX x86_64 */
#define __UM_CALLING_H
#include "asm/arch/calling.h"
#endif
| 16.7 | 39 | 0.742515 |
293ccc75a687567d3aa606a07020ffcc17b6533a | 317 | c | C | gcc-gcc-7_3_0-release/gcc/testsuite/gcc.dg/anon-struct-14.c | best08618/asylo | 5a520a9f5c461ede0f32acc284017b737a43898c | [
"Apache-2.0"
] | 7 | 2020-05-02T17:34:05.000Z | 2021-10-17T10:15:18.000Z | gcc-gcc-7_3_0-release/gcc/testsuite/gcc.dg/anon-struct-14.c | best08618/asylo | 5a520a9f5c461ede0f32acc284017b737a43898c | [
"Apache-2.0"
] | null | null | null | gcc-gcc-7_3_0-release/gcc/testsuite/gcc.dg/anon-struct-14.c | best08618/asylo | 5a520a9f5c461ede0f32acc284017b737a43898c | [
"Apache-2.0"
] | 2 | 2020-07-27T00:22:36.000Z | 2021-04-01T09:41:02.000Z | /* { dg-do compile } */
/* { dg-options "-fplan9-extensions" } */
/* When using Plan 9 extensions, a typedef can conflict with an
anonymous field. */
typedef struct { int a; } s1;
struct s2 { s1; int s1; }; /* { dg-error "duplicate" } */
int f(struct s2 *p) { return p->s1; } /* { dg-error "incompatible" } */
| 31.7 | 71 | 0.599369 |
5533f6134f747af2b7d843a2329f00e80f6d8107 | 952 | h | C | PrivateFrameworks/WiFiVelocity.framework/W5SpeedTestResult.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | 36 | 2016-04-20T04:19:04.000Z | 2018-10-08T04:12:25.000Z | PrivateFrameworks/WiFiVelocity.framework/W5SpeedTestResult.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | null | null | null | PrivateFrameworks/WiFiVelocity.framework/W5SpeedTestResult.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | 10 | 2016-06-16T02:40:44.000Z | 2019-01-15T03:31:45.000Z | /* Generated by RuntimeBrowser
Image: /System/Library/PrivateFrameworks/WiFiVelocity.framework/WiFiVelocity
*/
@interface W5SpeedTestResult : NSObject <NSCopying, NSSecureCoding> {
long long _direction;
NSError * _error;
CLLocation * _location;
long long _size;
double _speed;
}
@property (nonatomic) long long direction;
@property (nonatomic, copy) NSError *error;
@property (nonatomic, copy) CLLocation *location;
@property (nonatomic) long long size;
@property (nonatomic) double speed;
+ (bool)supportsSecureCoding;
- (bool)conformsToProtocol:(id)arg1;
- (id)copyWithZone:(struct _NSZone { }*)arg1;
- (long long)direction;
- (void)encodeWithCoder:(id)arg1;
- (id)error;
- (id)initWithCoder:(id)arg1;
- (id)location;
- (void)setDirection:(long long)arg1;
- (void)setError:(id)arg1;
- (void)setLocation:(id)arg1;
- (void)setSize:(long long)arg1;
- (void)setSpeed:(double)arg1;
- (long long)size;
- (double)speed;
@end
| 25.72973 | 79 | 0.723739 |
19d22843bb5c365dedc7c79fd3a4d08798c3d34a | 442 | c | C | d/laerad/mon/obj/ubhorns.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-07-19T05:24:44.000Z | 2021-11-18T04:08:19.000Z | d/laerad/mon/obj/ubhorns.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 4 | 2021-03-15T18:56:39.000Z | 2021-08-17T17:08:22.000Z | d/laerad/mon/obj/ubhorns.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-09-12T06:22:38.000Z | 2022-01-31T01:15:12.000Z | //Coded by the one and only master of monsters...BANE//
#include <std.h>
inherit WEAPON;
void create(){
::create();
set_id(({"horn"}));
set_name("Undead Beast's horn");
set_short("Undead Beast's horn");
set_long("A nasty pair of horns from an Undead Beast.");
set_weight(15);
set_size(2);
set("value",1);
set_wc(3,8);
set_large_wc(3,8);
set_type("piercing");
set_property("monsterweapon",1);
}
| 24.555556 | 60 | 0.622172 |
e8bb89d7010eac06369450cc03ed867d6689a78f | 805 | h | C | src/problems/path-sum.h | Jeswang/leetcode-xcode | 150d8aeaaff25ebe8cd1b257cfe8d7fc87a0391a | [
"MIT"
] | null | null | null | src/problems/path-sum.h | Jeswang/leetcode-xcode | 150d8aeaaff25ebe8cd1b257cfe8d7fc87a0391a | [
"MIT"
] | null | null | null | src/problems/path-sum.h | Jeswang/leetcode-xcode | 150d8aeaaff25ebe8cd1b257cfe8d7fc87a0391a | [
"MIT"
] | 1 | 2021-07-21T09:12:33.000Z | 2021-07-21T09:12:33.000Z | //
// path-sum.h
//
// Created by jeswang 27/06/2014.
//
/*
Description:
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.
For example:
Given the below binary tree and sum = 22,
5
/ \
4 8
/ / \
11 13 4
/ \ \
7 2 1
return true, as there exist a root-to-leaf path 5->4->11->2 which sum is 22.
*/
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
bool hasPathSum(TreeNode *root, int sum) {
}
}; | 19.634146 | 149 | 0.518012 |
057f9eb17d55e67ce86a13249234a4f37ed630f1 | 391 | c | C | OpenMPOfficialExamples/Tests/Example_lastprivate.2.c | passlab/rexomptest | 558e084877c70b1d883dccecfd8058986350155c | [
"BSD-2-Clause"
] | null | null | null | OpenMPOfficialExamples/Tests/Example_lastprivate.2.c | passlab/rexomptest | 558e084877c70b1d883dccecfd8058986350155c | [
"BSD-2-Clause"
] | null | null | null | OpenMPOfficialExamples/Tests/Example_lastprivate.2.c | passlab/rexomptest | 558e084877c70b1d883dccecfd8058986350155c | [
"BSD-2-Clause"
] | null | null | null | /*
* @@name: lastprivate.2c
* @@type: C
* @@compilable: yes
* @@linkable: no
* @@expect: success
* @@version: omp_5.0
*/
#include <math.h>
float condlastprivate(float *a, int n)
{
float x = 0.0f;
#pragma omp parallel for simd lastprivate(conditional: x)
for (int k = 0; k < n; k++) {
if (a[k] < 108.5 || a[k] > 208.5) {
x = sinf(a[k]);
}
}
return x;
}
| 16.291667 | 60 | 0.531969 |
95859a3d5417a47e4bdede2c25adc0c7292e284b | 14,347 | h | C | libs/mavlink/include/mavlink/v2.0/development/mavlink_msg_wifi_network_info.h | JinRIIS/Custom-QGC | b08876453a90ddf1d8778c4f49bcbe68021bd09d | [
"Apache-2.0"
] | null | null | null | libs/mavlink/include/mavlink/v2.0/development/mavlink_msg_wifi_network_info.h | JinRIIS/Custom-QGC | b08876453a90ddf1d8778c4f49bcbe68021bd09d | [
"Apache-2.0"
] | null | null | null | libs/mavlink/include/mavlink/v2.0/development/mavlink_msg_wifi_network_info.h | JinRIIS/Custom-QGC | b08876453a90ddf1d8778c4f49bcbe68021bd09d | [
"Apache-2.0"
] | null | null | null | #pragma once
// MESSAGE WIFI_NETWORK_INFO PACKING
#define MAVLINK_MSG_ID_WIFI_NETWORK_INFO 298
typedef struct __mavlink_wifi_network_info_t {
uint16_t data_rate; /*< [MiB/s] WiFi network data rate. Set to UINT16_MAX if data_rate information is not supplied.*/
char ssid[32]; /*< Name of Wi-Fi network (SSID).*/
uint8_t channel_id; /*< WiFi network operating channel ID. Set to 0 if unknown or unidentified.*/
uint8_t signal_quality; /*< [%] WiFi network signal quality.*/
uint8_t security; /*< WiFi network security type.*/
} mavlink_wifi_network_info_t;
#define MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN 37
#define MAVLINK_MSG_ID_WIFI_NETWORK_INFO_MIN_LEN 37
#define MAVLINK_MSG_ID_298_LEN 37
#define MAVLINK_MSG_ID_298_MIN_LEN 37
#define MAVLINK_MSG_ID_WIFI_NETWORK_INFO_CRC 237
#define MAVLINK_MSG_ID_298_CRC 237
#define MAVLINK_MSG_WIFI_NETWORK_INFO_FIELD_SSID_LEN 32
#if MAVLINK_COMMAND_24BIT
#define MAVLINK_MESSAGE_INFO_WIFI_NETWORK_INFO { \
298, \
"WIFI_NETWORK_INFO", \
5, \
{ { "ssid", NULL, MAVLINK_TYPE_CHAR, 32, 2, offsetof(mavlink_wifi_network_info_t, ssid) }, \
{ "channel_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 34, offsetof(mavlink_wifi_network_info_t, channel_id) }, \
{ "signal_quality", NULL, MAVLINK_TYPE_UINT8_T, 0, 35, offsetof(mavlink_wifi_network_info_t, signal_quality) }, \
{ "data_rate", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_wifi_network_info_t, data_rate) }, \
{ "security", NULL, MAVLINK_TYPE_UINT8_T, 0, 36, offsetof(mavlink_wifi_network_info_t, security) }, \
} \
}
#else
#define MAVLINK_MESSAGE_INFO_WIFI_NETWORK_INFO { \
"WIFI_NETWORK_INFO", \
5, \
{ { "ssid", NULL, MAVLINK_TYPE_CHAR, 32, 2, offsetof(mavlink_wifi_network_info_t, ssid) }, \
{ "channel_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 34, offsetof(mavlink_wifi_network_info_t, channel_id) }, \
{ "signal_quality", NULL, MAVLINK_TYPE_UINT8_T, 0, 35, offsetof(mavlink_wifi_network_info_t, signal_quality) }, \
{ "data_rate", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_wifi_network_info_t, data_rate) }, \
{ "security", NULL, MAVLINK_TYPE_UINT8_T, 0, 36, offsetof(mavlink_wifi_network_info_t, security) }, \
} \
}
#endif
/**
* @brief Pack a wifi_network_info message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
*
* @param ssid Name of Wi-Fi network (SSID).
* @param channel_id WiFi network operating channel ID. Set to 0 if unknown or unidentified.
* @param signal_quality [%] WiFi network signal quality.
* @param data_rate [MiB/s] WiFi network data rate. Set to UINT16_MAX if data_rate information is not supplied.
* @param security WiFi network security type.
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_wifi_network_info_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
const char *ssid, uint8_t channel_id, uint8_t signal_quality, uint16_t data_rate, uint8_t security)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
char buf[MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN];
_mav_put_uint16_t(buf, 0, data_rate);
_mav_put_uint8_t(buf, 34, channel_id);
_mav_put_uint8_t(buf, 35, signal_quality);
_mav_put_uint8_t(buf, 36, security);
_mav_put_char_array(buf, 2, ssid, 32);
memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN);
#else
mavlink_wifi_network_info_t packet;
packet.data_rate = data_rate;
packet.channel_id = channel_id;
packet.signal_quality = signal_quality;
packet.security = security;
mav_array_memcpy(packet.ssid, ssid, sizeof(char)*32);
memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN);
#endif
msg->msgid = MAVLINK_MSG_ID_WIFI_NETWORK_INFO;
return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_MIN_LEN, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_CRC);
}
/**
* @brief Pack a wifi_network_info message on a channel
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param chan The MAVLink channel this message will be sent over
* @param msg The MAVLink message to compress the data into
* @param ssid Name of Wi-Fi network (SSID).
* @param channel_id WiFi network operating channel ID. Set to 0 if unknown or unidentified.
* @param signal_quality [%] WiFi network signal quality.
* @param data_rate [MiB/s] WiFi network data rate. Set to UINT16_MAX if data_rate information is not supplied.
* @param security WiFi network security type.
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_wifi_network_info_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
mavlink_message_t* msg,
const char *ssid,uint8_t channel_id,uint8_t signal_quality,uint16_t data_rate,uint8_t security)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
char buf[MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN];
_mav_put_uint16_t(buf, 0, data_rate);
_mav_put_uint8_t(buf, 34, channel_id);
_mav_put_uint8_t(buf, 35, signal_quality);
_mav_put_uint8_t(buf, 36, security);
_mav_put_char_array(buf, 2, ssid, 32);
memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN);
#else
mavlink_wifi_network_info_t packet;
packet.data_rate = data_rate;
packet.channel_id = channel_id;
packet.signal_quality = signal_quality;
packet.security = security;
mav_array_memcpy(packet.ssid, ssid, sizeof(char)*32);
memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN);
#endif
msg->msgid = MAVLINK_MSG_ID_WIFI_NETWORK_INFO;
return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_MIN_LEN, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_CRC);
}
/**
* @brief Encode a wifi_network_info struct
*
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
* @param wifi_network_info C-struct to read the message contents from
*/
static inline uint16_t mavlink_msg_wifi_network_info_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_wifi_network_info_t* wifi_network_info)
{
return mavlink_msg_wifi_network_info_pack(system_id, component_id, msg, wifi_network_info->ssid, wifi_network_info->channel_id, wifi_network_info->signal_quality, wifi_network_info->data_rate, wifi_network_info->security);
}
/**
* @brief Encode a wifi_network_info struct on a channel
*
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param chan The MAVLink channel this message will be sent over
* @param msg The MAVLink message to compress the data into
* @param wifi_network_info C-struct to read the message contents from
*/
static inline uint16_t mavlink_msg_wifi_network_info_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_wifi_network_info_t* wifi_network_info)
{
return mavlink_msg_wifi_network_info_pack_chan(system_id, component_id, chan, msg, wifi_network_info->ssid, wifi_network_info->channel_id, wifi_network_info->signal_quality, wifi_network_info->data_rate, wifi_network_info->security);
}
/**
* @brief Send a wifi_network_info message
* @param chan MAVLink channel to send the message
*
* @param ssid Name of Wi-Fi network (SSID).
* @param channel_id WiFi network operating channel ID. Set to 0 if unknown or unidentified.
* @param signal_quality [%] WiFi network signal quality.
* @param data_rate [MiB/s] WiFi network data rate. Set to UINT16_MAX if data_rate information is not supplied.
* @param security WiFi network security type.
*/
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
static inline void mavlink_msg_wifi_network_info_send(mavlink_channel_t chan, const char *ssid, uint8_t channel_id, uint8_t signal_quality, uint16_t data_rate, uint8_t security)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
char buf[MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN];
_mav_put_uint16_t(buf, 0, data_rate);
_mav_put_uint8_t(buf, 34, channel_id);
_mav_put_uint8_t(buf, 35, signal_quality);
_mav_put_uint8_t(buf, 36, security);
_mav_put_char_array(buf, 2, ssid, 32);
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_WIFI_NETWORK_INFO, buf, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_MIN_LEN, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_CRC);
#else
mavlink_wifi_network_info_t packet;
packet.data_rate = data_rate;
packet.channel_id = channel_id;
packet.signal_quality = signal_quality;
packet.security = security;
mav_array_memcpy(packet.ssid, ssid, sizeof(char)*32);
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_WIFI_NETWORK_INFO, (const char *)&packet, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_MIN_LEN, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_CRC);
#endif
}
/**
* @brief Send a wifi_network_info message
* @param chan MAVLink channel to send the message
* @param struct The MAVLink struct to serialize
*/
static inline void mavlink_msg_wifi_network_info_send_struct(mavlink_channel_t chan, const mavlink_wifi_network_info_t* wifi_network_info)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
mavlink_msg_wifi_network_info_send(chan, wifi_network_info->ssid, wifi_network_info->channel_id, wifi_network_info->signal_quality, wifi_network_info->data_rate, wifi_network_info->security);
#else
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_WIFI_NETWORK_INFO, (const char *)wifi_network_info, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_MIN_LEN, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_CRC);
#endif
}
#if MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN <= MAVLINK_MAX_PAYLOAD_LEN
/*
This varient of _send() can be used to save stack space by re-using
memory from the receive buffer. The caller provides a
mavlink_message_t which is the size of a full mavlink message. This
is usually the receive buffer for the channel, and allows a reply to an
incoming message with minimum stack space usage.
*/
static inline void mavlink_msg_wifi_network_info_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, const char *ssid, uint8_t channel_id, uint8_t signal_quality, uint16_t data_rate, uint8_t security)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
char *buf = (char *)msgbuf;
_mav_put_uint16_t(buf, 0, data_rate);
_mav_put_uint8_t(buf, 34, channel_id);
_mav_put_uint8_t(buf, 35, signal_quality);
_mav_put_uint8_t(buf, 36, security);
_mav_put_char_array(buf, 2, ssid, 32);
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_WIFI_NETWORK_INFO, buf, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_MIN_LEN, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_CRC);
#else
mavlink_wifi_network_info_t *packet = (mavlink_wifi_network_info_t *)msgbuf;
packet->data_rate = data_rate;
packet->channel_id = channel_id;
packet->signal_quality = signal_quality;
packet->security = security;
mav_array_memcpy(packet->ssid, ssid, sizeof(char)*32);
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_WIFI_NETWORK_INFO, (const char *)packet, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_MIN_LEN, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_CRC);
#endif
}
#endif
#endif
// MESSAGE WIFI_NETWORK_INFO UNPACKING
/**
* @brief Get field ssid from wifi_network_info message
*
* @return Name of Wi-Fi network (SSID).
*/
static inline uint16_t mavlink_msg_wifi_network_info_get_ssid(const mavlink_message_t* msg, char *ssid)
{
return _MAV_RETURN_char_array(msg, ssid, 32, 2);
}
/**
* @brief Get field channel_id from wifi_network_info message
*
* @return WiFi network operating channel ID. Set to 0 if unknown or unidentified.
*/
static inline uint8_t mavlink_msg_wifi_network_info_get_channel_id(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint8_t(msg, 34);
}
/**
* @brief Get field signal_quality from wifi_network_info message
*
* @return [%] WiFi network signal quality.
*/
static inline uint8_t mavlink_msg_wifi_network_info_get_signal_quality(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint8_t(msg, 35);
}
/**
* @brief Get field data_rate from wifi_network_info message
*
* @return [MiB/s] WiFi network data rate. Set to UINT16_MAX if data_rate information is not supplied.
*/
static inline uint16_t mavlink_msg_wifi_network_info_get_data_rate(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint16_t(msg, 0);
}
/**
* @brief Get field security from wifi_network_info message
*
* @return WiFi network security type.
*/
static inline uint8_t mavlink_msg_wifi_network_info_get_security(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint8_t(msg, 36);
}
/**
* @brief Decode a wifi_network_info message into a struct
*
* @param msg The message to decode
* @param wifi_network_info C-struct to decode the message contents into
*/
static inline void mavlink_msg_wifi_network_info_decode(const mavlink_message_t* msg, mavlink_wifi_network_info_t* wifi_network_info)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
wifi_network_info->data_rate = mavlink_msg_wifi_network_info_get_data_rate(msg);
mavlink_msg_wifi_network_info_get_ssid(msg, wifi_network_info->ssid);
wifi_network_info->channel_id = mavlink_msg_wifi_network_info_get_channel_id(msg);
wifi_network_info->signal_quality = mavlink_msg_wifi_network_info_get_signal_quality(msg);
wifi_network_info->security = mavlink_msg_wifi_network_info_get_security(msg);
#else
uint8_t len = msg->len < MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN? msg->len : MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN;
memset(wifi_network_info, 0, MAVLINK_MSG_ID_WIFI_NETWORK_INFO_LEN);
memcpy(wifi_network_info, _MAV_PAYLOAD(msg), len);
#endif
}
| 46.885621 | 237 | 0.779815 |
58cfc2c4985c4d236b04316f3d84436ea69a447a | 358 | h | C | src/urvirt-stub/seccomp-bpf.h | dramforever/umxc | b8e8326acd908b1ca1d6cd7ea0d58ab931677f7f | [
"MIT"
] | 9 | 2021-11-27T03:10:10.000Z | 2022-03-17T04:03:59.000Z | src/urvirt-stub/seccomp-bpf.h | dramforever/urvirt | b8e8326acd908b1ca1d6cd7ea0d58ab931677f7f | [
"MIT"
] | null | null | null | src/urvirt-stub/seccomp-bpf.h | dramforever/urvirt | b8e8326acd908b1ca1d6cd7ea0d58ab931677f7f | [
"MIT"
] | null | null | null | #pragma once
#include <stddef.h>
#include <stdint.h>
#include <linux/seccomp.h>
#include <linux/filter.h>
#include <linux/audit.h>
// Generate a Seccomp BPF filter that checks IP, and blocks all syscalls from
// address outside the half-open range [start_addr, end_addr)
size_t gen_addr_filter(size_t start_addr, size_t end_addr, struct sock_filter *out);
| 29.833333 | 84 | 0.768156 |
95d2158b9b1ac13bc4b49472d35af5fbc7716767 | 6,496 | c | C | uros_ws/firmware/build/include/test_msgs/srv/detail/empty__functions.c | artivis/micro_ros_raspberrypi_pico_sdk | 7ddbd005f90d3f841bd405314177018a34986d55 | [
"Apache-2.0"
] | 2 | 2021-08-11T15:22:24.000Z | 2021-11-25T19:07:52.000Z | lib/microros/test_msgs/srv/detail/empty__functions.c | masoudir/teensy41_uros_example_publisher_with_static_library | 983d0fe268c9340a58b69fba9747925e1c03cfa2 | [
"MIT"
] | null | null | null | lib/microros/test_msgs/srv/detail/empty__functions.c | masoudir/teensy41_uros_example_publisher_with_static_library | 983d0fe268c9340a58b69fba9747925e1c03cfa2 | [
"MIT"
] | null | null | null | // generated from rosidl_generator_c/resource/idl__functions.c.em
// with input from test_msgs:srv/Empty.idl
// generated code does not contain a copyright notice
#include "test_msgs/srv/detail/empty__functions.h"
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
bool
test_msgs__srv__Empty_Request__init(test_msgs__srv__Empty_Request * msg)
{
if (!msg) {
return false;
}
// structure_needs_at_least_one_member
return true;
}
void
test_msgs__srv__Empty_Request__fini(test_msgs__srv__Empty_Request * msg)
{
if (!msg) {
return;
}
// structure_needs_at_least_one_member
}
test_msgs__srv__Empty_Request *
test_msgs__srv__Empty_Request__create()
{
test_msgs__srv__Empty_Request * msg = (test_msgs__srv__Empty_Request *)malloc(sizeof(test_msgs__srv__Empty_Request));
if (!msg) {
return NULL;
}
memset(msg, 0, sizeof(test_msgs__srv__Empty_Request));
bool success = test_msgs__srv__Empty_Request__init(msg);
if (!success) {
free(msg);
return NULL;
}
return msg;
}
void
test_msgs__srv__Empty_Request__destroy(test_msgs__srv__Empty_Request * msg)
{
if (msg) {
test_msgs__srv__Empty_Request__fini(msg);
}
free(msg);
}
bool
test_msgs__srv__Empty_Request__Sequence__init(test_msgs__srv__Empty_Request__Sequence * array, size_t size)
{
if (!array) {
return false;
}
test_msgs__srv__Empty_Request * data = NULL;
if (size) {
data = (test_msgs__srv__Empty_Request *)calloc(size, sizeof(test_msgs__srv__Empty_Request));
if (!data) {
return false;
}
// initialize all array elements
size_t i;
for (i = 0; i < size; ++i) {
bool success = test_msgs__srv__Empty_Request__init(&data[i]);
if (!success) {
break;
}
}
if (i < size) {
// if initialization failed finalize the already initialized array elements
for (; i > 0; --i) {
test_msgs__srv__Empty_Request__fini(&data[i - 1]);
}
free(data);
return false;
}
}
array->data = data;
array->size = size;
array->capacity = size;
return true;
}
void
test_msgs__srv__Empty_Request__Sequence__fini(test_msgs__srv__Empty_Request__Sequence * array)
{
if (!array) {
return;
}
if (array->data) {
// ensure that data and capacity values are consistent
assert(array->capacity > 0);
// finalize all array elements
for (size_t i = 0; i < array->capacity; ++i) {
test_msgs__srv__Empty_Request__fini(&array->data[i]);
}
free(array->data);
array->data = NULL;
array->size = 0;
array->capacity = 0;
} else {
// ensure that data, size, and capacity values are consistent
assert(0 == array->size);
assert(0 == array->capacity);
}
}
test_msgs__srv__Empty_Request__Sequence *
test_msgs__srv__Empty_Request__Sequence__create(size_t size)
{
test_msgs__srv__Empty_Request__Sequence * array = (test_msgs__srv__Empty_Request__Sequence *)malloc(sizeof(test_msgs__srv__Empty_Request__Sequence));
if (!array) {
return NULL;
}
bool success = test_msgs__srv__Empty_Request__Sequence__init(array, size);
if (!success) {
free(array);
return NULL;
}
return array;
}
void
test_msgs__srv__Empty_Request__Sequence__destroy(test_msgs__srv__Empty_Request__Sequence * array)
{
if (array) {
test_msgs__srv__Empty_Request__Sequence__fini(array);
}
free(array);
}
bool
test_msgs__srv__Empty_Response__init(test_msgs__srv__Empty_Response * msg)
{
if (!msg) {
return false;
}
// structure_needs_at_least_one_member
return true;
}
void
test_msgs__srv__Empty_Response__fini(test_msgs__srv__Empty_Response * msg)
{
if (!msg) {
return;
}
// structure_needs_at_least_one_member
}
test_msgs__srv__Empty_Response *
test_msgs__srv__Empty_Response__create()
{
test_msgs__srv__Empty_Response * msg = (test_msgs__srv__Empty_Response *)malloc(sizeof(test_msgs__srv__Empty_Response));
if (!msg) {
return NULL;
}
memset(msg, 0, sizeof(test_msgs__srv__Empty_Response));
bool success = test_msgs__srv__Empty_Response__init(msg);
if (!success) {
free(msg);
return NULL;
}
return msg;
}
void
test_msgs__srv__Empty_Response__destroy(test_msgs__srv__Empty_Response * msg)
{
if (msg) {
test_msgs__srv__Empty_Response__fini(msg);
}
free(msg);
}
bool
test_msgs__srv__Empty_Response__Sequence__init(test_msgs__srv__Empty_Response__Sequence * array, size_t size)
{
if (!array) {
return false;
}
test_msgs__srv__Empty_Response * data = NULL;
if (size) {
data = (test_msgs__srv__Empty_Response *)calloc(size, sizeof(test_msgs__srv__Empty_Response));
if (!data) {
return false;
}
// initialize all array elements
size_t i;
for (i = 0; i < size; ++i) {
bool success = test_msgs__srv__Empty_Response__init(&data[i]);
if (!success) {
break;
}
}
if (i < size) {
// if initialization failed finalize the already initialized array elements
for (; i > 0; --i) {
test_msgs__srv__Empty_Response__fini(&data[i - 1]);
}
free(data);
return false;
}
}
array->data = data;
array->size = size;
array->capacity = size;
return true;
}
void
test_msgs__srv__Empty_Response__Sequence__fini(test_msgs__srv__Empty_Response__Sequence * array)
{
if (!array) {
return;
}
if (array->data) {
// ensure that data and capacity values are consistent
assert(array->capacity > 0);
// finalize all array elements
for (size_t i = 0; i < array->capacity; ++i) {
test_msgs__srv__Empty_Response__fini(&array->data[i]);
}
free(array->data);
array->data = NULL;
array->size = 0;
array->capacity = 0;
} else {
// ensure that data, size, and capacity values are consistent
assert(0 == array->size);
assert(0 == array->capacity);
}
}
test_msgs__srv__Empty_Response__Sequence *
test_msgs__srv__Empty_Response__Sequence__create(size_t size)
{
test_msgs__srv__Empty_Response__Sequence * array = (test_msgs__srv__Empty_Response__Sequence *)malloc(sizeof(test_msgs__srv__Empty_Response__Sequence));
if (!array) {
return NULL;
}
bool success = test_msgs__srv__Empty_Response__Sequence__init(array, size);
if (!success) {
free(array);
return NULL;
}
return array;
}
void
test_msgs__srv__Empty_Response__Sequence__destroy(test_msgs__srv__Empty_Response__Sequence * array)
{
if (array) {
test_msgs__srv__Empty_Response__Sequence__fini(array);
}
free(array);
}
| 24.329588 | 154 | 0.708744 |
d77dce1e7ed926b43de83de0c5be3a5c49b47dab | 3,380 | h | C | lutron.h | gutschke/automation | 1122d339731913c7010d5c7e4d04c30d9dfdfb70 | [
"MIT"
] | 1 | 2022-02-22T19:19:20.000Z | 2022-02-22T19:19:20.000Z | lutron.h | gutschke/automation | 1122d339731913c7010d5c7e4d04c30d9dfdfb70 | [
"MIT"
] | 1 | 2021-08-04T21:27:06.000Z | 2021-09-03T11:09:19.000Z | lutron.h | gutschke/automation | 1122d339731913c7010d5c7e4d04c30d9dfdfb70 | [
"MIT"
] | null | null | null | #pragma once
#include <sys/socket.h>
#include <functional>
#include <string>
#include <utility>
#include <vector>
#include "event.h"
class Lutron {
public:
Lutron(Event& event,
const std::string& gateway = "",
const std::string& username = "",
const std::string& passwd = "");
~Lutron();
Lutron& oninit(std::function<void (std::function<void ()> cb)> init) {
init_ = init; return *this; }
Lutron& oninput(std::function<void (const std::string& line)> input) {
input_ = input; return *this; }
Lutron& onclosed(std::function<void ()> closed) {
closed_ = closed; return *this; }
void command(const std::string& cmd,
std::function<void (const std::string& res)> cb = [](auto){},
std::function<void (void)> err = nullptr,
bool recurs = false);
void ping(std::function<void (void)> cb = nullptr) {
command("?SYSTEM,1", cb ? [=](auto) { cb(); }
: (std::function<void (const std::string&)>)nullptr); }
void closeSock();
bool getConnectedAddr(struct sockaddr& addr, socklen_t& len);
bool isConnected() { return isConnected_; }
bool commandPending() { return inCommand_; }
void initStillWorking();
private:
const char *PROMPT = "GNET> ";
const int KEEPALIVE = 5*1000;
const int TMO = 10*1000;
void checkDelayed(std::function<void ()> next = nullptr);
void waitForPrompt(const std::string& prompt,
std::function<void (void)> cb,
std::function<void (void)> err,
bool login = true,
std::string::size_type partial = 0);
void sendData(const std::string& data,
std::function<void (void)> cb,
std::function<void (void)> err,
const std::string& prompt = "GNET> ",
bool login = true);
void login(std::function<void (void)> cb,
std::function<void (void)> err);
void enterPassword(std::function<void (void)> cb,
std::function<void (void)> err);
void processLine(const std::string& line);
void readLine();
void pollIn(std::function<bool (pollfd *)> cb);
void advanceKeepAliveMonitor();
struct Command {
std::string cmd;
std::function<void (const std::string&)> cb;
std::function<void ()> err;
};
class Timeout {
public:
Timeout(Event& event) : event_(event), self_(0), handle_(0) { }
bool isArmed() { return !!handle_; }
unsigned next() { return self_ + 1; }
void set(unsigned tmo, std::function<void (void)> cb);
void clear();
unsigned push(std::function<void (void)> cb);
void pop(unsigned id = 0);
private:
Event& event_;
unsigned self_;
void *handle_;
std::vector<std::pair<unsigned, std::function<void (void)>>> finalizers_;
} timeout_;
Event& event_;
std::function<void (const std::string& line)> input_;
std::function<void (std::function<void ()> cb)> init_;
std::function<void (void)> closed_;
std::string gateway_, g_, username_, passwd_;
int sock_;
bool dontfinalize_;
bool isConnected_;
bool inCommand_;
bool inCallback_;
bool initIsBusy_;
bool atPrompt_;
std::string ahead_;
void *keepAlive_;
std::vector<Command> later_[2], pending_[2];
std::vector<std::function<void ()>> onPrompt_;
struct sockaddr_storage addr_;
socklen_t addrLen_ = 0;
};
| 31.886792 | 77 | 0.613314 |
01f4a9141c73db275f5bfcb4014fee6156047959 | 3,164 | h | C | mcucpp/filesystem/fat.h | evugar/Mcucpp | 202d98587e8b9584370a32c1bafa2c7315120c9e | [
"BSD-3-Clause"
] | 87 | 2015-03-16T19:09:09.000Z | 2022-03-19T19:48:49.000Z | mcucpp/filesystem/fat.h | evugar/Mcucpp | 202d98587e8b9584370a32c1bafa2c7315120c9e | [
"BSD-3-Clause"
] | 5 | 2015-04-19T11:02:35.000Z | 2021-04-21T05:29:22.000Z | mcucpp/filesystem/fat.h | evugar/Mcucpp | 202d98587e8b9584370a32c1bafa2c7315120c9e | [
"BSD-3-Clause"
] | 42 | 2015-02-11T16:29:35.000Z | 2022-03-12T11:48:08.000Z | #include <static_assert.h>
#include <filesystem/filesystem.h>
#include <filesystem/fscommon.h>
#include <block_device.h>
#include <binary_stream.h>
#include <memory_stream.h>
#include <filesystem/file.h>
#include <data_buffer.h>
namespace Mcucpp
{
namespace Fat
{
static const uint16_t BootSignatureOff = 510;
static const uint16_t BootSignatureVal = 0xaa55;
enum FileAttributes
{
ATTR_READ_ONLY = 0x01,
ATTR_HIDDEN = 0x02,
ATTR_SYSTEM = 0x04,
ATTR_VOLUME_ID = 0x08,
ATTR_DIRECTORY = 0x10,
ATTR_ARCHIVE = 0x20,
ATTR_LONG_NAME = 0x0f
};
enum
{
DIR_ENTRY_SIZE = 0x20,
EMPTY = 0x00,
DELETED = 0xe5
};
enum FatType
{
None = 0,
Fat12,
Fat16,
Fat32
};
struct FatInfo
{
FatInfo()
:sectorPerCluster(0),
numberofFATs(0),
bytesPerSector(0),
reservedSectorCount(0),
rootEntCnt(0),
rootDirSectors(0),
totalSectors(0),
hiddenSectors(0),
FATsize(0),
firstSector(0),
rootSector(0),
countofClusters(0),
firstDataSector(0),
dataSectors(0)
{}
uint8_t sectorPerCluster;
uint8_t numberofFATs;
uint16_t bytesPerSector;
uint16_t reservedSectorCount;
uint16_t rootEntCnt;
uint16_t rootDirSectors;
uint32_t totalSectors;
uint32_t hiddenSectors;
uint32_t FATsize;
uint32_t firstSector;
uint32_t rootSector;
uint32_t countofClusters;
uint32_t firstDataSector;
uint32_t dataSectors;
uint32_t eocMarker;
FatType type;
};
class FatFs : public Mcucpp::Fs::IFsDriver
{
FatInfo _fat;
Mcucpp::IBlockDevice &_device;
Fs::ErrorCode _lastError;
uint32_t _cachedSector;
enum {SectorSize = Fs::DefaultBlockSize, LfnNameChunkBytes = 26, LfnChunkSymbols = 13};
uint8_t *_sectorBuffer;
private:
uint32_t ClusterToSector(uint32_t cluster);
uint32_t SectorToClaster(uint32_t sector);
uint32_t ReadFat(uint32_t cluster, unsigned fatNum);
bool WriteFat(uint32_t cluster, uint32_t nextCluster);
MemoryStream ReadSector(uint32_t sector);
int ReadLfnEntry(BinaryStream<Fs::File> &reader, DataBuffer &lfnBuffer);
bool ReadDirEntry(BinaryStream<Fs::File> &reader, Fs::FileSystemEntry &entry, int lfnChecksum, DataBuffer &lfnBuffer);
public:
FatFs(Mcucpp::IBlockDevice &device);
virtual Fs::ErrorCode GetError();
virtual Fs::FsNode RootDirectory();
virtual bool ListDirectory(Fs::FsNode dir, Fs::DirectoryLister &directoryLister);
virtual uint32_t GetParameter(Fs::FsParams param);
virtual uint32_t GetBlocksPerNode(Fs::FsNode node);
virtual Fs::FsNode GetNextChunk(Fs::FsNode node);
virtual Fs::FsNode AllocNextChunk(Fs::FsNode parentNode);
virtual Fs::FsNode CreateNode(Fs::FsNode parentDir, Fs::FileAttributes attributes, uint8_t *nodeName);
virtual bool ReadBlock(Fs::FsNode node, uint8_t *buffer);
virtual bool WriteBlock(Fs::FsNode node, const uint8_t *buffer);
virtual bool EndOfFile(Fs::FsNode node);
virtual bool Mount();
virtual void Unmount();
};
}
}
| 27.513043 | 122 | 0.6811 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.