Location:
Search - char to h
Search list
Description: C++ Base64编码/解码源代码
inline int Base64Encode(char * base64code, const char * src, int src_len = 0)
inline int Base64Decode(char * buf, const char * base64code, int src_len = 0) 以上两个函数内联定义在base64.h中,使用时include \"base64.h\" 即可,编码后的长度一般比原文多占1/3的存储空间,为了效率,程序并没有检查目标存储区是否溢出,请保证有足够的存储空间。
-C Base64 encoding / decoding source code inline int Base64Encode (char * base64code, const char * src, int src_len = 0) inline int Base64Decode (char * buf, base64code const char *, int src_len = 0) over two letters few within the definition in conjunction base64.h, when used include "base64.h" can, coding the original length generally occupy more than 1 / 3 of storage space, in order to efficiency, procedures and did not check whether the target storage areas overflow, please ensure that there is sufficient storage space.
Platform: |
Size: 5583 |
Author: 王晓名 |
Hits:
Description: 本驱动程序在linux2.6.17中测试通过。yangxing msn:lelma_yx@hotmail.com
希望对SPI操作的朋友有所帮助。
一、工作方式:
从设备:SPI为MASTER模式
S3C2410:SPI为SLAVE模式+DMA
二、工作流程
1.S3C2410从接收:当从设备发送数据时,S3C2410利用DMA方式收数,收到指定长度的数据,则进入DMA中断,将接收的数据拷出。
2.S3C2410从发送:当S3C2410需要发送,首先由RTS请求发送,然后等待从设备应答CTS,当从设备应答CTS时,进入外部中断,启动DMA发送,发送完成,再次进入从接收状态。
三、文件位置
spi_dma_slave.c
spi_dma_slave.h
circular_buf.c
circular_buf.h
等文件存放入driver/char/目录
dma.c存放于arch/arm/mach-s3c2410/目录
dma.h存放于include/arm-asm/mach-s3c2410/目录
四、使用环境
1.arm-linux-gcc-3.4.1-the driver linux2.6.17 in which the test. Yangxing msn : lelma_yx@hotmail.com hope to operate SPI friends help. 1, mode of work : from equipment : SPI for the S3C2410 MASTER mode : SPI for SLAVE + DMA mode 2, workflow 1.S3C2410 from receiving : When sending data from the device, using DMA S3C2410 debt, the length of the designated data DMA will enter the interruption will receive unfettered access to the data. 2.S3C2410 from this : When S3C2410 need this, the first request sent by the RTS, Then wait for the response from CTS equipment, when the equipment response from CTS, access to external interrupt start DMA sent, Send completed, re-entered, from receiving state. 3. Position papers spi_dma_slave.c spi_dma_slave.h circul ar_buf.c circular_buf.h documents onto the driver / char / Contents
Platform: |
Size: 17368 |
Author: y |
Hits:
Description: avr应用有关使用注意事项如下
1 在使用例子程序之前将库文件libslavr.a 拷贝到ICCAVR 安装目录下的库文件目录中
即...\\LIB\\目录将头文件slavr.h 拷贝到头文件目录即...\\include\\目录
2 如果想使用库文件中的函数那么设置如下
1) 在文件中应使用 \"#include <slavr.h>\"包含slavr.h 头文件
2) 在工程选项中的Additional LIB 一栏中填入\"slavr\" 使用附加的libslavr.a
库文件(注意引号不需要输入)
3 libslavr.a 库中包含的函数清单如下
1) void write_lcd(unsigned char data,unsigned-avr applied to matters relating to the use of the following examples of the use of a procedure before the document libslav r.a ICCAVR copy of the installation directory of the library catalog is ... \\ LIB \\ directory paper's head lavr.h copy directory that is the end ... \\ include \\ directory 2 if they wish to use the library Functions are then installed a), the document should be used "# include
Platform: |
Size: 10023 |
Author: nndx |
Hits:
Description: #include \"intrins.h\"
unsigned char SystemError
sbit SCL= P1^6 //定义串行时钟线所在口 使用时根据自己的需要
sbit SDA= P1^7 //定义串行数据线所在口 使用时根据自己的需要
#define SomeNOP() {_nop_() _nop_() _nop_() _nop_() }-# include "intrins.h" unsigned char Syste mError sbit SCL = P1 ^ 6 / / definition serial clock line where I use according to their needs sbit SDA P1 = ^ 7 / / definition of serial data lines where I use according to their needs # defin e SomeNOP () (_nop_ () _nop_ () _nop_ () _nop_ (
Platform: |
Size: 229305 |
Author: zhusheng |
Hits:
Description: 使用mediastreamer2的g711common.h. unsigned char s16_to_alaw(int pcm_val). 将16bit的原始样本encode 成为8bit的a-law码.-use mediastreamer2 the g711common.h. Unsign ed char s16_to_alaw (int pcm_val). to the original 16bit samples The encode into a 8 bit-law code.
Platform: |
Size: 55219 |
Author: 韩义 |
Hits:
Description: 2.[问题描述]
编写递归算法,在二叉树中求位于先序序列中第K个位置的结点
[输入]
按照先序序列的顺序输入该结点的内容。其输入abd eh cf i g 。输入要求的位置
[输出]
若二叉树不空,按先序序列输出,求出所求位置的结点
[存储结构]
采用二叉表存储
[算法的基本思想]
采用递归方法建立和遍历二叉树。首先建立二叉树的根结点,然后建立其左右子树,直到空子树为止,先序遍历二叉树时,先遍厉左子树,后遍厉右子树,最后访问根结点并计算出二叉树中叶子结点的数目和第K个位置的结点
#include<stdio.h>
#include<malloc.h>
struct node{
char info
struct node*llink,*rlink
}
typedef struct node NODE
-2. [Description of the issue] to prepare recursive algorithm, Binary for the first sequence sequence in the first position of the K-node [imported] in accordance with the first order input sequence in the order of the nodes content. Input abd eh i g cf. Import requirements of the position [output] if the binary tree is not empty, the first sequence by sequence output obtained by seeking the location of nodes [storage structure] Table 2 forks storage [algorithm for the basic idea] recursive method and Traversing binary tree. First established binary tree root node, and then to build their son around the tree, the tree until the loopholes, preorder binary tree, Li first times the left sub-tree, after repeatedly Li-right tree Finally visit root node and calculated Binary leaf nodes and the nu
Platform: |
Size: 7096 |
Author: Demonic |
Hits:
Description: 应用于ucGUI的16*16点阵字库文件 只要将该文件加入ucGUI的工程中, 再在GUI.H中如下声明: extern const GUI_FONT GUI_Font6x8 ...... extern const GUI_FONT GUI_Font_HZ16x16 //汉字字体 即可使用. 使用实例: static void DemoHZ(void) { const char str[] = GUI_UC_START\"中国人民万岁\"GUI_UC_END /* Set ShiftJIS font */ GUI_SetFont(&GUI_Font_HZ16x16) GUI_DispString(str) }-used ucGUI 16 * 16 character dot-matrix document as long as the document ucGUI to join the project, which GUI.H again in the following statement : extern const GUI_FONT GUI_Font6x8 ...... extern const GUI_FONT GUI_Font_HZ16x16 / / Chinese fonts can be used. examples of use : static void DemoHZ (void) (const char str [] = GUI_UC_START "Long live the Chinese people" GUI_UC_END / * Set ShiftJIS font * / GUI_SetFont (GUI_ Font_HZ16x16) GUI_DispString (str
Platform: |
Size: 166043 |
Author: 康康 |
Hits:
Description: 一个判断远程主机存活程序代码(ping)
#include
#include
#include
#include
#include "winsock.h"
#pragma comment(lib,"Ws2_32");
#define SEND_SIZE 32
#define PACKET_SIZE 4096
#define ICMP_ECHO 8
#define ICMP_ECHOREPLY 0
struct icmp
{
unsigned char icmp_type;
unsigned char icmp_code;
unsigned short icmp_cksum;
unsigned short icmp_id;
unsigned short icmp_seq;
unsigned long icmp_data;
};
struct ip
{
unsigned char ip_hl:4;
unsigned char ip_v:4;
unsigned char ip_tos;
unsigned short ip_len;
unsigned short ip_id;
unsigned short ip_off;
unsigned char ip_ttl;
unsigned char ip_p;
unsigned short ip_sum;
unsigned long ip_src;
unsigned long ip_dst;
};
unsigned char sendpacket[PACKET_SIZE];
unsigned char recvpacket[PACKET_SIZE];
struct sockaddr_in dest_addr;
struct sockaddr_in from_addr;
int sockfd;
int pid;
unsigned short cal_chksum(unsigned short *addr,int len);
int pack(int pack_no);
int unpack(unsigned char *buf,int len);
void send_packet(void);
void recv_packet(void);
void main(int argc,char *argv[])
{
struct hostent *host;
struct protoent *protocol;
WSADATA wsaData;
int timeout=1000;
int SEND_COUNT=4;
int i;
char *par_host;
par_host=argv[argc-1]; //IP赋值
switch(argc)
{
case 2: break;
case 3: if(strcmp(argv[1],"-t")==0)
{
SEND_COUNT=10000;
break;
}
//fall through
default:
printf("usage: %s [-t] Host name or IP address\n",argv[0]);
exit(1);
}
if(WSAStartup(0x1010,&wsaData)!=0)
{
printf("wsastartup error\n");
exit(1);
}
if( (protocol=getprotobyname("icmp") )==NULL)
{
printf("getprotobyname error\n");
exit(1);
}
/*
printf("%s\n",protocol->p_name);
printf("%s\n",protocol->p_aliases);
printf("%d\n",protocol->p_proto);
system("pause");
*/
if( (sockfd=socket(AF_INET,SOCK_RAW,protocol->p_proto) )<0)
{
printf("socket error\n");
exit(1);
}
if(setsockopt(sockfd,SOL_SOCKET,SO_RCVTIMEO,(char*)&timeout,sizeof(timeout))h_length);
//resolve address to hostname
if(host=gethostbyaddr(host->h_addr,4,PF_INET))
par_host=host->h_name;
//
//printf("%s\n",par_host);
//
}
else if( dest_addr.sin_addr.s_addr=inet_addr(par_host)==INADDR_NONE)
{
printf("Unkown host %s\n",par_host);
exit(1);
}
pid=getpid();
/*
printf("%d\n",pid);
system("pause");
*/
printf("Pinging %s [%s]: with %d bytes of data:\n\n",par_host,inet_ntoa(dest_addr.sin_addr),SEND_SIZE);
for(i=0;i1)
{ sum+=*w++;
nleft-=2;
}
if( nleft==1)
{ *(unsigned char *)(&answer)=*(unsigned char *)w;
sum+=answer;
}
sum=(sum>>16)+(sum&0xffff);
sum+=(sum>>16);
answer=~sum;
return answer;
}
//打包
int pack(int pack_no)
{
int packsize;
struct icmp *icmp;
packsize=8+SEND_SIZE;
icmp=(struct icmp*)sendpacket;
icmp->icmp_type=ICMP_ECHO;
icmp->icmp_code=0;
icmp->icmp_cksum=0;
icmp->icmp_seq=pack_no;
icmp->icmp_id=pid;
icmp->icmp_data=GetTickCount();
icmp->icmp_cksum=cal_chksum( (unsigned short *)icmp,packsize); /*校验算法*/
return packsize;
}
//解包
int unpack(unsigned char *buf,int len)
{
struct ip *ip;
struct icmp *icmp;
double rtt;
int iphdrlen;
ip=(struct ip *)buf;
iphdrlen=ip->ip_hl*4;
icmp=(struct icmp *)(buf+iphdrlen);
if( (icmp->icmp_type==ICMP_ECHOREPLY) && (icmp->icmp_id==pid) )
{
len=len-iphdrlen-8;
rtt=GetTickCount()-icmp->icmp_data;
printf("Reply from %s: bytes=%d time=%.0fms TTL=%d icmp_seq=%u\n",
inet_ntoa(from_addr.sin_addr),
len,
rtt,
ip->ip_ttl,
icmp->icmp_seq);
return 1;
}
return 0;
}
//发送
void send_packet()
{
int packetsize;
static int pack_no=0;
packetsize=pack(pack_no++);
if( sendto(sockfd,(char *)sendpacket,packetsize,0,(struct sockaddr *)&dest_addr,sizeof(dest_addr) )=0)
success=unpack(recvpacket,n);
else if (WSAGetLastError() == WSAETIMEDOUT)
{
printf("Request timed out.\n");
return;
}
}while(!success);
}
UID5380 帖子239 精华0 积分1289 阅读权限40 来自软件学院 在线时间81 小时 注册时间2006-5-22 最后登录2007-2-24 查看详细资料
TOP
Platform: |
Size: 5881 |
Author: shuiyuan313 |
Hits:
Description: 应用于ucGUI的16*16点阵字库文件 只要将该文件加入ucGUI的工程中, 再在GUI.H中如下声明: extern const GUI_FONT GUI_Font6x8 ...... extern const GUI_FONT GUI_Font_HZ16x16 //汉字字体 即可使用. 使用实例: static void DemoHZ(void) { const char str[] = GUI_UC_START"中国人民万岁"GUI_UC_END /* Set ShiftJIS font */ GUI_SetFont(&GUI_Font_HZ16x16) GUI_DispString(str) }-used ucGUI 16* 16 character dot-matrix document as long as the document ucGUI to join the project, which GUI.H again in the following statement : extern const GUI_FONT GUI_Font6x8 ...... extern const GUI_FONT GUI_Font_HZ16x16// Chinese fonts can be used. examples of use : static void DemoHZ (void) (const char str [] = GUI_UC_START "Long live the Chinese people" GUI_UC_END/* Set ShiftJIS font*/GUI_SetFont (GUI_ Font_HZ16x16) GUI_DispString (str
Platform: |
Size: 165888 |
Author: 康康 |
Hits:
Description: C++ Base64编码/解码源代码
inline int Base64Encode(char * base64code, const char * src, int src_len = 0)
inline int Base64Decode(char * buf, const char * base64code, int src_len = 0) 以上两个函数内联定义在base64.h中,使用时include "base64.h" 即可,编码后的长度一般比原文多占1/3的存储空间,为了效率,程序并没有检查目标存储区是否溢出,请保证有足够的存储空间。
-C Base64 encoding/decoding source code inline int Base64Encode (char* base64code, const char* src, int src_len = 0) inline int Base64Decode (char* buf, base64code const char*, int src_len = 0) over two letters few within the definition in conjunction base64.h, when used include "base64.h" can, coding the original length generally occupy more than 1/3 of storage space, in order to efficiency, procedures and did not check whether the target storage areas overflow, please ensure that there is sufficient storage space.
Platform: |
Size: 5120 |
Author: 王晓名 |
Hits:
Description: 本驱动程序在linux2.6.17中测试通过。yangxing msn:lelma_yx@hotmail.com
希望对SPI操作的朋友有所帮助。
一、工作方式:
从设备:SPI为MASTER模式
S3C2410:SPI为SLAVE模式+DMA
二、工作流程
1.S3C2410从接收:当从设备发送数据时,S3C2410利用DMA方式收数,收到指定长度的数据,则进入DMA中断,将接收的数据拷出。
2.S3C2410从发送:当S3C2410需要发送,首先由RTS请求发送,然后等待从设备应答CTS,当从设备应答CTS时,进入外部中断,启动DMA发送,发送完成,再次进入从接收状态。
三、文件位置
spi_dma_slave.c
spi_dma_slave.h
circular_buf.c
circular_buf.h
等文件存放入driver/char/目录
dma.c存放于arch/arm/mach-s3c2410/目录
dma.h存放于include/arm-asm/mach-s3c2410/目录
四、使用环境
1.arm-linux-gcc-3.4.1-the driver linux2.6.17 in which the test. Yangxing msn : lelma_yx@hotmail.com hope to operate SPI friends help. 1, mode of work : from equipment : SPI for the S3C2410 MASTER mode : SPI for SLAVE+ DMA mode 2, workflow 1.S3C2410 from receiving : When sending data from the device, using DMA S3C2410 debt, the length of the designated data DMA will enter the interruption will receive unfettered access to the data. 2.S3C2410 from this : When S3C2410 need this, the first request sent by the RTS, Then wait for the response from CTS equipment, when the equipment response from CTS, access to external interrupt start DMA sent, Send completed, re-entered, from receiving state. 3. Position papers spi_dma_slave.c spi_dma_slave.h circul ar_buf.c circular_buf.h documents onto the driver/char/Contents
Platform: |
Size: 17408 |
Author: y |
Hits:
Description: avr应用有关使用注意事项如下
1 在使用例子程序之前将库文件libslavr.a 拷贝到ICCAVR 安装目录下的库文件目录中
即...\LIB\目录将头文件slavr.h 拷贝到头文件目录即...\include\目录
2 如果想使用库文件中的函数那么设置如下
1) 在文件中应使用 "#include <slavr.h>"包含slavr.h 头文件
2) 在工程选项中的Additional LIB 一栏中填入"slavr" 使用附加的libslavr.a
库文件(注意引号不需要输入)
3 libslavr.a 库中包含的函数清单如下
1) void write_lcd(unsigned char data,unsigned-avr applied to matters relating to the use of the following examples of the use of a procedure before the document libslav r.a ICCAVR copy of the installation directory of the library catalog is ... \ LIB \ directory paper's head lavr.h copy directory that is the end ... \ include \ directory 2 if they wish to use the library Functions are then installed a), the document should be used "# include
Platform: |
Size: 9216 |
Author: |
Hits:
Description: #include "intrins.h"
unsigned char SystemError
sbit SCL= P1^6 //定义串行时钟线所在口 使用时根据自己的需要
sbit SDA= P1^7 //定义串行数据线所在口 使用时根据自己的需要
#define SomeNOP() {_nop_() _nop_() _nop_() _nop_() }-# include "intrins.h" unsigned char Syste mError sbit SCL = P1 ^ 6// definition serial clock line where I use according to their needs sbit SDA P1 = ^ 7// definition of serial data lines where I use according to their needs# defin e SomeNOP () (_nop_ () _nop_ () _nop_ () _nop_ (
Platform: |
Size: 229376 |
Author: zhusheng |
Hits:
Description: 使用mediastreamer2的g711common.h. unsigned char s16_to_alaw(int pcm_val). 将16bit的原始样本encode 成为8bit的a-law码.-use mediastreamer2 the g711common.h. Unsign ed char s16_to_alaw (int pcm_val). to the original 16bit samples The encode into a 8 bit-law code.
Platform: |
Size: 55296 |
Author: 韩义 |
Hits:
Description: 2.[问题描述]
编写递归算法,在二叉树中求位于先序序列中第K个位置的结点
[输入]
按照先序序列的顺序输入该结点的内容。其输入abd eh cf i g 。输入要求的位置
[输出]
若二叉树不空,按先序序列输出,求出所求位置的结点
[存储结构]
采用二叉表存储
[算法的基本思想]
采用递归方法建立和遍历二叉树。首先建立二叉树的根结点,然后建立其左右子树,直到空子树为止,先序遍历二叉树时,先遍厉左子树,后遍厉右子树,最后访问根结点并计算出二叉树中叶子结点的数目和第K个位置的结点
#include<stdio.h>
#include<malloc.h>
struct node{
char info
struct node*llink,*rlink
}
typedef struct node NODE
-2. [Description of the issue] to prepare recursive algorithm, Binary for the first sequence sequence in the first position of the K-node [imported] in accordance with the first order input sequence in the order of the nodes content. Input abd eh i g cf. Import requirements of the position [output] if the binary tree is not empty, the first sequence by sequence output obtained by seeking the location of nodes [storage structure] Table 2 forks storage [algorithm for the basic idea] recursive method and Traversing binary tree. First established binary tree root node, and then to build their son around the tree, the tree until the loopholes, preorder binary tree, Li first times the left sub-tree, after repeatedly Li-right tree Finally visit root node and calculated Binary leaf nodes and the nu
Platform: |
Size: 7168 |
Author: Demonic |
Hits:
Description: 操作系统课程设计_进程调度演示源程序
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
typedef struct node
{
char name[10] /*进程标识符*/
int prio /*进程优先数*/
int round /*进程时间轮转时间片*/
int cputime /*进程占用CPU时间*/
int needtime /*进程到完成还要的时间*/
int count /*计数器*/
char state /*进程的状态*/
struct node *next /*链指针*/
}PCB -Operating system curriculum design process scheduling demo source _# Include stdio.h# Include stdlib.h# Include string.h typedef struct node (char name [10]/* process identifier*/int prio/* process priority number*/int round/* process time rotation time slice*/int cputime/* process occupy CPU time*/int needtime/* process to be completed but also the time*/int count/* counter*/char state/* process status*/struct node* next/* Chain pointer* /) PCB
Platform: |
Size: 2048 |
Author: wjx |
Hits:
Description: 51单片连tcs230的源程序,绝对原创,可以记忆颜色。
#define uchar unsigned char
#include <reg52.h>
#include<math.h>
sbit S0=P1^7
sbit S1=P1^0 //端口定义
sbit S2=P1^1
sbit S3=P1^2
sbit OE=P1^3
sbit OUT=P3^4 //频率从TO口输入
sbit key0=P1^5
sbit LED=P1^6
sbit a=P3^0
sbit b=P3^1
uchar color //1:blue 2:green 3:red
uchar T[4] //color timer
uchar TH[4]
uchar TL[4]
uchar bizhi[4]
void time1() interrupt 3
{
TH[color]=TH0
TL[color]=TL0
T[color]=(TH[color]*0xff+TL[color])
TR0=0 //关定时器
TR1=0
TH1=0xB1
TL1=0xE0 //归0
TH0=0x00
TL0=0x00 //归0
}-51 monolithic tcs230 even the source is absolutely original, you can remember the color.# Define uchar unsigned char# Include
Platform: |
Size: 1024 |
Author: 黄胜 |
Hits:
Description: #include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <fstream>
#include <iostream>
using namespace std
struct Code
{
float a
char s
}
Code cc[8]={{0.25, a },{0.3, b },{0.1, c },{0.05, d },{0.05, e },{0.05, . },{0.05, , },{0.15, 8 }}
int main()
{
srand((unsigned)time(NULL))
int x
int n
ofstream outobj("plpl.txt")
cout<<"inpute the number(要产生的字符数):"
cin>>n
for(int i=0 i<n i++)
{
x=rand()%1000+1
int low =1
for(int j=0 j<8 j++)
{
int high=cc[j].a*1000+low-1
if(x>=low&&x<=high)
{
outobj<<cc[j].s
break
}
low = high+1
}
}
outobj.flush()
outobj.close()
} 存到.dat文件里面-# Include <stdlib.h># Include <stdio.h># Include <time.h># Include <fstream># Include <iostream> using namespace std struct Code (float a char s) Code cc [ 8] = ((0.25, a), (0.3, b), (0.1, c), (0.05, d), (0.05, e), (0.05,.), (0.05,,), (0.15, 8 )) int main () (srand ((unsigned) time (NULL)) int x int n ofstream outobj ( plpl.txt ) cout << inpute the number (to generate the number of characters): cin>> n for (int i = 0 i <n i++) (x = rand () 1000+ 1 int low = 1 for (int j = 0 j <8 j++) (int high = cc [j] . a* 1000+ low-1 if (x> = low
Platform: |
Size: 1024 |
Author: 糊涂 |
Hits:
Description: 一些转换代码,hex to char,char to hex-Some of the conversion code, hex to char, char to hex
Platform: |
Size: 1024 |
Author: 陈先生 |
Hits:
Description: 文件说明:
function.h 函数申明
function.cpp 函数实现
main.cpp 函数调用
函数说明:
ppmtoppm(char* in, char* out)
读入ppm24位彩色图像,输出ppm24位灰度图像
ppmtopgm(char* in, char* out)
读入ppm24位彩色图像,输出pgm256色灰度图像
ppmtobmp(char* in, char* out)
读入ppm24位彩色图像,输出bmp24位彩色图像-File Description: function.h stated function.cpp function function function call function to achieve main.cpp Description: ppmtoppm (char* in, char* out) read ppm24-bit color images, the output ppm24 bit grayscale images ppmtopgm (char* in , char* out) read ppm24-bit color images, grayscale color output pgm256 ppmtobmp (char* in, char* out) read ppm24-bit color images, the output bmp24 bit color images
Platform: |
Size: 556032 |
Author: fu hang |
Hits: