Back to index

courier  0.68.2
Defines | Functions | Variables
log.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "lock.h"

Go to the source code of this file.

Defines

#define MSGCTXT_SEPARATOR   '\004' /* EOT */

Functions

static void print_escaped (FILE *stream, const char *str, const char *str_end)
 __libc_lock_define_initialized (static, lock)
void _nl_log_untranslated (const char *logfilename, const char *domainname, const char *msgid1, const char *msgid2, int plural)

Variables

static char * last_logfilename = NULL
static FILE * last_logfile = NULL

Define Documentation

#define MSGCTXT_SEPARATOR   '\004' /* EOT */

Definition at line 37 of file log.c.


Function Documentation

__libc_lock_define_initialized ( static  ,
lock   
)

Definition at line 63 of file log.c.

{
  FILE *logfile;
  const char *separator;

  /* Can we reuse the last opened logfile?  */
  if (last_logfilename == NULL || strcmp (logfilename, last_logfilename) != 0)
    {
      /* Close the last used logfile.  */
      if (last_logfilename != NULL)
        {
          if (last_logfile != NULL)
            {
              fclose (last_logfile);
              last_logfile = NULL;
            }
          free (last_logfilename);
          last_logfilename = NULL;
        }
      /* Open the logfile.  */
      last_logfilename = (char *) malloc (strlen (logfilename) + 1);
      if (last_logfilename == NULL)
        return;
      strcpy (last_logfilename, logfilename);
      last_logfile = fopen (logfilename, "a");
      if (last_logfile == NULL)
        return;
    }
  logfile = last_logfile;

  fprintf (logfile, "domain ");
  print_escaped (logfile, domainname, domainname + strlen (domainname));
  separator = strchr (msgid1, MSGCTXT_SEPARATOR);
  if (separator != NULL)
    {
      /* The part before the MSGCTXT_SEPARATOR is the msgctxt.  */
      fprintf (logfile, "\nmsgctxt ");
      print_escaped (logfile, msgid1, separator);
      msgid1 = separator + 1;
    }
  fprintf (logfile, "\nmsgid ");
  print_escaped (logfile, msgid1, msgid1 + strlen (msgid1));
  if (plural)
    {
      fprintf (logfile, "\nmsgid_plural ");
      print_escaped (logfile, msgid2, msgid2 + strlen (msgid2));
      fprintf (logfile, "\nmsgstr[0] \"\"\n");
    }
  else
    fprintf (logfile, "\nmsgstr \"\"\n");
  putc ('\n', logfile);
}

Here is the call graph for this function:

void _nl_log_untranslated ( const char *  logfilename,
const char *  domainname,
const char *  msgid1,
const char *  msgid2,
int  plural 
)

Definition at line 122 of file log.c.

{
  __libc_lock_lock (lock);
  _nl_log_untranslated_locked (logfilename, domainname, msgid1, msgid2, plural);
  __libc_lock_unlock (lock);
}

Here is the caller graph for this function:

static void print_escaped ( FILE *  stream,
const char *  str,
const char *  str_end 
) [static]

Definition at line 41 of file log.c.

{
  putc ('"', stream);
  for (; str != str_end; str++)
    if (*str == '\n')
      {
        fputs ("\\n\"", stream);
        if (str + 1 == str_end)
          return;
        fputs ("\n\"", stream);
      }
    else
      {
        if (*str == '"' || *str == '\\')
          putc ('\\', stream);
        putc (*str, stream);
      }
  putc ('"', stream);
}

Here is the caller graph for this function:


Variable Documentation

FILE* last_logfile = NULL [static]

Definition at line 62 of file log.c.

char* last_logfilename = NULL [static]

Definition at line 61 of file log.c.