Esempio n. 1
0
/*!
 * \brief This function performs similarly to the scanf function of 'C'.
 * 
 * \param[in] file_ptr The stream to scan from.
 * \param[in] fmt_ptr  The format string to use when scanning.
 * 
 * \return Number of input items converted and assigned.
 * \return IO_EOF  
 */ 
_mqx_int _io_fscanf
   (
      MQX_FILE_PTR     file_ptr,
      const char  *fmt_ptr, 
      ...
   )
{ /* Body */
   char    temp_buf[IO_MAXLINE];
   va_list ap;
   _mqx_int result;
   
#if MQX_CHECK_ERRORS
   if (file_ptr == NULL) {
      return(IO_EOF);
   } /* Endif */
#endif

   va_start(ap, fmt_ptr);
   /* get a line of input from user */
   if (_io_fgetline( file_ptr, temp_buf, IO_MAXLINE) == IO_EOF) {
      return(IO_EOF);
   } /* Endif */
   result = _io_scanline( temp_buf, (char *)fmt_ptr, ap );
   va_end(ap);
   return result;

} /* Endbody */
Esempio n. 2
0
_mqx_int _io_scanf
   ( 
      /* [IN] the format string to scan with */
      const char _PTR_ fmt_ptr, 
      ...
   )
{ /* Body */
   char    temp_buf[IO_MAXLINE];
   va_list ap;
   _mqx_int result;
   
   va_start(ap, fmt_ptr);
   temp_buf[0] = '\0';
   if (_io_fgetline(stdin, temp_buf, IO_MAXLINE) == IO_EOF) {
      return(IO_EOF);
   } /* Endif */
   result = _io_scanline(temp_buf, (char _PTR_)fmt_ptr, ap);
   va_end(ap);
   return result;

} /* Endbody */
Esempio n. 3
0
/*!
 * \brief Reads the specified string
 * 
 * This function reads at most the next size-1 characters into the array 
 * tty_line_ptr, stopping if a newline is encountered; The newline is included 
 * in the array, which is terminated by '\0'.
 * 
 * \param[in,out] tty_line_ptr Where to store the input string.
 * \param[in]     size         The maximum length to store.
 * \param[in]     file_ptr     The stream to read from.
 * 
 * \return Pointer to the character array.
 * \return NULL  (End of file or error.) 
 */ 
char  *_io_fgets
   (
      char   *tty_line_ptr,
      _mqx_int    size,
      MQX_FILE_PTR file_ptr
   )
{ /* Body */
   _mqx_int result;

#if MQX_CHECK_ERRORS
   if (file_ptr == NULL) {
      return(NULL);
   } /* Endif */
#endif

   /* Null terminate the buffer so we can tell if _io_fgetline() actually
      read any data... */

   tty_line_ptr[0] = '\0';

   /* Attempt to read a line of text from file_ptr */

   result = _io_fgetline(file_ptr, tty_line_ptr, size);

   /* If _io_fgetline() returned IO_EOF *and* no data was
      read into the tty_line_ptr buffer, return NULL... */

   if ((result == IO_EOF) && (tty_line_ptr[0] == '\0')) {
      return(NULL);
   } /* Endif */

   /* Otherwise, at least 1 byte was read so return the buffer pointer */

   return tty_line_ptr;

} /* Endbody */