This is Unofficial EPICS BASE Doxygen Site
osdReadline.c
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2002 The University of Saskatchewan
3 * Copyright (c) 2014 UChicago Argonne LLC, as Operator of Argonne
4 * National Laboratory.
5 * EPICS BASE is distributed subject to a Software License Agreement found
6 * in file LICENSE that is included with this distribution.
7 \*************************************************************************/
8 /* Author: Eric Norum Date: 12DEC2001 */
9 
10 /*
11  * This file is included by epicsReadline.c which has already included the
12  * headers stdio.h, stdlib.h, errno.h, envDefs.h and epicsReadline.h
13  */
14 
15 #include <string.h>
16 #include <libtecla.h>
17 
18 struct osdContext {};
19 
20 /*
21  * Create a command-line context
22  */
23 static void
24 osdReadlineBegin (struct readlineContext *context)
25 {
26  GetLine *gl;
27  long i = 50;
28 
30  if (i < 0)
31  i = 0;
32 
33  gl = new_GetLine(200, i * 40);
34  if (gl) {
35  context->osd = (struct osdContext *) gl;
36  if (context->in)
37  gl_change_terminal(gl, context->in, stdout, NULL);
38  }
39 }
40 
41 /*
42  * Read a line of input
43  */
44 static char *
45 osdReadline (const char *prompt, struct readlineContext *context)
46 {
47  GetLine *gl = (GetLine *) context->osd;
48  char *line;
49 
50  line = gl_get_line(gl, prompt ? prompt : "", NULL, -1);
51  if (line) {
52  char *nl = strchr(line, '\n');
53 
54  if (nl)
55  *nl = '\0';
56  }
57  return line;
58 }
59 
60 /*
61  * Destroy a command-line context
62  */
63 static void
64 osdReadlineEnd(struct readlineContext *context)
65 {
66  GetLine *gl = (GetLine *) context->osd;
67 
68  del_GetLine(gl);
69 }
70 
int i
Definition: scan.c:967
#define NULL
Definition: catime.c:38
LIBCOM_API const ENV_PARAM IOCSH_HISTSIZE
char * line
Definition: reader.c:25
#define stdout
Definition: epicsStdio.h:30
LIBCOM_API long epicsStdCall envGetLongConfigParam(const ENV_PARAM *pParam, long *pLong)
Get value of a long configuration parameter.
Definition: envSubr.c:303
struct osdContext * osd
Definition: epicsReadline.c:38