<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          cwbC 語(yǔ)言網(wǎng)絡(luò)框架

          聯(lián)合創(chuàng)作 · 2023-09-20 01:52

          cwb(C on Web)一個(gè)輕量級(jí),快速的 C 語(yǔ)言網(wǎng)絡(luò)框架。

          特性:

          • 異步IO支持
          • 事件驅(qū)動(dòng)庫(kù)
          • 數(shù)據(jù)序列化、編碼支持

          示例代碼

          /*    事件驅(qū)動(dòng)庫(kù)    */
          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);
          
          /*    數(shù)據(jù)結(jié)構(gòu)    */
          #include<stdio.h>
          #include<stdlib.h>
          #include<string.h>
          #include<assert.h>
          
          #include<cwb/Ds.h>
          
          #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;
          }
          
          /*    動(dòng)態(tài)字符串    */
          #include<assert.h>
          #include<stdio.h>
          #include<stdlib.h>
          #include<string.h>
          
          #include<cwb/Dstr.h>
          
          int main(void)
          {
          	char temp[1024];
          	fgets(temp,1024,stdin);
          
          	temp[strlen(temp)-1]='\0';
          
          	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;
          }

           

          瀏覽 29
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  日本欧美在线人 | 精品人妻人伦 | 69视频在线播放 | 福利综合网| 2018天天日天天色 |