/usr/share/calc/help/blk is in apcalc-common 2.12.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | NAME
blk - generate or modify block values
SYNOPSIS
blk([len, chunk]);
blk(val [, len, chunk]);
TYPES
len null or integer
chunk null or integer
val non-null string, block, or named block
return block or named block
DESCRIPTION
With only integer arguments, blk(len, chunk) attempts to
allocate a block of memory consisting of len octets (unsigned 8-bit
bytes). Allocation is always done in multiples of chunk
octets, so the actual allocation size of len rounded up
to the next multiple of chunk.
The default value for len is 0. The default value for chunk is 256.
If the allocation is successful, blk(len, chunk) returns a value B, say,
for which the octets in the block may be referenced by B[0], B[1],
... , B[len-1], these all initially having zero value.
The octets B[i] for i >= len always have zero value. If B[i] with
some i >= len is referenced, size(B) is increased to i + 1. For example:
B[i] = x
has an effect like that of two operations on a file stream fs:
fseek(fs, pos);
fputc(fs, x).
Similarly:
x = B[i]
is like:
fseek(fs, pos);
x = fgetc(fs).
The value of chunk is stored as the "chunksize" for B.
The size(B) builtin returns the current len for the block; sizeof(B)
returns its maxsize; memsize(B) returns maxsize + overhead for any block
value. Also size(B) is analogous to the length of a file stream in that
if size(B) < sizeof(B):
B[size(B)] = x
will append one octet to B and increment size(B).
The builtin test(B) returns 1 or 0 according as at least one octet
is nonzero or all octets are zero. If B1 and B2 are blocks, they are
considered equal (B1 == B2) if they have the same length and the
same data, i.e. B1[i] == B2[i] for 0 <= i < len. Chunksizes
and maxsizes are ignored.
The output for print B occupies two lines, the first line giving
the chunksize, number of octets allocated (len rounded up to the
next chunk) and len, and the second line up to 30 octets of data.
If the datalen is zero, the second line is blank. If the datalen
exceeds 30, this indicated by a trailing "...".
If a block value B created by B = blk(len, chunk) is assigned to
another variable by C = B, a new block of the same structure as B
is created to become the value of C, and the octets in B are copied
to this new block. A block with possibly different length or
chunksize is created by C = blk(B, newlen, newchunk), only the first
min(len, newlen) octets being copied from B; later octets are
assigned zero value. If omitted, newlen and newchunk default to
the current datalen and chunk-size for B. The current datalen,
chunksize and number of allocated octets for B may be changed by:
B = blk(B, newlen, newchunk).
No data is lost if newlen is greater than or equal to the old
size(B).
The memory block allocated by blk(len, chunk) is freed at or before
termination of the statement in which this occurred, the memory
allocated in B = blk(len, chunk) is freed when B is assigned another
value.
With a string str as its first argument, blk(str [, len, chunk])
when called for the first time creates a block with str as its
name. Here there no restriction on the characters used in str;
thus the string may include white space or characters normally used
for punctuation or operators. Any subsequent call to blk(str, ...)
with the same str will refer to the same named block.
A named block is assigned length and chunksize and consequent
maximum size in the same way as unnamed blocks. A major difference
is that in assignments, a named block is not copied. Thus, if a
block A has been created by:
A = blk("foo")
any subsequent:
B = A
or:
B = blk("foo")
will give a second variable B referring to the same block as A.
Either A[i] = x or B[i] = x may then be used to assign a value
to an octet in the block. Its length or chunksize may be changed by
instructions like:
blk(A, len, chunk);
A = blk(A, len, chunk);
null(blk(A, len, chunk)).
These have the same effect on A; when working interactively, the
last two avoid printing of the new value for A.
Named blocks are assigned index numbers 0, 1, 2, ..., in the order
of their creation. The block with index id is returned by blocks(id).
With no argument, blocks() returns the number of current unfreed
named blocks.
The memory allocated to a named block is freed by the blkfree()
function with argument the named block, its name, or its id number.
The block remains in existence but with a null data pointer,
its length and size being reduced to zero. A new block of memory
may be allocated to it, with possibly new length and chunksize by:
blk(val [, len, chunk])
where val is either the named block or its name.
The printing output for a named block is in three lines, the first
line displaying its id number and name, the other two as for an
unnamed block, except that "NULL" is printed if the memory has been
freed.
The identifying numbers and names of the current named blocks are
displayed by:
show blocks
If A and B are named blocks, A == B will be true only if they refer
to the same block of memory. Thus, blocks with the same data and
datalen will be considered unequal if they have different names.
If A is a named block, str(A) returns the name of the block.
Values may be assigned to the early octets of a named or unnamed
block by use of = { } initialization as for matrices.
EXAMPLE
; B = blk(15,10)
; B[7] = 0xff
; B
chunksize = 10, maxsize = 20, datalen = 15
00000000000000ff00000000000000
; B[18] = 127
; B
chunksize = 10, maxsize = 20, datalen = 18
00000000000000ff0000000000000000007f
; B[20] = 2
Index out of bounds for block
; print size(B), sizeof(B)
18 20
; B = blk(B, 100, 20)
; B
chunksize = 20, maxsize = 120, datalen = 100
00000000000000ff0000000000000000007f000000000000000000000000...
; C = blk(B, 10} = {1,2,3}
; C
chunksize = 20, maxsize = 20, datalen = 10
01020300000000ff0000
; A1 = blk("alpha")
; A1
block 0: alpha
chunksize = 256, maxsize = 256, datalen = 0
; A1[7] = 0xff
; A2 = A1
; A2[17] = 127
; A1
block 0: alpha
chunksize = 256, maxsize = 256, datalen = 18
00000000000000ff0000000000000000007f
; A1 = blk(A1, 1000)
; A1
block 0: alpha
chunksize = 256, maxsize = 1024, datalen = 1000
00000000000000ff0000000000000000007f000000000000000000000000...
; A1 = blk(A1, , 16)
; A1
block 0: alpha
chunksize = 16, maxsize = 1008, datalen = 1000
00000000000000ff0000000000000000007f000000000000000000000000...
LIMITS
0 <= len < 2^31
1 <= chunk < 2^31
LINK LIBRARY
BLOCK *blkalloc(int len, int chunk)
void blk_free(BLOCK *blk)
BLOCK *blkrealloc(BLOCK *blk, int newlen, int newchunk)
void blktrunc(BLOCK *blk)
BLOCK *blk_copy(BLOCK *blk)
int blk_cmp(BLOCK *a, BLOCK *b)
void blk_print(BLOCK *blk)
void nblock_print(NBLOCK *nblk)
NBLOCK *reallocnblock(int id, int len, int chunk)
NBLOCK *createnblock(char *name, int len, int chunk)
int findnblockid(char * name)
int removenblock(int id)
int countnblocks(void)
void shownblocks(void)
NBLOCK *findnblock(int id)
BLOCK *copyrealloc(BLOCK *blk, int newlen, int newchunk)
SEE ALSO
blocks, blkfree
## Copyright (C) 1999-2006 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: blk,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/blk,v $
##
## Under source code control: 1997/04/05 13:07:13
## File existed as early as: 1997
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|