Ejemplo n.º 1
0
void __fastcall TBTDownloadFrm::SaveBTJPARAMBTNClick(TObject *Sender)
{
	if(!MachNOEdit->Text.IsEmpty()&&!ComNoEdit->Text.IsEmpty()&&
    	!MaxXFEdit->Text.IsEmpty()&&!MaxNumEdit->Text.IsEmpty()&&
        !PasswordEdit->Text.IsEmpty())
    {
        BTJPARAMADOQ->Close();
        BTJPARAMADOQ->SQL->Clear();
        BTJPARAMADOQ->SQL->Add("select * from BTJPARAM");
        BTJPARAMADOQ->Open();
        if(BTJPARAMADOQ->IsEmpty())
        {
        	BTJPARAMADOQ->Insert();
            BTJPARAMADOQ->FieldByName("JH")->AsInteger = StrToInt(MachNOEdit->Text);
            BTJPARAMADOQ->FieldByName("SFJPORT")->AsInteger = StrToInt(ComNoEdit->Text);
            BTJPARAMADOQ->FieldByName("MAXXF")->AsInteger = StrToInt(MaxXFEdit->Text);
            BTJPARAMADOQ->FieldByName("MAXBTNUM")->AsInteger = StrToInt(MaxNumEdit->Text);
            BTJPARAMADOQ->FieldByName("PASSWORD")->AsInteger = StrToInt(PasswordEdit->Text);
            BTJPARAMADOQ->Post();

            btPosNo = BTJPARAMADOQ->FieldByName("JH")->AsInteger;
        	IntToChar(BTJPARAMADOQ->FieldByName("SFJPORT")->AsInteger, &btcomo);

            CSBTDownBTN->Enabled = true;
        	JBBTDownBTN->Enabled = true;
            BTJPARAMADOQ->Close();
            ShowMessage("补贴机信息保存完毕!");
        }
        else
        {
        	BTJPARAMADOQ->Edit();
            BTJPARAMADOQ->FieldByName("JH")->AsInteger = StrToInt(MachNOEdit->Text);
            BTJPARAMADOQ->FieldByName("SFJPORT")->AsInteger = StrToInt(ComNoEdit->Text);
            BTJPARAMADOQ->FieldByName("MAXXF")->AsInteger = StrToInt(MaxXFEdit->Text);
            BTJPARAMADOQ->FieldByName("MAXBTNUM")->AsInteger = StrToInt(MaxNumEdit->Text);
            BTJPARAMADOQ->FieldByName("PASSWORD")->AsInteger = StrToInt(PasswordEdit->Text);
            BTJPARAMADOQ->Post();

            btPosNo = BTJPARAMADOQ->FieldByName("JH")->AsInteger;
        	IntToChar(BTJPARAMADOQ->FieldByName("SFJPORT")->AsInteger, &btcomo);

            CSBTDownBTN->Enabled = true;
        	JBBTDownBTN->Enabled = true;
            BTJPARAMADOQ->Close();
            ShowMessage("补贴机信息保存完毕!");
        }
    }
    else
    	ShowMessage("补贴机信息填写不完整,请完整填写!");
}
Ejemplo n.º 2
0
void ADC_Test(void)
{
	int tem[2];
//	char *c = value;

//	AD_value=ADC_GetConversionValue(ADC1);
	tem[0] = (int)ADC_ValueTab[0]*331/4096;
    tem[1] = (int)ADC_ValueTab[1]*331/4096;
	IntToChar(tem[0]);
    IntToChar(tem[1]);
//	TFTShowString24(50,250,c,BLUE,0);
    SetEditTmp(&MAIN_WIN_ADC,tem[0]);
    SetEditTmp(&MAIN_WIN_ADC1,tem[1]);
	#ifdef DEBUG
//    printf("ADC: %.3f \r\n",(float)ADC_ValueTab[1]*336/409600);
    printf("ADC: %d \r\n",ADC_ValueTab[0]);
    printf("ADC: %d \r\n",ADC_ValueTab[1]);
    #endif
}
// caller needs to free() the result
WCHAR *DecodeHtmlEntitites(const char *string, UINT codepage)
{
    WCHAR *fixed = str::conv::FromCodePage(string, codepage), *dst = fixed;
    const WCHAR *src = fixed;

    while (*src) {
        if (*src != '&') {
            *dst++ = *src++;
            continue;
        }
        src++;
        // numeric entities
        int unicode;
        if (str::Parse(src, L"#%d;", &unicode) ||
            str::Parse(src, L"#x%x;", &unicode)) {
            *dst++ = IntToChar(unicode);
            src = str::FindChar(src, ';') + 1;
            continue;
        }

        // named entities
        int rune = -1;
        const WCHAR *entityEnd = src;
        while (iswalnum(*entityEnd))
            entityEnd++;
        if (entityEnd != src) {
            size_t entityLen = entityEnd - src;
            rune = HtmlEntityNameToRune(src, entityLen);
        }
        if (-1 != rune) {
            *dst++ = IntToChar(rune);
            src = entityEnd;
            if (*src == ';')
                ++src;
        } else {
            *dst++ = '&';
        }
    }
    *dst = '\0';

    return fixed;
}
Ejemplo n.º 4
0
char* GetDataTextOption(cngplpData *data, int id)
{
	if(id <= ID_PRETTYPRINT){
		char *option = NULL;
		int index = id - ID_TEXT_OPTION - 1;
		if((option = IDtoTextOption(index)) != NULL)
			return ToChar(GetCupsValue(data->cups_opt->text->option, option));
	}else if(id == ID_MARGIN){
		return IntToChar(data->cups_opt->text->margin_on);
	}
	return NULL;
}
Ejemplo n.º 5
0
char* GetDataImageOption(cngplpData *data, int id)
{
	if(id <= ID_POSITION){
		char *option = NULL;
		int index = id - ID_IMAGE_OPTION - 1;
		if((option = IDtoImageOption(index)) != NULL)
			return ToChar(GetCupsValue(data->cups_opt->image->option, option));
	}else if(id == ID_RESO_SCALE){
		return IntToChar(data->cups_opt->image->img_reso_scale);
	}
	return NULL;
}
Ejemplo n.º 6
0
void __fastcall TBTDownloadFrm::FormShow(TObject *Sender)
{
	btcomo = 0x00;
    btcmd = 0x43;
    ZeroMemory(btreceivebuf, 16);
    btreceivelen = 16;
    btdir = "E:\\BT";
    btdirlen = strlen(btdir);
    btPosNo = 0;

	DownloadBTtag = true;
    ExitBTN->Left = (BTDownloadFrm->Width-ExitBTN->Width)/2;
    CSPanel->Caption = "下传按消费次数生成的补贴,请点击“下传消费次数补贴”!";
    JBPanel->Caption = "下传按职务生成的补贴,请点击“下传职务补贴”!";

    BTJPARAMADOQ->Close();
    BTJPARAMADOQ->SQL->Clear();
    BTJPARAMADOQ->SQL->Add("select * from BTJPARAM");
    BTJPARAMADOQ->Open();
    if(!BTJPARAMADOQ->IsEmpty())
    {
    	ComNoEdit->Text = BTJPARAMADOQ->FieldByName("SFJPORT")->AsString;
        MachNOEdit->Text = BTJPARAMADOQ->FieldByName("JH")->AsString;
        MaxNumEdit->Text = BTJPARAMADOQ->FieldByName("MAXBTNUM")->AsString;
        MaxXFEdit->Text = BTJPARAMADOQ->FieldByName("MAXXF")->AsString;
        PasswordEdit->Text = BTJPARAMADOQ->FieldByName("PASSWORD")->AsString;
        btPosNo = BTJPARAMADOQ->FieldByName("JH")->AsInteger;
        IntToChar(BTJPARAMADOQ->FieldByName("SFJPORT")->AsInteger, &btcomo);
    }
    else
    {
        CSBTDownBTN->Enabled = false;
        JBBTDownBTN->Enabled = false;
        ShowMessage("系统中无补贴机信息,请正确填写!");
    }
    BTJPARAMADOQ->Close();
}
Ejemplo n.º 7
0
void askTheAudience(MainPlayerData *mpd) {
	int i;
	int random[4];
	int ans = mpd->ques.ans - 1;
	Question question = mpd->ques;
	int flag = 0;
	for (i = 0; i < 4; i++) {
		if (mpd->selectionStatus[i] == INVALID) {
			flag = 1; //50-50 mode
			break;
		}
	}
	if (flag == 0) {
		random[ans] = randomNumber(20) + 50; //ti le cua cau tra loi dung luon tren 50%
		int remain = 100 - random[ans];
		switch (ans) {
		case 0:
			random[1] = randomNumber(remain / 3);
			random[2] = remain - (random[1] + randomNumber(remain * 11 / 20));
			random[3] = remain - (random[1] + random[2]);
			break;
		case 1:
			random[0] = randomNumber(remain / 3);
			random[2] = remain - (random[0] + randomNumber(remain * 11 / 20));
			random[3] = remain - (random[0] + random[2]);
			break;
		case 2:
			random[0] = randomNumber(remain / 3);
			random[1] = remain - (random[0] + randomNumber(remain * 11 / 20));
			random[3] = remain - (random[0] + random[1]);
			break;
		case 3:
			random[0] = randomNumber(remain / 3);
			random[1] = remain - (random[0] + randomNumber(remain * 11 / 20));
			random[2] = remain - (random[0] + random[1]);
			break;
		}
		printf("\t>>>Ask The Expert<<<\n");
		printf("A.%-25s : %d%%\nB.%-25s : %d%%\n", question.answerList[0],
				random[0], question.answerList[1], random[1]);
		printf("C.%-25s : %d%%\nD.%-25s : %d%%\n", question.answerList[2],
				random[2], question.answerList[3], random[3]);

	} else {
		int random[2];
		char c;
		random[0] = randomNumber(25) + 55;
		random[1] = 100 - random[0];
		for (i = 0; i < 4; i++) {
			if (mpd->selectionStatus[i] == AVAILABLE) {

				if (i == ans) {
					printf("%c.%-25s : %d%%\n", IntToChar(i + 1),
							mpd->ques.answerList[i], random[0]);
				} else {
					printf("%c.%-25s : %d%%\n", IntToChar(i + 1),
							mpd->ques.answerList[i], random[1]);
				}

			}
		}
	}
	return;
}
Ejemplo n.º 8
0
void displayAnswer(Question ques) {
	int ans = ques.ans;
	printf("\nDap an cua chung toi la : %c.%s\n", IntToChar(ans),
			ques.answerList[ans - 1]);
}
Ejemplo n.º 9
0
void helpHandler(MainPlayerData *mpd, int help_choice[]) {
	int i = 0;
	int choice;
	int prob, rand;
	int ans = mpd->ques.ans - 1; //ans can be 0 1 2 3
	int flag = 0;
	for (i = 0; i < HELP_CHOICES; i++) {
		if (help_choice[i] != INVALID) {
			flag = 1;
			break;
		}
	}
	if (flag == 0) {
		printf("You have used all the help choices!\n");
		return;
	}
	switch (mpd->help_choice) {
	case 0: //50/50
		if (help_choice[0] == INVALID) {
			printf("You have used this help !\n");
			return;
		} else {
			char c;
			fifty_fifty(mpd);
			displayQuesWithFtyFty(mpd);
			help_choice[0] = INVALID;
			return;
		}
	case 1: //phone
		if (help_choice[1] == INVALID) {
			printf("You have used this help !\n");
			return;
		} else {
			int i;
			printf("\t>>>Lua chon nguoi tro giup<<<\n");
			printf("\t1.Isaac Newton.\n");
			printf("\t2.Mark Zuckerberg.\n");
			printf("\t3.Barack Obama.\n");
			printf(">>>Your choice :");
			while (1) {
				if (scanf("%d", &choice) == 1 && choice >= 1 && choice <= 3) {
					break;
				} else {
					printf("Wrong input ! Please type your choice again !\n");
				}
			}
			switch (choice) {
			case 1: //chon Newton
				prob = randomNumber(100) + 1;
				if (prob >= 15) {
					printf("Answer of Newton : %c.%s\n",
							IntToChar(mpd->ques.ans),
							mpd->ques.answerList[ans]);
				} else {
					for (i = 0; i < 4; i++) {
						if (i != ans && mpd->selectionStatus[i] == AVAILABLE) {
							printf("Answer of Newton : %c.%s\n",
									IntToChar(i + 1), mpd->ques.answerList[i]);
							break;
						}
					}

				}
				help_choice[1] = INVALID;
				break;
			case 2: //chon Mark
				prob = randomNumber(100) + 1;
				if (prob >= 25) {
					printf("Answer of Mark Zuckerberg : %c.%s\n",
							IntToChar(mpd->ques.ans),
							mpd->ques.answerList[ans]);
				} else {
					for (i = 0; i < 4; i++) {
						if (i != ans && mpd->selectionStatus[i] == AVAILABLE) {
							printf("Answer of Mark Zuckerberg : %c.%s\n",
									IntToChar(i + 1), mpd->ques.answerList[i]);
							break;
						}
					}
				}
				help_choice[1] = INVALID;
				break;
			case 3: //chon Barack Obama
				prob = randomNumber(100) + 1;
				if (prob >= 20) {
					printf("Answer of Barack Obama : %c.%s\n",
							IntToChar(mpd->ques.ans),
							mpd->ques.answerList[ans]);
				} else {
					for (i = 0; i < 4; i++) {
						if (i != ans && mpd->selectionStatus[i] == AVAILABLE) {
							printf("Answer of Barack Obama : %c.%s\n",
									IntToChar(i + 1), mpd->ques.answerList[i]);
							break;
						}
					}
				}
				help_choice[1] = INVALID;
				break;
			}
			return;
		}
	case 2: //Ask the Audience
		if (help_choice[2] == INVALID) {
			printf("You have used this help !\n");

		} else {
			askTheAudience(mpd);
			help_choice[2] = INVALID;
		}
		break;

	default:
		return;
	}
}
Ejemplo n.º 10
0
// Mesage handler for work box.
LRESULT CALLBACK DrugProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	const int nrItem = 5;

	switch (message)
	{
		case WM_INITDIALOG:
			SendMessage(hDlg, WM_COMMAND, UPDATE_DLG, NULL);
		break;
		case WM_COMMAND:
			if (LOWORD(wParam) == IDOK)
			{
				if(EmptyBox(hDlg, IDC_FIT, nrItem) != true)
				{
					SendMessage(hDlg, WM_COMMAND, SAVE_DLG, NULL);
					MessageBox(hDlg, "Now the Drug is saved \nJust load the game...", "Now Saved", MB_OK);
					DestroyWindow(hDlg);
				}
			}
			if (LOWORD(wParam) == IDCANCEL) 
			{
				EndDialog(hDlg, LOWORD(wParam));
				return TRUE;
			}
			if (LOWORD(wParam) == IDC_LOAD) 
			{	
				SendMessage(hDlg, WM_COMMAND, SAVE_DLG, NULL);
				EndDialog(hDlg, LOWORD(wParam));
				DialogBox(hInst, (LPCTSTR)IDD_STARTDLG, NULL, (DLGPROC)Start);
			}
			if (LOWORD(wParam) == IDC_DELETE) 
			{
				char objectName[MAX_NAME_LENGTH];
				strcpy(objectName, drug[activeDrug].name);

				for(int i = activeDrug; i < antDrug-1; i++)
				{
					strcpy(drug[i].name, drug[i+1].name);
					strcpy(drug[i].text, drug[i+1].text);
					drug[i].id = i;
					drug[i].nWage = drug[i+1].nWage;
					drug[i].nCostInSleep = drug[i+1].nCostInSleep;
					drug[i].nFitnes = drug[i+1].nFitnes;
				}

				strcpy(drug[i].name, "");
				strcpy(drug[i].text, "");
				drug[i].id = 0;
				drug[i].nCostInSleep = 0;
				drug[i].nWage = 0;
				drug[i].nFitnes = 0;

				if(antDrug > 0)
					antDrug--;

				activeDrug--;

				SendMessage(hDlg, WM_COMMAND, UPDATE_DLG, NULL);
				MessageBox(hDlg, "Object Deleted", objectName, MB_OK | MB_ICONEXCLAMATION);
			}
			if (LOWORD(wParam) == IDC_RIGHT) 
			{	
				if(EmptyBox(hDlg, IDC_FIT, nrItem) != true)
				{
					SendMessage(hDlg, WM_COMMAND, SAVE_DLG, NULL);
					if(activeDrug < antDrug-1)
					{
						activeDrug++;
					}
					else
					{
						if(MessageBox(hDlg, "Add one more Drug object?", "Add?", MB_ICONQUESTION | MB_YESNO) == IDYES)
							if(antDrug < MAX_WORK)
							{
								antDrug++;
								activeDrug++;
								drug[activeDrug].id = activeDrug;
							}
							else
								MessageBox(hDlg, "Max Drug\n Contact programmer !!!", "Array overflow", MB_OK);
					}
					SendMessage(hDlg, WM_COMMAND, UPDATE_DLG, NULL);
				}
			}

			if (LOWORD(wParam) == IDC_LEFT) 
			{	
				SendMessage(hDlg, WM_COMMAND, SAVE_DLG, NULL);
				if(activeDrug > 0)
					activeDrug--;

				SendMessage(hDlg, WM_COMMAND, UPDATE_DLG, NULL);
			}
			if (LOWORD(wParam) == UPDATE_DLG) 
			{	
				char* str[nrItem+1];

				str[0] = IntToChar(drug[activeDrug].id);
				str[1] = IntToChar(drug[activeDrug].nFitnes);
				str[2] = IntToChar(drug[activeDrug].nCostInSleep);
				str[3] = IntToChar(drug[activeDrug].nWage);
				str[4] = drug[activeDrug].name;
				str[5] = drug[activeDrug].text;


				int i = 0;
				for(int  item = IDC_ID; i < nrItem+1; i++, item++)
					SetDlgItemText(hDlg, item, str[i]);	
			}
			if (LOWORD(wParam) == SAVE_DLG) 
			{
				String str[nrItem];
				char* tmpStr;
				int i= 0;
				int len;
				bool emptyBox = false;
				for(int  item = IDC_FIT; i < nrItem && emptyBox != true; i++, item++)
				{
					len = GetWindowTextLength(GetDlgItem(hDlg, item));
					if(len > 0)
					{
						tmpStr = (char*)GlobalAlloc(GPTR, len + 1);
						GetDlgItemText(hDlg, item, tmpStr, len + 1);
						str[i] = tmpStr;
						GlobalFree((HANDLE)tmpStr);	
					}
					else
					{
						emptyBox = true;
						MessageBox(hDlg, "All fields are not filled!!!", "Oups!", MB_OK);
					}
				}

				if(emptyBox == false)
				{
					drug[activeDrug].id = activeDrug;
					drug[activeDrug].nFitnes = str[0].convertToInt();
					drug[activeDrug].nCostInSleep = str[1].convertToInt();
					drug[activeDrug].nWage = str[2].convertToInt();
					strcpy(drug[activeDrug].name, str[3].getString());
					strcpy(drug[activeDrug].text, str[4].getString());

					NewSaveDrug(file);
				}
			}
			break;
		case WM_DESTROY:
			PostQuitMessage(0);
			return TRUE;	
	}
    return FALSE;
}
Ejemplo n.º 11
0
char CIntegerVariable::GetChar(void) const
{
 return IntToChar(m_Value);
}
Ejemplo n.º 12
0
char* GetDataPPDOption(cngplpData *data, int id)
{
	char *option = NULL;

	switch(id){
	case ID_SELECTBY:
		return IntToChar(data->ppd_opt->selectby);
	case ID_JOBACCOUNT:
		if(data->ppd_opt->special == NULL)
			return NULL;
		else{
#ifndef	__APPLE__
			return IntToChar(data->ppd_opt->special->job_account);
#else
			return ToChar(data->ppd_opt->special->job_account == 0 ? "False" : "True");
#endif
		}
	case ID_JOBACCOUNT_ID:
		if(data->ppd_opt->special == NULL)
			return NULL;
		else
		return ToChar(data->ppd_opt->special->job_account_id);
	case ID_JOBACCOUNT_PASSWD:
		if(data->ppd_opt->special == NULL)
			return NULL;
		else
		return ToChar(data->ppd_opt->special->job_account_passwd);
	case ID_CNUSRPASSWORD:
		if(data->ppd_opt->special == NULL)
			return NULL;
		else
		return ToChar(data->ppd_opt->special->usr_passwd);
	case ID_DATANAME:
		if(data->ppd_opt->special == NULL)
			return NULL;
		else
		return IntToChar(data->ppd_opt->special->data_name);
	case ID_ENTERNAME:
		if(data->ppd_opt->special == NULL)
			return NULL;
		else
#ifndef _OPAL
		return ToChar(data->ppd_opt->special->enter_name);
#else
		if(data->ppd_opt->special->enter_name == NULL){
			return ToChar("");
		}else {
			return ToChar(data->ppd_opt->special->enter_name);
		}
#endif
	case ID_BOXIDNUM:
		if(data->ppd_opt->special == NULL)
			return NULL;
		else
#ifndef __APPLE__
		return IntToChar(data->ppd_opt->special->box_num);
#else
		return ToChar(data->ppd_opt->special->box_num);
#endif
	case ID_MAX_BOXIDNUM:
		return IntToChar(data->ppd_opt->max_box_num);
	case ID_GUTTER:
		if(data->ppd_opt->summary_flag & CNSUMMARY_FLG_GUTTER)
			return NULL;
                if(data->ppd_opt->us_type)
                        return DoubleToChar(data->ppd_opt->gutter_value_d);
                else
                        return IntToChar(data->ppd_opt->gutter_value);
	case ID_MAX_GUTTER:
                if(data->ppd_opt->us_type)
                        return DoubleToChar(data->ppd_opt->max_gutter_value_d);
                else
                        return IntToChar(data->ppd_opt->max_gutter_value);
        case ID_USTYPE:
                return ToChar(data->ppd_opt->us_type == 0 ? "False" : "True");
	case ID_LIST_MEDIATYPE:
		return IntToChar(data->ppd_opt->list_mediatype_value);
  case ID_LIST_PAGESIZE:
      return IntToChar(data->ppd_opt->list_pagesize_value);
	case ID_SECURED_DOCNAME:
		if(data->ppd_opt->special == NULL)
			return NULL;
		else
#ifndef _OPAL
		return ToChar(data->ppd_opt->special->doc_name);
#else
		if(data->ppd_opt->special->doc_name == NULL){
			return ToChar("");
		}else {
			return ToChar(data->ppd_opt->special->doc_name);
		}
#endif
	case ID_SECURED_USRNAME:
		if(data->ppd_opt->special == NULL)
			return NULL;
		else
		return ToChar(data->ppd_opt->special->usr_name);
	case ID_SECURED_PASSWD:
		if(data->ppd_opt->special == NULL)
			return NULL;
		else
		return ToChar(data->ppd_opt->special->passwd_array);
	case ID_COLOR_MODE:
		return IntToChar(data->ppd_opt->color_mode);
	case ID_PRINTERTYPE:
		return IntToChar(data->ppd_opt->printer_type);
	case ID_MAX_COPIES:
		return IntToChar(data->ppd_opt->max_copy_num);
	case ID_SPECIAL_FUNC:
		return ToChar(data->ppd_opt->special != NULL ? "1" : "0");
	case ID_DOC_LENGTH:
		return IntToChar(data->ppd_opt->max_doc_length);
	case ID_DUPLEX:
		option = IDtoPPDOption(id - 1);
		if(option == NULL)
			return NULL;
#ifdef	__APPLE__
			return MakePPDOptionList(data->ppd_opt, "Duplex");
#else
			return MakeDuplexBoolList(data->ppd_opt);
#endif
	case ID_BOOKLET:
	case ID_CNSADDLESTITCH:
	case ID_CNTRIMMING:
	case ID_CNZFOLDING:
	case ID_CNINSERTER:
	case ID_CNPUREBLACKPROCESS:
	case ID_CNPUNCHER:
	case ID_CNFOLDER:
	case ID_CNINSERTUNIT:
	case ID_CNTRIMMER:
	case ID_CNDUPLEXUNIT:
	case ID_CNSUPERSMOOTH:
	case ID_CNBACKPAPERPRINT:
	case ID_CNROTATEPRINT:
	case ID_CNCOPYSETNUMBERING:
	case ID_CNINTERLEAFSHEET:
	case ID_CNINTERLEAFPRINT:
	case ID_CNSKIPBLANK:
	case ID_CNDETECTPAPERSIZE:
	case ID_CNRGBPUREBLACKPROCESS:
	case ID_CNUSEGRAYSCALEPROFILE:
	case ID_CNLASTPAGEPRINTMODE:
	case ID_CNSET_FRONT_COVER:
	case ID_CNSET_BACK_COVER:
	case ID_CNSPECIFYNUMOFCOPIESSTACK:
	case ID_CNVFOLDING:
	case ID_CNPROPUNCHER:
		option = IDtoPPDOption(id - 1);
		if(option == NULL)
			return NULL;
#ifdef	__APPLE__
		if(data->ppd_opt->printer_type != PRINTER_TYPE_CAPT)
		{
			switch(id){
			case ID_CNPUNCHER:
			case ID_BOOKLET:
			case ID_CNFOLDER:
			case ID_CNTRIMMER:
			case ID_CNINSERTUNIT:
			case ID_CNLASTPAGEPRINTMODE:
			case ID_CNPROPUNCHER:
				return MakePPDOptionList(data->ppd_opt, option);
			default:
				return MakePPDBoolList(data->ppd_opt, option);
			}
		}
		else {
			switch(id){
			case ID_CNSUPERSMOOTH:
				return MakePPDOptionList(data->ppd_opt, option);
			default:
				return MakePPDBoolList(data->ppd_opt, option);
			}
#endif
			return MakePPDBoolList(data->ppd_opt, option);
#ifdef	__APPLE__
		}
#endif
	case ID_CNPUNCH:
		option = IDtoPPDOption(id - 1);
		if(option == NULL)
			return NULL;
		return MakeCNPunchBoolList(data->ppd_opt, option);
	case ID_BOOKLET_DLG:
		option = IDtoPPDOption(ID_BOOKLET - 1);
		if(option == NULL)
			return NULL;
		return MakePPDOptionList(data->ppd_opt, option);
	case ID_STARTNUM:
		return IntToChar(data->ppd_opt->startnum_value);
	case ID_USERID:
		return IntToChar(getuid());
	case ID_BACKPAPERPRINT_LABEL:
		return ToChar(GetItemString(data->ppd_opt->items_list, "CNBackPaperPrint"));
	case ID_DISABLE_JOBACCOUNT_BW:
		if(data->ppd_opt->special == NULL)
			return NULL;
		else
#ifndef	__APPLE__
			return IntToChar(data->ppd_opt->special->disable_job_account_bw);
#else
			return ToChar(data->ppd_opt->special->disable_job_account_bw == 0 ? "False:True<0>,False<0>" : "True:True<0>,False<0>");
#endif
#if !defined(__APPLE__) && !defined(_OPAL)
	case ID_SHOW_JOBACCOUNT:
		if(data->ppd_opt->special == NULL)
		{
			return NULL;
		}
		else
		{
			return IntToChar(data->ppd_opt->special->show_job_account);
		}
		break;
#endif
	case ID_SHOW_DISABLE_JOBACCOUNT_BW:
		if(data->ppd_opt->special == NULL)
			return NULL;
		else
		return IntToChar(data->ppd_opt->special->show_disable_job_account_bw);
	case ID_DETECTPAPER_LABEL:
		return ToChar(GetItemString(data->ppd_opt->items_list, "CNDetectPaperSize"));
	case ID_CNDPICONPICTID:
		if(data->ppd_opt->dpicon_pictid > 0)
			return IntToChar(data->ppd_opt->dpicon_pictid);
		break;
	case ID_CNENABLEFINISHFLAG:
		if(data->ppd_opt->enable_finishflag > 0)
			return IntToChar(data->ppd_opt->enable_finishflag);
		break;
	case ID_CNENABLEINPUTFLAG:
		if(data->ppd_opt->enable_inputflag > 0)
			return IntToChar(data->ppd_opt->enable_inputflag);
		break;
	case ID_CNENABLEQUALITYTYPE:
		if(data->ppd_opt->enable_qualitytype > 0)
			return IntToChar(data->ppd_opt->enable_qualitytype);
		break;
	case ID_INPUTSLOT_TYPE:
		return IntToChar(data->ppd_opt->input_slot_type);

	case ID_CNSHIFTTYPE:
		return IntToChar(data->ppd_opt->shift_pos_type);
	case ID_CNSHIFTUPWARDS:
		if((option = GetUIValue(data, "CNEnableDetailShiftPosition")) != NULL){
			if(strcasecmp(option,"True") == 0){
				return DoubleToChar(data->ppd_opt->detail_shift_upwards);
			}
		}
		return IntToChar(data->ppd_opt->shift_upwards);
	case ID_CNSHIFTRIGHT:
		if((option = GetUIValue(data, "CNEnableDetailShiftPosition")) != NULL){
			if(strcasecmp(option,"True") == 0){
				return DoubleToChar(data->ppd_opt->detail_shift_right);
			}
		}
		return IntToChar(data->ppd_opt->shift_right);
	case ID_CNSHIFTFRLONGEDGE:
		if((option = GetUIValue(data, "CNEnableDetailShiftPosition")) != NULL){
			if(strcasecmp(option,"True") == 0){
				return DoubleToChar(data->ppd_opt->detail_shift_front_long);
			}
		}
		return IntToChar(data->ppd_opt->shift_front_long);
	case ID_CNSHIFTFRSHORTEDGE:
		if((option = GetUIValue(data, "CNEnableDetailShiftPosition")) != NULL){
			if(strcasecmp(option,"True") == 0){
				return DoubleToChar(data->ppd_opt->detail_shift_front_short);
			}
		}
		return IntToChar(data->ppd_opt->shift_front_short);
	case ID_CNSHIFTBKLONGEDGE:
		if((option = GetUIValue(data, "CNEnableDetailShiftPosition")) != NULL){
			if(strcasecmp(option,"True") == 0){
				return DoubleToChar(data->ppd_opt->detail_shift_back_long);
			}
		}
		return IntToChar(data->ppd_opt->shift_back_long);
	case ID_CNSHIFTBKSHORTEDGE:
		if((option = GetUIValue(data, "CNEnableDetailShiftPosition")) != NULL){
			if(strcasecmp(option,"True") == 0){
				return DoubleToChar(data->ppd_opt->detail_shift_back_short);
			}
		}
		return IntToChar(data->ppd_opt->shift_back_short);
	case ID_CNSHIFTPOSITIONMAX:
		return cngplpGetValue(data,kPPD_Items_CNShiftPositionMax);
	case ID_CNSHIFTPOSITIONMIN:
		return cngplpGetValue(data,kPPD_Items_CNShiftPositionMin);
	case ID_CNJOBNOTE:
		if(data->ppd_opt->job_note == NULL)
			return NULL;
		else
		return ToChar(data->ppd_opt->job_note->note);
	case ID_CNJOBDETAILS:
		if(data->ppd_opt->job_note == NULL)
			return NULL;
		else
		return ToChar(data->ppd_opt->job_note->details);
	case ID_CNFINDETAILS:
      option = GetUIValue(data, kPPD_Items_CNFinDetails);
      if(option == NULL)
		return 0;
      return IntToChar((strcasecmp(option, "true") == 0) ? 1 : 0);
	case ID_CNOFFSETNUM:
		return IntToChar(data->ppd_opt->offset_num);
	case ID_CNUIOFFSETMAX:
		return cngplpGetValue(data,kPPD_Items_CNUIOffsetMax);
	case ID_CNGUTTERSHIFTNUM:
		return DoubleToChar2(data->ppd_opt->guttershiftnum_value_d);

	case ID_MAX_GUTTER_SHIFT_NUM:
		return cngplpGetValue(data,kPPD_Items_CNMAXGutterShiftNum);
	case ID_MIN_GUTTER_SHIFT_NUM:
		return cngplpGetValue(data,kPPD_Items_CNMINGutterShiftNum);
	case ID_CNTABSHIFT:
		return DoubleToChar(data->ppd_opt->tab_shift);
	case ID_DRIVERROOTPATH:
		if(data->ppd_opt->drv_root_path == NULL)
			return NULL;
		else
			return ToChar(data->ppd_opt->drv_root_path);
	case ID_CNMEDIABRANDLIST:
		return MakeMediaBrandListChar(data->ppd_opt);
	case ID_CNMEDIABRAND:
		return MakeMediaBrandChar(data->ppd_opt);
	case ID_CNINSERTMEDIABRANDLIST:
		return MakeInsertMediaBrandListChar(data->ppd_opt);
	case ID_CNINSERTMEDIABRAND:
		return MakeInsertMediaBrandChar(data->ppd_opt);
	case ID_CNINTERLEAFMEDIABRANDLIST:
		return MakeInterleafMediaBrandListChar(data->ppd_opt);
	case ID_CNINTERLEAFMEDIABRAND:
		return MakeInterleafMediaBrandChar(data->ppd_opt);
	case ID_CNPBINDCOVERMEDIABRANDLIST:
		return MakePBindCoverMediaBrandListChar(data->ppd_opt);
	case ID_CNPBINDCOVERMEDIABRAND:
		return MakePBindCoverMediaBrandChar(data->ppd_opt);
	case ID_CNINSERTTABSHIFT:
		return DoubleToChar(data->ppd_opt->ins_tab_shift);
	case ID_CNINSERTPOS:
		return ToChar(data->ppd_opt->ins_pos);
	case ID_CNINSERTPOSPAPERSOURCE:
		return ToChar(data->ppd_opt->ins_pos_papersource);
	case ID_CNINSERTPOSPRINTON:
		return ToChar(data->ppd_opt->ins_pos_printon);
	case ID_CNTABINSERTPOS:
		return ToChar(data->ppd_opt->tab_ins_pos);
	case ID_CNTABINSERTPOSPAPERSOURCE:
		return ToChar(data->ppd_opt->tab_ins_pos_papersource);
	case ID_CNTABINSERTPOSPRINTON:
		return ToChar(data->ppd_opt->tab_ins_pos_printon);
	case ID_CNTABINSERTMULTIPAPERNUMBER:
		return IntToChar(data->ppd_opt->tab_ins_multi_number);
	case ID_CNTABINSERTMULTIPAPERSOURCE:
		return ToChar(data->ppd_opt->tab_ins_multi_papersource);
	case ID_CNTABINSERTMULTIPAPERTYPE:
		return ToChar(data->ppd_opt->tab_ins_multi_papertype);
	case ID_CNBINNAME:
		return ToChar(data->ppd_opt->bin_name);
	case ID_CNBINNAME_ARRAY:
		return ToChar(data->ppd_opt->bin_name_array);
	case ID_CNOVERLAYFILENAME:
		if(data->ppd_opt->special == NULL)
			return NULL;
		else
		return ToChar(data->ppd_opt->special->form_name);
	case ID_CNFORMHANDLE:
		if(data->ppd_opt->special == NULL)
			return NULL;
		else
		return ToChar(data->ppd_opt->special->form_handle);
	case ID_CNFORMLIST:
		return MakeFormListChar(data->ppd_opt);
	case ID_CNADJUSTTRIMNUM:
		return DoubleToChar(data->ppd_opt->adjust_trim_num);
	case ID_CNUITRIMVALMAX:
		return cngplpGetValue(data, kPPD_Items_CNUITrimValMax);
	case ID_CNUITRIMVALMIN:
		return cngplpGetValue(data, kPPD_Items_CNUITrimValMin);
	case ID_CNADJUSTFORETRIMNUM:
		return DoubleToChar(data->ppd_opt->adjust_frtrim_num);
	case ID_CNADJUSTTOPBOTTOMTRIMNUM:
		return DoubleToChar(data->ppd_opt->adjust_tbtrim_num);
	case ID_CNPBINDFINISHFORETRIMNUM:
		return DoubleToChar(data->ppd_opt->pb_fin_fore_trim_num);
	case ID_CNPBINDFINISHTOPBOTTOMTRIMNUM:
		return DoubleToChar(data->ppd_opt->pb_fin_topbtm_trim_num);
	case ID_CNSENDTIMENUM:
		if(data->ppd_opt->fax_setting == NULL)
			return NULL;
		else
		return ToChar(data->ppd_opt->fax_setting->send_time);
	case ID_CNOUTSIDELINENUMBER:
		if(data->ppd_opt->fax_setting == NULL)
			return NULL;
		else
		return ToChar(data->ppd_opt->fax_setting->outside_line_number);
	case ID_CNOUTSIDELINENUMINTRA:
		if(data->ppd_opt->fax_setting == NULL)
			return NULL;
		else
		return ToChar(data->ppd_opt->fax_setting->outside_line_number_intra);
	case ID_CNOUTSIDELINENUMNGN:
		if(data->ppd_opt->fax_setting == NULL)
			return NULL;
		else
		return ToChar(data->ppd_opt->fax_setting->outside_line_number_ngn);
	case ID_CNOUTSIDELINENUMMYNUMBERNGN:
		if(data->ppd_opt->fax_setting == NULL)
			return NULL;
		else
		return ToChar(data->ppd_opt->fax_setting->outside_line_number_ngnmynum);
	case ID_CNOUTSIDELINENUMVOIP:
		if(data->ppd_opt->fax_setting == NULL)
			return NULL;
		else
		return ToChar(data->ppd_opt->fax_setting->outside_line_number_voip);
	case ID_CNSENDER:
		if(data->ppd_opt->fax_setting == NULL)
			return NULL;
		else
			return ToChar(data->ppd_opt->fax_setting->sender_name);
	case ID_HOLD_NAME:
		if(data->ppd_opt->special == NULL)
			return NULL;
		else
		return ToChar(data->ppd_opt->special->hold_name);
	case ID_HOLDQUEUE_DATANAME:
		if(data->ppd_opt->special == NULL)
			return NULL;
		else
		return IntToChar(data->ppd_opt->special->holddata_name);
	case ID_CNFEEDPAPERNAME:
		if(data->ppd_opt->feed_paper_name == NULL)
			return NULL;
		else
			return ToChar(data->ppd_opt->feed_paper_name);
	case ID_CNSADDLESETTING:
		option = IDtoPPDOption(id - 1);
		if(option == NULL)
			return NULL;
		return MakeCNSaddleSettingList(data->ppd_opt, option);
	case ID_CNSTACKCOPIESNUM:
		return IntToChar(data->ppd_opt->stack_copies_num);
	case ID_CNSADDLEPRESSADJUSTMENT:
		return IntToChar(data->ppd_opt->saddle_press_adjust);
	case ID_CNLISTIDSPECIALPRINTMODE:
		return IntToChar(data->ppd_opt->list_specialprintmode_value);
#ifndef	__APPLE__
	case ID_ENABLECNOFFSETNUM:
		return ToChar(GetUIValue(data, "EnableCNOffsetNum"));
	case ID_CNFOLDSETTING:
		option = IDtoPPDOption(id - 1);
		if(option == NULL){
			return NULL;
		}
		return MakeCNFoldSettingList(data->ppd_opt, option);
	case ID_CNPRINTSTYLE:
		option = IDtoPPDOption(id - 1);
		if(option == NULL){
			return NULL;
		}
		return MakeCNPrintStyleList(data->ppd_opt, option);
#endif
	case ID_PCFILENAME:
		return ToChar(data->ppd_opt->pcfile_name);
	case ID_MANUFACTURER:
		return ToChar(data->ppd_opt->manufacturer);
	case ID_NICKNAME:
		return ToChar(data->ppd_opt->nickname);
	case ID_CNPDLTYPE:
		return ToChar(data->ppd_opt->cnpdl_type);
	case ID_APPRINTERICONPATH:
		return ToChar(data->ppd_opt->ap_printer_icon_path);
	case ID_CONFLICTCNOFFSETNUM:
		return IntToChar(GetOffsetNumConflict(data));
	case ID_ENABLEINSERTPOSPAPERSOURCE:
		return MakeEnableInsertPosPaperSource(data, 0);
	case ID_ENABLETABINSERTPOSPAPERSOURCE:
		return MakeEnableInsertPosPaperSource(data, 1);
	default:
		option = IDtoPPDOption(id - 1);
		if(option == NULL)
			return NULL;
		return MakePPDOptionList(data->ppd_opt, option);
	}

	return NULL;
}
Ejemplo n.º 13
0
void CreditCard::GenerateCreditCardNumber() {
	for(int i = 0; i < 15; i++) {
		CreditCardNumber += IntToChar(rand() % 10);	
	}
}
Ejemplo n.º 14
0
void sensorcommunication_sendIntMsg(int left, int right)
{
	SENSORCOMMUNICATION_MESSAGE theMessage;
	//send message sequence byte
	theMessage.type = sensorcommunicationData.sensorIntTxMsgSeq;
	theMessage.msg = STARTBYTE;
	if(xQueueSend(sensorcommunicationData.sensorIntQueue, (void*)&(theMessage), 0) == pdTRUE)
	{
		sensorcommunicationData.sensorIntTxMsgSeq++;
	}
	//send from rover byte
	theMessage.type = sensorcommunicationData.sensorIntTxMsgSeq;
	theMessage.msg = sensorcommunicationData.sensorTxMsgSeq;	
	if(xQueueSend(sensorcommunicationData.sensorIntQueue, (void*)&(theMessage), 0) == pdTRUE)
	{
		sensorcommunicationData.sensorIntTxMsgSeq++;
	}
	//send left 1 of 4
	if(left > 9999)
		left = 9999;
	if(right > 9999)
		right = 9999;
	int leftxmit[4];
	int rightxmit[4];
	leftxmit[3] = left % 10;
	left /= 10;
	leftxmit[2] = left % 10;
	left /= 10;
	leftxmit[1] = left % 10;
	left /= 10;
	leftxmit[0] = left % 10;
	rightxmit[3] = right%10;
	right /= 10;
	rightxmit[2] = right%10;
	right /= 10;
	rightxmit[1] = right%10;
	right /= 10;
	rightxmit[0] = right%10;
	theMessage.type = sensorcommunicationData.sensorIntTxMsgSeq;
	theMessage.msg = IntToChar(leftxmit[0]);	
	if(xQueueSend(sensorcommunicationData.sensorIntQueue, (void*)&(theMessage), 0) == pdTRUE)
	{
		sensorcommunicationData.sensorIntTxMsgSeq++;
	}
	//send left 2 of 4
	theMessage.type = sensorcommunicationData.sensorIntTxMsgSeq;
	theMessage.msg = IntToChar(leftxmit[1]);
	if(xQueueSend(sensorcommunicationData.sensorIntQueue, (void*)&(theMessage), 0) == pdTRUE)
	{
		sensorcommunicationData.sensorIntTxMsgSeq++;
	}
	//send left 3 of 4
	theMessage.type = sensorcommunicationData.sensorIntTxMsgSeq;
	theMessage.msg = IntToChar(leftxmit[2]);	
	if(xQueueSend(sensorcommunicationData.sensorIntQueue, (void*)&(theMessage), 0) == pdTRUE)
	{
		sensorcommunicationData.sensorIntTxMsgSeq++;
	}
	//send 4 of 4
	theMessage.type = sensorcommunicationData.sensorIntTxMsgSeq;
	theMessage.msg = IntToChar(leftxmit[3]);	
	if(xQueueSend(sensorcommunicationData.sensorIntQueue, (void*)&(theMessage), 0) == pdTRUE)
	{
		sensorcommunicationData.sensorIntTxMsgSeq++;
	}
	//send right 1 of 4
	theMessage.type = sensorcommunicationData.sensorIntTxMsgSeq;
	theMessage.msg = IntToChar(rightxmit[0]);	
	if(xQueueSend(sensorcommunicationData.sensorIntQueue, (void*)&(theMessage), 0) == pdTRUE)
	{
		sensorcommunicationData.sensorIntTxMsgSeq++;
	}
	//send right 2 of 4
	theMessage.type = sensorcommunicationData.sensorIntTxMsgSeq;
	theMessage.msg = IntToChar(rightxmit[1]);	
	if(xQueueSend(sensorcommunicationData.sensorIntQueue, (void*)&(theMessage), 0) == pdTRUE)
	{
		sensorcommunicationData.sensorIntTxMsgSeq++;
	}
	//send right 3 of 4
	theMessage.type = sensorcommunicationData.sensorIntTxMsgSeq;
	theMessage.msg = IntToChar(rightxmit[2]);		
	if(xQueueSend(sensorcommunicationData.sensorIntQueue, (void*)&(theMessage), 0) == pdTRUE)
	{
		sensorcommunicationData.sensorIntTxMsgSeq++;
	}
	//send right 4 of 4
	theMessage.type = sensorcommunicationData.sensorIntTxMsgSeq;
	theMessage.msg = IntToChar(rightxmit[3]);		
	if(xQueueSend(sensorcommunicationData.sensorIntQueue, (void*)&(theMessage), 0) == pdTRUE)
	{
		sensorcommunicationData.sensorIntTxMsgSeq++;
	}
	sensorcommunicationData.sensorTxMsgSeq++;
	int temp = (int)sensorcommunicationData.sensorTxMsgSeq;
	if(sensorcommunicationData.sensorTxMsgSeq == 0x7F)
		sensorcommunicationData.sensorTxMsgSeq = 0x00;
	PLIB_INT_SourceEnable(INT_ID_0, INT_SOURCE_USART_3_TRANSMIT);	//ENABLE TX INTERRUPT
}
Ejemplo n.º 15
0
void CStaticText::setText(int init)
{
	char* temp = IntToChar(init);
	itsText = temp;
	delete[] temp;
}
Ejemplo n.º 16
0
void CCharVariable::SetInteger(const int Value)
{
 m_Value = IntToChar(Value);
}
Ejemplo n.º 17
0
char *BigAdd2(char *str1,char *str2)
{
    int len1 = strlen(str1);
    int len2 = strlen(str2);
    int a,b;
    int c =0;
    int num =0;

    int max = len1;
    if(len2>max)
    {
        max = len2;
    }
    int temp = max;
    char *result = (char*)malloc(max+2);
    while(len1 >0 || len2 >0)
    {
        if(len1 >0)
        {
            if(len1 -4 >0)
            {
                a = CharToInt(str1,len1-4,len1-1);
                len1-=4;
            }
            else
            {
                a= CharToInt(str1,0,len1-1);
                len1-=4;
            }
        }
        else
        {
            a=0;
        }

        if(len2>0)
        {
            if(len2-4>0)
            {
                b = CharToInt(str2,len2-4,len2-1);
                len2-=4;
            }
            else
            {
                b= CharToInt(str2,0,len2-1);
                len2-=4;
            }
        }
        else
        {
            b=0;
        }
        num = a+b+c;
        if(num >=10000)
        {
            c=1;
        }
        else
        {
            c=0;
        }
        IntToChar(result,temp-3,temp,num);
        temp -=4;
    }

    *result = c+'0';
    //	temp --;

    *(result+max+1) = '\0';
    return result;
}
Ejemplo n.º 18
0
Archivo: LZ78e.c Proyecto: darkf/LZF
unsigned char* PrintDict(dict_t *dict, unsigned int total_index){	
	dict_t *dict_ptr = dict;
	dict_t *temp_ptr;

	/* calculating needed allocated memory */
	size_t factor_size = WIDTH_DATA + WIDTH_INDEX;
	size_t total_size = factor_size * total_index;
	total_size = total_size + WIDTH_HEADER;
	
	/* allocating and checking for memory */
	unsigned char* output_stream = (unsigned char*) malloc(total_size);
	assert(output_stream != NULL);	
	
	unsigned char* index_char;
	
	int i = 0, j = 0;
	
	/* creating header bytes for output */
	index_char = HeaderDictSize(total_index);
	while(j < WIDTH_HEADER - 1){
		output_stream[j] = index_char[j];
		j++;
	}
	/* freeing memory */
	free(index_char);

	output_stream[j] = (unsigned char) WIDTH_DATA;
	j++;
	output_stream[j] = (unsigned char) WIDTH_INDEX;
	j++;

	/* appending dictionary for output */
	while(dict_ptr != NULL){
		index_char = IntToChar(dict_ptr->parent_index); 
		while(i < 4){
			if(i == 0){
				output_stream[j+i] = dict_ptr->node->data;
			}
			else{
				output_stream[j+i] = index_char[i-1];
			}
			i++;
		}
		temp_ptr = dict_ptr;
		dict_ptr = dict_ptr->next;
		
		/* freeing memory */
		free(index_char);
		index_char = NULL;
		free(temp_ptr->node);
		temp_ptr->node = NULL;
		free(temp_ptr);
		temp_ptr = NULL;
	
		i = 0;
		j += 4;
	}

	/* NULL-dereferencing for safety */
	dict_ptr = NULL;
	return output_stream;
}