jcs ratpoison hax
1-*- outline -*-
2
3This file is intented to give people who would like to modify
4ratpoison an idea the utility functions I've built up in ratpoison and
5the structure of the code.
6
7* Utility Functions
8
9** String Manipulation
10
11String manipulation is something C is seriously lacking, and something
12everyone does all the time. When writing ratpoison code, you SHOULD
13NOT be malloc'ing temporary string buffers then using strcat, strcpy,
14etc to patch strings together. The following structures and functions
15should give you just about everything you need.
16
17If there's something you want to do but can't with the following
18utils, then you should consider adding that functionality (Don't just
19hack it!) to them. Chances are, someone else will want to do it too.
20
21*** struct sbuf
22When you need to build a string by concating a bunch together or some
23messy frankensteinish string manipulation sbuf is nice to use. It
24handles all the memory allocation and you just say what you want to do
25with the sbuf_* commands. See sbuf.h.
26
27*** char *xstrdup(char *)
28If you need to copy a string, use this.
29
30*** char *xsprintf (char *fmt, ...) If you need to printf something
31into a string, don't go xmalloc'ing strlen(s)+20. Use xsprintf, it
32returns a new string, which you need to free when you're
33done. Guaranteed.
34
35*** char *xvsprintf (char *fmt, va_list ap)
36This is just like xsprintf except it takes a va_list argument.
37
38*** str_comp (char *s1, char *s2, int len)
39Just like strncmp, except that it's case-insensitive.
40
41** Memory
42
43*** xmalloc and xrealloc
44These functions are exactly like malloc and realloc, but they will
45NEVER return NULL.
46
47** Lists
48Ratpoison has taken a double-linked list implementation from the Linux
49kernel. Look at linkedlist.h. For an example of how to use it...read
50the source!
51
52* Coding Style
53
54Ratpoison follows the GNU coding style as described in the GNU Coding
55Standards Document (http://www.gnu.org/prep/standards.html). If you
56see something not compliant with the GNU Standard, please fix it and
57send a patch.