/* bool fetch (); */ NS_IMETHODIMP jxMySQL50Statement::Fetch(PRBool *_retval) { if (mConnection == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED); } if (mSTMT == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL); } PRInt32 ret = mysql_stmt_fetch(mSTMT); *_retval = PR_FALSE; if (!ret || ret == MYSQL_DATA_TRUNCATED) { *_retval = PR_TRUE; } else if (ret == MYSQL_NO_DATA) { *_retval = PR_FALSE; } else { // const char* err = mysql_stmt_error(mSTMT); PRUint32 eno = mysql_stmt_errno(mSTMT); if ( eno == 2050 || eno == 2051 || eno == 2052 || eno == 2053) { // No result set return NS_OK; } SET_ERROR_RETURN (JX_MYSQL50_MYSQL_ERROR); } return NS_OK; }
/* Fills out the **mesh structure from the (index)th mesh reference found in *db */ void GetMeshByIndex3ds(database3ds *db, ulong3ds index, mesh3ds **mesh) { chunk3ds *ntri; ulong3ds i, meshcount; if (db == NULL || mesh == NULL) SET_ERROR_RETURN(ERR_INVALID_ARG); if (db->topchunk == NULL) SET_ERROR_RETURN(ERR_INVALID_DATABASE); if (!(db->topchunk->tag == M3DMAGIC || db->topchunk->tag == CMAGIC)) SET_ERROR_RETURN(ERR_WRONG_DATABASE); /* Update the index to named objects if the list has changed recently */ UpdateNamedObjectList3ds(db); /* Scan through the list of named objects */ for (i = 0, meshcount = 0; i < db->objlist->count; i++) { /* Search each named object for a mesh chunk */ FindChunk3ds(db->objlist->list[i].chunk, N_TRI_OBJECT, &ntri); /* If a mesh chunk is found */ if (ntri != NULL) { /* Increment the running total */ meshcount++; /* If this is the (index)th mesh, fill out the structure */ if (meshcount-1 == index) { GetMeshEntryChunk3ds(db->objlist->list[i].chunk, mesh); break; } } } }
NS_IMETHODIMP jxMySQL50Statement::GetString(PRUint32 aIndex, nsAString & _retval) { if (mConnection == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED); } if (mSTMT == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL); } if (aIndex < 0 || aIndex >= mOut.mCount) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_ILLEGAL_VALUE); } if (mOut.mBindArrayIsNull[aIndex]) { // null columns get IsVoid set to distinguish them from empty strings _retval.Truncate(0); _retval.SetIsVoid(PR_TRUE); } else { // int slen = sqlite3_column_bytes16 (mSqliteStatement, aIndex); // const PRUnichar *wstr = (const PRUnichar *) sqlite3_column_text16 (mSqliteStatement, aIndex); PRUint32 slen = mOut.mBindArrayBufferTYPE_STRING_LEN_OUT[aIndex]; // const PRUnichar* wstr = (const PRUnichar *) mOut.mBindArrayBufferTYPE_STRING[aIndex]; //_retval.AssignASCII(mOut.mBindArrayBufferTYPE_STRING[aIndex], slen); _retval = NS_ConvertUTF8toUTF16(mOut.mBindArrayBufferTYPE_STRING[aIndex], slen); } return NS_OK; }
NS_IMETHODIMP jxMySQL50Statement::GetInt32(PRUint32 aIndex, PRInt32 *_retval) { if (mConnection == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED); } if (mSTMT == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL); } if (aIndex < 0 || aIndex >= mOut.mCount) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_ILLEGAL_VALUE); } if (mOut.mBindArrayIsNull[aIndex]) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_BIND_ARRAY_IS_NULL); } if (mOut.mBindArrayType[aIndex] != MYSQL_TYPE_DOUBLE) { SET_ERROR_RETURN (JX_MYSQL50_CANNOT_CONVERT_DATA); } double *dd = (double*)(&(mOut.mBindArrayBufferTYPE_DOUBLE[aIndex])); *_retval = (PRInt32) *dd; return NS_OK; }
NS_IMETHODIMP jxMySQL50Statement::GetUTF8String(PRUint32 aIndex, nsACString &_retval) { if (mConnection == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED); } if (mSTMT == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL); } if (aIndex < 0 || aIndex >= mOut.mCount) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_ILLEGAL_VALUE); } if (mOut.mBindArrayIsNull[aIndex]) { // null columns get IsVoid set to distinguish them from empty strings _retval.Truncate(0); _retval.SetIsVoid(PR_TRUE); } else { PRUint32 slen = mOut.mBindArrayBufferTYPE_STRING_LEN_OUT[aIndex]; const char* cstr = mOut.mBindArrayBufferTYPE_STRING[aIndex]; _retval.Assign(cstr, slen); } return NS_OK; }
/* Fills out the **mesh structure contained in *db with the name listed in *name */ void GetMeshByName3ds(database3ds *db, /* Chunk listing to be searched */ char3ds *name, /* Name of mesh being searched for */ mesh3ds **mesh /* A pointer to the address of the mesh structure, if (*mesh) is null, then memory will be allocated for the new structure, otherwise, the existing structure will be filled in with the new values. If no match is found, then **mesh remains unchanged */ ) { chunk3ds *nobj = NULL, *ntri = NULL; if (db == NULL || name == NULL || mesh == NULL) SET_ERROR_RETURN(ERR_INVALID_ARG); if (db->topchunk == NULL) SET_ERROR_RETURN(ERR_INVALID_DATABASE); if (!(db->topchunk->tag == M3DMAGIC || db->topchunk->tag == CMAGIC)) SET_ERROR_RETURN(ERR_WRONG_DATABASE); UpdateNamedObjectList3ds(db); /* Find the matching mesh name in the chunk list */ FindNamedObject3ds(db, name, &nobj); /* if a match is found */ if (nobj != NULL) { /* See it the named object is a mesh object */ FindChunk3ds(nobj, N_TRI_OBJECT, &ntri); /* If it is a mesh object, then fill in the mesh structure */ if (ntri != NULL) GetMeshEntryChunk3ds(nobj, mesh); } }
/* Sets the M3dMagicRelease level */ void PutM3dMagicRelease3ds(database3ds *db, releaselevel3ds release) { if (db == NULL) SET_ERROR_RETURN(ERR_INVALID_ARG); if (db->topchunk == NULL) SET_ERROR_RETURN(ERR_INVALID_DATA); if (db->topchunk->tag == M3DMAGIC) { chunk3ds *c; M3dVersion *d; ReplaceOrAddChild3ds(db->topchunk, M3D_VERSION, &c); ON_ERROR_RETURN; d = InitChunkData3ds(c); ON_ERROR_RETURN; switch(release) { case Release13ds: d->version = 1; break; case Release23ds: d->version = 2; break; case Release33ds: d->version = 3; break; case ReleaseNotKnown3ds: d->version = 4; } } }
/* void close (); */ NS_IMETHODIMP jxMySQL50Statement::Close() { if (mConnection == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED); } if (mSTMT == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL); } mysql_free_result(mRES); if(mysql_stmt_close(mSTMT)) { SET_ERROR_RETURN (JX_MYSQL50_MYSQL_ERROR); } mSTMT = nsnull; mIn.Free(); mOut.Free(); return NS_OK; }
/* void BindBooleanParameter (in unsigned long aParamIndex, in boolean aValue); */ NS_IMETHODIMP jxMySQL50Statement::BindBooleanParameter(PRUint32 aParamIndex, PRBool aValue) { if (mConnection == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED); } if (mSTMT == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL); } if (aParamIndex < 0 || aParamIndex >= mIn.mCount) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_ILLEGAL_VALUE); } mIn.mBindArrayBufferTYPE_BOOL[aParamIndex] = aValue; mIn.mBIND[aParamIndex].buffer_type = MYSQL_TYPE_TINY; mIn.mBIND[aParamIndex].buffer = &(mIn.mBindArrayBufferTYPE_BOOL[aParamIndex]); mIn.mBIND[aParamIndex].length = 0; mIn.mBIND[aParamIndex].is_null = 0; return NS_OK; }
NS_IMETHODIMP jxMySQL50Statement::GetTimeString(PRUint32 aIndex, nsAString &result) { if (mConnection == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED); } if (mSTMT == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL); } if (aIndex < 0 || aIndex >= mOut.mCount) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_ILLEGAL_VALUE); } if (mOut.mBindArrayIsNull[aIndex]) { // null columns get IsVoid set to distinguish them from empty strings result.Truncate(0); result.SetIsVoid(PR_TRUE); } else { MYSQL_TIME* mysqlTime = mOut.mBindArrayBufferTYPE_DATE[aIndex]; char buf[30]; sprintf(buf, "%02d:%02d:%02d", mysqlTime->hour, mysqlTime->minute, mysqlTime->second); result.AssignASCII(buf); } return NS_OK; }
/* void bindInt64Parameter (in unsigned long aParamIndex, in long long aValue); */ NS_IMETHODIMP jxMySQL50Statement::BindInt64Parameter(PRUint32 aParamIndex, PRInt64 aValue) { if (mConnection == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED); } if (mSTMT == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL); } if (aParamIndex < 0 || aParamIndex >= mIn.mCount) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_ILLEGAL_VALUE); } mIn.mBindArrayBufferTYPE_DOUBLE[aParamIndex] = aValue; mIn.mBIND[aParamIndex].buffer_type = MYSQL_TYPE_DOUBLE; // MYSQL_TYPE_LONGLONG; mIn.mBIND[aParamIndex].buffer = (char*) &(mIn.mBindArrayBufferTYPE_DOUBLE[aParamIndex]); mIn.mBIND[aParamIndex].length = 0; mIn.mBIND[aParamIndex].is_null = 0; return NS_OK; }
/* void bindNullParameter (in unsigned long aParamIndex); */ NS_IMETHODIMP jxMySQL50Statement::BindNullParameter(PRUint32 aParamIndex) { if (mConnection == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED); } if (mSTMT == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL); } if (aParamIndex < 0 || aParamIndex >= mIn.mCount) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_ILLEGAL_VALUE); } mIn.mBindArrayBufferTYPE_BOOL[aParamIndex] = 1; mIn.mBIND[aParamIndex].buffer_type = MYSQL_TYPE_NULL; mIn.mBIND[aParamIndex].buffer = (char*)&(mIn.mBindArrayBufferTYPE_BOOL[aParamIndex]); mIn.mBIND[aParamIndex].length = 0; // This may not work mIn.mBIND[aParamIndex].is_null = (my_bool*) &(mIn.mBindArrayBufferTYPE_BOOL[aParamIndex]); return NS_OK; }
/*-------------------------------------------------------------------------- | | GetSpotlightByName3ds | | Fills out the **spot structure contained in *db that matches the | name in *name. | +--------------------------------------------------------------------------*/ void GetSpotlightByName3ds(database3ds *db, char3ds *name, light3ds **spotlight) { chunk3ds *nobj, *lite, *spot; if (db == NULL || spotlight == NULL) SET_ERROR_RETURN(ERR_INVALID_ARG); if (db->topchunk == NULL) SET_ERROR_RETURN(ERR_INVALID_DATABASE); if (!(db->topchunk->tag == M3DMAGIC || db->topchunk->tag == CMAGIC)) SET_ERROR_RETURN(ERR_WRONG_DATABASE); /* Find the matching name */ FindNamedObject3ds(db, name, &nobj); /* If a match was found */ if (nobj != NULL) { /* Verify that its a light */ FindChunk3ds(nobj, N_DIRECT_LIGHT, &lite); /* if its a light then check to see if its a spot */ FindChunk3ds(lite, DL_SPOTLIGHT, &spot); /* if it is a spot, then retreave the structure */ if (spot != NULL) { GetLightEntryChunk3ds(nobj, spotlight); } } }
/*-------------------------------------------------------------------------- | InitLight3ds | | Initializes the light3ds structure. If *light is null, | memory is also allocated for it. Note that the *spot field is | ignored when an existing structure is used. | +--------------------------------------------------------------------------*/ void InitLight3ds(light3ds **light) { if (light == NULL) SET_ERROR_RETURN(ERR_INVALID_ARG); /* If (*light) a null pointer, then alloc new memory for the pointer */ if (*light == NULL){ *light = malloc(sizeof(light3ds)); if(*light == NULL) SET_ERROR_RETURN(ERR_NO_MEM); /* Set all fields with pointer to NULL as well */ (*light)->spot = NULL; (*light)->exclude = NULL; } (*light)->name[0] = 0; (*light)->pos.x = 0.0F; (*light)->pos.y = 0.0F; (*light)->pos.z = 0.0F; (*light)->color.r = 0.708852F; (*light)->color.g = 0.708852F; (*light)->color.b = 0.708852F; (*light)->multiplier = 1.0F; (*light)->dloff = False3ds; (*light)->attenuation.on = False3ds; (*light)->attenuation.inner = 10.0F; (*light)->attenuation.outer = 100.0F; if ((*light)->exclude != NULL) ReleaseNameList3ds(&((*light)->exclude)); InitNameList3ds( &((*light)->exclude), (long3ds)0); }
NS_IMETHODIMP jxMySQL50Statement::GetUTF8Text(PRUint32 aIndex, nsACString &aData) { if (mConnection == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED); } if (mSTMT == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL); } if (aIndex < 0 || aIndex >= mOut.mCount) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_ILLEGAL_VALUE); } if (mOut.mBindArrayIsNull[aIndex]) { // null columns get IsVoid set to distinguish them from empty strings aData.Truncate(0); aData.SetIsVoid(PR_TRUE); }else { int nsize = mOut.mBindArrayBufferTYPE_STRING_LEN_OUT[aIndex]; char *data = static_cast<char*>(nsMemory::Alloc(nsize+1)); //extra for the null if (data == NULL) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_OUT_OF_MEMORY); } my_bool is_null; my_bool error; unsigned long length; MYSQL_BIND bind; memset(&bind, 0, sizeof(bind)); bind.buffer= (void*)data; bind.buffer_length= nsize; bind.buffer_type = MYSQL_TYPE_STRING; bind.is_null= &is_null; bind.length= &length; bind.error= &error; if (mysql_stmt_fetch_column(mSTMT, &bind, aIndex, 0)) { SET_ERROR_RETURN (JX_MYSQL50_MYSQL_ERROR); } data[nsize] = 0; aData = nsDependentCString(data, nsize); } return NS_OK; }
/* Sets the KFDATA release level */ void PutKfRelease3ds(database3ds *db, releaselevel3ds release) { KFHdr *d; if (db == NULL) SET_ERROR_RETURN(ERR_INVALID_ARG); if (db->topchunk == NULL) SET_ERROR_RETURN(ERR_INVALID_DATABASE); if ((db->topchunk->tag == M3DMAGIC) || (db->topchunk->tag == CMAGIC)) { chunk3ds *kfdata; chunk3ds *kfhdr; /* Find the KFDATA section */ FindChunk3ds(db->topchunk, KFDATA, &kfdata); /* If one doesn't exist, then create it */ if (kfdata == NULL) { InitChunkAs3ds(&kfdata, KFDATA); AddChildOrdered3ds(db->topchunk, kfdata); } /* Find the KFHDR */ FindChunk3ds(kfdata, KFHDR, &kfhdr); /* If a KFHDR doesn't exist, then create it */ if (kfhdr == NULL) { d = InitChunkAndData3ds(&kfhdr, KFHDR); d->filename = strdup(""); d->animlength = 30; /* Just a default */ AddChildOrdered3ds(kfdata, kfhdr); } else /* Else, just get its data */ { d = ReadChunkData3ds(kfhdr); } /* Set the revision level */ switch(release) { case Release13ds: d->revision = 1; break; case Release23ds: d->revision = 2; break; case Release33ds: d->revision = 5; break; case ReleaseNotKnown3ds: d->revision = 6; break; } } }
/* AString getColumnDecltype(in unsigned long aParamIndex); */ NS_IMETHODIMP jxMySQL50Statement::GetColumnDecltype(PRUint32 aParamIndex, nsACString& aDeclType) { if (mConnection == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED); } if (mSTMT == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL); } if (aParamIndex < 0 || aParamIndex >= mOut.mCount) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_ILLEGAL_VALUE); } char *declType = 0; switch (mOut.mBindArrayType[aParamIndex]) { case MYSQL_TYPE_STRING: declType = "string"; break; case MYSQL_TYPE_BLOB: declType = "blob"; break; case MYSQL_TYPE_DOUBLE: declType = "double"; break; case MYSQL_TYPE_DATETIME: declType = "datetime"; break; case MYSQL_TYPE_DATE: declType = "date"; break; case MYSQL_TYPE_TIME: declType = "time"; break; case MYSQL_TYPE_NULL: declType = "null"; default: declType = "unknown"; break; } aDeclType.Assign(declType); return NS_OK; }
NS_IMETHODIMP jxMySQL50Statement::BindDatetimeParameter(PRUint32 aParamIndex, PRUint32 aSecond) { if (mConnection == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED); } if (mSTMT == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL); } if (aParamIndex < 0 || aParamIndex >= mIn.mCount) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_ILLEGAL_VALUE); } if (mIn.mBindArrayBufferTYPE_DATE[aParamIndex] == nsnull) mIn.mBindArrayBufferTYPE_DATE[aParamIndex] = static_cast<MYSQL_TIME*>(nsMemory::Alloc(sizeof(MYSQL_TIME))); if (mIn.mBindArrayBufferTYPE_DATE[aParamIndex] == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_OUT_OF_MEMORY); } time_t t = (time_t) aSecond; struct tm *tmptm = gmtime(&t); // struct tm *tmpltm = localtime(&t); #if 0 PRTime t = aSecond * 1000; PRExplodedTime prtime; PR_ExplodeTime(t, PR_LocalTimeParameters, &prtime); #endif MYSQL_TIME* mysqlTime = mIn.mBindArrayBufferTYPE_DATE[aParamIndex]; mysqlTime->year = tmptm->tm_year + 1900; mysqlTime->month = tmptm->tm_mon + 1; mysqlTime->day = tmptm->tm_mday; mysqlTime->hour = tmptm->tm_hour; mysqlTime->minute = tmptm->tm_min; mysqlTime->second = tmptm->tm_sec; mysqlTime->second_part = 0; /* mic's not supported in MySQL yet */ mysqlTime->neg = 0; mysqlTime->time_type = MYSQL_TIMESTAMP_DATETIME; mIn.mBIND[aParamIndex].buffer_type = MYSQL_TYPE_DATETIME; mIn.mBIND[aParamIndex].buffer = mIn.mBindArrayBufferTYPE_DATE[aParamIndex]; mIn.mBIND[aParamIndex].length = 0; mIn.mBIND[aParamIndex].length_value = lenOfMySQL_TIME; mIn.mBIND[aParamIndex].buffer_length = lenOfMySQL_TIME; return NS_OK; }
NS_IMETHODIMP jxMySQL50Statement::GetBlob(PRUint32 aIndex, PRUint32 *aDataSize, PRUint8 **aData) { if (mConnection == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED); } if (mSTMT == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL); } if (aIndex < 0 || aIndex >= mOut.mCount) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_ILLEGAL_VALUE); } int blobsize = mOut.mBindArrayBufferTYPE_STRING_LEN_OUT[aIndex]; if (blobsize > 0) { void *blob = static_cast<void*>(nsMemory::Alloc(blobsize)); if (blob == NULL) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_OUT_OF_MEMORY); } my_bool is_null; my_bool error; unsigned long length; MYSQL_BIND bind; memset(&bind, 0, sizeof(bind)); bind.buffer_type = MYSQL_TYPE_BLOB; bind.buffer= blob; bind.buffer_length= blobsize; bind.is_null= &is_null; bind.length= &length; bind.error= &error; if (mysql_stmt_fetch_column(mSTMT, &bind, aIndex, 0)) { SET_ERROR_RETURN (JX_MYSQL50_MYSQL_ERROR); } *aData = (PRUint8*) blob; *aDataSize = blobsize; }else { *aData = 0; *aDataSize = 0; } return NS_OK; }
void CopyBackground3ds(database3ds *destdb, database3ds *srcdb) { chunk3ds *srcmdata, *destmdata, *srcchunk, *destchunk; if ((destdb == NULL) || (srcdb == NULL)) SET_ERROR_RETURN(ERR_INVALID_ARG); if ((srcdb->topchunk == NULL) || (destdb->topchunk == NULL)) SET_ERROR_RETURN(ERR_INVALID_DATABASE); if ((srcdb->topchunk->tag != M3DMAGIC) && (srcdb->topchunk->tag != CMAGIC)) SET_ERROR_RETURN(ERR_WRONG_DATABASE); if ((destdb->topchunk->tag != M3DMAGIC) && (destdb->topchunk->tag != CMAGIC)) SET_ERROR_RETURN(ERR_WRONG_DATABASE); /* Find source mesh section */ FindChunk3ds(srcdb->topchunk, MDATA, &srcmdata); /* If found */ if (srcmdata != NULL) { /* Find or create destination mesh section */ FindChunk3ds(destdb->topchunk, MDATA, &destmdata); if (destmdata == NULL) { InitChunkAs3ds(&destmdata, MDATA); AddChildOrdered3ds(destdb->topchunk, destmdata); } /* Scan the source mdata section looking for background setting chunks */ for (srcchunk = srcmdata->children; srcchunk != NULL; srcchunk = srcchunk->sibling) { switch(srcchunk->tag) { case V_GRADIENT: case SOLID_BGND: case BIT_MAP: case USE_SOLID_BGND: case USE_V_GRADIENT: case USE_BIT_MAP: /* if the same chunk exists in the destination, then delete it */ FindNextChunk3ds(destmdata->children, srcchunk->tag, &destchunk); if (destchunk != NULL) DeleteChunk3ds(destchunk); /* Copy and add the chunk */ CopyChunk3ds(srcchunk, &destchunk); AddChildOrdered3ds(destmdata, destchunk); break; default: break; } } } }
/*-------------------------------------------------------------------------- | PutOmnilightMotion3ds | Puts Omnilight keyframe information into database. | | kfOmnilight3ds--->db | | KFDATA | ... | LIGHT_NODE | NODE_ID | NODE_HDR | APP_DATA | POS_TRACK | COL_TRACK | | Needs Work: | 1. NodeId: what value? | +--------------------------------------------------------------------------*/ void PutOmnilightMotion3ds(database3ds *db, kfomni3ds *kfomni) { chunk3ds *pKfChunk, *pOmniChunk, *pOmniXdata = NULL; if(db == NULL || kfomni == NULL) SET_ERROR_RETURN(ERR_INVALID_ARG); if(db->topchunk == NULL) SET_ERROR_RETURN(ERR_INVALID_DATABASE); if (!(db->topchunk->tag == M3DMAGIC || db->topchunk->tag == CMAGIC)) SET_ERROR_RETURN(ERR_WRONG_DATABASE); MakeNodeTagListDirty3ds(db); /*--- Find KFSEG chunk to put keyframe data into */ kfGetKfSeg(db->topchunk, &pKfChunk); /*--- Destroy old chunks, Copy any XData and reattach it later */ kfExtractXdata(db, kfomni->name, LIGHT_NODE_TAG, &pOmniXdata); pOmniChunk = kfPutGenericNode(LIGHT_NODE_TAG, pKfChunk); kfPutNodeId(pOmniChunk); kfPutNodeHeader(kfomni->name, kfomni->flags1, kfomni->flags2, kfomni->parent, pOmniChunk); MakeNodeTagListDirty3ds(db); if (kfomni->npkeys>0 && kfomni->pkeys && kfomni->pos) kfPutPosTrack(kfomni->npkeys, kfomni->npflag, kfomni->pkeys, kfomni->pos, pOmniChunk); if (kfomni->nckeys>0 && kfomni->ckeys && kfomni->color) kfPutColorTrack(kfomni->nckeys, kfomni->ncflag, kfomni->ckeys, kfomni->color, pOmniChunk); /*--- Replace XData */ if (pOmniXdata) AddChildOrdered3ds(pOmniChunk, pOmniXdata); }
/*---------------------------------------------------------- | |InitAmbientLightMotion3ds | +----------------------------------------------------------*/ void InitAmbientLightMotion3ds(kfambient3ds **light, ulong3ds nckeys) { ulong3ds i; if (*light == NULL) { (*light) = malloc(sizeof(kfambient3ds)); if(*light == NULL) SET_ERROR_RETURN(ERR_NO_MEM); (*light)->flags1 = (*light)->flags2 = (ushort3ds)0; (*light)->nckeys = nckeys; (*light)->color = NULL; (*light)->ckeys = NULL; } if ((*light)->ckeys != NULL) { free((*light)->ckeys); (*light)->ckeys = NULL; } if ((*light)->color != NULL) { free((*light)->color); (*light)->color = NULL; } if (nckeys != 0) { (*light)->ncflag = TrackSingle3ds; (*light)->nckeys = nckeys; (*light)->ckeys = calloc((*light)->nckeys, sizeof(keyheader3ds)); if((*light)->ckeys == NULL) SET_ERROR_RETURN(ERR_NO_MEM); for (i = 0; i < (*light)->nckeys; i++) memcpy(&(((*light)->ckeys)[i]), &DefKeyHeader3ds, sizeof(DefKeyHeader3ds)); (*light)->color = calloc((*light)->nckeys, sizeof(fcolor3ds)); if((*light)->color == NULL) SET_ERROR_RETURN(ERR_NO_MEM); for (i = 0; i < (*light)->nckeys; i++) ((*light)->color)[i].r = ((*light)->color)[i].g = ((*light)->color)[i].b = (float3ds)1.0; } }
NS_IMETHODIMP jxMySQL50Statement::Execute(PRUint32 *_retval) { if (mConnection == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED); } if (mSTMT == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL); } *_retval = 1; // Assume the input parameters are all inited. // Get access to the array of parameter values and verify its length. if (mysql_stmt_bind_param(mSTMT, mIn.mBIND)) { //Error *_retval = 1; SET_ERROR_RETURN (JX_MYSQL50_MYSQL_ERROR); } // Bind output fields if not done already. if (!mOut.mBIND && mOut.mCount > 0) { nsresult rv = BindOutput(); if (NS_FAILED(rv)) { *_retval = 1; SET_ERROR_RETURN (rv); } } if (mysql_stmt_execute(mSTMT)) { *_retval = 1; SET_ERROR_RETURN (JX_MYSQL50_MYSQL_ERROR); } *_retval = 0; return NS_OK; }
/* long paramCount (); */ NS_IMETHODIMP jxMySQL50Statement::ParamCount(PRInt32 *_retval) { if (mConnection == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED); } if (mSTMT == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL); } *_retval = mIn.mCount; return NS_OK; }
/* AString SQLState (); */ NS_IMETHODIMP jxMySQL50Statement::SQLState(nsAString & _retval) { if (mConnection == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED); } if (mSTMT == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL); } _retval.Assign(NS_ConvertUTF8toUTF16(mysql_stmt_sqlstate(mSTMT))); return NS_OK; }
/* Adds a file3ds * to **FileContextList3ds */ void AddContext3ds(file3ds *file) { ubyte3ds i; /* If this is the first add, initialize the list */ if (FileContextList3ds == NULL) InitContextList3ds(); /* scan for an open slot in the list */ for (i = 0; i < NextFileContext; i++) { if (FileContextList3ds[i] == NULL) break; } if (i>=MaxFileContext) SET_ERROR_RETURN(ERR_TOO_MANY_FILES); /* Install the file pointer */ FileContextList3ds[i] = file; /* Associate the list position with the file */; file->index = i; /* Increment the file counter if needed */ if (i == NextFileContext) NextFileContext++; }
void SetFile3ds(FILE *file) { if (file == NULL) SET_ERROR_RETURN(ERR_INVALID_ARG); GetContext3ds()->file = file; }
/* long long rowCount (); */ NS_IMETHODIMP jxMySQL50Statement::RowCount(PRInt64 *aCount) { if (mConnection == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED); } if (mSTMT == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL); } *aCount = mysql_stmt_num_rows(mSTMT); return NS_OK; }
/* unsigned long fieldCount (); */ NS_IMETHODIMP jxMySQL50Statement::FieldCount(PRUint32 *aCount) { if (mConnection == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED); } if (mSTMT == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL); } *aCount = mOut.mCount; return NS_OK; }
/* long long insertId (); */ NS_IMETHODIMP jxMySQL50Statement::InsertId(PRInt64 *aID) { if (mConnection == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED); } if (mSTMT == nsnull) { SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL); } *aID = mysql_stmt_insert_id(mSTMT); return NS_OK; }