Remove extra debug message
[geda-gaf.git] / gschem / src / g_funcs.c
blob423880a0f2a753b4c85a0edd71e06700b849e827
1 /* gEDA - GPL Electronic Design Automation
2 * gschem - gEDA Schematic Capture
3 * Copyright (C) 1998-2010 Ales Hvezda
4 * Copyright (C) 1998-2019 gEDA Contributors (see ChangeLog for details)
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 of the License, or
9 * (at your option) any later version.
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 program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #include <config.h>
22 #include <stdio.h>
23 #include <sys/stat.h>
24 #include <ctype.h>
25 #ifdef HAVE_STRING_H
26 #include <string.h>
27 #endif
28 #ifdef HAVE_STDLIB_H
29 #include <stdlib.h>
30 #endif
31 #ifdef HAVE_UNISTD_H
32 #include <unistd.h>
33 #endif
35 #include "gschem.h"
37 /*! \todo Finish function documentation!!!
38 * \brief
39 * \par Function Description
42 SCM g_funcs_pdf (SCM scm_filename)
44 char *filename;
45 gboolean status;
46 GschemToplevel *w_current = g_current_window ();
48 SCM_ASSERT (scm_is_string (scm_filename), scm_filename,
49 SCM_ARG1, "gschem-pdf");
51 if (output_filename) {
52 status = x_print_export_pdf (w_current, output_filename);
53 } else {
54 filename = scm_to_utf8_string(scm_filename);
55 status = x_print_export_pdf (w_current, filename);
56 free(filename);
59 return (status ? SCM_BOOL_T : SCM_BOOL_F);
62 /*! \todo Finish function documentation!!!
63 * \brief
64 * \par Function Description
67 SCM g_funcs_image(SCM scm_filename)
69 char *filename;
71 SCM_ASSERT (scm_is_string (scm_filename), scm_filename,
72 SCM_ARG1, "gschem-image");
74 GschemToplevel *w_current = g_current_window ();
76 if (output_filename) {
77 x_image_lowlevel (w_current, output_filename,
78 w_current->image_width,
79 w_current->image_height,
80 g_strdup("png"));
81 } else {
82 filename = scm_to_utf8_string (scm_filename);
83 x_image_lowlevel (w_current, filename,
84 w_current->image_width,
85 w_current->image_height,
86 g_strdup("png"));
87 free(filename);
90 return SCM_BOOL_T;
93 /*! \todo Finish function documentation!!!
94 * \brief
95 * \par Function Description
98 SCM g_funcs_exit(void)
100 exit(0);
103 /*! \todo Finish function documentation!!!
104 * \brief
105 * \par Function Description
108 SCM g_funcs_log(SCM scm_msg)
110 char *msg;
112 SCM_ASSERT (scm_is_string (scm_msg), scm_msg,
113 SCM_ARG1, "gschem-log");
115 msg = scm_to_utf8_string (scm_msg);
116 s_log_message ("%s", msg);
117 free(msg);
119 return SCM_BOOL_T;
122 /*! \todo Finish function documentation!!!
123 * \brief
124 * \par Function Description
127 SCM g_funcs_msg(SCM scm_msg)
129 char *msg;
131 SCM_ASSERT (scm_is_string (scm_msg), scm_msg,
132 SCM_ARG1, "gschem-msg");
134 msg = scm_to_utf8_string (scm_msg);
135 generic_msg_dialog (msg);
136 free(msg);
138 return SCM_BOOL_T;
141 /*! \todo Finish function documentation!!!
142 * \brief
143 * \par Function Description
146 SCM g_funcs_confirm(SCM scm_msg)
148 int r;
149 char *msg;
151 SCM_ASSERT (scm_is_string (scm_msg), scm_msg,
152 SCM_ARG1, "gschem-msg");
154 msg = scm_to_utf8_string (scm_msg);
155 r = generic_confirm_dialog (msg);
156 free(msg);
158 if (r)
159 return SCM_BOOL_T;
160 else
161 return SCM_BOOL_F;
164 /*! \todo Finish function documentation!!!
165 * \brief
166 * \par Function Description
169 SCM g_funcs_filesel(SCM scm_msg, SCM scm_templ, SCM scm_flags)
171 int c_flags;
172 char *r, *msg, *templ;
173 SCM v;
175 SCM_ASSERT (scm_is_string (scm_msg), scm_msg,
176 SCM_ARG1, "gschem-filesel");
178 SCM_ASSERT (scm_is_string (scm_templ), scm_templ,
179 SCM_ARG2, "gschem-filesel");
181 /*! \bug FIXME -- figure out the magic SCM_ASSERT for the flags */
183 /*! \bug FIXME -- how to deal with conflicting flags?
184 * Should I throw a scheme error? Just deal in the c code?
186 for (c_flags = 0; scm_is_pair (scm_flags); scm_flags = SCM_CDR (scm_flags)) {
187 char *flag;
188 SCM scm_flag = SCM_CAR (scm_flags);
190 flag = scm_to_utf8_string (scm_flag);
191 if (strcmp (flag, "may_exist") == 0) {
192 c_flags |= FSB_MAY_EXIST;
194 } else if (strcmp (flag, "must_exist") == 0) {
195 c_flags |= FSB_MUST_EXIST;
197 } else if (strcmp (flag, "must_not_exist") == 0) {
198 c_flags |= FSB_SHOULD_NOT_EXIST;
200 } else if (strcmp (flag, "save") == 0) {
201 c_flags |= FSB_SAVE;
203 } else if (strcmp (flag, "open") == 0) {
204 c_flags |= FSB_LOAD;
206 } else {
207 free(flag);
208 scm_wrong_type_arg ("gschem-filesel", SCM_ARG3, scm_flag);
210 free(flag);
213 scm_dynwind_begin (0);
214 msg = scm_to_utf8_string (scm_msg);
215 scm_dynwind_free (msg);
216 templ = scm_to_utf8_string (scm_templ);
217 scm_dynwind_free (templ);
219 r = generic_filesel_dialog (msg, templ, c_flags);
220 scm_dynwind_unwind_handler (g_free, r, SCM_F_WIND_EXPLICITLY);
222 v = scm_from_utf8_string (r);
224 scm_dynwind_end();
225 return v;
228 /*! \todo Finish function documentation!!!
229 * \brief
230 * \par Function Description
233 SCM g_funcs_use_rc_values(void)
235 i_vars_set(g_current_window ());
236 return SCM_BOOL_T;