コード例 #1
0
ファイル: Source.c プロジェクト: CptDemocracy/The-C-Blues
int main(void)
{
    // initialize to zeros
    struct Product prod = { 0 };

    printf("Enter item number: ");
    ReadInt(&prod.id, &OnInvalidInputHandler);

    printf("Enter unit price: ");
    ReadDouble(&prod.price, &OnInvalidInputHandler);

    printf("Enter purchase date (mm/dd/yyyy): ");
    ReadDate(&prod.purchaseDate, &OnInvalidInputHandler);

    printf("%s\t%s\t%s\n", "Item", "Unit Price", "Purchase Date");
    printf("%d\t$%.2Lf\t\t%02d/%02d/%d\n",
        prod.id,
        prod.price,
        prod.purchaseDate.tm_mon,
        prod.purchaseDate.tm_mday,
        prod.purchaseDate.tm_year);
    getchar();

    return EXIT_SUCCESS;
}
コード例 #2
0
ファイル: NanoLogger.cpp プロジェクト: MindMil/XCSoar
static bool
ParseLogbookContent(const char *_line, RecordedFlightInfo &info)
{
  NMEAInputLine line(_line);

  unsigned n;
  return line.Skip() &&
    line.ReadChecked(n) &&
    ReadFilename(line, info) > 0 &&
    ReadDate(line, info.date) &&
    ReadTime(line, info.start_time) &&
    ReadTime(line, info.end_time);
}
コード例 #3
0
ファイル: xGLOBinit.c プロジェクト: oeli/yafra
int GLOBsave(MP_PROFIL *aProf, GLOBDATA *aGlobdata)
{
    extern int sprache;

    extern int glob_spr_bez;
    extern char glob_host_dlt[];
    extern char glob_dlt_bch[];

    extern SPRACHEN globSPR;
    extern LAND globLAND;
    extern TRAEGER_TYP globDLTT;
    extern DIENST_TRAEGER globDLT;
    extern KATEGORIE globKAT;
    extern ANGEBOTS_TYP globDLAT;
    extern REISENDER_TYP globDLNT;
    extern SAISON globSAI;
    extern PROGRAMM globPRG;
    extern int globA_ZEIT;
    extern int globE_ZEIT;
    extern int globP_RANGE;

    struct tm DateTime;
    int status = (int)MPOK;
    int id;

    (void)memcpy((void *)aGlobdata, (void *)comm.buffer, sizeof(GLOBDATA));
    globDLTT.typ_id = (int)_UNDEF;
    globDLTT.bez_id = (int)_UNDEF;
    globKAT.kat_id = (int)_UNDEF;
    globKAT.typ_id = (int)_UNDEF;
    globDLT.dlt_id = (int)_UNDEF;
    globDLT.bez_id = (int)_UNDEF;
    globDLT.typ_id = (int)_UNDEF;
    globDLT.kat_id = (int)_UNDEF;
    globDLT.stufe = (int)0;
    globDLAT.art_id = (int)_UNDEF;
    globDLAT.bez_id = (int)_UNDEF;
    globDLNT.rkr_id = (int)_UNDEF;
    globDLNT.bez_id = (int)_UNDEF;
    globSAI.sai_id = (int)_UNDEF;
    globSAI.bez_id = (int)_UNDEF;
    globPRG.prg_id = (int)_UNDEF;
    globPRG.bez_id = (int)_UNDEF;
    globA_ZEIT=(int)_UNDEF;
    globE_ZEIT=(int)_UNDEF;
    globP_RANGE=(int)_UNDEF;

    /* begin trx */
    status=MPAPIdb_begintrx(SQLISOLATION_RU, SQLPRIO_NORMAL);
    if (status != MPOK)
    {
        UtilMsg(status, MSGTYP_DBERROR, NULL);
        status=(int)MPERROR;
    }

    /* SPRACHEN */
    if (*aGlobdata->sprache != NULL)
    {
        id = MPAPIselectEntry((int)_SPRACHEN, aGlobdata->sprache,
                              (char *)&globSPR, sizeof(SPRACHEN), sizeof(globSPR.s_id));
        if (id != _UNDEF)
        {
            aProf->s_id = globSPR.s_id;
            glob_spr_bez = sprache = aProf->s_id;
        }
    }

    /* LAND */
    if (*aGlobdata->land != NULL)
    {
        id = MPAPIselectEntry((int)_LAND, aGlobdata->land,
                              (char *)&globLAND, sizeof(LAND), sizeof(globLAND.land_id));
        if (id != _UNDEF)
            aProf->land_id = globLAND.land_id;
    }

    /*	TRAEGER_TYP */
    if (*aGlobdata->dltt != NULL)
    {
        id = MPAPIselectEntry((int)_TRAEGER_TYP, aGlobdata->dltt,
                              (char *)&globDLTT, sizeof(TRAEGER_TYP), sizeof(globDLTT.typ_id));
        if (id != _UNDEF)
            aProf->dltt_id = globDLTT.typ_id;
    }

    /*	KATEGORIE */
    if (*aGlobdata->kat != NULL)
    {
        id = MPAPIselectEntry((int)_KATEGORIE, aGlobdata->kat,
                              (char *)&globKAT, sizeof(KATEGORIE), sizeof(globKAT.kat_id));
        if (id != _UNDEF)
            aProf->kat_id = globKAT.kat_id;
    }

    /* DIENST_TRAEGER */
    globDLT.stufe = (int)1;
    if (*aGlobdata->dlt != NULL)
    {
        id = MPAPIselectEntry((int)_DIENST_TRAEGER, aGlobdata->dlt,
                              (char *)&globDLT, sizeof(DIENST_TRAEGER), sizeof(globDLT.dlt_id));
        if (id != _UNDEF)
        {
            aProf->dlt_id = globDLT.dlt_id;
            strcpy(glob_host_dlt, aGlobdata->dlt);
            strcpy(glob_dlt_bch, aGlobdata->dlt);
        }
    }

    /*	ANGEBOTS_TYP */
    if (*aGlobdata->dlat != NULL)
    {
        id = MPAPIselectEntry((int)_ANGEBOTS_TYP, aGlobdata->dlat,
                              (char *)&globDLAT, sizeof(ANGEBOTS_TYP), sizeof(globDLAT.art_id));
        if (id != _UNDEF)
            aProf->dlat_id = globDLAT.art_id;
    }

    /*	REISENDER_TYP DLNT */
    if (*aGlobdata->dlnt != NULL)
    {
        id = MPAPIselectEntry((int)_REISENDER_TYP, aGlobdata->dlnt,
                              (char *)&globDLNT, sizeof(REISENDER_TYP), sizeof(globDLNT.rkr_id));
        if (id != _UNDEF)
            aProf->dlnt_id = globDLNT.rkr_id;
    }

    /*	SAISON */
    if (*aGlobdata->saison != NULL)
    {
        id = MPAPIselectEntry((int)_SAISON, aGlobdata->saison,
                              (char *)&globSAI, sizeof(SAISON), sizeof(globSAI.sai_id));
        if (id != _UNDEF)
            aProf->sai_id = globSAI.sai_id;
    }

    /*	PROGRAMM */
    if (*aGlobdata->programm != NULL)
    {
        id = MPAPIselectEntry((int)_PROGRAMM, aGlobdata->programm,
                              (char *)&globPRG, sizeof(PROGRAMM), sizeof(globPRG.prg_id));
        if (id != _UNDEF)
            aProf->prg_id = globPRG.prg_id;
    }

    /*	Abfahrtszeit */
    if (*aGlobdata->a_zeit != NULL)
    {
        (void)memset((void *)&DateTime, NULL, sizeof(DateTime));
        DateTime.tm_mday=(int)_UNDEF;
        DateTime.tm_mon =(int)_UNDEF;
        DateTime.tm_year=(int)_UNDEF;
        DateTime.tm_hour=(int)_UNDEF;
        DateTime.tm_min=(int)_UNDEF;
        (void)ReadDate(&DateTime, (time_t *)&globA_ZEIT, aGlobdata->a_zeit);
        aProf->a_zeit = globA_ZEIT;
    }

    /*	Globale Ankunftszeit festlegen */
    if (*aGlobdata->e_zeit != NULL)
    {
        (void)memset((void *)&DateTime, NULL, sizeof(DateTime));
        DateTime.tm_mday=(int)_UNDEF;
        DateTime.tm_mon =(int)_UNDEF;
        DateTime.tm_year=(int)_UNDEF;
        DateTime.tm_hour=(int)_UNDEF;
        DateTime.tm_min=(int)_UNDEF;
        (void)ReadDate(&DateTime, (time_t *)&globE_ZEIT, aGlobdata->e_zeit);
        aProf->e_zeit = globE_ZEIT;
    }

    /* set global range for 'planungsboard' */
    if (*aGlobdata->p_range != NULL)
    {
        status = readInteger(&globP_RANGE, aGlobdata->p_range);
        aProf->p_range = globP_RANGE;
    }

    (void)MPAPIdb_committrx();

    /* send GLOBDATA to GUI */
    (void)memcpy((void *)comm.buffer, (void *)aGlobdata, sizeof(GLOBDATA));
    comm.datalen = sizeof(GLOBDATA);

    /* update mp_profil table */

    return(status);
}
コード例 #4
0
ファイル: RESwrite.c プロジェクト: oeli/yafra
/*************************************************************
 * function:  KAPA VIEW make information string
 * typ:       public
 * desc:      get KAPA VIEW entries for a DL or ARR
 * input:     DL or ARR ID as char buffer (dlid\tarrid\t\0)
 *************************************************************/
int RESinsert(char *aInbuf, PSmemobj *aOutbuf)
{
	extern int sprache;
	extern int DebugFlag;
	extern MP_PROFIL prof;
	extern PERSONEN pers;
	extern PERSADR adr;
	extern KUNDEN kun;
	extern KUN_VIEW kunv;
	extern BUCHUNG bch;
	extern BCH_DLN bd;
	extern REISENDER dln;
	extern DIENSTLEISTUNG dl;
	extern ARRANGEMENT arr;
	extern KATEGORIE kat;
	extern RESERVATION res;
	extern SPRACHEN spr;
	extern KUNDEN_TYP kunt;
	extern LAND land;
	extern WAEHRUNG whr;
	extern TEXTE txt;

	BCH_DLN *all_bd    = (BCH_DLN *)NULL;

	char **splitbuffer;
	int anzsplit;
	char **dlnbuffer;
	int anzdlnsplit;
	char onedln[_BEZLEN+1][1];
	char *dlnptr;
	char *tmpptr;
	char attr1[_BEZLEN+1];
	char dln_name[_BEZLEN+1];
	char dln_vorname[_BEZLEN+1];
	char dln_alter[_BEZLEN+1];
	char dln_nat[_BEZLEN+1];
	char dln_sex[_BEZLEN+1];
	char tmpbuf[_RECORDLEN];
	char query[_QUERYLEN];

	int status=(int)MPOK;
	int cret = MPOK;
	int anzdln;
	int i;
	int id;
	size_t len;
	struct tm DateTime;

	int old_bid        = (int)_UNDEF;
	int existing_kid   = (int)_UNDEF;
	int anzbd          = 0;
	unsigned long dlen = 0;
	unsigned long alen = 0;

	if (DebugFlag)
		PSSYSdebug(MPNET_DBGFILE, NULL, "welcome to RESwrite");

	/* Init the aOutbuf memory */
	aOutbuf->datalen = _RECORDLEN;
	if (aOutbuf->datalen > aOutbuf->alloclen)
		aOutbuf->buffer = PSSYSallocobj(aOutbuf, PSMEMCHUNK30);
	(void)sprintf(aOutbuf->buffer, "%d\n%d\n%d\n", PSOK, 1, 1);

	/* split incomming fields from CGI script */
	if (aInbuf != NULL && *aInbuf != NULL)
		{
		splitbuffer = (char **)MPAPIbufferSplit(aInbuf, &anzsplit, (char)'\b');
		if (splitbuffer == NULL || anzsplit != 18)
			{
			UtilMsg((int)MPE_SPLIT, MSGTYP_ERROR, NULL);
			return((int)MPERROR);
			}
		}

	/* set important ID's */
	arr.arr_id = atoi(splitbuffer[0]);
	dl.dlg_id = atoi(splitbuffer[1]);
	kat.kat_id = atoi(splitbuffer[2]);
	anzdln = atoi(splitbuffer[13]);

	old_bid = atoi(splitbuffer[16]);
	if ( strcmp(splitbuffer[16], "0") == (int)MPOK )
		{
		old_bid = (int)_UNDEF;
		}
	else if ( strlen(splitbuffer[16]) > 0 && old_bid == 0)
		{
		UtilMsg((int)MPE_NOBCH, MSGTYP_ERROR, NULL);
		return((int)MPERROR);
		}

	existing_kid = atoi(splitbuffer[17]);
	if ( strcmp(splitbuffer[17], "0") == (int)MPOK )
		{
		existing_kid = (int)_UNDEF;
		}
	else if ( strlen(splitbuffer[17]) > 0 && existing_kid == 0)
		{
		UtilMsg((int)MPE_NOKUNT, MSGTYP_ERROR, NULL);
		return((int)MPERROR);
		}

	if (anzdln < 1 && old_bid == (int)_UNDEF)
		{
		UtilMsg((int)MPE_NODLN, MSGTYP_ERROR, NULL);
		return((int)MPERROR);
		}

	(void)memset((void *)&DateTime, NULL, sizeof(DateTime));
	DateTime.tm_mday=(int)_UNDEF;
	DateTime.tm_mon =(int)_UNDEF;
	DateTime.tm_year=(int)_UNDEF;
	DateTime.tm_hour=(int)0;
	DateTime.tm_min =(int)0;
	(void)ReadDate(&DateTime, (time_t *)&res.a_zeit, splitbuffer[11]);
/*
	(void)memset((void *)&DateTime, NULL, sizeof(DateTime));
	DateTime.tm_mday=(int)_UNDEF;
	DateTime.tm_mon =(int)_UNDEF;
	DateTime.tm_year=(int)_UNDEF;
	DateTime.tm_hour=(int)0;
	DateTime.tm_min =(int)0;
	(void)ReadDate(&DateTime, (time_t *)&res.e_zeit, splitbuffer[12]);
*/
	res.e_zeit = res.a_zeit + (24*60*60)*(atoi(splitbuffer[12]));


	if ( old_bid == (int)_UNDEF )
		{

/*------------------------------------*/
		if (DebugFlag)
			PSSYSdebug(MPNET_DBGFILE, NULL, "inserting KUNDE now");

		if ( existing_kid > 0 )
			{
			id = MPAPIselectOneId((int)_KUN_VIEW, existing_kid, (char *)&kunv);
			if ( id == (int)_UNDEF )
				{
				UtilMsg((int)MPE_NOKUNT, MSGTYP_ERROR, NULL);
				return((int)MPERROR);
				}
			else
				{
				(void)copyTextTo((char *)attr1, kunv.attr1, (int)_BEZLEN);
				if (strcmp(splitbuffer[10], attr1) != (int)MPOK)
					{
					UtilMsg((int)MPE_NOCHOOSE, MSGTYP_ERROR, NULL);
					return((int)MPERROR);
					}
				kun.pers_id = kunv.kun_id;
				bch.kid = kunv.kun_id;
				pers.s_id = sprache;
				(void)copyTextTo((char *)adr.ort, kunv.ort, (int)_BEZLEN);
				}
			}
		else
			{

			/* insert KUNDE + ADR */
			pers.pers_id = (int)_UNDEF;
			pers.sta_id = (int)_UNDEF;
				pers.pers_typ = (int)_PERS_FIRMEN;
			pers.s_id = sprache;
			pers.textid = (int)_UNDEF;
				(void)copyTextTo((char *)pers.name, splitbuffer[3], (int)_BEZLEN);
			(void)copyTextTo((char *)adr.ort, splitbuffer[7], (int)_BEZLEN);
			cret = MPAPIinsertEntry((int)_PERSONEN, (char *)&pers, (BEZEICHNUNG *)NULL);
			if (cret != (int)MPOK)
				return(cret);

			adr.pers_id = pers.pers_id;
			adr.land_id = (int)1;
			*adr.kant = (char)NULL;
			*adr.adr2 = (char)NULL;
			*adr.adr3 = (char)NULL;
			adr.sta_id = (int)_UNDEF;
			(void)copyTextTo((char *)adr.ans, splitbuffer[4], (int)_BEZLEN);
				(void)copyTextTo((char *)adr.adr1, splitbuffer[5], (int)_BEZLEN);
			(void)copyTextTo((char *)adr.plz, splitbuffer[6], (int)_BEZLEN);
			cret = MPAPIinsertEntry((int)_PERSADR, (char *)&adr, (BEZEICHNUNG *)NULL);
			if (cret != (int)MPOK)
				return(cret);

			kun.pers_id = pers.pers_id;
			kun.k_typ_id = (int)1;           /*!! hardcoded */
			kun.whr_id = (int)1;
			*kun.konto = (char)NULL;
			*kun.attr2 = (char)NULL;
			(void)copyTextTo((char *)kun.fax, splitbuffer[8], (int)_BEZLEN);
			(void)copyTextTo((char *)kun.tel, splitbuffer[9], (int)_BEZLEN);
			(void)copyTextTo((char *)kun.attr1, splitbuffer[10], (int)_BEZLEN);
			cret = MPAPIinsertEntry((int)_KUNDEN, (char *)&kun, (BEZEICHNUNG *)NULL);
			if (cret != (int)MPOK)
				return(cret);

			}
/*------------------------*/

		if (DebugFlag)
			PSSYSdebug(MPNET_DBGFILE, NULL, "inserting BUCHUNG now");

		/* insert BUCHUNG with KUNDE as RECHST */
		bch.d_bid = (int)_UNDEF;
		bch.bid = (int)_UNDEF;
		*bch.ref = NULL;
		bch.arr_id = arr.arr_id;
		(void)copyTextTo(bch.anw, prof.mpuser, (int)_USERLEN);
		(void)strcpy(bch.sach, "-");
		(void)time((time_t *)&bch.b_dat);  /* Buchungsdatum setzen */
		(void)time((time_t *)&bch.m_dat);  /* Modifikationsdatum */
		bch.opt_bst = (int)_UNDEF;
		bch.opt_kid = (int)_UNDEF;
		bch.ast = _BCH_EXTWWW;
		bch.sta = _BCH_ENTER;
		bch.sai_id = (int)1;  /*!! muss von der DL oder ARR gelesen werden */
		bch.k_id = (int)_UNDEF;
		bch.kid = kun.pers_id;
		bch.history = (int)_UNDEF;
		bch.b_text = (int)_UNDEF;
		if (*splitbuffer[15] != NULL)
			{
			txt.typ    = (int)_BUCHUNG;
			txt.s_id   = sprache;
			txt.textid = bch.b_text;
			bch.b_text = TXTinsert(splitbuffer[15]);
			}
		cret = MPAPIinsertEntry((int)_BUCHUNG, (char *)&bch, (BEZEICHNUNG *)NULL);
		if (cret != (int)MPOK)
			return(cret);

		bd.bid = bch.bid;
		res.bid = bch.bid;
		if (*splitbuffer[14] != NULL)
			{
			dlnbuffer = (char **)MPAPIbufferSplit(splitbuffer[14], &anzdlnsplit, (char)'\n');
			if (anzdlnsplit == (int)0 && *splitbuffer[14] != (char)NULL)
				anzdlnsplit = 1;
			if ((anzdlnsplit > 1 && dlnbuffer == NULL) || anzdlnsplit < anzdln)
				{
				UtilMsg((int)MPE_SPLIT, MSGTYP_ERROR, NULL);
				return((int)MPERROR);
				}
			}

		if (DebugFlag)
			PSSYSdebug(MPNET_DBGFILE, NULL, "inserting DLNs now");

		}
	else
		{
		if ( existing_kid > 0 )
			{
			id = MPAPIselectOneId((int)_KUN_VIEW, existing_kid, (char *)&kunv);
			if ( id == (int)_UNDEF )
				{
				UtilMsg((int)MPE_NOKUNT, MSGTYP_ERROR, NULL);
				return((int)MPERROR);
				}
			else
				{
				(void)copyTextTo((char *)attr1, kunv.attr1, (int)_BEZLEN);
				if (strcmp(splitbuffer[10], attr1) != (int)MPOK)
					{
					UtilMsg((int)MPE_NOCHOOSE, MSGTYP_ERROR, NULL);
					return((int)MPERROR);
					}
				kun.pers_id = kunv.kun_id;
				bch.kid = kunv.kun_id;
				}
			}
		else
			{
			UtilMsg((int)MPE_NOKUNT, MSGTYP_ERROR, NULL);
			return((int)MPERROR);
			}
		(void)sprintf(query, _SEL_BD_BCH, old_bid);
		status = MPAPIdb_sqlquery((int)_BCH_DLN, (char **)&all_bd, query,
	                	&anzbd, &dlen, &alen);
		if (anzbd > (int)0 && status == (int)MPOK)
			{
			anzdln=anzbd;
			id = MPAPIselectOneId((int)_BUCHUNG, old_bid, (char *)&bch);
			if ( bch.bid == (int)_UNDEF)
				{
				UtilMsg((int)MPE_NOENTRYFOUND, MSGTYP_ERROR, NULL);
				return((int)MPERROR);
				}
			/* check the KundenID with the booking */
			if (bch.kid != kunv.kun_id)
				{
				UtilMsg((int)MPE_NOKUNT, MSGTYP_ERROR, NULL);
				return((int)MPERROR);
				}
			}
		else
			{
			UtilMsg((int)MPE_NOENTRYFOUND, MSGTYP_ERROR, NULL);
			return((int)MPERROR);
			}
		}


	/* insert REI */
	for (i = 0; i < anzdln; i++)
		{
		if ( anzbd == (int)0 && old_bid == (int)_UNDEF )
			{
			if (anzdln == 1)
				dlnptr = splitbuffer[14];
			else
				dlnptr = dlnbuffer[i];
			len = strlen(dlnptr);
			if (dlnptr[len - 1] == '\r')
				dlnptr[len - 1] = (char)NULL;

			/* NAME */
			tmpptr = strpbrk(dlnptr, ", ");
			if (tmpptr != (char)NULL)
				*tmpptr = (char)NULL;
			(void)strcpy(dln_name, dlnptr);
			dlnptr = (tmpptr + 2);

			/* VORNAME */
			tmpptr = strpbrk(dlnptr, ", ");
			if (tmpptr != (char)NULL)
				*tmpptr = (char)NULL;
			(void)strcpy(dln_vorname, dlnptr);
			dlnptr = (tmpptr + 2);

			/* SEX */
			tmpptr = strpbrk(dlnptr, ", ");
			if (tmpptr != (char)NULL)
				*tmpptr = (char)NULL;
			(void)strcpy(dln_sex, dlnptr);
			dlnptr = (tmpptr + 2);

			/* NATIONALITAET */
			(void)strcpy(dln_nat, dlnptr);

			/* insert PERSONEN - inherit all except name */
			pers.pers_id = (int)_UNDEF;
			pers.pers_typ = (int)_PERS_PRIVAT;
			(void)copyTextTo((char *)pers.name, dln_name, (int)_BEZLEN);
			cret = MPAPIinsertEntry((int)_PERSONEN, (char *)&pers, (BEZEICHNUNG *)NULL);
			if (cret != (int)MPOK)
				return(cret);

			/* insert ADRESSE - inherit all */
			adr.pers_id = pers.pers_id;
			cret = MPAPIinsertEntry((int)_PERSADR, (char *)&adr, (BEZEICHNUNG *)NULL);
			if (cret != (int)MPOK)
				return(cret);

			/* insert REISENDER */
			dln.pers_id = pers.pers_id;
			(void)copyTextTo((char *)dln.vor, dln_vorname, (int)_BEZLEN);
			dln.rkr_id = 1;
			dln.sex = atoi(dln_sex);
			dln.mutters_id = (int)_UNDEF;
			(void)copyTextTo((char *)dln.age, dln_alter, (int)_BEZLEN);
			(void)strcpy(dln.passnr, "-");
			(void)copyTextTo((char *)dln.attr1, dln_nat, (int)_BEZLEN);
			*dln.attr2 = (char)NULL;
			cret = MPAPIinsertEntry((int)_REISENDER, (char *)&dln, (BEZEICHNUNG *)NULL);
			if (cret != (int)MPOK)
				return(cret);

			/* insert BCH_DLN */
			bd.dln_id = dln.pers_id;
			cret = MPAPIinsertEntry((int)_BCH_DLN, (char *)&bd, (BEZEICHNUNG *)NULL);
			if (cret != (int)MPOK)
				return(cret);

			}
		else if ( anzbd > (int)0 && old_bid != (int)_UNDEF )
			{
			dln.pers_id = all_bd[i].dln_id;
			}

		/* insert RES */
		/* insert AKTD */
		/* update KAPA */
		res.dlg_id = dl.dlg_id;
		res.dl_id = (int)_UNDEF;
		res.pers_id = dln.pers_id;
		res.teil = (int)_UNDEF;
		res.dlt_id = (int)_UNDEF;
		res.typ_id = (int)_UNDEF;
		res.bid = bch.bid;
		res.kont_id = (int)_UNDEF;
		res.kat_id = kat.kat_id;
		res.k_kon = (int)_UNDEF;
		res.b_kon = (int)_UNDEF;
		res.r_sta = (int)_UNDEF;
		res.sai_id = (int)_UNDEF;
		res.textid = (int)_UNDEF;
		cret = RESwrite(bch.bid, dln.pers_id, res.dlg_id, 0, (int *)NULL, &res);
		if (cret == (int)MPOK)
			cret = AKTDwrite(bch.bid, dln.pers_id, res.dlg_id, &res);
		if (cret != (int)MPOK)
			return(cret);

		if (DebugFlag)
			PSSYSdebug(MPNET_DBGFILE, NULL, "insert of DLN no %d done", i);
		}

	MPfreearray(splitbuffer, anzsplit);
	if (anzdlnsplit > (int)1 && old_bid == (int)_UNDEF)
		MPfreearray(dlnbuffer, anzdlnsplit);
	else if ( old_bid != (int)_UNDEF)
		MPfree((char *)all_bd);

	(void)sprintf(tmpbuf, "%d\t%d\r\n", bch.bid, bch.kid);
	(void)strcat(aOutbuf->buffer, tmpbuf);
	aOutbuf->datalen = strlen(aOutbuf->buffer);

	if (DebugFlag)
		PSSYSdebug(MPNET_DBGFILE, NULL, "free up and return from RESwrite");

	return(cret);
}
コード例 #5
0
ファイル: Parser.cpp プロジェクト: ThomasXBMC/XCSoar
bool
NMEAParser::RMC(NMEAInputLine &line, NMEAInfo &info)
{
    /*
     * $--RMC,hhmmss.ss,A,llll.ll,a,yyyyy.yy,a,x.x,x.x,xxxx,x.x,a,m,*hh
     *
     * Field Number:
     *  1) UTC Time
     *  2) Status, V=Navigation receiver warning A=Valid
     *  3) Latitude
     *  4) N or S
     *  5) Longitude
     *  6) E or W
     *  7) Speed over ground, knots
     *  8) Track made good, degrees true
     *  9) Date, ddmmyy
     * 10) Magnetic Variation, degrees
     * 11) E or W
     * 12) FAA mode indicator (NMEA 2.3 and later)
     * 13) Checksum
     */

    fixed this_time;
    if (!ReadTime(line, info.date_time_utc, this_time))
        return true;

    bool gps_valid = !NAVWarn(line.ReadFirstChar());

    GeoPoint location;
    bool valid_location = ReadGeoPoint(line, location);

    fixed speed;
    bool ground_speed_available = line.ReadChecked(speed);

    Angle track;
    bool track_available = ReadBearing(line, track);

    // JMW get date info first so TimeModify is accurate
    ReadDate(line, info.date_time_utc);

    Angle variation;
    bool variation_available = ReadVariation(line, variation);

    if (!TimeHasAdvanced(this_time, info))
        return true;

    if (!gps_valid)
        info.location_available.Clear();
    else if (valid_location)
        info.location_available.Update(info.clock);

    if (valid_location)
        info.location = location;

    if (ground_speed_available) {
        info.ground_speed = Units::ToSysUnit(speed, Unit::KNOTS);
        info.ground_speed_available.Update(info.clock);
    }

    if (track_available && info.MovementDetected()) {
        // JMW don't update bearing unless we're moving
        info.track = track;
        info.track_available.Update(info.clock);
    }

    if (!variation_available)
        info.variation_available.Clear();
    else if (variation_available) {
        info.variation = variation;
        info.variation_available.Update(info.clock);
    }

    info.gps.real = real;
#if defined(ANDROID) || defined(__APPLE__)
    info.gps.nonexpiring_internal_gps = false;
#endif

    return true;
}
コード例 #6
0
ファイル: SYSDEP1.C プロジェクト: dylancarlson/citadel-86
void CitGetFileList(char *mask, SListBase *list, long before, long after,
								char *phrase)
{
    struct ffblk   FlBlock;
    extern char    *monthTab[13];
    char	   *w, *work, *sp, again, buf[10];
    DirEntry       *fp;
    int		   done;
    struct stat    buff;
    long	   time;

    w = work = strdup(mask);

    do {
	again = (sp = strchr(work, ' ')) != NULL;      /* space is separator */
	if (again) {
	    *sp = 0;
	}
	/* Do all scanning for illegal requests here */
	if (!ValidDirFileName(work))
	    continue;

	/* this checks for illegal file names like CON:, PRN:, etc. */
	if (stat(work, &buff) == 0)
	    if (buff.st_mode & S_IFCHR)
		continue;

	for (done = findfirst(work, &FlBlock, 0); !done; 
						done = findnext(&FlBlock)) {
	    /* format date to our standards */
	    DosToNormal(buf, FlBlock.ff_fdate);

	    /* now read it so we can handle date specs */
	    ReadDate(buf, &time);

	    /* add to list iff dates inactive or we meet the specs */
	    if ((before != -1l && time > before) ||
				(after  != -1l && time < after))
		continue;

	    fp = (DirEntry *) GetDynamic(sizeof *fp);

	    fp->unambig = strdup(FlBlock.ff_name);

	    strCpy(fp->FileDate, buf);
	    fp->FileSize = FlBlock.ff_fsize;

	    AddData(list, fp, NULL, TRUE);
	}
	if (again) work = sp+1;
    } while (again);
    free(w);

    if (strLen(phrase) != 0) {
	Phrase = phrase;
	StFileComSearch();      /* so's we can do phrase searches */
	list->CheckIt = ChPhrase;   /* COVER YOUR EYES I'M CHEATING! */
	KillData(list, list);
	list->CheckIt = DirCheck;   /* COVER YOUR EYES I'M CHEATING! */
	EndFileComment();
    }
}
コード例 #7
0
ファイル: xARRcopy.c プロジェクト: oeli/yafra
int ARRcopymove(char *newdat, char *orgarr_bez)
{
	extern ARRANGEMENT arr;
	extern int sprache;
	extern char glob_bez_arr[];

	DIENSTLEISTUNG org_dl;
	DIENSTLEISTUNG dl;
	ARR_DLG *arr_dl = NULL;
	ARRANGEMENT newarr;
	ARRANGEMENT orgarr;
	BEZEICHNUNG newbez;
	int status=MPOK;
	int cret;
	int id;
	int i;
	int anzahl = 0;
	int newdl_dat;
	int ArrSavepoint;
	int datumsdiff = 0;
	unsigned long dlen = 0;
	unsigned long alen = 0;
	char *buffer_ptr;
	char newdl_datstr[_RECORDLEN];
	char query[_QUERYLEN];
	struct tm DateTime;

	/* DELETE Modus hat keine Kopier/Bewegungs - Funktion */
	if (ACTIONTYP == MPDELETE)
		return(MPNOP);

	orgarr.arr_id = MPAPIselectEntry((int)_ARRANGEMENT, orgarr_bez,
		  (char *)&orgarr, sizeof(ARRANGEMENT), sizeof(orgarr.arr_id));
	if (orgarr.arr_id == _UNDEF)
		return(MPNOP);

	/* wandle neues Datum von String zu time_t um und berechne Differenz */
	(void)memset((void *)&DateTime, NULL, sizeof(DateTime));
	DateTime.tm_mday=(int)_UNDEF;
	DateTime.tm_mon =(int)_UNDEF;
	DateTime.tm_year=(int)_UNDEF;
	DateTime.tm_hour=(int)_UNDEF;
	DateTime.tm_min =(int)_UNDEF;
	(void)ReadDate(&DateTime, (time_t *)&newarr.a_dat, newdat);
	if (newarr.a_dat == orgarr.a_dat)
		return(MPNOP);  /* Datum hat nicht ge?ndert */
	datumsdiff = (newarr.a_dat - orgarr.a_dat);

	/* Neue ARR schreiben */
	status = MPAPIdb_setsavepoint(&ArrSavepoint);
	newarr.arr_id = _UNDEF;
	newarr.bez_id = orgarr.bez_id;
	newarr.textid = orgarr.textid;
	newarr.sai_id = orgarr.sai_id;
	newarr.prg_id = orgarr.prg_id;
	(void)copyTextTo(newarr.code, orgarr.code, (int)_CHAR256);
	newbez.s_id = (int)sprache;
	newbez.bez_id = SelectBez(_ARRANGEMENT, sprache, newarr.bez_id, newbez.bez);
	if (newbez.bez_id == (int)_UNDEF)
		return(MPNOP);
	newbez.typ = (int)_ARRANGEMENT;
	status = MPAPIinsertEntry(_ARRANGEMENT, (char *)&newarr, &newbez);
	if (status != MPOK)
		return(MPNOP);

	/* Alte DL lesen und neue DL schreiben */
	(void)sprintf(query, _SEL_ALL_DTG_ARR, orgarr.arr_id);
	status=MPAPIdb_sqlquery((int)_ARR_DLG, (char **)&arr_dl, query, &anzahl,
	                         &dlen, &alen);
	if (status != MPOK)
		{
		MPfree((char *)arr_dl);
		return(MPNOP);
		}
	for (i = 0; i < anzahl; i++)
		{
		id = MPAPIselectOneId(_DIENSTLEISTUNG, arr_dl[i].dlg_id, (char *)&dl);
		if (id != (int)_UNDEF)
			{
			if (dl.a_zeit > 0)
				{
				newdl_dat = dl.a_zeit + datumsdiff;
				(void)memset((void *)&DateTime, NULL, sizeof(DateTime));
				DateTime.tm_min  = (int)_UNDEF;
				DateTime.tm_hour = (int)_UNDEF;
				DateTime.tm_mday = (int)_UNDEF;
				DateTime.tm_mon  = (int)_UNDEF;
				DateTime.tm_year = (int)_UNDEF;
				(void)WriteDate(&DateTime, (time_t *)&newdl_dat, newdl_datstr);
				status = DLcopymove(&dl, newdl_datstr, (int)FALSE);
				if (status != MPOK)
					break;
				}
			arr_dl[i].dlg_id = dl.dlg_id;   /* setze jetzt neue DL ID      */
			arr_dl[i].arr_id = newarr.arr_id;  /* setze jetzt neue ARR ID */
			}
		else
			{
			status = (int)MPERROR;
			break;
			}
		}
	if (status == MPOK)
		{
		for (i = 0; i < anzahl; i++)
			{
			status = MPAPIinsertEntry(_ARR_DLG, (char *)&arr_dl[i], NULL);
			if (status != MPOK)
				break;
			}
		}

	if (MENUNR == (unsigned char)_ARRANGEMENT && status == MPOK)
		{
		(void)memcpy((void *)&arr, (void *)&newarr, sizeof(ARRANGEMENT));
		(void)memset((void *)&DateTime, NULL, sizeof(DateTime));
		DateTime.tm_min  = (int)0;
		DateTime.tm_hour = (int)0;
		DateTime.tm_mday = (int)_UNDEF;
		DateTime.tm_mon  = (int)_UNDEF;
		DateTime.tm_year = (int)_UNDEF;
		buffer_ptr = strstr(glob_bez_arr, TRENNER);
		if (buffer_ptr == NULL)
			buffer_ptr = glob_bez_arr;
		else
			buffer_ptr += (size_t)4;
		(void)WriteDate(&DateTime, (time_t *)&newarr.a_dat, buffer_ptr);
		(void)strcat(buffer_ptr, "\n");
		}

	/* Falls Fehler zur?ck zum savepoint */
	if (status != MPOK)
		cret = MPAPIdb_rollbacksavepoint(&ArrSavepoint);

	MPfree((char *)arr_dl);
	return(status);
}