ref: 215bd037edbcdbd6e10c39e496ee95ee849ca972
parent: 20e6eb83a93fc28b5add875f112fe252cd221b51
author: Erik de Castro Lopo <erikd@mega-nerd.com>
date: Fri Sep 26 10:09:15 EDT 2008
tests/util.[ch] : Add function print_cpu_name.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-09-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * tests/util.[ch]
+ Add function print_cpu_name.
+
2008-09-17 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* configure.ac
--- a/tests/util.c
+++ b/tests/util.c
@@ -18,6 +18,8 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
#include <math.h>
#include "util.h"
@@ -163,4 +165,35 @@
} ;
} /* reverse_data */
+
+void
+print_cpu_name (void)
+{ char buffer [512] ;
+ FILE * file ;
+
+ if ((file = fopen ("/proc/cpuinfo", "r")) == NULL)
+ { puts ("Unknown") ;
+ return ;
+ } ;
+
+ while (fgets (buffer, sizeof (buffer), file) != NULL)
+ if (strstr (buffer, "model name") == buffer)
+ { const char * cptr ;
+
+ if ((cptr = strchr (buffer, ':')) != NULL)
+ { cptr ++ ;
+ while (isspace (cptr [0])) cptr ++ ;
+ printf ("%s", cptr) ;
+ goto complete ;
+ } ;
+ } ;
+
+ goto failed ;
+complete :
+ fclose (file) ;
+ return ;
+failed :
+ puts ("Unknown") ;
+ return ;
+} /* print_cpu_name */
--- a/tests/util.h
+++ b/tests/util.h
@@ -35,6 +35,8 @@
double calculate_snr (float *data, int len, int expected_peaks) ;
+void print_cpu_name (void) ;
+
#if OS_IS_WIN32
/*
** Extra Win32 hacks.