Changeset 6922edd for perlconfig.c


Ignore:
Timestamp:
Oct 26, 2006, 11:14:41 AM (18 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
4c46dfd
Parents:
bc220b2
Message:
Adding the ability to install real commands from perl.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perlconfig.c

    r216c734 r6922edd  
    77#define OWL_PERL
    88#include "owl.h"
    9 #include <perl.h>
    10 #include "XSUB.h"
    119
    1210static const char fileIdent[] = "$Id$";
     
    1614extern XS(boot_owl);
    1715extern XS(boot_DynaLoader);
    18 extern XS(boot_DBI);
     16// extern XS(boot_DBI);
    1917
    2018static void owl_perl_xs_init(pTHX)
     
    337335  }
    338336}
     337
     338char *owl_perlconfig_perlcmd(owl_cmd *cmd, int argc, char **argv)
     339{
     340  int i, count;
     341  char * ret = NULL;
     342  STRLEN n_a;
     343  dSP;
     344
     345  ENTER;
     346  SAVETMPS;
     347
     348  PUSHMARK(SP);
     349  for(i=0;i<argc;i++) {
     350    XPUSHs(sv_2mortal(newSVpv(argv[i], 0)));
     351  }
     352  PUTBACK;
     353
     354  count = call_sv(cmd->cmd_perl, G_SCALAR|G_EVAL);
     355
     356  SPAGAIN;
     357
     358  if(SvTRUE(ERRSV)) {
     359    owl_function_error("Error: %s", SvPV(ERRSV, n_a));
     360    POPs;
     361  } else {
     362    if(count != 1)
     363      croak("Perl command %s returned more than one value!", cmd->name);
     364    SV * rv = POPs;
     365    if(SvTRUE(rv)) {
     366      ret = owl_strdup(SvPV(rv, n_a));
     367    }
     368  }
     369
     370  FREETMPS;
     371  LEAVE;
     372
     373  return ret;
     374}
     375
     376void owl_perlconfig_cmd_free(owl_cmd *cmd)
     377{
     378  SvREFCNT_dec(cmd);
     379}
Note: See TracChangeset for help on using the changeset viewer.