Added a patch from Tim Waugh to use mktemp instead of mkdtemp

DEVEL_2_0_BRANCH-1
Peter Fales 2001-06-15 04:07:40 +00:00
rodzic f57a437dbc
commit 66d8bc2029
1 zmienionych plików z 11 dodań i 9 usunięć

Wyświetl plik

@ -138,8 +138,7 @@ static char tty_name[PATH_MAX];
#define DEF_TTY_NAME "/dev/ttyS0" #define DEF_TTY_NAME "/dev/ttyS0"
static speed_t tty_baud = DEFAULT_TTY_BAUD; static speed_t tty_baud = DEFAULT_TTY_BAUD;
static char *tmpname; static char tmpdir[] = "/tmp/dc25.XXXXXX";
static char tmpnamebuf[] = "/tmp/dc25.XXXXXX";
static Dc20Info *dc20_info; static Dc20Info *dc20_info;
static Dc20Info CameraInfo; static Dc20Info CameraInfo;
@ -1173,7 +1172,7 @@ static int
convert_pic (char *base_name, int format, int orientation) convert_pic (char *base_name, int format, int orientation)
{ {
FILE *ifp; FILE *ifp;
unsigned char pic[MAX_IMAGE_SIZE]; unsigned char pic[MAX_IMAGE_SIZE];
int res, int res,
image_size, image_size,
image_width, image_width,
@ -1201,7 +1200,7 @@ convert_pic (char *base_name, int format, int orientation)
return -1; return -1;
} }
if (strncmp (pic, COMET_MAGIC, sizeof(COMET_MAGIC)) != 0) { if (strncmp ((char *)pic, COMET_MAGIC, sizeof(COMET_MAGIC)) != 0) {
DBG (10,"convert_pic: error: file %s is not in COMET format\n",base_name); DBG (10,"convert_pic: error: file %s is not in COMET format\n",base_name);
fclose (ifp); fclose (ifp);
return -1; return -1;
@ -1870,10 +1869,9 @@ sane_open (SANE_String_Const devicename, SANE_Handle * handle)
DBG (1,"No device info\n"); DBG (1,"No device info\n");
} }
if ( tmpname == NULL ) { if ( strstr (tmpdir, "XXXXXX") ) {
tmpname = tmpnamebuf; if (!mkdtemp (tmpdir) ) {
if ( mktemp(tmpname) == NULL ) { perror (tmpdir);
perror (tmpname);
DBG (1,"Unable to make temp file name\n"); DBG (1,"Unable to make temp file name\n");
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
@ -2261,13 +2259,17 @@ sane_start (SANE_Handle handle)
* to set the "-u1" flag on the system drives. * to set the "-u1" flag on the system drives.
*/ */
char tmpname[100];
size_t tmpdirlen = strlen (tmpdir);
memcpy (tmpname, tmpdir, tmpdirlen);
strcpy (tmpname + tmpdirlen, "comet");
f = fopen (tmpname,"wb"); f = fopen (tmpname,"wb");
if ( f == NULL ) { if ( f == NULL ) {
DBG (4,"Unable to open tmp file\n"); DBG (4,"Unable to open tmp file\n");
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
strcpy (buffer,COMET_MAGIC); strcpy ((char *)buffer,COMET_MAGIC);
fwrite (buffer,1,COMET_HEADER_SIZE,f); fwrite (buffer,1,COMET_HEADER_SIZE,f);
pic_pck[3] = (unsigned char)dc25_opt_image_number; pic_pck[3] = (unsigned char)dc25_opt_image_number;