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

Comparing rxvt-unicode/src/misc.C (file contents):
Revision 1.25 by root, Mon Feb 7 01:17:03 2005 UTC vs.
Revision 1.28 by root, Fri Aug 5 16:42:44 2005 UTC

23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *----------------------------------------------------------------------*/ 24 *----------------------------------------------------------------------*/
25 25
26#include "../config.h" /* NECESSARY */ 26#include "../config.h" /* NECESSARY */
27#include "rxvt.h" /* NECESSARY */ 27#include "rxvt.h" /* NECESSARY */
28#include "misc.intpro" /* PROTOS for internal routines */
29 28
30char * 29char *
31rxvt_wcstombs (const wchar_t *str, int len) 30rxvt_wcstombs (const wchar_t *str, int len)
32{ 31{
33 if (len < 0) len = wcslen (str); 32 if (len < 0) len = wcslen (str);
168rxvt_strdup (const char *str) 167rxvt_strdup (const char *str)
169{ 168{
170 return str ? strdup (str) : 0; 169 return str ? strdup (str) : 0;
171} 170}
172 171
173/* INTPROTO */
174char * 172char *
175rxvt_r_basename (const char *str) 173rxvt_r_basename (const char *str)
176{ 174{
177 char *base = strrchr (str, '/'); 175 char *base = strrchr (str, '/');
178 176
180} 178}
181 179
182/* 180/*
183 * Print an error message 181 * Print an error message
184 */ 182 */
185/* INTPROTO */
186void 183void
187rxvt_vlog (const char *fmt, va_list arg_ptr) 184rxvt_vlog (const char *fmt, va_list arg_ptr)
188{ 185{
189 char msg[1024]; 186 char msg[1024];
190 187
194 (*GET_R->log_hook) (msg); 191 (*GET_R->log_hook) (msg);
195 else 192 else
196 write (STDOUT_FILENO, msg, strlen (msg)); 193 write (STDOUT_FILENO, msg, strlen (msg));
197} 194}
198 195
199/* INTPROTO */
200void 196void
201rxvt_log (const char *fmt,...) 197rxvt_log (const char *fmt,...)
202{ 198{
203 va_list arg_ptr; 199 va_list arg_ptr;
204 200
208} 204}
209 205
210/* 206/*
211 * Print an error message 207 * Print an error message
212 */ 208 */
213/* INTPROTO */
214void 209void
215rxvt_warn (const char *fmt,...) 210rxvt_warn (const char *fmt,...)
216{ 211{
217 va_list arg_ptr; 212 va_list arg_ptr;
218 213
221 va_start (arg_ptr, fmt); 216 va_start (arg_ptr, fmt);
222 rxvt_vlog (fmt, arg_ptr); 217 rxvt_vlog (fmt, arg_ptr);
223 va_end (arg_ptr); 218 va_end (arg_ptr);
224} 219}
225 220
226/* INTPROTO */
227void 221void
228rxvt_fatal (const char *fmt,...) 222rxvt_fatal (const char *fmt,...)
229{ 223{
230 va_list arg_ptr; 224 va_list arg_ptr;
231 225
238 rxvt_exit_failure (); 232 rxvt_exit_failure ();
239} 233}
240 234
241class rxvt_failure_exception rxvt_failure_exception; 235class rxvt_failure_exception rxvt_failure_exception;
242 236
243/* INTPROTO */
244void 237void
245rxvt_exit_failure () 238rxvt_exit_failure ()
246{ 239{
247 throw (rxvt_failure_exception); 240 throw (rxvt_failure_exception);
248} 241}
253 * No Match 246 * No Match
254 * return: 0 247 * return: 0
255 * Match 248 * Match
256 * return: strlen (S2) 249 * return: strlen (S2)
257 */ 250 */
258/* INTPROTO */
259int 251int
260rxvt_Str_match (const char *s1, const char *s2) 252rxvt_Str_match (const char *s1, const char *s2)
261{ 253{
262 int n = strlen (s2); 254 int n = strlen (s2);
263 255
264 return ((strncmp (s1, s2, n) == 0) ? n : 0); 256 return ((strncmp (s1, s2, n) == 0) ? n : 0);
265} 257}
266 258
267/* INTPROTO */
268const char * 259const char *
269rxvt_Str_skip_space (const char *str) 260rxvt_Str_skip_space (const char *str)
270{ 261{
271 if (str) 262 if (str)
272 while (*str && isspace (*str)) 263 while (*str && isspace (*str))
277 268
278/* 269/*
279 * remove leading/trailing space and strip-off leading/trailing quotes. 270 * remove leading/trailing space and strip-off leading/trailing quotes.
280 * in place. 271 * in place.
281 */ 272 */
282/* INTPROTO */
283char * 273char *
284rxvt_Str_trim (char *str) 274rxvt_Str_trim (char *str)
285{ 275{
286 char *r, *s; 276 char *r, *s;
287 277
325 * "M-x" prefixed strings, append "\r" if needed 315 * "M-x" prefixed strings, append "\r" if needed
326 * "\E]" prefixed strings (XTerm escape sequence) append ST if needed 316 * "\E]" prefixed strings (XTerm escape sequence) append ST if needed
327 * 317 *
328 * returns the converted string length 318 * returns the converted string length
329 */ 319 */
330/* INTPROTO */
331int 320int
332rxvt_Str_escaped (char *str) 321rxvt_Str_escaped (char *str)
333{ 322{
334 char ch, *s, *d; 323 char ch, *s, *d;
335 int i, num, append = 0; 324 int i, num, append = 0;
402/* 391/*
403 * Split a comma-separated string into an array, stripping leading and 392 * Split a comma-separated string into an array, stripping leading and
404 * trailing spaces from each entry. Empty strings are properly returned 393 * trailing spaces from each entry. Empty strings are properly returned
405 * Caller should free each entry and array when done 394 * Caller should free each entry and array when done
406 */ 395 */
407/* INTPROTO */
408char ** 396char **
409rxvt_splitcommastring (const char *cs) 397rxvt_splitcommastring (const char *cs)
410{ 398{
411 int l, n, p; 399 int l, n, p;
412 const char *s, *t; 400 const char *s, *t;
456 * search for FILE in the current working directory, and within the 444 * search for FILE in the current working directory, and within the
457 * colon-delimited PATHLIST, adding the file extension EXT if required. 445 * colon-delimited PATHLIST, adding the file extension EXT if required.
458 * 446 *
459 * FILE is either semi-colon or zero terminated 447 * FILE is either semi-colon or zero terminated
460 */ 448 */
461/* INTPROTO */
462char * 449char *
463rxvt_File_search_path (const char *pathlist, const char *file, const char *ext) 450rxvt_File_search_path (const char *pathlist, const char *file, const char *ext)
464{ 451{
465 int maxpath, len; 452 int maxpath, len;
466 const char *p, *path; 453 const char *p, *path;
529 } 516 }
530 } 517 }
531 return NULL; 518 return NULL;
532} 519}
533 520
534/* INTPROTO */
535char * 521char *
536rxvt_File_find (const char *file, const char *ext, const char *path) 522rxvt_File_find (const char *file, const char *ext, const char *path)
537{ 523{
538 char *f; 524 char *f;
539 525
562 548
563/* 549/*
564 * Draw top/left and bottom/right border shadows around windows 550 * Draw top/left and bottom/right border shadows around windows
565 */ 551 */
566#if defined(RXVT_SCROLLBAR) || defined(MENUBAR) 552#if defined(RXVT_SCROLLBAR) || defined(MENUBAR)
567/* INTPROTO */
568void 553void
569rxvt_Draw_Shadow (Display *display, Window win, GC topShadow, GC botShadow, int x, int y, int w, int h) 554rxvt_Draw_Shadow (Display *display, Window win, GC topShadow, GC botShadow, int x, int y, int w, int h)
570{ 555{
571 int shadow; 556 int shadow;
572 557
583} 568}
584#endif 569#endif
585 570
586/* button shapes */ 571/* button shapes */
587#ifdef MENUBAR 572#ifdef MENUBAR
588/* INTPROTO */
589void 573void
590rxvt_Draw_Triangle (Display *display, Window win, GC topShadow, GC botShadow, int x, int y, int w, int type) 574rxvt_Draw_Triangle (Display *display, Window win, GC topShadow, GC botShadow, int x, int y, int w, int type)
591{ 575{
592 switch (type) 576 switch (type)
593 { 577 {
624#endif 608#endif
625 609
626 } 610 }
627} 611}
628#endif 612#endif
613
614// should nto be use din interactive programs, for obvious reasons
615void rxvt_usleep (int usecs)
616{
617#if HAVE_NANOSLEEP
618 struct timespec ts;
619
620 ts.tv_sec = 0;
621 ts.tv_nsec = usecs * 1000;
622 nanosleep (&ts, NULL);
623#else
624 /* use select for timing */
625 struct timeval tv;
626
627 tv.tv_sec = 0;
628 tv.tv_usec = usecs;
629 select (0, NULL, NULL, NULL, &tv);
630#endif
631}
632
629/*----------------------- end-of-file (C source) -----------------------*/ 633/*----------------------- end-of-file (C source) -----------------------*/
634

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines