40 |
# endif |
# endif |
41 |
# include <string.h> |
# include <string.h> |
42 |
#endif |
#endif |
43 |
|
|
44 |
|
#if HAVE_LIBGUILE_H |
45 |
|
# include <libguile.h> |
46 |
|
#endif |
47 |
#if HAVE_GUILE_GH_H |
#if HAVE_GUILE_GH_H |
48 |
# include <guile/gh.h> |
# include <guile/gh.h> |
49 |
#endif |
#endif |
108 |
char *text, *textmin, *bufmin; |
char *text, *textmin, *bufmin; |
109 |
int len; |
int len; |
110 |
|
|
111 |
text = gh_scm2newstr (gh_car (elem), &len); |
text = gh_scm2newstr (SCM_CAR (elem), &len); |
112 |
/* duplicate and lowerize all strings to become case insensitive */ |
/* duplicate and lowerize all strings to become case insensitive */ |
113 |
bufmin = strdup (buffer); |
bufmin = strdup (buffer); |
114 |
textmin = strdup (text); |
textmin = strdup (text); |
120 |
log (LOG_NOTICE, gettext ("Script: String '%s' matched\n"), text); |
log (LOG_NOTICE, gettext ("Script: String '%s' matched\n"), text); |
121 |
/* evaluate next elem */ |
/* evaluate next elem */ |
122 |
#if HAVE_R5RS_EVAL |
#if HAVE_R5RS_EVAL |
123 |
*result = scm_eval (gh_cadr (elem), scm_current_module()); |
*result = scm_eval (SCM_CADR (elem), scm_current_module()); |
124 |
#else |
#else |
125 |
*result = scm_eval (gh_cadr (elem)); |
*result = scm_eval (SCM_CADR (elem)); |
126 |
#endif |
#endif |
127 |
match = 1; |
match = 1; |
128 |
} |
} |
151 |
do |
do |
152 |
{ |
{ |
153 |
found = compare_elem (buffer, elem, result); |
found = compare_elem (buffer, elem, result); |
154 |
elem = gh_car (remainder); |
elem = SCM_CAR (remainder); |
155 |
remainder = gh_cdr (remainder); |
remainder = SCM_CDR (remainder); |
156 |
} |
} |
157 |
while (gh_length (remainder) > 0 && !found); |
while (gh_length (remainder) > 0 && !found); |
158 |
|
|
159 |
/* treat the last element only if it isn't an else */ |
/* treat the last element only if it isn't an else */ |
160 |
if (!found && gh_string_p (elem)) |
if (!found && SCM_STRINGP (elem)) |
161 |
{ |
{ |
162 |
found = compare_elem (buffer, elem, result); |
found = compare_elem (buffer, elem, result); |
163 |
} |
} |
174 |
log (LOG_NOTICE, gettext ("Script: No string matched\n")); |
log (LOG_NOTICE, gettext ("Script: No string matched\n")); |
175 |
if (gh_length (others) > 0) |
if (gh_length (others) > 0) |
176 |
{ |
{ |
177 |
elem = gh_car (gh_reverse (others)); |
elem = SCM_CAR (scm_reverse (others)); |
178 |
} |
} |
179 |
return 0; |
return 0; |
180 |
} |
} |
237 |
SCM result = SCM_UNDEFINED; |
SCM result = SCM_UNDEFINED; |
238 |
SCM connect; |
SCM connect; |
239 |
|
|
240 |
|
/*#if HAVE_SCM_C_DEFINE_GSUBR |
241 |
|
scm_c_define_gsubr ("chat-success", 0, 0, 0, chat_success); |
242 |
|
scm_c_define_gsubr ("chat-failure", 0, 0, 0, chat_failure); |
243 |
|
scm_c_define_gsubr ("chat-send", 1, 0, 0, chat_send); |
244 |
|
scm_c_define_gsubr ("chat-try", 2, 0, 1, chat_try); |
245 |
|
#els*/ |
246 |
|
#if HAVE_GH_NEW_PROCEDURE |
247 |
gh_new_procedure ("chat-success", chat_success, 0, 0, 0); |
gh_new_procedure ("chat-success", chat_success, 0, 0, 0); |
248 |
gh_new_procedure ("chat-failure", chat_failure, 0, 0, 0); |
gh_new_procedure ("chat-failure", chat_failure, 0, 0, 0); |
249 |
gh_new_procedure ("chat-send", chat_send, 1, 0, 0); |
gh_new_procedure ("chat-send", chat_send, 1, 0, 0); |
250 |
gh_new_procedure ("chat-try", chat_try, 2, 0, 1); |
gh_new_procedure ("chat-try", chat_try, 2, 0, 1); |
251 |
|
#endif |
252 |
|
|
253 |
gh_eval_file (filename); |
/*#if HAVE_SCM_C_PRIMITIVE_LOAD |
254 |
|
scm_c_primitive_load (filename); |
255 |
|
#els*/ |
256 |
|
#if HAVE_GH_EVAL_FILE |
257 |
|
gh_eval_file(filename); |
258 |
|
#endif |
259 |
|
|
260 |
|
/*#if HAVE_SCM_C_LOOKUP |
261 |
|
connect = scm_c_lookup ("chat-connect"); |
262 |
|
#els */ |
263 |
|
#if HAVE_GH_LOOKUP |
264 |
connect = gh_lookup ("chat-connect"); |
connect = gh_lookup ("chat-connect"); |
265 |
|
#endif |
266 |
result = gh_call0 (connect); |
result = gh_call0 (connect); |
267 |
|
|
268 |
if (!gh_boolean_p (result)) |
if (!SCM_BOOLP (result)) |
269 |
{ |
{ |
270 |
log (LOG_ERR, gettext ("%s: returned value isn't a boolean.\n"), |
log (LOG_ERR, gettext ("%s: returned value isn't a boolean.\n"), |
271 |
filename); |
filename); |