Ignore:
Timestamp:
Apr 16, 2000, 6:06:11 AM (25 years ago)
Author:
bird
Message:

Initial coding...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/odin32validate.h

    r3395 r3396  
    1 /* $Id: odin32validate.h,v 1.1 2000-04-16 02:59:03 bird Exp $
     1/* $Id: odin32validate.h,v 1.2 2000-04-16 04:06:11 bird Exp $
    22 *
    33 * Parameter validation macros.
     4 *
     5 * Note that these are not fully implemented yet. Pointers and memory areas
     6 * are not checked if valid yet, since this requires some more effort. So,
     7 * for the time being pointers and memory areas are checked agains the
     8 * maximum user virtual address space limits.
    49 *
    510 * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
     
    1217
    1318/**
    14  * ADDRESS_SPACE_LIMIT holds the largest possible address in the address space + 1.
    15  * 3GB is the higest possible address in the user address space in OS/2.
     19 * ADDRESS_SPACE_LIMIT holds the largest possible address in the user virtual
     20 * address virtual space + 1.
     21 * 3GB is the higest possible address in the user virtual address space in OS/2.
    1622 */
    1723#define ADDRESS_SPACE_LIMIT 0xc0000000
     
    1925
    2026/**
    21  * Validates that the value of a pointer is within the virtual address space.
     27 * Validates that the specified pointer points at valid.
     28 * (Currently it only check that it's within the user virtual address space.)
    2229 * @returns   TRUE if valid.
    2330 *            FALSE if invalid.
    2431 * @param     p     Pointer value.
    2532 */
    26 #define VALIDFAST_PTR(p) \
     33#define VALID_PTR(p) \
    2734            ((char*)(p) >= (char*)0x10000 \
    2835            && (char*)(p) < (char*)ADDRESS_SPACE_LIMIT)
     
    3037
    3138/**
    32  * Validates that a area pointed to is within the virtual address space.
     39 * Validates that the area pointed to is valid.
     40 * (Currently it only check that it's within the user virtual address space.)
    3341 * @returns   TRUE if valid.
    3442 *            FALSE if invalid.
     
    3644 * @param     cb    Size of data pointer to by the pointer.
    3745 */
    38 #define VALIDFAST_PTRSIZE(p, cb) \
     46#define VALID_PTRSIZE(p, cb) \
    3947            ((char*)(p) >= (char*)0x10000 \
    4048             && (char*)(p) < (char*)ADDRESS_SPACE_LIMIT \
    41              && (char*)(p) + (char*)(cb) < (char*)ADDRESS_SPACE_LIMIT)
     49             && (char*)(p) + (unsigned)(cb) < (char*)ADDRESS_SPACE_LIMIT)
     50
    4251
    4352/**
    44  * Validates that the value of a string pointer is within the virtual address
    45  * space, and that its length less or equal to the given max length.
     53 * Validates that a string pointer is valid and that the entire string is valid.
     54 * (Currently it only checks that the first byte of the string is within
     55 * the user virtual address space.)
    4656 * @returns   TRUE if valid.
    4757 *            FALSE if invalid.
     
    4959 * @param     cchMax    Max string length
    5060 */
    51 #define VALIDFAST_PSZLENGTH(psz, cchMax) \
    52             (VALIDFAST_PTRSIZE(psz, 1) \
    53              && strlen(psz) <= cchMax)
     61#define VALID_PSZ(psz) \
     62            (VALID_PTRSIZE(psz, 1))
     63
     64/**
     65 * Validates that a string less or equal to a given max length.
     66 * Note! the pointer isn't validated. That you'll have to do separatly using
     67 * VALID_PSZ(psz) which is defined right above.
     68 * @returns   TRUE if valid.
     69 *            FALSE if invalid.
     70 * @param     psz       String pointer.
     71 * @param     cchMax    Max string length
     72 */
     73#define VALID_PSZMAXSIZE(psz, cchMax) \
     74             (strlen(psz) <= cchMax)
    5475
    5576
Note: See TracChangeset for help on using the changeset viewer.