Update of /cvsroot/agd/server/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13694
Modified Files:
sys.c sys.h
Log Message:
Cleaned up; removed log.c [and debug()]; to_power(); renamed stringdup to xstrdup
Index: sys.h
===================================================================
RCS file: /cvsroot/agd/server/src/sys.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- sys.h 14 Jun 2004 20:48:08 -0000 1.11
+++ sys.h 23 Jul 2004 17:05:40 -0000 1.12
@@ -4,28 +4,24 @@
/* memory allocation */
void *xmalloc(size_t bytes);
void *xrealloc(void *ptr, size_t bytes);
+char *xstrdup(char *s);
/* configuration */
typedef struct {
int port, heartbeat;
- char *lib_root, *error_log;
+ char *lib_root;
char *master;
int debuglevel;
} config_t;
-
extern config_t conf;
-int legal_path(char *fn);
-
-char *stringdup(char *s);
-
#define max(i, j) i > j ? i : j
+int to_power(int base, int pow);
+int legal_path(char *fn);
char *add_extension(char *str);
char *absolute_path(char *path);
-/* Defined in log.c */
-int check_logfile(void);
-void debug(char *prefix, char *fmt, ...);
+void crash(int sig, char *reason, int retval);
#endif
Index: sys.c
===================================================================
RCS file: /cvsroot/agd/server/src/sys.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- sys.c 23 Jul 2004 14:22:43 -0000 1.18
+++ sys.c 23 Jul 2004 17:05:40 -0000 1.19
@@ -57,19 +57,13 @@
if(strncmp(buf, "lib:", 4) == 0) {
fscanf(f, "%s\n", buf);
- conf.lib_root = stringdup(buf);
- continue;
- }
-
- if(strncmp(buf, "errorlog:", 10) == 0) {
- fscanf(f, "%s\n", buf);
- conf.error_log = stringdup(buf);
+ conf.lib_root = xstrdup(buf);
continue;
}
if(strncmp(buf, "master:", 8) == 0) {
fscanf(f, "%s\n", buf);
- conf.master = stringdup(buf);
+ conf.master = xstrdup(buf);
continue;
}
@@ -87,7 +81,6 @@
CONFCHECK(conf.port, "port");
CONFCHECK(conf.heartbeat, "heartbeat");
CONFCHECK(conf.lib_root, "lib");
-/* CONFCHECK(conf.error_log, "errorlog");*/
CONFCHECK(conf.master, "master");
}
@@ -125,7 +118,7 @@
}
/* strdup() isn't ANSI, so we need this replacement. */
-char *stringdup(char *s)
+char *xstrdup(char *s)
{
char *p = xmalloc(strlen(s) + 1);
strcpy(p, s);
@@ -140,7 +133,7 @@
p = str + len - 5;
if(strcmp(p, ".lpc") == 0)
- return stringdup(buf);
+ return xstrdup(buf);
buf = xmalloc(len + 5);
sprintf(buf, "%s.lpc", str);
@@ -155,3 +148,22 @@
s = strcat(s, path);
return s;
}
+
+int to_power(int base, int pow)
+{
+ int i, ret;
+ if(base == 0)
+ return 0;
+ if(pow == 0)
+ return 1;
+ if(pow == 1)
+ return base;
+ if(base == 2)
+ return 2 << pow - 1;
+
+ ret = base;
+ for(i=0;i<pow-1;i++) {
+ ret *= base;
+ }
+ return ret;
+}
|