Files | |
file | main.c |
PC command line entry point. | |
file | argusage.c |
Common platform argument parsing and usage reporting. | |
file | argusage.h |
Common platform argument parsing and usage reporting. | |
Data Structures | |
struct | parse_args_t |
Macros | |
#define | ENABLECOLORCONSOLE 1 |
Whether to enable colorful console output, switched by the -! option. | |
Enumerations | |
enum | |
Functions | |
static void | monitorCallback (uint32 bufLen, const uint8 *u8buf) |
Monitor information callback. More... | |
static HqBool | extendLibrarySearchPath (char *pszPath) |
static void | le_exception_handler (char *mess) |
static uint8 * | wchar_to_utf8 (WCHAR *arg, HqBool keep) |
static HqBool | args_used (void *data, int n) |
Callback to check that we have enough arguments left. | |
static uint8 * | arg_to_utf8 (void *data, int index, HqBool keep) |
Callback to convert an indexed argument to UTF-8. | |
static uint8 * | program_name_from_argv (WCHAR **argv) |
Function to get program leaf name in UTF-8 from initial argv. | |
static uint8 * | program_name (void *data) |
Callback to get program leaf name in UTF-8. | |
static uint8 * | program_name_from_opaque_argv (void *data) |
Function to get program leaf name in UTF-8 from initial argv, through opaque pointer for platform abstraction. | |
static void | PlatformOptionInitialize (HqBool sdkinit) |
static int32 | PlatformOption (int32 option, HqBool sdkready, HqBool(*args_used)(void *data, int n), uint8 *(*arg_to_utf8)(void *data, int index, HqBool keep), uint8 *(*program_name)(void *data), void *data) |
static HqBool | AddFilesToInputQ (uint8 *pattern, const uint8 *configName, uint8 *errbuf) |
static int32 | ParseArguments (int argc, WCHAR **argv, HqBool sdkready) |
static void | do_cpuid (uint32 *info, uint32 id) |
static HqBool | cpuid_fail (char *reason) |
static HqBool | verify_system_requirements (void) |
int __cdecl | wmain (int argc, WCHAR *argv[]) |
The main entry point to the Windows version of the clrip command-line RIP application. More... | |
static HqBool | MountDriveType (char *pRootPath) |
HqBool | PTNextDrive (int32 index, uint8 *pDrivename) |
Called by MountAllDrives() to get the next (first if index == 0) drive that is on the machine. More... | |
int32 | ClripOption (int32 option, HqBool sdkready, HqBool filenameConsumed, HqBool(*args_used)(void *data, int n), uint8 *(*arg_to_utf8)(void *data, int index, HqBool keep), uint8 *(*program_name)(void *data), void *data) |
Parse common options for all platform versions of clrip. More... | |
void | ClripOptionInitialize (HqBool sdkinit) |
Initialise common options to empty or default values. More... | |
int32 | PrepareProcessing (uint8 *(*program_name)(void *data), void *data) |
Prepare to process jobs by determining whether the stuff_to_do fields are consistent, and start the appropriate extra processing threads if necessary. More... | |
void | ClripOptionFinalize (void) |
Finalise allocations used for option parsing before processing jobs. | |
int32 | ClripUsage (const uint8 *program, char which, const char *error,...) |
Display help information for the clrip program, optionally restricting output to just one option. More... | |
void | enable_color_console (int mode) |
Hook provided by platform to enable color console output. | |
Variables | |
HqBool | fLogStderr |
SwLeDoParams | doparams = { sizeof(doparams) } |
The parameters structure used for calls to SwLeDo(). | |
int | stuff_to_do |
HqBool | fLogStderr |
int | stuff_to_do |
SwLeDoParams | doparams |
The parameters structure used for calls to SwLeDo(). | |
anonymous enum |
Bitmask of stuff we've been asked to do.
Add all of the files matching a pattern to the input queue.
[in,out] | pattern | A wildcard pattern for finding input files. |
configName | A configuration name to use for printing the files. | |
[out] | errbuf | A buffer of length at least LONGESTFILENAME into which an error message will be written if the function fails. |
TRUE | All of the files matching the pattern were added to the input queue. |
FALSE | An error occurred. An error message at most LONGESTFILENAME long was written into errbuf. |
int32 ClripOption | ( | int32 | option, |
HqBool | sdkready, | ||
HqBool | filenameConsumed, | ||
HqBool(*)(void *data, int n) | args_used, | ||
uint8 *(*)(void *data, int index, HqBool keep) | arg_to_utf8, | ||
uint8 *(*)(void *data) | program_name, | ||
void * | data | ||
) |
Parse common options for all platform versions of clrip.
[in] | option | The option character(s). Options may have multiple characters; up to four characters are packed into this parameter, but longer options can be checked by calling the arg_to_utf8() callback to examine the option itself. |
sdkready | Argument parsing is handled in two passes, one before initialising the RIP SDK, and the other after. The first pass should be used to handle options that affect the initial state of the SDK, or for idempotent flags; the second pass should be used to process configurations and job files. Processing of options for both passes should call the args_used() callback with the same number of arguments to consume. This flag is passed onto the ClripUsage() function in the case of an error, indicating whether the SDK should be shutdown before returning. | |
filenameConsumed | Set to TRUE to indicate that a filename has just been consumed from the argument list. This is only used for argument handling sanity checks. | |
args_used | A callback function used to indicate how many arguments were consumed by the call. The function must return FALSE if the number of arguments requested are not available. It may be called multiple times in a single ClripOption() call: the final call is the number of arguments to be consumed. If this function is not called, or the final call used the value zero, then the option was not recognised by ClripOption(), and the caller should take appropriate action. | |
arg_to_utf8 | A function pointer called to convert an argument to UTF-8, and return it to the caller. The index passed to the callback is a zero-based index relative to the option argument itself. It will always be less than the number of arguments indicated by the preceding args_used() callback. The keep boolean passed to the callback indicates if the caller needs to retain the data beyond the scope of this ClripOption() call. | |
program_name | A callback function to return the program name (without directory path) in UTF-8. This is only called immediately prior to issuing an error message with ClripUsage(). | |
data | An opaque data pointer passed to all of the callback functions, indicating the platform-specific state of argument parsing. |
EXIT_FAILURE | if the option had an error. The error information has already been reported. |
EXIT_SUCCESS | if the option was successfully processed, or the option was not recognised. If the option was successfully processed, then the final args_used() callback will indicate one or more argument was used. |
void ClripOptionInitialize | ( | HqBool | sdkinit | ) |
Initialise common options to empty or default values.
sdkinit | If TRUE, this is before a full SDK init. If FALSE, we are resetting just the core RIP. |
Display help information for the clrip program, optionally restricting output to just one option.
[in] | program | The name of the program, i.e., the leafname of the RIP executable, as stored in argv[0]. |
which | The option to report help for, or zero for all options. | |
[in] | error | An optional error format to print before reporting individual option help. All remaining parameters after this format string are interpreted according to the fprintf() specification. |
|
static |
This CPU does not mean the minimum system requirements. Inform the user and exit.
Call the OS to generate the cpuid intrinsic.
Double-check to make sure the given id is a valid call on this CPU, and pre-clear the 4 integer results array so that if there is any problem we will default to no SIMD available.
|
static |
Simple utility to add an extra entry to the end of the PATH environment variable.
The current value of PATH is obtained, and then extended with a semicolon followed by the string pszPath. The resulting string is applied as the new value of PATH.
Extending the PATH is a useful and generic way of broadening the search for DLLs. An alternative way to do this is to use the SetDllDirectory API, provided by Windows XP SP1 and later versions.
[in] | pszPath | Directory to add to PATH. |
TRUE | If the path was extended |
FALSE | If the path could not be extended |
|
static |
Output an exception message to stderr. This is installed as the exception handler for debug builds, to write out stack trace information.
Monitor information callback.
bufLen | The length of the monitor information in u8buf. | |
[in] | u8buf | A buffer of data to write to the monitor. |
The data in the buffer should be UTF-8 encoded, but this is not uniformly enforced yet. This function converts the buffer to wide characters, for console output on Windows, and routes it through the monitorFile() call to send it to the logfile(s), stdout, or stderr.
|
static |
Predicate to determine whether a drive attached on this machine should be mounted on the RIP.
Run the entire argument parsing loop for pre- or post- SDK cases.
|
static |
Options that are handled by platform-specific code, either because the option is platform-specific, or the action requires a platform-specific function. We use the same parsing framework as the common options for consistency.
|
static |
Initialize platform-specific options before argument parsing.
Prepare to process jobs by determining whether the stuff_to_do fields are consistent, and start the appropriate extra processing threads if necessary.
program_name | A callback function to return the program name (without directory path) in UTF-8. This is only called immediately prior to issuing an error message with ClripUsage(). |
data | An opaque data pointer passed to all of the callback functions, indicating the platform-specific state of argument parsing. |
EXIT_FAILURE | if the processing requested had an error. The error information has already been reported. |
EXIT_SUCCESS | if the processing was successfully prepared. |
Called by MountAllDrives() to get the next (first if index == 0) drive that is on the machine.
FALSE
when there are no more drives, and TRUE
if it has more. The returned pDrivename can be an empty string.
|
static |
Check that the machine meets the minimum system requirements.
By generating the cpuid intrinsic we can discover the level of SIMD supported by the CPU. Make sure we have at least the minimum level mandated by the code optimisations in use.
For Hqn 13, the RIP requires and uses SSE2 and below. For Hqn 14, we are mandating AVX2 and below on x86-amd64.
The hierarchy and introduction dates of SIMD are:
Convert zero-terminated wide-character argument to UTF8, retaining the argument in a static buffer if required.
int __cdecl wmain | ( | int | argc, |
WCHAR * | argv[] | ||
) |
The main entry point to the Windows version of the clrip command-line RIP application.
For pedagogical purposes, this command-line skin allows the entire RIP lifecycle to be run several times, using the -z (repeat count) option. This is not likely to be useful in production. The wmain() function is structured with a short startup sequence, a short finalisation sequence, and a repeat loop in between. The repeat loop shows all of the actions that need to be taken to initialise the SDK, process jobs using the RIP, and shut the SDK down. The actual RIP startup and shutdown is performed in the ProcessJobs() function.
Arguments to wmain() are scanned in two phases:
This is a Unicode wide-character enabled entry point. Arguments and filenames are converted to UTF-8 by callbacks before being passed to the SDK or the RIP.
HqBool fLogStderr |
Send all MON_CHANNEL_STDERR event messages to stderr. By default, a compatibility mode is used where only messages originating in the skin or SDK are sent to stderr, RIP messages on MON_CHANNEL_STDERR are sent to stdout.
|
extern |
Send all MON_CHANNEL_STDERR event messages to stderr. By default, a compatibility mode is used where only messages originating in the skin or SDK are sent to stderr, RIP messages on MON_CHANNEL_STDERR are sent to stdout.
int stuff_to_do |
Variable holding bitmask of stuff we've been asked to do.
|
extern |
Variable holding bitmask of stuff we've been asked to do.