From: Zdenek S. <st...@us...> - 2013-10-26 19:11:35
|
Update of /cvsroot/ipmitool/ipmitool/lib In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv31493/lib Modified Files: ipmi_fwum.c Log Message: ID: 46 - ipmi_fwum needs some re-work KfwumShowProgress() - code formatting, fix Commit fixes code formatting in KfwumShowProgress() and replaces ``unsigned char'', which didn't make any sense, with a ``signed char'', resp. ``char''. Index: ipmi_fwum.c =================================================================== RCS file: /cvsroot/ipmitool/ipmitool/lib/ipmi_fwum.c,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** ipmi_fwum.c 26 Oct 2013 19:10:16 -0000 1.33 --- ipmi_fwum.c 26 Oct 2013 19:11:33 -0000 1.34 *************** *** 152,157 **** static tKFWUM_Status KfwumSetupBuffersFromFile(unsigned char * pFileName, unsigned long fileSize); ! static void KfwumShowProgress( const unsigned char * task, ! unsigned long current, unsigned long total); static unsigned short KfwumCalculateChecksumPadding(unsigned char * pBuffer, unsigned long totalSize); --- 152,157 ---- static tKFWUM_Status KfwumSetupBuffersFromFile(unsigned char * pFileName, unsigned long fileSize); ! void KfwumShowProgress(const char *task, unsigned long current, ! unsigned long total); static unsigned short KfwumCalculateChecksumPadding(unsigned char * pBuffer, unsigned long totalSize); *************** *** 445,449 **** rewind(pFileHandle); for (qty=0; qty < count; qty++) { ! KfwumShowProgress((const unsigned char *)"Reading Firmware from File", qty, count); if (fread(&firmBuf[qty * MAX_BUFFER_SIZE], 1, --- 445,449 ---- rewind(pFileHandle); for (qty=0; qty < count; qty++) { ! KfwumShowProgress("Reading Firmware from File", qty, count); if (fread(&firmBuf[qty * MAX_BUFFER_SIZE], 1, *************** *** 460,465 **** } if (status == KFWUM_STATUS_OK) { ! KfwumShowProgress((const unsigned char *)"Reading Firmware from File", ! 100, 100); } fclose(pFileHandle); --- 460,464 ---- } if (status == KFWUM_STATUS_OK) { ! KfwumShowProgress("Reading Firmware from File", 100, 100); } fclose(pFileHandle); *************** *** 475,518 **** * total : limit */ ! #define PROG_LENGTH 42 ! void KfwumShowProgress( const unsigned char * task, unsigned long current , ! unsigned long total) { ! static unsigned long staticProgress=0xffffffff; ! ! unsigned char spaces[PROG_LENGTH + 1]; ! unsigned short hash; ! float percent = ((float)current/total); ! unsigned long progress = 100*(percent); ! ! if(staticProgress == progress) ! { ! /* We displayed the same last time.. so don't do it */ ! } ! else ! { ! staticProgress = progress; ! ! ! printf("%-25s : ",task); /* total 20 bytes */ ! ! hash = ( percent * PROG_LENGTH ); ! memset(spaces,'#', hash); ! spaces[ hash ] = '\0'; ! printf("%s", spaces ); ! ! memset(spaces,' ',( PROG_LENGTH - hash ) ); ! spaces[ ( PROG_LENGTH - hash ) ] = '\0'; ! printf("%s", spaces ); ! printf(" %3ld %%\r",progress); /* total 7 bytes */ ! if( progress == 100 ) ! { ! printf("\n"); ! } ! fflush(stdout); ! } } --- 474,507 ---- * total : limit */ ! # define PROG_LENGTH 42 ! void ! KfwumShowProgress(const char *task, unsigned long current, unsigned long total) { ! static unsigned long staticProgress=0xffffffff; ! unsigned char spaces[PROG_LENGTH + 1]; ! unsigned short hash; ! float percent = ((float)current/total); ! unsigned long progress = 100*(percent); + if (staticProgress == progress) { + /* We displayed the same last time.. so don't do it */ + return; + } + staticProgress = progress; + printf("%-25s : ", task); /* total 20 bytes */ + hash = (percent * PROG_LENGTH); + memset(spaces,'#', hash); + spaces[hash] = '\0'; ! printf("%s", spaces); ! memset(spaces, ' ', (PROG_LENGTH - hash)); ! spaces[(PROG_LENGTH - hash)] = '\0'; ! printf("%s", spaces ); ! printf(" %3ld %%\r", progress); /* total 7 bytes */ ! if (progress == 100) { ! printf("\n"); ! } ! fflush(stdout); } *************** *** 1131,1136 **** if (status == KFWUM_STATUS_OK) { if ((address % 1024) == 0) { ! KfwumShowProgress((const unsigned char *)\ ! "Writting Firmware in Flash", address, totalSize); } --- 1120,1124 ---- if (status == KFWUM_STATUS_OK) { if ((address % 1024) == 0) { ! KfwumShowProgress("Writting Firmware in Flash", address, totalSize); } *************** *** 1139,1144 **** } while ((status == KFWUM_STATUS_OK) && (address < totalSize)); if (status == KFWUM_STATUS_OK) { ! KfwumShowProgress((const unsigned char *)\ ! "Writting Firmware in Flash", 100, 100); } --- 1127,1131 ---- } while ((status == KFWUM_STATUS_OK) && (address < totalSize)); if (status == KFWUM_STATUS_OK) { ! KfwumShowProgress("Writting Firmware in Flash", 100, 100); } |