/** * @brief Complain that some DLL failed to CreateObject() something. */ void ComplainCreateObject(HMODULE handle, LPCTSTR name) { TCHAR szContext[800]; LPTSTR pszContext = szContext + wsprintf(szContext, _T("%.100s@"), name); ::GetModuleFileName(handle, pszContext, 500); Complain(RPC_S_INTERFACE_NOT_FOUND, szContext); }
/** Complain about wrong parameter format */ void WrongFormat(char *keyword) { char msgbuffer[100]; sprintf(msgbuffer, "Wrong parameter format for keyword '%s'. See man page.\n", keyword); Complain(msgbuffer); }
/** Complain about missing parameter */ void ParameterNeeded(char *keyword) { char msgbuffer[100]; sprintf(msgbuffer, "Keyword '%s' must be followed by an parameter ('=....'). See man page.\n", keyword); Complain(msgbuffer); }
/** Complain about not supported keyword */ void KeywordNotSupported(char *keyword) { char msgbuffer[100]; sprintf(msgbuffer, "Keyword '%s' not supported. See man page.\n", keyword); Complain(msgbuffer); }
REMOTETUNESHOOK_API bool WINAPI InstallHook(HWND relayWindow) { if (!isHookInstalled) { hook = SetWindowsHookEx(WH_SHELL, CallWndProc, (HINSTANCE)dllHandle, 0); if (hook) { isHookInstalled = true; mediaCmdRelayWindowHandle = relayWindow; } else { Complain(TEXT("Could not install the global message receiver hook.")); } } return isHookInstalled; }
// Output message to screen/logs/socket. void Output(const char *format, ...) { // Check for error indicator (eg, format starting with "<0>") int code = 7; if (format[0] == '<' && format[1] >= '0' && format[1] <= '9' && format[2] == '>') { code = format[1] - '0'; format += 3; } // Format output string. char rawbuf[MAXOUTBUF]; va_list args; va_start(args, format); int rawlen = vsnprintf(rawbuf, sizeof(rawbuf) - PADOUTBUF, format, args); va_end(args); // Convert newline characters char buf[MAXOUTBUF]; int len = convertNL(buf, sizeof(buf), rawbuf, rawlen); writeLog(buf, len); printf(buf); //printf("\n"); outputfn *ofn = getOutputFn(); if (!ofn && code < 6) { Complain(rawbuf, rawlen, code-1); return; } if (code <= 6) writeScreen(buf, len); if (ofn && code <= 7) ofn->sendMessage(buf, len); }
int main( void ) { struct Process *Proc = ( struct Process * )FindTask( 0L ); BlankMsg *FreeMsg; LONG ReturnVal = 0; if( Proc->pr_CLI ) { STRPTR Str = BADDR((( struct CommandLineInterface * ) BADDR( Proc->pr_CLI ))->cli_CommandName ); CopyMem( Str + 1, PrefsPath, *Str ); PrefsPath[*Str] = '\0'; strcat( PrefsPath, ".prefs" ); } IntuitionBase = OpenLibrary( "intuition.library", 37L ); GfxBase = OpenLibrary( GRAPHICSNAME, 37L ); GarshnelibBase = OpenLibrary( "Garshnelib.library", 37L ); if( IntuitionBase && GfxBase && GarshnelibBase ) { ClientPort = CreateMsgPort(); TimerPort = CreateMsgPort(); if( ClientPort && TimerPort ) { TimeOutIO = ( struct timerequest * ) CreateExtIO( TimerPort, sizeof( struct timerequest )); if( TimeOutIO && !OpenDevice( "timer.device", UNIT_VBLANK, ( struct IORequest * )TimeOutIO, 0L )) { ClientPort->mp_Node.ln_Name = PortName; ClientPort->mp_Node.ln_Pri = 0L; AddPort( ClientPort ); CurPrefs = LoadPrefs( PrefsPath ); CurrentTime( &InitSecs, &InitMicros ); RangeSeed = InitSecs + InitMicros; Blank( CurPrefs ); while( FreeMsg = ( BlankMsg * )GetMsg( ClientPort )) { if( FreeMsg->bm_Type & BF_REPLY ) FreeVec( FreeMsg ); else { FreeMsg->bm_Type |= BF_REPLY; ReplyMsg(( struct Message * )FreeMsg ); } } if( CurPrefs ) FreeVec( CurPrefs ); if( !PortRemoved ) RemPort( ClientPort ); } if( TimeOutIO ) { if( TimeOutIO->tr_node.io_Device ) CloseDevice(( struct IORequest * )TimeOutIO ); DeleteExtIO(( struct IORequest * )TimeOutIO ); } } else { Complain( "ClientPort or TimerPort failed to open." ); ReturnVal = 2; } if( ClientPort ) { BlankMsg *TmpMsg; while( TmpMsg = ( BlankMsg * )GetMsg( ClientPort )) { TmpMsg->bm_Flags |= BF_REPLY; ReplyMsg(( struct Message * )TmpMsg ); } DeleteMsgPort( ClientPort ); } if( TimerPort ) DeleteMsgPort( TimerPort ); } else { Complain( "A library failed to open." ); ReturnVal = 1; } if( GarshnelibBase ) CloseLibrary( GarshnelibBase ); if( GfxBase ) CloseLibrary( GfxBase ); if( IntuitionBase ) CloseLibrary( IntuitionBase ); return ReturnVal; }