home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_guile.idb / usr / freeware / include / libguile / hooks.h.z / hooks.h
Encoding:
C/C++ Source or Header  |  2002-07-08  |  4.0 KB  |  126 lines

  1. /* classes: h_files */
  2.  
  3. #ifndef SCM_HOOKS_H
  4. #define SCM_HOOKS_H
  5. /* Copyright (C) 1995,1996,1999,2000,2001 Free Software Foundation, Inc.
  6.  * 
  7.  * This program is free software; you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License as published by
  9.  * the Free Software Foundation; either version 2, or (at your option)
  10.  * any later version.
  11.  * 
  12.  * This program is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  * GNU General Public License for more details.
  16.  * 
  17.  * You should have received a copy of the GNU General Public License
  18.  * along with this software; see the file COPYING.  If not, write to
  19.  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  20.  * Boston, MA 02111-1307 USA
  21.  *
  22.  * As a special exception, the Free Software Foundation gives permission
  23.  * for additional uses of the text contained in its release of GUILE.
  24.  *
  25.  * The exception is that, if you link the GUILE library with other files
  26.  * to produce an executable, this does not by itself cause the
  27.  * resulting executable to be covered by the GNU General Public License.
  28.  * Your use of that executable is in no way restricted on account of
  29.  * linking the GUILE library code into it.
  30.  *
  31.  * This exception does not however invalidate any other reasons why
  32.  * the executable file might be covered by the GNU General Public License.
  33.  *
  34.  * This exception applies only to the code released by the
  35.  * Free Software Foundation under the name GUILE.  If you copy
  36.  * code from other Free Software Foundation releases into a copy of
  37.  * GUILE, as the General Public License permits, the exception does
  38.  * not apply to the code that you add in this way.  To avoid misleading
  39.  * anyone as to the status of such modified files, you must delete
  40.  * this exception notice from them.
  41.  *
  42.  * If you write modifications of your own for GUILE, it is your choice
  43.  * whether to permit this exception to apply to your modifications.
  44.  * If you do not wish that, delete this exception notice.  */
  45.  
  46.  
  47.  
  48. #include "libguile/__scm.h"
  49.  
  50. /*
  51.  * C level hooks
  52.  */
  53.  
  54. /*
  55.  * The interface is designed for and- and or-type hooks which
  56.  * both may want to indicate success/failure and return a result.
  57.  */
  58.  
  59. typedef enum scm_t_c_hookype_t {
  60.   SCM_C_HOOK_NORMAL,
  61.   SCM_C_HOOK_OR,
  62.   SCM_C_HOOK_AND
  63. } scm_t_c_hookype_t;
  64.  
  65. typedef void  *(*scm_t_c_hook_function) (void *hook_data,
  66.                      void *func_data,
  67.                      void *data);
  68.  
  69. typedef struct scm_t_c_hook_entry {
  70.   struct scm_t_c_hook_entry *next;
  71.   scm_t_c_hook_function func;
  72.   void *data;
  73. } scm_t_c_hook_entry;
  74.  
  75. typedef struct scm_t_c_hook {
  76.   scm_t_c_hook_entry *first;
  77.   scm_t_c_hookype_t type;
  78.   void *data;
  79. } scm_t_c_hook;
  80.  
  81. extern void scm_c_hook_init (scm_t_c_hook *hook,
  82.                  void *hook_data,
  83.                  scm_t_c_hookype_t type);
  84. extern void scm_c_hook_add (scm_t_c_hook *hook,
  85.                 scm_t_c_hook_function func,
  86.                 void *func_data, 
  87.                 int appendp);
  88. extern void scm_c_hook_remove (scm_t_c_hook *hook,
  89.                    scm_t_c_hook_function func,
  90.                    void *func_data);
  91. extern void *scm_c_hook_run (scm_t_c_hook *hook, void *data);
  92.  
  93. /*
  94.  * Scheme level hooks
  95.  */
  96.  
  97. extern scm_t_bits scm_tc16_hook;
  98.  
  99. #define SCM_HOOKP(x)            SCM_TYP16_PREDICATE (scm_tc16_hook, x)
  100. #define SCM_HOOK_ARITY(hook)        (SCM_CELL_WORD_0 (hook) >> 16)
  101. #define SCM_HOOK_PROCEDURES(hook)    SCM_CELL_OBJECT_1 (hook)
  102. #define SCM_SET_HOOK_PROCEDURES(hook, procs) SCM_SET_CELL_OBJECT_1 ((hook), (procs))
  103.  
  104. extern SCM scm_make_hook (SCM n_args);
  105. extern SCM scm_hook_p (SCM x);
  106. extern SCM scm_hook_empty_p (SCM hook);
  107. extern SCM scm_add_hook_x (SCM hook, SCM thunk, SCM appendp);
  108. extern SCM scm_remove_hook_x (SCM hook, SCM thunk);
  109. extern SCM scm_reset_hook_x (SCM hook);
  110. extern SCM scm_run_hook (SCM hook, SCM args);
  111. extern void scm_c_run_hook (SCM hook, SCM args);
  112. extern SCM scm_hook_to_list (SCM hook);
  113. extern void scm_init_hooks (void);
  114.  
  115. #if (SCM_DEBUG_DEPRECATED == 0)
  116. extern SCM scm_create_hook (const char* name, int n_args);
  117. #endif
  118.  
  119. #endif  /* SCM_HOOKS_H */
  120.  
  121. /*
  122.   Local Variables:
  123.   c-file-style: "gnu"
  124.   End:
  125. */
  126.