[asterisk-bugs] [Asterisk 0016461]: [patch] for reading and writing to text file

Asterisk Bug Tracker noreply at bugs.digium.com
Wed May 26 08:15:04 CDT 2010


A NOTE has been added to this issue. 
====================================================================== 
https://issues.asterisk.org/view.php?id=16461 
====================================================================== 
Reported By:                skyman
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   16461
Category:                   Functions/NewFeature
Reproducibility:            N/A
Severity:                   feature
Priority:                   normal
Status:                     feedback
Asterisk Version:           1.6.1.11 
JIRA:                       SWP-1478 
Regression:                 No 
Reviewboard Link:            
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!):  
Request Review:              
====================================================================== 
Date Submitted:             2009-12-17 09:55 CST
Last Modified:              2010-05-26 08:15 CDT
====================================================================== 
Summary:                    [patch] for reading and writing to text file
Description: 
this patch adds 7 functions in func_env :
FILE_FORMAT
FILE_COUNT_LINE
FILE_READ_LINE
FILE_WRITE
FILE_WRITE_LINE
FILE_APPEND
FILE_APPEND_LINE
====================================================================== 

---------------------------------------------------------------------- 
 (0122474) skyman (reporter) - 2010-05-26 08:15
 https://issues.asterisk.org/view.php?id=16461#c122474 
---------------------------------------------------------------------- 
You said :
"Also, the .read portion of the API is deprecated."
you mean the "file_read" is deprecated ?
if that's it, I can change the function "file_read" without asking any
question about backward compatibility?
I'm not sure this is a good idea. I prefer to keep backward
compatibility.


You said :
"You should instead be creating .read2 portions of the API, as this method
of
handling the buffer is much more efficient."
I dont understand. Have you some documentation or example of that ?


You said :
"I'd much rather you add functionality to the FILE() dialplan function and
use parameters to the dialplan function to specify the differences.
In addition, you're completely ignoring the write portion of dialplan
functions."
I know the ".write" portion of the dialplan, but that requires changing
the ".read" as.

I think a solution like this :
replace the :
FILE(filename,offset,length)
by
FILE(filename,offset,length[,readline[,format]])

[Arguments]
offset
    Maybe specified as any number. If negative, <offset> specifies the
    number of bytes back from the end of the file.
length
    If specified, will limit the length of the data read to that size.
    If negative, trims <length> bytes from the end of the file.

readline
    If set to 1, read one line at a time. <offset> specifie the line to be
read, <length> will be ignored.

format
    Format may be one of the following:
        u - Unix newline format (default).
	d - Dos newline format.
	m - Mac newline format.

examples :
FILE(/tmp/test.txt,10,20) : reads the 10th to 19th character in the file.
(for backware compatibility)
FILE(/tmp/test.txt,3,,1) : reads the 3th line of the file.
FILE(/tmp/test.txt,3,,1,d) : reads the 3th line of file in DOS format.

This preserves backward compatibility, but I'm not sure this is a good
idea.
What is your opinion ?

(sorry for my bad english, i am french) 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2010-05-26 08:15 skyman         Note Added: 0122474                          
======================================================================




More information about the asterisk-bugs mailing list