Bcopy » History » Version 6
Per Amundsen, 11/18/2018 07:24 AM
| 1 | 5 | Per Amundsen | _Added in 1.9.0_ |
|---|---|---|---|
| 2 | |||
| 3 | 4 | Per Amundsen | */bcopy [-zc] <&binvar> <N> <&binvar> <S> <M>* |
| 4 | 1 | Per Amundsen | |
| 5 | Copies <M> bytes from position <S> in the second &binvar to the first &binvar at position <N>. |
||
| 6 | This can also be used to copy overlapping parts of a &binvar to itself. |
||
| 7 | |||
| 8 | *Switches* |
||
| 9 | |||
| 10 | -z - The bytes in the second &binvar that is copied are zero-filled after the copy. |
||
| 11 | -c - The first &binvar is chopped to <N> + <M>. |
||
| 12 | |||
| 13 | *Parameters* |
||
| 14 | |||
| 15 | <&binvar> - Target &binvar to copy to. |
||
| 16 | 6 | Per Amundsen | <N> - Target position in the first &binvar to copy to. (If N = -1, bytes are appended to the destination &binvar) |
| 17 | 1 | Per Amundsen | <&binvar> - Source &binvar to copy from. |
| 18 | <S> - Source position to copy from. |
||
| 19 | <M> - Number of bytes to copy. |
||
| 20 | |||
| 21 | *Example* |
||
| 22 | |||
| 23 | 2 | Per Amundsen | <pre> |
| 24 | 1 | Per Amundsen | alias /example { |
| 25 | ;Create a binary variable and assign it some text |
||
| 26 | bset -t &example 1 This is a test! |
||
| 27 | |||
| 28 | ;Copy from 'example' from the 11th byte 10 bytes onward |
||
| 29 | ;Zero-fill the part that was copied |
||
| 30 | bcopy -z &example2 1 &example 11 10 |
||
| 31 | |||
| 32 | ;Print out &example's content (up to the first null) |
||
| 33 | echo -a $bvar(&example, 1-).text |
||
| 34 | |||
| 35 | ;Print out &example2's content |
||
| 36 | echo -a $bvar(&example2, 1-).text |
||
| 37 | } |
||
| 38 | 2 | Per Amundsen | </pre> |