Mest Lover
Not Sea Org Qualified
Hah, found a couple of the programs I wrote for CLO EUS. This was the stat evolution program.
----------------------
----------------------
Code:
/*
@(#) evol.c 1.1temp 91/01/05. COPYRIGHT (C) Q.U.E. computers 1990, 1991.
ALL RIGHTS RESERVED.
*** TEMPORARY WORKING VERSION THAT PUTS THE NUMBERS INTO A FILE FOR
ERIK KNAURHASE TO USE ON HIS COMPUTER
THIS C SORCE FILE PROGRAM WAS DESIGNED AND WRITTEN BY ANDRUE C. CARR
FOR Q.U.E. computers AND IS FOR EXCLUSIVE USE BY CLO EUS. EXPRESSED
WRITTEN PERMISSION FROM: Q.U.E. computers, ANDRUE C. CARR, OR
3F PRODUCTIONS IS REQUIRED FOR ITS: COMERCIAL USE, COMPILATION,
DUPLICATION, MODIFICATION, OR EXECUTION.
IN THE EVENT THAT THE WORKING COPY FOUND IN THE DIRECTORY: /usr/bin
IS RENDERED NON-EXECUTABLE OR ERASED, WRITTEN PERMISSION IS HEREBY
GRANTED TO COMPILE THE SORCE CODE FOUND IN THE DIRECTORY:
/usr/local/cprog AND DUPLICATE THE OBJECT FILE TO THE DIRECTORY:
/usr/bin BY ANY Q.U.E. computers OR CLO EUS AUTHORIZED C LANGUAGE
PROGRAMMER FOR THE SOLE PURPOSE OF RESTORING A WORKING COPY OF THIS
PROGRAM TO THE CLO EUS XENIX SYSTEM V 386 COMPUTER. BACKUP OR
HARDCOPIES MAY BE OBTAINED BY CONTACTING ANDRUE C. CARR.
ALL APPLICABLE COPYRIGHT LAWS DO APPLY.
o compile as usual: cc evol.c
copy to /usr/bin: cp a.out /usr/bin/evol.o
o INCLUDES: CASE CHANGE, SOME SPEED INCREASE, QUOTES (SIG/COND),
MORE EFF. SPELL, GOOD BOZO CHECKS, BREAK ON ORG SEARCH, SOME
CLEAN UP, BINARY ORG AND FLAG ASSIGNMENT, TELEX WRITING AND
SENDING (IF PRINTING) WITH INDIVIDUAL TLXNUMBERS.
WDAHWO + WDAHP ?= WDAH HAS BEEN RESTORED AS I THINK I DEBUGGED
THIS AND SHOULD RUN NORMALLY NOW. CABLE STRAIGHTENING IS NOW
IN PLACE ON TEST_FLAG[0] SO IT WILL TAKE A CABLE THAT IS DONE
WITHOUT NEWLINES AND PUT IT STRAIGHT UP AN DOWN AND PROPERLY
PLACE THE STATS THEN PRINT IT PUTS FINAL FILE IN fix.[orgname]
CABLE MUST BE EDITED THOUGH SO DO NORMAL EDITING BEFORE RUNNING
THIS. I DID SOME WORK ON THE SHELL SCRIPT TO REMOVE .tlxnum ONLY
WHEN IT RECOGNIZES THAT THE USER HAS DONE A PROCESS OF A CABLE
THIS SHOULD HELP WITH THE TELEX NUMBERS. IF YOU NEED TO EXIT
USE c OPTION ON MENU AND cat .tlxnum REMEMBER THE NUMBER AND
THEN WHEN YOU ENTER THE EVOL PGM AGAIN JUST USE THE c OPTION
AND echo -n [#] >.tlxnum TO RESTORE THE NUMBERS. [#] IS THE
NUMBER YOU REMEMBERED. ***NOW DOES BETTER SPELL CHECKING FROM
/usr/stats/cable.spell AND BREAKS WHEN PICKED.
* SWAPS ON PROMO OUT AND PROMO RATIO WHEN PROMO OUT IS 0.XX.
o NEEDS: INCREASED SPEED, MORE CLEAN UP, AND WORK ON
COOKING MODULE, FIX NEEDED ON TEST_FLAG[1] WHICH SETS 4 FOR SOME
REASON??, possibly done by lowing MAXORGS to 40., * A MINOR BUG
MAY OCCUR IN TELEX NUMBERING IF TWO PEOPLE ARE RUNING THE EVOL.SH
PROGRAM AT THE SAME TIME, IF ONE PERSON LOGS OUT AND THE OTHER IS
RUNNING evol.o PROGRAM THEN THE TELEX NUMBERS WILL START AT [date]610
AGAIN. THIS IS CAUSED BY THE EVOL.SH PROGRAM REMOVING THE .tlxnum
FILE WHEN LOGGING OUT, I HAVENT FIGURED OUT HOW TO REMOVE THE FILE
WHEN DONE OTHERWISE, AND BOTH PEOPLE SHOULD REMAIN LOGGED INTO
EVOL.SH WHEN PROCESSING STATS OR RENUMBER THE TELEXES FROM EXTERNAL
COMM. * STILL WONT DO MULTIPLE FILES BUT WILL DO MULTIPLE TELEXES
IN ONE FILE NO PROBLEM, I NEED TO DO A COMPLETE RE-WRITE TO GET
THIS TO HAPPEN CAN BE DONE IN THE FUTURE BUT REQUIRES A LOT OF
MOVEING IN THE MAIN MODULE, BASICALLY THE WHILE LOOP FROM THE
GETSTAT PORTION OF MAIN() NEEDS TO BE WIDENED TO INCLUDE THE
OTHER STUFF IN MAIN BEFORE EXIT BUT I HAD SOME PROBLEMS WITH THE
FENSES IN A LOWER PORTION WHEN I DID THIS, NEEDS LOOKING INTO.
A CUSTOMIZED STAT EVOLUTION COMPILATION AND MASTER CABLE GENERATION
PROGRAM.
*) :-) *===> -----}|
*/
#include <stdio.h>
#include <time.h>
#include <sys/types.h>
#include <signal.h>
#include <ctype.h>
#define MAXORGS 55 /* if problems w/memory lower this*/
#define MAXSTATS 300 /* if problems w/memory lower this*/
#define MAXSPELL 8 /* total # of diff. kinds of spells */
#define TRUE 1
#define FALSE 0
/* global variables */
char bell = '\007', temp[6][60], date_v[1][26], user[1][20], cwd[1][41];
char func[1][10], func_small[1][10], *we_date[26];
char lspot[1][21], l2spot[1][21], header[1][24];
char file_name[MAXORGS][40], spell[MAXSPELL][MAXSTATS][30];
char orgnames[MAXORGS][11], stat_kind[2][MAXSTATS][30], option[1][6];
char real_day[MAXORGS][10], error_log[MAXORGS][2000];
int i, j, c, b, d, k, org_amount, stat_amount[2], error_flag, arguments;
int test_flag[10], boz_cross[10], spell_num[MAXSTATS];
int cable_amount, stat_type[2][MAXSTATS], thurs;
int df, org_flag[MAXORGS]; /*if 0 then day, if 1 then fdn*/
int mid, picked, done, corr, bozo, spell_amount;
FILE *cable_file;
/***********************/
/* cable structure */
/***********************/
/* if dayfdn_flag == TRUE then org is fdn */
typedef struct
{
char org[1][11], stat[MAXSTATS][30], raw_stat[MAXSTATS][30];
int tot_stat, dayfdn_flag;
/* next taken out until cookem() is done */
/* int int_amount[MAXSTATS]; */ /* not needed yet*/
/* double fp_amount[MAXSTATS]; */ /* not needed yet */
} CABLES;
CABLES real_cable[MAXORGS], raw_cable[MAXORGS];
/**************************/
/* PERFORM SYSTEM CALLS */
/**************************/
int callout (cmd)
char *cmd[][40];
{
system (cmd); /* may be used later in updates */
}
/* clear screen */
int clearit ()
{
callout ("home");
wait ();
}
/********************/
/* GET A FILE NAME */
/********************/
int infile ()
{
printf ("\nPLEASE CHOOSE A FILENAME--> ");
scanf ("%s", file_name[1]);
++arguments;
return (0);
}
/**************/
/* CHECK USER */ /* this for later, already being done in sh script */
/**************/
int cuser (name)
char name[1][40];
{
char error[1][28];
FILE *log_file;
/* if root then dont bother logging it */
strcpy (error, func_small);
if ( (getuid ()) == 0 )
return (0);
/* if an error then log it to program.log file */
if ( error_flag == TRUE )
{
log_file = fopen ( lspot, "a" );
fprintf (log_file,"%s\n%s\n %s %s %s %s/%s\n",
header, date_v, error, user,
option, cwd, name);
fclose (log_file);
}
/* always log it to telex log file */
log_file = fopen ( l2spot, "a" );
fprintf (log_file,"%s\n%s\n %s %s %s %s/%s\n",
header, date_v, error, user,
option, cwd, name);
fclose (log_file);
return (0);
}
/***************************************************/
/* VERIFY THAT THE FILE EXIST AND CAN BE OPENED */
/***************************************************/
int checkfile (poter, message)
char *message[1][30];
FILE *poter;
{
if ( poter == (FILE *) NULL )
{
printf ("\n\n%c", bell);
printf (" ****** YOU DO NOT HAVE A");
printf (" %s FILE AVAILABLE ******", message);
printf ("\n\n");
exit (1);
}
}
/*********************/
/* FILE COPY MODULE */
/*********************/
int copyfile (orig_file, target_file)
char orig_file[1][40], target_file[1][40];
{
FILE *end_f, *copy_f;
end_f = fopen (target_file, "a");
fprintf (end_f, "\n");
copy_f = fopen (orig_file, "r");
while ( (c = getc (copy_f)) != EOF )
putc (c, end_f);
fclose (copy_f);
fclose (end_f);
return (0);
}
/****************************************/
/* LOAD ORG NAMES FROM CABLE.ORGS FILE */
/****************************************/
int name (namecable, cable_name)
char cable_name[1][40];
CABLES namecable[1];
{
/* The names of the orgs comes from the file: /usr/stats/cable.orgs
* and has the names of the orgs to search, one on each line
* and in alphabetical order (very important), and have either a
* 0 (zero) or a 1 (one) before the name. 0 = day org 1 = fdn org
* example:
0AA
0ATL
0ATLANTA
0BSND
1BSNF
0BUFF
* thats all that needs to be done more than 1 version of the orgs name
* can appear but must be alphabetical to the other name. the limit is
* set by MAXORGS in the define above.
*/
FILE *org_file;
org_file = fopen (cable_name, "r");
checkfile (org_file, temp[0]);
j = 0;
do
{
org_flag[j] = (getc (org_file)) - 48;
fscanf (org_file, "%s", namecable[0].org[j]);
++j;
}
while (( (c = getc (org_file)) != EOF ) && (j < MAXORGS) );
fclose (org_file);
org_amount = --j;
}
/*******************************/
/* MANUALLY TAKE IN NO REPORTS */
/*******************************/
int manover (no_report, org)
char *no_report[1][30], org[1][11];
{
if (test_flag[4] == TRUE )
{
if ( ((c = strcmp ("ORGEUS", temp[4])) == 0) ||
((c = strcmp ("DAY", temp[4])) == 0) )
return (0);
clearit ();
printf ("\n\n%c%c", bell, bell);
printf ("A TYPO OR NO REPORT HAS BEEN DETECTED. YOU MAY ENTER ");
printf ("THE STAT OR HIT\nRETURN TO LOG IT AS A NO REPORT.");
printf ("\n\nTHIS IS THE ORG: %-15s", org);
printf ("\n\nTHIS IS THE STAT: %-15s", temp[4]);
scanf ( "%s", no_report);
}
return (0);
}
/**********************************/
/* RIP OUT TABS, CONTR, FUNC KEYS */
/**********************************/
int rip (rip_string, rip_char)
char rip_string[1][30], rip_char[1][4];
{
strcpy (temp[2], ""); /* resets variable */
j = 0;
do
{
sprintf (temp[5], "%c", rip_string[0][j]);
if ((c = strcmp (rip_char, temp[5])) != 0)
strcat (temp[2], temp[5]);
++j;
}
while ( (c = strcmp ( temp[5], "\0")) != FALSE );
}
/******************************/
/* BINARY ORG SEARCH FUNCTION */
/*****************************/
int osearch (org_to_find, amount_there)
char org_to_find[];
int amount_there;
{
int low = 0;
int high = amount_there;
while (low <= high)
{
mid = (low + high) / 2;
c = strcmp (orgnames[mid], org_to_find);
if (c < 0)
low = mid + 1;
else if (c > 0)
high = mid - 1;
else
{
real_cable[i].dayfdn_flag = org_flag[mid];
return (0);
}
}
strcpy (real_cable[i].org, "NR");
return (0); /* not found */
}
/*****************************/
/* READ IN STATS FROM SOURCE */
/*****************************/
int getstats ()
{
int lrwnd, len;
b = 0;
do
{
if (b > 0) /* rewind to compensate for while getc() */
fseek (cable_file, -1, 1);
c = getc (cable_file);
if (c == '/')
{
do
{ /* take in stat name */
c = getc (cable_file);
if (c == EOF)
break;
/* if lower case make it upper case */
sprintf (temp[0], "%c", c);
if (islower(*(temp[0]) ))
sprintf (temp[1], "%c",
toupper(*(temp[0]) ));
else
sprintf (temp[1], "%c", c);
if ( (c != ':') && (c != '\040') &&
(c != '\n') )
strncat (raw_cable[i].stat[b], temp[1]);
}
while ( (c != ':' ) && (c != '*') && (c != '\n') );
fscanf (cable_file, "%s", temp[0]);
len = strlen (temp[0]);
if ((c = strcmp ("ORG", raw_cable[i].stat[b])) == 0)
{
strcpy (real_cable[i].org, temp[0]);
/* when name is known then assign the dayfdn_flag */
osearch (real_cable[i].org, org_amount);
}
/* find if / pres */
sprintf (temp[3], "%c", temp[0][0]);
if (((c = strcmp ("/", temp[3])) == 0) &&
((c = strcmp ("WE", raw_cable[i].stat[b])) != 0) ||
((c = strcmp ("NR", raw_cable[i].raw_stat[b])) == 0) )
{
strcpy (raw_cable[i].raw_stat[b], "NR");
for (lrwnd = 0; lrwnd <= len; ++lrwnd)
fseek (cable_file, -1, 1);
/*log the no report*/
sprintf (temp[0],
"\nON CABLE: %-12s NR CABLE: NO REPORT",
raw_cable[i].stat[b]);
strcat (error_log[i], temp[0]);
}
else
{
/* rips commas */
rip (temp[0], ",");
strcpy (raw_cable[i].raw_stat[b], temp[2]);
/* rips percentages */
rip (raw_cable[i].raw_stat[b], "%");
strcpy (raw_cable[i].raw_stat[b], temp[2]);
/* rips dollar signs */
rip (raw_cable[i].raw_stat[b], "$");
strcpy (raw_cable[i].raw_stat[b], temp[2]);
/* check for credit marks ( <1200> ) and change to negative ( -1200 ) */
sprintf (temp[0], "%c",
raw_cable[i].raw_stat[b][0]);
if ((c = strcmp ("<", temp[0])) == 0)
{
/* rips < */
rip (raw_cable[i].raw_stat[b], "<");
strcpy (raw_cable[i].raw_stat[b], temp[2]);
/* rips > */
rip (raw_cable[i].raw_stat[b], ">");
/* puts - on */
sprintf (raw_cable[i].raw_stat[b],
"-%s", temp[2]);
}
}
do
{
c = getc (cable_file);
if (c == EOF)
break;
}
while (c != '/');
++b;
}
}
while ( (c != EOF) && (b < MAXSTATS) &&
((c = strcmp ("*", raw_cable[i].stat[b - 1])) != 0) &&
((c = strcmp ("COND", raw_cable[i].stat[b - 1])) != 0) &&
((c = strcmp ("COND.", raw_cable[i].stat[b - 1])) != 0) );
/* set up how many stats for this cable */
raw_cable[i].tot_stat = b;
return (0);
}
/**************************/
/* BINARY SEARCH FUNCTION */
/**************************/
int bsearch (stat_to_find, amount_there)
char stat_to_find[];
int amount_there;
{
int low = 0;
int high = amount_there;
while (low <= high)
{
mid = (low + high) / 2;
c = strcmp (raw_cable[i].stat[mid], stat_to_find);
if (c < 0)
low = mid + 1;
else if (c > 0)
high = mid - 1;
else
{
strcpy (real_cable[i].raw_stat[b],
raw_cable[i].raw_stat[mid]);
picked = TRUE;
return (0);
}
}
if ((c = strcmp ("FDN", real_cable[i].raw_stat[b])) != 0)
strcpy (real_cable[i].raw_stat[b], "NR");
else
picked = TRUE;
return (0); /* not found */
}
/******************************************/
/* A QUICK HANDLING FOR: AND <> IN STATS */
/* FOR ERIKS FILES AND MAYBE MINE */
/******************************************/
int erikfile ()
{
int len;
if (test_flag[5] == TRUE) /* needs to route to a conversion for specs */
{
if (stat_type[0][b] == 2) /* special handling needed */
{
int dot;
done = FALSE;
dot = FALSE;
strcpy (temp[1], "");
strcpy (temp[2], "");
strcpy (temp[3], "");
strcpy (temp[4], "");
if ( ((c = strcmp ( "WDAH", real_cable[i].stat[b])) == 0) ||
((c = strcmp ( "WDAHWO", real_cable[i].stat[b])) == 0) ||
((c = strcmp ( "WDAHP", real_cable[i].stat[b])) == 0) ||
((c = strcmp ( "STFWDAHS", real_cable[i].stat[b])) == 0) )
{
if ((c = strcmp ( "NR", real_cable[i].raw_stat[b])) == 0)
return (0);
len = strlen (real_cable[i].raw_stat[b]);
strcpy (temp[0], real_cable[i].raw_stat[b]);
for (d = 0; d < len; ++d)
{
sprintf (temp[1], "%c", temp[0][d]);
if ( ((c = strcmp (":", temp[1])) != 0) &&
(done != TRUE) )
{
if ( ((c = strcmp (".", temp[1]))
!= 0) && (dot != TRUE) )
dot = FALSE;
else
dot = TRUE;
strcat (temp[2], temp[1]);
}
else
{
dot = TRUE;
done = TRUE;
if ((c = strcmp (":", temp[1])) != 0)
strcat (temp[3], temp[1]);
}
}
strcat (temp[3], "0"); /* makes 100/6 stead of 10/6 */
c = atoi (temp[3]);
d = (c / 6);
if (dot == FALSE)
strcat (temp[2], ".00");
if (done != TRUE)
strcpy (real_cable[i].raw_stat[b], temp[2]);
else
sprintf (real_cable[i].raw_stat[b], "%s.%.2d",
temp[2], d);
}
if ((c = strcmp ( "APRATIO", real_cable[i].stat[b])) == 0)
{
if ((c = strcmp ( "NR", real_cable[i].raw_stat[b])) == 0)
return (0);
len = strlen (real_cable[i].raw_stat[b]);
strcpy (temp[0], real_cable[i].raw_stat[b]);
for (d = 0; d < len; ++d)
{
sprintf (temp[1], "%c", temp[0][d]);
if ( ((c = strcmp (":", temp[1])) != 0)/* ||
((c = strcmp ("O", temp[1])) != 0) ||
((c = strcmp ("o", temp[1])) != 0)*/ &&
(done != TRUE) )
strcpy (temp[3], ""); /* continue on */
else
{
done = TRUE;
if ((c = strcmp (":", temp[1])) != 0)
strcat (temp[3], temp[1]);
}
}
strcpy (real_cable[i].raw_stat[b], temp[3]);
if ( ((c = strcmp ("", temp[3])) == 0) && (done == 0) )
strcpy (real_cable[i].raw_stat[b], temp[0]);
}
if ( ((c = strcmp ( "OPEQ", real_cable[i].stat[b])) == 0) ||
((c = strcmp ( "PCTBILLSPD", real_cable[i].stat[b])) == 0) )
{
if ( ((c = strcmp ( "NR", real_cable[i].raw_stat[b])) == 0) ||
((c = strcmp ("FDN", real_cable[i].raw_stat[b])) == 0) )
return (0);
dot = 0;
len = strlen (real_cable[i].raw_stat[b]);
strcpy (temp[0], real_cable[i].raw_stat[b]);
for (d = 0; d < len; ++d)
{
sprintf (temp[1], "%c", temp[0][d]);
if ((c = strcmp (".", temp[1])) == 0)
{
dot = d - 2;
--len;
break;
}
}
if (dot == -1)
strcat (temp[3], ".0");
rip (temp[0], ".");
for (k = 0; k < len; ++k)
{
if (k == dot)
strcat (temp[3], ".");
sprintf (temp[4], "%c", temp[2][k]);
strcat (temp[3], temp[4]);
}
strcpy (real_cable[i].raw_stat[b], temp[3]);
}
}
}
return (0);
}
/******************************/
/* VERIFY AS MUCH AS POSSIBLE */
/******************************/
int verify ()
{
done = 0;
picked = 0;
corr = 0;
if (df == TRUE) /* DAY ORG STATS ONLY */
if ( ((c = strcmp ("CASH", stat_kind[0][b])) == 0) ||
((c = strcmp ("BILLS", stat_kind[0][b])) == 0) ||
((c = strcmp ("INTORGBLL", stat_kind[0][b])) == 0) ||
((c = strcmp ("HCOCASH", stat_kind[0][b])) == 0) ||
((c = strcmp ("HCOBILLS", stat_kind[0][b])) == 0) ||
((c = strcmp ("BILLSPD", stat_kind[0][b])) == 0) ||
((c = strcmp ("AUDPTS", stat_kind[0][b])) == 0) ||
((c = strcmp ("ASSETRES", stat_kind[0][b])) == 0) ||
((c = strcmp ("PCTBILLSPD", stat_kind[0][b])) == 0) ||
((c = strcmp ("DATELINE", stat_kind[0][b])) == 0) ||
((c = strcmp ("AUDDATE", stat_kind[0][b])) == 0) )
strcpy (real_cable[i].raw_stat[b], "FDN");
strcpy (real_cable[i].stat[b], stat_kind[0][b]);
bsearch (real_cable[i].stat[b], raw_cable[i].tot_stat);
/***********************************/
/* CHECKS SOME DIFFERENT SPELLINGS */
/***********************************/
if (b == 0)
printf ("\n\n CHECKING: SPELLING");
if (picked != TRUE)
{
for (j = 0; (j < spell_amount) && (picked != TRUE); ++j)
if ((c = strcmp (spell[0][j], real_cable[i].stat[b])) == 0)
for (d = 1; (d < spell_num[j]) && (picked != TRUE); ++d)
bsearch (spell[d][j], raw_cable[i].tot_stat);
corr = TRUE;
}
/* if still no report manual override */
if ((c = strcmp ("NR", real_cable[i].raw_stat[b])) == 0)
{
if ( ((c = strcmp ("ORGEUS", real_cable[i].stat[b])) != 0 ) &&
((c = strcmp ("DAY", real_cable[i].stat[b])) != 0 ) &&
((c = strcmp ("FDN", real_cable[i].stat[b])) != 0) )
{
strcpy (temp[4], real_cable[i].stat[b]);
manover (real_cable[i].raw_stat[b], real_cable[i].org);
/*log it if still no report*/
if ( ((c = strcmp ("NR",
real_cable[i].raw_stat[b])) == 0) &&
((c = strcmp (real_cable[i].stat[b],
raw_cable[i].stat[mid])) != 0) )
{
/* finds raw_stat[mid] if no report */
sprintf (temp[0], "\nNAME N/F: %-12s NR",
real_cable[i].stat[b]);
strcat (error_log[i], temp[0]);
}
}
}
else
{
/*log the typo report*/
if (corr == TRUE)
{
sprintf (temp[0],
"\nNAME TPO: %-12s TYPO: %-12s CORR. TO: %s",
real_cable[i].stat[b],
raw_cable[i].stat[mid], real_cable[i].raw_stat[b] );
strcat (error_log[i], temp[0]);
}
}
return (0);
}
/*****************************/
/* COOK AMOUNTS INTO TYPES */
/*****************************/
int cookem ()
{
/* until working */
return (0);
/*********************************THIS TAKEN OUT TILL NEEDED LATER
j = 0;
for (b = 0; b < stat_amount[df]; ++b)
{
if (stat_type[df][b] == FALSE)
{
if ((c = strcmp ("NR", real_cable[i].raw_stat[b])) == 0)
real_cable[i].int_amount[j] = 0;
else
real_cable[i].int_amount[j] = atoi (real_cable[i].raw_stat[b]);
printf ("\n%-13d int stat,", real_cable[i].int_amount[j]);
}
if (stat_type[df][b] == TRUE)
{
if ((c = strcmp ("NR", real_cable[i].raw_stat[b])) == 0)
strcpy (real_cable[i].raw_stat[j], "0") ;
else
real_cable[i].fp_amount[j] = atof (real_cable[i].raw_stat[b]);
printf ("\n%-13f float amount %-13s name, %d j,",
real_cable[i].fp_amount[b], real_cable[i].stat[b],j);
++j;
}
if (type_stat[df][b] == 2 );
if (type_stat[df][b] == 3 );
++j;
}
return (0);
*********************************TAKEN OUT TO HERE***************/
}
/*****************/
/* BOZO CHECKING */
/*****************/
int bozocheck ()
{
int low_stat, mid_stat, high_stat;
bozo = 0;
if (b == 0)
printf ("\n\n CHECKING: BOZOS");
if ((c = strcmp ("PHS", real_cable[i].stat[b])) == 0)
{
low_stat = atoi (real_cable[i].raw_stat[b]);
high_stat = atoi (real_cable[i].raw_stat[boz_cross[0]]);
if (high_stat < low_stat)
{
sprintf (temp[1], "%s:", real_cable[i].stat[b]);
sprintf (temp[2], "%s IS GREATER THAN",
real_cable[i].raw_stat[b]);
sprintf (temp[3], "%s:", real_cable[i].stat[boz_cross[0]]);
strcpy (temp[4], real_cable[i].raw_stat[boz_cross[0]]);
bozo = TRUE;
}
}
if ((c = strcmp ("DIV3COLL", real_cable[i].stat[b])) == 0)
{
low_stat = atoi (real_cable[i].raw_stat[b]);
high_stat = atoi (real_cable[i].raw_stat[boz_cross[1]]);
if ( high_stat < low_stat )
{
sprintf (temp[1], "%s:", real_cable[i].stat[boz_cross[1]]);
sprintf (temp[2], "%s IS LESS THAN",
real_cable[i].raw_stat[boz_cross[1]]);
sprintf (temp[3], "%s:", real_cable[i].stat[b]);
strcpy (temp[4], real_cable[i].raw_stat[b]);
bozo = TRUE;
}
}
/* taken out again until adding correctly */
/*
if (( c = strcmp ("WDAHP", real_cable[i].stat[b])) == 0)
{
rip (real_cable[i].raw_stat[boz_cross[2]], ".");
high_stat = atoi (temp[2]);
rip (real_cable[i].raw_stat[boz_cross[3]], ".");
mid_stat = atoi (temp[2]);
rip (real_cable[i].raw_stat[b], ".");
low_stat = atoi (temp[2]);
mid_stat += low_stat;
if (mid_stat != high_stat)
{
sprintf (temp[1], "%s:", real_cable[i].stat[boz_cross[2]]);
sprintf (temp[2], "%s NOT EQUAL TO",
real_cable[i].raw_stat[boz_cross[2]]);
sprintf (temp[3], "%s: %s + %s: %s",
real_cable[i].stat[boz_cross[3]],
real_cable[i].raw_stat[boz_cross[3]],
real_cable[i].stat[b],
real_cable[i].raw_stat[b]);
sprintf (temp[4], "");
bozo = TRUE;
}
}
*/
if ((c = strcmp ("SPCC", real_cable[i].stat[b])) == 0)
{
low_stat = atoi (real_cable[i].raw_stat[b]);
high_stat = atoi (real_cable[i].raw_stat[boz_cross[4]]);
if ( high_stat < low_stat )
{
sprintf (temp[1], "%s:", real_cable[i].stat[boz_cross[4]]);
sprintf (temp[2], "%s IS LESS THAN",
real_cable[i].raw_stat[boz_cross[4]]);
sprintf (temp[3], "%s:", real_cable[i].stat[b]);
strcpy (temp[4], real_cable[i].raw_stat[b]);
bozo = TRUE;
}
}
if ((c = strcmp ("FIRSTSTARTS", real_cable[i].stat[b])) == 0)
{
low_stat = atoi (real_cable[i].raw_stat[b]);
high_stat = atoi (real_cable[i].raw_stat[boz_cross[5]]);
if ( high_stat < low_stat )
{
sprintf (temp[1], "%s:", real_cable[i].stat[boz_cross[5]]);
sprintf (temp[2], "%s IS LESS THAN",
real_cable[i].raw_stat[boz_cross[5]]);
sprintf (temp[3], "%s:", real_cable[i].stat[b]);
strcpy (temp[4], real_cable[i].raw_stat[b]);
bozo = TRUE;
}
}
if ((c = strcmp ("NFSMC", real_cable[i].stat[b])) == 0)
{
low_stat = atoi (real_cable[i].raw_stat[b]);
high_stat = atoi (real_cable[i].raw_stat[boz_cross[6]]);
if ( high_stat < low_stat )
{
sprintf (temp[1], "%s: %s IS LESS THAN",
real_cable[i].stat[boz_cross[6]],
real_cable[i].raw_stat[boz_cross[6]]);
sprintf (temp[2], "%s: %s",
real_cable[i].stat[b],
real_cable[i].raw_stat[b]);
/* swap fsmc and nfsmc to correct the poss. error */
strcpy (temp[3], real_cable[i].raw_stat[b]);
strcpy (real_cable[i].raw_stat[b],
real_cable[i].raw_stat[boz_cross[6]]);
strcpy (real_cable[i].raw_stat[boz_cross[6]], temp[3]);
sprintf (temp[3], "\nASSUMED CORRECTION MADE=> %s:",
real_cable[i].stat[boz_cross[6]]);
sprintf (temp[4], "%s <-*AND*-> %s: %s",
real_cable[i].raw_stat[boz_cross[6]],
real_cable[i].stat[b],
real_cable[i].raw_stat[b]);
bozo = TRUE;
}
}
if ((c = strcmp ("CGI", real_cable[i].stat[b])) == 0)
{
high_stat = atoi (real_cable[i].raw_stat[b]);
if ( high_stat < 0 )
{
sprintf (temp[1], "%s:", real_cable[i].stat[b]);
sprintf (temp[2], "%s IS LESS THAN 0",
real_cable[i].raw_stat[b]);
strcpy (temp[3], "");
strcpy (temp[4], "");
bozo = TRUE;
}
}
if ((c = strcmp ("WE", real_cable[i].stat[b])) == 0)
{
low_stat = thurs;
sprintf (temp[1], "%.2s", real_cable[i].raw_stat[b]);
rip (temp[1], ".");
strcpy (temp[1], temp[2]);
rip (temp[1], "/");
strcpy (real_day[i], temp[2]);
mid_stat = atoi (temp[2]);
if ( low_stat != mid_stat )
{
sprintf (temp[1], "%s:", real_cable[i].stat[b]);
sprintf (temp[2], "%s NOT THIS W/ENDING:",
real_cable[i].raw_stat[b]);
strcpy (temp[3], we_date);
strcpy (temp[4], "");
bozo = TRUE;
}
}
if ((c = strcmp ("FNVGIS", real_cable[i].stat[b])) == 0)
{
high_stat = atoi (real_cable[i].raw_stat[b]);
if ( high_stat < 100 )
{
sprintf (temp[1], "%s:", real_cable[i].stat[b]);
sprintf (temp[2], "%s IS LESS THAN",
real_cable[i].raw_stat[b]);
strcpy (temp[3], "100");
strcpy (temp[4], "");
bozo = TRUE;
}
}
if ( ((c = strcmp ("APRATIO", real_cable[i].stat[b])) == 0) &&
((strlen (real_cable[i].raw_stat[b])) == TRUE) )
{
high_stat = atoi (real_cable[i].raw_stat[b]);
if (high_stat == TRUE )
{
sprintf (temp[1], "%s:", real_cable[i].stat[b]);
sprintf (temp[2], "%s EQUAL TO",
real_cable[i].raw_stat[b]);
strcpy (temp[3], "1");
strcpy (temp[4], " CABLE: POSSIBLY ENTERED WRONG");
bozo = TRUE;
}
}
if ( ((c = strcmp ("WDAH", real_cable[i].stat[b])) == 0) ||
((c = strcmp ("WDAHWO", real_cable[i].stat[b])) == 0) )
{
high_stat = atoi (real_cable[i].raw_stat[b]);
if ( (high_stat > 100) &&
((c = strcmp ("MM", real_cable[i].org)) != 0) )
{
sprintf (temp[1], "%s:", real_cable[i].stat[b]);
sprintf (temp[2], "%s IS GREATER THAN",
real_cable[i].raw_stat[b]);
strcpy (temp[3], "100");
strcpy (temp[4], "");
bozo = TRUE;
}
}
if ((c = strcmp ("STFWDAHS", real_cable[i].stat[b])) == 0)
{
low_stat = atoi (real_cable[i].raw_stat[b]);
if ( low_stat > 40 )
{
sprintf (temp[1], "%s:", real_cable[i].stat[b]);
sprintf (temp[2], "%s IS GREATER THAN",
real_cable[i].raw_stat[b]);
strcpy (temp[3], "40");
strcpy (temp[4], "");
bozo = TRUE;
}
}
if ((c = strcmp ("SECUREHRS", real_cable[i].stat[b])) == 0)
{
high_stat = atoi (real_cable[i].raw_stat[b]);
if ( high_stat < 24 )
{
sprintf (temp[1], "%s:", real_cable[i].stat[b]);
sprintf (temp[2], "%s IS LESS THAN",
real_cable[i].raw_stat[b]);
strcpy (temp[3], "24");
strcpy (temp[4], "");
bozo = TRUE;
}
}
/* check promo out and promo ratio
* if promo out is like 0.09, the check is to see if
* promo out has three conditions:
* promo out is not a zero AND
* promo out has a zero and a decimal point on left OR
* promo out has only a decimal point on left
* if these are TRUE then swap and log.
*/
if ((c = strcmp ("PRMORATIO", real_cable[i].stat[b])) == 0)
{
rip (real_cable[i].raw_stat[boz_cross[7]], ".");
low_stat = atoi (temp[2]); /* for whether zero or not check */
sprintf (temp[0], "%c",
real_cable[i].raw_stat[boz_cross[7]][0]);
if ( (low_stat > 0) &&
( ((c = strcmp ("0", temp[0])) == 0) ||
((c = strcmp (".", temp[0])) == 0) ) )
{
sprintf (temp[1], "%s: %s IS LESS THAN",
real_cable[i].stat[boz_cross[7]],
real_cable[i].raw_stat[boz_cross[7]]);
sprintf (temp[2], "%s: %s",
real_cable[i].stat[b],
real_cable[i].raw_stat[b]);
/* swap prmout and prmoratio to correct the poss. error */
strcpy (temp[3], real_cable[i].raw_stat[b]);
strcpy (real_cable[i].raw_stat[b],
real_cable[i].raw_stat[boz_cross[7]]);
strcpy (real_cable[i].raw_stat[boz_cross[7]], temp[3]);
sprintf (temp[3], "\nASSUMED CORRECTION MADE=> %s:",
real_cable[i].stat[boz_cross[7]]);
sprintf (temp[4], "%s <-*AND*-> %s: %s",
real_cable[i].raw_stat[boz_cross[7]],
real_cable[i].stat[b],
real_cable[i].raw_stat[b]);
bozo = TRUE;
}
}
/* put quotes on sig and cond */
if ( ((c = strcmp ("SIG", real_cable[i].stat[b])) == 0) ||
((c = strcmp ("COND", real_cable[i].stat[b])) == 0))
{
sprintf (temp[0], "\"%s\"", real_cable[i].raw_stat[b]);
strcpy (real_cable[i].raw_stat[b], temp[0]);
}
if ( ((c = strcmp ("VALRR", real_cable[i].stat[b])) == 0) ||
((c = strcmp ("CVB", real_cable[i].stat[b])) == 0) )
{
low_stat = atoi (real_cable[i].raw_stat[b]);
if ( low_stat >= TRUE )
{
sprintf (temp[1], "%s:", real_cable[i].stat[b]);
sprintf (temp[2], "%s IS GREATER THAN OR EQUAL TO",
real_cable[i].raw_stat[b]);
strcpy (temp[3], "1");
strcpy (temp[4], "");
bozo = TRUE;
}
}
/*log the bozo report*/
if (bozo == TRUE)
if ((c = strcmp ("FDN", real_cable[i].raw_stat[b])) != 0)
{
sprintf (temp[0],
"\nSTAT BZO: POSSIBLE BOZO-> %s %s %s %s",
temp[1],
temp[2], temp[3],
temp[4]);
strcat (error_log[i], temp[0]);
}
}
/**************/
/* MAIN () */
/**************/
main (argc, argv)
char *argv[];
int argc;
{
char *tlx_num[26], month[1][26];
int len, start_file = TRUE, tnum = 6, file_nmbr = 0;
FILE *final_file;
clearit();
sprintf (temp[0],
"echo -n \"\n\n\n SETTING UP \"");
callout (temp[0]);
/** Get time of day **/
{
/* Get system time */
struct tm *date;
char * ctime();
long clock;
int flip1, check_day, month_num, year;
/* Get system time */
time (&clock);
/* Pass system time to converter */
date = localtime(&clock);
/* compensate and make it thursdays date if not thursday */
if ( date->tm_wday >= 4 )
flip1 = date->tm_wday - 4;
else
flip1 = 3 + date->tm_wday;
check_day = (date->tm_mday - (flip1)); /* subtracts from day*/
month_num = date->tm_mon;
year = date->tm_year;
/* if thursday is near the end of the month then adjust appropriat */
if ( check_day > 0 )
{
thurs = check_day;
++month_num; /* now increment to make proper month */
}
else
{ /* dont ++month cuz it is last mnth*/
if ( month_num == 2 )
{
if ( (year % 4) == FALSE )
thurs = 29 + check_day;
else
thurs = 28 + check_day;
}
else
{
if ( (month_num == 4) || (month_num == 6) ||
(month_num == 9) || (month_num == 11) )
thurs = 30 + check_day;
else
thurs = 31 + check_day;
if ( month_num == FALSE )
{
--year;
month_num = 12;
}
}
}
/* make w/e date for w/e: in telex */
sprintf (date_v, "%d/%d/%d", thurs, month_num, year);
/* if there is only one digit for day or month add a 0 in front */
if ( thurs < 10 )
sprintf (temp[0], "0%d", thurs );
else
sprintf (temp[0], "%d", thurs );
if ( month_num < 10 )
sprintf (temp[1], "0%d", month_num);
else
sprintf (temp[1], "%d", month_num);
/* make telex number */
sprintf (tlx_num, "%s%s%d", temp[0], temp[1], tnum );
/* alphatize the month_num */
sprintf ( temp[1], "JAN");
sprintf ( temp[2], "FEB");
sprintf ( temp[3], "MAR");
sprintf ( temp[4], "APR");
sprintf ( temp[5], "MAY");
sprintf ( temp[6], "JUNE");
sprintf ( temp[7], "JULY");
sprintf ( temp[8], "AUG");
sprintf ( temp[9], "SEPT");
sprintf ( temp[10], "OCT");
sprintf ( temp[11], "NOV");
sprintf ( temp[12], "DEC");
for ( i = 0; i < 13; ++i)
if ( i == month_num )
strcpy (month, temp[i]);
sprintf (we_date, "%d %s %d", thurs, month, year);
/* messages */
if ( (month_num == 5) && (thurs == 9))
{
clearit();
printf ("\n\n\n%c%c",bell, bell);
printf ("\n\n HAPPY DIANETICS ANIVERSARY DAY!!");
sleep (5);
}
if ( (month_num == 3) && (thurs == 13))
{
clearit();
printf ("\n\n\n%c%c",bell, bell);
printf ("\n\n HAPPY BIRTHDAY L. RON HUBBARD!!");
sleep (5);
}
}
/* SET UP OF ORIG VARIABLES */
test_flag[0] = FALSE; /* print orgs and stats straightened */
test_flag[1] = FALSE; /* testing with 1 3 5 on */
test_flag[2] = FALSE; /* print verified real cable */
test_flag[3] = FALSE; /* print error log info */
test_flag[4] = FALSE; /* print + do manover (); */
test_flag[5] = FALSE; /* this will write to eriks files only */
test_flag[6] = FALSE; /* doscp file to disk */
for ( i = 0; i < 23; ++i )
strcat ( header, "-" );
strcpy (lspot, "/usr/adm/program.log"); /* for cuser later */
strcpy (l2spot, "/usr/adm/tlx.log");
strcpy (user, getlogin ());
strcpy (func, "EVOL");
strcpy (func_small, "evol");
getcwd (cwd, 40);
arguments = argc;
if ( arguments < 2 ) /* if no file name then get one */
infile ();
else
{
strcpy (option, argv[1] );
if ( ((c = strcmp ( "-0", option )) == 0 ) ||
((c = strcmp ( "-06", option )) == 0 ) ||
((c = strcmp ( "-1", option )) == 0 ) ||
((c = strcmp ( "-2", option )) == 0 ) ||
((c = strcmp ( "-3", option )) == 0 ) ||
((c = strcmp ( "-35", option )) == 0 ) ||
((c = strcmp ( "-356", option )) == 0 ) ||
((c = strcmp ( "-4", option )) == 0 ) ||
((c = strcmp ( "-45", option )) == 0 ) ||
((c = strcmp ( "-456", option )) == 0 ) ||
((c = strcmp ( "-5", option )) == 0 ) )
++start_file;
for ( i = start_file; i < arguments; ++i )
strcpy (file_name[i], argv[i] );
}
if ((c = strcmp ("-0", option)) == 0 )
test_flag[0] = TRUE; /* straighten out cable + print it */
if ((c = strcmp ("-06", option)) == 0)
{
test_flag[0] = TRUE; /* straighten out cable + print it */
test_flag[6] = TRUE; /* read from disk */
}
if ((c = strcmp ("-1", option)) == 0 )
{
test_flag[1] = FALSE; /* turns off printer for tests*/
test_flag[3] = TRUE;
test_flag[5] = TRUE;
}
if ((c = strcmp ("-2", option)) == 0 )
test_flag[2] = TRUE;
if ((c = strcmp ("-3", option)) == 0 )
{
test_flag[1] = TRUE; /* turns on printer */
test_flag[3] = TRUE;
}
if ((c = strcmp ("-35", option)) == 0 )
{
test_flag[1] = TRUE; /* turns on printer */
test_flag[3] = TRUE; /* no reports and files on */
test_flag[5] = TRUE;
}
if ((c = strcmp ("-356", option)) == 0 )
{
test_flag[1] = TRUE; /* turns on printer */
test_flag[3] = TRUE; /* no reports and files on */
test_flag[5] = TRUE;
test_flag[6] = TRUE;
}
if ((c = strcmp ("-4", option)) == 0 )
test_flag[4] = TRUE;
if ((c = strcmp ("-45", option)) == 0 )
{
test_flag[4] = TRUE;
test_flag[5] = TRUE;
}
if ((c = strcmp ("-456", option)) == 0 )
{
test_flag[4] = TRUE; /* no reports and files on */
test_flag[5] = TRUE;
test_flag[6] = TRUE;
}
if ((c = strcmp ("-5", option)) == 0 )
test_flag[5] = TRUE;
/***************************/
/* SET UP SPELL CHECK STATS*/
/***************************/
/* the spell checks come from the file /usr/stats/cable.spell and
* in that file are aranged with the number of different spellings
* to check for on one line and then the correct spelled stat name
* directly under that and then the different spellings to check for
*
* example:
3
PDCWO
PDCW/O
PDCW0
PCDWO
2
STFWDAHS
STAFFWDAHS
STFWDAH
1
QSHWO
QSHW/O
* thats all there is to it. to add more different spellings to the
* check just change the number and add the check in below the
* correct spelling of the stat as usual **note that the number
* is always 1 less than the amount of words under it to the next #
* the limit of different spellings is set by MAXSPELL in the define
* above at the top.
*/
cable_file = fopen ("/usr/stats/cable.spell", "r");
checkfile (cable_file, "/usr/stats/cable.spell");
j = 0;
do
{
spell_num[j] = (getc (cable_file) - 47);
for (i = 0; i < spell_num[j]; ++i)
fscanf (cable_file, "%s", spell[i][j]);
++j;
}
while ( (c = getc (cable_file) != EOF) && (j < MAXSTATS) );
fclose (cable_file);
spell_amount = j - 1;
/***************************/
/* SET UP REAL CABLE STATS */
/***************************/
/* SET UP THE REAL VALUES OF ORG NAMES AND CABLE NAMES */
name (orgnames, "/usr/stats/cable.orgs"); /*name day */
strcpy (temp[0], "/usr/stats/cable.day");
strcpy (temp[1], "/usr/stats/cable.fdn");
for (i = 0; i < 2; ++i) /* 0 = day, 1 = fdn later df's */
{
FILE *org_file;
org_file = fopen (temp[i], "r");
checkfile (org_file, temp[i]);
j = 0;
do
{
/* the real stats come from the file: /usr/stats/cable.day or
* /usr/stats/cable.fdn
* and have a letter before the name:
* i = integer f = floating point s = special handling l = letters
* these must be put before the stat name but are not necessarily used
* at this time until cookem () has been finished.
* example:
lORG
lWE
iPDC
iPDCWO
fCVB
fGI
sWDAH
sWDAHWO
* something like that and must be in the order that you want the
* cable to appear when done. the limit on stats is set by MAXSTATS
* in the define above at the top of the cable.
*/
/* set stat type int is i = 105 and is set to 0
* float is f = 102 and is set to 1
* dstat_type specs is s = 115 and is set to 2
* fstat_type letts is l = 108 and is set to 3
*/
c = getc (org_file);
if ( c == 105 )
k = 0;
if ( c == 102 )
k = 1;
if ( c == 115 )
k = 2;
if ( c == 108 )
k = 3;
stat_type[i][j] = k;
fscanf (org_file, "%s", stat_kind[i][j]);
/* for bozo checks later these numbers are set for
* these stats to cross check on in bozo check.
* boz_cross[0] == FHS
* boz_cross[1] == GI
* boz_cross[2] == WDAH
* boz_cross[3] == WDAHWO
* boz_cross[4] == PCC
* boz_cross[5] == PRPS
* boz_cross[6] == FSMC
* boz_cross[7] == PRMOUT
* boz_cross[8] ==
* boz_cross[9] ==
*/
if (i == 0) /*day stats only now until later */
{
if ((c = strcmp ("FHS", stat_kind[i][j])) == 0)
boz_cross[0] = j;
if ((c = strcmp ("GI", stat_kind[i][j])) == 0)
boz_cross[1] = j;
if ((c = strcmp ("WDAH", stat_kind[i][j])) == 0)
boz_cross[2] = j;
if ((c = strcmp ("WDAHWO", stat_kind[i][j])) == 0)
boz_cross[3] = j;
if ((c = strcmp ("PCC", stat_kind[i][j])) == 0)
boz_cross[4] = j;
if ((c = strcmp ("PRPS", stat_kind[i][j])) == 0)
boz_cross[5] = j;
if ((c = strcmp ("FSMC", stat_kind[i][j])) == 0)
boz_cross[6] = j;
if ((c = strcmp ("PRMOUT", stat_kind[i][j])) == 0)
boz_cross[7] = j;
}
++j; /*increment stat counter now*/
}
while (( (c = getc (org_file)) != EOF ) && (j < 170) );
fclose (org_file);
stat_amount[i] = j - 1;
}
for (file_nmbr = start_file; file_nmbr < arguments; ++file_nmbr)
{
/********************/
/* READ FROM CABLE */
/********************/
clearit ();
sprintf (temp[0],
"echo -n \"\n\n\n READING: %s \"",
file_name[file_nmbr]);
callout (temp[0]);
if (test_flag[6] == TRUE)
{
sprintf (temp[0],
"doscp a:%s %s", file_name[file_nmbr],
file_name[file_nmbr]);
callout (temp[0]);
}
cable_file = (fopen (file_name[file_nmbr], "r"));
checkfile (cable_file, file_name[file_nmbr]);
i = 0;
do /* READ IN STATS FROM CABLES */
{
for (j = start_file; j < arguments; ++j)
getstats ();
++i;
}
while ( ((c = getc(cable_file)) != EOF ) &&
( i < (MAXORGS + start_file) ) );
cable_amount = --i;
clearit ();
sprintf (temp[0],
"echo -n \"\n\n\n SIFTING: %s \"",
file_name[file_nmbr]);
callout (temp[0]);
/************************************/
/* SORT RAW CABLE ALPHA FOR BSEARCH */
/************************************/
for (i = 0; i < cable_amount; ++i)
for (b = 0; b < raw_cable[i].tot_stat - 1; ++b)
for (j = b + 1; j < raw_cable[i].tot_stat; ++j)
if ((c = strcmp (raw_cable[i].stat[b],
raw_cable[i].stat[j])) == TRUE)
{
/* do the name */
strcpy (temp[0], raw_cable[i].stat[b]);
strcpy (raw_cable[i].stat[b],
raw_cable[i].stat[j]);
strcpy (raw_cable[i].stat[j], temp[0]);
/* do the amount */
strcpy (temp[0], raw_cable[i].raw_stat[b]);
strcpy (raw_cable[i].raw_stat[b],
raw_cable[i].raw_stat[j]);
strcpy (raw_cable[i].raw_stat[j], temp[0]);
}
/* VERIFY THE STAT NAMES FIRST */
for (i = 0; i < (cable_amount); ++i)
{
clearit ();
printf (
"\n\n\n VERIFYING: %s ",
real_cable[i].org);
/* 0 temp until df is good */
df = real_cable[i].dayfdn_flag;
for ( b = 0; b < stat_amount[0]; ++b)
{
verify ();
erikfile ();
bozocheck ();
}
len = stat_amount[0];
if (df == TRUE)
len = stat_amount[0] - 11;
if ( raw_cable[i].tot_stat < len)
{
/*log the no report*/
sprintf (temp[0], "\nCABLE SHORT BY %d STAT",
(len - raw_cable[i].tot_stat));
if ( (len - raw_cable[i].tot_stat) > 1 )
strcat (temp[0], "S");
strcat (error_log[i], temp[0]);
}
}
}
if (test_flag[3] == TRUE)
{
final_file = fopen ("lpfile.nr", "w");
for (i = 0; i < cable_amount;++i)
{
/* loging print test but write log mod later */
fprintf (final_file, "\nCABLE ERROR LOG: ");
fprintf (final_file,
"ORG: %s\n---------------------------------",
real_cable[i].org);
if ((c = strcmp ("", error_log[i])) == 0)
fprintf (final_file,
"\n\nNO ERRORS DETECTED, THANK YOU %s\n",
real_cable[i].org);
else
{
fprintf (final_file,
"\nAREA KEY REAL NAME ERROR DETECTED CHANGE MADE OR EXPLANATION");
fprintf (final_file,
"\n---------------------------------");
fprintf (final_file, "%s", error_log[i]);
}
fprintf (final_file,
"\n---------------------------------\n");
if (cable_amount > 1 )
fprintf (final_file, "\f");
}
fclose (final_file);
/* print the lpfile */
if (test_flag[1] == TRUE )
{
if (cable_amount == 0)
{
cable_file = (fopen ("badfile", "r"));
checkfile (cable_file, "FULLY EDITED CABLE");
}
callout ( "lp -s lpfile.nr");
}
}
clearit ();
printf ("\n\n\n COOKING CABLE ");
/**************************************/
/* STRAIGHTEN OUT CABLE AND PRINT IT*/
/**************************************/
if (test_flag[0] == TRUE)
{
for (i = 0; i < cable_amount; ++i)
{
sprintf (temp[0], "fix.%s", real_cable[i].org);
final_file = fopen (temp[0], "w");
for (b = 0; b < stat_amount[0]; ++b)
if ((c = strcmp ("FDN", real_cable[i].raw_stat[b])) != 0)
{
len = strlen (real_cable[i].stat[b]);
fprintf (final_file, "/%s:",
real_cable[i].stat[b]);
for (j = 0; j < (13 - len); ++j)
fprintf (final_file, " ");
fprintf (final_file, "%13s\n",
real_cable[i].raw_stat[b]);
}
fprintf (final_file, "/*\n\n\n\n\n");
fclose (final_file);
/* print the lpfile */
if (cable_amount == 0)
{
cable_file = (fopen ("badfile", "r"));
checkfile (cable_file, "FULLY EDITED CABLE");
}
clearit ();
printf ("\n\n\n PRINTING CABLE ");
sprintf (temp[0], "lp -s fix.%s", real_cable[i].org);
callout (temp[0]);
if (test_flag[6] == TRUE)
for (i = 0; i < cable_amount; ++i)
{
sprintf (temp[0],"doscp fix.%s a:fix.%s",
real_cable[i].org, real_cable[i].org);
callout (temp[0]);
}
}
}
/**************************/
/* WRITES TO ERIKS FILES */
/**************************/
for ( i = 0; i < cable_amount; ++i)
{
sprintf (temp[0], "%s.PRN", real_cable[i].org);
final_file = fopen (temp[0], "w");
fprintf (final_file, "%s\n", real_cable[i].org);
for (b = 0; b < stat_amount[0]; ++b)
if ( b > 1 )
fprintf (final_file, "%s\n", real_cable[i].raw_stat[b]);
fprintf (final_file, "%s", real_day[i]);
fclose (final_file);
}
if (test_flag[6] == TRUE)
for (i = 0; i < cable_amount; ++i)
{
sprintf (temp[0], "doscp %s.PRN a:", real_cable[i].org);
callout (temp[0]);
}
/*************************/
/* SPIT OUT TELEX TO ORG */
/*************************/
if ( test_flag[3] == TRUE )
{
int xnum;
if ( (cable_file = fopen (".tlxnum", "r")) == (FILE *) NULL )
xnum = 0;
else
{
fgets (temp[0], 80, cable_file);
fclose (cable_file);
xnum = atoi (temp[0]);
}
xnum += 10;
clearit ();
if (cable_amount == 1)
printf ("\n\n\n WRITING TELEX");
else
printf ("\n\n\n WRITING TELEXES");
for (i = 0; i < cable_amount;++i)
{
sprintf (temp[0], "tlx.%s", real_cable[i].org);
final_file = fopen (temp[0], "w");
fprintf (final_file,
"\n%s%d CLOEUS", tlx_num, (i + xnum));
if ((c = strcmp ("", error_log[i])) == 0)
fprintf (final_file, " //ACK//");
fprintf (final_file,
"\nSTATS I/C %s\n", real_cable[i].org);
fprintf (final_file,
"INFO: A/DATA AIDE CLO EUS. ED %s, HAS %s.\n",
real_cable[i].org, real_cable[i].org);
fprintf (final_file,
"RE: WEEKLY STAT CABLE W/E: %s\n", we_date);
fprintf (final_file, "DEAR TERMINAL,\n");
if ((c = strcmp ("", error_log[i])) == 0)
fprintf (final_file,
"YOUR CABLE WAS PROCESSED. HERE IS YOUR REPORT.\n");
else
{
fprintf (final_file,
"HERE IS A LIST OF THE COMPUTER ");
fprintf (final_file,
"DETECTED ERRORS THAT WERE PRESENT IN YOUR\n");
fprintf (final_file, "CABLE THIS WEEK. ");
fprintf (final_file,
"SEE THAT THESE OUTPOINTS ARE HANDLED BY NEXT WEEK.\n");
}
fprintf (final_file, "\nCOMPUTER DETECTED ERRORS:\n");
fprintf (final_file, "-------------------------\n");
fprintf (final_file, "\nCABLE ERROR LOG: ");
fprintf (final_file,
"ORG: %s\n---------------------------------",
real_cable[i].org);
if ((c = strcmp ("", error_log[i])) == 0)
fprintf (final_file,
"\n\nNO ERRORS DETECTED, THANK YOU %s!!!\n\n",
real_cable[i].org);
else
{
fprintf (final_file,
"\nAREA KEY REAL NAME ERROR DETECTED CHANGE MADE OR EXPLANATION");
fprintf (final_file,
"\n---------------------------------");
fprintf (final_file, "%s", error_log[i]);
fprintf (final_file,
"\n---------------------------------\n");
fprintf (final_file,
"\nANY POSSIBLE BOZO'S WERE PROBABLY QUERIED AND SHOULD ");
fprintf (final_file,
"JUST BE DOUBLE\nCHECKED.\n");
}
fprintf (final_file,
"ML, STATS INTEGRITY OFF CLO EUS.\n\n\n\n");
fclose (final_file);
if (test_flag[1] == TRUE )
{
sprintf (temp[0], "tlx -n tlx.%s",
real_cable[i].org);
callout (temp[0]);
cable_file = fopen (".tlxnum", "w");
fprintf (cable_file, "%d", ( (xnum + i) - 9));
fclose (cable_file);
}
}
}
exit (0); /* temp until multiple files can be done */
/* cook the amounts into ints, floats, specials, and letters */
/* NOT IN PLACE UNTIL FP_AMOUNT (FLOATING POINT EXCEPTION) IS CORRECTED */
/* NOT NEEDED TO WRITE TO ERIKS FILES FOR NOW UNTIL I WANT TO MAKE A */
/* MASTER CABLE LATER AND NEED TO ADD FP AND INT AMOUNTS. */
/*
for (i = 0; i < (cable_amount); ++i)
{
if ( real_cable[i].dayfdn_flag == FALSE )
{
df = 0;
cookem ();
}
else
{
df = TRUE;
cookem ();
}
}
*/ /* TAKEN OUT TO HERE */
for ( i = 0; i < 40; ++i)
{
sprintf (error_log[i], "");
}
exit (0);
}