/*************************************************************** MPU-SCANF.C This file contains public formatted input functions for LIBMPUIO library. PART OF : MPUIO - library . Copyright (C) 2000 - 2026 by Andrey V.Kosteltsev. All Rights Reserved. ***************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include #include /*************************************************************** Read formatted input from STREAM using a va_list. ***************************************************************/ int mpu_vfscanf( mpu_FILE *stream, const __mpu_char16_t *format, va_list args ) { return( __mpu_IO_vfscanf( stream, format, args ) ); } /* End of mpu_vfscanf() */ /*************************************************************** Read formatted input from STREAM. ***************************************************************/ int mpu_fscanf( mpu_FILE *stream, const __mpu_char16_t *format, ... ) { va_list args; int ret; va_start( args, format ); ret = mpu_vfscanf( stream, format, args ); va_end( args ); return( ret ); } /* End of mpu_fscanf() */ /*************************************************************** Read formatted input from mpu_stdin using a va_list. ***************************************************************/ int mpu_vscanf( const __mpu_char16_t *format, va_list args ) { return( mpu_vfscanf( mpu_stdin, format, args ) ); } /* End of mpu_vscanf() */ /*************************************************************** Read formatted input from mpu_stdin. ***************************************************************/ int mpu_scanf( const __mpu_char16_t *format, ... ) { va_list args; int ret; va_start( args, format ); ret = mpu_vscanf( format, args ); va_end( args ); return( ret ); } /* End of mpu_scanf() */ /*************************************************************** Read formatted input from STREAM using a va_list without locking STREAM. ***************************************************************/ int mpu_vfscanf_unlocked( mpu_FILE *stream, const __mpu_char16_t *format, va_list args ) { return( __mpu_IO_vfscanf_unlocked( stream, format, args ) ); } /* End of mpu_vfscanf_unlocked() */ /*************************************************************** Read formatted input from STREAM without locking STREAM. ***************************************************************/ int mpu_fscanf_unlocked( mpu_FILE *stream, const __mpu_char16_t *format, ... ) { va_list args; int ret; va_start( args, format ); ret = mpu_vfscanf_unlocked( stream, format, args ); va_end( args ); return( ret ); } /* End of mpu_fscanf_unlocked() */ /*************************************************************** Read formatted input from mpu_stdin using a va_list without locking the standard input stream. ***************************************************************/ int mpu_vscanf_unlocked( const __mpu_char16_t *format, va_list args ) { return( mpu_vfscanf_unlocked( mpu_stdin, format, args ) ); } /* End of mpu_vscanf_unlocked() */ /*************************************************************** Read formatted input from mpu_stdin without locking it. ***************************************************************/ int mpu_scanf_unlocked( const __mpu_char16_t *format, ... ) { va_list args; int ret; va_start( args, format ); ret = mpu_vscanf_unlocked( format, args ); va_end( args ); return( ret ); } /* End of mpu_scanf_unlocked() */ /*************************************************************** Read formatted input from a NUL-terminated UCS-2 string using a va_list. No UTF-8 conversion is performed for string input. ***************************************************************/ int mpu_vsscanf( const __mpu_char16_t *string, const __mpu_char16_t *format, va_list args ) { mpu_FILE *stream; size_t length = 0; int ret; if( string == (const __mpu_char16_t *)0 || format == (const __mpu_char16_t *)0 ) { errno = EINVAL; return( mpu_EOF ); } while( string[length] ) ++length; stream = __mpu_IO_str_open_readonly( string, length ); if( stream == (mpu_FILE *)0 ) return( mpu_EOF ); ret = __mpu_IO_vfscanf( stream, format, args ); mpu_fclose( stream ); return( ret ); } /* End of mpu_vsscanf() */ /*************************************************************** Read formatted input from a NUL-terminated UCS-2 string. ***************************************************************/ int mpu_sscanf( const __mpu_char16_t *string, const __mpu_char16_t *format, ... ) { va_list args; int ret; va_start( args, format ); ret = mpu_vsscanf( string, format, args ); va_end( args ); return( ret ); } /* End of mpu_sscanf() */