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

  1. /*
  2.  *  PROGRAM:   JQCPIC -- John Q's Portable CPI-C Abuser
  3.  *
  4.  *  MODULE:    PORT.C -- Change these procedures when porting
  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.  *  06/24/92   new
  35.  */
  36.  
  37. #include <signal.h>
  38. #include <stdarg.h>
  39. #include <stdlib.h>
  40. #include <stdio.h>
  41. #include <string.h>
  42.  
  43. #include "jqcpic.h"
  44.  
  45.  
  46. void *get_memory(size_t buffer_size)
  47. {
  48.     /*=========================================================================
  49.      * Allocate a memory block.
  50.      *=======================================================================*/
  51.  
  52.     void *buffer;
  53.  
  54.     buffer = malloc(buffer_size);
  55.     if (NULL == buffer) {
  56.         write_error("%s exiting because of memory allocation failure\n",
  57.                     program_name);
  58.         all_done(EXIT_FAILURE);
  59.     }
  60.  
  61.     return buffer;
  62. }
  63.  
  64.  
  65. void free_memory(void *buffer)
  66. {
  67.     /*=========================================================================
  68.      *
  69.      *=======================================================================*/
  70.  
  71.     return free(buffer);
  72. }
  73.  
  74.  
  75. void protocol_error(void)
  76. {
  77.     /*=========================================================================
  78.      *
  79.      *=======================================================================*/
  80.  
  81.     /* for now, just beep. */
  82.     (void)printf("%c", 0x07);
  83. }
  84.  
  85.  
  86. void write_error(char *fmt, ...)
  87. {
  88.     /*=========================================================================
  89.      *
  90.      *=======================================================================*/
  91.  
  92.     va_list args;
  93.  
  94.     va_start(args, fmt);
  95.     vfprintf(stderr, fmt, args);
  96.     va_end(args);
  97. }
  98.  
  99.  
  100. void write_output(char *fmt, ...)
  101. {
  102.     /*=========================================================================
  103.      *
  104.      *=======================================================================*/
  105.  
  106.     va_list args;
  107.  
  108.     va_start(args, fmt);
  109.     vfprintf(stdout, fmt, args);
  110.     va_end(args);
  111. }
  112.