A Cardiovascular Simulator for Research 1.0.0

File: <base>/src/check_redhat.c (985 bytes)
/* The function check_redhat.c determines whether Linux Redhat 6.2
   or greater is installed.  If so, libc5 libraries and linker will
   be installed (if argument is set to install) or uninstalled (if
   argument is set to uninstall).

   Function argument: either install or uninstall

   Function outputs: none 

   Compilation line: gcc -o check_redhat check_redhat.c */

#include <stdio.h>
#include <unistd.h>
#include <string.h>

main (argc, argv)
     int argc;
     char **argv;	
{
    char tmp[128];
    float version;
    FILE *fd;

    fd = fopen("/etc/redhat-release","r");

    if (fd != 0)
    {
	
	fscanf(fd,"%s %s %s %s %f %s\n",tmp,tmp,tmp,tmp,&version,tmp);
	if (!strcmp(argv[1],"install"))
	{

		if (version > 6.1)
		{
		    system("rpm -ivvh lib/libc-5.3.12-31.i386.rpm lib/ld.so-1.9.5-13.i386.rpm");
		}
	}
	    else if (!strcmp(argv[1],"uninstall"))
	{

	    	    if (version > 6.1)
		    {
			system("rpm -e libc-5.3.12-31 ld.so-1.9.5-13"); 
		    }
	}
    }

}