int main (int argc, char *argv[]) { t_fmsg *f; int i; /* Creer la file */ f = CreerFile(); // Créer le thread consommateur CreateProc((function_t)Consommateur,(void *)f, 0); // Créer les threads producteurs for (i = 0; i < NBPROD; i++) CreateProc((function_t)Producteur,(void *)f, 0); // Lancer l'ordonnanceur en mode non "verbeux" sched(1); // Imprimer les statistiques PrintStat(); return EXIT_SUCCESS; }
static struct asym *CreateProto( int i, struct asm_tok tokenarray[], const char *name, enum lang_type langtype ) /**************************************************************************************************************/ { struct asym *sym; struct dsym *dir; DebugMsg1(("CreateProto( i=%u, name=%s, lang=%u )\n", i, name ? name : "NULL", langtype )); sym = SymSearch( name ); /* the symbol must be either NULL or state * - SYM_UNDEFINED * - SYM_EXTERNAL + isproc == FALSE ( previous EXTERNDEF ) * - SYM_EXTERNAL + isproc == TRUE ( previous PROTO ) * - SYM_INTERNAL + isproc == TRUE ( previous PROC ) */ if( sym == NULL || sym->state == SYM_UNDEFINED || ( sym->state == SYM_EXTERNAL && sym->weak == TRUE && sym->isproc == FALSE )) { if ( NULL == ( sym = CreateProc( sym, name, SYM_EXTERNAL ) ) ) return( NULL ); /* name was probably invalid */ } else if ( sym->isproc == FALSE ) { EmitErr( SYMBOL_REDEFINITION, sym->name ); return( NULL ); } dir = (struct dsym *)sym; /* a PROTO typedef may be used */ if ( tokenarray[i].token == T_ID ) { struct asym * sym2; sym2 = SymSearch( tokenarray[i].string_ptr ); if ( sym2 && sym2->state == SYM_TYPE && sym2->mem_type == MT_PROC ) { i++; if ( tokenarray[i].token != T_FINAL ) { EmitErr( SYNTAX_ERROR_EX, tokenarray[i].string_ptr ); return( NULL ); } CopyPrototype( dir, (struct dsym *)sym2->target_type ); return( sym ); } } /* sym->isproc is set inside ParseProc() */ //sym->isproc = TRUE; if ( Parse_Pass == PASS_1 ) { if ( ParseProc( dir, i, tokenarray, FALSE, langtype ) == ERROR ) return( NULL ); #if DLLIMPORT sym->dll = ModuleInfo.CurrDll; #endif } else { sym->isdefined = TRUE; } return( sym ); }
int main (int argc, char *argv[]) { int i; int *j; // Créer les processus long for (i = 0; i < 2; i++) { j = (int *) malloc(sizeof(int)); *j= i; CreateProc((function_t)ProcLong,(void *)j, 80); } // Créer les processus court for (i = 0; i < 2; i++) { j = (int *) malloc(sizeof(int)); *j= i; CreateProc((function_t)ProcCourt,(void *)j, 10); } // Definir une nouvelle primitive d'election avec un quantum de 1 seconde // SchedParam(NEW, 1, RandomElect); // Definir une nouvelle primitive d'election sans quantum (batch) //SchedParam(NEW, 0, SJFElect); // Redefinir le quantum par defaut //SchedParam(PREMPT, 2, NULL); // Passer en mode batch //SchedParam(BATCH, 0, NULL); // Lancer l'ordonnanceur en mode non "verbeux" sched(0); // Imprimer les statistiques PrintStat(); return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { // Créer les processus long CreateProc((function_t)Thread1,(void *)NULL, 0); // Lancer l'ordonnanceur en mode "verbeux" sched(0); // Imprimer les statistiques PrintStat(); return EXIT_SUCCESS; }
ret_code ExternDirective( int i, struct asm_tok tokenarray[] ) /************************************************************/ { char *token; #if MANGLERSUPP char *mangle_type = NULL; #endif char *altname; struct asym *sym; enum lang_type langtype; struct qualified_type ti; DebugMsg1(("ExternDirective(%u) enter\n", i)); i++; /* skip EXT[E]RN token */ #if MANGLERSUPP mangle_type = Check4Mangler( &i, tokenarray ); #endif do { altname = NULL; /* get the symbol language type if present */ langtype = ModuleInfo.langtype; GetLangType( &i, tokenarray, &langtype ); /* get the symbol name */ if( tokenarray[i].token != T_ID ) { return( EmitErr( SYNTAX_ERROR_EX, tokenarray[i].string_ptr ) ); } token = tokenarray[i++].string_ptr; /* go past the optional alternative name (weak ext, default resolution) */ if( tokenarray[i].token == T_OP_BRACKET ) { i++; if ( tokenarray[i].token != T_ID ) { return( EmitErr( SYNTAX_ERROR_EX, tokenarray[i].string_ptr ) ); } altname = tokenarray[i].string_ptr; i++; if( tokenarray[i].token != T_CL_BRACKET ) { return( EmitErr( EXPECTED, ")" ) ); } i++; } /* go past the colon */ if( tokenarray[i].token != T_COLON ) { return( EmitError( COLON_EXPECTED ) ); } i++; sym = SymSearch( token ); ti.mem_type = MT_EMPTY; ti.size = 0; ti.is_ptr = 0; ti.is_far = FALSE; ti.ptr_memtype = MT_EMPTY; ti.symtype = NULL; ti.Ofssize = ModuleInfo.Ofssize; if ( tokenarray[i].token == T_ID && ( 0 == _stricmp( tokenarray[i].string_ptr, "ABS" ) ) ) { //ti.mem_type = MT_ABS; i++; } else if ( tokenarray[i].token == T_DIRECTIVE && tokenarray[i].tokval == T_PROTO ) { /* dont scan this line further */ /* CreateProto() will define a SYM_EXTERNAL */ sym = CreateProto( i + 1, tokenarray, token, langtype ); DebugMsg1(("ExternDirective(%s): CreateProto()=%X\n", token, sym)); if ( sym == NULL ) return( ERROR ); if ( sym->state == SYM_EXTERNAL ) { sym->weak = FALSE; return( HandleAltname( altname, sym ) ); } else { /* unlike EXTERNDEF, EXTERN doesn't allow a PROC for the same name */ return( EmitErr( SYMBOL_REDEFINITION, sym->name ) ); } } else if ( tokenarray[i].token != T_FINAL && tokenarray[i].token != T_COMMA ) { if ( GetQualifiedType( &i, tokenarray, &ti ) == ERROR ) return( ERROR ); } DebugMsg1(("ExternDirective(%s): mem_type=%Xh\n", token, ti.mem_type )); if( sym == NULL || sym->state == SYM_UNDEFINED ) { /* v2.04: emit the error at the PUBLIC directive */ //if ( sym && sym->public == TRUE ) { // EmitErr( CANNOT_DEFINE_AS_PUBLIC_OR_EXTERNAL, sym->name ); // return( ERROR ); //} if(( sym = MakeExtern( token, ti.mem_type, ti.mem_type == MT_TYPE ? ti.symtype : NULL, sym, ti.is_ptr ? ModuleInfo.Ofssize : ti.Ofssize )) == NULL ) return( ERROR ); /* v2.05: added to accept type prototypes */ if ( ti.is_ptr == 0 && ti.symtype && ti.symtype->isproc ) { CreateProc( sym, NULL, SYM_EXTERNAL ); sym->weak = FALSE; /* v2.09: reset the weak bit that has been set inside CreateProc() */ CopyPrototype( (struct dsym *)sym, (struct dsym *)ti.symtype ); ti.mem_type = ti.symtype->mem_type; ti.symtype = NULL; DebugMsg1(("ExternDirective(%s): prototype copied, memtype=%X\n", token, ti.mem_type )); } } else { #if MASM_EXTCOND /* allow internal AND external definitions for equates */ //if ( sym->state == SYM_INTERNAL && sym->mem_type == MT_ABS ) if ( sym->state == SYM_INTERNAL && sym->mem_type == MT_EMPTY ) ; else #endif if ( sym->state != SYM_EXTERNAL ) { DebugMsg(("ExternDirective: symbol %s redefinition, state=%u\n", token, sym->state )); return( EmitErr( SYMBOL_REDEFINITION, token ) ); } /* v2.05: added to accept type prototypes */ if ( ti.is_ptr == 0 && ti.symtype && ti.symtype->isproc ) { ti.mem_type = ti.symtype->mem_type; ti.symtype = NULL; } if( sym->mem_type != ti.mem_type || sym->is_ptr != ti.is_ptr || sym->isfar != ti.is_far || ( sym->is_ptr && sym->ptr_memtype != ti.ptr_memtype ) || ((sym->mem_type == MT_TYPE) ? sym->type : sym->target_type) != ti.symtype || ( langtype != LANG_NONE && sym->langtype != LANG_NONE && sym->langtype != langtype )) { DebugMsg(("ExternDirective: memtype:%X-%X ptr=%X-%X far=%X-%X ptr_memtype=%X-%X lang=%u-%u\n", sym->mem_type, ti.mem_type, sym->is_ptr, ti.is_ptr, sym->isfar, ti.is_far, sym->ptr_memtype, ti.ptr_memtype, sym->langtype, langtype )); return( EmitErr( SYMBOL_TYPE_CONFLICT, token ) ); } } sym->isdefined = TRUE; sym->Ofssize = ti.Ofssize; if ( ti.is_ptr == 0 && ti.Ofssize != ModuleInfo.Ofssize ) { sym->seg_ofssize = ti.Ofssize; if ( sym->segment && ((struct dsym *)sym->segment)->e.seginfo->Ofssize != sym->seg_ofssize ) sym->segment = NULL; } sym->mem_type = ti.mem_type; sym->is_ptr = ti.is_ptr; sym->isfar = ti.is_far; sym->ptr_memtype = ti.ptr_memtype; if ( ti.mem_type == MT_TYPE ) sym->type = ti.symtype; else sym->target_type = ti.symtype; HandleAltname( altname, sym ); SetMangler( sym, langtype, mangle_type ); if ( tokenarray[i].token != T_FINAL ) if ( tokenarray[i].token == T_COMMA && ( (i + 1) < Token_Count ) ) { i++; } else { return( EmitErr( SYNTAX_ERROR_EX, tokenarray[i].string_ptr ) ); } } while ( i < Token_Count ); return( NOT_ERROR ); }
ret_code ExterndefDirective( int i, struct asm_tok tokenarray[] ) /***************************************************************/ { char *token; #if MANGLERSUPP char *mangle_type = NULL; #endif struct asym *sym; enum lang_type langtype; char isnew; struct qualified_type ti; DebugMsg1(("ExterndefDirective(%u) enter\n", i)); i++; /* skip EXTERNDEF token */ #if MANGLERSUPP mangle_type = Check4Mangler( &i, tokenarray ); #endif do { ti.Ofssize = ModuleInfo.Ofssize; /* get the symbol language type if present */ langtype = ModuleInfo.langtype; GetLangType( &i, tokenarray, &langtype ); /* get the symbol name */ if( tokenarray[i].token != T_ID ) { return( EmitErr( SYNTAX_ERROR_EX, tokenarray[i].string_ptr ) ); } token = tokenarray[i++].string_ptr; /* go past the colon */ if( tokenarray[i].token != T_COLON ) { return( EmitError( COLON_EXPECTED ) ); } i++; sym = SymSearch( token ); //typetoken = tokenarray[i].string_ptr; ti.mem_type = MT_EMPTY; ti.size = 0; ti.is_ptr = 0; ti.is_far = FALSE; ti.ptr_memtype = MT_EMPTY; ti.symtype = NULL; ti.Ofssize = ModuleInfo.Ofssize; if ( tokenarray[i].token == T_ID && ( 0 == _stricmp( tokenarray[i].string_ptr, "ABS" ) ) ) { /* v2.07: MT_ABS is obsolete */ //ti.mem_type = MT_ABS; i++; } else if ( tokenarray[i].token == T_DIRECTIVE && tokenarray[i].tokval == T_PROTO ) { /* dont scan this line further! * CreateProto() will either define a SYM_EXTERNAL or fail * if there's a syntax error or symbol redefinition. */ sym = CreateProto( i + 1, tokenarray, token, langtype ); #if 0 /* global queue is obsolete */ if ( sym && sym->isglobal == FALSE ) { sym->isglobal = TRUE; QAddItem( &ModuleInfo.g.GlobalQueue, sym ); } #endif return( sym ? NOT_ERROR : ERROR ); } else if ( tokenarray[i].token != T_FINAL && tokenarray[i].token != T_COMMA ) { if ( GetQualifiedType( &i, tokenarray, &ti ) == ERROR ) return( ERROR ); } isnew = FALSE; if ( sym == NULL || sym->state == SYM_UNDEFINED ) { sym = CreateExternal( sym, token, TRUE ); isnew = TRUE; } /* new symbol? */ if ( isnew ) { DebugMsg1(("ExterndefDirective(%s): memtype=%X set, ofssize=%X\n", token, ti.mem_type, ti.Ofssize )); /* v2.05: added to accept type prototypes */ if ( ti.is_ptr == 0 && ti.symtype && ti.symtype->isproc ) { CreateProc( sym, NULL, SYM_EXTERNAL ); CopyPrototype( (struct dsym *)sym, (struct dsym *)ti.symtype ); ti.mem_type = ti.symtype->mem_type; ti.symtype = NULL; } switch ( ti.mem_type ) { //case MT_ABS: case MT_EMPTY: /* v2.04: hack no longer necessary */ //if ( sym->weak == TRUE ) // sym->equate = TRUE; /* allow redefinition by EQU, = */ break; case MT_FAR: /* v2.04: don't inherit current segment for FAR externals * if -Zg is set. */ if ( Options.masm_compat_gencode ) break; /* fall through */ default: //SetSymSegOfs( sym ); sym->segment = &CurrSeg->sym; } sym->Ofssize = ti.Ofssize; if ( ti.is_ptr == 0 && ti.Ofssize != ModuleInfo.Ofssize ) { sym->seg_ofssize = ti.Ofssize; if ( sym->segment && ((struct dsym *)sym->segment)->e.seginfo->Ofssize != sym->seg_ofssize ) sym->segment = NULL; } sym->mem_type = ti.mem_type; sym->is_ptr = ti.is_ptr; sym->isfar = ti.is_far; sym->ptr_memtype = ti.ptr_memtype; if ( ti.mem_type == MT_TYPE ) sym->type = ti.symtype; else sym->target_type = ti.symtype; /* v2.04: only set language if there was no previous definition */ SetMangler( sym, langtype, mangle_type ); } else if ( Parse_Pass == PASS_1 ) { /* v2.05: added to accept type prototypes */ if ( ti.is_ptr == 0 && ti.symtype && ti.symtype->isproc ) { ti.mem_type = ti.symtype->mem_type; ti.symtype = NULL; } /* ensure that the type of the symbol won't change */ if ( sym->mem_type != ti.mem_type ) { /* if the symbol is already defined (as SYM_INTERNAL), Masm won't display an error. The other way, first externdef and then the definition, will make Masm complain, however */ DebugMsg(("ExterndefDirective: type conflict for %s. mem_types old-new: %X-%X\n", sym->name, sym->mem_type, ti.mem_type)); EmitWarn( 1, SYMBOL_TYPE_CONFLICT, sym->name ); } else if ( sym->mem_type == MT_TYPE && sym->type != ti.symtype ) { struct asym *sym2 = sym; /* skip alias types and compare the base types */ DebugMsg(("ExterndefDirective(%s): types differ: %X (%s) - %X (%s)\n", sym->name, sym->type, sym->type->name, ti.symtype, ti.symtype->name)); while ( sym2->type ) sym2 = sym2->type; while ( ti.symtype->type ) ti.symtype = ti.symtype->type; if ( sym2 != ti.symtype ) { DebugMsg(("ExterndefDirective(%s): type conflict old-new: %X (%s) - %X (%s)\n", sym->name, sym2, sym2->name, ti.symtype, ti.symtype->name)); EmitWarn( 1, SYMBOL_TYPE_CONFLICT, sym->name ); } } /* v2.04: emit a - weak - warning if language differs. * Masm doesn't warn. */ if ( langtype != LANG_NONE && sym->langtype != langtype ) EmitWarn( 3, LANGUAGE_ATTRIBUTE_CONFLICT, sym->name ); } sym->isdefined = TRUE; #if 0 /* write a global entry if none has been written yet */ if ( sym->state == SYM_EXTERNAL && sym->weak == FALSE ) ;/* skip EXTERNDEF if a real EXTERN/COMM was done */ else if ( sym->isglobal == FALSE ) { sym->isglobal = TRUE; DebugMsg1(("ExterndefDirective(%s): writing a global entry\n", sym->name)); QAddItem( &ModuleInfo.g.GlobalQueue, sym ); } #else if ( sym->state == SYM_INTERNAL && sym->ispublic == FALSE ) { sym->ispublic = TRUE; AddPublicData( sym ); } #endif if ( tokenarray[i].token != T_FINAL ) if ( tokenarray[i].token == T_COMMA ) { if ( (i + 1) < Token_Count ) i++; } else { return( EmitErr( EXPECTING_COMMA, tokenarray[i].tokpos ) ); } } while ( i < Token_Count ); return( NOT_ERROR ); }
void AddLinnumDataRef( unsigned srcfile, uint_32 line_num ) /*********************************************************/ { struct line_num_info *curr; #if COFF_SUPPORT /* COFF line number info is related to functions/procedures. Since * assembly allows code lines outside of procs, "dummy" procs must * be generated. A dummy proc lasts until * - a true PROC is detected or * - the source file changes or * - the segment/section changes ( added in v2.11 ) */ if ( Options.output_format == OFORMAT_COFF && CurrProc == NULL && ( dmyproc == NULL || dmyproc->debuginfo->file != srcfile || dmyproc->segment != (struct asym *)CurrSeg ) ) { char procname[12]; if ( dmyproc ) { /**/myassert( dmyproc->segment ); dmyproc->total_size = ((struct dsym *)dmyproc->segment)->e.seginfo->current_loc - dmyproc->offset; } sprintf( procname, "$$$%05u", procidx ); DebugMsg1(("AddLinnumDataRef(src=%u.%u): CurrProc==NULL, dmyproc=%s searching proc=%s\n", srcfile, line_num, dmyproc ? dmyproc->name : "NULL", procname )); dmyproc = SymSearch( procname ); /* in pass 1, create the proc */ if ( dmyproc == NULL ) { dmyproc = CreateProc( NULL, procname, SYM_INTERNAL ); DebugMsg1(("AddLinnumDataRef: new proc %s created\n", procname )); dmyproc->isproc = TRUE; /* flag is usually set inside ParseProc() */ dmyproc->included = TRUE; AddPublicData( dmyproc ); } else procidx++; /* for passes > 1, adjust procidx */ /* if the symbols isn't a PROC, the symbol name has been used * by the user - bad! A warning should be displayed */ if ( dmyproc->isproc == TRUE ) { SetSymSegOfs( dmyproc ); dmyproc->Ofssize = ModuleInfo.Ofssize; dmyproc->langtype = ModuleInfo.langtype; if ( write_to_file == TRUE ) { curr = LclAlloc( sizeof( struct line_num_info ) ); curr->sym = dmyproc; curr->line_number = GetLineNumber(); curr->file = srcfile; curr->number = 0; DebugMsg1(("AddLinnumDataRef: CURRPROC=NULL, sym=%s, calling AddLinnumData(src=%u.%u)\n", curr->sym->name, curr->file, curr->line_number )); AddLinnumData( curr ); } } } #endif if( line_num && ( write_to_file == FALSE || lastLineNumber == line_num )) { #ifdef DEBUG_OUT if ( write_to_file == TRUE ) DebugMsg1(("AddLinnumDataRef(src=%u.%u) line skipped, lastline=%u\n", srcfile, line_num, lastLineNumber )); #endif return; } DebugMsg1(("AddLinnumDataRef(src=%u.%u): currofs=%Xh, CurrProc=%s, GeneratedCode=%u\n", srcfile, line_num, GetCurrOffset(), CurrProc ? CurrProc->sym.name : "NULL", ModuleInfo.GeneratedCode )); curr = LclAlloc( sizeof( struct line_num_info ) ); curr->number = line_num; #if COFF_SUPPORT if ( line_num == 0 ) { /* happens for COFF only */ /* changed v2.03 (CurrProc might have been NULL) */ /* if ( Options.output_format == OFORMAT_COFF && CurrProc->sym.public == FALSE ) { */ /* v2.09: avoid duplicates, check for pass 1 */ //if ( Options.output_format == OFORMAT_COFF && CurrProc && CurrProc->sym.public == FALSE ) { if ( Parse_Pass == PASS_1 && Options.output_format == OFORMAT_COFF && CurrProc && CurrProc->sym.ispublic == FALSE ) { CurrProc->sym.included = TRUE; AddPublicData( (struct asym *)CurrProc ); } /* changed v2.03 */ /* curr->sym = (struct asym *)CurrProc; */ curr->sym = ( CurrProc ? (struct asym *)CurrProc : dmyproc ); curr->line_number = GetLineNumber(); curr->file = srcfile; /* set the function's size! */ if ( dmyproc ) { /**/myassert( dmyproc->segment ); dmyproc->total_size = ((struct dsym *)dmyproc->segment)->e.seginfo->current_loc - dmyproc->offset; dmyproc = NULL; } /* v2.11: write a 0x7fff line item if prologue exists */ if ( CurrProc && CurrProc->e.procinfo->size_prolog ) { DebugMsg1(("AddLinnumDataRef: calling AddLinnumData(src=%u.%u) sym=%s\n", curr->file, curr->line_number, curr->sym->name )); AddLinnumData( curr ); curr = LclAlloc( sizeof( struct line_num_info ) ); curr->number = GetLineNumber(); curr->offset = GetCurrOffset(); curr->srcfile = srcfile; } } else { #endif curr->offset = GetCurrOffset(); curr->srcfile = srcfile; #if COFF_SUPPORT } #endif lastLineNumber = line_num; /* v2.11: added, improved multi source support for CV. * Also, the size of line number info could have become > 1024, * ( even > 4096, thus causing an "internal error in omfint.c" ) */ if ( Options.output_format == OFORMAT_OMF ) omf_check_flush( curr ); /* v2.10: warning if line-numbers for segments without class code! */ if ( CurrSeg->e.seginfo->linnum_init == FALSE ) { CurrSeg->e.seginfo->linnum_init = TRUE; if ( TypeFromClassName( CurrSeg, CurrSeg->e.seginfo->clsym ) != SEGTYPE_CODE ) { EmitWarn( 2, LINNUM_INFO_FOR_SEGMENT_WITHOUT_CLASS_CODE, CurrSeg->sym.name ); } } DebugMsg1(("AddLinnumDataRef: calling AddLinnumData(src=%u.%u ofs=%X)\n", curr->number == 0 ? curr->file : curr->srcfile, curr->number, curr->offset )); AddLinnumData( curr ); return; }
BOOL CChromaDlg::OnCommand(WPARAM wParam, LPARAM lParam) { HWND hDlg = GetSafeHwnd(); BOOL bReturn = TRUE; UINT id = LOWORD(wParam); HWND hControl = (HWND)lParam; int codeNotify = HIWORD(wParam); int i; long Color; HWND hActiveWnd; char Buff[10]; BYTE mask; hActiveWnd = m_pView->GetSafeHwnd(); switch (id) { case IDC_CHROMASELECT: i = TableHandleCombo(hDlg, &iCombo[0], nCombo, id, codeNotify); if (i != IDC_CHROMA_NORMAL && i != IDC_CHROMA_HSL && i != IDC_CHROMA_LUMIN) break; lpChromaMask->ChromaColorMode = i; lpChromaMask->SetupChroma(); break; case IDC_MAP_PROBE: ::GetWindowText(hControl, Buff, 10); id = atoi(Buff); if (id < 1 || id > 8) break; id += IDC_MASKCOLOR1 - 1; GetDlgItem(id)->ShowWindow(SW_SHOW); GetDlgItem(id)->SetFocus(); ::ShowWindow(hControl, SW_HIDE); case IDC_MASKCOLOR1: case IDC_MASKCOLOR2: case IDC_MASKCOLOR3: case IDC_MASKCOLOR4: case IDC_MASKCOLOR5: case IDC_MASKCOLOR6: case IDC_MASKCOLOR7: case IDC_MASKCOLOR8: lpChromaMask->ActiveChromaMask = i = id - IDC_MASKCOLOR1; if (codeNotify != 1 /*Not A DoubleClick*/) { if (hActiveWnd) bProbePending = YES; } else { bProbePending = NO; if (!ColorPicker(&lpChromaMask->MaskColor[i], NULL)) break; CopyRGB(&lpChromaMask->MaskColor[i].rgb, &Color); SetWindowLong(::GetDlgItem(hDlg, id), GWL_ACTIVE, Color); AstralControlRepaint(hDlg, IDC_MASKCOLOR1+i); } mask = 1 << (id - IDC_MASKCOLOR1); if (lpChromaMask->Mask & mask) break; id = id - IDC_MASKCOLOR1 + IDC_MASKACTIVE1; case IDC_MASKACTIVE1: case IDC_MASKACTIVE2: case IDC_MASKACTIVE3: case IDC_MASKACTIVE4: case IDC_MASKACTIVE5: case IDC_MASKACTIVE6: case IDC_MASKACTIVE7: case IDC_MASKACTIVE8: { mask = 1 << (id - IDC_MASKACTIVE1); lpChromaMask->Mask ^= mask; CheckDlgButton(id, lpChromaMask->Mask & mask); lpChromaMask->SetupChroma(); } break; case IDC_CHROMA_FADE: if (::GetFocus() != ::GetDlgItem(hDlg, id)) break; if ( codeNotify == EN_CHANGE ) { BOOL Bool; lpChromaMask->Fade = GetDlgItemSpin(hDlg, id, &Bool, NO); lpChromaMask->SetupChroma(); } break; case IDC_MASKRANGE1: case IDC_MASKRANGE2: case IDC_MASKRANGE3: case IDC_MASKRANGE4: case IDC_MASKRANGE5: case IDC_MASKRANGE6: case IDC_MASKRANGE7: case IDC_MASKRANGE8: if (::GetFocus() != ::GetDlgItem(hDlg, id)) break; if ( codeNotify == EN_CHANGE ) { BOOL Bool; lpChromaMask->MaskRange[id-IDC_MASKRANGE1] = GetDlgItemSpin(hDlg, id, &Bool, NO); lpChromaMask->SetupChroma(); } break; case IDC_MASKMODE_ADD: case IDC_MASKMODE_SUBTRACT: case IDC_MASKMODE_REVERSE: lpChromaMask->ChromaCombineMode = SHAPE_REVERSE + (id - IDC_MASKMODE_REVERSE); CheckRadioButton(IDC_MASKMODE_REVERSE, IDC_MASKMODE_SUBTRACT,id); break; case IDC_DELETEMASK: lpChromaMask->Delete = !lpChromaMask->Delete; CheckDlgButton(id, lpChromaMask->Delete); break; case IDC_CHROMA: if (hActiveWnd) { idLastTool = ActivateTool(id); CreateProc(hActiveWnd, 0, 0, this); bPreview = YES; } break; case IDC_RESET: if ( bPreview ) DeactivateTool(); bPreview = NO; break; default: bReturn = FALSE; break; } return bReturn ? bReturn : CPPViewModalDlg::OnCommand(wParam, lParam); }
// function for downloading files/updating DWORD WINAPI DownloadThread(LPVOID param) { char buffer[IRCLINE]; DWORD r, d, start, total, speed; DOWNLOAD dl = *((DOWNLOAD *)param); DOWNLOAD *dls = (DOWNLOAD *)param; dls->gotinfo = true; HANDLE fh = fInternetOpenUrl(ih, dl.url, NULL, 0, 0, 0); if (fh != NULL) { // open the file HANDLE f = CreateFile(dl.dest, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0); // make sure that our file handle is valid if (f < (HANDLE)1) { sprintf(buffer,"[DOWNLOAD]: Couldn't open file: %s.",dl.dest); if (!dl.silent) irc_privmsg(dl.sock,dl.chan,buffer,dl.notice); addlog(buffer); clearthread(dl.threadnum); ExitThread(EXIT_FAILURE); } total = 0; start = GetTickCount(); char *fileTotBuff=(char *)malloc(512000); //FIX ME: Only checks first 500 kb do { memset(buffer, 0, sizeof(buffer)); fInternetReadFile(fh, buffer, sizeof(buffer), &r); if (dl.encrypted) Xorbuff(buffer,r); WriteFile(f, buffer, r, &d, NULL); if ((total) < 512000) { //We have free bytes... //512000-total unsigned int bytestocopy; bytestocopy=512000-total; if (bytestocopy>r) bytestocopy=r; memcpy(&fileTotBuff[total],buffer,bytestocopy); } total+=r; if (dl.filelen) if (total>dl.filelen) break; //er, we have a problem... filesize is too big. if (dl.update != 1) sprintf(threads[dl.threadnum].name, "[DOWNLOAD]: File download: %s (%dKB transferred).", dl.url, total / 1024); else sprintf(threads[dl.threadnum].name, "[DOWNLOAD]: Update: %s (%dKB transferred).", dl.url, total / 1024); } while (r > 0); bool goodfile=true; if (dl.filelen) { if (total!=dl.filelen) { goodfile=false; sprintf(buffer,"[DOWNLOAD]: Filesize is incorrect: (%d != %d).", total, dl.filelen); irc_privmsg(dl.sock,dl.chan,buffer,dl.notice); addlog(buffer); } } speed = total / (((GetTickCount() - start) / 1000) + 1); CloseHandle(f); /* if (dl.expectedcrc) { unsigned long crc,crclength; sprintf(buffer,"crc32([%lu], [%d])\n",fileTotBuff,total); crclength=total; if (crclength>512000) crclength=512000; crc=crc32(fileTotBuff,crclength); if (crc!=dl.expectedcrc) { goodfile=false; irc_privmsg(dl.sock,dl.chan,"CRC Failed!",dl.notice); } } */ free(fileTotBuff); if (dl.expectedcrc) { unsigned long crc=crc32f(dl.dest); if (crc!=dl.expectedcrc) { goodfile=false; sprintf(buffer,"[DOWNLOAD]: CRC Failed (%d != %d).", crc, dl.expectedcrc); irc_privmsg(dl.sock, dl.chan, buffer, dl.notice); addlog(buffer); } } if (goodfile==false) goto badfile; //download isn't an update if (dl.update != 1) { sprintf(buffer, "[DOWNLOAD]: Downloaded %.1f KB to %s @ %.1f KB/sec.", total / 1024.0, dl.dest, speed / 1024.0); if (!dl.silent) irc_privmsg(dl.sock, dl.chan, buffer, dl.notice); addlog(buffer); if (dl.run == 1) { CreateProc(dl.dest,NULL,SW_SHOW); if (!dl.silent) { sprintf(buffer,"[DOWNLOAD]: Opened: %s.",dl.dest); irc_privmsg(dl.sock,dl.chan,buffer,dl.notice); addlog(buffer); } } // download is an update } else { sprintf(buffer, "[DOWNLOAD]: Downloaded %.1fKB to %s @ %.1fKB/sec. Updating.", total / 1024.0, dl.dest, speed / 1024.0); if (!dl.silent) irc_privmsg(dl.sock, dl.chan, buffer, dl.notice); addlog(buffer); if (CreateProc(dl.dest,NULL,SW_HIDE) != 0) { fWSACleanup(); uninstall(); ExitProcess(EXIT_SUCCESS); } else { sprintf(buffer,"[DOWNLOAD]: Update failed: Error executing file: %s.",dl.dest); if (!dl.silent) irc_privmsg(dl.sock, dl.chan, buffer, dl.notice); addlog(buffer); } } } else { sprintf(buffer,"[DOWNLOAD]: Bad URL, or DNS Error: %s.",dl.url); if (!dl.silent) irc_privmsg(dl.sock, dl.chan, buffer, dl.notice); addlog(buffer); } badfile: fInternetCloseHandle(fh); clearthread(dl.threadnum); ExitThread(EXIT_SUCCESS); }
LOCAL void ShieldFloat_OnCommand(HWND hDlg, int id, HWND hControl, UINT codeNotify) /************************************************************************/ { int i; BOOL Bool, active; BYTE mask; long Color; ITEMID idLastTool; HWND hActiveWnd; char Buff[10]; hActiveWnd = GetActiveDoc(); switch (id) { case IDC_MAP_PROBE: GetWindowText(hControl, Buff, 10); id = atoi(Buff); if (id < 1 || id > 8) break; id += IDC_MASKCOLOR1 - 1; ShowWindow(GetDlgItem(hDlg, id), SW_SHOW); SetFocus(GetDlgItem(hDlg, id)); ShowWindow(hControl, SW_HIDE); case IDC_MASKCOLOR1: case IDC_MASKCOLOR2: case IDC_MASKCOLOR3: case IDC_MASKCOLOR4: case IDC_MASKCOLOR5: case IDC_MASKCOLOR6: case IDC_MASKCOLOR7: case IDC_MASKCOLOR8: ColorMask.MaskShield = i = id - IDC_MASKCOLOR1; if ( codeNotify != 1 /*Not A DoubleClick*/ ) { if ( hActiveWnd ) bProbePending = YES; } else { bProbePending = NO; if ( !ColorPicker( &ColorMask.MaskColor[i], NULL ) ) break; CopyRGB( &ColorMask.MaskColor[i].rgb, &Color ); SetWindowLong( GetDlgItem( hDlg, id ), GWL_ACTIVE, Color ); AstralControlRepaint( hDlg, IDC_MASKCOLOR1 + i ); } mask = 1 << (id - IDC_MASKCOLOR1); if (ColorMask.Mask & mask) { SetupShield(); break; } id = id - IDC_MASKCOLOR1 + IDC_MASKACTIVE1; case IDC_MASKACTIVE1: case IDC_MASKACTIVE2: case IDC_MASKACTIVE3: case IDC_MASKACTIVE4: case IDC_MASKACTIVE5: case IDC_MASKACTIVE6: case IDC_MASKACTIVE7: case IDC_MASKACTIVE8: mask = 1 << (id - IDC_MASKACTIVE1); ColorMask.Mask ^= mask; active = ColorMask.Mask & mask; CheckDlgButton( hDlg, id, active ); SetupShield(); break; case IDC_MASKRANGE1: case IDC_MASKRANGE2: case IDC_MASKRANGE3: case IDC_MASKRANGE4: case IDC_MASKRANGE5: case IDC_MASKRANGE6: case IDC_MASKRANGE7: case IDC_MASKRANGE8: if ( GetFocus() != GetDlgItem( hDlg, id ) ) break; if ( codeNotify != EN_CHANGE ) break; ColorMask.MaskRange[id-IDC_MASKRANGE1] = GetDlgItemSpin( hDlg, id, &Bool, NO ); SetupShield(); break; case IDC_SHIELD_IFHIDDEN: ColorMask.IfHidden = !ColorMask.IfHidden; CheckDlgButton( hDlg, id, !ColorMask.IfHidden ); break; case IDC_SHIELDSELECT: // case IDC_MASKINCLUDE: // case IDC_MASKEXCLUDE: if ( !(id = HandleCombo( hDlg, id, codeNotify )) ) break; ColorMask.Include = ( id == IDC_MASKINCLUDE ); if ( Tool.hRibbon ) SendMessage( Tool.hRibbon, WM_SHIELDCHANGE, 0, 0L ); break; case IDC_PREVIEW: if (!hActiveWnd) break; idLastTool = ActivateTool(id); CreateProc( hActiveWnd, 0, 0, idLastTool ); bPreview = YES; break; case IDC_RESET: TurnOffShieldPreview(); break; default: break; } }