| 32 |
32 |
#include "addrcache.h"
|
| 33 |
33 |
|
| 34 |
34 |
#include "base64.h"
|
|
35 |
#include "codeconv.h"
|
| 35 |
36 |
#include "utils.h"
|
| 36 |
37 |
|
| 37 |
38 |
/*
|
| ... | ... | |
| 384 |
385 |
gint iLen = 0, iLenT = 0;
|
| 385 |
386 |
ItemPerson *person;
|
| 386 |
387 |
ItemEMail *email;
|
|
388 |
gboolean familyFirst = FALSE;
|
| 387 |
389 |
|
| 388 |
390 |
nodeAddress = rec->listAddress;
|
| 389 |
391 |
if( nodeAddress == NULL ) return;
|
| ... | ... | |
| 408 |
410 |
if( rec->listLName ) {
|
| 409 |
411 |
lastName = rec->listLName->data;
|
| 410 |
412 |
}
|
|
413 |
if( rec->listCName ) {
|
|
414 |
fullName = g_strdup((gchar *)rec->listCName->data);
|
|
415 |
}
|
| 411 |
416 |
|
| 412 |
|
if( firstName ) {
|
| 413 |
|
if( lastName ) {
|
| 414 |
|
fullName = g_strdup_printf( "%s %s", firstName, lastName );
|
|
417 |
familyFirst = conv_is_ja_locale();
|
|
418 |
|
|
419 |
if( fullName == NULL ) {
|
|
420 |
if( familyFirst ) {
|
|
421 |
if( lastName ) {
|
|
422 |
if( firstName ) {
|
|
423 |
fullName = g_strdup_printf( "%s %s", lastName, firstName );
|
|
424 |
}
|
|
425 |
else {
|
|
426 |
fullName = g_strdup_printf( "%s", lastName );
|
|
427 |
}
|
|
428 |
}
|
|
429 |
else {
|
|
430 |
if( firstName ) {
|
|
431 |
fullName = g_strdup_printf( "%s", firstName );
|
|
432 |
}
|
|
433 |
}
|
|
434 |
} else {
|
|
435 |
if( firstName ) {
|
|
436 |
if( lastName ) {
|
|
437 |
fullName = g_strdup_printf( "%s %s", firstName, lastName );
|
|
438 |
}
|
|
439 |
else {
|
|
440 |
fullName = g_strdup_printf( "%s", firstName );
|
|
441 |
}
|
|
442 |
}
|
|
443 |
else {
|
|
444 |
if( lastName ) {
|
|
445 |
fullName = g_strdup_printf( "%s", lastName );
|
|
446 |
}
|
|
447 |
}
|
| 415 |
448 |
}
|
| 416 |
|
else {
|
| 417 |
|
fullName = g_strdup_printf( "%s", firstName );
|
| 418 |
|
}
|
| 419 |
449 |
}
|
| 420 |
|
else {
|
| 421 |
|
if( lastName ) {
|
| 422 |
|
fullName = g_strdup_printf( "%s", lastName );
|
| 423 |
|
}
|
| 424 |
|
}
|
| 425 |
450 |
if( fullName ) {
|
| 426 |
|
g_strchug( fullName ); g_strchomp( fullName );
|
|
451 |
g_strstrip( fullName );
|
| 427 |
452 |
}
|
| 428 |
453 |
|
| 429 |
454 |
if( rec->listNName ) {
|
| ... | ... | |
| 511 |
536 |
else if( g_ascii_strcasecmp( nm, LDIF_TAG_LASTNAME ) == 0 ) {
|
| 512 |
537 |
rec->listLName = g_slist_append( rec->listLName, val );
|
| 513 |
538 |
}
|
| 514 |
|
else if( g_ascii_strcasecmp( nm, LDIF_TAG_NICKNAME ) == 0 ) {
|
|
539 |
else if( g_ascii_strcasecmp( nm, LDIF_TAG_NICKNAME ) == 0 ||
|
|
540 |
g_ascii_strcasecmp( nm, LDIF_TAG_XNICKNAME ) == 0 ) {
|
| 515 |
541 |
rec->listNName = g_slist_append( rec->listNName, val );
|
| 516 |
542 |
}
|
| 517 |
543 |
else if( g_ascii_strcasecmp( nm, LDIF_TAG_EMAIL ) == 0 ) {
|
| ... | ... | |
| 598 |
624 |
gchar outBuf[8192];
|
| 599 |
625 |
gint len;
|
| 600 |
626 |
|
| 601 |
|
printf( "base-64 : inbuf : %s\n", buf );
|
|
627 |
g_print( "base-64 : inbuf : %s\n", buf );
|
| 602 |
628 |
decoder = base64_decoder_new();
|
| 603 |
629 |
len = base64_decoder_decode( decoder, buf, outBuf );
|
| 604 |
630 |
if (len < 0) {
|
| 605 |
|
printf( "base-64 : Bad BASE64 content\n" );
|
|
631 |
g_print( "base-64 : Bad BASE64 content\n" );
|
| 606 |
632 |
}
|
| 607 |
633 |
else {
|
| 608 |
634 |
outBuf[len] = '\0';
|
| 609 |
|
printf( "base-64 : %d : %s\n\n", len, outBuf );
|
|
635 |
g_print( "base-64 : %d : %s\n\n", len, outBuf );
|
| 610 |
636 |
}
|
| 611 |
637 |
base64_decoder_free( decoder );
|
| 612 |
638 |
decoder = NULL;
|
| 613 |
639 |
}
|
| 614 |
640 |
#endif
|
| 615 |
641 |
|
|
642 |
static gchar *ldif_conv_base64( gchar *buf ) {
|
|
643 |
gchar *outbuf;
|
|
644 |
gint len;
|
|
645 |
|
|
646 |
outbuf = g_malloc(strlen(buf) + 1);
|
|
647 |
len = base64_decode(outbuf, buf, -1);
|
|
648 |
outbuf[len] = '\0';
|
|
649 |
if (g_utf8_validate(outbuf, -1, NULL))
|
|
650 |
return outbuf;
|
|
651 |
else {
|
|
652 |
gchar *utf8str;
|
|
653 |
|
|
654 |
if (conv_is_ja_locale())
|
|
655 |
utf8str = conv_codeset_strdup(outbuf, NULL, NULL);
|
|
656 |
else
|
|
657 |
utf8str = conv_localetodisp(outbuf, NULL);
|
|
658 |
|
|
659 |
g_free(outbuf);
|
|
660 |
return utf8str;
|
|
661 |
}
|
|
662 |
}
|
|
663 |
|
| 616 |
664 |
/*
|
| 617 |
665 |
* Read file data into address cache.
|
| 618 |
666 |
* Note that one LDIF record identifies one entity uniquely with the
|
| ... | ... | |
| 663 |
711 |
fullValue = mgu_list_coalesce( listValue );
|
| 664 |
712 |
|
| 665 |
713 |
/* Base-64 encoded data */
|
| 666 |
|
/*
|
| 667 |
714 |
if( last64 ) {
|
| 668 |
|
ldif_dump_b64( fullValue );
|
|
715 |
gchar *decValue;
|
|
716 |
decValue = ldif_conv_base64( fullValue );
|
|
717 |
g_free( fullValue );
|
|
718 |
fullValue = decValue;
|
| 669 |
719 |
}
|
| 670 |
|
*/
|
| 671 |
720 |
|
| 672 |
721 |
ldif_add_value( rec, lastTag, fullValue, hashField );
|
| 673 |
722 |
/* ldif_print_record( rec, stdout ); */
|
| ... | ... | |
| 700 |
749 |
/* Save data */
|
| 701 |
750 |
fullValue = mgu_list_coalesce( listValue );
|
| 702 |
751 |
/* Base-64 encoded data */
|
| 703 |
|
/*
|
| 704 |
752 |
if( last64 ) {
|
| 705 |
|
ldif_dump_b64( fullValue );
|
|
753 |
gchar *decValue;
|
|
754 |
decValue = ldif_conv_base64( fullValue );
|
|
755 |
g_free( fullValue );
|
|
756 |
fullValue = decValue;
|
| 706 |
757 |
}
|
| 707 |
|
*/
|
| 708 |
758 |
|
| 709 |
759 |
ldif_add_value( rec, lastTag, fullValue, hashField );
|
| 710 |
760 |
g_free( lastTag );
|