Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00030 #include <errno.h>
00031
00032 #include "../../parser/parse_from.h"
00033 #include "../../parser/parse_cseq.h"
00034 #include "../../parser/parse_content.h"
00035 #include "../../parser/parse_uri.h"
00036 #include "../../parser/contact/parse_contact.h"
00037
00038 #include "../../data_lump.h"
00039 #include "../../msg_translator.h"
00040 #include "auth_identity.h"
00041
00042
00043
00044
00045
00046 int initdynstr(dynstr *sout, int isize)
00047 {
00048 memset(sout,0,sizeof(*sout));
00049 getstr_dynstr(sout).s=pkg_malloc(isize);
00050 if (!getstr_dynstr(sout).s) {
00051 LOG(L_WARN,
00052 "AUTH_IDENTITY:initdynstr: Not enough memory error\n");
00053 return -1;
00054 }
00055 sout->size=isize;
00056
00057 return 0;
00058 }
00059
00060 int cpy2dynstr(dynstr *sout, str *s2app)
00061 {
00062 char *stmp;
00063 int isize = s2app->len;
00064
00065 if (isize > sout->size) {
00066 stmp=pkg_realloc(sout->sd.s, isize);
00067 if (!stmp) {
00068 LOG(L_ERR, "AUTH_IDENTITY:cpy2dynstr: Not enough memory error\n");
00069 return -1;
00070 }
00071 sout->sd.s=stmp;
00072 sout->size=isize;
00073 }
00074
00075 memcpy(sout->sd.s,s2app->s,s2app->len);
00076 sout->sd.len = isize;
00077
00078 return 0;
00079 }
00080
00081 int app2dynchr(dynstr *sout, char capp)
00082 {
00083 char *stmp;
00084 int isize = sout->sd.len + 1;
00085
00086 if (isize > sout->size) {
00087 stmp=pkg_realloc(sout->sd.s, isize);
00088 if (!stmp) {
00089 LOG(L_ERR, "AUTH_IDENTITY:app2dynchr: Not enough memory error\n");
00090 return -1;
00091 }
00092 sout->sd.s=stmp;
00093 sout->size++;
00094 }
00095
00096 sout->sd.s[sout->sd.len]=capp;
00097 sout->sd.len++;
00098
00099 return 0;
00100 }
00101
00102 int app2dynstr(dynstr *sout, str *s2app)
00103 {
00104 char *stmp;
00105 int isize = sout->sd.len + s2app->len;
00106
00107 if (isize > sout->size) {
00108 stmp=pkg_realloc(sout->sd.s, isize);
00109 if (!stmp) {
00110 LOG(L_ERR, "AUTH_IDENTITY:app2dynstr: Not enough memory error\n");
00111 return -1;
00112 }
00113 sout->sd.s=stmp;
00114 sout->size=isize;
00115 }
00116
00117 memcpy(&sout->sd.s[sout->sd.len],s2app->s,s2app->len);
00118 sout->sd.len = isize;
00119
00120 return 0;
00121 }