// chebysheve outlier detection // this function is used to detect the abnormal value among a set of data // input: // delta: a set of data // FLAG: discribe which data is already known as outlier // p: restrict level // output: // double[] door : byyond which the data may be considered as a outlier // door[0]: the upperdoor // door[1]: the lowerdoor
标签: chebysheve detection abnormal function
上传时间: 2013-11-30
上传用户:13517191407
该工具用Delphi7写的,可帮助我们生成一些插入语句。 例如: 现要向一台机(P2)的数据库(以HR为例)插入另一台机(P1)的HR_New_Info记录,可如下操作: 1.输入P1的IP,用户名,密码。数据库输入“HR” 2.在查询语句输入 select Title,Content,TypeName,FLAG,DateAndTime from HR_New_Info 3.在插入语句输入 insert into HR_New_Info(Title,Content,TypeName,FLAG,DateAndTime) 4.点击生成语句,可生成如下语句: insert into HR_New_Info(Title,Content,TypeName,FLAG,DateAndTime) values( 政府招聘网上报名系统投入使用 , , 新闻资信 ,True, 2008-9-30 ) insert into HR_New_Info(Title,Content,TypeName,FLAG,DateAndTime) values( 防洪防汛工作顺利完成 , , 新闻资信 ,True, 2008-9-15 ) 注,语句暂时只能保存为.sql文件
标签: Delphi7
上传时间: 2017-01-22
上传用户:zxc23456789
哲学家吃饭问题 当五个人都拿到左手边筷子,都等待拿右手边筷子,则因为谁都不能放下手中的筷子,这样就进入无止境的等待,构成死锁 * 解决方法1:奇数号先拿左边的筷子,偶数号先拿右边的筷子,即相邻两个人先拿其中间夹的筷子,使这个筷子成为临界资源; * 解决方法2:两边的筷子都空闲时,再拿筷子,if(chopstick.FLAG(n)==false&&chopstick.FLAG(n 5)==false); * 解决方法3:只允许(n-1)个人同时进餐; * 本程序采用方法1 解决
标签: 家
上传时间: 2017-05-27
上传用户:zsjzc
un the configuration script ---------------------------- In the CGIs directory there is a configure.s and a configure.bat file. Run this file after you ve moved the CGIs directory to it s desired location. The configure script will create a file nammed apache.conf. Append this file the the httpd.conf file. LINUX: [prompt]$ ./configure.s [prompt]$ cat apache.conf >> /etc/httpd/conf/httpd.conf Note: you may need to set the executable FLAG on the script chmod 755 configure.s WINDOWS: prompt> configure.bat Copy the contents of apache.conf to httpd.conf
标签: configuration the directory config
上传时间: 2014-01-25
上传用户:heart520beat
Main program running when workpiece is ready on deferent belt(deferent_ready=ture). * Call Square_Wave subroutine to generate 0.5ms square wave on P1.2 to drive * electromotor,then drive deferent belt step forward. When it steps to the measure * zone, it stops to be measured. Then call A_D subroutine to transform analog * signals to digital signals , after then call serial subroutine to transfer * digital signals to PC. Call square wave subroutine to drive deferent belt step to * original position waitting for defere ready FLAG to run the next circle.
标签: deferent_ready workpiece deferent program
上传时间: 2017-08-31
上传用户:baiom
两个链表的交集 #include<stdio.h> #include<stdlib.h> typedef struct Node{ int data; struct Node *next; }Node; void initpointer(struct Node *p){ p=NULL; } int printlist(struct Node* head){ int FLAG=1; head=head->next; /* 因为标记1的地方你用了头结点,所以第一个数据域无效,应该从下一个头元结点开始 */ if(head==NULL) printf("NULL\n"); else { while(head!=NULL) { if(FLAG==1) { printf("%d",head->data); FLAG=0; } else { printf(" %d",head->data); } head=head->next; } printf("\n"); } return 0; } struct Node *creatlist(struct Node *head) { int n; struct Node *p1=(struct Node *)malloc(sizeof(struct Node)); p1->next=NULL; while(scanf("%d",&n),n!=-1) { struct Node *pnode=(struct Node *)malloc(sizeof(struct Node)); pnode->next=NULL; pnode->data=n; if(head==NULL) head=pnode; p1->next=pnode; p1=pnode; } return head; } struct Node *Intersect(struct Node *head1, struct Node *head2) { struct Node *p1=head1,*p2=head2;/*我这里没有用头指针和头结点,这里是首元结点head1里面就是第一个数据,一定要理解什么事头指针, 头结点,和首元结点 具体你一定要看这个博客:http://blog.sina.com.cn/s/blog_71e7e6fb0101lipz.html*/ struct Node *head,*p,*q; head = (struct Node *)malloc(sizeof(struct Node)); head->next = NULL; p = head; while( (p1!=NULL)&&(p2!=NULL) ) { if (p1->data == p2->data) { q = (struct Node *)malloc(sizeof(struct Node)); q->data = p1->data; q->next = NULL; p->next = q;//我可以认为你这里用了头结点,也就是说第一个数据域无效 **标记1** p = q; p1 = p1->next; p2 = p2->next; } else if (p1->data < p2->data) { p1 = p1->next; } else { p2 = p2->next; } } return head; } int main() { struct Node *head=NULL,*headt=NULL,*t; //initpointer(head);//这里的函数相当于head=NULL; // initpointer(headt);//上面已经写了headt=NULL那么这里可以不用调用这个函数 head=creatlist(head); headt=creatlist(headt); t=Intersect(head,headt); printlist(t); }
标签: c语言编程
上传时间: 2015-04-27
上传用户:coco2017co
/* ********************************************************************************************************* * uC/TCP-IP V2 * The Embedded TCP/IP Suite * * (c) Copyright 2003-2010; Micrium, Inc.; Weston, FL * * All rights reserved. Protected by international copyright laws. * * uC/TCP-IP is provided in source form to registered licensees ONLY. It is * illegal to distribute this source code to any third party unless you receive * written permission by an authorized Micrium representative. Knowledge of * the source code may NOT be used to develop a similar product. * * Please help us continue to provide the Embedded community with the finest * software available. Your honesty is greatly appreciated. * * You can contact us at www.micrium.com. ********************************************************************************************************* */ /* ********************************************************************************************************* * * NETWORK TCP LAYER * (TRANSMISSION CONTROL PROTOCOL) * * Filename : net_tcp.h * Version : V2.10 * Programmer(s) : ITJ ********************************************************************************************************* * Note(s) : (1) Supports Transmission Control Protocol as described in RFC #793 with the following * restrictions/constraints : * * (a) TCP Security & Precedence NOT supported RFC # 793, Section 3.6 * * (b) TCP Urgent Data NOT supported RFC # 793, Section 3.7 * 'The Communication of * Urgent Information' * * (c) The following TCP options NOT supported : * * (1) Window Scale RFC #1072, Section 2 * RFC #1323, Section 2 * (2) Selective Acknowledgement (SACK) RFC #1072, Section 3 * RFC #2018 * RFC #2883 * (3) TCP Echo RFC #1072, Section 4 * (4) Timestamp RFC #1323, Section 3.2 * (5) Protection Against Wrapped Sequences (PAWS) RFC #1323, Section 4 * * (d) #### IP-Options-to-TCP-Connection RFC #1122, Section 4.2.3.8 * Handling NOT supported * * (e) #### ICMP-Error-Message-to-TCP-Connection RFC #1122, Section 4.2.3.9 * Handling NOT currently supported * * (2) TCP Layer assumes/requires Network Socket Layer (see 'net_sock.h MODULE Note #1a2'). ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * MODULE * * Note(s) : (1) TCP Layer module is NOT required for UDP-to-Application API configuration. * * See also 'net_cfg.h TRANSPORT LAYER CONFIGURATION' * & 'net_cfg.h USER DATAGRAM PROTOCOL LAYER CONFIGURATION'. * * See also 'net_tcp.h Note #2'. * * (2) The following TCP-module-present configuration value MUST be pre-#define'd in * 'net_cfg_net.h' PRIOR to all other network modules that require TCP Layer * configuration (see 'net_cfg_net.h TCP LAYER CONFIGURATION Note #2b') : * * NET_TCP_MODULE_PRESENT ********************************************************************************************************* */ #ifdef NET_TCP_MODULE_PRESENT /* See Note #2. */ /* ********************************************************************************************************* * EXTERNS ********************************************************************************************************* */ #if ((defined(NET_TCP_MODULE)) && \ (defined(NET_GLOBALS_EXT))) #define NET_TCP_EXT #else #define NET_TCP_EXT extern #endif /*$PAGE*/ /* ********************************************************************************************************* * DEFINES ********************************************************************************************************* */ /* ********************************************************************************************************* * TCP HEADER DEFINES * * Note(s) : (1) The following TCP value MUST be pre-#define'd in 'net_def.h' PRIOR to 'net_buf.h' so that * the Network Buffer Module can configure maximum buffer header size (see 'net_def.h TCP * LAYER DEFINES' & 'net_buf.h NETWORK BUFFER INDEX & SIZE DEFINES Note #1') : * * (a) NET_TCP_HDR_SIZE_MAX 60 (NET_TCP_HDR_LEN_MAX * * NET_TCP_HDR_LEN_WORD_SIZE) * * (2) Urgent pointer & data NOT supported (see 'net_tcp.h Note #1b'). ********************************************************************************************************* */ #define NET_TCP_HDR_LEN_MASK 0xF000u #define NET_TCP_HDR_LEN_SHIFT 12u #define NET_TCP_HDR_LEN_NONE 0u #define NET_TCP_HDR_LEN_MIN 5u #define NET_TCP_HDR_LEN_MAX 15u #define NET_TCP_HDR_LEN_WORD_SIZE CPU_WORD_SIZE_32 #define NET_TCP_HDR_SIZE_MIN (NET_TCP_HDR_LEN_MIN * NET_TCP_HDR_LEN_WORD_SIZE) #if 0 /* See Note #1a. */ #define NET_TCP_HDR_SIZE_MAX (NET_TCP_HDR_LEN_MAX * NET_TCP_HDR_LEN_WORD_SIZE) #endif #define NET_TCP_HDR_SIZE_TOT_MIN (NET_IP_HDR_SIZE_TOT_MIN + NET_TCP_HDR_SIZE_MIN) #define NET_TCP_HDR_SIZE_TOT_MAX (NET_IP_HDR_SIZE_TOT_MAX + NET_TCP_HDR_SIZE_MAX) #define NET_TCP_PSEUDO_HDR_SIZE 12u /* = sizeof(NET_TCP_PSEUDO_HDR) */ #define NET_TCP_PORT_NBR_RESERVED NET_PORT_NBR_RESERVED #define NET_TCP_PORT_NBR_NONE NET_TCP_PORT_NBR_RESERVED #define NET_TCP_HDR_URG_PTR_NONE 0x0000u /* See Note #2. */ /*$PAGE*/ /* ********************************************************************************************************* * TCP HEADER FLAG DEFINES * * Note(s) : (1) See 'TCP HEADER Note #2' for FLAG fields. * * (2) Urgent pointer & data NOT supported (see 'net_tcp.h Note #1b'). ********************************************************************************************************* */ #define NET_TCP_HDR_FLAG_MASK 0x0FFFu #define NET_TCP_HDR_FLAG_NONE DEF_BIT_NONE #define NET_TCP_HDR_FLAG_RESERVED 0x0FE0u /* MUST be '0'. */ #define NET_TCP_HDR_FLAG_URGENT DEF_BIT_05 /* See Note #2. */ #define NET_TCP_HDR_FLAG_ACK DEF_BIT_04 #define NET_TCP_HDR_FLAG_PUSH DEF_BIT_03 #define NET_TCP_HDR_FLAG_RESET DEF_BIT_02 #define NET_TCP_HDR_FLAG_SYNC DEF_BIT_01 #define NET_TCP_HDR_FLAG_FIN DEF_BIT_00 #define NET_TCP_HDR_FLAG_CLOSE NET_TCP_HDR_FLAG_FIN /* ********************************************************************************************************* * TCP FLAG DEFINES ********************************************************************************************************* */ /* ------------------ NET TCP FLAGS ------------------- */ #define NET_TCP_FLAG_NONE DEF_BIT_NONE #define NET_TCP_FLAG_USED DEF_BIT_00 /* TCP conn cur used; i.e. NOT in free TCP conn pool. */ /* ------------------ TCP TX FLAGS ------------------- */ /* TCP tx FLAGs copied from TCP hdr FLAGs. */ #define NET_TCP_FLAG_TX_FIN NET_TCP_HDR_FLAG_FIN #define NET_TCP_FLAG_TX_CLOSE NET_TCP_FLAG_TX_FIN #define NET_TCP_FLAG_TX_SYNC NET_TCP_HDR_FLAG_SYNC #define NET_TCP_FLAG_TX_RESET NET_TCP_HDR_FLAG_RESET #define NET_TCP_FLAG_TX_PUSH NET_TCP_HDR_FLAG_PUSH #define NET_TCP_FLAG_TX_ACK NET_TCP_HDR_FLAG_ACK #define NET_TCP_FLAG_TX_URGENT NET_TCP_HDR_FLAG_URGENT #define NET_TCP_FLAG_TX_BLOCK DEF_BIT_07 /* ------------------ TCP RX FLAGS ------------------- */ #define NET_TCP_FLAG_RX_DATA_PEEK DEF_BIT_08 #define NET_TCP_FLAG_RX_BLOCK DEF_BIT_15 /*$PAGE*/ /* ********************************************************************************************************* * TCP TYPE DEFINES * * Note(s) : (1) NET_TCP_TYPE_&&& #define values specifically chosen as ASCII representations of the TCP * types. Memory displays of TCP types will display with their chosen ASCII names. ********************************************************************************************************* */ /* ------------------ NET TCP TYPES ------------------- */ #if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG) #define NET_TCP_TYPE_NONE 0x4E4F4E45u /* "NONE" in ASCII. */ #define NET_TCP_TYPE_CONN 0x54435020u /* "TCP " in ASCII. */ #else #if (CPU_CFG_DATA_SIZE == CPU_WORD_SIZE_32) #define NET_TCP_TYPE_NONE 0x454E4F4Eu /* "NONE" in ASCII. */ #define NET_TCP_TYPE_CONN 0x20504354u /* "TCP " in ASCII. */ #elif (CPU_CFG_DATA_SIZE == CPU_WORD_SIZE_16) #define NET_TCP_TYPE_NONE 0x4F4E454Eu /* "NONE" in ASCII. */ #define NET_TCP_TYPE_CONN 0x43542050u /* "TCP " in ASCII. */ #else /* Dflt CPU_WORD_SIZE_08. */ #define NET_TCP_TYPE_NONE 0x4E4F4E45u /* "NONE" in ASCII. */ #define NET_TCP_TYPE_CONN 0x54435020u /* "TCP " in ASCII. */ #endif #endif /* ********************************************************************************************************* * TCP SEQUENCE NUMBER DEFINES * * Note(s) : (1) TCP initial transmit sequence number is incremented by a fixed value, preferably a large * prime value or a large value with multiple unique factors. * * (a) One reasonable TCP initial transmit sequence number increment value example : * * 65527 = 37 * 23 * 11 * 7 * * * #### NET_TCP_TX_SEQ_NBR_CTR_INC could be developer-configured in 'net_cfg.h'. * * See also 'NET_TCP_TX_GET_SEQ_NBR() Notes #1b2 & #1c2'. ********************************************************************************************************* */ #define NET_TCP_SEQ_NBR_NONE 0u #define NET_TCP_ACK_NBR_NONE NET_TCP_SEQ_NBR_NONE #define NET_TCP_TX_SEQ_NBR_CTR_INC 65527u /* See Note #1. */ #define NET_TCP_ACK_NBR_DUP_WIN_SIZE_SCALE 4 /*$PAGE*/ /* ********************************************************************************************************* * TCP DATA/TOTAL LENGTH DEFINES * * Note(s) : (1) (a) TCP total length #define's (NET_TCP_TOT_LEN) relate to the total size of a complete * TCP packet, including the packet's TCP header. Note that a complete TCP packet MAY * be fragmented in multiple Internet Protocol packets. * * (b) TCP data length #define's (NET_TCP_DATA_LEN) relate to the data size of a complete * TCP packet, equal to the total TCP packet length minus its TCP header size. Note * that a complete TCP packet MAY be fragmented in multiple Internet Protocol packets. ********************************************************************************************************* */ /* See Notes #1a & #1b. */ #define NET_TCP_DATA_LEN_MIN 0u #define NET_TCP_TOT_LEN_MIN (NET_TCP_HDR_SIZE_MIN + NET_TCP_DATA_LEN_MIN) #define NET_TCP_TOT_LEN_MAX (NET_IP_TOT_LEN_MAX - NET_IP_HDR_SIZE_MIN ) #define NET_TCP_DATA_LEN_MAX (NET_TCP_TOT_LEN_MAX - NET_TCP_HDR_SIZE_MIN) /*$PAGE*/ /* ********************************************************************************************************* * TCP SEGMENT SIZE DEFINES * * Note(s) : (1) (a) RFC # 879, Section 3 states that the TCP Maximum Segment Size "counts only * data octets in the segment, ... not the TCP header or the IP header". * * (b) RFC #1122, Section 4.2.2.6 requires that : * * (1) "The MSS value to be sent in an MSS option must be less than or equal to * * (A) MMS_R - 20 * * where MMS_R is the maximum size for a transport-layer message that can * be received." * * (2) "If an MSS option is not received at connection setup, TCP MUST assume a * default send MSS of 536 (576 - 40)." * * See also 'net_ip.h IP DATA/TOTAL LENGTH DEFINES Note #1'. ********************************************************************************************************* */ /* See Note #1. */ #define NET_TCP_MAX_SEG_SIZE_DFLT (NET_IP_MAX_DATAGRAM_SIZE_DFLT - NET_IP_HDR_SIZE_MIN - NET_TCP_HDR_SIZE_MIN) #define NET_TCP_MAX_SEG_SIZE_DFLT_RX NET_TCP_DATA_LEN_MAX /* See Note #1b1. */ #define NET_TCP_MAX_SEG_SIZE_DFLT_TX NET_TCP_MAX_SEG_SIZE_DFLT /* See Note #1b2. */ #define NET_TCP_MAX_SEG_SIZE_NONE 0u #define NET_TCP_MAX_SEG_SIZE_MIN NET_TCP_MAX_SEG_SIZE_DFLT #define NET_TCP_MAX_SEG_SIZE_MAX NET_TCP_DATA_LEN_MAX #define NET_TCP_SEG_LEN_MIN NET_TCP_DATA_LEN_MIN #define NET_TCP_SEG_LEN_MAX NET_TCP_DATA_LEN_MAX #define NET_TCP_SEG_LEN_SYNC 1u #define NET_TCP_SEG_LEN_FIN 1u #define NET_TCP_SEG_LEN_CLOSE NET_TCP_SEG_LEN_FIN #define NET_TCP_SEG_LEN_ACK 0u #define NET_TCP_SEG_LEN_RESET 0u #define NET_TCP_SEG_LEN_PROBE 0u #define NET_TCP_DATA_LEN_TX_SYNC 0u #define NET_TCP_DATA_LEN_TX_FIN 0u #define NET_TCP_DATA_LEN_TX_CLOSE NET_TCP_DATA_LEN_TX_FIN #define NET_TCP_DATA_LEN_TX_ACK 0u #define NET_TCP_DATA_LEN_TX_PROBE_NO_DATA 0u #define NET_TCP_DATA_LEN_TX_PROBE_DATA 1u #define NET_TCP_DATA_LEN_TX_RESET 0u #define NET_TCP_TX_PROBE_DATA 0x00u /* ********************************************************************************************************* * TCP WINDOW SIZE DEFINES * * Note(s) : (1) Although NO RFC specifies the absolute minimum TCP connection window size value allowed, * RFC #793, Section 3.7 'Data Communication : Managing the Window' states that for "the * window ... there is an assumption that this is related to the currently available data * buffer space available for this connection". ********************************************************************************************************* */ #define NET_TCP_WIN_SIZE_NONE 0u #define NET_TCP_WIN_SIZE_MIN NET_TCP_MAX_SEG_SIZE_MIN #define NET_TCP_WIN_SIZE_MAX DEF_INT_16U_MAX_VAL /*$PAGE*/ /* ********************************************************************************************************* * TCP HEADER OPTIONS DEFINES * * Note(s) : (1) See the following RFC's for TCP options summary : * * (a) RFC # 793, Section 3.1 'Header Format : Options' * (b) RFC #1122; Sections 4.2.2.5, 4.2.2.6 * * (2) TCP option types are encoded in the first octet for each TCP option as follows : * * -------- * | TYPE | * -------- * * The TCP option type value determines the TCP option format : * * (a) The following TCP option types are single-octet TCP options -- i.e. the option type * octet is the ONLY octet for the TCP option. * * (1) TYPE = 0 End of Options List * (2) TYPE = 1 No Operation * * * (b) All other TCP options MUST be multi-octet TCP options (see RFC #1122, Section 4.2.2.5) : * * ------------------------------ * | TYPE | LEN | TCP OPT | * ------------------------------ * * where * TYPE Indicates the specific TCP option type * LEN Indicates the total TCP option length, in octets, including * the option type & the option length octets * TCP OPT Additional TCP option octets, if any, that contain the remaining * TCP option information * * The following TCP option types are multi-octet TCP options where the option's second * octet specify the total TCP option length, in octets, including the option type & the * option length octets : * * (1) TYPE = 2 Maximum Segment Size See RFC # 793, Section 3.1 'Header Format : * Options : Maximum Segment Size'; * RFC #1122, Section 4.2.2.6; * RFC # 879, Section 3 * * (2) TYPE = 3 Window Scale See 'net_tcp.h Note #1c1' * (3) TYPE = 4 SACK Allowed See 'net_tcp.h Note #1c2' * (4) TYPE = 5 SACK Option See 'net_tcp.h Note #1c2' * (5) TYPE = 6 Echo Request See 'net_tcp.h Note #1c3' * (6) TYPE = 7 Echo Reply See 'net_tcp.h Note #1c3' * (7) TYPE = 8 Timestamp See 'net_tcp.h Note #1c4' * * (3) TCP header allows for a maximum option list length of 40 octets : * * NET_TCP_HDR_OPT_SIZE_MAX = NET_TCP_HDR_SIZE_MAX - NET_TCP_HDR_SIZE_MIN * * = 60 - 20 * * = 40 * * (4) 'NET_TCP_OPT_SIZE' MUST be pre-defined PRIOR to all definitions that require TCP option * size data type. ********************************************************************************************************* */ /*$PAGE*/ #define NET_TCP_HDR_OPT_END_LIST 0u #define NET_TCP_HDR_OPT_NOP 1u #define NET_TCP_HDR_OPT_MAX_SEG_SIZE 2u #define NET_TCP_HDR_OPT_WIN_SCALE 3u #define NET_TCP_HDR_OPT_SACK_PERMIT 4u #define NET_TCP_HDR_OPT_SACK 5u #define NET_TCP_HDR_OPT_ECHO_REQ 6u #define NET_TCP_HDR_OPT_ECHO_REPLY 7u #define NET_TCP_HDR_OPT_TS 8u #define NET_TCP_HDR_OPT_PAD NET_TCP_HDR_OPT_END_LIST #define NET_TCP_HDR_OPT_LEN_END_LIST 1u #define NET_TCP_HDR_OPT_LEN_NOP 1u #define NET_TCP_HDR_OPT_LEN_MAX_SEG_SIZE 4u #define NET_TCP_HDR_OPT_LEN_WIN_SCALE 3u #define NET_TCP_HDR_OPT_LEN_SACK_PERMIT 2u #define NET_TCP_HDR_OPT_LEN_ECHO_REQ 6u #define NET_TCP_HDR_OPT_LEN_ECHO_REPLY 6u #define NET_TCP_HDR_OPT_LEN_TS 10u #define NET_TCP_HDR_OPT_LEN_SACK_MIN 6u #define NET_TCP_HDR_OPT_LEN_SACK_MAX 38u #define NET_TCP_HDR_OPT_LEN_MIN 1u #define NET_TCP_HDR_OPT_LEN_MIN_LEN 2u #define NET_TCP_HDR_OPT_LEN_MAX 38u typedef CPU_INT32U NET_TCP_OPT_SIZE; /* TCP opt size data type (see Note #4). */ #define NET_TCP_HDR_OPT_SIZE_WORD (sizeof(NET_TCP_OPT_SIZE)) #define NET_TCP_HDR_OPT_SIZE_MAX (NET_TCP_HDR_SIZE_MAX - NET_TCP_HDR_SIZE_MIN) #define NET_TCP_HDR_OPT_NBR_MIN 0u #define NET_TCP_HDR_OPT_NBR_MAX (NET_TCP_HDR_OPT_SIZE_MAX / NET_TCP_HDR_OPT_SIZE_WORD) #define NET_TCP_HDR_OPT_IX NET_TCP_HDR_SIZE_MIN /*$PAGE*/ /* ********************************************************************************************************* * TCP OPTION CONFIGURATION TYPE DEFINES * * Note(s) : (1) NET_TCP_OPT_CFG_TYPE_&&& #define values specifically chosen as ASCII representations of * the TCP option configuration types. Memory displays of TCP option configuration buffers * will display the TCP option configuration TYPEs with their chosen ASCII names. ********************************************************************************************************* */ /* ---------------- TCP OPT CFG TYPES ----------------- */ #if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG) #define NET_TCP_OPT_CFG_TYPE_NONE 0x4E4F4E45u /* "NONE" in ASCII. */ #define NET_TCP_OPT_CFG_TYPE_MAX_SEG_SIZE 0x4D535320u /* "MSS " in ASCII. */ #define NET_TCP_OPT_CFG_TYPE_WIN_SCALE 0x57494E20u /* "WIN " in ASCII (see 'net_tcp.h Note #1c1'). */ #define NET_TCP_OPT_CFG_TYPE_SACK_PERMIT 0x53434B50u /* "SCKP" in ASCII (see 'net_tcp.h Note #1c2'). */ #define NET_TCP_OPT_CFG_TYPE_SACK 0x5341434Bu /* "SACK" in ASCII (see 'net_tcp.h Note #1c2'). */ #define NET_TCP_OPT_CFG_TYPE_ECHO_REQ 0x45524551u /* "EREQ" in ASCII (see 'net_tcp.h Note #1c3'). */ #define NET_TCP_OPT_CFG_TYPE_ECHO_REPLY 0x4543484Fu /* "ECHO" in ASCII (see 'net_tcp.h Note #1c3'). */ #define NET_TCP_OPT_CFG_TYPE_TS 0x54532020u /* "TS " in ASCII (see 'net_tcp.h Note #1c4'). */ #else #if (CPU_CFG_DATA_SIZE == CPU_WORD_SIZE_32) #define NET_TCP_OPT_CFG_TYPE_NONE 0x454E4F4Eu /* "NONE" in ASCII. */ #define NET_TCP_OPT_CFG_TYPE_MAX_SEG_SIZE 0x2053534Du /* "MSS " in ASCII. */ #define NET_TCP_OPT_CFG_TYPE_WIN_SCALE 0x204E4957u /* "WIN " in ASCII (see 'net_tcp.h Note #1c1'). */ #define NET_TCP_OPT_CFG_TYPE_SACK_PERMIT 0x504B4353u /* "SCKP" in ASCII (see 'net_tcp.h Note #1c2'). */ #define NET_TCP_OPT_CFG_TYPE_SACK 0x4B434153u /* "SACK" in ASCII (see 'net_tcp.h Note #1c2'). */ #define NET_TCP_OPT_CFG_TYPE_ECHO_REQ 0x51455245u /* "EREQ" in ASCII (see 'net_tcp.h Note #1c3'). */ #define NET_TCP_OPT_CFG_TYPE_ECHO_REPLY 0x4F484345u /* "ECHO" in ASCII (see 'net_tcp.h Note #1c3'). */ #define NET_TCP_OPT_CFG_TYPE_TS 0x20205354u /* "TS " in ASCII (see 'net_tcp.h Note #1c4'). */ #elif (CPU_CFG_DATA_SIZE == CPU_WORD_SIZE_16) #define NET_TCP_OPT_CFG_TYPE_NONE 0x4F4E454Eu /* "NONE" in ASCII. */ #define NET_TCP_OPT_CFG_TYPE_MAX_SEG_SIZE 0x534D2053u /* "MSS " in ASCII. */ #define NET_TCP_OPT_CFG_TYPE_WIN_SCALE 0x4957204Eu /* "WIN " in ASCII (see 'net_tcp.h Note #1c1'). */ #define NET_TCP_OPT_CFG_TYPE_SACK_PERMIT 0x4353504Bu /* "SCKP" in ASCII (see 'net_tcp.h Note #1c2'). */ #define NET_TCP_OPT_CFG_TYPE_SACK 0x41534B43u /* "SACK" in ASCII (see 'net_tcp.h Note #1c2'). */ #define NET_TCP_OPT_CFG_TYPE_ECHO_REQ 0x52455145u /* "EREQ" in ASCII (see 'net_tcp.h Note #1c3'). */ #define NET_TCP_OPT_CFG_TYPE_ECHO_REPLY 0x43454F48u /* "ECHO" in ASCII (see 'net_tcp.h Note #1c3'). */ #define NET_TCP_OPT_CFG_TYPE_TS 0x53542020u /* "TS " in ASCII (see 'net_tcp.h Note #1c4'). */ #else /* Dflt CPU_WORD_SIZE_08. */ #define NET_TCP_OPT_CFG_TYPE_NONE 0x4E4F4E45u /* "NONE" in ASCII. */ #define NET_TCP_OPT_CFG_TYPE_MAX_SEG_SIZE 0x4D535320u /* "MSS " in ASCII. */ #define NET_TCP_OPT_CFG_TYPE_WIN_SCALE 0x57494E20u /* "WIN " in ASCII (see 'net_tcp.h Note #1c1'). */ #define NET_TCP_OPT_CFG_TYPE_SACK_PERMIT 0x53434B50u /* "SCKP" in ASCII (see 'net_tcp.h Note #1c2'). */ #define NET_TCP_OPT_CFG_TYPE_SACK 0x5341434Bu /* "SACK" in ASCII (see 'net_tcp.h Note #1c2'). */ #define NET_TCP_OPT_CFG_TYPE_ECHO_REQ 0x45524551u /* "EREQ" in ASCII (see 'net_tcp.h Note #1c3'). */ #define NET_TCP_OPT_CFG_TYPE_ECHO_REPLY 0x4543484Fu /* "ECHO" in ASCII (see 'net_tcp.h Note #1c3'). */ #define NET_TCP_OPT_CFG_TYPE_TS 0x54532020u /* "TS " in ASCII (see 'net_tcp.h Note #1c4'). */ #endif #endif /*$PAGE*/ /* ********************************************************************************************************* * TCP CONNECTION TIMEOUT DEFINES * * Note(s) : (1) (a) (1) RFC #1122, Section 4.2.2.13 'DISCUSSION' states that "the graceful close algorithm * of TCP requires that the connection state remain defined on (at least) one end of * the connection, for a timeout period of 2xMSL ... During this period, the (remote * socket, local socket) pair that defines the connection is busy and cannot be reused". * * (2) The following sections reiterate that the TIME-WAIT state timeout scalar is two * maximum segment lifetimes (2 MSL) : * * (A) RFC #793, Section 3.9 'Event Processing : SEGMENT ARRIVES : * Check Sequence Number : TIME-WAIT STATE' * (B) RFC #793, Section 3.9 'Event Processing : SEGMENT ARRIVES : * Check FIN Bit : TIME-WAIT STATE' * * (b) (1) RFC #793, Section 3.3 'Sequence Numbers : Knowing When to Keep Quiet' states that * "the Maximum Segment Lifetime (MSL) is ... to be 2 minutes. This is an engineering * choice, and may be changed if experience indicates it is desirable to do so". * * (2) Microsoft Corporation's Windows XP defaults MSL to 15 seconds. ********************************************************************************************************* */ /* Max seg timeout (see Note #1b) : */ #define NET_TCP_CONN_TIMEOUT_MAX_SEG_MIN_SEC ( 0u ) /* ... min = 0 seconds */ #define NET_TCP_CONN_TIMEOUT_MAX_SEG_MAX_SEC ( 2u * DEF_TIME_NBR_SEC_PER_MIN) /* ... max = 2 minutes */ #define NET_TCP_CONN_TIMEOUT_MAX_SEG_DFLT_SEC ( 15u ) /* ... dflt = 15 seconds */ #define NET_TCP_CONN_TIMEOUT_MAX_SEG_SCALAR 2u /* ... scalar (see Note #1a). */ #define NET_TCP_CONN_TIMEOUT_CONN_DFLT_SEC (120u * DEF_TIME_NBR_SEC_PER_MIN) /* Dflt conn timeout = 120 minutes */ #define NET_TCP_CONN_TIMEOUT_USER_DFLT_SEC ( 30u * DEF_TIME_NBR_SEC_PER_MIN) /* Dflt user timeout = 30 minutes */ /*$PAGE*/ /* ********************************************************************************************************* * TCP CONNECTION STATES * * Note(s) : (1) See the following RFC's for TCP state machine summary : * * (a) RFC # 793; Sections 3.2, 3.4, 3.5, 3.9 * (b) RFC #1122; Sections 4.2.2.8, 4.2.2.10, 4.2.2.11, 4.2.2.13, 4.2.2.18, 4.2.2.20 * * (2) (a) #### Additional closing-data-available state used for closing connections to allow the * application layer to receive any remaining data. * * See also 'net_tcp.c NetTCP_RxPktConnHandlerFinWait1() Note #2f5A2', * 'net_tcp.c NetTCP_RxPktConnHandlerFinWait2() Note #2f5B', * 'net_tcp.c NetTCP_RxPktConnHandlerClosing() Note #2d2B2a1B', * & 'net_tcp.c NetTCP_RxPktConnHandlerLastAck() Note #2d2A1b'. ********************************************************************************************************* */ #define NET_TCP_CONN_STATE_NONE 0u #define NET_TCP_CONN_STATE_FREE 1u #define NET_TCP_CONN_STATE_CLOSED 10u #define NET_TCP_CONN_STATE_LISTEN 20u #define NET_TCP_CONN_STATE_SYNC_RXD 30u #define NET_TCP_CONN_STATE_SYNC_RXD_PASSIVE 31u #define NET_TCP_CONN_STATE_SYNC_RXD_ACTIVE 32u #define NET_TCP_CONN_STATE_SYNC_TXD 35u #define NET_TCP_CONN_STATE_CONN 40u #define NET_TCP_CONN_STATE_FIN_WAIT_1 50u #define NET_TCP_CONN_STATE_FIN_WAIT_2 51u #define NET_TCP_CONN_STATE_CLOSING 52u #define NET_TCP_CONN_STATE_TIME_WAIT 53u #define NET_TCP_CONN_STATE_CLOSE_WAIT 55u #define NET_TCP_CONN_STATE_LAST_ACK 56u #define NET_TCP_CONN_STATE_CLOSING_DATA_AVAIL 59u /* See Note #2a. */ /* ********************************************************************************************************* * TCP CONNECTION QUEUE STATES ********************************************************************************************************* */ #define NET_TCP_RX_Q_STATE_NONE 0u #define NET_TCP_RX_Q_STATE_CLOSED 100u #define NET_TCP_RX_Q_STATE_CLOSING 101u #define NET_TCP_RX_Q_STATE_SYNC 110u #define NET_TCP_RX_Q_STATE_CONN 111u #define NET_TCP_TX_Q_STATE_NONE 0u #define NET_TCP_TX_Q_STATE_CLOSED 200u #define NET_TCP_TX_Q_STATE_CLOSING 201u #define NET_TCP_TX_Q_STATE_SYNC 210u #define NET_TCP_TX_Q_STATE_CONN 211u #define NET_TCP_TX_Q_STATE_SUSPEND 215u #define NET_TCP_TX_Q_STATE_CLOSED_SUSPEND 220u #define NET_TCP_TX_Q_STATE_CLOSING_SUSPEND 221u /*$PAGE*/ /* ********************************************************************************************************* * TCP CONNECTION CODE DEFINES **************
上传时间: 2015-11-22
上传用户:the same kong
/**************************************************************** 外部晶振8M PA0~3:四位数码管的位选 PB0~7:数码管的8位段选 外部中断0用于计数 定时器0溢出中断的定时为1ms 说明 :检测到水流较小时,继电器延时1秒关闭 ******************************************************************/ #include<iom16v.h> #include<macros.h> #define uchar unsigned char #define uint unsigned int char led_7[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F}; //数码管段选 char position[4]={0xfe,0xfd,0xfb,0xf7};//数码管位选 uint sumnum=0; //用于记录1000ms内进入中断的次数 uint time=0; //记录进入比较定时器0的次数 uint num=0; //记录1ms内进入中断的次数 uint count=0; //进入外部中断0的次数 uchar FLAG; uint sumnum1; //记录100ms内的数目 /***************************函数声明***************************/ void delay(); void display(uint m ); void init(); void init_0(); void init_2(); void _delay_us(uint l) { unsigned int i; for(i=0;i<l;i++) { asm("nop"); } } /**************************主函数***********************************/ void main() { init(); init_0(); init_2(); while(sumnum<5) { PORTD=0XBF; segdisplay(sumnum1); } while(1) { segdisplay(sumnum1); } } /*************************扫描数码管时的延时函数*********************/ void delay() { uchar i,j; for(i=6;i>0;i--) for(j=225;j>0;j--); } /************************数码管显示函数*****************************/ void segdisplay( int temp) { int seg[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; int temp1,temp2,temp3,temp4; temp1=temp/1000; temp2=(temp/100)%10; temp3=(temp/10)%10; temp4=temp%10; DDRB=0xff; DDRA|=0x0f; PORTA=~BIT(3); PORTB=seg[temp1]; _delay_us(100); PORTA=~BIT(2); PORTB=seg[temp2]; _delay_us(100); PORTA=~BIT(1); PORTB=seg[temp3]; _delay_us(100); PORTA=~BIT(0); PORTB=seg[temp4]; _delay_us(100); } /***********************管脚初始化函数*********************/ void init() { DDRD|=0X40; //PD4 设置为输出 PORTD=0XBF; DDRA=0XFF; DDRB=0XFF; PORTA=0XFF; PORTB=0XFF; } /***********************外部中断0初始化*********************/ void init_0() { MCUCR=0X02; //INT0为下降沿触发 GICR=0X40; //使能INT0中断 SREG=0X80; //使能总中断 } /**********************定时器2初始化***********************/ void init_2() { TCCR0=0x03; // 内部时钟,64 分频(8M/64=125KHz) TCNT0=0x83; //装初值 TIMSK=0x01; // 允许 T/C0溢出中断中断 } /***********************外部中断0子函数********************/ #pragma interrupt_handler int0_isr:2 void int0_isr(void) { count++; } /*********************定时计数器0溢出中断子函数*****************/ #pragma interrupt_handler int0_over:10 void int0_over(void) { TCNT0=0x83; //重装初值 if((time%100) == 0) sumnum1 = num; if(time == 1000) { sumnum=num; if(sumnum<10) { if((FLAG==1)&&(sumnum<10)) { PORTD=0XFF; FLAG=0; } FLAG++; } else PORTD=0XBF; num=0; time=0; } num+=count; count=0; ++time; }
标签: C语言
上传时间: 2016-03-09
上传用户:彦 yan
#include <stdlib.h> #include<stdio.h> #include <malloc.h> #define stack_init_size 100 #define stackincrement 10 typedef struct sqstack { int *base; int *top; int stacksize; } sqstack; int StackInit(sqstack *s) { s->base=(int *)malloc(stack_init_size *sizeof(int)); if(!s->base) return 0; s->top=s->base; s->stacksize=stack_init_size; return 1; } int Push(sqstack *s,int e) { if(s->top-s->base>=s->stacksize) { s->base=(int *)realloc(s->base,(s->stacksize+stackincrement)*sizeof(int)); if(!s->base) return 0; s->top=s->base+s->stacksize; s->stacksize+=stackincrement; } *(s->top++)=e; return e; } int Pop(sqstack *s,int e) { if(s->top==s->base) return 0; e=*--s->top; return e; } int stackempty(sqstack *s) { if(s->top==s->base) { return 1; } else { return 0; } } int conversion(sqstack *s) { int n,e=0,FLAG=0; printf("输入要转化的十进制数:\n"); scanf("%d",&n); printf("要转化为多少进制:\n"); scanf("%d",&FLAG); printf("将十进制数%d 转化为%d 进制是:\n",n,FLAG); while(n) { Push(s,n%FLAG); n=n/FLAG; } while(!stackempty(s)) { e=Pop(s,e); switch(e) { case 10: printf("A"); break; case 11: printf("B"); break; case 12: printf("C"); break; case 13: printf("D"); break; case 14: printf("E"); break; case 15: printf("F"); break; default: printf("%d",e); } } printf("\n"); return 0; } int main() { sqstack s; StackInit(&s); conversion(&s); return 0; }
上传时间: 2016-12-08
上传用户:爱你198
#include "string.h" #include "ctype.h" #include "stdio.h" search(char pd[]) {FILE *fp; int time=0,i=0,j=0,add[80],k=0,m; char *ch, str[900]; m=strlen(pd); if((fp=fopen("haha.txt","r"))==NULL) { printf("Cannot open this file\n"); exit(0); } for(;!feof(fp);i++) { str[i]=fgetc(fp); if(tolower(str[i])==tolower(pd[k])) {k++; if(k==m) if(!isalpha(i-m)&&!isalpha((str[i++]=fgetc(fp)))) { time++; add[j]=i-m+1; j++; k=0; } else k=0; } } if(time) { printf("The time is:%d\n",time); printf("The adders is:\n"); for(i=0;i<j;i++) printf("%5d",add[i]); if(i%5==0) printf("\n"); getch(); fclose(fp); } else printf("Sorry!Cannot find the word(^_^)"); } main() { char pd[10],choose='y'; int FLAG=1; while(FLAG) {printf("In put the word you want to seqarch:"); scanf("%s",pd); search(strlwr(pd)); printf("\nWould you want to continue?(Y/N):"); getchar(); scanf("%c",&choose); if((tolower(choose))=='n') FLAG=0; else FLAG=1; } printf("Thanks for your using!Bye-bye!\n"); getch(); }
标签: 学生专用
上传时间: 2016-12-29
上传用户:767483511