diff options
author | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-04-29 20:19:13 +0000 |
---|---|---|
committer | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-04-29 20:19:13 +0000 |
commit | 878abc56f013a9bd94a46bf1a009407e6c8ecceb (patch) | |
tree | d38e11f3cc2cdb3cc9357e9a1bee1f20c724f272 /xpp/utils/hexfile.c | |
parent | 47bcd1d6d884db6f92c68772aad712579f1c3b16 (diff) |
xpp rev. 3814:
* Protocol no. 2.6: syncing improvements.
* Support for 8-port Astribank BRI.
* Firmware unloading now works:
rmmod xpp_usb; /etc/hotplug/usb/xpp_fxloader reset
* Defaults of kernel parameters are now part of parameter description.
* World-readable kernel parameters.
* No need for extra patch beyond bristuff for Astribank BRI.
* Default poll intervals changed: 500 in BRI and FXO.
* Allow changing FXS polls interval at run time.
* BRI initalization fixed on SUSE (path to logger).
* When using the SUSE zaptel rpm package, set modules_var=ZAPTEL_MODULES in
/etc/sysconfig/zaptel .
* zt_registration not verbose by default.
* xpp_sync warns if FXO is sync slave.
* Fixed genzaptelconf -z (zapscan output emulation).
* PCM fixes.
* Solves "multiple ticks" bug. No need for pcm_tasklets workaround.
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@2475 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/utils/hexfile.c')
-rw-r--r-- | xpp/utils/hexfile.c | 74 |
1 files changed, 62 insertions, 12 deletions
diff --git a/xpp/utils/hexfile.c b/xpp/utils/hexfile.c index a4b12c5..5d6eaa7 100644 --- a/xpp/utils/hexfile.c +++ b/xpp/utils/hexfile.c @@ -278,6 +278,39 @@ int dump_hexfile2(struct hexdata *hexdata, FILE *outfile, uint8_t maxwidth) return 0; } +void process_comment(struct hexdata *hexdata, char buf[]) +{ + char *dollar_start; + char *dollar_end; + const char id_prefix[] = "Id: "; + char tmp[BUFSIZ]; + char *p; + int len; + + if(report_func) + report_func(LOG_INFO, "Comment: %s\n", buf + 1); + /* Search for RCS keywords */ + if((dollar_start = strchr(buf, '$')) == NULL) + return; + if((dollar_end = strchr(dollar_start + 1, '$')) == NULL) + return; + /* Crop the '$' signs */ + len = dollar_end - dollar_start; + len -= 2; + memcpy(tmp, dollar_start + 1, len); + tmp[len] = '\0'; + p = tmp; + if(strstr(tmp, id_prefix) == NULL) + return; + p += strlen(id_prefix); + if((p = strchr(p, ' ')) == NULL) + return; + p++; + strncpy(hexdata->version_info, p, BUFSIZ - 1); + if((p = strchr(hexdata->version_info, ' ')) != NULL) + *p = '\0'; +} + struct hexdata *parse_hexfile(const char *fname, unsigned int maxlines) { FILE *fp; @@ -314,18 +347,7 @@ struct hexdata *parse_hexfile(const char *fname, unsigned int maxlines) } chomp(buf); if(buf[0] == '#') { - char *dollar_start; - char *dollar_end; - - if(report_func) - report_func(LOG_INFO, "Comment: %s\n", buf + 1); - /* Search for RCS keywords */ - if((dollar_start = strchr(buf, '$')) == NULL) - continue; - if((dollar_end = strchr(dollar_start + 1, '$')) == NULL) - continue; - *(dollar_end + 1) = '\0'; - strncpy(hexdata->version_info, dollar_start, BUFSIZ - 1); + process_comment(hexdata, buf); continue; } if(buf[0] != ':') { @@ -383,3 +405,31 @@ void dump_binary(struct hexdata *hexdata, const char *outfile) fclose(fp); } +/* + * Algorithm lifted of sum(1) implementation from coreutils. + * We chose the default algorithm (BSD style). + */ +int calc_checksum(struct hexdata *hexdata) +{ + unsigned int i; + size_t len; + int ck = 0; + + for(i = 0; i < hexdata->maxlines; i++) { + struct hexline *hexline = hexdata->lines[i]; + unsigned char *p; + + if(!hexline) + break; + if(hexline->d.content.header.tt == TT_EOF) + continue; + len = hexline->d.content.header.ll; + p = hexline->d.content.tt_data.data; + for(; len; p++, len--) { + ck = (ck >> 1) + ((ck & 1) << 15); + ck += *p; + ck &= 0xffff; /* Keep it within bounds. */ + } + } + return ck; +} |