/*======================================================================*/
/*  Calculator Function Routine(s)                                      */
/*======================================================================*/

#include stdio

/* calculator common definitions */

#include "calc_include.h"

/* global flags and variables */

extern int    debug_flag;
extern int    error_flag;


/*----------------------------------------------------------------------*/
/*  ABS Function Parsed                                                 */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int abs_function(options,stringcnt,stringptr,tokencnt,
                 tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(ABS);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  ACOS Function Parsed                                                */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int acos_function(options,stringcnt,stringptr,tokencnt,
                  tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(ACOS);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  ASIN Function Parsed                                                */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int asin_function(options,stringcnt,stringptr,tokencnt,
                  tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(ASIN);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  ATAN Function Parsed                                                */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int atan_function(options,stringcnt,stringptr,tokencnt,
                  tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(ATAN);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  CEILING Function Parsed                                             */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int ceiling_function(options,stringcnt,stringptr,tokencnt,
                     tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(CEILING);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  COS Function Parsed                                                 */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int cos_function(options,stringcnt,stringptr,tokencnt,
                 tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(COS);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  COSH Function Parsed                                                */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int cosh_function(options,stringcnt,stringptr,tokencnt,
                  tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(COSH);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  EXP Function Parsed                                                 */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int exp_function(options,stringcnt,stringptr,tokencnt,
                 tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(EXP);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  FLT Function Parsed                                                 */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int flt_function(options,stringcnt,stringptr,tokencnt,
                 tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(FLT);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  FLOOR Function Parsed                                               */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int floor_function(options,stringcnt,stringptr,tokencnt,
                   tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(FLOOR);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  INT Function Parsed                                                 */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int int_function(options,stringcnt,stringptr,tokencnt,
                 tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(INT);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  LN Function Parsed                                                  */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int ln_function(options,stringcnt,stringptr,tokencnt,
                tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(LN);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  LOG Function Parsed                                                 */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int log_function(options,stringcnt,stringptr,tokencnt,
                 tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(LOG);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  POW Function Parsed                                                 */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int pow_function(options,stringcnt,stringptr,tokencnt,
                 tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(POW);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  RAND Function Parsed                                                */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int rand_function(options,stringcnt,stringptr,tokencnt,
                  tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(RAND);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  MAX Function Parsed                                                 */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int max_function(options,stringcnt,stringptr,tokencnt,
                 tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(MAX);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  MIN Function Parsed                                                 */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int min_function(options,stringcnt,stringptr,tokencnt,
                 tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(MIN);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  MOD Function Parsed                                                 */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int mod_function(options,stringcnt,stringptr,tokencnt,
                 tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(MOD);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  SEED Function Parsed                                                */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int seed_function(options,stringcnt,stringptr,tokencnt,
                  tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(SEED);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  SIN Function Parsed                                                 */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int sin_function(options,stringcnt,stringptr,tokencnt,
                 tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(SIN);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  SINH Function Parsed                                                */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int sinh_function(options,stringcnt,stringptr,tokencnt,
                  tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(SINH);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  SQRT Function Parsed                                                */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int sqrt_function(options,stringcnt,stringptr,tokencnt,
                  tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(SQRT);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  TAN Function Parsed                                                 */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int tan_function(options,stringcnt,stringptr,tokencnt,
                 tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);
                             
   create_function_token(TAN);

   return 1;
}


/*----------------------------------------------------------------------*/
/*  TANH Function Parsed                                                */
/*                                                                      */
/*  Parameter  Description                                              */
/*                                                                      */
/*  options    processing option flags                                  */
/*  stringcnt  length of input string                                   */
/*  stringptr  address of input string                                  */
/*  tokencnt   length of current token                                  */
/*  tokenptr   address of current token                                 */
/*  character  character value of character token                       */
/*  number     binary value of numeric token                            */
/*  param      user supplied argument                                   */
/*                                                                      */
/*----------------------------------------------------------------------*/

int tanh_function(options,stringcnt,stringptr,tokencnt,
                  tokenptr,character,number,param)
int  options,stringcnt,tokencnt,number,param;
char character,stringptr[],tokenptr[];
{
   if (debug_flag)
      printf("Function:   %.*s\n",tokencnt,tokenptr);

   create_function_token(TANH);

   return 1;
}
