home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p024 / 12.img / ADS2.LIB / TEMPLATE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-12  |  4.4 KB  |  143 lines

  1. /*    TEMPLATE.C
  2.       ¬⌐┼v (C) 1990-1992  Autodesk ñ╜Ñq
  3.  
  4.       Ñ╗│n┼ΘºK╢O¿╤▒z╢iªµÑ⌠ª≤Ñ╬│~╗▌¿D¬║½■¿⌐íB¡╫º∩ñ╬╡oªµ, ª²¼O░╚╜╨┐φ┤`ñU¡z
  5.       ¡∞½h :
  6.  
  7.       1)  ñWªC¬║¬⌐┼v│qºi░╚╗▌ÑX▓{ªb¿Cñ@Ñ≈½■¿⌐∙╪íC
  8.       2)  ¼█├÷¬║╗í⌐·ñσÑ≤ñ]Ñ▓╢╖⌐·╕ⁿ¬⌐┼v│qºiñ╬Ñ╗╢╡│\Ñi│qºiíC
  9.  
  10.       Ñ╗│n┼Θ╢╚┤ú¿╤º@¼░└│Ñ╬ñW¬║░╤ª╥, ª╙Ñ╝┴n⌐·⌐╬┴⌠ºtÑ⌠ª≤½O├╥; ╣∩⌐≤Ñ⌠ª≤»S«φ
  11.       Ñ╬│~ñº╛A║┘⌐╩, ÑHñ╬░╙╖~╛P░Γ⌐╥┴⌠ºtÑX¿π¬║½O├╥, ªbª╣ñ@╖ºñ⌐ÑHº_╗{íC
  12.  
  13.  
  14.  
  15.       DESCRIPTION:
  16.  
  17.       This is a template file to demonstrate the structure required by
  18.       an ADS application.
  19.  
  20.       Prototype for ADS application.
  21.  
  22.       by Amy Berger
  23.       April 16, 1990
  24.  
  25.       Updated July 30, 1990
  26.  
  27. */
  28.  
  29.  
  30. #include  <stdio.h>
  31. #include  "adslib.h"
  32.  
  33. static int loadfuncs();
  34. int adsfunc();
  35.  
  36.  
  37. /* MAIN - the main routine */
  38.  
  39.  
  40. void
  41. main(argc, argv)
  42.   int argc;
  43.   char *argv[];
  44. {
  45.     int stat;
  46.     short scode = RSRSLT;             /* This is the default result code */
  47.  
  48.     ads_init(argc, argv);             /* Initialize the interface */
  49.  
  50.     for ( ;; ) {                      /* Note loop conditions */
  51.  
  52.         if ((stat = ads_link(scode)) < 0) {
  53.  
  54.             printf("TEMPLATE: Ñ╤ ads_link() ╢╟ª^¬║ñú¿╬¬║¬¼║A = %d\n", stat);
  55.  
  56.             /* Can't use ads_printf to display
  57.                this message, because the link failed */
  58.             fflush(stdout);
  59.             exit(1);
  60.         }
  61.  
  62.         scode = RSRSLT;               /* Default return value */
  63.  
  64.         /* Check for the following cases here */
  65.         switch (stat) {
  66.  
  67.         case RQXLOAD:                 /* Register your ADS external functions.
  68.                                          Register your function handlers if you
  69.                                          want your ADS functions to be called
  70.                                          transparent to this dispatch loop.
  71.                                          Required for all applications.  */
  72.  
  73.             scode = loadfuncs() ? RSRSLT : RSERR;
  74.             break;
  75.  
  76.         case RQSUBR:                  /* This case is normally expanded to
  77.                                          select one of the application's
  78.                                          external functions */
  79.             break;
  80.  
  81.         case RQXUNLD:                 /* Do C program cleanup here.
  82.                                          Not required unless you need to
  83.                                          clean up your own allocated resources.
  84.  
  85.                                          Note: You don't have to undefine ADS
  86.                                          functions.  LISP does it for you.  */
  87.             break;
  88.  
  89.         case RQSAVE:                  /* AutoCAD SAVE command notification.
  90.                                          You can use it for your own database
  91.                                          synchronization.  Not required.  */
  92.             break;
  93.  
  94.         case RQQUIT:                  /* AutoCAD QUIT command notification.
  95.                                          Not required.  */
  96.             break;
  97.  
  98.         case RQEND:                   /* AutoCAD END command notification.
  99.                                          Not required.  */
  100.             break;
  101.  
  102.         default:
  103.             break;
  104.         }
  105.     }
  106. }
  107.  
  108.  
  109. /* LOADFUNCS  --  Define external functions with AutoLISP.
  110.  
  111.                   Normally expanded to call ads_defun() once for each
  112.                   external function to be defined, assigning each one a
  113.                   different ADS function code.  ads_regfunc() is then
  114.                   called to specify the handler function for each ADS
  115.                   function code.
  116. */
  117. static int loadfuncs()
  118. {
  119.     if (ads_defun("ADSFUNC", 0) == RTNORM) {   /* Define function */
  120.         ads_regfunc(adsfunc, 0);      /* Register handler */
  121.         return 1;
  122.     } else
  123.         return 0;
  124. }
  125.  
  126.  
  127. /* ADSFUNC  --  Sample handler for ADS function code 0.
  128.  
  129.                 This function will handle (ADSFUNC) calls.  You can have
  130.                 one handler for each external function, or use one handler
  131.                 for several functions.  ads_getfuncode() tells the handler
  132.                 which function (ADS function code) it's dealing with.
  133.  
  134.                 If you choose to use the RQSUBR method, you should place
  135.                 this function call following the RQSUBR switch statement.
  136. */
  137. int adsfunc()
  138. {
  139.     /* Do something. */
  140.  
  141.     return RSRSLT;                    /* Normal completion */
  142. }
  143.