Changes in perlconfig.c [3ea31b6:5b37c063]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
perlconfig.c
r3ea31b6 r5b37c063 44 44 h = newHV(); 45 45 46 #define MSG2H(h,field) (void)hv_store(h, #field, strlen(#field),\47 46 #define MSG2H(h,field) hv_store(h, #field, strlen(#field), \ 47 newSVpv(owl_message_get_##field(m),0), 0) 48 48 49 49 if (owl_message_is_type_zephyr(m) … … 59 59 owl_free(ptr); 60 60 } 61 (void)hv_store(h, "fields", strlen("fields"), newRV_noinc((SV*)av_zfields), 0);62 63 (void)hv_store(h, "auth", strlen("auth"),64 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); 65 65 } 66 66 … … 68 68 for(i=0; i<j; i++) { 69 69 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 70 hv_store(h, owl_pair_get_key(pair), strlen(owl_pair_get_key(pair)), 71 newSVpv(owl_pair_get_value(pair),0),0); 72 72 } 73 73 … … 88 88 MSG2H(h, header); 89 89 } 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 96 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); 97 97 98 98 type = owl_message_get_type(m); … … 102 102 blessas = owl_sprintf("BarnOwl::Message::%s", type); 103 103 104 hr = newRV_noinc((SV*)h);104 hr = sv_2mortal(newRV_noinc((SV*)h)); 105 105 stash = gv_stashpv(blessas,0); 106 106 if(!stash) { … … 182 182 dSP ; 183 183 int count; 184 unsigned int len; 184 185 SV *msgref, *srv; 185 char *out ;186 char *out, *preout; 186 187 187 188 ENTER ; … … 190 191 PUSHMARK(SP) ; 191 192 msgref = owl_perlconfig_message2hashref(m); 192 XPUSHs( sv_2mortal(msgref));193 XPUSHs(msgref); 193 194 PUTBACK ; 194 195 … … 198 199 199 200 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)); 201 203 /* and clear the error */ 202 204 sv_setsv (ERRSV, &PL_sv_undef); … … 211 213 212 214 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'; 214 219 } else { 215 220 out = NULL; … … 230 235 { 231 236 dSP; 232 unsigned int count, i;237 unsigned int count, len, i; 233 238 SV *msgref, *srv; 234 char *out ;239 char *out, *preout; 235 240 236 241 msgref = owl_perlconfig_message2hashref(m); … … 240 245 241 246 PUSHMARK(SP); 242 XPUSHs( sv_2mortal(msgref));247 XPUSHs(msgref); 243 248 for(i=0;i<argc;i++) { 244 249 XPUSHs(sv_2mortal(newSVpv(argv[i], 0))); … … 256 261 257 262 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)); 259 265 /* and clear the error */ 260 266 sv_setsv (ERRSV, &PL_sv_undef); … … 264 270 265 271 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'; 267 276 } else { 268 277 out = NULL; … … 277 286 278 287 279 char *owl_perlconfig_initperl(char * file )288 char *owl_perlconfig_initperl(char * file, int *Pargc, char ***Pargv, char *** Penv) 280 289 { 281 290 int ret; … … 285 294 286 295 /* create and initialize interpreter */ 296 PERL_SYS_INIT3(Pargc, Pargv, Penv); 287 297 p=perl_alloc(); 288 298 owl_global_set_perlinterp(&g, (void*)p); … … 294 304 ret=perl_parse(p, owl_perl_xs_init, 2, args, NULL); 295 305 if (ret || SvTRUE(ERRSV)) { 296 err=owl_strdup(SvPV_nolen(ERRSV)); 306 STRLEN n_a; 307 err=owl_strdup(SvPV(ERRSV, n_a)); 297 308 sv_setsv(ERRSV, &PL_sv_undef); /* and clear the error */ 298 309 return(err); … … 301 312 ret=perl_run(p); 302 313 if (ret || SvTRUE(ERRSV)) { 303 err=owl_strdup(SvPV_nolen(ERRSV)); 314 STRLEN n_a; 315 err=owl_strdup(SvPV(ERRSV, n_a)); 304 316 sv_setsv(ERRSV, &PL_sv_undef); /* and clear the error */ 305 317 return(err); … … 330 342 331 343 if (SvTRUE(ERRSV)) { 332 err=owl_strdup(SvPV_nolen(ERRSV)); 344 STRLEN n_a; 345 err=owl_strdup(SvPV(ERRSV, n_a)); 333 346 sv_setsv (ERRSV, &PL_sv_undef); /* and clear the error */ 334 347 return(err); … … 383 396 384 397 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)); 386 400 sv_setsv (ERRSV, &PL_sv_undef); /* and clear the error */ 387 401 } 388 402 389 403 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 } 394 411 395 412 return(out); … … 422 439 char * ret = NULL; 423 440 SV *rv; 441 STRLEN n_a; 424 442 dSP; 425 443 … … 440 458 441 459 if(SvTRUE(ERRSV)) { 442 owl_function_error("%s", SvPV _nolen(ERRSV));460 owl_function_error("%s", SvPV(ERRSV, n_a)); 443 461 (void)POPs; 444 462 } else { … … 447 465 rv = POPs; 448 466 if(SvTRUE(rv)) { 449 ret = owl_strdup(SvPV _nolen(rv));467 ret = owl_strdup(SvPV(rv, n_a)); 450 468 } 451 469 } … … 471 489 SV *cb = (SV*)(e->cbdata); 472 490 SV *text; 491 unsigned int n_a; 473 492 dSP; 474 493 … … 489 508 490 509 if(SvTRUE(ERRSV)) { 491 owl_function_error("%s", SvPV _nolen(ERRSV));510 owl_function_error("%s", SvPV(ERRSV, n_a)); 492 511 } 493 512 … … 507 526 call_pv("BarnOwl::Hooks::_mainloop_hook", G_DISCARD|G_EVAL); 508 527 if(SvTRUE(ERRSV)) { 509 owl_function_error("%s", SvPV_nolen(ERRSV)); 528 STRLEN n_a; 529 owl_function_error("%s", SvPV(ERRSV, n_a)); 510 530 } 511 531 return; … … 515 535 { 516 536 SV *cb = d->pfunc; 537 unsigned int n_a; 517 538 dSP; 518 539 if(cb == NULL) { … … 529 550 530 551 if(SvTRUE(ERRSV)) { 531 owl_function_error("%s", SvPV _nolen(ERRSV));552 owl_function_error("%s", SvPV(ERRSV, n_a)); 532 553 } 533 554
Note: See TracChangeset
for help on using the changeset viewer.