home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p024 / 12.img / ADS1.LIB / ADS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-11  |  16.3 KB  |  388 lines

  1. /* 
  2.    ADS.H   -    Definitions of the AutoCAD functions for Applications 
  3.                 This takes the place of xlacad.h (from LISP) and contains
  4.                 the changes to the function definitions to make them
  5.                 compatible with the application interface.
  6.  
  7.       (C) Copyright 1988-1992 by Autodesk, Inc.
  8.  
  9.       This program is copyrighted by Autodesk, Inc. and is  licensed
  10.       to you under the following conditions.  You may not distribute
  11.       or  publish the source code of this program in any form.   You
  12.       may  incorporate this code in object form in derivative  works
  13.       provided  such  derivative  works  are  (i.) are  designed and
  14.       intended  to  work  solely  with  Autodesk, Inc. products, and
  15.       (ii.)  contain  Autodesk's  copyright  notice  "(C)  Copyright
  16.       1988-1992 by Autodesk, Inc."
  17.  
  18.       AUTODESK  PROVIDES THIS PROGRAM "AS IS" AND WITH  ALL  FAULTS.
  19.       AUTODESK  SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF  MER-
  20.       CHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK,  INC.
  21.       DOES  NOT  WARRANT THAT THE OPERATION OF THE PROGRAM  WILL  BE
  22.       UNINTERRUPTED OR ERROR FREE.
  23.  
  24.  
  25. */
  26.  
  27. #ifndef _ads_h
  28. #define _ads_h
  29.  
  30. /* There is a clash between the alignment required within structures for
  31.    ADS and that required for members within Zortech structs and classes.
  32.    ADS requires byte alignment (-a1) while 32-bit Zortech requires 4-byte
  33.    alignment (-a4).  To work around this clash the alignment is set to one
  34.    at the top of this header file and restored to four at the bottom so
  35.    that ADS structures are byte-aligned. */
  36. #ifdef __ZTC__
  37. #pragma ZTC align 1
  38. #endif
  39.  
  40. /* Ensure that C++ modules use the right linking conventions when calling
  41.    functions contained in C. */
  42. #ifdef __cplusplus
  43.     extern /*MSG0*/"C" {
  44. #endif
  45.  
  46.  
  47. /* A real to AutoCAD is a double precision float, and must be
  48.    used for all floating point numbers in AutoCAD. */
  49. typedef double ads_real;
  50.  
  51. /* The following types are used in functions that accept points or entity/ss
  52.    names, and return one of these as well. */
  53.  
  54. typedef ads_real ads_point[3];
  55. typedef long ads_name[2];
  56.  
  57. /* The following type is used by functions that accept a 3D matrix */
  58.  
  59. typedef ads_real ads_matrix[4][4];
  60.  
  61. /* The coordinates of a point */
  62. #define X  0
  63. #define Y  1
  64. #define Z  2
  65.  
  66. /* The translation vector of a 3D matrix */
  67. #define T  3
  68.  
  69. /* The PAUSE token for ads_command and ads_cmd */
  70. #define PAUSE "\\"
  71.  
  72. /* The ADS_INITGET control bits */
  73.  
  74. #define RSG_NONULL 0x01               /* Disallow null input */
  75. #define RSG_NOZERO 0x02               /* Disallow zero input */
  76. #define RSG_NONEG  0x04               /* Disallow negative input */
  77. #define RSG_NOLIM  0x08               /* Do not check limits */
  78. #define RSG_GETZ   0x10               /* Get Z coordinate */
  79. #define RSG_DASH   0x20               /* Draw dashed rubber band/box (not a
  80.                                          GEDIT control bit) */
  81. #define RSG_2D     0x40               /* Restrict (getdist) to 2D (causes the
  82.                                          UD_GETZ control bit to be cleared) */
  83. #define RSG_OTHER  0x80               /* Return input string if unknown */
  84.  
  85. /* Binary data stream structure */
  86.  
  87. struct ads_binary {                   /* Binary data chunk structure */
  88.     short clen;                       /* length of chunk in bytes */
  89.     char *buf;                        /* binary data */
  90. };
  91.  
  92. /*  Union for storing different ADS data types. */
  93.  
  94. union ads_u_val {
  95.    ads_real rreal;
  96.    ads_real rpoint[3];
  97.    short rint;
  98.    char *rstring;
  99.    long rlname[2];
  100.    long rlong;   
  101.    struct ads_binary rbinary;
  102. }; 
  103.  
  104. /* The following is the structure definition of the general result buffer.
  105.    This is used for both passing back results from functions, as well
  106.    as exotic applications like entity lists, and command function lists.
  107.    It is as close as we come to the AutoLISP node structure.  */
  108.  
  109. struct resbuf {                                                  
  110.         struct resbuf *rbnext;        /* Allows them to be "linked" */
  111.         short restype;
  112.         union ads_u_val resval;
  113. };
  114.  
  115. /* External function definitions accessible from applications */
  116.  
  117. /* Application initialization  function */
  118. void           ads_init _((int argc, char *argv[]));
  119.  
  120. /* General failure (prints message) mechanism */
  121. void           ads_fail _((const char *str));
  122.  
  123. /* General abort mechanism.  Return RSABORT to Lisp. */
  124. void           ads_abort _((const char *str));
  125.  
  126. /* ADS exit() function used for transparent exit of programs */
  127. void           ads_exit _((int status));
  128.  
  129. /* Register an ADS function handler */
  130. int            ads_regfunc _((int (*fhdl) (void), int fcode));
  131.  
  132. /* Link back to host with request code */
  133. int            ads_link _((int cbc));
  134.  
  135. /* Get a new result buffer */
  136. struct resbuf *ads_newrb _((int v));
  137.  
  138. /* Release a result buffer as well as those linked to it */
  139. int            ads_relrb _((struct resbuf *rb));
  140.  
  141. /* Check for a console break */
  142. int            ads_usrbrk _((void));
  143.  
  144.  
  145. /* Define an external subroutine in AutoLISP */
  146. int            ads_defun _((const char *sname, short funcno));
  147.  
  148. /* Undefine an external subroutine in AutoLISP */
  149. int            ads_undef _((const char *sname, short funcno));
  150.  
  151. /* Unitilies for external subroutine interface */
  152. int            ads_getfuncode _((void));
  153. struct resbuf *ads_getargs _((void));
  154.  
  155. /* Return the specified type as a result of external subroutine */
  156. int            ads_retlist _((const struct resbuf *rbuf));
  157. int            ads_retval _((const struct resbuf *rbuf));
  158. int            ads_retpoint _((const ads_point pt));
  159. int            ads_retstr _((const char *s));
  160. int            ads_retname _((const ads_name aname, int type));
  161. int            ads_retint _((int ival));
  162. int            ads_retreal _((ads_real rval));
  163. int            ads_rett _((void));
  164. int            ads_retnil _((void));
  165. int            ads_retvoid _((void));
  166.  
  167.  
  168. /* AutoCAD Entity access routines */
  169.  
  170. int            ads_entdel _((const ads_name ent));
  171. struct resbuf *ads_entgetx _((const ads_name ent, const struct resbuf *args));
  172. struct resbuf *ads_entget _((const ads_name ent));
  173. int            ads_entlast _((ads_name result));
  174. int            ads_entnext _((const ads_name ent, ads_name result));
  175. int            ads_entupd _((const ads_name ent));
  176. int            ads_entmod _((const struct resbuf *ent));
  177. int            ads_entmake _((const struct resbuf *ent));
  178. int            ads_entsel _((const char *str, ads_name entres,
  179.                              ads_point ptres));
  180. int            ads_nentsel _((const char *str, ads_name entres,
  181.                               ads_point ptres, ads_point xformres[4],
  182.                               struct resbuf **refstkres));
  183. int            ads_nentselp _((const char *str, ads_name entres,
  184.                               ads_point ptres, int pickflag,
  185.                               ads_matrix xformres,
  186.                               struct resbuf **refstkres));
  187. int            ads_ssget _((const char *str, const void *pt1,
  188.                             const ads_point pt2, const struct resbuf *filter,
  189.                             ads_name ss));
  190. int            ads_ssfree _((const ads_name sname));
  191. int            ads_sslength _((const ads_name sname, long *len));
  192. int            ads_ssadd _((const ads_name ename, const ads_name sname,
  193.                             ads_name result));
  194. int            ads_ssdel _((const ads_name ename, const ads_name ss));
  195. int            ads_ssmemb _((const ads_name ename, const ads_name ss));
  196. int            ads_ssname _((const ads_name ss, long i, ads_name entres));
  197.  
  198. /* Extended Entity data utilities */
  199. int            ads_xdroom _((const ads_name ent, long *result));
  200. int            ads_xdsize _((const struct resbuf *rb, long *result));
  201.  
  202. /* AutoCAD table access routines */
  203. struct resbuf *ads_tblnext _((const char *tblname, int rewind));
  204. struct resbuf *ads_tblsearch _((const char *tblname, const char *sym,
  205.                                 int setnext));
  206.  
  207. /* Drawing database utilities */
  208. int            ads_handent _((const char *handle, ads_name entres));
  209. int            ads_trans _((const ads_point pt, const struct resbuf *from,
  210.                             const struct resbuf *to, int disp,
  211.                             ads_point result));
  212.  
  213. /* General AutoCAD utility routines */
  214. int            ads_angtos _((ads_real v, int unit, int prec, char *str));
  215. int            ads_cvunit _((ads_real value, const char *oldunit,
  216.                              const char *newunit, ads_real *result));
  217. int            ads_wcmatch _((const char *string, const char *pattern));
  218. int            ads_rtos _((ads_real val, int unit, int prec, char *str));
  219. int            ads_angtof _((const char *str, int unit, ads_real *v));
  220. int            ads_distof _((const char *str, int unit, ads_real *v));
  221. int            ads_setvar _((const char *sym, const struct resbuf *val));
  222. int            ads_initget _((int val, const char *kwl));
  223.  
  224. int            ads_getsym _((const char *sname, struct resbuf **value));
  225. int            ads_putsym _((const char *sname, struct resbuf *value));
  226. struct resbuf  *ads_loaded _(());
  227. int            ads_xload _((const char *app));
  228. int            ads_xunload _((const char *app));
  229. #if    UNIX && !OS2
  230. int            ads_command ();
  231. struct resbuf *ads_buildlist ();
  232. int            ads_printf ();
  233. #else
  234. int            ads_command _((int rtype, ...));
  235. struct resbuf *ads_buildlist _((int rtype, ...));
  236. int            ads_printf _((const char *format, ...));
  237. #endif
  238. int            ads_cmd _((const struct resbuf *rbp));
  239. int            ads_invoke _((const struct resbuf *args,
  240.                              struct resbuf **result));
  241. int            ads_inters _((const ads_point from1, const ads_point to1,
  242.                              const ads_point from2, const ads_point to2,
  243.                              int teston, ads_point result));
  244.  
  245. /* Functions that get system variables */
  246. int            ads_getvar _((const char *sym, struct resbuf *result));
  247. int            ads_findfile _((const char *fname, char *result));
  248.  
  249. /* Function that gets a string */
  250. int            ads_getstring _((int cronly, const char *prompt, char *result));
  251.  
  252. /* Functions that pass AutoCAD a single string  */
  253. int            ads_menucmd _((const char *str));
  254. int            ads_prompt _((const char *str));
  255. int            ads_alert _((const char *str));
  256.  
  257. /* Function to register an application with AutoCAD */
  258. int            ads_regapp _((const char *appname));
  259.  
  260. /* Functions used to get user input  */
  261. int            ads_getangle _((const ads_point pt, const char *prompt,
  262.                                ads_real *result));
  263. int            ads_getcorner _((const ads_point pt, const char *prompt,
  264.                                 ads_point result));
  265. int            ads_getdist _((const ads_point pt, const char *prompt,
  266.                               ads_real *result));
  267. int            ads_getorient _((const ads_point pt, const char *prompt,
  268.                                 ads_real *result));
  269. int            ads_getpoint _((const ads_point pt, const char *prompt,
  270.                                ads_point result));
  271. int            ads_getint _((const char *prompt, int *result));
  272. int            ads_getkword _((const char *prompt, char *result));
  273. int            ads_getreal _((const char *prompt, ads_real *result));
  274. int            ads_getinput _((char *str));
  275. int            ads_vports _((struct resbuf **vlist));
  276.  
  277. /* Functions for screen flipping */
  278. int            ads_textscr _((void));
  279. int            ads_graphscr _((void));
  280. int            ads_textpage _((void));
  281.  
  282. /* Graphics related functions */
  283. int            ads_grclear _((void));
  284. int            ads_redraw _((const ads_name ent, int mode));
  285. int            ads_osnap _((const ads_point pt, const char *mode,
  286.                             ads_point result));
  287. int            ads_grread _((int track, int *type, struct resbuf *result));
  288. int            ads_grtext _((int box, const char *text, int hl));
  289. int            ads_grdraw _((const ads_point from, const ads_point to,
  290.                              int color, int hl));
  291. int            ads_grvecs _((const struct resbuf *vlist, ads_matrix mat));
  292. int            ads_xformss _((const ads_name ssname,
  293.                               ads_matrix genmat));
  294. int            ads_draggen _((const ads_name ss, const char *pmt, int cursor,
  295.                               int (*scnf) _((ads_point pt, ads_matrix mt)),
  296.                               ads_point p));
  297.  
  298. /* Geometry utilities */
  299. ads_real       ads_angle _((const ads_point pt1, const ads_point pt2));
  300. ads_real       ads_distance _((const ads_point pt1, const ads_point pt2));
  301. void           ads_polar _((const ads_point pt, ads_real angle,
  302.                             ads_real dist, ads_point ptres));
  303.  
  304. /* Functions that put up standard dialogs for user input */
  305. int            ads_getfiled _((const char *title, const char *defawlt,
  306.                                const char *ext, int flags,
  307.                                struct resbuf *result));
  308.  
  309. int            ads_textbox _((const struct resbuf *args,
  310.                               ads_point pt1, ads_point pt2));
  311.  
  312. /*  Function to retrieve or establish AutoCAD's tablet transformation: */
  313. int            ads_tablet  _((const struct resbuf *args,
  314.                               struct resbuf **result));
  315.  
  316. /* Functions to support ADS / ADI communications */
  317. int            ads_recfgport _((int *idvc, int iotype, int baudrate,
  318.                                 int parity, int databits, int stopbits,
  319.                                 int hhflag, char *devname));
  320. void           ads_adiinfo   _((void *dsinfoptr));
  321. void           ads_dscfg     _((void *dspktptr));
  322. void           ads_dsxqt     _((void *dspktptr));
  323. void           ads_dispt     _((void *dspktptr));
  324. void           ads_adistart  _((void *dsactptr));
  325. void           ads_adiend    _((void *dsactptr));
  326.  
  327. #ifdef WIN
  328. /* Call before termination to clean up Windows, DDE, memory, etc */
  329. void           adsi_machexit(int exitval);
  330. #endif
  331.  
  332. /* Functions for character handling */
  333. int            ads_isalpha _((int c));
  334. int            ads_isupper _((int c));
  335. int            ads_islower _((int c));
  336. int            ads_isdigit _((int c));
  337. int            ads_isxdigit _((int c));
  338. int            ads_isspace _((int c));
  339. int            ads_ispunct _((int c));
  340. int            ads_isalnum _((int c));
  341. int            ads_isprint _((int c));
  342. int            ads_isgraph _((int c));
  343. int            ads_iscntrl _((int c));
  344. int            ads_toupper _((int c));
  345. int            ads_tolower _((int c));
  346.  
  347. /* When you want something that's explicitly a pointer type and not an array
  348.    type, use ads_pointp and ads_namep.  Remember that if your function takes an
  349.    *array* of points, it still declares ads_point[] foo; */
  350. typedef ads_real *ads_pointp;
  351. typedef long     *ads_namep;
  352.  
  353. /* Define macros to copy them.  NOTE that the result is the SECOND argument,
  354.    consistent with ADS usage.  The standard C ones require <string.h> */
  355. #ifdef __STDC__
  356. #define ads_name_set(from, to)  (memcpy(to, from, sizeof(ads_name)))
  357. #define ads_point_set(from,to)  (memcpy(to, from, sizeof(ads_point)))
  358. #else
  359. #define ads_name_set(from, to)  (*(to)= *(from), (to)[1]=(from)[1])
  360. #define ads_point_set(from, to) (*(to)= *(from), (to)[1]=(from)[1], (to)[2]=(from)[2])
  361. #endif  /* !__STDC__ */
  362.  
  363. /* Define null value for ads_names.  These values are NOT guaranteed valid;
  364.    that is, there is no actual guarantee (such as C gives with NULL) that the
  365.    system will never under any circumstances generate the values as valid data.
  366.    The correct values will be created as part of the Lisp reinitialization
  367.    project, if we go through with that one, and will then be inserted here.
  368.    */
  369. #define ads_name_clear(name)    name[0] = name[1] = 0
  370. #define ads_name_nil(name)      (name[0] == 0 && name[1] == 0)
  371. #define ads_name_equal(name1, name2)  (name1[0]==name2[0] \
  372.                                        && name1[1]==name2[1])
  373.  
  374. #ifdef __cplusplus
  375.     }
  376. #endif
  377.  
  378. /* Restore the 32-bit Zortech C++ alignment to a 4-byte boundary (except
  379.    when building the Zortech ADS library, which requires 1-byte alignment:
  380.    P386 is defined when building the library). */
  381. #ifndef P386
  382. #ifdef __ZTC__
  383. #pragma ZTC align 4
  384. #endif
  385. #endif
  386.  
  387. #endif  /* !_ads_h */
  388.