home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / lanserv / access32 / errmsg.c < prev   
C/C++ Source or Header  |  1998-10-01  |  5KB  |  178 lines

  1. /***************************************************************************/
  2. /*
  3.  *    PROGRAM NAME: ERRMSG
  4.  *    ------------
  5.  *
  6.  *    What this program does:
  7.  *                     It provides a common detailed error message
  8.  *                     generation function for programs using the NetAPI
  9.  *                     and NetAPI32 functions and return codes.
  10.  *
  11.  *    REQUIRED FILES:
  12.  *    --------------
  13.  *    ERRMSG.C        - C source code for the Error_Message function.
  14.  *
  15.  *    REQUIRED LIBRARIES:
  16.  *    ------------------
  17.  *    None.
  18.  *
  19.  *    NetAPI functions used in this program :
  20.  *    --------------------------------------
  21.  *    None.
  22.  */
  23. /***************************************************************************/
  24.  
  25. /*------------------ OS/2 Include definitions -----------------------------*/
  26.  
  27. #define  INCL_BASE
  28.  
  29. #include <os2.h>
  30. #include <neterr.h>
  31.  
  32. /*--------------------- C Include definitions -----------------------------*/
  33.  
  34. #include <stdio.h>
  35.  
  36. /***************************************************************************/
  37. /* Error_Message Function                                                  */
  38. /*    Prints a detailed error message (in the case of common errors)       */
  39. /*   and/or an error number.                                               */
  40. /*-------------------------------------------------------------------------*/
  41.  
  42. VOID
  43. Error_Message(USHORT usRc, PSZ pszNetAPIName)
  44. {
  45.  
  46.     switch (usRc)
  47.     {
  48.         case ERROR_BAD_NETPATH:
  49.         {
  50.             printf("%s return code : %d - The network path cannot be found\n",
  51.                     pszNetAPIName, usRc);
  52.             printf("Possible cause: The server is not started or does not exist.\n");
  53.             break;
  54.         }
  55.  
  56.         case NERR_BufTooSmall:
  57.         {
  58.             printf("%s return code : %d - The buffer is too small for",
  59.                     pszNetAPIName, usRc);
  60.             printf(" fixed-length data.\n");
  61.             break;
  62.         }
  63.  
  64.         case NERR_ResourceNotFound:
  65.         {
  66.            printf("%s return code : %d - The network resource cannot be found\n",
  67.                    pszNetAPIName, usRc);
  68.            break;
  69.        }
  70.  
  71.         case NERR_RemoteOnly:
  72.         {
  73.             printf("%s return code : %d - This operation is not supported on\n",
  74.                     pszNetAPIName, usRc);
  75.             printf("                      workstations.\n");
  76.             break;
  77.         }
  78.  
  79.         case NERR_DeviceNotShared:
  80.         {
  81.             printf("%s return code : %d - Device not shared\n",
  82.                     pszNetAPIName, usRc);
  83.             printf("                   or device does not exist.\n");
  84.             break;
  85.         }
  86.  
  87.         case NERR_WkstaNotStarted:
  88.         {
  89.             printf("%s return code : %d - Requester service not started.\n",
  90.                    pszNetAPIName, usRc);
  91.             break;
  92.         }
  93.  
  94.         case NERR_NetNameNotFound:
  95.         {
  96.             printf("%s return code : %d - Netname not found.\n",
  97.                     pszNetAPIName, usRc);
  98.             printf("            The Netname is not shared \n");
  99.             printf("         or the Netname does not exist.\n");
  100.             break;
  101.         }
  102.  
  103.         case ERROR_ACCESS_DENIED:
  104.         {
  105.             printf("%s return code : %d - Access denied.\n",
  106.                     pszNetAPIName, usRc);
  107.             printf("            Administrator privilege is required.\n");
  108.             break;
  109.         }
  110.  
  111.         case NERR_AliasExists:
  112.         {
  113.             printf("%s return code : %d - The alias has already been created.\n",
  114.                     pszNetAPIName, usRc);
  115.             break;
  116.         }
  117.  
  118.         case NERR_AliasNotFound:
  119.         {
  120.             printf("%s return code : %d - The alias does not exist.\n",
  121.                     pszNetAPIName, usRc);
  122.             break;
  123.         }
  124.  
  125.         case NERR_AppExists:
  126.         {
  127.             printf("%s return code : %d - An application with this name "\
  128.                    "has already been created.\n", pszNetAPIName, usRc);
  129.             break;
  130.         }
  131.  
  132.         case NERR_AppNotFound:
  133.         {
  134.             printf("%s return code : %d - The application does not exist.\n",
  135.                     pszNetAPIName, usRc);
  136.             break;
  137.         }
  138.  
  139.         case NERR_DASDNotInstalled:
  140.         {
  141.             printf("%s return code : %d - Directory limits are not enabled\n"\
  142.                    "on the specified drive.\n", pszNetAPIName, usRc);
  143.             break;
  144.         }
  145.  
  146.         case NERR_LimitExists:
  147.         {
  148.             printf("%s return code : %d - The directory limit already exists.\n",
  149.                     pszNetAPIName, usRc);
  150.             break;
  151.         }
  152.  
  153.         case NERR_NotHPFSVolume:
  154.         {
  155.             printf("%s return code : %d - The directory is not on "\
  156.                    "a 386 HPFS volume.\n", pszNetAPIName, usRc);
  157.             break;
  158.         }
  159.  
  160.         case NERR_DuplicateShare:
  161.         {
  162.             printf("%s return code : %d - The netname has already been shared.\n",
  163.                     pszNetAPIName, usRc);
  164.             break;
  165.         }
  166.  
  167.         default:
  168.         {
  169.             printf("Unexpected return code from %s : %d\n",
  170.                     pszNetAPIName, usRc);
  171.             break;
  172.         }
  173.  
  174.     }
  175.  
  176.     return;
  177. }
  178.