diff --git a/camlibs/directory/makefile.os2 b/camlibs/directory/makefile.os2 index 85da26743..e00c36f8b 100644 --- a/camlibs/directory/makefile.os2 +++ b/camlibs/directory/makefile.os2 @@ -1,10 +1,10 @@ -CCFLAGS=-O2 -c -I.. -I..\..\include -Zmtd -Zcrtdll -Zbin-files -D__ST_MT_ERRNO_ -I. -DOS2 -DHAVE_TERMIOS_H +CCFLAGS=-O2 -c -I.. -I..\..\include -I..\..\libgpio -Zmtd -Zcrtdll -Zbin-files -D__ST_MT_ERRNO_ -I. -DOS2 -DHAVE_TERMIOS_H CC=gcc all: ..\gpdirbrw.dll ..\..\obj\directory.o : directory.c directory.h - $(CC) -o $@ directory.c + $(CC) -o $@ directory.c $(CCFLAGS) ..\gpdirbrw.dll: ..\..\obj\directory.o $(CC) -g -Wall -Zdll -Zcrtdll -o $@ $** directory.def -lwrap -Le:\emx\lib -lst\check -lgcc -LE:\NETLABS\GNOME\GPHOTO2\LIB -llibgphoto2 -llibgpio -ldl E:\NETLABS\GNOME\GPHOTO2\obj\interface.o -lpthreads -lpthrdrtl -lmt\c diff --git a/frontends/command-line/main.c b/frontends/command-line/main.c index c71c74030..261991495 100644 --- a/frontends/command-line/main.c +++ b/frontends/command-line/main.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include #ifdef HAVE_CONFIG_H #include "config.h" @@ -30,29 +30,29 @@ int set_globals(); /* Command-line option ----------------------------------------------------------------------- - this is funky and may look a little scary, but sounded cool to do. - it makes sense since this is just a wrapper for a functional/flow-based + this is funky and may look a little scary, but sounded cool to do. + it makes sense since this is just a wrapper for a functional/flow-based library. AFTER NOTE: whoah. gnome does something like this. cool deal :) When the program starts it calls (in order): - 1) verify_options() to make sure all options are valid, - and that any options needing an argument have one (or if they - need an argument, they don't have one). - 2) (optional) option_is_present() to see if a particular option was - typed in the command-line. This can be used to set up something - before the next step. - 3) execute_options() to actually parse the command-line and execute - the command-line options in order. + 1) verify_options() to make sure all options are valid, + and that any options needing an argument have one (or if they + need an argument, they don't have one). + 2) (optional) option_is_present() to see if a particular option was + typed in the command-line. This can be used to set up something + before the next step. + 3) execute_options() to actually parse the command-line and execute + the command-line options in order. This might sound a little complex, but makes adding options REALLY easy, and it is very flexible. How to add a command-line option: -/* 1) Add a forward-declaration here */ +/* 1) Add a forward-declaration here */ /* ----------------------------------------------------------------- */ -/* Use the OPTION_CALLBACK(function) macro. */ +/* Use the OPTION_CALLBACK(function) macro. */ OPTION_CALLBACK(abilities); OPTION_CALLBACK(help); @@ -77,53 +77,55 @@ OPTION_CALLBACK(summary); OPTION_CALLBACK(manual); OPTION_CALLBACK(about); -/* 2) Add an entry in the option table */ +/* 2) Add an entry in the option table */ /* ----------------------------------------------------------------- */ -/* Format for option is: */ +/* Format for option is: */ /* {"short", "long", "argument", "description", callback_function, required}, */ -/* if it is just a flag, set the argument to "". */ +/* if it is just a flag, set the argument to "". */ /* Order is important! Options are exec'd in the order in the table! */ Option option[] = { /* Settings needed for formatting output */ -{"", "debug", "", "Turn on debugging", debug, 0}, -{"q", "quiet", "", "Quiet output (default=verbose)",quiet, 0}, +{"", "debug", "", "Turn on debugging", debug, 0}, +{"q", "quiet", "", "Quiet output (default=verbose)",quiet, 0}, /* Display and die actions */ -{"h", "help", "", "Displays this help screen", help, 0}, -{"", "verify", "", "Verifies gPhoto installation", test, 0}, -{"D", "daemon", "", "gPhoto daemon (stdin/stdout)", daemonmode, 0}, -{"", "list-cameras", "", "List supported camera models", list_cameras, 0}, -{"", "list-ports", "", "List supported port devices", list_ports, 0}, + +{"h", "help", "", "Displays this help screen", help, 0}, +{"", "verify", "", "Verifies gPhoto installation", test, 0}, +{"D", "daemon", "", "gPhoto daemon (stdin/stdout)", daemonmode, 0}, +{"", "list-cameras", "", "List supported camera models", list_cameras, 0}, +{"", "list-ports", "", "List supported port devices", list_ports, 0}, + /* Settings needed for camera functions */ -{"" , "port", "path", "Specify port device", port, 0}, -{"" , "speed", "speed", "Specify serial transfer speed",speed, 0}, -{"" , "camera", "model", "Specify camera model", model, 0}, -{"" , "filename", "filename", "Specify a filename", filename, 0}, +{"" , "port", "path", "Specify port device", port, 0}, +{"" , "speed", "speed", "Specify serial transfer speed",speed, 0}, +{"" , "camera", "model", "Specify camera model", model, 0}, +{"" , "filename", "filename", "Specify a filename", filename, 0}, /* Actions that depend on settings */ -{"", "list-folders", "", "List all folders on the camera",list_folders, 0}, -{"a", "abilities", "", "Display camera abilities", abilities, 0}, -{"f", "folder", "folder", "Specify camera folder (default=\"/\")",use_folder,0}, -{"n", "num-pictures", "", "Display number of pictures", num_pictures, 0}, -{"p", "get-picture", "#", "Get picture # from camera", get_picture, 0}, -{"t", "get-thumbnail", "#", "Get thumbnail # from camera", get_thumbnail, 0}, -{"d", "delete-picture", "#", "Delete picture # from camera", delete_picture, 0}, -{"u", "upload-picture", "filename", "Upload a picture to camera", upload_picture, 0}, -{"", "summary", "", "Summary of camera status", summary, 0}, -{"", "manual", "", "Camera driver manual", manual, 0}, -{"", "about", "", "About the camera driver", about, 0}, +{"", "list-folders", "", "List all folders on the camera",list_folders, 0}, +{"a", "abilities", "", "Display camera abilities", abilities, 0}, +{"f", "folder", "folder", "Specify camera folder (default=\"/\")",use_folder,0}, +{"n", "num-pictures", "", "Display number of pictures", num_pictures, 0}, +{"p", "get-picture", "#", "Get picture # from camera", get_picture, 0}, +{"t", "get-thumbnail", "#", "Get thumbnail # from camera", get_thumbnail, 0}, +{"d", "delete-picture", "#", "Delete picture # from camera", delete_picture, 0}, +{"u", "upload-picture", "filename", "Upload a picture to camera", upload_picture, 0}, +{"", "summary", "", "Summary of camera status", summary, 0}, +{"", "manual", "", "Camera driver manual", manual, 0}, +{"", "about", "", "About the camera driver", about, 0}, -/* End of list */ -{"" , "", "", "", NULL, 0} +/* End of list */ +{"" , "", "", "", NULL, 0} }; -/* 3) Add any necessary global variables */ +/* 3) Add any necessary global variables */ /* ----------------------------------------------------------------- */ /* Most flags will set options, like choosing a port, camera model, */ -/* etc... */ +/* etc... */ int option_count; /* total number of command-line options */ @@ -140,53 +142,53 @@ int glob_quiet=0; int glob_filename_override=0; char glob_filename[128]; -/* 4) Finally, add your callback function. */ +/* 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. */ +/* 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 "-d/--debug" flag. Use */ /* debug_print(char *message, char *arg) to display debug output.Use */ -/* error_print(char *message) to display error output. */ +/* error_print(char *message) to display error output. */ OPTION_CALLBACK(help) { - debug_print("Displaying usage", ""); - - usage(); - exit(EXIT_SUCCESS); + debug_print("Displaying usage", ""); + + usage(); + exit(EXIT_SUCCESS); } OPTION_CALLBACK(test) { - debug_print("Testing gPhoto Installation", ""); + debug_print("Testing gPhoto Installation", ""); - test_gphoto(); - exit(EXIT_SUCCESS); + test_gphoto(); + exit(EXIT_SUCCESS); } OPTION_CALLBACK(abilities) { - int x=0; - char buf[32], msg[1024]; + int x=0; + char buf[32], msg[1024]; - if (strlen(glob_model)==0) { - sprintf(msg, "Must specify a camera model using \"%scamera model\"",LONG_OPTION); - error_print(msg); - return (GP_ERROR); - } + if (strlen(glob_model)==0) { + sprintf(msg, "Must specify a camera model using \"%scamera model\"",LONG_OPTION); + error_print(msg); + return (GP_ERROR); + } - if (gp_camera_abilities_by_name(glob_model, &glob_abilities)==GP_ERROR) { - sprintf(msg, "Could not find camera \"%s\".\nUse \"--list-cameras\" to see available camera models", glob_model); - error_print(msg); - return (GP_ERROR); - } + if (gp_camera_abilities_by_name(glob_model, &glob_abilities)==GP_ERROR) { + sprintf(msg, "Could not find camera \"%s\".\nUse \"--list-cameras\" to see available camera models", glob_model); + error_print(msg); + return (GP_ERROR); + } - /* Output a parsing friendly abilities table. Split on ":" */ + /* Output a parsing friendly abilities table. Split on ":" */ - printf("Abilities for camera: : %s\n", - glob_abilities.model); + printf("Abilities for camera: : %s\n", + glob_abilities.model); printf("Serial port support : %s\n", SERIAL_SUPPORTED(glob_abilities.port)? "yes":"no"); printf("Parallel port support : %s\n", @@ -198,719 +200,731 @@ OPTION_CALLBACK(abilities) { printf("Network support : %s\n", NETWORK_SUPPORTED(glob_abilities.port)? "yes":"no"); - if (glob_abilities.speed[0] != 0) { - printf("Transfer speeds supported :\n"); - do { - printf(" : %i\n", glob_abilities.speed[x]); - x++; - } while (glob_abilities.speed[x]!=0); - } - printf("Capture from computer support : %s\n", - glob_abilities.capture == 0? "no":"yes"); - printf("Configuration support : %s\n", - glob_abilities.config == 0? "no":"yes"); - printf("Delete files on camera support : %s\n", - glob_abilities.file_delete == 0? "no":"yes"); - printf("File preview (thumbnail) support : %s\n", - glob_abilities.file_preview == 0? "no":"yes"); - printf("File upload support : %s\n", - glob_abilities.file_put == 0? "no":"yes"); + if (glob_abilities.speed[0] != 0) { + printf("Transfer speeds supported :\n"); + do { + printf(" : %i\n", glob_abilities.speed[x]); + x++; + } while (glob_abilities.speed[x]!=0); + } + printf("Capture from computer support : %s\n", + glob_abilities.capture == 0? "no":"yes"); + printf("Configuration support : %s\n", + glob_abilities.config == 0? "no":"yes"); + printf("Delete files on camera support : %s\n", + glob_abilities.file_delete == 0? "no":"yes"); + printf("File preview (thumbnail) support : %s\n", + glob_abilities.file_preview == 0? "no":"yes"); + printf("File upload support : %s\n", + glob_abilities.file_put == 0? "no":"yes"); - return (GP_OK); + return (GP_OK); } OPTION_CALLBACK(list_cameras) { - int x, n; - char buf[64]; + int x, n; + char buf[64]; - debug_print("Listing Cameras", ""); + debug_print("Listing Cameras", ""); - if ((n = gp_camera_count())==GP_ERROR) - error_print("Could not retrieve the number of supported cameras!"); - if (glob_quiet) - printf("%i\n", n); - else - printf("Number of supported cameras: %i\nSupported cameras:\n", n); + if ((n = gp_camera_count())==GP_ERROR) + error_print("Could not retrieve the number of supported cameras!"); + if (glob_quiet) + printf("%i\n", n); + else + printf("Number of supported cameras: %i\nSupported cameras:\n", n); - for (x=0; x", path)==0) - return; + if (strcmp("", path)==0) + return; - count = gp_folder_list(path, fl); - while (x")!=0) { - if (strcmp(path, "/")==0) - sprintf(buf, "/%s", fl[x].name); - else - sprintf(buf, "%s/%s", path, fl[x].name); - printf("%s\n", buf); - list_folders_rec(buf); - } else { -// printf("%s has files!\n", path); - } - x++; - } + count = gp_folder_list(path, fl); + while (x")!=0) { + if (strcmp(path, "/")==0) + sprintf(buf, "/%s", fl[x].name); + else + sprintf(buf, "%s/%s", path, fl[x].name); + printf("%s\n", buf); + list_folders_rec(buf); + } else { +// printf("%s has files!\n", path); + } + x++; + } - return; + return; } OPTION_CALLBACK(list_folders) { - int count; + int count; - if (set_globals() == GP_ERROR) - return (GP_ERROR); - if (!glob_quiet) - printf("Folders on camera:\n"); - printf("/\n"); + if (set_globals() == GP_ERROR) + return (GP_ERROR); + if (!glob_quiet) + printf("Folders on camera:\n"); + printf("/\n"); - list_folders_rec("/"); + list_folders_rec("/"); - return (GP_OK); + return (GP_OK); } OPTION_CALLBACK(use_folder) { - debug_print("Setting folder to %s", arg); + debug_print("Setting folder to %s", arg); - strcpy(glob_folder, arg); + strcpy(glob_folder, arg); - return (GP_OK); + return (GP_OK); } OPTION_CALLBACK(num_pictures) { - int count; + int count; - debug_print("Counting pictures", ""); + debug_print("Counting pictures", ""); - if (set_globals() == GP_ERROR) - return (GP_ERROR); + if (set_globals() == GP_ERROR) + return (GP_ERROR); - count = gp_file_count(); - - if (count == GP_ERROR) { - error_print("Could not get number of pictures on camera"); - return (GP_ERROR); - } + count = gp_file_count(); - if (glob_quiet) - printf("%i\n", count); - else - printf("Number of pictures in folder %s: %i\n", glob_folder, count); + if (count == GP_ERROR) { + error_print("Could not get number of pictures on camera"); + return (GP_ERROR); + } - return (GP_OK); + if (glob_quiet) + printf("%i\n", count); + else + printf("Number of pictures in folder %s: %i\n", glob_folder, count); + + return (GP_OK); } int get_picture_common(int num, int thumbnail) { - CameraFile *f; - int count=0; - char filename[1024], msg[1024]; - char *slash; + CameraFile *f; + int count=0; + char filename[1024], msg[1024]; + char *slash; - if (thumbnail) - debug_print("Getting thumbnail", ""); - else - debug_print("Getting picture", ""); + if (thumbnail) + debug_print("Getting thumbnail", ""); + else + debug_print("Getting picture", ""); - if (set_globals() == GP_ERROR) - return (GP_ERROR); + if (set_globals() == GP_ERROR) + return (GP_ERROR); - if ((thumbnail)&&(!glob_abilities.file_preview)) { - error_print("Camera doesn't support picture thumbnails"); - return (GP_ERROR); - } + if ((thumbnail)&&(!glob_abilities.file_preview)) { + error_print("Camera doesn't support picture thumbnails"); + return (GP_ERROR); + } - count = gp_file_count(); + count = gp_file_count(); - if (count == GP_ERROR) { - error_print("Could not get number of pictures on camera"); - return (GP_ERROR); - } + if (count == GP_ERROR) { + error_print("Could not get number of pictures on camera"); + return (GP_ERROR); + } - if (num > count) { - error_print("Picture number is too large"); - return (GP_ERROR); - } + if (num > count) { + error_print("Picture number is too large"); + return (GP_ERROR); + } - f = gp_file_new(); + f = gp_file_new(); - if (thumbnail) { - if (!glob_abilities.file_preview) { - error_print("Camera can not provide thumbnails"); - gp_file_free(f); - return (GP_ERROR); - } - if (gp_file_get_preview(num-1, f) == GP_ERROR) { - error_print("Can not get preview."); - return (GP_ERROR); - } - } else { - if (gp_file_get(num-1, f) == GP_ERROR) { - error_print("Can not get picture."); - return (GP_ERROR); - } - } - if ((glob_filename_override)&&(strlen(glob_filename)>0)) - sprintf(filename, glob_filename, num); - else if (strlen(f->name)>0) - if (thumbnail) - sprintf(filename, "thumb_%s", f->name); - else - strcpy(filename, f->name); - else { - sprintf(msg, "Filename not found. Use \"%sfilename\" to specify a filename", LONG_OPTION); - error_print(msg); - gp_file_free(f); - return (GP_ERROR); - } + if (thumbnail) { + if (!glob_abilities.file_preview) { + error_print("Camera can not provide thumbnails"); + gp_file_free(f); + return (GP_ERROR); + } + if (gp_file_get_preview(num-1, f) == GP_ERROR) { + error_print("Can not get preview."); + return (GP_ERROR); + } + } else { + if (gp_file_get(num-1, f) == GP_ERROR) { + error_print("Can not get picture."); + return (GP_ERROR); + } + } + if ((glob_filename_override)&&(strlen(glob_filename)>0)) + sprintf(filename, glob_filename, num); + else if (strlen(f->name)>0) + if (thumbnail) + sprintf(filename, "thumb_%s", f->name); + else + strcpy(filename, f->name); + else { + sprintf(msg, "Filename not found. Use \"%sfilename\" to specify a filename", LONG_OPTION); + error_print(msg); + gp_file_free(f); + return (GP_ERROR); + } - if (!glob_quiet) - printf("Saving image #%i as %s\n", num, filename); - if (gp_file_save(f, filename)==GP_ERROR) { - sprintf(msg, "Can not save image as ", filename); - error_print(msg); - } - gp_file_free(f); + if (!glob_quiet) + printf("Saving image #%i as %s\n", num, filename); + if (gp_file_save(f, filename)==GP_ERROR) { + sprintf(msg, "Can not save image as ", filename); + error_print(msg); + } + gp_file_free(f); - return (GP_OK); + + return (GP_OK); } OPTION_CALLBACK(get_picture) { - return (get_picture_common(atoi(arg), 0)); + return (get_picture_common(atoi(arg), 0)); } OPTION_CALLBACK(get_thumbnail) { - return (get_picture_common(atoi(arg), 1)); + return (get_picture_common(atoi(arg), 1)); + } OPTION_CALLBACK(delete_picture) { - int num = atoi(arg); - int count; + int num = atoi(arg); + int count; - debug_print("Deleting picture", ""); + debug_print("Deleting picture", ""); - if (set_globals() == GP_ERROR) - return (GP_ERROR); + if (set_globals() == GP_ERROR) + return (GP_ERROR); - if (!glob_abilities.file_delete) { - error_print("Camera can not delete pictures"); - return (GP_ERROR); - } + if (!glob_abilities.file_delete) { + error_print("Camera can not delete pictures"); + return (GP_ERROR); + } - count = gp_file_count(); + count = gp_file_count(); - if (count == GP_ERROR) { - error_print("Could not get number of pictures on camera"); - return (GP_ERROR); - } + if (count == GP_ERROR) { + error_print("Could not get number of pictures on camera"); + return (GP_ERROR); + } - if (num > count) { - error_print("Picture number is too large.\nRemember that numbering begins at zero (0)"); - return (GP_ERROR); - } + if (num > count) { + error_print("Picture number is too large.\nRemember that numbering begins at zero (0)"); + return (GP_ERROR); + } - if (gp_file_delete(num-1)==GP_ERROR) { - error_print("Could not delete the picture"); - return (GP_ERROR); - } - - return (GP_OK); + if (gp_file_delete(num-1)==GP_ERROR) { + error_print("Could not delete the picture"); + return (GP_ERROR); + } + + return (GP_OK); } OPTION_CALLBACK(upload_picture) { - CameraFile *f; - char buf[1024]; + CameraFile *f; + char buf[1024]; - debug_print("Uploading picture", ""); + debug_print("Uploading picture", ""); - if (set_globals() == GP_ERROR) - return (GP_ERROR); + if (set_globals() == GP_ERROR) + return (GP_ERROR); - if (!glob_abilities.file_put) { - error_print("Camera doesn't support uploading pictures"); - return (GP_ERROR); - } + if (!glob_abilities.file_put) { + error_print("Camera doesn't support uploading pictures"); + return (GP_ERROR); + } - f = gp_file_new(); - if (gp_file_open(f, arg)==GP_ERROR) { - sprintf(buf, "Could not open file %s", arg); - error_print(buf); - return (GP_ERROR); - } - - if (gp_file_put(f)==GP_ERROR) { - error_print("Could not upload the picture"); - return (GP_ERROR); - } + f = gp_file_new(); + if (gp_file_open(f, arg)==GP_ERROR) { + sprintf(buf, "Could not open file %s", arg); + error_print(buf); + return (GP_ERROR); + } - gp_file_free(f); + if (gp_file_put(f)==GP_ERROR) { + error_print("Could not upload the picture"); + return (GP_ERROR); + } - return (GP_OK); + gp_file_free(f); + + return (GP_OK); } OPTION_CALLBACK(summary) { - CameraText buf; - if (set_globals() == GP_ERROR) - return (GP_ERROR); + CameraText buf; - if (gp_summary(&buf)==GP_ERROR) { - error_print("Could not get camera summary"); - return (GP_ERROR); - } - printf("Camera Summary:\n%s\n", buf.text); - return (GP_OK); + if (set_globals() == GP_ERROR) + return (GP_ERROR); + + + if (gp_summary(&buf)==GP_ERROR) { + error_print("Could not get camera summary"); + return (GP_ERROR); + } + printf("Camera Summary:\n%s\n", buf.text); + + + return (GP_OK); } OPTION_CALLBACK(manual) { - CameraText buf; - if (set_globals() == GP_ERROR) - return (GP_ERROR); + CameraText buf; - if (gp_manual(&buf)==GP_ERROR) { - error_print("Could not get camera manual"); - return (GP_ERROR); - } - printf("Camera Manual:\n%s\n", buf.text); - return (GP_OK); + if (set_globals() == GP_ERROR) + return (GP_ERROR); + + if (gp_manual(&buf)==GP_ERROR) { + error_print("Could not get camera manual"); + return (GP_ERROR); + } + printf("Camera Manual:\n%s\n", buf.text); + + + return (GP_OK); } OPTION_CALLBACK(about) { - CameraText buf; - if (set_globals() == GP_ERROR) - return (GP_ERROR); + CameraText buf; - if (gp_about(&buf)==GP_ERROR) { - error_print("Could not get camera manual"); - return (GP_ERROR); - } - printf("About the library:\n%s\n", buf.text); - return (GP_OK); + if (set_globals() == GP_ERROR) + return (GP_ERROR); + + if (gp_about(&buf)==GP_ERROR) { + error_print("Could not get camera manual"); + return (GP_ERROR); + } + printf("About the library:\n%s\n", buf.text); + + + return (GP_OK); } int set_globals () { - /* takes all the settings and sets up the gphoto lib */ - CameraPortSettings s; - char buf[1024]; + /* takes all the settings and sets up the gphoto lib */ + CameraPortSettings s; + char buf[1024]; - if (strlen(glob_model) == 0) { - sprintf(buf, "Must specify a camera model using \"%scamera model\"",LONG_OPTION); - error_print(buf); - return (GP_ERROR); - } + if (strlen(glob_model) == 0) { + sprintf(buf, "Must specify a camera model using \"%scamera model\"",LONG_OPTION); + error_print(buf); + return (GP_ERROR); + } - if ((strlen(glob_port) == 0)&&(strcmp(glob_model, "Directory Browse")!=0)) { - sprintf(buf, "Must specify a camera port using \"%sport path\"",LONG_OPTION); - error_print(buf); - return (GP_ERROR); - } + if ((strlen(glob_port) == 0)&&(strcmp(glob_model, "Directory Browse")!=0)) { + sprintf(buf, "Must specify a camera port using \"%sport path\"",LONG_OPTION); + error_print(buf); + 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_ERROR) { - sprintf(buf, "Could not find camera \"%s\".\nUse \"--list-cameras\" to see available camera models", glob_model); - error_print(buf); - return (GP_ERROR); - } + if (gp_camera_abilities_by_name(glob_model, &glob_abilities)==GP_ERROR) { + sprintf(buf, "Could not find camera \"%s\".\nUse \"--list-cameras\" to see available camera models", glob_model); + error_print(buf); + return (GP_ERROR); + } - if (gp_camera_set_by_name(glob_model, &s)==GP_ERROR) { - sprintf(buf, "Can not initialize camera \"%s\"",glob_model); - error_print(buf); - return (GP_ERROR); - } + if (gp_camera_set_by_name(glob_model, &s)==GP_ERROR) { + sprintf(buf, "Can not initialize camera \"%s\"",glob_model); + error_print(buf); + return (GP_ERROR); + } - if (gp_folder_set(glob_folder)==GP_ERROR) { - sprintf(buf, "Can not find folder \"%s\"",glob_folder); - error_print(buf); - return (GP_ERROR); - } + if (gp_folder_set(glob_folder)==GP_ERROR) { + sprintf(buf, "Can not find folder \"%s\"",glob_folder); + error_print(buf); + return (GP_ERROR); + } - return (GP_OK); + return (GP_OK); } int init_globals () { - option_count = 0; + option_count = 0; - strcpy(glob_model, ""); - strcpy(glob_port, ""); - strcpy(glob_filename, "gphoto"); - strcpy(glob_folder, "/"); + strcpy(glob_model, ""); + strcpy(glob_port, ""); + strcpy(glob_filename, "gphoto"); + strcpy(glob_folder, "/"); - glob_speed = 0; - glob_debug = 0; - glob_quiet = 0; - glob_filename_override = 0; + glob_speed = 0; + glob_debug = 0; + glob_quiet = 0; + glob_filename_override = 0; } -/* Command-line option functions */ -/* ------------------------------------------------------------------ */ +/* Command-line option functions */ +/* ------------------------------------------------------------------ */ int option_is_present (char *op, int argc, char **argv) { - /* checks to see if op is in the command-line. it will */ - /* check for both short and long option-formats for op */ + /* checks to see if op is in the command-line. it will */ + /* check for both short and long option-formats for op */ - int x, found=0; - char s[5], l[20]; + int x, found=0; + char s[5], l[20]; - /* look for short/long options and fill them in */ - for (x=0; x0) { - if (x+1 < argc) { - if ( - (strncmp(argv[x+1], SHORT_OPTION, strlen(SHORT_OPTION))!=0) && - (strncmp(argv[x+1], LONG_OPTION, strlen(LONG_OPTION))!=0) - ) { - match=1; - x++; - } else { - which=y; - missing_arg=1; - } - } else { - missing_arg=1; - which=y; - } - } else - match=1; - } - } - if (!match) { - sprintf(msg, "Bad option \"%s\": ", argv[x]); - error_print(msg); - if (missing_arg) { - sprintf(buf, " Missing argument. You must specify the \"%s\"", - option[which].argument); - error_print(msg); - } else - error_print(" unknown option"); - return (GP_ERROR); - } - } + for (x=1; x0) { + if (x+1 < argc) { + if ( + (strncmp(argv[x+1], SHORT_OPTION, strlen(SHORT_OPTION))!=0) && + (strncmp(argv[x+1], LONG_OPTION, strlen(LONG_OPTION))!=0) + ) { + match=1; + x++; + } else { + which=y; + missing_arg=1; + } + } else { + missing_arg=1; + which=y; + } + } else + match=1; + } + } + if (!match) { + sprintf(msg, "Bad option \"%s\": ", argv[x]); + error_print(msg); + if (missing_arg) { + sprintf(buf, " Missing argument. You must specify the \"%s\"", + option[which].argument); + error_print(msg); + } else + error_print(" unknown option"); + return (GP_ERROR); + } + } - /* Make sure required options are present */ - for (x=0; x0? SHORT_OPTION:LONG_OPTION, - strlen(option[x].short_id)>0? option[x].short_id:option[x].long_id); - return (GP_ERROR); - } - } - } + /* Make sure required options are present */ + for (x=0; x0? SHORT_OPTION:LONG_OPTION, + strlen(option[x].short_id)>0? option[x].short_id:option[x].long_id); + return (GP_ERROR); + } + } + } - return (GP_OK); + return (GP_OK); } int execute_options (int argc, char **argv) { - int x, y, ret; - char s[5], l[24]; - char *op; - - /* Execute the command-line options */ - for (x=0; x 0) { - ret=(*option[x].execute)(argv[++y]); - } else - ret=(*option[x].execute)(NULL); - if (ret == GP_ERROR) { - // error_print("Option \"%s\" did not execute properly.",op); - return (GP_ERROR); - } - } - } - } - } + int x, y, ret; + char s[5], l[24]; + char *op; - return (GP_OK); + /* Execute the command-line options */ + for (x=0; x 0) { + ret=(*option[x].execute)(argv[++y]); + } else + ret=(*option[x].execute)(NULL); + if (ret == GP_ERROR) { + // error_print("Option \"%s\" did not execute properly.",op); + return (GP_ERROR); + } + } + } + } + } + + return (GP_OK); } void usage () { - int x=0, y=0; - char buf[128], s[5], l[24], a[16]; + int x=0, y=0; + char buf[128], s[5], l[24], a[16]; - /* Standard licensing stuff */ - printf( - "\ngPhoto2 (v%s)- Cross-platform digital camera library.\n" - "Copyright (C) 2000 Scott Fritzinger\n" + /* Standard licensing stuff */ + printf( + "\ngPhoto2 (v%s)- Cross-platform digital camera library.\n" + "Copyright (C) 2000 Scott Fritzinger\n" #ifdef OS2 "OS/2 port by Bart van Leeuwen\n" #endif - "Licensed under the Library GNU Public License (LGPL).\n" - "Usage:\n", VERSION - ); + "Licensed under the Library GNU Public License (LGPL).\n" + "Usage:\n", VERSION + ); - printf ("Short/long options (& argument) description\n" - "------------------------------------------------------------------------\n"); + printf ("Short/long options (& argument) description\n" + "------------------------------------------------------------------------\n"); - /* Run through option and print them out */ - while (x < option_count) { - /* maybe sort these by short option? can't be an in-place sort. - would need to memcpy() to a new struct array. */ - if (strlen(option[x].short_id) > 0) - sprintf(s, "%s%s ", SHORT_OPTION, option[x].short_id); - else - sprintf(s, " "); + /* Run through option and print them out */ + while (x < option_count) { + /* maybe sort these by short option? can't be an in-place sort. + would need to memcpy() to a new struct array. */ + if (strlen(option[x].short_id) > 0) + sprintf(s, "%s%s ", SHORT_OPTION, option[x].short_id); + else + sprintf(s, " "); - if (strlen(option[x].long_id) > 0) - sprintf(l, "%s%s", LONG_OPTION, option[x].long_id); - else - sprintf(l, " "); + if (strlen(option[x].long_id) > 0) + sprintf(l, "%s%s", LONG_OPTION, option[x].long_id); + else + sprintf(l, " "); - if (strlen(option[x].argument) > 0) - sprintf(a, "%s", option[x].argument); - else - sprintf(a, " "); - sprintf(buf, " %-04s %s %s", s, l, a); - printf("%-38s %s\n", buf, option[x].description); - x++; - } - printf( "------------------------------------------------------------------------\n" - "[Use double-quotes around arguments] [Picture numbers begin one (1)]\n"); + if (strlen(option[x].argument) > 0) + sprintf(a, "%s", option[x].argument); + else + sprintf(a, " "); + sprintf(buf, " %-04s %s %s", s, l, a); + printf("%-38s %s\n", buf, option[x].description); + x++; + } + printf( "------------------------------------------------------------------------\n" + "[Use double-quotes around arguments] [Picture numbers begin one (1)]\n"); } -/* Misc functions */ -/* ------------------------------------------------------------------ */ +/* Misc functions */ +/* ------------------------------------------------------------------ */ void debug_print(char *message, char *str) { - if (glob_debug) { - printf("cli: "); - printf(message, str); - printf("\n"); - } + if (glob_debug) { + printf("cli: "); + printf(message, str); + printf("\n"); + } } void error_print(char *message) { - - printf("ERROR: %s\n", message); + + printf("ERROR: %s\n", message); } -/* ------------------------------------------------------------------ */ +/* ------------------------------------------------------------------ */ int main (int argc, char **argv) { - /* Initialize the globals */ - init_globals(); + /* Initialize the globals */ + init_globals(); - /* Count the number of command-line options we have */ - while ((strlen(option[option_count].short_id)>0) || - (strlen(option[option_count].long_id)>0)) { - option_count++; - } + /* Count the number of command-line options we have */ + while ((strlen(option[option_count].short_id)>0) || + (strlen(option[option_count].long_id)>0)) { + option_count++; + } - /* Peek ahead: Turn on quiet if they gave the flag */ - if (option_is_present("q", argc, argv)==GP_OK) - glob_quiet=1; + /* Peek ahead: Turn on quiet if they gave the flag */ + if (option_is_present("q", argc, argv)==GP_OK) + glob_quiet=1; - /* Peek ahead: Check to see if we need to turn on debugging output */ - if (option_is_present("debug", argc, argv)==GP_OK) - glob_debug=1; + /* Peek ahead: Check to see if we need to turn on debugging output */ + if (option_is_present("debug", argc, argv)==GP_OK) + glob_debug=1; #ifdef OS2 /*check if environment is set otherwise quit*/ if(CAMLIBS==NULL) { -printf("gPhoto2 for OS/2 requires you to set the enviroment value CAMLIBS -to the location of the camera libraries. +printf("gPhoto2 for OS/2 requires you to set the enviroment value CAMLIBS \ +to the location of the camera libraries. \ e.g. SET CAMLIBS=C:\\GPHOTO2\\CAM\n"); - exit(EXIT_FAILURE); - } + exit(EXIT_FAILURE); + } #endif - /* Peek ahead: Make sure we were called correctly */ - if ((argc == 1)||(verify_options(argc, argv)==GP_ERROR)) { - if (!glob_quiet) - usage(); - exit(EXIT_FAILURE); - } + /* Peek ahead: Make sure we were called correctly */ + if ((argc == 1)||(verify_options(argc, argv)==GP_ERROR)) { + if (!glob_quiet) + usage(); + exit(EXIT_FAILURE); + } - /* Initialize gPhoto core */ - gp_init(glob_debug); + /* Initialize gPhoto core */ + gp_init(glob_debug); - if (execute_options(argc, argv) == GP_ERROR) { -// if (!glob_quiet) -// usage(); - exit(EXIT_FAILURE); - } + if (execute_options(argc, argv) == GP_ERROR) { +// if (!glob_quiet) +// usage(); + exit(EXIT_FAILURE); + } - /* Exit gPhoto core */ - gp_exit(); + /* Exit gPhoto core */ + gp_exit(); - return (EXIT_SUCCESS); + return (EXIT_SUCCESS); } diff --git a/frontends/command-line/makefile.os2 b/frontends/command-line/makefile.os2 index 5425702c8..278874f8e 100644 --- a/frontends/command-line/makefile.os2 +++ b/frontends/command-line/makefile.os2 @@ -1,4 +1,4 @@ -CCFLAGS=-O2 -c -I.. -I..\..\include -Zmtd -Zcrtdll -Zbin-files -D__ST_MT_ERRNO_ -I. -DOS2 -DHAVE_TERMIOS_H +CCFLAGS=-O2 -c -I.. -I..\..\libgpio -I..\..\include -Zmtd -Zcrtdll -Zbin-files -D__ST_MT_ERRNO_ -I. -DOS2 -DHAVE_TERMIOS_H CC=gcc all: ..\..\gphoto2.exe @@ -12,6 +12,5 @@ all: ..\..\gphoto2.exe ..\..\obj\test.o: test.c $(CC) -o $@ $** $(CCFLAGS) -..\..\gphoto2.exe: ..\..\obj\interface.o ..\..\obj\main.o ..\..\obj\test.o ..\..\lib\libgphoto2.a ..\..\lib\libgpio.a +..\..\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 -Le:\emx\lib -L..\..\lib -llibgphoto2 -llibgpio -ldl -lpthreads -lpthrdrtl - diff --git a/include/gphoto2.h b/include/gphoto2.h index eddd6a37a..0cc9e8c5e 100644 --- a/include/gphoto2.h +++ b/include/gphoto2.h @@ -1,10 +1,11 @@ -/* Header file for gPhoto 0.5-Dev +/* Header file for gPhoto 0.5-Dev - Author: Scott Fritzinger + Author: Scott Fritzinger - This library is covered by the LGPL. + This library is covered by the LGPL. */ +#include #include #include #include diff --git a/include/gphotoos2.h b/include/gphotoos2.h index 52d9c80f6..fa50f248b 100644 --- a/include/gphotoos2.h +++ b/include/gphotoos2.h @@ -1,8 +1,6 @@ #ifndef GPHOTO_OS2_INCLUDED #define GPHOTO_OS2_INCLUDED - - #define CAMLIBS getenv("CAMLIBS") #define RTLD_LAZY 0x001 #define VERSION "2" - +#endif diff --git a/libgphoto2/library.c b/libgphoto2/library.c index b81f38e84..fd43693c2 100644 --- a/libgphoto2/library.c +++ b/libgphoto2/library.c @@ -11,190 +11,190 @@ int is_library(char *library_filename) { - char buf[1024]; - void *lh; + char buf[1024]; + void *lh; -#if defined(OS2) || defined(WINDOWS) - sprintf(buf, "%s/%s", CAMLIBS, library_filename); + +#ifdef (OS2) || (WINDOWS) + sprintf(buf, "%s\\%s", CAMLIBS, library_filename); #else - sprintf(buf, "%s/%s", CAMLIBS, library_filename); + sprintf(buf, "%s/%s", CAMLIBS, library_filename); #endif - if ((lh = dlopen(buf, RTLD_LAZY))==NULL) { - if (glob_debug) - perror("core:\tis_library"); - return (GP_ERROR); - } - - dlclose(lh); + if ((lh = dlopen(buf, RTLD_LAZY))==NULL) { + if (glob_debug) + perror("core:\tis_library"); + return (GP_ERROR); + } - return (GP_OK); + dlclose(lh); + + return (GP_OK); } int load_library (char *camera_name) { - char buf[1024]; - void *lh; - int x; - for (x=0; xd_name); + if (glob_debug) + printf("core:\tis %s a library? ", de->d_name); /* try to open the library */ if (is_library(de->d_name) == GP_OK) { - if (glob_debug) - printf("yes\n"); + if (glob_debug) + printf("yes\n"); load_camera_list(de->d_name); } else { - if (glob_debug) - printf("no\n"); + if (glob_debug) + printf("no\n"); } } } while (de); - /* Sort the camera list */ - for (x=0; x 0) { - memcpy(&t, &glob_camera[x], sizeof(t)); - memcpy(&glob_camera[x], &glob_camera[y], sizeof(t)); - memcpy(&glob_camera[y], &t, sizeof(t)); + /* Sort the camera list */ + for (x=0; x 0) { + memcpy(&t, &glob_camera[x], sizeof(t)); + memcpy(&glob_camera[x], &glob_camera[y], sizeof(t)); + memcpy(&glob_camera[y], &t, sizeof(t)); - memcpy(&a, &glob_camera_abilities[x], sizeof(a)); - memcpy(&glob_camera_abilities[x], &glob_camera_abilities[y], - sizeof(a)); - memcpy(&glob_camera_abilities[y], &a, sizeof(a)); - } - } - } - - return (GP_OK); + memcpy(&a, &glob_camera_abilities[x], sizeof(t)); + memcpy(&glob_camera_abilities[x], &glob_camera_abilities[y], + sizeof(t)); + memcpy(&glob_camera_abilities[y], &a, sizeof(t)); + } + } + } + return (GP_OK); } int close_library () { - dlclose(glob_library_handle); + dlclose(glob_library_handle); - return (GP_OK); + return (GP_OK); } diff --git a/libgphoto2/makefile.os2 b/libgphoto2/makefile.os2 index 1ab962b0a..9b4b00076 100644 --- a/libgphoto2/makefile.os2 +++ b/libgphoto2/makefile.os2 @@ -1,8 +1,9 @@ -CCFLAGS=-O2 -c -I.. -I..\include -Zmtd -Zcrtdll -Zbin-files -D__ST_MT_ERRNO_ -I. -DOS2 -DHAVE_TERMIOS_H +CCFLAGS=-O2 -c -I.. -I..\include -I..\libgpio -Zmtd -Zcrtdll -Zbin-files -D__ST_MT_ERRNO_ -I. -DOS2 -DHAVE_TERMIOS_H CC=gcc MKLIB=ar r all: ..\lib\libgphoto2.a + @echo enter libgphoto2 ..\obj\core.o: core.c $(CC) -o $@ $** $(CCFLAGS) diff --git a/makefile.os2 b/makefile.os2 index 1bd135212..3fd865981 100644 --- a/makefile.os2 +++ b/makefile.os2 @@ -11,10 +11,12 @@ all: @cd libgphoto2 @nmake -nologo -f makefile.os2 @cd .. + @cd frontends\libgphoto2_frontend + @nmake -nologo -f makefile.os2 + @cd ..\command-line + @nmake -nologo -f makefile.os2 + @cd ..\.. @cd camlibs @nmake -nologo -f makefile.os2 @cd .. - @cd frontends\command-line - @nmake -nologo -f makefile.os2 - @cd ..\.. @echo Done