home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / inetlg71.zip / IJOYLOG.CMD < prev    next >
OS/2 REXX Batch file  |  2000-02-10  |  25KB  |  754 lines

  1. /*
  2. InJoy log analyzer
  3. ╕ 1998 - 2000 by Charles H McKinnis,  Sandia Park, NM (USA) 04 Feb 2000
  4. mckinnis@attglobal.net
  5.  
  6. REXX Program to extract and totalize monthly time-ons by
  7. analyzing the InJoy dialer log
  8. */
  9. Trace 'N'
  10. version = '7.1'
  11. what_r_we = 'IJOYLOG  v'||version '╕ 1998 - 2000 by Charles H McKinnis'
  12. irc = 0                                        /* ijoylog return code */
  13.  
  14. If Rxfuncquery('SysDropFuncs') Then
  15.    Do
  16.       Call Rxfuncadd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  17.       Call SysLoadFuncs
  18.    End
  19.  
  20. If Rxfuncquery('RxExtra') Then
  21.    Do
  22.       Call Rxfuncadd 'RxExtra', 'RxExtras', 'RxExtra'
  23.       Call RxExtra 'LOAD'
  24.    End
  25.  
  26. /* Where are we ? */
  27. Parse Source . . install_path .
  28. install_path = Filespec('D',install_path) || Filespec('P',install_path)
  29. ini_file = install_path || 'INETLOG.INI'
  30. cfg_file = install_path || 'inetcfg.cfg'
  31. cfg_save = install_path || 'inetcfg.sav'
  32. save_path = Directory()
  33. our_path = Strip(install_path, 'T', '\')
  34. our_path = Directory(our_path)
  35. Parse Upper Arg otherparms
  36.  
  37. If Wordpos('/PMREXX', otherparms) > 0 Then
  38.    pmrexx = 1
  39. Else
  40.    pmrexx = 0
  41.  
  42. Call Initialize_parms
  43.  
  44. If irc = 0 Then
  45.    Call Analyze_logfile   /* gets, calculates, totalizes connect times. 
  46.                                         Mostly a bunch of conditionals with a Call to a
  47.                                         data-formatting routine. All is stored in
  48.                                         variables for output all at once */
  49.  
  50. If irc = 0 Then
  51.    Call Outputter        /* Outputs everything to console and to disk */
  52.  
  53. irc = Cleanup(irc)                                           /* Exits */
  54. Return irc
  55.  
  56. Analyze_logfile:
  57. trace_save = Trace('N')
  58. /* Now find all lines in connect.log that contain the key_phrase
  59.    string.  A typical line generated in the connect.log after
  60.    disconnect is:
  61.      DATE 21.02.1998, START 10:54:25, END 11:33:30, DURATION 39  min, 2345  sec
  62.    which we would parse as follows:
  63.     'DATE' date ','  . 'END' word2 ',' . 'min,' connect_time 'sec' */
  64.  
  65. /* this section will read through the connection log files
  66.    data and assign account information and userid to each
  67.    connection log record */
  68. line. = ''
  69. line.0 = 0
  70. Do m = 1 To Words(injoy_logs)
  71.    log_file = Word(injoy_logs, m)
  72.    injoy_acct = Word(injoy_accts, m)
  73.    injoy_user = Word(injoy_users, m)
  74.    last_time.injoy_acct.injoy_user = Word(injoy_times, m)
  75.  
  76.    lrc = SysFileSearch(key_phrase, log_file, 'temp.')
  77.  
  78.    If lrc <> 0 | temp.0 < 1 Then
  79.       Iterate                        /* the log may have been cleared */
  80.  
  81.    Do i = 1 To temp.0
  82.       j = line.0 + 1
  83.       line.j = Space(Injoyformat(temp.i) injoy_acct injoy_user)
  84.       line.0 = j
  85.    End
  86. End
  87.  
  88. /* this is a great way to sort the entries */
  89. Call RxSort 'line.', 'A'
  90.  
  91. Do i = 1 To line.0
  92.    Parse Var line.i time_stamp connect_time acctid userid .
  93.    acctid = Strip(acctid)
  94.    userid = Strip(userid)
  95.    connect_time = Strip(connect_time)
  96.    year = Substr(time_stamp, 2, 4)
  97.    t_yr = year
  98.    mm = Substr(time_stamp, 6, 2)
  99.    dd = Substr(time_stamp, 8, 2)
  100.    mins = connect_time % 60                            /*... and mins */
  101.    secs = connect_time - (mins * 60)                 /*...and seconds */
  102.    /* Calculate time_on for that connection */
  103.    time_on = (mins + (1/60)*secs)
  104.    If time_stamp > last_time.acctid.userid Then
  105.       Call Monthly_update
  106.  
  107.    If old_d = 0 Then
  108.       Do                            /* for very first connection line */
  109.          old_m = mm
  110.          old_d = dd
  111.          old_y = year
  112.          signons_each_day = 1                           /* reset to 1 */
  113.          signons_each_month = 1
  114.          /* This and next one are timeons in minutes */
  115.          daily_time_on = time_on
  116.          monthly_time_on = time_on
  117.       End
  118.  
  119.    Else         /* continue to accumulate times if same month and day */
  120.       If old_m = mm & old_d = dd & month <> 0 Then
  121.       Do
  122.          old_y = year
  123.          signons_each_day = signons_each_day + 1
  124.          signons_each_month = signons_each_month + 1
  125.          daily_time_on = daily_time_on + time_on
  126.          monthly_time_on = monthly_time_on + time_on
  127.       End
  128.  
  129.    Else                                      /* new day of same month */
  130.       If old_m = mm & old_d <> dd Then
  131.       Do
  132.          Call Prepare_data
  133.          dcounter = dcounter + 1
  134.          year.dcounter = year
  135.          year.mcounter = year
  136.          dayline.dcounter = year.dcounter month.old_m old_d d_signons d_mins d_hhmmss d_hrs
  137.  
  138.          old_d = dd
  139.          old_y = year
  140.          signons_each_day = 1            /* Start counting over again */
  141.          signons_each_month = signons_each_month + 1
  142.          daily_time_on = time_on
  143.          monthly_time_on = monthly_time_on + time_on
  144.       End
  145.  
  146.    Else   /* for any new month, which by definition is also a new day */
  147.       If old_m <> mm & old_m <> 0 Then
  148.       Do
  149.          Call Prepare_data
  150.          dcounter = dcounter + 1
  151.          year.dcounter = old_y
  152.          dayline.dcounter = year.dcounter month.old_m old_d d_signons d_mins d_hhmmss d_hrs
  153.  
  154.          mcounter = mcounter + 1
  155.          year.mcounter = old_y
  156.          monthline.mcounter = year.mcounter month.old_m m_signons m_mins m_hhmmss m_hrs
  157.  
  158.          old_m = mm
  159.          old_d = dd
  160.          old_y = year
  161.          signons_each_day = 1
  162.          signons_each_month = 1
  163.          daily_time_on = time_on
  164.          monthly_time_on = time_on
  165.       End
  166.  
  167. End             /* end of all these If's and Else If's of searching for 
  168.                    key_phrase in all possible lines in the connect.log */
  169.  
  170. /* Now, since last day and last month is done: */
  171. Call Prepare_data
  172. dcounter = dcounter + 1
  173. year.dcounter = year
  174. dayline.dcounter = year.dcounter month.old_m old_d d_signons d_mins d_hhmmss d_hrs
  175.  
  176. mcounter = mcounter + 1
  177. year.mcounter = year
  178. monthline.mcounter = year.mcounter month.old_m m_signons m_mins m_hhmmss m_hrs
  179. time_stamp = ''
  180. Do m = 1 To Words(injoy_logs)
  181.    injoy_acct = Word(injoy_accts, m)
  182.    injoy_user = Word(injoy_users, m)
  183.    time_stamp = time_stamp last_time.injoy_acct.injoy_user
  184. End
  185. /* save the last */
  186. injoy_times = Space(time_stamp)
  187. Call Write_config
  188. Trace (trace_save)
  189. return                                          /* from Analyze_logfile     */
  190.  
  191. Injoyformat: Procedure
  192. Parse Arg line
  193. Parse Var line 'DATE' date ',' . 'END' word2 ',' . 'min,' connect_time 'sec' .
  194. date = Strip(date)
  195. Parse Var date dd '.' mm '.' year
  196. word2 = Strip(word2)
  197. /* Extract for time stamp and save */
  198. Parse Var word2 t_hr ':' t_min ':' t_sec
  199. t_yr = year
  200. time_stamp = 'T' || t_yr || mm || dd || t_hr || t_min || t_sec
  201. connect_time = Strip(connect_time)
  202. line = time_stamp connect_time
  203. Return line
  204.  
  205. Monthly_update:
  206. s_yr = Strip(t_yr)
  207. s_mo = Strip(mm)
  208. If summary.acctid.userid.s_yr.s_mo <> '' Then
  209.    Do
  210.       Parse Var summary.acctid.userid.s_yr.s_mo s_yr s_mo s_stamp s_sess s_min .
  211.       If time_stamp > s_stamp Then
  212.          Do
  213.             s_sess = s_sess + 1
  214.             s_min = s_min + time_on
  215.             summary.acctid.userid.s_yr.s_mo = s_yr s_mo time_stamp s_sess s_min
  216.          End
  217.    End
  218. Else
  219.    Do
  220.       x = monthly.0 + 1
  221.       monthly.x = acctid userid s_yr s_mo
  222.       monthly.0 = x
  223.       summary.acctid.userid.s_yr.s_mo = s_yr s_mo time_stamp '1' time_on
  224.    End
  225. last_time.acctid.userid = time_stamp
  226. Return
  227.  
  228. Prepare_data:
  229. /* Calculates and formats what is to be put into an output line */
  230.  
  231. /* Signons per day or month, as, e.g.: '4X' */
  232. d_signons = Format(signons_each_day, sig_x)||'X'
  233. m_signons = Format(signons_each_month, sig_x)||'X'
  234.  
  235. /* Minutes/day, minutes/month, hrs/day, hrs/month as, e.g.: '105.50 mins or hrs' */
  236. d_mins = Format(daily_time_on, sig_min, 2) 'mins'
  237. d_hrs = Format((daily_time_on/60), sig_hr, 2) 'hrs'
  238. m_mins = Format(monthly_time_on, sig_min, 2) 'mins'
  239. m_hrs = Format((monthly_time_on/60), sig_hr, 2) 'hrs'
  240.  
  241. /* minutes, seconds per day or month, as 2-digit numbers; hrs can exceed 2 digs */
  242. dy_hh = Format(Trunc(daily_time_on/60),sig_hr)            
  243. dy_mm = Right(Trunc(daily_time_on//60),2,'0')
  244. dy_ss = Right(Trunc(60*((daily_time_on//60) - Trunc(daily_time_on//60))),2,'0')
  245. mo_hh = Format(Trunc(monthly_time_on/60),sig_hr)
  246. mo_mm = Right(Trunc(monthly_time_on//60),2,'0')
  247. mo_ss = Right(Trunc(60*((monthly_time_on//60) - Trunc(monthly_time_on//60))),2,'0')
  248.  
  249. /* hours, minutes, seconds per day or month, as, e.g.: '1:45:30'*/
  250. d_hhmmss = '  '||dy_hh||':'||dy_mm||':'||dy_ss
  251. m_hhmmss = '  '||mo_hh||':'||mo_mm||':'||mo_ss
  252.  
  253. Return                                                /* Prepare_data */
  254.  
  255. Outputter:
  256. /* Now output everything to console and to file */
  257.  
  258. /* get the screen size; rows is what we are interested in */
  259. Parse Value SysTextScreenSize() With rows cols
  260. Call Stream stdin, 'C', 'OPEN READ'
  261. /* Tell us all */
  262. intro = what_r_we
  263. Call Say_out intro
  264. If otherparms <> '' Then
  265.    Do
  266.       Call Say_out crlf || 'Running with parms =' otherparms
  267.       Call Lineout output_file crlf || 'Running with parms =' otherparms
  268.    End
  269. Call Lineout output_file, intro
  270. intro = crlf || 'Analysis of InJoy log file(s)' injoy_logs '(' || Date() '@' Time() || ')'
  271. Call Say_out intro
  272. Call Lineout output_file, intro
  273. If daily_report Then
  274.    Call Say_out crlf || daily totals
  275. Call Lineout output_file, crlf || daily totals
  276. Do j = 1 To dcounter
  277.    If daily_report Then
  278.       Call Say_out dayline.j
  279.    Call Lineout output_file, dayline.j
  280.    If one_screen_at_a_time & daily_report & \quiet & \pmrexx then            
  281.    If (j - rows + 6) // (rows - 5) = 0 Then
  282.       answer = Say_message('               Press any key to continue...')
  283. End
  284.  
  285. If one_screen_at_a_time & daily_report & \quiet & \pmrexx then            
  286. If (j - rows + 6) // (rows - 5) > 5 Then
  287.    Do                                   /* If at about 5 lines to end */
  288.       answer = Say_message('   Daily Totals done, press any key for Monthlies...')
  289.       /* If decision is to do a 'Press-Any-Key to continue', reset to 0 */
  290.       j = 0
  291.    End
  292. If \ daily_report Then
  293.    j = 0
  294.  
  295. /* back up the summary file and delete it */
  296. If RxFileExists(summary_file) Then
  297.    Do
  298.       Parse Var summary_file fname '.' ext
  299.       Address cmd '@COPY' summary_file fname || '.bak > NUL'
  300.       Call SysFileDelete summary_file
  301.    End
  302. rc = File_cmd(summary_file,'W')
  303. acct_user_save = ''
  304.  
  305. Call RxSort 'monthly.', 'A' /* sort the summary data */
  306.  
  307. call summary_sample /* get the header information */
  308. /* insert the header info into the summary data */
  309. do k = summary_sample.0 to 1 by -1
  310.    call rxsteminsert 'monthly.', 1, summary_sample.k
  311. end
  312.  
  313. Do k = 1 To monthly.0
  314.    If Abbrev(monthly.k,'*') Then
  315.       Do                                   /* write comments back out */
  316.          Call Lineout summary_file, monthly.k
  317.          Iterate k
  318.       End
  319.    Parse Var monthly.k acctid userid s_yr s_mo
  320.    acct_user = acctid userid
  321.    Call Lineout summary_file, acctid userid '*' summary.acctid.userid.s_yr.s_mo
  322.    Parse Var summary.acctid.userid.s_yr.s_mo . . . s_sess s_mins
  323.    m_sess = Format(s_sess, sig_x) || 'X'
  324.    m_mins = Format(s_mins, sig_min, 2) 'mins'
  325.    mo_hh = Format(Trunc(s_mins / 60),sig_hr)
  326.    mo_mm = Right(Trunc(s_mins // 60),2,'0')
  327.    mo_ss = Right(Trunc(60 * ((s_mins // 60) - Trunc(s_mins // 60))),2,'0')
  328.    m_hhmmss = '  '||mo_hh||':'||mo_mm||':'||mo_ss
  329.    m_hrs = Format((s_mins / 60), sig_hr, 2) 'hrs'
  330.    a_sess = s_mins / s_sess
  331.    If a_sess < 60 Then
  332.       a_sess = Format(a_sess,2,0) 'mins'
  333.    Else
  334.       a_sess = Format((a_sess / 60),2,2) 'hrs'
  335.    a_sess = '- Ave =' a_sess
  336.    monthline = s_yr month.s_mo m_sess m_mins m_hhmmss m_hrs a_sess
  337.    If acct_user <> acct_user_save Then
  338.       Do
  339.          intro = crlf || 'MONTHLY TOTALS for Account(' || acctid || ') Userid(' || userid || '}'
  340.          Call Say_out intro
  341.          Call Lineout output_file, intro
  342.          acct_user_save = acct_user
  343.       End
  344.    Call Lineout output_file, monthline
  345.    monthline = s_yr month.s_mo m_sess m_hrs a_sess
  346.    Call Say_out monthline
  347.    If one_screen_at_a_time & \quiet & \pmrexx Then
  348.       If (k + j - rows + 6) // (rows - 6) = 0 Then
  349.       answer = Say_message('               Press any key to continue...')
  350. End
  351. rc = File_cmd(summary_file,'C')
  352. finished = crlf || 'End of analysis of InJoy log file(s)'
  353. Call Say_out finished
  354. Call Lineout output_file, finished
  355.  
  356. Return                                              /* from Outputter */
  357.  
  358. Initialize_parms:
  359. trace_save = Trace('N')
  360. Trace 'N'
  361. quiet = 0
  362. irc = 0
  363.  
  364. Do i = 1 To Words(otherparms)
  365.    Parse Value Word(otherparms, i) With key_word '=' key_value
  366.    Select
  367.       When Abbrev(key_word, '/Q') Then
  368.          quiet = 1
  369.       Otherwise Nop
  370.    End
  371. End
  372.  
  373. Call Read_config
  374.  
  375. Call Update_config
  376.  
  377. /* Get full paths for output file and summary file */
  378. output_file = data_path || injoy_output_file
  379. summary_file = data_path || injoy_summary_file
  380. Call Set_monthly_summary
  381.  
  382. /* initialize variables */
  383. crlf = D2c(13) || D2c(10)               /* carriage return + linefeed */
  384. esc = D2c(27)                                     /* Escape character */
  385. time_stamp = ''                  /* Time stamp of each connect record */
  386.  
  387. Do i = 1 To 12                                   /* initialize months */
  388.    x = Right(i,2,'0')
  389.    month.x = Word('Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec',i)
  390. End
  391.  
  392. /* calculated variables
  393.    signons_each_day    Accumulate number of connects daily
  394.    signons_each_month  Accumulate number of connects monthly
  395.    time_on             Time, each connect  (minutes)
  396.    daily_time_on       Accumulated minutes, daily
  397.    monthly_time_on     Accumulated minutes, monthly */
  398.  
  399. /* More variables: these we initialize as follows: */
  400. old_m = 0                 /* Storage of a 2-digit month (eg 05 = May) */
  401. old_d = 0                                    /* ... and a 2-digit day */
  402. dcounter = 0              /* Counter increments each sign-on in a day */
  403. mcounter = 0                         /* Same for each sign-on in a month */
  404. monthline. = ''           /* Initialize both of these as null strings */
  405. dayline. = ''       /* These are for monthly and daily output strings */
  406.  
  407. /* A typical line generated in the default.log upon disconnect looks like
  408.       DATE 20.02.1998, START 16:22:32, END 16:22:33, DURATION 0   min, 1     sec
  409.    We search for a key_phrase using the RexxUtil function SysFileSearch */
  410.  
  411. key_phrase = 'DATE'                /* Word or phrase we'll search for */
  412.  
  413. Do i = 1 To Words(injoy_logs)
  414.    If \RxFileExists(Word(injoy_logs, i)) Then
  415.       Do
  416.          Say 'Log file' Word(injoy_logs, i) 'does not exist.'
  417.          Say 'It may have been cleared and will be bypassed.'
  418.       End
  419.    /* make sure that we have control of the log file */
  420.    Else
  421.       Do
  422.          rc = File_cmd(Word(injoy_logs, i), 'W')
  423.          If \ rc Then
  424.             Do Until rc
  425.                Say 'Log file' Word(injoy_logs, i) 'returned' result
  426.                rc = File_cmd(Word(injoy_logs, i), 'C')
  427.                Say 'Unable to open' Word(injoy_logs, i)
  428.                Say 'Press Esc to abort run'
  429.                answer = Say_message('Press any other key to wait 5 seconds')
  430.                If answer = esc Then
  431.                   irc = Cleanup(24)
  432.                Call SysSleep 5
  433.                Call SysCls
  434.                rc = File_cmd(Word(injoy_logs, i), 'W')
  435.             End
  436.       End
  437.    rc = File_cmd(Word(injoy_logs, i), 'C')
  438. End
  439.  
  440. /* Here is where we Check if the output file exists.  If it does, we
  441.    overwrite it, and if not we create it.  BUT....  we don't want to
  442.    do something stupid like try to erase a vital file or the connect
  443.    logfile... */
  444.  
  445. /* Backup any output file of the same name if it exists, then erase orig. */
  446. If RxFileExists(output_file) Then
  447.    Do
  448.       Parse Var output_file fname '.' ext
  449.       Address cmd '@COPY' output_file fname||'.bak > NUL'
  450.       Call SysFileDelete output_file
  451.    End
  452.  
  453. Trace (trace_save)
  454. Return                                            /* Initialize_parms */
  455.  
  456. Set_monthly_summary:                           /* set monthly summary */
  457. monthly. = ''
  458. monthly.0 = 0
  459. summary. = ''
  460. s_time = 'T00000000000000'
  461. If RxFileExists(summary_file) Then
  462.    Do
  463.       Call RxRead 'data.', summary_file
  464.       Do i = 1 To data.0
  465.          If \ Abbrev(data.i,'*') & data.i <> '' Then
  466.             Do
  467.                Parse Var data.i acctid userid '*' s_yr s_mo s_time s_data
  468.                If s_yr = '' Then
  469.                   Do
  470.                      acctid = 'unknown'
  471.                      userid = 'unknown'
  472.                      Parse Var data.i s_yr s_mo s_data
  473.                   End
  474.                acctid = Strip(acctid)
  475.                userid = Strip(userid)
  476.                s_yr = Strip(s_yr)
  477.                s_mo = Strip(s_mo)
  478.                j = monthly.0 + 1
  479.                monthly.j = acctid userid s_yr s_mo
  480.                monthly.0 = j
  481.                summary.acctid.userid.s_yr.s_mo = s_yr s_mo s_time s_data
  482.             End
  483.       End
  484.       Call RxSort 'monthly.0', 'A'
  485.    End
  486. Else
  487.    s_time = 'T00000000000000'       /* reset timestamp to get updates */
  488. Return                                         /* Set_monthly_summary */
  489.  
  490. /* read the config file */
  491. Read_config:
  492. trace_save = Trace('N')
  493. Trace 'N'
  494. If RxFileExists(cfg_file) Then            /* do we have a config file */
  495.    input_file = cfg_file
  496. Else
  497.    Do
  498.       If RxFileExists(cfg_save) Then
  499.          input_file = cfg_save
  500.       Else
  501.          Do
  502.             Call Config_sample               /* use the sample values */
  503.             input_file = 'sample'
  504.          End
  505.    End
  506.  
  507. If input_file <> 'sample' Then
  508.    Call RxRead 'data.', input_file
  509. Else
  510.    Call RxStemCopy 'cfg_sample.', 'data.'
  511. config. = ''
  512. config.0 = data.0
  513. Do i = 1 To data.0
  514.    config.i = data.i
  515.    If Abbrev(data.i, ';') | Abbrev(data.i, '[') Then
  516.       Nop
  517.    Else
  518.       Do
  519.          Parse Var data.i key_id '=' key_value
  520.          key_id = Strip(key_id)
  521.          key_value = "'" || Strip(key_value) || "'"
  522.          Interpret key_id '=' key_value
  523.       End
  524. End
  525. Trace(trace_save)
  526. Return
  527.  
  528. /* update the config file */
  529. Update_config:
  530. trace_save = Trace('N')
  531. Trace 'N'
  532. /* path to data files */
  533. If data_path = '' Then
  534.    Do
  535.       data_path = install_path || 'data\'
  536.       Call Write_config
  537.    End
  538. /* create the data path sub-directory if needed */
  539. If \RxFileExists(data_path || '*.*') Then
  540.    xrc = SysMkDir(Strip(data_path, , '\'))
  541. /* IBM dialer support */
  542. If ibm_dialer = '' Then
  543.    Do
  544.       Say 'Support the IBM dialer (y/N)?'
  545.       Parse Upper Pull ans .
  546.       key_value = Abbrev(ans, 'Y')
  547.       ibm_dialer = key_value
  548.       Call Write_config
  549.    End
  550. /* InJoy dialer support */
  551. If injoy_dialer = '' Then
  552.    Do
  553.       Say 'Support the InJoy dialer (y/N)?'
  554.       Parse Upper Pull ans .
  555.       key_value = Abbrev(ans, 'Y')
  556.       injoy_dialer = key_value
  557.       Call Write_config
  558.    End
  559.  
  560. /* process IBM dialer entries */
  561. If ibm_dialer Then
  562.    Do
  563.       /* dialer ini file */
  564.       If ibm_dialer_ini_file = '' Then
  565.          Do
  566.             Say 'Please select your IBM dialer by number'
  567.             Say '   1 - DIALER.EXE (1.67 and below)'
  568.             Say '   2 - TCPDIAL.EXE (1.69 and above)'
  569.             Parse Upper Pull ans .
  570.             Select
  571.                When ans = 1 Then
  572.                   key_value = 'dialer.ini'
  573.                When ans = 2 Then
  574.                   key_value = 'tcpdial.ini'
  575.                Otherwise Do
  576.                   Say 'You did not chose a supported dialer'
  577.                   key_value = ''
  578.                End
  579.             End
  580.             ibm_dialer_ini_file = key_value
  581.             Call Write_config
  582.          End
  583.    End
  584.  
  585. /* process InJoy dialer entries */
  586. If injoy_dialer Then
  587.    Do
  588.       If injoy_logs = '' Then
  589.          Do
  590.             /* get path to InJoy */
  591.             Say 'Enter the full path to the InJoy Dialer logs or hit enter to quit.'
  592.             Parse Upper Pull ans .
  593.             If ans <> '' Then
  594.                Do
  595.                   /* get all *.log file names */
  596.                   log_path = ans
  597.                   rc = SysFileTree(log_path || '\*.log', 'logs.', 'FO')
  598.                   /* loop through log file names to see the user wants them included */
  599.                   If rc = 0 & logs.0 > 0 Then
  600.                      Do i = 1 To logs.0
  601.                         Say 'Found InJoy log file -' logs.i
  602.                         Say 'Analyze this log (y/N)'
  603.                         Parse Upper Pull ans
  604.                         If Abbrev(ans, 'Y') Then
  605.                            Do
  606.                               injoy_logs = Space(injoy_logs logs.i)
  607.                            End
  608.                      End
  609.                   Else
  610.                      Do
  611.                         Say 'Unable to locate any logs in InJoy log path -' ans
  612.                         Say 'InJoy logs in' ans 'will not be processed.'
  613.                      End
  614.                End
  615.             Else
  616.                Say 'InJoy logs will not be processed'
  617.             injoy_accts = ''
  618.             injoy_users = ''
  619.             injoy_times = ''
  620.             Do i = 1 To Words(injoy_logs)
  621.                joylog = Word(injoy_logs, i)
  622.                joyacct = Word(injoy_accts, i)
  623.                joyuser = Word(injoy_users, i)
  624.                joytime = Word(injoy_times, i)
  625.                If joyacct = '' Then
  626.                   Do
  627.                      Say 'Enter an account id for InJoy log -' joylog
  628.                      Parse Pull joydata
  629.                      injoy_accts = Strip(injoy_accts joydata)
  630.                   End
  631.                If joyuser = '' Then
  632.                   Do
  633.                      Say 'Enter an user id for InJoy log -' joylog
  634.                      Say 'and account id -' joydata
  635.                      Parse Pull joydata
  636.                      injoy_users = Strip(injoy_users joydata)
  637.                   End
  638.                If joytime = '' Then
  639.                   Do
  640.                      joydata = 'T00000000000000'
  641.                      injoy_times = Strip(injoy_times joydata)
  642.                   End
  643.             End
  644.             Call Write_config
  645.          End
  646.    End
  647. Trace(trace_save)
  648. Return
  649.  
  650. /* write the config file */
  651. Write_config:
  652. trace_save = Trace('N')
  653. Trace 'N'
  654. If RxFileExists(cfg_file) Then            /* do we have a config file */
  655.    Do
  656.       If RxFileExists(cfg_save) Then
  657.          Call SysFileDelete(cfg_save)
  658.       Address cmd '@rename' cfg_file Filespec('N', cfg_save) '> nul'
  659.    End
  660. Do i = 1 To config.0
  661.    If Abbrev(config.i, ';') | Abbrev(config.i, '[') Then
  662.       Nop
  663.    Else
  664.       Do
  665.          Parse Var config.i key_id '=' key_value
  666.          key_id = Strip(key_id)
  667.          config.i = key_id '=' Value(key_id)
  668.       End
  669. End
  670. Call RxWrite 'config.', cfg_file
  671. Trace(trace_save)
  672. Return
  673.  
  674. Cleanup:
  675. Parse Arg irc
  676. Return irc
  677.  
  678. Say_out:                             /* performs output to the screen */
  679. Procedure Expose quiet
  680. If quiet Then
  681.    Return
  682. trace_save = Trace('N')
  683. Parse Arg line
  684. Say line
  685. Trace (trace_save)
  686. Return
  687.  
  688. Say_message:       /* performs message output and returns key entered */
  689. Procedure Expose quiet
  690. trace_save = Trace('N')
  691. Parse Arg msg
  692. Say msg
  693. answer = SysGetKey('NOECHO')
  694. Trace (trace_save)
  695. Return answer
  696.  
  697. /* performs common Stream commands and returns 1 or a date if successful */
  698. File_cmd: Procedure Expose result
  699. trace_save = Trace('N')
  700. Trace 'N'
  701. Parse Arg file_name, command
  702. command = Translate(command)
  703. Select
  704.    When command = 'X' Then
  705.       Do
  706.          result = Stream(file_name, 'C', 'QUERY EXISTS')
  707.          answer = (result <> '')
  708.       End
  709.    When command = 'C' Then
  710.       Do
  711.          result = Stream(file_name, 'C', 'CLOSE')
  712.          answer = Abbrev(result,'READY') | (result = '')
  713.       End
  714.    When command = 'W' Then
  715.       Do
  716.          result = Stream(file_name, 'C', 'OPEN WRITE')
  717.          answer = Abbrev(result,'READY')
  718.       End
  719.    When command = 'R' Then
  720.       Do
  721.          result = Stream(file_name, 'C', 'OPEN READ')
  722.          answer = Abbrev(result,'READY')
  723.       End
  724.    When command = 'D' Then
  725.       Do
  726.          result = Stream(file_name, 'C', 'QUERY DATETIME')
  727.          If result <> '' Then
  728.             Do
  729.                Parse Var result date time
  730.                date = Dateconv(Translate(date, '/', '-'), 'U', 'S')
  731.                Parse Var time hr ':' min ':' sec
  732.                answer = Strip(date) || Strip(hr) || Strip(min) || Strip(sec)
  733.             End
  734.          Else
  735.             answer = '00000000000000'
  736.       End
  737.    Otherwise answer = 0
  738. End
  739. Trace (trace_save)
  740. Return answer
  741.  
  742. Summary_sample: Procedure Expose summary_sample.
  743. trace_save = Trace('N')
  744. Trace 'N'
  745. data_queue = INetSmp('summary')
  746. old_queue = Rxqueue('Set', data_queue)
  747. summary_sample.0 = Queued()
  748. Do i = 1 To summary_sample.0
  749.    Parse Pull summary_sample.i
  750. End
  751. rx_queue = Rxqueue('Delete', data_queue)
  752. Trace(trace_save)
  753. Return
  754.