×

cwb C语言网络框架

消耗积分:2 | 格式:zip | 大小:0.05 MB | 2022-06-17

的撒的

分享资料个

授权协议 LGPL
开发语言 C/C++
操作系统 跨平台
软件类型 开源软件
所属分类 Web应用开发Web框架

软件简介

cwb(C on Web)一个轻量级,快速的 C 语言网络框架。

特性:

  • 异步IO支持
  • 事件驱动库
  • 数据序列化、编码支持

示例代码

/*    事件驱动库    */
Cwb_Event_Base *base = cwb_event_new();
assert(base);
assert(!cwb_event_watch_fd(base,serverSocket,CWB_EVENT_READ,sockethandler,NULL));
cwb_event_loop(base);
cwb_event_destroy(base);

/*    数据结构    */
#include
#include
#include
#include

#include

#include"Test.h"

int main(void)
{
	Cwb_Ds *dic=cwb_ds_new(CWB_DS_DICTIONARY,CWB_DS_SKEY);
	assert(dic);

	cwb_ds_set(dic,"I","Suote127");
	cwb_ds_set(dic,"you","User");
	cwb_ds_set(dic,"he","Unknow");

	puts(cwb_ds_get(dic,"he"));
	puts(cwb_ds_get(dic,"you"));
	puts(cwb_ds_get(dic,"I"));
	
	cwb_ds_set(dic,"I","The programmer");

	puts(cwb_ds_get(dic,"I"));

	cwb_ds_set(dic,"you",CWB_DS_UNDEFINED);
	assert(cwb_ds_get(dic,"you")==CWB_DS_UNDEFINED);

	cwb_ds_destroy(dic);
	
	return 0;
}

/*    动态字符串    */
#include
#include
#include
#include

#include

int main(void)
{
	char temp[1024];
	fgets(temp,1024,stdin);

	temp[strlen(temp);

	Cwb_Dstr *dstr = cwb_dstr_new();
	assert(dstr);
	
	assert(cwb_dstr_assign(dstr,temp));
	Cwb_Dstr *copy = cwb_dstr_copy(dstr);

	char *s = cwb_dstr_convert(dstr,NULL,0);
	puts(s);
	char *t = strdup(s);
	cwb_dstr_appendd(dstr,&t);
	assert(!t);
	cwb_dstr_appendc(dstr,':');
	cwb_dstr_appendc(dstr,')');
	free(s);
	
	s = cwb_dstr_convert(dstr,NULL,0);
	puts(s);

	cwb_dstr_destroy(dstr);
	free(s);

	cwb_dstr_appends(copy,":)");
	s = cwb_dstr_convert(copy,NULL,0);
	puts(s);
	free(s);

	return 0;
}

 

 

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

评论(0)
发评论

下载排行榜

全部0条评论

快来发表一下你的评论吧 !