faxd/TagLine.c++
/*
 * Read in the PCF font to use for imaging the tag line and
 * preformat as much of the tag line as possible.
 */
Read in the PCF font to use for imaging the tag line and
preformat as much of the tag line as possible.
Read in the PCF font to use for imaging the tag line and preformat as much of the tag line as possible .
void
FaxModem::setupTagLine(const FaxRequest& req, const fxStr& tagLineFmt, const fxStr& locale, const fxStr& tz)
{
    if (tagLineFont == NULL)
	tagLineFont = new PCFFont;
    if (!tagLineFont->isReady() && conf.tagLineFontFile != "")
	(void) tagLineFont->read(conf.tagLineFontFile);
    tagLineLocale = locale;
#ifdef LC_CTYPE
    setlocale(LC_CTYPE, tagLineLocale);         
#endif
#ifdef LC_TIME
    setlocale(LC_TIME, tagLineLocale);          
#endif
    bool isutf8 = false;
#if HAS_LANGINFO
    isutf8 = (strcmp(nl_langinfo(CODESET), "UTF-8") == 0);
    tagLine.setUTF8(isutf8);
#endif
    if (tz != "") setenv("TZ", tz, 1);
    time_t t = Sys::now();
    tm* tm = localtime(&t);
    char line[1024];
    strftime(line, sizeof (line)-1, tagLineFmt, tm);
    tagLine = line;
    u_int l = 0;
    while (l < tagLine.length()) {
	l = tagLine.next(l, '%');
	if (l >= tagLine.length()-1)
	    break;
	switch (tagLine[l+1]) {
	case 'a': insert(tagLine, l, req.subaddr); break;
	case 'c': insert(tagLine, l, req.company); break;
	case 'C': insert(tagLine, l, req.fromcompany); break;
	case 'd': insert(tagLine, l, req.external); break;
	case 'g': insert(tagLine, l, req.location); break;
	case 'G': insert(tagLine, l, req.fromlocation); break;
	case 'i': insert(tagLine, l, req.jobid); break;
	case 'I': insert(tagLine, l, req.groupid); break;
	case 'j': insert(tagLine, l, req.jobtag); break;
	case 'l': insert(tagLine, l, server.getLocalIdentifier()); break;
	case 'm': insert(tagLine, l, req.mailaddr); break;
	case 'n':
	    if (req.faxnumber == "")
		insert(tagLine, l, server.getModemNumber());
	    else
		insert(tagLine, l, req.faxnumber);
	    break;
	case 'r': insert(tagLine, l, req.receiver); break;
	case 's': insert(tagLine, l, req.sender); break;
	case 'S': insert(tagLine, l, req.regarding); break;
	case 't': insert(tagLine, l,
			fxStr((int)(req.totpages-req.npages), "%u")); break;
	case 'T': insert(tagLine, l,
			fxStr((int)(req.totpages+req.skippedpages-req.nocountcover), "%u")); break;
	case 'v': insert(tagLine, l, req.voice); break;
	case 'V': insert(tagLine, l, req.fromvoice); break;
	case '%': tagLine.remove(l); break;
	default:  l += 2; break;
	}
    }
    tagLineFields = 0;
    for (l = 0; l < tagLine.length(); l = tagLine.next(l+1, '|'))
	tagLineFields++;
}
void FaxModem :: setupTagLine ( const FaxRequest & req , const fxStr & tagLineFmt , const fxStr & locale , const fxStr & tz ) { if ( tagLineFont == NULL ) tagLineFont = new PCFFont ; if ( ! tagLineFont -> isReady ( ) && conf . tagLineFontFile != " " ) ( void ) tagLineFont -> read ( conf . tagLineFontFile ) ; tagLineLocale = locale ; #ifdef LC_CTYPE setlocale ( LC_CTYPE , tagLineLocale ) ; #endif #ifdef LC_TIME setlocale ( LC_TIME , tagLineLocale ) ; #endif bool isutf8 = false ; #if HAS_LANGINFO isutf8 = ( strcmp ( nl_langinfo ( CODESET ) , " " ) == 0 ) ; tagLine . setUTF8 ( isutf8 ) ; #endif if ( tz != " " ) setenv ( " " , tz , 1 ) ; time_t t = Sys :: now ( ) ; tm * tm = localtime ( & t ) ; char line [ 1024 ] ; strftime ( line , sizeof ( line ) - 1 , tagLineFmt , tm ) ; tagLine = line ; u_int l = 0 ; while ( l < tagLine . length ( ) ) { l = tagLine . next ( l , ' ' ) ; if ( l >= tagLine . length ( ) - 1 ) break ; switch ( tagLine [ l + 1 ] ) { case ' ' : insert ( tagLine , l , req . subaddr ) ; break ; case ' ' : insert ( tagLine , l , req . company ) ; break ; case ' ' : insert ( tagLine , l , req . fromcompany ) ; break ; case ' ' : insert ( tagLine , l , req . external ) ; break ; case ' ' : insert ( tagLine , l , req . location ) ; break ; case ' ' : insert ( tagLine , l , req . fromlocation ) ; break ; case ' ' : insert ( tagLine , l , req . jobid ) ; break ; case ' ' : insert ( tagLine , l , req . groupid ) ; break ; case ' ' : insert ( tagLine , l , req . jobtag ) ; break ; case ' ' : insert ( tagLine , l , server . getLocalIdentifier ( ) ) ; break ; case ' ' : insert ( tagLine , l , req . mailaddr ) ; break ; case ' ' : if ( req . faxnumber == " " ) insert ( tagLine , l , server . getModemNumber ( ) ) ; else insert ( tagLine , l , req . faxnumber ) ; break ; case ' ' : insert ( tagLine , l , req . receiver ) ; break ; case ' ' : insert ( tagLine , l , req . sender ) ; break ; case ' ' : insert ( tagLine , l , req . regarding ) ; break ; case ' ' : insert ( tagLine , l , fxStr ( ( int ) ( req . totpages - req . npages ) , " " ) ) ; break ; case ' ' : insert ( tagLine , l , fxStr ( ( int ) ( req . totpages + req . skippedpages - req . nocountcover ) , " " ) ) ; break ; case ' ' : insert ( tagLine , l , req . voice ) ; break ; case ' ' : insert ( tagLine , l , req . fromvoice ) ; break ; case ' ' : tagLine . remove ( l ) ; break ; default : l += 2 ; break ; } } tagLineFields = 0 ; for ( l = 0 ; l < tagLine . length ( ) ; l = tagLine . next ( l + 1 , ' ' ) ) tagLineFields ++ ; }
Read in the PCF font to use for imaging the tag line and
 preformat as much of the tag line as possible.
Read in the PCF font to use for imaging the tag line and preformat as much of the tag line as possible .
// for <ctype.h> calls // for strftime calls /*
     * Break the tag into fields.
     */