scanf.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1995, by Sun Microsystems, Inc.
* All rights reserved.
*/
/* Copyright (c) 1984 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
/*LINTLIBRARY*/
#include <stdio.h>
#include <ctype.h>
#include <varargs.h>
#include <errno.h>
#define ON 1
#define OFF 0
#define ARGMAX 64
static unsigned char newform[256];
extern char *strcpy();
extern char *malloc();
extern int _doscan();
static int format_arg();
/*VARARGS1*/
int
char *fmt;
{
char *nf;
int ret_val;
return(ret_val);
}
}
}
/*VARARGS2*/
int
char *fmt;
{
char *nf;
int ret_val;
#ifdef POSIX
return (EOF);
}
#endif POSIX
return(ret_val);
}
}
}
/*VARARGS2*/
int
register char *str;
char *fmt;
{
char *nf;
int ret_val;
return(ret_val);
}
}
}
/*
* This function reorganises the format string and argument list.
*/
#ifndef NL_ARGMAX
#define NL_ARGMAX 9
#endif
struct al {
int a_num; /* arg # specified at this position */
unsigned char *a_start; /* ptr to 'n' part of '%n$' in format str */
unsigned char *a_end; /* ptr to '$'+1 part of '%n$' in format str */
int *a_val; /* pointers to arguments */
};
static int
{
unsigned char *fmtsav;
#ifdef VTEST
{
int fd;
}
#endif
nl_fmt = 0;
i = j = 1;
while (*format) {
break;
case 'l':
case 'h':
goto charswitch;
case '0': case '1': case '2':
case '3': case '4': case '5':
case '6': case '7': case '8':
case '9':
format++;
}
if (*format == '$') {
nl_fmt++;
}
goto charswitch;
/* now have arg type only to parse */
case 'd': case 'u': case 'o':
case 'x': case 'e': case 'f':
case 'g': case 'c': case '[':
case 's':
if (nl_fmt == 0)
return(OFF);
}
i++;
break;
case '*':
case '%':
break;
default:
format--;
break;
}
}
length = i;
if (nl_fmt == 0)
return (OFF);
/*
* Reformat the format string
*/
do {
if (i == length)
while (*cptr++);
else
} while (i < length);
/*
* Create arglist
* assuming that pointer to all variable type have
* same size.
*/
for (i = 1; i < length; i++)
for (i = 1; i < length; i++) {
int **ptr;
newlist += sizeof(int *);
}
return(ON);
}