MCPcopy Create free account
hub / github.com/cgsecurity/testdisk / screen_buffer_add

Function screen_buffer_add

src/intrf.c:69–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67int intr_nbr_line=0;
68
69int screen_buffer_add(const char *_format, ...)
70{
71#ifndef DISABLED_FOR_FRAMAC
72 char tmp[BUFFER_LINE_LENGTH+1];
73 const char *start=tmp;
74 va_list ap;
75 memset(tmp, '\0', sizeof(tmp));
76 va_start(ap, _format);
77 vsnprintf(tmp, sizeof(tmp), _format, ap);
78 va_end(ap);
79 while(start!=NULL && intr_nbr_line<MAX_LINES)
80 {
81 const unsigned int dst_current_len=strlen(intr_buffer_screen[intr_nbr_line]);
82 const char *end=strchr(start,'\n');
83 unsigned int nbr=(end==NULL ? strlen(start) : (unsigned int)(end-start));
84 if(nbr > BUFFER_LINE_LENGTH-dst_current_len)
85 nbr=BUFFER_LINE_LENGTH-dst_current_len;
86
87 memcpy(&intr_buffer_screen[intr_nbr_line][dst_current_len], start, nbr);
88 intr_buffer_screen[intr_nbr_line][dst_current_len+nbr]='\0';
89 if(end!=NULL)
90 {
91 if(++intr_nbr_line<MAX_LINES)
92 intr_buffer_screen[intr_nbr_line][0]='\0';
93 end++;
94 }
95 start=end;
96 }
97 /* log_trace("aff_intr_buffer_screen %d =>%s<=\n",intr_nbr_line,tmp); */
98 if(intr_nbr_line==MAX_LINES)
99 {
100 log_warning("Buffer can't store more than %d lines.\n", MAX_LINES);
101 intr_nbr_line++;
102 }
103#endif
104 return 0;
105}
106
107/*@
108 @ ensures intr_nbr_line == 0;

Callers 15

check_HPFSFunction · 0.85
aff_part_bufferFunction · 0.85
read_part_gpt_auxFunction · 0.85
read_part_gptFunction · 0.85
check_part_gptFunction · 0.85
ntfs_boot_sector_scanFunction · 0.85
exFAT_boot_sector_rescanFunction · 0.85
reiser_dirFunction · 0.85
test_NTFSFunction · 0.85
read_part_macFunction · 0.85
check_part_macFunction · 0.85

Calls 1

vsnprintfFunction · 0.85

Tested by 4

test_NTFSFunction · 0.68
test_FATFunction · 0.68
test_MBR_dataFunction · 0.68
test_MBR_overFunction · 0.68