Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

tbuf(3pub) [debian man page]

TBUF(3pub)																TBUF(3pub)

NAME
tbuf_create, tbuf_destroy, tbuf_copy, tbuf_cat, tbuf_length, tbuf_chars - manipulate text editor buffer SYNOPSIS
#include <publib.h> Tbuf *tbuf_create(const char *chars, size_t len); void tbuf_destroy(Tbuf *tbuf); Tbuf *tbuf_copy(Tbuf *tbuf, size_t offset, size_tlen); Tbuf *tbuf_cat(Tbuf *tbuf, Tbuf * tbuf); size_t tbuf_length(Tbuf *tbuf); void tbuf_chars(char *chars, Tbuf *tbuf, size_t offset, size_t len); DESCRIPTION
These routines create and manipulate simple text editor buffers, which can also be thought of as arbitrarily large text strings. The buf- fers are one-dimensional (i.e., not automatically divided into lines), and are indexed with character offsets. They are 8-bit and binary clean, i.e., they may contain any 8-bit characters, including the zero byte (''). tbuf_create creates a buffer from a C character array, and tbuf_destroy destroys it. Once it's created, a buffer may not be modified. Instead, a new buffer needs to be created, using tbuf_cat and tbuf_copy. They create the new buffer so that it shares as much memory as possible with the old buffer, so the immutability does not necessarily waste memory much. By never changing a buffer, it is rather simple to implement undo and redo: you only need to keep a list of buffers and display the suitable one to the user. The caller should remember to call tbuf_destroy for unnecessary buffers, of course. tbuf_length returns the number of characters in the buffer. tbuf_copy copies part of a buffer into a C character array. The array is not zero-terminated; the caller must do it himself. RETURN VALUE
tbuf_create, tbuf_copy, and tbuf_cat return a pointer to the new buffer, or NULL if the operation failed. tbuf_length returns the number of characters in the buffer. tbuf_destroy and tbuf_chars return nothing and cannot fail. SEE ALSO
publib(3), sbuf(3) AUTHOR
Lars Wirzenius, liw@iki.fi. TBUF(3pub)

Check Out this Related Man Page

MEMSHUFFLE(3pub)					       C Programmer's Manual						  MEMSHUFFLE(3pub)

NAME
memshuffle - make an array be in random order SYNOPSIS
#include <publib.h> void *memshuffle(void *block, size_t elsize, size_t elnum); DESCRIPTION
memshuffle will move around the elements of an array in a random fashion. It uses the standard library function rand(3) to get the pseudo- random numbers it needs. The caller must set a suitable seed with srand(3). RETURN VALUE
memshuffle returns its first argument. EXAMPLE
To shuffle an integer array one might do the following. int array[4] = { 1, 2, 3, 4 }; memshuffle(array, sizeof(array[0]), 4); BUGS
On many systems rand(3) is not of very good quality. However, it is the only random number generator that can be assumed to exist. Making it possible for the caller to provide an alternate source of random numbers (e.g., via a function pointer) is perhaps too more trouble than its worth. A better way would be for everyone to fix their rand's. SEE ALSO
publib(3), memrev(3), rand(3), srand(3) AUTHOR
Lars Wirzenius (lars.wirzenius@helsinki.fi) Publib C Programmer's Manual MEMSHUFFLE(3pub)
Man Page

11 More Discussions You Might Find Interesting

1. Programming

Message Queue Problem

Hi all, I need help about message queues, i have a server-client program that communicates each other via msg queue, firstly server opens its msg queue and waits for msg then client opens server msg queue and its own msg queue(for receiving msg from server,clients sends msg to server msg... (7 Replies)
Discussion started by: SaTYR
7 Replies

2. Programming

Masking Password with *'s

So I've been working on this for some time now and can't seem to find the solution that works for me. I'm working in C/Unix. Basically, I want to take a user input and output something different. For example, I want to take a password and output *'s. In another instance, I want to take inputed... (35 Replies)
Discussion started by: bigdrock44
35 Replies

3. Shell Programming and Scripting

Redirecting stdout continously to a file

I have a C program that continously outputs info to stdout. The problem is that I am redirecting the stdout and stderr to a file and stdout is written at the end of the problem rather than continously to the file. This could be a problem if for example the program is killed and the stdout output is... (3 Replies)
Discussion started by: igurov
3 Replies

4. Shell Programming and Scripting

Expect Script using the split command?

Hello All, I have an Expect Script that ssh'es to a server and does some stuff. In Expect there is a built-in Array Variable called "expect_out(buffer)" which contains all the output from the previous send command up until the expected output. I want to pass the array "expect_out(buffer)" to... (2 Replies)
Discussion started by: mrm5102
2 Replies

5. UNIX for Advanced & Expert Users

nth date

Hi I need to get the date of 50th day from the last friday for one of the calculation into variable in Unix script. The format required is YYYYMMDD. I have solaris OS and dont have GNU date. I would appreciate if some one can help me with this. It can be a onliner or function or block of code. ... (7 Replies)
Discussion started by: lijjumathew
7 Replies

6. Programming

Logging in shared file

Hi. The problem is to write logs in a shared file from several processes. The cooperate call of fprintf() leads to messing the content even in one call example: fprintf(f,"a1 \n a2"); fprintf(f,"a3 \n a4"); out: a1 a3 a2 a4 Ofcourse this is possible to implement the file as a... (9 Replies)
Discussion started by: z7ql
9 Replies

7. UNIX for Dummies Questions & Answers

Issue Enabling DAQ's NFQ Module while Compiling

Hello All, OS: OpenSuSE 12.3 x86_64 A little while back I installed Snort 2.9.6 and was trying to use the NFQ module along with it for packet acquisition but got errors that the module is not present. If I run: # snort --daq-list Available DAQ modules: pcap(v3): readback live multi... (0 Replies)
Discussion started by: mrm5102
0 Replies

8. Programming

Forcing a write to a file without newline?

Hello, I am writing a program which runs with root privileges, and it creates a child with lowered privileges and has to redirect it's stdout and stderr to a file and then run bash. The problem is, whenever I read this file, I want to see all of the current output, even when the program is still... (10 Replies)
Discussion started by: madd-games
10 Replies

9. UNIX for Dummies Questions & Answers

Shell equivalent of matlab fwrite function

I have some matlab code that sends the serial port elements of an array using matlab's fwrite function, e.g.: fwrite(s, , 'uchar'); What would be a unix shell equivalent? E.g., after successfully accessing the port using instructions here: Simple terminal serial port program for Linux/MacOSX... (3 Replies)
Discussion started by: darwin_886
3 Replies

10. UNIX for Beginners Questions & Answers

Linux router help needed

hi guys. I have an Kaon router wich runs "Linux version 3.10.24-svn1480 (jskim@jake-205) (gcc version 4.4.7 (Realtek MSDK-4.4.7 Build 1459". The problem I have it is that its firmware is in early stages and has alot of things messed up. Wake on lan doesn't work without arp binding and that can... (23 Replies)
Discussion started by: apoklyps3
23 Replies

11. UNIX for Beginners Questions & Answers

Ncurses status bar

Hi, all, I'm writing a BBS telnet client, and am trying to implement a status bar into it, at the bottom of the screen. I am using NCurses to accomplish this. So far, it appears to be working, that is, upon connecting to BBS, it will display the status bar, and then quickly disappear. ... (5 Replies)
Discussion started by: ignatius
5 Replies