⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wsagent.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
字号:
/* * Copyright (C) 1999-2005 Wind River Systems, Inc. * All rights reserved.  Provided under license only. * Distribution or other use of this software is only * permitted pursuant to the terms of a license agreement * from Wind River Systems (and is otherwise prohibited). * Refer to that license agreement for terms of use. *//**************************************************************************** *  Copyright 1988-1997 Epilogue Technology Corporation. *  Copyright 1998 Integrated Systems, Inc. *  All rights reserved. ****************************************************************************//* $Log: wsagent.c,v $/* Revision 1.3  2003/01/15 14:05:00  josh/* directory structure shifting/*/* Revision 1.2  2001/11/09 21:29:37  josh/* winagent path retooling/*/* Revision 1.1.1.1  2001/11/05 17:49:19  tneale/* Tornado shuffle/*/* Revision 1.10  2001/01/19 22:25:12  paul/* Update copyright./*/* Revision 1.9  2000/03/17 00:15:53  meister/* Update copyright message/* * Revision 1.8  1998/02/25 04:58:35  sra * Update copyrights. * * Revision 1.7  1997/03/20 19:27:12  mrf * don't call GetLastError under Win16. * * Revision 1.5  1997/02/25 16:34:43  mrf * Added RCS log and copyright notice * *//* [clearcase]modification history-------------------01a,19apr05,job  update copyright notices*//* $Header: /usr/cvsroot/target/src/wrn/wm/demo/winagent/wsagent.c,v 1.3 2003/01/15 14:05:00 josh Exp $ *//*---------------------------------------------------------  WSAGENT.C -- Windows Sockets SNMP Agent.		Main Window and Dialog Box Controls.  ---------------------------------------------------------*/#include <sys/types.h>#include <sys/timeb.h>#include "wsagent.h"#include "resource.h"#include "sysvars.h"#include <wrn/wm/common/install.h>#include <wrn/wm/snmp/engine/snmpstat.h>/* exported functions. *///#if INSTALL_on_msvc20//LONG APIENTRY WSAgent_WndProc (HWND, UINT, UINT, LONG) ;#if INSTALL_on_win32LRESULT CALLBACK WSAgent_WndProc (HWND, UINT, UINT, LONG) ;LONG APIENTRY WSAgent_About (HWND, UINT, UINT, LONG) ;#else long FAR PASCAL _export WSAgent_WndProc (HWND, UINT, UINT, LONG) ;     long FAR PASCAL _export WSAgent_About (HWND, UINT, UINT, LONG) ;     #endif /* INSTALL_on_win32 *//* global definition of our application name. */LPSTR szAppName;/* global definition of snmp_stats structure */SNMP_STATS_T    snmp_stats;/*---------------------------------------------------------  WinMain() --  Default Windows entry point.  ---------------------------------------------------------*/#if INSTALL_on_win32WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,		LPSTR lpszCmdParam, int nCmdShow)#elseint PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,		LPSTR lpszCmdParam, int nCmdShow)#endif /* INSTALL_on_win32 */{	HWND        hwnd ;	MSG         msg ;	WNDCLASS    wndclass ;	HACCEL      haccl;#if INSTALL_on_win32    	DWORD    err;#endif    	ATOM     wclass;	szAppName = "WinAgent";	if (!hPrevInstance)	{		wndclass.style         = CS_HREDRAW | CS_VREDRAW ;		wndclass.lpfnWndProc   = WSAgent_WndProc ;      		wndclass.cbClsExtra    = 0 ;		wndclass.cbWndExtra    = 0 ;		wndclass.hInstance     = hInstance ;		wndclass.hIcon       = LoadIcon (hInstance, MAKEINTRESOURCE(IDI_WSAGENT)) ;		wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;		wndclass.hbrBackground = GetStockObject (WHITE_BRUSH) ;		wndclass.lpszMenuName  = MAKEINTRESOURCE(WSAGENTMENU) ;		wndclass.lpszClassName = szAppName ;		wclass = RegisterClass (&wndclass) ;			if (wclass == 0)            		{#if INSTALL_on_win32            			err = GetLastError();#endif            			return (1);		}	}	hwnd = CreateWindow (			szAppName,                 /* window class name          */			"Winsock SNMP Agent",         /* window caption             */			 WS_OVERLAPPEDWINDOW,         /* window style               */			 CW_USEDEFAULT,               /* initial x position         */			 CW_USEDEFAULT,                  /* initial y position         */			 CW_USEDEFAULT,                  /* initial x size             */			 CW_USEDEFAULT,                  /* initial y size             */			 (HWND) NULL,                    /* parent window handle       */			 (HMENU) NULL,                /* window menu handle         */			 hInstance,                   /* program instance handle    */			 NULL) ;                      /* creation parameters        */	if (hwnd == NULL)	{#if INSTALL_on_win32        		err = GetLastError();#endif        		return (1);	}	haccl = LoadAccelerators (hInstance, MAKEINTRESOURCE(IDR_WSAGENTACCEL));	ShowWindow (hwnd, nCmdShow) ;	UpdateWindow (hwnd) ;	while (GetMessage (&msg, NULL, 0, 0))	{		if (!TranslateAccelerator (hwnd, haccl, &msg))		{			TranslateMessage (&msg) ;			DispatchMessage (&msg) ;		}	}	return msg.wParam ;}/*---------------------------------------------------------  WSAgent_WndProc() --  Handles main window.  Offers very basic menu options  and doesn't really do much a user can see except  paint a basic status message.		Calls socket handling functions as mapped to		windows messages:			WM_CREATE -- WS_Initialize()			WM_SOCKET_SELECT -- WS_Receive()			WM_DESTROY -- WS_Close()  ---------------------------------------------------------*///#if INSTALL_on_msvc20//LONG APIENTRY WSAgent_WndProc (HWND hwnd, UINT message, //       UINT wParam, LONG lParam)#if INSTALL_on_win32LRESULT CALLBACK WSAgent_WndProc (HWND hwnd, UINT message, 			UINT wParam, LONG lParam)#elselong FAR PASCAL _export WSAgent_WndProc (HWND hwnd, UINT message, 			UINT wParam, LONG lParam)#endif /* INSTALL_on_win32 */{	HDC                  hdc ;	PAINTSTRUCT          ps ;	RECT                 rect ;	static HINSTANCE     hInstance;	static FARPROC       lpfnAboutDlgProc;	switch (message)	{				case WM_CREATE:			hInstance = ((LPCREATESTRUCT) lParam)->hInstance;			lpfnAboutDlgProc = MakeProcInstance ((FARPROC) WSAgent_About, (HINSTANCE)hInstance);			_ftime(&boot_at);			if(WS_Initialize(hwnd) == FAILURE)				/* should add error handling here */#if (INSTALL_ENVOY_SNMP_GROUP_V1 || INSTALL_ENVOY_SNMP_GROUP_V2)			(void)memset((char *)&snmp_stats, 0, sizeof(snmp_stats));#endif 				return 0;		case WM_PAINT:			hdc = BeginPaint (hwnd, &ps);			GetClientRect (hwnd, &rect);			DrawText (hdc, "Winsock SNMP Agent!!", -1, 				&rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);			EndPaint (hwnd, &ps);			return 0;			 		case WM_COMMAND:			switch (wParam)				{			case ID_HELP_ABOUT:				DialogBox (hInstance, MAKEINTRESOURCE(IDD_ABOUTDIALOG), hwnd, (DLGPROC)lpfnAboutDlgProc);				return 0;			case ID_FILE_EXIT:				SendMessage (hwnd, WM_CLOSE, 0, 0L);				return 0;			default:					return 0;				}		case WM_SOCKET_SELECT:			WS_Receive((SOCKET)wParam, (SOCKERR)WSAGETSELECTERROR(lParam),					(SOCKEVENT)WSAGETSELECTEVENT(lParam));			return 0;		case WM_DESTROY:			WS_Close();			PostQuitMessage (0) ;			return 0 ;	}	return DefWindowProc (hwnd, message, wParam, lParam) ;} /*---------------------------------------------------------  WSAgent_About() --  Handles the "about" dialog box.  ---------------------------------------------------------*/#if INSTALL_on_win32LONG APIENTRY WSAgent_About (HWND hDlg, UINT message, 			UINT wParam, LONG lParam)#elselong FAR PASCAL _export WSAgent_About (HWND hDlg, UINT message, 			UINT wParam, LONG lParam)#endif /*INSTALL_on_win32 */  {	switch (message)	{	case WM_INITDIALOG:		return TRUE;	case WM_COMMAND:		switch (wParam)		{		case IDOK:			EndDialog (hDlg, 0);			return TRUE;		}		break;	}	return FALSE;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -