ACE.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  * @file    ACE.h
00006  *
00007  * ACE.h,v 4.155 2006/06/01 09:09:17 jwillemsen Exp
00008  *
00009  * This file contains value added ACE functions that extend the
00010  * behavior of the UNIX and Win32 OS calls.
00011  *
00012  * All these ACE static functions are consolidated in a single place
00013  * in order to manage the namespace better.  These functions are put
00014  * here rather than in @c ACE_OS in order to separate concerns.
00015  *
00016  * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00017  */
00018 //=============================================================================
00019 
00020 #ifndef ACE_ACE_H
00021 #define ACE_ACE_H
00022 
00023 #include /**/ "ace/pre.h"
00024 
00025 #include "ace/config-lite.h"
00026 
00027 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00028 # pragma once
00029 #endif /* ACE_LACKS_PRAGMA_ONCE */
00030 
00031 #include "ace/Flag_Manip.h"
00032 #include "ace/Handle_Ops.h"
00033 #include "ace/Lib_Find.h"
00034 #include "ace/Init_ACE.h"
00035 #include "ace/Sock_Connect.h"
00036 #include "ace/Default_Constants.h"
00037 
00038 #if defined (CYGWIN32)
00039 // Include math.h. math.h defines a macro log2 that conflicts with ACE::log2()
00040 // which seems to only cause a problem on cygwin.  Insuring that math.h is
00041 // included first solves it since we define acelog2 as log2, then
00042 // undefines log2.
00043 # include "ace/os_include/os_math.h"
00044 #endif
00045 
00046 // When log2 is defined as macro redefine it as acelog2
00047 #if defined (log2)
00048 # define acelog2 log2
00049 # undef log2
00050 #endif /* log2 */
00051 
00052 #if defined (ACE_EXPORT_MACRO)
00053 #  undef ACE_EXPORT_MACRO
00054 #endif
00055 #define ACE_EXPORT_MACRO ACE_Export
00056 
00057 // Open versioned namespace, if enabled by the user.
00058 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00059 
00060 // Forward declarations.
00061 class ACE_Time_Value;
00062 class ACE_Message_Block;
00063 class ACE_Handle_Set;
00064 
00065 /**
00066  * @namespace ACE
00067  *
00068  * @brief The namespace containing the ACE framework itself.
00069  *
00070  * The ACE namespace contains all types (classes, structures,
00071  * typedefs, etc), and global functions and variables in the ACE
00072  * framework.
00073  */
00074 namespace ACE
00075 {
00076   // = ACE version information.
00077   /// e.g., the "5" in ACE 5.1.12.
00078   extern ACE_Export u_int major_version (void);
00079 
00080   /// e.g., the "1" in ACE 5.1.12.
00081   extern ACE_Export u_int minor_version (void);
00082 
00083   /// e.g., the "12" in ACE 5.1.12.
00084   /// Returns 0 for "stable" (non-beta) releases.
00085   extern ACE_Export u_int beta_version (void);
00086 
00087   // = C++ compiler version information.
00088   /// E.g., the "SunPro C++" in SunPro C++ 4.32.0
00089   extern ACE_Export const ACE_TCHAR * compiler_name (void);
00090 
00091   /// E.g., the "4" in SunPro C++ 4.32.0
00092   extern ACE_Export u_int compiler_major_version (void);
00093 
00094   /// E.g., the "32" in SunPro C++ 4.32.0
00095   extern ACE_Export u_int compiler_minor_version (void);
00096 
00097   /// E.g., the "0" in SunPro C++ 4.32.0
00098   extern ACE_Export u_int compiler_beta_version (void);
00099 
00100   /// Check if error indicates the process being out of handles (file
00101   /// descriptors).
00102   extern ACE_Export int out_of_handles (int error);
00103 
00104   /// Simple wildcard matching function supporting '*' and '?'
00105   /// return true if string s matches pattern.
00106   extern ACE_Export bool wild_match(const char* s, const char* pattern, bool case_sensitive = true);
00107 
00108   /**
00109    * @name I/O operations
00110    *
00111    * Notes on common parameters:
00112    *
00113    * @a handle is the connected endpoint that will be used for I/O.
00114    *
00115    * @a buf is the buffer to write from or receive into.
00116    *
00117    * @a len is the number of bytes to transfer.
00118    *
00119    * The @a timeout parameter in the following methods indicates how
00120    * long to blocking trying to transfer data.  If @a timeout == 0,
00121    * then the call behaves as a normal send/recv call, i.e., for
00122    * blocking sockets, the call will block until action is possible;
00123    * for non-blocking sockets, @c EWOULDBLOCK will be returned if no
00124    * action is immediately possible.
00125    *
00126    * If @a timeout != 0, the call will wait until the relative time
00127    * specified in  @a *timeout elapses.
00128    *
00129    * The "_n()" I/O methods keep looping until all the data has been
00130    * transferred.  These methods also work for sockets in non-blocking
00131    * mode i.e., they keep looping on @c EWOULDBLOCK.  @a timeout is
00132    * used to make sure we keep making progress, i.e., the same timeout
00133    * value is used for every I/O operation in the loop and the timeout
00134    * is not counted down.
00135    *
00136    * The return values for the "*_n()" methods match the return values
00137    * from the non "_n()" methods and are specified as follows:
00138    *
00139    * - On complete transfer, the number of bytes transferred is returned.
00140    * - On timeout, -1 is returned, @c errno == @c ETIME.
00141    * - On error, -1 is returned, @c errno is set to appropriate error.
00142    * - On @c EOF, 0 is returned, @c errno is irrelevant.
00143    *
00144    * On partial transfers, i.e., if any data is transferred before
00145    * timeout / error / @c EOF, @a bytes_transferred> will contain the
00146    * number of bytes transferred.
00147    *
00148    * Methods with @a iovec parameter are I/O vector variants of the
00149    * I/O operations.
00150    *
00151    * Methods with the extra @a flags argument will always result in
00152    * @c send getting called. Methods without the extra @a flags
00153    * argument will result in @c send getting called on Win32
00154    * platforms, and @c write getting called on non-Win32 platforms.
00155    */
00156   //@{
00157   extern ACE_Export ssize_t recv (ACE_HANDLE handle,
00158                                   void *buf,
00159                                   size_t len,
00160                                   int flags,
00161                                   const ACE_Time_Value *timeout = 0);
00162 
00163 #if defined (ACE_HAS_TLI)
00164 
00165   extern ACE_Export ssize_t t_rcv (ACE_HANDLE handle,
00166                                    void *buf,
00167                                    size_t len,
00168                                    int *flags,
00169                                    const ACE_Time_Value *timeout = 0);
00170 
00171 #endif /* ACE_HAS_TLI */
00172 
00173   extern ACE_Export ssize_t recv (ACE_HANDLE handle,
00174                                   void *buf,
00175                                   size_t len,
00176                                   const ACE_Time_Value *timeout = 0);
00177 
00178   extern ACE_Export ssize_t recvmsg (ACE_HANDLE handle,
00179                                      struct msghdr *msg,
00180                                      int flags,
00181                                      const ACE_Time_Value *timeout = 0);
00182 
00183   extern ACE_Export ssize_t recvfrom (ACE_HANDLE handle,
00184                                       char *buf,
00185                                       int len,
00186                                       int flags,
00187                                       struct sockaddr *addr,
00188                                       int *addrlen,
00189                                       const ACE_Time_Value *timeout = 0);
00190 
00191   ACE_NAMESPACE_INLINE_FUNCTION
00192   ssize_t recv_n (ACE_HANDLE handle,
00193                   void *buf,
00194                   size_t len,
00195                   int flags,
00196                   const ACE_Time_Value *timeout = 0,
00197                   size_t *bytes_transferred = 0);
00198 
00199 #if defined (ACE_HAS_TLI)
00200 
00201   ACE_NAMESPACE_INLINE_FUNCTION
00202   ssize_t t_rcv_n (ACE_HANDLE handle,
00203                    void *buf,
00204                    size_t len,
00205                    int *flags,
00206                    const ACE_Time_Value *timeout = 0,
00207                    size_t *bytes_transferred = 0);
00208 
00209 #endif /* ACE_HAS_TLI */
00210 
00211   ACE_NAMESPACE_INLINE_FUNCTION
00212   ssize_t recv_n (ACE_HANDLE handle,
00213                   void *buf,
00214                   size_t len,
00215                   const ACE_Time_Value *timeout = 0,
00216                   size_t *bytes_transferred = 0);
00217 
00218   /// Receive into a variable number of pieces.
00219   /**
00220    * Accepts a variable, caller-specified, number of pointer/length
00221    * pairs. Arguments following @a n are char *, size_t pairs.
00222    *
00223    * @param handle The I/O handle to receive on
00224    * @param n      The total number of char *, size_t pairs following @a n.
00225    *
00226    * @return -1 on error, else total number of bytes received.
00227    */
00228   extern ACE_Export ssize_t recv (ACE_HANDLE handle, size_t n, ...);
00229 
00230   extern ACE_Export ssize_t recvv (ACE_HANDLE handle,
00231                                    iovec *iov,
00232                                    int iovcnt,
00233                                    const ACE_Time_Value *timeout = 0);
00234 
00235   ACE_NAMESPACE_INLINE_FUNCTION
00236   ssize_t recvv_n (ACE_HANDLE handle,
00237                    iovec *iov,
00238                    int iovcnt,
00239                    const ACE_Time_Value *timeout = 0,
00240                    size_t *bytes_transferred = 0);
00241 
00242   extern ACE_Export ssize_t recv_n (ACE_HANDLE handle,
00243                                     ACE_Message_Block *message_block,
00244                                     const ACE_Time_Value *timeout = 0,
00245                                     size_t *bytes_transferred = 0);
00246 
00247   extern ACE_Export ssize_t send (ACE_HANDLE handle,
00248                                   const void *buf,
00249                                   size_t len,
00250                                   int flags,
00251                                   const ACE_Time_Value *timeout = 0);
00252 
00253 #if defined (ACE_HAS_TLI)
00254 
00255   extern ACE_Export ssize_t t_snd (ACE_HANDLE handle,
00256                                    const void *buf,
00257                                    size_t len,
00258                                    int flags,
00259                                    const ACE_Time_Value *timeout = 0);
00260 
00261 #endif /* ACE_HAS_TLI */
00262 
00263   extern ACE_Export ssize_t send (ACE_HANDLE handle,
00264                                   const void *buf,
00265                                   size_t len,
00266                                   const ACE_Time_Value *timeout = 0);
00267 
00268   extern ACE_Export ssize_t sendmsg (ACE_HANDLE handle,
00269                                      const struct msghdr *msg,
00270                                      int flags,
00271                                      const ACE_Time_Value *timeout = 0);
00272 
00273   extern ACE_Export ssize_t sendto (ACE_HANDLE handle,
00274                                     const char *buf,
00275                                     int len,
00276                                     int flags,
00277                                     const struct sockaddr *addr,
00278                                     int addrlen,
00279                                     const ACE_Time_Value *timeout = 0);
00280 
00281   ACE_NAMESPACE_INLINE_FUNCTION
00282   ssize_t send_n (ACE_HANDLE handle,
00283                   const void *buf,
00284                   size_t len,
00285                   int flags,
00286                   const ACE_Time_Value *timeout = 0,
00287                   size_t *bytes_transferred = 0);
00288 
00289 #if defined (ACE_HAS_TLI)
00290 
00291   ACE_NAMESPACE_INLINE_FUNCTION
00292   ssize_t t_snd_n (ACE_HANDLE handle,
00293                    const void *buf,
00294                    size_t len,
00295                    int flags,
00296                    const ACE_Time_Value *timeout = 0,
00297                    size_t *bytes_transferred = 0);
00298 
00299 #endif /* ACE_HAS_TLI */
00300 
00301   ACE_NAMESPACE_INLINE_FUNCTION
00302   ssize_t send_n (ACE_HANDLE handle,
00303                   const void *buf,
00304                   size_t len,
00305                   const ACE_Time_Value *timeout = 0,
00306                   size_t *bytes_transferred = 0);
00307 
00308   /// Varargs variant.
00309   extern ACE_Export ssize_t send (ACE_HANDLE handle, size_t n, ...);
00310 
00311   extern ACE_Export ssize_t sendv (ACE_HANDLE handle,
00312                                    const iovec *iov,
00313                                    int iovcnt,
00314                                    const ACE_Time_Value *timeout = 0);
00315 
00316   ACE_NAMESPACE_INLINE_FUNCTION
00317   ssize_t sendv_n (ACE_HANDLE handle,
00318                    const iovec *iov,
00319                    int iovcnt,
00320                    const ACE_Time_Value *timeout = 0,
00321                    size_t *bytes_transferred = 0);
00322 
00323   /// Send all the @a message_blocks chained through their @c next and
00324   /// @c cont pointers.  This call uses the underlying OS gather-write
00325   /// operation to reduce the domain-crossing penalty.
00326   extern ACE_Export ssize_t send_n (ACE_HANDLE handle,
00327                                     const ACE_Message_Block *message_block,
00328                                     const ACE_Time_Value *timeout = 0,
00329                                     size_t *bytes_transferred = 0);
00330 
00331   // = File system I/O functions (these don't support timeouts).
00332 
00333   ACE_NAMESPACE_INLINE_FUNCTION
00334   ssize_t read_n (ACE_HANDLE handle,
00335                   void *buf,
00336                   size_t len,
00337                   size_t *bytes_transferred = 0);
00338 
00339   ACE_NAMESPACE_INLINE_FUNCTION
00340   ssize_t write_n (ACE_HANDLE handle,
00341                    const void *buf,
00342                    size_t len,
00343                    size_t *bytes_transferred = 0);
00344 
00345   /// Write all the @a message_blocks chained through their @c next
00346   /// and @c cont pointers.  This call uses the underlying OS
00347   /// gather-write operation to reduce the domain-crossing penalty.
00348   extern ACE_Export ssize_t write_n (ACE_HANDLE handle,
00349                                      const ACE_Message_Block *message_block,
00350                                      size_t *bytes_transferred = 0);
00351 
00352   extern ACE_Export ssize_t readv_n (ACE_HANDLE handle,
00353                                      iovec *iov,
00354                                      int iovcnt,
00355                                      size_t *bytes_transferred = 0);
00356 
00357   extern ACE_Export ssize_t writev_n (ACE_HANDLE handle,
00358                                       const iovec *iov,
00359                                       int iovcnt,
00360                                       size_t *bytes_transferred = 0);
00361   //@}
00362 
00363   /**
00364    * Wait up to @a timeout amount of time to passively establish a
00365    * connection.  This method doesn't perform the @c accept, it just
00366    * does the timed wait.
00367    */
00368   extern ACE_Export int handle_timed_accept (ACE_HANDLE listener,
00369                                              ACE_Time_Value *timeout,
00370                                              int restart);
00371 
00372   /**
00373    * Wait up to @a timeout amount of time to complete an actively
00374    * established non-blocking connection.  If @a is_tli is non-0 then
00375    * we are being called by a TLI wrapper (which behaves slightly
00376    * differently from a socket wrapper).
00377    */
00378   extern ACE_Export ACE_HANDLE handle_timed_complete (
00379     ACE_HANDLE listener,
00380     const ACE_Time_Value *timeout,
00381     int is_tli = 0);
00382 
00383   /**
00384    * Reset the limit on the number of open handles.  If @a new_limit
00385    * == -1 set the limit to the maximum allowable.  Otherwise, set
00386    * the limit value to @a new_limit.  If @a increase_limit_only is
00387    * non-0 then only allow increases to the limit.
00388    */
00389   extern ACE_Export int set_handle_limit (int new_limit = -1,
00390                                           int increase_limit_only = 0);
00391 
00392   /**
00393    * Returns the maximum number of open handles currently permitted in
00394    * this process.  This maximum may be extended using
00395    * @c ACE::set_handle_limit.
00396    */
00397   extern ACE_Export int max_handles (void);
00398 
00399   // = String functions
00400 #if !defined (ACE_HAS_WINCE)
00401   /**
00402    * Return a dynamically allocated duplicate of @a str, substituting
00403    * the environment variable if @c str[0] @c == @c '$'.  Note that
00404    * the pointer is allocated with @c ACE_OS::malloc and must be freed
00405    * by @c ACE_OS::free.
00406    */
00407   extern ACE_Export ACE_TCHAR *strenvdup (const ACE_TCHAR *str);
00408 #endif /* ACE_HAS_WINCE */
00409 
00410   /// Returns a pointer to the "end" of the string, i.e., the character
00411   /// past the '\0'.
00412   extern ACE_Export const char *strend (const char *s);
00413 
00414   /// This method is just like @c strdup, except that it uses
00415   /// @c operator @c new rather than @c malloc.  If @a s is NULL
00416   /// returns NULL rather than segfaulting.
00417   extern ACE_Export char *strnew (const char *s);
00418 
00419   /// Delete the memory allocated by @c strnew.
00420   ACE_NAMESPACE_INLINE_FUNCTION void strdelete (char *s);
00421 
00422   /// Create a fresh new copy of @a str, up to @a n chars long.  Uses
00423   /// @c ACE_OS::malloc to allocate the new string.
00424   extern ACE_Export char *strndup (const char *str, size_t n);
00425 
00426   /// Create a fresh new copy of @a str, up to @a n chars long.  Uses
00427   /// @c ACE_OS::malloc to allocate the new string.
00428   extern ACE_Export char *strnnew (const char *str, size_t n);
00429 
00430 #if defined (ACE_HAS_WCHAR)
00431   extern ACE_Export const wchar_t *strend (const wchar_t *s);
00432 
00433   extern ACE_Export wchar_t *strnew (const wchar_t *s);
00434 
00435   ACE_NAMESPACE_INLINE_FUNCTION void strdelete (wchar_t *s);
00436 
00437   extern ACE_Export wchar_t *strndup (const wchar_t *str, size_t n);
00438 
00439   extern ACE_Export wchar_t *strnnew (const wchar_t *str, size_t n);
00440 
00441 #endif /* ACE_HAS_WCHAR */
00442 
00443   /**
00444    * On Windows, determines if a specified pathname ends with ".exe"
00445    * (not case sensitive). If on Windows and there is no ".exe" suffix,
00446    * a new ACE_TCHAR array is allocated and a copy of @c pathname with
00447    * the ".exe" suffix is copied into it. In this case, the caller is
00448    * responsible for calling delete [] on the returned pointer.
00449    *
00450    * @param pathname  The name to check for a proper suffix.
00451    *
00452    * @retval @c pathname if there is a proper suffix for Windows. This is
00453    *         always the return value for non-Windows platforms.
00454    * @retval If a suffix needs to be added, returns a pointer to new[]
00455    *         allocated memory containing the original @c pathname plus
00456    *         a ".exe" suffix. The caller is responsible for freeing the
00457    *         memory using delete [].
00458    */
00459   extern ACE_Export const ACE_TCHAR *execname (const ACE_TCHAR *pathname);
00460 
00461   /**
00462    * Returns the "basename" of a @a pathname separated by @a delim.
00463    * For instance, the basename of "/tmp/foo.cpp" is "foo.cpp" when
00464    * @a delim is @a '/'.
00465    */
00466   extern ACE_Export const ACE_TCHAR *basename (const ACE_TCHAR *pathname,
00467                                                ACE_TCHAR delim =
00468                                                ACE_DIRECTORY_SEPARATOR_CHAR);
00469 
00470   /**
00471    * Returns the "dirname" of a @a pathname.  For instance, the
00472    * dirname of "/tmp/foo.cpp" is "/tmp" when @a delim is @a '/'.  If
00473    * @a pathname has no @a delim ".\0" is returned.  This method does
00474    * not modify @a pathname and is not reentrant.
00475    */
00476   extern ACE_Export const ACE_TCHAR *dirname (const ACE_TCHAR *pathname,
00477                                               ACE_TCHAR delim =
00478                                               ACE_DIRECTORY_SEPARATOR_CHAR);
00479 
00480   /**
00481    * Returns the current timestamp in the form
00482    * "hour:minute:second:microsecond."  The month, day, and year are
00483    * also stored in the beginning of the @a date_and_time array, which
00484    * is a user-supplied array of size @a time_len> @c ACE_TCHARs.
00485    * Returns 0 if unsuccessful, else returns pointer to beginning of the
00486    * "time" portion of @a date_and_time.  If @a
00487    * return_pointer_to_first_digit is 0 then return a pointer to the
00488    * space before the time, else return a pointer to the beginning of
00489    * the time portion.
00490    */
00491   extern ACE_Export ACE_TCHAR *timestamp (ACE_TCHAR date_and_time[],
00492                                           int time_len,
00493                                           int return_pointer_to_first_digit =
00494                                             0);
00495 
00496   /**
00497    * if @a avoid_zombies == 0 call @c ACE_OS::fork directly, else
00498    * create an orphan process that's inherited by the init process;
00499    * init cleans up when the orphan process terminates so we don't
00500    * create zombies.  Returns -1 on failure and either the child PID
00501    * on success if @a avoid_zombies == 0 or 1 on success if @a
00502    * avoid_zombies != 0 (this latter behavior is a known bug that
00503    * needs to be fixed).
00504    */
00505   extern ACE_Export pid_t fork (
00506     const ACE_TCHAR *program_name = ACE_LIB_TEXT ("<unknown>"),
00507     int avoid_zombies = 0);
00508 
00509   /**
00510    * Become a daemon process using the algorithm in Richard Stevens
00511    * "Advanced Programming in the UNIX Environment."  If
00512    * @a close_all_handles is non-zero then all open file handles are
00513    * closed.
00514    */
00515   extern ACE_Export int daemonize (
00516     const ACE_TCHAR pathname[] = ACE_LIB_TEXT ("/"),
00517     int close_all_handles = ACE_DEFAULT_CLOSE_ALL_HANDLES,
00518     const ACE_TCHAR program_name[] = ACE_LIB_TEXT ("<unknown>"));
00519 
00520   // = Miscellaneous functions.
00521   /// Rounds the request to a multiple of the page size.
00522   extern ACE_Export size_t round_to_pagesize (off_t len);
00523 
00524   /// Rounds the request to a multiple of the allocation granularity.
00525   extern ACE_Export size_t round_to_allocation_granularity (off_t len);
00526 
00527   // @@ UNICODE what about buffer?
00528   /// Format buffer into printable format.  This is useful for
00529   /// debugging.
00530   extern ACE_Export size_t format_hexdump (const char *buffer, size_t size,
00531                                            ACE_TCHAR *obuf, size_t obuf_sz);
00532 
00533   /// Computes the hash value of {str} using the "Hash PJW" routine.
00534   extern ACE_Export u_long hash_pjw (const char *str);
00535 
00536   /// Computes the hash value of {str} using the "Hash PJW" routine.
00537   extern ACE_Export u_long hash_pjw (const char *str, size_t len);
00538 
00539 #if defined (ACE_HAS_WCHAR)
00540   /// Computes the hash value of {str} using the "Hash PJW" routine.
00541   extern ACE_Export u_long hash_pjw (const wchar_t *str);
00542 
00543   /// Computes the hash value of {str} using the "Hash PJW" routine.
00544   extern ACE_Export u_long hash_pjw (const wchar_t *str, size_t len);
00545 #endif /* ACE_HAS_WCHAR */
00546 
00547   /// Computes CRC-CCITT for the string.
00548   extern ACE_Export ACE_UINT16 crc_ccitt(const char *str);
00549 
00550   /// Computes CRC-CCITT for the buffer.
00551   extern ACE_Export ACE_UINT16 crc_ccitt(const void *buf, size_t len,
00552            ACE_UINT16 crc = 0);
00553 
00554   /// Computes CRC-CCITT for the @ len iovec buffers.
00555   extern ACE_Export ACE_UINT16 crc_ccitt(const iovec *iov, int len,
00556            ACE_UINT16 crc = 0);
00557 
00558   /// Computes the ISO 8802-3 standard 32 bits CRC for the string.
00559   extern ACE_Export ACE_UINT32 crc32 (const char *str);
00560 
00561   /// Computes the ISO 8802-3 standard 32 bits CRC for the buffer.
00562   extern ACE_Export ACE_UINT32 crc32 (const void *buf, size_t len,
00563               ACE_UINT32 crc = 0);
00564 
00565   /// Computes the ISO 8802-3 standard 32 bits CRC for the
00566   /// @ len iovec buffers.
00567   extern ACE_Export ACE_UINT32 crc32 (const iovec *iov, int len,
00568               ACE_UINT32 crc = 0);
00569 
00570   /// Euclid's greatest common divisor algorithm.
00571   extern ACE_Export u_long gcd (u_long x, u_long y);
00572 
00573   /// Calculates the minimum enclosing frame size for the given values.
00574   extern ACE_Export u_long minimum_frame_size (u_long period1, u_long period2);
00575 
00576   /**
00577    * Function that can burn up noticeable CPU time:  brute-force
00578    * determination of whether number @a n is prime.  Returns 0 if
00579    * it is prime, or the smallest factor if it is not prime.
00580    * @a min_factor and @a max_factor can be used to partition the work
00581    * among threads. For just one thread, typical values are 2 and
00582    * n/2.
00583    */
00584   extern ACE_Export u_long is_prime (const u_long n,
00585                                      const u_long min_factor,
00586                                      const u_long max_factor);
00587 
00588   /// Map troublesome win32 errno values to values that standard C
00589   /// strerr function understands.  Thank you Microsoft.
00590   extern ACE_Export int map_errno (int error);
00591 
00592   /// Returns a string containing the error message corresponding to a
00593   /// WinSock error.  This works around an omission in the Win32 API.
00594   /// @internal
00595   extern ACE_Export const ACE_TCHAR * sock_error (int error);
00596 
00597   /// Determins whether the given error code corresponds to to a
00598   /// WinSock error. If so returns true, false otherwise.
00599   /// @internal
00600   extern ACE_Export bool is_sock_error (int error);
00601 
00602   /**
00603    * Checks if process with {pid} is still alive.  Returns 1 if it is
00604    * still alive, 0 if it isn't alive, and -1 if something weird
00605    * happened.
00606    */
00607   extern ACE_Export int process_active (pid_t pid);
00608 
00609   /**
00610    * Terminate the process abruptly with id @a pid.  On Win32 platforms
00611    * this uses {TerminateProcess} and on POSIX platforms is uses
00612    * {kill} with the -9 (SIGKILL) signal, which cannot be caught or
00613    * ignored.  Note that this call is potentially dangerous to use
00614    * since the process being terminated may not have a chance to
00615    * cleanup before it shuts down.
00616    */
00617   extern ACE_Export int terminate_process (pid_t pid);
00618 
00619   /**
00620    * This method uses process id and object pointer to come up with a
00621    * machine wide unique name.  The process ID will provide uniqueness
00622    * between processes on the same machine. The "this" pointer of the
00623    * {object} will provide uniqueness between other "live" objects in
00624    * the same process. The uniqueness of this name is therefore only
00625    * valid for the life of {object}.
00626    */
00627   ACE_NAMESPACE_INLINE_FUNCTION void unique_name (const void *object,
00628                                                   ACE_TCHAR *name,
00629                                                   size_t length);
00630 
00631   /// Computes the base 2 logarithm of {num}.
00632   ACE_NAMESPACE_INLINE_FUNCTION u_long log2 (u_long num);
00633 
00634   /// Hex conversion utility.
00635   ACE_NAMESPACE_INLINE_FUNCTION ACE_TCHAR nibble2hex (u_int n);
00636 
00637   /// Convert a hex character to its byte representation.
00638   ACE_NAMESPACE_INLINE_FUNCTION u_char hex2byte (ACE_TCHAR c);
00639 
00640   // = Set/get the debug level.
00641   extern ACE_Export char debug (void);
00642   extern ACE_Export void debug (char d);
00643 
00644   /// Wrapper facade for @c select that uses @c ACE_Handle_Sets.
00645   extern ACE_Export int select (int width,
00646                                 ACE_Handle_Set *readfds,
00647                                 ACE_Handle_Set *writefds = 0,
00648                                 ACE_Handle_Set *exceptfds = 0,
00649                                 const ACE_Time_Value *timeout = 0);
00650 
00651   /// Wrapper facade for the most common use of @c select that uses
00652   /// @c ACE_Handle_Sets.
00653   extern ACE_Export int select (int width,
00654                                 ACE_Handle_Set &readfds,
00655                                 const ACE_Time_Value *timeout = 0);
00656 
00657   /// Timed wait for handle to get read ready.
00658   ACE_NAMESPACE_INLINE_FUNCTION
00659   int handle_read_ready (ACE_HANDLE handle,
00660                          const ACE_Time_Value *timeout);
00661 
00662   /// Timed wait for handle to get write ready.
00663   ACE_NAMESPACE_INLINE_FUNCTION
00664   int handle_write_ready (ACE_HANDLE handle,
00665                           const ACE_Time_Value *timeout);
00666 
00667   /// Timed wait for handle to get exception ready.
00668   ACE_NAMESPACE_INLINE_FUNCTION
00669   int handle_exception_ready (ACE_HANDLE handle,
00670                               const ACE_Time_Value *timeout);
00671 
00672   /// Timed wait for handle to get read, write, or exception ready.
00673   extern ACE_Export int handle_ready (ACE_HANDLE handle,
00674                                       const ACE_Time_Value *timeout,
00675                                       int read_ready,
00676                                       int write_ready,
00677                                       int exception_ready);
00678 
00679   /// Wait for @a timeout before proceeding to a @c recv operation.
00680   /// @a val keeps track of whether we're in non-blocking mode or
00681   /// not.
00682   extern ACE_Export int enter_recv_timedwait (ACE_HANDLE handle,
00683                                               const ACE_Time_Value *timeout,
00684                                               int &val);
00685 
00686   /// Wait for @a timeout before proceeding to a @c send operation.
00687   /// @a val keeps track of whether we're in non-blocking mode or
00688   /// not.
00689   extern ACE_Export int enter_send_timedwait (ACE_HANDLE handle,
00690                                               const ACE_Time_Value* timeout,
00691                                               int &val);
00692 
00693   /// This makes sure that @a handle is set into non-blocking mode.
00694   /// @a val keeps track of whether were in non-blocking mode or not.
00695   extern ACE_Export void record_and_set_non_blocking_mode (ACE_HANDLE handle,
00696                                                            int &val);
00697 
00698   /// Cleanup after a timed operation, restore the appropriate
00699   /// non-blocking status of @a handle.
00700   extern ACE_Export void restore_non_blocking_mode (ACE_HANDLE handle,
00701                                                     int val);
00702 
00703   // private:
00704   //   These functions aren't meant to be used internally, so they are
00705   //   not exported.
00706 
00707   //
00708   // = Recv_n helpers
00709   //
00710 
00711   ACE_NAMESPACE_INLINE_FUNCTION ssize_t recv_i (ACE_HANDLE handle,
00712                                                 void *buf,
00713                                                 size_t len);
00714 
00715   extern ACE_Export ssize_t recv_n_i (ACE_HANDLE handle,
00716                                       void *buf,
00717                                       size_t len,
00718                                       int flags,
00719                                       size_t *bytes_transferred);
00720 
00721   extern ACE_Export ssize_t recv_n_i (ACE_HANDLE handle,
00722                                       void *buf,
00723                                       size_t len,
00724                                       int flags,
00725                                       const ACE_Time_Value *timeout,
00726                                       size_t *bytes_transferred);
00727 
00728 #if defined (ACE_HAS_TLI)
00729 
00730   extern ACE_Export ssize_t t_rcv_n_i (ACE_HANDLE handle,
00731                                        void *buf,
00732                                        size_t len,
00733                                        int *flags,
00734                                        size_t *bytes_transferred);
00735 
00736   extern ACE_Export ssize_t t_rcv_n_i (ACE_HANDLE handle,
00737                                        void *buf,
00738                                        size_t len,
00739                                        int *flags,
00740                                        const ACE_Time_Value *timeout,
00741                                        size_t *bytes_transferred);
00742 
00743 #endif /* ACE_HAS_TLI */
00744 
00745   extern ACE_Export ssize_t recv_n_i (ACE_HANDLE handle,
00746                                       void *buf,
00747                                       size_t len,
00748                                       size_t *bytes_transferred);
00749 
00750   extern ACE_Export ssize_t recv_n_i (ACE_HANDLE handle,
00751                                       void *buf,
00752                                       size_t len,
00753                                       const ACE_Time_Value *timeout,
00754                                       size_t *bytes_transferred);
00755 
00756   extern ACE_Export ssize_t recvv_n_i (ACE_HANDLE handle,
00757                                        iovec *iov,
00758                                        int iovcnt,
00759                                        size_t *bytes_transferred);
00760 
00761   extern ACE_Export ssize_t recvv_n_i (ACE_HANDLE handle,
00762                                        iovec *iov,
00763                                        int iovcnt,
00764                                        const ACE_Time_Value *timeout,
00765                                        size_t *bytes_transferred);
00766 
00767   //
00768   // = Send_n helpers
00769   //
00770 
00771   ACE_NAMESPACE_INLINE_FUNCTION ssize_t send_i (ACE_HANDLE handle,
00772                                                 const void *buf,
00773                                                 size_t len);
00774 
00775   extern ACE_Export ssize_t send_n_i (ACE_HANDLE handle,
00776                                       const void *buf,
00777                                       size_t len,
00778                                       int flags,
00779                                       size_t *bytes_transferred);
00780 
00781   extern ACE_Export ssize_t send_n_i (ACE_HANDLE handle,
00782                                       const void *buf,
00783                                       size_t len,
00784                                       int flags,
00785                                       const ACE_Time_Value *timeout,
00786                                       size_t *bytes_transferred);
00787 
00788 #if defined (ACE_HAS_TLI)
00789 
00790   extern ACE_Export ssize_t t_snd_n_i (ACE_HANDLE handle,
00791                                        const void *buf,
00792                                        size_t len,
00793                                        int flags,
00794                                        size_t *bytes_transferred);
00795 
00796   extern ACE_Export ssize_t t_snd_n_i (ACE_HANDLE handle,
00797                                        const void *buf,
00798                                        size_t len,
00799                                        int flags,
00800                                        const ACE_Time_Value *timeout,
00801                                        size_t *bytes_transferred);
00802 
00803 #endif /* ACE_HAS_TLI */
00804 
00805   extern ACE_Export ssize_t send_n_i (ACE_HANDLE handle,
00806                                       const void *buf,
00807                                       size_t len,
00808                                       size_t *bytes_transferred);
00809 
00810   extern ACE_Export ssize_t send_n_i (ACE_HANDLE handle,
00811                                       const void *buf,
00812                                       size_t len,
00813                                       const ACE_Time_Value *timeout,
00814                                       size_t *bytes_transferred);
00815 
00816   extern ACE_Export ssize_t sendv_n_i (ACE_HANDLE handle,
00817                                        const iovec *iov,
00818                                        int iovcnt,
00819                                        size_t *bytes_transferred);
00820 
00821   extern ACE_Export ssize_t sendv_n_i (ACE_HANDLE handle,
00822                                        const iovec *iov,
00823                                        int iovcnt,
00824                                        const ACE_Time_Value *timeout,
00825                                        size_t *bytes_transferred);
00826 
00827 }
00828 
00829 // Close versioned namespace, if enabled by the user.
00830 ACE_END_VERSIONED_NAMESPACE_DECL
00831 
00832 #if defined (__ACE_INLINE__)
00833 #include "ace/ACE.inl"
00834 #endif /* __ACE_INLINE__ */
00835 
00836 #if defined (acelog2)
00837 # define log2 acelog2
00838 #endif /* acelog2 */
00839 
00840 #include /**/ "ace/post.h"
00841 
00842 #endif  /* ACE_ACE_H */

Generated on Thu Nov 9 09:41:45 2006 for ACE by doxygen 1.3.6