1
/* Copyright (C) 2000 Damir Zucic */
3
/*=============================================================================
8
Extract slab steps (five doubles) from a string.
11
(1) Pointer to ConfigS structure, where values will be stored.
12
(2) Input string pointer.
18
(1) Positive on success.
19
(2) Negative on failure.
21
========includes:============================================================*/
27
#include <X11/Xutil.h>
29
#include <X11/Xatom.h>
34
/*======extract slab steps from a string:====================================*/
36
int ExtractSlabSteps_ (ConfigS *configSP, char *sP)
40
double d1, d2, d3, d4, d5;
42
/* Colon should be separator: */
43
if ((P0 = strstr (sP, ":")) == NULL) P0 = sP;
45
/* Replace each non-numeric character (except */
46
/* minus sign and decimal point) with space: */
48
while ((n = *P1++) != '\0')
50
if (!isdigit (n) && (n != '-') && (n != '.')) *(P1 - 1) = ' ';
53
/* Try to read five doubles: */
54
if (sscanf (P0, "%lf %lf %lf %lf %lf", &d1, &d2, &d3, &d4, &d5) != 5)
59
/* Copy slab steps to ConfigS: */
60
configSP->slab_stepA[0] = d1;
61
configSP->slab_stepA[1] = d2;
62
configSP->slab_stepA[2] = d3;
63
configSP->slab_stepA[3] = d4;
64
configSP->slab_stepA[4] = d5;
66
/* If everything worked fine, return positive number: */
70
/*===========================================================================*/