aboutsummaryrefslogtreecommitdiff
path: root/packages/patches/libdir-0.38-4.patch
blob: f3f85347047e8598191d424f7638b00fe9611fbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
Index: s_loader.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_loader.c,v
retrieving revision 1.6
diff -u -w -r1.6 s_loader.c
--- s_loader.c	30 May 2005 03:04:19 -0000	1.6
+++ s_loader.c	28 Nov 2006 03:59:50 -0000
@@ -172,3 +175,83 @@
 
 
 
+/* <hans@at.or.at> { */
+
+/*
+ * This function opens a directory as a library.  In the long run, the idea is
+ * that one folder will have all of objects files, all of the related
+ * *-help.pd files, a file with meta data for the help system, etc.  Then to
+ * install the lib, it would just be dropped into extra, or the path anywhere.
+ * <hans@at.or.at>
+ */
+
+int sys_load_lib_dir(char *dirname, char *classname)
+{
+    int fd = -1;
+    char searchpathname[MAXPDSTRING], helppathname[MAXPDSTRING], 
+        fullclassname[MAXPDSTRING], dirbuf[MAXPDSTRING], *nameptr;
+    
+#if 0
+    fprintf(stderr, "sys_load_lib_directory %s %s\n", dirname, classname);
+#endif
+
+/* look for meta file (classname)/(classname)-meta.pd */
+	strncpy(fullclassname, classname, MAXPDSTRING - 6);
+	strcat(fullclassname, "/");
+	strncat(fullclassname, classname, MAXPDSTRING - strlen(fullclassname) - 6);
+	strcat(fullclassname, "-meta");
+    if ((fd = open_via_path(dirname, fullclassname, ".pd",
+                            dirbuf, &nameptr, MAXPDSTRING, 1)) < 0)
+    {
+        return (0);
+    }
+    close(fd);
+    
+    /* Ultimately, the meta file will be read for meta data, specifically for
+     * the auto-generated Help system, but for other things too.  Right now,
+     * its just used as a marker that a directory is meant to be a library.
+     * Plus its much easier to implement it this way, I can use
+     * open_via_path() instead of writing a new function.  The grand plan is
+     * to have one directory hold the objects, help files, manuals,
+     * etc. making it a self-contained library. <hans@at.or.at>
+     */
+
+#if 0
+    fprintf(stderr, "sys_load_lib_directory %s %s\n", dirname, classname);
+#endif
+        /* create full path to libdir for adding to the paths */
+    strcpy(searchpathname,dirbuf);
+//    strcat(searchpathname,"/");
+//    strncat(searchpathname,classname, MAXPDSTRING-strlen(searchpathname));
+
+    strncpy(helppathname, sys_libdir->s_name, MAXPDSTRING-30);
+    helppathname[MAXPDSTRING-30] = 0;
+    strcat(helppathname, "/doc/5.reference/");
+    strcat(helppathname, classname);
+
+    sys_searchpath = namelist_append_files(sys_searchpath, searchpathname);
+    /* this help path supports having the help files in a complete library
+     * directory format, where everything is in one folder.  The help meta
+     * system needs to be implemented for this to work with the new Help
+     * menu/browser system. Ultimately, /path/to/extra will have to be added
+     * to sys_helppath in order for this to work properly.<hans@at.or.at> */
+    sys_helppath = namelist_append_files(sys_helppath, searchpathname);
+    /* this supports having the help files in a distinct dir
+     * (i.e. doc/5.reference), but having the help files in subdirs named with
+     * the same name as the library directory.  <hans@at.or.at>*/
+    sys_helppath = namelist_append_files(sys_helppath, helppathname);
+    
+        /* this should be changed to use sys_debuglevel */
+    if (sys_verbose) 
+    {
+        post("Added to search path: %s", searchpathname);
+        post("Added to help path: %s", searchpathname);
+        post("Added to help path: %s", helppathname);
+    }
+    if (sys_verbose) 
+        post("Loaded libdir %s from %s", classname, dirbuf);
+
+    return (1);
+}
+
+/* }  <hans@at.or.at> */
Index: s_main.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_main.c,v
retrieving revision 1.9.2.5
diff -u -w -r1.9.2.5 s_main.c
--- s_main.c	24 Feb 2005 01:37:20 -0000	1.9.2.5
+++ s_main.c	20 Nov 2005 03:47:04 -0000
@@ -233,6 +233,7 @@
         /* load dynamic libraries specified with "-lib" args */
     for  (nl = sys_externlist; nl; nl = nl->nl_next)
         if (!sys_load_lib(cwd, nl->nl_string))
+            if (!sys_load_lib_dir(cwd, nl->nl_string))
             post("%s: can't load library", nl->nl_string);
         /* open patches specifies with "-open" args */
     for  (nl = sys_openlist; nl; nl = nl->nl_next)
Index: s_stuff.h
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_stuff.h,v
retrieving revision 1.5
diff -u -w -r1.5 s_stuff.h
--- s_stuff.h	6 Sep 2004 20:20:36 -0000	1.5
+++ s_stuff.h	20 Nov 2005 03:47:04 -0000
@@ -48,6 +48,8 @@
 /* s_loader.c */
 int sys_load_lib(char *dirname, char *filename);
 
+int sys_load_lib_dir(char *dirname, char *filename);
+
 /* s_audio.c */
 
 #define SENDDACS_NO 0           /* return values for sys_send_dacs() */