while(!mark_shutdown) { // Shall we finally capture some pics? res = gp_camera_capture(camera, GP_CAPTURE_IMAGE, &path, context); if(res!=GP_OK) {printf("16 - Code: %d - %s\n", res, gp_result_as_string(res));} time(&rawtime); gmtime_r(&rawtime, &time_struct); sprintf(output_file, "%s-%04d%02d%02d-%02d%02d%02d.jpg", camera_owner, time_struct.tm_year+1900, time_struct.tm_mon+1, time_struct.tm_mday, time_struct.tm_hour, time_struct.tm_min, time_struct.tm_sec); fd = open(output_file, O_CREAT|O_WRONLY, 0644); //fd = prepare_socket(output_file); if(fd>0) { res = gp_file_new_from_fd(&file, fd); if(res!=GP_OK) {printf("17 - Code: %d - %s\n", res, gp_result_as_string(res));} res = gp_camera_file_get(camera, path.folder, path.name, GP_FILE_TYPE_NORMAL, file, context); if(res!=GP_OK) {printf("18 - Code: %d - %s\n", res, gp_result_as_string(res));} // sometimes it fails res = gp_file_unref(file); if(res!=GP_OK) {printf("19 - Code: %d - %s\n", res, gp_result_as_string(res));} close(fd); } res = gp_camera_file_delete(camera, path.folder, path.name, context); if(res!=GP_OK) {printf("20 - Code: %d - %s\n", res, gp_result_as_string(res));} pthread_mutex_lock(&lock); pthread_cond_wait(&fire, &lock); pthread_mutex_unlock(&lock); } // Cleanup gp_camera_exit(camera, context); gp_camera_unref(camera); gp_context_unref(context); printf("Camera %s closed!\n", camera_owner); return NULL;