Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

cutils.c

Go to the documentation of this file.
00001 
00002 /*
00003  * Copyright (c) 1986,1987,1988,1989,1990,1991,1992,1993,
00004  * by Steve McMillan, Drexel University, Philadelphia, PA.
00005  *
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms are permitted
00009  * provided that the above copyright notice and this paragraph are
00010  * duplicated in all such forms and that any documentation,
00011  * advertising materials, and other materials related to such
00012  * distribution and use acknowledge that the software was developed
00013  * by the author named above.
00014  *
00015  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
00016  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
00017  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00018  */
00019 
00020 /*
00021  *      CUTILS: C-files to allow FORTRAN to do I/O, communicate
00022  *              with the operating system, etc.  Note the annoying
00023  *              trailing underscores in some names...
00024  */
00025 
00026 #include <stdio.h>
00027 
00028 /*
00029  *      MYPUTC, MYGETC: I/O interfaces.
00030  */
00031 
00032 void myputc(c, l)
00033 char *c;
00034 long l;
00035 {
00036     putchar(*c);
00037     fflush(stdout);
00038 }
00039 
00040 void myputc_(c, l)
00041 char *c;
00042 long l;
00043 {
00044     myputc(c, l);
00045 }
00046 
00047 void mygetc(c, l)
00048 char *c;
00049 long l;
00050 {
00051     *c = getchar();
00052 }
00053 
00054 void mygetc_(c, l)
00055 char *c;
00056 long l;
00057 {
00058     mygetc(c, l);
00059 }
00060 
00061 /*----------------------------------------------------------------------*/
00062 
00063 /*
00064  *      The following routines are unnecessary on a Sun, but
00065  *      are necessary on other systems (e.g. HP, linux).
00066  *
00067  *      Define them so long as they don't conflict with a built-in.
00068  */
00069 
00070 /*
00071  *      CFLUSH:  FORTRAN-accessible call to flush.
00072  */
00073 
00074 void cflush()
00075 {
00076     fflush(stdout);
00077 }
00078 
00079 void cflush_()
00080 {
00081     cflush();
00082 }
00083 
00084 #include <stdlib.h>
00085 
00086 /*
00087  *      CGETENV:  FORTRAN-accessible call to getenv.
00088  *                Accepts and returns FORTRAN character strings.
00089  */
00090 
00091 void cgetenv(name, value, ln, lv)
00092 char *name, *value;
00093 long ln, lv;
00094 {
00095     int i;
00096     char *c;
00097     char temp[100];
00098 
00099     /* Translate name from FORTRAN to C */
00100 
00101     for (i = 0; i < ln; i++) temp[i] = name[i];
00102     temp[ln] = '\0';
00103 
00104     lv = 0;
00105     value[0] = '\0';
00106 
00107     if ( c = getenv(temp) )
00108       do {value[lv++] = *c;} while ( *(++c) > '\0' );
00109 }
00110 
00111 void cgetenv_(name, value, ln, lv)
00112 char *name, *value;
00113 long ln, lv;
00114 {
00115     cgetenv(name, value, ln, lv);
00116 }
00117 
00118 /*
00119  *      CSYSTEM:  Temporary patch for the FORTRAN "system" routine.
00120  *
00121  */
00122 
00123 int csystem(string, length)
00124 char *string;
00125 long int length;
00126 {
00127     char *str;
00128     int i;
00129     
00130     str = (char*) malloc(length+1);
00131     for (i = 0; i < length; i++) str[i] = string[i];
00132     str[length] = '\0';
00133 
00134     return system(str);
00135 }
00136 
00137 int csystem_(string, length)
00138 char *string;
00139 long int length;
00140 {
00141     csystem(string, length);
00142 }
00143 
00144 /*----------------------------------------------------------------------*/
00145 
00146 /*
00147  *      UWAIT:  Wait a specified number of microseconds.
00148  */
00149 
00150 uwait(iwait)
00151 int *iwait;
00152 {
00153 #ifdef HAS_USLEEP
00154     usleep (*iwait);
00155 #endif
00156 }
00157 
00158 uwait_(iwait)
00159 int *iwait;
00160 {
00161     uwait(iwait);
00162 }

Generated at Sun Feb 24 09:56:57 2002 for STARLAB by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001