/*++ Copyright (c) Microsoft Corporation. All rights reserved. Module Name: devcon.cpp Abstract: Device Console command-line interface for managing devices --*/ #include "devcon.h" struct IdEntry { LPCTSTR String; // string looking for LPCTSTR Wild; // first wild character if any BOOL InstanceId; }; void FormatToStream(_In_ FILE * stream, _In_ 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) { // strip any trailing "\r\n"s and replace by a single "\n" LPTSTR p, q; for(p = q = locbuffer; *p != TEXT('\0'); p++) { if(p != q) { *q = *p; } if(*p != TEXT('\r')) { q++; } } *q = TEXT('\0'); // // now write to apropriate stream // _fputts(locbuffer,stream); } LocalFree(locbuffer); } } void Padding(_In_ 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