/[pengfork]/pengfork/src/modem/script.c
ViewVC logotype

Diff of /pengfork/src/modem/script.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10 by chupa, Fri Dec 13 15:29:15 2002 UTC revision 1.11 by chupa, Thu Jan 2 13:43:49 2003 UTC
# Line 40  Line 40 
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
# Line 104  compare_elem (buffer, elem, result) Line 108  compare_elem (buffer, elem, result)
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);
# Line 116  compare_elem (buffer, elem, result) Line 120  compare_elem (buffer, elem, result)
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      }      }
# Line 147  compare_buf (buffer, first, others, resu Line 151  compare_buf (buffer, first, others, resu
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      }      }
# Line 170  do_else (others, result) Line 174  do_else (others, result)
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  }  }
# Line 233  chat_connect (filename) Line 237  chat_connect (filename)
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);

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26