|
|
1.1 ! root 1: .TH MUXSTRING 9.3 ! 2: .CT 2 comm_term ! 3: .SH NAME ! 4: strinsure, strinsert, strdelete, strzero, setmuxbuf, getmuxbuf, movstring \- dynamic strings in mux ! 5: .SH SYNOPSIS ! 6: .B #include <jerq.h> ! 7: .PP ! 8: .B strinsure(s, n); String *s; ! 9: .PP ! 10: .B "strinsert(d, i, s); String *d, *s; ! 11: .PP ! 12: .B "strdelete(d, i, j); String *d; ! 13: .PP ! 14: .B strzero(d); String *d; ! 15: .PP ! 16: .B setmuxbuf(s); String *s; ! 17: .PP ! 18: .B getmuxbuf(d); String *d; ! 19: .PP ! 20: .B movstring(n, sp, dp); char *sp, *dp; ! 21: .SH DESCRIPTION ! 22: These functions manipulate strings represented ! 23: in the following form. ! 24: .IP ! 25: .EX ! 26: .ta \w'struct 'u ! 27: struct String { ! 28: char *s; ! 29: short n; ! 30: short size; ! 31: }; ! 32: .EE ! 33: .LP ! 34: The string proper occupies the first ! 35: .B n ! 36: characters of a data block of ! 37: .L size ! 38: characters pointed to by ! 39: .BR s . ! 40: Initially both ! 41: .B size ! 42: and ! 43: .B s ! 44: should be 0. ! 45: Strings are always counted, not terminated by ! 46: .BR \e0 . ! 47: The functions obtain space as needed from ! 48: .IR gcalloc ; ! 49: see ! 50: .IR alloc (9.3). ! 51: Thus a ! 52: .B String ! 53: structure should never be copied. ! 54: .PP ! 55: .I Strinsure ! 56: arranges that ! 57: .IB s ->size\(>= n. ! 58: It must be called before any operation that could ! 59: overflow the current size. ! 60: .PP ! 61: .I Strinsert ! 62: inserts a copy of source ! 63: .I s ! 64: into destination ! 65: .I d ! 66: beginning at character ! 67: .I i ! 68: (counted from 0), ! 69: adding ! 70: .IB s ->n ! 71: to ! 72: .IB d ->n . ! 73: .PP ! 74: .I Strdelete ! 75: removes characters ! 76: .I i ! 77: through ! 78: .IR j \-1 ! 79: from string ! 80: .I d, ! 81: subtracting ! 82: .IR j \- i, ! 83: which must be nonnegative, from ! 84: .IB d ->n . ! 85: .PP ! 86: .IB Strzero ! 87: frees the memory associated with ! 88: .I d ! 89: and sets both ! 90: .IB d ->n ! 91: and ! 92: .IB d ->size ! 93: to zero. ! 94: .PP ! 95: .I Setmuxbuf ! 96: copies string ! 97: .I s ! 98: into the snarf buffer maintained by ! 99: .IR mux (9.1); ! 100: .I getmuxbuf ! 101: copies from the snarf buffer into ! 102: .I d. ! 103: .PP ! 104: .I Movstr ! 105: copies a block of ! 106: .I n ! 107: characters beginning at ! 108: .I sp ! 109: to a block beginning at ! 110: .I dp. ! 111: If ! 112: .I n ! 113: is negative it copies ! 114: .RI \- n ! 115: characters ending at ! 116: .IR sp \- 1 ! 117: to a block ending at ! 118: .IR dp \-1. ! 119: Notice that ! 120: .I movstring ! 121: does not operate on ! 122: .BR String s. ! 123: .SH SEE ALSO ! 124: .IR libc (9.3)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.