Esempio n. 1
0
void did_net(const char *callnode)
	{
	CronEventListS *theEvent;
	label alias, locID, address;

	const l_slot logslot = nodexists(callnode, NULL);

	if (logslot == CERROR)		// extremely unlikely
		{
		return;
		}

	LogTab[logslot].GetAlias(alias, sizeof(alias));
	LogTab[logslot].GetLocID(locID, sizeof(locID));
	makeaddress(alias, locID, address);

	WAITFORm(CronMutex);
	for (int i = 1; (theEvent = Cron.GetEventNum(i)) != NULL; i++)
		{
		if (theEvent->Event.GetType() == CR_NET && (
				SameString(theEvent->Event.GetString(), callnode) ||
				SameString(theEvent->Event.GetString(), address) ||
				SameString(theEvent->Event.GetString(), alias)))
			{
			theEvent->Event.SetDone();
			}
		}
	RELEASEm(CronMutex);
	}
Esempio n. 2
0
void SendJoin(user *Except, const char *Format, ...) {

   time_t   Time;
   va_list  Args;
   char    *Char, *Char2, String[STRING_SIZE], String2[STRING_SIZE], String3[STRING_SIZE];
   node    *Node;
   user    *User;

   Time = time(NULL);
   strftime(String3,(size_t)15,"%X ",localtime(&Time));

   va_start(Args,Format);
   vsprintf(String,Format,Args);
   va_end(Args);

   AsciiToTelnet(String,String2);
   strcat(String3,String2);

   for (Node = UserList->Head; Node != NULL; Node = Node->Next) {
      User = (user *) Node->Object;
      if (IsConnected(User) && SameString(User->Channel,Except->Channel) && User->Join && User != Except) {
         SendString(User->Conn,(User->Away)?String3:String2);
      }
   }
}
Esempio n. 3
0
void GetSysPWHandler(const char *PW)
    {
    if (LockMessages(MSG_CONSOLE))
        {
        if (SameString(PW, cfg.f6pass))
            {
            ConsoleLock.Unlock();
            ScreenSaver.Update();

            if (cfg.VerboseConsole)
                {
                CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 40));
                }
            }
        else
            {
            if (cfg.VerboseConsole)
                {
                CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 39));
                }
            }
        }
    else
        {
        cOutOfMemory(104);
        }
    }
Esempio n. 4
0
Bool TERMWINDOWMEMBER get_next_room(char *here, char *there)
	{
	assert(nodefile);

	char line[95];

	while (fgets(line, 90, nodefile) != NULL)
		{
		if (line[0] != '#')
			{
			continue;
			}

		char *words[256];
		const int count = parse_it(words, line);

		if (SameString(words[0], getnetmsg(37)))
			{
			fclose(nodefile);
			nodefile = NULL;
			return (FALSE);
			}

		if (SameString(words[0], getnetmsg(38)))
			{
			CopyString2Buffer(here, words[1], LABELSIZE);

			if (count > 2)
				{
				CopyString2Buffer(there, words[2], LABELSIZE);
				}
			else
				{
				strcpy(there, here);
				}

			return (TRUE);
			}
		}

	fclose(nodefile);
	nodefile = NULL;
	return (FALSE);
	}
Esempio n. 5
0
Bool TERMWINDOWMEMBER wait_for(const char *str, int timeout)
    {
    char line[80];
    long st;
    int i, stl;

    stl = strlen(str);

    if (stl)
        {
        for (i = 0; i < stl; i++)
            {
            line[i] = '\0';
            }

        time(&st);

        for (;;)
            {
            if (CommPort->IsInputReady())
                {
                memcpy(line, line+1, stl);
                line[stl-1] = (char) CommPort->Input();
                line[stl] = '\0';

                if (debug)
                    {
                    outCon(line[stl-1]);
                    }

                if (SameString(line, str))
                    {
                    return (TRUE);
                    }
                }
            else
                {
                if ((time(NULL) - st) > (long)timeout ||
                        !CommPort->HaveConnection())
                    {
                    return (FALSE);
                    }

                if (KBReady())  // Aborted by user
                    {
                    ciChar();
                    return (FALSE);
                    }
                }
            }
        }
    else
        {
        return (FALSE);
        }
    }
Esempio n. 6
0
FuncObjC* DataCaptureStaticSupport::GetWellQFO(const char* wellID)
{
  for (int i = 0; i < dataCaptureData.Size(); i++)
  {
    DataCaptureSpecGlob& currSpec = *(dataCaptureData[i]);
    if (SameString(wellID, currSpec.dataDesig) && currSpec.IsWell() && currSpec.IsFlow())
      return currSpec.GetObjRef();
  }
  return 0;
}
Esempio n. 7
0
static int
SameName(char *a, char *b)
{
    int result;
    if (FileTypes == 0) {
	result = SameString(a, b);
    } else {
	result = SameTypeless(a, b);
    }
    return result;
}
Esempio n. 8
0
void CreateConfigurationFile(int FileNameIndex, int FileDataIndex, Bool PrintStuff)
    {
    discardable *d;

    if (!filexists(citfiles[FileNameIndex]))
        {
        if ((d = readData(16, FileDataIndex, FileDataIndex)) != NULL)
            {
            FILE *File;

            if ((File = fopen(citfiles[FileNameIndex], FO_W)) != NULL)
                {
                if (PrintStuff)
                    {
#ifndef WINCIT
                    cPrintf(getcfgmsg(133), citfiles[FileNameIndex]);
                    doccr();
#endif
                    }

                const char **Data = (const char **) d->aux;

                for (int i = 0; !SameString(Data[i], getcfgmsg(244)); i++)
                    {
                    fprintf(File, getmsg(472), Data[i], bn);
                    }

                fclose(File);
                }
            else
                {
                if (PrintStuff)
                    {
#ifndef WINCIT
                    cPrintf(getcfgmsg(134), citfiles[FileNameIndex]);
                    doccr();
#endif
                    }
                }

            discardData(d);
            }
        else
            {
            if (PrintStuff)
                {
                cOutOfMemory(51);
                }
            }
        }
    }
Esempio n. 9
0
void LayerErrorListing::CreateListing()
{
  StdTitle("Layer Setup Errors");

  layerSpec.SetThicknesses();

  double totThick = 0.0;
  for (int i = 0; i < geologyLayers.Size(); i++)
  {
    const double& currThick = geologyLayers[i].currThickness;
    if (currThick < 1.0E-03)
      AddError("Geology layer < 1 mm thick");

    const char* currID = geologyLayers[i].intervalID;
    for (int j = i + 1; j < geologyLayers.Size(); j++)
      if (SameString(currID, geologyLayers[j].intervalID))
        AddError("Duplicate geology layer ID");

    totThick += currThick;
  }
  for (int i = 0; i < wellBoreZones.Size(); i++)
  {
    const double& currThick = wellBoreZones[i].currThickness;
    if (currThick < 1.0E-03)
      AddError("Well bore zone < 1 mm thick");

    const char* currID = wellBoreZones[i].intervalID;
    for (int j = i + 1; j < wellBoreZones.Size(); j++)
      if (SameString(currID, wellBoreZones[j].intervalID))
        AddError("Duplicate wellbore zone ID");

    totThick -= currThick;
  }

  if (totThick < 0.0)
    AddError("Well bore zone thicker than defined geology");

}
bool is_note_to ( Creature *ch, NOTE_DATA *pnote )
{
	if ( SameString ( ch->name, pnote->sender ) )
	{ return TRUE; }

	if ( is_exact_name ( "all", pnote->to_list ) )
	{ return TRUE; }

	if ( IsStaff ( ch ) && is_exact_name ( "immortal", pnote->to_list ) )
	{ return TRUE; }

	if ( ch->clan && is_exact_name ( ( char * ) clan_table[ch->clan].name, pnote->to_list ) )
	{ return TRUE; }

	if ( is_exact_name ( ch->name, pnote->to_list ) )
	{ return TRUE; }

	return FALSE;
}
Esempio n. 11
0
/* Compare two leaf-names, ignoring their suffix. */
static int
SameTypeless(char *a, char *b)
{
    int result = FALSE;
    char *type_a = ftype(a);
    char *type_b = ftype(b);
    if ((type_a - a) == (type_b - b)) {
	if (type_a == a) {
	    result = SameString(a, b);
	} else {
	    if (caseless) {
		if (!strncasecmp(a, b, (size_t) (type_a - a)))
		    result = TRUE;
	    } else {
		if (!strncmp(a, b, (size_t) (type_a - a)))
		    result = TRUE;
	    }
	}
    }
    return result;
}
bool hide_note ( Creature *ch, NOTE_DATA *pnote )
{
	time_t last_read;

	if ( IS_NPC ( ch ) )
	{ return TRUE; }

	switch ( pnote->type ) {
		default:
			return TRUE;
		case NOTE_NOTE:
			last_read = ch->pcdata->last_note;
			break;
		case NOTE_IDEA:
			last_read = ch->pcdata->last_idea;
			break;
		case NOTE_PENALTY:
			last_read = ch->pcdata->last_penalty;
			break;
		case NOTE_NEWS:
			last_read = ch->pcdata->last_news;
			break;
		case NOTE_CHANGES:
			last_read = ch->pcdata->last_changes;
			break;
	}

	if ( pnote->date_stamp <= last_read )
	{ return TRUE; }

	if ( SameString ( ch->name, pnote->sender ) )
	{ return TRUE; }

	if ( !is_note_to ( ch, pnote ) )
	{ return TRUE; }

	return FALSE;
}
Esempio n. 13
0
int doAtoD (WF3Info *wf3, SingleGroup *x) {

/* arguments:
WF3Info *wf3	 i: calibration switches, etc
SingleGroup *x	io: image to be calibrated; written to in-place
*/

	extern int status;

	TblInfo tabinfo;	/* pointer to table descriptor, etc */
	TblRow tabrow;		/* values read from a table row */
	TblArray tabarray;	/* correction array read from table row */

	int foundit;		/* row found in table? */
	int row;		/* loop index for row number */
	int row_min;		/* row with matching keyword */
	double ref_key_value;	/* value gotten from image header */
	double dt, dt_min;	/* for finding desired row in table */
	int ival;		/* input science data value from x */
	int i, j;
	short dqval;

	int GetKeyDbl (Hdr *, char *, int, double, double *);
	int RowPedigree (RefTab *, int, IRAFPointer, IRAFPointer, IRAFPointer);
	int SameFlt (float, float);
	int SameString (char *, char *);

    row_min=0;
    dt_min=0.0f;
    
	if (wf3->atodcorr != PERFORM)
	    return (status);

	if (wf3->ncombine > 1) {
	    trlerror 
		("NCOMBINE is already > 1 before ATODCORR has been performed.");
	    return (status = 1010);
	}

	/* Open the A-to-D table. */
	if (OpenAtoDTab (wf3->atod.name, &tabinfo))
	    return (status);

	/* Find the row with value closest to the temperature. */

	foundit = 0;
	for (row = 1;  row <= tabinfo.nrows;  row++) {
	    if (ReadAtoDTab (&tabinfo, row, &tabrow))
		return (status);
	    if (SameString (tabrow.ccdamp, wf3->ccdamp) &&
		SameFlt (tabrow.ccdgain, wf3->ccdgain)) {
		if (GetKeyDbl (x->globalhdr, tabrow.ref_key, NO_DEFAULT,
			       0., &ref_key_value))
		    return (status);
		if (!foundit) {
		    /* assign initial values */
		    foundit = 1;
		    row_min = row;
		    dt_min = fabs (ref_key_value - tabrow.ref_key_value);
		} else {
		    /* Get value from image, and update dt_min. */
		    dt = fabs (ref_key_value - tabrow.ref_key_value);
		    if (dt < dt_min) {
			dt_min = dt;
			row_min = row;
		    }
		}
	    }
	}

	if (!foundit) {
	    sprintf (MsgText, "CCD amp %s, gain %g, not found in ATODTAB `%s'.",
		wf3->ccdamp, wf3->ccdgain, wf3->atod.name);
	    trlerror (MsgText);
	    CloseAtoDTab (&tabinfo);
	    return (status = TABLE_ERROR);
	}

	/* Get pedigree & descrip from the row. */
	if (RowPedigree (&wf3->atod, row_min,
		tabinfo.tp, tabinfo.cp_pedigree, tabinfo.cp_descrip))
	    return (status);
	if (wf3->atod.goodPedigree == DUMMY_PEDIGREE) {
	    wf3->atodcorr = DUMMY;
	    CloseAtoDTab (&tabinfo);
	    return (status);
	}

	/* Reread the appropriate row to get the correction array. */
	if (ReadAtoDArray (&tabinfo, row_min, &tabarray))
	    return (status);

	/* Apply this correction to each pixel in the image.  At this
	   stage the values should still be integers, so assigning
	   a value to an integer (ival) should not result in truncation.
	*/
	dqval = 0;
	for (j = 0;  j < x->sci.data.ny;  j++) {
	    for (i = 0;  i < x->sci.data.nx;  i++) {
		ival = (int) Pix (x->sci.data, i, j);
		if (ival >= tabarray.nelem) {
		    Pix (x->sci.data, i, j) = tabarray.atod[tabarray.nelem-1];
			dqval = SATPIXEL | DQPix (x->dq.data, i, j);
		    DQSetPix (x->dq.data, i, j, dqval);	/* saturated */
		} else if (ival >= 0) {
		    Pix (x->sci.data, i, j) = tabarray.atod[ival];
		}		/* else if ival < 0, no change */
	    }
	}

	free (tabarray.atod);
	if (CloseAtoDTab (&tabinfo))
	    return (status);

	return (status);
}
Esempio n. 14
0
int GetDisp (StisInfo7 *sts, DispRelation **disp) {

/* arguments:
StisInfo7 *sts       i: calibration switches and info
DispRelation **disp  o: size and coordinate info for output
*/

	int status;

	TblInfo tabinfo;	/* pointer to table descriptor, etc */
	TblRow tabrow;		/* values read from a table row */

	int row;		/* loop index */
	int CheckDisp (DispRelation **);
	void FreeDisp (DispRelation **);

	/* Open the dispersion coefficients table. */
	if ((status = OpenDSPTab (sts->disptab.name, &tabinfo)))
	    return (status);

	for (row = 1;  row <= tabinfo.nrows;  row++) {

	    if ((status = ReadDSPTab (&tabinfo, row, &tabrow)))
		return (status);

	    /* Check for a match with opt_elem and cenwave. */

	    if (SameString (tabrow.opt_elem, sts->opt_elem) &&
		SameInt (tabrow.cenwave, sts->cenwave)) {

		/* Get pedigree & descrip from the row. */
		if ((status = RowPedigree (&sts->disptab, row,
                        tabinfo.tp, tabinfo.cp_pedigree, tabinfo.cp_descrip)))
		    return (status);
		if (sts->disptab.goodPedigree == DUMMY_PEDIGREE) {
		    printf ("Warning  DUMMY pedigree in row %d of %s.\n",
			row, sts->disptab.name);
		    sts->x2dcorr_o = DUMMY;
		    CloseDSPTab (&tabinfo);
		    return (0);
		}

		/* Read data from this row. */
		if ((status = ReadDSPArray (&tabinfo, row, disp)))
		    return (status);
	    }
	}

	/* Get for duplicate a2center or non-duplicate ref_aper. */
	if ((status = CheckDisp (disp))) {
	    FreeDisp (disp);
	    if (status < 0) {
		printf ("Warning  Matching row not found in DISPTAB %s; \\\n",
				sts->disptab.name);
		printf ("Warning  OPT_ELEM %s, CENWAVE %d\n",
			sts->opt_elem, sts->cenwave);
		sts->x2dcorr_o = OMIT;
	    } else {
		return (status);
	    }
	}

	if ((status = CloseDSPTab (&tabinfo)))
	    return (status);

	return (0);
}
Esempio n. 15
0
int doDQI (StisInfo1 *sts, SingleGroup *x) {

/* arguments:
StisInfo1 *sts    i: calibration switches, etc
SingleGroup *x    io: image to be calibrated; DQ array written to in-place
*/

	int status;

	TblInfo tabinfo;	/* pointer to table descriptor, etc */
	TblRow tabrow;		/* values read from a table row */

	ShortTwoDArray ydq;		/* scratch space */

	/* mappings from one coordinate system to another */
	double ri_m[2], ri_v[2];	/* reference to image */
	double rs_m[2], rs_v[2];	/* reference to scratch */
	double si_m[2], si_v[2];	/* scratch to image */

	/* for copying from scratch array (only copy overlap region): */
	int first[2], last[2];	/* corners of overlap region in image coords */
	int sfirst[2];		/* lower left corner of overlap in scratch */
	int rbin[2];		/* bin size of image relative to ref bin size */

	int snpix[2];		/* size of scratch array */
	int npix[2];		/* size of current image */

	float *ds;		/* Doppler smearing array */
	int nds, d0;		/* size of ds and index in ds of zero point */
	int k, kmin, kmax;	/* loop index; range of indexes in ds */
	int doppmin, doppmax;	/* Doppler offsets relative to d0 */

	int in_place;		/* true if same bin size and no Doppler */
	int high_res;		/* true if Doppler or either axis is high-res */
	int i, j, i0, j0;	/* indexes for scratch array ydq */
	int m, n;		/* indexes for data quality array in x */
	short sum_dq;		/* for binning data quality array */

	int row;		/* loop index for row number */

	void FlagFilter (StisInfo1 *, ShortTwoDArray *,
		int, int, double *, double *);
	int MakeDopp (double, double, double, double, double, int,
		float *, int *, int *);

	/* We could still flag saturation even if the bpixtab was dummy. */
	if (sts->dqicorr != PERFORM && sts->dqicorr != DUMMY)
	    return (0);

	/* For the CCD, check for and flag saturation. */
	if (sts->detector == CCD_DETECTOR) {
	    for (j = 0;  j < x->sci.data.ny;  j++) {
		for (i = 0;  i < x->sci.data.nx;  i++) {
		    if ((int) Pix (x->sci.data, i, j) > sts->saturate) {
			sum_dq = DQPix (x->dq.data, i, j) | SATPIXEL;
			DQSetPix (x->dq.data, i, j, sum_dq);	/* saturated */
		    }
		}
	    }
	}

	/* Get the linear transformation between reference and input image. */
	if ((status = GetLT0 (&x->sci.hdr, ri_m, ri_v))) /* zero indexed LTV */
	    return (status);

	/* Flag regions beyond the bounderies of the aperture, for CCD data. */
	if (sts->detector == CCD_DETECTOR) {
	    FlagFilter (sts, &x->dq.data, x->dq.data.nx, x->dq.data.ny,
			ri_m, ri_v);
	}

	/* There might not be any bad pixel table.  If not, quit now. */
	if (sts->bpix.exists == EXISTS_NO || sts->dqicorr != PERFORM)
	    return (0);

	initShortData (&ydq);

	/* In some cases we can set the data quality flags directly in
	   the DQ array, but in other cases we must create a scratch
	   array and copy back to the original.  Either the original or
	   the scratch may be in high-res mode.
	*/
	if (sts->detector == CCD_DETECTOR) {

	    if (sts->bin[0] == 1 && sts->bin[1] == 1)
		in_place = 1;			/* no binning */
	    else
		in_place = 0;
	    high_res = 0;

	} else {				/* MAMA */

	    if (sts->doppcorr == PERFORM) {

		high_res = 1;

		if (sts->bin[0] == 1 && sts->bin[1] == 1)
		    in_place = 1;		/* high-res in both axes */
		else
		    in_place = 0;

	    } else {				/* no Doppler convolution */

		if (sts->bin[0] == 2 && sts->bin[1] == 2) {
		    high_res = 0;		/* both axes low-res */
		    in_place = 1;
		} else if (sts->bin[0] == 1 && sts->bin[1] == 1) {
		    high_res = 1;		/* both axes high-res */
		    in_place = 1;
		} else {
		    high_res = 1;		/* low-res in one axis */
		    in_place = 0;
		}
	    }
	}

	/* Get the other linear transformations (ri_m & ri_v were gotten
	   earlier, just after checking for saturation.)
	*/
	if (!in_place) {
	    if (high_res) {
		/* DQ array is binned finer than reference coords */
		rs_m[0] = 2.;
		rs_m[1] = 2.;
		rs_v[0] = 0.5;
		rs_v[1] = 0.5;
		/* assumes rs_m = 2, rs_v = 0.5 */
		si_m[0] = ri_m[0] * 0.5;
		si_m[1] = ri_m[1] * 0.5;
		si_v[0] = ri_v[0] - ri_m[0] * 0.25;
		si_v[1] = ri_v[1] - ri_m[1] * 0.25;
	    } else {
		/* scratch is in reference coords */
		rs_m[0] = 1.;
		rs_m[1] = 1.;
		rs_v[0] = 0.;
		rs_v[1] = 0.;
		/* assumes rs_m = 1, rs_v = 0 */
		si_m[0] = ri_m[0];
		si_m[1] = ri_m[1];
		si_v[0] = ri_v[0];
		si_v[1] = ri_v[1];
	    }
	}

	if (sts->doppcorr == PERFORM) {
	    /* Compute the Doppler smearing array, if we need it.  We need
		the size (nds) and zero point (d0), not the array itself.
	    */
	    nds = 2 * (sts->doppmag + 1) + 21;	/* reassigned by makeDopp */
	    ds = (float *) calloc (nds, sizeof (float));
	    if ((status = MakeDopp (sts->doppzero, sts->doppmag, sts->orbitper,
                                    sts->expstart, sts->exptime, sts->dispsign,
                                    ds, &nds, &d0)))
		return (status);
	    /* Find the range of non-zero elements in ds. */
	    kmin = nds - 1;		/* initial values */
	    kmax = 0;
	    for (k = 0;  k < nds;  k++) {
		if (ds[k] > 0.) {	/* there will be no negative values */
		    if (k < kmin)
			kmin = k;
		    if (k > kmax)
			kmax = k;
		}
	    }
	    /* It's the indexes relative to d0 that are important. */
	    doppmin = kmin - d0;
	    doppmax = kmax - d0;
	    free (ds);
	} else {
	    doppmin = 0;
	    doppmax = 0;
	}

	/* Open the data quality initialization table, find columns, etc. */
	if ((status = OpenBpixTab (sts->bpix.name, &tabinfo)))
	    return (status);

	/* Size of scratch image */
	if (high_res) {
	    snpix[0] = 2 * tabinfo.axlen1;
	    snpix[1] = 2 * tabinfo.axlen2;
	} else {
	    snpix[0] = tabinfo.axlen1;
	    snpix[1] = tabinfo.axlen2;
	}

	/* size of current image */
	npix[0] = x->dq.data.nx;
	npix[1] = x->dq.data.ny;

	if (!in_place) {
	    /* Allocate space for a scratch array. */
	    allocShortData (&ydq, snpix[0], snpix[1], True);
	    if (hstio_err()) {
		printf (
		"ERROR    (doDQI) couldn't allocate data quality array.\n");
		return (OUT_OF_MEMORY);
	    }
	    for (j = 0;  j < snpix[1];  j++)
		for (i = 0;  i < snpix[0];  i++)
		    DQSetPix (ydq, i, j, 0);		/* initially OK */
	}

	/* Read each row of the table, and fill in data quality values. */

	for (row = 1;  row <= tabinfo.nrows;  row++) {

	    if ((status = ReadBpixTab (&tabinfo, row, &tabrow))) {
		printf ("ERROR    Error reading BPIXTAB.\n");
		return (status);
	    }

	    if (!SameString (tabrow.opt_elem, sts->opt_elem))
		continue;

	    if (tabrow.xstart < 0 || tabrow.xstart >= tabinfo.axlen1 ||
		tabrow.ystart < 0 || tabrow.ystart >= tabinfo.axlen2) {
		printf (
	"Warning  Starting pixel (%d,%d) in BPIXTAB is out of range.\n",
			tabrow.xstart+1, tabrow.ystart+1);
		continue;			/* ignore this row */
	    }

	    /* Assign the flag value to all relevant pixels. */
	    if (in_place) {
		if (high_res)
		    DQIHigh (&x->dq.data, ri_v, &tabrow, doppmin, doppmax);
		else
		    DQINormal (&x->dq.data, ri_v, &tabrow);
	    } else {				/* use scratch array */
		if (high_res)
		    DQIHigh (&ydq, rs_v, &tabrow, doppmin, doppmax);
		else
		    DQINormal (&ydq, rs_v, &tabrow);
	    }
	}

	if ((status = CloseBpixTab (&tabinfo)))	/* done with the table */
	    return (status);

	if (!in_place) {

	    /* Get corners of region of overlap between image and
		scratch array.
	    */
	    FirstLast (si_m, si_v, snpix, npix, rbin, first, last, sfirst);

	    /* We have been writing to a scratch array ydq.  Now copy or
		bin the values down to the actual size of x.
	    */
	    j0 = sfirst[1];
	    for (n = first[1];  n <= last[1];  n++) {
		i0 = sfirst[0];
		for (m = first[0];  m <= last[0];  m++) {
		    sum_dq = DQPix (x->dq.data, m, n);
		    for (j = j0;  j < j0+rbin[1];  j++)
			for (i = i0;  i < i0+rbin[0];  i++)
			    sum_dq |= DQPix (ydq, i, j);
		    DQSetPix (x->dq.data, m, n, sum_dq);
		    i0 += rbin[0];
		}
		j0 += rbin[1];
	    }

	    freeShortData (&ydq);			/* done with ydq */
	}

	return (0);
}
Esempio n. 16
0
int GetSDC6 (StisInfo6 *sts, CoordInfo **coords, int *minorder, int *maxorder)
{

/* arguments:
StisInfo6 *sts             i: calibration switches and info
CoordInfo **coords         o: size and coordinate info for output
int *minorder, *maxorder   o: minimum and maximum values of SPORDER
*/

	int status;

	TblInfo tabinfo;	/* pointer to table descriptor, etc */
	TblRow tabrow;		/* values read from a table row */

	int row;		/* loop index */
	int RangeCoord6 (CoordInfo **, int *, int *);

	/* Open the spectroscopic distortion information table. */
	if ((status = OpenSDistTab (sts->distntab.name, &tabinfo)))
	    return (status);

	for (row = 1;  row <= tabinfo.nrows;  row++) {

	    if ((status = ReadSDistTab (&tabinfo, row, &tabrow)))
		return (status);

	    /* Check for a match with opt_elem and cenwave. */
	    if (SameString (tabrow.opt_elem, sts->opt_elem) &&
		SameInt (tabrow.cenwave, sts->cenwave)) {

		/* Get pedigree & descrip from the row. */
		if ((status = RowPedigree (&sts->distntab, row,
                       tabinfo.tp, tabinfo.cp_pedigree, tabinfo.cp_descrip)))
		    return (status);
		if (sts->distntab.goodPedigree == DUMMY_PEDIGREE) {
		    printf ("Warning  DUMMY pedigree in row %d of %s.\n",
			row, sts->distntab.name);
		    sts->x1d_o = DUMMY;
		    CloseSDistTab (&tabinfo);
		    return (0);
		}

		/* Read data from this row. */
		if ((status = ReadSDistArray (&tabinfo, row, coords)))
		    return (status);

		/* This was added because the SDCTAB may contain multiple
		   entries for the CCD pseudo-apertures.  In this case, all
		   matching rows contain the same NPIX2 value, so we can
		   take the value from the first matching row.
		*/
		if ((*coords)->sporder == 1)
		    break;
	    }
	}

	/* Get the range of order numbers. */
	if ((status = RangeCoord6 (coords, minorder, maxorder))) {
	    if (status < 0) {
		printf ("Warning  Matching row not found in SDCTAB %s; \\\n",
				sts->distntab.name);
		printf ("Warning  OPT_ELEM %s, CENWAVE %d.\n",
		    sts->opt_elem, sts->cenwave);
		sts->x1d_o = OMIT;
	    } else {
		return (status);
	    }
	}

	if ((status = CloseSDistTab (&tabinfo)))
	    return (status);

	return (0);
}
Esempio n. 17
0
Bool ReadNodesCit(NodesCitC **newNode, const char *NameOrAddrToFind, ModemConsoleE W, Bool option)
#endif
    {
    FILE *fBuf;
    char *words[256];
    int i;
    char path[80];
    int count;
    uint lineno = 0;
    l_slot logslot;

    if (!read_node_ddata())
        {
        TWwPrintf(W, getmsg(59));
        return (FALSE);
        }

    const char **nodekeywords = (const char **) nddd->aux;
    const char **nettypes = (const char **) nddd->next->aux;
    const char **nodemsgs = (const char **) nddd->next->next->aux;

    label NameToFind;
    CopyStringToBuffer(NameToFind, NameOrAddrToFind);

    if (SameString(NameOrAddrToFind, getnodemsg(2)))
        {
        // if default, start fresh
        if (!clearNode(newNode))
            {
            dump_node_ddata();
            return (FALSE);
            }
        }
    else
        {
        // else first read in default
#ifdef WINCIT
        ReadNodesCit(TW, newNode, getnodemsg(2), W, FALSE);
#else
        ReadNodesCit(newNode, getnodemsg(2), W, FALSE);
#endif

        if (*newNode)
            {
#ifdef WINCIT
            logslot = nodexists(NameOrAddrToFind, TW ? TW->LogOrder : NULL);
#else
            logslot = nodexists(NameOrAddrToFind);
#endif

            if (logslot == CERROR)
                {
                TWwDoCR(W);
                TWwPrintf(W, getnodemsg(3), NameOrAddrToFind);

                if (strlen(NameOrAddrToFind) < 4)
                    {
                    char temp[4];

                    CopyStringToBuffer(temp, NameOrAddrToFind);
                    strlwr(temp);
                    TWwPrintf(W, getnodemsg(4), temp, cfg.locID);
                    }

                dump_node_ddata();
                return (FALSE);
                }

            label Alias, LocID;

#ifdef WINCIT
            if (!*LogTab[TW ? TW->LogOrder[logslot] : logslot].GetAlias(Alias, sizeof(Alias)) ||
                    !*LogTab[TW ? TW->LogOrder[logslot] : logslot].GetLocID(LocID, sizeof(LocID)))
#else
            if (!*LTab(logslot).GetAlias(Alias, sizeof(Alias)) || !*LTab(logslot).GetLocID(LocID, sizeof(LocID)))
#endif
                {
                TWwDoCR(W);
                TWwPrintf(W, getnodemsg(5), NameOrAddrToFind);

                dump_node_ddata();
                return (FALSE);
                }

            (*newNode)->SetAlias(Alias);
            (*newNode)->SetLocID(LocID);

            label FileName;
            sprintf(FileName, getnodemsg(6), (*newNode)->GetAlias());
            (*newNode)->SetMailFileName(FileName);

            // Make sure NameToFind is a name, not address.
#ifdef WINCIT
            LogTab[TW ? TW->LogOrder[logslot] : logslot].GetName(NameToFind, sizeof(NameToFind));
#else
            LTab(logslot).GetName(NameToFind, sizeof(NameToFind));
#endif

            // Support for optional nodes.cit entries.
            (*newNode)->SetName(NameToFind);
            }
        }

    if (!*newNode)
        {
        cOutOfMemory(44);
        dump_node_ddata();
        return (FALSE);
        }

    compactMemory();

    sprintf(path, sbs, cfg.homepath, getnodemsg(8));

    if ((fBuf = fopen(path, FO_R)) == NULL) // ASCII mode
        {
        TWdoccr();
        TWcPrintf(getmsg(15), getnodemsg(8));
        TWdoccr();

        dump_node_ddata();
        return (option);
        }

    char line[256];
    Bool FoundOurEntry = FALSE;
    long pos = ftell(fBuf);
    while (fgets(line, 254, fBuf) != NULL)
        {
        lineno++;

        if (line[0] != '#')
            {
            pos = ftell(fBuf);
            continue;
            }

        // Don't read anything until we found our entry, except possible beginnings of our entry. (#NODE...)
        if (!FoundOurEntry && strnicmp(line + 1, nodekeywords[NOK_NODE], strlen(nodekeywords[NOK_NODE])) != SAMESTRING)
            {
            pos = ftell(fBuf);
            continue;
            }

        // Save a copy of the line in case this is the #LOGIN macro: parse_it
        // changes what is passed to it.
        char ltmp[256];
        CopyStringToBuffer(ltmp, line);

        count = parse_it(words, line);

        // Look up our first word in table of keywords.
        for (i = 0; i < NOK_NUM; i++)
            {
            if (SameString(words[0] + 1, nodekeywords[i]))
                {                   //^ add one for '#'
                break;
                }
            }

        if (i < NOK_NUM && !words[1][0])    // valid keywords need a param
            {
            TWcPrintf(getnodemsg(9), getnodemsg(8), ltoac(lineno), nodekeywords[i], ns);
            TWdoccr();
            continue;
            }

        if (i == NOK_NODE)
            {
            // This is a #NODE line... if we have alread found our entry,
            // then this is the start of the next one, and we are done.
            if (FoundOurEntry)
                {
                fclose(fBuf);
                dump_node_ddata();
                return (TRUE);
                }

            // This is a #NODE line... if it is for us, then we have now
            // found our entry. If not, then we continue looking.
            if (SameString(NameToFind, words[1]))
                {
                FoundOurEntry = TRUE;
                }
            else
                {
                pos = ftell(fBuf);
                continue;
                }
            }

        switch (i)
            {
            case NOK_BAUD:
                {
                PortSpeedE PS = digitbaud(atol(words[1]));

                if (PS == PS_ERROR)
                    {
                    TWcPrintf(getnodemsg(9), getnodemsg(8), ltoac(lineno), nodekeywords[i], words[1]);
                    TWdoccr();
                    }
                else
                    {
                    (*newNode)->SetBaud(PS);
                    }

                break;
                }

            case NOK_DIALOUT:
            case NOK_PHONE:
                {
                (*newNode)->SetDialOut(words[1]);

                if (strlen(words[1]) > 49)
                    {
                    TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], 50);
                    TWdoccr();
                    }

                break;
                }

            case NOK_PREDIAL:
                {
                (*newNode)->SetPreDial(words[1]);

                if (strlen(words[1]) > 63)
                    {
                    TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], 64);
                    TWdoccr();
                    }

                break;
                }

            case NOK_FETCH_TIMEOUT:
                {
                (*newNode)->SetFetchTimeout(atoi(words[1]));
                break;
                }

            case NOK_ZIP:
                {
                if (!words[2][0])   // need second param
                    {
                    TWcPrintf(getnodemsg(9), getnodemsg(8), ltoac(lineno), nodekeywords[i], ns);
                    TWdoccr();
                    continue;
                    }
                else
                    {
                    (*newNode)->SetCreatePacket(words[1]);

                    if (strlen(words[1]) > 39)
                        {
                        TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], 40);
                        TWdoccr();
                        }

                    (*newNode)->SetExtractPacket(words[2]);

                    if (strlen(words[2]) > 39)
                        {
                        TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], 40);
                        TWdoccr();
                        }
                    }

                break;
                }

            case NOK_NETWORK:
                {
                (*newNode)->SetNetworkRevisionNumber(0);

                NETTYPES j;
                for (j = (NETTYPES) 0; j < NET_NUM; j = (NETTYPES) (j + 1))
                    {
                    if (SameString(words[1], nettypes[j]))
                        {
                        break;
                        }
                    }

                if (j == NET_DCIT11)
                    {
                    j = NET_DCIT10;
                    }

                if (j == NET_6_9a)
                    {
                    (*newNode)->SetNetworkRevisionNumber(1);
                    j = NET_6_9;
                    }

                if (j == NET_NUM)
                    {
                    TWcPrintf(getnodemsg(9), getnodemsg(8), ltoac(lineno), nodekeywords[i], words[1]);
                    TWdoccr();
                    }
                else
                    {
                    (*newNode)->SetNetworkType(j);
                    }

                break;
                }

            case NOK_PROTOCOL:
                {
                (*newNode)->SetProtocol(words[1][0]);
                break;
                }

            case NOK_AUTOHALL:
                {
                (*newNode)->SetAutoHall(hallexists(words[1]));

                if (strlen(words[1]) > LABELSIZE)
                    {
                    TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], LABELSIZE + 1);
                    TWdoccr();
                    }

                break;
                }

            case NOK_AUTOGROUP:
                {
                (*newNode)->SetAutoGroup(FindGroupByName(words[1]));

                if (strlen(words[1]) > LABELSIZE)
                    {
                    TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], LABELSIZE + 1);
                    TWdoccr();
                    }

                break;
                }

            case NOK_MAPUNKGROUP:
                {
                g_slot GroupSlot = FindGroupByName(words[1]);

                if (GroupSlot == CERROR)
                    {
                    GroupSlot = SPECIALSECURITY;
                    }

                (*newNode)->SetMapUnknownGroup(GroupSlot);

                if (strlen(words[1]) > LABELSIZE)
                    {
                    TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], LABELSIZE + 1);
                    TWdoccr();
                    }

                break;
                }

            case NOK_LOGIN:
                {
                (*newNode)->SetLoginMacro(ltmp + strlen(nodekeywords[NOK_LOGIN]) + 1);
                break;
                }

            case NOK_NODE:
                {
                // A bit silly.
                (*newNode)->SetName(words[1]);

                if (strlen(words[1]) > LABELSIZE)
                    {
                    TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], LABELSIZE + 1);
                    TWdoccr();
                    }

                if (count > 2)
                    {
                    (*newNode)->SetOldRegion(words[2]);

                    if (strlen(words[2]) > LABELSIZE)
                        {
                        TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], LABELSIZE + 1);
                        TWdoccr();
                        }
                    }
                else
                    {
                    (*newNode)->SetOldRegion(ns);
                    }

                (*newNode)->FreeMappedGroups();
                (*newNode)->SetRoomOffset(0);

                break;
                }

            case NOK_DIAL_TIMEOUT:
                {
                (*newNode)->SetDialTimeout(atoi(words[1]));
                break;
                }

            case NOK_REQUEST:
                {
                (*newNode)->SetRequest(atoi(words[1]));
                break;
                }

            case NOK_WAIT_TIMEOUT:
                {
                (*newNode)->SetWaitTimeout(atoi(words[1]));
                break;
                }

            case NOK_AUTOROOM:
                {
                (*newNode)->SetAutoRoom(atoi(words[1]));
                break;
                }

            case NOK_VERBOSE:
                {
                (*newNode)->SetDefaultVerbose();

                const char **verbosekeywords = (const char **) nddd->next->next->next->aux;

                for (int j = 1; j < count; j++)
                    {
                    if (SameString(words[j], getnodemsg(39)))
                        {
                        (*newNode)->SetDefaultVerbose();
                        }
                    else if (SameString(words[j], getnodemsg(40)))
                        {
                        (*newNode)->SetDefaultVerbose();
                        (*newNode)->SetVerbose(NCV_FILE69INFULL, TRUE);
                        (*newNode)->SetVerbose(NCV_NOACCESS, TRUE);
                        }
                    else if (SameString(words[j], getnodemsg(41)))
                        {
                        (*newNode)->SetDefaultVerbose();
                        (*newNode)->SetVerbose(NCV_FILE69INFULL, TRUE);
                        (*newNode)->SetVerbose(NCV_NOACCESS, TRUE);
                        (*newNode)->SetVerbose(NCV_ROOMCREATED, TRUE);
                        (*newNode)->SetVerbose(NCV_ROOMNOTCREATED, TRUE);
                        (*newNode)->SetVerbose(NCV_NETIDNOTFOUND, TRUE);
                        (*newNode)->SetVerbose(NCV_NONETIDONSYSTEM, TRUE);
                        }
                    else
                        {
                        const char *Keyword;
                        Bool NewSetting;

                        if (words[j][0] == '!')
                            {
                            Keyword = words[j] + 1;
                            NewSetting = FALSE;
                            }
                        else
                            {
                            Keyword = words[j];
                            NewSetting = TRUE;
                            }

                        NCV_Type TestType;

                        for (TestType = (NCV_Type) 0; TestType < NCV_MAX; TestType = (NCV_Type) (TestType + 1))
                            {
                            if (SameString(Keyword, verbosekeywords[TestType]))
                                {
                                (*newNode)->SetVerbose(TestType, NewSetting);
                                break;
                                }
                            }

                        if (TestType == NCV_MAX)
                            {
                            if (SameString(Keyword, getnodemsg(13)))
                                {
                                // ALL
                                for (TestType = (NCV_Type) 0; TestType < NCV_MAX; TestType = (NCV_Type) (TestType + 1))
                                    {
                                    (*newNode)->SetVerbose(TestType, NewSetting);
                                    }
                                }
                            else
                                {
                                TWcPrintf(getnodemsg(12), getnodemsg(8), ltoac(lineno), words[0], Keyword);
                                TWdoccr();
                                }
                            }
                        }
                    }

                break;
                }

            case NOK_CHAT:
                {
                (*newNode)->SetDefaultChat();

                const char **chatkeywords = (const char **) nddd->next->next->next->next->aux;

                for (int j = 1; j < count; j++)
                    {
                    const char *Keyword;
                    Bool NewSetting;

                    if (words[j][0] == '!')
                        {
                        Keyword = words[j] + 1;
                        NewSetting = FALSE;
                        }
                    else
                        {
                        Keyword = words[j];
                        NewSetting = TRUE;
                        }

                    NCC_Type TestType;

                    for (TestType = (NCC_Type) 0; TestType < NCC_MAX; TestType = (NCC_Type) (TestType + 1))
                        {
                        if (SameString(Keyword, chatkeywords[TestType]))
                            {
                            (*newNode)->SetChat(TestType, NewSetting);
                            break;
                            }
                        }

                    if (TestType == NCV_MAX)
                        {
                        if (SameString(Keyword, getnodemsg(13)))
                            {
                            // ALL
                            for (TestType = (NCC_Type) 0; TestType < NCC_MAX; TestType = (NCC_Type) (TestType + 1))
                                {
                                (*newNode)->SetChat(TestType, NewSetting);
                                }
                            }
                        else
                            {
                            TWcPrintf(getnodemsg(12), getnodemsg(8), ltoac(lineno), words[0], Keyword);
                            TWdoccr();
                            }
                        }
                    }

                break;
                }

            case NOK_REDIAL:
                {
                (*newNode)->SetRedial(atoi(words[1]));
                break;
                }

            case NOK_ROOM:
                {
                (*newNode)->SetRoomOffset(pos);
                fclose(fBuf);
                dump_node_ddata();
                return (TRUE);
                }

            case NOK_GROUP:
                {
                if (!(*newNode)->AddMappedGroups(words[1], words[2]))
                    {
                    TWcPrintf(getnodemsg(10), words[1]);
                    TWdoccr();
                    }

                if (strlen(words[1]) > LABELSIZE)
                    {
                    TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], LABELSIZE + 1);
                    TWdoccr();
                    }

                if (strlen(words[2]) > LABELSIZE)
                    {
                    TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], LABELSIZE + 1);
                    TWdoccr();
                    }

                break;
                }

            case NOK_GATEWAY:
                {
                (*newNode)->SetGateway(atoi(words[1]));
                break;
                }

            case NOK_FETCH:
                {
                (*newNode)->SetFetch(atoi(words[1]));
                break;
                }

            case NOK_NETFAIL:
                {
                (*newNode)->SetNetFail(atoi(words[1]));
                break;
                }

            case NOK_OUTPUTPACE:
                {
                (*newNode)->SetOutputPace(atoi(words[1]));
                break;
                }

            case NOK_IPADDRESS:
                {
#ifdef WINCIT
                (*newNode)->SetIpAddress(words[1]);

                if (strlen(words[1]) > 255)
                    {
                    TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], 256);
                    TWdoccr();
                    }
#endif
                break;
                }

            case NOK_IPPORT:
                {
#ifdef WINCIT
                (*newNode)->SetIpPort(atoi(words[1]));
#endif
                break;
                }

            default:
                {
                TWcPrintf(getnodemsg(11), getnodemsg(8), ltoac(lineno), words[0]);
                TWdoccr();

                break;
                }
            }

        pos = ftell(fBuf);
        }

    fclose(fBuf);

    if (!FoundOurEntry && !option && debug)
        {
        TWwDoCR(W);
        TWwPrintf(W, getmsg(206), NameOrAddrToFind);
        TWwDoCR(W);
        }

    dump_node_ddata();

    if (option)
        {
        return (TRUE);
        }
    else
        {
        return (FoundOurEntry);
        }
    }
Esempio n. 18
0
void TERMWINDOWMEMBER fkey(uint inkey)
    {
    int key = inkey >> 8;

    // this handles the keys for dialout mode
    if (DoWhat == DIALOUT)
        {
        dialout_fkey = key;
        return;
        }

    // let RLM take over keyboard if it wants
    if (!CitadelIsConfiguring && rlmEvent(LT_KEYSTROKE, key, inkey))
        {
        return;
        }

    if (cfg.FullConLock && ConsoleLock.IsLocked() && ScreenSaver.IsOn() &&
            key != ALT_L)
        {
        return;
        }

    if (!LockMessages(MSG_CONSOLE))
        {
        cOutOfMemory(49);
        }

    if (key == CTL_F2)      // CTRL_F2 is never locked.
        {
#ifndef WINCIT
        if (allWindows)
            {
            setFocus(allWindows->wnd);
            }
#endif
        }
    else if (key != ALT_F1 && ConsoleLock.IsLocked(key == F6 || key == ALT_F6 || key == SFT_F6 || key == CTL_F6))
        {
#ifndef WINCIT
        if (key == ALT_L && ConsoleLock.MayUnlock())
            {
            GetStringFromConsole(getmsg(MSG_CONSOLE, 0), LABELSIZE, ns, GetSysPWHandler, TRUE);
            }
        else
            {
            if (cfg.VerboseConsole)
                {
                CitWindowsNote(NULL, (key == ALT_L) ? getmsg(MSG_CONSOLE, 1) : getmsg(MSG_CONSOLE, 2));
                }
            }
#endif
        }
    else
        {
        // Console is not locked

        if (CitadelIsConfiguring)
            {
            // Only let certain keystrokes through if configuring
            if (key != CTL_F6 && key != F7 && key != F8 && key != ALT_D && key != ALT_L && key != ALT_M &&
                    key != ALT_S && key != ALT_U)
                {
                WaitUntilDoneConfiguring();
                key = 0;
                }
            }

        ScreenSaver.Update();
        switch (key)
            {
            case F1:
                {
                CITWINDOW *w = CitWindowsMsg(NULL, getmsg(MSG_CONSOLE, 3));

#ifndef WINCIT
                CommPort->DropDtr();
#endif

                if (w)
                    {
                    destroyCitWindow(w, FALSE);
                    }

                break;
                }

#ifndef WINCIT
            case CTL_F1:
                {
                if (say_ascii != (int (cdecl *)(const char *, int)) nullFunc)
                    {
                    cfg.speechOn = !cfg.speechOn;

                    if (cfg.VerboseConsole)
                        {
                        CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 4), cfg.speechOn ? getmsg(317) : getmsg(316));
                        }
                    }
                else
                    {
                    cfg.speechOn = FALSE;

                    if (cfg.VerboseConsole)
                        {
                        CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 5));
                        }
                    }

                break;
                }
#endif

            case ALT_F1:
                {
                cls(SCROLL_SAVE);
                break;
                }

            case F2:
                {
                CITWINDOW *w = CitWindowsMsg(NULL, getmsg(19));

                Initport();

                if (w)
                    {
                    destroyCitWindow(w, FALSE);
                    }

                break;
                }

            case F3:
                {
                sysReq = !sysReq;

                if (cfg.VerboseConsole)
                    {
                    CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 6), sysReq ? getmsg(317) : getmsg(316));
                    }

                break;
                }

            case ALT_F3:
                {
                if (sysReq)
                    {
                    altF3Timeout = 0;
                    sysReq = FALSE;

                    if (cfg.VerboseConsole)
                        {
                        CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 6), getmsg(316));
                        }
                    }
                else
                    {
                    altF3Timeout = time(NULL) + cfg.altF3Time;
                    sysReq = TRUE;

                    if (cfg.VerboseConsole)
                        {
                        long tme = time(NULL);

                        CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 7), (altF3Timeout - tme) / 60, (altF3Timeout - tme) % 60);
                        }
                    }

                break;
                }

            case F4:
                {
                if (!StatusLine.ToggleFullScreen(WC_TWp))
                    {
                    if (cfg.VerboseConsole)
                        {
                        CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 8));
                        }
                    }

                break;
                }

            case F5:
                {
                if (onConsole)
                    {
                    OC.whichIO = MODEM;
                    OC.setio();

                    if (cfg.VerboseConsole)
                        {
                        CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 9), getmsg(MSG_CONSOLE, 10));
                        }
                    }
                else
                    {
                    OC.whichIO = CONSOLE;
                    OC.setio();

                    if (cfg.VerboseConsole)
                        {
                        CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 9), getmsg(MSG_CONSOLE, 11));
                        }
                    }

                break;
                }

            case F6:
                {
                sysopkey = TRUE;
                break;
                }

#ifndef WINCIT
            case CTL_F6:
                {
                doConsoleSysop();
                break;
                }
#endif

            case ALT_F6:
                {
                CurrentUser->SetAide(!CurrentUser->IsAide());

                if (cfg.VerboseConsole)
                    {
                    CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 12),
							CurrentUser->IsAide() ? getmsg(MSG_CONSOLE, 13) : getmsg(MSG_CONSOLE, 14), getmsg(385));
                    }

                break;
                }

            case SFT_F6:
                {
                CurrentUser->SetSysop(!CurrentUser->IsSysop());

                if (cfg.VerboseConsole)
                    {
                    CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 12),
                            CurrentUser->IsSysop() ? getmsg(MSG_CONSOLE, 13) : getmsg(MSG_CONSOLE, 14), getmsg(386));
                    }

                break;
                }

            case F7:
                {
                cfg.noBells++;

                if (cfg.noBells == 3)
                    {
                    cfg.noBells = 0;
                    }

                if (cfg.VerboseConsole)
                    {
                    CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 15), getmsg(MSG_CONSOLE, 16 + cfg.noBells));
                    }

                break;
                }

            case ALT_C:
            case F8:
                {
                chatkey = !chatkey;
                break;
                }

            case F9:
                {
                cfg.noChat = !cfg.noChat;
                chatReq = FALSE;

                if (cfg.VerboseConsole)
                    {
                    CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 19), cfg.noChat ? getmsg(316) : getmsg(317));
                    }

                break;
                }

            case F10:
            case ALT_H:
                {
                StatusLine.ToggleHelp(WC_TWp);
                break;
                }

            case ALT_F10:
                {
                StatusLine.ToggleSecond(WC_TWp);
                break;
                }

            case SFT_F10:
                {
                StatusLine.Toggle(WC_TWp);
                break;
                }

#ifdef WINCIT
            case F11:
                {
				TermWindowCollection.FocusPrev();
                break;
                }

            case F12:
                {
				TermWindowCollection.FocusNext();
                break;
                }
#endif

            case ALT_A:
                {
                CurrentUser->SetAccounting(!CurrentUser->IsAccounting());

                if (cfg.VerboseConsole)
                    {
                    CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 20), CurrentUser->IsAccounting() ? getmsg(317) : getmsg(316));
                    }

                break;
                }

            case ALT_D:
                {
                if (debug)
                    {
                    TurnDebugOff();

                    if (cfg.VerboseConsole)
                        {
                        CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 21), getmsg(316));
                        }
                    }
                else
                    {
                    if (TurnDebugOn())
                        {
                        if (cfg.VerboseConsole)
                            {
                            CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 21), getmsg(317));
                            }
                        }
                    else
                        {
                        if (cfg.VerboseConsole)
                            {
                            CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 22));
                            }
                        }
                    }

                break;
                }

#ifndef WINCIT
            case ALT_K:
                {
                if (!allWindows)
                    {
                    if (cfg.scrollSize)
                        {
                        DisplayScrollBackBuffer();
                        time(&LastActiveTime);
                        }
                    else
                        {
                        if (cfg.VerboseConsole)
                            {
                            CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 23), citfiles[C_CONFIG_CIT]);
                            }
                        }
                    }
                else
                    {
                    if (cfg.VerboseConsole)
                        {
                        CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 24));
                        }
                    }

                break;
                }
#endif

            case ALT_L:
                {
                if (*cfg.f6pass)
                    {
                    if (!SameString(cfg.f6pass, getmsg(670)))
                        {
                        ConsoleLock.Lock();

                        if (cfg.VerboseConsole)
                            {
                            CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 32));
                            }
                        }
                    }
                else
                    {
                    if (cfg.VerboseConsole)
                        {
                        CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 33), citfiles[C_CONFIG_CIT]);
                        }
                    }

                break;
                }

            case ALT_M:
                {
                memoryDump();
                break;
                }

            case ALT_P:
                {
                if (OC.Printing)
                    {
                    OC.Printing = FALSE;
                    fclose(OC.PrintFile);

                    if (cfg.VerboseConsole)
                        {
                        CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 25));
                        }
                    }
                else
                    {
#ifndef WINCIT
                    if (cfg.printerprompt)
                        {
                        GetStringFromConsole(getmsg(289), 63, cfg.printer, StartPrinting, FALSE);
                        }
                    else
#endif
                        {
                        char Buffer[sizeof(cfg.homepath) + sizeof(cfg.printer)];
                        sprintf(Buffer, sbs, cfg.homepath, cfg.printer);

                        StartPrinting(Buffer);
                        }
                    }

                break;
                }

            case ALT_R:
                repeatevent = TRUE;
                // fall through

            case ALT_F:
                forceevent = TRUE;
                // fall through

            case ALT_E:
                eventkey = TRUE;
                break;


            case ALT_S:
                {
                if (ScreenSaver.TurnOn())
                    {
#ifndef WINCIT
                    while ((*sp_press)());
#endif
                    }
                else
                    {
                    if (cfg.VerboseConsole)
                        {
                        CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 26));
                        }
                    }

                break;
                }

            case ALT_T:
                {
                CurrentUser->SetProblem(!CurrentUser->IsProblem());

                if (cfg.VerboseConsole)
                    {
                    CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 12),
                            CurrentUser->IsProblem() ? getmsg(MSG_CONSOLE, 13) : getmsg(MSG_CONSOLE, 14),
							getmsg(MSG_CONSOLE, 27));
                    }

                break;
                }

            case ALT_U:
                {
                cfg.ignore_uptime = !cfg.ignore_uptime;

                if (cfg.VerboseConsole)
                    {
                    CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 28),
							citfiles[C_CONFIG_CIT], cfg.ignore_uptime ? getmsg(317) : getmsg(316));
                    }

                break;
                }

            case ALT_V:
                {
                CurrentUser->SetVerified(!CurrentUser->IsVerified());

                if (cfg.VerboseConsole)
                    {
                    CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 12),
							CurrentUser->IsVerified() ? getmsg(MSG_CONSOLE, 13) : getmsg(MSG_CONSOLE, 14),
							getmsg(MSG_CONSOLE, 29));
                    }

                break;
                }

            case ALT_X:
            case ALT_F4:
                {
#ifndef WINCIT
                if (cfg.AltXPrompt)
                    {
                    GetYNFromConsole(getmsg(MSG_CONSOLE, 30), 0, ExitYNHandler);
                    }
                else
#endif
                    {
                    ExitToMsdos = TRUE;
                    }

                break;
                }

            case ALT_Z:
                {
                if (CommPort->HaveConnection() || debug)
                    {
                    sleepkey = TRUE;
                    }

                break;
                }

            case ALT_3:
                {
                CurrentUser->SetOut300(!CurrentUser->IsOut300());

                if (cfg.VerboseConsole)
                    {
                    CitWindowsNote(NULL, getmsg(MSG_CONSOLE, 12),
                            CurrentUser->IsOut300() ? getmsg(MSG_CONSOLE, 13) : getmsg(MSG_CONSOLE, 14),
                            getmsg(MSG_CONSOLE, 31));
                    }

                break;
                }

            case PGUP:
                {
                CurrentUser->SetCredits(CurrentUser->GetCredits() + 5 * 60);
                break;
                }

            case PGDN:
                {
                CurrentUser->SetCredits(CurrentUser->GetCredits() - 5 * 60);
                break;
                }
            }
        }

    UnlockMessages(MSG_CONSOLE);

    StatusLine.Update(WC_TWp);
    }
Esempio n. 19
0
int GetAngle4 (StisInfo4 *sts, char *ref_aper, double *angle) {

/* arguments:
StisInfo4 *sts   i: calibration switches and info
char *ref_aper   i: name of reference aperture for dispersion relation coeff
double *angle    o: incidence angle, in arcseconds
*/

	int status;

	TblInfo tabinfo;	/* pointer to table descriptor, etc */
	TblRow tabrow;		/* values read from a table row */

	double ap_offset;	/* offset of aperture used for observation */
	double ref_offset;	/* offset of reference aperture */
	int row;		/* number of rows, and loop index */
	int ap_found;		/* true if aperture found in table */
	int ref_found;		/* true if reference aperture found in table */

	/* Open the aperture description table. */
	if ((status = OpenApTab (sts->apdestab.name, &tabinfo)))
	    return (status);

	/* Check each row for a match with aperture or ref_aper. */

	ap_found = 0;
	ref_found = 0;
	for (row = 1;  row <= tabinfo.nrows;  row++) {

	    if ((status = ReadApTab (&tabinfo, row, &tabrow)))
		return (status);

	    if (SameString (tabrow.aperture, sts->aperture)) {
		ap_found = 1;
		ap_offset = tabrow.offset;
		/* Get pedigree & descrip from this row. */
		if ((status = RowPedigree (&sts->apdestab, row,
                        tabinfo.tp, tabinfo.cp_pedigree, tabinfo.cp_descrip)))
		    return (status);
		if (sts->apdestab.goodPedigree == DUMMY_PEDIGREE)
		    printf ("Warning  APDESTAB has PEDIGREE = DUMMY.\n");
	    }

	    if (SameString (tabrow.aperture, ref_aper)) {
		ref_found = 1;
		ref_offset = tabrow.offset;
	    }
	    if (ap_found && ref_found)
		break;
	}

	if ((status = CloseApTab (&tabinfo)))
	    return (status);

	if (!ap_found || !ref_found) {
	    if (!ap_found)
		printf ("APERTURE %s not found in APDESTAB.\n", sts->aperture);
	    if (!ref_found)
		printf ("REF_APER %s not found in APDESTAB.\n", ref_aper);
	    printf ("  APDESTAB = %s\n", sts->apdestab.name);
	    return (TABLE_ERROR);
	}

	*angle = ap_offset - ref_offset;

	return (0);
}
Esempio n. 20
0
int GetCCDTab (ACSInfo *acs, int dimx, int dimy) {

/* arguments:
ACSInfo *acs     io: calibration switches, etc
int     dimx      i: number of columns in exposure
int     dimy      i: number of lines in exposure
*/

	extern int status;

	TblInfo tabinfo;	/* pointer to table descriptor, etc */
	TblRow tabrow;		/* values read from a table row */

	int row;		/* loop index */
	int i;
	char amp[5] = "ABCD";
    int samegain;
	
	int foundit;		/* has the correct row been found? */
	int RowPedigree (RefTab *, int, IRAFPointer, IRAFPointer, IRAFPointer);
	int SameInt (int, int);
	int SameFlt (float, float);
	int SameString (char *, char *);

	/* Open the CCD parameters table and find columns. */
	if (OpenCCDTab (acs->ccdpar.name, &tabinfo))
	    return (status);

	/* Check each row for a match with ccdamp, ccdgain, ccdoffst,
	   binaxis1, and binaxis2, and get info from the matching row.
	*/

	foundit = 0;
	for (row = 1;  row <= tabinfo.nrows;  row++) {

	    /* Read the current row into tabrow. */
	    if (ReadCCDTab (&tabinfo, row, &tabrow))
		return (status);

        /* Commanded gain values were int valued pre-SM4 and 
           float valued post-SM4, so we need to check what type
           of ref table we have as input.
        */
        if (tabinfo.intgain == 1) {
            /* Pre-SM4 int valued table */
            samegain = SameInt (tabrow.ccdgaini, (int)acs->ccdgain);
        } else {
            /* Post-SM4 float valued table */
            samegain = SameFlt (tabrow.ccdgainf, acs->ccdgain);
        }

	    if (SameString (tabrow.ccdamp, acs->ccdamp) &&
		samegain &&
		SameInt (tabrow.ccdchip, acs->chip) &&
		SameInt (tabrow.ccdoffset[0], acs->ccdoffset[0]) &&
		SameInt (tabrow.ccdoffset[1], acs->ccdoffset[1]) &&
		SameInt (tabrow.ccdoffset[2], acs->ccdoffset[2]) &&
		SameInt (tabrow.ccdoffset[3], acs->ccdoffset[3])) {

		foundit = 1;
		if (RowPedigree (&acs->ccdpar, row,
			tabinfo.tp, tabinfo.cp_pedigree, tabinfo.cp_descrip))
		    return (status);
		if (acs->ccdpar.goodPedigree == DUMMY_PEDIGREE) {
		    sprintf (MsgText, "Row %d of CCDTAB is DUMMY.", row);
			trlwarn (MsgText);
		}

		for (i = 0; i < NAMPS; i++){
			/* If the amp is used, keep the value, otherwise set to zero*/
			if (strchr(acs->ccdamp, amp[i]) != NULL) {
				acs->atodgain[i] = tabrow.atodgain[i];
				acs->readnoise[i] = tabrow.readnoise[i];
				acs->ccdbias[i] = tabrow.bias[i];
			} else {
				acs->atodgain[i] = 0.;
				acs->readnoise[i] = 0.;			
				acs->ccdbias[i] = 0.;			
			}
		}

        /* 
            Correct ampx/ampy to match the actual size of the exposure
            This will allow more seamless processing of subarrays.
        */
		acs->ampx = (tabrow.ampx > dimx) ? dimx : tabrow.ampx;
		acs->ampy = tabrow.ampy;		
		acs->saturate = tabrow.saturate;
		break;
	    }
	}

	if (!foundit) {
	    sprintf (MsgText, "Matching row not found in CCDTAB `%s'.", acs->ccdpar.name);
	    trlerror (MsgText);
		sprintf (MsgText, "CCDAMP %s, CCDGAIN %4.1f, CCDOFFST %d,%d,%d,%d.",
		acs->ccdamp, acs->ccdgain, acs->ccdoffset[0], acs->ccdoffset[1],
		acs->ccdoffset[2], acs->ccdoffset[3]);
		trlerror (MsgText);
		
	    CloseCCDTab (&tabinfo);
	    return (status = TABLE_ERROR);
	}

	if (CloseCCDTab (&tabinfo))		/* close the table */
	    return (status);

	return (status);
}
Esempio n. 21
0
static Bool initCitadel(void)
    {
    if (!read_cfg_messages())
        {
#ifdef WINCIT
        char Buffer[128];
        sprintf(Buffer, getmsg(188), getmsg(671));
        MessageBox(NULL, Buffer, NULL, MB_ICONSTOP | MB_OK);
#else
        printf(getmsg(188), getmsg(671));
#endif
        return (FALSE);
        }

    checkfiles();

    initExtDrivers();

    get_os();

	cfg.battr = 0xff;
    setscreen();

    logo(TRUE); // no go for debug version; td32 go crash crash

    init_internal_sound();

	// some mouse initialization technology!!!!
    initMouseHandler();
    hideCounter = 1;

    if (time(NULL) < 700000000L)
        {
#ifdef WINCIT
        MessageBox(NULL, getcfgmsg(119), NULL, MB_ICONSTOP | MB_OK);
#else
        doccr();
        doccr();
        cPrintf(getcfgmsg(119));
        doccr();
#endif
        dump_cfg_messages();
        return (FALSE);
        }


    static char prompt[92];
    static char citadel[92];
    char *envprompt;
    char *citprompt;

    envprompt = getenv(getcfgmsg(120));
    citprompt = getenv(getcfgmsg(121));
    if (citprompt)
        {
        sprintf(prompt, getcfgmsg(122), citprompt);
        }
    else if (envprompt)
        {
        sprintf(prompt, getcfgmsg(123), envprompt);
        }
    else
        {
        strcpy(prompt, getcfgmsg(124));
        }
    putenv(prompt);

    sprintf(citadel, getcfgmsg(125), programName, version);
    putenv(citadel);


#ifndef WINCIT
    OC.whichIO = CONSOLE;
    OC.SetOutFlag(OUTOK);
    OC.Echo = BOTH;
    OC.setio();
#endif

    VerifyHeap(1);

    // If we aren't reconfiguring, load the tables...
    if (!reconfig)
        {
        // Start by reading ETC.TAB
        getcwd(etcpath, 64);

        FILE *fd;
        if ((fd = fopen(etcTab, FO_RB)) != NULL)
            {
            if (filelength(fileno(fd)) != (long) sizeof(config) ||
					fread(&cfg, 1, sizeof(config), fd) != (long) sizeof(config))
                {
                memset(&cfg, 0, sizeof(cfg));
                reconfig = TRUE;
                }

            fclose(fd);
            unlink(etcTab);


            // If ETC.TAB could be loaded, load the rest
            if (!reconfig)
                {
                changedir(cfg.homepath);

                allocateTables();

                if (!LogTab.Load() || !MessageDat.LoadTable() || !RoomTab.Load())
                    {
                    reconfig = TRUE;
                    }

                Cron.ReadTable(WC_TWpn);
                }
            }
        else
            {
            if (!batchmode)
                {
#ifdef WINCIT
                MessageBox(NULL, "No ETC.TAB.", NULL, MB_ICONSTOP | MB_OK);
#else
                doccr();

                discardable *d;

                if ((d = readData(6)) != NULL)
                    {
                    int i;

                    for (i = 0; ((char **) d->next->aux)[i][0] != '#'; i++)
                        {
                        cPrintf(pcts, ((char **) d->next->aux)[i]);
                        doccr();
                        }

                    doccr();

                    discardData(d);
                    }
                else
                    {
                    cOutOfMemory(28);
                    }

                DeinitializeTimer();
                critical(FALSE);
#endif
                exit(1);
                }

            reconfig = TRUE;
            }
        }



    if (reconfig)
        {
        cfg.attr = 7;

#ifndef WINCIT
        pause(200);
        cls(SCROLL_SAVE);

        cCPrintf(getcfgmsg(126));
        doccr();
#endif


        if (!configcit())
            {
#ifdef WINCIT
            MessageBox(NULL, getcfgmsg(127), NULL, MB_ICONSTOP | MB_OK);
#else
            doccr();
            doccr();
            cPrintf(getcfgmsg(127));
            doccr();
#endif
            dump_cfg_messages();
            return (FALSE);
            }


#ifndef WINCIT
        setdefaultTerm(TT_ANSI);
        CurrentUser->SetWidth(80);
#endif

        Cron.ReadCronCit(WC_TWpn);
        }
    else
        {
#ifndef WINCIT
        if (!CreateScrollBackBuffer())
            {
            cPrintf(getcfgmsg(60));
            doccr();
            }
#endif


        if (readconfigcit)  // forced to read in config.cit
            {
            if (!readconfig(NULL, 1))
                {
#ifdef WINCIT
                MessageBox(NULL, getcfgmsg(129), NULL, MB_ICONSTOP | MB_OK);
#else
                doccr();
                doccr();
                cPrintf(getcfgmsg(129));
                doccr();
#endif
                dump_cfg_messages();
                return (FALSE);
                }
            }
        }

    VerifyHeap(1);

    makeBorders();
    readBordersDat();

    if (cmd_nobells)
        {
        cfg.noBells = 2;
        }

    if (cmd_nochat)
        {
        cfg.noChat = TRUE;
        }

    if (cmd_mdata != CERROR)
        {
        cfg.mdata = cmd_mdata;
        }

    if (*cfg.f6pass)
        {
        if (SameString(cfg.f6pass, getmsg(670)))
            {
            ConsoleLock.LockF6();
            }
        else
            {
            ConsoleLock.Lock();
            }
        }


#ifndef WINCIT
    if (cfg.ovrEms)
        {
        if (_OvrInitEms(0, 0, 0))
            {
            cPrintf(getcfgmsg(130));
            doccr();
            pause(200);
            }
        }

    if (cfg.ovrExt)
        {
        if (_OvrInitExt(0, 0))
            {
            cPrintf(getcfgmsg(131));
            doccr();
            pause(200);
            }
        }

    CommPort->Init();
    setscreen();
#endif

    logo(TRUE); // no go for debug version; td32 go crash crash

#ifndef WINCIT
    StatusLine.Update(WC_TWp);
#endif

    if (cfg.msgpath[(strlen(cfg.msgpath) - 1)] == '\\')
        {
        cfg.msgpath[(strlen(cfg.msgpath) - 1)] = '\0';
        }

    // move to home path
    changedir(cfg.homepath);
    char FileName[128];

    ReIndexFileInfo();  // keep fileinfo.dat nice and pretty

    // open message file
    if (!MessageDat.OpenMessageFile(cfg.msgpath))
		{
		illegal(getmsg(78), MessageDat.GetFilename());
		}

    // Then room file
    sprintf(FileName, sbs, cfg.homepath, roomDat);
    openFile(FileName, &RoomFile);

    citOpen(cfg.trapfile, CO_A, &TrapFile);
    initMenus();
    dump_cfg_messages();

    if(!read_tr_messages())
        {
        errorDisp(getmsg(172));
        }
    else
        {
#ifdef WINCIT
    trap(T_SYSOP, "", gettrmsg(37));
#else
    trap(T_SYSOP, gettrmsg(37));
#endif
        dump_tr_messages();
        }

        read_cfg_messages();            // uh-oh!

    if (!GroupData.Load())
        {
        return (FALSE);
        }

    if (!HallData.Load())
        {
        return (FALSE);
        }

    getRoomPos();

    if (cfg.accounting)
        {
        ReadGrpdataCit(WC_TWpn);
        }

    ReadExternalCit(WC_TWpn);
    ReadProtocolCit(WC_TWpn);
    ReadMdmresltCit(WC_TWpn);
    ReadCommandsCit(WC_TWpn);


#ifndef WINCIT
    ReadMCICit(FALSE);

    CurrentRoom->Load(LOBBY);
    thisRoom = LOBBY;
    checkdir();

    if (!slv_door)
        {
        CITWINDOW *w = CitWindowsMsg(NULL, getmsg(19));

        Initport();
        Initport();

        if (w)
            {
            destroyCitWindow(w, FALSE);
            }
        }
    else
        {
        CommPort->Enable();
        }

    OC.whichIO = MODEM;
    OC.setio();
#endif


    // record when we put system up
    time(&uptimestamp);

#ifndef WINCIT
    setdefaultconfig(FALSE);
    Talley->Fill();
#endif
    logo(FALSE);

    VerifyHeap(1);

    dump_cfg_messages();
    compactMemory(1);

    return (TRUE);
    }
Esempio n. 22
0
int GetCCDTab (StisInfo1 *sts) {

/* arguments:
StisInfo1 *sts     io: calibration switches, etc
*/

	int status;

	TblInfo tabinfo;	/* pointer to table descriptor, etc */
	TblRow tabrow;		/* values read from a table row */

	int row;		/* loop index */
	int foundit;		/* has the correct row been found? */

	/* Open the CCD parameters table and find columns. */
	if ((status = OpenCCDTab (sts->ccdpar.name, &tabinfo)))
	    return (status);

	/* Check each row for a match with ccdamp, ccdgain, ccdoffst,
	   binaxis1, and binaxis2, and get info from the matching row.
	*/

	foundit = 0;
	for (row = 1;  row <= tabinfo.nrows;  row++) {

	    /* Read the current row into tabrow. */
	    if ((status = ReadCCDTab (&tabinfo, row, &tabrow)))
		return (status);

	    if (SameString (tabrow.ccdamp, sts->ccdamp) &&
		SameInt (tabrow.ccdgain, sts->ccdgain) &&
		SameInt (tabrow.ccdoffset, sts->ccdoffset) &&
		SameInt (tabrow.bin[0], sts->binaxis[0]) &&
		SameInt (tabrow.bin[1], sts->binaxis[1])) {

		foundit = 1;
		if ((status = RowPedigree (&sts->ccdpar, row,
                        tabinfo.tp, tabinfo.cp_pedigree, tabinfo.cp_descrip)))
		    return (status);
		if (sts->ccdpar.goodPedigree == DUMMY_PEDIGREE)
		    printf ("Warning  Row %d of CCDTAB is DUMMY.\n", row);
		sts->atodgain = tabrow.atodgain;
		sts->ccdbias = tabrow.ccdbias;
		sts->readnoise = tabrow.readnoise;
		sts->saturate = tabrow.saturate;
		sts->blev_clip = tabrow.blev_clip;
		break;
	    }
	}

	if (!foundit) {
	    printf ("ERROR    Matching row not found in CCDTAB `%s'.\n",
			sts->ccdpar.name);
	    printf (
		"ERROR    CCDAMP %s, CCDGAIN %d, CCDOFFST %d, BINAXIS %d,%d.\n",
		sts->ccdamp, sts->ccdgain, sts->ccdoffset,
		sts->binaxis[0], sts->binaxis[1]);
	    CloseCCDTab (&tabinfo);
	    return (TABLE_ERROR);
	}

	if ((status = CloseCCDTab (&tabinfo)))  /* close the table */
	    return (status);

	return (0);
}
Esempio n. 23
0
static void GetSDC (StisInfo4 *sts) {

	IRAFPointer tp;
	IRAFPointer cp_opt_elem;
	IRAFPointer cp_a2center, cp_cdelt2;
	IRAFPointer cp_pedigree, cp_descrip;
	char opt_elem[STIS_CBUF+1];		/* grating or prism name */
	int nrows, row;
	int foundit;

	/* default values */
	sts->crpix[1] = PRISM_CRPIX2 - 1.;	/* zero indexed */
	sts->cdelt[1] = PRISM_CDELT2;		/* degrees per pixel */
	sts->crpix[0] = 0.;		/* the rest are not used */
	sts->cdelt[0] = 0.;
	sts->crval[0] = 0.;
	sts->crval[1] = 0.;

	tp = c_tbtopn (sts->sdctab.name, IRAF_READ_ONLY, 0);
	if (c_iraferr()) {
	    printf ("Warning  SDCTAB `%s' not found; default values used.\n",
		sts->sdctab.name);
	    clear_cvoserr();
	    return;
	}
	nrows = c_tbpsta (tp, TBL_NROWS);

	c_tbcfnd1 (tp, "OPT_ELEM", &cp_opt_elem);
	c_tbcfnd1 (tp, "A2CENTER", &cp_a2center);
	c_tbcfnd1 (tp, "CDELT2", &cp_cdelt2);
	if (cp_opt_elem == 0 || cp_a2center == 0 || cp_cdelt2 == 0) {
	    printf ("Warning  Column(s) not found in SDCTAB; defaults used.\n");
	    c_tbtclo (tp);
	    return;
	}
	c_tbcfnd1 (tp, "PEDIGREE", &cp_pedigree);
	c_tbcfnd1 (tp, "DESCRIP", &cp_descrip);

	foundit = 0;
	for (row = 1;  row <= nrows;  row++) {

	    c_tbegtt (tp, cp_opt_elem, row, opt_elem, STIS_CBUF);
	    if (c_iraferr()) {
		strcpy (opt_elem, "dummy");
		clear_cvoserr();
	    }

	    if (SameString (opt_elem, sts->opt_elem)) {

		foundit = 1;
		c_tbegtd (tp, cp_a2center, row, &sts->crpix[1]);
		c_tbegtd (tp, cp_cdelt2, row, &sts->cdelt[1]);
		sts->crpix[1] -= 1.;		/* zero indexed */
		sts->cdelt[1] /= 3600.;		/* degrees per pixel */

		RowPedigree (&sts->sdctab, row, tp, cp_pedigree, cp_descrip);

		break;
	    }
	}

	c_tbtclo (tp);

	if (!foundit)
	    printf ("Warning  PRISM not found in SDCTAB; defaults used.\n");
}
Esempio n. 24
0
int GetDisp4 (StisInfo4 *sts, DispRelation *disp, char *ref_aper) {

/* arguments:
StisInfo4 *sts       i: calibration switches and info
DispRelation *disp   o: dispersion relation
char *ref_aper       o: name of aperture used to measure dispersion relation
*/

	int status;

	TblInfo tabinfo;	/* pointer to table descriptor, etc */
	TblRow tabrow;		/* values read from a table row */

	int row;		/* loop index */
	int best_row;		/* read info from this row */
	double a2diff;		/* difference between A2CENTER and middle */
	double min_a2diff;	/* min value of a2diff */

	/* Open the dispersion coefficients table. */
	if ((status = OpenDSPTab (sts->disptab.name, &tabinfo)))
	    return (status);

	best_row = -1;			/* initial values */
	min_a2diff = 2. * MIDDLE_LINE;

	for (row = 1;  row <= tabinfo.nrows;  row++) {

	    if ((status = ReadDSPTab (&tabinfo, row, &tabrow)))
		return (status);

	    /* Check for a match with opt_elem and cenwave. */

	    if (SameString (tabrow.opt_elem, sts->opt_elem) &&
		SameInt (tabrow.cenwave, sts->cenwave)) {

		a2diff = fabs (tabrow.a2center - MIDDLE_LINE);
		if (a2diff < min_a2diff) {
		    min_a2diff = a2diff;
		    best_row = row;
		}
	    }
	}

	if (best_row < 1) {
	    printf ("Matching row not found in DISPTAB %s:\n",
				sts->disptab.name);
	    printf ("    OPT_ELEM %s, CENWAVE %d\n",
			sts->opt_elem, sts->cenwave);
	    return (TABLE_ERROR);
	}

	/* Read data from the most appropriate row. */
	if ((status = ReadDSPArray (&tabinfo, best_row, disp, ref_aper)))
	    return (status);

	/* Get pedigree & descrip from this row. */
	if ((status = RowPedigree (&sts->disptab, best_row,
                tabinfo.tp, tabinfo.cp_pedigree, tabinfo.cp_descrip)))
	    return (status);
	if (sts->disptab.goodPedigree == DUMMY_PEDIGREE) {
	    printf ("Warning  DUMMY pedigree in row %d of %s.\n",
		best_row, sts->disptab.name);
	}

	if ((status = CloseDSPTab (&tabinfo)))
	    return (status);

	return (0);
}
Esempio n. 25
0
int GetApOffset6 (StisInfo6 *sts, float *ap_offset, char *ref_aper,
		double *delta) {

/* arguments:
StisInfo6 *sts   i: calibration switches and info
float *ap_offset i: offset of aperture from position reference
char *ref_aper   i: name of reference aperture for dispersion relation coeff
double *delta    o: offset in dispersion direction, arcseconds
*/

	int status;

	TblInfo tabinfo;	/* pointer to table descriptor, etc */
	TblRow tabrow;		/* values read from a table row */

	int row;		/* number of rows, and loop index */
	int pedigree;		/* for selected row */
	int foundit = 0;	/* true if aperture found in table */

	/* Open the aperture description table. */
	if ((status = OpenApTab (sts->apdestab.name, &tabinfo)))
	    return (status);

	/* Check each row for a match with ref_aper. */

	for (row = 1;  row <= tabinfo.nrows;  row++) {

	    if ((status = ReadApTab (&tabinfo, row, &tabrow)))
		return (status);

	    if (SameString (tabrow.aperture, ref_aper)) {

		foundit = 1;
		if ((status = CheckPedigree (&tabinfo, row, &pedigree)))
		    return (status);
		if (pedigree == DUMMY_PEDIGREE) {
	            sts->x1d_o = DUMMY;
		    *delta = 0.;
		    CloseApTab (&tabinfo);
		    return (0);
		} else {
		    if (sts->dispaxis == 1)
			*delta = ap_offset[0] - tabrow.offset[0];
		    else if (sts->dispaxis == 2)
			*delta = ap_offset[1] - tabrow.offset[1];
		    else
			*delta = 0.;
		}

		break;
	    }
	}

	if ((status = CloseApTab (&tabinfo)))
	    return (status);

	if (!foundit) {
	    printf ("ERROR    APERTURE %s not found in APDESTAB %s\n",
		sts->aperture, sts->apdestab.name);
	    return (ROW_NOT_FOUND);
	}

	return (0);
}
Esempio n. 26
0
void DataCaptureGridCtrl::FinishEdit(const char* szText, int nValue, int nLastChar)
{
  dataCaptureUIChange = true;

  int dCapIndex = m_cellActive.m_nRow - 1;

  bool wasInvalid  = (dataCaptureData.IsNotValid(dCapIndex));

  dataCapture.CheckAndAllocDataCapture(dCapIndex);
  DataCaptureSpec& currRef = dataCaptureData.GetRef(dCapIndex);

  // Change values in Grid
  CGridCell* pCell = GetCell(m_cellActive.m_nRow, m_cellActive.m_nCol);

  int currCol = m_cellActive.m_nCol;
  if ((!control.IsLayered()) && (currCol > 3))
    currCol++;

  if (control.Is2DRadial() && (currCol == 6))
    currCol = 7;

  switch (currCol) {
  case 1: // desig
  {
    if (!SameString(currRef.dataDesig, szText))
      currRef.makeDefaultDataDesig = false;

    CopyString(currRef.dataDesig, szText, DataCaptureSpec::dataDesigLen);

    if ((dCapIndex == 0) && (currRef.IsWell() && currRef.IsPressure()))
    {
      // changing main well name -- change for flow too
      if (dataCaptureData.IsValid(1))
      {
        DataCaptureSpec& flowRef = dataCaptureData.GetRef(1);
        if (flowRef.IsFlow() && flowRef.IsWell())
        {
          CopyString(flowRef.dataDesig, szText, DataCaptureSpec::dataDesigLen);
          ResetCell(2, 1);
        }
      }
    }
    // adding new -- assume obs well
    if (wasInvalid)
    {
      currRef.captureType = DataCaptureSpec::ctPressure;
      currRef.pressureCapType = DataCaptureSpec::pctRadius;
    }
    break;
  }
  case 2: // Type
  {
    static_cast<CaptureTypeGridCell*>(pCell)->SetDataCaptureType(nValue);
    break;

  }
  case 3: // sub-type
  {
    static_cast<CaptureSubTypeGridCell*>(pCell)->SetDataCaptureSubType(nValue);
    break;
  }
  case 4: // zone
  {
    static_cast<DcapWellboreZoneDesigGridCell*>(pCell)->SetWellboreZone(nValue);
    break;
  }
  case 5: // radii
  {
    if (currRef.UsesRadius())
    {
      if (currRef.IsPressure() && (control.Is2DRadial() || control.IsHorizontalAnisotropic()))
        ResetCell(m_cellActive.m_nRow, 5);
      else
        currRef.radiusData.IsWithinRange(szText, 0.001, 1.0E+05);
    }
    break;
  }
  case 6: // radii units
  {
    if (currRef.UsesRadiusUnits())
    {
      currRef.radiusData.SetConvIndex(nValue);
      if (currRef.UsesRadius())
        ResetCell(m_cellActive.m_nRow, 4);
    }
    break;
  }
  case 7: // output units
  {
    currRef.outputUnits.SetConvIndex(nValue);
    break;
  }

  }

  // update all
  for (int i = 1; i < GetColCount(); i++)
    ResetCell(m_cellActive.m_nRow, i);

  OutputUnitsGridCell* currCell = static_cast<OutputUnitsGridCell*>(GetCell(m_cellActive.m_nRow, GetColCount() - 1));
  currCell->SetUnitType(currRef.outputUnits.unitType);

  if (dataCapture.SetDataCaptureDesigs())
  {
    for (int i = m_cellActive.m_nRow; i < GetRowCount(); i++)
      ResetCell(i, 1);
  }

  StopEdit(false);

  // if the right key continue editing on next cell
  switch (nLastChar) {
  case VK_TAB:
  case VK_DOWN:
  case VK_UP:
  case VK_RIGHT:
  case VK_LEFT:
  case VK_NEXT:
  case VK_PRIOR:
  case VK_HOME:
  case VK_END:
    OnKeyDown(nLastChar, 0, 0);
    UpdateWindow();
    if (m_cellActive != m_cellActiveOld)
      StartEdit(nLastChar);
    break;
  }
}
Esempio n. 27
0
int Boolean(const char *Value) {

    if (Value == NULL) return FALSE;

    return (SameString(Value,"True") || SameString(Value,"On") || SameString(Value,"Yes") || SameString(Value,"1"));
}
Esempio n. 28
0
Bool ConsoleLockC::MayUnlock(void)
    {
    return (LockState == CON_LOCKED &&
			!(SameString(cfg.f6pass, getmsg(670)) || SameString(cfg.f6pass, getmsg(MSG_CONSOLE, 36))));
    }
Esempio n. 29
0
int GetAbsPhot (StisInfo7 *sts, int sporder, PhotInfo *phot, int print,
                int *warn) {

/* arguments:
StisInfo *sts   i: calibration switches and info
int sporder     i: current order number
PhotInfo *phot  o: factors to convert to absolute flux
int print	i: if set to zero, turn off error message printing
int *warn	io: if set to zero, turn off blaze shift warning
*/

	int status;

	TblInfo tabinfo;	/* pointer to table descriptor, etc */
	TblRow tabrow;		/* values read from a table row */

	int row;		/* loop index */
	int foundit = 0;	/* true if parameters found in table */

	/* Assign the units for the calibrated data. */
	strcpy (phot->bunit, "erg /s /cm**2 /angstrom /arcsec**2");

	/* Open the photometry table. */
	if ((status = OpenPhotTab (sts, &tabinfo, phot, warn)))
	    return (status);

	/* Check each row for a match with keyword values, then read
	   the arrays of wavelength and throughput if there's a match.
	*/

	for (row = 1;  row <= tabinfo.nrows;  row++) {

	    if ((status = ReadPhotTab (&tabinfo, row, &tabrow)))
		return (status);

	    if (sts->obstype == SPECTROSCOPIC_TYPE) {
		if (!SameInt (tabrow.cenwave, sts->cenwave) ||
		    !SameInt (tabrow.sporder, sporder))
		    continue;
	    }

	    if (SameString (tabrow.opt_elem, sts->opt_elem)) {

		foundit = 1;

		/* Get pedigree & descrip from the row. */
		if ((status = RowPedigree (&sts->phottab, row,
                        tabinfo.tp, tabinfo.cp_pedigree, tabinfo.cp_descrip)))
		    return (status);
		if (sts->phottab.goodPedigree == DUMMY_PEDIGREE) {
		    printf ("Warning  DUMMY pedigree in row %d of %s.\n",
			row, sts->phottab.name);
		    sts->x2dcorr_o = DUMMY;
		    ClosePhotTab (&tabinfo);
		    return (0);
		}

		/* Read wavelengths and throughputs into phot. */
		if ((status = ReadPhotData (&tabinfo, row, phot)))
		    return (status);

		break;
	    }
	}

	if ((status = ClosePhotTab (&tabinfo)))
	    return (status);

	if (!foundit) {
	    if (print) {
	        printf ("Warning  Matching row not found in PHOTTAB %s; \\\n",
			 sts->phottab.name);
	        if (sts->obstype == SPECTROSCOPIC_TYPE) {
		    printf ("Warning  OPT_ELEM %s, CENWAVE %d, SPORDER %d.\n",
			    sts->opt_elem, sts->cenwave, sporder);
	        } else {
		    printf ("Warning  OPT_ELEM %s\n", sts->opt_elem);
	        }
	        sts->x2dcorr_o = OMIT;
	    } else
	        return (ROW_NOT_FOUND);
	}

	return (0);
}
Esempio n. 30
0
/* -------------------------------------------------------------------- */
void ReadExternalCit(void)
	{
	FILE *fBuf;
	char line[257];
	char *words[256];
	int count;

	if ((fBuf = fopen(externalCit, "r")) == NULL)       /* ASCII mode */
		{
		printf("Cannot find %s!", externalCit);
		exit(69);
		}
	else
		{
		int i, lineNo = 0;

		while (fgets(line, 256, fBuf) != NULL)
			{
			lineNo++;

			if (line[0] != '#')
				{
				continue;
				}

			count = parse_it(words, line);

			if (SameString(words[0], "#PROTOCOL"))
				{
				protocols *theProt;

				theProt = (protocols *) addLL((void **) &protList,
							sizeof(*theProt));

				if (theProt)
					{
					CopyStringToBuffer(theProt->name, words[1], LABELSIZE);
					theProt->batch = !!atoi(words[2]);
					theProt->block = atoi(words[3]);
					CopyStringToBuffer(theProt->rcv, words[4], 127);
					CopyStringToBuffer(theProt->snd, words[5], 127);

					if (count <= 6 || words[6][0] == '\0')
						{
						theProt->autoDown[0] = '\0';
						}
					else
						{
						CopyStringToBuffer(theProt->autoDown, words[6], LABELSIZE);
						}

					if (count > 7)
						{
						CopyStringToBuffer(theProt->respDown, words[7], 127);
						}
					}
				else
					{
					printf("Not enough memory for #PROTOCOL \"%s\"",
							words[1]);
					printf("\n");
					}
				}
			}

		fclose(fBuf);
		}
	}