home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p024 / 12.img / ADS1.LIB / ADS_PERR.C next >
Encoding:
C/C++ Source or Header  |  1993-02-17  |  10.7 KB  |  238 lines

  1. /* Next available MSG number is  88 */
  2.  
  3. /*
  4.     ADS_PERR.C
  5.       ¬⌐┼v (C) 1988-1992  Autodesk ñ╜Ñq
  6.  
  7.       Ñ╗│n┼ΘºK╢O¿╤▒z╢iªµÑ⌠ª≤Ñ╬│~╗▌¿D¬║½■¿⌐íB¡╫º∩ñ╬╡oªµ, ª²¼O░╚╜╨┐φ┤`ñU¡z
  8.       ¡∞½h :
  9.  
  10.       1)  ñWªC¬║¬⌐┼v│qºi░╚╗▌ÑX▓{ªb¿Cñ@Ñ≈½■¿⌐∙╪íC
  11.       2)  ¼█├÷¬║╗í⌐·ñσÑ≤ñ]Ñ▓╢╖⌐·╕ⁿ¬⌐┼v│qºiñ╬Ñ╗╢╡│\Ñi│qºiíC
  12.  
  13.       Ñ╗│n┼Θ╢╚┤ú¿╤º@¼░└│Ñ╬ñW¬║░╤ª╥, ª╙Ñ╝┴n⌐·⌐╬┴⌠ºtÑ⌠ª≤½O├╥; ╣∩⌐≤Ñ⌠ª≤»S«φ
  14.       Ñ╬│~ñº╛A║┘⌐╩, ÑHñ╬░╙╖~╛P░Γ⌐╥┴⌠ºtÑX¿π¬║½O├╥, ªbª╣ñ@╖ºñ⌐ÑHº_╗{íC
  15.  
  16.  
  17.  
  18.     ADS_PERR.C  -  ADS routine to print the error message
  19.                    associated with the value of "errno" upon failure
  20.                    of a call to AutoCAD.  This routine is meant to be
  21.                    invoked by other ADS programs, and contains a table
  22.                    of the current error messages as found in ol_errno.h.
  23.                    This routine is meant to parallel the Unix
  24.                    perror() function.
  25.  
  26.                    ads_perror() is a Lisp-callable or invokable function that
  27.                    takes an optional single argument and prints the message on
  28.                    the AutoCAD command line.  The syntax is:
  29.  
  30.                    (ads_perror "string")
  31.  
  32.                    The string is optional; if provided, it is printed on a
  33.                    separate line before the system error message.  To be of
  34.                    most use, the argument string should include the name of the
  35.                    program that incurred the error.  The error number is taken
  36.                    from the system variable "errno", which is set when most
  37.                    errors occur, but not cleared when non-erroneous calls are
  38.                    made.
  39.  
  40.                    The STANDALONE macro is obsolete.  Forget it.
  41.  */
  42.  
  43. #include  <stdio.h>
  44. #include  <string.h>
  45. #include  "adslib.h"
  46. #include  "ol_errno.h"
  47.  
  48.  
  49. /* The error message table */
  50.  
  51. char *errmsg[] = {                                               /* ERRNO ╜X */
  52.     /*MSG1*/"╡L«─¬║íu▓┼╕╣¬φ (symbol table)ívªW║┘íC",                   /*  1 */
  53.     /*MSG2*/"╡L«─¬║ªW║┘ (íu╣╧ñ╕ív⌐╬íu┐∩╢░ív) ñ║«eíC",                  /*  2 */
  54.     /*MSG3*/"╢WÑXíu┐∩╢░ívñW¡¡íC",                                      /*  3 */
  55.     /*MSG4*/"íu┐∩╢░ív╡L«─íC",                                          /*  4 */
  56.     /*MSG5*/"íu╣╧╕s⌐w╕q╣╧ñ╕ív¿╧Ñ╬ñúÑ┐╜TíC",                            /*  5 */
  57.     /*MSG6*/"íuXref ╣╧ñ╕ív¿╧Ñ╬ñúÑ┐╜TíC",                               /*  6 */
  58.     /*MSG7*/"¼D┐∩íu╣╧ñ╕┐∩╢░ívÑó▒╤íC",                                  /*  7 */
  59.     /*MSG8*/"íu╣╧ñ╕└╔«╫ív╡▓º⌠íC",                                      /*  8 */
  60.     /*MSG9*/"íu╣╧╕s⌐w╕q└╔«╫ív╡▓º⌠íC",                                  /*  9 */
  61.     /*MSG10*/"íueidlastívÑó▒╤íC",                                      /* 10 */
  62.     /*MSG11*/"╣∩íu╡°╡íív╢iªµ¬║íuentdelívñúªX¬kíC",                     /* 11 */
  63.     /*MSG12*/"ª╣º@╖~ñúñ╣│\134ªbíu╗EªX╜uíúPLINEíñív½ⁿÑO┤┴╢í░⌡ªµíC"      /* 12 */
  64.     /*MSG13*/"íu╣╧╜Xív╡L«─íC",                                         /* 13 */
  65.     /*MSG14*/"íu╣╧╜XívÑ╝▒╥Ñ╬íC",                                       /* 14 */
  66.     /*MSG15*/"íuTRANSív¬║»┴¿D╡L«─íC",                                  /* 15 */
  67.     /*MSG16*/"íu¬┼╢í┬α╕mív¬║╗▌»┴╡L«─íC",                               /* 16 */
  68.     /*MSG17*/"╡L«─í╨¿╧Ñ╬íuñwºR░ú¬║╣╧ñ╕ívíC"                            /* 17 */
  69.     /*MSG18*/"íu¬φªW (table name)ív╡L«─íC",                            /* 18 */
  70.     /*MSG19*/"íu¬φ╢╡¿τ╝╞ív¬║íuñ▐╝╞ív╡L«─íC",                           /* 19 */
  71.     /*MSG20*/"╖N╣╧│]⌐wíu░▀┼¬ív┼▄╝╞íC",                                 /* 20 */
  72.     /*MSG21*/"íu0ív ¡╚╡L«─íC",                                         /* 21 */
  73.     /*MSG22*/"╝╞¡╚╢WÑX╜d│≥íC",                                         /* 22 */
  74.     /*MSG23*/"╢iªµ╜╞┬°¬║¡½Ñ═íC",                                       /* 23 */
  75.     /*MSG24*/"╖N╣╧┼▄º≤íu╣╧ñ╕├■ºOívíC",                                 /* 24 */
  76.     /*MSG25*/"íu╝hªWívª│╗~íC",                                         /* 25 */
  77.     /*MSG26*/"íu╜u½¼ªW║┘ívª│╗~íC",                                     /* 26 */
  78.     /*MSG27*/"íu├CªΓªW║┘ívª│╗~íC",                                     /* 27 */
  79.     /*MSG28*/"íuªr½¼ªW║┘ívª│╗~íC",                                     /* 28 */
  80.     /*MSG29*/"íuº╬¬¼ªW║┘ívª│╗~íC",                                     /* 29 */
  81.     /*MSG30*/"ѵÑIíu╣╧ñ╕├■ºOív¬║íu─µ╢╡ívª│╗~íC",                       /* 30 */
  82.     /*MSG31*/"╖N╣╧ entmod ñwíuºR░úív¬║╣╧ñ╕íC",                         /* 31 */
  83.     /*MSG32*/"╖N╣╧ entmodíuSEQENDívíC",                                /* 32 */
  84.     /*MSG33*/"╖N╣╧º≤º∩íu╣╧╜XívíC",                                     /* 33 */
  85.     /*MSG34*/"íu╡°╡íÑi▓{│]⌐wív¬║¡╫º∩ñúªX▓zíC",                         /* 34 */
  86.     /*MSG35*/"╣╧ñ╕ª∞⌐≤íu┬Ω┼@ív¬║╝hñWíC",                               /* 35 */
  87.     /*MSG36*/"íu╣╧ñ╕├■ºOívª│╗~íC",                                     /* 36 */
  88.     /*MSG37*/"íuPLINE ╣╧ñ╕ívª│╗~íC",                                   /* 37 */
  89.     /*MSG38*/"íu╣╧╕sívññª│ñúº╣╛π¬║íu╜╞┬°╣╧ñ╕ívíC",                     /* 38 */
  90.     /*MSG39*/"íu╣╧╕sªW║┘ív¬║íu─µ╢╡ív╡L«─íC",                           /* 39 */
  91.     /*MSG40*/"íu╣╧╕s║X╝╨ív¬║íu─µ╢╡ív¡½╜╞íC",                           /* 40 */
  92.     /*MSG41*/"íu╣╧╕sªW║┘ív¬║íu─µ╢╡ív¡½╜╞íC",                           /* 41 */
  93.     /*MSG42*/"íu¬kªV╢qívª│╗~íC",                                       /* 42 */
  94.     /*MSG43*/"║|»╩íu╣╧╕sªW║┘ívíC",                                     /* 43 */
  95.     /*MSG44*/"║|»╩íu╣╧╕s║X╝╨ívíC",                                     /* 44 */
  96.     /*MSG45*/"╡L«─¬║íu░╬ªW╣╧╕sívíC",                                   /* 45 */
  97.     /*MSG46*/"╡L«─¬║íu╣╧╕s⌐w╕q╣╧ñ╕ívíC",                               /* 46 */
  98.     /*MSG47*/"║|»╩íu⌐RÑO─µ╢╡ívíC",                                     /* 47 */
  99.     /*MSG48*/"╡L¬k┐δ╗{¬║íu⌐╡ª∙╕Ω«╞├■ºOívíC",                           /* 48 */
  100.     /*MSG49*/"Xdata ññªΩªC¬║íu▒_▓╒ívñúÑ┐╜TíC",                         /* 49 */
  101.     /*MSG50*/"íuAPPID ─µ╢╡ív¬║ª∞╕mñúÑ┐╜TíC",                           /* 50 */
  102.     /*MSG51*/"╢WÑXíuXdataív«e┐nñW¡¡íC",                                /* 51 */
  103.     /*MSG52*/"╣╧ñ╕┐∩╢░ª]íu¬┼ª^└│ívª╙Ñó▒╤íC",                           /* 52 */
  104.     /*MSG53*/"Xdata ññíu└│Ñ╬├■╢╡ív¬║ªW║┘¡½╜╞íC",                       /* 53 */
  105.     /*MSG56*/"╖N╣╧½╪Ñ▀⌐╬¡╫º∩íu╡°╡í╣╧ñ╕ívíC",                           /* 54 */
  106.     /*MSG57*/"╖N╣╧½╪Ñ▀íuXrefív⌐╬íu▒q└H▓┼╕╣ívíC",                       /* 55 */
  107.     /*MSG58*/"íussget ┬o┬^ívª│╗~: ¡zÑyÑ╝▓╫ñεíC",                       /* 56 */
  108.     /*MSG59*/"íussget ┬o┬^ívª│╗~: ║|»╩íuñ±╕╒▓┼ívíC",                   /* 57 */
  109.     /*MSG60*/"íussget ┬o┬^ívª│╗~:íuñ±╕╒▓┼ívªrªΩ╡L«─íC",                /* 58 */
  110.     /*MSG61*/"íussget ┬o┬^ívª│╗~:íu¬┼¡zÑyív⌐╬íu▒_▓╒ñúÑ┐╜TívíC",        /* 59 */
  111.     /*MSG62*/"íussget ┬o┬^ívª│╗~:íu░_⌐lí■╡▓º⌠ív¡zÑyÑ╝░t▓┼íC",          /* 60 */
  112.     /*MSG63*/"íussget ┬o┬^ívª│╗~:íuXOR/NOTív╣B║Γ▓┼¬║╝╞Ñ╪┐∙╗~íC",       /* 61 */
  113.     /*MSG64*/"íussget ┬o┬^ívª│╗~: ╢WÑXíu▒_▓╒╝h╢ÑívñW¡¡íC",             /* 62 */
  114.     /*MSG65*/"íussget ┬o┬^ívª│╗~: íu╕s╜X (group code)ív╡L«─íC",        /* 63 */
  115.     /*MSG66*/"íussget ┬o┬^ívª│╗~: íuªrªΩív┤·╕╒╡L«─íC",                 /* 64 */
  116.     /*MSG67*/"íussget ┬o┬^ívª│╗~: íuªV╢qív┤·╕╒╡L«─íC",                 /* 65 */
  117.     /*MSG68*/"íussget ┬o┬^ívª│╗~: íu╣Ω╝╞ív┤·╕╒╡L«─íC",                 /* 66 */
  118.     /*MSG69*/"íussget ┬o┬^ívª│╗~: íu╛π╝╞ív┤·╕╒╡L«─íC",                 /* 67 */
  119.     /*MSG70*/"íu╝╞ñ╞╗÷ívñú¼Oíu╝╞ª∞¬Oív",                               /* 68 */
  120.     /*MSG71*/"íu╝╞ª∞¬OívÑ╝«╒Ñ┐íC",                                     /* 69 */
  121.     /*MSG72*/"╢╟ñ⌐ (TABLET) ¿τ╝╞¬║íuñ▐╝╞ív╡L«─íC",                     /* 70 */
  122.     /*MSG73*/"╡L¿¼░≈¬║íu░O╛╨¬┼╢íív¿╤░t╕míu╡▓¬G╜w╜─░╧ívíC",             /* 71 */
  123.     /*MSG74*/"▒NíuNULL ½ⁿ╝╨ív┤ú¿╤º@¼░íuñ▐╝╞ívíC",                      /* 72 */
  124.     /*MSG75*/"½ⁿ⌐w¬║íu└╔«╫ív╡L¬k╢}▒╥íC",                               /* 73 */
  125.     /*MSG76*/"½ⁿ⌐w¬║íu└│Ñ╬╡{ªíívñw╕ⁿñJíC",                             /* 74 */
  126.     /*MSG77*/"ñw╣F¿∞ñ╣│\134╕ⁿñJñºíuADS └│Ñ╬╡{ªíív¬║ñW¡¡íC",            /* 75 */
  127.     /*MSG78*/"½ⁿ⌐w¬║íu└│Ñ╬╡{ªíív╡L¬k░⌡ªµíC",                           /* 76 */
  128.     /*MSG79*/"íuADS └│Ñ╬╡{ªíív¬⌐Ñ╗╕╣╜Xñú¼█«eíC",                       /* 77 */
  129.     /*MSG80*/"íuADS └│Ñ╬╡{ªíívÑ┐ªb╣Bº@, ⌐╬¼Oíu▒_▓╒ívª╙╡L¬k¡½╖s╕ⁿñJíC", /* 78 */
  130.     /*MSG81*/"íuADS └│Ñ╬╡{ªíív⌐┌ªµíuXUNLOADívíC",                      /* 79 */
  131.     /*MSG82*/"½ⁿ⌐wñºíuADS └│Ñ╬╡{ªíív⌐|Ñ╝╕ⁿñJíC",                       /* 80 */
  132.     /*MSG83*/"╡L¿¼░≈¬║íu░O╛╨¬┼╢íívÑH¿╤╕ⁿñJíuADS └│Ñ╬╡{ªíív",           /* 81 */
  133.     /*MSG84*/"íu┬α╕m»x░}ív╡L«─íC",                                     /* 82 */
  134.     /*MSG85*/"íu▓┼╕╣ªW║┘ív╡L«─íC",                                     /* 83 */
  135.     /*MSG86*/"íu▓┼╕╣╝╞¡╚ív╡L«─íC",                                     /* 84 */
  136.     /*MSG87*/"íu╣∩╕▄«╪ívº@Ñ╬ñº╗┌ñúñ╣│\134ª╣╣Bº@íC",                    /* 85 */
  137.    };
  138.  
  139. /*  Local function declarations */
  140.  
  141. int     ads_perror  _((void));
  142.  
  143. #define STANDALONE 1                  /* This is meant to be ads_invoked */
  144.  
  145. #ifdef STANDALONE
  146.  
  147. void    main        _((int, char **));
  148. int     loadfuncs   _((void));
  149.  
  150.  
  151. /* MAIN -- the main routine */
  152. void
  153. main(argc,argv)
  154.   int argc;
  155.   char *argv[];
  156. {
  157.     int stat;
  158.     short scode = RSRSLT;
  159.  
  160.     ads_init(argc, argv);
  161.  
  162.     for ( ;; ) {
  163.  
  164.         if ((stat = ads_link(scode)) < 0) {
  165.             printf(/*MSG54*/"ADS_PERR: Ñ╤ ads_link() ╢╟ª^¬║ñú¿╬¬¼║A = %d\n",
  166.                    stat);
  167.             fflush(stdout);
  168.             exit(1);
  169.         }
  170.  
  171.         scode = RSRSLT;               /* default return value */
  172.  
  173.         /* Check for AT LEAST the following cases here */
  174.         switch (stat) {
  175.  
  176.         case RQXLOAD:
  177.             scode = loadfuncs() ? RSRSLT : -RSERR;
  178.             break;
  179.  
  180.         case RQSUBR:
  181.             ads_perror();
  182.             break;
  183.  
  184.         default:
  185.             break;
  186.  
  187.         }
  188.     }
  189. }
  190.  
  191.  
  192. /* LOADFUNCS  --  Define external functions with AutoLISP */
  193. static int loadfuncs()
  194. {
  195.     if (!ads_defun(/*MSG0*/"ads_perror", 0))
  196.         return FALSE;
  197.  
  198.     /* Although this function is never involved in some recursive call,
  199.        we ads_regfunc it so that future implementations may do away
  200.        with the need to go through the dispatch loop.
  201.     */
  202.  
  203.     ads_regfunc(ads_perror, 0);
  204.     return 1;
  205. }
  206.  
  207. #endif  /* STANDALONE */
  208.  
  209. #ifdef STANDALONE
  210. static
  211. #endif
  212. int
  213. /*FCN*/ads_perror()
  214. {
  215.     struct resbuf *argl, errval;
  216.  
  217.     argl = ads_getargs();
  218.  
  219.     if (ads_getfuncode() != 0)        /* This is the ONLY function here */
  220.         return RSRSLT;
  221.  
  222.     if (ads_getvar(/*MSG0*/"ERRNO", &errval) == RTERROR)
  223.         return RSRSLT;
  224.  
  225.     if (errval.resval.rint < 1 || errval.resval.rint > MAX_OL_ERRNO)
  226.         return RSRSLT;
  227.  
  228.     if (argl && argl->restype == RTSTR && strlen(argl->resval.rstring))
  229.         ads_printf("%s: ", argl->resval.rstring);
  230.  
  231.     ads_printf("%s\n", errmsg[errval.resval.rint - 1]);
  232.  
  233.     ads_relrb(argl);
  234.     ads_retvoid();
  235.  
  236.     return RSRSLT;
  237. }
  238.