⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 g7to.c

📁 这是经典的卫星编程应用程序
💻 C
📖 第 1 页 / 共 5 页
字号:
	if( source != (char *) NULL )
		ch = source;

	/* For each character in the source string, see if it is a separator
	 * character.
	 */
	if(bump) ch+=bump;
	for( token = ch; *ch; ++ch ) {
		for( sep = separators; *sep; ++sep ) {

			/* look for a separator
			 */
			if( *ch == *sep ) {
				/* Got one, put a null there and move the
				 * saved source pointer up one for next time.
				 */
				*ch = 0;
				++ch;
				return token;
			}
		}
	}

	/* If nothing was found, then return nothing
	 * else return the token
	 */
	if( token == ch )
		return (char *) NULL;
	else
		return token;
} /* getstrings */

/* -------------------------------------------------------------------------- */
/***** hpcvmb:net.sources / dolphy!jmg /  2:55 pm  Oct 15, 1985*/
/**** RE: a program that stands up for America ***

It seems that the evil empire has struck again: there is no
strtok(3) in ucb UNIX, or 4.2 at least...and that means that
those of you who received typo(1), a program to prevent
typing errors caused by the red scourge, were left defenseless.

So, I've oil't down my body, built up my pecks, plugged a few
slant-eye commie automatons, donned the clothes of a middle-america
down home television minister and implemented strtok(3) according
to the specs of at&t 5.2 manual.  Here is its, caveats and all:
*/

/* strtok(3) (from the manual system 5.2):
 * char *strtok(s1,s2)
 * char *s1, *s2;
 *  strtok considers the string s1 to consist of a sequence
 * of zero or more text tokens separated by spans of one or more
 * characters from the separator string s2.  The first call (with
 * pointer s1 specified) returns a pointer to the first character of
 * the first token, and will have written a null character into s1
 * immediatlely following the returned token.  The function keeps
 * track of its position in the string between separate calls, so
 * that subsequent calls (which must be made with the first arguemtn
 * a NULL pointer) will work through the string s1 immediately
 * following that token.  In this way subsequent calls will work
 * through the string s1 until no tokens remain.  The separator
 * string s2 may be different from call to call.  When no token
 * remains in s1, a NULL pointer is returned.
 *
 * Below is my simulation of at&t unix 5.2 strtok(3) function for use
 * with the typo(1) program for ucb unix 4.2... I tried to make
 * it do what the description above says, but I didn't try very
 * hard...just enough for it to work with typo(1), which I
 * submitted a few days ago.  That is, it may be correct...but, I
 * haven't rigorously tested it... If it's adequate in general, tell me!
 * 
 * Jeffrey Greenberg ihnp4!allegra!phri!dolphy!jmg
 * Tue Oct 15 17:25:23 EDT 1985
 */
PROCX char *strtok3(char *source, char *separators )
{
	static char *ch;
	register char *sep, *token;

	/* if no source supplied, use the previous one.
	 */
	if( source != (char *) NULL )
		ch = source;

	/* For each character in the source string, see if it is a separator
	 * character.
	 */
	for( token = ch; *ch; ++ch ) {
		for( sep = separators; *sep; ++sep ) {

			/* look for a separator
			 */
			if( *ch == *sep ) {
				/* Got one, put a null there and move the
				 * saved source pointer up one for next time.
				 */
				*ch = 0;
				++ch;
				return token;
			}
		}
	}

	/* If nothing was found, then return nothing
	 * else return the token
	 */
	if( token == ch )
		return (char *) NULL;
	else
		return token;
} /* strtok3 */

/* -------------------------------------------------------------------------- */
// convert datums
PROCX void convert_datum(char *datum)
{
		if(strcmp(datum,"WGS-84") != 0) {
			datumconv(record.la,record.lo);
			record.la=LA;
			record.lo=LO;
			set_ns();
		}
}
/* -------------------------------------------------------------------------- */
PROCX char *latlongstr(void)
{
	static char bfr[50];
	double x,y;
	char *zone="           ";

	if(UTM) {
		UTMf=UTMf_out;
		UTMa=UTMa_out;
		DegToUTM(record.la,record.lo, zone, &x, &y);
		sprintf(bfr,"%s %9.1lf %10.1lf ",zone,x,y);
	}
	else {
		sprintf(bfr,"%s %s ",toDMlat(record.la),toDMlon(record.lo));
	}
	return bfr;
} // latlongstr

/* -------------------------------------------------------------------------- */
//  set_sign works when the values of record.ns and record.ew are correct
//    it sets the values of record.la (N+,S-), record.lo (E+,W-)
//
PROCX void set_sign(void)
{
	record.la=fabs(record.la);
	record.lo=fabs(record.lo);
	if(record.ns=='S') record.la=-record.la; // restore sign
	if(record.ew=='W') record.lo=-record.lo; // restore sign
} // set_sign(void)

/* -------------------------------------------------------------------------- */
//
// set_ns works when the sign of record.la and record.lo are correct.  It sets
//   the value of record.ns and record.ew
//
PROCX void set_ns(void)
{
	if(record.la<0.0) record.ns='S'; else record.ns='N';
	if(record.lo<0.0) record.ew='W'; else record.ew='E';
} // set_ns

/* -------------------------------------------------------------------------- */
PROCX void set_datetime(void)
{
/*
 * date/time
 */
		sprintf(record.datetime, "%s %s %02d %02d:%02d:%02d %04d", 
			days[dow(record.dayofmonth,record.monthn,record.year)],
			months[record.monthn], 
			record.dayofmonth, record.ht, record.mt, record.st,
			record.year);
} // set_datetime()

/* -------------------------------------------------------------------------- */
// when input a Ozi icon number.. this returns the Garmin icon type
PROCX INT convert_Garmin_to_Ozi(INT ict)
{
	INT i;

	i=0;
	while(Garmin_Symbol_Table[i].Garmin >=0) {
		if(Garmin_Symbol_Table[i].Garmin==ict) {
			if(G45out) { 
				if(Garmin_Symbol_Table[i].OziG>=0) return Garmin_Symbol_Table[i].OziG;
			}
			else  {
				if(Garmin_Symbol_Table[i].GM100>=0) return Garmin_Symbol_Table[i].GM100;
			}
			return 0;
		}
		i++;
	}
	return 0;
} // convert_Garmin_to_Ozi

/* -------------------------------------------------------------------------- */
//
//  When command line -1 is set and input is from Ozi output to the 12XL is
//   assumed.
PROCX INT convert_Ozi_to_12XL(INT ict)
{
	return convert_from_12xl(ict);
} // convert_Ozi_to_12XL

/* -------------------------------------------------------------------------- */
//
//  When command line -1 is set and input is from Ozi output to the 12XL is
//   assumed.
PROCX INT convert_12XL_to_Ozi(INT ict)
{
	return convert_to_12xl(ict);
} // convert_12XL_to_Ozi

/* -------------------------------------------------------------------------- */
// when input a Ozi icon number.. this returns the Garmin icon type
PROCX INT convert_Ozi_to_Garmin(INT ict)
{
	INT i;

	i=0;
	while(Garmin_Symbol_Table[i].Garmin >=0) {
		if(G45out) {
			if(Garmin_Symbol_Table[i].OziG==ict) return Garmin_Symbol_Table[i].Garmin;
		}
		else {
			if(Garmin_Symbol_Table[i].GM100==ict) return Garmin_Symbol_Table[i].Garmin;
		}
		i++;
	}
	return default_Garmin_icon;
} // convert_Ozi_to_Garmin

/* -------------------------------------------------------------------------- */
// when input a 12xl icon type this returns the internal icon type
PROCX INT convert_from_12xl(INT ict)
{
	INT i;

	i=0;
	while(Garmin_Symbol_Table[i].Garmin>=0) {
		if(Garmin_Symbol_Table[i].XL==ict) return Garmin_Symbol_Table[i].Garmin;
		i++;
	}
	return default_Garmin_icon;
} // convert_from_12xl

/* -------------------------------------------------------------------------- */
// when input a Garmin icon type this returns the 12XL icon type
PROCX INT convert_to_12xl(INT ict)
{
	INT i;

	i=0;
	while(Garmin_Symbol_Table[i].Garmin>=0) {
		if(Garmin_Symbol_Table[i].Garmin==ict) return Garmin_Symbol_Table[i].XL;
		i++;
	}
	return default_G12_icon;
} // convert_to_12xl

/* -------------------------------------------------------------------------- */
// when input a Lowr icon type this returns the internal icon type
PROCX INT convert_from_Lowr(INT ict)
{
	INT i;
	
	i=0;
	while(Garmin_Symbol_Table[i].Garmin>=0) {
		if(Garmin_Symbol_Table[i].GM100==ict) return Garmin_Symbol_Table[i].Garmin;
		i++;
	}
	return default_Garmin_icon;
} // convert_from_Lowr

static INT xm(INT i, INT j)
{
	div_t x;

	x=div(i,j);
	return x.rem;
}

PROCX INT convert_to_Lowr(INT ict)
{
	INT i;

	i=0;
	while(Garmin_Symbol_Table[i].Garmin>=0) {
		if(Garmin_Symbol_Table[i].Garmin==ict)  {
			if(Garmin_Symbol_Table[i].GM100==(-1)) return default_LWR_icon;
			return xm(Garmin_Symbol_Table[i].GM100,LowrID.NumOfIconSym);
		}
		i++;
	}
	return default_LWR_icon;
} // convert_to_Lowr

/* -------------------------------------------------------------------------- */
// simple bubble sort from Grogono
PROCX void sortit(char **a, int *items)
{
	INT jump,m,n,alldone,len;
	char *temp,*p1,*p2;
	char t1[MAX_LENGTH], t2[MAX_LENGTH];
	char name1[50],name2[50];
//	char lat1[50],lat2[50],lon1[50],lon2[50];

	jump=len=*items;
	while(jump>1) {
		jump=jump/2;
		do {
			alldone=1;
			for(m=1;m<=(len-jump);m++) {
				n=m+jump;
				strcpy(t1,a[m]);
				strcpy(t2,a[n]);
				p1=strtok3(t1,";");
				p1=strtok3(NULL,";");
				p1=strtok3(NULL,";");
				p2=strtok3(t2,";");
				p2=strtok3(NULL,";");
				p2=strtok3(NULL,";");
				if(strcmp(p1,p2)>0) {
					temp=a[m];
					a[m]=a[n];
					a[n]=temp;
					alldone=0;
				}
			}
		} while(alldone!=1);
	} /* while(jump>1) */
/*
 * a pseudo unique function
 */
doitagain:;
 	for(m=1;m<len;m++) {
		strcpy(t1,a[m]);
		strcpy(t2,a[m+1]);

		p1=strtok3(t1,";");
		p1=strtok3(NULL,";");
		p1=strtok3(NULL,";");
		strcpy(name1,p1);
//		p1=strtok3(NULL,";");
//		p1=strtok3(NULL,"!");
//		p1=strtok3(NULL,";");
//		strcpy(lat1,p1);
//		p1=strtok3(NULL,";");
//		strcpy(lon1,p1);

		p2=strtok3(t2,";");
		p2=strtok3(NULL,";");
		p2=s

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -