forked from pool/csound
152 lines
4.4 KiB
Plaintext
152 lines
4.4 KiB
Plaintext
--- one_file.c-dist 2003-07-28 13:23:59.878487232 +0200
|
|
+++ one_file.c 2003-07-28 15:31:26.337048840 +0200
|
|
@@ -200,12 +200,16 @@
|
|
static int createOrchestra(FILE *unf)
|
|
{
|
|
char *p;
|
|
+ int fd;
|
|
FILE *orcf;
|
|
|
|
- tmpnam(orcname); /* Generate orchestra name */
|
|
- if ((p=strchr(orcname, '.')) != NULL) *p='\0'; /* with extention */
|
|
- strcat(orcname, ".orc");
|
|
- orcf = fopen(orcname, "w");
|
|
+ /* Generate orchestra name */
|
|
+ strcpy(orcname, "/tmp/csoundXXXXXX.orc");
|
|
+ if ((fd = mkstemp(orcname)) < 0) {
|
|
+ perror(Str("Failed to create\n"));
|
|
+ longjmp(exitjmp,1);
|
|
+ }
|
|
+ orcf = fdopen(fd, "w");
|
|
printf(Str("Creating %s (%p)\n"), orcname, orcf);
|
|
if (orcf==NULL){
|
|
perror(Str("Failed to create\n"));
|
|
@@ -219,6 +223,7 @@
|
|
}
|
|
else fputs(buffer, orcf);
|
|
}
|
|
+ fclose(orcf);
|
|
return FALSE;
|
|
}
|
|
|
|
@@ -226,13 +231,15 @@
|
|
static int createScore(FILE *unf)
|
|
{
|
|
char *p;
|
|
+ int fd;
|
|
FILE *scof;
|
|
|
|
- tmpnam(sconame); /* Generate score name */
|
|
- if ((p=strchr(sconame, '.')) != NULL) *p='\0'; /* with extention */
|
|
- strcat(sconame, ".sco");
|
|
- scof = fopen(sconame, "w");
|
|
- /*RWD 3:2000*/
|
|
+ /* Generate score name */
|
|
+ strcpy(sconame, "/tmp/csoundXXXXXX.sco");
|
|
+ if ((fd = mkstemp(orcname)) < 0)
|
|
+ return FALSE;
|
|
+ scof = fdopen(fd, "w");
|
|
+ /*RWD 3:2000*/
|
|
if (scof==NULL)
|
|
return FALSE;
|
|
|
|
@@ -244,6 +251,7 @@
|
|
}
|
|
else fputs(buffer, scof);
|
|
}
|
|
+ fclose(scof);
|
|
return FALSE;
|
|
}
|
|
|
|
@@ -251,16 +259,17 @@
|
|
{
|
|
int size;
|
|
char *p;
|
|
+ int fd;
|
|
FILE *midf;
|
|
int c;
|
|
|
|
- if (tmpnam(midname)==NULL) { /* Generate MIDI file name */
|
|
+ /* Generate MIDI file name */
|
|
+ strcpy(midname, "/tmp/csoundXXXXXX.mid");
|
|
+ if ((fd = mkstemp(midname)) < 0) {
|
|
printf(Str("Cannot create temporary file for MIDI subfile\n"));
|
|
longjmp(exitjmp,1);
|
|
}
|
|
- if ((p=strchr(midname, '.')) != NULL) *p='\0'; /* with extention */
|
|
- strcat(midname, ".mid");
|
|
- midf = fopen(midname, "wb");
|
|
+ midf = fdopen(fd, "wb");
|
|
if (midf==NULL) {
|
|
printf(Str("Cannot open temporary file (%s) for MIDI subfile\n"), midname);
|
|
longjmp(exitjmp,1);
|
|
@@ -333,15 +342,16 @@
|
|
static int createMIDI2(FILE *unf)
|
|
{
|
|
char *p;
|
|
+ int fd;
|
|
FILE *midf;
|
|
|
|
- if (tmpnam(midname)==NULL) { /* Generate MIDI file name */
|
|
+ /* Generate MIDI file name */
|
|
+ strcpy(midname, "/tmp/csoundXXXXXX.mid");
|
|
+ if ((fd = mkstemp(midname)) < 0) {
|
|
printf(Str("Cannot create temporary file for MIDI subfile\n"));
|
|
longjmp(exitjmp,1);
|
|
}
|
|
- if ((p=strchr(midname, '.')) != NULL) *p='\0'; /* with extention */
|
|
- strcat(midname, ".mid");
|
|
- midf = fopen(midname, "wb");
|
|
+ midf = fdopen(fd, "wb");
|
|
if (midf==NULL) {
|
|
printf(Str("Cannot open temporary file (%s) for MIDI subfile\n"),
|
|
midname);
|
|
--- csmain.c-dist 2003-07-28 13:23:06.867546120 +0200
|
|
+++ csmain.c 2003-07-28 15:15:50.720284208 +0200
|
|
@@ -407,10 +407,13 @@
|
|
FILE *scof;
|
|
extern char sconame[];
|
|
void deleteScore(void);
|
|
- tmpnam(sconame); /* Generate score name */
|
|
- if ((p=strchr(sconame, '.')) != NULL) *p='\0'; /* with extention */
|
|
- strcat(sconame, ".sco");
|
|
- scof = fopen(sconame, "w");
|
|
+ int fd;
|
|
+ /* Generate score name */
|
|
+ strcpy(sconame, "/tmp/csoundXXXXXX.sco");
|
|
+ fd = mkstemp(sconame);
|
|
+ if (fd < 0)
|
|
+ dieu(Str("cannot create temp file"));
|
|
+ scof = fdopen(fd, "w");
|
|
fprintf(scof, "f0 86400\n");
|
|
fclose(scof);
|
|
scorename = sconame;
|
|
@@ -498,7 +501,12 @@
|
|
scorename = "score.srt";
|
|
}
|
|
else {
|
|
- scorename = tmpnam(scnm);
|
|
+ int fd;
|
|
+ strcpy(scnm, "/tmp/csoundXXXXXX");
|
|
+ if ((fd = mkstemp(scnm)) < 0)
|
|
+ dieu(Str("cannot create temp file"));
|
|
+ close(fd);
|
|
+ scorename = scnm;
|
|
add_tmpfile(scorename); /* IV - Oct 31 2002 */
|
|
}
|
|
}
|
|
@@ -531,7 +539,12 @@
|
|
playscore = sortedscore = "score.srt";
|
|
}
|
|
else {
|
|
- playscore = sortedscore = tmpnam(nme);
|
|
+ int fd;
|
|
+ strcpy(nme, "/tmp/csoundXXXXXX");
|
|
+ if ((fd = mkstemp(nme)) < 0)
|
|
+ dieu(Str("cannot create temp file"));
|
|
+ close(fd);
|
|
+ playscore = sortedscore = nme;
|
|
add_tmpfile(playscore); /* IV - Oct 31 2002 */
|
|
}
|
|
if (!(scorin = fopen(scorename, "r"))) /* else sort it */
|