From 9b479cc4aaf2c595656aa96cccfff2a421fecb27 Mon Sep 17 00:00:00 2001 From: bvl Date: Thu, 30 Nov 2000 23:27:41 +0000 Subject: [PATCH] OS/2 Updates git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@1369 67ed7778-7388-44ab-90cf-0a291f65f57c --- frontends/command-line/main.c | 866 ++++++++++++++-------------- frontends/command-line/makefile.os2 | 19 +- 2 files changed, 455 insertions(+), 430 deletions(-) diff --git a/frontends/command-line/main.c b/frontends/command-line/main.c index 119abfd32..dbc951922 100644 --- a/frontends/command-line/main.c +++ b/frontends/command-line/main.c @@ -109,8 +109,8 @@ Option option[] = { {"", "verify", "", "Verifies gPhoto installation", test, 0}, {"", "list-cameras", "", "List supported camera models", list_cameras, 0}, {"", "list-ports", "", "List supported port devices", list_ports, 0}, -{"", "stdout", "", "Send file to stdout", use_stdout, 0}, -{"", "stdout-size", "", "Print filesize before data", use_stdout_size,0}, +{"", "stdout", "", "Send file to stdout", use_stdout, 0}, +{"", "stdout-size", "", "Print filesize before data", use_stdout_size,0}, /* Settings needed for camera functions */ {"" , "port", "path", "Specify port device", port, 0}, @@ -119,26 +119,26 @@ Option option[] = { {"" , "filename", "filename", "Specify a filename", filename, 0}, /* Actions that depend on settings */ -{"a", "abilities", "", "Display camera abilities", abilities, 0}, -{"f", "folder", "folder", "Specify camera folder (default=\"/\")",use_folder,0}, -{"R", "recurse", "", "Recursively descend through folders",recurse, 0}, -{"l", "list-folders", "", "List folders in folder", list_folders, 0}, -{"L", "list-files", "", "List files in folder", list_files, 0}, -{"n", "num-pictures", "", "Display number of pictures", num_pictures, 0}, -{"p", "get-picture", "range", "Get pictures given in range", get_picture, 0}, -{"P", "get-all-pictures","", "Get all pictures from folder", get_all_pictures,0}, -{"t", "get-thumbnail", "range", "Get thumbnails given in range",get_thumbnail, 0}, -{"T", "get-all-thumbnails","", "Get all thumbnails from folder",get_all_thumbnails,0}, -{"d", "delete-picture", "range", "Delete pictures given in range", delete_picture, 0}, -{"D", "delete-all-pictures","", "Delete all pictures in folder",delete_all_pictures,0}, -{"u", "upload-picture", "filename", "Upload a picture to camera", upload_picture, 0}, -{"" , "capture-image", "", "Capture an image and download",capture_image, 0}, -{"" , "capture-movie", "duration", "Capture a movie and download", capture_movie, 0}, -{"" , "capture-preview","", "Capture a preview and download",capture_preview,0}, -{"", "summary", "", "Summary of camera status", summary, 0}, -{"", "manual", "", "Camera driver manual", manual, 0}, -{"", "about", "", "About the camera driver", about, 0}, -{"", "shell", "", "gPhoto shell", shell, 0}, +{"a", "abilities", "", "Display camera abilities", abilities, 0}, +{"f", "folder", "folder", "Specify camera folder (default=\"/\")",use_folder,0}, +{"R", "recurse", "", "Recursively descend through folders",recurse, 0}, +{"l", "list-folders", "", "List folders in folder", list_folders, 0}, +{"L", "list-files", "", "List files in folder", list_files, 0}, +{"n", "num-pictures", "", "Display number of pictures", num_pictures, 0}, +{"p", "get-picture", "range", "Get pictures given in range", get_picture, 0}, +{"P", "get-all-pictures","", "Get all pictures from folder", get_all_pictures,0}, +{"t", "get-thumbnail", "range", "Get thumbnails given in range",get_thumbnail, 0}, +{"T", "get-all-thumbnails","", "Get all thumbnails from folder",get_all_thumbnails,0}, +{"d", "delete-picture", "range", "Delete pictures given in range", delete_picture, 0}, +{"D", "delete-all-pictures","", "Delete all pictures in folder",delete_all_pictures,0}, +{"u", "upload-picture", "filename", "Upload a picture to camera", upload_picture, 0}, +{"" , "capture-image", "", "Capture an image and download",capture_image, 0}, +{"" , "capture-movie", "duration", "Capture a movie and download", capture_movie, 0}, +{"" , "capture-preview","", "Capture a preview and download",capture_preview,0}, +{"", "summary", "", "Summary of camera status", summary, 0}, +{"", "manual", "", "Camera driver manual", manual, 0}, +{"", "about", "", "About the camera driver", about, 0}, +{"", "shell", "", "gPhoto shell", shell, 0}, /* End of list */ {"" , "", "", "", NULL, 0} @@ -161,7 +161,7 @@ int glob_num=1; Camera *glob_camera=NULL; CameraAbilities glob_abilities; -int glob_debug=0; +extern int glob_debug; int glob_shell=0; int glob_quiet=0; int glob_filename_override=0; @@ -173,59 +173,59 @@ int glob_stdout_size=0; /* 4) Finally, add your callback function. */ /* ----------------------------------------------------------------- */ /* The callback function is passed "char *arg" to the argument of */ -/* command-line option. It must return GP_OK or GP_ERROR. */ -/* Again, use the OPTION_CALLBACK(function) macro. */ -/* glob_debug is set if the user types in the "--debug" flag. Use */ -/* cli_debug_print(char *format, ...) to display debug output. Use */ -/* cli_error_print(char *format, ...) to display error output. */ +/* command-line option. It must return GP_OK or GP_ERROR. */ +/* Again, use the OPTION_CALLBACK(function) macro. */ +/* glob_debug is set if the user types in the "--debug" flag. Use */ +/* cli_debug_print(char *format, ...) to display debug output. Use */ +/* cli_error_print(char *format, ...) to display error output. */ OPTION_CALLBACK(help) { - cli_debug_print("Displaying usage"); - - usage(); - exit(EXIT_SUCCESS); - return GP_OK; + cli_debug_print("Displaying usage"); + + usage(); + exit(EXIT_SUCCESS); + return GP_OK; } OPTION_CALLBACK(test) { - cli_debug_print("Testing gPhoto Installation"); - test_gphoto(); - exit(EXIT_SUCCESS); - return GP_OK; + cli_debug_print("Testing gPhoto Installation"); + test_gphoto(); + exit(EXIT_SUCCESS); + return GP_OK; } OPTION_CALLBACK(use_stdout) { - glob_quiet = 1; /* implied */ - glob_stdout = 1; + glob_quiet = 1; /* implied */ + glob_stdout = 1; - return GP_OK; + return GP_OK; } OPTION_CALLBACK(use_stdout_size) { - glob_stdout_size = 1; - use_stdout(arg); + glob_stdout_size = 1; + use_stdout(arg); - return GP_OK; + return GP_OK; } OPTION_CALLBACK(abilities) { - int x=0; + int x=0; - if (strlen(glob_model)==0) { - cli_error_print("Must specify a camera model using \"%scamera model\"",LONG_OPTION); - return (GP_ERROR); - } + if (strlen(glob_model)==0) { + cli_error_print("Must specify a camera model using \"%scamera model\"",LONG_OPTION); + return (GP_ERROR); + } - if (gp_camera_abilities_by_name(glob_model, &glob_abilities) != GP_OK) { - cli_error_print("Could not find camera \"%s\".\nUse \"--list-cameras\" to see available camera models", glob_model); - return (GP_ERROR); - } + if (gp_camera_abilities_by_name(glob_model, &glob_abilities) != GP_OK) { + cli_error_print("Could not find camera \"%s\".\nUse \"--list-cameras\" to see available camera models", glob_model); + return (GP_ERROR); + } /* Output a parsing friendly abilities table. Split on ":" */ @@ -269,7 +269,7 @@ OPTION_CALLBACK(list_cameras) { int x, n; char buf[64]; - cli_debug_print("Listing Cameras"); + cli_debug_print("Listing Cameras"); if ((n = gp_camera_count()) < 0) cli_error_print("Could not retrieve the number of supported cameras!"); @@ -352,15 +352,15 @@ OPTION_CALLBACK(model) { OPTION_CALLBACK(debug) { - glob_debug = 1; - cli_debug_print("Turning on debug mode"); + glob_debug = 1; + cli_debug_print("Turning on debug mode"); return (GP_OK); } OPTION_CALLBACK(quiet) { - cli_debug_print("Setting to quiet mode"); + cli_debug_print("Setting to quiet mode"); glob_quiet=1; @@ -369,283 +369,283 @@ OPTION_CALLBACK(quiet) { OPTION_CALLBACK(shell) { - cli_debug_print("Entering shell mode"); - - if (set_globals() != GP_OK) - return (GP_ERROR); - - glob_shell = 1; - - return (shell_prompt()); - -} - -OPTION_CALLBACK(use_folder) { - - cli_debug_print("Setting folder to %s", arg); - - strcpy(glob_folder, arg); - - return (GP_OK); -} - -OPTION_CALLBACK(recurse) { - - cli_debug_print("Setting recursive mode"); - - glob_recurse = 1; - - return (GP_OK); -} - -OPTION_CALLBACK(list_folders) { - - if (set_globals() != GP_OK) - return (GP_ERROR); - - if (!glob_quiet) - printf("Subfolders of \"%s\":\n", glob_folder); - - return for_each_subfolder(glob_folder, print_folder, NULL, glob_recurse); -} - -OPTION_CALLBACK(list_files) { - - if (set_globals() != GP_OK) - return (GP_ERROR); - - print_files(glob_folder, NULL, 0); - - if (!glob_recurse) - return (GP_OK); - - return for_each_subfolder(glob_folder, print_files, NULL, glob_recurse); -} - -OPTION_CALLBACK(num_pictures) { - - CameraList list; - - cli_debug_print("Counting pictures"); - - if (set_globals() != GP_OK) - return (GP_ERROR); - - if (gp_camera_file_list(glob_camera, &list, glob_folder) != GP_OK) - return (GP_ERROR); - - if (glob_quiet) - printf("%i\n", gp_list_count(&list)); - else - printf("Number of pictures in folder %s: %i\n", glob_folder, gp_list_count(&list)); - - return (GP_OK); -} - -int save_picture_to_file(char *folder, char *filename, int thumbnail) { - - char out_filename[1024], out_folder[1024], buf[1024], msg[1024]; - char *f; - int resp1, resp2; - - CameraFile *file; - - file = gp_file_new(); - - if (thumbnail) { - if (gp_camera_file_get_preview(glob_camera, file, folder, filename) != GP_OK) { - cli_error_print("Can not get preview for %s.", filename); - return (GP_ERROR); - } - } else { - if (gp_camera_file_get(glob_camera, file, folder, filename) != GP_OK) { - cli_error_print("Can not get picture %s", filename); - return (GP_ERROR); - } - } - - if (glob_stdout) { - if (glob_stdout_size) - printf("%li\n", file->size); - fwrite(file->data, sizeof(char), file->size, stdout); - gp_file_free(file); - return GP_OK; - } - - /* Determine the folder and filename */ - strcpy(out_filename, ""); - strcpy(out_folder, ""); - - if (glob_filename_override) { - if (strchr(glob_filename, '/')) { /* Check if they specified an output dir */ - f = strrchr(glob_filename, '/'); - strcpy(buf, f+1); /* Get the filename */ - sprintf(out_filename, buf, glob_num++); - *f = 0; - strcpy(out_folder, glob_filename); /* Get the folder */ - strcat(out_folder, "/"); - *f = '/'; - } else { /* If not, subst and set */ - sprintf(out_filename, glob_filename, glob_num++); - } - } else { - strcat(out_filename, filename); - } - - if (thumbnail) - sprintf(buf, "%sthumb_%s", out_folder, out_filename); - else - sprintf(buf, "%s%s", out_folder, out_filename); - - if (!glob_quiet) { - while (GPIO_IS_FILE(buf)) { - sprintf(msg, "File %s exists. Overwrite?", buf); - resp1 = gp_frontend_confirm(glob_camera, msg); - if ((resp1==GP_CONFIRM_NO)||(resp1==GP_CONFIRM_NOTOALL)) { - resp2 = gp_frontend_confirm(glob_camera, "Specify new filename?"); - if ((resp2==GP_CONFIRM_NO)||(resp2==GP_CONFIRM_NOTOALL)) { - gp_file_free(file); - return (GP_OK); - } - printf("Enter new filename: "); - fflush(stdout); - fgets(buf, 1023, stdin); - buf[strlen(buf)-1]=0; - } else { - break; - } - } - printf("Saving %s as %s\n", thumbnail ? "preview" : "image", buf); - } - if (gp_file_save(file, buf) != GP_OK) - cli_error_print("Can not save %s as %s", thumbnail ? "preview" : "image", buf); - - gp_file_free(file); - - return (GP_OK); -} - -/* - get_picture_common() - parse range, download specified images, or their - thumbnails according to thumbnail argument, and save to files. -*/ - -int get_picture_common(char *arg, int thumbnail) { - - if (thumbnail) - cli_debug_print("Getting thumbnail(s) %s", arg); - else - cli_debug_print("Getting picture(s) %s", arg); - - if (set_globals() != GP_OK) - return (GP_ERROR); - - if (thumbnail && !glob_abilities.file_preview) { - cli_error_print("Camera doesn't support picture thumbnails"); - return (GP_ERROR); - } - - if (strchr(arg, '.')) { - save_picture_to_file(glob_folder, arg, thumbnail); - return (GP_OK); - } - - if (thumbnail) - return for_each_image_in_range(glob_folder, arg, save_thumbnail_action, 0); - else - return for_each_image_in_range(glob_folder, arg, save_picture_action, 0); -} - -OPTION_CALLBACK(get_picture) { - - return get_picture_common(arg, 0); -} - -OPTION_CALLBACK(get_all_pictures) { - - cli_debug_print("Getting all pictures"); - - if (set_globals() != GP_OK) - return (GP_ERROR); - - return for_each_image(glob_folder, save_picture_action, 0); -} - -OPTION_CALLBACK(get_thumbnail) { - - return (get_picture_common(arg, 1)); -} - -OPTION_CALLBACK(get_all_thumbnails) { - - cli_debug_print("Getting all thumbnails"); - - if (set_globals() != GP_OK) - return (GP_ERROR); - - if (!glob_abilities.file_preview) { - cli_error_print("Camera doesn't support picture thumbnails"); - return (GP_ERROR); - } - - return for_each_image(glob_folder, save_thumbnail_action, 0); -} - -OPTION_CALLBACK(delete_picture) { - - cli_debug_print("Deleting picture(s) %s", arg); - - if (set_globals() != GP_OK) - return (GP_ERROR); - - if (!glob_abilities.file_delete) { - cli_error_print("Camera can not delete pictures"); - return (GP_ERROR); - } - - return for_each_image_in_range(glob_folder, arg, delete_picture_action, 1); -} - -OPTION_CALLBACK(delete_all_pictures) { - - cli_debug_print("Deleting all pictures"); - - if (set_globals() != GP_OK) - return (GP_ERROR); - - if (!glob_abilities.file_delete) { - cli_error_print("Camera can not delete pictures"); - return (GP_ERROR); - } - - return for_each_image(glob_folder, delete_picture_action, 1); -} - -OPTION_CALLBACK(upload_picture) { - - CameraFile *file; - - file = gp_file_new(); - - cli_debug_print("Uploading picture"); + cli_debug_print("Entering shell mode"); if (set_globals() != GP_OK) return (GP_ERROR); - if (!glob_abilities.file_put) { - cli_error_print("Camera doesn't support uploading pictures"); - return (GP_ERROR); - } + glob_shell = 1; - if (gp_file_open(file, arg) != GP_OK) { - cli_error_print("Could not open file %s", arg); - return (GP_ERROR); - } - - if (gp_camera_file_put(glob_camera, file, glob_folder) != GP_OK) { - cli_error_print("Could not upload the picture"); - return (GP_ERROR); - } + return (shell_prompt()); + +} + +OPTION_CALLBACK(use_folder) { + + cli_debug_print("Setting folder to %s", arg); + + strcpy(glob_folder, arg); + + return (GP_OK); +} + +OPTION_CALLBACK(recurse) { + + cli_debug_print("Setting recursive mode"); + + glob_recurse = 1; + + return (GP_OK); +} + +OPTION_CALLBACK(list_folders) { + + if (set_globals() != GP_OK) + return (GP_ERROR); + + if (!glob_quiet) + printf("Subfolders of \"%s\":\n", glob_folder); + + return for_each_subfolder(glob_folder, print_folder, NULL, glob_recurse); +} + +OPTION_CALLBACK(list_files) { + + if (set_globals() != GP_OK) + return (GP_ERROR); + + print_files(glob_folder, NULL, 0); + + if (!glob_recurse) + return (GP_OK); + + return for_each_subfolder(glob_folder, print_files, NULL, glob_recurse); +} + +OPTION_CALLBACK(num_pictures) { + + CameraList list; + + cli_debug_print("Counting pictures"); + + if (set_globals() != GP_OK) + return (GP_ERROR); + + if (gp_camera_file_list(glob_camera, &list, glob_folder) != GP_OK) + return (GP_ERROR); + + if (glob_quiet) + printf("%i\n", gp_list_count(&list)); + else + printf("Number of pictures in folder %s: %i\n", glob_folder, gp_list_count(&list)); + + return (GP_OK); +} + +int save_picture_to_file(char *folder, char *filename, int thumbnail) { + + char out_filename[1024], out_folder[1024], buf[1024], msg[1024]; + char *f; + int resp1, resp2; + + CameraFile *file; + + file = gp_file_new(); + + if (thumbnail) { + if (gp_camera_file_get_preview(glob_camera, file, folder, filename) != GP_OK) { + cli_error_print("Can not get preview for %s.", filename); + return (GP_ERROR); + } + } else { + if (gp_camera_file_get(glob_camera, file, folder, filename) != GP_OK) { + cli_error_print("Can not get picture %s", filename); + return (GP_ERROR); + } + } + + if (glob_stdout) { + if (glob_stdout_size) + printf("%li\n", file->size); + fwrite(file->data, sizeof(char), file->size, stdout); + gp_file_free(file); + return GP_OK; + } + + /* Determine the folder and filename */ + strcpy(out_filename, ""); + strcpy(out_folder, ""); + + if (glob_filename_override) { + if (strchr(glob_filename, '/')) { /* Check if they specified an output dir */ + f = strrchr(glob_filename, '/'); + strcpy(buf, f+1); /* Get the filename */ + sprintf(out_filename, buf, glob_num++); + *f = 0; + strcpy(out_folder, glob_filename); /* Get the folder */ + strcat(out_folder, "/"); + *f = '/'; + } else { /* If not, subst and set */ + sprintf(out_filename, glob_filename, glob_num++); + } + } else { + strcat(out_filename, filename); + } + + if (thumbnail) + sprintf(buf, "%sthumb_%s", out_folder, out_filename); + else + sprintf(buf, "%s%s", out_folder, out_filename); + + if (!glob_quiet) { + while (GPIO_IS_FILE(buf)) { + sprintf(msg, "File %s exists. Overwrite?", buf); + resp1 = gp_frontend_confirm(glob_camera, msg); + if ((resp1==GP_CONFIRM_NO)||(resp1==GP_CONFIRM_NOTOALL)) { + resp2 = gp_frontend_confirm(glob_camera, "Specify new filename?"); + if ((resp2==GP_CONFIRM_NO)||(resp2==GP_CONFIRM_NOTOALL)) { + gp_file_free(file); + return (GP_OK); + } + printf("Enter new filename: "); + fflush(stdout); + fgets(buf, 1023, stdin); + buf[strlen(buf)-1]=0; + } else { + break; + } + } + printf("Saving %s as %s\n", thumbnail ? "preview" : "image", buf); + } + if (gp_file_save(file, buf) != GP_OK) + cli_error_print("Can not save %s as %s", thumbnail ? "preview" : "image", buf); + + gp_file_free(file); + + return (GP_OK); +} + +/* + get_picture_common() - parse range, download specified images, or their + thumbnails according to thumbnail argument, and save to files. +*/ + +int get_picture_common(char *arg, int thumbnail) { + + if (thumbnail) + cli_debug_print("Getting thumbnail(s) %s", arg); + else + cli_debug_print("Getting picture(s) %s", arg); + + if (set_globals() != GP_OK) + return (GP_ERROR); + + if (thumbnail && !glob_abilities.file_preview) { + cli_error_print("Camera doesn't support picture thumbnails"); + return (GP_ERROR); + } + + if (strchr(arg, '.')) { + save_picture_to_file(glob_folder, arg, thumbnail); + return (GP_OK); + } + + if (thumbnail) + return for_each_image_in_range(glob_folder, arg, save_thumbnail_action, 0); + else + return for_each_image_in_range(glob_folder, arg, save_picture_action, 0); +} + +OPTION_CALLBACK(get_picture) { + + return get_picture_common(arg, 0); +} + +OPTION_CALLBACK(get_all_pictures) { + + cli_debug_print("Getting all pictures"); + + if (set_globals() != GP_OK) + return (GP_ERROR); + + return for_each_image(glob_folder, save_picture_action, 0); +} + +OPTION_CALLBACK(get_thumbnail) { + + return (get_picture_common(arg, 1)); +} + +OPTION_CALLBACK(get_all_thumbnails) { + + cli_debug_print("Getting all thumbnails"); + + if (set_globals() != GP_OK) + return (GP_ERROR); + + if (!glob_abilities.file_preview) { + cli_error_print("Camera doesn't support picture thumbnails"); + return (GP_ERROR); + } + + return for_each_image(glob_folder, save_thumbnail_action, 0); +} + +OPTION_CALLBACK(delete_picture) { + + cli_debug_print("Deleting picture(s) %s", arg); + + if (set_globals() != GP_OK) + return (GP_ERROR); + + if (!glob_abilities.file_delete) { + cli_error_print("Camera can not delete pictures"); + return (GP_ERROR); + } + + return for_each_image_in_range(glob_folder, arg, delete_picture_action, 1); +} + +OPTION_CALLBACK(delete_all_pictures) { + + cli_debug_print("Deleting all pictures"); + + if (set_globals() != GP_OK) + return (GP_ERROR); + + if (!glob_abilities.file_delete) { + cli_error_print("Camera can not delete pictures"); + return (GP_ERROR); + } + + return for_each_image(glob_folder, delete_picture_action, 1); +} + +OPTION_CALLBACK(upload_picture) { + + CameraFile *file; + + file = gp_file_new(); + + cli_debug_print("Uploading picture"); + + if (set_globals() != GP_OK) + return (GP_ERROR); + + if (!glob_abilities.file_put) { + cli_error_print("Camera doesn't support uploading pictures"); + return (GP_ERROR); + } + + if (gp_file_open(file, arg) != GP_OK) { + cli_error_print("Could not open file %s", arg); + return (GP_ERROR); + } + + if (gp_camera_file_put(glob_camera, file, glob_folder) != GP_OK) { + cli_error_print("Could not upload the picture"); + return (GP_ERROR); + } gp_file_free(file); @@ -654,58 +654,58 @@ OPTION_CALLBACK(upload_picture) { int capture_generic (int type, int duration) { - CameraCaptureInfo info; - CameraFile *file; - char out_filename[1024]; + CameraCaptureInfo info; + CameraFile *file; + char out_filename[1024]; if (set_globals() != GP_OK) return (GP_ERROR); - info.type = type; - info.duration = duration; + info.type = type; + info.duration = duration; - file = gp_file_new(); + file = gp_file_new(); if (gp_camera_capture(glob_camera, file, &info) != GP_OK) { cli_error_print("Could not capture."); return (GP_ERROR); } - if ((glob_filename_override)&&(strlen(glob_filename)>0)) - strcpy(out_filename, glob_filename); - else { - if (strlen(file->name) == 0) { - printf("Could not determine filename.\nRename to approprite filename and extension.\n"); - strcpy(out_filename, "capture.dat"); - } else { - strcpy(out_filename, file->name); - } - } + if ((glob_filename_override)&&(strlen(glob_filename)>0)) + strcpy(out_filename, glob_filename); + else { + if (strlen(file->name) == 0) { + printf("Could not determine filename.\nRename to approprite filename and extension.\n"); + strcpy(out_filename, "capture.dat"); + } else { + strcpy(out_filename, file->name); + } + } - if (!glob_quiet) - printf("Saving capture as %s\n", out_filename); - if (gp_file_save(file, out_filename) != GP_OK) - cli_error_print("Can not save capture as %s.\nSpecify a different filename using \"--filename\"\n", out_filename); + if (!glob_quiet) + printf("Saving capture as %s\n", out_filename); + if (gp_file_save(file, out_filename) != GP_OK) + cli_error_print("Can not save capture as %s.\nSpecify a different filename using \"--filename\"\n", out_filename); - gp_file_free(file); + gp_file_free(file); - return (GP_OK); + return (GP_OK); } OPTION_CALLBACK(capture_image) { - return (capture_generic(GP_CAPTURE_IMAGE, 0)); + return (capture_generic(GP_CAPTURE_IMAGE, 0)); } OPTION_CALLBACK(capture_movie) { - return (capture_generic(GP_CAPTURE_VIDEO, atoi(arg))); + return (capture_generic(GP_CAPTURE_VIDEO, atoi(arg))); } OPTION_CALLBACK(capture_preview) { - return (capture_generic(GP_CAPTURE_PREVIEW, 0)); + return (capture_generic(GP_CAPTURE_PREVIEW, 0)); } OPTION_CALLBACK(summary) { @@ -750,119 +750,119 @@ OPTION_CALLBACK(about) { if (set_globals() != GP_OK) return (GP_ERROR); - if (gp_camera_about(glob_camera, &buf) != GP_OK) { - cli_error_print("Could not get camera driver information"); - return (GP_ERROR); - } - printf("About the library:\n%s\n", buf.text); + if (gp_camera_about(glob_camera, &buf) != GP_OK) { + cli_error_print("Could not get camera driver information"); + return (GP_ERROR); + } + printf("About the library:\n%s\n", buf.text); return (GP_OK); } -/* Set/init global variables */ +/* Set/init global variables */ /* ------------------------------------------------------------ */ int set_globals () { - /* takes all the settings and sets up the gphoto lib */ - CameraPortInfo s; + /* takes all the settings and sets up the gphoto lib */ + CameraPortInfo s; - if (strlen(glob_model) == 0) { - cli_error_print("Must specify a camera model using \"%scamera model\"",LONG_OPTION); - return (GP_ERROR); - } + if (strlen(glob_model) == 0) { + cli_error_print("Must specify a camera model using \"%scamera model\"",LONG_OPTION); + return (GP_ERROR); + } - if ((strlen(glob_port) == 0)&&(strcmp(glob_model, "Directory Browse")!=0)) { - cli_error_print("Must specify a camera port using \"%sport path\"",LONG_OPTION); - return (GP_ERROR); - } + if ((strlen(glob_port) == 0)&&(strcmp(glob_model, "Directory Browse")!=0)) { + cli_error_print("Must specify a camera port using \"%sport path\"",LONG_OPTION); + return (GP_ERROR); + } - strcpy(s.path, glob_port); - s.speed = glob_speed; + strcpy(s.path, glob_port); + s.speed = glob_speed; - if (gp_camera_abilities_by_name(glob_model, &glob_abilities) != GP_OK) { - cli_error_print("Could not find camera \"%s\".\nUse \"--list-cameras\" to see available camera models", glob_model); - return (GP_ERROR); - } + if (gp_camera_abilities_by_name(glob_model, &glob_abilities) != GP_OK) { + cli_error_print("Could not find camera \"%s\".\nUse \"--list-cameras\" to see available camera models", glob_model); + return (GP_ERROR); + } - if (gp_camera_new_by_name(&glob_camera, glob_model) != GP_OK) { - cli_error_print("Can not create camera data \"%s\"",glob_model); - return (GP_ERROR); - } + if (gp_camera_new_by_name(&glob_camera, glob_model) != GP_OK) { + cli_error_print("Can not create camera data \"%s\"",glob_model); + return (GP_ERROR); + } - if (gp_camera_init(glob_camera, &s) != GP_OK) { - cli_error_print("Can not initialize the camera \"%s\"",glob_model); - return (GP_ERROR); - } + if (gp_camera_init(glob_camera, &s) != GP_OK) { + cli_error_print("Can not initialize the camera \"%s\"",glob_model); + return (GP_ERROR); + } return (GP_OK); } int init_globals () { - glob_option_count = 0; + glob_option_count = 0; - strcpy(glob_model, ""); - strcpy(glob_port, ""); - strcpy(glob_filename, "gphoto"); - strcpy(glob_folder, "/"); - if (!getcwd(glob_owd, 1023)) - strcpy(glob_owd, "./"); - strcpy(glob_cwd, glob_owd); + strcpy(glob_model, ""); + strcpy(glob_port, ""); + strcpy(glob_filename, "gphoto"); + strcpy(glob_folder, "/"); + if (!getcwd(glob_owd, 1023)) + strcpy(glob_owd, "./"); + strcpy(glob_cwd, glob_owd); - glob_camera = NULL; - glob_speed = 0; - glob_debug = 0; - glob_quiet = 0; - glob_filename_override = 0; - glob_recurse = 0; - return GP_OK; + glob_camera = NULL; + glob_speed = 0; + glob_debug = 0; + glob_quiet = 0; + glob_filename_override = 0; + glob_recurse = 0; + return GP_OK; } -/* Misc functions */ -/* ------------------------------------------------------------------ */ +/* Misc functions */ +/* ------------------------------------------------------------------ */ void cli_debug_print(char *format, ...) { - va_list pvar; - - if (glob_debug) { - fprintf(stderr, "cli: "); - va_start(pvar, format); - vfprintf(stderr, format, pvar); - va_end(pvar); - fprintf(stderr, "\n"); - } + va_list pvar; + + if (glob_debug) { + fprintf(stderr, "cli: "); + va_start(pvar, format); + vfprintf(stderr, format, pvar); + va_end(pvar); + fprintf(stderr, "\n"); + } } void cli_error_print(char *format, ...) { - va_list pvar; + va_list pvar; - fprintf(stderr, "ERROR: "); - va_start(pvar, format); - vfprintf(stderr, format, pvar); - va_end(pvar); - fprintf(stderr, "\n"); + fprintf(stderr, "ERROR: "); + va_start(pvar, format); + vfprintf(stderr, format, pvar); + va_end(pvar); + fprintf(stderr, "\n"); } void signal_exit (int signo) { - if (!glob_quiet) - printf("\nExiting gPhoto...\n"); + if (!glob_quiet) + printf("\nExiting gPhoto...\n"); /* Exit gPhoto core */ - if (glob_camera) + if (glob_camera) gp_camera_free(glob_camera); gp_exit(); - if (strlen(glob_owd)>0) - chdir(glob_owd); + if (strlen(glob_owd)>0) + chdir(glob_owd); + + exit(EXIT_SUCCESS); - exit(EXIT_SUCCESS); - } -/* Main :) */ +/* Main :) */ /* -------------------------------------------------------------------- */ int main (int argc, char **argv) { @@ -870,7 +870,7 @@ int main (int argc, char **argv) { /* Initialize the globals */ init_globals(); - signal(SIGINT, signal_exit); + signal(SIGINT, signal_exit); /* Count the number of command-line options we have */ while ((strlen(option[glob_option_count].short_id)>0) || @@ -896,6 +896,16 @@ e.g. SET CAMLIBS=C:\\GPHOTO2\\CAM\n"); } #endif +#ifdef OS2 /*check if environment is set otherwise quit*/ + if(IOLIBS==NULL) + { +printf("gPhoto2 for OS/2 requires you to set the enviroment value IOLIBS \ +to the location of the io libraries. \ +e.g. SET IOLIBS=C:\\GPHOTO2\\IOLIB\n"); + exit(EXIT_FAILURE); + } +#endif + /* Peek ahead: Make sure we were called correctly */ if ((argc == 1)||(verify_options(argc, argv) != GP_OK)) { if (!glob_quiet) @@ -905,8 +915,8 @@ e.g. SET CAMLIBS=C:\\GPHOTO2\\CAM\n"); /* Initialize gPhoto core */ gp_init(glob_debug? GP_DEBUG_HIGH: GP_DEBUG_NONE); - gp_frontend_register(gp_interface_status, gp_interface_progress, - gp_interface_message, gp_interface_confirm, NULL); + gp_frontend_register(gp_interface_status, gp_interface_progress, + gp_interface_message, gp_interface_confirm, NULL); if (execute_options(argc, argv) != GP_OK) { // if (!glob_quiet) // usage(); @@ -914,9 +924,9 @@ e.g. SET CAMLIBS=C:\\GPHOTO2\\CAM\n"); } /* Exit gPhoto core */ - if (glob_camera) + if (glob_camera) gp_camera_free(glob_camera); gp_exit(); - return (EXIT_SUCCESS); + return (EXIT_SUCCESS); } diff --git a/frontends/command-line/makefile.os2 b/frontends/command-line/makefile.os2 index a15e6d6b2..8783eaef5 100644 --- a/frontends/command-line/makefile.os2 +++ b/frontends/command-line/makefile.os2 @@ -26,5 +26,20 @@ cmdline: ..\..\gphoto2.exe ..\..\obj\test.o: test.c @$(CC) -o $@ $** $(CCFLAGS) -..\..\gphoto2.exe: ..\..\obj\interface.o ..\..\obj\script.o ..\..\obj\main.o ..\..\obj\test.o ..\..\lib\libgphoto2.a ..\..\lib\libgpio.a - @$(CC) -O2 $** -o $@ -Zbin-files -Zcrtdll -Zmtd -s -L..\..\lib -llibgphoto2 -llibgpio -ldl -lpthreads -lpthrdrtl +..\..\obj\shell.o: shell.c + @$(CC) -o $@ $** $(CCFLAGS) + +..\..\obj\range.o: range.c + @$(CC) -o $@ $** $(CCFLAGS) + +..\..\obj\actions.o: actions.c + @$(CC) -o $@ $** $(CCFLAGS) + +..\..\obj\options.o: options.c + @$(CC) -o $@ $** $(CCFLAGS) + +..\..\obj\foreach.o: foreach.c + @$(CC) -o $@ $** $(CCFLAGS) + +..\..\gphoto2.exe: ..\..\obj\interface.o ..\..\obj\script.o ..\..\obj\main.o ..\..\obj\test.o ..\..\lib\libgphoto2.a ..\..\lib\libgpio.a ..\..\obj\actions.o ..\..\obj\shell.o ..\..\obj\foreach.o ..\..\obj\options.o ..\..\obj\range.o + @$(CC) -O2 $** -o $@ -Zbin-files -Zcrtdll -Zmtd -s -L..\..\lib -llibgphoto2 -llibgpio -ldllib -lmt\emx