Changeset 61abb18


Ignore:
Timestamp:
Aug 10, 2008, 10:53:16 AM (11 years ago)
Author:
Geoffrey Thomas <geofft@mit.edu>
Branches:
barnowl_perlaim
Parents:
3dcccba
Message:
Now it compiles. Highly likely to leak or crash, although it seems to work for me...
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    r3dcccba r61abb18  
    24712471{
    24722472  char *text = owl_strdup(owl_editwin_get_text(e));
    2473   void (*callback)(void *, char *) = owl_editwin_get_callback(e);
     2473  owl_callback_t callback = owl_editwin_get_callback(e);
    24742474  void *cbdata = owl_editwin_get_cbdata(e);
    24752475
  • editwin.c

    r3dcccba r61abb18  
    8484}
    8585
    86 void owl_editwin_set_command(owl_editwin *e, char *command) {
    87   if(e->command) owl_free(e->command);
    88   e->command = owl_strdup(command);
    89 }
    90 
    91 char *owl_editwin_get_command(owl_editwin *e) {
    92   if(e->command) return e->command;
    93   return "";
    94 }
    95 
    96 void owl_editwin_set_callback(owl_editwin *e, void (*cb)(void*, char*)) {
     86void owl_editwin_set_callback(owl_editwin *e, owl_callback_t cb, void *cbdata) {
    9787  e->callback = cb;
    98 }
    99 
    100 void (*owl_editwin_get_callback(owl_editwin*))(void *cbdata, char *text) {
     88  e->cbdata = cbdata;
     89}
     90
     91owl_callback_t owl_editwin_get_callback(owl_editwin *e) {
    10192  return e->callback;
    102 }
    103 
    104 void owl_editwin_set_cbdata(owl_editwin *e, void *data) {
    105   e->cbdata = data;
    10693}
    10794
     
    11299void owl_editwin_do_callback(owl_editwin *e) {
    113100  /* XXX get rid of me */
    114   void (*cb)(void*, char*);
    115   cb=owl_editwin_get_callback(e);
     101  owl_callback_t cb = owl_editwin_get_callback(e);
    116102  if(!cb) {
    117103    owl_function_error("Internal error: No editwin callback!");
    118104  } else {
    119105    /* owl_function_error("text: |%s|", owl_editwin_get_text(e)); */
    120     cb(e->cbdata, e->text);
     106    cb(e->cbdata, owl_editwin_get_text(e));
    121107  }
    122108}
  • functions.c

    r3dcccba r61abb18  
    268268  owl_global_set_typwin_active(&g);
    269269
    270   owl_global_set_buffercommand(&g, line);
    271   owl_global_set_buffercallback(&g, &owl_callback_zwrite);
     270  owl_global_set_buffercallback(&g, &owl_callback_zwrite, line);
    272271}
    273272
     
    293292  owl_global_set_typwin_active(&g);
    294293
    295   owl_global_set_buffercommand(&g, "loopwrite");
    296   owl_global_set_buffercallback(&g, &owl_callback_loopwrite);
    297 }
    298 
    299 void owl_callback_zwrite(owl_editwin *e) {
    300   owl_function_zwrite(owl_editwin_get_command(e),
    301                       owl_editwin_get_text(e));
     294  owl_global_set_buffercallback(&g, &owl_callback_loopwrite, "loopwrite");
     295}
     296
     297void owl_callback_zwrite(void *cbdata, char *text) {
     298  owl_function_zwrite((char *)cbdata, text);
    302299}
    303300
     
    398395}
    399396
    400 void owl_callback_loopwrite(owl_editwin *e) {
    401   owl_function_loopwrite(owl_editwin_get_text(e));
     397void owl_callback_loopwrite(void *cbdata, char *text) {
     398  owl_function_loopwrite(text);
    402399}
    403400
  • global.c

    rc453ada r61abb18  
    237237}
    238238
    239 /* buffercommand */
    240 
    241 void owl_global_set_buffercommand(owl_global *g, char *command) {
    242   owl_editwin_set_command(owl_global_get_typwin(g), command);
    243 }
    244 
    245 char *owl_global_get_buffercommand(owl_global *g) {
    246   return owl_editwin_get_command(owl_global_get_typwin(g));
    247 }
    248 
    249 void owl_global_set_buffercallback(owl_global *g, void (*cb)(owl_editwin*)) {
    250   owl_editwin_set_callback(owl_global_get_typwin(g), cb);
    251 }
    252 
    253 void (*owl_global_get_buffercallback(owl_global *g))(owl_editwin*) {
    254   return owl_editwin_get_callback(owl_global_get_typwin(g));
     239/* buffercallback */
     240
     241void owl_global_set_buffercallback(owl_global *g, owl_callback_t cb, char *line) {
     242  owl_editwin_set_callback(owl_global_get_typwin(g), cb, line);
    255243}
    256244
  • owl.h

    r3dcccba r61abb18  
    203203
    204204#define LINE 2048
     205
     206typedef void (*owl_callback_t)(void *cbdata, char *text);
    205207
    206208typedef struct _owl_variable {
     
    452454  int echochar;
    453455
    454   char *command;
    455   void (*callback)(void *, char *);
     456  owl_callback_t callback;
    456457  void *cbdata;
    457458} owl_editwin;
  • perlconfig.c

    r3dcccba r61abb18  
    472472}
    473473
    474 void owl_perlconfig_edit_callback(void *cbdata, char *c_text);
     474void owl_perlconfig_edit_callback(void *cbdata, char *c_text)
    475475{
    476476  SV *cb = (SV*)cbdata;
     
    479479  dSP;
    480480
    481   e->cbdata = NULL;
    482481  if(cb == NULL) {
    483482    owl_function_error("Perl callback is NULL!");
  • perlglue.xs

    rb67ab6b r61abb18  
    166166
    167167                SvREFCNT_inc(callback);
    168                 owl_editwin_set_cbdata(owl_global_get_typwin(&g), callback);
    169                 owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback);
     168                owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback, callback);
    170169        }
    171170
     
    182181
    183182                SvREFCNT_inc(callback);
    184                 owl_editwin_set_cbdata(owl_global_get_typwin(&g), callback);
    185                 owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback);
     183                owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback, callback);
    186184        }
    187185
     
    208206
    209207                SvREFCNT_inc(callback);
    210                 owl_editwin_set_cbdata(owl_global_get_typwin(&g), callback);
    211                 owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback);
     208                owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback, callback);
    212209        }
    213210
Note: See TracChangeset for help on using the changeset viewer.