· KLDP.org · KLDP.net · KLDP Wiki · KLDP BBS ·
Asterisk Ver0-1-0/Loader DotC

AsteriskVer0-1-0/LoaderDotC


struct module {
        int (*load_module)(void);
        int (*unload_module)(void);
        int (*usecount)(void);
        char *(*description)(void);
        void *lib;
        char resource[256];
        struct module *next;
};

static struct module *module_list=NULL;

* int ast_load_resource(char *resource_name)
  • struct module *m = malloc(sizeof(struct module));
  • resource_name ÀÌ Àý´ëÆнº¸é ±×´ë·Î fn ¿¡ ¼³Á¤, ¾Æ´Ï¸é /usr/lib/asterisk/modules/ À» ¾Õ¿¡ ÷ºÎÇÏ¿© fn ¿¡ ¼³Á¤
  • fn À» »ç¿ëÇÏ¿© dlopen, return °ªÀ» m->lib ¿¡ ¼³Á¤
  • m->lib °ú dlsym À» »ç¿ëÇÏ¿© load_module, unload_module, usecount, description À» Àоî structure m ¿¡ °¢°¢ ¼³Á¤
  • m->load_module() À» »ç¿ëÇÏ¿© ½ÇÇà½ÃŲ´Ù.
  • pthread_mutex_lock(&modlock) asterisk Ver0-1-0 ¿¡ ÀϺΠ¼³¸íÀÖÀ½.
  • m->next = module_list;
  • module_list = m;
  • pthread_mutex_unlock(&modlock);
  • ast_update_use_count();
  • return 0;

* dlopen dlsym dlclose dlerror: Programming interface to dynamic linking loader.
dlopen loads a dynamic library from the file named by the null terminated string filename and returns an opaque "handle" for the dynamic library.
dlsym takes a "handle" of a dynamic library returned by dlopen and the null terminated symbol name, returning the address where that symbol is loaded. If the symbol is not found, dlsym returns NULL
dlclose decrements the reference count on the dynamic library handle handle. If the reference count drops to zero and no other loaded libraries use symbols in it, then the dynamic library is unloaded.
* .so ÆÄÀÏÀÇ Á¾·ù¿Í °¢°¢ÀÇ load_module
  • apps ¹Ø¿¡ ÀÖ´Â application Àº load_module ¿¡ ÀÇÇØ ast_register_application À» ¼öÇàÇÑ´Ù.
  • channels ¹Ø¿¡ ÀÖ´Â device driver µéÀº load_module ¿¡ ÀÇÇØ mkif ¿Í ast_channel_register À» ¼öÇàÇÏ°í restart_monitor ¸¦ ÅëÇØ ÀÔ·ÂÀ» ±â´Ù¸°´Ù.
  • codecs ¹Ø¿¡ ÀÖ´Â codec ÆÄÀÏÀº load_module ¿¡ ÀÇÇØ ast_register_translator ¸¦ ¼öÇàÇÑ´Ù.
  • format ¹Ø¿¡ ÀÖ´Â ÆÄÀϵéÀº load_module ¿¡ ÀÇÇØ ast_format_register ¸¦ ¼öÇàÇÑ´Ù.
  • pbx ¹ØÀÇ ÆÄÀϵéÀº

* ast_register_application
  • pbx.c:int ast_register_application(char *app, int (*execute)(struct ast_channel *, void *))

* ast_register_translator
  • translate.c:int ast_register_translator(struct ast_translator *t)

* ast_format_register
  • file.c:int ast_format_register



sponsored by andamiro
sponsored by cdnetworks
sponsored by HP

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2010-07-03 02:06:45
Processing time 0.0040 sec