The very beginnings of the new user-space application

It doesn't do much yet, but at least it compiles and links...


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@99 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Frodo Looijaard committed 1998-12-21 16:49:11 +00:00
1 parent f26b52021b
commit b10d66cc58
5 files changed
+230 -3

No files matched your search

+1 -1
View File
@@ -95,7 +95,7 @@ LIBINCLUDEDIR := $(INCLUDEDIR)/sensors
# to do this.
# The subdirectories we need to build things in
SRCDIRS := src lib
SRCDIRS := src lib prog/sensors
ifeq ($(I2C),1)
SRCDIRS += i2c i2c/detect i2c/drivers i2c/eeprom
endif
+10 -1
View File
@@ -32,7 +32,8 @@ LIBSHLIBNAME := libsensors.so.$(LIBVER)
LIBSTLIBNAME := libsensors.a
LIBSHSONAME := libsensors.so.$(LIBMAINVER)
LIBTARGETS := $(MODULE_DIR)/$(LIBSTLIBNAME) $(MODULE_DIR)/$(LIBSHLIBNAME)
LIBTARGETS := $(MODULE_DIR)/$(LIBSTLIBNAME) $(MODULE_DIR)/$(LIBSHLIBNAME) \
$(MODULE_DIR)/$(LIBSHSONAME) $(MODULE_DIR)/$(LIBSHBASENAME)
LIBCSOURCES := $(MODULE_DIR)/data.c $(MODULE_DIR)/general.c \
$(MODULE_DIR)/error.c $(MODULE_DIR)/chips.c \
@@ -49,6 +50,14 @@ LIBHEADERFILES := $(MODULE_DIR)/error.h $(MODULE_DIR)/sensors.h
$(MODULE_DIR)/$(LIBSHLIBNAME): $(LIBSHOBJECTS)
$(CC) -shared -Wl,-soname,$(LIBSHSONAME) -o $@ $^ -lc
$(MODULE_DIR)/$(LIBSHSONAME): $(MODULE_DIR)/$(LIBSHLIBNAME)
$(RM) $@
$(LN) $(LIBSHLIBNAME) $@
$(MODULE_DIR)/$(LIBSHBASENAME): $(MODULE_DIR)/$(LIBSHLIBNAME)
$(RM) $@
$(LN) $(LIBSHLIBNAME) $@
# And the static library
$(MODULE_DIR)/$(LIBSTLIBNAME): $(LIBSTOBJECTS)
$(RM) $@
+1 -1
View File
@@ -23,7 +23,7 @@
#include "sensors.h"
/* This header file contains all kinds of data structures which are used
for the representation of the config file data and the /proc/.../chips
for the representation of the config file data and the /proc/...
data. */
typedef enum sensors_operation {
+47
View File
@@ -0,0 +1,47 @@
# Module.mk - Makefile for a Linux module for reading sensor data.
# Copyright (c) 1998 Frodo Looijaard <frodol@dds.nl>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# Note that MODULE_DIR (the directory in which this file resides) is a
# 'simply expanded variable'. That means that its value is substituted
# verbatim in the rules, until it is redefined.
MODULE_DIR := prog/sensors
# Regrettably, even 'simply expanded variables' will not put their currently
# defined value verbatim into the command-list of rules...
PROGSENSORSTARGETS := $(MODULE_DIR)/sensors
PROGSENSORSSOURCES := $(MODULE_DIR)/main.c
# Include all dependency files. We use '.rd' to indicate this will create
# executables.
INCLUDEFILES += $(PROGSENSORSSOURCES:.c=.rd)
$(PROGSENSORSTARGETS): $(PROGSENSORSSOURCES:.c=.ro) lib/$(LIBSHBASENAME)
$(CC) -o $@ $^ -Llib -lsensors
all-prog-sensors: $(PROGSENSORSTARGETS)
all :: all-prog-sensors
# No install rule
install-prog-sensors:
mkdir -p $(BINDIR)
$(INSTALL) -o root -g root -m 755 $(PROGSENSORSTARGETS) $(BINDIR)
install :: install-prog-sensors
clean-prog-sensors:
$(RM) $(PROGSENSORSSOURCES:.c=.rd) $(PROGSENSORSSOURCES:.c=.ro) \
$(PROGSENSORSTARGETS)
clean :: clean-prog-sensors
+171
View File
@@ -0,0 +1,171 @@
/*
main.c - Part of sensors, a user-space program for hardware monitoring
Copyright (c) 1998 Frodo Looijaard <frodol@dds.nl>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <string.h>
#include <errno.h>
#include "lib/sensors.h"
#include "lib/error.h"
#define PROGRAM "sensors"
#define VERSION "0.0"
#define DEFAULT_CONFIG_FILE_NAME "sensors.conf"
static char *config_file_name;
FILE *config_file;
static const char *config_file_path[] =
{ "/etc", "/usr/lib/sensors", "/usr/local/lib/sensors", "/usr/lib",
"/usr/local/lib", ".", 0 };
extern int main(int argc, char *arv[]);
static void print_short_help(void);
static void print_long_help(void);
static void print_version(void);
static void open_config_file(void);
static int open_this_config_file(char *filename);
void print_short_help(void)
{
printf("Try `%s -h' for more information\n",PROGRAM);
}
void print_long_help(void)
{
printf("Usage: %s [OPTION]...\n",PROGRAM);
printf(" -c, --config-file Specify a config file\n");
printf(" -h, --help Display this help text\n");
printf(" -v, --version Display the program version\n");
printf("\n");
printf("By default, a list of directories is examined for the config file `sensors.conf'\n");
printf("Use `-' after `-c' to read the config file from stdin\n");
}
void print_version(void)
{
printf("%s version %s\n", PROGRAM, VERSION);
}
/* This examines global var config_file, and leaves the name there too.
It also opens config_file. */
void open_config_file(void)
{
#define MAX_FILENAME_LEN 1024
char *filename;
char buffer[MAX_FILENAME_LEN];
int res,i;
if (config_file_name && !strcmp(config_file_name,"-")) {
config_file = stdin;
return;
} else if (config_file_name && index(config_file_name,'/')) {
if ((res = open_this_config_file(config_file_name))) {
fprintf(stderr,"Could not locate or open config file\n");
fprintf(stderr,"%s: %s\n",config_file_name,strerror(res));
exit(1);
}
}
else {
if (config_file_name)
filename = config_file_name;
else
filename = strdup(DEFAULT_CONFIG_FILE_NAME);
for (i = 0; config_file_path[i]; i++) {
if ((snprintf(buffer,MAX_FILENAME_LEN,
"%s/%s",config_file_path[i],filename)) < 1) {
fprintf(stderr,
"open_config_file: ridiculous long config file name!\n");
exit(1);
}
if (!open_this_config_file(buffer)) {
free(config_file_name);
config_file_name = strdup(buffer);
return;
}
}
fprintf(stderr,"Could not locate or open config file!\n");
exit(1);
}
}
int open_this_config_file(char *filename)
{
config_file = fopen(filename,"r");
if (! config_file)
return -errno;
return 0;
}
int main (int argc, char *argv[])
{
int c;
struct option long_opts[] = {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'v'},
{ "config-file", required_argument, NULL, 'c' }
};
while (1) {
c = getopt_long(argc,argv,"hvc:",long_opts,NULL);
if (c == EOF)
break;
switch(c) {
case ':':
case '?':
print_short_help();
exit(1);
case 'h':
print_long_help();
exit(0);
case 'v':
print_version();
exit(0);
case 'c':
config_file_name = strdup(optarg);
break;
default:
fprintf(stderr,"Internal error while parsing options!\n");
}
}
open_config_file();
exit(0);
}
/*
if ((res = sensors_init(stdin))) {
if (res == SENSORS_ERR_PROC)
fprintf(stderr,
"/proc/sys/dev/sensors/chips or /proc/bus/i2c unreadable:\n"
"Make sure you have inserted modules sensors.o and i2c-proc.o!");
else
fprintf(stderr,"%s\n",sensors_strerror(res));
exit(1);
}
for (i = 0; i < sensors_proc_bus_count; i++)
printf("%d: %s %s\n",sensors_proc_bus[i].number,
sensors_proc_bus[i].adapter,sensors_proc_bus[i].algorithm);
}
*/