~ubuntu-branches/ubuntu/raring/virtualbox-ose/raring

« back to all changes in this revision

Viewing changes to include/iprt/err.h

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-01-30 23:27:25 UTC
  • mfrom: (0.3.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20110130232725-2ouajjd2ggdet0zd
Tags: 4.0.2-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Drop ubuntu-01-fix-build-gcc45.patch, fixed upstream.
* Drop ubuntu-02-as-needed.patch, added to the Debian package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 */
4
4
 
5
5
/*
6
 
 * Copyright (C) 2006-2009 Oracle Corporation
 
6
 * Copyright (C) 2006-2010 Oracle Corporation
7
7
 *
8
8
 * This file is part of VirtualBox Open Source Edition (OSE), as
9
9
 * available from http://www.virtualbox.org. This file is free software;
28
28
 
29
29
#include <iprt/cdefs.h>
30
30
#include <iprt/types.h>
 
31
#include <iprt/stdarg.h>
31
32
 
32
 
RT_C_DECLS_BEGIN
33
33
 
34
34
/** @defgroup grp_rt_err            RTErr - Status Codes
35
35
 * @ingroup grp_rt
 
36
 *
 
37
 * The IPRT status codes are in two ranges: {0..999} and {22000..32766}.  The
 
38
 * IPRT users are free to use the range {1000..21999}.  See RTERR_RANGE1_FIRST,
 
39
 * RTERR_RANGE1_LAST, RTERR_RANGE2_FIRST, RTERR_RANGE2_LAST, RTERR_USER_FIRST
 
40
 * and RTERR_USER_LAST.
 
41
 *
36
42
 * @{
37
43
 */
38
44
 
176
182
 */
177
183
#define RT_FAILURE_NP(rc)   ( !RT_SUCCESS_NP(rc) )
178
184
 
 
185
RT_C_DECLS_BEGIN
 
186
 
179
187
/**
180
188
 * Converts a Darwin HRESULT error to an iprt status code.
181
189
 *
272
280
 */
273
281
RTDECL(int)  RTErrConvertToErrno(int iErr);
274
282
 
275
 
 
276
283
#ifdef IN_RING3
277
284
 
278
285
/**
385
392
 
386
393
#endif /* IN_RING3 */
387
394
 
388
 
/** @} */
 
395
/** @defgroup RTERRINFO_FLAGS_XXX   RTERRINFO::fFlags
 
396
 * @{ */
 
397
/** Custom structure (the default). */
 
398
#define RTERRINFO_FLAGS_T_CUSTOM    UINT32_C(0)
 
399
/** Static structure (RTERRINFOSTATIC). */
 
400
#define RTERRINFO_FLAGS_T_STATIC    UINT32_C(1)
 
401
/** Allocated structure (RTErrInfoAlloc). */
 
402
#define RTERRINFO_FLAGS_T_ALLOC     UINT32_C(2)
 
403
/** Reserved type. */
 
404
#define RTERRINFO_FLAGS_T_RESERVED  UINT32_C(3)
 
405
/** Type mask. */
 
406
#define RTERRINFO_FLAGS_T_MASK      UINT32_C(3)
 
407
/** Error info is set. */
 
408
#define RTERRINFO_FLAGS_SET         RT_BIT_32(2)
 
409
/** Fixed flags (magic). */
 
410
#define RTERRINFO_FLAGS_MAGIC       UINT32_C(0xbabe0000)
 
411
/** The bit mask for the magic value. */
 
412
#define RTERRINFO_FLAGS_MAGIC_MASK  UINT32_C(0xffff0000)
 
413
/** @} */
 
414
 
 
415
/**
 
416
 * Initializes an error info structure.
 
417
 *
 
418
 * @returns @a pErrInfo.
 
419
 * @param   pErrInfo            The error info structure to init.
 
420
 * @param   pszMsg              The message buffer.  Must be at least one byte.
 
421
 * @param   cbMsg               The size of the message buffer.
 
422
 */
 
423
DECLINLINE(PRTERRINFO) RTErrInfoInit(PRTERRINFO pErrInfo, char *pszMsg, size_t cbMsg)
 
424
{
 
425
    *pszMsg = '\0';
 
426
 
 
427
    pErrInfo->fFlags         = RTERRINFO_FLAGS_T_CUSTOM | RTERRINFO_FLAGS_MAGIC;
 
428
    pErrInfo->rc             = /*VINF_SUCCESS*/ 0;
 
429
    pErrInfo->pszMsg         = pszMsg;
 
430
    pErrInfo->cbMsg          = cbMsg;
 
431
    pErrInfo->apvReserved[0] = NULL;
 
432
    pErrInfo->apvReserved[1] = NULL;
 
433
 
 
434
    return pErrInfo;
 
435
}
 
436
 
 
437
/**
 
438
 * Initialize a static error info structure.
 
439
 *
 
440
 * @param   pStaticErrInfo      The static error info structure to init.
 
441
 */
 
442
DECLINLINE(void) RTErrInfoInitStatic(PRTERRINFOSTATIC pStaticErrInfo)
 
443
{
 
444
    RTErrInfoInit(&pStaticErrInfo->Core, pStaticErrInfo->szMsg, sizeof(pStaticErrInfo->szMsg));
 
445
    pStaticErrInfo->Core.fFlags = RTERRINFO_FLAGS_T_STATIC | RTERRINFO_FLAGS_MAGIC;
 
446
}
 
447
 
 
448
/**
 
449
 * Allocates a error info structure with a buffer at least the given size.
 
450
 *
 
451
 * @returns Pointer to an error info structure on success, NULL on failure.
 
452
 *
 
453
 * @param   cbMsg               The minimum message buffer size.  Use 0 to get
 
454
 *                              the default buffer size.
 
455
 */
 
456
RTDECL(PRTERRINFO)  RTErrInfoAlloc(size_t cbMsg);
 
457
 
 
458
/**
 
459
 * Same as RTErrInfoAlloc, except that an IPRT status code is returned.
 
460
 *
 
461
 * @returns IPRT status code.
 
462
 *
 
463
 * @param   cbMsg               The minimum message buffer size.  Use 0 to get
 
464
 *                              the default buffer size.
 
465
 * @param   ppErrInfo           Where to store the pointer to the allocated
 
466
 *                              error info structure on success.  This is
 
467
 *                              always set to NULL.
 
468
 */
 
469
RTDECL(int)         RTErrInfoAllocEx(size_t cbMsg, PRTERRINFO *ppErrInfo);
 
470
 
 
471
/**
 
472
 * Frees an error info structure allocated by RTErrInfoAlloc or
 
473
 * RTErrInfoAllocEx.
 
474
 *
 
475
 * @param   pErrInfo            The error info structure.
 
476
 */
 
477
RTDECL(void)        RTErrInfoFree(PRTERRINFO pErrInfo);
 
478
 
 
479
/**
 
480
 * Fills in the error info details.
 
481
 *
 
482
 * @returns @a rc.
 
483
 *
 
484
 * @param   pErrInfo            The error info structure to fill in.
 
485
 * @param   rc                  The status code to return.
 
486
 * @param   pszMsg              The error message string.
 
487
 */
 
488
RTDECL(int)         RTErrInfoSet(PRTERRINFO pErrInfo, int rc, const char *pszMsg);
 
489
 
 
490
/**
 
491
 * Fills in the error info details, with a sprintf style message.
 
492
 *
 
493
 * @returns @a rc.
 
494
 *
 
495
 * @param   pErrInfo            The error info structure to fill in.
 
496
 * @param   rc                  The status code to return.
 
497
 * @param   pszFormat           The format string.
 
498
 * @param   ...                 The format arguments.
 
499
 */
 
500
RTDECL(int)         RTErrInfoSetF(PRTERRINFO pErrInfo, int rc, const char *pszFormat, ...);
 
501
 
 
502
/**
 
503
 * Fills in the error info details, with a vsprintf style message.
 
504
 *
 
505
 * @returns @a rc.
 
506
 *
 
507
 * @param   pErrInfo            The error info structure to fill in.
 
508
 * @param   rc                  The status code to return.
 
509
 * @param   pszFormat           The format string.
 
510
 * @param   va                  The format arguments.
 
511
 */
 
512
RTDECL(int)         RTErrInfoSetV(PRTERRINFO pErrInfo, int rc, const char *pszFormat, va_list va);
 
513
 
 
514
/**
 
515
 * Checks if the error info is set.
 
516
 *
 
517
 * @returns true if set, false if not.
 
518
 * @param   pErrInfo            The error info structure. NULL is OK.
 
519
 */
 
520
DECLINLINE(bool)    RTErrInfoIsSet(PCRTERRINFO pErrInfo)
 
521
{
 
522
    if (!pErrInfo)
 
523
        return false;
 
524
    return (pErrInfo->fFlags & (RTERRINFO_FLAGS_MAGIC_MASK | RTERRINFO_FLAGS_SET))
 
525
        == (RTERRINFO_FLAGS_MAGIC | RTERRINFO_FLAGS_SET);
 
526
}
 
527
 
 
528
/**
 
529
 * Clears the error info structure.
 
530
 *
 
531
 * @param   pErrInfo            The error info structure. NULL is OK.
 
532
 */
 
533
DECLINLINE(void)    RTErrInfoClear(PRTERRINFO pErrInfo)
 
534
{
 
535
    if (pErrInfo)
 
536
    {
 
537
        pErrInfo->fFlags &= ~RTERRINFO_FLAGS_SET;
 
538
        pErrInfo->rc      = /*VINF_SUCCESS*/0;
 
539
        *pErrInfo->pszMsg = '\0';
 
540
    }
 
541
}
 
542
 
 
543
RT_C_DECLS_END
 
544
 
 
545
/** @} */
 
546
 
 
547
/** @name Status Code Ranges
 
548
 * @{ */
 
549
/** The first status code in the primary IPRT range. */
 
550
#define RTERR_RANGE1_FIRST                  0
 
551
/** The last status code in the primary IPRT range. */
 
552
#define RTERR_RANGE1_LAST                   999
 
553
 
 
554
/** The first status code in the secondary IPRT range. */
 
555
#define RTERR_RANGE2_FIRST                  22000
 
556
/** The last status code in the secondary IPRT range. */
 
557
#define RTERR_RANGE2_LAST                   32766
 
558
 
 
559
/** The first status code in the user range. */
 
560
#define RTERR_USER_FIRST                    1000
 
561
/** The last status code in the user range. */
 
562
#define RTERR_USER_LAST                     21999
 
563
/** @}  */
389
564
 
390
565
 
391
566
/* SED-START */
429
604
/** The request function is not implemented. */
430
605
#define VERR_NOT_IMPLEMENTED                (-12)
431
606
 
 
607
/** Not equal. */
 
608
#define VERR_NOT_EQUAL                      (-18)
 
609
/** The specified path does not point at a symbolic link. */
 
610
#define VERR_NOT_SYMLINK                    (-19)
432
611
/** Failed to allocate temporary memory. */
433
612
#define VERR_NO_TMP_MEMORY                  (-20)
434
613
/** Invalid file mode mask (RTFMODE). */
464
643
#define VERR_INVALID_FUNCTION               (-36)
465
644
/** Not supported. */
466
645
#define VERR_NOT_SUPPORTED                  (-37)
 
646
/** Not supported. */
 
647
#define VINF_NOT_SUPPORTED                  37
467
648
/** Access denied. */
468
649
#define VERR_ACCESS_DENIED                  (-38)
469
650
/** Call interrupted. */
616
797
 * This status is used when two threads is caught sharing the same object
617
798
 * reference. */
618
799
#define VERR_CALLER_NO_REFERENCE            (-93)
619
 
/** Invalid login data given. */
620
 
#define VERR_LOGON_FAILURE                  (-94)
621
800
/** Generic no change error. */
622
801
#define VERR_NO_CHANGE                      (-95)
623
802
/** Generic no change info. */
624
803
#define VINF_NO_CHANGE                      95
625
804
/** Out of memory condition when allocating executable memory. */
626
805
#define VERR_NO_EXEC_MEMORY                 (-96)
627
 
 
 
806
/** The alignment is not supported. */
 
807
#define VERR_UNSUPPORTED_ALIGNMENT          (-97)
 
808
/** The alignment is not really supported, however we got lucky with this
 
809
 * allocation. */
 
810
#define VINF_UNSUPPORTED_ALIGNMENT          97
 
811
/** Duplicate something. */
 
812
#define VERR_DUPLICATE                      (-98)
 
813
/** Something is missing. */
 
814
#define VERR_MISSING                        (-99)
628
815
/** @} */
629
816
 
630
817
 
641
828
#define VERR_PATH_NOT_FOUND                 (-103)
642
829
/** Invalid (malformed) file/path name. */
643
830
#define VERR_INVALID_NAME                   (-104)
644
 
/** File/Device already exists. */
 
831
/** The object in question already exists. */
645
832
#define VERR_ALREADY_EXISTS                 (-105)
 
833
/** The object in question already exists. */
 
834
#define VWRN_ALREADY_EXISTS                 105
646
835
/** Too many open files. */
647
836
#define VERR_TOO_MANY_OPEN_FILES            (-106)
648
837
/** Seek error. */
712
901
#define VERR_FILE_AIO_INSUFFICIENT_RESSOURCES (-137)
713
902
/** Device or resource is busy. */
714
903
#define VERR_RESOURCE_BUSY                  (-138)
 
904
/** A file operation was attempted on a non-file object. */
 
905
#define VERR_NOT_A_FILE                     (-139)
 
906
/** A non-file operation was attempted on a file object. */
 
907
#define VERR_IS_A_FILE                      (-140)
 
908
/** Unexpected filesystem object type. */
 
909
#define VERR_UNEXPECTED_FS_OBJ_TYPE         (-141)
 
910
/** A path does not start with a root specification. */
 
911
#define VERR_PATH_DOES_NOT_START_WITH_ROOT  (-142)
 
912
/** A path is relative, expected an absolute path. */
 
913
#define VERR_PATH_IS_RELATIVE               (-143)
 
914
/** A path is not relative (start with root), expected an relative path. */
 
915
#define VERR_PATH_IS_NOT_RELATIVE           (-144)
715
916
/** @} */
716
917
 
717
918
 
734
935
#define VERR_TOO_MANY_SYMLINKS              (-156)
735
936
/** The OS does not support setting the time stamps on a symbolic link. */
736
937
#define VERR_NS_SYMLINK_SET_TIME            (-157)
 
938
/** The OS does not support changing the owner of a symbolic link. */
 
939
#define VERR_NS_SYMLINK_CHANGE_OWNER        (-158)
737
940
/** @} */
738
941
 
739
942
 
1255
1458
 * @{ */
1256
1459
/** The checksum of a tar header record doesn't match. */
1257
1460
#define VERR_TAR_CHKSUM_MISMATCH                (-925)
 
1461
/** The tar end of file record was read. */
 
1462
#define VERR_TAR_END_OF_FILE                    (-926)
 
1463
/** The tar file ended unexpectedly. */
 
1464
#define VERR_TAR_UNEXPECTED_EOS                 (-927)
 
1465
/** The tar termination records was encountered without reaching the end of
 
1466
  * the input stream. */
 
1467
#define VERR_TAR_EOS_MORE_INPUT                 (-928)
 
1468
/** A number tar header field was malformed.  */
 
1469
#define VERR_TAR_BAD_NUM_FIELD                  (-929)
 
1470
/** A numeric tar header field was not terminated correctly. */
 
1471
#define VERR_TAR_BAD_NUM_FIELD_TERM             (-930)
 
1472
/** A number tar header field was encoded using base-256 which this
 
1473
 * tar implementation currently does not support.  */
 
1474
#define VERR_TAR_BASE_256_NOT_SUPPORTED         (-931)
 
1475
/** A number tar header field yielded a value too large for the internal
 
1476
 * variable of the tar interpreter. */
 
1477
#define VERR_TAR_NUM_VALUE_TOO_LARGE            (-932)
 
1478
/** The combined minor and major device number type is too small to hold the
 
1479
 * value stored in the tar header.  */
 
1480
#define VERR_TAR_DEV_VALUE_TOO_LARGE            (-933)
 
1481
/** The mode field in a tar header is bad. */
 
1482
#define VERR_TAR_BAD_MODE_FIELD                 (-934)
 
1483
/** The mode field should not include the type. */
 
1484
#define VERR_TAR_MODE_WITH_TYPE                 (-935)
 
1485
/** The size field should be zero for links and symlinks. */
 
1486
#define VERR_TAR_SIZE_NOT_ZERO                  (-936)
 
1487
/** Encountered an unknown type flag. */
 
1488
#define VERR_TAR_UNKNOWN_TYPE_FLAG              (-937)
 
1489
/** The tar header is all zeros. */
 
1490
#define VERR_TAR_ZERO_HEADER                    (-938)
 
1491
/** Not a uniform standard tape v0.0 archive header. */
 
1492
#define VERR_TAR_NOT_USTAR_V00                  (-939)
 
1493
/** The name is empty. */
 
1494
#define VERR_TAR_EMPTY_NAME                     (-940)
 
1495
/** A non-directory entry has a name ending with a slash. */
 
1496
#define VERR_TAR_NON_DIR_ENDS_WITH_SLASH        (-941)
 
1497
/** Encountered an unsupported portable archive exchange (pax) header. */
 
1498
#define VERR_TAR_UNSUPPORTED_PAX_TYPE           (-942)
 
1499
/** Encountered an unsupported Solaris Tar extension. */
 
1500
#define VERR_TAR_UNSUPPORTED_SOLARIS_HDR_TYPE   (-943)
 
1501
/** Encountered an unsupported GNU Tar extension. */
 
1502
#define VERR_TAR_UNSUPPORTED_GNU_HDR_TYPE       (-944)
 
1503
/** Malformed checksum field in the tar header. */
 
1504
#define VERR_TAR_BAD_CHKSUM_FIELD               (-945)
 
1505
/** Malformed checksum field in the tar header. */
 
1506
#define VERR_TAR_MALFORMED_GNU_LONGXXXX         (-946)
 
1507
/** Too long name or link string. */
 
1508
#define VERR_TAR_NAME_TOO_LONG                  (-947)
1258
1509
/** @} */
1259
1510
 
1260
1511
/** @name RTPoll status codes
1269
1520
#define VERR_POLL_SET_IS_FULL                   (-953)
1270
1521
/** @} */
1271
1522
 
 
1523
/** @name RTZip status codes
 
1524
 * @{ */
 
1525
/** Generic zip error. */
 
1526
#define VERR_ZIP_ERROR                          (-22000)
 
1527
/** The compressed data was corrupted. */
 
1528
#define VERR_ZIP_CORRUPTED                      (-22001)
 
1529
/** Ran out of memory while compressing or uncompressing. */
 
1530
#define VERR_ZIP_NO_MEMORY                      (-22002)
 
1531
/** The compression format version is unsupported. */
 
1532
#define VERR_ZIP_UNSUPPORTED_VERSION            (-22003)
 
1533
/** The compression method is unsupported. */
 
1534
#define VERR_ZIP_UNSUPPORTED_METHOD             (-22004)
 
1535
/** The compressed data started with a bad header. */
 
1536
#define VERR_ZIP_BAD_HEADER                     (-22005)
 
1537
/** @} */
 
1538
 
 
1539
/** @name RTVfs status codes
 
1540
 * @{ */
 
1541
/** The VFS chain specification does not have a valid prefix. */
 
1542
#define VERR_VFS_CHAIN_NO_PREFIX                    (-22100)
 
1543
/** The VFS chain specification is empty. */
 
1544
#define VERR_VFS_CHAIN_EMPTY                        (-22101)
 
1545
/** Expected an element. */
 
1546
#define VERR_VFS_CHAIN_EXPECTED_ELEMENT             (-22102)
 
1547
/** The VFS object type is not known. */
 
1548
#define VERR_VFS_CHAIN_UNKNOWN_TYPE                 (-22103)
 
1549
/** Expected a left paranthese. */
 
1550
#define VERR_VFS_CHAIN_EXPECTED_LEFT_PARENTHESES    (-22104)
 
1551
/** Expected a right paranthese. */
 
1552
#define VERR_VFS_CHAIN_EXPECTED_RIGHT_PARENTHESES   (-22105)
 
1553
/** Expected a provider name. */
 
1554
#define VERR_VFS_CHAIN_EXPECTED_PROVIDER_NAME       (-22106)
 
1555
/** Expected an action (> or |). */
 
1556
#define VERR_VFS_CHAIN_EXPECTED_ACTION              (-22107)
 
1557
/** Only one action element is currently supported. */
 
1558
#define VERR_VFS_CHAIN_MULTIPLE_ACTIONS             (-22108)
 
1559
/** Expected to find a driving action (>), but there is none. */
 
1560
#define VERR_VFS_CHAIN_NO_ACTION                    (-22109)
 
1561
/** Expected pipe action. */
 
1562
#define VERR_VFS_CHAIN_EXPECTED_PIPE                (-22110)
 
1563
/** Unexpected action type. */
 
1564
#define VERR_VFS_CHAIN_UNEXPECTED_ACTION_TYPE       (-22111)
 
1565
/** @} */
 
1566
 
1272
1567
/* SED-END */
1273
1568
 
1274
1569
/** @} */
1275
1570
 
1276
 
RT_C_DECLS_END
1277
 
 
1278
1571
#endif
1279
1572