AT&T UNIX™PC Unix System V Users Manual - tenox

AT&T UNIX™PC Unix System V Users Manual - tenox AT&T UNIX™PC Unix System V Users Manual - tenox

01.01.2013 Views

PASTE (3T) (AT&T UNIX PC only ) PASTE ( 3T ) Pb_empty empties the paste buffer file and closes it, It is intended to be called after the paste buffer file has been read, Pb_name returns a pointer to a static area containing the name of the paste buffer file. Pb_puts appends a null terminated text string to the paste buffer �, file in ADF format. It has the same interface as [puts . Pb_weof writes an end of file code to the paste buffer file, and closes the file. It is intended to be called after the paste buffer file has been written. Pb_gets reads the next string from the paste buffer file and converts it to text. It has the same interface as [g ets . Pb_gets always returns EOF after 511 bytes have been read. To read larger blocks of text, pb_gbuf must be used. Pb_gbuf reads a paste buffer file entry and converts it to text. It puts the results into the buffer passed to it. Pb_gbuf calls the passed function to store the buffer at the end of the paste entry, or when the buffer becomes full. When this function is called, it is passed the buffer address, and the number of bytes in the buffer. This function should return a negative value on error. If a NULL pointer is passed in place of the function, then pb_gbuf returns a null-terminated string, stored in the passed buffer. Note that pb_gbuf can only be called once, and the paste buffer file should be marked empty after the call. The three functions ad/_gtwrd, ad/_gtxcd, and ad/_gttok are utilities used by pb_gbuf to interpret the ADF format. Applications that wish to access the ADF formatted files directly might use them. ad/_gtwrd scans the input string pointed to by sptr and pulls out the next word. It stores this word (null-terminated) to the buffer pointed to by dptr, and returns an updated input pointer. Ad/_gtxcd pulls out the embedded text code from the input string pointed to by sptr , and also returns an updated input pointer. This text code is stored null-terminated in the buffer pointed to by dptr . Ad/_gtxcd should be called when a "\" is encountered in the input line in a text field, and sptr should be pointing to the character following the "\." Ad/_gttok converts a word (a null-terminated string) to a token (integer) and returns the token. The conversion is driven by the passed keyword table. The keyword table structure is defined in the include file pbf.h. EXAMPLE To implement the cut operation: paste_file = pb_open (); if (paste_file == NULL) message (MT_ERROR, "wp.hlp", "Paste", "Unable to open or create paste buffer file"); - 2-

PASTE ( 3T ) ( AT&T UNIX PC only ) PASTE ( 3T ) SEE ALSO else { chr = Enter; if (pb_check (paste_file )) { chr = message (MT_QUIT, "wp.hlp", "Paste", "Paste buffer contains an entry - \ do you wish to overwrite?"); } if (chr == Enter) { ... I* Paste file is empty, or is OK to *I ... /* overwrite, write the paste file using *I ... /* fwrite, fprintf, etc. } fclose (paste_file ); } To implement the paste operation: paste_file = pb_open (); if (paste_file == NULL) message (MT_ERROR, "wp.hlp", "Paste", "Unable to open or create paste buffer file"); else { if (pb_check (paste_file )) { /* Paste file exists and is non empty, *I I* Read the paste file using fread, *I /* fscanf, etc. } else message (MT_ERROR, "wp.hlp", "Paste", "Paste buffer is empty"); pb_empty (paste_file ); } adf(4), message(3T), tam(3T). DIAGNOSTICS Pb_open returns a NULL pointer on failure. Pb_gets returns a NULL pointer at end of file. Pb_puts returns EOF on failure. - 3-

PASTE ( 3T ) ( AT&T UNIX PC only ) PASTE ( 3T )<br />

SEE ALSO<br />

else<br />

{<br />

chr = Enter;<br />

if (pb_check (paste_file ))<br />

{<br />

chr = message (MT_QUIT, "wp.hlp", "Paste",<br />

"Paste buffer contains an entry - \ do you<br />

wish to overwrite?");<br />

}<br />

if (chr == Enter)<br />

{<br />

... I* Paste file is empty, or is OK to *I<br />

... /* overwrite, write the paste file using *I<br />

... /* fwrite, fprintf, etc.<br />

}<br />

fclose (paste_file );<br />

}<br />

To implement the paste operation:<br />

paste_file = pb_open ();<br />

if (paste_file == NULL)<br />

message (MT_ERROR, "wp.hlp", "Paste",<br />

"Unable to open or create paste buffer file");<br />

else<br />

{<br />

if (pb_check (paste_file ))<br />

{<br />

/* Paste file exists and is non empty, *I<br />

I* Read the paste file using fread, *I<br />

/* fscanf, etc.<br />

}<br />

else<br />

message (MT_ERROR, "wp.hlp", "Paste",<br />

"Paste buffer is empty");<br />

pb_empty (paste_file );<br />

}<br />

adf(4), message(3T), tam(3T).<br />

DIAGNOSTICS<br />

Pb_open returns a NULL pointer on failure. Pb_gets returns a<br />

NULL pointer at end of file. Pb_puts returns EOF on failure.<br />

- 3-

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!