115 |
} |
} |
116 |
|
|
117 |
|
|
|
/* Try to read a line, terminated by \n from the given |
|
|
gpgme data object @dh into @line. |
|
|
Return value: numbers of chars read. */ |
|
|
size_t |
|
|
gpg_data_readline (gpgme_data_t dh, char *line, size_t nbytes) |
|
|
{ |
|
|
char ch = 0; |
|
|
int nread = 0, pos = 0; |
|
|
|
|
|
if( !dh ) |
|
|
return 0; |
|
|
|
|
|
memset( line, 0, nbytes ); |
|
|
while( (nread=gpgme_data_read( dh, &ch, 1)) != -1 ) { |
|
|
if( !nread ) |
|
|
break; |
|
|
if( ch == '\n' ) { |
|
|
line[pos++] = ch; |
|
|
line[pos++] = '\0'; |
|
|
break; |
|
|
} |
|
|
line[pos++] = ch; |
|
|
if( pos > (int)nbytes ) { |
|
|
line[pos++] = '\0'; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
return pos; |
|
|
} |
|
|
|
|
|
|
|
118 |
/* Search for the armor header 'Version:' in @r_dh and |
/* Search for the armor header 'Version:' in @r_dh and |
119 |
add the WinPT version. On success @r_dh is replaced |
add the WinPT version. On success @r_dh is replaced |
120 |
with the modified data. |
with the modified data. |
125 |
gpgme_error_t err = 0; |
gpgme_error_t err = 0; |
126 |
gpgme_data_t mdh; |
gpgme_data_t mdh; |
127 |
char line[128+32]; |
char line[128+32]; |
128 |
|
int n; |
129 |
|
|
130 |
if (!r_dh) |
if (!r_dh) |
131 |
return gpg_error (GPG_ERR_INV_ARG); |
return gpg_error (GPG_ERR_INV_ARG); |
|
*r_dh = NULL; |
|
132 |
|
|
133 |
err = gpgme_data_new(&mdh); |
err = gpgme_data_new (&mdh); |
134 |
if (err) |
if (err) |
135 |
return err; |
return err; |
136 |
|
|
137 |
while (gpg_data_readline (*r_dh, line, 128)) { |
gpgme_data_rewind (*r_dh); |
138 |
|
while ((n=gpg_data_readline (*r_dh, line, 128)) > 0) { |
139 |
|
line[n] = '\0'; |
140 |
if (strlen (line) > 14 && |
if (strlen (line) > 14 && |
141 |
!strncmp (line, "Version: GnuPG", 14) && |
!strncmp (line, "Version: GnuPG", 14) && |
142 |
!strstr (line, "WinPT "PGM_VERSION)) { |
!strstr (line, "WinPT "PGM_VERSION)) { |
147 |
} |
} |
148 |
gpgme_data_write (mdh, line, strlen (line)); |
gpgme_data_write (mdh, line, strlen (line)); |
149 |
} |
} |
150 |
|
|
151 |
gpgme_data_write (mdh, "", 1); |
gpgme_data_write (mdh, "", 1); |
152 |
|
gpgme_data_rewind (mdh); |
153 |
gpgme_data_release (*r_dh); |
gpgme_data_release (*r_dh); |
154 |
*r_dh = mdh; |
*r_dh = mdh; |
155 |
return err; |
return err; |
174 |
gpg_data_change_version (&in); |
gpg_data_change_version (&in); |
175 |
|
|
176 |
clip_text = gpgme_data_release_and_get_mem (in, &n); |
clip_text = gpgme_data_release_and_get_mem (in, &n); |
177 |
if (clip_text && (size = strlen (clip_text)) > 0) { |
if (clip_text && *clip_text) { |
178 |
clip_text[n] = 0; |
clip_text[n] = 0; |
179 |
|
size = strlen (clip_text); |
180 |
set_w32_clip_text (clip_text, size); |
set_w32_clip_text (clip_text, size); |
181 |
memset (clip_text, 0xFF, size); |
memset (clip_text, 0xFF, size); |
182 |
if (clip_text) |
if (clip_text) |
183 |
free (clip_text); |
free (clip_text); |
184 |
} |
} |
|
gpgme_data_release (in); |
|
185 |
} |
} |