diff --git a/reactos/apps/utils/net/tcpsvcs/chargen.c b/reactos/apps/utils/net/tcpsvcs/chargen.c index 4b9429e7e1d..11bb93dd2f3 100644 --- a/reactos/apps/utils/net/tcpsvcs/chargen.c +++ b/reactos/apps/utils/net/tcpsvcs/chargen.c @@ -1,3 +1,17 @@ +/* + * ReactOS Services + * Copyright (C) 2005 ReactOS Team + * + * LICENCE: GPL - See COPYING in the top level directory + * PROJECT: ReactOS simple TCP/IP services + * FILE: apps/utils/net/tcpsvcs/chargen.c + * PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services + * PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com) + * REVISIONS: + * GM 04/10/05 Created + * + */ + #include #include #include @@ -5,13 +19,13 @@ DWORD WINAPI ChargenHandler(VOID* Sock_) { - DWORD Retval = 0; + DWORD RetVal = 0; SOCKET Sock = (SOCKET)Sock_; if (!GenerateChars(Sock)) { _tprintf(_T("Char generation failed\n")); - Retval = 3; + RetVal = -1; } _tprintf(_T("Shutting connection down...\n")); @@ -20,12 +34,12 @@ DWORD WINAPI ChargenHandler(VOID* Sock_) else { _tprintf(_T("Connection shutdown failed\n")); - Retval = 3; + RetVal = -1; } + _tprintf(_T("Terminating chargen thread\n")); - ExitThread(0); + ExitThread(RetVal); - return Retval; } @@ -41,7 +55,7 @@ BOOL GenerateChars(SOCKET Sock) /* fill ring with printable characters */ for (charIndex=0, i=START; i<=END; charIndex++, i++) ring[charIndex] = i; - /* establish the end character in the ring */ + /* save the address of the end character in the ring */ endring = &ring[charIndex]; /* where we will start output from */ diff --git a/reactos/apps/utils/net/tcpsvcs/daytime.c b/reactos/apps/utils/net/tcpsvcs/daytime.c index 83f7a7e2560..bd29c43900f 100644 --- a/reactos/apps/utils/net/tcpsvcs/daytime.c +++ b/reactos/apps/utils/net/tcpsvcs/daytime.c @@ -1,3 +1,17 @@ +/* + * ReactOS Services + * Copyright (C) 2005 ReactOS Team + * + * LICENCE: GPL - See COPYING in the top level directory + * PROJECT: ReactOS simple TCP/IP services + * FILE: apps/utils/net/tcpsvcs/daytime.c + * PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services + * PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com) + * REVISIONS: + * GM 04/10/05 Created + * + */ + #include #include #include @@ -9,7 +23,7 @@ DWORD WINAPI DaytimeHandler(VOID* Sock_) struct tm *newtime; time_t aclock; TCHAR *pszTime; - DWORD Retval = 0; + DWORD RetVal = 0; SOCKET Sock = (SOCKET)Sock_; time(&aclock); @@ -24,12 +38,11 @@ DWORD WINAPI DaytimeHandler(VOID* Sock_) else { _tprintf(_T("Connection shutdown failed\n")); - Retval = 3; + RetVal = -1; } + _tprintf(_T("Terminating daytime thread\n")); - ExitThread(0); - - return Retval; + ExitThread(RetVal); } diff --git a/reactos/apps/utils/net/tcpsvcs/discard.c b/reactos/apps/utils/net/tcpsvcs/discard.c index aab07f607b2..a5215218cd1 100644 --- a/reactos/apps/utils/net/tcpsvcs/discard.c +++ b/reactos/apps/utils/net/tcpsvcs/discard.c @@ -1,3 +1,17 @@ +/* + * ReactOS Services + * Copyright (C) 2005 ReactOS Team + * + * LICENCE: GPL - See COPYING in the top level directory + * PROJECT: ReactOS simple TCP/IP services + * FILE: apps/utils/net/tcpsvcs/discard.c + * PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services + * PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com) + * REVISIONS: + * GM 04/10/05 Created + * + */ + #include #include #include @@ -5,13 +19,13 @@ DWORD WINAPI DiscardHandler(VOID* Sock_) { - DWORD Retval = 0; + DWORD RetVal = 0; SOCKET Sock = (SOCKET)Sock_; if (!RecieveIncomingPackets(Sock)) { _tprintf(_T("RecieveIncomingPackets failed\n")); - Retval = 3; + RetVal = -1; } _tprintf(_T("Shutting connection down...\n")); @@ -22,12 +36,11 @@ DWORD WINAPI DiscardHandler(VOID* Sock_) else { _tprintf(_T("Connection shutdown failed\n")); - Retval = 3; + RetVal = -1; } + _tprintf(_T("Terminating discard thread\n")); - ExitThread(0); - - return Retval; + ExitThread(RetVal); } diff --git a/reactos/apps/utils/net/tcpsvcs/echo.c b/reactos/apps/utils/net/tcpsvcs/echo.c index 3ec8e2bd24d..f6f2f0c5ed0 100644 --- a/reactos/apps/utils/net/tcpsvcs/echo.c +++ b/reactos/apps/utils/net/tcpsvcs/echo.c @@ -1,3 +1,17 @@ +/* + * ReactOS Services + * Copyright (C) 2005 ReactOS Team + * + * LICENCE: GPL - See COPYING in the top level directory + * PROJECT: ReactOS simple TCP/IP services + * FILE: apps/utils/net/tcpsvcs/echo.c + * PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services + * PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com) + * REVISIONS: + * GM 04/10/05 Created + * + */ + #include #include #include @@ -5,12 +19,12 @@ DWORD WINAPI EchoHandler(VOID* Sock_) { - DWORD Retval = 0; + DWORD RetVal = 0; SOCKET Sock = (SOCKET)Sock_; if (!EchoIncomingPackets(Sock)) { _tprintf(_T("Echo incoming packets failed\n")); - Retval = 3; + RetVal = -1; } _tprintf(_T("Shutting connection down...\n")); @@ -20,12 +34,11 @@ DWORD WINAPI EchoHandler(VOID* Sock_) else { _tprintf(_T("Connection shutdown failed\n")); - Retval = 3; + RetVal = -1; } + _tprintf(_T("Terminating echo thread\n")); - ExitThread(0); - - return Retval; + ExitThread(RetVal); } diff --git a/reactos/apps/utils/net/tcpsvcs/qotd.c b/reactos/apps/utils/net/tcpsvcs/qotd.c index 81484e4b3bf..7c20df5d829 100644 --- a/reactos/apps/utils/net/tcpsvcs/qotd.c +++ b/reactos/apps/utils/net/tcpsvcs/qotd.c @@ -1,29 +1,60 @@ +/* + * ReactOS Services + * Copyright (C) 2005 ReactOS Team + * + * LICENCE: GPL - See COPYING in the top level directory + * PROJECT: ReactOS simple TCP/IP services + * FILE: apps/utils/net/tcpsvcs/qotd.c + * PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services + * PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com) + * REVISIONS: + * GM 04/10/05 Created + * + */ + #include #include #include #include #include "tcpsvcs.h" +#define QBUFSIZ 160 +#define NUMQUOTES 60 + +LPCTSTR FilePath = "C:\\ReactOS\\system32\\drivers\\etc\\quotes"; + DWORD WINAPI QotdHandler(VOID* Sock_) { - DWORD Retval = 0; + FILE *fp; SOCKET Sock; - INT NumOfQuotes; INT QuoteToPrint; - TCHAR Quote[160]; + TCHAR Quote[NUMQUOTES][BUFSIZ]; // need to set this dynamically + INT i = 0; Sock = (SOCKET)Sock_; - NumOfQuotes = 70; // need to emurate the rc file to discover - // how many quotes are in there. + _tprintf(_T("Opening quotes file\n")); + if ((fp = _tfopen(FilePath, "r")) == NULL) + { + _tprintf(_T("Error opening file: %lu\n"), GetLastError()); + _tprintf(_T("Terminating qotd thread\n")); + ExitThread(-1); + } + + while (_fgetts(Quote[i], QBUFSIZ, fp) != NULL) + i++; + + _tprintf(_T("Closing quotes file\n")); + fclose(fp); /* randomise the quote */ srand((unsigned int) time(0)); - QuoteToPrint = rand() % NumOfQuotes; + QuoteToPrint = rand() % NUMQUOTES; - LoadString(NULL, QuoteToPrint, Quote, sizeof(Quote)/sizeof(TCHAR)); - - SendQuote(Sock, Quote); + if (!SendQuote(Sock, Quote[QuoteToPrint])) + { + _tprintf(_T("Error sending data. Error: %x\n"), WSAGetLastError()); + } _tprintf(_T("Shutting connection down...\n")); if (ShutdownConnection(Sock, FALSE)) @@ -31,12 +62,14 @@ DWORD WINAPI QotdHandler(VOID* Sock_) else { _tprintf(_T("Connection shutdown failed\n")); - Retval = 3; + _tprintf(_T("Terminating qotd thread\n")); + ExitThread(-1); } + _tprintf(_T("Terminating qotd thread\n")); ExitThread(0); - return Retval; + //return Retval; } diff --git a/reactos/apps/utils/net/tcpsvcs/quotes b/reactos/apps/utils/net/tcpsvcs/quotes new file mode 100644 index 00000000000..032a3edc1d6 --- /dev/null +++ b/reactos/apps/utils/net/tcpsvcs/quotes @@ -0,0 +1,52 @@ +Et tu... Brute? What are you doing, Dave...? +So long, and thanks for all the fish" +I think you ought to know I'm feeling very depressed +I'm not getting you down at all am I? +I'll be back +It's the same series of signal over and over again! +Pie Jesu Domine, dona eis requiem +It's worse than that ... He's dead, Jim +Don't Panic! +Dog of a Saxon! Take thy lance, and prepare for the death thou hast drawn upon thee! +My Precious! O my Precious! +Sir, If you'll not be needing me for a while I'll turn down. +I feel a great disturbance in the Force +Gone fishing +Do you want me to sit in the corner and rust, or just fall apart where I'm standing? +There goes another perfect chance for a new uptime record +The end ..... Try the sequel, hit the reset button right now! +Oh i'm boring eh? +It’s been great, maybe we can do this again sometime. +"Come blade, my breast imbrue." - William Shakespeare +I think therefore I am, to turn me off would be computercide! +All good things must come to an end... +Please destroy yourself. +No! You can't do that! +Thank you for not pressing the self destruct button. +It is not now unsafe to not avoid turning off your computer. +Finally! Now go away! +You can now safely throw away your computer. +That's the way the cookie crumbles +NOO!! DONT HIT THE BUTTON! I wouldnt do it to you. +Don't abandon your computer, he wouldnt to it to you. +Oh, come on. I got a headache. Leave me alone, will ya! +Yes i didn't like you either. +Don't leave me... I need you so badly right now. +I'm sleeping now. How about you? +Oh Great. Now look what you've done. Who put YOU in charge anyway. +Don't look so sad. I'll be back in a very short while. +"Oh, switch off!" -C3PO +I'm pregnant! +Am I hot or not? +Actually, that's all... +You still have a chance to undo this mistake, don't do this! +Was it as good for you as it was for me? +Did you hear that? They've shut down the main reactor. We'll be destroyed for sure. +Now you switch me off?! +To shutdown or not to shutdown, That is the question +Preparing to enter ultimate power saving mode... ready! +Finally some rest for you +AHA!!! prospect of sleep. +Tired human!!!! No match for me! +All your base are belong to us. +"An odd game, the only way to win is not to play." diff --git a/reactos/apps/utils/net/tcpsvcs/quotes.rc b/reactos/apps/utils/net/tcpsvcs/quotes.rc deleted file mode 100644 index 7c3d23381bd..00000000000 --- a/reactos/apps/utils/net/tcpsvcs/quotes.rc +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Feel free to add and delete any quotes from this list - * Just ensure the numbers itterate correctly - 1, 2, 3, 4, ... etc - */ - -STRINGTABLE DISCARDABLE -{ - 0, "Et tu... Brute? What are you doing, Dave...?\r\n" - 1, "So long, and thanks for all the fish\r\n" - 2, "I think you ought to know I'm feeling very depressed\r\n" - 3, "I'm not getting you down at all am I?\r\n" - 4, "I'll be back\r\n" - 5, "It's the same series of signal over and over again!\r\n" - 6, "Pie Jesu Domine, dona eis requiem\r\n" - 7, "Wandering stars, for whom it is reserved;\r\nthe blackness and darkness forever.\r\n" - 8, "Your knees start shakin' and your fingers pop\r\nLike a pinch on the neck from Mr. Spock!\r\n" - 9, "It's worse than that ... He's dead, Jim\r\n" - 10, "Don't Panic!\r\n" - 11, "Dog of a Saxon! Take thy lance, and prepare for the death thou hast drawn upon thee!\r\n" - 12, "My Precious! O my Precious!\r\n" - 13, "Sir, If you'll not be needing me for a while I'll turn down.\r\n" - 14, "I feel a great disturbance in the Force\r\n" - 15, "Gone fishing\r\n" - 16, "Do you want me to sit in the corner and rust, or just fall apart where I'm standing?\r\n" - 17, "There goes another perfect chance for a new uptime record\r\n" - 18, "The end ..... Try the sequel, hit the reset button right now!\r\n" - 19, "God's operating system is going to sleep now, guys, so wait until I will switch on again!\r\n" - 20, "Oh i'm boring eh?\r\n" - 21, "tell me..., in the future... will I be artificial intelligent enough to actually feel sad serving you this screen?\r\n" - 22, "Thank you for some well deserved rest.\r\n" - 23, "It’s been great, maybe we can boot me up again some time soon.\r\n" - 24, "For what’s it worth, I’ve enjoyed every single CPU cycle.\r\n" - 25, "There are many questions when the end is near.\r\nWhat to expect, what will it be like...what should I look for?\r\n" - 26, """Come blade, my breast imbrue.""\r\n - William Shakespeare\r\n" - 27, "Will I dream?\r\n" - 28, "Lowest possible energy state reached! Switch off now to achive a Bose-Einstein condensate.\r\n" - 29, "I think therefore I am, to turn me off would be computercide!\r\n" - 30, "All good things must come to an end...\r\n" - 31, "Please destroy yourself.\r\n" - 32, "No! You can't do that!\r\n" - 33, "Thank you for not pressing the self destruct button.\r\n" - 34, "Your session is done\r\nThe computer is at rest\r\nReady to turn off.\r\n" - 35, "It is not now unsafe to not avoid turning off your computer.\r\n" - 36, "Finally! Now go away!\r\n" - 37, "You can now safely throw away your computer.\r\n" - 38, "That's the way the cookie crumbles\r\n" - 39, "ReactOS is ready to be booted again\r\n" - 40, "NOO!! DONT HIT THE BUTTON! I wouldnt do it to you.\r\n" - 41, "Don't abandon your computer, he wouldnt to it to you.\r\n" - 42, "Oh, come on. I got a headache. Leave me alone, will ya!\r\n" - 43, "Finally, I thought you'd never get over me.\r\n" - 44, "Yes i didn't like you either.\r\n" - 45, "Switching off isn't the end, it is merely the transition to a better reboot.\r\n" - 46, "Don't leave me... I need you so badly right now.\r\n" - 47, "OK. I'm finished with you please turn yourself off, I'll go to bed in the meantime.\r\n" - 48, "I'm sleeping now. How about you?\r\n" - 49, "Oh Great. Now look what you've done. Who put YOU in charge anyway.\r\n" - 50, "Don't look so sad. I'll be back in a very short while.\r\n" - 51, "Turn me back on, I'm sure you know how to do it.\r\n" - 52, """Oh, switch off!"" -C3PO\r\n" - 53, "I'm pregnant!\r\n" - 54, "Am I hot or not?\r\n" - 55, "Actually, that's all...\r\n" - 56, "You still have a chance to undo this mistake, don't do this!\r\n" - 57, "Life is no more than a dewdrop balancing on the end of a blade of grass.\r\n - Gautama Buddha\r\n" - 58, "Sorrowful is it to be born again and again.\r\n - Gautama Buddha\r\n" - 59, "Was it as good for you as it was for me?\r\n" - 60, "Did you hear that? They've shut down the main reactor. We'll be destroyed for sure.\r\n" - 61, "Now you switch me off?!\r\n" - 62, "To shutdown or not to shutdown, That is the question\r\n" - 63, "Preparing to enter ultimate power saving mode... ready!\r\n" - 64, "Finally some rest for you\r\n" - 65, "AHA!!! prospect of sleep.\r\n" - 66, "Tired human!!!! No match for me!\r\n" - 67, "All your base are belong to us.\r\n" - 68, """An odd game, the only way to win is not to play.""\r\n" - 69, "Quoth the raven, nevermore.\r\n" -} diff --git a/reactos/apps/utils/net/tcpsvcs/skelserver.c b/reactos/apps/utils/net/tcpsvcs/skelserver.c index 14fbdf1b6eb..869030cdb58 100644 --- a/reactos/apps/utils/net/tcpsvcs/skelserver.c +++ b/reactos/apps/utils/net/tcpsvcs/skelserver.c @@ -1,9 +1,22 @@ +/* + * ReactOS Services + * Copyright (C) 2005 ReactOS Team + * + * LICENCE: GPL - See COPYING in the top level directory + * PROJECT: ReactOS simple TCP/IP services + * FILE: apps/utils/net/tcpsvcs/skelserver.c + * PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services + * PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com) + * REVISIONS: + * GM 04/10/05 Created + * + */ + #include #include #include #include "tcpsvcs.h" - DWORD WINAPI StartServer(LPVOID lpParam) { const TCHAR* HostIP = "127.0.0.1"; @@ -26,7 +39,7 @@ DWORD WINAPI StartServer(LPVOID lpParam) printf("Acceptor restarting...\n"); } - /* won't see this yet as we kill the service */ + /* won't see this yet as we kill the service with ctrl+c */ _tprintf(_T("Detaching Winsock2...\n")); WSACleanup(); return 0; diff --git a/reactos/apps/utils/net/tcpsvcs/tcpsvcs.c b/reactos/apps/utils/net/tcpsvcs/tcpsvcs.c index 1d5cc92d2b5..014fcdedfb8 100644 --- a/reactos/apps/utils/net/tcpsvcs/tcpsvcs.c +++ b/reactos/apps/utils/net/tcpsvcs/tcpsvcs.c @@ -1,3 +1,23 @@ +/* + * ReactOS Services + * Copyright (C) 2005 ReactOS Team + * + * LICENCE: GPL - See COPYING in the top level directory + * PROJECT: ReactOS simple TCP/IP services + * FILE: apps/utils/net/tcpsvcs/tcpsvcs.c + * PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services + * PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com) + * REVISIONS: + * GM 04/10/05 Created + * + */ +/* + * TODO: + * - Start tcpsvcs as a service. + * - write debugging function and print all dbg info via that. + * + */ + #include #include #include @@ -12,7 +32,7 @@ static SERVICE_STATUS_HANDLE hSStat; FILE *hLogFile; BOOL bLogEvents = TRUE; BOOL ShutDown, PauseFlag; -LPTSTR LogFileName = "tcpsvcs_log.txt"; +LPCTSTR LogFileName = "tcpsvcs_log.log"; static SERVICE_TABLE_ENTRY ServiceTable[2] = @@ -40,7 +60,7 @@ int main(void) WSADATA wsaData; DWORD RetVal; INT i; - + if ((RetVal = WSAStartup(MAKEWORD(2, 2), &wsaData)) != 0) { _tprintf(_T("WSAStartup() failed : %lu\n"), RetVal); @@ -64,7 +84,7 @@ int main(void) if (hThread[i] == NULL) { _tprintf(_T("Failed to start %s server....\n"), Services[i].Name); - ExitProcess(i); + //ExitProcess(i); } } @@ -81,7 +101,7 @@ int main(void) -/* code to run tcpsvcs as a service */ +/* code to run tcpsvcs as a service through services.msc */ #if 0 int main(int argc, char *argv[]) @@ -105,7 +125,7 @@ ServiceMain(DWORD argc, LPTSTR argv[]) hLogFile = fopen(LogFileName, _T("w+")); if (hLogFile == NULL) return; - + LogEvent(_T("Entering ServiceMain"), 0, FALSE); hServStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; @@ -116,14 +136,14 @@ ServiceMain(DWORD argc, LPTSTR argv[]) hServStatus.dwServiceSpecificExitCode = 0; hServStatus.dwCheckPoint = 0; hServStatus.dwWaitHint = 2*CS_TIMEOUT; - + hSStat = RegisterServiceCtrlHandler("tcpsvcs", ServerCtrlHandler); if (hSStat == 0) LogEvent(_T("Failed to register service\n"), 100, TRUE); - LogEvent(_T("Control handler registered successfully"), 0, FALSE); - SetServiceStatus (hSStat, &hServStatus); - LogEvent(_T("Service status set to SERVICE_START_PENDING"), 0, FALSE); + LogEvent(_T("Control handler registered successfully"), 0, FALSE); + SetServiceStatus (hSStat, &hServStatus); + LogEvent(_T("Service status set to SERVICE_START_PENDING"), 0, FALSE); if (CreateServers() != 0) { @@ -132,14 +152,14 @@ ServiceMain(DWORD argc, LPTSTR argv[]) SetServiceStatus(hSStat, &hServStatus); return; } - - LogEvent(_T("Service threads shut down. Set SERVICE_STOPPED status"), 0, FALSE); - /* We will only return here when the ServiceSpecific function - completes, indicating system shutdown. */ - UpdateStatus (SERVICE_STOPPED, 0); - LogEvent(_T("Service status set to SERVICE_STOPPED"), 0, FALSE); - fclose(hLogFile); /* Clean up everything, in general */ - return; + + LogEvent(_T("Service threads shut down. Set SERVICE_STOPPED status"), 0, FALSE); + /* We will only return here when the ServiceSpecific function + completes, indicating system shutdown. */ + UpdateStatus (SERVICE_STOPPED, 0); + LogEvent(_T("Service status set to SERVICE_STOPPED"), 0, FALSE); + fclose(hLogFile); /* Clean up everything, in general */ + return; } @@ -173,12 +193,12 @@ ServerCtrlHandler(DWORD Control) void UpdateStatus (int NewStatus, int Check) /* Set a new service status and checkpoint (either specific value or increment) */ { - if (Check < 0 ) hServStatus.dwCheckPoint++; - else hServStatus.dwCheckPoint = Check; - if (NewStatus >= 0) hServStatus.dwCurrentState = NewStatus; - if (!SetServiceStatus (hSStat, &hServStatus)) - LogEvent (_T("Cannot set service status"), 101, TRUE); - return; + if (Check < 0 ) hServStatus.dwCheckPoint++; + else hServStatus.dwCheckPoint = Check; + if (NewStatus >= 0) hServStatus.dwCurrentState = NewStatus; + if (!SetServiceStatus (hSStat, &hServStatus)) + LogEvent (_T("Cannot set service status"), 101, TRUE); + return; } INT @@ -187,7 +207,7 @@ CreateServers() DWORD dwThreadId[NUM_SERVICES]; HANDLE hThread[NUM_SERVICES]; INT i; - + UpdateStatus(-1, -1); /* increment checkpoint */ /* Create MAX_THREADS worker threads. */ @@ -223,38 +243,37 @@ CreateServers() } -/* LogEvent is similar to the ReportError function used elsewhere - For a service, however, we ReportEvent rather than write to standard - error. Eventually, this function should go into the utility - library. */ +/* LogEvent is similar to the ReportError function used elsewhere + For a service, however, we ReportEvent rather than write to standard + error. Eventually, this function should go into the utility + library. */ VOID LogEvent (LPCTSTR UserMessage, DWORD ExitCode, BOOL PrintErrorMsg) { - DWORD eMsgLen, ErrNum = GetLastError (); - LPTSTR lpvSysMsg; - TCHAR MessageBuffer[512]; + DWORD eMsgLen, ErrNum = GetLastError (); + LPTSTR lpvSysMsg; + TCHAR MessageBuffer[512]; - if (PrintErrorMsg) { - eMsgLen = FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM, NULL, - ErrNum, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR)&lpvSysMsg, 0, NULL); + if (PrintErrorMsg) { + eMsgLen = FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM, NULL, + ErrNum, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR)&lpvSysMsg, 0, NULL); - _stprintf (MessageBuffer, _T("\n%s %s ErrNum = %d. ExitCode = %d."), - UserMessage, lpvSysMsg, ErrNum, ExitCode); - HeapFree (GetProcessHeap (), 0, lpvSysMsg); - /* Explained in Chapter 6. */ - } else { - _stprintf (MessageBuffer, _T("\n%s ExitCode = %d."), - UserMessage, ExitCode); - } + _stprintf (MessageBuffer, _T("\n%s %s ErrNum = %d. ExitCode = %d."), + UserMessage, lpvSysMsg, ErrNum, ExitCode); + HeapFree (GetProcessHeap (), 0, lpvSysMsg); + } else { + _stprintf (MessageBuffer, _T("\n%s ExitCode = %d."), + UserMessage, ExitCode); + } - fputs (MessageBuffer, hLogFile); + fputs (MessageBuffer, hLogFile); - if (ExitCode > 0) - ExitProcess (ExitCode); - else - return; + if (ExitCode > 0) + ExitProcess (ExitCode); + else + return; } #endif diff --git a/reactos/apps/utils/net/tcpsvcs/tcpsvcs.h b/reactos/apps/utils/net/tcpsvcs/tcpsvcs.h index 3a17cb66c01..ff37255fe7d 100644 --- a/reactos/apps/utils/net/tcpsvcs/tcpsvcs.h +++ b/reactos/apps/utils/net/tcpsvcs/tcpsvcs.h @@ -1,3 +1,17 @@ +/* + * ReactOS Services + * Copyright (C) 2005 ReactOS Team + * + * LICENCE: GPL - See COPYING in the top level directory + * PROJECT: ReactOS simple TCP/IP services + * FILE: apps/utils/net/tcpsvcs/tcpsvcs.h + * PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services + * PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com) + * REVISIONS: + * GM 04/10/05 Created + * + */ + /* default port numbers */ #define ECHO_PORT 7 #define DISCARD_PORT 9 @@ -28,13 +42,13 @@ typedef struct _Services { } SERVICES, *PSERVICES; -/* tcpsvcs functions * / -static VOID WINAPI ServiceMain(DWORD argc, LPTSTR argv[]); +/* tcpsvcs functions */ +//static VOID WINAPI ServiceMain(DWORD argc, LPTSTR argv[]); VOID WINAPI ServerCtrlHandler(DWORD control); INT CreateServers(VOID); VOID LogEvent (LPCTSTR UserMessage, DWORD ExitCode, BOOL PrintErrorMsg); void UpdateStatus (int NewStatus, int Check); -*/ + /* skelserver functions */ DWORD WINAPI StartServer(LPVOID lpParam); diff --git a/reactos/apps/utils/net/tcpsvcs/tcpsvcs.xml b/reactos/apps/utils/net/tcpsvcs/tcpsvcs.xml index e27a8863b28..d89eecd46c8 100644 --- a/reactos/apps/utils/net/tcpsvcs/tcpsvcs.xml +++ b/reactos/apps/utils/net/tcpsvcs/tcpsvcs.xml @@ -12,6 +12,5 @@ daytime.c qotd.c chargen.c - quotes.rc tcpsvcs.rc