Annotation of mstools/samples/nwlink/testlib/geterror.c, revision 1.1

1.1     ! root        1: /****************************************************************************\
        !             2: *  geterror.c -- sample program demonstrating NWLink.
        !             3: *
        !             4: *       Original code from Micro Computer Systems, Inc.
        !             5: *       Copyright(c) 1992  All Rights Reserved.
        !             6: *       Microsoft Developer Support
        !             7: *       Copyright (c) 1992, 1993 Microsoft Corporation
        !             8: *
        !             9: *  Demonstrates basic sockets programming with the Windows Sockets API
        !            10: *  using the NWLink transport.
        !            11: * 
        !            12: ****************************************************************************/
        !            13: #include <winsock.h>
        !            14: #include <stdio.h>
        !            15: #include "externs.h"
        !            16: 
        !            17: #define WSAERRGAP1 28
        !            18: #define WSAERRGAP2 19
        !            19:  
        !            20: extern ERROR_STRUCT errlist[];
        !            21: 
        !            22: /****************************************************************************
        !            23: *
        !            24: *    FUNCTION:  get_error_text( int error )
        !            25: *
        !            26: *    PURPOSE:   Gets the text string explaining the error number passed in.
        !            27: *                  If the error number is 0, or is not found, a respective
        !            28: *                              message is returned.
        !            29: *
        !            30: *    ARGUMENTS:        int     error number to look up
        !            31: *                
        !            32: *       RETURNS:   LPCSTR      => char string having error message
        !            33: *                              
        !            34: *\***************************************************************************/
        !            35: LPCSTR get_error_text(int error)
        !            36: {
        !            37:     int search = 0;
        !            38: 
        !            39: 
        !            40:     /*
        !            41:     *   No error
        !            42:     */
        !            43: 
        !            44:     if (!error)
        !            45:         return (LPCSTR)msg_no_error;
        !            46: 
        !            47:     /* 
        !            48:     *   Search through our array of error number / string pairs
        !            49:     *   until we find a matching error number or get to the end
        !            50:     *   of our list.  If we found a matching error number, 
        !            51:     *   return a LPSTR to the corresponding string.
        !            52:     */
        !            53: 
        !            54:     while (errlist[search].errstr) {
        !            55:         if (error == errlist[search].errnum)
        !            56:             return errlist[search].errstr;
        !            57:         search++;
        !            58:     }
        !            59: 
        !            60:     /*
        !            61:     * If we didn't have the error in our list, return unkown 
        !            62:     */
        !            63: 
        !            64:     return (LPCSTR)msg_unknown_error;
        !            65: }
        !            66: 
        !            67:     

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.