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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cb0cc52359ff576b4cf271a68acf6c3e5f411ad4 | 18,524 | c | C | Projeto/hca.c | MaxRoecker/HCA | 3b8957dc2a6ad9f5d98390627286f48a6787f235 | [
"MIT"
] | null | null | null | Projeto/hca.c | MaxRoecker/HCA | 3b8957dc2a6ad9f5d98390627286f48a6787f235 | [
"MIT"
] | null | null | null | Projeto/hca.c | MaxRoecker/HCA | 3b8957dc2a6ad9f5d98390627286f48a6787f235 | [
"MIT"
] | null | null | null | /***********************************************************
* Created: Ter 09 Ago 2011 21:05:59 BRT
*
* Author: Carla N. Lintzmayer, carla0negri@gmail.com
*
***********************************************************
*
* HCA [1999, , Galinier and Hao]
*
* Hybrid Coloring Algorithm.
* Utilizing GPX crossover.
*
***********************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <pthread.h>
#include <semaphore.h>
#include <bits/stdio.h>
#include "color.h"
#include "util.h"
#include "tabucol.h"
#include "hca.h"
/* ### */
extern gcp_solution_t *bufferCrossover[BUFFER_SIZE];
extern int indexBufferCrossover;
static gcp_solution_t *crossoverReturn;
pthread_t crossOverThread;
pthread_t tabucolThreads[BUFFER_SIZE];
pthread_t updatePopulationThread;
sem_t semFiller;
sem_t semEmptier;
sem_t semUpdater;
pthread_barrier_t barrier;
/* ### */
static gcp_solution_t **population;
static gcp_solution_t *best_solution;
static gcp_solution_t *offspring;
void hca_printbanner(void) {
fprintf(problem->fileout, "HCA\n");
fprintf(problem->fileout, "-------------------------------------------------\n");
fprintf(problem->fileout, "Using Parameters:\n");
fprintf(problem->fileout, " Population size..: %d\n", hca_info->sizeof_population);
fprintf(problem->fileout, " Max LS iter......: %d\n", hca_info->cyc_local_search);
fprintf(problem->fileout, " Max colors.......: %i\n", problem->max_colors);
fprintf(problem->fileout, " Seed.............: %i\n", hca_info->seed);
}
void hca_initialization(void) {
if (!(get_flag(problem->flags, FLAG_COLOR)))
problem->max_colors = problem->nof_vertices;
if (!(get_flag(problem->flags, FLAG_SEED)))
hca_info->seed = create_seed();
srand48(hca_info->seed);
}
void hca_show_solution(void) {
fprintf(problem->fileout, "Nof. crossovers realized: %d\n", hca_info->nof_cross);
fprintf(problem->fileout, "Diversity in the final population: %d\n", hca_info->diversity);
}
static void test_solution(gcp_solution_t* sol) {
int i, j, v;
for (i = 0; i < problem->max_colors; i++) {
for (j = 1; j <= sol->class_color[i][0]; j++) {
v = sol->class_color[i][j];
if (i != sol->color_of[v]) {
printf(" ERROR!! %d está na classe %d, mas cor de %d = %d \n", v + 1, i, v + 1, sol->color_of[v]);
}
}
}
}
static gcp_solution_t* create_indiv(void) {
gcp_solution_t *solution = init_solution();
int i, j, c, v, color, nc, v_max_degree;
int possible_color[problem->nof_vertices];
// int confl_vertices[problem->nof_vertices];
int neighbors_by_color[problem->nof_vertices][problem->max_colors + 1];
/* Initializing auxiliary arrays and choosing a vertex with a maximal degree
* to be the first one */
v_max_degree = 0;
for (i = 0; i < problem->nof_vertices; i++) {
possible_color[i] = 0;
solution->color_of[i] = -1;
// confl_vertices[i] = 0;
for (j = 0; j < problem->max_colors; j++) {
neighbors_by_color[i][j] = 0;
solution->class_color[j][i] = -1;
}
neighbors_by_color[i][problem->max_colors] = 0;
if (problem->degree[i] > problem->degree[v_max_degree]) {
v_max_degree = i;
}
}
for (j = 0; j < problem->max_colors; j++) {
solution->class_color[j][problem->nof_vertices] = -1;
solution->class_color[j][0] = 0;
}
v_max_degree = 0;
/* Color the chosen vertex with the first color (0) */
color = 0;
solution->color_of[v_max_degree] = color;
solution->class_color[color][0]++;
solution->class_color[color][solution->class_color[color][0]] = v_max_degree;
v = v_max_degree; /* the current vertex, last one that was colored */
nc = 1; /* number of colored vertices */
while (nc < problem->nof_vertices) {
/* Update degree of saturation and possible colors; choose vertex with
* maximal saturation degree */
for (i = 0; i < problem->nof_vertices; i++) {
if (problem->adj_matrix[v][i]) {
/* update degree of saturation: */
if (neighbors_by_color[i][color] == 0) {
neighbors_by_color[i][problem->max_colors]++;
}
/* now <i> has a neighbor colored with <color> */
neighbors_by_color[i][color]++;
if (solution->color_of[i] == -1) {
/* if <i> is not colored yet and <i> is neighbor of <v>,
* update possible color for <i>: among all the possible
* colors for a neighbor of <i>, chose the least one */
int changed = FALSE;
for (c = problem->max_colors; c >= 0; c--) {
if (neighbors_by_color[i][c] == 0) {
possible_color[i] = c;
changed = TRUE;
}
}
if (!changed) possible_color[i] = problem->max_colors;
}
}
}
v_max_degree = -1;
for (i = 0; i < problem->nof_vertices; i++) {
/* choose vertex with a maximal saturation degree: */
if (solution->color_of[i] == -1) {
if (v_max_degree == -1) v_max_degree = i;
else if (neighbors_by_color[i][problem->max_colors] >
neighbors_by_color[v_max_degree][problem->max_colors]) {
v_max_degree = i;
}
}
}
v = v_max_degree;
color = possible_color[v];
/* if no viable color is found for <v>, chose a random one.
* this means that a conflict is being generated. */
if (color == problem->max_colors) {
color = (int) RANDOM(problem->max_colors);
}
solution->color_of[v] = color;
solution->class_color[color][0]++;
solution->class_color[color][solution->class_color[color][0]] = v;
nc++;
}
solution->spent_time = current_usertime_secs();
solution->time_to_best = solution->spent_time;
test_solution(solution);
return solution;
}
static void create_population(void) {
int i;
population = malloc_(sizeof (gcp_solution_t*) * hca_info->sizeof_population);
best_solution->nof_confl_edges = INT_MAX;
for (i = 0; i < hca_info->sizeof_population; i++) {
population[i] = create_indiv();
population[i]->cycles_to_best = 0;
population[i]->nof_colors = problem->max_colors;
tabucol(population[i], hca_info->cyc_local_search, tabucol_info->tl_style);
population[i]->time_to_best = current_usertime_secs();
if (population[i]->nof_confl_edges < best_solution->nof_confl_edges) {
cpy_solution(population[i], best_solution);
}
}
}
static void choose_parents(int *p1, int *p2) {
(*p1) = (int) RANDOM(hca_info->sizeof_population);
(*p2) = (int) RANDOM(hca_info->sizeof_population);
while ((*p2) == (*p1)) {
(*p2) = (int) RANDOM(hca_info->sizeof_population);
}
}
static void crossover(int p1, int p2, int posBuffer) {
/*####*/
int color, parent, max, i, j, c, v, otherparent, p;
int class_colors[2][problem->max_colors][problem->nof_vertices + 1];
bufferCrossover[posBuffer]->nof_colors = problem->max_colors;
for (i = 0; i < problem->nof_vertices; i++) {
bufferCrossover[posBuffer]->color_of[i] = -1;
for (c = 0; c < problem->max_colors; c++) {
class_colors[0][c][i] = population[p1]->class_color[c][i];
class_colors[1][c][i] = population[p2]->class_color[c][i];
bufferCrossover[posBuffer]->class_color[c][i] = -1;
}
}
for (c = 0; c < problem->max_colors; c++) {
bufferCrossover[posBuffer]->class_color[c][0] = 0;
bufferCrossover[posBuffer]->class_color[c][problem->nof_vertices] = -1;
class_colors[0][c][problem->nof_vertices] =
population[p1]->class_color[c][problem->nof_vertices];
class_colors[1][c][problem->nof_vertices] =
population[p2]->class_color[c][problem->nof_vertices];
}
for (color = 0; color < problem->max_colors; color++) {
parent = (color % 2) ? 0 : 1; // 0 equals p1 and 1 equals p2
otherparent = (parent == 0) ? 1 : 0;
/* choose <max> such as C_max of <parent> is maximal */
max = 0;
for (i = 1; i < problem->max_colors; i++) {
if (class_colors[parent][i][0] > class_colors[parent][max][0]) {
max = i;
}
}
/* C_color gets C_max from <parent> */
for (i = 1; i <= class_colors[parent][max][0]; i++) {
v = class_colors[parent][max][i];
class_colors[parent][max][i] = -1;
bufferCrossover[posBuffer]->class_color[color][0]++;
bufferCrossover[posBuffer]->class_color[color][bufferCrossover[posBuffer]->class_color[color][0]] = v;
bufferCrossover[posBuffer]->color_of[v] = color;
/* Remove all vertices of <otherparent> */
p = (otherparent == 0) ? p1 : p2;
c = population[p]->color_of[v];
for (j = 1; j <= class_colors[otherparent][c][0]; j++) {
if (class_colors[otherparent][c][j] == v) {
class_colors[otherparent][c][j] =
class_colors[otherparent][c][class_colors[otherparent][c][0]];
class_colors[otherparent][c][class_colors[otherparent][c][0]] = -1;
class_colors[otherparent][c][0]--;
break;
}
}
}
/* Remove all vertices in C_color of <parent> */
class_colors[parent][max][0] = 0;
}
/* Assign randomly the vertices of V - (C_1 U ... U C_k) */
for (i = 0; i < problem->nof_vertices; i++) {
if (bufferCrossover[posBuffer]->color_of[i] == -1) {
c = (int) RANDOM(problem->max_colors);
bufferCrossover[posBuffer]->color_of[i] = c;
bufferCrossover[posBuffer]->class_color[c][0]++;
bufferCrossover[posBuffer]->class_color[c][bufferCrossover[posBuffer]->class_color[c][0]] = i;
}
}
test_solution(population[p1]);
test_solution(population[p2]);
test_solution(bufferCrossover[posBuffer]);
/*####*/
}
static int substitute_worst(int p1, int p2, gcp_solution_t* offspring) {/*{{{*/
if (population[p1]->nof_confl_edges > population[p2]->nof_confl_edges) {
cpy_solution(offspring, population[p1]);
return p1;
}
cpy_solution(offspring, population[p2]);
return p2;
}
static int distance(gcp_solution_t *ind1, gcp_solution_t *ind2) {/*{{{*/
int i, dist = 0;
for (i = 0; i < problem->nof_vertices; i++) {
if (ind1->color_of[i] != ind2->color_of[i]) {
dist++;
}
}
return dist;
}
static int calculate_diversity(void) {
int i, j;
double dist, diversity = 0;
for (i = 0; i < hca_info->sizeof_population; i++) {
dist = 0;
for (j = 0; j < hca_info->sizeof_population; j++) {
if (i != j) {
dist += distance(population[i], population[j]);
}
}
dist = (double) dist / (hca_info->sizeof_population - 1);
diversity += dist;
}
diversity = (double) diversity / hca_info->sizeof_population;
return diversity;
}
static int hca_terminate_conditions(gcp_solution_t *solution, int diversity) {
if (diversity < HCA_DEFAULT_DIVERSITY) {
solution->stop_criterion = STOP_ALG;
return TRUE;
} else if (best_solution->nof_confl_edges == 0) {
solution->stop_criterion = STOP_BEST;
return TRUE;
}
return FALSE;
}
/*###*/
int cross;
void *filler(void *threadId) {
long tid = (long) threadId;
int parent1, parent2;
sem_wait(&semFiller);
cross = 0;
while (1) {
if (indexBufferCrossover == BUFFER_SIZE) {
int i;
for (i = 0; i < BUFFER_SIZE; i++) {
sem_post(&semEmptier);
}
sem_wait(&semFiller);
} else {
choose_parents(&parent1, &parent2);
crossover(parent1, parent2, indexBufferCrossover);
indexBufferCrossover++;
cross++;
}
}
}
void *emptier(void *threadId) {
long int id = (long int) threadId;
int contador = 0;
sem_wait(&semEmptier);
while (1) {
test_solution(bufferCrossover[id]);
tabucol(bufferCrossover[id], hca_info->cyc_local_search, tabucol_info->tl_style);
pthread_barrier_wait(&barrier);
if (id == 0) {
sem_post(&semUpdater);
}
sem_wait(&semEmptier);
}
}
int findBestInBuffer() {
int posBest = 0;
int i;
for (i = 1; i < BUFFER_SIZE; i++) {
if (bufferCrossover[i]->nof_confl_vertices < bufferCrossover[posBest]->nof_confl_vertices) {
posBest = i;
}
}
return posBest;
}
int findWorstParent() {
int posWorst = 0;
int i;
for (i = 1; i < hca_info->sizeof_population; i++) {
if (population[i]->nof_confl_vertices > population[posWorst]->nof_confl_vertices) {
posWorst = i;
}
}
return posWorst;
}
/**
* Verifica se o pior da populacao é melhor que o melhor do buffer, se for ele mantem o cara no buffer para realizar tabucol de novo
* @return posicao do filho atualizado na populacao ou -1 caso o filho permaneceu no buffer
*/
int updatePopulation() {
int posWorst = findWorstParent();
int posBestBuffer = findBestInBuffer();
if (population[posWorst]->nof_confl_vertices > bufferCrossover[posBestBuffer]->nof_confl_vertices) {
cpy_solution(bufferCrossover[posBestBuffer], population[posWorst]);
return posWorst;
}
return -1;
}
void *updater(void *threadId) {
long int id = (long int) threadId;
int cycle = 0;
int converg = 0;
int cont = 0;
sem_wait(&semUpdater);
while (1) {
printf("#%ld: atualizando populacao - %d\n", id, cont++);
sem_post(&semFiller);
sem_wait(&semUpdater);
int sp = updatePopulation();
//verifica se atualizou na populacao ou manteve no buffer
if (sp >= 0) {
if (best_solution->nof_confl_edges > population[sp]->nof_confl_edges) {
cpy_solution(population[sp], best_solution);
best_solution->time_to_best = current_usertime_secs();
best_solution->cycles_to_best = cycle;
converg = 0;
}
indexBufferCrossover = 0;
} else {
printf("TA FODA SUBSTITUIR A POPULATION\n");
if (best_solution->nof_confl_edges > bufferCrossover[0]->nof_confl_edges) {
cpy_solution(bufferCrossover[0], best_solution);
best_solution->time_to_best = current_usertime_secs();
best_solution->cycles_to_best = cycle;
converg = 0;
}
indexBufferCrossover = 1;
}
hca_info->diversity = calculate_diversity();
printf("Diversidade: %d\n",hca_info->diversity);
if (get_flag(problem->flags, FLAG_VERBOSE)) {
fprintf(problem->fileout, "HCA: cycle %d; best so far: %d; diversity: %d; parent substituted: %d\n",
cycle, best_solution->nof_confl_edges, hca_info->diversity, sp + 1);
}
if (!(!hca_terminate_conditions(best_solution, hca_info->diversity) &&
!terminate_conditions(best_solution, cycle, converg))) {
best_solution->spent_time = current_usertime_secs();
best_solution->total_cycles = cycle;
hca_info->nof_cross = cross;
printf("FIIIMMM\n\n");
show_solution(best_solution);
getchar();
exit(EXIT_SUCCESS);
//return best_solution;
}
cycle++;
converg++;
}
}
/*###*/
gcp_solution_t* hca(void) {
int cycle = 0;
int converg = 0;
int parent1, parent2, sp;
int cross = 0;
hca_info->diversity = 2 * HCA_DEFAULT_DIVERSITY;
best_solution = init_solution();
best_solution->nof_confl_edges = INT_MAX;
offspring = init_solution();
/*###*/
indexBufferCrossover = 0;
/*###*/
create_population();
/*###*/
pthread_t fillerThread;
pthread_t emptierThreads[BUFFER_SIZE];
pthread_t updaterThread;
sem_init(&semFiller, 0, 1);
sem_init(&semEmptier, 0, 0);
sem_init(&semUpdater, 0, 0);
pthread_barrier_init(&barrier, NULL, BUFFER_SIZE);
long int i = 0;
pthread_create(&fillerThread, NULL, filler, (void*) i);
for (i = 0; i < BUFFER_SIZE; i++) {
pthread_create(&emptierThreads[i], NULL, emptier, (void*) i);
}
i = 0;
pthread_create(&updaterThread, NULL, updater, (void*) i);
pthread_join(fillerThread, NULL);
for (i = 0; i < BUFFER_SIZE; i++) {
pthread_join(emptierThreads[i], NULL);
}
pthread_join(updaterThread, NULL);
/*###*/
while (!hca_terminate_conditions(best_solution, hca_info->diversity) &&
!terminate_conditions(best_solution, cycle, converg)) {
/*choose_parents(&parent1, &parent2);
crossover(parent1, parent2);
cross++;*/
tabucol(offspring, hca_info->cyc_local_search, tabucol_info->tl_style);
sp = substitute_worst(parent1, parent2, offspring);
if (best_solution->nof_confl_edges > offspring->nof_confl_edges) {
cpy_solution(offspring, best_solution);
best_solution->time_to_best = current_usertime_secs();
best_solution->cycles_to_best = cycle;
converg = 0;
}
hca_info->diversity = calculate_diversity();
if (get_flag(problem->flags, FLAG_VERBOSE)) {
fprintf(problem->fileout, "HCA: cycle %d; best so far: %d; diversity: %d; parent substituted: %d\n",
cycle, best_solution->nof_confl_edges, hca_info->diversity, sp + 1);
}
cycle++;
converg++;
}
best_solution->spent_time = current_usertime_secs();
best_solution->total_cycles = cycle;
hca_info->nof_cross = cross;
return best_solution;
}
| 32.441331 | 132 | 0.574984 |
4609052b02309c630320a92aac8c26fd4d5e2ebc | 2,889 | h | C | cpp/Commits.h | cppdreams/brigitte | 8d34f3072a63638ac869d1ba85886f78721c0a89 | [
"MIT"
] | 1 | 2018-05-25T06:39:39.000Z | 2018-05-25T06:39:39.000Z | cpp/Commits.h | cppdreams/brigitte | 8d34f3072a63638ac869d1ba85886f78721c0a89 | [
"MIT"
] | null | null | null | cpp/Commits.h | cppdreams/brigitte | 8d34f3072a63638ac869d1ba85886f78721c0a89 | [
"MIT"
] | null | null | null | #pragma once
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
#include "Git.h"
class Commits : public QAbstractListModel
{
Q_OBJECT
public slots:
int getBranchIndex(int row) const;
QVector<int> getParents(int row) const;
QVector<int> getChildren(int row) const;
void loadFrom(QString path, int maxCommits);
void refresh();
public:
void reset(std::vector<Commit> commits);
virtual int rowCount(const QModelIndex &parent) const override;
virtual QVariant data(const QModelIndex &index, int role) const override;
virtual QHash<int, QByteArray> roleNames() const override;
virtual bool setData(const QModelIndex &index, const QVariant &value, int role) override;
enum Roles {
ShaRole = Qt::UserRole + 1,
ShortShaRole,
MessageRole,
BranchIndexRole,
ChildrenRole,
ParentsRole,
SelectionRole,
AuthorRole,
TimeRole
};
private:
Git m_git;
QString m_path;
int m_maxCommits = 0;
std::vector<char> m_selected;
std::vector<Commit> m_commits;
};
class FilteredCommits : public QSortFilterProxyModel
{
Q_OBJECT
Q_PROPERTY(int selectionRole READ getSelectionRole)
public slots:
int getActiveBranchIndex(int row) const;
QVector<int> getParents(int row) const;
QVector<int> getChildren(int row) const;
bool isSelected(int row) const;
void setSelected(int row, bool selected);
/**
Show only nodes that have multiple parents and/or children, and those
parents/children
*/
void filterOnBranching();
/**
Show only commits that belong to the branch the commit with index 'row'
is in, + direct parents/children.
*/
void filterOnBranch(int row);
void resetFilter();
void search(QString searchString);
public:
/**
Take Commits as argument to get access to unfiltered data without having
to cast SourceModel
*/
FilteredCommits(Commits* commits);
int getSelectionRole() const;
QVector<int> getSourceParents(int sourceRow) const;
QVector<int> getSourceChildren(int sourceRow) const;
private:
struct Filter
{
enum class Type
{
Search,
Git
};
Type type;
std::vector<char> visible;
};
private:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
// bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
/**
Make parents and children visible
*/
void makeDirectRelationsVisible(int sourceRow, Filter &filter);
void makeChildrenVisible(int sourceRow, Filter &filter);
void makeParentsVisible(int sourceRow, Filter &filter);
private:
Commits* m_commits;
std::vector<Filter> m_filters;
};
| 24.483051 | 93 | 0.663898 |
d1452d46c68912db342e130d91be12e314615ca3 | 3,101 | c | C | fourth_semester/Sysopy/Zadanie7/zad2/src/customers.c | MajronMan/agh_stuff | d045e3bd47ac17880526203d9993d9b2389a9ffe | [
"Unlicense"
] | 2 | 2019-03-02T19:31:57.000Z | 2019-04-03T19:54:39.000Z | fourth_semester/Sysopy/Zadanie7/zad2/src/customers.c | MajronMan/agh_stuff | d045e3bd47ac17880526203d9993d9b2389a9ffe | [
"Unlicense"
] | null | null | null | fourth_semester/Sysopy/Zadanie7/zad2/src/customers.c | MajronMan/agh_stuff | d045e3bd47ac17880526203d9993d9b2389a9ffe | [
"Unlicense"
] | 1 | 2019-04-03T18:26:50.000Z | 2019-04-03T18:26:50.000Z | #include "customers.h"
int main(int argc, char **argv) {
CHECK_UNEQUAL("main", argc, 3,
"Usage: ./customers customers_count haircuts_count")
customers_count = (unsigned int) atoi(argv[1]);
haircuts_count = (unsigned int) atoi(argv[2]);
pid_t *pids = calloc(customers_count, sizeof(pid_t));
GET_SEMAPHORE(queue_sem, QUEUE_SEM_NAME)
GET_SEMAPHORE(seat_sem, SEAT_SEM_NAME)
GET_SEMAPHORE(pillow_sem, PILLOW_SEM_NAME)
GET_SHARED_Q(q, queue_mem_id, SHARED_Q_NAME)
for (int i = 0; i < customers_count; i++) {
CHECK_NEGATIVE("create_customer", (pids[i] = fork()),
"Cannot create new customer process")
if (pids[i] == 0) {
do_customer_stuff();
printf("%d is free!\n", getpid());
exit(0);
}
}
wait(NULL);
printf("\n\n-------------------\n\nDONE\n");
free(pids);
munmap((void *) q, sizeof(queue));
return 0;
}
void do_customer_stuff() {
pid_t my_pid = getpid();
my_haircuts = 0;
printf("%d is gonna do some customer stuff at %10.ld\n", my_pid, get_timestamp());
while (my_haircuts < haircuts_count) {
printf("%d is gonna get a haircut at %10.ld\n", my_pid, get_timestamp());
if (in_da_shop()) {
wait_for_barber();
while(wait_for_sigusr) {
sigsuspend(&sig_old_mask);
}
sigprocmask(SIG_UNBLOCK, &sig_mask, NULL);
printf("%d is leaving the shop with awesome haircut at %10.ld\n", my_pid, get_timestamp());
} else {
printf("%d is leaving the shop due to lack of space at %10.ld\n", my_pid, get_timestamp());
my_haircuts++;
}
}
}
char in_da_shop() {
pid_t my_pid = getpid();
char result;
prolaag(queue_sem);
if (!is_empty(q)) {
printf("%d sees there are people waiting and joins queue at %.10ld\n", my_pid, get_timestamp());
result = push(q, my_pid);
verhoog(queue_sem);
} else {
prolaag(seat_sem);
if (q->seat > 0) {
printf("%d sees seat is taken and joins queue at %.10ld\n",
my_pid, get_timestamp());
result = push(q, my_pid);
verhoog(queue_sem);
verhoog(seat_sem);
} else {
prolaag(pillow_sem);
if (q->pillow <= 0) {
printf("%d sees barber is not asleep and joins queue at %.10ld\n",
my_pid, get_timestamp());
result = push(q, my_pid);
verhoog(queue_sem);
verhoog(seat_sem);
verhoog(pillow_sem);
} else {
printf("%d sees barber %d is sleeping and wakes him at %.10ld\n",
my_pid, q->pillow, get_timestamp());
push(q, my_pid);
kill(q->pillow, SIGUSR1);
verhoog(queue_sem);
verhoog(seat_sem);
verhoog(pillow_sem);
result = 1;
}
}
}
return result;
}
void wait_for_barber() {
CHECK_NEGATIVE("wait_for_barber", signal(SIGUSR1, handler), "Cannot create SIGUSR1 handler")
sigfillset(&sig_mask);
sigdelset(&sig_mask, SIGUSR1);
sigprocmask(SIG_BLOCK, &sig_mask, &sig_old_mask);
wait_for_sigusr = 1;
}
void handler(int sig) {
if (sig == SIGUSR1) {
my_haircuts++;
wait_for_sigusr = 0;
}
}
| 27.6875 | 100 | 0.610771 |
44f289f0c4b1d91c56ee88555466ae5b11182aec | 242 | h | C | include/scene.h | Cotax61/Global_Game_Jam_2020 | 45561aa587ba19c0a2dbbd669d4a5527f670514d | [
"MIT"
] | 3 | 2020-02-02T01:43:17.000Z | 2020-02-02T02:29:04.000Z | include/scene.h | Cotax61/Global_Game_Jam_2020 | 45561aa587ba19c0a2dbbd669d4a5527f670514d | [
"MIT"
] | 13 | 2020-01-31T18:53:10.000Z | 2020-02-02T04:25:35.000Z | include/scene.h | Cotax61/Global_Game_Jam_2020 | 45561aa587ba19c0a2dbbd669d4a5527f670514d | [
"MIT"
] | null | null | null | #ifndef SCENE_H_
#define SCENE_H_
#include "libdragon.h"
dg_scene_t *scene_level0_past(void);
dg_scene_t *scene_level0_present(void);
dg_scene_t *scene_level01_past(void);
dg_scene_t *scene_level01_present(void);
#endif /* !SCENE_H_ */
| 16.133333 | 40 | 0.785124 |
933728dbb7da26b48294a19b6001d41c84cadc21 | 5,331 | h | C | stitch/queue_mpsc_waitfree.h | adamelliot/stitch | e2a7f4cfb0f8171f8d01e1f1c41b30f3c03be5f3 | [
"MIT"
] | 4 | 2017-11-28T17:22:46.000Z | 2022-03-17T07:47:19.000Z | stitch/queue_mpsc_waitfree.h | adamelliot/stitch | e2a7f4cfb0f8171f8d01e1f1c41b30f3c03be5f3 | [
"MIT"
] | 10 | 2017-10-04T01:20:25.000Z | 2017-11-23T06:15:23.000Z | stitch/queue_mpsc_waitfree.h | adamelliot/stitch | e2a7f4cfb0f8171f8d01e1f1c41b30f3c03be5f3 | [
"MIT"
] | 1 | 2019-06-13T23:05:49.000Z | 2019-06-13T23:05:49.000Z | #include <cmath>
#include <atomic>
#include <vector>
#include <thread>
#include <stdexcept>
namespace Stitch {
using std::vector;
using std::atomic;
// FIXME: Use atomic_flag instead of atomic<bool>
template <typename T>
class Waitfree_MPSC_Queue
{
public:
static bool is_lockfree()
{
return (ATOMIC_INT_LOCK_FREE == 2) && (ATOMIC_BOOL_LOCK_FREE == 2);
}
Waitfree_MPSC_Queue(int size):
d_data(next_power_of_two(size)),
d_journal(d_data.size()),
d_wrap_mask(d_data.size() - 1),
d_writable(d_data.size())
{
//printf("Size = %d\n", (int) d_data.size());
for (auto & val : d_journal)
val = false;
}
~Waitfree_MPSC_Queue()
{}
int capacity() const
{
return d_data.size();
}
bool full()
{
return d_writable < 1;
}
bool empty()
{
return d_journal[d_tail] == false;
}
/*!
\brief Adds an item to the queue.
The item \p value is added to the input end of the queue.
This can fail if the queue is full, in which case nothing is done.
\return True on success, false on failure.
- Progess: Wait-free
- Time complexity: O(1)
*/
bool push(const T & value)
{
int pos;
if (!reserve_write(1, pos))
return false;
//printf("Writing at %d\n", pos);
d_data[pos] = value;
d_journal[pos] = true;
return true;
}
/*!
\brief Adds items in bulk to the queue.
'count' consecutive item starting at the 'input_start' iterator are added to the input end of the queue.
This can fail if the queue does not have space for 'count' items, in which case nothing is done.
The 'input_start' type 'I' must satisfy the Input Iterator requirements, with `value_type` equal to T.
For example `T*`.
See: https://en.cppreference.com/w/cpp/named_req/InputIterator
\return True on success, false on failure.
For example:
Waitfree_MPSC_Queue<int> q(10);
int data[5];
q.push(5, data);
- Progess: Wait-free
- Time complexity: O(count)
*/
template <typename I>
bool push(int count, I input_start)
{
int pos;
if (!reserve_write(count, pos))
return false;
I input = input_start;
for (int i = 0; i < count; ++i, ++input)
{
d_data[pos] = *input;
d_journal[pos] = true;
pos = (pos + 1) & d_wrap_mask;
}
return true;
}
/*!
\brief
Removes an item from the queue.
An item is removed from the output end of the queue and stored in \p value.
This can fail if the queue is empty, in which case nothing is done.
\return True on success, false on failure.
- Progess: Wait-free
- Time complexity: O(1)
*/
bool pop(T & value)
{
if (!d_journal[d_tail])
return false;
int pos = d_tail;
d_tail = (d_tail + 1) & d_wrap_mask;
//printf("Reading at %d\n", pos);
value = d_data[pos];
d_journal[pos] = false;
d_writable.fetch_add(1);
return true;
}
/*!
\brief Removes items in bulk from the queue.
'count' items are removed from the output end of the queue, and stored into consecutive locations starting at the 'output_start' iterator.
This can fail if there is less than 'count' items in the queue, in which case nothing is done.
The 'output_start' type 'O' must satisfy the Output Iterator requirements, with `value_type` equal to T.
For example `T*`.
See: https://en.cppreference.com/w/cpp/named_req/OutputIterator
\return True on success, false on failure.
For example:
Waitfree_MPSC_Queue<int> q(10);
int data[5];
q.pop(5, data);
- Progess: Wait-free
- Time complexity: O(count)
*/
template <typename O>
bool pop(int count, O output_start)
{
if (count > d_data.size())
return false;
int pos = d_tail;
for (int i = 0; i < count; ++i)
{
int j = (pos + i) & d_wrap_mask;
if (!d_journal[j])
return false;
}
O output = output_start;
for (int i = 0; i < count; ++i, ++output)
{
*output = d_data[pos];
d_journal[pos] = false;
pos = (pos + 1) & d_wrap_mask;
}
d_tail = pos;
d_writable.fetch_add(count);
return true;
}
private:
bool reserve_write(int count, int & pos)
{
int old_writable = d_writable.fetch_sub(count);
bool ok = old_writable - count >= 0;
if (!ok)
{
d_writable.fetch_add(count);
return false;
}
// We must wrap "pos", because another thread might have
// incremented d_head just before us.
pos = d_head.fetch_add(count) & d_wrap_mask;
d_head.fetch_and(d_wrap_mask);
return true;
}
int next_power_of_two(int value)
{
return std::pow(2, std::ceil(std::log2(value)));
}
vector<T> d_data;
vector<atomic<bool>> d_journal;
int d_wrap_mask = 0;
atomic<int> d_head { 0 };
atomic<int> d_writable { 0 };
int d_tail { 0 };
};
}
| 22.028926 | 142 | 0.568561 |
d893cd2a3c7bcb579d682aaa5f01d0d158abf6c7 | 1,169 | h | C | Source/Divided/counter_rb.h | alexruzzi98/API | c070350f70c3f498d198a3b686368065276d710c | [
"MIT"
] | null | null | null | Source/Divided/counter_rb.h | alexruzzi98/API | c070350f70c3f498d198a3b686368065276d710c | [
"MIT"
] | null | null | null | Source/Divided/counter_rb.h | alexruzzi98/API | c070350f70c3f498d198a3b686368065276d710c | [
"MIT"
] | null | null | null | #ifndef PROGETTO_API_COUNTER_RB_H
#define PROGETTO_API_COUNTER_RB_H
#include "rel.h"
#include <stdio.h>
//defining all the rb-tree structures and the relations structure
typedef struct rb_Tree_cont{
char color;
char *entities;
int contatore;
struct rb_Tree_cont *right,*left,*p;
struct T *received;
}rb_Tree_cont;
typedef struct T3 {
struct rb_Tree_cont *root,*nil;
}T3;
//end of structures
//defining functions of the rb-tree of the counter
T3 *left_rotate3(T3 *ent_t,rb_Tree_cont *x);
T3* right_rotate3(T3 *ent_t,rb_Tree_cont *x);
T3 *rb_insert_fixup3(T3 *ent_t , rb_Tree_cont *z);
rb_Tree_cont *create_element3(rel relations,T3 *ent_t, int cont);
T3 *rb_insert3(T3 *ent_t,rel relations);
T3 *create_rb3();
rb_Tree_cont *tree_minimum3(rb_Tree_cont *x,rb_Tree_cont *nil);
rb_Tree_cont *tree_successor3(rb_Tree_cont *x,rb_Tree_cont *nil);
T3 *rb_delete_fixup3(T3 *ent_t,rb_Tree_cont *x);
T3 *delete_rb3(T3 *ent_t,rb_Tree_cont *z);
void print_rb3(rb_Tree_cont *root,rb_Tree_cont *nil);
rb_Tree_cont *rb_search3(rb_Tree_cont *root,rb_Tree_cont *nil,char *value);
//end of functions
#endif //PROGETTO_API_COUNTER_RB_H
| 18.854839 | 75 | 0.753636 |
d238e6e1d11d7b4cabb8beb2fa9ab44a5e2c6087 | 816 | h | C | j2objc/include/java/io/FileFilter.h | benf1977/j2objc-serialization-example | bc356a2fa4a1f4da680a0f6cfe33985220be74f3 | [
"MIT"
] | null | null | null | j2objc/include/java/io/FileFilter.h | benf1977/j2objc-serialization-example | bc356a2fa4a1f4da680a0f6cfe33985220be74f3 | [
"MIT"
] | null | null | null | j2objc/include/java/io/FileFilter.h | benf1977/j2objc-serialization-example | bc356a2fa4a1f4da680a0f6cfe33985220be74f3 | [
"MIT"
] | null | null | null | //
// Generated by the J2ObjC translator. DO NOT EDIT!
// source: android/libcore/luni/src/main/java/java/io/FileFilter.java
//
#ifndef _JavaIoFileFilter_H_
#define _JavaIoFileFilter_H_
#include "J2ObjC_header.h"
@class JavaIoFile;
/*!
@brief An interface for filtering <code>File</code> objects based on their names
or other information.
*/
@protocol JavaIoFileFilter < NSObject, JavaObject >
/*!
@brief Indicating whether a specific file should be included in a pathname list.
@param pathname
the abstract file to check.
@return <code>true</code> if the file should be included, <code>false</code>
otherwise.
*/
- (jboolean)acceptWithJavaIoFile:(JavaIoFile *)pathname;
@end
J2OBJC_EMPTY_STATIC_INIT(JavaIoFileFilter)
J2OBJC_TYPE_LITERAL_HEADER(JavaIoFileFilter)
#endif // _JavaIoFileFilter_H_
| 23.314286 | 81 | 0.769608 |
cf9b1df7662b8a035084606621a741547caad863 | 969 | h | C | System/Library/PrivateFrameworks/IMFoundation.framework/IMMultiQueue.h | lechium/tvOS130Headers | 6b47cdcd4a6f453b399aa9d742b5d0f7e3f732fd | [
"MIT"
] | 11 | 2019-11-06T04:48:48.000Z | 2022-02-09T17:48:15.000Z | System/Library/PrivateFrameworks/IMFoundation.framework/IMMultiQueue.h | lechium/tvOS130Headers | 6b47cdcd4a6f453b399aa9d742b5d0f7e3f732fd | [
"MIT"
] | 1 | 2020-04-16T01:41:56.000Z | 2020-04-16T04:32:00.000Z | System/Library/PrivateFrameworks/IMFoundation.framework/IMMultiQueue.h | lechium/tvOS130Headers | 6b47cdcd4a6f453b399aa9d742b5d0f7e3f732fd | [
"MIT"
] | 3 | 2019-12-22T20:17:53.000Z | 2021-01-25T09:47:49.000Z | /*
* This header is generated by classdump-dyld 1.0
* on Tuesday, November 5, 2019 at 2:42:04 AM Mountain Standard Time
* Operating System: Version 13.0 (Build 17J586)
* Image Source: /System/Library/PrivateFrameworks/IMFoundation.framework/IMFoundation
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos.
*/
@protocol OS_dispatch_queue;
@class NSMutableDictionary, NSObject;
@interface IMMultiQueue : NSObject {
NSMutableDictionary* _queueMap;
NSObject*<OS_dispatch_queue> _queue;
}
-(id)init;
-(void)dealloc;
-(id)initWithQueue:(id)arg1 ;
-(void)_popEnqueuedBlockWithGUID:(id)arg1 key:(id)arg2 ;
-(BOOL)_addBlock:(/*^block*/id)arg1 withGUID:(id)arg2 forKey:(id)arg3 description:(id)arg4 ;
-(id)loggableOverviewForKey:(id)arg1 ;
-(BOOL)addBlock:(/*^block*/id)arg1 withTimeout:(double)arg2 forKey:(id)arg3 description:(id)arg4 ;
-(BOOL)addBlock:(/*^block*/id)arg1 forKey:(id)arg2 description:(id)arg3 ;
-(id)loggableOverview;
@end
| 32.3 | 98 | 0.75645 |
89c2fa5afe121d091058a8aabc852b1d95fe32c0 | 3,920 | h | C | native/src/seal/relinkeys.h | deisler134/SEAL | 4a019473ad90b066b593f5714d6bf07d3a3ed671 | [
"MIT"
] | 3 | 2019-12-24T07:08:33.000Z | 2020-05-13T17:40:28.000Z | SEAL/native/src/seal/relinkeys.h | adi-ar/LogisticRegression_SEAL-Python | 047bcf7e2142bbdca178754de26cace4298c5936 | [
"MIT"
] | null | null | null | SEAL/native/src/seal/relinkeys.h | adi-ar/LogisticRegression_SEAL-Python | 047bcf7e2142bbdca178754de26cace4298c5936 | [
"MIT"
] | null | null | null | // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
#pragma once
#include <iostream>
#include <vector>
#include <limits>
#include "seal/ciphertext.h"
#include "seal/memorymanager.h"
#include "seal/encryptionparams.h"
#include "seal/kswitchkeys.h"
namespace seal
{
/**
Class to store relinearization keys.
@par Relinearization
Freshly encrypted ciphertexts have a size of 2, and multiplying ciphertexts
of sizes K and L results in a ciphertext of size K+L-1. Unfortunately, this
growth in size slows down further multiplications and increases noise growth.
Relinearization is an operation that has no semantic meaning, but it reduces
the size of ciphertexts back to 2. Microsoft SEAL can only relinearize size 3
ciphertexts back to size 2, so if the ciphertexts grow larger than size 3,
there is no way to reduce their size. Relinearization requires an instance of
RelinKeys to be created by the secret key owner and to be shared with the
evaluator. Note that plain multiplication is fundamentally different from
normal multiplication and does not result in ciphertext size growth.
@par When to Relinearize
Typically, one should always relinearize after each multiplications. However,
in some cases relinearization should be postponed as late as possible due to
its computational cost. For example, suppose the computation involves several
homomorphic multiplications followed by a sum of the results. In this case it
makes sense to not relinearize each product, but instead add them first and
only then relinearize the sum. This is particularly important when using the
CKKS scheme, where relinearization is much more computationally costly than
multiplications and additions.
@par Thread Safety
In general, reading from RelinKeys is thread-safe as long as no other thread
is concurrently mutating it. This is due to the underlying data structure
storing the relinearization keys not being thread-safe.
@see SecretKey for the class that stores the secret key.
@see PublicKey for the class that stores the public key.
@see GaloisKeys for the class that stores the Galois keys.
@see KeyGenerator for the class that generates the relinearization keys.
*/
class RelinKeys : public KSwitchKeys
{
public:
/**
Returns the index of a relinearization key in the backing KSwitchKeys
instance that corresponds to the given secret key power, assuming that
it exists in the backing KSwitchKeys.
@param[in] key_power The power of the secret key
@throws std::invalid_argument if key_power is less than 2
*/
inline static std::size_t get_index(std::size_t key_power)
{
if (key_power < 2)
{
throw std::invalid_argument("key_power cannot be less than 2");
}
return key_power - 2;
}
/**
Returns whether a relinearization key corresponding to a given power of
the secret key exists.
@param[in] key_power The power of the secret key
@throws std::invalid_argument if key_power is less than 2
*/
inline bool has_key(std::size_t key_power) const
{
std::size_t index = get_index(key_power);
return data().size() > index && !data()[index].empty();
}
/**
Returns a const reference to a relinearization key. The returned
relinearization key corresponds to the given power of the secret key.
@param[in] key_power The power of the secret key
@throws std::invalid_argument if the key corresponding to key_power does not exist
*/
inline auto &key(std::size_t key_power) const
{
return KSwitchKeys::data(get_index(key_power));
}
};
} | 40.833333 | 90 | 0.7 |
c9004658740e441e8a7974924b7ba5a06cc9bc4b | 323 | h | C | ColorPicker/ColorsHistoryController.h | jiangxiaoxin/Color-Picker-Pro | 3050c898ed1f0038e1366d1822755539035e2d69 | [
"MIT",
"Unlicense"
] | 216 | 2015-01-05T13:11:06.000Z | 2022-02-05T01:32:24.000Z | ColorPicker/ColorsHistoryController.h | jiangxiaoxin/Color-Picker-Pro | 3050c898ed1f0038e1366d1822755539035e2d69 | [
"MIT",
"Unlicense"
] | 3 | 2015-09-16T18:53:29.000Z | 2017-10-06T13:07:08.000Z | ColorPicker/ColorsHistoryController.h | jiangxiaoxin/Color-Picker-Pro | 3050c898ed1f0038e1366d1822755539035e2d69 | [
"MIT",
"Unlicense"
] | 31 | 2015-01-21T12:54:58.000Z | 2021-03-26T02:22:46.000Z | //
// ColorsHistory.h
// ColorPicker
//
// Created by Oscar Del Ben on 8/22/11.
// Copyright 2011 DibiStore. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface ColorsHistoryController : NSObject
+ (NSData *)defaultValues;
+ (void)push:(NSColor *)aColor;
+ (NSColor *)colorAtIndex:(int)index;
@end
| 17.944444 | 50 | 0.705882 |
c5d1bbbef62c99d47ad7ab45b122154bce2845e3 | 493 | h | C | libs/libobjc/include/libobjc/class.h | samvirg-git/pranaOS | 0a457fdd00842078769a0fbe6b9185b0b9d1e9dc | [
"BSD-2-Clause"
] | 1 | 2021-12-04T13:33:48.000Z | 2021-12-04T13:33:48.000Z | libs/libobjc/include/libobjc/class.h | smithersomer/pranaOS | b8ef2554af43fd3e0f67a5ceebbad8b1ae1c4cb1 | [
"BSD-2-Clause"
] | null | null | null | libs/libobjc/include/libobjc/class.h | smithersomer/pranaOS | b8ef2554af43fd3e0f67a5ceebbad8b1ae1c4cb1 | [
"BSD-2-Clause"
] | null | null | null | /*
* Copyright (c) 2021, Krisna Pranav
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#ifndef _LIBOBJC_CLASS_H
#define _LIBOBJC_CLASS_H
#include <libobjc/module.h>
#define DISPATCH_TABLE_NOT_INITIALIZED (void*)0x0
bool class_resolve_links(Class cls);
void class_resolve_all_unresolved();
void class_table_init();
void class_add_from_module(struct objc_symtab* symtab);
IMP class_get_implementation(Class cls, SEL sel);
Class objc_getClass(const char* name);
#endif // _LIBOBJC_CLASS_H | 21.434783 | 55 | 0.789047 |
65c5d48208ef939f8f8f0f94bb54e4ce546388f0 | 969 | h | C | macOS/10.13/AVKit.framework/AVThumbnailGenerator.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | 30 | 2016-10-09T20:13:00.000Z | 2022-01-24T04:14:57.000Z | macOS/10.13/AVKit.framework/AVThumbnailGenerator.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | null | null | null | macOS/10.13/AVKit.framework/AVThumbnailGenerator.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | 7 | 2017-08-29T14:41:25.000Z | 2022-01-19T17:14:54.000Z | /* Generated by RuntimeBrowser
Image: /System/Library/Frameworks/AVKit.framework/Versions/A/AVKit
*/
@interface AVThumbnailGenerator : NSObject {
AVThumbnailGenerationRequest * _activeRequest;
NSMutableDictionary * _pendingRequestsForRequestType;
NSObject<OS_dispatch_queue> * _thumbnailGenerationQueue;
NSTimer * _thumbnailGenerationTimer;
NSArray * _thumbnails;
}
@property (atomic, readonly) NSArray *thumbnails;
- (void).cxx_destruct;
- (void)_cancelActiveRequest;
- (void)_cancelThumbnailGenerationTimer;
- (void)_didCompleteRequest:(id)arg1;
- (void)_processRequest:(id)arg1;
- (void)cancelThumbnailGenerationForRequestType:(long long)arg1;
- (void)dealloc;
- (void)generateThumbnailsForAsset:(id)arg1 startTime:(double)arg2 duration:(double)arg3 thumbnailTimes:(id)arg4 tolerance:(double)arg5 size:(struct CGSize { double x1; double x2; })arg6 requestType:(long long)arg7 thumbnailHandler:(id)arg8;
- (id)init;
- (id)thumbnails;
@end
| 35.888889 | 241 | 0.781218 |
6598b985c92c65a538cfe1f3cf6a0610ae05172c | 5,328 | c | C | components/mqtt/test/test_mqtt_connection.c | horscchtey/esp-idf | 9fd621c7ad27a1e7a5d4ba68ca418b5990afa3cb | [
"Apache-2.0"
] | 2 | 2022-03-04T02:48:03.000Z | 2022-03-04T05:55:42.000Z | components/mqtt/test/test_mqtt_connection.c | Tien76/esp-idf | 8363f88cd5c8bad44c6b2ffda42cd7cc9996e64c | [
"Apache-2.0"
] | null | null | null | components/mqtt/test/test_mqtt_connection.c | Tien76/esp-idf | 8363f88cd5c8bad44c6b2ffda42cd7cc9996e64c | [
"Apache-2.0"
] | null | null | null | /*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "freertos/FreeRTOS.h"
#include "freertos/event_groups.h"
#include "unity.h"
#include "esp_event.h"
#include "esp_eth.h"
#include "esp_log.h"
#if SOC_EMAC_SUPPORTED
#define ETH_START_BIT BIT(0)
#define ETH_STOP_BIT BIT(1)
#define ETH_CONNECT_BIT BIT(2)
#define ETH_GOT_IP_BIT BIT(3)
#define ETH_STOP_TIMEOUT_MS (10000)
#define ETH_GET_IP_TIMEOUT_MS (60000)
static const char *TAG = "esp32_eth_test_fixture";
static EventGroupHandle_t s_eth_event_group = NULL;
static esp_netif_t *s_eth_netif = NULL;
static esp_eth_mac_t *s_mac = NULL;
static esp_eth_phy_t *s_phy = NULL;
static esp_eth_handle_t s_eth_handle = NULL;
static esp_eth_netif_glue_handle_t s_eth_glue = NULL;
/** Event handler for Ethernet events */
static void eth_event_handler(void *arg, esp_event_base_t event_base,
int32_t event_id, void *event_data)
{
EventGroupHandle_t eth_event_group = (EventGroupHandle_t)arg;
switch (event_id) {
case ETHERNET_EVENT_CONNECTED:
xEventGroupSetBits(eth_event_group, ETH_CONNECT_BIT);
ESP_LOGI(TAG, "Ethernet Link Up");
break;
case ETHERNET_EVENT_DISCONNECTED:
ESP_LOGI(TAG, "Ethernet Link Down");
break;
case ETHERNET_EVENT_START:
xEventGroupSetBits(eth_event_group, ETH_START_BIT);
ESP_LOGI(TAG, "Ethernet Started");
break;
case ETHERNET_EVENT_STOP:
xEventGroupSetBits(eth_event_group, ETH_STOP_BIT);
ESP_LOGI(TAG, "Ethernet Stopped");
break;
default:
break;
}
}
/** Event handler for IP_EVENT_ETH_GOT_IP */
static void got_ip_event_handler(void *arg, esp_event_base_t event_base,
int32_t event_id, void *event_data)
{
EventGroupHandle_t eth_event_group = (EventGroupHandle_t)arg;
ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;
const esp_netif_ip_info_t *ip_info = &event->ip_info;
ESP_LOGI(TAG, "Ethernet Got IP Address");
ESP_LOGI(TAG, "~~~~~~~~~~~");
ESP_LOGI(TAG, "ETHIP:" IPSTR, IP2STR(&ip_info->ip));
ESP_LOGI(TAG, "ETHMASK:" IPSTR, IP2STR(&ip_info->netmask));
ESP_LOGI(TAG, "ETHGW:" IPSTR, IP2STR(&ip_info->gw));
ESP_LOGI(TAG, "~~~~~~~~~~~");
xEventGroupSetBits(eth_event_group, ETH_GOT_IP_BIT);
}
static esp_err_t test_uninstall_driver(esp_eth_handle_t eth_hdl, uint32_t ms_to_wait)
{
int i = 0;
ms_to_wait += 100;
for (i = 0; i < ms_to_wait / 100; i++) {
vTaskDelay(pdMS_TO_TICKS(100));
if (esp_eth_driver_uninstall(eth_hdl) == ESP_OK) {
break;
}
}
if (i < ms_to_wait / 10) {
return ESP_OK;
} else {
return ESP_FAIL;
}
}
void connect_test_fixture_setup(void)
{
EventBits_t bits;
s_eth_event_group = xEventGroupCreate();
TEST_ASSERT(s_eth_event_group != NULL);
TEST_ESP_OK(esp_event_loop_create_default());
// create TCP/IP netif
esp_netif_config_t netif_cfg = ESP_NETIF_DEFAULT_ETH();
s_eth_netif = esp_netif_new(&netif_cfg);
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
eth_esp32_emac_config_t esp32_emac_config = ETH_ESP32_EMAC_DEFAULT_CONFIG();
s_mac = esp_eth_mac_new_esp32(&esp32_emac_config, &mac_config);
eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
s_phy = esp_eth_phy_new_ip101(&phy_config);
esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(s_mac, s_phy);
// install Ethernet driver
TEST_ESP_OK(esp_eth_driver_install(ð_config, &s_eth_handle));
// combine driver with netif
s_eth_glue = esp_eth_new_netif_glue(s_eth_handle);
TEST_ESP_OK(esp_netif_attach(s_eth_netif, s_eth_glue));
// register user defined event handers
TEST_ESP_OK(esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID, ð_event_handler, s_eth_event_group));
TEST_ESP_OK(esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &got_ip_event_handler, s_eth_event_group));
// start Ethernet driver
TEST_ESP_OK(esp_eth_start(s_eth_handle));
/* wait for IP lease */
bits = xEventGroupWaitBits(s_eth_event_group, ETH_GOT_IP_BIT, true, true, pdMS_TO_TICKS(ETH_GET_IP_TIMEOUT_MS));
TEST_ASSERT((bits & ETH_GOT_IP_BIT) == ETH_GOT_IP_BIT);
}
void connect_test_fixture_teardown(void)
{
EventBits_t bits;
// stop Ethernet driver
TEST_ESP_OK(esp_eth_stop(s_eth_handle));
/* wait for connection stop */
bits = xEventGroupWaitBits(s_eth_event_group, ETH_STOP_BIT, true, true, pdMS_TO_TICKS(ETH_STOP_TIMEOUT_MS));
TEST_ASSERT((bits & ETH_STOP_BIT) == ETH_STOP_BIT);
TEST_ESP_OK(esp_eth_del_netif_glue(s_eth_glue));
/* driver should be uninstalled within 2 seconds */
TEST_ESP_OK(test_uninstall_driver(s_eth_handle, 2000));
TEST_ESP_OK(s_phy->del(s_phy));
TEST_ESP_OK(s_mac->del(s_mac));
TEST_ESP_OK(esp_event_handler_unregister(IP_EVENT, IP_EVENT_ETH_GOT_IP, got_ip_event_handler));
TEST_ESP_OK(esp_event_handler_unregister(ETH_EVENT, ESP_EVENT_ANY_ID, eth_event_handler));
esp_netif_destroy(s_eth_netif);
TEST_ESP_OK(esp_event_loop_delete_default());
vEventGroupDelete(s_eth_event_group);
}
#endif // SOC_EMAC_SUPPORTED
| 37 | 117 | 0.718844 |
45cb1bc006f8ca44e7ffcc68a43bf29c748bd980 | 115,587 | c | C | release/src/router/httpd/sysdeps/web-broadcom.c | zhoutao0712/rtn11pb1 | 09e6b6c7ef4b91be0a9374daeacc3ac9f2fa3a05 | [
"Apache-2.0"
] | null | null | null | release/src/router/httpd/sysdeps/web-broadcom.c | zhoutao0712/rtn11pb1 | 09e6b6c7ef4b91be0a9374daeacc3ac9f2fa3a05 | [
"Apache-2.0"
] | null | null | null | release/src/router/httpd/sysdeps/web-broadcom.c | zhoutao0712/rtn11pb1 | 09e6b6c7ef4b91be0a9374daeacc3ac9f2fa3a05 | [
"Apache-2.0"
] | null | null | null | /*
* Broadcom Home Gateway Reference Design
* Web Page Configuration Support Routines
*
* Copyright 2004, Broadcom Corporation
* All Rights Reserved.
*
* THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
* KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
* SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
* $Id: broadcom.c,v 1.1.1.1 2010/10/15 02:24:15 shinjung Exp $
*/
#ifdef WEBS
#include <webs.h>
#include <uemf.h>
#include <ej.h>
#else /* !WEBS */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <unistd.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <assert.h>
#include <httpd.h>
#endif /* WEBS */
#include <shared.h>
#include <typedefs.h>
#include <proto/ethernet.h>
#ifdef RTCONFIG_BCMWL6
#include <proto/wps.h>
#endif
#include <bcmnvram.h>
#include <bcmutils.h>
#include <shutils.h>
#include <wlutils.h>
#include <linux/types.h>
#include <wlscan.h>
#ifdef RTCONFIG_BCMWL6
#include <dirent.h>
#ifdef RTCONFIG_QTN
#include "web-qtn.h"
#endif
enum {
NOTHING,
REBOOT,
RESTART,
};
#endif
#define EZC_FLAGS_READ 0x0001
#define EZC_FLAGS_WRITE 0x0002
#define EZC_FLAGS_CRYPT 0x0004
#define EZC_CRYPT_KEY "620A83A6960E48d1B05D49B0288A2C1F"
#define EZC_SUCCESS 0
#define EZC_ERR_NOT_ENABLED 1
#define EZC_ERR_INVALID_STATE 2
#define EZC_ERR_INVALID_DATA 3
#ifndef NOUSB
static const char * const apply_header =
"<head>"
"<title>Broadcom Home Gateway Reference Design: Apply</title>"
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"
"<style type=\"text/css\">"
"body { background: white; color: black; font-family: arial, sans-serif; font-size: 9pt }"
".title { font-family: arial, sans-serif; font-size: 13pt; font-weight: bold }"
".subtitle { font-family: arial, sans-serif; font-size: 11pt }"
".label { color: #306498; font-family: arial, sans-serif; font-size: 7pt }"
"</style>"
"</head>"
"<body>"
"<p>"
"<span class=\"title\">APPLY</span><br>"
"<span class=\"subtitle\">This screen notifies you of any errors "
"that were detected while changing the router's settings.</span>"
"<form method=\"get\" action=\"apply.cgi\">"
"<p>"
;
static const char * const apply_footer =
"<p>"
"<input type=\"button\" name=\"action\" value=\"Continue\" OnClick=\"document.location.href='%s';\">"
"</form>"
"<p class=\"label\">©2001-2004 Broadcom Corporation. All rights reserved.</p>"
"</body>"
;
#endif
#include <fcntl.h>
#include <signal.h>
#include <time.h>
#include <sys/klog.h>
#include <sys/wait.h>
#include <sys/ioctl.h>
#include <net/if.h>
typedef u_int64_t u64;
typedef u_int32_t u32;
typedef u_int16_t u16;
typedef u_int8_t u8;
#include <linux/ethtool.h>
#include <linux/sockios.h>
#include <net/if_arp.h>
#define sys_restart() kill(1, SIGHUP)
#define sys_reboot() kill(1, SIGTERM)
#define sys_stats(url) eval("stats", (url))
int
ej_wl_sta_status(int eid, webs_t wp, char *name)
{
// TODO
return 0;
}
#include <bcmendian.h>
#include <bcmparams.h> /* for DEV_NUMIFS */
#define SSID_FMT_BUF_LEN 4*32+1 /* Length for SSID format string */
#define MAX_STA_COUNT 128
/* The below macros handle endian mis-matches between wl utility and wl driver. */
static bool g_swap = FALSE;
#define htod32(i) (g_swap?bcmswap32(i):(uint32)(i))
#define dtoh32(i) (g_swap?bcmswap32(i):(uint32)(i))
#define dtoh16(i) (g_swap?bcmswap16(i):(uint16)(i))
#define dtohchanspec(i) (g_swap?dtoh16(i):i)
/* 802.11i/WPA RSN IE parsing utilities */
typedef struct {
uint16 version;
wpa_suite_mcast_t *mcast;
wpa_suite_ucast_t *ucast;
wpa_suite_auth_key_mgmt_t *akm;
uint8 *capabilities;
} rsn_parse_info_t;
/* Helper routine to print the infrastructure mode while pretty printing the BSS list */
#if 0
static const char *
capmode2str(uint16 capability)
{
capability &= (DOT11_CAP_ESS | DOT11_CAP_IBSS);
if (capability == DOT11_CAP_ESS)
return "Managed";
else if (capability == DOT11_CAP_IBSS)
return "Ad Hoc";
else
return "<unknown>";
}
#endif
int
dump_rateset(int eid, webs_t wp, int argc, char_t **argv, uint8 *rates, uint count)
{
uint i;
uint r;
bool b;
int retval = 0;
retval += websWrite(wp, "[ ");
for (i = 0; i < count; i++) {
r = rates[i] & 0x7f;
b = rates[i] & 0x80;
if (r == 0)
break;
retval += websWrite(wp, "%d%s%s ", (r / 2), (r % 2)?".5":"", b?"(b)":"");
}
retval += websWrite(wp, "]");
return retval;
}
#ifdef RTCONFIG_BCMWL6
/* Definitions for D11AC capable Chanspec type */
/* Chanspec ASCII representation with 802.11ac capability:
* [<band> 'g'] <channel> ['/'<bandwidth> [<ctl-sideband>]['/'<1st80channel>'-'<2nd80channel>]]
*
* <band>:
* (optional) 2, 3, 4, 5 for 2.4GHz, 3GHz, 4GHz, and 5GHz respectively.
* Default value is 2g if channel <= 14, otherwise 5g.
* <channel>:
* channel number of the 5MHz, 10MHz, 20MHz channel,
* or primary channel of 40MHz, 80MHz, 160MHz, or 80+80MHz channel.
* <bandwidth>:
* (optional) 5, 10, 20, 40, 80, 160, or 80+80. Default value is 20.
* <primary-sideband>:
* (only for 2.4GHz band 40MHz) U for upper sideband primary, L for lower.
*
* For 2.4GHz band 40MHz channels, the same primary channel may be the
* upper sideband for one 40MHz channel, and the lower sideband for an
* overlapping 40MHz channel. The U/L disambiguates which 40MHz channel
* is being specified.
*
* For 40MHz in the 5GHz band and all channel bandwidths greater than
* 40MHz, the U/L specificaion is not allowed since the channels are
* non-overlapping and the primary sub-band is derived from its
* position in the wide bandwidth channel.
*
* <1st80Channel>:
* <2nd80Channel>:
* Required for 80+80, otherwise not allowed.
* Specifies the center channel of the first and second 80MHz band.
*
* In its simplest form, it is a 20MHz channel number, with the implied band
* of 2.4GHz if channel number <= 14, and 5GHz otherwise.
*
* To allow for backward compatibility with scripts, the old form for
* 40MHz channels is also allowed: <channel><ctl-sideband>
*
* <channel>:
* primary channel of 40MHz, channel <= 14 is 2GHz, otherwise 5GHz
* <ctl-sideband>:
* "U" for upper, "L" for lower (or lower case "u" "l")
*
* 5 GHz Examples:
* Chanspec BW Center Ch Channel Range Primary Ch
* 5g8 20MHz 8 - -
* 52 20MHz 52 - -
* 52/40 40MHz 54 52-56 52
* 56/40 40MHz 54 52-56 56
* 52/80 80MHz 58 52-64 52
* 56/80 80MHz 58 52-64 56
* 60/80 80MHz 58 52-64 60
* 64/80 80MHz 58 52-64 64
* 52/160 160MHz 50 36-64 52
* 36/160 160MGz 50 36-64 36
* 36/80+80/42-106 80+80MHz 42,106 36-48,100-112 36
*
* 2 GHz Examples:
* Chanspec BW Center Ch Channel Range Primary Ch
* 2g8 20MHz 8 - -
* 8 20MHz 8 - -
* 6 20MHz 6 - -
* 6/40l 40MHz 8 6-10 6
* 6l 40MHz 8 6-10 6
* 6/40u 40MHz 4 2-6 6
* 6u 40MHz 4 2-6 6
*/
/* bandwidth ASCII string */
static const char *wf_chspec_bw_str[] =
{
"5",
"10",
"20",
"40",
"80",
"160",
"80+80",
"na"
};
static const uint8 wf_chspec_bw_mhz[] =
{5, 10, 20, 40, 80, 160, 160};
#define WF_NUM_BW \
(sizeof(wf_chspec_bw_mhz)/sizeof(uint8))
/* 40MHz channels in 5GHz band */
static const uint8 wf_5g_40m_chans[] =
{38, 46, 54, 62, 102, 110, 118, 126, 134, 142, 151, 159};
#define WF_NUM_5G_40M_CHANS \
(sizeof(wf_5g_40m_chans)/sizeof(uint8))
/* 80MHz channels in 5GHz band */
static const uint8 wf_5g_80m_chans[] =
{42, 58, 106, 122, 138, 155};
#define WF_NUM_5G_80M_CHANS \
(sizeof(wf_5g_80m_chans)/sizeof(uint8))
/* 160MHz channels in 5GHz band */
static const uint8 wf_5g_160m_chans[] =
{50, 114};
#define WF_NUM_5G_160M_CHANS \
(sizeof(wf_5g_160m_chans)/sizeof(uint8))
/* convert bandwidth from chanspec to MHz */
static uint
bw_chspec_to_mhz(chanspec_t chspec)
{
uint bw;
bw = (chspec & WL_CHANSPEC_BW_MASK) >> WL_CHANSPEC_BW_SHIFT;
return (bw >= WF_NUM_BW ? 0 : wf_chspec_bw_mhz[bw]);
}
/* bw in MHz, return the channel count from the center channel to the
* the channel at the edge of the band
*/
static uint8
center_chan_to_edge(uint bw)
{
/* edge channels separated by BW - 10MHz on each side
* delta from cf to edge is half of that,
* MHz to channel num conversion is 5MHz/channel
*/
return (uint8)(((bw - 20) / 2) / 5);
}
/* return channel number of the low edge of the band
* given the center channel and BW
*/
static uint8
channel_low_edge(uint center_ch, uint bw)
{
return (uint8)(center_ch - center_chan_to_edge(bw));
}
/* return control channel given center channel and side band */
static uint8
channel_to_ctl_chan(uint center_ch, uint bw, uint sb)
{
return (uint8)(channel_low_edge(center_ch, bw) + sb * 4);
}
/*
* Verify the chanspec is using a legal set of parameters, i.e. that the
* chanspec specified a band, bw, ctl_sb and channel and that the
* combination could be legal given any set of circumstances.
* RETURNS: TRUE is the chanspec is malformed, false if it looks good.
*/
bool
wf_chspec_malformed(chanspec_t chanspec)
{
uint chspec_bw = CHSPEC_BW(chanspec);
uint chspec_ch = CHSPEC_CHANNEL(chanspec);
/* must be 2G or 5G band */
if (CHSPEC_IS2G(chanspec)) {
/* must be valid bandwidth */
if (chspec_bw != WL_CHANSPEC_BW_20 &&
chspec_bw != WL_CHANSPEC_BW_40) {
return TRUE;
}
} else if (CHSPEC_IS5G(chanspec)) {
if (chspec_bw == WL_CHANSPEC_BW_8080) {
uint ch1_id, ch2_id;
/* channel number in 80+80 must be in range */
ch1_id = CHSPEC_CHAN1(chanspec);
ch2_id = CHSPEC_CHAN2(chanspec);
if (ch1_id >= WF_NUM_5G_80M_CHANS || ch2_id >= WF_NUM_5G_80M_CHANS)
return TRUE;
/* ch2 must be above ch1 for the chanspec */
if (ch2_id <= ch1_id)
return TRUE;
} else if (chspec_bw == WL_CHANSPEC_BW_20 || chspec_bw == WL_CHANSPEC_BW_40 ||
chspec_bw == WL_CHANSPEC_BW_80 || chspec_bw == WL_CHANSPEC_BW_160) {
if (chspec_ch > MAXCHANNEL) {
return TRUE;
}
} else {
/* invalid bandwidth */
return TRUE;
}
} else {
/* must be 2G or 5G band */
return TRUE;
}
/* side band needs to be consistent with bandwidth */
if (chspec_bw == WL_CHANSPEC_BW_20) {
if (CHSPEC_CTL_SB(chanspec) != WL_CHANSPEC_CTL_SB_LLL)
return TRUE;
} else if (chspec_bw == WL_CHANSPEC_BW_40) {
if (CHSPEC_CTL_SB(chanspec) > WL_CHANSPEC_CTL_SB_LLU)
return TRUE;
} else if (chspec_bw == WL_CHANSPEC_BW_80) {
if (CHSPEC_CTL_SB(chanspec) > WL_CHANSPEC_CTL_SB_LUU)
return TRUE;
}
return FALSE;
}
/*
* This function returns the channel number that control traffic is being sent on, for 20MHz
* channels this is just the channel number, for 40MHZ, 80MHz, 160MHz channels it is the 20MHZ
* sideband depending on the chanspec selected
*/
uint8
wf_chspec_ctlchan(chanspec_t chspec)
{
uint center_chan;
uint bw_mhz;
uint sb;
if (wf_chspec_malformed(chspec))
return 0;
/* Is there a sideband ? */
if (CHSPEC_IS20(chspec)) {
return CHSPEC_CHANNEL(chspec);
} else {
sb = CHSPEC_CTL_SB(chspec) >> WL_CHANSPEC_CTL_SB_SHIFT;
if (CHSPEC_IS8080(chspec)) {
bw_mhz = 80;
if (sb < 4) {
center_chan = CHSPEC_CHAN1(chspec);
}
else {
center_chan = CHSPEC_CHAN2(chspec);
sb -= 4;
}
/* convert from channel index to channel number */
center_chan = wf_5g_80m_chans[center_chan];
}
else {
bw_mhz = bw_chspec_to_mhz(chspec);
center_chan = CHSPEC_CHANNEL(chspec) >> WL_CHANSPEC_CHAN_SHIFT;
}
return (channel_to_ctl_chan(center_chan, bw_mhz, sb));
}
}
/* given a chanspec and a string buffer, format the chanspec as a
* string, and return the original pointer a.
* Min buffer length must be CHANSPEC_STR_LEN.
* On error return ""
*/
char *
wf_chspec_ntoa(chanspec_t chspec, char *buf)
{
const char *band;
uint ctl_chan;
if (wf_chspec_malformed(chspec))
return "";
band = "";
/* check for non-default band spec */
if ((CHSPEC_IS2G(chspec) && CHSPEC_CHANNEL(chspec) > CH_MAX_2G_CHANNEL) ||
(CHSPEC_IS5G(chspec) && CHSPEC_CHANNEL(chspec) <= CH_MAX_2G_CHANNEL))
band = (CHSPEC_IS2G(chspec)) ? "2g" : "5g";
/* ctl channel */
if (!(ctl_chan = wf_chspec_ctlchan(chspec)))
return "";
/* bandwidth and ctl sideband */
if (CHSPEC_IS20(chspec)) {
snprintf(buf, CHANSPEC_STR_LEN, "%s%d", band, ctl_chan);
} else if (!CHSPEC_IS8080(chspec)) {
const char *bw;
const char *sb = "";
bw = wf_chspec_bw_str[(chspec & WL_CHANSPEC_BW_MASK) >> WL_CHANSPEC_BW_SHIFT];
#ifdef CHANSPEC_NEW_40MHZ_FORMAT
/* ctl sideband string if needed for 2g 40MHz */
if (CHSPEC_IS40(chspec) && CHSPEC_IS2G(chspec)) {
sb = CHSPEC_SB_UPPER(chspec) ? "u" : "l";
}
snprintf(buf, CHANSPEC_STR_LEN, "%s%d/%s%s", band, ctl_chan, bw, sb);
#else
/* ctl sideband string instead of BW for 40MHz */
if (CHSPEC_IS40(chspec)) {
sb = CHSPEC_SB_UPPER(chspec) ? "u" : "l";
snprintf(buf, CHANSPEC_STR_LEN, "%s%d%s", band, ctl_chan, sb);
} else {
snprintf(buf, CHANSPEC_STR_LEN, "%s%d/%s", band, ctl_chan, bw);
}
#endif /* CHANSPEC_NEW_40MHZ_FORMAT */
} else {
/* 80+80 */
uint chan1 = (chspec & WL_CHANSPEC_CHAN1_MASK) >> WL_CHANSPEC_CHAN1_SHIFT;
uint chan2 = (chspec & WL_CHANSPEC_CHAN2_MASK) >> WL_CHANSPEC_CHAN2_SHIFT;
/* convert to channel number */
chan1 = (chan1 < WF_NUM_5G_80M_CHANS) ? wf_5g_80m_chans[chan1] : 0;
chan2 = (chan2 < WF_NUM_5G_80M_CHANS) ? wf_5g_80m_chans[chan2] : 0;
/* Outputs a max of CHANSPEC_STR_LEN chars including '\0' */
snprintf(buf, CHANSPEC_STR_LEN, "%d/80+80/%d-%d", ctl_chan, chan1, chan2);
}
return (buf);
}
#else
/* given a chanspec and a string buffer, format the chanspec as a
* string, and return the original pointer a.
* Min buffer length must be CHANSPEC_STR_LEN.
* On error return NULL
*/
char *
wf_chspec_ntoa(chanspec_t chspec, char *buf)
{
const char *band, *bw, *sb;
uint channel;
band = "";
bw = "";
sb = "";
channel = CHSPEC_CHANNEL(chspec);
/* check for non-default band spec */
if ((CHSPEC_IS2G(chspec) && channel > CH_MAX_2G_CHANNEL) ||
(CHSPEC_IS5G(chspec) && channel <= CH_MAX_2G_CHANNEL))
band = (CHSPEC_IS2G(chspec)) ? "b" : "a";
if (CHSPEC_IS40(chspec)) {
if (CHSPEC_SB_UPPER(chspec)) {
sb = "u";
channel += CH_10MHZ_APART;
} else {
sb = "l";
channel -= CH_10MHZ_APART;
}
} else if (CHSPEC_IS10(chspec)) {
bw = "n";
}
/* Outputs a max of 6 chars including '\0' */
snprintf(buf, 6, "%d%s%s%s", channel, band, bw, sb);
return (buf);
}
#endif
static int
wlu_bcmp(const void *b1, const void *b2, int len)
{
return (memcmp(b1, b2, len));
}
/*
* Traverse a string of 1-byte tag/1-byte length/variable-length value
* triples, returning a pointer to the substring whose first element
* matches tag
*/
static uint8 *
wlu_parse_tlvs(uint8 *tlv_buf, int buflen, uint key)
{
uint8 *cp;
int totlen;
cp = tlv_buf;
totlen = buflen;
/* find tagged parameter */
while (totlen >= 2) {
uint tag;
int len;
tag = *cp;
len = *(cp +1);
/* validate remaining totlen */
if ((tag == key) && (totlen >= (len + 2)))
return (cp);
cp += (len + 2);
totlen -= (len + 2);
}
return NULL;
}
/* Is this body of this tlvs entry a WPA entry? If */
/* not update the tlvs buffer pointer/length */
static bool
wlu_is_wpa_ie(uint8 **wpaie, uint8 **tlvs, uint *tlvs_len)
{
uint8 *ie = *wpaie;
/* If the contents match the WPA_OUI and type=1 */
if ((ie[1] >= 6) && !wlu_bcmp(&ie[2], WPA_OUI "\x01", 4)) {
return TRUE;
}
/* point to the next ie */
ie += ie[1] + 2;
/* calculate the length of the rest of the buffer */
*tlvs_len -= (int)(ie - *tlvs);
/* update the pointer to the start of the buffer */
*tlvs = ie;
return FALSE;
}
/* Validates and parses the RSN or WPA IE contents into a rsn_parse_info_t structure
* Returns 0 on success, or 1 if the information in the buffer is not consistant with
* an RSN IE or WPA IE.
* The buf pointer passed in should be pointing at the version field in either an RSN IE
* or WPA IE.
*/
static int
wl_rsn_ie_parse_info(uint8* rsn_buf, uint len, rsn_parse_info_t *rsn)
{
uint16 count;
memset(rsn, 0, sizeof(rsn_parse_info_t));
/* version */
if (len < sizeof(uint16))
return 1;
rsn->version = ltoh16_ua(rsn_buf);
len -= sizeof(uint16);
rsn_buf += sizeof(uint16);
/* Multicast Suite */
if (len < sizeof(wpa_suite_mcast_t))
return 0;
rsn->mcast = (wpa_suite_mcast_t*)rsn_buf;
len -= sizeof(wpa_suite_mcast_t);
rsn_buf += sizeof(wpa_suite_mcast_t);
/* Unicast Suite */
if (len < sizeof(uint16))
return 0;
count = ltoh16_ua(rsn_buf);
if (len < (sizeof(uint16) + count * sizeof(wpa_suite_t)))
return 1;
rsn->ucast = (wpa_suite_ucast_t*)rsn_buf;
len -= (sizeof(uint16) + count * sizeof(wpa_suite_t));
rsn_buf += (sizeof(uint16) + count * sizeof(wpa_suite_t));
/* AKM Suite */
if (len < sizeof(uint16))
return 0;
count = ltoh16_ua(rsn_buf);
if (len < (sizeof(uint16) + count * sizeof(wpa_suite_t)))
return 1;
rsn->akm = (wpa_suite_auth_key_mgmt_t*)rsn_buf;
len -= (sizeof(uint16) + count * sizeof(wpa_suite_t));
rsn_buf += (sizeof(uint16) + count * sizeof(wpa_suite_t));
/* Capabilites */
if (len < sizeof(uint16))
return 0;
rsn->capabilities = rsn_buf;
return 0;
}
static uint
wl_rsn_ie_decode_cntrs(uint cntr_field)
{
uint cntrs;
switch (cntr_field) {
case RSN_CAP_1_REPLAY_CNTR:
cntrs = 1;
break;
case RSN_CAP_2_REPLAY_CNTRS:
cntrs = 2;
break;
case RSN_CAP_4_REPLAY_CNTRS:
cntrs = 4;
break;
case RSN_CAP_16_REPLAY_CNTRS:
cntrs = 16;
break;
default:
cntrs = 0;
break;
}
return cntrs;
}
static int
wl_rsn_ie_dump(int eid, webs_t wp, int argc, char_t **argv, bcm_tlv_t *ie)
{
int i;
int rsn;
wpa_ie_fixed_t *wpa = NULL;
rsn_parse_info_t rsn_info;
wpa_suite_t *suite;
uint8 std_oui[3];
int unicast_count = 0;
int akm_count = 0;
uint16 capabilities;
uint cntrs;
int err;
int retval = 0;
if (ie->id == DOT11_MNG_RSN_ID) {
rsn = TRUE;
memcpy(std_oui, WPA2_OUI, WPA_OUI_LEN);
err = wl_rsn_ie_parse_info(ie->data, ie->len, &rsn_info);
} else {
rsn = FALSE;
memcpy(std_oui, WPA_OUI, WPA_OUI_LEN);
wpa = (wpa_ie_fixed_t*)ie;
err = wl_rsn_ie_parse_info((uint8*)&wpa->version, wpa->length - WPA_IE_OUITYPE_LEN,
&rsn_info);
}
if (err || rsn_info.version != WPA_VERSION)
return retval;
if (rsn)
retval += websWrite(wp, "RSN:\n");
else
retval += websWrite(wp, "WPA:\n");
/* Check for multicast suite */
if (rsn_info.mcast) {
retval += websWrite(wp, "\tmulticast cipher: ");
if (!wlu_bcmp(rsn_info.mcast->oui, std_oui, 3)) {
switch (rsn_info.mcast->type) {
case WPA_CIPHER_NONE:
retval += websWrite(wp, "NONE\n");
break;
case WPA_CIPHER_WEP_40:
retval += websWrite(wp, "WEP64\n");
break;
case WPA_CIPHER_WEP_104:
retval += websWrite(wp, "WEP128\n");
break;
case WPA_CIPHER_TKIP:
retval += websWrite(wp, "TKIP\n");
break;
case WPA_CIPHER_AES_OCB:
retval += websWrite(wp, "AES-OCB\n");
break;
case WPA_CIPHER_AES_CCM:
retval += websWrite(wp, "AES-CCMP\n");
break;
default:
retval += websWrite(wp, "Unknown-%s(#%d)\n", rsn ? "RSN" : "WPA",
rsn_info.mcast->type);
break;
}
}
else {
retval += websWrite(wp, "Unknown-%02X:%02X:%02X(#%d) ",
rsn_info.mcast->oui[0], rsn_info.mcast->oui[1],
rsn_info.mcast->oui[2], rsn_info.mcast->type);
}
}
/* Check for unicast suite(s) */
if (rsn_info.ucast) {
unicast_count = ltoh16_ua(&rsn_info.ucast->count);
retval += websWrite(wp, "\tunicast ciphers(%d): ", unicast_count);
for (i = 0; i < unicast_count; i++) {
suite = &rsn_info.ucast->list[i];
if (!wlu_bcmp(suite->oui, std_oui, 3)) {
switch (suite->type) {
case WPA_CIPHER_NONE:
retval += websWrite(wp, "NONE ");
break;
case WPA_CIPHER_WEP_40:
retval += websWrite(wp, "WEP64 ");
break;
case WPA_CIPHER_WEP_104:
retval += websWrite(wp, "WEP128 ");
break;
case WPA_CIPHER_TKIP:
retval += websWrite(wp, "TKIP ");
break;
case WPA_CIPHER_AES_OCB:
retval += websWrite(wp, "AES-OCB ");
break;
case WPA_CIPHER_AES_CCM:
retval += websWrite(wp, "AES-CCMP ");
break;
default:
retval += websWrite(wp, "WPA-Unknown-%s(#%d) ", rsn ? "RSN" : "WPA",
suite->type);
break;
}
}
else {
retval += websWrite(wp, "Unknown-%02X:%02X:%02X(#%d) ",
suite->oui[0], suite->oui[1], suite->oui[2],
suite->type);
}
}
retval += websWrite(wp, "\n");
}
/* Authentication Key Management */
if (rsn_info.akm) {
akm_count = ltoh16_ua(&rsn_info.akm->count);
retval += websWrite(wp, "\tAKM Suites(%d): ", akm_count);
for (i = 0; i < akm_count; i++) {
suite = &rsn_info.akm->list[i];
if (!wlu_bcmp(suite->oui, std_oui, 3)) {
switch (suite->type) {
case RSN_AKM_NONE:
retval += websWrite(wp, "None ");
break;
case RSN_AKM_UNSPECIFIED:
retval += websWrite(wp, "WPA ");
break;
case RSN_AKM_PSK:
retval += websWrite(wp, "WPA-PSK ");
break;
default:
retval += websWrite(wp, "Unknown-%s(#%d) ",
rsn ? "RSN" : "WPA", suite->type);
break;
}
}
else {
retval += websWrite(wp, "Unknown-%02X:%02X:%02X(#%d) ",
suite->oui[0], suite->oui[1], suite->oui[2],
suite->type);
}
}
retval += websWrite(wp, "\n");
}
/* Capabilities */
if (rsn_info.capabilities) {
capabilities = ltoh16_ua(rsn_info.capabilities);
retval += websWrite(wp, "\tCapabilities(0x%04x): ", capabilities);
if (rsn)
retval += websWrite(wp, "%sPre-Auth, ", (capabilities & RSN_CAP_PREAUTH) ? "" : "No ");
retval += websWrite(wp, "%sPairwise, ", (capabilities & RSN_CAP_NOPAIRWISE) ? "No " : "");
cntrs = wl_rsn_ie_decode_cntrs((capabilities & RSN_CAP_PTK_REPLAY_CNTR_MASK) >>
RSN_CAP_PTK_REPLAY_CNTR_SHIFT);
retval += websWrite(wp, "%d PTK Replay Ctr%s", cntrs, (cntrs > 1)?"s":"");
if (rsn) {
cntrs = wl_rsn_ie_decode_cntrs(
(capabilities & RSN_CAP_GTK_REPLAY_CNTR_MASK) >>
RSN_CAP_GTK_REPLAY_CNTR_SHIFT);
retval += websWrite(wp, "%d GTK Replay Ctr%s\n", cntrs, (cntrs > 1)?"s":"");
} else {
retval += websWrite(wp, "\n");
}
} else {
retval += websWrite(wp, "\tNo %s Capabilities advertised\n", rsn ? "RSN" : "WPA");
}
return retval;
}
static int
wl_dump_wpa_rsn_ies(int eid, webs_t wp, int argc, char_t **argv, uint8* cp, uint len)
{
uint8 *parse = cp;
uint parse_len = len;
uint8 *wpaie;
uint8 *rsnie;
int retval = 0;
while ((wpaie = wlu_parse_tlvs(parse, parse_len, DOT11_MNG_WPA_ID)))
if (wlu_is_wpa_ie(&wpaie, &parse, &parse_len))
break;
if (wpaie)
retval += wl_rsn_ie_dump(eid, wp, argc, argv, (bcm_tlv_t*)wpaie);
rsnie = wlu_parse_tlvs(cp, len, DOT11_MNG_RSN_ID);
if (rsnie)
retval += wl_rsn_ie_dump(eid, wp, argc, argv, (bcm_tlv_t*)rsnie);
return retval;
}
int
wl_format_ssid(char* ssid_buf, uint8* ssid, int ssid_len)
{
int i, c;
char *p = ssid_buf;
if (ssid_len > 32) ssid_len = 32;
for (i = 0; i < ssid_len; i++) {
c = (int)ssid[i];
if (c == '\\') {
*p++ = '\\';
// *p++ = '\\';
} else if (isprint((uchar)c)) {
*p++ = (char)c;
} else {
p += sprintf(p, "\\x%02X", c);
}
}
*p = '\0';
return p - ssid_buf;
}
#ifdef RTCONFIG_BCMWL6
static int
bcm_wps_version(webs_t wp, uint8 *wps_ie)
{
uint16 wps_len;
uint16 wps_off, wps_suboff;
uint16 wps_key;
uint8 wps_field_len;
int retval = 0;
wps_len = (uint16)*(wps_ie+TLV_LEN_OFF);/* Get the length of the WPS OUI header */
wps_off = WPS_OUI_FIXED_HEADER_OFF; /* Skip the fixed headers */
wps_field_len = 1;
/* Parsing the OUI header looking for version number */
while ((wps_len >= wps_off + 2) && (wps_field_len))
{
wps_key = (((uint8)wps_ie[wps_off]*256) + (uint8)wps_ie[wps_off+1]);
if (wps_key == WPS_ID_VENDOR_EXT) {
/* Key found */
wps_suboff = wps_off + WPS_OUI_HEADER_SIZE;
/* Looking for the Vendor extension code 0x00 0x37 0x2A
* and the Version 2 sudId 0x00
* if found then the next byte is the len of field which is always 1
* for version field the byte after is the version number
*/
if (!wlu_bcmp(&wps_ie[wps_suboff], WFA_VENDOR_EXT_ID, WPS_OUI_LEN)&&
(wps_ie[wps_suboff+WPS_WFA_SUBID_V2_OFF] == WPS_WFA_SUBID_VERSION2))
{
retval += websWrite(wp, "V%d.%d ", (wps_ie[wps_suboff+WPS_WFA_V2_OFF]>>4),
(wps_ie[wps_suboff+WPS_WFA_V2_OFF] & 0x0f));
return retval;
}
}
/* Jump to next field */
wps_field_len = wps_ie[wps_off+WPS_OUI_HEADER_LEN+1];
wps_off += WPS_OUI_HEADER_SIZE + wps_field_len;
}
/* If nothing found from the parser then this is the WPS version 1.0 */
retval += websWrite(wp, "V1.0 ");
return retval;
}
static int
bcm_is_wps_configured(webs_t wp, uint8 *wps_ie)
{
uint16 wps_key;
int retval = 0;
wps_key = (wps_ie[WPS_SCSTATE_OFF]*256) + wps_ie[WPS_SCSTATE_OFF+1];
if ((wps_ie[TLV_LEN_OFF] > (WPS_SCSTATE_OFF+5))&&
(wps_key == WPS_ID_SC_STATE))
{
switch (wps_ie[WPS_SCSTATE_OFF+WPS_OUI_HEADER_SIZE])
{
case WPS_SCSTATE_UNCONFIGURED:
retval += websWrite(wp, "Unconfigured\n");
break;
case WPS_SCSTATE_CONFIGURED:
retval += websWrite(wp, "Configured\n");
break;
default:
retval += websWrite(wp, "Unknown State\n");
}
}
return retval;
}
/* Looking for WPS OUI in the propriatary_ie */
static bool
bcm_is_wps_ie(uint8 *ie, uint8 **tlvs, uint32 *tlvs_len)
{
bool retval = FALSE;
/* If the contents match the WPS_OUI and type=4 */
if ((ie[TLV_LEN_OFF] > (WPS_OUI_LEN+1)) &&
!wlu_bcmp(&ie[TLV_BODY_OFF], WPS_OUI "\x04", WPS_OUI_LEN + 1)) {
retval = TRUE;
}
/* point to the next ie */
ie += ie[TLV_LEN_OFF] + TLV_HDR_LEN;
/* calculate the length of the rest of the buffer */
*tlvs_len -= (int)(ie - *tlvs);
/* update the pointer to the start of the buffer */
*tlvs = ie;
return retval;
}
static int
wl_dump_wps(webs_t wp, uint8* cp, uint len)
{
uint8 *parse = cp;
uint32 parse_len = len;
uint8 *proprietary_ie;
int retval = 0;
while ((proprietary_ie = wlu_parse_tlvs(parse, parse_len, DOT11_MNG_WPA_ID))) {
if (bcm_is_wps_ie(proprietary_ie, &parse, &parse_len)) {
/* Print WPS status */
retval += websWrite(wp, "WPS: ");
/* Print the version get from vendor extension field */
retval += bcm_wps_version(wp, proprietary_ie);
/* Print the WPS configure or Unconfigure option */
retval += bcm_is_wps_configured(wp, proprietary_ie);
break;
}
}
return retval;
}
static chanspec_t
wl_chspec_from_driver(chanspec_t chanspec)
{
chanspec = dtohchanspec(chanspec);
/*
if (ioctl_version == 1) {
chanspec = wl_chspec_from_legacy(chanspec);
}
*/
return chanspec;
}
#ifdef RTCONFIG_BCM_7114
#define VHT_PROP_MCS_MAP_NONE 3
#endif
#endif
static int
dump_bss_info(int eid, webs_t wp, int argc, char_t **argv, wl_bss_info_t *bi)
{
char ssidbuf[SSID_FMT_BUF_LEN];
char chspec_str[CHANSPEC_STR_LEN];
wl_bss_info_107_t *old_bi;
#ifndef RTCONFIG_QTN
int mcs_idx = 0;
#endif
int retval = 0;
/* Convert version 107 to 109 */
if (dtoh32(bi->version) == LEGACY_WL_BSS_INFO_VERSION) {
old_bi = (wl_bss_info_107_t *)bi;
bi->chanspec = CH20MHZ_CHSPEC(old_bi->channel);
bi->ie_length = old_bi->ie_length;
bi->ie_offset = sizeof(wl_bss_info_107_t);
#ifdef RTCONFIG_BCMWL6
} else {
/* do endian swap and format conversion for chanspec if we have
* not created it from legacy bi above
*/
bi->chanspec = wl_chspec_from_driver(bi->chanspec);
#endif
}
wl_format_ssid(ssidbuf, bi->SSID, bi->SSID_len);
retval += websWrite(wp, "SSID: \"%s\"\n", ssidbuf);
// retval += websWrite(wp, "Mode: %s\t", capmode2str(dtoh16(bi->capability)));
retval += websWrite(wp, "RSSI: %d dBm\t", (int16)(dtoh16(bi->RSSI)));
/*
* SNR has valid value in only 109 version.
* So print SNR for 109 version only.
*/
if (dtoh32(bi->version) == WL_BSS_INFO_VERSION) {
retval += websWrite(wp, "SNR: %d dB\t", (int16)(dtoh16(bi->SNR)));
}
retval += websWrite(wp, "noise: %d dBm\t", bi->phy_noise);
if (bi->flags) {
bi->flags = dtoh16(bi->flags);
retval += websWrite(wp, "Flags: ");
if (bi->flags & WL_BSS_FLAGS_FROM_BEACON) retval += websWrite(wp, "FromBcn ");
if (bi->flags & WL_BSS_FLAGS_FROM_CACHE) retval += websWrite(wp, "Cached ");
if (bi->flags & WL_BSS_FLAGS_RSSI_ONCHANNEL) retval += websWrite(wp, "RSSI on-channel ");
retval += websWrite(wp, "\t");
}
retval += websWrite(wp, "Channel: %s\n", wf_chspec_ntoa(dtohchanspec(bi->chanspec), chspec_str));
retval += websWrite(wp, "BSSID: %s\t", wl_ether_etoa(&bi->BSSID));
#ifndef RTCONFIG_QTN
retval += websWrite(wp, "Capability: ");
bi->capability = dtoh16(bi->capability);
if (bi->capability & DOT11_CAP_ESS) retval += websWrite(wp, "ESS ");
if (bi->capability & DOT11_CAP_IBSS) retval += websWrite(wp, "IBSS ");
if (bi->capability & DOT11_CAP_POLLABLE) retval += websWrite(wp, "Pollable ");
if (bi->capability & DOT11_CAP_POLL_RQ) retval += websWrite(wp, "PollReq ");
if (bi->capability & DOT11_CAP_PRIVACY) retval += websWrite(wp, "WEP ");
if (bi->capability & DOT11_CAP_SHORT) retval += websWrite(wp, "ShortPre ");
if (bi->capability & DOT11_CAP_PBCC) retval += websWrite(wp, "PBCC ");
if (bi->capability & DOT11_CAP_AGILITY) retval += websWrite(wp, "Agility ");
if (bi->capability & DOT11_CAP_SHORTSLOT) retval += websWrite(wp, "ShortSlot ");
if (bi->capability & DOT11_CAP_CCK_OFDM) retval += websWrite(wp, "CCK-OFDM ");
#endif
retval += websWrite(wp, "\n");
retval += websWrite(wp, "Supported Rates: ");
retval += dump_rateset(eid, wp, argc, argv, bi->rateset.rates, dtoh32(bi->rateset.count));
retval += websWrite(wp, "\n");
if (dtoh32(bi->ie_length))
retval += wl_dump_wpa_rsn_ies(eid, wp, argc, argv, (uint8 *)(((uint8 *)bi) + dtoh16(bi->ie_offset)),
dtoh32(bi->ie_length));
#ifndef RTCONFIG_QTN
if (dtoh32(bi->version) != LEGACY_WL_BSS_INFO_VERSION && bi->n_cap) {
#ifdef RTCONFIG_BCMWL6
if (bi->vht_cap)
retval += websWrite(wp, "VHT Capable:\n");
else
retval += websWrite(wp, "HT Capable:\n");
retval += websWrite(wp, "\tChanspec: %sGHz channel %d %dMHz (0x%x)\n",
CHSPEC_IS2G(bi->chanspec)?"2.4":"5", CHSPEC_CHANNEL(bi->chanspec),
(CHSPEC_IS80(bi->chanspec) ?
80 : (CHSPEC_IS40(bi->chanspec) ?
40 : (CHSPEC_IS20(bi->chanspec) ? 20 : 10))),
bi->chanspec);
retval += websWrite(wp, "\tPrimary channel: %d\n", bi->ctl_ch);
retval += websWrite(wp, "\tHT Capabilities: ");
#else
retval += websWrite(wp, "802.11N Capable:\n");
bi->chanspec = dtohchanspec(bi->chanspec);
retval += websWrite(wp, "\tChanspec: %sGHz channel %d %dMHz (0x%x)\n",
CHSPEC_IS2G(bi->chanspec)?"2.4":"5", CHSPEC_CHANNEL(bi->chanspec),
CHSPEC_IS40(bi->chanspec) ? 40 : (CHSPEC_IS20(bi->chanspec) ? 20 : 10),
bi->chanspec);
retval += websWrite(wp, "\tControl channel: %d\n", bi->ctl_ch);
retval += websWrite(wp, "\t802.11N Capabilities: ");
#endif
if (dtoh32(bi->nbss_cap) & HT_CAP_40MHZ)
retval += websWrite(wp, "40Mhz ");
if (dtoh32(bi->nbss_cap) & HT_CAP_SHORT_GI_20)
retval += websWrite(wp, "SGI20 ");
if (dtoh32(bi->nbss_cap) & HT_CAP_SHORT_GI_40)
retval += websWrite(wp, "SGI40 ");
retval += websWrite(wp, "\n\tSupported MCS : [ ");
for (mcs_idx = 0; mcs_idx < (MCSSET_LEN * 8); mcs_idx++)
if (isset(bi->basic_mcs, mcs_idx))
retval += websWrite(wp, "%d ", mcs_idx);
retval += websWrite(wp, "]\n");
#ifdef RTCONFIG_BCMWL6
if (bi->vht_cap) {
int i;
uint mcs;
#ifdef RTCONFIG_BCM_7114
uint prop_mcs = VHT_PROP_MCS_MAP_NONE;
#endif
retval += websWrite(wp, "\tVHT Capabilities: \n");
retval += websWrite(wp, "\tSupported VHT (tx) Rates:\n");
for (i = 1; i <= VHT_CAP_MCS_MAP_NSS_MAX; i++) {
mcs = VHT_MCS_MAP_GET_MCS_PER_SS(i, dtoh16(bi->vht_txmcsmap));
#ifdef RTCONFIG_BCM_7114
if (dtoh16(bi->length) >= (OFFSETOF(wl_bss_info_t,
vht_txmcsmap_prop) +
ROUNDUP(dtoh32(bi->ie_length), 4) +
sizeof(uint16))) {
prop_mcs = VHT_MCS_MAP_GET_MCS_PER_SS(i,
dtoh16(bi->vht_txmcsmap_prop));
}
#endif
if (mcs != VHT_CAP_MCS_MAP_NONE){
#ifdef RTCONFIG_BCM_7114
if (prop_mcs != VHT_PROP_MCS_MAP_NONE)
retval += websWrite(wp, "\t\tNSS: %d MCS: %s\n", i,
(mcs == VHT_CAP_MCS_MAP_0_9 ? "0-11" :
(mcs == VHT_CAP_MCS_MAP_0_8 ? "0-8, 10-11" : "0-7, 10-11")));
else
#endif
retval += websWrite(wp, "\t\tNSS: %d MCS: %s\n", i,
(mcs == VHT_CAP_MCS_MAP_0_9 ? "0-9" :
(mcs == VHT_CAP_MCS_MAP_0_8 ? "0-8" : "0-7")));
}
}
retval += websWrite(wp, "\tSupported VHT (rx) Rates:\n");
for (i = 1; i <= VHT_CAP_MCS_MAP_NSS_MAX; i++) {
mcs = VHT_MCS_MAP_GET_MCS_PER_SS(i, dtoh16(bi->vht_rxmcsmap));
#ifdef RTCONFIG_BCM_7114
if (dtoh16(bi->length) >= (OFFSETOF(wl_bss_info_t,
vht_txmcsmap_prop) +
ROUNDUP(dtoh32(bi->ie_length), 4) +
sizeof(uint16))) {
prop_mcs = VHT_MCS_MAP_GET_MCS_PER_SS(i,
dtoh16(bi->vht_txmcsmap_prop));
}
#endif
if (mcs != VHT_CAP_MCS_MAP_NONE)
#ifdef RTCONFIG_BCM_7114
if (prop_mcs != VHT_PROP_MCS_MAP_NONE)
retval += websWrite(wp, "\t\tNSS: %d MCS: %s\n", i,
(mcs == VHT_CAP_MCS_MAP_0_9 ? "0-11" :
(mcs == VHT_CAP_MCS_MAP_0_8 ? "0-8, 10-11" : "0-7, 10-11")));
else
#endif
retval += websWrite(wp, "\t\tNSS: %d MCS: %s\n", i,
(mcs == VHT_CAP_MCS_MAP_0_9 ? "0-9" :
(mcs == VHT_CAP_MCS_MAP_0_8 ? "0-8" : "0-7")));
}
}
#endif
}
#endif
#ifdef RTCONFIG_BCMWL6
if (dtoh32(bi->ie_length))
{
retval += wl_dump_wps(wp, (uint8 *)(((uint8 *)bi) + dtoh16(bi->ie_offset)),
dtoh32(bi->ie_length));
}
#endif
retval += websWrite(wp, "\n");
return retval;
}
static int
wl_status(int eid, webs_t wp, int argc, char_t **argv, int unit)
{
int ret;
struct ether_addr bssid;
wlc_ssid_t ssid;
char ssidbuf[SSID_FMT_BUF_LEN];
wl_bss_info_t *bi;
int retval = 0;
char tmp[128], prefix[] = "wlXXXXXXXXXX_";
char *name;
snprintf(prefix, sizeof(prefix), "wl%d_", unit);
name = nvram_safe_get(strcat_r(prefix, "ifname", tmp));
if ((ret = wl_ioctl(name, WLC_GET_BSSID, &bssid, ETHER_ADDR_LEN)) == 0) {
/* The adapter is associated. */
*(uint32*)buf = htod32(WLC_IOCTL_MAXLEN);
if ((ret = wl_ioctl(name, WLC_GET_BSS_INFO, buf, WLC_IOCTL_MAXLEN)) < 0)
return 0;
bi = (wl_bss_info_t*)(buf + 4);
if (dtoh32(bi->version) == WL_BSS_INFO_VERSION ||
dtoh32(bi->version) == LEGACY2_WL_BSS_INFO_VERSION ||
dtoh32(bi->version) == LEGACY_WL_BSS_INFO_VERSION)
retval += dump_bss_info(eid, wp, argc, argv, bi);
else
retval += websWrite(wp, "Sorry, your driver has bss_info_version %d "
"but this program supports only version %d.\n",
bi->version, WL_BSS_INFO_VERSION);
} else {
retval += websWrite(wp, "Not associated. Last associated with ");
if ((ret = wl_ioctl(name, WLC_GET_SSID, &ssid, sizeof(wlc_ssid_t))) < 0) {
retval += websWrite(wp, "\n");
return 0;
}
wl_format_ssid(ssidbuf, ssid.SSID, dtoh32(ssid.SSID_len));
retval += websWrite(wp, "SSID: \"%s\"\n", ssidbuf);
}
return retval;
}
sta_info_t *
wl_sta_info(char *ifname, struct ether_addr *ea)
{
static char buf[sizeof(sta_info_t)];
sta_info_t *sta = NULL;
strcpy(buf, "sta_info");
memcpy(buf + strlen(buf) + 1, (void *)ea, ETHER_ADDR_LEN);
if (!wl_ioctl(ifname, WLC_GET_VAR, buf, sizeof(buf))) {
sta = (sta_info_t *)buf;
sta->ver = dtoh16(sta->ver);
/* Report unrecognized version */
if (sta->ver > WL_STA_VER) {
dbg(" ERROR: unknown driver station info version %d\n", sta->ver);
return NULL;
}
sta->len = dtoh16(sta->len);
sta->cap = dtoh16(sta->cap);
#ifdef RTCONFIG_BCMARM
sta->aid = dtoh16(sta->aid);
#endif
sta->flags = dtoh32(sta->flags);
sta->idle = dtoh32(sta->idle);
sta->rateset.count = dtoh32(sta->rateset.count);
sta->in = dtoh32(sta->in);
sta->listen_interval_inms = dtoh32(sta->listen_interval_inms);
#ifdef RTCONFIG_BCMARM
sta->ht_capabilities = dtoh16(sta->ht_capabilities);
sta->vht_flags = dtoh16(sta->vht_flags);
#endif
}
return sta;
}
char *
print_rate_buf(int raw_rate, char *buf)
{
if (!buf) return NULL;
if (raw_rate == -1) sprintf(buf, " ");
else if ((raw_rate % 1000) == 0)
sprintf(buf, "%6dM ", raw_rate / 1000);
else
sprintf(buf, "%6.1fM ", (double) raw_rate / 1000);
return buf;
}
char *
print_rate_buf_compact(int raw_rate, char *buf)
{
if (!buf) return NULL;
if (raw_rate == -1)
sprintf(buf, " ");
else if ((raw_rate % 1000) == 0)
sprintf(buf, "%d", raw_rate / 1000);
else
sprintf(buf, "%.1f", (double) raw_rate / 1000);
return buf;
}
int wl_control_channel(int unit);
#ifdef RTCONFIG_QTN
extern int wl_status_5g(int eid, webs_t wp, int argc, char_t **argv);
extern int ej_wl_status_5g(int eid, webs_t wp, int argc, char_t **argv);
#endif
int
ej_wl_status(int eid, webs_t wp, int argc, char_t **argv, int unit)
{
char tmp[128], prefix[] = "wlXXXXXXXXXX_";
char *name;
char name_vif[] = "wlX.Y_XXXXXXXXXX";
struct maclist *auth = NULL;
int mac_list_size;
int i, ii, val = 0, ret = 0;
char ea[ETHER_ADDR_STR_LEN];
scb_val_t scb_val;
char rate_buf[8];
int hr, min, sec;
sta_info_t *sta;
snprintf(prefix, sizeof(prefix), "wl%d_", unit);
#ifdef RTCONFIG_PROXYSTA
if (psta_exist_except(unit))
{
ret += websWrite(wp, "%s radio is disabled\n",
(wl_control_channel(unit) > 0) ?
((wl_control_channel(unit) > CH_MAX_2G_CHANNEL) ? "5 GHz" : "2.4 GHz") :
(nvram_match(strcat_r(prefix, "nband", tmp), "1") ? "5 GHz" : "2.4 GHz"));
return ret;
}
#endif
name = nvram_safe_get(strcat_r(prefix, "ifname", tmp));
#ifdef RTCONFIG_QTN
if (unit && rpc_qtn_ready())
{
ret = qcsapi_wifi_rfstatus((qcsapi_unsigned_int *) &val);
if (ret < 0)
dbG("qcsapi_wifi_rfstatus error, return: %d\n", ret);
else
val = !val;
}
else
#endif
{
wl_ioctl(name, WLC_GET_RADIO, &val, sizeof(val));
val &= WL_RADIO_SW_DISABLE | WL_RADIO_HW_DISABLE;
}
#ifdef RTCONFIG_QTN
if (unit && !rpc_qtn_ready())
{
ret += websWrite(wp, "5 GHz radio is not ready\n");
return ret;
}
else
#endif
if (val)
{
ret += websWrite(wp, "%s radio is disabled\n",
(wl_control_channel(unit) > 0) ?
((wl_control_channel(unit) > CH_MAX_2G_CHANNEL) ? "5 GHz" : "2.4 GHz") :
(nvram_match(strcat_r(prefix, "nband", tmp), "1") ? "5 GHz" : "2.4 GHz"));
return ret;
}
if (nvram_match(strcat_r(prefix, "mode", tmp), "wds")) {
// dump static info only for wds mode:
// ret += websWrite(wp, "SSID: %s\n", nvram_safe_get(strcat_r(prefix, "ssid", tmp)));
ret += websWrite(wp, "Channel: %d\n", wl_control_channel(unit));
}
else {
#ifdef RTCONFIG_QTN
if (unit)
ret += wl_status_5g(eid, wp, argc, argv);
else
#endif
ret += wl_status(eid, wp, argc, argv, unit);
}
if (nvram_match(strcat_r(prefix, "mode", tmp), "ap"))
{
if (nvram_match(strcat_r(prefix, "lazywds", tmp), "1") ||
nvram_invmatch(strcat_r(prefix, "wds", tmp), ""))
ret += websWrite(wp, "Mode : Hybrid\n");
else ret += websWrite(wp, "Mode : AP Only\n");
}
else if (nvram_match(strcat_r(prefix, "mode", tmp), "wds"))
{
ret += websWrite(wp, "Mode : WDS Only\n");
return ret;
}
else if (nvram_match(strcat_r(prefix, "mode", tmp), "sta"))
{
ret += websWrite(wp, "Mode : Stations\n");
ret += ej_wl_sta_status(eid, wp, name);
return ret;
}
else if (nvram_match(strcat_r(prefix, "mode", tmp), "wet"))
{
// ret += websWrite(wp, "Mode : Ethernet Bridge\n");
#ifdef RTCONFIG_WIRELESSREPEATER
if ((nvram_get_int("sw_mode") == SW_MODE_REPEATER)
&& (nvram_get_int("wlc_band") == unit))
sprintf(prefix, "wl%d.%d_", unit, 1);
#endif
ret += websWrite(wp, "Mode : Repeater [ SSID local: \"%s\" ]\n", nvram_safe_get(strcat_r(prefix, "ssid", tmp)));
// ret += ej_wl_sta_status(eid, wp, name);
// return ret;
}
#ifdef RTCONFIG_PROXYSTA
else if (nvram_match(strcat_r(prefix, "mode", tmp), "psta"))
{
if ((nvram_get_int("sw_mode") == SW_MODE_AP) &&
(nvram_get_int("wlc_psta") == 1) &&
(nvram_get_int("wlc_band") == unit))
ret += websWrite(wp, "Mode : Media Bridge\n");
}
#endif
#ifdef RTCONFIG_QTN
if (unit && rpc_qtn_ready())
{
ret += ej_wl_status_5g(eid, wp, argc, argv);
return ret;
}
#endif
#ifdef RTCONFIG_WIRELESSREPEATER
if ((nvram_get_int("sw_mode") == SW_MODE_REPEATER)
&& (nvram_get_int("wlc_band") == unit))
{
sprintf(name_vif, "wl%d.%d", unit, 1);
name = name_vif;
}
#endif
if (!strlen(name))
goto exit;
/* buffers and length */
mac_list_size = sizeof(auth->count) + MAX_STA_COUNT * sizeof(struct ether_addr);
auth = malloc(mac_list_size);
if (!auth)
goto exit;
memset(auth, 0, mac_list_size);
/* query wl for authenticated sta list */
strcpy((char*)auth, "authe_sta_list");
if (wl_ioctl(name, WLC_GET_VAR, auth, mac_list_size))
goto exit;
ret += websWrite(wp, "\n");
ret += websWrite(wp, "Stations List \n");
ret += websWrite(wp, "----------------------------------------\n");
#ifdef RTCONFIG_BCMARM
#ifndef RTCONFIG_QTN
#ifdef RTCONFIG_MUMIMO
ret += websWrite(wp, "%-4s%-18s%-11s%-11s%-8s%-4s%-4s%-5s%-5s%-8s%-8s%-12s\n",
"idx", "MAC", "Associated", "Authorized", " RSSI", "PSM", "SGI", "STBC", "MUBF", "Tx rate", "Rx rate", "Connect Time");
#else
ret += websWrite(wp, "%-4s%-18s%-11s%-11s%-8s%-4s%-4s%-5s%-8s%-8s%-12s\n",
"idx", "MAC", "Associated", "Authorized", " RSSI", "PSM", "SGI", "STBC", "Tx rate", "Rx rate", "Connect Time");
#endif // RTCONFIG_MUMIMO
#else
ret += websWrite(wp, "%-4s%-18s%-11s%-11s%-8s%-8s%-8s%-12s\n",
"idx", "MAC", "Associated", "Authorized", " RSSI", "Tx rate", "Rx rate", "Connect Time");
#endif // RTCONFIG_QTN
#else
ret += websWrite(wp, "%-4s%-18s%-11s%-11s%-8s%-4s%-8s%-8s%-12s\n",
"idx", "MAC", "Associated", "Authorized", " RSSI", "PSM", "Tx rate", "Rx rate", "Connect Time");
#endif // RTCONFIG_BCMARM
/* build authenticated sta list */
for (i = 0; i < auth->count; i ++) {
sta = wl_sta_info(name, &auth->ea[i]);
if (!sta) continue;
if (!(sta->flags & WL_STA_ASSOC) && !sta->in) continue;
ret += websWrite(wp, " ");
ret += websWrite(wp, "%s ", ether_etoa((void *)&auth->ea[i], ea));
ret += websWrite(wp, "%-11s%-11s", (sta->flags & WL_STA_ASSOC) ? "Yes" : " ", (sta->flags & WL_STA_AUTHO) ? "Yes" : "");
memcpy(&scb_val.ea, &auth->ea[i], ETHER_ADDR_LEN);
if (wl_ioctl(name, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t)))
ret += websWrite(wp, "%-8s", "");
else
ret += websWrite(wp, "%4ddBm ", scb_val.val);
if (sta->flags & WL_STA_SCBSTATS)
{
#ifdef RTCONFIG_BCMARM
#ifndef RTCONFIG_QTN
#ifdef RTCONFIG_MUMIMO
ret += websWrite(wp, "%-4s%-4s%-5s%-5s",
(sta->flags & WL_STA_PS) ? "Yes" : "No",
((sta->ht_capabilities & WL_STA_CAP_SHORT_GI_20) || (sta->ht_capabilities & WL_STA_CAP_SHORT_GI_40)) ? "Yes" : "No",
((sta->ht_capabilities & WL_STA_CAP_TX_STBC) || (sta->ht_capabilities & WL_STA_CAP_RX_STBC_MASK)) ? "Yes" : "No",
((sta->vht_flags & WL_STA_MU_BEAMFORMER) || (sta->vht_flags & WL_STA_MU_BEAMFORMEE)) ? "Yes" : "No");
#else
ret += websWrite(wp, "%-4s%-4s%-5s",
(sta->flags & WL_STA_PS) ? "Yes" : "No",
((sta->ht_capabilities & WL_STA_CAP_SHORT_GI_20) || (sta->ht_capabilities & WL_STA_CAP_SHORT_GI_40)) ? "Yes" : "No",
((sta->ht_capabilities & WL_STA_CAP_TX_STBC) || (sta->ht_capabilities & WL_STA_CAP_RX_STBC_MASK)) ? "Yes" : "No");
#endif
#endif
#else
ret += websWrite(wp, "%-4s",
(sta->flags & WL_STA_PS) ? "Yes" : "No");
#endif
ret += websWrite(wp, "%s", print_rate_buf(sta->tx_rate, rate_buf));
ret += websWrite(wp, "%s", print_rate_buf(sta->rx_rate, rate_buf));
hr = sta->in / 3600;
min = (sta->in % 3600) / 60;
sec = sta->in - hr * 3600 - min * 60;
ret += websWrite(wp, "%02d:%02d:%02d", hr, min, sec);
}
ret += websWrite(wp, "\n");
}
for (i = 1; i < 4; i++) {
#ifdef RTCONFIG_WIRELESSREPEATER
if ((nvram_get_int("sw_mode") == SW_MODE_REPEATER)
&& (unit == nvram_get_int("wlc_band")) && (i == 1))
break;
#endif
sprintf(prefix, "wl%d.%d_", unit, i);
if (nvram_match(strcat_r(prefix, "bss_enabled", tmp), "1"))
{
sprintf(name_vif, "wl%d.%d", unit, i);
memset(auth, 0, mac_list_size);
/* query wl for authenticated sta list */
strcpy((char*)auth, "authe_sta_list");
if (wl_ioctl(name_vif, WLC_GET_VAR, auth, mac_list_size))
goto exit;
for (ii = 0; ii < auth->count; ii++) {
sta = wl_sta_info(name_vif, &auth->ea[ii]);
if (!sta) continue;
if (!(sta->flags & WL_STA_ASSOC) && !sta->in) continue;
ret += websWrite(wp, "%-3d ", i);
ret += websWrite(wp, "%s ", ether_etoa((void *)&auth->ea[ii], ea));
ret += websWrite(wp, "%-11s%-11s", (sta->flags & WL_STA_ASSOC) ? "Yes" : " ", (sta->flags & WL_STA_AUTHO) ? "Yes" : "");
memcpy(&scb_val.ea, &auth->ea[ii], ETHER_ADDR_LEN);
if (wl_ioctl(name_vif, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t)))
ret += websWrite(wp, "%-8s", "");
else
ret += websWrite(wp, "%4ddBm ", scb_val.val);
if (sta->flags & WL_STA_SCBSTATS)
{
#ifdef RTCONFIG_BCMARM
#ifdef RTCONFIG_MUMIMO
ret += websWrite(wp, "%-4s%-4s%-5s%-5s",
(sta->flags & WL_STA_PS) ? "Yes" : "No",
((sta->ht_capabilities & WL_STA_CAP_SHORT_GI_20) || (sta->ht_capabilities & WL_STA_CAP_SHORT_GI_40)) ? "Yes" : "No",
((sta->ht_capabilities & WL_STA_CAP_TX_STBC) || (sta->ht_capabilities & WL_STA_CAP_RX_STBC_MASK)) ? "Yes" : "No",
((sta->vht_flags & WL_STA_MU_BEAMFORMER) || (sta->vht_flags & WL_STA_MU_BEAMFORMEE)) ? "Yes" : "No");
#else
ret += websWrite(wp, "%-4s%-4s%-5s",
(sta->flags & WL_STA_PS) ? "Yes" : "No",
((sta->ht_capabilities & WL_STA_CAP_SHORT_GI_20) || (sta->ht_capabilities & WL_STA_CAP_SHORT_GI_40)) ? "Yes" : "No",
((sta->ht_capabilities & WL_STA_CAP_TX_STBC) || (sta->ht_capabilities & WL_STA_CAP_RX_STBC_MASK)) ? "Yes" : "No");
#endif
#else
ret += websWrite(wp, "%-4s",
(sta->flags & WL_STA_PS) ? "Yes" : "No");
#endif
ret += websWrite(wp, "%s", print_rate_buf(sta->tx_rate, rate_buf));
ret += websWrite(wp, "%s", print_rate_buf(sta->rx_rate, rate_buf));
hr = sta->in / 3600;
min = (sta->in % 3600) / 60;
sec = sta->in - hr * 3600 - min * 60;
ret += websWrite(wp, "%02d:%02d:%02d", hr, min, sec);
}
ret += websWrite(wp, "\n");
}
}
}
/* error/exit */
exit:
if (auth) free(auth);
return ret;
}
int
ej_wl_status_2g(int eid, webs_t wp, int argc, char_t **argv)
{
int retval = 0;
int ii = 0;
char nv_param[NVRAM_MAX_PARAM_LEN];
char *temp;
for (ii = 0; ii < DEV_NUMIFS; ii++) {
sprintf(nv_param, "wl%d_unit", ii);
temp = nvram_get(nv_param);
if (temp && strlen(temp) > 0)
{
retval += ej_wl_status(eid, wp, argc, argv, ii);
retval += websWrite(wp, "\n");
}
}
return retval;
}
int
wl_control_channel(int unit)
{
int ret;
struct ether_addr bssid;
wl_bss_info_t *bi;
wl_bss_info_107_t *old_bi;
char tmp[128], prefix[] = "wlXXXXXXXXXX_";
char *name;
#ifdef RTCONFIG_QTN
qcsapi_unsigned_int channel;
#endif
snprintf(prefix, sizeof(prefix), "wl%d_", unit);
name = nvram_safe_get(strcat_r(prefix, "ifname", tmp));
if ((ret = wl_ioctl(name, WLC_GET_BSSID, &bssid, ETHER_ADDR_LEN)) == 0) {
/* The adapter is associated. */
*(uint32*)buf = htod32(WLC_IOCTL_MAXLEN);
if ((ret = wl_ioctl(name, WLC_GET_BSS_INFO, buf, WLC_IOCTL_MAXLEN)) < 0)
return 0;
bi = (wl_bss_info_t*)(buf + 4);
if (dtoh32(bi->version) == WL_BSS_INFO_VERSION ||
dtoh32(bi->version) == LEGACY2_WL_BSS_INFO_VERSION ||
dtoh32(bi->version) == LEGACY_WL_BSS_INFO_VERSION)
{
/* Convert version 107 to 109 */
if (dtoh32(bi->version) == LEGACY_WL_BSS_INFO_VERSION) {
old_bi = (wl_bss_info_107_t *)bi;
bi->chanspec = CH20MHZ_CHSPEC(old_bi->channel);
bi->ie_length = old_bi->ie_length;
bi->ie_offset = sizeof(wl_bss_info_107_t);
}
if (dtoh32(bi->version) != LEGACY_WL_BSS_INFO_VERSION && bi->n_cap)
return bi->ctl_ch;
else
return (bi->chanspec & WL_CHANSPEC_CHAN_MASK);
}
}
#ifdef RTCONFIG_QTN
ret = rpc_qcsapi_get_channel(&channel);
if (ret < 0) return 0;
else return channel;
#else
return 0;
#endif
}
int
ej_wl_control_channel(int eid, webs_t wp, int argc, char_t **argv)
{
int ret = 0;
int channel_24 = 0, channel_50 = 0;
#if defined(RTAC3200) || defined(RTAC5300) || defined(RTAC5300R)
int channel_50_2 = 0;
#endif
channel_24 = wl_control_channel(0);
if (!(channel_50 = wl_control_channel(1)))
ret = websWrite(wp, "[\"%d\", \"%d\"]", channel_24, 0);
else
#if !defined(RTAC3200) && !defined(RTAC5300) && !defined(RTAC5300R)
ret = websWrite(wp, "[\"%d\", \"%d\"]", channel_24, channel_50);
#else
{
if (!(channel_50_2 = wl_control_channel(2)))
ret = websWrite(wp, "[\"%d\", \"%d\", \"%d\"]", channel_24, channel_50, 0);
else
ret = websWrite(wp, "[\"%d\", \"%d\", \"%d\"]", channel_24, channel_50, channel_50_2);
}
#endif
return ret;
}
#define IW_MAX_FREQUENCIES 32
static int ej_wl_channel_list(int eid, webs_t wp, int argc, char_t **argv, int unit)
{
int i, retval = 0;
int channels[MAXCHANNEL+1];
wl_uint32_list_t *list = (wl_uint32_list_t *) channels;
char tmp[256], tmp1[256], tmp2[256], prefix[] = "wlXXXXXXXXXX_";
char *name;
uint ch;
char word[256], *next;
int unit_max = 0, count = 0;
sprintf(tmp1, "[\"%d\"]", 0);
foreach (word, nvram_safe_get("wl_ifnames"), next)
unit_max++;
if (unit > (unit_max - 1))
goto ERROR;
snprintf(prefix, sizeof(prefix), "wl%d_", unit);
name = nvram_safe_get(strcat_r(prefix, "ifname", tmp));
if (is_wlif_up(name) != 1)
{
foreach (word, nvram_safe_get(strcat_r(prefix, "chlist", tmp)), next)
count++;
if (count < 2)
goto ERROR;
i = 0;
foreach (word, nvram_safe_get(strcat_r(prefix, "chlist", tmp)), next) {
if (i == 0)
{
sprintf(tmp1, "[\"%s\",", word);
}
else if (i == (count - 1))
{
sprintf(tmp1, "%s \"%s\"]", tmp1, word);
}
else
{
sprintf(tmp1, "%s \"%s\",", tmp1, word);
}
i++;
}
goto ERROR;
}
memset(channels, 0, sizeof(channels));
list->count = htod32(MAXCHANNEL);
if (wl_ioctl(name, WLC_GET_VALID_CHANNELS , channels, sizeof(channels)) < 0)
{
dbg("error doing WLC_GET_VALID_CHANNELS\n");
sprintf(tmp1, "[\"%d\"]", 0);
goto ERROR;
}
if (dtoh32(list->count) == 0)
{
sprintf(tmp1, "[\"%d\"]", 0);
goto ERROR;
}
for (i = 0; i < dtoh32(list->count) && i < IW_MAX_FREQUENCIES; i++) {
ch = dtoh32(list->element[i]);
if (i == 0)
{
sprintf(tmp1, "[\"%d\",", ch);
sprintf(tmp2, "%d", ch);
}
else if (i == (dtoh32(list->count) - 1))
{
sprintf(tmp1, "%s \"%d\"]", tmp1, ch);
sprintf(tmp2, "%s %d", tmp2, ch);
}
else
{
sprintf(tmp1, "%s \"%d\",", tmp1, ch);
sprintf(tmp2, "%s %d", tmp2, ch);
}
if (strlen(tmp2))
nvram_set(strcat_r(prefix, "chlist", tmp), tmp2);
}
ERROR:
retval += websWrite(wp, "%s", tmp1);
return retval;
}
static int ej_wl_chanspecs(int eid, webs_t wp, int argc, char_t **argv, int unit)
{
int i, retval = 0;
char tmp[1024], tmp1[1024], tmp2[1024], tmpx[1024], prefix[] = "wlXXXXXXXXXX_";
char *name;
char word[256], *next;
int unit_max = 0, count = 0;
wl_uint32_list_t *list;
chanspec_t c = 0;
char data_buf[WLC_IOCTL_MAXLEN];
char chanbuf[CHANSPEC_STR_LEN];
sprintf(tmp1, "[\"%d\"]", 0);
#ifdef RTCONFIG_QTN
if (unit) goto ERROR;
#endif
foreach (word, nvram_safe_get("wl_ifnames"), next)
unit_max++;
if (unit > (unit_max - 1))
goto ERROR;
snprintf(prefix, sizeof(prefix), "wl%d_", unit);
name = nvram_safe_get(strcat_r(prefix, "ifname", tmp));
if (is_wlif_up(name) != 1) {
foreach (word, nvram_safe_get(strcat_r(prefix, "chansps", tmp)), next)
count++;
if (count < 2)
goto ERROR;
i = 0;
foreach (word, nvram_safe_get(strcat_r(prefix, "chansps", tmp)), next) {
if (i == 0) {
sprintf(tmp1, "[\"%s\",", word);
} else if (i == (count - 1)) {
sprintf(tmpx, "%s \"%s\"]", tmp1, word);
strlcpy(tmp1, tmpx, sizeof(tmp1));
} else {
sprintf(tmpx, "%s \"%s\",", tmp1, word);
strlcpy(tmp1, tmpx, sizeof(tmp1));
}
i++;
}
goto ERROR;
}
memset(data_buf, 0, WLC_IOCTL_MAXLEN);
if (wl_iovar_getbuf(name, "chanspecs", &c, sizeof(chanspec_t), data_buf, WLC_IOCTL_MAXLEN) < 0) {
dbg("error doing WLC_GET_VAR chanspecs\n");
sprintf(tmp1, "[\"%d\"]", 0);
goto ERROR;
}
list = (wl_uint32_list_t *)data_buf;
count = dtoh32(list->count);
if (!count) {
dbg("number of valid chanspec is 0\n");
sprintf(tmp1, "[\"%d\"]", 0);
goto ERROR;
} else
for (i = 0; i < count; i++) {
c = (chanspec_t)dtoh32(list->element[i]);
wf_chspec_ntoa(c, chanbuf);
if (i == 0)
{
sprintf(tmp1, "[\"%s\",", chanbuf);
sprintf(tmp2, "%s", chanbuf);
}
else if (i == (count - 1))
{
sprintf(tmpx, "%s \"%s\"]", tmp1, chanbuf);
strlcpy(tmp1, tmpx, sizeof(tmp1));
sprintf(tmpx, "%s %s", tmp2, chanbuf);
strlcpy(tmp2, tmpx, sizeof(tmp2));
}
else
{
sprintf(tmpx, "%s \"%s\",", tmp1, chanbuf);
strlcpy(tmp1, tmpx, sizeof(tmp1));
sprintf(tmpx, "%s %s", tmp2, chanbuf);
strlcpy(tmp2, tmpx, sizeof(tmp2));
}
if (strlen(tmp2))
nvram_set(strcat_r(prefix, "chansps", tmp), tmp2);
}
ERROR:
retval += websWrite(wp, "%s", tmp1);
return retval;
}
int
ej_wl_channel_list_2g(int eid, webs_t wp, int argc, char_t **argv)
{
return ej_wl_channel_list(eid, wp, argc, argv, 0);
}
#ifndef RTCONFIG_QTN
int
ej_wl_channel_list_5g(int eid, webs_t wp, int argc, char_t **argv)
{
return ej_wl_channel_list(eid, wp, argc, argv, 1);
}
#endif
int
ej_wl_channel_list_5g_2(int eid, webs_t wp, int argc, char_t **argv)
{
return ej_wl_channel_list(eid, wp, argc, argv, 2);
}
int
ej_wl_chanspecs_2g(int eid, webs_t wp, int argc, char_t **argv)
{
return ej_wl_chanspecs(eid, wp, argc, argv, 0);
}
int
ej_wl_chanspecs_5g(int eid, webs_t wp, int argc, char_t **argv)
{
return ej_wl_chanspecs(eid, wp, argc, argv, 1);
}
int
ej_wl_chanspecs_5g_2(int eid, webs_t wp, int argc, char_t **argv)
{
return ej_wl_chanspecs(eid, wp, argc, argv, 2);
}
#define WL_IW_RSSI_NO_SIGNAL -91 /* NDIS RSSI link quality cutoffs */
static int ej_wl_rssi(int eid, webs_t wp, int argc, char_t **argv, int unit)
{
int retval = 0;
char tmp[256], prefix[] = "wlXXXXXXXXXX_";
char *name;
char word[256], *next;
int unit_max = 0, unit_cur = -1;
char rssi_buf[32];
#ifdef RTCONFIG_QTN
int rssi_by_chain[4];
#endif
char *mode = NULL;
int sta = 0, wet = 0, psta = 0, psr = 0;
int rssi = WL_IW_RSSI_NO_SIGNAL, ret;
memset(rssi_buf, 0, sizeof(rssi_buf));
#ifdef RTCONFIG_QTN
if (unit != 0) {
if (!rpc_qtn_ready())
goto ERROR;
qcsapi_wifi_get_rssi_by_chain(WIFINAME, 0, &rssi_by_chain[0]);
qcsapi_wifi_get_rssi_by_chain(WIFINAME, 1, &rssi_by_chain[1]);
qcsapi_wifi_get_rssi_by_chain(WIFINAME, 2, &rssi_by_chain[2]);
qcsapi_wifi_get_rssi_by_chain(WIFINAME, 3, &rssi_by_chain[3]);
rssi = (rssi_by_chain[0] + rssi_by_chain[1] + rssi_by_chain[2] + rssi_by_chain[3]) / 4;
retval += websWrite(wp, "%d dBm", rssi);
return retval;
}
#endif
foreach (word, nvram_safe_get("wl_ifnames"), next)
unit_max++;
if (unit > (unit_max - 1))
goto ERROR;
snprintf(prefix, sizeof(prefix), "wl%d_", unit);
name = nvram_safe_get(strcat_r(prefix, "ifname", tmp));
mode = nvram_safe_get(strcat_r(prefix, "mode", tmp));
sta = !strcmp(mode, "sta");
wet = !strcmp(mode, "wet");
psta = !strcmp(mode, "psta");
psr = !strcmp(mode, "psr");
if (wet || sta || psta || psr) {
ret = wl_ioctl(name, WLC_GET_RSSI, &rssi, sizeof(rssi));
if (ret < 0)
dbg("Err: reading intf:%s RSSI\n", name);
}
wl_ioctl(name, WLC_GET_INSTANCE, &unit_cur, sizeof(unit_cur));
if (unit != unit_cur)
goto ERROR;
else if (!(wet || sta || psta || psr))
goto ERROR;
else if (wl_ioctl(name, WLC_GET_RSSI, &rssi, sizeof(rssi))) {
dbg("can not get rssi info of %s\n", name);
goto ERROR;
} else {
rssi = dtoh32(rssi);
sprintf(rssi_buf, "%d dBm", rssi);
}
ERROR:
retval += websWrite(wp, "%s", rssi_buf);
return retval;
}
int
ej_wl_rssi_2g(int eid, webs_t wp, int argc, char_t **argv)
{
return ej_wl_rssi(eid, wp, argc, argv, 0);
}
int
ej_wl_rssi_5g(int eid, webs_t wp, int argc, char_t **argv)
{
return ej_wl_rssi(eid, wp, argc, argv, 1);
}
int
ej_wl_rssi_5g_2(int eid, webs_t wp, int argc, char_t **argv)
{
return ej_wl_rssi(eid, wp, argc, argv, 2);
}
static int ej_wl_rate(int eid, webs_t wp, int argc, char_t **argv, int unit)
{
int retval = 0;
char tmp[256], prefix[] = "wlXXXXXXXXXX_";
char *name;
char word[256], *next;
int unit_max = 0, unit_cur = -1;
int rate = 0;
char rate_buf[32];
struct ether_addr bssid;
unsigned char bssid_null[6] = {0x0,0x0,0x0,0x0,0x0,0x0};
int sta_rate;
#ifdef RTCONFIG_BCMWL6
int s = -1;
#endif
#ifdef RTCONFIG_QTN
uint32_t count = 0, speed;
#endif
sprintf(rate_buf, "0 Mbps");
#ifdef RTCONFIG_QTN
if (unit != 0) {
if (!rpc_qtn_ready()) {
goto ERROR;
}
// if ssid associated, check associations
if (qcsapi_wifi_get_link_quality(WIFINAME, count, &speed) < 0) {
// dbg("fail to get link status index %d\n", (int)count);
} else {
speed = speed ; /* 4 antenna? */
if ((int)speed < 1) {
sprintf(rate_buf, "auto");
} else {
sprintf(rate_buf, "%d Mbps", (int)speed);
}
}
retval += websWrite(wp, "%s", rate_buf);
return retval;
}
#endif
foreach (word, nvram_safe_get("wl_ifnames"), next)
unit_max++;
if (unit > (unit_max - 1))
goto ERROR;
snprintf(prefix, sizeof(prefix), "wl%d_", unit);
name = nvram_safe_get(strcat_r(prefix, "ifname", tmp));
wl_ioctl(name, WLC_GET_INSTANCE, &unit_cur, sizeof(unit_cur));
if (unit != unit_cur)
goto ERROR;
else if (wl_ioctl(name, WLC_GET_RATE, &rate, sizeof(int))) {
dbg("can not get rate info of %s\n", name);
goto ERROR;
} else {
rate = dtoh32(rate);
if ((rate == -1) || (rate == 0))
sprintf(rate_buf, "auto");
else
sprintf(rate_buf, "%d%s Mbps", (rate / 2), (rate & 1) ? ".5" : "");
}
if (nvram_match(strcat_r(prefix, "mode", tmp), "wet")) {
if (wl_ioctl(name, WLC_GET_BSSID, &bssid, ETHER_ADDR_LEN) != 0)
goto ERROR;
else if (!memcmp(&bssid, bssid_null, 6))
goto ERROR;
sta_info_t *sta = wl_sta_info(name, &bssid);
if (sta && (sta->flags & WL_STA_SCBSTATS)) {
if ((dtoh32(sta->tx_rate) == -1) &&
(dtoh32(sta->rx_rate) == -1))
goto ERROR;
sta_rate = max(sta->tx_rate, sta->rx_rate);
rate = max(rate * 500, sta_rate);
if ((rate % 1000) == 0)
sprintf(rate_buf, "%6d Mbps", rate / 1000);
else
sprintf(rate_buf, "%6.1f Mbps", (double) rate / 1000);
}
#ifdef RTCONFIG_BCMWL6
} else if (nvram_match(strcat_r(prefix, "mode", tmp), "psta") ||
nvram_match(strcat_r(prefix, "mode", tmp), "psr")) {
#if 0
char eabuf[32];
#endif
struct ifreq ifr;
unsigned char wlta[6];
if (wl_ioctl(name, WLC_GET_BSSID, &bssid, ETHER_ADDR_LEN) != 0)
goto ERROR;
else if (!memcmp(&bssid, bssid_null, 6))
goto ERROR;
if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
goto ERROR;
strcpy(ifr.ifr_name, "br0");
if (ioctl(s, SIOCGIFHWADDR, &ifr))
goto ERROR;
memcpy(wlta, ifr.ifr_hwaddr.sa_data, ETHER_ADDR_LEN);
if (nvram_match(strcat_r(prefix, "mode", tmp), "psr"))
wlta[0] |= 0x02;
#if 0
dbg("%s TA: %s\n", name, ether_etoa((const unsigned char *)wlta, eabuf));
#endif
DIR *dir_to_open = NULL;
char dir_path[128];
int n, j;
struct dirent **namelist;
sprintf(dir_path, "/sys/class/net");
dir_to_open = opendir(dir_path);
if (dir_to_open) {
closedir(dir_to_open);
n = scandir(dir_path, &namelist, 0, alphasort);
snprintf(prefix, sizeof(prefix), "wl%d.", unit);
for (j= 0; j< n; j++) {
if (namelist[j]->d_name[0] == '.')
{
free(namelist[j]);
continue;
}
else if (strncmp(prefix, namelist[j]->d_name, 4))
{
free(namelist[j]);
continue;
}
strcpy(tmp, namelist[j]->d_name);
free(namelist[j]);
strcpy(ifr.ifr_name, tmp);
if (ioctl(s, SIOCGIFHWADDR, &ifr))
goto ERROR;
#if 0
dbg("%s macaddr: %s\n", tmp, ether_etoa((const unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf));
#endif
if (!memcmp(wlta, ifr.ifr_hwaddr.sa_data, 6)) {
sta_info_t *sta = wl_sta_info(tmp, &bssid);
if (sta && (sta->flags & WL_STA_SCBSTATS)) {
if ((dtoh32(sta->tx_rate) == -1) &&
(dtoh32(sta->rx_rate) == -1))
goto ERROR;
sta_rate = max(sta->tx_rate, sta->rx_rate);
rate = max(rate * 500, sta_rate);
if ((rate % 1000) == 0)
sprintf(rate_buf, "%6d Mbps", rate / 1000);
else
sprintf(rate_buf, "%6.1f Mbps", (double) rate / 1000);
}
break;
}
}
}
#endif
}
ERROR:
#ifdef RTCONFIG_BCMWL6
close(s);
#endif
retval += websWrite(wp, "%s", rate_buf);
return retval;
}
int
ej_wl_rate_2g(int eid, webs_t wp, int argc, char_t **argv)
{
return ej_wl_rate(eid, wp, argc, argv, 0);
}
int
ej_wl_rate_5g(int eid, webs_t wp, int argc, char_t **argv)
{
return ej_wl_rate(eid, wp, argc, argv, 1);
}
int
ej_wl_rate_5g_2(int eid, webs_t wp, int argc, char_t **argv)
{
return ej_wl_rate(eid, wp, argc, argv, 2);
}
static int wps_stop_count = 0;
static void reset_wps_status()
{
if (++wps_stop_count > 30)
{
wps_stop_count = 0;
nvram_set("wps_proc_status_x", "0");
}
}
char *
getWscStatusStr()
{
char *status = nvram_safe_get("wps_proc_status_x");
switch (atoi(status)) {
case 1: /* WPS_ASSOCIATED */
wps_stop_count = 0;
return "Start WPS Process";
break;
case 2: /* WPS_OK */
case 7: /* WPS_MSGDONE */
reset_wps_status();
return "Success";
break;
case 3: /* WPS_MSG_ERR */
reset_wps_status();
return "Fail due to WPS message exchange error!";
break;
case 4: /* WPS_TIMEOUT */
reset_wps_status();
return "Fail due to WPS time out!";
break;
case 5: /* WPS_UI_SENDM2 */
return "Send M2";
break;
case 6: /* WPS_UI_SENDM7 */
return "Send M7";
break;
case 8: /* WPS_PBCOVERLAP */
reset_wps_status();
return "Fail due to PBC session overlap!";
break;
case 9: /* WPS_UI_FIND_PBC_AP */
return "Finding a PBC access point...";
break;
case 10: /* WPS_UI_ASSOCIATING */
return "Assciating with access point...";
break;
default:
wps_stop_count = 0;
if (nvram_match("wps_enable", "1"))
return "Idle";
else
return "Not used";
break;
}
}
int
wps_is_oob()
{
char tmp[16];
snprintf(tmp, sizeof(tmp), "lan_wps_oob");
/*
* OOB: enabled
* Configured: disabled
*/
if (nvram_match(tmp, "disabled"))
return 0;
return 1;
}
void getWPSAuthMode(int unit, char *ret_str)
{
char tmp[128], prefix[]="wlXXXXXXX_";
snprintf(prefix, sizeof(prefix), "wl%d_", unit);
if (nvram_match(strcat_r(prefix, "auth_mode_x", tmp), "shared"))
strcpy(ret_str, "Shared Key");
else if (nvram_match(strcat_r(prefix, "auth_mode_x", tmp), "psk"))
strcpy(ret_str, "WPA-Personal");
else if (nvram_match(strcat_r(prefix, "auth_mode_x", tmp), "psk2"))
strcpy(ret_str, "WPA2-Personal");
else if (nvram_match(strcat_r(prefix, "auth_mode_x", tmp), "pskpsk2"))
strcpy(ret_str, "WPA-Auto-Personal");
else if (nvram_match(strcat_r(prefix, "auth_mode_x", tmp), "wpa"))
strcpy(ret_str, "WPA-Enterprise");
else if (nvram_match(strcat_r(prefix, "auth_mode_x", tmp), "wpa2"))
strcpy(ret_str, "WPA2-Enterprise");
else if (nvram_match(strcat_r(prefix, "auth_mode_x", tmp), "wpawpa2"))
strcpy(ret_str, "WPA-Auto-Enterprise");
else if (nvram_match(strcat_r(prefix, "auth_mode_x", tmp), "radius"))
strcpy(ret_str, "802.1X");
else
strcpy(ret_str, "Open System");
}
void getWPSEncrypType(int unit, char *ret_str)
{
char tmp[128], prefix[]="wlXXXXXXX_";
snprintf(prefix, sizeof(prefix), "wl%d_", unit);
if (nvram_match(strcat_r(prefix, "auth_mode_x", tmp), "open") &&
nvram_match(strcat_r(prefix, "wep_x", tmp), "0"))
strcpy(ret_str, "None");
else if ((nvram_match(strcat_r(prefix, "auth_mode_x", tmp), "open") && !nvram_match(strcat_r(prefix, "wep_x", tmp), "0")) ||
nvram_match("wl_auth_mode", "shared") ||
nvram_match("wl_auth_mode", "radius"))
strcpy(ret_str, "WEP");
if (nvram_match(strcat_r(prefix, "crypto", tmp), "tkip"))
strcpy(ret_str, "TKIP");
else if (nvram_match(strcat_r(prefix, "crypto", tmp), "aes"))
strcpy(ret_str, "AES");
else if (nvram_match(strcat_r(prefix, "crypto", tmp), "tkip+aes"))
strcpy(ret_str, "TKIP+AES");
}
int wl_wps_info(int eid, webs_t wp, int argc, char_t **argv, int unit)
{
char tmpstr[256];
int retval = 0;
char tmp[128], prefix[]="wlXXXXXXX_";
char *wps_sta_pin;
#ifdef RTCONFIG_QTN
int ret;
qcsapi_SSID ssid;
string_64 key_passphrase;
// char wps_pin[16];
#endif
snprintf(prefix, sizeof(prefix), "wl%d_", unit);
retval += websWrite(wp, "<wps>\n");
//0. WSC Status
if (!strcmp(nvram_safe_get(strcat_r(prefix, "wps_mode", tmp)), "enabled"))
{
#ifdef RTCONFIG_QTN
if (unit)
{
if (!rpc_qtn_ready())
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", "5 GHz radio is not ready");
else
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", getWscStatusStr_qtn());
}
else
#endif
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", getWscStatusStr());
}
else
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", "Not used");
//1. WPSConfigured
#ifdef RTCONFIG_QTN
if (unit)
{
if (!rpc_qtn_ready())
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", "");
else
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", get_WPSConfiguredStr_qtn());
}
else
#endif
if (!wps_is_oob())
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", "Yes");
else
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", "No");
//2. WPSSSID
#ifdef RTCONFIG_QTN
if (unit)
{
if (!rpc_qtn_ready())
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", "");
else
{
memset(&ssid, 0, sizeof(qcsapi_SSID));
ret = rpc_qcsapi_get_SSID(WIFINAME, &ssid);
if (ret < 0)
dbG("rpc_qcsapi_get_SSID %s error, return: %d\n", WIFINAME, ret);
memset(tmpstr, 0, sizeof(tmpstr));
char_to_ascii(tmpstr, ssid);
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", tmpstr);
}
}
else
#endif
{
memset(tmpstr, 0, sizeof(tmpstr));
char_to_ascii(tmpstr, nvram_safe_get(strcat_r(prefix, "ssid", tmp)));
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", tmpstr);
}
//3. WPSAuthMode
#ifdef RTCONFIG_QTN
if (unit)
{
if (!rpc_qtn_ready())
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", "");
else
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", getWPSAuthMode_qtn());
}
else
#endif
{
memset(tmpstr, 0, sizeof(tmpstr));
getWPSAuthMode(unit, tmpstr);
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", tmpstr);
}
//4. EncrypType
#ifdef RTCONFIG_QTN
if (unit)
{
if (!rpc_qtn_ready())
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", "");
else
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", getWPSEncrypType_qtn());
}
else
#endif
{
memset(tmpstr, 0, sizeof(tmpstr));
getWPSEncrypType(unit, tmpstr);
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", tmpstr);
}
//5. DefaultKeyIdx
#ifdef RTCONFIG_QTN
if (unit)
{
if (!rpc_qtn_ready())
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", "");
else
retval += websWrite(wp, "<wps_info>%d</wps_info>\n", 1);
}
else
#endif
{
memset(tmpstr, 0, sizeof(tmpstr));
sprintf(tmpstr, "%s", nvram_safe_get(strcat_r(prefix, "key", tmp)));
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", tmpstr);
}
//6. WPAKey
#if 0 //hide for security
#ifdef RTCONFIG_QTN
if (unit)
{
if (!rpc_qtn_ready())
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", "");
else
{
memset(&key_passphrase, 0, sizeof(key_passphrase));
ret = rpc_qcsapi_get_key_passphrase(WIFINAME, (char *) &key_passphrase);
if (ret < 0)
dbG("rpc_qcsapi_get_key_passphrase %s error, return: %d\n", WIFINAME, ret);
if (!strlen(key_passphrase))
retval += websWrite(wp, "<wps_info>None</wps_info>\n");
else
{
memset(tmpstr, 0, sizeof(tmpstr));
char_to_ascii(tmpstr, key_passphrase);
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", tmpstr);
}
}
}
else
#endif
if (!strlen(nvram_safe_get(strcat_r(prefix, "wpa_psk", tmp))))
retval += websWrite(wp, "<wps_info>None</wps_info>\n");
else
{
memset(tmpstr, 0, sizeof(tmpstr));
char_to_ascii(tmpstr, nvram_safe_get(strcat_r(prefix, "wpa_psk", tmp)));
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", tmpstr);
}
#else
retval += websWrite(wp, "<wps_info></wps_info>\n");
#endif
//7. AP PIN Code
#ifdef RTCONFIG_QTNBAK
/* QTN get wps_device_pin from BRCM */
if (unit)
{
if (!rpc_qtn_ready())
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", "");
else
{
wps_pin[0] = 0;
ret = rpc_qcsapi_wps_get_ap_pin(WIFINAME, wps_pin, 0);
if (ret < 0)
dbG("rpc_qcsapi_wps_get_ap_pin %s error, return: %d\n", WIFINAME, ret);
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", wps_pin);
}
}
else
#endif
{
memset(tmpstr, 0, sizeof(tmpstr));
sprintf(tmpstr, "%s", nvram_safe_get("wps_device_pin"));
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", tmpstr);
}
//8. Saved WPAKey
#if 0 //hide for security
#ifdef RTCONFIG_QTN
if (unit)
{
if (!rpc_qtn_ready())
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", "");
else
{
if (!strlen(key_passphrase))
retval += websWrite(wp, "<wps_info>None</wps_info>\n");
else
{
memset(tmpstr, 0, sizeof(tmpstr));
char_to_ascii(tmpstr, key_passphrase);
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", tmpstr);
}
}
}
else
#endif
if (!strlen(nvram_safe_get(strcat_r(prefix, "wpa_psk", tmp))))
{
retval += websWrite(wp, "<wps_info>None</wps_info>\n");
}
else
{
memset(tmpstr, 0, sizeof(tmpstr));
char_to_ascii(tmpstr, nvram_safe_get(strcat_r(prefix, "wpa_psk", tmp)));
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", tmpstr);
}
#else
retval += websWrite(wp, "<wps_info></wps_info>\n");
#endif
//9. WPS enable?
if (!strcmp(nvram_safe_get(strcat_r(prefix, "wps_mode", tmp)), "enabled"))
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", "1");
else
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", "0");
//A. WPS mode
wps_sta_pin = nvram_safe_get("wps_sta_pin");
if (strlen(wps_sta_pin) && strcmp(wps_sta_pin, "00000000"))
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", "1");
else
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", "2");
//B. current auth mode
retval += websWrite(wp, "<wps_info>%s</wps_info>\n", nvram_safe_get(strcat_r(prefix, "auth_mode_x", tmp)));
//C. WPS band
retval += websWrite(wp, "<wps_info>%d</wps_info>\n", nvram_get_int("wps_band_x"));
retval += websWrite(wp, "</wps>");
return retval;
}
int
ej_wps_info(int eid, webs_t wp, int argc, char_t **argv)
{
return wl_wps_info(eid, wp, argc, argv, 1);
}
int
ej_wps_info_2g(int eid, webs_t wp, int argc, char_t **argv)
{
return wl_wps_info(eid, wp, argc, argv, 0);
}
static int wpa_key_mgmt_to_bitfield(const unsigned char *s)
{
if (memcmp(s, WPA_AUTH_KEY_MGMT_UNSPEC_802_1X, WPA_SELECTOR_LEN) == 0)
return WPA_KEY_MGMT_IEEE8021X_;
if (memcmp(s, WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X, WPA_SELECTOR_LEN) ==
0)
return WPA_KEY_MGMT_PSK_;
if (memcmp(s, WPA_AUTH_KEY_MGMT_NONE, WPA_SELECTOR_LEN) == 0)
return WPA_KEY_MGMT_WPA_NONE_;
return 0;
}
static int rsn_key_mgmt_to_bitfield(const unsigned char *s)
{
if (memcmp(s, RSN_AUTH_KEY_MGMT_UNSPEC_802_1X, RSN_SELECTOR_LEN) == 0)
return WPA_KEY_MGMT_IEEE8021X2_;
if (memcmp(s, RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X, RSN_SELECTOR_LEN) ==
0)
return WPA_KEY_MGMT_PSK2_;
return 0;
}
static int wpa_selector_to_bitfield(const unsigned char *s)
{
if (memcmp(s, WPA_CIPHER_SUITE_NONE, WPA_SELECTOR_LEN) == 0)
return WPA_CIPHER_NONE_;
if (memcmp(s, WPA_CIPHER_SUITE_WEP40, WPA_SELECTOR_LEN) == 0)
return WPA_CIPHER_WEP40_;
if (memcmp(s, WPA_CIPHER_SUITE_TKIP, WPA_SELECTOR_LEN) == 0)
return WPA_CIPHER_TKIP_;
if (memcmp(s, WPA_CIPHER_SUITE_CCMP, WPA_SELECTOR_LEN) == 0)
return WPA_CIPHER_CCMP_;
if (memcmp(s, WPA_CIPHER_SUITE_WEP104, WPA_SELECTOR_LEN) == 0)
return WPA_CIPHER_WEP104_;
return 0;
}
static int rsn_selector_to_bitfield(const unsigned char *s)
{
if (memcmp(s, RSN_CIPHER_SUITE_NONE, RSN_SELECTOR_LEN) == 0)
return WPA_CIPHER_NONE_;
if (memcmp(s, RSN_CIPHER_SUITE_WEP40, RSN_SELECTOR_LEN) == 0)
return WPA_CIPHER_WEP40_;
if (memcmp(s, RSN_CIPHER_SUITE_TKIP, RSN_SELECTOR_LEN) == 0)
return WPA_CIPHER_TKIP_;
if (memcmp(s, RSN_CIPHER_SUITE_CCMP, RSN_SELECTOR_LEN) == 0)
return WPA_CIPHER_CCMP_;
if (memcmp(s, RSN_CIPHER_SUITE_WEP104, RSN_SELECTOR_LEN) == 0)
return WPA_CIPHER_WEP104_;
return 0;
}
static int wpa_parse_wpa_ie_wpa(const unsigned char *wpa_ie, size_t wpa_ie_len,
struct wpa_ie_data *data)
{
const struct wpa_ie_hdr *hdr;
const unsigned char *pos;
int left;
int i, count;
data->proto = WPA_PROTO_WPA_;
data->pairwise_cipher = WPA_CIPHER_TKIP_;
data->group_cipher = WPA_CIPHER_TKIP_;
data->key_mgmt = WPA_KEY_MGMT_IEEE8021X_;
data->capabilities = 0;
data->pmkid = NULL;
data->num_pmkid = 0;
if (wpa_ie_len == 0) {
/* No WPA IE - fail silently */
return -1;
}
if (wpa_ie_len < sizeof(struct wpa_ie_hdr)) {
// fprintf(stderr, "ie len too short %lu", (unsigned long) wpa_ie_len);
return -1;
}
hdr = (const struct wpa_ie_hdr *) wpa_ie;
if (hdr->elem_id != DOT11_MNG_WPA_ID ||
hdr->len != wpa_ie_len - 2 ||
memcmp(&hdr->oui, WPA_OUI_TYPE_ARR, WPA_SELECTOR_LEN) != 0 ||
WPA_GET_LE16(hdr->version) != WPA_VERSION_) {
// fprintf(stderr, "malformed ie or unknown version");
return -1;
}
pos = (const unsigned char *) (hdr + 1);
left = wpa_ie_len - sizeof(*hdr);
if (left >= WPA_SELECTOR_LEN) {
data->group_cipher = wpa_selector_to_bitfield(pos);
pos += WPA_SELECTOR_LEN;
left -= WPA_SELECTOR_LEN;
} else if (left > 0) {
// fprintf(stderr, "ie length mismatch, %u too much", left);
return -1;
}
if (left >= 2) {
data->pairwise_cipher = 0;
count = WPA_GET_LE16(pos);
pos += 2;
left -= 2;
if (count == 0 || left < count * WPA_SELECTOR_LEN) {
// fprintf(stderr, "ie count botch (pairwise), "
// "count %u left %u", count, left);
return -1;
}
for (i = 0; i < count; i++) {
data->pairwise_cipher |= wpa_selector_to_bitfield(pos);
pos += WPA_SELECTOR_LEN;
left -= WPA_SELECTOR_LEN;
}
} else if (left == 1) {
// fprintf(stderr, "ie too short (for key mgmt)");
return -1;
}
if (left >= 2) {
data->key_mgmt = 0;
count = WPA_GET_LE16(pos);
pos += 2;
left -= 2;
if (count == 0 || left < count * WPA_SELECTOR_LEN) {
// fprintf(stderr, "ie count botch (key mgmt), "
// "count %u left %u", count, left);
return -1;
}
for (i = 0; i < count; i++) {
data->key_mgmt |= wpa_key_mgmt_to_bitfield(pos);
pos += WPA_SELECTOR_LEN;
left -= WPA_SELECTOR_LEN;
}
} else if (left == 1) {
// fprintf(stderr, "ie too short (for capabilities)");
return -1;
}
if (left >= 2) {
data->capabilities = WPA_GET_LE16(pos);
pos += 2;
left -= 2;
}
if (left > 0) {
// fprintf(stderr, "ie has %u trailing bytes", left);
return -1;
}
return 0;
}
static int wpa_parse_wpa_ie_rsn(const unsigned char *rsn_ie, size_t rsn_ie_len,
struct wpa_ie_data *data)
{
const struct rsn_ie_hdr *hdr;
const unsigned char *pos;
int left;
int i, count;
data->proto = WPA_PROTO_RSN_;
data->pairwise_cipher = WPA_CIPHER_CCMP_;
data->group_cipher = WPA_CIPHER_CCMP_;
data->key_mgmt = WPA_KEY_MGMT_IEEE8021X2_;
data->capabilities = 0;
data->pmkid = NULL;
data->num_pmkid = 0;
if (rsn_ie_len == 0) {
/* No RSN IE - fail silently */
return -1;
}
if (rsn_ie_len < sizeof(struct rsn_ie_hdr)) {
// fprintf(stderr, "ie len too short %lu", (unsigned long) rsn_ie_len);
return -1;
}
hdr = (const struct rsn_ie_hdr *) rsn_ie;
if (hdr->elem_id != DOT11_MNG_RSN_ID ||
hdr->len != rsn_ie_len - 2 ||
WPA_GET_LE16(hdr->version) != RSN_VERSION_) {
// fprintf(stderr, "malformed ie or unknown version");
return -1;
}
pos = (const unsigned char *) (hdr + 1);
left = rsn_ie_len - sizeof(*hdr);
if (left >= RSN_SELECTOR_LEN) {
data->group_cipher = rsn_selector_to_bitfield(pos);
pos += RSN_SELECTOR_LEN;
left -= RSN_SELECTOR_LEN;
} else if (left > 0) {
// fprintf(stderr, "ie length mismatch, %u too much", left);
return -1;
}
if (left >= 2) {
data->pairwise_cipher = 0;
count = WPA_GET_LE16(pos);
pos += 2;
left -= 2;
if (count == 0 || left < count * RSN_SELECTOR_LEN) {
// fprintf(stderr, "ie count botch (pairwise), "
// "count %u left %u", count, left);
return -1;
}
for (i = 0; i < count; i++) {
data->pairwise_cipher |= rsn_selector_to_bitfield(pos);
pos += RSN_SELECTOR_LEN;
left -= RSN_SELECTOR_LEN;
}
} else if (left == 1) {
// fprintf(stderr, "ie too short (for key mgmt)");
return -1;
}
if (left >= 2) {
data->key_mgmt = 0;
count = WPA_GET_LE16(pos);
pos += 2;
left -= 2;
if (count == 0 || left < count * RSN_SELECTOR_LEN) {
// fprintf(stderr, "ie count botch (key mgmt), "
// "count %u left %u", count, left);
return -1;
}
for (i = 0; i < count; i++) {
data->key_mgmt |= rsn_key_mgmt_to_bitfield(pos);
pos += RSN_SELECTOR_LEN;
left -= RSN_SELECTOR_LEN;
}
} else if (left == 1) {
// fprintf(stderr, "ie too short (for capabilities)");
return -1;
}
if (left >= 2) {
data->capabilities = WPA_GET_LE16(pos);
pos += 2;
left -= 2;
}
if (left >= 2) {
data->num_pmkid = WPA_GET_LE16(pos);
pos += 2;
left -= 2;
if (left < data->num_pmkid * PMKID_LEN) {
// fprintf(stderr, "PMKID underflow "
// "(num_pmkid=%d left=%d)", data->num_pmkid, left);
data->num_pmkid = 0;
} else {
data->pmkid = pos;
pos += data->num_pmkid * PMKID_LEN;
left -= data->num_pmkid * PMKID_LEN;
}
}
if (left > 0) {
// fprintf(stderr, "ie has %u trailing bytes - ignored", left);
}
return 0;
}
int wpa_parse_wpa_ie(const unsigned char *wpa_ie, size_t wpa_ie_len,
struct wpa_ie_data *data)
{
if (wpa_ie_len >= 1 && wpa_ie[0] == DOT11_MNG_RSN_ID)
return wpa_parse_wpa_ie_rsn(wpa_ie, wpa_ie_len, data);
else
return wpa_parse_wpa_ie_wpa(wpa_ie, wpa_ie_len, data);
}
static const char * wpa_cipher_txt(int cipher)
{
switch (cipher) {
case WPA_CIPHER_NONE_:
return "NONE";
case WPA_CIPHER_WEP40_:
return "WEP-40";
case WPA_CIPHER_WEP104_:
return "WEP-104";
case WPA_CIPHER_TKIP_:
return "TKIP";
case WPA_CIPHER_CCMP_:
// return "CCMP";
return "AES";
case (WPA_CIPHER_TKIP_|WPA_CIPHER_CCMP_):
return "TKIP+AES";
default:
return "Unknown";
}
}
static const char * wpa_key_mgmt_txt(int key_mgmt, int proto)
{
switch (key_mgmt) {
case WPA_KEY_MGMT_IEEE8021X_:
/*
return proto == WPA_PROTO_RSN_ ?
"WPA2/IEEE 802.1X/EAP" : "WPA/IEEE 802.1X/EAP";
*/
return "WPA-Enterprise";
case WPA_KEY_MGMT_IEEE8021X2_:
return "WPA2-Enterprise";
case WPA_KEY_MGMT_PSK_:
/*
return proto == WPA_PROTO_RSN_ ?
"WPA2-PSK" : "WPA-PSK";
*/
return "WPA-Personal";
case WPA_KEY_MGMT_PSK2_:
return "WPA2-Personal";
case WPA_KEY_MGMT_NONE_:
return "NONE";
case WPA_KEY_MGMT_IEEE8021X_NO_WPA_:
// return "IEEE 802.1X (no WPA)";
return "IEEE 802.1X";
default:
return "Unknown";
}
}
static char scan_result[WLC_SCAN_RESULT_BUF_LEN];
int
ej_SiteSurvey(int eid, webs_t wp, int argc, char_t **argv)
{
int ret, i, k, left, ht_extcha;
int retval = 0, ap_count = 0, idx_same = -1, count = 0;
unsigned char *bssidp;
unsigned char rate;
unsigned char bssid[6];
char macstr[18];
char ure_mac[18];
char ssid_str[256];
wl_scan_results_t *result;
wl_bss_info_t *info;
wl_bss_info_107_t *old_info;
struct bss_ie_hdr *ie;
NDIS_802_11_NETWORK_TYPE NetWorkType;
struct maclist *authorized = NULL;
int mac_list_size;
int wl_authorized = 0;
wl_scan_params_t *params;
int params_size = WL_SCAN_PARAMS_FIXED_SIZE + NUMCHANS * sizeof(uint16);
int org_scan_time = 20, scan_time = 40;
#ifdef RTN12
if (nvram_invmatch("sw_mode_ex", "2"))
{
retval += websWrite(wp, "[");
retval += websWrite(wp, "];");
return retval;
}
#endif
params = (wl_scan_params_t*)malloc(params_size);
if (params == NULL)
return retval;
memset(params, 0, params_size);
params->bss_type = DOT11_BSSTYPE_INFRASTRUCTURE;
memcpy(¶ms->bssid, ðer_bcast, ETHER_ADDR_LEN);
params->scan_type = -1;
params->nprobes = -1;
params->active_time = -1;
params->passive_time = -1;
params->home_time = -1;
params->channel_num = 0;
/* extend scan channel time to get more AP probe resp */
wl_ioctl(WIF, WLC_GET_SCAN_CHANNEL_TIME, &org_scan_time, sizeof(org_scan_time));
if (org_scan_time < scan_time)
wl_ioctl(WIF, WLC_SET_SCAN_CHANNEL_TIME, &scan_time, sizeof(scan_time));
while ((ret = wl_ioctl(WIF, WLC_SCAN, params, params_size)) < 0 && count++ < 2)
{
fprintf(stderr, "set scan command failed, retry %d\n", count);
sleep(1);
}
free(params);
/* restore original scan channel time */
wl_ioctl(WIF, WLC_SET_SCAN_CHANNEL_TIME, &org_scan_time, sizeof(org_scan_time));
nvram_set("ap_selecting", "1");
fprintf(stderr, "Please wait (web hook) ");
fprintf(stderr, ".");
sleep(1);
fprintf(stderr, ".");
sleep(1);
fprintf(stderr, ".\n\n");
sleep(1);
nvram_set("ap_selecting", "0");
if (ret == 0)
{
count = 0;
result = (wl_scan_results_t *)scan_result;
result->buflen = htod32(WLC_SCAN_RESULT_BUF_LEN);
while ((ret = wl_ioctl(WIF, WLC_SCAN_RESULTS, result, WLC_SCAN_RESULT_BUF_LEN)) < 0 && count++ < 2)
{
fprintf(stderr, "set scan results command failed, retry %d\n", count);
sleep(1);
}
if (ret == 0)
{
info = &(result->bss_info[0]);
/* Convert version 107 to 109 */
if (dtoh32(info->version) == LEGACY_WL_BSS_INFO_VERSION) {
old_info = (wl_bss_info_107_t *)info;
info->chanspec = CH20MHZ_CHSPEC(old_info->channel);
info->ie_length = old_info->ie_length;
info->ie_offset = sizeof(wl_bss_info_107_t);
}
for (i = 0; i < result->count; i++)
{
if (info->SSID_len > 32/* || info->SSID_len == 0*/)
goto next_info;
#if 0
SSID_valid = 1;
for (j = 0; j < info->SSID_len; j++)
{
if (info->SSID[j] < 32 || info->SSID[j] > 126)
{
SSID_valid = 0;
break;
}
}
if (!SSID_valid)
goto next_info;
#endif
bssidp = (unsigned char *)&info->BSSID;
sprintf(macstr, "%02X:%02X:%02X:%02X:%02X:%02X", (unsigned char)bssidp[0],
(unsigned char)bssidp[1],
(unsigned char)bssidp[2],
(unsigned char)bssidp[3],
(unsigned char)bssidp[4],
(unsigned char)bssidp[5]);
idx_same = -1;
for (k = 0; k < ap_count; k++) // deal with old version of Broadcom Multiple SSID (share the same BSSID)
{
if (strcmp(apinfos[k].BSSID, macstr) == 0 && strcmp(apinfos[k].SSID, (char *)info->SSID) == 0)
{
idx_same = k;
break;
}
}
if (idx_same != -1)
{
if (info->RSSI >= -50)
apinfos[idx_same].RSSI_Quality = 100;
else if (info->RSSI >= -80) // between -50 ~ -80dbm
apinfos[idx_same].RSSI_Quality = (int)(24 + ((info->RSSI + 80) * 26)/10);
else if (info->RSSI >= -90) // between -80 ~ -90dbm
apinfos[idx_same].RSSI_Quality = (int)(((info->RSSI + 90) * 26)/10);
else // < -84 dbm
apinfos[idx_same].RSSI_Quality = 0;
}
else
{
strcpy(apinfos[ap_count].BSSID, macstr);
// strcpy(apinfos[ap_count].SSID, info->SSID);
memset(apinfos[ap_count].SSID, 0x0, 33);
memcpy(apinfos[ap_count].SSID, info->SSID, info->SSID_len);
apinfos[ap_count].channel = (uint8)(info->chanspec & WL_CHANSPEC_CHAN_MASK);
apinfos[ap_count].ctl_ch = info->ctl_ch;
if (info->RSSI >= -50)
apinfos[ap_count].RSSI_Quality = 100;
else if (info->RSSI >= -80) // between -50 ~ -80dbm
apinfos[ap_count].RSSI_Quality = (int)(24 + ((info->RSSI + 80) * 26)/10);
else if (info->RSSI >= -90) // between -80 ~ -90dbm
apinfos[ap_count].RSSI_Quality = (int)(((info->RSSI + 90) * 26)/10);
else // < -84 dbm
apinfos[ap_count].RSSI_Quality = 0;
if ((info->capability & 0x10) == 0x10)
apinfos[ap_count].wep = 1;
else
apinfos[ap_count].wep = 0;
apinfos[ap_count].wpa = 0;
/*
unsigned char *RATESET = &info->rateset;
for (k = 0; k < 18; k++)
fprintf(stderr, "%02x ", (unsigned char)RATESET[k]);
fprintf(stderr, "\n");
*/
NetWorkType = Ndis802_11DS;
if ((uint8)(info->chanspec & WL_CHANSPEC_CHAN_MASK) <= 14)
{
for (k = 0; k < info->rateset.count; k++)
{
rate = info->rateset.rates[k] & 0x7f; // Mask out basic rate set bit
if ((rate == 2) || (rate == 4) || (rate == 11) || (rate == 22))
continue;
else
{
NetWorkType = Ndis802_11OFDM24;
break;
}
}
}
else
NetWorkType = Ndis802_11OFDM5;
if (info->n_cap)
{
if (NetWorkType == Ndis802_11OFDM5)
{
#ifdef RTCONFIG_BCMWL6
if (info->vht_cap)
NetWorkType = Ndis802_11OFDM5_VHT;
else
#endif
NetWorkType = Ndis802_11OFDM5_N;
}
else
NetWorkType = Ndis802_11OFDM24_N;
}
apinfos[ap_count].NetworkType = NetWorkType;
ap_count++;
if (ap_count >= MAX_NUMBER_OF_APINFO)
break;
}
ie = (struct bss_ie_hdr *) ((unsigned char *) info + sizeof(*info));
for (left = info->ie_length; left > 0; // look for RSN IE first
left -= (ie->len + 2), ie = (struct bss_ie_hdr *) ((unsigned char *) ie + 2 + ie->len))
{
if (ie->elem_id != DOT11_MNG_RSN_ID)
continue;
if (wpa_parse_wpa_ie(&ie->elem_id, ie->len + 2, &apinfos[ap_count - 1].wid) == 0)
{
apinfos[ap_count-1].wpa = 1;
goto next_info;
}
}
ie = (struct bss_ie_hdr *) ((unsigned char *) info + sizeof(*info));
for (left = info->ie_length; left > 0; // then look for WPA IE
left -= (ie->len + 2), ie = (struct bss_ie_hdr *) ((unsigned char *) ie + 2 + ie->len))
{
if (ie->elem_id != DOT11_MNG_WPA_ID)
continue;
if (wpa_parse_wpa_ie(&ie->elem_id, ie->len + 2, &apinfos[ap_count-1].wid) == 0)
{
apinfos[ap_count-1].wpa = 1;
break;
}
}
next_info:
info = (wl_bss_info_t *) ((unsigned char *) info + info->length);
}
}
}
if (ap_count == 0)
{
fprintf(stderr, "No AP found!\n");
}
else
{
fprintf(stderr, "%-4s%-3s%-33s%-18s%-9s%-16s%-9s%8s%3s%3s\n",
"idx", "CH", "SSID", "BSSID", "Enc", "Auth", "Siganl(%)", "W-Mode", "CC", "EC");
for (k = 0; k < ap_count; k++)
{
fprintf(stderr, "%2d. ", k + 1);
fprintf(stderr, "%2d ", apinfos[k].ctl_ch);
fprintf(stderr, "%-33s", apinfos[k].SSID);
fprintf(stderr, "%-18s", apinfos[k].BSSID);
if (apinfos[k].wpa == 1)
fprintf(stderr, "%-9s%-16s", wpa_cipher_txt(apinfos[k].wid.pairwise_cipher), wpa_key_mgmt_txt(apinfos[k].wid.key_mgmt, apinfos[k].wid.proto));
else if (apinfos[k].wep == 1)
fprintf(stderr, "WEP Unknown ");
else
fprintf(stderr, "NONE Open System ");
fprintf(stderr, "%9d ", apinfos[k].RSSI_Quality);
if (apinfos[k].NetworkType == Ndis802_11FH || apinfos[k].NetworkType == Ndis802_11DS)
fprintf(stderr, "%-7s", "11b");
else if (apinfos[k].NetworkType == Ndis802_11OFDM5)
fprintf(stderr, "%-7s", "11a");
else if (apinfos[k].NetworkType == Ndis802_11OFDM5_N)
fprintf(stderr, "%-7s", "11a/n");
#ifdef RTCONFIG_BCMWL6
else if (apinfos[k].NetworkType == Ndis802_11OFDM5_VHT)
fprintf(stderr, "%-7s", "11ac");
#endif
else if (apinfos[k].NetworkType == Ndis802_11OFDM24)
fprintf(stderr, "%-7s", "11b/g");
else if (apinfos[k].NetworkType == Ndis802_11OFDM24_N)
fprintf(stderr, "%-7s", "11b/g/n");
else
fprintf(stderr, "%-7s", "unknown");
fprintf(stderr, "%3d", apinfos[k].ctl_ch);
if ( (
#ifdef RTCONFIG_BCMWL6
(apinfos[k].NetworkType == Ndis802_11OFDM5_VHT) ||
#endif
(apinfos[k].NetworkType == Ndis802_11OFDM5_N) || (apinfos[k].NetworkType == Ndis802_11OFDM24_N)) &&
(apinfos[k].channel != apinfos[k].ctl_ch))
{
if (apinfos[k].ctl_ch < apinfos[k].channel)
ht_extcha = 1;
else
ht_extcha = 0;
fprintf(stderr, "%3d", ht_extcha);
}
fprintf(stderr, "\n");
}
}
ret = wl_ioctl(WIF, WLC_GET_BSSID, bssid, sizeof(bssid));
memset(ure_mac, 0x0, 18);
if (!ret)
{
if ( !(!bssid[0] && !bssid[1] && !bssid[2] && !bssid[3] && !bssid[4] && !bssid[5]) )
{
sprintf(ure_mac, "%02X:%02X:%02X:%02X:%02X:%02X", (unsigned char)bssid[0],
(unsigned char)bssid[1],
(unsigned char)bssid[2],
(unsigned char)bssid[3],
(unsigned char)bssid[4],
(unsigned char)bssid[5]);
}
}
if (strstr(nvram_safe_get("wl0_akm"), "psk"))
{
mac_list_size = sizeof(authorized->count) + MAX_STA_COUNT * sizeof(struct ether_addr);
authorized = malloc(mac_list_size);
if (!authorized) goto ap_list;
memset(authorized, 0, mac_list_size);
// query wl for authorized sta list
strcpy((char*)authorized, "autho_sta_list");
if (!wl_ioctl(WIF, WLC_GET_VAR, authorized, mac_list_size))
{
if (authorized->count > 0) wl_authorized = 1;
}
if (authorized) free(authorized);
}
ap_list:
retval += websWrite(wp, "[");
if (ap_count > 0)
for (i = 0; i < ap_count; i++)
{
retval += websWrite(wp, "[");
if (strlen(apinfos[i].SSID) == 0)
retval += websWrite(wp, "\"\", ");
else
{
memset(ssid_str, 0, sizeof(ssid_str));
char_to_ascii(ssid_str, apinfos[i].SSID);
retval += websWrite(wp, "\"%s\", ", ssid_str);
}
retval += websWrite(wp, "\"%d\", ", apinfos[i].ctl_ch);
if (apinfos[i].wpa == 1)
{
if (apinfos[i].wid.key_mgmt == WPA_KEY_MGMT_IEEE8021X_)
retval += websWrite(wp, "\"%s\", ", "WPA");
else if (apinfos[i].wid.key_mgmt == WPA_KEY_MGMT_IEEE8021X2_)
retval += websWrite(wp, "\"%s\", ", "WPA2");
else if (apinfos[i].wid.key_mgmt == WPA_KEY_MGMT_PSK_)
retval += websWrite(wp, "\"%s\", ", "WPA-PSK");
else if (apinfos[i].wid.key_mgmt == WPA_KEY_MGMT_PSK2_)
retval += websWrite(wp, "\"%s\", ", "WPA2-PSK");
else if (apinfos[i].wid.key_mgmt == WPA_KEY_MGMT_NONE_)
retval += websWrite(wp, "\"%s\", ", "NONE");
else if (apinfos[i].wid.key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA_)
retval += websWrite(wp, "\"%s\", ", "IEEE 802.1X");
else
retval += websWrite(wp, "\"%s\", ", "Unknown");
}
else if (apinfos[i].wep == 1)
retval += websWrite(wp, "\"%s\", ", "Unknown");
else
retval += websWrite(wp, "\"%s\", ", "Open System");
if (apinfos[i].wpa == 1)
{
if (apinfos[i].wid.pairwise_cipher == WPA_CIPHER_NONE_)
retval += websWrite(wp, "\"%s\", ", "NONE");
else if (apinfos[i].wid.pairwise_cipher == WPA_CIPHER_WEP40_)
retval += websWrite(wp, "\"%s\", ", "WEP");
else if (apinfos[i].wid.pairwise_cipher == WPA_CIPHER_WEP104_)
retval += websWrite(wp, "\"%s\", ", "WEP");
else if (apinfos[i].wid.pairwise_cipher == WPA_CIPHER_TKIP_)
retval += websWrite(wp, "\"%s\", ", "TKIP");
else if (apinfos[i].wid.pairwise_cipher == WPA_CIPHER_CCMP_)
retval += websWrite(wp, "\"%s\", ", "AES");
else if (apinfos[i].wid.pairwise_cipher == (WPA_CIPHER_TKIP_|WPA_CIPHER_CCMP_))
retval += websWrite(wp, "\"%s\", ", "TKIP+AES");
else
retval += websWrite(wp, "\"%s\", ", "Unknown");
}
else if (apinfos[i].wep == 1)
retval += websWrite(wp, "\"%s\", ", "WEP");
else
retval += websWrite(wp, "\"%s\", ", "NONE");
retval += websWrite(wp, "\"%d\", ", apinfos[i].RSSI_Quality);
retval += websWrite(wp, "\"%s\", ", apinfos[i].BSSID);
retval += websWrite(wp, "\"%s\", ", "In");
if (apinfos[i].NetworkType == Ndis802_11FH || apinfos[i].NetworkType == Ndis802_11DS)
retval += websWrite(wp, "\"%s\", ", "b");
else if (apinfos[i].NetworkType == Ndis802_11OFDM5)
retval += websWrite(wp, "\"%s\", ", "a");
else if (apinfos[i].NetworkType == Ndis802_11OFDM5_N)
retval += websWrite(wp, "\"%s\", ", "an");
#ifdef RTCONFIG_BCMWL6
else if (apinfos[i].NetworkType == Ndis802_11OFDM5_VHT)
retval += websWrite(wp, "\"%s\", ", "ac");
#endif
else if (apinfos[i].NetworkType == Ndis802_11OFDM24)
retval += websWrite(wp, "\"%s\", ", "bg");
else if (apinfos[i].NetworkType == Ndis802_11OFDM24_N)
retval += websWrite(wp, "\"%s\", ", "bgn");
else
retval += websWrite(wp, "\"%s\", ", "");
if (nvram_invmatch("wl0_ssid", "") && strcmp(nvram_safe_get("wl0_ssid"), apinfos[i].SSID))
{
if (strcmp(apinfos[i].SSID, ""))
retval += websWrite(wp, "\"%s\"", "0"); // none
else if (!strcmp(ure_mac, apinfos[i].BSSID))
{ // hidden AP (null SSID)
if (strstr(nvram_safe_get("wl0_akm"), "psk"))
{
if (wl_authorized)
retval += websWrite(wp, "\"%s\"", "4"); // in profile, connected
else
retval += websWrite(wp, "\"%s\"", "5"); // in profile, connecting
}
else
retval += websWrite(wp, "\"%s\"", "4"); // in profile, connected
}
else // hidden AP (null SSID)
retval += websWrite(wp, "\"%s\"", "0"); // none
}
else if (nvram_invmatch("wl0_ssid", "") && !strcmp(nvram_safe_get("wl0_ssid"), apinfos[i].SSID))
{
if (!strlen(ure_mac))
retval += websWrite(wp, "\"%s\", ", "1"); // in profile, disconnected
else if (!strcmp(ure_mac, apinfos[i].BSSID))
{
if (strstr(nvram_safe_get("wl0_akm"), "psk"))
{
if (wl_authorized)
retval += websWrite(wp, "\"%s\"", "2"); // in profile, connected
else
retval += websWrite(wp, "\"%s\"", "3"); // in profile, connecting
}
else
retval += websWrite(wp, "\"%s\"", "2"); // in profile, connected
}
else
retval += websWrite(wp, "\"%s\"", "0"); // impossible...
}
else
retval += websWrite(wp, "\"%s\"", "0"); // wl0_ssid == ""
if (i == ap_count - 1)
retval += websWrite(wp, "]\n");
else
retval += websWrite(wp, "],\n");
}
retval += websWrite(wp, "];");
return retval;
}
int
ej_urelease(int eid, webs_t wp, int argc, char_t **argv)
{
int retval = 0;
if ( nvram_match("sw_mode_ex", "2") &&
nvram_invmatch("lan_ipaddr_new", "") &&
nvram_invmatch("lan_netmask_new", "") &&
nvram_invmatch("lan_gateway_new", ""))
{
retval += websWrite(wp, "[");
retval += websWrite(wp, "\"%s\", ", nvram_safe_get("lan_ipaddr_new"));
retval += websWrite(wp, "\"%s\", ", nvram_safe_get("lan_netmask_new"));
retval += websWrite(wp, "\"%s\"", nvram_safe_get("lan_gateway_new"));
retval += websWrite(wp, "];");
kill_pidfile_s("/var/run/ure_monitor.pid", SIGUSR1);
}
else
{
retval += websWrite(wp, "[");
retval += websWrite(wp, "\"\", ");
retval += websWrite(wp, "\"\", ");
retval += websWrite(wp, "\"\"");
retval += websWrite(wp, "];");
}
return retval;
}
#if 0
static bool find_ethaddr_in_list(void *ethaddr, struct maclist *list) {
int i;
for (i = 0; i < list->count; ++i)
if (!bcmp(ethaddr, (void *)&list->ea[i], ETHER_ADDR_LEN))
return TRUE;
return FALSE;
}
#endif
static int wl_sta_list(int eid, webs_t wp, int argc, char_t **argv, int unit) {
char tmp[128], prefix[] = "wlXXXXXXXXXX_";
char *name;
struct maclist *auth = NULL;
int mac_list_size;
int i, firstRow = 1;
char ea[ETHER_ADDR_STR_LEN];
scb_val_t scb_val;
char *value;
char name_vif[] = "wlX.Y_XXXXXXXXXX";
int ii;
int ret = 0;
sta_info_t *sta;
int from_app = 0;
from_app = check_user_agent(user_agent);
snprintf(prefix, sizeof(prefix), "wl%d_", unit);
name = nvram_safe_get(strcat_r(prefix, "ifname", tmp));
#ifdef RTCONFIG_WIRELESSREPEATER
if ((nvram_get_int("sw_mode") == SW_MODE_REPEATER)
&& (nvram_get_int("wlc_band") == unit))
{
sprintf(name_vif, "wl%d.%d", unit, 1);
name = name_vif;
}
#endif
if (!strlen(name))
goto exit;
/* buffers and length */
mac_list_size = sizeof(auth->count) + MAX_STA_COUNT * sizeof(struct ether_addr);
auth = malloc(mac_list_size);
if (!auth)
goto exit;
memset(auth, 0, mac_list_size);
/* query wl for authenticated sta list */
strcpy((char*)auth, "authe_sta_list");
if (wl_ioctl(name, WLC_GET_VAR, auth, mac_list_size))
goto exit;
/* build authenticated sta list */
for (i = 0; i < auth->count; ++i) {
sta = wl_sta_info(name, &auth->ea[i]);
if (!sta) continue;
if (!(sta->flags & WL_STA_ASSOC) && !sta->in) continue;
if (firstRow == 1)
firstRow = 0;
else
ret += websWrite(wp, ", ");
if (from_app == 0)
ret += websWrite(wp, "[");
ret += websWrite(wp, "\"%s\"", ether_etoa((void *)&auth->ea[i], ea));
if (from_app != 0) {
ret += websWrite(wp, ":{");
ret += websWrite(wp, "\"isWL\":");
}
value = (sta->flags & WL_STA_ASSOC) ? "Yes" : "No";
if (from_app == 0)
ret += websWrite(wp, ", \"%s\"", value);
else
ret += websWrite(wp, "\"%s\"", value);
value = (sta->flags & WL_STA_AUTHO) ? "Yes" : "No";
if (from_app == 0)
ret += websWrite(wp, ", \"%s\"", value);
if (from_app != 0) {
ret += websWrite(wp, ",\"rssi\":");
}
memcpy(&scb_val.ea, &auth->ea[i], ETHER_ADDR_LEN);
if (wl_ioctl(name, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t))) {
if (from_app == 0)
ret += websWrite(wp, ", \"%d\"", 0);
else
ret += websWrite(wp, "\"%d\"", 0);
} else {
if (from_app == 0)
ret += websWrite(wp, ", \"%d\"", scb_val.val);
else
ret += websWrite(wp, "\"%d\"", scb_val.val);
}
if (from_app == 0)
ret += websWrite(wp, "]");
else
ret += websWrite(wp, "}");
}
for (i = 1; i < 4; i++) {
#ifdef RTCONFIG_WIRELESSREPEATER
if ((nvram_get_int("sw_mode") == SW_MODE_REPEATER)
&& (unit == nvram_get_int("wlc_band")) && (i == 1))
break;
#endif
sprintf(prefix, "wl%d.%d_", unit, i);
if (nvram_match(strcat_r(prefix, "bss_enabled", tmp), "1"))
{
sprintf(name_vif, "wl%d.%d", unit, i);
memset(auth, 0, mac_list_size);
/* query wl for authenticated sta list */
strcpy((char*)auth, "authe_sta_list");
if (wl_ioctl(name_vif, WLC_GET_VAR, auth, mac_list_size))
goto exit;
for (ii = 0; ii < auth->count; ii++) {
sta = wl_sta_info(name_vif, &auth->ea[ii]);
if (!sta) continue;
if (!(sta->flags & WL_STA_ASSOC) && !sta->in) continue;
if (firstRow == 1)
firstRow = 0;
else
ret += websWrite(wp, ", ");
if (from_app == 0)
ret += websWrite(wp, "[");
ret += websWrite(wp, "\"%s\"", ether_etoa((void *)&auth->ea[ii], ea));
if (from_app != 0) {
ret += websWrite(wp, ":{");
ret += websWrite(wp, "\"isWL\":");
}
value = (sta->flags & WL_STA_ASSOC) ? "Yes" : "No";
if (from_app == 0)
ret += websWrite(wp, ", \"%s\"", value);
else
ret += websWrite(wp, "\"%s\"", value);
value = (sta->flags & WL_STA_AUTHO) ? "Yes" : "No";
if (from_app == 0)
ret += websWrite(wp, ", \"%s\"", value);
if (from_app != 0) {
ret += websWrite(wp, ",\"rssi\":");
}
memcpy(&scb_val.ea, &auth->ea[ii], ETHER_ADDR_LEN);
if (wl_ioctl(name_vif, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t))) {
if (from_app == 0)
ret += websWrite(wp, ", \"%d\"", 0);
else
ret += websWrite(wp, "\"%d\"", 0);
} else {
if (from_app == 0)
ret += websWrite(wp, ", \"%d\"", scb_val.val);
else
ret += websWrite(wp, "\"%d\"", scb_val.val);
}
if (from_app == 0)
ret += websWrite(wp, "]");
else
ret += websWrite(wp, "}");
}
}
}
/* error/exit */
exit:
if (auth) free(auth);
return ret;
}
#ifdef RTCONFIG_STAINFO
static int wl_stainfo_list(int eid, webs_t wp, int argc, char_t **argv, int unit) {
char tmp[128], prefix[] = "wlXXXXXXXXXX_";
char *name;
struct maclist *auth = NULL;
int mac_list_size;
int i, firstRow = 1;
char ea[ETHER_ADDR_STR_LEN];
char name_vif[] = "wlX.Y_XXXXXXXXXX";
int ii;
int ret = 0;
sta_info_t *sta;
char rate_buf[8];
int hr, min, sec;
snprintf(prefix, sizeof(prefix), "wl%d_", unit);
name = nvram_safe_get(strcat_r(prefix, "ifname", tmp));
#ifdef RTCONFIG_WIRELESSREPEATER
if ((nvram_get_int("sw_mode") == SW_MODE_REPEATER)
&& (nvram_get_int("wlc_band") == unit))
{
sprintf(name_vif, "wl%d.%d", unit, 1);
name = name_vif;
}
#endif
if (!strlen(name))
goto exit;
/* buffers and length */
mac_list_size = sizeof(auth->count) + MAX_STA_COUNT * sizeof(struct ether_addr);
auth = malloc(mac_list_size);
if (!auth)
goto exit;
memset(auth, 0, mac_list_size);
/* query wl for authenticated sta list */
strcpy((char*)auth, "authe_sta_list");
if (wl_ioctl(name, WLC_GET_VAR, auth, mac_list_size))
goto exit;
/* build authenticated sta list */
for (i = 0; i < auth->count; ++i) {
sta = wl_sta_info(name, &auth->ea[i]);
if (!sta) continue;
if (!(sta->flags & WL_STA_ASSOC) && !sta->in) continue;
if (firstRow == 1)
firstRow = 0;
else
ret += websWrite(wp, ", ");
ret += websWrite(wp, "[");
ret += websWrite(wp, "\"%s\"", ether_etoa((void *)&auth->ea[i], ea));
ret += websWrite(wp, ", \"%s\"", print_rate_buf_compact(sta->tx_rate, rate_buf));
ret += websWrite(wp, ", \"%s\"", print_rate_buf_compact(sta->rx_rate, rate_buf));
hr = sta->in / 3600;
min = (sta->in % 3600) / 60;
sec = sta->in - hr * 3600 - min * 60;
ret += websWrite(wp, ", \"%02d:%02d:%02d\"", hr, min, sec);
ret += websWrite(wp, "]");
}
for (i = 1; i < 4; i++) {
#ifdef RTCONFIG_WIRELESSREPEATER
if ((nvram_get_int("sw_mode") == SW_MODE_REPEATER)
&& (unit == nvram_get_int("wlc_band")) && (i == 1))
break;
#endif
sprintf(prefix, "wl%d.%d_", unit, i);
if (nvram_match(strcat_r(prefix, "bss_enabled", tmp), "1"))
{
sprintf(name_vif, "wl%d.%d", unit, i);
memset(auth, 0, mac_list_size);
/* query wl for authenticated sta list */
strcpy((char*)auth, "authe_sta_list");
if (wl_ioctl(name_vif, WLC_GET_VAR, auth, mac_list_size))
goto exit;
for (ii = 0; ii < auth->count; ii++) {
sta = wl_sta_info(name_vif, &auth->ea[ii]);
if (!sta) continue;
if (!(sta->flags & WL_STA_ASSOC) && !sta->in) continue;
if (firstRow == 1)
firstRow = 0;
else
ret += websWrite(wp, ", ");
ret += websWrite(wp, "[");
ret += websWrite(wp, "\"%s\"", ether_etoa((void *)&auth->ea[ii], ea));
ret += websWrite(wp, ", \"%s\"", print_rate_buf_compact(sta->tx_rate, rate_buf));
ret += websWrite(wp, ", \"%s\"", print_rate_buf_compact(sta->rx_rate, rate_buf));
hr = sta->in / 3600;
min = (sta->in % 3600) / 60;
sec = sta->in - hr * 3600 - min * 60;
ret += websWrite(wp, ", \"%02d:%02d:%02d\"", hr, min, sec);
ret += websWrite(wp, "]");
}
}
}
/* error/exit */
exit:
if (auth) free(auth);
return ret;
}
#endif
int
ej_wl_sta_list_2g(int eid, webs_t wp, int argc, char_t **argv)
{
return wl_sta_list(eid, wp, argc, argv, 0);
}
#ifndef RTCONFIG_QTN
int
ej_wl_sta_list_5g(int eid, webs_t wp, int argc, char_t **argv)
{
return wl_sta_list(eid, wp, argc, argv, 1);
}
int
ej_wl_sta_list_5g_2(int eid, webs_t wp, int argc, char_t **argv)
{
return wl_sta_list(eid, wp, argc, argv, 2);
}
#else
extern int ej_wl_sta_list_5g(int eid, webs_t wp, int argc, char_t **argv);
#endif
#ifdef RTCONFIG_STAINFO
int
ej_wl_stainfo_list_2g(int eid, webs_t wp, int argc, char_t **argv)
{
return wl_stainfo_list(eid, wp, argc, argv, 0);
}
#ifndef RTCONFIG_QTN
int
ej_wl_stainfo_list_5g(int eid, webs_t wp, int argc, char_t **argv)
{
return wl_stainfo_list(eid, wp, argc, argv, 1);
}
int
ej_wl_stainfo_list_5g_2(int eid, webs_t wp, int argc, char_t **argv)
{
return wl_stainfo_list(eid, wp, argc, argv, 2);
}
#else
extern int ej_wl_stainfo_list_5g(int eid, webs_t wp, int argc, char_t **argv);
#endif
#endif
// no WME in WL500gP V2
// MAC/associated/authorized
int ej_wl_auth_list(int eid, webs_t wp, int argc, char_t **argv) {
int unit = 0;
char tmp[128], prefix[] = "wlXXXXXXXXXX_";
char *name;
struct maclist *auth = NULL;
int mac_list_size;
int i, firstRow = 1;
char ea[ETHER_ADDR_STR_LEN];
char *value;
char word[256], *next;
char name_vif[] = "wlX.Y_XXXXXXXXXX";
int ii;
int ret = 0;
sta_info_t *sta;
/* buffers and length */
mac_list_size = sizeof(auth->count) + MAX_STA_COUNT * sizeof(struct ether_addr);
auth = malloc(mac_list_size);
//wme = malloc(mac_list_size);
//if (!auth || !wme)
if (!auth)
goto exit;
foreach (word, nvram_safe_get("wl_ifnames"), next) {
#ifdef RTCONFIG_QTN
if (unit) {
if (rpc_qtn_ready()) {
if (firstRow == 1)
firstRow = 0;
else
ret += websWrite(wp, ", ");
ret += ej_wl_sta_list_5g(eid, wp, argc, argv);
}
return ret;
}
#endif
snprintf(prefix, sizeof(prefix), "wl%d_", unit);
name = nvram_safe_get(strcat_r(prefix, "ifname", tmp));
memset(auth, 0, mac_list_size);
//memset(wme, 0, mac_list_size);
/* query wl for authenticated sta list */
strcpy((char*)auth, "authe_sta_list");
if (wl_ioctl(name, WLC_GET_VAR, auth, mac_list_size))
goto exit;
/* query wl for WME sta list */
/*strcpy((char*)wme, "wme_sta_list");
if (wl_ioctl(name, WLC_GET_VAR, wme, mac_list_size))
goto exit;*/
/* build authenticated/associated sta list */
for (i = 0; i < auth->count; ++i) {
sta = wl_sta_info(name, &auth->ea[i]);
if (!sta) continue;
if (!(sta->flags & WL_STA_ASSOC) && !sta->in) continue;
if (firstRow == 1)
firstRow = 0;
else
ret += websWrite(wp, ", ");
ret += websWrite(wp, "[");
ret += websWrite(wp, "\"%s\"", ether_etoa((void *)&auth->ea[i], ea));
value = (sta->flags & WL_STA_ASSOC) ? "Yes" : "No";
ret += websWrite(wp, ", \"%s\"", value);
value = (sta->flags & WL_STA_AUTHO) ? "Yes" : "No";
ret += websWrite(wp, ", \"%s\"", value);
/*value = (find_ethaddr_in_list((void *)&auth->ea[i], wme))?"Yes":"No";
ret += websWrite(wp, ", \"%s\"", value);*/
ret += websWrite(wp, "]");
}
for (i = 1; i < 4; i++) {
#ifdef RTCONFIG_WIRELESSREPEATER
if ((nvram_get_int("sw_mode") == SW_MODE_REPEATER)
&& (unit == nvram_get_int("wlc_band")) && (i == 1))
break;
#endif
sprintf(prefix, "wl%d.%d_", unit, i);
if (nvram_match(strcat_r(prefix, "bss_enabled", tmp), "1"))
{
sprintf(name_vif, "wl%d.%d", unit, i);
memset(auth, 0, mac_list_size);
/* query wl for authenticated sta list */
strcpy((char*)auth, "authe_sta_list");
if (wl_ioctl(name_vif, WLC_GET_VAR, auth, mac_list_size))
goto exit;
for (ii = 0; ii < auth->count; ii++) {
sta = wl_sta_info(name_vif, &auth->ea[ii]);
if (!sta) continue;
if (!(sta->flags & WL_STA_ASSOC) && !sta->in) continue;
if (firstRow == 1)
firstRow = 0;
else
ret += websWrite(wp, ", ");
ret += websWrite(wp, "[");
ret += websWrite(wp, "\"%s\"", ether_etoa((void *)&auth->ea[ii], ea));
value = (sta->flags & WL_STA_ASSOC) ? "Yes" : "No";
ret += websWrite(wp, ", \"%s\"", value);
value = (sta->flags & WL_STA_AUTHO) ? "Yes" : "No";
ret += websWrite(wp, ", \"%s\"", value);
ret += websWrite(wp, "]");
}
}
}
unit++;
}
/* error/exit */
exit:
if (auth) free(auth);
//if (wme) free(wme);
return ret;
}
/* WPS ENR mode APIs */
typedef struct wlc_ap_list_info
{
#if 0
bool used;
#endif
uint8 ssid[33];
uint8 ssidLen;
uint8 BSSID[6];
#if 0
uint8 *ie_buf;
uint32 ie_buflen;
#endif
uint8 channel;
#if 0
uint8 wep;
bool scstate;
#endif
} wlc_ap_list_info_t;
#define WLC_MAX_AP_SCAN_LIST_LEN 50
#define WLC_SCAN_RETRY_TIMES 5
static wlc_ap_list_info_t ap_list[WLC_MAX_AP_SCAN_LIST_LEN];
static char *
wl_get_scan_results(char *ifname)
{
int ret, retry_times = 0;
wl_scan_params_t *params;
wl_scan_results_t *list = (wl_scan_results_t*)scan_result;
int params_size = WL_SCAN_PARAMS_FIXED_SIZE + NUMCHANS * sizeof(uint16);
int org_scan_time = 20, scan_time = 40;
params = (wl_scan_params_t*)malloc(params_size);
if (params == NULL) {
return NULL;
}
memset(params, 0, params_size);
params->bss_type = DOT11_BSSTYPE_ANY;
memcpy(¶ms->bssid, ðer_bcast, ETHER_ADDR_LEN);
params->scan_type = -1;
params->nprobes = -1;
params->active_time = -1;
params->passive_time = -1;
params->home_time = -1;
params->channel_num = 0;
/* extend scan channel time to get more AP probe resp */
wl_ioctl(ifname, WLC_GET_SCAN_CHANNEL_TIME, &org_scan_time, sizeof(org_scan_time));
if (org_scan_time < scan_time)
wl_ioctl(ifname, WLC_SET_SCAN_CHANNEL_TIME, &scan_time, sizeof(scan_time));
retry:
ret = wl_ioctl(ifname, WLC_SCAN, params, params_size);
if (ret < 0) {
if (retry_times++ < WLC_SCAN_RETRY_TIMES) {
printf("set scan command failed, retry %d\n", retry_times);
sleep(1);
goto retry;
}
}
sleep(2);
list->buflen = htod32(WLC_SCAN_RESULT_BUF_LEN);
ret = wl_ioctl(ifname, WLC_SCAN_RESULTS, scan_result, WLC_SCAN_RESULT_BUF_LEN);
if (ret < 0 && retry_times++ < WLC_SCAN_RETRY_TIMES) {
printf("get scan result failed, retry %d\n", retry_times);
sleep(1);
goto retry;
}
free(params);
/* restore original scan channel time */
wl_ioctl(ifname, WLC_SET_SCAN_CHANNEL_TIME, &org_scan_time, sizeof(org_scan_time));
if (ret < 0)
return NULL;
return scan_result;
}
//static wlc_ap_list_info_t *
static int
wl_scan(int eid, webs_t wp, int argc, char_t **argv, int unit)
{
char *name = NULL;
char tmp[128], prefix[] = "wlXXXXXXXXXX_";
wl_scan_results_t *list = (wl_scan_results_t*)scan_result;
wl_bss_info_t *bi;
wl_bss_info_107_t *old_bi;
uint i, ap_count = 0;
unsigned char *bssidp;
char ssid_str[128];
char macstr[18];
int retval = 0;
snprintf(prefix, sizeof(prefix), "wl%d_", unit);
name = nvram_safe_get(strcat_r(prefix, "ifname", tmp));
if (wl_get_scan_results(name) == NULL)
return 0;
if (list->count == 0)
return 0;
else if (list->version != WL_BSS_INFO_VERSION
&& list->version != LEGACY_WL_BSS_INFO_VERSION
#ifdef RTCONFIG_BCMWL6
&& list->version != LEGACY2_WL_BSS_INFO_VERSION
#endif
) {
/* fprintf(stderr, "Sorry, your driver has bss_info_version %d "
"but this program supports only version %d.\n",
list->version, WL_BSS_INFO_VERSION); */
return 0;
}
memset(ap_list, 0, sizeof(ap_list));
bi = list->bss_info;
for (i = 0; i < list->count; i++) {
/* Convert version 107 to 109 */
if (dtoh32(bi->version) == LEGACY_WL_BSS_INFO_VERSION) {
old_bi = (wl_bss_info_107_t *)bi;
bi->chanspec = CH20MHZ_CHSPEC(old_bi->channel);
bi->ie_length = old_bi->ie_length;
bi->ie_offset = sizeof(wl_bss_info_107_t);
}
if (bi->ie_length) {
if (ap_count < WLC_MAX_AP_SCAN_LIST_LEN) {
#if 0
ap_list[ap_count].used = TRUE;
#endif
memcpy(ap_list[ap_count].BSSID, (uint8 *)&bi->BSSID, 6);
strncpy((char *)ap_list[ap_count].ssid, (char *)bi->SSID, bi->SSID_len);
ap_list[ap_count].ssid[bi->SSID_len] = '\0';
ap_list[ap_count].ssidLen= bi->SSID_len;
#if 0
ap_list[ap_count].ie_buf = (uint8 *)(((uint8 *)bi) + bi->ie_offset);
ap_list[ap_count].ie_buflen = bi->ie_length;
#endif
if (dtoh32(bi->version) != LEGACY_WL_BSS_INFO_VERSION && bi->n_cap)
ap_list[ap_count].channel = bi->ctl_ch;
else
ap_list[ap_count].channel = bi->chanspec & WL_CHANSPEC_CHAN_MASK;
#if 0
ap_list[ap_count].wep = bi->capability & DOT11_CAP_PRIVACY;
#endif
ap_count++;
if (ap_count >= WLC_MAX_AP_SCAN_LIST_LEN)
break;
}
}
bi = (wl_bss_info_t*)((int8*)bi + bi->length);
}
sprintf(tmp, "%-4s%-33s%-18s\n", "Ch", "SSID", "BSSID");
dbg("\n%s", tmp);
if (ap_count)
{
retval += websWrite(wp, "[");
for (i = 0; i < ap_count; i++)
{
memset(ssid_str, 0, sizeof(ssid_str));
char_to_ascii(ssid_str, trim_r((char *)ap_list[i].ssid));
bssidp = (unsigned char *)&ap_list[i].BSSID;
sprintf(macstr, "%02X:%02X:%02X:%02X:%02X:%02X",
(unsigned char)bssidp[0],
(unsigned char)bssidp[1],
(unsigned char)bssidp[2],
(unsigned char)bssidp[3],
(unsigned char)bssidp[4],
(unsigned char)bssidp[5]);
dbg("%-4d%-33s%-18s\n",
ap_list[i].channel,
ap_list[i].ssid,
macstr
);
if (!i)
retval += websWrite(wp, "[\"%s\", \"%s\"]", ssid_str, macstr);
else
retval += websWrite(wp, ", [\"%s\", \"%s\"]", ssid_str, macstr);
}
retval += websWrite(wp, "]");
dbg("\n");
}
else
retval += websWrite(wp, "[]");
// return ap_list;
return retval;
}
int
ej_wl_scan(int eid, webs_t wp, int argc, char_t **argv)
{
return wl_scan(eid, wp, argc, argv, 0);
}
int
ej_wl_scan_2g(int eid, webs_t wp, int argc, char_t **argv)
{
return wl_scan(eid, wp, argc, argv, 0);
}
#ifndef RTCONFIG_QTN
int
ej_wl_scan_5g(int eid, webs_t wp, int argc, char_t **argv)
{
return wl_scan(eid, wp, argc, argv, 1);
}
#endif
int
ej_wl_scan_5g_2(int eid, webs_t wp, int argc, char_t **argv)
{
return wl_scan(eid, wp, argc, argv, 2);
}
#ifdef RTCONFIG_PROXYSTA
#define NVRAM_BUFSIZE 100
static int
wl_autho(char *name, struct ether_addr *ea)
{
char buf[sizeof(sta_info_t)];
strcpy(buf, "sta_info");
memcpy(buf + strlen(buf) + 1, (void *)ea, ETHER_ADDR_LEN);
if (!wl_ioctl(name, WLC_GET_VAR, buf, sizeof(buf))) {
sta_info_t *sta = (sta_info_t *)buf;
uint32 f = sta->flags;
if (f & WL_STA_AUTHO)
return 1;
}
return 0;
}
static int psta_auth = 0;
int
ej_wl_auth_psta(int eid, webs_t wp, int argc, char_t **argv)
{
char tmp[NVRAM_BUFSIZE], prefix[] = "wlXXXXXXXXXX_";
char *name;
struct maclist *mac_list = NULL;
int mac_list_size, i, unit;
int retval = 0, psta = 0;
struct ether_addr bssid;
unsigned char bssid_null[6] = {0x0,0x0,0x0,0x0,0x0,0x0};
int psta_debug = 0;
if (nvram_match("psta_debug", "1"))
psta_debug = 1;
unit = nvram_get_int("wlc_band");
#ifdef RTCONFIG_QTN
if (unit == 1) {
return ej_wl_auth_psta_qtn(eid, wp, argc, argv);
}
#endif
snprintf(prefix, sizeof(prefix), "wl%d_", unit);
if (!nvram_match(strcat_r(prefix, "mode", tmp), "psta") &&
!nvram_match(strcat_r(prefix, "mode", tmp), "psr"))
goto PSTA_ERR;
name = nvram_safe_get(strcat_r(prefix, "ifname", tmp));
if (wl_ioctl(name, WLC_GET_BSSID, &bssid, ETHER_ADDR_LEN) != 0)
goto PSTA_ERR;
else if (!memcmp(&bssid, bssid_null, 6))
goto PSTA_ERR;
/* buffers and length */
mac_list_size = sizeof(mac_list->count) + MAX_STA_COUNT * sizeof(struct ether_addr);
mac_list = malloc(mac_list_size);
if (!mac_list)
goto PSTA_ERR;
memset(mac_list, 0, mac_list_size);
/* query wl for authenticated sta list */
strcpy((char*)mac_list, "authe_sta_list");
if (wl_ioctl(name, WLC_GET_VAR, mac_list, mac_list_size)) {
free(mac_list);
goto PSTA_ERR;
}
/* query sta_info for each STA */
if (mac_list->count)
{
if (nvram_match(strcat_r(prefix, "akm", tmp), ""))
psta = 1;
else
for (i = 0, psta = 2; i < mac_list->count; i++) {
if (wl_autho(name, &mac_list->ea[i]))
{
psta = 1;
break;
}
}
}
free(mac_list);
PSTA_ERR:
if (psta == 1)
{
if (psta_debug) dbg("connected\n");
psta_auth = 0;
}
else if (psta == 2)
{
if (psta_debug) dbg("authorization failed\n");
psta_auth = 1;
}
else
{
if (psta_debug) dbg("disconnected\n");
}
retval += websWrite(wp, "wlc_state=%d;", psta);
retval += websWrite(wp, "wlc_state_auth=%d;", psta_auth);
return retval;
}
#endif
| 26.706793 | 146 | 0.63386 |
438dd3bcfed5f565eab0057cc3f4f074ff514d64 | 40,032 | c | C | dpdk-eal-master/drivers/crypto/dpaa_sec/dpaa_sec.c | ictyangye/secure-vhost | 089cf0f17fcff64210e1b094fb0d3ee264c1c3c0 | [
"Intel"
] | 1 | 2021-12-21T07:12:16.000Z | 2021-12-21T07:12:16.000Z | dpdk-eal-master/drivers/crypto/dpaa_sec/dpaa_sec.c | Drag0nf1y/secure-vhost | 089cf0f17fcff64210e1b094fb0d3ee264c1c3c0 | [
"Intel"
] | null | null | null | dpdk-eal-master/drivers/crypto/dpaa_sec/dpaa_sec.c | Drag0nf1y/secure-vhost | 089cf0f17fcff64210e1b094fb0d3ee264c1c3c0 | [
"Intel"
] | 1 | 2021-12-21T07:12:14.000Z | 2021-12-21T07:12:14.000Z | /*-
* BSD LICENSE
*
* Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
* Copyright 2017 NXP.
*
* 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 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
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <fcntl.h>
#include <unistd.h>
#include <sched.h>
#include <net/if.h>
#include <rte_byteorder.h>
#include <rte_common.h>
#include <rte_cryptodev_pmd.h>
#include <rte_crypto.h>
#include <rte_cryptodev.h>
#include <rte_cycles.h>
#include <rte_dev.h>
#include <rte_kvargs.h>
#include <rte_malloc.h>
#include <rte_mbuf.h>
#include <rte_memcpy.h>
#include <rte_string_fns.h>
#include <fsl_usd.h>
#include <fsl_qman.h>
#include <of.h>
/* RTA header files */
#include <hw/desc/common.h>
#include <hw/desc/algo.h>
#include <hw/desc/ipsec.h>
#include <rte_dpaa_bus.h>
#include <dpaa_sec.h>
#include <dpaa_sec_log.h>
enum rta_sec_era rta_sec_era;
static uint8_t cryptodev_driver_id;
static __thread struct rte_crypto_op **dpaa_sec_ops;
static __thread int dpaa_sec_op_nb;
static inline void
dpaa_sec_op_ending(struct dpaa_sec_op_ctx *ctx)
{
if (!ctx->fd_status) {
ctx->op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
} else {
PMD_RX_LOG(ERR, "SEC return err: 0x%x", ctx->fd_status);
ctx->op->status = RTE_CRYPTO_OP_STATUS_ERROR;
}
/* report op status to sym->op and then free the ctx memeory */
rte_mempool_put(ctx->ctx_pool, (void *)ctx);
}
static inline struct dpaa_sec_op_ctx *
dpaa_sec_alloc_ctx(dpaa_sec_session *ses)
{
struct dpaa_sec_op_ctx *ctx;
int retval;
retval = rte_mempool_get(ses->ctx_pool, (void **)(&ctx));
if (!ctx || retval) {
PMD_TX_LOG(ERR, "Alloc sec descriptor failed!");
return NULL;
}
/*
* Clear SG memory. There are 16 SG entries of 16 Bytes each.
* one call to dcbz_64() clear 64 bytes, hence calling it 4 times
* to clear all the SG entries. dpaa_sec_alloc_ctx() is called for
* each packet, memset is costlier than dcbz_64().
*/
dcbz_64(&ctx->job.sg[SG_CACHELINE_0]);
dcbz_64(&ctx->job.sg[SG_CACHELINE_1]);
dcbz_64(&ctx->job.sg[SG_CACHELINE_2]);
dcbz_64(&ctx->job.sg[SG_CACHELINE_3]);
ctx->ctx_pool = ses->ctx_pool;
return ctx;
}
static inline rte_iova_t
dpaa_mem_vtop(void *vaddr)
{
const struct rte_memseg *memseg = rte_eal_get_physmem_layout();
uint64_t vaddr_64, paddr;
int i;
vaddr_64 = (uint64_t)vaddr;
for (i = 0; i < RTE_MAX_MEMSEG && memseg[i].addr_64 != 0; i++) {
if (vaddr_64 >= memseg[i].addr_64 &&
vaddr_64 < memseg[i].addr_64 + memseg[i].len) {
paddr = memseg[i].iova +
(vaddr_64 - memseg[i].addr_64);
return (rte_iova_t)paddr;
}
}
return (rte_iova_t)(NULL);
}
static inline void *
dpaa_mem_ptov(rte_iova_t paddr)
{
const struct rte_memseg *memseg = rte_eal_get_physmem_layout();
int i;
for (i = 0; i < RTE_MAX_MEMSEG && memseg[i].addr_64 != 0; i++) {
if (paddr >= memseg[i].iova &&
(char *)paddr < (char *)memseg[i].iova + memseg[i].len)
return (void *)(memseg[i].addr_64 +
(paddr - memseg[i].iova));
}
return NULL;
}
static void
ern_sec_fq_handler(struct qman_portal *qm __rte_unused,
struct qman_fq *fq,
const struct qm_mr_entry *msg)
{
RTE_LOG_DP(ERR, PMD, "sec fq %d error, RC = %x, seqnum = %x\n",
fq->fqid, msg->ern.rc, msg->ern.seqnum);
}
/* initialize the queue with dest chan as caam chan so that
* all the packets in this queue could be dispatched into caam
*/
static int
dpaa_sec_init_rx(struct qman_fq *fq_in, rte_iova_t hwdesc,
uint32_t fqid_out)
{
struct qm_mcc_initfq fq_opts;
uint32_t flags;
int ret = -1;
/* Clear FQ options */
memset(&fq_opts, 0x00, sizeof(struct qm_mcc_initfq));
flags = QMAN_FQ_FLAG_LOCKED | QMAN_FQ_FLAG_DYNAMIC_FQID |
QMAN_FQ_FLAG_TO_DCPORTAL;
ret = qman_create_fq(0, flags, fq_in);
if (unlikely(ret != 0)) {
PMD_INIT_LOG(ERR, "qman_create_fq failed");
return ret;
}
flags = QMAN_INITFQ_FLAG_SCHED;
fq_opts.we_mask = QM_INITFQ_WE_DESTWQ | QM_INITFQ_WE_CONTEXTA |
QM_INITFQ_WE_CONTEXTB;
qm_fqd_context_a_set64(&fq_opts.fqd, hwdesc);
fq_opts.fqd.context_b = fqid_out;
fq_opts.fqd.dest.channel = qm_channel_caam;
fq_opts.fqd.dest.wq = 0;
fq_in->cb.ern = ern_sec_fq_handler;
ret = qman_init_fq(fq_in, flags, &fq_opts);
if (unlikely(ret != 0))
PMD_INIT_LOG(ERR, "qman_init_fq failed");
return ret;
}
/* something is put into in_fq and caam put the crypto result into out_fq */
static enum qman_cb_dqrr_result
dqrr_out_fq_cb_rx(struct qman_portal *qm __always_unused,
struct qman_fq *fq __always_unused,
const struct qm_dqrr_entry *dqrr)
{
const struct qm_fd *fd;
struct dpaa_sec_job *job;
struct dpaa_sec_op_ctx *ctx;
if (dpaa_sec_op_nb >= DPAA_SEC_BURST)
return qman_cb_dqrr_defer;
if (!(dqrr->stat & QM_DQRR_STAT_FD_VALID))
return qman_cb_dqrr_consume;
fd = &dqrr->fd;
/* sg is embedded in an op ctx,
* sg[0] is for output
* sg[1] for input
*/
job = dpaa_mem_ptov(qm_fd_addr_get64(fd));
ctx = container_of(job, struct dpaa_sec_op_ctx, job);
ctx->fd_status = fd->status;
dpaa_sec_ops[dpaa_sec_op_nb++] = ctx->op;
dpaa_sec_op_ending(ctx);
return qman_cb_dqrr_consume;
}
/* caam result is put into this queue */
static int
dpaa_sec_init_tx(struct qman_fq *fq)
{
int ret;
struct qm_mcc_initfq opts;
uint32_t flags;
flags = QMAN_FQ_FLAG_NO_ENQUEUE | QMAN_FQ_FLAG_LOCKED |
QMAN_FQ_FLAG_DYNAMIC_FQID;
ret = qman_create_fq(0, flags, fq);
if (unlikely(ret)) {
PMD_INIT_LOG(ERR, "qman_create_fq failed");
return ret;
}
memset(&opts, 0, sizeof(opts));
opts.we_mask = QM_INITFQ_WE_DESTWQ | QM_INITFQ_WE_FQCTRL |
QM_INITFQ_WE_CONTEXTA | QM_INITFQ_WE_CONTEXTB;
/* opts.fqd.dest.channel = dpaa_sec_pool_chan; */
fq->cb.dqrr = dqrr_out_fq_cb_rx;
fq->cb.ern = ern_sec_fq_handler;
ret = qman_init_fq(fq, 0, &opts);
if (unlikely(ret)) {
PMD_INIT_LOG(ERR, "unable to init caam source fq!");
return ret;
}
return ret;
}
static inline int is_cipher_only(dpaa_sec_session *ses)
{
return ((ses->cipher_alg != RTE_CRYPTO_CIPHER_NULL) &&
(ses->auth_alg == RTE_CRYPTO_AUTH_NULL));
}
static inline int is_auth_only(dpaa_sec_session *ses)
{
return ((ses->cipher_alg == RTE_CRYPTO_CIPHER_NULL) &&
(ses->auth_alg != RTE_CRYPTO_AUTH_NULL));
}
static inline int is_aead(dpaa_sec_session *ses)
{
return ((ses->cipher_alg == 0) &&
(ses->auth_alg == 0) &&
(ses->aead_alg != 0));
}
static inline int is_auth_cipher(dpaa_sec_session *ses)
{
return ((ses->cipher_alg != RTE_CRYPTO_CIPHER_NULL) &&
(ses->auth_alg != RTE_CRYPTO_AUTH_NULL));
}
static inline int is_encode(dpaa_sec_session *ses)
{
return ses->dir == DIR_ENC;
}
static inline int is_decode(dpaa_sec_session *ses)
{
return ses->dir == DIR_DEC;
}
static inline void
caam_auth_alg(dpaa_sec_session *ses, struct alginfo *alginfo_a)
{
switch (ses->auth_alg) {
case RTE_CRYPTO_AUTH_NULL:
ses->digest_length = 0;
break;
case RTE_CRYPTO_AUTH_MD5_HMAC:
alginfo_a->algtype = OP_ALG_ALGSEL_MD5;
alginfo_a->algmode = OP_ALG_AAI_HMAC;
break;
case RTE_CRYPTO_AUTH_SHA1_HMAC:
alginfo_a->algtype = OP_ALG_ALGSEL_SHA1;
alginfo_a->algmode = OP_ALG_AAI_HMAC;
break;
case RTE_CRYPTO_AUTH_SHA224_HMAC:
alginfo_a->algtype = OP_ALG_ALGSEL_SHA224;
alginfo_a->algmode = OP_ALG_AAI_HMAC;
break;
case RTE_CRYPTO_AUTH_SHA256_HMAC:
alginfo_a->algtype = OP_ALG_ALGSEL_SHA256;
alginfo_a->algmode = OP_ALG_AAI_HMAC;
break;
case RTE_CRYPTO_AUTH_SHA384_HMAC:
alginfo_a->algtype = OP_ALG_ALGSEL_SHA384;
alginfo_a->algmode = OP_ALG_AAI_HMAC;
break;
case RTE_CRYPTO_AUTH_SHA512_HMAC:
alginfo_a->algtype = OP_ALG_ALGSEL_SHA512;
alginfo_a->algmode = OP_ALG_AAI_HMAC;
break;
default:
PMD_INIT_LOG(ERR, "unsupported auth alg %u", ses->auth_alg);
}
}
static inline void
caam_cipher_alg(dpaa_sec_session *ses, struct alginfo *alginfo_c)
{
switch (ses->cipher_alg) {
case RTE_CRYPTO_CIPHER_NULL:
break;
case RTE_CRYPTO_CIPHER_AES_CBC:
alginfo_c->algtype = OP_ALG_ALGSEL_AES;
alginfo_c->algmode = OP_ALG_AAI_CBC;
break;
case RTE_CRYPTO_CIPHER_3DES_CBC:
alginfo_c->algtype = OP_ALG_ALGSEL_3DES;
alginfo_c->algmode = OP_ALG_AAI_CBC;
break;
case RTE_CRYPTO_CIPHER_AES_CTR:
alginfo_c->algtype = OP_ALG_ALGSEL_AES;
alginfo_c->algmode = OP_ALG_AAI_CTR;
break;
default:
PMD_INIT_LOG(ERR, "unsupported cipher alg %d", ses->cipher_alg);
}
}
static inline void
caam_aead_alg(dpaa_sec_session *ses, struct alginfo *alginfo)
{
switch (ses->aead_alg) {
case RTE_CRYPTO_AEAD_AES_GCM:
alginfo->algtype = OP_ALG_ALGSEL_AES;
alginfo->algmode = OP_ALG_AAI_GCM;
break;
default:
PMD_INIT_LOG(ERR, "unsupported AEAD alg %d", ses->aead_alg);
}
}
/* prepare command block of the session */
static int
dpaa_sec_prep_cdb(dpaa_sec_session *ses)
{
struct alginfo alginfo_c = {0}, alginfo_a = {0}, alginfo = {0};
uint32_t shared_desc_len = 0;
struct sec_cdb *cdb = &ses->qp->cdb;
int err;
#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
int swap = false;
#else
int swap = true;
#endif
memset(cdb, 0, sizeof(struct sec_cdb));
if (is_cipher_only(ses)) {
caam_cipher_alg(ses, &alginfo_c);
if (alginfo_c.algtype == (unsigned int)DPAA_SEC_ALG_UNSUPPORT) {
PMD_TX_LOG(ERR, "not supported cipher alg\n");
return -ENOTSUP;
}
alginfo_c.key = (uint64_t)ses->cipher_key.data;
alginfo_c.keylen = ses->cipher_key.length;
alginfo_c.key_enc_flags = 0;
alginfo_c.key_type = RTA_DATA_IMM;
shared_desc_len = cnstr_shdsc_blkcipher(
cdb->sh_desc, true,
swap, &alginfo_c,
NULL,
ses->iv.length,
ses->dir);
} else if (is_auth_only(ses)) {
caam_auth_alg(ses, &alginfo_a);
if (alginfo_a.algtype == (unsigned int)DPAA_SEC_ALG_UNSUPPORT) {
PMD_TX_LOG(ERR, "not supported auth alg\n");
return -ENOTSUP;
}
alginfo_a.key = (uint64_t)ses->auth_key.data;
alginfo_a.keylen = ses->auth_key.length;
alginfo_a.key_enc_flags = 0;
alginfo_a.key_type = RTA_DATA_IMM;
shared_desc_len = cnstr_shdsc_hmac(cdb->sh_desc, true,
swap, &alginfo_a,
!ses->dir,
ses->digest_length);
} else if (is_aead(ses)) {
caam_aead_alg(ses, &alginfo);
if (alginfo.algtype == (unsigned int)DPAA_SEC_ALG_UNSUPPORT) {
PMD_TX_LOG(ERR, "not supported aead alg\n");
return -ENOTSUP;
}
alginfo.key = (uint64_t)ses->aead_key.data;
alginfo.keylen = ses->aead_key.length;
alginfo.key_enc_flags = 0;
alginfo.key_type = RTA_DATA_IMM;
if (ses->dir == DIR_ENC)
shared_desc_len = cnstr_shdsc_gcm_encap(
cdb->sh_desc, true, swap,
&alginfo,
ses->iv.length,
ses->digest_length);
else
shared_desc_len = cnstr_shdsc_gcm_decap(
cdb->sh_desc, true, swap,
&alginfo,
ses->iv.length,
ses->digest_length);
} else {
caam_cipher_alg(ses, &alginfo_c);
if (alginfo_c.algtype == (unsigned int)DPAA_SEC_ALG_UNSUPPORT) {
PMD_TX_LOG(ERR, "not supported cipher alg\n");
return -ENOTSUP;
}
alginfo_c.key = (uint64_t)ses->cipher_key.data;
alginfo_c.keylen = ses->cipher_key.length;
alginfo_c.key_enc_flags = 0;
alginfo_c.key_type = RTA_DATA_IMM;
caam_auth_alg(ses, &alginfo_a);
if (alginfo_a.algtype == (unsigned int)DPAA_SEC_ALG_UNSUPPORT) {
PMD_TX_LOG(ERR, "not supported auth alg\n");
return -ENOTSUP;
}
alginfo_a.key = (uint64_t)ses->auth_key.data;
alginfo_a.keylen = ses->auth_key.length;
alginfo_a.key_enc_flags = 0;
alginfo_a.key_type = RTA_DATA_IMM;
cdb->sh_desc[0] = alginfo_c.keylen;
cdb->sh_desc[1] = alginfo_a.keylen;
err = rta_inline_query(IPSEC_AUTH_VAR_AES_DEC_BASE_DESC_LEN,
MIN_JOB_DESC_SIZE,
(unsigned int *)cdb->sh_desc,
&cdb->sh_desc[2], 2);
if (err < 0) {
PMD_TX_LOG(ERR, "Crypto: Incorrect key lengths");
return err;
}
if (cdb->sh_desc[2] & 1)
alginfo_c.key_type = RTA_DATA_IMM;
else {
alginfo_c.key = (uint64_t)dpaa_mem_vtop(
(void *)alginfo_c.key);
alginfo_c.key_type = RTA_DATA_PTR;
}
if (cdb->sh_desc[2] & (1<<1))
alginfo_a.key_type = RTA_DATA_IMM;
else {
alginfo_a.key = (uint64_t)dpaa_mem_vtop(
(void *)alginfo_a.key);
alginfo_a.key_type = RTA_DATA_PTR;
}
cdb->sh_desc[0] = 0;
cdb->sh_desc[1] = 0;
cdb->sh_desc[2] = 0;
/* Auth_only_len is set as 0 here and it will be overwritten
* in fd for each packet.
*/
shared_desc_len = cnstr_shdsc_authenc(cdb->sh_desc,
true, swap, &alginfo_c, &alginfo_a,
ses->iv.length, 0,
ses->digest_length, ses->dir);
}
cdb->sh_hdr.hi.field.idlen = shared_desc_len;
cdb->sh_hdr.hi.word = rte_cpu_to_be_32(cdb->sh_hdr.hi.word);
cdb->sh_hdr.lo.word = rte_cpu_to_be_32(cdb->sh_hdr.lo.word);
return 0;
}
static inline unsigned int
dpaa_volatile_deq(struct qman_fq *fq, unsigned int len, bool exact)
{
unsigned int pkts = 0;
int ret;
struct qm_mcr_queryfq_np np;
enum qman_fq_state state;
uint32_t flags;
uint32_t vdqcr;
qman_query_fq_np(fq, &np);
if (np.frm_cnt) {
vdqcr = QM_VDQCR_NUMFRAMES_SET(len);
if (exact)
vdqcr |= QM_VDQCR_EXACT;
ret = qman_volatile_dequeue(fq, 0, vdqcr);
if (ret)
return 0;
do {
pkts += qman_poll_dqrr(len);
qman_fq_state(fq, &state, &flags);
} while (flags & QMAN_FQ_STATE_VDQCR);
}
return pkts;
}
/* qp is lockless, should be accessed by only one thread */
static int
dpaa_sec_deq(struct dpaa_sec_qp *qp, struct rte_crypto_op **ops, int nb_ops)
{
struct qman_fq *fq;
fq = &qp->outq;
dpaa_sec_op_nb = 0;
dpaa_sec_ops = ops;
if (unlikely(nb_ops > DPAA_SEC_BURST))
nb_ops = DPAA_SEC_BURST;
return dpaa_volatile_deq(fq, nb_ops, 1);
}
/**
* packet looks like:
* |<----data_len------->|
* |ip_header|ah_header|icv|payload|
* ^
* |
* mbuf->pkt.data
*/
static inline struct dpaa_sec_job *
build_auth_only(struct rte_crypto_op *op, dpaa_sec_session *ses)
{
struct rte_crypto_sym_op *sym = op->sym;
struct rte_mbuf *mbuf = sym->m_src;
struct dpaa_sec_job *cf;
struct dpaa_sec_op_ctx *ctx;
struct qm_sg_entry *sg;
rte_iova_t start_addr;
uint8_t *old_digest;
ctx = dpaa_sec_alloc_ctx(ses);
if (!ctx)
return NULL;
cf = &ctx->job;
ctx->op = op;
old_digest = ctx->digest;
start_addr = rte_pktmbuf_iova(mbuf);
/* output */
sg = &cf->sg[0];
qm_sg_entry_set64(sg, sym->auth.digest.phys_addr);
sg->length = ses->digest_length;
cpu_to_hw_sg(sg);
/* input */
sg = &cf->sg[1];
if (is_decode(ses)) {
/* need to extend the input to a compound frame */
sg->extension = 1;
qm_sg_entry_set64(sg, dpaa_mem_vtop(&cf->sg[2]));
sg->length = sym->auth.data.length + ses->digest_length;
sg->final = 1;
cpu_to_hw_sg(sg);
sg = &cf->sg[2];
/* hash result or digest, save digest first */
rte_memcpy(old_digest, sym->auth.digest.data,
ses->digest_length);
qm_sg_entry_set64(sg, start_addr + sym->auth.data.offset);
sg->length = sym->auth.data.length;
cpu_to_hw_sg(sg);
/* let's check digest by hw */
start_addr = dpaa_mem_vtop(old_digest);
sg++;
qm_sg_entry_set64(sg, start_addr);
sg->length = ses->digest_length;
sg->final = 1;
cpu_to_hw_sg(sg);
} else {
qm_sg_entry_set64(sg, start_addr + sym->auth.data.offset);
sg->length = sym->auth.data.length;
sg->final = 1;
cpu_to_hw_sg(sg);
}
return cf;
}
static inline struct dpaa_sec_job *
build_cipher_only(struct rte_crypto_op *op, dpaa_sec_session *ses)
{
struct rte_crypto_sym_op *sym = op->sym;
struct dpaa_sec_job *cf;
struct dpaa_sec_op_ctx *ctx;
struct qm_sg_entry *sg;
rte_iova_t src_start_addr, dst_start_addr;
uint8_t *IV_ptr = rte_crypto_op_ctod_offset(op, uint8_t *,
ses->iv.offset);
ctx = dpaa_sec_alloc_ctx(ses);
if (!ctx)
return NULL;
cf = &ctx->job;
ctx->op = op;
src_start_addr = rte_pktmbuf_iova(sym->m_src);
if (sym->m_dst)
dst_start_addr = rte_pktmbuf_iova(sym->m_dst);
else
dst_start_addr = src_start_addr;
/* output */
sg = &cf->sg[0];
qm_sg_entry_set64(sg, dst_start_addr + sym->cipher.data.offset);
sg->length = sym->cipher.data.length + ses->iv.length;
cpu_to_hw_sg(sg);
/* input */
sg = &cf->sg[1];
/* need to extend the input to a compound frame */
sg->extension = 1;
sg->final = 1;
sg->length = sym->cipher.data.length + ses->iv.length;
qm_sg_entry_set64(sg, dpaa_mem_vtop(&cf->sg[2]));
cpu_to_hw_sg(sg);
sg = &cf->sg[2];
qm_sg_entry_set64(sg, dpaa_mem_vtop(IV_ptr));
sg->length = ses->iv.length;
cpu_to_hw_sg(sg);
sg++;
qm_sg_entry_set64(sg, src_start_addr + sym->cipher.data.offset);
sg->length = sym->cipher.data.length;
sg->final = 1;
cpu_to_hw_sg(sg);
return cf;
}
static inline struct dpaa_sec_job *
build_cipher_auth_gcm(struct rte_crypto_op *op, dpaa_sec_session *ses)
{
struct rte_crypto_sym_op *sym = op->sym;
struct dpaa_sec_job *cf;
struct dpaa_sec_op_ctx *ctx;
struct qm_sg_entry *sg;
uint32_t length = 0;
rte_iova_t src_start_addr, dst_start_addr;
uint8_t *IV_ptr = rte_crypto_op_ctod_offset(op, uint8_t *,
ses->iv.offset);
src_start_addr = sym->m_src->buf_iova + sym->m_src->data_off;
if (sym->m_dst)
dst_start_addr = sym->m_dst->buf_iova + sym->m_dst->data_off;
else
dst_start_addr = src_start_addr;
ctx = dpaa_sec_alloc_ctx(ses);
if (!ctx)
return NULL;
cf = &ctx->job;
ctx->op = op;
/* input */
rte_prefetch0(cf->sg);
sg = &cf->sg[2];
qm_sg_entry_set64(&cf->sg[1], dpaa_mem_vtop(sg));
if (is_encode(ses)) {
qm_sg_entry_set64(sg, dpaa_mem_vtop(IV_ptr));
sg->length = ses->iv.length;
length += sg->length;
cpu_to_hw_sg(sg);
sg++;
if (ses->auth_only_len) {
qm_sg_entry_set64(sg,
dpaa_mem_vtop(sym->aead.aad.data));
sg->length = ses->auth_only_len;
length += sg->length;
cpu_to_hw_sg(sg);
sg++;
}
qm_sg_entry_set64(sg, src_start_addr + sym->aead.data.offset);
sg->length = sym->aead.data.length;
length += sg->length;
sg->final = 1;
cpu_to_hw_sg(sg);
} else {
qm_sg_entry_set64(sg, dpaa_mem_vtop(IV_ptr));
sg->length = ses->iv.length;
length += sg->length;
cpu_to_hw_sg(sg);
sg++;
if (ses->auth_only_len) {
qm_sg_entry_set64(sg,
dpaa_mem_vtop(sym->aead.aad.data));
sg->length = ses->auth_only_len;
length += sg->length;
cpu_to_hw_sg(sg);
sg++;
}
qm_sg_entry_set64(sg, src_start_addr + sym->aead.data.offset);
sg->length = sym->aead.data.length;
length += sg->length;
cpu_to_hw_sg(sg);
memcpy(ctx->digest, sym->aead.digest.data,
ses->digest_length);
sg++;
qm_sg_entry_set64(sg, dpaa_mem_vtop(ctx->digest));
sg->length = ses->digest_length;
length += sg->length;
sg->final = 1;
cpu_to_hw_sg(sg);
}
/* input compound frame */
cf->sg[1].length = length;
cf->sg[1].extension = 1;
cf->sg[1].final = 1;
cpu_to_hw_sg(&cf->sg[1]);
/* output */
sg++;
qm_sg_entry_set64(&cf->sg[0], dpaa_mem_vtop(sg));
qm_sg_entry_set64(sg,
dst_start_addr + sym->aead.data.offset - ses->auth_only_len);
sg->length = sym->aead.data.length + ses->auth_only_len;
length = sg->length;
if (is_encode(ses)) {
cpu_to_hw_sg(sg);
/* set auth output */
sg++;
qm_sg_entry_set64(sg, sym->aead.digest.phys_addr);
sg->length = ses->digest_length;
length += sg->length;
}
sg->final = 1;
cpu_to_hw_sg(sg);
/* output compound frame */
cf->sg[0].length = length;
cf->sg[0].extension = 1;
cpu_to_hw_sg(&cf->sg[0]);
return cf;
}
static inline struct dpaa_sec_job *
build_cipher_auth(struct rte_crypto_op *op, dpaa_sec_session *ses)
{
struct rte_crypto_sym_op *sym = op->sym;
struct dpaa_sec_job *cf;
struct dpaa_sec_op_ctx *ctx;
struct qm_sg_entry *sg;
rte_iova_t src_start_addr, dst_start_addr;
uint32_t length = 0;
uint8_t *IV_ptr = rte_crypto_op_ctod_offset(op, uint8_t *,
ses->iv.offset);
src_start_addr = sym->m_src->buf_iova + sym->m_src->data_off;
if (sym->m_dst)
dst_start_addr = sym->m_dst->buf_iova + sym->m_dst->data_off;
else
dst_start_addr = src_start_addr;
ctx = dpaa_sec_alloc_ctx(ses);
if (!ctx)
return NULL;
cf = &ctx->job;
ctx->op = op;
/* input */
rte_prefetch0(cf->sg);
sg = &cf->sg[2];
qm_sg_entry_set64(&cf->sg[1], dpaa_mem_vtop(sg));
if (is_encode(ses)) {
qm_sg_entry_set64(sg, dpaa_mem_vtop(IV_ptr));
sg->length = ses->iv.length;
length += sg->length;
cpu_to_hw_sg(sg);
sg++;
qm_sg_entry_set64(sg, src_start_addr + sym->auth.data.offset);
sg->length = sym->auth.data.length;
length += sg->length;
sg->final = 1;
cpu_to_hw_sg(sg);
} else {
qm_sg_entry_set64(sg, dpaa_mem_vtop(IV_ptr));
sg->length = ses->iv.length;
length += sg->length;
cpu_to_hw_sg(sg);
sg++;
qm_sg_entry_set64(sg, src_start_addr + sym->auth.data.offset);
sg->length = sym->auth.data.length;
length += sg->length;
cpu_to_hw_sg(sg);
memcpy(ctx->digest, sym->auth.digest.data,
ses->digest_length);
sg++;
qm_sg_entry_set64(sg, dpaa_mem_vtop(ctx->digest));
sg->length = ses->digest_length;
length += sg->length;
sg->final = 1;
cpu_to_hw_sg(sg);
}
/* input compound frame */
cf->sg[1].length = length;
cf->sg[1].extension = 1;
cf->sg[1].final = 1;
cpu_to_hw_sg(&cf->sg[1]);
/* output */
sg++;
qm_sg_entry_set64(&cf->sg[0], dpaa_mem_vtop(sg));
qm_sg_entry_set64(sg, dst_start_addr + sym->cipher.data.offset);
sg->length = sym->cipher.data.length;
length = sg->length;
if (is_encode(ses)) {
cpu_to_hw_sg(sg);
/* set auth output */
sg++;
qm_sg_entry_set64(sg, sym->auth.digest.phys_addr);
sg->length = ses->digest_length;
length += sg->length;
}
sg->final = 1;
cpu_to_hw_sg(sg);
/* output compound frame */
cf->sg[0].length = length;
cf->sg[0].extension = 1;
cpu_to_hw_sg(&cf->sg[0]);
return cf;
}
static int
dpaa_sec_enqueue_op(struct rte_crypto_op *op, struct dpaa_sec_qp *qp)
{
struct dpaa_sec_job *cf;
dpaa_sec_session *ses;
struct qm_fd fd;
int ret;
uint32_t auth_only_len = op->sym->auth.data.length -
op->sym->cipher.data.length;
ses = (dpaa_sec_session *)get_session_private_data(op->sym->session,
cryptodev_driver_id);
if (unlikely(!qp->ses || qp->ses != ses)) {
qp->ses = ses;
ses->qp = qp;
ret = dpaa_sec_prep_cdb(ses);
if (ret)
return ret;
}
/*
* Segmented buffer is not supported.
*/
if (!rte_pktmbuf_is_contiguous(op->sym->m_src)) {
op->status = RTE_CRYPTO_OP_STATUS_ERROR;
return -ENOTSUP;
}
if (is_auth_only(ses)) {
cf = build_auth_only(op, ses);
} else if (is_cipher_only(ses)) {
cf = build_cipher_only(op, ses);
} else if (is_aead(ses)) {
cf = build_cipher_auth_gcm(op, ses);
auth_only_len = ses->auth_only_len;
} else if (is_auth_cipher(ses)) {
cf = build_cipher_auth(op, ses);
} else {
PMD_TX_LOG(ERR, "not supported sec op");
return -ENOTSUP;
}
if (unlikely(!cf))
return -ENOMEM;
memset(&fd, 0, sizeof(struct qm_fd));
qm_fd_addr_set64(&fd, dpaa_mem_vtop(cf->sg));
fd._format1 = qm_fd_compound;
fd.length29 = 2 * sizeof(struct qm_sg_entry);
/* Auth_only_len is set as 0 in descriptor and it is overwritten
* here in the fd.cmd which will update the DPOVRD reg.
*/
if (auth_only_len)
fd.cmd = 0x80000000 | auth_only_len;
do {
ret = qman_enqueue(&qp->inq, &fd, 0);
} while (ret != 0);
return 0;
}
static uint16_t
dpaa_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops,
uint16_t nb_ops)
{
/* Function to transmit the frames to given device and queuepair */
uint32_t loop;
int32_t ret;
struct dpaa_sec_qp *dpaa_qp = (struct dpaa_sec_qp *)qp;
uint16_t num_tx = 0;
if (unlikely(nb_ops == 0))
return 0;
/*Prepare each packet which is to be sent*/
for (loop = 0; loop < nb_ops; loop++) {
if (ops[loop]->sess_type != RTE_CRYPTO_OP_WITH_SESSION) {
PMD_TX_LOG(ERR, "sessionless crypto op not supported");
return 0;
}
ret = dpaa_sec_enqueue_op(ops[loop], dpaa_qp);
if (!ret)
num_tx++;
}
dpaa_qp->tx_pkts += num_tx;
dpaa_qp->tx_errs += nb_ops - num_tx;
return num_tx;
}
static uint16_t
dpaa_sec_dequeue_burst(void *qp, struct rte_crypto_op **ops,
uint16_t nb_ops)
{
uint16_t num_rx;
struct dpaa_sec_qp *dpaa_qp = (struct dpaa_sec_qp *)qp;
num_rx = dpaa_sec_deq(dpaa_qp, ops, nb_ops);
dpaa_qp->rx_pkts += num_rx;
dpaa_qp->rx_errs += nb_ops - num_rx;
PMD_RX_LOG(DEBUG, "SEC Received %d Packets\n", num_rx);
return num_rx;
}
/** Release queue pair */
static int
dpaa_sec_queue_pair_release(struct rte_cryptodev *dev,
uint16_t qp_id)
{
struct dpaa_sec_dev_private *internals;
struct dpaa_sec_qp *qp = NULL;
PMD_INIT_FUNC_TRACE();
PMD_INIT_LOG(DEBUG, "dev =%p, queue =%d", dev, qp_id);
internals = dev->data->dev_private;
if (qp_id >= internals->max_nb_queue_pairs) {
PMD_INIT_LOG(ERR, "Max supported qpid %d",
internals->max_nb_queue_pairs);
return -EINVAL;
}
qp = &internals->qps[qp_id];
qp->internals = NULL;
dev->data->queue_pairs[qp_id] = NULL;
return 0;
}
/** Setup a queue pair */
static int
dpaa_sec_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id,
__rte_unused const struct rte_cryptodev_qp_conf *qp_conf,
__rte_unused int socket_id,
__rte_unused struct rte_mempool *session_pool)
{
struct dpaa_sec_dev_private *internals;
struct dpaa_sec_qp *qp = NULL;
PMD_INIT_LOG(DEBUG, "dev =%p, queue =%d, conf =%p",
dev, qp_id, qp_conf);
internals = dev->data->dev_private;
if (qp_id >= internals->max_nb_queue_pairs) {
PMD_INIT_LOG(ERR, "Max supported qpid %d",
internals->max_nb_queue_pairs);
return -EINVAL;
}
qp = &internals->qps[qp_id];
qp->internals = internals;
dev->data->queue_pairs[qp_id] = qp;
return 0;
}
/** Start queue pair */
static int
dpaa_sec_queue_pair_start(__rte_unused struct rte_cryptodev *dev,
__rte_unused uint16_t queue_pair_id)
{
PMD_INIT_FUNC_TRACE();
return 0;
}
/** Stop queue pair */
static int
dpaa_sec_queue_pair_stop(__rte_unused struct rte_cryptodev *dev,
__rte_unused uint16_t queue_pair_id)
{
PMD_INIT_FUNC_TRACE();
return 0;
}
/** Return the number of allocated queue pairs */
static uint32_t
dpaa_sec_queue_pair_count(struct rte_cryptodev *dev)
{
PMD_INIT_FUNC_TRACE();
return dev->data->nb_queue_pairs;
}
/** Returns the size of session structure */
static unsigned int
dpaa_sec_session_get_size(struct rte_cryptodev *dev __rte_unused)
{
PMD_INIT_FUNC_TRACE();
return sizeof(dpaa_sec_session);
}
static int
dpaa_sec_cipher_init(struct rte_cryptodev *dev __rte_unused,
struct rte_crypto_sym_xform *xform,
dpaa_sec_session *session)
{
session->cipher_alg = xform->cipher.algo;
session->iv.length = xform->cipher.iv.length;
session->iv.offset = xform->cipher.iv.offset;
session->cipher_key.data = rte_zmalloc(NULL, xform->cipher.key.length,
RTE_CACHE_LINE_SIZE);
if (session->cipher_key.data == NULL && xform->cipher.key.length > 0) {
PMD_INIT_LOG(ERR, "No Memory for cipher key\n");
return -ENOMEM;
}
session->cipher_key.length = xform->cipher.key.length;
memcpy(session->cipher_key.data, xform->cipher.key.data,
xform->cipher.key.length);
session->dir = (xform->cipher.op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) ?
DIR_ENC : DIR_DEC;
return 0;
}
static int
dpaa_sec_auth_init(struct rte_cryptodev *dev __rte_unused,
struct rte_crypto_sym_xform *xform,
dpaa_sec_session *session)
{
session->auth_alg = xform->auth.algo;
session->auth_key.data = rte_zmalloc(NULL, xform->auth.key.length,
RTE_CACHE_LINE_SIZE);
if (session->auth_key.data == NULL && xform->auth.key.length > 0) {
PMD_INIT_LOG(ERR, "No Memory for auth key\n");
return -ENOMEM;
}
session->auth_key.length = xform->auth.key.length;
session->digest_length = xform->auth.digest_length;
memcpy(session->auth_key.data, xform->auth.key.data,
xform->auth.key.length);
session->dir = (xform->auth.op == RTE_CRYPTO_AUTH_OP_GENERATE) ?
DIR_ENC : DIR_DEC;
return 0;
}
static int
dpaa_sec_aead_init(struct rte_cryptodev *dev __rte_unused,
struct rte_crypto_sym_xform *xform,
dpaa_sec_session *session)
{
session->aead_alg = xform->aead.algo;
session->iv.length = xform->aead.iv.length;
session->iv.offset = xform->aead.iv.offset;
session->auth_only_len = xform->aead.aad_length;
session->aead_key.data = rte_zmalloc(NULL, xform->aead.key.length,
RTE_CACHE_LINE_SIZE);
if (session->aead_key.data == NULL && xform->aead.key.length > 0) {
PMD_INIT_LOG(ERR, "No Memory for aead key\n");
return -ENOMEM;
}
session->aead_key.length = xform->aead.key.length;
session->digest_length = xform->aead.digest_length;
memcpy(session->aead_key.data, xform->aead.key.data,
xform->aead.key.length);
session->dir = (xform->aead.op == RTE_CRYPTO_AEAD_OP_ENCRYPT) ?
DIR_ENC : DIR_DEC;
return 0;
}
static int
dpaa_sec_qp_attach_sess(struct rte_cryptodev *dev, uint16_t qp_id, void *ses)
{
dpaa_sec_session *sess = ses;
struct dpaa_sec_qp *qp;
PMD_INIT_FUNC_TRACE();
qp = dev->data->queue_pairs[qp_id];
if (qp->ses != NULL) {
PMD_INIT_LOG(ERR, "qp in-use by another session\n");
return -EBUSY;
}
qp->ses = sess;
sess->qp = qp;
return dpaa_sec_prep_cdb(sess);
}
static int
dpaa_sec_qp_detach_sess(struct rte_cryptodev *dev, uint16_t qp_id, void *ses)
{
dpaa_sec_session *sess = ses;
struct dpaa_sec_qp *qp;
PMD_INIT_FUNC_TRACE();
qp = dev->data->queue_pairs[qp_id];
if (qp->ses != NULL) {
qp->ses = NULL;
sess->qp = NULL;
return 0;
}
PMD_DRV_LOG(ERR, "No session attached to qp");
return -EINVAL;
}
static int
dpaa_sec_set_session_parameters(struct rte_cryptodev *dev,
struct rte_crypto_sym_xform *xform, void *sess)
{
struct dpaa_sec_dev_private *internals = dev->data->dev_private;
dpaa_sec_session *session = sess;
PMD_INIT_FUNC_TRACE();
if (unlikely(sess == NULL)) {
RTE_LOG(ERR, PMD, "invalid session struct\n");
return -EINVAL;
}
/* Default IV length = 0 */
session->iv.length = 0;
/* Cipher Only */
if (xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER && xform->next == NULL) {
session->auth_alg = RTE_CRYPTO_AUTH_NULL;
dpaa_sec_cipher_init(dev, xform, session);
/* Authentication Only */
} else if (xform->type == RTE_CRYPTO_SYM_XFORM_AUTH &&
xform->next == NULL) {
session->cipher_alg = RTE_CRYPTO_CIPHER_NULL;
dpaa_sec_auth_init(dev, xform, session);
/* Cipher then Authenticate */
} else if (xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER &&
xform->next->type == RTE_CRYPTO_SYM_XFORM_AUTH) {
if (xform->cipher.op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
dpaa_sec_cipher_init(dev, xform, session);
dpaa_sec_auth_init(dev, xform->next, session);
} else {
PMD_DRV_LOG(ERR, "Not supported: Auth then Cipher");
return -EINVAL;
}
/* Authenticate then Cipher */
} else if (xform->type == RTE_CRYPTO_SYM_XFORM_AUTH &&
xform->next->type == RTE_CRYPTO_SYM_XFORM_CIPHER) {
if (xform->next->cipher.op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
dpaa_sec_auth_init(dev, xform, session);
dpaa_sec_cipher_init(dev, xform->next, session);
} else {
PMD_DRV_LOG(ERR, "Not supported: Auth then Cipher");
return -EINVAL;
}
/* AEAD operation for AES-GCM kind of Algorithms */
} else if (xform->type == RTE_CRYPTO_SYM_XFORM_AEAD &&
xform->next == NULL) {
dpaa_sec_aead_init(dev, xform, session);
} else {
PMD_DRV_LOG(ERR, "Invalid crypto type");
return -EINVAL;
}
session->ctx_pool = internals->ctx_pool;
return 0;
}
static int
dpaa_sec_session_configure(struct rte_cryptodev *dev,
struct rte_crypto_sym_xform *xform,
struct rte_cryptodev_sym_session *sess,
struct rte_mempool *mempool)
{
void *sess_private_data;
int ret;
PMD_INIT_FUNC_TRACE();
if (rte_mempool_get(mempool, &sess_private_data)) {
CDEV_LOG_ERR(
"Couldn't get object from session mempool");
return -ENOMEM;
}
ret = dpaa_sec_set_session_parameters(dev, xform, sess_private_data);
if (ret != 0) {
PMD_DRV_LOG(ERR, "DPAA PMD: failed to configure "
"session parameters");
/* Return session to mempool */
rte_mempool_put(mempool, sess_private_data);
return ret;
}
set_session_private_data(sess, dev->driver_id,
sess_private_data);
return 0;
}
/** Clear the memory of session so it doesn't leave key material behind */
static void
dpaa_sec_session_clear(struct rte_cryptodev *dev,
struct rte_cryptodev_sym_session *sess)
{
PMD_INIT_FUNC_TRACE();
uint8_t index = dev->driver_id;
void *sess_priv = get_session_private_data(sess, index);
dpaa_sec_session *s = (dpaa_sec_session *)sess_priv;
if (sess_priv) {
rte_free(s->cipher_key.data);
rte_free(s->auth_key.data);
memset(s, 0, sizeof(dpaa_sec_session));
struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv);
set_session_private_data(sess, index, NULL);
rte_mempool_put(sess_mp, sess_priv);
}
}
static int
dpaa_sec_dev_configure(struct rte_cryptodev *dev __rte_unused,
struct rte_cryptodev_config *config __rte_unused)
{
PMD_INIT_FUNC_TRACE();
return 0;
}
static int
dpaa_sec_dev_start(struct rte_cryptodev *dev __rte_unused)
{
PMD_INIT_FUNC_TRACE();
return 0;
}
static void
dpaa_sec_dev_stop(struct rte_cryptodev *dev __rte_unused)
{
PMD_INIT_FUNC_TRACE();
}
static int
dpaa_sec_dev_close(struct rte_cryptodev *dev __rte_unused)
{
PMD_INIT_FUNC_TRACE();
return 0;
}
static void
dpaa_sec_dev_infos_get(struct rte_cryptodev *dev,
struct rte_cryptodev_info *info)
{
struct dpaa_sec_dev_private *internals = dev->data->dev_private;
PMD_INIT_FUNC_TRACE();
if (info != NULL) {
info->max_nb_queue_pairs = internals->max_nb_queue_pairs;
info->feature_flags = dev->feature_flags;
info->capabilities = dpaa_sec_capabilities;
info->sym.max_nb_sessions = internals->max_nb_sessions;
info->sym.max_nb_sessions_per_qp =
RTE_DPAA_SEC_PMD_MAX_NB_SESSIONS / RTE_MAX_NB_SEC_QPS;
info->driver_id = cryptodev_driver_id;
}
}
static struct rte_cryptodev_ops crypto_ops = {
.dev_configure = dpaa_sec_dev_configure,
.dev_start = dpaa_sec_dev_start,
.dev_stop = dpaa_sec_dev_stop,
.dev_close = dpaa_sec_dev_close,
.dev_infos_get = dpaa_sec_dev_infos_get,
.queue_pair_setup = dpaa_sec_queue_pair_setup,
.queue_pair_release = dpaa_sec_queue_pair_release,
.queue_pair_start = dpaa_sec_queue_pair_start,
.queue_pair_stop = dpaa_sec_queue_pair_stop,
.queue_pair_count = dpaa_sec_queue_pair_count,
.session_get_size = dpaa_sec_session_get_size,
.session_configure = dpaa_sec_session_configure,
.session_clear = dpaa_sec_session_clear,
.qp_attach_session = dpaa_sec_qp_attach_sess,
.qp_detach_session = dpaa_sec_qp_detach_sess,
};
static int
dpaa_sec_uninit(struct rte_cryptodev *dev)
{
struct dpaa_sec_dev_private *internals = dev->data->dev_private;
if (dev == NULL)
return -ENODEV;
rte_mempool_free(internals->ctx_pool);
rte_free(internals);
PMD_INIT_LOG(INFO, "Closing DPAA_SEC device %s on numa socket %u\n",
dev->data->name, rte_socket_id());
return 0;
}
static int
dpaa_sec_dev_init(struct rte_cryptodev *cryptodev)
{
struct dpaa_sec_dev_private *internals;
struct dpaa_sec_qp *qp;
uint32_t i;
int ret;
char str[20];
PMD_INIT_FUNC_TRACE();
cryptodev->driver_id = cryptodev_driver_id;
cryptodev->dev_ops = &crypto_ops;
cryptodev->enqueue_burst = dpaa_sec_enqueue_burst;
cryptodev->dequeue_burst = dpaa_sec_dequeue_burst;
cryptodev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
RTE_CRYPTODEV_FF_HW_ACCELERATED |
RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING;
internals = cryptodev->data->dev_private;
internals->max_nb_queue_pairs = RTE_MAX_NB_SEC_QPS;
internals->max_nb_sessions = RTE_DPAA_SEC_PMD_MAX_NB_SESSIONS;
for (i = 0; i < internals->max_nb_queue_pairs; i++) {
/* init qman fq for queue pair */
qp = &internals->qps[i];
ret = dpaa_sec_init_tx(&qp->outq);
if (ret) {
PMD_INIT_LOG(ERR, "config tx of queue pair %d", i);
goto init_error;
}
ret = dpaa_sec_init_rx(&qp->inq, dpaa_mem_vtop(&qp->cdb),
qman_fq_fqid(&qp->outq));
if (ret) {
PMD_INIT_LOG(ERR, "config rx of queue pair %d", i);
goto init_error;
}
}
sprintf(str, "ctx_pool_%d", cryptodev->data->dev_id);
internals->ctx_pool = rte_mempool_create((const char *)str,
CTX_POOL_NUM_BUFS,
CTX_POOL_BUF_SIZE,
CTX_POOL_CACHE_SIZE, 0,
NULL, NULL, NULL, NULL,
SOCKET_ID_ANY, 0);
if (!internals->ctx_pool) {
RTE_LOG(ERR, PMD, "%s create failed\n", str);
goto init_error;
}
PMD_INIT_LOG(DEBUG, "driver %s: created\n", cryptodev->data->name);
return 0;
init_error:
PMD_INIT_LOG(ERR, "driver %s: create failed\n", cryptodev->data->name);
dpaa_sec_uninit(cryptodev);
return -EFAULT;
}
static int
cryptodev_dpaa_sec_probe(struct rte_dpaa_driver *dpaa_drv,
struct rte_dpaa_device *dpaa_dev)
{
struct rte_cryptodev *cryptodev;
char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN];
int retval;
sprintf(cryptodev_name, "dpaa_sec-%d", dpaa_dev->id.dev_id);
cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, rte_socket_id());
if (cryptodev == NULL)
return -ENOMEM;
if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
cryptodev->data->dev_private = rte_zmalloc_socket(
"cryptodev private structure",
sizeof(struct dpaa_sec_dev_private),
RTE_CACHE_LINE_SIZE,
rte_socket_id());
if (cryptodev->data->dev_private == NULL)
rte_panic("Cannot allocate memzone for private "
"device data");
}
dpaa_dev->crypto_dev = cryptodev;
cryptodev->device = &dpaa_dev->device;
cryptodev->device->driver = &dpaa_drv->driver;
/* init user callbacks */
TAILQ_INIT(&(cryptodev->link_intr_cbs));
/* if sec device version is not configured */
if (!rta_get_sec_era()) {
const struct device_node *caam_node;
for_each_compatible_node(caam_node, NULL, "fsl,sec-v4.0") {
const uint32_t *prop = of_get_property(caam_node,
"fsl,sec-era",
NULL);
if (prop) {
rta_set_sec_era(
INTL_SEC_ERA(rte_cpu_to_be_32(*prop)));
break;
}
}
}
/* Invoke PMD device initialization function */
retval = dpaa_sec_dev_init(cryptodev);
if (retval == 0)
return 0;
/* In case of error, cleanup is done */
if (rte_eal_process_type() == RTE_PROC_PRIMARY)
rte_free(cryptodev->data->dev_private);
rte_cryptodev_pmd_release_device(cryptodev);
return -ENXIO;
}
static int
cryptodev_dpaa_sec_remove(struct rte_dpaa_device *dpaa_dev)
{
struct rte_cryptodev *cryptodev;
int ret;
cryptodev = dpaa_dev->crypto_dev;
if (cryptodev == NULL)
return -ENODEV;
ret = dpaa_sec_uninit(cryptodev);
if (ret)
return ret;
return rte_cryptodev_pmd_destroy(cryptodev);
}
static struct rte_dpaa_driver rte_dpaa_sec_driver = {
.drv_type = FSL_DPAA_CRYPTO,
.driver = {
.name = "DPAA SEC PMD"
},
.probe = cryptodev_dpaa_sec_probe,
.remove = cryptodev_dpaa_sec_remove,
};
static struct cryptodev_driver dpaa_sec_crypto_drv;
RTE_PMD_REGISTER_DPAA(CRYPTODEV_NAME_DPAA_SEC_PMD, rte_dpaa_sec_driver);
RTE_PMD_REGISTER_CRYPTO_DRIVER(dpaa_sec_crypto_drv, rte_dpaa_sec_driver,
cryptodev_driver_id);
| 25.84377 | 77 | 0.710557 |
b78c85e47f3ab2f6d41d5ed8fdff862bc5280d60 | 5,317 | h | C | dev/Code/CryEngine/RenderDll/XRenderD3D9/DXGL/Specification/glad_egl.h | stickyparticles/lumberyard | dc523dd780f3cd1874251181b7cf6848b8db9959 | [
"AML"
] | 2 | 2019-11-29T09:04:54.000Z | 2021-03-18T02:34:44.000Z | dev/Code/CryEngine/RenderDll/XRenderD3D9/DXGL/Specification/glad_egl.h | JulianoCristian/Lumberyard-3 | dc523dd780f3cd1874251181b7cf6848b8db9959 | [
"AML"
] | null | null | null | dev/Code/CryEngine/RenderDll/XRenderD3D9/DXGL/Specification/glad_egl.h | JulianoCristian/Lumberyard-3 | dc523dd780f3cd1874251181b7cf6848b8db9959 | [
"AML"
] | 3 | 2019-05-13T09:41:33.000Z | 2021-04-09T12:12:38.000Z | /*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef __glad_egl_h_
#ifdef __egl_h_
#error EGL header already included, remove this include, glad already provides it
#endif
#define __glad_egl_h_
#define __egl_h_
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h>
#endif
#ifndef APIENTRY
#define APIENTRY
#endif
#ifndef APIENTRYP
#define APIENTRYP APIENTRY *
#endif
#ifndef GLAPI
#define GLAPI extern
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __gladloadproc__
#define __gladloadproc__
typedef void* (* GLADloadproc)(const char* name);
#endif
GLAPI int gladLoadEGLLoader(GLADloadproc);
GLAPI int gladLoadEGL(void);
GLAPI int gladLoadEGLLoader(GLADloadproc);
#include "khrplatform.h"
#include <EGL/eglplatform.h>
typedef unsigned int EGLBoolean;
typedef unsigned int EGLenum;
typedef intptr_t EGLAttribKHR;
typedef intptr_t EGLAttrib;
typedef void* EGLClientBuffer;
typedef void* EGLConfig;
typedef void* EGLContext;
typedef void* EGLDeviceEXT;
typedef void* EGLDisplay;
typedef void* EGLImage;
typedef void* EGLImageKHR;
typedef void* EGLOutputLayerEXT;
typedef void* EGLOutputPortEXT;
typedef void* EGLStreamKHR;
typedef void* EGLSurface;
typedef void* EGLSync;
typedef void* EGLSyncKHR;
typedef void* EGLSyncNV;
typedef void (* __eglMustCastToProperFunctionPointerType)(void);
typedef khronos_utime_nanoseconds_t EGLTimeKHR;
typedef khronos_utime_nanoseconds_t EGLTime;
typedef khronos_utime_nanoseconds_t EGLTimeNV;
typedef khronos_utime_nanoseconds_t EGLuint64NV;
typedef khronos_uint64_t EGLuint64KHR;
typedef int EGLNativeFileDescriptorKHR;
typedef khronos_ssize_t EGLsizeiANDROID;
typedef void (* EGLSetBlobFuncANDROID) (const void* key, EGLsizeiANDROID keySize, const void* value, EGLsizeiANDROID valueSize);
typedef EGLsizeiANDROID (* EGLGetBlobFuncANDROID) (const void* key, EGLsizeiANDROID keySize, void* value, EGLsizeiANDROID valueSize);
struct EGLClientPixmapHI
{
void* pData;
EGLint iWidth;
EGLint iHeight;
EGLint iStride;
};
EGLBoolean eglChooseConfig(EGLDisplay, const EGLint*, EGLConfig*, EGLint, EGLint*);
EGLBoolean eglCopyBuffers(EGLDisplay, EGLSurface, EGLNativePixmapType);
EGLContext eglCreateContext(EGLDisplay, EGLConfig, EGLContext, const EGLint*);
EGLSurface eglCreatePbufferSurface(EGLDisplay, EGLConfig, const EGLint*);
EGLSurface eglCreatePixmapSurface(EGLDisplay, EGLConfig, EGLNativePixmapType, const EGLint*);
EGLSurface eglCreateWindowSurface(EGLDisplay, EGLConfig, EGLNativeWindowType, const EGLint*);
EGLBoolean eglDestroyContext(EGLDisplay, EGLContext);
EGLBoolean eglDestroySurface(EGLDisplay, EGLSurface);
EGLBoolean eglGetConfigAttrib(EGLDisplay, EGLConfig, EGLint, EGLint*);
EGLBoolean eglGetConfigs(EGLDisplay, EGLConfig*, EGLint, EGLint*);
EGLDisplay eglGetCurrentDisplay();
EGLSurface eglGetCurrentSurface(EGLint);
EGLDisplay eglGetDisplay(EGLNativeDisplayType);
EGLint eglGetError();
__eglMustCastToProperFunctionPointerType eglGetProcAddress(const char*);
EGLBoolean eglInitialize(EGLDisplay, EGLint*, EGLint*);
EGLBoolean eglMakeCurrent(EGLDisplay, EGLSurface, EGLSurface, EGLContext);
EGLBoolean eglQueryContext(EGLDisplay, EGLContext, EGLint, EGLint*);
const char* eglQueryString(EGLDisplay, EGLint);
EGLBoolean eglQuerySurface(EGLDisplay, EGLSurface, EGLint, EGLint*);
EGLBoolean eglSwapBuffers(EGLDisplay, EGLSurface);
EGLBoolean eglTerminate(EGLDisplay);
EGLBoolean eglWaitGL();
EGLBoolean eglWaitNative(EGLint);
EGLBoolean eglBindTexImage(EGLDisplay, EGLSurface, EGLint);
EGLBoolean eglReleaseTexImage(EGLDisplay, EGLSurface, EGLint);
EGLBoolean eglSurfaceAttrib(EGLDisplay, EGLSurface, EGLint, EGLint);
EGLBoolean eglSwapInterval(EGLDisplay, EGLint);
EGLBoolean eglBindAPI(EGLenum);
EGLenum eglQueryAPI();
EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay, EGLenum, EGLClientBuffer, EGLConfig, const EGLint*);
EGLBoolean eglReleaseThread();
EGLBoolean eglWaitClient();
EGLContext eglGetCurrentContext();
EGLSync eglCreateSync(EGLDisplay, EGLenum, const EGLAttrib*);
EGLBoolean eglDestroySync(EGLDisplay, EGLSync);
EGLint eglClientWaitSync(EGLDisplay, EGLSync, EGLint, EGLTime);
EGLBoolean eglGetSyncAttrib(EGLDisplay, EGLSync, EGLint, EGLAttrib*);
EGLImage eglCreateImage(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLAttrib*);
EGLBoolean eglDestroyImage(EGLDisplay, EGLImage);
EGLDisplay eglGetPlatformDisplay(EGLenum, void*, const EGLAttrib*);
EGLSurface eglCreatePlatformWindowSurface(EGLDisplay, EGLConfig, void*, const EGLAttrib*);
EGLSurface eglCreatePlatformPixmapSurface(EGLDisplay, EGLConfig, void*, const EGLAttrib*);
EGLBoolean eglWaitSync(EGLDisplay, EGLSync, EGLint);
#ifdef __cplusplus
}
#endif
#endif
| 37.978571 | 133 | 0.821704 |
64723577fedaf8aa7745ae776d8f2c98c15e93ff | 318 | h | C | src/hashes/hash_null.h | efficient/ffbf | 8dc08e97f133a6df80fdc1d06ac30a9f578c93b9 | [
"Apache-2.0"
] | 43 | 2015-01-16T01:51:21.000Z | 2022-01-27T06:15:00.000Z | src/hashes/hash_null.h | leepro/ffbf | 8dc08e97f133a6df80fdc1d06ac30a9f578c93b9 | [
"Apache-2.0"
] | null | null | null | src/hashes/hash_null.h | leepro/ffbf | 8dc08e97f133a6df80fdc1d06ac30a9f578c93b9 | [
"Apache-2.0"
] | 14 | 2015-11-21T19:25:46.000Z | 2021-04-01T23:21:25.000Z | #ifndef _HASH_NULL_H_
#define _HASH_NULL_H_
#include "hash_common.h"
#include "hash_buf.h"
template<int LEN> class hash_null {
private:
public:
inline uint32_t hval() { return 0; }
inline void reset() { }
inline void init() { }
inline void update(unsigned char c) { }
};
#endif /* _HASH_NULL_H_ */
| 17.666667 | 43 | 0.676101 |
035f3ad8c9a743f888f631c4c9489ce3ecb4a98f | 2,760 | h | C | taichi/jit/jit_module.h | gaoxinge/taichi | 86d403f071b8505858763d4712b37cd71b89db91 | [
"MIT"
] | 1 | 2020-11-10T07:17:01.000Z | 2020-11-10T07:17:01.000Z | taichi/jit/jit_module.h | gaoxinge/taichi | 86d403f071b8505858763d4712b37cd71b89db91 | [
"MIT"
] | 1 | 2020-08-24T05:18:43.000Z | 2020-08-24T05:18:43.000Z | taichi/jit/jit_module.h | gaoxinge/taichi | 86d403f071b8505858763d4712b37cd71b89db91 | [
"MIT"
] | null | null | null | #pragma once
#include <memory>
#include <functional>
#include "taichi/inc/constants.h"
#include "taichi/lang_util.h"
#include "taichi/program/kernel_profiler.h"
TLANG_NAMESPACE_BEGIN
// A architecture-specific JIT module that initializes with an **LLVM** module
// and allows the user to call its functions
// TODO: should we generalize this to include the Metal and OpenGL backends as
// well?
class JITModule {
public:
JITModule() {
}
// Lookup a serial function.
// For example, a CPU function, or a serial GPU function
// This function returns a function pointer
virtual void *lookup_function(const std::string &name) = 0;
// Unfortunately, this can't be virtual since it's a template function
template <typename... Args>
std::function<void(Args...)> get_function(const std::string &name) {
using FuncT = typename std::function<void(Args...)>;
auto ret = FuncT((function_pointer_type<FuncT>)lookup_function(name));
TI_ASSERT(ret != nullptr);
return ret;
}
static std::vector<void *> get_arg_pointers() {
return std::vector<void *>();
}
template <typename... Args, typename T>
static std::vector<void *> get_arg_pointers(T &t, Args &...args) {
auto ret = get_arg_pointers(args...);
ret.insert(ret.begin(), &t);
return ret;
}
// Note: **call** is for serial functions
// Note: args must pass by value
template <typename... Args>
void call(const std::string &name, Args... args) {
if (direct_dispatch()) {
get_function<Args...>(name)(args...);
} else {
auto arg_pointers = JITModule::get_arg_pointers(args...);
call(name, arg_pointers);
}
}
virtual void call(const std::string &name,
const std::vector<void *> &arg_pointers) {
TI_NOT_IMPLEMENTED
}
// Note: **launch** is for parallel (GPU)_kernels
// Note: args must pass by value
template <typename... Args>
void launch(const std::string &name,
std::size_t grid_dim,
std::size_t block_dim,
std::size_t shared_mem_bytes,
Args... args) {
auto arg_pointers = JITModule::get_arg_pointers(args...);
launch_with_arg_pointers(name, grid_dim, block_dim, shared_mem_bytes,
arg_pointers);
}
virtual void launch(const std::string &name,
std::size_t grid_dim,
std::size_t block_dim,
std::size_t shared_mem_bytes,
const std::vector<void *> &arg_pointers) {
TI_NOT_IMPLEMENTED
}
// directly call the function (e.g. on CPU), or via another runtime system
// (e.g. cudaLaunch)?
virtual bool direct_dispatch() const = 0;
virtual ~JITModule() {
}
};
TLANG_NAMESPACE_END
| 29.361702 | 78 | 0.641667 |
03f8b23ab3ad2b4a54a5496369ddfe8231e893a1 | 1,135 | h | C | apiwznm/WznmQSbsFrs1NRelation.h | mpsitech/wznm-WhizniumSBE | 4911d561b28392d485c46e98fb915168d82b3824 | [
"MIT"
] | 3 | 2020-09-20T16:24:48.000Z | 2021-12-01T19:44:51.000Z | apiwznm/WznmQSbsFrs1NRelation.h | mpsitech/wznm-WhizniumSBE | 4911d561b28392d485c46e98fb915168d82b3824 | [
"MIT"
] | null | null | null | apiwznm/WznmQSbsFrs1NRelation.h | mpsitech/wznm-WhizniumSBE | 4911d561b28392d485c46e98fb915168d82b3824 | [
"MIT"
] | null | null | null | /**
* \file WznmQSbsFrs1NRelation.h
* API code for table TblWznmQSbsFrs1NRelation (declarations)
* \copyright (C) 2016-2020 MPSI Technologies GmbH
* \author Alexander Wirthmueller (auto-generation)
* \date created: 5 Dec 2020
*/
// IP header --- ABOVE
#ifndef WZNMQSBSFRS1NRELATION_H
#define WZNMQSBSFRS1NRELATION_H
#include <sbecore/Xmlio.h>
/**
* WznmQSbsFrs1NRelation
*/
class WznmQSbsFrs1NRelation {
public:
WznmQSbsFrs1NRelation(const Sbecore::uint jnum = 0, const std::string stubRef = "");
public:
Sbecore::uint jnum;
std::string stubRef;
public:
bool readXML(xmlXPathContext* docctx, std::string basexpath = "", bool addbasetag = false);
};
/**
* ListWznmQSbsFrs1NRelation
*/
class ListWznmQSbsFrs1NRelation {
public:
ListWznmQSbsFrs1NRelation();
ListWznmQSbsFrs1NRelation(const ListWznmQSbsFrs1NRelation& src);
ListWznmQSbsFrs1NRelation& operator=(const ListWznmQSbsFrs1NRelation& src);
~ListWznmQSbsFrs1NRelation();
void clear();
public:
std::vector<WznmQSbsFrs1NRelation*> nodes;
public:
bool readXML(xmlXPathContext* docctx, std::string basexpath = "", bool addbasetag = false);
};
#endif
| 21.826923 | 92 | 0.756828 |
c19a49c16307c1ef0232809b4a79b798476d6823 | 76 | c | C | Module 01/exemplos/ambiente.c | hpaes/Curso-Linguagem-C---Estudonauta | 14a96fd86815bcc5d5c6cb10fea1627724e7c2da | [
"MIT"
] | null | null | null | Module 01/exemplos/ambiente.c | hpaes/Curso-Linguagem-C---Estudonauta | 14a96fd86815bcc5d5c6cb10fea1627724e7c2da | [
"MIT"
] | null | null | null | Module 01/exemplos/ambiente.c | hpaes/Curso-Linguagem-C---Estudonauta | 14a96fd86815bcc5d5c6cb10fea1627724e7c2da | [
"MIT"
] | null | null | null | #include <stdio.h>
void main()
{
printf("oi, tudo \rbem?\n"); // raw
} | 10.857143 | 39 | 0.539474 |
8c18c66d197f269e61c9b674ccab8f0f1ab20e0f | 6,883 | h | C | include/simdjson/dom/serialization.h | mkleshchenok/simdjson | 79879802f9fa9cec17720b8412519f6cbbab5047 | [
"Apache-2.0"
] | 9,541 | 2019-02-21T00:32:22.000Z | 2020-03-20T00:06:57.000Z | include/simdjson/dom/serialization.h | mkleshchenok/simdjson | 79879802f9fa9cec17720b8412519f6cbbab5047 | [
"Apache-2.0"
] | 1,084 | 2020-03-20T15:06:02.000Z | 2022-03-29T13:47:35.000Z | include/simdjson/dom/serialization.h | mkleshchenok/simdjson | 79879802f9fa9cec17720b8412519f6cbbab5047 | [
"Apache-2.0"
] | 546 | 2019-02-21T03:19:22.000Z | 2020-03-19T11:56:58.000Z | #ifndef SIMDJSON_SERIALIZATION_H
#define SIMDJSON_SERIALIZATION_H
#include "simdjson/common_defs.h"
#include "simdjson/dom/document.h"
#include "simdjson/error.h"
#include "simdjson/internal/dom_parser_implementation.h"
#include "simdjson/internal/tape_ref.h"
#include "simdjson/padded_string.h"
#include "simdjson/portability.h"
#include <vector>
namespace simdjson {
/**
* The string_builder template and mini_formatter class
* are not part of our public API and are subject to change
* at any time!
*/
namespace internal {
class mini_formatter;
/**
* @private The string_builder template allows us to construct
* a string from a document element. It is parametrized
* by a "formatter" which handles the details. Thus
* the string_builder template could support both minification
* and prettification, and various other tradeoffs.
*/
template <class formatter = mini_formatter>
class string_builder {
public:
/** Construct an initially empty builder, would print the empty string **/
string_builder() = default;
/** Append an element to the builder (to be printed) **/
inline void append(simdjson::dom::element value);
/** Append an array to the builder (to be printed) **/
inline void append(simdjson::dom::array value);
/** Append an object to the builder (to be printed) **/
inline void append(simdjson::dom::object value);
/** Reset the builder (so that it would print the empty string) **/
simdjson_really_inline void clear();
/**
* Get access to the string. The string_view is owned by the builder
* and it is invalid to use it after the string_builder has been
* destroyed.
* However you can make a copy of the string_view on memory that you
* own.
*/
simdjson_really_inline std::string_view str() const;
/** Append a key_value_pair to the builder (to be printed) **/
simdjson_really_inline void append(simdjson::dom::key_value_pair value);
private:
formatter format{};
};
/**
* @private This is the class that we expect to use with the string_builder
* template. It tries to produce a compact version of the JSON element
* as quickly as possible.
*/
class mini_formatter {
public:
mini_formatter() = default;
/** Add a comma **/
simdjson_really_inline void comma();
/** Start an array, prints [ **/
simdjson_really_inline void start_array();
/** End an array, prints ] **/
simdjson_really_inline void end_array();
/** Start an array, prints { **/
simdjson_really_inline void start_object();
/** Start an array, prints } **/
simdjson_really_inline void end_object();
/** Prints a true **/
simdjson_really_inline void true_atom();
/** Prints a false **/
simdjson_really_inline void false_atom();
/** Prints a null **/
simdjson_really_inline void null_atom();
/** Prints a number **/
simdjson_really_inline void number(int64_t x);
/** Prints a number **/
simdjson_really_inline void number(uint64_t x);
/** Prints a number **/
simdjson_really_inline void number(double x);
/** Prints a key (string + colon) **/
simdjson_really_inline void key(std::string_view unescaped);
/** Prints a string. The string is escaped as needed. **/
simdjson_really_inline void string(std::string_view unescaped);
/** Clears out the content. **/
simdjson_really_inline void clear();
/**
* Get access to the buffer, it is owned by the instance, but
* the user can make a copy.
**/
simdjson_really_inline std::string_view str() const;
private:
// implementation details (subject to change)
/** Prints one character **/
simdjson_really_inline void one_char(char c);
/** Backing buffer **/
std::vector<char> buffer{}; // not ideal!
};
} // internal
namespace dom {
/**
* Print JSON to an output stream.
*
* @param out The output stream.
* @param value The element.
* @throw if there is an error with the underlying output stream. simdjson itself will not throw.
*/
inline std::ostream& operator<<(std::ostream& out, simdjson::dom::element value) {
simdjson::internal::string_builder<> sb;
sb.append(value);
return (out << sb.str());
}
#if SIMDJSON_EXCEPTIONS
inline std::ostream& operator<<(std::ostream& out, simdjson::simdjson_result<simdjson::dom::element> x) {
if (x.error()) { throw simdjson::simdjson_error(x.error()); }
return (out << x.value());
}
#endif
/**
* Print JSON to an output stream.
*
* @param out The output stream.
* @param value The array.
* @throw if there is an error with the underlying output stream. simdjson itself will not throw.
*/
inline std::ostream& operator<<(std::ostream& out, simdjson::dom::array value) {
simdjson::internal::string_builder<> sb;
sb.append(value);
return (out << sb.str());
}
#if SIMDJSON_EXCEPTIONS
inline std::ostream& operator<<(std::ostream& out, simdjson::simdjson_result<simdjson::dom::array> x) {
if (x.error()) { throw simdjson::simdjson_error(x.error()); }
return (out << x.value());
}
#endif
/**
* Print JSON to an output stream.
*
* @param out The output stream.
* @param value The object.
* @throw if there is an error with the underlying output stream. simdjson itself will not throw.
*/
inline std::ostream& operator<<(std::ostream& out, simdjson::dom::object value) {
simdjson::internal::string_builder<> sb;
sb.append(value);
return (out << sb.str());
}
#if SIMDJSON_EXCEPTIONS
inline std::ostream& operator<<(std::ostream& out, simdjson::simdjson_result<simdjson::dom::object> x) {
if (x.error()) { throw simdjson::simdjson_error(x.error()); }
return (out << x.value());
}
#endif
} // namespace dom
/**
* Converts JSON to a string.
*
* dom::parser parser;
* element doc = parser.parse(" [ 1 , 2 , 3 ] "_padded);
* cout << to_string(doc) << endl; // prints [1,2,3]
*
*/
template <class T>
std::string to_string(T x) {
// in C++, to_string is standard: http://www.cplusplus.com/reference/string/to_string/
// Currently minify and to_string are identical but in the future, they may
// differ.
simdjson::internal::string_builder<> sb;
sb.append(x);
std::string_view answer = sb.str();
return std::string(answer.data(), answer.size());
}
#if SIMDJSON_EXCEPTIONS
template <class T>
std::string to_string(simdjson_result<T> x) {
if (x.error()) { throw simdjson_error(x.error()); }
return to_string(x.value());
}
#endif
/**
* Minifies a JSON element or document, printing the smallest possible valid JSON.
*
* dom::parser parser;
* element doc = parser.parse(" [ 1 , 2 , 3 ] "_padded);
* cout << minify(doc) << endl; // prints [1,2,3]
*
*/
template <class T>
std::string minify(T x) {
return to_string(x);
}
#if SIMDJSON_EXCEPTIONS
template <class T>
std::string minify(simdjson_result<T> x) {
if (x.error()) { throw simdjson_error(x.error()); }
return to_string(x.value());
}
#endif
} // namespace simdjson
#endif | 31.429224 | 105 | 0.69214 |
96fa9f4e6601ef2b16eda321d45333202b9a3ad2 | 2,058 | h | C | platforms/Cross/plugins/B3DAcceleratorPlugin/sqOpenGLRenderer.h | pavel-krivanek/opensmalltalk-vm | 694dfe3ed015e16f5b8e9cf17d37e4bdd32bea16 | [
"MIT"
] | 445 | 2016-06-30T08:19:11.000Z | 2022-03-28T06:09:49.000Z | platforms/Cross/plugins/B3DAcceleratorPlugin/sqOpenGLRenderer.h | pavel-krivanek/opensmalltalk-vm | 694dfe3ed015e16f5b8e9cf17d37e4bdd32bea16 | [
"MIT"
] | 439 | 2016-06-29T20:14:36.000Z | 2022-03-17T19:59:58.000Z | platforms/Cross/plugins/B3DAcceleratorPlugin/sqOpenGLRenderer.h | pavel-krivanek/opensmalltalk-vm | 694dfe3ed015e16f5b8e9cf17d37e4bdd32bea16 | [
"MIT"
] | 137 | 2016-07-02T17:32:07.000Z | 2022-03-20T11:17:25.000Z | #ifndef SQ_OPENGL_RENDERER_H
#define SQ_OPENGL_RENDERER_H
#if defined(macintoshSqueak)
# include "sqMacOpenGL.h"
#elif defined(_WIN32)
# include "sqWin32OpenGL.h"
#elif defined(UNIX)
# include "sqUnixOpenGL.h"
#endif
#if !defined(GL_RENDERER_DEFINED)
typedef struct glRenderer {
GLint bufferRect[4];
GLint viewport[4];
} glRenderer;
#endif
struct glRenderer *glRendererFromHandle(int rendererHandle);
int glMakeCurrentRenderer(struct glRenderer *renderer);
int glSwapBuffers(struct glRenderer *renderer);
/***************************************************************************/
/***************************************************************************/
/* Debug Logging/Error Reporting to Squeak3D.log in the image's directory. */
/***************************************************************************/
/***************************************************************************/
#define ERROR_CHECK_2(glFn, sqFn) \
{ if( (glErr = glGetError()) != GL_NO_ERROR) DPRINTF3D(1, ("ERROR (%s): %s failed -- %s\n", sqFn, glFn, glErrString())); }
#define ERROR_CHECK_1(glFn) \
{ if( (glErr = glGetError()) != GL_NO_ERROR) DPRINTF3D(1, ("ERROR (file %s, line %d): %s failed -- %s\n", __FILE__, __LINE__, glFn, glErrString())); }
#define ERROR_CHECK ERROR_CHECK_1("a GL function")
/* Verbose level for debugging purposes:
0 - print NO information ever
1 - print critical debug errors
2 - print debug warnings
3 - print extra information
4 - print per-frame statistics
5 - print information about textures, lights, materials, and primitives
6 - print information about background synchronization
10 - print information about each vertex and face
*/
extern int glVerbosityLevel;
extern int glErr;
extern char *glErrString(void);
/* Note: Print this stuff into a file in case we lock up */
extern int print3Dlog(char *fmt, ...);
/* define forceFlush if we should fflush() after each write */
#define forceFlush 1
#define DPRINTF3D(v,a) do { if ((v) <= glVerbosityLevel) print3Dlog a; } while (0)
#endif /* sqOpenGLRenderer.h */
| 33.193548 | 151 | 0.624879 |
121526027889043d12f5f697c485ab7897eae0a0 | 3,137 | h | C | src/ext/wintypes.h | melshuber/libifdse | 3accf7292dcf60a8d54dd8f9cca70b1afa6a33ca | [
"MIT"
] | 3 | 2020-05-06T12:35:23.000Z | 2021-03-18T18:12:28.000Z | src/ext/wintypes.h | melshuber/libifdse | 3accf7292dcf60a8d54dd8f9cca70b1afa6a33ca | [
"MIT"
] | 2 | 2020-05-13T08:06:21.000Z | 2020-11-25T21:45:17.000Z | src/ext/wintypes.h | melshuber/libifdse | 3accf7292dcf60a8d54dd8f9cca70b1afa6a33ca | [
"MIT"
] | 1 | 2020-05-12T23:18:30.000Z | 2020-05-12T23:18:30.000Z | /*
* MUSCLE SmartCard Development ( http://pcsclite.alioth.debian.org/pcsclite.html )
*
* Copyright (C) 1999
* David Corcoran <corcoran@musclecard.com>
* Copyright (C) 2002-2011
* Ludovic Rousseau <ludovic.rousseau@free.fr>
*
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* @brief This keeps a list of Windows(R) types.
*/
#ifndef __wintypes_h__
#define __wintypes_h__
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef __APPLE__
#include <stdint.h>
#ifndef BYTE
typedef uint8_t BYTE;
#endif
typedef uint8_t UCHAR;
typedef UCHAR *PUCHAR;
typedef uint16_t USHORT;
#ifndef __COREFOUNDATION_CFPLUGINCOM__
typedef uint32_t ULONG;
typedef void *LPVOID;
typedef int16_t BOOL;
#endif
typedef ULONG *PULONG;
typedef const void *LPCVOID;
typedef uint32_t DWORD;
typedef DWORD *PDWORD;
typedef uint16_t WORD;
typedef int32_t LONG;
typedef const char *LPCSTR;
typedef const BYTE *LPCBYTE;
typedef BYTE *LPBYTE;
typedef DWORD *LPDWORD;
typedef char *LPSTR;
#else
#ifndef BYTE
typedef unsigned char BYTE;
#endif
typedef unsigned char UCHAR;
typedef UCHAR *PUCHAR;
typedef unsigned short USHORT;
#ifndef __COREFOUNDATION_CFPLUGINCOM__
typedef unsigned long ULONG;
typedef void *LPVOID;
#endif
typedef const void *LPCVOID;
typedef unsigned long DWORD;
typedef DWORD *PDWORD;
typedef long LONG;
typedef const char *LPCSTR;
typedef const BYTE *LPCBYTE;
typedef BYTE *LPBYTE;
typedef DWORD *LPDWORD;
typedef char *LPSTR;
/* these types were deprecated but still used by old drivers and
* applications. So just declare and use them. */
typedef LPSTR LPTSTR;
typedef LPCSTR LPCTSTR;
/* types unused by pcsc-lite */
typedef short BOOL;
typedef unsigned short WORD;
typedef ULONG *PULONG;
#endif
#ifdef __cplusplus
}
#endif
#endif
| 27.043103 | 83 | 0.760281 |
af449b66083280ad97f945e58e20bf8d07fcaf71 | 67,645 | c | C | tee/platform_sgx/moxie_swi_bolos_crypto.c | corollari/bolos-enclave | 573464ed783540704137b1cdc6dfd82c02c825ad | [
"Apache-2.0"
] | 36 | 2017-05-23T02:27:27.000Z | 2021-09-22T16:25:32.000Z | tee/platform_sgx/moxie_swi_bolos_crypto.c | corollari/bolos-enclave | 573464ed783540704137b1cdc6dfd82c02c825ad | [
"Apache-2.0"
] | 2 | 2018-01-24T20:45:37.000Z | 2018-10-10T15:05:24.000Z | tee/platform_sgx/moxie_swi_bolos_crypto.c | corollari/bolos-enclave | 573464ed783540704137b1cdc6dfd82c02c825ad | [
"Apache-2.0"
] | 8 | 2017-11-02T21:57:42.000Z | 2022-03-06T09:27:04.000Z | /*******************************************************************************
* BOLOS Enclave
* (c) 2017 Ledger
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
********************************************************************************/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include "signal.h"
#include <errno.h>
#include "bolos.h"
#include "machine.h"
#include "include/secp256k1.h"
#ifdef HAS_SCHNORR
#include "include/secp256k1_schnorr.h"
#endif
#include "include/secp256k1_ecdh.h"
#include "uECC.h"
#include "sodium/crypto_hash_sha256.h"
#include "sodium/crypto_hash_sha512.h"
#include "sodium/crypto_auth_hmacsha256.h"
#include "sodium/crypto_auth_hmacsha512.h"
#include "moxie_swi_common.h"
#include "portable_cx.h"
#include "bolos_core.h"
#include "bolos_crypto_common.h"
#include "bolos_crypto_platform_safenet.h"
#include "platform_al.h"
#include "sgx_pse.h"
#include "ctaes.h"
#include "ripemd160.h"
#include "sha3.h"
#define MAX_ECFP_PUBLIC_KEYS 5
#define MAX_ECFP_PRIVATE_KEYS 5
#define MAX_RSA_KEYS 5
#define MAX_CRYPTO_SESSIONS 10
#define MAX_HASH_SESSIONS 10
#define MAX_HMAC_SESSIONS 5
#define MAX_SYMMETRIC_KEYS 10
#define MAX_RSA_LONGINT_SIZE 512
#define MAX_SYMMETRIC_KEY_SIZE 32
extern secp256k1_context *secp256k1Context;
// uECC deterministic signing
typedef struct SHA256_HashContext {
uECC_HashContext uECC;
crypto_hash_sha256_state sha256;
} SHA256_HashContext;
void init_SHA256(const uECC_HashContext *base) {
SHA256_HashContext *context = (SHA256_HashContext *)base;
crypto_hash_sha256_init(&context->sha256);
}
void update_SHA256(const uECC_HashContext *base, const uint8_t *message,
unsigned message_size) {
SHA256_HashContext *context = (SHA256_HashContext *)base;
crypto_hash_sha256_update(&context->sha256, message, message_size);
}
void finish_SHA256(const uECC_HashContext *base, uint8_t *hash_result) {
SHA256_HashContext *context = (SHA256_HashContext *)base;
crypto_hash_sha256_final(&context->sha256, hash_result);
}
#define uECC_BYTES 32
// /uECC deterministic signing
typedef struct cryptoSession_s {
uint8_t algorithm;
bool available;
} cryptoSession_t;
typedef struct hashSession_t {
union {
crypto_hash_sha256_state sha256;
crypto_hash_sha512_state sha512;
RIPEMD160_CTX ripemd160;
SHA3_CTX sha3;
} hashAlg;
uint8_t algorithm;
bool available;
} hashSession_t;
typedef struct hmacSession_t {
union {
crypto_auth_hmacsha256_state hmacsha256;
crypto_auth_hmacsha512_state hmacsha512;
} hashAlg;
uint8_t algorithm;
bool available;
} hmacSession_t;
typedef struct symmetricKey_t {
uint8_t keyData[MAX_SYMMETRIC_KEY_SIZE];
uint16_t keySize;
} symmetricKey_t;
cx_ecfp_public_key_t ecfp_public_keys[MAX_ECFP_PUBLIC_KEYS];
bool ecfp_public_key_available[MAX_ECFP_PUBLIC_KEYS];
cx_ecfp_private_key_t ecfp_private_keys[MAX_ECFP_PRIVATE_KEYS];
bool ecfp_private_key_available[MAX_ECFP_PRIVATE_KEYS];
symmetricKey_t symmetricKeys[MAX_SYMMETRIC_KEYS];
bool symmetric_key_available[MAX_SYMMETRIC_KEYS];
cryptoSession_t cryptoSessions[MAX_CRYPTO_SESSIONS];
hashSession_t hashSessions[MAX_HASH_SESSIONS];
hmacSession_t hmacSessions[MAX_HMAC_SESSIONS];
const uint8_t SECP256K1_N[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41};
int ecdsa_der_to_sig(const uint8_t *der, uint8_t *sig) {
int length;
int offset = 2;
int delta = 0;
if (der[0] != 0x30) {
return 0;
}
if (der[offset + 2] == 0) {
length = der[offset + 1] - 1;
offset += 3;
} else {
length = der[offset + 1];
offset += 2;
}
if ((length < 0) || (length > uECC_BYTES)) {
return 0;
}
while ((length + delta) < uECC_BYTES) {
sig[delta++] = 0;
}
memmove(sig + delta, der + offset, length);
delta = 0;
offset += length;
if (der[offset + 2] == 0) {
length = der[offset + 1] - 1;
offset += 3;
} else {
length = der[offset + 1];
offset += 2;
}
if ((length < 0) || (length > uECC_BYTES)) {
return 0;
}
while ((length + delta) < uECC_BYTES) {
sig[uECC_BYTES + delta++] = 0;
}
memmove(sig + uECC_BYTES + delta, der + offset, length);
return 1;
}
int ecdsa_sig_to_der(const uint8_t *sig, uint8_t *der) {
int i;
uint8_t *p = der, *len, *len1, *len2;
*p = 0x30;
p++; // sequence
*p = 0x00;
len = p;
p++; // len(sequence)
*p = 0x02;
p++; // integer
*p = 0x00;
len1 = p;
p++; // len(integer)
// process R
i = 0;
while (sig[i] == 0 && i < 32) {
i++;
} // skip leading zeroes
if (sig[i] >= 0x80) { // put zero in output if MSB set
*p = 0x00;
p++;
*len1 = *len1 + 1;
}
while (i < 32) { // copy bytes to output
*p = sig[i];
p++;
*len1 = *len1 + 1;
i++;
}
*p = 0x02;
p++; // integer
*p = 0x00;
len2 = p;
p++; // len(integer)
// process S
i = 32;
while (sig[i] == 0 && i < 64) {
i++;
} // skip leading zeroes
if (sig[i] >= 0x80) { // put zero in output if MSB set
*p = 0x00;
p++;
*len2 = *len2 + 1;
}
while (i < 64) { // copy bytes to output
*p = sig[i];
p++;
*len2 = *len2 + 1;
i++;
}
*len = *len1 + *len2 + 4;
return *len + 2;
}
void moxie_swi_crypto_init() {
uint32_t i;
for (i = 0; i < MAX_ECFP_PUBLIC_KEYS; i++) {
ecfp_public_key_available[i] = true;
}
for (i = 0; i < MAX_ECFP_PRIVATE_KEYS; i++) {
ecfp_private_key_available[i] = true;
}
for (i = 0; i < MAX_CRYPTO_SESSIONS; i++) {
platform_secure_memset0(&cryptoSessions[i], sizeof(cryptoSession_t));
cryptoSessions[i].available = true;
}
for (i = 0; i < MAX_HASH_SESSIONS; i++) {
hashSessions[i].available = true;
}
for (i = 0; i < MAX_HMAC_SESSIONS; i++) {
hmacSessions[i].available = true;
}
for (i = 0; i < MAX_SYMMETRIC_KEYS; i++) {
symmetric_key_available[i] = true;
platform_secure_memset0(&symmetricKeys[i], sizeof(symmetricKey_t));
}
// Cleanup platform service session
sgx_reset_pse();
}
void moxie_swi_crypto_cleanup() {
uint32_t i;
for (i = 0; i < MAX_ECFP_PUBLIC_KEYS; i++) {
platform_secure_memset0(&ecfp_public_keys[i],
sizeof(cx_ecfp_public_key_t));
}
for (i = 0; i < MAX_ECFP_PRIVATE_KEYS; i++) {
platform_secure_memset0(&ecfp_private_keys[i],
sizeof(cx_ecfp_private_key_t));
}
for (i = 0; i < MAX_CRYPTO_SESSIONS; i++) {
platform_secure_memset0(&cryptoSessions[i], sizeof(cryptoSession_t));
}
for (i = 0; i < MAX_HASH_SESSIONS; i++) {
#ifndef SGX
if (hashSessions[i].hashAlg.nativeSession != NULL) {
hashSessions[i].hashAlg.nativeSession->Free(
hashSessions[i].hashAlg.nativeSession);
hashSessions[i].hashAlg.nativeSession = NULL;
}
#endif
platform_secure_memset0(&hashSessions[i], sizeof(hashSession_t));
}
for (i = 0; i < MAX_HMAC_SESSIONS; i++) {
// TODO : cleanup native
platform_secure_memset0(&hmacSessions[i], sizeof(hmacSession_t));
}
for (i = 0; i < MAX_SYMMETRIC_KEYS; i++) {
platform_secure_memset0(&symmetricKeys[i], sizeof(symmetricKey_t));
}
// Cleanup platform service session
sgx_close_pse();
}
uint8_t check_crypto_handle_allocate(bool *availableBuffer, uint32_t maxKeys,
uint32_t *cryptoHandle) {
uint32_t i;
if (*cryptoHandle > maxKeys) {
return 0;
}
if (*cryptoHandle == 0) {
for (i = 0; i < maxKeys; i++) {
if (availableBuffer[i]) {
availableBuffer[i] = false;
*cryptoHandle = i + 1;
break;
}
}
}
return (*cryptoHandle != 0);
}
uint8_t check_crypto_handle_use(bool *availableBuffer, uint32_t maxKeys,
uint32_t cryptoHandle) {
if ((cryptoHandle == 0) || (cryptoHandle > maxKeys) ||
(availableBuffer[cryptoHandle - 1])) {
return 0;
}
return 1;
}
uint8_t check_hash_handle_allocate(uint32_t *hashHandle) {
uint32_t i;
if (*hashHandle > MAX_HASH_SESSIONS) {
return 0;
}
if (*hashHandle == 0) {
for (i = 0; i < MAX_HASH_SESSIONS; i++) {
if (hashSessions[i].available) {
hashSessions[i].available = false;
*hashHandle = i + 1;
break;
}
}
}
return (*hashHandle != 0);
}
uint8_t check_hash_handle_use(uint32_t hashHandle) {
if ((hashHandle == 0) || (hashHandle > MAX_HASH_SESSIONS) ||
(hashSessions[hashHandle - 1].available)) {
return 0;
}
return 1;
}
uint8_t check_hmac_handle_allocate(uint32_t *hmacHandle) {
uint32_t i;
if (*hmacHandle > MAX_HASH_SESSIONS) {
return 0;
}
if (*hmacHandle == 0) {
for (i = 0; i < MAX_HMAC_SESSIONS; i++) {
if (hmacSessions[i].available) {
hmacSessions[i].available = false;
*hmacHandle = i + 1;
break;
}
}
}
return (*hmacHandle != 0);
}
uint8_t check_hmac_handle_use(uint32_t hmacHandle) {
if ((hmacHandle == 0) || (hmacHandle > MAX_HMAC_SESSIONS) ||
(hmacSessions[hmacHandle - 1].available)) {
return 0;
}
return 1;
}
/*
* bls_rng_u8
* Output:
* uint8_t
*/
void moxie_bls_rng_u8(struct machine *mach) {
uint8_t data;
platform_random(&data, 1);
mach->cpu.regs[MOXIE_R0] = data;
}
/*
* bls_rng
* $r0 -- buffer uint8_t*
* $r1 -- len size_t
* Output:
* int
*/
void moxie_bls_rng(struct machine *mach) {
uint8_t *data;
uint32_t size = mach->cpu.regs[MOXIE_R1];
uint32_t status = 0;
data =
(uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R0], size, true);
if (data == NULL) {
printf("Invalid buffer\n");
goto end;
}
platform_random(data, size);
status = 1;
end:
mach->cpu.regs[MOXIE_R0] = status;
}
/*
* bls_ripemd160_init
* $r0 -- hash bls_ripemd160_t*
* Output:
* int
*/
void moxie_bls_ripemd160_init(struct machine *mach) {
uint32_t cryptoHandle;
uint32_t status = 0;
if (!moxie_var_read_crypto_handle(mach, mach->cpu.regs[MOXIE_R0],
&cryptoHandle)) {
printf("Error reading handle\n");
goto end;
}
cryptoHandle = 0;
if (!check_hash_handle_allocate(&cryptoHandle)) {
printf("Error allocating handle\n");
goto end;
}
hashSessions[cryptoHandle - 1].algorithm = BLS_RIPEMD160;
ripemd160_Init(&hashSessions[cryptoHandle - 1].hashAlg.ripemd160);
moxie_var_write_crypto_handle(mach, mach->cpu.regs[MOXIE_R0], cryptoHandle);
status = 1;
end:
mach->cpu.regs[MOXIE_R0] = status;
}
/*
* bls_sha256_init
* $r0 -- hash bls_sha256_t*
* Output:
* int
*/
void moxie_bls_sha256_init(struct machine *mach) {
uint32_t cryptoHandle;
uint32_t status = 0;
if (!moxie_var_read_crypto_handle(mach, mach->cpu.regs[MOXIE_R0],
&cryptoHandle)) {
printf("Error reading handle\n");
goto end;
}
cryptoHandle = 0;
if (!check_hash_handle_allocate(&cryptoHandle)) {
printf("Error allocating handle\n");
goto end;
}
hashSessions[cryptoHandle - 1].algorithm = BLS_SHA256;
crypto_hash_sha256_init(&hashSessions[cryptoHandle - 1].hashAlg.sha256);
moxie_var_write_crypto_handle(mach, mach->cpu.regs[MOXIE_R0], cryptoHandle);
status = 1;
end:
mach->cpu.regs[MOXIE_R0] = status;
}
/*
* bls_sha512_init
* $r0 -- hash bls_sha512_t*
* Output:
* int
*/
void moxie_bls_sha512_init(struct machine *mach) {
uint32_t cryptoHandle;
uint32_t status = 0;
if (!moxie_var_read_crypto_handle(mach, mach->cpu.regs[MOXIE_R0],
&cryptoHandle)) {
printf("Error reading handle\n");
goto end;
}
cryptoHandle = 0;
if (!check_hash_handle_allocate(&cryptoHandle)) {
printf("Error allocating handle\n");
goto end;
}
hashSessions[cryptoHandle - 1].algorithm = BLS_SHA512;
crypto_hash_sha512_init(&hashSessions[cryptoHandle - 1].hashAlg.sha512);
moxie_var_write_crypto_handle(mach, mach->cpu.regs[MOXIE_R0], cryptoHandle);
status = 1;
end:
mach->cpu.regs[MOXIE_R0] = status;
}
/*
* bls_sha3_init
* $r0 -- hash bls_sha3_t*
* $r1 -- size int
* Output:
* int
*/
void moxie_bls_sha3_init(struct machine *mach) {
uint32_t cryptoHandle;
uint32_t status = 0;
uint32_t bits = mach->cpu.regs[MOXIE_R1];
if (!moxie_var_read_crypto_handle(mach, mach->cpu.regs[MOXIE_R0],
&cryptoHandle)) {
printf("Error reading handle\n");
goto end;
}
cryptoHandle = 0;
if (!check_hash_handle_allocate(&cryptoHandle)) {
printf("Error allocating handle\n");
goto end;
}
hashSessions[cryptoHandle - 1].algorithm = BLS_SHA3;
switch (bits) {
case 224:
sha3_224_Init(&hashSessions[cryptoHandle - 1].hashAlg.sha3);
break;
case 256:
sha3_256_Init(&hashSessions[cryptoHandle - 1].hashAlg.sha3);
break;
case 384:
sha3_384_Init(&hashSessions[cryptoHandle - 1].hashAlg.sha3);
break;
case 512:
sha3_512_Init(&hashSessions[cryptoHandle - 1].hashAlg.sha3);
break;
default:
printf("Unsupported size %d\n", bits);
hashSessions[cryptoHandle - 1].available = true;
goto end;
}
moxie_var_write_crypto_handle(mach, mach->cpu.regs[MOXIE_R0], cryptoHandle);
status = 1;
end:
mach->cpu.regs[MOXIE_R0] = status;
}
/*
* bls_keccak_init
* $r0 -- hash bls_sha3_t*
* $r1 -- size int
* Output:
* int
*/
void moxie_bls_keccak_init(struct machine *mach) {
uint32_t cryptoHandle;
uint32_t status = 0;
uint32_t bits = mach->cpu.regs[MOXIE_R1];
if (!moxie_var_read_crypto_handle(mach, mach->cpu.regs[MOXIE_R0],
&cryptoHandle)) {
printf("Error reading handle\n");
goto end;
}
cryptoHandle = 0;
if (!check_hash_handle_allocate(&cryptoHandle)) {
printf("Error allocating handle\n");
goto end;
}
hashSessions[cryptoHandle - 1].algorithm = BLS_KECCAK;
switch (bits) {
case 224:
keccak_224_Init(&hashSessions[cryptoHandle - 1].hashAlg.sha3);
break;
case 256:
keccak_256_Init(&hashSessions[cryptoHandle - 1].hashAlg.sha3);
break;
case 384:
keccak_384_Init(&hashSessions[cryptoHandle - 1].hashAlg.sha3);
break;
case 512:
keccak_512_Init(&hashSessions[cryptoHandle - 1].hashAlg.sha3);
break;
default:
printf("Unsupported size %d\n", bits);
hashSessions[cryptoHandle - 1].available = true;
goto end;
}
moxie_var_write_crypto_handle(mach, mach->cpu.regs[MOXIE_R0], cryptoHandle);
status = 1;
end:
mach->cpu.regs[MOXIE_R0] = status;
}
/*
* bls_sha1_init
* $r0 -- hash bls_sha1_t*
* Output:
* int
*/
void moxie_bls_sha1_init(struct machine *mach) {
#ifndef SGX
uint32_t cryptoHandle;
uint32_t status = 0;
if (!moxie_var_read_crypto_handle(mach, mach->cpu.regs[MOXIE_R0],
&cryptoHandle)) {
printf("Error reading handle\n");
goto end;
}
cryptoHandle = 0;
if (!check_hash_handle_allocate(&cryptoHandle)) {
printf("Error allocating handle\n");
goto end;
}
hashSessions[cryptoHandle - 1].algorithm = BLS_SHA1;
hashSessions[cryptoHandle - 1].algorithmNative = FMCO_IDX_SHA1;
if (hashSessions[cryptoHandle - 1].hashAlg.nativeSession != NULL) {
hashSessions[cryptoHandle - 1].hashAlg.nativeSession->Free(
hashSessions[cryptoHandle - 1].hashAlg.nativeSession);
}
hashSessions[cryptoHandle - 1].hashAlg.nativeSession = NULL;
moxie_var_write_crypto_handle(mach, mach->cpu.regs[MOXIE_R0], cryptoHandle);
status = 1;
end:
mach->cpu.regs[MOXIE_R0] = status;
#endif
mach->cpu.exception = SIGBUS;
}
/*
* bls_hash
* $r0 -- hash bls_hash_t*
* $r1 -- mode int
* $r2 -- in uint8_t*
* $r3 -- len size_t
* $r4 -- out uint8_t*
* Output:
* int
*/
void moxie_bls_hash(struct machine *mach) {
uint32_t cryptoHandle;
uint32_t mode = mach->cpu.regs[MOXIE_R1];
uint8_t *src;
uint32_t size = mach->cpu.regs[MOXIE_R3];
uint8_t *dest;
uint32_t status = 0;
uint32_t hashSize;
if (!moxie_var_read_crypto_handle(mach, mach->cpu.regs[MOXIE_R0],
&cryptoHandle)) {
printf("Error reading handle\n");
goto end;
}
if (!check_hash_handle_use(cryptoHandle)) {
printf("Invalid hash handle\n");
goto end;
}
switch (hashSessions[cryptoHandle - 1].algorithm) {
case BLS_RIPEMD160:
hashSize = 20;
break;
case BLS_SHA256:
hashSize = 32;
break;
case BLS_SHA512:
hashSize = 64;
break;
case BLS_SHA3:
case BLS_KECCAK:
hashSize =
100 - (hashSessions[cryptoHandle - 1].hashAlg.sha3.block_size / 2);
break;
default:
printf("Unsupported algorithm\n");
break;
}
src =
(uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R2], size, false);
if (src == NULL) {
printf("Invalid input buffer\n");
goto end;
}
dest = (uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R4], hashSize,
true);
if (dest == NULL) {
printf("Invalid output buffer\n");
goto end;
}
if ((mode & BLS_LAST) == 0) {
switch (hashSessions[cryptoHandle - 1].algorithm) {
case BLS_SHA256:
crypto_hash_sha256_update(
&hashSessions[cryptoHandle - 1].hashAlg.sha256, src, size);
break;
case BLS_SHA512:
crypto_hash_sha512_update(
&hashSessions[cryptoHandle - 1].hashAlg.sha512, src, size);
break;
case BLS_RIPEMD160:
ripemd160_Update(&hashSessions[cryptoHandle - 1].hashAlg.ripemd160,
src, size);
break;
case BLS_SHA3:
sha3_Update(&hashSessions[cryptoHandle - 1].hashAlg.sha3, src,
size);
break;
case BLS_KECCAK:
keccak_Update(&hashSessions[cryptoHandle - 1].hashAlg.sha3, src,
size);
break;
}
status = 1;
} else {
switch (hashSessions[cryptoHandle - 1].algorithm) {
case BLS_SHA256:
crypto_hash_sha256_update(
&hashSessions[cryptoHandle - 1].hashAlg.sha256, src, size);
crypto_hash_sha256_final(
&hashSessions[cryptoHandle - 1].hashAlg.sha256, dest);
break;
case BLS_SHA512:
crypto_hash_sha512_update(
&hashSessions[cryptoHandle - 1].hashAlg.sha512, src, size);
crypto_hash_sha512_final(
&hashSessions[cryptoHandle - 1].hashAlg.sha512, dest);
break;
case BLS_RIPEMD160:
ripemd160_Update(&hashSessions[cryptoHandle - 1].hashAlg.ripemd160,
src, size);
ripemd160_Final(&hashSessions[cryptoHandle - 1].hashAlg.ripemd160,
dest);
break;
case BLS_SHA3:
sha3_Update(&hashSessions[cryptoHandle - 1].hashAlg.sha3, src,
size);
sha3_Final(&hashSessions[cryptoHandle - 1].hashAlg.sha3, dest);
break;
case BLS_KECCAK:
keccak_Update(&hashSessions[cryptoHandle - 1].hashAlg.sha3, src,
size);
keccak_Final(&hashSessions[cryptoHandle - 1].hashAlg.sha3, dest);
break;
}
status = hashSize;
}
end:
mach->cpu.regs[MOXIE_R0] = status;
}
/*
* bls_hmac_ripemd160_init
* $r0 -- hmac bls_hmac_ripemd160_t*
* $r1 -- key uint8_t*
* $r2 -- key_len size_t
* Output:
* int
*/
void moxie_bls_hmac_ripemd160_init(struct machine *mach) {
mach->cpu.exception = SIGBUS;
}
/*
* bls_hmac_sha256_init
* $r0 -- hmac bls_hmac_sha256_t*
* $r1 -- key uint8_t*
* $r2 -- key_len size_t
* Output:
* int
*/
void moxie_bls_hmac_sha256_init(struct machine *mach) {
uint32_t cryptoHandle;
uint8_t *key;
uint32_t keySize = mach->cpu.regs[MOXIE_R2];
uint32_t status = 0;
if (!moxie_var_read_crypto_handle(mach, mach->cpu.regs[MOXIE_R0],
&cryptoHandle)) {
printf("Error reading handle\n");
goto end;
}
key = (uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R1], keySize,
false);
if (key == NULL) {
printf("Invalid key\n");
goto end;
}
cryptoHandle = 0;
if (!check_hmac_handle_allocate(&cryptoHandle)) {
printf("Error allocating handle\n");
goto end;
}
hmacSessions[cryptoHandle - 1].algorithm = BLS_SHA256;
crypto_auth_hmacsha256_init(
&hmacSessions[cryptoHandle - 1].hashAlg.hmacsha256, key, keySize);
moxie_var_write_crypto_handle(mach, mach->cpu.regs[MOXIE_R0], cryptoHandle);
status = 1;
end:
mach->cpu.regs[MOXIE_R0] = status;
}
/*
* bls_hmac_sha512_init
* $r0 -- hmac bls_hmac_sha512_t*
* $r1 -- key uint8_t*
* $r2 -- key_len size_t
* Output:
* int
*/
void moxie_bls_hmac_sha512_init(struct machine *mach) {
uint32_t cryptoHandle;
uint8_t *key;
uint32_t keySize = mach->cpu.regs[MOXIE_R2];
uint32_t status = 0;
if (!moxie_var_read_crypto_handle(mach, mach->cpu.regs[MOXIE_R0],
&cryptoHandle)) {
printf("Error reading handle\n");
goto end;
}
key = (uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R1], keySize,
false);
if (key == NULL) {
printf("Invalid key\n");
goto end;
}
cryptoHandle = 0;
if (!check_hmac_handle_allocate(&cryptoHandle)) {
printf("Error allocating handle\n");
goto end;
}
hmacSessions[cryptoHandle - 1].algorithm = BLS_SHA512;
crypto_auth_hmacsha512_init(
&hmacSessions[cryptoHandle - 1].hashAlg.hmacsha512, key, keySize);
moxie_var_write_crypto_handle(mach, mach->cpu.regs[MOXIE_R0], cryptoHandle);
end:
mach->cpu.regs[MOXIE_R0] = status;
}
/*
* bls_hmac
* $r0 -- hmac bls_hmac_t*
* $r1 -- mode int
* $r2 -- in uint8_t*
* $r3 -- len size_t
* $r4 -- mac uint8_t*
* Output:
* int
*/
void moxie_bls_hmac(struct machine *mach) {
uint32_t cryptoHandle;
uint32_t mode = mach->cpu.regs[MOXIE_R1];
uint8_t *src;
uint32_t size = mach->cpu.regs[MOXIE_R3];
uint8_t *dest;
uint32_t status = 0;
uint32_t hashSize;
if (!moxie_var_read_crypto_handle(mach, mach->cpu.regs[MOXIE_R0],
&cryptoHandle)) {
printf("Error reading handle\n");
goto end;
}
if (!check_hmac_handle_use(cryptoHandle)) {
printf("Invalid hmac handle\n");
goto end;
}
switch (hmacSessions[cryptoHandle - 1].algorithm) {
case BLS_SHA256:
hashSize = 32;
break;
case BLS_SHA512:
hashSize = 64;
break;
default:
printf("Unsupported algorithm\n");
break;
}
src =
(uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R2], size, false);
if (src == NULL) {
printf("Invalid input buffer\n");
goto end;
}
dest = (uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R4], hashSize,
true);
if (dest == NULL) {
printf("Invalid output buffer\n");
goto end;
}
if ((mode & BLS_LAST) == 0) {
switch (hmacSessions[cryptoHandle - 1].algorithm) {
case BLS_SHA256:
crypto_auth_hmacsha256_update(
&hmacSessions[cryptoHandle - 1].hashAlg.hmacsha256, src, size);
break;
case BLS_SHA512:
crypto_auth_hmacsha512_update(
&hmacSessions[cryptoHandle - 1].hashAlg.hmacsha512, src, size);
break;
}
status = 1;
} else {
switch (hmacSessions[cryptoHandle - 1].algorithm) {
case BLS_SHA256:
crypto_auth_hmacsha256_update(
&hmacSessions[cryptoHandle - 1].hashAlg.hmacsha256, src, size);
crypto_auth_hmacsha256_final(
&hmacSessions[cryptoHandle - 1].hashAlg.hmacsha256, dest);
break;
case BLS_SHA512:
crypto_auth_hmacsha512_update(
&hmacSessions[cryptoHandle - 1].hashAlg.hmacsha512, src, size);
crypto_auth_hmacsha512_final(
&hmacSessions[cryptoHandle - 1].hashAlg.hmacsha512, dest);
break;
}
status = hashSize;
}
end:
mach->cpu.regs[MOXIE_R0] = status;
}
void pbkdf2_sha256(uint8_t *password, uint32_t passwordSize, uint8_t *salt,
uint32_t saltSize, uint32_t iterations, uint8_t *buf,
uint32_t len) {
crypto_auth_hmacsha256_state PShctx, hctx;
uint32_t i;
uint8_t ivec[4];
uint8_t U[32];
uint8_t T[32];
uint32_t j;
uint32_t k;
uint32_t clen;
crypto_auth_hmacsha256_init(&PShctx, password, passwordSize);
crypto_auth_hmacsha256_update(&PShctx, salt, saltSize);
for (i = 0; i * 32 < len; i++) {
uint32_t counter = i + 1;
ivec[0] = counter >> 24;
ivec[1] = counter >> 16;
ivec[2] = counter >> 8;
ivec[3] = counter;
memcpy(&hctx, &PShctx, sizeof(crypto_auth_hmacsha256_state));
crypto_auth_hmacsha256_update(&hctx, ivec, 4);
crypto_auth_hmacsha256_final(&hctx, U);
memcpy(T, U, 32);
/* LCOV_EXCL_START */
for (j = 2; j <= iterations; j++) {
crypto_auth_hmacsha256_init(&hctx, password, passwordSize);
crypto_auth_hmacsha256_update(&hctx, U, 32);
crypto_auth_hmacsha256_final(&hctx, U);
for (k = 0; k < 32; k++) {
T[k] ^= U[k];
}
}
/* LCOV_EXCL_STOP */
clen = len - i * 32;
if (clen > 32) {
clen = 32;
}
memcpy(&buf[i * 32], T, clen);
}
}
void pbkdf2_sha512(uint8_t *password, uint32_t passwordSize, uint8_t *salt,
uint32_t saltSize, uint32_t iterations, uint8_t *buf,
uint32_t len) {
crypto_auth_hmacsha512_state PShctx, hctx;
uint32_t i;
uint8_t ivec[4];
uint8_t U[64];
uint8_t T[64];
uint32_t j;
uint32_t k;
uint32_t clen;
crypto_auth_hmacsha512_init(&PShctx, password, passwordSize);
crypto_auth_hmacsha512_update(&PShctx, salt, saltSize);
for (i = 0; i * 64 < len; i++) {
uint32_t counter = i + 1;
ivec[0] = counter >> 24;
ivec[1] = counter >> 16;
ivec[2] = counter >> 8;
ivec[3] = counter;
memcpy(&hctx, &PShctx, sizeof(crypto_auth_hmacsha512_state));
crypto_auth_hmacsha512_update(&hctx, ivec, 4);
crypto_auth_hmacsha512_final(&hctx, U);
memcpy(T, U, 64);
/* LCOV_EXCL_START */
for (j = 2; j <= iterations; j++) {
crypto_auth_hmacsha512_init(&hctx, password, passwordSize);
crypto_auth_hmacsha512_update(&hctx, U, 64);
crypto_auth_hmacsha512_final(&hctx, U);
for (k = 0; k < 64; k++) {
T[k] ^= U[k];
}
}
/* LCOV_EXCL_STOP */
clen = len - i * 64;
if (clen > 64) {
clen = 64;
}
memcpy(&buf[i * 64], T, clen);
}
}
/*
* bls_pbkdf2
* $r0 -- hash bls_md_t
* $r1 -- password bls_a`rea_t*
* $r2 -- salt bls_area_t*
* $r3 -- iterations int
* $r4 -- out uint8_t*
* Output:
* int
*/
void moxie_bls_pbkdf2(struct machine *mach) {
uint32_t hash = mach->cpu.regs[MOXIE_R0];
bls_area_t passwordArea;
bls_area_t saltArea;
uint32_t iterations = mach->cpu.regs[MOXIE_R3];
uint8_t *dest;
uint32_t status = 0;
if ((hash != BLS_SHA256) && (hash != BLS_SHA512)) {
printf("Unsupported hash\n");
goto end;
}
if (!moxie_var_read_bls_area(mach, mach->cpu.regs[MOXIE_R1], &passwordArea,
false)) {
printf("Invalid password\n");
goto end;
}
if (!moxie_var_read_bls_area(mach, mach->cpu.regs[MOXIE_R2], &saltArea,
false)) {
printf("Invalid salt\n");
goto end;
}
dest = (uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R4], 64, true);
if (dest == NULL) {
printf("Invalid output buffer\n");
goto end;
}
if (saltArea.length < 4) {
printf("Invalid salt\n");
goto end;
}
if (hash == BLS_SHA256) {
pbkdf2_sha256(passwordArea.buffer, passwordArea.length, saltArea.buffer,
saltArea.length - 4, iterations, dest, 32);
} else {
pbkdf2_sha512(passwordArea.buffer, passwordArea.length, saltArea.buffer,
saltArea.length - 4, iterations, dest, 64);
}
status = 1;
end:
mach->cpu.regs[MOXIE_R0] = status;
}
/*
* bls_des_init_key
* $r0 -- rawkey uint8_t*
* $r1 -- key_len size_t
* $r2 -- key bls_des_key_t*
* Output:
* int
*/
void moxie_bls_des_init_key(struct machine *mach) {
mach->cpu.exception = SIGBUS;
}
void moxie_bls_des_iv_mixed(struct machine *mach, bool useIV) {
mach->cpu.exception = SIGBUS;
}
/*
* bls_des
* $r0 -- key bls_des_key_t*
* $r1 -- mode int
* $r2 -- in bls_area_t*
* $r3 -- out bls_area_t*
* Output:
* int
*/
void moxie_bls_des(struct machine *mach) {
moxie_bls_des_iv_mixed(mach, false);
}
/*
* bls_des_iv
* $r0 -- key bls_des_key_t*
* $r1 -- mode int
* $r2 -- iv bls_area_t*
* $r3 -- in bls_area_t*
* $r4 -- out bls_area_t*
* Output:
* int
*/
void moxie_bls_des_iv(struct machine *mach) {
moxie_bls_des_iv_mixed(mach, true);
}
/*
* bls_aes_init_key
* $r0 -- rawkey uint8_t*
* $r1 -- key_len size_t
* $r2 -- key bls_aes_key_t*
* Output:
* int
*/
void moxie_bls_aes_init_key(struct machine *mach) {
uint8_t *key = NULL;
uint32_t keySize = mach->cpu.regs[MOXIE_R1];
uint32_t cryptoHandle;
uint32_t status = 0;
if (!moxie_var_read_crypto_handle(mach, mach->cpu.regs[MOXIE_R2],
&cryptoHandle)) {
printf("Error reading handle\n");
goto end;
}
if ((keySize != 16) && (keySize != 32)) {
printf("Invalid key size\n");
goto end;
}
key = (uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R0], keySize,
false);
if (key == NULL) {
goto end;
}
if (!check_crypto_handle_allocate(symmetric_key_available,
MAX_SYMMETRIC_KEYS, &cryptoHandle)) {
printf("Invalid handle\n");
goto end;
}
memmove(symmetricKeys[cryptoHandle - 1].keyData, key, keySize);
symmetricKeys[cryptoHandle - 1].keySize = keySize;
moxie_var_write_crypto_handle(mach, mach->cpu.regs[MOXIE_R2], cryptoHandle);
status = 1;
end:
mach->cpu.regs[MOXIE_R0] = status;
}
void moxie_bls_aes_iv_mixed(struct machine *mach, bool useIV) {
uint32_t cryptoHandle;
uint32_t mode = mach->cpu.regs[MOXIE_R1];
bls_area_t src;
bls_area_t dest;
bool encrypt = false;
uint32_t status = 0;
AES128_ctx aes128_ctx;
AES256_ctx aes256_ctx;
if ((mode & BLS_MASK_CHAIN) != BLS_CHAIN_ECB) {
printf("Invalid chaining\n");
goto end;
}
if (!moxie_var_read_crypto_handle(mach, mach->cpu.regs[MOXIE_R0],
&cryptoHandle)) {
printf("Error reading private handle\n");
goto end;
}
if (!check_crypto_handle_use(symmetric_key_available, MAX_SYMMETRIC_KEYS,
cryptoHandle)) {
printf("Invalid handle\n");
goto end;
}
if (!moxie_var_read_bls_area(mach, mach->cpu.regs[MOXIE_R2], &src, false)) {
printf("Invalid source\n");
goto end;
}
if (!moxie_var_read_bls_area(mach, mach->cpu.regs[MOXIE_R3], &dest, true)) {
printf("Invalid destination\n");
goto end;
}
switch (mode & BLS_MASK_PAD) {
case BLS_PAD_NONE:
if ((src.length % 16) != 0) {
printf("Invalid length\n");
goto end;
}
break;
default:
printf("Invalid padding algorithm\n");
goto end;
}
switch (mode & BLS_MASK_SIGCRYPT) {
case BLS_ENCRYPT:
encrypt = true;
break;
case BLS_DECRYPT:
encrypt = false;
break;
default:
printf("Invalid operation\n");
goto end;
}
if ((mode & BLS_LAST) == 0) {
printf("Update not supported\n");
goto end;
}
if (symmetricKeys[cryptoHandle - 1].keySize == 16) {
AES128_init(&aes128_ctx, symmetricKeys[cryptoHandle - 1].keyData);
} else {
AES256_init(&aes256_ctx, symmetricKeys[cryptoHandle - 1].keyData);
}
if (encrypt) {
if (symmetricKeys[cryptoHandle - 1].keySize == 16) {
AES128_encrypt(&aes128_ctx, src.length / 16, dest.buffer,
src.buffer);
} else {
AES256_encrypt(&aes256_ctx, src.length / 16, dest.buffer,
src.buffer);
}
} else {
if (symmetricKeys[cryptoHandle - 1].keySize == 16) {
AES128_decrypt(&aes128_ctx, src.length / 16, dest.buffer,
src.buffer);
} else {
AES256_decrypt(&aes256_ctx, src.length / 16, dest.buffer,
src.buffer);
}
}
dest.length = src.length;
moxie_var_write_bls_area_length(mach, mach->cpu.regs[MOXIE_R3],
dest.length);
status = 1;
end:
printf("AES final status %d\n", status);
mach->cpu.regs[MOXIE_R0] = status;
}
/*
* bls_aes
* $r0 -- key bls_aes_key_t*
* $r1 -- mode int
* $r2 -- in bls_area_t*
* $r3 -- out bls_area_t*
* Output:
* int
*/
void moxie_bls_aes(struct machine *mach) {
moxie_bls_aes_iv_mixed(mach, false);
}
/*
* bls_aes_iv
* $r0 -- key bls_aes_key_t*
* $r1 -- mode int
* $r2 -- iv bls_area_t*
* $r3 -- in bls_area_t*
* $r4 -- out bls_area_t*
* Output:
* int
*/
void moxie_bls_aes_iv(struct machine *mach) {
mach->cpu.exception = SIGBUS;
}
/*
* bls_aes_iv_gcm
* $r0 -- key bls_aes_key_t*
* $r1 -- mode int
* $r2 -- in bls_area_t*
* $r3 -- iv bls_area_t*
* $r4 -- aadTag bls_area_t*
* $r5 -- out bls_area_t*
* Output:
* int
*/
void moxie_bls_aes_iv_gcm(struct machine *mach) {
mach->cpu.exception = SIGBUS;
}
/*
* bls_rsa_init_private_key
* $r0 -- keyData bls_rsa_keypair_data_t*
* $r1 -- key bls_rsa_abstract_private_key_t*
* Output:
* int
*/
void moxie_bls_rsa_init_private_key(struct machine *mach) {
mach->cpu.exception = SIGBUS;
}
/*
* bls_rsa_init_public_key
* $r0 -- keyData bls_rsa_keypair_data_t*
* $r1 -- key bls_rsa_abstract_public_key_t*
* Output:
* int
*/
void moxie_bls_rsa_init_public_key(struct machine *mach) {
moxie_bls_rsa_init_private_key(mach);
}
/*
* bls_rsa_init_private_key_crt
* $r0 -- crtParameters bls_rsa_crt_t*
* $r1 -- key bls_rsa_abstract_private_key_t*
* Output:
* int
*/
void moxie_bls_rsa_init_private_key_crt(struct machine *mach) {
// TODO : implement
mach->cpu.exception = SIGBUS;
}
/*
* bls_rsa_generate_keypair
* $r0 -- modulus_len int
* $r1 -- privateKey bls_rsa_abstract_private_key_t*
* $r2 -- publicKey bls_rsa_abstract_public_key_t*
* $r3 -- generatedKeypairInfo bls_rsa_keypair_data_t*
* Output:
* int
*/
void moxie_bls_rsa_generate_keypair(struct machine *mach) {
mach->cpu.exception = SIGBUS;
}
/*
* bls_rsa_get_public_key_data
* $r0 -- publicKey bls_rsa_abstract_public_key_t*
* $r1 -- keyInfo bls_rsa_keypair_data_t*
* Output:
* int
*/
void moxie_bls_rsa_get_public_key_data(struct machine *mach) {
mach->cpu.exception = SIGBUS;
}
/*
* bls_rsa
* $r0 -- key bls_rsa_abstract_public_key_t*
* $r1 -- mode int
* $r2 -- hashID bls_md_t
* $r3 -- hash bls_area_t*
* $r4 -- sig bls_area_t*
* Output:
* int
*/
void moxie_bls_rsa(struct machine *mach) {
mach->cpu.exception = SIGBUS;
}
/*
* bls_rsa_pub
* $r0 -- key bls_rsa_abstract_public_key_t*
* $r1 -- mode int
* $r2 -- hashID bls_md_t
* $r3 -- data bls_area_t*
* $r4 -- sig bls_area_t*
* Output:
* int
*/
void moxie_bls_rsa_pub(struct machine *mach) {
moxie_bls_rsa(mach);
}
/*
* bls_rsa_priv
* $r0 -- key bls_rsa_abstract_private_key_t*
* $r1 -- mode int
* $r2 -- hashID bls_md_t
* $r3 -- data bls_area_t*
* $r4 -- sig bls_area_t*
* Output:
* int
*/
void moxie_bls_rsa_priv(struct machine *mach) {
moxie_bls_rsa(mach);
}
/*
* bls_ecfp_get_domain
* $r0 -- curve bls_curve_t
* Output:
* bls_curve_domain_t*
*/
void moxie_bls_ecfp_get_domain(struct machine *mach) {
mach->cpu.exception = SIGBUS;
}
/*
* bls_ecfp_is_valid_point
* $r0 -- domain bls_curve_domain_t*
* $r1 -- point uint8_t*
* Output:
* int
*/
void moxie_bls_ecfp_is_valid_point(struct machine *mach) {
mach->cpu.exception = SIGBUS;
}
/*
* bls_ecfp_add_point
* $r0 -- domain bls_curve_domain_t*
* $r1 -- R uint8_t*
* $r2 -- P uint8_t*
* $r3 -- Q uint8_t*
* Output:
* int
*/
void moxie_bls_ecfp_add_point(struct machine *mach) {
mach->cpu.exception = SIGBUS;
}
/*
* bls_ecdsa_init_public_key
* $r0 -- curve bls_curve_t
* $r1 -- rawkey uint8_t*
* $r2 -- key_len size_t
* $r3 -- key bls_ecfp_public_key_t*
* Output:
* int
*/
void moxie_bls_ecdsa_init_public_key(struct machine *mach) {
uint32_t curve = mach->cpu.regs[MOXIE_R0];
uint32_t keySize = mach->cpu.regs[MOXIE_R2];
uint8_t *key;
uint32_t cryptoHandle;
uint32_t status = 0;
if (!moxie_var_read_crypto_handle(mach, mach->cpu.regs[MOXIE_R3],
&cryptoHandle)) {
printf("Error reading handle\n");
goto end;
}
if (!((keySize == 65) ||
((keySize == 0) && (mach->cpu.regs[MOXIE_R1] == 0)))) {
printf("Invalid public key size\n");
goto end;
}
switch (curve) {
case BLS_CURVE_256K1:
case BLS_CURVE_256R1:
break;
default:
printf("Unsupported curve\n");
goto end;
}
if (mach->cpu.regs[MOXIE_R1] != 0) {
key = (uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R1], keySize,
false);
if (key == NULL) {
goto end;
}
}
if (!check_crypto_handle_allocate(ecfp_public_key_available,
MAX_ECFP_PUBLIC_KEYS, &cryptoHandle)) {
printf("Invalid handle\n");
goto end;
}
platform_secure_memset0(&ecfp_public_keys[cryptoHandle - 1],
sizeof(cx_ecfp_public_key_t));
ecfp_public_keys[cryptoHandle - 1].curve = curve;
memmove(ecfp_public_keys[cryptoHandle - 1].W, key, keySize);
ecfp_public_keys[cryptoHandle - 1].W_len = keySize;
moxie_var_write_crypto_handle(mach, mach->cpu.regs[MOXIE_R3], cryptoHandle);
status = 1;
end:
mach->cpu.regs[MOXIE_R0] = status;
}
/*
* bls_ecdsa_init_private_key
* $r0 -- curve bls_curve_t
* $r1 -- rawkey uint8_t*
* $r2 -- key_len size_t
* $r3 -- key bls_ecfp_private_key_t*
* Output:
* int
*/
void moxie_bls_ecdsa_init_private_key(struct machine *mach) {
uint32_t curve = mach->cpu.regs[MOXIE_R0];
uint32_t keySize = mach->cpu.regs[MOXIE_R2];
uint8_t *key = NULL;
uint32_t cryptoHandle;
uint32_t status = 0;
if (!moxie_var_read_crypto_handle(mach, mach->cpu.regs[MOXIE_R3],
&cryptoHandle)) {
printf("Error reading handle\n");
goto end;
}
if (!((keySize == 32) ||
((keySize == 0) && (mach->cpu.regs[MOXIE_R1] == 0)))) {
printf("Invalid private key size\n");
goto end;
}
switch (curve) {
case BLS_CURVE_256K1:
case BLS_CURVE_256R1:
break;
default:
printf("Unsupported curve\n");
goto end;
}
if (mach->cpu.regs[MOXIE_R1] != 0) {
key = (uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R1], keySize,
false);
if (key == NULL) {
goto end;
}
}
if (!check_crypto_handle_allocate(ecfp_private_key_available,
MAX_ECFP_PRIVATE_KEYS, &cryptoHandle)) {
printf("Invalid handle\n");
goto end;
}
platform_secure_memset0(&ecfp_private_keys[cryptoHandle - 1],
sizeof(cx_ecfp_private_key_t));
ecfp_private_keys[cryptoHandle - 1].curve = curve;
memmove(ecfp_private_keys[cryptoHandle - 1].d, key, keySize);
ecfp_private_keys[cryptoHandle - 1].d_len = keySize;
moxie_var_write_crypto_handle(mach, mach->cpu.regs[MOXIE_R3], cryptoHandle);
status = 1;
end:
mach->cpu.regs[MOXIE_R0] = status;
}
/*
* bls_ecfp_generate_pair
* $r0 -- curve bls_curve_t
* $r1 -- public_key bls_ecfp_public_key_t*
* $r2 -- private_key bls_ecfp_private_key_t*
* $r3 -- d uint8_t*
* Output:
* int
*/
void moxie_bls_ecfp_generate_pair(struct machine *mach) {
uint32_t curve = mach->cpu.regs[MOXIE_R0];
uint32_t cryptoHandle_public;
uint32_t cryptoHandle_private;
uint32_t status = 0;
uint8_t *privateComponent = NULL;
bool reuse = false;
if (!moxie_var_read_crypto_handle(mach, mach->cpu.regs[MOXIE_R1],
&cryptoHandle_public)) {
printf("Error reading public handle\n");
goto end;
}
if (!moxie_var_read_crypto_handle(mach, mach->cpu.regs[MOXIE_R2],
&cryptoHandle_private)) {
printf("Error reading private handle\n");
goto end;
}
switch (curve) {
case BLS_CURVE_256K1:
case BLS_CURVE_256R1:
break;
default:
printf("Unsupported curve\n");
goto end;
}
if (mach->cpu.regs[MOXIE_R3] != 0) {
privateComponent =
(uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R3], 32, true);
if (privateComponent == NULL) {
goto end;
}
}
if ((cryptoHandle_private != 0) &&
(check_crypto_handle_use(ecfp_private_key_available,
MAX_ECFP_PRIVATE_KEYS,
cryptoHandle_private))) {
reuse = true;
} else {
if (!check_crypto_handle_allocate(ecfp_private_key_available,
MAX_ECFP_PRIVATE_KEYS,
&cryptoHandle_private)) {
printf("Invalid private handle\n");
goto end;
}
}
if (!check_crypto_handle_allocate(ecfp_public_key_available,
MAX_ECFP_PUBLIC_KEYS,
&cryptoHandle_public)) {
printf("Invalid public handle\n");
ecfp_private_key_available[cryptoHandle_private] = true;
goto end;
}
if (curve == BLS_CURVE_256K1) {
uint8_t tmp[32];
secp256k1_pubkey pubkey;
size_t length = 65;
if (!reuse ||
(ecfp_private_keys[cryptoHandle_private - 1].d_len == 0)) {
for (;;) {
platform_random(tmp, sizeof(tmp));
if (secp256k1_ec_seckey_verify(secp256k1Context, tmp) == 1) {
break;
}
}
memmove(ecfp_private_keys[cryptoHandle_private - 1].d, tmp, 32);
ecfp_private_keys[cryptoHandle_private - 1].d_len = 32;
ecfp_private_keys[cryptoHandle_private - 1].curve = curve;
} else {
memmove(tmp, ecfp_private_keys[cryptoHandle_private - 1].d, 32);
}
if (secp256k1_ec_pubkey_create(secp256k1Context, &pubkey, tmp) != 1) {
// TODO cleanup
printf("Error getting public key\n");
goto end;
}
secp256k1_ec_pubkey_serialize(
secp256k1Context, ecfp_public_keys[cryptoHandle_public - 1].W,
&length, &pubkey, SECP256K1_EC_UNCOMPRESSED);
ecfp_public_keys[cryptoHandle_public - 1].curve = curve;
ecfp_public_keys[cryptoHandle_public - 1].W_len = length;
} else {
if (!reuse ||
(ecfp_private_keys[cryptoHandle_private - 1].d_len == 0)) {
if (!uECC_make_key(&ecfp_public_keys[cryptoHandle_public - 1].W[1],
ecfp_private_keys[cryptoHandle_private - 1].d,
uECC_secp256r1())) {
// TODO cleanup
printf("Error generating key\n");
goto end;
}
ecfp_public_keys[cryptoHandle_public - 1].W[0] = 0x04;
ecfp_public_keys[cryptoHandle_public - 1].curve = curve;
ecfp_public_keys[cryptoHandle_public - 1].W_len = 65;
ecfp_private_keys[cryptoHandle_private - 1].d_len = 32;
ecfp_private_keys[cryptoHandle_private - 1].curve = curve;
} else {
if (!uECC_compute_public_key(
ecfp_private_keys[cryptoHandle_private - 1].d,
&ecfp_public_keys[cryptoHandle_public - 1].W[1],
uECC_secp256r1())) {
printf("Error generating public key\n");
goto end;
}
ecfp_public_keys[cryptoHandle_public - 1].W[0] = 0x04;
ecfp_public_keys[cryptoHandle_public - 1].curve = curve;
ecfp_public_keys[cryptoHandle_public - 1].W_len = 65;
}
}
if (privateComponent != NULL) {
memmove(privateComponent, ecfp_private_keys[cryptoHandle_private - 1].d,
32);
}
moxie_var_write_crypto_handle(mach, mach->cpu.regs[MOXIE_R1],
cryptoHandle_public);
moxie_var_write_crypto_handle(mach, mach->cpu.regs[MOXIE_R2],
cryptoHandle_private);
status = 1;
end:
mach->cpu.regs[MOXIE_R0] = status;
}
/*
* bls_ecfp_get_public_component
* $r0 -- public_key bls_ecfp_public_key_t*
* $r1 -- W uint8_t*
* Output:
* int
*/
void moxie_bls_ecfp_get_public_component(struct machine *mach) {
uint32_t cryptoHandle;
uint8_t *publicComponent;
uint32_t status = 0;
if (!moxie_var_read_crypto_handle(mach, mach->cpu.regs[MOXIE_R0],
&cryptoHandle)) {
printf("Error reading handle\n");
goto end;
}
if (!check_crypto_handle_use(ecfp_public_key_available,
MAX_ECFP_PUBLIC_KEYS, cryptoHandle)) {
printf("Invalid handle\n");
goto end;
}
publicComponent =
(uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R1], 65, false);
if (publicComponent == NULL) {
goto end;
}
memmove(publicComponent, ecfp_public_keys[cryptoHandle - 1].W, 65);
status = 1;
end:
mach->cpu.regs[MOXIE_R0] = status;
}
/*
* bls_ecdsa
* $r0 -- key bls_ecfp_private_key_t*
* $r1 -- mode int
* $r2 -- hashID bls_md_t
* $r3 -- hash uint8_t*
* $r4 -- hash_len size_t
* $r5 -- sig uint8_t*
* Output:
* int
*/
void moxie_bls_ecdsa(struct machine *mach) {
uint32_t cryptoHandle;
uint8_t *hash;
uint32_t mode = mach->cpu.regs[MOXIE_R1];
uint32_t hashId = mach->cpu.regs[MOXIE_R2];
uint32_t hashLength = mach->cpu.regs[MOXIE_R4];
uint32_t status = 0;
uint32_t signatureLength;
uint32_t signMode = (mode & BLS_MASK_SIGCRYPT);
uint8_t *signature;
if (!moxie_var_read_crypto_handle(mach, mach->cpu.regs[MOXIE_R0],
&cryptoHandle)) {
printf("Error reading handle\n");
goto end;
}
if (signMode == BLS_SIGN) {
if (!check_crypto_handle_use(ecfp_private_key_available,
MAX_ECFP_PRIVATE_KEYS, cryptoHandle)) {
printf("Invalid handle\n");
goto end;
}
} else if (signMode == BLS_VERIFY) {
if (!check_crypto_handle_use(ecfp_public_key_available,
MAX_ECFP_PUBLIC_KEYS, cryptoHandle)) {
printf("Invalid handle\n");
goto end;
}
} else {
goto end;
}
if (hashLength != 32) {
goto end;
}
hash = (uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R3], hashLength,
false);
if (hash == NULL) {
goto end;
}
if (signMode == BLS_VERIFY) {
signature =
(uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R5], 2, false);
if (signature == NULL) {
goto end;
}
if (signature[0] != 0x30) {
goto end;
}
signatureLength = signature[1] + 2;
signature = (uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R5],
signatureLength, false);
if (signature == NULL) {
goto end;
}
}
if (signMode == BLS_SIGN) {
if (ecfp_private_keys[cryptoHandle - 1].curve == BLS_CURVE_256K1) {
secp256k1_ecdsa_signature sig;
uint8_t der[100];
size_t signatureLength = sizeof(der);
int result = secp256k1_ecdsa_sign(
secp256k1Context, &sig, hash,
ecfp_private_keys[cryptoHandle - 1].d, NULL, NULL);
if (result == 0) {
printf("Signature failed\n");
goto end;
}
if (secp256k1_ecdsa_signature_serialize_der(
secp256k1Context, der, &signatureLength, &sig) == 0) {
printf("Signature serialization failed\n");
goto end;
}
signature = (uint8_t *)physaddr_check(
mach, mach->cpu.regs[MOXIE_R5], signatureLength, true);
if (signature != NULL) {
memmove(signature, der, signatureLength);
status = signatureLength;
}
} else {
uint8_t tmp[64];
uint8_t der[100];
SHA256_HashContext ctx = {
{&init_SHA256, &update_SHA256, &finish_SHA256, 64, 32, tmp}};
size_t signatureLength = sizeof(der);
if (!uECC_sign_deterministic(ecfp_private_keys[cryptoHandle - 1].d,
hash, 32, &ctx.uECC, tmp,
uECC_secp256r1())) {
printf("Signature failed\n");
goto end;
}
signatureLength = ecdsa_sig_to_der(tmp, der);
signature = (uint8_t *)physaddr_check(
mach, mach->cpu.regs[MOXIE_R5], signatureLength, true);
if (signature != NULL) {
memmove(signature, der, signatureLength);
status = signatureLength;
}
}
} else {
if (ecfp_public_keys[cryptoHandle - 1].curve == BLS_CURVE_256K1) {
secp256k1_ecdsa_signature sigInternal;
secp256k1_pubkey pubkey;
if (!secp256k1_ecdsa_signature_parse_der(secp256k1Context,
&sigInternal, signature,
signatureLength)) {
printf("Unserialize DER failed\n");
goto end;
}
if (secp256k1_ec_pubkey_parse(secp256k1Context, &pubkey,
ecfp_public_keys[cryptoHandle - 1].W,
65)) {
int ret;
ret = secp256k1_ecdsa_verify(secp256k1Context, &sigInternal,
hash, &pubkey);
if (ret == 1) {
status = 1;
}
}
} else {
uint8_t tmp[64];
if (!ecdsa_der_to_sig(signature, tmp)) {
printf("Unserialize DER failed\n");
goto end;
}
status = uECC_verify(ecfp_public_keys[cryptoHandle - 1].W + 1, hash,
32, tmp, uECC_secp256r1());
}
}
end:
mach->cpu.regs[MOXIE_R0] = status;
}
/*
* bls_ecdsa_sign
* $r0 -- key bls_ecfp_private_key_t*
* $r1 -- mode int
* $r2 -- hashID bls_md_t
* $r3 -- hash uint8_t*
* $r4 -- hash_len size_t
* $r5 -- sig uint8_t*
* Output:
* int
*/
void moxie_bls_ecdsa_sign(struct machine *mach) {
moxie_bls_ecdsa(mach);
}
/*
* bls_ecdsa_verify
* $r0 -- key bls_ecfp_public_key_t*
* $r1 -- mode int
* $r2 -- hashID bls_md_t
* $r3 -- hash uint8_t*
* $r4 -- hash_len size_t
* $r5 -- sig uint8_t*
* Output:
* int
*/
void moxie_bls_ecdsa_verify(struct machine *mach) {
moxie_bls_ecdsa(mach);
}
/*
* bls_schnorr
* $r0 -- key bls_ecfp_private_key_t*
* $r1 -- mode int
* $r2 -- hashID bls_md_t
* $r3 -- hash uint8_t*
* $r4 -- hash_len size_t
* $r5 -- sig uint8_t*
* Output:
* int
*/
void moxie_bls_schnorr(struct machine *mach) {
#ifdef HAS_SCHNORR
uint32_t cryptoHandle;
uint8_t *hash;
uint8_t *signature;
uint32_t mode = mach->cpu.regs[MOXIE_R1];
uint32_t hashId = mach->cpu.regs[MOXIE_R2];
uint32_t hashLength = mach->cpu.regs[MOXIE_R4];
uint32_t status = 0;
uint32_t signMode = (mode & BLS_MASK_SIGCRYPT);
if (!moxie_var_read_crypto_handle(mach, mach->cpu.regs[MOXIE_R0],
&cryptoHandle)) {
printf("Error reading handle\n");
goto end;
}
if (signMode == BLS_SIGN) {
if (!check_crypto_handle_use(ecfp_private_key_available,
MAX_ECFP_PRIVATE_KEYS, cryptoHandle)) {
printf("Invalid handle\n");
goto end;
}
if (ecfp_private_keys[cryptoHandle - 1].curve != BLS_CURVE_256K1) {
printf("Invalid curve\n");
goto end;
}
} else if (signMode == BLS_VERIFY) {
if (!check_crypto_handle_use(ecfp_public_key_available,
MAX_ECFP_PUBLIC_KEYS, cryptoHandle)) {
printf("Invalid handle\n");
goto end;
}
if (ecfp_public_keys[cryptoHandle - 1].curve != BLS_CURVE_256K1) {
printf("Invalid curve\n");
goto end;
}
} else {
printf("Invalid mode\n");
goto end;
}
if (hashLength != 32) {
printf("Invalid hash\n");
goto end;
}
hash = (uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R3], hashLength,
false);
if (hash == NULL) {
printf("Invalid hash buffer\n");
goto end;
}
signature =
(uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R5], 64, true);
if (signature == NULL) {
printf("Invalid signature buffer\n");
goto end;
}
if (signMode == BLS_SIGN) {
printf("Schnorr sign\n");
if (secp256k1_schnorr_sign(secp256k1Context, signature, hash,
ecfp_private_keys[cryptoHandle - 1].d, NULL,
NULL)) {
status = 64;
} else {
printf("Schnorr signature failed\n");
}
} else if (signMode == BLS_VERIFY) {
secp256k1_pubkey pubkey;
printf("Schnorr verify\n");
if (secp256k1_ec_pubkey_parse(secp256k1Context, &pubkey,
ecfp_public_keys[cryptoHandle - 1].W,
65)) {
if (secp256k1_schnorr_verify(secp256k1Context, signature, hash,
&pubkey)) {
status = 1;
} else {
printf("Schnorr signature validation failed\n");
}
} else {
printf("Invalid point\n");
}
}
end:
mach->cpu.regs[MOXIE_R0] = status;
#else
mach->cpu.regs[MOXIE_R0] = 0;
#endif
}
/*
* bls_schnorr_sign
* $r0 -- key bls_ecfp_private_key_t*
* $r1 -- mode int
* $r2 -- hashID bls_md_t
* $r3 -- hash uint8_t*
* $r4 -- hash_len size_t
* $r5 -- sig uint8_t*
* Output:
* int
*/
void moxie_bls_schnorr_sign(struct machine *mach) {
moxie_bls_schnorr(mach);
}
/*
* bls_schnorr_verify
* $r0 -- key bls_ecfp_public_key_t*
* $r1 -- mode int
* $r2 -- hashID bls_md_t
* $r3 -- hash uint8_t*
* $r4 -- hash_len size_t
* $r5 -- sig uint8_t*
* Output:
* int
*/
void moxie_bls_schnorr_verify(struct machine *mach) {
moxie_bls_schnorr(mach);
}
/*
* bls_ecdh
* $r0 -- key bls_ecfp_private_key_t*
* $r1 -- mode int
* $r2 -- public_point uint8_t*
* $r3 -- secret uint8_t*
* Output:
* int
*/
void moxie_bls_ecdh(struct machine *mach) {
uint32_t cryptoHandle;
uint32_t mode = mach->cpu.regs[MOXIE_R1];
uint8_t *publicPoint;
uint8_t *secret;
uint32_t status = 0;
uint32_t secretLength = 0;
switch (mode & BLS_MASK_ECDH) {
case BLS_ECDH_POINT:
secretLength = 65;
break;
case BLS_ECDH_X:
case BLS_ECDH_HASHED:
secretLength = 32;
break;
default:
printf("Invalid ECDH mode\n");
goto end;
}
if (!moxie_var_read_crypto_handle(mach, mach->cpu.regs[MOXIE_R0],
&cryptoHandle)) {
printf("Error reading handle\n");
goto end;
}
if (!check_crypto_handle_allocate(ecfp_private_key_available,
MAX_ECFP_PRIVATE_KEYS, &cryptoHandle)) {
printf("Invalid private handle\n");
goto end;
}
publicPoint =
(uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R2], 65, false);
if (publicPoint == NULL) {
goto end;
}
secret = (uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R3],
secretLength, true);
if (secret == NULL) {
goto end;
}
secp256k1_pubkey pubkey;
if (ecfp_private_keys[cryptoHandle - 1].curve == BLS_CURVE_256K1) {
if (!secp256k1_ec_pubkey_parse(secp256k1Context, &pubkey, publicPoint,
65)) {
printf("Invalid public point\n");
goto end;
}
}
if ((mode & BLS_MASK_ECDH) == BLS_ECDH_HASHED) {
if (ecfp_private_keys[cryptoHandle - 1].curve != BLS_CURVE_256K1) {
printf("Unsupported mode on this curve\n");
goto end;
}
if (!secp256k1_ecdh(secp256k1Context, secret, &pubkey,
ecfp_private_keys[cryptoHandle - 1].d)) {
printf("ECDH error\n");
goto end;
}
status = 32;
} else if ((mode & BLS_MASK_ECDH) == BLS_ECDH_POINT) {
if (ecfp_private_keys[cryptoHandle - 1].curve != BLS_CURVE_256K1) {
printf("Unsupported mode on this curve\n");
goto end;
} else {
#ifdef HAVE_SECP256K1_XY
if (!secp256k1_ecdh_xy(secp256k1Context, secret, &pubkey,
ecfp_private_keys[cryptoHandle - 1].d)) {
printf("ECDH error\n");
goto end;
}
#else
printf("Unsupported mode on this curve\n");
goto end;
#endif
}
status = 65;
} else if ((mode & BLS_MASK_ECDH) == BLS_ECDH_X) {
if (ecfp_private_keys[cryptoHandle - 1].curve == BLS_CURVE_256K1) {
printf("Unsupported mode on this curve\n");
goto end;
} else {
if (!uECC_shared_secret(publicPoint + 1,
ecfp_private_keys[cryptoHandle - 1].d,
secret, uECC_secp256r1())) {
printf("ECDH error\n");
goto end;
}
status = 32;
}
} else {
printf("Unsupported mode\n");
goto end;
}
end:
mach->cpu.regs[MOXIE_R0] = status;
}
/*
* bls_crc16
* $r0 -- buffer void*
* $r1 -- len size_t
* Output:
* unsigned short
*/
void moxie_bls_crc16(struct machine *mach) {
mach->cpu.exception = SIGBUS;
}
/*
* bls_crc16_update
* $r0 -- crc unsigned short
* $r1 -- buffer void*
* $r2 -- len size_t
* Output:
* unsigned short
*/
void moxie_bls_crc16_update(struct machine *mach) {
mach->cpu.exception = SIGBUS;
}
/*
* bls_math_addm
* $r0 -- r uint8_t*
* $r1 -- a uint8_t*
* $r2 -- b uint8_t*
* $r3 -- m uint8_t*
* $r4 -- len size_t
* Output:
* void
*/
void moxie_bls_math_addm(struct machine *mach) {
uint8_t *r;
uint8_t *a;
uint8_t *b;
uint8_t *m;
uint32_t len = mach->cpu.regs[MOXIE_R4];
uint32_t status = 0;
if (len != 32) {
printf("Unsupported length\n");
goto end;
}
r = (uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R0], len, false);
if (r == NULL) {
goto end;
}
a = (uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R1], len, false);
if (a == NULL) {
goto end;
}
b = (uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R2], len, false);
if (r == NULL) {
goto end;
}
m = (uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R3], len, false);
if (m == NULL) {
goto end;
}
if (memcmp(m, SECP256K1_N, 32) != 0) {
printf("Unsupported domain\n");
goto end;
}
if (!secp256k1_ec_privkey_tweak_add(secp256k1Context, a, b)) {
printf("Error secp256k1_ec_privkey_tweak_add\n");
goto end;
}
memmove(r, a, len);
status = len;
end:
mach->cpu.regs[MOXIE_R0] = status;
}
/*
* bls_math_cmp
* $r0 -- a uint8_t*
* $r1 -- b uint8_t*
* $r2 -- len size_t
* Output:
* int
*/
void moxie_bls_math_cmp(struct machine *mach) {
mach->cpu.exception = SIGBUS;
}
/*
* bls_math_is_zero
* $r0 -- a uint8_t*
* $r1 -- len size_t
* Output:
* int
*/
void moxie_bls_math_is_zero(struct machine *mach) {
mach->cpu.exception = SIGBUS;
}
/*
* bls_math_modm
* $r0 -- v uint8_t*
* $r1 -- len_v size_t
* $r2 -- m uint8_t*
* $r3 -- len_m size_t
* Output:
* void
*/
void moxie_bls_math_modm(struct machine *mach) {
mach->cpu.exception = SIGBUS;
}
/*
* bls_wallet_derive
* $r0 -- details uint8_t
* $r1 -- path uint32_t*
* $r2 -- pathLength size_t
* $r3 -- chainCode uint8_t*
* $r4 -- privateKey bls_ecfp_private_key_t*
* $r5 -- publicKey bls_ecfp_public_key_t*
* Output:
* int
*/
void moxie_bls_wallet_derive(struct machine *mach) {
mach->cpu.exception = SIGBUS;
}
/*
* bls_wallet_get_address
* $r0 -- publicKey bls_ecfp_public_key_t*
* $r1 -- address char*
* $r2 -- addressLength size_t
* $r3 -- compressed uint8_t
* Output:
* int
*/
void moxie_bls_wallet_get_address(struct machine *mach) {
mach->cpu.exception = SIGBUS;
}
/*
* bls_bip32_derive_secp256k1_private
* $r0 -- privateKey uint8_t*
* $r1 -- chainCode uint8_t*
* $r2 -- index uint32_t
* Output:
* int
*/
void moxie_bls_bip32_derive_secp256k1_private(struct machine *mach) {
uint32_t status = 0;
uint8_t *privateKey;
uint8_t *chainCode;
uint32_t index = mach->cpu.regs[MOXIE_R2];
uint8_t tmp[64];
crypto_auth_hmacsha512_state hmac;
privateKey =
(uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R0], 32, true);
if ((privateKey == NULL) ||
(secp256k1_ec_seckey_verify(secp256k1Context, privateKey) != 1)) {
goto end;
}
chainCode =
(uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R1], 32, true);
if (chainCode == NULL) {
goto end;
}
if ((index & 0x80000000) != 0) {
tmp[0] = 0;
memmove(tmp + 1, privateKey, 32);
} else {
secp256k1_pubkey pubkey;
size_t length = 33;
if ((secp256k1_ec_pubkey_create(secp256k1Context, &pubkey,
privateKey) != 1) ||
(secp256k1_ec_pubkey_serialize(secp256k1Context, tmp, &length,
&pubkey,
SECP256K1_EC_COMPRESSED) != 1)) {
goto end;
}
}
tmp[33] = ((index >> 24) & 0xff);
tmp[34] = ((index >> 16) & 0xff);
tmp[35] = ((index >> 8) & 0xff);
tmp[36] = (index & 0xff);
crypto_auth_hmacsha512_init(&hmac, chainCode, 32);
crypto_auth_hmacsha512_update(&hmac, tmp, 37);
crypto_auth_hmacsha512_final(&hmac, tmp);
if (secp256k1_ec_privkey_tweak_add(secp256k1Context, privateKey, tmp) !=
1) {
goto end;
}
memmove(chainCode, tmp + 32, 32);
status = 1;
end:
platform_secure_memset0(tmp, sizeof(tmp));
mach->cpu.regs[MOXIE_R0] = status;
}
/*
* bls_bip32_derive_secp256k1_public
* $r0 -- publicKey uint8_t*
* $r1 -- chainCode uint8_t*
* $r2 -- index uint32_t
* Output:
* int
*/
void moxie_bls_bip32_derive_secp256k1_public(struct machine *mach) {
uint32_t status = 0;
uint8_t *publicKey;
uint8_t *chainCode;
uint32_t index = mach->cpu.regs[MOXIE_R2];
uint8_t tmp[64];
crypto_auth_hmacsha512_state hmac;
secp256k1_pubkey pubkey;
size_t length = 33;
publicKey =
(uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R0], 33, true);
if ((publicKey == NULL) ||
(secp256k1_ec_pubkey_parse(secp256k1Context, &pubkey, publicKey, 33) !=
1)) {
goto end;
}
chainCode =
(uint8_t *)physaddr_check(mach, mach->cpu.regs[MOXIE_R1], 32, true);
if (chainCode == NULL) {
goto end;
}
if ((index & 0x80000000) != 0) {
goto end;
} else {
memmove(tmp, publicKey, 33);
}
tmp[33] = ((index >> 24) & 0xff);
tmp[34] = ((index >> 16) & 0xff);
tmp[35] = ((index >> 8) & 0xff);
tmp[36] = (index & 0xff);
crypto_auth_hmacsha512_init(&hmac, chainCode, 32);
crypto_auth_hmacsha512_update(&hmac, tmp, 37);
crypto_auth_hmacsha512_final(&hmac, tmp);
if ((secp256k1_ec_pubkey_tweak_add(secp256k1Context, &pubkey, tmp) != 1) ||
(secp256k1_ec_pubkey_serialize(secp256k1Context, publicKey, &length,
&pubkey,
SECP256K1_EC_COMPRESSED) != 1)) {
goto end;
}
memmove(chainCode, tmp + 32, 32);
status = 1;
end:
platform_secure_memset0(tmp, sizeof(tmp));
mach->cpu.regs[MOXIE_R0] = status;
}
| 28.760629 | 81 | 0.581965 |
49cbd47816a334123f926f89c3c7971580620ec8 | 7,120 | c | C | src/pool/srv_metrics.c | rogue-developer/daos | 8f07d5540f0e47c797d62a1d91d5fce8988df4a5 | [
"BSD-2-Clause-Patent"
] | 2 | 2021-07-14T12:21:50.000Z | 2021-07-14T12:21:52.000Z | src/pool/srv_metrics.c | rogue-developer/daos | 8f07d5540f0e47c797d62a1d91d5fce8988df4a5 | [
"BSD-2-Clause-Patent"
] | null | null | null | src/pool/srv_metrics.c | rogue-developer/daos | 8f07d5540f0e47c797d62a1d91d5fce8988df4a5 | [
"BSD-2-Clause-Patent"
] | 1 | 2021-11-03T05:00:42.000Z | 2021-11-03T05:00:42.000Z | /**
* (C) Copyright 2021 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
#define D_LOGFAC DD_FAC(pool)
#include "srv_internal.h"
#include <abt.h>
#include <gurt/telemetry_producer.h>
/*
* Parent directory in metrics tree for all the per-pool metric directories
*/
#define POOL_METRICS_DIR_FMT "pool/current/%s"
/*
* Size in bytes of each per-pool metric directory.
*/
#define POOL_METRICS_DIR_BYTES (8 * 1024)
/**
* Global pool metrics
*/
struct pool_metrics ds_global_pool_metrics;
/**
* Per-pool metrics
*/
static d_list_t per_pool_metrics;
static ABT_mutex per_pool_lock;
struct per_pool_entry {
struct ds_pool_metrics metrics;
d_list_t link;
};
/**
* Initializes the pool metrics
*/
int
ds_pool_metrics_init(void)
{
int rc;
memset(&ds_global_pool_metrics, 0, sizeof(ds_global_pool_metrics));
D_INIT_LIST_HEAD(&per_pool_metrics);
rc = ABT_mutex_create(&per_pool_lock);
if (rc != 0) {
D_ERROR("Failed to create ABT mutex, err code=%d\n", rc);
return -DER_UNKNOWN;
}
rc = d_tm_add_metric(&ds_global_pool_metrics.open_hdl_gauge, D_TM_GAUGE,
"Number of open pool handles", "",
"pool/ops/open/active");
if (rc != 0)
D_ERROR("Couldn't add open handle gauge: "DF_RC"\n", DP_RC(rc));
D_DEBUG(DB_TRACE, "Initialized pool metrics\n");
return rc;
}
static void
per_pool_metrics_lock(void)
{
int rc = ABT_mutex_lock(per_pool_lock);
if (unlikely(rc != 0))
D_ERROR("Failed to lock per-pool metrics, err code=%d\n", rc);
}
static void
per_pool_metrics_unlock(void)
{
int rc = ABT_mutex_unlock(per_pool_lock);
if (unlikely(rc != 0))
D_ERROR("Failed to unlock per-pool metrics, err code=%d\n",
rc);
}
static void
free_per_pool_metrics(struct per_pool_entry *entry)
{
int rc;
if (entry == NULL)
return;
d_list_del(&entry->link);
rc = ABT_mutex_free(&entry->metrics.pm_lock);
if (rc != 0)
D_ERROR(DF_UUID ": Failed to free ABT mutex, err code=%d\n",
entry->metrics.pm_pool_uuid, rc);
D_FREE(entry);
}
static void
close_pool_metrics_dir(const uuid_t pool_uuid)
{
char path[D_TM_MAX_NAME_LEN] = {0};
int rc;
rc = ds_pool_metrics_get_path(pool_uuid, path, sizeof(path));
if (rc != 0) {
D_ERROR(DF_UUID ": unable to get pool metrics path, "DF_RC"\n",
DP_UUID(pool_uuid), DP_RC(rc));
return;
}
rc = d_tm_del_ephemeral_dir(path);
if (rc != 0) {
D_ERROR(DF_UUID ": unable to remove metrics dir for pool, "
DF_RC "\n", DP_UUID(pool_uuid), DP_RC(rc));
return;
}
}
/**
* Finalizes the pool metrics
*/
int
ds_pool_metrics_fini(void)
{
struct per_pool_entry *cur = NULL;
struct per_pool_entry *next = NULL;
uuid_t uuid;
int rc;
per_pool_metrics_lock();
d_list_for_each_entry_safe(cur, next, &per_pool_metrics, link) {
uuid_copy(uuid, cur->metrics.pm_pool_uuid);
free_per_pool_metrics(cur);
close_pool_metrics_dir(uuid);
}
per_pool_metrics_unlock();
D_DEBUG(DB_TRACE, "Finalized pool metrics\n");
rc = ABT_mutex_free(&per_pool_lock);
if (rc != 0) {
D_ERROR("Failed to free per-pool metrics mutex, err code=%d\n",
rc);
return -DER_UNKNOWN;
}
return 0;
}
/**
* Create the metrics path for a specific pool UUID.
*
* \param[in] pool_uuid UUID of the pool
* \param[out] path Path to the pool metrics
* \param[in] path_len Length of path array
*
* \return 0 Success
* -DER_INVAL Invalid inputs
*/
int
ds_pool_metrics_get_path(const uuid_t pool_uuid, char *path, size_t path_len)
{
char uuid_str[DAOS_UUID_STR_SIZE];
if (!daos_uuid_valid(pool_uuid)) {
D_ERROR(DF_UUID ": invalid uuid\n", DP_UUID(pool_uuid));
return -DER_INVAL;
}
uuid_unparse(pool_uuid, uuid_str);
snprintf(path, path_len, POOL_METRICS_DIR_FMT, uuid_str);
path[path_len - 1] = '\0';
return 0;
}
static int
new_per_pool_metrics(const uuid_t pool_uuid, const char *path)
{
struct per_pool_entry *entry;
int rc;
D_ALLOC_PTR(entry);
if (entry == NULL) {
D_ERROR(DF_UUID ": failed to allocate metrics struct\n",
DP_UUID(pool_uuid));
return -DER_NOMEM;
}
rc = ABT_mutex_create(&entry->metrics.pm_lock);
if (unlikely(rc != 0)) {
D_ERROR(DF_UUID ": failed to create metrics mutex, "
"err code = %d\n", DP_UUID(pool_uuid), rc);
D_FREE(entry);
return -DER_UNKNOWN;
}
uuid_copy(entry->metrics.pm_pool_uuid, pool_uuid);
/* Init all of the per-pool metrics */
rc = d_tm_add_metric(&entry->metrics.pm_started_timestamp,
D_TM_TIMESTAMP,
"Last time the pool started", NULL,
"%s/started_at", path);
if (rc != 0) /* Probably a bad sign, but not fatal */
D_ERROR(DF_UUID ": failed to add started_timestamp metric, "
DF_RC "\n", DP_UUID(pool_uuid), DP_RC(rc));
per_pool_metrics_lock();
d_list_add(&entry->link, &per_pool_metrics);
per_pool_metrics_unlock();
return 0;
}
/**
* Add metrics for a specific pool UUID.
*
* \param[in] pool_uuid Pool UUID
*/
void
ds_pool_metrics_start(const uuid_t pool_uuid)
{
struct ds_pool_metrics *metrics;
char path[D_TM_MAX_NAME_LEN] = {0};
int rc;
metrics = ds_pool_metrics_get(pool_uuid);
if (metrics != NULL) /* already exists - nothing to do */
return;
rc = ds_pool_metrics_get_path(pool_uuid, path, sizeof(path));
if (rc != 0) {
D_ERROR(DF_UUID ": unable to get pool metrics path, "DF_RC"\n",
DP_UUID(pool_uuid), DP_RC(rc));
return;
}
rc = d_tm_add_ephemeral_dir(NULL, POOL_METRICS_DIR_BYTES, path);
if (rc != 0) {
D_ERROR(DF_UUID ": unable to create metrics dir for pool, "
DF_RC "\n", DP_UUID(pool_uuid), DP_RC(rc));
return;
}
rc = new_per_pool_metrics(pool_uuid, path);
if (rc != 0) {
D_ERROR(DF_UUID ": unable to start metrics for pool, "
DF_RC "\n", DP_UUID(pool_uuid), DP_RC(rc));
rc = d_tm_del_ephemeral_dir(path);
if (rc != 0)
D_ERROR(DF_UUID ": unable to clean up metrics dir for "
"pool, "DF_RC "\n", DP_UUID(pool_uuid),
DP_RC(rc));
return;
}
D_INFO(DF_UUID ": created metrics for pool\n", DP_UUID(pool_uuid));
}
static struct per_pool_entry *
get_per_pool_entry(const uuid_t pool_uuid)
{
struct per_pool_entry *cur = NULL;
d_list_for_each_entry(cur, &per_pool_metrics, link) {
if (uuid_compare(pool_uuid, cur->metrics.pm_pool_uuid) == 0)
return cur;
}
return NULL;
}
/**
* Destroy metrics for a specific pool UUID.
*
* \param[in] pool_uuid Pool UUID
*/
void
ds_pool_metrics_stop(const uuid_t pool_uuid)
{
struct per_pool_entry *entry;
if (!daos_uuid_valid(pool_uuid)) {
D_ERROR(DF_UUID ": invalid uuid\n", DP_UUID(pool_uuid));
return;
}
per_pool_metrics_lock();
entry = get_per_pool_entry(pool_uuid);
free_per_pool_metrics(entry);
per_pool_metrics_unlock();
close_pool_metrics_dir(pool_uuid);
D_INFO(DF_UUID ": destroyed metrics for pool\n", DP_UUID(pool_uuid));
}
/**
* Get metrics for a specific active pool.
*
* \param[in] pool_uuid Pool UUID
*
* \return Pool's metrics structure, or NULL if not found
*/
struct ds_pool_metrics *
ds_pool_metrics_get(const uuid_t pool_uuid)
{
struct per_pool_entry *result;
per_pool_metrics_lock();
result = get_per_pool_entry(pool_uuid);
per_pool_metrics_unlock();
if (result == NULL)
return NULL;
return &result->metrics;
}
| 22.111801 | 77 | 0.704354 |
9929c615b869fe0c1851e9723080959ce0c2e163 | 6,394 | c | C | src/functions/activation/activation_cpu.c | mathxyz/math21 | bdca629dff4e1ecebfb8588082079755d5f262d6 | [
"Apache-2.0"
] | null | null | null | src/functions/activation/activation_cpu.c | mathxyz/math21 | bdca629dff4e1ecebfb8588082079755d5f262d6 | [
"Apache-2.0"
] | null | null | null | src/functions/activation/activation_cpu.c | mathxyz/math21 | bdca629dff4e1ecebfb8588082079755d5f262d6 | [
"Apache-2.0"
] | null | null | null | /* Copyright 2015 The math21 Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "inner_c.h"
#include "activation.h"
#include "activation_cpu.h"
static inline float stair_activate(float x)
{
int n = floor(x);
if (n%2 == 0) return floor(x/2.);
else return (x - n) + floor(x/2.);
}
static inline float hardtan_activate(float x)
{
if (x < -1) return -1;
if (x > 1) return 1;
return x;
}
static inline float linear_activate(float x){return x;}
static inline float logistic_activate(float x){return 1./(1. + exp(-x));}
static inline float loggy_activate(float x){return 2./(1. + exp(-x)) - 1;}
static inline float relu_activate(float x){return x*(x>0);}
static inline float elu_activate(float x){return (x >= 0)*x + (x < 0)*(exp(x)-1);}
static inline float selu_activate(float x){return (x >= 0)*1.0507*x + (x < 0)*1.0507*1.6732*(exp(x)-1);}
static inline float relie_activate(float x){return (x>0) ? x : .01*x;}
static inline float ramp_activate(float x){return x*(x>0)+.1*x;}
// todo: add slope alpha.
static inline float leaky_relu_activate(float x){return (x>0) ? x : .1*x;}
static inline float tanh_activate(float x){return (exp(2*x)-1)/(exp(2*x)+1);}
static inline float plse_activate(float x)
{
if(x < -4) return .01 * (x + 4);
if(x > 4) return .01 * (x - 4) + 1;
return .125*x + .5;
}
static inline float lhtan_activate(float x)
{
if(x < 0) return .001*x;
if(x > 1) return .001*(x-1) + 1;
return x;
}
static inline float lhtan_gradient(float x)
{
if(x > 0 && x < 1) return 1;
return .001;
}
static inline float hardtan_gradient(float x)
{
if (x > -1 && x < 1) return 1;
return 0;
}
static inline float linear_gradient(float y){return 1;}
static inline float logistic_gradient(float y){return (1-y)*y;}
static inline float loggy_gradient(float x)
{
float y = (x+1.)/2.;
return 2*(1-y)*y;
}
static inline float stair_gradient(float x)
{
if (floor(x) == x) return 0;
return 1;
}
static inline float relu_gradient(float x){return (x>0);}
static inline float elu_gradient(float x){return (x >= 0) + (x < 0)*(x + 1);}
static inline float selu_gradient(float x){return (x >= 0)*1.0507 + (x < 0)*(x + 1.0507*1.6732);}
static inline float relie_gradient(float x){return (x>0) ? 1 : .01;}
static inline float ramp_gradient(float x){return (x>0)+.1;}
static inline float leaky_gradient(float x){return (x>0) ? 1 : .1;}
static inline float tanh_gradient(float x){return 1-x*x;}
static inline float plse_gradient(float x){return (x < 0 || x > 1) ? .01 : .125;}
float math21_function_activation_value_cpu(float x, MATH21_FUNCTION_ACTIVATION_TYPE a)
{
switch(a){
case MATH21_FUNCTION_ACTIVATION_TYPE_LINEAR:
return linear_activate(x);
case MATH21_FUNCTION_ACTIVATION_TYPE_LOGISTIC:
return logistic_activate(x);
case MATH21_FUNCTION_ACTIVATION_TYPE_LOGGY:
return loggy_activate(x);
case MATH21_FUNCTION_ACTIVATION_TYPE_RELU:
return relu_activate(x);
case MATH21_FUNCTION_ACTIVATION_TYPE_ELU:
return elu_activate(x);
case MATH21_FUNCTION_ACTIVATION_TYPE_SELU:
return selu_activate(x);
case MATH21_FUNCTION_ACTIVATION_TYPE_RELIE:
return relie_activate(x);
case MATH21_FUNCTION_ACTIVATION_TYPE_RAMP:
return ramp_activate(x);
case MATH21_FUNCTION_ACTIVATION_TYPE_LEAKY:
return leaky_relu_activate(x);
case MATH21_FUNCTION_ACTIVATION_TYPE_TANH:
return tanh_activate(x);
case MATH21_FUNCTION_ACTIVATION_TYPE_PLSE:
return plse_activate(x);
case MATH21_FUNCTION_ACTIVATION_TYPE_STAIR:
return stair_activate(x);
case MATH21_FUNCTION_ACTIVATION_TYPE_HARDTAN:
return hardtan_activate(x);
case MATH21_FUNCTION_ACTIVATION_TYPE_LHTAN:
return lhtan_activate(x);
}
return 0;
}
// Y = h(X)
void math21_function_activation_vector_cpu(float *x, int n, MATH21_FUNCTION_ACTIVATION_TYPE a)
{
int i;
for(i = 0; i < n; ++i){
x[i] = math21_function_activation_value_cpu(x[i], a);
}
}
float math21_function_activation_gradient_cpu(float y, MATH21_FUNCTION_ACTIVATION_TYPE a)
{
switch(a){
case MATH21_FUNCTION_ACTIVATION_TYPE_LINEAR:
return linear_gradient(y);
case MATH21_FUNCTION_ACTIVATION_TYPE_LOGISTIC:
return logistic_gradient(y);
case MATH21_FUNCTION_ACTIVATION_TYPE_LOGGY:
return loggy_gradient(y);
case MATH21_FUNCTION_ACTIVATION_TYPE_RELU:
return relu_gradient(y);
case MATH21_FUNCTION_ACTIVATION_TYPE_ELU:
return elu_gradient(y);
case MATH21_FUNCTION_ACTIVATION_TYPE_SELU:
return selu_gradient(y);
case MATH21_FUNCTION_ACTIVATION_TYPE_RELIE:
return relie_gradient(y);
case MATH21_FUNCTION_ACTIVATION_TYPE_RAMP:
return ramp_gradient(y);
case MATH21_FUNCTION_ACTIVATION_TYPE_LEAKY:
return leaky_gradient(y);
case MATH21_FUNCTION_ACTIVATION_TYPE_TANH:
return tanh_gradient(y);
case MATH21_FUNCTION_ACTIVATION_TYPE_PLSE:
return plse_gradient(y);
case MATH21_FUNCTION_ACTIVATION_TYPE_STAIR:
return stair_gradient(y);
case MATH21_FUNCTION_ACTIVATION_TYPE_HARDTAN:
return hardtan_gradient(y);
case MATH21_FUNCTION_ACTIVATION_TYPE_LHTAN:
return lhtan_gradient(y);
}
return 0;
}
// dL/dx = dL/dy *.ele f.d(x)
void math21_function_activation_gradient_vector_cpu(const float *y, int n, MATH21_FUNCTION_ACTIVATION_TYPE a, float *dy)
{
int i;
for(i = 0; i < n; ++i){
dy[i] *= math21_function_activation_gradient_cpu(y[i], a);
}
}
| 36.537143 | 120 | 0.673444 |
85b31f452c5531d6ddcd366be46d9c6567096f4f | 255 | h | C | TableViewControllerDemo/TestVC/FirstViewController.h | kuroky/UITableViewDemo | fa1645ab59c89d0b8ec9f852462c7fbea01215b5 | [
"MIT"
] | null | null | null | TableViewControllerDemo/TestVC/FirstViewController.h | kuroky/UITableViewDemo | fa1645ab59c89d0b8ec9f852462c7fbea01215b5 | [
"MIT"
] | null | null | null | TableViewControllerDemo/TestVC/FirstViewController.h | kuroky/UITableViewDemo | fa1645ab59c89d0b8ec9f852462c7fbea01215b5 | [
"MIT"
] | null | null | null | //
// FirstViewController.h
// TableViewControllerDemo
//
// Created by kuroky on 2017/7/19.
// Copyright © 2017年 kuroky. All rights reserved.
//
#import "MXBaseTableViewController.h"
@interface FirstViewController : MXBaseTableViewController
@end
| 18.214286 | 58 | 0.752941 |
c4786f590683f1873e2d1e37e87bd5e83a14b862 | 924 | h | C | Comphi/src/Comphi/Platform/Windows/Window.h | mattateusb7/ComphyEngine | d73c374fc9ded1e0be638d69c10f3f6380e6a333 | [
"MIT"
] | null | null | null | Comphi/src/Comphi/Platform/Windows/Window.h | mattateusb7/ComphyEngine | d73c374fc9ded1e0be638d69c10f3f6380e6a333 | [
"MIT"
] | null | null | null | Comphi/src/Comphi/Platform/Windows/Window.h | mattateusb7/ComphyEngine | d73c374fc9ded1e0be638d69c10f3f6380e6a333 | [
"MIT"
] | null | null | null | #pragma once
#include "../IWindow.h"
#include "Comphi/Renderer/IGraphicsContext.h"
#include <GLFW/glfw3.h>
namespace Comphi::Windows {
class Window : public IWindow
{
public:
Window(const WindowProperties& props);
virtual ~Window();
void OnUpdate() override;
void OnBeginUpdate() override;
void OnWindowResized(uint x, uint y) override;
inline uint GetWidth() const override { return m_Data.Width; };
inline uint GetHeight() const override { return m_Data.Height; };
inline bool IsVSync() const override { return m_Data.VSync; };
void SetVSync(bool enabled) override;
void SetEventCallback(const EventCallback& callback) override;
inline void* GetNativeWindow() const override { return m_Window; };
private:
virtual void Init(const WindowProperties& props);
virtual void Shutdown();
private:
GLFWwindow* m_Window;
IGraphicsContext* m_GraphicsContext;
WindowProperties m_Data;
};
} | 27.176471 | 69 | 0.744589 |
c49124e835afd6e2c90a6cf34ca349e775fd6cf7 | 555 | c | C | userland/tests/test/main.c | somerandomdev49/oneOS | e37bc4b5c7ec2573bd9022ecaa2c12a58a46869f | [
"BSD-2-Clause"
] | null | null | null | userland/tests/test/main.c | somerandomdev49/oneOS | e37bc4b5c7ec2573bd9022ecaa2c12a58a46869f | [
"BSD-2-Clause"
] | null | null | null | userland/tests/test/main.c | somerandomdev49/oneOS | e37bc4b5c7ec2573bd9022ecaa2c12a58a46869f | [
"BSD-2-Clause"
] | null | null | null | #include <signal.h>
#include <unistd.h>
int acceptsig(int signo)
{
write(1, "oneOS\n", 6);
return 2;
}
int main()
{
sigaction(3, acceptsig);
raise(3);
char buf[256];
char* arg[] = {
"b",
"a",
"e",
};
arg[2] = (char*)0;
int sock_fd = socket(PF_LOCAL, 0, 0);
bind(sock_fd, "ke4.sock", 8);
int res = fork();
if (res == 0) {
execve("/bin/echo", arg, 0);
return -1;
}
while (1) {
read(sock_fd, buf, 4);
write(1, buf, 4);
}
return 0;
} | 15 | 41 | 0.454054 |
b1b839a921ab9f6fb877833ef4abed8824adc9be | 721 | h | C | src/MusicPlayer.h | Osmose/moseamp | 8357daf2c93bc903c8041cc82bf3567e8d085a60 | [
"MIT"
] | 6 | 2017-04-19T19:06:03.000Z | 2022-01-11T14:44:14.000Z | src/MusicPlayer.h | Osmose/moseamp | 8357daf2c93bc903c8041cc82bf3567e8d085a60 | [
"MIT"
] | 3 | 2015-07-17T21:17:23.000Z | 2021-01-19T17:44:44.000Z | src/MusicPlayer.h | Osmose/moseamp | 8357daf2c93bc903c8041cc82bf3567e8d085a60 | [
"MIT"
] | null | null | null | #include <napi.h>
#include "../musicplayer/plugins/plugins.h"
using musix::ChipPlayer;
using musix::ChipPlugin;
typedef struct musix::ChipPlayer ChipPlayer;
class MusicPlayer : public Napi::ObjectWrap<MusicPlayer> {
public:
static Napi::Object Init(Napi::Env env, Napi::Object exports);
MusicPlayer(const Napi::CallbackInfo& info);
private:
ChipPlayer* chipPlayer;
Napi::Value getMeta(const Napi::CallbackInfo& info);
Napi::Value getMetaInt(const Napi::CallbackInfo& info);
void seek(const Napi::CallbackInfo& info);
void freePlayer(const Napi::CallbackInfo& info);
Napi::Value play(const Napi::CallbackInfo& info);
Napi::Value nesAnalysis(const Napi::CallbackInfo& info);
};
| 30.041667 | 66 | 0.729542 |
df0e71eae83804bf260d97b25086b7bc3e6b6a9e | 96 | h | C | ext/zephyranthes/zephyranthes.h | 284km/zephyranthes | 34b764dbbd66f3323703b29a7ebfd84ee465f9ff | [
"MIT"
] | null | null | null | ext/zephyranthes/zephyranthes.h | 284km/zephyranthes | 34b764dbbd66f3323703b29a7ebfd84ee465f9ff | [
"MIT"
] | null | null | null | ext/zephyranthes/zephyranthes.h | 284km/zephyranthes | 34b764dbbd66f3323703b29a7ebfd84ee465f9ff | [
"MIT"
] | null | null | null | #ifndef ZEPHYRANTHES_H
#define ZEPHYRANTHES_H 1
#include "ruby.h"
#endif /* ZEPHYRANTHES_H */
| 13.714286 | 27 | 0.75 |
3d6e31c1fc04a0db7adaf6a0c61a73e7d93d6540 | 3,495 | h | C | src/xray/math_functions.h | ixray-team/ixray-2.0 | 85c3a544175842323fc82f42efd96c66f0fc5abb | [
"Linux-OpenIB"
] | 3 | 2021-10-30T09:36:14.000Z | 2022-03-26T17:00:06.000Z | src/xray/math_functions.h | acidicMercury8/ixray-2.0 | 85c3a544175842323fc82f42efd96c66f0fc5abb | [
"Linux-OpenIB"
] | null | null | null | src/xray/math_functions.h | acidicMercury8/ixray-2.0 | 85c3a544175842323fc82f42efd96c66f0fc5abb | [
"Linux-OpenIB"
] | 1 | 2022-03-26T17:00:08.000Z | 2022-03-26T17:00:08.000Z | ////////////////////////////////////////////////////////////////////////////
// Created : 14.10.2008
// Author : Dmitriy Iassenev
// Copyright (C) GSC Game World - 2009
////////////////////////////////////////////////////////////////////////////
#ifndef XRAY_MATH_FUNCTIONS_H_INCLUDED
#define XRAY_MATH_FUNCTIONS_H_INCLUDED
#include <xray/math_constants.h>
#include <limits>
namespace xray {
namespace math {
template < typename T >
inline typename T::type dot_product ( T const& left, typename T::type const& right );
inline float abs ( float left );
inline int abs ( int left );
inline s64 abs ( s64 left );
template < typename T >
inline T sqr ( T const& left );
template < typename T >
inline T min ( T const& left, T const& right );
template < typename T >
inline T min ( T const& value1, T const& value2, T const& value3 );
template < typename T >
inline T max ( T const& left, T const& right );
template < typename T >
inline T max ( T const& value1, T const& value2, T const& value3 );
template < typename T >
inline bool similar ( T const& left, T const& right, float const epsilon = epsilon_5 );
template < typename T >
inline bool similar ( T const& left, T const& right, typename T::type const& epsilon );
template < typename T >
inline bool is_zero ( T const& left, T const& epsilon = epsilon_5 );
inline float cos ( float angle );
inline float sin ( float angle );
inline float tan ( float angle );
inline float acos ( float value );
inline float asin ( float value );
inline float atan ( float value );
inline float atan2 ( float x, float y );
inline float sqrt ( float value );
inline float log ( float value );
inline float exp ( float power );
inline float pow ( float base, float power );
inline float pow ( float base, int power );
inline float pow ( float base, u32 power );
inline u32 pow ( u32 base, u32 power );
inline char sign ( float value );
inline bool valid ( float value );
template < typename T >
inline int floor ( float value );
template < typename T >
inline int ceil ( float value );
struct sine_cosine {
float sine;
float cosine;
inline sine_cosine ( float const angle );
}; // struct sine_cosine
template < typename T >
inline T type_epsilon ( );
inline bool negative ( float value );
inline float deg2rad ( float value );
inline float rad2deg ( float value );
template < typename T >
inline T clamp_r ( T value, T min, T max );
template < typename T >
inline void clamp ( T& value_and_result, T const min, T const max );
inline float angle_normalize_always ( float angle );
inline float angle_normalize ( float angle );
inline float angle_normalize_signed ( float angle );
enum intersection {
intersection_none,
intersection_inside,
intersection_outside,
intersection_intersect,
}; // enum intersection
template <class Ordinal>
Ordinal align_down ( Ordinal value, Ordinal align_on );
template <class Ordinal>
Ordinal align_up ( Ordinal value, Ordinal align_on );
float XRAY_CORE_API table_sin ( int angle_in_degrees );
float XRAY_CORE_API table_cos ( int angle_in_degrees );
} // namespace math
} // namespace xray
#include <xray/math_functions_inline.h>
#endif // #ifndef XRAY_MATH_FUNCTIONS_H_INCLUDED | 29.871795 | 93 | 0.627754 |
ce3a4a8c16f9edbe0e6ad4ab6ea6dc1fb239af33 | 2,394 | h | C | printscan/ui/scanlib/scanitem.h | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | printscan/ui/scanlib/scanitem.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | printscan/ui/scanlib/scanitem.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | /*******************************************************************************
*
* (C) COPYRIGHT MICROSOFT CORPORATION, 1998
*
* TITLE: SCANITEM.H
*
* VERSION: 1.0
*
* AUTHOR: ShaunIv
*
* DATE: 10/7/1999
*
* DESCRIPTION: WIA Item wrapper for scanner items
*
*******************************************************************************/
#ifndef __SCANITEM_H_INCLUDED
#define __SCANITEM_H_INCLUDED
#include "simevent.h"
#include "propstrm.h"
class CScannerItem
{
private:
CComPtr<IWiaItem> m_pIWiaItem; // Item COM pointer
SIZE m_AspectRatio;
DWORD m_dwIWiaItemCookie; // Global interface table entry
CSimpleEvent m_CancelEvent;
CPropertyStream m_SavedPropertyStream;
CPropertyStream m_CustomPropertyStream;
public:
CScannerItem( IWiaItem *pIWiaItem );
CScannerItem( void );
CScannerItem(const CScannerItem &other);
~CScannerItem(void);
CComPtr<IWiaItem> Item(void) const;
SIZE AspectRatio(void) const;
DWORD Cookie(void) const;
CScannerItem &Assign( const CScannerItem &other );
bool operator==( const CScannerItem & );
CScannerItem &operator=( const CScannerItem &other );
HRESULT Destroy(void);
HRESULT Initialize( IWiaItem *pIWiaItem );
bool GetInitialBedSize( SIZE &sizeBed );
bool GetAspectRatio( SIZE &sizeAspectRatio );
bool ApplyCurrentPreviewWindowSettings( HWND hWndPreview );
bool GetFullResolution( const SIZE &sizeResultionPerInch, SIZE &sizeRes );
void Cancel(void);
bool CalculatePreviewResolution( SIZE &sizeResolution );
HANDLE Scan( HWND hWndNotify, HWND hWndPreview );
HANDLE Scan( HWND hWndNotify, GUID guidFormat, const CSimpleStringWide &strFilename );
bool SetIntent( int nIntent );
CSimpleEvent CancelEvent(void) const;
CPropertyStream &SavedPropertyStream(void)
{
return m_SavedPropertyStream;
}
const CPropertyStream &SavedPropertyStream(void) const
{
return m_SavedPropertyStream;
}
CPropertyStream &CustomPropertyStream(void)
{
return m_CustomPropertyStream;
}
const CPropertyStream &CustomPropertyStream(void) const
{
return m_CustomPropertyStream;
}
};
#endif
| 30.303797 | 91 | 0.6132 |
ceb0317f71c92019514f155ecf8821f876dd35a6 | 990 | c | C | src/lib/builtins/env/set.c | youpaw/42 | 99d8bb4e787a9b6e2ada98389f3d3e6b6c5a06bc | [
"MIT"
] | null | null | null | src/lib/builtins/env/set.c | youpaw/42 | 99d8bb4e787a9b6e2ada98389f3d3e6b6c5a06bc | [
"MIT"
] | null | null | null | src/lib/builtins/env/set.c | youpaw/42 | 99d8bb4e787a9b6e2ada98389f3d3e6b6c5a06bc | [
"MIT"
] | 1 | 2021-05-15T16:12:51.000Z | 2021-05-15T16:12:51.000Z | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* set.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mgena <mgena@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/15 18:13:11 by mgena #+# #+# */
/* Updated: 2020/11/15 19:19:19 by mgena ### ########.fr */
/* */
/* ************************************************************************** */
#include "env.h"
int sh_set(const char **args)
{
(void)args;
env_print_full();
return (0);
}
| 47.142857 | 80 | 0.148485 |
0e12bf12769caba80724a66ba1eb7d86975acb56 | 7,037 | c | C | example.c | Taymindis/lfstack | a09d7390b9e5ba565e60836ea4b65bef9655fb4d | [
"BSD-2-Clause"
] | 23 | 2018-06-27T10:45:30.000Z | 2021-12-27T16:50:56.000Z | example.c | Taymindis/lfstack | a09d7390b9e5ba565e60836ea4b65bef9655fb4d | [
"BSD-2-Clause"
] | null | null | null | example.c | Taymindis/lfstack | a09d7390b9e5ba565e60836ea4b65bef9655fb4d | [
"BSD-2-Clause"
] | 8 | 2018-09-02T09:54:30.000Z | 2022-02-05T03:14:04.000Z | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <assert.h>
#include <sys/time.h>
#include <stdio.h>
#include "lfstack.h"
typedef void (*test_function)(pthread_t*);
void one_push_and_multi_pop(pthread_t *threads);
void one_pop_and_multi_push(pthread_t *threads);
void multi_push_pop(pthread_t *threads);
void* worker_push_pop(void *);
void* worker_push(void *);
void* worker_pop(void *);
void* worker_pushingle_c(void *);
/**Testing must**/
void one_push_and_multi_pop_must(pthread_t *threads);
void one_pop_must_and_multi_push(pthread_t *threads);
void multi_push_pop_must(pthread_t *threads);
void* worker_push_pop_must(void *);
void* worker_push_must(void *);
void* worker_pop_must(void *);
void* worker_single_pop_must(void *);
void running_test(test_function testfn);
struct timeval tv1, tv2;
#define total_put 50000
#define total_running_loop 50
int nthreads = 4;
int one_thread = 1;
int nthreads_exited = 0;
lfstack_t *mystack;
void* worker_pop_must(void *arg) {
int i = 0;
int *int_data;
int total_loop = total_put * (*(int*)arg);
while (i++ < total_loop) {
/*Pop*/
int_data = lfstack_pop_must(mystack);
// printf("%d\n", *int_data);
free(int_data);
}
__sync_add_and_fetch(&nthreads_exited, 1);
return 0;
}
void* worker_single_pop_must(void *arg) {
int i = 0;
int *int_data;
int total_loop = total_put * (*(int*)arg);
while (i++ < total_loop) {
/*Pop*/
int_data = lfstack_single_pop_must(mystack);
// printf("%d\n", *int_data);
free(int_data);
}
__sync_add_and_fetch(&nthreads_exited, 1);
return 0;
}
void* worker_push_pop_must(void *arg)
{
int i = 0;
int *int_data;
while (i < total_put) {
int_data = (int*)malloc(sizeof(int));
assert(int_data != NULL);
*int_data = i++;
/*Push*/
while (lfstack_push(mystack, int_data)) {
printf("ENQ FULL?\n");
}
/*Pop*/
int_data = lfstack_pop_must(mystack);
// printf("%d\n", *int_data);
free(int_data);
}
__sync_add_and_fetch(&nthreads_exited, 1);
return 0;
}
void* worker_pop(void *arg) {
int i = 0;
int *int_data;
int total_loop = total_put * (*(int*)arg);
while (i++ < total_loop) {
/*Pop*/
while ((int_data = lfstack_pop(mystack)) == NULL) {
lfstack_sleep(1);
}
// printf("%d\n", *int_data);
free(int_data);
}
__sync_add_and_fetch(&nthreads_exited, 1);
return 0;
}
void* worker_pushingle_c(void *arg) {
int i = 0;
int *int_data;
int total_loop = total_put * (*(int*)arg);
while (i++ < total_loop) {
/*Pop*/
while ((int_data = lfstack_single_pop(mystack)) == NULL) {
lfstack_sleep(1);
}
// printf("%d\n", *int_data);
free(int_data);
}
__sync_add_and_fetch(&nthreads_exited, 1);
return 0;
}
/** Worker Keep Sending at the same time, do not try instensively **/
void* worker_push(void *arg)
{
int i = 0, *int_data;
int total_loop = total_put * (*(int*)arg);
while (i++ < total_loop) {
int_data = (int*)malloc(sizeof(int));
assert(int_data != NULL);
*int_data = i;
/*Push*/
while (lfstack_push(mystack, int_data)) {
// printf("ENQ FULL?\n");
}
}
// __sync_add_and_fetch(&nthreads_exited, 1);
return 0;
}
/** Worker Send And Consume at the same time **/
void* worker_push_pop(void *arg)
{
int i = 0;
int *int_data;
while (i < total_put) {
int_data = (int*)malloc(sizeof(int));
assert(int_data != NULL);
*int_data = i++;
/*Push*/
while (lfstack_push(mystack, int_data)) {
printf("ENQ FULL?\n");
}
/*Pop*/
while ((int_data = lfstack_pop(mystack)) == NULL) {
lfstack_sleep(1);
}
// printf("%d\n", *int_data);
free(int_data);
}
__sync_add_and_fetch(&nthreads_exited, 1);
return 0;
}
#define join_threads \
for (i = 0; i < nthreads; i++) {\
pthread_join(threads[i], NULL); \
}
#define detach_thread_and_loop \
for (i = 0; i < nthreads; i++)\
pthread_detach(threads[i]);\
while ( nthreads_exited < nthreads ) \
lfstack_sleep(10);\
if(lfstack_size(mystack) != 0){\
lfstack_sleep(10);\
}
void multi_push_pop(pthread_t *threads) {
printf("-----------%s---------------\n", "multi_push_pop");
int i;
for (i = 0; i < nthreads; i++) {
pthread_create(threads + i, NULL, worker_push_pop, NULL);
}
join_threads;
// detach_thread_and_loop;
}
void one_pop_and_multi_push(pthread_t *threads) {
printf("-----------%s---------------\n", "one_pop_and_multi_push");
int i;
for (i = 0; i < nthreads; i++)
pthread_create(threads + i, NULL, worker_push, &one_thread);
worker_pushingle_c(&nthreads);
join_threads;
// detach_thread_and_loop;
}
void one_push_and_multi_pop(pthread_t *threads) {
printf("-----------%s---------------\n", "one_push_and_multi_pop");
int i;
for (i = 0; i < nthreads; i++)
pthread_create(threads + i, NULL, worker_pop, &one_thread);
worker_push(&nthreads);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-function-declaration"
detach_thread_and_loop;
#pragma GCC diagnostic pop
}
void one_pop_must_and_multi_push(pthread_t *threads) {
printf("-----------%s---------------\n", "one_pop_must_and_multi_push");
int i;
for (i = 0; i < nthreads; i++)
pthread_create(threads + i, NULL, worker_push, &one_thread);
worker_single_pop_must(&nthreads);
join_threads;
// detach_thread_and_loop;
}
void one_push_and_multi_pop_must(pthread_t *threads) {
printf("-----------%s---------------\n", "one_push_and_multi_pop_must");
int i;
for (i = 0; i < nthreads; i++)
pthread_create(threads + i, NULL, worker_pop_must, &one_thread);
worker_push(&nthreads);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-function-declaration"
detach_thread_and_loop;
#pragma GCC diagnostic pop
}
void multi_push_pop_must(pthread_t *threads) {
printf("-----------%s---------------\n", "multi_push_pop_must");
int i;
for (i = 0; i < nthreads; i++) {
pthread_create(threads + i, NULL, worker_push_pop_must, NULL);
}
join_threads;
// detach_thread_and_loop;
}
void running_test(test_function testfn) {
int n;
for (n = 0; n < total_running_loop; n++) {
printf("Current running at =%d, ", n);
nthreads_exited = 0;
/* Spawn threads. */
pthread_t threads[nthreads];
printf("Using %d thread%s.\n", nthreads, nthreads == 1 ? "" : "s");
printf("Total requests %d \n", total_put);
gettimeofday(&tv1, NULL);
testfn(threads);
gettimeofday(&tv2, NULL);
printf ("Total time = %f seconds\n",
(double) (tv2.tv_usec - tv1.tv_usec) / 1000000 +
(double) (tv2.tv_sec - tv1.tv_sec));
lfstack_sleep(10);
assert ( 0 == lfstack_size(mystack) && "Error, all stack should be consumed but not");
}
}
int main(void) {
mystack = malloc(sizeof (lfstack_t));
if (lfstack_init(mystack) == -1)
return -1;
running_test(one_push_and_multi_pop);
running_test(one_push_and_multi_pop_must);
running_test(one_pop_and_multi_push);
running_test(one_pop_must_and_multi_push);
running_test(multi_push_pop);
running_test(multi_push_pop_must);
lfstack_destroy(mystack);
// sleep(3);
free(mystack);
printf("Test Pass!\n");
return 0;
}
| 22.7 | 88 | 0.668751 |
33cbf8f297d8060dff5446574d8a20c94c1e3195 | 36,948 | h | C | include/QtGui/qwidget.h | 219-design/build_qt4_binaries_armv5tejl_sbc6000x | 0d33869719a56ce4e9c7009f825c7d3c79869f36 | [
"MIT"
] | null | null | null | include/QtGui/qwidget.h | 219-design/build_qt4_binaries_armv5tejl_sbc6000x | 0d33869719a56ce4e9c7009f825c7d3c79869f36 | [
"MIT"
] | null | null | null | include/QtGui/qwidget.h | 219-design/build_qt4_binaries_armv5tejl_sbc6000x | 0d33869719a56ce4e9c7009f825c7d3c79869f36 | [
"MIT"
] | null | null | null | /****************************************************************************
**
** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License versions 2.0 or 3.0 as published by the Free
** Software Foundation and appearing in the file LICENSE.GPL included in
** the packaging of this file. Please review the following information
** to ensure GNU General Public Licensing requirements will be met:
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html. In addition, as a special
** exception, Nokia gives you certain additional rights. These rights
** are described in the Nokia Qt GPL Exception version 1.3, included in
** the file GPL_EXCEPTION.txt in this package.
**
** Qt for Windows(R) Licensees
** As a special exception, Nokia, as the sole copyright holder for Qt
** Designer, grants users of the Qt/Eclipse Integration plug-in the
** right for the Qt/Eclipse Integration to link to functionality
** provided by Qt Designer and its related libraries.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
#ifndef QWIDGET_H
#define QWIDGET_H
#include <QtGui/qwindowdefs.h>
#include <QtCore/qobject.h>
#include <QtGui/qpaintdevice.h>
#include <QtGui/qpalette.h>
#include <QtGui/qfont.h>
#include <QtGui/qfontmetrics.h>
#include <QtGui/qfontinfo.h>
#include <QtGui/qsizepolicy.h>
#include <QtGui/qregion.h>
#include <QtGui/qbrush.h>
#include <QtGui/qcursor.h>
#include <QtGui/qkeysequence.h>
#ifdef QT_INCLUDE_COMPAT
#include <QtGui/qevent.h>
#endif
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
class QLayout;
class QWSRegionManager;
class QStyle;
class QAction;
class QVariant;
class QActionEvent;
class QMouseEvent;
class QWheelEvent;
class QHoverEvent;
class QKeyEvent;
class QFocusEvent;
class QPaintEvent;
class QMoveEvent;
class QResizeEvent;
class QCloseEvent;
class QContextMenuEvent;
class QInputMethodEvent;
class QTabletEvent;
class QDragEnterEvent;
class QDragMoveEvent;
class QDragLeaveEvent;
class QDropEvent;
class QShowEvent;
class QHideEvent;
class QInputContext;
class QIcon;
class QWindowSurface;
class QLocale;
#if defined(Q_WS_X11)
class QX11Info;
#endif
class QWidgetData
{
public:
WId winid;
uint widget_attributes;
Qt::WindowFlags window_flags;
uint window_state : 4;
uint focus_policy : 4;
uint sizehint_forced :1;
uint is_closing :1;
uint in_show : 1;
uint in_set_window_state : 1;
mutable uint fstrut_dirty : 1;
uint context_menu_policy : 3;
uint window_modality : 2;
uint in_destructor : 1;
uint unused : 13;
QRect crect;
mutable QPalette pal;
QFont fnt;
#if defined(Q_WS_QWS)
// QRegion req_region; // Requested region
// mutable QRegion paintable_region; // Paintable region
// mutable bool paintable_region_dirty;// needs to be recalculated
// mutable QRegion alloc_region; // Allocated region
// mutable bool alloc_region_dirty; // needs to be recalculated
// mutable int overlapping_children; // Handle overlapping children
int alloc_region_index;
// int alloc_region_revision;
#endif
#if defined(Q_OS_WINCE)
uint window_state_internal : 4;
#endif
QRect wrect;
};
class QWidgetPrivate;
class Q_GUI_EXPORT QWidget : public QObject, public QPaintDevice
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWidget)
Q_PROPERTY(bool modal READ isModal)
Q_PROPERTY(Qt::WindowModality windowModality READ windowModality WRITE setWindowModality)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry)
Q_PROPERTY(QRect frameGeometry READ frameGeometry)
Q_PROPERTY(QRect normalGeometry READ normalGeometry)
Q_PROPERTY(int x READ x)
Q_PROPERTY(int y READ y)
Q_PROPERTY(QPoint pos READ pos WRITE move DESIGNABLE false STORED false)
Q_PROPERTY(QSize frameSize READ frameSize)
Q_PROPERTY(QSize size READ size WRITE resize DESIGNABLE false STORED false)
Q_PROPERTY(int width READ width)
Q_PROPERTY(int height READ height)
Q_PROPERTY(QRect rect READ rect)
Q_PROPERTY(QRect childrenRect READ childrenRect)
Q_PROPERTY(QRegion childrenRegion READ childrenRegion)
Q_PROPERTY(QSizePolicy sizePolicy READ sizePolicy WRITE setSizePolicy)
Q_PROPERTY(QSize minimumSize READ minimumSize WRITE setMinimumSize)
Q_PROPERTY(QSize maximumSize READ maximumSize WRITE setMaximumSize)
Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth STORED false DESIGNABLE false)
Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight STORED false DESIGNABLE false)
Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth STORED false DESIGNABLE false)
Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight STORED false DESIGNABLE false)
Q_PROPERTY(QSize sizeIncrement READ sizeIncrement WRITE setSizeIncrement)
Q_PROPERTY(QSize baseSize READ baseSize WRITE setBaseSize)
Q_PROPERTY(QPalette palette READ palette WRITE setPalette)
Q_PROPERTY(QFont font READ font WRITE setFont)
#ifndef QT_NO_CURSOR
Q_PROPERTY(QCursor cursor READ cursor WRITE setCursor RESET unsetCursor)
#endif
Q_PROPERTY(bool mouseTracking READ hasMouseTracking WRITE setMouseTracking)
Q_PROPERTY(bool isActiveWindow READ isActiveWindow)
Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy)
Q_PROPERTY(bool focus READ hasFocus)
Q_PROPERTY(Qt::ContextMenuPolicy contextMenuPolicy READ contextMenuPolicy WRITE setContextMenuPolicy)
Q_PROPERTY(bool updatesEnabled READ updatesEnabled WRITE setUpdatesEnabled DESIGNABLE false)
Q_PROPERTY(bool visible READ isVisible WRITE setVisible DESIGNABLE false)
Q_PROPERTY(bool minimized READ isMinimized)
Q_PROPERTY(bool maximized READ isMaximized)
Q_PROPERTY(bool fullScreen READ isFullScreen)
Q_PROPERTY(QSize sizeHint READ sizeHint)
Q_PROPERTY(QSize minimumSizeHint READ minimumSizeHint)
Q_PROPERTY(bool acceptDrops READ acceptDrops WRITE setAcceptDrops)
Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle DESIGNABLE isWindow)
Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon DESIGNABLE isWindow)
Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText DESIGNABLE isWindow)
Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity DESIGNABLE isWindow)
Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified DESIGNABLE isWindow)
#ifndef QT_NO_TOOLTIP
Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip)
#endif
#ifndef QT_NO_STATUSTIP
Q_PROPERTY(QString statusTip READ statusTip WRITE setStatusTip)
#endif
#ifndef QT_NO_WHATSTHIS
Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis)
#endif
#ifndef QT_NO_ACCESSIBILITY
Q_PROPERTY(QString accessibleName READ accessibleName WRITE setAccessibleName)
Q_PROPERTY(QString accessibleDescription READ accessibleDescription WRITE setAccessibleDescription)
#endif
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection RESET unsetLayoutDirection)
QDOC_PROPERTY(Qt::WindowFlags windowFlags READ windowFlags WRITE setWindowFlags)
Q_PROPERTY(bool autoFillBackground READ autoFillBackground WRITE setAutoFillBackground)
#ifndef QT_NO_STYLE_STYLESHEET
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
#endif
Q_PROPERTY(QLocale locale READ locale WRITE setLocale RESET unsetLocale)
Q_PROPERTY(QString windowFilePath READ windowFilePath WRITE setWindowFilePath DESIGNABLE isWindow)
public:
enum RenderFlag {
DrawWindowBackground = 0x1,
DrawChildren = 0x2,
IgnoreMask = 0x4
};
Q_DECLARE_FLAGS(RenderFlags, RenderFlag)
explicit QWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
#ifdef QT3_SUPPORT
QT3_SUPPORT_CONSTRUCTOR QWidget(QWidget* parent, const char *name, Qt::WindowFlags f = 0);
#endif
~QWidget();
int devType() const;
WId winId() const;
void createWinId(); // internal, going away
inline WId internalWinId() const { return data->winid; }
WId effectiveWinId() const;
// GUI style setting
QStyle *style() const;
void setStyle(QStyle *);
// Widget types and states
bool isTopLevel() const;
bool isWindow() const;
bool isModal() const;
Qt::WindowModality windowModality() const;
void setWindowModality(Qt::WindowModality windowModality);
bool isEnabled() const;
bool isEnabledTo(QWidget*) const;
bool isEnabledToTLW() const;
public Q_SLOTS:
void setEnabled(bool);
void setDisabled(bool);
void setWindowModified(bool);
// Widget coordinates
public:
QRect frameGeometry() const;
const QRect &geometry() const;
QRect normalGeometry() const;
int x() const;
int y() const;
QPoint pos() const;
QSize frameSize() const;
QSize size() const;
inline int width() const;
inline int height() const;
inline QRect rect() const;
QRect childrenRect() const;
QRegion childrenRegion() const;
QSize minimumSize() const;
QSize maximumSize() const;
int minimumWidth() const;
int minimumHeight() const;
int maximumWidth() const;
int maximumHeight() const;
void setMinimumSize(const QSize &);
void setMinimumSize(int minw, int minh);
void setMaximumSize(const QSize &);
void setMaximumSize(int maxw, int maxh);
void setMinimumWidth(int minw);
void setMinimumHeight(int minh);
void setMaximumWidth(int maxw);
void setMaximumHeight(int maxh);
QSize sizeIncrement() const;
void setSizeIncrement(const QSize &);
void setSizeIncrement(int w, int h);
QSize baseSize() const;
void setBaseSize(const QSize &);
void setBaseSize(int basew, int baseh);
void setFixedSize(const QSize &);
void setFixedSize(int w, int h);
void setFixedWidth(int w);
void setFixedHeight(int h);
// Widget coordinate mapping
QPoint mapToGlobal(const QPoint &) const;
QPoint mapFromGlobal(const QPoint &) const;
QPoint mapToParent(const QPoint &) const;
QPoint mapFromParent(const QPoint &) const;
QPoint mapTo(QWidget *, const QPoint &) const;
QPoint mapFrom(QWidget *, const QPoint &) const;
QWidget *window() const;
QWidget *nativeParentWidget() const;
inline QWidget *topLevelWidget() const { return window(); }
// Widget appearance functions
const QPalette &palette() const;
void setPalette(const QPalette &);
void setBackgroundRole(QPalette::ColorRole);
QPalette::ColorRole backgroundRole() const;
void setForegroundRole(QPalette::ColorRole);
QPalette::ColorRole foregroundRole() const;
const QFont &font() const;
void setFont(const QFont &);
QFontMetrics fontMetrics() const;
QFontInfo fontInfo() const;
#ifndef QT_NO_CURSOR
QCursor cursor() const;
void setCursor(const QCursor &);
void unsetCursor();
#endif
void setMouseTracking(bool enable);
bool hasMouseTracking() const;
bool underMouse() const;
void setMask(const QBitmap &);
void setMask(const QRegion &);
QRegion mask() const;
void clearMask();
void render(QPaintDevice *target, const QPoint &targetOffset = QPoint(),
const QRegion &sourceRegion = QRegion(),
RenderFlags renderFlags = RenderFlags(DrawWindowBackground | DrawChildren));
void render(QPainter *painter, const QPoint &targetOffset = QPoint(),
const QRegion &sourceRegion = QRegion(),
RenderFlags renderFlags = RenderFlags(DrawWindowBackground | DrawChildren));
public Q_SLOTS:
void setWindowTitle(const QString &);
#ifndef QT_NO_STYLE_STYLESHEET
void setStyleSheet(const QString& styleSheet);
#endif
public:
#ifndef QT_NO_STYLE_STYLESHEET
QString styleSheet() const;
#endif
QString windowTitle() const;
void setWindowIcon(const QIcon &icon);
QIcon windowIcon() const;
void setWindowIconText(const QString &);
QString windowIconText() const;
void setWindowRole(const QString &);
QString windowRole() const;
void setWindowFilePath(const QString &filePath);
QString windowFilePath() const;
void setWindowOpacity(qreal level);
qreal windowOpacity() const;
bool isWindowModified() const;
#ifndef QT_NO_TOOLTIP
void setToolTip(const QString &);
QString toolTip() const;
#endif
#ifndef QT_NO_STATUSTIP
void setStatusTip(const QString &);
QString statusTip() const;
#endif
#ifndef QT_NO_WHATSTHIS
void setWhatsThis(const QString &);
QString whatsThis() const;
#endif
#ifndef QT_NO_ACCESSIBILITY
QString accessibleName() const;
void setAccessibleName(const QString &name);
QString accessibleDescription() const;
void setAccessibleDescription(const QString &description);
#endif
void setLayoutDirection(Qt::LayoutDirection direction);
Qt::LayoutDirection layoutDirection() const;
void unsetLayoutDirection();
void setLocale(const QLocale &locale);
QLocale locale() const;
void unsetLocale();
inline bool isRightToLeft() const { return layoutDirection() == Qt::RightToLeft; }
inline bool isLeftToRight() const { return layoutDirection() == Qt::LeftToRight; }
public Q_SLOTS:
inline void setFocus() { setFocus(Qt::OtherFocusReason); }
public:
bool isActiveWindow() const;
void activateWindow();
void clearFocus();
void setFocus(Qt::FocusReason reason);
Qt::FocusPolicy focusPolicy() const;
void setFocusPolicy(Qt::FocusPolicy policy);
bool hasFocus() const;
static void setTabOrder(QWidget *, QWidget *);
void setFocusProxy(QWidget *);
QWidget *focusProxy() const;
Qt::ContextMenuPolicy contextMenuPolicy() const;
void setContextMenuPolicy(Qt::ContextMenuPolicy policy);
// Grab functions
void grabMouse();
#ifndef QT_NO_CURSOR
void grabMouse(const QCursor &);
#endif
void releaseMouse();
void grabKeyboard();
void releaseKeyboard();
#ifndef QT_NO_SHORTCUT
int grabShortcut(const QKeySequence &key, Qt::ShortcutContext context = Qt::WindowShortcut);
void releaseShortcut(int id);
void setShortcutEnabled(int id, bool enable = true);
void setShortcutAutoRepeat(int id, bool enable = true);
#endif
static QWidget *mouseGrabber();
static QWidget *keyboardGrabber();
// Update/refresh functions
inline bool updatesEnabled() const;
void setUpdatesEnabled(bool enable);
#if 0 //def Q_WS_QWS
void repaintUnclipped(const QRegion &, bool erase = true);
#endif
public Q_SLOTS:
void update();
void repaint();
public:
inline void update(int x, int y, int w, int h);
void update(const QRect&);
void update(const QRegion&);
void repaint(int x, int y, int w, int h);
void repaint(const QRect &);
void repaint(const QRegion &);
public Q_SLOTS:
// Widget management functions
virtual void setVisible(bool visible);
inline void setHidden(bool hidden) { setVisible(!hidden); }
#ifndef Q_OS_WINCE
inline void show() { setVisible(true); }
#else
void show();
#endif
inline void hide() { setVisible(false); }
inline QT_MOC_COMPAT void setShown(bool shown) { setVisible(shown); }
void showMinimized();
void showMaximized();
void showFullScreen();
void showNormal();
bool close();
void raise();
void lower();
public:
void stackUnder(QWidget*);
void move(int x, int y);
void move(const QPoint &);
void resize(int w, int h);
void resize(const QSize &);
inline void setGeometry(int x, int y, int w, int h);
void setGeometry(const QRect &);
QByteArray saveGeometry() const;
bool restoreGeometry(const QByteArray &geometry);
void adjustSize();
bool isVisible() const;
bool isVisibleTo(QWidget*) const;
// ### Qt 5: bool isVisibleTo(_const_ QWidget *) const
inline bool isHidden() const;
bool isMinimized() const;
bool isMaximized() const;
bool isFullScreen() const;
Qt::WindowStates windowState() const;
void setWindowState(Qt::WindowStates state);
void overrideWindowState(Qt::WindowStates state);
virtual QSize sizeHint() const;
virtual QSize minimumSizeHint() const;
QSizePolicy sizePolicy() const;
void setSizePolicy(QSizePolicy);
inline void setSizePolicy(QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical);
virtual int heightForWidth(int) const;
QRegion visibleRegion() const;
void setContentsMargins(int left, int top, int right, int bottom);
void getContentsMargins(int *left, int *top, int *right, int *bottom) const;
QRect contentsRect() const;
public:
QLayout *layout() const;
void setLayout(QLayout *);
void updateGeometry();
void setParent(QWidget *parent);
void setParent(QWidget *parent, Qt::WindowFlags f);
void scroll(int dx, int dy);
void scroll(int dx, int dy, const QRect&);
// Misc. functions
QWidget *focusWidget() const;
QWidget *nextInFocusChain() const;
// drag and drop
bool acceptDrops() const;
void setAcceptDrops(bool on);
#ifndef QT_NO_ACTION
//actions
void addAction(QAction *action);
void addActions(QList<QAction*> actions);
void insertAction(QAction *before, QAction *action);
void insertActions(QAction *before, QList<QAction*> actions);
void removeAction(QAction *action);
QList<QAction*> actions() const;
#endif
QWidget *parentWidget() const;
void setWindowFlags(Qt::WindowFlags type);
inline Qt::WindowFlags windowFlags() const;
void overrideWindowFlags(Qt::WindowFlags type);
inline Qt::WindowType windowType() const;
static QWidget *find(WId);
#ifdef QT3_SUPPORT
static QT3_SUPPORT QWidgetMapper *wmapper();
#endif
inline QWidget *childAt(int x, int y) const;
QWidget *childAt(const QPoint &p) const;
#if defined(Q_WS_X11)
const QX11Info &x11Info() const;
Qt::HANDLE x11PictureHandle() const;
#endif
#if defined(Q_WS_MAC)
Qt::HANDLE macQDHandle() const;
Qt::HANDLE macCGHandle() const;
#endif
#if defined(Q_WS_WIN)
HDC getDC() const;
void releaseDC(HDC) const;
#else
Qt::HANDLE handle() const;
#endif
void setAttribute(Qt::WidgetAttribute, bool on = true);
inline bool testAttribute(Qt::WidgetAttribute) const;
QPaintEngine *paintEngine() const;
void ensurePolished() const;
QInputContext *inputContext();
void setInputContext(QInputContext *);
bool isAncestorOf(const QWidget *child) const;
#ifdef QT_KEYPAD_NAVIGATION
bool hasEditFocus() const;
void setEditFocus(bool on);
#endif
bool autoFillBackground() const;
void setAutoFillBackground(bool enabled);
void setWindowSurface(QWindowSurface *surface);
QWindowSurface *windowSurface() const;
Q_SIGNALS:
void customContextMenuRequested(const QPoint &pos);
protected:
// Event handlers
bool event(QEvent *);
virtual void mousePressEvent(QMouseEvent *);
virtual void mouseReleaseEvent(QMouseEvent *);
virtual void mouseDoubleClickEvent(QMouseEvent *);
virtual void mouseMoveEvent(QMouseEvent *);
#ifndef QT_NO_WHEELEVENT
virtual void wheelEvent(QWheelEvent *);
#endif
virtual void keyPressEvent(QKeyEvent *);
virtual void keyReleaseEvent(QKeyEvent *);
virtual void focusInEvent(QFocusEvent *);
virtual void focusOutEvent(QFocusEvent *);
virtual void enterEvent(QEvent *);
virtual void leaveEvent(QEvent *);
virtual void paintEvent(QPaintEvent *);
virtual void moveEvent(QMoveEvent *);
virtual void resizeEvent(QResizeEvent *);
virtual void closeEvent(QCloseEvent *);
#ifndef QT_NO_CONTEXTMENU
virtual void contextMenuEvent(QContextMenuEvent *);
#endif
#ifndef QT_NO_TABLETEVENT
virtual void tabletEvent(QTabletEvent *);
#endif
#ifndef QT_NO_ACTION
virtual void actionEvent(QActionEvent *);
#endif
#ifndef QT_NO_DRAGANDDROP
virtual void dragEnterEvent(QDragEnterEvent *);
virtual void dragMoveEvent(QDragMoveEvent *);
virtual void dragLeaveEvent(QDragLeaveEvent *);
virtual void dropEvent(QDropEvent *);
#endif
virtual void showEvent(QShowEvent *);
virtual void hideEvent(QHideEvent *);
#if defined(Q_WS_MAC)
virtual bool macEvent(EventHandlerCallRef, EventRef);
#endif
#if defined(Q_WS_WIN)
virtual bool winEvent(MSG *message, long *result);
#endif
#if defined(Q_WS_X11)
virtual bool x11Event(XEvent *);
#endif
#if defined(Q_WS_QWS)
virtual bool qwsEvent(QWSEvent *);
#endif
// Misc. protected functions
virtual void changeEvent(QEvent *);
int metric(PaintDeviceMetric) const;
virtual void inputMethodEvent(QInputMethodEvent *);
public:
virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const;
protected:
void resetInputContext();
protected Q_SLOTS:
void updateMicroFocus();
protected:
void create(WId = 0, bool initializeWindow = true,
bool destroyOldWindow = true);
void destroy(bool destroyWindow = true,
bool destroySubWindows = true);
virtual bool focusNextPrevChild(bool next);
inline bool focusNextChild() { return focusNextPrevChild(true); }
inline bool focusPreviousChild() { return focusNextPrevChild(false); }
protected:
QWidget(QWidgetPrivate &d, QWidget* parent, Qt::WindowFlags f);
private:
bool testAttribute_helper(Qt::WidgetAttribute) const;
friend void qt_syncBackingStore(QWidget *);
friend void qt_syncBackingStore(QRegion, QWidget *);
friend void qt_syncBackingStore(QRegion, QWidget *, bool);
friend QRegion qt_dirtyRegion(QWidget *, bool);
friend QWindowSurface *qt_default_window_surface(QWidget*);
friend class QBackingStoreDevice;
friend class QWidgetBackingStore;
friend class QApplication;
friend class QApplicationPrivate;
friend class QBaseApplication;
friend class QPainter;
friend class QPainterPrivate;
friend class QPixmap; // for QPixmap::fill()
friend class QFontMetrics;
friend class QFontInfo;
friend class QETWidget;
friend class QLayout;
friend class QWidgetItem;
friend class QWidgetItemV2;
friend class QGLContext;
friend class QGLWidget;
friend class QX11PaintEngine;
friend class QWin32PaintEngine;
friend class QShortcutPrivate;
friend class QWindowSurface;
friend class QD3DWindowSurface;
friend class QGraphicsProxyWidget;
friend class QGraphicsProxyWidgetPrivate;
friend class QStyleSheetStyle;
#ifdef Q_WS_MAC
#ifdef Q_WS_MAC32
friend class QMacSavedPortInfo;
#endif
friend class QCoreGraphicsPaintEnginePrivate;
friend QPoint qt_mac_posInWindow(const QWidget *w);
friend WindowPtr qt_mac_window_for(const QWidget *w);
friend bool qt_mac_is_metal(const QWidget *w);
friend HIViewRef qt_mac_hiview_for(const QWidget *w);
friend void qt_event_request_window_change(QWidget *widget);
#endif
#ifdef Q_WS_QWS
friend class QWSBackingStore;
friend class QWSManager;
friend class QWSManagerPrivate;
friend class QDecoration;
friend class QWSWindowSurface;
friend class QScreen;
friend class QVNCScreen;
friend bool isWidgetOpaque(const QWidget *);
friend class QGLWidgetPrivate;
#endif
friend Q_GUI_EXPORT QWidgetData *qt_qwidget_data(QWidget *widget);
friend Q_GUI_EXPORT QWidgetPrivate *qt_widget_private(QWidget *widget);
private:
Q_DISABLE_COPY(QWidget)
Q_PRIVATE_SLOT(d_func(), void _q_showIfNotHidden())
QWidgetData *data;
#ifdef QT3_SUPPORT
public:
inline QT3_SUPPORT bool isUpdatesEnabled() const { return updatesEnabled(); }
QT3_SUPPORT QStyle *setStyle(const QString&);
inline QT3_SUPPORT bool isVisibleToTLW() const;
QT3_SUPPORT QRect visibleRect() const;
inline QT3_SUPPORT void iconify() { showMinimized(); }
inline QT3_SUPPORT void constPolish() const { ensurePolished(); }
inline QT3_SUPPORT void polish() { ensurePolished(); }
inline QT3_SUPPORT void reparent(QWidget *parent, Qt::WindowFlags f, const QPoint &p, bool showIt=false)
{ setParent(parent, f); setGeometry(p.x(),p.y(),width(),height()); if (showIt) show(); }
inline QT3_SUPPORT void reparent(QWidget *parent, const QPoint &p, bool showIt=false)
{ setParent(parent, windowFlags() & ~Qt::WindowType_Mask); setGeometry(p.x(),p.y(),width(),height()); if (showIt) show(); }
inline QT3_SUPPORT void recreate(QWidget *parent, Qt::WindowFlags f, const QPoint & p, bool showIt=false)
{ setParent(parent, f); setGeometry(p.x(),p.y(),width(),height()); if (showIt) show(); }
inline QT3_SUPPORT void setSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver, bool hfw)
{ QSizePolicy sp(hor, ver); sp.setHeightForWidth(hfw); setSizePolicy(sp);}
inline QT3_SUPPORT bool hasMouse() const { return testAttribute(Qt::WA_UnderMouse); }
#ifndef QT_NO_CURSOR
inline QT3_SUPPORT bool ownCursor() const { return testAttribute(Qt::WA_SetCursor); }
#endif
inline QT3_SUPPORT bool ownFont() const { return testAttribute(Qt::WA_SetFont); }
inline QT3_SUPPORT void unsetFont() { setFont(QFont()); }
inline QT3_SUPPORT bool ownPalette() const { return testAttribute(Qt::WA_SetPalette); }
inline QT3_SUPPORT void unsetPalette() { setPalette(QPalette()); }
Qt::BackgroundMode QT3_SUPPORT backgroundMode() const;
void QT3_SUPPORT setBackgroundMode(Qt::BackgroundMode, Qt::BackgroundMode = Qt::PaletteBackground);
const QT3_SUPPORT QColor &eraseColor() const;
void QT3_SUPPORT setEraseColor(const QColor &);
const QT3_SUPPORT QColor &foregroundColor() const;
const QT3_SUPPORT QPixmap *erasePixmap() const;
void QT3_SUPPORT setErasePixmap(const QPixmap &);
const QT3_SUPPORT QColor &paletteForegroundColor() const;
void QT3_SUPPORT setPaletteForegroundColor(const QColor &);
const QT3_SUPPORT QColor &paletteBackgroundColor() const;
void QT3_SUPPORT setPaletteBackgroundColor(const QColor &);
const QT3_SUPPORT QPixmap *paletteBackgroundPixmap() const;
void QT3_SUPPORT setPaletteBackgroundPixmap(const QPixmap &);
const QT3_SUPPORT QBrush& backgroundBrush() const;
const QT3_SUPPORT QColor &backgroundColor() const;
const QT3_SUPPORT QPixmap *backgroundPixmap() const;
void QT3_SUPPORT setBackgroundPixmap(const QPixmap &);
QT3_SUPPORT void setBackgroundColor(const QColor &);
QT3_SUPPORT QColorGroup colorGroup() const;
QT3_SUPPORT QWidget *parentWidget(bool sameWindow) const;
inline QT3_SUPPORT void setKeyCompression(bool b) { setAttribute(Qt::WA_KeyCompression, b); }
inline QT3_SUPPORT void setFont(const QFont &f, bool) { setFont(f); }
inline QT3_SUPPORT void setPalette(const QPalette &p, bool) { setPalette(p); }
enum BackgroundOrigin { WidgetOrigin, ParentOrigin, WindowOrigin, AncestorOrigin };
inline QT3_SUPPORT void setBackgroundOrigin(BackgroundOrigin){};
inline QT3_SUPPORT BackgroundOrigin backgroundOrigin() const { return WindowOrigin; }
inline QT3_SUPPORT QPoint backgroundOffset() const { return QPoint(); }
inline QT3_SUPPORT void repaint(bool) { repaint(); }
inline QT3_SUPPORT void repaint(int x, int y, int w, int h, bool) { repaint(x,y,w,h); }
inline QT3_SUPPORT void repaint(const QRect &r, bool) { repaint(r); }
inline QT3_SUPPORT void repaint(const QRegion &rgn, bool) { repaint(rgn); }
QT3_SUPPORT void erase();
inline QT3_SUPPORT void erase(int x, int y, int w, int h) { erase_helper(x, y, w, h); }
QT3_SUPPORT void erase(const QRect &);
QT3_SUPPORT void erase(const QRegion &);
QT3_SUPPORT void drawText(const QPoint &p, const QString &s)
{ drawText_helper(p.x(), p.y(), s); }
inline QT3_SUPPORT void drawText(int x, int y, const QString &s)
{ drawText_helper(x, y, s); }
QT3_SUPPORT bool close(bool);
inline QT3_SUPPORT QWidget *childAt(int x, int y, bool includeThis) const
{
QWidget *w = childAt(x, y);
return w ? w : ((includeThis && rect().contains(x,y))?const_cast<QWidget*>(this):0);
}
inline QT3_SUPPORT QWidget *childAt(const QPoint &p, bool includeThis) const
{
QWidget *w = childAt(p);
return w ? w : ((includeThis && rect().contains(p))?const_cast<QWidget*>(this):0);
}
inline QT3_SUPPORT void setCaption(const QString &c) { setWindowTitle(c); }
QT3_SUPPORT void setIcon(const QPixmap &i);
inline QT3_SUPPORT void setIconText(const QString &it) { setWindowIconText(it); }
inline QT3_SUPPORT QString caption() const { return windowTitle(); }
QT3_SUPPORT const QPixmap *icon() const;
inline QT3_SUPPORT QString iconText() const { return windowIconText(); }
inline QT3_SUPPORT void setInputMethodEnabled(bool b) { setAttribute(Qt::WA_InputMethodEnabled, b); }
inline QT3_SUPPORT bool isInputMethodEnabled() const { return testAttribute(Qt::WA_InputMethodEnabled); }
inline QT3_SUPPORT void setActiveWindow() { activateWindow(); }
inline QT3_SUPPORT bool isShown() const { return !isHidden(); }
inline QT3_SUPPORT bool isDialog() const { return windowType() == Qt::Dialog; }
inline QT3_SUPPORT bool isPopup() const { return windowType() == Qt::Popup; }
inline QT3_SUPPORT bool isDesktop() const { return windowType() == Qt::Desktop; }
private:
void drawText_helper(int x, int y, const QString &);
void erase_helper(int x, int y, int w, int h);
#endif // QT3_SUPPORT
protected:
virtual void styleChange(QStyle&); // compat
virtual void enabledChange(bool); // compat
virtual void paletteChange(const QPalette &); // compat
virtual void fontChange(const QFont &); // compat
virtual void windowActivationChange(bool); // compat
virtual void languageChange(); // compat
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QWidget::RenderFlags)
#if defined Q_CC_MSVC && _MSC_VER < 1300
template <> inline QWidget *qobject_cast_helper<QWidget*>(QObject *o, QWidget *)
{
if (!o || !o->isWidgetType()) return 0;
return (QWidget*)(o);
}
#else
template <> inline QWidget *qobject_cast<QWidget*>(QObject *o)
{
if (!o || !o->isWidgetType()) return 0;
return static_cast<QWidget*>(o);
}
template <> inline const QWidget *qobject_cast<const QWidget*>(const QObject *o)
{
if (!o || !o->isWidgetType()) return 0;
return static_cast<const QWidget*>(o);
}
#endif
inline QWidget *QWidget::childAt(int ax, int ay) const
{ return childAt(QPoint(ax, ay)); }
inline Qt::WindowType QWidget::windowType() const
{ return static_cast<Qt::WindowType>(int(data->window_flags & Qt::WindowType_Mask)); }
inline Qt::WindowFlags QWidget::windowFlags() const
{ return data->window_flags; }
inline bool QWidget::isTopLevel() const
{ return (windowType() & Qt::Window); }
inline bool QWidget::isWindow() const
{ return (windowType() & Qt::Window); }
inline bool QWidget::isEnabled() const
{ return !testAttribute(Qt::WA_Disabled); }
inline bool QWidget::isModal() const
{ return data->window_modality != Qt::NonModal; }
inline bool QWidget::isEnabledToTLW() const
{ return isEnabled(); }
inline int QWidget::minimumWidth() const
{ return minimumSize().width(); }
inline int QWidget::minimumHeight() const
{ return minimumSize().height(); }
inline int QWidget::maximumWidth() const
{ return maximumSize().width(); }
inline int QWidget::maximumHeight() const
{ return maximumSize().height(); }
inline void QWidget::setMinimumSize(const QSize &s)
{ setMinimumSize(s.width(),s.height()); }
inline void QWidget::setMaximumSize(const QSize &s)
{ setMaximumSize(s.width(),s.height()); }
inline void QWidget::setSizeIncrement(const QSize &s)
{ setSizeIncrement(s.width(),s.height()); }
inline void QWidget::setBaseSize(const QSize &s)
{ setBaseSize(s.width(),s.height()); }
inline const QFont &QWidget::font() const
{ return data->fnt; }
inline QFontMetrics QWidget::fontMetrics() const
{ return QFontMetrics(data->fnt); }
inline QFontInfo QWidget::fontInfo() const
{ return QFontInfo(data->fnt); }
inline void QWidget::setMouseTracking(bool enable)
{ setAttribute(Qt::WA_MouseTracking, enable); }
inline bool QWidget::hasMouseTracking() const
{ return testAttribute(Qt::WA_MouseTracking); }
inline bool QWidget::underMouse() const
{ return testAttribute(Qt::WA_UnderMouse); }
inline bool QWidget::updatesEnabled() const
{ return !testAttribute(Qt::WA_UpdatesDisabled); }
inline void QWidget::update(int ax, int ay, int aw, int ah)
{ update(QRect(ax, ay, aw, ah)); }
inline bool QWidget::isVisible() const
{ return testAttribute(Qt::WA_WState_Visible); }
inline bool QWidget::isHidden() const
{ return testAttribute(Qt::WA_WState_Hidden); }
inline void QWidget::move(int ax, int ay)
{ move(QPoint(ax, ay)); }
inline void QWidget::resize(int w, int h)
{ resize(QSize(w, h)); }
inline void QWidget::setGeometry(int ax, int ay, int aw, int ah)
{ setGeometry(QRect(ax, ay, aw, ah)); }
inline QRect QWidget::rect() const
{ return QRect(0,0,data->crect.width(),data->crect.height()); }
inline const QRect &QWidget::geometry() const
{ return data->crect; }
inline QSize QWidget::size() const
{ return data->crect.size(); }
inline int QWidget::width() const
{ return data->crect.width(); }
inline int QWidget::height() const
{ return data->crect.height(); }
inline QWidget *QWidget::parentWidget() const
{ return static_cast<QWidget *>(QObject::parent()); }
inline void QWidget::setSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver)
{ setSizePolicy(QSizePolicy(hor, ver)); }
inline bool QWidget::testAttribute(Qt::WidgetAttribute attribute) const
{
if (attribute < int(8*sizeof(uint)))
return data->widget_attributes & (1<<attribute);
return testAttribute_helper(attribute);
}
#ifdef QT3_SUPPORT
inline bool QWidget::isVisibleToTLW() const
{ return isVisible(); }
inline QWidget *QWidget::parentWidget(bool sameWindow) const
{
if (sameWindow && isWindow())
return 0;
return static_cast<QWidget *>(QObject::parent());
}
inline QColorGroup QWidget::colorGroup() const
{ return QColorGroup(palette()); }
inline void QWidget::setPaletteForegroundColor(const QColor &c)
{ QPalette p = palette(); p.setColor(foregroundRole(), c); setPalette(p); }
inline const QBrush& QWidget::backgroundBrush() const { return palette().brush(backgroundRole()); }
inline void QWidget::setBackgroundPixmap(const QPixmap &pm)
{ QPalette p = palette(); p.setBrush(backgroundRole(), QBrush(pm)); setPalette(p); }
inline const QPixmap *QWidget::backgroundPixmap() const { return 0; }
inline void QWidget::setBackgroundColor(const QColor &c)
{ QPalette p = palette(); p.setColor(backgroundRole(), c); setPalette(p); }
inline const QColor & QWidget::backgroundColor() const { return palette().color(backgroundRole()); }
inline const QColor &QWidget::foregroundColor() const { return palette().color(foregroundRole());}
inline const QColor &QWidget::eraseColor() const { return palette().color(backgroundRole()); }
inline void QWidget::setEraseColor(const QColor &c)
{ QPalette p = palette(); p.setColor(backgroundRole(), c); setPalette(p); }
inline const QPixmap *QWidget::erasePixmap() const { return 0; }
inline void QWidget::setErasePixmap(const QPixmap &pm)
{ QPalette p = palette(); p.setBrush(backgroundRole(), QBrush(pm)); setPalette(p); }
inline const QColor &QWidget::paletteForegroundColor() const { return palette().color(foregroundRole());}
inline const QColor &QWidget::paletteBackgroundColor() const { return palette().color(backgroundRole()); }
inline void QWidget::setPaletteBackgroundColor(const QColor &c)
{ QPalette p = palette(); p.setColor(backgroundRole(), c); setPalette(p); }
inline const QPixmap *QWidget::paletteBackgroundPixmap() const
{ return 0; }
inline void QWidget::setPaletteBackgroundPixmap(const QPixmap &pm)
{ QPalette p = palette(); p.setBrush(backgroundRole(), QBrush(pm)); setPalette(p); }
inline QT3_SUPPORT void QWidget::erase() { erase_helper(0, 0, data->crect.width(), data->crect.height()); }
inline QT3_SUPPORT void QWidget::erase(const QRect &r) { erase_helper(r.x(), r.y(), r.width(), r.height()); }
#endif
#define QWIDGETSIZE_MAX ((1<<24)-1)
QT_END_NAMESPACE
QT_END_HEADER
#endif // QWIDGET_H
| 35.664093 | 127 | 0.730215 |
b8c6fae06665018e05e31d1d7ef6d3fc9620c096 | 14,857 | h | C | src/Engine/MatrixVectorKron/InitKronBase.h | TianyiWang918/dmrgpp | c007840eef1ebf423b6abc6b5b6ca2096ea6eef9 | [
"Unlicense"
] | 24 | 2016-02-22T20:53:19.000Z | 2022-03-17T07:29:32.000Z | src/Engine/MatrixVectorKron/InitKronBase.h | TianyiWang918/dmrgpp | c007840eef1ebf423b6abc6b5b6ca2096ea6eef9 | [
"Unlicense"
] | 31 | 2015-06-29T21:32:33.000Z | 2022-01-06T12:41:31.000Z | src/Engine/MatrixVectorKron/InitKronBase.h | TianyiWang918/dmrgpp | c007840eef1ebf423b6abc6b5b6ca2096ea6eef9 | [
"Unlicense"
] | 18 | 2015-08-13T04:17:47.000Z | 2021-04-27T15:50:23.000Z | /*
Copyright (c) 2009-2017, UT-Battelle, LLC
All rights reserved
[DMRG++, Version 4.]
[by G.A., Oak Ridge National Laboratory]
UT Battelle Open Source Software License 11242008
OPEN SOURCE LICENSE
Subject to the conditions of this License, each
contributor to this software hereby grants, free of
charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), a
perpetual, worldwide, non-exclusive, no-charge,
royalty-free, irrevocable copyright license to use, copy,
modify, merge, publish, distribute, and/or sublicense
copies of the Software.
1. Redistributions of Software must retain the above
copyright and license notices, this list of conditions,
and the following disclaimer. Changes or modifications
to, or derivative works of, the Software should be noted
with comments and the contributor and organization's
name.
2. Neither the names of UT-Battelle, LLC or the
Department of Energy nor the names of the Software
contributors may be used to endorse or promote products
derived from this software without specific prior written
permission of UT-Battelle.
3. The software and the end-user documentation included
with the redistribution, with or without modification,
must include the following acknowledgment:
"This product includes software produced by UT-Battelle,
LLC under Contract No. DE-AC05-00OR22725 with the
Department of Energy."
*********************************************************
DISCLAIMER
THE SOFTWARE IS SUPPLIED 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, CONTRIBUTORS, UNITED STATES GOVERNMENT,
OR THE UNITED STATES DEPARTMENT OF ENERGY 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.
NEITHER THE UNITED STATES GOVERNMENT, NOR THE UNITED
STATES DEPARTMENT OF ENERGY, NOR THE COPYRIGHT OWNER, NOR
ANY OF THEIR EMPLOYEES, REPRESENTS THAT THE USE OF ANY
INFORMATION, DATA, APPARATUS, PRODUCT, OR PROCESS
DISCLOSED WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS.
*********************************************************
*/
/** \ingroup DMRG */
/*@{*/
/*! \file InitKronBase.h
*
*
*/
#ifndef INITKRON_BASE_H
#define INITKRON_BASE_H
#include "ProgramGlobals.h"
#include "ArrayOfMatStruct.h"
#include "Vector.h"
#include "ProgressIndicator.h"
namespace Dmrg {
template<typename LeftRightSuperType>
class InitKronBase {
typedef typename PsimagLite::Vector<bool>::Type VectorBoolType;
public:
typedef typename LeftRightSuperType::SparseMatrixType SparseMatrixType;
typedef typename LeftRightSuperType::RealType RealType;
typedef typename LeftRightSuperType::BasisWithOperatorsType BasisWithOperatorsType;
typedef typename BasisWithOperatorsType::OperatorStorageType OperatorStorageType;
typedef typename SparseMatrixType::value_type ComplexOrRealType;
typedef ArrayOfMatStruct<LeftRightSuperType> ArrayOfMatStructType;
typedef typename ArrayOfMatStructType::MatrixDenseOrSparseType MatrixDenseOrSparseType;
typedef typename LeftRightSuperType::BasisType BasisType;
typedef typename BasisType::QnType QnType;
typedef typename ArrayOfMatStructType::GenIjPatchType GenIjPatchType;
typedef typename PsimagLite::Vector<ArrayOfMatStructType*>::Type VectorArrayOfMatStructType;
typedef typename PsimagLite::Vector<ComplexOrRealType>::Type VectorType;
typedef typename ArrayOfMatStructType::VectorSizeType VectorSizeType;
enum WhatBasisEnum {OLD, NEW};
InitKronBase(const LeftRightSuperType& lrs,
SizeType m,
const QnType& qn,
RealType denseSparseThreshold,
bool useLowerPart)
: progress_("InitKronBase"),
mOld_(m),
mNew_(m),
denseSparseThreshold_(denseSparseThreshold),
useLowerPart_(useLowerPart),
ijpatchesOld_(lrs, qn),
ijpatchesNew_(&ijpatchesOld_),
wftMode_(false)
{
PsimagLite::OstringStream msgg(std::cout.precision());
PsimagLite::OstringStream::OstringStreamType& msg = msgg();
msg<<"::ctor (for H), ";
msg<<"denseSparseThreshold= "<<denseSparseThreshold;
msg<<", useLowerPart= "<<useLowerPart;
progress_.printline(msgg, std::cout);
signsNew_ = lrs.left().signs();
}
~InitKronBase()
{
for (SizeType ic=0;ic<xc_.size();ic++) delete xc_[ic];
for (SizeType ic=0;ic<yc_.size();ic++) delete yc_[ic];
if (wftMode_) {
delete ijpatchesNew_;
ijpatchesNew_ = 0;
}
}
const RealType& denseFlopDiscount() const { return denseSparseThreshold_; }
bool useLowerPart() const { return useLowerPart_; }
const LeftRightSuperType& lrs(WhatBasisEnum what) const
{
return (what == OLD) ? ijpatchesOld_.lrs() : ijpatchesNew_->lrs();
}
const VectorSizeType& patch(WhatBasisEnum what,
typename GenIjPatchType::LeftOrRightEnumType i) const
{
return (what == OLD) ? ijpatchesOld_(i) :
ijpatchesNew_->operator()(i);
}
SizeType offset(WhatBasisEnum what) const
{
return (what == OLD) ? ijpatchesOld_.lrs().super().partition(mOld_) :
ijpatchesNew_->lrs().super().partition(mNew_);
}
const ArrayOfMatStructType& xc(SizeType ic) const
{
assert(ic < xc_.size());
assert(xc_[ic]);
return *xc_[ic];
}
const ArrayOfMatStructType& yc(SizeType ic) const
{
assert(ic < yc_.size());
assert(yc_[ic]);
return *yc_[ic];
}
SizeType connections() const { return xc_.size(); }
SizeType size(WhatBasisEnum what) const
{
return (what == OLD) ? sizeInternal(ijpatchesOld_, mOld_) :
sizeInternal(*ijpatchesNew_, mNew_);
}
const VectorSizeType& weightsOfPatchesNew() const
{
return weightsOfPatches_;
}
void computeOffsets(VectorSizeType& offsetForPatches,
WhatBasisEnum what)
{
assert(patch(what, GenIjPatchType::LEFT).size() ==
patch(what, GenIjPatchType::RIGHT).size());
SizeType npatch = patch(what, GenIjPatchType::LEFT).size();
SizeType sum = 0;
const BasisType& left = lrs(what).left();
const BasisType& right = lrs(what).right();
assert(offsetForPatches.size() == npatch + 1);
for( SizeType ipatch=0; ipatch < npatch; ipatch++) {
offsetForPatches[ipatch] = sum;
SizeType igroup = patch(what, GenIjPatchType::LEFT)[ipatch];
SizeType jgroup = patch(what, GenIjPatchType::RIGHT)[ipatch];
assert(left.partition(igroup+1) >= left.partition(igroup));
SizeType sizeLeft = left.partition(igroup+1) - left.partition(igroup);
assert(right.partition(jgroup+1) >= right.partition(jgroup));
SizeType sizeRight = right.partition(jgroup+1) - right.partition(jgroup);
sum += sizeLeft*sizeRight;
}
offsetForPatches[npatch] = sum;
}
SizeType numberOfPatches(WhatBasisEnum what) const
{
assert(patch(what, GenIjPatchType::LEFT).size() ==
patch(what, GenIjPatchType::RIGHT).size());
return patch(what, GenIjPatchType::LEFT).size();
}
// In production mode this function should be empty
void checks(const MatrixDenseOrSparseType& Amat,
const MatrixDenseOrSparseType& Bmat,
SizeType ipatch,
SizeType jpatch) const
{
#ifndef NDEBUG
SizeType lSizeI = lSizeFunction(NEW, ipatch);
SizeType lSizeJ = lSizeFunction(OLD, jpatch);
SizeType rSizeI = rSizeFunction(NEW, ipatch);
SizeType rSizeJ = rSizeFunction(OLD, jpatch);
assert(Amat.rows() == lSizeI);
assert(Amat.cols() == lSizeJ);
assert(Bmat.rows() == rSizeI);
assert(Bmat.cols() == rSizeJ);
#endif
}
protected:
void addOneConnection(const OperatorStorageType& A,
const OperatorStorageType& B,
const ComplexOrRealType& value,
const ProgramGlobals::FermionOrBosonEnum fermionOrBoson)
{
OperatorStorageType Ahat;
calculateAhat(Ahat.getCRSNonConst(), A.getCRS(), value, fermionOrBoson);
ArrayOfMatStructType* x1 = new ArrayOfMatStructType(Ahat,
ijpatchesOld_,
*ijpatchesNew_,
GenIjPatchType::LEFT,
denseSparseThreshold_,
useLowerPart_);
xc_.push_back(x1);
ArrayOfMatStructType* y1 = new ArrayOfMatStructType(B,
ijpatchesOld_,
*ijpatchesNew_,
GenIjPatchType::RIGHT,
denseSparseThreshold_,
useLowerPart_);
yc_.push_back(y1);
}
// -------------------------------------------
// setup vstart(:) for beginning of each patch
// -------------------------------------------
void setUpVstart(VectorSizeType& vstart, WhatBasisEnum what)
{
SizeType npatches = patch(what, GenIjPatchType::LEFT).size();
assert(npatches > 0);
SizeType ip = 0;
VectorSizeType weights(npatches, 0);
const BasisType& left = lrs(what).left();
const BasisType& right = lrs(what).right();
for (SizeType ipatch=0; ipatch < npatches; ++ipatch) {
vstart[ipatch] = ip;
SizeType igroup = patch(what, GenIjPatchType::LEFT)[ipatch];
SizeType jgroup = patch(what, GenIjPatchType::RIGHT)[ipatch];
assert(left.partition(igroup+1) >= left.partition(igroup));
SizeType sizeLeft = left.partition(igroup+1) - left.partition(igroup);
assert(right.partition(jgroup+1) >= right.partition(jgroup));
SizeType sizeRight = right.partition(jgroup+1) - right.partition(jgroup);
assert(1 <= sizeLeft);
assert(1 <= sizeRight);
weights[ipatch] = sizeLeft * sizeRight * (sizeLeft + sizeRight);
ip += sizeLeft * sizeRight;
}
vstart[npatches] = ip;
if (what == NEW)
setAndFixWeights(weights);
}
// -------------------
// copy xout(:) to vout(:)
// -------------------
void copyOut(VectorType& vout,
const VectorType& xout,
const VectorSizeType& vstart) const
{
const VectorSizeType& permInverse = lrs(NEW).super().permutationInverse();
SizeType offset1 = offset(NEW);
SizeType nl = lrs(NEW).left().hamiltonian().rows();
SizeType npatches = patch(NEW, GenIjPatchType::LEFT).size();
const BasisType& left = lrs(NEW).left();
const BasisType& right = lrs(NEW).right();
for( SizeType ipatch=0; ipatch < npatches; ++ipatch) {
SizeType igroup = patch(NEW, GenIjPatchType::LEFT)[ipatch];
SizeType jgroup = patch(NEW, GenIjPatchType::RIGHT)[ipatch];
assert(left.partition(igroup+1) >= left.partition(igroup));
SizeType sizeLeft = left.partition(igroup+1) - left.partition(igroup);
assert(right.partition(jgroup+1) >= right.partition(jgroup));
SizeType sizeRight = right.partition(jgroup+1) - right.partition(jgroup);
SizeType left_offset = left.partition(igroup);
SizeType right_offset = right.partition(jgroup);
for (SizeType ileft=0; ileft < sizeLeft; ++ileft) {
for (SizeType iright=0; iright < sizeRight; ++iright) {
SizeType i = ileft + left_offset;
SizeType j = iright + right_offset;
assert(i < nl);
assert(j < lrs(NEW).right().hamiltonian().rows());
assert(i + j*nl < permInverse.size());
SizeType r = permInverse[i + j*nl];
assert( !( (r < offset1) || (r >= (offset1 + size(NEW))) ) );
SizeType ip = vstart[ipatch] + (iright + ileft * sizeRight);
assert(ip < xout.size());
assert(r >= offset1 && ((r - offset1) < vout.size()) );
vout[r-offset1] = xout[ip];
}
}
}
}
private:
void setAndFixWeights(const VectorSizeType& weights)
{
long unsigned int max = *(std::max_element(weights.begin(), weights.end()));
max >>= 31;
SizeType bits = 1 + PsimagLite::log2Integer(max);
SizeType npatches = weights.size();
weightsOfPatches_.resize(npatches);
for (SizeType ipatch=0; ipatch < npatches; ++ipatch) {
long unsigned int tmp = (weights[ipatch] >> bits);
weightsOfPatches_[ipatch] = (max == 0) ? weights[ipatch] : tmp;
}
}
static SizeType sizeInternal(const GenIjPatchType& ijpatches,
SizeType m)
{
assert(ijpatches.lrs().super().partition(m + 1) >=
ijpatches.lrs().super().partition(m));
return ijpatches.lrs().super().partition(m + 1) -
ijpatches.lrs().super().partition(m);
}
static void cacheSigns(VectorBoolType& signs, const VectorSizeType& electrons)
{
signs.resize(electrons.size(), false);
for (SizeType i = 0; i < electrons.size(); ++i)
signs[i] = (electrons[i] & 1) ? true : false;
}
// Ahat(ia,ja) = (-1)^e_L(ia) A(ia,ja)*value
void calculateAhat(SparseMatrixType& Ahat,
const SparseMatrixType& A,
ComplexOrRealType val,
ProgramGlobals::FermionOrBosonEnum bosonOrFermion) const
{
Ahat = A;
SizeType rows = Ahat.rows();
assert(signsNew_.size() >= rows);
SizeType counter = 0;
for (SizeType i = 0; i < rows; ++i) {
RealType sign = (bosonOrFermion == ProgramGlobals::FermionOrBosonEnum::FERMION &&
signsNew_[i]) ? -1.0 : 1.0;
for (int k = Ahat.getRowPtr(i); k < Ahat.getRowPtr(i+1); ++k) {
ComplexOrRealType tmp = Ahat.getValue(k)*sign*val;
Ahat.setValues(counter++, tmp);
}
}
}
SizeType lSizeFunction(WhatBasisEnum what,
SizeType ipatch) const
{
SizeType igroup = patch(what, GenIjPatchType::LEFT)[ipatch];
return lrs(what).left().partition(igroup+1) -
lrs(what).left().partition(igroup);
}
SizeType rSizeFunction(WhatBasisEnum what,
SizeType ipatch) const
{
SizeType jgroup = patch(what, GenIjPatchType::RIGHT)[ipatch];
return lrs(what).right().partition(jgroup+1) -
lrs(what).right().partition(jgroup);
}
InitKronBase(const InitKronBase&);
InitKronBase& operator=(const InitKronBase&);
PsimagLite::ProgressIndicator progress_;
SizeType mOld_;
SizeType mNew_;
const RealType denseSparseThreshold_;
const bool useLowerPart_;
GenIjPatchType ijpatchesOld_;
GenIjPatchType* ijpatchesNew_;
VectorSizeType weightsOfPatches_;
VectorArrayOfMatStructType xc_;
VectorArrayOfMatStructType yc_;
VectorBoolType signsNew_;
bool wftMode_;
};
} // namespace Dmrg
#endif // INITKRON_BASE_H
| 32.796909 | 93 | 0.669314 |
983804efbc77639240858fee0d0a2ea1e4fd89c4 | 2,200 | c | C | sys/fork.c | wmoczulsky/mimiker | de6511df5aeeddaab2cfffa4a7fbbf27d9f4c08a | [
"BSD-3-Clause"
] | null | null | null | sys/fork.c | wmoczulsky/mimiker | de6511df5aeeddaab2cfffa4a7fbbf27d9f4c08a | [
"BSD-3-Clause"
] | null | null | null | sys/fork.c | wmoczulsky/mimiker | de6511df5aeeddaab2cfffa4a7fbbf27d9f4c08a | [
"BSD-3-Clause"
] | null | null | null | #include <fork.h>
#include <thread.h>
#include <filedesc.h>
#include <sched.h>
#include <stdc.h>
#include <vm_map.h>
#include <proc.h>
#include <sbrk.h>
int do_fork(void) {
thread_t *td = thread_self();
/* Cannot fork non-user threads. */
assert(td->td_proc);
thread_t *newtd = thread_create(td->td_name, NULL, NULL);
/* Clone the thread. Since we don't use fork-oriented thread_t layout, we copy
all necessary fields one-by one for clarity. The new thread is already on
the all_thread list, has name and tid set. Many fields don't require setup
as they will be prepared by sched_add. */
assert(td->td_idnest == 0);
newtd->td_idnest = 0;
/* Copy user context.. */
newtd->td_uctx = td->td_uctx;
newtd->td_uctx_fpu = td->td_uctx_fpu;
exc_frame_set_retval(&newtd->td_uctx, 0);
/* New thread does not need the exception frame just yet. */
newtd->td_kframe = NULL;
newtd->td_onfault = 0;
/* The new thread already has a new kernel stack allocated. There is no need
to copy its contents, it will be discarded anyway. We just prepare the
thread's kernel context to a fresh one so that it will continue execution
starting from user_exc_leave (which serves as fork_trampoline). */
ctx_init(newtd, (void (*)(void *))user_exc_leave, NULL);
newtd->td_sleepqueue = sleepq_alloc();
newtd->td_wchan = NULL;
newtd->td_waitpt = NULL;
newtd->td_prio = td->td_prio;
/* Now, prepare a new process. */
assert(td->td_proc);
proc_t *proc = proc_create();
proc->p_parent = td->td_proc;
TAILQ_INSERT_TAIL(&td->td_proc->p_children, proc, p_child);
proc_populate(proc, newtd);
/* Clone the entire process memory space. */
proc->p_uspace = vm_map_clone(td->td_proc->p_uspace);
/* Find copied brk segment. */
proc->p_sbrk = vm_map_find_entry(proc->p_uspace, SBRK_START);
/* Copy the parent descriptor table. */
/* TODO: Optionally share the descriptor table between processes. */
proc->p_fdtable = fdtab_copy(td->td_proc->p_fdtable);
/* Copy signal handler dispatch rules. */
memcpy(proc->p_sigactions, td->td_proc->p_sigactions,
sizeof(proc->p_sigactions));
sched_add(newtd);
return proc->p_pid;
}
| 30.555556 | 80 | 0.695 |
c25c6b346ddc3da1463669447feb7a10b45a362f | 8,492 | c | C | sources/nb/geometric_bot/mesh/mesh2D/elements2D/trg_exporter.c | vecn/nbots | bda4f5a2c607c8e6d26567bb0865ccbb953418ac | [
"MIT"
] | 7 | 2016-02-09T17:53:25.000Z | 2019-09-19T02:02:14.000Z | sources/nb/geometric_bot/mesh/mesh2D/elements2D/trg_exporter.c | vecn/nbots | bda4f5a2c607c8e6d26567bb0865ccbb953418ac | [
"MIT"
] | 1 | 2017-06-22T06:20:24.000Z | 2017-06-22T06:20:24.000Z | sources/nb/geometric_bot/mesh/mesh2D/elements2D/trg_exporter.c | vecn/nbots | bda4f5a2c607c8e6d26567bb0865ccbb953418ac | [
"MIT"
] | 2 | 2018-02-08T12:09:50.000Z | 2019-09-19T02:02:23.000Z | #include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "nb/memory_bot.h"
#include "nb/container_bot.h"
#include "nb/geometric_bot/knn/bins2D.h"
#include "nb/geometric_bot/knn/bins2D_iterator.h"
#include "nb/geometric_bot/mesh/mesh2D/elements2D/trg_exporter.h"
#include "../../tessellator2D_structs.h"
static void export_vertices(const nb_tessellator2D_t *const mesh,
nb_trg_exporter_interface_t *exp);
static void export_edges(const nb_tessellator2D_t *const mesh,
nb_trg_exporter_interface_t *exp);
static void export_and_enumerate_trg(nb_tessellator2D_t *mesh,
nb_trg_exporter_interface_t *exp);
static void export_trg_neighbours(const nb_tessellator2D_t *const mesh,
nb_trg_exporter_interface_t *exp);
static void export_input_vtx(const nb_tessellator2D_t *const mesh,
nb_trg_exporter_interface_t *exp);
static void export_input_sgm(const nb_tessellator2D_t *const mesh,
nb_trg_exporter_interface_t * exp);
static void set_input_sgm_table(const nb_tessellator2D_t *const restrict mesh,
nb_trg_exporter_interface_t * restrict exp);
static void set_input_sgm(const nb_tessellator2D_t *const restrict mesh,
nb_trg_exporter_interface_t * restrict exp,
uint32_t isgm);
void nb_tessellator2D_export(const nb_tessellator2D_t *const mesh,
nb_trg_exporter_interface_t *exp)
{
if (nb_bins2D_is_empty(mesh->ug_vtx))
goto EXIT;
mesh_enumerate_vtx((nb_tessellator2D_t*)mesh);
export_vertices(mesh, exp);
if (NULL != exp->set_N_edg) {
if (nb_container_is_not_empty(mesh->ht_edge))
export_edges(mesh, exp);
}
if (NULL != exp->set_N_trg) {
if (nb_container_is_not_empty(mesh->ht_trg)) {
export_and_enumerate_trg((nb_tessellator2D_t*)mesh, exp);
if (NULL != exp->set_trg_neighbours)
export_trg_neighbours(mesh, exp);
}
}
if (NULL != exp->set_N_input_vtx)
export_input_vtx(mesh, exp);
if (NULL != exp->set_N_input_sgm) {
if (mesh->N_input_sgm > 0)
export_input_sgm(mesh, exp);
}
EXIT:
return;
}
static void export_vertices(const nb_tessellator2D_t *const restrict mesh,
nb_trg_exporter_interface_t * restrict exp)
{
uint32_t N_vtx = nb_bins2D_get_length(mesh->ug_vtx);
exp->set_N_vtx(exp->structure, N_vtx);
exp->allocate_vtx(exp->structure);
exp->start_vtx_access(exp->structure);
nb_bins2D_iter_t* iter = nb_allocate_on_stack(nb_bins2D_iter_get_memsize());
nb_bins2D_iter_init(iter);
nb_bins2D_iter_set_bins(iter, mesh->ug_vtx);
while (nb_bins2D_iter_has_more(iter)) {
const msh_vtx_t* vtx = nb_bins2D_iter_get_next(iter);
uint32_t id = mvtx_get_id(vtx);
double x = vtx->x[0]/mesh->scale + mesh->xdisp;
double y = vtx->x[1]/mesh->scale + mesh->ydisp;
exp->set_vtx(exp->structure, id, x, y);
}
nb_bins2D_iter_finish(iter);
exp->stop_vtx_access(exp->structure);
}
static void export_edges(const nb_tessellator2D_t *const restrict mesh,
nb_trg_exporter_interface_t * restrict exp)
{
uint32_t N_edg = nb_container_get_length(mesh->ht_edge);
exp->set_N_edg(exp->structure, N_edg);
exp->allocate_edg(exp->structure);
exp->start_edg_access(exp->structure);
uint32_t i = 0;
nb_iterator_t *iter = nb_allocate_on_stack(nb_iterator_get_memsize());
nb_iterator_init(iter);
nb_iterator_set_container(iter, mesh->ht_edge);
while (nb_iterator_has_more(iter)) {
msh_edge_t *edge = (msh_edge_t*) nb_iterator_get_next(iter);
uint32_t v1 = mvtx_get_id(edge->v1);
uint32_t v2 = mvtx_get_id(edge->v2);
exp->set_edg(exp->structure, i, v1, v2);
i += 1;
}
nb_iterator_finish(iter);
exp->stop_edg_access(exp->structure);
}
static void export_and_enumerate_trg(nb_tessellator2D_t *mesh,
nb_trg_exporter_interface_t *exp)
{
uint32_t N_trg = nb_container_get_length(mesh->ht_trg);
exp->set_N_trg(exp->structure, N_trg);
bool include_neighbours = (NULL != exp->set_trg_neighbours);
exp->allocate_trg(exp->structure, include_neighbours);
exp->start_trg_access(exp->structure);
nb_iterator_t* trg_iter = nb_allocate_on_stack(nb_iterator_get_memsize());
nb_iterator_init(trg_iter);
nb_iterator_set_container(trg_iter, mesh->ht_trg);
uint32_t i = 0;
while (nb_iterator_has_more(trg_iter)) {
msh_trg_t* trg = (msh_trg_t*)nb_iterator_get_next(trg_iter);
uint32_t v1 = mvtx_get_id(trg->v1);
uint32_t v2 = mvtx_get_id(trg->v2);
uint32_t v3 = mvtx_get_id(trg->v3);
exp->set_trg(exp->structure, i, v1, v2, v3);
trg->id = i;
i++;
}
nb_iterator_finish(trg_iter);
exp->stop_trg_access(exp->structure);
}
static void export_trg_neighbours(const nb_tessellator2D_t *const restrict mesh,
nb_trg_exporter_interface_t * restrict exp)
{
exp->start_trg_neighbours_access(exp->structure);
nb_iterator_t* trg_iter = nb_allocate_on_stack(nb_iterator_get_memsize());
nb_iterator_init(trg_iter);
nb_iterator_set_container(trg_iter, mesh->ht_trg);
while (nb_iterator_has_more(trg_iter)) {
msh_trg_t* trg = (msh_trg_t*)nb_iterator_get_next(trg_iter);
uint32_t id = trg->id;
uint32_t t1 = nb_tessellator2D_get_N_trg(mesh);
if (NULL != trg->t1)
t1 = trg->t1->id;
uint32_t t2 = nb_tessellator2D_get_N_trg(mesh);
if (NULL != trg->t2)
t2 = trg->t2->id;
uint32_t t3 = nb_tessellator2D_get_N_trg(mesh);
if (NULL != trg->t3)
t3 = trg->t3->id;
exp->set_trg_neighbours(exp->structure, id, t1, t2, t3);
}
nb_iterator_finish(trg_iter);
exp->stop_trg_neighbours_access(exp->structure);
}
static void export_input_vtx(const nb_tessellator2D_t *const restrict mesh,
nb_trg_exporter_interface_t * restrict exp)
{
uint32_t N_vtx = mesh->N_input_vtx;
exp->set_N_input_vtx(exp->structure, N_vtx);
exp->allocate_input_vtx(exp->structure);
exp->start_input_vtx_access(exp->structure);
for (uint32_t i = 0; i < N_vtx; i++) {
uint32_t vtx_id;
if (NULL == mesh->input_vtx[i])
vtx_id = nb_tessellator2D_get_N_vtx(mesh);
else
vtx_id = mvtx_get_id(mesh->input_vtx[i]);
exp->set_input_vtx(exp->structure, i, vtx_id);
}
exp->stop_input_vtx_access(exp->structure);
}
static void export_input_sgm(const nb_tessellator2D_t *const restrict mesh,
nb_trg_exporter_interface_t * restrict exp)
{
uint32_t N_sgm = mesh->N_input_sgm;
exp->set_N_input_sgm(exp->structure, N_sgm);
exp->allocate_input_sgm_table(exp->structure);
exp->start_input_sgm_table_access(exp->structure);
set_input_sgm_table(mesh, exp);
for (uint32_t i = 0; i < N_sgm; i++) {
if (NULL != mesh->input_sgm[i]) {
exp->input_sgm_start_access(exp->structure, i);
set_input_sgm(mesh, exp, i);
exp->input_sgm_stop_access(exp->structure);
}
}
exp->stop_input_sgm_table_access(exp->structure);
}
static void set_input_sgm_table(const nb_tessellator2D_t *const restrict mesh,
nb_trg_exporter_interface_t * restrict exp)
{
for (uint32_t i = 0; i < mesh->N_input_sgm; i++) {
msh_edge_t* sgm = mesh->input_sgm[i];
uint32_t counter = 0;
while (NULL != sgm) {
counter++;
sgm = medge_subsgm_next(sgm);
}
if (0 < counter) {
exp->input_sgm_set_N_vtx(exp->structure, i, counter + 1);
exp->input_sgm_allocate_vtx(exp->structure, i);
} else {
exp->input_sgm_set_N_vtx(exp->structure, i, 0);
}
}
}
static void set_input_sgm(const nb_tessellator2D_t *const restrict mesh,
nb_trg_exporter_interface_t * restrict exp,
uint32_t isgm)
{
msh_edge_t* sgm = mesh->input_sgm[isgm];
msh_edge_t* sgm_prev = sgm;
sgm = medge_subsgm_next(sgm);
if (NULL == sgm) {
exp->input_sgm_set_vtx(exp->structure, 0,
mvtx_get_id(sgm_prev->v1));
exp->input_sgm_set_vtx(exp->structure, 1,
mvtx_get_id(sgm_prev->v2));
} else {
uint32_t idx = 0;
uint32_t id_chain;
uint32_t id1 = mvtx_get_id(sgm_prev->v1);
uint32_t id2 = mvtx_get_id(sgm_prev->v2);
uint32_t id1n = mvtx_get_id(sgm->v1);
uint32_t id2n = mvtx_get_id(sgm->v2);
if (id2 == id1n || id2 == id2n) {
exp->input_sgm_set_vtx(exp->structure, idx++, id1);
exp->input_sgm_set_vtx(exp->structure, idx++, id2);
id_chain = id2;
} else {
exp->input_sgm_set_vtx(exp->structure, idx++, id2);
exp->input_sgm_set_vtx(exp->structure, idx++, id1);
id_chain = id1;
}
while (NULL != sgm) {
sgm_prev = sgm;
uint32_t id1 = mvtx_get_id(sgm_prev->v1);
uint32_t id2 = mvtx_get_id(sgm_prev->v2);
if (id1 == id_chain) {
exp->input_sgm_set_vtx(exp->structure,
idx++, id2);
id_chain = id2;
} else {
exp->input_sgm_set_vtx(exp->structure,
idx++, id1);
id_chain = id1;
}
sgm = medge_subsgm_next(sgm);
}
}
}
| 30.768116 | 80 | 0.727862 |
ccf84574d4d592ed1274bd530ba2de3a581632bf | 8,149 | h | C | aws-cpp-sdk-quicksight/include/aws/quicksight/model/GenerateEmbedUrlForRegisteredUserRequest.h | perfectrecall/aws-sdk-cpp | fb8cbebf2fd62720b65aeff841ad2950e73d8ebd | [
"Apache-2.0"
] | 1 | 2022-02-10T08:06:54.000Z | 2022-02-10T08:06:54.000Z | aws-cpp-sdk-quicksight/include/aws/quicksight/model/GenerateEmbedUrlForRegisteredUserRequest.h | perfectrecall/aws-sdk-cpp | fb8cbebf2fd62720b65aeff841ad2950e73d8ebd | [
"Apache-2.0"
] | 1 | 2021-10-14T16:57:00.000Z | 2021-10-18T10:47:24.000Z | aws-cpp-sdk-quicksight/include/aws/quicksight/model/GenerateEmbedUrlForRegisteredUserRequest.h | ravindra-wagh/aws-sdk-cpp | 7d5ff01b3c3b872f31ca98fb4ce868cd01e97696 | [
"Apache-2.0"
] | 1 | 2021-11-09T11:58:03.000Z | 2021-11-09T11:58:03.000Z | /**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/quicksight/QuickSight_EXPORTS.h>
#include <aws/quicksight/QuickSightRequest.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/quicksight/model/RegisteredUserEmbeddingExperienceConfiguration.h>
#include <utility>
namespace Aws
{
namespace QuickSight
{
namespace Model
{
/**
*/
class AWS_QUICKSIGHT_API GenerateEmbedUrlForRegisteredUserRequest : public QuickSightRequest
{
public:
GenerateEmbedUrlForRegisteredUserRequest();
// Service request name is the Operation name which will send this request out,
// each operation should has unique request name, so that we can get operation's name from this request.
// Note: this is not true for response, multiple operations may have the same response name,
// so we can not get operation's name from response.
inline virtual const char* GetServiceRequestName() const override { return "GenerateEmbedUrlForRegisteredUser"; }
Aws::String SerializePayload() const override;
/**
* <p>The ID for the Amazon Web Services account that contains the dashboard that
* you're embedding.</p>
*/
inline const Aws::String& GetAwsAccountId() const{ return m_awsAccountId; }
/**
* <p>The ID for the Amazon Web Services account that contains the dashboard that
* you're embedding.</p>
*/
inline bool AwsAccountIdHasBeenSet() const { return m_awsAccountIdHasBeenSet; }
/**
* <p>The ID for the Amazon Web Services account that contains the dashboard that
* you're embedding.</p>
*/
inline void SetAwsAccountId(const Aws::String& value) { m_awsAccountIdHasBeenSet = true; m_awsAccountId = value; }
/**
* <p>The ID for the Amazon Web Services account that contains the dashboard that
* you're embedding.</p>
*/
inline void SetAwsAccountId(Aws::String&& value) { m_awsAccountIdHasBeenSet = true; m_awsAccountId = std::move(value); }
/**
* <p>The ID for the Amazon Web Services account that contains the dashboard that
* you're embedding.</p>
*/
inline void SetAwsAccountId(const char* value) { m_awsAccountIdHasBeenSet = true; m_awsAccountId.assign(value); }
/**
* <p>The ID for the Amazon Web Services account that contains the dashboard that
* you're embedding.</p>
*/
inline GenerateEmbedUrlForRegisteredUserRequest& WithAwsAccountId(const Aws::String& value) { SetAwsAccountId(value); return *this;}
/**
* <p>The ID for the Amazon Web Services account that contains the dashboard that
* you're embedding.</p>
*/
inline GenerateEmbedUrlForRegisteredUserRequest& WithAwsAccountId(Aws::String&& value) { SetAwsAccountId(std::move(value)); return *this;}
/**
* <p>The ID for the Amazon Web Services account that contains the dashboard that
* you're embedding.</p>
*/
inline GenerateEmbedUrlForRegisteredUserRequest& WithAwsAccountId(const char* value) { SetAwsAccountId(value); return *this;}
/**
* <p>How many minutes the session is valid. The session lifetime must be in
* [15-600] minutes range.</p>
*/
inline long long GetSessionLifetimeInMinutes() const{ return m_sessionLifetimeInMinutes; }
/**
* <p>How many minutes the session is valid. The session lifetime must be in
* [15-600] minutes range.</p>
*/
inline bool SessionLifetimeInMinutesHasBeenSet() const { return m_sessionLifetimeInMinutesHasBeenSet; }
/**
* <p>How many minutes the session is valid. The session lifetime must be in
* [15-600] minutes range.</p>
*/
inline void SetSessionLifetimeInMinutes(long long value) { m_sessionLifetimeInMinutesHasBeenSet = true; m_sessionLifetimeInMinutes = value; }
/**
* <p>How many minutes the session is valid. The session lifetime must be in
* [15-600] minutes range.</p>
*/
inline GenerateEmbedUrlForRegisteredUserRequest& WithSessionLifetimeInMinutes(long long value) { SetSessionLifetimeInMinutes(value); return *this;}
/**
* <p>The Amazon Resource Name for the registered user.</p>
*/
inline const Aws::String& GetUserArn() const{ return m_userArn; }
/**
* <p>The Amazon Resource Name for the registered user.</p>
*/
inline bool UserArnHasBeenSet() const { return m_userArnHasBeenSet; }
/**
* <p>The Amazon Resource Name for the registered user.</p>
*/
inline void SetUserArn(const Aws::String& value) { m_userArnHasBeenSet = true; m_userArn = value; }
/**
* <p>The Amazon Resource Name for the registered user.</p>
*/
inline void SetUserArn(Aws::String&& value) { m_userArnHasBeenSet = true; m_userArn = std::move(value); }
/**
* <p>The Amazon Resource Name for the registered user.</p>
*/
inline void SetUserArn(const char* value) { m_userArnHasBeenSet = true; m_userArn.assign(value); }
/**
* <p>The Amazon Resource Name for the registered user.</p>
*/
inline GenerateEmbedUrlForRegisteredUserRequest& WithUserArn(const Aws::String& value) { SetUserArn(value); return *this;}
/**
* <p>The Amazon Resource Name for the registered user.</p>
*/
inline GenerateEmbedUrlForRegisteredUserRequest& WithUserArn(Aws::String&& value) { SetUserArn(std::move(value)); return *this;}
/**
* <p>The Amazon Resource Name for the registered user.</p>
*/
inline GenerateEmbedUrlForRegisteredUserRequest& WithUserArn(const char* value) { SetUserArn(value); return *this;}
/**
* <p>The experience you are embedding. For registered users, you can embed Amazon
* QuickSight dashboards or the entire Amazon QuickSight console.</p>
*/
inline const RegisteredUserEmbeddingExperienceConfiguration& GetExperienceConfiguration() const{ return m_experienceConfiguration; }
/**
* <p>The experience you are embedding. For registered users, you can embed Amazon
* QuickSight dashboards or the entire Amazon QuickSight console.</p>
*/
inline bool ExperienceConfigurationHasBeenSet() const { return m_experienceConfigurationHasBeenSet; }
/**
* <p>The experience you are embedding. For registered users, you can embed Amazon
* QuickSight dashboards or the entire Amazon QuickSight console.</p>
*/
inline void SetExperienceConfiguration(const RegisteredUserEmbeddingExperienceConfiguration& value) { m_experienceConfigurationHasBeenSet = true; m_experienceConfiguration = value; }
/**
* <p>The experience you are embedding. For registered users, you can embed Amazon
* QuickSight dashboards or the entire Amazon QuickSight console.</p>
*/
inline void SetExperienceConfiguration(RegisteredUserEmbeddingExperienceConfiguration&& value) { m_experienceConfigurationHasBeenSet = true; m_experienceConfiguration = std::move(value); }
/**
* <p>The experience you are embedding. For registered users, you can embed Amazon
* QuickSight dashboards or the entire Amazon QuickSight console.</p>
*/
inline GenerateEmbedUrlForRegisteredUserRequest& WithExperienceConfiguration(const RegisteredUserEmbeddingExperienceConfiguration& value) { SetExperienceConfiguration(value); return *this;}
/**
* <p>The experience you are embedding. For registered users, you can embed Amazon
* QuickSight dashboards or the entire Amazon QuickSight console.</p>
*/
inline GenerateEmbedUrlForRegisteredUserRequest& WithExperienceConfiguration(RegisteredUserEmbeddingExperienceConfiguration&& value) { SetExperienceConfiguration(std::move(value)); return *this;}
private:
Aws::String m_awsAccountId;
bool m_awsAccountIdHasBeenSet;
long long m_sessionLifetimeInMinutes;
bool m_sessionLifetimeInMinutesHasBeenSet;
Aws::String m_userArn;
bool m_userArnHasBeenSet;
RegisteredUserEmbeddingExperienceConfiguration m_experienceConfiguration;
bool m_experienceConfigurationHasBeenSet;
};
} // namespace Model
} // namespace QuickSight
} // namespace Aws
| 39.75122 | 199 | 0.717266 |
f9d36edb774c2d4fe4cb1e151cebb70fd12f7750 | 7,583 | h | C | platform/gucefDRN/include/gucefDRN_CDRNDataGroup.h | amvb/GUCEF | 08fd423bbb5cdebbe4b70df24c0ae51716b65825 | [
"Apache-2.0"
] | 5 | 2016-04-18T23:12:51.000Z | 2022-03-06T05:12:07.000Z | platform/gucefDRN/include/gucefDRN_CDRNDataGroup.h | amvb/GUCEF | 08fd423bbb5cdebbe4b70df24c0ae51716b65825 | [
"Apache-2.0"
] | 2 | 2015-10-09T19:13:25.000Z | 2018-12-25T17:16:54.000Z | platform/gucefDRN/include/gucefDRN_CDRNDataGroup.h | amvb/GUCEF | 08fd423bbb5cdebbe4b70df24c0ae51716b65825 | [
"Apache-2.0"
] | 15 | 2015-02-23T16:35:28.000Z | 2022-03-25T13:40:33.000Z | /*
* gucefDRN: GUCEF module providing RAD networking trough data replication
* Copyright (C) 2002 - 2007. Dinand Vanvelzen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef GUCEF_DRN_CDRNDATAGROUP_H
#define GUCEF_DRN_CDRNDATAGROUP_H
/*-------------------------------------------------------------------------//
// //
// INCLUDES //
// //
//-------------------------------------------------------------------------*/
#include <map>
#ifndef GUCEF_CORE_CISTREAMABLE_H
#include "CIStreamable.h"
#define GUCEF_CORE_CISTREAMABLE_H
#endif /* GUCEF_CORE_CISTREAMABLE_H ? */
#ifndef GUCEF_CORE_CEVENT_H
#include "CEvent.h"
#define GUCEF_CORE_CEVENT_H
#endif /* GUCEF_CORE_CEVENT_H ? */
#ifndef GUCEF_CORE_COBSERVINGNOTIFIER_H
#include "CObservingNotifier.h"
#define GUCEF_CORE_COBSERVINGNOTIFIER_H
#endif /* GUCEF_CORE_COBSERVINGNOTIFIER_H ? */
#ifndef GUCEF_CORE_CTSHAREDPTR_H
#include "CTSharedPtr.h"
#define GUCEF_CORE_CTSHAREDPTR_H
#endif /* GUCEF_CORE_CTSHAREDPTR_H ? */
#ifndef GUCEF_CORE_CTCLONEABLEOBJ_H
#include "CTCloneableObj.h"
#define GUCEF_CORE_CTCLONEABLEOBJ_H
#endif /* GUCEF_CORE_CTCLONEABLEOBJ_H ? */
#ifndef GUCEF_DRN_CDRNDATAGROUPPROPERTIES_H
#include "gucefDRN_CDRNDataGroupProperties.h"
#define GUCEF_DRN_CDRNDATAGROUPPROPERTIES_H
#endif /* GUCEF_DRN_CDRNDATAGROUPPROPERTIES_H ? */
#ifndef GUCEF_DRN_MACROS_H
#include "gucefDRN_macros.h"
#define GUCEF_DRN_MACROS_H
#endif /* GUCEF_DRN_MACROS_H ? */
/*-------------------------------------------------------------------------//
// //
// NAMESPACE //
// //
//-------------------------------------------------------------------------*/
namespace GUCEF {
namespace DRN {
/*-------------------------------------------------------------------------//
// //
// CLASSES //
// //
//-------------------------------------------------------------------------*/
/**
* Data holder for a DRN data group.
* It groups data that can be processed according to the DRN settings of this
* class.
* It is capable of handling GUCEF::CORE::CStreamerEvents::StreamEvent if so desired
* Depending on the settings streamed data can be processed as part of a DRN group
* Note that for StreamEvent to be accepted it will have to have an ID.
*/
class GUCEF_DRN_EXPORT_CPP CDRNDataGroup : public CORE::CObservingNotifier
{
public:
static const CORE::CEvent ItemAddedEvent;
static const CORE::CEvent ItemChangedEvent;
static const CORE::CEvent ItemRemovedEvent;
struct ItemEntry
{
const CORE::CDynamicBuffer* id;
const CORE::CDynamicBuffer* data;
};
typedef CORE::CTCloneableObj< struct ItemEntry > ItemAddedEventData;
typedef CORE::CTCloneableObj< struct ItemEntry > ItemChangedEventData;
typedef CORE::CTCloneableObj< struct ItemEntry > ItemRemovedEventData;
static void RegisterEvents( void );
public:
typedef CORE::CTSharedPtr< CDRNDataGroupProperties, MT::CMutex > CDRNDataGroupPropertiesPtr;
CDRNDataGroup( const CORE::CString& groupName );
virtual ~CDRNDataGroup();
const CORE::CString& GetName( void ) const;
void SetGroupProperties( const CDRNDataGroupPropertiesPtr& properties );
CDRNDataGroupPropertiesPtr GetGroupProperties( void ) const;
bool SetItem( const CORE::CDynamicBuffer& id ,
const CORE::CDynamicBuffer& data ,
const bool addIfNotFound = true );
bool GetItem( const CORE::CDynamicBuffer& id ,
CORE::CDynamicBuffer& data ) const;
bool HasItem( const CORE::CDynamicBuffer& id ) const;
/**
* Attempts to locate and then remove the item with the given ID
* if the item is not found false is returned
*/
bool RemoveItem( const CORE::CDynamicBuffer& id );
UInt32 GetItemCount( void ) const;
bool GetIDAndDataAtIndex( const UInt32 index ,
const CORE::CDynamicBuffer** id ,
const CORE::CDynamicBuffer** data ) const;
protected:
/**
* @param notifier the notifier that sent the notification
* @param eventid the unique event id for an event
* @param eventdata optional notifier defined userdata
*/
virtual void OnNotify( CORE::CNotifier* notifier ,
const CORE::CEvent& eventid ,
CORE::CICloneable* eventdata = NULL );
private:
CDRNDataGroup( void ); /**< not possible */
CDRNDataGroup( const CDRNDataGroup& src ); /**< not allowed at this time */
CDRNDataGroup& operator=( const CDRNDataGroup& src ); /**< not allowed at this time */
private:
typedef std::map< CORE::CDynamicBuffer, CORE::CDynamicBuffer > TDataMap;
CDRNDataGroupPropertiesPtr m_properties;
CORE::CString m_groupName;
TDataMap m_dataMap;
};
/*-------------------------------------------------------------------------//
// //
// NAMESPACE //
// //
//-------------------------------------------------------------------------*/
}; /* namespace DRN */
}; /* namespace GUCEF */
/*-------------------------------------------------------------------------*/
#endif /* GUCEF_DRN_CDRNDATAGROUP_H ? */
/*-------------------------------------------------------------------------//
// //
// Info & Changes //
// //
//-------------------------------------------------------------------------//
- 02-03-2007 :
- Dinand: re-added this header
-----------------------------------------------------------------------------*/
| 39.494792 | 97 | 0.485824 |
74f570d5cf69925877ffc645a910c04cd974c947 | 685 | c | C | d/islands/carcosa/rooms/car6.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-07-19T05:24:44.000Z | 2021-11-18T04:08:19.000Z | d/islands/carcosa/rooms/car6.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 4 | 2021-03-15T18:56:39.000Z | 2021-08-17T17:08:22.000Z | d/islands/carcosa/rooms/car6.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-09-12T06:22:38.000Z | 2022-01-31T01:15:12.000Z | inherit "/std/room.c";
void create() {
::create();
set_property("indoors",0);
set_property("light",2);
set("short","The Isle of Carcosa");
set("long",
@LUCIFER
You are standing on the Isle of Carcosa.
You can see a river in the distance to the north and the fork
is now to youe south.
LUCIFER
);
set_smell("default","The smell of rotting flesh overwhelms your senses.");
set_listen("default","You hear the chanting louldly now.");
set_listen("chanting","Religous chanting fills your head.\n"+
"You find it hard to ignore.\n");
set_exits((["north":"/d/islands/carcosa/rooms/car7.c",
"south":"/d/islands/carcosa/rooms/car5.c"]));
}
| 29.782609 | 76 | 0.659854 |
25e709477ea1ec18657125e7bfd6fc2c3cb01e35 | 885 | c | C | res/window_map_legs_2.c | bbbbbr/gb-window-as-sprite | ba3ae1a3b3bcb631b68912d50d6bc1a7d5680f1f | [
"Unlicense"
] | 4 | 2019-07-08T23:42:08.000Z | 2021-06-23T20:03:13.000Z | res/window_map_legs_2.c | bbbbbr/gb-window-as-sprite | ba3ae1a3b3bcb631b68912d50d6bc1a7d5680f1f | [
"Unlicense"
] | null | null | null | res/window_map_legs_2.c | bbbbbr/gb-window-as-sprite | ba3ae1a3b3bcb631b68912d50d6bc1a7d5680f1f | [
"Unlicense"
] | null | null | null | /*
../SRC/WINDOW_MAP_LEGS_2.C
Map Source File.
Info:
Section :
Bank : 0
Map size : 20 x 3
Tile set : nyancassette-window-all.gbm.tiles.gbr
Plane count : 1 plane (8 bits)
Plane order : Tiles are continues
Tile offset : 0
Split data : No
This file was generated by GBMB v1.8
*/
#define window_map_legs_2Width 20
#define window_map_legs_2Height 3
#define window_map_legs_2Bank 0
const unsigned char window_map_legs_2[] =
{
0x00,0x00,0x00,0x26,0x0C,0x06,0x27,0x0C,0x0C,0x28,
0x1B,0x1B,0x1B,0x1B,0x29,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x30,0x1B,0x13,0x03,0x2C,0x2C,0x2C,0x13,
0x03,0x2C,0x03,0x2F,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/* End of ../SRC/WINDOW_MAP_LEGS_2.C */
| 24.583333 | 57 | 0.663277 |
50fb41ad8c822191be74f0c05c187ea95a871029 | 729 | h | C | lite/tnn/cv/tnn_subpixel_cnn.h | IgiArdiyanto/litehub | 54a43690d80e57f16bea1efc698e7d30f06b9d4f | [
"MIT"
] | null | null | null | lite/tnn/cv/tnn_subpixel_cnn.h | IgiArdiyanto/litehub | 54a43690d80e57f16bea1efc698e7d30f06b9d4f | [
"MIT"
] | null | null | null | lite/tnn/cv/tnn_subpixel_cnn.h | IgiArdiyanto/litehub | 54a43690d80e57f16bea1efc698e7d30f06b9d4f | [
"MIT"
] | null | null | null | //
// Created by DefTruth on 2021/11/29.
//
#ifndef LITE_AI_TOOLKIT_TNN_CV_TNN_SUBPIXEL_CNN_H
#define LITE_AI_TOOLKIT_TNN_CV_TNN_SUBPIXEL_CNN_H
#include "lite/tnn/core/tnn_core.h"
namespace tnncv
{
class LITE_EXPORTS TNNSubPixelCNN : public BasicTNNHandler
{
public:
explicit TNNSubPixelCNN(const std::string &_proto_path,
const std::string &_model_path,
unsigned int _num_threads = 1); //
~TNNSubPixelCNN() override = default;
private:
void transform(const cv::Mat &mat) override; //
public:
void detect(const cv::Mat &mat, types::SuperResolutionContent &super_resolution_content);
};
}
#endif //LITE_AI_TOOLKIT_TNN_CV_TNN_SUBPIXEL_CNN_H
| 25.137931 | 93 | 0.702332 |
5adf5cebf1b6bca8ef421db7b9a6ca369402378e | 8,363 | h | C | src/hal_timer.h | matt-alencar/avr-open-hal | b88a841e2c2d7ef06476f39f3fe636fd994cc9ea | [
"MIT"
] | null | null | null | src/hal_timer.h | matt-alencar/avr-open-hal | b88a841e2c2d7ef06476f39f3fe636fd994cc9ea | [
"MIT"
] | null | null | null | src/hal_timer.h | matt-alencar/avr-open-hal | b88a841e2c2d7ef06476f39f3fe636fd994cc9ea | [
"MIT"
] | null | null | null | /**
* @file hal_timer.h
* @author Matheus Alencar Nascimento (matt-alencar)
* @brief Header file of TIM HAL module.
**************************************************************************
* @copyright MIT License.
*
*/
#ifndef _TIMER_DRIVER_H_
#define _TIMER_DRIVER_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "hal_device.h"
#include "hal_gpio.h"
/**
* @brief Timer Hardware Type
*/
typedef enum {
TIMER8_TYPE, /*!< 8-bit timer */
TIMER16_TYPE, /*!< 16-bit timer */
TIMER_TYPE_NOT_DEFINED /*!< Timer type is not defined */
}timer_type_t;
/**
* @brief Timer Comparator
* @note Not all timers have all these comparators available
*/
typedef enum {
TIMER_COMP_OCRA = 0,
TIMER_COMP_OCRB,
TIMER_COMP_OCRC,
}timer_comp_t;
/**
* @brief Timer Output Mode
*/
typedef enum {
TIMER_OUTPUT_DISABLE = 0,
TIMER_OUTPUT_TOGGLE,
TIMER_OUTPUT_NON_INVERTING,
TIMER_OUTPUT_INVERTING
}timer_out_mode_t;
/**
* @brief Timer Clock Mode
*/
typedef enum {
TIMER_CLOCK_DISABLE = 0,
TIMER_CLOCK_PRESC_1,
TIMER_CLOCK_PRESC_8,
TIMER_CLOCK_PRESC_64,
TIMER_CLOCK_PRESC_256,
TIMER_CLOCK_PRESC_1024,
TIMER_CLOCK_EXT_FALLING_EDGE,
TIMER_CLOCK_EXT_RISING_EDGE,
}timer_clock_t;
/**
* @brief Timer Interrupt Type
* @note Not all timers have all these interrupt modes available
*/
typedef enum {
TIMER_INT_OVF = TOIE0, /*!< TIM Overflow IRQ */
TIMER_INT_OCRA = OCIE0A, /*!< TIM Comparator A match IRQ */
TIMER_INT_OCRB = OCIE0B, /*!< TIM Comparator B match IRQ */
TIMER_INT_OCRC = OCIE1C, /*!< TIM Comparator C match IRQ */
TIMER_INT_ICR = ICIE1 /*!< TIM Input Comparator match IRQ */
}timer_int_t;
/**
* @brief Timer8 Operation Mode
*/
typedef enum {
TIMER8_MODE_NORMAL = 0x00,
TIMER8_MODE_CTC = 0x02,
TIMER8_MODE_FAST_PWM_MAX_8BIT = 0x03,
TIMER8_MODE_FAST_PWM_OCRA = 0x07,
TIMER8_MODE_PHASE_CORRECT_PWM_MAX_8BIT = 0x01,
TIMER8_MODE_PHASE_CORRECT_PWM_OCRA = 0x05
}timer8_mode_t;
/**
* @brief Timer16 Operation Mode
*/
typedef enum {
TIMER16_MODE_NORMAL = 0x00,
TIMER16_MODE_CTC_OCRA = 0x04,
TIMER16_MODE_CTC_ICR = 0x0C,
TIMER16_MODE_FAST_PWM_MAX_8BIT = 0x05,
TIMER16_MODE_FAST_PWM_MAX_9BIT = 0x06,
TIMER16_MODE_FAST_PWM_MAX_10BIT = 0x07,
TIMER16_MODE_FAST_PWM_ICR = 0x0E,
TIMER16_MODE_FAST_PWM_OCRA = 0x0F,
TIMER16_MODE_PHASE_CORRECT_PWM_MAX_8BIT = 0x01,
TIMER16_MODE_PHASE_CORRECT_PWM_MAX_9BIT = 0x02,
TIMER16_MODE_PHASE_CORRECT_PWM_MAX_10BIT = 0x03,
TIMER16_MODE_PHASE_CORRECT_PWM_ICR = 0x0A,
TIMER16_MODE_PHASE_CORRECT_PWM_OCRA = 0x0B,
TIMER16_MODE_PHASE_FREQUENCY_CORRECT_PWM_ICR = 0x08,
TIMER16_MODE_PHASE_FREQUENCY_CORRECT_PWM_OCRA = 0x09
}timer16_mode_t;
/**
* @brief Timer input capture trigger edge
*/
typedef enum {
TIMER_IC_POLARITY_FALLING,
TIMER_IC_POLARITY_RISING,
}timer_ic_polarity_t;
/**
* @brief Timer input capture filter
*/
typedef enum {
TIMER_IC_FILER_DISABLE,
TIMER_IC_FILER_ENABLE,
}timer_ic_filter_t;
/**
* @brief Timer Configuration Struct definition
*/
typedef struct {
uint8_t Mode; /*!< Specifies the TIM operation mode. @ref timer8_mode_t, @ref timer16_mode_t */
timer_clock_t Clock; /*!< Specifies the TIM clock source */
uint16_t CompA; /*!< Specifies the TIM comparator A value */
uint16_t CompB; /*!< Specifies the TIM comparator B value */
uint16_t CompC; /*!< Specifies the TIM comparator C value (Only available on Timer-16) */
timer_out_mode_t OutModeA; /*!< Specifies the TIM output comparator A mode */
timer_out_mode_t OutModeB; /*!< Specifies the TIM output comparator B mode */
timer_out_mode_t OutModeC; /*!< Specifies the TIM output comparator C mode (Only available on Timer-16) */
uint16_t Counter; /*!< Specifies the TIM counter initial value */
timer_ic_polarity_t ICPolarity; /*!< Specifies the TIM input capture trigger edge (Only available on Timer-16) */
timer_ic_filter_t ICFilter; /*!< Specifies the TIM input capture filter state (Only available on Timer-16) */
}timer_init_t;
/**
* @brief Enable global timer clock prescallers
* @return None
*/
void Timer_Enable_Presc();
/**
* @brief Stop and reset global timer clock prescallers
* @return None
*/
void Timer_Disable_Presc();
/**
* @brief Get timer hardware type
*
* @param TIMx where x can be (0..5) to select the timer peripheral.
* @return timer_type_t
*/
timer_type_t Timer_GetType(timer_t *TIMx);
/**
* @brief Initialize configuration struct content
*
* @param timer_init Configuration struct pointer
* @return None
*/
void Timer_StructInit(timer_init_t *timer_init);
/**
* @brief Initializes the timer according to the specified
* parameters in timer_init.
*
* @param TIMx where x can be (0..5) to select the timer peripheral.
* @param timer_init Configuration struct pointer
* @return None
*/
void Timer_Init(timer_t *TIMx, timer_init_t *timer_init);
/**
* @brief DeInitializes the TIM peripheral
*
* @param TIMx where x can be (0..5) to select the timer peripheral.
* @return None
*/
void Timer_DeInit(timer_t *TIMx);
/**
* @brief Setup TIM operation mode
* @note Check the timer hardware type first
* @ref timer8_mode_t
* @ref timer16_mode_t
* @param TIMx where x can be (0..5) to select the timer peripheral.
* @param mode Can be any value from timer8_mode_t or timer16_mode_t.
* @return None
*/
void Timer_SetMode(timer_t *TIMx, uint8_t mode);
/**
* @brief Setup TIM input clock
*
* @param TIMx where x can be (0..5) to select the timer peripheral.
* @param clock can be anything from timer_clock_t.
* @return None
*/
void Timer_SetClock(timer_t *TIMx, timer_clock_t clock);
/**
* @brief Setup TIM output mode of comparator
*
* @param TIMx where x can be (0..5) to select the timer peripheral.
* @param comp Comparator module
* @param mode Output mode
* @return None
*/
void Timer_SetOutputMode(timer_t *TIMx, timer_comp_t comp, timer_out_mode_t mode);
/**
* @brief Set TIM counter value
*
* @param TIMx where x can be (0..5) to select the timer peripheral.
* @param value for timer8 hardware the maximum value allowed is 0xFF, for timer16 is 0xFFFF.
* @return None
*/
void Timer_SetCounter(timer_t *TIMx, uint16_t value);
/**
* @brief Get TIM counter value
*
* @param TIMx where x can be (0..5) to select the timer peripheral.
* @return TIM counter value
*/
uint16_t Timer_GetCounter(timer_t *TIMx);
/**
* @brief Get TIM comparator value
*
* @param TIMx where x can be (0..5) to select the timer peripheral.
* @param comp Comparator module
* @return uint16_t
*/
uint16_t Timer_GetCompare(timer_t *TIMx, timer_comp_t comp);
/**
* @brief Setup TIM comparator value
*
* @param TIMx where x can be (0..5) to select the timer peripheral.
* @param comp Comparator module
* @param value to write into selected comparator
* @return None
*/
void Timer_SetCompare(timer_t *TIMx, timer_comp_t comp, uint16_t value);
/**
* @brief Setup TIM input comparator
*
* @param TIMx where x can be (0..5) to select the timer peripheral.
* @param filter Filter state
* @param polarity Trigger polarity
* @return None
*/
void Timer_IC_Config(timer_t *TIMx, timer_ic_filter_t filter, timer_ic_polarity_t polarity);
/**
* @brief Set TIM input comparator value
*
* @param TIMx where x can be (0..5) to select the timer peripheral.
* @param value to write into input comparator
* @return None
*/
void Timer_IC_SetValue(timer_t *TIMx, uint16_t value);
/**
* @brief Get TIM input comparator value
*
* @param TIMx where x can be (0..5) to select the timer peripheral.
* @return uint16_t
*/
uint16_t Timer_IC_GetValue(timer_t *TIMx);
/**
* @brief Check if TIM is enabled
*
* @param TIMx where x can be (0..5) to select the timer peripheral.
* @return uint8_t: 0 -> Timer stoped, 1 -> Timer running
*/
uint8_t Timer_IsEnabled(timer_t *TIMx);
/**
* @brief Enable TIM interrupt request
*
* @param TIMx where x can be (0..5) to select the timer peripheral.
* @param int_type IRQ type
* @return None
*/
void Timer_Enable_IRQ(timer_t *TIMx, timer_int_t int_type);
/**
* @brief Disable TIM interrupt request
*
* @param TIMx where x can be (0..5) to select the timer peripheral.
* @param int_type IRQ type
* @return None
*/
void Timer_Disable_IRQ(timer_t *TIMx, timer_int_t int_type);
#ifdef __cplusplus
}
#endif
#endif /* _TIMER_DRIVER_H_ */ | 24.597059 | 116 | 0.716968 |
ea67330cf2eca7ec22f97985ee252dae628159f7 | 126 | h | C | loader/Apploader.h | StarMKWii/mkw-sp | e87fec9cdfc920fbe10b9680fc34cfe9a9ad2426 | [
"MIT"
] | null | null | null | loader/Apploader.h | StarMKWii/mkw-sp | e87fec9cdfc920fbe10b9680fc34cfe9a9ad2426 | [
"MIT"
] | null | null | null | loader/Apploader.h | StarMKWii/mkw-sp | e87fec9cdfc920fbe10b9680fc34cfe9a9ad2426 | [
"MIT"
] | null | null | null | #pragma once
#include <Common.h>
typedef void (*GameEntryFunc)(void);
bool Apploader_loadAndRun(GameEntryFunc *gameEntry);
| 15.75 | 52 | 0.777778 |
5a2998cc588b92d01a67d23c294d7081fd4eb768 | 273 | h | C | src/easeLib/Cubic.h | alizaliz/EasingCurves | daf8072224a9be2f68294e73276a3beebf8d0925 | [
"MIT"
] | 7 | 2020-01-12T16:55:08.000Z | 2021-08-25T16:52:03.000Z | src/easeLib/Cubic.h | alizaliz/EasingCurves | daf8072224a9be2f68294e73276a3beebf8d0925 | [
"MIT"
] | null | null | null | src/easeLib/Cubic.h | alizaliz/EasingCurves | daf8072224a9be2f68294e73276a3beebf8d0925 | [
"MIT"
] | null | null | null | #ifndef _PENNER_CUBIC
#define _PENNER_CUBIC
class CubicCurve
{
public:
static float easeIn(float t, float b, float c, float d);
static float easeOut(float t, float b, float c, float d);
static float easeInOut(float t, float b, float c, float d);
};
#endif | 21 | 61 | 0.699634 |
f6ebe32ac0def3cf81652365adc9ff31106212e0 | 693 | h | C | src/include/runtime/error.h | 61131/echidna | 862c1ef065e83b70666fdc9bc8e38a167f8bb57b | [
"BSD-2-Clause"
] | 13 | 2019-11-28T03:05:45.000Z | 2022-03-25T11:42:36.000Z | src/include/runtime/error.h | 61131/echidna | 862c1ef065e83b70666fdc9bc8e38a167f8bb57b | [
"BSD-2-Clause"
] | null | null | null | src/include/runtime/error.h | 61131/echidna | 862c1ef065e83b70666fdc9bc8e38a167f8bb57b | [
"BSD-2-Clause"
] | 5 | 2019-11-15T04:25:04.000Z | 2021-03-04T06:03:35.000Z | #ifndef _RUNTIME_ERROR_H
#define _RUNTIME_ERROR_H
typedef enum _RUNTIME_ERROR {
ERROR_NONE = 0,
ERROR_INTERNAL,
ERROR_INTERNAL_ALLOCATION,
ERROR_INTERNAL_READ,
ERROR_INTERNAL_WRITE,
ERROR_INVALID_BYTECODE,
ERROR_INVALID_SYMBOL,
ERROR_INVALID_FUNCTION,
ERROR_INVALID_LENGTH,
ERROR_DIVIDE_ZERO,
ERROR_MODULUS_ZERO,
ERROR_MATH_OVERFLOW,
ERROR_OPERAND_TYPE,
ERROR_PARAMETER_COUNT,
ERROR_PARAMETER_MISMATCH,
ERROR_PARAMETER_RANGE,
ERROR_PARAMETER_TYPE,
ERROR_PARAMETER_UNKNOWN,
ERROR_STACK_OVERFLOW,
ERROR_UNIMPLEMENTED,
}
RUNTIME_ERROR;
const char * runtime_errortostr(int Error);
#endif // _RUNTIME_ERROR_H
| 19.8 | 43 | 0.766234 |
ea05844d249ef7414069d9ed2f1ad85b9a86dcee | 464 | h | C | HKClipperDemo/HKClipperDemo/HKClipper/HKClipperView/HKClipperVeiw.h | clairehu7/HKClipperView | 55fc216e37d5de4a08e2a2a5331c85d094a21141 | [
"MIT"
] | 25 | 2016-09-07T02:46:05.000Z | 2020-03-24T07:29:59.000Z | HKClipperDemo/HKClipperDemo/HKClipper/HKClipperView/HKClipperVeiw.h | clairehu7/HKClipperView | 55fc216e37d5de4a08e2a2a5331c85d094a21141 | [
"MIT"
] | null | null | null | HKClipperDemo/HKClipperDemo/HKClipper/HKClipperView/HKClipperVeiw.h | clairehu7/HKClipperView | 55fc216e37d5de4a08e2a2a5331c85d094a21141 | [
"MIT"
] | 8 | 2016-11-21T13:42:55.000Z | 2020-02-24T13:02:15.000Z | //
// HKClipperVeiw.h
// HKBaseDemo
//
// Created by hukaiyin on 16/8/9.
// Copyright © 2016年 hukaiyin. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef NS_ENUM (NSUInteger, ClipperType) {
ClipperTypeImgMove,
ClipperTypeImgStay
};
@interface HKClipperVeiw : UIView
@property (nonatomic, strong) UIImage *baseImg;
@property (nonatomic, assign) CGSize resultImgSize;
@property (nonatomic, assign) ClipperType type;
- (UIImage *)clipImg;
@end
| 19.333333 | 52 | 0.724138 |
564748a793f24230aff4c08cd643afb75087213a | 3,902 | h | C | iOSOpenDev/frameworks/AccountSettings.framework/Headers/AccountsManager.h | bzxy/cydia | f8c838cdbd86e49dddf15792e7aa56e2af80548d | [
"MIT"
] | 678 | 2017-11-17T08:33:19.000Z | 2022-03-26T10:40:20.000Z | iOSOpenDev/frameworks/AccountSettings.framework/Headers/AccountsManager.h | chenfanfang/Cydia | 5efce785bfd5f1064b9c0f0e29a9cc05aa24cad0 | [
"MIT"
] | 22 | 2019-04-16T05:51:53.000Z | 2021-11-08T06:18:45.000Z | iOSOpenDev/frameworks/AccountSettings.framework/Headers/AccountsManager.h | chenfanfang/Cydia | 5efce785bfd5f1064b9c0f0e29a9cc05aa24cad0 | [
"MIT"
] | 170 | 2018-06-10T07:59:20.000Z | 2022-03-22T16:19:33.000Z | /**
* This header is generated by class-dump-z 0.2b.
*
* Source: /System/Library/PrivateFrameworks/AccountSettings.framework/AccountSettings
*/
#import <AccountSettings/AccountsManager.h>
@class NSMutableDictionary, NSMutableArray, NSArray;
@interface AccountsManager : NSObject {
NSMutableDictionary *_topLevelAccountsByID; // 4 = 0x4
NSMutableArray *_orderedTopLevelAccounts; // 8 = 0x8
NSMutableDictionary *_childAccountsByID; // 12 = 0xc
NSMutableDictionary *_childAccountIDToParentAccountID; // 16 = 0x10
@private
NSMutableDictionary *_originalAccountsByID; // 20 = 0x14
unsigned _dataVersion; // 24 = 0x18
NSArray *_runtimeFixers; // 28 = 0x1c
}
+ (void)_migrateAccountsIfNeeded; // 0x45dd
+ (void)accountWillChange:(id)account forDataclass:(id)dataclass; // 0x4439
+ (void)accountDidChange:(id)account forDataclass:(id)dataclass; // 0x4295
+ (id)displayNameForGroupOfAccountType:(id)accountType forBeginningOfSentence:(BOOL)sentence; // 0x3de5
+ (id)_notifierClassNamesForAccountType:(id)accountType dataclass:(id)dataclass; // 0x3eb5
- (id)init; // 0x3851
- (void)dealloc; // 0x7751
- (id)accountWithIdentifier:(id)identifier; // 0x388d
- (id)displayAccountWithSyncIdentifier:(id)syncIdentifier; // 0x3919
- (id)syncableAccountWithSyncIdentifier:(id)syncIdentifier; // 0x7581
- (id)allBasicAccounts; // 0x3961
- (id)allBasicSyncableAccounts; // 0x3999
- (id)basicAccountsWithTypes:(id)types; // 0x7475
- (id)fullDeviceLocalAccount; // 0x72b1
- (id)fullAccountWithIdentifier:(id)identifier loader:(id)loader; // 0x3a09
- (id)allMailAccounts; // 0x3a85
- (id)accountsWithTypes:(id)types; // 0x3b21
- (id)accountsWithTypes:(id)types withLoader:(id)loader; // 0x7029
- (unsigned)count; // 0x3b35
- (void)updateAccount:(id)account; // 0x6efd
- (void)insertAccount:(id)account; // 0x6e2d
- (void)deleteAccount:(id)account; // 0x6cf5
- (void)deleteAccountWithIdentifier:(id)identifier; // 0x3b55
- (void)replaceAccount:(id)account withAccount:(id)account2; // 0x3b95
- (void)replaceAccountsWithTypes:(id)types withAccounts:(id)accounts; // 0x679d
- (void)removeChildWithIdentifier:(id)identifier fromAccount:(id)account; // 0x6621
- (void)addChild:(id)child toAccount:(id)account; // 0x3c99
- (id)mergeInMemoryProperties:(id)memoryProperties originalProperties:(id)properties onDiskProperties:(id)properties3; // 0x63a1
- (void)saveAllAccounts; // 0x5cad
- (void)_removeChildrenForAccountWithIdentifier:(id)identifier; // 0x5b25
- (void)_loadChildrenFromAccount:(id)account; // 0x5971
- (id)_initWithAccountsInfo:(id)accountsInfo; // 0x5549
- (id)_createRuntimeFixers; // 0x3d75
- (unsigned)countOfBasicAccountsWithTypes:(id)types; // 0x5469
- (void)_setOriginalAccountDictionaries; // 0x52e9
- (void)_addNotificationToDictionary:(id)dictionary forChangeType:(int)changeType originalProperties:(id)properties currentProperties:(id)properties4; // 0x4be9
- (void)_sendNotificationsForChangedAccounts; // 0x472d
@end
@interface AccountsManager (MigrationSupport)
+ (void)killDataAccessIfNecessary; // 0x7e31
+ (id)createAndLockMigrationLock; // 0x78f5
+ (void)releaseMigrationLock:(id)lock; // 0x7945
+ (void)waitForMigrationToFinish; // 0x7975
+ (void)removeNewAccountSettingsToMigrateOldAccountInformation; // 0x7c81
+ (void)shouldMigrateOldMailAccounts:(BOOL *)accounts oldDAAccounts:(BOOL *)accounts2 newAccountSettings:(BOOL *)settings; // 0x79e9
+ (BOOL)accountSettingsNeedsToBeMigrated; // 0x7bd1
+ (BOOL)_oldDAAccountsInformationFound; // 0x7fb9
+ (BOOL)_oldMailAccountsInformationFound; // 0x8049
- (void)setDataVersion:(unsigned)version; // 0x3841
@end
@interface AccountsManager (Private)
+ (unsigned)currentVersion; // 0x381d
+ (id)fullPathToAccountSettingsPlist; // 0x7d1d
+ (void)_setShouldSkipNotifications:(BOOL)_set; // 0x3831
- (id)initWithAccounsInfoArray:(id)accounsInfoArray; // 0x7801
- (id)initInsideOfMigration; // 0x7811
- (unsigned)dataVersion; // 0x3821
@end
| 47.585366 | 160 | 0.778319 |
14c1ddb6b2ef72d3c0827b23fd399bb37c4bba60 | 2,517 | h | C | ds/security/csps/cryptoflex/slbcsp/cntrfinder.h | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | ds/security/csps/cryptoflex/slbcsp/cntrfinder.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | ds/security/csps/cryptoflex/slbcsp/cntrfinder.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | // CntrFinder.h -- Container Finder class header
// (c) Copyright Schlumberger Technology Corp., unpublished work, created
// 1999. This computer program includes Confidential, Proprietary
// Information and is a Trade Secret of Schlumberger Technology Corp. All
// use, disclosure, and/or reproduction is prohibited unless authorized
// in writing. All Rights Reserved.
#if !defined(SLBCSP_CNTRFINDER_H)
#define SLBCSP_CNTRFINDER_H
#include "cciCont.h"
#include "CardFinder.h"
#include "HAdptvCntr.h"
#include "Secured.h"
class ContainerFinder
: public CardFinder
{
public:
// Types
// C'tors/D'tors
ContainerFinder(DialogDisplayMode ddm,
HWND hwnd = 0,
CString const &rsDialogTitle = StringResource(IDS_SEL_SLB_CRYPTO_CARD).AsCString());
virtual ~ContainerFinder();
// Operators
// Operations
HContainer
Find(CSpec const &rcsContainer);
HAdaptiveContainerKey
MakeAdaptiveContainerKey();
// Access
// Predicates
protected:
// Types
// C'tors/D'tors
// Operators
// Operations
void
ContainerFound(HContainer hcntr);
void
DoDisconnect();
virtual void
DoOnError();
// Access
HContainer
ContainerFound() const;
// Predicates
bool
DoIsValid();
// Variables
private:
// Types
// C'tors/D'tors
// Operators
// Operations
// Access
// Predicates
// Variables
HContainer m_hcntr;
};
#endif // SLBCSP_CNTRFINDER_H
| 31.4625 | 105 | 0.400079 |
4ea83d760d8a6f8c8dcf3399ceb20e8c7369d97d | 2,415 | h | C | karman/multiple_particles_code/.qccbey1rk/grid/mempool.h | MNegus/fluid-art | 47721e59c3b8e8db562133888571cb17c568eaf6 | [
"Apache-2.0"
] | null | null | null | karman/multiple_particles_code/.qccbey1rk/grid/mempool.h | MNegus/fluid-art | 47721e59c3b8e8db562133888571cb17c568eaf6 | [
"Apache-2.0"
] | null | null | null | karman/multiple_particles_code/.qccbey1rk/grid/mempool.h | MNegus/fluid-art | 47721e59c3b8e8db562133888571cb17c568eaf6 | [
"Apache-2.0"
] | null | null | null | #ifndef BASILISK_HEADER_41
#define BASILISK_HEADER_41
#line 1 "/home/michael/basilisk_1/src/grid/mempool.h"
/* A memory pool implementation for fixed-size blocks
It uses Simple Segregated Storage, see e.g:
http://www.boost.org/doc/libs/1_55_0/libs/pool/doc/html/boost_pool/pool/pooling.html
*/
typedef struct _Pool Pool;
struct _Pool {
Pool * next; // next pool
};
typedef struct {
char * first, * lastb; // first and last free blocks
size_t size; // block size
size_t poolsize; // pool size
Pool * pool, * last; // first and last pools
} Mempool;
typedef struct {
char * next;
} FreeBlock;
Mempool * mempool_new (size_t poolsize, size_t size)
{
// check for 64 bytes alignment
assert (poolsize % 8 == 0);
assert (size >= sizeof(FreeBlock));
// to get the effective pool size, we cap this amount to 2^20 = 1MB
// i.e. something comparable to the size of a L2 cache
poolsize = min(1 << 20, poolsize + sizeof(Pool));
Mempool * m = qcalloc (1, Mempool);
m->poolsize = poolsize;
m->size = size;
return m;
}
void mempool_destroy (Mempool * m)
{
Pool * p = m->pool;
while (p) {
Pool * next = p->next;
free (p);
p = next;
}
free (m);
}
void * mempool_alloc (Mempool * m)
{
if (!m->first) {
// allocate new pool
Pool * p = (Pool *) malloc (m->poolsize);
p->next = NULL;
if (m->last)
m->last->next = p;
else
m->pool = p;
m->last = p;
m->first = m->lastb = ((char *)m->last) + sizeof(Pool);
FreeBlock * b = (FreeBlock *) m->first;
b->next = NULL;
}
void * ret = m->first;
FreeBlock * b = (FreeBlock *) ret;
char * next = b->next;
if (!next) {
m->lastb += m->size;
next = m->lastb;
if (next + m->size > ((char *) m->last) + m->poolsize)
next = NULL;
else {
FreeBlock * b = (FreeBlock *) next;
b->next = NULL;
}
}
m->first = next;
@if TRASH
double * v = (double *) ret;
for (int i = 0; i < m->size/sizeof(double); i++)
v[i] = undefined;
@endif
return ret;
}
void * mempool_alloc0 (Mempool * m)
{
void * ret = mempool_alloc (m);
memset (ret, 0, m->size);
return ret;
}
void mempool_free (Mempool * m, void * p)
{
@if TRASH
double * v = (double *) p;
for (int i = 0; i < m->size/sizeof(double); i++)
v[i] = undefined;
@endif
FreeBlock * b = (FreeBlock *) p;
b->next = m->first;
m->first = (char *) p;
}
#endif
| 22.361111 | 87 | 0.586335 |
5e12cb095d4d717bb0f7f185754c097dded0854e | 1,969 | h | C | JXUtilsKit/Tools/JXAuthorizationTool.h | Barnett2050/JXUtilsKit | 0e77e47636aba5f07b36a1ef4cde7d2b6fe481d5 | [
"MIT"
] | 1 | 2022-03-18T06:44:36.000Z | 2022-03-18T06:44:36.000Z | JXUtilsKit/Tools/JXAuthorizationTool.h | Barnett2050/JXUtilsKit | 0e77e47636aba5f07b36a1ef4cde7d2b6fe481d5 | [
"MIT"
] | null | null | null | JXUtilsKit/Tools/JXAuthorizationTool.h | Barnett2050/JXUtilsKit | 0e77e47636aba5f07b36a1ef4cde7d2b6fe481d5 | [
"MIT"
] | null | null | null | //
// JXAuthorizationTool.h
// JXUtilsKit
//
// Created by Barnett on 2021/8/3.
// Copyright © 2021 Barnett. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef enum : NSUInteger {
JXAuthorizationRequestCamera = 0, // 相机
JXAuthorizationRequestPhotoLibraryAddOnly API_AVAILABLE(ios(14)), // 相册仅允许添加照片
JXAuthorizationRequestPhotoLibraryReadWrite, // 相册允许访问照片,limitedLevel 必须为 readWrite
JXAuthorizationRequestAudio, // 麦克风
JXAuthorizationRequestMediaLibrary, // 获取音乐媒体权限,iOS 9.3之后
JXAuthorizationRequestContacts, // 通讯录
JXAuthorizationRequestCalendars, // 日历
JXAuthorizationRequestReminder, // 提醒事项,添加提醒事项需要打开iCloud里面的日历,日历权限和提醒权限必须同时申请.
JXAuthorizationRequestSpeechRecognition, // 语音识别
} JXAuthorizationRequestType;
typedef enum : NSUInteger {
JXAuthorizationStatusAuthorized = 0, // 完全的权限
JXAuthorizationStatusLimited API_AVAILABLE(ios(14)), // 有限的权限
} JXAuthorizationSuccessType;
typedef enum : NSUInteger {
JXAuthorizationStatusNotDetermined = 0, // 用户第一次请求权限未授权
JXAuthorizationStatusRestricted = 1, // 家长控制之类的活动限制
JXAuthorizationStatusDenied = 2, // 用户明确拒绝
JXAuthorizationFailNoneCamera = 3, // 无摄像头
JXAuthorizationFailRearUnavailable = 4, // 后方摄像头不可用
} JXAuthorizationFailType;
// 权限获取成功
typedef void(^requestAuthorizationSuccess)(JXAuthorizationSuccessType successType);
// 权限获取失败
typedef void(^requestAuthorizationFail)(JXAuthorizationFailType failType,NSError * _Nullable error);
@interface JXAuthorizationTool : NSObject
/// 跳转系统设置
+ (void)pushToApplicationSettings;
/// 后面的摄像头是否可用
+ (BOOL)rearCameraIsAvailable;
/// 前面的摄像头是否可用
+ (BOOL)frontCameraIsAvailable;
/// 请求系统相关授权
/// @param requestType 授权类型
/// @param success 成功回调
/// @param fail 失败回调
+ (void)requestAuthorizationType:(JXAuthorizationRequestType)requestType success:(requestAuthorizationSuccess)success fail:(requestAuthorizationFail)fail;
@end
NS_ASSUME_NONNULL_END
| 32.278689 | 154 | 0.779584 |
b2bc0ec6d3f209eb7b897debf096514417ac5000 | 4,455 | h | C | examples/SAM_DUE_WiFiNINA_WM/defines.h | khoih-prog/Blynk_WiFiNINA_WM | 7d91a63996f53859c72a650ee79d0daf2fceebbd | [
"MIT"
] | 2 | 2021-06-05T02:51:34.000Z | 2021-06-10T14:10:36.000Z | examples/SAM_DUE_WiFiNINA_WM/defines.h | khoih-prog/Blynk_WiFiNINA_WM | 7d91a63996f53859c72a650ee79d0daf2fceebbd | [
"MIT"
] | 1 | 2020-11-26T15:26:35.000Z | 2020-11-26T16:13:12.000Z | examples/SAM_DUE_WiFiNINA_WM/defines.h | khoih-prog/Blynk_WiFiNINA_WM | 7d91a63996f53859c72a650ee79d0daf2fceebbd | [
"MIT"
] | 1 | 2020-08-26T19:32:08.000Z | 2020-08-26T19:32:08.000Z | /****************************************************************************************************************************
defines.h
For SAM DUE boards using WiFiNINA Shields
Blynk_WiFiNINA_WM is a library for the Mega, Teensy, SAM DUE, nRF52, STM32, SAMD and RP2040 boards
(https://github.com/khoih-prog/Blynk_WiFiNINA_WM) to enable easy configuration/reconfiguration and
autoconnect/autoreconnect of WiFiNINA/Blynk
Modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases
Built by Khoi Hoang https://github.com/khoih-prog/Blynk_WiFiNINA_WM
Licensed under MIT license
*****************************************************************************************************************************/
#ifndef defines_h
#define defines_h
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#define DEBUG_WIFI_WEBSERVER_PORT Serial
#define WIFININA_DEBUG_OUTPUT Serial
#define DRD_GENERIC_DEBUG true
#define WIFININA_DEBUG true
#define BLYNK_WM_DEBUG 3
#define _WIFININA_LOGLEVEL_ 3
#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) )
#if defined(WIFININA_USE_SAM_DUE)
#undef WIFININA_USE_SAM_DUE
#undef WIFI_USE_SAM_DUE
#endif
#define WIFININA_USE_SAM_DUE true
#define WIFI_USE_SAM_DUE true
#warning Use SAM_DUE architecture
#endif
#if ( defined(ESP8266) || defined(ESP32) || defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_MEGA) || \
defined(CORE_TEENSY) || defined(CORE_TEENSY) || !(WIFININA_USE_SAM_DUE) )
#error This code is intended to run on the SAM DUE platform! Please check your Tools->Board setting.
#endif
#if defined(WIFININA_USE_SAM_DUE)
#if defined(ARDUINO_SAM_DUE)
#define BOARD_TYPE "SAM DUE"
#elif defined(__SAM3X8E__)
#define BOARD_TYPE "SAM SAM3X8E"
#else
#define BOARD_TYPE "SAM Unknown"
#endif
#endif
#if !defined(BOARD_NAME)
#define BOARD_NAME BOARD_TYPE
#endif
// Start location in EEPROM to store config data. Default 0
// Config data Size currently is 128 bytes)
#define EEPROM_START 0
#define USE_BLYNK_WM true
//#define USE_BLYNK_WM false
#define USE_SSL false
#if USE_BLYNK_WM
/////////////////////////////////////////////
/////////////////////////////////////////////
// Add customs headers from v1.1.0
#define USING_CUSTOMS_STYLE true
#define USING_CUSTOMS_HEAD_ELEMENT true
#define USING_CORS_FEATURE true
/////////////////////////////////////////////
// Permit running CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET times before reset hardware
// to permit user another chance to config. Only if Config Data is valid.
// If Config Data is invalid, this has no effect as Config Portal will persist
#define RESET_IF_CONFIG_TIMEOUT true
// Permitted range of user-defined RETRY_TIMES_RECONNECT_WIFI between 2-5 times
#define RETRY_TIMES_RECONNECT_WIFI 3
// Permitted range of user-defined CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET between 2-100
#define CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET 5
// Config Timeout 120s (default 60s). Applicable only if Config Data is Valid
#define CONFIG_TIMEOUT 120000L
// Permit input only one set of WiFi SSID/PWD. The other can be "NULL or "blank"
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW true
#define USE_DYNAMIC_PARAMETERS true
/////////////////////////////////////////////
#define SCAN_WIFI_NETWORKS true
// To be able to manually input SSID, not from a scanned SSID lists
#define MANUAL_SSID_INPUT_ALLOWED true
// From 2-15
#define MAX_SSID_IN_LIST 8
/////////////////////////////////////////////
#include <BlynkSimpleWiFiNINA_DUE_WM.h>
#else
#include <BlynkSimpleWiFiNINA_DUE.h>
#define USE_LOCAL_SERVER true
#if USE_LOCAL_SERVER
char auth[] = "****";
String BlynkServer = "account.duckdns.org";
//String BlynkServer = "192.168.2.112";
#else
char auth[] = "****";
String BlynkServer = "blynk-cloud.com";
#endif
#define BLYNK_SERVER_HARDWARE_PORT 8080
// Your WiFi credentials.
char ssid[] = "****";
char pass[] = "****";
#endif
#define HOST_NAME "SAM-DUE-WiFiNINA"
#endif //defines_h
| 31.821429 | 127 | 0.625365 |
05755df4f286dc291d223e99f41fab6d472fe1d0 | 889 | h | C | examples/dualmotes-nullnet/monitor/project-conf.h | RoaldVG/contiki-ng-combined | 6e0ba637a4a7f6b26f5e25b72ffb3e3bd2e40f49 | [
"BSD-3-Clause"
] | null | null | null | examples/dualmotes-nullnet/monitor/project-conf.h | RoaldVG/contiki-ng-combined | 6e0ba637a4a7f6b26f5e25b72ffb3e3bd2e40f49 | [
"BSD-3-Clause"
] | null | null | null | examples/dualmotes-nullnet/monitor/project-conf.h | RoaldVG/contiki-ng-combined | 6e0ba637a4a7f6b26f5e25b72ffb3e3bd2e40f49 | [
"BSD-3-Clause"
] | 2 | 2021-04-28T10:14:00.000Z | 2021-04-28T10:25:53.000Z | #ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
#include "stdint.h"
#include "sys/rtimer.h"
//#define ZOUL_CONF_USE_CC1200_RADIO 1
#undef IEEE802154_CONF_DEFAULT_CHANNEL
#define IEEE802154_CONF_DEFAULT_CHANNEL 20
#define ENERGEST_FREQ 100 // every x messages a message is sent to the energest sink
#define IO_WIDTH 11
// UART pins are used for parallel communication, serial comm over UART overwrites some pins
<<<<<<< HEAD
#undef UART_CONF_ENABLE
#define UART_CONF_ENABLE 0
#undef USB_SERIAL_CONF_ENABLE
#define USB_SERIAL_CONF_ENABLE 0
#endif // PROJECT_CONF_H_p
=======
#define UART_CONF_ENABLE 1
#include "stdint.h"
struct testmsg {
uint16_t observed_seqno;
uint16_t monitor_seqno;
uint32_t energy;
uint16_t counter_ADC;
uint32_t timestamp_app;
uint32_t timestamp_mac;
};
#endif // PROJECT_CONF_H_
>>>>>>> 37c9dabffb447a16f8c0157359f01fa9f8d22293
| 24.027027 | 92 | 0.778403 |
b281ac8c0f1605426138a5868d786b1c187afb8d | 2,085 | h | C | shell/gpu/gpu_surface_vulkan.h | charafau/engine | c4a1a72da5dde44cc6288f8c4c0020b03e1e9279 | [
"BSD-3-Clause"
] | 1 | 2022-03-14T18:29:14.000Z | 2022-03-14T18:29:14.000Z | shell/gpu/gpu_surface_vulkan.h | MasahideMori-SimpleAppli/engine | 1adccf1592cd980af3e446a344f738f7b2ac853c | [
"BSD-3-Clause"
] | 2 | 2019-05-09T12:15:03.000Z | 2020-03-09T09:24:39.000Z | shell/gpu/gpu_surface_vulkan.h | MasahideMori-SimpleAppli/engine | 1adccf1592cd980af3e446a344f738f7b2ac853c | [
"BSD-3-Clause"
] | 1 | 2022-02-08T00:14:53.000Z | 2022-02-08T00:14:53.000Z | // Copyright 2013 The Flutter 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 SHELL_GPU_GPU_SURFACE_VULKAN_H_
#define SHELL_GPU_GPU_SURFACE_VULKAN_H_
#include <memory>
#include "flutter/flow/surface.h"
#include "flutter/fml/macros.h"
#include "flutter/fml/memory/weak_ptr.h"
#include "flutter/shell/gpu/gpu_surface_vulkan_delegate.h"
#include "flutter/vulkan/vulkan_backbuffer.h"
#include "flutter/vulkan/vulkan_native_surface.h"
#include "flutter/vulkan/vulkan_window.h"
#include "include/core/SkRefCnt.h"
namespace flutter {
//------------------------------------------------------------------------------
/// @brief A GPU surface backed by VkImages provided by a
/// GPUSurfaceVulkanDelegate.
///
class GPUSurfaceVulkan : public Surface {
public:
//------------------------------------------------------------------------------
/// @brief Create a GPUSurfaceVulkan while letting it reuse an existing
/// GrDirectContext.
///
GPUSurfaceVulkan(GPUSurfaceVulkanDelegate* delegate,
const sk_sp<GrDirectContext>& context,
bool render_to_surface);
~GPUSurfaceVulkan() override;
// |Surface|
bool IsValid() override;
// |Surface|
std::unique_ptr<SurfaceFrame> AcquireFrame(const SkISize& size) override;
// |Surface|
SkMatrix GetRootTransformation() const override;
// |Surface|
GrDirectContext* GetContext() override;
static SkColorType ColorTypeFromFormat(const VkFormat format);
private:
GPUSurfaceVulkanDelegate* delegate_;
sk_sp<GrDirectContext> skia_context_;
bool render_to_surface_;
fml::WeakPtrFactory<GPUSurfaceVulkan> weak_factory_;
sk_sp<SkSurface> CreateSurfaceFromVulkanImage(const VkImage image,
const VkFormat format,
const SkISize& size);
FML_DISALLOW_COPY_AND_ASSIGN(GPUSurfaceVulkan);
};
} // namespace flutter
#endif // SHELL_GPU_GPU_SURFACE_VULKAN_H_
| 30.661765 | 82 | 0.658513 |
c98e815c1f950a840069b8460dcb4f99f9b8a0af | 206 | c | C | validation/label-redefined.c | sanfusu/Sparse | 2b96cd804dc7e4b5f6a0aae62c1962bd6b2caae9 | [
"MIT"
] | 17 | 2017-05-19T04:42:18.000Z | 2022-03-18T14:22:52.000Z | validation/label-redefined.c | sanfusu/Sparse | 2b96cd804dc7e4b5f6a0aae62c1962bd6b2caae9 | [
"MIT"
] | 1 | 2018-03-18T19:33:06.000Z | 2018-03-18T22:48:28.000Z | validation/label-redefined.c | sanfusu/Sparse | 2b96cd804dc7e4b5f6a0aae62c1962bd6b2caae9 | [
"MIT"
] | 8 | 2020-01-04T20:04:51.000Z | 2022-03-18T14:22:56.000Z | extern void fun(void);
static void foo(int p)
{
l:
if (p)
l:
fun();
}
/*
* check-name: label-redefined
*
* check-error-start
label-redefined.c:7:1: error: label 'l' redefined
* check-error-end
*/
| 11.444444 | 49 | 0.631068 |
f97e30036f83f4e58e47a44bc5d821ee7a5ee0ca | 526 | h | C | src/unity/djinni/objc/DBWalletLockStatus.h | guldenpay/gulden-official | 4ae4cc4143ed9c1c15896fe81ad5b64f43829e1b | [
"MIT"
] | 1 | 2015-09-27T07:07:57.000Z | 2015-09-27T07:07:57.000Z | src/unity/djinni/objc/DBWalletLockStatus.h | guldenpay/gulden-official | 4ae4cc4143ed9c1c15896fe81ad5b64f43829e1b | [
"MIT"
] | null | null | null | src/unity/djinni/objc/DBWalletLockStatus.h | guldenpay/gulden-official | 4ae4cc4143ed9c1c15896fe81ad5b64f43829e1b | [
"MIT"
] | null | null | null | // AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from libunity.djinni
#import <Foundation/Foundation.h>
@interface DBWalletLockStatus : NSObject
- (nonnull instancetype)initWithLocked:(BOOL)locked
lockTimeout:(int64_t)lockTimeout;
+ (nonnull instancetype)walletLockStatusWithLocked:(BOOL)locked
lockTimeout:(int64_t)lockTimeout;
@property (nonatomic, readonly) BOOL locked;
@property (nonatomic, readonly) int64_t lockTimeout;
@end
| 30.941176 | 72 | 0.703422 |
c75ad3532903017ef67efa0ce9147270c7f10871 | 16,205 | c | C | sdk-6.5.20/libs/sdklt/bcmlta/bcmltx/bcm56990_b0/bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | sdk-6.5.20/libs/sdklt/bcmlta/bcmltx/bcm56990_b0/bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | sdk-6.5.20/libs/sdklt/bcmlta/bcmltx/bcm56990_b0/bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | /*******************************************************************************
*
* DO NOT EDIT THIS FILE!
* This file is auto-generated by fltg from Logical Table mapping files.
*
* Tool: $SDK/INTERNAL/fltg/bin/fltg
*
* Edits to this file will be lost when it is regenerated.
*
* This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
*
* Copyright 2007-2020 Broadcom Inc. All rights reserved.
*/
/* Logical Table Adaptor for component bcmltx */
/* Handler: bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler */
#include <bcmlrd/bcmlrd_types.h>
#include <bcmltd/chip/bcmltd_id.h>
#include <bcmltx/bcmtm/bcmltx_port_q_oper_state.h>
#include <bcmdrd/chip/bcm56990_b0_enum.h>
#include <bcmlrd/chip/bcm56990_b0/bcm56990_b0_lrd_xfrm_field_desc.h>
static const uint32_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_arg0[1] = {
1,
};
static const uint32_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_arg1[1] = {
0,
};
extern const bcmltd_field_desc_t
bcm56990_b0_lrd_bcmltx_port_q_oper_state_src_field_desc_s0[];
extern const bcmltd_field_desc_t
bcm56990_b0_lrd_bcmltx_port_q_oper_state_src_field_desc_s1[];
extern const bcmltd_field_desc_t
bcm56990_b0_lrd_bcmltx_port_q_oper_state_src_field_desc_s2[];
extern const bcmltd_field_desc_t
bcm56990_b0_lrd_bcmltx_port_q_oper_state_src_field_desc_s3[];
extern const bcmltd_field_desc_t
bcm56990_b0_lrd_bcmltx_port_q_oper_state_src_field_desc_s4[];
extern const bcmltd_field_desc_t
bcm56990_b0_lrd_bcmltx_port_q_oper_state_src_field_desc_s5[];
static const bcmltd_field_desc_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_src_field_desc_k0[2] = {
{
.field_id = CTR_EGR_TM_BST_MC_Qt_PORT_IDf,
.field_idx = 0,
.minbit = 0,
.maxbit = 15,
.entry_idx = 0,
.reserved = 0
},
{
.field_id = CTR_EGR_TM_BST_MC_Qt_TM_MC_Q_IDf,
.field_idx = 0,
.minbit = 0,
.maxbit = 7,
.entry_idx = 0,
.reserved = 0
},
};
static const bcmltd_field_desc_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_src_field_desc_k1[2] = {
{
.field_id = CTR_EGR_TM_BST_UC_Qt_PORT_IDf,
.field_idx = 0,
.minbit = 0,
.maxbit = 15,
.entry_idx = 0,
.reserved = 0
},
{
.field_id = CTR_EGR_TM_BST_UC_Qt_TM_UC_Q_IDf,
.field_idx = 0,
.minbit = 0,
.maxbit = 7,
.entry_idx = 0,
.reserved = 0
},
};
static const bcmltd_field_desc_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_src_field_desc_k2[2] = {
{
.field_id = CTR_TM_MC_Q_DROPt_PORT_IDf,
.field_idx = 0,
.minbit = 0,
.maxbit = 15,
.entry_idx = 0,
.reserved = 0
},
{
.field_id = CTR_TM_MC_Q_DROPt_TM_MC_Q_IDf,
.field_idx = 0,
.minbit = 0,
.maxbit = 7,
.entry_idx = 0,
.reserved = 0
},
};
static const bcmltd_field_desc_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_src_field_desc_k3[2] = {
{
.field_id = CTR_TM_THD_MC_Qt_PORT_IDf,
.field_idx = 0,
.minbit = 0,
.maxbit = 15,
.entry_idx = 0,
.reserved = 0
},
{
.field_id = CTR_TM_THD_MC_Qt_TM_MC_Q_IDf,
.field_idx = 0,
.minbit = 0,
.maxbit = 7,
.entry_idx = 0,
.reserved = 0
},
};
static const bcmltd_field_desc_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_src_field_desc_k4[2] = {
{
.field_id = CTR_TM_THD_UC_Qt_PORT_IDf,
.field_idx = 0,
.minbit = 0,
.maxbit = 15,
.entry_idx = 0,
.reserved = 0
},
{
.field_id = CTR_TM_THD_UC_Qt_TM_UC_Q_IDf,
.field_idx = 0,
.minbit = 0,
.maxbit = 7,
.entry_idx = 0,
.reserved = 0
},
};
static const bcmltd_field_desc_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_src_field_desc_k5[2] = {
{
.field_id = CTR_TM_UC_Q_DROPt_PORT_IDf,
.field_idx = 0,
.minbit = 0,
.maxbit = 15,
.entry_idx = 0,
.reserved = 0
},
{
.field_id = CTR_TM_UC_Q_DROPt_TM_UC_Q_IDf,
.field_idx = 0,
.minbit = 0,
.maxbit = 7,
.entry_idx = 0,
.reserved = 0
},
};
static const
bcmltd_field_list_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_s0 = {
.field_num = 1,
.field_array = bcm56990_b0_lrd_bcmltx_port_q_oper_state_src_field_desc_s0
};
static const
bcmltd_field_list_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_s1 = {
.field_num = 1,
.field_array = bcm56990_b0_lrd_bcmltx_port_q_oper_state_src_field_desc_s1
};
static const
bcmltd_field_list_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_s2 = {
.field_num = 1,
.field_array = bcm56990_b0_lrd_bcmltx_port_q_oper_state_src_field_desc_s2
};
static const
bcmltd_field_list_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_s3 = {
.field_num = 1,
.field_array = bcm56990_b0_lrd_bcmltx_port_q_oper_state_src_field_desc_s3
};
static const
bcmltd_field_list_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_s4 = {
.field_num = 1,
.field_array = bcm56990_b0_lrd_bcmltx_port_q_oper_state_src_field_desc_s4
};
static const
bcmltd_field_list_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_s5 = {
.field_num = 1,
.field_array = bcm56990_b0_lrd_bcmltx_port_q_oper_state_src_field_desc_s5
};
static const
bcmltd_field_list_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_k0 = {
.field_num = 2,
.field_array = bcm56990_b0_lta_bcmltx_port_q_oper_state_src_field_desc_k0
};
static const
bcmltd_field_list_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_k1 = {
.field_num = 2,
.field_array = bcm56990_b0_lta_bcmltx_port_q_oper_state_src_field_desc_k1
};
static const
bcmltd_field_list_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_k2 = {
.field_num = 2,
.field_array = bcm56990_b0_lta_bcmltx_port_q_oper_state_src_field_desc_k2
};
static const
bcmltd_field_list_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_k3 = {
.field_num = 2,
.field_array = bcm56990_b0_lta_bcmltx_port_q_oper_state_src_field_desc_k3
};
static const
bcmltd_field_list_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_k4 = {
.field_num = 2,
.field_array = bcm56990_b0_lta_bcmltx_port_q_oper_state_src_field_desc_k4
};
static const
bcmltd_field_list_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_k5 = {
.field_num = 2,
.field_array = bcm56990_b0_lta_bcmltx_port_q_oper_state_src_field_desc_k5
};
static const bcmltd_field_list_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_dst_list_d0 = {
.field_num = 0,
.field_array = NULL
};
static const uint32_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_s0[1] = {
CTR_EGR_TM_BST_MC_Qt_OPERATIONAL_STATEf,
};
static const uint32_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_s1[1] = {
CTR_EGR_TM_BST_UC_Qt_OPERATIONAL_STATEf,
};
static const uint32_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_s2[1] = {
CTR_TM_MC_Q_DROPt_OPERATIONAL_STATEf,
};
static const uint32_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_s3[1] = {
CTR_TM_THD_MC_Qt_OPERATIONAL_STATEf,
};
static const uint32_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_s4[1] = {
CTR_TM_THD_UC_Qt_OPERATIONAL_STATEf,
};
static const uint32_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_s5[1] = {
CTR_TM_UC_Q_DROPt_OPERATIONAL_STATEf,
};
static const uint32_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_k0[2] = {
CTR_EGR_TM_BST_MC_Qt_PORT_IDf,
CTR_EGR_TM_BST_MC_Qt_TM_MC_Q_IDf,
};
static const uint32_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_k1[2] = {
CTR_EGR_TM_BST_UC_Qt_PORT_IDf,
CTR_EGR_TM_BST_UC_Qt_TM_UC_Q_IDf,
};
static const uint32_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_k2[2] = {
CTR_TM_MC_Q_DROPt_PORT_IDf,
CTR_TM_MC_Q_DROPt_TM_MC_Q_IDf,
};
static const uint32_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_k3[2] = {
CTR_TM_THD_MC_Qt_PORT_IDf,
CTR_TM_THD_MC_Qt_TM_MC_Q_IDf,
};
static const uint32_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_k4[2] = {
CTR_TM_THD_UC_Qt_PORT_IDf,
CTR_TM_THD_UC_Qt_TM_UC_Q_IDf,
};
static const uint32_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_k5[2] = {
CTR_TM_UC_Q_DROPt_PORT_IDf,
CTR_TM_UC_Q_DROPt_TM_UC_Q_IDf,
};
static const bcmltd_generic_arg_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_comp_data = {
.sid = CTR_EGR_TM_BST_MC_Qt,
.values = 0,
.value = NULL,
.user_data = NULL
};
static const bcmltd_generic_arg_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_comp_data1 = {
.sid = CTR_EGR_TM_BST_UC_Qt,
.values = 0,
.value = NULL,
.user_data = NULL
};
static const bcmltd_generic_arg_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_comp_data2 = {
.sid = CTR_TM_MC_Q_DROPt,
.values = 0,
.value = NULL,
.user_data = NULL
};
static const bcmltd_generic_arg_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_comp_data3 = {
.sid = CTR_TM_THD_MC_Qt,
.values = 0,
.value = NULL,
.user_data = NULL
};
static const bcmltd_generic_arg_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_comp_data4 = {
.sid = CTR_TM_THD_UC_Qt,
.values = 0,
.value = NULL,
.user_data = NULL
};
static const bcmltd_generic_arg_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_comp_data5 = {
.sid = CTR_TM_UC_Q_DROPt,
.values = 0,
.value = NULL,
.user_data = NULL
};
static const bcmltd_transform_arg_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler_rev_arg_s0_k0_d0_x0 = {
.values = 1,
.value = bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_arg0,
.tables = 0,
.table = NULL,
.fields = 0,
.field = NULL,
.field_list = &bcm56990_b0_lta_bcmltx_port_q_oper_state_dst_list_d0,
.kfields = 2,
.kfield = bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_k0,
.kfield_list = &bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_k0,
.rfields = 1,
.rfield = bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_s0,
.rfield_list = &bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_s0,
.comp_data = &bcm56990_b0_lta_bcmltx_port_q_oper_state_comp_data
};
static const bcmltd_transform_arg_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler_rev_arg_s1_k1_d0_x1 = {
.values = 1,
.value = bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_arg1,
.tables = 0,
.table = NULL,
.fields = 0,
.field = NULL,
.field_list = &bcm56990_b0_lta_bcmltx_port_q_oper_state_dst_list_d0,
.kfields = 2,
.kfield = bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_k1,
.kfield_list = &bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_k1,
.rfields = 1,
.rfield = bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_s1,
.rfield_list = &bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_s1,
.comp_data = &bcm56990_b0_lta_bcmltx_port_q_oper_state_comp_data1
};
static const bcmltd_transform_arg_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler_rev_arg_s2_k2_d0_x0 = {
.values = 1,
.value = bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_arg0,
.tables = 0,
.table = NULL,
.fields = 0,
.field = NULL,
.field_list = &bcm56990_b0_lta_bcmltx_port_q_oper_state_dst_list_d0,
.kfields = 2,
.kfield = bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_k2,
.kfield_list = &bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_k2,
.rfields = 1,
.rfield = bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_s2,
.rfield_list = &bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_s2,
.comp_data = &bcm56990_b0_lta_bcmltx_port_q_oper_state_comp_data2
};
static const bcmltd_transform_arg_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler_rev_arg_s3_k3_d0_x0 = {
.values = 1,
.value = bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_arg0,
.tables = 0,
.table = NULL,
.fields = 0,
.field = NULL,
.field_list = &bcm56990_b0_lta_bcmltx_port_q_oper_state_dst_list_d0,
.kfields = 2,
.kfield = bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_k3,
.kfield_list = &bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_k3,
.rfields = 1,
.rfield = bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_s3,
.rfield_list = &bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_s3,
.comp_data = &bcm56990_b0_lta_bcmltx_port_q_oper_state_comp_data3
};
static const bcmltd_transform_arg_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler_rev_arg_s4_k4_d0_x1 = {
.values = 1,
.value = bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_arg1,
.tables = 0,
.table = NULL,
.fields = 0,
.field = NULL,
.field_list = &bcm56990_b0_lta_bcmltx_port_q_oper_state_dst_list_d0,
.kfields = 2,
.kfield = bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_k4,
.kfield_list = &bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_k4,
.rfields = 1,
.rfield = bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_s4,
.rfield_list = &bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_s4,
.comp_data = &bcm56990_b0_lta_bcmltx_port_q_oper_state_comp_data4
};
static const bcmltd_transform_arg_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler_rev_arg_s5_k5_d0_x1 = {
.values = 1,
.value = bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_arg1,
.tables = 0,
.table = NULL,
.fields = 0,
.field = NULL,
.field_list = &bcm56990_b0_lta_bcmltx_port_q_oper_state_dst_list_d0,
.kfields = 2,
.kfield = bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_k5,
.kfield_list = &bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_k5,
.rfields = 1,
.rfield = bcm56990_b0_lta_bcmltx_port_q_oper_state_transform_src_s5,
.rfield_list = &bcm56990_b0_lta_bcmltx_port_q_oper_state_src_list_s5,
.comp_data = &bcm56990_b0_lta_bcmltx_port_q_oper_state_comp_data5
};
const bcmltd_xfrm_handler_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler_rev_s0_k0_d0_x0 = {
.ext_transform = bcmltx_port_q_oper_state_rev_transform,
.arg = &bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler_rev_arg_s0_k0_d0_x0
};
const bcmltd_xfrm_handler_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler_rev_s1_k1_d0_x1 = {
.ext_transform = bcmltx_port_q_oper_state_rev_transform,
.arg = &bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler_rev_arg_s1_k1_d0_x1
};
const bcmltd_xfrm_handler_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler_rev_s2_k2_d0_x0 = {
.ext_transform = bcmltx_port_q_oper_state_rev_transform,
.arg = &bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler_rev_arg_s2_k2_d0_x0
};
const bcmltd_xfrm_handler_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler_rev_s3_k3_d0_x0 = {
.ext_transform = bcmltx_port_q_oper_state_rev_transform,
.arg = &bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler_rev_arg_s3_k3_d0_x0
};
const bcmltd_xfrm_handler_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler_rev_s4_k4_d0_x1 = {
.ext_transform = bcmltx_port_q_oper_state_rev_transform,
.arg = &bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler_rev_arg_s4_k4_d0_x1
};
const bcmltd_xfrm_handler_t
bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler_rev_s5_k5_d0_x1 = {
.ext_transform = bcmltx_port_q_oper_state_rev_transform,
.arg = &bcm56990_b0_lta_bcmltx_port_q_oper_state_xfrm_handler_rev_arg_s5_k5_d0_x1
};
| 31.103647 | 134 | 0.738476 |
241513b8cde6b226e8e8d3f80b6f80382cb8040d | 232 | h | C | src/sensors.h | odontomachus/hotbox | d42c48d7f056f2b1f7bd707ad674e737a3c2fe08 | [
"MIT"
] | null | null | null | src/sensors.h | odontomachus/hotbox | d42c48d7f056f2b1f7bd707ad674e737a3c2fe08 | [
"MIT"
] | null | null | null | src/sensors.h | odontomachus/hotbox | d42c48d7f056f2b1f7bd707ad674e737a3c2fe08 | [
"MIT"
] | null | null | null | const double phys_params[2][3] =
{ {0.0009083, 0.0002229, 4.232e-08},
{0.001109, 0.0001925, 1.471e-07} };
const double log_resistors[2] = {9.890909, 9.893437};
const char mux_mask[2] = {0b0101, 0b0100};
void ADC_init(void);
| 29 | 53 | 0.663793 |
c9b5ba49c1d6fb16d9bf0f79f538239f37e2a331 | 827 | h | C | HAPI/optix/Renderer.h | Geerthan/HAPI-GPU | a9ffe70b1b43392344fef2ba552965b4eb8cc4a2 | [
"MIT"
] | null | null | null | HAPI/optix/Renderer.h | Geerthan/HAPI-GPU | a9ffe70b1b43392344fef2ba552965b4eb8cc4a2 | [
"MIT"
] | null | null | null | HAPI/optix/Renderer.h | Geerthan/HAPI-GPU | a9ffe70b1b43392344fef2ba552965b4eb8cc4a2 | [
"MIT"
] | null | null | null | #pragma once
#define NOMINMAX
#include <optix.h>
#include <optixu/optixu_matrix.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sutil/sutil.h>
#include <fstream>
#include <string>
#include <iostream>
#include <map>
#include "ProgramCreator.h"
#include "GeometryGenerator.h"
class Renderer {
private:
int WIDTH;
int HEIGHT;
optix::Context context;
public:
Renderer(int width, int height, int rayCount, int entryPoints, int stackSize);
/*
Create a buffer that can be used to read or write from the GPU
*/
void createBuffer(std::string bufferName);
/*
Render the scene
*/
void render(int entryPoints);
/*
Display the data from the output buffer to the screen
*/
void display(int * argc, char * argv[], std::string outputBufferName);
void cleanUp();
optix::Context getContext();
}; | 19.232558 | 79 | 0.720677 |
dba39a34b8155ecd6c4a9c55ba233515b56980a5 | 222 | h | C | AlarmClock/AlarmClock/TableViewController.h | LZ-lizhen/LZAlarmClock | d65bcb0a1209dd44acd12d8d10753146f29a53e5 | [
"MIT"
] | 1 | 2017-03-08T01:21:38.000Z | 2017-03-08T01:21:38.000Z | AlarmClock/AlarmClock/TableViewController.h | LZ-lizhen/LZAlarmClock | d65bcb0a1209dd44acd12d8d10753146f29a53e5 | [
"MIT"
] | 1 | 2017-07-13T09:11:49.000Z | 2017-07-13T09:11:49.000Z | AlarmClock/AlarmClock/TableViewController.h | LZ-lizhen/LZAlarmClock | d65bcb0a1209dd44acd12d8d10753146f29a53e5 | [
"MIT"
] | null | null | null | //
// TableViewController.h
// AlarmClock
//
// Created by lizhen on 17/2/27.
// Copyright © 2017年 lizhen. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface TableViewController : UITableViewController
@end
| 15.857143 | 54 | 0.711712 |
57de273e31de3514f97bc868aca6efc8dc4616aa | 2,566 | h | C | include/PPF.h | adrelino/point-pair-features | cda8eb667b2866d6384a4e203bb81183230d2b51 | [
"Apache-2.0"
] | 58 | 2015-10-17T16:01:14.000Z | 2022-03-30T06:36:47.000Z | include/PPF.h | Micalson/ppf-reconstruction | cda8eb667b2866d6384a4e203bb81183230d2b51 | [
"Apache-2.0"
] | 1 | 2016-02-28T02:54:11.000Z | 2017-04-13T06:26:16.000Z | include/PPF.h | Micalson/ppf-reconstruction | cda8eb667b2866d6384a4e203bb81183230d2b51 | [
"Apache-2.0"
] | 27 | 2016-05-26T11:40:45.000Z | 2022-01-21T06:35:05.000Z | //
// PPF.h
// PointPairFeatures
//
// Created by Adrian Haarbach on 02.08.14.
// Copyright (c) 2014 Adrian Haarbach. All rights reserved.
//
#ifndef __PointPairFeatures__PPF__
#define __PointPairFeatures__PPF__
#include <iostream>
#include <eigen3/Eigen/Dense>
#include <vector>
#include "Params.h"
using namespace Eigen;
using namespace std;
//struct PPF2 {unsigned int k;
// float alpha;
// unsigned short i;
// //unsigned short j;
// bool operator<(const PPF2 &o) const{
// return k < o.k;
// }
// bool operator>(const PPF2 &o) const{
// return k > o.k;
// }
// bool operator==(const PPF2 &o) const{
// return k == o.k;
// }
// };
class PPF {
public:
//static PPF2 makePPF2(const vector<Vector3f> &pts, const vector<Vector3f> &nor, int i, int j);
PPF();
PPF(const vector<Vector3f> &pts, const vector<Vector3f> &nor, int i, int j);
unsigned short i;//,j;
unsigned short index; //for scene reference points, so we can add it in acc array
//RowVector3f m1, m2, n1, n2;
//double _d,_n1d,_n2d,_n1n2;
unsigned int k; //the hashkey
float alpha;
//TODO: think about weather to save this for later reuse if ppf is peak in acc array
//Projective3f T; //Transformation of point and normal to local coordinates, aligned with x axis
void print();
bool operator==(const PPF &o) const;
int operator()(const PPF& k) const;
bool operator<(const PPF& o) const; //for sorting
unsigned int hashKey();
static Vector4f computePPF(Vector3f m1, Vector3f n1, Vector3f m2, Vector3f n2);
//moves p to origin, aligns n with x-axis
static
Isometry3f alignToOriginAndXAxis(Vector3f p, Vector3f n){
Vector3f xAxis = Vector3f::UnitX();
double angle = acos(xAxis.dot(n));
Vector3f axis = (n.cross(xAxis)).normalized();
//if n parallel to x axis, cross product is [0,0,0]
if(n.y()==0 && n.z()==0) axis=Vector3f::UnitY();
Translation3f tra(-p);
return Isometry3f( AngleAxisf(angle, axis) * tra);
}
//n2 not needed, it is automatically parallel to n because of the feature
static
float planarRotAngle(Vector3f p_i, Vector3f n_i, Vector3f p_j){
Isometry3f T_ms_g=alignToOriginAndXAxis(p_i,n_i);
Vector3f p_j_image=T_ms_g*p_j;
//can ignore x coordinate, since we rotate around x axis
return atan2f(p_j_image.z(), p_j_image.y());
}
};
#endif /* defined(__PointPairFeatures__PPF__) */
| 26.183673 | 100 | 0.632892 |
70eeb1a8698e88a5680865fe775acb1c92952d0b | 185 | c | C | gcc-gcc-7_3_0-release/gcc/testsuite/gcc.dg/torture/pr27116.c | best08618/asylo | 5a520a9f5c461ede0f32acc284017b737a43898c | [
"Apache-2.0"
] | 7 | 2020-05-02T17:34:05.000Z | 2021-10-17T10:15:18.000Z | llvm-gcc-4.2-2.9/gcc/testsuite/gcc.dg/torture/pr27116.c | vidkidz/crossbridge | ba0bf94aee0ce6cf7eb5be882382e52bc57ba396 | [
"MIT"
] | null | null | null | llvm-gcc-4.2-2.9/gcc/testsuite/gcc.dg/torture/pr27116.c | vidkidz/crossbridge | ba0bf94aee0ce6cf7eb5be882382e52bc57ba396 | [
"MIT"
] | 2 | 2020-07-27T00:22:36.000Z | 2021-04-01T09:41:02.000Z | /* { dg-do run } */
extern void abort(void);
int f(int a, int b)
{
return (-1 - a) / (-b);
}
int main()
{
if (f(__INT_MAX__, 2) != __INT_MAX__/2 + 1)
abort ();
return 0;
}
| 11.5625 | 45 | 0.508108 |
d12b9dee8aa6c347bddd2b85b4db412b5d1dcfce | 689 | h | C | hal/armv7/syspage.h | MaciejPurski/phoenix-rtos-kernel | b15f964f671bd89988de41e5b151fa20b6535f97 | [
"BSD-3-Clause"
] | null | null | null | hal/armv7/syspage.h | MaciejPurski/phoenix-rtos-kernel | b15f964f671bd89988de41e5b151fa20b6535f97 | [
"BSD-3-Clause"
] | null | null | null | hal/armv7/syspage.h | MaciejPurski/phoenix-rtos-kernel | b15f964f671bd89988de41e5b151fa20b6535f97 | [
"BSD-3-Clause"
] | null | null | null | /*
* Phoenix-RTOS
*
* Operating system kernel
*
* System information page (prepared by kernel loader)
*
* Copyright 2017 Phoenix Systems
* Author: Pawel Pisarczyk
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/
#ifndef _HAL_SYSPAGE_H_
#define _HAL_SYSPAGE_H_
#include "cpu.h"
#ifndef __ASSEMBLY__
#pragma pack(push, 1)
typedef struct syspage_program_t {
u32 start;
u32 end;
int mapno;
char cmdline[16];
} syspage_program_t;
typedef struct _syspage_t {
u32 pbegin;
u32 pend;
char *arg;
u32 progssz;
syspage_program_t progs[0];
} syspage_t;
#pragma pack(pop)
/* Syspage */
extern syspage_t *syspage;
void _hal_syspageInit(void);
#endif
#endif
| 12.087719 | 54 | 0.708273 |
cd0d98762b3e28694e76cf2394222d38a38bc036 | 32 | c | C | repository/linux/test553.c | ProgramRepair/SearchRepair | 10ce5c53afa0d287d52e821bc2abfad774b63d26 | [
"MIT"
] | 22 | 2016-02-03T21:49:53.000Z | 2021-12-21T19:18:13.000Z | repository/linux/test553.c | ProgramRepair/SearchRepair | 10ce5c53afa0d287d52e821bc2abfad774b63d26 | [
"MIT"
] | 3 | 2015-10-30T22:17:08.000Z | 2019-03-13T15:56:38.000Z | repository/linux/test553.c | ProgramRepair/SearchRepair | 10ce5c53afa0d287d52e821bc2abfad774b63d26 | [
"MIT"
] | 6 | 2015-11-12T16:57:02.000Z | 2019-08-07T10:27:11.000Z | void test(int v){
v = v ;} | 16 | 17 | 0.4375 |
2f0d7b5db354688ed9a4c02f2b2b3345b7e42656 | 177 | h | C | src/STE/ECS/Systems/ConsoleStateSystem.h | silenttowergames/stonetowerenginw | f47977d864f177cb06e681c50c6120c5a630115d | [
"0BSD"
] | 7 | 2020-08-20T17:02:01.000Z | 2022-03-25T13:50:40.000Z | src/STE/ECS/Systems/ConsoleStateSystem.h | silenttowergames/stonetowerenginw | f47977d864f177cb06e681c50c6120c5a630115d | [
"0BSD"
] | 23 | 2020-09-17T22:15:38.000Z | 2021-04-17T16:31:01.000Z | src/STE/ECS/Systems/ConsoleStateSystem.h | silenttowergames/stonetowerengine | f47977d864f177cb06e681c50c6120c5a630115d | [
"0BSD"
] | null | null | null | #pragma once
#include <flecs.h>
#include "../../Application/ApplicationStateFunctions.h"
#include "../../Debug/ConsoleState.h"
void ConsoleStateSystem(ApplicationState* app);
| 22.125 | 56 | 0.751412 |
f3ba127235586e027285d1697314f52c9282cf93 | 8,952 | c | C | src/utils/threading/threadpool.c | simonjj22/libsafecrypto | 3717bec9d9298f163f45acd5af54d708e03e0b9f | [
"MIT"
] | null | null | null | src/utils/threading/threadpool.c | simonjj22/libsafecrypto | 3717bec9d9298f163f45acd5af54d708e03e0b9f | [
"MIT"
] | null | null | null | src/utils/threading/threadpool.c | simonjj22/libsafecrypto | 3717bec9d9298f163f45acd5af54d708e03e0b9f | [
"MIT"
] | null | null | null | /*****************************************************************************
* Copyright (C) Queen's University Belfast, ECIT, 2016 *
* *
* This file is part of libsafecrypto. *
* *
* This file is subject to the terms and conditions defined in the file *
* 'LICENSE', which is part of this source code package. *
*****************************************************************************/
/*
* Git commit information:
* Author: $SC_AUTHOR$
* Date: $SC_DATE$
* Branch: $SC_BRANCH$
* Id: $SC_IDENT$
*/
#include "safecrypto_private.h"
#include "threadpool.h"
//--------------------------- PRIVATE FUNCTIONS -----------------------------//
static void * threadpool_thread(void *threadpool)
{
sc_threadpool_t *pool = (sc_threadpool_t *) threadpool;
sc_threadpool_task_t task;
SINT32 task_complete = 0;
while (1) {
/*struct sched_param param;
int policy;
pthread_t tid = pthread_self();
pthread_getschedparam(tid, &policy, ¶m);
policy = SCHED_OTHER;
pthread_setschedparam(tid, policy, ¶m);*/
utils_threading()->mtx_lock(pool->lock);
if (task_complete) {
task_complete = 0;
pool->task_count--;
utils_threading()->cond_signal(pool->wait);
}
// Check for spurious wakeups
while ((0 == pool->queue_count) && !pool->shutdown) {
utils_threading()->cond_wait(pool->notify, pool->lock);
}
// Check for a forced or graceful exit command
if ((pool->shutdown == THREAD_EXIT_FORCEFULLY) ||
((pool->shutdown == THREAD_EXIT_GRACEFULLY) && (pool->queue_count == 0))) {
break;
}
/*policy = SCHED_RR;
pthread_setschedparam(tid, policy, ¶m);*/
// Grab our task, advance the head pointer and decrement the number
// of buffered tasks for the worker threads
task.routine = pool->queue[pool->head].routine;
task.argument = pool->queue[pool->head].argument;
pool->head = (pool->head + 1) % pool->queue_size;
pool->queue_count--;
utils_threading()->mtx_unlock(pool->lock);
utils_threading()->cond_signal(pool->notify);
// Execute the given task
(*(task.routine))(task.argument);
task_complete = 1;
}
pool->started--;
utils_threading()->mtx_unlock(pool->lock);
utils_threading()->cond_signal(pool->wait);
utils_threading()->thread_exit();
return(NULL);
}
//---------------------------- PUBLIC FUNCTIONS -----------------------------//
SINT32 threadpool_free(sc_threadpool_t *pool)
{
size_t i;
if (pool == NULL || pool->started > 0) {
return SC_FUNC_FAILURE;
}
if (pool->threads) {
for (i=0; i<(size_t)pool->thread_count; i++) {
utils_threading()->thread_destroy(&pool->threads[i]);
}
SC_FREE(pool->threads, sizeof(sc_thread_t*) * pool->thread_count);
SC_FREE(pool->queue, sizeof(sc_threadpool_task_t) * pool->queue_size);
utils_threading()->mtx_lock(pool->lock);
utils_threading()->mtx_destroy(&pool->lock);
utils_threading()->cond_destroy(&pool->notify);
utils_threading()->mtx_lock(pool->wait_lock);
utils_threading()->mtx_destroy(&pool->wait_lock);
utils_threading()->cond_destroy(&pool->wait);
}
SC_FREE(pool, sizeof(sc_threadpool_t));
return SC_FUNC_SUCCESS;
}
sc_threadpool_t *threadpool_create(SINT32 thread_count, SINT32 queue_size)
{
if (thread_count <= 0 ||
thread_count > MAX_THREADS ||
queue_size <= 0 ||
queue_size > MAX_QUEUE) {
return NULL;
}
SINT32 i, j;
sc_threadpool_t *pool = SC_MALLOC(sizeof(sc_threadpool_t));
if (NULL == pool) {
goto creation_error;
}
pool->threads = SC_MALLOC(sizeof(sc_thread_t*) * thread_count);
if (NULL == pool->threads) {
goto creation_error;
}
pool->queue = SC_MALLOC(sizeof(sc_threadpool_task_t) * queue_size);
if (NULL == pool->queue) {
goto creation_error;
}
pool->thread_count = 0;
pool->task_count = 0;
pool->queue_size = queue_size;
pool->head = 0;
pool->tail = 0;
pool->queue_count = 0;
pool->shutdown = THREAD_EXIT_NONE;
pool->started = 0;
// Initialize mutex and conditional variable
pool->lock = utils_threading()->mtx_create();
pool->notify = utils_threading()->cond_create();
pool->wait_lock = utils_threading()->mtx_create();
pool->wait = utils_threading()->cond_create();
if ((NULL == pool->lock) ||
(NULL == pool->notify) ||
(NULL == pool->wait_lock) ||
(NULL == pool->wait) ||
(NULL == pool->threads) ||
(NULL == pool->queue)) {
goto creation_error;
}
// Start worker threads, pinning them to the available processors
// in a wrapped round-robin fashion
SINT32 num_cpu = sysconf(_SC_NPROCESSORS_ONLN);
for (i = 0, j=thread_count>>1; i < thread_count; i++, j++) {
pool->threads[i] = utils_threading()->thread_create(
threadpool_thread, (void*) pool, j % num_cpu);
if (NULL == pool->threads[i]) {
// If any worker thread cannot be created then exit gracefully
threadpool_destroy(pool, THREADPOOL_GRACEFUL_EXIT);
return NULL;
}
pool->thread_count++;
pool->started++;
}
return pool;
creation_error:
if (pool) {
threadpool_free(pool);
}
return NULL;
}
SINT32 threadpool_destroy(sc_threadpool_t *pool, UINT32 flags)
{
SINT32 i;
SINT32 err = SC_OK;
if (pool == NULL) {
return SC_NULL_POINTER;
}
if (SC_OK != utils_threading()->mtx_lock(pool->lock)) {
return SC_FAILED_LOCK;
}
// Already shutting down so return with an error
if (pool->shutdown) {
err = SC_THREAD_EXITING;
goto destroy_error;
}
pool->shutdown = (flags & THREADPOOL_GRACEFUL_EXIT) ?
THREAD_EXIT_GRACEFULLY : THREAD_EXIT_FORCEFULLY;
// Wake up all worker threads
if (SC_OK != (utils_threading()->cond_broadcast(pool->notify)) ||
SC_OK != utils_threading()->mtx_unlock(pool->lock)) {
err = SC_FAILED_LOCK;
goto destroy_error;
}
// Join all worker thread
for (i = 0; i < pool->thread_count; i++) {
if (SC_OK != utils_threading()->thread_join(pool->threads[i])) {
err = SC_THREAD_ERROR;
}
}
destroy_error:
// Only if everything went well do we deallocate the pool
if (!err) {
threadpool_free(pool);
}
return err;
}
SINT32 threadpool_wait(sc_threadpool_t *pool)
{
if (pool == NULL) {
return SC_NULL_POINTER;
}
if (SC_OK != utils_threading()->mtx_lock(pool->wait_lock)) {
return SC_FAILED_LOCK;
}
// If the worker threads are operating wait until no tasks are running
// and the queue is empty
if (0 != pool->started) {
while (0 != pool->task_count || 0 != pool->queue_count) {
utils_threading()->cond_wait(pool->wait, pool->wait_lock);
}
}
if (SC_OK != utils_threading()->mtx_unlock(pool->wait_lock)) {
return SC_FAILED_LOCK;
}
return SC_OK;
}
SINT32 threadpool_add(sc_threadpool_t *pool, task routine, void *argument)
{
SINT32 err = SC_OK;
SINT32 next;
if (pool == NULL || routine == NULL) {
return SC_NULL_POINTER;
}
if (SC_OK != utils_threading()->mtx_lock(pool->lock)) {
return SC_FAILED_LOCK;
}
// The next queue element to be buffered is indexed by the tail
// plus 1 and wraps around the defined queue size
next = (pool->tail + 1) % pool->queue_size;
// If we have no available buffers then return from this function
if (pool->queue_count == pool->queue_size) {
err = SC_QUEUE_FULL;
goto add_error;
}
// If we're in the process of shutting down then return from this function
if (pool->shutdown) {
err = SC_THREAD_EXITING;
goto add_error;
}
// Add task to queue, set the tail end of the queue and increment the number
// of queued tasks for the worker threads
pool->queue[pool->tail].routine = routine;
pool->queue[pool->tail].argument = argument;
pool->tail = next;
pool->queue_count++;
pool->task_count++;
// Signal the condition change to at least one blocked thread
if (SC_OK != utils_threading()->cond_signal(pool->notify)) {
err = SC_FAILED_LOCK;
}
add_error:
if (SC_OK != utils_threading()->mtx_unlock(pool->lock)) {
return SC_FAILED_LOCK;
}
return err;
}
| 29.642384 | 87 | 0.576519 |
2876c9100b048d494074d68df6b8522ce4afe4e9 | 646 | h | C | Loose-GNSS-IMU/Loose-GNSS-IMU/ReaderIMU.h | seongq/Loose-GNSS-IMU | aa2311566d2b1110983d88f055a70bb19b47e4bb | [
"MIT"
] | 128 | 2019-01-28T18:22:59.000Z | 2022-03-14T07:05:51.000Z | Loose-GNSS-IMU/Loose-GNSS-IMU/ReaderIMU.h | SignalImageCV/Loose-GNSS-IMU | aa2311566d2b1110983d88f055a70bb19b47e4bb | [
"MIT"
] | 12 | 2019-04-02T18:17:09.000Z | 2022-03-25T01:58:59.000Z | Loose-GNSS-IMU/Loose-GNSS-IMU/ReaderIMU.h | SignalImageCV/Loose-GNSS-IMU | aa2311566d2b1110983d88f055a70bb19b47e4bb | [
"MIT"
] | 53 | 2019-04-03T03:44:37.000Z | 2022-03-31T04:37:27.000Z | #pragma once
/*
* ReaderIMU.h
* Read and organize IMU sensor input in epochwise manner
* Created on: Sept 27, 2018
* Author: Aaron Boda
*/
#include "pch.h"
#ifndef READERIMU_H_
#define READERIMU_H_
class ReaderIMU
{
public:
// CONSTRUCTOR
ReaderIMU();
// DESTRUCTOR
~ReaderIMU();
// Data Structures
// To store observations in an epoch
struct IMUEpochInfo {
double imuTime;
std::vector<double> Acc;
std::vector<double> Gyr;
double Ax, Ay, Az;
double Gx, Gy, Gz;
};
// Attributes
IMUEpochInfo _IMUdata;
// Functions
void clearObs();
void obsEpoch(std::ifstream& infile);
private:
};
#endif /* READERIMU_H_ */
| 14.681818 | 56 | 0.685759 |
1a92e27dcb7c846c4fbd49a885a079113165ffc0 | 1,014 | c | C | libft/ft_strlen.c | Davyd11/ft_minishell | 3cfbb6e9a7a31906d721ed1e8e393425545ae6b5 | [
"MIT"
] | null | null | null | libft/ft_strlen.c | Davyd11/ft_minishell | 3cfbb6e9a7a31906d721ed1e8e393425545ae6b5 | [
"MIT"
] | null | null | null | libft/ft_strlen.c | Davyd11/ft_minishell | 3cfbb6e9a7a31906d721ed1e8e393425545ae6b5 | [
"MIT"
] | null | null | null | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tomartin <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/04/24 21:06:06 by tomartin #+# #+# */
/* Updated: 2021/04/25 17:22:06 by tomartin ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlen(const char *str)
{
size_t a;
a = 0;
while (str[a] != '\0')
a++;
return (a);
}
| 42.25 | 80 | 0.158777 |
b142e762c1c4b924540d729d38e8913ecd6e445d | 1,701 | h | C | src/main/include/subsystems/Turret.h | Team2959/2022RapidReact | e08ee79f7855d719ac4098b1bede8700b980f091 | [
"BSD-3-Clause"
] | null | null | null | src/main/include/subsystems/Turret.h | Team2959/2022RapidReact | e08ee79f7855d719ac4098b1bede8700b980f091 | [
"BSD-3-Clause"
] | null | null | null | src/main/include/subsystems/Turret.h | Team2959/2022RapidReact | e08ee79f7855d719ac4098b1bede8700b980f091 | [
"BSD-3-Clause"
] | null | null | null | #pragma once
#include <frc2/command/SubsystemBase.h>
#include <rev/CANSparkMax.h>
#include <rev/SparkMaxAnalogSensor.h>
#include <frc/controller/PIDController.h>
#include <frc/AnalogEncoder.h>
#include <cwtech/Debug.h>
#include <wpi/numbers>
#include <frc/DigitalInput.h>
#include <frc/DutyCycle.h>
#include <RobotMap.h>
class Turret : public frc2::SubsystemBase, public cwtech::Debug
{
public:
Turret(cwtech::Debug* parent = nullptr);
void SetDesiredAngle(units::degree_t degrees);
void Periodic() override;
void OnStartup();
private:
static constexpr double TurretMin = -wpi::numbers::pi;
static constexpr double TurretMax = wpi::numbers::pi;
static constexpr double m_turretMotorEncoderRatio = 1.0 / 462.0;
rev::CANSparkMax m_turretMotor{kTurretCanSparkMaxMotor, rev::CANSparkMax::MotorType::kBrushless};
rev::SparkMaxPIDController m_turretController = m_turretMotor.GetPIDController();
rev::SparkMaxAlternateEncoder m_turretRelativeEncoder{m_turretMotor.GetAlternateEncoder(rev::SparkMaxAlternateEncoder::Type::kQuadrature, 4096)};
frc::DigitalInput m_turretDutyCycleEncoderInput{kTurretPulseWidthDigIo};
frc::DutyCycle m_turretDutyCycleEncoder{m_turretDutyCycleEncoderInput};
units::degree_t m_offset;
cwtech::DebugVariable m_rawAnalogOutput = Variable("Analog Encoder Output", 0.0);
cwtech::DebugVariable m_analogDistance = Variable("Analog Encoder Distance", 0.0);
cwtech::DebugVariable m_relativeEncoder = Variable("Relative Encoder Output", 0.0);
cwtech::DebugVariable m_motorOuput = Variable("Direct Motor Output", 0.0);
cwtech::DebugVariable m_initalAnalogOutput = Variable("Inital Analog Encoder Output", 0.0);
};
| 44.763158 | 149 | 0.772487 |
7f7d259b899a7dc3cd8864169f6056fdc4a258cc | 1,824 | c | C | pkg/acs/calacs/lib/multk2d.c | rendinam/hstcal | e08676b02e4c7cd06e3d5630b62f7b59951ac8c3 | [
"BSD-3-Clause"
] | 8 | 2016-07-28T15:14:27.000Z | 2020-04-02T16:37:23.000Z | pkg/acs/calacs/lib/multk2d.c | rendinam/hstcal | e08676b02e4c7cd06e3d5630b62f7b59951ac8c3 | [
"BSD-3-Clause"
] | 484 | 2016-03-14T20:44:42.000Z | 2022-03-31T15:54:38.000Z | pkg/acs/calacs/lib/multk2d.c | rendinam/hstcal | e08676b02e4c7cd06e3d5630b62f7b59951ac8c3 | [
"BSD-3-Clause"
] | 21 | 2016-03-14T14:22:35.000Z | 2022-02-07T18:41:49.000Z | # include "hstio.h"
# include "hstcal.h"
/* The science data and the error array values are multiplied by k;
the data quality array is not modified.
M.D. De La Pena: 05 June 2018
Created AvgSciVal from AvgSciValLine (multk1d.c) and put the new routine
here to complement the multk2d routine.
*/
int multk2d (SingleGroup *a, float k) {
/* arguments:
SingleGroup *a io: input data; output product
float k i: multiply a by this constant
*/
extern int status;
if (k == 1.)
return (status);
/* science data */
int dimx = a->sci.data.nx;
int dimy = a->sci.data.ny;
{unsigned int i, j;
for (j = 0; j < dimy; j++) {
for (i = 0; i < dimx; i++) {
/* science array */
Pix (a->sci.data, i, j) = k * Pix (a->sci.data, i, j);
/* error array */
Pix (a->err.data, i, j) = k * Pix (a->err.data, i, j);
}
}}
return (status);
}
/* Compute the average of all the good pixels in the image, as
well as a weight value.
*/
void AvgSciVal (SingleGroup *y, short sdqflags, double *mean, double *weight) {
double sum = 0.0;
int numgood = 0; /* number of good pixels */
short flagval; /* data quality flag value */
int dimx = y->sci.data.nx;
int dimy = y->sci.data.ny;
{unsigned int i, j;
for (j = 0; j < dimy; j++) {
for (i = 0; i < dimx; i++) {
flagval = DQPix (y->dq.data, i, j);
/* no serious flag bit set */
if ( ! (sdqflags & flagval) ) {
sum += Pix (y->sci.data, i, j);
numgood++;
}
}
}}
*mean = 0.0;
*weight = 0.0;
if (numgood > 0) {
*mean = sum / (double) numgood;
*weight = (double) numgood / (double)(dimx * dimy);
}
}
| 24.32 | 79 | 0.520285 |
cf9acccbdb6013dcef4008cac471aa53ac3bc7ed | 5,139 | c | C | mame/src/mame/video/dbz.c | clobber/MAME-OS-X | ca11d0e946636bda042b6db55c82113e5722fc08 | [
"MIT"
] | 15 | 2015-03-03T23:15:57.000Z | 2021-11-12T07:09:24.000Z | mame/src/mame/video/dbz.c | clobber/MAME-OS-X | ca11d0e946636bda042b6db55c82113e5722fc08 | [
"MIT"
] | null | null | null | mame/src/mame/video/dbz.c | clobber/MAME-OS-X | ca11d0e946636bda042b6db55c82113e5722fc08 | [
"MIT"
] | 8 | 2015-07-07T16:40:44.000Z | 2020-08-18T06:57:29.000Z | /*
Dragonball Z
(c) 1993 Banpresto
Dragonball Z 2 Super Battle
(c) 1994 Banpresto
Video hardware emulation.
*/
#include "emu.h"
#include "video/konicdev.h"
#include "includes/dbz.h"
void dbz_tile_callback( running_machine &machine, int layer, int *code, int *color, int *flags )
{
dbz_state *state = machine.driver_data<dbz_state>();
*color = (state->m_layer_colorbase[layer] << 1) + ((*color & 0x3c) >> 2);
}
void dbz_sprite_callback( running_machine &machine, int *code, int *color, int *priority_mask )
{
dbz_state *state = machine.driver_data<dbz_state>();
int pri = (*color & 0x3c0) >> 5;
if (pri <= state->m_layerpri[3])
*priority_mask = 0xff00;
else if (pri > state->m_layerpri[3] && pri <= state->m_layerpri[2])
*priority_mask = 0xfff0;
else if (pri > state->m_layerpri[2] && pri <= state->m_layerpri[1])
*priority_mask = 0xfffc;
else
*priority_mask = 0xfffe;
*color = (state->m_sprite_colorbase << 1) + (*color & 0x1f);
}
/* Background Tilemaps */
WRITE16_HANDLER( dbz_bg2_videoram_w )
{
dbz_state *state = space->machine().driver_data<dbz_state>();
COMBINE_DATA(&state->m_bg2_videoram[offset]);
tilemap_mark_tile_dirty(state->m_bg2_tilemap, offset / 2);
}
static TILE_GET_INFO( get_dbz_bg2_tile_info )
{
dbz_state *state = machine.driver_data<dbz_state>();
int tileno, colour, flag;
tileno = state->m_bg2_videoram[tile_index * 2 + 1] & 0x7fff;
colour = (state->m_bg2_videoram[tile_index * 2] & 0x000f);
flag = (state->m_bg2_videoram[tile_index * 2] & 0x0080) ? TILE_FLIPX : 0;
SET_TILE_INFO(0, tileno, colour + (state->m_layer_colorbase[5] << 1), flag);
}
WRITE16_HANDLER( dbz_bg1_videoram_w )
{
dbz_state *state = space->machine().driver_data<dbz_state>();
COMBINE_DATA(&state->m_bg1_videoram[offset]);
tilemap_mark_tile_dirty(state->m_bg1_tilemap, offset / 2);
}
static TILE_GET_INFO( get_dbz_bg1_tile_info )
{
dbz_state *state = machine.driver_data<dbz_state>();
int tileno, colour, flag;
tileno = state->m_bg1_videoram[tile_index * 2 + 1] & 0x7fff;
colour = (state->m_bg1_videoram[tile_index * 2] & 0x000f);
flag = (state->m_bg1_videoram[tile_index * 2] & 0x0080) ? TILE_FLIPX : 0;
SET_TILE_INFO(1, tileno, colour + (state->m_layer_colorbase[4] << 1), flag);
}
VIDEO_START( dbz )
{
dbz_state *state = machine.driver_data<dbz_state>();
state->m_bg1_tilemap = tilemap_create(machine, get_dbz_bg1_tile_info, tilemap_scan_rows, 16, 16, 64, 32);
state->m_bg2_tilemap = tilemap_create(machine, get_dbz_bg2_tile_info, tilemap_scan_rows, 16, 16, 64, 32);
tilemap_set_transparent_pen(state->m_bg1_tilemap, 0);
tilemap_set_transparent_pen(state->m_bg2_tilemap, 0);
if (!strcmp(machine.system().name, "dbz"))
k056832_set_layer_offs(state->m_k056832, 0, -34, -16);
else
k056832_set_layer_offs(state->m_k056832, 0, -35, -16);
k056832_set_layer_offs(state->m_k056832, 1, -31, -16);
k056832_set_layer_offs(state->m_k056832, 3, -31, -16); //?
k053247_set_sprite_offs(state->m_k053246, -87, 32);
}
SCREEN_UPDATE( dbz )
{
dbz_state *state = screen->machine().driver_data<dbz_state>();
static const int K053251_CI[6] = { K053251_CI3, K053251_CI4, K053251_CI4, K053251_CI4, K053251_CI2, K053251_CI1 };
int layer[5], plane, new_colorbase;
state->m_sprite_colorbase = k053251_get_palette_index(state->m_k053251, K053251_CI0);
for (plane = 0; plane < 6; plane++)
{
new_colorbase = k053251_get_palette_index(state->m_k053251, K053251_CI[plane]);
if (state->m_layer_colorbase[plane] != new_colorbase)
{
state->m_layer_colorbase[plane] = new_colorbase;
if (plane <= 3)
k056832_mark_plane_dirty(state->m_k056832, plane);
else if (plane == 4)
tilemap_mark_all_tiles_dirty(state->m_bg1_tilemap);
else if (plane == 5)
tilemap_mark_all_tiles_dirty(state->m_bg2_tilemap);
}
}
//layers priority
layer[0] = 0;
state->m_layerpri[0] = k053251_get_priority(state->m_k053251, K053251_CI3);
layer[1] = 1;
state->m_layerpri[1] = k053251_get_priority(state->m_k053251, K053251_CI4);
layer[2] = 3;
state->m_layerpri[2] = k053251_get_priority(state->m_k053251, K053251_CI0);
layer[3] = 4;
state->m_layerpri[3] = k053251_get_priority(state->m_k053251, K053251_CI2);
layer[4] = 5;
state->m_layerpri[4] = k053251_get_priority(state->m_k053251, K053251_CI1);
konami_sortlayers5(layer, state->m_layerpri);
bitmap_fill(screen->machine().priority_bitmap, cliprect, 0);
for (plane = 0; plane < 5; plane++)
{
int flag, pri;
if (plane == 0)
{
flag = TILEMAP_DRAW_OPAQUE;
pri = 0;
}
else
{
flag = 0;
pri = 1 << (plane - 1);
}
if(layer[plane] == 4)
k053936_zoom_draw(state->m_k053936_2, bitmap, cliprect, state->m_bg1_tilemap, flag, pri, 1);
else if(layer[plane] == 5)
k053936_zoom_draw(state->m_k053936_1, bitmap, cliprect, state->m_bg2_tilemap, flag, pri, 1);
else
k056832_tilemap_draw(state->m_k056832, bitmap, cliprect, layer[plane], flag, pri);
}
k053247_sprites_draw(state->m_k053246, bitmap, cliprect);
return 0;
}
| 30.772455 | 116 | 0.690407 |
9a5dae437ed97ef8796a732fd526c2b0fb8eea91 | 3,283 | h | C | lib/active_shift2d.h | Queequeg92/Active-Shift-TF | 51c078a0bb35739d7d4b7d343ed2e4947a9f927a | [
"Apache-2.0"
] | 22 | 2018-10-03T20:37:01.000Z | 2021-04-08T01:41:27.000Z | lib/active_shift2d.h | Queequeg92/Active-Shift-TF | 51c078a0bb35739d7d4b7d343ed2e4947a9f927a | [
"Apache-2.0"
] | 4 | 2019-01-24T15:35:00.000Z | 2020-04-24T05:25:12.000Z | lib/active_shift2d.h | Queequeg92/Active-Shift-TF | 51c078a0bb35739d7d4b7d343ed2e4947a9f927a | [
"Apache-2.0"
] | 4 | 2018-12-27T14:15:09.000Z | 2021-05-20T14:59:01.000Z | /* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_KERNELS_ASL_OPS_H_
#define TENSORFLOW_KERNELS_ASL_OPS_H_
// #define EIGEN_USE_GPU
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/framework/tensor_types.h"
#include "tensorflow/core/framework/tensor_shape.h"
#include <cstring>
#include <vector>
namespace tensorflow {
// typedef Eigen::ThreadPoolDevice CPUDevice;
// typedef std::vector<int> TShape;
// typedef Eigen::GpuDevice GPUDevice;
namespace functor {
template <typename Device, typename DType>
struct ASLForward{
void operator()(const Device& d,
const int count, const int num, const int channels,
const int top_height, const int top_width,
const int bottom_height, const int bottom_width,
const DType* xshift, const DType* yshift,
const int pad_h, const int pad_w,
const int stride_h, const int stride_w,
const DType* bottom_data, DType* top_data);
};
template <typename Device, typename DType>
struct ASL_ShiftBackward{
void operator()(const Device& d,
const int count, const int num, const int channels,
const int top_height, const int top_width,
const int bottom_height, const int bottom_width,
const DType* xshift, const DType* yshift,
const int pad_h, const int pad_w,
const int stride_h, const int stride_w,
const DType* bottom_data, const DType* top_diff,
DType* bottom_backprop_ptr, DType* offset_backprop_ptr, DType* temp_buf_ptr);
};
template <typename Device, typename DType>
struct ASL_BottomBackward{
void operator()(const Device& d,
const int count, const int num, const int channels,
const int top_height, const int top_width,
const int bottom_height, const int bottom_width,
const DType* xshift, const DType* yshift,
const int pad_h, const int pad_w,
const int stride_h, const int stride_w,
const DType* bottom_data, const DType* top_diff,
DType* bottom_backprop_ptr, DType* offset_backprop_ptr);
};
template <typename Device, typename DType>
struct ApplyShiftConstraint{
void operator()(const Device& d, const int count,
const DType* xshift_data, const DType* yshift_data,
DType* xshift_diff, DType* yshift_diff,
const bool normalize, const float clip_gradient);
};
template <typename Device, typename DType>
struct setZero {
void operator() (const Device& d, const int n, DType* out);
};
template <typename Device, typename DType>
struct setValue {
void operator() (const Device& d, const int n, const DType val, DType* out);
};
} // namespace functor
} // namespace tensorflow
#endif // TENSORFLOW_KERNELS_ASL_OPS_H_
| 34.197917 | 80 | 0.745659 |
2cd5aec30524fafecffbcde017dc9965462476a9 | 917 | h | C | System/Library/PrivateFrameworks/MobileBackup.framework/MBDeviceTransferKeychain.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | 1 | 2020-11-04T15:43:01.000Z | 2020-11-04T15:43:01.000Z | System/Library/PrivateFrameworks/MobileBackup.framework/MBDeviceTransferKeychain.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | System/Library/PrivateFrameworks/MobileBackup.framework/MBDeviceTransferKeychain.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | /*
* This header is generated by classdump-dyld 1.0
* on Sunday, September 27, 2020 at 11:41:11 AM Mountain Standard Time
* Operating System: Version 14.0 (Build 18A373)
* Image Source: /System/Library/PrivateFrameworks/MobileBackup.framework/MobileBackup
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos.
*/
#import <MobileBackup/MobileBackup-Structs.h>
#import <libobjc.A.dylib/NSCopying.h>
#import <libobjc.A.dylib/NSSecureCoding.h>
@class NSString;
@interface MBDeviceTransferKeychain : NSObject <NSCopying, NSSecureCoding> {
NSString* _uuid;
}
@property (nonatomic,retain) NSString * uuid; //@synthesize uuid=_uuid - In the implementation block
+(BOOL)supportsSecureCoding;
-(id)copyWithZone:(NSZone*)arg1 ;
-(id)init;
-(void)setUuid:(NSString *)arg1 ;
-(id)initWithCoder:(id)arg1 ;
-(NSString *)uuid;
-(void)encodeWithCoder:(id)arg1 ;
-(id)description;
@end
| 28.65625 | 113 | 0.747001 |
306285929e2ab83be0537c2e9c48260160f6d1d8 | 1,279 | h | C | usr/libexec/pipelined/CLGpsPosition.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | 1 | 2020-11-04T15:43:01.000Z | 2020-11-04T15:43:01.000Z | usr/libexec/pipelined/CLGpsPosition.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | usr/libexec/pipelined/CLGpsPosition.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | //
// Generated by classdumpios 1.0.1 (64 bit) (iOS port by DreamDevLost)(Debug version compiled Sep 26 2020 13:48:20).
//
// Copyright (C) 1997-2019 Steve Nygard.
//
#import <objc/NSObject.h>
#import "NSSecureCoding-Protocol.h"
@interface CLGpsPosition : NSObject <NSSecureCoding>
{
time_point_e708cccf _expiry; // 8 = 0x8
CDStruct_4d1fbe9a _gpsLocation; // 16 = 0x10
CDStruct_6422f5cf _gpsLocationPrivate; // 160 = 0xa0
}
+ (_Bool)supportsSecureCoding; // IMP=0x000000010012ecbc
- (id).cxx_construct; // IMP=0x000000010012f0a8
@property(readonly, nonatomic) time_point_e708cccf expiry; // @synthesize expiry=_expiry;
@property(readonly, nonatomic) CDStruct_6422f5cf gpsLocationPrivate; // @synthesize gpsLocationPrivate=_gpsLocationPrivate;
@property(readonly, nonatomic) CDStruct_4d1fbe9a gpsLocation; // @synthesize gpsLocation=_gpsLocation;
- (id)description; // IMP=0x000000010012efac
- (void)encodeWithCoder:(id)arg1; // IMP=0x000000010012ef48
- (id)initWithCoder:(id)arg1; // IMP=0x000000010012ee1c
- (_Bool)isStaleFix:(time_point_e708cccf)arg1; // IMP=0x000000010012ee0c
- (id)initWithLocation:(const CDStruct_4d1fbe9a *)arg1 andPrivateLocation:(const CDStruct_6422f5cf *)arg2; // IMP=0x000000010012ed14
- (id)init; // IMP=0x000000010012ecc4
@end
| 39.96875 | 132 | 0.769351 |
cf518d32ee3ffe71fd7962e1710fcb6fb8944315 | 7,600 | h | C | include/IECoreNuke/LensDistort.h | bradleyhenke/cortex | f8245cc6c9464b1de9e6c6e57068248198e63de0 | [
"BSD-3-Clause"
] | 386 | 2015-01-02T11:10:43.000Z | 2022-03-10T15:12:20.000Z | include/IECoreNuke/LensDistort.h | bradleyhenke/cortex | f8245cc6c9464b1de9e6c6e57068248198e63de0 | [
"BSD-3-Clause"
] | 484 | 2015-01-09T18:28:06.000Z | 2022-03-31T16:02:04.000Z | include/IECoreNuke/LensDistort.h | bradleyhenke/cortex | f8245cc6c9464b1de9e6c6e57068248198e63de0 | [
"BSD-3-Clause"
] | 99 | 2015-01-28T23:18:04.000Z | 2022-03-27T00:59:39.000Z | //////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2011, Weta Digital Limited. All rights reserved.
// Copyright (c) 2013, Image Engine Design Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * 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 Image Engine Design nor the names of any
// other contributors to this software 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 IECORENUKE_LENSDISTORT_H
#define IECORENUKE_LENSDISTORT_H
#include "IECoreNuke/Export.h"
#include "IECore/LensModel.h"
#include "DDImage/Filter.h"
#include "DDImage/Iop.h"
#include "DDImage/Knobs.h"
#include "DDImage/Row.h"
#include "DDImage/Thread.h"
namespace IECoreNuke
{
/// LensDistort
/// Uses the IECore::LensModel libraries to distort or undistort a plate or sequence.
/// The LensDistort node provides a nuke interface to the IECore::LensDistort libraries.
/// It queries any registered lens models, displaying them within the pull-down menu of the "lens model"
/// knob. When a lens model is selected the node will dynamically create the required knobs on the
/// UI panel. An additional knob has been added to allow the input of a sequence of lens models
/// which have been serialized into .cob files.
///
/// Weta Digitals LensDistortion node was referenced when designing this node.
/// Their source code is available freely at: https://github.com/wetadigital/lensDistortion_3de
class IECORENUKE_API LensDistort : public DD::Image::Iop
{
/// PluginAttribute
/// A small struct for maintaining a list of the knobs on the UI and their values.
struct PluginAttribute
{
public:
PluginAttribute( std::string name, double defaultValue = 0. ) :
m_name( name ),
m_knob( NULL ),
m_value( defaultValue ),
m_low( 0. ),
m_high( 1. )
{};
PluginAttribute() :
m_name( "Unused" ),
m_knob( NULL ),
m_value( 0. ),
m_low( 0. ),
m_high( 1. )
{};
std::string m_name;
DD::Image::Knob *m_knob;
std::string m_script;
double m_value;
double m_low;
double m_high;
};
typedef std::vector< PluginAttribute > PluginAttributeList;
public:
enum
{
Distort,
Undistort
};
LensDistort( Node* node );
inline int getLensModel() const { return (int)knob("model")->get_value(); };
inline PluginAttributeList &attributeList() { return m_pluginAttributes; };
virtual void knobs( DD::Image::Knob_Callback f );
virtual int knob_changed( DD::Image::Knob* k );
virtual void append( DD::Image::Hash &hash );
virtual void _request( int x, int y, int r, int t, DD::Image::ChannelMask channels, int count );
virtual const char *Class() const;
virtual const char *node_help() const;
virtual void _validate( bool for_real );
virtual void engine( int y, int x, int r, DD::Image::ChannelMask channels, DD::Image::Row & outrow );
static void buildDynamicKnobs( void*, DD::Image::Knob_Callback f );
static void addDynamicKnobs( void*, DD::Image::Knob_Callback f );
static const Iop::Description m_description;
static DD::Image::Op *build( Node *node );
private:
/// Returns an array of const char* which is populated with the available lens models.
static const char ** modelNames();
static int indexFromModelName( const char *name );
/// Sets the lens model to use by calling the appropriate creators..
void setLensModel( IECore::ConstCompoundObjectPtr parameters );
void setLensModel( std::string modelName );
/// Updates the internal list of lens parameters (and their associated knobs) to those defined within the current lens models.
/// This method should only be called at the end of setLensModel.
/// @param updateKnobsFromParameters If this value is true then all knobs will be updated to the new lens model's parameters and any existing knob values.
/// will be discarded. If this value is false then the values of common parameters between the current and new lens model will be copied across.
void updateLensModel( bool updateKnobsFromParameters = false );
/// Returns true if there is text in the file sequence knob. The contents of the knob are returned in the attribute 'path'.
bool getFileSequencePath( std::string& path );
/// Checks that the file sequence is valid and then loads the required file from it. File sequences of the format path.#.ext and path.%0Xd.ext will have their
/// wild card characters replaced and set to the current frame.
/// @param returnPath The path of the file that has been loaded.
/// @return Whether or not the file path was successful.
bool setLensFromFile( std::string &returnPath );
/// Iterates over all of the lens model's attributes and if they are associated with a knob, retrieves the information from the knob.
void updatePluginAttributesFromKnobs();
/// Updates the dynamic knobs. This method should be called whenever a knob is changed or an event happens that requires
/// the dynamic knobs to be recreated or their enabled state changed.
void updateUI();
/// The maximum number of threads that we are going to use in parallel.
const int m_nThreads;
/// Plugin loaders. We need one of these per threads to make the lens lib thread safe.
std::vector< IECore::LensModelPtr > m_model;
/// locks for each LensModel object
DD::Image::Lock* m_locks;
/// A list of the attributes that the plugin uses.
PluginAttributeList m_pluginAttributes;
/// Which lens model we are currently using.
int m_lensModel;
/// Used to track the number of knobs created by the previous pass, so that the same number can be deleted next time.
int m_numNewKnobs;
/// The method of filtering. Defined by the 'filter' knob.
DD::Image::Filter m_filter;
/// Pointer to the 'mode' knob.
DD::Image::Knob *m_kModel;
/// Distort or undistort.
int m_mode;
/// All knobs below this one are dynamic.
DD::Image::Knob* m_lastStaticKnob;
/// Path that holds the file sequence information.
const char *m_assetPath;
/// Set within the knob_changed method to indicate whether a valid file sequence has been entered.
bool m_hasValidFileSequence;
bool m_useFileSequence;
};
};
#endif
| 38.77551 | 160 | 0.715263 |
45ce733874febdec69740426b64e03107ba0372c | 1,291 | h | C | core/include/mmcore/InstanceRequest.h | xge/megamol | 1e298dd3d8b153d7468ed446f6b2ed3ac49f0d5b | [
"BSD-3-Clause"
] | 49 | 2017-08-23T13:24:24.000Z | 2022-03-16T09:10:58.000Z | core/include/mmcore/InstanceRequest.h | xge/megamol | 1e298dd3d8b153d7468ed446f6b2ed3ac49f0d5b | [
"BSD-3-Clause"
] | 200 | 2018-07-20T15:18:26.000Z | 2022-03-31T11:01:44.000Z | core/include/mmcore/InstanceRequest.h | xge/megamol | 1e298dd3d8b153d7468ed446f6b2ed3ac49f0d5b | [
"BSD-3-Clause"
] | 31 | 2017-07-31T16:19:29.000Z | 2022-02-14T23:41:03.000Z | /*
* InstanceRequest.h
*
* Copyright (C) 2009 by VISUS (Universitaet Stuttgart).
* Alle Rechte vorbehalten.
*/
#ifndef MEGAMOLCORE_INSTANCEREQUEST_H_INCLUDED
#define MEGAMOLCORE_INSTANCEREQUEST_H_INCLUDED
#if (defined(_MSC_VER) && (_MSC_VER > 1000))
#pragma once
#endif /* (defined(_MSC_VER) && (_MSC_VER > 1000)) */
#include "mmcore/ParamValueSetRequest.h"
#include "vislib/String.h"
namespace megamol {
namespace core {
/**
* Abstract base class of job and view instantiation requests.
*/
class InstanceRequest : public ParamValueSetRequest {
public:
/**
* Answer the name for the instance to be instantiated.
*
* @return The name
*/
inline const vislib::StringA& Name(void) const {
return this->name;
}
/**
* Sets the name for the instance to be instantiated.
*
* @param name The new name
*/
inline void SetName(const vislib::StringA& name) {
this->name = name;
}
protected:
/**
* Ctor.
*/
InstanceRequest(void);
/**
* Dtor.
*/
virtual ~InstanceRequest(void);
private:
/** The name of the instance requested. */
vislib::StringA name;
};
} /* end namespace core */
} /* end namespace megamol */
#endif /* MEGAMOLCORE_INSTANCEREQUEST_H_INCLUDED */
| 20.171875 | 62 | 0.646011 |
ca1c95ca49729a2c592cf8db7a91a165a0096e3b | 88,062 | c | C | Games/Set/src/src/gfx/logo.c | CiaranGruber/Ti-84-Calculator | 96742a4a2b9e21aa9d675575dc7e4f26365430c0 | [
"MIT"
] | 1 | 2019-03-31T11:49:12.000Z | 2019-03-31T11:49:12.000Z | Games/Set/src/src/gfx/logo.c | CiaranGruber/Ti-84-Calculator | 96742a4a2b9e21aa9d675575dc7e4f26365430c0 | [
"MIT"
] | null | null | null | Games/Set/src/src/gfx/logo.c | CiaranGruber/Ti-84-Calculator | 96742a4a2b9e21aa9d675575dc7e4f26365430c0 | [
"MIT"
] | 1 | 2020-03-09T13:21:19.000Z | 2020-03-09T13:21:19.000Z | // convpng v6.8
#include <stdint.h>
#include "logo_gfx.h"
// 8 bpp image
uint8_t logo_data[17552] = {
195,90, // width,height
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x60,0x80,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0x80,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE9,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x24,0x24,0x24,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x11,0x11,0x11,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x5B,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0xA0,0x60,0x60,0x60,0xA0,0xA0,0xC0,0xC0,0xC0,0xC0,0xA0,0xA0,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x60,0x40,0x00,0x00,0x00,0x00,0x00,0x40,0xA0,0xC0,0xC0,0xC0,0xA0,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x40,0x40,0x40,0x40,0x00,0x00,0x00,0x40,0xA0,0xC0,0x60,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x03,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x60,0x40,0x00,0x00,0x60,0xA0,0xC0,0xC0,0xC0,0xA0,0x60,0x00,0x00,0x00,0x40,0x00,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x00,0x00,0x00,0x08,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x10,0x00,0x00,0x00,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x60,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x00,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x03,0x02,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x00,0x00,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x00,0x00,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x00,0x10,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x08,0x00,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x00,0x00,0x00,0x60,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x00,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x00,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x00,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x60,0x00,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x00,0x60,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x10,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x10,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x00,0x00,0x00,0x00,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x40,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x03,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x60,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x00,0x00,0x00,0x00,0x00,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x60,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x03,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x02,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x03,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x03,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x03,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x00,0x00,0x00,0x40,0xA0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x03,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x08,0x00,0x00,0x00,0x08,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x03,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x00,0x00,0x00,0x00,0x00,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x02,0x05,0x05,0x05,0x05,0x03,0x02,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x00,0x00,0x00,0x00,0x00,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x00,0x00,0x00,0x40,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x60,0x00,0x00,0x00,0x00,0x00,0x40,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x00,0x00,0x00,0x00,0x00,0x40,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x00,0x00,0x00,0x00,0x00,0x40,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xA0,0x40,0x00,0x00,0x00,0x00,0x40,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x60,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x40,0x00,0x00,0x00,0x00,0x40,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE8,0xE8,0xE8,0xE8,0x60,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x24,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x26,0x26,0x26,0x26,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x3A,0x3A,0x3A,0x3A,0x10,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x60,0x80,0x80,0x80,0x80,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x40,0x00,0x00,0x00,0x00,0x40,0x60,0x60,0x60,0x60,0x60,0x60,0xE8,0xE8,0xE8,0xE8,0x60,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x24,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x26,0x26,0x26,0x26,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x11,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x3A,0x3A,0x3A,0x10,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x60,0x80,0x80,0x80,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x40,0x00,0x00,0x00,0x00,0x40,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0xE8,0xE8,0xE8,0x60,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x24,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x26,0x26,0x26,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x11,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x3A,0x3A,0x10,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x60,0x80,0x80,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x40,0x00,0x00,0x00,0x00,0x40,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0xE8,0xE8,0x60,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x24,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x26,0x26,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x11,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x3A,0x10,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x60,0x80,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x40,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0xE8,0x60,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0x24,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x26,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x40,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x29,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0x00,0x00,0x29,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0x00,0x00,0x29,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0x00,0x00,0x29,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0x00,0x00,0x29,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x29,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x29,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x29,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x29,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x29,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x29,0xFF,0xFF,0xFF,0xFF,0x29,0x29,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x00,0x00,0x00,0x29,0x00,0x00,0x00,0x00,0x00,0x29,0x29,0x00,0x00,0x00,0x00,0x00,0x00,0x29,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x29,0x29,0x21,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x29,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x21,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
};
| 889.515152 | 976 | 0.798142 |
43f372cde43a55783075ed5c294b9766ef08e898 | 1,143 | h | C | mingw/x86_64-w64-mingw32/include/mapiwin.h | featherflew/DLSA2018 | 5b6e404060c19bf558e938a145ab89c0a01678d2 | [
"MIT"
] | null | null | null | mingw/x86_64-w64-mingw32/include/mapiwin.h | featherflew/DLSA2018 | 5b6e404060c19bf558e938a145ab89c0a01678d2 | [
"MIT"
] | null | null | null | mingw/x86_64-w64-mingw32/include/mapiwin.h | featherflew/DLSA2018 | 5b6e404060c19bf558e938a145ab89c0a01678d2 | [
"MIT"
] | 1 | 2020-11-04T03:27:51.000Z | 2020-11-04T03:27:51.000Z | /**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#ifndef __MAPIWIN_H__
#define __MAPIWIN_H__
#include "mapinls.h"
#ifdef __cplusplus
extern "C" {
#endif
#define MULDIV(x,y,z) MulDiv(x,y,z)
extern LPVOID pinstX;
#define PvGetInstanceGlobals() pinstX
#define ScSetInstanceGlobals(_pv) (pinstX = _pv,0)
#define PvGetVerifyInstanceGlobals(_pid) pinstX
#define ScSetVerifyInstanceGlobals(_pv,_pid) (pinstX = _pv,0)
#define PvSlowGetInstanceGlobals(_pid) pinstX
#define szMAPIDLLSuffix "32"
#define GetTempFileName32(_szPath,_szPfx,_n,_lpbuf) GetTempFileName(_szPath,_szPfx,_n,_lpbuf)
#define CloseMutexHandle CloseHandle
#define Cbtszsize(_a) ((lstrlen(_a)+1)*sizeof(TCHAR))
#define CbtszsizeA(_a) ((lstrlenA(_a) + 1))
#define CbtszsizeW(_a) ((lstrlenW(_a) + 1)*sizeof(WCHAR))
#define HexCchOf(_s) (sizeof(_s)*2+1)
#define HexSizeOf(_s) (HexCchOf(_s)*sizeof(TCHAR))
WINBOOL WINAPI IsBadBoundedStringPtr(const void *lpsz,UINT cchMax);
#ifdef __cplusplus
}
#endif
#endif
| 28.575 | 93 | 0.764654 |
31944d63338c06aee06b274174e866f7c20bec4e | 4,149 | h | C | sys/sys/ttyhook.h | dcui/FreeBSD-9.3_kernel | 39d9caaa6ba320e2f8e910b1f5f01efc24ca4a92 | [
"BSD-3-Clause"
] | 3 | 2015-12-15T00:56:39.000Z | 2018-01-11T01:01:38.000Z | sys/sys/ttyhook.h | dcui/FreeBSD-9.3_kernel | 39d9caaa6ba320e2f8e910b1f5f01efc24ca4a92 | [
"BSD-3-Clause"
] | null | null | null | sys/sys/ttyhook.h | dcui/FreeBSD-9.3_kernel | 39d9caaa6ba320e2f8e910b1f5f01efc24ca4a92 | [
"BSD-3-Clause"
] | 2 | 2018-01-11T01:01:12.000Z | 2020-11-19T03:07:29.000Z | /*-
* Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: releng/9.3/sys/sys/ttyhook.h 186056 2008-12-13 21:17:46Z mav $
*/
#ifndef _SYS_TTYHOOK_H_
#define _SYS_TTYHOOK_H_
#ifndef _SYS_TTY_H_
#error "can only be included through <sys/tty.h>"
#endif /* !_SYS_TTY_H_ */
struct tty;
/*
* Hooks interface, which allows to capture and inject traffic into the
* input and output paths of a TTY.
*/
typedef int th_rint_t(struct tty *tp, char c, int flags);
typedef size_t th_rint_bypass_t(struct tty *tp, const void *buf, size_t len);
typedef void th_rint_done_t(struct tty *tp);
typedef size_t th_rint_poll_t(struct tty *tp);
typedef size_t th_getc_inject_t(struct tty *tp, void *buf, size_t len);
typedef void th_getc_capture_t(struct tty *tp, const void *buf, size_t len);
typedef size_t th_getc_poll_t(struct tty *tp);
typedef void th_close_t(struct tty *tp);
struct ttyhook {
/* Character input. */
th_rint_t *th_rint;
th_rint_bypass_t *th_rint_bypass;
th_rint_done_t *th_rint_done;
th_rint_poll_t *th_rint_poll;
/* Character output. */
th_getc_inject_t *th_getc_inject;
th_getc_capture_t *th_getc_capture;
th_getc_poll_t *th_getc_poll;
th_close_t *th_close;
};
int ttyhook_register(struct tty **, struct proc *, int,
struct ttyhook *, void *);
void ttyhook_unregister(struct tty *);
#define ttyhook_softc(tp) ((tp)->t_hooksoftc)
#define ttyhook_hashook(tp,hook) ((tp)->t_hook != NULL && \
(tp)->t_hook->th_ ## hook != NULL)
static __inline int
ttyhook_rint(struct tty *tp, char c, int flags)
{
tty_lock_assert(tp, MA_OWNED);
MPASS(!tty_gone(tp));
return tp->t_hook->th_rint(tp, c, flags);
}
static __inline size_t
ttyhook_rint_bypass(struct tty *tp, const void *buf, size_t len)
{
tty_lock_assert(tp, MA_OWNED);
MPASS(!tty_gone(tp));
return tp->t_hook->th_rint_bypass(tp, buf, len);
}
static __inline void
ttyhook_rint_done(struct tty *tp)
{
tty_lock_assert(tp, MA_OWNED);
MPASS(!tty_gone(tp));
tp->t_hook->th_rint_done(tp);
}
static __inline size_t
ttyhook_rint_poll(struct tty *tp)
{
tty_lock_assert(tp, MA_OWNED);
MPASS(!tty_gone(tp));
return tp->t_hook->th_rint_poll(tp);
}
static __inline size_t
ttyhook_getc_inject(struct tty *tp, void *buf, size_t len)
{
tty_lock_assert(tp, MA_OWNED);
MPASS(!tty_gone(tp));
return tp->t_hook->th_getc_inject(tp, buf, len);
}
static __inline void
ttyhook_getc_capture(struct tty *tp, const void *buf, size_t len)
{
tty_lock_assert(tp, MA_OWNED);
MPASS(!tty_gone(tp));
tp->t_hook->th_getc_capture(tp, buf, len);
}
static __inline size_t
ttyhook_getc_poll(struct tty *tp)
{
tty_lock_assert(tp, MA_OWNED);
MPASS(!tty_gone(tp));
return tp->t_hook->th_getc_poll(tp);
}
static __inline void
ttyhook_close(struct tty *tp)
{
tty_lock_assert(tp, MA_OWNED);
tp->t_hook->th_close(tp);
}
#endif /* !_SYS_TTYHOOK_H_ */
| 28.033784 | 77 | 0.744517 |
bdf40d1e66e29fa56974fd75d3475a4103dc4795 | 3,146 | c | C | x/x.c | supermock/cgoemitter-demo | 4d291c17337afc0bd20e2b36e32806725e62d0cb | [
"MIT"
] | 1 | 2018-01-25T22:54:19.000Z | 2018-01-25T22:54:19.000Z | x/x.c | supermock/cgoemitter-demo | 4d291c17337afc0bd20e2b36e32806725e62d0cb | [
"MIT"
] | null | null | null | x/x.c | supermock/cgoemitter-demo | 4d291c17337afc0bd20e2b36e32806725e62d0cb | [
"MIT"
] | 1 | 2018-01-25T22:58:10.000Z | 2018-01-25T22:58:10.000Z | #include "x.h"
void check_err_cgoemitter_args_halloc_arg(void* value) {
if (value == NULL) puts("Failed on cgoemitter_args_halloc_arg()");
}
void check_err_cgoemitter_args_add_arg(int code) {
if (code == EXIT_FAILURE) puts("Failed on cgoemitter_args_add_arg()");
}
void say(char* text) {
char message_result[256];
sprintf(message_result, "Parameter sent to C language: %s", text);
cgoemitter_args_t cgoemitter_args = cgoemitter_new_args(1);
void* message_result_arg = cgoemitter_args_halloc_arg(&message_result, (strlen(message_result)+1) * sizeof(char));
check_err_cgoemitter_args_halloc_arg(message_result_arg);
check_err_cgoemitter_args_add_arg(cgoemitter_args_add_arg(&cgoemitter_args, &message_result_arg));
emit("message", &cgoemitter_args);
}
void sys_info() {
struct utsname uname_info;
uname(&uname_info);
struct SysInfo sys_info;
sys_info.SysName = uname_info.sysname;
sys_info.NodeName = uname_info.nodename;
sys_info.Release = uname_info.release;
sys_info.Version = uname_info.version;
sys_info.Machine = uname_info.machine;
cgoemitter_args_t cgoemitter_args = cgoemitter_new_args(1);
void* sys_info_arg = cgoemitter_args_halloc_arg(&sys_info, sizeof(struct utsname));
check_err_cgoemitter_args_halloc_arg(sys_info_arg);
check_err_cgoemitter_args_add_arg(cgoemitter_args_add_arg(&cgoemitter_args, &sys_info_arg));
emit("sys-info", &cgoemitter_args);
}
void raw_sys_info() {
struct utsname uname_info;
uname(&uname_info);
cgoemitter_args_t cgoemitter_args = cgoemitter_new_args(1);
void *sys_info_arg = cgoemitter_args_halloc_arg(&uname_info, sizeof(struct utsname));
check_err_cgoemitter_args_halloc_arg(sys_info_arg);
check_err_cgoemitter_args_add_arg(cgoemitter_args_add_arg(&cgoemitter_args, &sys_info_arg));
emit("raw-sys-info", &cgoemitter_args);
}
void* worker_scope(void* vargp) {
char* id = (char*)vargp;
int count = 0;
srand(time(NULL));
for (;;) {
sleep(1);
int random_value = 0;
if (++count <= 5) random_value = rand() % 100 + 1;
cgoemitter_args_t cgoemitter_args = cgoemitter_new_args(2);
void* id_arg = cgoemitter_args_halloc_arg(id, (strlen(id)+1) * sizeof(char));
check_err_cgoemitter_args_halloc_arg(id_arg);
check_err_cgoemitter_args_add_arg(cgoemitter_args_add_arg(&cgoemitter_args, &id_arg));
void* random_value_arg = cgoemitter_args_halloc_arg(&random_value, sizeof(int));
check_err_cgoemitter_args_halloc_arg(random_value_arg);
check_err_cgoemitter_args_add_arg(cgoemitter_args_add_arg(&cgoemitter_args, &random_value_arg));
emit("worker", &cgoemitter_args);
if (count == 6) break;
}
free(vargp);
return NULL;
}
void start_work(char* id) {
pthread_t tid;
pthread_create(&tid, NULL, worker_scope, (void*)id);
}
void unknown() {
int value = 10;
cgoemitter_args_t cgoemitter_args = cgoemitter_new_args(1);
void* value_arg = cgoemitter_args_halloc_arg(&value, sizeof(int));
check_err_cgoemitter_args_halloc_arg(value_arg);
check_err_cgoemitter_args_add_arg(cgoemitter_args_add_arg(&cgoemitter_args, &value_arg));
emit("unknown", &cgoemitter_args);
} | 29.961905 | 115 | 0.764781 |
aefad0a550feb31821dd4ddffbd06815c1d4f863 | 687 | c | C | namespace/main-1-uts.c | beyanger/sc | 1ae3db932b0fe8d692d72b6b039e0eba60a9d5a6 | [
"BSD-2-Clause"
] | null | null | null | namespace/main-1-uts.c | beyanger/sc | 1ae3db932b0fe8d692d72b6b039e0eba60a9d5a6 | [
"BSD-2-Clause"
] | null | null | null | namespace/main-1-uts.c | beyanger/sc | 1ae3db932b0fe8d692d72b6b039e0eba60a9d5a6 | [
"BSD-2-Clause"
] | null | null | null |
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <sched.h>
#include <signal.h>
#include <unistd.h>
#define STACK_SIZE (1024*1024)
static char stack[STACK_SIZE];
char *const args[] = {
"/bin/bash", NULL
};
int container_routine(void *arg) {
printf("inside container with pid: %d\n", getpid());
sethostname("container", 10);
execv(args[0], args);
printf("somethings' wrong\n");
return 1;
}
int main() {
printf("outside container with pid: %d\n", getpid());
pid_t cpid = clone(container_routine, stack+sizeof(stack),
CLONE_NEWUTS|SIGCHLD, NULL);
waitpid(cpid, NULL, 0);
printf("parent - container stoped!\n");
return 0;
}
| 18.567568 | 60 | 0.681223 |
64a1bbf916cb42226403efb09e1e750773857075 | 8,492 | h | C | wos.ru_iOS/Pods/Headers/Chivy/CHWebBrowserViewController.h | DZamataev/wos.ru_iOS | 923923c9aea4e595c40c0077a1c12b5ea827e440 | [
"MIT"
] | 1 | 2022-03-18T09:28:57.000Z | 2022-03-18T09:28:57.000Z | wos.ru_iOS/Pods/Headers/Chivy/CHWebBrowserViewController.h | DZamataev/wos.ru_iOS | 923923c9aea4e595c40c0077a1c12b5ea827e440 | [
"MIT"
] | null | null | null | wos.ru_iOS/Pods/Headers/Chivy/CHWebBrowserViewController.h | DZamataev/wos.ru_iOS | 923923c9aea4e595c40c0077a1c12b5ea827e440 | [
"MIT"
] | null | null | null | //
// CHWebBrowserViewController.h
// Chivy
//
// Created by Denis Zamataev on 10/31/13.
// Copyright (c) 2013 Denis Zamataev. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <CBAutoScrollLabel.h>
#import <DKBackBarButtonItem.h>
#import <ARSafariActivity.h>
#import <ARChromeActivity.h>
#import <NJKWebViewProgress.h>
#import <NJKWebViewProgressView.h>
#import "TKAURLProtocol.h"
#import "NSURL+IDN.h"
#ifndef CHWebBrowserNavBarHeight
#define CHWebBrowserNavBarHeight (self.topBar.frame.size.height)
#endif
#ifndef CHWebBrowserStatusBarHeight
#define CHWebBrowserStatusBarHeight (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation]) ? [UIApplication sharedApplication].statusBarFrame.size.height : [UIApplication sharedApplication].statusBarFrame.size.width)
#endif
#ifndef CHWebBrowserViewsAffectedByAlphaChangingByDefault
#define CHWebBrowserViewsAffectedByAlphaChangingByDefault (@[self.localTitleView, self.dismissBarButtonItem.customView, self.readBarButtonItem.customView, self.customBackBarButtonItem.customView])
#endif
#ifdef DEBUG
# define CHWebBrowserLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
# define CHWebBrowserLog(...)
#endif
typedef void (^CHValuesInAffectedViewsSetterBlock)(UIView *topBar,
float topBarYPosition,
UIView *bottomBar,
float bottomBarYPosition,
UIScrollView *scrollView,
UIEdgeInsets contentInset,
UIEdgeInsets scrollingIndicatorInsets,
NSArray *viewsAffectedByAlphaChanging,
float alpha);
@interface CHWebBrowserViewControllerAttributes : NSObject
@property (nonatomic, assign) float titleScrollingSpeed;
@property (nonatomic, assign) float animationDurationPerOnePixel;
@property (nonatomic, assign) NSTextAlignment titleTextAlignment;
@property (nonatomic, strong) UIFont *titleFont;
@property (nonatomic, strong) UIColor *titleTextColor;
@property (nonatomic, assign) BOOL isProgressBarEnabled;
@property (nonatomic, assign) BOOL isHidingBarsOnScrollingEnabled;
@property (nonatomic, assign) BOOL isReadabilityButtonHidden;
@property (nonatomic, assign) BOOL shouldAutorotate;
@property (nonatomic, assign) NSUInteger supportedInterfaceOrientations;
@property (nonatomic, assign) UIStatusBarStyle preferredStatusBarStyle;
@property (nonatomic, assign) BOOL isHttpAuthenticationPromptEnabled;
@property (nonatomic, assign) float progressBarViewThickness;
@property (nonatomic, strong) UIColor *toolbarTintColor;
+ (CHWebBrowserViewControllerAttributes*)defaultAttributes;
@end
@interface CHWebBrowserViewController : UIViewController <UIWebViewDelegate, NSURLConnectionDelegate, UIAlertViewDelegate, UIActionSheetDelegate, UIBarPositioningDelegate, UIScrollViewDelegate, TKAURLProtocolDelegate, NJKWebViewProgressDelegate>
{
CGPoint _lastContentOffset;
BOOL _isScrollViewScrolling;
BOOL _isMovingViews;
BOOL _isAnimatingViews;
BOOL _isAnimatingResettingViews;
NJKWebViewProgress *_progressDelegateProxy;
NJKWebViewProgressView *_progressView;
NSInteger _loadsInProgressCount;
// baking ivars
NSMutableArray *_viewsAffectedByAlphaChanging;
CHWebBrowserViewControllerAttributes *_cAttributes;
CHValuesInAffectedViewsSetterBlock _valuesInAffectedViewsSetterBlock;
BOOL _shouldShowDismissButton;
DKBackBarButtonItem *_customBackBarButtonItem;
NSString *_customBackBarButtonItemTitle;
}
@property (nonatomic, strong) CHWebBrowserViewControllerAttributes *cAttributes;
@property (nonatomic, strong) IBOutlet UIWebView *webView;
@property (nonatomic, strong) IBOutlet UIToolbar *bottomToolbar;
@property (nonatomic, strong) IBOutlet UIBarButtonItem *navigateBackButton;
@property (nonatomic, strong) IBOutlet UIBarButtonItem *navigateForwardButton;
@property (nonatomic, strong) IBOutlet UIBarButtonItem *actionButton;
@property (nonatomic, strong) IBOutlet UIBarButtonItem *refreshButton;
@property (nonatomic, strong) IBOutlet UINavigationBar *localNavigationBar;
@property (nonatomic, strong) IBOutlet UIView *localTitleView;
@property (nonatomic, strong) IBOutlet UIBarButtonItem *dismissBarButtonItem;
@property (nonatomic, strong) IBOutlet UIBarButtonItem *readBarButtonItem;
@property (nonatomic, strong) IBOutlet NSLayoutConstraint *webViewTopOffsetConstraint;
@property (nonatomic, strong) IBOutlet NSLayoutConstraint *bottomToolbarBottomOffsetConstraint;
@property (nonatomic, strong) NSMutableArray *viewsAffectedByAlphaChanging;
@property (nonatomic, strong) IBOutlet CBAutoScrollLabel *titleLabel;
@property (nonatomic, strong) IBOutlet CBAutoScrollLabel *urlLabel;
@property (nonatomic, strong) DKBackBarButtonItem *customBackBarButtonItem;
@property (nonatomic, strong) NSString *customBackBarButtonItemTitle;
@property (nonatomic, readonly) UINavigationBar *topBar;
@property (nonatomic, strong) NSURL *chromeActivityCallbackUrl; // Nil by default. Defines whether or not 'googlechrome-x-callback' URI scheme should be used instead of 'googlechrome' ('googlechromes') URI scheme. More about callback url here: https://developers.google.com/chrome/mobile/docs/ios-links
@property (nonatomic, copy) void (^onDismissCallback)(CHWebBrowserViewController *webBrowserVC);
@property (nonatomic, copy) void (^onLoadingFailedCallback)(CHWebBrowserViewController *webBrowserVC, NSError *error, NSURL *requestUrl, BOOL* shouldShowAlert);
@property (nonatomic, assign) BOOL shouldShowDismissButton;
@property (nonatomic, assign) BOOL wasNavigationBarHiddenByControllerOnEnter;
@property (nonatomic, assign) BOOL wasNavigationBarHiddenAsViewOnEnter;
/* This URL should be set after creating the controller but before viewWillAppear
On viewWillAppear it would be used to navigate the webView
*/
@property (nonatomic, strong) NSURL *homeUrl;
@property (nonatomic, strong) NSString *homeUrlString;
@property (nonatomic, strong) NSURLRequest *mainRequest;
/* This block is used to set **values** in **views** which both come from arguments in the following situations:
- scroll view did scroll and user was dragging (not animated call)
- scroll view ended scrolling and will not decelerate (animated call)
- scroll view ended decelerating (animated call)
- reset all views action (can be animated or not)
The ivar is created on first getter occurs
*/
@property (nonatomic, copy) CHValuesInAffectedViewsSetterBlock valuesInAffectedViewsSetterBlock;
+ (id)webBrowserControllerWithDefaultNib;
+ (id)webBrowserControllerWithDefaultNibAndHomeUrl:(NSURL*)url;
+ (void)openWebBrowserController:(CHWebBrowserViewController*)vc
modallyWithUrl:(NSURL*)url
fromController:(UIViewController*)viewControllerToPresetFrom
animated:(BOOL)animated
showDismissButton:(BOOL)showDismissButton
completion:(void (^)(void))completion;
+ (void)openWebBrowserController:(CHWebBrowserViewController*)vc modallyWithUrl:(NSURL*)url animated:(BOOL)animated showDismissButton:(BOOL)showDismissButton completion:(void (^)(void))completion;
+ (void)openWebBrowserController:(CHWebBrowserViewController*)vc modallyWithUrl:(NSURL*)url animated:(BOOL)animated completion:(void (^)(void))completion;
+ (void)openWebBrowserController:(CHWebBrowserViewController*)vc modallyWithUrl:(NSURL*)url animated:(BOOL)animated;
+ (void)openWebBrowserControllerModallyWithHomeUrl:(NSURL*)url animated:(BOOL)animated;
+ (void)openWebBrowserControllerModallyWithHomeUrl:(NSURL*)url animated:(BOOL)animated completion:(void (^)(void))completion;
/*
This method will handle proper encoding both host (domain) and path parts of your URL provided as string.
It will add http:// scheme if there is no other scheme.
It will most likely give you proper URL in situation where [NSURL URLWithString:s] will give you nothing (nil).
*/
+(NSURL*)URLWithString:(NSString*)string;
+ (void)clearCredentialsAndCookiesAndCache;
+ (void)clearCredentials;
+ (void)clearCookies;
+ (void)clearCache;
- (void)loadUrlString:(NSString*)urlString;
- (void)loadUrl:(NSURL*)url;
- (void)resetAffectedViewsAnimated:(BOOL)animated;
@end | 49.372093 | 302 | 0.771079 |
031af422aef3d6f0dc4a89159f239abfc952ad6b | 716 | h | C | YKSDK/YKSDK.framework/Headers/YKRemoteMatchDeviceKey.h | yaokantv/YKSDK-iOS | 4d35b37f5c767fb605086e4918339928bfc199c1 | [
"MIT"
] | 10 | 2017-06-30T03:30:41.000Z | 2021-11-18T07:04:35.000Z | YKSDK/YKSDK.framework/Headers/YKRemoteMatchDeviceKey.h | yaokantv/YKSDK-iOS | 4d35b37f5c767fb605086e4918339928bfc199c1 | [
"MIT"
] | 1 | 2017-10-09T06:24:50.000Z | 2017-11-22T09:52:28.000Z | YKSDK/YKSDK.framework/Headers/YKRemoteMatchDeviceKey.h | yaokantv/YKSDK-iOS | 4d35b37f5c767fb605086e4918339928bfc199c1 | [
"MIT"
] | 4 | 2017-06-05T01:42:59.000Z | 2019-07-24T07:53:01.000Z | //
// YKRemoteMatchDeviceKey.h
// Pods
//
// Created by Don on 2017/1/18.
//
//
#import <Foundation/Foundation.h>
@interface YKRemoteMatchDeviceKey : NSObject
@property (nonatomic, copy) NSString *key; // 遥控键名
@property (nonatomic, copy) NSString *shortCMD; // short 短码
@property (nonatomic, copy) NSString *src; // 原始码
@property (nonatomic, copy) NSString *reverse_src; // 反码
@property (nonatomic, copy) NSString *tip; // 匹配提示
@property (nonatomic, copy) NSString *kn; // 国际化键显示名
@property (nonatomic, assign) NSInteger zip; // zip
@property (nonatomic, assign) NSUInteger order; // 顺序
@end
| 31.130435 | 71 | 0.594972 |
82fec44abdc4798d9c3006876d2361c71a44bb6e | 2,115 | h | C | DearPyGui/src/Core/AppItems/mvWindowAppItem.h | AltoRetrato/DearPyGui | c8d7940aa3ccd0e95b7aefa661160fb626bb21b0 | [
"MIT"
] | null | null | null | DearPyGui/src/Core/AppItems/mvWindowAppItem.h | AltoRetrato/DearPyGui | c8d7940aa3ccd0e95b7aefa661160fb626bb21b0 | [
"MIT"
] | null | null | null | DearPyGui/src/Core/AppItems/mvWindowAppItem.h | AltoRetrato/DearPyGui | c8d7940aa3ccd0e95b7aefa661160fb626bb21b0 | [
"MIT"
] | null | null | null | #pragma once
#include <utility>
#include "Core/AppItems/mvTypeBases.h"
#include "mvApp.h"
#include "mvEventHandler.h"
namespace Marvel {
//-----------------------------------------------------------------------------
// mvWindowAppitem
// - this needs cleaning up badly
//-----------------------------------------------------------------------------
class mvWindowAppitem : public mvAppItem, public mvEventHandler
{
enum class Status{ Normal, Transition, Dirty};
public:
MV_APPITEM_TYPE(mvAppItemType::Window, "add_window")
mvWindowAppitem(const std::string& name, bool mainWindow, PyObject* closing_callback);
bool isARoot () const override { return true; }
void addMenuBar () { m_hasMenuBar = true; }
void addFlag (ImGuiWindowFlags flag) { m_windowflags |= flag; }
void removeFlag (ImGuiWindowFlags flag) { m_windowflags &= ~flag; }
void setWindowAsMainStatus(bool value);
void setWindowPos (float x, float y);
void setWidth (int width) override;
void setHeight (int height) override;
mvVec2 getWindowPos () const;
void draw () override;
void setExtraConfigDict (PyObject* dict) override;
void getExtraConfigDict (PyObject* dict) override;
void setFocusedNextFrame () { m_focusNextFrame = true; }
~mvWindowAppitem();
private:
ImGuiWindowFlags m_windowflags = ImGuiWindowFlags_NoSavedSettings;
ImGuiWindowFlags m_oldWindowflags = ImGuiWindowFlags_NoSavedSettings;
int m_xpos = 200;
int m_oldxpos = 200;
int m_ypos = 200;
int m_oldypos = 200;
int m_oldWidth = 200;
int m_oldHeight = 200;
bool m_mainWindow = false;
PyObject* m_closing_callback = nullptr;
bool m_dirty_pos = true;
bool m_dirty_size = true;
bool m_closing = true;
bool m_noclose = false;
bool m_hasMenuBar = false;
bool m_focusNextFrame = false;
};
} | 33.571429 | 88 | 0.573522 |
89e0fa057c91290cc7eb4f30eea6788f8d688381 | 223 | h | C | include/cru/platform/gui/osx/Keyboard.h | crupest/Cru | 261681705b9a1b8d939d1420c3373c5591316549 | [
"Apache-2.0"
] | null | null | null | include/cru/platform/gui/osx/Keyboard.h | crupest/Cru | 261681705b9a1b8d939d1420c3373c5591316549 | [
"Apache-2.0"
] | null | null | null | include/cru/platform/gui/osx/Keyboard.h | crupest/Cru | 261681705b9a1b8d939d1420c3373c5591316549 | [
"Apache-2.0"
] | null | null | null | #pragma once
#include "cru/platform/gui/Keyboard.h"
namespace cru::platform::gui::osx {
KeyCode KeyCodeFromOsxToCru(unsigned short n);
unsigned short KeyCodeFromCruToOsx(KeyCode k);
} // namespace cru::platform::gui::osx
| 27.875 | 46 | 0.7713 |
c58664c6f3339bcf9d94054aa9cab6ebdaf356f0 | 3,297 | h | C | Code/Base/askap/current/askap/SignalManagerSingleton.h | rtobar/askapsoft | 6bae06071d7d24f41abe3f2b7f9ee06cb0a9445e | [
"BSL-1.0",
"Apache-2.0",
"OpenSSL"
] | 1 | 2020-06-18T08:37:43.000Z | 2020-06-18T08:37:43.000Z | Code/Base/askap/current/askap/SignalManagerSingleton.h | ATNF/askapsoft | d839c052d5c62ad8a511e58cd4b6548491a6006f | [
"BSL-1.0",
"Apache-2.0",
"OpenSSL"
] | null | null | null | Code/Base/askap/current/askap/SignalManagerSingleton.h | ATNF/askapsoft | d839c052d5c62ad8a511e58cd4b6548491a6006f | [
"BSL-1.0",
"Apache-2.0",
"OpenSSL"
] | null | null | null | /// @file SignalManagerSingleton.h
/// @brief
///
/// @copyright (c) 2010 CSIRO
/// Australia Telescope National Facility (ATNF)
/// Commonwealth Scientific and Industrial Research Organisation (CSIRO)
/// PO Box 76, Epping NSW 1710, Australia
/// atnf-enquiries@csiro.au
///
/// This file is part of the ASKAP software distribution.
///
/// The ASKAP software distribution 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
///
/// @author Ben Humphreys<ben.humphreys@csiro.au>
///
#ifndef ASKAP_SIGNALMANAGERSINGLETON_H
#define ASKAP_SIGNALMANAGERSINGLETON_H
// System includes
#include <csignal>
#include <vector>
// Local package includes
#include "ISignalHandler.h"
namespace askap {
/// @brief A simple object-oriented wrapper around the standard ANSI C
/// signal mechanism.
class SignalManagerSingleton {
public:
/// @brief Obtain the singleton instance of the signal manager.
/// @return the singleton instance.
static SignalManagerSingleton* instance(void);
/// @brief Register an object (which implements the ISignalHandler
/// interface) to handle signals.
///
/// @param[in] signum signal to regester handler for.
/// @param[in] handler instance of a signal handler.
/// @note The signal handler is not copied, so must remain allocated
/// while the handler is registered.
ISignalHandler *registerHandler(int signum,
ISignalHandler *handler);
/// @brief Remove a signal handler.
/// @param[in] signum signal for which the handler will be
/// removed. The signal will be ignored
/// (i.e. SIG_IGN) after this call returns.
void removeHandler(int signum);
private:
// Constructor
SignalManagerSingleton();
// Dispatches to the handler object
static void dispatcher(int signum);
// No support for assignment
SignalManagerSingleton& operator=(const SignalManagerSingleton& rhs);
// No support for copy constructor
SignalManagerSingleton(const SignalManagerSingleton& src);
// Singleton instance of this class
static SignalManagerSingleton *itsInstance;
// Vector of signal handlers. This vector gets sized to the maximum
// number of signals (NSIG).
static std::vector<ISignalHandler *> itsSignalHandlers;
};
} // end namespace askap
#endif
| 37.044944 | 81 | 0.646042 |
5cc1da3da67012b2487c35e59f190c26f9fea3f5 | 3,298 | c | C | src/pci_uart.c | mike-pt/xhyve | da4b97e52f55c4a3ae31efd52e1fa21f37e04550 | [
"Intel",
"BSD-2-Clause"
] | 1,449 | 2018-02-23T21:40:16.000Z | 2022-03-31T22:07:38.000Z | src/pci_uart.c | mike-pt/xhyve | da4b97e52f55c4a3ae31efd52e1fa21f37e04550 | [
"Intel",
"BSD-2-Clause"
] | 143 | 2015-12-09T03:07:05.000Z | 2018-02-27T16:57:32.000Z | src/pci_uart.c | mike-pt/xhyve | da4b97e52f55c4a3ae31efd52e1fa21f37e04550 | [
"Intel",
"BSD-2-Clause"
] | 132 | 2018-07-02T19:07:54.000Z | 2022-03-23T02:37:52.000Z | /*-
* Copyright (c) 2012 NetApp, Inc.
* Copyright (c) 2015 xhyve developers
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``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 NETAPP, INC 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.
*
* $FreeBSD$
*/
#include <stdint.h>
#include <stdio.h>
#include <xhyve/support/misc.h>
#include <xhyve/xhyve.h>
#include <xhyve/pci_emul.h>
#include <xhyve/uart_emul.h>
/*
* Pick a PCI vid/did of a chip with a single uart at
* BAR0, that most versions of FreeBSD can understand:
* Siig CyberSerial 1-port.
*/
#define COM_VENDOR 0x131f
#define COM_DEV 0x2000
static void
pci_uart_intr_assert(void *arg)
{
struct pci_devinst *pi = arg;
pci_lintr_assert(pi);
}
static void
pci_uart_intr_deassert(void *arg)
{
struct pci_devinst *pi = arg;
pci_lintr_deassert(pi);
}
static void
pci_uart_write(UNUSED int vcpu, struct pci_devinst *pi, int baridx, uint64_t offset,
int size, uint64_t value)
{
assert(baridx == 0);
assert(size == 1);
uart_write(pi->pi_arg, ((int) offset), ((uint8_t) value));
}
static uint64_t
pci_uart_read(UNUSED int vcpu, struct pci_devinst *pi, int baridx,
uint64_t offset, int size)
{
uint8_t val;
assert(baridx == 0);
assert(size == 1);
val = uart_read(pi->pi_arg, ((int) offset));
return (val);
}
static int
pci_uart_init(struct pci_devinst *pi, char *opts)
{
struct uart_softc *sc;
char *name;
pci_emul_alloc_bar(pi, 0, PCIBAR_IO, UART_IO_BAR_SIZE);
pci_lintr_request(pi);
/* initialize config space */
pci_set_cfgdata16(pi, PCIR_DEVICE, COM_DEV);
pci_set_cfgdata16(pi, PCIR_VENDOR, COM_VENDOR);
pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_SIMPLECOMM);
sc = uart_init(pci_uart_intr_assert, pci_uart_intr_deassert, pi);
pi->pi_arg = sc;
asprintf(&name, "pci uart at %d:%d", pi->pi_slot, pi->pi_func);
if (uart_set_backend(sc, opts, name) != 0) {
fprintf(stderr, "Unable to initialize backend '%s' for %s\n", opts, name);
free(name);
return (-1);
}
free(name);
return (0);
}
static struct pci_devemu pci_de_com = {
.pe_emu = "uart",
.pe_init = pci_uart_init,
.pe_barwrite = pci_uart_write,
.pe_barread = pci_uart_read
};
PCI_EMUL_SET(pci_de_com);
| 27.483333 | 84 | 0.733172 |
cf1e526de56ac0fadd1c75b05b964481d8ec3e09 | 11,637 | c | C | runtime/musl-lkl/lkl/drivers/media/pci/saa7134/saa7134-i2c.c | dme26/intravisor | 9bf9c50aa14616bd9bd66eee47623e8b61514058 | [
"MIT"
] | 11 | 2022-02-05T12:12:43.000Z | 2022-03-08T08:09:08.000Z | runtime/musl-lkl/lkl/drivers/media/pci/saa7134/saa7134-i2c.c | dme26/intravisor | 9bf9c50aa14616bd9bd66eee47623e8b61514058 | [
"MIT"
] | 3 | 2021-09-06T09:14:42.000Z | 2022-03-27T08:09:54.000Z | runtime/musl-lkl/lkl/drivers/media/pci/saa7134/saa7134-i2c.c | dme26/intravisor | 9bf9c50aa14616bd9bd66eee47623e8b61514058 | [
"MIT"
] | 1 | 2022-03-18T07:17:40.000Z | 2022-03-18T07:17:40.000Z | /*
*
* device driver for philips saa7134 based TV cards
* i2c interface support
*
* (c) 2001,02 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
*
* 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.
*/
#include "saa7134.h"
#include "saa7134-reg.h"
#include <linux/init.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <media/v4l2-common.h>
/* ----------------------------------------------------------- */
static unsigned int i2c_debug;
module_param(i2c_debug, int, 0644);
MODULE_PARM_DESC(i2c_debug,"enable debug messages [i2c]");
static unsigned int i2c_scan;
module_param(i2c_scan, int, 0444);
MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
#define i2c_dbg(level, fmt, arg...) do { \
if (i2c_debug == level) \
printk(KERN_DEBUG pr_fmt("i2c: " fmt), ## arg); \
} while (0)
#define i2c_cont(level, fmt, arg...) do { \
if (i2c_debug == level) \
pr_cont(fmt, ## arg); \
} while (0)
#define I2C_WAIT_DELAY 32
#define I2C_WAIT_RETRY 16
/* ----------------------------------------------------------- */
static char *str_i2c_status[] = {
"IDLE", "DONE_STOP", "BUSY", "TO_SCL", "TO_ARB", "DONE_WRITE",
"DONE_READ", "DONE_WRITE_TO", "DONE_READ_TO", "NO_DEVICE",
"NO_ACKN", "BUS_ERR", "ARB_LOST", "SEQ_ERR", "ST_ERR", "SW_ERR"
};
enum i2c_status {
IDLE = 0, // no I2C command pending
DONE_STOP = 1, // I2C command done and STOP executed
BUSY = 2, // executing I2C command
TO_SCL = 3, // executing I2C command, time out on clock stretching
TO_ARB = 4, // time out on arbitration trial, still trying
DONE_WRITE = 5, // I2C command done and awaiting next write command
DONE_READ = 6, // I2C command done and awaiting next read command
DONE_WRITE_TO = 7, // see 5, and time out on status echo
DONE_READ_TO = 8, // see 6, and time out on status echo
NO_DEVICE = 9, // no acknowledge on device slave address
NO_ACKN = 10, // no acknowledge after data byte transfer
BUS_ERR = 11, // bus error
ARB_LOST = 12, // arbitration lost during transfer
SEQ_ERR = 13, // erroneous programming sequence
ST_ERR = 14, // wrong status echoing
SW_ERR = 15 // software error
};
static char *str_i2c_attr[] = {
"NOP", "STOP", "CONTINUE", "START"
};
enum i2c_attr {
NOP = 0, // no operation on I2C bus
STOP = 1, // stop condition, no associated byte transfer
CONTINUE = 2, // continue with byte transfer
START = 3 // start condition with byte transfer
};
static inline enum i2c_status i2c_get_status(struct saa7134_dev *dev)
{
enum i2c_status status;
status = saa_readb(SAA7134_I2C_ATTR_STATUS) & 0x0f;
i2c_dbg(2, "i2c stat <= %s\n", str_i2c_status[status]);
return status;
}
static inline void i2c_set_status(struct saa7134_dev *dev,
enum i2c_status status)
{
i2c_dbg(2, "i2c stat => %s\n", str_i2c_status[status]);
saa_andorb(SAA7134_I2C_ATTR_STATUS,0x0f,status);
}
static inline void i2c_set_attr(struct saa7134_dev *dev, enum i2c_attr attr)
{
i2c_dbg(2, "i2c attr => %s\n", str_i2c_attr[attr]);
saa_andorb(SAA7134_I2C_ATTR_STATUS,0xc0,attr << 6);
}
static inline int i2c_is_error(enum i2c_status status)
{
switch (status) {
case NO_DEVICE:
case NO_ACKN:
case BUS_ERR:
case ARB_LOST:
case SEQ_ERR:
case ST_ERR:
return true;
default:
return false;
}
}
static inline int i2c_is_idle(enum i2c_status status)
{
switch (status) {
case IDLE:
case DONE_STOP:
return true;
default:
return false;
}
}
static inline int i2c_is_busy(enum i2c_status status)
{
switch (status) {
case BUSY:
case TO_SCL:
case TO_ARB:
return true;
default:
return false;
}
}
static int i2c_is_busy_wait(struct saa7134_dev *dev)
{
enum i2c_status status;
int count;
for (count = 0; count < I2C_WAIT_RETRY; count++) {
status = i2c_get_status(dev);
if (!i2c_is_busy(status))
break;
saa_wait(I2C_WAIT_DELAY);
}
if (I2C_WAIT_RETRY == count)
return false;
return true;
}
static int i2c_reset(struct saa7134_dev *dev)
{
enum i2c_status status;
int count;
i2c_dbg(2, "i2c reset\n");
status = i2c_get_status(dev);
if (!i2c_is_error(status))
return true;
i2c_set_status(dev,status);
for (count = 0; count < I2C_WAIT_RETRY; count++) {
status = i2c_get_status(dev);
if (!i2c_is_error(status))
break;
udelay(I2C_WAIT_DELAY);
}
if (I2C_WAIT_RETRY == count)
return false;
if (!i2c_is_idle(status))
return false;
i2c_set_attr(dev,NOP);
return true;
}
static inline int i2c_send_byte(struct saa7134_dev *dev,
enum i2c_attr attr,
unsigned char data)
{
enum i2c_status status;
__u32 dword;
/* have to write both attr + data in one 32bit word */
dword = saa_readl(SAA7134_I2C_ATTR_STATUS >> 2);
dword &= 0x0f;
dword |= (attr << 6);
dword |= ((__u32)data << 8);
dword |= 0x00 << 16; /* 100 kHz */
// dword |= 0x40 << 16; /* 400 kHz */
dword |= 0xf0 << 24;
saa_writel(SAA7134_I2C_ATTR_STATUS >> 2, dword);
i2c_dbg(2, "i2c data => 0x%x\n", data);
if (!i2c_is_busy_wait(dev))
return -EIO;
status = i2c_get_status(dev);
if (i2c_is_error(status))
return -EIO;
return 0;
}
static inline int i2c_recv_byte(struct saa7134_dev *dev)
{
enum i2c_status status;
unsigned char data;
i2c_set_attr(dev,CONTINUE);
if (!i2c_is_busy_wait(dev))
return -EIO;
status = i2c_get_status(dev);
if (i2c_is_error(status))
return -EIO;
data = saa_readb(SAA7134_I2C_DATA);
i2c_dbg(2, "i2c data <= 0x%x\n", data);
return data;
}
static int saa7134_i2c_xfer(struct i2c_adapter *i2c_adap,
struct i2c_msg *msgs, int num)
{
struct saa7134_dev *dev = i2c_adap->algo_data;
enum i2c_status status;
unsigned char data;
int addr,rc,i,byte;
status = i2c_get_status(dev);
if (!i2c_is_idle(status))
if (!i2c_reset(dev))
return -EIO;
i2c_dbg(2, "start xfer\n");
i2c_dbg(1, "i2c xfer:");
for (i = 0; i < num; i++) {
if (!(msgs[i].flags & I2C_M_NOSTART) || 0 == i) {
/* send address */
i2c_dbg(2, "send address\n");
addr = msgs[i].addr << 1;
if (msgs[i].flags & I2C_M_RD)
addr |= 1;
if (i > 0 && msgs[i].flags &
I2C_M_RD && msgs[i].addr != 0x40 &&
msgs[i].addr != 0x41 &&
msgs[i].addr != 0x19) {
/* workaround for a saa7134 i2c bug
* needed to talk to the mt352 demux
* thanks to pinnacle for the hint */
int quirk = 0xfe;
i2c_cont(1, " [%02x quirk]", quirk);
i2c_send_byte(dev,START,quirk);
i2c_recv_byte(dev);
}
i2c_cont(1, " < %02x", addr);
rc = i2c_send_byte(dev,START,addr);
if (rc < 0)
goto err;
}
if (msgs[i].flags & I2C_M_RD) {
/* read bytes */
i2c_dbg(2, "read bytes\n");
for (byte = 0; byte < msgs[i].len; byte++) {
i2c_cont(1, " =");
rc = i2c_recv_byte(dev);
if (rc < 0)
goto err;
i2c_cont(1, "%02x", rc);
msgs[i].buf[byte] = rc;
}
/* discard mysterious extra byte when reading
from Samsung S5H1411. i2c bus gets error
if we do not. */
if (0x19 == msgs[i].addr) {
i2c_cont(1, " ?");
rc = i2c_recv_byte(dev);
if (rc < 0)
goto err;
i2c_cont(1, "%02x", rc);
}
} else {
/* write bytes */
i2c_dbg(2, "write bytes\n");
for (byte = 0; byte < msgs[i].len; byte++) {
data = msgs[i].buf[byte];
i2c_cont(1, " %02x", data);
rc = i2c_send_byte(dev,CONTINUE,data);
if (rc < 0)
goto err;
}
}
}
i2c_dbg(2, "xfer done\n");
i2c_cont(1, " >");
i2c_set_attr(dev,STOP);
rc = -EIO;
if (!i2c_is_busy_wait(dev))
goto err;
status = i2c_get_status(dev);
if (i2c_is_error(status))
goto err;
/* ensure that the bus is idle for at least one bit slot */
msleep(1);
i2c_cont(1, "\n");
return num;
err:
if (1 == i2c_debug) {
status = i2c_get_status(dev);
i2c_cont(1, " ERROR: %s\n", str_i2c_status[status]);
}
return rc;
}
/* ----------------------------------------------------------- */
static u32 functionality(struct i2c_adapter *adap)
{
return I2C_FUNC_SMBUS_EMUL;
}
static const struct i2c_algorithm saa7134_algo = {
.master_xfer = saa7134_i2c_xfer,
.functionality = functionality,
};
static const struct i2c_adapter saa7134_adap_template = {
.owner = THIS_MODULE,
.name = "saa7134",
.algo = &saa7134_algo,
};
static const struct i2c_client saa7134_client_template = {
.name = "saa7134 internal",
};
/* ----------------------------------------------------------- */
/* On Medion 7134 reading EEPROM needs DVB-T demod i2c gate open */
static void saa7134_i2c_eeprom_md7134_gate(struct saa7134_dev *dev)
{
u8 subaddr = 0x7, dmdregval;
u8 data[2];
int ret;
struct i2c_msg i2cgatemsg_r[] = { {.addr = 0x08, .flags = 0,
.buf = &subaddr, .len = 1},
{.addr = 0x08,
.flags = I2C_M_RD,
.buf = &dmdregval, .len = 1}
};
struct i2c_msg i2cgatemsg_w[] = { {.addr = 0x08, .flags = 0,
.buf = data, .len = 2} };
ret = i2c_transfer(&dev->i2c_adap, i2cgatemsg_r, 2);
if ((ret == 2) && (dmdregval & 0x2)) {
pr_debug("%s: DVB-T demod i2c gate was left closed\n",
dev->name);
data[0] = subaddr;
data[1] = (dmdregval & ~0x2);
if (i2c_transfer(&dev->i2c_adap, i2cgatemsg_w, 1) != 1)
pr_err("%s: EEPROM i2c gate open failure\n",
dev->name);
}
}
static int
saa7134_i2c_eeprom(struct saa7134_dev *dev, unsigned char *eedata, int len)
{
unsigned char buf;
int i,err;
if (dev->board == SAA7134_BOARD_MD7134)
saa7134_i2c_eeprom_md7134_gate(dev);
dev->i2c_client.addr = 0xa0 >> 1;
buf = 0;
if (1 != (err = i2c_master_send(&dev->i2c_client,&buf,1))) {
pr_info("%s: Huh, no eeprom present (err=%d)?\n",
dev->name,err);
return -1;
}
if (len != (err = i2c_master_recv(&dev->i2c_client,eedata,len))) {
pr_warn("%s: i2c eeprom read error (err=%d)\n",
dev->name,err);
return -1;
}
for (i = 0; i < len; i += 16) {
int size = (len - i) > 16 ? 16 : len - i;
pr_info("i2c eeprom %02x: %*ph\n", i, size, &eedata[i]);
}
return 0;
}
static char *i2c_devs[128] = {
[ 0x20 ] = "mpeg encoder (saa6752hs)",
[ 0xa0 >> 1 ] = "eeprom",
[ 0xc0 >> 1 ] = "tuner (analog)",
[ 0x86 >> 1 ] = "tda9887",
[ 0x5a >> 1 ] = "remote control",
};
static void do_i2c_scan(struct i2c_client *c)
{
unsigned char buf;
int i,rc;
for (i = 0; i < ARRAY_SIZE(i2c_devs); i++) {
c->addr = i;
rc = i2c_master_recv(c,&buf,0);
if (rc < 0)
continue;
pr_info("i2c scan: found device @ 0x%x [%s]\n",
i << 1, i2c_devs[i] ? i2c_devs[i] : "???");
}
}
int saa7134_i2c_register(struct saa7134_dev *dev)
{
dev->i2c_adap = saa7134_adap_template;
dev->i2c_adap.dev.parent = &dev->pci->dev;
strcpy(dev->i2c_adap.name,dev->name);
dev->i2c_adap.algo_data = dev;
i2c_set_adapdata(&dev->i2c_adap, &dev->v4l2_dev);
i2c_add_adapter(&dev->i2c_adap);
dev->i2c_client = saa7134_client_template;
dev->i2c_client.adapter = &dev->i2c_adap;
saa7134_i2c_eeprom(dev,dev->eedata,sizeof(dev->eedata));
if (i2c_scan)
do_i2c_scan(&dev->i2c_client);
/* Instantiate the IR receiver device, if present */
saa7134_probe_i2c_ir(dev);
return 0;
}
int saa7134_i2c_unregister(struct saa7134_dev *dev)
{
i2c_del_adapter(&dev->i2c_adap);
return 0;
}
| 25.188312 | 76 | 0.634957 |
d0a9da49531ecce667ab99fb43697d82855acfe7 | 79 | h | C | App/stdafx.h | refactormyself/CPPlingua | fd7e020efa9d8351448575650dd47401337814b3 | [
"BSD-2-Clause"
] | 59 | 2019-11-22T08:06:40.000Z | 2022-02-25T16:56:38.000Z | App/stdafx.h | refactormyself/CPPlingua | fd7e020efa9d8351448575650dd47401337814b3 | [
"BSD-2-Clause"
] | null | null | null | App/stdafx.h | refactormyself/CPPlingua | fd7e020efa9d8351448575650dd47401337814b3 | [
"BSD-2-Clause"
] | 12 | 2019-11-22T18:00:58.000Z | 2022-01-05T15:23:18.000Z | #pragma once
// TODO: reference additional headers your program requires here
| 19.75 | 64 | 0.797468 |
fd9bdff55e477fbb673b361a3c00d706a6580836 | 1,019 | h | C | cases/adaptive_surfers_in_channel_flow_z/param/env/objects/static/surfer__us_0o1__surftimeprefactor_1o0/group/homogeneous/_member/agent/_behaviour/navigator/_behaviour_direction/choice.h | C0PEP0D/sheld0n | 497d4ee8b6b1815cd5fa1b378d1b947ee259f4bc | [
"MIT"
] | null | null | null | cases/adaptive_surfers_in_channel_flow_z/param/env/objects/static/surfer__us_0o1__surftimeprefactor_1o0/group/homogeneous/_member/agent/_behaviour/navigator/_behaviour_direction/choice.h | C0PEP0D/sheld0n | 497d4ee8b6b1815cd5fa1b378d1b947ee259f4bc | [
"MIT"
] | null | null | null | cases/adaptive_surfers_in_channel_flow_z/param/env/objects/static/surfer__us_0o1__surftimeprefactor_1o0/group/homogeneous/_member/agent/_behaviour/navigator/_behaviour_direction/choice.h | C0PEP0D/sheld0n | 497d4ee8b6b1815cd5fa1b378d1b947ee259f4bc | [
"MIT"
] | null | null | null | #ifndef C0P_PARAM_OBJECTS_SURFER__US_0O1__SURFTIMEPREFACTOR_1O0_GROUP_HOMOGENEOUS_MEMBER_AGENT_BEHAVIOUR_NAVIGATOR_BEHAVIOUR_DIRECTION_CHOICE_H
#define C0P_PARAM_OBJECTS_SURFER__US_0O1__SURFTIMEPREFACTOR_1O0_GROUP_HOMOGENEOUS_MEMBER_AGENT_BEHAVIOUR_NAVIGATOR_BEHAVIOUR_DIRECTION_CHOICE_H
#pragma once
// THIS FILE SHOULD NOT BE EDITED DIRECTLY BY THE USERS.
// THIS FILE WILL BE AUTOMATICALLY EDITED WHEN THE
// CHOOSE COMMAND IS USED
// choose your behaviour
#include "param/env/objects/static/surfer__us_0o1__surftimeprefactor_1o0/group/homogeneous/_member/agent/_behaviour/navigator/_behaviour_direction/surf/choice.h"
namespace c0p {
template<typename SurferUs0O1Surftimeprefactor1O0GroupHomogeneousMemberAgentActiveStep>
using SurferUs0O1Surftimeprefactor1O0GroupHomogeneousMemberAgentBehaviourNavigatorBehaviourDirection = SurferUs0O1Surftimeprefactor1O0GroupHomogeneousMemberAgentBehaviourNavigatorBehaviourDirectionSurf<SurferUs0O1Surftimeprefactor1O0GroupHomogeneousMemberAgentActiveStep>;
}
#endif
| 59.941176 | 276 | 0.904809 |
a95edf493eaaa930794bad7a52a10aade06c1d31 | 4,928 | c | C | examples/firhilb_example.c | nturay/quiet-dsp | dd79a381d1720e763f93c0eda09b02c0deda4777 | [
"MIT"
] | 42 | 2017-12-16T02:36:59.000Z | 2022-02-27T08:16:21.000Z | examples/firhilb_example.c | nturay/quiet-dsp | dd79a381d1720e763f93c0eda09b02c0deda4777 | [
"MIT"
] | 1 | 2017-05-14T12:21:47.000Z | 2017-05-14T12:21:47.000Z | examples/firhilb_example.c | nturay/quiet-dsp | dd79a381d1720e763f93c0eda09b02c0deda4777 | [
"MIT"
] | 15 | 2017-10-05T01:12:38.000Z | 2021-03-16T07:55:48.000Z | //
// firhilb_example.c
//
// Hilbert transform example. This example demonstrates the
// functionality of firhilbf (finite impulse response Hilbert transform)
// which converts a complex time series into a real one and then back.
//
// SEE ALSO: firhilb_interp_example.c
// firhilb_example.c
//
#include <stdio.h>
#include <complex.h>
#include <math.h>
#include "liquid.h"
#define OUTPUT_FILENAME "firhilb_example.m"
int main() {
unsigned int m = 7; // Hilbert filter semi-length
float As = 60.0f; // stop-band attenuation [dB]
float fc = 0.123456; // signal center frequency
unsigned int num_input_samples=128; // number of samples
// derived values
unsigned int h_len = 4*m+1; // filter length
unsigned int num_total_samples = num_input_samples + h_len;
// create Hilbert transform object
firhilbf qi = firhilbf_create(m,As); // interpolator
firhilbf qd = firhilbf_create(m,As); // decimator
firhilbf_print(qi);
// data arrays
float complex x[ num_total_samples]; // complex input
float y[2*num_total_samples]; // real output
float complex z[ num_total_samples]; // complex output
// initialize input array
unsigned int i;
for (i=0; i<num_total_samples; i++) {
x[i] = cexpf(_Complex_I*2*M_PI*fc*i);
x[i] *= (i < num_input_samples) ? 1.855f*hamming(i,num_input_samples) : 0.0f;
}
// execute interpolator (complex to real conversion)
firhilbf_interp_execute_block(qi, x, num_total_samples, y);
// execute decimator (real to complex conversion)
firhilbf_decim_execute_block(qd, y, num_total_samples, z);
// destroy Hilbert transform object
firhilbf_destroy(qi);
firhilbf_destroy(qd);
//
// export results to file
//
FILE*fid = fopen(OUTPUT_FILENAME,"w");
fprintf(fid,"%% %s : auto-generated file\n", OUTPUT_FILENAME);
fprintf(fid,"clear all;\n");
fprintf(fid,"close all;\n");
fprintf(fid,"h_len=%u;\n", 4*m+1);
fprintf(fid,"num_input_samples=%u;\n", num_input_samples);
fprintf(fid,"num_total_samples=%u;\n", num_total_samples);
fprintf(fid,"tx = 0:(num_total_samples-1);\n");
fprintf(fid,"ty = [0:(2*num_total_samples-1)]/2;\n");
fprintf(fid,"tz = tx;\n");
for (i=0; i<num_total_samples; i++) {
// print results
fprintf(fid,"x(%3u) = %12.4e + %12.4ej;\n", i+1, crealf(x[i]), cimagf(x[i]));
fprintf(fid,"y(%3u) = %12.4e;\n", 2*i+1, y[2*i+0]);
fprintf(fid,"y(%3u) = %12.4e;\n", 2*i+2, y[2*i+1]);
fprintf(fid,"z(%3u) = %12.4e + %12.4ej;\n", i+1, crealf(z[i]), cimagf(z[i]));
}
fprintf(fid,"figure;\n");
fprintf(fid,"subplot(3,1,1);\n");
fprintf(fid," plot(tx,real(x),'Color',[0.00 0.25 0.50],'LineWidth',1.3,...\n");
fprintf(fid," tx,imag(x),'Color',[0.00 0.50 0.25],'LineWidth',1.3);\n");
fprintf(fid," legend('real','imag','location','northeast');\n");
fprintf(fid," ylabel('transformed/complex');\n");
fprintf(fid," axis([0 num_total_samples -2 2]);\n");
fprintf(fid," grid on;\n");
fprintf(fid,"subplot(3,1,2);\n");
fprintf(fid," plot(ty,y,'Color',[0.00 0.25 0.50],'LineWidth',1.3);\n");
fprintf(fid," ylabel('original/real');\n");
fprintf(fid," axis([0 num_total_samples -2 2]);\n");
fprintf(fid," grid on;\n");
fprintf(fid,"subplot(3,1,3);\n");
fprintf(fid," plot(tz,real(z),'Color',[0.00 0.25 0.50],'LineWidth',1.3,...\n");
fprintf(fid," tz,imag(z),'Color',[0.00 0.50 0.25],'LineWidth',1.3);\n");
fprintf(fid," legend('real','imag','location','northeast');\n");
fprintf(fid," ylabel('transformed/complex');\n");
fprintf(fid," axis([0 num_total_samples -2 2]);\n");
fprintf(fid," grid on;\n");
// plot results
fprintf(fid,"nfft=4096;\n");
fprintf(fid,"%% compute normalized windowing functions\n");
fprintf(fid,"X=20*log10(abs(fftshift(fft(x/num_input_samples,nfft))));\n");
fprintf(fid,"Y=20*log10(abs(fftshift(fft(y/num_input_samples,nfft))));\n");
fprintf(fid,"Z=20*log10(abs(fftshift(fft(z/num_input_samples,nfft))));\n");
fprintf(fid,"f =[0:(nfft-1)]/nfft-0.5;\n");
fprintf(fid,"figure; plot(f, X,'LineWidth',1,'Color',[0.50 0.50 0.50],...\n");
fprintf(fid," f*2,Y,'LineWidth',2,'Color',[0.00 0.50 0.25],...\n");
fprintf(fid," f, Z,'LineWidth',1,'Color',[0.00 0.25 0.50]);\n");
fprintf(fid,"grid on;\n");
fprintf(fid,"axis([-1.0 1.0 -80 20]);\n");
fprintf(fid,"xlabel('normalized frequency');\n");
fprintf(fid,"ylabel('PSD [dB]');\n");
fprintf(fid,"legend('original/cplx','transformed/real','regenerated/cplx','location','northeast');");
fclose(fid);
printf("results written to %s\n", OUTPUT_FILENAME);
printf("done.\n");
return 0;
}
| 40.393443 | 105 | 0.599229 |
654760589da5ba9426b849a042d5459281d1a5d6 | 467 | h | C | buildbox-common/buildboxcommon/buildboxcommon_platformutils.h | sdclarke/buildbox-common | f77bf556176625b083dd45e2a6575a1301c6276a | [
"Apache-2.0"
] | null | null | null | buildbox-common/buildboxcommon/buildboxcommon_platformutils.h | sdclarke/buildbox-common | f77bf556176625b083dd45e2a6575a1301c6276a | [
"Apache-2.0"
] | null | null | null | buildbox-common/buildboxcommon/buildboxcommon_platformutils.h | sdclarke/buildbox-common | f77bf556176625b083dd45e2a6575a1301c6276a | [
"Apache-2.0"
] | null | null | null | #ifndef INCLUDED_BUILDBOXCOMMON_PLATFORMUTILS
#define INCLUDED_BUILDBOXCOMMON_PLATFORMUTILS
#include <string>
#include <vector>
namespace buildboxcommon {
struct PlatformUtils {
/**
* Return REAPI OSFamily of running system.
*/
static std::string getHostOSFamily();
/**
* Return REAPI ISA of running system.
*/
static std::string getHostISA();
};
} // namespace buildboxcommon
#endif // INCLUDED_BUILDBOXCOMMON_PLATFORMUTILS
| 19.458333 | 47 | 0.721627 |
6594d57a0bb03db2e8652f661454d0122a742506 | 152 | h | C | Example/Pods/Target Support Files/PredicateEditor/PredicateEditor-umbrella.h | arvindhsukumar/PredicateEditor | e2a022ab33fe15b999f076d187bc24ce2ba0f5c5 | [
"MIT"
] | 405 | 2016-07-26T06:39:00.000Z | 2022-02-28T01:37:08.000Z | Example/Pods/Target Support Files/PredicateEditor/PredicateEditor-umbrella.h | arvindhsukumar/PredicateEditor | e2a022ab33fe15b999f076d187bc24ce2ba0f5c5 | [
"MIT"
] | 6 | 2016-08-01T13:48:11.000Z | 2017-08-25T11:24:26.000Z | Example/Pods/Target Support Files/PredicateEditor/PredicateEditor-umbrella.h | arvindhsukumar/PredicateEditor | e2a022ab33fe15b999f076d187bc24ce2ba0f5c5 | [
"MIT"
] | 27 | 2016-07-26T21:21:13.000Z | 2021-07-08T08:10:00.000Z | #import <UIKit/UIKit.h>
FOUNDATION_EXPORT double PredicateEditorVersionNumber;
FOUNDATION_EXPORT const unsigned char PredicateEditorVersionString[];
| 21.714286 | 69 | 0.855263 |
a9d91e2f80cb592141d066161313f555f110b5d9 | 20,266 | c | C | app/v0.0.1/node_modules/grpc/src/core/ext/filters/max_age/max_age_filter.c | zssky/dbking | 8f228f9e23f3da79ec40f653d80c9bd0022da283 | [
"Apache-2.0"
] | 57 | 2018-06-12T20:05:44.000Z | 2022-03-21T05:17:45.000Z | app/v0.0.1/node_modules/grpc/src/core/ext/filters/max_age/max_age_filter.c | zssky/dbking | 8f228f9e23f3da79ec40f653d80c9bd0022da283 | [
"Apache-2.0"
] | 1 | 2020-06-27T13:55:15.000Z | 2021-03-10T07:48:22.000Z | app/v0.0.1/node_modules/grpc/src/core/ext/filters/max_age/max_age_filter.c | zssky/dbking | 8f228f9e23f3da79ec40f653d80c9bd0022da283 | [
"Apache-2.0"
] | 15 | 2018-05-18T01:57:18.000Z | 2021-12-02T07:37:16.000Z | /*
*
* Copyright 2017, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * 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 Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "src/core/ext/filters/max_age/max_age_filter.h"
#include <limits.h>
#include <string.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/surface/channel_init.h"
#include "src/core/lib/transport/http2_errors.h"
#define DEFAULT_MAX_CONNECTION_AGE_MS INT_MAX
#define DEFAULT_MAX_CONNECTION_AGE_GRACE_MS INT_MAX
#define DEFAULT_MAX_CONNECTION_IDLE_MS INT_MAX
#define MAX_CONNECTION_AGE_JITTER 0.1
#define MAX_CONNECTION_AGE_INTEGER_OPTIONS \
(grpc_integer_options) { DEFAULT_MAX_CONNECTION_AGE_MS, 1, INT_MAX }
#define MAX_CONNECTION_IDLE_INTEGER_OPTIONS \
(grpc_integer_options) { DEFAULT_MAX_CONNECTION_IDLE_MS, 1, INT_MAX }
typedef struct channel_data {
/* We take a reference to the channel stack for the timer callback */
grpc_channel_stack* channel_stack;
/* Guards access to max_age_timer, max_age_timer_pending, max_age_grace_timer
and max_age_grace_timer_pending */
gpr_mu max_age_timer_mu;
/* True if the max_age timer callback is currently pending */
bool max_age_timer_pending;
/* True if the max_age_grace timer callback is currently pending */
bool max_age_grace_timer_pending;
/* The timer for checking if the channel has reached its max age */
grpc_timer max_age_timer;
/* The timer for checking if the max-aged channel has uesed up the grace
period */
grpc_timer max_age_grace_timer;
/* The timer for checking if the channel's idle duration reaches
max_connection_idle */
grpc_timer max_idle_timer;
/* Allowed max time a channel may have no outstanding rpcs */
gpr_timespec max_connection_idle;
/* Allowed max time a channel may exist */
gpr_timespec max_connection_age;
/* Allowed grace period after the channel reaches its max age */
gpr_timespec max_connection_age_grace;
/* Closure to run when the channel's idle duration reaches max_connection_idle
and should be closed gracefully */
grpc_closure close_max_idle_channel;
/* Closure to run when the channel reaches its max age and should be closed
gracefully */
grpc_closure close_max_age_channel;
/* Closure to run the channel uses up its max age grace time and should be
closed forcibly */
grpc_closure force_close_max_age_channel;
/* Closure to run when the init fo channel stack is done and the max_idle
timer should be started */
grpc_closure start_max_idle_timer_after_init;
/* Closure to run when the init fo channel stack is done and the max_age timer
should be started */
grpc_closure start_max_age_timer_after_init;
/* Closure to run when the goaway op is finished and the max_age_timer */
grpc_closure start_max_age_grace_timer_after_goaway_op;
/* Closure to run when the channel connectivity state changes */
grpc_closure channel_connectivity_changed;
/* Records the current connectivity state */
grpc_connectivity_state connectivity_state;
/* Number of active calls */
gpr_atm call_count;
} channel_data;
/* Increase the nubmer of active calls. Before the increasement, if there are no
calls, the max_idle_timer should be cancelled. */
static void increase_call_count(grpc_exec_ctx* exec_ctx, channel_data* chand) {
if (gpr_atm_full_fetch_add(&chand->call_count, 1) == 0) {
grpc_timer_cancel(exec_ctx, &chand->max_idle_timer);
}
}
/* Decrease the nubmer of active calls. After the decrement, if there are no
calls, the max_idle_timer should be started. */
static void decrease_call_count(grpc_exec_ctx* exec_ctx, channel_data* chand) {
if (gpr_atm_full_fetch_add(&chand->call_count, -1) == 1) {
GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_idle_timer");
grpc_timer_init(
exec_ctx, &chand->max_idle_timer,
gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), chand->max_connection_idle),
&chand->close_max_idle_channel, gpr_now(GPR_CLOCK_MONOTONIC));
}
}
static void start_max_idle_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) {
channel_data* chand = arg;
/* Decrease call_count. If there are no active calls at this time,
max_idle_timer will start here. If the number of active calls is not 0,
max_idle_timer will start after all the active calls end. */
decrease_call_count(exec_ctx, chand);
GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->channel_stack,
"max_age start_max_idle_timer_after_init");
}
static void start_max_age_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) {
channel_data* chand = arg;
gpr_mu_lock(&chand->max_age_timer_mu);
chand->max_age_timer_pending = true;
GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_age_timer");
grpc_timer_init(
exec_ctx, &chand->max_age_timer,
gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), chand->max_connection_age),
&chand->close_max_age_channel, gpr_now(GPR_CLOCK_MONOTONIC));
gpr_mu_unlock(&chand->max_age_timer_mu);
grpc_transport_op* op = grpc_make_transport_op(NULL);
op->on_connectivity_state_change = &chand->channel_connectivity_changed,
op->connectivity_state = &chand->connectivity_state;
grpc_channel_next_op(exec_ctx,
grpc_channel_stack_element(chand->channel_stack, 0), op);
GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->channel_stack,
"max_age start_max_age_timer_after_init");
}
static void start_max_age_grace_timer_after_goaway_op(grpc_exec_ctx* exec_ctx,
void* arg,
grpc_error* error) {
channel_data* chand = arg;
gpr_mu_lock(&chand->max_age_timer_mu);
chand->max_age_grace_timer_pending = true;
GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_age_grace_timer");
grpc_timer_init(exec_ctx, &chand->max_age_grace_timer,
gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
chand->max_connection_age_grace),
&chand->force_close_max_age_channel,
gpr_now(GPR_CLOCK_MONOTONIC));
gpr_mu_unlock(&chand->max_age_timer_mu);
GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->channel_stack,
"max_age start_max_age_grace_timer_after_goaway_op");
}
static void close_max_idle_channel(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) {
channel_data* chand = arg;
if (error == GRPC_ERROR_NONE) {
/* Prevent the max idle timer from being set again */
gpr_atm_no_barrier_fetch_add(&chand->call_count, 1);
grpc_transport_op* op = grpc_make_transport_op(NULL);
op->goaway_error =
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("max_idle"),
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_NO_ERROR);
grpc_channel_element* elem =
grpc_channel_stack_element(chand->channel_stack, 0);
elem->filter->start_transport_op(exec_ctx, elem, op);
} else if (error != GRPC_ERROR_CANCELLED) {
GRPC_LOG_IF_ERROR("close_max_idle_channel", error);
}
GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->channel_stack,
"max_age max_idle_timer");
}
static void close_max_age_channel(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) {
channel_data* chand = arg;
gpr_mu_lock(&chand->max_age_timer_mu);
chand->max_age_timer_pending = false;
gpr_mu_unlock(&chand->max_age_timer_mu);
if (error == GRPC_ERROR_NONE) {
GRPC_CHANNEL_STACK_REF(chand->channel_stack,
"max_age start_max_age_grace_timer_after_goaway_op");
grpc_transport_op* op = grpc_make_transport_op(
&chand->start_max_age_grace_timer_after_goaway_op);
op->goaway_error =
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("max_age"),
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_NO_ERROR);
grpc_channel_element* elem =
grpc_channel_stack_element(chand->channel_stack, 0);
elem->filter->start_transport_op(exec_ctx, elem, op);
} else if (error != GRPC_ERROR_CANCELLED) {
GRPC_LOG_IF_ERROR("close_max_age_channel", error);
}
GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->channel_stack,
"max_age max_age_timer");
}
static void force_close_max_age_channel(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) {
channel_data* chand = arg;
gpr_mu_lock(&chand->max_age_timer_mu);
chand->max_age_grace_timer_pending = false;
gpr_mu_unlock(&chand->max_age_timer_mu);
if (error == GRPC_ERROR_NONE) {
grpc_transport_op* op = grpc_make_transport_op(NULL);
op->disconnect_with_error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel reaches max age");
grpc_channel_element* elem =
grpc_channel_stack_element(chand->channel_stack, 0);
elem->filter->start_transport_op(exec_ctx, elem, op);
} else if (error != GRPC_ERROR_CANCELLED) {
GRPC_LOG_IF_ERROR("force_close_max_age_channel", error);
}
GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->channel_stack,
"max_age max_age_grace_timer");
}
static void channel_connectivity_changed(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) {
channel_data* chand = arg;
if (chand->connectivity_state != GRPC_CHANNEL_SHUTDOWN) {
grpc_transport_op* op = grpc_make_transport_op(NULL);
op->on_connectivity_state_change = &chand->channel_connectivity_changed,
op->connectivity_state = &chand->connectivity_state;
grpc_channel_next_op(
exec_ctx, grpc_channel_stack_element(chand->channel_stack, 0), op);
} else {
gpr_mu_lock(&chand->max_age_timer_mu);
if (chand->max_age_timer_pending) {
grpc_timer_cancel(exec_ctx, &chand->max_age_timer);
chand->max_age_timer_pending = false;
}
if (chand->max_age_grace_timer_pending) {
grpc_timer_cancel(exec_ctx, &chand->max_age_grace_timer);
chand->max_age_grace_timer_pending = false;
}
gpr_mu_unlock(&chand->max_age_timer_mu);
/* If there are no active calls, this increasement will cancel
max_idle_timer, and prevent max_idle_timer from being started in the
future. */
increase_call_count(exec_ctx, chand);
}
}
/* A random jitter of +/-10% will be added to MAX_CONNECTION_AGE to spread out
connection storms. Note that the MAX_CONNECTION_AGE option without jitter
would not create connection storms by itself, but if there happened to be a
connection storm it could cause it to repeat at a fixed period. */
static int add_random_max_connection_age_jitter(int value) {
/* generate a random number between 1 - MAX_CONNECTION_AGE_JITTER and
1 + MAX_CONNECTION_AGE_JITTER */
double multiplier = rand() * MAX_CONNECTION_AGE_JITTER * 2.0 / RAND_MAX +
1.0 - MAX_CONNECTION_AGE_JITTER;
double result = multiplier * value;
/* INT_MAX - 0.5 converts the value to float, so that result will not be
cast to int implicitly before the comparison. */
return result > INT_MAX - 0.5 ? INT_MAX : (int)result;
}
/* Constructor for call_data. */
static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
grpc_call_element* elem,
const grpc_call_element_args* args) {
channel_data* chand = elem->channel_data;
increase_call_count(exec_ctx, chand);
return GRPC_ERROR_NONE;
}
/* Destructor for call_data. */
static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
channel_data* chand = elem->channel_data;
decrease_call_count(exec_ctx, chand);
}
/* Constructor for channel_data. */
static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
grpc_channel_element* elem,
grpc_channel_element_args* args) {
channel_data* chand = elem->channel_data;
gpr_mu_init(&chand->max_age_timer_mu);
chand->max_age_timer_pending = false;
chand->max_age_grace_timer_pending = false;
chand->channel_stack = args->channel_stack;
chand->max_connection_age =
DEFAULT_MAX_CONNECTION_AGE_MS == INT_MAX
? gpr_inf_future(GPR_TIMESPAN)
: gpr_time_from_millis(add_random_max_connection_age_jitter(
DEFAULT_MAX_CONNECTION_AGE_MS),
GPR_TIMESPAN);
chand->max_connection_age_grace =
DEFAULT_MAX_CONNECTION_AGE_GRACE_MS == INT_MAX
? gpr_inf_future(GPR_TIMESPAN)
: gpr_time_from_millis(DEFAULT_MAX_CONNECTION_AGE_GRACE_MS,
GPR_TIMESPAN);
chand->max_connection_idle =
DEFAULT_MAX_CONNECTION_IDLE_MS == INT_MAX
? gpr_inf_future(GPR_TIMESPAN)
: gpr_time_from_millis(DEFAULT_MAX_CONNECTION_IDLE_MS, GPR_TIMESPAN);
for (size_t i = 0; i < args->channel_args->num_args; ++i) {
if (0 == strcmp(args->channel_args->args[i].key,
GRPC_ARG_MAX_CONNECTION_AGE_MS)) {
const int value = grpc_channel_arg_get_integer(
&args->channel_args->args[i], MAX_CONNECTION_AGE_INTEGER_OPTIONS);
chand->max_connection_age =
value == INT_MAX
? gpr_inf_future(GPR_TIMESPAN)
: gpr_time_from_millis(
add_random_max_connection_age_jitter(value), GPR_TIMESPAN);
} else if (0 == strcmp(args->channel_args->args[i].key,
GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS)) {
const int value = grpc_channel_arg_get_integer(
&args->channel_args->args[i],
(grpc_integer_options){DEFAULT_MAX_CONNECTION_AGE_GRACE_MS, 0,
INT_MAX});
chand->max_connection_age_grace =
value == INT_MAX ? gpr_inf_future(GPR_TIMESPAN)
: gpr_time_from_millis(value, GPR_TIMESPAN);
} else if (0 == strcmp(args->channel_args->args[i].key,
GRPC_ARG_MAX_CONNECTION_IDLE_MS)) {
const int value = grpc_channel_arg_get_integer(
&args->channel_args->args[i], MAX_CONNECTION_IDLE_INTEGER_OPTIONS);
chand->max_connection_idle =
value == INT_MAX ? gpr_inf_future(GPR_TIMESPAN)
: gpr_time_from_millis(value, GPR_TIMESPAN);
}
}
grpc_closure_init(&chand->close_max_idle_channel, close_max_idle_channel,
chand, grpc_schedule_on_exec_ctx);
grpc_closure_init(&chand->close_max_age_channel, close_max_age_channel, chand,
grpc_schedule_on_exec_ctx);
grpc_closure_init(&chand->force_close_max_age_channel,
force_close_max_age_channel, chand,
grpc_schedule_on_exec_ctx);
grpc_closure_init(&chand->start_max_idle_timer_after_init,
start_max_idle_timer_after_init, chand,
grpc_schedule_on_exec_ctx);
grpc_closure_init(&chand->start_max_age_timer_after_init,
start_max_age_timer_after_init, chand,
grpc_schedule_on_exec_ctx);
grpc_closure_init(&chand->start_max_age_grace_timer_after_goaway_op,
start_max_age_grace_timer_after_goaway_op, chand,
grpc_schedule_on_exec_ctx);
grpc_closure_init(&chand->channel_connectivity_changed,
channel_connectivity_changed, chand,
grpc_schedule_on_exec_ctx);
if (gpr_time_cmp(chand->max_connection_age, gpr_inf_future(GPR_TIMESPAN)) !=
0) {
/* When the channel reaches its max age, we send down an op with
goaway_error set. However, we can't send down any ops until after the
channel stack is fully initialized. If we start the timer here, we have
no guarantee that the timer won't pop before channel stack initialization
is finished. To avoid that problem, we create a closure to start the
timer, and we schedule that closure to be run after call stack
initialization is done. */
GRPC_CHANNEL_STACK_REF(chand->channel_stack,
"max_age start_max_age_timer_after_init");
grpc_closure_sched(exec_ctx, &chand->start_max_age_timer_after_init,
GRPC_ERROR_NONE);
}
/* Initialize the number of calls as 1, so that the max_idle_timer will not
start until start_max_idle_timer_after_init is invoked. */
gpr_atm_rel_store(&chand->call_count, 1);
if (gpr_time_cmp(chand->max_connection_idle, gpr_inf_future(GPR_TIMESPAN)) !=
0) {
GRPC_CHANNEL_STACK_REF(chand->channel_stack,
"max_age start_max_idle_timer_after_init");
grpc_closure_sched(exec_ctx, &chand->start_max_idle_timer_after_init,
GRPC_ERROR_NONE);
}
return GRPC_ERROR_NONE;
}
/* Destructor for channel_data. */
static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
grpc_channel_element* elem) {}
const grpc_channel_filter grpc_max_age_filter = {
grpc_call_next_op,
grpc_channel_next_op,
0, /* sizeof_call_data */
init_call_elem,
grpc_call_stack_ignore_set_pollset_or_pollset_set,
destroy_call_elem,
sizeof(channel_data),
init_channel_elem,
destroy_channel_elem,
grpc_call_next_get_peer,
grpc_channel_next_get_info,
"max_age"};
static bool maybe_add_max_age_filter(grpc_exec_ctx* exec_ctx,
grpc_channel_stack_builder* builder,
void* arg) {
const grpc_channel_args* channel_args =
grpc_channel_stack_builder_get_channel_arguments(builder);
bool enable =
grpc_channel_arg_get_integer(
grpc_channel_args_find(channel_args, GRPC_ARG_MAX_CONNECTION_AGE_MS),
MAX_CONNECTION_AGE_INTEGER_OPTIONS) != INT_MAX &&
grpc_channel_arg_get_integer(
grpc_channel_args_find(channel_args, GRPC_ARG_MAX_CONNECTION_IDLE_MS),
MAX_CONNECTION_IDLE_INTEGER_OPTIONS) != INT_MAX;
if (enable) {
return grpc_channel_stack_builder_prepend_filter(
builder, &grpc_max_age_filter, NULL, NULL);
} else {
return true;
}
}
void grpc_max_age_filter_init(void) {
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL,
GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
maybe_add_max_age_filter, NULL);
}
void grpc_max_age_filter_shutdown(void) {}
| 46.059091 | 80 | 0.70527 |
e72a28f82c2221095e2014f22d47078a75936c0d | 1,797 | h | C | include/api.h | 22pilarskil/7405K_20-21 | 71e8d18a8d4bc4c9df04471f46c12a2370430c2b | [
"Apache-2.0"
] | 10 | 2021-02-02T09:52:47.000Z | 2022-03-11T12:58:53.000Z | include/api.h | 22pilarskil/7405K_20-21 | 71e8d18a8d4bc4c9df04471f46c12a2370430c2b | [
"Apache-2.0"
] | null | null | null | include/api.h | 22pilarskil/7405K_20-21 | 71e8d18a8d4bc4c9df04471f46c12a2370430c2b | [
"Apache-2.0"
] | 3 | 2020-11-29T00:46:41.000Z | 2021-10-01T22:08:25.000Z | /**
* \file api.h
*
* PROS API header provides high-level user functionality
*
* Contains declarations for use by typical VEX programmers using PROS.
*
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* Copyright (c) 2017-2021, Purdue University ACM SIGBots.
* All rights reserved.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef _PROS_API_H_
#define _PROS_API_H_
#ifdef __cplusplus
#include <cerrno>
#include <cmath>
#include <cstdbool>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#else /* (not) __cplusplus */
#include <errno.h>
#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#endif /* __cplusplus */
#define PROS_VERSION_MAJOR 3
#define PROS_VERSION_MINOR 3
#define PROS_VERSION_PATCH 2
#define PROS_VERSION_STRING "3.3.2-commit.4.871e491"
#define PROS_ERR (INT32_MAX)
#define PROS_ERR_F (INFINITY)
#include "pros/adi.h"
#include "pros/colors.h"
#include "pros/distance.h"
#include "pros/ext_adi.h"
#include "pros/imu.h"
#include "pros/llemu.h"
#include "pros/misc.h"
#include "pros/motors.h"
#include "pros/optical.h"
#include "pros/rtos.h"
#include "pros/rotation.h"
#include "pros/vision.h"
#ifdef __cplusplus
#include "pros/adi.hpp"
#include "pros/distance.hpp"
#include "pros/imu.hpp"
#include "pros/llemu.hpp"
#include "pros/misc.hpp"
#include "pros/motors.hpp"
#include "pros/optical.hpp"
#include "pros/rotation.hpp"
#include "pros/rtos.hpp"
#include "pros/vision.hpp"
#endif
#endif // _PROS_API_H_
| 23.337662 | 77 | 0.730106 |
ececc03ec6205e69b2ece3c25c0bfce7e67905f3 | 1,003 | c | C | release/src-rt/linux/linux-2.6/arch/mips/pci/fixup-ocelot3.c | 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/arch/mips/pci/fixup-ocelot3.c | ghsecuritylab/tomato_egg | 50473a46347f4631eb4878a0f47955cc64c87293 | [
"FSFAP"
] | 374 | 2015-11-03T12:37:22.000Z | 2021-12-17T14:18:08.000Z | release/src-rt/linux/linux-2.6/arch/mips/pci/fixup-ocelot3.c | ghsecuritylab/tomato_egg | 50473a46347f4631eb4878a0f47955cc64c87293 | [
"FSFAP"
] | 96 | 2015-11-22T07:47:26.000Z | 2022-01-20T19:52:19.000Z | /*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* Copyright (C) 2004 Montavista Software Inc.
* Author: Manish Lachwani (mlachwani@mvista.com)
*
* Looking at the schematics for the Ocelot-3 board, there are
* two PCI busses and each bus has two PCI slots.
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/pci.h>
#include <asm/mipsregs.h>
/*
* Do platform specific device initialization at
* pci_enable_device() time
*/
int pcibios_plat_dev_init(struct pci_dev *dev)
{
return 0;
}
int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
{
int bus = dev->bus->number;
if (bus == 0 && slot == 1)
return 2; /* PCI-X A */
if (bus == 0 && slot == 2)
return 3; /* PCI-X B */
if (bus == 1 && slot == 1)
return 4; /* PCI A */
if (bus == 1 && slot == 2)
return 5; /* PCI B */
return 0;
panic("Whooops in pcibios_map_irq");
}
| 23.880952 | 77 | 0.659023 |
10ccfdb6e184b8029df6f54ca7e48bbaac540036 | 748 | h | C | AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/MonthBillAccountUIModel.h | ceekay1991/AliPayForDebug | 5795e5db31e5b649d4758469b752585e63e84d94 | [
"MIT"
] | 5 | 2020-03-29T12:08:37.000Z | 2021-05-26T05:20:11.000Z | AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/MonthBillAccountUIModel.h | ceekay1991/AliPayForDebug | 5795e5db31e5b649d4758469b752585e63e84d94 | [
"MIT"
] | null | null | null | AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/MonthBillAccountUIModel.h | ceekay1991/AliPayForDebug | 5795e5db31e5b649d4758469b752585e63e84d94 | [
"MIT"
] | 5 | 2020-04-17T03:24:04.000Z | 2022-03-30T05:42:17.000Z | //
// Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 17 2017 16:24:48).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard.
//
#import <objc/NSObject.h>
@class NSDate, NSMutableDictionary;
@interface MonthBillAccountUIModel : NSObject
{
NSMutableDictionary *_cacheDictionary;
NSDate *_selectedMonth;
}
@property(retain, nonatomic) NSDate *selectedMonth; // @synthesize selectedMonth=_selectedMonth;
@property(retain, nonatomic) NSMutableDictionary *cacheDictionary; // @synthesize cacheDictionary=_cacheDictionary;
- (void).cxx_destruct;
- (id)accountDataWithMonth:(id)arg1;
- (id)billFlowWithMonth:(id)arg1;
- (void)clearData;
- (void)loadWithMonth:(id)arg1;
- (id)init;
@end
| 26.714286 | 115 | 0.741979 |
3422af3a2776587b87016090e7bdca6d3f3e10d4 | 10,489 | c | C | tests/test-util.c | mestery/ovs-vxlan | bbd5b6f44bcc798a6636f52ed843b1cef1372f43 | [
"Apache-2.0"
] | 22 | 2015-01-28T12:48:51.000Z | 2021-12-21T23:25:00.000Z | tests/test-util.c | mestery/ovs-vxlan | bbd5b6f44bcc798a6636f52ed843b1cef1372f43 | [
"Apache-2.0"
] | null | null | null | tests/test-util.c | mestery/ovs-vxlan | bbd5b6f44bcc798a6636f52ed843b1cef1372f43 | [
"Apache-2.0"
] | 6 | 2015-11-04T14:26:35.000Z | 2017-03-09T15:04:03.000Z | /*
* Copyright (c) 2011, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <config.h>
#include <getopt.h>
#include <inttypes.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include "byte-order.h"
#include "command-line.h"
#include "random.h"
#include "util.h"
#include "vlog.h"
#undef NDEBUG
#include <assert.h>
static void
check_log_2_floor(uint32_t x, int n)
{
if (log_2_floor(x) != n) {
fprintf(stderr, "log_2_floor(%"PRIu32") is %d but should be %d\n",
x, log_2_floor(x), n);
abort();
}
}
static void
test_log_2_floor(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
{
int n;
for (n = 0; n < 32; n++) {
/* Check minimum x such that f(x) == n. */
check_log_2_floor(1 << n, n);
/* Check maximum x such that f(x) == n. */
check_log_2_floor((1 << n) | ((1 << n) - 1), n);
/* Check a random value in the middle. */
check_log_2_floor((random_uint32() & ((1 << n) - 1)) | (1 << n), n);
}
/* log_2_floor(0) is undefined, so don't check it. */
}
static void
check_ctz(uint32_t x, int n)
{
if (ctz(x) != n) {
fprintf(stderr, "ctz(%"PRIu32") is %d but should be %d\n",
x, ctz(x), n);
abort();
}
}
static void
test_ctz(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
{
int n;
for (n = 0; n < 32; n++) {
/* Check minimum x such that f(x) == n. */
check_ctz(1 << n, n);
/* Check maximum x such that f(x) == n. */
check_ctz(UINT32_MAX << n, n);
/* Check a random value in the middle. */
check_ctz((random_uint32() | 1) << n, n);
}
/* Check ctz(0). */
check_ctz(0, 32);
}
static void
shuffle(unsigned int *p, size_t n)
{
for (; n > 1; n--, p++) {
unsigned int *q = &p[rand() % n];
unsigned int tmp = *p;
*p = *q;
*q = tmp;
}
}
static void
check_popcount(uint32_t x, int n)
{
if (popcount(x) != n) {
fprintf(stderr, "popcount(%#"PRIx32") is %d but should be %d\n",
x, popcount(x), n);
abort();
}
}
static void
test_popcount(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
{
unsigned int bits[32];
int i;
for (i = 0; i < ARRAY_SIZE(bits); i++) {
bits[i] = 1u << i;
}
check_popcount(0, 0);
for (i = 0; i < 1000; i++) {
uint32_t x = 0;
int j;
shuffle(bits, ARRAY_SIZE(bits));
for (j = 0; j < 32; j++) {
x |= bits[j];
check_popcount(x, j + 1);
}
assert(x == UINT32_MAX);
shuffle(bits, ARRAY_SIZE(bits));
for (j = 31; j >= 0; j--) {
x &= ~bits[j];
check_popcount(x, j);
}
assert(x == 0);
}
}
/* Returns the sum of the squares of the first 'n' positive integers. */
static unsigned int
sum_of_squares(int n)
{
return n * (n + 1) * (2 * n + 1) / 6;
}
static void
test_bitwise_copy(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
{
unsigned int n_loops;
int src_ofs;
int dst_ofs;
int n_bits;
n_loops = 0;
for (n_bits = 0; n_bits <= 64; n_bits++) {
for (src_ofs = 0; src_ofs < 64 - n_bits; src_ofs++) {
for (dst_ofs = 0; dst_ofs < 64 - n_bits; dst_ofs++) {
ovs_be64 src = htonll(random_uint64());
ovs_be64 dst = htonll(random_uint64());
ovs_be64 orig_dst = dst;
ovs_be64 expect;
if (n_bits == 64) {
expect = dst;
} else {
uint64_t mask = (UINT64_C(1) << n_bits) - 1;
expect = orig_dst & ~htonll(mask << dst_ofs);
expect |= htonll(((ntohll(src) >> src_ofs) & mask)
<< dst_ofs);
}
bitwise_copy(&src, sizeof src, src_ofs,
&dst, sizeof dst, dst_ofs,
n_bits);
if (expect != dst) {
fprintf(stderr,"copy_bits(0x%016"PRIx64",8,%d, "
"0x%016"PRIx64",8,%d, %d) yielded 0x%016"PRIx64" "
"instead of the expected 0x%016"PRIx64"\n",
ntohll(src), src_ofs,
ntohll(orig_dst), dst_ofs,
n_bits,
ntohll(dst), ntohll(expect));
abort();
}
n_loops++;
}
}
}
if (n_loops != sum_of_squares(64)) {
abort();
}
}
static void
test_bitwise_zero(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
{
unsigned int n_loops;
int dst_ofs;
int n_bits;
n_loops = 0;
for (n_bits = 0; n_bits <= 64; n_bits++) {
for (dst_ofs = 0; dst_ofs < 64 - n_bits; dst_ofs++) {
ovs_be64 dst = htonll(random_uint64());
ovs_be64 orig_dst = dst;
ovs_be64 expect;
if (n_bits == 64) {
expect = htonll(0);
} else {
uint64_t mask = (UINT64_C(1) << n_bits) - 1;
expect = orig_dst & ~htonll(mask << dst_ofs);
}
bitwise_zero(&dst, sizeof dst, dst_ofs, n_bits);
if (expect != dst) {
fprintf(stderr,"bitwise_zero(0x%016"PRIx64",8,%d, %d) "
"yielded 0x%016"PRIx64" "
"instead of the expected 0x%016"PRIx64"\n",
ntohll(orig_dst), dst_ofs,
n_bits,
ntohll(dst), ntohll(expect));
abort();
}
n_loops++;
}
}
if (n_loops != 64 * (64 + 1) / 2) {
abort();
}
}
static void
test_bitwise_one(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
{
unsigned int n_loops;
int dst_ofs;
int n_bits;
n_loops = 0;
for (n_bits = 0; n_bits <= 64; n_bits++) {
for (dst_ofs = 0; dst_ofs < 64 - n_bits; dst_ofs++) {
ovs_be64 dst = htonll(random_uint64());
ovs_be64 orig_dst = dst;
ovs_be64 expect;
if (n_bits == 64) {
expect = htonll(UINT64_MAX);
} else {
uint64_t mask = (UINT64_C(1) << n_bits) - 1;
expect = orig_dst | htonll(mask << dst_ofs);
}
bitwise_one(&dst, sizeof dst, dst_ofs, n_bits);
if (expect != dst) {
fprintf(stderr,"bitwise_one(0x%016"PRIx64",8,%d, %d) "
"yielded 0x%016"PRIx64" "
"instead of the expected 0x%016"PRIx64"\n",
ntohll(orig_dst), dst_ofs,
n_bits,
ntohll(dst), ntohll(expect));
abort();
}
n_loops++;
}
}
if (n_loops != 64 * (64 + 1) / 2) {
abort();
}
}
static void
test_bitwise_is_all_zeros(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
{
int n_loops;
for (n_loops = 0; n_loops < 100; n_loops++) {
ovs_be64 x = htonll(0);
int i;
for (i = 0; i < 64; i++) {
ovs_be64 bit;
int ofs, n;
/* Change a random 0-bit into a 1-bit. */
do {
bit = htonll(UINT64_C(1) << (random_uint32() % 64));
} while (x & bit);
x |= bit;
for (ofs = 0; ofs < 64; ofs++) {
for (n = 0; n <= 64 - ofs; n++) {
bool expect;
bool answer;
expect = (n == 64
? x == 0
: !(x & htonll(((UINT64_C(1) << n) - 1)
<< ofs)));
answer = bitwise_is_all_zeros(&x, sizeof x, ofs, n);
if (expect != answer) {
fprintf(stderr,
"bitwise_is_all_zeros(0x%016"PRIx64",8,%d,%d "
"returned %s instead of %s\n",
ntohll(x), ofs, n,
answer ? "true" : "false",
expect ? "true" : "false");
abort();
}
}
}
}
}
}
static void
test_follow_symlinks(int argc, char *argv[])
{
int i;
for (i = 1; i < argc; i++) {
char *target = follow_symlinks(argv[i]);
puts(target);
free(target);
}
}
static void
test_assert(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
{
ovs_assert(false);
}
static const struct command commands[] = {
{"ctz", 0, 0, test_ctz},
{"popcount", 0, 0, test_popcount},
{"log_2_floor", 0, 0, test_log_2_floor},
{"bitwise_copy", 0, 0, test_bitwise_copy},
{"bitwise_zero", 0, 0, test_bitwise_zero},
{"bitwise_one", 0, 0, test_bitwise_one},
{"bitwise_is_all_zeros", 0, 0, test_bitwise_is_all_zeros},
{"follow-symlinks", 1, INT_MAX, test_follow_symlinks},
{"assert", 0, 0, test_assert},
{NULL, 0, 0, NULL},
};
static void
parse_options(int argc, char *argv[])
{
enum {
VLOG_OPTION_ENUMS
};
static const struct option long_options[] = {
VLOG_LONG_OPTIONS,
{NULL, 0, NULL, 0},
};
char *short_options = long_options_to_short_options(long_options);
for (;;) {
int c = getopt_long(argc, argv, short_options, long_options, NULL);
if (c == -1) {
break;
}
switch (c) {
VLOG_OPTION_HANDLERS
case '?':
exit(EXIT_FAILURE);
default:
abort();
}
}
free(short_options);
}
int
main(int argc, char *argv[])
{
set_program_name(argv[0]);
parse_options(argc, argv);
run_command(argc - optind, argv + optind, commands);
return 0;
}
| 26.288221 | 78 | 0.481075 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.