TPCCLIB
Toggle main menu visibility
Loading...
Searching...
No Matches
libtpctac
tacname.c
Go to the documentation of this file.
1
4
/*****************************************************************************/
5
#include "tpcclibConfig.h"
6
/*****************************************************************************/
7
#include "
tpcift.h
"
8
/*****************************************************************************/
9
#include <stdio.h>
10
#include <stdlib.h>
11
#include <math.h>
12
#include <time.h>
13
#include <string.h>
14
/*****************************************************************************/
15
#include "
tpctac.h
"
16
/*****************************************************************************/
17
18
/*****************************************************************************/
24
int
tacIndividualNames
(
26
TAC
*tac
27
) {
28
if
(tac==NULL || tac->
tacNr
<1)
return
(0);
29
int
ri, rj;
30
/* First check that names do exist */
31
for
(ri=0; ri<tac->
tacNr
; ri++) {
32
if
(!
roinameExists
(tac->
c
[ri].
name
))
return
(0);
33
}
34
/* If just one TAC, then its name is individual */
35
if
(tac->
tacNr
==1)
return
(1);
36
/* Otherwise compare each of the names */
37
for
(ri=0; ri<tac->
tacNr
-1; ri++)
38
for
(rj=ri+1; rj<tac->
tacNr
; rj++)
39
if
(strcasecmp(tac->
c
[ri].
name
, tac->
c
[rj].
name
)==0)
return
(0);
40
return
(1);
41
}
42
/*****************************************************************************/
43
44
/*****************************************************************************/
50
void
tacEnsureNames
(
52
TAC
*tac
53
) {
54
if
(tac==NULL || tac->
tacNr
<1)
return
;
55
int
ri, u, n;
56
u=tac->
tacNr
; n=1;
while
((u/=10)>=1) n++;
57
if
(n>
MAX_TACNAME_LEN
) n=
MAX_TACNAME_LEN
;
58
for
(ri=0; ri<tac->
tacNr
; ri++) {
59
if
(!
roinameExists
(tac->
c
[ri].
name
))
60
sprintf(tac->
c
[ri].
name
,
"%0*d"
, n, 1+ri);
61
}
62
return
;
63
}
64
/*****************************************************************************/
65
66
/*****************************************************************************/
roinameExists
int roinameExists(char *roiname)
Verifies whether TAC name exists or not.
Definition
roiname.c:158
TACC::name
char name[MAX_TACNAME_LEN+1]
Definition
tpctac.h:81
TAC
Definition
tpctac.h:87
TAC::c
TACC * c
Definition
tpctac.h:117
TAC::tacNr
int tacNr
Definition
tpctac.h:91
tacEnsureNames
void tacEnsureNames(TAC *tac)
Definition
tacname.c:50
tacIndividualNames
int tacIndividualNames(TAC *tac)
Definition
tacname.c:24
MAX_TACNAME_LEN
#define MAX_TACNAME_LEN
Max length of TAC ID name (not including trailing zero).
Definition
tpcextensions.h:35
tpcift.h
Header file for library libtpcift.
tpctac.h
Header file for library libtpctac.
Generated on
for TPCCLIB by
1.17.0