tags:

views:

67

answers:

2

Hi!

I look through a C source (pjsip) and I find this sctucture. I don't know how to conceive.

static struct user_agent
{
    pjsip_module     mod;
    pj_pool_t       *pool;
    pjsip_endpoint  *endpt;
    pj_mutex_t      *mutex;
    pj_hash_table_t *dlg_table;
    pjsip_ua_init_param  param;
    struct dlg_set   free_dlgset_nodes;

} mod_ua = 
{
  {
    NULL, NULL,         /* prev, next.          */
    { "mod-ua", 6 },        /* Name.                */
    -1,             /* Id               */
    PJSIP_MOD_PRIORITY_UA_PROXY_LAYER,  /* Priority     */
    &mod_ua_load,       /* load()               */
    NULL,           /* start()              */
    NULL,           /* stop()               */
    &mod_ua_unload,     /* unload()             */
    &mod_ua_on_rx_request,  /* on_rx_request()          */
    &mod_ua_on_rx_response, /* on_rx_response()         */
    NULL,           /* on_tx_request.           */
    NULL,           /* on_tx_response()         */
    &mod_ua_on_tsx_state,   /* on_tsx_state()           */
  }
};
+2  A: 

Not a particularly clear question but what I think you're having a problem with is that the struct is being declared and used in the same statement. How about:

struct user_agent {
    ....
}

static struct user_agent mod_ua = ....

That any clearer?

K

Kev
Thanks the solution!!!
BaluEdo
A: 

It's hard to be certain without the definitions of the structures, but I think what's happening is that the mod member (which is of type pjsip_module) is being initialised, and the other members of mod_ua are not explicitly initialised (which means they'll be set to zero, because that's what happens when some members are initialised and not others). The inner set of braces is the clue. Have a look at the definition of pjsip_module - does it match the values you have?

RichieHindle