Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perlconfig.c

    r3ea31b6 r5b37c063  
    4444  h = newHV();
    4545
    46 #define MSG2H(h,field) (void)hv_store(h, #field, strlen(#field),        \
    47                                       newSVpv(owl_message_get_##field(m),0), 0)
     46#define MSG2H(h,field) hv_store(h, #field, strlen(#field), \
     47                              newSVpv(owl_message_get_##field(m),0), 0)
    4848
    4949  if (owl_message_is_type_zephyr(m)
     
    5959      owl_free(ptr);
    6060    }
    61     (void)hv_store(h, "fields", strlen("fields"), newRV_noinc((SV*)av_zfields), 0);
    62 
    63     (void)hv_store(h, "auth", strlen("auth"),
    64                    newSVpv(owl_zephyr_get_authstr(owl_message_get_notice(m)),0),0);
     61    hv_store(h, "fields", strlen("fields"), newRV_noinc((SV*)av_zfields), 0);
     62
     63    hv_store(h, "auth", strlen("auth"),
     64             newSVpv(owl_zephyr_get_authstr(owl_message_get_notice(m)),0),0);
    6565  }
    6666
     
    6868  for(i=0; i<j; i++) {
    6969    pair=owl_list_get_element(&(m->attributes), i);
    70     (void)hv_store(h, owl_pair_get_key(pair), strlen(owl_pair_get_key(pair)),
    71                    newSVpv(owl_pair_get_value(pair),0),0);
     70    hv_store(h, owl_pair_get_key(pair), strlen(owl_pair_get_key(pair)),
     71             newSVpv(owl_pair_get_value(pair),0),0);
    7272  }
    7373 
     
    8888    MSG2H(h, header);
    8989  }
    90   (void)hv_store(h, "time", strlen("time"), newSVpv(owl_message_get_timestr(m),0),0);
    91   (void)hv_store(h, "id", strlen("id"), newSViv(owl_message_get_id(m)),0);
    92   (void)hv_store(h, "deleted", strlen("deleted"), newSViv(owl_message_is_delete(m)),0);
    93   (void)hv_store(h, "private", strlen("private"), newSViv(owl_message_is_private(m)),0);
    94   (void)hv_store(h, "should_wordwrap",
    95                  strlen("should_wordwrap"), newSViv(
    96                                                     owl_filter_message_match(wrap, m)),0);
     90  hv_store(h, "time", strlen("time"), newSVpv(owl_message_get_timestr(m),0),0);
     91  hv_store(h, "id", strlen("id"), newSViv(owl_message_get_id(m)),0);
     92  hv_store(h, "deleted", strlen("deleted"), newSViv(owl_message_is_delete(m)),0);
     93  hv_store(h, "private", strlen("private"), newSViv(owl_message_is_private(m)),0);
     94  hv_store(h, "should_wordwrap",
     95           strlen("should_wordwrap"), newSViv(
     96                                              owl_filter_message_match(wrap, m)),0);
    9797
    9898  type = owl_message_get_type(m);
     
    102102  blessas = owl_sprintf("BarnOwl::Message::%s", type);
    103103
    104   hr = newRV_noinc((SV*)h);
     104  hr = sv_2mortal(newRV_noinc((SV*)h));
    105105  stash =  gv_stashpv(blessas,0);
    106106  if(!stash) {
     
    182182  dSP ;
    183183  int count;
     184  unsigned int len;
    184185  SV *msgref, *srv;
    185   char *out;
     186  char *out, *preout;
    186187 
    187188  ENTER ;
     
    190191  PUSHMARK(SP) ;
    191192  msgref = owl_perlconfig_message2hashref(m);
    192   XPUSHs(sv_2mortal(msgref));
     193  XPUSHs(msgref);
    193194  PUTBACK ;
    194195 
     
    198199
    199200  if (SvTRUE(ERRSV)) {
    200     owl_function_error("Perl Error: '%s'", SvPV_nolen(ERRSV));
     201    STRLEN n_a;
     202    owl_function_error("Perl Error: '%s'", SvPV(ERRSV, n_a));
    201203    /* and clear the error */
    202204    sv_setsv (ERRSV, &PL_sv_undef);
     
    211213
    212214  if (srv) {
    213     out = owl_strdup(SvPV_nolen(srv));
     215    preout=SvPV(srv, len);
     216    out = owl_malloc(strlen(preout)+1);
     217    strncpy(out, preout, len);
     218    out[len] = '\0';
    214219  } else {
    215220    out = NULL;
     
    230235{
    231236  dSP;
    232   unsigned int count, i;
     237  unsigned int count, len, i;
    233238  SV *msgref, *srv;
    234   char *out;
     239  char *out, *preout;
    235240
    236241  msgref = owl_perlconfig_message2hashref(m);
     
    240245
    241246  PUSHMARK(SP);
    242   XPUSHs(sv_2mortal(msgref));
     247  XPUSHs(msgref);
    243248  for(i=0;i<argc;i++) {
    244249    XPUSHs(sv_2mortal(newSVpv(argv[i], 0)));
     
    256261
    257262  if (SvTRUE(ERRSV)) {
    258     owl_function_error("Error: '%s'", SvPV_nolen(ERRSV));
     263    STRLEN n_a;
     264    owl_function_error("Error: '%s'", SvPV(ERRSV, n_a));
    259265    /* and clear the error */
    260266    sv_setsv (ERRSV, &PL_sv_undef);
     
    264270
    265271  if (srv) {
    266     out = owl_strdup(SvPV_nolen(srv));
     272    preout=SvPV(srv, len);
     273    out = owl_malloc(strlen(preout)+1);
     274    strncpy(out, preout, len);
     275    out[len] = '\0';
    267276  } else {
    268277    out = NULL;
     
    277286
    278287
    279 char *owl_perlconfig_initperl(char * file)
     288char *owl_perlconfig_initperl(char * file, int *Pargc, char ***Pargv, char *** Penv)
    280289{
    281290  int ret;
     
    285294
    286295  /* create and initialize interpreter */
     296  PERL_SYS_INIT3(Pargc, Pargv, Penv);
    287297  p=perl_alloc();
    288298  owl_global_set_perlinterp(&g, (void*)p);
     
    294304  ret=perl_parse(p, owl_perl_xs_init, 2, args, NULL);
    295305  if (ret || SvTRUE(ERRSV)) {
    296     err=owl_strdup(SvPV_nolen(ERRSV));
     306    STRLEN n_a;
     307    err=owl_strdup(SvPV(ERRSV, n_a));
    297308    sv_setsv(ERRSV, &PL_sv_undef);     /* and clear the error */
    298309    return(err);
     
    301312  ret=perl_run(p);
    302313  if (ret || SvTRUE(ERRSV)) {
    303     err=owl_strdup(SvPV_nolen(ERRSV));
     314    STRLEN n_a;
     315    err=owl_strdup(SvPV(ERRSV, n_a));
    304316    sv_setsv(ERRSV, &PL_sv_undef);     /* and clear the error */
    305317    return(err);
     
    330342
    331343  if (SvTRUE(ERRSV)) {
    332     err=owl_strdup(SvPV_nolen(ERRSV));
     344    STRLEN n_a;
     345    err=owl_strdup(SvPV(ERRSV, n_a));
    333346    sv_setsv (ERRSV, &PL_sv_undef);     /* and clear the error */
    334347    return(err);
     
    383396
    384397  if (SvTRUE(ERRSV)) {
    385     owl_function_error("Perl Error: '%s'", SvPV_nolen(ERRSV));
     398    STRLEN n_a;
     399    owl_function_error("Perl Error: '%s'", SvPV(ERRSV, n_a));
    386400    sv_setsv (ERRSV, &PL_sv_undef);     /* and clear the error */
    387401  }
    388402
    389403  preout=SvPV(response, len);
    390   if (len == 0 || preout[len - 1] != '\n')
    391     out = owl_sprintf("%s\n", preout);
    392   else
    393     out = owl_strdup(preout);
     404  /* leave enough space in case we have to add a newline */
     405  out = owl_malloc(strlen(preout)+2);
     406  strncpy(out, preout, len);
     407  out[len] = '\0';
     408  if (!strlen(out) || out[strlen(out)-1]!='\n') {
     409    strcat(out, "\n");
     410  }
    394411
    395412  return(out);
     
    422439  char * ret = NULL;
    423440  SV *rv;
     441  STRLEN n_a;
    424442  dSP;
    425443
     
    440458
    441459  if(SvTRUE(ERRSV)) {
    442     owl_function_error("%s", SvPV_nolen(ERRSV));
     460    owl_function_error("%s", SvPV(ERRSV, n_a));
    443461    (void)POPs;
    444462  } else {
     
    447465    rv = POPs;
    448466    if(SvTRUE(rv)) {
    449       ret = owl_strdup(SvPV_nolen(rv));
     467      ret = owl_strdup(SvPV(rv, n_a));
    450468    }
    451469  }
     
    471489  SV *cb = (SV*)(e->cbdata);
    472490  SV *text;
     491  unsigned int n_a;
    473492  dSP;
    474493
     
    489508
    490509  if(SvTRUE(ERRSV)) {
    491     owl_function_error("%s", SvPV_nolen(ERRSV));
     510    owl_function_error("%s", SvPV(ERRSV, n_a));
    492511  }
    493512
     
    507526  call_pv("BarnOwl::Hooks::_mainloop_hook", G_DISCARD|G_EVAL);
    508527  if(SvTRUE(ERRSV)) {
    509     owl_function_error("%s", SvPV_nolen(ERRSV));
     528    STRLEN n_a;
     529    owl_function_error("%s", SvPV(ERRSV, n_a));
    510530  }
    511531  return;
     
    515535{
    516536  SV *cb = d->pfunc;
     537  unsigned int n_a;
    517538  dSP;
    518539  if(cb == NULL) {
     
    529550
    530551  if(SvTRUE(ERRSV)) {
    531     owl_function_error("%s", SvPV_nolen(ERRSV));
     552    owl_function_error("%s", SvPV(ERRSV, n_a));
    532553  }
    533554
Note: See TracChangeset for help on using the changeset viewer.