static void unpackpdbresource(UWORD resourcenum,UBYTE *pdbdata,size_t_68k pdbsize,int dbnum){ pdbresource* thisresource = (pdbresource*)(pdbdata + 0x4E + (resourcenum * 8)); UWORD numrecords = pdbdata[0x4C] << 8 | pdbdata[0x4C + 1]; ULONG nextresourcestart = belong(((pdbresource*)(pdbdata + 0x4E + (resourcenum * 8) + 8))->location); size_t_68k size; if(resourcenum + 1 == numrecords){ size = pdbsize - belong(thisresource->location); }else{ size = nextresourcestart - belong(thisresource->location); } palmresource pdbchunk; pdbchunk.id = resourcenum; pdbchunk.attr = thisresource->attr; pdbchunk.location = installresource((UBYTE*)(pdbdata + belong(thisresource->location)),size); pdbchunk.size = size; //dbgprintf("Resource:PDB,Id:%d,Installloc:0x%08x\n",resourcenum,pdbchunk.location); apps[dbnum].parts.push_back(pdbchunk); }
static void unpackprcresource(UWORD resourcenum,UBYTE *prcdata,size_t_68k prcsize,int app){ prcresource* thisresource = (prcresource*)(prcdata + 0x4E + resourcenum * 10); UWORD numrecords = prcdata[0x4C] << 8 | prcdata[0x4C + 1]; ULONG nextresourcestart = belong(((prcresource*)(prcdata + 0x4E + (resourcenum * 10) + 10))->location); size_t_68k size; if(resourcenum + 1 == numrecords){ size = prcsize - belong(thisresource->location); }else{ size = nextresourcestart - belong(thisresource->location); } palmresource prcchunk; prcchunk.id = beword(thisresource->id); prcchunk.type = thisresource->type; prcchunk.location = installresource((UBYTE*)(prcdata + belong(thisresource->location)),size); prcchunk.size = size; apps[app].parts.push_back(prcchunk); //dbgprintf("Resource:%s,Id:%d,Installloc:0x%08x\n",stringfromtype(thisresource->type.typec).c_str(),beword(thisresource->id),apps[app].parts[resourcenum].location); }
static void login_query() { char uid [IDLEN + 1], passbuf[PASSLEN]; int attempts; char genbuf [200]; resolve_utmp(); attempts = utmpshm->number; clear(); #ifdef CAMERA film_out(time(0) % 5, 0); #else show_file("etc/Welcome0", 0, 20, ONLY_COLOR); #endif if (attempts >= MAXACTIVE) { pressanykey("目前站上人數已達上限,請您稍後再來。"); oflush(); sleep(1); exit(1); } attempts = 0; while (1) { if (attempts++ >= LOGINATTEMPTS) { more("etc/goodbye", NA); pressanykey_old("錯誤太多次,掰掰~~~~~"); exit(1); } uid[0] = '\0'; getdata(22, 2, "您的代號:", uid, IDLEN + 1, DOECHO, 0); if (strcasecmp(uid, str_new) == 0) { #ifdef LOGINASNEW DL_func("SO/register.so:va_new_register", 0); break; #else pressanykey("本系統目前無法以 new 註冊, 請用 guest 進入"); continue; #endif } else if (uid[0] == '\0' /* || !dosearchuser(uid) */ ) pressanykey(err_uid); else if (belong(FN_DISABLED, uid)) { pressanykey("該 ID 為本站禁止上站之 ID"); logattempt(uid, '*'); } else if (strcmp(uid, STR_GUEST)) { getdata(22, 30, "您的密碼:", passbuf, PASSLEN, PASS, 0); passbuf[8] = '\0'; if (!dosearchuser(uid)) { logattempt(uid, '!'); pressanykey(ERR_PASSWD); } else if (!chkpasswd(cuser.passwd, passbuf)) { logattempt(cuser.userid, '-'); pressanykey(ERR_PASSWD); } else { /* SYSOP gets all permission bits */ if (!strcasecmp(cuser.userid, str_sysop)) cuser.userlevel = ~0; logattempt(cuser.userid, ' '); break; } } else { /* guest 的話 */ #ifdef LOGINASGUEST cuser.userlevel = 0; cuser.uflag = COLOR_FLAG | PAGER_FLAG | BRDSORT_FLAG | MOVIE_FLAG; break; #else pressanykey("本站不提供 guest 上站"); continue; #endif } } multi_user_check(); sethomepath(genbuf, cuser.userid); mkdir(genbuf, 0755); srand(time(0) ^ getpid() ^ (getpid() << 10)); srandom(time(0) ^ getpid() ^ (getpid() << 10)); }
static void user_login() { char genbuf [200]; struct tm *ptime, *tmp; time_t now = time(0); int a; extern struct FROMCACHE *fcache; extern int fcache_semid; log_usies("ENTER", fromhost); setproctitle("%s: %s", cuser.userid, fromhost); /* ------------------------ */ /* 初始化 uinfo、flag、mode */ /* ------------------------ */ setup_utmp(LOGIN); currmode = MODE_STARTED; enter_uflag = cuser.uflag; /* get local time */ tmp = localtime(&cuser.lastlogin); update_data(); /* wildcat: update user data */ /* Ptt check 同時上線人數 */ resolve_fcache(); resolve_utmp(); if ((a = utmpshm->number) > fcache->max_user) { sem_init(FROMSEM_KEY, &fcache_semid); sem_lock(SEM_ENTER, fcache_semid); fcache->max_user = a; fcache->max_time = now; sem_lock(SEM_LEAVE, fcache_semid); } #ifdef INITIAL_SETUP if (getbnum(DEFAULT_BOARD) == 0) { strcpy(currboard, "尚未選定"); } else #endif { brc_initial(DEFAULT_BOARD); set_board(); } /* ------------ */ /* 畫面處理開始 */ /* ------------ */ if (!(HAS_PERM(PERM_SYSOP) && HAS_PERM(PERM_DENYPOST))) { char buf [256]; time_t now; time(&now); sprintf(buf, "<<上站通知>> -- 我來囉! - %s", Etime(&now)); do_aloha(buf); } time(&now); ptime = localtime(&now); #ifdef CAMERA film_out(FILM_LOGIN, 0); #else more("etc/Welcome_login", NA); #endif #if 0 /* wildcat : 搬家通知用 */ if (belong(BBSHOME "/etc/oldip", fromhost)) { more(BBSHOME "/etc/removal"); abort_bbs(); } #endif if ((cuser.day == ptime->tm_mday) && (cuser.month == (ptime->tm_mon + 1))) currutmp->birth = 1; else currutmp->birth = 0; if (cuser.userlevel) { /* not guest */ move(t_lines - 3, 0); prints(" 歡迎您第 [1;33m%d[0;37m 度拜訪本站,\ 上次您是從 [1;33m%s[0;37m 連往本站,\n\ 我記得那天是 [1;33m%s[0;37m。\n", ++cuser.numlogins, cuser.lasthost, Etime(&cuser.lastlogin)); pressanykey(NULL); /* Ptt */ if (currutmp->birth == 1) { #ifdef CAMERA film_out(FILM_WEL_BIRTH, 0); #else more("etc/Welcome_birth", YEA); #endif brc_initial("Greeting"); set_board(); do_post(); } sethomefile(genbuf, cuser.userid, str_badlogin); if (more(genbuf, NA) != -1) { if (getans2(b_lines, 0, "您要刪除以上錯誤嘗試的記錄嗎?", 0, 2, 'y') != 'n') unlink(genbuf); } check_register(); strncpy(cuser.lasthost, fromhost, 24); substitute_record(fn_passwd, &cuser, sizeof(cuser), usernum); cuser.lasthost[23] = '\0'; restore_backup(); }
/* Divide a list of isophotal detections in several parts (deblending). NOTE: Even if the object is not deblended, the output objlist threshold is recomputed if a variable threshold is used. This can return two error codes: DEBLEND_OVERFLOW or MEMORY_ALLOC_ERROR */ int deblend(objliststruct *objlistin, int l, objliststruct *objlistout, int deblend_nthresh, double deblend_mincont, int minarea) { objstruct *obj; static objliststruct debobjlist, debobjlist2; double thresh, thresh0, value0; int h,i,j,k,m,subx,suby,subh,subw, xn, nbm = NBRANCH, status; int *submap; submap = NULL; status = RETURN_OK; xn = deblend_nthresh; /* reset global static objlist for deblending */ memset(objlist, 0, (size_t)xn*sizeof(objliststruct)); /* initialize local object lists */ debobjlist.obj = debobjlist2.obj = NULL; debobjlist.plist = debobjlist2.plist = NULL; debobjlist.nobj = debobjlist2.nobj = 0; debobjlist.npix = debobjlist2.npix = 0; /* Create the submap for the object. * The submap is used in lutz(). We create it here because we may call * lutz multiple times below, and we only want to create it once. */ submap = createsubmap(objlistin, l, &subx, &suby, &subw, &subh); if (!submap) { status = MEMORY_ALLOC_ERROR; goto exit; } /* set thresholds of object lists based on object threshold */ thresh0 = objlistin->obj[l].thresh; objlistout->thresh = debobjlist2.thresh = thresh0; /* add input object to global deblending objlist and one local objlist */ if ((status = addobjdeep(l, objlistin, &objlist[0])) != RETURN_OK) goto exit; if ((status = addobjdeep(l, objlistin, &debobjlist2)) != RETURN_OK) goto exit; value0 = objlist[0].obj[0].fdflux*deblend_mincont; ok[0] = (short)1; for (k=1; k<xn; k++) { /*------ Calculate threshold */ thresh = objlistin->obj[l].fdpeak; debobjlist.thresh = thresh > 0.0? thresh0*pow(thresh/thresh0,(double)k/xn) : thresh0; /*--------- Build tree (bottom->up) */ if (objlist[k-1].nobj>=NSONMAX) { status = DEBLEND_OVERFLOW; goto exit; } for (i=0; i<objlist[k-1].nobj; i++) { status = lutz(objlistin->plist, submap, subx, suby, subw, &objlist[k-1].obj[i], &debobjlist, minarea); if (status != RETURN_OK) goto exit; for (j=h=0; j<debobjlist.nobj; j++) if (belong(j, &debobjlist, i, &objlist[k-1])) { debobjlist.obj[j].thresh = debobjlist.thresh; if ((status = addobjdeep(j, &debobjlist, &objlist[k])) != RETURN_OK) goto exit; m = objlist[k].nobj - 1; if (m>=NSONMAX) { status = DEBLEND_OVERFLOW; goto exit; } if (h>=nbm-1) if (!(son = (short *) realloc(son,xn*NSONMAX*(nbm+=16)*sizeof(short)))) { status = MEMORY_ALLOC_ERROR; goto exit; } son[k-1+xn*(i+NSONMAX*(h++))] = (short)m; ok[k+xn*m] = (short)1; } son[k-1+xn*(i+NSONMAX*h)] = (short)-1; } } /*------- cut the right branches (top->down) */ for (k = xn-2; k>=0; k--) { obj = objlist[k+1].obj; for (i=0; i<objlist[k].nobj; i++) { for (m=h=0; (j=(int)son[k+xn*(i+NSONMAX*h)])!=-1; h++) { if (obj[j].fdflux - obj[j].thresh * obj[j].fdnpix > value0) m++; ok[k+xn*i] &= ok[k+1+xn*j]; } if (m>1) { for (h=0; (j=(int)son[k+xn*(i+NSONMAX*h)])!=-1; h++) if (ok[k+1+xn*j] && obj[j].fdflux - obj[j].thresh * obj[j].fdnpix > value0) { objlist[k+1].obj[j].flag |= SEP_OBJ_MERGED; status = addobjdeep(j, &objlist[k+1], &debobjlist2); if (status != RETURN_OK) goto exit; } ok[k+xn*i] = (short)0; } } } if (ok[0]) status = addobjdeep(0, &debobjlist2, objlistout); else status = gatherup(&debobjlist2, objlistout); exit: if (status == DEBLEND_OVERFLOW) put_errdetail("limit of " NSONMAX_STR " sub-objects reached while " "deblending. Decrease number of deblending thresholds " "or increase the detection threshold."); free(submap); submap = NULL; free(debobjlist2.obj); free(debobjlist2.plist); for (k=0; k<xn; k++) { free(objlist[k].obj); free(objlist[k].plist); } free(debobjlist.obj); free(debobjlist.plist); return status; }