2 * gwaverepl - read-evaluate-print loop connected to running gwave process.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this software; see the file COPYING.GPL. If not, write to
18 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19 * Boston, MA 02111-1307 USA
34 extern char *split_at(char **to_split
, int i
);
40 if (!(dispName
= getenv("DISPLAY")))
42 if (!(display
= XOpenDisplay(dispName
)))
54 main(int argc
, char **argv
)
63 char *result
, *out
, *err
;
68 char *gather
= g_new(char, 1);
72 die("Usage: gwaverepl\n");
74 die("Could not connect to gwave server. Check your DISPLAY environment variable.\n");
76 w
=xgexec_init(display
);
79 die("Unable to establish gwave-exec connection.\n");
85 if ((splitpoint
= check_balance(gather
))) {
86 char *result
, *error
, *output
;
87 expr
= split_at(&gather
,splitpoint
);
89 result
= xgexec_exec_full(display
, w
, expr
, &output
, &error
);
90 fputs (output
, stdout
);
91 if (strlen(error
)!=0) {
94 fputs(result
, stdout
);
98 if (result
) { g_free(result
); result
= NULL
; }
99 if (output
) { g_free(output
); output
= NULL
; }
100 if (error
) { g_free(error
); error
= NULL
; }
104 done
= !appending_fgets(&gather
);
108 XCloseDisplay (display
);