Ejemplo n.º 1
0
void DES::mixer(int leftBlock[32],int rightBlock[32],int RoundKeys[16][64])
{
	copydata(32,rightBlock,T1);
	functn(T1,RoundKeys,T2);
	exclusiveOR(32,leftBlock,T2,T3);
	copydata(32,T3,rightBlock);
}
Ejemplo n.º 2
0
void processCityData(char* dstbuff, char* cityUtf8)
{
	std::string strUtf8  = cityUtf8;
	std::string strAnsi;


	char city_utf8[] = {0xe5,0xb8,0x82,0x0};//"市"
	std::string old_value = city_utf8;


	std::string::size_type   pos(0);   
	if(   (pos=strUtf8.find(old_value))!=std::string::npos   )   
		strUtf8.replace(pos,old_value.length(),"");  


#ifdef  WIN32 
	EncodingConverter::Utf8StrToAnsiStr(strUtf8,strAnsi);
#else
	strAnsi = strUtf8;
#endif

	if(strAnsi.length() >= CITY_LEN-1)
	{
		memcpy(dstbuff,strAnsi.c_str(),CITY_LEN - 1 );
	}
	else
	{
		copydata(dstbuff,strAnsi.c_str());
	}
}
Ejemplo n.º 3
0
void copy_provice_data(char* dstbuff,char* proviceUtf8)
{
	char* ansidata = processProviceData(proviceUtf8) ; 
	if(ansidata)
	{	
#ifdef WIN32
		std::string origin = proviceUtf8;
		std::string dst ;
		EncodingConverter::Utf8StrToAnsiStr(origin,dst);
		copydata(dstbuff,dst.c_str());

#else
		copydata(dstbuff,ansidata);
#endif
	}
	else 
	{ 
		LOG(msgERROR,"convert provice failed ,line:%d",__LINE__); 
	}

}
Ejemplo n.º 4
0
static int findbestmatch(VCDIFFENC *enc, uint32_t hash, const char *targetptr,
                         const char *targetptrbegin, size_t targetsiz, BLKHASH *bhash) {
  int blknum;
  BLKHASHMATCH match;
  blknum = blkhashfindbestmatch(bhash, hash, targetptr, targetptrbegin, targetsiz, &match);
  if (blknum == -1) return -1; /* match not found */
  if (match.targetoff > 0) {
    /* ADD */
    adddata(enc, targetptrbegin, match.targetoff);
  }
  /* COPY */
  copydata(enc, match.sourceoff, match.size);
  return match.targetoff + match.size;
}
Ejemplo n.º 5
0
int sohu_parsedata(const std::vector<char>& contentdata,IpQueryCxt* ctx)
{

	if(contentdata.size() <= 0 )
	{
		LOG(msgINFO,"sohu_parsedata ,data is invalid\n");
		return -1;
	}


	std::vector<char>content_buff = contentdata;
	std::vector<char>::iterator  iter =  std::find(content_buff.begin(),content_buff.end(),'{');
	if(iter != content_buff.end())
	{
		content_buff.erase(content_buff.begin(),iter);
	}


	cJSON* j_root = cJSON_Parse(&*content_buff.begin());

	if(!j_root)
	{
		LOG(msgERROR,"sohu_parsedata  j_root failed\n");
		return -1;
	}


	cJSON* j_cip = cJSON_GetObjectItem(j_root,"cip");
	if(j_cip && j_cip->valuestring)
	{
		LOG(msgDEBUG,"sohu_parsedata cip:%s", j_cip->valuestring);
		if(ctx->ip)
		{
			free(ctx->ip);
		}
		ctx->ip = (char*)malloc(strlen(j_cip->valuestring) + 1);
		memset(ctx->ip,0,strlen(j_cip->valuestring) + 1);
		copydata(ctx->ip,j_cip->valuestring);
	}
	else
	{
		LOG(msgERROR,"sohu_parsedata ,get cip failed\n");
		return -1;
	}

	cJSON_Delete(j_root);

	return 0;
}
Ejemplo n.º 6
0
Archivo: proxy.c Proyecto: vodik/epoxy
static void handle_proxy_request(struct proxy_request *conn, int client_fd)
{
    if (conn->fd <= 0)
        errx(EXIT_FAILURE, "no proxy socket");

    printf("SENDING: ");
    fflush(stdout);
    iobuf_write(&conn->request, STDOUT_FILENO);

    /* write out header */
    iobuf_write(&conn->request, conn->fd);
    copydata(conn->fd, client_fd);

    close(conn->fd);
}
Ejemplo n.º 7
0
void processCarrierData(char* dstbuff, char* carrirUtf8)
{
	std::string strUtf8  = carrirUtf8;
	std::string strAnsi;


#ifdef  WIN32
	EncodingConverter::Utf8StrToAnsiStr(strUtf8,strAnsi);
#else
	strAnsi = strUtf8;
#endif



	if(strAnsi.length() >= CARRIR_LEN-1)
	{
		memcpy(dstbuff,strAnsi.c_str(),CARRIR_LEN - 1 );
	}
	else
	{
		copydata(dstbuff,strAnsi.c_str());
	}

}
Ejemplo n.º 8
0
void handler(int signo)
{
  copydata(fd1);
}
Ejemplo n.º 9
0
void DES::swapper(int leftBlock[32],int rightBlock[32])
{
	copydata(32,leftBlock,T);
	copydata(32,rightBlock,leftBlock);
	copydata(32,T,rightBlock);
}
Ejemplo n.º 10
0
bool Mission::loadLevel(uint8 * levelData)
{
    copydata(u01, 0);
    copydata(map, 8);
    copydata(people, 32776);
    copydata(cars, 56328);
    copydata(statics, 59016);
    copydata(u06, 71016);
    copydata(u07, 97116);
    copydata(u08, 97128);
    copydata(u09, 113512);
    copydata(u10, 113949);
    copydata(u11, 114075);

#if 0
    uint8 *data = (uint8 *) & level_data_;
    for (int i = 6; i < 0x8000; i++)
        if (data[i] != 0) {
            printf("%04X: ", i);
            for (; data[i]; i++)
                printf("%02X ", data[i]);
            printf("\n");
        }
#endif

    //printf("%08x\n", (char*)&level_data_.u10[0].unkn10[11] - (char*)&level_data_);
    map_ = level_data_.u10.map[0] | (level_data_.u10.map[1] << 8);
    min_x_ =
        (level_data_.u10.minx[0] | (level_data_.u10.minx[1] << 8)) / 2;
    min_y_ =
        (level_data_.u10.miny[0] | (level_data_.u10.miny[1] << 8)) / 2;
    max_x_ =
        (level_data_.u10.maxx[0] | (level_data_.u10.maxx[1] << 8)) / 2 + 4;
    max_y_ =
        (level_data_.u10.maxy[0] | (level_data_.u10.maxy[1] << 8)) / 2 + 4;
    objective_ =
        level_data_.u10.objective[0] | (level_data_.u10.objective[1] << 8);
    int objective_data =
        level_data_.u10.objective_data[0] | (level_data_.u10.
                                             objective_data[1] << 8);

    /*
       mission 20    1 922 39a
       mission 5     1 1106 452    or 39a + 5c * 2
       mission 38    1 1106 452
       mission 27    1 1474 5c2    or 39a + 5c * 6
       mission 41    1 1474 5c2
       mission 12    1 1566 61e    or 39a + 5c * 7
       mission 16    1 2118 846
       mission 21    1 2946 b82
       mission 45    1 2946 b82
       mission 29    1 3682 e62
       mission 3     1 4786 12b2
       mission 39    1 14446 386e
       mission 49    1 16378 3ffa  or 39a + 5c * a8

       mission 1     2 738 2e2   same
       mission 10    2 738 2e2
       mission 14    2 830 33e
       mission 32    2 922 39a
       mission 17    2 1198 4ae
       mission 19    2 1106 452
       mission 31    2 1106 452
       mission 7     2 1474 5c2
       mission 36    2 1474 5c2
       mission 24    2 2210 8a2
       mission 33    2 2946 b82
       mission 4     2 5614 15ee
       mission 34    2 9570 2562
       mission 35    2 14538 38ca
       mission 6     2 14998 3a96

       mission 25    3 3498 daa
       mission 30    3 3682 e62
       mission 40    3 3682 e62

       mission 8     5 40258 9d42        so I guess this would correspond to some
       mission 11    5 38242 9562        weapon table, that I don't even know exists
       mission 13    5 38242 9562
       mission 26    5 38314 95aa

       mission 43    10 0 0

       mission 2     11 0 0
       mission 9     11 0 0
       mission 15    11 0 0
       mission 18    11 0 0
       mission 22    11 0 0
       mission 28    11 0 0
       mission 37    11 0 0
       mission 42    11 0 0
       mission 48    11 0 0
       mission 50    11 0 0

       mission 23    14 23680 5c80  3 * 2a = 7e + 2 = 80
       mission 46    14 23596 5c2c  the vehicle struct size is 2a, +2 = 2c
       mission 47    14 23596 5c2c  so what's the 5c?  surely it can't be related to the size of the ped struct..

       mission 44    15 23596 5c2c
     */

    // 1  = persuade
    // 2  = assassinate
    // 3  = protect
    // 5  = equipment aquisition
    // 10 = combat sweep (police)
    // 11 = combat sweep
    // 14 = raid and rescue
    // 15 = use vehicle
    //printf("%i %i %x\n", objective_, objective_data, objective_data);

    if (objective_ == 1 || objective_ == 2 || objective_ == 3)
        objective_ped_ = (objective_data - 2) / 0x5c;

    if (objective_ == 14 || objective_ == 15)
        objective_vehicle_ = ((objective_data & 0xff) - 2) / 0x2a;

    vehicles_.clear();          // TODO: free existing?

    for (int i = 0; i < 64; i++) {
        LEVELDATA_CARS & car = level_data_.cars[i];
        // lots of things can make a car not exist
        if (car.unkn3 != 4 || car.unkn6 != 6
            || (car.unkn12[0] == 122 && car.unkn12[1] == 122))
            continue;
        VehicleInstance *v =
            g_App.vehicles().loadInstance((uint8 *) & car, map_);
        if (v)
            vehicles_.push_back(v);
    }

    for (int i = 0; i < 256; i++) {
        LEVELDATA_PEOPLE & pedref = level_data_.people[i];
        if (pedref.unkn3 != 4)
            continue;
        PedInstance *p =
            g_App.peds().loadInstance((uint8 *) & pedref, map_);
        peds_.push_back(p);
        if (p) {
            if (p->isHostile()) {
                Weapon *w = g_App.weapons().findWeapon(Ped::Pistol);
                if (w) {
                    WeaponInstance *wi = w->createInstance();
                    weapons_.push_back(wi);
                    p->addWeapon(wi);
                }
            }
        }
    }

    for (unsigned int i = 0; i < 400; i++) {
        LEVELDATA_STATICS & sref = level_data_.statics[i];
        Static *s = Static::loadInstance((uint8 *) & sref, map_);
        if (s)
            statics_.push_back(s);
    }

#if 0
    std::map < int, int >markers;
    for (unsigned int j = 0; j < 128; j++) {
        for (unsigned int i = 0; i < 128; i++) {
            uint8 a = level_data_.map.objs[j][i][0];
            uint8 b = level_data_.map.objs[j][i][1];
            int t = (a << 8) | b;

            if (t == 0)
                printf(".");
            else {
                if (markers.find(t) == markers.end())
                    markers[t] = markers.size();
                printf("%c", markers[t] + 'a');
            }
        }
        printf("\n");
    }

    for (std::map < int, int >::iterator it = markers.begin();
         it != markers.end(); it++)
        printf("%c -> %04x\n", it->second + 'a', it->first);
#endif

    return true;
}
Ejemplo n.º 11
0
static void
build(void)
{
	int	i;
	FILE	*oldrefs;	/* old cross-reference file */
	time_t	reftime;	/* old crossref modification time */
	char	*file;			/* current file */
	char	*oldfile;		/* file in old cross-reference */
	char	newdir[PATHLEN + 1];	/* directory in new cross-reference */
	char	olddir[PATHLEN + 1];	/* directory in old cross-reference */
	char	oldname[PATHLEN + 1];	/* name in old cross-reference */
	int	oldnum;			/* number in old cross-ref */
	struct	stat statstruct;	/* file status */
	int	firstfile;		/* first source file in pass */
	int	lastfile;		/* last source file in pass */
	int	built = 0;		/* built crossref for these files */
	int	copied = 0;		/* copied crossref for these files */
	BOOL	interactive = YES;	/* output progress messages */

	/*
	 * normalize the current directory relative to the home directory so
	 * the cross-reference is not rebuilt when the user's login is moved
	 */
	(void) strcpy(newdir, currentdir);
	if (strcmp(currentdir, home) == 0) {
		(void) strcpy(newdir, "$HOME");
	} else if (strncmp(currentdir, home, strlen(home)) == 0) {
		(void) sprintf(newdir, "$HOME%s", currentdir + strlen(home));
	}
	/* sort the source file names (needed for rebuilding) */
	qsort((char *)srcfiles, (unsigned)nsrcfiles, sizeof (char *), compare);

	/*
	 * if there is an old cross-reference and its current directory
	 * matches or this is an unconditional build
	 */
	if ((oldrefs = vpfopen(reffile, "r")) != NULL && unconditional == NO &&
	    fscanf(oldrefs, "cscope %d %s", &fileversion, olddir) == 2 &&
	    (strcmp(olddir, currentdir) == 0 || /* remain compatible */
	    strcmp(olddir, newdir) == 0)) {

		/* get the cross-reference file's modification time */
		(void) fstat(fileno(oldrefs), &statstruct);
		reftime = statstruct.st_mtime;
		if (fileversion >= 8) {
			BOOL	oldcompress = YES;
			BOOL	oldinvertedindex = NO;
			BOOL	oldtruncatesyms = NO;
			int	c;

			/* see if there are options in the database */
			for (;;) {
				while ((c = getc(oldrefs)) == ' ') {
				}
				if (c != '-') {
					(void) ungetc(c, oldrefs);
					break;
				}
				switch (c = getc(oldrefs)) {
				case 'c':	/* ASCII characters only */
					oldcompress = NO;
					break;
				case 'q':	/* quick search */
					oldinvertedindex = YES;
					(void) fscanf(oldrefs,
					    "%ld", &totalterms);
					break;
				case 'T':
					/* truncate symbols to 8 characters */
					oldtruncatesyms = YES;
					break;
				}
			}
			/* check the old and new option settings */
			if (oldcompress != compress ||
			    oldtruncatesyms != truncatesyms) {
				(void) fprintf(stderr,
				    "cscope: -c or -T option mismatch between "
				    "command line and old symbol database\n");
				goto force;
			}
			if (oldinvertedindex != invertedindex) {
				(void) fprintf(stderr,
				    "cscope: -q option mismatch between "
				    "command line and old symbol database\n");
				if (invertedindex == NO) {
					removeindex();
				}
				goto outofdate;
			}
			/* seek to the trailer */
			if (fscanf(oldrefs, "%ld", &traileroffset) != 1 ||
			    fseek(oldrefs, traileroffset, 0) == -1) {
				(void) fprintf(stderr,
				    "cscope: incorrect symbol database file "
				    "format\n");
				goto force;
			}
		}
		/* if assuming that some files have changed */
		if (fileschanged == YES) {
			goto outofdate;
		}
		/* see if the view path is the same */
		if (fileversion >= 13 &&
		    samelist(oldrefs, vpdirs, vpndirs) == NO) {
			goto outofdate;
		}
		/* see if the directory lists are the same */
		if (samelist(oldrefs, srcdirs, nsrcdirs) == NO ||
		    samelist(oldrefs, incdirs, nincdirs) == NO ||
		    fscanf(oldrefs, "%d", &oldnum) != 1 ||
		    fileversion >= 9 && fscanf(oldrefs, "%*s") != 0) {
			/* skip the string space size */
			goto outofdate;
		}
		/*
		 * see if the list of source files is the same and
		 * none have been changed up to the included files
		 */
		for (i = 0; i < nsrcfiles; ++i) {
			if (fscanf(oldrefs, "%s", oldname) != 1 ||
			    strnotequal(oldname, srcfiles[i]) ||
			    vpstat(srcfiles[i], &statstruct) != 0 ||
			    statstruct.st_mtime > reftime) {
				goto outofdate;
			}
		}
		/* the old cross-reference is up-to-date */
		/* so get the list of included files */
		while (i++ < oldnum && fscanf(oldrefs, "%s", oldname) == 1) {
			addsrcfile(oldname);
		}
		(void) fclose(oldrefs);
		return;

outofdate:
		/* if the database format has changed, rebuild it all */
		if (fileversion != FILEVERSION) {
			(void) fprintf(stderr,
			    "cscope: converting to new symbol database file "
			    "format\n");
			goto force;
		}
		/* reopen the old cross-reference file for fast scanning */
		if ((symrefs = vpopen(reffile, O_RDONLY)) == -1) {
			cannotopen(reffile);
			myexit(1);
		}
		/* get the first file name in the old cross-reference */
		blocknumber = -1;
		(void) readblock();	/* read the first cross-ref block */
		(void) scanpast('\t');	/* skip the header */
		oldfile = getoldfile();
	} else {	/* force cross-referencing of all the source files */
force:
		reftime = 0;
		oldfile = NULL;
	}
	/* open the new cross-reference file */
	if ((newrefs = fopen(newreffile, "w")) == NULL) {
		cannotopen(newreffile);
		myexit(1);
	}
	if (invertedindex == YES && (postings = fopen(temp1, "w")) == NULL) {
		cannotopen(temp1);
		cannotindex();
	}
	(void) fprintf(stderr, "cscope: building symbol database\n");
	putheader(newdir);
	fileversion = FILEVERSION;
	if (buildonly == YES && !isatty(0)) {
		interactive = NO;
	} else {
		initprogress();
	}
	/* output the leading tab expected by crossref() */
	dbputc('\t');

	/*
	 * make passes through the source file list until the last level of
	 * included files is processed
	 */
	firstfile = 0;
	lastfile = nsrcfiles;
	if (invertedindex == YES) {
		srcoffset = mymalloc((nsrcfiles + 1) * sizeof (long));
	}
	for (;;) {

		/* get the next source file name */
		for (fileindex = firstfile; fileindex < lastfile; ++fileindex) {
			/* display the progress about every three seconds */
			if (interactive == YES && fileindex % 10 == 0) {
				if (copied == 0) {
					progress("%ld files built",
					    (long)built, 0L);
				} else {
					progress("%ld files built, %ld "
					    "files copied", (long)built,
					    (long)copied);
				}
			}
			/* if the old file has been deleted get the next one */
			file = srcfiles[fileindex];
			while (oldfile != NULL && strcmp(file, oldfile) > 0) {
				oldfile = getoldfile();
			}
			/*
			 * if there isn't an old database or this is
			 * a new file
			 */
			if (oldfile == NULL || strcmp(file, oldfile) < 0) {
				crossref(file);
				++built;
			} else if (vpstat(file, &statstruct) == 0 &&
			    statstruct.st_mtime > reftime) {
				/* if this file was modified */
				crossref(file);
				++built;

				/*
				 * skip its old crossref so modifying the last
				 * source file does not cause all included files
				 * to be built.  Unfortunately a new file that
				 * is alphabetically last will cause all
				 * included files to be built, but this is
				 * less likely
				 */
				oldfile = getoldfile();
			} else {	/* copy its cross-reference */
				putfilename(file);
				if (invertedindex == YES) {
					copyinverted();
				} else {
					copydata();
				}
				++copied;
				oldfile = getoldfile();
			}
		}
		/* see if any included files were found */
		if (lastfile == nsrcfiles) {
			break;
		}
		firstfile = lastfile;
		lastfile = nsrcfiles;
		if (invertedindex == YES) {
			srcoffset = myrealloc(srcoffset,
			    (nsrcfiles + 1) * sizeof (long));
		}
		/* sort the included file names */
		qsort((char *)&srcfiles[firstfile],
		    (unsigned)(lastfile - firstfile), sizeof (char *), compare);
	}
	/* add a null file name to the trailing tab */
	putfilename("");
	dbputc('\n');

	/* get the file trailer offset */

	traileroffset = dboffset;

	/*
	 * output the view path and source and include directory and
	 * file lists
	 */
	putlist(vpdirs, vpndirs);
	putlist(srcdirs, nsrcdirs);
	putlist(incdirs, nincdirs);
	putlist(srcfiles, nsrcfiles);
	if (fflush(newrefs) == EOF) {
		/* rewind doesn't check for write failure */
		cannotwrite(newreffile);
		/* NOTREACHED */
	}
	/* create the inverted index if requested */
	if (invertedindex == YES) {
		char	sortcommand[PATHLEN + 1];

		if (fflush(postings) == EOF) {
			cannotwrite(temp1);
			/* NOTREACHED */
		}
		(void) fstat(fileno(postings), &statstruct);
		(void) fprintf(stderr,
		    "cscope: building symbol index: temporary file size is "
		    "%ld bytes\n", statstruct.st_size);
		(void) fclose(postings);
	/*
	 * sort -T is broken until it is fixed we don't have too much choice
	 */
	/*
	 * (void) sprintf(sortcommand, "sort -y -T %s %s", tmpdir, temp1);
	 */
	(void) sprintf(sortcommand, "LC_ALL=C sort %s", temp1);
		if ((postings = popen(sortcommand, "r")) == NULL) {
			(void) fprintf(stderr,
			    "cscope: cannot open pipe to sort command\n");
			cannotindex();
		} else {
			if ((totalterms = invmake(newinvname, newinvpost,
			    postings)) > 0) {
				movefile(newinvname, invname);
				movefile(newinvpost, invpost);
			} else {
				cannotindex();
			}
			(void) pclose(postings);
		}
		(void) unlink(temp1);
		(void) free(srcoffset);
		(void) fprintf(stderr,
		    "cscope: index has %ld references to %ld symbols\n",
		    npostings, totalterms);
	}
	/* rewrite the header with the trailer offset and final option list */
	rewind(newrefs);
	putheader(newdir);
	(void) fclose(newrefs);

	/* close the old database file */
	if (symrefs >= 0) {
		(void) close(symrefs);
	}
	if (oldrefs != NULL) {
		(void) fclose(oldrefs);
	}
	/* replace it with the new database file */
	movefile(newreffile, reffile);
}
Ejemplo n.º 12
0
void	Display::XX_ScreenFlip()
{
	DPMIregs	regs;
	regs.l.eax=regs.l.ebx=regs.l.ecx=regs.l.edx=0;
	regs.l.edi=regs.l.ebp=regs.l.esi=0;
int	skipbytes,Lines,Columns,page;
	if (++VESA.ScreenNum>=VESA.Screens)
		VESA.ScreenNum=0;
int	physicaloffset=VESA.ScreenNum*VESA.BytesPerScanLine*VESA.ScanLines;
	page=
		VESA.pagetop=physicaloffset/VESA.PageShift;
	VESA.pageoff=physicaloffset%VESA.PageShift;

	if (VESA.BytesPerScanLine==BytesPerScanLine)
	{
		skipbytes=0;
		Lines=1;
		Columns=BytesPerScanLine*PhysicalHeight;
	}
	else
	{
		skipbytes=VESA.BytesPerScanLine-BytesPerScanLine;
		Lines=PhysicalHeight;
		Columns=BytesPerScanLine;
	}

	LogicalPtr	src=logicalscreenptr;
	char		*trg2,*trg=(char*)VESA.writeaddr;
	int			off=VESA.pageoff;

	//set to page
	regs.w.ax=0x4f05;
	regs.w.bx=VESA.writewin;
	regs.w.dx=page;
	VESA.mode=page;
	ASM_DOSvia31(0x10,&regs,real_mode_stack,REALMODE_STACK_SIZE,0);

	while (Lines--)
	{
int		colleft=Columns;
		while (off+colleft>VESA.PageSize)
		{
int			tmpleft=VESA.PageSize-off;
			colleft=colleft-tmpleft;
//TempCode JIM 14Dec95 			ASM_blat(trg+off,src,tmpleft);
//TempCode JIM 14Dec95 			src+=tmpleft;
			if (tmpleft>0)
			{
				tmpleft=tmpleft>>2;
				trg2=off+trg;
				src=(LogicalPtr)copydata(src,trg2,tmpleft);
			}
			else
				src+=tmpleft;
//DeadCode JIM 19Nov96 			tmpleft=tmpleft>>2;
//DeadCode JIM 19Nov96 			trg2=off+trg;
//DeadCode JIM 19Nov96 			while (tmpleft--)
//DeadCode JIM 19Nov96 			{
//DeadCode JIM 19Nov96 				*((ULong*) (trg2))=*((LogicalLPtr) src);
//DeadCode JIM 19Nov96 				src+=4;
//DeadCode JIM 19Nov96 				trg2+=4;
//DeadCode JIM 19Nov96 			}
			off=0;

			//set to next page
			page+=VESA.PageShift;
			regs.w.ax=0x4f05;
			regs.w.bx=VESA.writewin;
			regs.w.dx=page;
	        VESA.mode=page;
			ASM_DOSvia31(0x10,&regs,real_mode_stack,REALMODE_STACK_SIZE,0);

		}
Ejemplo n.º 13
0
/*
 Load a new strip of pixel data into the buffer.
 */
void *loadstrip(picstruct *field)

{
	tabstruct *tab;
	checkstruct *check;
	int y, w, flags, interpflag;
	PIXTYPE *data, *wdata, *rmsdata;

	tab = field->tab;
	w = field->width;
	flags = field->flags;
	interpflag = 0; //(wfield && wfield->interp_flag);
	wdata = NULL; /* To avoid gcc -Wall warnings */

	if (!field->y)
	{
		/*- First strip */
		int nbpix;

		nbpix = w * field->stripheight;

		if (flags ^ FLAG_FIELD) {

			/*---- Allocate space for the frame-buffer */
			/*
			if (!(field->strip = (PIXTYPE *) malloc(
					field->stripheight * field->width * sizeof(PIXTYPE))))
				error(EXIT_FAILURE,
						"Not enough memory for the image buffer of ",
						field->rfilename); */

			data = field->strip;
			/*---- We assume weight data have been read just before */
			/*
			if (interpflag)
				wdata = wfield->strip;
			if (flags & BACKRMS_FIELD)
				for (y = 0, rmsdata = data; y < field->stripheight;
						y++, rmsdata += w)
					backrmsline(field, y, rmsdata);
			else if (flags & INTERP_FIELD)
				copydata(field, 0, nbpix);
			else *///true

				//read_body(tab, data, nbpix);

			//flag is in DETECT_FIELD | MEASURE_FIELD
			//if (flags & (WEIGHT_FIELD | RMS_FIELD | BACKRMS_FIELD | VAR_FIELD)) //false
			//	weight_to_var(field, data, nbpix);

			if ((flags & MEASURE_FIELD)
					&& (check = prefs.check[CHECK_IDENTICAL]))	//false
				writecheck(check, data, nbpix);

			for (y = 0; y < field->stripheight; y++, data += w) {
				/*------ This is the only place where one can pick-up safely the current bkg */
				if (flags & (MEASURE_FIELD | DETECT_FIELD))
					subbackline(field, y, data);

				/*------ Go to interpolation process */
				/*
				if (interpflag) {
					interpolate(field, wfield, data, wdata);
					wdata += w;
				}*/
				/*------ Check-image stuff */
				if (prefs.check_flag) {		//false

					if (flags & MEASURE_FIELD) {
						if ((check = prefs.check[CHECK_BACKGROUND]))
							writecheck(check, field->backline, w);
						if ((check = prefs.check[CHECK_SUBTRACTED]))
							writecheck(check, data, w);
						if ((check = prefs.check[CHECK_APERTURES]))
							writecheck(check, data, w);
						if ((check = prefs.check[CHECK_SUBPSFPROTOS]))
							writecheck(check, data, w);
						if ((check = prefs.check[CHECK_SUBPCPROTOS]))
							writecheck(check, data, w);
						if ((check = prefs.check[CHECK_SUBPROFILES]))
							writecheck(check, data, w);
					}
					if ((flags & DETECT_FIELD) && (check =
							prefs.check[CHECK_BACKRMS])) {  //false

						backrmsline(field, y, (PIXTYPE *) check->pix);
						writecheck(check, (PIXTYPE*)(check->pix), w);
					}
				}
			}
		}
		else {
			if (!(field->fstrip = (FLAGTYPE *) malloc(
					field->stripheight * field->width * sizeof(FLAGTYPE))))
				error(EXIT_FAILURE, "Not enough memory for the flag buffer of ",
						field->rfilename);
			read_ibody(field->tab, field->fstrip, nbpix);
		}

		field->ymax = field->stripheight;

		if (field->ymax < field->height)
			field->stripysclim = field->stripheight - field->stripmargin;
	} else {

		/*- other strips */
		if (flags ^ FLAG_FIELD) {
			data = field->strip + field->stripylim * w;
			/*---- We assume weight data have been read just before */
			//if (interpflag)
			//	wdata = wfield->strip + field->stripylim * w;

			/*---- copy to Check-image the "oldest" line before it is replaced */
			if ((flags & MEASURE_FIELD) && (check =
					prefs.check[CHECK_SUBOBJECTS]))
				writecheck(check, data, w);

			if (flags & BACKRMS_FIELD)
				backrmsline(field, field->ymax, data);
			else if (flags & INTERP_FIELD)
				copydata(field, field->stripylim * w, w);
			else
				read_body(tab, data, w);

			//if (flags & (WEIGHT_FIELD | RMS_FIELD | BACKRMS_FIELD | VAR_FIELD))
			//	weight_to_var(field, data, w);

			if ((flags & MEASURE_FIELD)
					&& (check = prefs.check[CHECK_IDENTICAL]))
				writecheck(check, data, w);
			/*---- Interpolate and subtract the background at current line */
			if (flags & (MEASURE_FIELD | DETECT_FIELD))
				subbackline(field, field->ymax, data);

			//if (interpflag)
			//	interpolate(field, wfield, data, wdata);
			/*---- Check-image stuff */
			if (prefs.check_flag) {
				if (flags & MEASURE_FIELD) {
					if ((check = prefs.check[CHECK_BACKGROUND]))
						writecheck(check, field->backline, w);
					if ((check = prefs.check[CHECK_SUBTRACTED]))
						writecheck(check, data, w);
					if ((check = prefs.check[CHECK_APERTURES]))
						writecheck(check, data, w);
					if ((check = prefs.check[CHECK_SUBPSFPROTOS]))
						writecheck(check, data, w);
					if ((check = prefs.check[CHECK_SUBPCPROTOS]))
						writecheck(check, data, w);
					if ((check = prefs.check[CHECK_SUBPROFILES]))
						writecheck(check, data, w);
				}
				if ((flags & DETECT_FIELD) && (check =
						prefs.check[CHECK_BACKRMS])) {
					backrmsline(field, field->ymax, (PIXTYPE *) check->pix);
					writecheck(check, (PIXTYPE*)(check->pix), w);
				}
			}
		} else
			read_ibody(tab, field->fstrip + field->stripylim * w, w);

		field->stripylim = (++field->ymin) % field->stripheight;
		if ((++field->ymax) < field->height)
			field->stripysclim = (++field->stripysclim) % field->stripheight;
	}

	return (flags ^ FLAG_FIELD) ?
			(void *) (field->strip + field->stripy * w) :
			(void *) (field->fstrip + field->stripy * w);
}