2 Copyright © 2006-2015, 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>
14 #include <proto/utility.h>
30 Locale_Deinitialize();
34 static void prettyprint(CONST_STRPTR str
, LONG minlen
)
37 LONG len
= strlen(str
);
39 RawPutChars(str
, len
);
41 for (i
= len
; i
< minlen
; i
++)
48 // eye-catching function name because this is what we'd see in the debugger
49 static void SNOOPY_breakpoint(void)
51 // interrupting makes only sense on "hosted" where we have a debugger
52 #if (AROS_FLAVOUR & AROS_FLAVOUR_EMULATION)
53 #if defined(__i386__) || defined(__x86_64__)
55 #elif defined(__powerpc__)
58 // TODO: other platforms
59 kprintf("[SNOOP] interrupt not supported on this platform\n");
65 void main_output(CONST_STRPTR action
, CONST_STRPTR target
, CONST_STRPTR option
,
66 IPTR result
, BOOL canInterrupt
, BOOL expand
)
68 char pathbuf
[MAX_STR_LEN
+1];
70 struct Task
*thistask
= FindTask(NULL
);
71 STRPTR name
= thistask
->tc_Node
.ln_Name
;
73 if (setup
.onlyShowFails
&& result
) return;
76 if ( ! Stricmp(name
, "wanderer:wanderer")) return;
77 if ( ! Stricmp(name
, "Shell")) return;
78 if ( ! Stricmp(name
, "new shell")) return;
79 if ( ! Stricmp(name
, "newshell")) return;
80 if ( ! Stricmp(name
, "boot shell")) return;
81 if ( ! Stricmp(name
, "background cli")) return;
84 if (setup
.match
&& ! MatchPatternNoCase(setup
.parsedpattern
, name
))
86 // pattern doesn't fit
90 // FIXME: Can Forbid/Permit cause locks?
93 RawPutChars("SNOOP ", 7);
95 prettyprint(name
, setup
.nameLen
);
100 if (thistask
->tc_Node
.ln_Type
== NT_PROCESS
&& ((struct Process
*)thistask
)->pr_CLI
)
102 clinum
= ((struct Process
*)thistask
)->pr_TaskNum
;
105 kprintf(" [%d]", clinum
);
108 prettyprint(action
, setup
.actionLen
);
110 if (setup
.showPaths
&& target
!= NULL
)
114 //Expand filename to full path
115 target
= MyNameFromLock(((struct Process
*)thistask
)->pr_CurrentDir
,
116 (char *)target
, pathbuf
, MAX_STR_LEN
);
119 prettyprint(target
, setup
.targetLen
);
121 prettyprint(option
, setup
.optionLen
);
122 prettyprint(result
? MSG(MSG_OK
) : MSG(MSG_FAIL
), 0);
126 // We're calling the breakpoint function from the output function
127 // so that we don't have to check the setup parameters again.
128 // canInterrupt is for cases where a patch prints multiple lines.
129 if (canInterrupt
&& setup
.breakPoint
) SNOOPY_breakpoint();
133 void main_parsepattern(void)
137 if (!setup
.pattern
) return;
138 if (setup
.pattern
[0] == '\0') return;
140 Forbid(); // avoid that parsed pattern is used while we change it
141 setup
.parsedpattern
[0] = '\0';
142 if (ParsePatternNoCase(setup
.pattern
, setup
.parsedpattern
, PARSEDPATTERNLEN
) != -1)
150 void clean_exit(char *s
)