void scan_spool(int do_unlink) { int i; glob_t g; struct stat sb; UT_array *files; UT_array *xtras; utarray_new(files,&ut_str_icd); utarray_new(xtras,&xtra_icd); char **f, *file; file_xtra x, *xp; if (chdir(dir) == -1) exit(-1); glob(wild, 0, NULL, &g); for(i=0; i < g.gl_pathc; i++) { utarray_push_back(files, &g.gl_pathv[i]); } utarray_sort(files, strsort); f=NULL; while ( (f=(char**)utarray_next(files,f))) { file = *f; stat(file,&sb); if (do_unlink) unlink(file); x.file_idx = utarray_eltidx(files,f); x.file_len = sb.st_size; utarray_push_back(xtras, &x); } utarray_sort(xtras, xtrasort); xp=NULL; while ( (xp=(file_xtra*)utarray_next(xtras,xp))) { f = (char**)utarray_eltptr(files,xp->file_idx); file = *f; printf("file %s, len %d\n", blot(file),xp->file_len); } globfree(&g); utarray_free(files); utarray_free(xtras); }
static void numbergrid(int row, int col, int low_clue, int high_clue) { if (row == 2 && low_clue == 1 && !ALLBLOT) return; { static unsigned long count = 0; if (K > 0 && ++count >= K) { printf("At %d, %d:\n", row, col); show(); count = 0; } } if (high_clue - low_clue + 1 > squares_remaining(row, col)) { return; } if (col > N) { numbergrid(row + 1, 1, low_clue, high_clue); } else { int srow, scol, snum; srow = symmetric(row); scol = symmetric(col); snum = srow + 1; if (row > srow) { NUMBERUP(row, 1, N); if (low_clue == high_clue + 1) show(); } else if (row == symmetric(row) && col > symmetric(col)) { /*printf("Numbergrid up:\n"); show();*/ NUMBERUP(row, col, N); NUMBERUP(snum, 1, col - 2); if (low_clue == high_clue + 1) show(); } else { int newhi; if (across[low_clue] && (row != firstrow || col != firstcol) && !across[grid[row][col-1]] && !down[grid[row-1][col]] /* no 1-letter words */ && (newhi = high_clue, blot(srow, scol), blotted(snum, scol) ? 1 /* not blank; no numbergrid issues */ : blotted(snum, scol - 1) ? across[newhi] && down[newhi] /* OK to number */ ? (grid[snum][scol] = newhi--, 1) : 0 /* must number, but newhi won't work here */ : !across[newhi] && down[newhi] /* OK to number */ ? (grid[snum][scol] = newhi--, 1) : 0 /* must number, but newhi won't work here */ ) && (MINWORD <= 2 || !shortwords(row, col)) ) { blot(row, col); numbergrid(row, col + 1, low_clue, newhi); { if (!blotted(snum, scol)) blank(snum, scol, BLANK); } } if (row > firstrow || col >= firstcol) { if ((newhi = high_clue, blank(srow, scol, BLANK), blotted(snum, scol) ? 1 /* not blank; no numbergrid issues */ : blotted(snum, scol - 1) ? across[newhi] && !down[newhi] /* OK to number */ ? (blank(snum, scol, newhi--), 1) : 0 /* must number, but newhi won't work here */ : 1 /* no blot to left, therefore no number needed */ )) { if (numberable(row, col, low_clue) && low_clue <= high_clue) { blank(row, col, low_clue); numbergrid(row, col + 1, low_clue + 1, newhi); } else if (!numberable(row, col, ANY)) { blank(row, col, BLANK); numbergrid(row, col + 1, low_clue, newhi); } { if (!blotted(snum, scol)) blank(snum, scol, BLANK); } } } grid[row][col] = grid[srow][scol] = UNKNOWN; } } }