void gli_startup(int argc, char *argv[]) { gli_baseline = 0; wininit(&argc, argv); if (argc > 1) glkunix_set_base_file(argv[argc-1]); gli_read_config(argc, argv); memcpy(gli_tstyles_def, gli_tstyles, sizeof(gli_tstyles_def)); memcpy(gli_gstyles_def, gli_gstyles, sizeof(gli_gstyles_def)); if (!gli_baseline) gli_baseline = gli_conf_propsize + 0.5; #ifdef USETTS gli_initialize_tts(); if (gli_conf_speak) gli_conf_quotes = 0; #endif gli_initialize_misc(); gli_initialize_fonts(); gli_initialize_windows(); gli_initialize_sound(); winopen(); gli_initialize_babel(); }
int winloop() { int x, y, c, marked, t0, inited; x= 10; y= 8; inited= 0; marked= 0; t0=time(0); steps=0; while(1) { c= igetkey(); //system("echo start_winloop_igetkey >> /home/bbs/stiger.test"); steps++; if(c=='q' || c==Ctrl('C')) return 0; if((c==KEY_UP||c=='k')&&y>1) y--; if((c==KEY_DOWN||c=='j')&&y<16) y++; if((c==KEY_LEFT||c=='h')&&x>1) x--; if((c==KEY_RIGHT||c=='l')&&x<30) x++; move(20,0); prints("й╠╪Д: %d ", time(0)-t0); move(21,0); prints("вЬ╠Й: %3d, %3d", x, y); move(y-1,x*2-2); //modified by stiger,2001,6,12,╦дуЩmarkedмЁ╪ф╣д╢МнС if(ganyingshi) { marknum=o[x-1][y-1]+o[x-1][y]+o[x-1][y+1]+o[x][y-1]+o[x][y+1]+o[x+1][y-1]+o[x+1][y]+o[x+1][y+1]; if((m[x][y]!=1)&&(num_mine_beside(x, y)==8-marknum)) { if(o[x-1][y-1]!=1) { if(!m[x-1][y-1]) {m[x-1][y-1]=1; marked++; } winsh(x-1,y-1);} if(o[x-1][y]!=1) { if(!m[x-1][y]) {m[x-1][y]=1; marked++; } winsh(x-1,y);} if(o[x-1][y+1]!=1) { if(!m[x-1][y+1]) {m[x-1][y+1]=1; marked++;} winsh(x-1,y+1);} if(o[x][y-1]!=1) { if(!m[x][y-1]) {m[x][y-1]=1; marked++; } winsh(x,y-1);} if(o[x][y+1]!=1) { if(!m[x][y+1]) {m[x][y+1]=1; marked++;} winsh(x,y+1);} if(o[x+1][y-1]!=1) { if(!m[x+1][y-1]) {m[x+1][y-1]=1; marked++;} winsh(x+1,y-1);} if(o[x+1][y]!=1) { if(!m[x+1][y]) {m[x+1][y]=1; marked++;} winsh(x+1,y);} if(o[x+1][y+1]!=1) { if(!m[x+1][y+1]) {m[x+1][y+1]=1; marked++;} winsh(x+1,y+1);} } if(num_mine_beside(x, y)==num_mark_beside(x, y)) dblclick(x,y); } //add by stiger,2001,6,12,╦дуЩmarkedотй╬╣днйлБ move(20,30); prints("╠Й╪г: %d ", marked); //add end if(c=='H') winhelp(); if(c=='d'|| c=='D') winrefresh(); if(c=='f'|| c=='F'){ if(!inited) { wininit(x, y); inited= 1; } dig(x, y); } if((c==83|| c==115)&&!o[x][y]) { if(m[x][y]){ m[x][y]=0; marked--; } else { m[x][y]=1; marked++; } winsh(x, y); //add by stiger,2001,6,12 move(20,30); prints("╠Й╪г: %d ", marked); //add end } if(checkwin()==1) { /*add by stiger*/ stiger=steps*1.0/(time(0)-t0); move(22,0); prints("вё╨ьдЦё║дЦЁи╧╕акё║ф╫╬Ыц©цК%lf╡╫",stiger); gameover= 0; win_checkrec(time(0)-t0);/* added by soff ╫Ьппеепп╪Л╡И */ return 1; } if(gameover) { move(22,0); prints("╨эре╨╤ё╛дЦй╖╟эак... тыю╢р╩╢н╟иё║ "); gameover= 0; return 1; } move(y-1,x*2-2); refresh(); } return 1; }
int startup(int argc, char *argv[]) { struct op_mask ops; /* Which of the ops do we want to perform? */ /* First, set the current directory to SystemRoot */ TCHAR gen_path[MAX_PATH]; DWORD res; res = GetWindowsDirectory(gen_path, sizeof(gen_path)); if (res==0) { printf("Couldn't get the windows directory - error %ld\n", GetLastError()); return 100; } if (res>=sizeof(gen_path)) { printf("Windows path too long (%ld)\n", res); return 100; } if (!SetCurrentDirectory(gen_path)) { wprintf(L"Cannot set the dir to %s (%ld)\n", gen_path, GetLastError()); return 100; } if (argc>1) { switch(argv[1][0]) { case 'r': /* Restart */ ops=SETUP; break; case 's': /* Full start */ ops=SESSION_START; break; default: ops=DEFAULT; break; } } else ops=DEFAULT; /* Perform the ops by order, stopping if one fails, skipping if necessary */ /* Shachar: Sorry for the perl syntax */ res=(ops.ntonly || !ops.preboot || wininit()) && (ops.w9xonly || !ops.preboot || pendingRename()) && (ops.ntonly || !ops.prelogin || ProcessRunKeys(HKEY_LOCAL_MACHINE, runkeys_names[RUNKEY_RUNSERVICESONCE], TRUE, FALSE)) && (ops.ntonly || !ops.prelogin || !ops.startup || ProcessRunKeys(HKEY_LOCAL_MACHINE, runkeys_names[RUNKEY_RUNSERVICES], FALSE, FALSE)) && (!ops.postlogin || ProcessRunKeys(HKEY_LOCAL_MACHINE, runkeys_names[RUNKEY_RUNONCE], TRUE, TRUE)) && (!ops.postlogin || !ops.startup || ProcessRunKeys(HKEY_LOCAL_MACHINE, runkeys_names[RUNKEY_RUN], FALSE, FALSE)) && (!ops.postlogin || !ops.startup || ProcessRunKeys(HKEY_CURRENT_USER, runkeys_names[RUNKEY_RUN], FALSE, FALSE)); printf("Operation done\n"); return res?0:101; }
int main( int argc, char *argv[] ) { extern HANDLE CDECL __wine_make_process_system(void); static const WCHAR RunW[] = {'R','u','n',0}; static const WCHAR RunOnceW[] = {'R','u','n','O','n','c','e',0}; static const WCHAR RunServicesW[] = {'R','u','n','S','e','r','v','i','c','e','s',0}; static const WCHAR RunServicesOnceW[] = {'R','u','n','S','e','r','v','i','c','e','s','O','n','c','e',0}; static const WCHAR wineboot_eventW[] = {'_','_','w','i','n','e','b','o','o','t','_','e','v','e','n','t',0}; /* First, set the current directory to SystemRoot */ int optc; int end_session = 0, force = 0, init = 0, kill = 0, restart = 0, shutdown = 0, update = 0; HANDLE event; SECURITY_ATTRIBUTES sa; BOOL is_wow64; GetWindowsDirectoryW( windowsdir, MAX_PATH ); if( !SetCurrentDirectoryW( windowsdir ) ) WINE_ERR("Cannot set the dir to %s (%d)\n", wine_dbgstr_w(windowsdir), GetLastError() ); if (IsWow64Process( GetCurrentProcess(), &is_wow64 ) && is_wow64) { STARTUPINFOW si; PROCESS_INFORMATION pi; WCHAR filename[MAX_PATH]; void *redir; DWORD exit_code; memset( &si, 0, sizeof(si) ); si.cb = sizeof(si); GetModuleFileNameW( 0, filename, MAX_PATH ); Wow64DisableWow64FsRedirection( &redir ); if (CreateProcessW( filename, GetCommandLineW(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi )) { WINE_TRACE( "restarting %s\n", wine_dbgstr_w(filename) ); WaitForSingleObject( pi.hProcess, INFINITE ); GetExitCodeProcess( pi.hProcess, &exit_code ); ExitProcess( exit_code ); } else WINE_ERR( "failed to restart 64-bit %s, err %d\n", wine_dbgstr_w(filename), GetLastError() ); Wow64RevertWow64FsRedirection( redir ); } while ((optc = getopt_long(argc, argv, short_options, long_options, NULL )) != -1) { switch(optc) { case 'e': end_session = 1; break; case 'f': force = 1; break; case 'i': init = 1; break; case 'k': kill = 1; break; case 'r': restart = 1; break; case 's': shutdown = 1; break; case 'u': update = 1; break; case 'h': usage(); return 0; case '?': usage(); return 1; } } if (end_session) { if (kill) { if (!shutdown_all_desktops( force )) return 1; } else if (!shutdown_close_windows( force )) return 1; } if (kill) kill_processes( shutdown ); if (shutdown) return 0; sa.nLength = sizeof(sa); sa.lpSecurityDescriptor = NULL; sa.bInheritHandle = TRUE; /* so that services.exe inherits it */ event = CreateEventW( &sa, TRUE, FALSE, wineboot_eventW ); ResetEvent( event ); /* in case this is a restart */ create_hardware_registry_keys(); create_dynamic_registry_keys(); create_environment_registry_keys(); wininit(); pendingRename(); ProcessWindowsFileProtection(); ProcessRunKeys( HKEY_LOCAL_MACHINE, RunServicesOnceW, TRUE, FALSE ); if (init || (kill && !restart)) { ProcessRunKeys( HKEY_LOCAL_MACHINE, RunServicesW, FALSE, FALSE ); start_services_process(); } if (init || update) update_wineprefix( update ); create_volatile_environment_registry_key(); ProcessRunKeys( HKEY_LOCAL_MACHINE, RunOnceW, TRUE, TRUE ); if (!init && !restart) { ProcessRunKeys( HKEY_LOCAL_MACHINE, RunW, FALSE, FALSE ); ProcessRunKeys( HKEY_CURRENT_USER, RunW, FALSE, FALSE ); ProcessStartupItems(); } WINE_TRACE("Operation done\n"); SetEvent( event ); return 0; }
Window* coladd(Column *c, Window *w, Window *clone, int y) { Rectangle r, r1; Window *v; int i, t; v = nil; r = c->r; r.min.y = c->tag.r.max.y+Border; if(y<r.min.y && c->nw>0){ /* steal half of last window by default */ v = c->w[c->nw-1]; y = v->body.r.min.y+Dy(v->body.r)/2; } /* look for window we'll land on */ for(i=0; i<c->nw; i++){ v = c->w[i]; if(y < v->r.max.y) break; } if(c->nw > 0){ if(i < c->nw) i++; /* new window will go after v */ /* * if v's too small, grow it first. */ if(!c->safe || v->body.maxlines<=3){ colgrow(c, v, 1); y = v->body.r.min.y+Dy(v->body.r)/2; } r = v->r; if(i == c->nw) t = c->r.max.y; else t = c->w[i]->r.min.y-Border; r.max.y = t; draw(screen, r, textcols[BACK], nil, ZP); r1 = r; y = min(y, t-(v->tag.font->height+v->body.font->height+Border+1)); r1.max.y = min(y, v->body.r.min.y+v->body.nlines*v->body.font->height); r1.min.y = winresize(v, r1, FALSE); r1.max.y = r1.min.y+Border; draw(screen, r1, display->black, nil, ZP); r.min.y = r1.max.y; } if(w == nil){ w = emalloc(sizeof(Window)); w->col = c; draw(screen, r, textcols[BACK], nil, ZP); wininit(w, clone, r); }else{ w->col = c; winresize(w, r, FALSE); } w->tag.col = c; w->tag.row = c->row; w->body.col = c; w->body.row = c->row; c->w = realloc(c->w, (c->nw+1)*sizeof(Window*)); memmove(c->w+i+1, c->w+i, (c->nw-i)*sizeof(Window*)); c->nw++; c->w[i] = w; savemouse(w); /* near but not on the button */ moveto(mousectl, addpt(w->tag.scrollr.max, Pt(3, 3))); barttext = &w->body; c->safe = TRUE; return w; }
Window* coladd(Column *c, Window *w, Window *clone, int y) { Rectangle r, r1; Window *v; int i, j, minht, ymax, buggered; v = nil; r = c->r; r.min.y = c->tag.fr.r.max.y+Border; if(y<r.min.y && c->nw>0){ /* steal half of last window by default */ v = c->w[c->nw-1]; y = v->body.fr.r.min.y+Dy(v->body.fr.r)/2; } /* look for window we'll land on */ for(i=0; i<c->nw; i++){ v = c->w[i]; if(y < v->r.max.y) break; } buggered = 0; if(c->nw > 0){ if(i < c->nw) i++; /* new window will go after v */ /* * if landing window (v) is too small, grow it first. */ minht = v->tag.fr.font->height+Border+1; j = 0; while(!c->safe || v->body.fr.maxlines<=3 || Dy(v->body.all) <= minht){ if(++j > 10){ buggered = 1; /* too many windows in column */ break; } colgrow(c, v, 1); } /* * figure out where to split v to make room for w */ /* new window stops where next window begins */ if(i < c->nw) ymax = c->w[i]->r.min.y-Border; else ymax = c->r.max.y; /* new window must start after v's tag ends */ y = max(y, v->tagtop.max.y+Border); /* new window must start early enough to end before ymax */ y = min(y, ymax - minht); /* if y is too small, too many windows in column */ if(y < v->tagtop.max.y+Border) buggered = 1; /* * resize & redraw v */ r = v->r; r.max.y = ymax; draw(screen, r, textcols[BACK], nil, ZP); r1 = r; y = min(y, ymax-(v->tag.fr.font->height*v->taglines+v->body.fr.font->height+Border+1)); r1.max.y = min(y, v->body.fr.r.min.y+v->body.fr.nlines*v->body.fr.font->height); r1.min.y = winresize(v, r1, FALSE, FALSE); r1.max.y = r1.min.y+Border; draw(screen, r1, display->black, nil, ZP); /* * leave r with w's coordinates */ r.min.y = r1.max.y; } if(w == nil){ w = emalloc(sizeof(Window)); w->col = c; draw(screen, r, textcols[BACK], nil, ZP); wininit(w, clone, r); }else{ w->col = c; winresize(w, r, FALSE, TRUE); } w->tag.col = c; w->tag.row = c->row; w->body.col = c; w->body.row = c->row; c->w = realloc(c->w, (c->nw+1)*sizeof(Window*)); memmove(c->w+i+1, c->w+i, (c->nw-i)*sizeof(Window*)); c->nw++; c->w[i] = w; c->safe = TRUE; /* if there were too many windows, redraw the whole column */ if(buggered) colresize(c, c->r); savemouse(w); /* near the button, but in the body */ moveto(mousectl, addpt(w->tag.scrollr.max, Pt(3, 3))); barttext = &w->body; return w; }
int startup(int argc, const char *argv[]) { struct op_mask ops; /* Which of the ops do we want to perform? */ /* First, set the current directory to SystemRoot */ TCHAR gen_path[MAX_PATH]; DWORD res; HKEY hSessionKey, hKey; HRESULT hr; res = GetWindowsDirectory(gen_path, sizeof(gen_path)); if (res==0) { printf("Couldn't get the windows directory - error %ld\n", GetLastError()); return 100; } if (!SetCurrentDirectory(gen_path)) { wprintf(L"Cannot set the dir to %s (%ld)\n", gen_path, GetLastError()); return 100; } hr = SHCreateSessionKey(KEY_WRITE, &hSessionKey); if (SUCCEEDED(hr)) { LONG Error; DWORD dwDisp; Error = RegCreateKeyEx(hSessionKey, L"StartupHasBeenRun", 0, NULL, REG_OPTION_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp); RegCloseKey(hSessionKey); if (Error == ERROR_SUCCESS) { RegCloseKey(hKey); if (dwDisp == REG_OPENED_EXISTING_KEY) { /* Startup programs has already been run */ return 0; } } } if (argc > 1) { switch(argv[1][0]) { case 'r': /* Restart */ ops = SETUP; break; case 's': /* Full start */ ops = SESSION_START; break; default: ops = DEFAULT; break; } } else ops = DEFAULT; /* do not run certain items in Safe Mode */ if(GetSystemMetrics(SM_CLEANBOOT)) ops.startup = FALSE; /* Perform the ops by order, stopping if one fails, skipping if necessary */ /* Shachar: Sorry for the perl syntax */ res = TRUE; if (res && !ops.ntonly && ops.preboot) res = wininit(); if (res && !ops.w9xonly && ops.preboot) res = pendingRename(); if (res && !ops.ntonly && ops.prelogin) res = ProcessRunKeys(HKEY_LOCAL_MACHINE, runkeys_names[RUNKEY_RUNSERVICESONCE], TRUE, FALSE); if (res && !ops.ntonly && ops.prelogin && ops.startup) res = ProcessRunKeys(HKEY_LOCAL_MACHINE, runkeys_names[RUNKEY_RUNSERVICES], FALSE, FALSE); if (res && ops.postlogin) res = ProcessRunKeys(HKEY_LOCAL_MACHINE, runkeys_names[RUNKEY_RUNONCE], TRUE, TRUE); if (res && ops.postlogin && ops.startup) res = ProcessRunKeys(HKEY_LOCAL_MACHINE, runkeys_names[RUNKEY_RUN], FALSE, FALSE); if (res && ops.postlogin && ops.startup) res = ProcessRunKeys(HKEY_CURRENT_USER, runkeys_names[RUNKEY_RUN], FALSE, FALSE); if (res && ops.postlogin && ops.startup) res = ProcessRunKeys(HKEY_CURRENT_USER, runkeys_names[RUNKEY_RUNONCE], TRUE, FALSE); printf("Operation done\n"); return res ? 0 : 101; }
void winloop() { int x, y, c, marked, t0, inited; char buf[100]; x = 10; y = 8; inited = 0; marked = 0; clearbuf(); t0 = time(0); while (1) { c = egetch(); if (c == 257 && y > 1) y--; if (c == 258 && y < 16) y++; if (c == 260 && x > 1) x--; if (c == 259 && x < 30) x++; move(0, 20); sprintf(buf, "ʱ¼ä: %d ", (int) (time(0) - t0)); prints(buf); move(40, 20); sprintf(buf, "±ê¼Ç: %d ", marked); prints(buf); move(0, 22); sprintf(buf, "×ø±ê: %3d, %3d", x, y); prints(buf); move(x * 2 - 2, y - 1); if (c == 'h' || c == 'H') winhelp(); if (c == 'd' || c == 'D') winrefresh(); if (c == 'a' || c == 'A') { if (!inited) { wininit(x, y); inited = 1; } dig(x, y); } if ((c == 83 || c == 115) && !o[x][y]) { if (m[x][y]) { m[x][y] = 0; marked--; } else { m[x][y] = 1; marked++; } winsh(x, y); } if (checkwin() == 1) { move(0, 22); prints("×£ºØÄ㣡Äã³É¹¦ÁË£¡ "); { char buf[100]; sprintf(buf, "finished in %d s.", (int) (time(0) - t0)); win_checkrec(time(0) - t0); winminelog(buf); } gameover = 0; return; } if (gameover) { move(0, 22); prints("ºÜÒź¶£¬Äãʧ°ÜÁË... ÔÙÀ´Ò»´Î°É£¡ "); { char buf[100]; sprintf(buf, "failed in %d s.", (int) (time(0) - t0)); winminelog(buf); } gameover = 0; return; } move(x * 2 - 2, y - 1); refresh(); } }
int winloop() { int x, y, c, marked, t0, inited; char buf[100]; x= 10; y= 8; inited= 0; marked= 0; clearbuf(); t0= time(0); while(1) { c= egetch(); if((c==257||c=='k')&&y>1) y--; if((c==258||c=='j')&&y<16) y++; if((c==260||c=='h')&&x>1) x--; if((c==259||c=='l')&&x<30) x++; move(0, 20); //% sprintf(buf, "时间: %ld ", time(0)-t0); sprintf(buf, "\xca\xb1\xbc\xe4: %ld ", time(0)-t0); prints(buf); move(40, 20); //% sprintf(buf, "标记: %d ", marked); sprintf(buf, "\xb1\xea\xbc\xc7: %d ", marked); prints(buf); move(0, 21); //% sprintf(buf, "坐标: %3d, %3d", x, y); sprintf(buf, "\xd7\xf8\xb1\xea: %3d, %3d", x, y); prints(buf); move(x*2-2, y-1); if(c=='H') winhelp(); if(c=='d'|| c=='D') winrefresh(); if(c=='f'|| c=='F'){ if(!inited) { wininit(x, y); inited= 1; } dig(x, y); } if((c==83|| c==115)&&!o[x][y]) { if(m[x][y]){ m[x][y]=0; marked--; } else { m[x][y]=1; marked++; } winsh(x, y); } if(checkwin()==1) { move(0, 22); //% prints("祝贺你!你成功了! "); prints("\xd7\xa3\xba\xd8\xc4\xe3\xa3\xa1\xc4\xe3\xb3\xc9\xb9\xa6\xc1\xcb\xa3\xa1 "); { char buf[100]; sprintf(buf, "finished in %ld s.", time(0)-t0); syslog(buf); } gameover= 0; win_checkrec(time(0)-t0);/* added by soff 进行排行检查 */ return; } if(gameover) { move(0, 22); //% prints("很遗憾,你失败了... 再来一次吧! "); prints("\xba\xdc\xd2\xc5\xba\xb6\xa3\xac\xc4\xe3\xca\xa7\xb0\xdc\xc1\xcb... \xd4\xd9\xc0\xb4\xd2\xbb\xb4\xce\xb0\xc9\xa3\xa1 "); { char buf[100]; sprintf(buf, "failed in %ld s.", time(0)-t0); syslog(buf); } gameover= 0; return; } move(x*2-2, y-1); refresh(); } }