msdosfs_conv.c (33751) | msdosfs_conv.c (33760) |
---|---|
1/* $Id: msdosfs_conv.c,v 1.19 1998/02/22 17:26:24 ache Exp $ */ | 1/* $Id: msdosfs_conv.c,v 1.20 1998/02/22 18:00:49 ache Exp $ */ |
2/* $NetBSD: msdosfs_conv.c,v 1.25 1997/11/17 15:36:40 ws Exp $ */ 3 4/*- 5 * Copyright (C) 1995, 1997 Wolfgang Solfrank. 6 * Copyright (C) 1995, 1997 TooLs GmbH. 7 * All rights reserved. 8 * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below). 9 * --- 336 unchanged lines hidden (view full) --- 346 */ 347 348/* 349 * Convert a DOS filename to a unix filename. And, return the number of 350 * characters in the resulting unix filename excluding the terminating 351 * null. 352 */ 353int | 2/* $NetBSD: msdosfs_conv.c,v 1.25 1997/11/17 15:36:40 ws Exp $ */ 3 4/*- 5 * Copyright (C) 1995, 1997 Wolfgang Solfrank. 6 * Copyright (C) 1995, 1997 TooLs GmbH. 7 * All rights reserved. 8 * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below). 9 * --- 336 unchanged lines hidden (view full) --- 346 */ 347 348/* 349 * Convert a DOS filename to a unix filename. And, return the number of 350 * characters in the resulting unix filename excluding the terminating 351 * null. 352 */ 353int |
354dos2unixfn(dn, un, lower) | 354dos2unixfn(dn, un, lower, ul) |
355 u_char dn[11]; 356 u_char *un; 357 int lower; | 355 u_char dn[11]; 356 u_char *un; 357 int lower; |
358 u_int8_t *ul; |
|
358{ 359 int i; 360 int thislong = 1; 361 u_char c; | 359{ 360 int i; 361 int thislong = 1; 362 u_char c; |
363 int table_loaded = (ul != NULL); |
|
362 363 /* 364 * If first char of the filename is SLOT_E5 (0x05), then the real 365 * first char of the filename should be 0xe5. But, they couldn't 366 * just have a 0xe5 mean 0xe5 because that is used to mean a freed 367 * directory slot. Another dos quirk. 368 */ 369 if (*dn == SLOT_E5) 370 c = dos2unix[0xe5]; 371 else 372 c = dos2unix[*dn]; | 364 365 /* 366 * If first char of the filename is SLOT_E5 (0x05), then the real 367 * first char of the filename should be 0xe5. But, they couldn't 368 * just have a 0xe5 mean 0xe5 because that is used to mean a freed 369 * directory slot. Another dos quirk. 370 */ 371 if (*dn == SLOT_E5) 372 c = dos2unix[0xe5]; 373 else 374 c = dos2unix[*dn]; |
373 *un++ = lower ? u2l[c] : c; | 375 *un++ = lower ? 376 (table_loaded && (c & 0x80) ? 377 ul[c & 0x7f] : u2l[c]) : c; |
374 dn++; 375 376 /* 377 * Copy the name portion into the unix filename string. 378 */ 379 for (i = 1; i < 8 && *dn != ' '; i++) { 380 c = dos2unix[*dn++]; | 378 dn++; 379 380 /* 381 * Copy the name portion into the unix filename string. 382 */ 383 for (i = 1; i < 8 && *dn != ' '; i++) { 384 c = dos2unix[*dn++]; |
381 *un++ = lower ? u2l[c] : c; | 385 *un++ = lower ? 386 (table_loaded && (c & 0x80) ? 387 ul[c & 0x7f] : u2l[c]) : c; |
382 thislong++; 383 } 384 dn += 8 - i; 385 386 /* 387 * Now, if there is an extension then put in a period and copy in 388 * the extension. 389 */ 390 if (*dn != ' ') { 391 *un++ = '.'; 392 thislong++; 393 for (i = 0; i < 3 && *dn != ' '; i++) { 394 c = dos2unix[*dn++]; | 388 thislong++; 389 } 390 dn += 8 - i; 391 392 /* 393 * Now, if there is an extension then put in a period and copy in 394 * the extension. 395 */ 396 if (*dn != ' ') { 397 *un++ = '.'; 398 thislong++; 399 for (i = 0; i < 3 && *dn != ' '; i++) { 400 c = dos2unix[*dn++]; |
395 *un++ = lower ? u2l[c] : c; | 401 *un++ = lower ? 402 (table_loaded && (c & 0x80) ? 403 ul[c & 0x7f] : u2l[c]) : c; |
396 thislong++; 397 } 398 } 399 *un++ = 0; 400 401 return (thislong); 402} 403 --- 254 unchanged lines hidden (view full) --- 658 return '?'; 659} 660 661/* 662 * Compare our filename to the one in the Win95 entry 663 * Returns the checksum or -1 if no match 664 */ 665int | 404 thislong++; 405 } 406 } 407 *un++ = 0; 408 409 return (thislong); 410} 411 --- 254 unchanged lines hidden (view full) --- 666 return '?'; 667} 668 669/* 670 * Compare our filename to the one in the Win95 entry 671 * Returns the checksum or -1 if no match 672 */ 673int |
666winChkName(un, unlen, wep, chksum, u2w) | 674winChkName(un, unlen, wep, chksum, u2w, ul) |
667 const u_char *un; 668 int unlen; 669 struct winentry *wep; 670 int chksum; 671 u_int16_t *u2w; | 675 const u_char *un; 676 int unlen; 677 struct winentry *wep; 678 int chksum; 679 u_int16_t *u2w; |
680 u_int8_t *ul; |
|
672{ 673 u_int8_t *cp; 674 int i; 675 u_int16_t code; | 681{ 682 u_int8_t *cp; 683 int i; 684 u_int16_t code; |
676 int table_loaded = (u2w != NULL); | 685 int u2w_loaded = (u2w != NULL); 686 int ul_loaded = (ul != NULL); 687 u_int8_t c1, c2; |
677 678 /* 679 * First compare checksums 680 */ 681 if (wep->weCnt&WIN_LAST) 682 chksum = wep->weChksum; 683 else if (chksum != wep->weChksum) 684 chksum = -1; --- 16 unchanged lines hidden (view full) --- 701 for (cp = wep->wePart1, i = sizeof(wep->wePart1)/2; --i >= 0;) { 702 if (--unlen < 0) { 703 if (!*cp++ && !*cp) 704 return chksum; 705 return -1; 706 } 707 code = (cp[1] << 8) | cp[0]; 708 if (code & 0xff80) { | 688 689 /* 690 * First compare checksums 691 */ 692 if (wep->weCnt&WIN_LAST) 693 chksum = wep->weChksum; 694 else if (chksum != wep->weChksum) 695 chksum = -1; --- 16 unchanged lines hidden (view full) --- 712 for (cp = wep->wePart1, i = sizeof(wep->wePart1)/2; --i >= 0;) { 713 if (--unlen < 0) { 714 if (!*cp++ && !*cp) 715 return chksum; 716 return -1; 717 } 718 code = (cp[1] << 8) | cp[0]; 719 if (code & 0xff80) { |
709 if (table_loaded) | 720 if (u2w_loaded) |
710 code = find_lcode(code, u2w); 711 else if (code & 0xff00) 712 code = '?'; 713 } | 721 code = find_lcode(code, u2w); 722 else if (code & 0xff00) 723 code = '?'; 724 } |
714 if (u2l[code] != u2l[*un++]) | 725 c1 = ul_loaded && (code & 0x80) ? 726 ul[code & 0x7f] : u2l[code]; 727 c2 = ul_loaded && (*un & 0x80) ? 728 ul[*un & 0x7f] : u2l[*un]; 729 if (c1 != c2) |
715 return -1; 716 cp += 2; | 730 return -1; 731 cp += 2; |
732 un++; |
|
717 } 718 for (cp = wep->wePart2, i = sizeof(wep->wePart2)/2; --i >= 0;) { 719 if (--unlen < 0) { 720 if (!*cp++ && !*cp) 721 return chksum; 722 return -1; 723 } 724 code = (cp[1] << 8) | cp[0]; 725 if (code & 0xff80) { | 733 } 734 for (cp = wep->wePart2, i = sizeof(wep->wePart2)/2; --i >= 0;) { 735 if (--unlen < 0) { 736 if (!*cp++ && !*cp) 737 return chksum; 738 return -1; 739 } 740 code = (cp[1] << 8) | cp[0]; 741 if (code & 0xff80) { |
726 if (table_loaded) | 742 if (u2w_loaded) |
727 code = find_lcode(code, u2w); 728 else if (code & 0xff00) 729 code = '?'; 730 } | 743 code = find_lcode(code, u2w); 744 else if (code & 0xff00) 745 code = '?'; 746 } |
731 if (u2l[code] != u2l[*un++]) | 747 c1 = ul_loaded && (code & 0x80) ? 748 ul[code & 0x7f] : u2l[code]; 749 c2 = ul_loaded && (*un & 0x80) ? 750 ul[*un & 0x7f] : u2l[*un]; 751 if (c1 != c2) |
732 return -1; 733 cp += 2; | 752 return -1; 753 cp += 2; |
754 un++; |
|
734 } 735 for (cp = wep->wePart3, i = sizeof(wep->wePart3)/2; --i >= 0;) { 736 if (--unlen < 0) { 737 if (!*cp++ && !*cp) 738 return chksum; 739 return -1; 740 } 741 code = (cp[1] << 8) | cp[0]; 742 if (code & 0xff80) { | 755 } 756 for (cp = wep->wePart3, i = sizeof(wep->wePart3)/2; --i >= 0;) { 757 if (--unlen < 0) { 758 if (!*cp++ && !*cp) 759 return chksum; 760 return -1; 761 } 762 code = (cp[1] << 8) | cp[0]; 763 if (code & 0xff80) { |
743 if (table_loaded) | 764 if (u2w_loaded) |
744 code = find_lcode(code, u2w); 745 else if (code & 0xff00) 746 code = '?'; 747 } | 765 code = find_lcode(code, u2w); 766 else if (code & 0xff00) 767 code = '?'; 768 } |
748 if (u2l[code] != u2l[*un++]) | 769 c1 = ul_loaded && (code & 0x80) ? 770 ul[code & 0x7f] : u2l[code]; 771 c2 = ul_loaded && (*un & 0x80) ? 772 ul[*un & 0x7f] : u2l[*un]; 773 if (c1 != c2) |
749 return -1; 750 cp += 2; | 774 return -1; 775 cp += 2; |
776 un++; |
|
751 } 752 return chksum; 753} 754 755/* 756 * Convert Win95 filename to dirbuf. 757 * Returns the checksum or -1 if impossible 758 */ --- 166 unchanged lines hidden --- | 777 } 778 return chksum; 779} 780 781/* 782 * Convert Win95 filename to dirbuf. 783 * Returns the checksum or -1 if impossible 784 */ --- 166 unchanged lines hidden --- |