125{
  130 
  131#if defined( _MSC_VER )
  132   {
  134 
  135      
  137         return -1;
  138   }
  139#endif
  140 
  141   
  143 
  146      perror(
"Cannot retrieve host name");
 
  147      return -1;
  148   }
  151      perror(
"Cannot retrieve host name");
 
  152      return -1;
  153   }
  154 
  155   
  158 
  159   
  161      perror(
"cannot create socket");
 
  162      return -1;
  163   }
  164 
  165   
  166   memset(&bind_addr, 0, 
sizeof(bind_addr));
 
  167   bind_addr.sin_family = 
AF_INET;
 
  168   bind_addr.sin_addr.s_addr = 0;
  169   bind_addr.sin_port = 
htons((
unsigned short) port);
 
  170 
  173      perror(
"cannot get host name");
 
  174      return -1;
  175   }
  176   memcpy((
char *) &(bind_addr.sin_addr), 
phe->h_addr, 
phe->h_length);
 
  177 
  178   
  179   status = connect(sock, (
struct sockaddr *) &bind_addr, 
sizeof(bind_addr));
 
  181      printf(
"Cannot connect to host %s, port %d\n", host, port);
 
  182      return -1;
  183   }
  184 
  186      printf(
"Successfully connected to host %s, port %d\n", host, port);
 
  187 
  188   
  189   strcpy(boundary, "---------------------------7d0bf1a60904bc");
  191   strcat(
content, 
"\r\nContent-Disposition: form-data; name=\"cmd\"\r\n\r\nSubmit\r\n");
 
  192 
  195              "%s\r\nContent-Disposition: form-data; name=\"unm\"\r\n\r\n%s\r\n",
  197 
  201              "%s\r\nContent-Disposition: form-data; name=\"upwd\"\r\n\r\n%s\r\n",
  203   }
  204 
  205   if (experiment[0])
  207              "%s\r\nContent-Disposition: form-data; name=\"exp\"\r\n\r\n%s\r\n",
  208              boundary, experiment);
  209 
  212              "%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n%s\r\n", boundary,
  214 
  216           "%s\r\nContent-Disposition: form-data; name=\"Text\"\r\n\r\n%s\r\n%s\r\n",
  217           boundary, text, boundary);
  218 
  221 
  225                 "Content-Disposition: form-data; name=\"attfile%d\"; filename=\"%s\"\r\n\r\n",
  227 
  230         memcpy(p, buffer[
i], buffer_size[
i]);
 
  232         strcpy(p, boundary);
  234 
  237      }
  238 
  239   
  242            "Content-Type: multipart/form-data; boundary=%s\r\n", boundary);
  246 
  250   }
  251 
  253 
  256 
  257   
  258
  259
  260
  261
  262
  263
  264
  265 
  266   
  268      printf(
"Request sent to host:\n");
 
  270   }
  271 
  273 
  274   
  277      perror(
"Cannot receive response");
 
  278      return -1;
  279   }
  280 
  281   
  287   }
  289 
  291 
  293      printf(
"Response received:\n");
 
  295   }
  296 
  297   
  299      printf(
"Message successfully transmitted\n");
 
  301      printf(
"No logbook specified\n\n");
 
  303      printf(
"Missing or invalid password\n");
 
  305      printf(
"Missing or invalid user name/password\n");
 
  306   else
  307      printf(
"Error transmitting message\n");
 
  308 
  309   return 1;
  310}
void base64_encode(char *s, char *d)