PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
getDec.c
1 /*
2  * @file getDec.c
3  * Function to get decimal number from the terminal.
4  *
5  * Copyright (c) 2013, Parallax Inc.
6  * Written by Steve Denson
7  */
8 #include <limits.h>
9 #include "simpletext.h"
10 
11 int getDec(void)
12 {
13  extern text_t *dport_ptr;
14  return readDec(dport_ptr);
15 }
16 
17 int readDec(text_t *text)
18 {
19  int rc = 0;
20  char buf[40];
21  char *str = _safe_gets(text, buf, 39);
22  if(*str)
23  _scanf_getl(str, &rc, 10, 11, 1); /* signed */
24  return rc;
25 }
26 
27 /*
28 +--------------------------------------------------------------------
29 | TERMS OF USE: MIT License
30 +--------------------------------------------------------------------
31 Permission is hereby granted, free of charge, to any person obtaining
32 a copy of this software and associated documentation files
33 (the "Software"), to deal in the Software without restriction,
34 including without limitation the rights to use, copy, modify, merge,
35 publish, distribute, sublicense, and/or sell copies of the Software,
36 and to permit persons to whom the Software is furnished to do so,
37 subject to the following conditions:
38 
39 The above copyright notice and this permission notice shall be
40 included in all copies or substantial portions of the Software.
41 
42 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
43 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
46 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
47 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
48 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
49 +--------------------------------------------------------------------
50 */
getDec
int getDec(void)
Get decimal number from the debug port.
Definition: getDec.c:11
readDec
int readDec(text_t *device)
Get decimal number from the device.
Definition: getDec.c:17
simpletext.h
This library provides a collection of functions for communicating with text devices such as SimpleIDE...
text_struct
Structure that contains data used by simple text device libraries.
Definition: simpletext.h:81