Csound Csound-dev Csound-tekno Search About

[CSOUND-DEV:5653] temp files

Date2005-01-08 07:04
From"Matt J. Ingalls"
Subject[CSOUND-DEV:5653] temp files
do you think it is dangerous using tmpnam() instead of tmpfil() ?

on my machine at least, if i run 2 csound processes at once, they will 
both create temp files with the same name.

-m

Date2005-01-08 12:07
Fromjpff@codemist.co.uk
Subject[CSOUND-DEV:5654] Re: temp files
tmpfil is not ANSI C89.
==John ffitch

Date2005-01-09 03:26
From"Matt J. Ingalls"
Subject[CSOUND-DEV:5655] Re: temp files
sorry i meant tmpfile()


On Sat, 8 Jan 2005 jpff@codemist.co.uk wrote:

> tmpfil is not ANSI C89.
> ==John ffitch
>
>

Date2005-01-26 17:23
FromAnthony Kozar
Subject[CSOUND-DEV:5754] Re: temp files
That would seem to be a bug in your tmpnam() then.  According to the
Metrowerks documentation (pro 4), tmpnam() is supposed to create a unique
name.

Unless you are saying that both processes generate the same name before
either one can open the file.  I guess that would be a potential problem,
but to have two processes running that closely in lock step seems unusual.

Anthony

On 1/8/05 2:04 AM, Matt J. Ingalls  etched in stone:

> 
> do you think it is dangerous using tmpnam() instead of tmpfil() ?
> 
> on my machine at least, if i run 2 csound processes at once, they will
> both create temp files with the same name.
> 
> -m
> 

Date2005-01-26 19:31
Fromramsdell@mitre.org (John D. Ramsdell)
Subject[CSOUND-DEV:5755] Re: temp files
The manual page on tmpnam says:

BUGS
       Never use this function. Use mkstemp(3) instead.

Please heed this warning.

John

Anthony Kozar  writes:

> That would seem to be a bug in your tmpnam() then.  According to the
> Metrowerks documentation (pro 4), tmpnam() is supposed to create a unique
> name.
> 
> Unless you are saying that both processes generate the same name before
> either one can open the file.  I guess that would be a potential problem,
> but to have two processes running that closely in lock step seems unusual.
> 
> Anthony
> 
> On 1/8/05 2:04 AM, Matt J. Ingalls  etched in stone:
> 
> > 
> > do you think it is dangerous using tmpnam() instead of tmpfil() ?
> > 
> > on my machine at least, if i run 2 csound processes at once, they will
> > both create temp files with the same name.
> > 
> > -m
> > 

Date2005-01-26 20:14
FromIstvan Varga
SubjectRe: [Cs-dev] Re: [CSOUND-DEV:5754] Re: temp files
John D. Ramsdell wrote:

>The manual page on tmpnam says:
>
>BUGS
>       Never use this function. Use mkstemp(3) instead.
>
>  
>
However, quoting from the mkstemp manual:
  "CONFORMING TO
       BSD 4.3, POSIX 1003.1-2001"
I think it would make sense to implement a temporary file
name generator function in the Csound API, so that it can
be implemented on all platforms using the best method
available, and system specific code would be limited to
one place.



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-01-26 20:20
FromAnthony Kozar
Subject[Cs-dev] Re: [CSOUND-DEV:5755] Re: temp files
I've seen a similar warning when compiling Csound with GCC.  However, I
cannot find this function in the MacOS 9 standard library.

Which header file is mkstemp() supposed to be in?

Anthony

On 1/26/05 2:31 PM, John D. Ramsdell  etched in stone:

> The manual page on tmpnam says:
> 
> BUGS
> Never use this function. Use mkstemp(3) instead.
> 
> Please heed this warning.



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-01-26 21:16
Fromjpff@codemist.co.uk
Subject[CSOUND-DEV:5756] Re: temp files
I repeat, mktemp is not ANSI C89, and for that reason I have not
changed the code.
==John ffitch

Date2005-01-26 22:06
Fromramsdell@mitre.org (John D. Ramsdell)
Subject[Cs-dev] Re: [CSOUND-DEV:5756] Re: temp files
jpff@codemist.co.uk writes:

> I repeat, mktemp is not ANSI C89, and for that reason I have not
> changed the code.

John is, of course, right.  The Lunux manual for mkstemp says it is:

CONFORMING TO
       BSD 4.3, POSIX 1003.1-2001

John


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-01-26 22:11
FromMatt Ingalls
SubjectRe: [Cs-dev] Re: [CSOUND-DEV:5754] Re: temp files
but i think tmpfile() is ANSI and mkstemp is not?

On Jan 26, 2005, at 12:14 PM, Istvan Varga wrote:

> John D. Ramsdell wrote:
>
>> The manual page on tmpnam says:
>>
>> BUGS
>>       Never use this function. Use mkstemp(3) instead.
>>
>>
> However, quoting from the mkstemp manual:
>  "CONFORMING TO
>       BSD 4.3, POSIX 1003.1-2001"
> I think it would make sense to implement a temporary file
> name generator function in the Csound API, so that it can
> be implemented on all platforms using the best method
> available, and system specific code would be limited to
> one place.
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
> Tool for open source databases. Create drag-&-drop reports. Save time
> by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
> Download a FREE copy at http://www.intelliview.com/go/osdn_nl
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-01-26 22:24
From"Matt J. Ingalls"
Subject[CSOUND-DEV:5757] Re: temp files
did you see my longish post a couple hours ago on the new dev list?
i didnt [and only reason i am posting here we should stop using this list]

bug or not, the race condition you mention could happen - and it 
might be more likely to happen when we get fully reentrant and all 
global data removed & we will have the ability to start multiple processes 
-- i could see some interest in running multiple processes at once with 
different thread priorities or something like that... then you could 
have some launcher/host app/script/etc starts a bunch of processes at once..

-m

On Wed, 26 Jan 2005, Anthony Kozar wrote:

> That would seem to be a bug in your tmpnam() then.  According to the
> Metrowerks documentation (pro 4), tmpnam() is supposed to create a unique
> name.
>
> Unless you are saying that both processes generate the same name before
> either one can open the file.  I guess that would be a potential problem,
> but to have two processes running that closely in lock step seems unusual.
>
> Anthony
>
> On 1/8/05 2:04 AM, Matt J. Ingalls  etched in stone:
>
>>
>> do you think it is dangerous using tmpnam() instead of tmpfil() ?
>>
>> on my machine at least, if i run 2 csound processes at once, they will
>> both create temp files with the same name.
>>
>> -m
>>
>
>

Date2005-01-26 22:38
From"Matt J. Ingalls"
Subject[CSOUND-DEV:5758] Re: temp files
but tmpfile() is and it is thread-safe!

On Wed, 26 Jan 2005 jpff@codemist.co.uk wrote:

> I repeat, mktemp is not ANSI C89, and for that reason I have not
> changed the code.
> ==John ffitch
>
>

Date2005-01-26 23:46
Fromramsdell@mitre.org (John D. Ramsdell)
Subject[Cs-dev] Csound 4 is not ANSI C89
I noticed that csound/ccsound.c was not ANSI C89, so I tried compiling
the Csound 4 source using GCC with -ansi.  I found out there are many
parts of Csound 4 that are not ANSI C89.  The file csound/aifc.c
contains multi-byte characters, but worse, csound/csound.h uses C++
style one line comments--a C99 feature.  I fixed csound/ccsound.c,
but did not touch anything else.

John

jpff@codemist.co.uk writes:

> I repeat, mktemp is not ANSI C89, and for that reason I have not
> changed the code.
> ==John ffitch


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-01-26 23:52
Fromramsdell@mitre.org (John D. Ramsdell)
SubjectRe: [Cs-dev] Re: [CSOUND-DEV:5754] Re: temp files
Matt Ingalls  writes:

> but i think tmpfile() is ANSI and mkstemp is not?

You are correct, but I think the code needs file names, not FILE
pointers.

John


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-01-26 23:57
FromMatt Ingalls
SubjectRe: [Cs-dev] Re: [CSOUND-DEV:5754] Re: temp files
i am suggesting changing the code!

On Jan 26, 2005, at 3:52 PM, John D. Ramsdell wrote:

> Matt Ingalls  writes:
>
>> but i think tmpfile() is ANSI and mkstemp is not?
>
> You are correct, but I think the code needs file names, not FILE
> pointers.
>
> John
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
> Tool for open source databases. Create drag-&-drop reports. Save time
> by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
> Download a FREE copy at http://www.intelliview.com/go/osdn_nl
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-01-27 00:15
Fromramsdell@mitre.org (John D. Ramsdell)
SubjectRe: [Cs-dev] temp files
Matt Ingalls  writes:

> i am suggesting changing the code!

I understand.  If one looks in csound/main.c, one sees that when
handling a CSD file, a filename is generated for the score.  The score
is opened for writing, and the score is extracted from the CSD file.
That file is closed, and then opened for reading using the method used
when Csound is given both an orchestra file and a score file.  With
tmpfile, one gets to open the file exactly one.  This means one is no
longer able to partition the CSD handling code cleanly from the other
part of the main routine.

It is likely that what you ask for can be done, but do you really want
to get that deeply into csound/main.c?  And then there is
csound/one_file.c.  It handles MIDI files too.

I think I once raised this very same issue, but eventually understood
why no change was made.  As Clinton said, "I feel your pain".

John

> On Jan 26, 2005, at 3:52 PM, John D. Ramsdell wrote:
> 
> > Matt Ingalls  writes:
> >
> >> but i think tmpfile() is ANSI and mkstemp is not?
> >
> > You are correct, but I think the code needs file names, not FILE
> > pointers.
> >
> > John
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
> > Tool for open source databases. Create drag-&-drop reports. Save time
> > by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
> > Download a FREE copy at http://www.intelliview.com/go/osdn_nl
> > _______________________________________________
> > Csound-devel mailing list
> > Csound-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
> Tool for open source databases. Create drag-&-drop reports. Save time
> by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
> Download a FREE copy at http://www.intelliview.com/go/osdn_nl
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-01-27 06:26
Fromjpff@codemist.co.uk
SubjectRe: [Cs-dev] Csound 4 is not ANSI C89
I repeatedly remove the // comments for /* */ in all csound sources.
As I have abandoned csound4 the non-ANSI bits in aiff which have
anoyed me for years are no longer a problem.
==John ffitch


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-01-27 09:57
FromIstvan Varga
SubjectRe: [Cs-dev] Csound 4 is not ANSI C89
John D. Ramsdell wrote:

> I noticed that csound/ccsound.c was not ANSI C89, so I tried compiling
> the Csound 4 source using GCC with -ansi.  I found out there are many
> parts of Csound 4 that are not ANSI C89.  The file csound/aifc.c
> contains multi-byte characters, but worse, csound/csound.h uses C++
> style one line comments--a C99 feature.  I fixed csound/ccsound.c,
> but did not touch anything else.

Would it be possible to switch to C99, at least in Csound5 ? It has
many useful features compared to C89. How many people use compilers
that still do not support C99 ?



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-01-27 10:10
FromIstvan Varga
SubjectRe: [Cs-dev] Re: [CSOUND-DEV:5754] Re: temp files
Matt Ingalls wrote:

> but i think tmpfile() is ANSI and mkstemp is not?

Correct. tmpfile() does have some minor disadvantages, though:
   1. You cannot control when the files are deleted. It always
      happens when the program terminates, however it would be
      preferable to delete tmp files at the end of a Csound
      instance (otherwise, in a re-entrant version tmp files
      would keep accumulating until you actually quit).
      On the other hand, sometimes it would be useful to keep
      the files.
   2. It returns a FILE* handle instead of a file name (that is
      needed for the improved reliability compared to tmpnam()),
      and there is no possibility of closing and then re-opening
      a file. This is a problem, because CSD files are first
      converted to temporary orc and sco files, which are written,
      closed, and then the name is passed to the orc/sco parser.
      This system would need to be changed if tmpfile() is used.


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-01-27 20:22
FromMatt Ingalls
SubjectRe: [Cs-dev] temp files
here is the main problem we are experiencing:

+ tmpnam() always creates the same temp file names
    temp000000, temp000001, temp000002, etc..
    for every csound process.

+ user runs csound and kills process [a common thing on commandline
    with an "endless" score (f0 99999)] or crashes, temp files
    are not deleted.

+ another user tries to run csound, and when it tries to create
   temp00000 file it returns an error because it doesnt have proper
   privileges to write over other user's temp files.


i think its worth trying to replace with tmpfile() even if it takes a 
bit of work.
i wouldnt mind seeing all those "using score file temp0000001.sco" 
output
messages go away anyway....

OR

is there an ANSII way to get the name/id/etc of the current user? it 
would
then be possible to create a directory for each user in /tmp and then
do something like:

char username[256];
getusername(username);
sprintf(sconame, "/tmp/%s/%s", username, tmpnam(NULL));
strcat(sconame, ".sco");
scof = fopen(sconame, "w");

well what do you guys do on other platforms?


thanks for your help,
m

On Jan 26, 2005, at 4:15 PM, John D. Ramsdell wrote:

> Matt Ingalls  writes:
>
>> i am suggesting changing the code!
>
> I understand.  If one looks in csound/main.c, one sees that when
> handling a CSD file, a filename is generated for the score.  The score
> is opened for writing, and the score is extracted from the CSD file.
> That file is closed, and then opened for reading using the method used
> when Csound is given both an orchestra file and a score file.  With
> tmpfile, one gets to open the file exactly one.  This means one is no
> longer able to partition the CSD handling code cleanly from the other
> part of the main routine.
>
> It is likely that what you ask for can be done, but do you really want
> to get that deeply into csound/main.c?  And then there is
> csound/one_file.c.  It handles MIDI files too.
>
> I think I once raised this very same issue, but eventually understood
> why no change was made.  As Clinton said, "I feel your pain".
>
> John
>
>> On Jan 26, 2005, at 3:52 PM, John D. Ramsdell wrote:
>>
>>> Matt Ingalls  writes:
>>>
>>>> but i think tmpfile() is ANSI and mkstemp is not?
>>>
>>> You are correct, but I think the code needs file names, not FILE
>>> pointers.
>>>
>>> John
>>>
>>>
>>> -------------------------------------------------------
>>> This SF.Net email is sponsored by: IntelliVIEW -- Interactive 
>>> Reporting
>>> Tool for open source databases. Create drag-&-drop reports. Save time
>>> by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, 
>>> etc.
>>> Download a FREE copy at http://www.intelliview.com/go/osdn_nl
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>
>>
>>
>> -------------------------------------------------------
>> This SF.Net email is sponsored by: IntelliVIEW -- Interactive 
>> Reporting
>> Tool for open source databases. Create drag-&-drop reports. Save time
>> by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
>> Download a FREE copy at http://www.intelliview.com/go/osdn_nl
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
> Tool for open source databases. Create drag-&-drop reports. Save time
> by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
> Download a FREE copy at http://www.intelliview.com/go/osdn_nl
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-01-28 01:04
Fromramsdell@mitre.org (John D. Ramsdell)
SubjectRe: [Cs-dev] Re: [CSOUND-DEV:5754] Re: temp files
Istvan Varga  writes:

> I think it would make sense to implement a temporary file
> name generator function in the Csound API, so that it can
> be implemented on all platforms using the best method
> available, and system specific code would be limited to
> one place.

Actually, this can be done by the configuration system.  For example,
a distribution that uses a GNU Build System, specifically the output
of autoconf, can probe the system, and select the best option.

Csound 5 uses SCons, and I'm sure one can use it to provide the same
functionality.  Since Csound 5 is the future, I think fixing the
problem for Csound 5 should be first priority, and the solution can be
back ported to Csound 4 if need be.

John


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-01-28 06:25
Fromjpff@codemist.co.uk
SubjectRe: [Cs-dev] temp files
A random number would be better than always starting from 0.
==John ffitch


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-01-28 16:35
FromCharles Baker
SubjectRe: [Cs-dev] temp files

The unix-y thing to do would be to create a .csound directory in the 
users home dir
(i.e. "~" ) and keep all tmp files there. As far as win, one could 
perhaps create a similar dir, hidden or not?
Cleaning said directory on program quit could be an option one could 
toggle?

cb

On Jan 27, 2005, at 3:22 PM, Matt Ingalls wrote:

> here is the main problem we are experiencing:
>
> + tmpnam() always creates the same temp file names
>    temp000000, temp000001, temp000002, etc..
>    for every csound process.
>
> + user runs csound and kills process [a common thing on commandline
>    with an "endless" score (f0 99999)] or crashes, temp files
>    are not deleted.
>
> + another user tries to run csound, and when it tries to create
>   temp00000 file it returns an error because it doesnt have proper
>   privileges to write over other user's temp files.
>
>
> i think its worth trying to replace with tmpfile() even if it takes a 
> bit of work.
> i wouldnt mind seeing all those "using score file temp0000001.sco" 
> output
> messages go away anyway....
>
> OR
>
> is there an ANSII way to get the name/id/etc of the current user? it 
> would
> then be possible to create a directory for each user in /tmp and then
> do something like:
>
> char username[256];
> getusername(username);
> sprintf(sconame, "/tmp/%s/%s", username, tmpnam(NULL));
> strcat(sconame, ".sco");
> scof = fopen(sconame, "w");
>
> well what do you guys do on other platforms?
>
>
> thanks for your help,
> m
>
> On Jan 26, 2005, at 4:15 PM, John D. Ramsdell wrote:
>
>> Matt Ingalls  writes:
>>
>>> i am suggesting changing the code!
>>
>> I understand.  If one looks in csound/main.c, one sees that when
>> handling a CSD file, a filename is generated for the score.  The score
>> is opened for writing, and the score is extracted from the CSD file.
>> That file is closed, and then opened for reading using the method used
>> when Csound is given both an orchestra file and a score file.  With
>> tmpfile, one gets to open the file exactly one.  This means one is no
>> longer able to partition the CSD handling code cleanly from the other
>> part of the main routine.
>>
>> It is likely that what you ask for can be done, but do you really want
>> to get that deeply into csound/main.c?  And then there is
>> csound/one_file.c.  It handles MIDI files too.
>>
>> I think I once raised this very same issue, but eventually understood
>> why no change was made.  As Clinton said, "I feel your pain".
>>
>> John
>>
>>> On Jan 26, 2005, at 3:52 PM, John D. Ramsdell wrote:
>>>
>>>> Matt Ingalls  writes:
>>>>
>>>>> but i think tmpfile() is ANSI and mkstemp is not?
>>>>
>>>> You are correct, but I think the code needs file names, not FILE
>>>> pointers.
>>>>
>>>> John
>>>>
>>>>
>>>> -------------------------------------------------------
>>>> This SF.Net email is sponsored by: IntelliVIEW -- Interactive 
>>>> Reporting
>>>> Tool for open source databases. Create drag-&-drop reports. Save 
>>>> time
>>>> by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, 
>>>> etc.
>>>> Download a FREE copy at http://www.intelliview.com/go/osdn_nl
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>
>>>
>>>
>>>
>>> -------------------------------------------------------
>>> This SF.Net email is sponsored by: IntelliVIEW -- Interactive 
>>> Reporting
>>> Tool for open source databases. Create drag-&-drop reports. Save time
>>> by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, 
>>> etc.
>>> Download a FREE copy at http://www.intelliview.com/go/osdn_nl
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>>
>> -------------------------------------------------------
>> This SF.Net email is sponsored by: IntelliVIEW -- Interactive 
>> Reporting
>> Tool for open source databases. Create drag-&-drop reports. Save time
>> by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
>> Download a FREE copy at http://www.intelliview.com/go/osdn_nl
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
> Tool for open source databases. Create drag-&-drop reports. Save time
> by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
> Download a FREE copy at http://www.intelliview.com/go/osdn_nl
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-01-28 17:34
Fromramsdell@mitre.org (John D. Ramsdell)
SubjectRe: [Cs-dev] temp files
Matt Ingalls  writes:

> i think its worth trying to replace with tmpfile() even if it takes a
> bit of work.

OK.  For Csound 4, I'll checking into autoconf hacks to replaces calls
to tmpnam with something else when possible.

John

> i wouldnt mind seeing all those "using score file temp0000001.sco"
> output
> messages go away anyway....
> 
> OR
> 
> is there an ANSII way to get the name/id/etc of the current user? it
> would
> then be possible to create a directory for each user in /tmp and then
> do something like:
> 
> char username[256];
> getusername(username);
> sprintf(sconame, "/tmp/%s/%s", username, tmpnam(NULL));
> strcat(sconame, ".sco");
> scof = fopen(sconame, "w");
> 
> well what do you guys do on other platforms?
> 
> 
> thanks for your help,
> m
> 
> On Jan 26, 2005, at 4:15 PM, John D. Ramsdell wrote:
> 
> > Matt Ingalls  writes:
> >
> >> i am suggesting changing the code!
> >
> > I understand.  If one looks in csound/main.c, one sees that when
> > handling a CSD file, a filename is generated for the score.  The score
> > is opened for writing, and the score is extracted from the CSD file.
> > That file is closed, and then opened for reading using the method used
> > when Csound is given both an orchestra file and a score file.  With
> > tmpfile, one gets to open the file exactly one.  This means one is no
> > longer able to partition the CSD handling code cleanly from the other
> > part of the main routine.
> >
> > It is likely that what you ask for can be done, but do you really want
> > to get that deeply into csound/main.c?  And then there is
> > csound/one_file.c.  It handles MIDI files too.
> >
> > I think I once raised this very same issue, but eventually understood
> > why no change was made.  As Clinton said, "I feel your pain".
> >
> > John
> >
> >> On Jan 26, 2005, at 3:52 PM, John D. Ramsdell wrote:
> >>
> >>> Matt Ingalls  writes:
> >>>
> >>>> but i think tmpfile() is ANSI and mkstemp is not?
> >>>
> >>> You are correct, but I think the code needs file names, not FILE
> >>> pointers.
> >>>
> >>> John
> >>>
> >>>
> >>> -------------------------------------------------------
> >>> This SF.Net email is sponsored by: IntelliVIEW -- Interactive
> >>> Reporting
> >>> Tool for open source databases. Create drag-&-drop reports. Save time
> >>> by over 75%! Publish reports on the web. Export to DOC, XLS, RTF,
> >>> etc.
> >>> Download a FREE copy at http://www.intelliview.com/go/osdn_nl
> >>> _______________________________________________
> >>> Csound-devel mailing list
> >>> Csound-devel@lists.sourceforge.net
> >>> https://lists.sourceforge.net/lists/listinfo/csound-devel
> >>>
> >>
> >>
> >>
> >> -------------------------------------------------------
> >> This SF.Net email is sponsored by: IntelliVIEW -- Interactive
> >> Reporting
> >> Tool for open source databases. Create drag-&-drop reports. Save time
> >> by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
> >> Download a FREE copy at http://www.intelliview.com/go/osdn_nl
> >> _______________________________________________
> >> Csound-devel mailing list
> >> Csound-devel@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/csound-devel
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
> > Tool for open source databases. Create drag-&-drop reports. Save time
> > by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
> > Download a FREE copy at http://www.intelliview.com/go/osdn_nl
> > _______________________________________________
> > Csound-devel mailing list
> > Csound-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
> Tool for open source databases. Create drag-&-drop reports. Save time
> by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
> Download a FREE copy at http://www.intelliview.com/go/osdn_nl
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-01-28 19:54
FromAnthony Kozar
SubjectRe: [Cs-dev] temp files
Would it?  You would end up with the same random number unless you seed the
generator.  But if you start two instances of csound back to back in a shell
script for example, I think that you will be likely to get the same value
from time() to seed with.

Anthony

On 1/28/05 1:25 AM, jpff@codemist.co.uk  etched in
stone:

> A random number would be better than always starting from 0.
> ==John ffitch



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-01-28 20:01
FromAnthony Kozar
SubjectRe: [Cs-dev] temp files
On 1/27/05 3:22 PM, Matt Ingalls  etched in stone:

> i think its worth trying to replace with tmpfile() even if it takes a
> bit of work.
> i wouldnt mind seeing all those "using score file temp0000001.sco"
> output
> messages go away anyway....

I suppose this is a possibility if we are willing to make the changes that
Istvan pointed out would be necessary.

> is there an ANSII way to get the name/id/etc of the current user? it
> would
> then be possible to create a directory for each user in /tmp and then
> do something like:
> 
> char username[256];
> getusername(username);
> sprintf(sconame, "/tmp/%s/%s", username, tmpnam(NULL));
> strcat(sconame, ".sco");
> scof = fopen(sconame, "w");
> 
> well what do you guys do on other platforms?

getuid() is not ANSI, AFAIK, but it is POSIX.  And there is an acceptable
implementation of it on MacOS 9 and I assume other non-Posix systems like
Windows.  We would still have to check the target directory for existing
files though.

I noticed that MacOS X already has subdirectories in /tmp such as /tmp/501
and /tmp/503.  These are subdirectories for specific users.  501 is the user
id number of the first user account created on OS X.  503 is the third, etc.
I don't know how to retrieve this number programmatically though.

Anthony



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-01-29 16:02
FromIstvan Varga
SubjectRe: [Cs-dev] temp files
Anthony Kozar wrote:

> Would it?  You would end up with the same random number unless you seed the
> generator.  But if you start two instances of csound back to back in a shell
> script for example, I think that you will be likely to get the same value
> from time() to seed with.

With the 'unsigned long timers_random_seed(void)' function (already in CVS),
you can get a 32 bit unsigned seed value from timers that have the following
resolution:
   * Linux/GCC/i386: CPU cycles (better than nanosecond)
   * Win32: the resolution of QueryPerformanceCounter(), should be better
     than microseconds
   * unix-like systems (including MacOS X?): microseconds (gettimeofday())
   * others: 1 second (time())
This function (and other time related ones) is in csound.c (may need to
change some #ifdefs, as I cannot test all systems).
Of course, this still does not guarantee 100% safety for temporary file
names. We can either use tmpfile(), or implement system dependent temporary
file code (with mkstemp() or whatever is available) and add it to the API so
that the #ifdefs will at least only appear in one place.
tmpfile() has the advantage that it is ANSI, and should be reliable, but
there is no way to control when the files are deleted, and it is not compatible
with the current way of using temporary files in Csound.


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-01-30 11:09
FromRichard Dobson
SubjectRe: [Cs-dev] Csound 4 is not ANSI C89
Viusual C++ v6 does not support it, and I have now checked the free download of 
Visual C++ 7, and that does not support it either (no stdint.h anywhere, nor are 
the types defined anywhere else). I have yet to try the beta of Visual C++ .NET 
2005 (demands more space than my spare machine can supply), but even if that 
does support C99 (and assumning it is not modified or "extended" in some way), 
many developers are likely to stick to v7, or even v6 for some time yet. Indeed, 
having found that even the V7 optimiser still generates astonishingly 
pathological instant-crash code for one particular program of mine, while the 
Intel compiler generates correct/efficient/compact code, I am currently rather 
more likely to upgrade to the Intel compiler than VC vX; and that does not 
support C99 either as far as I can see!

So I think we will want to stick to ANSI for the forseeable future. At the very 
least, given the new dependence on plugins, we would want to be sure C99 modules 
can link to C89 ones, and the introduction of new types into c99 would seem to 
preclude that, except where the C99 modules are ANSI compliant anyway.



Richard Dobson



Istvan Varga wrote:
> John D. Ramsdell wrote:
> 
>> I noticed that csound/ccsound.c was not ANSI C89, so I tried compiling
>> the Csound 4 source using GCC with -ansi.  I found out there are many
>> parts of Csound 4 that are not ANSI C89.  The file csound/aifc.c
>> contains multi-byte characters, but worse, csound/csound.h uses C++
>> style one line comments--a C99 feature.  I fixed csound/ccsound.c,
>> but did not touch anything else.
> 
> 
> Would it be possible to switch to C99, at least in Csound5 ? It has
> many useful features compared to C89. How many people use compilers
> that still do not support C99 ?
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
> Tool for open source databases. Create drag-&-drop reports. Save time
> by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
> Download a FREE copy at http://www.intelliview.com/go/osdn_nl
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> 




-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net