@@ -249,31 +249,42 @@ int main(int argc, char *argv[])
249249{
250250 process_args (argc, argv);
251251
252+ if (version) {
253+ std::cout << " \n X-LINUX-ISP version: " << README_VERSION << " \n " << std::endl;
254+ return 0 ;
255+ }
256+ else if (features) {
257+ std::cout << " \n ISP software:\n " << README_SOFTWARE << std::endl;
258+ std::cout << " \n Application examples:\n " << README_APPLI << " \n " << std::endl;
259+ std::cout << " \n Utilities:\n " << README_UTILITIES << " \n " << std::endl;
260+ std::cout << " \n Find more information on the wiki page: https://wiki.st.com/stm32mpu/wiki/Category:X-LINUX-ISP_expansion_package" << std::endl;
261+ return 0 ;
262+ }
263+
252264 /* Execute apt-get update first */
253- if (!version && !features) {
254- FILE *fp;
255- char path[1035 ];
265+ FILE *fp;
266+ char path[1035 ];
267+
268+ /* Open the command for reading */
269+ fp = popen (" apt-get update 2>&1" , " r" );
270+ if (fp == NULL ) {
271+ std::cout << " Fail to synchronize ISP packages, apt-get update fails." << std::endl;
272+ return 0 ;
273+ }
256274
257- /* Open the command for reading */
258- fp = popen (" apt-get update 2>&1" , " r" );
259- if (fp == NULL ) {
275+ /* Read the output a line at a time */
276+ while (fgets (path, sizeof (path) - 1 , fp) != NULL ) {
277+ /* Check for specific error message */
278+ if (strstr (path, " W: Failed" ) != NULL ) {
260279 std::cout << " Fail to synchronize ISP packages, apt-get update fails." << std::endl;
280+ pclose (fp);
261281 return 0 ;
262282 }
283+ }
263284
264- /* Read the output a line at a time */
265- while (fgets (path, sizeof (path) - 1 , fp) != NULL ) {
266- /* Check for specific error message */
267- if (strstr (path, " W: Failed" ) != NULL ) {
268- std::cout << " Fail to synchronize ISP packages, apt-get update fails." << std::endl;
269- pclose (fp);
270- return 0 ;
271- }
272- }
285+ /* Close the command stream */
286+ pclose (fp);
273287
274- /* Close the command stream */
275- pclose (fp);
276- }
277288
278289 /* Get list of ISP packages */
279290 /* 2 search paths to get the list of ISP packages: the official path and citool path */
@@ -328,15 +339,6 @@ int main(int argc, char *argv[])
328339 else if (to_remove && argc == 3 ) {
329340 manage_pkgs (argc, argv,false );
330341 }
331- else if (version) {
332- std::cout << " \n X-LINUX-ISP version: " << README_VERSION << " \n " << std::endl;
333- }
334- else if (features) {
335- std::cout << " \n ISP software:\n " << README_SOFTWARE << std::endl;
336- std::cout << " \n Application examples:\n " << README_APPLI << " \n " << std::endl;
337- std::cout << " \n Utilities:\n " << README_UTILITIES << " \n " << std::endl;
338- std::cout << " \n Find more information on the wiki page: https://wiki.st.com/stm32mpu/wiki/Category:X-LINUX-ISP_expansion_package" << std::endl;
339- }
340342 else {
341343 print_help (argc, argv);
342344 }
0 commit comments