more magic numbers

This commit is contained in:
Ed Hartnett 2018-06-06 13:09:16 -06:00
parent c172acab98
commit 8d08b8c236
2 changed files with 45 additions and 0 deletions

View File

@ -516,6 +516,9 @@ typedef struct NC_Dispatch NC_Dispatch;
EXTERNL int
nc_def_user_format(int mode_flag, NC_Dispatch *dispatch_table, char *magic_number);
EXTERNL int
nc_inq_user_format(int mode_flag, NC_Dispatch **dispatch_table, char *magic_number);
EXTERNL int
nc__create(const char *path, int cmode, size_t initialsz,
size_t *chunksizehintp, int *ncidp);

View File

@ -151,6 +151,48 @@ nc_def_user_format(int mode_flag, NC_Dispatch *dispatch_table, char *magic_numbe
return NC_NOERR;
}
/**
* Inquire about user-defined format.
*
* @param mode_flag NC_UDF0 or NC_UDF1
* @param dispatch_table Pointer that gets pointer to dispatch table
* to use for this user format, or NULL if this user-defined format is
* not defined. Ignored if NULL.
* @param magic_number Pointer that gets magic number used to identify
* file, if one has been set. Magic number will be of max size
* NC_MAX_MAGIC_NUMBER_LEN. Ignored if NULL.
*
* @return ::NC_NOERR No error.
* @return ::NC_EINVAL Invalid input.
* @author Ed Hartnett
* @ingroup datasets
*/
int
nc_inq_user_format(int mode_flag, NC_Dispatch **dispatch_table, char *magic_number)
{
/* Check inputs. */
if (mode_flag != NC_UDF0 && mode_flag != NC_UDF1)
return NC_EINVAL;
switch(mode_flag)
{
case NC_UDF0:
if (dispatch_table)
*dispatch_table = UDF0_dispatch_table;
if (magic_number)
strncpy(magic_number, UDF0_magic_number, NC_MAX_MAGIC_NUMBER_LEN);
break;
case NC_UDF1:
if (dispatch_table)
*dispatch_table = UDF1_dispatch_table;
if (magic_number)
strncpy(magic_number, UDF1_magic_number, NC_MAX_MAGIC_NUMBER_LEN);
break;
}
return NC_NOERR;
}
#endif /* USE_NETCDF4 */
/*!