ss_scope_t *
ss_pers_scope(ss_pers_t *pers, /* Persistent object link to query */
ss_scope_t *buf /* OUT: Optional buffer for the result scope link */
)
{
SS_ENTER(ss_pers_scope, ss_scope_tP);
ss_scope_t *buf_here=NULL;
ss_scope_t topscope, *retval=NULL;
ss_persobj_t *scopeobj=NULL;
ss_table_t *table=NULL;
SS_ASSERT_CLASS(pers, ss_pers_t);
if (NULL==ss_pers_topscope(pers, &topscope)) SS_ERROR(FAILED);
if (NULL==(table = ss_scope_table(&topscope, SS_MAGIC(ss_scope_t), NULL))) SS_ERROR(FAILED);
if (NULL==(scopeobj=ss_table_lookup(table, ss_pers_link_scopeidx(pers), SS_STRICT))) SS_ERROR(FAILED);
if (NULL==(retval = (ss_scope_t*)ss_pers_refer(&topscope, scopeobj, (ss_pers_t*)buf))) SS_ERROR(FAILED);
SS_CLEANUP:
SS_FREE(buf_here);
SS_LEAVE(retval);
}