示例#1
0
void __MkTmpFile( char *buf, int num )
{
    unsigned    pid;
    unsigned    i;
    char        *ptr;

    pid = getuniqueid();
//  JBS on Win32 pid's range from 0 to n where n is not very large for
//  most systems (e.g. 500 would indicate many, many processes are active).
//  #if defined(__386__) || defined(__AXP__) || defined(__PPC__)
//      // try to use more of the 32bit pid bits
//      pid |= pid >> 16;
//  #endif

    i = __GetTmpPath( buf );
    ptr = buf + i;
    ptr[0] = 't';
    for( i = 7; i != 0; i-- ) {     // JBS use 7 hex digits instead of 4
        ptr[i] = __hex( pid & 0x000F );
        pid = pid >> 4;
    }
    ptr[8] = '.';
    ptr[9] = 't';
    ptr[10] = __hex( (num >> 4) & 0x000F );
    ptr[11] = __hex( num & 0x000F );
    ptr[12] = NULLCHAR;
}
示例#2
0
/*
 * Convert the hex data in 'buf' into 'count' bytes to be placed in 'mem'.
 * Returns a pointer to the character in mem AFTER the last byte written.
 */
char *
__unpack_bytes_to_mem(char *buf, char *mem, int count)
{
    int  i;
    char ch;

    for (i = 0; i < count; i++) {
	ch = __hex(*buf++) << 4;
	ch = ch + __hex(*buf++);
	*mem++ = ch;
    }
    return(mem);
}
示例#3
0
/*
 * Unpack 'count' hex characters, forming them into a binary value.
 * Return that value as an int. Adjust the source pointer accordingly.
 */
int
__unpack_nibbles(char **ptr, int count)
{
    int value = 0;

    while (--count >= 0) {
	value = (value << 4) | __hex(**ptr);
	(*ptr)++;
    }
    return value;
}
示例#4
0
/*
 * While finding valid hex chars, build an unsigned long int.
 * Return number of hex chars processed.
 */
int
__unpack_ulong(char **ptr, unsigned long *val)
{
    int numChars = 0;
    int hexValue;
    
    *val = 0;

    while (**ptr) {
	hexValue = __hex(**ptr);
	if (hexValue >= 0) {
	    *val = (*val << 4) | hexValue;
	    numChars ++;
	} else
	    break;
	(*ptr)++;
    }
    return (numChars);
}