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

  1. /*
  2.  *  PROGRAM:   JQCPIC -- John Q's Portable CPI-C Abuser
  3.  *
  4.  *  MODULE:    CMDLIN.C -- process the command line parameters
  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.  */
  36.  
  37. #include <stdio.h>
  38. #include <stdlib.h>
  39. #include <string.h>
  40.  
  41. #include "jqcpic.h"
  42.  
  43. void command_line(int argc, char *argv[])
  44. {
  45.     /*=========================================================================
  46.      * Process the command line arguments.
  47.      *=======================================================================*/
  48.  
  49.     if (1 < argc) {
  50.         if (strlen(argv[1]) < MAX_SYM_DEST_NAME) {
  51.             memset((void *)sym_dest_name, (int)' ', MAX_SYM_DEST_NAME);
  52.             strcpy(sym_dest_name, argv[1]);
  53.             sym_dest_name[strlen(sym_dest_name)] = ' ';
  54.         }
  55.         else {
  56.             write_error("destination name is longer than %u "
  57.                         "characters\n", SYM_DEST_NAME_LENGTH);
  58.             usage();
  59.             exit(EXIT_FAILURE);
  60.         }
  61.     }
  62.     else {
  63.         usage();
  64.         exit(EXIT_FAILURE);
  65.     }
  66.  
  67.     return;
  68. }
  69.  
  70.  
  71. char *get_program_name(char *zInput)
  72. {
  73.     /*=========================================================================
  74.      * Move from the right end of the input string (presumably a program
  75.      * name) towards the left, looking for a slash or backslash.
  76.      *=======================================================================*/
  77.  
  78.     char *zOutput = zInput;
  79.     size_t nLength = strlen(zInput);
  80.  
  81.     for(; (*zInput != NULL_CHARACTER); zInput++) {
  82.         *zInput = (char)toupper((int)*zInput);
  83.     }
  84.     for (; (--nLength); ) {
  85.         if ((zOutput[nLength] == BACKSLASH) ||
  86.             (zOutput[nLength] == SLASH)) {
  87.             zOutput = &zOutput[nLength+1]; /* point past it */
  88.             break;
  89.         }
  90.     }
  91.  
  92.     return zOutput;
  93. }
  94.