コード例 #1
0
ファイル: makecfg.c プロジェクト: joshtriplett/tin-sample
static void
parse_tbl(
	char *buffer)
{
	char *s = buffer;
	char *t = s + strlen(s);

	/* strip leading/trailing blanks */
	while ((t-- != s) && isspace ((int)*t))
		*t = '\0';
	while (isspace ((int)*s))
		s++;
	buffer = s;

	line_no++;
	if (*buffer != ';' && *buffer != '\0') {	/* ignore comments */
		if (*buffer == '#') {
			store_data(buffer, "");
		} else {
			/*
			 * otherwise the data consists of 2 blank
			 * separated columns (name, type).
			 */
			while (*s && !isspace ((int)*s))
				s++;
			while (isspace ((int)*s))
				*s++ = '\0';
			store_data(buffer, s);
		}
	}
}
コード例 #2
0
// -- Internal used functions
// Check filtering by source and destination IP
void check_src_dst(char *protocol, char *src_ip, char *dst_ip, char *src_port, char *dst_port, char *status) 
    {
    if ((check_if_source(src_ip)) && (strcmp(DST_IP,"")==0)) {
	store_data(protocol,src_ip,dst_ip,src_port,dst_port,status);
	}
    else if ((check_if_destination(dst_ip)) && (strcmp(SRC_IP,"")==0)) {
	store_data(protocol,src_ip,dst_ip,src_port,dst_port,status);
	}
    else if ((check_if_destination(dst_ip)) && (check_if_source(src_ip))) {
	store_data(protocol,src_ip,dst_ip,src_port,dst_port,status);
	}
    }
コード例 #3
0
ファイル: rudp.c プロジェクト: GanapathyRaman/RUDP
int rudp_sendto(rudp_socket_t rsocket_t, void* data, int len, struct sockaddr_in6* to) {
	struct rudp_socket *rsocket;
	struct peer * cur_peer;
	struct vsftp * vs_data;

	rsocket = (struct rudp_socket *) rsocket_t;
	vs_data = (struct vsftp *) data;
	vs_data->vs_type = ntohl(vs_data->vs_type);

	// find the corresponding peer
	cur_peer = find_peer(rsocket, to);

	// create a new peer if needed
	if (cur_peer == NULL) {
		// ignore if it's not VS_TYPE_BEGIN
		if (vs_data->vs_type != VS_TYPE_BEGIN) {
			printf("rudp_sendto: cannot find peer\n");
			return -1;
		}

		cur_peer = add_peer(rsocket, to);	
	}

	// if the peer is the first peer, store the data to the data list of the socket
	if (cur_peer == rsocket->peer_head) {
		store_data(rsocket, vs_data, len);
	}

	vs_data->vs_type = htonl(vs_data->vs_type);
	
	return 0;
}
コード例 #4
0
ファイル: toxic.c プロジェクト: gracchus163/toxic
static void load_data(Tox *m, char *path)
{
    if (arg_opts.ignore_data_file)
        return;

    FILE *fd;

    if ((fd = fopen(path, "rb")) != NULL) {
        fseek(fd, 0, SEEK_END);
        int len = ftell(fd);
        fseek(fd, 0, SEEK_SET);

        char *buf = malloc(len);

        if (buf == NULL) {
            fclose(fd);
            exit_toxic_err("failed in load_data", FATALERR_MEMORY);
        }

        if (fread(buf, len, 1, fd) != 1) {
            free(buf);
            fclose(fd);
            exit_toxic_err("failed in load_data", FATALERR_FREAD);
        }

        tox_load(m, (uint8_t *) buf, len);
        load_friendlist(m);

        free(buf);
        fclose(fd);
    } else {
        if (store_data(m, path) != 0)
            exit_toxic_err("failed in load_data", FATALERR_STORE_DATA);
    }
}
コード例 #5
0
ファイル: productivity.c プロジェクト: priyancka/caps
/*-------------------------------------------------------------------------*
 *  Get All DAta
 *-------------------------------------------------------------------------*/
store_all()
{
  register long i, found;

  tmp_name(temp_file);                    /* get a temporary file name       */
  fp = fopen(temp_file, "w+");

  if (fp == 0)
  {
    krash("store_data", "open tmp", 1);
  }
  found = 0;

  for (i = 0; i < pr->pr_picklines; i++)
  {
    if (!pl[i].pl_pl) continue;
    if (pickline && pickline != i+1) continue;
    
    if (found)                             /* after first pickline           */
    {
      fprintf(fp, "%79c\n", 0x20);
      if (!summary)
      {
        fprintf(fp, "%79c\n", 0x20);
        fprintf(fp, "%79c\n", 0x20);
        fprintf(fp, "%79c\n", 0x20);
      }
    }
    store_data(i);                         /* store one pickline             */
    found = 1;
  }
  if (!found) eh_post(ERR_PROD, 0);

  return found;
}
コード例 #6
0
ファイル: global_commands.c プロジェクト: gracchus163/toxic
void cmd_nick(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
    char *errmsg;

    /* check arguments */
    if (argc < 1) {
        errmsg = "Invalid name.";
        line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
        return;
    }

    char *nick = argv[1];
    int len = strlen(nick);

    if (nick[0] == '\"') {
        ++nick;
        len -= 2;
        nick[len] = '\0';
    }

    if (!valid_nick(nick)) {
        errmsg = "Invalid name.";
        line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
        return;
    }

    len = MIN(len, TOXIC_MAX_NAME_LENGTH - 1);
    nick[len] = '\0';

    tox_set_name(m, (uint8_t *) nick, (uint16_t) len);
    prompt_update_nick(prompt, nick);

    store_data(m, DATA_FILE);
}
コード例 #7
0
ファイル: temp08.c プロジェクト: schenkl/Coldipozzo
read_parse_data()
{
	char line[LINE_SZ],buf[2],msg[40];
	int rtn,i,ptr,nl,ch;
	nl = 1;
	//system("stty raw");
	while (1)	//basically wait for data to arrive but return if any keys are hit..used to debug
	{
		for (i=0;i<LINE_SZ;i++) line[i]=0;
		ptr = 0;
		nl = 1;
		while (nl)
		{
			//if (!Daemon) printf("Calling recv.....\n");
			recv(Fd,buf,1,0);
			//if (!Daemon) printf("got a %c\n",buf[0]);
			if (buf[0] == '\n' || buf[0] == '>')
			{
				//if (!Daemon) printf("Found a cr\n");
				nl = 0;
			}
			line[ptr] = buf[0];
			ptr++;
		}
		rtn = store_data(line);
	}
}
コード例 #8
0
void exit_toxic_success(Tox *m)
{
    store_data(m, DATA_FILE);
    memset(&user_password, 0, sizeof(struct user_password));
    kill_all_file_transfers(m);
    kill_all_windows(m);
    terminate_notify();

#ifdef AUDIO
#ifdef VIDEO
    terminate_video();
#endif /* VIDEO */
    terminate_audio();
#endif /* AUDIO */

    free_global_data();
    tox_kill(m);
    endwin();
    curl_global_cleanup();

#ifdef X11
    /* We have to terminate xtra last coz reasons
     * Please don't call this anywhere else coz trust me
     */
    terminate_xtra();
#endif /* X11 */

    exit(EXIT_SUCCESS);
}
コード例 #9
0
ファイル: windows.c プロジェクト: rayslava/toxic
void on_nickchange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata)
{
    if (friendnumber < 0 || friendnumber > MAX_FRIENDS_NUM)
        return;

    if (length >= TOXIC_MAX_NAME_LENGTH) {    /* length includes null byte */
        string[TOXIC_MAX_NAME_LENGTH] = L'\0';
        length = TOXIC_MAX_NAME_LENGTH + 1;
        tox_setfriendname(m, friendnumber, string, length);
    }

    /* Append friendnumber to duplicate nicks to guarantee uniqueness */
    int n = get_friendnum(string);

    if (n != friendnumber && n != -1) {
        char n_buf[strlen(string)+4];    /* must have room for friendnum chars relative to MAX_FRIENDS_NUM */
        snprintf(n_buf, sizeof(n_buf), "%s%d", string, friendnumber);
        strcpy(string, n_buf);
        length = strlen(n_buf) + 1;
        tox_setfriendname(m, friendnumber, string, length);
    }

    int i;

    for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
        if (windows[i].onNickChange != NULL)
            windows[i].onNickChange(&windows[i], friendnumber, string, length);
    }

    if (store_data(m, DATA_FILE))
        wprintw(prompt->window, "\nCould not store Tox data\n");
}
コード例 #10
0
ファイル: tftp.c プロジェクト: hemiao3000/code
//解tftp包 pkt:指向tftp包 的首地址
void tftp_unpack(char *pkt, unsigned int len, unsigned short port)
{
	unsigned short no;

	switch(htons(((unsigned short *)pkt)[0]))
	{
		case TFTP_DATA:
			no = htons(((unsigned short *)pkt)[1]);//第几个包 编号

			if((no < 1) || (no > MAX_BLOCK) || (len < 4) || len > 516)//当编号为0 或者大于
			{
				printf("Error: block#: %d, len: %d\n", no, len);
				return;
			}
			
			store_data(pkt + 4, len - 4, no);//保存数据

			send_ack(port, no);//回ack
			break;

		case TFTP_OACK:
			send_ack(port, 0);//如果是ack 就回pc一个请求包
			break;

		case TFTP_ERROR://如果是错误 则打印
			printf("Error: %s\n", pkt + 4);
			break;

		default:
			printf("Unkown Opcode.\n");
	}
}
コード例 #11
0
ファイル: global_commands.c プロジェクト: jpoler/toxic
void cmd_nick(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
    if (argc < 1) {
        line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Input required.");
        return;
    }

    char nick[MAX_STR_SIZE];
    int len = 0;

    if (argv[1][0] == '\"') {    /* remove opening and closing quotes */
        snprintf(nick, sizeof(nick), "%s", &argv[1][1]);
        len = strlen(nick) - 1;
        nick[len] = '\0';
    } else {
        snprintf(nick, sizeof(nick), "%s", argv[1]);
        len = strlen(nick);
    }

    if (!valid_nick(nick)) {
        line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Invalid name.");
        return;
    }

    len = MIN(len, TOXIC_MAX_NAME_LENGTH - 1);
    nick[len] = '\0';

    tox_set_name(m, (uint8_t *) nick, (uint16_t) len);
    prompt_update_nick(prompt, nick);

    store_data(m, DATA_FILE);
}
コード例 #12
0
ファイル: tracefile_idlestat.c プロジェクト: bigzz/idlestat
int load_text_data_line(char *buffer, struct cpuidle_datas *datas, char *format, double *begin, double *end, size_t *start)
{
	unsigned int state, freq, cpu;
	double time;

	if (strstr(buffer, "cpu_idle")) {
		if (sscanf(buffer, format, &time, &state, &cpu)
		    != 3) {
			fprintf(stderr, "warning: Unrecognized cpuidle "
				"record. The result of analysis might "
				"be wrong.\n");
			return -1;
		}

		if (*start) {
			*begin = time;
			*start = 0;
		}
		*end = time;

		return store_data(time, state, cpu, datas);
	}

	if (strstr(buffer, "cpu_frequency")) {
		if (sscanf(buffer, format, &time, &freq, &cpu) != 3) {
			fprintf(stderr, "warning: Unrecognized cpufreq "
				"record. The result of analysis might "
				"be wrong.\n");
			return -1;
		}
		return cpu_change_pstate(datas, cpu, freq, time);
	}

	return get_wakeup_irq(datas, buffer);
}
コード例 #13
0
ファイル: friendlist.c プロジェクト: jpoler/toxic
static void delete_friend(Tox *m, int32_t f_num)
{
    if (Friends.list[f_num].chatwin >= 0) {
        ToxWindow *toxwin = get_window_ptr(Friends.list[f_num].chatwin);

        if (toxwin != NULL) {
            kill_chat_window(toxwin, m);
            set_active_window(1);   /* keep friendlist focused */
        }
    }

    if (Friends.list[f_num].group_invite.key != NULL)
        free(Friends.list[f_num].group_invite.key);

    tox_del_friend(m, f_num);
    memset(&Friends.list[f_num], 0, sizeof(ToxicFriend));

    int i;

    for (i = Friends.max_idx; i > 0; --i) {
        if (Friends.list[i - 1].active)
            break;
    }

    Friends.max_idx = i;
    Friends.num_friends = tox_count_friendlist(m);
    realloc_friends(i);

    /* make sure num_selected stays within Friends.num_friends range */
    if (Friends.num_friends && Friends.num_selected == Friends.num_friends)
        --Friends.num_selected;

    store_data(m, DATA_FILE);
}
コード例 #14
0
ファイル: windows.c プロジェクト: rayslava/toxic
void on_friendadded(Tox *m, int friendnumber)
{
    friendlist_onFriendAdded(m, friendnumber);

    if (store_data(m, DATA_FILE))
        wprintw(prompt->window, "\nCould not store Tox data\n");
}
コード例 #15
0
ファイル: friendlist.c プロジェクト: prodigeni/toxic
static void delete_friend(Tox *m, int32_t f_num)
{
    int i;

    if (friends[f_num].chatwin >= 0) {
        ToxWindow *toxwin = get_window_ptr(friends[f_num].chatwin);

        if (toxwin != NULL) {
            kill_chat_window(toxwin);
            set_active_window(1);   /* keep friendlist focused */
        }
    }

    tox_del_friend(m, f_num);
    memset(&friends[f_num], 0, sizeof(ToxicFriend));

    for (i = max_friends_index; i > 0; --i) {
        if (friends[i - 1].active)
            break;
    }

    max_friends_index = i;
    num_friends = tox_count_friendlist(m);

    /* make sure num_selected stays within num_friends range */
    if (num_friends && num_selected == num_friends)
        --num_selected;

    store_data(m, DATA_FILE);
}
コード例 #16
0
ファイル: server.c プロジェクト: randoms/burst-link
void intHandler(int dummy) {
    store_data(my_tox);
#ifdef _WIN32
	WSACleanup();
#endif
    printf("EXITING...\n");
    exit(EXIT_SUCCESS);
}
コード例 #17
0
ファイル: files.c プロジェクト: astrotycoon/grace
static int store_cb(Quark *q, void *udata)
{
    ascii_data *adata = (ascii_data *) udata;

    /* label the SSD */
    quark_idstr_set(q, adata->label);

    return store_data(q, adata->load_type, adata->settype);
}
コード例 #18
0
ファイル: main.c プロジェクト: FullName/toxic
void exit_toxic(Tox *m)
{
    store_data(m, DATA_FILE);
    free(DATA_FILE);
    free(SRVLIST_FILE);
    free(prompt->stb);
    tox_kill(m);
    endwin();
    exit(EXIT_SUCCESS);
}
コード例 #19
0
ファイル: prompt.c プロジェクト: notadecent/toxic
void cmd_nick(ToxWindow *self, Messenger *m, char **args)
{
    char *nick = args[1];
    setname(m, (uint8_t *) nick, strlen(nick) + 1);
    wprintw(self->window, "Nickname set to: %s\n", nick);

    if (store_data(m, DATA_FILE)) {
        wprintw(self->window, "\nCould not store Messenger data\n");
    }
}
コード例 #20
0
ファイル: friendlist.c プロジェクト: jpoler/toxic
static void friendlist_onConnectionChange(ToxWindow *self, Tox *m, int32_t num, uint8_t status)
{
    if (num >= Friends.max_idx)
        return;

    Friends.list[num].online = status;
    update_friend_last_online(num, get_unix_time());
    store_data(m, DATA_FILE);
    sort_friendlist_index();
}
コード例 #21
0
ファイル: windows.c プロジェクト: dbruenig/toxic
void on_nickchange(Tox *m, int32_t friendnumber, const uint8_t *string, uint16_t length, void *userdata)
{
    int i;

    for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
        if (windows[i].onNickChange != NULL)
            windows[i].onNickChange(&windows[i], m, friendnumber, (const char *) string, length);
    }

    store_data(m, DATA_FILE);
}
コード例 #22
0
ファイル: windows.c プロジェクト: dbruenig/toxic
void on_friendadded(Tox *m, int32_t friendnumber, bool sort)
{
    int i;

    for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
        if (windows[i].onFriendAdded != NULL)
            windows[i].onFriendAdded(&windows[i], m, friendnumber, sort);
    }

    store_data(m, DATA_FILE);
}
コード例 #23
0
ファイル: windows.c プロジェクト: Jman012/toxic
void on_friendadded(Tox *m, int friendnumber, bool sort)
{
    int i;

    for (i = 0; i < num_active_windows; ++i) {
        if (windows[i].onFriendAdded != NULL)
            windows[i].onFriendAdded(&windows[i], m, friendnumber, sort);
    }

    if (store_data(m, DATA_FILE))
        wprintw(prompt->window, "\nCould not store Tox data\n");
}
コード例 #24
0
ファイル: main.c プロジェクト: FullName/toxic
static void load_data(Tox *m, char *path)
{
    if (f_loadfromfile == 0) /*If file loading/saving is disabled*/
        return;

    FILE *fd;
    size_t len;
    uint8_t *buf;

    if ((fd = fopen(path, "r")) != NULL) {
        fseek(fd, 0, SEEK_END);
        len = ftell(fd);
        fseek(fd, 0, SEEK_SET);

        buf = malloc(len);

        if (buf == NULL) {
            fclose(fd);
            endwin();
            fprintf(stderr, "malloc() failed. Aborting...\n");
            exit(EXIT_FAILURE);
        }

        if (fread(buf, len, 1, fd) != 1) {
            free(buf);
            fclose(fd);
            endwin();
            fprintf(stderr, "fread() failed. Aborting...\n");
            exit(EXIT_FAILURE);
        }

        tox_load(m, buf, len);

        uint32_t i = 0;

        uint8_t name[TOX_MAX_NAME_LENGTH];
        while (tox_getname(m, i, name) != -1) {
            on_friendadded(m, i);
            i++;
        }

        free(buf);
        fclose(fd);
    } else {
        int st;

        if ((st = store_data(m, path)) != 0) {
            endwin();
            fprintf(stderr, "Store messenger failed with return code: %d\n", st);
            exit(EXIT_FAILURE);
        }
    }
}
コード例 #25
0
ファイル: friendlist.c プロジェクト: JFreegman/toxic
static void delete_friend(Tox *m, uint32_t f_num)
{
    Tox_Err_Friend_Delete err;

    if (tox_friend_delete(m, f_num, &err) != true) {
        fprintf(stderr, "tox_friend_delete failed with error %d\n", err);
        return;
    }

    --Friends.num_friends;

    if (Friends.list[f_num].connection_status != TOX_CONNECTION_NONE) {
        --Friends.num_online;
    }

    /* close friend's chatwindow if it's currently open */
    if (Friends.list[f_num].chatwin >= 0) {
        ToxWindow *toxwin = get_window_ptr(Friends.list[f_num].chatwin);

        if (toxwin != NULL) {
            kill_chat_window(toxwin, m);
            set_active_window_index(1);   /* keep friendlist focused */
        }
    }

    if (Friends.list[f_num].group_invite.key != NULL) {
        free(Friends.list[f_num].group_invite.key);
    }

    memset(&Friends.list[f_num], 0, sizeof(ToxicFriend));

    int i;

    for (i = Friends.max_idx; i > 0; --i) {
        if (Friends.list[i - 1].active) {
            break;
        }
    }

    Friends.max_idx = i;
    realloc_friends(i);

#ifdef AUDIO
    del_friend_AV(i);
#endif

    /* make sure num_selected stays within Friends.num_friends range */
    if (Friends.num_friends && Friends.num_selected == Friends.num_friends) {
        --Friends.num_selected;
    }

    store_data(m, DATA_FILE);
}
コード例 #26
0
ファイル: main.c プロジェクト: carriercomm/ProjectTox-Core
static void load_data(Messenger *m, char *path)
{
    if (f_loadfromfile == 0) /*If file loading/saving is disabled*/
        return;

    FILE *fd;
    size_t len;
    uint8_t *buf;

    if ((fd = fopen(path, "r")) != NULL) {
        fseek(fd, 0, SEEK_END);
        len = ftell(fd);
        fseek(fd, 0, SEEK_SET);

        buf = malloc(len);

        if (buf == NULL) {
            fprintf(stderr, "malloc() failed.\n");
            fclose(fd);
            endwin();
            exit(1);
        }

        if (fread(buf, len, 1, fd) != 1) {
            fprintf(stderr, "fread() failed.\n");
            free(buf);
            fclose(fd);
            endwin();
            exit(1);
        }

        Messenger_load(m, buf, len);

        uint32_t i;

        for (i = 0; i < m->numfriends; i++) {
            on_friendadded(m, i);
        }

        free(buf);
        fclose(fd);
    } else {
        int st;

        if ((st = store_data(m, path)) != 0) {
            fprintf(stderr, "Store messenger failed with return code: %d\n", st);
            endwin();
            exit(1);
        }
    }
}
コード例 #27
0
ファイル: decoder.cpp プロジェクト: BrentCranko/IPASS-DCF77
bool decoder::process_data(){
        
        int zero_counter = 0;
        int one_counter = 0;
        int n = 0;
        
        for(int i=0;i<5760;i++){
            if(raw_data_buffer[i] == 0){
                zero_counter++;
                if(zero_counter >= 86){
                        buffer[n] = 2;
                        if(marker_begin){
                            marker_end = n;
                            hwlib::cout<<"marker 2 is gevonden \n";
                        }
                        else{
                            marker_begin = n;
                            hwlib::cout<<"marker 1 is gevonden \n";
                        }
                        n++;
                        zero_counter = 0;
                }
            }
        
            if (raw_data_buffer[i] == 1){
                one_counter++;
                
                if((raw_data_buffer[i] == 1)and(raw_data_buffer[i+1] == 0)){
                    if(one_counter < 3){
                        one_counter = 0;
                        continue;
                    }
                    if (zero_counter < 30 && one_counter >= 1){
                        one_counter = 0;
                    }
                    zero_counter = 0;
                    
                    if(one_counter <= 5) {
                        buffer[n] = 0;            
                    }
                    
                    if(one_counter >= 6){
                        buffer[n] = 1;
                    }
                    n++;
                    one_counter=0;
                }
            }
        }
        return store_data();
}
コード例 #28
0
static int
flush_ogg_packet (oggdmux_prc_t * ap_prc, const OMX_U32 a_pid,
                  const OMX_U8 * ap_ogg_data, const OMX_U32 nbytes)
{
  OMX_BUFFERHEADERTYPE * p_hdr = NULL;
  OMX_U32 nbytes_remaining = nbytes;
  OMX_U32 nbytes_copied = 0;
  OMX_U32 op_offset = 0;

  while ((p_hdr = get_header (ap_prc, a_pid)))
    {
      nbytes_copied = dump_ogg_data (ap_prc, a_pid, ap_ogg_data + op_offset,
                                     nbytes_remaining, p_hdr);
      nbytes_remaining -= nbytes_copied;
      op_offset += nbytes_copied;
#ifdef _DEBUG
      if (a_pid == ARATELIA_OGG_DEMUXER_AUDIO_PORT_BASE_INDEX)
        {
          g_total_released += p_hdr->nFilledLen;
          OMX_U32 * p_offset = get_store_offset_ptr (ap_prc, a_pid);
          TIZ_TRACE (handleOf (ap_prc),
                     "total released [%d] "
                     "total read [%d] store [%d] last read [%d] "
                     "remaining [%d] diff [%d]",
                     g_total_released, g_total_read, *p_offset, g_last_read,
                     nbytes_remaining,
                     g_total_read - (g_total_released + nbytes_remaining));
        }
#endif
      release_header (ap_prc, a_pid);
      p_hdr = 0;
      if (0 == nbytes_remaining)
        {
          break;
        }
    }

  if (nbytes_remaining > 0)
    {
      /* Need_more_buffers. Temporarily store the data until an omx buffer is
       * available */
      TIZ_TRACE (handleOf (ap_prc), "Need to store [%d] bytes - pid [%d]",
                 nbytes_remaining, a_pid);
      nbytes_remaining
        = store_data (ap_prc, a_pid, ap_ogg_data + op_offset, nbytes_remaining);
    }

  return nbytes_remaining;
}
コード例 #29
0
ファイル: windows.c プロジェクト: Jman012/toxic
void on_nickchange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata)
{
    if (friendnumber < 0 || friendnumber > MAX_FRIENDS_NUM)
        return;

    int i;

    for (i = 0; i < num_active_windows; ++i) {
        if (windows[i].onNickChange != NULL)
            windows[i].onNickChange(&windows[i], m, friendnumber, string, length);
    }

    if (store_data(m, DATA_FILE))
        wprintw(prompt->window, "\nCould not store Tox data\n");
}
コード例 #30
0
ファイル: friendlist.c プロジェクト: pineapplewank/toxic
static void delete_friend(Tox *m, ToxWindow *self, int f_num, wint_t key)
{
    tox_delfriend(m, f_num);
    memset(&(friends[f_num]), 0, sizeof(friend_t));
    
    int i;

    for (i = num_friends; i > 0; --i) {
        if (friends[i-1].active)
            break;
    }

    num_friends = i;

    store_data(m, DATA_FILE);
    select_friend(m, KEY_DOWN);
}