Exemple #1
0
/* get the input text,and send it */
void send_text()
{
GtkTextIter start,end;
gchar *text;

if(issucceed==-1){ /* Haven't create a socket */
show_err("Not connected...\n");
}
else
{ /* Socket creating has succeed ,so send message */
text=(gchar *)malloc(MAXSIZE);
if(text==NULL)
{
printf("Malloc error!\n");
exit(1);
}
/* get text */
gtk_text_buffer_get_bounds(GTK_TEXT_BUFFER(input_buffer),&start,&end);
text=gtk_text_buffer_get_text(GTK_TEXT_BUFFER(input_buffer),&start,&end,FALSE);

/* If there is no input,do nothing but return */
if(strcmp(text,"")!=0)
{
send_func(text);
clean_send_text();
show_local_text(text);
}
else
show_err("The message can not be empty...\n");
free(text);
}
}
Exemple #2
0
/*
 * Callback from TURN session to send outgoing packet.
 */
static pj_status_t turn_on_send_pkt(pj_turn_session *sess,
				    const pj_uint8_t *pkt,
				    unsigned pkt_len,
				    const pj_sockaddr_t *dst_addr,
				    unsigned dst_addr_len)
{
    pj_turn_sock *turn_sock = (pj_turn_sock*) 
			      pj_turn_session_get_user_data(sess);
    pj_ssize_t len = pkt_len;
    pj_status_t status;

    if (turn_sock == NULL || turn_sock->is_destroying) {
	/* We've been destroyed */
	// https://trac.pjsip.org/repos/ticket/1316
	//pj_assert(!"We should shutdown gracefully");
	return PJ_EINVALIDOP;
    }

    PJ_UNUSED_ARG(dst_addr);
    PJ_UNUSED_ARG(dst_addr_len);

    status = pj_activesock_send(turn_sock->active_sock, &turn_sock->send_key,
				pkt, &len, 0);
    if (status != PJ_SUCCESS && status != PJ_EPENDING) {
	show_err(turn_sock, "socket send()", status);
    }

    return status;
}
Exemple #3
0
/* get IP address and create socket */
void get_ip(GtkWidget *button,gpointer ip_text)
{
gchar *serv_ip;
int res;
serv_ip=(gchar *)gtk_entry_get_text(GTK_ENTRY((GtkWidget *)ip_text));
res=build_socket(serv_ip);

if(res==1)
show_err("IP Address is  Invalid...\n");
else if(res==-1)
show_err("Connect Failure... \n");/*插入文本到缓冲区*/
else{
show_err("Connect Successful... \n");
issucceed=0;
}
}
Exemple #4
0
INT main(INT argcc, CHAR * argvc[])
{    
	CHAR * argv[] = {
		"xoc.exe",
		"..\\..\\test\\test_ansic.c",
	    "-dump","cfe.tmp",
	};
	INT argc = sizeof(argv)/sizeof(argv[0]);
#else
INT main(INT argc, CHAR * argv[])
{
#endif
	if (!process_cmd(argc, argv)) return 1;
	init_parser();
	g_fe_sym_tab = new SYM_TAB(64); 
	fe_process();

	//Show you all info that generated by CfrontEnd.
	dump_scope(get_global_scope(), 0xFFFFFFFF);	
	show_err();
	show_warn();
	fprintf(stdout, "\n%s - (%d) error(s), (%d) warnging(s)\n",
					g_source_file_name, 
					g_err_msg_list.get_elem_count(),
					g_warn_msg_list.get_elem_count());
	fini_parser();
	finidump();
	return 0;
}
Exemple #5
0
/*
 * Callback on new TCP connection.
 */
static void lis_on_accept_complete(pj_ioqueue_key_t *key, 
				   pj_ioqueue_op_key_t *op_key, 
				   pj_sock_t sock, 
				   pj_status_t status)
{
    struct tcp_listener *tcp_lis;
    struct accept_op *accept_op = (struct accept_op*) op_key;

    tcp_lis = (struct tcp_listener*) pj_ioqueue_get_user_data(key);

    PJ_UNUSED_ARG(sock);

    do {
	/* Report new connection. */
	if (status == PJ_SUCCESS) {
	    char addr[PJ_INET6_ADDRSTRLEN+8];
	    PJ_LOG(5,(tcp_lis->base.obj_name, "Incoming TCP from %s",
		      pj_sockaddr_print(&accept_op->src_addr, addr,
					sizeof(addr), 3)));
	    transport_create(accept_op->sock, &tcp_lis->base,
			     &accept_op->src_addr, accept_op->src_addr_len);
	} else if (status != PJ_EPENDING) {
	    show_err(tcp_lis->base.obj_name, "accept()", status);
	}

	/* Prepare next accept() */
	accept_op->src_addr_len = sizeof(accept_op->src_addr);
	status = pj_ioqueue_accept(key, op_key, &accept_op->sock,
				   NULL,
				   &accept_op->src_addr,
				   &accept_op->src_addr_len);

    } while (status != PJ_EPENDING && status != PJ_ECANCELLED &&
	     status != PJ_STATUS_FROM_OS(PJ_BLOCKING_ERROR_VAL));
}
  void enter()
  {
   while(1)
	{
	 if(successfullogin==1)
	   break;
	 show_close_button();
	 showmouseptr();
	 getmousepos(&button,&x,&y);
	  if((button&1)==1)
	  { corx=x;
		cory=y;
		if((corx>170&&corx<280)&&(cory>250&&cory<290))
		 {
			setcolor(WHITE);
			line(170,290,280,290);
			line(280,250,280,290);
			setcolor(DARKGRAY);
			line(170,250,280,250);
			line(170,250,170,290);
			delay(125);
			hidemouseptr();
			resetloginform();
			login();
		 }
		else if((corx>310&&corx<430)&&(cory>250&&cory<290))
		 {
			hidemouseptr();
			setcolor(WHITE);
			line(310,290,430,290);
			line(430,250,430,290);
			setcolor(DARKGRAY);
			line(310,250,430,250);
			line(310,250,310,290);
			delay(125);
			f1=fopen("admin","r");
			rewind(f1);
			fread(&admin,sizeof(admin),1,f1);
			if((strcmp(admin.loginid,loginid)==0) && (strcmp(admin.password,password)==0))
			 {
			  successfullogin=1;
			  return;
			 }
			else
			{
			 show_err("Wrong LoginID or Password");
			 resetloginform();
			 login();
			}
		 }
		else if((corx>618&&corx<630)&&(cory>8&&cory<20))
		{
		  show_exit_message();
		  delay(500);
		  exit(0);
		}
	  }
	}
  }
Exemple #7
0
/* On error, terminate session */
static void sess_fail(pj_turn_sock *turn_sock, const char *title,
		      pj_status_t status)
{
    show_err(turn_sock, title, status);
    if (turn_sock->sess) {
	pj_turn_session_destroy(turn_sock->sess, status);
    }
}
int main (void)
{
    int count = 5;

    system_init ();
    tinygl_init (LOOP_RATE);
    tinygl_font_set (&font3x5_1);
    tinygl_text_speed_set (MESSAGE_RATE);
    tinygl_text_mode_set (TINYGL_TEXT_MODE_SCROLL);
    tinygl_text_dir_set (TINYGL_TEXT_DIR_ROTATE);

    navswitch_init ();
    ir_serial_init ();

    show_count (count);

    pacer_init (LOOP_RATE);

    /* Paced loop.  */
    while (1)
    {
        int ret;
        uint8_t data;

        /* Wait for next tick.  */
        pacer_wait ();

        tinygl_update ();

        navswitch_update ();

        if (navswitch_push_event_p (NAVSWITCH_WEST))
            ir_serial_transmit (1);

        if (navswitch_push_event_p (NAVSWITCH_EAST))
            ir_serial_transmit (2);

        ret = ir_serial_receive (&data);
        if (ret == IR_SERIAL_OK)
        {
            if (data == 1)
                count--;
            else if (data == 2)
                count++;
            else
                count = 0;
            show_count (count);
        }
        else if (ret < 0)
        {
            show_err (-ret);
        }
    }

    return 0;
}
/*
 * Callback from TURN session to send outgoing packet.
 */
static pj_status_t turn_on_send_pkt(pj_turn_session *sess,
				    const pj_uint8_t *pkt,
				    unsigned pkt_len,
				    const pj_sockaddr_t *dst_addr,
				    unsigned dst_addr_len)
{
    pj_turn_sock *turn_sock = (pj_turn_sock*) 
			      pj_turn_session_get_user_data(sess);
    pj_ssize_t len = pkt_len;
    pj_status_t status;
    pj_bool_t is_stun = PJ_FALSE;
    pj_bool_t is_tnl_data = PJ_FALSE;

    if (turn_sock == NULL) {
	/* We've been destroyed */
	// https://trac.pjsip.org/repos/ticket/1316
	//pj_assert(!"We should shutdown gracefully");
	return PJ_EINVALIDOP;
    }

    PJ_UNUSED_ARG(dst_addr);
    PJ_UNUSED_ARG(dst_addr_len);

    /* Check that this is STUN message */
    status = pj_stun_msg_check((const pj_uint8_t*)pkt, pkt_len, 
    			       PJ_STUN_IS_DATAGRAM | PJ_STUN_CHECK_PACKET);
    if (status == PJ_SUCCESS) 
        is_stun = PJ_TRUE;
	else
		is_tnl_data = (((pj_uint8_t*)pkt)[pkt_len] == 1);

    if(is_stun || !is_tnl_data) {
        pj_ioqueue_op_key_t *op_key = (pj_ioqueue_op_key_t*)malloc(sizeof(pj_ioqueue_op_key_t));
        pj_ioqueue_op_key_init(op_key, sizeof(pj_ioqueue_op_key_t));
	    status = pj_activesock_send(turn_sock->active_sock, op_key,
			        pkt, &len, PJ_IOQUEUE_URGENT_DATA);
     } else {
	    status = pj_activesock_send(turn_sock->active_sock, &turn_sock->send_key,
		        	pkt, &len, 0);
    }

    if (status != PJ_SUCCESS && status != PJ_EPENDING) {
	show_err(turn_sock, "socket send()", status);
    }

    return status;
}
 void show_transactions()
   {
	unsigned int l,ac;
	char acc[5];
	inner_function_screen("TRANSACTIONS");
	settextstyle(3,0,2);
	setcolor(8);
	outtextxy(120,130,"Enter Account no.");
	gotoxy(42,10);
	cin>>ac;

	itoa(ac,acc,10);
	if((fp=fopen(acc,"rb+"))==NULL)
	 {
	  show_err("Sorry! Account doesn't exist");
	  settextstyle(1,0,4);
	  setcolor(WHITE);
	  outtextxy(75,350,"Press any key to try again");
	  return;
	 }
	fclose(fp);
	tran_enquiry(ac);
   }
Exemple #11
0
/** Program entry-point */
int main(int argc, char ** argv) {
    int rc;
    DWORD err;
    S_NTFSSECT_VOLINFO vol_info;
    HANDLE file;
    LARGE_INTEGER vcn, lba;
    S_NTFSSECT_EXTENT extent;
    LONGLONG len;
    BOOL ok;

    if (argc != 2) {
        rc = EXIT_FAILURE;
        show_usage();
        goto err_args;
      }

    /* Get volume info */
    err = NtfsSectGetVolumeInfoFromFileName(argv[1], &vol_info);
    if (err != ERROR_SUCCESS) {
        show_err(err);
        goto err_vol_info;
      }
    printf(
        "Volume has %d bytes per sector, %d sectors per cluster\n",
        vol_info.BytesPerSector,
        vol_info.SectorsPerCluster
      );

    /* Open the file for reading */
    file = CreateFile(
        argv[1],
        GENERIC_READ,
        FILE_SHARE_READ,
        NULL,
        OPEN_EXISTING,
        0,
        NULL
      );
    if (file == INVALID_HANDLE_VALUE) {
        rc = EXIT_FAILURE;
        show_last_err();
        goto err_file;
      }

    /* For each extent */
    for (
        vcn.QuadPart = 0;
        NtfsSectGetFileVcnExtent(file, &vcn, &extent) == ERROR_SUCCESS;
        vcn = extent.NextVcn
      ) {
        len = extent.NextVcn.QuadPart - extent.FirstVcn.QuadPart;
        printf("Extent @ VCN #%lld,", extent.FirstVcn.QuadPart);
        printf(" %lld clusters long:\n", len);
        printf("  VCN #%lld -", extent.FirstVcn.QuadPart);
        printf(" #%lld\n", extent.FirstVcn.QuadPart + len - 1);
        printf("  LCN #%lld -", extent.FirstLcn.QuadPart);
        printf(" #%lld\n", extent.FirstLcn.QuadPart + len - 1);
        err = NtfsSectLcnToLba(
            &vol_info,
            &extent.FirstLcn,
            &lba
          );
        if (err == ERROR_SUCCESS) {
            printf("  LBA #%lld -", lba.QuadPart);
            printf(
                " #%lld\n",
                lba.QuadPart + len * vol_info.SectorsPerCluster
              );
          }
        continue;
      }

    rc = EXIT_SUCCESS;

    CloseHandle(file);
    err_file:

    CloseHandle(vol_info.Handle);
    err_vol_info:

    err_args:

    return rc;
  }
Exemple #12
0
static void show_last_err(void) {
    show_err(GetLastError());
    return;
  }