int main(int argc, char **argv) { int length, repetitions; /* Store the command line arguments for string length and the number of strings required */ int opt; int i; srand(time(0)); if (argc < 3) { fprintf(stderr, "Usage: %s -l length -n number of passwords\n", argv[0]); exit(EXIT_FAILURE); } while ((opt = getopt(argc, argv, "l:n:")) != -1) { switch (opt) { case 'n': repetitions = atoi(optarg); break; case 'l': length = atoi(optarg); break; default: fprintf(stderr, "Usage: %s -l length -n number of passwords\n", argv[0]); exit (EXIT_FAILURE); } } for (i = 0; i < repetitions; i++) puts(getPwd(length)); return 0; }
void fcurrentdir(char *buffer, int size) { int currentP; char *p; int len; char namebuffer[13]; int i; char *q; p = buffer + size -1; *p = '\0'; p--; currentP = getPwd(); while (1) { getName(namebuffer, currentP); len = strlen(namebuffer); mystrncpy(p-len, namebuffer, len); *p = '/'; p = p-len-1; currentP = read8uint(currentP, 31); if (currentP == 0) break; } *p = '/'; len = buffer+size-1-p; q = buffer; for (i=0; i<len; i++) *q++ = *p++; q--; *q = '\0'; return; }
static int enterDirectory(Stream_t *Dir) { int r; char drive; if(currentDir == Dir) return 0; /* still the same directory */ leaveDirectory(0); drive = getDrive(Dir); r=enterDrive(Dir, drive); if(r) return r; currentDir = COPY(Dir); dynDirPath = getPwd(getDirentry(Dir)); if(!dynDirPath) dirPath=emptyString; else { if(!dynDirPath[3] && concise) dynDirPath[2]='\0'; dirPath=dynDirPath; } /* print directory title */ if(!concise) printf("\nDirectory for %s\n", dirPath); if(!wide && !concise) printf("\n"); dirsOnDrive++; bytesInDir = 0; filesInDir = 0; return 0; }
static int enterDirectory(Stream_t *Dir) { int r; char *drive; char *slash; if(currentDir == Dir) return 0; /* still the same directory */ leaveDirectory(0); drive = getDrive(Dir); r=enterDrive(Dir, drive); if(r) return r; currentDir = COPY(Dir); dirPath = getPwd(getDirentry(Dir)); if(!dirPath) dirPath=emptyString; if(concise && (slash = strrchr(dirPath, '/')) != NULL && slash[1] == '\0') *slash = '\0'; /* print directory title */ if(!concise) printf("\nDirectory for %s\n", dirPath); if(!wide && !concise) printf("\n"); dirsOnDrive++; bytesInDir = 0; filesInDir = 0; return 0; }