NETPRINT.C
资源名称:MSDN_VC98.zip [点击查看]
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:4k
源码类别:
Windows编程
开发平台:
Visual C++
- /****************************************************************************
- * wperror.c -- sample program library demonstrating NWLink.
- *
- * Microsoft Developer Support
- * Copyright (c) 1992-1997 Microsoft Corporation
- *
- * Demonstrates basic sockets programming with the Windows Sockets API
- * using the NWLink transport.
- *
- ****************************************************************************/
- #include <stdio.h>
- #include <windows.h>
- #include <wsipx.h>
- /****************************************************************************
- *
- * FUNCTION: print_network_num( char *addrp)
- *
- * PURPOSE: Print out a given network number
- *
- * ARGUMENTS: addrp Pointer to the network address
- *
- * RETURNS: nothing.
- *
- ****************************************************************************/
- void print_network_num(char *addrp)
- {
- printf("%02X%02X%02X%02X",
- (unsigned char)*addrp,
- (unsigned char)*(addrp + 1),
- (unsigned char)*(addrp + 2),
- (unsigned char)*(addrp + 3));
- return;
- }
- /****************************************************************************
- *
- * FUNCTION: print_node_num( char *addrp)
- *
- * PURPOSE: Print out a given node number
- *
- * ARGUMENTS: addrp Pointer to the network address
- *
- * RETURNS: nothing.
- *
- ****************************************************************************/
- void print_node_num(char *addrp)
- {
- printf("%02X%02X%02X%02X%02X%02X",
- (unsigned char)*addrp,
- (unsigned char)*(addrp + 1),
- (unsigned char)*(addrp + 2),
- (unsigned char)*(addrp + 3),
- (unsigned char)*(addrp + 4),
- (unsigned char)*(addrp + 5));
- return;
- }
- /****************************************************************************
- *
- * FUNCTION: print_socket_num( char *addrp)
- *
- * PURPOSE: Print out a given socket number
- *
- * ARGUMENTS: addrp Pointer to the network address
- *
- * RETURNS: nothing.
- *
- ****************************************************************************/
- void print_socket_num(char *addrp)
- {
- printf("%02X%02X",
- (unsigned char)*addrp,
- (unsigned char)*(addrp + 1));
- return;
- }
- /****************************************************************************
- *
- * FUNCTION: print_netaddr( char *addrp, char *prestr, char *poststr)
- *
- * PURPOSE: Print out a given network address
- *
- * ARGUMENTS: addrp = Ptr to the network address
- * prestr = String to print before addr
- * poststr = String to print after addr
- *
- * RETURNS: nothing.
- *
- ****************************************************************************/
- void print_netaddr(char *addrp, char *prestr, char *poststr)
- {
- if (prestr)
- printf(prestr);
- print_network_num(addrp);
- printf(" - ");
- print_node_num(addrp+4);
- printf(" - ");
- print_socket_num(addrp+10);
- if (poststr)
- printf(poststr);
- return;
- }
- /****************************************************************************
- *
- * FUNCTION: print_saddr( PSOCKADDR_IPX p )
- *
- * PURPOSE: Prints out contents of the SOCKADDR_IPX struct passed in.
- *
- * ARGUMENTS: PSOCKADDR_IPX => SOCKADDR_IPX struct to dump.
- *
- * RETURNS: nothing.
- *
- ****************************************************************************/
- void print_saddr(PSOCKADDR_IPX p)
- {
- printf("address family = %d address = ", p->sa_family);
- print_netaddr(p->sa_netnum, NULL, NULL);
- }
- /****************************************************************************
- *
- * FUNCTION: print_wsa( LPWSADATA w )
- *
- * PURPOSE: Dumps out the contents of a WSA structure.
- *
- * ARGUMENTS: umps out the contents of a WSA structure.
- *
- * RETURNS: nothing.
- *
- ****************************************************************************/
- void print_wsa(LPWSADATA w)
- {
- printf(" Version = %ldn", w->wVersion);
- printf(" High Version = %ldn", w->wHighVersion);
- printf(" Description = %sn", w->szDescription);
- printf(" System Status = %sn", w->szSystemStatus);
- printf(" Max sockets = %dn", w->iMaxSockets);
- printf(" Max UPD dg size = %dn", w->iMaxUdpDg);
- }