Sponsored Content
Full Discussion: read/write files
Top Forums Programming read/write files Post 302377758 by gaurav1086 on Saturday 5th of December 2009 03:48:09 AM
Old 12-05-2009
hello ..
you can read the structures one by one. using the simple read command.
given by your information-> the size of your structure would be.
(assuming 32 bit architecture) . you can add the sizes of the tokens or you can do a simple sizeof() to find the value.
then read the values in a buffer one by one and extract the values one by one.
Reply..if you need more.
Regards Smilie
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to read and write files one line at a time.

Hi! All! I am wirting a shell script in which i want to read one line at a time from the file and write it simultaneouly to other file one line at a time. Please let me know about some shell utility which can help me out. Thanx. If further clarifications are needed then please let me know... (2 Replies)
Discussion started by: s_chopra
2 Replies

2. Shell Programming and Scripting

Script with read/write Files

Hello, I am a Newbie in ksh Unix Script. So I must write a ksh/sh script who read character at a position in a File. So also it must read all the lines who belongs at these characters , then write these lines in a another File. Can you help me , or give little councils to advance with my... (5 Replies)
Discussion started by: steiner
5 Replies

3. UNIX for Dummies Questions & Answers

how to read or write device files

hi everybody, i am working in device drivers.As a beginner to this field ,i dont know how to read or write device files. Will copy_to_user and copy_from_user help me? I have created a device file using mknod command .Can anybody help me in this regard :confused thanks in advance sriram (1 Reply)
Discussion started by: sriram.ec
1 Replies

4. Shell Programming and Scripting

SED command for read and write to different files

Hi I need some help on SED command I am writing a shell script which does the following: 1. Read one line at a time from a file abc.txt which has millions of lines 2. Prefix each line read with some text " 3. Post fix each line read with a quote " 4. Write the new modified... (11 Replies)
Discussion started by: gaurav_1711
11 Replies

5. Shell Programming and Scripting

Find all files with group read OR group write OR user write permission

I need to find all the files that have group Read or Write permission or files that have user write permission. This is what I have so far: find . -exec ls -l {} \; | awk '/-...rw..w./ {print $1 " " $3 " " $4 " " $9}' It shows me all files where group read = true, group write = true... (5 Replies)
Discussion started by: shunter63
5 Replies

6. IP Networking

read/write,write/write lock with smbclient fails

Hi, We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies

7. Shell Programming and Scripting

How to read and write last modified timestamp to files?

Need help reading file last modified date in format: Filename (relative path);YYYYMMDDHHMMSS And then write it back. My idea is to backup it to a text file to restore later. Checked this command but does not work: Getting the Last Modification Timestamp of a File with Stat $ stat -f... (5 Replies)
Discussion started by: Tribe
5 Replies

8. Shell Programming and Scripting

Read input files and merge them in given order and write them to input one param or one file

Dear Friends, I am looking for a shell script to merge input files into one file .. here is my idea: 1st paramter would be outfile file (all input files content) read all input files and merge them to input param 1 ex: if I pass 6 file names to the script then 1st file name as output file... (4 Replies)
Discussion started by: hyd1234
4 Replies

9. Shell Programming and Scripting

Read and write operations on files.

Dears. kindly guide !!! I have data, which is delimited by | . it should contain 26 columns, but one column data contain | makes few row to 27 columns. I want to find rows have 27 columns and then concatenate the specific columns to single column to make it 26 columns. Kindly help, Can... (3 Replies)
Discussion started by: sadique.manzar
3 Replies
ST(3)							     Library Functions Manual							     ST(3)

NAME
libst - Sound Tools : sound sample file and effects libraries. SYNOPSIS
cc file.c -o file libst.a DESCRIPTION
Sound Tools is a library of sound sample file format readers/writers and sound effects processors. Sound Tools includes skeleton C files to assist you in writing new formats and effects. The full skeleton driver, skel.c, helps you write drivers for a new format which has data structures. The simple skeleton drivers help you write a new driver for raw (headerless) formats, or for formats which just have a simple header followed by raw data. Most sound sample formats are fairly simple: they are just a string of bytes or words and are presumed to be sampled at a known data rate. Most of them have a short data structure at the beginning of the file. INTERNALS
The Sound Tools formats and effects operate on an internal buffer format of signed 32-bit longs. The data processing routines are called with buffers of these samples, and buffer sizes which refer to the number of samples processed, not the number of bytes. File readers translate the input samples to signed longs and return the number of longs read. For example, data in linear signed byte format is left- shifted 24 bits. This does cause problems in processing the data. For example: *obuf++ = (*ibuf++ + *ibuf++)/2; would not mix down left and right channels into one monophonic channel, because the resulting samples would overflow 32 bits. Instead, the ``avg'' effects must use: *obuf++ = *ibuf++/2 + *ibuf++/2; Stereo data is stored with the left and right speaker data in successive samples. Quadraphonic data is stored in this order: left front, right front, left rear, right rear. FORMATS
A format is responsible for translating between sound sample files and an internal buffer. The internal buffer is store in signed longs with a fixed sampling rate. The format operates from two data structures: a format structure, and a private structure. The format structure contains a list of control parameters for the sample: sampling rate, data size (bytes, words, floats, etc.), encoding (unsigned, signed, logarithmic), number of sound channels. It also contains other state information: whether the sample file needs to be byte-swapped, whether fseek() will work, its suffix, its file stream pointer, its format pointer, and the private structure for the format . The private area is just a preallocated data array for the format to use however it wishes. It should have a defined data structure and cast the array to that structure. See voc.c for the use of a private data area. Voc.c has to track the number of samples it writes and when finishing, seek back to the beginning of the file and write it out. The private area is not very large. The ``echo'' effect has to malloc() a much larger area for its delay line buffers. A format has 6 routines: startread Set up the format parameters, or read in a data header, or do what needs to be done. read Given a buffer and a length: read up to that many samples, transform them into signed long integers, and copy them into the buffer. Return the number of samples actually read. stopread Do what needs to be done. startwrite Set up the format parameters, or write out a data header, or do what needs to be done. write Given a buffer and a length: copy that many samples out of the buffer, convert them from signed longs to the appropri- ate data, and write them to the file. If it can't write out all the samples, fail. stopwrite Fix up any file header, or do what needs to be done. EFFECTS
An effects loop has one input and one output stream. It has 5 routines. getopts is called with a character string argument list for the effect. start is called with the signal parameters for the input and output streams. flow is called with input and output data buffers, and (by reference) the input and output data buffer sizes. It processes the input buffer into the output buffer, and sets the size variables to the numbers of samples actually processed. It is under no obligation to read from the input buffer or write to the output buffer during the same call. If the call returns ST_EOF then this should be used as an indication that this effect will no longer read any data and can be used to switch to drain mode sooner. drain is called after there are no more input data samples. If the effect wishes to generate more data samples it copies the generated data into a given buffer and returns the number of samples generated. If it fills the buffer, it will be called again, etc. The echo effect uses this to fade away. stop is called when there are no more input samples to process. stop may generate output samples on its own. See echo.c for how to do this, and see that what it does is absolutely bogus. COMMENTS
Theoretically, formats can be used to manipulate several files inside one program. Multi-sample files, for example the download for a sam- pling keyboard, can be handled cleanly with this feature. PORTABILITY PROBLEMS
Many computers don't supply arithmetic shifting, so do multiplies and divides instead of << and >>. The compiler will do the right thing if the CPU supplies arithmetic shifting. Do all arithmetic conversions one stage at a time. I've had too many problems with "obviously clean" combinations. In general, don't worry about "efficiency". The sox.c base translator is disk-bound on any machine (other than a 8088 PC with an SMD disk controller). Just comment your code and make sure it's clean and simple. You'll find that DSP code is extremely painful to write as it is. BUGS
The HCOM format is not re-entrant; it can only be used once in a program. The program/library interface is pretty weak. There's too much ad-hoc information which a program is supposed to gather up. Sound Tools wants to be an object-oriented dataflow architecture. October 15 1996 ST(3)
All times are GMT -4. The time now is 07:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy