2 Copyright © 2006-2011, The AROS Development Team. All rights reserved.
6 #include <aros/config.h>
7 #include <aros/debug.h>
11 #include <proto/dos.h>
12 #include <proto/arossupport.h>
13 #include <proto/exec.h>
29 Locale_Deinitialize();
33 static void prettyprint(CONST_STRPTR str
, LONG minlen
)
36 LONG len
= strlen(str
);
38 RawPutChars(str
, len
);
40 for (i
= len
; i
< minlen
; i
++)
47 // eye-catching function name because this is what we'd see in the debugger
48 static void SNOOPY_breakpoint(void)
50 // interrupting makes only sense on "hosted" where we have a debugger
51 #if (AROS_FLAVOUR & AROS_FLAVOUR_EMULATION)
52 #if defined(__i386__) || defined(__x86_64__)
54 #elif defined(__powerpc__)
57 // TODO: other platforms
58 kprintf("[SNOOP] interrupt not supported on this platform\n");
64 void main_output(CONST_STRPTR action
, CONST_STRPTR target
, CONST_STRPTR option
,
65 IPTR result
, BOOL canInterrupt
, BOOL expand
)
67 char pathbuf
[MAX_STR_LEN
+1];
69 struct Task
*thistask
= SysBase
->ThisTask
;
70 STRPTR name
= thistask
->tc_Node
.ln_Name
;
72 if (setup
.onlyShowFails
&& result
) return;
75 if ( ! stricmp(name
, "wanderer:wanderer")) return;
76 if ( ! stricmp(name
, "new shell")) return;
77 if ( ! stricmp(name
, "newshell")) return;
78 if ( ! stricmp(name
, "boot shell")) return;
79 if ( ! stricmp(name
, "background cli")) return;
82 if (setup
.match
&& ! MatchPatternNoCase(setup
.parsedpattern
, name
))
84 // pattern doesn't fit
88 // FIXME: Can Forbid/Permit cause locks?
91 RawPutChars("SNOOP ", 7);
93 prettyprint(name
, setup
.nameLen
);
98 if (thistask
->tc_Node
.ln_Type
== NT_PROCESS
&& ((struct Process
*)thistask
)->pr_CLI
)
100 clinum
= ((struct Process
*)thistask
)->pr_TaskNum
;
103 kprintf(" [%d]", clinum
);
106 prettyprint(action
, setup
.actionLen
);
108 if (setup
.showPaths
&& target
!= NULL
)
112 //Expand filename to full path
113 target
= MyNameFromLock(((struct Process
*)thistask
)->pr_CurrentDir
,
114 (char *)target
, pathbuf
, MAX_STR_LEN
);
117 prettyprint(target
, setup
.targetLen
);
119 prettyprint(option
, setup
.optionLen
);
120 prettyprint(result
? MSG(MSG_OK
) : MSG(MSG_FAIL
), 0);
124 // We're calling the breakpoint function from the output function
125 // so that we don't have to check the setup parameters again.
126 // canInterrupt is for cases where a patch prints multiple lines.
127 if (canInterrupt
&& setup
.breakPoint
) SNOOPY_breakpoint();
131 void main_parsepattern(void)
135 if (!setup
.pattern
) return;
136 if (setup
.pattern
[0] == '\0') return;
138 Forbid(); // avoid that parsed pattern is used while we change it
139 setup
.parsedpattern
[0] = '\0';
140 if (ParsePatternNoCase(setup
.pattern
, setup
.parsedpattern
, PARSEDPATTERNLEN
) != -1)
148 void clean_exit(char *s
)