/*++ Copyright (c) Microsoft Corporation. All rights reserved. Module Name: devcon.cpp Abstract: Device Console command-line interface for managing devices @@BEGIN_DDKSPLIT Author: Jamie Hunter (JamieHun) Nov-30-2000 Revision History: @@END_DDKSPLIT --*/ #include "devcon.h" struct IdEntry { LPCTSTR String; // string looking for LPCTSTR Wild; // first wild character if any BOOL InstanceId; }; void FormatToStream(FILE * stream,DWORD fmt,...) /*++ Routine Description: Format text to stream using a particular msg-id fmt Used for displaying localizable messages Arguments: stream - file stream to output to, stdout or stderr fmt - message id ... - parameters %1... Return Value: none --*/ { va_list arglist; LPTSTR locbuffer = NULL; DWORD count; va_start(arglist, fmt); count = FormatMessage(FORMAT_MESSAGE_FROM_HMODULE|FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, fmt, 0, // LANGID (LPTSTR) &locbuffer, 0, // minimum size of buffer &arglist); if(locbuffer) { if(count) { int c; int back = 0; // // strip any trailing "\r\n"s and replace by a single "\n" // while(((c = *CharPrev(locbuffer,locbuffer+count)) == TEXT('\r')) || (c == TEXT('\n'))) { count--; back++; } if(back) { locbuffer[count++] = TEXT('\n'); locbuffer[count] = TEXT('\0'); } // // now write to apropriate stream // _fputts(locbuffer,stream); } LocalFree(locbuffer); } } void Padding(int pad) /*++ Routine Description: Insert padding into line before text Arguments: pad - number of padding tabs to insert Return Value: none --*/ { int c; for(c=0;c