Beispiel #1
0
void ResetClass(/*InOut*/class_struct *c)
{

//
// Reset numerical data by setting to zero
//
    c->active_class = 0;
    c->hours = c->grade_points=0;

//
// Reset string data by clearing the strings
//
    ClearString(c->course_number);
    ClearString(c->dept_name);
    ClearString(c->grade);
}
Beispiel #2
0
 /* bo5-52.c 广义表的书写形式串为HString类型 */
 #include"c4-2.h" /* 定义HString类型 */
 #include"bo4-2.c" /* HString类型的基本操作 */
 Status sever(HString *str,HString *hstr)
 { /* 将非空串str分割成两部分:hstr为第一个','之前的子串,str为之后的子串 */
   int n,i=1,k=0; /* k记尚未配对的左括号个数 */
   HString ch,c1,c2,c3;
   InitString(&ch); /* 初始化HString类型的变量 */
   InitString(&c1);
   InitString(&c2);
   InitString(&c3);
   StrAssign(&c1,",");
   StrAssign(&c2,"(");
   StrAssign(&c3,")");
   n=StrLength(*str);
   do
   {
     SubString(&ch,*str,i,1);
     if(!StrCompare(ch,c2))
       ++k;
     else if(!StrCompare(ch,c3))
       --k;
     ++i;
   }while(i<=n&&StrCompare(ch,c1)||k!=0);
   if(i<=n)
   {
     StrCopy(&ch,*str);
     SubString(hstr,ch,1,i-2);
     SubString(str,ch,i,n-i+1);
   }
   else
   {
     StrCopy(hstr,*str);
     ClearString(str);
   }
   return OK;
 }
Beispiel #3
0
void Insert()
{
	int l, m;
	int i;

	printf("input lines input and line No. m insert to :");
	scanf("%d,%d", &l, &m);

	if (l+m>MAX_LEN || l <= 0) {
		printf("invalid insert lines\n");
		return;
	}

	for (i=n;i>=l;i--) {
		T[i+m] = T[i];
	}

	printf("input the lines: \n");
	while (m > 0) {
//		fgets(str, fp);
//		scanf("%s", str);
		gets(str);
		ClearString(&T[l]);
		StrAssign(&T[l], str);
		l++;
	}
	n+=m;
}
 /* bo5-51.c 广义表的书写形式串为SString类型 */
 #include "../ch4/c4-1.h" /* 定义SString类型 */
 #include "../ch4/bo4-1.c" /* SString类型的基本操作 */
 void sever(SString str,SString hstr) /* 算法5.8  SString是数组,不需引用类型 */
 { /* 将非空串str分割成两部分:hsub为第一个','之前的子串,str为之后的子串 */
   int n,k,i; /* k记尚未配对的左括号个数 */
   SString ch,c1,c2,c3;
   n=StrLength(str);
   StrAssign(c1,",");
   StrAssign(c2,"(");
   StrAssign(c3,")");
   SubString(ch,str,1,1);
   for(i=1,k=0;i<=n&&StrCompare(ch,c1)||k!=0;++i)
   { /* 搜索最外层的第一个逗号 */
     SubString(ch,str,i,1);
     if(!StrCompare(ch,c2))
       ++k;
     else if(!StrCompare(ch,c3))
       --k;
   }
   if(i<=n)
   {
     SubString(hstr,str,1,i-2);
     SubString(str,str,i,n-i+1);
   }
   else
   {
     StrCopy(hstr,str);
     ClearString(str);
   }
 }
Beispiel #5
0
void ClearAllGC()
{
    unsigned int index;
    /* contexts */
    for (index = 0;
         index < gGCManager.ctx_size;
         index++)
    {
        CONTEXT* context = gGCManager.contexts[index];
        ClearContext(context);
    }

    /* functions */
    for (index = 0;
         index < gGCManager.func_size;
         index++)
    {
        FUNCTION* function = gGCManager.functions[index];
        ClearFunction(function);
    }

    /* dictionaries */
    for (index = 0;
         index < gGCManager.table_size;
         index++)
    {
        HASH_TABLE* table = gGCManager.tables[index];
        ClearDictionary(table);
    }

    /* strings */
    for (index = 0;
         index < gGCManager.str_size;
         index++)
    {
        char* string = gGCManager.strings[index];
        ClearString(string);
    }

    /* parse tree */
    AST_STORE *cur_ast, *next_ast;
    cur_ast = gGCManager.parseTrees;
    while (cur_ast) {
        next_ast = cur_ast->next;
        FreeParseTree(cur_ast->parseTree);
        free(cur_ast);
        cur_ast = next_ast;
    }

    /* lexings */
    LEXING_STORE *cur_lex, *next_lex;
    cur_lex = gGCManager.lexings;
    while (cur_lex) {
        next_lex = cur_lex->next;
        FreeLexing(cur_lex->tokens, cur_lex->buffer);
        free(cur_lex);
        cur_lex = next_lex;
    }
}
Beispiel #6
0
static int StrInit(HString *hstr, int len){
    ClearString(hstr);

    hstr->len = len;
    hstr->ch = (char *)malloc(hstr->len);
    memset(hstr->ch, '\0', hstr->len);

    return 1;
}
void main()
{
	int i;
	char c, *p = "God bye!", *q = "God luck!";
	HString t, s, r;

	InitString(t);
	InitString(s);
	InitString(r);
	StrAssign(t, p);
	printf("串t为");
	StrPrint(t);
	printf("串长为%d,串空否?%d(1:空 0:否)\n", StrLength(t), StrEmpty(t));
	StrAssign(s, q);
	printf("串s为");
	StrPrint(s);
	i = StrCompare(s, t);
	if (i < 0)
		c = '<';
	else if (i == 0)
		c = '=';
	else
		c = '>';
	printf("串s%c串t\n", c);
	Concat(r, t, s);
	printf("串t连接串s产生的串r为");
	StrPrint(r);
	StrAssign(s, "oo");
	printf("串s为");
	StrPrint(s);
	StrAssign(t, "o");
	printf("串t为");
	StrPrint(t);
	Replace(r, t, s);
	printf("把串r中和串t相同的子串用串s代替后,串r为");
	StrPrint(r);
	ClearString(s);
	printf("串s清空后,串长为%d,空否?%d(1:空 0:否)\n", StrLength(s), StrEmpty(s));
	SubString(s, r, 6, 4);
	printf("串s为从串r的第6个字符起的4个字符,长度为%d,串s为", s.length);
	StrPrint(s);
	StrCopy(t, r);
	printf("由串r复制得串t,串t为");
	StrPrint(t);
	StrInsert(t, 6, s);
	printf("在串t的第6个字符前插入串s后,串t为");
	StrPrint(t);
	StrDelete(t, 1, 5);
	printf("从串t的第1个字符起删除5个字符后,串t为");
	StrPrint(t);
	printf("%d是从串t的第1个字符起,和串s相同的第1个子串的位置\n", Index(t, s, 1));
	printf("%d是从串t的第2个字符起,和串s相同的第1个子串的位置\n", Index(t, s, 2));
	DestroyString(t);
}
Beispiel #8
0
int StrCopy(HString *dst, HString *src)
{
    if(StrEmpty(src)){ 
        ClearString(dst);
        return 1; 
    }
    
    StrInit(dst, src->len);

    memcpy(dst->ch, src->ch, src->len);
    return 1;
}
Beispiel #9
0
bool IniParser::LoadFromFile(const std::string& filename)
{
    std::ifstream file(filename.c_str());
    if (file)
    {
        std::string line;
        Section* section = NULL;
        while (std::getline(file, line))
        {
            ClearString(line);
            if (line.size() > 0)
            {
                // look for sections
                if (line[0] == TOKEN_START_SECTION)
                {
                    // extract section name
                    size_t index = line.find(TOKEN_END_SECTION);
                    line = line.substr(1, index - 1);
                    section = &entries_[line];
                }
                else if (section != NULL)
                {
                    size_t index = line.find(TOKEN_SEPARATOR);
                    if (index != std::string::npos)
                    {
                        std::string key = line.substr(0, index);
                        ClearString(key);
                        std::string value = line.substr(index + 1);
                        ClearString(value);
                        (*section)[key] = value;
                    }
                }
            }
        }
        file.close();
        return true;
    }
    std::cerr << "cannot open file: " << filename << std::endl;
    return false;
}
Beispiel #10
0
void main()
{
  int i;
  char c,*p="God bye!",*q="God luck!";
  HString t,s,r;
  InitString(&t); /* HString类型必需初始化 */
  InitString(&s);
  InitString(&r);
  StrAssign(&t,p);
  printf("串t为: ");
  StrPrint(t);
  printf("串长为%d 串空否?%d(1:空 0:否)\n",StrLength(t),StrEmpty(t));
  StrAssign(&s,q);
  printf("串s为: ");
  StrPrint(s);
  i=StrCompare(s,t);
  if(i<0)
    c='<';
  else if(i==0)
    c='=';
  else
    c='>';
  printf("串s%c串t\n",c);
  Concat(&r,t,s);
  printf("串t联接串s产生的串r为: ");
  StrPrint(r);
  StrAssign(&s,"oo");
  printf("串s为: ");
  StrPrint(s);
  StrAssign(&t,"o");
  printf("串t为: ");
  StrPrint(t);
  Replace(&r,t,s);
  printf("把串r中和串t相同的子串用串s代替后,串r为:\n");
  StrPrint(r);
  ClearString(&s);
  printf("串s清空后,串长为%d 空否?%d(1:空 0:否)\n",StrLength(s),StrEmpty(s));
  SubString(&s,r,6,4);
  printf("串s为从串r的第6个字符起的4个字符,长度为%d 串s为: ",s.length);
  StrPrint(s);
  StrCopy(&t,r);
  printf("复制串t为串r,串t为: ");
  StrPrint(t);
  StrInsert(&t,6,s);
  printf("在串t的第6个字符前插入串s后,串t为: ");
  StrPrint(t);
  StrDelete(&t,1,5);
  printf("从串t的第1个字符起删除5个字符后,串t为: ");
  StrPrint(t);
  printf("%d是从串t的第1个字符起,和串s相同的第1个子串的位置\n",Index(t,s,1));
  printf("%d是从串t的第2个字符起,和串s相同的第1个子串的位置\n",Index(t,s,2));
}
Beispiel #11
0
void ResetStudent(/*InOut*/student_struct *s)
{
   int j = 0; // Loop variable

//
// Reset all numerical data by setting to zero
//
    s->active_student = 0;
    s->hoursCom_current = s->hoursCom_total = 0;
    s->gpa_current = s->gpa_total = 0.00;

//
// Reset all string data by clearing the strings
//
    ClearString(s->number);
    ClearString(s->name);
    ClearString(s->year);
    ClearString(s->major);

//
// Reset all classes by running loop to reset each class
//
    while(j < MAX_CLASSES_STUDENT)ResetClass(&s->classes[j++]);
}
Beispiel #12
0
void read_header(int cfd)
{
    int buf_size = BS;
    char *buf = NULL;
    char *line = NULL;

    int i = 0 ;

    int rlen = 0;

    FILE *fp = fdopen(cfd, "r") ;

    HString hs = {NULL, 0};
    
    buf = (char *)malloc(buf_size+1);

    while(1){

        memset(buf, '\0', buf_size);
        ClearString(&hs);

        while(fgets(buf, buf_size, fp)){
            StrAppend(&hs, buf);
            int _rlen = strlen(buf);
            if(buf[_rlen-1]=='\n')
                break;
        }
        
        ToString(&hs, &line);

        if(strncmp("\r\n",line,2)==0){
            printf("END \n");
            break;
        }

        if(strlen(line)<=0)
            break;
        
        printf("%s", line);
        parse_line(line);
    }

    printf("the request info is %d,%s,%s\n", req_info.method, req_info.file, req_info.host);

}
Beispiel #13
0
 void Save()
 { // 存盘
   int i,j;
   fp=fopen(filename,"w"); // 以写的方式重新打开文件
   if(fp) // 打开文件成功
   {
     for(i=0;i<n;i++)
     { // 依次将每行存入文件
       for(j=0;j<T[i].length;j++) // 依次存入每个字符
         fputc(T[i].ch[j],fp);
       fputc(10,fp); // 存入换行符
       ClearString(T[i]); // 释放串空间
     }
     fclose(fp); // 关闭文件
   }
   else
     printf("存盘失败\n");
 }
Beispiel #14
0
void ICPClass::ChangeToCNI(void)
{
	AircraftClass *playerAC = SimDriver.GetPlayerAircraft();

	ResetSubPages();
	if (playerAC && playerAC->FCC)
	{
		playerAC->FCC->SetStptMode(FireControlComputer::FCCWaypoint);
		playerAC->FCC->waypointStepCmd = 127;
	}
	ClearFlags();
	ClearStrings();
	ClearString();
	ClearDigits();
	ClearCount = 0;
	InputsMade = 0;
	SetICPFlag(ICPClass::MODE_CNI);
	SetICPFlag(ICPClass::EDIT_STPT);
	LaserLine = 1;
}
Beispiel #15
0
 void Zip(LString *S)
 { /* 压缩串(清除块中不必要的填补空余的字符)。加 */
   int j,n=0;
   Chunk *h=(*S).head;
   char *q;
   q=(char*)malloc(((*S).curlen+1)*sizeof(char));
   while(h) /* 将LString类型的字符串转换为char[]类型的字符串 */
   {
     for(j=0;j<CHUNKSIZE;j++)
       if(*(h->ch+j)!=blank)
       {
         *(q+n)=*(h->ch+j);
         n++;
       }
     h=h->next;
   }
   *(q+n)=0; /* 串结束符 */
   ClearString(S); /* 清空S */
   StrAssign(S,q); /* 重新生成S */
 }
Beispiel #16
0
 static void Zip(LString &S)
 { // 压缩串(清除块中不必要的填补空余的字符)。加
   int j,n=0;
   Chunk *h=S.head;
   char *q;
   q=(char*)malloc((S.curlen+1)*sizeof(char));
   while(h) // 将LString类型的字符串转换为char[]类型的字符串
   {
     for(j=0;j<CHUNKSIZE;j++)
       if(*(h->ch+j)!=blank)
       {
         *(q+n)=*(h->ch+j);
         n++;
       }
     h=h->next;
   }
   *(q+n)=0; // 串结束符
   ClearString(S); // 清空S
   StrAssign(S,q); // 重新生成S
 }
Beispiel #17
0
void Delete()
{
	int l, m;
	int i;

	printf("input delete from line l, and totol line number m: ");
	scanf("%d,%d", &l, &m);

	if (l < 1 || l + m > n) {
		printf("invalid delete number\n");
		return;
	}

	for (i = l + m; i < n; ++i) {
		T[i-m] = T[i];
	}

	for (i = n - m; i < n; i++)
		ClearString(&T[i]);

	n -= m;
}
Beispiel #18
0
jc_void PopGotoTable(CJcGotoStack * pStack)
{
	jc_uint i;
	CJcGoto* pGoto;
	CJcGotoTable *pPrev, * pTable;

	pTable = pStack->pGotoTable;
	if(pTable)
	{
		pPrev = pTable->pPrev;
		DestroyHashTable(pTable->pLabelTable);
		if(pTable->pGotoTable)
		{
			for(i=0; i<pTable->nCount; ++i)
			{
				pGoto = pTable->pGotoTable+i;
				ClearString(&pGoto->oLabelName);
			}
			g_oInterface.Free(pTable->pGotoTable);
		}
		g_oInterface.Free(pTable);
		pStack->pGotoTable = pPrev;
	}
}
Beispiel #19
0
 void main()
 {
   char *s1="ABCDEFGHI",*s2="12345",*s3="",*s4="asd#tr",*s5="ABCD";
   Status k;
   int pos,len;
   LString t1,t2,t3,t4;
   InitString(&t1);
   InitString(&t2);
   printf("初始化串t1后,串t1空否?%d(1:空 0:否) 串长=%d\n",StrEmpty(t1),StrLength(t1));
   k=StrAssign(&t1,s3);
   if(k==OK)
   {
     printf("串t1为: ");
     StrPrint(t1);
   }
   else
     printf("出错\n"); /* 不能生成空串 */
   k=StrAssign(&t1,s4);
   if(k==OK)
   {
     printf("串t1为: ");
     StrPrint(t1);
   }
   else
     printf("出错\n"); /* 不能生成含有变量blank所代表的字符的串 */
   k=StrAssign(&t1,s1);
   if(k==OK)
   {
     printf("串t1为: ");
     StrPrint(t1);
   }
   else
     printf("出错\n");
   printf("串t1空否?%d(1:空 0:否) 串长=%d\n",StrEmpty(t1),StrLength(t1));
   StrAssign(&t2,s2);
   printf("串t2为: ");
   StrPrint(t2);
   StrCopy(&t3,t1);
   printf("由串t1拷贝得到串t3,串t3为: ");
   StrPrint(t3);
   InitString(&t4);
   StrAssign(&t4,s5);
   printf("串t4为: ");
   StrPrint(t4);
   Replace(&t3,t4,t2);
   printf("用t2取代串t3中的t4串后,串t3为: ");
   StrPrint(t3);
   ClearString(&t1);
   printf("清空串t1后,串t1空否?%d(1:空 0:否) 串长=%d\n",StrEmpty(t1),StrLength(t1));
   Concat(&t1,t2,t3);
   printf("串t1(=t2+t3)为: ");
   StrPrint(t1);
   Zip(&t1);
   printf("去除不必要的占位符后,串t1为: ");
   StrPrint(t1);
   pos=Index(t1,t3,1);
   printf("pos=%d\n",pos);
   printf("在串t1的第pos个字符之前插入串t2,请输入pos: ");
   scanf("%d",&pos);
   k=StrInsert(&t1,pos,t2);
   if(k)
   {
     printf("插入串t2后,串t1为: ");
     StrPrint(t1);
   }
   else
     printf("插入失败!\n");
   printf("求从t1的第pos个字符起,长度为len的子串t2,请输入pos,len: ");
   scanf("%d,%d",&pos,&len);
   SubString(&t2,t1,pos,len);
   printf("串t2为: ");
   StrPrint(t2);
   printf("StrCompare(t1,t2)=%d\n",StrCompare(t1,t2));
   printf("删除串t1中的子字符串:从第pos个字符起删除len个字符。请输入pos,len:");
   scanf("%d,%d",&pos,&len);
   k=StrDelete(&t1,pos,len);
   if(k)
   {
     printf("从第%d位置起删除%d个元素后串t1为:",pos,len);
     StrPrint(t1);
   }
 }
Beispiel #20
0
void test()
{
	char ch[2][255];
	int i=0,pos=1;
	CString S[2],T;

	InitString(S[0]);
	InitString(S[1]);
	InitString(T);

	for(i=0;i<2;i++)
	{
		printf("ÊäÈë×Ö·û´®%d:",i+1);
		scanf("%s",ch[i]);
		StrAssign(S[i],ch[i]);
	}

	for(i=0;i<2;i++)
	{
		printf("Êä³ö×Ö·û´®%d:",i+1);
		StrPrint(S[i]);
		printf("×Ö·ûÊÇ·ñΪ¿Õ%d(1-·Ç 0-¿Õ),×Ö·û´®³¤¶È:%d\n",!StrEmpty(S[i]),StrLength(S[i]));
	}

	printf("---Á¬½Ó´®--\n");
	Concat(T,S[0],S[1]);
	printf("Á¬½Óºó:");
	StrPrint(T);
	
	printf("---Çó×Ó´®---\n");
	printf("ÊäÈë×Ö´®:");
	scanf("%s",ch[0]);
	printf("ÊäÈë²éÕÒλÖÃ:");
	scanf("%d",&pos);
	StrAssign(S[0],ch[0]);
	i=Index(T,S[0],pos);
	printf("²éÕÒµ½µÄλÖÃ:%d\n",i);

	printf("ɾ³ý%sºó:",ch[0]);
	if(i)
		StrDelete(T,i,S[0].length);
	StrPrint(T);

	printf("²åÈë%sºó:",ch[0]);
	if(i)
		StrInsert(T,S[0],i);
	StrPrint(T);

	printf("---Ìæ´ú---\n");
	printf("ÊäÈëÌæ´úµÄ×Ó´®:");
	scanf("%s",ch[1]);
	printf("Ìæ»»%sºó:",ch[0]);
	StrAssign(S[1],ch[1]);
	Replace(T,S[0],S[1]);
	StrPrint(T);

	printf("±È½Ï×Ö·û´®:S%d%cS%d\n",1,StrCompare(S[0],S[1])>0?'>':StrCompare(S[0],S[1])<0?'<':'=',2);
	StrCopy(S[0],S[1]);
	printf("---¸´Öƺó---\n");
	for(i=0;i<2;i++)
	{
		printf("Êä³ö×Ö·û´®%d:",i+1);
		StrPrint(S[i]);
		printf("×Ö·ûÊÇ·ñΪ¿Õ%d(1-·Ç 0-¿Õ),×Ö·û´®³¤¶È:%d\n",!StrEmpty(S[i]),StrLength(S[i]));
	}
	printf("±È½Ï×Ö·û´®:S%d%cS%d\n",1,StrCompare(S[0],S[1])>0?'>':StrCompare(S[0],S[1])<0?'<':'=',2);

	ClearString(S[0]);
	ClearString(S[1]);
	ClearString(T);
}
int main()
{

    int i,j;
    Status k;
    char s;
    String t,s1,s2;
    printf("请输入串s1: ");

    k=StrAssign(s1,"abcd");
    if(!k)
    {
        printf("串长超过MAXSIZE(=%d)\n",MAXSIZE);
        exit(0);
    }
    printf("串长为%d 串空否?%d(1:是 0:否)\n",StrLength(s1),StrEmpty(s1));
    StrCopy(s2,s1);
    printf("拷贝s1生成的串为: ");
    StrPrint(s2);
    printf("请输入串s2: ");

    k=StrAssign(s2,"efghijk");
    if(!k)
    {
        printf("串长超过MAXSIZE(%d)\n",MAXSIZE);
        exit(0);
    }
    i=StrCompare(s1,s2);
    if(i<0)
        s='<';
    else if(i==0)
        s='=';
    else
        s='>';
    printf("串s1%c串s2\n",s);
    k=Concat(t,s1,s2);
    printf("串s1联接串s2得到的串t为: ");
    StrPrint(t);
    if(k==FALSE)
        printf("串t有截断\n");
    ClearString(s1);
    printf("清为空串后,串s1为: ");
    StrPrint(s1);
    printf("串长为%d 串空否?%d(1:是 0:否)\n",StrLength(s1),StrEmpty(s1));
    printf("求串t的子串,请输入子串的起始位置,子串长度: ");

    i=2;
    j=3;
    printf("%d,%d \n",i,j);

    k=SubString(s2,t,i,j);
    if(k)
    {
        printf("子串s2为: ");
        StrPrint(s2);
    }
    printf("从串t的第pos个字符起,删除len个字符,请输入pos,len: ");

    i=4;
    j=2;
    printf("%d,%d \n",i,j);


    StrDelete(t,i,j);
    printf("删除后的串t为: ");
    StrPrint(t);
    i=StrLength(s2)/2;
    StrInsert(s2,i,t);
    printf("在串s2的第%d个字符之前插入串t后,串s2为:\n",i);
    StrPrint(s2);
    i=Index(s2,t,1);
    printf("s2的第%d个字母起和t第一次匹配\n",i);
    SubString(t,s2,1,1);
    printf("串t为:");
    StrPrint(t);
    Concat(s1,t,t);
    printf("串s1为:");
    StrPrint(s1);
    Replace(s2,t,s1);
    printf("用串s1取代串s2中和串t相同的不重叠的串后,串s2为: ");
    StrPrint(s2);


    return 0;
}
void ICPClass::ScratchPad(int Line, int Start, int End)
{
	AircraftClass *playerAC = SimDriver.GetPlayerAircraft();
	//ILS page
	if(IsICPSet(ICPClass::MODE_CNI) && mICPSecondaryMode == ONE_BUTTON)
	{
		if(Manual_Input)
		{
			if(Input_Digit7 < 10)
				InputString[2] = '0' + Input_Digit7;
			else
				InputString[2] = ' ';
			if(Input_Digit6 < 10)
				InputString[1] = '0' + Input_Digit6;
			else 
				InputString[1] = ' ';
			if(Input_Digit5 < 10)
				InputString[0] = '0' + Input_Digit5;
			else
				InputString[0] = ' ';
			InputString[3] = '\0';
		}
		else
		{
			ClearString();
			InputString[3] = '\0';
		}
	}
	//Bingo Page
	else if(IsICPSet(ICPClass::MODE_LIST) && mICPSecondaryMode == TWO_BUTTON)
	{
		if(!Manual_Input)
		{
			level = (long)((AircraftClass*)(playerAC))->GetBingoFuel();
			if(level < 10000)
				sprintf(InputString," %dLBS",level);
			else 
				sprintf(InputString,"%dLBS",level);
		}
		else
		{
			InputString[5] = 'L';
			InputString[6] = 'B';
			InputString[7] = 'S';
			if(Input_Digit7 < 10)
				InputString[4] = '0' + Input_Digit7;
			else
				InputString[4] = ' ';
			if(Input_Digit6 < 10)
				InputString[3] = '0' + Input_Digit6;
			else 
				InputString[3] = ' ';
			if(Input_Digit5 < 10)
				InputString[2] = '0' + Input_Digit5;
			else
				InputString[2] = ' ';
			if(Input_Digit4 < 10)
				InputString[1] = '0' + Input_Digit4;
			else
				InputString[1] = ' ';
			if(Input_Digit3 < 10)
				InputString[0] = '0' + Input_Digit3;
			else
				InputString[0] = ' ';
		}
		InputString[8] = '\0';
	}
	else if(IsICPSet(ICPClass::MODE_CNI) && mICPSecondaryMode == TWO_BUTTON)
	{
		if(!Manual_Input)
		{
			if(EDITMSLFLOOR)
				sprintf(InputString,"%dFT",TheHud->MSLFloor);
			else if(TFADV)
				sprintf(InputString,"%dFT",TheHud->TFAdv);
			else
			{
				if(EDITMSLFLOOR);
				else if(TFADV);
				else
				{
					long	alt;
					int	alt1, alt2;
					char	tmpstr[5] = "";
					alt = (long)TheHud->lowAltWarning;

					alt1 = (int) alt / 1000;
					alt2 = (int) alt % 1000;

					if(alt1) 
					{
						sprintf(tmpstr, "%-3d", alt2);
						if(alt2 < 100) 
							tmpstr[0] = '0';
						if(alt2 < 10)
							tmpstr[1] = '0';
						if(alt2 < 1)
							tmpstr[2] = '0';
						sprintf(InputString, "%-d%sFT", alt1, tmpstr);
					} 
					else
						sprintf(InputString, "%dFT", alt2);
				}
			}
		}
		else
		{
			InputString[7] = '\0';
			InputString[6] = 'T';
			InputString[5] = 'F';
			if(Input_Digit7 < 10)
				InputString[4] = '0' + Input_Digit7;
			else
				InputString[4] = ' ';
			if(Input_Digit6 < 10)
				InputString[3] = '0' + Input_Digit6;
			else 
				InputString[3] = ' ';
			if(Input_Digit5 < 10)
				InputString[2] = '0' + Input_Digit5;
			else
				InputString[2] = ' ';
			if(Input_Digit4 < 10)
				InputString[1] = '0' + Input_Digit4;
			else
				InputString[1] = ' ';
			if(Input_Digit3 < 10)
				InputString[0] = '0' + Input_Digit3;
			else
				InputString[0] = ' ';
		}
	}
	else if((IsICPSet(ICPClass::EDIT_LAT) || IsICPSet(ICPClass::EDIT_LONG)) && Manual_Input)
	{
		InputString[10] = '\0';
		InputString[9] = '\'';
		if(Input_Digit7 < 10)
			InputString[8] = '0' + Input_Digit7;
		else
			InputString[8] = '0';
		if(Input_Digit6 < 10)
			InputString[7] = '0' + Input_Digit6;
		else 
			InputString[7] = '0';
		InputString[6] = '.';
		if(Input_Digit5 < 10)
			InputString[5] = '0' + Input_Digit5;
		else
			InputString[5] = '0';
		if(Input_Digit4 < 10)
			InputString[4] = '0' + Input_Digit4;
		else
			InputString[4] = '0';
		InputString[3] = '*'; //this is a ° symbol
		if(Input_Digit3 < 10)
			InputString[2] = '0' + Input_Digit3;
		else
			InputString[2] = '0';
		if(Input_Digit2 < 10)
			InputString[1] = '0' + Input_Digit2;
		else
			InputString[1] = '0';
		if(IsICPSet(ICPClass::EDIT_LAT) && Manual_Input)
		{
			if(Input_Digit1 < 10)
				InputString[0] = '0' + Input_Digit1;
			else
				InputString[0] = '0';
		}
		else
			InputString[0] = ' ';
	}
	else if(IsICPSet(ICPClass::MODE_LIST) && mICPSecondaryMode == FIFE_BUTTON)
	{
		if(Manual_Input)
		{
			InputString[5] = '\0';
			InputString[3] = 'F';
			InputString[4] = 'T';
			if(Input_Digit7 < 10)
				InputString[2] = '0' + Input_Digit7;
			else
				InputString[2] = ' ';
			if(Input_Digit6 < 10)
				InputString[1] = '0' + Input_Digit6;
			else 
				InputString[1] = ' ';
			if(Input_Digit5 < 10)
				InputString[0] = '0' + Input_Digit5;
			else
				InputString[0] = ' ';
			
		}
		else
			sprintf(InputString,"%3.0fFT",ManualWSpan);
	}
	//INS page
	else if(IsICPSet(ICPClass::MODE_LIST) && mICPSecondaryMode == SIX_BUTTON && Manual_Input)
	{
		if(INSLine == 0)
		{
			//LAT String
			InputString[10] = '\0';
			InputString[9] = '\'';
			if(Input_Digit7 < 10)
				InputString[8] = '0' + Input_Digit7;
			else
				InputString[8] = '0';
			if(Input_Digit6 < 10)
				InputString[7] = '0' + Input_Digit6;
			else 
				InputString[7] = '0';
			InputString[6] = '.';
			if(Input_Digit5 < 10)
				InputString[5] = '0' + Input_Digit5;		
			else
				InputString[5] = '0';
			if(Input_Digit4 < 10)
				InputString[4] = '0' + Input_Digit4;
			else
				InputString[4] = '0';
			InputString[3] = '*'; //this is a ° symbol
			if(Input_Digit3 < 10)
				InputString[2] = '0' + Input_Digit3;
			else
				InputString[2] = '0';
			if(Input_Digit2 < 10)
				InputString[1] = '0' + Input_Digit2;
			else
				InputString[1] = '0';
		}
		else if(INSLine == 1)
		{
			//LONG String
			InputString[10] = '\0';
			InputString[9] = '\'';
			if(Input_Digit7 < 10)
				InputString[8] = '0' + Input_Digit7;
			else
				InputString[8] = '0';
			if(Input_Digit6 < 10)
				InputString[7] = '0' + Input_Digit6;
			else 
				InputString[7] = '0';
			InputString[6] = '.';
			if(Input_Digit5 < 10)
				InputString[5] = '0' + Input_Digit5;
			else
				InputString[5] = '0';
			if(Input_Digit4 < 10)
				InputString[4] = '0' + Input_Digit4;
			else
				InputString[4] = '0';
			InputString[3] = '*'; //this is a ° symbol
			if(Input_Digit3 < 10)
				InputString[2] = '0' + Input_Digit3;
			else
				InputString[2] = '0';
			if(Input_Digit2 < 10)
				InputString[1] = '0' + Input_Digit2;
			else
				InputString[1] = '0';
			if(Input_Digit1 < 10)
				InputString[0] = '0' + Input_Digit1;
			else
				InputString[0] = '0';
		}
		else if(INSLine == 2)
		{
			//ALT String
			InputString[7] = '\0';
			InputString[6] = 'T';
			InputString[5] = 'F';
			if(Input_Digit7 < 10)
				InputString[4] = '0' + Input_Digit7;
			else
				InputString[4] = ' ';
			if(Input_Digit6 < 10)
				InputString[3] = '0' + Input_Digit6;
			else 
				InputString[3] = ' ';
			if(Input_Digit5 < 10)
				InputString[2] = '0' + Input_Digit5;
			else
				InputString[2] = ' ';
			if(Input_Digit4 < 10)
				InputString[1] = '0' + Input_Digit4;
			else
				InputString[1] = ' ';
			if(Input_Digit3 < 10)
				InputString[0] = '0' + Input_Digit3;
			else
				InputString[0] = ' ';
		}
		else if(INSLine == 3)
		{
			//THDG String
			InputString[6] = '\0';
			InputString[5] = '*';
			if(Input_Digit7 < 10)
				InputString[4] = '0' + Input_Digit7;
			else
				InputString[4] = ' ';
			InputString[3] = '.';
			if(Input_Digit6 < 10)
				InputString[2] = '0' + Input_Digit6;
			else
				InputString[2] = ' ';
			if(Input_Digit5 < 10)
				InputString[1] = '0' + Input_Digit5;
			else 
				InputString[1] = ' ';
			if(Input_Digit4 < 10)
				InputString[0] = '0' + Input_Digit4;
			else
				InputString[0] = ' ';
		}
	}
	else if(IsICPSet(ICPClass::CHAFF_BINGO))
	{
		if(Manual_Input)
		{
			if(Input_Digit7 < 10)
				InputString[1] = '0' + Input_Digit7;
			else
				InputString[1] = '0';
			if(Input_Digit6 < 10)
				InputString[0] = '0' + Input_Digit6;
			else
				InputString[0] = ' ';
			InputString[2] = '\0';
		}
		else
			sprintf(InputString,"%d",ChaffBingo);
	}
	else if(IsICPSet(ICPClass::FLARE_BINGO))
	{
		if(Manual_Input)
		{
			if(Input_Digit7 < 10)
				InputString[1] = '0' + Input_Digit7;
			else
				InputString[1] = ' ';
			if(Input_Digit6 < 10)
				InputString[0] = '0' + Input_Digit6;
			else
				InputString[0] = ' ';
			InputString[2] = '\0';
		}
		else
			sprintf(InputString,"%d",FlareBingo);
	}
	else if(IsICPSet(ICPClass::MODE_LIST) && mICPSecondaryMode == EIGHT_BUTTON)
	{
		if(IN_AA)
		{
			sprintf(InputString,"A-A");
			if(mICPPrimaryMode == AA_MODE)
				IsSelected = TRUE;
			else
				IsSelected = FALSE;
		}
		else if(IN_AG)
		{
			sprintf(InputString,"A-G");
			if(mICPPrimaryMode == AG_MODE)
				IsSelected = TRUE;
			else
				IsSelected = FALSE;
		}
	}
	else if(BQ)
	{
		if(Manual_Input)
		{
			if(Input_Digit7 < 10)
				InputString[1] = '0' + Input_Digit7;
			else
				InputString[1] = ' ';
			if(Input_Digit6 < 10)
				InputString[0] = '0' + Input_Digit6;
			else
				InputString[0] = ' ';
			InputString[2] = '\0';
		}
		else
		{
			if(PGMChaff)
			{
				if(iCHAFF_BQ[CPI] <= 0)
					sprintf(InputString,"0");
				else
					sprintf(InputString,"%2.0d",iCHAFF_BQ[CPI]);
			}
			else if(PGMFlare)
			{
				if(iFLARE_BQ[FPI] <= 0)
					sprintf(InputString,"0");
				else
					sprintf(InputString,"%2.0d",iFLARE_BQ[FPI]);
			}
		}
	}
	else if(BI)
	{
		if(Manual_Input)
		{
			if(Input_Digit7 < 10)
				InputString[5] = '0' + Input_Digit7;
			else
				InputString[5] = ' ';
			if(Input_Digit6 < 10)
				InputString[4] = '0' + Input_Digit6;
			else 
				InputString[4] = ' ';
			if(Input_Digit5 < 10)
				InputString[3] = '0' + Input_Digit5;
			else
				InputString[3] = ' ';
			InputString[2] = '.';
			if(Input_Digit4 < 10)
				InputString[1] = '0' + Input_Digit4;
			else
				InputString[1] = ' ';
			if(Input_Digit3 < 10)
				InputString[0] = '0' + Input_Digit3;
			else
				InputString[0] = ' ';
			InputString[6] = '\0';
		}
		else
		{
			if(PGMChaff)
				sprintf(InputString,"%2.3f",fCHAFF_BI[CPI]);
			else if(PGMFlare)
				sprintf(InputString,"%2.3f",fFLARE_BI[FPI]);
		}
	}
	else if(SQ)
	{
		if(Manual_Input)
		{
			if(Input_Digit7 < 10)
				InputString[1] = '0' + Input_Digit7;
			else
				InputString[1] = ' ';
			if(Input_Digit6 < 10)
				InputString[0] = '0' + Input_Digit6;
			else
				InputString[0] = ' ';
			InputString[2] = '\0';
		}
		else
		{
			if(PGMChaff)
			{
				if(iCHAFF_SQ[CPI] <= 0)
					sprintf(InputString,"0");
				else
				{
					if(iCHAFF_SQ[FPI] < 10)
						sprintf(InputString,"%1.0d",iCHAFF_SQ[CPI]);
					else
						sprintf(InputString,"%2.0d",iCHAFF_SQ[CPI]);
				}
			}
			else if(PGMFlare)
			{
				if(iFLARE_SQ[FPI] <= 0)
					sprintf(InputString,"0");
				else
				{
					if(iFLARE_SQ[FPI] < 10)
						sprintf(InputString,"%1.0d",iFLARE_SQ[FPI]);
					else
						sprintf(InputString,"%2.0d",iFLARE_SQ[FPI]);
				}
			}
		}
	}
	else if(SI)
	{
		if(Manual_Input)
		{
			if(Input_Digit7 < 10)
				InputString[5] = '0' + Input_Digit7;
			else
				InputString[5] = ' ';
			if(Input_Digit6 < 10)
				InputString[4] = '0' + Input_Digit6;
			else 
				InputString[4] = ' ';
			InputString[3] = '.';
			if(Input_Digit5 < 10)
				InputString[2] = '0' + Input_Digit5;
			else
				InputString[2] = ' ';
			if(Input_Digit4 < 10)
				InputString[1] = '0' + Input_Digit4;
			else
				InputString[1] = ' ';
			if(Input_Digit3 < 10)
				InputString[0] = '0' + Input_Digit3;
			else
				InputString[0] = ' ';
			InputString[6] = '\0';
		}
		else
		{
			if(PGMChaff)
				sprintf(InputString,"%3.2f",fCHAFF_SI[CPI]);
			else if(PGMFlare)
				sprintf(InputString,"%3.2f",fFLARE_SI[FPI]);
		}
	}
	else if(OA1 || OA2)
	{
		if(Manual_Input)
		{
			if(OA_RNG || OA_ALT)
			{
				InputString[7] = 'T';
				InputString[6] = 'F';
				if(Input_Digit7 < 10)
					InputString[5] = '0' + Input_Digit7;
				else
					InputString[5] = ' ';
				if(Input_Digit6 < 10)
					InputString[4] = '0' + Input_Digit6;
				else 
					InputString[4] = ' ';
				if(Input_Digit5 < 10)
					InputString[3] = '0' + Input_Digit5;
				else
					InputString[3] = ' ';
				if(Input_Digit4 < 10)
					InputString[2] = '0' + Input_Digit4;
				else
					InputString[2] = ' ';
				if(Input_Digit3 < 10)
					InputString[1] = '0' + Input_Digit3;
				else
					InputString[1] = ' ';
				if(Input_Digit2 < 10)
					InputString[0] = '0' + Input_Digit2;
				else
					InputString[0] = ' ';
				InputString[8] = '\0';
			}
			else if(OA_BRG)
			{
				InputString[5] = '\'';
				if(Input_Digit7 < 10)
					InputString[4] = '0' + Input_Digit7;
				else
					InputString[4] = ' ';
				InputString[3] = '.';
				if(Input_Digit6 < 10)
					InputString[2] = '0' + Input_Digit6;
				else 
					InputString[2] = ' ';
				if(Input_Digit5 < 10)
					InputString[1] = '0' + Input_Digit5;
				else
					InputString[1] = ' ';
				if(Input_Digit4 < 10)
					InputString[0] = '0' + Input_Digit4;
				else
					InputString[0] = ' ';
				InputString[6] = '\0';
			}
		}
		else
		{
			if(OA1)
			{
				if(OA_RNG)
					sprintf(InputString,"%dFT", iOA_RNG);
				if(OA_BRG)
					sprintf(InputString,"%3.1f'",fOA_BRG);
				if(OA_ALT)
					sprintf(InputString,"%dFT",iOA_ALT);
			}
			else if(OA2)
			{
				if(OA_RNG)
					sprintf(InputString,"%dFT", iOA_RNG2);
				if(OA_BRG)
					sprintf(InputString,"%3.1f'",fOA_BRG2);
				if(OA_ALT)
					sprintf(InputString,"%dFT",iOA_ALT2);
			}
		}
	}
	//VIP and VRP
	else if(IsICPSet(ICPClass::MODE_LIST) && mICPSecondaryMode == THREE_BUTTON  ||
		IsICPSet(ICPClass::MODE_LIST) && mICPSecondaryMode == NINE_BUTTON)	
	{
		if(Manual_Input)
		{
			if(VIP_RNG || VRP_RNG)
			{
				InputString[7] = 'T';
				InputString[6] = 'F';
				if(Input_Digit7 < 10)
					InputString[5] = '0' + Input_Digit7;
				else
					InputString[5] = ' ';
				if(Input_Digit6 < 10)
					InputString[4] = '0' + Input_Digit6;
				else 
					InputString[4] = ' ';
				if(Input_Digit5 < 10)
					InputString[3] = '0' + Input_Digit5;
				else
					InputString[3] = ' ';
				if(Input_Digit4 < 10)
					InputString[2] = '0' + Input_Digit4;
				else
					InputString[2] = ' ';
				if(Input_Digit3 < 10)
					InputString[1] = '0' + Input_Digit3;
				else
					InputString[1] = ' ';
				if(Input_Digit2 < 10)
					InputString[0] = '0' + Input_Digit2;
				else
					InputString[0] = ' ';
				InputString[8] = '\0';
			}
			else if(VIP_BRG || VRP_BRG)
			{
				InputString[5] = '\'';
				if(Input_Digit7 < 10)
					InputString[4] = '0' + Input_Digit7;
				else
					InputString[4] = ' ';
				InputString[3] = '.';
				if(Input_Digit6 < 10)
					InputString[2] = '0' + Input_Digit6;
				else 
					InputString[2] = ' ';
				if(Input_Digit5 < 10)
					InputString[1] = '0' + Input_Digit5;
				else
					InputString[1] = ' ';
				if(Input_Digit4 < 10)
					InputString[0] = '0' + Input_Digit4;
				else
					InputString[0] = ' ';
				InputString[6] = '\0';
			}
			else if(VIP_ALT || VRP_ALT)
			{
				InputString[7] = 'T';
				InputString[6] = 'F';
				if(Input_Digit7 < 10)
					InputString[5] = '0' + Input_Digit7;
				else
					InputString[5] = ' ';
				if(Input_Digit6 < 10)
					InputString[4] = '0' + Input_Digit6;
				else 
					InputString[4] = ' ';
				if(Input_Digit5 < 10)
					InputString[3] = '0' + Input_Digit5;
				else
					InputString[3] = ' ';
				if(Input_Digit4 < 10)
					InputString[2] = '0' + Input_Digit4;
				else
					InputString[2] = ' ';
				if(Input_Digit3 < 10)
					InputString[1] = '0' + Input_Digit3;
				else
					InputString[1] = ' ';
				if(Input_Digit2 < 10)
					InputString[0] = '0' + Input_Digit2;
				else
					InputString[0] = ' ';
				InputString[8] = '\0';
			}

		}
		else
		{
			//VIP
			if(mICPSecondaryMode == THREE_BUTTON)
			{
				if(VIP_RNG)
					sprintf(InputString,"%dFT", iVIP_RNG);
				if(VIP_BRG)
					sprintf(InputString,"%3.1f'",fVIP_BRG);
				if(VIP_ALT)
					sprintf(InputString,"%dFT",iVIP_ALT);
			}
			else if(mICPSecondaryMode == NINE_BUTTON)
			{
				if(VRP_RNG)
					sprintf(InputString,"%dFT", iVRP_RNG);
				if(VRP_BRG)
					sprintf(InputString,"%3.1f'",fVRP_BRG);
				if(VRP_ALT)
					sprintf(InputString,"%dFT",iVRP_ALT);
			}
		}
	}
	else if((IsICPSet(ICPClass::MODE_LIST) && mICPSecondaryMode == 100) ||
		IsICPSet(ICPClass::MODE_IFF)) //INTG and IFF
	{
		if(Input_Digit7 < 10)
			InputString[4] = '0' + Input_Digit7;
		else
			InputString[4] = ' ';
		if(Input_Digit6 < 10)
			InputString[3] = '0' + Input_Digit6;
		else 
			InputString[3] = ' ';
		if(Input_Digit5 < 10)
			InputString[2] = '0' + Input_Digit5;
		else
			InputString[2] = ' ';
		if(Input_Digit4 < 10)
			InputString[1] = '0' + Input_Digit4;
		else
			InputString[1] = ' ';
		if(Input_Digit3 < 10)
			InputString[0] = '0' + Input_Digit3;
		else
			InputString[0] = ' ';
		InputString[5] = '\0';
	}
	//Laser Page
	else if(IsICPSet(ICPClass::MISC_MODE) && mICPSecondaryMode == FIFE_BUTTON)
	{
		if(LaserLine == 1)
		{
			if(Manual_Input)
			{
				if(Input_Digit7 < 10)
					InputString[3] = '0' + Input_Digit7;
				else
					InputString[3] = ' ';
				if(Input_Digit6 < 10)
					InputString[2] = '0' + Input_Digit6;
				else 
					InputString[2] = ' ';
				if(Input_Digit5 < 10)
					InputString[1] = '0' + Input_Digit5;
				else
					InputString[1] = ' ';
				if(Input_Digit4 < 10)
					InputString[0] = '0' + Input_Digit4;
				else
					InputString[0] = ' ';
				InputString[4] = '\0';
			}
			else
			{
				sprintf(InputString, "%d", LaserCode);
			}
		}
		else if(LaserLine == 2)
		{
			if(Manual_Input)
			{
				if(Input_Digit7 < 10)
					InputString[2] = '0' + Input_Digit7;
				else
					InputString[2] = ' ';
				if(Input_Digit6 < 10)
					InputString[1] = '0' + Input_Digit6;
				else 
					InputString[1] = ' ';
				if(Input_Digit5 < 10)
					InputString[0] = '0' + Input_Digit5;
				else
					InputString[0] = ' ';
				InputString[3] = '\0';
			}
			else
			{
				sprintf(InputString, "%d", LaserTime);
			}
		}
	}
	else
		ClearString();

	if(IsICPSet(ICPClass::FLASH_FLAG))
	{
		if(flash)
		{
			//Visible
			FillDEDMatrix(Line, Start+1,InputString);
			FillDEDMatrix(Line,Start,"\x02",2);
			FillDEDMatrix(Line,End,"\x02",2);
			MakeInverted(Line, Start+1, End);
		}
		else
		{
			//Don't draw anything
			ClearString();
			//Limit our string lenght
			InputString[End - (Start+1)] = '\0';
			FillDEDMatrix(Line, Start+1, InputString);
			FillDEDMatrix(Line,Start,"\x02",2);
			FillDEDMatrix(Line,End,"\x02",2);
			ClearInverted(Line, Start+1, End);
		}
	}
	else
	{
		FillDEDMatrix(Line, (End - strlen(InputString)), InputString);
		FillDEDMatrix(Line,Start,"\x02",2);
		FillDEDMatrix(Line,End,"\x02",2);
		if(Manual_Input ||  IsSelected)
		{
			MakeInverted(Line, Start, End);
		}
		else
			ClearInverted(Line, Start+1, End-1);
	}
}
Beispiel #23
0
int main(int argc, char** argv) {
    int xVal, yVal;

    void Ludacris_Speed_GO(void);
    Ludacris_Speed_GO();

    UART1_Config();
    Timer1_Setup();
    Pin_Setup();
    Interrupt_Setup();

    printf("\nWe're gon-na to get you...\n");

    while(1)
    {
        switch (PromptState)
        {
        case GETXINPUT:
        case GETYINPUT:
            if (PromptState == GETXINPUT)
            {
                if(!Prompted)
                {
                    printf("x = ");
                    Prompted++;
                }
                if(RX_Done)
                {
                    xVal = atoi(RX_Data);
                    PromptState = GETYINPUT;
                    Prompted = 0;
                    RX_Done = 0;
                    ClearString();
                }
            }
            if (PromptState == GETYINPUT)
            {
                if(!Prompted)
                {
                    printf("y = ");
                    Prompted++;
                }
                if(RX_Done)
                {
                    yVal = atoi(RX_Data);
                    PromptState = CALCULATE;
                    Prompted = 0;
                    RX_Done = 0;
                    ClearString();
                }
            }
            Prompted = 1;
            break;
        case CALCULATE:
            Calculate(xVal, yVal);
            printf("Press Enter to play again...");
            break;
        case WAITING:
            Nop();
            if(RX_Done)
            {
                PromptState = RESET;
                RX_Done = 0;
            }
            break;
        case RESET:
            Prompted = 0;
            T1CONbits.TON = 1;
            PromptState = WAITING;
        }
    }
    return (EXIT_SUCCESS);
}
Beispiel #24
0
/****************************************************************************
*  Mouse Handler for Win 95                                                   *
****************************************************************************/
static LRESULT CALLBACK WinProc(HWND hWnd, UINT messg, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;

	char str[3] = " ";
	switch (messg)
	{
	case WM_PAINT:
		BeginPaint(hWnd, &ps);
		PrintMessage(buffer);
		// Draw everything
		//	  RefreshScreen();

		ValidateRect(hWnd, NULL);

		EndPaint(hWnd, &ps);
		break;
	case WM_CHAR:
		// Win32 keyboard message: lParam=key code wParam= virtual key (ASCII) code 

		if (!(LOWORD(wParam) & KF_UP) &&
			!(LOWORD(wParam) & KF_ALTDOWN))
		{
			//  take keyboard input
			key_input = (char)LOWORD(wParam);

			if (key_input == ENTER) // Enter
			{
				EraseMessage();
				//buffer[strlen(buffer)]=0x00;
			}
			else if (key_input == BACKSPACE) // BackSpace
			{
				if (strlen(buffer) > 0)
				{
					int len = strlen(buffer) - 1;
					// Clear last character in buffer
					buffer[len] = ' ';
					// Clear characters in input box
					strcat_s(buffer, "   ");
					PrintMessage(buffer);
					buffer[len] = 0x00; // put end string
				}
			}
			else if (key_input > 31 && key_input < 130)
			{
				int leng = strlen(buffer);
				EraseMessage();
				str[0] = key_input;
				strcat_s(buffer, str); // add char
				// display, update input box
				PrintMessage(buffer);
			}
			else if (key_input != ESC) //ESC
				key_input = -1;
			break;
		}
	case WM_SIZE:
		// resize 
		SetMaxX(LOWORD(lParam));  // width of client area 
		SetMaxY(HIWORD(lParam));
		PostMessage(WinHandle, WM_PAINT, wParam, lParam);
		break;
	case WM_MOUSEMOVE:
		key_input = wParam;
		if (key_input == MK_LBUTTON)
		{
			EraseMessage();
			mouse_x = LOWORD(lParam);
			mouse_y = HIWORD(lParam);
			key_input = wParam;
			printf_s(buffer, " x = %d y = %d", mouse_x, mouse_y);
			PrintMessage(buffer);
			mouse_action = L_MOUSE_MOVE_DOWN;
			ClearString(buffer);
		}
		break;
	case WM_LBUTTONDOWN:
		EraseMessage();
		mouse_x = LOWORD(lParam);
		mouse_y = HIWORD(lParam);
		key_input = wParam;
		printf_s(buffer, " x = %d y = %d", mouse_x, mouse_y);
		PrintMessage(buffer);
		mouse_action = L_MOUSE_DOWN;
		ClearString(buffer);
		break;
	case WM_LBUTTONUP:
		EraseMessage();
		mouse_x = LOWORD(lParam);
		mouse_y = HIWORD(lParam);
		key_input = wParam;
		sprintf_s(buffer, " x = %d y = %d", mouse_x, mouse_y);
		PrintMessage(buffer);
		mouse_action = L_MOUSE_UP;
		ClearString(buffer);
		break;
	case WM_RBUTTONDOWN:
		EraseMessage();
		key_input = wParam;
		mouse_x = LOWORD(lParam);
		mouse_y = HIWORD(lParam);

		sprintf_s(buffer, " x = %d y = %d", mouse_x, mouse_y);
		PrintMessage(buffer);

		mouse_action = R_MOUSE_DOWN;
		ClearString(buffer);

		break;
	case WM_LBUTTONDBLCLK:
		EraseMessage();
		mouse_x = LOWORD(lParam);
		mouse_y = HIWORD(lParam);
		key_input = wParam;
		sprintf_s(buffer, " x = %d y = %d", mouse_x, mouse_y);
		PrintMessage(buffer);
		mouse_action = L_DOUBLE_CLICK;
		ClearString(buffer);
		key_input = wParam;

		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	case WM_COMMAND:
		menu_item = LOWORD(wParam);
		break;

	default:
		return(DefWindowProc(hWnd, messg, wParam, lParam));
		break;
	}

	return 0;
}
Beispiel #25
0
void CallGCTraceRoot(CONTEXT* root,
                     VALUE    curExpr)
{
    //printf("RUNNING GARBAGE COLLECTOR\n");
    //printf(".");

    GC_DATA_MANAGEMENT  managed;
    unsigned int index;

    managed = InitGC(/*managed*/);

    GCAddValue(curExpr, &managed);
//    CallGCRecurseContext(root, &managed);
    CallGCRecurseContext(gCurrentContext, &managed);

    CONTEXT_STACK* stack = gExecutionStack;
    while (stack) {
        CallGCRecurseContext(stack->context, &managed);
        stack = stack->next;
    }
    //CallGCRecurseContext(gGlobalContext, &managed);

    // find elements in gGCManager that are not
    // members of gc managed
    // then remove those elements and free()
    // their memory
    
    /* contexts */
    for (index = 0;
         index < gGCManager.ctx_size;
         index++)
    {
        CONTEXT* context = gGCManager.contexts[index];
        if (!CONTAINS_POINTER_ARRAY((void**)managed.contexts,
                                    managed.ctx_size,
                                    (void*)context))
        {
            ClearContext(context);
            gGCManager.contexts[index] = NULL;
            gGCManager.contexts[index] = gGCManager.contexts[gGCManager.ctx_size-1];
            gGCManager.ctx_size--;
            index--;
        }
    }

    /* functions */
    for (index = 0;
         index < gGCManager.func_size;
         index++)
    {
        FUNCTION* function = gGCManager.functions[index];
        if (!CONTAINS_POINTER_ARRAY((void**)managed.functions,
                                    managed.func_size,
                                    (void*)function))
        {
            ClearFunction(function);
            gGCManager.functions[index] = NULL;
            gGCManager.functions[index] = gGCManager.functions[gGCManager.func_size-1];
            gGCManager.func_size--;
            index--;
        }
    }

    /* dictionaries */
    for (index = 0;
         index < gGCManager.table_size;
         index++)
    {
        HASH_TABLE* table = gGCManager.tables[index];
        if (!CONTAINS_POINTER_ARRAY((void**)managed.tables,
                                    managed.table_size,
                                    (void*)table))
        {
            ClearDictionary(table);
            gGCManager.tables[index] = NULL;
            gGCManager.tables[index] = gGCManager.tables[gGCManager.table_size-1];
            gGCManager.table_size--;
            index--;
        }
    }

    /* strings */
    for (index = 0;
         index < gGCManager.str_size;
         index++)
    {
        char* string = gGCManager.strings[index];
        if (!CONTAINS_POINTER_ARRAY((void**)managed.strings,
                                    managed.str_size,
                                    (void*)string))
        {
            ClearString(string);
            gGCManager.strings[index] = NULL;
            gGCManager.strings[index] = gGCManager.strings[gGCManager.str_size-1];
            gGCManager.str_size--;
            index--;
        }
    }

    FreeGCMgmtObject(managed);
}
Beispiel #26
0
void ICPClass::ExecILSMode(void) 
{
	if(!g_bRealisticAvionics)
	{
		//MI Original code
		VU_ID							id;
		VU_ID							homeid;
		VU_ID							ilsid;
		BOOL							isValidILS;
		BOOL							isValidRWY;
		int							channel;
		char							rwyNum[4] = "";
		TacanList::StationSet	set;
		char							setchar;
		char							p_signaltype[10] = "";
		NavigationSystem::Type	type;
		static int					frame = 0;


		if(mUpdateFlags & ILS_UPDATE) 
		{
			mUpdateFlags &= ~ILS_UPDATE;

			if (gNavigationSys)
			{
				gNavigationSys->GetTacanVUID(NavigationSystem::ICP, &id);
			}
			else
			{
				id == FalconNullId;
			}

			if(id == FalconNullId) 
			{
				sprintf(mpLine1, "NO MISSION PRESETS");
				sprintf(mpLine2, "");
				sprintf(mpLine3, "");
			}
			else 
			{
				
				type = gNavigationSys->GetType();

				// Line #1
				sprintf(mpLine1, "");

				// Line #2
				if(type == NavigationSystem::AIRBASE) 
				{
					gNavigationSys->GetHomeID(&homeid);

					isValidILS = gNavigationSys->GetILSAttribute(NavigationSystem::AIRBASE_ID, &ilsid);
					isValidRWY = gNavigationSys->GetILSAttribute(NavigationSystem::RWY_NUM, (char*)rwyNum);
			
					if(id == homeid) 
					{
						sprintf(mpLine2, "HOME RUNWAY ");
					}
					else 
					{
						sprintf(mpLine2, "ALTERNATE RUNWAY ");
					}

					if(id == ilsid && isValidILS && isValidRWY) 
					{
						strcat(mpLine2, rwyNum);
					}
				}	
				else if(type == NavigationSystem::TANKER) 
				{
					sprintf(mpLine2, "TANKER");
				}
				else if(type == NavigationSystem::CARRIER) 
				{
					if(id == homeid) 
					{
						sprintf(mpLine2, "HOME CARRIER");
					}
					else 
					{
						sprintf(mpLine2, "ALTERNATE CARRIER");
					}
				}

				// Line #3
				gNavigationSys->GetTacanChannel(NavigationSystem::ICP, &channel, &set);

				if(set == TacanList::X) {
					setchar = 'X';
				}
				else {
					setchar = 'Y';
				}

				if(type == NavigationSystem::TANKER) {
					strcpy(p_signaltype, "AA-TR");			
				}		
				else {
					strcpy(p_signaltype, "TR");
				}

				sprintf(mpLine3, "TCN %-3d%c %s", channel, setchar, p_signaltype);
			}
		}
		else if (frame == 9) 
		{

			if (gNavigationSys)
			{
				gNavigationSys->GetTacanVUID(NavigationSystem::ICP, &id);
				type = gNavigationSys->GetType();
				if(type == NavigationSystem::AIRBASE) 
				{
					gNavigationSys->GetHomeID(&homeid);

					isValidILS = gNavigationSys->GetILSAttribute(NavigationSystem::AIRBASE_ID, &ilsid);
					isValidRWY = gNavigationSys->GetILSAttribute(NavigationSystem::RWY_NUM, (char*)rwyNum);
			
					if(id == homeid) {
						sprintf(mpLine2, "HOME RUNWAY ");
					}
					else {
						sprintf(mpLine2, "ALTERNATE RUNWAY ");
					}

					if(id == ilsid && isValidILS && isValidRWY) 
					{
						strcat(mpLine2, rwyNum);
					}
				}
			}
			else
			{
				id == FalconNullId;
			}

			frame = 0;
		}
		else 
		{

			frame++;
		}
	}
	else
	{
		ClearStrings();
		//MI modified for ICP stuff
		VU_ID							id;
		VU_ID							homeid;
		VU_ID							ilsid;
		char							rwyNum[4] = "";
		char							p_signaltype[10] = "";
		static int						frame = 0;

		HSICourse = static_cast<int>
			(OTWDriver.pCockpitManager->mpHsi->GetValue(CPHsi::HSI_VAL_DESIRED_CRS));

		if(gNavigationSys->GetControlSrc() == NavigationSystem::AUXCOMM)
			ILSBackup();
		else
		{
			if(gNavigationSys->GetTacanBand(NavigationSystem::ICP) == TacanList::X)
				TacanBand = 'X';
			else
				TacanBand = 'Y';
			if (gNavigationSys)
				gNavigationSys->GetTacanVUID(NavigationSystem::ICP, &id);
			else
				id == FalconNullId;

			if(id == FalconNullId) 
				ILSOn = 0;
			else 
			{
				//We SHOULD only have ILS when our Tacanband is == X
				if(TacanBand == 'X')
					ILSOn = 1;
				else 
					ILSOn = 0;
			}
			if(gNavigationSys->GetDomain(NavigationSystem::ICP) == TacanList::AA)
			{
				//Line1
				FillDEDMatrix(0,1,"TCN A/A TR");

				if(ILSOn ==1)
					FillDEDMatrix(0,18,"ILS ON");
				else
					FillDEDMatrix(0,18,"ILS OFF");
			}
			else
			{
				//Line1
				FillDEDMatrix(0,1,"TCN TR");
				if(ILSOn ==1)
					FillDEDMatrix(0,18,"ILS ON");
				else
					FillDEDMatrix(0,18,"ILS OFF");
			}			

			Digit1 = gNavigationSys->GetTacanChannel(NavigationSystem::ICP, 2);
			Digit2 = gNavigationSys->GetTacanChannel(NavigationSystem::ICP, 1);
			Digit3 = gNavigationSys->GetTacanChannel(NavigationSystem::ICP, 0);
			TacanChannel = (Digit1 * 100 + Digit2 * 10 + Digit3);
			
			//FakeILSFreq();
			sprintf(Freq, "%3.2f", gNavigationSys->GetCurTCNILS());
			//BEGIN LINE 3
			PossibleInputs = 3;
			if(ILSPageSel == 0)
				ScratchPad(2,8,12);
			else if(ILSPageSel == 1)
				ScratchPad(2,16,25);

			if(GetCMDSTR())
				FillDEDMatrix(2,17,"CMD STRG", 2);
			else
				FillDEDMatrix(2,17,"CMD STRG");
			//END LINE 3

			//BEGIN LINE 4
			FillDEDMatrix(3,1,"CHAN");
			ClearString();
			sprintf(tempstr,"%3.0d",TacanChannel);
			FillDEDMatrix(3,9,tempstr);
			FillDEDMatrix(3,14,"FREQ");
			FillDEDMatrix(3,19,Freq);
			//END LINE 4

			//BEGIN LINE 5
			FillDEDMatrix(4,1,"BAND");
			sprintf(tempstr,"%c(0)",TacanBand);
			FillDEDMatrix(4,9,tempstr);
			FillDEDMatrix(4,14,"CRS");
			sprintf(tempstr,"%d*",HSICourse);
			FillDEDMatrix(4,18,tempstr);
			//END LINE 5
		}
	}
}