The Machine Perception Toolbox

[Introduction]- [News]- [Download]- [Screenshots]- [Manual (pdf)]- [Forums]- [API Reference]- [Repository ]

 

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

command.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Classes

struct  _cmd

Defines

#define cmd_next(c)   ((c)->next)

Typedefs

typedef _cmd CMD

Functions

void cmd_free (CMD *cmd)
CMDcmd_new (RULE *rule, LIST *targets, LIST *sources, LIST *shell)


Define Documentation

#define cmd_next c   )     ((c)->next)
 

Definition at line 58 of file command.h.

Referenced by make1d().


Typedef Documentation

typedef struct _cmd CMD
 

Definition at line 38 of file command.h.

Referenced by cmd_free(), cmd_new(), make1c(), make1cmds(), and make1d().


Function Documentation

void cmd_free CMD cmd  ) 
 

Definition at line 100 of file command.c.

References _cmd::args, _cmd::buf, CMD, list_free(), lol_free(), and _cmd::shell.

Referenced by cmd_new(), and make1d().

00101 {
00102         lol_free( &cmd->args );
00103         list_free( cmd->shell );
00104     free( cmd->buf );
00105         free( (char *)cmd );
00106 }

Here is the call graph for this function:

CMD* cmd_new RULE rule,
LIST targets,
LIST sources,
LIST shell
 

Definition at line 35 of file command.c.

References _rule::actions, _cmd::args, _cmd::buf, CMD, cmd_free(), rule_actions::command, LIST, list_next, lol_add(), lol_init(), _cmd::next, _cmd::rule, RULE, s, _cmd::shell, _list::string, and var_string().

Referenced by make1cmds().

00040 {
00041     CMD *cmd = (CMD *)malloc( sizeof( CMD ) );
00042     /* lift line-length limitation entirely when JAMSHELL is just "%" */
00043     int no_limit = ( shell && !strcmp(shell->string,"%") && !list_next(shell) );
00044     int max_line = MAXLINE;
00045     int allocated = -1;
00046 
00047     cmd->rule = rule;
00048     cmd->shell = shell;
00049     cmd->next = 0;
00050 
00051     lol_init( &cmd->args );
00052     lol_add( &cmd->args, targets );
00053     lol_add( &cmd->args, sources );
00054     cmd->buf = 0;
00055 
00056     do
00057     {
00058         free(cmd->buf); /* free any buffer from previous iteration */
00059         
00060         cmd->buf = (char*)malloc(max_line + 1);
00061         
00062         if (cmd->buf == 0)
00063             break;
00064         
00065         allocated = var_string( rule->actions->command, cmd->buf, max_line, &cmd->args );
00066         
00067         max_line = max_line * 2;
00068     }
00069     while( allocated < 0 && max_line < INT_MAX / 2 );
00070 
00071     if ( !no_limit )
00072     {
00073         /* Bail if the result won't fit in MAXLINE */
00074         char *s = cmd->buf;
00075         while ( *s )
00076         {
00077             size_t l = strcspn( s, "\n" );
00078             
00079             if ( l > MAXLINE )
00080             {
00081                 /* We don't free targets/sources/shell if bailing. */
00082                 cmd_free( cmd );
00083                 return 0;
00084             }
00085             
00086             s += l;
00087             if ( *s )
00088                 ++s;
00089         }
00090     }
00091 
00092     return cmd;
00093 }

Here is the call graph for this function:


Generated on Mon Nov 8 17:07:56 2004 for MPT by  doxygen 1.3.9.1