Initial revision
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@37 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
		
							
								
								
									
										31
									
								
								lib/des/gethostid.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								lib/des/gethostid.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Some systems doesn't have gethostid(2) (e.g Solaris if you don't
 | 
				
			||||||
 | 
					 * link with libucb - and we don't want that...
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * $Id$
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "config.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef HAVE_GETHOSTID
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					#include <sys/systeminfo.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					long gethostid(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  static int flag=0;
 | 
				
			||||||
 | 
					  static long hostid;
 | 
				
			||||||
 | 
					  if(!flag){
 | 
				
			||||||
 | 
					    char s[32];
 | 
				
			||||||
 | 
					    sysinfo(SI_HW_SERIAL, s, 32);
 | 
				
			||||||
 | 
					    sscanf(s, "%u", &hostid);
 | 
				
			||||||
 | 
					    flag=1;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return hostid;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
		Reference in New Issue
	
	Block a user