-#if 0
-/*
-* aim_getfile_send - send a FULL file down (ie: blocking; that is: DON'T USE IT, use send_chunk below.)
-* @conn: the OFT connection to shove the data down,
-* @tosend: is the FILE
-* for the file to send
-* @fh: the filled-in fh value
-
-*
-* returns -1 on error, 1 on success. This sends the whold file and
-* blocks, so it will totally mess you up if you use it. use the
-* send_chunk below and work out a schduling setup or some such.
-
-*
-*/
-faim_export int aim_getfile_send(struct aim_conn_t *conn, FILE *tosend, struct aim_fileheader_t *fh)
-{
- int pos, bufpos, i;
- const int bufsize = 4096;
- char *buf;
-
- /* sanity checks
- */
-
- if(conn->type != AIM_CONN_TYPE_RENDEZVOUS || conn->subtype != AIM_CONN_SUBTYPE_OFT_GETFILE)
- { faimdprintf(1, "getfile_send: conn->type(0x%04x) != RENDEZVOUS or conn->subtype(0x%04x) != GETFILE\n", conn->type, conn->subtype);
- return -1;
- }
- if(!tosend)
- { faimdprintf(1, "getfile_send: file pointer isn't valid\n");
- return -1;
- }
- if(!fh)
- { faimdprintf(1, "getfile_send: fh isn't valid\n");
- return -1;
- }
- /* real code
- */
-
- if(!(buf = (char *)calloc(1, bufsize)))
- { perror("faim: getfile_send: calloc:");
- faimdprintf(2, "getfile_send calloc error\n");
- return -1;
- } pos = 0;
- if( fseek(tosend, 0, SEEK_SET) == -1)
- { perror("faim: getfile_send: fseek:");
- faimdprintf(2, "getfile_send fseek error\n");
- } faimdprintf(2, "faim: getfile_send: using %i byte blocks\n", bufsize);
- for(pos = 0;
- pos < fh->size;
- pos++) { bufpos = pos % bufsize;
- if(bufpos == 0 && pos > 0)
- {
- /* filled our buffer. spit it across the wire
- */
-
- if ( (i = send(conn->fd, buf, bufsize, 0)) != bufsize )
- { perror("faim: getfile_send: write1: ");
- faimdprintf(1, "faim: getfile_send: whoopsy, didn't write it all...\n");
- free(buf);
- return -1;
- } }
- if( (buf[bufpos] = fgetc(tosend)) == EOF)
- {
- if(pos != fh->size)
- { printf("faim: getfile_send: hrm... apparent early EOF at pos 0x%x of 0x%lx\n", pos, fh->size);
- faimdprintf(1, "faim: getfile_send: hrm... apparent early EOF at pos 0x%lx of 0x%lx\n", pos, fh->size);
- free(buf);
- return -1;
- } } }
- if( (i = send(conn->fd, buf, bufpos+1, 0)) != (bufpos+1))
- { perror("faim: getfile_send: write2: ");
- faimdprintf(1, "faim: getfile_send cleanup: whoopsy, didn't write it all...\n");
- free(buf);
- return -1;
- } free(buf);
- fclose(tosend);
- return 1;
-}
-
-/*
-* aim_getfile_send_chunk - send a chunk of a file down a conn
-* @conn: the OFT connection to shove the data down,
-* @tosend: the buffer to send
-* @fh: the filled-in fh value
-* @pos: the position to start at (see below)
-* @bufsize: the size of the chunk to send
-
-*
-* returns -1 on error, new pos on success.
-* Notes on usage:
-* You don't really have to keep track of pos if you don't want
-* to. just always call with -1 for pos, and it'll use the one
-* contained within the FILE
-*.
-
-*
-* if (pos + chunksize > fh->size), we only send as much data as we
-* can get (ie: up to fh->size.
-
-*
-* the value of pos: at beginning should be 0, after 5 bytes are sent
-* should be 5); -1 for "don't seek"
-
-*
-* GOING TO BE CHANGED TO USE unsigned char
-* BUFFERS!!!
-*/
-faim_export int aim_getfile_send_chunk(struct aim_conn_t *conn, FILE *tosend, struct aim_fileheader_t *fh, int pos, int bufsize)
-{
- int bufpos;
- char *buf;
-
- /* sanity checks
- */
-
- if(conn->type != AIM_CONN_TYPE_RENDEZVOUS || conn->type != AIM_CONN_SUBTYPE_OFT_GETFILE)
- { faimdprintf(1, "faim: getfile_send_chunk: conn->type(0x%04x) != RENDEZVOUS or conn->subtype(0x%04x) != GETFILE\n", conn->type, conn->subtype);
- return -1;
- }
- if(!tosend)
- { faimdprintf(1, "faim: getfile_send_chunk: file pointer isn't valid\n");
- return -1;
- }
- if(!fh)
- { faimdprintf(1, "faim: getfile_send_chunk: fh isn't valid\n");
- return -1;
- }
- /* real code
- */
-
- if(!(buf = (char *)calloc(1, bufsize)))
- { perror("faim: getfile_send_chunk: calloc:");
- faimdprintf(2, "faim: getfile_send_chunk calloc error\n");
- return -1;
- }
- if(pos != -1)
- {
- if( fseek(tosend, pos, SEEK_SET) == -1)
- { perror("faim: getfile_send_chunk: fseek:");
- faimdprintf(2, "faim: getfile_send_chunk fseek error\n");
- } } faimdprintf(2, "faim: getfile_send_chunk: using %i byte blocks\n", bufsize);
- for(bufpos = 0;
- pos < fh->size;
- bufpos++, pos++) {
- if( (buf[bufpos] = fgetc(tosend)) == EOF)
- {
- if(pos != fh->size)
- { faimdprintf(1, "faim: getfile_send_chunk: hrm... apparent early EOF at pos 0x%x of 0x%x\n", pos, fh->size);
- free(buf);
- return -1;
- } } }
- if( send(conn->fd, buf, bufpos+1, 0) != (bufpos+1))
- { faimdprintf(1, "faim: getfile_send_chunk cleanup: whoopsy, didn't write it all...\n");
- free(buf);
- return -1;
- } free(buf);
- return (pos + bufpos);
-}
-#endif
-/*
-* aim_tx_destroy - free's tx_command_t's
-* @command: the command to free