/* read from stdin ,put data into a temp file
* b is boundary string,use it to end an input
* name in here now is not used
*/
{
char key;
FILE * out;
long size = 0;
char enddata[MAXBOUNDARYLEN];
char fullpath[MAX_DIRLEN];
int index = 0,i;
sprintf(enddata, "%c%c%s", 0x0d, 0x0a, b);
sprintf(fullpath, "%s/%s/%s", useronlineinfo.homedirectory,DOWNLOAD,name);
out = fopen(fullpath, "w+");
if (out == NULL) return 0;
while (fread(&key, 1, 1, stdin))
{
if (enddata[index] == '\0') break;
else if (key == enddata[index]) index++;
else
{
for (i = 0; i < index; i++)
{
fwrite(&enddata[i], 1, 1, out);
size++;
}
index = 0;
if (key == enddata[index])
index++;
else
{
fwrite(&key, 1, 1, out);
size++;
}
}
}
fflush(out);
fclose(out);
return 1;
}