1 /******************************************************************************
2 *
3 * Copyright (C) 2006, The Gentee Group. All rights reserved.
4 * This file is part of the Gentee open source project - http://www.gentee.com.
5 *
6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT").
7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS
8 * ACCEPTANCE OF THE AGREEMENT.
9 *
10 * ID: arr 18.10.06 0.0.A.
11 *
12 * Author: Alexey Krivonogov ( gentee )
13 *
14 ******************************************************************************/
15
16 #include "arrdata.h"
17 //! temporary
18 //#include "../os/user/defines.h"
19
20 /*-----------------------------------------------------------------------------
21 *
22 * ID: arrdata_appendstr 23.10.06 0.0.A.
23 *
24 * Summary: Append str to arrdata of str
25 *
26 * Return: The length of the appended string
27 *
28 -----------------------------------------------------------------------------*/
29
30 uint STDCALL arrdata_appendstr( parrdata pa, pubyte input )
31 {
32 pstr ps;
33
34 ps = ( pstr )arr_append( pa );
35 str_init( ps );
36 str_copyzero( ps, input );
37 return str_len( ps );
38 }
39
40 /*-----------------------------------------------------------------------------
41 *
42 * ID: arrdata_delete 23.10.06 0.0.A.
43 *
44 * Summary: Delete arrdata
45 *
46 -----------------------------------------------------------------------------*/
47
48 void STDCALL arrdata_delete( parrdata pa )
49 {
50 uint i, count = arr_count( pa );
51
52 for ( i = 0; i < count; i++ )
53 buf_delete( arrdata_get( pa, i ));
54 arr_delete( pa );
55 }
56
57 /*-----------------------------------------------------------------------------
58 *
59 * ID: arrdata_get 23.10.06 0.0.A.
60 *
61 * Summary: Get the item with <i> number (from 0)
62 *
63 -----------------------------------------------------------------------------*/
64
65 pstr STDCALL arrdata_get( parrdata pa, uint index )
66 {
67 return ( pstr )( buf_ptr( &pa->data ) + index * sizeof( buf ));
68 }
69
70 /*-----------------------------------------------------------------------------
71 *
72 * ID: arrdata_init 23.10.06 0.0.A.
73 *
74 * Summary: Init arrdata
75 *
76 -----------------------------------------------------------------------------*/
77
78 parrdata STDCALL arrdata_init( parrdata pa )
79 {
80 arr_init( pa, sizeof( buf ));
81 return pa;
82 }
83
84 /*-----------------------------------------------------------------------------
85 *
86 * ID: arrdata_strload 23.10.06 0.0.A.
87 *
88 * Summary: Load arrdata from string 0 string 0 string 00
89 *
90 -----------------------------------------------------------------------------*/
91
92 uint STDCALL arrdata_strload( parrdata pa, pubyte input )
93 {
94 uint count = 0;
95
96 if ( !input )
97 return 0;
98
99 while ( *input )
100 {
101 input += arrdata_appendstr( pa, input ) + 1;
102 count++;
103 }
104
105 return count;
106 }
107
108 //--------------------------------------------------------------------------
109
Редактировать