-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetver.c
More file actions
58 lines (53 loc) · 1.48 KB
/
Copy pathgetver.c
File metadata and controls
58 lines (53 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
#include <sys/wait.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#ifdef CRAY
#define _cptofcd(c, l) ((char *)((((long)(c))&0xfc000000ffffffff) | \
((((long)(l))&0x7fffff)<<35)))
#define _fcdtocp(f) ((char *)(((long)(f))&0xfc000000ffffffff))
#define _fcdlen(f) ((unsigned)((((long)(f))>>35)&0x7fffff))
#else
#define vfork (fork)
#define _cptofcd(c, l) ((char *)c)
#define _fcdtocp(f) ((char *)f)
#define _fcdlen(f) (strlen(f))
#endif
int archpid = 0;
#ifdef CRAY
void ADDVER( char *base, char *suf, int *iver, char *filename, int *length )
#else
void addver_( char *base, char *suf, int *iver, char *filename, int *length )
#endif
{
if ( sprintf(filename,"%s.%s.%d",_fcdtocp(base),_fcdtocp(suf),*iver) >
*length-1 ) {
printf("Error in addver...\n");
printf(" Needed string length greater that %d.\n",*length);
printf(" Increase string length in calling routine\n\n");
exit(1);
}
filename = _cptofcd(filename,*length);
}
#ifdef CRAY
int IGETVER( char *base, char *suf )
#else
int igetver_( char *base, char *suf )
#endif
{
FILE *istr;
char command[256], line[256];
int iver=0;
sprintf(command,"verlist %s.%s 0 0\n", _fcdtocp(base), _fcdtocp(suf) );
istr = popen(command,"r");
fgets(line,256,istr);
pclose(istr);
sscanf(line,"%d",&iver);
if ( strlen(line) < 1 ) iver = 0;
return iver;
}