Exemple #1
0
static char *
read_textline (FILE *fp)
{
  char line[4096];
  char *p;
  int any = 0;

  /* Read line but skip over initial empty lines.  */
  do
    {
      do
        {
          if (!fgets (line, sizeof line, fp))
            {
              if (feof (fp))
                return NULL;
              die ("error reading input line: %s\n", strerror (errno));
            }
          p = strchr (line, '\n');
          if (p)
            *p = 0;
          p = line + (*line? (strlen (line)-1):0);
          for ( ;p > line; p--)
            if (my_isascii (*p) && isspace (*p))
              *p = 0;
        }
      while (!any && !*line);
      any = 1;
    }
  while (*line == '#');  /* Always skip comment lines.  */
  if (verbose > 1)
    fprintf (stderr, PGM ": received line: %s\n", line);
  return gcry_xstrdup (line);
}
Exemple #2
0
/* ********************************************************************* */
int clean_name(char *tmp_path, char *opath)
{
   /* remove spaces, *'s, :'s &'s and commas from the name */
   int len = strlen(tmp_path);
   int o_index=0;
   for(int i=0; i<len; i++)
   {
      if( isspace(tmp_path[i] ) )
      {  
          if( o_index &&              // add a _ if not first char
              opath[o_index-1] != '_' ) // and if previous char not a _
         opath[o_index++] = '_';
      }
      else
      if( my_isascii( tmp_path[i] ) && 
          tmp_path[i] != '&'   &&
          tmp_path[i] != ','   &&
          tmp_path[i] != '*'   &&
          tmp_path[i] != '/'   &&
          tmp_path[i] != ':' )
          opath[o_index++] = tmp_path[i];
   }
   opath[o_index] = '\0'; /* terminate the string */
 
   return(OK);
}
Exemple #3
0
/* Read next line but skip over empty and comment lines.  Caller must
   xfree the result.  */
static char *
read_textline (FILE *fp, int *lineno)
{
  char line[4096];
  char *p;

  do
    {
      if (!fgets (line, sizeof line, fp))
        {
          if (feof (fp))
            return NULL;
          die ("error reading input line: %s\n", strerror (errno));
        }
      ++*lineno;
      p = strchr (line, '\n');
      if (!p)
        die ("input line %d not terminated or too long\n", *lineno);
      *p = 0;
      for (p--;p > line && my_isascii (*p) && isspace (*p); p--)
        *p = 0;
    }
  while (!*line || *line == '#');
  /* if (debug) */
  /*   show ("read line: '%s'\n", line); */
  return xstrdup (line);
}
Exemple #4
0
static void
hexdowncase (char *string)
{
  char *p;

  for (p=string; *p; p++)
    if (my_isascii (*p))
      *p = tolower (*p);
}
Exemple #5
0
/* Copy the data after the tag to BUFFER.  BUFFER will be allocated as
   needed.  */
static void
copy_data (char **buffer, const char *line, int lineno)
{
  const char *s;

  xfree (*buffer);
  *buffer = NULL;

  s = strchr (line, ':');
  if (!s)
    {
      fail ("syntax error at input line %d", lineno);
      return;
    }
  for (s++; my_isascii (*s) && isspace (*s); s++)
    ;
  *buffer = xstrdup (s);
}