forked from robertapengelly/ar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
display.c
57 lines (37 loc) · 1.19 KB
/
display.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/******************************************************************************
* @file display.c
*****************************************************************************/
#include <stdio.h>
#include <string.h>
#include "ar.h"
#include "report.h"
void display (void) {
char temp[17] = { 0 };
int i;
for (;;) {
struct ar_header hdr;
long bytes;
if (fread (&hdr, sizeof (hdr), 1, arfp) != 1) {
if (feof (arfp)) {
break;
}
report_at (program_name, 0, REPORT_ERROR, "failed whilst reading '%s'", state->outfile);
return;
}
bytes = conv_dec (hdr.size, 10);
if (bytes % 2) {
bytes++;
}
fseek (arfp, bytes, SEEK_CUR);
if (memcmp (hdr.name, "/", 1) == 0) {
continue;
}
memcpy (temp, hdr.name, 16);
for (i = 16; i >= 0; --i) {
if (temp[i] == 0x20) {
temp[i] = '\0';
}
}
printf ("%s\n", temp);
}
}