comparison cinst/main.c @ 291:5ab445e6a4da

Trim instruction lines to avoid line ending trouble
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 02 Apr 2014 15:35:12 +0000
parents b460d2cf088d
children f733f4aa2a90
comparison
equal deleted inserted replaced
290:b460d2cf088d 291:5ab445e6a4da
113 printf ("Too many lines\n"); 113 printf ("Too many lines\n");
114 return ERR_TOO_MUCH_INPUT; 114 return ERR_TOO_MUCH_INPUT;
115 } 115 }
116 if (*buf == 'I') 116 if (*buf == 'I')
117 { 117 {
118 /* Remove leading I: and trailing \n */ 118 char *trimmed = buf+2;
119 strv_append (to_install, buf + 2, len - 3); 119 /* Remove leading I: and trailing whitespace */
120 str_trim(&trimmed);
121 strv_append (to_install, trimmed, strlen(trimmed));
120 continue; 122 continue;
121 } 123 }
122 if (*buf == 'R') 124 if (*buf == 'R')
123 { 125 {
124 /* Remove leading R: and trailing \n */ 126 char *trimmed = buf+2;
125 strv_append (to_remove, buf + 2, len - 3); 127 /* Remove leading R: and trailing whitespace */
128 str_trim(&trimmed);
129 strv_append (to_remove, trimmed, strlen(trimmed));
126 continue; 130 continue;
127 } 131 }
128 } 132 }
129 133
130 return 0; 134 return 0;
160 for (i = 0; to_validate[i]; i++) 164 for (i = 0; to_validate[i]; i++)
161 { 165 {
162 bool found = false; 166 bool found = false;
163 for (j = 0; all_certs[j]; j++) 167 for (j = 0; all_certs[j]; j++)
164 { 168 {
165 if (strncmp (to_validate[i], all_certs[j], MAX_LINE_LENGTH - 2) == 169 if (strncmp (to_validate[i], all_certs[j], MAX_LINE_LENGTH) ==
166 0) 170 0)
167 { 171 {
168 found = true; 172 found = true;
169 break; 173 break;
170 } 174 }
171 } 175 }
172 if (!found) 176 if (!found)
173 { 177 {
174 printf ("Install instruction with invalid certificate\n."); 178 DEBUGPRINTF ("Failed to find certificate; \n%s\n", to_validate[i]);
175 return ERR_INVALID_INSTRUCTIONS; 179 return ERR_INVALID_INSTRUCTIONS;
176 } 180 }
177 } 181 }
178 182
179 return 0; 183 return 0;

http://wald.intevation.org/projects/trustbridge/