diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-07-15 12:26:57 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-07-15 12:26:57 +0000 |
commit | fc3f4c3fd168334d80167ab229d3e8e5841a4388 (patch) | |
tree | 2fefd817fdf1b61dddb835dd4acc879d55c67578 /src | |
parent | e67faec7efa18a8ce2bdb97798828e9d1a524683 (diff) | |
download | gnunet-fc3f4c3fd168334d80167ab229d3e8e5841a4388.tar.gz gnunet-fc3f4c3fd168334d80167ab229d3e8e5841a4388.zip |
-hacking get, rename, delete on client side
Diffstat (limited to 'src')
-rw-r--r-- | src/identity/identity_api.c | 101 |
1 files changed, 94 insertions, 7 deletions
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c index 291113b95..e35137cbe 100644 --- a/src/identity/identity_api.c +++ b/src/identity/identity_api.c | |||
@@ -501,7 +501,6 @@ transmit_next (struct GNUNET_IDENTITY_Handle *h) | |||
501 | GNUNET_NO, | 501 | GNUNET_NO, |
502 | &send_next_message, | 502 | &send_next_message, |
503 | h); | 503 | h); |
504 | |||
505 | } | 504 | } |
506 | 505 | ||
507 | 506 | ||
@@ -593,8 +592,35 @@ GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *id, | |||
593 | GNUNET_IDENTITY_Callback cb, | 592 | GNUNET_IDENTITY_Callback cb, |
594 | void *cb_cls) | 593 | void *cb_cls) |
595 | { | 594 | { |
596 | GNUNET_break (0); // FIXME | 595 | struct GNUNET_IDENTITY_Operation *op; |
597 | return NULL; | 596 | struct GNUNET_IDENTITY_GetDefaultMessage *gdm; |
597 | size_t slen; | ||
598 | |||
599 | slen = strlen (service_name) + 1; | ||
600 | if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_GetDefaultMessage)) | ||
601 | { | ||
602 | GNUNET_break (0); | ||
603 | return NULL; | ||
604 | } | ||
605 | op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) + | ||
606 | sizeof (struct GNUNET_IDENTITY_GetDefaultMessage) + | ||
607 | slen); | ||
608 | op->cb = cb; | ||
609 | op->cls = cb_cls; | ||
610 | gdm = (struct GNUNET_IDENTITY_GetDefaultMessage *) &op[1]; | ||
611 | gdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT); | ||
612 | gdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_GetDefaultMessage) + | ||
613 | slen); | ||
614 | gdm->name_len = htons (slen); | ||
615 | gdm->reserved = htons (0); | ||
616 | memcpy (&gdm[1], service_name, slen); | ||
617 | op->msg = &gdm->header; | ||
618 | GNUNET_CONTAINER_DLL_insert_tail (id->op_head, | ||
619 | id->op_tail, | ||
620 | op); | ||
621 | if (NULL == id->th) | ||
622 | transmit_next (id); | ||
623 | return op; | ||
598 | } | 624 | } |
599 | 625 | ||
600 | 626 | ||
@@ -657,8 +683,42 @@ GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *id, | |||
657 | GNUNET_IDENTITY_Continuation cb, | 683 | GNUNET_IDENTITY_Continuation cb, |
658 | void *cb_cls) | 684 | void *cb_cls) |
659 | { | 685 | { |
660 | GNUNET_break (0); // FIXME | 686 | struct GNUNET_IDENTITY_Operation *op; |
661 | return NULL; | 687 | struct GNUNET_IDENTITY_RenameMessage *grm; |
688 | size_t slen_old; | ||
689 | size_t slen_new; | ||
690 | char *dst; | ||
691 | |||
692 | slen_old = strlen (old_identifier) + 1; | ||
693 | slen_new = strlen (new_identifier) + 1; | ||
694 | if ( (slen_old >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || | ||
695 | (slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || | ||
696 | (slen_old + slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_RenameMessage)) ) | ||
697 | { | ||
698 | GNUNET_break (0); | ||
699 | return NULL; | ||
700 | } | ||
701 | op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) + | ||
702 | sizeof (struct GNUNET_IDENTITY_RenameMessage) + | ||
703 | slen_old + slen_new); | ||
704 | op->cont = cb; | ||
705 | op->cls = cb_cls; | ||
706 | grm = (struct GNUNET_IDENTITY_RenameMessage *) &op[1]; | ||
707 | grm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_RENAME); | ||
708 | grm->header.size = htons (sizeof (struct GNUNET_IDENTITY_RenameMessage) + | ||
709 | slen_old + slen_new); | ||
710 | grm->old_name_len = htons (slen_old); | ||
711 | grm->new_name_len = htons (slen_new); | ||
712 | dst = (char *) &grm[1]; | ||
713 | memcpy (dst, old_identifier, slen_old); | ||
714 | memcpy (&dst[slen_old], new_identifier, slen_new); | ||
715 | op->msg = &grm->header; | ||
716 | GNUNET_CONTAINER_DLL_insert_tail (id->op_head, | ||
717 | id->op_tail, | ||
718 | op); | ||
719 | if (NULL == id->th) | ||
720 | transmit_next (id); | ||
721 | return op; | ||
662 | } | 722 | } |
663 | 723 | ||
664 | 724 | ||
@@ -677,8 +737,35 @@ GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *id, | |||
677 | GNUNET_IDENTITY_Continuation cb, | 737 | GNUNET_IDENTITY_Continuation cb, |
678 | void *cb_cls) | 738 | void *cb_cls) |
679 | { | 739 | { |
680 | GNUNET_break (0); // FIXME | 740 | struct GNUNET_IDENTITY_Operation *op; |
681 | return NULL; | 741 | struct GNUNET_IDENTITY_DeleteMessage *gdm; |
742 | size_t slen; | ||
743 | |||
744 | slen = strlen (identifier) + 1; | ||
745 | if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_DeleteMessage)) | ||
746 | { | ||
747 | GNUNET_break (0); | ||
748 | return NULL; | ||
749 | } | ||
750 | op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) + | ||
751 | sizeof (struct GNUNET_IDENTITY_DeleteMessage) + | ||
752 | slen); | ||
753 | op->cont = cb; | ||
754 | op->cls = cb_cls; | ||
755 | gdm = (struct GNUNET_IDENTITY_DeleteMessage *) &op[1]; | ||
756 | gdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_DELETE); | ||
757 | gdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_DeleteMessage) + | ||
758 | slen); | ||
759 | gdm->name_len = htons (slen); | ||
760 | gdm->reserved = htons (0); | ||
761 | memcpy (&gdm[1], identifier, slen); | ||
762 | op->msg = &gdm->header; | ||
763 | GNUNET_CONTAINER_DLL_insert_tail (id->op_head, | ||
764 | id->op_tail, | ||
765 | op); | ||
766 | if (NULL == id->th) | ||
767 | transmit_next (id); | ||
768 | return op; | ||
682 | } | 769 | } |
683 | 770 | ||
684 | 771 | ||