Changeset 2


Ignore:
Timestamp:
Mar 13, 2007, 10:32:52 AM (18 years ago)
Author:
Paul Smedley
Message:

Fix missing function os2_randget in lib/os2ea.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/samba-3.0.25pre1/source/lib/os2ea.c

    r1 r2  
    55#define INCL_LONGLONG
    66#define INCL_DOS
     7#define INCL_DOSPROCESS
     8#define INCL_DOSPROFILE
     9#define INCL_DOSMISC
     10#define INCL_DOSMODULEMGR
    711#define INCL_DOSERRORS
    812//_SMB_H
     
    1418#ifndef TESTING
    1519#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
     20#define CMD_KI_RDCNT            (0x63)
     21
     22typedef struct _CPUUTIL {
     23    ULONG ulTimeLow;     /* Low 32 bits of time stamp      */
     24    ULONG ulTimeHigh;    /* High 32 bits of time stamp     */
     25    ULONG ulIdleLow;     /* Low 32 bits of idle time       */
     26    ULONG ulIdleHigh;    /* High 32 bits of idle time      */
     27    ULONG ulBusyLow;     /* Low 32 bits of busy time       */
     28    ULONG ulBusyHigh;    /* High 32 bits of busy time      */
     29    ULONG ulIntrLow;     /* Low 32 bits of interrupt time  */
     30    ULONG ulIntrHigh;    /* High 32 bits of interrupt time */
     31   } CPUUTIL;
     32
    1633#include "local.h"
    1734#include "xfile.h"
     
    4158        return 0;
    4259}
     60
     61// very simple random data gatherer derived from openssl
     62void os2_randget(char * buffer, int length)
     63{
     64        QWORD qwTime;
     65        ULONG SysVars[QSV_FOREGROUND_PROCESS];
     66        int done = 0;
     67
     68        if (!buffer || length <= 0)
     69        {
     70                return;
     71        }
     72
     73        DosTmrQueryTime(&qwTime);
     74        memcpy(buffer, &qwTime, sizeof(qwTime) > length ? length : sizeof(qwTime));
     75        done += sizeof(qwTime);
     76        if (done >= length)
     77        {
     78                return;
     79        }
     80
     81        if (DosPerfSysCall)
     82        {
     83                CPUUTIL util;
     84                if (DosPerfSysCall(CMD_KI_RDCNT, (ULONG)&util, 0, 0) == 0)
     85                {
     86                        memcpy(buffer + done, &util, sizeof(util) > length - done ? length - done : sizeof(util));
     87                        done += sizeof(util);
     88                        if (done >= length)
     89                        {
     90                                return;
     91                        }
     92                }
     93        }
     94
     95        DosQuerySysInfo(1, QSV_FOREGROUND_PROCESS, SysVars, sizeof(SysVars));
     96        memcpy(buffer + done, SysVars, sizeof(SysVars) > length - done ? length - done : sizeof(SysVars));
     97}
     98
    4399
    44100void maperrno(int rc)
Note: See TracChangeset for help on using the changeset viewer.