Post by Paul FoxPost by Alexandros ManoussakisIn any case, I really want to see my patch into mgetty soon,
be patient. :-)
...
for the record, my patches were in a message on june 1 2004, rad's were
on sept 1, 2004.)
I hope I won't have to wait 4 years.
I'm picking up German just to get some better traction with Gert:
Gert, bitte finden sie die Zeit mein Patch zu benutzen !
Viele Leute werden dich danken! Open-source Projekts wollen activ und
lebend sein :-)
Updated patch follows to include your environmental suggestions,
(in code as well as in documentation). They worked nice for me.
Alex
diff -upr mgetty-1.1.36-orig/cnd.c mgetty-1.1.36/cnd.c
--- mgetty-1.1.36-orig/cnd.c 2005-04-17 04:55:43.000000000 -0700
+++ mgetty-1.1.36/cnd.c 2008-04-21 17:15:59.000000000 -0700
@@ -170,7 +170,7 @@ cndfind _P1((str), char *str)
p++;
}
}
- lprintf(L_JUNK, "CND: found: %s", *(cp->variable));
+ lprintf(L_NOISE, "CND: found: %s", *(cp->variable));
return;
}
}
@@ -221,7 +221,7 @@ void process_rockwell_mesg _P0 (void)
}
*p = 0;
- lprintf(L_JUNK, "CND: caller ID: %s", CallerId);
+ lprintf(L_NOISE, "CND: caller ID: %s", CallerId);
}
/* lookup Caller ID in CNDFILE, decide upon answering or not */
@@ -287,6 +287,7 @@ int cnd_call _P3((name, tty, dist_ring),
tty, CallerId, CallName, dist_ring, CalledNr, CONSOLE );
lprintf( L_NOISE, "CND: program \"%s\"", program );
+ setup_environment();
rc = system(program);
if ( rc < 0 )
diff -upr mgetty-1.1.36-orig/conf_mg.c mgetty-1.1.36/conf_mg.c
--- mgetty-1.1.36-orig/conf_mg.c 2006-01-01 09:13:18.000000000 -0800
+++ mgetty-1.1.36/conf_mg.c 2008-03-29 09:55:32.000000000 -0700
@@ -84,6 +84,7 @@ struct conf_data_mgetty c = {
{ "rings", {1}, CT_INT, C_PRESET },
{ "msn-list", {(p_int) NULL}, CT_CHAT, C_EMPTY },
{ "get-cnd-chat", {0}, CT_CHAT, C_EMPTY },
+ { "cid-program", {(p_int) NULL}, CT_STRING, C_EMPTY },
{ "cnd-program", {(p_int) NULL}, CT_STRING, C_EMPTY },
{ "answer-chat", {0}, CT_CHAT, C_EMPTY },
{ "answer-chat-timeout", {80}, CT_INT, C_PRESET },
diff -upr mgetty-1.1.36-orig/conf_mg.h mgetty-1.1.36/conf_mg.h
--- mgetty-1.1.36-orig/conf_mg.h 2005-11-24 08:57:58.000000000 -0800
+++ mgetty-1.1.36/conf_mg.h 2008-03-29 09:55:32.000000000 -0700
@@ -33,6 +33,7 @@ extern struct conf_data_mgetty {
rings_wanted, /* number of RINGs */
msn_list, /* ISDN MSNs (dist.ring) */
getcnd_chat, /* get caller ID (for ELINK)*/
+ cid_program, /* notify about caller ID */
cnd_program, /* accept caller? */
answer_chat, /* ATA...CONNECT...""...\n */
answer_chat_timeout, /* longer as S7! */
diff -upr mgetty-1.1.36-orig/doc/mgetty.texi-in mgetty-1.1.36/doc/mgetty.texi-in
--- mgetty-1.1.36-orig/doc/mgetty.texi-in 2005-12-30 13:43:49.000000000 -0800
+++ mgetty-1.1.36/doc/mgetty.texi-in 2008-04-21 17:19:40.000000000 -0700
@@ -638,12 +638,20 @@ Some telephone companies provide a servi
your phone is ringing. Not all providers support it, and you'll have to
ask for it.
-If your modem is able to retrieve callerid information, and @code{mgetty}
+Right now, Caller ID in @code{mgetty} works for most modem variants out there,
+ZyXEL, Rockwell, ELSA and isdn4linux among them.
+
+If your modem is able to retrieve callerid information, @code{mgetty} can
+report that information by passing it as arguments to the @code{cid-program}
+statement in @file{mgetty.config}. You may point @code{cid-program} to a
+script that writes to a logfile, displays a popup on your terminal, etc.
+@code{cid-program} takes the same arguments as @code{cnd-program} (see below)
+but its exit code is ignored.
+
+In addition to the ability of reporting callerid information, if @code{mgetty}
is compiled with @code{CNDFILE} defined in @file{policy.h}, @code{mgetty}
-can check the caller's number before answering the phone. (Right now, it
-works for most variants out there, ZyXEL, Rockwell, ELSA and isdn4linux
-among them). If @code{CNDFILE} is undefined, or if the
-file specified does not exist, all calls will be allowed.
+can check the caller's number before answering the phone. If @code{CNDFILE} is
+undefined, or if the file specified does not exist, all calls will be allowed.
One important thing: for most analog modems, you @strong{must} set the
number of RINGs to wait for to two (2) or higher (set @samp{rings 2} in
@@ -1042,6 +1050,13 @@ if the static Caller ID selection in CND
or if you want to use the Caller ID data for other purposes (displaying,
for example). @xref{Caller-ID}.
+@item @code{cid-program} @var{pathname}
+
+Specify a program to be run as soon as Caller ID information comes in
+(typically between 1st and 2nd ring). If Caller ID info is not available by
+the 3rd ring, still run the program (to report the time that the phone rang).
+This allows mgetty to behave like a caller-id box. @xref{Caller-ID}.
+
@item @code{answer-chat} @var{chat sequence}
This is the command sequence that is used to answer a phone call. Usually
@@ -1489,11 +1504,11 @@ A sample command line might look like th
@BINDIR@/new_fax 0 "+49 89 3243328" 1 @FAX_SPOOL@/ff-01.a123
@end example
-In addition, some environment variables are provide: @code{CALLER_ID},
+In addition, some environment variables are provided: @code{CALLER_ID},
@code{CALLER_NAME}, @code{CALLED_ID} (Caller ID and destination ISDN MSN,
-if available and supported by your modem), and @code{DEVICE} (the full
-name of the tty device, if you want to process faxes differently
-depending on the line they came in).
+if available and supported by your modem), @code{CALL_DATE}, @code{CALL_TIME},
+and @code{DEVICE} (the full name of the tty device, if you want to process
+faxes differently depending on the line they came in).
Such a ``notify program'' could print out the fax, convert it into a MIME
metamail and send it away, display it in an X window (this a little bit
diff -upr mgetty-1.1.36-orig/login.c mgetty-1.1.36/login.c
--- mgetty-1.1.36-orig/login.c 2003-12-05 14:28:58.000000000 -0800
+++ mgetty-1.1.36/login.c 2008-04-21 17:23:42.000000000 -0700
@@ -373,6 +373,10 @@ void setup_environment _P0(void)
{
if ( *CallerId )
set_env_var( "CALLER_ID", CallerId );
+ if ( *CallDate )
+ set_env_var( "CALL_DATE", CallDate );
+ if ( *CallTime )
+ set_env_var( "CALL_TIME", CallTime );
if ( *CallName )
set_env_var( "CALLER_NAME", CallName );
if ( *CalledNr )
diff -upr mgetty-1.1.36-orig/mgetty.c mgetty-1.1.36/mgetty.c
--- mgetty-1.1.36-orig/mgetty.c 2006-01-01 09:13:18.000000000 -0800
+++ mgetty-1.1.36/mgetty.c 2008-04-13 00:48:10.000000000 -0700
@@ -279,6 +279,7 @@ int main _P2((argc, argv), int argc, cha
int rings_wanted;
int rings = 0;
int dist_ring = 0; /* type of RING detected */
+ boolean cid_program_ran = FALSE;/* Only run cid_program once per call */
#if defined(_3B1_) || defined(MEIBE) || defined(sysV68)
extern struct passwd *getpwuid(), *getpwnam();
@@ -548,6 +549,7 @@ int main _P2((argc, argv), int argc, cha
*/
CallTime = CallName = CalledNr = ""; /* dirty */
CallerId = "none";
+ cid_program_ran = FALSE;
clean_line( STDIN, 3); /* let line settle */
rmlocks();
mgetty_state = St_waiting;
@@ -738,14 +740,26 @@ int main _P2((argc, argv), int argc, cha
while ( rings < rings_wanted )
{
- if ( wait_for_ring( STDIN, c_chat(msn_list),
- ( c_bool(ringback) && rings == 0 )
- ? c_int(ringback_time) : ring_chat_timeout,
- ring_chat_actions, &what_action,
- &dist_ring ) == FAIL)
+ int w;
+
+ w = wait_for_ring( STDIN, c_chat(msn_list),
+ ( c_bool(ringback) && rings == 0 )
+ ? c_int(ringback_time) : ring_chat_timeout,
+ ring_chat_actions, &what_action,
+ &dist_ring );
+
+ /* Inform about Caller ID. If we haven't gotten the info by 3rd
+ * ring, it's hopeless; just report that the phone rang. */
+ if ( c_isset(cid_program) && !cid_program_ran
+ && (rings >= 2 || *CallName || strcmp(CallerId, "none")) )
{
- break; /* ringing stopped, or "action" */
+ cnd_call( c_string(cid_program), Device, dist_ring );
+ cid_program_ran = TRUE;
}
+
+ if ( w == FAIL )
+ break; /* ringing stopped, or "action" */
+
rings++;
}
diff -upr mgetty-1.1.36-orig/mgetty.h mgetty-1.1.36/mgetty.h
--- mgetty-1.1.36-orig/mgetty.h 2006-01-01 09:13:18.000000000 -0800
+++ mgetty-1.1.36/mgetty.h 2008-04-21 17:12:27.000000000 -0700
@@ -296,6 +296,7 @@ void setup_environment _PROTO(( void ));
extern char *Connect;
extern char *CallerId;
+extern char *CallDate;
extern char *CallTime;
extern char *CallName;
extern char *CalledNr;
-- end of message --