int main(int argc, char **argv) { char Buf[256], *cps, *cph; Setup(); ParseOptions(argc, argv); if (simple_to_from_hex) return simple_convert(); // if no input redirection then give usage. I 'guess' we could allow // a user to type in hashes, but is that really likely? It is almost // certain that if there is no input redirection, the user does not // know how to use the tool, so tell him how. if (isatty(fileno(stdin))) usage(argv[0]); FGETS(Buf, sizeof(Buf), stdin); while (!feof(stdin)) { strtok(Buf, "\r\n"); if (!leading_salt) { cph = Buf; cps = &Buf[hash_len]; if (salt_sep && *cps == salt_sep) ++cps; } else { cps = Buf; cph = &Buf[leading_salt]; if (salt_sep && *cph == salt_sep) {*cph++ = 0;} } printf("$dynamic_%d$%*.*s$%s\n", dyna_num, hash_len,hash_len, cph, GetSalt(cps)); FGETS(Buf, sizeof(Buf), stdin); } MEMDBG_PROGRAM_EXIT_CHECKS(stderr); return 0; }
/* print out any matches found */ static void display (MYDBM_FILE dbf, struct mandata *info, const char *page) { struct mandata *newinfo; char *string, *whatis, *string_conv; const char *page_name; char *key; int line_len, rest; newinfo = resolve_pointers (dbf, info, page); whatis = get_whatis (newinfo, page); if (newinfo == NULL) newinfo = info; dbprintf (newinfo); if (newinfo->name) page_name = newinfo->name; else page_name = page; key = xasprintf ("%s (%s)", page_name, newinfo->ext); if (hashtable_lookup_structure (display_seen, key, strlen (key))) goto out; hashtable_install (display_seen, key, strlen (key), NULL); line_len = get_line_length (); if (!long_output && strlen (page_name) > (size_t) (line_len / 2)) string = xasprintf ("%.*s...", line_len / 2 - 3, page_name); else string = xstrdup (page_name); string = appendstr (string, " (", newinfo->ext, ")", NULL); if (!STREQ (newinfo->pointer, "-") && !STREQ (newinfo->pointer, page)) string = appendstr (string, " [", newinfo->pointer, "]", NULL); if (strlen (string) < (size_t) 20) { int i; string = xrealloc (string, 21); for (i = strlen (string); i < 20; ++i) string[i] = ' '; string[i] = '\0'; } string = appendstr (string, " - ", NULL); rest = line_len - strlen (string); if (!long_output && strlen (whatis) > (size_t) rest) { whatis[rest - 3] = '\0'; string = appendstr (string, whatis, "...\n", NULL); } else string = appendstr (string, whatis, "\n", NULL); string_conv = simple_convert (conv_to_locale, string); fputs (string_conv, stdout); free (string_conv); free (string); out: free (key); free (whatis); if (newinfo != info) free_mandata_struct (newinfo); }