Changeset 3396 for trunk/include/odin32validate.h
- Timestamp:
- Apr 16, 2000, 6:06:11 AM (25 years ago)
- 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:03bird Exp $1 /* $Id: odin32validate.h,v 1.2 2000-04-16 04:06:11 bird Exp $ 2 2 * 3 3 * 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. 4 9 * 5 10 * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@pmsc.no) … … 12 17 13 18 /** 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. 16 22 */ 17 23 #define ADDRESS_SPACE_LIMIT 0xc0000000 … … 19 25 20 26 /** 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.) 22 29 * @returns TRUE if valid. 23 30 * FALSE if invalid. 24 31 * @param p Pointer value. 25 32 */ 26 #define VALID FAST_PTR(p) \33 #define VALID_PTR(p) \ 27 34 ((char*)(p) >= (char*)0x10000 \ 28 35 && (char*)(p) < (char*)ADDRESS_SPACE_LIMIT) … … 30 37 31 38 /** 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.) 33 41 * @returns TRUE if valid. 34 42 * FALSE if invalid. … … 36 44 * @param cb Size of data pointer to by the pointer. 37 45 */ 38 #define VALID FAST_PTRSIZE(p, cb) \46 #define VALID_PTRSIZE(p, cb) \ 39 47 ((char*)(p) >= (char*)0x10000 \ 40 48 && (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 42 51 43 52 /** 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.) 46 56 * @returns TRUE if valid. 47 57 * FALSE if invalid. … … 49 59 * @param cchMax Max string length 50 60 */ 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) 54 75 55 76
Note:
See TracChangeset
for help on using the changeset viewer.