Visual Servoing Platform
version 3.6.1 under development (2024-11-15)
vpMyio.cpp
1
/****************************************************************************
2
*
3
* ViSP, open source Visual Servoing Platform software.
4
* Copyright (C) 2005 - 2023 by Inria. All rights reserved.
5
*
6
* This software is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
10
* See the file LICENSE.txt at the root directory of this source
11
* distribution for additional information about the GNU GPL.
12
*
13
* For using ViSP with software that can not be combined with the GNU
14
* GPL, please contact Inria about acquiring a ViSP Professional
15
* Edition License.
16
*
17
* See https://visp.inria.fr for more information.
18
*
19
* This software was developed at:
20
* Inria Rennes - Bretagne Atlantique
21
* Campus Universitaire de Beaulieu
22
* 35042 Rennes Cedex
23
* France
24
*
25
* If you have questions regarding the use of this file, please contact
26
* Inria at visp@inria.fr
27
*
28
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30
*
31
* Description:
32
* Le module "myio.c" contient les procedures d'entree/sortie
33
* des types definis dans le module "my.h".
34
* Les entrees non specifiees sont effectuees
35
* sur le fichier "source" du module "lex.c".
36
* Pour les mots cles des "fprintf_..." voir "token.c".
37
*
38
* Authors:
39
* Jean-Luc CORRE
40
*
41
*****************************************************************************/
42
43
#include "vpMyio.h"
44
#include "vpLex.h"
45
#include "vpToken.h"
46
47
#include <stdio.h>
48
#include <stdlib.h>
49
#include <string.h>
50
51
#ifndef DOXYGEN_SHOULD_SKIP_THIS
52
53
extern
char
*mytext;
/* chaine du symbole courant */
54
55
BEGIN_VISP_NAMESPACE
56
/*
57
* La procedure "fscanf_float" lit en ascii un nombre flottant.
58
* Entree :
59
* fp Nombre flottant a lire.
60
*/
61
void
fscanf_float(
float
*fp)
62
{
63
int
t;
64
65
if
((t = lex()) != T_FLOAT && t != T_INT)
66
lexerr(
"start"
,
"float expected"
, NULL);
67
*fp = (t == T_INT) ? (
float
)myint : myfloat;
68
}
69
70
/*
71
* La procedure "fscanf_Index" lit en ascii un indice.
72
* Entree :
73
* ip Indice a lire.
74
*/
75
void
fscanf_Index(Index *ip)
76
{
77
if
(lex() != T_INT)
78
lexerr(
"start"
,
"integer expected"
, NULL);
79
*ip = (Index)myint;
80
}
81
82
/*
83
* La procedure "fscanf_int" lit en ascii un nombre entier.
84
* Entree :
85
* ip Nombre entier a lire.
86
*/
87
void
fscanf_int(
int
*ip)
88
{
89
if
(lex() != T_INT)
90
lexerr(
"start"
,
"integer expected"
, NULL);
91
*ip = myint;
92
}
93
94
/*
95
* La procedure "fscanf_string" lit en ascii une chaine de caracteres.
96
* Entree :
97
* str Chaine a lire.
98
*/
99
void
fscanf_string(
char
**str)
100
{
101
if
(lex() != T_STRING)
102
lexerr(
"start"
,
"string expected"
, NULL);
103
if
(*str == NULL)
104
*str = (
char
*)malloc((
size_t
)(mylength + 1) *
sizeof
(
char
));
105
else
106
*str = (
char
*)realloc(*str, (
size_t
)(mylength + 1) *
sizeof
(
char
));
107
108
if
(*str == NULL) {
109
printf(
"Unable to read the string: bad memory allocation"
);
110
return
;
111
}
112
113
strncpy(*str, mytext, (
size_t
)mylength);
114
}
115
116
/*
117
* La procedure "fscanf_Type" lit en ascii un octet.
118
* Entree :
119
* ip Type a lire.
120
*/
121
void
fscanf_Type(Type *ip)
122
{
123
if
(lex() != T_INT)
124
lexerr(
"start"
,
"integer expected"
, NULL);
125
*ip = (Type)myint;
126
}
127
END_VISP_NAMESPACE
128
#endif
visp
modules
robot
src
wireframe-simulator
vpMyio.cpp
Generated by
1.9.1