Пример #1
0
void _cdecl wr_counter(dword ctr, int col, int row, int Fcolor, int Bcolor, int radix)
{
#if (DEVICE_CONSOLE_OUT)

   char  buffer[11];
   uint  i, j;

   ENTER_CLIB();
   _ultoa(ctr, buffer, radix);
   EXIT_CLIB();

   for(i = 0; buffer[i] && i < 6; i++) {}  /* find end of string */
   for(; i < 6; i++)                       /* right align */
   {
      for(j = i+1; j > 0; j--)
         buffer[j] = buffer[j-1];
      buffer[j] = '0';
   }

   wr_string(col,row,Fcolor,Bcolor,!BLINK,buffer);

#else
   /* Avoid compiler warning about unused pars. */
   (void) ctr;
   (void) col;
   (void) row;
   (void) Fcolor;
   (void) Bcolor;
   (void) radix;

#endif /* DEVICE_CONSOLE_OUT */
}
void CrashHandlerWindows::writeCrashDump(PEXCEPTION_POINTERS pExceptionPointers) {

    // Build the temporary path to store the minidump
    CHAR* tempPathBuffer = m_pCrashInfo->miniDumpTmpFile;
    GetTempPath(MAX_PATH, m_pCrashInfo->miniDumpTmpFile);
    DWORD tick = GetTickCount();
    char tickChar[24];
    _ultoa(tick, tickChar, 10);
    strcat(&tempPathBuffer[0], tickChar);
    strcat(&tempPathBuffer[0], ".dmp");

    // Create the minidump file
    HANDLE hFile = CreateFile(tempPathBuffer, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    if(hFile == INVALID_HANDLE_VALUE)
        return;

    MINIDUMP_TYPE miniDumpType = (MINIDUMP_TYPE)(MiniDumpWithIndirectlyReferencedMemory | MiniDumpScanMemory);

    MINIDUMP_EXCEPTION_INFORMATION exceptionInfo;
    exceptionInfo.ThreadId = GetCurrentThreadId();
    exceptionInfo.ExceptionPointers = pExceptionPointers;
    exceptionInfo.ClientPointers = TRUE;

    MINIDUMP_CALLBACK_INFORMATION callbackInfo;
    callbackInfo.CallbackRoutine = miniDumpCallback;
    callbackInfo.CallbackParam = 0;

    // Write the minidump
    MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, miniDumpType, &exceptionInfo, NULL, NULL);
    CloseHandle(hFile);
}
Пример #3
0
STDMETHODIMP CCustomerDisplay::DisplayOn(ULONG ulCom, ULONG ulBaud, ULONG* pulErrorCode)
{
    // если порт дисплея открыт, выходим
    if (hComm != INVALID_HANDLE_VALUE)
    {
        *pulErrorCode = E_SUCCESS;
        return S_OK;
    }

    // преобразуем номер порта в имя файла
    CHAR c_CommFile[] = "COM1", c_CommNumber[2] = {0};
    _ultoa(ulCom, c_CommNumber, 10);
    c_CommFile[3] = c_CommNumber[0];
    // открываем порт
    hComm = CreateFile(c_CommFile, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 
        FILE_ATTRIBUTE_NORMAL, NULL);
    if (hComm == INVALID_HANDLE_VALUE)
    {
        *pulErrorCode = E_PORT_IS_BUSY;
        return S_OK;
    }
    // задаем конфигурацию порта
    DCB dcb;
    GetCommState(hComm, &dcb);
    dcb.BaudRate = ulBaud;
    dcb.Parity = NOPARITY;
    dcb.ByteSize = 8;
    dcb.StopBits = ONESTOPBIT;
    SetCommState(hComm, &dcb);

    *pulErrorCode = E_SUCCESS;
    return S_OK;
}
Пример #4
0
void AddContactDlgOpts(HWND hdlg, const char* szProto, BOOL bAuthOptsOnly = FALSE)
{
	DWORD flags = (szProto) ? CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) : 0;
	if (IsDlgButtonChecked(hdlg, IDC_ADDTEMP)) {
		EnableWindow(GetDlgItem(hdlg, IDC_ADDED), FALSE);
		EnableWindow(GetDlgItem(hdlg, IDC_AUTH), FALSE);
		EnableWindow(GetDlgItem(hdlg, IDC_AUTHREQ), FALSE);
		EnableWindow(GetDlgItem(hdlg, IDC_AUTHGB), FALSE);
	}
	else {
		EnableWindow(GetDlgItem(hdlg, IDC_ADDED), !(flags & PF4_FORCEADDED));
		EnableWindow(GetDlgItem(hdlg, IDC_AUTH), !(flags & PF4_FORCEAUTH));
		EnableWindow(GetDlgItem(hdlg, IDC_AUTHREQ), (flags & PF4_NOCUSTOMAUTH) ? FALSE : IsDlgButtonChecked(hdlg, IDC_AUTH));
		EnableWindow(GetDlgItem(hdlg, IDC_AUTHGB), (flags & PF4_NOCUSTOMAUTH) ? FALSE : IsDlgButtonChecked(hdlg, IDC_AUTH));
	}

	if (bAuthOptsOnly)
		return;

	SetDlgItemText(hdlg, IDC_AUTHREQ, (flags & PF4_NOCUSTOMAUTH) ? _T("") : TranslateT("Please authorize my request and add me to your contact list."));

	char* szUniqueId = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDTEXT, 0);
	if (szUniqueId) {
		size_t cbLen = strlen(szUniqueId) + 2;
		TCHAR* pszUniqueId = (TCHAR*)mir_alloc(cbLen * sizeof(TCHAR));
		mir_sntprintf(pszUniqueId, cbLen, _T("%S:"), szUniqueId);
		SetDlgItemText(hdlg, IDC_IDLABEL, pszUniqueId);
		mir_free(pszUniqueId);
	}
	else SetDlgItemText(hdlg, IDC_IDLABEL, TranslateT("Contact ID:"));

	flags = (szProto) ? CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) : 0;
	if (flags & PF1_NUMERICUSERID) {
		char buffer[65];
		SetWindowLongPtr(GetDlgItem(hdlg, IDC_USERID), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hdlg, IDC_USERID), GWL_STYLE) | ES_NUMBER);
		if (strstr(szProto, "GG"))
			_ultoa(INT_MAX, buffer, 10);
		else
			_ultoa(ULONG_MAX, buffer, 10);
		SendDlgItemMessage(hdlg, IDC_USERID, EM_LIMITTEXT, (WPARAM)strlen(buffer), 0);
	}
	else {
		SetWindowLongPtr(GetDlgItem(hdlg, IDC_USERID), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hdlg, IDC_USERID), GWL_STYLE) & ~ES_NUMBER);
		SendDlgItemMessage(hdlg, IDC_USERID, EM_LIMITTEXT, 255, 0);
	}
}
Пример #5
0
void _ltoa(long value, char* string, unsigned char radix)
{
  if (value < 0 && radix == 10) {
    *string++ = '-';
    value = -value;
  }
  _ultoa(value, string, radix);
}
Пример #6
0
CString ULongToStr(unsigned long ulVal)
{
	CString strRet;
	char buff[20];
	
	_ultoa(ulVal, buff, 10);
	strRet = buff;
	return strRet;

}
Пример #7
0
void MimeHeaders::addULong(const char* name, unsigned lValue)
{
	MimeHeader& H = mVals[allocSlot()];
	H.name = name;

	char szBuffer[20];
	_ultoa(lValue, szBuffer, 10);
	H.value = mir_strdup(szBuffer); 
	H.flags = 2;
}
Пример #8
0
unsigned APIENTRY LibMain( unsigned hmod, unsigned termination )
{
    if( !termination )
    {
        getSGID();

        strcpy( m_szPipeName, PIPE_KSHELL_VIOSUB_BASE );
        _ultoa( m_ulSGID, m_szPipeName + strlen( m_szPipeName ), 16 );
    }

    return 1;
}
Пример #9
0
// UnsignedToRxVariable -- Convert an unsigned number into a REXX String.
//
//      Return: REXX Variable Pool return code
//
ULONG UnsignedToRxVariable(
    ULONG number,
    PRXSTRING rxName)
{
    UCHAR string[34];
    ULONG cc;

    _ultoa(number, string, 10);

    cc = StringToRxVariable(string, strlen(string), rxName);
    return cc;
}
Пример #10
0
// UnsignedToRxResult -- Convert a numeric code to Result.
//
//      Return: return of 'StringToRxResult'
//
ULONG UnsignedToRxResult(
    ULONG number,                       // Code to convert.
    PRXSTRING rxResult)                 // REXX function result.
{
    UCHAR string[34];
    ULONG cc;

    _ultoa(number, string, 10);

    cc = StringToRxResult(string, strlen(string), rxResult);
    return cc;
}
Пример #11
0
std::string str(uint32_t value)
{
	char buf[64];
#ifdef USING_VISUAL_2005
	if (_ultoa_s(value, buf, sizeof(buf), 10) == 0)
		return buf;
	else
		return "";
#else
	return _ultoa(value, buf, 10);
#endif //USING_VISUAL_2005
}
Пример #12
0
void PDBLK::plot(                //draw outline
                 ScrollView* window,  //window to draw in
                 int32_t serial,   //serial number
                 ScrollView::Color colour   //colour to draw in
                ) {
  ICOORD startpt;                //start of outline
  ICOORD endpt;                  //end of outline
  ICOORD prevpt;                 //previous point
  ICOORDELT_IT it = &leftside;   //iterator

                                 //set the colour
  window->Pen(colour);
  window->TextAttributes("Times", BLOCK_LABEL_HEIGHT, false, false, false);

  if (hand_poly != nullptr) {
    hand_poly->plot(window, serial);
  } else if (!leftside.empty ()) {
    startpt = *(it.data ());     //bottom left corner
    //              tprintf("Block %d bottom left is (%d,%d)\n",
    //                      serial,startpt.x(),startpt.y());
    char temp_buff[34];
#if !defined(_WIN32) || defined(__MINGW32__)
    snprintf(temp_buff, sizeof(temp_buff), "%" PRId32, serial);
#else
    _ultoa(serial, temp_buff, 10);
#endif
    window->Text(startpt.x (), startpt.y (), temp_buff);

    window->SetCursor(startpt.x (), startpt.y ());
    do {
      prevpt = *(it.data ());    //previous point
      it.forward ();             //move to next point
                                 //draw round corner
    window->DrawTo(prevpt.x (), it.data ()->y ());
    window->DrawTo(it.data ()->x (), it.data ()->y ());
    }
    while (!it.at_last ());      //until end of list
    endpt = *(it.data ());       //end point

                                 //other side of boundary
    window->SetCursor(startpt.x (), startpt.y ());
    it.set_to_list (&rightside);
    prevpt = startpt;
    for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
                                 //draw round corner
    window->DrawTo(prevpt.x (), it.data ()->y ());
    window->DrawTo(it.data ()->x (), it.data ()->y ());
      prevpt = *(it.data ());    //previous point
    }
                                 //close boundary
    window->DrawTo(endpt.x(), endpt.y());
  }
}
Пример #13
0
void CWMPADialog::UpdateSongList()
{
   char buffer[32];
   CString name;
   CString artist;
   CString title;
   CString album;
   CString bitrate;
   CString duration;
   CString song;
   long index;
   long count;

   m_SongListBox.ResetContent();
   CWMPPlaylist playlist = m_WMP.GetCurrentPlaylist();
   count = playlist.GetCount();
   m_SongListBox.ResetContent();
   for (index = 0; index < count; index++) {
      name         = playlist.GetItem(index).GetName();
      artist       = playlist.GetItem(index).getItemInfo("Artist");
      title        = playlist.GetItem(index).getItemInfo("Title");
      album        = playlist.GetItem(index).getItemInfo("Album");
      bitrate      = playlist.GetItem(index).getItemInfo("Bitrate");
      duration     = playlist.GetItem(index).GetDurationString();

      long krate = strtoul((LPCTSTR) bitrate, NULL, 10) / 1000;
      _ultoa(krate, buffer, 10);
      bitrate = CString(buffer);

      if (album.IsEmpty()) {
         playlist.removeItem(playlist.GetItem(index));
         count = playlist.GetCount();
      }
      else {
         song = "";
         song += artist;
         if (song.IsEmpty()) song = "Various";
         song += " - ";
         song += title;
         song += " (";
         song += album;
         song += ") [";
         song += duration;
         song += "/";
         song += bitrate;
         song += "Kbps]";
         m_SongListBox.AddString((LPCTSTR) song);
      }

   }
   m_SongListBox.SetCurSel(0);
}
Пример #14
0
void CMobs::DrawStats()
{
	if (Visible)
	{
		char buf[100];
		char ultoabuf[10];
		strcpy(buf, MobName.c_str());
		strcat(buf, "\n");
		strcat(buf, "HP: ");
		strcat(buf, _ultoa(HP, ultoabuf, 10));
		strcat(buf, " / ");
		strcat(buf, _ultoa(MaxHP, ultoabuf, 10));
		strcat(buf, "\n");
		strcat(buf, "MP: ");
		strcat(buf, _ultoa(MP, ultoabuf, 10));
		strcat(buf, " / ");
		strcat(buf, _ultoa(MaxMP, ultoabuf, 10));
		strcat(buf, "\n");
		strcat(buf, "EXP: ");
		strcat(buf, _ultoa(EXPGiven, ultoabuf, 10));
		D3D.TextWorld(D3D.FrostFont, X - 10, Y - (20*4), D3DCOLOR_XRGB( 0xFF, 0xFF, 0xFF ), buf);
	}
}
Пример #15
0
int automem_append_field_ulong(automem_t* pmem, const char * field, unsigned int f_len, unsigned long val)
{
	char intVal[32];int slen;

	automem_append_voidp(pmem, field, f_len);
	_ultoa(val, intVal,10);
	slen = strlen(intVal);

	automem_ensure_newspace(pmem, slen + 4);
	pmem->pdata[pmem->size++]='=';
	pmem->pdata[pmem->size++]='"';
	automem_append_voidp(pmem, intVal, slen);
	pmem->pdata[pmem->size++]='"';
	pmem->pdata[pmem->size++]=' ';

	return pmem->size;
}
Пример #16
0
wchar_t * __cdecl _ultow (
        unsigned long val,
        wchar_t *buf,
        int radix
        )
{
        char astring[LONG_SIZE_LENGTH];

        _ultoa (val, astring, radix);
#if defined(_NTSUBSET_)
        mbstowcs(buf, astring, LONG_SIZE_LENGTH);
#else
        MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, astring, -1,
                            buf, LONG_SIZE_LENGTH);
#endif

        return (buf);
}
Пример #17
0
Файл: _exit.c Проект: sevki/apex
void
_finish(int status, char *term)
{
	char *cp;

	if(_finishing)
		exits(exitstatus);
	_finishing = 1;
	if(status){
		cp = _ultoa(exitstatus, status & 0xFF);
		*cp = 0;
	}else if(term){
		strncpy(exitstatus, term, ERRMAX);
		exitstatus[ERRMAX-1] = '\0';
	}
	if(_sessleader)
		kill(0, SIGTERM);
	exits(exitstatus);
}
Пример #18
0
int GetValueA(MCONTACT hContact, const char *module, const char *setting, char *value, int length)
{
	DBVARIANT dbv = { 0 };

	if (!module || !setting || !value)
		return 0;

	if (length >= 10 && !db_get_s(hContact, module, setting, &dbv, 0)) {
		switch (dbv.type) {

		case DBVT_ASCIIZ:
			mir_strncpy(value, dbv.pszVal, length);
			break;

		case DBVT_DWORD:
		case DBVT_WORD:
		case DBVT_BYTE:
			_ultoa(getNumericValue(&dbv), value, 10);
			break;

		case DBVT_WCHAR:
			mir_strncpy(value, ptrA(mir_u2a(dbv.pwszVal)), length);
			break;

		case DBVT_UTF8:
			mir_strncpy(value, ptrA(mir_utf8decodeA(dbv.pszVal)), length);
			break;

		case DBVT_DELETED:
			value[0] = 0;
			return 0;
		}

		int type = dbv.type;
		db_free(&dbv);
		return type;
	}

	value[0] = 0;
	return 0;
}
Пример #19
0
BOOL FE_DialogConvert::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_outfilevalue=m_Doutfilename1;
	m_imagetypevalue=m_Doutputimagetype1;
    if (m_Doutputimagequality1<=33)
        m_qualityvalue=0;
    else if (m_Doutputimagequality1<=66)
        m_qualityvalue=1;
    else if (m_Doutputimagequality1>66)
        m_qualityvalue=2;

    m_inputimagetype=m_Dinputimagetype;
	_ultoa(m_Dinputimagesize,m_inputimagesize.GetBuffer(255),10);
	m_inputimagesize.ReleaseBuffer();
	UpdateData(FALSE);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Пример #20
0
/*:::::*/
FBCALL FBSTRING *fb_UIntToStr ( unsigned int num )
{
    FBSTRING 	*dst;

    /* alloc temp string */
    dst = fb_hStrAllocTemp( NULL, sizeof( int ) * 3 );
    if( dst != NULL )
    {
        /* convert */
#ifdef HOST_MINGW
        _ultoa( num, dst->data, 10 );
#else
        sprintf( dst->data, "%u", num );
#endif
        fb_hStrSetLength( dst, strlen( dst->data ) );
    }
    else
        dst = &__fb_ctx.null_desc;

    return dst;
}
Пример #21
0
char*
get_registry_value (char *keyName, const char *name)
{
  HKEY key, hKey;
  char *subkey;
  LONG result;
  DWORD type;
  DWORD data;
  DWORD dataSize;
  char *value = NULL;

  get_registry_key (keyName, &key, &subkey);
  result = RegOpenKeyEx (key, subkey, 0, KEY_READ, &hKey);

  dataSize = 0;
  RegQueryValueEx (hKey, name, 0, &type, NULL, &dataSize);

  if (type == REG_DWORD)
    {
      dataSize = sizeof (DWORD);
      result = RegQueryValueEx (hKey, name, 0, NULL, (LPBYTE)&data, &dataSize);
      if (result == ERROR_SUCCESS)
        {
          value = malloc (255);
          _ultoa (data, value, 10);
        }
    }
  else if ((type == REG_EXPAND_SZ) || (type == REG_SZ))
    {
      value = malloc (dataSize + 1);
      memset (value, dataSize + 1, 0);
      result = RegQueryValueEx (hKey, name, 0, NULL, (LPBYTE)value, &dataSize);
    }

  RegCloseKey (hKey);

  return value;
}
Пример #22
0
char *
SDL_ultoa(unsigned long value, char *string, int radix)
{
#if defined(HAVE__ULTOA)
    return _ultoa(value, string, radix);
#else
    char *bufp = string;

    if (value) {
        while (value > 0) {
            *bufp++ = ntoa_table[value % radix];
            value /= radix;
        }
    } else {
        *bufp++ = '0';
    }
    *bufp = '\0';

    /* The numbers went into the string backwards. :) */
    SDL_strrev(string);

    return string;
#endif /* HAVE__ULTOA */
}
Пример #23
0
void UpdateControls( HWND hwndDlg )
{
    int  i;
    char szFromUl[ 9 ];
    HWND hwndLB;

    hwndLB = WinWindowFromID( hwndDlg, LB_CONTROL );
    WinSendMsg( hwndLB, LM_SELECTITEM, MPFROMSHORT( LIT_NONE ),
                MPFROMLONG( FALSE ) );
    for( i = 0; i < cControlTypes; i++ )
        if( dlgInfo.fsControl & dcControl[ i ].iItem )
            WinSendMsg( hwndLB, LM_SELECTITEM, MPFROMSHORT( i ),
                        MPFROMLONG( TRUE ) );

    hwndLB = WinWindowFromID( hwndDlg, LB_SUPPORTEDOPS );
    WinSendMsg( hwndLB, LM_SELECTITEM, MPFROMSHORT( LIT_NONE ),
                MPFROMLONG( FALSE ) );
    for( i = 0; i < cSupportedOps; i++ )
        if( dlgInfo.fsSupportedOps & dcSupportedOp[ i ].iItem )
            WinSendMsg( hwndLB, LM_SELECTITEM, MPFROMSHORT( i ),
                        MPFROMLONG( TRUE ) );

    for( i = 0; i < cOperations; i++ )
        if( dlgInfo.usOperation == dcOperation[ i ].iItem )
        {
            WinSetDlgItemText( hwndDlg, CB_OPERATION, dcOperation[ i ].szItem );
            break;
        }
    if( i == cOperations )
        WinSetDlgItemText( hwndDlg, CB_OPERATION,
                           _ultoa( (ULONG)dlgInfo.usOperation, szFromUl, 16 ) );

    if( dlgInfo.ulItemID )
        WinSetDlgItemText( hwndDlg, EF_ITEMID,
                           _ultoa( dlgInfo.ulItemID, szFromUl, 16 ) );
    else
        WinSetDlgItemText( hwndDlg, EF_ITEMID, "" );

    WinSetDlgItemText( hwndDlg, CB_TYPE, dlgInfo.szType );
    for( i = 0; i < cTypes; i++ )
    {
       if( !stricmp( ntsType[ i ].szString, dlgInfo.szType ) )
           WinSetDlgItemText( hwndDlg, CB_TYPE, ntsType[ i ].szName );
    }

    WinSetDlgItemText( hwndDlg, EF_CNR_NAME, dlgInfo.szContainerName );
    WinSetDlgItemText( hwndDlg, EF_SOURCE_NAME, dlgInfo.szSourceName );
    WinSetDlgItemText( hwndDlg, EF_TARGET_NAME, dlgInfo.szTargetName );

    WinCheckButton( hwndDlg, CHK_OVERRIDE_ID, dlgInfo.fUseDlgItemID );
    WinCheckButton( hwndDlg, CHK_OVERRIDE_HSTRS, dlgInfo.fUseDlgDragNames );

    WinEnableControl( hwndDlg, EF_ITEMID, dlgInfo.fUseDlgItemID );
    WinEnableControl( hwndDlg, ST_ITEMID, dlgInfo.fUseDlgItemID );
    WinEnableControl( hwndDlg, EF_CNR_NAME, dlgInfo.fUseDlgDragNames );
    WinEnableControl( hwndDlg, EF_SOURCE_NAME, dlgInfo.fUseDlgDragNames );
    WinEnableControl( hwndDlg, EF_TARGET_NAME, dlgInfo.fUseDlgDragNames );
    WinEnableControl( hwndDlg, ST_CNR_NAME, dlgInfo.fUseDlgDragNames );
    WinEnableControl( hwndDlg, ST_SOURCE_NAME, dlgInfo.fUseDlgDragNames );
    WinEnableControl( hwndDlg, ST_TARGET_NAME, dlgInfo.fUseDlgDragNames );
}
Пример #24
0
BOOL
InitDialog (
    HWND hwnd,
    HWND hwndFocus,
    LPARAM lParam
    )
{
    BOOLEAN Found = FALSE;
    CHAR   buffer[34];
    DWORD  bytes;
    HWND   Drives = GetDlgItem (hwnd,DRV_BOX);
    PCHAR  lp;
    UINT   i = 0,
           NoDrives = 0;

    srand(GetTickCount());
    Button_Enable(GetDlgItem(hwnd,STOP_BUTTON), FALSE);


    //
    // Get attached drives, filter out non-disk drives, and fill drive box.
    //

    bytes = GetLogicalDriveStrings(0,NULL);

    DrvStrHandle = VirtualAlloc(NULL,bytes + 1,
                                MEM_COMMIT | MEM_RESERVE,
                                PAGE_READWRITE);

    GetLogicalDriveStrings( bytes, DrvStrHandle);
    for (lp = DrvStrHandle;*lp; ) {
        if (GetDriveType(lp) == DRIVE_FIXED) {
            ComboBox_AddString(Drives,lp);
            ++NoDrives;
        }
        while(*lp++);
    }

    //
    // Check for cmd line params passed in, and set the test drive to either
    // the specified drive, or to the first in the drive list.
    //

    ComboBox_SetCurSel (Drives,0);
    if (TestDrv[4] != '\0') {
        do {
            ComboBox_GetText(GetDlgItem(hwnd,DRV_BOX),buffer,4);
            if (buffer[0] == TestDrv[4]) {
                Found = TRUE;
            } else {
                if (++i >= NoDrives) {
                    Found = TRUE;
                } else {
                    ComboBox_SetCurSel (Drives,i);
                }
            }
        } while (!Found);
        if (i >= NoDrives) {

            //
            // Couldn't find the drive, exit with a message.
            //

            LogError("Incorrect Drive Letter in command line.",1,0);
            EndDialog(hwnd,0);
            return FALSE;
        }

    } else {
        ComboBox_SetCurSel (Drives,0);
    }

    //
    // Get the sector size for the default selection.
    //
    TestDrv[4] = '\0';
    ComboBox_GetText(GetDlgItem(hwnd,DRV_BOX),buffer, 4);
    strcat (TestDrv,buffer);
    TestDrv[6] = '\0';
    GetSectorSize(&SectorSize,TestDrv);

    //
    // If index is 0, use defaults, otherwise set the test according to
    // the cmdline passes in.
    //

    Button_SetCheck(GetDlgItem(hwnd,TEST_RAD_READ + (index >> 1)), TRUE);
    Button_SetCheck(GetDlgItem(hwnd,VAR_RAD_SEQ + (index & 0x01)),TRUE);

    //
    // Set buffer size.
    //

    if (BufferSize == 0) {

        BufferSize = 65536;
        NumberIOs = FILE_SIZE / BufferSize;

    } else {

        //
        // Verify that buffersize is a multiple of sector size, if not adjust it.
        //

        if (BufferSize % SectorSize) {
            BufferSize &= ~(SectorSize - 1);
        }

        NumberIOs = FILE_SIZE / BufferSize;

        //
        // Cmd line was present and has been used to config. the test. Send a message
        // to the start button to get things rolling.
        //

        SendMessage(hwnd,WM_COMMAND,(BN_CLICKED << 16) | START_BUTTON,(LPARAM)GetDlgItem(hwnd,START_BUTTON));
    }
    _ultoa(BufferSize,buffer,10);
    Static_SetText(GetDlgItem(hwnd,BUFFER_TEXT),buffer);

    return(TRUE);
}
Пример #25
0
void __cdecl FindSettings(LPVOID param)
{
	FindInfo* fi = (FindInfo*)param;
	HWND hwndParent = GetParent(fi->hwnd);

	ModuleSettingLL ModuleList, SettingList;
	ModSetLinkLinkItem *module, *setting;

	MCONTACT hContact;
	DBVARIANT dbv = { 0 };

	int foundCount = 0,	 replaceCount = 0, deleteCount = 0;

	DWORD numsearch = 0, numreplace = 0;
	int NULLContactDone = 0;

	if (!fi->search || !EnumModules(&ModuleList)) {
		fi_free(fi);
		return;
	}

	_T2A search(fi->search);
	_T2A replace(fi->replace);

    // skip modules and setting names on unicode search or replace
   	if (IsRealUnicode(fi->search) || IsRealUnicode(fi->replace)) {
   		fi->options &= ~(F_SETNAME | F_MODNAME); 
   		fi->options |= F_UNICODE;
   	}

    if (!(fi->options & F_UNICODE) && (fi->options & F_SETVAL)) {
		char val[16];
		numsearch = strtoul(search, NULL, 10);
		_ultoa(numsearch, val, 10);
		if (!mir_strcmp(search, val)) {
			fi->options |= F_NUMSRCH;
			// replace numeric values only entirely
			if (replace && (fi->options & F_ENTIRE)) {
				numreplace = strtoul(replace, NULL, 10);
				_ultoa(numreplace, val, 10);
				if (!replace[0] || !mir_strcmp(replace, val))
					fi->options |= F_NUMREPL;
			}
		}
	}

	SendDlgItemMessage(hwndParent, IDC_SBAR, SB_SETTEXT, 0, (LPARAM)TranslateT("Searching..."));

	hContact = 0;

	while (GetWindowLongPtr(GetDlgItem(hwndParent, IDC_SEARCH), GWLP_USERDATA)) {

		if (!hContact) {
			if (NULLContactDone) 
				break;
			else {
				NULLContactDone = 1;
				hContact = db_find_first();
			}
		}
		else 
			hContact = db_find_next(hContact);

		for (module = ModuleList.first; module; module = module->next) {

			if (IsModuleEmpty(hContact, module->name))
				continue;

			if (fi->options & (F_SETVAL | F_SETNAME)) {

				if (!EnumSettings(hContact, module->name, &SettingList)) {
					fi_free(fi);
					FreeModuleSettingLL(&ModuleList);
					return;
				}

				for (setting = SettingList.first; setting; setting = setting->next) {

					dbv.type = 0;
					if (db_get_s(hContact, module->name, setting->name, &dbv, 0))
						continue;

					// check in settings value				
					if (fi->options & F_SETVAL) {

						TCHAR *value = NULL;

					    switch(dbv.type) {

						case DBVT_BYTE: 
						case DBVT_WORD: 
						case DBVT_DWORD:
							if ((fi->options & F_NUMSRCH) && numsearch == getNumericValue(&dbv)) {
								TCHAR *val = fi->search;
								int flag = F_SETVAL;

								if (fi->options & F_NUMREPL) {
								    if (replace[0]) {
										db_unset(hContact, module->name, setting->name);
										flag |= F_DELETED;
										deleteCount++;
									} 
									else
									if (setNumericValue(hContact, module->name, setting->name, numreplace, dbv.type)) {
										val = fi->replace;
										flag |= F_REPLACED;
										replaceCount++;
									}
								}

								ItemFound(fi->hwnd, hContact, module->name, setting->name, val, flag);
							}
							break;

						case DBVT_WCHAR:
							if (!value) value = mir_u2t(dbv.pwszVal);
						case DBVT_UTF8:
							if (!value) value = mir_utf8decodeT(dbv.pszVal);
						case DBVT_ASCIIZ:
							if (!value) value = mir_a2t(dbv.pszVal);

							if (FindMatchT(value, fi->search, fi->options)) {
								foundCount++;
								ptrT ptr;
								TCHAR *newValue = value;
								int flag = F_SETVAL;

								if (fi->replace) {
									newValue = (fi->options & F_ENTIRE) ? fi->replace : ptr = multiReplaceT(value, fi->search, fi->replace, fi->options & F_CASE);
									// !!!! delete or make empty ?
									if (!newValue[0]) {
										db_unset(hContact, module->name, setting->name);
										flag |= F_DELETED;
										newValue = value;
										deleteCount++;
									} else {
#ifdef _UNICODE
                                        // save as unicode if needed
										if (dbv.type != DBVT_ASCIIZ || IsRealUnicode(newValue))
											db_set_ws(hContact, module->name, setting->name, newValue);
										else												
#endif
											db_set_s(hContact, module->name, setting->name, _T2A(newValue)); 
										flag |= F_REPLACED;
										replaceCount++;
									}
								}

								ItemFound(fi->hwnd, hContact, module->name, setting->name, newValue, flag);
							}
							mir_free(value);
							break;
						} // switch
					}

					// check in setting name
					if ((fi->options & F_SETNAME) && FindMatchA(setting->name, search, fi->options)) {
						foundCount++;
						ptrA ptr;
						char *newSetting = setting->name;
						int flag = F_SETNAME;

						if (replace) {
							newSetting = (fi->options & F_ENTIRE) ? replace : ptr = multiReplaceA(setting->name, search, replace, fi->options & F_CASE);

							if (!newSetting[0]) {
								db_unset(hContact, module->name, setting->name);
								flag |= F_DELETED;
								newSetting = setting->name;
								deleteCount++;
							} else {
								DBVARIANT dbv2;
								// skip if exist
								if (!db_get_s(hContact, module->name, newSetting, &dbv2, 0)) 
									db_free(&dbv2);
								else if (!db_set(hContact, module->name, newSetting, &dbv)) {
									db_unset(hContact, module->name, setting->name);
									flag |= F_REPLACED;
							 		replaceCount++;
								}
							}
						}

						ItemFound(fi->hwnd, hContact, module->name, newSetting, NULL, flag);
					}

					db_free(&dbv);

				} // for(setting)

				FreeModuleSettingLL(&SettingList);
			}

			// check in module name
			if ((fi->options & F_MODNAME) && FindMatchA(module->name, search, fi->options)) {
				foundCount++;
				char *newModule = module->name;
				int flag = F_MODNAME;
				ptrA ptr;

				if (replace) {
					newModule = (fi->options & F_ENTIRE) ? replace : ptr = multiReplaceA(module->name, search, replace, fi->options & F_CASE);
								
					if (!newModule[0]) {
						deleteModule(hContact, module->name, 0);
						replaceTreeItem(hContact, module->name, NULL);
						flag |= F_DELETED;
						newModule = module->name;
						deleteCount++;
					} 
					else if (renameModule(hContact, module->name, newModule)) {
   						replaceTreeItem(hContact, module->name, NULL);
						flag |= F_REPLACED;
						replaceCount++;
					}
				}

				ItemFound(fi->hwnd, hContact, newModule, 0, 0, flag);
			}

		} // for(module)
	}

	TCHAR msg[MSG_SIZE];	
	mir_sntprintf(msg, TranslateT("Finished. Items found: %d / replaced: %d / deleted: %d"), foundCount, replaceCount, deleteCount);
	SendDlgItemMessage(hwndParent, IDC_SBAR, SB_SETTEXT, 0, (LPARAM)msg);

	if (fi->replace) {
		EnableWindow(GetDlgItem(hwndParent, IDC_SEARCH), 1);
		SetDlgItemText(hwndParent, IDOK, TranslateT("&Replace"));
	}
	else {
		SetDlgItemText(hwndParent, IDC_SEARCH, TranslateT("&Search"));
		EnableWindow(GetDlgItem(hwndParent, IDOK), 1);
	}

	fi_free(fi);
	FreeModuleSettingLL(&ModuleList);

	SetWindowLongPtr(GetDlgItem(hwndParent, IDC_SEARCH), GWLP_USERDATA, 0);
	EnableWindow(GetDlgItem(hwndParent, IDCANCEL), 1);
}
Пример #26
0
static int
readprocfdinit(void)
{
	/* construct info from /proc/$pid/fd */
	char buf[8192];
	Fdinfo *fi;
	int fd, pfd, pid, n, tot, m;
	char *s, *nexts;

	memset(buf, 0, sizeof buf);
	pfd = _OPEN("#c/pid", 0);
	if(pfd < 0)
		return -1;
	if(_PREAD(pfd, buf, 100, 0) < 0){
		_CLOSE(pfd);
		return -1;
	}
	_CLOSE(pfd);
	pid = strtoul(buf, 0, 10);
	strcpy(buf, "#p/");
	_ultoa(buf+3, pid);
	strcat(buf, "/fd");
	pfd = _OPEN(buf, 0);
	if(pfd < 0)
		return -1;
	memset(buf, 0, sizeof buf);
	tot = 0;
	for(;;){
		n = _PREAD(pfd, buf+tot, sizeof buf-tot, tot);
		if(n <= 0)
			break;
		tot += n;
	}
	_CLOSE(pfd);
	if(n < 0)
		return -1;
	buf[sizeof buf-1] = '\0';
	s = strchr(buf, '\n');	/* skip current directory */
	if(s == 0)
		return -1;
	s++;
	m = 0;
	for(; s && *s; s=nexts){
		nexts = strchr(s, '\n');
		if(nexts)
			*nexts++ = '\0';
		errno = 0;
		fd = strtoul(s, &s, 10);
		if(errno != 0)
			return -1;
		if(fd >= OPEN_MAX)
			continue;
		if(fd == pfd)
			continue;
		fi = &_fdinfo[fd];
		fi->flags = FD_ISOPEN;
		while(*s == ' ' || *s == '\t')
			s++;
		if(*s == 'r'){
			m |= 1;
			s++;
		}
		if(*s == 'w'){
			m |= 2;
		}
		if(m==1)
			fi->oflags = O_RDONLY;
		else if(m==2)
			fi->oflags = O_WRONLY;
		else
			fi->oflags = O_RDWR;
		if(strlen(s) >= 9 && strcmp(s+strlen(s)-9, "/dev/cons") == 0)
			fi->flags |= FD_ISTTY;
	}
	return 0;
}
Пример #27
0
int
execve(const char *name, const char *argv[], const char *envp[])
{
	int n, f, i;
	char **e, *ss, *se;
	Fdinfo *fi;
	unsigned long flags;
	char nam[256+5];
	char buf[1000];

	_RFORK(RFCENVG);
	/*
	 * To pass _fdinfo[] across exec, put lines like
	 *   fd flags oflags
	 * in $_fdinfo (for open fd's)
	 */

	f = _CREATE("#e/_fdinfo", OWRITE, 0666);
	ss = buf;
	for(n = 0; n<OPEN_MAX; n++){
		fi = &_fdinfo[n];
		flags = fi->flags;
		if(flags&FD_CLOEXEC){
			_CLOSE(n);
			fi->flags = 0;
			fi->oflags = 0;
		}else if(flags&FD_ISOPEN){
			ss = _ultoa(ss, n);
			*ss++ = ' ';
			ss = _ultoa(ss, flags);
			*ss++ = ' ';
			ss = _ultoa(ss, fi->oflags);
			*ss++ = '\n';
			if(ss-buf < sizeof(buf)-50){
				_WRITE(f, buf, ss-buf);
				ss = buf;
			}
		}
	}
	if(ss > buf)
		_WRITE(f, buf, ss-buf);
	_CLOSE(f);
	/*
	 * To pass _sighdlr[] across exec, set $_sighdlr
	 * to list of blank separated fd's that have
	 * SIG_IGN (the rest will be SIG_DFL).
	 * We write the variable, even if no signals
	 * are ignored, in case the current value of the
	 * variable ignored some.
	 */
	f = _CREATE("#e/_sighdlr", OWRITE, 0666);
	if(f >= 0){
		ss = buf;
		for(i = 0; i <=MAXSIG && ss < &buf[sizeof(buf)]-5; i++) {
			if(_sighdlr[i] == SIG_IGN) {
				ss = _ultoa(ss, i);
				*ss++ = ' ';
			}
		}
		_WRITE(f, buf, ss-buf);
		_CLOSE(f);
	}
	if(envp){
		strcpy(nam, "#e/");
		for(e = (char **)envp; (ss = *e); e++) {
			se = strchr(ss, '=');
			if(!se || ss==se)
				continue;	/* what is name? value? */
			n = se-ss;
			if(n >= sizeof(nam)-3)
				n = sizeof(nam)-3-1;
			memcpy(nam+3, ss, n);
			nam[3+n] = 0;
			f = _CREATE(nam, OWRITE, 0666);
			if(f < 0)
				continue;
			se++; /* past = */
			n = strlen(se);
			/* temporarily decode nulls (see _envsetup()) */
			for(i=0; i < n; i++)
				if(se[i] == 1)
					se[i] = 0;
			_WRITE(f, se, n);
			/* put nulls back */
			for(i=0; i < n; i++)
				if(se[i] == 0)
					se[i] = 1;
			_CLOSE(f);
		}
	}
	n = _EXEC(name, argv);
	_syserrno();
	return n;
}
Пример #28
0
static DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
{
	ULONG	CommitChargeTotal;
	ULONG	CommitChargeLimit;
	ULONG	CommitChargePeak;

	ULONG	KernelMemoryTotal;
	ULONG	KernelMemoryPaged;
	ULONG	KernelMemoryNonPaged;

	ULONG	PhysicalMemoryTotal;
	ULONG	PhysicalMemoryAvailable;
	ULONG	PhysicalMemorySystemCache;

	ULONG	TotalHandles;
	ULONG	TotalThreads;
	ULONG	TotalProcesses;

	TCHAR	Text[260];

	/*  Create the event */
	hPerformancePageEvent = CreateEvent(NULL, TRUE, TRUE, NULL);

	/*  If we couldn't create the event then exit the thread */
	if (!hPerformancePageEvent)
		return 0;

	while (1)
	{
		DWORD	dwWaitVal;

		/*  Wait on the event */
		dwWaitVal = WaitForSingleObject(hPerformancePageEvent, INFINITE);

		/*  If the wait failed then the event object must have been */
		/*  closed and the task manager is exiting so exit this thread */
		if (dwWaitVal == WAIT_FAILED)
			return 0;

		if (dwWaitVal == WAIT_OBJECT_0)
		{
			ULONG CpuUsage;
			ULONG CpuKernelUsage;
			int nBarsUsed1;
			int nBarsUsed2;

			/*  Reset our event */
			ResetEvent(hPerformancePageEvent);

			/* 
			 *  Update the commit charge info
			 */ 
			CommitChargeTotal = PerfDataGetCommitChargeTotalK();
			CommitChargeLimit = PerfDataGetCommitChargeLimitK();
			CommitChargePeak = PerfDataGetCommitChargePeakK();
			_ultoa(CommitChargeTotal, Text, 10);
			SetWindowText(hPerformancePageCommitChargeTotalEdit, Text);
			_ultoa(CommitChargeLimit, Text, 10);
			SetWindowText(hPerformancePageCommitChargeLimitEdit, Text);
			_ultoa(CommitChargePeak, Text, 10);
			SetWindowText(hPerformancePageCommitChargePeakEdit, Text);
			wsprintf(Text, _T("Mem Usage: %dK / %dK"), CommitChargeTotal, CommitChargeLimit);
			SendMessage(hStatusWnd, SB_SETTEXT, 2, (LPARAM)Text);

			/* 
			 *  Update the kernel memory info
			 */ 
			KernelMemoryTotal = PerfDataGetKernelMemoryTotalK();
			KernelMemoryPaged = PerfDataGetKernelMemoryPagedK();
			KernelMemoryNonPaged = PerfDataGetKernelMemoryNonPagedK();
			_ultoa(KernelMemoryTotal, Text, 10);
			SetWindowText(hPerformancePageKernelMemoryTotalEdit, Text);
			_ultoa(KernelMemoryPaged, Text, 10);
			SetWindowText(hPerformancePageKernelMemoryPagedEdit, Text);
			_ultoa(KernelMemoryNonPaged, Text, 10);
			SetWindowText(hPerformancePageKernelMemoryNonPagedEdit, Text);

			/* 
			 *  Update the physical memory info
			 */ 
			PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK();
			PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
			PhysicalMemorySystemCache = PerfDataGetPhysicalMemorySystemCacheK();
			_ultoa(PhysicalMemoryTotal, Text, 10);
			SetWindowText(hPerformancePagePhysicalMemoryTotalEdit, Text);
			_ultoa(PhysicalMemoryAvailable, Text, 10);
			SetWindowText(hPerformancePagePhysicalMemoryAvailableEdit, Text);
			_ultoa(PhysicalMemorySystemCache, Text, 10);
			SetWindowText(hPerformancePagePhysicalMemorySystemCacheEdit, Text);

			/* 
			 *  Update the totals info
			 */ 
			TotalHandles = PerfDataGetSystemHandleCount();
			TotalThreads = PerfDataGetTotalThreadCount();
			TotalProcesses = PerfDataGetProcessCount();
			_ultoa(TotalHandles, Text, 10);
			SetWindowText(hPerformancePageTotalsHandleCountEdit, Text);
			_ultoa(TotalThreads, Text, 10);
			SetWindowText(hPerformancePageTotalsThreadCountEdit, Text);
			_ultoa(TotalProcesses, Text, 10);
			SetWindowText(hPerformancePageTotalsProcessCountEdit, Text);

			/* 
			 *  Redraw the graphs
			 */ 
			InvalidateRect(hPerformancePageCpuUsageGraph, NULL, FALSE);
			InvalidateRect(hPerformancePageMemUsageGraph, NULL, FALSE);

                        /*
                         *  Get the CPU usage
                         */
                        CpuUsage = PerfDataGetProcessorUsage();
                        CpuKernelUsage = PerfDataGetProcessorSystemUsage();

                        /*
                         *  Get the memory usage
                         */
                        CommitChargeTotal = (ULONGLONG)PerfDataGetCommitChargeTotalK();
                        CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK();
                        nBarsUsed1 = CommitChargeLimit ? ((CommitChargeTotal * 100) / CommitChargeLimit) : 0;

                        PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK();
                        PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
                        nBarsUsed2 = PhysicalMemoryTotal ? ((PhysicalMemoryAvailable * 100) / PhysicalMemoryTotal) : 0;


                        GraphCtrl_AppendPoint(&PerformancePageCpuUsageHistoryGraph, CpuUsage, CpuKernelUsage, 0.0, 0.0);
                        GraphCtrl_AppendPoint(&PerformancePageMemUsageHistoryGraph, nBarsUsed1, nBarsUsed2, 0.0, 0.0);
                        /* PerformancePageMemUsageHistoryGraph.SetRange(0.0, 100.0, 10) ; */
                        InvalidateRect(hPerformancePageMemUsageHistoryGraph, NULL, FALSE);
                        InvalidateRect(hPerformancePageCpuUsageHistoryGraph, NULL, FALSE);
                }
	}
        return 0;
}
Пример #29
0
Файл: cmp.c Проект: 8l/FUZIX
void main(int argc, char *argv[])
{
	int		fd1;
	int		fd2;
	int		cc1;
	int		cc2;
	long		pos;
	char		*bp1;
	char		*bp2;
	struct	stat	statbuf1;
	struct	stat	statbuf2;

	if (argc < 3) {
		eputstr(argv[0]);
		eputstr(": file1 file2.\n");
		exit(2);
	}
	if (stat(argv[1], &statbuf1) < 0) {
		perror(argv[1]);
		exit(2);
	}

	if (stat(argv[2], &statbuf2) < 0) {
		perror(argv[2]);
		exit(2);
	}

	if ((statbuf1.st_dev == statbuf2.st_dev) &&
		(statbuf1.st_ino == statbuf2.st_ino))
	{
		putstr("Files are links to each other\n");
		exit(0);
	}

	if (statbuf1.st_size != statbuf2.st_size) {
		putstr("Files are different sizes\n");
		exit(1);
	}

	fd1 = open(argv[1], 0);
	if (fd1 < 0) {
		perror(argv[1]);
		exit(2);
	}

	fd2 = open(argv[2], 0);
	if (fd2 < 0) {
		perror(argv[2]);
		close(fd1);
		exit(2);
	}

	pos = 0;
	while (1) {
		cc1 = read(fd1, buf1, sizeof(buf1));
		if (cc1 < 0) {
			perror(argv[1]);
			exit(2);
		}

		cc2 = read(fd2, buf2, sizeof(buf2));
		if (cc2 < 0) {
			perror(argv[2]);
			goto differ;
		}

		if ((cc1 == 0) && (cc2 == 0)) {
			putstr("Files are identical\n");
			goto same;
		}

		if (cc1 < cc2) {
			putstr("First file is shorter than second\n");
			goto differ;
		}

		if (cc1 > cc2) {
			putstr("Second file is shorter than first\n");
			goto differ;
		}

		if (memcmp(buf1, buf2, cc1) == 0) {
			pos += cc1;
			continue;
		}

		bp1 = buf1;
		bp2 = buf2;
		while (*bp1++ == *bp2++)
			pos++;

		putstr("Files differ at byte position ");
		bp1 = _ultoa(pos);
		putstr(bp1);
		putstr("\n");
		goto differ;
	}
same:
	exit(0);
differ:
	exit(1);
}
Пример #30
0
VOID
NetpMakeTimeString(
    struct tm           *TimeStruct,
    LPNET_TIME_FORMAT   TimeFormat,
    CHAR                *Buffer,
    int                 BufferLength
    )

/*++

Routine Description:

    This function reads the current time, and creates a string in the
    format specified in the TimeFormat structure.  The string is placed
    in the Buffer passed in by the caller.

Arguments:

    TimeStruct - This a pointer to a c-runtime time structure that is
        to be used to make a time string.

    TimeFormat - This is a pointer to a structure that contains format
        information for the time string.

    Buffer - A pointer to a buffer that will contain the time string
        upon exit.

    BufferLength - The number of characters the buffer will hold.

Return Value:


--*/
{
    LPSTR       pParseString;
    CHAR        czTimeString[MAX_TIME_SIZE];
    LPSTR       pCurLoc;
    LPSTR       pTime;
    INT         numChars;
    INT         i,dateType;
    DWORD       numSame;
    LPSTR       ProfileLoc = "intl";
    LPSTR       emptyStr = "";
    DWORD       dateStringSize;
    LPSTR       pAMPMString;


    pParseString = TimeFormat->DateFormat;
    if (pParseString != NULL) {
        numChars = strlen(pParseString);
    }
    else {
        numChars = 0;
    }

    czTimeString[0]='\0';

    //-----------------------------------------
    // Fill in the date string
    //-----------------------------------------
    pCurLoc = czTimeString;

    for (i=0; i<numChars; i++ ) {

        dateType = i;
        numSame  = 1;

        //
        // Find out how many characters are the same.
        // (MM or M, dd or d, yy or yyyy)
        //
        while (pParseString[i] == pParseString[i+1]) {
            numSame++;
            i++;
        }

        //
        // i is the offset to the last character in the date type.
        //

        switch (pParseString[dateType]) {
        case 'M':
        case 'm':
            //
            // Month goes from 0-11.  So we must increment it.
            //
            TimeStruct->tm_mon++;

            //
            // If we have a single digit month, but require 2 digits,
            // then add a leading zero.
            //
            if ((numSame == 2) && (TimeStruct->tm_mon < 10)) {
                *pCurLoc = '0';
                pCurLoc++;
            }
            _ultoa(TimeStruct->tm_mon, pCurLoc, 10);
            pCurLoc += strlen(pCurLoc);
            break;

        case 'D':
        case 'd':

            //
            // If we have a single digit day, but require 2 digits,
            // then add a leading zero.
            //
            if ((numSame == 2) && (TimeStruct->tm_mday < 10)) {
                *pCurLoc = '0';
                pCurLoc++;
            }
            _ultoa(TimeStruct->tm_mday, pCurLoc, 10);
            pCurLoc += strlen(pCurLoc);
            break;

        case 'Y':
        case 'y':

            TimeStruct->tm_year += 1900;
            _ultoa(TimeStruct->tm_year, pCurLoc, 10);
            //
            // If we are only to show 2 digits, take the
            // 3rd and 4th, and move them into the first two
            // locations.
            //
            if (numSame == 2) {
                pCurLoc[0] = pCurLoc[2];
                pCurLoc[1] = pCurLoc[3];
                pCurLoc[2] = '\0';
            }
            pCurLoc += strlen(pCurLoc);
            break;

        default:
            NetpKdPrint(( PREFIX_NETLIB
                    "NetpMakeTimeString: "
                    "Default case: Unrecognized time character - "
                    "We Should never get here\n" ));
            break;
        }
        //
        // Increment the index beyond the last character in the data type.
        // If not at the end of the buffer, add the separator character.
        // Otherwise, add the trailing NUL.
        //
        i++;
        if ( i < numChars ) {
            *pCurLoc = pParseString[i];
            pCurLoc++;
        }
        else {
            *pCurLoc='\0';
        }
    }

    //
    // Build the time string
    //
    if (TimeFormat->TwelveHour) {
        if (TimeStruct->tm_hour > 11) {
            pAMPMString = TimeFormat->PMString;
        }
        else {
            pAMPMString = TimeFormat->AMString;
        }
    }
    else {
        pAMPMString = emptyStr;
    }
    dateStringSize = strlen(czTimeString);
    pTime = czTimeString + (dateStringSize + 1);

    //
    // If TimePrefix is TRUE, we should put AMPMstring first.
    //
	if(TimeFormat->TimePrefix ){
        strcpy(pTime,pAMPMString);
    	pTime += strlen(pTime);
	}

    if (TimeFormat->TwelveHour) {
        if (TimeStruct->tm_hour > 12) {
            TimeStruct->tm_hour -= 12;
        }
        else if (TimeStruct->tm_hour < 1) {
            TimeStruct->tm_hour += 12;
        }
    }
    //
    // If the time is a single digit, and we need a leading zero,
    // than add the leading zero.
    //
    if ((TimeStruct->tm_hour < 10) && (TimeFormat->LeadingZero)) {
        *pTime = '0';
        pTime++;
    }
    //
    // Hour
    //
    _ultoa(TimeStruct->tm_hour, pTime, 10);
    pTime += strlen(pTime);
    //
    // Time Separator
    //
    strcat(pTime, TimeFormat->TimeSeparator);
    pTime += strlen(pTime);

    //
    // Minutes
    //
    if (TimeStruct->tm_min < 10) {
        *pTime = '0';
        pTime++;
    }
    _ultoa(TimeStruct->tm_min, pTime, 10);

	if( !TimeFormat->TimePrefix ){
	    if (strlen(pAMPMString) <= MAX_AM_PM) {
		    strcat(pTime,pAMPMString);
	    }
	}

    pTime = czTimeString + (strlen(czTimeString) + 1);

    //
    // If there is a date string, add a space as a seperator between
    // it and the time string.
    //
    if (dateStringSize > 0) {
        *(--pTime) = ' ';
    }

    numChars = strlen(czTimeString)+1;
    if (numChars > BufferLength) {
        numChars = BufferLength;
    }
    strncpy(Buffer, czTimeString, numChars);
}