diff options
| author | me_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac> | 2012-06-17 21:15:12 +0000 |
|---|---|---|
| committer | me_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac> | 2012-06-17 21:15:12 +0000 |
| commit | 8df9466ada46e4b07990b9cb7e8b1cd61b96844a (patch) | |
| tree | 2cb652e5839bed672133ffa90e7ad477f55cfb6b /tests/test_getidfromsubstr.c | |
| download | pica-pica-8df9466ada46e4b07990b9cb7e8b1cd61b96844a.tar.gz pica-pica-8df9466ada46e4b07990b9cb7e8b1cd61b96844a.zip | |
todo list update
git-svn-id: svn://localhost/project_picapica/trunk@128 fb96df88-216d-11de-830c-f3023f12d8ac
Diffstat (limited to 'tests/test_getidfromsubstr.c')
| -rwxr-xr-x | tests/test_getidfromsubstr.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/test_getidfromsubstr.c b/tests/test_getidfromsubstr.c new file mode 100755 index 0000000..2e33a67 --- /dev/null +++ b/tests/test_getidfromsubstr.c @@ -0,0 +1,43 @@ +#include <stdlib.h> +#include <stdio.h> +#include <limits.h> +#include <string.h> + +int get_id_fromsubjstr(char* DN_str,unsigned int* id) +{ + char* tmp1; + char* tmp2; + + tmp1=strstr(DN_str,"/CN="); + + if (!tmp1) + return 0; + + tmp2=strchr(tmp1,'#'); + + if (!tmp2) + return 0; + + *tmp2=0; + + tmp1+=4; + + if (tmp1==tmp2) + return 0; + + *id=(unsigned int)strtol(tmp1,0,10); + + *tmp2='#'; + return 1; +} + +int main() +{ + int ret;unsigned int id; + char dnstr[]="/O=TESTNET/OU=CA/CN=#\xD1\x82\xD0\xB5\xD1\x81\xD1\x82\xD0\xB5\xD1\x80"; + + ret=get_id_fromsubjstr(dnstr,&id); + printf("dnstr=%s, ret=%i, id=%u \n",dnstr,ret,id); + +return 0; +} |
