コード例 #1
0
ファイル: charset.c プロジェクト: 55887MX/CCORE
static const char*
get_charset_name_alias(const char *name)
{
  if (!my_strcasecmp(&my_charset_latin1, name, "utf8mb3"))
    return "utf8";
  return NULL;
}
コード例 #2
0
MDJVU_IMPLEMENT int ends_with_ignore_case(const char *s, const char *prefix)
{
    size_t sl = strlen(s);
    size_t pl = strlen(prefix);
    if (sl < pl) return 0;
    return !my_strcasecmp(s + sl - pl, prefix);
}
コード例 #3
0
ファイル: assuan-handler.c プロジェクト: tierney/lockbox-py
static gpg_error_t
std_handler_help (assuan_context_t ctx, char *line)
{
  unsigned int i;
  char buf[ASSUAN_LINELENGTH];
  const char *helpstr;
  size_t n;

  n = strcspn (line, " \t\n");
  if (!n)
    {
      /* Print all commands.  If a help string is available and that
         starts with the command name, print the first line of the
         help string.  */
      for (i = 0; i < ctx->cmdtbl_used; i++)
        {
          n = strlen (ctx->cmdtbl[i].name);
          helpstr = ctx->cmdtbl[i].helpstr;
          if (helpstr
              && !strncmp (ctx->cmdtbl[i].name, helpstr, n)
              && (!helpstr[n] || helpstr[n] == '\n' || helpstr[n] == ' ')
              && (n = strcspn (helpstr, "\n"))          )
            snprintf (buf, sizeof (buf), "# %.*s", (int)n, helpstr);
          else
            snprintf (buf, sizeof (buf), "# %s", ctx->cmdtbl[i].name);
          buf[ASSUAN_LINELENGTH - 1] = '\0';
          assuan_write_line (ctx, buf);
        }
    }
  else
    {
      /* Print the help for the given command.  */
      int c = line[n];
      line[n] = 0;
      for (i=0; ctx->cmdtbl[i].name; i++)
        if (!my_strcasecmp (line, ctx->cmdtbl[i].name))
          break;
      line[n] = c;
      if (!ctx->cmdtbl[i].name)
        return PROCESS_DONE (ctx, set_error (ctx,GPG_ERR_UNKNOWN_COMMAND,NULL));
      helpstr = ctx->cmdtbl[i].helpstr;
      if (!helpstr)
        return PROCESS_DONE (ctx, set_error (ctx, GPG_ERR_NOT_FOUND, NULL));
      do
        {
          n = strcspn (helpstr, "\n");
          snprintf (buf, sizeof (buf), "# %.*s", (int)n, helpstr);
          helpstr += n;
          if (*helpstr == '\n')
            helpstr++;
          buf[ASSUAN_LINELENGTH - 1] = '\0';
          assuan_write_line (ctx, buf);
        }
      while (*helpstr);
    }

  return PROCESS_DONE (ctx, 0);
}
コード例 #4
0
ファイル: lwlib.c プロジェクト: mmaruska/emacs
static widget_creation_function
find_in_table (const char *type, const widget_creation_entry *table)
{
  const widget_creation_entry* cur;
  for (cur = table; cur->type; cur++)
    if (!my_strcasecmp (type, cur->type))
      return cur->function;
  return NULL;
}
コード例 #5
0
/*
  Looks up a null-terminated string in a list,
  case insensitively.
 
  SYNOPSIS
    str_list_find()
    list        list of items
    str         item to find

  RETURN
    0  ok
    1  reserved file name
*/
static int str_list_find(const char **list, const char *str)
{
  const char **name;
  for (name= list; *name; name++)
  {
    if (!my_strcasecmp(&my_charset_latin1, *name, str))
      return 1;
  }
  return 0;
}
コード例 #6
0
ファイル: qif.c プロジェクト: wazari972/Grisbi
/**
 * retourne le type de compte en fonction du header du QIF file
 *
 *
 * \return -1 si un type non traité else 0 to 7
 * */
gint gsb_qif_get_account_type ( gchar *header )
{
    gint account_type = -1;
    gchar *ptr;

    ptr = g_utf8_strchr ( header, -1, ':' );
    ptr++;

    if ( g_ascii_strncasecmp ( ptr, "bank", 4 ) == 0 || my_strcasecmp ( ptr, _("bank") ) == 0 )
        account_type = 0;
    else if ( g_ascii_strncasecmp ( ptr, "invst", 5 ) == 0  || my_strcasecmp ( ptr, _("invst)") ) == 0 )
        account_type = 6;
    else if ( g_ascii_strncasecmp ( ptr, "cash", 4 ) == 0  || my_strcasecmp ( ptr, _("cash)") ) == 0 )
        account_type = 7;
    else if ( g_ascii_strncasecmp ( ptr, "oth a", 5 ) == 0  || my_strcasecmp ( ptr, _("oth a)") ) == 0 )
        account_type = 2;
    else if ( g_ascii_strncasecmp ( ptr, "oth l", 5 ) == 0  || my_strcasecmp ( ptr, _("oth l)") ) == 0 )
        account_type = 3;
    else if ( g_ascii_strncasecmp ( ptr, "ccard", 5 ) == 0  || my_strcasecmp ( ptr, _("ccard)") ) == 0 )
        account_type = 5;
    else
        account_type = -1;

    return account_type;
}
コード例 #7
0
ファイル: HTFile.c プロジェクト: thentenaar/mosaic-ng
/*	Convert filenames between local and WWW formats
**	-----------------------------------------------
** On exit,
**	returns	a malloc'ed string which must be freed by the caller.
*/
PUBLIC char * HTLocalName ARGS1(WWW_CONST char *,name)
{
  char * access = HTParse(name, "", PARSE_ACCESS);
  char * host = HTParse(name, "", PARSE_HOST);
  char * path = HTParse(name, "", PARSE_PATH+PARSE_PUNCTUATION);
  
  HTUnEscape(path);	/* Interpret % signs */
  
  if (0==strcmp(access, "file")) 
    {
      free(access);	
      if (!host || !*host || (0==my_strcasecmp(host, HTHostName())) ||
          (0==my_strcasecmp(host, "localhost"))) 
        {
          if (host)
            free(host);
#ifndef DISABLE_TRACE
          if (www2Trace) 
            fprintf(stderr, "Node `%s' means path `%s'\n", name, path);
#endif
          return(path);
        }
      else
        {
          free (host);
          if (path)
            free (path);
          return NULL;
        }
    }
  
  /* not file */
  if (host)
    free (host);
  free (access);
  if (path)
    free (path);
  return NULL;
}
コード例 #8
0
ファイル: charset.c プロジェクト: 55887MX/CCORE
static uint
get_collation_number_internal(const char *name)
{
  CHARSET_INFO **cs;
  for (cs= all_charsets;
       cs < all_charsets + array_elements(all_charsets);
       cs++)
  {
    if ( cs[0] && cs[0]->name &&
         !my_strcasecmp(&my_charset_latin1, cs[0]->name, name))
      return cs[0]->number;
  }
  return 0;
}
コード例 #9
0
ファイル: charset.c プロジェクト: 55887MX/CCORE
static uint
get_charset_number_internal(const char *charset_name, uint cs_flags)
{
  CHARSET_INFO **cs;

  for (cs= all_charsets;
       cs < all_charsets + array_elements(all_charsets);
       cs++)
  {
    if ( cs[0] && cs[0]->csname && (cs[0]->state & cs_flags) &&
         !my_strcasecmp(&my_charset_latin1, cs[0]->csname, charset_name))
      return cs[0]->number;
  }
  return 0;
}
コード例 #10
0
ファイル: charset.c プロジェクト: Tsuiwiki/infobright
uint get_charset_number(const char *charset_name, uint cs_flags)
{
  CHARSET_INFO **cs;
  init_available_charsets(MYF(0));
  
  for (cs= all_charsets;
       cs < all_charsets+array_elements(all_charsets)-1 ;
       cs++)
  {
    if ( cs[0] && cs[0]->csname && (cs[0]->state & cs_flags) &&
         !my_strcasecmp(&my_charset_latin1, cs[0]->csname, charset_name))
      return cs[0]->number;
  }  
  return 0;
}
コード例 #11
0
int main(){
  char *strings1[]={"Hallo","hallo","Hallali"};
  char *strings2[]= {"hello","Hallo","Hallo"};
  char chars[] = {'a','l','e'};

  int i;
  for(i = 0; i <= 2; i++){
    if(strcasecmp(strings1[i],strings2[i]) != my_strcasecmp(strings1[i],strings2[i])){
	printf("%s\n %s\n",strings1[i],strings2[i]);
    }else if(index(strings1[i],chars[i]) != my_index(strings1[i],chars[i])){
	 printf("%s\n %c\n",strings1[i],chars[i]);
    }else{
       printf("ALLES SUUUPER!!\n");
    }   
  }


  return 0;
}
コード例 #12
0
ファイル: cmp.c プロジェクト: patrickzip/emap
int			cmp_name(void *data1, void *data2)
{
    road_t *r1 = ROAD(data1);
    road_t *r2 = ROAD(data2);
    int res = 0;

    if (!data1 || !data2)
        return 0;

    if (!r1->name && !r2->name)
        return 0;
    if (!r1->name && r2->name)
        return 1;
    if (r1->name && !r2->name)
        return -1;
    res = -1 * my_strcasecmp(r1->name, r2->name);
    if (res > 0)
        return 1;
    if (res < 0)
        return -1;
    return 0;
}
コード例 #13
0
ファイル: utils_str.c プロジェクト: wazari972/Grisbi
/**
 * recherche des mots séparés par des jokers "%*" dans une chaine
 *
 * \param haystack
 * \param needle
 *
 * \return TRUE si trouvé FALSE autrement
 */
gboolean gsb_string_is_trouve ( const gchar *payee_name, const gchar *needle )
{
    gchar **tab_str;
    gchar *tmpstr;
    gint i;
    gboolean is_prefix = FALSE, is_suffix = FALSE;

    if ( g_strstr_len ( needle, -1, "%" ) == NULL &&
                        g_strstr_len ( needle, -1, "*" ) == NULL )
    {
        if ( my_strcasecmp ( payee_name, needle ) == 0 )
            return TRUE;
        else
            return FALSE;
    }
    if ( g_str_has_prefix ( needle, "%" ) == FALSE &&
                        g_str_has_prefix ( needle, "*" ) == FALSE )
        is_prefix = TRUE;

    if ( g_str_has_suffix ( needle, "%" ) == FALSE &&
                        g_str_has_suffix ( needle, "*" ) == FALSE )
        is_suffix = TRUE;

    if ( is_prefix && is_suffix )
    {
        tab_str = g_strsplit_set ( needle, "%*", 0 );
        is_prefix = g_str_has_prefix ( payee_name, tab_str[0] );
        is_suffix = g_str_has_suffix ( payee_name, tab_str[1] );
        if ( is_prefix && is_suffix )
            return TRUE;
        else
            return FALSE;
    }
    else if ( is_prefix && ! is_suffix )
    {
        tmpstr = gsb_string_supprime_joker ( needle );
        is_prefix = g_str_has_prefix (payee_name, tmpstr);
        g_free (tmpstr);
        return is_prefix;
    }
    else if ( is_suffix && ! is_prefix )
    {
        tmpstr = gsb_string_supprime_joker ( needle );
        is_suffix = g_str_has_suffix (payee_name, tmpstr);
        g_free (tmpstr);
        return is_suffix;
    }

    tab_str = g_strsplit_set ( needle, "%*", 0 );

    for (i = 0; tab_str[i] != NULL; i++)
	{
        if ( tab_str[i] && strlen (tab_str[i]) > 0)
        {
            if ( g_strstr_len (payee_name, -1, tab_str[i]))
            {
                g_strfreev ( tab_str );
                return TRUE;
            }
        }
    }

    g_strfreev ( tab_str );

    return FALSE;
}
コード例 #14
0
/**
 * used with g_slist_find_custom to find a payee in the g_list
 * by his name
 *
 * \param payee the struct of the current payee checked
 * \param name the name we are looking for
 *
 * \return 0 if it's the same name
 * */
gint gsb_data_payee_get_pointer_from_name_in_glist ( struct_payee *payee,
						     const gchar *name )
{
    return ( my_strcasecmp ( payee -> payee_name, name ) );
}
コード例 #15
0
ファイル: assuan-handler.c プロジェクト: tierney/lockbox-py
/* Parse the line, break out the command, find it in the command
   table, remove leading and white spaces from the arguments, call the
   handler with the argument line and return the error.  */
static gpg_error_t
dispatch_command (assuan_context_t ctx, char *line, int linelen)
{
  gpg_error_t err;
  char *p;
  const char *s;
  int shift, i;

  /* Note that as this function is invoked by assuan_process_next as
     well, we need to hide non-critical errors with PROCESS_DONE.  */

  if (*line == 'D' && line[1] == ' ') /* divert to special handler */
    /* FIXME: Depending on the final implementation of
       handle_data_line, this may be wrong here.  For example, if a
       user callback is invoked, and that callback is responsible for
       calling assuan_process_done, then this is wrong.  */
    return PROCESS_DONE (ctx, handle_data_line (ctx, line+2, linelen-2));

  for (p=line; *p && *p != ' ' && *p != '\t'; p++)
    ;
  if (p==line)
    return PROCESS_DONE
      (ctx, set_error (ctx, GPG_ERR_ASS_SYNTAX, "leading white-space"));
  if (*p)
    { /* Skip over leading WS after the keyword */
      *p++ = 0;
      while ( *p == ' ' || *p == '\t')
        p++;
    }
  shift = p - line;

  for (i=0; (s=ctx->cmdtbl[i].name); i++)
    {
      if (!strcmp (line, s))
        break;
    }
  if (!s)
    { /* and try case insensitive */
      for (i=0; (s=ctx->cmdtbl[i].name); i++)
        {
          if (!my_strcasecmp (line, s))
            break;
        }
    }
  if (!s)
    return PROCESS_DONE (ctx, set_error (ctx, GPG_ERR_ASS_UNKNOWN_CMD, NULL));
  line += shift;
  linelen -= shift;

  if (ctx->pre_cmd_notify_fnc) {
    err = ctx->pre_cmd_notify_fnc(ctx, ctx->cmdtbl[i].name);

    if (err)
      return PROCESS_DONE(ctx, err);
  }

/*    fprintf (stderr, "DBG-assuan: processing %s `%s'\n", s, line); */
  ctx->current_cmd_name = ctx->cmdtbl[i].name;
  err = ctx->cmdtbl[i].handler (ctx, line);
  ctx->current_cmd_name = NULL;
  return err;
}
コード例 #16
0
ファイル: assuan-handler.c プロジェクト: tierney/lockbox-py
/**
 * assuan_register_command:
 * @ctx: the server context
 * @cmd_name: A string with the command name
 * @handler: The handler function to be called or NULL to use a default
 *           handler.
 * HELPSTRING
 *
 * Register a handler to be used for a given command.  Note that
 * several default handlers are already regsitered with a new context.
 * This function however allows to override them.
 *
 * Return value: 0 on success or an error code
 **/
gpg_error_t
assuan_register_command (assuan_context_t ctx, const char *cmd_name,
                         assuan_handler_t handler, const char *help_string)
{
  int i, cmd_index = -1;
  const char *s;

  if (cmd_name && !*cmd_name)
    cmd_name = NULL;

  if (!cmd_name)
    return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);

  if (!handler)
    { /* find a default handler. */
      for (i=0; (s=std_cmd_table[i].name) && strcmp (cmd_name, s); i++)
        ;
      if (!s)
        { /* Try again but case insensitive. */
          for (i=0; (s=std_cmd_table[i].name)
                    && my_strcasecmp (cmd_name, s); i++)
            ;
        }
      if (s)
        handler = std_cmd_table[i].handler;
      if (!handler)
        handler = dummy_handler; /* Last resort is the dummy handler. */
    }

  if (!ctx->cmdtbl)
    {
      ctx->cmdtbl_size = 50;
      ctx->cmdtbl = _assuan_calloc (ctx, ctx->cmdtbl_size, sizeof *ctx->cmdtbl);
      if (!ctx->cmdtbl)
	return _assuan_error (ctx, gpg_err_code_from_syserror ());
      ctx->cmdtbl_used = 0;
    }
  else if (ctx->cmdtbl_used >= ctx->cmdtbl_size)
    {
      struct cmdtbl_s *x;

      x = _assuan_realloc (ctx, ctx->cmdtbl, (ctx->cmdtbl_size+10) * sizeof *x);
      if (!x)
	return _assuan_error (ctx, gpg_err_code_from_syserror ());
      ctx->cmdtbl = x;
      ctx->cmdtbl_size += 50;
    }

  for (i=0; i<ctx->cmdtbl_used; i++)
    {
      if (!my_strcasecmp (cmd_name, ctx->cmdtbl[i].name))
        {
	  cmd_index = i;
	  break;
	}
    }

  if (cmd_index == -1)
    cmd_index = ctx->cmdtbl_used++;

  ctx->cmdtbl[cmd_index].name = cmd_name;
  ctx->cmdtbl[cmd_index].handler = handler;
  ctx->cmdtbl[cmd_index].helpstr = help_string;
  return 0;
}
コード例 #17
0
ファイル: HTFile.c プロジェクト: thentenaar/mosaic-ng
PUBLIC HTFormat HTFileFormat ARGS4 (
			char *,	filename,
			HTAtom **,	pencoding,
                        HTAtom *,       default_type,
                        int *, compressed)
{
  HTSuffix *suff;
  int n, i, lf;

  if (!filename)
    return NULL;

  /* Make a copy to hack and slash. */
  filename = strdup (filename);

  lf = strlen (filename);

  /* Step backward through filename, looking for '?'. */
  for (i = lf - 1; i >= 0; i--)
    {
      if (filename[i] == '?')
        {
          /* Clip query. */
          filename[i] = '\0';
          /* Get new strlen, since we just changed it. */
          lf = strlen (filename);
          goto ok_ready;
        }
    }

  *compressed = 0;

  /* Check for .Z and .z. */
  if (lf > 2)
    {
      if (strcmp (&(filename[lf-2]), ".Z") == 0)
        {
          *compressed = COMPRESSED_BIGZ;
          filename[lf-2] = '\0';
          lf = strlen (filename);
#ifndef DISABLE_TRACE
          if (www2Trace)
            fprintf (stderr, "[HTFileFormat] Got hit on .Z; filename '%s'\n",
                     filename);
#endif
          goto ok_ready;
        }
      else if (strcmp (&(filename[lf-2]), ".z") == 0)
        {
          *compressed = COMPRESSED_GNUZIP;
          filename[lf-2] = '\0';
          lf = strlen (filename);
#ifndef DISABLE_TRACE
          if (www2Trace)
            fprintf (stderr, "[HTFileFormat] Got hit on .z; filename '%s'\n",
                     filename);
#endif
          goto ok_ready;
        }
      else if (lf > 3)
        {
          if (strcmp (&(filename[lf-3]), ".gz") == 0)
            {
              *compressed = COMPRESSED_GNUZIP;
              filename[lf-3] = '\0';
              lf = strlen (filename);
#ifndef DISABLE_TRACE
              if (www2Trace)
                fprintf (stderr, 
                         "[HTFileFormat] Got hit on .gz; filename '%s'\n",
                         filename);
#endif
              goto ok_ready;
            }
        }      
    }      
  
 ok_ready:
  if (!HTSuffixes) 
    HTFileInit();

  *pencoding = NULL;

  n = HTList_count(HTSuffixes);

  for(i=0; i<n; i++) 
    {
      int ls;
      suff = HTList_objectAt(HTSuffixes, i);
      ls = strlen(suff->suffix);
      if ((ls <= lf) && 0==my_strcasecmp(suff->suffix, filename + lf - ls)) 
        {
          int j;
          *pencoding = suff->encoding;
          if (suff->rep) 
            goto done;
          
          for(j=0; j<n; j++) 
            {  /* Got encoding, need representation */
              int ls2;
              suff = HTList_objectAt(HTSuffixes, j);
              ls2 = strlen(suff->suffix);
              if ((ls <= lf) && 
                  0==my_strncasecmp(suff->suffix, filename + lf - ls -ls2, ls2)) 
                if (suff->rep) 
                  goto done;
	    }
        }
    }
  
  suff = strchr(filename, '.') ? 	/* Unknown suffix */
    ( unknown_suffix.rep ? &unknown_suffix : &no_suffix)
      : &no_suffix;
  
  /* For now, assuming default is 8bit text/plain.
     We also want default 8bit text/html for http connections. */
  
  /* set default encoding unless found with suffix already */
  if (!*pencoding) *pencoding = suff->encoding ? suff->encoding
    : HTAtom_for("8bit");

 done:

  /* Free our copy. */
  free (filename);
  return suff->rep ? suff->rep : default_type;
}
コード例 #18
0
/**
 * used with g_slist_find_custom to find a sub-budget in the g_list
 * by his name
 *
 * \param sub_budget the struct of the current sub_budget checked
 * \param name the name we are looking for
 *
 * \return 0 if it's the same name
 * */
gint gsb_data_budget_get_pointer_from_sub_name_in_glist ( struct_sub_budget *sub_budget,
                        const gchar *name )
{
    return ( my_strcasecmp ( sub_budget -> sub_budget_name, name ));
}