ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/xpm.C
(Generate patch)

Comparing rxvt-unicode/src/xpm.C (file contents):
Revision 1.44 by ayin, Sat Jun 30 23:34:57 2007 UTC vs.
Revision 1.45 by ayin, Sat Jun 30 23:58:29 2007 UTC

26#include "../config.h" /* NECESSARY */ 26#include "../config.h" /* NECESSARY */
27#include "rxvt.h" /* NECESSARY */ 27#include "rxvt.h" /* NECESSARY */
28 28
29#ifdef XPM_BACKGROUND 29#ifdef XPM_BACKGROUND
30 30
31#ifndef HAVE_AFTERIMAGE
32/*
33 * search for FILE in the current working directory, and within the
34 * colon-delimited PATHLIST, adding the file extension EXT if required.
35 *
36 * FILE is either semi-colon or zero terminated
37 */
38static char *
39rxvt_File_search_path (const char *pathlist, const char *file, const char *ext)
40{
41 int maxpath, len;
42 const char *p, *path;
43 char name[256];
44
45 if (!access (file, R_OK)) /* found (plain name) in current directory */
46 return strdup (file);
47
48 /* semi-colon delimited */
49 if ((p = strchr (file, ';')))
50 len = (p - file);
51 else
52 len = strlen (file);
53
54 /* leave room for an extra '/' and trailing '\0' */
55 maxpath = sizeof (name) - (len + (ext ? strlen (ext) : 0) + 2);
56 if (maxpath <= 0)
57 return NULL;
58
59 /* check if we can find it now */
60 strncpy (name, file, len);
61 name[len] = '\0';
62
63 if (!access (name, R_OK))
64 return strdup (name);
65 if (ext)
66 {
67 strcat (name, ext);
68 if (!access (name, R_OK))
69 return strdup (name);
70 }
71 for (path = pathlist; path != NULL && *path != '\0'; path = p)
72 {
73 int n;
74
75 /* colon delimited */
76 if ((p = strchr (path, ':')) == NULL)
77 p = strchr (path, '\0');
78
79 n = (p - path);
80 if (*p != '\0')
81 p++;
82
83 if (n > 0 && n <= maxpath)
84 {
85 strncpy (name, path, n);
86 if (name[n - 1] != '/')
87 name[n++] = '/';
88 name[n] = '\0';
89 strncat (name, file, len);
90
91 if (!access (name, R_OK))
92 return strdup (name);
93 if (ext)
94 {
95 strcat (name, ext);
96 if (!access (name, R_OK))
97 return strdup (name);
98 }
99 }
100 }
101 return NULL;
102}
103
31/* 104/*
32 * Calculate tiling sizes and increments 105 * Calculate tiling sizes and increments
33 * At start, p == 0, incr == xpmwidthheight 106 * At start, p == 0, incr == xpmwidthheight
34 */ 107 */
35static void 108static void
101 *wh = cwh; 174 *wh = cwh;
102 *xy = cxy; 175 *xy = cxy;
103 *incr = cincr; 176 *incr = cincr;
104 *p = cp; 177 *p = cp;
105} 178}
179#endif
106 180
107/* 181/*
108 * These GEOM strings indicate absolute size/position: 182 * These GEOM strings indicate absolute size/position:
109 * @ `WxH+X+Y' 183 * @ `WxH+X+Y'
110 * @ `WxH+X' -> Y = X 184 * @ `WxH+X' -> Y = X
430 xpmAttr.depth = depth; 504 xpmAttr.depth = depth;
431 xpmAttr.valuemask = (XpmCloseness | XpmColormap | XpmVisual 505 xpmAttr.valuemask = (XpmCloseness | XpmColormap | XpmVisual
432 | XpmDepth | XpmSize | XpmReturnPixels); 506 | XpmDepth | XpmSize | XpmReturnPixels);
433 507
434 /* search environment variables here too */ 508 /* search environment variables here too */
435 f = (char *)rxvt_File_find (file, ".xpm", rs[Rs_path]); 509 f = rxvt_File_search_path (rs[Rs_path], file, ".xpm");
436 if (f == NULL 510 if (f == NULL
437 || XpmReadFileToPixmap (dpy, display->root, f, 511 || XpmReadFileToPixmap (dpy, display->root, f,
438 &bgPixmap.pixmap, NULL, 512 &bgPixmap.pixmap, NULL,
439 &xpmAttr)) 513 &xpmAttr))
440 { 514 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines