delorie.com/djgpp/doc/libc/libc_847.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

v2loadimage

Syntax

 
#include <debug/v2load.h>

int v2loadimage (const char *program, const char *cmdline,
                 jmp_buf load_state);

Description

This function loads an executable image of a DJGPP v2.x program and prepares it for debugging. program should point to the file name of the executable program. v2loadimage does not search the PATH and does not try any executable extensions, so program should point to a fully-qualified path, complete with the drive, directory, and file-name extension; otherwise the call will fail.

cmdline should point to the command-line arguments to be passed to the program. A command line up to 126 characters long can be formatted exactly like the command tail DOS passes to programs: the first byte gives the length of the command tail, the tail itself begins with the second byte, and the tail is terminated by a CR character (decimal code 13); the length byte does not include the CR. Longer command lines require a different format: the first byte is 255, the command-line starting with the second byte which is terminated by a NUL character (decimal code 0). Regardless of the method used, the command-line arguments should look as if they were to be passed to the library function system. In particular, all special characters like wildcards and whitespace should be quoted as if they were typed at the DOS prompt.

After the function loads the image and sets up the necessary memory segments for it to be able to run, it sets load_state so that it can be used to longjmp to the debuggee's entry point. This information is typically used by run_child (see section run_child).

Return Value

Zero in case of success, non-zero otherwise.

Portability

ANSI/ISO C No
POSIX No

Example

 
 cmdline = (char *) alloca (strlen (args) + 4);
 cmdline[0] = strlen (args);
 strcpy (cmdline + 1, args);
 cmdline[strlen (args) + 1] = 13;

 if (v2loadimage (exec_file, cmdline, start_state))
  {
    printf ("Load failed for image %s\n", exec_file);
    exit (1);
  }

  edi_init (start_state);


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004