home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include "clink.h"
-
- /********
- *
- * Add temperature conversion functions to the basic compliment
- * of KMAN functions.
- *
- ********/
- centry(argc, argv)
- int argc;
- struct item argv[];
- {
- /* check for the Farenheit TO Celsius conversion function */
- if (strcmp(argv[0].data.str, "FTOC") == 0)
- ftoc(argc, argv);
-
- /* check for the Celsius TO Farenheit conversion function */
- else if (strcmp(argv[0].data.str, "CTOF") == 0)
- ctof(argc, argv);
-
- else /* unrecognized function name ... return ERROR !!! */
- return (-1);
-
- return (0); /* return the sucessful response */
- }
-
- /********
- *
- * ftoc - convert from the farenheit temperature scale into the celcius
- * temperature scale.
- *
- ********/
- ftoc(argc, argv)
- int argc; /* input argument count */
- struct item argv[]; /* input argument data vector */
- {
- double c; /* scratch for celsius temp value */
-
- c = 0.0;
- if (argc != 2)
- /* ERROR !!! incorrect number of arguments */
- ;
- else {
- /* process integer arguments ... */
- if (argv[1].type == DINT)
- c = (argv[1].data.intt - 32) * 5.0 / 9.0;
-
- /* process floating point numeric arguments ... */
- else if (argv[1].type == DNUM)
- c = (argv[1].data.num - 32.0) * 5.0 / 9.0;
-
- else /* ERROR !!! incorrect data type */
- ;
- }
-
- /* assign the results into the first input 'item' structure */
- argv[0].data.num = c;
- argv[0].type = DNUM;
- }
-
- /********
- *
- * ctof - convert from the celsius temperature scale into the farenheit
- * temperature scale.
- *
- ********/
- ctof(argc, argv)
- int argc; /* input argument count */
- struct item argv[]; /* input argument data vector */
- {
- double f; /* scratch for farenheit temp value */
-
- f = 0.0;
- if (argc != 2)
- /* ERROR !!! incorrect number of arguments */
- ;
- else {
- /* process integer arguments ... */
- if (argv[1].type == DINT)
- f = (argv[1].data.intt * 9.0 / 5.0) + 32.0;
-
- /* process floating point numeric arguments ... */
- else if (argv[1].type == DNUM)
- f = (argv[1].data.num * 9.0 / 5.0) + 32.0;
-
- else /* ERROR !!! incorrect data type */
- ;
- }
-
- /* assign the results into the first input 'item' structure */
- argv[0].data.num = f;
- argv[0].type = DNUM;
- }
-