| 14 | } |
| 15 | |
| 16 | int main(int argc, char* argv[]) |
| 17 | { |
| 18 | int ch; |
| 19 | acl::string from_charset, to_charset, from_dir, to_dir; |
| 20 | bool use_bom = false, check_only = false;; |
| 21 | |
| 22 | while ((ch = getopt(argc, argv, "hf:t:bs:d:c")) > 0) |
| 23 | { |
| 24 | switch (ch) |
| 25 | { |
| 26 | case 'h': |
| 27 | usage(argv[0]); |
| 28 | return 0; |
| 29 | case 'f': |
| 30 | from_charset = optarg; |
| 31 | break; |
| 32 | case 't': |
| 33 | to_charset = optarg; |
| 34 | break; |
| 35 | case 'b': |
| 36 | use_bom = true; |
| 37 | break; |
| 38 | case 's': |
| 39 | from_dir = optarg; |
| 40 | break; |
| 41 | case 'd': |
| 42 | to_dir = optarg; |
| 43 | break; |
| 44 | case 'c': |
| 45 | check_only = true; |
| 46 | break; |
| 47 | default: |
| 48 | break; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | acl::log::stdout_open(true); |
| 53 | |
| 54 | if (check_only) |
| 55 | { |
| 56 | if (from_dir.empty() || from_charset.empty()) |
| 57 | { |
| 58 | printf("from_charset or from_dir not set\r\n"); |
| 59 | return 1; |
| 60 | } |
| 61 | |
| 62 | int n = charset_transfer::check_path(from_dir, from_charset); |
| 63 | |
| 64 | printf("check over: %d, charset: %s\r\n", |
| 65 | n, from_charset.c_str()); |
| 66 | return 0; |
| 67 | } |
| 68 | |
| 69 | if (from_charset.empty() || to_charset.empty() |
| 70 | || from_dir.empty() || to_dir.empty()) |
| 71 | { |
| 72 | usage(argv[0]); |
| 73 | return 0; |