Exemplo n.º 1
0
int send_email(int socket,char *from,char *address,char *subject,char *content){
	char message[BUFSIZ] = "";
	char *content_encode = NULL;

	strcpy(message,"MAIL FROM: <");
	strcat(message,from);
	strcat(message,">");
	client_send(socket,message);
	get_response(socket,message,BUFSIZ);
	printf("%s\n",message);

	strcpy(message,"RCPT TO: <");
	strcat(message,address);
	strcat(message,">");
	client_send(socket,message);
	get_response(socket,message,BUFSIZ);
	printf("%s\n",message);

	client_send(socket,"DATA");
	get_response(socket,message,BUFSIZ);
	printf("%s\n",message);

	strcpy(message,"From: ");
	strcat(message,from);
	client_send(socket,message);

	strcpy(message,"To: ");
	strcat(message,address);
	client_send(socket,message);

	strcpy(message,"Subject:");
	strcat(message,subject);
	client_send(socket,message);

	client_send(socket,"MIME-Version:1.0");
	
	client_send(socket,"Content-Type:multipart/alternative;");
	client_send(socket,"boundary=----=smtp_demo");
	client_send(socket,"\r\n----=smtp_demo");


	client_send(socket,"Content-Type:text/plain;charset=utf-8");
	client_send(socket,"Content-Transfer-Encoding: 8bit\r\n");
	client_send(socket,content);
	client_send(socket,"\r\n----=smtp_demo");

	client_send(socket,"Content-Type:text/html;charset=utf-8");
	client_send(socket,"Content-Transfer-Encoding: 8bit\r\n");
	client_send(socket,content);
	client_send(socket,"\r\n----=smtp_demo");
	client_send(socket,".");
	memset(message,0,BUFSIZ);
	get_response(socket,message,BUFSIZ);
	printf("%s\n",message);
}
Exemplo n.º 2
0
STATIC void
show_target(uint32_t id, iscsid_list_kind_t kind)
{
	iscsid_list_id_t req;
	iscsid_response_t *trsp, *prsp;
	iscsid_get_target_rsp_t *targ;
	iscsid_get_portal_rsp_t *port;
	unsigned i;

	/* get target info */
	req.list_kind = kind;
	req.id.id = id;
	req.id.name[0] = '\0';
	send_request(ISCSID_GET_TARGET_INFO, sizeof(req), &req);

	trsp = get_response(TRUE);
	if (trsp->status) {
		status_error(trsp->status);
	}
	targ = (iscsid_get_target_rsp_t *)(void *)trsp->parameter;

	/* display basic target info */
	printf("%6d", targ->target_id.id);
	if (targ->target_id.name[0]) {
		printf(" [%s]", targ->target_id.name);
	}
	printf(": %s", targ->TargetName);
	if (targ->TargetAlias[0]) {
		printf(" (%s)", targ->TargetAlias);
	}
	printf("\n");

	/* now get and display info on the target's portals */
	for (i = 0; i < targ->num_portals; i++) {
		req.id.id = targ->portal[i];
		send_request(ISCSID_GET_PORTAL_INFO, sizeof(req), &req);
		prsp = get_response(FALSE);
		if (prsp->status) {
			status_error(prsp->status);
		}
		port = (iscsid_get_portal_rsp_t *)(void *)prsp->parameter;

		printf("   %6d", port->portal_id.id);
		if (port->portal_id.name[0]) {
			printf(" [%s]", port->portal_id.name);
		}
		printf(": %s:%d", port->portal.address, port->portal.port);
		if (kind != SEND_TARGETS_LIST) {
			printf(",%d", port->portal.group_tag);
		}
		printf("\n");
		free_response(prsp);
	}
	free_response(trsp);
}
Exemplo n.º 3
0
int
set_node_name(int argc, char **argv)
{
	iscsid_set_node_name_req_t req;
	iscsid_response_t *rsp;
	uint64_t isid;

	memset(&req, 0x0, sizeof(req));
	if (!cl_get_string('n', (char *)req.InitiatorName, argc, argv)) {
		arg_missing("Initiator Name");
	}
	cl_get_string('A', (char *)req.InitiatorAlias, argc, argv);
	isid = cl_get_longlong('i', argc, argv);
	hton6(req.ISID, isid);

	check_extra_args(argc, argv);

	send_request(ISCSID_SET_NODE_NAME, sizeof(req), &req);

	rsp = get_response(FALSE);
	if (rsp->status) {
		status_error(rsp->status);
	}
	free_response(rsp);

	printf("OK\n");
	return 0;
}
Exemplo n.º 4
0
int collect_replies(fd_set *master_set, int maxfd)
{
    struct timeval tv;
    int retval;
    fd_set tmpset;

    tv.tv_sec = 1;
    tv.tv_usec = 0;

    while (1)
    {
        memcpy(&tmpset, master_set, sizeof(tmpset));
        retval = select(maxfd + 1, &tmpset, NULL, NULL, &tv);

        if (retval < 0 && errno != EINTR)
        {
            ROS_ERROR("Select exited with an error code.");
            return -1;
        }

        if (!retval)
            return 0;

        ROS_INFO("Got packet %i.", retval);
        for (int i = 0; i <= maxfd && retval > 0; i++)
            if (FD_ISSET(i, &tmpset))
            {
                get_response(i);
                retval--;
            }
    }
}
Exemplo n.º 5
0
 implement(const char* host, unsigned short port)
     : debug_(false), tcp_(host, port)
 {
     response rsp = get_response();
     if (rsp.status[0] != '2')
         tcp_.close();
 }
int send_req(char *req, int req_len, char *resp_buf, int *buf_len)
{
  struct sockaddr_in d_addr;
  int len;
  int ret;

  memset(&d_addr, 0, sizeof(d_addr));
  d_addr.sin_family = PF_INET;
  d_addr.sin_addr.s_addr = inet_addr(dest_ip);
  d_addr.sin_port = htons(dest_port);

  len = sendto(cmd_sock, req, req_len, 0,
               (struct sockaddr *)&d_addr, sizeof(struct sockaddr_in));

  if (len != req_len)
  {
    ret = RET_SOCK_WRITE_ERROR;
  }

  if (resp_buf)
  {
    ret = get_response(cmd_sock, resp_buf, buf_len);
    if (ret != RET_OK)
    {
      goto EXIT;
    }
  }

  ret = RET_OK;

  EXIT:

  return(ret);
}
Exemplo n.º 7
0
static int set_noticed_model_bins (Isis_Rmf_t *rmf, int num_chan, int *chan_notice, /*{{{*/
                                   int num_model, int *model_notice)
{
   Elem_Type *elem = get_response (rmf);
   int k;

   (void) num_chan;

   memset ((char *)model_notice, 0, num_model * sizeof(int));

   for (k = 0; k < num_model; k++)
     {
        Elem_Type *e = &elem[k];
        unsigned int n = e->num_chan;

        if (n <= 1)
          {
             if (n == 0 || chan_notice[ e->chan.s ])
               model_notice[k] = 1;
          }
        else if (n > 1)
          {
             unsigned int i, *chv = e->chan.v;
             for (i = 0; i < n; i++)
               {
                  if (chan_notice[chv[i]])
                    model_notice[k] = 1;
               }
          }
     }

   return 0;
}
Exemplo n.º 8
0
int
add_portal(int argc, char **argv)
{
	iscsid_add_portal_req_t port;
	iscsid_response_t *rsp;
	iscsid_add_portal_rsp_t *res;

	if (!cl_get_portal(&port, argc, argv)) {
		arg_missing("Portal Address");
	}
	if (!cl_get_id('I', &port.target_id, argc, argv)) {
		arg_missing("Target ID");
	}
	cl_get_symname(port.sym_name, argc, argv);
	check_extra_args(argc, argv);

	send_request(ISCSID_ADD_PORTAL, sizeof(port), &port);
	rsp = get_response(FALSE);

	if (rsp->status) {
		status_error(rsp->status);
	}
	res = (iscsid_add_portal_rsp_t *)(void *)rsp->parameter;

	printf("Added Portal %d to Target %d\n",
		res->portal_id.id, res->target_id.id);
	free_response(rsp);
	return 0;
}
Exemplo n.º 9
0
int
add_connection(int argc, char **argv)
{
	iscsid_login_req_t loginp;
	iscsid_login_rsp_t	*loginrsp;
	iscsid_response_t *rsp;

	memset(&loginp, 0x0, sizeof(loginp));
	loginp.login_type = ISCSI_LOGINTYPE_MAP;
	cl_get_id('I', &loginp.session_id, argc, argv);

	login_or_add(&loginp, argc, argv);

	send_request(ISCSID_ADD_CONNECTION, sizeof(loginp), &loginp);

	rsp = get_response(FALSE);
	if (rsp->status) {
		status_error(rsp->status);
	}
	loginrsp = (iscsid_login_rsp_t *)(void *)(rsp->parameter);
	printf("Added Connection %d\n", loginrsp->connection_id.id);

	free_response(rsp);
	return 0;
}
Exemplo n.º 10
0
Arquivo: file.c Projeto: jtsymon/cws
int write_headers (int fd) {
    int headers_len;
    char *headers = get_response(&headers_len);
    int error = (!headers || headers_len <= 0 || write (fd, headers, headers_len) < 0);
    free (headers);
    return error;
}
Exemplo n.º 11
0
int main()
{
    int response;

    response = get_response( QUESTION );
    return response;
}
int
send_request_long (int cmd, int p1, int p2, int p3, int p4, int p5,
		   const char *payload)
{
  ossmix_commad_packet_t msg;

  memset (&msg, 0, sizeof (msg));

  msg.cmd = cmd;
  msg.p1 = p1;
  msg.p2 = p2;
  msg.p3 = p3;
  msg.p4 = p4;
  msg.p5 = p5;
  msg.ack_rq = 1;
  msg.payload_size = strlen (payload);

  if (do_byteswap)
    byteswap_msg (&msg);

  if (write (sockfd, &msg, sizeof (msg)) != sizeof (msg))
    {
      fprintf (stderr, "Write to socket failed\n");
    }
  if (write (sockfd, payload, msg.payload_size) != msg.payload_size)
    {
      fprintf (stderr, "Write to socket failed\n");
    }
  return get_response ();
}
Exemplo n.º 13
0
/**
 * Return -1 on sink, 1 on hit (no sink), -2 on game over, 0 on miss
 */
int do_fire(const int sock, const int x, const int y)
{
  BMesg *buf;
  int nbytes;
  buf = CreateBMesg(BFIRE, x, y);
  if ( (nbytes = send(sock, buf, sizeof(BMesg), 0)) == -1) { /*send error*/
    cleanup_ncurses();
    perror("send error");
    exit(EXIT_FAILURE);
  }
  //we successfully sent
  //printw("Sent data...\n");
  refresh();

  //receive response
  get_response(sock, buf);
  if (buf->msg == BHIT) {
    if ( strcmp(buf->code,SUNK) == 0 ) {
      //printw("You sunk them!");
      return -1;
    } else if ( strcmp(buf->code,GAME_OVER) == 0){
      return -2;
    } else {
      //printw("You hit them!");
      return 1;
    }
    refresh();
  } else {
    return 0;
    //printw("You missed!");
  }
  //WE SHOULD NEVER GET HERE!
  return -100;
  //TODO: get rid of memory leaks (deallocate everything allocated with CreateBMesg)
}
Exemplo n.º 14
0
static int redistribute (Isis_Rmf_t *rmf, unsigned int in_lam, double flux, /*{{{*/
                         double *det_chan, unsigned int num_ebounds)
{
   Elem_Type *elem = get_response (rmf);
   Elem_Type *e;
   unsigned int n;

   (void) num_ebounds;

   if (elem == NULL)
     return -1;

   e = &elem[in_lam];
   n = e->num_chan;

   if (n == 1)
     {
        det_chan[ e->chan.s ] += flux * e->resp.s;
     }
   else if (n > 1)
     {
        float *resp = e->resp.v;
        unsigned int i, *chv = e->chan.v;

        for (i = 0; i < n; i++)
          det_chan[chv[i]] += flux * resp[i];
     }

   return 0;
}
Exemplo n.º 15
0
BOOL CSMTP::Disconnect()
{
	BOOL ret;
	if( !m_bConnected )
		return TRUE;

	// Disconnect gracefully from the server and close the socket
	CString sQuit = _T( "QUIT\r\n" );
	send(m_wsSMTPServer, (LPCTSTR)sQuit, sQuit.GetLength(), 0);

	// No need to check return value here.
	// If it fails, the message is available with GetLastError
	ret = get_response( QUIT_SUCCESS );
	shutdown(m_wsSMTPServer, 0x02);
	closesocket(m_wsSMTPServer);

	if( response_buf != NULL )
	{
		delete[] response_buf;
		response_buf = NULL;
	}

	m_bConnected = FALSE;
	return ret;
}
Exemplo n.º 16
0
int
login(int argc, char **argv)
{
	iscsid_login_req_t loginp;
	iscsid_login_rsp_t *res;
	iscsid_response_t *rsp;

	memset(&loginp, 0x0, sizeof(loginp));
	loginp.login_type = (cl_get_opt('m', argc, argv))
						? ISCSI_LOGINTYPE_NOMAP : ISCSI_LOGINTYPE_MAP;

	login_or_add(&loginp, argc, argv);

	send_request(ISCSID_LOGIN, sizeof(loginp), &loginp);

	rsp = get_response(FALSE);
	if (rsp->status) {
		status_error(rsp->status);
	}
	res = (iscsid_login_rsp_t *)(void *)rsp->parameter;
	printf("Created Session %d, Connection %d\n",
		res->session_id.id, res->connection_id.id);

	free_response(rsp);
	return 0;
}
Exemplo n.º 17
0
int
add_initiator(int argc, char **argv)
{
	iscsid_add_initiator_req_t req;
	iscsid_add_initiator_rsp_t *res;
	iscsid_response_t *rsp;

	memset(&req, 0x0, sizeof(req));
	if (!cl_get_string('a', (char *)req.address, argc, argv)) {
		arg_missing("Interface Address");
	}
	cl_get_symname(req.name, argc, argv);
	check_extra_args(argc, argv);

	send_request(ISCSID_ADD_INITIATOR_PORTAL, sizeof(req), &req);
	rsp = get_response(FALSE);
	if (rsp->status) {
		status_error(rsp->status);
	}
	res = (iscsid_add_initiator_rsp_t *)(void *)rsp->parameter;
	printf("Added Initiator Portal %d\n", res->portal_id);

	free_response(rsp);
	return 0;
}
Exemplo n.º 18
0
int
add_isns_server(int argc, char **argv)
{
	iscsid_add_isns_server_req_t arg;
	iscsid_add_isns_server_rsp_t *res;
	iscsid_response_t *rsp;

	memset(&arg, 0x0, sizeof(arg));
	if (!(cl_get_isns(&arg, argc, argv))) {
		arg_missing("Server Address");
	}
	check_extra_args(argc, argv);

	send_request(ISCSID_ADD_ISNS_SERVER, sizeof(arg), &arg);
	rsp = get_response(FALSE);

	if (rsp->status) {
		status_error(rsp->status);
	}
	res = (iscsid_add_isns_server_rsp_t *)(void *)rsp->parameter;

	printf("Added iSNS Server ID %d\n", res->server_id);

	free_response(rsp);
	return 0;
}
Exemplo n.º 19
0
STATIC int
do_list_targets(int argc, char **argv, iscsid_list_kind_t kind)
{
	iscsid_get_list_req_t lst;
	iscsid_response_t *rsp;
	iscsid_get_list_rsp_t *list;
	unsigned i;

	check_extra_args(argc, argv);

	/* get the list of targets */
	lst.list_kind = kind;
	send_request(ISCSID_GET_LIST, sizeof(lst), &lst);
	rsp = get_response(TRUE);
	if (rsp->status) {
		status_error(rsp->status);
	}
	list = (iscsid_get_list_rsp_t *)(void *)rsp->parameter;

	/* display all targets */
	for (i = 0; i < list->num_entries; i++) {
		show_target(list->id[i], kind);
	}
	free_response(rsp);
	return 0;
}
Exemplo n.º 20
0
int connect2server(int *socket_p,char *host,char *port){
	char response[BUFSIZ] = "";
	struct addrinfo hint = {0},*res = NULL;
	int function_flag = -1;

	hint.ai_family = AF_UNSPEC;
	hint.ai_socktype = SOCK_STREAM;
	function_flag = getaddrinfo(host,"smtp",&hint,&res);
	if (function_flag != 0){
		return -1;
	}else{
		struct addrinfo *temp = res;
		while (temp){
			*socket_p = socket(temp->ai_family,SOCK_STREAM,temp->ai_protocol);
			if (*socket_p == -1){
				temp = temp->ai_next;
			}else{
				break;
			}
		}
		function_flag = connect(*socket_p,temp->ai_addr,temp->ai_addrlen);
		get_response(*socket_p,response,BUFSIZ);
		printf("%s\n",response);
		freeaddrinfo(res);
		return function_flag;
	}
}
Exemplo n.º 21
0
uint32_t
get_sessid(int argc, char **argv, int optional)
{
	iscsid_sym_id_t sid;
	iscsid_search_list_req_t srch;
	iscsid_response_t *rsp;

	if (!cl_get_id('I', &sid, argc, argv)) {
		if (!optional) {
			arg_missing("Session ID");
		}
		return 0;
	}

	if (!sid.id) {
		srch.list_kind = SESSION_LIST;
		srch.search_kind = FIND_NAME;
		strlcpy((char *)srch.strval, (char *)sid.name, sizeof(srch.strval));
		srch.intval = 0;

		send_request(ISCSID_SEARCH_LIST, sizeof(srch), &srch);
		rsp = get_response(FALSE);
		if (rsp->status)
			status_error_slist(rsp->status);

		GET_SYM_ID(sid.id, rsp->parameter);
		free_response(rsp);
	}
	return sid.id;
}
Exemplo n.º 22
0
static char * fetch(BIO *bio,
                  const void *key,
                  uint16_t nkey)
{
    protocol_binary_request_get request;
    protocol_binary_response_no_extras response;
    char *payload;

    memset(&request, 0, sizeof(request));
    request.message.header.request.magic = PROTOCOL_BINARY_REQ;
    request.message.header.request.opcode = PROTOCOL_BINARY_CMD_GET;
    request.message.header.request.keylen = htons((uint16_t)nkey);
    request.message.header.request.bodylen = htonl(nkey);

    ensure_send(bio, &request, sizeof(request.bytes));
    ensure_send(bio, key, nkey);
    if (BIO_flush(bio) != 1) {
        fprintf(stderr, "Failed to flush bio instance\n");
        exit(EXIT_FAILURE);
    }

    payload = get_response(bio, &response);
    cb_assert(ntohs(response.message.header.response.status) == PROTOCOL_BINARY_RESPONSE_SUCCESS);
    cb_assert(payload != NULL);
    return payload;

}
Exemplo n.º 23
0
int fill_out_form(app_input_t form_questions[], int num_fields)
{
    int i;
    page_option pg_opt;
    for (i = 0; i < num_fields; i++) {
        app_input_t *form_question = &form_questions[i];
        while (form_question->input == NULL) {
            printf("%s%s: ", form_question->text_field, form_question->input_specification);
            pg_opt = get_response();
            if (pg_opt < 0) {
                continue;
            } else if (pg_opt != INPUT) {
                goto page_option_selected;
            } else if (!form_question->is_required && memcmp(g_user_resp, "", 1) == 0) {
                form_question->input = calloc(1, form_question->max_input_length);
                break;
            } else if (form_question->verify_input(g_user_resp, form_question->max_input_length) != 0) {
                continue;
            }

            form_question->input = calloc(1, form_question->max_input_length);
            strcpy(form_question->input, g_user_resp);
        }
    }

    return NOOP;

page_option_selected:
    return pg_opt;
}
Exemplo n.º 24
0
// callback : have received a Pdu from the target host with given read comm str
// this is really simplistic, but gives the general idea
int agent_impl::handle_get( Pdu &pdu, UdpTarget &target)
{
  ACE_TRACE("agent_impl::handle_get");
  OctetStr mgr_rd_str, agent_rd_str;
  target.get_read_community(mgr_rd_str); // requster's read community string
  tgt_.get_read_community(agent_rd_str); // this agent's read community string

  //  1. verify we have a valid read string else drop pdu (no response to caller)
  if (mgr_rd_str != agent_rd_str) {
     ACE_DEBUG((LM_DEBUG, "agent_impl::handle_get: invalid read community recvd\n"));
     return 0;
  }

  // 2. iterate over each varbind in the pdu, filling providing responses
  int fdone = 0;
  for (int i = 0; (i < pdu.get_vb_count()) && !fdone; i++) {
    Vb vb;
    pdu.get_vb(vb, i);
    if (get_response(vb)) { // set a value for the oid if we can else
      set_error_status(&pdu, SNMP_ERROR_NO_SUCH_NAME); // these ought to be member
      set_error_index(&pdu, i); // functions but are not yet...
      fdone++; // trigger flag to exit loop early
    }
    else // failed, return noSuch error
      pdu.set_vb(vb, i);
  }

  // 3. lastly, return the pkt to the caller
  return respond(pdu, target);
}
Exemplo n.º 25
0
int
get_reminder ( S710_Driver *d, S710_Packet_Index which, reminder_t *reminder )
{
  packet_t *p;
  int       ok = 0;

  if ( which < S710_GET_REMINDER_1 || 
       which > S710_GET_REMINDER_7 )
    return 0;

  p = get_response ( which, d );
  if ( p != NULL) {
    reminder->which = p->data[0] + 1;
    extract_label ( &p->data[6], &reminder->label, 7 );
    memset(&reminder->date,0,sizeof(reminder->date));
    reminder->date.tm_sec  = 0;
    reminder->date.tm_min  = BCD(p->data[1]);
    reminder->date.tm_hour = BCD(p->data[2]);
    reminder->date.tm_mday = BCD(p->data[3]);
    reminder->date.tm_mon  = LNIB(p->data[5]) - 1;
    reminder->date.tm_year = BCD(p->data[4]) + 100;
    reminder->date.tm_wday = 0;
    reminder->on           = (UNIB(p->data[5]) & 0x01) ? S710_ON : S710_OFF;
    reminder->exercise     = LNIB(p->data[13]);
    reminder->repeat       = UNIB(p->data[13]);
    free ( p );
    ok = 1;
  }

  return ok;
}
Exemplo n.º 26
0
int main(int argc, char *argv[]) {
  tty_mode(0); // save tty mode
  set_cr_noecho_mode();
  int response = get_response(QUESTION);
  tty_mode(1); // reload tty mode
  return response;
}
Exemplo n.º 27
0
int			cmd_get(int sockfd, char *line, uint32_t cmd, t_param *param)
{
	t_command		command;
	char			*src;
	char			*dst;

	command.magic = MAGIC_CMD;
	command.command = cmd;
	if (!get_2_params(line, &src, &dst))
	{
		printf(INVALID_ARG_GET "\n");
		return (0);
	}
	if (!send_data(sockfd, &command, sizeof(t_command)))
	{
		param->to_deco = 1;
		printf(SEND_CMD_FAIL "\n");
		return (0);
	}
	if  (!send_string(sockfd, src, ft_strlen(src)))
	{
		printf(SEND_STRING_FAIL "\n");
		return (0);
	}
	if (!(get_response(sockfd, dst, param)))
		return (0);
	return (1);
}
Exemplo n.º 28
0
STATIC int
do_refresh(int argc, char **argv, iscsid_list_kind_t kind)
{
	iscsid_sym_id_t id;
	iscsid_response_t *rsp;
	iscsid_refresh_req_t req;

	req.kind = kind;

	if (cl_get_id('I', &id, argc, argv)) {
		check_extra_args(argc, argv);

		if (!id.id) {
			iscsid_search_list_req_t srch;

			srch.search_kind = FIND_NAME;
			srch.list_kind = kind;
			strlcpy((char *)srch.strval, (char *)id.name,
				sizeof(srch.strval));

			send_request(ISCSID_SEARCH_LIST, sizeof(srch), &srch);
			rsp = get_response(FALSE);
			if (rsp->status) {
				status_error_slist(rsp->status);
			}
			GET_SYM_ID(req.id[0], rsp->parameter);
			free_response(rsp);
		} else {
			req.id[0] = id.id;
		}
		req.num_ids = 1;
	} else {
		req.num_ids = 0;
		check_extra_args(argc, argv);
	}

	req.kind = kind;
	send_request(ISCSID_REFRESH_TARGETS, sizeof(req), &req);

	rsp = get_response(FALSE);
	if (rsp->status) {
		status_error(rsp->status);
	}
	printf("OK\n");
	free_response(rsp);
	return 0;
}
Exemplo n.º 29
0
uint8_t read_block(uint32_t block_number, uint8_t *block_info)
{
	uint8_t error_flag, timeout;
	uint8_t return_value[5];
	ncs = 0;
	timeout = 0;
	error_flag = send_command(17, block_number);
	do
	{
		timeout++;
		if(error_flag == NO_ERRORS)
			error_flag = get_response(1, &return_value);
	}while(return_value != 0x00 && timeout != 0);
	if(timeout == 0)
	{
		error_flag = TIMEOUT_ERROR;
	}
	timeout = 0;
	do
	{
		timeout++;
		if(error_flag == NO_ERRORS)
			error_flag = get_response_no_end(1, &return_value);
	}while(return_value[0] != 0xFE && (return_value[0] & 0xF0) != 0x00   && timeout != 0 && error_flag == NO_ERRORS);
	if(timeout == 0)
	{
		error_flag = TIMEOUT_ERROR;
	}
	if((return_value[0] & 0xF0 )== 0x00)
	{
		error_flag = SDCARD_ERROR;
	}
	if(error_flag == NO_ERRORS)
	{
		error_flag = get_response_no_end(512, block_info);
	}
	
	if(error_flag == NO_ERRORS)
	{
		error_flag = get_response(2, &return_value);
//		CRC16 = return_value[0] * 256 + return_value[1]; Check sum, dont care
	}
	ncs = 1;
	
	return error_flag;
	
}
Exemplo n.º 30
0
int hello(int socket,char *hostname){
	char message[108] = "HELO ";
	strcat(message,hostname);
	client_send(socket,message);
	get_response(socket,message,108);
	printf("%s",message);
	return 0;
}