mirror of
https://github.com/reactos/reactos.git
synced 2024-10-20 16:06:27 +00:00
[CMAKE]
Sync trunk up to r50477. svn path=/branches/cmake-bringup/; revision=50504
This commit is contained in:
commit
e2b7eacdd5
|
@ -1,4 +1,5 @@
|
|||
|
||||
set_unicode()
|
||||
add_definitions(-D__USE_W32_SOCKETS)
|
||||
|
||||
add_executable(ping ping.c ping.rc)
|
||||
|
|
35
base/applications/network/ping/lang/de-DE.rc
Normal file
35
base/applications/network/ping/lang/de-DE.rc
Normal file
|
@ -0,0 +1,35 @@
|
|||
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_USAGE "\nSyntax: ping [-t] [-n Anzahl] [-l Größe] [-w Zeitlimit] Zielhost\n\n" \
|
||||
"Optionen:\n" \
|
||||
" -t Sendet fortlaufend Pings an den angegebenen Host.\n" \
|
||||
" Drücken Sie STRG-C, um den Vorgang abzubrechen.\n" \
|
||||
" -n Anzahl Anzahl der Echoanforderungen, die gesendet werden.\n" \
|
||||
" -l Größe Größe des Sendepuffers.\n" \
|
||||
" -w Zeitlimit Zeitlimit in Millisekunden für eine Antwort.\n\n\0"
|
||||
|
||||
IDS_PING_WITH_BYTES "\nPinging %1 [%2] with %3!d! bytes Data:\n\n\0"
|
||||
IDS_PING_STATISTICS "\nPing Statistik für %1:\n\0"
|
||||
IDS_PACKETS_SENT_RECEIVED_LOST " Packets: Gesendet = %1!d!, Empfangen = %2!d!, Verloren = %3!d! (%4!d!%% Verlust),\n\0"
|
||||
IDS_APPROXIMATE_ROUND_TRIP "Durchschnittliche Antwortzeit in Millisekunden:\n\0"
|
||||
IDS_MIN_MAX_AVERAGE " Minimum = %1, Maximum = %2, Durchschnitt = %3\n\0"
|
||||
IDS_NOT_ENOUGH_RESOURCES "Nicht genügend freie Resourcen verfügbar.\n\0"
|
||||
IDS_UNKNOWN_HOST "Unbekannter Host %1.\n\0"
|
||||
IDS_SETSOCKOPT_FAILED "setsockopt ist fehlgeschlagen (%1!d!).\n\0"
|
||||
IDS_COULD_NOT_CREATE_SOCKET "Konnte keinen Socket erzeugen (#%1!d!).\n\0"
|
||||
IDS_COULD_NOT_INIT_WINSOCK "Die Winsock DLL konnte nicht initialisiert werden.\n\0"
|
||||
IDS_DEST_MUST_BE_SPECIFIED "Name oder IP-Address des Zielhostes muss angegeben werden.\n\0"
|
||||
IDS_BAD_PARAMETER "Ungültiger Parameter %1.\n\0"
|
||||
IDS_BAD_OPTION_FORMAT "Ungültiges Options-Format %1.\n\0"
|
||||
IDS_BAD_OPTION "Ungültige Option %1.\n\0"
|
||||
IDS_BAD_VALUE_OPTION_L "Ungültiger Wert für Option -l, Erlaubter Bereich ist von 0 bis %1!d!.\n\0"
|
||||
IDS_REPLY_FROM "Antwort von %1: bytes=%2!d! time%3%4 TTL=%5!d!\n\0"
|
||||
IDS_DEST_UNREACHABLE "Zielhost nicht erreichbar.\n\0"
|
||||
IDS_COULD_NOT_TRANSMIT "Es konnten keine Daten gesendet werden (%1!d!).\n\0"
|
||||
IDS_COULD_NOT_RECV "Es konnten keine Daten empfangen werden (%1!d!).\n\0"
|
||||
IDS_REQUEST_TIMEOUT "Zeitüberschreitung der Anforderung.\n\0"
|
||||
IDS_MS "ms\0"
|
||||
IDS_1MS "1ms\0"
|
||||
END
|
35
base/applications/network/ping/lang/en-US.rc
Normal file
35
base/applications/network/ping/lang/en-US.rc
Normal file
|
@ -0,0 +1,35 @@
|
|||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_USAGE "\nUsage: ping [-t] [-n count] [-l size] [-w timeout] destination-host\n\n" \
|
||||
"Options:\n" \
|
||||
" -t Ping the specified host until stopped.\n" \
|
||||
" To stop - type Control-C.\n" \
|
||||
" -n count Number of echo requests to send.\n" \
|
||||
" -l size Send buffer size.\n" \
|
||||
" -w timeout Timeout in milliseconds to wait for each reply.\n\n\0"
|
||||
|
||||
IDS_PING_WITH_BYTES "\nPinging %1 [%2] with %3!d! bytes of data:\n\n\0"
|
||||
IDS_PING_STATISTICS "\nPing statistics for %1:\n\0"
|
||||
IDS_PACKETS_SENT_RECEIVED_LOST " Packets: Sent = %1!d!, Received = %2!d!, Lost = %3!d! (%4!d!%% loss),\n\0"
|
||||
IDS_APPROXIMATE_ROUND_TRIP "Approximate round trip times in milli-seconds:\n\0"
|
||||
IDS_MIN_MAX_AVERAGE " Minimum = %1, Maximum = %2, Average = %3\n\0"
|
||||
IDS_NOT_ENOUGH_RESOURCES "Not enough free resources available.\n\0"
|
||||
IDS_UNKNOWN_HOST "Unknown host %1.\n\0"
|
||||
IDS_SETSOCKOPT_FAILED "setsockopt failed (%1!d!).\n\0"
|
||||
IDS_COULD_NOT_CREATE_SOCKET "Could not create socket (#%1!d!).\n\0"
|
||||
IDS_COULD_NOT_INIT_WINSOCK "Could not initialize winsock dll.\n\0"
|
||||
IDS_DEST_MUST_BE_SPECIFIED "Name or IP address of destination host must be specified.\n\0"
|
||||
IDS_BAD_PARAMETER "Bad parameter %1.\n\0"
|
||||
IDS_BAD_OPTION_FORMAT "Bad option format %1.\n\0"
|
||||
IDS_BAD_OPTION "Bad option %1.\n\0"
|
||||
IDS_BAD_VALUE_OPTION_L "Bad value for option -l, valid range is from 0 to %1!d!.\n\0"
|
||||
IDS_REPLY_FROM "Reply from %1: bytes=%2!d! time%3%4 TTL=%5!d!\n\0"
|
||||
IDS_DEST_UNREACHABLE "Destination host unreachable.\n\0"
|
||||
IDS_COULD_NOT_TRANSMIT "Could not transmit data (%1!d!).\n\0"
|
||||
IDS_COULD_NOT_RECV "Could not receive data (%1!d!).\n\0"
|
||||
IDS_REQUEST_TIMEOUT "Request timed out.\n\0"
|
||||
IDS_MS "ms\0"
|
||||
IDS_1MS "1ms\0"
|
||||
END
|
35
base/applications/network/ping/lang/fr-FR.rc
Normal file
35
base/applications/network/ping/lang/fr-FR.rc
Normal file
|
@ -0,0 +1,35 @@
|
|||
LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_USAGE "\nUtilisation : ping [-t] [-n nombre] [-l taille] [-w délai] hôte-destination\n\n" \
|
||||
"Options :\n" \
|
||||
" -t Ping l'hôte spécifié jusqu'à l'arrêt.\n" \
|
||||
" Pour l'arrêter, tapez Ctrl+c.\n" \
|
||||
" -n nombre Nombre de requêtes echo à envoyer.\n" \
|
||||
" -l taille Taille du tampon d'envoi.\n" \
|
||||
" -w délai Délai d'attente en millisecondes pour chaque réponse.\n\n\0"
|
||||
|
||||
IDS_PING_WITH_BYTES "\nPing de %1 [%2] avec %3!d! octets de données :\n\n\0"
|
||||
IDS_PING_STATISTICS "\nStatistiques du ping de %1 :\n\0"
|
||||
IDS_PACKETS_SENT_RECEIVED_LOST " Paquets : Envoyés = %1!d!, Reçus = %2!d!, Perdus = %3!d! (%4!d!%% de perte),\n\0"
|
||||
IDS_APPROXIMATE_ROUND_TRIP "Délai approximatif de réponse en millisecondes :\n\0"
|
||||
IDS_MIN_MAX_AVERAGE " Minimum = %1, Maximum = %2, Moyenne = %3\n\0"
|
||||
IDS_NOT_ENOUGH_RESOURCES "Ressources libres disponibles insuffisantes.\n\0"
|
||||
IDS_UNKNOWN_HOST "Hôte inconnu %1.\n\0"
|
||||
IDS_SETSOCKOPT_FAILED "Échec de setsockopt (%1!d!).\n\0"
|
||||
IDS_COULD_NOT_CREATE_SOCKET "Impossible de créer la socket (#%1!d!).\n\0"
|
||||
IDS_COULD_NOT_INIT_WINSOCK "Impossible d'initialiser winsock dll.\n\0"
|
||||
IDS_DEST_MUST_BE_SPECIFIED "Le nom ou l'adresse IP de l'hôte de destination doit être spécifié.\n\0"
|
||||
IDS_BAD_PARAMETER "Paramètre incorrect %1.\n\0"
|
||||
IDS_BAD_OPTION_FORMAT "Format d'option incorrect %1.\n\0"
|
||||
IDS_BAD_OPTION "Option incorrecte %1.\n\0"
|
||||
IDS_BAD_VALUE_OPTION_L "Valeur incorrecte pour l'option -l, elle doit être entre 0 et %1!d!.\n\0"
|
||||
IDS_REPLY_FROM "Réponse de %1 : octets=%2!d! durée%3%4 TTL=%5!d!\n\0"
|
||||
IDS_DEST_UNREACHABLE "Hôte de destination injoignable.\n\0"
|
||||
IDS_COULD_NOT_TRANSMIT "Échec lors de la transmission (%1!d!).\n\0"
|
||||
IDS_COULD_NOT_RECV "Échec lors de la récéption (%1!d!).\n\0"
|
||||
IDS_REQUEST_TIMEOUT "Expiration du délai d'attente.\n\0"
|
||||
IDS_MS "ms\0"
|
||||
IDS_1MS "1ms\0"
|
||||
END
|
35
base/applications/network/ping/lang/it-IT.rc
Normal file
35
base/applications/network/ping/lang/it-IT.rc
Normal file
|
@ -0,0 +1,35 @@
|
|||
LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_USAGE "\nUso: ping [-t] [-n conteggio] [-l dimensione] [-w timeout] host-destinazione\n\n" \
|
||||
"Opzioni:\n" \
|
||||
" -t Esegue il ping dell'host specificato finchè non termina.\n" \
|
||||
" Per fermare - digitare Control-C.\n" \
|
||||
" -n conteggio Numero di richieste echo da inviare.\n" \
|
||||
" -l dimensione Dimensione del buffer di invio.\n" \
|
||||
" -w timeout Timeout in millisecondi per l'attesa di ogni risposta.\n\n\0"
|
||||
|
||||
IDS_PING_WITH_BYTES "\nPing in corso %1 [%2] con %3!d! bytes di dati:\n\n\0"
|
||||
IDS_PING_STATISTICS "\nStatistiche di Ping per %1:\n\0"
|
||||
IDS_PACKETS_SENT_RECEIVED_LOST " Pacchetti: Inviati = %1!d!, Ricevuti = %2!d!, Persi = %3!d! (%4!d!%% perdita),\n\0"
|
||||
IDS_APPROXIMATE_ROUND_TRIP "Tempo approssimato di andata e ritorno in milli-secondi:\n\0"
|
||||
IDS_MIN_MAX_AVERAGE " Minimo = %1, Massimo = %2, Media = %3\n\0"
|
||||
IDS_NOT_ENOUGH_RESOURCES "Risorse disponibili insufficienti.\n\0"
|
||||
IDS_UNKNOWN_HOST "Host sconosciuto%1.\n\0"
|
||||
IDS_SETSOCKOPT_FAILED "setsockopt fallito (%1!d!).\n\0"
|
||||
IDS_COULD_NOT_CREATE_SOCKET "Impossibile creare il socket (#%1!d!).\n\0"
|
||||
IDS_COULD_NOT_INIT_WINSOCK "Impossibile inizializzare winsock dll.\n\0"
|
||||
IDS_DEST_MUST_BE_SPECIFIED "Il nome o l'IP dell'host deve essere specificato.\n\0"
|
||||
IDS_BAD_PARAMETER "Parametro errato %1.\n\0"
|
||||
IDS_BAD_OPTION_FORMAT "Formato opzione errato %1.\n\0"
|
||||
IDS_BAD_OPTION "Opzione errata %1.\n\0"
|
||||
IDS_BAD_VALUE_OPTION_L "Valore errato per il parametro -l, l'intervallo valido è tra 0 to %1!d!.\n\0"
|
||||
IDS_REPLY_FROM "Risposta da %1: bytes=%2!d! time%3%4 TTL=%5!d!\n\0"
|
||||
IDS_DEST_UNREACHABLE "Host destinazione irraggiungibile.\n\0"
|
||||
IDS_COULD_NOT_TRANSMIT "Impossibile trasmettere dati (%1!d!).\n\0"
|
||||
IDS_COULD_NOT_RECV "Impossibile ricevere dati (%1!d!).\n\0"
|
||||
IDS_REQUEST_TIMEOUT "Richiesta scaduta.\n\0"
|
||||
IDS_MS "ms\0"
|
||||
IDS_1MS "1ms\0"
|
||||
END
|
42
base/applications/network/ping/lang/pl-PL.rc
Normal file
42
base/applications/network/ping/lang/pl-PL.rc
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* translated by Caemyr (Olaf Siejka)
|
||||
* caemyr@gmail.com
|
||||
* Jan, 2011
|
||||
*/
|
||||
|
||||
|
||||
LANGUAGE LANG_POLISH, SUBLANG_DEFAULT
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_USAGE "\nSposób użycia: ping [-t] [-n ilość] [-l bajtów] [-w czas] host-docelowy\n\n" \
|
||||
"Opcje:\n" \
|
||||
" -t Pinguj wskazanego hosta w sposób ciągły.\n" \
|
||||
" Aby przerwać - wciśnij Control C.\n" \
|
||||
" -n ilość Ilość prób pingowania.\n" \
|
||||
" -l bajtów Rozmiar pakietu echo w bajtach .\n" \
|
||||
" -w czas Opóźnienie oczekiwanej odpowiedzi, w milisekundach.\n\n\0"
|
||||
|
||||
IDS_PING_WITH_BYTES "\nPingowanie %1 [%2] przy użyciu %3!d! bajtów danych:\n\n\0"
|
||||
IDS_PING_STATISTICS "\nStatystyka wyników badania hosta %1:\n\0"
|
||||
IDS_PACKETS_SENT_RECEIVED_LOST " Pakiety: Wysłane = %1!d!, Odebrane = %2!d!, Utracone = %3!d! (%4!d!%% strat),\n\0"
|
||||
IDS_APPROXIMATE_ROUND_TRIP "Całkowity, przybliżony czas podróży pakietu w millisekundach:\n\0"
|
||||
IDS_MIN_MAX_AVERAGE " Minimum = %1, Maksimum = %2, Uśredniony = %3\n\0"
|
||||
IDS_NOT_ENOUGH_RESOURCES "Brak dostępnych zasobów.\n\0"
|
||||
IDS_UNKNOWN_HOST "Nieznany host %1.\n\0"
|
||||
IDS_SETSOCKOPT_FAILED "Błąd w setsockopt (%1!d!).\n\0"
|
||||
IDS_COULD_NOT_CREATE_SOCKET "Błąd podczas tworzenia gniazda (#%1!d!).\n\0"
|
||||
IDS_COULD_NOT_INIT_WINSOCK "Błąd podczas inicjalizacji winsock dll.\n\0"
|
||||
IDS_DEST_MUST_BE_SPECIFIED "Brak nazwy hosta bądź adresu IP.\n\0"
|
||||
IDS_BAD_PARAMETER "Nieprawidłowy parametr %1.\n\0"
|
||||
IDS_BAD_OPTION_FORMAT "Nieprawidłowy format opcji %1.\n\0"
|
||||
IDS_BAD_OPTION "Nieprawidłowa opcja %1.\n\0"
|
||||
IDS_BAD_VALUE_OPTION_L "Nieprawidłowa wartość dla opcji -l, wymagana liczba naturalna od 0 do %1!d!.\n\0"
|
||||
IDS_REPLY_FROM "Odpowiedź z %1: bajtów=%2!d! czas%3%4 TTL=%5!d!\n\0"
|
||||
IDS_DEST_UNREACHABLE "Host docelowy nieosiągalny.\n\0"
|
||||
IDS_COULD_NOT_TRANSMIT "Błąd podczas transmisji danych (%1!d!).\n\0"
|
||||
IDS_COULD_NOT_RECV "Błąd podczas odbioru danych (%1!d!).\n\0"
|
||||
IDS_REQUEST_TIMEOUT "Brak odpowiedzi.\n\0"
|
||||
IDS_MS "ms\0"
|
||||
IDS_1MS "1ms\0"
|
||||
END
|
|
@ -12,6 +12,7 @@
|
|||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "resource.h"
|
||||
|
||||
#define NDEBUG
|
||||
|
||||
|
@ -67,10 +68,10 @@ BOOL DontFragment;
|
|||
ULONG TTLValue;
|
||||
ULONG TOSValue;
|
||||
ULONG Timeout;
|
||||
CHAR TargetName[256];
|
||||
WCHAR TargetName[256];
|
||||
SOCKET IcmpSock;
|
||||
SOCKADDR_IN Target;
|
||||
LPSTR TargetIP;
|
||||
WCHAR TargetIP[16];
|
||||
FD_SET Fds;
|
||||
TIMEVAL Timeval;
|
||||
UINT CurrentSeqNum;
|
||||
|
@ -85,6 +86,7 @@ LARGE_INTEGER TicksPerMs; /* Ticks per millisecond */
|
|||
LARGE_INTEGER TicksPerUs; /* Ticks per microsecond */
|
||||
LARGE_INTEGER SentTime;
|
||||
BOOL UsePerformanceCounter;
|
||||
HANDLE hStdOutput;
|
||||
|
||||
#ifndef NDEBUG
|
||||
/* Display the contents of a buffer */
|
||||
|
@ -107,16 +109,71 @@ static VOID DisplayBuffer(
|
|||
}
|
||||
#endif /* !NDEBUG */
|
||||
|
||||
LPWSTR
|
||||
MyLoadString(UINT uID)
|
||||
{
|
||||
HRSRC hres;
|
||||
HGLOBAL hResData;
|
||||
WCHAR *pwsz;
|
||||
UINT string_num, i;
|
||||
|
||||
hres = FindResourceW(NULL, MAKEINTRESOURCEW((LOWORD(uID) >> 4) + 1), RT_STRING);
|
||||
if (!hres) return NULL;
|
||||
|
||||
hResData = LoadResource(NULL, hres);
|
||||
if (!hResData) return NULL;
|
||||
|
||||
pwsz = LockResource(hResData);
|
||||
if (!pwsz) return NULL;
|
||||
|
||||
string_num = uID & 15;
|
||||
for (i = 0; i < string_num; i++)
|
||||
pwsz += *pwsz + 1;
|
||||
|
||||
return pwsz + 1;
|
||||
}
|
||||
|
||||
void FormatOutput(UINT uID, ...)
|
||||
{
|
||||
va_list valist;
|
||||
|
||||
WCHAR Buf[1024];
|
||||
LPWSTR pBuf = Buf;
|
||||
LPWSTR Format;
|
||||
DWORD written;
|
||||
UINT DataLength;
|
||||
|
||||
va_start(valist, uID);
|
||||
|
||||
Format = MyLoadString(uID);
|
||||
if (!Format) return;
|
||||
|
||||
DataLength = FormatMessage(FORMAT_MESSAGE_FROM_STRING, Format, 0, 0, Buf,\
|
||||
sizeof(Buf) / sizeof(WCHAR), &valist);
|
||||
|
||||
if(!DataLength)
|
||||
{
|
||||
if(GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
||||
return;
|
||||
|
||||
DataLength = FormatMessage(FORMAT_MESSAGE_FROM_STRING |\
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER,\
|
||||
Format, 0, 0, (LPWSTR)&pBuf, 0, &valist);
|
||||
|
||||
if(!DataLength)
|
||||
return;
|
||||
}
|
||||
|
||||
WriteConsole(hStdOutput, pBuf, DataLength, &written, NULL);
|
||||
|
||||
if(pBuf != Buf)
|
||||
LocalFree(pBuf);
|
||||
}
|
||||
|
||||
/* Display usage information on screen */
|
||||
static VOID Usage(VOID)
|
||||
{
|
||||
printf("\nUsage: ping [-t] [-n count] [-l size] [-w timeout] destination-host\n\n");
|
||||
printf("Options:\n");
|
||||
printf(" -t Ping the specified host until stopped.\n");
|
||||
printf(" To stop - type Control-C.\n");
|
||||
printf(" -n count Number of echo requests to send.\n");
|
||||
printf(" -l size Send buffer size.\n");
|
||||
printf(" -w timeout Timeout in milliseconds to wait for each reply.\n\n");
|
||||
FormatOutput(IDS_USAGE);
|
||||
}
|
||||
|
||||
/* Reset configuration to default values */
|
||||
|
@ -157,26 +214,26 @@ static VOID Reset(VOID)
|
|||
}
|
||||
|
||||
/* Return ULONG in a string */
|
||||
static ULONG GetULONG(LPSTR String)
|
||||
static ULONG GetULONG(LPWSTR String)
|
||||
{
|
||||
UINT i, Length;
|
||||
ULONG Value;
|
||||
LPSTR StopString;
|
||||
LPWSTR StopString;
|
||||
i = 0;
|
||||
Length = (UINT)_tcslen(String);
|
||||
while ((i < Length) && ((String[i] < '0') || (String[i] > '9'))) i++;
|
||||
if ((i >= Length) || ((String[i] < '0') || (String[i] > '9')))
|
||||
Length = (UINT)wcslen(String);
|
||||
while ((i < Length) && ((String[i] < L'0') || (String[i] > L'9'))) i++;
|
||||
if ((i >= Length) || ((String[i] < L'0') || (String[i] > L'9')))
|
||||
{
|
||||
InvalidOption = TRUE;
|
||||
return 0;
|
||||
}
|
||||
Value = strtoul(&String[i], &StopString, 10);
|
||||
Value = wcstoul(&String[i], &StopString, 10);
|
||||
|
||||
return Value;
|
||||
}
|
||||
|
||||
/* Return ULONG in a string. Try next paramter if not successful */
|
||||
static ULONG GetULONG2(LPSTR String1, LPSTR String2, PINT i)
|
||||
static ULONG GetULONG2(LPWSTR String1, LPWSTR String2, PINT i)
|
||||
{
|
||||
ULONG Value;
|
||||
|
||||
|
@ -184,7 +241,7 @@ static ULONG GetULONG2(LPSTR String1, LPSTR String2, PINT i)
|
|||
if (InvalidOption)
|
||||
{
|
||||
InvalidOption = FALSE;
|
||||
if (String2[0] != '-')
|
||||
if (String2[0] != L'-')
|
||||
{
|
||||
Value = GetULONG(String2);
|
||||
if (!InvalidOption)
|
||||
|
@ -196,7 +253,7 @@ static ULONG GetULONG2(LPSTR String1, LPSTR String2, PINT i)
|
|||
}
|
||||
|
||||
/* Parse command line parameters */
|
||||
static BOOL ParseCmdline(int argc, char* argv[])
|
||||
static BOOL ParseCmdline(int argc, LPWSTR argv[])
|
||||
{
|
||||
INT i;
|
||||
BOOL ShowUsage;
|
||||
|
@ -210,34 +267,35 @@ static BOOL ParseCmdline(int argc, char* argv[])
|
|||
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if (argv[i][0] == '-')
|
||||
if (argv[i][0] == L'-')
|
||||
{
|
||||
switch (argv[i][1])
|
||||
{
|
||||
case 't': NeverStop = TRUE; break;
|
||||
case 'a': ResolveAddresses = TRUE; break;
|
||||
case 'n': PingCount = GetULONG2(&argv[i][2], argv[i + 1], &i); break;
|
||||
case 'l':
|
||||
case L't': NeverStop = TRUE; break;
|
||||
case L'a': ResolveAddresses = TRUE; break;
|
||||
case L'n': PingCount = GetULONG2(&argv[i][2], argv[i + 1], &i); break;
|
||||
case L'l':
|
||||
DataSize = GetULONG2(&argv[i][2], argv[i + 1], &i);
|
||||
if (DataSize > ICMP_MAXSIZE - sizeof(ICMP_ECHO_PACKET) - sizeof(IPv4_HEADER))
|
||||
{
|
||||
printf("Bad value for option -l, valid range is from 0 to %d.\n",
|
||||
ICMP_MAXSIZE - (int)sizeof(ICMP_ECHO_PACKET) - (int)sizeof(IPv4_HEADER));
|
||||
FormatOutput(IDS_BAD_VALUE_OPTION_L, ICMP_MAXSIZE - \
|
||||
(int)sizeof(ICMP_ECHO_PACKET) - \
|
||||
(int)sizeof(IPv4_HEADER));
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case 'f': DontFragment = TRUE; break;
|
||||
case 'i': TTLValue = GetULONG2(&argv[i][2], argv[i + 1], &i); break;
|
||||
case 'v': TOSValue = GetULONG2(&argv[i][2], argv[i + 1], &i); break;
|
||||
case 'w': Timeout = GetULONG2(&argv[i][2], argv[i + 1], &i); break;
|
||||
case L'f': DontFragment = TRUE; break;
|
||||
case L'i': TTLValue = GetULONG2(&argv[i][2], argv[i + 1], &i); break;
|
||||
case L'v': TOSValue = GetULONG2(&argv[i][2], argv[i + 1], &i); break;
|
||||
case L'w': Timeout = GetULONG2(&argv[i][2], argv[i + 1], &i); break;
|
||||
default:
|
||||
printf("Bad option %s.\n", argv[i]);
|
||||
FormatOutput(IDS_BAD_OPTION, argv[i]);
|
||||
Usage();
|
||||
return FALSE;
|
||||
}
|
||||
if (InvalidOption)
|
||||
{
|
||||
printf("Bad option format %s.\n", argv[i]);
|
||||
FormatOutput(IDS_BAD_OPTION_FORMAT, argv[i]);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -245,12 +303,12 @@ static BOOL ParseCmdline(int argc, char* argv[])
|
|||
{
|
||||
if (FoundTarget)
|
||||
{
|
||||
printf("Bad parameter %s.\n", argv[i]);
|
||||
FormatOutput(IDS_BAD_PARAMETER, argv[i]);
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
lstrcpy(TargetName, argv[i]);
|
||||
wcscpy(TargetName, argv[i]);
|
||||
FoundTarget = TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +316,7 @@ static BOOL ParseCmdline(int argc, char* argv[])
|
|||
|
||||
if ((!ShowUsage) && (!FoundTarget))
|
||||
{
|
||||
printf("Name or IP address of destination host must be specified.\n");
|
||||
FormatOutput(IDS_DEST_MUST_BE_SPECIFIED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -298,20 +356,21 @@ static BOOL Setup(VOID)
|
|||
INT Status;
|
||||
ULONG Addr;
|
||||
PHOSTENT phe;
|
||||
CHAR aTargetName[256];
|
||||
|
||||
wVersionRequested = MAKEWORD(2, 2);
|
||||
|
||||
Status = WSAStartup(wVersionRequested, &WsaData);
|
||||
if (Status != 0)
|
||||
{
|
||||
printf("Could not initialize winsock dll.\n");
|
||||
FormatOutput(IDS_COULD_NOT_INIT_WINSOCK);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
IcmpSock = WSASocket(AF_INET, SOCK_RAW, IPPROTO_ICMP, NULL, 0, 0);
|
||||
if (IcmpSock == INVALID_SOCKET)
|
||||
{
|
||||
printf("Could not create socket (#%d).\n", WSAGetLastError());
|
||||
FormatOutput(IDS_COULD_NOT_CREATE_SOCKET, WSAGetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -321,7 +380,7 @@ static BOOL Setup(VOID)
|
|||
(const char *)&DontFragment,
|
||||
sizeof(DontFragment)) == SOCKET_ERROR)
|
||||
{
|
||||
printf("setsockopt failed (%d).\n", WSAGetLastError());
|
||||
FormatOutput(IDS_SETSOCKOPT_FAILED, WSAGetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -331,35 +390,44 @@ static BOOL Setup(VOID)
|
|||
(const char *)&TTLValue,
|
||||
sizeof(TTLValue)) == SOCKET_ERROR)
|
||||
{
|
||||
printf("setsockopt failed (%d).\n", WSAGetLastError());
|
||||
FormatOutput(IDS_SETSOCKOPT_FAILED, WSAGetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
if(!WideCharToMultiByte(CP_ACP, 0, TargetName, -1, aTargetName,\
|
||||
sizeof(aTargetName), NULL, NULL))
|
||||
{
|
||||
FormatOutput(IDS_UNKNOWN_HOST, TargetName);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ZeroMemory(&Target, sizeof(Target));
|
||||
phe = NULL;
|
||||
Addr = inet_addr(TargetName);
|
||||
Addr = inet_addr(aTargetName);
|
||||
if (Addr == INADDR_NONE)
|
||||
{
|
||||
phe = gethostbyname(TargetName);
|
||||
phe = gethostbyname(aTargetName);
|
||||
if (phe == NULL)
|
||||
{
|
||||
printf("Unknown host %s.\n", TargetName);
|
||||
FormatOutput(IDS_UNKNOWN_HOST, TargetName);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
CopyMemory(&Target.sin_addr, phe->h_addr, phe->h_length);
|
||||
Target.sin_family = phe->h_addrtype;
|
||||
}
|
||||
else
|
||||
{
|
||||
Target.sin_addr.s_addr = Addr;
|
||||
Target.sin_family = AF_INET;
|
||||
}
|
||||
|
||||
if (phe != NULL)
|
||||
CopyMemory(&Target.sin_addr, phe->h_addr, phe->h_length);
|
||||
else
|
||||
Target.sin_addr.s_addr = Addr;
|
||||
|
||||
if (phe != NULL)
|
||||
Target.sin_family = phe->h_addrtype;
|
||||
else
|
||||
Target.sin_family = AF_INET;
|
||||
|
||||
TargetIP = inet_ntoa(Target.sin_addr);
|
||||
swprintf(TargetIP, L"%d.%d.%d.%d", Target.sin_addr.S_un.S_un_b.s_b1,\
|
||||
Target.sin_addr.S_un.S_un_b.s_b2,\
|
||||
Target.sin_addr.S_un.S_un_b.s_b3,\
|
||||
Target.sin_addr.S_un.S_un_b.s_b4);
|
||||
CurrentSeqNum = 1;
|
||||
SentCount = 0;
|
||||
LostCount = 0;
|
||||
|
@ -405,16 +473,18 @@ static VOID QueryTime(PLARGE_INTEGER Time)
|
|||
}
|
||||
}
|
||||
|
||||
static VOID TimeToMsString(LPSTR String, LARGE_INTEGER Time)
|
||||
static VOID TimeToMsString(LPWSTR String, LARGE_INTEGER Time)
|
||||
{
|
||||
CHAR Convstr[40];
|
||||
WCHAR Convstr[40];
|
||||
LARGE_INTEGER LargeTime;
|
||||
LPWSTR ms;
|
||||
|
||||
LargeTime.QuadPart = Time.QuadPart / TicksPerMs.QuadPart;
|
||||
|
||||
_i64toa(LargeTime.QuadPart, Convstr, 10);
|
||||
strcpy(String, Convstr);
|
||||
strcat(String, "ms");
|
||||
_i64tow(LargeTime.QuadPart, Convstr, 10);
|
||||
wcscpy(String, Convstr);
|
||||
ms = MyLoadString(IDS_MS);
|
||||
wcscat(String, ms);
|
||||
}
|
||||
|
||||
/* Locate the ICMP data and print it. Returns TRUE if the packet was good,
|
||||
|
@ -424,10 +494,11 @@ static BOOL DecodeResponse(PCHAR buffer, UINT size, PSOCKADDR_IN from)
|
|||
PIPv4_HEADER IpHeader;
|
||||
PICMP_ECHO_PACKET Icmp;
|
||||
UINT IphLength;
|
||||
CHAR Time[100];
|
||||
WCHAR Time[100];
|
||||
LARGE_INTEGER RelativeTime;
|
||||
LARGE_INTEGER LargeTime;
|
||||
CHAR Sign[2];
|
||||
WCHAR Sign[2];
|
||||
WCHAR wfromIP[16];
|
||||
|
||||
IpHeader = (PIPv4_HEADER)buffer;
|
||||
|
||||
|
@ -473,18 +544,27 @@ static BOOL DecodeResponse(PCHAR buffer, UINT size, PSOCKADDR_IN from)
|
|||
|
||||
if ((RelativeTime.QuadPart / TicksPerMs.QuadPart) < 1)
|
||||
{
|
||||
strcpy(Sign, "<");
|
||||
strcpy(Time, "1ms");
|
||||
LPWSTR ms1;
|
||||
|
||||
wcscpy(Sign, L"<");
|
||||
ms1 = MyLoadString(IDS_1MS);
|
||||
wcscpy(Time, ms1);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(Sign, "=");
|
||||
wcscpy(Sign, L"=");
|
||||
TimeToMsString(Time, RelativeTime);
|
||||
}
|
||||
|
||||
|
||||
printf("Reply from %s: bytes=%d time%s%s TTL=%d\n", inet_ntoa(from->sin_addr),
|
||||
size - IphLength - (int)sizeof(ICMP_ECHO_PACKET), Sign, Time, IpHeader->TTL);
|
||||
swprintf(wfromIP, L"%d.%d.%d.%d", from->sin_addr.S_un.S_un_b.s_b1,\
|
||||
from->sin_addr.S_un.S_un_b.s_b2,\
|
||||
from->sin_addr.S_un.S_un_b.s_b3,\
|
||||
from->sin_addr.S_un.S_un_b.s_b4);
|
||||
FormatOutput(IDS_REPLY_FROM, wfromIP,\
|
||||
size - IphLength - (int)sizeof(ICMP_ECHO_PACKET),\
|
||||
Sign, Time, IpHeader->TTL);
|
||||
|
||||
if (RelativeTime.QuadPart < MinRTT.QuadPart || !MinRTTSet)
|
||||
{
|
||||
MinRTT.QuadPart = RelativeTime.QuadPart;
|
||||
|
@ -513,7 +593,7 @@ static BOOL Ping(VOID)
|
|||
Buffer = GlobalAlloc(0, Size);
|
||||
if (!Buffer)
|
||||
{
|
||||
printf("Not enough free resources available.\n");
|
||||
FormatOutput(IDS_NOT_ENOUGH_RESOURCES);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -556,9 +636,9 @@ static BOOL Ping(VOID)
|
|||
if (Status == SOCKET_ERROR)
|
||||
{
|
||||
if (WSAGetLastError() == WSAEHOSTUNREACH)
|
||||
printf("Destination host unreachable.\n");
|
||||
FormatOutput(IDS_DEST_UNREACHABLE);
|
||||
else
|
||||
printf("Could not transmit data (%d).\n", WSAGetLastError());
|
||||
FormatOutput(IDS_COULD_NOT_TRANSMIT, WSAGetLastError());
|
||||
GlobalFree(Buffer);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -588,7 +668,7 @@ static BOOL Ping(VOID)
|
|||
{
|
||||
if (WSAGetLastError() != WSAETIMEDOUT)
|
||||
{
|
||||
printf("Could not receive data (%d).\n", WSAGetLastError());
|
||||
FormatOutput(IDS_COULD_NOT_RECV, WSAGetLastError());
|
||||
GlobalFree(Buffer);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -597,7 +677,7 @@ static BOOL Ping(VOID)
|
|||
|
||||
if (Status == 0)
|
||||
{
|
||||
printf("Request timed out.\n");
|
||||
FormatOutput(IDS_REQUEST_TIMEOUT);
|
||||
GlobalFree(Buffer);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -610,20 +690,21 @@ static BOOL Ping(VOID)
|
|||
|
||||
|
||||
/* Program entry point */
|
||||
int main(int argc, char* argv[])
|
||||
int wmain(int argc, LPWSTR argv[])
|
||||
{
|
||||
UINT Count;
|
||||
CHAR MinTime[20];
|
||||
CHAR MaxTime[20];
|
||||
CHAR AvgTime[20];
|
||||
WCHAR MinTime[20];
|
||||
WCHAR MaxTime[20];
|
||||
WCHAR AvgTime[20];
|
||||
|
||||
hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
Reset();
|
||||
|
||||
if ((ParseCmdline(argc, argv)) && (Setup()))
|
||||
{
|
||||
|
||||
printf("\nPinging %s [%s] with %d bytes of data:\n\n",
|
||||
TargetName, TargetIP, DataSize);
|
||||
FormatOutput(IDS_PING_WITH_BYTES, TargetName, TargetIP, DataSize);
|
||||
|
||||
Count = 0;
|
||||
while ((NeverStop) || (Count < PingCount))
|
||||
|
@ -653,15 +734,15 @@ int main(int argc, char* argv[])
|
|||
TimeToMsString(AvgTime, AvgRTT);
|
||||
|
||||
/* Print statistics */
|
||||
printf("\nPing statistics for %s:\n", TargetIP);
|
||||
printf(" Packets: Sent = %d, Received = %d, Lost = %d (%d%% loss),\n",
|
||||
FormatOutput(IDS_PING_STATISTICS, TargetIP);
|
||||
FormatOutput(IDS_PACKETS_SENT_RECEIVED_LOST,\
|
||||
SentCount, SentCount - LostCount, LostCount, Count);
|
||||
|
||||
/* Print approximate times or NO approximate times if 100% loss */
|
||||
if ((SentCount - LostCount) > 0)
|
||||
{
|
||||
printf("Approximate round trip times in milli-seconds:\n");
|
||||
printf(" Minimum = %s, Maximum = %s, Average = %s\n",
|
||||
MinTime, MaxTime, AvgTime);
|
||||
FormatOutput(IDS_APPROXIMATE_ROUND_TRIP);
|
||||
FormatOutput(IDS_MIN_MAX_AVERAGE, MinTime, MaxTime, AvgTime);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -1,7 +1,15 @@
|
|||
/* $Id$ */
|
||||
#include <windows.h>
|
||||
#include "resource.h"
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS TCP/IPv4 Win32 Ping\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "ping\0"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "ping.exe\0"
|
||||
#define REACTOS_STR_ORIGINAL_COPYRIGHT "Casper S. Hornstrup (chorns@users.sourceforge.net)\0"
|
||||
#include <reactos/version.rc>
|
||||
|
||||
#include "lang/de-DE.rc"
|
||||
#include "lang/en-US.rc"
|
||||
#include "lang/fr-FR.rc"
|
||||
#include "lang/pl-PL.rc"
|
||||
#include "lang/it-IT.rc"
|
||||
|
|
24
base/applications/network/ping/resource.h
Normal file
24
base/applications/network/ping/resource.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#define IDS_USAGE 0
|
||||
#define IDS_PING_WITH_BYTES 1
|
||||
#define IDS_PING_STATISTICS 2
|
||||
#define IDS_PACKETS_SENT_RECEIVED_LOST 3
|
||||
#define IDS_APPROXIMATE_ROUND_TRIP 4
|
||||
#define IDS_MIN_MAX_AVERAGE 5
|
||||
#define IDS_NOT_ENOUGH_RESOURCES 6
|
||||
#define IDS_UNKNOWN_HOST 7
|
||||
#define IDS_SETSOCKOPT_FAILED 8
|
||||
#define IDS_COULD_NOT_CREATE_SOCKET 9
|
||||
#define IDS_COULD_NOT_INIT_WINSOCK 10
|
||||
#define IDS_DEST_MUST_BE_SPECIFIED 11
|
||||
#define IDS_BAD_PARAMETER 12
|
||||
#define IDS_BAD_OPTION_FORMAT 13
|
||||
#define IDS_BAD_OPTION 14
|
||||
#define IDS_BAD_VALUE_OPTION_L 15
|
||||
#define IDS_REPLY_FROM 16
|
||||
#define IDS_DEST_UNREACHABLE 17
|
||||
#define IDS_COULD_NOT_TRANSMIT 18
|
||||
#define IDS_COULD_NOT_RECV 19
|
||||
#define IDS_REQUEST_TIMEOUT 20
|
||||
#define IDS_MS 21
|
||||
#define IDS_1MS 22
|
||||
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
[Section]
|
||||
Name = K Desktop Environment
|
||||
Version = 0.9.7-0
|
||||
Version = 0.9.8-1
|
||||
Licence = GPL
|
||||
Description = KDE for Windows.
|
||||
Size = 2.0MB
|
||||
Category = 15
|
||||
URLSite = http://www.winkde.org/
|
||||
URLDownload = http://www.winkde.org/pub/kde/ports/win32/installer/kdewin-installer-gui-0.9.7-0.exe
|
||||
URLDownload = http://www.winkde.org/pub/kde/ports/win32/installer/kdewin-installer-gui-0.9.8-1.exe
|
||||
CDPath = none
|
||||
|
||||
[Section.0407]
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
[Section]
|
||||
Name = LibreOffice
|
||||
Version = 3.3.0 RC2
|
||||
Version = 3.3.0 RC3
|
||||
Licence = LGPL
|
||||
Description = Former called OpenOffice. Open Source Office Suite.
|
||||
Size = 206.0MB
|
||||
Size = 209.0MB
|
||||
Category = 6
|
||||
URLSite = http://www.documentfoundation.org/
|
||||
URLDownload = http://download.documentfoundation.org/libreoffice/testing/3.3.0-rc2/win/x86/LibO_3.3.0rc2_Win_x86_install_multi.exe
|
||||
URLDownload = http://download.documentfoundation.org/libreoffice/testing/3.3.0-rc3/win/x86/LibO_3.3.0rc3_Win_x86_install_multi.exe
|
||||
CDPath = none
|
||||
|
||||
[Section.0407]
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
[Section]
|
||||
Name = Mono .net Development Framework
|
||||
Version = 2.8.1
|
||||
Version = 2.8.2
|
||||
Licence = Unknown
|
||||
Description = Open Source .net Framework.
|
||||
Size = 77MB
|
||||
Category = 14
|
||||
URLSite = http://www.mono-project.com/Main_Page
|
||||
URLDownload = http://ftp.novell.com/pub/mono/archive/2.8.1/windows-installer/3/mono-2.8.1-gtksharp-2.12.10-win32-3.exe
|
||||
URLDownload = http://ftp.novell.com/pub/mono/archive/2.8.2/windows-installer/1/mono-2.8.2-gtksharp-2.12.10-win32-1.exe
|
||||
CDPath = none
|
||||
|
||||
[Section.0415]
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
[Section]
|
||||
Name = Python
|
||||
Version = 2.6.6
|
||||
Version = 2.7.1
|
||||
Licence = GPL/LGPL
|
||||
Description = A remarkably powerful dynamic programming language.
|
||||
Size = 14.5MB
|
||||
Size = 15.0MB
|
||||
Category = 7
|
||||
URLSite = http://www.python.org/
|
||||
URLDownload = http://www.python.org/ftp/python/2.6.6/python-2.6.6.msi
|
||||
URLDownload = http://www.python.org/ftp/python/2.7.1/python-2.7.1.msi
|
||||
CDPath = none
|
||||
|
||||
[Section.0407]
|
||||
|
|
48
base/applications/rapps/rapps/sbforvmware.txt
Normal file
48
base/applications/rapps/rapps/sbforvmware.txt
Normal file
|
@ -0,0 +1,48 @@
|
|||
; UTF-8
|
||||
|
||||
[Section]
|
||||
Name = SoundBlaster Driver for VMWare
|
||||
Version = 5.12.1.5017
|
||||
Licence = Unknown
|
||||
Description = Unzip in the "ReactOS" folder then restart ReactOS twice.
|
||||
Size = 2.2MB
|
||||
Category = 13
|
||||
URLSite = Unknown
|
||||
URLDownload = http://svn.reactos.org/packages/sb_vmware.exe
|
||||
CDPath = none
|
||||
|
||||
[Section.0405]
|
||||
Name = Ovladač SoundBlaster pro VMWare
|
||||
Licence = Neznámá
|
||||
Description = Rozbalte do složky "ReactOS" a pak ReactOS dvakrát restartujte.
|
||||
URLSite = Neznámá
|
||||
|
||||
[Section.0407]
|
||||
Name = SoundBlaster Treiber für VMWare
|
||||
Licence = Unbekannt
|
||||
Description = Entpacken in das "ReactOS"-Verzeichnis und ReactOS zweimal neustarten.
|
||||
URLSite = Unbekannt
|
||||
|
||||
[Section.040a]
|
||||
Name = Driver SoundBlaster para VMWare
|
||||
Licence = Desconocida
|
||||
Description = Descomprimir en la carpeta "Reactos" y reiniciar Reactos dos veces.
|
||||
URLSite = Desconocida
|
||||
|
||||
[Section.0415]
|
||||
Name = Sterownik SoundBlaster dla VMWare
|
||||
Licence = Nieznana
|
||||
Description = Rozpakuj zawartość w folderze "ReactOS" i dwukrotnie zrestartuj system.
|
||||
URLSite = Nieznana
|
||||
|
||||
[Section.0419]
|
||||
Name = Драйвер SoundBlaster для VMWare
|
||||
Licence = Не указано
|
||||
Description = Pазархивируйте содержимое в папку "ReactOS", затем дважды перезагрузите систему.
|
||||
URLSite = Не указано
|
||||
|
||||
[Section.0422]
|
||||
Name = Драйвер SoundBlaster для VMWare
|
||||
Licence = Невідома
|
||||
Description = Pозархівуйте вміст в теку "ReactOS" після чого двічі перезавантажте систему.
|
||||
URLSite = Не вказано
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
[Section]
|
||||
Name = TuxPaint
|
||||
Version = 0.9.21b
|
||||
Version = 0.9.21c
|
||||
Licence = GPL
|
||||
Description = An Open Source bitmap graphics editor geared towards young children.
|
||||
Size = 11MB
|
||||
Category = 3
|
||||
URLSite = http://tuxpaint.org/
|
||||
URLDownload = http://ovh.dl.sourceforge.net/project/tuxpaint/tuxpaint/0.9.21b/tuxpaint-0.9.21b-win32-installer.exe
|
||||
URLDownload = http://ovh.dl.sourceforge.net/project/tuxpaint/tuxpaint/0.9.21c/tuxpaint-0.9.21c-win32-installer.exe
|
||||
CDPath = none
|
||||
|
||||
[Section.0405]
|
||||
|
|
|
@ -4,7 +4,7 @@ STRINGTABLE DISCARDABLE
|
|||
BEGIN
|
||||
|
||||
IDS_USAGE, "Utilisation: shutdown [-?] [-l | -s | -r] [-f]\n\n\
|
||||
Aucun argument ou -?\tAffichent ce message\n\
|
||||
Aucun argument ou -?\tAffiche ce message\n\
|
||||
-l\t\t\tSe déconnecter\n\
|
||||
-s\t\t\tÉteindre l'ordinateur\n\
|
||||
-r\t\t\tÉteindre et redémarrer l'ordinateur\n\
|
||||
|
|
|
@ -31,6 +31,7 @@ add_importlibs(explorer_new
|
|||
oleaut32
|
||||
shell32
|
||||
shlwapi
|
||||
version
|
||||
msvcrt
|
||||
kernel32
|
||||
ntdll)
|
||||
|
|
|
@ -26,6 +26,12 @@ HANDLE hProcessHeap;
|
|||
HKEY hkExplorer = NULL;
|
||||
DRAWCAPTEMP DrawCapTemp = NULL;
|
||||
|
||||
typedef struct _LANGCODEPAGE
|
||||
{
|
||||
WORD wLanguage;
|
||||
WORD wCodePage;
|
||||
} LANGCODEPAGE, *PLANGCODEPAGE;
|
||||
|
||||
/* undoc GUID */
|
||||
DEFINE_GUID(CLSID_RebarBandSite, 0xECD4FC4D, 0x521C, 0x11D0, 0xB7, 0x92, 0x00, 0xA0, 0xC9, 0x03, 0x12, 0xE1);
|
||||
|
||||
|
@ -270,6 +276,80 @@ SetShellReadyEvent(IN LPCTSTR lpEventName)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
GetVersionInfoString(IN TCHAR *szFileName,
|
||||
IN TCHAR *szVersionInfo,
|
||||
OUT TCHAR *szBuffer,
|
||||
IN UINT cbBufLen)
|
||||
{
|
||||
LPVOID lpData = NULL;
|
||||
TCHAR szSubBlock[128];
|
||||
TCHAR *lpszLocalBuf = NULL;
|
||||
LANGID UserLangId;
|
||||
PLANGCODEPAGE lpTranslate = NULL;
|
||||
DWORD dwLen;
|
||||
DWORD dwHandle;
|
||||
UINT cbTranslate;
|
||||
UINT cbLen;
|
||||
BOOL bRet = FALSE;
|
||||
unsigned int i;
|
||||
|
||||
dwLen = GetFileVersionInfoSize(szFileName,&dwHandle);
|
||||
|
||||
if (dwLen > 0)
|
||||
{
|
||||
lpData = HeapAlloc(hProcessHeap,0,dwLen);
|
||||
|
||||
if (lpData != NULL)
|
||||
{
|
||||
if (GetFileVersionInfo(szFileName,
|
||||
0,
|
||||
dwLen,
|
||||
lpData) != 0)
|
||||
{
|
||||
UserLangId = GetUserDefaultLangID();
|
||||
|
||||
VerQueryValue(lpData,
|
||||
TEXT("\\VarFileInfo\\Translation"),
|
||||
(LPVOID *)&lpTranslate,
|
||||
&cbTranslate);
|
||||
|
||||
for (i = 0;i < (cbTranslate / sizeof(LANGCODEPAGE));i++)
|
||||
{
|
||||
/* If the bottom eight bits of the language id's
|
||||
match, use this version information (since this
|
||||
means that the version information and the users
|
||||
default language are the same). */
|
||||
if ((lpTranslate[i].wLanguage & 0xFF) ==
|
||||
(UserLangId & 0xFF))
|
||||
{
|
||||
wnsprintf(szSubBlock,
|
||||
sizeof(szSubBlock) / sizeof(szSubBlock[0]),
|
||||
TEXT("\\StringFileInfo\\%04X%04X\\%s"),
|
||||
lpTranslate[i].wLanguage,
|
||||
lpTranslate[i].wCodePage,szVersionInfo);
|
||||
|
||||
if (VerQueryValue(lpData,
|
||||
szSubBlock,
|
||||
(LPVOID *)&lpszLocalBuf,
|
||||
&cbLen) != 0)
|
||||
{
|
||||
wcsncpy(szBuffer,lpszLocalBuf,cbBufLen);
|
||||
|
||||
bRet = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
HeapFree(hProcessHeap,0,lpData);
|
||||
lpData = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
INT WINAPI
|
||||
_tWinMain(IN HINSTANCE hInstance,
|
||||
IN HINSTANCE hPrevInstance,
|
||||
|
|
|
@ -1715,6 +1715,64 @@ TaskSwitchWnd_HandleButtonClick(IN OUT PTASK_SWITCH_WND This,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static VOID
|
||||
TaskSwitchWnd_HandleTaskItemRightClick(IN OUT PTASK_SWITCH_WND This,
|
||||
IN OUT PTASK_ITEM TaskItem)
|
||||
{
|
||||
|
||||
HMENU hmenu = GetSystemMenu(TaskItem->hWnd, FALSE);
|
||||
|
||||
if (hmenu) {
|
||||
POINT pt;
|
||||
GetCursorPos(&pt);
|
||||
int cmd = TrackPopupMenu(hmenu, TPM_LEFTBUTTON|TPM_RIGHTBUTTON|TPM_RETURNCMD, pt.x, pt.y, 0, This->hWndToolbar, NULL);
|
||||
if (cmd) {
|
||||
SetForegroundWindow(TaskItem->hWnd); // reactivate window after the context menu has closed
|
||||
PostMessage(TaskItem->hWnd, WM_SYSCOMMAND, cmd, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static VOID
|
||||
TaskSwitchWnd_HandleTaskGroupRightClick(IN OUT PTASK_SWITCH_WND This,
|
||||
IN OUT PTASK_GROUP TaskGroup)
|
||||
{
|
||||
/* TODO: Show task group right click menu */
|
||||
}
|
||||
|
||||
static BOOL
|
||||
TaskSwitchWnd_HandleButtonRightClick(IN OUT PTASK_SWITCH_WND This,
|
||||
IN WORD wIndex)
|
||||
{
|
||||
PTASK_ITEM TaskItem;
|
||||
PTASK_GROUP TaskGroup;
|
||||
if (This->IsGroupingEnabled)
|
||||
{
|
||||
TaskGroup = FindTaskGroupByIndex(This,
|
||||
(INT)wIndex);
|
||||
if (TaskGroup != NULL && TaskGroup->IsCollapsed)
|
||||
{
|
||||
TaskSwitchWnd_HandleTaskGroupRightClick(This,
|
||||
TaskGroup);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
TaskItem = FindTaskItemByIndex(This,
|
||||
(INT)wIndex);
|
||||
|
||||
if (TaskItem != NULL)
|
||||
{
|
||||
TaskSwitchWnd_HandleTaskItemRightClick(This,
|
||||
TaskItem);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static LRESULT
|
||||
TaskSwichWnd_HandleItemPaint(IN OUT PTASK_SWITCH_WND This,
|
||||
IN OUT NMTBCUSTOMDRAW *nmtbcd)
|
||||
|
@ -2001,7 +2059,8 @@ TaskSwitchWndProc(IN HWND hwnd,
|
|||
(LPARAM)&pt);
|
||||
if (iBtn >= 0)
|
||||
{
|
||||
/* FIXME: Display the system menu of the window */
|
||||
TaskSwitchWnd_HandleButtonRightClick(This,
|
||||
iBtn);
|
||||
}
|
||||
else
|
||||
goto ForwardContextMenuMsg;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_EXTRA_LEAN
|
||||
#include <windows.h>
|
||||
#include <undocuser.h>
|
||||
|
||||
// Unicode support
|
||||
#if defined(UNICODE) && !defined(_UNICODE)
|
||||
|
|
|
@ -961,7 +961,9 @@ CreateWindowStationAndDesktops(
|
|||
DWORD SidSize, AclSize;
|
||||
PACL pDefaultAcl = NULL;
|
||||
PACL pUserDesktopAcl = NULL;
|
||||
SECURITY_DESCRIPTOR DefaultSecurityDescriptor;
|
||||
SECURITY_ATTRIBUTES DefaultSecurity;
|
||||
SECURITY_DESCRIPTOR UserDesktopSecurityDescriptor;
|
||||
SECURITY_ATTRIBUTES UserDesktopSecurity;
|
||||
BOOL ret = FALSE;
|
||||
|
||||
|
@ -1008,8 +1010,24 @@ CreateWindowStationAndDesktops(
|
|||
ERR("WL: AddAccessAllowedAce() failed (error %lu)\n", GetLastError());
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the default security descriptor
|
||||
*/
|
||||
if (!InitializeSecurityDescriptor(&DefaultSecurityDescriptor, SECURITY_DESCRIPTOR_REVISION))
|
||||
{
|
||||
ERR("WL: InitializeSecurityDescriptor() failed (error %lu)\n", GetLastError());
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!SetSecurityDescriptorDacl(&DefaultSecurityDescriptor, TRUE, pDefaultAcl, FALSE))
|
||||
{
|
||||
ERR("WL: SetSecurityDescriptorDacl() failed (error %lu)\n", GetLastError());
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
DefaultSecurity.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
DefaultSecurity.lpSecurityDescriptor = pDefaultAcl;
|
||||
DefaultSecurity.lpSecurityDescriptor = &DefaultSecurityDescriptor;
|
||||
DefaultSecurity.bInheritHandle = TRUE;
|
||||
|
||||
/*
|
||||
|
@ -1021,8 +1039,24 @@ CreateWindowStationAndDesktops(
|
|||
ERR("WL: AddAccessAllowedAce() failed (error %lu)\n", GetLastError());
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the user desktop security descriptor
|
||||
*/
|
||||
if (!InitializeSecurityDescriptor(&UserDesktopSecurityDescriptor, SECURITY_DESCRIPTOR_REVISION))
|
||||
{
|
||||
ERR("WL: InitializeSecurityDescriptor() failed (error %lu)\n", GetLastError());
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!SetSecurityDescriptorDacl(&UserDesktopSecurityDescriptor, TRUE, pUserDesktopAcl, FALSE))
|
||||
{
|
||||
ERR("WL: SetSecurityDescriptorDacl() failed (error %lu)\n", GetLastError());
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
UserDesktopSecurity.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
UserDesktopSecurity.lpSecurityDescriptor = pUserDesktopAcl;
|
||||
UserDesktopSecurity.lpSecurityDescriptor = &UserDesktopSecurityDescriptor;
|
||||
UserDesktopSecurity.bInheritHandle = TRUE;
|
||||
|
||||
/*
|
||||
|
|
|
@ -33,7 +33,6 @@ PcMachInit(const char *CmdLine)
|
|||
MachVtbl.VideoGetDisplaySize = PcVideoGetDisplaySize;
|
||||
MachVtbl.VideoGetBufferSize = PcVideoGetBufferSize;
|
||||
MachVtbl.VideoSetTextCursorPosition = PcVideoSetTextCursorPosition;
|
||||
MachVtbl.VideoSetTextCursorPosition = PcVideoSetTextCursorPosition;
|
||||
MachVtbl.VideoHideShowTextCursor = PcVideoHideShowTextCursor;
|
||||
MachVtbl.VideoPutChar = PcVideoPutChar;
|
||||
MachVtbl.VideoCopyOffScreenBufferToVRAM = PcVideoCopyOffScreenBufferToVRAM;
|
||||
|
|
|
@ -208,7 +208,7 @@ WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
|
|||
Extension->AcpiTable = (PVOID)1;
|
||||
}
|
||||
|
||||
#ifndef _M_ARM
|
||||
#ifdef _M_IX86
|
||||
/* Set headless block pointer */
|
||||
if (WinLdrTerminalConnected)
|
||||
{
|
||||
|
@ -538,7 +538,7 @@ LoadAndBootWindows(PCSTR OperatingSystemName,
|
|||
/* Allocate and minimalistic-initialize LPB */
|
||||
AllocateAndInitLPB(&LoaderBlock);
|
||||
|
||||
#ifndef _M_ARM
|
||||
#ifdef _M_IX86
|
||||
/* Setup redirection support */
|
||||
WinLdrSetupEms(BootOptions);
|
||||
#endif
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "winbase.h"
|
||||
#include "winnls.h"
|
||||
#include "winuser.h"
|
||||
#include "undocuser.h"
|
||||
#include "softpub.h"
|
||||
#include "wingdi.h"
|
||||
#include "richedit.h"
|
||||
|
|
|
@ -9,6 +9,11 @@ include_directories(include)
|
|||
|
||||
spec2def(gdi32.dll gdi32.spec)
|
||||
|
||||
if(ARCH MATCHES i386)
|
||||
list(APPEND SOURCE
|
||||
objects/efloat.c)
|
||||
endif()
|
||||
|
||||
list(APPEND SOURCE
|
||||
main/dllmain.c
|
||||
misc/heap.c
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
@ stdcall ColorCorrectPalette(ptr ptr long long)
|
||||
@ stdcall ColorMatchToTarget(ptr ptr long)
|
||||
@ stdcall CombineRgn(long long long long)
|
||||
@ stdcall CombineTransform(ptr ptr ptr) NtGdiCombineTransform
|
||||
@ stdcall CombineTransform(ptr ptr ptr)
|
||||
@ stdcall CopyEnhMetaFileA(long str)
|
||||
@ stdcall CopyEnhMetaFileW(long wstr)
|
||||
@ stdcall CopyMetaFileA(long str)
|
||||
|
|
|
@ -292,7 +292,6 @@ int FASTCALL DocumentEventEx(PVOID,HANDLE,HDC,int,ULONG,PVOID,ULONG,PVOID);
|
|||
BOOL FASTCALL EndPagePrinterEx(PVOID,HANDLE);
|
||||
BOOL FASTCALL LoadTheSpoolerDrv(VOID);
|
||||
|
||||
|
||||
FORCEINLINE
|
||||
PVOID
|
||||
GdiAllocBatchCommand(
|
||||
|
@ -379,4 +378,43 @@ GdiAllocBatchCommand(
|
|||
return pHdr;
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
PDC_ATTR
|
||||
GdiGetDcAttr(HDC hdc)
|
||||
{
|
||||
PDC_ATTR pdcattr;
|
||||
|
||||
if (!GdiGetHandleUserData((HGDIOBJ)hdc, GDI_OBJECT_TYPE_DC, (PVOID*)&pdcattr)) return NULL;
|
||||
return pdcattr;
|
||||
}
|
||||
|
||||
#ifdef _M_IX86
|
||||
FLOATL FASTCALL EFtoF(EFLOAT_S * efp);
|
||||
#define FOtoF(pfo) EFtoF((EFLOAT_S*)pfo)
|
||||
#else
|
||||
#define FOtoF(pfo) (*(pfo))
|
||||
#endif
|
||||
|
||||
/* This is an inlined version of lrintf. */
|
||||
FORCEINLINE
|
||||
int
|
||||
_lrintf(float f)
|
||||
{
|
||||
#if defined(_M_IX86) && defined(__GNUC__)
|
||||
int ret;
|
||||
__asm__ __volatile__ ("fistpl %0" : "=m" (ret) : "t" (f) : "st");
|
||||
return ret;
|
||||
#elif defined(_M_IX86) && defined(_MSC_VER)
|
||||
int ret;
|
||||
__asm
|
||||
{
|
||||
fld f;
|
||||
fistp ret;
|
||||
}
|
||||
#else
|
||||
/* slow, but portable */
|
||||
return (int)(f >= 0 ? f+0.5 : f-0.5);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,145 +1,155 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS System Libraries
|
||||
* FILE: dll/gdi32/objects/coord.c
|
||||
* PURPOSE: Functions for coordinate transformation
|
||||
* PROGRAMMER:
|
||||
*/
|
||||
#include "precomp.h"
|
||||
|
||||
/* the following deal with IEEE single-precision numbers */
|
||||
#define EXCESS 126L
|
||||
#define SIGNBIT 0x80000000L
|
||||
#define SIGN(fp) ((fp) & SIGNBIT)
|
||||
#define EXP(fp) (((fp) >> 23L) & 0xFF)
|
||||
#define MANT(fp) ((fp) & 0x7FFFFFL)
|
||||
#define PACK(s,e,m) ((s) | ((e) << 23L) | (m))
|
||||
|
||||
// Sames as lrintf.
|
||||
#ifdef __GNUC__
|
||||
#define FLOAT_TO_INT(in,out) \
|
||||
__asm__ __volatile__ ("fistpl %0" : "=m" (out) : "t" (in) : "st");
|
||||
#else
|
||||
#define FLOAT_TO_INT(in,out) \
|
||||
__asm fld in; \
|
||||
__asm fistp out;
|
||||
#endif
|
||||
|
||||
LONG
|
||||
FASTCALL
|
||||
EFtoF( EFLOAT_S * efp)
|
||||
/* Currently we use a MATRIX inside the DC_ATTR containing the
|
||||
coordinate transformations, while we deal with XFORM structures
|
||||
internally. If we move all coordinate transformation to gdi32,
|
||||
we might as well have an XFORM structure in the DC_ATTR. */
|
||||
void
|
||||
MatrixToXForm(XFORM *pxform, const MATRIX *pmx)
|
||||
{
|
||||
long Mant, Exp, Sign = 0;
|
||||
|
||||
if (!efp->lMant) return 0;
|
||||
|
||||
Mant = efp->lMant;
|
||||
Exp = efp->lExp;
|
||||
Sign = SIGN(Mant);
|
||||
|
||||
//// M$ storage emulation
|
||||
if( Sign ) Mant = -Mant;
|
||||
Mant = ((Mant & 0x3fffffff) >> 7);
|
||||
Exp += (EXCESS-1);
|
||||
////
|
||||
Mant = MANT(Mant);
|
||||
return PACK(Sign, Exp, Mant);
|
||||
XFORML *pxforml = (XFORML*)pxform;
|
||||
pxforml->eM11 = FOtoF(&pmx->efM11);
|
||||
pxforml->eM12 = FOtoF(&pmx->efM12);
|
||||
pxforml->eM21 = FOtoF(&pmx->efM21);
|
||||
pxforml->eM22 = FOtoF(&pmx->efM22);
|
||||
pxforml->eDx = FOtoF(&pmx->efDx);
|
||||
pxforml->eDy = FOtoF(&pmx->efDy);
|
||||
}
|
||||
|
||||
VOID
|
||||
FASTCALL
|
||||
FtoEF( EFLOAT_S * efp, FLOATL f)
|
||||
{
|
||||
long Mant, Exp, Sign = 0;
|
||||
gxf_long worker;
|
||||
|
||||
#ifdef _X86_
|
||||
worker.l = f; // It's a float stored in a long.
|
||||
#else
|
||||
worker.f = f;
|
||||
#endif
|
||||
|
||||
Exp = EXP(worker.l);
|
||||
Mant = MANT(worker.l);
|
||||
if (SIGN(worker.l)) Sign = -1;
|
||||
//// M$ storage emulation
|
||||
Mant = ((Mant << 7) | 0x40000000);
|
||||
Mant ^= Sign;
|
||||
Mant -= Sign;
|
||||
Exp -= (EXCESS-1);
|
||||
////
|
||||
efp->lMant = Mant;
|
||||
efp->lExp = Exp;
|
||||
}
|
||||
|
||||
|
||||
VOID FASTCALL
|
||||
CoordCnvP(MATRIX_S * mx, LPPOINT Point)
|
||||
void
|
||||
GdiTransformPoints2(
|
||||
XFORM *pxform,
|
||||
PPOINT pptOut,
|
||||
PPOINT pptIn,
|
||||
ULONG nCount)
|
||||
{
|
||||
ULONG i;
|
||||
FLOAT x, y;
|
||||
gxf_long a, b, c;
|
||||
|
||||
x = (FLOAT)Point->x;
|
||||
y = (FLOAT)Point->y;
|
||||
|
||||
a.l = EFtoF( &mx->efM11 );
|
||||
b.l = EFtoF( &mx->efM21 );
|
||||
c.l = EFtoF( &mx->efDx );
|
||||
x = x * a.f + y * b.f + c.f;
|
||||
|
||||
a.l = EFtoF( &mx->efM12 );
|
||||
b.l = EFtoF( &mx->efM22 );
|
||||
c.l = EFtoF( &mx->efDy );
|
||||
y = x * a.f + y * b.f + c.f;
|
||||
|
||||
FLOAT_TO_INT(x, Point->x );
|
||||
FLOAT_TO_INT(y, Point->y );
|
||||
for (i = 0; i < nCount; i++)
|
||||
{
|
||||
x = pptIn[i].x * pxform->eM11 + pptIn[i].y * pxform->eM12 + pxform->eDx;
|
||||
pptOut[i].x = _lrintf(x);
|
||||
y = pptIn[i].x * pxform->eM21 + pptIn[i].y * pxform->eM22 + pxform->eDy;
|
||||
pptOut[i].y = _lrintf(y);
|
||||
}
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
void
|
||||
GdiTransformPoints(
|
||||
MATRIX *pmx,
|
||||
PPOINT pptOut,
|
||||
PPOINT pptIn,
|
||||
ULONG nCount)
|
||||
{
|
||||
XFORM xform;
|
||||
|
||||
MatrixToXForm(&xform, pmx);
|
||||
GdiTransformPoints2(&xform, pptOut, pptIn, nCount);
|
||||
}
|
||||
|
||||
#define MAX_OFFSET 4294967040.0
|
||||
|
||||
BOOL
|
||||
WINAPI
|
||||
DPtoLP ( HDC hDC, LPPOINT Points, INT Count )
|
||||
CombineTransform(
|
||||
LPXFORM pxfResult,
|
||||
const XFORM *pxf1,
|
||||
const XFORM *pxf2)
|
||||
{
|
||||
#if 0
|
||||
INT i;
|
||||
PDC_ATTR Dc_Attr;
|
||||
XFORM xformTmp;
|
||||
|
||||
if (!GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE;
|
||||
/* Check paramters */
|
||||
if (!pxfResult || !pxf1 || !pxf2) return FALSE;
|
||||
|
||||
if (Dc_Attr->flXform & ( DEVICE_TO_WORLD_INVALID | // Force a full recalibration!
|
||||
PAGE_XLATE_CHANGED | // Changes or Updates have been made,
|
||||
PAGE_EXTENTS_CHANGED | // do processing in kernel space.
|
||||
WORLD_XFORM_CHANGED ))
|
||||
#endif
|
||||
return NtGdiTransformPoints( hDC, Points, Points, Count, GdiDpToLp); // DPtoLP mode.
|
||||
/* Do matrix multiplication */
|
||||
xformTmp.eM11 = pxf1->eM11 * pxf2->eM11 + pxf1->eM12 * pxf2->eM21;
|
||||
xformTmp.eM12 = pxf1->eM11 * pxf2->eM12 + pxf1->eM12 * pxf2->eM22;
|
||||
xformTmp.eM21 = pxf1->eM21 * pxf2->eM11 + pxf1->eM22 * pxf2->eM21;
|
||||
xformTmp.eM22 = pxf1->eM21 * pxf2->eM12 + pxf1->eM22 * pxf2->eM22;
|
||||
xformTmp.eDx = pxf1->eDx * pxf2->eM11 + pxf1->eDy * pxf2->eM21 + pxf2->eDx;
|
||||
xformTmp.eDy = pxf1->eDx * pxf2->eM12 + pxf1->eDy * pxf2->eM22 + pxf2->eDy;
|
||||
|
||||
*pxfResult = xformTmp;
|
||||
#if 0
|
||||
else
|
||||
/* windows compatibility fixups (needs more work) */
|
||||
if (_isnan(xformTmp.eM12))
|
||||
{
|
||||
for ( i = 0; i < Count; i++ )
|
||||
CoordCnvP ( &Dc_Attr->mxDeviceToWorld, &Points[i] );
|
||||
if (pxf1->eM11 == 0 || pxf2->eM12 == 0) pxfResult->eM12 = 0.;
|
||||
}
|
||||
#endif
|
||||
/* Check for invalid offset ranges */
|
||||
if (xformTmp.eDx > MAX_OFFSET || xformTmp.eDx < -MAX_OFFSET ||
|
||||
xformTmp.eDy > MAX_OFFSET || xformTmp.eDy < -MAX_OFFSET)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
WINAPI
|
||||
LPtoDP ( HDC hDC, LPPOINT Points, INT Count )
|
||||
DPtoLP(HDC hdc, LPPOINT lpPoints, INT nCount)
|
||||
{
|
||||
#if 0
|
||||
INT i;
|
||||
PDC_ATTR Dc_Attr;
|
||||
PDC_ATTR pdcattr;
|
||||
|
||||
if (!GdiGetHandleUserData((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE;
|
||||
|
||||
if (Dc_Attr->flXform & ( PAGE_XLATE_CHANGED | // Check for Changes and Updates
|
||||
PAGE_EXTENTS_CHANGED |
|
||||
WORLD_XFORM_CHANGED ))
|
||||
#endif
|
||||
return NtGdiTransformPoints( hDC, Points, Points, Count, GdiLpToDp); // LPtoDP mode
|
||||
#if 0
|
||||
else
|
||||
pdcattr = GdiGetDcAttr(hdc);
|
||||
if (!pdcattr)
|
||||
{
|
||||
for ( i = 0; i < Count; i++ )
|
||||
CoordCnvP ( &Dc_Attr->mxWorldToDevice, &Points[i] );
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (pdcattr->flXform & ANY_XFORM_CHANGES)
|
||||
{
|
||||
GdiFixupTransforms(pdcattr);
|
||||
}
|
||||
|
||||
// FIXME: can this fail on Windows?
|
||||
GdiTransformPoints(&pdcattr->mxDeviceToWorld, lpPoints, lpPoints, nCount);
|
||||
|
||||
return TRUE;
|
||||
#endif
|
||||
return NtGdiTransformPoints(hdc, lpPoints, lpPoints, nCount, GdiDpToLp);
|
||||
}
|
||||
|
||||
BOOL
|
||||
WINAPI
|
||||
LPtoDP(HDC hdc, LPPOINT lpPoints, INT nCount)
|
||||
{
|
||||
#if 0
|
||||
INT i;
|
||||
PDC_ATTR pdcattr;
|
||||
|
||||
pdcattr = GdiGetDcAttr(hdc);
|
||||
if (!pdcattr)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (pdcattr->flXform & ANY_XFORM_CHANGES)
|
||||
{
|
||||
GdiFixupTransforms(pdcattr);
|
||||
}
|
||||
|
||||
// FIXME: can this fail on Windows?
|
||||
GdiTransformPoints(&pdcattr->mxWorldToDevice, lpPoints, lpPoints, nCount);
|
||||
|
||||
return TRUE;
|
||||
#endif
|
||||
return NtGdiTransformPoints(hdc, lpPoints, lpPoints, nCount, GdiLpToDp);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -187,6 +197,23 @@ BOOL
|
|||
WINAPI
|
||||
GetWorldTransform(HDC hDC, LPXFORM lpXform)
|
||||
{
|
||||
#if 0
|
||||
PDC_ATTR pdcattr;
|
||||
|
||||
pdcattr = GdiGetDcAttr(hdc);
|
||||
if (!pdcattr)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (pdcattr->flXform & ANY_XFORM_INVALID)
|
||||
{
|
||||
GdiFixupTransforms(pdcattr);
|
||||
}
|
||||
|
||||
MatrixToXForm(lpXform, &pdcattr->mxWorldToDevice);
|
||||
#endif
|
||||
return NtGdiGetTransform(hDC, GdiWorldSpaceToPageSpace, lpXform);
|
||||
}
|
||||
|
||||
|
|
62
dll/win32/gdi32/objects/efloat.c
Normal file
62
dll/win32/gdi32/objects/efloat.c
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS System Libraries
|
||||
* FILE: dll/gdi32/objects/coord.c
|
||||
* PURPOSE: Functions to convert between FLOAT and EFLOAT
|
||||
* PROGRAMMER: James Tabor
|
||||
*/
|
||||
#include "precomp.h"
|
||||
|
||||
/* the following deal with IEEE single-precision numbers */
|
||||
#define EXCESS 126L
|
||||
#define SIGNBIT 0x80000000L
|
||||
#define SIGN(fp) ((fp) & SIGNBIT)
|
||||
#define EXP(fp) (((fp) >> 23L) & 0xFF)
|
||||
#define MANT(fp) ((fp) & 0x7FFFFFL)
|
||||
#define PACK(s,e,m) ((s) | ((e) << 23L) | (m))
|
||||
|
||||
FLOATL
|
||||
FASTCALL
|
||||
EFtoF(EFLOAT_S * efp)
|
||||
{
|
||||
ULONG Mant, Exp, Sign;
|
||||
|
||||
if (!efp->lMant) return 0;
|
||||
|
||||
Mant = efp->lMant;
|
||||
Exp = efp->lExp;
|
||||
Sign = SIGN(Mant);
|
||||
|
||||
if (Sign) Mant = -Mant;
|
||||
Mant >>= 7;
|
||||
Exp += (EXCESS-1);
|
||||
|
||||
Mant = MANT(Mant);
|
||||
return PACK(Sign, Exp, Mant);
|
||||
}
|
||||
|
||||
VOID
|
||||
FASTCALL
|
||||
FtoEF( EFLOAT_S * efp, FLOATL f)
|
||||
{
|
||||
ULONG Mant, Exp, Sign = 0;
|
||||
gxf_long worker;
|
||||
|
||||
#ifdef _X86_
|
||||
worker.l = f; // It's a float stored in a long.
|
||||
#else
|
||||
worker.f = f;
|
||||
#endif
|
||||
|
||||
Exp = EXP(worker.l);
|
||||
Mant = MANT(worker.l);
|
||||
if (SIGN(worker.l)) Sign = -1;
|
||||
|
||||
Mant = ((Mant << 7) | 0x40000000);
|
||||
Mant ^= Sign;
|
||||
Mant -= Sign;
|
||||
Exp -= (EXCESS-1);
|
||||
|
||||
efp->lMant = Mant;
|
||||
efp->lExp = Exp;
|
||||
}
|
|
@ -160,9 +160,4 @@ BOOL WINAPI
|
|||
GetComputerNameExA(COMPUTER_NAME_FORMAT,LPSTR,LPDWORD);
|
||||
#endif
|
||||
|
||||
#ifdef FORCE_DEBUG
|
||||
#undef DPRINT
|
||||
#define DPRINT(fmt,x...) DbgPrint("%s:%d:%s: " fmt, __FILE__, __LINE__, __FUNCTION__, ## x)
|
||||
#endif
|
||||
|
||||
#endif/*IPPRIVATE_H*/
|
||||
|
|
|
@ -47,6 +47,8 @@
|
|||
#include "iphlpapi.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi);
|
||||
|
||||
typedef struct _NAME_SERVER_LIST_PRIVATE {
|
||||
UINT NumServers;
|
||||
IP_ADDR_STRING * pCurrent;
|
||||
|
@ -74,7 +76,7 @@ QueryNameServer(
|
|||
if (Status != ERROR_SUCCESS)
|
||||
{
|
||||
/* failed to retrieve size */
|
||||
DbgPrint("Status %x\n", Status);
|
||||
TRACE("Status %x\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ ReadDirectoryChangesW(
|
|||
EventHandle,
|
||||
IoApcRoutine,
|
||||
CompletionRoutine, /* ApcContext */
|
||||
lpOverlapped ? (PIO_STATUS_BLOCK)lpOverlapped->Internal : &IoStatus,
|
||||
lpOverlapped ? (PIO_STATUS_BLOCK) lpOverlapped : &IoStatus,
|
||||
lpBuffer,
|
||||
nBufferLength,
|
||||
dwNotifyFilter,
|
||||
|
|
|
@ -179,6 +179,34 @@ CONFIGRET WINAPI CMP_Report_LogOn(
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* CMP_WaitServicesAvailable [SETUPAPI.@]
|
||||
*/
|
||||
CONFIGRET
|
||||
WINAPI
|
||||
CMP_WaitServicesAvailable(HMACHINE hMachine)
|
||||
{
|
||||
RPC_BINDING_HANDLE BindingHandle = NULL;
|
||||
CONFIGRET ret = CR_SUCCESS;
|
||||
WORD Version;
|
||||
|
||||
if (!PnpGetLocalHandles(&BindingHandle, NULL))
|
||||
return CR_FAILURE;
|
||||
|
||||
RpcTryExcept
|
||||
{
|
||||
ret = PNP_GetVersion(BindingHandle, &Version);
|
||||
}
|
||||
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
ret = RpcStatusToCmStatus(RpcExceptionCode());
|
||||
}
|
||||
RpcEndExcept;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* CM_Add_Empty_Log_Conf [SETUPAPI.@]
|
||||
*/
|
||||
|
@ -1825,7 +1853,7 @@ CONFIGRET WINAPI CM_Get_Device_ID_ExA(
|
|||
WCHAR szBufferW[MAX_DEVICE_ID_LEN];
|
||||
CONFIGRET ret = CR_SUCCESS;
|
||||
|
||||
FIXME("%lx %p %ld %ld %lx\n",
|
||||
TRACE("%lx %p %ld %ld %lx\n",
|
||||
dnDevInst, Buffer, BufferLen, ulFlags, hMachine);
|
||||
|
||||
if (Buffer == NULL)
|
||||
|
@ -1931,7 +1959,7 @@ CONFIGRET WINAPI CM_Get_Device_ID_List_ExA(
|
|||
LPWSTR pszFilterW = NULL;
|
||||
CONFIGRET ret = CR_SUCCESS;
|
||||
|
||||
FIXME("%p %p %ld %ld %lx\n",
|
||||
TRACE("%p %p %ld %ld %lx\n",
|
||||
pszFilter, Buffer, BufferLen, ulFlags, hMachine);
|
||||
|
||||
BufferW = MyMalloc(BufferLen * sizeof(WCHAR));
|
||||
|
@ -2016,7 +2044,7 @@ CONFIGRET WINAPI CM_Get_Device_ID_List_ExW(
|
|||
RpcTryExcept
|
||||
{
|
||||
ret = PNP_GetDeviceList(BindingHandle,
|
||||
pszFilter,
|
||||
(LPWSTR)pszFilter,
|
||||
Buffer,
|
||||
&BufferLen,
|
||||
ulFlags);
|
||||
|
@ -2264,6 +2292,8 @@ CONFIGRET WINAPI CM_Get_First_Log_Conf_Ex(
|
|||
if (ret != CR_SUCCESS)
|
||||
return ret;
|
||||
|
||||
if (plcLogConf)
|
||||
{
|
||||
pLogConfInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(LOG_CONF_INFO));
|
||||
if (pLogConfInfo == NULL)
|
||||
return CR_OUT_OF_MEMORY;
|
||||
|
@ -2274,6 +2304,7 @@ CONFIGRET WINAPI CM_Get_First_Log_Conf_Ex(
|
|||
pLogConfInfo->ulTag = ulTag;
|
||||
|
||||
*plcLogConf = (LOG_CONF)pLogConfInfo;
|
||||
}
|
||||
|
||||
return CR_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -1158,29 +1158,8 @@ BOOL WINAPI SetupDiClassNameFromGuidExW(
|
|||
if (hKey == INVALID_HANDLE_VALUE)
|
||||
return FALSE;
|
||||
|
||||
/* Retrieve the class name data */
|
||||
dwLength = ClassNameSize * sizeof(WCHAR);
|
||||
|
||||
do
|
||||
{
|
||||
/* Allocate a buffer to retrieve the class name data */
|
||||
Buffer = HeapAlloc(GetProcessHeap(), 0, dwLength);
|
||||
|
||||
if (Buffer == NULL)
|
||||
{
|
||||
rc = GetLastError();
|
||||
break;
|
||||
}
|
||||
|
||||
/* Query for the class name data */
|
||||
rc = RegQueryValueExW(hKey, Class, NULL, &dwRegType, (LPBYTE) Buffer, &dwLength);
|
||||
|
||||
/* Clean up the buffer if needed */
|
||||
if (rc != ERROR_SUCCESS)
|
||||
HeapFree(GetProcessHeap(), 0, Buffer);
|
||||
} while (rc == ERROR_MORE_DATA);
|
||||
|
||||
/* Close the key */
|
||||
/* Retrieve the class name data and close the key */
|
||||
rc = QueryRegistryValue(hKey, Class, (LPBYTE *) &Buffer, &dwRegType, &dwLength);
|
||||
RegCloseKey(hKey);
|
||||
|
||||
/* Make sure we got the data */
|
||||
|
@ -1193,7 +1172,7 @@ BOOL WINAPI SetupDiClassNameFromGuidExW(
|
|||
/* Make sure the data is a string */
|
||||
if (dwRegType != REG_SZ)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, Buffer);
|
||||
MyFree(Buffer);
|
||||
SetLastError(ERROR_GEN_FAILURE);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1217,7 +1196,7 @@ BOOL WINAPI SetupDiClassNameFromGuidExW(
|
|||
*RequiredSize = dwLength;
|
||||
|
||||
/* Clean up the buffer */
|
||||
HeapFree(GetProcessHeap(), 0, Buffer);
|
||||
MyFree(Buffer);
|
||||
|
||||
/* Make sure the buffer was large enough */
|
||||
if ((ClassName == NULL) || (dwLength > ClassNameSize))
|
||||
|
@ -1757,7 +1736,7 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(
|
|||
*/
|
||||
SetLastError(ERROR_DEVINST_ALREADY_EXISTS);
|
||||
}
|
||||
else if (GetLastError() == ERROR_FILE_NOT_FOUND)
|
||||
else if (GetLastError() == ERROR_NO_SUCH_DEVINST)
|
||||
{
|
||||
struct DeviceInfo *deviceInfo;
|
||||
|
||||
|
@ -2198,69 +2177,82 @@ BOOL WINAPI SetupDiGetClassDescriptionExW(
|
|||
DWORD dwLength;
|
||||
DWORD dwRegType;
|
||||
LONG rc;
|
||||
PWSTR Buffer;
|
||||
|
||||
TRACE("%s %p %lu %p %s %p\n", debugstr_guid(ClassGuid), ClassDescription,
|
||||
ClassDescriptionSize, RequiredSize, debugstr_w(MachineName), Reserved);
|
||||
|
||||
/* Make sure there's a GUID */
|
||||
if (!ClassGuid)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
else if (!ClassDescription && ClassDescriptionSize > 0)
|
||||
|
||||
/* Make sure there's a real buffer when there's a size */
|
||||
if (!ClassDescription && ClassDescriptionSize > 0)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Open the key for the GUID */
|
||||
hKey = SetupDiOpenClassRegKeyExW(ClassGuid,
|
||||
KEY_QUERY_VALUE,
|
||||
DIOCR_INSTALLER,
|
||||
MachineName,
|
||||
Reserved);
|
||||
if (hKey == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
WARN("SetupDiOpenClassRegKeyExW() failed (Error %u)\n", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (ClassDescriptionSize < sizeof(UNICODE_NULL) || !ClassDescription)
|
||||
dwLength = 0;
|
||||
else
|
||||
dwLength = ClassDescriptionSize * sizeof(WCHAR) - sizeof(UNICODE_NULL);
|
||||
|
||||
rc = RegQueryValueExW(hKey,
|
||||
NULL,
|
||||
NULL,
|
||||
&dwRegType,
|
||||
(LPBYTE)ClassDescription,
|
||||
&dwLength);
|
||||
/* Retrieve the class description data and close the key */
|
||||
rc = QueryRegistryValue(hKey, NULL, (LPBYTE *) &Buffer, &dwRegType, &dwLength);
|
||||
RegCloseKey(hKey);
|
||||
if (rc != ERROR_MORE_DATA && rc != ERROR_SUCCESS)
|
||||
|
||||
/* Make sure we got the data */
|
||||
if (rc != ERROR_SUCCESS)
|
||||
{
|
||||
SetLastError(rc);
|
||||
return FALSE;
|
||||
}
|
||||
else if (dwRegType != REG_SZ)
|
||||
|
||||
/* Make sure the data is a string */
|
||||
if (dwRegType != REG_SZ)
|
||||
{
|
||||
MyFree(Buffer);
|
||||
SetLastError(ERROR_GEN_FAILURE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (RequiredSize)
|
||||
*RequiredSize = dwLength / sizeof(WCHAR) + 1;
|
||||
/* Determine the length of the class description */
|
||||
dwLength /= sizeof(WCHAR);
|
||||
|
||||
if (ClassDescriptionSize * sizeof(WCHAR) >= dwLength + sizeof(UNICODE_NULL))
|
||||
/* Count the null-terminator if none is present */
|
||||
if ((dwLength == 0) || (Buffer[dwLength - 1] != UNICODE_NULL))
|
||||
dwLength++;
|
||||
|
||||
/* Inform the caller about the class description */
|
||||
if ((ClassDescription != NULL) && (dwLength <= ClassDescriptionSize))
|
||||
{
|
||||
if (ClassDescriptionSize > sizeof(UNICODE_NULL))
|
||||
ClassDescription[ClassDescriptionSize / sizeof(WCHAR)] = UNICODE_NULL;
|
||||
return TRUE;
|
||||
memcpy(ClassDescription, Buffer, (dwLength - 1) * sizeof(WCHAR));
|
||||
ClassDescription[dwLength - 1] = UNICODE_NULL;
|
||||
}
|
||||
else
|
||||
|
||||
/* Inform the caller about the required size */
|
||||
if (RequiredSize != NULL)
|
||||
*RequiredSize = dwLength;
|
||||
|
||||
/* Clean up the buffer */
|
||||
MyFree(Buffer);
|
||||
|
||||
/* Make sure the buffer was large enough */
|
||||
if ((ClassDescription == NULL) || (dwLength > ClassDescriptionSize))
|
||||
{
|
||||
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -2357,7 +2349,7 @@ HDEVINFO WINAPI SetupDiGetClassDevsExW(
|
|||
if (!(flags & DIGCF_ALLCLASSES) && !class)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return NULL;
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
/* Create the deviceset if not set */
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
@ stdcall CMP_Report_LogOn(long long)
|
||||
@ stdcall CMP_UnregisterNotification(ptr)
|
||||
@ stdcall CMP_WaitNoPendingInstallEvents(long)
|
||||
@ stub CMP_WaitServicesAvailable
|
||||
@ stdcall CMP_WaitServicesAvailable(ptr)
|
||||
@ stdcall CM_Add_Empty_Log_Conf(ptr ptr long long)
|
||||
@ stdcall CM_Add_Empty_Log_Conf_Ex(ptr ptr long long ptr)
|
||||
@ stdcall CM_Add_IDA(ptr str long)
|
||||
|
|
|
@ -39,7 +39,6 @@ list(APPEND SOURCE
|
|||
misc/usrapihk.c
|
||||
misc/winhelp.c
|
||||
misc/winsta.c
|
||||
misc/wsprintf.c
|
||||
windows/accel.c
|
||||
windows/caret.c
|
||||
windows/class.c
|
||||
|
@ -74,6 +73,7 @@ add_library(user32 SHARED
|
|||
set_module_type(user32 win32dll)
|
||||
|
||||
target_link_libraries(user32
|
||||
user32_wsprintf
|
||||
wine
|
||||
win32ksys
|
||||
${PSEH_LIB})
|
||||
|
|
|
@ -22,11 +22,6 @@
|
|||
|
||||
#include <wine/debug.h>
|
||||
|
||||
#ifdef __REACTOS__
|
||||
#define MAKEINTATOMW(atom) ((LPCWSTR)((ULONG_PTR)((WORD)(atom))))
|
||||
#define ICONTITLE_CLASS_ATOM MAKEINTATOMW(32772)
|
||||
#endif
|
||||
|
||||
static BOOL bMultiLineTitle;
|
||||
static HFONT hIconTitleFont;
|
||||
|
||||
|
@ -35,7 +30,7 @@ static HFONT hIconTitleFont;
|
|||
*/
|
||||
const struct builtin_class_descr ICONTITLE_builtin_class =
|
||||
{
|
||||
(LPCWSTR)ICONTITLE_CLASS_ATOM, /* name */
|
||||
WC_ICONTITLE, /* name */
|
||||
0, /* style */
|
||||
NULL, /* procA (winproc is Unicode only) */
|
||||
IconTitleWndProc, /* procW */
|
||||
|
|
|
@ -38,17 +38,6 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(listbox);
|
||||
|
||||
/* Start of hack section -------------------------------- */
|
||||
|
||||
#define WM_LBTRACKPOINT 0x0131
|
||||
#define WS_EX_DRAGDETECT 0x00000002L
|
||||
#define WM_BEGINDRAG 0x022C
|
||||
|
||||
UINT_PTR WINAPI SetSystemTimer(HWND,UINT_PTR,UINT,TIMERPROC);
|
||||
BOOL WINAPI KillSystemTimer(HWND,UINT_PTR);
|
||||
|
||||
/* End of hack section -------------------------------- */
|
||||
|
||||
/* Items array granularity */
|
||||
#define LB_ARRAY_GRANULARITY 16
|
||||
|
||||
|
|
|
@ -845,31 +845,28 @@ static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style )
|
|||
DeleteObject( hBrush );
|
||||
}
|
||||
|
||||
/* Modified for ReactOS */
|
||||
static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style )
|
||||
{
|
||||
RECT rc, iconRect;
|
||||
HBRUSH hbrush;
|
||||
HICON hIcon;
|
||||
ICONINFO info;
|
||||
SIZE size;
|
||||
|
||||
GetClientRect( hwnd, &rc );
|
||||
hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
|
||||
hIcon = (HICON)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET );
|
||||
if (!hIcon || (!GetIconInfo(hIcon, &info)))
|
||||
if (!hIcon || !get_icon_size( hIcon, &size ))
|
||||
{
|
||||
FillRect(hdc, &rc, hbrush);
|
||||
}
|
||||
else
|
||||
{
|
||||
BITMAP bm;
|
||||
if (!GetObjectW(info.hbmColor, sizeof(BITMAP), &bm)) return;
|
||||
if (style & SS_CENTERIMAGE)
|
||||
{
|
||||
iconRect.left = (rc.right - rc.left) / 2 - bm.bmWidth / 2;
|
||||
iconRect.top = (rc.bottom - rc.top) / 2 - bm.bmHeight / 2;
|
||||
iconRect.right = iconRect.left + bm.bmWidth;
|
||||
iconRect.bottom = iconRect.top + bm.bmHeight;
|
||||
iconRect.left = (rc.right - rc.left) / 2 - size.cx / 2;
|
||||
iconRect.top = (rc.bottom - rc.top) / 2 - size.cy / 2;
|
||||
iconRect.right = iconRect.left + size.cx;
|
||||
iconRect.bottom = iconRect.top + size.cy;
|
||||
}
|
||||
else
|
||||
iconRect = rc;
|
||||
|
@ -966,3 +963,4 @@ static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style )
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
/* Missing from Winuser.h */
|
||||
#define ES_COMBO 0x00000200 /* Undocumented. Parent is a combobox */
|
||||
#ifndef MAKEINTATOMA
|
||||
#define MAKEINTATOMA(atom) ((LPCSTR)((ULONG_PTR)((WORD)(atom))))
|
||||
#endif
|
||||
#ifndef WM_ISACTIVEICON
|
||||
#define WM_ISACTIVEICON 0x0035
|
||||
#endif
|
||||
|
||||
#ifndef HBMMENU_CALLBACK
|
||||
#define HBMMENU_CALLBACK ((HBITMAP) -1)
|
||||
#endif
|
||||
|
@ -46,11 +37,6 @@
|
|||
/* winuser.h */
|
||||
|
||||
|
||||
// I dont know where this goes
|
||||
|
||||
#define LB_CARETON 0x01a3
|
||||
#define LB_CARETOFF 0x01a4
|
||||
|
||||
/* combo box */
|
||||
|
||||
#define ID_CB_LISTBOX 1000
|
||||
|
@ -106,7 +92,6 @@ extern BOOL COMBO_FlipListbox( LPHEADCOMBO, BOOL, BOOL );
|
|||
#define LB_ADDSTRING_UPPER 0x1AC
|
||||
#define LB_ADDSTRING_LOWER 0x1AD
|
||||
|
||||
#define DESKTOP_CLASS_ATOM MAKEINTATOMA(32769) /* Desktop */
|
||||
LRESULT WINAPI DesktopWndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam );
|
||||
LRESULT WINAPI User32DefWindowProc(HWND,UINT,WPARAM,LPARAM,BOOL);
|
||||
BOOL WINAPI RegisterClientPFN(VOID);
|
||||
|
|
|
@ -10,3 +10,6 @@ HICON CreateCursorIconFromData(PVOID ImageData,
|
|||
int yHotspot,
|
||||
BOOL fIcon);
|
||||
|
||||
|
||||
BOOL get_icon_size(HICON hIcon, SIZE *size);
|
||||
|
||||
|
|
|
@ -11,9 +11,6 @@
|
|||
BOOL FASTCALL MessageInit(VOID);
|
||||
VOID FASTCALL MessageCleanup(VOID);
|
||||
|
||||
#define WM_ALTTABACTIVE 0x0029
|
||||
#define WM_SETVISIBLE 0x0009
|
||||
|
||||
static __inline BOOL
|
||||
IsCallProcHandle(IN WNDPROC lpWndProc)
|
||||
{
|
||||
|
|
|
@ -10,9 +10,6 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#define IS_ATOM(x) \
|
||||
(((ULONG_PTR)(x) > 0x0) && ((ULONG_PTR)(x) < 0x10000))
|
||||
|
||||
/* Built-in class descriptor */
|
||||
struct builtin_class_descr
|
||||
{
|
||||
|
|
|
@ -33,6 +33,9 @@
|
|||
#include <win32k/ntuser.h>
|
||||
#include <win32k/callback.h>
|
||||
|
||||
/* Undocumented user definitions*/
|
||||
#include <undocuser.h>
|
||||
|
||||
/* WINE Headers */
|
||||
#include <wine/unicode.h>
|
||||
|
||||
|
@ -47,60 +50,9 @@
|
|||
(GetWin32ClientInfo()->pDeskInfo && GetWin32ClientInfo()->pDeskInfo->fsHooks & HOOKID_TO_FLAG(HookId)))
|
||||
|
||||
/* Temporarily in here for now. */
|
||||
typedef struct _USERAPIHOOKINFO
|
||||
{
|
||||
DWORD m_size;
|
||||
LPCWSTR m_dllname1;
|
||||
LPCWSTR m_funname1;
|
||||
LPCWSTR m_dllname2;
|
||||
LPCWSTR m_funname2;
|
||||
} USERAPIHOOKINFO,*PUSERAPIHOOKINFO;
|
||||
|
||||
typedef LRESULT(CALLBACK *WNDPROC_OWP)(HWND,UINT,WPARAM,LPARAM,ULONG_PTR,PDWORD);
|
||||
|
||||
typedef struct _UAHOWP
|
||||
{
|
||||
BYTE* MsgBitArray;
|
||||
DWORD Size;
|
||||
} UAHOWP, *PUAHOWP;
|
||||
|
||||
typedef struct tagUSERAPIHOOK
|
||||
{
|
||||
DWORD size;
|
||||
WNDPROC DefWindowProcA;
|
||||
WNDPROC DefWindowProcW;
|
||||
UAHOWP DefWndProcArray;
|
||||
FARPROC GetScrollInfo;
|
||||
FARPROC SetScrollInfo;
|
||||
FARPROC EnableScrollBar;
|
||||
FARPROC AdjustWindowRectEx;
|
||||
FARPROC SetWindowRgn;
|
||||
WNDPROC_OWP PreWndProc;
|
||||
WNDPROC_OWP PostWndProc;
|
||||
UAHOWP WndProcArray;
|
||||
WNDPROC_OWP PreDefDlgProc;
|
||||
WNDPROC_OWP PostDefDlgProc;
|
||||
UAHOWP DlgProcArray;
|
||||
FARPROC GetSystemMetrics;
|
||||
FARPROC SystemParametersInfoA;
|
||||
FARPROC SystemParametersInfoW;
|
||||
FARPROC ForceResetUserApiHook;
|
||||
FARPROC DrawFrameControl;
|
||||
FARPROC DrawCaption;
|
||||
FARPROC MDIRedrawFrame;
|
||||
FARPROC GetRealWindowOwner;
|
||||
} USERAPIHOOK, *PUSERAPIHOOK;
|
||||
|
||||
typedef enum _UAPIHK
|
||||
{
|
||||
uahLoadInit,
|
||||
uahStop,
|
||||
uahShutdown
|
||||
} UAPIHK, *PUAPIHK;
|
||||
|
||||
extern RTL_CRITICAL_SECTION gcsUserApiHook;
|
||||
extern USERAPIHOOK guah;
|
||||
typedef DWORD (CALLBACK * USERAPIHOOKPROC)(UAPIHK State, ULONG_PTR Info);
|
||||
BOOL FASTCALL BeginIfHookedUserApiHook(VOID);
|
||||
BOOL FASTCALL EndUserApiHook(VOID);
|
||||
BOOL FASTCALL IsInsideUserApiHook(VOID);
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
#include "winsta.h"
|
||||
#include "ntwrapper.h"
|
||||
|
||||
#define IS_ATOM(x) \
|
||||
(((ULONG_PTR)(x) > 0x0) && ((ULONG_PTR)(x) < 0x10000))
|
||||
|
||||
/* One/Two Param Functions */
|
||||
#define NtUserMsqSetWakeMask(dwWaitMask) \
|
||||
(HANDLE)NtUserCallOneParam(dwWaitMask, ONEPARAM_ROUTINE_GETINPUTEVENT)
|
||||
|
|
|
@ -12,8 +12,6 @@ extern HBRUSH SysBrushes[];
|
|||
|
||||
#define NUM_SYSCOLORS 31
|
||||
|
||||
#define IS_ATOM(x) \
|
||||
(((ULONG_PTR)(x) > 0x0) && ((ULONG_PTR)(x) < 0x10000))
|
||||
|
||||
#define UserHasAnyFrameStyle(Style, ExStyle) \
|
||||
(((Style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) || \
|
||||
|
|
|
@ -20,7 +20,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(user32);
|
|||
#if 0 // Kept for referencing.
|
||||
const struct builtin_class_descr DESKTOP_builtin_class =
|
||||
{
|
||||
(LPCWSTR) DESKTOP_CLASS_ATOM, /* name */
|
||||
WC_DESKTOP, /* name */
|
||||
CS_DBLCLKS, /* style */
|
||||
NULL, /* procA (winproc is Unicode only) */
|
||||
(WNDPROC) DesktopWndProc, /* procW */
|
||||
|
|
|
@ -1,536 +0,0 @@
|
|||
/*
|
||||
* wsprintf functions
|
||||
*
|
||||
* Copyright 1996 Alexandre Julliard
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
* NOTE:
|
||||
* This code is duplicated in shlwapi. If you change something here make sure
|
||||
* to change it in shlwapi too.
|
||||
*/
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS User32
|
||||
* PURPOSE: [w]sprintf functions
|
||||
* FILE: lib/user32/wsprintf.c
|
||||
* PROGRAMER: Steven Edwards
|
||||
* REVISION HISTORY: 2003/07/13 Merged from wine user/wsprintf.c
|
||||
* NOTES: Adapted from Wine
|
||||
*/
|
||||
|
||||
#include <user32.h>
|
||||
|
||||
#define WINE_NO_TRACE_MSGS
|
||||
#include <wine/debug.h>
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(string);
|
||||
|
||||
|
||||
#define WPRINTF_LEFTALIGN 0x0001 /* Align output on the left ('-' prefix) */
|
||||
#define WPRINTF_PREFIX_HEX 0x0002 /* Prefix hex with 0x ('#' prefix) */
|
||||
#define WPRINTF_ZEROPAD 0x0004 /* Pad with zeros ('0' prefix) */
|
||||
#define WPRINTF_LONG 0x0008 /* Long arg ('l' prefix) */
|
||||
#define WPRINTF_SHORT 0x0010 /* Short arg ('h' prefix) */
|
||||
#define WPRINTF_UPPER_HEX 0x0020 /* Upper-case hex ('X' specifier) */
|
||||
#define WPRINTF_WIDE 0x0040 /* Wide arg ('w' prefix) */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
WPR_UNKNOWN,
|
||||
WPR_CHAR,
|
||||
WPR_WCHAR,
|
||||
WPR_STRING,
|
||||
WPR_WSTRING,
|
||||
WPR_SIGNED,
|
||||
WPR_UNSIGNED,
|
||||
WPR_HEXA
|
||||
} WPRINTF_TYPE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT flags;
|
||||
UINT width;
|
||||
UINT precision;
|
||||
WPRINTF_TYPE type;
|
||||
} WPRINTF_FORMAT;
|
||||
|
||||
typedef union {
|
||||
WCHAR wchar_view;
|
||||
CHAR char_view;
|
||||
LPCSTR lpcstr_view;
|
||||
LPCWSTR lpcwstr_view;
|
||||
INT int_view;
|
||||
} WPRINTF_DATA;
|
||||
|
||||
static const CHAR null_stringA[] = "(null)";
|
||||
static const WCHAR null_stringW[] = { '(', 'n', 'u', 'l', 'l', ')', 0 };
|
||||
|
||||
/***********************************************************************
|
||||
* WPRINTF_ParseFormatA
|
||||
*
|
||||
* Parse a format specification. A format specification has the form:
|
||||
*
|
||||
* [-][#][0][width][.precision]type
|
||||
*
|
||||
* Return value is the length of the format specification in characters.
|
||||
*/
|
||||
static INT WPRINTF_ParseFormatA( LPCSTR format, WPRINTF_FORMAT *res )
|
||||
{
|
||||
LPCSTR p = format;
|
||||
|
||||
res->flags = 0;
|
||||
res->width = 0;
|
||||
res->precision = 0;
|
||||
if (*p == '-') { res->flags |= WPRINTF_LEFTALIGN; p++; }
|
||||
if (*p == '#') { res->flags |= WPRINTF_PREFIX_HEX; p++; }
|
||||
if (*p == '0') { res->flags |= WPRINTF_ZEROPAD; p++; }
|
||||
while ((*p >= '0') && (*p <= '9')) /* width field */
|
||||
{
|
||||
res->width = res->width * 10 + *p - '0';
|
||||
p++;
|
||||
}
|
||||
if (*p == '.') /* precision field */
|
||||
{
|
||||
p++;
|
||||
while ((*p >= '0') && (*p <= '9'))
|
||||
{
|
||||
res->precision = res->precision * 10 + *p - '0';
|
||||
p++;
|
||||
}
|
||||
}
|
||||
if (*p == 'l') { res->flags |= WPRINTF_LONG; p++; }
|
||||
else if (*p == 'h') { res->flags |= WPRINTF_SHORT; p++; }
|
||||
else if (*p == 'w') { res->flags |= WPRINTF_WIDE; p++; }
|
||||
switch(*p)
|
||||
{
|
||||
case 'c':
|
||||
res->type = (res->flags & WPRINTF_LONG) ? WPR_WCHAR : WPR_CHAR;
|
||||
break;
|
||||
case 'C':
|
||||
res->type = (res->flags & WPRINTF_SHORT) ? WPR_CHAR : WPR_WCHAR;
|
||||
break;
|
||||
case 'd':
|
||||
case 'i':
|
||||
res->type = WPR_SIGNED;
|
||||
break;
|
||||
case 's':
|
||||
res->type = (res->flags & (WPRINTF_LONG |WPRINTF_WIDE)) ? WPR_WSTRING : WPR_STRING;
|
||||
break;
|
||||
case 'S':
|
||||
res->type = (res->flags & (WPRINTF_SHORT|WPRINTF_WIDE)) ? WPR_STRING : WPR_WSTRING;
|
||||
break;
|
||||
case 'u':
|
||||
res->type = WPR_UNSIGNED;
|
||||
break;
|
||||
case 'p':
|
||||
res->width = 8;
|
||||
res->flags |= WPRINTF_ZEROPAD;
|
||||
/* fall through */
|
||||
case 'X':
|
||||
res->flags |= WPRINTF_UPPER_HEX;
|
||||
/* fall through */
|
||||
case 'x':
|
||||
res->type = WPR_HEXA;
|
||||
break;
|
||||
default: /* unknown format char */
|
||||
res->type = WPR_UNKNOWN;
|
||||
p--; /* print format as normal char */
|
||||
break;
|
||||
}
|
||||
return (INT)(p - format) + 1;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* WPRINTF_ParseFormatW
|
||||
*
|
||||
* Parse a format specification. A format specification has the form:
|
||||
*
|
||||
* [-][#][0][width][.precision]type
|
||||
*
|
||||
* Return value is the length of the format specification in characters.
|
||||
*/
|
||||
static INT WPRINTF_ParseFormatW( LPCWSTR format, WPRINTF_FORMAT *res )
|
||||
{
|
||||
LPCWSTR p = format;
|
||||
|
||||
res->flags = 0;
|
||||
res->width = 0;
|
||||
res->precision = 0;
|
||||
if (*p == '-') { res->flags |= WPRINTF_LEFTALIGN; p++; }
|
||||
if (*p == '#') { res->flags |= WPRINTF_PREFIX_HEX; p++; }
|
||||
if (*p == '0') { res->flags |= WPRINTF_ZEROPAD; p++; }
|
||||
while ((*p >= '0') && (*p <= '9')) /* width field */
|
||||
{
|
||||
res->width = res->width * 10 + *p - '0';
|
||||
p++;
|
||||
}
|
||||
if (*p == '.') /* precision field */
|
||||
{
|
||||
p++;
|
||||
while ((*p >= '0') && (*p <= '9'))
|
||||
{
|
||||
res->precision = res->precision * 10 + *p - '0';
|
||||
p++;
|
||||
}
|
||||
}
|
||||
if (*p == 'l') { res->flags |= WPRINTF_LONG; p++; }
|
||||
else if (*p == 'h') { res->flags |= WPRINTF_SHORT; p++; }
|
||||
else if (*p == 'w') { res->flags |= WPRINTF_WIDE; p++; }
|
||||
switch((CHAR)*p)
|
||||
{
|
||||
case 'c':
|
||||
res->type = (res->flags & WPRINTF_SHORT) ? WPR_CHAR : WPR_WCHAR;
|
||||
break;
|
||||
case 'C':
|
||||
res->type = (res->flags & WPRINTF_LONG) ? WPR_WCHAR : WPR_CHAR;
|
||||
break;
|
||||
case 'd':
|
||||
case 'i':
|
||||
res->type = WPR_SIGNED;
|
||||
break;
|
||||
case 's':
|
||||
res->type = ((res->flags & WPRINTF_SHORT) && !(res->flags & WPRINTF_WIDE)) ? WPR_STRING : WPR_WSTRING;
|
||||
break;
|
||||
case 'S':
|
||||
res->type = (res->flags & (WPRINTF_LONG|WPRINTF_WIDE)) ? WPR_WSTRING : WPR_STRING;
|
||||
break;
|
||||
case 'u':
|
||||
res->type = WPR_UNSIGNED;
|
||||
break;
|
||||
case 'p':
|
||||
res->width = 8;
|
||||
res->flags |= WPRINTF_ZEROPAD;
|
||||
/* fall through */
|
||||
case 'X':
|
||||
res->flags |= WPRINTF_UPPER_HEX;
|
||||
/* fall through */
|
||||
case 'x':
|
||||
res->type = WPR_HEXA;
|
||||
break;
|
||||
default:
|
||||
res->type = WPR_UNKNOWN;
|
||||
p--; /* print format as normal char */
|
||||
break;
|
||||
}
|
||||
return (INT)(p - format) + 1;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* WPRINTF_GetLen
|
||||
*/
|
||||
static UINT WPRINTF_GetLen( WPRINTF_FORMAT *format, WPRINTF_DATA *arg,
|
||||
LPSTR number, UINT maxlen )
|
||||
{
|
||||
UINT len;
|
||||
|
||||
if (format->flags & WPRINTF_LEFTALIGN) format->flags &= ~WPRINTF_ZEROPAD;
|
||||
if (format->width > maxlen) format->width = maxlen;
|
||||
switch(format->type)
|
||||
{
|
||||
case WPR_CHAR:
|
||||
case WPR_WCHAR:
|
||||
return (format->precision = 1);
|
||||
case WPR_STRING:
|
||||
if (!arg->lpcstr_view) arg->lpcstr_view = null_stringA;
|
||||
for (len = 0; !format->precision || (len < format->precision); len++)
|
||||
if (!*(arg->lpcstr_view + len)) break;
|
||||
if (len > maxlen) len = maxlen;
|
||||
return (format->precision = len);
|
||||
case WPR_WSTRING:
|
||||
if (!arg->lpcwstr_view) arg->lpcwstr_view = null_stringW;
|
||||
for (len = 0; !format->precision || (len < format->precision); len++)
|
||||
if (!*(arg->lpcwstr_view + len)) break;
|
||||
if (len > maxlen) len = maxlen;
|
||||
return (format->precision = len);
|
||||
case WPR_SIGNED:
|
||||
len = sprintf( number, "%d", arg->int_view );
|
||||
break;
|
||||
case WPR_UNSIGNED:
|
||||
len = sprintf( number, "%u", (UINT)arg->int_view );
|
||||
break;
|
||||
case WPR_HEXA:
|
||||
len = sprintf( number,
|
||||
(format->flags & WPRINTF_UPPER_HEX) ? "%X" : "%x",
|
||||
(UINT)arg->int_view);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
if (len > maxlen) len = maxlen;
|
||||
if (format->precision < len) format->precision = len;
|
||||
if (format->precision > maxlen) format->precision = maxlen;
|
||||
if ((format->flags & WPRINTF_ZEROPAD) && (format->width > format->precision))
|
||||
format->precision = format->width;
|
||||
if (format->flags & WPRINTF_PREFIX_HEX) len += 2;
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* wvsnprintfA (internal)
|
||||
*/
|
||||
static INT wvsnprintfA( LPSTR buffer, UINT maxlen, LPCSTR spec, __ms_va_list args )
|
||||
{
|
||||
WPRINTF_FORMAT format;
|
||||
LPSTR p = buffer;
|
||||
UINT i, len, sign;
|
||||
CHAR number[20];
|
||||
WPRINTF_DATA argData;
|
||||
|
||||
TRACE("%p %u %s\n", buffer, maxlen, debugstr_a(spec));
|
||||
|
||||
while (*spec && (maxlen > 1))
|
||||
{
|
||||
if (*spec != '%') { *p++ = *spec++; maxlen--; continue; }
|
||||
spec++;
|
||||
if (*spec == '%') { *p++ = *spec++; maxlen--; continue; }
|
||||
spec += WPRINTF_ParseFormatA( spec, &format );
|
||||
|
||||
switch(format.type)
|
||||
{
|
||||
case WPR_WCHAR:
|
||||
argData.wchar_view = (WCHAR)va_arg( args, int );
|
||||
break;
|
||||
case WPR_CHAR:
|
||||
argData.char_view = (CHAR)va_arg( args, int );
|
||||
break;
|
||||
case WPR_STRING:
|
||||
argData.lpcstr_view = va_arg( args, LPCSTR );
|
||||
break;
|
||||
case WPR_WSTRING:
|
||||
argData.lpcwstr_view = va_arg( args, LPCWSTR );
|
||||
break;
|
||||
case WPR_HEXA:
|
||||
case WPR_SIGNED:
|
||||
case WPR_UNSIGNED:
|
||||
argData.int_view = va_arg( args, INT );
|
||||
break;
|
||||
default:
|
||||
argData.wchar_view = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
len = WPRINTF_GetLen( &format, &argData, number, maxlen - 1 );
|
||||
sign = 0;
|
||||
if (!(format.flags & WPRINTF_LEFTALIGN))
|
||||
for (i = format.precision; i < format.width; i++, maxlen--)
|
||||
*p++ = ' ';
|
||||
switch(format.type)
|
||||
{
|
||||
case WPR_WCHAR:
|
||||
*p++ = argData.wchar_view;
|
||||
break;
|
||||
case WPR_CHAR:
|
||||
*p++ = argData.char_view;
|
||||
break;
|
||||
case WPR_STRING:
|
||||
memcpy( p, argData.lpcstr_view, len );
|
||||
p += len;
|
||||
break;
|
||||
case WPR_WSTRING:
|
||||
{
|
||||
LPCWSTR ptr = argData.lpcwstr_view;
|
||||
for (i = 0; i < len; i++) *p++ = (CHAR)*ptr++;
|
||||
}
|
||||
break;
|
||||
case WPR_HEXA:
|
||||
if ((format.flags & WPRINTF_PREFIX_HEX) && (maxlen > 3))
|
||||
{
|
||||
*p++ = '0';
|
||||
*p++ = (format.flags & WPRINTF_UPPER_HEX) ? 'X' : 'x';
|
||||
maxlen -= 2;
|
||||
len -= 2;
|
||||
}
|
||||
/* fall through */
|
||||
case WPR_SIGNED:
|
||||
/* Transfer the sign now, just in case it will be zero-padded*/
|
||||
if (number[0] == '-')
|
||||
{
|
||||
*p++ = '-';
|
||||
sign = 1;
|
||||
}
|
||||
/* fall through */
|
||||
case WPR_UNSIGNED:
|
||||
for (i = len; i < format.precision; i++, maxlen--) *p++ = '0';
|
||||
memcpy( p, number + sign, len - sign );
|
||||
p += len - sign;
|
||||
break;
|
||||
case WPR_UNKNOWN:
|
||||
continue;
|
||||
}
|
||||
if (format.flags & WPRINTF_LEFTALIGN)
|
||||
for (i = format.precision; i < format.width; i++, maxlen--)
|
||||
*p++ = ' ';
|
||||
maxlen -= len;
|
||||
}
|
||||
*p = 0;
|
||||
TRACE("%s\n",debugstr_a(buffer));
|
||||
return (maxlen > 1) ? (INT)(p - buffer) : -1;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* wvsnprintfW (internal)
|
||||
*/
|
||||
static INT wvsnprintfW( LPWSTR buffer, UINT maxlen, LPCWSTR spec, __ms_va_list args )
|
||||
{
|
||||
WPRINTF_FORMAT format;
|
||||
LPWSTR p = buffer;
|
||||
UINT i, len, sign;
|
||||
CHAR number[20];
|
||||
WPRINTF_DATA argData;
|
||||
|
||||
TRACE("%p %u %s\n", buffer, maxlen, debugstr_w(spec));
|
||||
|
||||
while (*spec && (maxlen > 1))
|
||||
{
|
||||
if (*spec != '%') { *p++ = *spec++; maxlen--; continue; }
|
||||
spec++;
|
||||
if (*spec == '%') { *p++ = *spec++; maxlen--; continue; }
|
||||
spec += WPRINTF_ParseFormatW( spec, &format );
|
||||
|
||||
switch(format.type)
|
||||
{
|
||||
case WPR_WCHAR:
|
||||
argData.wchar_view = (WCHAR)va_arg( args, int );
|
||||
break;
|
||||
case WPR_CHAR:
|
||||
argData.char_view = (CHAR)va_arg( args, int );
|
||||
break;
|
||||
case WPR_STRING:
|
||||
argData.lpcstr_view = va_arg( args, LPCSTR );
|
||||
break;
|
||||
case WPR_WSTRING:
|
||||
argData.lpcwstr_view = va_arg( args, LPCWSTR );
|
||||
break;
|
||||
case WPR_HEXA:
|
||||
case WPR_SIGNED:
|
||||
case WPR_UNSIGNED:
|
||||
argData.int_view = va_arg( args, INT );
|
||||
break;
|
||||
default:
|
||||
argData.wchar_view = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
len = WPRINTF_GetLen( &format, &argData, number, maxlen - 1 );
|
||||
sign = 0;
|
||||
if (!(format.flags & WPRINTF_LEFTALIGN))
|
||||
for (i = format.precision; i < format.width; i++, maxlen--)
|
||||
*p++ = ' ';
|
||||
switch(format.type)
|
||||
{
|
||||
case WPR_WCHAR:
|
||||
*p++ = argData.wchar_view;
|
||||
break;
|
||||
case WPR_CHAR:
|
||||
*p++ = argData.char_view;
|
||||
break;
|
||||
case WPR_STRING:
|
||||
{
|
||||
LPCSTR ptr = argData.lpcstr_view;
|
||||
for (i = 0; i < len; i++) *p++ = (WCHAR)*ptr++;
|
||||
}
|
||||
break;
|
||||
case WPR_WSTRING:
|
||||
if (len) memcpy( p, argData.lpcwstr_view, len * sizeof(WCHAR) );
|
||||
p += len;
|
||||
break;
|
||||
case WPR_HEXA:
|
||||
if ((format.flags & WPRINTF_PREFIX_HEX) && (maxlen > 3))
|
||||
{
|
||||
*p++ = '0';
|
||||
*p++ = (format.flags & WPRINTF_UPPER_HEX) ? 'X' : 'x';
|
||||
maxlen -= 2;
|
||||
len -= 2;
|
||||
}
|
||||
/* fall through */
|
||||
case WPR_SIGNED:
|
||||
/* Transfer the sign now, just in case it will be zero-padded*/
|
||||
if (number[0] == '-')
|
||||
{
|
||||
*p++ = '-';
|
||||
sign = 1;
|
||||
}
|
||||
/* fall through */
|
||||
case WPR_UNSIGNED:
|
||||
for (i = len; i < format.precision; i++, maxlen--) *p++ = '0';
|
||||
for (i = sign; i < len; i++) *p++ = (WCHAR)number[i];
|
||||
break;
|
||||
case WPR_UNKNOWN:
|
||||
continue;
|
||||
}
|
||||
if (format.flags & WPRINTF_LEFTALIGN)
|
||||
for (i = format.precision; i < format.width; i++, maxlen--)
|
||||
*p++ = ' ';
|
||||
maxlen -= len;
|
||||
}
|
||||
*p = 0;
|
||||
TRACE("%s\n",debugstr_w(buffer));
|
||||
return (maxlen > 1) ? (INT)(p - buffer) : -1;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* wvsprintfA (USER32.@)
|
||||
*/
|
||||
INT WINAPI wvsprintfA( LPSTR buffer, LPCSTR spec, __ms_va_list args )
|
||||
{
|
||||
INT res = wvsnprintfA( buffer, 1024, spec, args );
|
||||
return ( res == -1 ) ? 1024 : res;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* wvsprintfW (USER32.@)
|
||||
*/
|
||||
INT WINAPI wvsprintfW( LPWSTR buffer, LPCWSTR spec, __ms_va_list args )
|
||||
{
|
||||
INT res = wvsnprintfW( buffer, 1024, spec, args );
|
||||
return ( res == -1 ) ? 1024 : res;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* wsprintfA (USER32.@)
|
||||
*/
|
||||
INT WINAPIV wsprintfA( LPSTR buffer, LPCSTR spec, ... )
|
||||
{
|
||||
__ms_va_list valist;
|
||||
INT res;
|
||||
|
||||
__ms_va_start( valist, spec );
|
||||
res = wvsnprintfA( buffer, 1024, spec, valist );
|
||||
__ms_va_end( valist );
|
||||
return ( res == -1 ) ? 1024 : res;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* wsprintfW (USER32.@)
|
||||
*/
|
||||
INT WINAPIV wsprintfW( LPWSTR buffer, LPCWSTR spec, ... )
|
||||
{
|
||||
__ms_va_list valist;
|
||||
INT res;
|
||||
|
||||
__ms_va_start( valist, spec );
|
||||
res = wvsnprintfW( buffer, 1024, spec, valist );
|
||||
__ms_va_end( valist );
|
||||
return ( res == -1 ) ? 1024 : res;
|
||||
}
|
|
@ -339,27 +339,11 @@ IntGetWndProc(PWND pWnd, BOOL Ansi)
|
|||
return (gcpd ? gcpd : Ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
DWORD WINAPI
|
||||
GetClassLongA(HWND hWnd, int nIndex)
|
||||
static ULONG_PTR FASTCALL
|
||||
IntGetClassLongA(PWND Wnd, PCLS Class, int nIndex)
|
||||
{
|
||||
PWND Wnd;
|
||||
PCLS Class;
|
||||
ULONG_PTR Ret = 0;
|
||||
|
||||
TRACE("%p %d\n", hWnd, nIndex);
|
||||
|
||||
Wnd = ValidateHwnd(hWnd);
|
||||
if (!Wnd)
|
||||
return 0;
|
||||
|
||||
_SEH2_TRY
|
||||
{
|
||||
Class = DesktopPtrToUser(Wnd->pcls);
|
||||
if (Class != NULL)
|
||||
{
|
||||
if (nIndex >= 0)
|
||||
{
|
||||
if (nIndex + sizeof(ULONG_PTR) < nIndex ||
|
||||
|
@ -429,42 +413,15 @@ GetClassLongA(HWND hWnd, int nIndex)
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN("Invalid class for hwnd 0x%p!\n", hWnd);
|
||||
}
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
Ret = 0;
|
||||
}
|
||||
_SEH2_END;
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
DWORD WINAPI
|
||||
GetClassLongW ( HWND hWnd, int nIndex )
|
||||
static ULONG_PTR FASTCALL
|
||||
IntGetClassLongW (PWND Wnd, PCLS Class, int nIndex)
|
||||
{
|
||||
PWND Wnd;
|
||||
PCLS Class;
|
||||
ULONG_PTR Ret = 0;
|
||||
|
||||
TRACE("%p %d\n", hWnd, nIndex);
|
||||
|
||||
Wnd = ValidateHwnd(hWnd);
|
||||
if (!Wnd)
|
||||
return 0;
|
||||
|
||||
_SEH2_TRY
|
||||
{
|
||||
Class = DesktopPtrToUser(Wnd->pcls);
|
||||
if (Class != NULL)
|
||||
{
|
||||
if (nIndex >= 0)
|
||||
{
|
||||
if (nIndex + sizeof(ULONG_PTR) < nIndex ||
|
||||
|
@ -487,7 +444,7 @@ GetClassLongW ( HWND hWnd, int nIndex )
|
|||
Ret = (ULONG_PTR)Class->cbclsExtra;
|
||||
break;
|
||||
|
||||
case GCL_HBRBACKGROUND:
|
||||
case GCLP_HBRBACKGROUND:
|
||||
Ret = (ULONG_PTR)Class->hbrBackground;
|
||||
if (Ret != 0 && Ret < 0x4000)
|
||||
Ret = (ULONG_PTR)GetSysColorBrush((ULONG)Ret - 1);
|
||||
|
@ -497,7 +454,7 @@ GetClassLongW ( HWND hWnd, int nIndex )
|
|||
Ret = (ULONG_PTR)Class->hModule;
|
||||
break;
|
||||
|
||||
case GCL_MENUNAME:
|
||||
case GCLP_MENUNAME:
|
||||
Ret = (ULONG_PTR)Class->lpszClientUnicodeMenuName;
|
||||
break;
|
||||
|
||||
|
@ -533,6 +490,51 @@ GetClassLongW ( HWND hWnd, int nIndex )
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
DWORD WINAPI
|
||||
GetClassLongA(HWND hWnd, int nIndex)
|
||||
{
|
||||
PWND Wnd;
|
||||
PCLS Class;
|
||||
ULONG_PTR Ret = 0;
|
||||
|
||||
TRACE("%p %d\n", hWnd, nIndex);
|
||||
|
||||
Wnd = ValidateHwnd(hWnd);
|
||||
if (!Wnd)
|
||||
return 0;
|
||||
|
||||
_SEH2_TRY
|
||||
{
|
||||
Class = DesktopPtrToUser(Wnd->pcls);
|
||||
if (Class != NULL)
|
||||
{
|
||||
#ifdef _WIN64
|
||||
switch (nIndex)
|
||||
{
|
||||
case GCLP_HBRBACKGROUND:
|
||||
case GCLP_HCURSOR:
|
||||
case GCLP_HICON:
|
||||
case GCLP_HICONSM:
|
||||
case GCLP_HMODULE:
|
||||
case GCLP_MENUNAME:
|
||||
case GCLP_WNDPROC:
|
||||
SetLastError(ERROR_INVALID_INDEX);
|
||||
break;
|
||||
|
||||
default:
|
||||
Ret = IntGetClassLongA(Wnd, Class, nIndex);
|
||||
break;
|
||||
}
|
||||
#else
|
||||
Ret = IntGetClassLongA(Wnd, Class, nIndex);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -541,35 +543,146 @@ GetClassLongW ( HWND hWnd, int nIndex )
|
|||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
Ret = 0;
|
||||
}
|
||||
_SEH2_END;
|
||||
|
||||
return Ret;
|
||||
return (DWORD)Ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
DWORD WINAPI
|
||||
GetClassLongW ( HWND hWnd, int nIndex )
|
||||
{
|
||||
PWND Wnd;
|
||||
PCLS Class;
|
||||
ULONG_PTR Ret = 0;
|
||||
|
||||
TRACE("%p %d\n", hWnd, nIndex);
|
||||
|
||||
Wnd = ValidateHwnd(hWnd);
|
||||
if (!Wnd)
|
||||
return 0;
|
||||
|
||||
_SEH2_TRY
|
||||
{
|
||||
Class = DesktopPtrToUser(Wnd->pcls);
|
||||
if (Class != NULL)
|
||||
{
|
||||
#ifdef _WIN64
|
||||
switch (nIndex)
|
||||
{
|
||||
case GCLP_HBRBACKGROUND:
|
||||
case GCLP_HCURSOR:
|
||||
case GCLP_HICON:
|
||||
case GCLP_HICONSM:
|
||||
case GCLP_HMODULE:
|
||||
case GCLP_MENUNAME:
|
||||
case GCLP_WNDPROC:
|
||||
SetLastError(ERROR_INVALID_INDEX);
|
||||
break;
|
||||
|
||||
default:
|
||||
Ret = IntGetClassLongW(Wnd, Class, nIndex);
|
||||
break;
|
||||
}
|
||||
#else
|
||||
Ret = IntGetClassLongW(Wnd, Class, nIndex);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN("Invalid class for hwnd 0x%p!\n", hWnd);
|
||||
}
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
Ret = 0;
|
||||
}
|
||||
_SEH2_END;
|
||||
|
||||
return (DWORD)Ret;
|
||||
}
|
||||
|
||||
#ifdef _WIN64
|
||||
/*
|
||||
* @unimplemented
|
||||
* @implemented
|
||||
*/
|
||||
ULONG_PTR
|
||||
WINAPI
|
||||
GetClassLongPtrA(HWND hWnd,
|
||||
INT nIndex)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
PWND Wnd;
|
||||
PCLS Class;
|
||||
ULONG_PTR Ret = 0;
|
||||
|
||||
TRACE("%p %d\n", hWnd, nIndex);
|
||||
|
||||
Wnd = ValidateHwnd(hWnd);
|
||||
if (!Wnd)
|
||||
return 0;
|
||||
|
||||
_SEH2_TRY
|
||||
{
|
||||
Class = DesktopPtrToUser(Wnd->pcls);
|
||||
if (Class != NULL)
|
||||
{
|
||||
Ret = IntGetClassLongA(Wnd, Class, nIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN("Invalid class for hwnd 0x%p!\n", hWnd);
|
||||
}
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
Ret = 0;
|
||||
}
|
||||
_SEH2_END;
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
* @implemented
|
||||
*/
|
||||
ULONG_PTR
|
||||
WINAPI
|
||||
GetClassLongPtrW(HWND hWnd,
|
||||
INT nIndex)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
PWND Wnd;
|
||||
PCLS Class;
|
||||
ULONG_PTR Ret = 0;
|
||||
|
||||
TRACE("%p %d\n", hWnd, nIndex);
|
||||
|
||||
Wnd = ValidateHwnd(hWnd);
|
||||
if (!Wnd)
|
||||
return 0;
|
||||
|
||||
_SEH2_TRY
|
||||
{
|
||||
Class = DesktopPtrToUser(Wnd->pcls);
|
||||
if (Class != NULL)
|
||||
{
|
||||
Ret = IntGetClassLongW(Wnd, Class, nIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN("Invalid class for hwnd 0x%p!\n", hWnd);
|
||||
}
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
Ret = 0;
|
||||
}
|
||||
_SEH2_END;
|
||||
|
||||
return Ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1173,13 +1173,21 @@ HICON WINAPI CreateIcon(
|
|||
iinfo.fIcon = TRUE;
|
||||
iinfo.xHotspot = nWidth / 2;
|
||||
iinfo.yHotspot = nHeight / 2;
|
||||
iinfo.hbmMask = CreateBitmap( nWidth, nHeight, 1, 1, lpANDbits );
|
||||
if (bPlanes * bBitsPixel > 1)
|
||||
{
|
||||
iinfo.hbmColor = CreateBitmap( nWidth, nHeight, bPlanes, bBitsPixel, lpXORbits );
|
||||
iinfo.hbmMask = CreateBitmap( nWidth, nHeight, 1, 1, lpANDbits );
|
||||
}
|
||||
else
|
||||
{
|
||||
iinfo.hbmMask = CreateBitmap( nWidth, nHeight * 2, 1, 1, lpANDbits );
|
||||
iinfo.hbmColor = NULL;
|
||||
}
|
||||
|
||||
hIcon = CreateIconIndirect( &iinfo );
|
||||
|
||||
DeleteObject( iinfo.hbmMask );
|
||||
DeleteObject( iinfo.hbmColor );
|
||||
if (iinfo.hbmColor) DeleteObject( iinfo.hbmColor );
|
||||
|
||||
return hIcon;
|
||||
}
|
||||
|
@ -1477,8 +1485,9 @@ HICON WINAPI CreateIconIndirect(PICONINFO iconinfo)
|
|||
bmpXor.bmWidth, bmpXor.bmHeight, bmpXor.bmWidthBytes,
|
||||
bmpXor.bmPlanes, bmpXor.bmBitsPixel);
|
||||
|
||||
width = bmpXor.bmWidth;
|
||||
height = bmpXor.bmHeight;
|
||||
// the size of the mask bitmap always determines the icon size!
|
||||
width = bmpAnd.bmWidth;
|
||||
height = bmpAnd.bmHeight;
|
||||
if (bmpXor.bmPlanes * bmpXor.bmBitsPixel != 1)
|
||||
{
|
||||
color = CreateBitmap( width, height, bmpXor.bmPlanes, bmpXor.bmBitsPixel, NULL );
|
||||
|
@ -2181,3 +2190,23 @@ User32SetupDefaultCursors(PVOID Arguments,
|
|||
|
||||
return(ZwCallbackReturn(&Result, sizeof(LRESULT), STATUS_SUCCESS));
|
||||
}
|
||||
|
||||
BOOL get_icon_size(HICON hIcon, SIZE *size)
|
||||
{
|
||||
ICONINFO info;
|
||||
BITMAP bitmap;
|
||||
|
||||
if (!GetIconInfo(hIcon, &info)) return FALSE;
|
||||
if (!GetObject(info.hbmMask, sizeof(bitmap), &bitmap)) return FALSE;
|
||||
|
||||
size->cx = bitmap.bmWidth;
|
||||
size->cy = bitmap.bmHeight;
|
||||
|
||||
/* Black and white icons store both the XOR and AND bitmap in hbmMask */
|
||||
if (!info.hbmColor)
|
||||
{
|
||||
size->cy /= 2;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -16,13 +16,6 @@
|
|||
#include <wine/debug.h>
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(user32);
|
||||
|
||||
#ifndef WM_SETVISIBLE
|
||||
#define WM_SETVISIBLE 9
|
||||
#endif
|
||||
#ifndef WM_QUERYDROPOBJECT
|
||||
#define WM_QUERYDROPOBJECT 0x022B
|
||||
#endif
|
||||
|
||||
LRESULT DefWndNCPaint(HWND hWnd, HRGN hRgn, BOOL Active);
|
||||
LRESULT DefWndNCCalcSize(HWND hWnd, BOOL CalcSizeStruct, RECT *Rect);
|
||||
LRESULT DefWndNCActivate(HWND hWnd, WPARAM wParam);
|
||||
|
|
|
@ -39,17 +39,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(user32);
|
|||
|
||||
#define DF_END 0x0001
|
||||
#define DF_OWNERENABLED 0x0002
|
||||
#define CW_USEDEFAULT16 ((short)0x8000)
|
||||
#define DWLP_ROS_DIALOGINFO (DWLP_USER+sizeof(ULONG_PTR))
|
||||
#define GETDLGINFO(hwnd) DIALOG_get_info(hwnd, FALSE)
|
||||
#define SETDLGINFO(hwnd, info) SetWindowLongPtrW((hwnd), DWLP_ROS_DIALOGINFO, (LONG_PTR)(info))
|
||||
#define GET_WORD(ptr) (*(WORD *)(ptr))
|
||||
#define GET_DWORD(ptr) (*(DWORD *)(ptr))
|
||||
#define MAKEINTATOMA(atom) ((LPCSTR)((ULONG_PTR)((WORD)(atom))))
|
||||
#define MAKEINTATOMW(atom) ((LPCWSTR)((ULONG_PTR)((WORD)(atom))))
|
||||
#define DIALOG_CLASS_ATOMA MAKEINTATOMA(32770) /* Dialog */
|
||||
#define DIALOG_CLASS_ATOMW MAKEINTATOMW(32770) /* Dialog */
|
||||
|
||||
void WINAPI WinPosActivateOtherWindow(HWND hwnd);
|
||||
|
||||
/* INTERNAL STRUCTS **********************************************************/
|
||||
|
@ -118,7 +112,7 @@ typedef struct
|
|||
*/
|
||||
const struct builtin_class_descr DIALOG_builtin_class =
|
||||
{
|
||||
DIALOG_CLASS_ATOMW, /* name */
|
||||
WC_DIALOG, /* name */
|
||||
CS_SAVEBITS | CS_DBLCLKS, /* style */
|
||||
(WNDPROC) DefDlgProcA, /* procA */
|
||||
(WNDPROC) DefDlgProcW, /* procW */
|
||||
|
@ -632,7 +626,7 @@ static LPCSTR DIALOG_ParseTemplate32( LPCSTR template, DLG_TEMPLATE * result )
|
|||
switch(GET_WORD(p))
|
||||
{
|
||||
case 0x0000:
|
||||
result->className = DIALOG_CLASS_ATOMW;
|
||||
result->className = WC_DIALOG;
|
||||
p++;
|
||||
break;
|
||||
case 0xffff:
|
||||
|
@ -995,6 +989,7 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate,
|
|||
if (template.style & WS_VISIBLE && !(GetWindowLongPtrW( hwnd, GWL_STYLE ) & WS_VISIBLE))
|
||||
{
|
||||
ShowWindow( hwnd, SW_SHOWNORMAL ); /* SW_SHOW doesn't always work */
|
||||
IntNotifyWinEvent(EVENT_SYSTEM_DIALOGSTART, hwnd, OBJID_WINDOW, CHILDID_SELF, 0);
|
||||
}
|
||||
return hwnd;
|
||||
}
|
||||
|
|
|
@ -66,11 +66,6 @@ static BOOL fEndMenu = FALSE;
|
|||
#define SEPARATOR_HEIGHT (5)
|
||||
#define MENU_TAB_SPACE (8)
|
||||
|
||||
#define MAKEINTATOMA(atom) ((LPCSTR)((ULONG_PTR)((WORD)(atom))))
|
||||
#define MAKEINTATOMW(atom) ((LPCWSTR)((ULONG_PTR)((WORD)(atom))))
|
||||
#define POPUPMENU_CLASS_ATOMA MAKEINTATOMA(32768) /* PopupMenu */
|
||||
#define POPUPMENU_CLASS_ATOMW MAKEINTATOMW(32768) /* PopupMenu */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT TrackFlags;
|
||||
|
@ -86,7 +81,7 @@ typedef struct
|
|||
*/
|
||||
const struct builtin_class_descr POPUPMENU_builtin_class =
|
||||
{
|
||||
POPUPMENU_CLASS_ATOMW, /* name */
|
||||
WC_MENU, /* name */
|
||||
CS_SAVEBITS | CS_DBLCLKS, /* style */
|
||||
(WNDPROC) NULL, /* FIXME - procA */
|
||||
(WNDPROC) PopupMenuWndProcW, /* FIXME - procW */
|
||||
|
@ -1626,7 +1621,7 @@ static BOOL FASTCALL MenuShowPopup(HWND hwndOwner, HMENU hmenu, UINT id, UINT fl
|
|||
if( y < info.rcMonitor.top ) y = info.rcMonitor.top;
|
||||
|
||||
/* NOTE: In Windows, top menu popup is not owned. */
|
||||
MenuInfo.Wnd = CreateWindowExW( 0, POPUPMENU_CLASS_ATOMW, NULL,
|
||||
MenuInfo.Wnd = CreateWindowExW( 0, WC_MENU, NULL,
|
||||
WS_POPUP, x, y, width, height,
|
||||
hwndOwner, 0, (HINSTANCE) GetWindowLongPtrW(hwndOwner, GWLP_HINSTANCE),
|
||||
(LPVOID) MenuInfo.Self);
|
||||
|
|
|
@ -18,8 +18,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(user32);
|
|||
LRESULT DefWndNCPaint(HWND hWnd, HRGN hRgn, BOOL Active);
|
||||
void MDI_CalcDefaultChildPos( HWND hwndClient, INT total, LPPOINT lpPos, INT delta, UINT *id );
|
||||
|
||||
#define CW_USEDEFAULT16 0x00008000
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@ NpfsQueryDirectory(PNPFS_CCB Ccb,
|
|||
PFILE_DIRECTORY_INFORMATION DirectoryBuffer;
|
||||
PFILE_FULL_DIR_INFORMATION FullDirBuffer;
|
||||
PFILE_BOTH_DIR_INFORMATION BothDirBuffer;
|
||||
ULONG InfoSize = 0;
|
||||
ULONG NameLength;
|
||||
|
||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
|
||||
|
@ -109,11 +111,36 @@ NpfsQueryDirectory(PNPFS_CCB Ccb,
|
|||
|
||||
DPRINT("Buffer = %p tofind = %wZ\n", Buffer, &Ccb->u.Directory.SearchPattern);
|
||||
|
||||
switch (FileInformationClass)
|
||||
{
|
||||
case FileDirectoryInformation:
|
||||
InfoSize = sizeof(FILE_DIRECTORY_INFORMATION) - sizeof(WCHAR);
|
||||
break;
|
||||
|
||||
case FileFullDirectoryInformation:
|
||||
InfoSize = sizeof(FILE_FULL_DIR_INFORMATION) - sizeof(WCHAR);
|
||||
break;
|
||||
|
||||
case FileBothDirectoryInformation:
|
||||
InfoSize = sizeof(FILE_BOTH_DIR_INFORMATION) - sizeof(WCHAR);
|
||||
break;
|
||||
|
||||
case FileNamesInformation:
|
||||
InfoSize = sizeof(FILE_NAMES_INFORMATION) - sizeof(WCHAR);
|
||||
break;
|
||||
|
||||
default:
|
||||
DPRINT1("Invalid information class: %lu\n", FileInformationClass);
|
||||
return STATUS_INVALID_INFO_CLASS;
|
||||
}
|
||||
|
||||
PipeIndex = 0;
|
||||
|
||||
Vcb = Ccb->Fcb->Vcb;
|
||||
CurrentEntry = Vcb->PipeListHead.Flink;
|
||||
while (CurrentEntry != &Vcb->PipeListHead && Found == FALSE)
|
||||
while (CurrentEntry != &Vcb->PipeListHead &&
|
||||
Found == FALSE &&
|
||||
Status == STATUS_SUCCESS)
|
||||
{
|
||||
/* Get the FCB of the next pipe */
|
||||
PipeFcb = CONTAINING_RECORD(CurrentEntry,
|
||||
|
@ -134,7 +161,20 @@ NpfsQueryDirectory(PNPFS_CCB Ccb,
|
|||
|
||||
if (PipeIndex >= FileIndex)
|
||||
{
|
||||
RtlZeroMemory(Buffer, BufferLength);
|
||||
/* Determine whether or not the full pipe name fits into the buffer */
|
||||
if (InfoSize + PipeFcb->PipeName.Length > BufferLength)
|
||||
{
|
||||
NameLength = BufferLength - InfoSize;
|
||||
Status = STATUS_BUFFER_OVERFLOW;
|
||||
}
|
||||
else
|
||||
{
|
||||
NameLength = PipeFcb->PipeName.Length;
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* Initialize the information struct */
|
||||
RtlZeroMemory(Buffer, InfoSize);
|
||||
|
||||
switch (FileInformationClass)
|
||||
{
|
||||
|
@ -145,12 +185,10 @@ NpfsQueryDirectory(PNPFS_CCB Ccb,
|
|||
DirectoryBuffer->FileAttributes = FILE_ATTRIBUTE_NORMAL;
|
||||
DirectoryBuffer->EndOfFile.QuadPart = PipeFcb->CurrentInstances;
|
||||
DirectoryBuffer->AllocationSize.LowPart = PipeFcb->MaximumInstances;
|
||||
DirectoryBuffer->FileNameLength = PipeFcb->PipeName.Length;
|
||||
DirectoryBuffer->FileNameLength = NameLength;
|
||||
RtlCopyMemory(DirectoryBuffer->FileName,
|
||||
PipeFcb->PipeName.Buffer,
|
||||
PipeFcb->PipeName.Length);
|
||||
*Size = sizeof(FILE_DIRECTORY_INFORMATION) + PipeFcb->PipeName.Length - sizeof(WCHAR);
|
||||
Status = STATUS_SUCCESS;
|
||||
NameLength);
|
||||
break;
|
||||
|
||||
case FileFullDirectoryInformation:
|
||||
|
@ -160,12 +198,10 @@ NpfsQueryDirectory(PNPFS_CCB Ccb,
|
|||
FullDirBuffer->FileAttributes = FILE_ATTRIBUTE_NORMAL;
|
||||
FullDirBuffer->EndOfFile.QuadPart = PipeFcb->CurrentInstances;
|
||||
FullDirBuffer->AllocationSize.LowPart = PipeFcb->MaximumInstances;
|
||||
FullDirBuffer->FileNameLength = PipeFcb->PipeName.Length;
|
||||
FullDirBuffer->FileNameLength = NameLength;
|
||||
RtlCopyMemory(FullDirBuffer->FileName,
|
||||
PipeFcb->PipeName.Buffer,
|
||||
PipeFcb->PipeName.Length);
|
||||
*Size = sizeof(FILE_FULL_DIR_INFORMATION) + PipeFcb->PipeName.Length - sizeof(WCHAR);
|
||||
Status = STATUS_SUCCESS;
|
||||
NameLength);
|
||||
break;
|
||||
|
||||
case FileBothDirectoryInformation:
|
||||
|
@ -175,32 +211,30 @@ NpfsQueryDirectory(PNPFS_CCB Ccb,
|
|||
BothDirBuffer->FileAttributes = FILE_ATTRIBUTE_NORMAL;
|
||||
BothDirBuffer->EndOfFile.QuadPart = PipeFcb->CurrentInstances;
|
||||
BothDirBuffer->AllocationSize.LowPart = PipeFcb->MaximumInstances;
|
||||
BothDirBuffer->FileNameLength = PipeFcb->PipeName.Length;
|
||||
BothDirBuffer->FileNameLength = NameLength;
|
||||
RtlCopyMemory(BothDirBuffer->FileName,
|
||||
PipeFcb->PipeName.Buffer,
|
||||
PipeFcb->PipeName.Length);
|
||||
*Size = sizeof(FILE_BOTH_DIR_INFORMATION) + PipeFcb->PipeName.Length - sizeof(WCHAR);
|
||||
Status = STATUS_SUCCESS;
|
||||
NameLength);
|
||||
break;
|
||||
|
||||
case FileNamesInformation:
|
||||
NamesBuffer = (PFILE_NAMES_INFORMATION)Buffer;
|
||||
NamesBuffer->NextEntryOffset = 0;
|
||||
NamesBuffer->FileIndex = PipeIndex;
|
||||
NamesBuffer->FileNameLength = PipeFcb->PipeName.Length;
|
||||
NamesBuffer->FileNameLength = NameLength;
|
||||
RtlCopyMemory(NamesBuffer->FileName,
|
||||
PipeFcb->PipeName.Buffer,
|
||||
PipeFcb->PipeName.Length);
|
||||
*Size = sizeof(FILE_NAMES_INFORMATION) + PipeFcb->PipeName.Length - sizeof(WCHAR);
|
||||
Status = STATUS_SUCCESS;
|
||||
NameLength);
|
||||
break;
|
||||
|
||||
default:
|
||||
DPRINT1("Invalid information class: %lu\n", FileInformationClass);
|
||||
Status = STATUS_INVALID_INFO_CLASS;
|
||||
/* Should never happen! */
|
||||
ASSERT(FALSE);
|
||||
break;
|
||||
}
|
||||
|
||||
*Size = InfoSize + NameLength;
|
||||
|
||||
Ccb->u.Directory.FileIndex = PipeIndex;
|
||||
Found = TRUE;
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ EhciDefferedRoutine(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVO
|
|||
DPRINT("Asyn Complete!\n");
|
||||
ULONG CurrentAddr, OffSet;
|
||||
PQUEUE_HEAD CompletedQH, NextQH;
|
||||
PQUEUE_TRANSFER_DESCRIPTOR CompletedTD;
|
||||
PQUEUE_TRANSFER_DESCRIPTOR CompletedTD, NextTD;
|
||||
|
||||
/* AsyncListAddr Register will have the next QueueHead to execute */
|
||||
CurrentAddr = GetAsyncListQueueRegister(hcd);
|
||||
|
@ -64,14 +64,13 @@ EhciDefferedRoutine(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVO
|
|||
|
||||
/* Free memory for the Descriptors */
|
||||
CompletedTD = CompletedQH->TransferDescriptor;
|
||||
//DumpTransferDescriptor(CompletedTD);
|
||||
FreeDescriptor(CompletedTD);
|
||||
CompletedTD = CompletedTD->NextDescriptor;
|
||||
//DumpTransferDescriptor(CompletedTD);
|
||||
FreeDescriptor(CompletedTD);
|
||||
CompletedTD = CompletedTD->NextDescriptor;
|
||||
//DumpTransferDescriptor(CompletedTD);
|
||||
NextTD = CompletedTD;
|
||||
while (NextTD)
|
||||
{
|
||||
CompletedTD = NextTD;
|
||||
NextTD = NextTD->NextDescriptor;
|
||||
FreeDescriptor(CompletedTD);
|
||||
}
|
||||
|
||||
/* If the Event is set then release waiter */
|
||||
if (CompletedQH->Event)
|
||||
|
@ -79,27 +78,25 @@ EhciDefferedRoutine(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVO
|
|||
KeSetEvent(CompletedQH->Event, IO_NO_INCREMENT, FALSE);
|
||||
}
|
||||
|
||||
/* Free the Mdl */
|
||||
ASSERT(CompletedQH->MdlToFree);
|
||||
/* Free the Mdl if there was one */
|
||||
if(CompletedQH->MdlToFree)
|
||||
IoFreeMdl(CompletedQH->MdlToFree);
|
||||
|
||||
/* Is there an IRP that needs to be completed */
|
||||
if (CompletedQH->IrpToComplete)
|
||||
{
|
||||
PIRP Irp;
|
||||
PIO_STACK_LOCATION Stack;
|
||||
PURB Urb;
|
||||
|
||||
Irp = CompletedQH->IrpToComplete;
|
||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
ASSERT(Stack);
|
||||
Urb = (PURB) Stack->Parameters.Others.Argument1;
|
||||
|
||||
/* Check for error */
|
||||
if (CStatus & EHCI_ERROR_INT)
|
||||
{
|
||||
PIO_STACK_LOCATION Stack;
|
||||
PURB Urb;
|
||||
|
||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
ASSERT(Stack);
|
||||
Urb = (PURB) Stack->Parameters.Others.Argument1;
|
||||
ASSERT(FALSE);
|
||||
/* Haled bit should be set */
|
||||
if (CompletedQH->Token.Bits.Halted)
|
||||
{
|
||||
|
|
|
@ -139,20 +139,21 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp)
|
|||
}
|
||||
}
|
||||
else
|
||||
DPRINT("Interrupt Transfer not for hub\n");
|
||||
DPRINT1("Interrupt Transfer not for hub\n");
|
||||
break;
|
||||
}
|
||||
case URB_FUNCTION_GET_STATUS_FROM_DEVICE:
|
||||
{
|
||||
DPRINT1("URB_FUNCTION_GET_STATUS_FROM_DEVICE\n");
|
||||
if (Urb->UrbControlGetStatusRequest.Index == 0)
|
||||
/* If for the hub device */
|
||||
if ((Urb->UrbControlGetStatusRequest.Index == 0) && (UsbDevice == PdoDeviceExtension->UsbDevices[0]))
|
||||
{
|
||||
ASSERT(Urb->UrbBulkOrInterruptTransfer.TransferBuffer != NULL);
|
||||
*(PUSHORT)Urb->UrbControlGetStatusRequest.TransferBuffer = USB_PORT_STATUS_CONNECT | USB_PORT_STATUS_ENABLE;
|
||||
*(PUSHORT)Urb->UrbControlGetStatusRequest.TransferBuffer = USB_PORT_STATUS_CONNECT /*| USB_PORT_STATUS_ENABLE*/;
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT1("Uknown identifier\n");
|
||||
DPRINT1("UsbDeviceHandle %x, Index %x not implemented yet\n", UsbDevice, Urb->UrbControlGetStatusRequest.Index);
|
||||
Urb->UrbHeader.Status = USBD_STATUS_INVALID_URB_FUNCTION;
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
@ -189,15 +190,14 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp)
|
|||
|
||||
ASSERT(Urb->UrbControlDescriptorRequest.TransferBuffer != NULL);
|
||||
|
||||
DPRINT("Calling BuildSetUpPacketFromUrb\n");
|
||||
BuildSetupPacketFromURB(&FdoDeviceExtension->hcd, Urb, &CtrlSetup);
|
||||
DPRINT("SubmitControlTransfer\n");
|
||||
IoMarkIrpPending(Irp);
|
||||
Status = STATUS_PENDING;
|
||||
SubmitControlTransfer(&FdoDeviceExtension->hcd,
|
||||
&CtrlSetup,
|
||||
Urb->UrbControlDescriptorRequest.TransferBuffer,
|
||||
Urb->UrbControlDescriptorRequest.TransferBufferLength,
|
||||
Irp);
|
||||
|
||||
break;
|
||||
}
|
||||
case USB_CONFIGURATION_DESCRIPTOR_TYPE:
|
||||
|
@ -267,24 +267,15 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp)
|
|||
if (Urb->UrbControlDescriptorRequest.Index == 0)
|
||||
DPRINT1("Requesting LANGID's\n");
|
||||
|
||||
CtrlSetup.bmRequestType._BM.Recipient = BMREQUEST_TO_DEVICE;
|
||||
CtrlSetup.bmRequestType._BM.Type = BMREQUEST_STANDARD;
|
||||
CtrlSetup.bmRequestType._BM.Reserved = 0;
|
||||
CtrlSetup.bmRequestType._BM.Dir = BMREQUEST_DEVICE_TO_HOST;
|
||||
CtrlSetup.bRequest = USB_REQUEST_GET_DESCRIPTOR;
|
||||
CtrlSetup.wValue.LowByte = Urb->UrbControlDescriptorRequest.Index;
|
||||
CtrlSetup.wValue.HiByte = Urb->UrbControlDescriptorRequest.DescriptorType;
|
||||
CtrlSetup.wIndex.W = Urb->UrbControlDescriptorRequest.LanguageId;
|
||||
CtrlSetup.wLength = Urb->UrbControlDescriptorRequest.TransferBufferLength;
|
||||
BuildSetupPacketFromURB(&FdoDeviceExtension->hcd, Urb, &CtrlSetup);
|
||||
IoMarkIrpPending(Irp);
|
||||
Status = STATUS_PENDING;
|
||||
|
||||
SubmitControlTransfer(&FdoDeviceExtension->hcd,
|
||||
&CtrlSetup,
|
||||
Urb->UrbControlDescriptorRequest.TransferBuffer,
|
||||
Urb->UrbControlDescriptorRequest.TransferBufferLength,
|
||||
Irp);
|
||||
|
||||
IoMarkIrpPending(Irp);
|
||||
Status = STATUS_PENDING;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -301,11 +292,11 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp)
|
|||
|
||||
DPRINT1("Selecting Configuration\n");
|
||||
DPRINT1("ConfigurationHandle %x\n",Urb->UrbSelectConfiguration.ConfigurationHandle);
|
||||
|
||||
if (Urb->UrbSelectConfiguration.ConfigurationDescriptor)
|
||||
{
|
||||
Urb->UrbSelectConfiguration.ConfigurationHandle = (PVOID)&PdoDeviceExtension->UsbDevices[0]->ActiveConfig->ConfigurationDescriptor;
|
||||
DPRINT("ConfigHandle %x\n", Urb->UrbSelectConfiguration.ConfigurationHandle);
|
||||
Urb->UrbSelectConfiguration.ConfigurationHandle = &UsbDevice->ActiveConfig->ConfigurationDescriptor;
|
||||
DPRINT1("ConfigHandle %x\n", Urb->UrbSelectConfiguration.ConfigurationHandle);
|
||||
ASSERT(FALSE);
|
||||
InterfaceInfo = &Urb->UrbSelectConfiguration.Interface;
|
||||
|
||||
DPRINT1("Length %x\n", InterfaceInfo->Length);
|
||||
|
@ -324,7 +315,7 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp)
|
|||
InterfaceInfo->Pipes[pCount].MaximumPacketSize = UsbDevice->ActiveInterface->EndPoints[pCount]->EndPointDescriptor.wMaxPacketSize;
|
||||
InterfaceInfo->Pipes[pCount].EndpointAddress = UsbDevice->ActiveInterface->EndPoints[pCount]->EndPointDescriptor.bEndpointAddress;
|
||||
InterfaceInfo->Pipes[pCount].Interval = UsbDevice->ActiveInterface->EndPoints[pCount]->EndPointDescriptor.bInterval;
|
||||
InterfaceInfo->Pipes[pCount].PipeType = UsbdPipeTypeInterrupt;
|
||||
InterfaceInfo->Pipes[pCount].PipeType = UsbDevice->ActiveInterface->EndPoints[pCount]->EndPointDescriptor.bmAttributes;
|
||||
InterfaceInfo->Pipes[pCount].PipeHandle = (PVOID)&UsbDevice->ActiveInterface->EndPoints[pCount]->EndPointDescriptor;
|
||||
if (InterfaceInfo->Pipes[pCount].MaximumTransferSize == 0)
|
||||
InterfaceInfo->Pipes[pCount].MaximumTransferSize = 4096;
|
||||
|
@ -337,9 +328,39 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp)
|
|||
else
|
||||
{
|
||||
/* FIXME: Set device to unconfigured state */
|
||||
DPRINT1("Setting device to unconfigured state not implemented!\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case URB_FUNCTION_SELECT_INTERFACE:
|
||||
{
|
||||
USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup;
|
||||
PUSBD_INTERFACE_INFORMATION InterfaceInfo;
|
||||
int i;
|
||||
|
||||
DPRINT1("Select Interface!\n");
|
||||
DPRINT1("Config Handle %x\n", Urb->UrbSelectInterface.ConfigurationHandle);
|
||||
|
||||
InterfaceInfo = &Urb->UrbSelectInterface.Interface;
|
||||
DPRINT1("InterfaceNumber %x\n", InterfaceInfo->InterfaceNumber);
|
||||
DPRINT1("AlternateSetting %x\n", InterfaceInfo->AlternateSetting);
|
||||
DPRINT1("NumPipes %x\n", InterfaceInfo->NumberOfPipes);
|
||||
for (i=0;i<InterfaceInfo->NumberOfPipes;i++)
|
||||
{
|
||||
InterfaceInfo->Pipes[i].PipeHandle = (PVOID)&UsbDevice->ActiveInterface->EndPoints[i]->EndPointDescriptor;
|
||||
}
|
||||
|
||||
BuildSetupPacketFromURB(&FdoDeviceExtension->hcd, Urb, &CtrlSetup);
|
||||
IoMarkIrpPending(Irp);
|
||||
Status = STATUS_PENDING;
|
||||
|
||||
SubmitControlTransfer(&FdoDeviceExtension->hcd,
|
||||
&CtrlSetup,
|
||||
NULL,
|
||||
0,
|
||||
Irp);
|
||||
break;
|
||||
}
|
||||
case URB_FUNCTION_CLASS_DEVICE:
|
||||
{
|
||||
DPRINT1("URB_FUNCTION_CLASS_DEVICE\n");
|
||||
|
@ -456,7 +477,7 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp)
|
|||
{
|
||||
case USB_REQUEST_GET_STATUS:
|
||||
{
|
||||
DPRINT1("USB_REQUEST_GET_STATUS Port %d\n", Urb->UrbControlVendorClassRequest.Index);
|
||||
DPRINT("USB_REQUEST_GET_STATUS Port %d\n", Urb->UrbControlVendorClassRequest.Index);
|
||||
|
||||
ASSERT(Urb->UrbControlVendorClassRequest.TransferBuffer != 0);
|
||||
DPRINT("PortStatus %x\n", PdoDeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortStatus);
|
||||
|
@ -467,23 +488,21 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp)
|
|||
}
|
||||
case USB_REQUEST_CLEAR_FEATURE:
|
||||
{
|
||||
DPRINT1("USB_REQUEST_CLEAR_FEATURE Port %d, value %x\n", Urb->UrbControlVendorClassRequest.Index,
|
||||
Urb->UrbControlVendorClassRequest.Value);
|
||||
switch (Urb->UrbControlVendorClassRequest.Value)
|
||||
{
|
||||
case C_PORT_CONNECTION:
|
||||
DPRINT1("C_PORT_CONNECTION\n");
|
||||
DPRINT("C_PORT_CONNECTION\n");
|
||||
PdoDeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange &= ~USB_PORT_STATUS_CONNECT;
|
||||
break;
|
||||
case C_PORT_RESET:
|
||||
DPRINT1("C_PORT_RESET\n");
|
||||
DPRINT("C_PORT_RESET\n");
|
||||
PdoDeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange &= ~USB_PORT_STATUS_RESET;
|
||||
PdoDeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortStatus |= USB_PORT_STATUS_ENABLE;
|
||||
break;
|
||||
default:
|
||||
DPRINT1("Unknown Value for Clear Feature %x \n", Urb->UrbControlVendorClassRequest.Value);
|
||||
DPRINT("Unknown Value for Clear Feature %x \n", Urb->UrbControlVendorClassRequest.Value);
|
||||
break;
|
||||
}
|
||||
CompletePendingURBRequest(PdoDeviceExtension);
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_SET_FEATURE:
|
||||
|
@ -495,18 +514,10 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp)
|
|||
{
|
||||
case PORT_RESET:
|
||||
{
|
||||
//PWORKITEMDATA WorkItemData;
|
||||
|
||||
PdoDeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortStatus |= USB_PORT_STATUS_ENABLE;
|
||||
DPRINT("Port Reset %d\n", Urb->UrbControlVendorClassRequest.Index-1);
|
||||
PdoDeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange |= USB_PORT_STATUS_RESET;
|
||||
|
||||
PdoDeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortStatus &= ~USB_PORT_STATUS_ENABLE;
|
||||
ResetPort(&FdoDeviceExtension->hcd, Urb->UrbControlVendorClassRequest.Index-1);
|
||||
//WorkItemData = ExAllocatePool(NonPagedPool, sizeof(WORKITEMDATA));
|
||||
//WorkItemData->Context = PdoDeviceExtension;
|
||||
//ExInitializeWorkItem(&WorkItemData->WorkItem, (PWORKER_THREAD_ROUTINE)WorkerThread, (PVOID) WorkItemData)
|
||||
//ExQueueWorkItem(&WorkItemData->WorkItem, DelayedWorkQueue);
|
||||
//IoMarkIrpPending(Irp);
|
||||
//Status = STATUS_PENDING;
|
||||
break;
|
||||
}
|
||||
case PORT_ENABLE:
|
||||
|
@ -525,7 +536,10 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(PdoDeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortStatus & 0x8000))
|
||||
CompletePendingURBRequest(PdoDeviceExtension);
|
||||
|
||||
break;
|
||||
}
|
||||
case USB_REQUEST_SET_ADDRESS:
|
||||
|
@ -577,6 +591,23 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case URB_FUNCTION_CONTROL_TRANSFER:
|
||||
{
|
||||
DPRINT1("URB_FUNCTION_CONTROL_TRANSFER\n");
|
||||
DPRINT1("PipeHandle %x\n", Urb->UrbControlTransfer.PipeHandle);
|
||||
DPRINT1("TransferFlags %x\n", Urb->UrbControlTransfer.TransferFlags);
|
||||
DPRINT1("TransferLength %x\n", Urb->UrbControlTransfer.TransferBufferLength);
|
||||
DPRINT1("TransferBuffer %x\n", Urb->UrbControlTransfer.TransferBuffer);
|
||||
DPRINT1("TransferMDL %x\n", Urb->UrbControlTransfer.TransferBufferMDL);
|
||||
DPRINT1("SetupPacket %x\n", Urb->UrbControlTransfer.SetupPacket);
|
||||
ASSERT(FALSE);
|
||||
break;
|
||||
}
|
||||
case URB_FUNCTION_CLASS_INTERFACE:
|
||||
{
|
||||
DPRINT1("URB_FUNCTION_CLASS_INTERFACE\n");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DPRINT1("Unhandled URB %x\n", Urb->UrbHeader.Function);
|
||||
|
@ -586,14 +617,6 @@ NTSTATUS HandleUrbRequest(PPDO_DEVICE_EXTENSION PdoDeviceExtension, PIRP Irp)
|
|||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = Information;
|
||||
|
||||
if (Urb->UrbHeader.Status == USBD_STATUS_SUCCESS)
|
||||
{
|
||||
/* Fake a successful Control Transfer */
|
||||
Urb->UrbHeader.Function = 0x08;
|
||||
Urb->UrbHeader.UsbdFlags = 0;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -606,23 +629,25 @@ CompletePendingURBRequest(PPDO_DEVICE_EXTENSION DeviceExtension)
|
|||
|
||||
KeAcquireSpinLock(&DeviceExtension->IrpQueueLock, &oldIrql);
|
||||
|
||||
while (!IsListEmpty(&DeviceExtension->IrpQueue))
|
||||
if (IsListEmpty(&DeviceExtension->IrpQueue))
|
||||
{
|
||||
DPRINT1("There should have been one SCE request pending\n");
|
||||
KeReleaseSpinLock(&DeviceExtension->IrpQueueLock, oldIrql);
|
||||
return;
|
||||
}
|
||||
NextIrp = RemoveHeadList(&DeviceExtension->IrpQueue);
|
||||
Irp = CONTAINING_RECORD(NextIrp, IRP, Tail.Overlay.ListEntry);
|
||||
|
||||
if (!Irp)
|
||||
{
|
||||
DPRINT1("No IRP\n");
|
||||
break;
|
||||
DPRINT1("No Irp\n");
|
||||
return;
|
||||
}
|
||||
|
||||
IoSetCancelRoutine(Irp, NULL);
|
||||
KeReleaseSpinLock(&DeviceExtension->IrpQueueLock, oldIrql);
|
||||
|
||||
HandleUrbRequest(DeviceExtension, Irp);
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
KeAcquireSpinLock(&DeviceExtension->IrpQueueLock, &oldIrql);
|
||||
}
|
||||
|
||||
KeReleaseSpinLock(&DeviceExtension->IrpQueueLock, oldIrql);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ AllocateMemory(PEHCI_HOST_CONTROLLER hcd, ULONG Size, ULONG *PhysicalAddress)
|
|||
|
||||
Size = ((Size + SMALL_ALLOCATION_SIZE - 1) / SMALL_ALLOCATION_SIZE) * SMALL_ALLOCATION_SIZE;
|
||||
BlocksNeeded = Size / SMALL_ALLOCATION_SIZE;
|
||||
|
||||
do
|
||||
{
|
||||
if (MemoryPage->IsFull)
|
||||
|
@ -52,6 +51,11 @@ AllocateMemory(PEHCI_HOST_CONTROLLER hcd, ULONG Size, ULONG *PhysicalAddress)
|
|||
freeCount = 0;
|
||||
}
|
||||
|
||||
if ((i-freeCount+1 + BlocksNeeded) > sizeof(MemoryPage->Entry))
|
||||
{
|
||||
freeCount = 0;
|
||||
continue;
|
||||
}
|
||||
if (freeCount == BlocksNeeded)
|
||||
{
|
||||
for (j = 0; j < freeCount; j++)
|
||||
|
@ -80,13 +84,13 @@ VOID
|
|||
ReleaseMemory(ULONG Address)
|
||||
{
|
||||
PMEM_HEADER MemoryPage;
|
||||
ULONG Index, i;
|
||||
ULONG Index, i, BlockSize;
|
||||
|
||||
MemoryPage = (PMEM_HEADER)(Address & ~(PAGE_SIZE - 1));
|
||||
|
||||
Index = (Address - ((ULONG)MemoryPage + sizeof(MEM_HEADER))) / SMALL_ALLOCATION_SIZE;
|
||||
|
||||
for (i = 0; i < MemoryPage->Entry[Index].Blocks; i++)
|
||||
BlockSize = MemoryPage->Entry[Index].Blocks;
|
||||
for (i = 0; i < BlockSize; i++)
|
||||
{
|
||||
MemoryPage->Entry[Index + i].InUse = 0;
|
||||
MemoryPage->Entry[Index + i].Blocks = 0;
|
||||
|
|
|
@ -11,7 +11,8 @@ typedef struct _MEM_ENTRY
|
|||
typedef struct _MEM_HEADER
|
||||
{
|
||||
UCHAR IsFull;
|
||||
MEM_ENTRY Entry[127];
|
||||
MEM_ENTRY Entry[124];
|
||||
UCHAR Reserved[3];
|
||||
} MEM_HEADER, *PMEM_HEADER;
|
||||
|
||||
VOID
|
||||
|
|
|
@ -77,6 +77,9 @@ BuildSetupPacketFromURB(PEHCI_HOST_CONTROLLER hcd, PURB Urb, PUSB_DEFAULT_PIPE_S
|
|||
/* SET CONFIG */
|
||||
case URB_FUNCTION_SELECT_CONFIGURATION:
|
||||
CtrlSetup->bRequest = USB_REQUEST_SET_CONFIGURATION;
|
||||
CtrlSetup->wValue.W = Urb->UrbSelectConfiguration.ConfigurationDescriptor->bConfigurationValue;
|
||||
CtrlSetup->wIndex.W = 0;
|
||||
CtrlSetup->wLength = 0;
|
||||
CtrlSetup->bmRequestType.B = 0x00;
|
||||
break;
|
||||
|
||||
|
@ -111,7 +114,11 @@ BuildSetupPacketFromURB(PEHCI_HOST_CONTROLLER hcd, PURB Urb, PUSB_DEFAULT_PIPE_S
|
|||
|
||||
/* SET INTERFACE*/
|
||||
case URB_FUNCTION_SELECT_INTERFACE:
|
||||
DPRINT1("Not implemented\n");
|
||||
CtrlSetup->bRequest = USB_REQUEST_SET_INTERFACE;
|
||||
CtrlSetup->wValue.W = Urb->UrbSelectInterface.Interface.AlternateSetting;
|
||||
CtrlSetup->wIndex.W = Urb->UrbSelectInterface.Interface.InterfaceNumber;
|
||||
CtrlSetup->wLength = 0;
|
||||
CtrlSetup->bmRequestType.B = 0x01;
|
||||
break;
|
||||
|
||||
/* SYNC FRAME */
|
||||
|
@ -150,6 +157,8 @@ SubmitControlTransfer(PEHCI_HOST_CONTROLLER hcd,
|
|||
KeInitializeEvent(Event, NotificationEvent, FALSE);
|
||||
}
|
||||
|
||||
if (TransferBuffer)
|
||||
{
|
||||
/* Allocate Mdl for Buffer */
|
||||
pMdl = IoAllocateMdl(TransferBuffer,
|
||||
TransferBufferLength,
|
||||
|
@ -162,6 +171,7 @@ SubmitControlTransfer(PEHCI_HOST_CONTROLLER hcd,
|
|||
//MmProbeAndLockPages(pMdl, KernelMode, IoReadAccess);
|
||||
|
||||
MdlPhysicalAddr = MmGetPhysicalAddress((PVOID)TransferBuffer).LowPart;
|
||||
}
|
||||
|
||||
QueueHead = CreateQueueHead(hcd);
|
||||
|
||||
|
@ -175,9 +185,12 @@ SubmitControlTransfer(PEHCI_HOST_CONTROLLER hcd,
|
|||
/* Save the first descriptor */
|
||||
QueueHead->TransferDescriptor = Descriptor[0];
|
||||
|
||||
if (TransferBuffer)
|
||||
{
|
||||
Descriptor[1] = CreateDescriptor(hcd,
|
||||
PID_CODE_IN_TOKEN,
|
||||
TransferBufferLength);
|
||||
}
|
||||
|
||||
Descriptor[2] = CreateDescriptor(hcd,
|
||||
PID_CODE_OUT_TOKEN,
|
||||
|
@ -186,17 +199,34 @@ SubmitControlTransfer(PEHCI_HOST_CONTROLLER hcd,
|
|||
Descriptor[1]->Token.Bits.InterruptOnComplete = FALSE;
|
||||
|
||||
/* Link the descriptors */
|
||||
|
||||
if (TransferBuffer)
|
||||
{
|
||||
Descriptor[0]->NextDescriptor = Descriptor[1];
|
||||
Descriptor[1]->NextDescriptor = Descriptor[2];
|
||||
Descriptor[1]->PreviousDescriptor = Descriptor[0];
|
||||
Descriptor[2]->PreviousDescriptor = Descriptor[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
Descriptor[0]->NextDescriptor = Descriptor[2];
|
||||
Descriptor[2]->PreviousDescriptor = Descriptor[0];
|
||||
}
|
||||
|
||||
/* Assign the descritors buffers */
|
||||
Descriptor[0]->BufferPointer[0] = (ULONG)CtrlPhysicalPA;
|
||||
Descriptor[1]->BufferPointer[0] = MdlPhysicalAddr;
|
||||
|
||||
if (TransferBuffer)
|
||||
{
|
||||
Descriptor[1]->BufferPointer[0] = MdlPhysicalAddr;
|
||||
Descriptor[0]->NextPointer = Descriptor[1]->PhysicalAddr;
|
||||
Descriptor[1]->NextPointer = Descriptor[2]->PhysicalAddr;
|
||||
}
|
||||
else
|
||||
{
|
||||
Descriptor[0]->NextPointer = Descriptor[2]->PhysicalAddr;
|
||||
}
|
||||
|
||||
QueueHead->NextPointer = Descriptor[0]->PhysicalAddr;
|
||||
|
||||
QueueHead->IrpToComplete = IrpToComplete;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#define DEVICEBUSY 0x04
|
||||
#define DEVICESTOPPED 0x08
|
||||
#define DEVICESTALLED 0x10
|
||||
#define DEVICEREMOVED 0x20
|
||||
|
||||
|
||||
#define MAX_USB_DEVICES 127
|
||||
|
@ -71,6 +72,8 @@ typedef struct _USB_DEVICE
|
|||
BOOLEAN IsHub;
|
||||
USB_DEVICE_SPEED DeviceSpeed;
|
||||
USB_DEVICE_TYPE DeviceType;
|
||||
ULONG DeviceState;
|
||||
PDEVICE_OBJECT UsbDevicePdo;
|
||||
USB_DEVICE_DESCRIPTOR DeviceDescriptor;
|
||||
UNICODE_STRING LanguageIDs;
|
||||
UNICODE_STRING iManufacturer;
|
||||
|
|
|
@ -223,14 +223,13 @@ InitializeUsbDevice(PVOID BusContext, PUSB_DEVICE_HANDLE DeviceHandle)
|
|||
UsbDevice->Configs[i]->Interfaces[j]->EndPoints[k] = ExAllocatePoolWithTag(NonPagedPool, sizeof(USB_ENDPOINT), USB_POOL_TAG);
|
||||
RtlCopyMemory(&UsbDevice->Configs[i]->Interfaces[j]->EndPoints[k]->EndPointDescriptor,
|
||||
EndpointDesc, sizeof(USB_ENDPOINT_DESCRIPTOR));
|
||||
Ptr += sizeof(USB_ENDPOINT_DESCRIPTOR);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
UsbDevice->ActiveConfig = UsbDevice->Configs[0];
|
||||
UsbDevice->ActiveInterface = UsbDevice->Configs[0]->Interfaces[0];
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
/* Set the device address */
|
||||
|
@ -251,6 +250,7 @@ InitializeUsbDevice(PVOID BusContext, PUSB_DEVICE_HANDLE DeviceHandle)
|
|||
0,
|
||||
NULL);
|
||||
|
||||
PdoDeviceExtension->UsbDevices[i]->DeviceState = DEVICEINTIALIZED;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -334,15 +334,12 @@ RemoveUsbDevice(PVOID BusContext, PUSB_DEVICE_HANDLE DeviceHandle, ULONG Flags)
|
|||
}
|
||||
|
||||
ExFreePool(UsbDevice);
|
||||
|
||||
/* DeConfig Device */
|
||||
break;
|
||||
case USBD_KEEP_DEVICE_DATA:
|
||||
DPRINT1("USBD_KEEP_DEVICE_DATA Not implemented!\n");
|
||||
break;
|
||||
|
||||
case USBD_MARK_DEVICE_BUSY:
|
||||
DPRINT1("USBD_MARK_DEVICE_BUSY Not implemented!\n");
|
||||
UsbDevice->DeviceState |= DEVICEBUSY;
|
||||
/* Fall through */
|
||||
case USBD_KEEP_DEVICE_DATA:
|
||||
UsbDevice->DeviceState |= DEVICEREMOVED;
|
||||
break;
|
||||
default:
|
||||
DPRINT1("Unknown Remove Flags %x\n", Flags);
|
||||
|
@ -354,8 +351,60 @@ NTSTATUS
|
|||
USB_BUSIFFN
|
||||
RestoreUsbDevice(PVOID BusContext, PUSB_DEVICE_HANDLE OldDeviceHandle, PUSB_DEVICE_HANDLE NewDeviceHandle)
|
||||
{
|
||||
DPRINT1("Ehci: RestoreUsbDevice not implemented! %x, %x, %x\n", BusContext, OldDeviceHandle, NewDeviceHandle);
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
PUSB_DEVICE OldUsbDevice;
|
||||
PUSB_DEVICE NewUsbDevice;
|
||||
|
||||
DPRINT1("Ehci: RestoreUsbDevice %x, %x, %x\n", BusContext, OldDeviceHandle, NewDeviceHandle);
|
||||
|
||||
OldUsbDevice = DeviceHandleToUsbDevice(BusContext, OldDeviceHandle);
|
||||
NewUsbDevice = DeviceHandleToUsbDevice(BusContext, NewDeviceHandle);
|
||||
|
||||
if (!OldUsbDevice)
|
||||
{
|
||||
DPRINT1("OldDeviceHandle is invalid\n");
|
||||
return STATUS_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
if (!(OldUsbDevice->DeviceState & DEVICEREMOVED))
|
||||
{
|
||||
DPRINT1("UsbDevice is not marked as Removed!\n");
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
if (!NewUsbDevice)
|
||||
{
|
||||
DPRINT1("NewDeviceHandle is invalid\n");
|
||||
return STATUS_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
if ((OldUsbDevice->DeviceDescriptor.idVendor == NewUsbDevice->DeviceDescriptor.idVendor) &&
|
||||
(OldUsbDevice->DeviceDescriptor.idProduct == NewUsbDevice->DeviceDescriptor.idProduct))
|
||||
{
|
||||
PUSB_CONFIGURATION ConfigToDelete;
|
||||
int i;
|
||||
|
||||
NewUsbDevice->DeviceState &= ~DEVICEBUSY;
|
||||
NewUsbDevice->DeviceState &= ~DEVICEREMOVED;
|
||||
|
||||
NewUsbDevice->ActiveConfig = OldUsbDevice->ActiveConfig;
|
||||
NewUsbDevice->ActiveInterface = OldUsbDevice->ActiveInterface;
|
||||
|
||||
for (i = 0; i < NewUsbDevice->DeviceDescriptor.bNumConfigurations; i++)
|
||||
{
|
||||
ConfigToDelete = NewUsbDevice->Configs[i];
|
||||
ASSERT(OldUsbDevice->Configs[i]);
|
||||
NewUsbDevice->Configs[i] = OldUsbDevice->Configs[i];
|
||||
OldUsbDevice->Configs[i] = ConfigToDelete;
|
||||
}
|
||||
|
||||
RemoveUsbDevice(BusContext, OldDeviceHandle, 0);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT1("VendorId or ProductId did not match!\n");
|
||||
return STATUS_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
@ -407,13 +456,24 @@ QueryDeviceInformation(PVOID BusContext,
|
|||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
DeviceInfo->PortNumber = UsbDevice->Port;
|
||||
DeviceInfo->HubAddress = 1;
|
||||
DeviceInfo->HubAddress = 0;
|
||||
DeviceInfo->DeviceAddress = UsbDevice->Address;
|
||||
DeviceInfo->DeviceSpeed = UsbDevice->DeviceSpeed;
|
||||
DeviceInfo->DeviceType = UsbDevice->DeviceType;
|
||||
|
||||
if (!UsbDevice->DeviceState)
|
||||
{
|
||||
DeviceInfo->CurrentConfigurationValue = 0;
|
||||
DeviceInfo->NumberOfOpenPipes = 0;
|
||||
DeviceInfo->PortNumber = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DeviceInfo->CurrentConfigurationValue = UsbDevice->ActiveConfig->ConfigurationDescriptor.bConfigurationValue;
|
||||
/* FIXME: Use correct number of open pipes instead of all available */
|
||||
DeviceInfo->NumberOfOpenPipes = UsbDevice->ActiveInterface->InterfaceDescriptor.bNumEndpoints;
|
||||
DeviceInfo->PortNumber = UsbDevice->Port;
|
||||
}
|
||||
|
||||
RtlCopyMemory(&DeviceInfo->DeviceDescriptor, &UsbDevice->DeviceDescriptor, sizeof(USB_DEVICE_DESCRIPTOR));
|
||||
|
||||
|
@ -495,15 +555,15 @@ GetExtendedHubInformation(PVOID BusContext,
|
|||
DPRINT1("InformationLevel should really be set to 0. Ignoring\n");
|
||||
}
|
||||
|
||||
UsbExtHubInfo->NumberOfPorts = 8;
|
||||
UsbExtHubInfo->NumberOfPorts = FdoDeviceExntension->hcd.ECHICaps.HCSParams.PortCount;
|
||||
|
||||
for (i=0; i < UsbExtHubInfo->NumberOfPorts; i++)
|
||||
{
|
||||
UsbExtHubInfo->Port[i].PhysicalPortNumber = i + 1;
|
||||
UsbExtHubInfo->Port[i].PortLabelNumber = FdoDeviceExntension->hcd.ECHICaps.HCSParams.PortCount;
|
||||
UsbExtHubInfo->Port[i].PortLabelNumber = i + 1;
|
||||
UsbExtHubInfo->Port[i].VidOverride = 0;
|
||||
UsbExtHubInfo->Port[i].PidOverride = 0;
|
||||
UsbExtHubInfo->Port[i].PortAttributes = USB_PORTATTR_SHARED_USB2;
|
||||
UsbExtHubInfo->Port[i].PortAttributes = USB_PORTATTR_SHARED_USB2;// | USB_PORTATTR_OWNED_BY_CC;
|
||||
}
|
||||
|
||||
*LengthReturned = FIELD_OFFSET(USB_EXTHUB_INFORMATION_0, Port[8]);
|
||||
|
@ -600,7 +660,17 @@ VOID
|
|||
USB_BUSIFFN
|
||||
SetDeviceHandleData(PVOID BusContext, PVOID DeviceHandle, PDEVICE_OBJECT UsbDevicePdo)
|
||||
{
|
||||
DPRINT1("Ehci: SetDeviceHandleData not implemented %x, %x, %x\n", BusContext, DeviceHandle, UsbDevicePdo);
|
||||
PUSB_DEVICE UsbDevice;
|
||||
|
||||
DPRINT1("Ehci: SetDeviceHandleData %x, %x, %x\n", BusContext, DeviceHandle, UsbDevicePdo);
|
||||
UsbDevice = DeviceHandleToUsbDevice(BusContext, DeviceHandle);
|
||||
if (!UsbDevice)
|
||||
{
|
||||
DPRINT1("Invalid DeviceHandle or device not connected\n");
|
||||
return;
|
||||
}
|
||||
|
||||
UsbDevice->UsbDevicePdo = UsbDevicePdo;
|
||||
}
|
||||
|
||||
|
||||
|
@ -654,6 +724,6 @@ NTSTATUS
|
|||
USB_BUSIFFN
|
||||
EnumLogEntry(PVOID BusContext, ULONG DriverTag, ULONG EnumTag, ULONG P1, ULONG P2)
|
||||
{
|
||||
DPRINT1("Ehci: EnumLogEntry called\n");
|
||||
DPRINT1("Ehci: EnumLogEntry called %x, %x, %x, %x\n", DriverTag, EnumTag, P1, P2);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -79,22 +79,37 @@ extern "C" {
|
|||
#define _alloca(s) __builtin_alloca(s)
|
||||
#endif
|
||||
|
||||
/*** Atomic operations ***/
|
||||
/*** Memory barriers ***/
|
||||
|
||||
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
|
||||
#define _ReadWriteBarrier() __sync_synchronize()
|
||||
#else
|
||||
__INTRIN_INLINE void _MemoryBarrier(void)
|
||||
#ifdef _x86_64
|
||||
__INTRIN_INLINE void __faststorefence(void)
|
||||
{
|
||||
long local;
|
||||
__asm__ __volatile__("lock; orl $0, %0;" : : "m"(local));
|
||||
}
|
||||
#endif
|
||||
|
||||
__INTRIN_INLINE void _mm_lfence(void)
|
||||
{
|
||||
__asm__ __volatile__("lfence");
|
||||
}
|
||||
|
||||
__INTRIN_INLINE void _mm_sfence(void)
|
||||
{
|
||||
__asm__ __volatile__("sfence");
|
||||
}
|
||||
|
||||
__INTRIN_INLINE void _ReadWriteBarrier(void)
|
||||
{
|
||||
__asm__ __volatile__("" : : : "memory");
|
||||
}
|
||||
#define _ReadWriteBarrier() _MemoryBarrier()
|
||||
#endif
|
||||
|
||||
/* BUGBUG: GCC only supports full barriers */
|
||||
/* GCC only supports full barriers */
|
||||
#define _ReadBarrier _ReadWriteBarrier
|
||||
#define _WriteBarrier _ReadWriteBarrier
|
||||
|
||||
/*** Atomic operations ***/
|
||||
|
||||
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
|
||||
|
||||
__INTRIN_INLINE char _InterlockedCompareExchange8(volatile char * const Destination, const char Exchange, const char Comperand)
|
||||
|
|
|
@ -118,7 +118,6 @@ Author:
|
|||
#define DISPATCH_LENGTH 106
|
||||
#endif
|
||||
|
||||
#define SharedUserdata ((KUSER_SHARED_DATA *CONST)(USER_SHARED_DATA|KSEG0_BASE))
|
||||
#else
|
||||
|
||||
//
|
||||
|
|
|
@ -943,6 +943,10 @@ CONFIGRET
|
|||
WINAPI
|
||||
CMP_UnregisterNotification(IN ULONG luhDevNotify);
|
||||
|
||||
CMAPI
|
||||
CONFIGRET
|
||||
WINAPI
|
||||
CMP_WaitServicesAvailable(IN HMACHINE hMachine);
|
||||
*/
|
||||
|
||||
CMAPI
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef _WINDOWSX_H
|
||||
#define _WINDOWSX_H
|
||||
|
||||
#define WM_CTLCOLOR 25
|
||||
#define Button_Enable(hwndCtl,fEnable) EnableWindow((hwndCtl),(fEnable))
|
||||
#define Button_GetCheck(hwndCtl) ((int)(DWORD)SendMessage((hwndCtl),BM_GETCHECK,0,0))
|
||||
#define Button_GetState(hwndCtl) ((int)(DWORD)SendMessage((hwndCtl),BM_GETSTATE,0,0))
|
||||
|
|
|
@ -17,8 +17,6 @@ extern "C" {
|
|||
#define WINUSERAPI
|
||||
#endif
|
||||
|
||||
|
||||
#define WC_DIALOG MAKEINTATOM(0x8002)
|
||||
#define FALT 16
|
||||
#define FCONTROL 8
|
||||
#define FNOINVERT 2
|
||||
|
@ -300,9 +298,6 @@ extern "C" {
|
|||
#define ES_LOWERCASE 16
|
||||
#define ES_MULTILINE 4
|
||||
#define ES_NOHIDESEL 256
|
||||
#ifdef _WINE
|
||||
#define ES_COMBO 0x200 /* Undocumented. Parent is a combobox */
|
||||
#endif
|
||||
#define ES_NUMBER 0x2000
|
||||
#define ES_OEMCONVERT 0x400
|
||||
#define ES_PASSWORD 32
|
||||
|
@ -390,7 +385,6 @@ extern "C" {
|
|||
#define WS_EX_COMPOSITED 0x2000000 /* XP */
|
||||
#define WS_EX_CONTEXTHELP 0x400
|
||||
#define WS_EX_CONTROLPARENT 0x10000
|
||||
#define WS_EX_DRAGDETECT 0x00000002L
|
||||
#define WS_EX_DLGMODALFRAME 1
|
||||
#define WS_EX_LAYERED 0x80000 /* w2k */
|
||||
#define WS_EX_LAYOUTRTL 0x400000 /* w98, w2k */
|
||||
|
@ -870,8 +864,6 @@ extern "C" {
|
|||
#endif
|
||||
#define QS_SENDMESSAGE 64
|
||||
#define QS_TIMER 16
|
||||
/* Extra (undocumented) queue wake bits - see "Undoc. Windows" */
|
||||
#define QS_SMRESULT 0x8000
|
||||
|
||||
#define USER_TIMER_MAXIMUM 2147483647
|
||||
#define USER_TIMER_MINIMUM 10
|
||||
|
@ -1213,10 +1205,6 @@ extern "C" {
|
|||
#define SWP_NOSENDCHANGING 1024
|
||||
#define SWP_DEFERERASE 8192
|
||||
#define SWP_ASYNCWINDOWPOS 16384
|
||||
/* undocumented SWP flags - from SDK 3.1 */
|
||||
#define SWP_NOCLIENTSIZE 0x0800
|
||||
#define SWP_NOCLIENTMOVE 0x1000
|
||||
#define SWP_STATECHANGED 0x8000
|
||||
|
||||
#define HSHELL_WINDOWCREATED 1
|
||||
#define HSHELL_WINDOWDESTROYED 2
|
||||
|
@ -1575,9 +1563,6 @@ extern "C" {
|
|||
#define WM_ACTIVATE 6
|
||||
#define WM_SETFOCUS 7
|
||||
#define WM_KILLFOCUS 8
|
||||
#ifdef _WINE
|
||||
#define WM_SETVISIBLE 9
|
||||
#endif
|
||||
#define WM_ENABLE 10
|
||||
#define WM_SETREDRAW 11
|
||||
#define WM_SETTEXT 12
|
||||
|
@ -1617,8 +1602,6 @@ extern "C" {
|
|||
#define WM_GETFONT 49
|
||||
#define WM_SETHOTKEY 50
|
||||
#define WM_GETHOTKEY 51
|
||||
#define WM_ISACTIVEICON 53
|
||||
#define WM_QUERYPARKICON 54
|
||||
#define WM_QUERYDRAGICON 55
|
||||
#define WM_COMPAREITEM 57
|
||||
#if (WINVER >= 0x0500)
|
||||
|
@ -1673,7 +1656,6 @@ extern "C" {
|
|||
#define WM_NCXBUTTONDBLCLK 173
|
||||
#endif /* (_WIN32_WINNT >= 0x0500) */
|
||||
|
||||
#define WM_KEYF1 0x004d
|
||||
#define WM_KEYFIRST 256
|
||||
#define WM_KEYDOWN 256
|
||||
#define WM_KEYUP 257
|
||||
|
@ -1707,7 +1689,6 @@ extern "C" {
|
|||
#define WM_VSCROLL 277
|
||||
#define WM_INITMENU 278
|
||||
#define WM_INITMENUPOPUP 279
|
||||
#define WM_SYSTIMER 280
|
||||
#define WM_MENUSELECT 287
|
||||
#define WM_MENUCHAR 288
|
||||
#define WM_ENTERIDLE 289
|
||||
|
@ -1727,15 +1708,6 @@ extern "C" {
|
|||
#endif /* _WIN32_WCE */
|
||||
#endif /* (WINVER >= 0x0500) */
|
||||
|
||||
/* D&D messages */
|
||||
#define WM_DROPOBJECT 0x022A
|
||||
#define WM_QUERYDROPOBJECT 0x022B
|
||||
#define WM_BEGINDRAG 0x022C
|
||||
#define WM_DRAGLOOP 0x022D
|
||||
#define WM_DRAGSELECT 0x022E
|
||||
#define WM_DRAGMOVE 0x022F
|
||||
|
||||
#define WM_CTLCOLOR 25
|
||||
#define WM_CTLCOLORMSGBOX 306
|
||||
#define WM_CTLCOLOREDIT 307
|
||||
#define WM_CTLCOLORLISTBOX 308
|
||||
|
@ -1746,7 +1718,6 @@ extern "C" {
|
|||
#define MN_GETHMENU 481
|
||||
#define WM_MOUSEFIRST 512
|
||||
#define WM_MOUSEMOVE 512
|
||||
#define WM_LBTRACKPOINT 0x0131
|
||||
#define WM_LBUTTONDOWN 513
|
||||
#define WM_LBUTTONUP 514
|
||||
#define WM_LBUTTONDBLCLK 515
|
||||
|
@ -1978,10 +1949,6 @@ extern "C" {
|
|||
#define EN_VSCROLL 1538
|
||||
#define LB_ADDFILE 406
|
||||
#define LB_ADDSTRING 384
|
||||
#ifdef _WINE
|
||||
#define LB_CARETON 419
|
||||
#define LB_CARETOFF 420
|
||||
#endif
|
||||
#define LB_DELETESTRING 386
|
||||
#define LB_DIR 397
|
||||
#define LB_FINDSTRING 399
|
||||
|
@ -2075,9 +2042,6 @@ extern "C" {
|
|||
#define DCX_INTERSECTRGN 128
|
||||
#define DCX_VALIDATE 0x200000
|
||||
#define DCX_EXCLUDEUPDATE 0x100
|
||||
#ifdef _WINE
|
||||
#define DCX_USESTYLE 0x10000
|
||||
#endif
|
||||
#define GMDI_GOINTOPOPUPS 2
|
||||
#define GMDI_USEDISABLED 1
|
||||
#define FKF_AVAILABLE 2
|
||||
|
@ -4942,6 +4906,10 @@ typedef MONITORINFOEXA MONITORINFOEX, *LPMONITORINFOEX;
|
|||
#endif /* UNICODE */
|
||||
#endif /* RC_INVOKED */
|
||||
|
||||
#ifdef _WINE
|
||||
#include "reactos/undocuser.h"
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* PURPOSE: ASM macros for for GAS and MASM/ML64
|
||||
* PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||
*/
|
||||
#ifndef _ASM_INC_
|
||||
#define _ASM_INC_
|
||||
|
||||
#ifdef _USE_ML
|
||||
|
||||
|
@ -53,10 +55,6 @@ ENDM
|
|||
|
||||
#define lidt lidt fword ptr ds:
|
||||
|
||||
ljmp MACRO segment, offset
|
||||
DB 0
|
||||
ENDM
|
||||
|
||||
.code64 MACRO
|
||||
.code
|
||||
ENDM
|
||||
|
@ -115,9 +113,9 @@ ENDM
|
|||
// FIXME
|
||||
ENDM
|
||||
|
||||
ljmp MACRO segment, offset
|
||||
//ljmp MACRO segment, offset
|
||||
// FIXME
|
||||
ENDM
|
||||
//ENDM
|
||||
|
||||
UNIMPLEMENTED MACRO name
|
||||
ENDM
|
||||
|
@ -176,9 +174,9 @@ ENDM
|
|||
#define REPEAT .rept
|
||||
#define ENDR .endr
|
||||
|
||||
.macro ljmp segment, offset
|
||||
jmp far ptr \segment:\offset
|
||||
.endm
|
||||
//.macro ljmp segment, offset
|
||||
// jmp far ptr \segment:\offset
|
||||
//.endm
|
||||
|
||||
/* MASM compatible EXTERN */
|
||||
.macro EXTERN name
|
||||
|
@ -260,3 +258,5 @@ code = 1
|
|||
#define elseif .elseif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _ASM_INC_ */
|
||||
|
|
1074
include/reactos/ksamd64.inc
Normal file
1074
include/reactos/ksamd64.inc
Normal file
File diff suppressed because it is too large
Load diff
175
include/reactos/undocuser.h
Normal file
175
include/reactos/undocuser.h
Normal file
|
@ -0,0 +1,175 @@
|
|||
#ifndef _UNDOCUSER_H
|
||||
#define _UNDOCUSER_H
|
||||
|
||||
/* Built in class atoms */
|
||||
#define WC_MENU (MAKEINTATOM(0x8000))
|
||||
#define WC_DESKTOP (MAKEINTATOM(0x8001))
|
||||
#define WC_DIALOG (MAKEINTATOM(0x8002))
|
||||
#define WC_SWITCH (MAKEINTATOM(0x8003))
|
||||
#define WC_ICONTITLE (MAKEINTATOM(0x8004))
|
||||
|
||||
/* Non SDK Styles */
|
||||
#define ES_COMBO 0x200 /* Parent is a combobox */
|
||||
#define WS_MAXIMIZED WS_MAXIMIZE
|
||||
#define WS_MINIMIZED WS_MINIMIZE
|
||||
|
||||
/* Non SDK ExStyles */
|
||||
#define WS_EX_DRAGDETECT 0x00000002
|
||||
#define WS_EX_MAKEVISIBLEWHENUNGHOSTED 0x00000800
|
||||
#define WS_EX_FORCELEGACYRESIZENCMETR 0x00800000
|
||||
#define WS_EX_UISTATEACTIVE 0x04000000
|
||||
#define WS_EX_REDIRECTED 0x20000000
|
||||
#define WS_EX_UISTATEKBACCELHIDDEN 0x40000000
|
||||
#define WS_EX_UISTATEFOCUSRECTHIDDEN 0x80000000
|
||||
#define WS_EX_SETANSICREATOR 0x80000000 // For WNDS_ANSICREATOR
|
||||
|
||||
/* Non SDK Window Message types. */
|
||||
#define WM_SETVISIBLE 0x00000009
|
||||
#define WM_CTLCOLOR 0x00000019
|
||||
#define WM_ALTTABACTIVE 0x00000029
|
||||
#define WM_ISACTIVEICON 0x00000035
|
||||
#define WM_QUERYPARKICON 0x00000036
|
||||
#define WM_CLIENTSHUTDOWN 0x0000003B
|
||||
#define WM_COPYGLOBALDATA 0x00000049
|
||||
#define WM_LOGONNOTIFY 0x0000004c
|
||||
#define WM_KEYF1 0x0000004d
|
||||
#define WM_SYSTIMER 0x00000118
|
||||
#define WM_LBTRACKPOINT 0x00000131
|
||||
#define LB_CARETON 0x000001a3
|
||||
#define LB_CARETOFF 0x000001a4
|
||||
#define WM_DROPOBJECT 0x0000022A
|
||||
#define WM_QUERYDROPOBJECT 0x0000022B
|
||||
#define WM_BEGINDRAG 0x0000022C
|
||||
#define WM_DRAGLOOP 0x0000022D
|
||||
#define WM_DRAGSELECT 0x0000022E
|
||||
#define WM_DRAGMOVE 0x0000022F
|
||||
#define WM_POPUPSYSTEMMENU 0x00000313
|
||||
#define WM_CBT 0x000003FF // ReactOS only.
|
||||
#define WM_MAXIMUM 0x0001FFFF
|
||||
|
||||
/* Non SDK DCE types.*/
|
||||
#define DCX_USESTYLE 0x00010000
|
||||
#define DCX_KEEPCLIPRGN 0x00040000
|
||||
#define DCX_KEEPLAYOUT 0x40000000
|
||||
#define DCX_PROCESSOWNED 0x80000000
|
||||
|
||||
/* Caret timer ID */
|
||||
#define IDCARETTIMER (0xffff)
|
||||
|
||||
/* SetWindowPos undocumented flags */
|
||||
#define SWP_NOCLIENTSIZE 0x0800
|
||||
#define SWP_NOCLIENTMOVE 0x1000
|
||||
#define SWP_STATECHANGED 0x8000
|
||||
|
||||
/* Non SDK Queue state flags. */
|
||||
#define QS_SMRESULT 0x8000 /* see "Undoc. Windows" */
|
||||
|
||||
//
|
||||
// Definitions used by WM_CLIENTSHUTDOWN
|
||||
//
|
||||
// Client Shutdown messages
|
||||
#define MCS_SHUTDOWNTIMERS 1
|
||||
#define MCS_QUERYENDSESSION 2
|
||||
// Client Shutdown returns
|
||||
#define MCSR_GOODFORSHUTDOWN 1
|
||||
#define MCSR_SHUTDOWNFINISHED 2
|
||||
#define MCSR_DONOTSHUTDOWN 3
|
||||
|
||||
//
|
||||
// Definitions used by WM_LOGONNOTIFY
|
||||
//
|
||||
#define LN_START_TASK_MANAGER 0x4
|
||||
#define LN_LOCK_WORKSTATION 0x5
|
||||
#define LN_UNLOCK_WORKSTATION 0x6
|
||||
#define LN_MESSAGE_BEEP 0x9
|
||||
|
||||
#define CW_USEDEFAULT16 ((short)0x8000)
|
||||
|
||||
#define SBRG_SCROLLBAR 0 /* the scrollbar itself */
|
||||
#define SBRG_TOPRIGHTBTN 1 /* the top or right button */
|
||||
#define SBRG_PAGEUPRIGHT 2 /* the page up or page right region */
|
||||
#define SBRG_SCROLLBOX 3 /* the scroll box */
|
||||
#define SBRG_PAGEDOWNLEFT 4 /* the page down or page left region */
|
||||
#define SBRG_BOTTOMLEFTBTN 5 /* the bottom or left button */
|
||||
|
||||
|
||||
BOOL WINAPI KillSystemTimer(HWND,UINT_PTR);
|
||||
UINT_PTR WINAPI SetSystemTimer(HWND,UINT_PTR,UINT,TIMERPROC);
|
||||
DWORD_PTR WINAPI SetSysColorsTemp(const COLORREF *, const HBRUSH *, DWORD_PTR);
|
||||
BOOL WINAPI SetDeskWallPaper(LPCSTR);
|
||||
VOID WINAPI ScrollChildren(HWND,UINT,WPARAM,LPARAM);
|
||||
void WINAPI CalcChildScroll(HWND, INT);
|
||||
BOOL WINAPI RegisterLogonProcess(DWORD,BOOL);
|
||||
DWORD WINAPI GetAppCompatFlags(HTASK hTask);
|
||||
DWORD WINAPI GetAppCompatFlags2(HTASK hTask);
|
||||
LONG WINAPI CsrBroadcastSystemMessageExW(DWORD dwflags,
|
||||
LPDWORD lpdwRecipients,
|
||||
UINT uiMessage,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam,
|
||||
PBSMINFO pBSMInfo);
|
||||
BOOL WINAPI CliImmSetHotKey(DWORD dwID, UINT uModifiers, UINT uVirtualKey, HKL hKl);
|
||||
HWND WINAPI GetTaskmanWindow(VOID);
|
||||
HWND WINAPI GetProgmanWindow(VOID);
|
||||
|
||||
//
|
||||
// User api hook
|
||||
//
|
||||
|
||||
typedef struct _USERAPIHOOKINFO
|
||||
{
|
||||
DWORD m_size;
|
||||
LPCWSTR m_dllname1;
|
||||
LPCWSTR m_funname1;
|
||||
LPCWSTR m_dllname2;
|
||||
LPCWSTR m_funname2;
|
||||
} USERAPIHOOKINFO,*PUSERAPIHOOKINFO;
|
||||
|
||||
typedef enum _UAPIHK
|
||||
{
|
||||
uahLoadInit,
|
||||
uahStop,
|
||||
uahShutdown
|
||||
} UAPIHK, *PUAPIHK;
|
||||
|
||||
typedef DWORD (CALLBACK * USERAPIHOOKPROC)(UAPIHK State, ULONG_PTR Info);
|
||||
|
||||
typedef LRESULT(CALLBACK *WNDPROC_OWP)(HWND,UINT,WPARAM,LPARAM,ULONG_PTR,PDWORD);
|
||||
|
||||
typedef struct _UAHOWP
|
||||
{
|
||||
BYTE* MsgBitArray;
|
||||
DWORD Size;
|
||||
} UAHOWP, *PUAHOWP;
|
||||
|
||||
typedef struct tagUSERAPIHOOK
|
||||
{
|
||||
DWORD size;
|
||||
WNDPROC DefWindowProcA;
|
||||
WNDPROC DefWindowProcW;
|
||||
UAHOWP DefWndProcArray;
|
||||
FARPROC GetScrollInfo;
|
||||
FARPROC SetScrollInfo;
|
||||
FARPROC EnableScrollBar;
|
||||
FARPROC AdjustWindowRectEx;
|
||||
FARPROC SetWindowRgn;
|
||||
WNDPROC_OWP PreWndProc;
|
||||
WNDPROC_OWP PostWndProc;
|
||||
UAHOWP WndProcArray;
|
||||
WNDPROC_OWP PreDefDlgProc;
|
||||
WNDPROC_OWP PostDefDlgProc;
|
||||
UAHOWP DlgProcArray;
|
||||
FARPROC GetSystemMetrics;
|
||||
FARPROC SystemParametersInfoA;
|
||||
FARPROC SystemParametersInfoW;
|
||||
FARPROC ForceResetUserApiHook;
|
||||
FARPROC DrawFrameControl;
|
||||
FARPROC DrawCaption;
|
||||
FARPROC MDIRedrawFrame;
|
||||
FARPROC GetRealWindowOwner;
|
||||
} USERAPIHOOK, *PUSERAPIHOOK;
|
||||
|
||||
BOOL WINAPI RegisterUserApiHook(PUSERAPIHOOKINFO puah);
|
||||
BOOL WINAPI UnregisterUserApiHook(VOID);
|
||||
|
||||
#endif
|
|
@ -466,19 +466,6 @@ typedef struct _SBINFOEX
|
|||
#define WNDS2_SHELLHOOKREGISTERED 0X40000000
|
||||
#define WNDS2_WMCREATEMSGPROCESSED 0X80000000
|
||||
|
||||
/* Non SDK ExStyles */
|
||||
#define WS_EX_MAKEVISIBLEWHENUNGHOSTED 0x00000800
|
||||
#define WS_EX_FORCELEGACYRESIZENCMETR 0x00800000
|
||||
#define WS_EX_UISTATEACTIVE 0x04000000
|
||||
#define WS_EX_REDIRECTED 0X20000000
|
||||
#define WS_EX_UISTATEKBACCELHIDDEN 0X40000000
|
||||
#define WS_EX_UISTATEFOCUSRECTHIDDEN 0X80000000
|
||||
#define WS_EX_SETANSICREATOR 0x80000000 // For WNDS_ANSICREATOR
|
||||
|
||||
/* Non SDK Styles */
|
||||
#define WS_MAXIMIZED WS_MAXIMIZE
|
||||
#define WS_MINIMIZED WS_MINIMIZE
|
||||
|
||||
/* ExStyles2 */
|
||||
#define WS_EX2_CLIPBOARDLISTENER 0X00000001
|
||||
#define WS_EX2_LAYEREDINVALIDATE 0X00000002
|
||||
|
@ -860,29 +847,6 @@ typedef struct _USERCONNECT
|
|||
SHAREDINFO siClient;
|
||||
} USERCONNECT, *PUSERCONNECT;
|
||||
|
||||
//
|
||||
// Non SDK Window Message types.
|
||||
//
|
||||
#define WM_CLIENTSHUTDOWN 59
|
||||
#define WM_COPYGLOBALDATA 73
|
||||
#define WM_SYSTIMER 280
|
||||
#define WM_POPUPSYSTEMMENU 787
|
||||
#define WM_CBT 1023 // ReactOS only.
|
||||
#define WM_MAXIMUM 0x0001FFFF
|
||||
|
||||
//
|
||||
// Non SDK DCE types.
|
||||
//
|
||||
#define DCX_USESTYLE 0x00010000
|
||||
#define DCX_KEEPCLIPRGN 0x00040000
|
||||
#define DCX_KEEPLAYOUT 0x40000000
|
||||
#define DCX_PROCESSOWNED 0x80000000
|
||||
|
||||
//
|
||||
// Non SDK Queue message types.
|
||||
//
|
||||
#define QS_SMRESULT 0x8000
|
||||
|
||||
DWORD
|
||||
NTAPI
|
||||
NtUserAssociateInputContext(
|
||||
|
|
|
@ -50,9 +50,7 @@ list(APPEND SOURCE
|
|||
security.c
|
||||
slist.c
|
||||
sid.c
|
||||
sprintf.c
|
||||
srw.c
|
||||
swprintf.c
|
||||
splaytree.c
|
||||
thread.c
|
||||
time.c
|
||||
|
|
|
@ -238,7 +238,7 @@ RtlpInsertFreeBlockHelper(PHEAP Heap,
|
|||
/* Check if PreviousSize of the next entry matches ours */
|
||||
if (!(FreeEntry->Flags & HEAP_ENTRY_LAST_ENTRY))
|
||||
{
|
||||
ASSERT(((PHEAP_ENTRY)FreeEntry + BlockSize)->PreviousSize = BlockSize);
|
||||
ASSERT(((PHEAP_ENTRY)FreeEntry + BlockSize)->PreviousSize == BlockSize);
|
||||
}
|
||||
|
||||
/* Insert it either into dedicated or non-dedicated list */
|
||||
|
|
|
@ -1,747 +0,0 @@
|
|||
|
||||
#ifndef USE_NEW_SPRINTF
|
||||
/*
|
||||
* PROGRAMMERS: David Welch
|
||||
* Eric Kohl
|
||||
*
|
||||
* TODO:
|
||||
* - Verify the implementation of '%Z'.
|
||||
*/
|
||||
|
||||
/*
|
||||
* linux/lib/vsprintf.c
|
||||
*
|
||||
* Copyright (C) 1991, 1992 Linus Torvalds
|
||||
*/
|
||||
|
||||
/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
|
||||
/*
|
||||
* Wirzenius wrote this portably, Torvalds fucked it up :-)
|
||||
*/
|
||||
|
||||
#include <rtl.h>
|
||||
|
||||
#define ZEROPAD 1 /* pad with zero */
|
||||
#define SIGN 2 /* unsigned/signed long */
|
||||
#define PLUS 4 /* show plus */
|
||||
#define SPACE 8 /* space if plus */
|
||||
#define LEFT 16 /* left justified */
|
||||
#define SPECIAL 32 /* 0x */
|
||||
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
|
||||
#define REMOVEHEX 256 /* use 256 as remve 0x frim BASE 16 */
|
||||
typedef struct {
|
||||
unsigned int mantissal:32;
|
||||
unsigned int mantissah:20;
|
||||
unsigned int exponent:11;
|
||||
unsigned int sign:1;
|
||||
} double_t;
|
||||
|
||||
static
|
||||
__inline
|
||||
int
|
||||
_isinf(double __x)
|
||||
{
|
||||
union
|
||||
{
|
||||
double* __x;
|
||||
double_t* x;
|
||||
} x;
|
||||
|
||||
x.__x = &__x;
|
||||
return ( x.x->exponent == 0x7ff && ( x.x->mantissah == 0 && x.x->mantissal == 0 ));
|
||||
}
|
||||
|
||||
static
|
||||
__inline
|
||||
int
|
||||
_isnan(double __x)
|
||||
{
|
||||
union
|
||||
{
|
||||
double* __x;
|
||||
double_t* x;
|
||||
} x;
|
||||
x.__x = &__x;
|
||||
return ( x.x->exponent == 0x7ff && ( x.x->mantissah != 0 || x.x->mantissal != 0 ));
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
__inline
|
||||
int
|
||||
do_div(long long *n, int base)
|
||||
{
|
||||
int a;
|
||||
a = ((unsigned long long) *n) % (unsigned) base;
|
||||
*n = ((unsigned long long) *n) / (unsigned) base;
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
static int skip_atoi(const char **s)
|
||||
{
|
||||
int i=0;
|
||||
|
||||
while (isdigit(**s))
|
||||
i = i*10 + *((*s)++) - '0';
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
number(char * buf, char * end, long long num, int base, int size, int precision, int type)
|
||||
{
|
||||
char c,sign,tmp[66];
|
||||
const char *digits;
|
||||
const char *small_digits = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
const char *large_digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
int i;
|
||||
|
||||
digits = (type & LARGE) ? large_digits : small_digits;
|
||||
if (type & LEFT)
|
||||
type &= ~ZEROPAD;
|
||||
if (base < 2 || base > 36)
|
||||
return 0;
|
||||
c = (type & ZEROPAD) ? '0' : ' ';
|
||||
sign = 0;
|
||||
if (type & SIGN) {
|
||||
if (num < 0) {
|
||||
sign = '-';
|
||||
num = -num;
|
||||
size--;
|
||||
} else if (type & PLUS) {
|
||||
sign = '+';
|
||||
size--;
|
||||
} else if (type & SPACE) {
|
||||
sign = ' ';
|
||||
size--;
|
||||
}
|
||||
}
|
||||
|
||||
if ((type & SPECIAL) && ((type & REMOVEHEX) == 0)) {
|
||||
if (base == 16)
|
||||
size -= 2;
|
||||
|
||||
}
|
||||
i = 0;
|
||||
if ((num == 0) && (precision !=0))
|
||||
tmp[i++] = '0';
|
||||
else while (num != 0)
|
||||
tmp[i++] = digits[do_div(&num,base)];
|
||||
if (i > precision)
|
||||
precision = i;
|
||||
size -= precision;
|
||||
if (!(type&(ZEROPAD+LEFT))) {
|
||||
while(size-->0) {
|
||||
if (buf <= end)
|
||||
*buf = ' ';
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
if (sign) {
|
||||
if (buf <= end)
|
||||
*buf = sign;
|
||||
++buf;
|
||||
}
|
||||
|
||||
if ((type & SPECIAL) && ((type & REMOVEHEX) == 0)) {
|
||||
if (base==16) {
|
||||
if (buf <= end)
|
||||
*buf = '0';
|
||||
++buf;
|
||||
if (buf <= end)
|
||||
*buf = digits[33];
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(type & LEFT)) {
|
||||
while (size-- > 0) {
|
||||
if (buf <= end)
|
||||
*buf = c;
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
while (i < precision--) {
|
||||
if (buf <= end)
|
||||
*buf = '0';
|
||||
++buf;
|
||||
}
|
||||
while (i-- > 0) {
|
||||
if (buf <= end)
|
||||
*buf = tmp[i];
|
||||
++buf;
|
||||
}
|
||||
while (size-- > 0) {
|
||||
if (buf <= end)
|
||||
*buf = ' ';
|
||||
++buf;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static char *
|
||||
numberf(char * buf, char * end, double num, int base, int size, int precision, int type)
|
||||
{
|
||||
char c,sign,tmp[66];
|
||||
const char *digits;
|
||||
const char *small_digits = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
const char *large_digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
int i;
|
||||
long long x;
|
||||
|
||||
/* FIXME
|
||||
the float version of number is direcly copy of number
|
||||
*/
|
||||
|
||||
digits = (type & LARGE) ? large_digits : small_digits;
|
||||
if (type & LEFT)
|
||||
type &= ~ZEROPAD;
|
||||
if (base < 2 || base > 36)
|
||||
return 0;
|
||||
c = (type & ZEROPAD) ? '0' : ' ';
|
||||
sign = 0;
|
||||
if (type & SIGN) {
|
||||
if (num < 0) {
|
||||
sign = '-';
|
||||
num = -num;
|
||||
size--;
|
||||
} else if (type & PLUS) {
|
||||
sign = '+';
|
||||
size--;
|
||||
} else if (type & SPACE) {
|
||||
sign = ' ';
|
||||
size--;
|
||||
}
|
||||
}
|
||||
if (type & SPECIAL) {
|
||||
if (base == 16)
|
||||
size -= 2;
|
||||
else if (base == 8)
|
||||
size--;
|
||||
}
|
||||
i = 0;
|
||||
if (num == 0)
|
||||
tmp[i++] = '0';
|
||||
else while (num != 0)
|
||||
{
|
||||
x = num;
|
||||
tmp[i++] = digits[do_div(&x,base)];
|
||||
#ifndef _M_ARM // Missing __floatdidf in CeGCC 0.55 -- GCC 4.4
|
||||
num=x;
|
||||
#endif
|
||||
}
|
||||
if (i > precision)
|
||||
precision = i;
|
||||
size -= precision;
|
||||
if (!(type&(ZEROPAD+LEFT))) {
|
||||
while(size-->0) {
|
||||
if (buf <= end)
|
||||
*buf = ' ';
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
if (sign) {
|
||||
if (buf <= end)
|
||||
*buf = sign;
|
||||
++buf;
|
||||
}
|
||||
if (type & SPECIAL) {
|
||||
if (base==8) {
|
||||
if (buf <= end)
|
||||
*buf = '0';
|
||||
++buf;
|
||||
} else if (base==16) {
|
||||
if (buf <= end)
|
||||
*buf = '0';
|
||||
++buf;
|
||||
if (buf <= end)
|
||||
*buf = digits[33];
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
if (!(type & LEFT)) {
|
||||
while (size-- > 0) {
|
||||
if (buf <= end)
|
||||
*buf = c;
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
while (i < precision--) {
|
||||
if (buf <= end)
|
||||
*buf = '0';
|
||||
++buf;
|
||||
}
|
||||
while (i-- > 0) {
|
||||
if (buf <= end)
|
||||
*buf = tmp[i];
|
||||
++buf;
|
||||
}
|
||||
while (size-- > 0) {
|
||||
if (buf <= end)
|
||||
*buf = ' ';
|
||||
++buf;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
static char*
|
||||
string(char* buf, char* end, const char* s, int len, int field_width, int precision, int flags)
|
||||
{
|
||||
int i;
|
||||
char c;
|
||||
|
||||
c = (flags & ZEROPAD) ? '0' : ' ';
|
||||
|
||||
if (s == NULL)
|
||||
{
|
||||
s = "<NULL>";
|
||||
len = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (len == -1)
|
||||
{
|
||||
len = 0;
|
||||
while ((unsigned int)len < (unsigned int)precision && s[len])
|
||||
len++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((unsigned int)len > (unsigned int)precision)
|
||||
len = precision;
|
||||
}
|
||||
}
|
||||
if (!(flags & LEFT))
|
||||
while (len < field_width--)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = c;
|
||||
++buf;
|
||||
}
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = *s++;
|
||||
++buf;
|
||||
}
|
||||
while (len < field_width--)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = ' ';
|
||||
++buf;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
static char*
|
||||
stringw(char* buf, char* end, const wchar_t* sw, int len, int field_width, int precision, int flags)
|
||||
{
|
||||
int i;
|
||||
char c;
|
||||
|
||||
c = (flags & ZEROPAD) ? '0' : ' ';
|
||||
|
||||
if (sw == NULL)
|
||||
{
|
||||
sw = L"<NULL>";
|
||||
len = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (len == -1)
|
||||
{
|
||||
len = 0;
|
||||
while ((unsigned int)len < (unsigned int)precision && sw[len])
|
||||
len++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((unsigned int)len > (unsigned int)precision)
|
||||
len = precision;
|
||||
}
|
||||
}
|
||||
if (!(flags & LEFT))
|
||||
while (len < field_width--)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = c;
|
||||
buf++;
|
||||
}
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = (unsigned char)(*sw++);
|
||||
buf++;
|
||||
}
|
||||
while (len < field_width--)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = ' ';
|
||||
buf++;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int __cdecl _vsnprintf(char *buf, size_t cnt, const char *fmt, va_list args)
|
||||
{
|
||||
int len;
|
||||
unsigned long long num;
|
||||
double _double;
|
||||
|
||||
int base;
|
||||
char *str, *end;
|
||||
const char *s;
|
||||
const wchar_t *sw;
|
||||
|
||||
int flags; /* flags to number() */
|
||||
|
||||
int field_width; /* width of output field */
|
||||
int precision; /* min. # of digits for integers; max
|
||||
number of chars for from string */
|
||||
int qualifier; /* 'h', 'l', 'L', 'I' or 'w' for integer fields */
|
||||
|
||||
/* clear the string buffer with zero so we do not need NULL terment it at end */
|
||||
|
||||
str = buf;
|
||||
end = buf + cnt - 1;
|
||||
if (end < buf - 1) {
|
||||
end = ((char *) -1);
|
||||
cnt = end - buf + 1;
|
||||
}
|
||||
|
||||
for ( ; *fmt ; ++fmt) {
|
||||
if (*fmt != '%') {
|
||||
if (str <= end)
|
||||
*str = *fmt;
|
||||
++str;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* process flags */
|
||||
flags = 0;
|
||||
repeat:
|
||||
++fmt; /* this also skips first '%' */
|
||||
switch (*fmt) {
|
||||
case '-': flags |= LEFT; goto repeat;
|
||||
case '+': flags |= PLUS; goto repeat;
|
||||
case ' ': flags |= SPACE; goto repeat;
|
||||
case '#': flags |= SPECIAL; goto repeat;
|
||||
case '0': flags |= ZEROPAD; goto repeat;
|
||||
}
|
||||
|
||||
/* get field width */
|
||||
field_width = -1;
|
||||
if (isdigit(*fmt))
|
||||
field_width = skip_atoi(&fmt);
|
||||
else if (*fmt == '*') {
|
||||
++fmt;
|
||||
/* it's the next argument */
|
||||
field_width = va_arg(args, int);
|
||||
if (field_width < 0) {
|
||||
field_width = -field_width;
|
||||
flags |= LEFT;
|
||||
}
|
||||
}
|
||||
|
||||
/* get the precision */
|
||||
precision = -1;
|
||||
if (*fmt == '.') {
|
||||
++fmt;
|
||||
if (isdigit(*fmt))
|
||||
precision = skip_atoi(&fmt);
|
||||
else if (*fmt == '*') {
|
||||
++fmt;
|
||||
/* it's the next argument */
|
||||
precision = va_arg(args, int);
|
||||
}
|
||||
if (precision < 0)
|
||||
precision = 0;
|
||||
}
|
||||
|
||||
/* get the conversion qualifier */
|
||||
qualifier = -1;
|
||||
if (*fmt == 'l' && *(fmt+1) == 'l') {
|
||||
qualifier = 'I';
|
||||
fmt += 2;
|
||||
} else if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt == 'w') {
|
||||
qualifier = *fmt;
|
||||
++fmt;
|
||||
} else if (*fmt == 'I' && *(fmt+1) == '6' && *(fmt+2) == '4') {
|
||||
qualifier = *fmt;
|
||||
fmt += 3;
|
||||
} else if (*fmt == 'I' && *(fmt+1) == '3' && *(fmt+2) == '2') {
|
||||
qualifier = 'l';
|
||||
fmt += 3;
|
||||
} else if (*fmt == 'F' && *(fmt+1) == 'p') {
|
||||
fmt += 1;
|
||||
flags |= REMOVEHEX;
|
||||
}
|
||||
|
||||
/* default base */
|
||||
base = 10;
|
||||
|
||||
switch (*fmt) {
|
||||
case 'c': /* finished */
|
||||
if (qualifier == 'l' || qualifier == 'w') {
|
||||
wchar_t sw1[2];
|
||||
/* print unicode string */
|
||||
sw1[0] = (wchar_t) va_arg(args, int);
|
||||
sw1[1] = 0;
|
||||
str = stringw(str, end, (wchar_t *)&sw1, -1, field_width, precision, flags);
|
||||
} else {
|
||||
char s1[2];
|
||||
/* print ascii string */
|
||||
s1[0] = ( unsigned char) va_arg(args, int);
|
||||
s1[1] = 0;
|
||||
str = string(str, end, (char *)&s1, -1, field_width, precision, flags);
|
||||
}
|
||||
continue;
|
||||
|
||||
case 'C': /* finished */
|
||||
if (!(flags & LEFT))
|
||||
while (--field_width > 0) {
|
||||
if (str <= end)
|
||||
*str = ' ';
|
||||
++str;
|
||||
}
|
||||
if (qualifier == 'h') {
|
||||
if (str <= end)
|
||||
*str = (unsigned char) va_arg(args, int);
|
||||
++str;
|
||||
} else {
|
||||
if (str <= end)
|
||||
*str = (unsigned char)(wchar_t) va_arg(args, int);
|
||||
++str;
|
||||
}
|
||||
while (--field_width > 0) {
|
||||
if (str <= end)
|
||||
*str = ' ';
|
||||
++str;
|
||||
}
|
||||
continue;
|
||||
|
||||
case 's': /* finished */
|
||||
if (qualifier == 'l' || qualifier == 'w') {
|
||||
/* print unicode string */
|
||||
sw = va_arg(args, wchar_t *);
|
||||
str = stringw(str, end, sw, -1, field_width, precision, flags);
|
||||
} else {
|
||||
/* print ascii string */
|
||||
s = va_arg(args, char *);
|
||||
str = string(str, end, s, -1, field_width, precision, flags);
|
||||
}
|
||||
continue;
|
||||
|
||||
case 'S':
|
||||
if (qualifier == 'h') {
|
||||
/* print ascii string */
|
||||
s = va_arg(args, char *);
|
||||
str = string(str, end, s, -1, field_width, precision, flags);
|
||||
} else {
|
||||
/* print unicode string */
|
||||
sw = va_arg(args, wchar_t *);
|
||||
str = stringw(str, end, sw, -1, field_width, precision, flags);
|
||||
}
|
||||
continue;
|
||||
|
||||
case 'Z':
|
||||
if (qualifier == 'w') {
|
||||
/* print counted unicode string */
|
||||
PUNICODE_STRING pus = va_arg(args, PUNICODE_STRING);
|
||||
if ((pus == NULL) || (pus->Buffer == NULL)) {
|
||||
sw = NULL;
|
||||
len = -1;
|
||||
} else {
|
||||
sw = pus->Buffer;
|
||||
len = pus->Length / sizeof(WCHAR);
|
||||
}
|
||||
str = stringw(str, end, sw, len, field_width, precision, flags);
|
||||
} else {
|
||||
/* print counted ascii string */
|
||||
PANSI_STRING pus = va_arg(args, PANSI_STRING);
|
||||
if ((pus == NULL) || (pus->Buffer == NULL)) {
|
||||
s = NULL;
|
||||
len = -1;
|
||||
} else {
|
||||
s = pus->Buffer;
|
||||
len = pus->Length;
|
||||
}
|
||||
str = string(str, end, s, len, field_width, precision, flags);
|
||||
}
|
||||
continue;
|
||||
|
||||
case 'p':
|
||||
if ((flags & LARGE) == 0)
|
||||
flags |= LARGE;
|
||||
|
||||
if (field_width == -1) {
|
||||
field_width = 2 * sizeof(void *);
|
||||
flags |= ZEROPAD;
|
||||
}
|
||||
str = number(str, end,
|
||||
(ULONG_PTR) va_arg(args, void *), 16,
|
||||
field_width, precision, flags);
|
||||
continue;
|
||||
|
||||
case 'n':
|
||||
/* FIXME: What does C99 say about the overflow case here? */
|
||||
if (qualifier == 'l') {
|
||||
long * ip = va_arg(args, long *);
|
||||
*ip = (str - buf);
|
||||
} else {
|
||||
int * ip = va_arg(args, int *);
|
||||
*ip = (str - buf);
|
||||
}
|
||||
continue;
|
||||
|
||||
/* float number formats - set up the flags and "break" */
|
||||
case 'e':
|
||||
case 'E':
|
||||
case 'f':
|
||||
case 'g':
|
||||
case 'G':
|
||||
_double = (double)va_arg(args, double);
|
||||
if ( _isnan(_double) ) {
|
||||
s = "Nan";
|
||||
len = 3;
|
||||
while ( len > 0 ) {
|
||||
if (str <= end)
|
||||
*str = *s++;
|
||||
++str;
|
||||
len --;
|
||||
}
|
||||
} else if ( _isinf(_double) < 0 ) {
|
||||
s = "-Inf";
|
||||
len = 4;
|
||||
while ( len > 0 ) {
|
||||
if (str <= end)
|
||||
*str = *s++;
|
||||
++str;
|
||||
len --;
|
||||
}
|
||||
} else if ( _isinf(_double) > 0 ) {
|
||||
s = "+Inf";
|
||||
len = 4;
|
||||
while ( len > 0 ) {
|
||||
if (str <= end)
|
||||
*str = *s++;
|
||||
++str;
|
||||
len --;
|
||||
}
|
||||
} else {
|
||||
if ( precision == -1 )
|
||||
precision = 6;
|
||||
str = numberf(str, end, (int)_double, base, field_width, precision, flags);
|
||||
}
|
||||
|
||||
continue;
|
||||
|
||||
|
||||
/* integer number formats - set up the flags and "break" */
|
||||
case 'o':
|
||||
base = 8;
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
base = 2;
|
||||
break;
|
||||
|
||||
case 'X':
|
||||
flags |= LARGE;
|
||||
case 'x':
|
||||
base = 16;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
case 'i':
|
||||
flags |= SIGN;
|
||||
case 'u':
|
||||
break;
|
||||
|
||||
default:
|
||||
if (*fmt) {
|
||||
if (str <= end)
|
||||
*str = *fmt;
|
||||
++str;
|
||||
} else
|
||||
--fmt;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (qualifier == 'I')
|
||||
num = va_arg(args, unsigned long long);
|
||||
else if (qualifier == 'l') {
|
||||
if (flags & SIGN)
|
||||
num = va_arg(args, long);
|
||||
else
|
||||
num = va_arg(args, unsigned long);
|
||||
}
|
||||
else if (qualifier == 'h') {
|
||||
if (flags & SIGN)
|
||||
num = va_arg(args, int);
|
||||
else
|
||||
num = va_arg(args, unsigned int);
|
||||
}
|
||||
else {
|
||||
if (flags & SIGN)
|
||||
num = va_arg(args, int);
|
||||
else
|
||||
num = va_arg(args, unsigned int);
|
||||
}
|
||||
str = number(str, end, num, base, field_width, precision, flags);
|
||||
}
|
||||
if (str <= end)
|
||||
*str = '\0';
|
||||
else if (cnt > 0)
|
||||
/* don't write out a null byte if the buf size is zero */
|
||||
*end = '\0';
|
||||
return str-buf;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int sprintf(char * buf, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int i;
|
||||
|
||||
va_start(args, fmt);
|
||||
i=_vsnprintf(buf,MAXLONG,fmt,args);
|
||||
va_end(args);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _snprintf(char * buf, size_t cnt, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int i;
|
||||
|
||||
va_start(args, fmt);
|
||||
i=_vsnprintf(buf,cnt,fmt,args);
|
||||
va_end(args);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int __cdecl vsprintf(char *buf, const char *fmt, va_list args)
|
||||
{
|
||||
return _vsnprintf(buf,MAXLONG,fmt,args);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
#endif
|
||||
|
|
@ -131,7 +131,7 @@ RtlpReleaseWaitBlockLockExclusive(IN OUT PRTL_SRWLOCK SRWLock,
|
|||
}
|
||||
}
|
||||
|
||||
(void)InterlockedExchange((PLONG)&SRWLock->Ptr, NewValue);
|
||||
(void)_InterlockedExchangePointer(&SRWLock->Ptr, (PVOID)NewValue);
|
||||
|
||||
if (FirstWaitBlock->Exclusive)
|
||||
{
|
||||
|
@ -186,7 +186,7 @@ RtlpReleaseWaitBlockLockLastShared(IN OUT PRTL_SRWLOCK SRWLock,
|
|||
NewValue = RTL_SRWLOCK_OWNED;
|
||||
}
|
||||
|
||||
(void)InterlockedExchange((PLONG)&SRWLock->Ptr, NewValue);
|
||||
(void)_InterlockedExchangePointer(&SRWLock->Ptr, (PVOID)NewValue);
|
||||
|
||||
(void)InterlockedOr(&FirstWaitBlock->Wake,
|
||||
TRUE);
|
||||
|
@ -420,9 +420,9 @@ RtlAcquireSRWLockShared(IN OUT PRTL_SRWLOCK SRWLock)
|
|||
NewValue = (CurrentValue >> RTL_SRWLOCK_BITS) + 1;
|
||||
NewValue = (NewValue << RTL_SRWLOCK_BITS) | (CurrentValue & RTL_SRWLOCK_MASK);
|
||||
|
||||
if (InterlockedCompareExchange((PLONG)&SRWLock->Ptr,
|
||||
NewValue,
|
||||
CurrentValue) == CurrentValue)
|
||||
if ((LONG_PTR)_InterlockedCompareExchangePointer(&SRWLock->Ptr,
|
||||
(PVOID)NewValue,
|
||||
(PVOID)CurrentValue) == CurrentValue)
|
||||
{
|
||||
/* Successfully incremented the shared count, we acquired the lock */
|
||||
break;
|
||||
|
@ -499,9 +499,9 @@ RtlAcquireSRWLockShared(IN OUT PRTL_SRWLOCK SRWLock)
|
|||
ASSERT_SRW_WAITBLOCK(&StackWaitBlock);
|
||||
|
||||
NewValue = (ULONG_PTR)&StackWaitBlock | RTL_SRWLOCK_OWNED | RTL_SRWLOCK_CONTENDED;
|
||||
if (InterlockedCompareExchange((PLONG)&SRWLock->Ptr,
|
||||
NewValue,
|
||||
CurrentValue) == CurrentValue)
|
||||
if ((LONG_PTR)_InterlockedCompareExchangePointer(&SRWLock->Ptr,
|
||||
(PVOID)NewValue,
|
||||
(PVOID)CurrentValue) == CurrentValue)
|
||||
{
|
||||
RtlpAcquireSRWLockSharedWait(SRWLock,
|
||||
&StackWaitBlock,
|
||||
|
@ -521,9 +521,9 @@ RtlAcquireSRWLockShared(IN OUT PRTL_SRWLOCK SRWLock)
|
|||
RTL_SRWLOCK_SHARED nor the RTL_SRWLOCK_OWNED bit is set */
|
||||
ASSERT(!(CurrentValue & RTL_SRWLOCK_CONTENDED));
|
||||
|
||||
if (InterlockedCompareExchange((PLONG)&SRWLock->Ptr,
|
||||
NewValue,
|
||||
CurrentValue) == CurrentValue)
|
||||
if ((LONG_PTR)_InterlockedCompareExchangePointer(&SRWLock->Ptr,
|
||||
(PVOID)NewValue,
|
||||
(PVOID)CurrentValue) == CurrentValue)
|
||||
{
|
||||
/* Successfully set the shared count, we acquired the lock */
|
||||
break;
|
||||
|
@ -580,9 +580,9 @@ RtlReleaseSRWLockShared(IN OUT PRTL_SRWLOCK SRWLock)
|
|||
NewValue = (NewValue << RTL_SRWLOCK_BITS) | RTL_SRWLOCK_SHARED | RTL_SRWLOCK_OWNED;
|
||||
}
|
||||
|
||||
if (InterlockedCompareExchange((PLONG)&SRWLock->Ptr,
|
||||
NewValue,
|
||||
CurrentValue) == CurrentValue)
|
||||
if ((LONG_PTR)_InterlockedCompareExchangePointer(&SRWLock->Ptr,
|
||||
(PVOID)NewValue,
|
||||
(PVOID)CurrentValue) == CurrentValue)
|
||||
{
|
||||
/* Successfully released the lock */
|
||||
break;
|
||||
|
@ -639,9 +639,9 @@ RtlAcquireSRWLockExclusive(IN OUT PRTL_SRWLOCK SRWLock)
|
|||
|
||||
NewValue = (ULONG_PTR)&StackWaitBlock | RTL_SRWLOCK_SHARED | RTL_SRWLOCK_CONTENDED | RTL_SRWLOCK_OWNED;
|
||||
|
||||
if (InterlockedCompareExchange((PLONG)&SRWLock->Ptr,
|
||||
NewValue,
|
||||
CurrentValue) == CurrentValue)
|
||||
if ((LONG_PTR)_InterlockedCompareExchangePointer(&SRWLock->Ptr,
|
||||
(PVOID)NewValue,
|
||||
(PVOID)CurrentValue) == CurrentValue)
|
||||
{
|
||||
RtlpAcquireSRWLockExclusiveWait(SRWLock,
|
||||
&StackWaitBlock);
|
||||
|
@ -697,9 +697,9 @@ AddWaitBlock:
|
|||
ASSERT_SRW_WAITBLOCK(&StackWaitBlock);
|
||||
|
||||
NewValue = (ULONG_PTR)&StackWaitBlock | RTL_SRWLOCK_OWNED | RTL_SRWLOCK_CONTENDED;
|
||||
if (InterlockedCompareExchange((PLONG)&SRWLock->Ptr,
|
||||
NewValue,
|
||||
CurrentValue) == CurrentValue)
|
||||
if ((LONG_PTR)_InterlockedCompareExchangePointer(&SRWLock->Ptr,
|
||||
(PVOID)NewValue,
|
||||
(PVOID)CurrentValue) == CurrentValue)
|
||||
{
|
||||
RtlpAcquireSRWLockExclusiveWait(SRWLock,
|
||||
&StackWaitBlock);
|
||||
|
@ -767,9 +767,9 @@ RtlReleaseSRWLockExclusive(IN OUT PRTL_SRWLOCK SRWLock)
|
|||
ASSERT(!(CurrentValue & ~RTL_SRWLOCK_OWNED));
|
||||
|
||||
NewValue = 0;
|
||||
if (InterlockedCompareExchange((PLONG)&SRWLock->Ptr,
|
||||
NewValue,
|
||||
CurrentValue) == CurrentValue)
|
||||
if ((LONG_PTR)_InterlockedCompareExchangePointer(&SRWLock->Ptr,
|
||||
(PVOID)NewValue,
|
||||
(PVOID)CurrentValue) == CurrentValue)
|
||||
{
|
||||
/* We released the lock */
|
||||
break;
|
||||
|
|
|
@ -1,744 +0,0 @@
|
|||
#ifndef USE_NEW_SPRINTF
|
||||
/*
|
||||
* PROGRAMMERS: David Welch
|
||||
* Eric Kohl
|
||||
*
|
||||
* TODO:
|
||||
* - Verify the implementation of '%Z'.
|
||||
*/
|
||||
|
||||
/*
|
||||
* linux/lib/vsprintf.c
|
||||
*
|
||||
* Copyright (C) 1991, 1992 Linus Torvalds
|
||||
*/
|
||||
|
||||
/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
|
||||
/*
|
||||
* Wirzenius wrote this portably, Torvalds fucked it up :-)
|
||||
*/
|
||||
|
||||
#include <rtl.h>
|
||||
|
||||
#define ZEROPAD 1 /* pad with zero */
|
||||
#define SIGN 2 /* unsigned/signed long */
|
||||
#define PLUS 4 /* show plus */
|
||||
#define SPACE 8 /* space if plus */
|
||||
#define LEFT 16 /* left justified */
|
||||
#define SPECIAL 32 /* 0x */
|
||||
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
|
||||
#define REMOVEHEX 256 /* use 256 as remve 0x frim BASE 16 */
|
||||
typedef struct {
|
||||
unsigned int mantissal:32;
|
||||
unsigned int mantissah:20;
|
||||
unsigned int exponent:11;
|
||||
unsigned int sign:1;
|
||||
} double_t;
|
||||
|
||||
static
|
||||
__inline
|
||||
int
|
||||
_isinf(double __x)
|
||||
{
|
||||
union
|
||||
{
|
||||
double* __x;
|
||||
double_t* x;
|
||||
} x;
|
||||
|
||||
x.__x = &__x;
|
||||
return ( x.x->exponent == 0x7ff && ( x.x->mantissah == 0 && x.x->mantissal == 0 ));
|
||||
}
|
||||
|
||||
static
|
||||
__inline
|
||||
int
|
||||
_isnan(double __x)
|
||||
{
|
||||
union
|
||||
{
|
||||
double* __x;
|
||||
double_t* x;
|
||||
} x;
|
||||
x.__x = &__x;
|
||||
return ( x.x->exponent == 0x7ff && ( x.x->mantissah != 0 || x.x->mantissal != 0 ));
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
__inline
|
||||
int
|
||||
do_div(long long *n, int base)
|
||||
{
|
||||
int a;
|
||||
a = ((unsigned long long) *n) % (unsigned) base;
|
||||
*n = ((unsigned long long) *n) / (unsigned) base;
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
static int skip_atoi(const wchar_t **s)
|
||||
{
|
||||
int i=0;
|
||||
|
||||
while (iswdigit(**s))
|
||||
i = i*10 + *((*s)++) - L'0';
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
static wchar_t *
|
||||
number(wchar_t * buf, wchar_t * end, long long num, int base, int size, int precision, int type)
|
||||
{
|
||||
wchar_t c, sign, tmp[66];
|
||||
const wchar_t *digits;
|
||||
const wchar_t *small_digits = L"0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
const wchar_t *large_digits = L"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
int i;
|
||||
|
||||
digits = (type & LARGE) ? large_digits : small_digits;
|
||||
if (type & LEFT)
|
||||
type &= ~ZEROPAD;
|
||||
if (base < 2 || base > 36)
|
||||
return 0;
|
||||
c = (type & ZEROPAD) ? L'0' : L' ';
|
||||
sign = 0;
|
||||
if (type & SIGN) {
|
||||
if (num < 0) {
|
||||
sign = L'-';
|
||||
num = -num;
|
||||
size--;
|
||||
} else if (type & PLUS) {
|
||||
sign = L'+';
|
||||
size--;
|
||||
} else if (type & SPACE) {
|
||||
sign = ' ';
|
||||
size--;
|
||||
}
|
||||
}
|
||||
|
||||
if ((type & SPECIAL) && ((type & REMOVEHEX) == 0)) {
|
||||
if (base == 16)
|
||||
size -= 2;
|
||||
}
|
||||
i = 0;
|
||||
if ((num == 0) && (precision !=0))
|
||||
tmp[i++] = L'0';
|
||||
else while (num != 0)
|
||||
tmp[i++] = digits[do_div(&num,base)];
|
||||
if (i > precision)
|
||||
precision = i;
|
||||
size -= precision;
|
||||
if (!(type&(ZEROPAD+LEFT))) {
|
||||
while(size-->0) {
|
||||
if (buf <= end)
|
||||
*buf = L' ';
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
if (sign) {
|
||||
if (buf <= end)
|
||||
*buf = sign;
|
||||
++buf;
|
||||
}
|
||||
|
||||
if ((type & SPECIAL) && ((type & REMOVEHEX) == 0)) {
|
||||
if (base==16) {
|
||||
if (buf <= end)
|
||||
*buf = L'0';
|
||||
++buf;
|
||||
if (buf <= end)
|
||||
*buf = digits[33];
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
if (!(type & LEFT)) {
|
||||
while (size-- > 0) {
|
||||
if (buf <= end)
|
||||
*buf = c;
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
while (i < precision--) {
|
||||
if (buf <= end)
|
||||
*buf = L'0';
|
||||
++buf;
|
||||
}
|
||||
while (i-- > 0) {
|
||||
if (buf <= end)
|
||||
*buf = tmp[i];
|
||||
++buf;
|
||||
}
|
||||
while (size-- > 0) {
|
||||
if (buf <= end)
|
||||
*buf = L' ';
|
||||
++buf;
|
||||
}
|
||||
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static wchar_t *
|
||||
numberf(wchar_t * buf, wchar_t * end, double num, int base, int size, int precision, int type)
|
||||
{
|
||||
wchar_t c, sign, tmp[66];
|
||||
const wchar_t *digits;
|
||||
const wchar_t *small_digits = L"0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
const wchar_t *large_digits = L"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
int i;
|
||||
long long x;
|
||||
|
||||
/* FIXME
|
||||
the float version of number is direcly copy of number
|
||||
*/
|
||||
|
||||
|
||||
digits = (type & LARGE) ? large_digits : small_digits;
|
||||
if (type & LEFT)
|
||||
type &= ~ZEROPAD;
|
||||
if (base < 2 || base > 36)
|
||||
return 0;
|
||||
c = (type & ZEROPAD) ? L'0' : L' ';
|
||||
sign = 0;
|
||||
if (type & SIGN) {
|
||||
if (num < 0) {
|
||||
sign = L'-';
|
||||
num = -num;
|
||||
size--;
|
||||
} else if (type & PLUS) {
|
||||
sign = L'+';
|
||||
size--;
|
||||
} else if (type & SPACE) {
|
||||
sign = ' ';
|
||||
size--;
|
||||
}
|
||||
}
|
||||
if (type & SPECIAL) {
|
||||
if (base == 16)
|
||||
size -= 2;
|
||||
else if (base == 8)
|
||||
size--;
|
||||
}
|
||||
i = 0;
|
||||
if (num == 0)
|
||||
tmp[i++] = L'0';
|
||||
else while (num != 0)
|
||||
{
|
||||
x = num;
|
||||
tmp[i++] = digits[do_div(&x,base)];
|
||||
#ifndef _M_ARM // Missing __floatdidf in CeGCC 0.55 -- GCC 4.4
|
||||
num = x;
|
||||
#endif
|
||||
}
|
||||
if (i > precision)
|
||||
precision = i;
|
||||
size -= precision;
|
||||
if (!(type&(ZEROPAD+LEFT))) {
|
||||
while(size-->0) {
|
||||
if (buf <= end)
|
||||
*buf = L' ';
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
if (sign) {
|
||||
if (buf <= end)
|
||||
*buf = sign;
|
||||
++buf;
|
||||
}
|
||||
if (type & SPECIAL) {
|
||||
if (base==8) {
|
||||
if (buf <= end)
|
||||
*buf = L'0';
|
||||
++buf;
|
||||
} else if (base==16) {
|
||||
if (buf <= end)
|
||||
*buf = L'0';
|
||||
++buf;
|
||||
if (buf <= end)
|
||||
*buf = digits[33];
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
if (!(type & LEFT)) {
|
||||
while (size-- > 0) {
|
||||
if (buf <= end)
|
||||
*buf = c;
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
while (i < precision--) {
|
||||
if (buf <= end)
|
||||
*buf = L'0';
|
||||
++buf;
|
||||
}
|
||||
while (i-- > 0) {
|
||||
if (buf <= end)
|
||||
*buf = tmp[i];
|
||||
++buf;
|
||||
}
|
||||
while (size-- > 0) {
|
||||
if (buf <= end)
|
||||
*buf = L' ';
|
||||
++buf;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
static wchar_t*
|
||||
string(wchar_t* buf, wchar_t* end, const char* s, int len, int field_width, int precision, int flags)
|
||||
{
|
||||
int i;
|
||||
wchar_t c;
|
||||
|
||||
c = (flags & ZEROPAD) ? L'0' : L' ';
|
||||
|
||||
if (s == NULL)
|
||||
{
|
||||
s = "<NULL>";
|
||||
len = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (len == -1)
|
||||
{
|
||||
len = 0;
|
||||
while ((unsigned int)len < (unsigned int)precision && s[len])
|
||||
len++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((unsigned int)len > (unsigned int)precision)
|
||||
len = precision;
|
||||
}
|
||||
}
|
||||
if (!(flags & LEFT))
|
||||
while (len < field_width--)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = c;
|
||||
++buf;
|
||||
}
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = *s++;
|
||||
++buf;
|
||||
}
|
||||
while (len < field_width--)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = L' ';
|
||||
++buf;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
static wchar_t*
|
||||
stringw(wchar_t* buf, wchar_t* end, const wchar_t* sw, int len, int field_width, int precision, int flags)
|
||||
{
|
||||
int i;
|
||||
wchar_t c;
|
||||
|
||||
c = (flags & ZEROPAD) ? L'0' : L' ';
|
||||
|
||||
if (sw == NULL)
|
||||
{
|
||||
sw = L"<NULL>";
|
||||
len = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (len == -1)
|
||||
{
|
||||
len = 0;
|
||||
while ((unsigned int)len < (unsigned int)precision && sw[len])
|
||||
len++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((unsigned int)len > (unsigned int)precision)
|
||||
len = precision;
|
||||
}
|
||||
}
|
||||
if (!(flags & LEFT))
|
||||
while (len < field_width--)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = c;
|
||||
buf++;
|
||||
}
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = *sw++;
|
||||
buf++;
|
||||
}
|
||||
while (len < field_width--)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = L' ';
|
||||
buf++;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int __cdecl _vsnwprintf(wchar_t *buf, size_t cnt, const wchar_t *fmt, va_list args)
|
||||
{
|
||||
int len;
|
||||
unsigned long long num;
|
||||
int base;
|
||||
wchar_t * str, * end;
|
||||
const char *s;
|
||||
const wchar_t *sw;
|
||||
const wchar_t *ss;
|
||||
double _double;
|
||||
|
||||
int flags; /* flags to number() */
|
||||
|
||||
int field_width; /* width of output field */
|
||||
int precision; /* min. # of digits for integers; max
|
||||
number of chars for from string */
|
||||
int qualifier; /* 'h', 'l', 'L', 'w' or 'I' for integer fields */
|
||||
|
||||
str = buf;
|
||||
end = buf + cnt - 1;
|
||||
if (end < buf - 1) {
|
||||
end = ((wchar_t *) -1);
|
||||
cnt = end - buf + 1;
|
||||
}
|
||||
|
||||
for ( ; *fmt ; ++fmt) {
|
||||
if (*fmt != L'%') {
|
||||
if (str <= end)
|
||||
*str = *fmt;
|
||||
++str;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* process flags */
|
||||
flags = 0;
|
||||
repeat:
|
||||
++fmt; /* this also skips first '%' */
|
||||
switch (*fmt) {
|
||||
case L'-': flags |= LEFT; goto repeat;
|
||||
case L'+': flags |= PLUS; goto repeat;
|
||||
case L' ': flags |= SPACE; goto repeat;
|
||||
case L'#': flags |= SPECIAL; goto repeat;
|
||||
case L'0': flags |= ZEROPAD; goto repeat;
|
||||
}
|
||||
|
||||
/* get field width */
|
||||
field_width = -1;
|
||||
if (iswdigit(*fmt))
|
||||
field_width = skip_atoi(&fmt);
|
||||
else if (*fmt == L'*') {
|
||||
++fmt;
|
||||
/* it's the next argument */
|
||||
field_width = va_arg(args, int);
|
||||
if (field_width < 0) {
|
||||
field_width = -field_width;
|
||||
flags |= LEFT;
|
||||
}
|
||||
}
|
||||
|
||||
/* get the precision */
|
||||
precision = -1;
|
||||
if (*fmt == L'.') {
|
||||
++fmt;
|
||||
if (iswdigit(*fmt))
|
||||
precision = skip_atoi(&fmt);
|
||||
else if (*fmt == L'*') {
|
||||
++fmt;
|
||||
/* it's the next argument */
|
||||
precision = va_arg(args, int);
|
||||
}
|
||||
if (precision < 0)
|
||||
precision = 0;
|
||||
}
|
||||
|
||||
/* get the conversion qualifier */
|
||||
qualifier = -1;
|
||||
if (*fmt == L'l' && *(fmt+1) == L'l') {
|
||||
qualifier = L'I';
|
||||
fmt += 2;
|
||||
} else if (*fmt == L'h' || *fmt == L'l' || *fmt == L'L' || *fmt == L'w') {
|
||||
qualifier = *fmt;
|
||||
++fmt;
|
||||
} else if (*fmt == L'I' && *(fmt+1) == L'6' && *(fmt+2) == L'4') {
|
||||
qualifier = *fmt;
|
||||
fmt += 3;
|
||||
} else if (*fmt == L'I' && *(fmt+1) == L'3' && *(fmt+2) == L'2') {
|
||||
qualifier = L'l';
|
||||
fmt += 3;
|
||||
} else if (*fmt == L'F' && *(fmt+1) == L'p') {
|
||||
fmt += 1;
|
||||
flags |= REMOVEHEX;
|
||||
}
|
||||
|
||||
/* default base */
|
||||
base = 10;
|
||||
|
||||
switch (*fmt) {
|
||||
case L'c':
|
||||
if (qualifier == 'h' || qualifier == 'w') {
|
||||
wchar_t sw1[2];
|
||||
/* print unicode string */
|
||||
sw1[0] = (wchar_t) va_arg(args, int);
|
||||
sw1[1] = 0;
|
||||
str = stringw(str, end, (wchar_t *)&sw1, -1, field_width, precision, flags);
|
||||
} else {
|
||||
char s1[2];
|
||||
/* print ascii string */
|
||||
s1[0] = ( unsigned char) va_arg(args, int);
|
||||
s1[1] = 0;
|
||||
str = string(str, end, (char *)&s1, -1, field_width, precision, flags);
|
||||
}
|
||||
|
||||
continue;
|
||||
|
||||
case L'C':
|
||||
if (!(flags & LEFT))
|
||||
while (--field_width > 0) {
|
||||
if (str <= end)
|
||||
*str = L' ';
|
||||
++str;
|
||||
}
|
||||
if (qualifier == 'l' || qualifier == 'w') {
|
||||
if (str <= end)
|
||||
*str = (wchar_t) va_arg(args, int);
|
||||
++str;
|
||||
} else {
|
||||
if (str <= end)
|
||||
*str = (wchar_t) va_arg(args, int);
|
||||
++str;
|
||||
}
|
||||
while (--field_width > 0) {
|
||||
if (str <= end)
|
||||
*str = L' ';
|
||||
++str;
|
||||
}
|
||||
continue;
|
||||
|
||||
case L's':
|
||||
if (qualifier == 'h') {
|
||||
/* print ascii string */
|
||||
s = va_arg(args, char *);
|
||||
str = string(str, end, s, -1, field_width, precision, flags);
|
||||
} else {
|
||||
/* print unicode string */
|
||||
sw = va_arg(args, wchar_t *);
|
||||
str = stringw(str, end, sw, -1, field_width, precision, flags);
|
||||
}
|
||||
continue;
|
||||
|
||||
case L'S':
|
||||
if (qualifier == 'l' || qualifier == 'w') {
|
||||
/* print unicode string */
|
||||
sw = va_arg(args, wchar_t *);
|
||||
str = stringw(str, end, sw, -1, field_width, precision, flags);
|
||||
} else {
|
||||
/* print ascii string */
|
||||
s = va_arg(args, char *);
|
||||
str = string(str, end, s, -1, field_width, precision, flags);
|
||||
}
|
||||
continue;
|
||||
|
||||
case L'Z':
|
||||
if (qualifier == 'h') {
|
||||
/* print counted ascii string */
|
||||
PANSI_STRING pus = va_arg(args, PANSI_STRING);
|
||||
if ((pus == NULL) || (pus->Buffer == NULL)) {
|
||||
s = NULL;
|
||||
len = -1;
|
||||
} else {
|
||||
s = pus->Buffer;
|
||||
len = pus->Length;
|
||||
}
|
||||
str = string(str, end, s, len, field_width, precision, flags);
|
||||
} else {
|
||||
/* print counted unicode string */
|
||||
PUNICODE_STRING pus = va_arg(args, PUNICODE_STRING);
|
||||
if ((pus == NULL) || (pus->Buffer == NULL)) {
|
||||
sw = NULL;
|
||||
len = -1;
|
||||
} else {
|
||||
sw = pus->Buffer;
|
||||
len = pus->Length / sizeof(WCHAR);
|
||||
}
|
||||
str = stringw(str, end, sw, len, field_width, precision, flags);
|
||||
}
|
||||
continue;
|
||||
|
||||
case L'p':
|
||||
if ((flags & LARGE) == 0)
|
||||
flags |= LARGE;
|
||||
if (field_width == -1) {
|
||||
field_width = 2*sizeof(void *);
|
||||
flags |= ZEROPAD;
|
||||
}
|
||||
str = number(str, end,
|
||||
(ULONG_PTR) va_arg(args, void *), 16,
|
||||
field_width, precision, flags);
|
||||
continue;
|
||||
|
||||
case L'n':
|
||||
/* FIXME: What does C99 say about the overflow case here? */
|
||||
if (qualifier == 'l') {
|
||||
long * ip = va_arg(args, long *);
|
||||
*ip = (str - buf);
|
||||
} else {
|
||||
int * ip = va_arg(args, int *);
|
||||
*ip = (str - buf);
|
||||
}
|
||||
continue;
|
||||
/* float number formats - set up the flags and "break" */
|
||||
case 'e':
|
||||
case 'E':
|
||||
case 'f':
|
||||
case 'g':
|
||||
case 'G':
|
||||
_double = (double)va_arg(args, double);
|
||||
|
||||
if ( _isnan(_double) ) {
|
||||
ss = L"Nan";
|
||||
len = 3;
|
||||
while ( len > 0 ) {
|
||||
if (str <= end)
|
||||
*str = *ss++;
|
||||
++str;
|
||||
len --;
|
||||
}
|
||||
} else if ( _isinf(_double) < 0 ) {
|
||||
ss = L"-Inf";
|
||||
len = 4;
|
||||
while ( len > 0 ) {
|
||||
if (str <= end)
|
||||
*str = *ss++;
|
||||
++str;
|
||||
len --;
|
||||
}
|
||||
} else if ( _isinf(_double) > 0 ) {
|
||||
ss = L"+Inf";
|
||||
len = 4;
|
||||
while ( len > 0 ) {
|
||||
if (str <= end)
|
||||
*str = *ss++;
|
||||
++str;
|
||||
len --;
|
||||
}
|
||||
} else {
|
||||
if ( precision == -1 )
|
||||
precision = 6;
|
||||
str = numberf(str, end, _double, base, field_width, precision, flags);
|
||||
}
|
||||
|
||||
continue;
|
||||
|
||||
|
||||
|
||||
/* integer number formats - set up the flags and "break" */
|
||||
case L'o':
|
||||
base = 8;
|
||||
break;
|
||||
|
||||
case L'b':
|
||||
base = 2;
|
||||
break;
|
||||
|
||||
case L'X':
|
||||
flags |= LARGE;
|
||||
case L'x':
|
||||
base = 16;
|
||||
break;
|
||||
|
||||
case L'd':
|
||||
case L'i':
|
||||
flags |= SIGN;
|
||||
case L'u':
|
||||
break;
|
||||
|
||||
default:
|
||||
if (*fmt) {
|
||||
if (str <= end)
|
||||
*str = *fmt;
|
||||
++str;
|
||||
} else
|
||||
--fmt;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (qualifier == L'I')
|
||||
num = va_arg(args, unsigned long long);
|
||||
else if (qualifier == L'l') {
|
||||
if (flags & SIGN)
|
||||
num = va_arg(args, long);
|
||||
else
|
||||
num = va_arg(args, unsigned long);
|
||||
}
|
||||
else if (qualifier == L'h') {
|
||||
if (flags & SIGN)
|
||||
num = va_arg(args, int);
|
||||
else
|
||||
num = va_arg(args, unsigned int);
|
||||
}
|
||||
else {
|
||||
if (flags & SIGN)
|
||||
num = va_arg(args, int);
|
||||
else
|
||||
num = va_arg(args, unsigned int);
|
||||
}
|
||||
str = number(str, end, num, base, field_width, precision, flags);
|
||||
}
|
||||
if (str <= end)
|
||||
*str = L'\0';
|
||||
else if (cnt > 0)
|
||||
/* don't write out a null byte if the buf size is zero */
|
||||
*end = L'\0';
|
||||
return str-buf;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int swprintf(wchar_t *buf, const wchar_t *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int i;
|
||||
|
||||
va_start(args, fmt);
|
||||
i=_vsnwprintf(buf,MAXLONG,fmt,args);
|
||||
va_end(args);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int __cdecl _snwprintf(wchar_t *buf, size_t cnt, const wchar_t *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int i;
|
||||
|
||||
va_start(args, fmt);
|
||||
i=_vsnwprintf(buf,cnt,fmt,args);
|
||||
va_end(args);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int __cdecl vswprintf(wchar_t *buf, const wchar_t *fmt, va_list args)
|
||||
{
|
||||
return _vsnwprintf(buf,MAXLONG,fmt,args);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
#endif
|
|
@ -5,7 +5,6 @@ add_definitions(-D_CRTBLD)
|
|||
|
||||
list(APPEND CRT_SOURCE
|
||||
conio/cgets.c
|
||||
conio/cprintf.c
|
||||
conio/cputs.c
|
||||
conio/getch.c
|
||||
conio/getche.c
|
||||
|
@ -54,6 +53,7 @@ list(APPEND CRT_SOURCE
|
|||
math/ldiv.c
|
||||
math/logf.c
|
||||
math/modf.c
|
||||
math/powf.c
|
||||
math/rand.c
|
||||
math/sqrtf.c
|
||||
math/s_modf.c
|
||||
|
@ -128,6 +128,26 @@ list(APPEND CRT_SOURCE
|
|||
misc/purecall.c
|
||||
misc/stubs.c
|
||||
misc/tls.c
|
||||
printf/_cprintf.c
|
||||
printf/_snprintf.c
|
||||
printf/_snwprintf.c
|
||||
printf/_vcprintf.c
|
||||
printf/_vsnprintf.c
|
||||
printf/_vsnwprintf.c
|
||||
printf/fprintf.c
|
||||
printf/fwprintf.c
|
||||
printf/printf.c
|
||||
printf/sprintf.c
|
||||
printf/streamout.c
|
||||
printf/swprintf.c
|
||||
printf/vfprintf.c
|
||||
printf/vfwprintf.c
|
||||
printf/vprintf.c
|
||||
printf/vsprintf.c
|
||||
printf/vswprintf.c
|
||||
printf/vwprintf.c
|
||||
printf/wprintf.c
|
||||
printf/wstreamout.c
|
||||
process/_cwait.c
|
||||
process/_system.c
|
||||
process/dll.c
|
||||
|
@ -142,13 +162,15 @@ list(APPEND CRT_SOURCE
|
|||
search/lsearch.c
|
||||
signal/signal.c
|
||||
signal/xcptinfo.c
|
||||
stdio/_flsbuf.c
|
||||
stdio/_flswbuf.c
|
||||
stdio/access.c
|
||||
stdio/file.c
|
||||
stdio/find.c
|
||||
stdio/find64.c
|
||||
stdio/findi64.c
|
||||
stdio/fmode.c
|
||||
stdio/lnx_sprintf.c
|
||||
stdio/lock_file.c
|
||||
stdio/perror.c
|
||||
stdio/popen.c
|
||||
stdio/stat.c
|
||||
|
@ -427,6 +449,18 @@ list(APPEND LIBCNTPR_SOURCE
|
|||
mem/memccpy.c
|
||||
mem/memcmp.c
|
||||
mem/memicmp.c
|
||||
printf/_snprintf.c
|
||||
printf/_snwprintf.c
|
||||
printf/_vcprintf.c
|
||||
printf/_vsnprintf.c
|
||||
printf/_vsnwprintf.c
|
||||
printf/sprintf.c
|
||||
printf/streamout.c
|
||||
printf/swprintf.c
|
||||
printf/vprintf.c
|
||||
printf/vsprintf.c
|
||||
printf/vswprintf.c
|
||||
printf/wstreamout.c
|
||||
search/bsearch.c
|
||||
search/lfind.c
|
||||
stdlib/qsort.c
|
||||
|
@ -588,3 +622,16 @@ if(MSVC)
|
|||
add_library(msvcsup ${MSVCSUP_SOURCE})
|
||||
add_dependencies(msvcsup psdk buildno_header asm)
|
||||
endif()
|
||||
|
||||
add_definitions(-D_USER32_WSPRINTF)
|
||||
add_library(user32_wsprintf
|
||||
printf/streamout.c
|
||||
printf/wstreamout.c
|
||||
printf/wsprintfA.c
|
||||
printf/wsprintfW.c
|
||||
printf/wvsprintfA.c
|
||||
printf/wvsprintfW.c
|
||||
printf/wvsnprintfA.c
|
||||
printf/wvsnprintfW.c
|
||||
string/mbstowcs_nt.c
|
||||
string/wcstombs_nt.c)
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* COPYRIGHT: Winehq
|
||||
* PROJECT: wine
|
||||
* FILE: msvcrt/conio/cprintf.c
|
||||
* PURPOSE: C Runtime
|
||||
* PROGRAMMER: Magnus Olsen (Imported from wine cvs 2006-05-23)
|
||||
*/
|
||||
#ifndef USE_NEW_SPRINTF
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int
|
||||
_cprintf(const char *fmt, ...)
|
||||
{
|
||||
char buf[2048], *mem = buf;
|
||||
int written, resize = sizeof(buf), retval;
|
||||
va_list valist;
|
||||
|
||||
va_start( valist, fmt );
|
||||
|
||||
while ((written = _vsnprintf( mem, resize, fmt, valist )) == -1 ||
|
||||
written > resize)
|
||||
{
|
||||
resize = (written == -1 ? resize * 2 : written + 1);
|
||||
if (mem != buf)
|
||||
free (mem);
|
||||
if (!(mem = (char *)malloc(resize)))
|
||||
return EOF;
|
||||
|
||||
va_end ( valist );
|
||||
va_start( valist, fmt );
|
||||
}
|
||||
va_end ( valist );
|
||||
retval = _cputs( mem );
|
||||
if (mem != buf)
|
||||
free (mem);
|
||||
return retval;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -6,34 +6,7 @@
|
|||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <tchar.h>
|
||||
|
||||
int _cdecl streamout(FILE *stream, const char *format, va_list argptr);
|
||||
|
||||
int
|
||||
_cdecl
|
||||
_snprintf(char *buffer, size_t count, const char *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
int result;
|
||||
FILE stream;
|
||||
|
||||
stream._base = buffer;
|
||||
stream._ptr = stream._base;
|
||||
stream._charbuf = 0;
|
||||
stream._bufsiz = count;
|
||||
stream._cnt = stream._bufsiz;
|
||||
stream._flag = 0;
|
||||
stream._tmpfname = 0;
|
||||
|
||||
va_start(argptr, format);
|
||||
result = streamout(&stream, format, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
*stream._ptr = '\0';
|
||||
return result;
|
||||
}
|
||||
|
||||
#define _sxprintf _snprintf
|
||||
#define USE_COUNT 1
|
||||
|
||||
#include "_sxprintf.c"
|
||||
|
|
|
@ -6,37 +6,8 @@
|
|||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#define _sxprintf _snwprintf
|
||||
#define USE_COUNT 1
|
||||
#define _UNICODE
|
||||
|
||||
int _cdecl wstreamout(FILE *stream, const wchar_t *format, va_list argptr);
|
||||
|
||||
int
|
||||
__cdecl
|
||||
_snwprintf(
|
||||
wchar_t *buffer,
|
||||
size_t count,
|
||||
const wchar_t *format,
|
||||
...)
|
||||
{
|
||||
va_list argptr;
|
||||
int result;
|
||||
FILE stream;
|
||||
|
||||
stream._base = (char*)buffer;
|
||||
stream._ptr = stream._base;
|
||||
stream._bufsiz = count * sizeof(wchar_t);
|
||||
stream._cnt = stream._bufsiz;
|
||||
stream._flag = _IOSTRG | _IOWRT;
|
||||
stream._tmpfname = 0;
|
||||
stream._charbuf = 0;
|
||||
|
||||
va_start(argptr, format);
|
||||
result = wstreamout(&stream, format, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
/* Only zero terminate if there is enough space left */
|
||||
if (stream._cnt >= sizeof(wchar_t)) *(wchar_t*)stream._ptr = L'\0';
|
||||
|
||||
return result;
|
||||
}
|
||||
#include "_sxprintf.c"
|
||||
|
|
72
lib/sdk/crt/printf/_sxprintf.c
Normal file
72
lib/sdk/crt/printf/_sxprintf.c
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/swprintf.c
|
||||
* PURPOSE: Implementation of swprintf
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#ifdef _UNICODE
|
||||
#define _tstreamout wstreamout
|
||||
#else
|
||||
#define _tstreamout streamout
|
||||
#endif
|
||||
|
||||
int _cdecl _tstreamout(FILE *stream, const TCHAR *format, va_list argptr);
|
||||
|
||||
int
|
||||
#if defined(USER32_WSPRINTF) && defined(_M_IX86)
|
||||
_stdcall
|
||||
#else
|
||||
_cdecl
|
||||
#endif
|
||||
_sxprintf(
|
||||
TCHAR *buffer,
|
||||
#if USE_COUNT
|
||||
size_t count,
|
||||
#endif
|
||||
const TCHAR *format,
|
||||
#if USE_VARARGS
|
||||
va_list argptr)
|
||||
#else
|
||||
...)
|
||||
#endif
|
||||
{
|
||||
#if !USE_VARARGS
|
||||
va_list argptr;
|
||||
#endif
|
||||
int result;
|
||||
FILE stream;
|
||||
|
||||
stream._base = (char*)buffer;
|
||||
stream._ptr = stream._base;
|
||||
stream._charbuf = 0;
|
||||
#if USE_COUNT
|
||||
stream._cnt = count * sizeof(TCHAR);
|
||||
#else
|
||||
stream._cnt = INT_MAX;
|
||||
#endif
|
||||
stream._bufsiz = 0;
|
||||
stream._flag = _IOSTRG | _IOWRT;
|
||||
stream._tmpfname = 0;
|
||||
|
||||
#if !USE_VARARGS
|
||||
va_start(argptr, format);
|
||||
#endif
|
||||
result = _tstreamout(&stream, format, argptr);
|
||||
#if !USE_VARARGS
|
||||
va_end(argptr);
|
||||
#endif
|
||||
|
||||
/* Only zero terminate if there is enough space left */
|
||||
if (stream._cnt >= sizeof(TCHAR)) *(TCHAR*)stream._ptr = _T('\0');
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -6,32 +6,8 @@
|
|||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#define _sxprintf _vsnprintf
|
||||
#define USE_COUNT 1
|
||||
#define USE_VARARGS 1
|
||||
|
||||
int _cdecl streamout(FILE *stream, const char *format, va_list argptr);
|
||||
|
||||
int
|
||||
__cdecl
|
||||
_vsnprintf(
|
||||
char *buffer,
|
||||
size_t count,
|
||||
const char *format,
|
||||
va_list argptr)
|
||||
{
|
||||
int result;
|
||||
FILE stream;
|
||||
|
||||
stream._base = buffer;
|
||||
stream._ptr = stream._base;
|
||||
stream._bufsiz = count;
|
||||
stream._cnt = stream._bufsiz;
|
||||
stream._flag = _IOSTRG | _IOWRT;
|
||||
stream._tmpfname = 0;
|
||||
stream._charbuf = 0;
|
||||
|
||||
result = streamout(&stream, format, argptr);
|
||||
*stream._ptr = '\0';
|
||||
|
||||
return result;
|
||||
}
|
||||
#include "_sxprintf.c"
|
||||
|
|
|
@ -6,32 +6,9 @@
|
|||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#define _sxprintf _vsnwprintf
|
||||
#define USE_COUNT 1
|
||||
#define USE_VARARGS 1
|
||||
#define _UNICODE
|
||||
|
||||
int _cdecl wstreamout(FILE *stream, const wchar_t *format, va_list argptr);
|
||||
|
||||
int
|
||||
__cdecl
|
||||
_vsnwprintf(
|
||||
wchar_t *buffer,
|
||||
size_t count,
|
||||
const wchar_t *format,
|
||||
va_list argptr)
|
||||
{
|
||||
int result;
|
||||
FILE stream;
|
||||
|
||||
stream._base = (char*)buffer;
|
||||
stream._ptr = stream._base;
|
||||
stream._bufsiz = count * sizeof(wchar_t);
|
||||
stream._cnt = stream._bufsiz;
|
||||
stream._flag = _IOSTRG | _IOWRT;
|
||||
stream._tmpfname = 0;
|
||||
stream._charbuf = 0;
|
||||
|
||||
result = wstreamout(&stream, format, argptr);
|
||||
*(wchar_t*)stream._ptr = L'\0';
|
||||
|
||||
return result;
|
||||
}
|
||||
#include "_sxprintf.c"
|
||||
|
|
|
@ -22,6 +22,7 @@ printf(const char *format, ...)
|
|||
va_start(argptr, format);
|
||||
result = streamout(stdout, format, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,33 +6,7 @@
|
|||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
|
||||
int _cdecl streamout(FILE *stream, const char *format, va_list argptr);
|
||||
|
||||
int
|
||||
_cdecl
|
||||
sprintf(char *buffer, const char *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
int result;
|
||||
FILE stream;
|
||||
|
||||
stream._base = buffer;
|
||||
stream._ptr = stream._base;
|
||||
stream._charbuf = 0;
|
||||
stream._bufsiz = INT_MAX;
|
||||
stream._cnt = stream._bufsiz;
|
||||
stream._flag = 0;
|
||||
stream._tmpfname = 0;
|
||||
|
||||
va_start(argptr, format);
|
||||
result = streamout(&stream, format, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
*stream._ptr = '\0';
|
||||
return result;
|
||||
}
|
||||
#define _sxprintf sprintf
|
||||
#define USE_COUNT 0
|
||||
|
||||
#include "_sxprintf.c"
|
||||
|
|
|
@ -16,6 +16,13 @@
|
|||
#ifdef _UNICODE
|
||||
# define streamout wstreamout
|
||||
# define format_float format_floatw
|
||||
# define _flsbuf _flswbuf
|
||||
int __cdecl _flswbuf(int ch, FILE *stream);
|
||||
#endif
|
||||
|
||||
#ifdef _LIBCNT_
|
||||
# undef _flsbuf
|
||||
# define _flsbuf(chr, stream) _TEOF
|
||||
#endif
|
||||
|
||||
#define MB_CUR_MAX 10
|
||||
|
@ -67,11 +74,10 @@ enum
|
|||
(flags & FLAG_LONGDOUBLE) ? va_arg(argptr, long double) : \
|
||||
va_arg(argptr, double)
|
||||
|
||||
#ifdef _LIBCNT_
|
||||
# define _flsbuf(chr, stream) 0
|
||||
#endif
|
||||
#define get_exp(f) floor(f == 0 ? 0 : (f >= 0 ? log10(f) : log10(-f)))
|
||||
#define round(x) floor((x) + 0.5)
|
||||
|
||||
#define get_exp(f) floor(f > 0 ? log10(f) : log10(-f))
|
||||
#ifndef _USER32_WSPRINTF
|
||||
|
||||
void
|
||||
#ifdef _LIBCNT
|
||||
|
@ -92,30 +98,56 @@ format_float(
|
|||
static const TCHAR _nan[] = _T("#QNAN");
|
||||
static const TCHAR _infinity[] = _T("#INF");
|
||||
const TCHAR *digits = digits_l;
|
||||
int exponent = 0;
|
||||
long double fpval;
|
||||
int num_digits, val32, base = 10;
|
||||
__int64 val64;
|
||||
int exponent = 0, sign;
|
||||
long double fpval, fpval2;
|
||||
int padding = 0, num_digits, val32, base = 10;
|
||||
|
||||
/* Normalize the precision */
|
||||
if (precision < 0) precision = 6;
|
||||
else if (precision > 512) precision = 512;
|
||||
else if (precision > 17)
|
||||
{
|
||||
padding = precision - 17;
|
||||
precision = 17;
|
||||
}
|
||||
|
||||
/* Get the float value and calculate the exponent */
|
||||
fpval = va_arg_ffp(*argptr, flags);
|
||||
exponent = get_exp(fpval);
|
||||
sign = fpval < 0 ? -1 : 1;
|
||||
|
||||
switch (chr)
|
||||
{
|
||||
case _T('G'):
|
||||
digits = digits_u;
|
||||
case _T('g'):
|
||||
if (precision > 0) precision--;
|
||||
if (exponent < -4 || exponent >= precision) goto case_e;
|
||||
|
||||
/* Shift the decimal point and round */
|
||||
fpval2 = round(sign * fpval * pow(10., precision));
|
||||
|
||||
/* Skip trailing zeroes */
|
||||
while (precision && (unsigned __int64)fpval2 % 10 == 0)
|
||||
{
|
||||
precision--;
|
||||
fpval2 /= 10;
|
||||
}
|
||||
break;
|
||||
|
||||
case _T('E'):
|
||||
digits = digits_u;
|
||||
case _T('e'):
|
||||
case_e:
|
||||
fpval /= pow(10., exponent);
|
||||
/* Shift the decimal point and round */
|
||||
fpval2 = round(sign * fpval * pow(10., precision - exponent));
|
||||
|
||||
/* Compensate for changed exponent through rounding */
|
||||
if (fpval2 >= (unsigned __int64)pow(10., precision + 1))
|
||||
{
|
||||
exponent++;
|
||||
fpval2 = round(sign * fpval * pow(10., precision - exponent));
|
||||
}
|
||||
|
||||
val32 = exponent >= 0 ? exponent : -exponent;
|
||||
|
||||
// FIXME: handle length of exponent field:
|
||||
|
@ -128,7 +160,7 @@ format_float(
|
|||
}
|
||||
|
||||
/* Sign for the exponent */
|
||||
*--(*string) = exponent > 0 ? _T('+') : _T('-');
|
||||
*--(*string) = exponent >= 0 ? _T('+') : _T('-');
|
||||
|
||||
/* Add 'e' or 'E' separator */
|
||||
*--(*string) = digits[0xe];
|
||||
|
@ -141,16 +173,15 @@ format_float(
|
|||
// FIXME: TODO
|
||||
|
||||
case _T('f'):
|
||||
default:
|
||||
/* Shift the decimal point and round */
|
||||
fpval2 = round(sign * fpval * pow(10., precision));
|
||||
break;
|
||||
}
|
||||
|
||||
/* CHECKME: Windows seems to handle a max of 17 digits(?) */
|
||||
num_digits = precision <= 17 ? precision: 17;
|
||||
|
||||
/* Handle sign */
|
||||
if (fpval < 0)
|
||||
{
|
||||
fpval = -fpval;
|
||||
*prefix = _T("-");
|
||||
}
|
||||
else if (flags & FLAG_FORCE_SIGN)
|
||||
|
@ -163,46 +194,58 @@ format_float(
|
|||
{
|
||||
(*string) -= sizeof(_nan) / sizeof(TCHAR) - 1;
|
||||
_tcscpy((*string), _nan);
|
||||
val64 = 1;
|
||||
fpval2 = 1;
|
||||
}
|
||||
else if (!_finite(fpval))
|
||||
{
|
||||
(*string) -= sizeof(_infinity) / sizeof(TCHAR) - 1;
|
||||
_tcscpy((*string), _infinity);
|
||||
val64 = 1;
|
||||
fpval2 = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
fpval *= pow(10., precision);
|
||||
val64 = (__int64)(fpval + 0.5);
|
||||
/* Zero padding */
|
||||
while (padding-- > 0) *--(*string) = _T('0');
|
||||
|
||||
/* Digits after the decimal point */
|
||||
num_digits = precision;
|
||||
while (num_digits-- > 0)
|
||||
{
|
||||
*--(*string) = digits[val64 % 10];
|
||||
val64 /= 10;
|
||||
*--(*string) = digits[(unsigned __int64)fpval2 % 10];
|
||||
fpval2 /= base;
|
||||
}
|
||||
}
|
||||
|
||||
if (precision > 0 || flags & FLAG_SPECIAL)
|
||||
*--(*string) = _T('.');
|
||||
|
||||
/* Digits before the decimal point */
|
||||
do
|
||||
{
|
||||
*--(*string) = digits[val64 % base];
|
||||
val64 /= base;
|
||||
*--(*string) = digits[(unsigned __int64)fpval2 % base];
|
||||
fpval2 /= base;
|
||||
}
|
||||
while (val64);
|
||||
while ((unsigned __int64)fpval2);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
static
|
||||
int
|
||||
streamout_char(FILE *stream, int chr)
|
||||
{
|
||||
/* Flush the buffer if neccessary */
|
||||
/* Check if the buffer is full */
|
||||
if (stream->_cnt < sizeof(TCHAR))
|
||||
{
|
||||
return _flsbuf(chr, stream) != EOF;
|
||||
#ifdef _USER32_WSPRINTF
|
||||
return _TEOF;
|
||||
#else
|
||||
/* Strings are done now */
|
||||
if (stream->_flag & _IOSTRG) return _TEOF;
|
||||
|
||||
/* Flush buffer for files */
|
||||
return _flsbuf(chr, stream) != _TEOF;
|
||||
#endif
|
||||
}
|
||||
|
||||
*(TCHAR*)stream->_ptr = chr;
|
||||
|
@ -270,6 +313,11 @@ streamout_wstring(FILE *stream, const wchar_t *string, int count)
|
|||
#define streamout_string streamout_astring
|
||||
#endif
|
||||
|
||||
#ifdef _USER32_WSPRINTF
|
||||
# define USE_MULTISIZE 0
|
||||
#else
|
||||
# define USE_MULTISIZE 1
|
||||
#endif
|
||||
|
||||
int
|
||||
_cdecl
|
||||
|
@ -363,21 +411,17 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr)
|
|||
else precision = -1;
|
||||
|
||||
/* Handle argument size prefix */
|
||||
while (1)
|
||||
do
|
||||
{
|
||||
if (chr == _T('h')) flags |= FLAG_SHORT;
|
||||
else if (chr == _T('w')) flags |= FLAG_WIDECHAR;
|
||||
else if (chr == _T('L')) flags |= 0; // FIXME: long double
|
||||
else if (chr == _T('F')) flags |= 0; // FIXME: what is that?
|
||||
else if (chr == _T('l'))
|
||||
{
|
||||
flags |= FLAG_LONG;
|
||||
#if SUPPORT_LL
|
||||
if (format[0] == _T('l'))
|
||||
{
|
||||
format++;
|
||||
flags |= FLAG_INT64;
|
||||
}
|
||||
#endif
|
||||
/* Check if this is the 2nd 'l' in a row */
|
||||
if (format[-2] == 'l') flags |= FLAG_INT64;
|
||||
else flags |= FLAG_LONG;
|
||||
}
|
||||
else if (chr == _T('I'))
|
||||
{
|
||||
|
@ -401,6 +445,7 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr)
|
|||
else break;
|
||||
chr = *format++;
|
||||
}
|
||||
while (USE_MULTISIZE);
|
||||
|
||||
/* Handle the format specifier */
|
||||
digits = digits_l;
|
||||
|
@ -479,8 +524,10 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr)
|
|||
else
|
||||
len = strlen((char*)string);
|
||||
if (precision >= 0 && len > precision) len = precision;
|
||||
precision = 0;
|
||||
break;
|
||||
|
||||
#ifndef _USER32_WSPRINTF
|
||||
case _T('G'):
|
||||
case _T('E'):
|
||||
case _T('A'):
|
||||
|
@ -498,6 +545,7 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr)
|
|||
len = _tcslen(string);
|
||||
precision = 0;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case _T('d'):
|
||||
case _T('i'):
|
||||
|
@ -517,9 +565,12 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr)
|
|||
|
||||
case _T('o'):
|
||||
base = 8;
|
||||
if (flags & FLAG_SPECIAL) prefix = _T("0");
|
||||
if (flags & FLAG_SPECIAL)
|
||||
{
|
||||
prefix = _T("0");
|
||||
if (precision > 0) precision--;
|
||||
}
|
||||
goto case_unsigned;
|
||||
/* Fall through */
|
||||
|
||||
case _T('p'):
|
||||
precision = 2 * sizeof(void*);
|
||||
|
@ -587,7 +638,7 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr)
|
|||
if (prefix)
|
||||
{
|
||||
written = streamout_string(stream, prefix, prefixlen);
|
||||
if (written == -1) return -3;
|
||||
if (written == -1) return -1;
|
||||
written_all += written;
|
||||
}
|
||||
|
||||
|
@ -604,7 +655,7 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr)
|
|||
written = streamout_wstring(stream, (wchar_t*)string, len);
|
||||
else
|
||||
written = streamout_astring(stream, (char*)string, len);
|
||||
if (written == -1) return -5;
|
||||
if (written == -1) return -1;
|
||||
written_all += written;
|
||||
|
||||
#if 0 && SUPPORT_FLOAT
|
||||
|
@ -629,7 +680,7 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr)
|
|||
|
||||
}
|
||||
|
||||
if (written == -1) return -8;
|
||||
if (written == -1) return -1;
|
||||
|
||||
return written_all;
|
||||
}
|
||||
|
|
|
@ -6,34 +6,8 @@
|
|||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
|
||||
int _cdecl wstreamout(FILE *stream, const wchar_t *format, va_list argptr);
|
||||
|
||||
int
|
||||
_cdecl
|
||||
swprintf(wchar_t *buffer, const wchar_t *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
int result;
|
||||
FILE stream;
|
||||
|
||||
stream._base = (char*)buffer;
|
||||
stream._ptr = stream._base;
|
||||
stream._charbuf = 0;
|
||||
stream._bufsiz = INT_MAX;
|
||||
stream._cnt = stream._bufsiz;
|
||||
stream._flag = 0;
|
||||
stream._tmpfname = 0;
|
||||
|
||||
va_start(argptr, format);
|
||||
result = wstreamout(&stream, format, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
*(wchar_t*)stream._ptr = '\0';
|
||||
return result;
|
||||
}
|
||||
|
||||
#define _sxprintf swprintf
|
||||
#define USE_COUNT 0
|
||||
#define _UNICODE
|
||||
|
||||
#include "_sxprintf.c"
|
||||
|
|
|
@ -6,32 +6,8 @@
|
|||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
#define _sxprintf vsprintf
|
||||
#define USE_COUNT 0
|
||||
#define USE_VARARGS 1
|
||||
|
||||
int _cdecl streamout(FILE *stream, const char *format, va_list argptr);
|
||||
|
||||
int
|
||||
__cdecl
|
||||
vsprintf(
|
||||
char *buffer,
|
||||
const char *format,
|
||||
va_list argptr)
|
||||
{
|
||||
int result;
|
||||
FILE stream;
|
||||
|
||||
stream._base = buffer;
|
||||
stream._ptr = stream._base;
|
||||
stream._charbuf = 0;
|
||||
stream._bufsiz = INT_MAX;
|
||||
stream._cnt = stream._bufsiz;
|
||||
stream._flag = _IOSTRG|_IOWRT|_IOMYBUF;
|
||||
stream._tmpfname = 0;
|
||||
|
||||
result = streamout(&stream, format, argptr);
|
||||
*stream._ptr = '\0';
|
||||
|
||||
return result;
|
||||
}
|
||||
#include "_sxprintf.c"
|
||||
|
|
|
@ -6,13 +6,9 @@
|
|||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
#define _sxprintf vswprintf
|
||||
#define USE_COUNT 0
|
||||
#define USE_VARARGS 1
|
||||
#define _UNICODE
|
||||
|
||||
int
|
||||
__cdecl
|
||||
vswprintf(wchar_t *buffer, const wchar_t *format, va_list argptr)
|
||||
{
|
||||
return _vsnwprintf(buffer, INT_MAX, format, argptr);
|
||||
}
|
||||
#include "_sxprintf.c"
|
||||
|
|
13
lib/sdk/crt/printf/wsprintfA.c
Normal file
13
lib/sdk/crt/printf/wsprintfA.c
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/wsprintfA.c
|
||||
* PURPOSE: Implementation of wsprintfA
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#define _sxprintf wsprintfA
|
||||
#define USE_COUNT 0
|
||||
#define USER32_WSPRINTF
|
||||
|
||||
#include "_sxprintf.c"
|
14
lib/sdk/crt/printf/wsprintfW.c
Normal file
14
lib/sdk/crt/printf/wsprintfW.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/wsprintfW.c
|
||||
* PURPOSE: Implementation of wsprintfW
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#define _sxprintf wsprintfW
|
||||
#define USE_COUNT 0
|
||||
#define _UNICODE
|
||||
#define USER32_WSPRINTF
|
||||
|
||||
#include "_sxprintf.c"
|
14
lib/sdk/crt/printf/wvsnprintfA.c
Normal file
14
lib/sdk/crt/printf/wvsnprintfA.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/wvsnprintfA.c
|
||||
* PURPOSE: Implementation of wvsnprintfA
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#define _sxprintf wvsnprintfA
|
||||
#define USE_COUNT 1
|
||||
#define USE_VARARGS 1
|
||||
#define USER32_WSPRINTF
|
||||
|
||||
#include "_sxprintf.c"
|
14
lib/sdk/crt/printf/wvsnprintfW.c
Normal file
14
lib/sdk/crt/printf/wvsnprintfW.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/wvsnprintfW.c
|
||||
* PURPOSE: Implementation of wvsnprintfW
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#define _sxprintf wvsnprintfW
|
||||
#define USE_COUNT 1
|
||||
#define USE_VARARGS 1
|
||||
#define USER32_WSPRINTF
|
||||
|
||||
#include "_sxprintf.c"
|
14
lib/sdk/crt/printf/wvsprintfA.c
Normal file
14
lib/sdk/crt/printf/wvsprintfA.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/wvsprintfA.c
|
||||
* PURPOSE: Implementation of wvsprintfA
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#define _sxprintf wvsprintfA
|
||||
#define USE_COUNT 0
|
||||
#define USE_VARARGS 1
|
||||
#define USER32_WSPRINTF
|
||||
|
||||
#include "_sxprintf.c"
|
14
lib/sdk/crt/printf/wvsprintfW.c
Normal file
14
lib/sdk/crt/printf/wvsprintfW.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/printf/wvsprintfW.c
|
||||
* PURPOSE: Implementation of wvsprintfW
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#define _sxprintf wvsprintfW
|
||||
#define USE_COUNT 0
|
||||
#define USE_VARARGS 1
|
||||
#define USER32_WSPRINTF
|
||||
|
||||
#include "_sxprintf.c"
|
82
lib/sdk/crt/stdio/_flsbuf.c
Normal file
82
lib/sdk/crt/stdio/_flsbuf.c
Normal file
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/stdio/_flsbuf.c
|
||||
* PURPOSE: Implementation of _flsbuf / _flswbuf
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <io.h>
|
||||
#include <tchar.h>
|
||||
|
||||
void __cdecl alloc_buffer(FILE *stream);
|
||||
|
||||
int __cdecl
|
||||
_flsbuf(int ch, FILE *stream)
|
||||
{
|
||||
int count, written;
|
||||
|
||||
/* Check if the stream supports flushing */
|
||||
if ((stream->_flag & _IOSTRG) || !(stream->_flag & (_IORW|_IOWRT)))
|
||||
{
|
||||
stream->_flag |= _IOERR;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
/* Is this was a read buffer */
|
||||
if (stream->_flag & _IOREAD)
|
||||
{
|
||||
/* Must be at the end of the file */
|
||||
if (!(stream->_flag & _IOEOF))
|
||||
{
|
||||
stream->_flag |= _IOERR;
|
||||
stream->_cnt = 0;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
/* Reset buffer */
|
||||
stream->_ptr = stream->_base;
|
||||
}
|
||||
|
||||
/* Fixup flags */
|
||||
stream->_flag &= ~(_IOREAD|_IOEOF);
|
||||
stream->_flag |= _IOWRT;
|
||||
|
||||
/* If we have no buffer, try to allocate one */
|
||||
if (!stream->_base && stream != stdout && stream != stderr)
|
||||
{
|
||||
alloc_buffer(stream);
|
||||
}
|
||||
|
||||
/* Check if we have a buffer now */
|
||||
if (stream->_base)
|
||||
{
|
||||
/* We have one, check if there is something to write */
|
||||
count = stream->_ptr - stream->_base;
|
||||
if (count > 0)
|
||||
written = _write(stream->_file, stream->_base, count);
|
||||
else
|
||||
written = 0;
|
||||
|
||||
/* Reset buffer and put the char into it */
|
||||
stream->_ptr = stream->_base + sizeof(TCHAR);
|
||||
stream->_cnt = stream->_bufsiz - sizeof(TCHAR);
|
||||
*(TCHAR*)stream->_base = ch;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* There is no buffer, write the char directly */
|
||||
count = sizeof(TCHAR);
|
||||
written = _write(stream->_file, &ch, sizeof(TCHAR));
|
||||
}
|
||||
|
||||
/* Check for failure */
|
||||
if (written != count)
|
||||
{
|
||||
stream->_flag |= _IOERR;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
return ch & (sizeof(TCHAR) > sizeof(char) ? 0xffff : 0xff);
|
||||
}
|
11
lib/sdk/crt/stdio/_flswbuf.c
Normal file
11
lib/sdk/crt/stdio/_flswbuf.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* COPYRIGHT: GNU GPL, see COPYING in the top level directory
|
||||
* PROJECT: ReactOS crt library
|
||||
* FILE: lib/sdk/crt/stdio/_flswbuf
|
||||
* PURPOSE: Implementation of _flswbuf
|
||||
* PROGRAMMER: Timo Kreuzer
|
||||
*/
|
||||
|
||||
#define _UNICODE
|
||||
#define _flsbuf _flswbuf
|
||||
#include "_flsbuf.c"
|
|
@ -409,7 +409,7 @@ static int flush_buffer(FILE* file)
|
|||
}
|
||||
|
||||
/* INTERNAL: Allocate stdio file buffer */
|
||||
static void alloc_buffer(FILE* file)
|
||||
void alloc_buffer(FILE* file)
|
||||
{
|
||||
file->_base = calloc(BUFSIZ,1);
|
||||
if(file->_base) {
|
||||
|
@ -2290,37 +2290,6 @@ int CDECL fputc(int c, FILE* file)
|
|||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* _flsbuf (MSVCRT.@)
|
||||
*/
|
||||
int CDECL _flsbuf(int c, FILE* file)
|
||||
{
|
||||
/* Flush output buffer */
|
||||
if(file->_bufsiz == 0 && !(file->_flag & _IONBF)) {
|
||||
alloc_buffer(file);
|
||||
}
|
||||
if(!(file->_flag & _IOWRT)) {
|
||||
if(file->_flag & _IORW) {
|
||||
file->_flag |= _IOWRT;
|
||||
} else {
|
||||
return EOF;
|
||||
}
|
||||
}
|
||||
if(file->_bufsiz) {
|
||||
int res=flush_buffer(file);
|
||||
return res?res : fputc(c, file);
|
||||
} else {
|
||||
unsigned char cc=c;
|
||||
int len;
|
||||
/* set _cnt to 0 for unbuffered FILEs */
|
||||
file->_cnt = 0;
|
||||
len = _write(file->_file, &cc, 1);
|
||||
if (len == 1) return c & 0xff;
|
||||
file->_flag |= _IOERR;
|
||||
return EOF;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* _fputchar (MSVCRT.@)
|
||||
*/
|
||||
|
@ -2814,142 +2783,6 @@ FILE* CDECL tmpfile(void)
|
|||
return file;
|
||||
}
|
||||
|
||||
#ifndef USE_NEW_SPRINTF
|
||||
/*********************************************************************
|
||||
* vfprintf (MSVCRT.@)
|
||||
*/
|
||||
int CDECL vfprintf(FILE* file, const char *format, va_list valist)
|
||||
{
|
||||
char buf[2048], *mem = buf;
|
||||
int written, resize = sizeof(buf), retval;
|
||||
/* There are two conventions for vsnprintf failing:
|
||||
* Return -1 if we truncated, or
|
||||
* Return the number of bytes that would have been written
|
||||
* The code below handles both cases
|
||||
*/
|
||||
while ((written = _vsnprintf(mem, resize, format, valist)) == -1 ||
|
||||
written > resize)
|
||||
{
|
||||
resize = (written == -1 ? resize * 2 : written + 1);
|
||||
if (mem != buf)
|
||||
free (mem);
|
||||
if (!(mem = malloc(resize)))
|
||||
return EOF;
|
||||
}
|
||||
retval = fwrite(mem, sizeof(*mem), written, file);
|
||||
if (mem != buf)
|
||||
free (mem);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* vfwprintf (MSVCRT.@)
|
||||
* FIXME:
|
||||
* Is final char included in written (then resize is too big) or not
|
||||
* (then we must test for equality too)?
|
||||
*/
|
||||
int CDECL vfwprintf(FILE* file, const wchar_t *format, va_list valist)
|
||||
{
|
||||
wchar_t buf[2048], *mem = buf;
|
||||
int written, resize = sizeof(buf) / sizeof(wchar_t), retval;
|
||||
/* See vfprintf comments */
|
||||
while ((written = _vsnwprintf(mem, resize, format, valist)) == -1 ||
|
||||
written > resize)
|
||||
{
|
||||
resize = (written == -1 ? resize * 2 : written + sizeof(wchar_t));
|
||||
if (mem != buf)
|
||||
free (mem);
|
||||
if (!(mem = malloc(resize*sizeof(*mem))))
|
||||
return EOF;
|
||||
}
|
||||
|
||||
/* Check if outputting to a text-file */
|
||||
if (fdesc[file->_file].wxflag & WX_TEXT)
|
||||
{
|
||||
/* Convert each character and stop at the first invalid character. Behavior verified by tests under WinXP SP2 */
|
||||
char chMultiByte[MB_LEN_MAX];
|
||||
int nReturn;
|
||||
wchar_t *p;
|
||||
|
||||
retval = 0;
|
||||
|
||||
for (p = mem; *p; p++)
|
||||
{
|
||||
nReturn = wctomb(chMultiByte, *p);
|
||||
|
||||
if(nReturn == -1)
|
||||
break;
|
||||
|
||||
retval += fwrite(chMultiByte, 1, nReturn, file);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
retval = fwrite(mem, sizeof(*mem), written, file);
|
||||
}
|
||||
|
||||
if (mem != buf)
|
||||
free (mem);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* vprintf (MSVCRT.@)
|
||||
*/
|
||||
int CDECL vprintf(const char *format, va_list valist)
|
||||
{
|
||||
return vfprintf(stdout,format,valist);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* vwprintf (MSVCRT.@)
|
||||
*/
|
||||
int CDECL vwprintf(const wchar_t *format, va_list valist)
|
||||
{
|
||||
return vfwprintf(stdout,format,valist);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* fprintf (MSVCRT.@)
|
||||
*/
|
||||
int CDECL fprintf(FILE* file, const char *format, ...)
|
||||
{
|
||||
va_list valist;
|
||||
int res;
|
||||
va_start(valist, format);
|
||||
res = vfprintf(file, format, valist);
|
||||
va_end(valist);
|
||||
return res;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* fwprintf (MSVCRT.@)
|
||||
*/
|
||||
int CDECL fwprintf(FILE* file, const wchar_t *format, ...)
|
||||
{
|
||||
va_list valist;
|
||||
int res;
|
||||
va_start(valist, format);
|
||||
res = vfwprintf(file, format, valist);
|
||||
va_end(valist);
|
||||
return res;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* printf (MSVCRT.@)
|
||||
*/
|
||||
int CDECL printf(const char *format, ...)
|
||||
{
|
||||
va_list valist;
|
||||
int res;
|
||||
va_start(valist, format);
|
||||
res = vfprintf(stdout, format, valist);
|
||||
va_end(valist);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
* ungetc (MSVCRT.@)
|
||||
*/
|
||||
|
@ -2986,21 +2819,6 @@ wint_t CDECL ungetwc(wint_t wc, FILE * file)
|
|||
return mwc;
|
||||
}
|
||||
|
||||
#ifndef USE_NEW_SPRINTF
|
||||
/*********************************************************************
|
||||
* wprintf (MSVCRT.@)
|
||||
*/
|
||||
int CDECL wprintf(const wchar_t *format, ...)
|
||||
{
|
||||
va_list valist;
|
||||
int res;
|
||||
va_start(valist, format);
|
||||
res = vwprintf(format, valist);
|
||||
va_end(valist);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
* _getmaxstdio (MSVCRT.@)
|
||||
*/
|
||||
|
|
|
@ -1,882 +0,0 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PURPOSE: CRT's vsnprintf
|
||||
* FILE: lib/sdk/crt/stdio/lnx_printf.c
|
||||
* PROGRAMERS: David Welch
|
||||
Eric Kohl
|
||||
Gregor Schneider
|
||||
* TODO:
|
||||
* - Verify the implementation of '%Z'.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Parts from linux/lib/vsprintf.c
|
||||
* Lars Wirzenius & Linus Torvalds
|
||||
* Wirzenius wrote this portably, Torvalds fucked it up :-)
|
||||
*/
|
||||
#ifndef USE_NEW_SPRINTF
|
||||
#include <precomp.h>
|
||||
|
||||
#include <wchar.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#define ZEROPAD 1 /* pad with zero */
|
||||
#define SIGN 2 /* unsigned/signed */
|
||||
#define PLUS 4 /* show plus */
|
||||
#define SPACE 8 /* space if plus */
|
||||
#define LEFT 16 /* left justified */
|
||||
#define SPECIAL 32 /* 0x */
|
||||
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
|
||||
#define ZEROTRUNC 128 /* truncate zero's */
|
||||
#define REMOVEHEX 256 /* remove 0x from BASE 16 */
|
||||
|
||||
static
|
||||
__inline
|
||||
int
|
||||
do_div(long long *n, int base)
|
||||
{
|
||||
int a;
|
||||
a = ((unsigned long long) *n) % (unsigned) base;
|
||||
*n = ((unsigned long long) *n) / (unsigned) base;
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
static int skip_atoi(const char **s)
|
||||
{
|
||||
int i=0;
|
||||
|
||||
while (isdigit(**s))
|
||||
i = i*10 + *((*s)++) - '0';
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
number(char * buf, char * end, long long num, int base, int size, int precision, int type)
|
||||
{
|
||||
char c,sign,tmp[66];
|
||||
const char *digits;
|
||||
const char *small_digits = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
const char *large_digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
int i;
|
||||
|
||||
digits = (type & LARGE) ? large_digits : small_digits;
|
||||
if (type & LEFT)
|
||||
type &= ~ZEROPAD;
|
||||
if (base < 2 || base > 36)
|
||||
return 0;
|
||||
c = (type & ZEROPAD) ? '0' : ' ';
|
||||
sign = 0;
|
||||
if (type & SIGN) {
|
||||
if (num < 0) {
|
||||
sign = '-';
|
||||
num = -num;
|
||||
size--;
|
||||
} else if (type & PLUS) {
|
||||
sign = '+';
|
||||
size--;
|
||||
} else if (type & SPACE) {
|
||||
sign = ' ';
|
||||
size--;
|
||||
}
|
||||
}
|
||||
|
||||
if ((type & SPECIAL) && ((type & REMOVEHEX) == 0)) {
|
||||
if (base == 16)
|
||||
size -= 2;
|
||||
}
|
||||
i = 0;
|
||||
if ((num == 0) && (precision !=0))
|
||||
tmp[i++] = '0';
|
||||
else while (num != 0)
|
||||
tmp[i++] = digits[do_div(&num,base)];
|
||||
if (i > precision)
|
||||
precision = i;
|
||||
size -= precision;
|
||||
if (!(type&(ZEROPAD+LEFT))) {
|
||||
while(size-->0) {
|
||||
if (buf <= end)
|
||||
*buf = ' ';
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
if (sign) {
|
||||
if (buf <= end)
|
||||
*buf = sign;
|
||||
++buf;
|
||||
}
|
||||
|
||||
if ((type & SPECIAL) && ((type & REMOVEHEX) == 0)) {
|
||||
if (base==16) {
|
||||
if (buf <= end)
|
||||
*buf = '0';
|
||||
++buf;
|
||||
if (buf <= end)
|
||||
*buf = digits[33];
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(type & LEFT)) {
|
||||
while (size-- > 0) {
|
||||
if (buf <= end)
|
||||
*buf = c;
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
while (i < precision--) {
|
||||
if (buf <= end)
|
||||
*buf = '0';
|
||||
++buf;
|
||||
}
|
||||
while (i-- > 0) {
|
||||
if (buf <= end)
|
||||
*buf = tmp[i];
|
||||
++buf;
|
||||
}
|
||||
while (size-- > 0) {
|
||||
if (buf <= end)
|
||||
*buf = ' ';
|
||||
++buf;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
unsigned int mantissal:32;
|
||||
unsigned int mantissah:20;
|
||||
unsigned int exponent:11;
|
||||
unsigned int sign:1;
|
||||
} ieee_double_t;
|
||||
|
||||
static __inline void fracrnd(double *number, int prec)
|
||||
{
|
||||
/* Shifts fractional digits to decimal places and compares to round table */
|
||||
/* Only suitable to determine the exponent with more precision, not for normal rounding */
|
||||
/* Incoming numbers are expected to range from approx -10.0 to 10.0 */
|
||||
int lpos = 1, ubound, sign = 1;
|
||||
long decimal = abs((long)*number);
|
||||
double frac = (*number - decimal) * 10;
|
||||
long rt[] =
|
||||
{
|
||||
0,
|
||||
9,
|
||||
99,
|
||||
999,
|
||||
9999,
|
||||
99999,
|
||||
999999,
|
||||
9999999,
|
||||
99999999,
|
||||
999999999
|
||||
};
|
||||
|
||||
if (*number < 0)
|
||||
{
|
||||
sign = -1;
|
||||
}
|
||||
ubound = min(prec, sizeof(rt)/sizeof(*rt) - 1);
|
||||
while ((long)frac % 10 != 0 && lpos < ubound)
|
||||
{
|
||||
frac *= 10;
|
||||
lpos++;
|
||||
}
|
||||
if (abs((long)frac) == rt[lpos])
|
||||
{
|
||||
*number = sign * (decimal + 1);
|
||||
}
|
||||
}
|
||||
|
||||
static char *
|
||||
numberf(char * buf, char * end, double num, char exp_sign, int size, int precision, int type)
|
||||
{
|
||||
double exponent = 0.0;
|
||||
double e = 0.0;
|
||||
long ie;
|
||||
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int ro = 0;
|
||||
int isize;
|
||||
|
||||
double num2, frac, intr;
|
||||
double p;
|
||||
|
||||
char c, sign, digits[66];
|
||||
char *tmp;
|
||||
|
||||
union
|
||||
{
|
||||
double* __n;
|
||||
ieee_double_t* n;
|
||||
} n;
|
||||
|
||||
n.__n = #
|
||||
|
||||
if ( exp_sign == 'g' || exp_sign == 'G' || exp_sign == 'e' || exp_sign == 'E' )
|
||||
{
|
||||
ie = ((unsigned int)n.n->exponent - (unsigned int)0x3ff);
|
||||
if (num != 0.0)
|
||||
{
|
||||
exponent = ie/3.321928;
|
||||
}
|
||||
}
|
||||
|
||||
if ( exp_sign == 'g' || exp_sign == 'G' )
|
||||
{
|
||||
type |= ZEROTRUNC;
|
||||
if ( exponent < -4 || fabs(exponent) >= precision )
|
||||
exp_sign -= 2; // g -> e and G -> E
|
||||
else
|
||||
exp_sign = 'f';
|
||||
if (type & SPECIAL) precision--;
|
||||
}
|
||||
|
||||
if ( exp_sign == 'e' || exp_sign == 'E' )
|
||||
{
|
||||
if (num != 0.0)
|
||||
{
|
||||
/* Find a suitable exponent */
|
||||
frac = modf(exponent, &e);
|
||||
num2 = num/pow(10.0L, (long double)e);
|
||||
/* Check if rounding is possible */
|
||||
fracrnd(&num2, precision);
|
||||
if (num2 < 1.0 && num2 > -1.0)
|
||||
{
|
||||
e--;
|
||||
}
|
||||
else if (num2 <= -10.0 || num2 >= 10.0)
|
||||
{
|
||||
e++;
|
||||
}
|
||||
}
|
||||
|
||||
/* size-5 because "e+abc" is going to follow */
|
||||
buf = numberf(buf, end, num/pow(10.0L,(long double)e), 'f', size-5, precision, type);
|
||||
isize = 4;
|
||||
while(*(buf-1) == ' ')
|
||||
{
|
||||
isize++;
|
||||
--buf;
|
||||
}
|
||||
|
||||
if (buf <= end)
|
||||
*buf = exp_sign;
|
||||
++buf;
|
||||
size--;
|
||||
|
||||
ie = (long)e;
|
||||
type = LEFT | SIGN | PLUS;
|
||||
buf = number(buf, end, ie, 10, isize, 3, type);
|
||||
return buf;
|
||||
}
|
||||
|
||||
if ( exp_sign == 'f' )
|
||||
{
|
||||
if (type & LEFT)
|
||||
type &= ~ZEROPAD;
|
||||
|
||||
c = (type & ZEROPAD) ? '0' : ' ';
|
||||
sign = 0;
|
||||
|
||||
if (num < 0)
|
||||
{
|
||||
sign = '-';
|
||||
num = fabs(num);
|
||||
size--;
|
||||
}
|
||||
else if (type & PLUS)
|
||||
{
|
||||
sign = '+';
|
||||
size--;
|
||||
}
|
||||
else if (type & SPACE)
|
||||
{
|
||||
sign = ' ';
|
||||
size--;
|
||||
}
|
||||
|
||||
frac = modf(num,&intr);
|
||||
|
||||
// # flags forces a . and prevents truncation of trailing zero's
|
||||
if ( precision > 0 )
|
||||
{
|
||||
i = precision-1;
|
||||
while ( i >= 0 )
|
||||
{
|
||||
frac*=10.0L;
|
||||
frac = modf(frac, &p);
|
||||
digits[i] = (int)p + '0';
|
||||
i--;
|
||||
}
|
||||
|
||||
i = precision;
|
||||
size -= precision;
|
||||
}
|
||||
|
||||
if ( precision >= 1 || type & SPECIAL)
|
||||
{
|
||||
digits[i++] = '.';
|
||||
size--;
|
||||
}
|
||||
|
||||
ro = 0;
|
||||
if ( frac > 0.5 )
|
||||
{
|
||||
ro = 1;
|
||||
}
|
||||
|
||||
if ( intr == 0.0 )
|
||||
{
|
||||
digits[i++] = '0';
|
||||
size--;
|
||||
}
|
||||
else
|
||||
{
|
||||
while ( intr > 0.0 )
|
||||
{
|
||||
p = intr;
|
||||
intr/=10.0L;
|
||||
modf(intr, &intr);
|
||||
|
||||
p -= 10.0*intr;
|
||||
|
||||
digits[i++] = (int)p + '0';
|
||||
size--;
|
||||
}
|
||||
}
|
||||
|
||||
j = 0;
|
||||
while ( j < i && ro == 1)
|
||||
{
|
||||
if ( digits[j] >= '0' && digits[j] <= '8' )
|
||||
{
|
||||
digits[j]++;
|
||||
ro = 0;
|
||||
}
|
||||
else if ( digits[j] == '9' )
|
||||
{
|
||||
digits[j] = '0';
|
||||
}
|
||||
j++;
|
||||
}
|
||||
if ( ro == 1 )
|
||||
digits[i++] = '1';
|
||||
|
||||
digits[i] = 0;
|
||||
|
||||
if (!(type & (ZEROPAD+LEFT)))
|
||||
{
|
||||
while(size-->0)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = ' ';
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
if (sign)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = sign;
|
||||
++buf;
|
||||
}
|
||||
|
||||
if (!(type & (ZEROPAD+LEFT)))
|
||||
{
|
||||
while(size-->0)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = ' ';
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(type & LEFT))
|
||||
{
|
||||
while (size-- > 0)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = c;
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
|
||||
tmp = digits;
|
||||
if ( type & ZEROTRUNC && ((type & SPECIAL) != SPECIAL) )
|
||||
{
|
||||
j = 0;
|
||||
while ( j < i && ( *tmp == '0' || *tmp == '.' ))
|
||||
{
|
||||
tmp++;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
while (i-- > 0)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = tmp[i];
|
||||
++buf;
|
||||
}
|
||||
while (size-- > 0)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = ' ';
|
||||
buf++;
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
static char*
|
||||
string(char* buf, char* end, const char* s, int len, int field_width, int precision, int flags)
|
||||
{
|
||||
int i;
|
||||
char c;
|
||||
|
||||
c = (flags & ZEROPAD) ? '0' : ' ';
|
||||
|
||||
if (s == NULL)
|
||||
{
|
||||
s = "<NULL>";
|
||||
len = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (len == -1)
|
||||
{
|
||||
len = 0;
|
||||
while ((unsigned int)len < (unsigned int)precision && s[len])
|
||||
len++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((unsigned int)len > (unsigned int)precision)
|
||||
len = precision;
|
||||
}
|
||||
}
|
||||
if (!(flags & LEFT))
|
||||
while (len < field_width--)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = c;
|
||||
++buf;
|
||||
}
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = *s++;
|
||||
++buf;
|
||||
}
|
||||
while (len < field_width--)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = ' ';
|
||||
++buf;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
static char*
|
||||
stringw(char* buf, char* end, const wchar_t* sw, int len, int field_width, int precision, int flags)
|
||||
{
|
||||
int i;
|
||||
char c;
|
||||
|
||||
c = (flags & ZEROPAD) ? '0' : ' ';
|
||||
|
||||
if (sw == NULL)
|
||||
{
|
||||
sw = L"<NULL>";
|
||||
len = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (len == -1)
|
||||
{
|
||||
len = 0;
|
||||
while ((unsigned int)len < (unsigned int)precision && sw[len])
|
||||
len++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((unsigned int)len > (unsigned int)precision)
|
||||
len = precision;
|
||||
}
|
||||
}
|
||||
if (!(flags & LEFT))
|
||||
while (len < field_width--)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = c;
|
||||
buf++;
|
||||
}
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = (unsigned char)(*sw++);
|
||||
buf++;
|
||||
}
|
||||
while (len < field_width--)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = ' ';
|
||||
buf++;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int __cdecl lnx_vsnprintf(char *buf, size_t cnt, const char *fmt, va_list args)
|
||||
{
|
||||
int len;
|
||||
unsigned long long num;
|
||||
double _double;
|
||||
|
||||
int base;
|
||||
char *str, *end;
|
||||
const char *s;
|
||||
const wchar_t *sw;
|
||||
|
||||
int flags; /* flags to number() */
|
||||
|
||||
int field_width; /* width of output field */
|
||||
int precision; /* min. # of digits for integers; max
|
||||
number of chars for from string */
|
||||
int qualifier; /* 'h', 'l', 'L', 'I' or 'w' for integer fields */
|
||||
|
||||
str = buf;
|
||||
end = buf + cnt - 1;
|
||||
if (end < buf - 1) {
|
||||
end = ((char *) -1);
|
||||
cnt = end - buf + 1;
|
||||
}
|
||||
|
||||
for ( ; *fmt ; ++fmt) {
|
||||
if (*fmt != '%') {
|
||||
if (str <= end)
|
||||
*str = *fmt;
|
||||
++str;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* process flags */
|
||||
flags = 0;
|
||||
repeat:
|
||||
++fmt; /* this also skips first '%' */
|
||||
switch (*fmt) {
|
||||
case '-': flags |= LEFT; goto repeat;
|
||||
case '+': flags |= PLUS; goto repeat;
|
||||
case ' ': flags |= SPACE; goto repeat;
|
||||
case '#': flags |= SPECIAL; goto repeat;
|
||||
case '0': flags |= ZEROPAD; goto repeat;
|
||||
}
|
||||
|
||||
/* get field width */
|
||||
field_width = -1;
|
||||
if (isdigit(*fmt))
|
||||
field_width = skip_atoi(&fmt);
|
||||
else if (*fmt == '*') {
|
||||
++fmt;
|
||||
/* it's the next argument */
|
||||
field_width = va_arg(args, int);
|
||||
if (field_width < 0) {
|
||||
field_width = -field_width;
|
||||
flags |= LEFT;
|
||||
}
|
||||
}
|
||||
|
||||
/* get the precision */
|
||||
precision = -1;
|
||||
if (*fmt == '.') {
|
||||
++fmt;
|
||||
if (isdigit(*fmt))
|
||||
precision = skip_atoi(&fmt);
|
||||
else if (*fmt == '*') {
|
||||
++fmt;
|
||||
/* it's the next argument */
|
||||
precision = va_arg(args, int);
|
||||
}
|
||||
if (precision < 0)
|
||||
precision = 0;
|
||||
}
|
||||
|
||||
/* get the conversion qualifier */
|
||||
qualifier = -1;
|
||||
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt == 'w') {
|
||||
qualifier = *fmt;
|
||||
++fmt;
|
||||
} else if (*fmt == 'I' && *(fmt+1) == '6' && *(fmt+2) == '4') {
|
||||
qualifier = *fmt;
|
||||
fmt += 3;
|
||||
} else if (*fmt == 'I' && *(fmt+1) == '3' && *(fmt+2) == '2') {
|
||||
qualifier = 'l';
|
||||
fmt += 3;
|
||||
} else if (*fmt == 'F' && *(fmt+1) == 'p') {
|
||||
fmt += 1;
|
||||
flags |= REMOVEHEX;
|
||||
}
|
||||
|
||||
/* default base */
|
||||
base = 10;
|
||||
|
||||
switch (*fmt) {
|
||||
case 'c': /* finished */
|
||||
if (qualifier == 'l' || qualifier == 'w') {
|
||||
wchar_t sw1[2];
|
||||
/* print unicode string */
|
||||
sw1[0] = (wchar_t) va_arg(args, int);
|
||||
sw1[1] = 0;
|
||||
str = stringw(str, end, (wchar_t *)&sw1, -1, field_width, precision, flags);
|
||||
} else {
|
||||
char s1[2];
|
||||
/* print ascii string */
|
||||
s1[0] = ( unsigned char) va_arg(args, int);
|
||||
s1[1] = 0;
|
||||
str = string(str, end, (char *)&s1, -1, field_width, precision, flags);
|
||||
}
|
||||
continue;
|
||||
|
||||
case 'C': /* finished */
|
||||
if (!(flags & LEFT))
|
||||
while (--field_width > 0) {
|
||||
if (str <= end)
|
||||
*str = ' ';
|
||||
++str;
|
||||
}
|
||||
if (qualifier == 'h') {
|
||||
if (str <= end)
|
||||
*str = (unsigned char) va_arg(args, int);
|
||||
++str;
|
||||
} else {
|
||||
if (str <= end)
|
||||
*str = (unsigned char)(wchar_t) va_arg(args, int);
|
||||
++str;
|
||||
}
|
||||
while (--field_width > 0) {
|
||||
if (str <= end)
|
||||
*str = ' ';
|
||||
++str;
|
||||
}
|
||||
continue;
|
||||
|
||||
case 's': /* finished */
|
||||
if (qualifier == 'l' || qualifier == 'w') {
|
||||
/* print unicode string */
|
||||
sw = va_arg(args, wchar_t *);
|
||||
str = stringw(str, end, sw, -1, field_width, precision, flags);
|
||||
} else {
|
||||
/* print ascii string */
|
||||
s = va_arg(args, char *);
|
||||
str = string(str, end, s, -1, field_width, precision, flags);
|
||||
}
|
||||
continue;
|
||||
|
||||
case 'S':
|
||||
if (qualifier == 'h') {
|
||||
/* print ascii string */
|
||||
s = va_arg(args, char *);
|
||||
str = string(str, end, s, -1, field_width, precision, flags);
|
||||
} else {
|
||||
/* print unicode string */
|
||||
sw = va_arg(args, wchar_t *);
|
||||
str = stringw(str, end, sw, -1, field_width, precision, flags);
|
||||
}
|
||||
continue;
|
||||
|
||||
case 'Z':
|
||||
if (qualifier == 'w') {
|
||||
/* print counted unicode string */
|
||||
PUNICODE_STRING pus = va_arg(args, PUNICODE_STRING);
|
||||
if ((pus == NULL) || (pus->Buffer == NULL)) {
|
||||
sw = NULL;
|
||||
len = -1;
|
||||
} else {
|
||||
sw = pus->Buffer;
|
||||
len = pus->Length / sizeof(WCHAR);
|
||||
}
|
||||
str = stringw(str, end, sw, len, field_width, precision, flags);
|
||||
} else {
|
||||
/* print counted ascii string */
|
||||
PANSI_STRING pus = va_arg(args, PANSI_STRING);
|
||||
if ((pus == NULL) || (pus->Buffer == NULL)) {
|
||||
s = NULL;
|
||||
len = -1;
|
||||
} else {
|
||||
s = pus->Buffer;
|
||||
len = pus->Length;
|
||||
}
|
||||
str = string(str, end, s, len, field_width, precision, flags);
|
||||
}
|
||||
continue;
|
||||
|
||||
case 'p':
|
||||
if ((flags & LARGE) == 0)
|
||||
flags |= LARGE;
|
||||
|
||||
if (field_width == -1) {
|
||||
field_width = 2 * sizeof(void *);
|
||||
flags |= ZEROPAD;
|
||||
}
|
||||
str = number(str, end,
|
||||
(uintptr_t) va_arg(args, void *), 16,
|
||||
field_width, precision, flags);
|
||||
continue;
|
||||
|
||||
case 'n':
|
||||
/* FIXME: What does C99 say about the overflow case here? */
|
||||
if (qualifier == 'l') {
|
||||
long * ip = va_arg(args, long *);
|
||||
*ip = (str - buf);
|
||||
} else {
|
||||
int * ip = va_arg(args, int *);
|
||||
*ip = (str - buf);
|
||||
}
|
||||
continue;
|
||||
|
||||
/* float number formats - set up the flags and "break" */
|
||||
case 'e':
|
||||
case 'E':
|
||||
case 'f':
|
||||
case 'g':
|
||||
case 'G':
|
||||
_double = (double)va_arg(args, double);
|
||||
if ( _isnan(_double) ) {
|
||||
s = "Nan";
|
||||
len = 3;
|
||||
while ( len > 0 ) {
|
||||
if (str <= end)
|
||||
*str = *s++;
|
||||
++str;
|
||||
len --;
|
||||
}
|
||||
} else if ( _isinf(_double) < 0 ) {
|
||||
s = "-Inf";
|
||||
len = 4;
|
||||
while ( len > 0 ) {
|
||||
if (str <= end)
|
||||
*str = *s++;
|
||||
++str;
|
||||
len --;
|
||||
}
|
||||
} else if ( _isinf(_double) > 0 ) {
|
||||
s = "+Inf";
|
||||
len = 4;
|
||||
while ( len > 0 ) {
|
||||
if (str <= end)
|
||||
*str = *s++;
|
||||
++str;
|
||||
len --;
|
||||
}
|
||||
} else {
|
||||
if ( precision == -1 )
|
||||
precision = 6;
|
||||
str = numberf(str, end, _double, *fmt, field_width, precision, flags);
|
||||
}
|
||||
continue;
|
||||
|
||||
/* integer number formats - set up the flags and "break" */
|
||||
case 'o':
|
||||
base = 8;
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
base = 2;
|
||||
break;
|
||||
|
||||
case 'X':
|
||||
flags |= LARGE;
|
||||
case 'x':
|
||||
base = 16;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
case 'i':
|
||||
flags |= SIGN;
|
||||
case 'u':
|
||||
break;
|
||||
|
||||
default:
|
||||
if (*fmt) {
|
||||
if (str <= end)
|
||||
*str = *fmt;
|
||||
++str;
|
||||
} else
|
||||
--fmt;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (qualifier == 'I')
|
||||
num = va_arg(args, unsigned long long);
|
||||
else if (qualifier == 'l') {
|
||||
if (flags & SIGN)
|
||||
num = va_arg(args, long);
|
||||
else
|
||||
num = va_arg(args, unsigned long);
|
||||
}
|
||||
else if (qualifier == 'h') {
|
||||
if (flags & SIGN)
|
||||
num = va_arg(args, int);
|
||||
else
|
||||
num = va_arg(args, unsigned int);
|
||||
}
|
||||
else {
|
||||
if (flags & SIGN)
|
||||
num = va_arg(args, int);
|
||||
else
|
||||
num = va_arg(args, unsigned int);
|
||||
}
|
||||
str = number(str, end, num, base, field_width, precision, flags);
|
||||
}
|
||||
if (str <= end)
|
||||
*str = '\0';
|
||||
else if (cnt > 0)
|
||||
/* don't write out a null byte if the buf size is zero */
|
||||
*end = '\0';
|
||||
return str-buf;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int lnx_sprintf(char * buf, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int i;
|
||||
|
||||
va_start(args, fmt);
|
||||
i=lnx_vsnprintf(buf,MAXLONG,fmt,args);
|
||||
va_end(args);
|
||||
return i;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _snprintf(char * buf, size_t cnt, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int i;
|
||||
|
||||
va_start(args, fmt);
|
||||
i=_vsnprintf(buf,cnt,fmt,args);
|
||||
va_end(args);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int __cdecl vsprintf(char *buf, const char *fmt, va_list args)
|
||||
{
|
||||
return _vsnprintf(buf,MAXLONG,fmt,args);
|
||||
}
|
||||
#endif
|
||||
/* EOF */
|
||||
#endif
|
|
@ -18,6 +18,7 @@ _ecvt (double value, int ndigits, int *decpt, int *sign)
|
|||
static char ecvtbuf[DBL_MAX_10_EXP + 10];
|
||||
char *cvtbuf, *s, *d;
|
||||
|
||||
if (ndigits < 0) ndigits = 0;
|
||||
s = cvtbuf = (char*)malloc(ndigits + NUMBER_EFMT);
|
||||
d = ecvtbuf;
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue