[Asterisk-cvs] asterisk Makefile,1.135,1.136 app.c,1.48,1.49
markster at lists.digium.com
markster at lists.digium.com
Sun Feb 27 13:10:03 CST 2005
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv19667
Modified Files:
Makefile app.c
Log Message:
Merge mog's ReadFile application (bug #3670)
Index: Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/Makefile,v
retrieving revision 1.135
retrieving revision 1.136
diff -u -d -r1.135 -r1.136
--- Makefile 11 Feb 2005 21:16:34 -0000 1.135
+++ Makefile 27 Feb 2005 19:07:46 -0000 1.136
@@ -407,6 +407,7 @@
mkdir -p $(DESTDIR)$(ASTSBINDIR)
mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
+ mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
install -m 755 asterisk $(DESTDIR)$(ASTSBINDIR)/
install -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
Index: app.c
===================================================================
RCS file: /usr/cvsroot/asterisk/app.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- app.c 17 Feb 2005 20:04:10 -0000 1.48
+++ app.c 27 Feb 2005 19:07:46 -0000 1.49
@@ -1393,3 +1393,37 @@
res = 0;
return res;
}
+
+char *ast_read_textfile(const char *filename)
+{
+ int fd;
+ char *output=NULL;
+ struct stat filesize;
+ int count=0;
+ int res;
+ if(stat(filename,&filesize)== -1){
+ ast_log(LOG_WARNING,"Error can't stat %s\n", filename);
+ return NULL;
+ }
+ count=filesize.st_size + 1;
+ fd = open(filename, O_RDONLY);
+ if (fd < 0) {
+ ast_log(LOG_WARNING, "Cannot open file '%s' for reading: %s\n", filename, strerror(errno));
+ return NULL;
+ }
+ output=(char *)malloc(count);
+ if (output) {
+ res = read(fd, output, count - 1);
+ if (res == count - 1) {
+ output[res] = '\0';
+ } else {
+ ast_log(LOG_WARNING, "Short read of %s (%d of %d): %s\n", filename, res, count - 1, strerror(errno));
+ free(output);
+ output = NULL;
+ }
+ } else
+ ast_log(LOG_WARNING, "Out of memory!\n");
+ close(fd);
+ return output;
+}
+
More information about the svn-commits
mailing list