SetToggleButtonState -> ToggleButtonSetState
[grace.git] / grace_np / gracef_np.c
blob04b21a30b3d2330d8fa6bae898ade11c5c0557fe
1 #include <config.h>
3 #if defined(WITH_F77_WRAPPER)
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
9 #include "grace_np.h"
11 #ifdef NEED_F77_UNDERSCORE
12 # define F77_FNAME(fname) fname ## _
13 #else
14 # define F77_FNAME(fname) fname
15 #endif
17 typedef void (*GraceFortranFunctionType) (const char *str, int len);
18 static GraceFortranFunctionType fortran_error = (GraceFortranFunctionType) 0;
20 static void GraceFortranWrapper(const char *str)
22 if (fortran_error == (GraceFortranFunctionType) 0) {
23 fprintf(stderr, "%s\n", str);
24 } else {
25 fortran_error(str, strlen(str));
29 void F77_FNAME(graceregistererrorfunctionf) (GraceFortranFunctionType f)
31 fortran_error = f;
32 GraceRegisterErrorFunction(GraceFortranWrapper);
35 int F77_FNAME(graceopenf) (const int *arg)
37 return (GraceOpen (*arg));
40 int F77_FNAME(graceisopenf) (void)
42 return (GraceIsOpen ());
45 int F77_FNAME(graceclosef) (void)
47 return (GraceClose ());
50 int F77_FNAME(graceclosepipef) (void)
52 return (GraceClosePipe());
55 int F77_FNAME(graceflushf) (void)
57 return (GraceFlush ());
61 int F77_FNAME(gracecommandf) (const char* arg, int length)
63 char* str;
64 int res;
66 str = (char*) malloc ((size_t) (length + 1));
67 if (str == NULL) {
68 fprintf (stderr, "GraceCommandf: Not enough memory\n");
69 return (-1);
71 strncpy (str, arg, length);
72 str[length] = 0;
73 res = GraceCommand (str);
74 free (str);
75 return (res);
78 #else /* don't include Fortran wrapper */
80 /* To make ANSI C happy about non-empty file */
81 void F77_FNAME(_gracef_np_c_dummy_func) (void) {}
83 #endif /* WITH_F77_WRAPPER */