merge the formfield patch from ooo-build
[ooovba.git] / sal / qa / osl / socket / sockethelper.hxx
blob04f92986f3bedb793021ac9598e5b83ccca2ca3f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sockethelper.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 //------------------------------------------------------------------------
31 //------------------------------------------------------------------------
33 #ifndef _SOCKETHELPER_HXX_
34 #define _SOCKETHELPER_HXX_
36 //------------------------------------------------------------------------
37 //------------------------------------------------------------------------
38 #include <sal/types.h>
39 #include <rtl/textenc.h>
40 #include <rtl/ustring.hxx>
41 #include <rtl/ustring.h>
43 #ifndef _OSL_SOCLET_HXX_
44 #include <osl/socket.hxx>
45 #endif
46 #include <osl/socket.h>
48 #ifndef _OSL_THREAD_HXX
49 #include <osl/thread.hxx>
50 #endif
52 #ifndef _OSL_FILE_HXX
53 #include <osl/file.hxx>
54 #endif
56 #ifndef _OSL_MUTEX_HXX
57 #include <osl/mutex.hxx>
58 #endif
59 #include <osl/time.h>
61 #ifdef __cplusplus
62 extern "C"
64 #endif
66 //------------------------------------------------------------------------
67 // OS dependent declaration and includes
68 //------------------------------------------------------------------------
69 #if ( defined UNX ) || ( defined OS2 ) //Unix
71 #include <unistd.h>
72 #include <limits.h>
73 #include <string.h>
74 #include <math.h>
75 #include <errno.h>
76 #include <fcntl.h>
77 #include <sys/stat.h>
78 #include <sys/statfs.h>
79 #include <sys/statvfs.h>
80 #include <sys/types.h>
81 #include <sys/socket.h>
82 #include <netdb.h>
83 #include <netinet/in.h>
84 #include <arpa/inet.h>
85 #include <sys/wait.h>
86 #endif
88 #ifndef _OSL_SOCKET_CONST_H_
90 #if ( defined WNT ) // Windows
91 #include <tools/prewin.h>
92 // #include <windows.h>
93 #include <winsock.h>
94 #include <string.h>
95 #include <tools/postwin.h>
96 #endif
98 #endif
100 //------------------------------------------------------------------------
101 //------------------------------------------------------------------------
103 #ifdef __cplusplus
105 #endif
107 /** compare two OUString.
109 sal_Bool compareUString( const ::rtl::OUString & ustr1, const ::rtl::OUString & ustr2 );
110 /** compare a OUString and an ASCII string.
112 sal_Bool compareUString( const ::rtl::OUString & ustr, const sal_Char *astr );
113 /** compare two socket address.
115 sal_Bool compareSocketAddr( const ::osl::SocketAddr & addr1 , const ::osl::SocketAddr & addr2 );
116 //char * oustring2char( const ::rtl::OUString & str );
117 /** print a UNI_CODE String. And also print some comments of the string.
119 void printUString( const ::rtl::OUString & str, const char * msg = "" );
120 /** get the local host name.
121 mindy: gethostbyname( "localhost" ), on Linux, it returns the hostname in /etc/hosts + domain name,
122 if no entry in /etc/hosts, it returns "localhost" + domain name
124 ::rtl::OUString getHost( void );
125 /** get the full host name of the current processor, such as "aegean.prc.sun.com" --mindyliu
127 ::rtl::OUString getThisHostname( void );
128 /** get IP by name, search /etc/hosts first, then search from dns, fail return OUString("")
130 ::rtl::OUString getIPbyName( rtl::OString const& str_name );
131 /** get local ethernet IP
133 ::rtl::OUString getLocalIP( );
134 /** construct error message
136 ::rtl::OUString outputError( const ::rtl::OUString & returnVal, const ::rtl::OUString & rightVal, const sal_Char * msg = "");
137 void thread_sleep( sal_Int32 _nSec );
138 /** print Boolean value.
140 void printBool( sal_Bool bOk );
141 /** print content of a ByteSequence.
143 void printByteSequence_IP( const ::rtl::ByteSequence & bsByteSeq, sal_Int32 nLen );
144 /** convert an IP which is stored as a UString format to a ByteSequence array for later use.
146 ::rtl::ByteSequence UStringIPToByteSequence( ::rtl::OUString aUStr );
147 /** print a socket result name.
149 void printSocketResult( oslSocketResult eResult );
150 /** if 4 parts of an IP addr are equal to specified values
152 sal_Bool ifIpv4is( const ::rtl::ByteSequence Ipaddr, sal_Int8 seq1, sal_Int8 seq2, sal_Int8 seq3, sal_Int8 seq4 );
153 /** if the IP or hostname is availble( alive )
155 //sal_Bool ifAvailable( const char * stringAddrOrHostName );
156 sal_Bool ifAvailable( rtl::OUString const& strAddrOrHostName );
158 class ClientSocketThread : public Thread
159 class ServerSocketThread : public Thread
160 class ValueCheckProvider
161 class ClientReadSocketThread : public Thread
162 class ServerWriteSocketThread : public Thread
163 class AcceptorThread : public Thread
164 class CloseSocketThread : public Thread
168 #endif