Logo Search packages:      
Sourcecode: cafix version File versions  Download package

send.c

#include "custom.h"
int a;
long taille;
char *buffer, *nom, nomcasio[8];
extern int remainingfiles, file, fdev, promptfilenames;
struct stat buf;
    cafixdata *data;

void sendHandshake() {
    if (cafix_handshake_send(fdev, data)) {
        printf("failed! (%i)\n", data->status);}
        return;}

void sendPG() {
    stat(nom, &buf);
    printf("file is %li Bytes long\n", buf.st_size);
    buffer = (char*) malloc(buf.st_size);

    read(file, buffer, buf.st_size);
    data = calloc(1, sizeof (cafixdata));

if (promptfilenames==1) {
                printf("Input filename (7 characters):");
                for(a=0;a<9;a++){
                nomcasio[a]=getchar();
                if (nomcasio[a]=='\n'){ nomcasio[a]='\0'; break;}}
                 nom=nomcasio;}
    data->format = FMT_PROGRAM;
    data->datatype = DATA_PG;
    data->name = nom;//"data";
    printf("should be sending %s\n",nom);
    data->length = buf.st_size;
    data->data = buffer;
/*    printf("Handshaking...");
    if (cafix_handshake_send(fdev, data)) {
        printf("failed! (%i)\n", data->status);
      return -1;
    } else*/
      printf("done!\n");
    printf("Sending...\n");
    if (cafix_send(fdev, data, &show_status)) {
      printf("failed! (%i)\n", data->status);
      return ;// 1;
    } else
      printf("done!\n");
    free(data);
    printf("fichier restants: %i\n", remainingfiles);
     if (remainingfiles==0) {sendEnd();}
    return;
}

 void sendEnd() {
        data = calloc(1, sizeof(cafixdata));
        data->format = FMT_END;
        if (cafix_send(fdev, data, &show_status))
                printf("returns error\n");
        printf("status became %i\n", data->status);
        free(data);}

Generated by  Doxygen 1.6.0   Back to index