📄 receiver_output_th.c
字号:
/* $Author: peltotal $ $Date: 2006/03/14 12:29:15 $ $Revision: 1.13 $ *//* * MAD-FLUTELIB: Implementation of FLUTE protocol. * Copyright (c) 2003-2006 TUT - Tampere University of Technology * main authors/contacts: jani.peltotalo@tut.fi and sami.peltotalo@tut.fi * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#include "flute_inc.h"/**** Private Functions ****/void print_receiver_info(fdt_th_args_t *args);/* * This function. * * Params: void *a:. * * Return: void * */void* receiver_output_thread(void *a) { fdt_th_args_t *args; args = (fdt_th_args_t *)a; while(args->fdt == NULL) { if(get_session_state(args->s_id) == SExiting) {#ifdef WIN32 _endthread();#else pthread_exit(0);#endif } else if(get_session_state(args->s_id) == STxStopped) {#ifdef WIN32 _endthread();#else pthread_exit(0);#endif }#ifdef WIN32 Sleep(1000);#else sleep(1);#endif continue; } while(get_session_state(args->s_id) == SActive) { print_receiver_info(a); #ifdef WIN32 Sleep(1000);#else sleep(1);#endif }#ifdef WIN32 _endthread();#else pthread_exit(0);#endif return NULL;}/* * This function. * * Params: fdt_th_args_t *args:. * * Return: void * */void print_receiver_info(fdt_th_args_t *args) { trans_obj_t *trans_obj; alc_session_t *s; file_t *next_file; file_t *file; char tmp[17]; s = get_alc_session(args->s_id);#ifdef WIN32 system("cls");#else printf("\e[H\e[J");#endif printf("%-7s%-7s%-16s%-13s%-36s\n\n", "TOI", "Rx[%]", "Blocks", "Size[B]", "File"); next_file = args->fdt->file_list; if(next_file == NULL) { printf("next_file id NULL\n"); } while(next_file != NULL) { file = next_file;#ifdef WIN32 printf("%-7I64u", file->toi);#else printf("%-7llu", file->toi);#endif trans_obj = object_exist(file->toi, s, 1); if(trans_obj != NULL) {#ifdef WIN32 printf("%-7.2f", (double)((double)100 * ((double)(LONGLONG)trans_obj->rx_bytes/(double)(LONGLONG)trans_obj->len)));#else printf("%-7.2f", (double)((double)100 * ((double)(long long)trans_obj->rx_bytes/(double)(long long)trans_obj->len))); #endif memset(tmp, 17, 0); sprintf(tmp, "%u/%u", trans_obj->nb_of_ready_blocks, trans_obj->bs->N); printf("%-16s", tmp); } else if(file->is_downloaded == 2) { printf("%-7s%-16s", "100", ""); } else { printf("%-7s%-16s", "", ""); } #ifdef WIN32 printf("%-13I64u", file->file_len);#else printf("%-13llu", file->file_len);#endif printf("%-36s\n", file->location); fflush(stdout); next_file = file->next; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -