2 * Copyright (C) 2001 Yan "Warrior" Gurtovoy (ymg@azstarnet.com)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 void str2upper(char *str) {
26 /* converts given string to upper case */
28 while (str[i]) toupper(str[i++]);
32 void str2lower(char *str) {
33 /* converts given string to lower case */
35 while (str[i]) tolower(str[i++]);
39 /* callback functions */
41 void rc_get_bytes(tty_struct *ptr, char *value) {
43 ptr->dspbytes = strcmp(ON, value) ? FALSE : TRUE;
47 void rc_get_tstamp(tty_struct *ptr, char *value) {
49 ptr->tstamp = strcmp(ON, value) ? FALSE : TRUE;
53 void rc_get_nolock(tty_struct *ptr, char *value) {
55 ptr->nolock = strcmp(ON, value) ? FALSE : TRUE;
59 void rc_get_color(tty_struct *ptr, char *value) {
63 clr = getColor(value);
64 if (clr) strcat(ptr->clr, clr);
68 void rc_get_timecolor(tty_struct *ptr, char *value) {
72 clr = getColor(value);
73 if (clr) strcat(ptr->tclr, clr);
77 void rc_get_bytescolor(tty_struct *ptr, char *value) {
81 clr = getColor(value);
82 if (clr) strcat(ptr->bclr, clr);
86 /* end of callback functions */
88 void readRC(tty_struct *ptr) {
89 /* read settings from rc-file .slsnifrc */
92 char name[NAMELEN + 1];
93 char value[VALUELEN + 1];
97 /* get path to the rc-file */
98 sprintf(buffer, "%s/%s", getenv("HOME"), RCFNAME);
99 /* try to open rc-file */
100 if (!(fp = fopen(buffer, "r"))) {
103 /* read rc-file line by line */
104 while (fgets(buffer, 256, fp)) {
105 /* check for comments */
106 if (buffer[0] != '#') {
108 sscanf(buffer, "%s %[^\n]", name, value);
110 /* if identificator is valid, process data */
111 while (rc_data[i].name && strcmp(rc_data[i].name, name)) i++;
112 if (rc_data[i].name) rc_data[i].fn(ptr, value);