R
rudra
I have 2 subroutine in c(which is ultimately called by fortran):
$ cat bit_unm.c
/***********************************************
This code returns the machine bit
to the program bitinit
***********************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int operating_system(char *sys) {
FILE *stream;
char *sysptr;
int bit;
sysptr = &sys[0];
sys[0] = 0x0;
stream = popen("/bin/uname -snm", "r");
fread(sysptr, 1, 32, stream);
pclose(stream);
return bit;
}
and$ cat nis.c
/***********************************************
This code returns the machine bit
to the program bitinit
***********************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int operating_sys(char *nis ){
FILE *stream;
char *sysptr;
int bit;
sysptr = &nis[0];
nis[6] = 0x0;
stream=popen("/bin/nisdomainname","r");
fread(sysptr,1,15,stream);
pclose(stream);
return bit;
}
As it is seen this two are doing almost same thing except the unix
command in popen.
is it possible to make it a single routine where the unix command
nisdomainname or uname will be an argument?
$ cat bit_unm.c
/***********************************************
This code returns the machine bit
to the program bitinit
***********************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int operating_system(char *sys) {
FILE *stream;
char *sysptr;
int bit;
sysptr = &sys[0];
sys[0] = 0x0;
stream = popen("/bin/uname -snm", "r");
fread(sysptr, 1, 32, stream);
pclose(stream);
return bit;
}
and$ cat nis.c
/***********************************************
This code returns the machine bit
to the program bitinit
***********************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int operating_sys(char *nis ){
FILE *stream;
char *sysptr;
int bit;
sysptr = &nis[0];
nis[6] = 0x0;
stream=popen("/bin/nisdomainname","r");
fread(sysptr,1,15,stream);
pclose(stream);
return bit;
}
As it is seen this two are doing almost same thing except the unix
command in popen.
is it possible to make it a single routine where the unix command
nisdomainname or uname will be an argument?