file
stringlengths 18
26
| data
stringlengths 3
1.04M
|
---|---|
the_stack_data/190766922.c | #include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main(){
srand(time(0));
int num=rand()%10+1,guess_num=0,chance=0;
//printf("The number is %d\n",num);
do{
if(chance!=0)
printf("This is your %d chance",chance);
printf("\nGuess the number between 1 to 10\n");
scanf("%d",&guess_num);
chance++;
}while(num!=guess_num);
return 0;
} |
the_stack_data/11076080.c | // File: fig0610.c
// Computer Systems, Fifth edition
// Figure 6.10
#include <stdio.h>
char letter;
int main() {
scanf("%c", &letter);
while (letter != '*') {
if (letter == ' ') {
printf("\n");
}
else {
printf("%c", letter);
}
scanf("%c", &letter);
}
return 0;
}
|
the_stack_data/211081445.c | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <unistd.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<netinet/in.h>
int main()
{
int network_socket;
network_socket=socket(AF_INET,SOCK_DGRAM,0);
if(network_socket==-1)
{
printf("[-] Error in creating the socket.\n");
return 0;
}
struct sockaddr_in server_address;
server_address.sin_family=AF_INET;
server_address.sin_port=htons(9003);
server_address.sin_addr.s_addr=INADDR_ANY;
char client_response[200];
int response_descriptor;
printf("[!] Enter a string: \n");
response_descriptor=read(0,client_response,sizeof(client_response));
sendto(network_socket,client_response,response_descriptor,0,(struct sockaddr*)&server_address,sizeof(server_address));
int recv_stat;
int addr_len=sizeof(server_address);
char server_response[200];
recv_stat=recvfrom(network_socket,server_response,sizeof(server_response),0,(struct sockaddr*)&server_address,&addr_len);
write(1,server_response,recv_stat);
printf("[+] Successfully received.\n");
close(network_socket);
return 0;
}
|
the_stack_data/122014311.c | /* This testcase is part of GDB, the GNU debugger.
Copyright 2014-2021 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
int
func_nodebug (int neg)
{
return -neg;
}
int unresolved = 20;
|
the_stack_data/154831681.c | #include<stdio.h>
int solution(int n)
{
return 2*( n -1) / 3 + 1;
}
/* Do not edit below code */
int main(void) {
int n;
scanf("%d",&n);
int answer=solution(n);
printf("%d",answer);
return 0;
} |
the_stack_data/80313.c | /*
* Combined parallel for
* with multiple clauses
* */
#include <omp.h>
int main(void)
{
int i, a[1000];
int sum;
#pragma omp parallel for if(1) ordered reduction(+:sum) schedule(dynamic, 5)
for (i=0;i<1000;i++)
{
a[i]=i*2;
sum+=i;
}
return 0;
}
|
the_stack_data/952783.c | int x = 3;
int y;
int main(void) {
int z;
int y = x + 1; // 4
return 0;
} |
the_stack_data/154830509.c | /* ex1.c */
#include <sys/utsname.h>
#include <unistd.h>
#include <stdio.h>
int main()
{
union
{
short inum;
char c[sizeof(short)];
} un;
struct utsname uts;
un.inum=0x0102;
if(uname(&uts)<0)
{
printf("Could not get host information .\n");
return -1;
}
printf("%s -%s-%s:\n",uts.machine, uts.sysname, uts.release);
if(sizeof(short)!=2)
{
printf("sizeof short =%d\n", sizeof(short));
return 0;
}
if(un.c[0]==1 && un.c[1]==2)
printf("big_endian.\n");
else if(un.c[0]==2 && un.c[1]==1)
printf("little_endian.\n");
else
printf("unknown .\n");
return 0;
}
|
the_stack_data/122015099.c | #include <stdio.h>
#include <omp.h>
#define INTERVALS 1000000
int main(int arc, char* argv[])
{
double area; /* The final anser */
double ysum; /* Sum of rectangle heights */
double xi; /* Midpoint of interval */
int i;
ysum = 0.0;
double begin = omp_get_wtime();
for (i=0; i < INTERVALS; i++)
{
xi=((1.0/INTERVALS)*(i+0.5));
ysum+=4.0/(1.0+xi*xi);
}
area = ysum * (1.0/INTERVALS);
double time_spent = (double)(omp_get_wtime() - begin);
printf("pi is %13.11f\n", area);
printf ("Time: %f\n", time_spent);
return 0;
}
|
the_stack_data/560844.c | // { dg-do compile }
// { dg-options "-O -g -dA -gno-strict-dwarf" }
// { dg-additional-options "-fno-common" { target hppa*-*-hpux* } }
// { dg-final { scan-assembler-times " DW_AT_alignment" 1 { xfail { powerpc-ibm-aix* } } } }
typedef int __attribute__((__aligned__(64))) i_t;
i_t i;
|
the_stack_data/248809.c | /**
* \file
* \brief Use this file for quick parser tests on your machine.
*/
/*
* Copyright (c) 2011, ETH Zurich.
* All rights reserved.
*
* This file is distributed under the terms in the attached LICENSE file.
* If you do not find this file, copies can be found by writing to:
* ETH Zurich D-INFK, Universitaetstr. 6, CH-8092 Zurich. Attn: Systems Group.
*/
#ifdef TEST_PARSER
#include <stdio.h>
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#ifdef TEST_PARSER
#include "../../../include/octopus/parser/ast.h"
#else
#include <octopus/parser/ast.h>
#endif
#include "y.tab.h"
#define INITIAL_LENGTH 255
struct writer {
char* output;
size_t pos;
size_t length;
};
struct skb_record {
struct writer name;
struct writer attributes;
struct writer constraints;
};
void emit(struct writer*, const char*, ...);
// State used by tranlate()
static struct skb_record* sr;
static struct writer* w;
struct ast_object* attribute_name;
#ifdef PARSER_DEBUG
static void print_writer(struct writer* w) {
printf("\tpos: %lu\n", w->pos);
printf("\tlength: %lu\n", w->length);
printf("\toutput: %s\n", w->output);
}
#endif
void emit(struct writer* w, const char* format, ...)
{
assert(w != NULL);
assert(format != NULL);
va_list args;
if(w->output == NULL) {
w->output = malloc(INITIAL_LENGTH);
assert(w->output != NULL);
w->pos = 0;
w->length = INITIAL_LENGTH;
}
va_start(args, format);
int append_len = vsnprintf(NULL, 0, format, args);
va_end(args);
size_t occupied = w->pos + append_len;
if(w->length < occupied) {
w->output = realloc(w->output, occupied+1);
w->length = occupied;
}
va_start(args, format);
int bytes_written = vsnprintf(w->output+w->pos, append_len+1, format, args);
va_end(args);
assert(bytes_written == append_len);
w->pos = occupied;
}
static void translate(struct ast_object* p) {
assert(sr != NULL);
assert(p != NULL);
switch(p->type) {
case nodeType_Object:
assert(p->u.on.name != NULL);
w = &sr->name;
translate(p->u.on.name);
w = &sr->attributes;
emit(w, "[ ");
emit(&sr->constraints, "[ ");
if(p->u.on.attrs) {
translate(p->u.on.attrs);
}
emit(w, " ]");
size_t len = strlen(sr->constraints.output);
if(sr->constraints.output[len-2] == ',') {
sr->constraints.output[len-2] = ' ';
sr->constraints.output[len-1] = ']';
}
else {
emit(&sr->constraints, " ]");
}
break;
case nodeType_Attribute:
assert(p->u.an.attr != NULL);
translate(p->u.an.attr);
if(p->u.an.next != NULL) {
emit(w, ", ");
translate(p->u.an.next);
}
break;
case nodeType_Pair:
assert(p->u.pn.left != NULL);
assert(p->u.pn.right != NULL);
attribute_name = p->u.pn.left;
translate(p->u.pn.left);
emit(w, "::");
translate(p->u.pn.right);
break;
case nodeType_Constraint:
assert(p->u.cnsn.value != NULL);
// prolog variable, dont care about result, just make sure it's set
emit(w, "_");
w = &sr->constraints;
char* operator;
switch(p->u.cnsn.op) {
case constraint_GT:
operator = ">";
break;
case constraint_GE:
operator = ">=";
break;
case constraint_LT:
operator = "<";
break;
case constraint_LE:
operator = "=<";
break;
case constraint_EQ:
operator = "==";
break;
case constraint_NE:
operator = "=/=";
break;
case constraint_REGEX:
operator = "match";
break;
default:
assert(!"OP code not supported");
break;
}
emit(w, "constraint(");
translate(attribute_name);
emit(w, ", ");
emit(w, "'%s'", operator);
emit(w, ", ");
translate(p->u.cnsn.value);
emit(w, "), ");
w = &sr->attributes;
break;
case nodeType_Float:
emit(w, "%f", p->u.fn.value);
break;
case nodeType_Boolean:
if(p->u.bn.value) {
emit(w, "true");
}
else {
emit(w, "false");
}
break;
case nodeType_Constant:
emit(w, "%d", p->u.cn.value);
break;
case nodeType_String:
emit(w, "\'");
emit(w, p->u.sn.str);
emit(w, "\'");
break;
case nodeType_Ident:
emit(w, p->u.in.str);
break;
case nodeType_Unset:
assert(!"nodeType_Unset");
break;
}
}
static void walk_attributes(struct ast_object* ast) {
struct ast_object* attr = ast->u.on.attrs;
while(attr != NULL) {
assert(attr->type == nodeType_Attribute);
struct ast_object* pair = attr->u.an.attr;
assert(pair != NULL);
assert(pair->type == nodeType_Pair);
struct ast_object* left = pair->u.pn.left;
struct ast_object* right = pair->u.pn.right;;
assert(left != NULL);
assert(right != NULL);
attr = attr->u.an.next;
}
}
void transform_query(char* obj)
{
struct ast_object* ast = NULL;
errval_t err = generate_ast(obj, &ast);
if(err == 0) {
printf("AST seems ok, translate...\n");
sr = malloc(sizeof(struct skb_record));
memset(sr, 0, sizeof(struct skb_record));
translate(ast);
}
else {
assert(!"ast generation failed");
}
//free_ast(ast);
}
int main(int argc, char** argv)
{
transform_query("spawn.1.ready");
printf("result: %s:\n\t%s\n\t%s\n", sr->name.output, sr->attributes.output, sr->constraints.output);
/*transform_query("obj2 {}");
printf("result: %s:\n\t%s\n\t%s\n", sr->name.output, sr->attributes.output, sr->constraints.output);
transform_query("obj3 { int: -11, fl: 12.0}");
printf("result: %s:\n\t%s\n\t%s\n", sr->name.output, sr->attributes.output, sr->constraints.output);
transform_query("obj4 { int: 12, fl: .0012321, fl2: .22123100 }");
printf("result: %s:\n\t%s\n\t%s\n", sr->name.output, sr->attributes.output, sr->constraints.output);
transform_query("obj5 { reference: bla, integer: 12, str: '[]String!@#%^&*$&^*(_)(-=\\'', float: 12.0, bool: true }");
printf("result: %s:\n\t%s\n\t%s\n", sr->name.output, sr->attributes.output, sr->constraints.output);
transform_query("obj5 { str1: 'String1', str2: 'String2' }");
printf("result: %s:\n\t%s\n\t%s\n", sr->name.output, sr->attributes.output, sr->constraints.output);
//transform_query("obj7 { c1: < 10, c1: > 11.0, c3: == 0, c4: >= 0, c5: <= .123 }");
//printf("result: %s:\n\t%s\n\t%s\n", sr->name.output, sr->attributes.output, sr->constraints.output);
transform_query("obj7 { c1: r'^12.*ab$', c2: r'^ \\\\ ab*ab$ asd \\naasdf' }");
printf("result: %s:\n\t%s\n\t%s\n", sr->name.output, sr->attributes.output, sr->constraints.output);
*/
return 0;
}
#endif
|
the_stack_data/187642434.c | /*******************************************************************************
* File Name: cymetadata.c
*
* PSoC Creator 4.2
*
* Description:
* This file defines all extra memory spaces that need to be included.
* This file is automatically generated by PSoC Creator.
*
********************************************************************************
* Copyright (c) 2007-2018 Cypress Semiconductor. All rights reserved.
* You may use this file only in accordance with the license, terms, conditions,
* disclaimers, and limitations in the end user license agreement accompanying
* the software package with which this file was provided.
********************************************************************************/
#include "stdint.h"
#if defined(__GNUC__) || defined(__ARMCC_VERSION)
#ifndef CY_FLASH_PROT_SECTION
#define CY_FLASH_PROT_SECTION __attribute__ ((__section__(".cyflashprotect"), used))
#endif
CY_FLASH_PROT_SECTION
#elif defined(__ICCARM__)
#pragma location=".cyflashprotect"
#else
#error "Unsupported toolchain"
#endif
const uint8_t cy_meta_flashprotect[] = {
0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u,
0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u,
0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u,
0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u
};
#if defined(__GNUC__) || defined(__ARMCC_VERSION)
#ifndef CY_META_SECTION
#define CY_META_SECTION __attribute__ ((__section__(".cymeta"), used))
#endif
CY_META_SECTION
#elif defined(__ICCARM__)
#pragma location=".cymeta"
#else
#error "Unsupported toolchain"
#endif
const uint8_t cy_metadata[] = {
0x00u, 0x02u, 0x04u, 0xC8u, 0x11u, 0x93u, 0x11u, 0x01u,
0x00u, 0x00u, 0x00u, 0x00u
};
#if defined(__GNUC__) || defined(__ARMCC_VERSION)
#ifndef CY_CHIP_PROT_SECTION
#define CY_CHIP_PROT_SECTION __attribute__ ((__section__(".cychipprotect"), used))
#endif
CY_CHIP_PROT_SECTION
#elif defined(__ICCARM__)
#pragma location=".cychipprotect"
#else
#error "Unsupported toolchain"
#endif
const uint8_t cy_meta_chipprotect[] = {
0x01u
};
|
the_stack_data/47113.c | // code: 1
int i = 0,
*p = &i,
*q = 0,
*r = (void*)0,
f(void),
(*fp)() = f,
a[] = {1, 2, 3};
struct s { int i; } my_s;
int *s = &my_s.i;
int f() { return 1; }
int main() { return (*fp)(); }
|
the_stack_data/60655.c | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dnascime <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/12/08 14:06:06 by dnascime #+# #+# */
/* Updated: 2019/12/08 14:25:12 by dnascime ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putchar(char c)
{
write(1, &c, 1);
} |
the_stack_data/90761876.c | static void order_dimms(void)
{
unsigned long tom;
tom = 0;
for(;;) {
unsigned csbase, csmask;
unsigned size;
unsigned index;
csbase = 0;
for(index = 0; index < 1; index++) {
csbase = __builtin_inl(0x40);
}
if (csbase == 0) {
break;
}
size = csbase;
csbase = (tom << 21);
tom += size;
csmask = size;
csmask |= 0xfe00;
__builtin_outl(csbase, 0xCFC);
__builtin_outl(0xc260, 0xCF8);
__builtin_outl(csmask, 0xCFC);
}
tom &= ~0xff000000;
__builtin_outl(tom, 0x1234);
}
|
the_stack_data/757118.c | #include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#define NBYTES 262144 /* 512 x 512 bytes */
unsigned char buf[NBYTES];
main (int argc, char **argv)
{
int i, fd, sz;
fd = open (argv[1], O_RDONLY, 0644);
sz = read (fd, buf, NBYTES);
close (fd);
printf ("#define LOGO_XDIM\t\t512\n");
printf ("#define LOGO_YDIM\t\t512\n");
printf ("#define LOGO_NCOLORS\t\t200\n");
printf ("#define LOGO_NBYTES\t\t262144\n");
printf ("\n");
printf ("unsigned char logo_data[] = {");
for (i=0; i < NBYTES; i++) {
if ((i % 15) == 0)
printf ("\n ");
printf ("0x%02x%s", (unsigned char)buf[i],(i==(NBYTES-1) ? "\n" : ","));
}
printf ("};\n\n");
}
|
the_stack_data/791090.c | void assert(int cond) { if (!cond) { ERROR: return; } }
int main() {
int x = 0;
int y = 0;
while (1) {
x++;
y++;
x += y;
y += x;
if (x >= 10 || y >= 10) break;
}
assert(y >= 10);
}
|
the_stack_data/76700563.c | #include <stdio.h>
int factorial(int i)
{
if (i < 2)
return i;
else
return i * factorial(i - 1);
}
int main()
{
int Count;
for (Count = 1; Count <= 10; Count++)
printf("%d\n", factorial(Count));
return 0;
}
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
|
the_stack_data/18886498.c | /**
@file calc_volume.c
@author Wesley Ring ([email protected])
Caculates the volume of a sphere with a given radius
*/
#include <stdio.h>
#define PI (3.141592653589793)
int main() {
float radius;
printf("Please enter the radius of the sphere:");
scanf("%f", &radius);
float volume = (4.0f / 3.0f) * PI * (radius * radius *radius);
printf("Volume (cubic feet): %f", volume);
return 0;
} |
the_stack_data/125140187.c | #include <stdio.h>
int main(void){
const int DAY_PER_WEEK = 7;
int day;
int week;
printf("请输入天数:");
scanf("%d", &day);
while(day > 0){
week = day / DAY_PER_WEEK;
day = day % DAY_PER_WEEK;
printf("%d days are %d weeks, %d days.\n",week * 7 + day, week,day);
printf("请输入天数:");
scanf("%d",&day);
}
return 0;
}
|
the_stack_data/151666.c | #include <stdio.h>
int Faktorijel(int x){
int i; int fakt=1;
if(x>=1){
for(i=1;i<=x;i++)
{
fakt=fakt*i;
}
} else fakt=1;
return fakt;
}
int main() {
int n;
int i;
double x, suma=0;
printf("Unesite broj n u intervalu [1, 12]: ");
scanf("%d", &n);
printf("Unesite realan broj x: ");
scanf("%lf", &x);
for(i=1;i<=n;i++)
{
suma= suma + (x/Faktorijel(i));
}
printf("Suma od 1 do %d za x = %.3f je %.3f", n, x, suma);
return 0;
}
|
the_stack_data/18887710.c | /**** use to break with :
LINEARIZE_ARRAY updating CODE(linearize)
updating CODE(linearize_array13!)
updating ENTITIES()
pips error in intrinsic_call_to_type: (../../../../../src/pips/src/Libs/ri-util/type.c:2136) assertion failed
'pointer arithmetic with array name, first element must be the address expression' not verified
***/
int linearize(int a[10][10],int b[10][10]) {
int ret;
ret = a[0][(int) (1+b[2][1])];
return ret;
}
|
the_stack_data/756290.c | /* This testcase is part of GDB, the GNU debugger.
Copyright 2007-2015 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <stdlib.h>
#define DELTA (0.0001df)
#define DELTA_B (0.001)
double double_val1 = 45.125;
double double_val2 = -67.75;
double double_val3 = 0.25;
double double_val4 = 1.25;
double double_val5 = 2.25;
double double_val6 = 3.25;
double double_val7 = 4.25;
double double_val8 = 5.25;
double double_val9 = 6.25;
double double_val10 = 7.25;
double double_val11 = 8.25;
double double_val12 = 9.25;
double double_val13 = 10.25;
double double_val14 = 11.25;
_Decimal32 dec32_val1 = 3.14159df;
_Decimal32 dec32_val2 = -2.3765df;
_Decimal32 dec32_val3 = 0.2df;
_Decimal32 dec32_val4 = 1.2df;
_Decimal32 dec32_val5 = 2.2df;
_Decimal32 dec32_val6 = 3.2df;
_Decimal32 dec32_val7 = 4.2df;
_Decimal32 dec32_val8 = 5.2df;
_Decimal32 dec32_val9 = 6.2df;
_Decimal32 dec32_val10 = 7.2df;
_Decimal32 dec32_val11 = 8.2df;
_Decimal32 dec32_val12 = 9.2df;
_Decimal32 dec32_val13 = 10.2df;
_Decimal32 dec32_val14 = 11.2df;
_Decimal32 dec32_val15 = 12.2df;
_Decimal32 dec32_val16 = 13.2df;
_Decimal64 dec64_val1 = 3.14159dd;
_Decimal64 dec64_val2 = -2.3765dd;
_Decimal64 dec64_val3 = 0.2dd;
_Decimal64 dec64_val4 = 1.2dd;
_Decimal64 dec64_val5 = 2.2dd;
_Decimal64 dec64_val6 = 3.2dd;
_Decimal64 dec64_val7 = 4.2dd;
_Decimal64 dec64_val8 = 5.2dd;
_Decimal64 dec64_val9 = 6.2dd;
_Decimal64 dec64_val10 = 7.2dd;
_Decimal64 dec64_val11 = 8.2dd;
_Decimal64 dec64_val12 = 9.2dd;
_Decimal64 dec64_val13 = 10.2dd;
_Decimal64 dec64_val14 = 11.2dd;
_Decimal64 dec64_val15 = 12.2dd;
_Decimal64 dec64_val16 = 13.2dd;
_Decimal128 dec128_val1 = 3.14159dl;
_Decimal128 dec128_val2 = -2.3765dl;
_Decimal128 dec128_val3 = 0.2dl;
_Decimal128 dec128_val4 = 1.2dl;
_Decimal128 dec128_val5 = 2.2dl;
_Decimal128 dec128_val6 = 3.2dl;
_Decimal128 dec128_val7 = 4.2dl;
_Decimal128 dec128_val8 = 5.2dl;
_Decimal128 dec128_val9 = 6.2dl;
_Decimal128 dec128_val10 = 7.2dl;
_Decimal128 dec128_val11 = 8.2dl;
_Decimal128 dec128_val12 = 9.2dl;
_Decimal128 dec128_val13 = 10.2dl;
_Decimal128 dec128_val14 = 11.2dl;
_Decimal128 dec128_val15 = 12.2dl;
_Decimal128 dec128_val16 = 13.2dl;
volatile _Decimal32 d32;
volatile _Decimal64 d64;
volatile _Decimal128 d128;
struct decstruct
{
int int4;
long long8;
float float4;
double double8;
_Decimal32 dec32;
_Decimal64 dec64;
_Decimal128 dec128;
} ds;
static _Decimal32
arg0_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2,
_Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5)
{
return arg0;
}
static _Decimal64
arg0_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2,
_Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5)
{
return arg0;
}
static _Decimal128
arg0_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2,
_Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5)
{
return arg0;
}
/* Function to test if _Decimal128 argument interferes with stack slots
because of alignment. */
int
decimal_dec128_align (double arg0, _Decimal128 arg1, double arg2, double arg3,
double arg4, double arg5, double arg6, double arg7,
double arg8, double arg9, double arg10, double arg11,
double arg12, double arg13)
{
return ((arg0 - double_val1) < DELTA_B
&& (arg0 - double_val1) > -DELTA_B
&& (arg1 - dec128_val2) < DELTA
&& (arg1 - dec128_val2) > -DELTA
&& (arg2 - double_val3) < DELTA_B
&& (arg2 - double_val3) > -DELTA_B
&& (arg3 - double_val4) < DELTA_B
&& (arg3 - double_val4) > -DELTA_B
&& (arg4 - double_val5) < DELTA_B
&& (arg4 - double_val5) > -DELTA_B
&& (arg5 - double_val6) < DELTA_B
&& (arg5 - double_val6) > -DELTA_B
&& (arg6 - double_val7) < DELTA_B
&& (arg6 - double_val7) > -DELTA_B
&& (arg7 - double_val8) < DELTA_B
&& (arg7 - double_val8) > -DELTA_B
&& (arg8 - double_val9) < DELTA_B
&& (arg8 - double_val9) > -DELTA_B
&& (arg9 - double_val10) < DELTA_B
&& (arg9 - double_val10) > -DELTA_B
&& (arg10 - double_val11) < DELTA_B
&& (arg10 - double_val11) > -DELTA_B
&& (arg11 - double_val12) < DELTA_B
&& (arg11 - double_val12) > -DELTA_B
&& (arg12 - double_val13) < DELTA_B
&& (arg12 - double_val13) > -DELTA_B
&& (arg13 - double_val14) < DELTA_B
&& (arg13 - double_val14) > -DELTA_B);
}
int
decimal_mixed (_Decimal32 arg0, _Decimal64 arg1, _Decimal128 arg2)
{
return ((arg0 - dec32_val1) < DELTA
&& (arg0 - dec32_val1) > -DELTA
&& (arg1 - dec64_val1) < DELTA
&& (arg1 - dec64_val1) > -DELTA
&& (arg2 - dec128_val1) < DELTA
&& (arg2 - dec128_val1) > -DELTA);
}
/* These functions have many arguments to force some of them to be passed via
the stack instead of registers, to test that GDB can construct correctly
the parameter save area. Note that Linux/ppc32 has 8 float registers to use
for float parameter passing and Linux/ppc64 has 13, so the number of
arguments has to be at least 14 to contemplate these platforms. */
int
decimal_many_args_dec32 (_Decimal32 f1, _Decimal32 f2, _Decimal32 f3,
_Decimal32 f4, _Decimal32 f5, _Decimal32 f6,
_Decimal32 f7, _Decimal32 f8, _Decimal32 f9,
_Decimal32 f10, _Decimal32 f11, _Decimal32 f12,
_Decimal32 f13, _Decimal32 f14, _Decimal32 f15,
_Decimal32 f16)
{
_Decimal32 sum_args;
_Decimal32 sum_values;
sum_args = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12
+ f13 + f14 + f15 + f16;
sum_values = dec32_val1 + dec32_val2 + dec32_val3 + dec32_val4 + dec32_val5
+ dec32_val6 + dec32_val7 + dec32_val8 + dec32_val9
+ dec32_val10 + dec32_val11 + dec32_val12 + dec32_val13
+ dec32_val14 + dec32_val15 + dec32_val16;
return ((sum_args - sum_values) < DELTA
&& (sum_args - sum_values) > -DELTA);
}
int
decimal_many_args_dec64 (_Decimal64 f1, _Decimal64 f2, _Decimal64 f3,
_Decimal64 f4, _Decimal64 f5, _Decimal64 f6,
_Decimal64 f7, _Decimal64 f8, _Decimal64 f9,
_Decimal64 f10, _Decimal64 f11, _Decimal64 f12,
_Decimal64 f13, _Decimal64 f14, _Decimal64 f15,
_Decimal64 f16)
{
_Decimal64 sum_args;
_Decimal64 sum_values;
sum_args = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12
+ f13 + f14 + f15 + f16;
sum_values = dec64_val1 + dec64_val2 + dec64_val3 + dec64_val4 + dec64_val5
+ dec64_val6 + dec64_val7 + dec64_val8 + dec64_val9
+ dec64_val10 + dec64_val11 + dec64_val12 + dec64_val13
+ dec64_val14 + dec64_val15 + dec64_val16;
return ((sum_args - sum_values) < DELTA
&& (sum_args - sum_values) > -DELTA);
}
int
decimal_many_args_dec128 (_Decimal128 f1, _Decimal128 f2, _Decimal128 f3,
_Decimal128 f4, _Decimal128 f5, _Decimal128 f6,
_Decimal128 f7, _Decimal128 f8, _Decimal128 f9,
_Decimal128 f10, _Decimal128 f11, _Decimal128 f12,
_Decimal128 f13, _Decimal128 f14, _Decimal128 f15,
_Decimal128 f16)
{
_Decimal128 sum_args;
_Decimal128 sum_values;
sum_args = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12
+ f13 + f14 + f15 + f16;
sum_values = dec128_val1 + dec128_val2 + dec128_val3 + dec128_val4 + dec128_val5
+ dec128_val6 + dec128_val7 + dec128_val8 + dec128_val9
+ dec128_val10 + dec128_val11 + dec128_val12 + dec128_val13
+ dec128_val14 + dec128_val15 + dec128_val16;
return ((sum_args - sum_values) < DELTA
&& (sum_args - sum_values) > -DELTA);
}
int
decimal_many_args_mixed (_Decimal32 f1, _Decimal32 f2, _Decimal32 f3,
_Decimal64 f4, _Decimal64 f5, _Decimal64 f6,
_Decimal64 f7, _Decimal128 f8, _Decimal128 f9,
_Decimal128 f10, _Decimal32 f11, _Decimal64 f12,
_Decimal32 f13, _Decimal64 f14, _Decimal128 f15)
{
_Decimal128 sum_args;
_Decimal128 sum_values;
sum_args = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12
+ f13 + f14 + f15;
sum_values = dec32_val1 + dec32_val2 + dec32_val3 + dec64_val4 + dec64_val5
+ dec64_val6 + dec64_val7 + dec128_val8 + dec128_val9
+ dec128_val10 + dec32_val11 + dec64_val12 + dec32_val13
+ dec64_val14 + dec128_val15;
return ((sum_args - sum_values) < DELTA
&& (sum_args - sum_values) > -DELTA);
}
int main()
{
/* An finite 32-bits decimal floating point. */
d32 = 1.2345df; /* Initialize d32. */
/* Non-finite 32-bits decimal floating point: infinity and NaN. */
d32 = __builtin_infd32(); /* Positive infd32. */
d32 = -__builtin_infd32(); /* Negative infd32. */
d32 = __builtin_nand32("");
/* An finite 64-bits decimal floating point. */
d64 = 1.2345dd; /* Initialize d64. */
/* Non-finite 64-bits decimal floating point: infinity and NaN. */
d64 = __builtin_infd64(); /* Positive infd64. */
d64 = -__builtin_infd64(); /* Negative infd64. */
d64 = __builtin_nand64("");
/* An finite 128-bits decimal floating point. */
d128 = 1.2345dl; /* Initialize d128. */
/* Non-finite 128-bits decimal floating point: infinity and NaN. */
d128 = __builtin_infd128(); /* Positive infd128. */
d128 = -__builtin_infd128(); /* Negative infd128. */
d128 = __builtin_nand128("");
/* Functions with decimal floating point as parameter and return value. */
d32 = arg0_32 (0.1df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df);
d64 = arg0_64 (0.1dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd);
d128 = arg0_128 (0.1dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl);
ds.int4 = 1;
ds.long8 = 2;
ds.float4 = 3.1;
ds.double8 = 4.2;
ds.dec32 = 1.2345df;
ds.dec64 = 1.2345dd;
ds.dec128 = 1.2345dl;
return 0; /* Exit point. */
}
|
the_stack_data/31995.c | #include <assert.h>
#include <stdlib.h>
#define FIRST_CORO f25
#define FIRST_DIRECT d05
int d01( int a )
{
return ( a * 17 + 29 ) % 1553;
}
int d02( int a ) { return d01( d01( a ) ); }
int d03( int a ) { return d02( d02( a ) ); }
int d04( int a ) { return d03( d03( a ) ); }
int d05( int a ) { return d04( d04( a ) ); }
int d06( int a ) { return d05( d05( a ) ); }
int d07( int a ) { return d06( d06( a ) ); }
int d08( int a ) { return d07( d07( a ) ); }
int d09( int a ) { return d08( d08( a ) ); }
int d10( int a ) { return d09( d09( a ) ); }
int d11( int a ) { return d10( d10( a ) ); }
int d12( int a ) { return d11( d11( a ) ); }
int d13( int a ) { return d12( d12( a ) ); }
int d14( int a ) { return d13( d13( a ) ); }
int d15( int a ) { return d14( d14( a ) ); }
int d16( int a ) { return d15( d15( a ) ); }
int d17( int a ) { return d16( d16( a ) ); }
int d18( int a ) { return d17( d17( a ) ); }
int d19( int a ) { return d18( d18( a ) ); }
int d20( int a ) { return d19( d19( a ) ); }
int d21( int a ) { return d20( d20( a ) ); }
int d22( int a ) { return d21( d21( a ) ); }
int d23( int a ) { return d22( d22( a ) ); }
int d24( int a ) { return d23( d23( a ) ); }
int d25( int a ) { return d24( d24( a ) ); }
int d26( int a ) { return d25( d25( a ) ); }
int d27( int a ) { return d26( d26( a ) ); }
int d28( int a ) { return d27( d27( a ) ); }
int d29( int a ) { return d28( d28( a ) ); }
int d30( int a ) { return d29( d29( a ) ); }
int d31( int a ) { return d30( d30( a ) ); }
int d32( int a ) { return d31( d31( a ) ); }
int d33( int a ) { return d32( d32( a ) ); }
int d34( int a ) { return d33( d33( a ) ); }
int d35( int a ) { return d34( d34( a ) ); }
int d36( int a ) { return d35( d35( a ) ); }
int d37( int a ) { return d36( d36( a ) ); }
int d38( int a ) { return d37( d37( a ) ); }
int d39( int a ) { return d38( d38( a ) ); }
int d40( int a ) { return d39( d39( a ) ); }
typedef struct frame_t frame_t, *frame_p;
typedef enum
{
CORO_CALL,
CORO_RETURN,
} coro_status;
struct frame_t
{
frame_p prev;
void *return_address;
coro_status (*fn)( frame_p, frame_p * );
int return_val, param, local;
};
coro_status f01( frame_p curr, frame_p *callee )
{
curr->return_val = FIRST_DIRECT( curr->param );
return CORO_RETURN;
}
#define FXX( f1, f2 ) \
coro_status f2( frame_p curr, frame_p *callee ) { \
if( curr->return_address ) \
{ \
goto *curr->return_address; \
} \
*callee = (frame_p)malloc( sizeof( callee[0][0] ) ); \
(*callee)->prev = curr; \
(*callee)->return_address = 0; \
(*callee)->param = curr->param; \
(*callee)->fn = f1; \
curr->return_address = &&step2; \
return CORO_CALL; \
step2: \
(*callee)->return_address = 0; \
(*callee)->param = (*callee)->return_val; \
curr->return_address = &&step3; \
return CORO_CALL; \
step3: \
curr->return_val = (*callee)->return_val; \
free( *callee ); \
return CORO_RETURN; \
}
FXX( f01, f02 )
FXX( f02, f03 )
FXX( f03, f04 )
FXX( f04, f05 )
FXX( f05, f06 )
FXX( f06, f07 )
FXX( f07, f08 )
FXX( f08, f09 )
FXX( f09, f10 )
FXX( f10, f11 )
FXX( f11, f12 )
FXX( f12, f13 )
FXX( f13, f14 )
FXX( f14, f15 )
FXX( f15, f16 )
FXX( f16, f17 )
FXX( f17, f18 )
FXX( f18, f19 )
FXX( f19, f20 )
FXX( f20, f21 )
FXX( f21, f22 )
FXX( f22, f23 )
FXX( f23, f24 )
FXX( f24, f25 )
FXX( f25, f26 )
FXX( f26, f27 )
FXX( f27, f28 )
FXX( f28, f29 )
FXX( f29, f30 )
int main( int argc, char **argv )
{
frame_p f = (frame_p)malloc( sizeof( f[0] ) );
int return_val;
frame_p callee;
f->return_address = 0;
f->param = argc;
f->prev = NULL;
f->fn = FIRST_CORO;
while( f )
{
coro_status status;
//if( f->fn == f01 )
// status = f01( f, &callee );
//else
status = f->fn( f, &callee );
switch( status )
{
case CORO_CALL:
f = callee;
break;
case CORO_RETURN:
callee = f;
return_val = f->return_val;
f = f->prev;
break;
default:
assert( 0 );
}
}
return return_val;
}
|
the_stack_data/215769520.c | //
// main.c
// 14
//
// Created by Никифоров Иван on 14.10.14.
// Copyright (c) 2014 NIkif. All rights reserved.
//
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int wcount(char *s)
{
int n, i, sum=0, a=0;
n = (int)strlen(s);
char *string;
string=(char*)malloc((n+1)*sizeof(char));
strncpy(string, s, n);
if (n==0) {
free(string);
return 0;
}
if ((n==1)&&(string[0]!=' ')){
free(string);
return 1;
}
for (i=1; i<n; i++) {
if ((string[i]!= ' ')&&(string[i-1]== ' '))
sum+=1;
// if(s[i]!=0) printf("%s -> %d\n", &s[i], sum);
}
if (string[0]!=' ') {
sum+=1;
}
if (sum!=0){
free(string);
return sum;
}else{
for (i=0; i<n; i++) {
if (string[i]!= ' ') a+=1;
}
if (a!=0){
free(string);
return 1;
}
}
free(string);
return sum;
}
int main(int argc, const char * argv[]) {
char s;
gets(&s);
int n =wcount(&s);
printf("%d", n);
// int *d = wcount(&s);
// free(d);
return 0;
}
|
the_stack_data/15008.c | #include <stdio.h>
#include <stdlib.h>
#include <signal.h>
/* some labeled signal defines from signal.h
* #define SIGHUP 1 hangup
* #define SIGINT 2 interrupt (Ctrl-C)
* #define SIGQUIT 3 quit (Ctrl-\)
* #define SIGILL 4 illegal instruction
* #define SIGTRAP 5 trace/breakpoint trap
* #define SIGABRT 6 process aborted
* #define SIGBUS 7 bus error
* #define SIGFPE 8 floating point error
* #define SIGKILL 9 kill
* #define SIGUSR1 10 user defined signal 1
* #define SIGSEGV 11 segmentation fault
* #define SIGUSR2 12 user defined signal 2
* #define SIGPIPE 13 write to pipe with no one reading
* #define SIGALRM 14 countdown alarm set by alarm()
* #define SIGTERM 15 termination (sent by kill command)
* #define SIGCHLD 17 child process signal
* #define SIGCONT 18 continue if stopped
* #define SIGSTOP 19 stop (pause execution)
* #define SIGTSTP 20 terminal stop [suspend] (Ctrl-Z)
* #define SIGTTIN 21 background process trying to read stdin
* #define SIGTTOU 22 background process trying to read stdout
*/
/* a signal handler */
void signal_handler(int signal) {
printf("Caught signal %d\t", signal);
if (signal == SIGTSTP)
printf("SIGTSTP (Ctrl-Z)");
else if (signal == SIGQUIT)
printf("SIGQUIT (Ctrl-\\)");
else if (signal == SIGUSR1)
printf("SIGUSR1");
else if (signal == SIGUSR2)
printf("SIGUSR2");
printf("\n");
}
void sigint_handler(int x) {
printf("Caught a Ctrl-C (SIGINT) in a separate handler\nExiting..\n");
exit(0);
}
int main() {
/* registering signal handlers */
signal(SIGQUIT, signal_handler); // set signal_handler() as the
signal(SIGTSTP, signal_handler); // signal handler for these
signal(SIGUSR1, signal_handler); // signals
signal(SIGUSR2, signal_handler);
signal(SIGINT, sigint_handler); // set sigint_handler() for SIGINT
while(1) {} // loop forever
}
|
the_stack_data/901510.c | #include <spawn.h>
#include <stdlib.h>
#include <stdio.h>
int main(__attribute__((unused)) int argc, char **argv) {
pid_t pid = 0;
printf("doing it:\n");
int ret = posix_spawn(&pid, argv[1], NULL, NULL, argv + 1, NULL);
printf("==> %d pid=%d\n", ret, pid);
}
|
the_stack_data/34513335.c | /* Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C 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.
The GNU C 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 the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define VAR "FOOBAR"
char putenv_val[100] = VAR "=some longer value";
int
main (void)
{
int result = 0;
const char *valp;
/* First test: remove entry FOOBAR, whether it exists or not. */
unsetenv (VAR);
/* Now getting the value should fail. */
if (getenv (VAR) != NULL)
{
printf ("There should be no `%s' value\n", VAR);
result = 1;
}
/* Now add a value, with the replace flag cleared. */
if (setenv (VAR, "one", 0) != 0)
{
printf ("setenv #1 failed: %m\n");
result = 1;
}
/* Getting this value should now be possible. */
valp = getenv (VAR);
if (valp == NULL || strcmp (valp, "one") != 0)
{
puts ("getenv #2 failed");
result = 1;
}
/* Try to replace without the replace flag set. This should fail. */
if (setenv (VAR, "two", 0) != 0)
{
printf ("setenv #2 failed: %m\n");
result = 1;
}
/* The value shouldn't have changed. */
valp = getenv (VAR);
if (valp == NULL || strcmp (valp, "one") != 0)
{
puts ("getenv #3 failed");
result = 1;
}
/* Now replace the value using putenv. */
if (putenv (putenv_val) != 0)
{
printf ("putenv #1 failed: %m\n");
result = 1;
}
/* The value should have changed now. */
valp = getenv (VAR);
if (valp == NULL || strcmp (valp, "some longer value") != 0)
{
printf ("getenv #4 failed (is \"%s\")\n", valp);
result = 1;
}
/* Now one tricky check: changing the variable passed in putenv should
change the environment. */
strcpy (&putenv_val[sizeof VAR], "a short one");
/* The value should have changed again. */
valp = getenv (VAR);
if (valp == NULL || strcmp (valp, "a short one") != 0)
{
puts ("getenv #5 failed");
result = 1;
}
/* It should even be possible to rename the variable. */
strcpy (putenv_val, "XYZZY=some other value");
/* Now a lookup using the old name should fail. */
if (getenv (VAR) != NULL)
{
puts ("getenv #6 failed");
result = 1;
}
/* But using the new name it should work. */
valp = getenv ("XYZZY");
if (valp == NULL || strcmp (valp, "some other value") != 0)
{
puts ("getenv #7 failed");
result = 1;
}
/* Create a new variable with the old name. */
if (setenv (VAR, "a new value", 0) != 0)
{
printf ("setenv #3 failed: %m\n");
result = 1;
}
/* At this point a getenv call must return the new value. */
valp = getenv (VAR);
if (valp == NULL || strcmp (valp, "a new value") != 0)
{
puts ("getenv #8 failed");
result = 1;
}
/* Black magic: rename the variable we added using putenv back. */
strcpy (putenv_val, VAR "=old name new value");
/* This is interesting. We have two variables with the same name.
Getting a value should return one of them. */
valp = getenv (VAR);
if (valp == NULL
|| (strcmp (valp, "a new value") != 0
&& strcmp (valp, "old name new value") != 0))
{
puts ("getenv #9 failed");
result = 1;
}
/* More fun ahead: we are now removing the variable. This should remove
both values. The cast is ok: this call should never put the string
in the environment and it should never modify it. */
putenv ((char *) VAR);
/* Getting the value should now fail. */
if (getenv (VAR) != NULL)
{
printf ("getenv #10 failed (\"%s\" found)\n", getenv (VAR));
result = 1;
}
/* Now a test with an environment variable that's one character long.
This is to test a special case in the getenv implementation. */
strcpy (putenv_val, "X=one character test");
if (putenv (putenv_val) != 0)
{
printf ("putenv #2 failed: %m\n");
result = 1;
}
valp = getenv ("X");
if (valp == NULL || strcmp (valp, "one character test") != 0)
{
puts ("getenv #11 failed");
result = 1;
}
return result;
}
|
the_stack_data/89200243.c | /*
* Copyright (c) 2014 SGI.
* All rights reserved.
*
* 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.
*
* This program is distributed in the hope that it would 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 the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* Generator for a compact trie for unicode normalization */
#include <sys/types.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
/* Default names of the in- and output files. */
#define AGE_NAME "DerivedAge.txt"
#define CCC_NAME "DerivedCombiningClass.txt"
#define PROP_NAME "DerivedCoreProperties.txt"
#define DATA_NAME "UnicodeData.txt"
#define FOLD_NAME "CaseFolding.txt"
#define NORM_NAME "NormalizationCorrections.txt"
#define TEST_NAME "NormalizationTest.txt"
#define UTF8_NAME "utf8data.h"
const char *age_name = AGE_NAME;
const char *ccc_name = CCC_NAME;
const char *prop_name = PROP_NAME;
const char *data_name = DATA_NAME;
const char *fold_name = FOLD_NAME;
const char *norm_name = NORM_NAME;
const char *test_name = TEST_NAME;
const char *utf8_name = UTF8_NAME;
int verbose = 0;
/* An arbitrary line size limit on input lines. */
#define LINESIZE 1024
char line[LINESIZE];
char buf0[LINESIZE];
char buf1[LINESIZE];
char buf2[LINESIZE];
char buf3[LINESIZE];
const char *argv0;
/* ------------------------------------------------------------------ */
/*
* Unicode version numbers consist of three parts: major, minor, and a
* revision. These numbers are packed into an unsigned int to obtain
* a single version number.
*
* To save space in the generated trie, the unicode version is not
* stored directly, instead we calculate a generation number from the
* unicode versions seen in the DerivedAge file, and use that as an
* index into a table of unicode versions.
*/
#define UNICODE_MAJ_SHIFT (16)
#define UNICODE_MIN_SHIFT (8)
#define UNICODE_MAJ_MAX ((unsigned short)-1)
#define UNICODE_MIN_MAX ((unsigned char)-1)
#define UNICODE_REV_MAX ((unsigned char)-1)
#define UNICODE_AGE(MAJ,MIN,REV) \
(((unsigned int)(MAJ) << UNICODE_MAJ_SHIFT) | \
((unsigned int)(MIN) << UNICODE_MIN_SHIFT) | \
((unsigned int)(REV)))
unsigned int *ages;
int ages_count;
unsigned int unicode_maxage;
static int age_valid(unsigned int major, unsigned int minor,
unsigned int revision)
{
if (major > UNICODE_MAJ_MAX)
return 0;
if (minor > UNICODE_MIN_MAX)
return 0;
if (revision > UNICODE_REV_MAX)
return 0;
return 1;
}
/* ------------------------------------------------------------------ */
/*
* utf8trie_t
*
* A compact binary tree, used to decode UTF-8 characters.
*
* Internal nodes are one byte for the node itself, and up to three
* bytes for an offset into the tree. The first byte contains the
* following information:
* NEXTBYTE - flag - advance to next byte if set
* BITNUM - 3 bit field - the bit number to tested
* OFFLEN - 2 bit field - number of bytes in the offset
* if offlen == 0 (non-branching node)
* RIGHTPATH - 1 bit field - set if the following node is for the
* right-hand path (tested bit is set)
* TRIENODE - 1 bit field - set if the following node is an internal
* node, otherwise it is a leaf node
* if offlen != 0 (branching node)
* LEFTNODE - 1 bit field - set if the left-hand node is internal
* RIGHTNODE - 1 bit field - set if the right-hand node is internal
*
* Due to the way utf8 works, there cannot be branching nodes with
* NEXTBYTE set, and moreover those nodes always have a righthand
* descendant.
*/
typedef unsigned char utf8trie_t;
#define BITNUM 0x07
#define NEXTBYTE 0x08
#define OFFLEN 0x30
#define OFFLEN_SHIFT 4
#define RIGHTPATH 0x40
#define TRIENODE 0x80
#define RIGHTNODE 0x40
#define LEFTNODE 0x80
/*
* utf8leaf_t
*
* The leaves of the trie are embedded in the trie, and so the same
* underlying datatype, unsigned char.
*
* leaf[0]: The unicode version, stored as a generation number that is
* an index into utf8agetab[]. With this we can filter code
* points based on the unicode version in which they were
* defined. The CCC of a non-defined code point is 0.
* leaf[1]: Canonical Combining Class. During normalization, we need
* to do a stable sort into ascending order of all characters
* with a non-zero CCC that occur between two characters with
* a CCC of 0, or at the begin or end of a string.
* The unicode standard guarantees that all CCC values are
* between 0 and 254 inclusive, which leaves 255 available as
* a special value.
* Code points with CCC 0 are known as stoppers.
* leaf[2]: Decomposition. If leaf[1] == 255, then leaf[2] is the
* start of a NUL-terminated string that is the decomposition
* of the character.
* The CCC of a decomposable character is the same as the CCC
* of the first character of its decomposition.
* Some characters decompose as the empty string: these are
* characters with the Default_Ignorable_Code_Point property.
* These do affect normalization, as they all have CCC 0.
*
* The decompositions in the trie have been fully expanded.
*
* Casefolding, if applicable, is also done using decompositions.
*/
typedef unsigned char utf8leaf_t;
#define LEAF_GEN(LEAF) ((LEAF)[0])
#define LEAF_CCC(LEAF) ((LEAF)[1])
#define LEAF_STR(LEAF) ((const char*)((LEAF) + 2))
#define MAXGEN (255)
#define MINCCC (0)
#define MAXCCC (254)
#define STOPPER (0)
#define DECOMPOSE (255)
#define HANGUL ((char)(255))
#define UTF8HANGULLEAF (12)
struct tree;
static utf8leaf_t *utf8nlookup(struct tree *, unsigned char *,
const char *, size_t);
static utf8leaf_t *utf8lookup(struct tree *, unsigned char *, const char *);
unsigned char *utf8data;
size_t utf8data_size;
utf8trie_t *nfkdi;
utf8trie_t *nfkdicf;
/* ------------------------------------------------------------------ */
/*
* UTF8 valid ranges.
*
* The UTF-8 encoding spreads the bits of a 32bit word over several
* bytes. This table gives the ranges that can be held and how they'd
* be represented.
*
* 0x00000000 0x0000007F: 0xxxxxxx
* 0x00000000 0x000007FF: 110xxxxx 10xxxxxx
* 0x00000000 0x0000FFFF: 1110xxxx 10xxxxxx 10xxxxxx
* 0x00000000 0x001FFFFF: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
* 0x00000000 0x03FFFFFF: 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
* 0x00000000 0x7FFFFFFF: 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
*
* There is an additional requirement on UTF-8, in that only the
* shortest representation of a 32bit value is to be used. A decoder
* must not decode sequences that do not satisfy this requirement.
* Thus the allowed ranges have a lower bound.
*
* 0x00000000 0x0000007F: 0xxxxxxx
* 0x00000080 0x000007FF: 110xxxxx 10xxxxxx
* 0x00000800 0x0000FFFF: 1110xxxx 10xxxxxx 10xxxxxx
* 0x00010000 0x001FFFFF: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
* 0x00200000 0x03FFFFFF: 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
* 0x04000000 0x7FFFFFFF: 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
*
* Actual unicode characters are limited to the range 0x0 - 0x10FFFF,
* 17 planes of 65536 values. This limits the sequences actually seen
* even more, to just the following.
*
* 0 - 0x7f: 0 0x7f
* 0x80 - 0x7ff: 0xc2 0x80 0xdf 0xbf
* 0x800 - 0xffff: 0xe0 0xa0 0x80 0xef 0xbf 0xbf
* 0x10000 - 0x10ffff: 0xf0 0x90 0x80 0x80 0xf4 0x8f 0xbf 0xbf
*
* Even within those ranges not all values are allowed: the surrogates
* 0xd800 - 0xdfff should never be seen.
*
* Note that the longest sequence seen with valid usage is 4 bytes,
* the same a single UTF-32 character. This makes the UTF-8
* representation of Unicode strictly smaller than UTF-32.
*
* The shortest sequence requirement was introduced by:
* Corrigendum #1: UTF-8 Shortest Form
* It can be found here:
* http://www.unicode.org/versions/corrigendum1.html
*
*/
#define UTF8_2_BITS 0xC0
#define UTF8_3_BITS 0xE0
#define UTF8_4_BITS 0xF0
#define UTF8_N_BITS 0x80
#define UTF8_2_MASK 0xE0
#define UTF8_3_MASK 0xF0
#define UTF8_4_MASK 0xF8
#define UTF8_N_MASK 0xC0
#define UTF8_V_MASK 0x3F
#define UTF8_V_SHIFT 6
static int utf8encode(char *str, unsigned int val)
{
int len;
if (val < 0x80) {
str[0] = val;
len = 1;
} else if (val < 0x800) {
str[1] = val & UTF8_V_MASK;
str[1] |= UTF8_N_BITS;
val >>= UTF8_V_SHIFT;
str[0] = val;
str[0] |= UTF8_2_BITS;
len = 2;
} else if (val < 0x10000) {
str[2] = val & UTF8_V_MASK;
str[2] |= UTF8_N_BITS;
val >>= UTF8_V_SHIFT;
str[1] = val & UTF8_V_MASK;
str[1] |= UTF8_N_BITS;
val >>= UTF8_V_SHIFT;
str[0] = val;
str[0] |= UTF8_3_BITS;
len = 3;
} else if (val < 0x110000) {
str[3] = val & UTF8_V_MASK;
str[3] |= UTF8_N_BITS;
val >>= UTF8_V_SHIFT;
str[2] = val & UTF8_V_MASK;
str[2] |= UTF8_N_BITS;
val >>= UTF8_V_SHIFT;
str[1] = val & UTF8_V_MASK;
str[1] |= UTF8_N_BITS;
val >>= UTF8_V_SHIFT;
str[0] = val;
str[0] |= UTF8_4_BITS;
len = 4;
} else {
printf("%#x: illegal val\n", val);
len = 0;
}
return len;
}
static unsigned int utf8decode(const char *str)
{
const unsigned char *s = (const unsigned char*)str;
unsigned int unichar = 0;
if (*s < 0x80) {
unichar = *s;
} else if (*s < UTF8_3_BITS) {
unichar = *s++ & 0x1F;
unichar <<= UTF8_V_SHIFT;
unichar |= *s & 0x3F;
} else if (*s < UTF8_4_BITS) {
unichar = *s++ & 0x0F;
unichar <<= UTF8_V_SHIFT;
unichar |= *s++ & 0x3F;
unichar <<= UTF8_V_SHIFT;
unichar |= *s & 0x3F;
} else {
unichar = *s++ & 0x0F;
unichar <<= UTF8_V_SHIFT;
unichar |= *s++ & 0x3F;
unichar <<= UTF8_V_SHIFT;
unichar |= *s++ & 0x3F;
unichar <<= UTF8_V_SHIFT;
unichar |= *s & 0x3F;
}
return unichar;
}
static int utf32valid(unsigned int unichar)
{
return unichar < 0x110000;
}
#define HANGUL_SYLLABLE(U) ((U) >= 0xAC00 && (U) <= 0xD7A3)
#define NODE 1
#define LEAF 0
struct tree {
void *root;
int childnode;
const char *type;
unsigned int maxage;
struct tree *next;
int (*leaf_equal)(void *, void *);
void (*leaf_print)(void *, int);
int (*leaf_mark)(void *);
int (*leaf_size)(void *);
int *(*leaf_index)(struct tree *, void *);
unsigned char *(*leaf_emit)(void *, unsigned char *);
int leafindex[0x110000];
int index;
};
struct node {
int index;
int offset;
int mark;
int size;
struct node *parent;
void *left;
void *right;
unsigned char bitnum;
unsigned char nextbyte;
unsigned char leftnode;
unsigned char rightnode;
unsigned int keybits;
unsigned int keymask;
};
/*
* Example lookup function for a tree.
*/
static void *lookup(struct tree *tree, const char *key)
{
struct node *node;
void *leaf = NULL;
node = tree->root;
while (!leaf && node) {
if (node->nextbyte)
key++;
if (*key & (1 << (node->bitnum & 7))) {
/* Right leg */
if (node->rightnode == NODE) {
node = node->right;
} else if (node->rightnode == LEAF) {
leaf = node->right;
} else {
node = NULL;
}
} else {
/* Left leg */
if (node->leftnode == NODE) {
node = node->left;
} else if (node->leftnode == LEAF) {
leaf = node->left;
} else {
node = NULL;
}
}
}
return leaf;
}
/*
* A simple non-recursive tree walker: keep track of visits to the
* left and right branches in the leftmask and rightmask.
*/
static void tree_walk(struct tree *tree)
{
struct node *node;
unsigned int leftmask;
unsigned int rightmask;
unsigned int bitmask;
int indent = 1;
int nodes, singletons, leaves;
nodes = singletons = leaves = 0;
printf("%s_%x root %p\n", tree->type, tree->maxage, tree->root);
if (tree->childnode == LEAF) {
assert(tree->root);
tree->leaf_print(tree->root, indent);
leaves = 1;
} else {
assert(tree->childnode == NODE);
node = tree->root;
leftmask = rightmask = 0;
while (node) {
printf("%*snode @ %p bitnum %d nextbyte %d"
" left %p right %p mask %x bits %x\n",
indent, "", node,
node->bitnum, node->nextbyte,
node->left, node->right,
node->keymask, node->keybits);
nodes += 1;
if (!(node->left && node->right))
singletons += 1;
while (node) {
bitmask = 1 << node->bitnum;
if ((leftmask & bitmask) == 0) {
leftmask |= bitmask;
if (node->leftnode == LEAF) {
assert(node->left);
tree->leaf_print(node->left,
indent+1);
leaves += 1;
} else if (node->left) {
assert(node->leftnode == NODE);
indent += 1;
node = node->left;
break;
}
}
if ((rightmask & bitmask) == 0) {
rightmask |= bitmask;
if (node->rightnode == LEAF) {
assert(node->right);
tree->leaf_print(node->right,
indent+1);
leaves += 1;
} else if (node->right) {
assert(node->rightnode == NODE);
indent += 1;
node = node->right;
break;
}
}
leftmask &= ~bitmask;
rightmask &= ~bitmask;
node = node->parent;
indent -= 1;
}
}
}
printf("nodes %d leaves %d singletons %d\n",
nodes, leaves, singletons);
}
/*
* Allocate an initialize a new internal node.
*/
static struct node *alloc_node(struct node *parent)
{
struct node *node;
int bitnum;
node = malloc(sizeof(*node));
node->left = node->right = NULL;
node->parent = parent;
node->leftnode = NODE;
node->rightnode = NODE;
node->keybits = 0;
node->keymask = 0;
node->mark = 0;
node->index = 0;
node->offset = -1;
node->size = 4;
if (node->parent) {
bitnum = parent->bitnum;
if ((bitnum & 7) == 0) {
node->bitnum = bitnum + 7 + 8;
node->nextbyte = 1;
} else {
node->bitnum = bitnum - 1;
node->nextbyte = 0;
}
} else {
node->bitnum = 7;
node->nextbyte = 0;
}
return node;
}
/*
* Insert a new leaf into the tree, and collapse any subtrees that are
* fully populated and end in identical leaves. A nextbyte tagged
* internal node will not be removed to preserve the tree's integrity.
* Note that due to the structure of utf8, no nextbyte tagged node
* will be a candidate for removal.
*/
static int insert(struct tree *tree, char *key, int keylen, void *leaf)
{
struct node *node;
struct node *parent;
void **cursor;
int keybits;
assert(keylen >= 1 && keylen <= 4);
node = NULL;
cursor = &tree->root;
keybits = 8 * keylen;
/* Insert, creating path along the way. */
while (keybits) {
if (!*cursor)
*cursor = alloc_node(node);
node = *cursor;
if (node->nextbyte)
key++;
if (*key & (1 << (node->bitnum & 7)))
cursor = &node->right;
else
cursor = &node->left;
keybits--;
}
*cursor = leaf;
/* Merge subtrees if possible. */
while (node) {
if (*key & (1 << (node->bitnum & 7)))
node->rightnode = LEAF;
else
node->leftnode = LEAF;
if (node->nextbyte)
break;
if (node->leftnode == NODE || node->rightnode == NODE)
break;
assert(node->left);
assert(node->right);
/* Compare */
if (! tree->leaf_equal(node->left, node->right))
break;
/* Keep left, drop right leaf. */
leaf = node->left;
/* Check in parent */
parent = node->parent;
if (!parent) {
/* root of tree! */
tree->root = leaf;
tree->childnode = LEAF;
} else if (parent->left == node) {
parent->left = leaf;
parent->leftnode = LEAF;
if (parent->right) {
parent->keymask = 0;
parent->keybits = 0;
} else {
parent->keymask |= (1 << node->bitnum);
}
} else if (parent->right == node) {
parent->right = leaf;
parent->rightnode = LEAF;
if (parent->left) {
parent->keymask = 0;
parent->keybits = 0;
} else {
parent->keymask |= (1 << node->bitnum);
parent->keybits |= (1 << node->bitnum);
}
} else {
/* internal tree error */
assert(0);
}
free(node);
node = parent;
}
/* Propagate keymasks up along singleton chains. */
while (node) {
parent = node->parent;
if (!parent)
break;
/* Nix the mask for parents with two children. */
if (node->keymask == 0) {
parent->keymask = 0;
parent->keybits = 0;
} else if (parent->left && parent->right) {
parent->keymask = 0;
parent->keybits = 0;
} else {
assert((parent->keymask & node->keymask) == 0);
parent->keymask |= node->keymask;
parent->keymask |= (1 << parent->bitnum);
parent->keybits |= node->keybits;
if (parent->right)
parent->keybits |= (1 << parent->bitnum);
}
node = parent;
}
return 0;
}
/*
* Prune internal nodes.
*
* Fully populated subtrees that end at the same leaf have already
* been collapsed. There are still internal nodes that have for both
* their left and right branches a sequence of singletons that make
* identical choices and end in identical leaves. The keymask and
* keybits collected in the nodes describe the choices made in these
* singleton chains. When they are identical for the left and right
* branch of a node, and the two leaves comare identical, the node in
* question can be removed.
*
* Note that nodes with the nextbyte tag set will not be removed by
* this to ensure tree integrity. Note as well that the structure of
* utf8 ensures that these nodes would not have been candidates for
* removal in any case.
*/
static void prune(struct tree *tree)
{
struct node *node;
struct node *left;
struct node *right;
struct node *parent;
void *leftleaf;
void *rightleaf;
unsigned int leftmask;
unsigned int rightmask;
unsigned int bitmask;
int count;
if (verbose > 0)
printf("Pruning %s_%x\n", tree->type, tree->maxage);
count = 0;
if (tree->childnode == LEAF)
return;
if (!tree->root)
return;
leftmask = rightmask = 0;
node = tree->root;
while (node) {
if (node->nextbyte)
goto advance;
if (node->leftnode == LEAF)
goto advance;
if (node->rightnode == LEAF)
goto advance;
if (!node->left)
goto advance;
if (!node->right)
goto advance;
left = node->left;
right = node->right;
if (left->keymask == 0)
goto advance;
if (right->keymask == 0)
goto advance;
if (left->keymask != right->keymask)
goto advance;
if (left->keybits != right->keybits)
goto advance;
leftleaf = NULL;
while (!leftleaf) {
assert(left->left || left->right);
if (left->leftnode == LEAF)
leftleaf = left->left;
else if (left->rightnode == LEAF)
leftleaf = left->right;
else if (left->left)
left = left->left;
else if (left->right)
left = left->right;
else
assert(0);
}
rightleaf = NULL;
while (!rightleaf) {
assert(right->left || right->right);
if (right->leftnode == LEAF)
rightleaf = right->left;
else if (right->rightnode == LEAF)
rightleaf = right->right;
else if (right->left)
right = right->left;
else if (right->right)
right = right->right;
else
assert(0);
}
if (! tree->leaf_equal(leftleaf, rightleaf))
goto advance;
/*
* This node has identical singleton-only subtrees.
* Remove it.
*/
parent = node->parent;
left = node->left;
right = node->right;
if (parent->left == node)
parent->left = left;
else if (parent->right == node)
parent->right = left;
else
assert(0);
left->parent = parent;
left->keymask |= (1 << node->bitnum);
node->left = NULL;
while (node) {
bitmask = 1 << node->bitnum;
leftmask &= ~bitmask;
rightmask &= ~bitmask;
if (node->leftnode == NODE && node->left) {
left = node->left;
free(node);
count++;
node = left;
} else if (node->rightnode == NODE && node->right) {
right = node->right;
free(node);
count++;
node = right;
} else {
node = NULL;
}
}
/* Propagate keymasks up along singleton chains. */
node = parent;
/* Force re-check */
bitmask = 1 << node->bitnum;
leftmask &= ~bitmask;
rightmask &= ~bitmask;
for (;;) {
if (node->left && node->right)
break;
if (node->left) {
left = node->left;
node->keymask |= left->keymask;
node->keybits |= left->keybits;
}
if (node->right) {
right = node->right;
node->keymask |= right->keymask;
node->keybits |= right->keybits;
}
node->keymask |= (1 << node->bitnum);
node = node->parent;
/* Force re-check */
bitmask = 1 << node->bitnum;
leftmask &= ~bitmask;
rightmask &= ~bitmask;
}
advance:
bitmask = 1 << node->bitnum;
if ((leftmask & bitmask) == 0 &&
node->leftnode == NODE &&
node->left) {
leftmask |= bitmask;
node = node->left;
} else if ((rightmask & bitmask) == 0 &&
node->rightnode == NODE &&
node->right) {
rightmask |= bitmask;
node = node->right;
} else {
leftmask &= ~bitmask;
rightmask &= ~bitmask;
node = node->parent;
}
}
if (verbose > 0)
printf("Pruned %d nodes\n", count);
}
/*
* Mark the nodes in the tree that lead to leaves that must be
* emitted.
*/
static void mark_nodes(struct tree *tree)
{
struct node *node;
struct node *n;
unsigned int leftmask;
unsigned int rightmask;
unsigned int bitmask;
int marked;
marked = 0;
if (verbose > 0)
printf("Marking %s_%x\n", tree->type, tree->maxage);
if (tree->childnode == LEAF)
goto done;
assert(tree->childnode == NODE);
node = tree->root;
leftmask = rightmask = 0;
while (node) {
bitmask = 1 << node->bitnum;
if ((leftmask & bitmask) == 0) {
leftmask |= bitmask;
if (node->leftnode == LEAF) {
assert(node->left);
if (tree->leaf_mark(node->left)) {
n = node;
while (n && !n->mark) {
marked++;
n->mark = 1;
n = n->parent;
}
}
} else if (node->left) {
assert(node->leftnode == NODE);
node = node->left;
continue;
}
}
if ((rightmask & bitmask) == 0) {
rightmask |= bitmask;
if (node->rightnode == LEAF) {
assert(node->right);
if (tree->leaf_mark(node->right)) {
n = node;
while (n && !n->mark) {
marked++;
n->mark = 1;
n = n->parent;
}
}
} else if (node->right) {
assert(node->rightnode == NODE);
node = node->right;
continue;
}
}
leftmask &= ~bitmask;
rightmask &= ~bitmask;
node = node->parent;
}
/* second pass: left siblings and singletons */
assert(tree->childnode == NODE);
node = tree->root;
leftmask = rightmask = 0;
while (node) {
bitmask = 1 << node->bitnum;
if ((leftmask & bitmask) == 0) {
leftmask |= bitmask;
if (node->leftnode == LEAF) {
assert(node->left);
if (tree->leaf_mark(node->left)) {
n = node;
while (n && !n->mark) {
marked++;
n->mark = 1;
n = n->parent;
}
}
} else if (node->left) {
assert(node->leftnode == NODE);
node = node->left;
if (!node->mark && node->parent->mark) {
marked++;
node->mark = 1;
}
continue;
}
}
if ((rightmask & bitmask) == 0) {
rightmask |= bitmask;
if (node->rightnode == LEAF) {
assert(node->right);
if (tree->leaf_mark(node->right)) {
n = node;
while (n && !n->mark) {
marked++;
n->mark = 1;
n = n->parent;
}
}
} else if (node->right) {
assert(node->rightnode == NODE);
node = node->right;
if (!node->mark && node->parent->mark &&
!node->parent->left) {
marked++;
node->mark = 1;
}
continue;
}
}
leftmask &= ~bitmask;
rightmask &= ~bitmask;
node = node->parent;
}
done:
if (verbose > 0)
printf("Marked %d nodes\n", marked);
}
/*
* Compute the index of each node and leaf, which is the offset in the
* emitted trie. These values must be pre-computed because relative
* offsets between nodes are used to navigate the tree.
*/
static int index_nodes(struct tree *tree, int index)
{
struct node *node;
unsigned int leftmask;
unsigned int rightmask;
unsigned int bitmask;
int count;
int indent;
/* Align to a cache line (or half a cache line?). */
while (index % 64)
index++;
tree->index = index;
indent = 1;
count = 0;
if (verbose > 0)
printf("Indexing %s_%x: %d\n", tree->type, tree->maxage, index);
if (tree->childnode == LEAF) {
index += tree->leaf_size(tree->root);
goto done;
}
assert(tree->childnode == NODE);
node = tree->root;
leftmask = rightmask = 0;
while (node) {
if (!node->mark)
goto skip;
count++;
if (node->index != index)
node->index = index;
index += node->size;
skip:
while (node) {
bitmask = 1 << node->bitnum;
if (node->mark && (leftmask & bitmask) == 0) {
leftmask |= bitmask;
if (node->leftnode == LEAF) {
assert(node->left);
*tree->leaf_index(tree, node->left) =
index;
index += tree->leaf_size(node->left);
count++;
} else if (node->left) {
assert(node->leftnode == NODE);
indent += 1;
node = node->left;
break;
}
}
if (node->mark && (rightmask & bitmask) == 0) {
rightmask |= bitmask;
if (node->rightnode == LEAF) {
assert(node->right);
*tree->leaf_index(tree, node->right) = index;
index += tree->leaf_size(node->right);
count++;
} else if (node->right) {
assert(node->rightnode == NODE);
indent += 1;
node = node->right;
break;
}
}
leftmask &= ~bitmask;
rightmask &= ~bitmask;
node = node->parent;
indent -= 1;
}
}
done:
/* Round up to a multiple of 16 */
while (index % 16)
index++;
if (verbose > 0)
printf("Final index %d\n", index);
return index;
}
/*
* Mark the nodes in a subtree, helper for size_nodes().
*/
static int mark_subtree(struct node *node)
{
int changed;
if (!node || node->mark)
return 0;
node->mark = 1;
node->index = node->parent->index;
changed = 1;
if (node->leftnode == NODE)
changed += mark_subtree(node->left);
if (node->rightnode == NODE)
changed += mark_subtree(node->right);
return changed;
}
/*
* Compute the size of nodes and leaves. We start by assuming that
* each node needs to store a three-byte offset. The indexes of the
* nodes are calculated based on that, and then this function is
* called to see if the sizes of some nodes can be reduced. This is
* repeated until no more changes are seen.
*/
static int size_nodes(struct tree *tree)
{
struct tree *next;
struct node *node;
struct node *right;
struct node *n;
unsigned int leftmask;
unsigned int rightmask;
unsigned int bitmask;
unsigned int pathbits;
unsigned int pathmask;
unsigned int nbit;
int changed;
int offset;
int size;
int indent;
indent = 1;
changed = 0;
size = 0;
if (verbose > 0)
printf("Sizing %s_%x\n", tree->type, tree->maxage);
if (tree->childnode == LEAF)
goto done;
assert(tree->childnode == NODE);
pathbits = 0;
pathmask = 0;
node = tree->root;
leftmask = rightmask = 0;
while (node) {
if (!node->mark)
goto skip;
offset = 0;
if (!node->left || !node->right) {
size = 1;
} else {
if (node->rightnode == NODE) {
/*
* If the right node is not marked,
* look for a corresponding node in
* the next tree. Such a node need
* not exist.
*/
right = node->right;
next = tree->next;
while (!right->mark) {
assert(next);
n = next->root;
while (n->bitnum != node->bitnum) {
nbit = 1 << n->bitnum;
if (!(pathmask & nbit))
break;
if (pathbits & nbit) {
if (n->rightnode == LEAF)
break;
n = n->right;
} else {
if (n->leftnode == LEAF)
break;
n = n->left;
}
}
if (n->bitnum != node->bitnum)
break;
n = n->right;
right = n;
next = next->next;
}
/* Make sure the right node is marked. */
if (!right->mark)
changed += mark_subtree(right);
offset = right->index - node->index;
} else {
offset = *tree->leaf_index(tree, node->right);
offset -= node->index;
}
assert(offset >= 0);
assert(offset <= 0xffffff);
if (offset <= 0xff) {
size = 2;
} else if (offset <= 0xffff) {
size = 3;
} else { /* offset <= 0xffffff */
size = 4;
}
}
if (node->size != size || node->offset != offset) {
node->size = size;
node->offset = offset;
changed++;
}
skip:
while (node) {
bitmask = 1 << node->bitnum;
pathmask |= bitmask;
if (node->mark && (leftmask & bitmask) == 0) {
leftmask |= bitmask;
if (node->leftnode == LEAF) {
assert(node->left);
} else if (node->left) {
assert(node->leftnode == NODE);
indent += 1;
node = node->left;
break;
}
}
if (node->mark && (rightmask & bitmask) == 0) {
rightmask |= bitmask;
pathbits |= bitmask;
if (node->rightnode == LEAF) {
assert(node->right);
} else if (node->right) {
assert(node->rightnode == NODE);
indent += 1;
node = node->right;
break;
}
}
leftmask &= ~bitmask;
rightmask &= ~bitmask;
pathmask &= ~bitmask;
pathbits &= ~bitmask;
node = node->parent;
indent -= 1;
}
}
done:
if (verbose > 0)
printf("Found %d changes\n", changed);
return changed;
}
/*
* Emit a trie for the given tree into the data array.
*/
static void emit(struct tree *tree, unsigned char *data)
{
struct node *node;
unsigned int leftmask;
unsigned int rightmask;
unsigned int bitmask;
int offlen;
int offset;
int index;
int indent;
int size;
int bytes;
int leaves;
int nodes[4];
unsigned char byte;
nodes[0] = nodes[1] = nodes[2] = nodes[3] = 0;
leaves = 0;
bytes = 0;
index = tree->index;
data += index;
indent = 1;
if (verbose > 0)
printf("Emitting %s_%x\n", tree->type, tree->maxage);
if (tree->childnode == LEAF) {
assert(tree->root);
tree->leaf_emit(tree->root, data);
size = tree->leaf_size(tree->root);
index += size;
leaves++;
goto done;
}
assert(tree->childnode == NODE);
node = tree->root;
leftmask = rightmask = 0;
while (node) {
if (!node->mark)
goto skip;
assert(node->offset != -1);
assert(node->index == index);
byte = 0;
if (node->nextbyte)
byte |= NEXTBYTE;
byte |= (node->bitnum & BITNUM);
if (node->left && node->right) {
if (node->leftnode == NODE)
byte |= LEFTNODE;
if (node->rightnode == NODE)
byte |= RIGHTNODE;
if (node->offset <= 0xff)
offlen = 1;
else if (node->offset <= 0xffff)
offlen = 2;
else
offlen = 3;
nodes[offlen]++;
offset = node->offset;
byte |= offlen << OFFLEN_SHIFT;
*data++ = byte;
index++;
while (offlen--) {
*data++ = offset & 0xff;
index++;
offset >>= 8;
}
} else if (node->left) {
if (node->leftnode == NODE)
byte |= TRIENODE;
nodes[0]++;
*data++ = byte;
index++;
} else if (node->right) {
byte |= RIGHTNODE;
if (node->rightnode == NODE)
byte |= TRIENODE;
nodes[0]++;
*data++ = byte;
index++;
} else {
assert(0);
}
skip:
while (node) {
bitmask = 1 << node->bitnum;
if (node->mark && (leftmask & bitmask) == 0) {
leftmask |= bitmask;
if (node->leftnode == LEAF) {
assert(node->left);
data = tree->leaf_emit(node->left,
data);
size = tree->leaf_size(node->left);
index += size;
bytes += size;
leaves++;
} else if (node->left) {
assert(node->leftnode == NODE);
indent += 1;
node = node->left;
break;
}
}
if (node->mark && (rightmask & bitmask) == 0) {
rightmask |= bitmask;
if (node->rightnode == LEAF) {
assert(node->right);
data = tree->leaf_emit(node->right,
data);
size = tree->leaf_size(node->right);
index += size;
bytes += size;
leaves++;
} else if (node->right) {
assert(node->rightnode == NODE);
indent += 1;
node = node->right;
break;
}
}
leftmask &= ~bitmask;
rightmask &= ~bitmask;
node = node->parent;
indent -= 1;
}
}
done:
if (verbose > 0) {
printf("Emitted %d (%d) leaves",
leaves, bytes);
printf(" %d (%d+%d+%d+%d) nodes",
nodes[0] + nodes[1] + nodes[2] + nodes[3],
nodes[0], nodes[1], nodes[2], nodes[3]);
printf(" %d total\n", index - tree->index);
}
}
/* ------------------------------------------------------------------ */
/*
* Unicode data.
*
* We need to keep track of the Canonical Combining Class, the Age,
* and decompositions for a code point.
*
* For the Age, we store the index into the ages table. Effectively
* this is a generation number that the table maps to a unicode
* version.
*
* The correction field is used to indicate that this entry is in the
* corrections array, which contains decompositions that were
* corrected in later revisions. The value of the correction field is
* the Unicode version in which the mapping was corrected.
*/
struct unicode_data {
unsigned int code;
int ccc;
int gen;
int correction;
unsigned int *utf32nfkdi;
unsigned int *utf32nfkdicf;
char *utf8nfkdi;
char *utf8nfkdicf;
};
struct unicode_data unicode_data[0x110000];
struct unicode_data *corrections;
int corrections_count;
struct tree *nfkdi_tree;
struct tree *nfkdicf_tree;
struct tree *trees;
int trees_count;
/*
* Check the corrections array to see if this entry was corrected at
* some point.
*/
static struct unicode_data *corrections_lookup(struct unicode_data *u)
{
int i;
for (i = 0; i != corrections_count; i++)
if (u->code == corrections[i].code)
return &corrections[i];
return u;
}
static int nfkdi_equal(void *l, void *r)
{
struct unicode_data *left = l;
struct unicode_data *right = r;
if (left->gen != right->gen)
return 0;
if (left->ccc != right->ccc)
return 0;
if (left->utf8nfkdi && right->utf8nfkdi &&
strcmp(left->utf8nfkdi, right->utf8nfkdi) == 0)
return 1;
if (left->utf8nfkdi || right->utf8nfkdi)
return 0;
return 1;
}
static int nfkdicf_equal(void *l, void *r)
{
struct unicode_data *left = l;
struct unicode_data *right = r;
if (left->gen != right->gen)
return 0;
if (left->ccc != right->ccc)
return 0;
if (left->utf8nfkdicf && right->utf8nfkdicf &&
strcmp(left->utf8nfkdicf, right->utf8nfkdicf) == 0)
return 1;
if (left->utf8nfkdicf && right->utf8nfkdicf)
return 0;
if (left->utf8nfkdicf || right->utf8nfkdicf)
return 0;
if (left->utf8nfkdi && right->utf8nfkdi &&
strcmp(left->utf8nfkdi, right->utf8nfkdi) == 0)
return 1;
if (left->utf8nfkdi || right->utf8nfkdi)
return 0;
return 1;
}
static void nfkdi_print(void *l, int indent)
{
struct unicode_data *leaf = l;
printf("%*sleaf @ %p code %X ccc %d gen %d", indent, "", leaf,
leaf->code, leaf->ccc, leaf->gen);
if (leaf->utf8nfkdi && leaf->utf8nfkdi[0] == HANGUL)
printf(" nfkdi \"%s\"", "HANGUL SYLLABLE");
else if (leaf->utf8nfkdi)
printf(" nfkdi \"%s\"", (const char*)leaf->utf8nfkdi);
printf("\n");
}
static void nfkdicf_print(void *l, int indent)
{
struct unicode_data *leaf = l;
printf("%*sleaf @ %p code %X ccc %d gen %d", indent, "", leaf,
leaf->code, leaf->ccc, leaf->gen);
if (leaf->utf8nfkdicf)
printf(" nfkdicf \"%s\"", (const char*)leaf->utf8nfkdicf);
else if (leaf->utf8nfkdi && leaf->utf8nfkdi[0] == HANGUL)
printf(" nfkdi \"%s\"", "HANGUL SYLLABLE");
else if (leaf->utf8nfkdi)
printf(" nfkdi \"%s\"", (const char*)leaf->utf8nfkdi);
printf("\n");
}
static int nfkdi_mark(void *l)
{
return 1;
}
static int nfkdicf_mark(void *l)
{
struct unicode_data *leaf = l;
if (leaf->utf8nfkdicf)
return 1;
return 0;
}
static int correction_mark(void *l)
{
struct unicode_data *leaf = l;
return leaf->correction;
}
static int nfkdi_size(void *l)
{
struct unicode_data *leaf = l;
int size = 2;
if (HANGUL_SYLLABLE(leaf->code))
size += 1;
else if (leaf->utf8nfkdi)
size += strlen(leaf->utf8nfkdi) + 1;
return size;
}
static int nfkdicf_size(void *l)
{
struct unicode_data *leaf = l;
int size = 2;
if (HANGUL_SYLLABLE(leaf->code))
size += 1;
else if (leaf->utf8nfkdicf)
size += strlen(leaf->utf8nfkdicf) + 1;
else if (leaf->utf8nfkdi)
size += strlen(leaf->utf8nfkdi) + 1;
return size;
}
static int *nfkdi_index(struct tree *tree, void *l)
{
struct unicode_data *leaf = l;
return &tree->leafindex[leaf->code];
}
static int *nfkdicf_index(struct tree *tree, void *l)
{
struct unicode_data *leaf = l;
return &tree->leafindex[leaf->code];
}
static unsigned char *nfkdi_emit(void *l, unsigned char *data)
{
struct unicode_data *leaf = l;
unsigned char *s;
*data++ = leaf->gen;
if (HANGUL_SYLLABLE(leaf->code)) {
*data++ = DECOMPOSE;
*data++ = HANGUL;
} else if (leaf->utf8nfkdi) {
*data++ = DECOMPOSE;
s = (unsigned char*)leaf->utf8nfkdi;
while ((*data++ = *s++) != 0)
;
} else {
*data++ = leaf->ccc;
}
return data;
}
static unsigned char *nfkdicf_emit(void *l, unsigned char *data)
{
struct unicode_data *leaf = l;
unsigned char *s;
*data++ = leaf->gen;
if (HANGUL_SYLLABLE(leaf->code)) {
*data++ = DECOMPOSE;
*data++ = HANGUL;
} else if (leaf->utf8nfkdicf) {
*data++ = DECOMPOSE;
s = (unsigned char*)leaf->utf8nfkdicf;
while ((*data++ = *s++) != 0)
;
} else if (leaf->utf8nfkdi) {
*data++ = DECOMPOSE;
s = (unsigned char*)leaf->utf8nfkdi;
while ((*data++ = *s++) != 0)
;
} else {
*data++ = leaf->ccc;
}
return data;
}
static void utf8_create(struct unicode_data *data)
{
char utf[18*4+1];
char *u;
unsigned int *um;
int i;
if (data->utf8nfkdi) {
assert(data->utf8nfkdi[0] == HANGUL);
return;
}
u = utf;
um = data->utf32nfkdi;
if (um) {
for (i = 0; um[i]; i++)
u += utf8encode(u, um[i]);
*u = '\0';
data->utf8nfkdi = strdup(utf);
}
u = utf;
um = data->utf32nfkdicf;
if (um) {
for (i = 0; um[i]; i++)
u += utf8encode(u, um[i]);
*u = '\0';
if (!data->utf8nfkdi || strcmp(data->utf8nfkdi, utf))
data->utf8nfkdicf = strdup(utf);
}
}
static void utf8_init(void)
{
unsigned int unichar;
int i;
for (unichar = 0; unichar != 0x110000; unichar++)
utf8_create(&unicode_data[unichar]);
for (i = 0; i != corrections_count; i++)
utf8_create(&corrections[i]);
}
static void trees_init(void)
{
struct unicode_data *data;
unsigned int maxage;
unsigned int nextage;
int count;
int i;
int j;
/* Count the number of different ages. */
count = 0;
nextage = (unsigned int)-1;
do {
maxage = nextage;
nextage = 0;
for (i = 0; i <= corrections_count; i++) {
data = &corrections[i];
if (nextage < data->correction &&
data->correction < maxage)
nextage = data->correction;
}
count++;
} while (nextage);
/* Two trees per age: nfkdi and nfkdicf */
trees_count = count * 2;
trees = calloc(trees_count, sizeof(struct tree));
/* Assign ages to the trees. */
count = trees_count;
nextage = (unsigned int)-1;
do {
maxage = nextage;
trees[--count].maxage = maxage;
trees[--count].maxage = maxage;
nextage = 0;
for (i = 0; i <= corrections_count; i++) {
data = &corrections[i];
if (nextage < data->correction &&
data->correction < maxage)
nextage = data->correction;
}
} while (nextage);
/* The ages assigned above are off by one. */
for (i = 0; i != trees_count; i++) {
j = 0;
while (ages[j] < trees[i].maxage)
j++;
trees[i].maxage = ages[j-1];
}
/* Set up the forwarding between trees. */
trees[trees_count-2].next = &trees[trees_count-1];
trees[trees_count-1].leaf_mark = nfkdi_mark;
trees[trees_count-2].leaf_mark = nfkdicf_mark;
for (i = 0; i != trees_count-2; i += 2) {
trees[i].next = &trees[trees_count-2];
trees[i].leaf_mark = correction_mark;
trees[i+1].next = &trees[trees_count-1];
trees[i+1].leaf_mark = correction_mark;
}
/* Assign the callouts. */
for (i = 0; i != trees_count; i += 2) {
trees[i].type = "nfkdicf";
trees[i].leaf_equal = nfkdicf_equal;
trees[i].leaf_print = nfkdicf_print;
trees[i].leaf_size = nfkdicf_size;
trees[i].leaf_index = nfkdicf_index;
trees[i].leaf_emit = nfkdicf_emit;
trees[i+1].type = "nfkdi";
trees[i+1].leaf_equal = nfkdi_equal;
trees[i+1].leaf_print = nfkdi_print;
trees[i+1].leaf_size = nfkdi_size;
trees[i+1].leaf_index = nfkdi_index;
trees[i+1].leaf_emit = nfkdi_emit;
}
/* Finish init. */
for (i = 0; i != trees_count; i++)
trees[i].childnode = NODE;
}
static void trees_populate(void)
{
struct unicode_data *data;
unsigned int unichar;
char keyval[4];
int keylen;
int i;
for (i = 0; i != trees_count; i++) {
if (verbose > 0) {
printf("Populating %s_%x\n",
trees[i].type, trees[i].maxage);
}
for (unichar = 0; unichar != 0x110000; unichar++) {
if (unicode_data[unichar].gen < 0)
continue;
keylen = utf8encode(keyval, unichar);
data = corrections_lookup(&unicode_data[unichar]);
if (data->correction <= trees[i].maxage)
data = &unicode_data[unichar];
insert(&trees[i], keyval, keylen, data);
}
}
}
static void trees_reduce(void)
{
int i;
int size;
int changed;
for (i = 0; i != trees_count; i++)
prune(&trees[i]);
for (i = 0; i != trees_count; i++)
mark_nodes(&trees[i]);
do {
size = 0;
for (i = 0; i != trees_count; i++)
size = index_nodes(&trees[i], size);
changed = 0;
for (i = 0; i != trees_count; i++)
changed += size_nodes(&trees[i]);
} while (changed);
utf8data = calloc(size, 1);
utf8data_size = size;
for (i = 0; i != trees_count; i++)
emit(&trees[i], utf8data);
if (verbose > 0) {
for (i = 0; i != trees_count; i++) {
printf("%s_%x idx %d\n",
trees[i].type, trees[i].maxage, trees[i].index);
}
}
nfkdi = utf8data + trees[trees_count-1].index;
nfkdicf = utf8data + trees[trees_count-2].index;
nfkdi_tree = &trees[trees_count-1];
nfkdicf_tree = &trees[trees_count-2];
}
static void verify(struct tree *tree)
{
struct unicode_data *data;
utf8leaf_t *leaf;
unsigned int unichar;
char key[4];
unsigned char hangul[UTF8HANGULLEAF];
int report;
int nocf;
if (verbose > 0)
printf("Verifying %s_%x\n", tree->type, tree->maxage);
nocf = strcmp(tree->type, "nfkdicf");
for (unichar = 0; unichar != 0x110000; unichar++) {
report = 0;
data = corrections_lookup(&unicode_data[unichar]);
if (data->correction <= tree->maxage)
data = &unicode_data[unichar];
utf8encode(key,unichar);
leaf = utf8lookup(tree, hangul, key);
if (!leaf) {
if (data->gen != -1)
report++;
if (unichar < 0xd800 || unichar > 0xdfff)
report++;
} else {
if (unichar >= 0xd800 && unichar <= 0xdfff)
report++;
if (data->gen == -1)
report++;
if (data->gen != LEAF_GEN(leaf))
report++;
if (LEAF_CCC(leaf) == DECOMPOSE) {
if (HANGUL_SYLLABLE(data->code)) {
if (data->utf8nfkdi[0] != HANGUL)
report++;
} else if (nocf) {
if (!data->utf8nfkdi) {
report++;
} else if (strcmp(data->utf8nfkdi,
LEAF_STR(leaf))) {
report++;
}
} else {
if (!data->utf8nfkdicf &&
!data->utf8nfkdi) {
report++;
} else if (data->utf8nfkdicf) {
if (strcmp(data->utf8nfkdicf,
LEAF_STR(leaf)))
report++;
} else if (strcmp(data->utf8nfkdi,
LEAF_STR(leaf))) {
report++;
}
}
} else if (data->ccc != LEAF_CCC(leaf)) {
report++;
}
}
if (report) {
printf("%X code %X gen %d ccc %d"
" nfkdi -> \"%s\"",
unichar, data->code, data->gen,
data->ccc,
data->utf8nfkdi);
if (leaf) {
printf(" gen %d ccc %d"
" nfkdi -> \"%s\"",
LEAF_GEN(leaf),
LEAF_CCC(leaf),
LEAF_CCC(leaf) == DECOMPOSE ?
LEAF_STR(leaf) : "");
}
printf("\n");
}
}
}
static void trees_verify(void)
{
int i;
for (i = 0; i != trees_count; i++)
verify(&trees[i]);
}
/* ------------------------------------------------------------------ */
static void help(void)
{
printf("Usage: %s [options]\n", argv0);
printf("\n");
printf("This program creates an a data trie used for parsing and\n");
printf("normalization of UTF-8 strings. The trie is derived from\n");
printf("a set of input files from the Unicode character database\n");
printf("found at: http://www.unicode.org/Public/UCD/latest/ucd/\n");
printf("\n");
printf("The generated tree supports two normalization forms:\n");
printf("\n");
printf("\tnfkdi:\n");
printf("\t- Apply unicode normalization form NFKD.\n");
printf("\t- Remove any Default_Ignorable_Code_Point.\n");
printf("\n");
printf("\tnfkdicf:\n");
printf("\t- Apply unicode normalization form NFKD.\n");
printf("\t- Remove any Default_Ignorable_Code_Point.\n");
printf("\t- Apply a full casefold (C + F).\n");
printf("\n");
printf("These forms were chosen as being most useful when dealing\n");
printf("with file names: NFKD catches most cases where characters\n");
printf("should be considered equivalent. The ignorables are mostly\n");
printf("invisible, making names hard to type.\n");
printf("\n");
printf("The options to specify the files to be used are listed\n");
printf("below with their default values, which are the names used\n");
printf("by version 11.0.0 of the Unicode Character Database.\n");
printf("\n");
printf("The input files:\n");
printf("\t-a %s\n", AGE_NAME);
printf("\t-c %s\n", CCC_NAME);
printf("\t-p %s\n", PROP_NAME);
printf("\t-d %s\n", DATA_NAME);
printf("\t-f %s\n", FOLD_NAME);
printf("\t-n %s\n", NORM_NAME);
printf("\n");
printf("Additionally, the generated tables are tested using:\n");
printf("\t-t %s\n", TEST_NAME);
printf("\n");
printf("Finally, the output file:\n");
printf("\t-o %s\n", UTF8_NAME);
printf("\n");
}
static void usage(void)
{
help();
exit(1);
}
static void open_fail(const char *name, int error)
{
printf("Error %d opening %s: %s\n", error, name, strerror(error));
exit(1);
}
static void file_fail(const char *filename)
{
printf("Error parsing %s\n", filename);
exit(1);
}
static void line_fail(const char *filename, const char *line)
{
printf("Error parsing %s:%s\n", filename, line);
exit(1);
}
/* ------------------------------------------------------------------ */
static void print_utf32(unsigned int *utf32str)
{
int i;
for (i = 0; utf32str[i]; i++)
printf(" %X", utf32str[i]);
}
static void print_utf32nfkdi(unsigned int unichar)
{
printf(" %X ->", unichar);
print_utf32(unicode_data[unichar].utf32nfkdi);
printf("\n");
}
static void print_utf32nfkdicf(unsigned int unichar)
{
printf(" %X ->", unichar);
print_utf32(unicode_data[unichar].utf32nfkdicf);
printf("\n");
}
/* ------------------------------------------------------------------ */
static void age_init(void)
{
FILE *file;
unsigned int first;
unsigned int last;
unsigned int unichar;
unsigned int major;
unsigned int minor;
unsigned int revision;
int gen;
int count;
int ret;
if (verbose > 0)
printf("Parsing %s\n", age_name);
file = fopen(age_name, "r");
if (!file)
open_fail(age_name, errno);
count = 0;
gen = 0;
while (fgets(line, LINESIZE, file)) {
ret = sscanf(line, "# Age=V%d_%d_%d",
&major, &minor, &revision);
if (ret == 3) {
ages_count++;
if (verbose > 1)
printf(" Age V%d_%d_%d\n",
major, minor, revision);
if (!age_valid(major, minor, revision))
line_fail(age_name, line);
continue;
}
ret = sscanf(line, "# Age=V%d_%d", &major, &minor);
if (ret == 2) {
ages_count++;
if (verbose > 1)
printf(" Age V%d_%d\n", major, minor);
if (!age_valid(major, minor, 0))
line_fail(age_name, line);
continue;
}
}
/* We must have found something above. */
if (verbose > 1)
printf("%d age entries\n", ages_count);
if (ages_count == 0 || ages_count > MAXGEN)
file_fail(age_name);
/* There is a 0 entry. */
ages_count++;
ages = calloc(ages_count + 1, sizeof(*ages));
/* And a guard entry. */
ages[ages_count] = (unsigned int)-1;
rewind(file);
count = 0;
gen = 0;
while (fgets(line, LINESIZE, file)) {
ret = sscanf(line, "# Age=V%d_%d_%d",
&major, &minor, &revision);
if (ret == 3) {
ages[++gen] =
UNICODE_AGE(major, minor, revision);
if (verbose > 1)
printf(" Age V%d_%d_%d = gen %d\n",
major, minor, revision, gen);
if (!age_valid(major, minor, revision))
line_fail(age_name, line);
continue;
}
ret = sscanf(line, "# Age=V%d_%d", &major, &minor);
if (ret == 2) {
ages[++gen] = UNICODE_AGE(major, minor, 0);
if (verbose > 1)
printf(" Age V%d_%d = %d\n",
major, minor, gen);
if (!age_valid(major, minor, 0))
line_fail(age_name, line);
continue;
}
ret = sscanf(line, "%X..%X ; %d.%d #",
&first, &last, &major, &minor);
if (ret == 4) {
for (unichar = first; unichar <= last; unichar++)
unicode_data[unichar].gen = gen;
count += 1 + last - first;
if (verbose > 1)
printf(" %X..%X gen %d\n", first, last, gen);
if (!utf32valid(first) || !utf32valid(last))
line_fail(age_name, line);
continue;
}
ret = sscanf(line, "%X ; %d.%d #", &unichar, &major, &minor);
if (ret == 3) {
unicode_data[unichar].gen = gen;
count++;
if (verbose > 1)
printf(" %X gen %d\n", unichar, gen);
if (!utf32valid(unichar))
line_fail(age_name, line);
continue;
}
}
unicode_maxage = ages[gen];
fclose(file);
/* Nix surrogate block */
if (verbose > 1)
printf(" Removing surrogate block D800..DFFF\n");
for (unichar = 0xd800; unichar <= 0xdfff; unichar++)
unicode_data[unichar].gen = -1;
if (verbose > 0)
printf("Found %d entries\n", count);
if (count == 0)
file_fail(age_name);
}
static void ccc_init(void)
{
FILE *file;
unsigned int first;
unsigned int last;
unsigned int unichar;
unsigned int value;
int count;
int ret;
if (verbose > 0)
printf("Parsing %s\n", ccc_name);
file = fopen(ccc_name, "r");
if (!file)
open_fail(ccc_name, errno);
count = 0;
while (fgets(line, LINESIZE, file)) {
ret = sscanf(line, "%X..%X ; %d #", &first, &last, &value);
if (ret == 3) {
for (unichar = first; unichar <= last; unichar++) {
unicode_data[unichar].ccc = value;
count++;
}
if (verbose > 1)
printf(" %X..%X ccc %d\n", first, last, value);
if (!utf32valid(first) || !utf32valid(last))
line_fail(ccc_name, line);
continue;
}
ret = sscanf(line, "%X ; %d #", &unichar, &value);
if (ret == 2) {
unicode_data[unichar].ccc = value;
count++;
if (verbose > 1)
printf(" %X ccc %d\n", unichar, value);
if (!utf32valid(unichar))
line_fail(ccc_name, line);
continue;
}
}
fclose(file);
if (verbose > 0)
printf("Found %d entries\n", count);
if (count == 0)
file_fail(ccc_name);
}
static void nfkdi_init(void)
{
FILE *file;
unsigned int unichar;
unsigned int mapping[19]; /* Magic - guaranteed not to be exceeded. */
char *s;
unsigned int *um;
int count;
int i;
int ret;
if (verbose > 0)
printf("Parsing %s\n", data_name);
file = fopen(data_name, "r");
if (!file)
open_fail(data_name, errno);
count = 0;
while (fgets(line, LINESIZE, file)) {
ret = sscanf(line, "%X;%*[^;];%*[^;];%*[^;];%*[^;];%[^;];",
&unichar, buf0);
if (ret != 2)
continue;
if (!utf32valid(unichar))
line_fail(data_name, line);
s = buf0;
/* skip over <tag> */
if (*s == '<')
while (*s++ != ' ')
;
/* decode the decomposition into UTF-32 */
i = 0;
while (*s) {
mapping[i] = strtoul(s, &s, 16);
if (!utf32valid(mapping[i]))
line_fail(data_name, line);
i++;
}
mapping[i++] = 0;
um = malloc(i * sizeof(unsigned int));
memcpy(um, mapping, i * sizeof(unsigned int));
unicode_data[unichar].utf32nfkdi = um;
if (verbose > 1)
print_utf32nfkdi(unichar);
count++;
}
fclose(file);
if (verbose > 0)
printf("Found %d entries\n", count);
if (count == 0)
file_fail(data_name);
}
static void nfkdicf_init(void)
{
FILE *file;
unsigned int unichar;
unsigned int mapping[19]; /* Magic - guaranteed not to be exceeded. */
char status;
char *s;
unsigned int *um;
int i;
int count;
int ret;
if (verbose > 0)
printf("Parsing %s\n", fold_name);
file = fopen(fold_name, "r");
if (!file)
open_fail(fold_name, errno);
count = 0;
while (fgets(line, LINESIZE, file)) {
ret = sscanf(line, "%X; %c; %[^;];", &unichar, &status, buf0);
if (ret != 3)
continue;
if (!utf32valid(unichar))
line_fail(fold_name, line);
/* Use the C+F casefold. */
if (status != 'C' && status != 'F')
continue;
s = buf0;
if (*s == '<')
while (*s++ != ' ')
;
i = 0;
while (*s) {
mapping[i] = strtoul(s, &s, 16);
if (!utf32valid(mapping[i]))
line_fail(fold_name, line);
i++;
}
mapping[i++] = 0;
um = malloc(i * sizeof(unsigned int));
memcpy(um, mapping, i * sizeof(unsigned int));
unicode_data[unichar].utf32nfkdicf = um;
if (verbose > 1)
print_utf32nfkdicf(unichar);
count++;
}
fclose(file);
if (verbose > 0)
printf("Found %d entries\n", count);
if (count == 0)
file_fail(fold_name);
}
static void ignore_init(void)
{
FILE *file;
unsigned int unichar;
unsigned int first;
unsigned int last;
unsigned int *um;
int count;
int ret;
if (verbose > 0)
printf("Parsing %s\n", prop_name);
file = fopen(prop_name, "r");
if (!file)
open_fail(prop_name, errno);
assert(file);
count = 0;
while (fgets(line, LINESIZE, file)) {
ret = sscanf(line, "%X..%X ; %s # ", &first, &last, buf0);
if (ret == 3) {
if (strcmp(buf0, "Default_Ignorable_Code_Point"))
continue;
if (!utf32valid(first) || !utf32valid(last))
line_fail(prop_name, line);
for (unichar = first; unichar <= last; unichar++) {
free(unicode_data[unichar].utf32nfkdi);
um = malloc(sizeof(unsigned int));
*um = 0;
unicode_data[unichar].utf32nfkdi = um;
free(unicode_data[unichar].utf32nfkdicf);
um = malloc(sizeof(unsigned int));
*um = 0;
unicode_data[unichar].utf32nfkdicf = um;
count++;
}
if (verbose > 1)
printf(" %X..%X Default_Ignorable_Code_Point\n",
first, last);
continue;
}
ret = sscanf(line, "%X ; %s # ", &unichar, buf0);
if (ret == 2) {
if (strcmp(buf0, "Default_Ignorable_Code_Point"))
continue;
if (!utf32valid(unichar))
line_fail(prop_name, line);
free(unicode_data[unichar].utf32nfkdi);
um = malloc(sizeof(unsigned int));
*um = 0;
unicode_data[unichar].utf32nfkdi = um;
free(unicode_data[unichar].utf32nfkdicf);
um = malloc(sizeof(unsigned int));
*um = 0;
unicode_data[unichar].utf32nfkdicf = um;
if (verbose > 1)
printf(" %X Default_Ignorable_Code_Point\n",
unichar);
count++;
continue;
}
}
fclose(file);
if (verbose > 0)
printf("Found %d entries\n", count);
if (count == 0)
file_fail(prop_name);
}
static void corrections_init(void)
{
FILE *file;
unsigned int unichar;
unsigned int major;
unsigned int minor;
unsigned int revision;
unsigned int age;
unsigned int *um;
unsigned int mapping[19]; /* Magic - guaranteed not to be exceeded. */
char *s;
int i;
int count;
int ret;
if (verbose > 0)
printf("Parsing %s\n", norm_name);
file = fopen(norm_name, "r");
if (!file)
open_fail(norm_name, errno);
count = 0;
while (fgets(line, LINESIZE, file)) {
ret = sscanf(line, "%X;%[^;];%[^;];%d.%d.%d #",
&unichar, buf0, buf1,
&major, &minor, &revision);
if (ret != 6)
continue;
if (!utf32valid(unichar) || !age_valid(major, minor, revision))
line_fail(norm_name, line);
count++;
}
corrections = calloc(count, sizeof(struct unicode_data));
corrections_count = count;
rewind(file);
count = 0;
while (fgets(line, LINESIZE, file)) {
ret = sscanf(line, "%X;%[^;];%[^;];%d.%d.%d #",
&unichar, buf0, buf1,
&major, &minor, &revision);
if (ret != 6)
continue;
if (!utf32valid(unichar) || !age_valid(major, minor, revision))
line_fail(norm_name, line);
corrections[count] = unicode_data[unichar];
assert(corrections[count].code == unichar);
age = UNICODE_AGE(major, minor, revision);
corrections[count].correction = age;
i = 0;
s = buf0;
while (*s) {
mapping[i] = strtoul(s, &s, 16);
if (!utf32valid(mapping[i]))
line_fail(norm_name, line);
i++;
}
mapping[i++] = 0;
um = malloc(i * sizeof(unsigned int));
memcpy(um, mapping, i * sizeof(unsigned int));
corrections[count].utf32nfkdi = um;
if (verbose > 1)
printf(" %X -> %s -> %s V%d_%d_%d\n",
unichar, buf0, buf1, major, minor, revision);
count++;
}
fclose(file);
if (verbose > 0)
printf("Found %d entries\n", count);
if (count == 0)
file_fail(norm_name);
}
/* ------------------------------------------------------------------ */
/*
* Hangul decomposition (algorithm from Section 3.12 of Unicode 6.3.0)
*
* AC00;<Hangul Syllable, First>;Lo;0;L;;;;;N;;;;;
* D7A3;<Hangul Syllable, Last>;Lo;0;L;;;;;N;;;;;
*
* SBase = 0xAC00
* LBase = 0x1100
* VBase = 0x1161
* TBase = 0x11A7
* LCount = 19
* VCount = 21
* TCount = 28
* NCount = 588 (VCount * TCount)
* SCount = 11172 (LCount * NCount)
*
* Decomposition:
* SIndex = s - SBase
*
* LV (Canonical/Full)
* LIndex = SIndex / NCount
* VIndex = (Sindex % NCount) / TCount
* LPart = LBase + LIndex
* VPart = VBase + VIndex
*
* LVT (Canonical)
* LVIndex = (SIndex / TCount) * TCount
* TIndex = (Sindex % TCount)
* LVPart = SBase + LVIndex
* TPart = TBase + TIndex
*
* LVT (Full)
* LIndex = SIndex / NCount
* VIndex = (Sindex % NCount) / TCount
* TIndex = (Sindex % TCount)
* LPart = LBase + LIndex
* VPart = VBase + VIndex
* if (TIndex == 0) {
* d = <LPart, VPart>
* } else {
* TPart = TBase + TIndex
* d = <LPart, VPart, TPart>
* }
*
*/
static void hangul_decompose(void)
{
unsigned int sb = 0xAC00;
unsigned int lb = 0x1100;
unsigned int vb = 0x1161;
unsigned int tb = 0x11a7;
/* unsigned int lc = 19; */
unsigned int vc = 21;
unsigned int tc = 28;
unsigned int nc = (vc * tc);
/* unsigned int sc = (lc * nc); */
unsigned int unichar;
unsigned int mapping[4];
unsigned int *um;
int count;
int i;
if (verbose > 0)
printf("Decomposing hangul\n");
/* Hangul */
count = 0;
for (unichar = 0xAC00; unichar <= 0xD7A3; unichar++) {
unsigned int si = unichar - sb;
unsigned int li = si / nc;
unsigned int vi = (si % nc) / tc;
unsigned int ti = si % tc;
i = 0;
mapping[i++] = lb + li;
mapping[i++] = vb + vi;
if (ti)
mapping[i++] = tb + ti;
mapping[i++] = 0;
assert(!unicode_data[unichar].utf32nfkdi);
um = malloc(i * sizeof(unsigned int));
memcpy(um, mapping, i * sizeof(unsigned int));
unicode_data[unichar].utf32nfkdi = um;
assert(!unicode_data[unichar].utf32nfkdicf);
um = malloc(i * sizeof(unsigned int));
memcpy(um, mapping, i * sizeof(unsigned int));
unicode_data[unichar].utf32nfkdicf = um;
/*
* Add a cookie as a reminder that the hangul syllable
* decompositions must not be stored in the generated
* trie.
*/
unicode_data[unichar].utf8nfkdi = malloc(2);
unicode_data[unichar].utf8nfkdi[0] = HANGUL;
unicode_data[unichar].utf8nfkdi[1] = '\0';
if (verbose > 1)
print_utf32nfkdi(unichar);
count++;
}
if (verbose > 0)
printf("Created %d entries\n", count);
}
static void nfkdi_decompose(void)
{
unsigned int unichar;
unsigned int mapping[19]; /* Magic - guaranteed not to be exceeded. */
unsigned int *um;
unsigned int *dc;
int count;
int i;
int j;
int ret;
if (verbose > 0)
printf("Decomposing nfkdi\n");
count = 0;
for (unichar = 0; unichar != 0x110000; unichar++) {
if (!unicode_data[unichar].utf32nfkdi)
continue;
for (;;) {
ret = 1;
i = 0;
um = unicode_data[unichar].utf32nfkdi;
while (*um) {
dc = unicode_data[*um].utf32nfkdi;
if (dc) {
for (j = 0; dc[j]; j++)
mapping[i++] = dc[j];
ret = 0;
} else {
mapping[i++] = *um;
}
um++;
}
mapping[i++] = 0;
if (ret)
break;
free(unicode_data[unichar].utf32nfkdi);
um = malloc(i * sizeof(unsigned int));
memcpy(um, mapping, i * sizeof(unsigned int));
unicode_data[unichar].utf32nfkdi = um;
}
/* Add this decomposition to nfkdicf if there is no entry. */
if (!unicode_data[unichar].utf32nfkdicf) {
um = malloc(i * sizeof(unsigned int));
memcpy(um, mapping, i * sizeof(unsigned int));
unicode_data[unichar].utf32nfkdicf = um;
}
if (verbose > 1)
print_utf32nfkdi(unichar);
count++;
}
if (verbose > 0)
printf("Processed %d entries\n", count);
}
static void nfkdicf_decompose(void)
{
unsigned int unichar;
unsigned int mapping[19]; /* Magic - guaranteed not to be exceeded. */
unsigned int *um;
unsigned int *dc;
int count;
int i;
int j;
int ret;
if (verbose > 0)
printf("Decomposing nfkdicf\n");
count = 0;
for (unichar = 0; unichar != 0x110000; unichar++) {
if (!unicode_data[unichar].utf32nfkdicf)
continue;
for (;;) {
ret = 1;
i = 0;
um = unicode_data[unichar].utf32nfkdicf;
while (*um) {
dc = unicode_data[*um].utf32nfkdicf;
if (dc) {
for (j = 0; dc[j]; j++)
mapping[i++] = dc[j];
ret = 0;
} else {
mapping[i++] = *um;
}
um++;
}
mapping[i++] = 0;
if (ret)
break;
free(unicode_data[unichar].utf32nfkdicf);
um = malloc(i * sizeof(unsigned int));
memcpy(um, mapping, i * sizeof(unsigned int));
unicode_data[unichar].utf32nfkdicf = um;
}
if (verbose > 1)
print_utf32nfkdicf(unichar);
count++;
}
if (verbose > 0)
printf("Processed %d entries\n", count);
}
/* ------------------------------------------------------------------ */
int utf8agemax(struct tree *, const char *);
int utf8nagemax(struct tree *, const char *, size_t);
int utf8agemin(struct tree *, const char *);
int utf8nagemin(struct tree *, const char *, size_t);
ssize_t utf8len(struct tree *, const char *);
ssize_t utf8nlen(struct tree *, const char *, size_t);
struct utf8cursor;
int utf8cursor(struct utf8cursor *, struct tree *, const char *);
int utf8ncursor(struct utf8cursor *, struct tree *, const char *, size_t);
int utf8byte(struct utf8cursor *);
/*
* Hangul decomposition (algorithm from Section 3.12 of Unicode 6.3.0)
*
* AC00;<Hangul Syllable, First>;Lo;0;L;;;;;N;;;;;
* D7A3;<Hangul Syllable, Last>;Lo;0;L;;;;;N;;;;;
*
* SBase = 0xAC00
* LBase = 0x1100
* VBase = 0x1161
* TBase = 0x11A7
* LCount = 19
* VCount = 21
* TCount = 28
* NCount = 588 (VCount * TCount)
* SCount = 11172 (LCount * NCount)
*
* Decomposition:
* SIndex = s - SBase
*
* LV (Canonical/Full)
* LIndex = SIndex / NCount
* VIndex = (Sindex % NCount) / TCount
* LPart = LBase + LIndex
* VPart = VBase + VIndex
*
* LVT (Canonical)
* LVIndex = (SIndex / TCount) * TCount
* TIndex = (Sindex % TCount)
* LVPart = SBase + LVIndex
* TPart = TBase + TIndex
*
* LVT (Full)
* LIndex = SIndex / NCount
* VIndex = (Sindex % NCount) / TCount
* TIndex = (Sindex % TCount)
* LPart = LBase + LIndex
* VPart = VBase + VIndex
* if (TIndex == 0) {
* d = <LPart, VPart>
* } else {
* TPart = TBase + TIndex
* d = <LPart, VPart, TPart>
* }
*/
/* Constants */
#define SB (0xAC00)
#define LB (0x1100)
#define VB (0x1161)
#define TB (0x11A7)
#define LC (19)
#define VC (21)
#define TC (28)
#define NC (VC * TC)
#define SC (LC * NC)
/* Algorithmic decomposition of hangul syllable. */
static utf8leaf_t *utf8hangul(const char *str, unsigned char *hangul)
{
unsigned int si;
unsigned int li;
unsigned int vi;
unsigned int ti;
unsigned char *h;
/* Calculate the SI, LI, VI, and TI values. */
si = utf8decode(str) - SB;
li = si / NC;
vi = (si % NC) / TC;
ti = si % TC;
/* Fill in base of leaf. */
h = hangul;
LEAF_GEN(h) = 2;
LEAF_CCC(h) = DECOMPOSE;
h += 2;
/* Add LPart, a 3-byte UTF-8 sequence. */
h += utf8encode((char *)h, li + LB);
/* Add VPart, a 3-byte UTF-8 sequence. */
h += utf8encode((char *)h, vi + VB);
/* Add TPart if required, also a 3-byte UTF-8 sequence. */
if (ti)
h += utf8encode((char *)h, ti + TB);
/* Terminate string. */
h[0] = '\0';
return hangul;
}
/*
* Use trie to scan s, touching at most len bytes.
* Returns the leaf if one exists, NULL otherwise.
*
* A non-NULL return guarantees that the UTF-8 sequence starting at s
* is well-formed and corresponds to a known unicode code point. The
* shorthand for this will be "is valid UTF-8 unicode".
*/
static utf8leaf_t *utf8nlookup(struct tree *tree, unsigned char *hangul,
const char *s, size_t len)
{
utf8trie_t *trie = utf8data + tree->index;
int offlen;
int offset;
int mask;
int node;
if (!tree)
return NULL;
if (len == 0)
return NULL;
node = 1;
while (node) {
offlen = (*trie & OFFLEN) >> OFFLEN_SHIFT;
if (*trie & NEXTBYTE) {
if (--len == 0)
return NULL;
s++;
}
mask = 1 << (*trie & BITNUM);
if (*s & mask) {
/* Right leg */
if (offlen) {
/* Right node at offset of trie */
node = (*trie & RIGHTNODE);
offset = trie[offlen];
while (--offlen) {
offset <<= 8;
offset |= trie[offlen];
}
trie += offset;
} else if (*trie & RIGHTPATH) {
/* Right node after this node */
node = (*trie & TRIENODE);
trie++;
} else {
/* No right node. */
return NULL;
}
} else {
/* Left leg */
if (offlen) {
/* Left node after this node. */
node = (*trie & LEFTNODE);
trie += offlen + 1;
} else if (*trie & RIGHTPATH) {
/* No left node. */
return NULL;
} else {
/* Left node after this node */
node = (*trie & TRIENODE);
trie++;
}
}
}
/*
* Hangul decomposition is done algorithmically. These are the
* codepoints >= 0xAC00 and <= 0xD7A3. Their UTF-8 encoding is
* always 3 bytes long, so s has been advanced twice, and the
* start of the sequence is at s-2.
*/
if (LEAF_CCC(trie) == DECOMPOSE && LEAF_STR(trie)[0] == HANGUL)
trie = utf8hangul(s - 2, hangul);
return trie;
}
/*
* Use trie to scan s.
* Returns the leaf if one exists, NULL otherwise.
*
* Forwards to trie_nlookup().
*/
static utf8leaf_t *utf8lookup(struct tree *tree, unsigned char *hangul,
const char *s)
{
return utf8nlookup(tree, hangul, s, (size_t)-1);
}
/*
* Return the number of bytes used by the current UTF-8 sequence.
* Assumes the input points to the first byte of a valid UTF-8
* sequence.
*/
static inline int utf8clen(const char *s)
{
unsigned char c = *s;
return 1 + (c >= 0xC0) + (c >= 0xE0) + (c >= 0xF0);
}
/*
* Maximum age of any character in s.
* Return -1 if s is not valid UTF-8 unicode.
* Return 0 if only non-assigned code points are used.
*/
int utf8agemax(struct tree *tree, const char *s)
{
utf8leaf_t *leaf;
int age = 0;
int leaf_age;
unsigned char hangul[UTF8HANGULLEAF];
if (!tree)
return -1;
while (*s) {
leaf = utf8lookup(tree, hangul, s);
if (!leaf)
return -1;
leaf_age = ages[LEAF_GEN(leaf)];
if (leaf_age <= tree->maxage && leaf_age > age)
age = leaf_age;
s += utf8clen(s);
}
return age;
}
/*
* Minimum age of any character in s.
* Return -1 if s is not valid UTF-8 unicode.
* Return 0 if non-assigned code points are used.
*/
int utf8agemin(struct tree *tree, const char *s)
{
utf8leaf_t *leaf;
int age;
int leaf_age;
unsigned char hangul[UTF8HANGULLEAF];
if (!tree)
return -1;
age = tree->maxage;
while (*s) {
leaf = utf8lookup(tree, hangul, s);
if (!leaf)
return -1;
leaf_age = ages[LEAF_GEN(leaf)];
if (leaf_age <= tree->maxage && leaf_age < age)
age = leaf_age;
s += utf8clen(s);
}
return age;
}
/*
* Maximum age of any character in s, touch at most len bytes.
* Return -1 if s is not valid UTF-8 unicode.
*/
int utf8nagemax(struct tree *tree, const char *s, size_t len)
{
utf8leaf_t *leaf;
int age = 0;
int leaf_age;
unsigned char hangul[UTF8HANGULLEAF];
if (!tree)
return -1;
while (len && *s) {
leaf = utf8nlookup(tree, hangul, s, len);
if (!leaf)
return -1;
leaf_age = ages[LEAF_GEN(leaf)];
if (leaf_age <= tree->maxage && leaf_age > age)
age = leaf_age;
len -= utf8clen(s);
s += utf8clen(s);
}
return age;
}
/*
* Maximum age of any character in s, touch at most len bytes.
* Return -1 if s is not valid UTF-8 unicode.
*/
int utf8nagemin(struct tree *tree, const char *s, size_t len)
{
utf8leaf_t *leaf;
int leaf_age;
int age;
unsigned char hangul[UTF8HANGULLEAF];
if (!tree)
return -1;
age = tree->maxage;
while (len && *s) {
leaf = utf8nlookup(tree, hangul, s, len);
if (!leaf)
return -1;
leaf_age = ages[LEAF_GEN(leaf)];
if (leaf_age <= tree->maxage && leaf_age < age)
age = leaf_age;
len -= utf8clen(s);
s += utf8clen(s);
}
return age;
}
/*
* Length of the normalization of s.
* Return -1 if s is not valid UTF-8 unicode.
*
* A string of Default_Ignorable_Code_Point has length 0.
*/
ssize_t utf8len(struct tree *tree, const char *s)
{
utf8leaf_t *leaf;
size_t ret = 0;
unsigned char hangul[UTF8HANGULLEAF];
if (!tree)
return -1;
while (*s) {
leaf = utf8lookup(tree, hangul, s);
if (!leaf)
return -1;
if (ages[LEAF_GEN(leaf)] > tree->maxage)
ret += utf8clen(s);
else if (LEAF_CCC(leaf) == DECOMPOSE)
ret += strlen(LEAF_STR(leaf));
else
ret += utf8clen(s);
s += utf8clen(s);
}
return ret;
}
/*
* Length of the normalization of s, touch at most len bytes.
* Return -1 if s is not valid UTF-8 unicode.
*/
ssize_t utf8nlen(struct tree *tree, const char *s, size_t len)
{
utf8leaf_t *leaf;
size_t ret = 0;
unsigned char hangul[UTF8HANGULLEAF];
if (!tree)
return -1;
while (len && *s) {
leaf = utf8nlookup(tree, hangul, s, len);
if (!leaf)
return -1;
if (ages[LEAF_GEN(leaf)] > tree->maxage)
ret += utf8clen(s);
else if (LEAF_CCC(leaf) == DECOMPOSE)
ret += strlen(LEAF_STR(leaf));
else
ret += utf8clen(s);
len -= utf8clen(s);
s += utf8clen(s);
}
return ret;
}
/*
* Cursor structure used by the normalizer.
*/
struct utf8cursor {
struct tree *tree;
const char *s;
const char *p;
const char *ss;
const char *sp;
unsigned int len;
unsigned int slen;
short int ccc;
short int nccc;
unsigned int unichar;
unsigned char hangul[UTF8HANGULLEAF];
};
/*
* Set up an utf8cursor for use by utf8byte().
*
* s : string.
* len : length of s.
* u8c : pointer to cursor.
* trie : utf8trie_t to use for normalization.
*
* Returns -1 on error, 0 on success.
*/
int utf8ncursor(struct utf8cursor *u8c, struct tree *tree, const char *s,
size_t len)
{
if (!tree)
return -1;
if (!s)
return -1;
u8c->tree = tree;
u8c->s = s;
u8c->p = NULL;
u8c->ss = NULL;
u8c->sp = NULL;
u8c->len = len;
u8c->slen = 0;
u8c->ccc = STOPPER;
u8c->nccc = STOPPER;
u8c->unichar = 0;
/* Check we didn't clobber the maximum length. */
if (u8c->len != len)
return -1;
/* The first byte of s may not be an utf8 continuation. */
if (len > 0 && (*s & 0xC0) == 0x80)
return -1;
return 0;
}
/*
* Set up an utf8cursor for use by utf8byte().
*
* s : NUL-terminated string.
* u8c : pointer to cursor.
* trie : utf8trie_t to use for normalization.
*
* Returns -1 on error, 0 on success.
*/
int utf8cursor(struct utf8cursor *u8c, struct tree *tree, const char *s)
{
return utf8ncursor(u8c, tree, s, (unsigned int)-1);
}
/*
* Get one byte from the normalized form of the string described by u8c.
*
* Returns the byte cast to an unsigned char on succes, and -1 on failure.
*
* The cursor keeps track of the location in the string in u8c->s.
* When a character is decomposed, the current location is stored in
* u8c->p, and u8c->s is set to the start of the decomposition. Note
* that bytes from a decomposition do not count against u8c->len.
*
* Characters are emitted if they match the current CCC in u8c->ccc.
* Hitting end-of-string while u8c->ccc == STOPPER means we're done,
* and the function returns 0 in that case.
*
* Sorting by CCC is done by repeatedly scanning the string. The
* values of u8c->s and u8c->p are stored in u8c->ss and u8c->sp at
* the start of the scan. The first pass finds the lowest CCC to be
* emitted and stores it in u8c->nccc, the second pass emits the
* characters with this CCC and finds the next lowest CCC. This limits
* the number of passes to 1 + the number of different CCCs in the
* sequence being scanned.
*
* Therefore:
* u8c->p != NULL -> a decomposition is being scanned.
* u8c->ss != NULL -> this is a repeating scan.
* u8c->ccc == -1 -> this is the first scan of a repeating scan.
*/
int utf8byte(struct utf8cursor *u8c)
{
utf8leaf_t *leaf;
int ccc;
for (;;) {
/* Check for the end of a decomposed character. */
if (u8c->p && *u8c->s == '\0') {
u8c->s = u8c->p;
u8c->p = NULL;
}
/* Check for end-of-string. */
if (!u8c->p && (u8c->len == 0 || *u8c->s == '\0')) {
/* There is no next byte. */
if (u8c->ccc == STOPPER)
return 0;
/* End-of-string during a scan counts as a stopper. */
ccc = STOPPER;
goto ccc_mismatch;
} else if ((*u8c->s & 0xC0) == 0x80) {
/* This is a continuation of the current character. */
if (!u8c->p)
u8c->len--;
return (unsigned char)*u8c->s++;
}
/* Look up the data for the current character. */
if (u8c->p) {
leaf = utf8lookup(u8c->tree, u8c->hangul, u8c->s);
} else {
leaf = utf8nlookup(u8c->tree, u8c->hangul,
u8c->s, u8c->len);
}
/* No leaf found implies that the input is a binary blob. */
if (!leaf)
return -1;
/* Characters that are too new have CCC 0. */
if (ages[LEAF_GEN(leaf)] > u8c->tree->maxage) {
ccc = STOPPER;
} else if ((ccc = LEAF_CCC(leaf)) == DECOMPOSE) {
u8c->len -= utf8clen(u8c->s);
u8c->p = u8c->s + utf8clen(u8c->s);
u8c->s = LEAF_STR(leaf);
/* Empty decomposition implies CCC 0. */
if (*u8c->s == '\0') {
if (u8c->ccc == STOPPER)
continue;
ccc = STOPPER;
goto ccc_mismatch;
}
leaf = utf8lookup(u8c->tree, u8c->hangul, u8c->s);
ccc = LEAF_CCC(leaf);
}
u8c->unichar = utf8decode(u8c->s);
/*
* If this is not a stopper, then see if it updates
* the next canonical class to be emitted.
*/
if (ccc != STOPPER && u8c->ccc < ccc && ccc < u8c->nccc)
u8c->nccc = ccc;
/*
* Return the current byte if this is the current
* combining class.
*/
if (ccc == u8c->ccc) {
if (!u8c->p)
u8c->len--;
return (unsigned char)*u8c->s++;
}
/* Current combining class mismatch. */
ccc_mismatch:
if (u8c->nccc == STOPPER) {
/*
* Scan forward for the first canonical class
* to be emitted. Save the position from
* which to restart.
*/
assert(u8c->ccc == STOPPER);
u8c->ccc = MINCCC - 1;
u8c->nccc = ccc;
u8c->sp = u8c->p;
u8c->ss = u8c->s;
u8c->slen = u8c->len;
if (!u8c->p)
u8c->len -= utf8clen(u8c->s);
u8c->s += utf8clen(u8c->s);
} else if (ccc != STOPPER) {
/* Not a stopper, and not the ccc we're emitting. */
if (!u8c->p)
u8c->len -= utf8clen(u8c->s);
u8c->s += utf8clen(u8c->s);
} else if (u8c->nccc != MAXCCC + 1) {
/* At a stopper, restart for next ccc. */
u8c->ccc = u8c->nccc;
u8c->nccc = MAXCCC + 1;
u8c->s = u8c->ss;
u8c->p = u8c->sp;
u8c->len = u8c->slen;
} else {
/* All done, proceed from here. */
u8c->ccc = STOPPER;
u8c->nccc = STOPPER;
u8c->sp = NULL;
u8c->ss = NULL;
u8c->slen = 0;
}
}
}
/* ------------------------------------------------------------------ */
static int normalize_line(struct tree *tree)
{
char *s;
char *t;
int c;
struct utf8cursor u8c;
/* First test: null-terminated string. */
s = buf2;
t = buf3;
if (utf8cursor(&u8c, tree, s))
return -1;
while ((c = utf8byte(&u8c)) > 0)
if (c != (unsigned char)*t++)
return -1;
if (c < 0)
return -1;
if (*t != 0)
return -1;
/* Second test: length-limited string. */
s = buf2;
/* Replace NUL with a value that will cause an error if seen. */
s[strlen(s) + 1] = -1;
t = buf3;
if (utf8cursor(&u8c, tree, s))
return -1;
while ((c = utf8byte(&u8c)) > 0)
if (c != (unsigned char)*t++)
return -1;
if (c < 0)
return -1;
if (*t != 0)
return -1;
return 0;
}
static void normalization_test(void)
{
FILE *file;
unsigned int unichar;
struct unicode_data *data;
char *s;
char *t;
int ret;
int ignorables;
int tests = 0;
int failures = 0;
if (verbose > 0)
printf("Parsing %s\n", test_name);
/* Step one, read data from file. */
file = fopen(test_name, "r");
if (!file)
open_fail(test_name, errno);
while (fgets(line, LINESIZE, file)) {
ret = sscanf(line, "%[^;];%*[^;];%*[^;];%*[^;];%[^;];",
buf0, buf1);
if (ret != 2 || *line == '#')
continue;
s = buf0;
t = buf2;
while (*s) {
unichar = strtoul(s, &s, 16);
t += utf8encode(t, unichar);
}
*t = '\0';
ignorables = 0;
s = buf1;
t = buf3;
while (*s) {
unichar = strtoul(s, &s, 16);
data = &unicode_data[unichar];
if (data->utf8nfkdi && !*data->utf8nfkdi)
ignorables = 1;
else
t += utf8encode(t, unichar);
}
*t = '\0';
tests++;
if (normalize_line(nfkdi_tree) < 0) {
printf("Line %s -> %s", buf0, buf1);
if (ignorables)
printf(" (ignorables removed)");
printf(" failure\n");
failures++;
}
}
fclose(file);
if (verbose > 0)
printf("Ran %d tests with %d failures\n", tests, failures);
if (failures)
file_fail(test_name);
}
/* ------------------------------------------------------------------ */
static void write_file(void)
{
FILE *file;
int i;
int j;
int t;
int gen;
if (verbose > 0)
printf("Writing %s\n", utf8_name);
file = fopen(utf8_name, "w");
if (!file)
open_fail(utf8_name, errno);
fprintf(file, "/* This file is generated code, do not edit. */\n");
fprintf(file, "#ifndef __INCLUDED_FROM_UTF8NORM_C__\n");
fprintf(file, "#error Only nls_utf8-norm.c should include this file.\n");
fprintf(file, "#endif\n");
fprintf(file, "\n");
fprintf(file, "static const unsigned int utf8vers = %#x;\n",
unicode_maxage);
fprintf(file, "\n");
fprintf(file, "static const unsigned int utf8agetab[] = {\n");
for (i = 0; i != ages_count; i++)
fprintf(file, "\t%#x%s\n", ages[i],
ages[i] == unicode_maxage ? "" : ",");
fprintf(file, "};\n");
fprintf(file, "\n");
fprintf(file, "static const struct utf8data utf8nfkdicfdata[] = {\n");
t = 0;
for (gen = 0; gen < ages_count; gen++) {
fprintf(file, "\t{ %#x, %d }%s\n",
ages[gen], trees[t].index,
ages[gen] == unicode_maxage ? "" : ",");
if (trees[t].maxage == ages[gen])
t += 2;
}
fprintf(file, "};\n");
fprintf(file, "\n");
fprintf(file, "static const struct utf8data utf8nfkdidata[] = {\n");
t = 1;
for (gen = 0; gen < ages_count; gen++) {
fprintf(file, "\t{ %#x, %d }%s\n",
ages[gen], trees[t].index,
ages[gen] == unicode_maxage ? "" : ",");
if (trees[t].maxage == ages[gen])
t += 2;
}
fprintf(file, "};\n");
fprintf(file, "\n");
fprintf(file, "static const unsigned char utf8data[%zd] = {\n",
utf8data_size);
t = 0;
for (i = 0; i != utf8data_size; i += 16) {
if (i == trees[t].index) {
fprintf(file, "\t/* %s_%x */\n",
trees[t].type, trees[t].maxage);
if (t < trees_count-1)
t++;
}
fprintf(file, "\t");
for (j = i; j != i + 16; j++)
fprintf(file, "0x%.2x%s", utf8data[j],
(j < utf8data_size -1 ? "," : ""));
fprintf(file, "\n");
}
fprintf(file, "};\n");
fclose(file);
}
/* ------------------------------------------------------------------ */
int main(int argc, char *argv[])
{
unsigned int unichar;
int opt;
argv0 = argv[0];
while ((opt = getopt(argc, argv, "a:c:d:f:hn:o:p:t:v")) != -1) {
switch (opt) {
case 'a':
age_name = optarg;
break;
case 'c':
ccc_name = optarg;
break;
case 'd':
data_name = optarg;
break;
case 'f':
fold_name = optarg;
break;
case 'n':
norm_name = optarg;
break;
case 'o':
utf8_name = optarg;
break;
case 'p':
prop_name = optarg;
break;
case 't':
test_name = optarg;
break;
case 'v':
verbose++;
break;
case 'h':
help();
exit(0);
default:
usage();
}
}
if (verbose > 1)
help();
for (unichar = 0; unichar != 0x110000; unichar++)
unicode_data[unichar].code = unichar;
age_init();
ccc_init();
nfkdi_init();
nfkdicf_init();
ignore_init();
corrections_init();
hangul_decompose();
nfkdi_decompose();
nfkdicf_decompose();
utf8_init();
trees_init();
trees_populate();
trees_reduce();
trees_verify();
/* Prevent "unused function" warning. */
(void)lookup(nfkdi_tree, " ");
if (verbose > 2)
tree_walk(nfkdi_tree);
if (verbose > 2)
tree_walk(nfkdicf_tree);
normalization_test();
write_file();
return 0;
}
|
the_stack_data/54825854.c | # 1 "security/mbedtls/src/ssl_cookie.c"
# 1 "/home/stone/Documents/Ali_IOT//"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "security/mbedtls/src/ssl_cookie.c"
# 27 "security/mbedtls/src/ssl_cookie.c"
# 1 "./security/mbedtls/include/mbedtls/config.h" 1
# 99 "./security/mbedtls/include/mbedtls/config.h"
# 1 "./security/mbedtls/include/mbedtls/check_config.h" 1
# 36 "./security/mbedtls/include/mbedtls/check_config.h"
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include-fixed/limits.h" 1 3 4
# 34 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include-fixed/limits.h" 3 4
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include-fixed/syslimits.h" 1 3 4
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include-fixed/limits.h" 1 3 4
# 168 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include-fixed/limits.h" 3 4
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/limits.h" 1 3 4
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/newlib.h" 1 3 4
# 14 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/newlib.h" 3 4
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/_newlib_version.h" 1 3 4
# 15 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/newlib.h" 2 3 4
# 5 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/limits.h" 2 3 4
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/cdefs.h" 1 3 4
# 43 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/cdefs.h" 3 4
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 1 3 4
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/features.h" 1 3 4
# 9 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 2 3 4
# 27 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 3 4
# 27 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 3 4
typedef signed char __int8_t;
typedef unsigned char __uint8_t;
# 41 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 3 4
typedef short int __int16_t;
typedef short unsigned int __uint16_t;
# 63 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 3 4
typedef long int __int32_t;
typedef long unsigned int __uint32_t;
# 89 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 3 4
typedef long long int __int64_t;
typedef long long unsigned int __uint64_t;
# 120 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 3 4
typedef signed char __int_least8_t;
typedef unsigned char __uint_least8_t;
# 146 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 3 4
typedef short int __int_least16_t;
typedef short unsigned int __uint_least16_t;
# 168 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 3 4
typedef long int __int_least32_t;
typedef long unsigned int __uint_least32_t;
# 186 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 3 4
typedef long long int __int_least64_t;
typedef long long unsigned int __uint_least64_t;
# 200 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 3 4
typedef int __intptr_t;
typedef unsigned int __uintptr_t;
# 44 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/cdefs.h" 2 3 4
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4
# 149 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 3 4
typedef int ptrdiff_t;
# 216 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 3 4
typedef unsigned int size_t;
# 328 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 3 4
typedef unsigned int wchar_t;
# 426 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 3 4
typedef struct {
long long __max_align_ll __attribute__((__aligned__(__alignof__(long long))));
long double __max_align_ld __attribute__((__aligned__(__alignof__(long double))));
} max_align_t;
# 46 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/cdefs.h" 2 3 4
# 6 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/limits.h" 2 3 4
# 169 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include-fixed/limits.h" 2 3 4
# 8 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include-fixed/syslimits.h" 2 3 4
# 35 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include-fixed/limits.h" 2 3 4
# 37 "./security/mbedtls/include/mbedtls/check_config.h" 2
# 672 "./security/mbedtls/include/mbedtls/check_config.h"
# 672 "./security/mbedtls/include/mbedtls/check_config.h"
typedef int mbedtls_iso_c_forbids_empty_translation_units;
# 100 "./security/mbedtls/include/mbedtls/config.h" 2
# 28 "security/mbedtls/src/ssl_cookie.c" 2
# 1 "./security/mbedtls/include/mbedtls/platform.h" 1
# 27 "./security/mbedtls/include/mbedtls/platform.h"
# 1 "./security/mbedtls/include/mbedtls/config.h" 1
# 28 "./security/mbedtls/include/mbedtls/platform.h" 2
# 299 "./security/mbedtls/include/mbedtls/platform.h"
# 1 "./security/mbedtls/include/mbedtls/platform_alt.h" 1
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdlib.h" 1 3
# 10 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdlib.h" 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/ieeefp.h" 1 3
# 11 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdlib.h" 2 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/_ansi.h" 1 3
# 16 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/_ansi.h" 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/config.h" 1 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/ieeefp.h" 1 3
# 5 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/config.h" 2 3
# 17 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/_ansi.h" 2 3
# 12 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdlib.h" 2 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4
# 17 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdlib.h" 2 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 1 3
# 13 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/_ansi.h" 1 3
# 14 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 2 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4
# 15 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 2 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_types.h" 1 3
# 24 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_types.h" 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_types.h" 1 3
# 25 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_types.h" 2 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/lock.h" 1 3
# 6 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/lock.h" 3
typedef int _LOCK_T;
typedef int _LOCK_RECURSIVE_T;
# 26 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_types.h" 2 3
typedef long __blkcnt_t;
typedef long __blksize_t;
typedef __uint64_t __fsblkcnt_t;
typedef __uint32_t __fsfilcnt_t;
typedef long _off_t;
typedef int __pid_t;
typedef short __dev_t;
typedef unsigned short __uid_t;
typedef unsigned short __gid_t;
typedef __uint32_t __id_t;
typedef unsigned short __ino_t;
# 88 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_types.h" 3
typedef __uint32_t __mode_t;
__extension__ typedef long long _off64_t;
typedef _off_t __off_t;
typedef _off64_t __loff_t;
typedef long __key_t;
typedef long _fpos_t;
# 129 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_types.h" 3
typedef unsigned int __size_t;
# 145 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_types.h" 3
typedef signed int _ssize_t;
# 156 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_types.h" 3
typedef _ssize_t __ssize_t;
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4
# 357 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 3 4
typedef unsigned int wint_t;
# 160 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_types.h" 2 3
typedef struct
{
int __count;
union
{
wint_t __wch;
unsigned char __wchb[4];
} __value;
} _mbstate_t;
typedef _LOCK_RECURSIVE_T _flock_t;
typedef void *_iconv_t;
typedef unsigned long __clock_t;
typedef long __time_t;
typedef unsigned long __clockid_t;
typedef unsigned long __timer_t;
typedef __uint8_t __sa_family_t;
typedef __uint32_t __socklen_t;
typedef unsigned short __nlink_t;
typedef long __suseconds_t;
typedef unsigned long __useconds_t;
typedef __builtin_va_list __va_list;
# 16 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 2 3
typedef unsigned long __ULong;
# 38 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 3
struct _reent;
struct __locale_t;
struct _Bigint
{
struct _Bigint *_next;
int _k, _maxwds, _sign, _wds;
__ULong _x[1];
};
struct __tm
{
int __tm_sec;
int __tm_min;
int __tm_hour;
int __tm_mday;
int __tm_mon;
int __tm_year;
int __tm_wday;
int __tm_yday;
int __tm_isdst;
};
struct _on_exit_args {
void * _fnargs[32];
void * _dso_handle[32];
__ULong _fntypes;
__ULong _is_cxa;
};
# 93 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 3
struct _atexit {
struct _atexit *_next;
int _ind;
void (*_fns[32])(void);
struct _on_exit_args _on_exit_args;
};
# 117 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 3
struct __sbuf {
unsigned char *_base;
int _size;
};
# 181 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 3
struct __sFILE {
unsigned char *_p;
int _r;
int _w;
short _flags;
short _file;
struct __sbuf _bf;
int _lbfsize;
void * _cookie;
int (* _read) (struct _reent *, void *, char *, int)
;
int (* _write) (struct _reent *, void *, const char *, int)
;
_fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int);
int (* _close) (struct _reent *, void *);
struct __sbuf _ub;
unsigned char *_up;
int _ur;
unsigned char _ubuf[3];
unsigned char _nbuf[1];
struct __sbuf _lb;
int _blksize;
_off_t _offset;
struct _reent *_data;
_flock_t _lock;
_mbstate_t _mbstate;
int _flags2;
};
# 287 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 3
typedef struct __sFILE __FILE;
struct _glue
{
struct _glue *_next;
int _niobs;
__FILE *_iobs;
};
# 319 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 3
struct _rand48 {
unsigned short _seed[3];
unsigned short _mult[3];
unsigned short _add;
};
# 569 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 3
struct _reent
{
int _errno;
__FILE *_stdin, *_stdout, *_stderr;
int _inc;
char _emergency[25];
int _unspecified_locale_info;
struct __locale_t *_locale;
int __sdidinit;
void (* __cleanup) (struct _reent *);
struct _Bigint *_result;
int _result_k;
struct _Bigint *_p5s;
struct _Bigint **_freelist;
int _cvtlen;
char *_cvtbuf;
union
{
struct
{
unsigned int _unused_rand;
char * _strtok_last;
char _asctime_buf[26];
struct __tm _localtime_buf;
int _gamma_signgam;
__extension__ unsigned long long _rand_next;
struct _rand48 _r48;
_mbstate_t _mblen_state;
_mbstate_t _mbtowc_state;
_mbstate_t _wctomb_state;
char _l64a_buf[8];
char _signal_buf[24];
int _getdate_err;
_mbstate_t _mbrlen_state;
_mbstate_t _mbrtowc_state;
_mbstate_t _mbsrtowcs_state;
_mbstate_t _wcrtomb_state;
_mbstate_t _wcsrtombs_state;
int _h_errno;
} _reent;
struct
{
unsigned char * _nextf[30];
unsigned int _nmalloc[30];
} _unused;
} _new;
struct _atexit *_atexit;
struct _atexit _atexit0;
void (**(_sig_func))(int);
struct _glue __sglue;
__FILE __sf[3];
};
# 766 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 3
extern struct _reent *_impure_ptr ;
extern struct _reent *const _global_impure_ptr ;
void _reclaim_reent (struct _reent *);
# 19 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdlib.h" 2 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/stdlib.h" 1 3
# 21 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdlib.h" 2 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/alloca.h" 1 3
# 23 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdlib.h" 2 3
# 33 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdlib.h" 3
typedef struct
{
int quot;
int rem;
} div_t;
typedef struct
{
long quot;
long rem;
} ldiv_t;
typedef struct
{
long long int quot;
long long int rem;
} lldiv_t;
typedef int (*__compar_fn_t) (const void *, const void *);
int __locale_mb_cur_max (void);
void abort (void) __attribute__ ((__noreturn__));
int abs (int);
__uint32_t arc4random (void);
__uint32_t arc4random_uniform (__uint32_t);
void arc4random_buf (void *, size_t);
int atexit (void (*__func)(void));
double atof (const char *__nptr);
float atoff (const char *__nptr);
int atoi (const char *__nptr);
int _atoi_r (struct _reent *, const char *__nptr);
long atol (const char *__nptr);
long _atol_r (struct _reent *, const char *__nptr);
void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar)
;
void * calloc (size_t __nmemb, size_t __size) ;
div_t div (int __numer, int __denom);
void exit (int __status) __attribute__ ((__noreturn__));
void free (void *) ;
char * getenv (const char *__string);
char * _getenv_r (struct _reent *, const char *__string);
char * _findenv (const char *, int *);
char * _findenv_r (struct _reent *, const char *, int *);
extern char *suboptarg;
int getsubopt (char **, char * const *, char **);
long labs (long);
ldiv_t ldiv (long __numer, long __denom);
void * malloc (size_t __size) ;
int mblen (const char *, size_t);
int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *);
int mbtowc (wchar_t *restrict, const char *restrict, size_t);
int _mbtowc_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *);
int wctomb (char *, wchar_t);
int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *);
size_t mbstowcs (wchar_t *restrict, const char *restrict, size_t);
size_t _mbstowcs_r (struct _reent *, wchar_t *restrict, const char *restrict, size_t, _mbstate_t *);
size_t wcstombs (char *restrict, const wchar_t *restrict, size_t);
size_t _wcstombs_r (struct _reent *, char *restrict, const wchar_t *restrict, size_t, _mbstate_t *);
char * mkdtemp (char *);
int mkstemp (char *);
int mkstemps (char *, int);
char * mktemp (char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead")));
char * _mkdtemp_r (struct _reent *, char *);
int _mkostemp_r (struct _reent *, char *, int);
int _mkostemps_r (struct _reent *, char *, int, int);
int _mkstemp_r (struct _reent *, char *);
int _mkstemps_r (struct _reent *, char *, int);
char * _mktemp_r (struct _reent *, char *) __attribute__ ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead")));
void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar);
int rand (void);
void * realloc (void * __r, size_t __size) ;
void * reallocf (void * __r, size_t __size);
char * realpath (const char *restrict path, char *restrict resolved_path);
int rpmatch (const char *response);
void srand (unsigned __seed);
double strtod (const char *restrict __n, char **restrict __end_PTR);
double _strtod_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR);
float strtof (const char *restrict __n, char **restrict __end_PTR);
long strtol (const char *restrict __n, char **restrict __end_PTR, int __base);
long _strtol_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base);
unsigned long strtoul (const char *restrict __n, char **restrict __end_PTR, int __base);
unsigned long _strtoul_r (struct _reent *,const char *restrict __n, char **restrict __end_PTR, int __base);
# 186 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdlib.h" 3
int system (const char *__string);
long a64l (const char *__input);
char * l64a (long __input);
char * _l64a_r (struct _reent *,long __input);
int on_exit (void (*__func)(int, void *),void * __arg);
void _Exit (int __status) __attribute__ ((__noreturn__));
int putenv (char *__string);
int _putenv_r (struct _reent *, char *__string);
void * _reallocf_r (struct _reent *, void *, size_t);
int setenv (const char *__string, const char *__value, int __overwrite);
int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite);
# 219 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdlib.h" 3
char * __itoa (int, char *, int);
char * __utoa (unsigned, char *, int);
char * itoa (int, char *, int);
char * utoa (unsigned, char *, int);
int rand_r (unsigned *__seed);
double drand48 (void);
double _drand48_r (struct _reent *);
double erand48 (unsigned short [3]);
double _erand48_r (struct _reent *, unsigned short [3]);
long jrand48 (unsigned short [3]);
long _jrand48_r (struct _reent *, unsigned short [3]);
void lcong48 (unsigned short [7]);
void _lcong48_r (struct _reent *, unsigned short [7]);
long lrand48 (void);
long _lrand48_r (struct _reent *);
long mrand48 (void);
long _mrand48_r (struct _reent *);
long nrand48 (unsigned short [3]);
long _nrand48_r (struct _reent *, unsigned short [3]);
unsigned short *
seed48 (unsigned short [3]);
unsigned short *
_seed48_r (struct _reent *, unsigned short [3]);
void srand48 (long);
void _srand48_r (struct _reent *, long);
char * initstate (unsigned, char *, size_t);
long random (void);
char * setstate (char *);
void srandom (unsigned);
long long atoll (const char *__nptr);
long long _atoll_r (struct _reent *, const char *__nptr);
long long llabs (long long);
lldiv_t lldiv (long long __numer, long long __denom);
long long strtoll (const char *restrict __n, char **restrict __end_PTR, int __base);
long long _strtoll_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base);
unsigned long long strtoull (const char *restrict __n, char **restrict __end_PTR, int __base);
unsigned long long _strtoull_r (struct _reent *, const char *restrict __n, char **restrict __end_PTR, int __base);
void cfree (void *);
int unsetenv (const char *__string);
int _unsetenv_r (struct _reent *, const char *__string);
int __attribute__((__nonnull__(1))) posix_memalign (void **, size_t, size_t);
char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**);
void * _malloc_r (struct _reent *, size_t) ;
void * _calloc_r (struct _reent *, size_t, size_t) ;
void _free_r (struct _reent *, void *) ;
void * _realloc_r (struct _reent *, void *, size_t) ;
void _mstats_r (struct _reent *, char *);
int _system_r (struct _reent *, const char *);
void __eprintf (const char *, const char *, unsigned int, const char *);
# 306 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdlib.h" 3
void qsort_r (void * __base, size_t __nmemb, size_t __size, void * __thunk, int (*_compar)(void *, const void *, const void *))
__asm__ ("" "__bsd_qsort_r");
# 316 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdlib.h" 3
extern long double _strtold_r (struct _reent *, const char *restrict, char **restrict);
extern long double strtold (const char *restrict, char **restrict);
void * aligned_alloc(size_t, size_t) __attribute__((__malloc__)) __attribute__((__alloc_align__(1)))
__attribute__((__alloc_size__(2)));
int at_quick_exit(void (*)(void));
_Noreturn void
quick_exit(int);
# 9 "./security/mbedtls/include/mbedtls/platform_alt.h" 2
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/time.h" 1 3
# 16 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/time.h" 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4
# 17 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/time.h" 2 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/time.h" 1 3
# 20 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/time.h" 2 3
# 28 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/time.h" 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/types.h" 1 3
# 28 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/types.h" 3
typedef __uint8_t u_int8_t;
typedef __uint16_t u_int16_t;
typedef __uint32_t u_int32_t;
typedef __uint64_t u_int64_t;
typedef int register_t;
# 62 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/types.h" 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4
# 63 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/types.h" 2 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_stdint.h" 1 3
# 20 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_stdint.h" 3
typedef __int8_t int8_t ;
typedef __uint8_t uint8_t ;
typedef __int16_t int16_t ;
typedef __uint16_t uint16_t ;
typedef __int32_t int32_t ;
typedef __uint32_t uint32_t ;
typedef __int64_t int64_t ;
typedef __uint64_t uint64_t ;
typedef __intptr_t intptr_t;
typedef __uintptr_t uintptr_t;
# 65 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/types.h" 2 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/endian.h" 1 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_endian.h" 1 3
# 7 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/endian.h" 2 3
# 68 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/types.h" 2 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/select.h" 1 3
# 25 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/select.h" 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_sigset.h" 1 3
# 41 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_sigset.h" 3
typedef unsigned long __sigset_t;
# 26 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/select.h" 2 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_timeval.h" 1 3
# 35 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_timeval.h" 3
typedef __suseconds_t suseconds_t;
typedef long time_t;
# 52 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_timeval.h" 3
struct timeval {
time_t tv_sec;
suseconds_t tv_usec;
};
# 27 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/select.h" 2 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/timespec.h" 1 3
# 38 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/timespec.h" 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_timespec.h" 1 3
# 45 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_timespec.h" 3
struct timespec {
time_t tv_sec;
long tv_nsec;
};
# 39 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/timespec.h" 2 3
# 58 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/timespec.h" 3
struct itimerspec {
struct timespec it_interval;
struct timespec it_value;
};
# 28 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/select.h" 2 3
typedef __sigset_t sigset_t;
# 45 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/select.h" 3
typedef unsigned long fd_mask;
typedef struct _types_fd_set {
fd_mask fds_bits[(((64)+(((sizeof (fd_mask) * 8))-1))/((sizeof (fd_mask) * 8)))];
} _types_fd_set;
# 71 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/select.h" 3
int select (int __n, _types_fd_set *__readfds, _types_fd_set *__writefds, _types_fd_set *__exceptfds, struct timeval *__timeout)
;
int pselect (int __n, _types_fd_set *__readfds, _types_fd_set *__writefds, _types_fd_set *__exceptfds, const struct timespec *__timeout, const sigset_t *__set)
;
# 69 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/types.h" 2 3
typedef __uint32_t in_addr_t;
typedef __uint16_t in_port_t;
# 87 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/types.h" 3
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef __blkcnt_t blkcnt_t;
typedef __blksize_t blksize_t;
typedef unsigned long clock_t;
# 135 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/types.h" 3
typedef long daddr_t;
typedef char * caddr_t;
typedef __fsblkcnt_t fsblkcnt_t;
typedef __fsfilcnt_t fsfilcnt_t;
typedef __id_t id_t;
typedef __ino_t ino_t;
# 173 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/types.h" 3
typedef __off_t off_t;
typedef __dev_t dev_t;
typedef __uid_t uid_t;
typedef __gid_t gid_t;
typedef __pid_t pid_t;
typedef __key_t key_t;
typedef _ssize_t ssize_t;
typedef __mode_t mode_t;
typedef __nlink_t nlink_t;
typedef __clockid_t clockid_t;
typedef __timer_t timer_t;
typedef __useconds_t useconds_t;
# 236 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/types.h" 3
typedef __int64_t sbintime_t;
# 465 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/types.h" 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/types.h" 1 3
# 466 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/types.h" 2 3
# 29 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/time.h" 2 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_locale.h" 1 3
# 9 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_locale.h" 3
struct __locale_t;
typedef struct __locale_t *locale_t;
# 33 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/time.h" 2 3
struct tm
{
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
};
clock_t clock (void);
double difftime (time_t _time2, time_t _time1);
time_t mktime (struct tm *_timeptr);
time_t time (time_t *_timer);
char *asctime (const struct tm *_tblock);
char *ctime (const time_t *_time);
struct tm *gmtime (const time_t *_timer);
struct tm *localtime (const time_t *_timer);
size_t strftime (char *restrict _s, size_t _maxsize, const char *restrict _fmt, const struct tm *restrict _t)
;
extern size_t strftime_l (char *restrict _s, size_t _maxsize,
const char *restrict _fmt,
const struct tm *restrict _t, locale_t _l);
char *asctime_r (const struct tm *restrict, char *restrict)
;
char *ctime_r (const time_t *, char *);
struct tm *gmtime_r (const time_t *restrict, struct tm *restrict)
;
struct tm *localtime_r (const time_t *restrict, struct tm *restrict)
;
# 101 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/time.h" 3
void tzset (void);
void _tzset_r (struct _reent *);
typedef struct __tzrule_struct
{
char ch;
int m;
int n;
int d;
int s;
time_t change;
long offset;
} __tzrule_type;
typedef struct __tzinfo_struct
{
int __tznorth;
int __tzyear;
__tzrule_type __tzrule[2];
} __tzinfo_type;
__tzinfo_type *__gettzinfo (void);
# 154 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/time.h" 3
extern long _timezone;
extern int _daylight;
extern char *_tzname[2];
# 10 "./security/mbedtls/include/mbedtls/platform_alt.h" 2
# 18 "./security/mbedtls/include/mbedtls/platform_alt.h"
# 18 "./security/mbedtls/include/mbedtls/platform_alt.h"
typedef time_t mbedtls_time_t;
void *mbedtls_calloc( size_t n, size_t size );
void mbedtls_free( void *ptr );
# 300 "./security/mbedtls/include/mbedtls/platform.h" 2
# 36 "security/mbedtls/src/ssl_cookie.c" 2
# 1 "./security/mbedtls/include/mbedtls/ssl_cookie.h" 1
# 26 "./security/mbedtls/include/mbedtls/ssl_cookie.h"
# 1 "./security/mbedtls/include/mbedtls/ssl.h" 1
# 32 "./security/mbedtls/include/mbedtls/ssl.h"
# 1 "./security/mbedtls/include/mbedtls/bignum.h" 1
# 32 "./security/mbedtls/include/mbedtls/bignum.h"
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4
# 33 "./security/mbedtls/include/mbedtls/bignum.h" 2
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stdint.h" 1 3 4
# 9 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stdint.h" 3 4
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdint.h" 1 3 4
# 13 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdint.h" 3 4
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_intsup.h" 1 3 4
# 49 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_intsup.h" 3 4
# 201 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_intsup.h" 3 4
# 14 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdint.h" 2 3 4
# 21 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdint.h" 3 4
typedef __int_least8_t int_least8_t;
typedef __uint_least8_t uint_least8_t;
typedef __int_least16_t int_least16_t;
typedef __uint_least16_t uint_least16_t;
typedef __int_least32_t int_least32_t;
typedef __uint_least32_t uint_least32_t;
typedef __int_least64_t int_least64_t;
typedef __uint_least64_t uint_least64_t;
# 51 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdint.h" 3 4
typedef int int_fast8_t;
typedef unsigned int uint_fast8_t;
# 61 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdint.h" 3 4
typedef int int_fast16_t;
typedef unsigned int uint_fast16_t;
# 71 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdint.h" 3 4
typedef int int_fast32_t;
typedef unsigned int uint_fast32_t;
# 81 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdint.h" 3 4
typedef long long int int_fast64_t;
typedef long long unsigned int uint_fast64_t;
# 130 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdint.h" 3 4
typedef long long int intmax_t;
# 139 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdint.h" 3 4
typedef long long unsigned int uintmax_t;
# 10 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stdint.h" 2 3 4
# 34 "./security/mbedtls/include/mbedtls/bignum.h" 2
# 130 "./security/mbedtls/include/mbedtls/bignum.h"
# 130 "./security/mbedtls/include/mbedtls/bignum.h"
typedef int32_t mbedtls_mpi_sint;
typedef uint32_t mbedtls_mpi_uint;
typedef uint64_t mbedtls_t_udbl;
# 144 "./security/mbedtls/include/mbedtls/bignum.h"
typedef struct
{
int s;
size_t n;
mbedtls_mpi_uint *p;
}
mbedtls_mpi;
# 159 "./security/mbedtls/include/mbedtls/bignum.h"
void mbedtls_mpi_init( mbedtls_mpi *X );
void mbedtls_mpi_free( mbedtls_mpi *X );
# 177 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_grow( mbedtls_mpi *X, size_t nblimbs );
# 188 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_shrink( mbedtls_mpi *X, size_t nblimbs );
# 199 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_copy( mbedtls_mpi *X, const mbedtls_mpi *Y );
void mbedtls_mpi_swap( mbedtls_mpi *X, mbedtls_mpi *Y );
# 226 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_safe_cond_assign( mbedtls_mpi *X, const mbedtls_mpi *Y, unsigned char assign );
# 245 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_safe_cond_swap( mbedtls_mpi *X, mbedtls_mpi *Y, unsigned char assign );
# 256 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_lset( mbedtls_mpi *X, mbedtls_mpi_sint z );
# 266 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_get_bit( const mbedtls_mpi *X, size_t pos );
# 282 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_set_bit( mbedtls_mpi *X, size_t pos, unsigned char val );
# 292 "./security/mbedtls/include/mbedtls/bignum.h"
size_t mbedtls_mpi_lsb( const mbedtls_mpi *X );
# 302 "./security/mbedtls/include/mbedtls/bignum.h"
size_t mbedtls_mpi_bitlen( const mbedtls_mpi *X );
size_t mbedtls_mpi_size( const mbedtls_mpi *X );
# 320 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_read_string( mbedtls_mpi *X, int radix, const char *s );
# 338 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_write_string( const mbedtls_mpi *X, int radix,
char *buf, size_t buflen, size_t *olen );
# 380 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_read_binary( mbedtls_mpi *X, const unsigned char *buf, size_t buflen );
# 394 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_write_binary( const mbedtls_mpi *X, unsigned char *buf, size_t buflen );
# 405 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_shift_l( mbedtls_mpi *X, size_t count );
# 416 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_shift_r( mbedtls_mpi *X, size_t count );
# 428 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_cmp_abs( const mbedtls_mpi *X, const mbedtls_mpi *Y );
# 440 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_cmp_mpi( const mbedtls_mpi *X, const mbedtls_mpi *Y );
# 452 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_cmp_int( const mbedtls_mpi *X, mbedtls_mpi_sint z );
# 464 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_add_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B );
# 476 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_sub_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B );
# 488 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_add_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B );
# 500 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_sub_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B );
# 512 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_add_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint b );
# 524 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_sub_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint b );
# 536 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_mul_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B );
# 550 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_mul_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_uint b );
# 566 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_div_mpi( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, const mbedtls_mpi *B );
# 582 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_div_int( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, mbedtls_mpi_sint b );
# 596 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_mod_mpi( mbedtls_mpi *R, const mbedtls_mpi *A, const mbedtls_mpi *B );
# 610 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_mod_int( mbedtls_mpi_uint *r, const mbedtls_mpi *A, mbedtls_mpi_sint b );
# 630 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *E, const mbedtls_mpi *N, mbedtls_mpi *_RR );
# 643 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_fill_random( mbedtls_mpi *X, size_t size,
int (*f_rng)(void *, unsigned char *, size_t),
void *p_rng );
# 657 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_gcd( mbedtls_mpi *G, const mbedtls_mpi *A, const mbedtls_mpi *B );
# 671 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_inv_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *N );
# 684 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_is_prime( const mbedtls_mpi *X,
int (*f_rng)(void *, unsigned char *, size_t),
void *p_rng );
# 702 "./security/mbedtls/include/mbedtls/bignum.h"
int mbedtls_mpi_gen_prime( mbedtls_mpi *X, size_t nbits, int dh_flag,
int (*f_rng)(void *, unsigned char *, size_t),
void *p_rng );
int mbedtls_mpi_self_test( int verbose );
# 33 "./security/mbedtls/include/mbedtls/ssl.h" 2
# 1 "./security/mbedtls/include/mbedtls/ecp.h" 1
# 62 "./security/mbedtls/include/mbedtls/ecp.h"
typedef enum
{
MBEDTLS_ECP_DP_NONE = 0,
MBEDTLS_ECP_DP_SECP192R1,
MBEDTLS_ECP_DP_SECP224R1,
MBEDTLS_ECP_DP_SECP256R1,
MBEDTLS_ECP_DP_SECP384R1,
MBEDTLS_ECP_DP_SECP521R1,
MBEDTLS_ECP_DP_BP256R1,
MBEDTLS_ECP_DP_BP384R1,
MBEDTLS_ECP_DP_BP512R1,
MBEDTLS_ECP_DP_CURVE25519,
MBEDTLS_ECP_DP_SECP192K1,
MBEDTLS_ECP_DP_SECP224K1,
MBEDTLS_ECP_DP_SECP256K1,
} mbedtls_ecp_group_id;
# 89 "./security/mbedtls/include/mbedtls/ecp.h"
typedef struct
{
mbedtls_ecp_group_id grp_id;
uint16_t tls_id;
uint16_t bit_size;
const char *name;
} mbedtls_ecp_curve_info;
# 106 "./security/mbedtls/include/mbedtls/ecp.h"
typedef struct
{
mbedtls_mpi X;
mbedtls_mpi Y;
mbedtls_mpi Z;
}
mbedtls_ecp_point;
# 138 "./security/mbedtls/include/mbedtls/ecp.h"
typedef struct
{
mbedtls_ecp_group_id id;
mbedtls_mpi P;
mbedtls_mpi A;
mbedtls_mpi B;
mbedtls_ecp_point G;
mbedtls_mpi N;
size_t pbits;
size_t nbits;
unsigned int h;
int (*modp)(mbedtls_mpi *);
int (*t_pre)(mbedtls_ecp_point *, void *);
int (*t_post)(mbedtls_ecp_point *, void *);
void *t_data;
mbedtls_ecp_point *T;
size_t T_size;
}
mbedtls_ecp_group;
# 165 "./security/mbedtls/include/mbedtls/ecp.h"
typedef struct
{
mbedtls_ecp_group grp;
mbedtls_mpi d;
mbedtls_ecp_point Q;
}
mbedtls_ecp_keypair;
# 249 "./security/mbedtls/include/mbedtls/ecp.h"
const mbedtls_ecp_curve_info *mbedtls_ecp_curve_list( void );
# 258 "./security/mbedtls/include/mbedtls/ecp.h"
const mbedtls_ecp_group_id *mbedtls_ecp_grp_id_list( void );
# 267 "./security/mbedtls/include/mbedtls/ecp.h"
const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_grp_id( mbedtls_ecp_group_id grp_id );
# 276 "./security/mbedtls/include/mbedtls/ecp.h"
const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_tls_id( uint16_t tls_id );
# 285 "./security/mbedtls/include/mbedtls/ecp.h"
const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_name( const char *name );
void mbedtls_ecp_point_init( mbedtls_ecp_point *pt );
void mbedtls_ecp_group_init( mbedtls_ecp_group *grp );
void mbedtls_ecp_keypair_init( mbedtls_ecp_keypair *key );
void mbedtls_ecp_point_free( mbedtls_ecp_point *pt );
void mbedtls_ecp_group_free( mbedtls_ecp_group *grp );
void mbedtls_ecp_keypair_free( mbedtls_ecp_keypair *key );
# 326 "./security/mbedtls/include/mbedtls/ecp.h"
int mbedtls_ecp_copy( mbedtls_ecp_point *P, const mbedtls_ecp_point *Q );
# 337 "./security/mbedtls/include/mbedtls/ecp.h"
int mbedtls_ecp_group_copy( mbedtls_ecp_group *dst, const mbedtls_ecp_group *src );
# 347 "./security/mbedtls/include/mbedtls/ecp.h"
int mbedtls_ecp_set_zero( mbedtls_ecp_point *pt );
# 356 "./security/mbedtls/include/mbedtls/ecp.h"
int mbedtls_ecp_is_zero( mbedtls_ecp_point *pt );
# 370 "./security/mbedtls/include/mbedtls/ecp.h"
int mbedtls_ecp_point_cmp( const mbedtls_ecp_point *P,
const mbedtls_ecp_point *Q );
# 383 "./security/mbedtls/include/mbedtls/ecp.h"
int mbedtls_ecp_point_read_string( mbedtls_ecp_point *P, int radix,
const char *x, const char *y );
# 400 "./security/mbedtls/include/mbedtls/ecp.h"
int mbedtls_ecp_point_write_binary( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *P,
int format, size_t *olen,
unsigned char *buf, size_t buflen );
# 422 "./security/mbedtls/include/mbedtls/ecp.h"
int mbedtls_ecp_point_read_binary( const mbedtls_ecp_group *grp, mbedtls_ecp_point *P,
const unsigned char *buf, size_t ilen );
# 439 "./security/mbedtls/include/mbedtls/ecp.h"
int mbedtls_ecp_tls_read_point( const mbedtls_ecp_group *grp, mbedtls_ecp_point *pt,
const unsigned char **buf, size_t len );
# 456 "./security/mbedtls/include/mbedtls/ecp.h"
int mbedtls_ecp_tls_write_point( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt,
int format, size_t *olen,
unsigned char *buf, size_t blen );
# 473 "./security/mbedtls/include/mbedtls/ecp.h"
int mbedtls_ecp_group_load( mbedtls_ecp_group *grp, mbedtls_ecp_group_id index );
# 488 "./security/mbedtls/include/mbedtls/ecp.h"
int mbedtls_ecp_tls_read_group( mbedtls_ecp_group *grp, const unsigned char **buf, size_t len );
# 501 "./security/mbedtls/include/mbedtls/ecp.h"
int mbedtls_ecp_tls_write_group( const mbedtls_ecp_group *grp, size_t *olen,
unsigned char *buf, size_t blen );
# 530 "./security/mbedtls/include/mbedtls/ecp.h"
int mbedtls_ecp_mul( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
const mbedtls_mpi *m, const mbedtls_ecp_point *P,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
# 554 "./security/mbedtls/include/mbedtls/ecp.h"
int mbedtls_ecp_muladd( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
const mbedtls_mpi *m, const mbedtls_ecp_point *P,
const mbedtls_mpi *n, const mbedtls_ecp_point *Q );
# 579 "./security/mbedtls/include/mbedtls/ecp.h"
int mbedtls_ecp_check_pubkey( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt );
# 594 "./security/mbedtls/include/mbedtls/ecp.h"
int mbedtls_ecp_check_privkey( const mbedtls_ecp_group *grp, const mbedtls_mpi *d );
# 613 "./security/mbedtls/include/mbedtls/ecp.h"
int mbedtls_ecp_gen_keypair_base( mbedtls_ecp_group *grp,
const mbedtls_ecp_point *G,
mbedtls_mpi *d, mbedtls_ecp_point *Q,
int (*f_rng)(void *, unsigned char *, size_t),
void *p_rng );
# 635 "./security/mbedtls/include/mbedtls/ecp.h"
int mbedtls_ecp_gen_keypair( mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp_point *Q,
int (*f_rng)(void *, unsigned char *, size_t),
void *p_rng );
# 650 "./security/mbedtls/include/mbedtls/ecp.h"
int mbedtls_ecp_gen_key( mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
# 663 "./security/mbedtls/include/mbedtls/ecp.h"
int mbedtls_ecp_check_pub_priv( const mbedtls_ecp_keypair *pub, const mbedtls_ecp_keypair *prv );
# 34 "./security/mbedtls/include/mbedtls/ssl.h" 2
# 1 "./security/mbedtls/include/mbedtls/ssl_ciphersuites.h" 1
# 26 "./security/mbedtls/include/mbedtls/ssl_ciphersuites.h"
# 1 "./security/mbedtls/include/mbedtls/pk.h" 1
# 33 "./security/mbedtls/include/mbedtls/pk.h"
# 1 "./security/mbedtls/include/mbedtls/md.h" 1
# 28 "./security/mbedtls/include/mbedtls/md.h"
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4
# 29 "./security/mbedtls/include/mbedtls/md.h" 2
# 39 "./security/mbedtls/include/mbedtls/md.h"
typedef enum {
MBEDTLS_MD_NONE=0,
MBEDTLS_MD_MD2,
MBEDTLS_MD_MD4,
MBEDTLS_MD_MD5,
MBEDTLS_MD_SHA1,
MBEDTLS_MD_SHA224,
MBEDTLS_MD_SHA256,
MBEDTLS_MD_SHA384,
MBEDTLS_MD_SHA512,
MBEDTLS_MD_RIPEMD160,
} mbedtls_md_type_t;
# 61 "./security/mbedtls/include/mbedtls/md.h"
typedef struct mbedtls_md_info_t mbedtls_md_info_t;
typedef struct {
const mbedtls_md_info_t *md_info;
void *md_ctx;
void *hmac_ctx;
} mbedtls_md_context_t;
const int *mbedtls_md_list( void );
# 94 "./security/mbedtls/include/mbedtls/md.h"
const mbedtls_md_info_t *mbedtls_md_info_from_string( const char *md_name );
# 105 "./security/mbedtls/include/mbedtls/md.h"
const mbedtls_md_info_t *mbedtls_md_info_from_type( mbedtls_md_type_t md_type );
void mbedtls_md_init( mbedtls_md_context_t *ctx );
void mbedtls_md_free( mbedtls_md_context_t *ctx );
# 141 "./security/mbedtls/include/mbedtls/md.h"
int mbedtls_md_init_ctx( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info ) ;
# 159 "./security/mbedtls/include/mbedtls/md.h"
int mbedtls_md_setup( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac );
# 175 "./security/mbedtls/include/mbedtls/md.h"
int mbedtls_md_clone( mbedtls_md_context_t *dst,
const mbedtls_md_context_t *src );
# 185 "./security/mbedtls/include/mbedtls/md.h"
unsigned char mbedtls_md_get_size( const mbedtls_md_info_t *md_info );
# 194 "./security/mbedtls/include/mbedtls/md.h"
mbedtls_md_type_t mbedtls_md_get_type( const mbedtls_md_info_t *md_info );
# 203 "./security/mbedtls/include/mbedtls/md.h"
const char *mbedtls_md_get_name( const mbedtls_md_info_t *md_info );
# 215 "./security/mbedtls/include/mbedtls/md.h"
int mbedtls_md_starts( mbedtls_md_context_t *ctx );
# 229 "./security/mbedtls/include/mbedtls/md.h"
int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen );
# 242 "./security/mbedtls/include/mbedtls/md.h"
int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output );
# 255 "./security/mbedtls/include/mbedtls/md.h"
int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen,
unsigned char *output );
# 285 "./security/mbedtls/include/mbedtls/md.h"
int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key,
size_t keylen );
# 301 "./security/mbedtls/include/mbedtls/md.h"
int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *input,
size_t ilen );
# 316 "./security/mbedtls/include/mbedtls/md.h"
int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output);
# 328 "./security/mbedtls/include/mbedtls/md.h"
int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx );
# 343 "./security/mbedtls/include/mbedtls/md.h"
int mbedtls_md_hmac( const mbedtls_md_info_t *md_info, const unsigned char *key, size_t keylen,
const unsigned char *input, size_t ilen,
unsigned char *output );
int mbedtls_md_process( mbedtls_md_context_t *ctx, const unsigned char *data );
# 34 "./security/mbedtls/include/mbedtls/pk.h" 2
# 1 "./security/mbedtls/include/mbedtls/rsa.h" 1
# 655 "./security/mbedtls/include/mbedtls/rsa.h"
# 1 "./security/mbedtls/include/mbedtls/rsa_alt.h" 1
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdio.h" 1 3
# 36 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdio.h" 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4
# 37 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdio.h" 2 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stdarg.h" 1 3 4
# 40 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stdarg.h" 3 4
# 40 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stdarg.h" 3 4
typedef __builtin_va_list __gnuc_va_list;
# 41 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdio.h" 2 3
typedef __gnuc_va_list va_list;
# 63 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdio.h" 3
typedef __FILE FILE;
typedef _fpos_t fpos_t;
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/stdio.h" 1 3
# 80 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdio.h" 2 3
# 181 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdio.h" 3
char * ctermid (char *);
FILE * tmpfile (void);
char * tmpnam (char *);
char * tempnam (const char *, const char *);
int fclose (FILE *);
int fflush (FILE *);
FILE * freopen (const char *restrict, const char *restrict, FILE *restrict);
void setbuf (FILE *restrict, char *restrict);
int setvbuf (FILE *restrict, char *restrict, int, size_t);
int fprintf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3)))
;
int fscanf (FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3)))
;
int printf (const char *restrict, ...) __attribute__ ((__format__ (__printf__, 1, 2)))
;
int scanf (const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 1, 2)))
;
int sscanf (const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3)))
;
int vfprintf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0)))
;
int vprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0)))
;
int vsprintf (char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0)))
;
int fgetc (FILE *);
char * fgets (char *restrict, int, FILE *restrict);
int fputc (int, FILE *);
int fputs (const char *restrict, FILE *restrict);
int getc (FILE *);
int getchar (void);
char * gets (char *);
int putc (int, FILE *);
int putchar (int);
int puts (const char *);
int ungetc (int, FILE *);
size_t fread (void * restrict, size_t _size, size_t _n, FILE *restrict);
size_t fwrite (const void * restrict , size_t _size, size_t _n, FILE *);
int fgetpos (FILE *restrict, fpos_t *restrict);
int fseek (FILE *, long, int);
int fsetpos (FILE *, const fpos_t *);
long ftell ( FILE *);
void rewind (FILE *);
void clearerr (FILE *);
int feof (FILE *);
int ferror (FILE *);
void perror (const char *);
FILE * fopen (const char *restrict _name, const char *restrict _type);
int sprintf (char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3)))
;
int remove (const char *);
int rename (const char *, const char *);
# 257 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdio.h" 3
int fseeko (FILE *, off_t, int);
off_t ftello ( FILE *);
int snprintf (char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4)))
;
int vsnprintf (char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0)))
;
int vfscanf (FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0)))
;
int vscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0)))
;
int vsscanf (const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0)))
;
# 284 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdio.h" 3
int asiprintf (char **, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3)))
;
char * asniprintf (char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4)))
;
char * asnprintf (char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4)))
;
int diprintf (int, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3)))
;
int fiprintf (FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3)))
;
int fiscanf (FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3)))
;
int iprintf (const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)))
;
int iscanf (const char *, ...) __attribute__ ((__format__ (__scanf__, 1, 2)))
;
int siprintf (char *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3)))
;
int siscanf (const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3)))
;
int sniprintf (char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4)))
;
int vasiprintf (char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0)))
;
char * vasniprintf (char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0)))
;
char * vasnprintf (char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0)))
;
int vdiprintf (int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0)))
;
int vfiprintf (FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0)))
;
int vfiscanf (FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0)))
;
int viprintf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 1, 0)))
;
int viscanf (const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 1, 0)))
;
int vsiprintf (char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0)))
;
int vsiscanf (const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0)))
;
int vsniprintf (char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0)))
;
# 339 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdio.h" 3
FILE * fdopen (int, const char *);
int fileno (FILE *);
int pclose (FILE *);
FILE * popen (const char *, const char *);
void setbuffer (FILE *, char *, int);
int setlinebuf (FILE *);
int getw (FILE *);
int putw (int, FILE *);
int getc_unlocked (FILE *);
int getchar_unlocked (void);
void flockfile (FILE *);
int ftrylockfile (FILE *);
void funlockfile (FILE *);
int putc_unlocked (int, FILE *);
int putchar_unlocked (int);
# 374 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdio.h" 3
int dprintf (int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3)))
;
FILE * fmemopen (void *restrict, size_t, const char *restrict);
FILE * open_memstream (char **, size_t *);
int vdprintf (int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0)))
;
int renameat (int, const char *, int, const char *);
int _asiprintf_r (struct _reent *, char **, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4)))
;
char * _asniprintf_r (struct _reent *, char *, size_t *, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5)))
;
char * _asnprintf_r (struct _reent *, char *restrict, size_t *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5)))
;
int _asprintf_r (struct _reent *, char **restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4)))
;
int _diprintf_r (struct _reent *, int, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4)))
;
int _dprintf_r (struct _reent *, int, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4)))
;
int _fclose_r (struct _reent *, FILE *);
int _fcloseall_r (struct _reent *);
FILE * _fdopen_r (struct _reent *, int, const char *);
int _fflush_r (struct _reent *, FILE *);
int _fgetc_r (struct _reent *, FILE *);
int _fgetc_unlocked_r (struct _reent *, FILE *);
char * _fgets_r (struct _reent *, char *restrict, int, FILE *restrict);
char * _fgets_unlocked_r (struct _reent *, char *restrict, int, FILE *restrict);
int _fgetpos_r (struct _reent *, FILE *, fpos_t *);
int _fsetpos_r (struct _reent *, FILE *, const fpos_t *);
int _fiprintf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4)))
;
int _fiscanf_r (struct _reent *, FILE *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4)))
;
FILE * _fmemopen_r (struct _reent *, void *restrict, size_t, const char *restrict);
FILE * _fopen_r (struct _reent *, const char *restrict, const char *restrict);
FILE * _freopen_r (struct _reent *, const char *restrict, const char *restrict, FILE *restrict);
int _fprintf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4)))
;
int _fpurge_r (struct _reent *, FILE *);
int _fputc_r (struct _reent *, int, FILE *);
int _fputc_unlocked_r (struct _reent *, int, FILE *);
int _fputs_r (struct _reent *, const char *restrict, FILE *restrict);
int _fputs_unlocked_r (struct _reent *, const char *restrict, FILE *restrict);
size_t _fread_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict);
size_t _fread_unlocked_r (struct _reent *, void * restrict, size_t _size, size_t _n, FILE *restrict);
int _fscanf_r (struct _reent *, FILE *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4)))
;
int _fseek_r (struct _reent *, FILE *, long, int);
int _fseeko_r (struct _reent *, FILE *, _off_t, int);
long _ftell_r (struct _reent *, FILE *);
_off_t _ftello_r (struct _reent *, FILE *);
void _rewind_r (struct _reent *, FILE *);
size_t _fwrite_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict);
size_t _fwrite_unlocked_r (struct _reent *, const void * restrict, size_t _size, size_t _n, FILE *restrict);
int _getc_r (struct _reent *, FILE *);
int _getc_unlocked_r (struct _reent *, FILE *);
int _getchar_r (struct _reent *);
int _getchar_unlocked_r (struct _reent *);
char * _gets_r (struct _reent *, char *);
int _iprintf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__printf__, 2, 3)))
;
int _iscanf_r (struct _reent *, const char *, ...) __attribute__ ((__format__ (__scanf__, 2, 3)))
;
FILE * _open_memstream_r (struct _reent *, char **, size_t *);
void _perror_r (struct _reent *, const char *);
int _printf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3)))
;
int _putc_r (struct _reent *, int, FILE *);
int _putc_unlocked_r (struct _reent *, int, FILE *);
int _putchar_unlocked_r (struct _reent *, int);
int _putchar_r (struct _reent *, int);
int _puts_r (struct _reent *, const char *);
int _remove_r (struct _reent *, const char *);
int _rename_r (struct _reent *, const char *_old, const char *_new)
;
int _scanf_r (struct _reent *, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 2, 3)))
;
int _siprintf_r (struct _reent *, char *, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4)))
;
int _siscanf_r (struct _reent *, const char *, const char *, ...) __attribute__ ((__format__ (__scanf__, 3, 4)))
;
int _sniprintf_r (struct _reent *, char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 4, 5)))
;
int _snprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 4, 5)))
;
int _sprintf_r (struct _reent *, char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__printf__, 3, 4)))
;
int _sscanf_r (struct _reent *, const char *restrict, const char *restrict, ...) __attribute__ ((__format__ (__scanf__, 3, 4)))
;
char * _tempnam_r (struct _reent *, const char *, const char *);
FILE * _tmpfile_r (struct _reent *);
char * _tmpnam_r (struct _reent *, char *);
int _ungetc_r (struct _reent *, int, FILE *);
int _vasiprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0)))
;
char * _vasniprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0)))
;
char * _vasnprintf_r (struct _reent*, char *, size_t *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0)))
;
int _vasprintf_r (struct _reent *, char **, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0)))
;
int _vdiprintf_r (struct _reent *, int, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0)))
;
int _vdprintf_r (struct _reent *, int, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0)))
;
int _vfiprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0)))
;
int _vfiscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0)))
;
int _vfprintf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0)))
;
int _vfscanf_r (struct _reent *, FILE *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0)))
;
int _viprintf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0)))
;
int _viscanf_r (struct _reent *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0)))
;
int _vprintf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 2, 0)))
;
int _vscanf_r (struct _reent *, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 2, 0)))
;
int _vsiprintf_r (struct _reent *, char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0)))
;
int _vsiscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0)))
;
int _vsniprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0)))
;
int _vsnprintf_r (struct _reent *, char *restrict, size_t, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 4, 0)))
;
int _vsprintf_r (struct _reent *, char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__printf__, 3, 0)))
;
int _vsscanf_r (struct _reent *, const char *restrict, const char *restrict, __gnuc_va_list) __attribute__ ((__format__ (__scanf__, 3, 0)))
;
int fpurge (FILE *);
ssize_t __getdelim (char **, size_t *, int, FILE *);
ssize_t __getline (char **, size_t *, FILE *);
void clearerr_unlocked (FILE *);
int feof_unlocked (FILE *);
int ferror_unlocked (FILE *);
int fileno_unlocked (FILE *);
int fflush_unlocked (FILE *);
int fgetc_unlocked (FILE *);
int fputc_unlocked (int, FILE *);
size_t fread_unlocked (void * restrict, size_t _size, size_t _n, FILE *restrict);
size_t fwrite_unlocked (const void * restrict , size_t _size, size_t _n, FILE *);
# 574 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdio.h" 3
int __srget_r (struct _reent *, FILE *);
int __swbuf_r (struct _reent *, int, FILE *);
# 598 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdio.h" 3
FILE *funopen (const void * __cookie, int (*__readfn)(void * __cookie, char *__buf, int __n), int (*__writefn)(void * __cookie, const char *__buf, int __n), fpos_t (*__seekfn)(void * __cookie, fpos_t __off, int __whence), int (*__closefn)(void * __cookie))
;
FILE *_funopen_r (struct _reent *, const void * __cookie, int (*__readfn)(void * __cookie, char *__buf, int __n), int (*__writefn)(void * __cookie, const char *__buf, int __n), fpos_t (*__seekfn)(void * __cookie, fpos_t __off, int __whence), int (*__closefn)(void * __cookie))
;
# 684 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdio.h" 3
static __inline__ int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
return (*_p->_p++ = _c);
else
return (__swbuf_r(_ptr, _c, _p));
}
# 767 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdio.h" 3
# 6 "./security/mbedtls/include/mbedtls/rsa_alt.h" 2
# 17 "./security/mbedtls/include/mbedtls/rsa_alt.h"
# 17 "./security/mbedtls/include/mbedtls/rsa_alt.h"
typedef struct
{
size_t n_len;
size_t e_len;
unsigned char *rsa_n;
unsigned char *rsa_e;
int padding;
int hash_id;
} mbedtls_rsa_context;
int rsa_verify_alt(void *ctx, size_t hash_id,
const unsigned char *hash, size_t hash_len,
const unsigned char *sig, size_t sig_len);
int rsa_sign_alt(void *ctx, size_t hash_id,
const unsigned char *hash, size_t hash_len,
unsigned char *sig, size_t *sig_len);
int rsa_decrypt_alt(void *ctx, const unsigned char *input, size_t ilen,
unsigned char *output, size_t *olen);
int rsa_encrypt_alt(void *ctx, const unsigned char *input, size_t ilen,
unsigned char *output, size_t *olen);
void mbedtls_rsa_init_alt(mbedtls_rsa_context *ctx,
int padding, int hash_id);
void mbedtls_rsa_free_alt(mbedtls_rsa_context *ctx);
# 656 "./security/mbedtls/include/mbedtls/rsa.h" 2
# 37 "./security/mbedtls/include/mbedtls/pk.h" 2
# 78 "./security/mbedtls/include/mbedtls/pk.h"
typedef enum {
MBEDTLS_PK_NONE=0,
MBEDTLS_PK_RSA,
MBEDTLS_PK_ECKEY,
MBEDTLS_PK_ECKEY_DH,
MBEDTLS_PK_ECDSA,
MBEDTLS_PK_RSA_ALT,
MBEDTLS_PK_RSASSA_PSS,
} mbedtls_pk_type_t;
typedef struct
{
mbedtls_md_type_t mgf1_hash_id;
int expected_salt_len;
} mbedtls_pk_rsassa_pss_options;
typedef enum
{
MBEDTLS_PK_DEBUG_NONE = 0,
MBEDTLS_PK_DEBUG_MPI,
MBEDTLS_PK_DEBUG_ECP,
} mbedtls_pk_debug_type;
typedef struct
{
mbedtls_pk_debug_type type;
const char *name;
void *value;
} mbedtls_pk_debug_item;
typedef struct mbedtls_pk_info_t mbedtls_pk_info_t;
typedef struct
{
const mbedtls_pk_info_t * pk_info;
void * pk_ctx;
} mbedtls_pk_context;
# 143 "./security/mbedtls/include/mbedtls/pk.h"
static inline mbedtls_rsa_context *mbedtls_pk_rsa( const mbedtls_pk_context pk )
{
return( (mbedtls_rsa_context *) (pk).pk_ctx );
}
# 183 "./security/mbedtls/include/mbedtls/pk.h"
const mbedtls_pk_info_t *mbedtls_pk_info_from_type( mbedtls_pk_type_t pk_type );
void mbedtls_pk_init( mbedtls_pk_context *ctx );
void mbedtls_pk_free( mbedtls_pk_context *ctx );
# 209 "./security/mbedtls/include/mbedtls/pk.h"
int mbedtls_pk_setup( mbedtls_pk_context *ctx, const mbedtls_pk_info_t *info );
# 239 "./security/mbedtls/include/mbedtls/pk.h"
size_t mbedtls_pk_get_bitlen( const mbedtls_pk_context *ctx );
static inline size_t mbedtls_pk_get_len( const mbedtls_pk_context *ctx )
{
return( ( mbedtls_pk_get_bitlen( ctx ) + 7 ) / 8 );
}
# 261 "./security/mbedtls/include/mbedtls/pk.h"
int mbedtls_pk_can_do( const mbedtls_pk_context *ctx, mbedtls_pk_type_t type );
# 287 "./security/mbedtls/include/mbedtls/pk.h"
int mbedtls_pk_verify( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
const unsigned char *hash, size_t hash_len,
const unsigned char *sig, size_t sig_len );
# 320 "./security/mbedtls/include/mbedtls/pk.h"
int mbedtls_pk_verify_ext( mbedtls_pk_type_t type, const void *options,
mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
const unsigned char *hash, size_t hash_len,
const unsigned char *sig, size_t sig_len );
# 349 "./security/mbedtls/include/mbedtls/pk.h"
int mbedtls_pk_sign( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
const unsigned char *hash, size_t hash_len,
unsigned char *sig, size_t *sig_len,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
# 370 "./security/mbedtls/include/mbedtls/pk.h"
int mbedtls_pk_decrypt( mbedtls_pk_context *ctx,
const unsigned char *input, size_t ilen,
unsigned char *output, size_t *olen, size_t osize,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
# 391 "./security/mbedtls/include/mbedtls/pk.h"
int mbedtls_pk_encrypt( mbedtls_pk_context *ctx,
const unsigned char *input, size_t ilen,
unsigned char *output, size_t *olen, size_t osize,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
# 404 "./security/mbedtls/include/mbedtls/pk.h"
int mbedtls_pk_check_pair( const mbedtls_pk_context *pub, const mbedtls_pk_context *prv );
# 414 "./security/mbedtls/include/mbedtls/pk.h"
int mbedtls_pk_debug( const mbedtls_pk_context *ctx, mbedtls_pk_debug_item *items );
# 423 "./security/mbedtls/include/mbedtls/pk.h"
const char * mbedtls_pk_get_name( const mbedtls_pk_context *ctx );
# 432 "./security/mbedtls/include/mbedtls/pk.h"
mbedtls_pk_type_t mbedtls_pk_get_type( const mbedtls_pk_context *ctx );
# 454 "./security/mbedtls/include/mbedtls/pk.h"
int mbedtls_pk_parse_key( mbedtls_pk_context *ctx,
const unsigned char *key, size_t keylen,
const unsigned char *pwd, size_t pwdlen );
# 475 "./security/mbedtls/include/mbedtls/pk.h"
int mbedtls_pk_parse_public_key( mbedtls_pk_context *ctx,
const unsigned char *key, size_t keylen );
# 589 "./security/mbedtls/include/mbedtls/pk.h"
int mbedtls_pk_parse_subpubkey( unsigned char **p, const unsigned char *end,
mbedtls_pk_context *pk );
# 27 "./security/mbedtls/include/mbedtls/ssl_ciphersuites.h" 2
# 1 "./security/mbedtls/include/mbedtls/cipher.h" 1
# 35 "./security/mbedtls/include/mbedtls/cipher.h"
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4
# 36 "./security/mbedtls/include/mbedtls/cipher.h" 2
# 69 "./security/mbedtls/include/mbedtls/cipher.h"
typedef enum {
MBEDTLS_CIPHER_ID_NONE = 0,
MBEDTLS_CIPHER_ID_NULL,
MBEDTLS_CIPHER_ID_AES,
MBEDTLS_CIPHER_ID_DES,
MBEDTLS_CIPHER_ID_3DES,
MBEDTLS_CIPHER_ID_CAMELLIA,
MBEDTLS_CIPHER_ID_BLOWFISH,
MBEDTLS_CIPHER_ID_ARC4,
} mbedtls_cipher_id_t;
typedef enum {
MBEDTLS_CIPHER_NONE = 0,
MBEDTLS_CIPHER_NULL,
MBEDTLS_CIPHER_AES_128_ECB,
MBEDTLS_CIPHER_AES_192_ECB,
MBEDTLS_CIPHER_AES_256_ECB,
MBEDTLS_CIPHER_AES_128_CBC,
MBEDTLS_CIPHER_AES_192_CBC,
MBEDTLS_CIPHER_AES_256_CBC,
MBEDTLS_CIPHER_AES_128_CFB128,
MBEDTLS_CIPHER_AES_192_CFB128,
MBEDTLS_CIPHER_AES_256_CFB128,
MBEDTLS_CIPHER_AES_128_CTR,
MBEDTLS_CIPHER_AES_192_CTR,
MBEDTLS_CIPHER_AES_256_CTR,
MBEDTLS_CIPHER_AES_128_GCM,
MBEDTLS_CIPHER_AES_192_GCM,
MBEDTLS_CIPHER_AES_256_GCM,
MBEDTLS_CIPHER_CAMELLIA_128_ECB,
MBEDTLS_CIPHER_CAMELLIA_192_ECB,
MBEDTLS_CIPHER_CAMELLIA_256_ECB,
MBEDTLS_CIPHER_CAMELLIA_128_CBC,
MBEDTLS_CIPHER_CAMELLIA_192_CBC,
MBEDTLS_CIPHER_CAMELLIA_256_CBC,
MBEDTLS_CIPHER_CAMELLIA_128_CFB128,
MBEDTLS_CIPHER_CAMELLIA_192_CFB128,
MBEDTLS_CIPHER_CAMELLIA_256_CFB128,
MBEDTLS_CIPHER_CAMELLIA_128_CTR,
MBEDTLS_CIPHER_CAMELLIA_192_CTR,
MBEDTLS_CIPHER_CAMELLIA_256_CTR,
MBEDTLS_CIPHER_CAMELLIA_128_GCM,
MBEDTLS_CIPHER_CAMELLIA_192_GCM,
MBEDTLS_CIPHER_CAMELLIA_256_GCM,
MBEDTLS_CIPHER_DES_ECB,
MBEDTLS_CIPHER_DES_CBC,
MBEDTLS_CIPHER_DES_EDE_ECB,
MBEDTLS_CIPHER_DES_EDE_CBC,
MBEDTLS_CIPHER_DES_EDE3_ECB,
MBEDTLS_CIPHER_DES_EDE3_CBC,
MBEDTLS_CIPHER_BLOWFISH_ECB,
MBEDTLS_CIPHER_BLOWFISH_CBC,
MBEDTLS_CIPHER_BLOWFISH_CFB64,
MBEDTLS_CIPHER_BLOWFISH_CTR,
MBEDTLS_CIPHER_ARC4_128,
MBEDTLS_CIPHER_AES_128_CCM,
MBEDTLS_CIPHER_AES_192_CCM,
MBEDTLS_CIPHER_AES_256_CCM,
MBEDTLS_CIPHER_CAMELLIA_128_CCM,
MBEDTLS_CIPHER_CAMELLIA_192_CCM,
MBEDTLS_CIPHER_CAMELLIA_256_CCM,
} mbedtls_cipher_type_t;
typedef enum {
MBEDTLS_MODE_NONE = 0,
MBEDTLS_MODE_ECB,
MBEDTLS_MODE_CBC,
MBEDTLS_MODE_CFB,
MBEDTLS_MODE_OFB,
MBEDTLS_MODE_CTR,
MBEDTLS_MODE_GCM,
MBEDTLS_MODE_STREAM,
MBEDTLS_MODE_CCM,
} mbedtls_cipher_mode_t;
typedef enum {
MBEDTLS_PADDING_PKCS7 = 0,
MBEDTLS_PADDING_ONE_AND_ZEROS,
MBEDTLS_PADDING_ZEROS_AND_LEN,
MBEDTLS_PADDING_ZEROS,
MBEDTLS_PADDING_NONE,
} mbedtls_cipher_padding_t;
typedef enum {
MBEDTLS_OPERATION_NONE = -1,
MBEDTLS_DECRYPT = 0,
MBEDTLS_ENCRYPT,
} mbedtls_operation_t;
enum {
MBEDTLS_KEY_LENGTH_NONE = 0,
MBEDTLS_KEY_LENGTH_DES = 64,
MBEDTLS_KEY_LENGTH_DES_EDE = 128,
MBEDTLS_KEY_LENGTH_DES_EDE3 = 192,
};
# 177 "./security/mbedtls/include/mbedtls/cipher.h"
typedef struct mbedtls_cipher_base_t mbedtls_cipher_base_t;
typedef struct mbedtls_cmac_context_t mbedtls_cmac_context_t;
typedef struct {
mbedtls_cipher_type_t type;
mbedtls_cipher_mode_t mode;
unsigned int key_bitlen;
const char * name;
unsigned int iv_size;
int flags;
unsigned int block_size;
const mbedtls_cipher_base_t *base;
} mbedtls_cipher_info_t;
typedef struct {
const mbedtls_cipher_info_t *cipher_info;
int key_bitlen;
mbedtls_operation_t operation;
void (*add_padding)( unsigned char *output, size_t olen, size_t data_len );
int (*get_padding)( unsigned char *input, size_t ilen, size_t *data_len );
unsigned char unprocessed_data[16];
size_t unprocessed_len;
unsigned char iv[16];
size_t iv_size;
void *cipher_ctx;
} mbedtls_cipher_context_t;
const int *mbedtls_cipher_list( void );
# 273 "./security/mbedtls/include/mbedtls/cipher.h"
const mbedtls_cipher_info_t *mbedtls_cipher_info_from_string( const char *cipher_name );
# 284 "./security/mbedtls/include/mbedtls/cipher.h"
const mbedtls_cipher_info_t *mbedtls_cipher_info_from_type( const mbedtls_cipher_type_t cipher_type );
# 298 "./security/mbedtls/include/mbedtls/cipher.h"
const mbedtls_cipher_info_t *mbedtls_cipher_info_from_values( const mbedtls_cipher_id_t cipher_id,
int key_bitlen,
const mbedtls_cipher_mode_t mode );
void mbedtls_cipher_init( mbedtls_cipher_context_t *ctx );
void mbedtls_cipher_free( mbedtls_cipher_context_t *ctx );
# 330 "./security/mbedtls/include/mbedtls/cipher.h"
int mbedtls_cipher_setup( mbedtls_cipher_context_t *ctx, const mbedtls_cipher_info_t *cipher_info );
# 340 "./security/mbedtls/include/mbedtls/cipher.h"
static inline unsigned int mbedtls_cipher_get_block_size( const mbedtls_cipher_context_t *ctx )
{
if(
# 342 "./security/mbedtls/include/mbedtls/cipher.h" 3 4
((void *)0)
# 342 "./security/mbedtls/include/mbedtls/cipher.h"
== ctx ||
# 342 "./security/mbedtls/include/mbedtls/cipher.h" 3 4
((void *)0)
# 342 "./security/mbedtls/include/mbedtls/cipher.h"
== ctx->cipher_info )
return 0;
return ctx->cipher_info->block_size;
}
# 357 "./security/mbedtls/include/mbedtls/cipher.h"
static inline mbedtls_cipher_mode_t mbedtls_cipher_get_cipher_mode( const mbedtls_cipher_context_t *ctx )
{
if(
# 359 "./security/mbedtls/include/mbedtls/cipher.h" 3 4
((void *)0)
# 359 "./security/mbedtls/include/mbedtls/cipher.h"
== ctx ||
# 359 "./security/mbedtls/include/mbedtls/cipher.h" 3 4
((void *)0)
# 359 "./security/mbedtls/include/mbedtls/cipher.h"
== ctx->cipher_info )
return MBEDTLS_MODE_NONE;
return ctx->cipher_info->mode;
}
# 374 "./security/mbedtls/include/mbedtls/cipher.h"
static inline int mbedtls_cipher_get_iv_size( const mbedtls_cipher_context_t *ctx )
{
if(
# 376 "./security/mbedtls/include/mbedtls/cipher.h" 3 4
((void *)0)
# 376 "./security/mbedtls/include/mbedtls/cipher.h"
== ctx ||
# 376 "./security/mbedtls/include/mbedtls/cipher.h" 3 4
((void *)0)
# 376 "./security/mbedtls/include/mbedtls/cipher.h"
== ctx->cipher_info )
return 0;
if( ctx->iv_size != 0 )
return (int) ctx->iv_size;
return (int) ctx->cipher_info->iv_size;
}
# 393 "./security/mbedtls/include/mbedtls/cipher.h"
static inline mbedtls_cipher_type_t mbedtls_cipher_get_type( const mbedtls_cipher_context_t *ctx )
{
if(
# 395 "./security/mbedtls/include/mbedtls/cipher.h" 3 4
((void *)0)
# 395 "./security/mbedtls/include/mbedtls/cipher.h"
== ctx ||
# 395 "./security/mbedtls/include/mbedtls/cipher.h" 3 4
((void *)0)
# 395 "./security/mbedtls/include/mbedtls/cipher.h"
== ctx->cipher_info )
return MBEDTLS_CIPHER_NONE;
return ctx->cipher_info->type;
}
# 408 "./security/mbedtls/include/mbedtls/cipher.h"
static inline const char *mbedtls_cipher_get_name( const mbedtls_cipher_context_t *ctx )
{
if(
# 410 "./security/mbedtls/include/mbedtls/cipher.h" 3 4
((void *)0)
# 410 "./security/mbedtls/include/mbedtls/cipher.h"
== ctx ||
# 410 "./security/mbedtls/include/mbedtls/cipher.h" 3 4
((void *)0)
# 410 "./security/mbedtls/include/mbedtls/cipher.h"
== ctx->cipher_info )
return 0;
return ctx->cipher_info->name;
}
# 425 "./security/mbedtls/include/mbedtls/cipher.h"
static inline int mbedtls_cipher_get_key_bitlen( const mbedtls_cipher_context_t *ctx )
{
if(
# 427 "./security/mbedtls/include/mbedtls/cipher.h" 3 4
((void *)0)
# 427 "./security/mbedtls/include/mbedtls/cipher.h"
== ctx ||
# 427 "./security/mbedtls/include/mbedtls/cipher.h" 3 4
((void *)0)
# 427 "./security/mbedtls/include/mbedtls/cipher.h"
== ctx->cipher_info )
return MBEDTLS_KEY_LENGTH_NONE;
return (int) ctx->cipher_info->key_bitlen;
}
# 442 "./security/mbedtls/include/mbedtls/cipher.h"
static inline mbedtls_operation_t mbedtls_cipher_get_operation( const mbedtls_cipher_context_t *ctx )
{
if(
# 444 "./security/mbedtls/include/mbedtls/cipher.h" 3 4
((void *)0)
# 444 "./security/mbedtls/include/mbedtls/cipher.h"
== ctx ||
# 444 "./security/mbedtls/include/mbedtls/cipher.h" 3 4
((void *)0)
# 444 "./security/mbedtls/include/mbedtls/cipher.h"
== ctx->cipher_info )
return MBEDTLS_OPERATION_NONE;
return ctx->operation;
}
# 465 "./security/mbedtls/include/mbedtls/cipher.h"
int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx, const unsigned char *key,
int key_bitlen, const mbedtls_operation_t operation );
# 481 "./security/mbedtls/include/mbedtls/cipher.h"
int mbedtls_cipher_set_padding_mode( mbedtls_cipher_context_t *ctx, mbedtls_cipher_padding_t mode );
# 497 "./security/mbedtls/include/mbedtls/cipher.h"
int mbedtls_cipher_set_iv( mbedtls_cipher_context_t *ctx,
const unsigned char *iv, size_t iv_len );
# 508 "./security/mbedtls/include/mbedtls/cipher.h"
int mbedtls_cipher_reset( mbedtls_cipher_context_t *ctx );
# 555 "./security/mbedtls/include/mbedtls/cipher.h"
int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *input,
size_t ilen, unsigned char *output, size_t *olen );
# 575 "./security/mbedtls/include/mbedtls/cipher.h"
int mbedtls_cipher_finish( mbedtls_cipher_context_t *ctx,
unsigned char *output, size_t *olen );
# 635 "./security/mbedtls/include/mbedtls/cipher.h"
int mbedtls_cipher_crypt( mbedtls_cipher_context_t *ctx,
const unsigned char *iv, size_t iv_len,
const unsigned char *input, size_t ilen,
unsigned char *output, size_t *olen );
# 28 "./security/mbedtls/include/mbedtls/ssl_ciphersuites.h" 2
# 237 "./security/mbedtls/include/mbedtls/ssl_ciphersuites.h"
typedef enum {
MBEDTLS_KEY_EXCHANGE_NONE = 0,
MBEDTLS_KEY_EXCHANGE_RSA,
MBEDTLS_KEY_EXCHANGE_DHE_RSA,
MBEDTLS_KEY_EXCHANGE_ECDHE_RSA,
MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA,
MBEDTLS_KEY_EXCHANGE_PSK,
MBEDTLS_KEY_EXCHANGE_DHE_PSK,
MBEDTLS_KEY_EXCHANGE_RSA_PSK,
MBEDTLS_KEY_EXCHANGE_ECDHE_PSK,
MBEDTLS_KEY_EXCHANGE_ECDH_RSA,
MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA,
MBEDTLS_KEY_EXCHANGE_ECJPAKE,
} mbedtls_key_exchange_type_t;
# 278 "./security/mbedtls/include/mbedtls/ssl_ciphersuites.h"
typedef struct mbedtls_ssl_ciphersuite_t mbedtls_ssl_ciphersuite_t;
# 288 "./security/mbedtls/include/mbedtls/ssl_ciphersuites.h"
struct mbedtls_ssl_ciphersuite_t
{
int id;
const char * name;
mbedtls_cipher_type_t cipher;
mbedtls_md_type_t mac;
mbedtls_key_exchange_type_t key_exchange;
int min_major_ver;
int min_minor_ver;
int max_major_ver;
int max_minor_ver;
unsigned char flags;
};
const int *mbedtls_ssl_list_ciphersuites( void );
const mbedtls_ssl_ciphersuite_t *mbedtls_ssl_ciphersuite_from_string( const char *ciphersuite_name );
const mbedtls_ssl_ciphersuite_t *mbedtls_ssl_ciphersuite_from_id( int ciphersuite_id );
mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_pk_alg( const mbedtls_ssl_ciphersuite_t *info );
int mbedtls_ssl_ciphersuite_uses_ec( const mbedtls_ssl_ciphersuite_t *info );
int mbedtls_ssl_ciphersuite_uses_psk( const mbedtls_ssl_ciphersuite_t *info );
# 36 "./security/mbedtls/include/mbedtls/ssl.h" 2
# 1 "./security/mbedtls/include/mbedtls/x509_crt.h" 1
# 32 "./security/mbedtls/include/mbedtls/x509_crt.h"
# 1 "./security/mbedtls/include/mbedtls/x509.h" 1
# 32 "./security/mbedtls/include/mbedtls/x509.h"
# 1 "./security/mbedtls/include/mbedtls/asn1.h" 1
# 32 "./security/mbedtls/include/mbedtls/asn1.h"
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4
# 33 "./security/mbedtls/include/mbedtls/asn1.h" 2
# 118 "./security/mbedtls/include/mbedtls/asn1.h"
typedef struct mbedtls_asn1_buf
{
int tag;
size_t len;
unsigned char *p;
}
mbedtls_asn1_buf;
typedef struct mbedtls_asn1_bitstring
{
size_t len;
unsigned char unused_bits;
unsigned char *p;
}
mbedtls_asn1_bitstring;
typedef struct mbedtls_asn1_sequence
{
mbedtls_asn1_buf buf;
struct mbedtls_asn1_sequence *next;
}
mbedtls_asn1_sequence;
typedef struct mbedtls_asn1_named_data
{
mbedtls_asn1_buf oid;
mbedtls_asn1_buf val;
struct mbedtls_asn1_named_data *next;
unsigned char next_merged;
}
mbedtls_asn1_named_data;
# 171 "./security/mbedtls/include/mbedtls/asn1.h"
int mbedtls_asn1_get_len( unsigned char **p,
const unsigned char *end,
size_t *len );
# 187 "./security/mbedtls/include/mbedtls/asn1.h"
int mbedtls_asn1_get_tag( unsigned char **p,
const unsigned char *end,
size_t *len, int tag );
# 201 "./security/mbedtls/include/mbedtls/asn1.h"
int mbedtls_asn1_get_bool( unsigned char **p,
const unsigned char *end,
int *val );
# 215 "./security/mbedtls/include/mbedtls/asn1.h"
int mbedtls_asn1_get_int( unsigned char **p,
const unsigned char *end,
int *val );
# 229 "./security/mbedtls/include/mbedtls/asn1.h"
int mbedtls_asn1_get_bitstring( unsigned char **p, const unsigned char *end,
mbedtls_asn1_bitstring *bs);
# 243 "./security/mbedtls/include/mbedtls/asn1.h"
int mbedtls_asn1_get_bitstring_null( unsigned char **p, const unsigned char *end,
size_t *len );
# 257 "./security/mbedtls/include/mbedtls/asn1.h"
int mbedtls_asn1_get_sequence_of( unsigned char **p,
const unsigned char *end,
mbedtls_asn1_sequence *cur,
int tag);
# 290 "./security/mbedtls/include/mbedtls/asn1.h"
int mbedtls_asn1_get_alg( unsigned char **p,
const unsigned char *end,
mbedtls_asn1_buf *alg, mbedtls_asn1_buf *params );
# 306 "./security/mbedtls/include/mbedtls/asn1.h"
int mbedtls_asn1_get_alg_null( unsigned char **p,
const unsigned char *end,
mbedtls_asn1_buf *alg );
# 320 "./security/mbedtls/include/mbedtls/asn1.h"
mbedtls_asn1_named_data *mbedtls_asn1_find_named_data( mbedtls_asn1_named_data *list,
const char *oid, size_t len );
void mbedtls_asn1_free_named_data( mbedtls_asn1_named_data *entry );
void mbedtls_asn1_free_named_data_list( mbedtls_asn1_named_data **head );
# 33 "./security/mbedtls/include/mbedtls/x509.h" 2
# 187 "./security/mbedtls/include/mbedtls/x509.h"
typedef mbedtls_asn1_buf mbedtls_x509_buf;
typedef mbedtls_asn1_bitstring mbedtls_x509_bitstring;
typedef mbedtls_asn1_named_data mbedtls_x509_name;
typedef mbedtls_asn1_sequence mbedtls_x509_sequence;
typedef struct mbedtls_x509_time
{
int year, mon, day;
int hour, min, sec;
}
mbedtls_x509_time;
# 242 "./security/mbedtls/include/mbedtls/x509.h"
int mbedtls_x509_serial_gets( char *buf, size_t size, const mbedtls_x509_buf *serial );
# 256 "./security/mbedtls/include/mbedtls/x509.h"
int mbedtls_x509_time_is_past( const mbedtls_x509_time *time );
# 270 "./security/mbedtls/include/mbedtls/x509.h"
int mbedtls_x509_time_is_future( const mbedtls_x509_time *time );
int mbedtls_x509_self_test( int verbose );
int mbedtls_x509_get_name( unsigned char **p, const unsigned char *end,
mbedtls_x509_name *cur );
int mbedtls_x509_get_alg_null( unsigned char **p, const unsigned char *end,
mbedtls_x509_buf *alg );
int mbedtls_x509_get_alg( unsigned char **p, const unsigned char *end,
mbedtls_x509_buf *alg, mbedtls_x509_buf *params );
int mbedtls_x509_get_sig( unsigned char **p, const unsigned char *end, mbedtls_x509_buf *sig );
int mbedtls_x509_get_sig_alg( const mbedtls_x509_buf *sig_oid, const mbedtls_x509_buf *sig_params,
mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg,
void **sig_opts );
int mbedtls_x509_get_time( unsigned char **p, const unsigned char *end,
mbedtls_x509_time *time );
int mbedtls_x509_get_serial( unsigned char **p, const unsigned char *end,
mbedtls_x509_buf *serial );
int mbedtls_x509_get_ext( unsigned char **p, const unsigned char *end,
mbedtls_x509_buf *ext, int tag );
int mbedtls_x509_key_size_helper( char *buf, size_t buf_size, const char *name );
int mbedtls_x509_string_to_names( mbedtls_asn1_named_data **head, const char *name );
int mbedtls_x509_set_extension( mbedtls_asn1_named_data **head, const char *oid, size_t oid_len,
int critical, const unsigned char *val,
size_t val_len );
int mbedtls_x509_write_extensions( unsigned char **p, unsigned char *start,
mbedtls_asn1_named_data *first );
int mbedtls_x509_write_names( unsigned char **p, unsigned char *start,
mbedtls_asn1_named_data *first );
int mbedtls_x509_write_sig( unsigned char **p, unsigned char *start,
const char *oid, size_t oid_len,
unsigned char *sig, size_t size );
# 33 "./security/mbedtls/include/mbedtls/x509_crt.h" 2
# 1 "./security/mbedtls/include/mbedtls/x509_crl.h" 1
# 51 "./security/mbedtls/include/mbedtls/x509_crl.h"
typedef struct mbedtls_x509_crl_entry
{
mbedtls_x509_buf raw;
mbedtls_x509_buf serial;
mbedtls_x509_time revocation_date;
mbedtls_x509_buf entry_ext;
struct mbedtls_x509_crl_entry *next;
}
mbedtls_x509_crl_entry;
typedef struct mbedtls_x509_crl
{
mbedtls_x509_buf raw;
mbedtls_x509_buf tbs;
int version;
mbedtls_x509_buf sig_oid;
mbedtls_x509_buf issuer_raw;
mbedtls_x509_name issuer;
mbedtls_x509_time this_update;
mbedtls_x509_time next_update;
mbedtls_x509_crl_entry entry;
mbedtls_x509_buf crl_ext;
mbedtls_x509_buf sig_oid2;
mbedtls_x509_buf sig;
mbedtls_md_type_t sig_md;
mbedtls_pk_type_t sig_pk;
void *sig_opts;
struct mbedtls_x509_crl *next;
}
mbedtls_x509_crl;
# 108 "./security/mbedtls/include/mbedtls/x509_crl.h"
int mbedtls_x509_crl_parse_der( mbedtls_x509_crl *chain,
const unsigned char *buf, size_t buflen );
# 122 "./security/mbedtls/include/mbedtls/x509_crl.h"
int mbedtls_x509_crl_parse( mbedtls_x509_crl *chain, const unsigned char *buf, size_t buflen );
# 149 "./security/mbedtls/include/mbedtls/x509_crl.h"
int mbedtls_x509_crl_info( char *buf, size_t size, const char *prefix,
const mbedtls_x509_crl *crl );
void mbedtls_x509_crl_init( mbedtls_x509_crl *crl );
void mbedtls_x509_crl_free( mbedtls_x509_crl *crl );
# 34 "./security/mbedtls/include/mbedtls/x509_crt.h" 2
# 52 "./security/mbedtls/include/mbedtls/x509_crt.h"
typedef struct mbedtls_x509_crt
{
mbedtls_x509_buf raw;
mbedtls_x509_buf tbs;
int version;
mbedtls_x509_buf serial;
mbedtls_x509_buf sig_oid;
mbedtls_x509_buf issuer_raw;
mbedtls_x509_buf subject_raw;
mbedtls_x509_name issuer;
mbedtls_x509_name subject;
mbedtls_x509_time valid_from;
mbedtls_x509_time valid_to;
mbedtls_pk_context pk;
mbedtls_x509_buf issuer_id;
mbedtls_x509_buf subject_id;
mbedtls_x509_buf v3_ext;
mbedtls_x509_sequence subject_alt_names;
int ext_types;
int ca_istrue;
int max_pathlen;
unsigned int key_usage;
mbedtls_x509_sequence ext_key_usage;
unsigned char ns_cert_type;
mbedtls_x509_buf sig;
mbedtls_md_type_t sig_md;
mbedtls_pk_type_t sig_pk;
void *sig_opts;
struct mbedtls_x509_crt *next;
}
mbedtls_x509_crt;
# 107 "./security/mbedtls/include/mbedtls/x509_crt.h"
typedef struct
{
uint32_t allowed_mds;
uint32_t allowed_pks;
uint32_t allowed_curves;
uint32_t rsa_min_bitlen;
}
mbedtls_x509_crt_profile;
# 152 "./security/mbedtls/include/mbedtls/x509_crt.h"
extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_default;
extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_next;
extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_suiteb;
# 175 "./security/mbedtls/include/mbedtls/x509_crt.h"
int mbedtls_x509_crt_parse_der( mbedtls_x509_crt *chain, const unsigned char *buf,
size_t buflen );
# 193 "./security/mbedtls/include/mbedtls/x509_crt.h"
int mbedtls_x509_crt_parse( mbedtls_x509_crt *chain, const unsigned char *buf, size_t buflen );
# 239 "./security/mbedtls/include/mbedtls/x509_crt.h"
int mbedtls_x509_crt_info( char *buf, size_t size, const char *prefix,
const mbedtls_x509_crt *crt );
# 254 "./security/mbedtls/include/mbedtls/x509_crt.h"
int mbedtls_x509_crt_verify_info( char *buf, size_t size, const char *prefix,
uint32_t flags );
# 301 "./security/mbedtls/include/mbedtls/x509_crt.h"
int mbedtls_x509_crt_verify( mbedtls_x509_crt *crt,
mbedtls_x509_crt *trust_ca,
mbedtls_x509_crl *ca_crl,
const char *cn, uint32_t *flags,
int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *),
void *p_vrfy );
# 335 "./security/mbedtls/include/mbedtls/x509_crt.h"
int mbedtls_x509_crt_verify_with_profile( mbedtls_x509_crt *crt,
mbedtls_x509_crt *trust_ca,
mbedtls_x509_crl *ca_crl,
const mbedtls_x509_crt_profile *profile,
const char *cn, uint32_t *flags,
int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *),
void *p_vrfy );
# 405 "./security/mbedtls/include/mbedtls/x509_crt.h"
void mbedtls_x509_crt_init( mbedtls_x509_crt *crt );
void mbedtls_x509_crt_free( mbedtls_x509_crt *crt );
# 39 "./security/mbedtls/include/mbedtls/ssl.h" 2
# 350 "./security/mbedtls/include/mbedtls/ssl.h"
union mbedtls_ssl_premaster_secret
{
unsigned char _pms_rsa[48];
# 381 "./security/mbedtls/include/mbedtls/ssl.h"
};
# 392 "./security/mbedtls/include/mbedtls/ssl.h"
typedef enum
{
MBEDTLS_SSL_HELLO_REQUEST,
MBEDTLS_SSL_CLIENT_HELLO,
MBEDTLS_SSL_SERVER_HELLO,
MBEDTLS_SSL_SERVER_CERTIFICATE,
MBEDTLS_SSL_SERVER_KEY_EXCHANGE,
MBEDTLS_SSL_CERTIFICATE_REQUEST,
MBEDTLS_SSL_SERVER_HELLO_DONE,
MBEDTLS_SSL_CLIENT_CERTIFICATE,
MBEDTLS_SSL_CLIENT_KEY_EXCHANGE,
MBEDTLS_SSL_CERTIFICATE_VERIFY,
MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC,
MBEDTLS_SSL_CLIENT_FINISHED,
MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC,
MBEDTLS_SSL_SERVER_FINISHED,
MBEDTLS_SSL_FLUSH_BUFFERS,
MBEDTLS_SSL_HANDSHAKE_WRAPUP,
MBEDTLS_SSL_HANDSHAKE_OVER,
MBEDTLS_SSL_SERVER_NEW_SESSION_TICKET,
MBEDTLS_SSL_SERVER_HELLO_VERIFY_REQUEST_SENT,
}
mbedtls_ssl_states;
# 433 "./security/mbedtls/include/mbedtls/ssl.h"
typedef int mbedtls_ssl_send_t( void *ctx,
const unsigned char *buf,
size_t len );
# 456 "./security/mbedtls/include/mbedtls/ssl.h"
typedef int mbedtls_ssl_recv_t( void *ctx,
unsigned char *buf,
size_t len );
# 482 "./security/mbedtls/include/mbedtls/ssl.h"
typedef int mbedtls_ssl_recv_timeout_t( void *ctx,
unsigned char *buf,
size_t len,
uint32_t timeout );
# 508 "./security/mbedtls/include/mbedtls/ssl.h"
typedef void mbedtls_ssl_set_timer_t( void * ctx,
uint32_t int_ms,
uint32_t fin_ms );
# 523 "./security/mbedtls/include/mbedtls/ssl.h"
typedef int mbedtls_ssl_get_timer_t( void * ctx );
typedef struct mbedtls_ssl_session mbedtls_ssl_session;
typedef struct mbedtls_ssl_context mbedtls_ssl_context;
typedef struct mbedtls_ssl_config mbedtls_ssl_config;
typedef struct mbedtls_ssl_transform mbedtls_ssl_transform;
typedef struct mbedtls_ssl_handshake_params mbedtls_ssl_handshake_params;
typedef struct mbedtls_ssl_key_cert mbedtls_ssl_key_cert;
typedef struct mbedtls_ssl_flight_item mbedtls_ssl_flight_item;
struct mbedtls_ssl_session
{
int ciphersuite;
int compression;
size_t id_len;
unsigned char id[32];
unsigned char master[48];
mbedtls_x509_crt *peer_cert;
uint32_t verify_result;
# 567 "./security/mbedtls/include/mbedtls/ssl.h"
unsigned char mfl_code;
# 577 "./security/mbedtls/include/mbedtls/ssl.h"
};
struct mbedtls_ssl_config
{
const int *ciphersuite_list[4];
void (*f_dbg)(void *, int, const char *, int, const char *);
void *p_dbg;
int (*f_rng)(void *, unsigned char *, size_t);
void *p_rng;
int (*f_get_cache)(void *, mbedtls_ssl_session *);
int (*f_set_cache)(void *, const mbedtls_ssl_session *);
void *p_cache;
# 614 "./security/mbedtls/include/mbedtls/ssl.h"
int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *);
void *p_vrfy;
# 651 "./security/mbedtls/include/mbedtls/ssl.h"
const mbedtls_x509_crt_profile *cert_profile;
mbedtls_ssl_key_cert *key_cert;
mbedtls_x509_crt *ca_chain;
mbedtls_x509_crl *ca_crl;
const int *sig_hashes;
# 685 "./security/mbedtls/include/mbedtls/ssl.h"
uint32_t read_timeout;
uint32_t hs_timeout_min;
uint32_t hs_timeout_max;
# 708 "./security/mbedtls/include/mbedtls/ssl.h"
unsigned char max_major_ver;
unsigned char max_minor_ver;
unsigned char min_major_ver;
unsigned char min_minor_ver;
unsigned int endpoint : 1;
unsigned int transport : 1;
unsigned int authmode : 2;
unsigned int allow_legacy_renegotiation : 2 ;
unsigned int mfl_code : 3;
# 735 "./security/mbedtls/include/mbedtls/ssl.h"
unsigned int anti_replay : 1;
# 752 "./security/mbedtls/include/mbedtls/ssl.h"
};
struct mbedtls_ssl_context
{
const mbedtls_ssl_config *conf;
int state;
int major_ver;
int minor_ver;
mbedtls_ssl_send_t *f_send;
mbedtls_ssl_recv_t *f_recv;
mbedtls_ssl_recv_timeout_t *f_recv_timeout;
void *p_bio;
mbedtls_ssl_session *session_in;
mbedtls_ssl_session *session_out;
mbedtls_ssl_session *session;
mbedtls_ssl_session *session_negotiate;
mbedtls_ssl_handshake_params *handshake;
mbedtls_ssl_transform *transform_in;
mbedtls_ssl_transform *transform_out;
mbedtls_ssl_transform *transform;
mbedtls_ssl_transform *transform_negotiate;
void *p_timer;
mbedtls_ssl_set_timer_t *f_set_timer;
mbedtls_ssl_get_timer_t *f_get_timer;
unsigned char *in_buf;
unsigned char *in_ctr;
unsigned char *in_hdr;
unsigned char *in_len;
unsigned char *in_iv;
unsigned char *in_msg;
unsigned char *in_offt;
int in_msgtype;
size_t in_msglen;
size_t in_left;
uint16_t in_epoch;
size_t next_record_offset;
uint64_t in_window_top;
uint64_t in_window;
size_t in_hslen;
int nb_zero;
int record_read;
unsigned char *out_buf;
unsigned char *out_ctr;
unsigned char *out_hdr;
unsigned char *out_len;
unsigned char *out_iv;
unsigned char *out_msg;
int out_msgtype;
size_t out_msglen;
size_t out_left;
# 866 "./security/mbedtls/include/mbedtls/ssl.h"
int client_auth;
char *hostname;
# 892 "./security/mbedtls/include/mbedtls/ssl.h"
int secure_renegotiation;
};
# 926 "./security/mbedtls/include/mbedtls/ssl.h"
const int *mbedtls_ssl_list_ciphersuites( void );
# 936 "./security/mbedtls/include/mbedtls/ssl.h"
const char *mbedtls_ssl_get_ciphersuite_name( const int ciphersuite_id );
# 946 "./security/mbedtls/include/mbedtls/ssl.h"
int mbedtls_ssl_get_ciphersuite_id( const char *ciphersuite_name );
# 955 "./security/mbedtls/include/mbedtls/ssl.h"
void mbedtls_ssl_init( mbedtls_ssl_context *ssl );
# 972 "./security/mbedtls/include/mbedtls/ssl.h"
int mbedtls_ssl_setup( mbedtls_ssl_context *ssl,
const mbedtls_ssl_config *conf );
# 985 "./security/mbedtls/include/mbedtls/ssl.h"
int mbedtls_ssl_session_reset( mbedtls_ssl_context *ssl );
void mbedtls_ssl_conf_endpoint( mbedtls_ssl_config *conf, int endpoint );
# 1009 "./security/mbedtls/include/mbedtls/ssl.h"
void mbedtls_ssl_conf_transport( mbedtls_ssl_config *conf, int transport );
# 1037 "./security/mbedtls/include/mbedtls/ssl.h"
void mbedtls_ssl_conf_authmode( mbedtls_ssl_config *conf, int authmode );
# 1051 "./security/mbedtls/include/mbedtls/ssl.h"
void mbedtls_ssl_conf_verify( mbedtls_ssl_config *conf,
int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *),
void *p_vrfy );
# 1063 "./security/mbedtls/include/mbedtls/ssl.h"
void mbedtls_ssl_conf_rng( mbedtls_ssl_config *conf,
int (*f_rng)(void *, unsigned char *, size_t),
void *p_rng );
# 1081 "./security/mbedtls/include/mbedtls/ssl.h"
void mbedtls_ssl_conf_dbg( mbedtls_ssl_config *conf,
void (*f_dbg)(void *, int, const char *, int, const char *),
void *p_dbg );
# 1115 "./security/mbedtls/include/mbedtls/ssl.h"
void mbedtls_ssl_set_bio( mbedtls_ssl_context *ssl,
void *p_bio,
mbedtls_ssl_send_t *f_send,
mbedtls_ssl_recv_t *f_recv,
mbedtls_ssl_recv_timeout_t *f_recv_timeout );
# 1137 "./security/mbedtls/include/mbedtls/ssl.h"
void mbedtls_ssl_conf_read_timeout( mbedtls_ssl_config *conf, uint32_t timeout );
# 1159 "./security/mbedtls/include/mbedtls/ssl.h"
void mbedtls_ssl_set_timer_cb( mbedtls_ssl_context *ssl,
void *p_timer,
mbedtls_ssl_set_timer_t *f_set_timer,
mbedtls_ssl_get_timer_t *f_get_timer );
# 1183 "./security/mbedtls/include/mbedtls/ssl.h"
typedef int mbedtls_ssl_ticket_write_t( void *p_ticket,
const mbedtls_ssl_session *session,
unsigned char *start,
const unsigned char *end,
size_t *tlen,
uint32_t *lifetime );
# 1242 "./security/mbedtls/include/mbedtls/ssl.h"
typedef int mbedtls_ssl_ticket_parse_t( void *p_ticket,
mbedtls_ssl_session *session,
unsigned char *buf,
size_t len );
# 1298 "./security/mbedtls/include/mbedtls/ssl.h"
typedef int mbedtls_ssl_cookie_write_t( void *ctx,
unsigned char **p, unsigned char *end,
const unsigned char *info, size_t ilen );
# 1315 "./security/mbedtls/include/mbedtls/ssl.h"
typedef int mbedtls_ssl_cookie_check_t( void *ctx,
const unsigned char *cookie, size_t clen,
const unsigned char *info, size_t ilen );
# 1394 "./security/mbedtls/include/mbedtls/ssl.h"
void mbedtls_ssl_conf_dtls_anti_replay( mbedtls_ssl_config *conf, char mode );
# 1456 "./security/mbedtls/include/mbedtls/ssl.h"
void mbedtls_ssl_conf_handshake_timeout( mbedtls_ssl_config *conf, uint32_t min, uint32_t max );
# 1518 "./security/mbedtls/include/mbedtls/ssl.h"
int mbedtls_ssl_set_session( mbedtls_ssl_context *ssl, const mbedtls_ssl_session *session );
# 1536 "./security/mbedtls/include/mbedtls/ssl.h"
void mbedtls_ssl_conf_ciphersuites( mbedtls_ssl_config *conf,
const int *ciphersuites );
# 1558 "./security/mbedtls/include/mbedtls/ssl.h"
void mbedtls_ssl_conf_ciphersuites_for_version( mbedtls_ssl_config *conf,
const int *ciphersuites,
int major, int minor );
# 1573 "./security/mbedtls/include/mbedtls/ssl.h"
void mbedtls_ssl_conf_cert_profile( mbedtls_ssl_config *conf,
const mbedtls_x509_crt_profile *profile );
# 1583 "./security/mbedtls/include/mbedtls/ssl.h"
void mbedtls_ssl_conf_ca_chain( mbedtls_ssl_config *conf,
mbedtls_x509_crt *ca_chain,
mbedtls_x509_crl *ca_crl );
# 1615 "./security/mbedtls/include/mbedtls/ssl.h"
int mbedtls_ssl_conf_own_cert( mbedtls_ssl_config *conf,
mbedtls_x509_crt *own_cert,
mbedtls_pk_context *pk_key );
# 1781 "./security/mbedtls/include/mbedtls/ssl.h"
void mbedtls_ssl_conf_sig_hashes( mbedtls_ssl_config *conf,
const int *hashes );
# 1797 "./security/mbedtls/include/mbedtls/ssl.h"
int mbedtls_ssl_set_hostname( mbedtls_ssl_context *ssl, const char *hostname );
# 1940 "./security/mbedtls/include/mbedtls/ssl.h"
void mbedtls_ssl_conf_max_version( mbedtls_ssl_config *conf, int major, int minor );
# 1960 "./security/mbedtls/include/mbedtls/ssl.h"
void mbedtls_ssl_conf_min_version( mbedtls_ssl_config *conf, int major, int minor );
# 2050 "./security/mbedtls/include/mbedtls/ssl.h"
int mbedtls_ssl_conf_max_frag_len( mbedtls_ssl_config *conf, unsigned char mfl_code );
# 2142 "./security/mbedtls/include/mbedtls/ssl.h"
void mbedtls_ssl_conf_legacy_renegotiation( mbedtls_ssl_config *conf, int allow_legacy );
# 2220 "./security/mbedtls/include/mbedtls/ssl.h"
size_t mbedtls_ssl_get_bytes_avail( const mbedtls_ssl_context *ssl );
# 2233 "./security/mbedtls/include/mbedtls/ssl.h"
uint32_t mbedtls_ssl_get_verify_result( const mbedtls_ssl_context *ssl );
# 2242 "./security/mbedtls/include/mbedtls/ssl.h"
const char *mbedtls_ssl_get_ciphersuite( const mbedtls_ssl_context *ssl );
# 2251 "./security/mbedtls/include/mbedtls/ssl.h"
const char *mbedtls_ssl_get_version( const mbedtls_ssl_context *ssl );
# 2263 "./security/mbedtls/include/mbedtls/ssl.h"
int mbedtls_ssl_get_record_expansion( const mbedtls_ssl_context *ssl );
# 2282 "./security/mbedtls/include/mbedtls/ssl.h"
size_t mbedtls_ssl_get_max_frag_len( const mbedtls_ssl_context *ssl );
# 2300 "./security/mbedtls/include/mbedtls/ssl.h"
const mbedtls_x509_crt *mbedtls_ssl_get_peer_cert( const mbedtls_ssl_context *ssl );
# 2320 "./security/mbedtls/include/mbedtls/ssl.h"
int mbedtls_ssl_get_session( const mbedtls_ssl_context *ssl, mbedtls_ssl_session *session );
# 2344 "./security/mbedtls/include/mbedtls/ssl.h"
int mbedtls_ssl_handshake( mbedtls_ssl_context *ssl );
# 2365 "./security/mbedtls/include/mbedtls/ssl.h"
int mbedtls_ssl_handshake_step( mbedtls_ssl_context *ssl );
# 2423 "./security/mbedtls/include/mbedtls/ssl.h"
int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len );
# 2460 "./security/mbedtls/include/mbedtls/ssl.h"
int mbedtls_ssl_write( mbedtls_ssl_context *ssl, const unsigned char *buf, size_t len );
# 2478 "./security/mbedtls/include/mbedtls/ssl.h"
int mbedtls_ssl_send_alert_message( mbedtls_ssl_context *ssl,
unsigned char level,
unsigned char message );
# 2494 "./security/mbedtls/include/mbedtls/ssl.h"
int mbedtls_ssl_close_notify( mbedtls_ssl_context *ssl );
void mbedtls_ssl_free( mbedtls_ssl_context *ssl );
# 2513 "./security/mbedtls/include/mbedtls/ssl.h"
void mbedtls_ssl_config_init( mbedtls_ssl_config *conf );
# 2530 "./security/mbedtls/include/mbedtls/ssl.h"
int mbedtls_ssl_config_defaults( mbedtls_ssl_config *conf,
int endpoint, int transport, int preset );
void mbedtls_ssl_config_free( mbedtls_ssl_config *conf );
void mbedtls_ssl_session_init( mbedtls_ssl_session *session );
void mbedtls_ssl_session_free( mbedtls_ssl_session *session );
# 27 "./security/mbedtls/include/mbedtls/ssl_cookie.h" 2
# 1 "./security/mbedtls/include/mbedtls/threading.h" 1
# 53 "./security/mbedtls/include/mbedtls/threading.h"
# 1 "./security/mbedtls/include/mbedtls/threading_alt.h" 1
# 1 "./include/aos/kernel.h" 1
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4
# 9 "./include/aos/kernel.h" 2
# 19 "./include/aos/kernel.h"
typedef struct {
void *hdl;
} aos_hdl_t;
typedef aos_hdl_t aos_task_t;
typedef aos_hdl_t aos_mutex_t;
typedef aos_hdl_t aos_sem_t;
typedef aos_hdl_t aos_queue_t;
typedef aos_hdl_t aos_timer_t;
typedef aos_hdl_t aos_work_t;
typedef aos_hdl_t aos_event_t;
typedef struct {
void *hdl;
void *stk;
} aos_workqueue_t;
typedef unsigned int aos_task_key_t;
void aos_reboot(void);
int aos_get_hz(void);
const char *aos_version_get(void);
# 67 "./include/aos/kernel.h"
int aos_task_new(const char *name, void (*fn)(void *), void *arg, int stack_size);
# 82 "./include/aos/kernel.h"
int aos_task_new_ext(aos_task_t *task, const char *name, void (*fn)(void *), void *arg,
int stack_size, int prio);
void aos_task_exit(int code);
const char *aos_task_name(void);
# 106 "./include/aos/kernel.h"
int aos_task_key_create(aos_task_key_t *key);
void aos_task_key_delete(aos_task_key_t key);
# 123 "./include/aos/kernel.h"
int aos_task_setspecific(aos_task_key_t key, void *vp);
void *aos_task_getspecific(aos_task_key_t key);
# 140 "./include/aos/kernel.h"
int aos_mutex_new(aos_mutex_t *mutex);
void aos_mutex_free(aos_mutex_t *mutex);
# 158 "./include/aos/kernel.h"
int aos_mutex_lock(aos_mutex_t *mutex, unsigned int timeout);
# 167 "./include/aos/kernel.h"
int aos_mutex_unlock(aos_mutex_t *mutex);
# 176 "./include/aos/kernel.h"
int aos_mutex_is_valid(aos_mutex_t *mutex);
# 187 "./include/aos/kernel.h"
int aos_sem_new(aos_sem_t *sem, int count);
void aos_sem_free(aos_sem_t *sem);
# 205 "./include/aos/kernel.h"
int aos_sem_wait(aos_sem_t *sem, unsigned int timeout);
void aos_sem_signal(aos_sem_t *sem);
# 221 "./include/aos/kernel.h"
int aos_sem_is_valid(aos_sem_t *sem);
void aos_sem_signal_all(aos_sem_t *sem);
# 240 "./include/aos/kernel.h"
int aos_event_new(aos_event_t *event, unsigned int flags);
# 251 "./include/aos/kernel.h"
void aos_event_free(aos_event_t *event);
# 272 "./include/aos/kernel.h"
int aos_event_get(aos_event_t *event, unsigned int flags, unsigned char opt,
unsigned int *actl_flags, unsigned int timeout);
# 286 "./include/aos/kernel.h"
int aos_event_set(aos_event_t *event, unsigned int flags, unsigned char opt);
# 299 "./include/aos/kernel.h"
int aos_queue_new(aos_queue_t *queue, void *buf, unsigned int size, int max_msg);
void aos_queue_free(aos_queue_t *queue);
# 317 "./include/aos/kernel.h"
int aos_queue_send(aos_queue_t *queue, void *msg, unsigned int size);
# 329 "./include/aos/kernel.h"
int aos_queue_recv(aos_queue_t *queue, unsigned int ms, void *msg, unsigned int *size);
# 338 "./include/aos/kernel.h"
int aos_queue_is_valid(aos_queue_t *queue);
# 347 "./include/aos/kernel.h"
void *aos_queue_buf_ptr(aos_queue_t *queue);
# 360 "./include/aos/kernel.h"
int aos_timer_new(aos_timer_t *timer, void (*fn)(void *, void *),
void *arg, int ms, int repeat);
# 375 "./include/aos/kernel.h"
int aos_timer_new_ext(aos_timer_t *timer, void (*fn)(void *, void *),
void *arg, int ms, int repeat, unsigned char auto_run);
void aos_timer_free(aos_timer_t *timer);
# 392 "./include/aos/kernel.h"
int aos_timer_start(aos_timer_t *timer);
# 401 "./include/aos/kernel.h"
int aos_timer_stop(aos_timer_t *timer);
# 411 "./include/aos/kernel.h"
int aos_timer_change(aos_timer_t *timer, int ms);
# 422 "./include/aos/kernel.h"
int aos_workqueue_create(aos_workqueue_t *workqueue, int pri, int stack_size);
# 434 "./include/aos/kernel.h"
int aos_work_init(aos_work_t *work, void (*fn)(void *), void *arg, int dly);
void aos_work_destroy(aos_work_t *work);
# 451 "./include/aos/kernel.h"
int aos_work_run(aos_workqueue_t *workqueue, aos_work_t *work);
# 460 "./include/aos/kernel.h"
int aos_work_sched(aos_work_t *work);
# 469 "./include/aos/kernel.h"
int aos_work_cancel(aos_work_t *work);
# 479 "./include/aos/kernel.h"
void *aos_realloc(void *mem, unsigned int size);
# 488 "./include/aos/kernel.h"
void *aos_malloc(unsigned int size);
# 497 "./include/aos/kernel.h"
void *aos_zalloc(unsigned int size);
void aos_alloc_trace(void *addr, size_t allocator);
void aos_free(void *mem);
long long aos_now(void);
long long aos_now_ms(void);
void aos_msleep(int ms);
void aos_init(void);
void aos_start(void);
# 6 "./security/mbedtls/include/mbedtls/threading_alt.h" 2
typedef struct
{
aos_mutex_t mutex;
char is_valid;
} mbedtls_threading_mutex_t;
void threading_mutex_init(mbedtls_threading_mutex_t *mutex);
void threading_mutex_free(mbedtls_threading_mutex_t *mutex);
int threading_mutex_lock(mbedtls_threading_mutex_t *mutex);
int threading_mutex_unlock(mbedtls_threading_mutex_t *mutex);
# 54 "./security/mbedtls/include/mbedtls/threading.h" 2
# 73 "./security/mbedtls/include/mbedtls/threading.h"
void mbedtls_threading_set_alt( void (*mutex_init)( mbedtls_threading_mutex_t * ),
void (*mutex_free)( mbedtls_threading_mutex_t * ),
int (*mutex_lock)( mbedtls_threading_mutex_t * ),
int (*mutex_unlock)( mbedtls_threading_mutex_t * ) );
void mbedtls_threading_free_alt( void );
# 90 "./security/mbedtls/include/mbedtls/threading.h"
extern void (*mbedtls_mutex_init)( mbedtls_threading_mutex_t *mutex );
extern void (*mbedtls_mutex_free)( mbedtls_threading_mutex_t *mutex );
extern int (*mbedtls_mutex_lock)( mbedtls_threading_mutex_t *mutex );
extern int (*mbedtls_mutex_unlock)( mbedtls_threading_mutex_t *mutex );
extern mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex;
extern mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex;
# 30 "./security/mbedtls/include/mbedtls/ssl_cookie.h" 2
# 52 "./security/mbedtls/include/mbedtls/ssl_cookie.h"
typedef struct
{
mbedtls_md_context_t hmac_ctx;
unsigned long serial;
unsigned long timeout;
mbedtls_threading_mutex_t mutex;
} mbedtls_ssl_cookie_ctx;
void mbedtls_ssl_cookie_init( mbedtls_ssl_cookie_ctx *ctx );
int mbedtls_ssl_cookie_setup( mbedtls_ssl_cookie_ctx *ctx,
int (*f_rng)(void *, unsigned char *, size_t),
void *p_rng );
# 87 "./security/mbedtls/include/mbedtls/ssl_cookie.h"
void mbedtls_ssl_cookie_set_timeout( mbedtls_ssl_cookie_ctx *ctx, unsigned long delay );
void mbedtls_ssl_cookie_free( mbedtls_ssl_cookie_ctx *ctx );
mbedtls_ssl_cookie_write_t mbedtls_ssl_cookie_write;
mbedtls_ssl_cookie_check_t mbedtls_ssl_cookie_check;
# 42 "security/mbedtls/src/ssl_cookie.c" 2
# 1 "./security/mbedtls/include/mbedtls/ssl_internal.h" 1
# 29 "./security/mbedtls/include/mbedtls/ssl_internal.h"
# 1 "./security/mbedtls/include/mbedtls/md5.h" 1
# 32 "./security/mbedtls/include/mbedtls/md5.h"
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4
# 33 "./security/mbedtls/include/mbedtls/md5.h" 2
# 108 "./security/mbedtls/include/mbedtls/md5.h"
# 1 "./security/mbedtls/include/mbedtls/md5_alt.h" 1
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4
# 9 "./security/mbedtls/include/mbedtls/md5_alt.h" 2
typedef struct {
size_t size;
void *ali_ctx;
} mbedtls_md5_context;
void mbedtls_md5_init_alt(mbedtls_md5_context *ctx);
void mbedtls_md5_free_alt(mbedtls_md5_context *ctx);
void mbedtls_md5_clone_alt(mbedtls_md5_context *dst,
const mbedtls_md5_context *src);
void mbedtls_md5_starts_alt(mbedtls_md5_context *ctx);
void mbedtls_md5_update_alt(mbedtls_md5_context *ctx, const unsigned char *input, size_t ilen);
void mbedtls_md5_finish_alt(mbedtls_md5_context *ctx, unsigned char output[16]);
void mbedtls_md5_alt( const unsigned char *input, size_t ilen, unsigned char output[16] );
# 109 "./security/mbedtls/include/mbedtls/md5.h" 2
# 131 "./security/mbedtls/include/mbedtls/md5.h"
int mbedtls_md5_self_test( int verbose );
# 30 "./security/mbedtls/include/mbedtls/ssl_internal.h" 2
# 1 "./security/mbedtls/include/mbedtls/sha1.h" 1
# 32 "./security/mbedtls/include/mbedtls/sha1.h"
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4
# 33 "./security/mbedtls/include/mbedtls/sha1.h" 2
# 108 "./security/mbedtls/include/mbedtls/sha1.h"
# 1 "./security/mbedtls/include/mbedtls/sha1_alt.h" 1
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4
# 9 "./security/mbedtls/include/mbedtls/sha1_alt.h" 2
typedef struct {
size_t size;
void *ali_ctx;
} mbedtls_sha1_context;
void mbedtls_sha1_init_alt(mbedtls_sha1_context *ctx);
void mbedtls_sha1_free_alt(mbedtls_sha1_context *ctx);
void mbedtls_sha1_clone_alt(mbedtls_sha1_context *dst,
const mbedtls_sha1_context *src);
void mbedtls_sha1_starts_alt(mbedtls_sha1_context *ctx);
void mbedtls_sha1_update_alt(mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen);
void mbedtls_sha1_finish_alt(mbedtls_sha1_context *ctx, unsigned char output[20]);
void mbedtls_sha1_alt( const unsigned char *input, size_t ilen, unsigned char output[20] );
# 109 "./security/mbedtls/include/mbedtls/sha1.h" 2
# 131 "./security/mbedtls/include/mbedtls/sha1.h"
int mbedtls_sha1_self_test( int verbose );
# 34 "./security/mbedtls/include/mbedtls/ssl_internal.h" 2
# 1 "./security/mbedtls/include/mbedtls/sha256.h" 1
# 32 "./security/mbedtls/include/mbedtls/sha256.h"
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4
# 33 "./security/mbedtls/include/mbedtls/sha256.h" 2
# 111 "./security/mbedtls/include/mbedtls/sha256.h"
# 1 "./security/mbedtls/include/mbedtls/sha256_alt.h" 1
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4
# 9 "./security/mbedtls/include/mbedtls/sha256_alt.h" 2
typedef struct {
size_t size;
void *ali_ctx;
} mbedtls_sha256_context;
void mbedtls_sha256_init_alt(mbedtls_sha256_context *ctx);
void mbedtls_sha256_free_alt(mbedtls_sha256_context *ctx);
void mbedtls_sha256_clone_alt(mbedtls_sha256_context *dst,
const mbedtls_sha256_context *src);
void mbedtls_sha256_starts_alt(mbedtls_sha256_context *ctx, int is224);
void mbedtls_sha256_update_alt(mbedtls_sha256_context *ctx, const unsigned char *input, size_t ilen);
void mbedtls_sha256_finish_alt(mbedtls_sha256_context *ctx, unsigned char output[32]);
void mbedtls_sha256_alt(const unsigned char *input, size_t ilen, unsigned char output[32], int is224);
# 112 "./security/mbedtls/include/mbedtls/sha256.h" 2
# 136 "./security/mbedtls/include/mbedtls/sha256.h"
int mbedtls_sha256_self_test( int verbose );
# 38 "./security/mbedtls/include/mbedtls/ssl_internal.h" 2
# 163 "./security/mbedtls/include/mbedtls/ssl_internal.h"
struct mbedtls_ssl_handshake_params
{
int sig_alg;
int verify_sig_alg;
# 192 "./security/mbedtls/include/mbedtls/ssl_internal.h"
mbedtls_ssl_key_cert *key_cert;
# 201 "./security/mbedtls/include/mbedtls/ssl_internal.h"
unsigned int out_msg_seq;
unsigned int in_msg_seq;
unsigned char *verify_cookie;
unsigned char verify_cookie_len;
unsigned char *hs_msg;
uint32_t retransmit_timeout;
unsigned char retransmit_state;
mbedtls_ssl_flight_item *flight;
mbedtls_ssl_flight_item *cur_msg;
unsigned int in_flight_start_seq;
mbedtls_ssl_transform *alt_transform_out;
unsigned char alt_out_ctr[8];
# 233 "./security/mbedtls/include/mbedtls/ssl_internal.h"
mbedtls_sha256_context fin_sha256;
void (*update_checksum)(mbedtls_ssl_context *, const unsigned char *, size_t);
void (*calc_verify)(mbedtls_ssl_context *, unsigned char *);
void (*calc_finished)(mbedtls_ssl_context *, unsigned char *, int);
int (*tls_prf)(const unsigned char *, size_t, const char *,
const unsigned char *, size_t,
unsigned char *, size_t);
size_t pmslen;
unsigned char randbytes[64];
unsigned char premaster[sizeof( union mbedtls_ssl_premaster_secret )];
int resume;
int max_major_ver;
int max_minor_ver;
int cli_exts;
};
struct mbedtls_ssl_transform
{
const mbedtls_ssl_ciphersuite_t *ciphersuite_info;
unsigned int keylen;
size_t minlen;
size_t ivlen;
size_t fixed_ivlen;
size_t maclen;
unsigned char iv_enc[16];
unsigned char iv_dec[16];
mbedtls_md_context_t md_ctx_enc;
mbedtls_md_context_t md_ctx_dec;
mbedtls_cipher_context_t cipher_ctx_enc;
mbedtls_cipher_context_t cipher_ctx_dec;
# 305 "./security/mbedtls/include/mbedtls/ssl_internal.h"
};
struct mbedtls_ssl_key_cert
{
mbedtls_x509_crt *cert;
mbedtls_pk_context *key;
mbedtls_ssl_key_cert *next;
};
struct mbedtls_ssl_flight_item
{
unsigned char *p;
size_t len;
unsigned char type;
mbedtls_ssl_flight_item *next;
};
# 339 "./security/mbedtls/include/mbedtls/ssl_internal.h"
void mbedtls_ssl_transform_free( mbedtls_ssl_transform *transform );
void mbedtls_ssl_handshake_free( mbedtls_ssl_handshake_params *handshake );
int mbedtls_ssl_handshake_client_step( mbedtls_ssl_context *ssl );
int mbedtls_ssl_handshake_server_step( mbedtls_ssl_context *ssl );
void mbedtls_ssl_handshake_wrapup( mbedtls_ssl_context *ssl );
int mbedtls_ssl_send_fatal_handshake_failure( mbedtls_ssl_context *ssl );
void mbedtls_ssl_reset_checksum( mbedtls_ssl_context *ssl );
int mbedtls_ssl_derive_keys( mbedtls_ssl_context *ssl );
int mbedtls_ssl_read_record_layer( mbedtls_ssl_context *ssl );
int mbedtls_ssl_handle_message_type( mbedtls_ssl_context *ssl );
int mbedtls_ssl_prepare_handshake_record( mbedtls_ssl_context *ssl );
void mbedtls_ssl_update_handshake_status( mbedtls_ssl_context *ssl );
int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl );
int mbedtls_ssl_fetch_input( mbedtls_ssl_context *ssl, size_t nb_want );
int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl );
int mbedtls_ssl_flush_output( mbedtls_ssl_context *ssl );
int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl );
int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl );
int mbedtls_ssl_parse_change_cipher_spec( mbedtls_ssl_context *ssl );
int mbedtls_ssl_write_change_cipher_spec( mbedtls_ssl_context *ssl );
int mbedtls_ssl_parse_finished( mbedtls_ssl_context *ssl );
int mbedtls_ssl_write_finished( mbedtls_ssl_context *ssl );
void mbedtls_ssl_optimize_checksum( mbedtls_ssl_context *ssl,
const mbedtls_ssl_ciphersuite_t *ciphersuite_info );
unsigned char mbedtls_ssl_sig_from_pk( mbedtls_pk_context *pk );
mbedtls_pk_type_t mbedtls_ssl_pk_alg_from_sig( unsigned char sig );
mbedtls_md_type_t mbedtls_ssl_md_alg_from_hash( unsigned char hash );
unsigned char mbedtls_ssl_hash_from_md_alg( int md );
int mbedtls_ssl_set_calc_verify_md( mbedtls_ssl_context *ssl, int md );
int mbedtls_ssl_check_sig_hash( const mbedtls_ssl_context *ssl,
mbedtls_md_type_t md );
static inline mbedtls_pk_context *mbedtls_ssl_own_key( mbedtls_ssl_context *ssl )
{
mbedtls_ssl_key_cert *key_cert;
if( ssl->handshake !=
# 408 "./security/mbedtls/include/mbedtls/ssl_internal.h" 3 4
((void *)0)
# 408 "./security/mbedtls/include/mbedtls/ssl_internal.h"
&& ssl->handshake->key_cert !=
# 408 "./security/mbedtls/include/mbedtls/ssl_internal.h" 3 4
((void *)0)
# 408 "./security/mbedtls/include/mbedtls/ssl_internal.h"
)
key_cert = ssl->handshake->key_cert;
else
key_cert = ssl->conf->key_cert;
return( key_cert ==
# 413 "./security/mbedtls/include/mbedtls/ssl_internal.h" 3 4
((void *)0)
# 413 "./security/mbedtls/include/mbedtls/ssl_internal.h"
?
# 413 "./security/mbedtls/include/mbedtls/ssl_internal.h" 3 4
((void *)0)
# 413 "./security/mbedtls/include/mbedtls/ssl_internal.h"
: key_cert->key );
}
static inline mbedtls_x509_crt *mbedtls_ssl_own_cert( mbedtls_ssl_context *ssl )
{
mbedtls_ssl_key_cert *key_cert;
if( ssl->handshake !=
# 420 "./security/mbedtls/include/mbedtls/ssl_internal.h" 3 4
((void *)0)
# 420 "./security/mbedtls/include/mbedtls/ssl_internal.h"
&& ssl->handshake->key_cert !=
# 420 "./security/mbedtls/include/mbedtls/ssl_internal.h" 3 4
((void *)0)
# 420 "./security/mbedtls/include/mbedtls/ssl_internal.h"
)
key_cert = ssl->handshake->key_cert;
else
key_cert = ssl->conf->key_cert;
return( key_cert ==
# 425 "./security/mbedtls/include/mbedtls/ssl_internal.h" 3 4
((void *)0)
# 425 "./security/mbedtls/include/mbedtls/ssl_internal.h"
?
# 425 "./security/mbedtls/include/mbedtls/ssl_internal.h" 3 4
((void *)0)
# 425 "./security/mbedtls/include/mbedtls/ssl_internal.h"
: key_cert->cert );
}
# 437 "./security/mbedtls/include/mbedtls/ssl_internal.h"
int mbedtls_ssl_check_cert_usage( const mbedtls_x509_crt *cert,
const mbedtls_ssl_ciphersuite_t *ciphersuite,
int cert_endpoint,
uint32_t *flags );
void mbedtls_ssl_write_version( int major, int minor, int transport,
unsigned char ver[2] );
void mbedtls_ssl_read_version( int *major, int *minor, int transport,
const unsigned char ver[2] );
static inline size_t mbedtls_ssl_hdr_len( const mbedtls_ssl_context *ssl )
{
if( ssl->conf->transport == 1 )
return( 13 );
return( 5 );
}
static inline size_t mbedtls_ssl_hs_hdr_len( const mbedtls_ssl_context *ssl )
{
if( ssl->conf->transport == 1 )
return( 12 );
return( 4 );
}
void mbedtls_ssl_send_flight_completed( mbedtls_ssl_context *ssl );
void mbedtls_ssl_recv_flight_completed( mbedtls_ssl_context *ssl );
int mbedtls_ssl_resend( mbedtls_ssl_context *ssl );
int mbedtls_ssl_dtls_replay_check( mbedtls_ssl_context *ssl );
void mbedtls_ssl_dtls_replay_update( mbedtls_ssl_context *ssl );
static inline int mbedtls_ssl_safer_memcmp( const void *a, const void *b, size_t n )
{
size_t i;
const unsigned char *A = (const unsigned char *) a;
const unsigned char *B = (const unsigned char *) b;
unsigned char diff = 0;
for( i = 0; i < n; i++ )
diff |= A[i] ^ B[i];
return( diff );
}
# 43 "security/mbedtls/src/ssl_cookie.c" 2
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/string.h" 1 3
# 17 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/string.h" 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4
# 18 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/string.h" 2 3
# 25 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/string.h" 3
void * memchr (const void *, int, size_t);
int memcmp (const void *, const void *, size_t);
void * memcpy (void * restrict, const void * restrict, size_t);
void * memmove (void *, const void *, size_t);
void * memset (void *, int, size_t);
char *strcat (char *restrict, const char *restrict);
char *strchr (const char *, int);
int strcmp (const char *, const char *);
int strcoll (const char *, const char *);
char *strcpy (char *restrict, const char *restrict);
size_t strcspn (const char *, const char *);
char *strerror (int);
size_t strlen (const char *);
char *strncat (char *restrict, const char *restrict, size_t);
int strncmp (const char *, const char *, size_t);
char *strncpy (char *restrict, const char *restrict, size_t);
char *strpbrk (const char *, const char *);
char *strrchr (const char *, int);
size_t strspn (const char *, const char *);
char *strstr (const char *, const char *);
char *strtok (char *restrict, const char *restrict);
size_t strxfrm (char *restrict, const char *restrict, size_t);
int strcoll_l (const char *, const char *, locale_t);
char *strerror_l (int, locale_t);
size_t strxfrm_l (char *restrict, const char *restrict, size_t, locale_t);
char *strtok_r (char *restrict, const char *restrict, char **restrict);
int bcmp (const void *, const void *, size_t);
void bcopy (const void *, void *, size_t);
void bzero (void *, size_t);
void explicit_bzero (void *, size_t);
int timingsafe_bcmp (const void *, const void *, size_t);
int timingsafe_memcmp (const void *, const void *, size_t);
int ffs (int);
char *index (const char *, int);
void * memccpy (void * restrict, const void * restrict, int, size_t);
# 86 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/string.h" 3
char *rindex (const char *, int);
char *stpcpy (char *restrict, const char *restrict);
char *stpncpy (char *restrict, const char *restrict, size_t);
int strcasecmp (const char *, const char *);
char *strdup (const char *);
char *_strdup_r (struct _reent *, const char *);
char *strndup (const char *, size_t);
char *_strndup_r (struct _reent *, const char *, size_t);
# 121 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/string.h" 3
int strerror_r (int, char *, size_t)
__asm__ ("" "__xpg_strerror_r")
;
char * _strerror_r (struct _reent *, int, int, int *);
size_t strlcat (char *, const char *, size_t);
size_t strlcpy (char *, const char *, size_t);
int strncasecmp (const char *, const char *, size_t);
size_t strnlen (const char *, size_t);
char *strsep (char **, const char *);
char *strlwr (char *);
char *strupr (char *);
char *strsignal (int __signo);
# 192 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/string.h" 3
# 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/string.h" 1 3
# 193 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/string.h" 2 3
# 45 "security/mbedtls/src/ssl_cookie.c" 2
# 47 "security/mbedtls/src/ssl_cookie.c"
static void mbedtls_zeroize( void *v, size_t n ) {
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
}
# 78 "security/mbedtls/src/ssl_cookie.c"
void mbedtls_ssl_cookie_init( mbedtls_ssl_cookie_ctx *ctx )
{
mbedtls_md_init( &ctx->hmac_ctx );
ctx->serial = 0;
ctx->timeout = 60;
mbedtls_mutex_init( &ctx->mutex );
}
void mbedtls_ssl_cookie_set_timeout( mbedtls_ssl_cookie_ctx *ctx, unsigned long delay )
{
ctx->timeout = delay;
}
void mbedtls_ssl_cookie_free( mbedtls_ssl_cookie_ctx *ctx )
{
mbedtls_md_free( &ctx->hmac_ctx );
mbedtls_mutex_free( &ctx->mutex );
mbedtls_zeroize( ctx, sizeof( mbedtls_ssl_cookie_ctx ) );
}
int mbedtls_ssl_cookie_setup( mbedtls_ssl_cookie_ctx *ctx,
int (*f_rng)(void *, unsigned char *, size_t),
void *p_rng )
{
int ret;
unsigned char key[32];
if( ( ret = f_rng( p_rng, key, sizeof( key ) ) ) != 0 )
return( ret );
ret = mbedtls_md_setup( &ctx->hmac_ctx, mbedtls_md_info_from_type( MBEDTLS_MD_SHA224 ), 1 );
if( ret != 0 )
return( ret );
ret = mbedtls_md_hmac_starts( &ctx->hmac_ctx, key, sizeof( key ) );
if( ret != 0 )
return( ret );
mbedtls_zeroize( key, sizeof( key ) );
return( 0 );
}
static int ssl_cookie_hmac( mbedtls_md_context_t *hmac_ctx,
const unsigned char time[4],
unsigned char **p, unsigned char *end,
const unsigned char *cli_id, size_t cli_id_len )
{
unsigned char hmac_out[32];
if( (size_t)( end - *p ) < 28 )
return( -0x6A00 );
if( mbedtls_md_hmac_reset( hmac_ctx ) != 0 ||
mbedtls_md_hmac_update( hmac_ctx, time, 4 ) != 0 ||
mbedtls_md_hmac_update( hmac_ctx, cli_id, cli_id_len ) != 0 ||
mbedtls_md_hmac_finish( hmac_ctx, hmac_out ) != 0 )
{
return( -0x6C00 );
}
memcpy( *p, hmac_out, 28 );
*p += 28;
return( 0 );
}
int mbedtls_ssl_cookie_write( void *p_ctx,
unsigned char **p, unsigned char *end,
const unsigned char *cli_id, size_t cli_id_len )
{
int ret;
mbedtls_ssl_cookie_ctx *ctx = (mbedtls_ssl_cookie_ctx *) p_ctx;
unsigned long t;
if( ctx ==
# 168 "security/mbedtls/src/ssl_cookie.c" 3 4
((void *)0)
# 168 "security/mbedtls/src/ssl_cookie.c"
|| cli_id ==
# 168 "security/mbedtls/src/ssl_cookie.c" 3 4
((void *)0)
# 168 "security/mbedtls/src/ssl_cookie.c"
)
return( -0x7100 );
if( (size_t)( end - *p ) < ( 4 + 28 ) )
return( -0x6A00 );
t = ctx->serial++;
(*p)[0] = (unsigned char)( t >> 24 );
(*p)[1] = (unsigned char)( t >> 16 );
(*p)[2] = (unsigned char)( t >> 8 );
(*p)[3] = (unsigned char)( t );
*p += 4;
if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 )
return( -0x6C00 + ret );
ret = ssl_cookie_hmac( &ctx->hmac_ctx, *p - 4,
p, end, cli_id, cli_id_len );
if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 )
return( -0x6C00 +
-0x001E );
return( ret );
}
int mbedtls_ssl_cookie_check( void *p_ctx,
const unsigned char *cookie, size_t cookie_len,
const unsigned char *cli_id, size_t cli_id_len )
{
unsigned char ref_hmac[28];
int ret = 0;
unsigned char *p = ref_hmac;
mbedtls_ssl_cookie_ctx *ctx = (mbedtls_ssl_cookie_ctx *) p_ctx;
unsigned long cur_time, cookie_time;
if( ctx ==
# 216 "security/mbedtls/src/ssl_cookie.c" 3 4
((void *)0)
# 216 "security/mbedtls/src/ssl_cookie.c"
|| cli_id ==
# 216 "security/mbedtls/src/ssl_cookie.c" 3 4
((void *)0)
# 216 "security/mbedtls/src/ssl_cookie.c"
)
return( -0x7100 );
if( cookie_len != ( 4 + 28 ) )
return( -1 );
if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 )
return( -0x6C00 + ret );
if( ssl_cookie_hmac( &ctx->hmac_ctx, cookie,
&p, p + sizeof( ref_hmac ),
cli_id, cli_id_len ) != 0 )
ret = -1;
if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 )
return( -0x6C00 +
-0x001E );
if( ret != 0 )
return( ret );
if( mbedtls_ssl_safer_memcmp( cookie + 4, ref_hmac, sizeof( ref_hmac ) ) != 0 )
return( -1 );
cur_time = ctx->serial;
cookie_time = ( (unsigned long) cookie[0] << 24 ) |
( (unsigned long) cookie[1] << 16 ) |
( (unsigned long) cookie[2] << 8 ) |
( (unsigned long) cookie[3] );
if( ctx->timeout != 0 && cur_time - cookie_time > ctx->timeout )
return( -1 );
return( 0 );
}
|
the_stack_data/192331057.c | #include <stdio.h>
#include <stdlib.h>
int main()
{
int r = 7;
int e = 23;
float pi = 3.14;
double kure_yuzey_alani = 4 * pi * r * r;
int kupun_yuzey_alani = 6 * e * e;
printf("Kupun yuzey alani: %d\n", kupun_yuzey_alani);
printf("Kurenin yuzey alani: %.5lf", kure_yuzey_alani);
return 0;
}
|
the_stack_data/14380.c | /*
* Linux roam cache
*
* Copyright (C) 1999-2018, Broadcom Corporation
*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to you
* under the terms of the GNU General Public License version 2 (the "GPL"),
* available at http://www.broadcom.com/licenses/GPLv2.php, with the
* following added to such license:
*
* As a special exception, the copyright holders of this software give you
* permission to link this software with independent modules, and to copy and
* distribute the resulting executable under terms of your choice, provided that
* you also meet, for each linked independent module, the terms and conditions of
* the license of that module. An independent module is a module which is not
* derived from this software. The special exception does not apply to any
* modifications of the software.
*
* Notwithstanding the above, under no circumstances may you combine this
* software in any way with any other Broadcom software provided under a license
* other than the GPL, without Broadcom's express prior written consent.
*
*
* <<Broadcom-WL-IPTag/Open:>>
*
* $Id: wl_roam.c 589977 2015-10-01 07:03:40Z $
*/
|
the_stack_data/70450823.c | #include <stdio.h>
int main()
{
int *p = NULL;
*p = 100;
printf("Value of *p : %d\n", *p);
return 0;
}
|
the_stack_data/193893888.c | int atoi(const char *nptr);
int isalnum(int c);
typedef int foo_fn(const char *);
int foo(foo_fn fn) {
int (*p)(const char *) = fn;
return p("10");
}
typedef int bar_fn(int);
int bar(bar_fn fn) {
return fn('a');
}
int main(void) {
#ifdef __APPLE__
return !(foo(atoi) + bar(isalnum) == 11);
#else
return !(foo(atoi) + bar(isalnum) == 18);
#endif
}
|
the_stack_data/73574293.c | /* Code generated from eC source file: BTNode.ec */
#if defined(__GNUC__)
typedef long long int64;
typedef unsigned long long uint64;
#ifndef _WIN32
#define __declspec(x)
#endif
#elif defined(__TINYC__)
#include <stdarg.h>
#define __builtin_va_list va_list
#define __builtin_va_start va_start
#define __builtin_va_end va_end
#ifdef _WIN32
#define strcasecmp stricmp
#define strncasecmp strnicmp
#define __declspec(x) __attribute__((x))
#else
#define __declspec(x)
#endif
typedef long long int64;
typedef unsigned long long uint64;
#else
typedef __int64 int64;
typedef unsigned __int64 uint64;
#endif
#ifdef __BIG_ENDIAN__
#define __ENDIAN_PAD(x) (8 - (x))
#else
#define __ENDIAN_PAD(x) 0
#endif
#include <stdint.h>
#include <sys/types.h>
#if /*defined(_W64) || */(defined(__WORDSIZE) && __WORDSIZE == 8) || defined(__x86_64__)
#define _64BIT 1
#else
#define _64BIT 0
#endif
#define arch_PointerSize sizeof(void *)
#define structSize_Instance (_64BIT ? 24 : 12)
extern void * __ecereNameSpace__ecere__com__eSystem_New(unsigned int size);
extern void * __ecereNameSpace__ecere__com__eSystem_New0(unsigned int size);
extern void * __ecereNameSpace__ecere__com__eSystem_Renew(void * memory, unsigned int size);
extern void * __ecereNameSpace__ecere__com__eSystem_Renew0(void * memory, unsigned int size);
extern void __ecereNameSpace__ecere__com__eSystem_Delete(void * memory);
struct __ecereNameSpace__ecere__sys__BTNode
{
uintptr_t key;
struct __ecereNameSpace__ecere__sys__BTNode * parent, * left, * right;
int depth;
} __attribute__ ((gcc_struct));
static struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__BTNode;
extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__BinaryTree;
struct __ecereNameSpace__ecere__sys__BinaryTree
{
struct __ecereNameSpace__ecere__sys__BTNode * root;
int count;
int (* CompareKey)(struct __ecereNameSpace__ecere__sys__BinaryTree * tree, uintptr_t a, uintptr_t b);
void (* FreeKey)(void * key);
} __attribute__ ((gcc_struct));
extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__OldList;
struct __ecereNameSpace__ecere__sys__OldList
{
void * first;
void * last;
int count;
unsigned int offset;
unsigned int circ;
} __attribute__ ((gcc_struct));
extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Class;
struct __ecereNameSpace__ecere__com__Class
{
struct __ecereNameSpace__ecere__com__Class * prev;
struct __ecereNameSpace__ecere__com__Class * next;
char * name;
int offset;
int structSize;
int (* * _vTbl)();
int vTblSize;
int (* Constructor)(struct __ecereNameSpace__ecere__com__Instance *);
void (* Destructor)(struct __ecereNameSpace__ecere__com__Instance *);
int offsetClass;
int sizeClass;
struct __ecereNameSpace__ecere__com__Class * base;
struct __ecereNameSpace__ecere__sys__BinaryTree methods;
struct __ecereNameSpace__ecere__sys__BinaryTree members;
struct __ecereNameSpace__ecere__sys__BinaryTree prop;
struct __ecereNameSpace__ecere__sys__OldList membersAndProperties;
struct __ecereNameSpace__ecere__sys__BinaryTree classProperties;
struct __ecereNameSpace__ecere__sys__OldList derivatives;
int memberID;
int startMemberID;
int type;
struct __ecereNameSpace__ecere__com__Instance * module;
struct __ecereNameSpace__ecere__com__NameSpace * nameSpace;
char * dataTypeString;
struct __ecereNameSpace__ecere__com__Instance * dataType;
int typeSize;
int defaultAlignment;
void (* Initialize)();
int memberOffset;
struct __ecereNameSpace__ecere__sys__OldList selfWatchers;
char * designerClass;
unsigned int noExpansion;
char * defaultProperty;
unsigned int comRedefinition;
int count;
unsigned int isRemote;
unsigned int internalDecl;
void * data;
unsigned int computeSize;
int structAlignment;
int destructionWatchOffset;
unsigned int fixed;
struct __ecereNameSpace__ecere__sys__OldList delayedCPValues;
int inheritanceAccess;
char * fullName;
void * symbol;
struct __ecereNameSpace__ecere__sys__OldList conversions;
struct __ecereNameSpace__ecere__sys__OldList templateParams;
struct __ecereNameSpace__ecere__com__ClassTemplateArgument * templateArgs;
struct __ecereNameSpace__ecere__com__Class * templateClass;
struct __ecereNameSpace__ecere__sys__OldList templatized;
int numParams;
unsigned int isInstanceClass;
unsigned int byValueSystemClass;
} __attribute__ ((gcc_struct));
extern long long __ecereNameSpace__ecere__com__eClass_GetProperty(struct __ecereNameSpace__ecere__com__Class * _class, char * name);
extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Property;
struct __ecereNameSpace__ecere__com__Property
{
struct __ecereNameSpace__ecere__com__Property * prev;
struct __ecereNameSpace__ecere__com__Property * next;
char * name;
unsigned int isProperty;
int memberAccess;
int id;
struct __ecereNameSpace__ecere__com__Class * _class;
char * dataTypeString;
struct __ecereNameSpace__ecere__com__Class * dataTypeClass;
struct __ecereNameSpace__ecere__com__Instance * dataType;
void (* Set)(void * , int);
int (* Get)(void * );
unsigned int (* IsSet)(void * );
void * data;
void * symbol;
int vid;
unsigned int conversion;
unsigned int watcherOffset;
char * category;
unsigned int compiled;
unsigned int selfWatchable;
unsigned int isWatchable;
} __attribute__ ((gcc_struct));
extern void __ecereNameSpace__ecere__com__eInstance_FireSelfWatchers(struct __ecereNameSpace__ecere__com__Instance * instance, struct __ecereNameSpace__ecere__com__Property * _property);
extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Instance;
struct __ecereNameSpace__ecere__com__Instance
{
int (* * _vTbl)();
struct __ecereNameSpace__ecere__com__Class * _class;
int _refCount;
} __attribute__ ((gcc_struct));
extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__DataMember;
struct __ecereNameSpace__ecere__com__DataMember
{
struct __ecereNameSpace__ecere__com__DataMember * prev;
struct __ecereNameSpace__ecere__com__DataMember * next;
char * name;
unsigned int isProperty;
int memberAccess;
int id;
struct __ecereNameSpace__ecere__com__Class * _class;
char * dataTypeString;
struct __ecereNameSpace__ecere__com__Class * dataTypeClass;
struct __ecereNameSpace__ecere__com__Instance * dataType;
int type;
int offset;
int memberID;
struct __ecereNameSpace__ecere__sys__OldList members;
struct __ecereNameSpace__ecere__sys__BinaryTree membersAlpha;
int memberOffset;
int structAlignment;
} __attribute__ ((gcc_struct));
extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Method;
struct __ecereNameSpace__ecere__com__Method
{
char * name;
struct __ecereNameSpace__ecere__com__Method * parent;
struct __ecereNameSpace__ecere__com__Method * left;
struct __ecereNameSpace__ecere__com__Method * right;
int depth;
int (* function)();
int vid;
int type;
struct __ecereNameSpace__ecere__com__Class * _class;
void * symbol;
char * dataTypeString;
struct __ecereNameSpace__ecere__com__Instance * dataType;
int memberAccess;
} __attribute__ ((gcc_struct));
extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__SerialBuffer;
struct __ecereNameSpace__ecere__com__SerialBuffer
{
unsigned char * _buffer;
unsigned int count;
unsigned int _size;
unsigned int pos;
} __attribute__ ((gcc_struct));
extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__DataValue;
struct __ecereNameSpace__ecere__com__DataValue
{
union
{
char c;
unsigned char uc;
short s;
unsigned short us;
int i;
unsigned int ui;
void * p;
float f;
double d;
long long i64;
uint64 ui64;
} __attribute__ ((gcc_struct));
} __attribute__ ((gcc_struct));
extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__ClassTemplateArgument;
struct __ecereNameSpace__ecere__com__ClassTemplateArgument
{
union
{
struct
{
char * dataTypeString;
struct __ecereNameSpace__ecere__com__Class * dataTypeClass;
} __attribute__ ((gcc_struct));
struct __ecereNameSpace__ecere__com__DataValue expression;
struct
{
char * memberString;
union
{
struct __ecereNameSpace__ecere__com__DataMember * member;
struct __ecereNameSpace__ecere__com__Property * prop;
struct __ecereNameSpace__ecere__com__Method * method;
} __attribute__ ((gcc_struct));
} __attribute__ ((gcc_struct));
} __attribute__ ((gcc_struct));
} __attribute__ ((gcc_struct));
typedef __builtin_va_list va_list;
static struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__TreePrintStyle;
extern int vsprintf(char * , const char * , __builtin_va_list);
extern size_t strlen(const char * );
void __ecereNameSpace__ecere__sys__strcatf(char * string, char * format, ...)
{
va_list args;
__builtin_va_start(args, format);
vsprintf(string + strlen(string), format, args);
__builtin_va_end(args);
}
static struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__sys__BTNode_prev, * __ecerePropM___ecereNameSpace__ecere__sys__BTNode_prev;
static struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__sys__BTNode_next, * __ecerePropM___ecereNameSpace__ecere__sys__BTNode_next;
static struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__sys__BTNode_count, * __ecerePropM___ecereNameSpace__ecere__sys__BTNode_count;
static struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__sys__BTNode_balanceFactor, * __ecerePropM___ecereNameSpace__ecere__sys__BTNode_balanceFactor;
void __ecereMethod___ecereNameSpace__ecere__com__IOChannel_Serialize(struct __ecereNameSpace__ecere__com__Instance * this, struct __ecereNameSpace__ecere__com__Class * class, void * data);
extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_bool;
extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_uint;
void __ecereMethod___ecereNameSpace__ecere__sys__BTNode_OnSerialize(struct __ecereNameSpace__ecere__com__Class * class, struct __ecereNameSpace__ecere__sys__BTNode * this, struct __ecereNameSpace__ecere__com__Instance * channel)
{
if((struct __ecereNameSpace__ecere__sys__BTNode *)this)
{
unsigned int __internalValue000;
unsigned int truth = 0x1;
__ecereMethod___ecereNameSpace__ecere__com__IOChannel_Serialize(channel, __ecereClass_bool, &truth);
__ecereMethod___ecereNameSpace__ecere__com__IOChannel_Serialize(channel, __ecereClass_uint, __extension__ ({
__internalValue000 = (unsigned int)this->key;
&__internalValue000;
}));
__ecereMethod___ecereNameSpace__ecere__com__IOChannel_Serialize(channel, __ecereClass___ecereNameSpace__ecere__sys__BTNode, this->left);
__ecereMethod___ecereNameSpace__ecere__com__IOChannel_Serialize(channel, __ecereClass___ecereNameSpace__ecere__sys__BTNode, this->right);
}
else
{
unsigned int nothing = 0;
__ecereMethod___ecereNameSpace__ecere__com__IOChannel_Serialize(channel, __ecereClass_uint, ¬hing);
}
}
extern void * __ecereNameSpace__ecere__com__eInstance_New(struct __ecereNameSpace__ecere__com__Class * _class);
void __ecereMethod___ecereNameSpace__ecere__com__IOChannel_Unserialize(struct __ecereNameSpace__ecere__com__Instance * this, struct __ecereNameSpace__ecere__com__Class * class, void * * data);
int __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_depthProp(struct __ecereNameSpace__ecere__sys__BTNode * this);
static struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__sys__BTNode_depthProp, * __ecerePropM___ecereNameSpace__ecere__sys__BTNode_depthProp;
void __ecereMethod___ecereNameSpace__ecere__sys__BTNode_OnUnserialize(struct __ecereNameSpace__ecere__com__Class * class, struct __ecereNameSpace__ecere__sys__BTNode ** this, struct __ecereNameSpace__ecere__com__Instance * channel)
{
unsigned int truth;
__ecereMethod___ecereNameSpace__ecere__com__IOChannel_Unserialize(channel, __ecereClass_bool, &truth);
if(truth)
{
(*this) = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass___ecereNameSpace__ecere__sys__BTNode);
{
unsigned int k;
__ecereMethod___ecereNameSpace__ecere__com__IOChannel_Unserialize(channel, __ecereClass_uint, &k);
(*this)->key = k;
}
__ecereMethod___ecereNameSpace__ecere__com__IOChannel_Unserialize(channel, __ecereClass___ecereNameSpace__ecere__sys__BTNode, &(*this)->left);
if((*this)->left)
{
(*this)->left->parent = *(struct __ecereNameSpace__ecere__sys__BTNode **)this;
}
__ecereMethod___ecereNameSpace__ecere__com__IOChannel_Unserialize(channel, __ecereClass___ecereNameSpace__ecere__sys__BTNode, &(*this)->right);
if((*this)->right)
{
(*this)->right->parent = *(struct __ecereNameSpace__ecere__sys__BTNode **)this;
}
(*this)->depth = __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_depthProp((*(struct __ecereNameSpace__ecere__sys__BTNode **)this));
}
else
(*this) = (((void *)0));
}
struct __ecereNameSpace__ecere__sys__BTNode * __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_maximum(struct __ecereNameSpace__ecere__sys__BTNode * this);
static struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__sys__BTNode_maximum, * __ecerePropM___ecereNameSpace__ecere__sys__BTNode_maximum;
struct __ecereNameSpace__ecere__sys__BTNode * __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_prev(struct __ecereNameSpace__ecere__sys__BTNode * this)
{
if(this->left)
return __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_maximum(this->left);
while(this)
{
if(this->parent && this == this->parent->right)
return this->parent;
else
this = this->parent;
}
return this;
}
struct __ecereNameSpace__ecere__sys__BTNode * __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_minimum(struct __ecereNameSpace__ecere__sys__BTNode * this);
static struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__sys__BTNode_minimum, * __ecerePropM___ecereNameSpace__ecere__sys__BTNode_minimum;
struct __ecereNameSpace__ecere__sys__BTNode * __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_next(struct __ecereNameSpace__ecere__sys__BTNode * this)
{
struct __ecereNameSpace__ecere__sys__BTNode * right = this->right;
if(right)
return __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_minimum(right);
while(this)
{
struct __ecereNameSpace__ecere__sys__BTNode * parent = this->parent;
if(parent && this == parent->left)
return parent;
else
this = parent;
}
return (((void *)0));
}
struct __ecereNameSpace__ecere__sys__BTNode * __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_minimum(struct __ecereNameSpace__ecere__sys__BTNode * this)
{
while(this->left)
this = this->left;
return this;
}
struct __ecereNameSpace__ecere__sys__BTNode * __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_maximum(struct __ecereNameSpace__ecere__sys__BTNode * this)
{
while(this->right)
this = this->right;
return this;
}
int __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_count(struct __ecereNameSpace__ecere__sys__BTNode * this)
{
return 1 + (this->left ? __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_count(this->left) : 0) + (this->right ? __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_count(this->right) : 0);
}
int __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_depthProp(struct __ecereNameSpace__ecere__sys__BTNode * this)
{
int leftDepth = this->left ? (__ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_depthProp(this->left) + 1) : 0;
int rightDepth = this->right ? (__ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_depthProp(this->right) + 1) : 0;
return ((leftDepth > rightDepth) ? leftDepth : rightDepth);
}
void __ecereMethod___ecereNameSpace__ecere__sys__BTNode_Free(struct __ecereNameSpace__ecere__sys__BTNode * this, void (* FreeKey)(void * key))
{
if(this->left)
__ecereMethod___ecereNameSpace__ecere__sys__BTNode_Free(this->left, FreeKey);
if(this->right)
__ecereMethod___ecereNameSpace__ecere__sys__BTNode_Free(this->right, FreeKey);
if(FreeKey)
FreeKey((void *)this->key);
((this ? (__ecereClass___ecereNameSpace__ecere__sys__BTNode->Destructor ? __ecereClass___ecereNameSpace__ecere__sys__BTNode->Destructor(this) : 0, __ecereNameSpace__ecere__com__eSystem_Delete(this)) : 0), this = 0);
}
unsigned int __ecereMethod___ecereNameSpace__ecere__sys__BTNode_Add(struct __ecereNameSpace__ecere__sys__BTNode * this, struct __ecereNameSpace__ecere__sys__BinaryTree * tree, struct __ecereNameSpace__ecere__sys__BTNode * node)
{
uintptr_t newKey = node->key;
while(0x1)
{
int result = tree->CompareKey(tree, newKey, this->key);
if(!result)
{
return 0x0;
}
else if(result > 0)
{
if(this->right)
this = this->right;
else
{
node->parent = this;
this->right = node;
node->depth = 0;
{
struct __ecereNameSpace__ecere__sys__BTNode * n;
for(n = this; n; n = n->parent)
{
int __simpleStruct0, __simpleStruct1;
int newDepth = (__simpleStruct0 = n->left ? (n->left->depth + 1) : 0, __simpleStruct1 = n->right ? (n->right->depth + 1) : 0, (__simpleStruct0 > __simpleStruct1) ? __simpleStruct0 : __simpleStruct1);
if(newDepth == n->depth)
break;
n->depth = newDepth;
}
}
return 0x1;
}
}
else
{
if(this->left)
this = this->left;
else
{
node->parent = this;
this->left = node;
node->depth = 0;
{
struct __ecereNameSpace__ecere__sys__BTNode * n;
for(n = this; n; n = n->parent)
{
int __simpleStruct0, __simpleStruct1;
int newDepth = (__simpleStruct0 = n->left ? (n->left->depth + 1) : 0, __simpleStruct1 = n->right ? (n->right->depth + 1) : 0, (__simpleStruct0 > __simpleStruct1) ? __simpleStruct0 : __simpleStruct1);
if(newDepth == n->depth)
break;
n->depth = newDepth;
}
}
return 0x1;
}
}
}
}
unsigned int __ecereMethod___ecereNameSpace__ecere__sys__BTNode_FindNode(struct __ecereNameSpace__ecere__sys__BTNode * this, struct __ecereNameSpace__ecere__sys__BTNode * node)
{
if(this == node)
return 0x1;
else if(this->left && __ecereMethod___ecereNameSpace__ecere__sys__BTNode_FindNode(this->left, node))
return 0x1;
else if(this->right && __ecereMethod___ecereNameSpace__ecere__sys__BTNode_FindNode(this->right, node))
return 0x1;
return 0x0;
}
struct __ecereNameSpace__ecere__sys__BTNode * __ecereMethod___ecereNameSpace__ecere__sys__BTNode_Find(struct __ecereNameSpace__ecere__sys__BTNode * this, struct __ecereNameSpace__ecere__sys__BinaryTree * tree, uintptr_t key)
{
while(this)
{
int result = tree->CompareKey(tree, key, this->key);
if(result < 0)
this = this->left;
else if(result > 0)
this = this->right;
else
break;
}
return this;
}
extern int strcmp(const char * , const char * );
struct __ecereNameSpace__ecere__sys__BTNode * __ecereMethod___ecereNameSpace__ecere__sys__BTNode_FindString(struct __ecereNameSpace__ecere__sys__BTNode * this, char * key)
{
while(this)
{
int result;
if(key && this->key)
result = strcmp(key, (char *)this->key);
else if(key && !this->key)
result = 1;
else if(!key && this->key)
result = -1;
else
result = 0;
if(result < 0)
this = this->left;
else if(result > 0)
this = this->right;
else
break;
}
return this;
}
extern int strncmp(const char * , const char * , size_t n);
struct __ecereNameSpace__ecere__sys__BTNode * __ecereMethod___ecereNameSpace__ecere__sys__BTNode_FindPrefix(struct __ecereNameSpace__ecere__sys__BTNode * this, char * key)
{
struct __ecereNameSpace__ecere__sys__BTNode * subString = (((void *)0));
int len = key ? strlen(key) : 0;
while(this)
{
int result;
if(key && this->key)
result = strcmp(key, (char *)this->key);
else if(key && !this->key)
result = 1;
else if(!key && this->key)
result = -1;
else
result = 0;
if(result < 0)
{
if(!strncmp(key, (char *)this->key, len))
subString = this;
this = this->left;
}
else if(result > 0)
this = this->right;
else
{
subString = this;
break;
}
}
return subString;
}
struct __ecereNameSpace__ecere__sys__BTNode * __ecereMethod___ecereNameSpace__ecere__sys__BTNode_FindAll(struct __ecereNameSpace__ecere__sys__BTNode * this, uintptr_t key)
{
struct __ecereNameSpace__ecere__sys__BTNode * result = (((void *)0));
if(this->key == key)
result = this;
if(!result && this->left)
result = __ecereMethod___ecereNameSpace__ecere__sys__BTNode_FindAll(this->left, key);
if(!result && this->right)
result = __ecereMethod___ecereNameSpace__ecere__sys__BTNode_FindAll(this->right, key);
return result;
}
void __ecereMethod___ecereNameSpace__ecere__sys__BTNode_RemoveSwap(struct __ecereNameSpace__ecere__sys__BTNode * this, struct __ecereNameSpace__ecere__sys__BTNode * swap)
{
if(swap->left)
{
swap->left->parent = swap->parent;
if(swap == swap->parent->left)
swap->parent->left = swap->left;
else if(swap == swap->parent->right)
swap->parent->right = swap->left;
swap->left = (((void *)0));
}
if(swap->right)
{
swap->right->parent = swap->parent;
if(swap == swap->parent->left)
swap->parent->left = swap->right;
else if(swap == swap->parent->right)
swap->parent->right = swap->right;
swap->right = (((void *)0));
}
if(swap == swap->parent->left)
swap->parent->left = (((void *)0));
else if(swap == swap->parent->right)
swap->parent->right = (((void *)0));
{
struct __ecereNameSpace__ecere__sys__BTNode * n;
for(n = swap->parent; n; n = n->parent)
{
int __simpleStruct0, __simpleStruct1;
int newDepth = (__simpleStruct0 = n->left ? (n->left->depth + 1) : 0, __simpleStruct1 = n->right ? (n->right->depth + 1) : 0, (__simpleStruct0 > __simpleStruct1) ? __simpleStruct0 : __simpleStruct1);
if(newDepth == n->depth)
break;
n->depth = newDepth;
if(n == this)
break;
}
}
{
swap->left = this->left;
if(this->left)
this->left->parent = swap;
}
{
swap->right = this->right;
if(this->right)
this->right->parent = swap;
}
swap->parent = this->parent;
this->left = (((void *)0));
this->right = (((void *)0));
if(this->parent)
{
if(this == this->parent->left)
this->parent->left = swap;
else if(this == this->parent->right)
this->parent->right = swap;
}
}
struct __ecereNameSpace__ecere__sys__BTNode * __ecereMethod___ecereNameSpace__ecere__sys__BTNode_Rebalance();
struct __ecereNameSpace__ecere__sys__BTNode * __ecereMethod___ecereNameSpace__ecere__sys__BTNode_RemoveSwapLeft(struct __ecereNameSpace__ecere__sys__BTNode * this)
{
struct __ecereNameSpace__ecere__sys__BTNode * swap = this->left ? __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_maximum(this->left) : this->right;
struct __ecereNameSpace__ecere__sys__BTNode * swapParent = (((void *)0));
if(swap)
{
swapParent = swap->parent;
__ecereMethod___ecereNameSpace__ecere__sys__BTNode_RemoveSwap(this, swap);
}
if(this->parent)
{
if(this == this->parent->left)
this->parent->left = (((void *)0));
else if(this == this->parent->right)
this->parent->right = (((void *)0));
}
{
struct __ecereNameSpace__ecere__sys__BTNode * n;
for(n = swap ? swap : this->parent; n; n = n->parent)
{
int __simpleStruct0, __simpleStruct1;
int newDepth = (__simpleStruct0 = n->left ? (n->left->depth + 1) : 0, __simpleStruct1 = n->right ? (n->right->depth + 1) : 0, (__simpleStruct0 > __simpleStruct1) ? __simpleStruct0 : __simpleStruct1);
if(newDepth == n->depth && n != swap)
break;
n->depth = newDepth;
}
}
if(swapParent && swapParent != this)
return __ecereMethod___ecereNameSpace__ecere__sys__BTNode_Rebalance(swapParent);
else if(swap)
return __ecereMethod___ecereNameSpace__ecere__sys__BTNode_Rebalance(swap);
else if(this->parent)
return __ecereMethod___ecereNameSpace__ecere__sys__BTNode_Rebalance(this->parent);
else
return (((void *)0));
}
struct __ecereNameSpace__ecere__sys__BTNode * __ecereMethod___ecereNameSpace__ecere__sys__BTNode_RemoveSwapRight(struct __ecereNameSpace__ecere__sys__BTNode * this)
{
struct __ecereNameSpace__ecere__sys__BTNode * result;
struct __ecereNameSpace__ecere__sys__BTNode * swap = this->right ? __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_minimum(this->right) : this->left;
struct __ecereNameSpace__ecere__sys__BTNode * swapParent = (((void *)0));
if(swap)
{
swapParent = swap->parent;
__ecereMethod___ecereNameSpace__ecere__sys__BTNode_RemoveSwap(this, swap);
}
if(this->parent)
{
if(this == this->parent->left)
this->parent->left = (((void *)0));
else if(this == this->parent->right)
this->parent->right = (((void *)0));
}
{
struct __ecereNameSpace__ecere__sys__BTNode * n;
for(n = swap ? swap : this->parent; n; n = n->parent)
{
int __simpleStruct0, __simpleStruct1;
int newDepth = (__simpleStruct0 = n->left ? (n->left->depth + 1) : 0, __simpleStruct1 = n->right ? (n->right->depth + 1) : 0, (__simpleStruct0 > __simpleStruct1) ? __simpleStruct0 : __simpleStruct1);
if(newDepth == n->depth && n != swap)
break;
n->depth = newDepth;
}
}
if(swapParent && swapParent != this)
result = __ecereMethod___ecereNameSpace__ecere__sys__BTNode_Rebalance(swapParent);
else if(swap)
result = __ecereMethod___ecereNameSpace__ecere__sys__BTNode_Rebalance(swap);
else if(this->parent)
result = __ecereMethod___ecereNameSpace__ecere__sys__BTNode_Rebalance(this->parent);
else
result = (((void *)0));
return result;
}
int __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_balanceFactor(struct __ecereNameSpace__ecere__sys__BTNode * this)
{
int leftDepth = this->left ? (this->left->depth + 1) : 0;
int rightDepth = this->right ? (this->right->depth + 1) : 0;
return rightDepth - leftDepth;
}
void __ecereMethod___ecereNameSpace__ecere__sys__BTNode_DoubleRotateRight();
void __ecereMethod___ecereNameSpace__ecere__sys__BTNode_SingleRotateRight();
void __ecereMethod___ecereNameSpace__ecere__sys__BTNode_DoubleRotateLeft();
void __ecereMethod___ecereNameSpace__ecere__sys__BTNode_SingleRotateLeft();
struct __ecereNameSpace__ecere__sys__BTNode * __ecereMethod___ecereNameSpace__ecere__sys__BTNode_Rebalance(struct __ecereNameSpace__ecere__sys__BTNode * this)
{
while(0x1)
{
int factor = __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_balanceFactor(this);
if(factor < -1)
{
if(__ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_balanceFactor(this->left) == 1)
__ecereMethod___ecereNameSpace__ecere__sys__BTNode_DoubleRotateRight(this);
else
__ecereMethod___ecereNameSpace__ecere__sys__BTNode_SingleRotateRight(this);
}
else if(factor > 1)
{
if(__ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_balanceFactor(this->right) == -1)
__ecereMethod___ecereNameSpace__ecere__sys__BTNode_DoubleRotateLeft(this);
else
__ecereMethod___ecereNameSpace__ecere__sys__BTNode_SingleRotateLeft(this);
}
if(this->parent)
this = this->parent;
else
return this;
}
}
void __ecereMethod___ecereNameSpace__ecere__sys__BTNode_SingleRotateRight(struct __ecereNameSpace__ecere__sys__BTNode * this)
{
int __simpleStruct2, __simpleStruct3;
int __simpleStruct0, __simpleStruct1;
if(this->parent)
{
if(this == this->parent->left)
this->parent->left = this->left;
else if(this == this->parent->right)
this->parent->right = this->left;
}
this->left->parent = this->parent;
this->parent = this->left;
this->left = this->parent->right;
if(this->left)
this->left->parent = this;
this->parent->right = this;
this->depth = (__simpleStruct0 = this->left ? (this->left->depth + 1) : 0, __simpleStruct1 = this->right ? (this->right->depth + 1) : 0, (__simpleStruct0 > __simpleStruct1) ? __simpleStruct0 : __simpleStruct1);
this->parent->depth = (__simpleStruct2 = this->parent->left ? (this->parent->left->depth + 1) : 0, __simpleStruct3 = this->parent->right ? (this->parent->right->depth + 1) : 0, (__simpleStruct2 > __simpleStruct3) ? __simpleStruct2 : __simpleStruct3);
{
struct __ecereNameSpace__ecere__sys__BTNode * n;
for(n = this->parent->parent; n; n = n->parent)
{
int __simpleStruct0, __simpleStruct1;
int newDepth = (__simpleStruct0 = n->left ? (n->left->depth + 1) : 0, __simpleStruct1 = n->right ? (n->right->depth + 1) : 0, (__simpleStruct0 > __simpleStruct1) ? __simpleStruct0 : __simpleStruct1);
if(newDepth == n->depth)
break;
n->depth = newDepth;
}
}
}
void __ecereMethod___ecereNameSpace__ecere__sys__BTNode_SingleRotateLeft(struct __ecereNameSpace__ecere__sys__BTNode * this)
{
int __simpleStruct2, __simpleStruct3;
int __simpleStruct0, __simpleStruct1;
if(this->parent)
{
if(this == this->parent->right)
this->parent->right = this->right;
else if(this == this->parent->left)
this->parent->left = this->right;
}
this->right->parent = this->parent;
this->parent = this->right;
this->right = this->parent->left;
if(this->right)
this->right->parent = this;
this->parent->left = this;
this->depth = (__simpleStruct0 = this->left ? (this->left->depth + 1) : 0, __simpleStruct1 = this->right ? (this->right->depth + 1) : 0, (__simpleStruct0 > __simpleStruct1) ? __simpleStruct0 : __simpleStruct1);
this->parent->depth = (__simpleStruct2 = this->parent->left ? (this->parent->left->depth + 1) : 0, __simpleStruct3 = this->parent->right ? (this->parent->right->depth + 1) : 0, (__simpleStruct2 > __simpleStruct3) ? __simpleStruct2 : __simpleStruct3);
{
struct __ecereNameSpace__ecere__sys__BTNode * n;
for(n = this->parent->parent; n; n = n->parent)
{
int __simpleStruct0, __simpleStruct1;
int newDepth = (__simpleStruct0 = n->left ? (n->left->depth + 1) : 0, __simpleStruct1 = n->right ? (n->right->depth + 1) : 0, (__simpleStruct0 > __simpleStruct1) ? __simpleStruct0 : __simpleStruct1);
if(newDepth == n->depth)
break;
n->depth = newDepth;
}
}
}
void __ecereMethod___ecereNameSpace__ecere__sys__BTNode_DoubleRotateRight(struct __ecereNameSpace__ecere__sys__BTNode * this)
{
__ecereMethod___ecereNameSpace__ecere__sys__BTNode_SingleRotateLeft(this->left);
__ecereMethod___ecereNameSpace__ecere__sys__BTNode_SingleRotateRight(this);
}
void __ecereMethod___ecereNameSpace__ecere__sys__BTNode_DoubleRotateLeft(struct __ecereNameSpace__ecere__sys__BTNode * this)
{
__ecereMethod___ecereNameSpace__ecere__sys__BTNode_SingleRotateRight(this->right);
__ecereMethod___ecereNameSpace__ecere__sys__BTNode_SingleRotateLeft(this);
}
extern char * strcat(char * , const char * );
void __ecereMethod___ecereNameSpace__ecere__sys__BTNode_PrintDepth(struct __ecereNameSpace__ecere__sys__BTNode * this, char * output, int wantedDepth, int curDepth, int maxDepth, unsigned int last);
char * __ecereMethod___ecereNameSpace__ecere__sys__BTNode_Print(struct __ecereNameSpace__ecere__sys__BTNode * this, char * output, int tps)
{
switch(tps)
{
case 0:
case 2:
case 1:
{
if(tps == 2)
__ecereNameSpace__ecere__sys__strcatf(output, "%d ", this->key);
if(this->left)
__ecereMethod___ecereNameSpace__ecere__sys__BTNode_Print(this->left, output, tps);
if(tps == 0)
__ecereNameSpace__ecere__sys__strcatf(output, "%d ", this->key);
if(this->right)
__ecereMethod___ecereNameSpace__ecere__sys__BTNode_Print(this->right, output, tps);
if(tps == 1)
__ecereNameSpace__ecere__sys__strcatf(output, "%d ", this->key);
return output;
}
case 3:
{
int maxDepth = this->depth;
int curDepth;
for(curDepth = 0; curDepth <= maxDepth; curDepth++)
{
int c;
for(c = 0; c < ((1 << (maxDepth - curDepth)) - 1) * 4 / 2; c++)
strcat(output, " ");
__ecereMethod___ecereNameSpace__ecere__sys__BTNode_PrintDepth(this, output, curDepth, 0, maxDepth, 0x1);
strcat(output, "\n");
}
return output;
}
}
return (((void *)0));
}
extern int sprintf(char * , char * , ...);
void __ecereMethod___ecereNameSpace__ecere__sys__BTNode_PrintDepth(struct __ecereNameSpace__ecere__sys__BTNode * this, char * output, int wantedDepth, int curDepth, int maxDepth, unsigned int last)
{
int c;
if(wantedDepth == curDepth)
{
char nodeString[10] = "";
int len;
if(this)
sprintf(nodeString, "%d", this->key);
len = strlen(nodeString);
for(c = 0; c < (4 - len) / 2; c++)
strcat(output, " ");
len += c;
strcat(output, nodeString);
for(c = len; c < 4; c++)
strcat(output, " ");
if(curDepth && !last)
{
for(c = 0; c < ((1 << (maxDepth - curDepth)) - 1) * 4; c++)
strcat(output, " ");
}
}
else if(curDepth <= maxDepth)
{
__ecereMethod___ecereNameSpace__ecere__sys__BTNode_PrintDepth((this ? this->left : (struct __ecereNameSpace__ecere__sys__BTNode *)(((void *)0))), output, wantedDepth, curDepth + 1, maxDepth, last && this && !this->right);
__ecereMethod___ecereNameSpace__ecere__sys__BTNode_PrintDepth((this ? this->right : (struct __ecereNameSpace__ecere__sys__BTNode *)(((void *)0))), output, wantedDepth, curDepth + 1, maxDepth, last);
}
}
extern int printf(char * , ...);
unsigned int __ecereMethod___ecereNameSpace__ecere__sys__BTNode_Check(struct __ecereNameSpace__ecere__sys__BTNode * this, struct __ecereNameSpace__ecere__sys__BinaryTree * tree)
{
unsigned int valid = 0x1;
int leftHeight = this->left ? __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_depthProp(this->left) + 1 : 0;
int rightHeight = this->right ? __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_depthProp(this->right) + 1 : 0;
int diffHeight = rightHeight - leftHeight;
if(this->left)
{
if(this->left->parent != this)
{
printf("Parent not set properly at node %d\n", this->left->key);
valid = 0x0;
}
valid *= __ecereMethod___ecereNameSpace__ecere__sys__BTNode_Check(this->left, tree);
}
if(this->right)
{
if(this->right->parent != this)
{
printf("Parent not set properly at node %d\n", this->right->key);
valid = 0x0;
}
valid *= __ecereMethod___ecereNameSpace__ecere__sys__BTNode_Check(this->right, tree);
}
if(this->depth != __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_depthProp(this))
{
printf("Depth value at node %d (%d) doesn't match depth property (%d)\n", this->key, this->depth, __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_depthProp(this));
valid = (unsigned int)0;
}
if(diffHeight < -1 || diffHeight > 1)
{
valid = (unsigned int)0;
printf("Height difference is %d at node %d\n", diffHeight, this->key);
}
if(diffHeight != __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_balanceFactor(this))
{
valid = (unsigned int)0;
printf("Height difference %d doesnt match balance-factor of %d at node \n", diffHeight, __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_balanceFactor(this), this->key);
}
if(this->left && tree->CompareKey(tree, this->left->key, this->key) > 0)
{
valid = 0x0;
printf("Node %d is *smaller* than left subtree %d\n", this->key, this->left->key);
}
if(this->right && tree->CompareKey(tree, this->right->key, this->key) < 0)
{
valid = 0x0;
printf("Node %d is *greater* than right subtree %d\n", this->key, this->right->key);
}
return valid;
}
struct __ecereNameSpace__ecere__sys__StringBTNode
{
char * key;
struct __ecereNameSpace__ecere__sys__StringBTNode * parent, * left, * right;
int depth;
} __attribute__ ((gcc_struct));
static struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__StringBTNode;
extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_String;
void __ecereMethod___ecereNameSpace__ecere__sys__StringBTNode_OnSerialize(struct __ecereNameSpace__ecere__com__Class * class, struct __ecereNameSpace__ecere__sys__StringBTNode * this, struct __ecereNameSpace__ecere__com__Instance * channel)
{
if((struct __ecereNameSpace__ecere__sys__StringBTNode *)this)
{
unsigned int truth = 0x1;
__ecereMethod___ecereNameSpace__ecere__com__IOChannel_Serialize(channel, __ecereClass_bool, &truth);
__ecereMethod___ecereNameSpace__ecere__com__IOChannel_Serialize(channel, __ecereClass_String, this->key);
__ecereMethod___ecereNameSpace__ecere__com__IOChannel_Serialize(channel, __ecereClass___ecereNameSpace__ecere__sys__StringBTNode, this->left);
__ecereMethod___ecereNameSpace__ecere__com__IOChannel_Serialize(channel, __ecereClass___ecereNameSpace__ecere__sys__StringBTNode, this->right);
}
else
{
unsigned int nothing = 0;
__ecereMethod___ecereNameSpace__ecere__com__IOChannel_Serialize(channel, __ecereClass_uint, ¬hing);
}
}
void __ecereMethod___ecereNameSpace__ecere__sys__StringBTNode_OnUnserialize(struct __ecereNameSpace__ecere__com__Class * class, struct __ecereNameSpace__ecere__sys__StringBTNode ** this, struct __ecereNameSpace__ecere__com__Instance * channel)
{
unsigned int truth;
__ecereMethod___ecereNameSpace__ecere__com__IOChannel_Unserialize(channel, __ecereClass_bool, &truth);
if(truth)
{
(*this) = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass___ecereNameSpace__ecere__sys__StringBTNode);
__ecereMethod___ecereNameSpace__ecere__com__IOChannel_Unserialize(channel, __ecereClass_String, &(*this)->key);
__ecereMethod___ecereNameSpace__ecere__com__IOChannel_Unserialize(channel, __ecereClass___ecereNameSpace__ecere__sys__StringBTNode, &(*this)->left);
if((*this)->left)
{
(*this)->left->parent = *(struct __ecereNameSpace__ecere__sys__StringBTNode **)this;
}
__ecereMethod___ecereNameSpace__ecere__com__IOChannel_Unserialize(channel, __ecereClass___ecereNameSpace__ecere__sys__StringBTNode, &(*this)->right);
if((*this)->right)
{
(*this)->right->parent = *(struct __ecereNameSpace__ecere__sys__StringBTNode **)this;
}
(*this)->depth = __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_depthProp(((struct __ecereNameSpace__ecere__sys__BTNode *)*(struct __ecereNameSpace__ecere__sys__StringBTNode **)this));
}
else
(*this) = (((void *)0));
}
extern struct __ecereNameSpace__ecere__com__Class * __ecereNameSpace__ecere__com__eSystem_RegisterClass(int type, char * name, char * baseName, int size, int sizeClass, unsigned int (* Constructor)(void * ), void (* Destructor)(void * ), struct __ecereNameSpace__ecere__com__Instance * module, int declMode, int inheritanceAccess);
extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__NameSpace;
struct __ecereNameSpace__ecere__com__NameSpace
{
char * name;
struct __ecereNameSpace__ecere__com__NameSpace * btParent;
struct __ecereNameSpace__ecere__com__NameSpace * left;
struct __ecereNameSpace__ecere__com__NameSpace * right;
int depth;
struct __ecereNameSpace__ecere__com__NameSpace * parent;
struct __ecereNameSpace__ecere__sys__BinaryTree nameSpaces;
struct __ecereNameSpace__ecere__sys__BinaryTree classes;
struct __ecereNameSpace__ecere__sys__BinaryTree defines;
struct __ecereNameSpace__ecere__sys__BinaryTree functions;
} __attribute__ ((gcc_struct));
extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Module;
struct __ecereNameSpace__ecere__com__Module
{
struct __ecereNameSpace__ecere__com__Instance * application;
struct __ecereNameSpace__ecere__sys__OldList classes;
struct __ecereNameSpace__ecere__sys__OldList defines;
struct __ecereNameSpace__ecere__sys__OldList functions;
struct __ecereNameSpace__ecere__sys__OldList modules;
struct __ecereNameSpace__ecere__com__Instance * prev;
struct __ecereNameSpace__ecere__com__Instance * next;
char * name;
void * library;
void * Unload;
int importType;
int origImportType;
struct __ecereNameSpace__ecere__com__NameSpace privateNameSpace;
struct __ecereNameSpace__ecere__com__NameSpace publicNameSpace;
} __attribute__ ((gcc_struct));
extern struct __ecereNameSpace__ecere__com__Instance * __thisModule;
extern void __ecereNameSpace__ecere__com__eEnum_AddFixedValue(struct __ecereNameSpace__ecere__com__Class * _class, char * string, int value);
extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__GlobalFunction;
struct __ecereNameSpace__ecere__com__GlobalFunction;
extern struct __ecereNameSpace__ecere__com__GlobalFunction * __ecereNameSpace__ecere__com__eSystem_RegisterFunction(char * name, char * type, void * func, struct __ecereNameSpace__ecere__com__Instance * module, int declMode);
extern struct __ecereNameSpace__ecere__com__Method * __ecereNameSpace__ecere__com__eClass_AddMethod(struct __ecereNameSpace__ecere__com__Class * _class, char * name, char * type, void * function, int declMode);
extern struct __ecereNameSpace__ecere__com__DataMember * __ecereNameSpace__ecere__com__eClass_AddDataMember(struct __ecereNameSpace__ecere__com__Class * _class, char * name, char * type, unsigned int size, unsigned int alignment, int declMode);
extern struct __ecereNameSpace__ecere__com__Property * __ecereNameSpace__ecere__com__eClass_AddProperty(struct __ecereNameSpace__ecere__com__Class * _class, char * name, char * dataType, void * setStmt, void * getStmt, int declMode);
void __ecereRegisterModule_BTNode(struct __ecereNameSpace__ecere__com__Instance * module)
{
struct __ecereNameSpace__ecere__com__Class * class;
class = __ecereNameSpace__ecere__com__eSystem_RegisterClass(4, "ecere::sys::TreePrintStyle", 0, 0, 0, 0, 0, module, 4, 1);
if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application && class)
__ecereClass___ecereNameSpace__ecere__sys__TreePrintStyle = class;
__ecereNameSpace__ecere__com__eEnum_AddFixedValue(class, "inOrder", 0);
__ecereNameSpace__ecere__com__eEnum_AddFixedValue(class, "postOrder", 1);
__ecereNameSpace__ecere__com__eEnum_AddFixedValue(class, "preOrder", 2);
__ecereNameSpace__ecere__com__eEnum_AddFixedValue(class, "depthOrder", 3);
__ecereNameSpace__ecere__com__eSystem_RegisterFunction("ecere::sys::strcatf", "void ecere::sys::strcatf(char * string, char * format, ...)", __ecereNameSpace__ecere__sys__strcatf, module, 4);
class = __ecereNameSpace__ecere__com__eSystem_RegisterClass(5, "ecere::sys::BTNode", 0, sizeof(struct __ecereNameSpace__ecere__sys__BTNode), 0, 0, 0, module, 4, 1);
if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application && class)
__ecereClass___ecereNameSpace__ecere__sys__BTNode = class;
__ecereNameSpace__ecere__com__eClass_AddMethod(class, "OnSerialize", 0, __ecereMethod___ecereNameSpace__ecere__sys__BTNode_OnSerialize, 1);
__ecereNameSpace__ecere__com__eClass_AddMethod(class, "OnUnserialize", 0, __ecereMethod___ecereNameSpace__ecere__sys__BTNode_OnUnserialize, 1);
__ecereNameSpace__ecere__com__eClass_AddMethod(class, "FindPrefix", "ecere::sys::BTNode FindPrefix(char * key)", __ecereMethod___ecereNameSpace__ecere__sys__BTNode_FindPrefix, 1);
__ecereNameSpace__ecere__com__eClass_AddMethod(class, "FindString", "ecere::sys::BTNode FindString(char * key)", __ecereMethod___ecereNameSpace__ecere__sys__BTNode_FindString, 1);
__ecereNameSpace__ecere__com__eClass_AddDataMember(class, "key", "uintptr", arch_PointerSize, arch_PointerSize, 1);
__ecereNameSpace__ecere__com__eClass_AddDataMember(class, "parent", "ecere::sys::BTNode", arch_PointerSize, arch_PointerSize, 1);
__ecereNameSpace__ecere__com__eClass_AddDataMember(class, "left", "ecere::sys::BTNode", arch_PointerSize, arch_PointerSize, 1);
__ecereNameSpace__ecere__com__eClass_AddDataMember(class, "right", "ecere::sys::BTNode", arch_PointerSize, arch_PointerSize, 1);
__ecereNameSpace__ecere__com__eClass_AddDataMember(class, "depth", "int", 4, 4, 1);
__ecerePropM___ecereNameSpace__ecere__sys__BTNode_prev = __ecereNameSpace__ecere__com__eClass_AddProperty(class, "prev", "ecere::sys::BTNode", 0, __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_prev, 1);
if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application)
__ecereProp___ecereNameSpace__ecere__sys__BTNode_prev = __ecerePropM___ecereNameSpace__ecere__sys__BTNode_prev, __ecerePropM___ecereNameSpace__ecere__sys__BTNode_prev = (void *)0;
__ecerePropM___ecereNameSpace__ecere__sys__BTNode_next = __ecereNameSpace__ecere__com__eClass_AddProperty(class, "next", "ecere::sys::BTNode", 0, __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_next, 1);
if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application)
__ecereProp___ecereNameSpace__ecere__sys__BTNode_next = __ecerePropM___ecereNameSpace__ecere__sys__BTNode_next, __ecerePropM___ecereNameSpace__ecere__sys__BTNode_next = (void *)0;
__ecerePropM___ecereNameSpace__ecere__sys__BTNode_minimum = __ecereNameSpace__ecere__com__eClass_AddProperty(class, "minimum", "ecere::sys::BTNode", 0, __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_minimum, 1);
if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application)
__ecereProp___ecereNameSpace__ecere__sys__BTNode_minimum = __ecerePropM___ecereNameSpace__ecere__sys__BTNode_minimum, __ecerePropM___ecereNameSpace__ecere__sys__BTNode_minimum = (void *)0;
__ecerePropM___ecereNameSpace__ecere__sys__BTNode_maximum = __ecereNameSpace__ecere__com__eClass_AddProperty(class, "maximum", "ecere::sys::BTNode", 0, __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_maximum, 1);
if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application)
__ecereProp___ecereNameSpace__ecere__sys__BTNode_maximum = __ecerePropM___ecereNameSpace__ecere__sys__BTNode_maximum, __ecerePropM___ecereNameSpace__ecere__sys__BTNode_maximum = (void *)0;
__ecerePropM___ecereNameSpace__ecere__sys__BTNode_count = __ecereNameSpace__ecere__com__eClass_AddProperty(class, "count", "int", 0, __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_count, 1);
if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application)
__ecereProp___ecereNameSpace__ecere__sys__BTNode_count = __ecerePropM___ecereNameSpace__ecere__sys__BTNode_count, __ecerePropM___ecereNameSpace__ecere__sys__BTNode_count = (void *)0;
__ecerePropM___ecereNameSpace__ecere__sys__BTNode_depthProp = __ecereNameSpace__ecere__com__eClass_AddProperty(class, "depthProp", "int", 0, __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_depthProp, 1);
if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application)
__ecereProp___ecereNameSpace__ecere__sys__BTNode_depthProp = __ecerePropM___ecereNameSpace__ecere__sys__BTNode_depthProp, __ecerePropM___ecereNameSpace__ecere__sys__BTNode_depthProp = (void *)0;
__ecerePropM___ecereNameSpace__ecere__sys__BTNode_balanceFactor = __ecereNameSpace__ecere__com__eClass_AddProperty(class, "balanceFactor", "int", 0, __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_balanceFactor, 2);
if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application)
__ecereProp___ecereNameSpace__ecere__sys__BTNode_balanceFactor = __ecerePropM___ecereNameSpace__ecere__sys__BTNode_balanceFactor, __ecerePropM___ecereNameSpace__ecere__sys__BTNode_balanceFactor = (void *)0;
if(class)
class->fixed = (unsigned int)1;
class = __ecereNameSpace__ecere__com__eSystem_RegisterClass(5, "ecere::sys::StringBTNode", 0, sizeof(struct __ecereNameSpace__ecere__sys__StringBTNode), 0, 0, 0, module, 4, 1);
if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application && class)
__ecereClass___ecereNameSpace__ecere__sys__StringBTNode = class;
__ecereNameSpace__ecere__com__eClass_AddMethod(class, "OnSerialize", 0, __ecereMethod___ecereNameSpace__ecere__sys__StringBTNode_OnSerialize, 1);
__ecereNameSpace__ecere__com__eClass_AddMethod(class, "OnUnserialize", 0, __ecereMethod___ecereNameSpace__ecere__sys__StringBTNode_OnUnserialize, 1);
__ecereNameSpace__ecere__com__eClass_AddDataMember(class, "key", "String", arch_PointerSize, arch_PointerSize, 1);
__ecereNameSpace__ecere__com__eClass_AddDataMember(class, "parent", "ecere::sys::StringBTNode", arch_PointerSize, arch_PointerSize, 1);
__ecereNameSpace__ecere__com__eClass_AddDataMember(class, "left", "ecere::sys::StringBTNode", arch_PointerSize, arch_PointerSize, 1);
__ecereNameSpace__ecere__com__eClass_AddDataMember(class, "right", "ecere::sys::StringBTNode", arch_PointerSize, arch_PointerSize, 1);
__ecereNameSpace__ecere__com__eClass_AddDataMember(class, "depth", "int", 4, 4, 1);
if(class)
class->fixed = (unsigned int)1;
}
void __ecereUnregisterModule_BTNode(struct __ecereNameSpace__ecere__com__Instance * module)
{
__ecerePropM___ecereNameSpace__ecere__sys__BTNode_prev = (void *)0;
__ecerePropM___ecereNameSpace__ecere__sys__BTNode_next = (void *)0;
__ecerePropM___ecereNameSpace__ecere__sys__BTNode_minimum = (void *)0;
__ecerePropM___ecereNameSpace__ecere__sys__BTNode_maximum = (void *)0;
__ecerePropM___ecereNameSpace__ecere__sys__BTNode_count = (void *)0;
__ecerePropM___ecereNameSpace__ecere__sys__BTNode_depthProp = (void *)0;
__ecerePropM___ecereNameSpace__ecere__sys__BTNode_balanceFactor = (void *)0;
}
|
the_stack_data/64199646.c | /* $OpenBSD: strsep.c,v 1.7 2014/02/05 20:42:32 stsp Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <string.h>
/*
* Get next token from string *stringp, where tokens are possibly-empty
* strings separated by characters from delim.
*
* Writes NULs into the string at *stringp to end tokens.
* delim need not remain constant from call to call.
* On return, *stringp points past the last NUL written (if there might
* be further tokens), or is NULL (if there are definitely no more tokens).
*
* If *stringp is NULL, strsep returns NULL.
*/
char *
strsep(char **stringp, const char *delim)
{
char *s;
const char *spanp;
int c, sc;
char *tok;
if ((s = *stringp) == NULL)
return (NULL);
for (tok = s;;) {
c = *s++;
spanp = delim;
do {
if ((sc = *spanp++) == c) {
if (c == 0)
s = NULL;
else
s[-1] = 0;
*stringp = s;
return (tok);
}
} while (sc != 0);
}
/* NOTREACHED */
}
|
the_stack_data/51700707.c | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdio.h>
#include <syscall.h>
#include <unistd.h>
void* thread_func(void* args)
{
int readFd = *(int*)args;
while (1)
{
int ret, data;
// read is blocking until writer writes to pipe
while ((ret = read(readFd, &data, 1)) < 0 && errno == EINTR)
;
if (ret < 0)
{
close(readFd);
return;
}
}
printf("unreachable (%s)\n", __FUNCTION__);
}
int main(int argc, const char* argv[])
{
int pipeFds[2];
int flags = O_CLOEXEC;
int ret = pipe2(pipeFds, flags);
assert(ret == 0);
pthread_t child;
pthread_create(&child, NULL, thread_func, &pipeFds[0]);
printf("main thread exiting w/o writing to pipe...\n");
// CRT will call sys_exit_group as part of exit sequence
// this should kill the child thread
return 0;
}
|
the_stack_data/92326059.c | // RUN: echo "GNU89 tests:"
// RUN: %clang %s -target i386-unknown-unknown -O1 -emit-llvm -S -o - -std=gnu89 | FileCheck %s --check-prefix=CHECK1
// CHECK1: define i32 @foo()
// CHECK1: define i32 @bar()
// CHECK1: define void @unreferenced1()
// CHECK1-NOT: unreferenced2
// CHECK1: define void @gnu_inline()
// CHECK1: define i32 @test1
// CHECK1: define i32 @test2
// CHECK1: define void @test3()
// CHECK1: define available_externally i32 @test4
// CHECK1: define available_externally i32 @test5
// CHECK1: define i32 @test6
// CHECK1: define void @test7
// CHECK1: define i{{..}} @strlcpy
// CHECK1-NOT: test9
// CHECK1: define void @testA
// CHECK1: define void @testB
// CHECK1: define void @testC
// CHECK1: define available_externally void @gnu_ei_inline()
// CHECK1: define available_externally i32 @ei()
// RUN: echo "C99 tests:"
// RUN: %clang %s -target i386-unknown-unknown -O1 -emit-llvm -S -o - -std=gnu99 | FileCheck %s --check-prefix=CHECK2
// CHECK2: define i32 @ei()
// CHECK2: define i32 @bar()
// CHECK2-NOT: unreferenced1
// CHECK2: define void @unreferenced2()
// CHECK2: define void @gnu_inline()
// CHECK2: define i32 @test1
// CHECK2: define i32 @test2
// CHECK2: define void @test3
// CHECK2: define available_externally i32 @test4
// CHECK2: define available_externally i32 @test5
// CHECK2: define i32 @test6
// CHECK2: define void @test7
// CHECK2: define available_externally i{{..}} @strlcpy
// CHECK2: define void @test9
// CHECK2: define void @testA
// CHECK2: define void @testB
// CHECK2: define void @testC
// CHECK2: define available_externally void @gnu_ei_inline()
// CHECK2: define available_externally i32 @foo()
// RUN: echo "C++ tests:"
// RUN: %clang -x c++ %s -target i386-unknown-unknown -O1 -emit-llvm -S -o - -std=c++98 | FileCheck %s --check-prefix=CHECK3
// CHECK3: define i32 @_Z3barv()
// CHECK3: define linkonce_odr i32 @_Z3foov()
// CHECK3-NOT: unreferenced
// CHECK3: define void @_Z10gnu_inlinev()
// CHECK3: define available_externally void @_Z13gnu_ei_inlinev()
// CHECK3: define linkonce_odr i32 @_Z2eiv()
extern __inline int ei() { return 123; }
__inline int foo() {
return ei();
}
int bar() { return foo(); }
__inline void unreferenced1() {}
extern __inline void unreferenced2() {}
__inline __attribute((__gnu_inline__)) void gnu_inline() {}
// PR3988
extern __inline __attribute__((gnu_inline)) void gnu_ei_inline() {}
void (*P)() = gnu_ei_inline;
// <rdar://problem/6818429>
int test1();
__inline int test1() { return 4; }
__inline int test2() { return 5; }
__inline int test2();
int test2();
void test_test1() { test1(); }
void test_test2() { test2(); }
// PR3989
extern __inline void test3() __attribute__((gnu_inline));
__inline void __attribute__((gnu_inline)) test3() {}
extern int test4(void);
extern __inline __attribute__ ((__gnu_inline__)) int test4(void)
{
return 0;
}
void test_test4() { test4(); }
extern __inline int test5(void) __attribute__ ((__gnu_inline__));
extern __inline int __attribute__ ((__gnu_inline__)) test5(void)
{
return 0;
}
void test_test5() { test5(); }
// PR10233
__inline int test6() { return 0; }
extern int test6();
// No PR#, but this once crashed clang in C99 mode due to buggy extern inline
// redeclaration detection.
void test7() { }
void test7();
// PR11062; the fact that the function is named strlcpy matters here.
inline __typeof(sizeof(int)) strlcpy(char *dest, const char *src, __typeof(sizeof(int)) size) { return 3; }
void test8() { strlcpy(0,0,0); }
// PR10657; the test crashed in C99 mode
extern inline void test9() { }
void test9();
inline void testA() {}
void testA();
void testB();
inline void testB() {}
extern void testB();
extern inline void testC() {}
inline void testC();
|
the_stack_data/817429.c | #include<stdio.h>
int main() {
int X = 5;
int Y = 8;
printf("Hasil X < Y: %d\n", X < Y);
printf("Hasil X > Y: %d\n", X > Y);
printf("Hasil X <= Y: %d\n", X <= Y);
printf("Hasil X >= Y: %d\n", X >= Y);
printf("Hasil X == Y: %d\n", X == Y);
printf("Hasil X != Y: %d\n", X != Y);
printf("Hasil X == X: %d\n", X == X);
printf("Hasil X != X: %d\n", X != X);
return 0;
} |
the_stack_data/90763525.c | // RUN: %llvmgcc -S %s -o - | \
// RUN: opt -std-compile-opts -S | not grep {declare i32.*func}
// There should not be an unresolved reference to func here. Believe it or not,
// the "expected result" is a function named 'func' which is internal and
// referenced by bar().
// This is PR244
static int func();
void bar() {
int func();
foo(func);
}
static int func(char** A, char ** B) {}
|
the_stack_data/50136828.c | // 3. 修改8.2节的deal.c程序,使它显示出牌的全名:
// 提示:用指向字符串的指针的数组来替换数组rank_code和数组suit_code。
/* Deals a random hand of cards */
#include <stdbool.h> /* C99 only */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define NUM_SUITS 4
#define NUM_RANKS 13
int main(void) {
bool in_hand[NUM_SUITS][NUM_RANKS] = {false};
int num_cards, rank, suit;
const char* rank_code[] = {"Two", "Three", "Four", "Five", "Six",
"Seven", "Eight", "Nine", "Ten", "Jack",
"Queen", "King", "Ace"};
const char* suit_code[] = {"club", "diamond", "heart", "spade"};
srand((unsigned)time(NULL));
printf("Enter number of cards in hand: ");
scanf("%d", &num_cards);
printf("Your hand:\n");
while (num_cards > 0) {
suit = rand() % NUM_SUITS; /* picks a random suit */
rank = rand() % NUM_RANKS; /* picks a random rank */
if (!in_hand[suit][rank]) {
in_hand[suit][rank] = true;
num_cards--;
printf("\t%s of %s\n", rank_code[rank], suit_code[suit]);
}
}
printf("\n");
return 0;
} |
the_stack_data/116146.c | int main() {
struct s {
int m1;
};
struct s o1;
}
|
the_stack_data/131600.c | #include <stdio.h>
#include <unistd.h>
int main(void)
{
int i;
printf("Hi, starting to run now!\n");
while(1) {
sleep(1);
i++;
fprintf(stdout, "Ran for %d seconds\n", i);
fprintf(stderr, "Ran for %d seconds\n", i);
}
fprintf(stderr, "Ho... finished the loop!\n");
return 0;
}
|
the_stack_data/40763379.c | /* nosc-server.c -- an OSC server for Nyquist */
/*
* this enables OSC clients to set slider values in Nyquist
* for security reasons, OSC clients cannot invoke Lisp expressions
* the only operation allowed is to set a value in a Lisp array
*
* The API is:
*
* int nosc_init() -- initialize the server, return error, 0 means none
* int nosc_poll() -- poll for messages and process them, return error, 0 means none
* void nosc_finish() -- free data structures, return error, 0 means none
*/
#ifdef OSC
#ifdef WIN32
#include <winsock2.h>
#include <malloc.h>
#include <process.h>
#else
#include <stdlib.h>
#include <sys/time.h>
#include <sys/types.h>
#ifndef __APPLE__ // OS X does not have strings.h
#include <strings.h>
#endif
#include <unistd.h>
#include <stdio.h>
#endif
#include "xlisp.h"
#include "sound.h" /* to get nosc_enabled */
#include "lo/lo.h"
#include "nyq-osc-server.h"
#include "sndsliders.h"
#include "sliderdata.h"
static lo_server the_server = NULL;
static int lo_fd;
static void error(int num, const char *msg, const char *path)
{
char s[256];
snprintf(s, 255, "liblo server error %d in path %s: %s\n", num, path, msg);
stdputstr(s);
}
static int slider_handler(const char *path, const char *types, lo_arg **argv,
int argc, void *data, void *user_data)
{
// printf("%s <- %d, %g\n", path, argv[0]->i, argv[1]->f);
// fflush(stdout);
set_slider(argv[0]->i, argv[1]->f);
return 0;
}
// wii_orientation_handler -- controls sliders 0 and 1 in range [0, 1]
// using wii orientation messages from OSC
static int wii_orientation_handler(const char *path, const char *types,
lo_arg **argv, int argc, void *data,
void *user_data)
{
set_slider(0, min(1.0F, max(0.0F, (argv[0]->f / 180.0F) + 0.5F)));
set_slider(1, min(1.0F, max(0.0F, (argv[1]->f / 180.0F) + 0.5F)));
return 0;
}
int nosc_init()
{
if (!SAFE_NYQUIST) {
the_server = lo_server_new("7770", error);
/* add method that will match the path /slider, with two numbers, coerced
* to int and float */
lo_server_add_method(the_server, "/slider", "if", slider_handler, NULL);
lo_server_add_method(the_server, "/wii/orientation", "ff",
wii_orientation_handler, NULL);
/* On Win64 this is technically incorrect because socket_type is 64 bits,
but *currently* the high-order WIN64 handle bits are zero and this
works. It is likely to continue working because changing it would cause
many failures. */
lo_fd = (int) lo_server_get_socket_fd(the_server);
nosc_enabled = true;
}
return 0;
}
int nosc_poll()
{
fd_set rfds;
struct timeval tv;
int retval;
if (SAFE_NYQUIST) return 0;
// loop, receiving all pending OSC messages
while (true) {
FD_ZERO(&rfds);
FD_SET(lo_fd, &rfds);
tv.tv_sec = 0;
tv.tv_usec = 0;
retval = select(lo_fd + 1, &rfds, NULL, NULL, &tv);
if (retval == -1) {
stdputstr("select() error in nosc_poll\n");
return -1;
} else if (retval > 0 && FD_ISSET(lo_fd, &rfds)) {
/* printf("lo_server_recv_noblock 1\n"); */
lo_server_recv_noblock(the_server, 0);
} else {
return 0;
}
}
return 0;
}
void nosc_finish()
{
if (!SAFE_NYQUIST) {
lo_server_free(the_server);
nosc_enabled = false;
}
}
#endif
|
the_stack_data/710638.c | //#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
//#include <time.h>
int main (int argc, char* argv[]) {
void* initial = sbrk(0);
printf("The initial top of the heap is %p\n",initial);
void* current = sbrk(0);
printf("The current top of the heap is %p\n",current);
printf("Increased by %ld (%#lx) bytes\n", current - initial, current - initial);
return 0;
}
|
the_stack_data/150143513.c | /*
* Generated with test/generate_buildtest.pl, to check that such a simple
* program builds.
*/
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_STDIO
# include <stdio.h>
#endif
#ifndef OPENSSL_NO_RSA
# include <openssl/rsa.h>
#endif
int main(void)
{
return 0;
}
|
the_stack_data/212643514.c | #ifdef _OPENMP
/* compress 1d contiguous array in parallel */
static void
_t2(compress_omp, Scalar, 1)(zfp_stream* stream, const zfp_field* field)
{
/* array metadata */
const Scalar* data = (const Scalar*)field->data;
uint nx = field->nx;
/* number of omp threads, blocks, and chunks */
uint threads = thread_count_omp(stream);
uint blocks = (nx + 3) / 4;
uint chunks = chunk_count_omp(stream, blocks, threads);
/* allocate per-thread streams */
bitstream** bs = compress_init_par(stream, field, chunks, blocks);
if (!bs)
return;
/* compress chunks of blocks in parallel */
int chunk;
#pragma omp parallel for num_threads(threads)
for (chunk = 0; chunk < (int)chunks; chunk++) {
/* determine range of block indices assigned to this thread */
uint bmin = chunk_offset(blocks, chunks, chunk + 0);
uint bmax = chunk_offset(blocks, chunks, chunk + 1);
uint block;
/* set up thread-local bit stream */
zfp_stream s = *stream;
zfp_stream_set_bit_stream(&s, bs[chunk]);
/* compress sequence of blocks */
for (block = bmin; block < bmax; block++) {
/* determine block origin x within array */
const Scalar* p = data;
uint x = 4 * block;
p += x;
/* compress partial or full block */
if (nx - x < 4)
_t2(zfpns.zfp_encode_partial_block_strided, Scalar, 1)(&s, p, MIN(nx - x, 4u), 1);
else
_t2(zfpns.zfp_encode_block, Scalar, 1)(&s, p);
}
}
/* concatenate per-thread streams */
compress_finish_par(stream, bs, chunks);
}
/* compress 1d strided array in parallel */
static void
_t2(compress_strided_omp, Scalar, 1)(zfp_stream* stream, const zfp_field* field)
{
/* array metadata */
const Scalar* data = (const Scalar*)field->data;
uint nx = field->nx;
int sx = field->sx ? field->sx : 1;
/* number of omp threads, blocks, and chunks */
uint threads = thread_count_omp(stream);
uint blocks = (nx + 3) / 4;
uint chunks = chunk_count_omp(stream, blocks, threads);
/* allocate per-thread streams */
bitstream** bs = compress_init_par(stream, field, chunks, blocks);
if (!bs)
return;
/* compress chunks of blocks in parallel */
int chunk;
#pragma omp parallel for num_threads(threads)
for (chunk = 0; chunk < (int)chunks; chunk++) {
/* determine range of block indices assigned to this thread */
uint bmin = chunk_offset(blocks, chunks, chunk + 0);
uint bmax = chunk_offset(blocks, chunks, chunk + 1);
uint block;
/* set up thread-local bit stream */
zfp_stream s = *stream;
zfp_stream_set_bit_stream(&s, bs[chunk]);
/* compress sequence of blocks */
for (block = bmin; block < bmax; block++) {
/* determine block origin x within array */
const Scalar* p = data;
uint x = 4 * block;
p += sx * (ptrdiff_t)x;
/* compress partial or full block */
if (nx - x < 4)
_t2(zfpns.zfp_encode_partial_block_strided, Scalar, 1)(&s, p, MIN(nx - x, 4u), sx);
else
_t2(zfpns.zfp_encode_block_strided, Scalar, 1)(&s, p, sx);
}
}
/* concatenate per-thread streams */
compress_finish_par(stream, bs, chunks);
}
/* compress 2d strided array in parallel */
static void
_t2(compress_strided_omp, Scalar, 2)(zfp_stream* stream, const zfp_field* field)
{
/* array metadata */
const Scalar* data = (const Scalar*)field->data;
uint nx = field->nx;
uint ny = field->ny;
int sx = field->sx ? field->sx : 1;
int sy = field->sy ? field->sy : (int)nx;
/* number of omp threads, blocks, and chunks */
uint threads = thread_count_omp(stream);
uint bx = (nx + 3) / 4;
uint by = (ny + 3) / 4;
uint blocks = bx * by;
uint chunks = chunk_count_omp(stream, blocks, threads);
/* allocate per-thread streams */
bitstream** bs = compress_init_par(stream, field, chunks, blocks);
if (!bs)
return;
/* compress chunks of blocks in parallel */
int chunk;
#pragma omp parallel for num_threads(threads)
for (chunk = 0; chunk < (int)chunks; chunk++) {
/* determine range of block indices assigned to this thread */
uint bmin = chunk_offset(blocks, chunks, chunk + 0);
uint bmax = chunk_offset(blocks, chunks, chunk + 1);
uint block;
/* set up thread-local bit stream */
zfp_stream s = *stream;
zfp_stream_set_bit_stream(&s, bs[chunk]);
/* compress sequence of blocks */
for (block = bmin; block < bmax; block++) {
/* determine block origin (x, y) within array */
const Scalar* p = data;
uint b = block;
uint x, y;
x = 4 * (b % bx); b /= bx;
y = 4 * b;
p += sx * (ptrdiff_t)x + sy * (ptrdiff_t)y;
/* compress partial or full block */
if (nx - x < 4 || ny - y < 4)
_t2(zfpns.zfp_encode_partial_block_strided, Scalar, 2)(&s, p, MIN(nx - x, 4u), MIN(ny - y, 4u), sx, sy);
else
_t2(zfpns.zfp_encode_block_strided, Scalar, 2)(&s, p, sx, sy);
}
}
/* concatenate per-thread streams */
compress_finish_par(stream, bs, chunks);
}
/* compress 3d strided array in parallel */
static void
_t2(compress_strided_omp, Scalar, 3)(zfp_stream* stream, const zfp_field* field)
{
/* array metadata */
const Scalar* data = (const Scalar*)field->data;
uint nx = field->nx;
uint ny = field->ny;
uint nz = field->nz;
int sx = field->sx ? field->sx : 1;
int sy = field->sy ? field->sy : (int)nx;
int sz = field->sz ? field->sz : (int)(nx * ny);
/* number of omp threads, blocks, and chunks */
uint threads = thread_count_omp(stream);
uint bx = (nx + 3) / 4;
uint by = (ny + 3) / 4;
uint bz = (nz + 3) / 4;
uint blocks = bx * by * bz;
uint chunks = chunk_count_omp(stream, blocks, threads);
/* allocate per-thread streams */
bitstream** bs = compress_init_par(stream, field, chunks, blocks);
if (!bs)
return;
/* compress chunks of blocks in parallel */
int chunk;
#pragma omp parallel for num_threads(threads)
for (chunk = 0; chunk < (int)chunks; chunk++) {
/* determine range of block indices assigned to this thread */
uint bmin = chunk_offset(blocks, chunks, chunk + 0);
uint bmax = chunk_offset(blocks, chunks, chunk + 1);
uint block;
/* set up thread-local bit stream */
zfp_stream s = *stream;
zfp_stream_set_bit_stream(&s, bs[chunk]);
/* compress sequence of blocks */
for (block = bmin; block < bmax; block++) {
/* determine block origin (x, y, z) within array */
const Scalar* p = data;
uint b = block;
uint x, y, z;
x = 4 * (b % bx); b /= bx;
y = 4 * (b % by); b /= by;
z = 4 * b;
p += sx * (ptrdiff_t)x + sy * (ptrdiff_t)y + sz * (ptrdiff_t)z;
/* compress partial or full block */
if (nx - x < 4 || ny - y < 4 || nz - z < 4)
_t2(zfpns.zfp_encode_partial_block_strided, Scalar, 3)(&s, p, MIN(nx - x, 4u), MIN(ny - y, 4u), MIN(nz - z, 4u), sx, sy, sz);
else
_t2(zfpns.zfp_encode_block_strided, Scalar, 3)(&s, p, sx, sy, sz);
}
}
/* concatenate per-thread streams */
compress_finish_par(stream, bs, chunks);
}
/* compress 4d strided array in parallel */
static void
_t2(compress_strided_omp, Scalar, 4)(zfp_stream* stream, const zfp_field* field)
{
/* array metadata */
const Scalar* data = field->data;
uint nx = field->nx;
uint ny = field->ny;
uint nz = field->nz;
uint nw = field->nw;
int sx = field->sx ? field->sx : 1;
int sy = field->sy ? field->sy : (int)nx;
int sz = field->sz ? field->sz : (int)(nx * ny);
int sw = field->sw ? field->sw : (int)(nx * ny * nz);
/* number of omp threads, blocks, and chunks */
uint threads = thread_count_omp(stream);
uint bx = (nx + 3) / 4;
uint by = (ny + 3) / 4;
uint bz = (nz + 3) / 4;
uint bw = (nw + 3) / 4;
uint blocks = bx * by * bz * bw;
uint chunks = chunk_count_omp(stream, blocks, threads);
/* allocate per-thread streams */
bitstream** bs = compress_init_par(stream, field, chunks, blocks);
if (!bs)
return;
/* compress chunks of blocks in parallel */
int chunk;
#pragma omp parallel for num_threads(threads)
for (chunk = 0; chunk < (int)chunks; chunk++) {
/* determine range of block indices assigned to this thread */
uint bmin = chunk_offset(blocks, chunks, chunk + 0);
uint bmax = chunk_offset(blocks, chunks, chunk + 1);
uint block;
/* set up thread-local bit stream */
zfp_stream s = *stream;
zfp_stream_set_bit_stream(&s, bs[chunk]);
/* compress sequence of blocks */
for (block = bmin; block < bmax; block++) {
/* determine block origin (x, y, z, w) within array */
const Scalar* p = data;
uint b = block;
uint x, y, z, w;
x = 4 * (b % bx); b /= bx;
y = 4 * (b % by); b /= by;
z = 4 * (b % bz); b /= bz;
w = 4 * b;
p += sx * (ptrdiff_t)x + sy * (ptrdiff_t)y + sz * (ptrdiff_t)z + sw * (ptrdiff_t)w;
/* compress partial or full block */
if (nx - x < 4 || ny - y < 4 || nz - z < 4 || nw - w < 4)
_t2(zfpns.zfp_encode_partial_block_strided, Scalar, 4)(&s, p, MIN(nx - x, 4u), MIN(ny - y, 4u), MIN(nz - z, 4u), MIN(nw - w, 4u), sx, sy, sz, sw);
else
_t2(zfpns.zfp_encode_block_strided, Scalar, 4)(&s, p, sx, sy, sz, sw);
}
}
/* concatenate per-thread streams */
compress_finish_par(stream, bs, chunks);
}
#endif
|
the_stack_data/391114.c | //
// Created by matti on 5.9.2015.
// Exercise 1-5
//
#include <stdio.h>
main () {
int fahr = 0;
for (fahr = 300; fahr >= 0; fahr = fahr - 20) {
printf("%3d %6.1f\n", fahr, (5.0/9.0)*(fahr-32));
}
} |
the_stack_data/130588.c | // Program for linked implementation of complete binary tree
#include <stdio.h>
#include <stdlib.h>
// For Queue Size
#define SIZE 26
// A tree node
struct node
{
char data;
struct node *right,*left;
};
// A queue node
struct Queue
{
char front, rear;
int size;
struct node* *array;
};
// A utility function to create a new tree node
struct node* newNode(int data)
{
struct node* temp = (struct node*) malloc(sizeof( struct node ));
temp->data = data;
temp->left = temp->right = NULL;
return temp;
}
// A utility function to create a new Queue
struct Queue* createQueue(int size)
{
struct Queue* queue = (struct Queue*) malloc(sizeof( struct Queue ));
queue->front = queue->rear = -1;
queue->size = size;
queue->array = (struct node**) malloc
(queue->size * sizeof( struct node* ));
int i;
for (i = 0; i < size; ++i)
queue->array[i] = NULL;
return queue;
}
// Standard Queue Functions
int isEmpty(struct Queue* queue)
{
return queue->front == -1;
}
int isFull(struct Queue* queue)
{ return queue->rear == queue->size - 1; }
int hasOnlyOneItem(struct Queue* queue)
{ return queue->front == queue->rear; }
void Enqueue(struct node *root, struct Queue* queue)
{
if (isFull(queue))
return;
queue->array[++queue->rear] = root;
if (isEmpty(queue))
++queue->front;
}
struct node* Dequeue(struct Queue* queue)
{
if (isEmpty(queue))
return NULL;
struct node* temp = queue->array[queue->front];
if (hasOnlyOneItem(queue))
queue->front = queue->rear = -1;
else
++queue->front;
return temp;
}
struct node* getFront(struct Queue* queue)
{ return queue->array[queue->front]; }
// A utility function to check if a tree node
// has both left and right children
int hasBothChild(struct node* temp)
{
return temp && temp->left && temp->right;
}
// Function to insert a new node in complete binary tree
void insert(struct node **root, int data, struct Queue* queue)
{
// Create a new node for given data
struct node *temp = newNode(data);
// If the tree is empty, initialize the root with new node.
if (!*root)
*root = temp;
else
{
// get the front node of the queue.
struct node* front = getFront(queue);
// If the left child of this front node doesn’t exist, set the
// left child as the new node
if (!front->left)
front->left = temp;
// If the right child of this front node doesn’t exist, set the
// right child as the new node
else if (!front->right)
front->right = temp;
// If the front node has both the left child and right child,
// Dequeue() it.
if (hasBothChild(front))
Dequeue(queue);
}
// Enqueue() the new node for later insertions
Enqueue(temp, queue);
}
// Standard level order traversal to test above function
void levelOrder(struct node* root)
{
struct Queue* queue = createQueue(SIZE);
Enqueue(root, queue);
while (!isEmpty(queue))
{
struct node* temp = Dequeue(queue);
printf("%c ", temp->data);
if (temp->left)
Enqueue(temp->left, queue);
if (temp->right)
Enqueue(temp->right, queue);
}
}
void Preorder(struct node *root){
if(root){
printf("%c ",root->data);
Preorder(root->left);
Preorder(root->right);
}
}
void Inorder(struct node *root){
if(root){
Inorder(root->left);
printf("%c ", root->data);
Inorder(root->right);
}
}
void Postorder(struct node *root){
if(root){
Postorder(root->left);
Postorder(root->right);
printf("%c ", root->data);
}
}
// Driver program to test above functions
int main()
{
struct node* root = NULL;
struct Queue* queue = createQueue(SIZE);
int i;
for(i = 65; i <= 90; ++i)
insert(&root, i, queue);
printf("The Levelorder traversal of the given Binary tree is : \n");
levelOrder(root);
printf("\n");
printf("The Preorder traversal of the given Binary tree is : \n");
Preorder(root);
printf("\n");
printf("The Inorder traversal of the given Binary tree is : \n");
Inorder(root);
printf("\n");
printf("The Postorder traversal of the given Binary tree is : \n");
Postorder(root);
printf("\n");
return 0;
}
|
the_stack_data/38039.c | /* Tests that the may_alias attribute works as expected.
Author: Osku Salerma <[email protected]> Apr 2002. */
extern void abort(void);
extern void exit(int);
typedef short __attribute__((__may_alias__)) short_a;
int
main (void)
{
int a = 0x12345678;
short_a *b = (short_a*) &a;
b[1] = 0;
if (a == 0x12345678)
abort();
exit(0);
}
|
the_stack_data/23574433.c | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char *argv[]) {
int x,y,m,n,k;
scanf("%d %d",&n,&m);
x=1;
y=n-x;
k=-1;
while(k==-1){
if(2*x+4*y!=m){
x++;
y=n-x;
if(x>=n) k=0;
}else{
k=1;
}
}
if(k==1)
printf("%d %d",x,y);
if(k==0)
printf("No");
return 0;
}
|
the_stack_data/178266350.c | #include <stdio.h>
#include <math.h>
int main()
{
int arr[] = {8,10,13,45,23,4};
int n = sizeof(arr)/sizeof(arr[0]);
int i, key, j;
for (i = 1; i < n; i++)
{
key = arr[i];
j = i-1;
while (j >= 0 && arr[j] > key)
{
arr[j+1] = arr[j];
j = j-1;
}
arr[j+1] = key;
}
for (i=0; i < n; i++)
printf("%d ", arr[i]);
printf("\n");
return 0;
} |
the_stack_data/31387007.c | #include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<signal.h>
#include<stdlib.h>
int main()
{
void handler(int sig);
int pid=fork();
if(pid<0)
{
printf("Process creation failed. \n");
}
else if(pid>0)
{
printf("Parent process has started executing\n");
signal(SIGINT,handler);
while(1);
printf("Parent process is now completed\n");
}
else
{
printf("child process has started executing\n");
sleep(2);
kill(getppid(),SIGINT);
printf("Child process is now completed\n");
}
return 0;
}
void handler(int sig)
{
printf("Parent process has received the kill system call from the child function and has executed the signal handler function\n");
}
|
the_stack_data/184517370.c | #include <stdio.h>
int main() {
char *palavra[] = {"casa", "carro"};
for(int i = 0; i < sizeof(palavra) / sizeof(palavra[0]); i++) {
printf("%s", palavra[i]);
}
}
//http://pt.stackoverflow.com/q/178522/101
|
the_stack_data/248581582.c | // KMSAN: uninit-value in crc_t10dif_generic
// https://syzkaller.appspot.com/bug?id=3758e2229eb144cf5bd6d17b0386a9a8a47521d0
// status:invalid
// autogenerated by syzkaller (http://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <errno.h>
#include <errno.h>
#include <fcntl.h>
#include <linux/capability.h>
#include <sched.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/prctl.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
__attribute__((noreturn)) static void doexit(int status)
{
volatile unsigned i;
syscall(__NR_exit_group, status);
for (i = 0;; i++) {
}
}
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
const int kFailStatus = 67;
const int kRetryStatus = 69;
static void fail(const char* msg, ...)
{
int e = errno;
va_list args;
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
fprintf(stderr, " (errno %d)\n", e);
doexit((e == ENOMEM || e == EAGAIN) ? kRetryStatus : kFailStatus);
}
static void use_temporary_dir()
{
char tmpdir_template[] = "./syzkaller.XXXXXX";
char* tmpdir = mkdtemp(tmpdir_template);
if (!tmpdir)
fail("failed to mkdtemp");
if (chmod(tmpdir, 0777))
fail("failed to chmod");
if (chdir(tmpdir))
fail("failed to chdir");
}
static bool write_file(const char* file, const char* what, ...)
{
char buf[1024];
va_list args;
va_start(args, what);
vsnprintf(buf, sizeof(buf), what, args);
va_end(args);
buf[sizeof(buf) - 1] = 0;
int len = strlen(buf);
int fd = open(file, O_WRONLY | O_CLOEXEC);
if (fd == -1)
return false;
if (write(fd, buf, len) != len) {
int err = errno;
close(fd);
errno = err;
return false;
}
close(fd);
return true;
}
static void loop();
static void sandbox_common()
{
prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
setpgrp();
setsid();
struct rlimit rlim;
rlim.rlim_cur = rlim.rlim_max = 128 << 20;
setrlimit(RLIMIT_AS, &rlim);
rlim.rlim_cur = rlim.rlim_max = 8 << 20;
setrlimit(RLIMIT_MEMLOCK, &rlim);
rlim.rlim_cur = rlim.rlim_max = 32 << 20;
setrlimit(RLIMIT_FSIZE, &rlim);
rlim.rlim_cur = rlim.rlim_max = 1 << 20;
setrlimit(RLIMIT_STACK, &rlim);
rlim.rlim_cur = rlim.rlim_max = 0;
setrlimit(RLIMIT_CORE, &rlim);
if (unshare(CLONE_NEWNS)) {
}
if (unshare(CLONE_NEWIPC)) {
}
if (unshare(0x02000000)) {
}
if (unshare(CLONE_NEWUTS)) {
}
if (unshare(CLONE_SYSVSEM)) {
}
}
static int real_uid;
static int real_gid;
__attribute__((aligned(64 << 10))) static char sandbox_stack[1 << 20];
static int namespace_sandbox_proc(void* arg)
{
sandbox_common();
write_file("/proc/self/setgroups", "deny");
if (!write_file("/proc/self/uid_map", "0 %d 1\n", real_uid))
fail("write of /proc/self/uid_map failed");
if (!write_file("/proc/self/gid_map", "0 %d 1\n", real_gid))
fail("write of /proc/self/gid_map failed");
if (unshare(CLONE_NEWNET))
fail("unshare(CLONE_NEWNET)");
if (mkdir("./syz-tmp", 0777))
fail("mkdir(syz-tmp) failed");
if (mount("", "./syz-tmp", "tmpfs", 0, NULL))
fail("mount(tmpfs) failed");
if (mkdir("./syz-tmp/newroot", 0777))
fail("mkdir failed");
if (mkdir("./syz-tmp/newroot/dev", 0700))
fail("mkdir failed");
unsigned mount_flags = MS_BIND | MS_REC | MS_PRIVATE;
if (mount("/dev", "./syz-tmp/newroot/dev", NULL, mount_flags, NULL))
fail("mount(dev) failed");
if (mkdir("./syz-tmp/newroot/proc", 0700))
fail("mkdir failed");
if (mount(NULL, "./syz-tmp/newroot/proc", "proc", 0, NULL))
fail("mount(proc) failed");
if (mkdir("./syz-tmp/newroot/selinux", 0700))
fail("mkdir failed");
const char* selinux_path = "./syz-tmp/newroot/selinux";
if (mount("/selinux", selinux_path, NULL, mount_flags, NULL)) {
if (errno != ENOENT)
fail("mount(/selinux) failed");
if (mount("/sys/fs/selinux", selinux_path, NULL, mount_flags, NULL) &&
errno != ENOENT)
fail("mount(/sys/fs/selinux) failed");
}
if (mkdir("./syz-tmp/newroot/sys", 0700))
fail("mkdir failed");
if (mount(NULL, "./syz-tmp/newroot/sys", "sysfs", 0, NULL))
fail("mount(sysfs) failed");
if (mkdir("./syz-tmp/pivot", 0777))
fail("mkdir failed");
if (syscall(SYS_pivot_root, "./syz-tmp", "./syz-tmp/pivot")) {
if (chdir("./syz-tmp"))
fail("chdir failed");
} else {
if (chdir("/"))
fail("chdir failed");
if (umount2("./pivot", MNT_DETACH))
fail("umount failed");
}
if (chroot("./newroot"))
fail("chroot failed");
if (chdir("/"))
fail("chdir failed");
struct __user_cap_header_struct cap_hdr = {};
struct __user_cap_data_struct cap_data[2] = {};
cap_hdr.version = _LINUX_CAPABILITY_VERSION_3;
cap_hdr.pid = getpid();
if (syscall(SYS_capget, &cap_hdr, &cap_data))
fail("capget failed");
cap_data[0].effective &= ~(1 << CAP_SYS_PTRACE);
cap_data[0].permitted &= ~(1 << CAP_SYS_PTRACE);
cap_data[0].inheritable &= ~(1 << CAP_SYS_PTRACE);
if (syscall(SYS_capset, &cap_hdr, &cap_data))
fail("capset failed");
loop();
doexit(1);
}
static int do_sandbox_namespace(void)
{
int pid;
real_uid = getuid();
real_gid = getgid();
mprotect(sandbox_stack, 4096, PROT_NONE);
pid =
clone(namespace_sandbox_proc, &sandbox_stack[sizeof(sandbox_stack) - 64],
CLONE_NEWUSER | CLONE_NEWPID, 0);
if (pid < 0)
fail("sandbox clone failed");
return pid;
}
uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff};
void loop()
{
long res = 0;
res = syscall(__NR_socket, 0x26, 5, 0);
if (res != -1)
r[0] = res;
*(uint16_t*)0x2062ffa8 = 0x26;
memcpy((void*)0x2062ffaa,
"\x68\x61\x73\x68\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 14);
*(uint32_t*)0x2062ffb8 = 0;
*(uint32_t*)0x2062ffbc = 0;
memcpy((void*)0x2062ffc0,
"\x63\x72\x63\x74\x31\x30\x64\x69\x66\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
64);
syscall(__NR_bind, r[0], 0x2062ffa8, 0x58);
res = syscall(__NR_accept, r[0], 0, 0);
if (res != -1)
r[1] = res;
memcpy((void*)0x204b8ff8, "./file0", 8);
res = syscall(__NR_open, 0x204b8ff8, 0x28042, 0);
if (res != -1)
r[2] = res;
syscall(__NR_fallocate, r[2], 0, 0, 9);
*(uint64_t*)0x20e64ff8 = 0;
syscall(__NR_sendfile, r[1], r[2], 0x20e64ff8, 8);
}
int main()
{
syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0);
use_temporary_dir();
int pid = do_sandbox_namespace();
int status = 0;
while (waitpid(pid, &status, __WALL) != pid) {
}
return 0;
}
|
the_stack_data/787870.c | /*
/ _____) _ | |
( (____ _____ ____ _| |_ _____ ____| |__
\____ \| ___ | (_ _) ___ |/ ___) _ \
_____) ) ____| | | || |_| ____( (___| | | |
(______/|_____)_|_|_| \__)_____)\____)_| |_|
(C)2013 Semtech-Cycleo
Description:
LoRa concentrator HAL auxiliary functions
License: Revised BSD License, see LICENSE.TXT file include in the project
Maintainer: Sylvain Miermont
*/
/* -------------------------------------------------------------------------- */
/* --- DEPENDANCIES --------------------------------------------------------- */
/* fix an issue between POSIX and C99 */
#if __STDC_VERSION__ >= 199901L
#define _XOPEN_SOURCE 600
#else
#define _XOPEN_SOURCE 500
#endif
#include <stdio.h> /* printf fprintf */
#include <time.h> /* clock_nanosleep */
/* -------------------------------------------------------------------------- */
/* --- PRIVATE MACROS ------------------------------------------------------- */
#if DEBUG_AUX == 1
#define DEBUG_MSG(str) fprintf(stderr, str)
#define DEBUG_PRINTF(fmt, args...) fprintf(stderr,"%s:%d: "fmt, __FUNCTION__, __LINE__, args)
#else
#define DEBUG_MSG(str)
#define DEBUG_PRINTF(fmt, args...)
#endif
/* -------------------------------------------------------------------------- */
/* --- PUBLIC FUNCTIONS DEFINITION ------------------------------------------ */
/* This implementation is POSIX-pecific and require a fix to be compatible with C99 */
#ifdef __MACH__
#include <unistd.h>
void wait_ms(unsigned long a) {
usleep(1000*a);
}
#else
void wait_ms(unsigned long a) {
struct timespec dly;
struct timespec rem;
dly.tv_sec = a / 1000;
dly.tv_nsec = ((long)a % 1000) * 1000000;
DEBUG_PRINTF("NOTE dly: %ld sec %ld ns\n", dly.tv_sec, dly.tv_nsec);
if((dly.tv_sec > 0) || ((dly.tv_sec == 0) && (dly.tv_nsec > 100000))) {
clock_nanosleep(CLOCK_MONOTONIC, 0, &dly, &rem);
DEBUG_PRINTF("NOTE remain: %ld sec %ld ns\n", rem.tv_sec, rem.tv_nsec);
}
return;
}
#endif
/* --- EOF ------------------------------------------------------------------ */
|
the_stack_data/88937.c | #include<stdio.h>
int main()
{
int *a,*b;
int x=10,y=20;
swap (*a,*b);
}
void swap(int *a,int *b)
{
int temp;
temp=*a;
*a=*b;
*b=temp;
printf("%d %d",*a,*b);
}
|
the_stack_data/108382.c | #include <stdio.h>
#include <stdlib.h>
int main(){
int vet[10],vet2[10];
int i,n;
for(i=0;i<10;i++){
printf("Vet[%d]:",i);
scanf("%d",&vet[i]);
}
for(i=0;i<10;i++){
printf("%d ",vet[i]);
}
printf("\n");
for(n=9;n>=0;n--){
i=0;
vet2[i]=vet[n];
printf("%d ",vet2[i]);
i++;
}
}
|
the_stack_data/111078878.c | // WAP to create a double circular double linked list of n nodes and display the
// linked list by using suitable user defined functions for create and display operations.
#include<stdio.h>
#include<stdlib.h>
struct node{
int data;
struct node *next,*prev;
};
void insert(struct node **start,int value){
if (*start == NULL)
{
struct node* new_node = (struct node *)malloc(sizeof(struct node));
new_node->data = value;
new_node->next = new_node->prev = new_node;
*start = new_node;
return;
}
struct node *last = (*start)->prev;
struct node *new_node = (struct node *)malloc(sizeof(struct node));
new_node->data = value;
new_node->next = *start;
(*start)->prev = new_node;
new_node->prev = last;
last->next = new_node;
}
void display(struct node *start){
struct node *temp = start;
printf("\nCircular DLL -> \n");
while (temp->next != start){
if(temp==start)printf("/");
else if(temp->next->next == start)printf("\\");
else printf("---------->");
temp = temp->next;
}
printf("\n");
temp = temp->next;
while (temp->next != start)
{
printf("%d <-> ", temp->data);
temp = temp->next;
}
printf("%d \n", temp->data);
temp = temp->next;
while (temp->next != start){
if(temp==start)printf("\\");
else if(temp->next->next == start)printf("/");
else printf("<----------");
temp = temp->next;
}
printf("\n\n");
}
int main(){
struct node *start=NULL;
insert(&start,1);
insert(&start,2);
insert(&start,3);
insert(&start,4);
insert(&start,5);
display(start);
return 0;
}
|
the_stack_data/61075971.c | /* Copyright (C) 1994, 1997, 2000, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Joel Sherrill ([email protected]),
On-Line Applications Research Corporation.
The GNU C 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.
The GNU C 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 the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int
main (void)
{
int failures = 0;
int i;
auto void try (const char *name, long long int param, int value,
int expected);
void try (const char *name, long long int param, int value, int expected)
{
if (value != expected)
{
printf ("%s(%#llx) expected %d got %d\n",
name, param, expected, value);
++failures;
}
else
printf ("%s(%#llx) as expected %d\n", name, param, value);
}
#define TEST(fct, type) \
try (#fct, 0, fct ((type) 0), 0); \
for (i=0 ; i < 8 * sizeof (type); i++) \
try (#fct, 1ll << i, fct (((type) 1) << i), i + 1); \
for (i=0 ; i < 8 * sizeof (type) ; i++) \
try (#fct, (~((type) 0) >> i) << i, fct ((~((type) 0) >> i) << i), i + 1);\
try (#fct, 0x80008000, fct ((type) 0x80008000), 16)
TEST (ffs, int);
/* Not implemented in uClibc (yet?)
TEST (ffsl, long int);
TEST (ffsll, long long int);
*/
if (failures)
printf ("Test FAILED! %d failure%s.\n", failures, &"s"[failures == 1]);
else
puts ("Test succeeded.");
return failures;
}
|
the_stack_data/27175.c | #define thisprog "xe-progdep"
#define TITLE_STRING thisprog" v 5: 26.January.2018 [JRH]"
#define MAXLINELEN 1000
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
<TAGS>programming</TAGS>
v 5: 26.January.2018 [JRH]
- tweak to linecomment function
v 5: 21.May.2016 [JRH]
- switch to new long-int version of strstr1
v 5: 11.July.2013 [JRH]
- bugfix: complete reworking of comment/quote removal, now moved to function xf_linecomment1
- previously, the presence of "#" or "//" automatically terminated the rest of the line
- quotes within quotes used to be counted
- quotes within comments were previously counted
- bugfix: xs- xe- or xf_ now do not have to be the first character in a word for it to be recognized as a dependency
- this means defining a variable as a program name, provided it is not enclosed in quotes, will now make it appear as a dependency
v 4: 18.June.2013 [JRH]
- bugfix - should now ignore quoted text (single or double quotes)
v 3: 7.June.2013 [JRH]
- script basenames can now include "."
v 1.2: 9.March.2013 [JRH]
- update to use xf_strstr1 - a more general function that allows detection of the first or last of a series of characters in a string
- the old function was xf_strstr
*/
/* external functions start */
int xf_linecomment1(char *line, int *skip1);
long xf_strstr1(char *haystack,char *needle,int setcase,int firstlast);
/* external functions end */
int main (int argc, char *argv[]) {
/* general variables */
char infile[256],line[MAXLINELEN],*pline,*pcol;
long i,j,k,n,zz;
int v,w,x,y,col;
int sizeofchar=sizeof(char),sizeofint=sizeof(int);
FILE *fpin;
/* program-specific variables */
char *words=NULL, path[256],basename[256],tempword[256],prev;
int *iword=NULL, lenwords=0,nwords=0, basetype=0,skip=0,q1=0,q2=0,q3=0,q4=0;
/* arguments */
/* PRINT INSTRUCTIONS IF THERE IS NO FILENAME SPECIFIED */
if(argc<2) {
fprintf(stderr,"\n");
fprintf(stderr,"----------------------------------------------------------------------\n");
fprintf(stderr,"%s\n",TITLE_STRING);
fprintf(stderr,"----------------------------------------------------------------------\n");
fprintf(stderr,"Check dependencies in a script or program\n");
fprintf(stderr,"Looks for any mention of a word containing xs-, xe-, or xf_ \n");
fprintf(stderr," - allows definition of dependency (e.g. prog=[progname) to be \n");
fprintf(stderr," detected, PROVIDED quotes are not used\n");
fprintf(stderr," - any other reference to a script/prog/function may be falsely \n");
fprintf(stderr," detected, if NOT enclosed in quotes\n");
fprintf(stderr,"Ignores additional references to the same script/program/function\n");
fprintf(stderr,"Ignores comments:\n");
fprintf(stderr," - all text between /* and */ \n");
fprintf(stderr," - everything after the first # or // on a given line\n");
fprintf(stderr,"Ignores quoted text (between single or double-quotes)\n");
fprintf(stderr,"Word delimiters: |(){}; \"\'\\t\\n\n");
fprintf(stderr,"USAGE:\n");
fprintf(stderr," %s [file-name]\n",thisprog);
fprintf(stderr,"EXAMPLES:\n");
fprintf(stderr," %s xs-myscript\n",thisprog);
fprintf(stderr,"----------------------------------------------------------------------\n");
fprintf(stderr,"\n");
exit(0);
}
/* READ THE FILENAME AND OPTIONAL ARGUMENTS */
sprintf(infile,"%s",argv[1]);
/* OPEN THE INPUT FILE USING FULL SPECIFIED PATH */
if((fpin=fopen(infile,"r"))==0) {fprintf(stderr,"\n--- Error [%s]: file \"%s\" not found\n\n",thisprog,infile);exit(1);}
n=0;
/* REMOVE PATH DESIGNATION (IF PRESENT) FROM INPUT FILE NAME - IT'S NOT NEEDED AT THIS POINT */
pcol=strrchr(infile,'/');
if(pcol!=NULL) sprintf(basename,"%s",++pcol);
else sprintf(basename,"%s",infile);
/* DETERMINE INFILE TYPE - STRIP EVERYTHING AFTER THE FIRST "." FOR xe- and xf_ FILES */
basetype=0;
if(xf_strstr1(basename,"xs-",1,1)>=0) basetype=1;
else {
if(xf_strstr1(basename,"xe-",1,1)>=0) basetype=2;
if(xf_strstr1(basename,"xf_",1,1)>=0) basetype=3;
zz=xf_strstr1(basename,".",1,1);
if(zz>=0) basename[zz]='\0';
}
/* READ THE FILE LINE-BY LINE LOOKING FOR WORDS SATRING WITH xs- xe- or xf_ */
skip=0;
while(fgets(line,MAXLINELEN,fpin)!=NULL) {
/* negate commented or quoted text */
xf_linecomment1(line,&skip);
/* search for xs- xe- or xf_, indicators of script program or function dependencies */
pline=line;
for(col=1;(pcol=strtok(pline,"|(){}; \t\n"))!=NULL;col++) {
pline=NULL;
zz=-1; /* flag indicating a script, program or function name has been found */
if((zz=xf_strstr1(pcol,"xs-",1,1))>=0) {
pcol+=zz;
if(strcmp(pcol,basename)==0) continue; /* this is a recursive call - do not report */
}
else if((zz=xf_strstr1(pcol,"xe-",1,1))>=0) {
pcol+=zz;
if(strcmp(pcol,basename)==0) continue; /* this is a recursive call - do not report */
if(basetype==2) {fprintf(stderr,"\n--- Warning [%s]: program %s appears to call another program %s\n\n",thisprog,infile,pcol);continue;}
if(basetype==3) {fprintf(stderr,"\n--- Warning [%s]: function %s appears to call a program %s\n\n",thisprog,infile,pcol); continue;}
}
else if((zz=xf_strstr1(pcol,"xf_",1,1))>=0) {
pcol+=zz;
if(strcmp(pcol,basename)==0) continue; /* this is a recursive call - do not report */
if(basetype==1) {fprintf(stderr,"\n--- Warning [%s]: script %s appears to call a function %s\n\n",thisprog,infile,pcol); continue;}
}
else continue; /* indicates no xs- xe- or xf- were found */
/* check to see if label already exists - if so, ignore it */
zz=0; for(j=0;j<nwords;j++) if(strcmp(pcol,(words+iword[j]))==0) zz=1; if(zz==1) continue;
/* allocate memory for expanded words and word-index */
x=strlen(pcol); // not including terminating NULL
words=(char *)realloc(words,((lenwords+x+4)*sizeofchar)); if(words==NULL) {fprintf(stderr,"\n--- Error [%s]: insufficient memory\n\n",thisprog);exit(1);};
iword=(int *)realloc(iword,(nwords+1)*sizeofint); if(words==NULL) {fprintf(stderr,"\n--- Error [%s]: insufficient memory\n\n",thisprog);exit(1);};
/* set pointer to start position (currently, the end of the labels string) */
iword[nwords]=lenwords;
/* add new word to end of words, adding terminal NULL */
sprintf(words+lenwords,"%s",pcol);
/* update length, allowing for terminal NULL - serves as pointer to start of next word */
lenwords+=(x+1);
/* incriment nwords with check */
nwords++;
}
}
fclose(fpin);
for(i=0;i<nwords;i++) printf("%s\n",(words+iword[i]));
free(words);
free(iword);
exit(0);
}
|
the_stack_data/500822.c | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct entrada{
char *palavra;
int ocorr;
struct entrada *prox;
} *Palavras, pal;
typedef Palavras Dicionario;
void initDic (Dicionario *d) {
(*d) = NULL;
}
int acrescenta (Dicionario *d, char *pal) {
Dicionario pt;
Palavras new = malloc(sizeof(pal));
new->ocorr = 1;
new->palavra = pal;
new->prox = NULL;
if(!(*d)) *d = new;
else {
for(pt = (*d); pt; pt = pt->prox) {
if(strcmp(pt->palavra, pal) == 0) {
pt->ocorr++;
return pt->ocorr;
}
}
if(!pt) {
pt->prox = new;
}
}
return 1;
}
char * maisFreq (Dicionario d, int *c) {
Dicionario pt;
int max = 0;
*c = 0;
char *palfreq;
for(pt = d; pt; pt = pt->prox) {
if(pt->ocorr > *c) {
max = *c = pt->ocorr;
palfreq = pt->palavra;
}
}
return palfreq;
}
int main(int argc, char *argv[]) {
FILE *input;
int r = 0, count = 0;
char word[100];
Dicionario d = malloc(sizeof(struct entrada));
d = NULL;
if (argc == 1) input = stdin;
else input = fopen(argv[1], "r");
if (input == NULL) r = 1;
else {
while((fscanf(input, "%s", word) == 1)) {
acrescenta(&d,word);
count++;
}
fclose(input);
printf("%d palavras\n", count);
}
int* c = malloc(sizeof(*c));
printf("Palavra mais comum: %s - ",maisFreq(d,c));
printf("aparece %d vez(es)",*c);
return r;
}
|
the_stack_data/67325431.c | /* @(#)strncpy.c 1.3 */
/* 3.0 SID # 1.2 */
/*LINTLIBRARY*/
/*
* Copy s2 to s1, truncating or null-padding to always copy n bytes
* return s1
*/
char *
strncpy(s1, s2, n)
register char *s1, *s2;
register int n;
{
register char *os1 = s1;
while (--n >= 0)
if ((*s1++ = *s2++) == '\0')
while (--n >= 0)
*s1++ = '\0';
return (os1);
}
|
the_stack_data/117328538.c | /* Copyright (c) 2017, Piotr Durlej
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#include <limits.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <pwd.h>
#include <err.h>
#define SHELLS "/etc/shells"
static void chk_shell(const char *sh)
{
static char buf[PATH_MAX];
char *p;
FILE *f;
f = fopen(SHELLS, "r");
while (fgets(buf, sizeof buf, f))
{
p = strchr(buf, '\n');
if (p != NULL)
*p = 0;
if (!strcmp(sh, buf))
{
fclose(f);
return;
}
}
errx(127, "%s: Not in " SHELLS, sh);
}
int main(int argc, char **argv)
{
static char buf[PATH_MAX];
const char *newsh = NULL;
const char *user = NULL;
struct passwd *pw;
uid_t ruid;
char *p;
int c;
if (argc == 2 && !strcmp(argv[1], "--help"))
{
printf("\nUsage: %s [-s SHELL] [user]\n\n"
"Change user's shell.\n\n"
" -s change the user's shell to SHELL\n\n",
argv[0]);
return 0;
}
ruid = getuid();
while (c = getopt(argc, argv, "s:"), c > 0)
switch (c)
{
case 's':
newsh = optarg;
break;
default:
return 127;
}
if (optind < argc)
{
if (ruid)
errx(127, "You are not root");
user = argv[optind];
}
else
{
pw = getpwuid(ruid);
if (pw == NULL)
errx(127, "No account");
user = strdup(pw->pw_name);
if (user == NULL)
err(errno, "strdup");
}
if (newsh == NULL)
{
printf("New shell for %s: ", user);
if (fgets(buf, sizeof buf, stdin) == NULL)
{
if (ferror(stdin))
err(errno, "stdin");
return 0;
}
p = strchr(buf, '\n');
if (p != NULL)
*p = 0;
newsh = buf;
}
if (ruid)
chk_shell(newsh);
if (_setshell(user, newsh))
err(errno, "_setshell");
if (access(newsh, X_OK))
warn("warning: %s", newsh);
return 0;
}
|
the_stack_data/162493.c | typedef struct {int champ1; int champ2;} mystruct;
void decl04(mystruct s)
{
mystruct s_loc = s;
s_loc.champ1 = s_loc.champ1 -1;
}
int main()
{
mystruct s;
s.champ1 = 3;
s.champ2 = 4;
decl04(s);
return 0;
}
|
the_stack_data/444800.c | #include <stdio.h>
void pay_amount(int dollars, int *twenties, int *tens, int *fives, int *ones);
int main(void) {
int money = 0, twenties, tens, fives, ones;
printf("Enter a dollar amount: ");
scanf("%d", &money);
pay_amount(money, &twenties, &tens, &fives, &ones);
printf("$20 bills: %d\n", twenties);
printf("$10 bills: %d\n", tens);
printf(" $5 bills: %d\n", fives);
printf(" $1 bills: %d\n", ones);
return 0;
}
void pay_amount(int dollars, int *twenties, int *tens, int *fives, int *ones) {
*twenties = dollars / 20;
dollars -= *twenties * 20;
*tens = dollars / 10;
dollars -= *tens * 10;
*fives = dollars / 5;
dollars -= *fives * 5;
*ones = dollars;
}
// Enter a dollar amount: 66 |
the_stack_data/165769387.c | #include<stdio.h>
float calculateTotalCost(int itemNo, int quantity);
void printDetails(int itemNo, int quantity, float totalCost);
int main (void)
{
int itemNo , quantity;
float totalCost;
printf("Enter Item No : ");
scanf("%d" , &itemNo);
printf("Enter Quantity : ");
scanf("%d" , &quantity);
totalCost = calculateTotalCost(itemNo, quantity);
printDetails(itemNo , quantity, totalCost);
return 0;
}
float calculateTotalCost(int itemNo, int quantity)
{
float totalCost;
if (itemNo == 1)
{
totalCost = 100.00 * quantity;
}
else if (itemNo == 2)
{
totalCost = 200.00 * quantity;
}
else if (itemNo == 3)
{
totalCost = 300.00 * quantity;
}
return totalCost;
}
void printDetails(int itemNo, int quantity, float totalCost)
{
printf("Item No : %d\n" , itemNo);
printf("Quantity : %d\n" , quantity);
printf("Total Cost : Rs.%.2f\n" , totalCost);
}
|
the_stack_data/212641847.c | /*
Apply various randomness tests to a stream of bytes
by John Walker -- September 1996
http://www.fourmilab.ch/
*/
#include <math.h>
#define FALSE 0
#define TRUE 1
#define log2of10 3.32192809488736234787
static int binary = FALSE; /* Treat input as a bitstream */
static long ccount[256], /* Bins to count occurrences of values */
totalc = 0; /* Total bytes counted */
static double prob[256]; /* Probabilities per bin for entropy */
/* RT_LOG2 -- Calculate log to the base 2 */
static double rt_log2(double x)
{
return log2of10 * log10(x);
}
#define MONTEN 6 /* Bytes used as Monte Carlo
co-ordinates. This should be no more
bits than the mantissa of your
"double" floating point type. */
static int mp, sccfirst;
static unsigned int monte[MONTEN];
static long inmont, mcount;
static double cexp, incirc, montex, montey, montepi,
scc, sccun, sccu0, scclast, scct1, scct2, scct3,
ent, chisq, datasum;
/* RT_INIT -- Initialise random test counters. */
void rt_init(int binmode)
{
int i;
binary = binmode; /* Set binary / byte mode */
/* Initialise for calculations */
ent = 0.0; /* Clear entropy accumulator */
chisq = 0.0; /* Clear Chi-Square */
datasum = 0.0; /* Clear sum of bytes for arithmetic mean */
mp = 0; /* Reset Monte Carlo accumulator pointer */
mcount = 0; /* Clear Monte Carlo tries */
inmont = 0; /* Clear Monte Carlo inside count */
incirc = 65535.0 * 65535.0;/* In-circle distance for Monte Carlo */
sccfirst = TRUE; /* Mark first time for serial correlation */
scct1 = scct2 = scct3 = 0.0; /* Clear serial correlation terms */
incirc = pow(pow(256.0, (double) (MONTEN / 2)) - 1, 2.0);
for (i = 0; i < 256; i++) {
ccount[i] = 0;
}
totalc = 0;
}
/* RT_ADD -- Add one or more bytes to accumulation. */
void rt_add(void *buf, int bufl)
{
unsigned char *bp = buf;
int oc, c, bean;
while (bean = 0, (bufl-- > 0)) {
oc = *bp++;
do {
if (binary) {
c = !!(oc & 0x80);
} else {
c = oc;
}
ccount[c]++; /* Update counter for this bin */
totalc++;
/* Update inside / outside circle counts for Monte Carlo
computation of PI */
if (bean == 0) {
monte[mp++] = oc; /* Save character for Monte Carlo */
if (mp >= MONTEN) { /* Calculate every MONTEN character */
int mj;
mp = 0;
mcount++;
montex = montey = 0;
for (mj = 0; mj < MONTEN / 2; mj++) {
montex = (montex * 256.0) + monte[mj];
montey = (montey * 256.0) + monte[(MONTEN / 2) + mj];
}
if ((montex * montex + montey * montey) <= incirc) {
inmont++;
}
}
}
/* Update calculation of serial correlation coefficient */
sccun = c;
if (sccfirst) {
sccfirst = FALSE;
scclast = 0;
sccu0 = sccun;
} else {
scct1 = scct1 + scclast * sccun;
}
scct2 = scct2 + sccun;
scct3 = scct3 + (sccun * sccun);
scclast = sccun;
oc <<= 1;
} while (binary && (++bean < 8));
}
}
/* RT_END -- Complete calculation and return results. */
void rt_end(double *r_ent, double *r_chisq, double *r_mean,
double *r_montepicalc, double *r_scc)
{
int i;
/* Complete calculation of serial correlation coefficient */
scct1 = scct1 + scclast * sccu0;
scct2 = scct2 * scct2;
scc = totalc * scct3 - scct2;
if (scc == 0.0) {
scc = -100000;
} else {
scc = (totalc * scct1 - scct2) / scc;
}
/* Scan bins and calculate probability for each bin and
Chi-Square distribution. The probability will be reused
in the entropy calculation below. While we're at it,
we sum of all the data which will be used to compute the
mean. */
cexp = totalc / (binary ? 2.0 : 256.0); /* Expected count per bin */
for (i = 0; i < (binary ? 2 : 256); i++) {
double a = ccount[i] - cexp;;
prob[i] = ((double) ccount[i]) / totalc;
chisq += (a * a) / cexp;
datasum += ((double) i) * ccount[i];
}
/* Calculate entropy */
for (i = 0; i < (binary ? 2 : 256); i++) {
if (prob[i] > 0.0) {
ent += prob[i] * rt_log2(1 / prob[i]);
}
}
/* Calculate Monte Carlo value for PI from percentage of hits
within the circle */
montepi = 4.0 * (((double) inmont) / mcount);
/* Return results through arguments */
*r_ent = ent;
*r_chisq = chisq;
*r_mean = datasum / totalc;
*r_montepicalc = montepi;
*r_scc = scc;
}
|
the_stack_data/552939.c | #include <stdlib.h>
#include <stdio.h>
#define MAXL 100
#define NDIA 3
#define NELE 5
#define BONUS 8.0f
typedef struct{
char nome[MAXL]; // Nome dell'elemento
int tipo; // Tipologia: 2 = avanti, 1 = indietro, 0 = di transizione
int dir_in; // Direzione di ingresso: 1 = frontale, 0 = di spalle
int dir_out; // Direzione di uscita: 1 = frontale, 0 = di spalle
int first; // 0 = puo essere il primo, 1 = deve essere preceduto da un altro
int last; // 1 = deve essere l'ultimo, 0 = puo non essere l'ultimo
float val; // Valore dell'elemento
int diff; // Difficolta dell'elemento
}Elemento;
typedef struct{
Elemento *data;
int len;
}elemArray;
typedef struct{
int dd[NDIA]; // Difficolta massima per diagonale
int dp; // Difficolta massima del programma
int acrxdiag[NDIA]; // Almeno un elemento acrobatico per diagonale
int fbacro[2]; // Almeno un elemento acrobatico frontale e di spalle nel programma
}Constr;
// Variabili globali
int glob_sol[NDIA][NELE]; // Soluzione ottimale.
int glob_tmp[NDIA][NELE]; // Soluzione currente.
float maxval = -1.0f; // Valore della soluzione ottimale.
float tmpval = 0.0f; // Valore della soluzione corrente.
float calcValSolTmp(elemArray);
void addElemento(elemArray, Constr, int, int);
void stampaSol(elemArray);
void generaProgramma(elemArray, int, int);
int main(int argc, char *argv[]){
elemArray elem;
int i, DD, DP;
FILE *fp = fopen("elementi.txt", "r");
if(fp == NULL) exit(EXIT_FAILURE);
fscanf(fp, "%d", &elem.len);
elem.data = (Elemento*) malloc(elem.len * sizeof(Elemento));
if(elem.data == NULL) exit(EXIT_FAILURE);
for(i = 0; i < elem.len; ++i){
fscanf(fp, "%s %d %d %d %d %d %f %d", elem.data[i].nome, &elem.data[i].tipo, &elem.data[i].dir_in, &elem.data[i].dir_out, &elem.data[i].first, &elem.data[i].last, &elem.data[i].val, &elem.data[i].diff);
// printf("%s %d %d %d %d %d %f %d\n", elem.data[i].nome, elem.data[i].tipo, elem.data[i].dir_in, elem.data[i].dir_out, elem.data[i].first, elem.data[i].last, elem.data[i].val, elem.data[i].diff);
}
fclose(fp);
printf("Difficolta massima diagonale: ");
scanf("%d", &DD);
printf("Difficolta massima totale: ");
scanf("%d", &DP);
generaProgramma(elem, DD, DP);
return 0;
}
float calcValSolTmp(elemArray arr){
float sum[NDIA] = {0};
int i, j, l = 0;
for(i = 0; i < NDIA; ++i){
for(j = 0; j < NELE; ++j){
if(glob_tmp[i][j] == -1) break;
sum[i] += arr.data[glob_tmp[i][j]].val;
}
l = j-1;
}
return sum[0] + sum[1] + sum[2] * ((arr.data[glob_tmp[2][l]].diff >= BONUS) ? 1.5 : 1);
}
void addElemento(elemArray arr, Constr c, int index_diag, int index_elem){
int i, j, flag = 0;
/*printf("Diag: %d, Elem: %d\n", index_diag, index_elem);
for(i = 0; i < NDIA; ++i){
for(j = 0; j < NELE; ++j){
printf("%d ", glob_tmp[i][j]);
}
printf("\n");
}
printf("\n");*/
if(index_diag >= NDIA){ // Stop
// Controllo ammissibilita (c.dacro e c.fbacro)
if(c.fbacro[0] == 0 || c.fbacro[1] == 0)
return;
for(i = 0; i < NDIA; ++i){
flag = 0;
for(j = 0; j < NELE; ++j){
if(arr.data[glob_tmp[i][j]].tipo > 0){
if(flag == 0){
flag = 1;
}
else{
// Trovata la doppia acrobazia
tmpval = calcValSolTmp(arr);
if(tmpval > maxval){
maxval = tmpval;
for(i = 0; i < NDIA; ++i)
for(j = 0; j < NELE; ++j)
glob_sol[i][j] = glob_tmp[i][j];
printf("%f\n", tmpval);
stampaSol(arr);
printf("\n");
}
return;
}
}
else{
flag = 0;
}
}
}
}
// Metti tutti gli altri elementi
// Sia in questa diagonale che ad iniziare la prossima
// Se sono al 5 elemento metto solo nella prossima
// Se non ho rispettato i constr di questa diagonale non vado alla prossima.
// Metto solo elementi legali.
for(i = 0; i < arr.len && index_elem < NELE; ++i){
if(index_elem == 0 && arr.data[i].first == 1)
continue;
// Aggiungo alla diagonale se posso
if((index_elem == 0 && arr.data[i].dir_in == 1) || (index_elem > 0 && ((!arr.data[glob_tmp[index_diag][index_elem-1]].dir_out ^ !arr.data[i].dir_in) == 0))){
// Aggiorno constraints e glob_tmp
c.dd[index_diag] -= arr.data[i].diff;
c.dp -= arr.data[i].diff;
c.acrxdiag[index_diag] += arr.data[i].tipo;
c.fbacro[0] += (arr.data[i].tipo == 2);
c.fbacro[1] += (arr.data[i].tipo == 1);
tmpval += arr.data[i].val;
glob_tmp[index_diag][index_elem] = i;
// Ricorro
if(c.dd[index_diag] >= 0 && c.dp >= 0){
if(arr.data[i].last == 0)
addElemento(arr, c, index_diag, index_elem+1);
else
addElemento(arr, c, index_diag+1, 0);
}
// Backtrack
c.dd[index_diag] += arr.data[i].diff;
c.dp += arr.data[i].diff;
c.acrxdiag[index_diag] -= arr.data[i].tipo;
c.fbacro[0] -= (arr.data[i].tipo == 2);
c.fbacro[1] -= (arr.data[i].tipo == 1);
tmpval -= arr.data[i].val;
glob_tmp[index_diag][index_elem] = -1;
}
}
// Se no passo alla prossima
if(c.acrxdiag[index_diag] > 0){
addElemento(arr, c, index_diag+1, 0);
}
return;
}
void stampaSol(elemArray arr){
int i, j, l = 0;
float sum[NDIA] = {0};
for(i = 0; i < NDIA; ++i){
for(j = 0; j < NELE; ++j){
printf("%d ", glob_sol[i][j]);
}
printf("\n");
}
printf("\n");
for(i = 0; i < NDIA; ++i){
for(j = 0; j < NELE; ++j){
if(glob_sol[i][j] == -1) break;
sum[i] += arr.data[glob_sol[i][j]].val;
}
l = j - 1;
}
printf("TOT = %.3f\n", maxval);
for(i = 0; i < NDIA; ++i){
printf("DIAG #%d > %.3f", i+1, sum[i]);
if(i == 2 && arr.data[glob_sol[i][l]].diff >= BONUS)
printf(" * 1.5 (BONUS)");
printf("\n");
for(j = 0; j < NELE; ++j){
if(glob_sol[i][j] == -1) break;
printf("%s ", arr.data[glob_sol[i][j]].nome);
}
printf("\n");
}
}
void generaProgramma(elemArray arr, int dd, int dp){
Constr c = {{dd, dd, dd}, dp, {0, 0, 0}, {0, 0}};
int i, j;
for(i = 0; i < NDIA; ++i)
for(j = 0; j < NELE; ++j)
glob_tmp[i][j] = glob_sol[i][j] = -1;
addElemento(arr, c, 0, 0);
stampaSol(arr);
}
|
the_stack_data/150141840.c | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#define BUF_SIZE 30
void error_handling(char *message);
int main(int argc, char *argv[])
{
int serv_sock;
char message[BUF_SIZE];
int str_len;
socklen_t clnt_adr_sz;
struct sockaddr_in serv_adr, clnt_adr;
if(argc !=2){
printf("usage: %s <port> \n", argv[0]);
exit(1);
}
serv_sock=socket(PF_INET, SOCK_DGRAM, 0);
if(serv_sock==-1)
error_handling("UDP socket creation error");
memset(&serv_adr, 0, sizeof(serv_adr));
serv_adr.sin_family=AF_INET;
serv_adr.sin_addr.s_addr=htonl(INADDR_ANY);
serv_adr.sin_port=htons(atoi(argv[1]));
if(bind(serv_sock, (struct sockaddr*)&serv_adr, sizeof(serv_adr))==-1)
error_handling("bind() error");
while(1){
clnt_adr_sz=sizeof(clnt_adr);
// 获取数据传输端(客户端)的地址,例如该地址,调用send_to, 逆向传输数据
str_len=recvfrom(serv_sock, message, BUF_SIZE, 0, (struct sockaddr*)&clnt_adr, &clnt_adr_sz);
sendto(serv_sock, message, str_len, 0, (struct sockaddr*)&clnt_adr, clnt_adr_sz);
}
close(serv_sock);
return 0;
}
void error_handling(char *message)
{
fputs(message, stderr);
fputc('\n', stderr);
exit(1);
}
|
the_stack_data/432086.c |
#include <stdio.h>
#include <stdlib.h>
typedef struct DataType DATATYPE;
struct DataType {
int x;
int y;
int val;
};
typedef struct _list_stack {
DATATYPE data;
int count;
struct _list_stack *next;
} stack;
stack *stackCreate() {
stack *s = (stack *)malloc(sizeof(stack));
if (s == NULL) { return NULL; }
s->next = NULL;
s->count = 0;
return s;
}
void stackDestroy(stack *s) {
stack *tempS = NULL;
while (s->next != NULL) {
tempS = s->next;
s->next = tempS->next;
free(tempS);
}
free(s);
}
void stackPush(stack *s, DATATYPE data) {
stack *node = (stack *)malloc(sizeof(stack));
if (node == NULL) { return; }
s->count += 1;
node->data = data;
node->count = s->count;
node->next = s->next;
s->next = node;
}
DATATYPE stackPop(stack *s) {
if (s->next == NULL) {
DATATYPE data = {0,0,0};
return data;
}
stack *next = s->next;
DATATYPE data = next->data;
s->count -= 1;
s->next = next->next;
free(next);
return data;
}
void stackDump(stack *s) {
if (s->next == NULL) { printf("stack empty!\n"); return; }
stack *next = s->next;
while (next != NULL) {
printf("-> (%d,%d=%d) ", next->data.x, next->data.y,next->data.val);
next = next->next;
}
printf("\n");
}
void gameOfLife(int** board, int boardSize, int* boardColSize){
if (board == NULL || boardSize <= 0 || boardColSize == NULL ) { return; }
int dirX[] = {0,1,0,-1,-1,-1,1,1};
int dirY[] = {1,0,-1,0,-1,1,-1,1};
stack *s = stackCreate();
int nearX = 0, nearY = 0, nearLiveCount = 0;
int colSize = boardColSize[0];
for (int i = 0; i < boardSize; i++) {
for (int j = 0; j < colSize; j++) {
nearLiveCount = 0;
for (int d = 0; d < 8; d++) {
nearX = i + dirX[d]; nearY = j + dirY[d];
if (nearX >= 0 && nearY >= 0 && nearX < boardSize && nearY < colSize && board[nearX][nearY] == 1) {
nearLiveCount++;
}
}
//把有变动的,入栈保存
DATATYPE data = {i,j,0};
if (nearLiveCount < 2 || nearLiveCount > 3) {
//周围活细胞数少于两个,则该位置活细胞死亡
//周围有超过三个活细胞,则该位置活细胞死亡
data.val = 0;
stackPush(s, data);
} else if (nearLiveCount == 3 && board[i][j] == 0) {
//周围正好有三个活细胞,则该位置死细胞复活
data.val = 1;
stackPush(s, data);
}
//else if ( (nearLiveCount == 2 || nearLiveCount == 3) && board[i][j] == 1) {
// //周围有两个或三个活细胞,则该位置活细胞仍然存活
//data.val = 1; stackPush(s, data); }
}
}
//修改原数据
if (s->next == NULL) { return; }
stack *next = s->next;
while (next != NULL) {
board[next->data.x][next->data.y] = next->data.val;
next = next->next;
}
}
int main(int argc, const char * argv[]) {
int array[5][5] = {{0,0,1,1,1},{0,1,1,0,0},{0,0,1,1,0},{1,0,0,0,0},{1,1,0,0,1}};
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
printf("%d ", array[i][j]);
}
printf("\n");
}
printf("\n");
int **a = (int **)malloc(sizeof(int *)*5);
for (int i = 0; i < 5; i++) {
int *a1 = (int *)malloc(sizeof(int)*5);
for (int j = 0; j < 5; j++) {
a1[j] = array[i][j];
}
a[i] = a1;
}
int b[5] = {5,5,5,5,5};
gameOfLife(a, 5, b);
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
printf("%d ", a[i][j]);
}
printf("\n");
}
printf("\n");
return 0;
}
|
the_stack_data/43887001.c | #include <stdlib.h>
int main(int argc, char** argv)
{
return 0;
}
|
the_stack_data/52728.c | #include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
int main(int argc, char* argv[])
{
if(argc != 2)
{
printf("Usage: %s <matrixSize>\n", argv[0]);
return -1;
}
// Matrix size
int64_t N = atoi(argv[1]);
int bl;
int** a = (int **) malloc(N * sizeof(int *));
int** b = (int **) malloc(N * sizeof(int *));
int** c = (int **) malloc(N * sizeof(int *));
for(int i = 0; i < N; i++){
a[i] = (int *) malloc(N * sizeof(int));
b[i] = (int *) malloc(N * sizeof(int));
c[i] = (int *) malloc(N * sizeof(int));
}
for(int i = 0; i < N; i++)
for(int j = 0; j < N; j++){
a[i][j] = rand() % 10;
b[i][j] = rand() % 10;
c[i][j] = 0;
}
int i,j,k,ii,jj,kk;
struct timeval start, end;
gettimeofday(&start, NULL);
bl = 64;
for(ii=0; ii<N; ii+=bl)
for(jj=0; jj<N; jj+=bl)
for(kk=0; kk<N; kk+=bl)
for(i=0; i<bl && ii+i < N; i++)
for(j=0; j<bl && jj + j < N; j++)
for(k=0; k<bl && kk + k < N; k++)
c[ii+i][jj+j] += a[ii+i][kk+k]*b[kk+k][jj+j];
gettimeofday(&end, NULL);
float elapsed = ((end.tv_sec - start.tv_sec)*1000000.0f + end.tv_usec - start.tv_usec)/1000000.0f;
printf("%12f\n", elapsed);
return 0;
}
|
the_stack_data/888045.c | /******************************************************************************
* Copyright (c) 2004, 2008 IBM Corporation
* All rights reserved.
* This program and the accompanying materials
* are made available under the terms of the BSD License
* which accompanies this distribution, and is available at
* http://www.opensource.org/licenses/bsd-license.php
*
* Contributors:
* IBM Corporation - initial implementation
*****************************************************************************/
#include <stdlib.h>
unsigned long int strtoul(const char *S, char **PTR,int BASE)
{
unsigned long rval = 0;
short int digit;
// *PTR is S, unless PTR is NULL, in which case i override it with my own ptr
char* ptr;
if (PTR == 0)
{
//override
PTR = &ptr;
}
// i use PTR to advance through the string
*PTR = (char *) S;
//check if BASE is ok
if ((BASE < 0) || BASE > 36)
{
return 0;
}
// ignore white space at beginning of S
while ((**PTR == ' ')
|| (**PTR == '\t')
|| (**PTR == '\n')
|| (**PTR == '\r')
)
{
(*PTR)++;
}
// if BASE is 0... determine the base from the first chars...
if (BASE == 0)
{
// if S starts with "0x", BASE = 16, else 10
if ((**PTR == '0') && (*((*PTR)+1) == 'x'))
{
BASE = 16;
(*PTR)++;
(*PTR)++;
}
else
{
BASE = 10;
}
}
if (BASE == 16)
{
// S may start with "0x"
if ((**PTR == '0') && (*((*PTR)+1) == 'x'))
{
(*PTR)++;
(*PTR)++;
}
}
//until end of string
while (**PTR)
{
if (((**PTR) >= '0') && ((**PTR) <='9'))
{
//digit (0..9)
digit = **PTR - '0';
}
else if (((**PTR) >= 'a') && ((**PTR) <='z'))
{
//alphanumeric digit lowercase(a (10) .. z (35) )
digit = (**PTR - 'a') + 10;
}
else if (((**PTR) >= 'A') && ((**PTR) <='Z'))
{
//alphanumeric digit uppercase(a (10) .. z (35) )
digit = (**PTR - 'A') + 10;
}
else
{
//end of parseable number reached...
break;
}
if (digit < BASE)
{
rval = (rval * BASE) + digit;
}
else
{
//digit found, but its too big for current base
//end of parseable number reached...
break;
}
//next...
(*PTR)++;
}
//done
return rval;
}
|
the_stack_data/156392722.c | /*C program to Display abbreviated form of a given name*/
#include<stdio.h> //Preprocessor Directive
int main()
{
char s1[50],s2[20];int i,j=0,k=-1; //Declaration and Initialization
printf("Enter a Name: ");
gets(s1); //Input Name
for(i=0;s1[i]!='\0';i++) //Loop to iterate over Name
{
if(s1[i]==' ')
{
s2[j++]=s1[k+1]; //Assignment
s2[j++]='.';
k=i;
}
}
for(;s1[k]!='\0';j++,k++) //Loop to assign last word
s2[j]=s1[k];
s2[j]='\0'; //Assigning Null character at the end
printf("Abbreviated Form: %s\n",s2); //Output
return 0;
} //End of Program
|
the_stack_data/220455309.c | // RUN: %clang_asan -O0 %s -o %t
// RUN: not %run %t 2>&1 | FileCheck %s
// Since ASan is built with -fomit-frame-pointer, backtrace is not able to
// symbolicate the trace past ASan runtime on i386. (This is fixed in
// latest OS X.)
// REQUIRES: asan-64-bits
#include <execinfo.h>
#include <sanitizer/common_interface_defs.h>
#include <stdio.h>
#include <stdlib.h>
void death_function() {
fprintf(stderr, "DEATH CALLBACK\n");
void* callstack[128];
int i, frames = backtrace(callstack, 128);
char** strs = backtrace_symbols(callstack, frames);
for (i = 0; i < frames; ++i) {
fprintf(stderr, "%s\n", strs[i]);
}
free(strs);
fprintf(stderr, "END OF BACKTRACE\n");
}
int fault_function() {
char *x = (char*)malloc(10 * sizeof(char));
free(x);
return x[5]; // BOOM
}
int main() {
__sanitizer_set_death_callback(death_function);
fault_function();
return 0;
}
// CHECK: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}}
// CHECK: {{READ of size 1 at 0x.* thread T0}}
// CHECK: {{ #0 0x.* in fault_function}}
// CHECK: DEATH CALLBACK
// CHECK: death_function
// CHECK: fault_function
// CHECK: main
// CHECK: END OF BACKTRACE
|
the_stack_data/95528.c |
/* nothing */
|
the_stack_data/51699308.c | /**/
#include <stdio.h>
int main()
{
int n1, n2, n3;
printf("Please enter 3 numbers separated by spaces > ");
scanf("%d%d%d", &n1, &n2, &n3);
if ((n1>n2)&&(n1>n3)&&(n2>n3))
printf("%d is the median\n", n2);
else if ((n1>n2)&&(n1>n3)&&(n3>n2))
printf("%d is the median\n", n3);
else if ((n2>n1)&&(n2>n3)&&(n3>n1))
printf("%d is the median\n", n3);
else if ((n2>n1)&&(n2>n3)&&(n1>n3))
printf("%d is the median\n", n1);
else if ((n3>n1)&&(n3>n2)&&(n1>n2))
printf("%d is the median\n", n1);
else if ((n3>n1)&&(n3>n2)&&(n2>n1))
printf("%d is the median\n", n2);
else if ((n1=n2)&&(n2=n3))
printf("%d is the median\n", n1);
return(0);
}
|
the_stack_data/154107.c | /*
Data race between the values in countervar leading to changing results. Only using worker level parallelism.
*/
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#define N 100000
int countervar[N];
int init(){
for(int i=0; i<N; i++){
countervar[i]=0;
}
return 0;
}
int count(){
#pragma acc data copy(countervar[0:N])
#pragma acc parallel num_workers(256)
#pragma acc loop worker
for (int i=1; i<N; i++){
countervar[i]=countervar[i-1]+1;
}
return 0;
}
int check(){
bool test = false;
for(int i=0; i<N; i++){
if(countervar[i]!=i){
test = true;
}
}
printf("Memory Access Issue visible: %s\n",test ? "true" : "false");
return 0;
}
int main(){
init();
count();
check();
return 0;
} |
the_stack_data/43888017.c | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <xmmintrin.h>
#include <sys/time.h>
#define EPS 1E-6
enum {
n = 1000003
};
void saxpy(float *x, float *y, float a, int n)
{
for (int i = 0; i < n; i++)
y[i] = a * x[i] + y[i];
}
void saxpy_sse(float * restrict x, float * restrict y, float a, int n)
{
__m128 *xx = (__m128 *)x;
__m128 *yy = (__m128 *)y;
int k = n / 4;
__m128 aa = _mm_set1_ps(a);
for (int i = 0; i < k; i++) {
__m128 z = _mm_mul_ps(aa, xx[i]);
yy[i] = _mm_add_ps(z, yy[i]);
}
for (int i = k * 4; i < n; i++)
y[i] = a * x[i] + y[i];
}
void *xmalloc(size_t size)
{
void *p = malloc(size);
if (!p) {
fprintf(stderr, "malloc failed\n");
exit(EXIT_FAILURE);
}
return p;
}
double wtime()
{
struct timeval t;
gettimeofday(&t, NULL);
return (double)t.tv_sec + (double)t.tv_usec * 1E-6;
}
double run_scalar()
{
float *x, *y, a = 2.0;
x = xmalloc(sizeof(*x) * n);
y = xmalloc(sizeof(*y) * n);
for (int i = 0; i < n; i++) {
x[i] = i * 2 + 1.0;
y[i] = i;
}
double t = wtime();
saxpy(x, y, a, n);
t = wtime() - t;
/* Verification */
for (int i = 0; i < n; i++) {
float xx = i * 2 + 1.0;
float yy = a * xx + i;
if (fabs(y[i] - yy) > EPS) {
fprintf(stderr, "run_scalar: verification failed (y[%d] = %f != %f)\n", i, y[i], yy);
break;
}
}
printf("Elapsed time (scalar): %.6f sec.\n", t);
free(x);
free(y);
return t;
}
double run_vectorized()
{
float *x, *y, a = 2.0;
x = _mm_malloc(sizeof(*x) * n, 16);
y = _mm_malloc(sizeof(*y) * n, 16);
for (int i = 0; i < n; i++) {
x[i] = i * 2 + 1.0;
y[i] = i;
}
double t = wtime();
saxpy_sse(x, y, a, n);
t = wtime() - t;
/* Verification */
for (int i = 0; i < n; i++) {
float xx = i * 2 + 1.0;
float yy = a * xx + i;
if (fabs(y[i] - yy) > EPS) {
fprintf(stderr, "run_vectorized: verification failed (y[%d] = %f != %f)\n", i, y[i], yy);
break;
}
}
printf("Elapsed time (vectorized): %.6f sec.\n", t);
free(x);
free(y);
return t;
}
int main(int argc, char **argv)
{
printf("SAXPY (y[i] = a * x[i] + y[i]; n = %d)\n", n);
double tscalar = run_scalar();
double tvec = run_vectorized();
printf("Speedup: %.2f\n", tscalar / tvec);
return 0;
}
|
the_stack_data/87638919.c | /* Exercise 1 - Calculations
Write a C program to input marks of two subjects. Calculate and print the average of the two marks. */
#include <stdio.h>
int main()
{
int sum , mark1 , mark2 ;
float avg ;
printf("ENTER THE MARKS OF SUBJECT 1:");
scanf("%d", &mark1) ;
printf("ENTER MARKS OF THE SUBJECT 2: ");
scanf("%d", &mark2);
sum = mark1 + mark2 ;
avg=sum/2.00;
printf("THE AVERAGE OF THE TWO MARKS IS : %f",avg );
return 0;
}
|
the_stack_data/5639.c | /*
* Copyright (c) 1992-1994 by Xerox Corporation. All rights reserved.
*
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
*
* Permission is hereby granted to use or copy this program
* for any purpose, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
/* Boehm, March 29, 1995 12:51 pm PST */
# ifdef CHECKSUMS
# include "gc_priv.h"
/* This is debugging code intended to verify the results of dirty bit */
/* computations. Works only in a single threaded environment. */
/* We assume that stubborn objects are changed only when they are */
/* enabled for writing. (Certain kinds of writing are actually */
/* safe under other conditions.) */
# define NSUMS 2000
# define OFFSET 0x10000
typedef struct {
GC_bool new_valid;
word old_sum;
word new_sum;
struct hblk * block; /* Block to which this refers + OFFSET */
/* to hide it from colector. */
} page_entry;
page_entry GC_sums [NSUMS];
word GC_checksum(h)
struct hblk *h;
{
register word *p = (word *)h;
register word *lim = (word *)(h+1);
register word result = 0;
while (p < lim) {
result += *p++;
}
return(result | 0x80000000 /* doesn't look like pointer */);
}
# ifdef STUBBORN_ALLOC
/* Check whether a stubborn object from the given block appears on */
/* the appropriate free list. */
GC_bool GC_on_free_list(h)
struct hblk *h;
{
register hdr * hhdr = HDR(h);
register int sz = hhdr -> hb_sz;
ptr_t p;
if (sz > MAXOBJSZ) return(FALSE);
for (p = GC_sobjfreelist[sz]; p != 0; p = obj_link(p)) {
if (HBLKPTR(p) == h) return(TRUE);
}
return(FALSE);
}
# endif
int GC_n_dirty_errors;
int GC_n_changed_errors;
int GC_n_clean;
int GC_n_dirty;
void GC_update_check_page(h, index)
struct hblk *h;
int index;
{
page_entry *pe = GC_sums + index;
register hdr * hhdr = HDR(h);
if (pe -> block != 0 && pe -> block != h + OFFSET) ABORT("goofed");
pe -> old_sum = pe -> new_sum;
pe -> new_sum = GC_checksum(h);
# if !defined(MSWIN32) && !defined(MSWINCE)
if (pe -> new_sum != 0 && !GC_page_was_ever_dirty(h)) {
GC_printf1("GC_page_was_ever_dirty(0x%lx) is wrong\n",
(unsigned long)h);
}
# endif
if (GC_page_was_dirty(h)) {
GC_n_dirty++;
} else {
GC_n_clean++;
}
if (pe -> new_valid && pe -> old_sum != pe -> new_sum) {
if (!GC_page_was_dirty(h) || !GC_page_was_ever_dirty(h)) {
/* Set breakpoint here */GC_n_dirty_errors++;
}
# ifdef STUBBORN_ALLOC
if (!IS_FORWARDING_ADDR_OR_NIL(hhdr)
&& hhdr -> hb_map != GC_invalid_map
&& hhdr -> hb_obj_kind == STUBBORN
&& !GC_page_was_changed(h)
&& !GC_on_free_list(h)) {
/* if GC_on_free_list(h) then reclaim may have touched it */
/* without any allocations taking place. */
/* Set breakpoint here */GC_n_changed_errors++;
}
# endif
}
pe -> new_valid = TRUE;
pe -> block = h + OFFSET;
}
word GC_bytes_in_used_blocks;
void GC_add_block(h, dummy)
struct hblk *h;
word dummy;
{
register hdr * hhdr = HDR(h);
register bytes = WORDS_TO_BYTES(hhdr -> hb_sz);
bytes += HDR_BYTES + HBLKSIZE-1;
bytes &= ~(HBLKSIZE-1);
GC_bytes_in_used_blocks += bytes;
}
void GC_check_blocks()
{
word bytes_in_free_blocks = 0;
struct hblk * h = GC_hblkfreelist;
hdr * hhdr = HDR(h);
word sz;
GC_bytes_in_used_blocks = 0;
GC_apply_to_all_blocks(GC_add_block, (word)0);
while (h != 0) {
sz = hhdr -> hb_sz;
bytes_in_free_blocks += sz;
h = hhdr -> hb_next;
hhdr = HDR(h);
}
GC_printf2("GC_bytes_in_used_blocks = %ld, bytes_in_free_blocks = %ld ",
GC_bytes_in_used_blocks, bytes_in_free_blocks);
GC_printf1("GC_heapsize = %ld\n", GC_heapsize);
if (GC_bytes_in_used_blocks + bytes_in_free_blocks != GC_heapsize) {
GC_printf0("LOST SOME BLOCKS!!\n");
}
}
/* Should be called immediately after GC_read_dirty and GC_read_changed. */
void GC_check_dirty()
{
register int index;
register unsigned i;
register struct hblk *h;
register ptr_t start;
GC_check_blocks();
GC_n_dirty_errors = 0;
GC_n_changed_errors = 0;
GC_n_clean = 0;
GC_n_dirty = 0;
index = 0;
for (i = 0; i < GC_n_heap_sects; i++) {
start = GC_heap_sects[i].hs_start;
for (h = (struct hblk *)start;
h < (struct hblk *)(start + GC_heap_sects[i].hs_bytes);
h++) {
GC_update_check_page(h, index);
index++;
if (index >= NSUMS) goto out;
}
}
out:
GC_printf2("Checked %lu clean and %lu dirty pages\n",
(unsigned long) GC_n_clean, (unsigned long) GC_n_dirty);
if (GC_n_dirty_errors > 0) {
GC_printf1("Found %lu dirty bit errors\n",
(unsigned long)GC_n_dirty_errors);
}
if (GC_n_changed_errors > 0) {
GC_printf1("Found %lu changed bit errors\n",
(unsigned long)GC_n_changed_errors);
GC_printf0("These may be benign (provoked by nonpointer changes)\n");
# ifdef THREADS
GC_printf0(
"Also expect 1 per thread currently allocating a stubborn obj.\n");
# endif
}
}
# else
extern int GC_quiet;
/* ANSI C doesn't allow translation units to be empty. */
/* So we guarantee this one is nonempty. */
# endif /* CHECKSUMS */
|
the_stack_data/165766391.c | #include <stdio.h>
int estPair(int nb){
//Fonction qui renvoie vrai si le nombre nb est estPair
return (nb % 2);
}
int chargerFich(FILE* fich){
//Fonction qui charge ouvre le fichier fich
fich = fopen("nombres.txt", "r");
return (fich == NULL);
}
void affResultat(int nb_pair, FILE* fich){
//Fonction qui affiche le résultat du programme et qui ferme le fichier
printf("Le fichier contient %i entiers pairs\n", nb_pair);
fclose(fich);
}
int lecture(FILE* fich){
//Fonction qui lit le fichier et qui revoie le nombre d'entiers pairs
int test_val;
int resultat = 0;
fscanf(fich,"%i", &test_val);
while(! feof(fich)){
resultat += estPair(test_val);
fscanf(fich,"%i", &test_val);
}
return resultat;
}
int main(void){
FILE* f;
int test_val;
int resultat = 0 ;
f = fopen("nombres.txt", "r");
fscanf(f,"%i", &test_val);
while(! feof(f)){
resultat += estPair(test_val);
fscanf(f,"%i", &test_val);
}
printf("Le fichier contient %i entiers pairs\n", resultat);
fclose(f);
return 0;
} |
the_stack_data/150139358.c | struct a {
int b;
int c;
int d;
int e;
int f;
int g;
int h;
int i;
int j;
int k;
int l;
int m;
int n;
int o
};
struct p {
int family;
struct a config
} q(struct p *r) {
switch (r->family) {
case 8:
r->config.b = 2;
r->config.c = 2;
r->config.d = 8;
r->config.e = 2;
r->config.f = 4;
r->config.g = 2;
r->config.h = 256;
r->config.i = 2;
r->config.j = 8;
r->config.k = 32;
r->config.l = 0;
r->config.m = 48;
r->config.n = 304;
break;
case 0:
r->config.b = 2;
r->config.c = 8;
r->config.d = 5;
r->config.e = 2;
r->config.f = 4;
r->config.g = 8;
r->config.h = 256;
r->config.i = 2;
r->config.j = 8;
r->config.k = 32;
r->config.l = 0;
r->config.m = 48;
r->config.n = 304;
break;
default:
r->config.b = 1;
r->config.c = 4;
r->config.d = 5;
r->config.e = 2;
r->config.f = 4;
r->config.g = 4;
r->config.h = 256;
r->config.i = 2;
r->config.j = 8;
r->config.k = 32;
r->config.l = 0;
r->config.m = 48;
r->config.n = 304;
break;
case 1:
r->config.b = r->config.c = r->config.d = r->config.e = r->config.f =
r->config.g = r->config.h = r->config.i = r->config.j = r->config.k =
r->config.l = r->config.m = 8;
case 2:
r->config.b = 1;
r->config.c = 4;
r->config.d = 5;
r->config.e = 1;
r->config.f = 1;
r->config.g = 2;
r->config.h = 256;
r->config.i = 6;
r->config.j = 8;
r->config.k = 32;
r->config.l = 4;
r->config.m = 48;
r->config.n = 304;
}
switch (r->config.o) {
default:
s();
s(1);
break;
case 4:
s(2);
}
}
|
the_stack_data/85472.c | // INFO: task hung in snd_seq_kernel_client_ctl
// https://syzkaller.appspot.com/bug?id=ce4e6f3b0608824cab0e5c01bd96b10579350310
// status:fixed
// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
int main(void)
{
syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0);
memcpy((void*)0x200019c0, "/dev/sequencer\000", 15);
syscall(__NR_openat, 0xffffffffffffff9c, 0x200019c0, 1, 0);
return 0;
}
|
the_stack_data/1113754.c | #include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
/**
* Определяет максимальный повторяющийся фрагмент с конца буфера
*
* Возвращает или размер фрагмента или 0 в случае неудачи.
*/
size_t find_max_fragment(char* buf, size_t size) {
printf("%c %i\n", buf[size-2], size);
size_t max = 0;
char* end = buf+size;
for(size_t i=9114, s=size/2; i<s; i++) {
char* a = end-i;
char* b = end-i*2;
printf("%c==%c end %i\n", a[0], b[0], a[i-1]==b[i-1]);
if(memcmp(a, b, i) == 0) max = i;
//printf("START %c==%c\n", *a, *b);
// int x = 0;
// for(; a<end; a++, b++) {
// //printf("%c==%c\n", *a, *b);
// if(*a != *b) { x=1; break; }
// }
// if(x==0) max = i;
break;
}
return max;
}
/**
* Нахождение минимального повторяющегося фрагмента внутри указанного фрагмента
*
* Максимальный повторяющийся фрагмент может состоять из более мелких фрагментов.
* Находим средний повторяющийся фрагмент.
* Это нужно, чтобы захватить максимум повторяющихся фрагментов.
*/
size_t find_mid_fragment(char* fragment, size_t size) {
size_t mid = size;
for(size_t k=2; k<size; k++) {
if(size % k != 0) continue; // только если делится без остатка
// это - длина равных участков на которые делится найденный фрагмент (max байт с конца)
size_t size_mid = size / k;
printf("k=%i size_mid=%i\n", k, size_mid);
// цикл по столбцам
for(size_t c=0; c<size_mid; c++) {
char first_byte = fragment[c];
// цикл по участкам
for(size_t u=0; u<k; u++)
if(first_byte != fragment[u*size_mid+c]) goto NO;
}
mid = k;
NO: (void) 0;
}
return mid;
}
/**
* Cрезает из файла повторяющиеся фрагменты
*/
void cut_end_repeated_file(FILE* f, char* fragment, size_t size) {
// определяем место с которого фрагмент начинает повторяться
size_t pos;
char* b = malloc(size);
for(size_t i=size*4;; i+=size) {
if(fseek(f, -i, SEEK_END)) break;
if(fread(b, 1, size, f) != size) break;
if(memcmp(fragment, b, size)) break;
pos = i;
}
// усекаем файл
//ftruncate(f, i);
printf("pos: %i\n", pos);
free(b);
}
/**
* Точка входа
*/
int main(int ac, char** av) {
int buf_size = 1024 * 1024;
if(ac == 3) buf_size = atoi(av[2]);
if(!(ac == 2 || ac == 3)) {
fprintf(stderr, "using: dublios <file> [<buffer size>]\n");
return 1;
}
FILE* f = fopen(av[1], "rb");
if(!f) { perror(av[1]); exit(errno); }
fseek(f, 0, SEEK_END);
size_t file_size = ftell(f);
size_t len = file_size < buf_size? file_size: buf_size;
// читаем с конца
char* buf = malloc(len);
#define RETURN(CODE) fclose(f); free(buf); return CODE
if(fseek(f, -len, SEEK_END)) { perror("Не могу переместиться к концу."); RETURN(1);}
printf("pos=%i len=%i file_size=%i\n", ftell(f), len, file_size);
size_t size = fread(buf, 1, len, f);
if(size == 0) { perror("Последний фрагмент не считан."); RETURN(1);}
size_t max = find_max_fragment(buf, size);
if(max == 0) {
fprintf(stderr, "Повторяющихся фрагментов не найдено.\n");
RETURN(1);
}
char* end = buf+size;
int n = 0;
for(char* s=end-max; s<end; s++) if(*s=='\n') n++;
printf("max=%i pos=%i newline.end=%i\n", max, file_size-max, n);
size_t mid = find_mid_fragment(buf+size-max, max);
n = 0;
for(char* s=end-mid; s<end; s++) if(*s=='\n') n++;
printf("mid=%i pos=%i newline.end=%i\n", max, file_size-mid, n);
cut_end_repeated_file(f, buf+size-mid, mid);
RETURN(0);
}
|
the_stack_data/1134012.c | #include <stdio.h>
int main() {
int t;
scanf("%d", &t);
while(t--) {
int p, d, d2, d4;
scanf("%d %d", &p, &d);
d = p - d;
d2 = d/2;
d4 = d/4;
long long count = d2*(d4 + 1) - d4*d4 + 1;
printf("%lld\n", count);
}
return 0;
}
|
the_stack_data/122981.c | /* wget from http://www.netlib.org/benchmark/linpackc.new
**
** LINPACK.C Linpack benchmark, calculates FLOPS.
** (FLoating Point Operations Per Second)
**
** Translated to C by Bonnie Toy 5/88
**
** Modified by Will Menninger, 10/93, with these features:
** (modified on 2/25/94 to fix a problem with daxpy for
** unequal increments or equal increments not equal to 1.
** Jack Dongarra)
**
** - Defaults to double precision.
** - Averages ROLLed and UNROLLed performance.
** - User selectable array sizes.
** - Automatically does enough repetitions to take at least 10 CPU seconds.
** - Prints machine precision.
** - ANSI prototyping.
**
** To compile: cc -O -o linpack linpack.c -lm
**
**
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <float.h>
#define SP
#ifdef SP
#define ZERO 0.0
#define ONE 1.0
#define PREC "Single"
#define BASE10DIG FLT_DIG
typedef float REAL;
#endif
#ifdef DP
#define ZERO 0.0e0
#define ONE 1.0e0
#define PREC "Double"
#define BASE10DIG DBL_DIG
typedef double REAL;
#endif
static REAL linpack (long nreps,int arsize);
static void matgen (REAL *a,int lda,int n,REAL *b,REAL *norma);
static void dgefa (REAL *a,int lda,int n,int *ipvt,int *info,int roll);
static void dgesl (REAL *a,int lda,int n,int *ipvt,REAL *b,int job,int roll);
static void daxpy_r (int n,REAL da,REAL *dx,int incx,REAL *dy,int incy);
static REAL ddot_r (int n,REAL *dx,int incx,REAL *dy,int incy);
static void dscal_r (int n,REAL da,REAL *dx,int incx);
static void daxpy_ur (int n,REAL da,REAL *dx,int incx,REAL *dy,int incy);
static REAL ddot_ur (int n,REAL *dx,int incx,REAL *dy,int incy);
static void dscal_ur (int n,REAL da,REAL *dx,int incx);
static int idamax (int n,REAL *dx,int incx);
static REAL second (void);
static void *mempool;
void main(void)
{
char buf[80];
int arsize;
long arsize2d,memreq,nreps;
size_t malloc_arg;
while (1)
{
printf("Enter array size (q to quit) [200]: ");
fgets(buf,79,stdin);
if (buf[0]=='q' || buf[0]=='Q')
break;
if (buf[0]=='\0' || buf[0]=='\n')
arsize=200;
else
arsize=atoi(buf);
arsize/=2;
arsize*=2;
if (arsize<10)
{
printf("Too small.\n");
continue;
}
arsize2d = (long)arsize*(long)arsize;
memreq=arsize2d*sizeof(REAL)+(long)arsize*sizeof(REAL)+(long)arsize*sizeof(int);
printf("Memory required: %ldK.\n",(memreq+512L)>>10);
malloc_arg=(size_t)memreq;
if (malloc_arg!=memreq || (mempool=malloc(malloc_arg))==NULL)
{
printf("Not enough memory available for given array size.\n\n");
continue;
}
printf("\n\nLINPACK benchmark, %s precision.\n",PREC);
printf("Machine precision: %d digits.\n",BASE10DIG);
printf("Array size %d X %d.\n",arsize,arsize);
printf("Average rolled and unrolled performance:\n\n");
printf(" Reps Time(s) DGEFA DGESL OVERHEAD KFLOPS\n");
printf("----------------------------------------------------\n");
nreps=1;
while (linpack(nreps,arsize)<10.)
nreps*=2;
free(mempool);
printf("\n");
}
}
static REAL linpack(long nreps,int arsize)
{
REAL *a,*b;
REAL norma,t1,kflops,tdgesl,tdgefa,totalt,toverhead,ops;
int *ipvt,n,info,lda;
long i,arsize2d;
lda = arsize;
n = arsize/2;
arsize2d = (long)arsize*(long)arsize;
ops=((2.0*n*n*n)/3.0+2.0*n*n);
a=(REAL *)mempool;
b=a+arsize2d;
ipvt=(int *)&b[arsize];
tdgesl=0;
tdgefa=0;
totalt=second();
for (i=0;i<nreps;i++)
{
matgen(a,lda,n,b,&norma);
t1 = second();
dgefa(a,lda,n,ipvt,&info,1);
tdgefa += second()-t1;
t1 = second();
dgesl(a,lda,n,ipvt,b,0,1);
tdgesl += second()-t1;
}
for (i=0;i<nreps;i++)
{
matgen(a,lda,n,b,&norma);
t1 = second();
dgefa(a,lda,n,ipvt,&info,0);
tdgefa += second()-t1;
t1 = second();
dgesl(a,lda,n,ipvt,b,0,0);
tdgesl += second()-t1;
}
totalt=second()-totalt;
if (totalt<0.5 || tdgefa+tdgesl<0.2)
return(0.);
kflops=2.*nreps*ops/(1000.*(tdgefa+tdgesl));
toverhead=totalt-tdgefa-tdgesl;
if (tdgefa<0.)
tdgefa=0.;
if (tdgesl<0.)
tdgesl=0.;
if (toverhead<0.)
toverhead=0.;
printf("%8ld %6.2f %6.2f%% %6.2f%% %6.2f%% %9.3f\n",
nreps,totalt,100.*tdgefa/totalt,
100.*tdgesl/totalt,100.*toverhead/totalt,
kflops);
return(totalt);
}
/*
** For matgen,
** We would like to declare a[][lda], but c does not allow it. In this
** function, references to a[i][j] are written a[lda*i+j].
*/
static void matgen(REAL *a,int lda,int n,REAL *b,REAL *norma)
{
int init,i,j;
init = 1325;
*norma = 0.0;
for (j = 0; j < n; j++)
for (i = 0; i < n; i++)
{
init = (int)((long)3125*(long)init % 65536L);
a[lda*j+i] = (init - 32768.0)/16384.0;
*norma = (a[lda*j+i] > *norma) ? a[lda*j+i] : *norma;
}
for (i = 0; i < n; i++)
b[i] = 0.0;
for (j = 0; j < n; j++)
for (i = 0; i < n; i++)
b[i] = b[i] + a[lda*j+i];
}
/*
**
** DGEFA benchmark
**
** We would like to declare a[][lda], but c does not allow it. In this
** function, references to a[i][j] are written a[lda*i+j].
**
** dgefa factors a double precision matrix by gaussian elimination.
**
** dgefa is usually called by dgeco, but it can be called
** directly with a saving in time if rcond is not needed.
** (time for dgeco) = (1 + 9/n)*(time for dgefa) .
**
** on entry
**
** a REAL precision[n][lda]
** the matrix to be factored.
**
** lda integer
** the leading dimension of the array a .
**
** n integer
** the order of the matrix a .
**
** on return
**
** a an upper triangular matrix and the multipliers
** which were used to obtain it.
** the factorization can be written a = l*u where
** l is a product of permutation and unit lower
** triangular matrices and u is upper triangular.
**
** ipvt integer[n]
** an integer vector of pivot indices.
**
** info integer
** = 0 normal value.
** = k if u[k][k] .eq. 0.0 . this is not an error
** condition for this subroutine, but it does
** indicate that dgesl or dgedi will divide by zero
** if called. use rcond in dgeco for a reliable
** indication of singularity.
**
** linpack. this version dated 08/14/78 .
** cleve moler, university of New Mexico, argonne national lab.
**
** functions
**
** blas daxpy,dscal,idamax
**
*/
static void dgefa(REAL *a,int lda,int n,int *ipvt,int *info,int roll)
{
REAL t;
int j,k,kp1,l,nm1;
/* gaussian elimination with partial pivoting */
if (roll)
{
*info = 0;
nm1 = n - 1;
if (nm1 >= 0)
for (k = 0; k < nm1; k++)
{
kp1 = k + 1;
/* find l = pivot index */
l = idamax(n-k,&a[lda*k+k],1) + k;
ipvt[k] = l;
/* zero pivot implies this column already
triangularized */
if (a[lda*k+l] != ZERO)
{
/* interchange if necessary */
if (l != k)
{
t = a[lda*k+l];
a[lda*k+l] = a[lda*k+k];
a[lda*k+k] = t;
}
/* compute multipliers */
t = -ONE/a[lda*k+k];
dscal_r(n-(k+1),t,&a[lda*k+k+1],1);
/* row elimination with column indexing */
for (j = kp1; j < n; j++)
{
t = a[lda*j+l];
if (l != k)
{
a[lda*j+l] = a[lda*j+k];
a[lda*j+k] = t;
}
daxpy_r(n-(k+1),t,&a[lda*k+k+1],1,&a[lda*j+k+1],1);
}
}
else
(*info) = k;
}
ipvt[n-1] = n-1;
if (a[lda*(n-1)+(n-1)] == ZERO)
(*info) = n-1;
}
else
{
*info = 0;
nm1 = n - 1;
if (nm1 >= 0)
for (k = 0; k < nm1; k++)
{
kp1 = k + 1;
/* find l = pivot index */
l = idamax(n-k,&a[lda*k+k],1) + k;
ipvt[k] = l;
/* zero pivot implies this column already
triangularized */
if (a[lda*k+l] != ZERO)
{
/* interchange if necessary */
if (l != k)
{
t = a[lda*k+l];
a[lda*k+l] = a[lda*k+k];
a[lda*k+k] = t;
}
/* compute multipliers */
t = -ONE/a[lda*k+k];
dscal_ur(n-(k+1),t,&a[lda*k+k+1],1);
/* row elimination with column indexing */
for (j = kp1; j < n; j++)
{
t = a[lda*j+l];
if (l != k)
{
a[lda*j+l] = a[lda*j+k];
a[lda*j+k] = t;
}
daxpy_ur(n-(k+1),t,&a[lda*k+k+1],1,&a[lda*j+k+1],1);
}
}
else
(*info) = k;
}
ipvt[n-1] = n-1;
if (a[lda*(n-1)+(n-1)] == ZERO)
(*info) = n-1;
}
}
/*
**
** DGESL benchmark
**
** We would like to declare a[][lda], but c does not allow it. In this
** function, references to a[i][j] are written a[lda*i+j].
**
** dgesl solves the double precision system
** a * x = b or trans(a) * x = b
** using the factors computed by dgeco or dgefa.
**
** on entry
**
** a double precision[n][lda]
** the output from dgeco or dgefa.
**
** lda integer
** the leading dimension of the array a .
**
** n integer
** the order of the matrix a .
**
** ipvt integer[n]
** the pivot vector from dgeco or dgefa.
**
** b double precision[n]
** the right hand side vector.
**
** job integer
** = 0 to solve a*x = b ,
** = nonzero to solve trans(a)*x = b where
** trans(a) is the transpose.
**
** on return
**
** b the solution vector x .
**
** error condition
**
** a division by zero will occur if the input factor contains a
** zero on the diagonal. technically this indicates singularity
** but it is often caused by improper arguments or improper
** setting of lda . it will not occur if the subroutines are
** called correctly and if dgeco has set rcond .gt. 0.0
** or dgefa has set info .eq. 0 .
**
** to compute inverse(a) * c where c is a matrix
** with p columns
** dgeco(a,lda,n,ipvt,rcond,z)
** if (!rcond is too small){
** for (j=0,j<p,j++)
** dgesl(a,lda,n,ipvt,c[j][0],0);
** }
**
** linpack. this version dated 08/14/78 .
** cleve moler, university of new mexico, argonne national lab.
**
** functions
**
** blas daxpy,ddot
*/
static void dgesl(REAL *a,int lda,int n,int *ipvt,REAL *b,int job,int roll)
{
REAL t;
int k,kb,l,nm1;
if (roll)
{
nm1 = n - 1;
if (job == 0)
{
/* job = 0 , solve a * x = b */
/* first solve l*y = b */
if (nm1 >= 1)
for (k = 0; k < nm1; k++)
{
l = ipvt[k];
t = b[l];
if (l != k)
{
b[l] = b[k];
b[k] = t;
}
daxpy_r(n-(k+1),t,&a[lda*k+k+1],1,&b[k+1],1);
}
/* now solve u*x = y */
for (kb = 0; kb < n; kb++)
{
k = n - (kb + 1);
b[k] = b[k]/a[lda*k+k];
t = -b[k];
daxpy_r(k,t,&a[lda*k+0],1,&b[0],1);
}
}
else
{
/* job = nonzero, solve trans(a) * x = b */
/* first solve trans(u)*y = b */
for (k = 0; k < n; k++)
{
t = ddot_r(k,&a[lda*k+0],1,&b[0],1);
b[k] = (b[k] - t)/a[lda*k+k];
}
/* now solve trans(l)*x = y */
if (nm1 >= 1)
for (kb = 1; kb < nm1; kb++)
{
k = n - (kb+1);
b[k] = b[k] + ddot_r(n-(k+1),&a[lda*k+k+1],1,&b[k+1],1);
l = ipvt[k];
if (l != k)
{
t = b[l];
b[l] = b[k];
b[k] = t;
}
}
}
}
else
{
nm1 = n - 1;
if (job == 0)
{
/* job = 0 , solve a * x = b */
/* first solve l*y = b */
if (nm1 >= 1)
for (k = 0; k < nm1; k++)
{
l = ipvt[k];
t = b[l];
if (l != k)
{
b[l] = b[k];
b[k] = t;
}
daxpy_ur(n-(k+1),t,&a[lda*k+k+1],1,&b[k+1],1);
}
/* now solve u*x = y */
for (kb = 0; kb < n; kb++)
{
k = n - (kb + 1);
b[k] = b[k]/a[lda*k+k];
t = -b[k];
daxpy_ur(k,t,&a[lda*k+0],1,&b[0],1);
}
}
else
{
/* job = nonzero, solve trans(a) * x = b */
/* first solve trans(u)*y = b */
for (k = 0; k < n; k++)
{
t = ddot_ur(k,&a[lda*k+0],1,&b[0],1);
b[k] = (b[k] - t)/a[lda*k+k];
}
/* now solve trans(l)*x = y */
if (nm1 >= 1)
for (kb = 1; kb < nm1; kb++)
{
k = n - (kb+1);
b[k] = b[k] + ddot_ur(n-(k+1),&a[lda*k+k+1],1,&b[k+1],1);
l = ipvt[k];
if (l != k)
{
t = b[l];
b[l] = b[k];
b[k] = t;
}
}
}
}
}
/*
** Constant times a vector plus a vector.
** Jack Dongarra, linpack, 3/11/78.
** ROLLED version
*/
static void daxpy_r(int n,REAL da,REAL *dx,int incx,REAL *dy,int incy)
{
int i,ix,iy;
if (n <= 0)
return;
if (da == ZERO)
return;
if (incx != 1 || incy != 1)
{
/* code for unequal increments or equal increments != 1 */
ix = 1;
iy = 1;
if(incx < 0) ix = (-n+1)*incx + 1;
if(incy < 0)iy = (-n+1)*incy + 1;
for (i = 0;i < n; i++)
{
dy[iy] = dy[iy] + da*dx[ix];
ix = ix + incx;
iy = iy + incy;
}
return;
}
/* code for both increments equal to 1 */
for (i = 0;i < n; i++)
dy[i] = dy[i] + da*dx[i];
}
/*
** Forms the dot product of two vectors.
** Jack Dongarra, linpack, 3/11/78.
** ROLLED version
*/
static REAL ddot_r(int n,REAL *dx,int incx,REAL *dy,int incy)
{
REAL dtemp;
int i,ix,iy;
dtemp = ZERO;
if (n <= 0)
return(ZERO);
if (incx != 1 || incy != 1)
{
/* code for unequal increments or equal increments != 1 */
ix = 0;
iy = 0;
if (incx < 0) ix = (-n+1)*incx;
if (incy < 0) iy = (-n+1)*incy;
for (i = 0;i < n; i++)
{
dtemp = dtemp + dx[ix]*dy[iy];
ix = ix + incx;
iy = iy + incy;
}
return(dtemp);
}
/* code for both increments equal to 1 */
for (i=0;i < n; i++)
dtemp = dtemp + dx[i]*dy[i];
return(dtemp);
}
/*
** Scales a vector by a constant.
** Jack Dongarra, linpack, 3/11/78.
** ROLLED version
*/
static void dscal_r(int n,REAL da,REAL *dx,int incx)
{
int i,nincx;
if (n <= 0)
return;
if (incx != 1)
{
/* code for increment not equal to 1 */
nincx = n*incx;
for (i = 0; i < nincx; i = i + incx)
dx[i] = da*dx[i];
return;
}
/* code for increment equal to 1 */
for (i = 0; i < n; i++)
dx[i] = da*dx[i];
}
/*
** constant times a vector plus a vector.
** Jack Dongarra, linpack, 3/11/78.
** UNROLLED version
*/
static void daxpy_ur(int n,REAL da,REAL *dx,int incx,REAL *dy,int incy)
{
int i,ix,iy,m;
if (n <= 0)
return;
if (da == ZERO)
return;
if (incx != 1 || incy != 1)
{
/* code for unequal increments or equal increments != 1 */
ix = 1;
iy = 1;
if(incx < 0) ix = (-n+1)*incx + 1;
if(incy < 0)iy = (-n+1)*incy + 1;
for (i = 0;i < n; i++)
{
dy[iy] = dy[iy] + da*dx[ix];
ix = ix + incx;
iy = iy + incy;
}
return;
}
/* code for both increments equal to 1 */
m = n % 4;
if ( m != 0)
{
for (i = 0; i < m; i++)
dy[i] = dy[i] + da*dx[i];
if (n < 4)
return;
}
for (i = m; i < n; i = i + 4)
{
dy[i] = dy[i] + da*dx[i];
dy[i+1] = dy[i+1] + da*dx[i+1];
dy[i+2] = dy[i+2] + da*dx[i+2];
dy[i+3] = dy[i+3] + da*dx[i+3];
}
}
/*
** Forms the dot product of two vectors.
** Jack Dongarra, linpack, 3/11/78.
** UNROLLED version
*/
static REAL ddot_ur(int n,REAL *dx,int incx,REAL *dy,int incy)
{
REAL dtemp;
int i,ix,iy,m;
dtemp = ZERO;
if (n <= 0)
return(ZERO);
if (incx != 1 || incy != 1)
{
/* code for unequal increments or equal increments != 1 */
ix = 0;
iy = 0;
if (incx < 0) ix = (-n+1)*incx;
if (incy < 0) iy = (-n+1)*incy;
for (i = 0;i < n; i++)
{
dtemp = dtemp + dx[ix]*dy[iy];
ix = ix + incx;
iy = iy + incy;
}
return(dtemp);
}
/* code for both increments equal to 1 */
m = n % 5;
if (m != 0)
{
for (i = 0; i < m; i++)
dtemp = dtemp + dx[i]*dy[i];
if (n < 5)
return(dtemp);
}
for (i = m; i < n; i = i + 5)
{
dtemp = dtemp + dx[i]*dy[i] +
dx[i+1]*dy[i+1] + dx[i+2]*dy[i+2] +
dx[i+3]*dy[i+3] + dx[i+4]*dy[i+4];
}
return(dtemp);
}
/*
** Scales a vector by a constant.
** Jack Dongarra, linpack, 3/11/78.
** UNROLLED version
*/
static void dscal_ur(int n,REAL da,REAL *dx,int incx)
{
int i,m,nincx;
if (n <= 0)
return;
if (incx != 1)
{
/* code for increment not equal to 1 */
nincx = n*incx;
for (i = 0; i < nincx; i = i + incx)
dx[i] = da*dx[i];
return;
}
/* code for increment equal to 1 */
m = n % 5;
if (m != 0)
{
for (i = 0; i < m; i++)
dx[i] = da*dx[i];
if (n < 5)
return;
}
for (i = m; i < n; i = i + 5)
{
dx[i] = da*dx[i];
dx[i+1] = da*dx[i+1];
dx[i+2] = da*dx[i+2];
dx[i+3] = da*dx[i+3];
dx[i+4] = da*dx[i+4];
}
}
/*
** Finds the index of element having max. absolute value.
** Jack Dongarra, linpack, 3/11/78.
*/
static int idamax(int n,REAL *dx,int incx)
{
REAL dmax;
int i, ix, itemp;
if (n < 1)
return(-1);
if (n ==1 )
return(0);
if(incx != 1)
{
/* code for increment not equal to 1 */
ix = 1;
dmax = fabs((double)dx[0]);
ix = ix + incx;
for (i = 1; i < n; i++)
{
if(fabs((double)dx[ix]) > dmax)
{
itemp = i;
dmax = fabs((double)dx[ix]);
}
ix = ix + incx;
}
}
else
{
/* code for increment equal to 1 */
itemp = 0;
dmax = fabs((double)dx[0]);
for (i = 1; i < n; i++)
if(fabs((double)dx[i]) > dmax)
{
itemp = i;
dmax = fabs((double)dx[i]);
}
}
return (itemp);
}
static REAL second(void)
{
return ((REAL)((REAL)clock()/(REAL)CLOCKS_PER_SEC));
}
|
the_stack_data/165767019.c | /*
* POK header
*
* The following file is a part of the POK project. Any modification should
* made according to the POK licence. You CANNOT use this file or a part of
* this file is this part of a file for your own project
*
* For more information on the POK licence, please see our LICENCE FILE
*
* Please follow the coding guidelines described in doc/CODING_GUIDELINES
*
* Copyright (c) 2007-2009 POK team
*
* Created by julien on Fri Jan 30 14:41:34 2009
*/
/* @(#)s_cbrt.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#ifdef POK_NEEDS_LIBMATH
#include <types.h>
#include <libm.h>
#include "math_private.h"
/* cbrt(x)
* Return cube root of x
*/
static const uint32_t
B1 = 715094163, /* B1 = (682-0.03306235651)*2**20 */
B2 = 696219795; /* B2 = (664-0.03306235651)*2**20 */
static const double
C = 5.42857142857142815906e-01, /* 19/35 = 0x3FE15F15, 0xF15F15F1 */
D = -7.05306122448979611050e-01, /* -864/1225 = 0xBFE691DE, 0x2532C834 */
E = 1.41428571428571436819e+00, /* 99/70 = 0x3FF6A0EA, 0x0EA0EA0F */
F = 1.60714285714285720630e+00, /* 45/28 = 0x3FF9B6DB, 0x6DB6DB6E */
G = 3.57142857142857150787e-01; /* 5/14 = 0x3FD6DB6D, 0xB6DB6DB7 */
double
cbrt(double x)
{
int32_t hx;
double r,s,t=0.0,w;
uint32_t sign;
uint32_t high,low;
GET_HIGH_WORD(hx,x);
sign=hx&0x80000000; /* sign= sign(x) */
hx ^=sign;
if(hx>=0x7ff00000) return(x+x); /* cbrt(NaN,INF) is itself */
GET_LOW_WORD(low,x);
if((hx|low)==0)
return(x); /* cbrt(0) is itself */
SET_HIGH_WORD(x,hx); /* x <- |x| */
/* rough cbrt to 5 bits */
if(hx<0x00100000) /* subnormal number */
{SET_HIGH_WORD(t,0x43500000); /* set t= 2**54 */
t*=x; GET_HIGH_WORD(high,t); SET_HIGH_WORD(t,high/3+B2);
}
else
SET_HIGH_WORD(t,hx/3+B1);
/* new cbrt to 23 bits, may be implemented in single precision */
r=t*t/x;
s=C+r*t;
t*=G+F/(s+E+D/s);
/* chopped to 20 bits and make it larger than cbrt(x) */
GET_HIGH_WORD(high,t);
INSERT_WORDS(t,high+0x00000001,0);
/* one step newton iteration to 53 bits with error less than 0.667 ulps */
s=t*t; /* t*t is exact */
r=x/s;
w=t+t;
r=(r-t)/(w+r); /* r-s is exact */
t=t+t*r;
/* retore the sign bit */
GET_HIGH_WORD(high,t);
SET_HIGH_WORD(t,high|sign);
return(t);
}
#endif
|
the_stack_data/65134.c | #include<stdio.h>
int main(void)
{
int x;
printf("Enter the value of x:\n");
scanf("%d",&x);
for(int i=x;i>=1;i--)
{
for(int l=i-1;l>0;l--)
{
printf(" ");
}
for(int j=x;j>=i;j--)
{
printf("%d",j);
}
printf("\n");
}
}
|
the_stack_data/42672.c | #include <stdio.h>
int main()
{
int i;
char char_array[5] = {'a', 'b', 'c', 'd', 'e'};
int int_array[5] = {1, 2, 3, 4, 5};
void *void_pointer;
void_pointer = (void *) char_array;
for (i = 0; i < 5; i++)
{
printf("[integer pointer] points to %p, which contains the char %c\n", void_pointer, *((char *) void_pointer));
void_pointer = (void *) ((char *) void_pointer + 1); //Casting pointers
}
void_pointer = (void *) int_array;
for (i = 0; i < 5; i++)
{
printf("[char pointer] points to %p, which contains the int %d\n", void_pointer, *((int *) void_pointer));
void_pointer = (char *) ((int *) void_pointer + 1); //Casting pointers
}
return 0;
} |
the_stack_data/173578738.c | /*
** EPITECH PROJECT, 2020
** my_strncpy.c
** File description:
** [email protected]
*/
#include <stdlib.h>
char *my_strncpy(char *dest, char const *src, int n)
{
size_t index = 0;
while (src[index] != '\0' && index < n) {
dest[index] = src[index];
index++;
}
if (index > 0 && src[index] == '\0')
dest[index] = '\0';
return dest;
} |
the_stack_data/28163.c | #include <stdio.h>
#define MAX_STRING_LEN 30
// Function definitions
int indexOf(char c, char*);
char * rmchar(char c, char*);
int main(void){
//variable declarations
char * new;
char * lower = "abcdefghijklmnopqrstuvwxyz0123456789";
char * caps = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
while(1){
//get user input
char string[MAX_STRING_LEN];
printf("Enter a(nother) string to check: ");
scanf("%[^\n]%*c", string);
//remove non alpha-num chars
//caps to lowercase
new = string;
int ptr = 0;
int i = 0;
while(string[ptr] != '\0' && ptr < MAX_STRING_LEN){
if(indexOf(string[ptr], lower) == -1){
if(indexOf(string[ptr], caps) != -1){
new[ptr - i] = string[ptr] + 32;
}
else{
new = rmchar(string[ptr], new);
i++;
}
}
ptr++;
}
//palindrome check
int length = ptr - i;
int flag = 1;
for(int i = 0; i < length / 2; i++){
if(new[i] != new[length - 1 - i]){
flag = 0;
break;
}
}
//print message
switch(flag){
case 0:
printf("Not a palindrome! :(\n");
break;
case 1:
printf("Is a palindrome! :)\n");
break;
}
}
return 0;
}
// Function declarations
// index of char
int indexOf(char c, char * a) {
char * cpy = a;
while (*cpy != '\0') {
if (*cpy == c) {
return cpy - a;
}
cpy++;
}
return -1;
}
// remove first instance of char
char * rmchar(char c, char * a) {
char * ptr = a;
char * i = a;
int del = indexOf(c, ptr);
static char result[( sizeof(a) / sizeof(*a) )];
while (*ptr != '\0') {
if (ptr != a + del) {
result[i - a] = *ptr;
i++;
}
ptr++;
}
result[i - a] = '\0';
return result;
}
|
the_stack_data/107394.c | //Reverse a given number using while loop
#include <stdio.h>
int main()
{
int num, rem, reverse_num=0;
//input number from user.
printf("\n Please enter some numbers: ");
scanf("%d", &num);
while (num>=1)
{
rem = num % 10;
reverse_num = reverse_num*10 + rem;
num = num/10;
}
printf("\n Reverse of the input number is: %d", reverse_num);
return 0;
}
|
the_stack_data/87921.c | #include <stdio.h>
#include <stdbool.h>
#define STACK_SIZE 5
#define INVALID_VAL -256
typedef struct{
int data[STACK_SIZE];
int top;
}stack;
void initialize(stack *s){
s->top = -1;
}
bool is_empty(stack *s){
return s->top == -1 ? true : false;
}
bool is_full(stack *s){
return s->top == STACK_SIZE-1 ? true : false;
}
void push(stack *s, int elem){
if(is_full(s)){
printf("Overflow: Stack is full!\n\n");
return;
}
s->data[++(s->top)] = elem;
}
int pop(stack *s){
if(is_empty(s)){
printf("Underflow: Stack is empty!\n\n");
return INVALID_VAL;
}
return s->data[s->top--];
}
int top_of_stack(stack *s){
if(is_empty(s)){
printf("Stack is empty.\n");
return INVALID_VAL;
}
return s->data[s->top];
}
void display(stack *s){
if(is_empty(s)){
printf("Stack is empty.\n\n");
return;
}
for(int i = s->top; i > -1; i--){
printf("| %5d |\n", s->data[i]);
}
}
int main(void){
stack s;
initialize(&s);
bool loop = true;
int choice, val, temp;
while(loop){
printf("\t1. Push\n");
printf("\t2. Pop\n");
printf("\t3. Top of Stack\n");
printf("\t4. Display\n");
printf("\t5. Exit\n");
printf("Choice [1,2,3,4,5]: ");
scanf("%d", &choice);
switch(choice){
case 1:
do{
printf("\nValue to push [-256 is invalid]: ");
scanf("%d", &val);
}while(val == INVALID_VAL);
push(&s, val);
break;
case 2:
temp = pop(&s);
temp == INVALID_VAL ? printf("Nothing removed.\n\n") : printf("%d is removed.\n\n", temp);
break;
case 3:
temp = top_of_stack(&s);
temp == INVALID_VAL ? printf("\n") : printf("%d is on top.\n", temp);
break;
case 4:
display(&s);
break;
case 5:
loop = false;
break;
default:
printf("Invalid input\n");
}
}
return 0;
} |
the_stack_data/227879.c | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct tf *tp;
struct tf
{
int am;
tp next, previous;
};
tp h,t,temp,to;
int da;
void insert(tp *h,tp to);
void delete(tp *h,tp t);
void print(tp h);
void print_2(tp h);
int main(void)
{
char fry,fry2;
fry='a';
h=NULL;
t=NULL;
while(fry!='q')
{
printf("\n Previous Fry %c \n",fry);
if(fry!='q')
{
printf("\n Give a new choice: \n");
printf("\n (i to 'INSERT', d to 'DELETE', p to 'PRINT_1', w to 'PRINT_2', q to 'QUIT') \n");
printf("\n ");
fry='a';
fflush(stdin);
scanf("%c",&fry);
getchar();
if(fry=='q')
{
printf("\n QUIT \n");
}
if(fry=='i')
{
printf("\n INSERT \n");
printf("\n Give me the AM integer \n");
scanf("%d",&da);
getchar();
temp = (tp)malloc(sizeof(struct tf));
temp->am = da;
temp->next = NULL;
temp->previous = NULL;
printf("\n The AM of temp is %d \n",temp->am);
insert(&h,temp);
}
if(fry=='d')
{
printf("\n Give me the AM integer \n");
scanf("%d",&da);
getchar();
printf("\n DELETE \n");
delete(&h,t);
}
if(fry=='p')
{
printf("\n PRINT \n");
print(h);
}
if(fry=='w')
{
printf("\n PRINT2 \n");
print_2(h);
}
}
}
//system ("pause");
return 0;
}
void insert(tp *h, tp to)
{
tp aux;
if((*h) != NULL)
{
if(((*h)->next) != NULL)
{
if(temp->am > (*h)->am)
{
aux = (*h);
insert(&(aux->next),t);
}
else
{
if((*h)->previous == NULL)
{
temp->next = (*h);
temp->previous = NULL;
(*h)->previous = temp;
(*h) = temp;
}
else
{
aux = (*h);
temp->next = aux;
temp->previous = aux->previous;
aux->previous = temp;
(*h) = temp;
}
}
}
else
{
if(temp->am > (*h)->am)
{
temp->previous = (*h);
temp->next = NULL;
(*h)->next = temp;
}
else
{
aux = (*h);
(aux)->previous = temp;
(aux)->next = NULL;
temp->next = (aux);
temp->previous = NULL;
(*h) = temp;
}
}
}
else
{
//printf("\n The head is NULL \n");
(*h) = temp;
(*h)->next = NULL;
(*h)->previous = NULL;
printf("\n First %d \n",temp->am);
}
}
void delete(tp *h,tp t)
{
tp aux, aux1, aux2;
if(((*h) != NULL)&&((*h)->next != NULL))
{
if((*h)->am != da)
{
aux = (*h);
delete(&(aux->next),t);
}
else if((*h)->am == da)
{
if((*h)->previous != NULL)
{
aux = (*h);
(*h) = (*h)->next;
aux1 = aux->previous;
aux1->next = (*h);
(*h)->previous = aux1;
free(aux);
aux = NULL;
}
else
{
aux = (*h);
(*h) = (*h)->next;
(*h)->previous = NULL;
free(aux);
aux = NULL;
}
}
else
{
printf("\n The AM integer does not exist \n");
}
}
else if(((*h) != NULL)&&((*h)->next == NULL))
{
if((*h)->am == da)
{
free(*h);
(*h) = NULL;
printf("\n The head is now NULL \n");
}
else
{
printf("\n The AM integer does not exist \n");
}
}
else if((*h) == NULL)
{
printf("\n The head is NULL, so the AM integer does not exist \n");
}
}
void print(tp h)
{
if(h != NULL)
{
printf("\n AM is %d ",h->am);
if(h->next != NULL)
{
print(h->next);
}
}
else
{
printf("\n The head is NULL \n");
}
}
void print_2(tp h)
{
tp aux;
if(h != NULL)
{
aux = h;
while(aux->next != NULL)
{
aux = aux->next;
}
while(aux != NULL)
{
printf("\n AM is %d ",aux->am);
aux = aux->previous;
}
}
else
{
printf("\n The head is NULL \n");
}
}
|
the_stack_data/32949121.c | /* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-alias1-vops" } */
/* LLVM LOCAL test not applicable */
/* { dg-require-fdump "" } */
typedef struct {
int i;
int j;
int k;
} Foo;
void bar(Foo*);
int foo(void)
{
Foo a;
a.i = 1;
bar(&a);
return a.i;
}
/* { dg-final { scan-tree-dump-times "V_MAY_DEF" 2 "alias1" } } */
/* { dg-final { cleanup-tree-dump "alias1" } } */
|
the_stack_data/184518366.c | #include <ncurses.h>
int main(void)
{
int rows,cols;
initscr();
getmaxyx(stdscr,rows,cols);
rows--;
cols--;
move(0,0); /* UL corner */
addch('*');
refresh();
napms(500); /* pause half a sec. */
move(0,cols); /* UR corner */
addch('*');
refresh();
napms(500);
move(rows,0); /* LL corner */
addch('*');
refresh();
napms(500);
move(rows,cols); /* LR corner */
addch('*');
refresh();
getchar();
endwin();
return 0;
}
|
the_stack_data/48576147.c | #include <stdio.h>
#define MAXLINE 1000 /* maximum input line size */
int get_line(char line[], int maxline);
void rev_copy(char to[], char from[]);
/* print longest input line */
int main()
{
int len; /* current line length */
char line[MAXLINE]; /* current input line */
char rev_line[MAXLINE]; /* reversed line */
while ((len = get_line(line, MAXLINE)) > 0) {
rev_copy(rev_line, line);
printf("%s", rev_line);
}
return 0;
}
/* get_line: read a line into s, return length */
int get_line(char s[], int lim)
{
int c, i;
for (i=0; i<lim-1 && (c=getchar()) != EOF && c != '\n'; ++i)
s[i] = c;
if (c == '\n') {
s[i] = c;
++i;
}
s[i] = '\0';
return i;
}
/* rev_copy: create a reversed copy 'from' into 'to'; assume to is big enough */
void rev_copy(char to[], char from[])
{
int i;
i = 0;
int from_len = 0;
while(from[from_len] != '\0') ++from_len;
int index_before_newline = from_len - 2;
for (int i = index_before_newline; i >= 0; --i)
to[index_before_newline - i] = from[i];
to[index_before_newline + 1] = '\n';
to[index_before_newline + 2] = '\0';
}
|
the_stack_data/90766244.c | #include <stdio.h>
#include <stdlib.h>
int main(){
float quali, nvenda, negativas;
printf("---------------------------------------");
printf("\nPROGRAMA PARA SIMULAR EXITO EM COMPRA");
printf("\nEntre com o numero de vendas: ");
scanf("%f",&nvenda);
printf("\nEntre com o numero de negativas: ");
scanf("%f",&negativas);
quali=(negativas+1)/nvenda;
printf("\nA probabilidade de uma boa compra pode variar %.2f% em cima da qualificacao atual", quali);
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.