2012-02-01 20:07:57 +01:00
|
|
|
/****************************************************************************
|
2012-10-04 02:11:05 +02:00
|
|
|
* apps/system/readline/readline.c
|
2012-02-01 20:07:57 +01:00
|
|
|
*
|
2021-06-10 13:17:16 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2012-02-01 20:07:57 +01:00
|
|
|
*
|
2021-06-10 13:17:16 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2012-02-01 20:07:57 +01:00
|
|
|
*
|
2021-06-10 13:17:16 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2012-02-01 20:07:57 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2013-09-30 19:34:04 +02:00
|
|
|
#include <assert.h>
|
2012-03-30 18:08:28 +02:00
|
|
|
|
2016-07-11 18:11:18 +02:00
|
|
|
#include "system/readline.h"
|
2012-02-01 20:07:57 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
2015-10-03 00:20:33 +02:00
|
|
|
* Public Functions
|
2012-02-01 20:07:57 +01:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: readline
|
|
|
|
*
|
2021-11-13 15:18:04 +01:00
|
|
|
* readline() is same to readline_fd() but accept a file stream instead
|
|
|
|
* of a file handle.
|
2012-02-01 20:07:57 +01:00
|
|
|
*
|
2015-10-03 01:33:30 +02:00
|
|
|
****************************************************************************/
|
2012-02-01 20:07:57 +01:00
|
|
|
|
2021-11-13 15:18:04 +01:00
|
|
|
#ifdef CONFIG_FILE_STREAM
|
2012-02-01 20:07:57 +01:00
|
|
|
ssize_t readline(FAR char *buf, int buflen, FILE *instream, FILE *outstream)
|
|
|
|
{
|
2023-09-22 13:37:51 +02:00
|
|
|
int instream_fd;
|
|
|
|
int outstream_fd;
|
|
|
|
|
2012-02-01 20:07:57 +01:00
|
|
|
/* Sanity checks */
|
|
|
|
|
2013-09-30 19:34:04 +02:00
|
|
|
DEBUGASSERT(instream && outstream);
|
2012-02-01 20:07:57 +01:00
|
|
|
|
2021-11-13 15:18:04 +01:00
|
|
|
/* Let readline_fd do the work */
|
2012-02-01 20:07:57 +01:00
|
|
|
|
2023-09-22 13:37:51 +02:00
|
|
|
instream_fd = fileno(instream);
|
|
|
|
outstream_fd = fileno(outstream);
|
|
|
|
|
|
|
|
return readline_fd(buf, buflen, instream_fd, outstream_fd);
|
2012-02-01 20:07:57 +01:00
|
|
|
}
|
2021-11-13 15:18:04 +01:00
|
|
|
#endif
|