/*static char *SCCSID = "@(#)cmstrchr.c	6.1 90/11/16";*/
/* static char *SCCSID = "@(#)cmstrchr.c	6.2 90/01/24"; */

/*********************************************************************/
/*	 IBM/Microsoft Confidential				     */
/*								     */
/*	 Copyright (c) IBM Corporation 1987, 1989		     */
/*	 Copyright (c) Microsoft Corporation 1987, 1989		     */
/*								     */
/*	 All Rights Reserved					     */
/*********************************************************************/

/*********** START OF SPECIFICATION ****** IBM CONFIDENTIAL **********/
/*								     */
/* SUBROUTINE NAME:  COM_STRCHR					     */
/*								     */
/* DESCRIPTIVE NAME:  FIND CHARACTER IN A STRING		     */
/*								     */
/* FUNCTION:							     */
/*								     */
/*								     */
/* NOTES:							     */
/*								     */
/*								     */
/* ENTRY POINT:	 com_strchr					     */
/*   LINKAGE  :							     */
/*								     */
/* INPUT:    string1  --- source string pointer (unsigned char ptr)  */
/*	     c	      --- character to be found			     */
/*								     */
/* EXIT:							     */
/*								     */
/*								     */
/* EXIT-NORMAL: pointer to found character			     */
/*								     */
/* EXIT-ERROR:	none						     */
/*								     */
/*								     */
/* EFFECTS:							     */
/*								     */
/* INTERNAL REFERENCES:						     */
/*   ROUTINES:		 com_settble				     */
/*								     */
/* EXTERNAL REFERENCES:						     */
/*   ROUTINES:							     */
/*								     */
/* RELEASE:							     */
/*								     */
/*   VERSION	  DATE		 REASON				     */
/*								     */
/*     1.00	06/13/1986     initial version			     */
/*     1.10	07/15/1987     - JMH - 1) changes from I2 review     */
/*				       2) code cleanup		     */
/*				       3) addition of comments	     */
/**************** END OF SPECIFICATIONS ******************************/
#include "cmdbcs.h"				 /* dbcs externs		  */
#include "comsub.h"				 /* dbcs externs	*/
#include <string.h>				 /* C string support		  */
#include <stdio.h>				/* C string support    */

 char *com_strchr(string1, c)			 /*				  */
 unsigned char *string1;			 /* string to be searched	  */
 unsigned char c;				 /* char to search with		  */
   {						 /*				  */
    int i = 0;					 /* index varb to search string	  */
						 /*				  */
    com_settbl();				 /* initialize table if necessary */
						 /*				  */
    while (string1[i] != '\0')			 /* while not at end of string	  */
      {						 /*				  */
       if (check_dbcs(string1[i]) == DBCS)	 /* if cur char == DBCS lead byte */
	 {					 /*   then			  */
	  i++;					 /*	increment by 1 past char  */
	 }					 /*				  */
       else					 /*   else			  */
	 {					 /*				  */
	  if (string1[i] == c)			 /*	if cur char == passed char*/
	    {					 /*	then			  */
	     return(&string1[i]);		 /*	  return ptr at cur char  */
	    }					 /*				  */
	 }					 /*	endif			  */
       i++;					 /*   increment past cur char	  */
      }						 /*   if DBCS then past trail byte*/
						 /* end while			  */
    if (c == '\0')				 /* if passed char == null	  */
      {						 /*   then			  */
       return(&string1[i]);			 /*	return string at begin	  */
      }						 /*   endif			  */
    return(NULL);				 /* If not found return NULL	  */
   }						 /*				  */
