Skip to content

Commit

Permalink
First pass at VS support
Browse files Browse the repository at this point in the history
  • Loading branch information
nyetwurk committed Sep 24, 2014
1 parent 1736ccd commit 309048c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# FOR MSVSS nmake only

TARGET = me7sum.exe
SOURCES = crc32.c inifile_prop.c me7sum.c utils.c inifile/inifile.c os/pgetopt.c
SOURCES = crc32.c inifile_prop.c me7sum.c utils.c str.c inifile/inifile.c os/pgetopt.c
CFLAGS = -D__GIT_VERSION=\"$(GIT_VERSION)\"

all: $(TARGET)
Expand Down
21 changes: 15 additions & 6 deletions me7sum.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ int main(int argc, char **argv)
int i, c;
struct ImageHandle ih;
struct section *osconfig=NULL;
struct strbuf buf={};
struct strbuf buf;

memset(&buf, 0, sizeof(buf));

// information about the tool
printf("ME7Tool (%s) [ Management tool for Bosch ME7.x firmwares]\n",
Expand Down Expand Up @@ -372,7 +374,9 @@ int main(int argc, char **argv)
for(iTemp=0; iTemp<64; iTemp++)
{
int result=0;
struct strbuf buf = {};
struct strbuf buf;

memset(&buf, 0, sizeof(buf));
sbprintf(&buf, "%2d) ",iTemp+1);
result = DoChecksumBlk(&ih, Config.multipoint_block_start[i]+(Config.multipoint_block_len*iTemp), &buf);
if (buf.pbuf) {
Expand Down Expand Up @@ -405,7 +409,9 @@ int main(int argc, char **argv)

if(output && ErrorsCorrected > 0)
{
struct strbuf buf={};
struct strbuf buf;

memset(&buf, 0, sizeof(buf));
printf("\nAttempting to output corrected firmware file '%s'\n",output);
// write crc corrected file out
save_file(output,ih.d.p,ih.len, &buf);
Expand Down Expand Up @@ -1110,10 +1116,13 @@ static int DoMainChecksum(struct ImageHandle *ih, uint32_t nOffset, uint32_t nCs

if (r[0].end + 1 != r[1].start)
{
struct Range sr = {.start = r[0].end+1, .end = r[1].start-1};
struct Range sr;
uint32_t ss, sc;
sr.start = r[0].end+1;
sr.end = r[1].start-1;
//struct Range sr = {.start = 0x10000, .end = 0x1FFFF};
uint32_t ss = CalcChecksumBlk16(ih, &sr);
uint32_t sc = crc32(0, ih->d.u8+sr.start, sr.end-sr.start+1);
ss = CalcChecksumBlk16(ih, &sr);
sc = crc32(0, ih->d.u8+sr.start, sr.end-sr.start+1);
printf(" 0x%06X-0x%06X SKIPPED CalcChk: 0x%08X CalcCRC: 0x%08X\n",
sr.start, sr.end, ss, sc);
}
Expand Down
8 changes: 7 additions & 1 deletion str.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
# define STR(x) X__STR(x)
#endif

#ifdef __cplusplus
extern "C" {
#endif

/** expanding string buffer for \ref sbprintf */
struct strbuf {
char *pbuf;
Expand Down Expand Up @@ -63,8 +67,10 @@ static inline int snputs(char *dest, const char *src, size_t n)
return strnlen(dest, n);
}


void sbputs(struct strbuf *sb, const char *s);

#ifdef __cplusplus
}
#endif

#endif /* STR_H */

0 comments on commit 309048c

Please sign in to comment.