/*! subt_ttx_ctrl_set_dr \param[in] p_pmt: pmt data received from pmt.c \return SUCCESS if no error */ RET_CODE subt_ttx_ctrl_set_pmt(void *p_pmt) { RET_CODE ret = ERR_FAILURE; pmt_t *p_data = (pmt_t *)p_pmt; do { ERR_POINT(p_data); ret = _subt_ctrl_process(p_data); ERR_CHECK(ret); ret = _ttx_ctrl_process(p_data); ERR_CHECK(ret); if(p_data != NULL) { _subt_ctrl_auto(); _ttx_ctrl_auto(); _auto_notify(); } return SUCCESS; }while(0); return ret; }
void CleanTemp(void) { OSErr err = noErr; short vRefNum; long dirID; FSSpec viewerFSp; XPISpec *xpiList, *currXPI = 0, *nextXPI = 0; #ifdef MIW_DEBUG Boolean isDir = false; #endif #ifndef MIW_DEBUG /* get "viewer" in "Temporary Items" folder */ ERR_CHECK(FindFolder(kOnSystemDisk, kTemporaryFolderType, kCreateFolder, &vRefNum, &dirID)); err = FSMakeFSSpec(vRefNum, dirID, kViewerFolder, &viewerFSp); #else /* for DEBUG builds temp is "<currProcessVolume>:Temp NSInstall:" */ ERR_CHECK(GetCWD(&dirID, &vRefNum)); err = FSMakeFSSpec(vRefNum, 0, kTempFolder, &viewerFSp); if (err == fnfErr) return; /* no debug temp exists */ err = FSpGetDirectoryID(&viewerFSp, &dirID, &isDir); if (err != noErr || !isDir) return; err = FSMakeFSSpec(vRefNum, dirID, kViewerFolder, &viewerFSp); #endif /* whack the viewer folder if it exists */ if (err == noErr) { ERR_CHECK(DeleteDirectory(viewerFSp.vRefNum, viewerFSp.parID, viewerFSp.name)); } /* clean out the zippies (.xpi's) */ xpiList = (XPISpec *) NewPtrClear(sizeof(XPISpec)); if (!xpiList) return; IterateDirectory(vRefNum, dirID, "\p", 1, CheckIfXPI, (void*)&xpiList); if (xpiList) { currXPI = xpiList; while(currXPI) { nextXPI = currXPI->next; /* save nextXPI before we blow away currXPI */ if (currXPI->FSp) { FSpDelete(currXPI->FSp); DisposePtr((Ptr)currXPI->FSp); } DisposePtr((Ptr)currXPI); currXPI = nextXPI; } } }
M4OSA_ERR M4MP4W_putBE24(M4OSA_UInt32 val, M4OSA_FileWriterPointer* fileFunction, M4OSA_Context context) /*******************************************************************************/ { M4OSA_ERR err; err = M4MP4W_putByte((M4OSA_UChar)(val >> 16), fileFunction, context); ERR_CHECK(err == M4NO_ERROR, err); err = M4MP4W_putByte((M4OSA_UChar)(val >> 8), fileFunction, context); ERR_CHECK(err == M4NO_ERROR, err); err = M4MP4W_putByte((M4OSA_UChar)val, fileFunction, context); return err; }
static RET_CODE _ttx_ctrl_start(ttx_ctrl_t *p_ttx, teletext_descr_t *p_ttx_dr) { RET_CODE ret = ERR_FAILURE; do { /*! * First time use start decode interface, otherwise use reset pid interface */ if(FALSE == p_ttx->m_start) { if(p_ttx_dr != NULL) { OS_PRINTF("lubin: _ttx_ctrl_start PID %d\n", p_ttx_dr->pid); ret = mul_teletext_start_decode(p_ttx_dr->pid); } else { ret = mul_teletext_start_decode(0); OS_PRINTF("lubin: _ttx_ctrl_start 0 ret %d\n", ret); } ERR_CHECK(ret); p_ttx->m_start = TRUE; } return SUCCESS; }while(0); return ret; }
/*! ttx_ctrl_show \param[in] lang_idx: language index of teletext \return SUCCESS if no error */ RET_CODE ttx_ctrl_start(u8 *p_lang) { RET_CODE ret = ERR_FAILURE; teletext_descr_t *p_dr = NULL; subt_ttx_ctrl_priv_t *p_this = NULL; do { ERR_POINT(p_lang); p_this = get_priv(); ERR_POINT(p_this); memcpy(p_this->m_ttx_ctrl.m_ui_lang, p_lang, SUBT_TTX_CTRL_LANG_LEN); p_dr = _ttx_ctrl_match_dr(&p_this->m_ttx_ctrl, p_lang); // ERR_POINT(p_dr); OS_PRINTF("lubin: ttx_ctrl_start 863\n"); ret = _ttx_ctrl_start(&p_this->m_ttx_ctrl, p_dr); ERR_CHECK(ret); return ret; }while(0); return ERR_FAILURE; }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { LcaError theErr; lcaErrorInit(&theErr); LHSCHECK(nlhs, plhs); if ( 1 < nlhs ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Need one output arg"); goto cleanup; } if ( 0 != nrhs ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Expected no rhs argument"); goto cleanup; } ezcaDebugOn(); nlhs = 0; cleanup: ERR_CHECK(nlhs, plhs, &theErr); }
void MakeMenus(void) { Handle mbarHdl; MenuHandle menuHdl; OSErr err; if ( !(mbarHdl = GetNewMBar( rMBar)) ) { ErrorHandler(eMem, nil); return; } SetMenuBar(mbarHdl); if ( (menuHdl = GetMenuHandle(mApple)) != nil) { AppendResMenu(menuHdl, 'DRVR'); } else ErrorHandler(eMenuHdl, nil); ERR_CHECK(HMGetHelpMenuHandle(&menuHdl)); DisableItem(menuHdl, 1); DrawMenuBar(); }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { LcaError theErr; lcaErrorInit(&theErr); LHSCHECK(nlhs, plhs); if ( 1 < nlhs ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Need one output arg"); goto cleanup; } if ( 0 != nrhs ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Expected no rhs argument"); goto cleanup; } if ( ! (plhs[0] = mxCreateDoubleMatrix( 1, 1, mxREAL )) ) { lcaSetError(&theErr, EZCA_FAILEDMALLOC, "Not enough memory"); goto cleanup; } *mxGetPr(plhs[0]) = ezcaGetTimeout(); nlhs = 0; cleanup: ERR_CHECK(nlhs, plhs, &theErr); }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { PVs pvs = { {0} }; MultiArgRec args[]={ { sizeof(double), 0, (void**)0 }, { sizeof(double), 0, (void**)0 } }; void *pres[NumberOf(args)]; int i; LcaError theErr; lcaErrorInit(&theErr); LHSCHECK(nlhs, plhs); if ( NumberOf(args) < nlhs ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Too many output args"); goto cleanup; } if ( 1 != nrhs ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Expected one rhs argument"); goto cleanup; } for ( i=0; i<NumberOf(args); i++) { args[i].pres = &pres[i]; plhs[i]=0; } if ( buildPVs(prhs[0], &pvs, &theErr) ) goto cleanup; if ( !multi_ezca_get_misc(pvs.names, pvs.m, (MultiEzcaFunc)ezcaGetAlarmLimits, NumberOf(args), args, &theErr) ) goto cleanup; for ( i=0; i<nlhs; i++ ) { if ( !(plhs[i]=mxCreateDoubleMatrix(pvs.m, 1, mxREAL)) ) { lcaSetError(&theErr, EZCA_FAILEDMALLOC, "Not enough memory"); goto cleanup; } memcpy(mxGetPr(plhs[i]), *args[i].pres, pvs.m * args[i].size); } nlhs = 0; /* prevent array destruction if everything is OK */ cleanup: for ( i=0; i<nlhs; i++ ) { if ( plhs[i] ) { mxDestroyArray(plhs[i]); plhs[i] = 0; } } for ( i=0; i<NumberOf(args); i++ ) { if ( args[i].pres ) lcaFree(*args[i].pres); } releasePVs(&pvs); /* do this LAST (in case mexErrMsgTxt is called) */ ERR_CHECK(nlhs, plhs, &theErr); }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { PVs pvs = { {0} }; int i,j; LcaError theErr; MultiArgRec args[1]; units_string *strbuf MAY_ALIAS = 0; mxArray *tmp; lcaErrorInit(&theErr); LHSCHECK(nlhs, plhs); if ( nlhs > 1 ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Too many output args"); goto cleanup; } if ( nrhs < 1 || nrhs > 1 ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Expected 1 rhs argument"); goto cleanup; } if ( buildPVs(prhs[0], &pvs, &theErr) ) goto cleanup; MSetArg(args[0], sizeof(units_string), 0, &strbuf); if ( !multi_ezca_get_misc(pvs.names, pvs.m, (MultiEzcaFunc)ezcaGetUnits, NumberOf(args), args, &theErr) ) goto cleanup; /* convert string array to a matlab cell array of matlab strings */ if ( !(plhs[0] = mxCreateCellMatrix(pvs.m, 1)) ) { lcaSetError(&theErr, EZCA_FAILEDMALLOC, "Not enough memory"); goto cleanup; } for ( i = 0; i < pvs.m; i++ ) { if ( !(tmp = mxCreateString((char*)&strbuf[i])) ) { for ( j=0; j<i; j++ ) { mxDestroyArray(mxGetCell(plhs[0],i)); } mxDestroyArray(plhs[0]); plhs[0] = 0; lcaSetError(&theErr, EZCA_FAILEDMALLOC, "Not enough memory"); goto cleanup; } mxSetCell(plhs[0], i, (mxArray*)tmp); } nlhs = 0; cleanup: if ( strbuf ) lcaFree( strbuf ); releasePVs(&pvs); /* do this LAST (in case mexErrMsgTxt is called) */ ERR_CHECK(nlhs, plhs, &theErr); }
void advertising_start(void) { ble_gap_adv_params_t adv_params; memset(&adv_params, 0, sizeof(adv_params)); adv_params.type = BLE_GAP_ADV_TYPE_ADV_IND; adv_params.p_peer_addr = NULL; adv_params.fp = BLE_GAP_ADV_FP_ANY; adv_params.interval = APP_ADV_INTERVAL; adv_params.timeout = APP_ADV_TIMEOUT_IN_SECONDS; ERR_CHECK(sd_ble_gap_adv_start(&adv_params)); }
static RET_CODE _subt_ctrl_show_teletext(subt_ttx_ctrl_priv_t *p_this, teletext_descr_t *p_ttx_dr) { RET_CODE ret = ERR_FAILURE; do { subt_ctrl_hide(); OS_PRINTF("lubin: start ttx from subt\n"); ret = _ttx_ctrl_start(&p_this->m_ttx_ctrl, p_ttx_dr); ERR_CHECK(ret); ret = mul_teletext_display_teletext(NULL, TRUE, p_ttx_dr->magazien, p_ttx_dr->page); ERR_CHECK(ret); p_this->m_subt_ctrl.m_ttx_start = TRUE; return SUCCESS; }while(0); return ret; }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int i,n = 0; const mxArray *tmp; PVs pvs = { {0} }; char type = ezcaNative; LcaError theErr; lcaErrorInit(&theErr); LHSCHECK(nlhs, plhs); if ( nlhs > 1 ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Too many output args"); goto cleanup; } if ( nrhs < 1 || nrhs > 3 ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Expected 1..3 rhs argument"); goto cleanup; } /* check for an optional 'column dimension' argument */ if ( nrhs > 1 ) { if ( ! mxIsNumeric(tmp = prhs[1]) || 1 != mxGetM(tmp) || 1 != mxGetN(tmp) ) { lcaSetError(&theErr, EZCA_INVALIDARG, "2nd argument must be a numeric scalar"); goto cleanup; } n = (int)mxGetScalar( tmp ); } /* check for an optional data type argument */ if ( nrhs > 2 ) { if ( ezcaInvalid == (type = marg2ezcaType( prhs[2], &theErr )) ) { goto cleanup; } } if ( buildPVs(prhs[0], &pvs, &theErr) ) goto cleanup; if ( 0 == multi_ezca_set_mon( pvs.names, pvs.m, type, n, &theErr ) ) { nlhs = 0; } cleanup: releasePVs(&pvs); /* do this LAST (in case mexErrMsgTxt is called) */ ERR_CHECK(nlhs, plhs, &theErr); }
/// --------------------------------------------------------------------------- /// Draws this glyph /// --------------------------------------------------------------------------- void prFontGlyph::Draw() { // Move to offset glTranslatef(mOffset.x, mOffset.y, 0); // Bind texture for character glBindTexture(GL_TEXTURE_2D, mTextureID); ERR_CHECK(); // Draw glVertexPointer(2, GL_FLOAT, sizeof(QuadData), &quadData->x); ERR_CHECK(); glTexCoordPointer(2, GL_FLOAT, sizeof(QuadData), &quadData->u); ERR_CHECK(); glDrawArrays(GL_TRIANGLE_STRIP, 0, 6); ERR_CHECK(); // Undo offset glTranslatef(-mOffset.x, -mOffset.y, 0); // Advance glTranslatef(mAdvance.x, mAdvance.y, 0); }
bool check(BS_test_t *t) { float EPSILON = 2.0f; cl_int errcode_ret; BS_gold(t); cl_float * CallResult = (cl_float *) malloc (t->num * sizeof(cl_float)); cl_float * PutResult = (cl_float *) malloc (t->num * sizeof(cl_float)); errcode_ret = clEnqueueReadBuffer(t->hCmdQueue, t->d_CallResult, CL_TRUE, 0, t->num * sizeof(cl_float), CallResult, 0, NULL, NULL); ERR_CHECK(errcode_ret, "clEnqueueReadBuffer"); errcode_ret = clEnqueueReadBuffer(t->hCmdQueue, t->d_PutResult, CL_TRUE, 0, t->num * sizeof(cl_float), PutResult, 0, NULL, NULL); ERR_CHECK(errcode_ret, "clEnqueueReadBuffer"); //print_arr(t, CallResult); //print_arr(t, PutResult); for (unsigned int i = 0; i < t->num; i++) { cl_float hstCall = t->h_CallResult[i]; cl_float hstPut = t->h_PutResult[i]; cl_float devCall = CallResult[i]; cl_float devPut = PutResult[i]; if (abs(hstCall - devCall) >= EPSILON || abs(hstPut - devPut) >= EPSILON ) { fprintf(stderr, "check failed at %d: [%f, %f] != [%f, %f]\n", i, hstCall, hstPut, devCall, devPut); free(CallResult); free(PutResult); return false; } } free(CallResult); free(PutResult); return true; }
int main(void) { trx_regval_t rval; /* This will stop the application before initializing the radio transceiver * (ISP issue with MISO pin, see FAQ) */ trap_if_key_pressed(); /* Step 0: init MCU peripherals */ LED_INIT(); trx_io_init(SPI_RATE_1_2); LED_SET_VALUE(LED_MAX_VALUE); LED_SET_VALUE(0); /* Step 1: initialize the transceiver */ TRX_RESET_LOW(); TRX_SLPTR_LOW(); DELAY_US(TRX_RESET_TIME_US); TRX_RESET_HIGH(); trx_reg_write(RG_TRX_STATE,CMD_TRX_OFF); DELAY_US(TRX_INIT_TIME_US); rval = trx_bit_read(SR_TRX_STATUS); ERR_CHECK(TRX_OFF!=rval); LED_SET_VALUE(1); /* Step 2: setup transmitter * - configure radio channel * - go into RX state, * - enable "receive end" IRQ */ trx_bit_write(SR_CHANNEL,CHANNEL); trx_reg_write(RG_TRX_STATE,CMD_RX_ON); #if defined(TRX_IRQ_TRX_END) trx_reg_write(RG_IRQ_MASK,TRX_IRQ_TRX_END); #elif defined(TRX_IRQ_RX_END) trx_reg_write(RG_IRQ_MASK,TRX_IRQ_RX_END); #else # error "Unknown IRQ bits" #endif sei(); LED_SET_VALUE(2); /* Step 3: Going to receive frames */ rxcnt = 0; LED_SET_VALUE(0); while(1); }
void cleanup(BS_test_t * t) { cl_int errcode_ret; printf("Freeing Host and Device buffers...\n"); free(t->h_CallResult); free(t->h_PutResult); free(t->h_StockPrice); free(t->h_OptionStrike); free(t->h_OptionYears); clFinish(t->hCmdQueue); errcode_ret = clReleaseMemObject(t->d_CallResult); ERR_CHECK(errcode_ret, "clReleaseMemObject d_CallResult"); errcode_ret = clReleaseMemObject(t->d_PutResult); ERR_CHECK(errcode_ret, "clReleaseMemObject d_PutResult"); errcode_ret = clReleaseMemObject(t->d_StockPrice); ERR_CHECK(errcode_ret, "clReleaseMemObject d_StockPrice"); errcode_ret = clReleaseMemObject(t->d_OptionStrike); ERR_CHECK(errcode_ret, "clReleaseMemObject d_OptionStrike"); errcode_ret = clReleaseMemObject(t->d_OptionYears); ERR_CHECK(errcode_ret, "clReleaseMemObject d_OptionYears"); clFlush(t->hCmdQueue); }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int i; int *src; int *dst; LcaError *ptheErr = lcaGetLastError(); LcaError theErr; lcaErrorInit(&theErr); LHSCHECK(nlhs, plhs); if ( nlhs > 1 ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Too many output args"); goto cleanup; } if ( nrhs ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Expected no rhs argument"); goto cleanup; } if ( (i=ptheErr->nerrs) ) { src = ptheErr->errs; } else { i = 1; src = &ptheErr->err; } if ( ! (plhs[0] = mxCreateNumericMatrix( i, 1, mxINT32_CLASS, mxREAL )) ) { lcaSetError(&theErr, EZCA_FAILEDMALLOC, "Not enough memory"); goto cleanup; } dst = (int*)mxGetData(plhs[0]); while ( i-- ) { *dst++ = *src++; } nlhs = 0; cleanup: /* do this LAST (in case mexErrMsgTxt is called) */ ERR_CHECK(nlhs, plhs, &theErr); }
void setup_buffers(BS_test_t * t, cl_float(*gen)(cl_float low, cl_float high)) { // malloc host memory t->h_CallResult = (cl_float *) malloc (t->num * sizeof(cl_float)); t->h_PutResult = (cl_float *) malloc (t->num * sizeof(cl_float)); t->h_StockPrice = (cl_float *) malloc (t->num * sizeof(cl_float)); t->h_OptionStrike = (cl_float *) malloc (t->num * sizeof(cl_float)); t->h_OptionYears = (cl_float *) malloc (t->num * sizeof(cl_float)); cl_int errcode_ret; // malloc device memory t->d_CallResult = clCreateBuffer(t->hContext, CL_MEM_WRITE_ONLY, t->num * sizeof(cl_float), NULL, &errcode_ret); ERR_CHECK(errcode_ret, "clCreateBuffer"); t->d_PutResult = clCreateBuffer(t->hContext, CL_MEM_WRITE_ONLY, t->num * sizeof(cl_float), NULL, &errcode_ret); ERR_CHECK(errcode_ret, "clCreateBuffer"); t->d_StockPrice = clCreateBuffer(t->hContext, CL_MEM_READ_ONLY, t->num * sizeof(cl_float), NULL, &errcode_ret); ERR_CHECK(errcode_ret, "clCreateBuffer"); t->d_OptionStrike = clCreateBuffer(t->hContext, CL_MEM_READ_ONLY, t->num * sizeof(cl_float), NULL, &errcode_ret); ERR_CHECK(errcode_ret, "clCreateBuffer"); t->d_OptionYears = clCreateBuffer(t->hContext, CL_MEM_READ_ONLY, t->num * sizeof(cl_float), NULL, &errcode_ret); ERR_CHECK(errcode_ret, "clCreateBuffer"); // init host memory for (unsigned int i = 0; i < t->num; i++) { t->h_CallResult[i] = -1.0f; t->h_PutResult[i] = -1.0f; t->h_StockPrice[i] = gen(5.0f, 30.0f); t->h_OptionStrike[i] = gen(1.0f, 100.0f); t->h_OptionYears[i] = gen(0.25f, 10.0f); } // copy to device memory printf("Copying input matrices to GPU...\n"); errcode_ret = clEnqueueWriteBuffer(t->hCmdQueue, t->d_StockPrice, CL_TRUE, 0, t->num * sizeof(cl_float), t->h_StockPrice, 0, NULL, NULL); ERR_CHECK(errcode_ret, "clEnqueueWriteBuffer"); errcode_ret = clEnqueueWriteBuffer(t->hCmdQueue, t->d_OptionStrike, CL_TRUE, 0, t->num * sizeof(cl_float), t->h_OptionStrike, 0, NULL, NULL); ERR_CHECK(errcode_ret, "clEnqueueWriteBuffer"); errcode_ret = clEnqueueWriteBuffer(t->hCmdQueue, t->d_OptionYears, CL_TRUE, 0, t->num * sizeof(cl_float), t->h_OptionYears, 0, NULL, NULL); ERR_CHECK(errcode_ret, "clEnqueueWriteBuffer"); }
RET_CODE ttx_ctrl_show(void) { RET_CODE ret = ERR_FAILURE; subt_ttx_ctrl_priv_t *p_this = NULL; do { p_this = get_priv(); ERR_POINT(p_this); if(p_this->m_ttx_ctrl.m_start != TRUE) { return ERR_FAILURE; } ret = mul_teletext_display_teletext(NULL, FALSE, 1, 0); ERR_CHECK(ret); return ret; }while(0); return ERR_FAILURE; }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { LcaError theErr; float timeout; lcaErrorInit(&theErr); LHSCHECK(nlhs, plhs); if ( 1 < nlhs ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Need one output arg"); goto cleanup; } if ( 1 != nrhs ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Expected one rhs argument"); goto cleanup; } if ( !mxIsDouble(prhs[0]) || 1 != mxGetM(prhs[0]) || 1 != mxGetN(prhs[0]) ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Need a single numeric argument"); goto cleanup; } timeout = mxGetScalar(prhs[0]); if ( timeout < 0.001 ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Timeout arg must be >= 0.001"); goto cleanup; } ezcaSetTimeout(timeout); nlhs = 0; cleanup: ERR_CHECK(nlhs, plhs, &theErr); }
static RET_CODE _subt_ctrl_show_subtitle(subt_ctrl_t *p_subt, subtitle_descr_t *p_subt_dr) { RET_CODE ret = ERR_FAILURE; do { /*! * Hide subtitle, maybe teletext subtitle show last time, subtitle show this time */ subt_ctrl_hide(); ret = mul_subtitle_start_decode(p_subt_dr->pid, p_subt_dr->cmps_page_id, p_subt_dr->ancl_page_id); ERR_CHECK(ret); p_subt->m_subt_start = TRUE; return SUCCESS; }while(0); return ret; }
M4OSA_ERR M4MP4W_freeContext(M4OSA_Context context) /*******************************************************************************/ { #ifdef _M4MP4W_MOOV_FIRST M4OSA_UInt32 i; #endif /*_M4MP4W_MOOV_FIRST*/ M4MP4W_Mp4FileData* mMp4FileDataPtr = (M4MP4W_Mp4FileData*)context; ERR_CHECK(context != M4OSA_NULL, M4ERR_PARAMETER); /*freeContext is now called after closeWrite*/ ERR_CHECK( mMp4FileDataPtr->state == M4MP4W_closed, M4ERR_STATE); mMp4FileDataPtr->state = M4MP4W_closed; if (mMp4FileDataPtr->audioTrackPtr != M4OSA_NULL) { /*delete also other chunks if any*/ /*for (i=0; i<=mMp4FileDataPtr->audioTrackPtr->currentChunk; i++)*/ #ifdef _M4MP4W_MOOV_FIRST for (i=0; i<=mMp4FileDataPtr->audioTrackPtr->LastAllocatedChunk; i++) { free(mMp4FileDataPtr->audioTrackPtr->Chunk[i]); } #else if ((M4OSA_NULL != mMp4FileDataPtr->audioTrackPtr->Chunk) && (M4OSA_NULL != mMp4FileDataPtr->audioTrackPtr->Chunk[0])) { free(mMp4FileDataPtr->audioTrackPtr->Chunk[0]); } if (M4OSA_NULL != mMp4FileDataPtr->audioTrackPtr->chunkOffsetTable) { free(mMp4FileDataPtr->audioTrackPtr->chunkOffsetTable); } #endif /*_M4MP4W_MOOV_FIRST*/ /*now dynamic*/ if (M4OSA_NULL != mMp4FileDataPtr->audioTrackPtr->Chunk) { free(mMp4FileDataPtr->audioTrackPtr->Chunk); } if (M4OSA_NULL != mMp4FileDataPtr->audioTrackPtr->chunkSizeTable) { free(mMp4FileDataPtr->audioTrackPtr->chunkSizeTable); } if (M4OSA_NULL != mMp4FileDataPtr->audioTrackPtr->chunkSampleNbTable) { free(mMp4FileDataPtr->audioTrackPtr->chunkSampleNbTable); } if (M4OSA_NULL != mMp4FileDataPtr->audioTrackPtr->chunkTimeMsTable) { free(mMp4FileDataPtr->audioTrackPtr->chunkTimeMsTable); } if (mMp4FileDataPtr->audioTrackPtr->TABLE_STTS != M4OSA_NULL) { free(mMp4FileDataPtr->audioTrackPtr->TABLE_STTS); } if (mMp4FileDataPtr->audioTrackPtr->TABLE_STSZ != M4OSA_NULL) { free(mMp4FileDataPtr->audioTrackPtr->TABLE_STSZ); } if (mMp4FileDataPtr->audioTrackPtr->DSI != M4OSA_NULL) { free(mMp4FileDataPtr->audioTrackPtr->DSI); mMp4FileDataPtr->audioTrackPtr->DSI = M4OSA_NULL; } free(mMp4FileDataPtr->audioTrackPtr); mMp4FileDataPtr->audioTrackPtr = M4OSA_NULL; } if (mMp4FileDataPtr->videoTrackPtr != M4OSA_NULL) { /*delete also other chunks if any*/ /*for (i=0; i<=mMp4FileDataPtr->videoTrackPtr->currentChunk; i++)*/ #ifdef _M4MP4W_MOOV_FIRST for (i=0; i<=mMp4FileDataPtr->videoTrackPtr->LastAllocatedChunk; i++) { free(mMp4FileDataPtr->videoTrackPtr->Chunk[i]); } #else if ((M4OSA_NULL != mMp4FileDataPtr->videoTrackPtr->Chunk) && (M4OSA_NULL != mMp4FileDataPtr->videoTrackPtr->Chunk[0])) { free(mMp4FileDataPtr->videoTrackPtr->Chunk[0]); } if (M4OSA_NULL != mMp4FileDataPtr->videoTrackPtr->chunkOffsetTable) { free(mMp4FileDataPtr->videoTrackPtr->chunkOffsetTable); } #endif /*_M4MP4W_MOOV_FIRST*/ /*now dynamic*/ if (M4OSA_NULL != mMp4FileDataPtr->videoTrackPtr->Chunk) { free(mMp4FileDataPtr->videoTrackPtr->Chunk); } if (M4OSA_NULL != mMp4FileDataPtr->videoTrackPtr->chunkSizeTable) { free(mMp4FileDataPtr->videoTrackPtr->chunkSizeTable); } if (M4OSA_NULL != mMp4FileDataPtr->videoTrackPtr->chunkSampleNbTable) { free(mMp4FileDataPtr->videoTrackPtr->chunkSampleNbTable); } if (M4OSA_NULL != mMp4FileDataPtr->videoTrackPtr->chunkTimeMsTable) { free(mMp4FileDataPtr->videoTrackPtr->chunkTimeMsTable); } if (mMp4FileDataPtr->videoTrackPtr->DSI != M4OSA_NULL) { free(mMp4FileDataPtr->videoTrackPtr->DSI); mMp4FileDataPtr->videoTrackPtr->DSI = M4OSA_NULL; } /*now dynamic*/ if (M4OSA_NULL != mMp4FileDataPtr->videoTrackPtr->TABLE_STTS) { free(mMp4FileDataPtr->videoTrackPtr->TABLE_STTS); } if (M4OSA_NULL != mMp4FileDataPtr->videoTrackPtr->TABLE_STSZ) { free(mMp4FileDataPtr->videoTrackPtr->TABLE_STSZ); } if (M4OSA_NULL != mMp4FileDataPtr->videoTrackPtr->TABLE_STSS) { free(mMp4FileDataPtr->videoTrackPtr->TABLE_STSS); } free(mMp4FileDataPtr->videoTrackPtr); mMp4FileDataPtr->videoTrackPtr = M4OSA_NULL; } if (mMp4FileDataPtr->embeddedString != M4OSA_NULL) { free(mMp4FileDataPtr->embeddedString); mMp4FileDataPtr->embeddedString = M4OSA_NULL; } free(mMp4FileDataPtr); return M4NO_ERROR; }
void InitLicTxt(void) { Rect destRect, viewRect; FSSpec licFile; long dirID, dataSize; short vRefNum, dataRef, resRef; unsigned char* cLicFName; Str255 pLicFName; OSErr err; Handle text, stylHdl; ERR_CHECK(GetCWD(&dirID, &vRefNum)); /* open and read license file */ HLock(gControls->cfg->licFileName); if(**gControls->cfg->licFileName != nil) { cLicFName = CToPascal(*gControls->cfg->licFileName); ERR_CHECK(FSMakeFSSpec(vRefNum, dirID, cLicFName, &licFile)); if (cLicFName) DisposePtr((char*)cLicFName); } else /* assume default license filename from str rsrc */ { GetResourcedString(pLicFName, rInstList, sLicenseFName); ERR_CHECK(FSMakeFSSpec(vRefNum, dirID, pLicFName, &licFile)); } HUnlock(gControls->cfg->licFileName); /* read license text */ ERR_CHECK(FSpOpenDF( &licFile, fsRdPerm, &dataRef)); ERR_CHECK(GetEOF(dataRef, &dataSize)); if (dataSize > 0) { if (!(text = NewHandle(dataSize))) { ErrorHandler(eMem, nil); return; } ERR_CHECK(FSRead(dataRef, &dataSize, *text)); } else text = nil; ERR_CHECK(FSClose(dataRef)); /* get 'styl' if license is multistyled */ resRef = FSpOpenResFile( &licFile, fsRdPerm); ERR_CHECK(ResError()); UseResFile(resRef); stylHdl = RGetResource('styl', 128); ERR_CHECK(ResError()); if(stylHdl) DetachResource(stylHdl); else stylHdl = nil; CloseResFile(resRef); /* TE specific init */ HLock( (Handle) gControls->lw->licBox); SetRect(&viewRect, (*(gControls->lw->licBox))->contrlRect.left, (*(gControls->lw->licBox))->contrlRect.top, (*(gControls->lw->licBox))->contrlRect.right, (*(gControls->lw->licBox))->contrlRect.bottom); HUnlock( (Handle) gControls->lw->licBox); destRect.left = viewRect.left; viewRect.right = (*(gControls->lw->scrollBar))->contrlRect.left; destRect.right = viewRect.right; destRect.top = viewRect.top; destRect.bottom = viewRect.bottom * kNumLicScrns; // gControls->lw->licTxt = (TEHandle) NewPtrClear(sizeof(TEPtr)); TextFont(applFont); TextFace(normal); TextSize(9); HLock(text); if (stylHdl) { gControls->lw->licTxt = TEStyleNew( &destRect, &viewRect ); TEStyleInsert( *text, dataSize, (StScrpRec ** )stylHdl, gControls->lw->licTxt); } else { gControls->lw->licTxt = TENew( &destRect, &viewRect); TEInsert( *text, dataSize, gControls->lw->licTxt); } HUnlock(text); TextFont(systemFont); TextSize(12); TESetAlignment(teFlushDefault, gControls->lw->licTxt); }
void ChatServer::send_to_all(char *msg, int len) { for (auto client_fd = clients.begin(); client_fd != clients.end(); client_fd++) { ERR_CHECK(send(client_fd->first, msg, len, MSG_NOSIGNAL)); } }
int ChatServer::run(short port) { try { ERR_CHECK(listener_fd = socket(PF_INET, SOCK_STREAM, 0)); bzero(&my_addr, sizeof(struct sockaddr_in)); my_addr.sin_family = AF_INET; my_addr.sin_port = htons(port); my_addr.sin_addr.s_addr = htonl(INADDR_ANY); int yes = 1; ERR_CHECK(setsockopt(listener_fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int))); ERR_CHECK(bind(listener_fd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr))); ERR_CHECK(make_socket_non_blocking(listener_fd)); ERR_CHECK(listen(listener_fd, SOMAXCONN)); ERR_CHECK(epoll_fd = epoll_create1(0)); event.data.fd = listener_fd; event.events = EPOLLIN | EPOLLET; ERR_CHECK(epoll_ctl(epoll_fd, EPOLL_CTL_ADD, listener_fd, &event)); events = (epoll_event *)calloc(MAXEVENTS, sizeof(event)); while (1) { int n_events; n_events = epoll_wait(epoll_fd, events, MAXEVENTS, -1); for (int i = 0; i < n_events; i++) { if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP)) { //throw std::system_error(errno, std::system_category()); close_socket(events[i].data.fd); clients.erase(events[i].data.fd); } else if (listener_fd == events[i].data.fd) { while (1) { struct sockaddr new_addr; socklen_t in_len = sizeof(new_addr); int new_fd; if ((new_fd = accept(listener_fd, &new_addr, &in_len)) == -1) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) { // we have no new connections break; } else { throw std::system_error(errno, std::system_category()); } } printf("accepted connection\n"); ERR_CHECK(make_socket_non_blocking(new_fd)); // adding new desciptor to epoll event.data.fd = new_fd; event.events = EPOLLIN | EPOLLET; ERR_CHECK(epoll_ctl(epoll_fd, EPOLL_CTL_ADD, new_fd, &event)); clients.insert(std::pair<int, ClientBuffer>(new_fd, ClientBuffer())); ERR_CHECK(send(new_fd, "Welcome\n", 8, MSG_NOSIGNAL)); } } else { // we read from some socket //printf("reading from socket\n"); ssize_t n_read; bool close_conn = false; // reading one less, so that we while (1) { n_read = recv(events[i].data.fd, buf, BUF_SIZE, 0); if (n_read == -1) { if ((errno != EAGAIN) && (errno != EWOULDBLOCK)) { close_conn = true; } // or else everything is ok, we just read everything we could break; } else if (n_read == 0) { // connection is closed close_conn = true; break; } write(1, buf, n_read); process_input_buffer(events[i].data.fd, n_read); } if (close_conn) { clients.erase(events[i].data.fd); close_socket(events[i].data.fd); } } } } } catch (const std::system_error& e) { std::cout << "Caught system_error with code " << e.code() << " meaning " << e.what() << '\n'; if (events != nullptr) { free(events); } return -1; } if (events != nullptr) { free(events); } return 0; }
/// --------------------------------------------------------------------------- /// Draws this layer /// --------------------------------------------------------------------------- void prBackgroundLayer::Draw() { // TODO: Add screen offset for positioning if (mpTexture) { mpTexture->Bind(); s32 tile = 0; //f32 posX; glEnable(GL_BLEND); ERR_CHECK(); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); ERR_CHECK(); // glPushMatrix(); // ERR_CHECK(); //// translate to quad center, then translate for position //glTranslatef((GLfloat)(mTileWidth >> 1), (GLfloat)(mTileHeight >> 1), 0); //ERR_CHECK(); //glTranslatef(0, 28, 0); //ERR_CHECK(); //glScalef((GLfloat)mTileWidth, (GLfloat)mTileHeight, 0); //ERR_CHECK(); //glTranslatef(mTileWidth, 0, 0); for (s32 y=0; y<mLayerHeight; y++) { s32 row = y*mLayerWidth; for (s32 x=0; x<mLayerWidth; x++) { tile = mMapData[row + x]; if (tile == -1) continue; //// Set the frame source rect position indices //s32 x = frame % m_framesAcross; //s32 y = frame / m_framesAcross; // Set the tile image source rect s32 xpos = tile % mTilesAcross; s32 ypos = tile / mTilesAcross; f32 m_u0 = xpos * mTileWidthInPixels; f32 m_u1 = m_u0 + mTileWidthInPixels; f32 m_v0 = 1.0f - ((ypos * mTileHeightInPixels) + mTileHeightInPixels); f32 m_v1 = m_v0 + mTileHeightInPixels; prRenderer *pRenderer = static_cast<prRenderer *>(prCoreGetComponent(PRSYSTEM_RENDERER)); if (pRenderer) { glPushMatrix(); ERR_CHECK(); // translate to quad center, then translate for position glTranslatef((GLfloat)(mTileWidth >> 1), (GLfloat)(mTileHeight >> 1), 0); ERR_CHECK(); glTranslatef(0, 28, 0); ERR_CHECK(); glTranslatef((GLfloat)mTileWidth * x, (GLfloat)mTileHeight * y, 0.f); glScalef((GLfloat)mTileWidth, (GLfloat)mTileHeight, 0); pRenderer->DrawQuad(m_u0, m_v0, m_u1, m_v1, prColour::White);// m_colour); // prTrace(LogError, "Tile size %i, %i\n", mTileWidth , mTileHeight); // prTrace(LogError, "Tile %i, at (%i, %i)\n", tile, mTileWidth * x, mTileHeight * y); glPopMatrix(); ERR_CHECK(); } //#if defined(PLATFORM_PC) // m_v0 += (m_ph / 2); // Sub half pixel to stop blurring //#endif } } // glPopMatrix(); // ERR_CHECK(); glDisable(GL_BLEND); ERR_CHECK(); } }
int main(void) { trx_regval_t rval; /* This will stop the application before initializing the radio transceiver * (ISP issue with MISO pin, see FAQ) */ trap_if_key_pressed(); /* Step 0: init MCU peripherals */ LED_INIT(); trx_io_init(SPI_RATE_1_2); LED_SET_VALUE(LED_MAX_VALUE); LED_SET_VALUE(0); /* Step 1: initialize the transceiver */ TRX_RESET_LOW(); TRX_SLPTR_LOW(); DELAY_US(TRX_RESET_TIME_US); TRX_RESET_HIGH(); trx_reg_write(RG_TRX_STATE,CMD_TRX_OFF); DELAY_MS(TRX_INIT_TIME_US); rval = trx_bit_read(SR_TRX_STATUS); ERR_CHECK(TRX_OFF!=rval); LED_SET_VALUE(1); /* Step 2: setup transmitter * - configure radio channel * - enable transmitters automatic crc16 generation * - go into RX AACK state, * - configure address filter * - enable "receive end" IRQ */ trx_bit_write(SR_CHANNEL,CHANNEL); trx_bit_write(SR_TX_AUTO_CRC_ON,1); trx_reg_write(RG_PAN_ID_0,(PANID&0xff)); trx_reg_write(RG_PAN_ID_1,(PANID>>8)); trx_reg_write(RG_SHORT_ADDR_0,(SHORT_ADDR&0xff)); trx_reg_write(RG_SHORT_ADDR_1,(SHORT_ADDR>>8)); trx_reg_write(RG_TRX_STATE,CMD_RX_AACK_ON); #if defined(TRX_IRQ_TRX_END) trx_reg_write(RG_IRQ_MASK,TRX_IRQ_TRX_END); #elif defined(TRX_IRQ_RX_END) trx_reg_write(RG_IRQ_MASK,TRX_IRQ_RX_END); #else # error "Unknown IRQ bits" #endif sei(); LED_SET_VALUE(2); /* Step 3: send a frame each 500ms */ tx_cnt = 0; tx_in_progress = false; LED_SET_VALUE(0); while(1); }
void setup_cl(BS_test_t *t) { cl_int errcode_ret; // Get OpenCL platform count cl_uint NumPlatforms; clGetPlatformIDs (0, NULL, &NumPlatforms); // Get all OpenCL platform IDs cl_platform_id* PlatformIDs; PlatformIDs = new cl_platform_id[NumPlatforms]; clGetPlatformIDs (NumPlatforms, PlatformIDs, NULL); // find NVIDIA & AMD platforms char cBuffer[1024]; cl_int NvPlatform = -1; cl_int AMDPlatform = -1; for(cl_uint i = 0; i < NumPlatforms; ++i) { clGetPlatformInfo (PlatformIDs[i], CL_PLATFORM_NAME, 1024, cBuffer, NULL); printf("%s\n", cBuffer); if(strstr(cBuffer, "NVIDIA") != NULL) { NvPlatform = i; } else if (strstr(cBuffer, "AMD") != NULL) { AMDPlatform = i; } } // check for AMD and NVIDIA GPU devices cl_device_id cdDevice; cl_uint NvNumDevices = 0; cl_uint AMDNumDevices = 0; if (AMDPlatform != -1) clGetDeviceIDs(PlatformIDs[AMDPlatform], CL_DEVICE_TYPE_GPU, 0, NULL, &AMDNumDevices); if (NvPlatform != -1) clGetDeviceIDs(PlatformIDs[NvPlatform], CL_DEVICE_TYPE_GPU, 0, NULL, &NvNumDevices); // if there is an AMD GPU, take it, or take an NVIDIA GPU if it is there if (AMDNumDevices > 0) clGetDeviceIDs(PlatformIDs[AMDPlatform], CL_DEVICE_TYPE_GPU, 1, &cdDevice, NULL); else if (NvNumDevices > 0) clGetDeviceIDs(PlatformIDs[NvPlatform], CL_DEVICE_TYPE_GPU, 1, &cdDevice, NULL); else { fprintf(stderr, "could not find any GPU devices, exiting\n"); delete [] PlatformIDs; exit(-1); } delete [] PlatformIDs; // get max work group size, just in case clGetDeviceInfo(cdDevice, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(size_t), &(t->maxBlockSize), NULL); //Create a context printf("Creating context for %s GPU...\n", (AMDNumDevices > 0) ? "AMD" : "NVIDIA"); t->hContext = clCreateContext(NULL, 1, &cdDevice, NULL, NULL, &errcode_ret); ERR_CHECK(errcode_ret, "clCreateContext"); size_t nContextDescriptorSize; clGetContextInfo(t->hContext, CL_CONTEXT_DEVICES, 0, 0, &nContextDescriptorSize); cl_device_id * aDevices = (cl_device_id *) malloc(nContextDescriptorSize); clGetContextInfo(t->hContext, CL_CONTEXT_DEVICES, nContextDescriptorSize, aDevices, 0); // create a command queue for first // device the context reported t->hCmdQueue = clCreateCommandQueue(t->hContext, aDevices[0], CL_QUEUE_PROFILING_ENABLE, &errcode_ret); ERR_CHECK(errcode_ret, "clCreateCommandQueue"); free(aDevices); // create & compile Black-Scholes program cl_program hBSProg; char * BSCode; size_t BSLen; printf("Compiling Black-Scholes program...\n"); BSCode = oclLoadProgSource("bs_kernel.cl", "", &BSLen); hBSProg = clCreateProgramWithSource(t->hContext,1, (const char **)&BSCode, &BSLen, &errcode_ret); ERR_CHECK(errcode_ret, "clCreateProgramWithSource BS"); errcode_ret = clBuildProgram(hBSProg, 0, NULL, NULL, NULL, NULL); ERR_CHECK(errcode_ret, "clBuildProgram BS"); free(BSCode); #ifdef PTX_OUTPUT size_t progSize; errcode_ret = clGetProgramInfo(hBSProg, CL_PROGRAM_BINARY_SIZES, sizeof(size_t), &progSize, NULL); ERR_CHECK(errcode_ret, "clGetProgramInfo"); char ** prog = (char **) malloc (sizeof(char **)); prog[0] = (char *) malloc(progSize * sizeof(char *)); errcode_ret = clGetProgramInfo(hBSProg, CL_PROGRAM_BINARIES, sizeof(char **) * progSize, prog, NULL); ERR_CHECK(errcode_ret, "clGetProgramInfo"); FILE * f = fopen("bs_cl.ptx", "w"); fprintf(f, "%s\n", prog[0]); fclose(f); #endif // create BS kernel printf("Creating Black-Scholes kernel...\n"); t->hBSKernel = clCreateKernel(hBSProg, "BlackScholes", &errcode_ret); ERR_CHECK(errcode_ret, "clCreateKernel BlackScholes"); }
void ShowTerminalWin(void) { Str255 next, back; Handle rectH; Rect viewRect; short reserr; MenuHandle popupMenu; PopupPrivateData ** pvtDataHdl; unsigned char * currMenuItem; short i, vRefNum; long cwdDirID, dirID; Boolean isDir = false; Str255 pModulesDir; OSErr err = noErr; GrafPtr oldPort; GetPort(&oldPort); if (gWPtr != NULL) { SetPort(gWPtr); gCurrWin = kTerminalID; /* gControls->tw = (TermWin*) NewPtrClear(sizeof(TermWin)); */ GetResourcedString(next, rInstList, sInstallBtn); GetResourcedString(back, rInstList, sBackBtn); // malloc and get control rectH = Get1Resource('RECT', rStartMsgBox); reserr = ResError(); if (reserr == noErr && rectH != NULL) { viewRect = (Rect) **((Rect **)rectH); ReleaseResource(rectH); } else { ErrorHandler(reserr, nil); return; } gControls->tw->siteSelector = NULL; gControls->tw->saveBitsCheckbox = NULL; gControls->tw->startMsgBox = viewRect; gControls->tw->startMsg = TENew(&viewRect, &viewRect); if (gControls->tw->startMsg == NULL) { ErrorHandler(eMem, nil); return; } // save bits after download and install /* get the "Installer Modules" relative subdir */ ERR_CHECK(GetCWD(&cwdDirID, &vRefNum)); GetIndString(pModulesDir, rStringList, sInstModules); GetDirectoryID(vRefNum, cwdDirID, pModulesDir, &dirID, &isDir); if (isDir) { if (!ExistArchives(vRefNum, dirID)) // going to download { if (gControls->cfg->numSites > 0) { // download settings groupbox Str255 dlSettingsGBTitle; gControls->tw->dlSettingsGB = GetNewControl(rDLSettingsGB, gWPtr); if (gControls->tw->dlSettingsGB) { GetResourcedString(dlSettingsGBTitle, rInstList, sDLSettings); SetControlTitle(gControls->tw->dlSettingsGB, dlSettingsGBTitle); ShowControl(gControls->tw->dlSettingsGB); } // site selector label Str255 siteSelMsgStr; gControls->tw->siteSelMsg = GetNewControl(rSiteSelMsg, gWPtr); if (gControls->tw->siteSelMsg) { GetResourcedString(siteSelMsgStr, rInstList, sSiteSelMsg); SetControlData(gControls->tw->siteSelMsg, kControlNoPart, kControlStaticTextTextTag, siteSelMsgStr[0], (Ptr)&siteSelMsgStr[1]); ShowControl(gControls->tw->siteSelMsg); } // site selector gControls->tw->siteSelector = GetNewControl( rSiteSelector, gWPtr ); if (!gControls->tw->siteSelector) { ErrorHandler(eMem, nil); return; } // populate popup button menus HLock((Handle)gControls->tw->siteSelector); pvtDataHdl = (PopupPrivateData **) (*(gControls->tw->siteSelector))->contrlData; HLock((Handle)pvtDataHdl); popupMenu = (MenuHandle) (**pvtDataHdl).mHandle; for (i=0; i<gControls->cfg->numSites; i++) { HLock(gControls->cfg->site[i].desc); currMenuItem = CToPascal(*gControls->cfg->site[i].desc); HUnlock(gControls->cfg->site[i].desc); InsertMenuItem( popupMenu, currMenuItem, i ); } HUnlock((Handle)pvtDataHdl); HUnlock((Handle)gControls->tw->siteSelector); SetControlMaximum(gControls->tw->siteSelector, gControls->cfg->numSites); SetControlValue(gControls->tw->siteSelector, gControls->opt->siteChoice); ShowControl(gControls->tw->siteSelector); } // show check box and message gControls->tw->saveBitsCheckbox = GetNewControl( rSaveCheckbox, gWPtr ); if (!gControls->tw->saveBitsCheckbox) { ErrorHandler(eMem, nil); return; } if (gControls->opt->saveBits) SetControlValue(gControls->tw->saveBitsCheckbox, 1); ShowControl(gControls->tw->saveBitsCheckbox); // get rect for save bits message rectH = Get1Resource('RECT', rSaveBitsMsgBox); reserr = ResError(); if (reserr == noErr && rectH != NULL) { gControls->tw->saveBitsMsgBox = (Rect) **((Rect **)rectH); DisposeHandle(rectH); } else { ErrorHandler(reserr, nil); return; } // get text edit record for save bits message gControls->tw->saveBitsMsg = TENew(&gControls->tw->saveBitsMsgBox, &gControls->tw->saveBitsMsgBox ); if (gControls->tw->saveBitsMsg == NULL) { ErrorHandler(eMem, nil); return; } HLock(gControls->cfg->saveBitsMsg); TESetText(*gControls->cfg->saveBitsMsg, strlen(*gControls->cfg->saveBitsMsg), gControls->tw->saveBitsMsg); HUnlock(gControls->cfg->saveBitsMsg); // show save bits msg TEUpdate(&gControls->tw->saveBitsMsgBox, gControls->tw->saveBitsMsg); // proxy settings button gControls->tw->proxySettingsBtn = GetNewControl(rProxySettgBtn, gWPtr); if (!gControls->tw->proxySettingsBtn) { ErrorHandler(eMem, nil); return; } Str255 proxySettingsTitle; GetResourcedString(proxySettingsTitle, rInstList, sProxySettings); SetControlTitle(gControls->tw->proxySettingsBtn, proxySettingsTitle); ShowControl(gControls->tw->proxySettingsBtn); } } // populate control HLock(gControls->cfg->startMsg); TESetText(*gControls->cfg->startMsg, strlen(*gControls->cfg->startMsg), gControls->tw->startMsg); HUnlock(gControls->cfg->startMsg); // show controls TEUpdate(&viewRect, gControls->tw->startMsg); ShowNavButtons( back, next ); } SetPort(oldPort); }