// !!UNC static LPTSTR translate( LPCTSTR path, TCHAR *buffer ) { TCHAR *l = host_drive_list; const TCHAR *p = path; while(*l) { if(_totupper(p[1]) == _totupper(*l)) break; l += _tcslen(l) + 1; } if(p[0] == TEXT('\\') && *l && (p[2] == 0 || p[2] == TEXT(':') || p[2] == TEXT('\\'))) { p += 2; if(*p == TEXT(':')) p++; if(*p == TEXT('\\')) p++; _sntprintf( buffer, MAX_PATH_LENGTH, TEXT("%c:\\%s"), *l, p ); } else { if(*path == TEXT('\\')) { _sntprintf( buffer, MAX_PATH_LENGTH, TEXT("%s%s"), virtual_root, path ); } else { int len = _tcslen(path); if(len == 0 || path[len-1] == TEXT('\\')) { make_mask( buffer, virtual_root, path, tstr(my_computer).get() ); } else { make_mask( buffer, virtual_root, path, 0 ); } } } charset_mac2host( buffer ); return buffer; }
// !!UNC static char *translate( const char *path, char *buffer ) { char *l = host_drive_list; char *p = (char *)path; while(*l) { if(toupper(p[1]) == toupper(*l)) break; l += strlen(l) + 1; } if(p[0] == '\\' && *l && (p[2] == 0 || p[2] == ':' || p[2] == '\\')) { p += 2; if(*p == ':') p++; if(*p == '\\') p++; sprintf( buffer, "%c:\\%s", *l, p ); } else { if(*path == '\\') { sprintf( buffer, "%s%s", virtual_root, path ); } else { int len = strlen(path); if(len == 0 || path[len-1] == '\\') { make_mask( buffer, virtual_root, path, my_computer ); } else { make_mask( buffer, virtual_root, path, 0 ); } } } charset_mac2host( buffer ); return buffer; }
struct DIR *opendir( const char *path ) { DISABLE_ERRORS; DIR *d = new DIR; if(d) { memset( d, 0, sizeof(DIR) ); if(*path == 0) { d->vname_list = host_drive_list; if(d->vname_list) { d->h = VIRTUAL_ROOT_ID; strcpy( d->FindFileData.cFileName, d->vname_list ); d->FindFileData.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY; } else { d->h = INVALID_HANDLE_VALUE; } } else { char mask[MAX_PATH_LENGTH]; make_mask( mask, MRP(path), "*.*", 0 ); D(bug("opendir path=%s, mask=%s\n", path, mask)); d->h = FindFirstFile( mask, &d->FindFileData ); if(d->h == INVALID_HANDLE_VALUE) { delete d; d = 0; } } } D(bug("opendir(%s,%s) = %08x\n", path, MRP(path), d)); RESTORE_ERRORS; return d; }
void operator()(T const &elem) { auto h = Hash{}(elem); auto j = h & make_mask(K); auto v = h >> K; m_[j] = std::max<size_t>( m_[j], rank(v) ); }
/* Small help func takes ip-address-string, determines if a valid netmask is specified and inserts the netmask into mask. Cuts of the netmask of the string, if it founds a netmask !!! Returns 0 if no netmask found, -1 if netmask isn't valid, and 1 if successful. According to this function a mask is in form of 255.255.192.0 so an ip/mask looks like 10.0.0.0/255.255.192.0 we will extend it to 10.0.0.0/18 which will be also valid */ int parse_ip_netmask (char *c, char **ip, unsigned int *mask) { char *p, *q; unsigned int netmask; if (c == NULL) { return -10; } p = c; if ((q = strchr (p, '/')) == NULL) { *mask = 0xFFFFFFFF; return 0; /* no mask */ } else { *ip = (char *) malloc (q - p + 1); if ((*ip) == NULL) return -2; memcpy (*ip, p, q - p); (*ip)[q - p] = 0; // wrong (*q) = 0; /* cut of the netmask */ q++; /* * two possibilities /16 or /255.255.192.0 */ if (is_positive_number (q) == 1) { /* we have a /16 mask */ if ((netmask = make_mask (atoi (q))) == 0) { *mask = 0; /* error in value of /43 or something like */ return -1; } else { *mask = netmask; return 1; } } else /* we may have a 255.255.192.0 mask */ if (parse_ip_address (q, &netmask) == 1) /* and parse the netmask */ { *mask = netmask; return 1; } else { *mask = 0; return -1; } } }
/* * Bitpack_getu() - This function takes an unsigned 64 bit word, a field * width to extract a value from, and the least significant * bit of the field to be extracted. This function returns * the unsigned value extracted from the original word */ uint64_t Bitpack_getu(uint64_t word, unsigned width, unsigned lsb) { assert((width + lsb) <= WORD_SIZE); if (width == 0) return ZERO; uint64_t mask; mask = make_mask(width, lsb); return shift_rightu((mask & word), lsb); }
void bg_x11_window_make_icon(bg_x11_window_t * win, const gavl_video_frame_t * icon, const gavl_video_format_t * format, Pixmap * icon_ret, Pixmap * mask_ret) { if(icon_ret) *icon_ret = make_icon(win, icon, format); if(mask_ret) *mask_ret = make_mask(win, icon, format); }
/*! @brief this m n project */ int main(int argc, char *argv[]) { if (argc < 4) { std::cerr << "MC_dynamic_demo [m] [n] [project] [(option)log directory in project]" << std::endl; return 1; } const int m = atoi(argv[1]); const int n = atoi(argv[2]); const std::string project = argv[3]; const std::string log_dirname = (argc == 5) ? os::path::join(project, argv[4]) : os::path::join(project, "log"); const std::string M_filename = os::path::join(project, "M.mat"); const std::string Lr_filename = os::path::join(project, "Lr.mat"); const std::string Lc_filename = os::path::join(project, "Lc.mat"); const std::string prob_param_filename = "prob_param"; const std::string solver_param_filename = "solver_param"; const std::string X_filename = os::path::join(project, "X.mat"); MC<Scalar> mc(m, n); std::ifstream fin(M_filename); in(fin, mc.M); fin.close(); // mc.M = (mc.M.array() - mc.M.mean()).matrix(); mc.A = make_mask(mc.M); fin.open(Lr_filename); in(fin, mc.Lr); fin.close(); fin.open(Lc_filename); in(fin, mc.Lc); fin.close(); fin.open(prob_param_filename); fin >> mc.gamma_n >> mc.gamma_r >> mc.gamma_c >> mc.rho; fin.close(); fin.open(solver_param_filename); fin >> MC<Scalar>::max_rep >> MC<Scalar>::abs_tol >> MC<Scalar>::rel_tol; fin.close(); MC<Scalar>::logfile = os::path::join(log_dirname, "X"); mc.go(); std::ofstream fout(X_filename); out(fout, mc.X); fout.close(); return 0; }
static int folder_copy( LPCTSTR folder_src, LPCTSTR folder_dst ) { HANDLE fh; WIN32_FIND_DATA FindFileData; int ok, result = 0; TCHAR mask[_MAX_PATH]; D(bug(TEXT("copying folder %s -> \n"), folder_src, folder_dst)); my_errno = 0; if(!CreateDirectory( folder_dst, 0 )) { my_errno = EACCES; return -1; } make_mask( mask, folder_src, TEXT("*.*"), 0 ); fh = FindFirstFile( mask, &FindFileData ); ok = fh != INVALID_HANDLE_VALUE; while(ok) { make_mask( mask, folder_src, FindFileData.cFileName, 0 ); int isdir = (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; TCHAR target[_MAX_PATH]; make_mask( target, folder_dst, FindFileData.cFileName, 0 ); D(bug(TEXT("copying item %s -> %s\n"), mask, target)); if(isdir) { if(_tcscmp(FindFileData.cFileName,TEXT(".")) && _tcscmp(FindFileData.cFileName,TEXT(".."))) { result = folder_copy( mask, target ); if(result < 0) break; } } else { result = file_copy( mask, target ); if(result < 0) break; } ok = FindNextFile( fh, &FindFileData ); } if(fh != INVALID_HANDLE_VALUE) FindClose( fh ); return result; }
void main(int argc, char *argv[]) { FILE *fp; char frac1[400]; float FR1[MAX][MAX]; float NEW[MAX][MAX]; int rows,cols,void_nr; int i,j; char junk[50]; float xllcorner,yllcorner,resolution; if(argc!=2) { fprintf(stderr,"Usage: %s <fraction file>\n",argv[0]); fprintf(stderr,"\t<fraction file> is the routing fraction file for the current model resolution WITH AN ARC/INFO HEADER.\n"); fprintf(stderr,"\tOutput is to stdout.\n"); exit(0); } strcpy(frac1,argv[1]); if((fp = fopen(frac1,"r"))==NULL){ /* Opens maskfile */ printf("Cannot open file maskfile %s \n",frac1); exit(0);} fscanf(fp,"%s %d",junk,&cols); printf("%s %d\n",junk,cols/2); fscanf(fp,"%s %d",junk,&rows); printf("%s %d\n",junk,rows/2); fscanf(fp,"%s %f",junk,&xllcorner); printf("%s %.4f\n",junk,xllcorner); fscanf(fp,"%s %f",junk,&yllcorner); printf("%s %.4f\n",junk,yllcorner); fscanf(fp,"%s %f",junk,&resolution); printf("%s %.4f\n",junk,resolution*2.0); fscanf(fp,"%s %d",junk,&void_nr); printf("%s %d\n",junk,void_nr); fclose(fp); read_fraction(frac1,FR1,rows,cols); /* Reads fractionfile */ make_mask(FR1,NEW,rows,cols); /* Makes new mask with new resolution */ for(i=0;i<(rows/2);i++) { for(j=0;j<(cols/2); j++) printf("%.3f ",NEW[i][j]); printf("\n"); } }/* END MAIN ******************************************************************/
static int myRemoveDirectory( LPCTSTR source ) { HANDLE fh; WIN32_FIND_DATA FindFileData; int ok, result = 1; TCHAR mask[_MAX_PATH]; D(bug(TEXT("removing folder %s\n"), source)); make_mask( mask, source, TEXT("*.*"), 0 ); fh = FindFirstFile( mask, &FindFileData ); ok = fh != INVALID_HANDLE_VALUE; while(ok) { make_mask( mask, source, FindFileData.cFileName, 0 ); D(bug(TEXT("removing item %s\n"), mask)); int isdir = (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; if(isdir) { // must delete ".finf", ".rsrc" but not ".", ".." if(_tcscmp(FindFileData.cFileName,TEXT(".")) && _tcscmp(FindFileData.cFileName,TEXT(".."))) { result = myRemoveDirectory( mask ); if(!result) break; } } else { D(bug(TEXT("DeleteFile %s\n"), mask)); result = DeleteFile( mask ); if(!result) break; } ok = FindNextFile( fh, &FindFileData ); } if(fh != INVALID_HANDLE_VALUE) FindClose( fh ); if(result) { D(bug(TEXT("RemoveDirectory %s\n"), source)); result = RemoveDirectory( source ); } return result; }
/* * Bitpack_newu() - This function takes an unsigned 64 bit word, a field * width to update within that word, the least significant * bit of the field to be updated, and an unsigned value to * insert into the field being updated. This function * returns the updated word. * * note: if the word being inserted is too large for its * field width, the exception Bitpack_Overflow is * raised. */ uint64_t Bitpack_newu(uint64_t word, unsigned width, unsigned lsb, uint64_t value) { assert((width + lsb) <= 64); if (! Bitpack_fitsu(value, width)) RAISE(Bitpack_Overflow); uint64_t mask; mask = ~(make_mask(width, lsb)); word = (word & mask); word = (word | shift_left(value, lsb)); return word; }
vector readMaskFromFile(WaveFile* waveFile, int length, char marker) { vector mask_from_file; MaskData data = getLabelsFromFile(waveFile, marker); qDebug() << "MaskData pointsFrom" << data.pointsFrom.x << LOG_DATA; qDebug() << "MaskData pointsLength" << data.pointsLength.x << LOG_DATA; mask_from_file = make_mask(length, data.pointsFrom.x, data.pointsFrom.v, data.pointsLength.v); qDebug() << "make_mask" << LOG_DATA; freeiv(data.pointsFrom); freeiv(data.pointsLength); return mask_from_file; }
struct dirent *readdir( struct DIR *d ) { DISABLE_ERRORS; dirent *de = 0; if(d) { if(d->h != INVALID_HANDLE_VALUE) { if(d->h == VIRTUAL_ROOT_ID) { make_dentry(d); de = &d->de; d->vname_list += _tcslen(d->vname_list) + 1; if(*d->vname_list) { _tcscpy( d->FindFileData.cFileName, d->vname_list ); d->FindFileData.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY; } else { // Out of static drive entries. Continue with other stuff. TCHAR mask[MAX_PATH_LENGTH]; make_mask( mask, virtual_root, TEXT("*.*"), 0 ); d->h = FindFirstFile( mask, &d->FindFileData ); } } else { int done = 0; do { if(make_dentry(d)) { de = &d->de; done = 1; } if(!FindNextFile( d->h, &d->FindFileData )) { FindClose( d->h ); d->h = INVALID_HANDLE_VALUE; done = 1; } } while(!done); } } } if(de) { D(bug("readdir found %s\n", de->d_name)); } RESTORE_ERRORS; return de; }
int main() { clean_up(); build_global_data(); make_index(); string name; FILE* tmp_fp=fopen("tmp.txt","r"); char buf[10086]; while(fscanf(tmp_fp,"%s",buf)==1) { name=buf; make_mask(name); } fclose(tmp_fp); pack_up(); return 0; }
int main(int argc, char **argv) { #define NEWIMG(s) cvLoadImage(s, CV_LOAD_IMAGE_COLOR) // 19 - 22 are 'similar' IplImage *mask = make_mask("bunny.png"); IplImage *a = NEWIMG("frames/bbb20.png"); IplImage *b = cvCreateImage(cvGetSize(a), a->depth, a->nChannels); cvCopy(a, b, NULL); #undef NEWIMG IplImage *out = fill(a, b, mask); cvShowImage("a", a); cvShowImage("mask", mask); cvShowImage("out", out); cvMoveWindow("a", 0, 0); cvMoveWindow("mask", 480, 0); cvMoveWindow("out", 0, 400); cvWaitKey(0); cvReleaseImage(&a); cvReleaseImage(&b); cvReleaseImage(&mask); return 0; }
static void set_bit(servo_t* servo) { *servo->addr |= make_mask(servo); }
static int match_address(char *addr, char *tok) { char *p; struct addrinfo hints, *resa, *rest; int gai; int ret = 0; int addrlen = 0; #ifdef HAVE_STRTOL long int bits; #else int bits; #endif char mask[16]; char *a = NULL, *t = NULL; unsigned int len; if (!addr || !*addr) return 0; p = strchr(tok,'/'); if (p) { *p = '\0'; len = p - tok; } else len = strlen(tok); /* Fail quietly if tok is a hostname (not an address) */ if (strspn(tok, ".0123456789") != len #ifdef INET6 && strchr(tok, ':') == NULL #endif ) { if (p) *p = '/'; return 0; } memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; #ifdef AI_NUMERICHOST hints.ai_flags = AI_NUMERICHOST; #endif if (getaddrinfo(addr, NULL, &hints, &resa) != 0) { if (p) *p = '/'; return 0; } gai = getaddrinfo(tok, NULL, &hints, &rest); if (p) *p++ = '/'; if (gai != 0) { rprintf(FLOG, "error matching address %s: %s\n", tok, gai_strerror(gai)); freeaddrinfo(resa); return 0; } if (rest->ai_family != resa->ai_family) { ret = 0; goto out; } switch(resa->ai_family) { case PF_INET: a = (char *)&((struct sockaddr_in *)resa->ai_addr)->sin_addr; t = (char *)&((struct sockaddr_in *)rest->ai_addr)->sin_addr; addrlen = 4; break; #ifdef INET6 case PF_INET6: { struct sockaddr_in6 *sin6a, *sin6t; sin6a = (struct sockaddr_in6 *)resa->ai_addr; sin6t = (struct sockaddr_in6 *)rest->ai_addr; a = (char *)&sin6a->sin6_addr; t = (char *)&sin6t->sin6_addr; addrlen = 16; #ifdef HAVE_SOCKADDR_IN6_SCOPE_ID if (sin6t->sin6_scope_id && sin6a->sin6_scope_id != sin6t->sin6_scope_id) { ret = 0; goto out; } #endif break; } #endif default: rprintf(FLOG, "unknown family %u\n", rest->ai_family); ret = 0; goto out; } bits = -1; if (p) { if (inet_pton(resa->ai_addr->sa_family, p, mask) <= 0) { #ifdef HAVE_STRTOL char *ep = NULL; #else unsigned char *pp; #endif #ifdef HAVE_STRTOL bits = strtol(p, &ep, 10); if (!*p || *ep) { rprintf(FLOG, "malformed mask in %s\n", tok); ret = 0; goto out; } #else for (pp = (unsigned char *)p; *pp; pp++) { if (!isascii(*pp) || !isdigit(*pp)) { rprintf(FLOG, "malformed mask in %s\n", tok); ret = 0; goto out; } } bits = atoi(p); #endif if (bits == 0) { ret = 1; goto out; } if (bits < 0 || bits > (addrlen << 3)) { rprintf(FLOG, "malformed mask in %s\n", tok); ret = 0; goto out; } } } else { bits = 128; } if (bits >= 0) make_mask(mask, bits, addrlen); ret = match_binary(a, t, mask, addrlen); out: freeaddrinfo(resa); freeaddrinfo(rest); return ret; }
int mbtransfer (char *ziel) //************************************************************************* // // TRANSFER-Prozedur // (wird fuer jedes transferierte File einzeln aufgerufen) // //************************************************************************* { char name[20]; strcpy(name, "mbtransfer"); lastfunc(name); char *line = b->line; int findex; FILE *oldf, *newf; char usermail = 0; int retwert = NO; int nocp; //no-copy flag char oldsubject[101]; unsigned long int oldfpos; char oldmsgty; char oldmailfname[10]; time_t oldmsgtime; char old_ziel[DIRLEN+1]; int old_usermail; char oldboardname[10]; char oldmailpath[FNAMELEN+1]; char zielcall[CALLEN+1]; char newcall[CALLEN+1]; int gleichesboard = NO; unsigned long nummer; #ifdef USERLT short int old_lt; #endif #ifdef DEBUG_FWD trace(report, "mbtransfer", "ziel: %s", ziel); #endif strupr(ziel); nexttoken(ziel, zielcall, CALLEN); strcpy(oldmailpath, b->mailpath); if (sema_test("sendlock") || m.disable) { putf(ms(m_sendnotpossible)); return NO; } if (mbcallok(zielcall)) { // Use newcall if (get_newcall(zielcall, newcall)) { strcpy(zielcall, newcall); putf(ms(m_usingnewcall), newcall); } } char *bbuf = (char *) t_malloc(sizeof(tvar_t) - sizeof(task_t), "tran"); char *oldfname; oldfname = (char *) t_malloc(sizeof(char) * (FNAMELEN+1), "tra2"); if (! bbuf || ! oldfname) return NO; memcpy(bbuf, (char *) b + sizeof(task_t), sizeof(tvar_t) - sizeof(task_t)); strlwr(b->mailpath); strcpy(oldfname, b->mailpath); strcpy(oldmailfname, b->mailfname); oldmsgtime = filename2time(b->mailfname); if ((oldf = s_fopen(oldfname, "srt")) != NULL) { fgets(b->line, BUFLEN - 1, oldf); // Befehlszeile einlesen mbsend_parse(line, 0); if (b->mailtype == 'A' || (b->mailtype == 'B' && b->eraseinfo == 'T')) { retwert = NIL; s_fclose(oldf); goto error_exit; } oldmsgty = b->conttype; // save mailflags ...(conttype) fgets(b->line, BUFLEN - 1, oldf); // Forwardzeile vernichten fgets(b->line, BUFLEN - 1, oldf); // Read-Zeile fgets(oldsubject, BETREFFLEN, oldf); // Betreff cut_blank(oldsubject); // Newline entfernen if (mbcallok(zielcall)) *b->at = 0; // Verteiler loeschen -> Neubestimmen strcpy(old_ziel, b->ziel); #ifdef USERLT old_lt = b->lifetime; b->lifetime = 0; #endif old_usermail = b->usermail; mbsend_parse(ziel, 2); if (! stricmp(b->ziel, b->mailpath+strlen(b->mailpath)-strlen(b->ziel)-8)) { retwert = NIL; s_fclose(oldf); goto error_exit; } b->conttype = oldmsgty; // set mailflags again.. (conttype) if (b->mailtype == 'B' && ! old_usermail) strcpy(b->ziel, old_ziel); weiterleiten(1, b->zielboard); waitfor(e_ticsfull); findex = finddir(b->zielboard, b->sysop); if (findex && !(strlen(b->zielboard)==1 && !b->sysop)) { if (xmkdir(b->boardpath)) { trace(serious, name, "mkdir %s error", b->boardpath); s_fclose(oldf); goto error_exit; } nocp = ! strcmp(b->herkunft, b->logincall) || b->sysop; //kein "CP " wenn Sysop! if (nocp || b->mailtype == 'B') strcpy(b->betreff, oldsubject); else sprintf(b->betreff, "CP %s: %.67s", b->logincall, oldsubject); //Bei Nicht-Bulletin BID neu generieren bzw. wenn BID fehlt if (b->mailtype != 'B'|| ! *b->bid) strcpy(b->bid, newbid()); make_mask(b->mailpath, b->boardfullname); strcpy(b->mask, b->mailpath); // Ursprungsboardnamen aus b->mailpath holen und mit ziel vergleichen strcpy(oldboardname, b->boardname); oldmailpath[strlen(oldmailpath)-8] = 0; if (finddir(oldmailpath,0) > 0) { if (! strcmp(ziel, b->boardname)) gleichesboard = YES; } else gleichesboard = NO; strcpy(b->boardname,oldboardname); // b->boardname wieder herstellen // bei Usermail oder gleichem Board zum Sortieren // Filezeit/-namen neu setzen if (mbcallok(zielcall) || gleichesboard) { strcpy(b->mailfname, time2filename(0)); } else strcpy(b->mailfname, oldmailfname); if (! strstr(b->mailpath, "*.*")) trace(fatal, name, "mask %s", b->mailpath); strcpy(strstr(b->mailpath, "*.*"), b->mailfname); strlwr(b->mailpath); if ((newf = s_fopen(b->mailpath, "sw+t")) != NULL) { s_fsetopt(newf, 1); #ifdef USERLT set_boardlife_max(old_lt); b->lifetime = old_lt; #endif writeheader(newf, 1); if (b->mailtype != 'B') { if (fgets(b->line, BUFLEN - 1, oldf)) { do { // fputs(line,f); skip old R-lines waitfor(e_ticsfull); fgets(b->line, BUFLEN - 1, oldf); } while (! feof(oldf) && *line == 'R' && line[1] == ':'); } fprintf(newf, "%s\n", makeheader(1)); fprintf(newf, "X-Transfer: %s by %s @ %s\n", datestr(ad_time(), 12), b->logincall, m.boxadress); fprintf(newf, "X-Original-Date: %s\n", datestr(oldmsgtime, 10)); do { if(( ! strncasecmp(line, "from", 4) || ! strncmp(line, "de: ", 4) || ! strncmp(line, "de ", 3) || ! strncmp(line, "fm ", 3)) && ! nocp) fprintf(newf, "X-Originally %s", line); else if (( ! strncasecmp(line, "to: ", 4) || ! strncasecmp(line, "to ", 3)) && ! nocp) fprintf(newf, "X-Originally %s", line); else if (! strncmp(line, "X-MID: ", 7)) fprintf(newf, "X-Old-MID: %s", line + 7); else if (! strncmp(line, "X-BID: ", 7)) fprintf(newf, "X-Old-BID: %s", line + 7); else fputs(line, newf); waitfor(e_ticsfull); fgets(b->line, BUFLEN - 1, oldf); } while (! feof(oldf) && *line != LF); fputc(LF, newf); } //Files binaer behandeln oldfpos = ftell(oldf); s_fclose(oldf); s_fclose(newf); writemailflags(); if ((oldf = s_fopen(oldfname, "srb")) != NULL) { if ((newf = s_fopen(b->mailpath, "sab")) != NULL) //append to file { fseek(oldf, oldfpos, SEEK_SET); do { //oe3dzw: Transferroutine transparent int len; len = fread(line, 1, 255, oldf); if (len) fwrite(line, 1, len, newf); waitfor(e_ticsfull); } while (! feof(oldf)); if (b->binstart) //bei binaeren Mails offset neu berechnen { b->binstart += ftell(newf) - ftell(oldf); if (b->binstart < 0) trace(serious, name, "offset %ld in %s", b->binstart, b->mailpath); } s_fclose(newf); if (b->binstart) writelines(); //Neuen Binstart speichern if (b->bytes) { if (old_usermail || gleichesboard) nummer = appenddirlist(1); else nummer = appenddirlist(0); //change old CHECKLINE if (b->usermail) { add_fwdfile("", get_fdelay(b->herkunft), 0); sprintf(b->line, "%s %lu", b->herkunft, nummer); mbtalk("\001", b->zielboard, b->line); trigger_ufwd(b->zielboard); } else { handle fh; char found; if (old_usermail) add_fwdfile("", get_fdelay(b->herkunft), 0); else add_fwdfile("", get_fdelay(b->herkunft), 1); if (findex > 0) tree[findex - 1].newestmail = oldmsgtime; if ((fh = s_open(CHECKNAME, "sr+b")) != EOF) { seek_fname(fh, b->mailfname, &found, 1); long pos = ltell(fh); if (found) { _read(fh, b->line, BLEN); sprintf(b->line + 15, "%-8s", b->boardname); b->line[23] = '~'; #ifdef USERLT char nlt[4]; sprintf(nlt, "%3.3d", b->boardlife_max); memcpy(b->line + 51, nlt, 3); #endif lseek(fh, -(LBLEN), SEEK_CUR); _write(fh, b->line, BLEN); } s_close(fh); if (found && (fh = s_open(CHECKNUMNAME, "sr+b")) != EOF) { lseek(fh, 2*(pos >> 6), SEEK_SET); //2* da 32bit! _write(fh, &nummer, 4); // 4Byte=32 bit s_close(fh); } } else trace(serious, name, "check"); } inc_mailgot(b->boardname); writemailflags(); retwert = OK;
void main(int argc, char **argv) { FILE *fp; char dir1[400]; char acc1[400]; char junk[50]; int DIR1[MAX][MAX]; int ACC1[MAX][MAX]; int NEW[MAX][MAX]; int rows; int cols; int i,j; int AI,BI,CI,DI; int AJ,BJ,CJ,DJ; int max_acc; int new_dir; float xllcorner,yllcorner,resolution; int void_nr; if (argc!=3) { /* Must be exactly 2 arguments behind the program name */ fprintf(stderr,"Usage: %s <direction file> <accumulation file>\n",argv[0]); fprintf(stderr,"\tThis program builds a new routing direction file at twice the resolution (e.g. 1/8 to 1/4) of the provided direction file. The accumulation file for the current direction file must also be provided.\n"); fprintf(stderr,"\tThe new direction file is output to stdout.\n"); exit(0); } strcpy(dir1,argv[1]); strcpy(acc1,argv[2]); /*Read the header of the direction file */ if((fp = fopen(dir1,"r"))==NULL){ /* Opens maskfile */ printf("Cannot open file %s \n",dir1); exit(0); } fscanf(fp,"%s %d",junk,&cols); printf("%-15s %d\n",junk,cols/2); fscanf(fp,"%s %d",junk,&rows); printf("%-15s %d\n",junk,rows/2); fscanf(fp,"%s %f",junk,&xllcorner); printf("%-15s %.4f\n",junk,xllcorner); fscanf(fp,"%s %f",junk,&yllcorner); printf("%-15s %.4f\n",junk,yllcorner); fscanf(fp,"%s %f",junk,&resolution); printf("%-15s %.4f\n",junk,resolution*2.0); fscanf(fp,"%s %d",junk,&void_nr); printf("%-15s %d\n",junk,void_nr); fclose(fp); read_dir(dir1,DIR1,rows,cols); /* Reads direction file */ read_dir(acc1,ACC1,rows,cols); /* reads accumulation file */ make_mask(DIR1,NEW,rows,cols); /* Makes new mask with new resolution */ for(i=0;i<(rows/2);i++) { for(j=0;j<(cols/2);j++) { AJ = j*2; AI = i*2; BJ = j*2 + 1; BI = i*2; CJ = j*2; CI = i*2 + 1; DJ = j*2 + 1; DI = i*2 + 1; max_acc = new_dir = 0; if(NEW[i][j] > 0) { if(DIR1[AI][AJ] == 2) DIR1[AI][AJ] = 1; if(DIR1[AI][AJ] == 6) DIR1[AI][AJ] = 7; if(DIR1[BI][BJ] == 4) DIR1[BI][BJ] = 3; if(DIR1[BI][BJ] == 8) DIR1[BI][BJ] = 1; if(DIR1[CI][CJ] == 4) DIR1[CI][CJ] = 5; if(DIR1[CI][CJ] == 8) DIR1[CI][CJ] = 7; if(DIR1[DI][DJ] == 2) DIR1[DI][DJ] = 3; if(DIR1[DI][DJ] == 6) DIR1[DI][DJ] = 5; if(ACC1[AI][AJ] > max_acc) { max_acc = ACC1[AI][AJ]; new_dir = DIR1[AI][AJ]; } if(ACC1[BI][BJ] > max_acc) { max_acc = ACC1[BI][BJ]; new_dir = DIR1[BI][BJ]; } if(ACC1[CI][CJ] > max_acc) { max_acc = ACC1[CI][CJ]; new_dir = DIR1[CI][CJ]; } if(ACC1[DI][DJ] > max_acc) { max_acc = ACC1[DI][DJ]; new_dir = DIR1[DI][DJ]; } /* printf("DIR1[%d][%d] %d ACC1[%d][%d] %d\n",AI,AJ,DIR1[AI][AJ],AI,AJ,ACC1[AI][AJ]); */ /* printf("DIR1[%d][%d] %d ACC1[%d][%d] %d\n",BI,BJ,DIR1[BI][BJ],BI,BJ,ACC1[BI][BJ]); */ /* printf("DIR1[%d][%d] %d ACC1[%d][%d] %d\n",CI,CJ,DIR1[CI][CJ],CI,CJ,ACC1[CI][CJ]); */ /* printf("DIR1[%d][%d] %d ACC1[%d][%d] %d\n",DI,DJ,DIR1[DI][DJ],DI,DJ,ACC1[DI][DJ]); */ /* printf("\n"); */ /* Sets the new direction */ NEW[i][j] = new_dir; } } } /* printf("ncols %d\n",cols/2); */ /* printf("nrows %d\n",rows/2); */ /* printf("xllcorner \n"); */ /* printf("yllcorner \n"); */ /* printf("cellsize \n"); */ /* printf("NODATA_value 0\n"); */ for(i=0;i<(rows/2);i++) { for(j=0;j<(cols/2); j++) printf("%d ",NEW[i][j]); printf("\n"); } }/* END MAIN ******************************************************************/
void allocate(int datareg, int addreg, int floatreg, SNODE *block ) /* * allocate will allocate registers for the expressions that have * a high enough desirability. */ { CSE *csp; ENODE *exptr; unsigned mask, rmask,i,fmask,frmask,size; AMODE *ap, *ap2; framedepth = 4+lc_maxauto; mask = 0; rmask = 0; fmask = frmask = 0; for (i=cf_freedata; i < datareg; i++) { framedepth+=4; rmask = rmask | (1 << (15 - i)); mask = mask | (1 << i); } for (i=cf_freeaddress+16; i < addreg; i++) { framedepth+=4; rmask = rmask | (1 << (23 - i)); mask = mask | (1 << (i-8)); } while( bsort(&olist) ); /* sort the expression list */ csp = olist; while( csp != 0 ) { if (csp->reg == -1 && !(csp->exp->cflags & DF_VOL) && !csp->voidf) { if( desire(csp) < 3 ) csp->reg = -1; else { if (csp->exp->nodetype == en_rcon || csp->exp->nodetype == en_fcon || csp->exp->nodetype == en_lrcon || csp->exp->nodetype == en_floatref || csp->exp->nodetype ==en_doubleref || csp->exp->nodetype == en_longdoubleref) { if (floatreg <24 && floatregs) csp->reg = floatreg++; } else if( (datareg < cf_maxdata) && (csp->duses <= csp->uses/4) && dataregs) csp->reg = (datareg)++; else if( !(csp->size == 1 || csp->size == -1) && (addreg < cf_maxaddress) &&addrregs) csp->reg = (addreg)++; } } if( csp->reg != -1 ) { if (lvalue(csp->exp) && !((SYM *)csp->exp->v.p[0]->v.p[0])->funcparm) { ((SYM *)csp->exp->v.p[0]->v.p[0])->inreg = TRUE; ((SYM *)csp->exp->v.p[0]->v.p[0])->value.i = -csp->reg; } if (csp->reg < 16) { framedepth+=4; rmask = rmask | (1 << (15 - csp->reg)); mask = mask | (1 << csp->reg); } else if (csp->reg < 32) { framedepth+=4; rmask = rmask | (1 << (23 - csp->reg)); mask = mask | (1 << (csp->reg-8)); } else { framedepth+=12; frmask = frmask | (1 << (39 - csp->reg)); fmask = fmask | (1 << (csp->reg-32)); } } csp = csp->next; } allocstack(); /* Allocate stack space for the local vars */ if (currentfunc->tp->lst.head !=0 && currentfunc->tp->lst.head != (SYM *)-1) { if (prm_phiform || currentfunc->intflag) { mask |= (1 << (linkreg +8)); rmask |= (1 << (15 - linkreg -8)); framedepth+=4; } if (currentfunc->intflag) { mask |= 0xffff; rmask |= 0xffff; framedepth = lc_maxauto; } } if (prm_linkreg && !currentfunc->intflag && (currentfunc->tp->lst.head && currentfunc->tp->lst.head != (SYM *)-1 || lc_maxauto)) { gen_code(op_link,0,makeareg(linkreg),make_immed(-lc_maxauto)); } if( mask != 0 ) gen_code(op_movem,4,make_mask(rmask,0,0),push); save_mask = mask; if (fmask!=0) gen_code(op_fmovem,10,make_mask(frmask,0,1),push); fsave_mask = fmask; if ((prm_phiform || currentfunc->intflag) && currentfunc->tp->lst.head && currentfunc->tp->lst.head != (SYM *) -1) { gen_code(op_move,4,makeareg(0), makeareg(linkreg)); } if ((!prm_linkreg || currentfunc->intflag) && lc_maxauto) { AMODE *ap = xalloc(sizeof(AMODE)); ap->mode = am_indx; ap->offset = makenode(en_icon,(char *)-lc_maxauto,0); ap->preg = 7; gen_code(op_lea,0,ap,makeareg(7)); } if (prm_stackcheck) { AMODE *ap1; ap = set_symbol("_stackerror",1); ap1 = set_symbol("_stackbottom",0); if (prm_rel) { ap1->mode = am_indx; ap1->preg = basereg; } else { ap1->mode = am_adirect; if (prm_smalldata) ap1->preg = 2; else ap1->preg = 4; } gen_code(op_cmp,4,ap1,makeareg(7)); gen_code(op_bhi,0,ap,0); } }
static void show_help (XtPointer data, XtIntervalId* id) { int x, y; int shape; XPoint border[ 3 ]; if (id == NULL || ((id && b_timer) && b_text)) { b_timer = None; /* size */ get_text_size (b_dpy, b_fontStruct, b_text, &b_width, &b_height); b_width += 2 * MARGIN_WIDTH + 2 * BORDER_WIDTH; b_height += 2 * MARGIN_WIDTH + 2 * BORDER_WIDTH + CONE_HEIGHT; /* origin */ get_pointer_xy (b_dpy, &x, &y); /* guess at shape */ shape = get_shape(b_lastShape, x, y, b_width, b_height, b_screenWidth, b_screenHeight); x += (shape & SHAPE_CONE_LEFT) ? POINTER_OFFSET : -POINTER_OFFSET; y += (shape & SHAPE_CONE_TOP) ? POINTER_OFFSET : -POINTER_OFFSET; /* make sure it is still ok with offset */ shape = get_shape (shape, x, y, b_width, b_height, b_screenWidth, b_screenHeight); b_lastShape = shape; make_mask (shape, x, y, b_width, b_height); XShapeCombineMask (b_dpy, b_win, ShapeBounding, 0, 0, b_mask, ShapeSet); XMoveResizeWindow(b_dpy, b_win, (shape & SHAPE_CONE_LEFT) ? x : x - b_width, (shape & SHAPE_CONE_TOP) ? y : y - b_height, b_width, b_height); XClearWindow (b_dpy, b_win); XMapRaised (b_dpy, b_win); b_winMapped = True; draw_text (b_dpy, b_win, b_gc, b_fontStruct, BORDER_WIDTH + MARGIN_WIDTH, BORDER_WIDTH + MARGIN_WIDTH + ((shape & SHAPE_CONE_TOP) ? CONE_HEIGHT : 0), b_text); /* 3d border */ /* shine- top left */ border[0].x = 0 + BORDER_WIDTH_HALF; border[0].y = ((shape & SHAPE_CONE_TOP) ? b_height : b_height - CONE_HEIGHT) - BORDER_WIDTH_HALF; border[1].x = 0 + BORDER_WIDTH_HALF; border[1].y = ((shape & SHAPE_CONE_TOP) ? CONE_HEIGHT : 0) + BORDER_WIDTH_HALF; border[2].x = b_width - BORDER_WIDTH_HALF; border[2].y = border[1].y; XDrawLines (b_dpy, b_win, b_shineGC, border, 3, CoordModeOrigin); /* shadow- bottom right */ border[0].x = 0 + BORDER_WIDTH_HALF; border[0].y = ((shape & SHAPE_CONE_TOP) ? b_height : b_height - CONE_HEIGHT) - BORDER_WIDTH_HALF; border[1].x = b_width - BORDER_WIDTH_HALF; border[1].y = border[0].y; border[2].x = b_width - BORDER_WIDTH_HALF; border[2].y = ((shape & SHAPE_CONE_TOP) ? CONE_HEIGHT : 0) + BORDER_WIDTH_HALF; XDrawLines (b_dpy, b_win, b_shadowGC, border, 3, CoordModeOrigin); /* cone */ if (SHAPE_CONE_TOP_LEFT == shape) { XClearArea (b_dpy, b_win, CONE_WIDTH / 2 + BORDER_WIDTH, CONE_HEIGHT, CONE_WIDTH / 2 - BORDER_WIDTH, BORDER_WIDTH, False); XDrawLine (b_dpy, b_win, b_shadowGC, 0, 0, CONE_WIDTH / 2 + BORDER_WIDTH_HALF, CONE_HEIGHT); XDrawLine (b_dpy, b_win, b_shineGC, 0, 0, CONE_WIDTH - BORDER_WIDTH_HALF, CONE_HEIGHT); } else if (SHAPE_CONE_TOP_RIGHT == shape) { XClearArea (b_dpy, b_win, b_width - CONE_WIDTH + BORDER_WIDTH, CONE_HEIGHT, CONE_WIDTH / 2 - BORDER_WIDTH, BORDER_WIDTH, False); XDrawLine (b_dpy, b_win, b_shadowGC, b_width, 0, b_width - CONE_WIDTH / 2 - BORDER_WIDTH_HALF, CONE_HEIGHT); XDrawLine (b_dpy, b_win, b_shineGC, b_width, 0, b_width - CONE_WIDTH + BORDER_WIDTH_HALF, CONE_HEIGHT); } else if (SHAPE_CONE_BOTTOM_LEFT == shape) { XClearArea (b_dpy, b_win, CONE_WIDTH / 2 + BORDER_WIDTH, b_height - CONE_HEIGHT - BORDER_WIDTH, CONE_WIDTH / 2 - BORDER_WIDTH, BORDER_WIDTH, False); XDrawLine (b_dpy, b_win, b_shadowGC, 0, b_height - 1, CONE_WIDTH, b_height - 1 - CONE_HEIGHT); XDrawLine (b_dpy, b_win, b_shineGC, 0, b_height - 1, CONE_WIDTH / 2 + BORDER_WIDTH, b_height - 1 - CONE_HEIGHT); } else if (SHAPE_CONE_BOTTOM_RIGHT == shape) { XClearArea (b_dpy, b_win, b_width - 1 - CONE_WIDTH + BORDER_WIDTH, b_height - CONE_HEIGHT - BORDER_WIDTH, CONE_WIDTH / 2 - BORDER_WIDTH - 1, BORDER_WIDTH, False); XDrawLine (b_dpy, b_win, b_shadowGC, b_width - 1, b_height - 1, b_width - 1 - CONE_WIDTH, b_height - 1 - CONE_HEIGHT); XDrawLine (b_dpy, b_win, b_shineGC, b_width - 1, b_height - 1, b_width - 1 - CONE_WIDTH / 2 - BORDER_WIDTH, b_height - 1 - CONE_HEIGHT); } } }
return Drop(b); } static int steering_net_init(arguments_t args) { struct network_addr { __be32 addr; int prefix; int prefix2; } * data = get_arg(struct network_addr, args); __be32 ipv4 = data->addr; __be32 mask = make_mask(data->prefix); __be32 submask = make_mask(data->prefix2); set_arg_0(args, ipv4); set_arg_1(args, mask); set_arg_2(args, submask); pr_devel("[PFQ|init] steer_net: addr=%pI4 mask=%pI4 submask=%pI4\n", &ipv4, &mask, &submask); return 0; } static Action_SkBuff steering_net(arguments_t args, SkBuff b) {