Home | History | Annotate | Download | only in include
      1 /*---------------------------------------------------------------------------*
      2  *  ESR_ReturnCode.h  *
      3  *                                                                           *
      4  *  Copyright 2007, 2008 Nuance Communciations, Inc.                               *
      5  *                                                                           *
      6  *  Licensed under the Apache License, Version 2.0 (the 'License');          *
      7  *  you may not use this file except in compliance with the License.         *
      8  *                                                                           *
      9  *  You may obtain a copy of the License at                                  *
     10  *      http://www.apache.org/licenses/LICENSE-2.0                           *
     11  *                                                                           *
     12  *  Unless required by applicable law or agreed to in writing, software      *
     13  *  distributed under the License is distributed on an 'AS IS' BASIS,        *
     14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
     15  *  See the License for the specific language governing permissions and      *
     16  *  limitations under the License.                                           *
     17  *                                                                           *
     18  *---------------------------------------------------------------------------*/
     19 
     20 #ifndef ESR_RETURNCODE_H
     21 #define ESR_RETURNCODE_H
     22 
     23 
     24 
     25 #include "PortPrefix.h"
     26 
     27 /**
     28  * @addtogroup ESR_PortableModule ESR_Portable API functions
     29  *
     30  * @{
     31  */
     32 
     33 /**
     34  * Return-code values.
     35  */
     36 typedef enum ESR_ReturnCode_t
     37 {
     38   /*
     39    * Note: do not forget to modify ESR_rc2str when modifying this enum.
     40    */
     41 
     42   /**
     43    * Operation completed successfully.
     44    */
     45   ESR_SUCCESS,
     46 
     47   /**
     48    * Intermediate stage of operation completed successfully, we wish to indicate
     49    * that remainig stages of operation may proceed.
     50    */
     51   ESR_CONTINUE_PROCESSING,
     52 
     53   /**
     54    * Indicates a fatal error.
     55    */
     56   ESR_FATAL_ERROR,
     57 
     58   /**
     59    * Buffer overflow occured.
     60    */
     61   ESR_BUFFER_OVERFLOW,
     62 
     63   /**
     64    * Error typing to open an entity or the operation failed because the entity was not opened.
     65    */
     66   ESR_OPEN_ERROR,
     67 
     68   /**
     69    * Error trying to open an entity that is already open.
     70    */
     71   ESR_ALREADY_OPEN,
     72 
     73   /**
     74    * Error typing to close a entity or the operation failed because the entity was not closed.
     75    */
     76   ESR_CLOSE_ERROR,
     77 
     78   /**
     79    * Error trying to close a entity that was already closed.
     80    */
     81   ESR_ALREADY_CLOSED,
     82 
     83   /**
     84    * Error trying to read a file.
     85    */
     86   ESR_READ_ERROR,
     87 
     88   /**
     89    * Error trying to write to a entity.
     90    */
     91   ESR_WRITE_ERROR,
     92 
     93   /**
     94    * Error trying to flush a entity.
     95    */
     96   ESR_FLUSH_ERROR,
     97 
     98   /**
     99    * Error trying to seek a entity.
    100    */
    101   ESR_SEEK_ERROR,
    102 
    103   /**
    104    * Error trying to allocate memory.
    105    */
    106   ESR_OUT_OF_MEMORY,
    107 
    108   /**
    109    * Specified argument is out of bounds.
    110    */
    111   ESR_ARGUMENT_OUT_OF_BOUNDS,
    112 
    113   /**
    114    * Failed to locate the specified entity.
    115    */
    116   ESR_NO_MATCH_ERROR,
    117 
    118   /**
    119    * Passed in argument contains an invalid value. Such as when a NULL pointer
    120    * is passed in when when an actual value is expected.
    121    */
    122   ESR_INVALID_ARGUMENT,
    123 
    124   /**
    125    * Indicates that request functionality is not supported.
    126    */
    127   ESR_NOT_SUPPORTED,
    128 
    129   /**
    130    * Indicates that the object is not in a state such that the operation can
    131    * be succesfully performed.
    132    */
    133   ESR_INVALID_STATE,
    134 
    135   /**
    136    * Indicates that a thread could not be created.
    137    */
    138   ESR_THREAD_CREATION_ERROR,
    139 
    140   /**
    141    * Indicates that a resource with the same identifier already exists.
    142    */
    143   ESR_IDENTIFIER_COLLISION,
    144 
    145   /**
    146    * Indicates that the operation timed out.
    147    */
    148   ESR_TIMED_OUT,
    149 
    150   /**
    151    * Indicates that the object being retrieved isn't of the expected type.
    152    * For example, when retrieving an integer from a HashMap we find out the
    153    * value is actually of type float.
    154    */
    155   ESR_INVALID_RESULT_TYPE,
    156 
    157   /**
    158    * Indicates that the invoked function has not been implemented.
    159    */
    160   ESR_NOT_IMPLEMENTED,
    161 
    162   /**
    163    * A connection was forcibly closed by a peer. This normally results from
    164    * a loss of the connection on the remote socket due to a timeout or a reboot.
    165    */
    166   ESR_CONNECTION_RESET_BY_PEER,
    167 
    168   /**
    169    * Indicates that a process could not be created.
    170    */
    171   ESR_PROCESS_CREATE_ERROR,
    172 
    173   /**
    174    * Indicates that no matching TTS engine is available.
    175    */
    176   ESR_TTS_NO_ENGINE,
    177 
    178   /**
    179    * Indicates that an attempt to create a mutex failed because the OS is running out of resources.
    180    */
    181   ESR_MUTEX_CREATION_ERROR,
    182 
    183   /**
    184    * Indicates a deadlock situation has occured.
    185    */
    186   ESR_DEADLOCK
    187 } ESR_ReturnCode;
    188 
    189 
    190 /**
    191  * Checks the function return-code and if it is not ESR_SUCCESS, returns it.
    192  */
    193 #define CHK(rc, x) do { if ((rc = (x)) != ESR_SUCCESS) goto CLEANUP; } while (0)
    194 
    195 #include "ptypes.h"
    196 
    197 /**
    198  * Given a return-code, returns its string representation.
    199  *
    200  * @param rc Return-code
    201  * @return String representation of return-code.
    202  */
    203 PORTABLE_API const LCHAR* ESR_rc2str(const ESR_ReturnCode rc);
    204 
    205 #ifdef _WIN32
    206 /**
    207  * Called before entering any function.
    208  */
    209 PORTABLE_API void _cdecl _penter(void);
    210 /**
    211  * Called after exiting any function.
    212  */
    213 PORTABLE_API void _cdecl _pexit(void);
    214 #endif
    215 
    216 /**
    217  * @}
    218  */
    219 
    220 #endif
    221