Develop and Download Open Source Software

Browse CVS Repository

Annotation of /xoonips/AL/common.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (hide annotations) (download) (as text)
Thu Jan 6 07:17:15 2005 UTC (19 years, 3 months ago) by youi
Branch: MAIN
Changes since 1.3: +10 -1 lines
File MIME type: text/x-c++src
VC toolkit使用時のsnprintfと_fltusedの定義を追加.

1 youi 1.1 /*
2     * Abstract Layer????罘??純?????鋎帥???∽?違???????у?臂?????鐚?/span>
3     *
4 youi 1.4 * $Revision: 1.3 $
5 aga 1.2 * $Log: common.cc,v $
6 youi 1.4 * Revision 1.3 2004/11/26 05:13:40 aga
7     * ??serid_t, groupid_t??unsigned int ??信罩?
8     * ??nsignedIntToString()??篏???.
9     *
10 aga 1.3 * Revision 1.2 2004/11/26 03:29:43 aga
11     * ??ntToString()??篏???.
12     *
13 aga 1.2 * Revision 1.1 2004/11/22 08:25:16 youi
14     * initial version.
15     *
16 youi 1.1 *
17     */
18    
19     #include <stdio.h>
20     #include <string.h>
21     #include "common.h"
22 youi 1.4
23     #if defined(_MSC_VER)
24     #define snprintf _snprintf
25     int _fltused = 0x9875;
26     #endif
27 youi 1.1
28     /**
29     *
30     * 筝???????????絖?????茲?茖純??鐚??????≪?????鴻??菴???鐚?/span>
31     *
32     * @param text
33     * @return 茲?茖純??????絖??????≪??????/span>
34     * @return 0 茲?茖純??け??
35     *
36     */
37     char* str_dup( const char* text )
38     {
39     if( text == 0 ) return 0;
40     char* ptr = new char[ strlen( text ) + 1 ];
41     if( ptr == 0 ) return 0;
42     strcpy( ptr , text );
43     return ptr;
44     }
45    
46     /**
47     *
48     * newtext?ф??絎?????????絖?????茲?茖純??鐚??????≪?????鴻??*dstptr??撮?ャ????.<br>
49     * ??????????鐚??????障??dstptr?????с??????????????茹f?障????.<br>
50     * ??筝??уけ???????翫????dstptr????絎鴻???吾??????????????鐚?lt;br>
51     * newtext==0?????????*dstptr?????с??????????茹f?障??鐚?腥堺??絖????域???????????????≪?????鴻??*dstptr??撮?ャ????.<br>
52     *
53     * @param newtext *dstptr??撮?ャ????????絖???
54     * @param dstptr 茲?茖純????newtext???≪?????鴻??篁e?ャ???????ゃ?潟?水??違?吾?????ゃ?潟??/span>
55     * @return dstptr??撮?ャ?????≪????? 紊掩??????????????stptr
56     *
57     */
58     char* setValue( char** dstptr, const char* newtext )
59     {
60     char* ptr;
61    
62     // newtext??0????鐚?*dstptr?????с?????<?≪????????茹f?障??鐚?
63     // *dstptr?????域?篏???????腥堺??絖????≪?????鴻??篁e??/span>
64     if( newtext == 0 ){
65     ptr = str_dup( "" );
66     }else{
67     ptr = str_dup( newtext );
68     }
69     if( ptr != 0 ){
70     if( *dstptr != 0 ) delete[] *dstptr;
71     *dstptr = ptr;
72     }
73     return *dstptr;
74     }
75 aga 1.2
76     /**
77     *
78     * int????絖??????????
79     *
80     * @param i 紊??????鴻???医??/span>
81     * @return 紊???緇?????絖???
82     *
83     */
84     string intToString( int i ){
85     char buf[sizeof(int)*3+1+1+1]; // n???ゃ??????3n+1罅?篁ヤ???膃?垩??罅???\0??罅?
86     snprintf( buf, sizeof(buf), "%d", i );
87 aga 1.3 string s( buf );
88     return s;
89     }
90    
91     /**
92     *
93     * unsigned int????絖??????????
94     *
95     * @param i 紊??????鴻???医??/span>
96     * @return 紊???緇?????絖???
97     *
98     */
99     string unsignedIntToString( unsigned int i ){
100     char buf[sizeof(int)*3+1+1]; // n???ゃ??????3n+1罅?篁ヤ???\0??罅?
101     snprintf( buf, sizeof(buf), "%u", i );
102 aga 1.2 string s( buf );
103     return s;
104     }
105    
106    
107    

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26