LingYun IoT Studio NB-IoT research project
guowenxue
2018-11-19 ec8c799d8bb2ee69b5e6f56201231e8c905edeb1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*********************************************************************************
 *      Copyright:  (C) 2012 Guo Wenxue<guowenxue@gmail.com>  
 *                  All rights reserved.
 *
 *       Filename:  test_string.c
 *    Description:  This file 
 *                 
 *        Version:  1.0.0(11/27/2012~)
 *         Author:  Guo Wenxue <guowenxue@gmail.com>
 *      ChangeLog:  1, Release initial version on "11/27/2012 01:28:39 PM"
 *                 
 ********************************************************************************/
 
#include <cp_string.h>
 
 
/********************************************************************************
 *  Description:
 *   Input Args:
 *  Output Args:
 * Return Value:
 ********************************************************************************/
int main (int argc, char **argv)
{
    int            i;
    cp_string      *rcv;
    cp_string      *snd;
 
    rcv = cp_string_create_empty(64);
    snd = cp_string_create_empty(64);
 
    printf("=======================\n");
    printf("Test cp_string_copy \n");
    printf("=======================\n");
    cp_string_clear_data(rcv);
    cp_string_cstrcpy(rcv, "Hello world!");
    printf("Receive buffer data:\n");
    cp_string_dump(rcv);
 
    for(i=0; i<20; i++) 
    {
        if( cp_string_copy(snd, rcv) > 0)
        {
            printf("[%d] Send buffer data:\n", i);
            cp_string_dump(snd);
        }
    }
 
    printf("\n=======================\n");
    printf("Test cp_string_move \n");
    printf("=======================\n");
 
    cp_string_clear_data(snd);
    cp_string_clear_data(rcv);
    for(i=0; i<20; i++) 
    {
        cp_string_cstrcpy(rcv, "Hello world!");
        //printf("Set new receive buffer data [%d] bytes:\n", cp_string_len(rcv));
        cp_string_dump(rcv);
 
        if( cp_string_move(snd, rcv) > 0)
        {
            printf("[%d] Send buffer [%d] bytes data:\n", i, cp_string_len(snd));
            cp_string_dump(snd);
            
            printf("[%d] receive buffer [%d] bytes data:\n", i, cp_string_len(rcv));
            cp_string_dump(rcv);
        }
    }
 
    cp_string_destroy(rcv);
    cp_string_destroy(snd);
 
 
    return 0;
} /* ----- End of main() ----- */