~ubuntu-branches/ubuntu/dapper/xscreensaver/dapper

« back to all changes in this revision

Viewing changes to utils/resources.c

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Grawert
  • Date: 2005-10-11 21:00:42 UTC
  • mfrom: (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20051011210042-u7q6zslgevdxspr3
Tags: 4.21-4ubuntu17
updated pt_BR again, fixed to UTF-8 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* xscreensaver, Copyright (c) 1992, 1997, 1998
 
1
/* xscreensaver, Copyright (c) 1992, 1997, 1998, 2001, 2003
2
2
 *  Jamie Zawinski <jwz@jwz.org>
3
3
 *
4
4
 * Permission to use, copy, modify, distribute, and sell this software and its
91
91
 
92
92
  if (ss[0] == '0' && (ss[1] == 'x' || ss[1] == 'X'))   /* 0x: parse as hex */
93
93
    {
94
 
      if (1 == sscanf (ss+2, "%x %c", &val, &c))
 
94
      if (1 == sscanf (ss+2, "%x %c", (unsigned int *) &val, &c))
95
95
        {
96
96
          free (s);
97
97
          return val;
137
137
  XColor color;
138
138
  char *s = get_string_resource (res_name, res_class);
139
139
  char *s2;
 
140
  Bool ok = True;
140
141
  if (!s) goto DEFAULT;
141
142
 
142
143
  for (s2 = s + strlen(s) - 1; s2 > s; s2--)
147
148
 
148
149
  if (! XParseColor (dpy, cmap, s, &color))
149
150
    {
150
 
      fprintf (stderr, "%s: can't parse color %s\n", progname, s);
 
151
      fprintf (stderr, "%s: can't parse color %s", progname, s);
 
152
      ok = False;
151
153
      goto DEFAULT;
152
154
    }
153
155
  if (! XAllocColor (dpy, cmap, &color))
154
156
    {
155
 
      fprintf (stderr, "%s: couldn't allocate color %s\n", progname, s);
 
157
      fprintf (stderr, "%s: couldn't allocate color %s", progname, s);
 
158
      ok = False;
156
159
      goto DEFAULT;
157
160
    }
158
161
  free (s);
159
162
  return color.pixel;
160
163
 DEFAULT:
161
164
  if (s) free (s);
162
 
  return ((strlen(res_class) >= 10 &&
163
 
           !strcmp ("Background", res_class + strlen(res_class) - 10))
164
 
          ? BlackPixel (dpy, DefaultScreen (dpy))
165
 
          : WhitePixel (dpy, DefaultScreen (dpy)));
 
165
 
 
166
  {
 
167
    Bool black_p = (strlen(res_class) >= 10 &&
 
168
                    !strcasecmp ("Background",
 
169
                                 res_class + strlen(res_class) - 10));
 
170
    if (!ok)
 
171
      fprintf (stderr, ": using %s.\n", (black_p ? "black" : "white"));
 
172
    color.flags = DoRed|DoGreen|DoBlue;
 
173
    color.red = color.green = color.blue = (black_p ? 0 : 0xFFFF);
 
174
    if (XAllocColor (dpy, cmap, &color))
 
175
      return color.pixel;
 
176
    else
 
177
      {
 
178
        fprintf (stderr, "%s: couldn't allocate %s either!\n", progname,
 
179
                 (black_p ? "black" : "white"));
 
180
        /* We can't use BlackPixel/WhitePixel here, because we don't know
 
181
           what screen we're allocating on (only an issue when running inside
 
182
           the xscreensaver daemon: for hacks, DefaultScreen is fine.)
 
183
         */
 
184
        return 0;
 
185
      }
 
186
  }
166
187
}
167
188
 
168
189