• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ perl_alloc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中perl_alloc函数的典型用法代码示例。如果您正苦于以下问题:C++ perl_alloc函数的具体用法?C++ perl_alloc怎么用?C++ perl_alloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了perl_alloc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: PERL_SYS_INIT

PerlInterpreter *p5_init_perl() {
    char *embedding[] = { "", "-e", "0" };
    int argc = 0;
    char **argv;
    if (!inited++)
        PERL_SYS_INIT(&argc, &argv);
    PerlInterpreter *my_perl = perl_alloc();
    PERL_SET_CONTEXT(my_perl);
    PL_perl_destruct_level = 1;
    perl_construct( my_perl );
    perl_parse(my_perl, xs_init, 3, embedding, NULL);
    PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
    perl_run(my_perl);
    return my_perl;
}
开发者ID:masak,项目名称:Inline-Perl5,代码行数:15,代码来源:p5helper.c


示例2:

void *my_Perl_get_context(void) {
    PerlInterpreter *my_perl=Perl_get_context();
    if (!my_perl) {
	my_perl=perl_alloc();
	PERL_SET_CONTEXT(my_perl);
	perl_construct(my_perl);
	perl_parse(my_perl, xs_init, 3, pargs, NULL);
	PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
	perl_run(my_perl);
	PL_thread_at_exit(clear_perl, NULL, 0);
	/* warn ("new perl interpreter created %x (thread=%i)",
	      my_perl,
	      PL_thread_self()); */
    }
    return my_perl;
}
开发者ID:dtikhonov,项目名称:p5-Language-Prolog-Yaswi,代码行数:16,代码来源:engines.c


示例3: script_init

void
script_init (int argc, char **argv)
{
#ifdef USE_PERL
    char *filename;

    perl_env = perl_alloc ();
    perl_construct (perl_env);
    filename = gethome_conf_file ("script.pl");
    script_load (filename, SCRIPT_PERL);
#endif

#ifdef USE_GUILE
    gh_enter (argc, argv, fake_main);
#endif
}
开发者ID:erikg,项目名称:bmud,代码行数:16,代码来源:script.c


示例4: perl_main

int
perl_main(int argc, char **argv, char **env)
{
	int	r;

	iperl = perl_alloc();
	perl_construct(iperl);
	perl_parse(iperl, xs_init, argc, argv, (char **)NULL);
	r = perl_run(iperl);

PerlIO_flush(PerlIO_stdout());
PerlIO_flush(PerlIO_stderr());

	perl_destruct(iperl);
	perl_free(iperl);
	return (r);
}
开发者ID:AaronDP,项目名称:bash4adbshell,代码行数:17,代码来源:iperl.c


示例5: plperl_init_interp

static void
plperl_init_interp(void)
{
	static char *embedding[3] = {
		"", "-e", PERLBOOT
	};

	plperl_interp = perl_alloc();
	if (!plperl_interp)
		elog(ERROR, "could not allocate Perl interpreter");

	perl_construct(plperl_interp);
	perl_parse(plperl_interp, plperl_init_shared_libs, 3, embedding, NULL);
	perl_run(plperl_interp);

	plperl_proc_hash = newHV();
}
开发者ID:shubham2094,项目名称:postgresql_8.1,代码行数:17,代码来源:plperl.c


示例6: start_perl_interpreter

static PerlInterpreter *
start_perl_interpreter (char *err, int max_len)
{
  PerlInterpreter *intrp;
  char *embedding[3];
#ifdef MY_ENV
  char *envp[] = {
    NULL
  };
#else
  char **envp = NULL;
#endif

  embedding[0] = "CGI";
  embedding[1] = "-e";
  embedding[2] = virt_handler;
  log_debug ("start_perl_interpreter");
  if (NULL == (intrp = perl_alloc()))
    {
      SET_ERR ("Unable to allocate perl interpreter");
      return NULL;
    }
    {
      dTHX;
      perl_construct(intrp);
      PERL_SET_CONTEXT(intrp);

      if (0 == perl_parse(intrp, xs_init, 3, embedding, envp))
	{
	  PERL_SET_CONTEXT(intrp);
	  if (0 == perl_run(intrp))
	    return intrp;
	  else
	    SET_ERR ("Unable to run the perl interpreter");
	}
      else
	SET_ERR ("Unable to parse virt_handler.pl");
#ifdef PERL_EXIT_DESTRUCT_END
      PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
#endif
      perl_destruct (intrp);
      perl_free (intrp);
    }
  return NULL;
}
开发者ID:China-ls,项目名称:virtuoso-opensource,代码行数:45,代码来源:hosting_perl.c


示例7: perl_alloc

/*
 * Initialize the perl interpreter.
 * This might later be used to reinit the module.
 */
PerlInterpreter *parser_init(void) {
	int argc = 0;
	char *argv[9];
	PerlInterpreter *new_perl = NULL;
	int modpathset = 0;

	new_perl = perl_alloc();

	if (!new_perl) {
		LM_ERR("could not allocate perl.\n");
		return NULL;
	}

	perl_construct(new_perl);

	argv[0] = ""; argc++; /* First param _needs_ to be empty */

	 /* Possible Include path extension by modparam */
	if (modpath && (strlen(modpath) > 0)) {
		modpathset = argc;
		LM_INFO("setting lib path: '%s'\n", modpath);
		argv[argc] = pkg_malloc(strlen(modpath)+20);
		sprintf(argv[argc], "-I%s", modpath);
		argc++;
	}

	argv[argc] = "-M"DEFAULTMODULE; argc++; /* Always "use" Opensips.pm */

	argv[argc] = filename; /* The script itself */
	argc++;

	if (perl_parse(new_perl, xs_init, argc, argv, NULL)) {
		LM_ERR("failed to load perl file \"%s\".\n", argv[argc-1]);
		if (modpathset) pkg_free(argv[modpathset]);
		return NULL;
	} else {
		LM_INFO("successfully loaded perl file \"%s\"\n", argv[argc-1]);
	}

	if (modpathset) pkg_free(argv[modpathset]);
	perl_run(new_perl);

	return new_perl;

}
开发者ID:GeorgeShaw,项目名称:opensips,代码行数:49,代码来源:perl.c


示例8: perl_alloc

PerlInterpreter *uwsgi_perl_new_interpreter(void) {

	PerlInterpreter *pi = perl_alloc();
        if (!pi) {
                uwsgi_log("unable to allocate perl interpreter\n");
                return NULL;
        }

	PERL_SET_CONTEXT(pi);

        PL_perl_destruct_level = 2;
        PL_origalen = 1;
        perl_construct(pi);
	// over-engeneering
        PL_origalen = 1;

	return pi;
}
开发者ID:dbhattar,项目名称:uwsgi,代码行数:18,代码来源:psgi_loader.c


示例9: PurlInit

static void
PurlInit()
{
  PL_origalen = 1;

  dummy_argv = malloc(sizeof(char*) * 3);
  dummy_argv[0] = "purl";
  dummy_argv[1] = "-e";
  dummy_argv[2] = "0";

  PERL_SYS_INIT3(&dummy_argc,&dummy_argv,&dummy_env);

  my_perl = perl_alloc();
  perl_construct(my_perl);
  PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
  perl_parse(my_perl, xs_init, dummy_argc, dummy_argv, (char **)NULL);
  //perl_run(my_perl);
}
开发者ID:ian-kent,项目名称:purl,代码行数:18,代码来源:purl.c


示例10: main

main (int argc, char **argv, char **env)
{
  char *embedding[] = { "", "-e", "0" };
  char *text, **match_list;
  int num_matches, i;
  int j;
  my_perl = perl_alloc();
  perl_construct( my_perl );
  perl_parse(my_perl, NULL, 3, embedding, NULL);
  text = (char *) malloc(sizeof(char) * 486); /** A long string follows! **/
  sprintf(text, "%s", "When he is at a convenience store and the bill comes to some amount like 76 cents, Maynard is aware that there is something he *should* do, something that will enable him to get back a quarter, but he has no idea *what*.  He fumbles through his red squeezey changepurse and gives the boy three extra pennies with his dollar, hoping that he might luck into the correct amount.  The boy gives him back two of his own pennies and then the big shiny quarter that is his prize. -RICHH");
  if (match(text, "m/quarter/")) /** Does text contain 'quarter'? **/
    printf("match: Text contains the word 'quarter'.\n\n");
  else
    printf("match: Text doesn't contain the word 'quarter'.\n\n");
  if (match(text, "m/eighth/")) /** Does text contain 'eighth'? **/
    printf("match: Text contains the word 'eighth'.\n\n");
  else
    printf("match: Text doesn't contain the word 'eighth'.\n\n");
  /** Match all occurrences of /wi../ **/
  num_matches = matches(text, "m/(wi..)/g", &match_list);
  printf("matches: m/(wi..)/g found %d matches...\n", num_matches);
  for (i = 0; i < num_matches; i++)
    printf("match: %s\n", match_list[i]);
  printf("\n");
  for (i = 0; i < num_matches; i++) {
    free(match_list[i]);
  }
  free(match_list);
  /** Remove all vowels from text **/
  num_matches = substitute(&text, "s/[aeiou]//gi");
  if (num_matches) {
    printf("substitute: s/[aeiou]//gi...%d substitutions made.\n",
	   num_matches);
    printf("Now text is: %s\n\n", text);
  }
  /** Attempt a substitution **/
  if (!substitute(&text, "s/Perl/C/")) {
    printf("substitute: s/Perl/C...No substitution made.\n\n");
  }
  free(text);
  perl_destruct(my_perl);
  perl_free(my_perl);
}
开发者ID:gitpan,项目名称:ExtUtils-Embed,代码行数:44,代码来源:orig-match.c


示例11: perl_alloc

bool KviPerlInterpreter::init()
{
	if(m_pInterpreter)done();
	const char * daArgs[] = { "yo", "-e", "0", "-w" };
	m_pInterpreter = perl_alloc();
	if(!m_pInterpreter)return false;
	PERL_SET_CONTEXT(m_pInterpreter);
	PL_perl_destruct_level = 1;
	perl_construct(m_pInterpreter);
	perl_parse(m_pInterpreter,xs_init,4,(char **)daArgs,NULL);
	QString szInitCode;

	// this part of the code seems to be unnecessary
	// even if it is created by the perl make process...
	//	"our %EXPORT_TAGS = ('all' => [qw(echo)]);\n"
	//	"our @EXPORT_OK = (qw(echo));\n"
	//	"our @EXPORT = qw();\n"
	// This is probably needed only if perl has to load
	// the XS through XSLoader ?
	// Maybe also the remaining part of the package
	// declaration could be dropped as well...
	// I just haven't tried :D

	szInitCode = QString(
		"{\n" \
			"package KVIrc;\n" \
			"require Exporter;\n" \
			"our @ISA = qw(Exporter);\n" \
			"1;\n" \
		"}\n" \
		"$g_szContext = \"%1\";\n" \
		"$g_bExecuteQuiet = 0;\n" \
		"$SIG{__WARN__} = sub\n" \
		"{\n" \
		"	my($p,$f,$l,$x);\n" \
		"	($p,$f,$l) = caller;\n" \
		"	KVIrc::internalWarning(\"At line \".$l.\" of perl code: \");\n" \
		"	KVIrc::internalWarning(join(' ',@_));\n" \
		"}\n").arg(m_szContextName);

	eval_pv(szInitCode.toUtf8().data(),false);
	return true;
}
开发者ID:philouvb,项目名称:KVIrc,代码行数:43,代码来源:libkviperlcore.cpp


示例12: proxenet_perl_initialize_vm

int proxenet_perl_initialize_vm(plugin_t* plugin)
{
	interpreter_t *interpreter;
        char *perl_args[] = { "", "/dev/null", NULL };
        int   perl_args_count = 2;

#ifdef PERL_SYS_INIT3
        int a;
        char **perl_args_local;
        char *perl_env[] = {};
        a = perl_args_count;
        perl_args_local = perl_args;
        (void) perl_env;
        PERL_SYS_INIT3 (&a, (char ***)&perl_args_local, (char ***)&perl_env);
#endif

	interpreter = plugin->interpreter;

	/* checks */
	if (interpreter->ready)
                return 0;

#ifdef DEBUG
        xlog_perl(LOG_DEBUG, "%s\n", "Initializing VM");
#endif

        /* vm init */
        my_perl = perl_alloc();
        perl_construct(my_perl);
        PL_exit_flags |= PERL_EXIT_DESTRUCT_END;

        if (!my_perl) {
                xlog_perl(LOG_ERROR, "%s\n", "failed init-ing vm");
                return -1;
        }

        perl_parse(my_perl, NULL, perl_args_count, perl_args, (char **)NULL);

        interpreter->vm = (void*) my_perl;
        interpreter->ready = true;

	return 0;
}
开发者ID:drptbl,项目名称:proxenet,代码行数:43,代码来源:plugin-perl.c


示例13: maybe_source_perl_startup

void
maybe_source_perl_startup(void)
{
    const char     *embedargs[] = { "", "" };
    const char     *perl_init_file = netsnmp_ds_get_string(NETSNMP_DS_APPLICATION_ID,
							   NETSNMP_DS_AGENT_PERL_INIT_FILE);
    char            init_file[SNMP_MAXBUF];

    static int      have_done_init = 0;

    if (have_done_init)
        return;
    have_done_init = 1;

    if (!perl_init_file) {
        snprintf(init_file, sizeof(init_file) - 1,
                 "%s/%s", SNMPSHAREPATH, "snmp_perl.pl");
        perl_init_file = init_file;
    }
    embedargs[1] = perl_init_file;

    DEBUGMSGTL(("perl", "initializing perl (%s)\n", embedargs[1]));
    my_perl = perl_alloc();
    if (!my_perl)
        goto bail_out;

    perl_construct(my_perl);
    if (perl_parse(my_perl, xs_init, 2, (char **) embedargs, NULL))
        goto bail_out;

    if (perl_run(my_perl))
        goto bail_out;

    DEBUGMSGTL(("perl", "done initializing perl\n"));

    return;

  bail_out:
    snmp_log(LOG_ERR, "embedded perl support failed to initalize\n");
    netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, 
			   NETSNMP_DS_AGENT_DISABLE_PERL, 1);
    return;
}
开发者ID:KrisChaplin,项目名称:LRT2x4_v1.0.2.06_GPL_source,代码行数:43,代码来源:snmp_perl.c


示例14: perl_init

int perl_init(){
	int myargc=0;
	char **myenv = NULL;
	char **myargv = NULL;
	char *embedding[]={"","-e","0"};

	PERL_SYS_INIT3(&myargc, &myargv, &myenv);

	my_perl=perl_alloc();
        sv=NEWSV(1099,0);
        perl_construct(my_perl);

	PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
    
	perl_parse(my_perl, NULL, 3, embedding, NULL);
        perl_run(my_perl);
	
	return 1;
}	
开发者ID:mmostafa30512,项目名称:iView,代码行数:19,代码来源:fwstub.c


示例15: new_perl

PerlInterpreter *
new_perl(void)
{
    PerlInterpreter *p;
    char *embedding[] = { "", "-mPython::Object", "-e", "$| = 1;", NULL };

    p = perl_alloc();
#if 0
    fprintf(stderr, "creating new perl %p\n", p); fflush(stderr);
#endif
    perl_construct(p);
#ifdef BOOT_FROM_PERL
    perl_parse(p, 0, 4, embedding, NULL);
#else
    perl_parse(p, xs_init, 4, embedding, NULL);
#endif
    perl_run(p);

    return p;
}
开发者ID:nikicat,项目名称:python-perlmodule,代码行数:20,代码来源:perlmodule.c


示例16: module_init

void module_init(VCSI_CONTEXT vc) {
  /* create the perl environment */
  char *embedding[] = {"","-e","0"};


  perl_embed = perl_alloc();
  perl_construct(perl_embed);
  perl_parse(perl_embed,NULL,3,embedding,NULL);

  /* register the proc */
  set_int_proc(vc,"perl-eval",PROC1,perl_eval);  
  set_int_proc(vc,"perl-func",PROCOPT,perl_func);
  set_int_proc(vc,"perl-sc-var",PROC1,perl_sc_var);

  /* if ever we destroyed */
  /*
    perl_destruct(perl_embed);
    perl_free(perl_embed);
  */
}
开发者ID:mdbarr,项目名称:vcsi,代码行数:20,代码来源:perl.c


示例17: init_perl

void
init_perl(struct module *module)
{
	/* FIXME: it seems that some systems like OS/2 requires PERL_SYS_INIT3
	 * and PERL_SYS_TERM to open/close the same block, at least regarding
	 * some ml messages.
	 *
	 * Is passing @environ strictly needed ? --Zas */

	/* PERL_SYS_INIT3 may not be defined, it depends on the system. */
#ifdef PERL_SYS_INIT3
	char *my_argvec[] = { NULL, NULL };
	char **my_argv = my_argvec;
	int my_argc = 0;

	/* A hack to prevent unused variables warnings. */
	my_argv[my_argc++] = "";

	PERL_SYS_INIT3(&my_argc, &my_argv, &environ);
#endif

	my_perl = perl_alloc();
	if (my_perl) {
		char *hook_global = get_global_hook_file();
		char *hook_local = get_local_hook_file();
		char *global_argv[] = { "", hook_global};
		char *local_argv[] = { "", hook_local};
		int err = 1;

		perl_construct(my_perl);
		if (hook_local)
			err = perl_parse(my_perl, NULL, 2, local_argv, NULL);
		else if (hook_global)
			err = perl_parse(my_perl, NULL, 2, global_argv, NULL);
#ifdef PERL_EXIT_DESTRUCT_END
		PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
#endif
		if (!err) err = perl_run(my_perl);
		if (err) precleanup_perl(module);
	}
}
开发者ID:ohmori7,项目名称:kcn-tools,代码行数:41,代码来源:core.c


示例18: perl_embed_init

void perl_embed_init(char **incl_path, int cache_perl_files) {
	static int is_initialized = 0;
	if (is_initialized) {
		fprintf(stderr, "perl_embed_init has already been initialized, ignoring call.\n");
		return;
	}
	is_initialized = 1;

	int incl_n = _chararray_size(incl_path);
	perl_opt_cache = cache_perl_files;
	char sdlib_arg[512];
	snprintf(sdlib_arg, sizeof sdlib_arg, "-Mblib=%s", bfile(SD_CRAWL_LIB_PATH));

        //char *perl_argv[] = { "", blib,  "-I", bfile("crawlers/Modules/"), bfile2("perl/persistent.pl"), NULL };
	char *perl_argv[incl_n ? incl_n + 4 : 3];
	int perl_argc = 0;

	perl_argv[perl_argc++] = "";
	if (incl_n) {
		perl_argv[perl_argc++] = "-I";
		int i;
		for (i = 0; i < incl_n; i++)
			perl_argv[perl_argc++] = incl_path[i];
	}
	perl_argv[perl_argc++] = sdlib_arg;
	perl_argv[perl_argc++] = bfile(PERSISTENT_PATH);
	perl_argv[perl_argc] = NULL;

	
	extern char **environ;
        PERL_SYS_INIT3(&argc, &argv, &environ);
        my_perl = perl_alloc();
        perl_construct(my_perl);

	//int j = 0;
	//while (perl_argv[j++] != NULL)
		//printf("perl argument %s\n", perl_argv[j]);

        perl_parse(my_perl, xs_init, perl_argc, perl_argv, NULL);
        PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
}
开发者ID:dateline,项目名称:enterprise-search,代码行数:41,代码来源:perlembed.c


示例19: perl_start_script

/*
 * Start trace script
 */
static int perl_start_script(const char *script, int argc, const char **argv)
{
	const char **command_line;
	int i, err = 0;

	command_line = malloc((argc + 2) * sizeof(const char *));
	command_line[0] = "";
	command_line[1] = script;
	for (i = 2; i < argc + 2; i++)
		command_line[i] = argv[i - 2];

	my_perl = perl_alloc();
	perl_construct(my_perl);

	if (perl_parse(my_perl, xs_init, argc + 2, (char **)command_line,
		       (char **)NULL)) {
		err = -1;
		goto error;
	}

	if (perl_run(my_perl)) {
		err = -1;
		goto error;
	}

	if (SvTRUE(ERRSV)) {
		err = -1;
		goto error;
	}

	run_start_sub();

	free(command_line);
	fprintf(stderr, "perf trace started with Perl script %s\n\n", script);
	return 0;
error:
	perl_free(my_perl);
	free(command_line);

	return err;
}
开发者ID:KaZoom,项目名称:buildroot-linux-kernel-m3,代码行数:44,代码来源:trace-event-perl.c


示例20: perlstartstop

/* Stopping has one big memory leak right now, so it's not used. */
void perlstartstop (int startnotstop) {
	if (startnotstop && !isperlrunning) {
		char *embedding[] = {
			"", "-e",
			"$SIG{__DIE__}=$SIG{__WARN__}=\\&EPIC::yell;"
		};
		++isperlrunning;
		my_perl = perl_alloc();
		perl_construct( my_perl );
		perl_parse(my_perl, xs_init, 3, embedding, NULL);
		if (SvTRUE(ERRSV)) yell("perl_parse: %s", SvPV_nolen(ERRSV));
		perl_run(my_perl);
		if (SvTRUE(ERRSV)) yell("perl_run: %s", SvPV_nolen(ERRSV));
	} else if (!startnotstop && isperlrunning && !perlcalldepth) {
		perl_destruct(my_perl);
		if (SvTRUE(ERRSV)) yell("perl_destruct: %s", SvPV_nolen(ERRSV));
		perl_free(my_perl);
		if (SvTRUE(ERRSV)) yell("perl_free: %s", SvPV_nolen(ERRSV));
		isperlrunning=0;
	}
}
开发者ID:carriercomm,项目名称:epic5-1,代码行数:22,代码来源:perl.c



注:本文中的perl_alloc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ perl_destruct函数代码示例发布时间:2022-05-30
下一篇:
C++ peripheral_free_list函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap