generic wrapper ptp command function added
ported some old wrapper functions to be just macros. git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@12211 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2009-07-10 Marcus Meissner <marcus@jet.franken.de>
|
||||
|
||||
* ptp.c,ptp.h: Generic PTP wrapper function (no data, no output)
|
||||
to avoid coding all generic functions as seperate functions.
|
||||
Started converting functions to macros.
|
||||
|
||||
2009-07-09 Axel Waggershauser <awagger@web.de>
|
||||
* ptp.c: Some sprintf format adjustments.
|
||||
* ptp.h: EOS_RemoteRelease doc comments.
|
||||
|
||||
@@ -447,6 +447,39 @@ ptp_canon_eos_getdeviceinfo (PTPParams* params, PTPCanonEOSDeviceInfo*di)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* ptp_generic_no_data:
|
||||
* params: PTPParams*
|
||||
* code PTP OP Code
|
||||
* n_param count of parameters
|
||||
* ... variable argument list ...
|
||||
*
|
||||
* Emits a generic PTP command without any data transfer.
|
||||
*
|
||||
* Return values: Some PTP_RC_* code.
|
||||
**/
|
||||
uint16_t
|
||||
ptp_generic_no_data (PTPParams* params, uint16_t code, unsigned int n_param, ...)
|
||||
{
|
||||
PTPContainer ptp;
|
||||
va_list args;
|
||||
int i;
|
||||
|
||||
if( n_param > 5 )
|
||||
return PTP_RC_InvalidParameter;
|
||||
|
||||
PTP_CNT_INIT(ptp);
|
||||
ptp.Code=code;
|
||||
ptp.Nparam=n_param;
|
||||
|
||||
va_start(args, n_param);
|
||||
for( i=0; i<n_param; ++i )
|
||||
(&ptp.Param1)[i] = va_arg(args, uint32_t);
|
||||
va_end(args);
|
||||
|
||||
return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* ptp_opensession:
|
||||
* params: PTPParams*
|
||||
@@ -485,33 +518,6 @@ ptp_opensession (PTPParams* params, uint32_t session)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* ptp_closesession:
|
||||
* params: PTPParams*
|
||||
*
|
||||
* Closes session.
|
||||
*
|
||||
* Return values: Some PTP_RC_* code.
|
||||
**/
|
||||
uint16_t
|
||||
ptp_closesession (PTPParams* params)
|
||||
{
|
||||
PTPContainer ptp;
|
||||
|
||||
ptp_debug(params,"PTP: Closing session");
|
||||
|
||||
/* free any dangling response packet */
|
||||
if (params->response_packet_size > 0) {
|
||||
free(params->response_packet);
|
||||
params->response_packet = NULL;
|
||||
params->response_packet_size = 0;
|
||||
}
|
||||
PTP_CNT_INIT(ptp);
|
||||
ptp.Code=PTP_OC_CloseSession;
|
||||
ptp.Nparam=0;
|
||||
return ptp_transaction_new(params, &ptp, PTP_DP_NODATA, 0, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* ptp_free_params:
|
||||
* params: PTPParams*
|
||||
@@ -532,27 +538,6 @@ ptp_free_params (PTPParams *params) {
|
||||
ptp_free_DI (¶ms->deviceinfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* ptp_resetdevice:
|
||||
* params: PTPParams*
|
||||
*
|
||||
* Uses the built-in function to reset the device
|
||||
*
|
||||
* Return values: Some PTP_RC_* code.
|
||||
*
|
||||
*/
|
||||
uint16_t
|
||||
ptp_resetdevice (PTPParams* params)
|
||||
{
|
||||
PTPContainer ptp;
|
||||
|
||||
PTP_CNT_INIT(ptp);
|
||||
ptp.Code=PTP_OC_ResetDevice;
|
||||
ptp.Nparam=0;
|
||||
|
||||
return ptp_transaction_new(params, &ptp, PTP_DP_NODATA, 0, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* ptp_getststorageids:
|
||||
* params: PTPParams*
|
||||
@@ -609,28 +594,6 @@ ptp_getstorageinfo (PTPParams* params, uint32_t storageid,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* ptp_formatstore:
|
||||
* params: PTPParams*
|
||||
* storageid - StorageID
|
||||
*
|
||||
* Formats the storage on the device.
|
||||
*
|
||||
* Return values: Some PTP_RC_* code.
|
||||
**/
|
||||
uint16_t
|
||||
ptp_formatstore (PTPParams* params, uint32_t storageid)
|
||||
{
|
||||
PTPContainer ptp;
|
||||
|
||||
PTP_CNT_INIT(ptp);
|
||||
ptp.Code=PTP_OC_FormatStore;
|
||||
ptp.Param1=storageid;
|
||||
ptp.Param2=PTP_FST_Undefined;
|
||||
ptp.Nparam=2;
|
||||
return ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* ptp_getobjecthandles:
|
||||
* params: PTPParams*
|
||||
|
||||
@@ -1993,14 +1993,43 @@ uint16_t ptp_ptpip_event_check (PTPParams* params, PTPContainer* event);
|
||||
|
||||
uint16_t ptp_getdeviceinfo (PTPParams* params, PTPDeviceInfo* deviceinfo);
|
||||
|
||||
uint16_t ptp_opensession (PTPParams *params, uint32_t session);
|
||||
uint16_t ptp_closesession (PTPParams *params);
|
||||
uint16_t ptp_generic_no_data (PTPParams* params, uint16_t opcode, unsigned int cnt, ...);
|
||||
|
||||
uint16_t ptp_opensession (PTPParams *params, uint32_t session);
|
||||
|
||||
/**
|
||||
* ptp_closesession:
|
||||
* params: PTPParams*
|
||||
*
|
||||
* Closes session.
|
||||
*
|
||||
* Return values: Some PTP_RC_* code.
|
||||
**/
|
||||
#define ptp_closesession(params) ptp_generic_no_data(params,PTP_OC_CloseSession,0)
|
||||
/**
|
||||
* ptp_resetdevice:
|
||||
* params: PTPParams*
|
||||
*
|
||||
* Uses the built-in function to reset the device
|
||||
*
|
||||
* Return values: Some PTP_RC_* code.
|
||||
*
|
||||
*/
|
||||
#define ptp_resetdevice(params) ptp_generic_no_data(params,PTP_OC_ResetDevice,0)
|
||||
|
||||
uint16_t ptp_resetdevice (PTPParams* params);
|
||||
uint16_t ptp_getstorageids (PTPParams* params, PTPStorageIDs* storageids);
|
||||
uint16_t ptp_getstorageinfo (PTPParams* params, uint32_t storageid,
|
||||
PTPStorageInfo* storageinfo);
|
||||
uint16_t ptp_formatstore (PTPParams* params, uint32_t storageid);
|
||||
/**
|
||||
* ptp_formatstore:
|
||||
* params: PTPParams*
|
||||
* storageid - StorageID
|
||||
*
|
||||
* Formats the storage on the device.
|
||||
*
|
||||
* Return values: Some PTP_RC_* code.
|
||||
**/
|
||||
#define ptp_formatstore(params,storageid) ptp_generic_no_data(params,PTP_OC_FormatStore,1,storageid)
|
||||
|
||||
uint16_t ptp_getobjecthandles (PTPParams* params, uint32_t storage,
|
||||
uint32_t objectformatcode,
|
||||
|
||||
Reference in New Issue
Block a user