home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / CPI-C.ZIP / SHOW.C < prev   
Text File  |  1992-06-24  |  4KB  |  134 lines

  1. /*
  2.  *  PROGRAM:   JQCPIC -- John Q's Portable CPI-C Abuser
  3.  *
  4.  *  MODULE:    SHOW.C -- write strings to stdout
  5.  *
  6.  *  COPYRIGHTS:
  7.  *             This module contains code made available by IBM
  8.  *             Corporation on an AS IS basis.  Any one receiving the
  9.  *             module is considered to be licensed under IBM copyrights
  10.  *             to use the IBM-provided source code in any way he or she
  11.  *             deems fit, including copying it, compiling it, modifying
  12.  *             it, and redistributing it, with or without
  13.  *             modifications.  No license under any IBM patents or
  14.  *             patent applications is to be implied from this copyright
  15.  *             license.
  16.  *
  17.  *             A user of the module should understand that IBM cannot
  18.  *             provide technical support for the module and will not be
  19.  *             responsible for any consequences of use of the program.
  20.  *
  21.  *             Any notices, including this one, are not to be removed
  22.  *             from the module without the prior written consent of
  23.  *             IBM.
  24.  *
  25.  *  AUTHOR:    Dr. John Q. Walker II
  26.  *             IBM VNET: JOHNQ at RALVM6          IBM tie line: 444-4414
  27.  *             Internet: johnq@vnet.ibm.com        phone: (919) 254-4414
  28.  *
  29.  *  RELATED FILES:
  30.  *             See file JQCPIC.DOC for detailed information.
  31.  *
  32.  *  CHANGE HISTORY:
  33.  *  Date       Description
  34.  *  05/12/92   Added prologue.
  35.  *  06/21/92   Added show_error()
  36.  */
  37.  
  38. #include <signal.h>
  39. #include <stdarg.h>
  40. #include <stdlib.h>
  41. #include <stdio.h>
  42. #include <string.h>
  43.  
  44. #include "jqcpic.h"
  45.  
  46.  
  47.  
  48. void show_end_of_line(void)
  49. {
  50.     /*=========================================================================
  51.      * Print the end-of-line character.
  52.      *=======================================================================*/
  53.  
  54.     write_output("\n");
  55. }
  56.  
  57.  
  58. void show_cpic_call_short(const CPIC_VERB_INDEX index)
  59. {
  60.     /*=========================================================================
  61.      * Show the string representing the current CPI-C call (short).
  62.      *=======================================================================*/
  63.  
  64.     write_output("%-6s ", cpicerr_verbs_short[index].message);
  65. }
  66.  
  67.  
  68. void show_cpic_call_long(const CPIC_VERB_INDEX index)
  69. {
  70.     /*=========================================================================
  71.      * Show the string representing the current CPI-C call (long).
  72.      *=======================================================================*/
  73.  
  74.     write_output("%-33s ", cpicerr_verbs_long [index].message);
  75. }
  76.  
  77.  
  78. void show_conv_state(const CM_CONVERSATION_STATE index)
  79. {
  80.     /*=========================================================================
  81.      * Show the string representing the conversation state.
  82.      *=======================================================================*/
  83.  
  84.     write_output("%-12.12s ", cpicerr_states_conv[index].message);
  85. }
  86.  
  87.  
  88. void show_cpic_call(CPIC_CONV_ATTRIB *this, const CPIC_VERB_INDEX index)
  89. {
  90.     /*=========================================================================
  91.      * Show the string representing the current CPI-C call.
  92.      *=======================================================================*/
  93.  
  94.     /* need to get an index into the right array */
  95.     CPIC_VERB_INDEX true_index = call_state_map[index];
  96.  
  97.     this->call_index = (CM_INT32)true_index;
  98.  
  99.     show_cpic_call_short(true_index);
  100. }
  101.  
  102.  
  103. void show_return_code(CPIC_CONV_ATTRIB *this)
  104. {
  105.     /*=========================================================================
  106.      * Show the string representing the return code from the last CPI-C call.
  107.      *=======================================================================*/
  108.  
  109. #ifdef NOCPIC
  110.     /* this is where we invent new return codes */
  111.     this->return_code = (rand() % (NUM_CPIC_RETURN_CODES));
  112. #endif
  113.  
  114.     write_output("%-29s ", cpicerr_get_message(CPIC_RETURN_CODES,
  115.                                                this->return_code));
  116. }
  117.  
  118.  
  119. void show_error(char *fmt, ...)
  120. {
  121.     /*=========================================================================
  122.      * Show the error string.
  123.      *=======================================================================*/
  124.  
  125.     va_list args;
  126.     va_start(args, fmt);
  127.  
  128.     write_output("* ");
  129.     write_output(fmt, args);
  130.     write_output(" ");
  131.  
  132.     va_end(args);
  133. }
  134.