/*! * \brief Command initialization. * * \param argc Command-line argument count. * \param argv Command-line arguments. * \param pI2C Pointer to \h_i2c handle. */ static void MainInit(int argc, char *argv[], i2c_t *pI2C) { // Name of this process Argv0 = basename(argv[0]); // Get the environment //EnvGet(); // Parse input arguments argv = OptsGet(Argv0, &PkgInfo, &I2CWritePgmInfo, I2CWriteOptsInfo, true, &argc, argv); // Final option checks if( OptI2CAddr < 0x00 ) { fprintf(stderr, "%s: Address option required\n", Argv0); exit(EC_BAD_OPT); } else if( (OptI2CAddr < I2C_ADDR_DEV_LOW) || (OptI2CAddr > I2C_ADDR_DEV_HIGH) ) { fprintf(stderr, "%s: Address out of range: 0x%x\n", Argv0, OptI2CAddr); exit(EC_BAD_OPT); } // Convert command-line arguments ArgsGet(argc, argv); // Opened device specified if( OptDevFd >= 0 ) { pI2C->fd = OptDevFd; pI2C->addr = (ushort_t)(-1); } // I2C Bus device specified else { if( OptDevName == NULL || OptDevName[0] == 0 ) { OptDevName = "/dev/i2c/0"; } if( OptVerbose ) { printf("I2C device: %s\n\n", OptDevName); } if( i2c_open(pI2C, OptDevName) < 0 ) { LOGSYSERROR("%s: Failed to open.", OptDevName); exit(EC_ERROR); } } }
//----------------------------------------------------------------------------- // Purpose: runs diff on all changed files in the date range // Input : argc - // *argv[] - // Output : int //----------------------------------------------------------------------------- int main( int argc, char *argv[] ) { char tmpBuf[1024]; if ( argc < 2 ) { Error( "Incorrect usage\n" ); } ArgsInit( argc, argv ); const char *pSSDir = ArgsGet( "-ssdir", "\\\\jeeves\\vsscode" ); sprintf( tmpBuf, "ssdir=%s", pSSDir ); putenv( tmpBuf ); const char *pSSProject = argv[argc-1]; const char *pSSUser = ArgsGet( "-user", "Jay" ); printf("Changes for %s\n", pSSUser ); const char *pSSTmpFile = _tempnam( ".", "ssc" ); const char *pRecurse = ""; if ( ArgsExist( "-r" ) || ArgsExist( "-R" ) ) { pRecurse = "-R"; } const char *pDateRange = ArgsGet( "-vssdate", NULL ); char dateBuf[128]; if ( !pDateRange ) { pDateRange = ArgsGet( "-weeks", "1" ); int weeks = atoi( pDateRange ); struct tm last, first; SetToday( &last ); SetSunday( &last ); SubtractWeeks( &last, &first, weeks ); if ( ArgsExist( "-addcurrent" ) ) { SetToday( &last ); } string end = TmToString(last); string start = TmToString( first ); sprintf( dateBuf, "%s~%s", &end[0], &start[0] ); pDateRange = dateBuf; printf("From %s to %s\n", &start[0], &end[0] ); } else { printf("Using custom vss date range: %s\n", pDateRange ); } sprintf( tmpBuf, "history %s %s -vd%s -u%s >%s", pRecurse, pSSProject, pDateRange, pSSUser, pSSTmpFile ); RunVSS( tmpBuf ); STRING_LIST list = ParseHistory( pSSProject, pSSTmpFile ); int totalLines = 0; for ( int i = 0; i < list.size(); i++ ) { const char *pFileName = (const char *)&((list[i].file)[0]); sprintf( tmpBuf, "Diff -IEW %s -V%d~%d -DU >%s", pFileName, list[i].version-1, list[i].version, pSSTmpFile ); RunVSS( tmpBuf ); int linesChanged = CountDiffs( pSSTmpFile ); printf( "Changed %-32s (ver %3d) \t%4d lines\n", pFileName, list[i].version, linesChanged ); totalLines += linesChanged; } unlink( pSSTmpFile ); printf( "\nTotal Files changed: %d\n", list.size() ); printf( "Total Lines changed: %d\n\n", totalLines ); return 0; }