Doxygen Source Code Documentation
r_misc.h File Reference
Go to the source code of this file.
Data Structures | |
struct | THD_dvec3 |
Defines | |
#define | ORCODE(aa) |
#define | OR3OK(x, y, z) ( ((x)&6) + ((y)&6) + ((z)&6) == 6 ) |
Functions | |
int | r_sprintf_long_to_hex (char *dest, unsigned long lsrc, int bytes, int pad) |
unsigned long | r_hex_str_to_long (char *src, int hex_digits) |
Define Documentation
|
|
|
Value: ( (aa)=='R' ? ORI_R2L_TYPE : (aa)=='L' ? ORI_L2R_TYPE : \ (aa)=='P' ? ORI_P2A_TYPE : (aa)=='A' ? ORI_A2P_TYPE : \ (aa)=='I' ? ORI_I2S_TYPE : (aa)=='S' ? ORI_S2I_TYPE : ILLEGAL_TYPE ) |
Function Documentation
|
Definition at line 31 of file r_misc.c.
00032 { 00033 unsigned long res = 0; 00034 char * cp; 00035 int nib, digs; 00036 00037 if ( hex_digits <= 0 || hex_digits > 8 ) 00038 return 0; 00039 00040 for ( digs = hex_digits, cp = src; digs > 0; digs--, cp++ ) 00041 { 00042 if ( (*cp >= '0') && (*cp <= '9') ) 00043 nib = *cp - '0'; 00044 else if ( (*cp >= 'a') && (*cp <= 'f') ) 00045 nib = *cp - 'a' + 10; 00046 else if ( (*cp >= 'A') && (*cp <= 'F') ) 00047 nib = *cp - 'A' + 10; 00048 else 00049 { 00050 fprintf( stderr, "r_hex_str_to_long: invalid input string <%8s>\n", 00051 src ); 00052 return 0; 00053 } 00054 00055 res = (res << 4) + (nib & 0xf); 00056 } 00057 00058 return res; 00059 } |
|
---------------------------------------------------------------------- sprintf_long_to_hex - write hex chars to a string return number of hex pairs written (should equal bytes) ---------------------------------------------------------------------- Definition at line 1250 of file SUMA_Color.c.
01256 { 01257 static char hexstring[] = "0123456789ABCDEF"; 01258 01259 unsigned char ub; 01260 char * cp = dest; 01261 int posn, size, ret; 01262 01263 if ( (bytes <= 0) || (bytes > 4) ) 01264 { 01265 *cp = '\0'; 01266 return 0; 01267 } 01268 01269 size = r_ulong_size( lsrc ); 01270 01271 if ( (size < bytes) && !pad ) 01272 ret = size; 01273 else 01274 ret = bytes; 01275 01276 for ( posn = ret-1; posn >= 0; posn-- ) 01277 { 01278 /* write one hex pair for this byte */ 01279 ub = ( lsrc >> (posn << 3) ) & 0xff; /* current ubyte */ 01280 *cp++ = hexstring[(ub>>4) & 0xf]; /* upper nibble */ 01281 *cp++ = hexstring[ ub & 0xf]; /* lower nibble */ 01282 } 01283 01284 *cp = '\0'; 01285 01286 return ret; 01287 } |