void SjSee::HttpRequest_init() { SEE_value temp; // Create the "HttpRequest.prototype" object, this is used as a template for the instances m_HttpRequest_prototype = (SEE_object *)alloc_httprequest_object_(m_interpr); SEE_native_init((SEE_native *)m_HttpRequest_prototype, m_interpr, &httprequest_inst_class, m_interpr->Object_prototype); PUT_FUNC(m_HttpRequest_prototype, httprequest, setRequestHeader, 0); PUT_FUNC(m_HttpRequest_prototype, httprequest, getResponseHeader, 0); PUT_FUNC(m_HttpRequest_prototype, httprequest, request, 0); PUT_FUNC(m_HttpRequest_prototype, httprequest, abort, 0); // create the "HttpRequest" object SEE_object* HttpRequest = (SEE_object *)SEE_malloc(m_interpr, sizeof(SEE_native)); SEE_native_init((SEE_native *)HttpRequest, m_interpr, &httprequest_constructor_class, m_interpr->Object_prototype); PUT_OBJECT(HttpRequest, str_prototype, m_HttpRequest_prototype); // now we can add the globals PUT_OBJECT(m_interpr->Global, str_HttpRequest, HttpRequest); }
void SjSee::Database_init() { SEE_value temp; // Create the "Database.prototype" object, this is used as a template for the instances m_Database_prototype = (SEE_object *)alloc_database_object(m_interpr); SEE_native_init((SEE_native *)m_Database_prototype, m_interpr, &database_inst_class, m_interpr->Object_prototype); PUT_FUNC(m_Database_prototype, database, openQuery, 0); PUT_FUNC(m_Database_prototype, database, nextRecord, 0); PUT_FUNC(m_Database_prototype, database, getFieldCount, 0); PUT_FUNC(m_Database_prototype, database, getField, 0); PUT_FUNC(m_Database_prototype, database, closeQuery, 0); PUT_FUNC(m_Database_prototype, database, getFile, 0); // create the "Database" object SEE_object* Database = (SEE_object *)SEE_malloc(m_interpr, sizeof(SEE_native)); SEE_native_init((SEE_native *)Database, m_interpr, &database_constructor_class, m_interpr->Object_prototype); PUT_OBJECT(Database, str_prototype, m_Database_prototype) PUT_FUNC(Database, database, update, 0); // static function // now we can add the globals PUT_OBJECT(m_interpr->Global, str_Database, Database); }
void SjSee::Player_init() { SEE_value temp; // Create the "Player.prototype" object, this is used as a template for the instances m_Player_prototype = (SEE_object *)alloc_player_object(m_interpr); SEE_native_init((SEE_native *)m_Player_prototype, m_interpr, &player_inst_class, m_interpr->Object_prototype); PUT_FUNC(m_Player_prototype, player, play, 0); PUT_FUNC(m_Player_prototype, player, pause, 0); PUT_FUNC(m_Player_prototype, player, stop, 0); PUT_FUNC(m_Player_prototype, player, prev, 0); PUT_FUNC(m_Player_prototype, player, next, 0); PUT_FUNC(m_Player_prototype, player, isPlaying, 0); PUT_FUNC(m_Player_prototype, player, isPaused, 0); PUT_FUNC(m_Player_prototype, player, isStopped, 0); PUT_FUNC(m_Player_prototype, player, hasPrev, 0); PUT_FUNC(m_Player_prototype, player, hasNext, 0); PUT_FUNC(m_Player_prototype, player, getUrlAtPos, 0); PUT_FUNC(m_Player_prototype, player, getAutoplayAtPos, 0); PUT_FUNC(m_Player_prototype, player, getPlayCountAtPos, 0); PUT_FUNC(m_Player_prototype, player, getArtistAtPos, 0); PUT_FUNC(m_Player_prototype, player, getAlbumAtPos, 0); PUT_FUNC(m_Player_prototype, player, getTitleAtPos, 0); PUT_FUNC(m_Player_prototype, player, getDurationAtPos, 0); PUT_FUNC(m_Player_prototype, player, addAtPos, 0); PUT_FUNC(m_Player_prototype, player, removeAtPos, 0); PUT_FUNC(m_Player_prototype, player, removeAll, 0); // create the "Player" object SEE_object* Player = (SEE_object *)SEE_malloc(m_interpr, sizeof(SEE_native)); SEE_native_init((SEE_native *)Player, m_interpr, &player_constructor_class, m_interpr->Object_prototype); PUT_OBJECT(Player, str_prototype, m_Player_prototype) // now we can add the globals PUT_OBJECT(m_interpr->Global, str_Player, Player); m_player = Player_new(); PUT_OBJECT(m_interpr->Global, str_player, m_player); }
/* find all the certs that represent the appropriate object (cert, priv key, or * pub key) in the cert store. */ static PRUint32 collect_class( CK_OBJECT_CLASS objClass, SecItemClass itemClass, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulAttributeCount, ckmkInternalObject ***listp, PRUint32 *sizep, PRUint32 count, CK_RV *pError ) { ckmkInternalObject *next = NULL; SecKeychainSearchRef searchRef = 0; SecKeychainItemRef itemRef = 0; OSStatus error; /* future, build the attribute list based on the template * so we can refine the search */ error = SecKeychainSearchCreateFromAttributes( NULL, itemClass, NULL, &searchRef); while (noErr == SecKeychainSearchCopyNext(searchRef, &itemRef)) { /* if we don't have an internal object structure, get one */ if ((ckmkInternalObject *)NULL == next) { next = nss_ZNEW(NULL, ckmkInternalObject); if ((ckmkInternalObject *)NULL == next) { *pError = CKR_HOST_MEMORY; goto loser; } } /* fill in the relevant object data */ next->type = ckmkItem; next->objClass = objClass; next->u.item.itemRef = itemRef; next->u.item.itemClass = itemClass; /* see if this is one of the objects we are looking for */ if( CK_TRUE == ckmk_match(pTemplate, ulAttributeCount, next) ) { /* yes, put it on the list */ PUT_OBJECT(next, *pError, *sizep, count, *listp); next = NULL; /* this one is on the list, need to allocate a new one now */ } else { /* no , release the current item and clear out the structure for reuse */ CFRelease(itemRef); /* don't cache the values we just loaded */ nsslibc_memset(next, 0, sizeof(*next)); } } loser: if (searchRef) { CFRelease(searchRef); } nss_ZFreeIf(next); return count; }
static PRUint32 collect_objects( CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulAttributeCount, ckmkInternalObject ***listp, CK_RV *pError ) { PRUint32 i; PRUint32 count = 0; PRUint32 size = 0; CK_OBJECT_CLASS objClass; /* * first handle the static build in objects (if any) */ for( i = 0; i < nss_ckmk_nObjects; i++ ) { ckmkInternalObject *o = (ckmkInternalObject *)&nss_ckmk_data[i]; if( CK_TRUE == ckmk_match(pTemplate, ulAttributeCount, o) ) { PUT_OBJECT(o, *pError, size, count, *listp); } } /* * now handle the various object types */ objClass = nss_ckmk_GetULongAttribute(CKA_CLASS, pTemplate, ulAttributeCount, pError); if (CKR_OK != *pError) { objClass = CK_INVALID_HANDLE; } *pError = CKR_OK; switch (objClass) { case CKO_CERTIFICATE: count = collect_class(objClass, kSecCertificateItemClass, pTemplate, ulAttributeCount, listp, &size, count, pError); break; case CKO_PUBLIC_KEY: count = collect_class(objClass, CSSM_DL_DB_RECORD_PUBLIC_KEY, pTemplate, ulAttributeCount, listp, &size, count, pError); break; case CKO_PRIVATE_KEY: count = collect_class(objClass, CSSM_DL_DB_RECORD_PRIVATE_KEY, pTemplate, ulAttributeCount, listp, &size, count, pError); break; /* all of them */ case CK_INVALID_HANDLE: count = collect_class(CKO_CERTIFICATE, kSecCertificateItemClass, pTemplate, ulAttributeCount, listp, &size, count, pError); count = collect_class(CKO_PUBLIC_KEY, CSSM_DL_DB_RECORD_PUBLIC_KEY, pTemplate, ulAttributeCount, listp, &size, count, pError); count = collect_class(CKO_PUBLIC_KEY, CSSM_DL_DB_RECORD_PRIVATE_KEY, pTemplate, ulAttributeCount, listp, &size, count, pError); break; default: break; } if (CKR_OK != *pError) { goto loser; } return count; loser: nss_ZFreeIf(*listp); return 0; }