iBOOL MyWater_Init( void ) { /// init space. mwInitSpace(CurrLevelNum); iU32 * LcdInfoArr; LcdInfoArr = i51AdeMmiGetPanel(); if( iNULL == LcdInfoArr ) { return iFALSE; } mwScreenBuffer = (iU16 *) LcdInfoArr[1] ; CurrLevelNum = MW_LEVEL_CHOOSE; if( i51AdeOsFileIsExist((iU16 *)(MW_CONTAIN_PATH)) ) { if(iFALSE==i51KitG2CheckImageContainer((iU16 *)MW_CONTAIN_PATH)) { iLog("容器文件损坏"); return iFALSE; } mwContainer = i51KitG2OpenImageContainer((iU16 *)MW_CONTAIN_PATH); if(iFALSE==i51AdeOsFileIsExist((iU16 *)MW_DATA_PATH)) { iLog("数据文件不存在"); return iFALSE; } iFILE File = i51AdeOsFileOpen((iU16 *)MW_DATA_PATH, i51_OS_FL_READ|i51_OS_FL_ALWAYS_OPEN, __FILE__ , __LINE__ ); i51AdeOsFileSetSeek(File, 10, i51_OS_FL_SEEK_HEAD); i51AdeOsFileReadInt32(File, &CurrTotalDuck ); i51AdeOsFileReadInt32(File, &UnlockMaxLevel ); iU32 Read; i51AdeOsFileRead(File, LevelDuckNum, TOTAL_LEVEL, &Read); i51AdeOsFileClose(File); CurrGameState= GAME_STATE_MAIN; } else { iLog("容器文件不存在"); return iFALSE; } return iTRUE; }
int forkSUDO(int ac,const char *av[],Connection *Conn,int csock){ CStr(title,128); CStr(buf,1024); sprintf(title,"SUDO-%d",getppid()); ProcTitle(Conn,"%s",title); if( PollIn(csock,30*1000) == 0 ){ sv0log("--SU timeout to start\n"); return -1; } if( read(csock,portSUDO,sizeof(portSUDO)) < sizeof(portSUDO) ){ sv0log("--SU EOF on start\n"); return -1; } sprintf(title,"SUDO-%s",portSUDO); ProcTitle(Conn,"%s",title); passSUDO = getRand64(); IGNRETP write(csock,&passSUDO,sizeof(passSUDO)); iLog("--- being SUDO server"); isPrivateSUDO = csock; return 0; }
int i51KitAmrPcmStream2AmrStream ( void* pcm_stream , iU32 stream_length , void* amr_buffer , iU32 buff_length ) { // author : jelo // since : 2012.3.21 // (C) 2011 , PKIG Tech. Co., Ltd. if ( 0 == pcm_stream || 0 == stream_length || 0 == amr_buffer || 0 == buff_length ) { iLog ( "AMR-Enc : Buffer is Empty" ) ; return 0 ; } Encoder_Interface_init () ; enstate = Encoder_Interface_init(dtx); while (fread( speech, sizeof (Word16), 160, file_speech ) > 0) { /* read mode */ if (file_mode != NULL){ req_mode = 8; if (fscanf(file_mode, "%9s\n", mode_string) != EOF) { mode_tmp = strtol(&mode_string[2], NULL, 0); for (req_mode = 0; req_mode < 8; req_mode++){ if (mode_tmp == modeConv[req_mode]){ break; } } } if (req_mode == 8){ break; } } frames ++; /* call encoder */ byte_counter = Encoder_Interface_Encode(enstate, req_mode, speech, serial_data, 0); bytes += byte_counter; fwrite(serial_data, sizeof (UWord8), byte_counter, file_encoded ); fflush(file_encoded); } Encoder_Interface_exit(enstate); }
//---------------------------------------------------------------------------- // CIrDAObexSearcher::CreateObexClientL() //---------------------------------------------------------------------------- // CObexClient* CIrDAObexSearcher::CreateObexClientL() { //DBG_FILE( "CIrDAObexSearcher::CreateObexClientL()" ); TObexIrProtocolInfo pInfo; pInfo.iTransport.Copy( KIrTransportName ); if( iRetryConn ) { // ISA device pInfo.iClassName.Copy( _L("OBEX") ); } else { pInfo.iClassName.Copy( KClassName ); iRetryConn = ETrue; } pInfo.iAttributeName.Copy( _L8("IrDA:TinyTP:LsapSel") ); pInfo.iAddr = iLog().iAddr; CObexClient* client = CObexClient::NewL( pInfo ); return client; }
iBOOL mwLevelChooseInitDraw( void ) { iRECT DesRect; iU32 ICON_NUM_ID[4] = {ChsLv0,ChsLv1,ChsLv2,ChsLv3}; iU8 CurrDuckNum = 0; iS16 Bath_X = 0; iS16 Bath_Y = 360; iS16 Bath_W = SCREEN_WIDTH; iS16 Bath_H = 120; iS16 Word_X = 75; iS16 Word_Y = 268; iS16 Word_W = 171; iS16 Word_H = 24; iS16 Block_W = 81; iS16 Block_H = 81; iS16 Block_StartX = 0; iS16 Block_StartY = 160; int X,Y,i; #if SOUND_NEED if(iFALSE==MusicCloseFlag && SoundChoosePlay == iFALSE) { SoundChoosePlay = iTRUE; pfunc->public_audio_play( 0, MW_SOUND_NAME_CHOOSE, i51AdeStdWStrlen((iU16*)MW_SOUND_NAME_CHOOSE), i51_MMI_DEC_FILE_BASED, AUDIO_PLAYER_WAV_0, iTRUE ); } #endif //iLog("start choose!"); if(UnlockMaxLevel>TOTAL_LEVEL) { iLog("MaxLevel:%d>TOTAL_LEVEL:%d",UnlockMaxLevel,TOTAL_LEVEL); return iFALSE; } i51KitG2DrawImage(mwContainer, ChooseBKHead, iNULL, iNULL); for( Y = Block_StartY; Y<=SCREEN_HEIGHT; Y+=Block_H ) { for( X = Block_StartX; X<=SCREEN_WIDTH; X+=Block_W ) { DesRect.X = X; DesRect.Y = Y; DesRect.Width= Block_W; DesRect.Height= Block_H; i51KitG2DrawImage(mwContainer, ChooseBKBlock, &DesRect, iNULL); } } DesRect.X = Bath_X; DesRect.Y = Bath_Y; DesRect.Width= Bath_W; DesRect.Height= Bath_H; i51KitG2DrawImage(mwContainer, ChsLvBath, &DesRect, iNULL); DesRect.X = Word_X; DesRect.Y = Word_Y; DesRect.Width= Word_W; DesRect.Height= Word_H; i51KitG2DrawImage(mwContainer, XiaoWanPiWord, &DesRect, iNULL); mwLevelDrawReturn(); DesRect.Width = ICON_WIDTH; DesRect.Height= ICON_HEIGHT; for( i = 0; i< TOTAL_LEVEL; i++ ) { CurrDuckNum = LevelDuckNum[i]; if(CurrDuckNum>MAXDUCK_ONELEVEL) { // iLog("Get level:%dduck numer error:%d",i,CurrDuckNum); continue; } DesRect.X = LEVEL_START_LEVEL1_X + (i%ICON_NUM_ONELINE)*LEVEL_START_LEVEL_ADDX; DesRect.Y = LEVEL_START_LEVEL1_Y + (i/ICON_NUM_ONELINE)*LEVEL_START_LEVEL_ADDY; if(i<UnlockMaxLevel) { i51KitG2DrawImage(mwContainer, ICON_NUM_ID[CurrDuckNum], &DesRect, iNULL); if( i<9 ) { DesRect.X += 14; } else { DesRect.X += 7; } DesRect.Y += 7; mwLevelDrawNum(i+1,NumBig,&DesRect) ; } else { i51KitG2DrawImage(mwContainer, ChsLvLock, &DesRect, iNULL); // mwLevelDrawNum(i,NumBig,&DesRect) ; } } DesRect.X = LEVEL_START_DUCK_NUM_X; DesRect.Y = LEVEL_START_DUCK_NUM_Y; DesRect.Width = 121; DesRect.Height = 37; mwDrawNumStep(mwContainer, NumBig, &DesRect, CurrTotalDuck, TOTAL_DUCK_NUM); // iU32 ImageId[2] = {ChsLvBK}; // i51KitG2SetImageMemoryCopy(mwContainer, 1, ImageId); //iLog("end choose!"); return iTRUE; }
iBOOL mwLevelChooseInitDraw( void ) { iRECT DesRect; iRECT SrcRect; iU8 CurrDuckNum = 0; //iU32 ICON_NUM_ID[4] = {ChsLv0,ChsLv1,ChsLv2,ChsLv3}; #ifdef PKIG_SCREEN_240X320 iS16 Bath_X = 0; iS16 Bath_Y = 231; iS16 Bath_W = SCREEN_WIDTH; iS16 Bath_H = 90; iS16 Word_X = 56; iS16 Word_Y = 192; iS16 Word_W = 171; iS16 Word_H = 24; iS16 Block_W = 61; iS16 Block_H = 61; iS16 Block_StartX = 0; iS16 Block_StartY = 118; iS16 NumFrame_W = 92; iS16 NumFrame_H = 32; #elif defined PKIG_SCREEN_240X400 iS16 Bath_X = 0; iS16 Bath_Y = 360; iS16 Bath_W = SCREEN_WIDTH; iS16 Bath_H = 120; iS16 Word_X = 75; iS16 Word_Y = 268; iS16 Word_W = 171; iS16 Word_H = 24; iS16 Block_W = 61; iS16 Block_H = 61; iS16 Block_StartX = 0; iS16 Block_StartY = 118; iS16 NumFrame_W = 92; iS16 NumFrame_H = 32; #elif defined PKIG_SCREEN_320X480 iS16 Bath_X = 0; iS16 Bath_Y = 360; iS16 Bath_W = SCREEN_WIDTH; iS16 Bath_H = 120; iS16 Word_X = 75; iS16 Word_Y = 268; iS16 Word_W = 171; iS16 Word_H = 24; iS16 Block_W = 81; iS16 Block_H = 81; iS16 Block_StartX = 0; iS16 Block_StartY = 160; iS16 NumFrame_W = 121; iS16 NumFrame_H = 37; #endif int X,Y,i; #if SOUND_NEED if(iFALSE==MusicCloseFlag && SoundChoosePlay == iFALSE) //xie //if(iFALSE==MusicCloseFlag && SoundWinPlay == iFALSE) { //SoundWinPlay = iTRUE; SoundChoosePlay = iTRUE; //pfunc->public_audio_play( // 0, // MW_SOUND_NAME_CHOOSE, // i51AdeStdWStrlen((iU16*)MW_SOUND_NAME_CHOOSE), // i51_MMI_DEC_FILE_BASED, // AUDIO_PLAYER_WAV_0, // iTRUE // ); public_audio_play_x(0, wmw_SoundChoose_mp3, wmw_SoundChoose_mp3_len,i51_MMI_DEC_MEM_BASED, AUDIO_PLAYER_MP3, iTRUE); } #endif //iLog("start choose!"); if(UnlockMaxLevel>TOTAL_LEVEL) { iLog("MaxLevel:%d>TOTAL_LEVEL:%d",UnlockMaxLevel,TOTAL_LEVEL); return iFALSE; } SWMW_i51KitG2DrawImage(&iMageInfo[ChooseBKHead], iNULL, iNULL); for( Y = Block_StartY; Y<=SCREEN_HEIGHT; Y+=Block_H ) { for( X = Block_StartX; X<=SCREEN_WIDTH; X+=Block_W ) { DesRect.X = X; DesRect.Y = Y; DesRect.Width= Block_W; DesRect.Height= Block_H; SWMW_i51KitG2DrawImage(&iMageInfo[ChooseBKBlock], &DesRect, iNULL); } } DesRect.X = Bath_X; DesRect.Y = Bath_Y; DesRect.Width= Bath_W; DesRect.Height= Bath_H; //SWMW_i51KitG2DrawImage(mwContainer, ChsLvBath, &DesRect, iNULL); SWMW_i51KitG2DrawImage(&iMageInfo[ChsLvBath], &DesRect, iNULL); DesRect.X = Word_X; DesRect.Y = Word_Y; DesRect.Width= Word_W; DesRect.Height= Word_H; mwLevelDrawReturn(); DesRect.Width = ICON_WIDTH; DesRect.Height= ICON_HEIGHT; for( i = 0; i< TOTAL_LEVEL; i++ ) { CurrDuckNum = LevelDuckNum[i]; if(CurrDuckNum>MAXDUCK_ONELEVEL) { // iLog("Get level:%dduck numer error:%d",i,CurrDuckNum); continue; } DesRect.X = LEVEL_START_LEVEL1_X + (i%ICON_NUM_ONELINE)*LEVEL_START_LEVEL_ADDX; DesRect.Y = LEVEL_START_LEVEL1_Y + (i/ICON_NUM_ONELINE)*LEVEL_START_LEVEL_ADDY; if(i<UnlockMaxLevel) { SrcRect.X = 0; SrcRect.Y = CurrDuckNum * 2 * ICON_HEIGHT ; SrcRect.Width = ICON_WIDTH; SrcRect.Height = ICON_HEIGHT; //i51KitG2DrawImage(mwContainer, ChsLv, &DesRect, &SrcRect); SWMW_i51KitG2DrawImage(&iMageInfo[ChsLv], &DesRect, &SrcRect); if( i<9 ) { DesRect.X += 14; } else { DesRect.X += 7; } DesRect.Y += 7; #if defined(PKIG_SCREEN_240X320) mwLevelDrawNum(i+1,NumSmall,&DesRect); #elif defined(PKIG_SCREEN_240X400) mwLevelDrawNum(i+1,NumSmall,&DesRect); #elif defined(PKIG_SCREEN_320X480) mwLevelDrawNum(i+1,NumBig,&DesRect); #endif } else { SrcRect.X = 0; SrcRect.Y = ICON_HEIGHT * 8; SrcRect.Width = ICON_WIDTH; SrcRect.Height = ICON_HEIGHT; //i51KitG2DrawImage(mwContainer, ChsLv, &DesRect, &SrcRect); SWMW_i51KitG2DrawImage(&iMageInfo[ChsLv], &DesRect, &SrcRect); } } DesRect.X = LEVEL_START_DUCK_NUM_X; DesRect.Y = LEVEL_START_DUCK_NUM_Y; DesRect.Width = NumFrame_W; DesRect.Height = NumFrame_H; #if defined(PKIG_SCREEN_240X320) mwDrawNumStep(mwContainer, NumSmall, &DesRect, CurrTotalDuck, TOTAL_DUCK_NUM); #elif defined(PKIG_SCREEN_240X400) mwDrawNumStep(mwContainer, NumSmall, &DesRect, CurrTotalDuck, TOTAL_DUCK_NUM); #elif defined(PKIG_SCREEN_320X480) mwDrawNumStep(mwContainer, NumBig, &DesRect, CurrTotalDuck, TOTAL_DUCK_NUM); #endif //DesRect.X = LEVEL_START_DUCK_NUM_X; //DesRect.Y = LEVEL_START_DUCK_NUM_Y; //DesRect.Width = 121; //DesRect.Height = 37; //mwDrawNumStep(mwContainer, NumBig, &DesRect, CurrTotalDuck, TOTAL_DUCK_NUM); // iU32 ImageId[2] = {ChsLvBK}; // i51KitG2SetImageMemoryCopy(mwContainer, 1, ImageId); //iLog("end choose!"); return iTRUE; }
void createRenderContext(void *view) { iLog("Create opengl context"); EGLNativeWindowType hwnd = view; EGLNativeDisplayType dc = 0; EGLDisplay display = eglGetDisplay((dc) ? dc : EGL_DEFAULT_DISPLAY); if (!display) { iError("eglGetDisplay failed"); return; } s_display = display; EGLint major; EGLint minor; EGLint numFound = 0; #define MAX_CONFIG 32 EGLConfig configList[MAX_CONFIG]; iLog("eglInitialize"); EGLBoolean success = eglInitialize(display, &major, &minor); if (!success) { iError("eglInitialize failed"); return; } iLog("eglGetConfigs"); eglGetConfigs(display, configList, MAX_CONFIG, &numFound); if (!numFound) { iError("eglGetConfigs failed to find any configs"); return; } int config = -1; for (int i = 0; i < numFound; i++) { EGLint renderable = 0; EGLint enableSample = 0; EGLint sampleLevel = 4; EGLint r = 5; EGLint g = 6; EGLint b = 5; EGLint depth = 16; eglGetConfigAttrib(display, configList[i], EGL_RENDERABLE_TYPE, &renderable); eglGetConfigAttrib(display, configList[i], EGL_SAMPLE_BUFFERS, &enableSample); eglGetConfigAttrib(display, configList[i], EGL_SAMPLES, &sampleLevel); eglGetConfigAttrib(display, configList[i], EGL_RED_SIZE, &r); eglGetConfigAttrib(display, configList[i], EGL_GREEN_SIZE, &g); eglGetConfigAttrib(display, configList[i], EGL_BLUE_SIZE, &b); eglGetConfigAttrib(display, configList[i], EGL_DEPTH_SIZE, &depth); if ((renderable & EGL_OPENGL_ES2_BIT) //&& enableSample == 1 //&& sampleLevel == 4 && r == 8 && g == 8 && b == 8 && depth == 24) { config = i; break; } } if (config == -1) { iError("No GLES2 configs reported. Trying random config"); config = 0; } int version = 1; EGLint attribs[] = { EGL_CONTEXT_CLIENT_VERSION, version, EGL_NONE }; iLog("eglCreateContext"); s_context = eglCreateContext(display, configList[config], 0, attribs); if (!s_context) { iError("eglCreateContext failed"); return; } iLog("eglCreateWindowSurface"); s_surface = eglCreateWindowSurface(display, configList[config], hwnd, 0); iLog("eglMakeCurrent"); eglMakeCurrent(display, s_surface, s_surface, s_context); //eglSwapInterval(display, 1); }
int callFilter(Connection *Conn,int ac,const char *av[]) { int ein,eout,rcc; int tcc = 0; int fio[2]; FILE *in,*out; const char *args; int sock; int rcode; SpawnArgs spawnArgs; iLog("--- callFilter(%X,%d,%X)",p2i(Conn),ac,p2i(av)); /* sscanf(av[2],"%d/%d",&ein,&eout); in = fdopen(ein,"r"); */ /* sscanf(av[2],"%d/%d/%d/%d",&fio[0],&fio[1],&ein,&eout); */ sscanf(av[2],"%d/%d/%d/%d %d/%d",&fio[0],&fio[1],&ein,&eout, &CHILD_SERNO,&CHILD_SERNO_MULTI); in = fdopen(fio[0],"r"); close(fio[1]); rcc = fread(&spawnArgs,1,sizeof(spawnArgs),in); tcc += rcc; if( rcc != sizeof(spawnArgs) ){ /* 9.9.4 MTSS the caller might exited with signal */ fprintf(stderr,"[%d] --- callFilter sA rcc=%d/%d %d\n", getpid(),rcc,isizeof(spawnArgs),tcc); fflush(stderr); _exit(-1); } rcc = fread(Conn,1,sizeof(Connection),in); tcc += rcc; if( rcc != sizeof(Connection) ){ fprintf(stderr,"[%d] --- callFilter Co rcc=%d/%d %d\n", getpid(),rcc,isizeof(Connection),tcc); fflush(stderr); _exit(-1); } iLog("--- callFilter %d %X %X %X+%d %X:%X %d:%d:%d %X %X",rcc, Conn->cx_magic,LOG_bugs,p2i(Conn->cl_reqbuf),Conn->cl_reqbufsize, p2i(&D_REQUESTtag),p2i(D_REQUESTtag.ut_addr), isizeof(int),isizeof(char*),isizeof(Connection), xp2i(clearConnPTR),xp2i(callFilter) ); if( rcc != sizeof(Connection) ){ void initABORT(int sig); bzero(Conn,sizeof(Conn)); /* dumped in initABORT() */ initABORT(0); Finish(-1); return -1; } if( Conn->cl_reqbuf ){ Conn->cl_reqbuf = (char*)malloc(Conn->cl_reqbufsize); iLog("--- qbuf=%X+%d",p2i(Conn->cl_reqbuf),Conn->cl_reqbufsize); rcc = fread(Conn->cl_reqbuf,1,Conn->cl_reqbufsize,in); tcc += rcc; if( rcc != Conn->cl_reqbufsize ){ fprintf(stderr,"[%d] --- callFilter qb rcc=%d/%d %d\n", getpid(),rcc,Conn->cl_reqbufsize,tcc); fflush(stderr); _exit(-1); } iLog("--- qbuf rcc=%d/%d",rcc,Conn->cl_reqbufsize); } clearConnPTR(Conn); fdopenLogFile(Conn->fi_logfd); if( 0 < Conn->fi_arglen ){ args = (char*)malloc(Conn->fi_arglen); rcc = fread((char*)args,1,Conn->fi_arglen,in); tcc += rcc; if( rcc != Conn->fi_arglen ){ fprintf(stderr,"[%d] --- callFilter fa rcc=%d/%d %d\n", getpid(),rcc,Conn->fi_arglen,tcc); fflush(stderr); _exit(-1); } }else{ args = NULL; rcc = 0; } iLog("--- callFilter args=%d/%d %X",rcc,Conn->fi_arglen,p2i(args)); ClientSock = -1; if( Conn->fi_issock ){ if( (sock = getclientsock()) < 0 ) sock = Conn->fi_topeer; if( Conn->fi_dupclsock ) ClientSock = sock; }else sock = Conn->fi_topeer; if( spawnArgs.sa_mountserno ){ IStr(opts,1024); /* opts[] can be empty */ if( 0 < spawnArgs.sa_moptslen ){ int len = sizeof(opts)-1; int occ; if( spawnArgs.sa_moptslen < len ){ len = spawnArgs.sa_moptslen; } occ = fread(opts,1,len,in); if( 0 <= occ ){ setVStrEnd(opts,occ); } } setMountOptions(FL_ARG,Conn,stralloc(opts)); } fclose(in); if( Conn->fi_iomode & 1 ){ close(eout); out = fdopen(sock,"w"); in = fdopen(ein,"r"); }else{ in = fdopen(sock,"r"); out = fdopen(eout,"w"); } iLog("--- callFilter %X(%X,%X,%X,%d)",xp2i(Conn->fi_func),p2i(in),p2i(out),p2i(args),rcc); Verbose("## callFilter: %x[%d,%d]\n",xp2i(Conn->fi_func),fileno(in),fileno(out)); rcode = (*Conn->fi_func)(Conn,in,out,args,rcc); Finish(rcode?1:0); return -1; }
int spawnFilter(Connection *Conn,int iomode,int tofil[],int sock,iFUNCP func,PCStr(args)) { CStr(ein,32); int ac; const char *av[256]; /**/ CStr(epath,1024); CStr(logtype,64); CStr(logtype2,64); int fin; /* input at the filter side */ int fout; /* output at the DeleGate side */ int pid; int wcc; int wi; int fio[2]; /* a pipe to inherit Conn. */ FILE *out; SpawnArgs spawnArgs; iLog("--- spawnFilter sock=%d func=%X args=%X",sock,xp2i(func),p2i(args)); fin = tofil[0]; fout = tofil[1]; pipeX(fio,8*1024); out = fdopen(fio[1],"w"); sprintf(ein,"%d/%d/%d/%d %d/%d",fio[0],fio[1],fin,fout, CHILD_SERNO,CHILD_SERNO_MULTI); /* sprintf(ein,"%d/%d/%d/%d",fio[0],fio[1],fin,fout); */ /* sprintf(ein,"%d/%d",fin,fout); */ sprintf(epath,"%s=%s",P_EXEC_PATH,EXEC_PATH); ac = 0; av[ac++] = /*DeleGate1*/ "DeleGate"; av[ac++] = /*FuncFILTER*/ "(Filter)"; av[ac++] = ein; av[ac++] = epath; /* sprintf(logtype,"-L0x%x",LOG_type); */ sprintf(logtype,"-L0x%x/%d",LOG_type,curLogFd()); av[ac++] = logtype; if( LOG_type2 || LOG_bugs ){ sprintf(logtype2,"-L20x%x/%x",LOG_type2,LOG_bugs); av[ac++] = logtype2; } ac += copy_param("f",elnumof(av)-ac,&av[ac],&main_argv[1]); av[ac] = NULL; Conn->fi_func = func; if( args == NULL ) Conn->fi_arglen = 0; else Conn->fi_arglen = strlen(args)+1; Conn->fi_iomode = iomode; Conn->fi_logfd = curLogFd(); if( file_isreg(sock) ){ /* it might be TMPFILE() with CloseOnExec flag set */ clearCloseOnExec(sock); } Conn->fi_topeer = sock; Conn->fi_dupclsock = 0; if( Conn->fi_issock = file_ISSOCK(sock) ){ setclientsock(sock); if( sock == ClientSock || SocketOf(sock) == SocketOf(ClientSock) ) Conn->fi_dupclsock = 1; } /* might be emulating spawn() on Unix */ sigsetmask(sigblock(0) & ~sigmask(SIGHUP) ); pid = Spawnvp("openFilter",EXEC_PATH,av); Verbose("## spawnFilter: %d -> %d\n",getpid(),pid); if( pid <= 0 ){ /* 9.6.3 don't freeze in fwrite() to the pipe ... */ fclose(out); close(fio[0]); daemonlog("F","spawnFilter: FAILED %d\n",pid); porting_dbg("--FATAL: spawnFilter: FAILED spawn %d",pid); putpplog("--FATAL: spawnFilter: FAILED spawn %d\n",pid); return pid; } /* wcc = write(fout,Conn,sizeof(Connection)); if( Conn->cl_reqbuf ) write(fout,Conn->cl_reqbuf,Conn->cl_reqbufsize); if( args != NULL ) write(fout,args,strlen(args)+1); */ close(fio[0]); /* close here to get EPIPE on write(fio[1]) */ if( MountOptions ){ spawnArgs.sa_mountserno = MountSerno(MountOptions); spawnArgs.sa_moptslen = strlen(MountOptions)+1; }else{ spawnArgs.sa_mountserno = 0; spawnArgs.sa_moptslen = 0; } wcc = fwrite(&spawnArgs,1,sizeof(spawnArgs),out); wcc = fwrite(Conn,1,sizeof(Connection),out); if( Conn->cl_reqbuf ) fwrite(Conn->cl_reqbuf,1,Conn->cl_reqbufsize,out); if( args != NULL ) fwrite(args,1,strlen(args)+1,out); if( MountOptions && spawnArgs.sa_moptslen ){ fwrite(MountOptions,1,spawnArgs.sa_moptslen,out); setMountOptions(FL_ARG,Conn,0); } fclose(out); /* If the iomode == READ then * must wait till the client finish to read the written environment * not to read it by myself. * (in the case of FFROMCL, payload data may be ready, but cannot * identify whether or not it is env. data or payload data ...) * If the iomode == WRITE and filter is direct system-command then * must wait not to make buffered data be not passed to the filter. */ /* if( iomode == 0 || iomode != 0 && 0 < PollIn(fin,1) ){ sv1log("## wait the filter finish reading enviroment\n"); msleep(100); } */ return pid; }