home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************
- CALMNGF.C
- (C) ¬⌐┼v 1988-1992 Autodesk ñ╜Ñq
-
- Ñ╗╡{ªíñwÑ╤ Autodesk ñ╜Ñq╡∙ÑU¬⌐┼v, ╢╚⌐≤ñU¡z▒í¬pñUÑi▒┬╗P▒zíu│\ÑiívíC
- ╗╒ñUñú▒oÑHÑ⌠ª≤º╬ªí╡oªµ⌐╬ÑX¬⌐ª╣╡{ªí¬║íu¡∞⌐l╜Xív; ª²ñ╣│\▒zªb»S⌐w¡lÑ═
- ¬║ñuº@ñW╡▓ªXª╣╡{ªí¬║íuÑ╪¬║╜Xív¿╧Ñ╬íCª│├÷│o├■¡lÑ═ñuº@¬║▒°Ñ≤ªpñU:
-
- ( i) │]¡pñW╗Pñuº@ñW¼╥»┬║Θ░w╣∩ Autodesk ñ╜Ñq¬║▓ú½~íC
- (ii) ╕ⁿª│íu¬⌐┼v (C) 1988-1992 Autodesk ñ╜Ñqív¬║¬⌐┼v│qºiíC
-
-
-
- AUTODESKñ╜Ñq┤ú¿╤ª╣╡{ªí╢╚¿╤º@íu├■ªⁿív¬║░╤ª╥, ª╙ÑBñú▒╞░úª│Ñ⌠ª≤┐∙╗~¬║
- Ñi»αíCAUTODESKñ╜Ñq»Sª╣º_╗{Ñ⌠ª≤»S⌐wÑ╬│~ñº╛A║┘⌐╩, ÑHñ╬░╙╖~╛P░Γ⌐╥┴⌠ºt
- ÑX¿π¬║½O├╥íCAUTODESKñ╜ÑqªP«╔ÑτñúÑX¿πª╣╡{ªí░⌡ªµ«╔ñ@⌐wñú╖|íuññ┬_ív⌐╬
- íuº╣Ñ■╡L╗~ív¬║½O├╥íC
-
-
- Description: Management of the table of calculator functions.
-
- *****************************************************************************/
-
-
- /****************************************************************************/
- /* INCLUDES */
- /****************************************************************************/
-
- #include "cal.h"
-
-
- /****************************************************************************/
- /* EXPORTED VARIABLES */
- /****************************************************************************/
-
- cft cal_funcs_table; /* Table of calculator functions */
- int cal_funcs_number = 0; /* Number of calculator functions */
-
- /* Variables for passing actual parameters to calculator functions
- and returning the value from the function:
-
- Before a calculator function is called, its acutal parameters must
- be stored in global array 'params[]'. The function returns its result
- in global variable 'result'. See functions in module 'calstdf.c'.
- */
-
- int no_of_params;
- vector_real_int params[MAX_FUNC_PARAM];
- vector_real_int result;
-
-
- /****************************************************************************/
- /*.doc cal_register_function(external)*/
- /*+
- Function registers new calculator function. 'func_name' is the
- name of the function which will be used to refer to this function
- in arithmetic expressions, 'func_ptr' is a pointer to the function
- definition. If the function fails, it prints an error message
- and terminates the ADS application.
- -*/
- /****************************************************************************/
-
-
- void
- /*FCN*/cal_register_function(func_name, func_ptr)
-
- char *func_name;
- void (*func_ptr)();
- {
- int i;
- char name[MAX_SYMBOL_LENGTH+1];
- int len;
-
- if (cal_err)
- return;
-
- /* Do initial checking */
-
- if (cal_funcs_number >= MAX_CAL_FUNC) {
- error(44, NULL);
- return;
- }
-
- if (func_name == NULL) {
- error(46, NULL);
- return;
- }
-
- len = strlen(func_name);
-
- if (len > MAX_SYMBOL_LENGTH) {
- error(47, func_name);
- return;
- }
-
- /* Check whether the function name is an identifier */
-
- strcpy(name, func_name);
-
- if (!ads_isalpha(name[0])) {
- error(42, func_name);
- return;
- }
- for (i = 0; i < len; i++) {
- name[i] = ads_toupper(name[i]);
- if (!ads_isalnum(name[i]) && (name[i] != '_')) {
- error(42, func_name);
- return;
- }
- }
-
- /* Check whether function of this name wasn't already registered */
-
- for (i = 0; i < cal_funcs_number; i++) {
- if (strcmp(cal_funcs_table[i].name, name) == 0) {
- error(60, func_name);
- return;
- }
- }
-
- /* Insert the new calculator function at the end of the table */
-
- strcpy(cal_funcs_table[cal_funcs_number].name, name);
- cal_funcs_table[cal_funcs_number].func = func_ptr;
- cal_funcs_number++;
-
- } /*cal_register_function*/
-
-
- /****************************************************************************/
- /*.doc cal_invoke_function(external)*/
- /*+
- Invoke calculator function whose name is 'func_name'.
-
- Before a function is invoked, the function parameters must be stored in
- array'params[]', the number of actual parameters in 'no_of_params'. The
- invoked function returns its result in 'result'.
-
- Function returns TRUE if function 'func_name' was successfully invoked
- and the invoked function succeeded, otherwise FALSE is returned. You can
- use 'cal_err' variable to check the reason why the invocation failed.
- -*/
- /****************************************************************************/
-
-
- int
- /*FCN*/cal_invoke_function(func_name)
-
- char *func_name;
- {
- int i;
-
- if (cal_err)
- return(FALSE);
-
- for (i = 0; i < cal_funcs_number; i++) {
- if (strcmp(func_name, cal_funcs_table[i].name) == 0) {
- (*cal_funcs_table[i].func)();
- return(cal_err == 0);
- }
- } /*for*/
-
- error(52, func_name);
- return(FALSE);
- } /*cal_invoke_function*/
-
-