示例#1
0
void mhash_init_mhash_program(void) {
  start_new_program();
  ADD_STORAGE( mhash_storage  );
  ADD_FUNCTION("create", f_hash_create,   tFunc(tOr(tInt,tVoid),tVoid), 0);
  ADD_FUNCTION("update", f_hash_feed,   	tFunc(tStr,tObj), 0 ); 
  ADD_FUNCTION("feed", f_hash_feed,     	tFunc(tStr,tObj), 0 );
  ADD_FUNCTION("digest", f_hash_digest, 	tFunc(tVoid,tStr), 0);
  ADD_FUNCTION("query_name", f_hash_query_name, tFunc(tVoid,tStr), 0 ); 
  ADD_FUNCTION("reset", f_hash_reset,   	tFunc(tVoid,tVoid), 0 ); 
  ADD_FUNCTION("set_type", f_hash_set_type, 	tFunc(tInt,tVoid), 0 ); 
  set_init_callback(init_hash_storage);
  set_exit_callback(free_hash_storage);
  end_class("Hash", 0);
}
示例#2
0
文件: mcast.c 项目: hww3/pexts
void pike_module_init(void)
{
#ifdef PEXTS_VERSION
   pexts_init();
#endif

   struct svalue sv;
   
   /* Starting a new class */
   start_new_program();
   
   /* Agrega espacio para los datos internos */
   low_add_storage(sizeof(struct mcast_storage) - sizeof(struct udp_storage),
		   ALIGNOF(struct mcast_storage),0);

   /* Hereda Stdio.UDP */
   /* NOTA IMPORTANTE
    * Aparentemente no se puede heredar un objeto
    * escrito en Pike desde aquí... luego, heredo
    * el objeto básico (nativo) */

   /* Resuelve el objeto (encuentra el archivo) */
   push_text("files.UDP");
   SAFE_APPLY_MASTER("resolv",1);
   if(Pike_sp[-1].type != T_FUNCTION)
     Pike_error("Error in resolving of Stdio.UDP!\n");
   
   /* Obtiene el programa */
   stdio_udp = program_from_function(&Pike_sp[-1]);
   pop_n_elems(1);
   
   /* Hereda */
   sv.type = T_PROGRAM;
   sv.subtype = 0;
   sv.u.program = stdio_udp;
   do_inherit( &sv, 0, 0);
   
   /* Agrega los métodos */
   ADD_FUNCTION("join",mcast_join,tFunc(tStr,tVoid),0);
   ADD_FUNCTION("leave",mcast_leave,tFunc(tStr,tVoid),0);
   ADD_FUNCTION("setLoopback",mcast_loopback,tFunc(tInt,tVoid),0);
   ADD_FUNCTION("setTTL",mcast_setTTL,tFunc(tInt,tVoid),0);
   ADD_FUNCTION("setInterface",mcast_setif,tFunc(tStr,tVoid),0);
   
   /* Llama a "init_mcast" antes de crear los objetos */
   set_init_callback(init_mcast);
   
   end_class("MultiCastUDP",0);
}
示例#3
0
文件: pcre.c 项目: hww3/pexts
/* Init the module */
void pike_module_init(void)
{
#ifdef PEXTS_VERSION
  pexts_init();
#endif

  start_new_program();
  ADD_STORAGE( PCRE_Regexp  );
  ADD_FUNCTION( "create", f_pcre_create,
		tFunc(tOr(tStr,tVoid) tOr(tStr,tVoid), tVoid), 0);
  ADD_FUNCTION("match", f_pcre_match,
	       tFunc(tStr tOr(tStr,tVoid), tInt), 0);
  ADD_FUNCTION("split", f_pcre_split,
	       tFunc(tStr tOr(tStr,tVoid), tArr(tStr)), 0);
  set_init_callback(init_regexp);
  set_exit_callback(free_regexp);
  end_class("Regexp", 0);
  add_integer_constant("version", 2, 0);
}
示例#4
0
/* Initialize and start module */
void pike_module_init( void )
{
  STRS(data)     = make_shared_string("data");
  STRS(file)     = make_shared_string("file");
  STRS(method)   = make_shared_string("method");
  STRS(protocol) = make_shared_string("protocol");
  STRS(query)    = make_shared_string("query");
  STRS(raw_url)  = make_shared_string("raw_url");

  SVAL(data)->type     = T_STRING;
  SVAL(file)->type     = T_STRING;
  SVAL(method)->type   = T_STRING;
  SVAL(protocol)->type = T_STRING;
  SVAL(query)->type    = T_STRING;
  SVAL(raw_url)->type  = T_STRING;
  
  add_function_constant( "parse_headers", f_parse_headers,
                         "function(string:mapping)", 0);
  add_function_constant( "parse_query_string", f_parse_query_string,
                         "function(string,mapping:void)",
                         OPT_SIDE_EFFECT);
  add_function_constant( "parse_prestates", f_parse_prestates,
                         "function(string,multiset,multiset:string)",
                         OPT_SIDE_EFFECT);
  add_function_constant( "get_address", f_get_address,
                         "function(string:string)", 0);
  add_function_constant( "extension", f_extension,
                         "function(string:string)", 0);
  add_function_constant( "create_process", f_create_process,
                         "function(array(string),void|mapping(string:mixed):int)", 0);

  start_new_program();
  ADD_STORAGE( buffer );
  add_function( "append", f_buf_append,
                "function(string:int)", OPT_SIDE_EFFECT );
  add_function( "create", f_buf_create, "function(mapping,mapping,int|void:void)", 0 );
  set_init_callback(alloc_buf_struct);
  set_exit_callback(free_buf_struct);
  end_class("ParseHTTP", 0);
  init_nbio();
}
示例#5
0
void pike_module_init() {
	struct utsname utsname;
	char *p;
	uname(&utsname);
	if ((p = strchr (utsname.nodename, '.')))
		*p = 0;
	Hostname=strdup(utsname.nodename);
	Tempdir=(char *) LIBMUTT_TEMPDIR;

	ADD_INT_CONSTANT("M_READ",M_READ,0);
	ADD_INT_CONSTANT("M_REPLIED",M_REPLIED,0);
	ADD_INT_CONSTANT("M_OLD",M_OLD,0);
	ADD_INT_CONSTANT("M_FLAG",M_FLAG,0);
	ADD_INT_CONSTANT("M_DELETE",M_DELETE,0);
	ADD_INT_CONSTANT("M_TAG",M_TAG,0);
	ADD_INT_CONSTANT("M_NEW",M_NEW,0);

	/* constants for mx_check_mailbox() */
	ADD_INT_CONSTANT("M_NEW_MAIL",M_NEW_MAIL,0);
	ADD_INT_CONSTANT("M_REOPENED",M_REOPENED,0);
	ADD_INT_CONSTANT("M_FLAGS",M_FLAGS,0);

	start_new_program();
	 ADD_STORAGE(MAILSTORE_STORAGE);
	
	 set_init_callback(init_mailstore);
	 set_exit_callback(exit_mailstore);


	// public pike methods
	ADD_FUNCTION("create", f_create,
		tFunc(tString, tVoid), 0);
	ADD_FUNCTION("_sizeof", f__sizeof,
		tFunc(tVoid, tInt), 0);
	ADD_FUNCTION("stat", f_stat,
		tFunc(tVoid, tMapping), 0); 
	ADD_FUNCTION("get_header", f_get_header,
		tFunc(tInt, tMapping), 0);
	ADD_FUNCTION("debug", f_debug,
		tFunc(tInt, tInt), 0);
	ADD_FUNCTION("set_flag", f_set_flag,
		tFunc(tInt tInt, tVoid), 0);
	ADD_FUNCTION("reset_flag", f_reset_flag,
		tFunc(tInt tInt, tVoid), 0);
	ADD_FUNCTION("check_mailbox", f_check_mailbox,
		tFunc(tVoid, tInt), 0);

	/* Mailbox.Message */
	start_new_program();
 	  set_init_callback(init_message_storage);
	  set_exit_callback(exit_message_storage);
	  ADD_STORAGE( MESSAGE_STORAGE );
	  ADD_FUNCTION("create", f_msg_create,
			tFunc(tInt, tVoid), 0);
	  ADD_FUNCTION("getFD", f_msg_getfd,   
			tFunc(tVoid, tInt), 0);
	  ADD_FUNCTION("get_header",f_msg_get_header, 
			tFunc(tVoid, tMapping), 0);
	 end_class("Message",0);

	end_class("Mailbox",0);
	
	mutt_error=libmutt_error;
	/* reference it so that it's not optimized out */
	__dummy_variable[0] = (void*)NULL;
}