Enlightenment CVS committal
Author : atmosphere
Project : misc
Module : engage
Dir : misc/engage/src
Modified Files:
userconfig.c
Log Message:
load applinks even if you don't have a mapping file, break the reading of the two
files out into functions
===================================================================
RCS file: /cvsroot/enlightenment/misc/engage/src/userconfig.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- userconfig.c 21 Apr 2004 04:27:13 -0000 1.2
+++ userconfig.c 25 Apr 2004 20:00:21 -0000 1.3
@@ -10,42 +10,17 @@
#define engage_conf "/.e/apps/engage/applinks"
#define engage_mappings "/.e/apps/engage/mappings"
-int
-userconfig_load()
+static void
+userconfig_mappings_load(FILE * fp)
{
- FILE *fd = NULL;
- char *homepath = NULL;
- char *filename = NULL;
char *line = NULL;
- char *exe = NULL;
+ size_t len = 0;
+ size_t read = 0;
char *name = NULL;
char *class = NULL;
char *icon = NULL;
- size_t len = 0;
- size_t read = 0;
-
- /* getting user environement */
- homepath = (char *) getenv("HOME");
-
- /* malloc for the config filename */
- filename =
- (char *) malloc(sizeof(char) *
- (strlen(homepath) + strlen(engage_mappings)) + 1);
- memset(filename, 0, (strlen(homepath) + strlen(engage_mappings) + 1));
-
- /* filename is the string containing the full path for config file */
- filename = strcat(filename, homepath);
- filename = strcat(filename, engage_mappings);
-
- /* opening filename in read mode */
- fd = fopen(filename, "r");
-
- /* check that filename is open(able) */
- if (fd == NULL)
- return (1);
- /* reading filename while EOF */
- while ((read = getline(&line, &len, fd)) != -1) {
+ while ((read = getline(&line, &len, fp)) != -1) {
if (*line == '#' || *line == '\n')
continue;
/* stripping line return */
@@ -67,34 +42,19 @@
if (line)
free(line);
line = NULL;
+}
- if (filename)
- free(filename);
-
- /* close filename */
- fclose(fd);
-
-
-
-
- /* malloc for the config filename */
- filename =
- (char *) malloc(sizeof(char) * (strlen(homepath) + strlen(engage_conf)) +
- 1);
- memset(filename, 0, (strlen(homepath) + strlen(engage_conf) + 1));
-
- /* filename is the string containing the full path for config file */
- filename = strcat(filename, homepath);
- filename = strcat(filename, engage_conf);
-
- /* opening filename in read mode */
- fd = fopen(filename, "r");
+static void
+userconfig_applinks_load(FILE * fp)
+{
+ char *line = NULL;
+ size_t len = 0;
+ size_t read = 0;
+ char *exe = NULL;
+ char *name = NULL;
+ char *icon = NULL;
- /* check that filename is open(able) */
- if (fd == NULL)
- return (1);
- /* reading filename while EOF */
- while ((read = getline(&line, &len, fd)) != -1) {
+ while ((read = getline(&line, &len, fp)) != -1) {
if (*line == '#' || *line == '\n')
continue;
/* stripping line return */
@@ -119,13 +79,24 @@
/* cleaning memory */
if (line)
free(line);
+}
- if (filename)
- free(filename);
-
- /* close filename */
- fclose(fd);
+int
+userconfig_load()
+{
+ FILE *fd = NULL;
+ char filename[PATH_MAX];
+ snprintf(filename, PATH_MAX, "%s/.e/apps/engage/mappings", getenv("HOME"));
+ if ((fd = fopen(filename, "r"))) {
+ userconfig_mappings_load(fd);
+ fclose(fd);
+ }
+ snprintf(filename, PATH_MAX, "%s/.e/apps/engage/applinks", getenv("HOME"));
+ if ((fd = fopen(filename, "r"))) {
+ userconfig_applinks_load(fd);
+ fclose(fd);
+ }
/* nothing special */
return (0);
}
-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek
For a limited time only, get FREE Ground shipping on all orders of $35
or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs