Changeset 25729b2 for perlconfig.c


Ignore:
Timestamp:
Jan 8, 2007, 4:17:55 PM (14 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
723f464
Parents:
6beac73
git-author:
Nelson Elhage <nelhage@mit.edu> (01/08/07 15:55:09)
git-committer:
Nelson Elhage <nelhage@mit.edu> (01/08/07 16:17:55)
Message:
Adding basic smartnarrow support for jabber, and infrastructure to
make it extensible.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perlconfig.c

    ra55abb3 r25729b2  
    161161  return out;
    162162}
     163
     164
     165/* Calls a method on a perl object representing a message.
     166   If the return value is non-null, the caller must free it.
     167 */
     168char * owl_perlconfig_message_call_method(owl_message *m, char *method, int argc, char ** argv)
     169{
     170  dSP;
     171  unsigned int count, len, i;
     172  SV *msgref, *srv;
     173  char *out, *preout;
     174
     175  msgref = owl_perlconfig_message2hashref(m);
     176
     177  ENTER;
     178  SAVETMPS;
     179
     180  PUSHMARK(SP);
     181  XPUSHs(msgref);
     182  for(i=0;i<argc;i++) {
     183    XPUSHs(sv_2mortal(newSVpv(argv[i], 0)));
     184  }
     185  PUTBACK;
     186
     187  count = call_method(method, G_SCALAR|G_KEEPERR|G_EVAL);
     188
     189  SPAGAIN;
     190
     191  if(count != 1) {
     192    fprintf(stderr, "perl returned wrong count %d\n", count);
     193    abort();
     194  }
     195
     196  if (SvTRUE(ERRSV)) {
     197    STRLEN n_a;
     198    owl_function_error("Error: '%s'", SvPV(ERRSV, n_a));
     199    /* and clear the error */
     200    sv_setsv (ERRSV, &PL_sv_undef);
     201  }
     202
     203  srv = POPs;
     204
     205  if (srv) {
     206    preout=SvPV(srv, len);
     207    out = owl_malloc(strlen(preout)+1);
     208    strncpy(out, preout, len);
     209    out[len] = '\0';
     210  } else {
     211    out = NULL;
     212  }
     213
     214  PUTBACK;
     215  FREETMPS;
     216  LEAVE;
     217
     218  return out;
     219}
     220
    163221
    164222char *owl_perlconfig_readconfig(void)
Note: See TracChangeset for help on using the changeset viewer.