ajsys.c

Datatypes:
none System utility functions


Datatype: none

Sections:
Argument list manipulation functionsMiscellaneous
System cast functionsMiscellaneous
System functions for filesMiscellaneous
Wrappers to commandsMiscellaneous
Wrappers to C functionsMiscellaneous
executing commandsMiscellaneous
executing programsMiscellaneous
Miscellaneous system functionsMiscellaneous
piped commandsMiscellaneous
exitMiscellaneous


Section: Argument list manipulation functions

Function for manipulating argument list.

Functions:
ajSysArglistBuildCGenerates a program name and argument list from a command line string.
ajSysArglistBuildSGenerates a program name and argument list from a command line string.
ajSysArglistFreeFree memory in an argument list allocated by ajSysArgList


Function ajSysArglistBuildC

Generates a program name and argument list from a command line string.

Prototype

AjBool ajSysArglistBuildC (
      const char* cmdlinetxt,
      char** Pname,
      char*** PParglist
);

TypeNameRead/WriteDescription
const char*cmdlinetxtInputCommand line.
char**PnameOutputProgram name.
char***PParglistOutputArgument list.
AjBool RETURNajTrue on success.

From EMBOSS 6.3.0


Function ajSysArglistBuildS

Generates a program name and argument list from a command line string.

Prototype

AjBool ajSysArglistBuildS (
      const AjPStr cmdline,
      char** Pname,
      char*** PParglist
);

TypeNameRead/WriteDescription
const AjPStrcmdlineInputCommand line.
char**PnameOutputProgram name.
char***PParglistOutputArgument list.
AjBool RETURNajTrue on success.

From EMBOSS 6.3.0


Function ajSysArglistFree

Free memory in an argument list allocated by ajSysArgList

Prototype

void ajSysArglistFree (
      char*** PParglist
);

TypeNameRead/WriteDescription
char***PParglistOutputArgument list.
void RETURN

From EMBOSS 5.0.0


Section: System cast functions

Function for casting one datatype to another.

Functions:
ajSysCastItocConvert Int to Char Needed for very fussy compilers i.e. Digital C
ajSysCastItoucConvert Int to Unsigned Char Needed for very fussy compilers i.e. Digital C


Function ajSysCastItoc

Convert Int to Char Needed for very fussy compilers i.e. Digital C

Prototype

char ajSysCastItoc (
      ajint v
);

TypeNameRead/WriteDescription
ajintvInputinteger
char RETURNCharacter cast

From EMBOSS 5.0.0


Function ajSysCastItouc

Convert Int to Unsigned Char Needed for very fussy compilers i.e. Digital C

Prototype

unsigned char ajSysCastItouc (
      ajint v
);

TypeNameRead/WriteDescription
ajintvInputinteger
unsigned char RETURNUnsigned character cast

From EMBOSS 5.0.0


Section: System functions for files

System functions for files.

Functions:
ajSysFileRmrfCForcibly delete a directory tree
ajSysFileUnlinkCDeletes a file or link
ajSysFileUnlinkSDeletes a file or link
ajSysFileWhichGets the Basename of a file then searches $PATH sequentially until it finds a user-EXECUTABLE file of the same name.
ajSysFileWhichEnvGets the Basename of a file then searches $PATH sequentially until it finds a user-EXECUTABLE file of the same name. Reentrant.
ajSysGetHomedirGet the home directory of the current user
ajSysGetHomedirFromNameGet a home directory location from a username


Function ajSysFileRmrfC

Forcibly delete a directory tree

Prototype

AjBool ajSysFileRmrfC (
      const char* path
);

TypeNameRead/WriteDescription
const char*pathInputDirectory path
AjBool RETURNtrue if deleted false otherwise

From EMBOSS 6.3.0


Function ajSysFileUnlinkC

Deletes a file or link

Prototype

AjBool ajSysFileUnlinkC (
      const char* filename
);

TypeNameRead/WriteDescription
const char*filenameInputFilename in AjStr.
AjBool RETURNtrue if deleted false otherwise

From EMBOSS 6.3.0


Function ajSysFileUnlinkS

Deletes a file or link

Prototype

AjBool ajSysFileUnlinkS (
      const AjPStr filename
);

TypeNameRead/WriteDescription
const AjPStrfilenameInputFilename in AjStr.
AjBool RETURNtrue if deleted false otherwise

From EMBOSS 6.3.0


Function ajSysFileWhich

Gets the Basename of a file then searches $PATH sequentially until it finds a user-EXECUTABLE file of the same name.

Prototype

AjBool ajSysFileWhich (
      AjPStr* Pfilename
);

TypeNameRead/WriteDescription
AjPStr*PfilenameModifyFilename in AjStr, replaced by full pathname
AjBool RETURNTrue if executable found, false otherwise

From EMBOSS 5.0.0


Function ajSysFileWhichEnv

Gets the Basename of a file then searches $PATH sequentially until it finds a user-EXECUTABLE file of the same name. Reentrant.

Prototype

AjBool ajSysFileWhichEnv (
      AjPStr* Pfilename,
      char* const[] env
);

TypeNameRead/WriteDescription
AjPStr*PfilenameModifyFilename in AjStr, replaced by full pathname
char* const[]envInputEnvironment
AjBool RETURNTrue if executable found, false otherwise

From EMBOSS 5.0.0


Function ajSysGetHomedir

Get the home directory of the current user

Prototype

char* ajSysGetHomedir (
      void
);

TypeNameRead/WriteDescription
char* RETURNHome directory or NULL

From EMBOSS 6.3.0


Function ajSysGetHomedirFromName

Get a home directory location from a username

Prototype

char* ajSysGetHomedirFromName (
      const char* username
);

TypeNameRead/WriteDescription
const char*usernameInputUsername
char* RETURNHome directory or NULL

From EMBOSS 6.3.0


Section: Wrappers to commands

Functions for invoking commands

Functions:
ajSysCommandCopyCCopy a file
ajSysCommandCopySCopy a file
ajSysCommandMakedirCDelete a file
ajSysCommandMakedirSDelete a file
ajSysCommandRemoveCDelete a file
ajSysCommandRemoveSDelete a file
ajSysCommandRemovedirCDelete a file
ajSysCommandRemovedirSDelete a file
ajSysCommandRenameCRename a file
ajSysCommandRenameSRename a file


Function ajSysCommandCopyC

Copy a file

Prototype

AjBool ajSysCommandCopyC (
      const char* name,
      const char* name2
);

TypeNameRead/WriteDescription
const char*nameInputSource filename
const char*name2InputTarget filename
AjBool RETURNTrue on success

From EMBOSS 6.3.0


Function ajSysCommandCopyS

Copy a file

Prototype

AjBool ajSysCommandCopyS (
      const AjPStr strname,
      const AjPStr strname2
);

TypeNameRead/WriteDescription
const AjPStrstrnameInputSource filename
const AjPStrstrname2InputTarget filename
AjBool RETURNTrue on success

From EMBOSS 6.3.0


Function ajSysCommandMakedirC

Delete a file

Prototype

AjBool ajSysCommandMakedirC (
      const char* name
);

TypeNameRead/WriteDescription
const char*nameInputDirectory
AjBool RETURNTrue on success

From EMBOSS 6.3.0


Function ajSysCommandMakedirS

Delete a file

Prototype

AjBool ajSysCommandMakedirS (
      const AjPStr strname
);

TypeNameRead/WriteDescription
const AjPStrstrnameInputDirectory
AjBool RETURNTrue on success

From EMBOSS 6.3.0


Function ajSysCommandRemoveC

Delete a file

Prototype

AjBool ajSysCommandRemoveC (
      const char* name
);

TypeNameRead/WriteDescription
const char*nameInputFilename
AjBool RETURNTrue on success

From EMBOSS 6.3.0


Function ajSysCommandRemoveS

Delete a file

Prototype

AjBool ajSysCommandRemoveS (
      const AjPStr strname
);

TypeNameRead/WriteDescription
const AjPStrstrnameInputFilename
AjBool RETURNTrue on success

From EMBOSS 6.3.0


Function ajSysCommandRemovedirC

Delete a file

Prototype

AjBool ajSysCommandRemovedirC (
      const char* name
);

TypeNameRead/WriteDescription
const char*nameInputDirectory
AjBool RETURNTrue on success

From EMBOSS 6.3.0


Function ajSysCommandRemovedirS

Delete a file

Prototype

AjBool ajSysCommandRemovedirS (
      const AjPStr strname
);

TypeNameRead/WriteDescription
const AjPStrstrnameInputDirectory
AjBool RETURNTrue on success

From EMBOSS 6.3.0


Function ajSysCommandRenameC

Rename a file

Prototype

AjBool ajSysCommandRenameC (
      const char* name,
      const char* name2
);

TypeNameRead/WriteDescription
const char*nameInputSource filename
const char*name2InputTarget filename
AjBool RETURNTrue on success

From EMBOSS 6.3.0


Function ajSysCommandRenameS

Rename a file

Prototype

AjBool ajSysCommandRenameS (
      const AjPStr strname,
      const AjPStr strname2
);

TypeNameRead/WriteDescription
const AjPStrstrnameInputSource filename
const AjPStrstrname2InputTarget filename
AjBool RETURNTrue on success

From EMBOSS 6.3.0


Section: Wrappers to C functions

Functions for calling or substituting C-functions.

Functions:
ajSysFuncFdopenPlace non-ANSI fdopen here
ajSysFuncFgetsAn fgets replacement that will cope with Mac OSX <CR> files
ajSysFuncFopenAn fopen replacement to cope with cygwin and windows
ajSysFuncSocketSocket function coping with UNIX and WIN32
ajSysFuncStrdupDuplicate BSD strdup function for very strict ANSI compilers
ajSysFuncStrtokstrtok that doesn't corrupt the source string
ajSysFuncStrtokRReentrant strtok that doesn't corrupt the source string. This function uses a string buffer provided by the caller.


Function ajSysFuncFdopen

Place non-ANSI fdopen here

Prototype

FILE* ajSysFuncFdopen (
      ajint filedes,
      const char* mode
);

TypeNameRead/WriteDescription
ajintfiledesInputfile descriptor
const char*modeInputfile mode
FILE* RETURNfile pointer

From EMBOSS 5.0.0


Function ajSysFuncFgets

An fgets replacement that will cope with Mac OSX <CR> files

Prototype

char* ajSysFuncFgets (
      char* buf,
      int size,
      FILE* fp
);

TypeNameRead/WriteDescription
char*bufOutputbuffer
intsizeInputmaximum length to read
FILE*fpModifystream
char* RETURNbuf or NULL

From EMBOSS 5.0.0


Function ajSysFuncFopen

An fopen replacement to cope with cygwin and windows

Prototype

FILE* ajSysFuncFopen (
      const char* name,
      const char* flags
);

TypeNameRead/WriteDescription
const char*nameInputfile to open
const char*flagsInputr/w/a flags
FILE* RETURNfile or NULL

From EMBOSS 5.0.0


Function ajSysFuncSocket

Socket function coping with UNIX and WIN32

Prototype

SOCKRET ajSysFuncSocket (
      int domain,
      int type,
      int protocol
);

TypeNameRead/WriteDescription
intdomainInputDomain
inttypeInputType
intprotocolInputProtocol
SOCKRET RETURNUniversal (UNIX/WIN32) socket value

From EMBOSS 6.3.0


Function ajSysFuncStrdup

Duplicate BSD strdup function for very strict ANSI compilers

Prototype

char* ajSysFuncStrdup (
      const char* dupstr
);

TypeNameRead/WriteDescription
const char*dupstrInputstring to duplicate
char* RETURNText string as for strdup

From EMBOSS 5.0.0


Function ajSysFuncStrtok

strtok that doesn't corrupt the source string

Prototype

char* ajSysFuncStrtok (
      const char* srcstr,
      const char* delimstr
);

TypeNameRead/WriteDescription
const char*srcstrInputsource string
const char*delimstrInputdelimiter string
char* RETURNpointer or NULL when nothing is found

From EMBOSS 5.0.0


Function ajSysFuncStrtokR

Reentrant strtok that doesn't corrupt the source string. This function uses a string buffer provided by the caller.

Prototype

char* ajSysFuncStrtokR (
      const char* srcstr,
      const char* delimstr,
      const char** ptrptr,
      AjPStr* buf
);

TypeNameRead/WriteDescription
const char*srcstrModifysource string
const char*delimstrInputdelimiter string
const char**ptrptrModifyptr save
AjPStr*bufOutputresult buffer
char* RETURNpointer or NULL

From EMBOSS 5.0.0


Section: executing commands

Functions for executing commands

Functions:
ajSysExecCExec a command line as if from the C shell
ajSysExecSExec a command line as if from the C shell
ajSysExecEnvCExec a command line as if from the C shell
ajSysExecEnvSExec a command line as if from the C shell
ajSysExecLocaleCExec a command line as if from the C shell with a defined locale variable.
ajSysExecLocaleSExec a command line as if from the C shell with a defined locale variable.
ajSysExecOutnameCExec a command line as if from the C shell with standard output redirected to and overwriting a named file
ajSysExecOutnameSExec a command line as if from the C shell with standard output redirected to and overwriting a named file
ajSysExecOutnameAppendCExec a command line as if from the C shell with standard output redirected and appended to a named file
ajSysExecOutnameAppendSExec a command line as if from the C shell with standard output redirected and appended to a named file
ajSysExecOutnameErrCExec a command line as if from the C shell with standard output and standard error redirected to and overwriting a named file
ajSysExecOutnameErrSExec a command line as if from the C shell with standard output and standard error redirected to and overwriting a named file
ajSysExecOutnameErrAppendCExec a command line as if from the C shell with standard output and standard error redirected and appended to a named file
ajSysExecOutnameErrAppendSExec a command line as if from the C shell with standard output and standard error redirected and appended to a named file
ajSysExecPathCExec a command line with a test for the program name in the current path
ajSysExecPathSExec a command line with a test for the program name in the current path
ajSysExecRedirectCExecute an application redirecting its stdin/out to pipe fds


Function ajSysExecC

Exec a command line as if from the C shell

Prototype

ajint ajSysExecC (
      const char* cmdlinetxt
);

TypeNameRead/WriteDescription
const char*cmdlinetxtInputThe command line
ajint RETURNExit status

From EMBOSS 6.3.0


Function ajSysExecS

Exec a command line as if from the C shell

Prototype

ajint ajSysExecS (
      const AjPStr cmdline
);

TypeNameRead/WriteDescription
const AjPStrcmdlineInputThe command line
ajint RETURNExit status

From EMBOSS 6.3.0


Function ajSysExecEnvC

Exec a command line as if from the C shell

Prototype

ajint ajSysExecEnvC (
      const char* cmdlinetxt,
      char* const[] env
);

TypeNameRead/WriteDescription
const char*cmdlinetxtInputThe command line
char* const[]envInputThe environment
ajint RETURNExit status

From EMBOSS 6.3.0


Function ajSysExecEnvS

Exec a command line as if from the C shell

Prototype

ajint ajSysExecEnvS (
      const AjPStr cmdline,
      char* const[] env
);

TypeNameRead/WriteDescription
const AjPStrcmdlineInputThe command line
char* const[]envInputThe environment
ajint RETURNExit status

From EMBOSS 6.3.0


Function ajSysExecLocaleC

Exec a command line as if from the C shell with a defined locale variable.

Prototype

ajint ajSysExecLocaleC (
      const char* cmdlinetxt,
      const char* localetxt
);

TypeNameRead/WriteDescription
const char*cmdlinetxtInputThe command line
const char*localetxtInputThe locale value
ajint RETURNExit status

From EMBOSS 6.3.0


Function ajSysExecLocaleS

Exec a command line as if from the C shell with a defined locale variable.

Prototype

ajint ajSysExecLocaleS (
      const AjPStr cmdline,
      const AjPStr localestr
);

TypeNameRead/WriteDescription
const AjPStrcmdlineInputThe command line
const AjPStrlocalestrInputThe locale value
ajint RETURNExit status

From EMBOSS 6.3.0


Function ajSysExecOutnameC

Exec a command line as if from the C shell with standard output redirected to and overwriting a named file

Prototype

ajint ajSysExecOutnameC (
      const char* cmdlinetxt,
      const char* outfnametxt
);

TypeNameRead/WriteDescription
const char*cmdlinetxtInputThe command line
const char*outfnametxtInputThe output file name
ajint RETURNExit status

From EMBOSS 6.3.0


Function ajSysExecOutnameS

Exec a command line as if from the C shell with standard output redirected to and overwriting a named file

Prototype

ajint ajSysExecOutnameS (
      const AjPStr cmdline,
      const AjPStr outfname
);

TypeNameRead/WriteDescription
const AjPStrcmdlineInputThe command line
const AjPStroutfnameInputThe output file name
ajint RETURNExit status

From EMBOSS 6.3.0


Function ajSysExecOutnameAppendC

Exec a command line as if from the C shell with standard output redirected and appended to a named file

Prototype

ajint ajSysExecOutnameAppendC (
      const char* cmdlinetxt,
      const char* outfnametxt
);

TypeNameRead/WriteDescription
const char*cmdlinetxtInputThe command line
const char*outfnametxtInputThe output file name
ajint RETURNExit status

From EMBOSS 6.3.0


Function ajSysExecOutnameAppendS

Exec a command line as if from the C shell with standard output redirected and appended to a named file

Prototype

ajint ajSysExecOutnameAppendS (
      const AjPStr cmdline,
      const AjPStr outfname
);

TypeNameRead/WriteDescription
const AjPStrcmdlineInputThe command line
const AjPStroutfnameInputThe output file name
ajint RETURNExit status

From EMBOSS 6.3.0


Function ajSysExecOutnameErrC

Exec a command line as if from the C shell with standard output and standard error redirected to and overwriting a named file

Prototype

ajint ajSysExecOutnameErrC (
      const char* cmdlinetxt,
      const char* outfnametxt
);

TypeNameRead/WriteDescription
const char*cmdlinetxtInputThe command line
const char*outfnametxtInputThe output file name
ajint RETURNExit status

From EMBOSS 6.3.0


Function ajSysExecOutnameErrS

Exec a command line as if from the C shell with standard output and standard error redirected to and overwriting a named file

Prototype

ajint ajSysExecOutnameErrS (
      const AjPStr cmdline,
      const AjPStr outfname
);

TypeNameRead/WriteDescription
const AjPStrcmdlineInputThe command line
const AjPStroutfnameInputThe output file name
ajint RETURNExit status

From EMBOSS 6.3.0


Function ajSysExecOutnameErrAppendC

Exec a command line as if from the C shell with standard output and standard error redirected and appended to a named file

Prototype

ajint ajSysExecOutnameErrAppendC (
      const char* cmdlinetxt,
      const char* outfnametxt
);

TypeNameRead/WriteDescription
const char*cmdlinetxtInputThe command line
const char*outfnametxtInputThe output file name
ajint RETURNExit status

From EMBOSS 6.3.0


Function ajSysExecOutnameErrAppendS

Exec a command line as if from the C shell with standard output and standard error redirected and appended to a named file

Prototype

ajint ajSysExecOutnameErrAppendS (
      const AjPStr cmdline,
      const AjPStr outfname
);

TypeNameRead/WriteDescription
const AjPStrcmdlineInputThe command line
const AjPStroutfnameInputThe output file name
ajint RETURNExit status

From EMBOSS 6.3.0


Function ajSysExecPathC

Exec a command line with a test for the program name in the current path

Prototype

ajint ajSysExecPathC (
      const char* cmdlinetxt
);

TypeNameRead/WriteDescription
const char*cmdlinetxtInputThe command line
ajint RETURNExit status

From EMBOSS 6.3.0


Function ajSysExecPathS

Exec a command line with a test for the program name in the current path

Prototype

ajint ajSysExecPathS (
      const AjPStr cmdline
);

TypeNameRead/WriteDescription
const AjPStrcmdlineInputThe command line
ajint RETURNExit status

From EMBOSS 6.3.0


Function ajSysExecRedirectC

Execute an application redirecting its stdin/out to pipe fds

Prototype

AjBool ajSysExecRedirectC (
      const char* cmdlinetxt,
      int** pipeto,
      int** pipefrom
);

TypeNameRead/WriteDescription
const char*cmdlinetxtInputCommand string. The string may end with a trailing pipe character.
int**pipetoOutputpipes to the process
int**pipefromOutputpipes from the process
AjBool RETURNTrue on success

From EMBOSS 6.3.0


Section: executing programs

Functions for executing programs

Functions:
ajSysExecprogNowaitCExec a command line with no parent wait
ajSysExecprogNowaitSExec a command line with no parent wait


Function ajSysExecprogNowaitC

Exec a command line with no parent wait

Prototype

ajint ajSysExecprogNowaitC (
      const char* prog,
      char* const[] arg,
      char* const[] env
);

TypeNameRead/WriteDescription
const char*progInputThe command line
char* const[]argInputArgument list
char* const[]envInputAn environment
ajint RETURNExit status

From EMBOSS 6.4.0


Function ajSysExecprogNowaitS

Exec a command line with no parent wait

Prototype

ajint ajSysExecprogNowaitS (
      const AjPStr progstr,
      char* const[] arg,
      char* const[] env
);

TypeNameRead/WriteDescription
const AjPStrprogstrInputThe command line
char* const[]argInputArgument list
char* const[]envInputAn environment
ajint RETURNExit status

From EMBOSS 6.4.0


Section: Miscellaneous system functions

Miscellaneous system functions

Functions:
ajSysCanonSets or unsets TTY canonical mode
ajSysFdFromSocketReturn a file descriptor from a UNIX of Windows socket
ajSysSocketcloseCloses a UNIX or WIN32 socket
ajSysTimeoutSetSets an alarm abort timeout for UNIX and Windows
ajSysTimeoutUnsetUnsets an alarm abort timeout for UNIX and Windows


Function ajSysCanon

Sets or unsets TTY canonical mode

Prototype

void ajSysCanon (
      AjBool state
);

TypeNameRead/WriteDescription
AjBoolstateInputstate=true sets canon state=false sets noncanon
void RETURN

From EMBOSS 1.0.0


Function ajSysFdFromSocket

Return a file descriptor from a UNIX of Windows socket

Prototype

FILE* ajSysFdFromSocket (
      const struct AJSOCKET sock,
      const char* mode
);

TypeNameRead/WriteDescription
const struct AJSOCKETsockInputAJAX socket structure
const char*modeInputOpening mode ("r" or "a")
FILE* RETURNFile descriptor

From EMBOSS 6.3.0


Function ajSysSocketclose

Closes a UNIX or WIN32 socket

Prototype

void ajSysSocketclose (
      struct AJSOCKET sock
);

TypeNameRead/WriteDescription
struct AJSOCKETsockModifyAJAX socket structure
void RETURN

From EMBOSS 6.3.0


Function ajSysTimeoutSet

Sets an alarm abort timeout for UNIX and Windows

Prototype

int ajSysTimeoutSet (
      struct AJTIMEOUT* ts
);

TypeNameRead/WriteDescription
struct AJTIMEOUT*tsModifyAJAX timeout structure
int RETURN0 = success -1 = error

From EMBOSS 6.3.0


Function ajSysTimeoutUnset

Unsets an alarm abort timeout for UNIX and Windows

Prototype

int ajSysTimeoutUnset (
      struct AJTIMEOUT* ts
);

TypeNameRead/WriteDescription
struct AJTIMEOUT*tsModifyAJAX timeout structure
int RETURN0 = success -1 = error

From EMBOSS 6.3.0


Section: piped commands

system command lines piped to a file

Functions:
ajSysCreateInpipeCReturn a new file object from which to read the output from a command.
ajSysCreateInpipeSReturn a new file object from which to read the output from a command.


Function ajSysCreateInpipeC

Return a new file object from which to read the output from a command.

Prototype

AjPFile ajSysCreateInpipeC (
      const char* cmdlinetxt
);

TypeNameRead/WriteDescription
const char*cmdlinetxtInputCommand string. The string may end with a trailing pipe character.
AjPFile RETURNNew file object.

From EMBOSS 6.3.0


Function ajSysCreateInpipeS

Return a new file object from which to read the output from a command.

Prototype

AjPFile ajSysCreateInpipeS (
      const AjPStr command
);

TypeNameRead/WriteDescription
const AjPStrcommandInputCommand string. The string may end with a trailing pipe character.
AjPFile RETURNNew file object.

From EMBOSS 6.3.0


Section: exit

Functions called on exit from the program by ajExit to do any necessary cleanup and to report internal statistics to the debug file

Functions:
ajSysExitCleans up system internals memory


Function ajSysExit

Cleans up system internals memory

Prototype

void ajSysExit (
      void
);

TypeNameRead/WriteDescription
void RETURN

From EMBOSS 4.0.0