Exemplo n.º 1
1
void	ft_putendl(char const *s)
{
	write(1, s, ft_strlen(s));
	ft_putchar('\n');
}
Exemplo n.º 2
1
t_arg_parser		ft_arg_create(int ac, char const *const *av)
{
	return ((t_arg_parser){NULL, '\0', 0, ac, 0, ft_strlen(*av) - 1, av});
}
Exemplo n.º 3
0
char	*ft_strcat(char *dest, char *src)
{
	ft_strcpy(&dest[ft_strlen(dest)], src);
	return (dest);
}
Exemplo n.º 4
0
char	*ft_strcat(char *dst, const char *src)
{
	ft_strncat(dst, src, ft_strlen(src));
	return (dst);
}
Exemplo n.º 5
0
void	ft_putnbr_base(size_t nbr, char *base)
{
	if (nbr >= ft_strlen(base) - 1)
		ft_putnbr_base(nbr / ft_strlen(base), base);
	ft_putchar(base[nbr % ft_strlen(base)]);
}
Exemplo n.º 6
0
void		ft_putstr_fd(char const *str, int fd)
{
	write(fd, str, ft_strlen(str));
}
Exemplo n.º 7
0
char		*ft_strstr(const char *s1, const char *s2)
{
	return (ft_strnstr(s1, s2, ft_strlen(s1)));
}
Exemplo n.º 8
0
  t42_parse_dict( T42_Face    face,
                  T42_Loader  loader,
                  FT_Byte*    base,
                  FT_Long     size )
  {
    T42_Parser  parser     = &loader->parser;
    FT_Byte*    limit;
    FT_Int      n_keywords = (FT_Int)( sizeof ( t42_keywords ) /
                                         sizeof ( t42_keywords[0] ) );


    parser->root.cursor = base;
    parser->root.limit  = base + size;
    parser->root.error  = T42_Err_Ok;

    limit = parser->root.limit;

    T1_Skip_Spaces( parser );

    while ( parser->root.cursor < limit )
    {
      FT_Byte*  cur;


      cur = parser->root.cursor;

      /* look for `FontDirectory' which causes problems for some fonts */
      if ( *cur == 'F' && cur + 25 < limit                    &&
           ft_strncmp( (char*)cur, "FontDirectory", 13 ) == 0 )
      {
        FT_Byte*  cur2;


        /* skip the `FontDirectory' keyword */
        T1_Skip_PS_Token( parser );
        T1_Skip_Spaces  ( parser );
        cur = cur2 = parser->root.cursor;

        /* look up the `known' keyword */
        while ( cur < limit )
        {
          if ( *cur == 'k' && cur + 5 < limit             &&
                ft_strncmp( (char*)cur, "known", 5 ) == 0 )
            break;

          T1_Skip_PS_Token( parser );
          if ( parser->root.error )
            goto Exit;
          T1_Skip_Spaces  ( parser );
          cur = parser->root.cursor;
        }

        if ( cur < limit )
        {
          T1_TokenRec  token;


          /* skip the `known' keyword and the token following it */
          T1_Skip_PS_Token( parser );
          T1_ToToken( parser, &token );

          /* if the last token was an array, skip it! */
          if ( token.type == T1_TOKEN_TYPE_ARRAY )
            cur2 = parser->root.cursor;
        }
        parser->root.cursor = cur2;
      }

      /* look for immediates */
      else if ( *cur == '/' && cur + 2 < limit )
      {
        FT_PtrDist  len;


        cur++;

        parser->root.cursor = cur;
        T1_Skip_PS_Token( parser );
        if ( parser->root.error )
          goto Exit;

        len = parser->root.cursor - cur;

        if ( len > 0 && len < 22 && parser->root.cursor < limit )
        {
          int  i;


          /* now compare the immediate name to the keyword table */

          /* loop through all known keywords */
          for ( i = 0; i < n_keywords; i++ )
          {
            T1_Field  keyword = (T1_Field)&t42_keywords[i];
            FT_Byte   *name   = (FT_Byte*)keyword->ident;


            if ( !name )
              continue;

            if ( cur[0] == name[0]                                  &&
                 len == (FT_PtrDist)ft_strlen( (const char *)name ) &&
                 ft_memcmp( cur, name, len ) == 0                   )
            {
              /* we found it -- run the parsing callback! */
              parser->root.error = t42_load_keyword( face,
                                                     loader,
                                                     keyword );
              if ( parser->root.error )
                return parser->root.error;
              break;
            }
          }
        }
      }
      else
      {
        T1_Skip_PS_Token( parser );
        if ( parser->root.error )
          goto Exit;
      }

      T1_Skip_Spaces( parser );
    }

  Exit:
    return parser->root.error;
  }
Exemplo n.º 9
0
Arquivo: ttbdf.c Projeto: 1vanK/Urho3D
  tt_face_find_bdf_prop( TT_Face           face,
                         const char*       property_name,
                         BDF_PropertyRec  *aprop )
  {
    TT_BDF     bdf   = &face->bdf;
    FT_Size    size  = FT_FACE(face)->size;
    FT_Error   error = FT_Err_Ok;
    FT_Byte*   p;
    FT_UInt    count;
    FT_Byte*   strike;
    FT_Offset  property_len;


    aprop->type = BDF_PROPERTY_TYPE_NONE;

    if ( bdf->loaded == 0 )
    {
      error = tt_face_load_bdf_props( face, FT_FACE( face )->stream );
      if ( error )
        goto Exit;
    }

    count  = bdf->num_strikes;
    p      = bdf->table + 8;
    strike = p + 4 * count;

    error = FT_ERR( Invalid_Argument );

    if ( !size || !property_name )
      goto Exit;

    property_len = ft_strlen( property_name );
    if ( property_len == 0 )
      goto Exit;

    for ( ; count > 0; count-- )
    {
      FT_UInt  _ppem  = FT_NEXT_USHORT( p );
      FT_UInt  _count = FT_NEXT_USHORT( p );


      if ( _ppem == size->metrics.y_ppem )
      {
        count = _count;
        goto FoundStrike;
      }

      strike += 10 * _count;
    }
    goto Exit;

  FoundStrike:
    p = strike;
    for ( ; count > 0; count-- )
    {
      FT_UInt  type = FT_PEEK_USHORT( p + 4 );


      if ( ( type & 0x10 ) != 0 )
      {
        FT_UInt32  name_offset = FT_PEEK_ULONG( p     );
        FT_UInt32  value       = FT_PEEK_ULONG( p + 6 );

        /* be a bit paranoid for invalid entries here */
        if ( name_offset < bdf->strings_size                    &&
             property_len < bdf->strings_size - name_offset     &&
             ft_strncmp( property_name,
                         (const char*)bdf->strings + name_offset,
                         bdf->strings_size - name_offset ) == 0 )
        {
          switch ( type & 0x0F )
          {
          case 0x00:  /* string */
          case 0x01:  /* atoms */
            /* check that the content is really 0-terminated */
            if ( value < bdf->strings_size &&
                 ft_memchr( bdf->strings + value, 0, bdf->strings_size ) )
            {
              aprop->type   = BDF_PROPERTY_TYPE_ATOM;
              aprop->u.atom = (const char*)bdf->strings + value;
              error         = FT_Err_Ok;
              goto Exit;
            }
            break;

          case 0x02:
            aprop->type      = BDF_PROPERTY_TYPE_INTEGER;
            aprop->u.integer = (FT_Int32)value;
            error            = FT_Err_Ok;
            goto Exit;

          case 0x03:
            aprop->type       = BDF_PROPERTY_TYPE_CARDINAL;
            aprop->u.cardinal = value;
            error             = FT_Err_Ok;
            goto Exit;

          default:
            ;
          }
        }
      }
      p += 10;
    }

  Exit:
    return error;
  }
Exemplo n.º 10
0
	t_printf		info;
	int				len;
	unsigned int	nbr;
	char			*tmp;

	info.type = 'b';
	init_info(&info, f, lenud, ap);
	if ((nbr = ft_get_value_ou(ap, &info)) == 2)
	{
		nbr = va_arg(ap, unsigned int);
		info.value = ft_zutoa((size_t)nbr);
	}
	tmp = info.value;
	info.value = ft_convert_base(info.value, "0123456789", "01");
	free(tmp);
	len = ft_strlen(info.value);
	info.add = '\0';
	ft_print_d(info, len, nbr, (info.mark && nbr ? "b" : ""));
	free(info.value);
	return (len);
}

int		ft_action_f(char *f, int lenud, va_list ap)
{
	t_printf		info;
	int				len;
	long double		nbr;
	char			*tmp;

	info.type = 'f';
	init_info(&info, f, lenud, ap);
Exemplo n.º 11
0
int		why_chr(char *word)
{
	return ((ft_strchr(word, '/')) ? ft_strchr(word, '/') - word :\
	(int)ft_strlen(word));
}
Exemplo n.º 12
0
  static FT_Error
  pcf_interpret_style( PCF_Face  pcf )
  {
    FT_Error   error  = PCF_Err_Ok;
    FT_Face    face   = FT_FACE( pcf );
    FT_Memory  memory = face->memory;

    PCF_Property  prop;

    char  *istr = NULL, *bstr = NULL;
    char  *sstr = NULL, *astr = NULL;

    int  parts = 0, len = 0;


    face->style_flags = 0;

    prop = pcf_find_property( pcf, "SLANT" );
    if ( prop && prop->isString                                       &&
         ( *(prop->value.atom) == 'O' || *(prop->value.atom) == 'o' ||
           *(prop->value.atom) == 'I' || *(prop->value.atom) == 'i' ) )
    {
      face->style_flags |= FT_STYLE_FLAG_ITALIC;
      istr = ( *(prop->value.atom) == 'O' || *(prop->value.atom) == 'o' )
               ? (char *)"Oblique"
               : (char *)"Italic";
      len += ft_strlen( istr );
      parts++;
    }

    prop = pcf_find_property( pcf, "WEIGHT_NAME" );
    if ( prop && prop->isString                                       &&
         ( *(prop->value.atom) == 'B' || *(prop->value.atom) == 'b' ) )
    {
      face->style_flags |= FT_STYLE_FLAG_BOLD;
      bstr = (char *)"Bold";
      len += ft_strlen( bstr );
      parts++;
    }

    prop = pcf_find_property( pcf, "SETWIDTH_NAME" );
    if ( prop && prop->isString                                        &&
         *(prop->value.atom)                                           &&
         !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
    {
      sstr = (char *)(prop->value.atom);
      len += ft_strlen( sstr );
      parts++;
    }

    prop = pcf_find_property( pcf, "ADD_STYLE_NAME" );
    if ( prop && prop->isString                                        &&
         *(prop->value.atom)                                           &&
         !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
    {
      astr = (char *)(prop->value.atom);
      len += ft_strlen( astr );
      parts++;
    }

    if ( !parts || !len )
    {
      if ( FT_ALLOC( face->style_name, 8 ) )
        return error;
      ft_strcpy( face->style_name, "Regular" );
      face->style_name[7] = '\0';
    }
    else
    {
      char          *style, *s;
      unsigned int  i;


      if ( FT_ALLOC( style, len + parts ) )
        return error;

      s = style;

      if ( astr )
      {
        ft_strcpy( s, astr );
        for ( i = 0; i < ft_strlen( astr ); i++, s++ )
          if ( *s == ' ' )
            *s = '-';                     /* replace spaces with dashes */
        *(s++) = ' ';
      }
      if ( bstr )
      {
        ft_strcpy( s, bstr );
        s += ft_strlen( bstr );
        *(s++) = ' ';
      }
      if ( istr )
      {
        ft_strcpy( s, istr );
        s += ft_strlen( istr );
        *(s++) = ' ';
      }
      if ( sstr )
      {
        ft_strcpy( s, sstr );
        for ( i = 0; i < ft_strlen( sstr ); i++, s++ )
          if ( *s == ' ' )
            *s = '-';                     /* replace spaces with dashes */
        *(s++) = ' ';
      }
      *(--s) = '\0';        /* overwrite last ' ', terminate the string */

      face->style_name = style;                     /* allocated string */
    }

    return error;
  }
Exemplo n.º 13
0
  static FT_Error
  pcf_get_properties( FT_Stream  stream,
                      PCF_Face   face )
  {
    PCF_ParseProperty  props      = 0;
    PCF_Property       properties = 0;
    FT_Int             nprops, i;
    FT_ULong           format, size;
    FT_Error           error;
    FT_Memory          memory     = FT_FACE(face)->memory;
    FT_ULong           string_size;
    FT_String*         strings    = 0;


    error = pcf_seek_to_table_type( stream,
                                    face->toc.tables,
                                    face->toc.count,
                                    PCF_PROPERTIES,
                                    &format,
                                    &size );
    if ( error )
      goto Bail;

    if ( FT_READ_ULONG_LE( format ) )
      goto Bail;

    FT_TRACE4(( "pcf_get_properties:\n" ));

    FT_TRACE4(( "  format = %ld\n", format ));

    if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
      goto Bail;

    if ( PCF_BYTE_ORDER( format ) == MSBFirst )
      (void)FT_READ_ULONG( nprops );
    else
      (void)FT_READ_ULONG_LE( nprops );
    if ( error )
      goto Bail;

    FT_TRACE4(( "  nprop = %d\n", nprops ));

    if ( FT_NEW_ARRAY( props, nprops ) )
      goto Bail;

    for ( i = 0; i < nprops; i++ )
    {
      if ( PCF_BYTE_ORDER( format ) == MSBFirst )
      {
        if ( FT_STREAM_READ_FIELDS( pcf_property_msb_header, props + i ) )
          goto Bail;
      }
      else
      {
        if ( FT_STREAM_READ_FIELDS( pcf_property_header, props + i ) )
          goto Bail;
      }
    }

    /* pad the property array                                            */
    /*                                                                   */
    /* clever here - nprops is the same as the number of odd-units read, */
    /* as only isStringProp are odd length   (Keith Packard)             */
    /*                                                                   */
    if ( nprops & 3 )
    {
      i = 4 - ( nprops & 3 );
      FT_Stream_Skip( stream, i );
    }

    if ( PCF_BYTE_ORDER( format ) == MSBFirst )
      (void)FT_READ_ULONG( string_size );
    else
      (void)FT_READ_ULONG_LE( string_size );
    if ( error )
      goto Bail;

    FT_TRACE4(( "  string_size = %ld\n", string_size ));

    if ( FT_NEW_ARRAY( strings, string_size ) )
      goto Bail;

    error = FT_Stream_Read( stream, (FT_Byte*)strings, string_size );
    if ( error )
      goto Bail;

    if ( FT_NEW_ARRAY( properties, nprops ) )
      goto Bail;

    for ( i = 0; i < nprops; i++ )
    {
      /* XXX: make atom */
      if ( FT_NEW_ARRAY( properties[i].name,
                         ft_strlen( strings + props[i].name ) + 1 ) )
        goto Bail;
      ft_strcpy( properties[i].name, strings + props[i].name );

      FT_TRACE4(( "  %s:", properties[i].name ));

      properties[i].isString = props[i].isString;

      if ( props[i].isString )
      {
        if ( FT_NEW_ARRAY( properties[i].value.atom,
                           ft_strlen( strings + props[i].value ) + 1 ) )
          goto Bail;
        ft_strcpy( properties[i].value.atom, strings + props[i].value );

        FT_TRACE4(( " `%s'\n", properties[i].value.atom ));
      }
      else
      {
        properties[i].value.integer = props[i].value;

        FT_TRACE4(( " %d\n", properties[i].value.integer ));
      }
    }

    face->properties = properties;
    face->nprops = nprops;

    FT_FREE( props );
    FT_FREE( strings );

    return PCF_Err_Ok;

  Bail:
    FT_FREE( props );
    FT_FREE( strings );

    return error;
  }
Exemplo n.º 14
0
  pcf_load_font( FT_Stream  stream,
                 PCF_Face   face )
  {
    FT_Error   error  = PCF_Err_Ok;
    FT_Memory  memory = FT_FACE(face)->memory;
    FT_Bool    hasBDFAccelerators;


    error = pcf_read_TOC( stream, face );
    if ( error )
      goto Exit;

    error = pcf_get_properties( stream, face );
    if ( error )
      goto Exit;

    /* Use the old accelerators if no BDF accelerators are in the file. */
    hasBDFAccelerators = pcf_has_table_type( face->toc.tables,
                                             face->toc.count,
                                             PCF_BDF_ACCELERATORS );
    if ( !hasBDFAccelerators )
    {
      error = pcf_get_accel( stream, face, PCF_ACCELERATORS );
      if ( error )
        goto Exit;
    }

    /* metrics */
    error = pcf_get_metrics( stream, face );
    if ( error )
      goto Exit;

    /* bitmaps */
    error = pcf_get_bitmaps( stream, face );
    if ( error )
      goto Exit;

    /* encodings */
    error = pcf_get_encodings( stream, face );
    if ( error )
      goto Exit;

    /* BDF style accelerators (i.e. bounds based on encoded glyphs) */
    if ( hasBDFAccelerators )
    {
      error = pcf_get_accel( stream, face, PCF_BDF_ACCELERATORS );
      if ( error )
        goto Exit;
    }

    /* XXX: TO DO: inkmetrics and glyph_names are missing */

    /* now construct the face object */
    {
      FT_Face       root = FT_FACE( face );
      PCF_Property  prop;


      root->num_faces  = 1;
      root->face_index = 0;
      root->face_flags = FT_FACE_FLAG_FIXED_SIZES |
                         FT_FACE_FLAG_HORIZONTAL  |
                         FT_FACE_FLAG_FAST_GLYPHS;

      if ( face->accel.constantWidth )
        root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;

      if ( ( error = pcf_interpret_style( face ) ) != 0 )
         goto Exit;

      prop = pcf_find_property( face, "FAMILY_NAME" );
      if ( prop && prop->isString )
      {
        int  l = ft_strlen( prop->value.atom ) + 1;


        if ( FT_NEW_ARRAY( root->family_name, l ) )
          goto Exit;
        ft_strcpy( root->family_name, prop->value.atom );
      }
      else
        root->family_name = NULL;

      /* Note: We shift all glyph indices by +1 since we must
       * respect the convention that glyph 0 always corresponds
       * to the "missing glyph".
       *
       * This implies bumping the number of "available" glyphs by 1.
       */
      root->num_glyphs = face->nmetrics + 1;

      root->num_fixed_sizes = 1;
      if ( FT_NEW_ARRAY( root->available_sizes, 1 ) )
        goto Exit;

      {
        FT_Bitmap_Size*  bsize = root->available_sizes;
        FT_Short         resolution_x = 0, resolution_y = 0;


        FT_MEM_ZERO( bsize, sizeof ( FT_Bitmap_Size ) );

#if 0
        bsize->height = face->accel.maxbounds.ascent << 6;
#endif
        bsize->height = (FT_Short)( face->accel.fontAscent +
                                    face->accel.fontDescent );

        prop = pcf_find_property( face, "AVERAGE_WIDTH" );
        if ( prop )
          bsize->width = (FT_Short)( ( prop->value.integer + 5 ) / 10 );
        else
          bsize->width = (FT_Short)( bsize->height * 2/3 );

        prop = pcf_find_property( face, "POINT_SIZE" );
        if ( prop )
          /* convert from 722.7 decipoints to 72 points per inch */
          bsize->size =
            (FT_Pos)( ( prop->value.integer * 64 * 7200 + 36135L ) / 72270L );

        prop = pcf_find_property( face, "PIXEL_SIZE" );
        if ( prop )
          bsize->y_ppem = (FT_Short)prop->value.integer << 6;

        prop = pcf_find_property( face, "RESOLUTION_X" );
        if ( prop )
          resolution_x = (FT_Short)prop->value.integer;

        prop = pcf_find_property( face, "RESOLUTION_Y" );
        if ( prop )
          resolution_y = (FT_Short)prop->value.integer;

        if ( bsize->y_ppem == 0 )
        {
          bsize->y_ppem = bsize->size;
          if ( resolution_y )
            bsize->y_ppem = bsize->y_ppem * resolution_y / 72;
        }
        if ( resolution_x && resolution_y )
          bsize->x_ppem = bsize->y_ppem * resolution_x / resolution_y;
        else
          bsize->x_ppem = bsize->y_ppem;
      }

      /* set up charset */
      {
        PCF_Property  charset_registry = 0, charset_encoding = 0;


        charset_registry = pcf_find_property( face, "CHARSET_REGISTRY" );
        charset_encoding = pcf_find_property( face, "CHARSET_ENCODING" );

        if ( charset_registry && charset_registry->isString &&
             charset_encoding && charset_encoding->isString )
        {
          if ( FT_NEW_ARRAY( face->charset_encoding,
                             ft_strlen( charset_encoding->value.atom ) + 1 ) )
            goto Exit;

          if ( FT_NEW_ARRAY( face->charset_registry,
                             ft_strlen( charset_registry->value.atom ) + 1 ) )
            goto Exit;

          ft_strcpy( face->charset_registry, charset_registry->value.atom );
          ft_strcpy( face->charset_encoding, charset_encoding->value.atom );
        }
      }
    }

  Exit:
    if ( error )
    {
      /* this is done to respect the behaviour of the original */
      /* PCF font driver.                                      */
      error = PCF_Err_Invalid_File_Format;
    }

    return error;
  }
Exemplo n.º 15
0
void		test_ft_strlen(void)
{
	char str1[] = "Ici, la taille compte";
	char str2[] = "Oui mais on dit quelle ne compte pas";
	char str3[] = "Seulement les rageux disent ça\n\n\n\n";
	char str4[] = "Moi je ne suis\0 pourtant pas un rageu";
	char str5[] = "T'en a pas marre de parler solo?";
	char str6[] = "Un peu, on arrête là";
	char str7[] = "Ok!";

	(ft_strlen(str1) == strlen(str1)) ? ft_putstr("\033[32mOK \033[m") : ft_putstr("\033[31mFAIL \033[m");
	printf("%s -> strlen: %zd, ft_strlen: %zd\n", str1, strlen(str1), ft_strlen(str1));

	(ft_strlen(str2) == strlen(str2)) ? ft_putstr("\033[32mOK \033[m") : ft_putstr("\033[31mFAIL \033[m");
	printf("%s -> strlen: %zd, ft_strlen: %zd\n", str2, strlen(str2), ft_strlen(str2));

	(ft_strlen(str3) == strlen(str3)) ? ft_putstr("\033[32mOK \033[m") : ft_putstr("\033[31mFAIL \033[m");
	printf("Seulement les rageux disent ca\\n\\n\\n\\n-> strlen: %zd, ft_strlen: %zd\n", strlen(str3), ft_strlen(str3));

	(ft_strlen(str4) == strlen(str4)) ? ft_putstr("\033[32mOK \033[m") : ft_putstr("\033[31mFAIL \033[m");
	printf("%s -> strlen: %zd, ft_strlen: %zd\n", str4, strlen(str4), ft_strlen(str4));

	(ft_strlen(str5) == strlen(str5)) ? ft_putstr("\033[32mOK \033[m") : ft_putstr("\033[31mFAIL \033[m");
	printf("%s -> strlen: %zd, ft_strlen: %zd\n", str1, strlen(str5), ft_strlen(str5));

	(ft_strlen(str6) == strlen(str6)) ? ft_putstr("\033[32mOK \033[m") : ft_putstr("\033[31mFAIL \033[m");
	printf("%s -> strlen: %zd, ft_strlen: %zd\n", str1, strlen(str6), ft_strlen(str6));

	(ft_strlen(str7) == strlen(str7)) ? ft_putstr("\033[32mOK \033[m") : ft_putstr("\033[31mFAIL \033[m");
	printf("%s -> strlen: %zd, ft_strlen: %zd\n", str1, strlen(str7), ft_strlen(str7));
}
Exemplo n.º 16
0
  static FT_Error
  pcf_interpret_style( PCF_Face  pcf )
  {
    FT_Error   error  = FT_Err_Ok;
    FT_Face    face   = FT_FACE( pcf );
    FT_Memory  memory = face->memory;

    PCF_Property  prop;

    size_t  nn, len;
    char*   strings[4] = { NULL, NULL, NULL, NULL };
    size_t  lengths[4];


    face->style_flags = 0;

    prop = pcf_find_property( pcf, "SLANT" );
    if ( prop && prop->isString                                       &&
         ( *(prop->value.atom) == 'O' || *(prop->value.atom) == 'o' ||
           *(prop->value.atom) == 'I' || *(prop->value.atom) == 'i' ) )
    {
      face->style_flags |= FT_STYLE_FLAG_ITALIC;
      strings[2] = ( *(prop->value.atom) == 'O' ||
                     *(prop->value.atom) == 'o' ) ? (char *)"Oblique"
                                                  : (char *)"Italic";
    }

    prop = pcf_find_property( pcf, "WEIGHT_NAME" );
    if ( prop && prop->isString                                       &&
         ( *(prop->value.atom) == 'B' || *(prop->value.atom) == 'b' ) )
    {
      face->style_flags |= FT_STYLE_FLAG_BOLD;
      strings[1] = (char*)"Bold";
    }

    prop = pcf_find_property( pcf, "SETWIDTH_NAME" );
    if ( prop && prop->isString                                        &&
         *(prop->value.atom)                                           &&
         !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
      strings[3] = (char*)( prop->value.atom );

    prop = pcf_find_property( pcf, "ADD_STYLE_NAME" );
    if ( prop && prop->isString                                        &&
         *(prop->value.atom)                                           &&
         !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
      strings[0] = (char*)( prop->value.atom );

    for ( len = 0, nn = 0; nn < 4; nn++ )
    {
      lengths[nn] = 0;
      if ( strings[nn] )
      {
        lengths[nn] = ft_strlen( strings[nn] );
        len        += lengths[nn] + 1;
      }
    }

    if ( len == 0 )
    {
      strings[0] = (char*)"Regular";
      lengths[0] = ft_strlen( strings[0] );
      len        = lengths[0] + 1;
    }

    {
      char*  s;


      if ( FT_ALLOC( face->style_name, len ) )
        return error;

      s = face->style_name;

      for ( nn = 0; nn < 4; nn++ )
      {
        char*  src = strings[nn];


        len = lengths[nn];

        if ( src == NULL )
          continue;

        /* separate elements with a space */
        if ( s != face->style_name )
          *s++ = ' ';

        ft_memcpy( s, src, len );

        /* need to convert spaces to dashes for */
        /* add_style_name and setwidth_name     */
        if ( nn == 0 || nn == 3 )
        {
          size_t  mm;


          for ( mm = 0; mm < len; mm++ )
            if ( s[mm] == ' ' )
              s[mm] = '-';
        }

        s += len;
      }
      *s = 0;
    }

    return error;
  }
Exemplo n.º 17
0
int		ft_putstr_fd(char const *str, int fd)
{
	if (!str)
		return (write(fd, FT_INVALID_STR, ft_strlen(FT_INVALID_STR)));
	return (write(fd, str, ft_strlen(str)));
}
Exemplo n.º 18
0
int	make_error(t_env *e, char *error)
{
	write(e->fd, error, ft_strlen(error));
	return (-1);
}
Exemplo n.º 19
0
void	ft_strclr(char *s)
{
	if (s != NULL)
		s = (char*)ft_memset((void*)s, '\0', (size_t)(ft_strlen(s) + 1));
}
Exemplo n.º 20
0
Arquivo: conv_arg.c Projeto: NSSX/prl
// SDU
//http://personal.ee.surrey.ac.u           k/Personal/R.Bowden/C/printf.html
int manage_arg(t_main *main)
{
	main->i++;
	if(main->chaine[main->i] == 'd' || main->chaine[main->i] == 'i')
	{
		if((main->accurate == 0 && main->width != 0) || 
			(find(main,'.') == 1 && main->accurate < 1 && main->width != 0)||
			((int)main->elem == 0 && find(main,'.') == 1 && main->accurate < 1))
		{
			return(0);
		}

		long long int a;
		a = (long long int)main->elem;
		if ((int)a < 0 && main->type == 0)// || (long int)a < 0 || (long long int)a < 0)
			main->signemoin = 1;
		else if ((long int)a < 0 && main->type == 1)
			main->signemoin = 1;
		else if ((long long int)a < 0 && main->type == 2)
			main->signemoin = 1;
		if(main->type == 0)
			join_d(main);
		else  if(main->type == 1)
			join_ld(main);
		else  if(main->type == 2)
			join_lld(main);
		else if(main->type == 3)
			join_hd(main);
		else if(main->type == 4)
			join_hhd(main);
		else if(main->type == 5)
			join_jd(main);
		else if(main->type == 6)
			join_zd(main);

		if(main->signemoin == 1)
		{
			int i = 0;
			int i2 = 0;
			char *temp;
			temp = (char *)malloc(sizeof(char) + ft_strlen(main->print));
			while(main->print[i] != '\0')
			{
				if(main->print[i] != '-')
				{

					temp[i2] = main->print[i];
					i2++;
				}
				i++;
			}
			temp[i2] = '\0';
			main->print = temp;
			main->print = ft_strjoin("-", main->print);
		}

	}  
	else if(main->chaine[main->i] == 'D')
	{
		if(main->type > 0)
		{
			main->type++;
		}
		else
			main->type = 1;
		if(main->type == 1)
			join_ld(main);
		else  if(main->type == 2)
			join_lld(main);
		else if(main->type == 3)
			join_hd(main);
		else if(main->type == 4)
			join_hhd(main);
		else if(main->type == 5)
			join_jd(main);
		else if(main->type == 6)
			join_zd(main);
	}

	else if(main->chaine[main->i] == 'o')
	{
		if(((main->accurate == 0 && main->width != 0) || 
			(find(main,'.') == 1 && main->accurate < 1 && main->width != 0)||
			((unsigned int)main->elem == 0 && find(main,'.') == 1 && main->accurate < 1)) && main->dietat == 0)
		{
			return(0);
		}

		if(main->dietat == 1)
		{
			main->print = ft_strjoin(main->print, "0");
			main->size++;
		}
		if((unsigned long long int)main->elem != 0)
			base_converter(main, (unsigned long long int)main->elem, 8);
		else if(main->dietat == 0)
		{
			main->size++;
			main->print = ft_strjoin(main->print, "0");
		}
		accurate_d(ft_strlen(main->print), main);
	}
	else if(main->chaine[main->i] == 'u')
	{
		if(main->type == 0)
			join_u(main);
		else  if(main->type == 1)
			join_lu(main);
		else  if(main->type == 2)
			join_llu(main);
		else if(main->type == 3)
			join_hu(main);
		else if(main->type == 4)
			join_hhu(main);
		else if(main->type == 5)
			join_ju(main);
		else if(main->type == 6)
			join_zu(main);
	}
	else if(main->chaine[main->i] == 'U')
	{
		if(main->type > 0)
		{
			main->type++;
		}
		else
			main->type = 1;
		if(main->type == 1)
			join_lu(main);
		else  if(main->type == 2)
			join_llu(main);
		else if(main->type == 3)
			join_hu(main);
		else if(main->type == 4)
			join_hhu(main);
		else if(main->type == 5)
			join_ju(main);
		else if(main->type == 6)
			join_zu(main);
	}
	else if(main->chaine[main->i] == 's')
	{
		if((char *)main->elem)
		{
			if(main->accurate == -1)
				main->accurate = ft_strlen((char *)main->elem);
			int i;
			char *lp;

			lp = (char *)main->elem;
			lp = ft_strsub(lp, 0, main->accurate);
			i = 0;
			main->print = ft_strjoin(main->print, &lp[0]);
			if((size_t)main->accurate > ft_strlen(lp))
				main->size = ft_strlen(lp);
			else
				main->size += main->accurate;
		}
		else
		{
			char *null;
			int i;
			i = 0;
			null = "(null)";
			if(main->accurate > 0)
			{
				while(i < main->accurate && i < 6)
				{
					main->print= ft_strjoin_carac(main->print, null[i]);
					main->size++;
					i++;
				}
			}
			else
			{
				main->print= ft_strjoin(main->print, null);
				main->size += 6;
			}
		}
	}
	else if(main->chaine[main->i] == 'S')
	{
		if((wchar_t *)main->elem)
		{
			int i;
			wchar_t *chaine;

			chaine = (wchar_t *)main->elem;
			i=0;
			while(chaine[i] != '\0')
			{
				mywchar(main, chaine[i]);
				i++;
			}
		}
		else
		{
			char *null;
			int i;
			i = 0;
			null = "(null)";
			if(main->accurate > 0)
			{
				while(i < main->accurate && i < 6)
				{
					main->print= ft_strjoin_carac(main->print, null[i]);
					main->size++;
					i++;
				}
			}
			else
			{
				main->print= ft_strjoin(main->print, null);
				main->size += 6;
			}
		}

	}
	else if(main->chaine[main->i] == 'c')
	{
		if((int)main->elem != 0)
		{
			main->size++;
			main->print = ft_strjoin_carac(main->print, (int)main->elem);
		}
		else
		{
			main->size++;
		}
	}
	else if(main->chaine[main->i] == 'C')
	{
		if((wint_t)main->elem != 0)
			mywchar(main, (wint_t)main->elem);
		else
			main->size++;
	}
	else if(main->chaine[main->i] == '%')
	{
		main->size++;
		main->print = ft_strjoin_carac(main->print, '%');
	}
	else if(main->chaine[main->i] == 'p')
	{
		if((unsigned long long int)main->elem == 0)
		{
			main->size += 3;
			main->print = ft_strjoin(main->print, "0x0");
		}
		else
		{
			main->size += 2;
			main->print = ft_strjoin(main->print, "0x");
			base_converter(main, (unsigned long long int)main->elem, 16);
		}

	}
	else if(main->chaine[main->i] == 'x')
	{
			if((main->accurate == 0 && main->width != 0) || 
			(find(main,'.') == 1 && main->accurate < 1 && main->width != 0)||
			((unsigned int)main->elem == 0 && find(main,'.') == 1 && main->accurate < 1))
		{
			return(0);
		}

		if((unsigned long long int)main->elem != 4294967296 || main->type >= 1)
		{
			if(main->dietat == 1 && (unsigned long long int)main->elem != 0)
			{
				//      main->print = ft_strjoin(main->print, "0x");
				main->size += 2;
			}
			if((unsigned long long int)main->elem != 0)
			{
				if(main->type == 0)
					base_converter(main, (unsigned int)main->elem, 16);
				else  if(main->type == 1)
					base_converter(main, (unsigned long int)main->elem, 16);
				else  if(main->type == 2)
					base_converter(main, (unsigned long long int)main->elem, 16);
				else if(main->type == 3)
					base_converter(main, (unsigned short int)main->elem, 16);
				else if(main->type == 4)
					base_converter(main, (unsigned char)main->elem, 16);
				else if(main->type == 5)
					base_converter(main, (uintmax_t)main->elem, 16);
				else if(main->type == 6)
					base_converter(main, (size_t)main->elem, 16);
				if(main->print[0] == '\0')
				{
					main->size++;
					main->print = ft_strjoin(main->print, "0");
				}   
			}
			else
			{
				main->size++;
				main->print = ft_strjoin(main->print, "0");
			}
		}
		else
		{
			main->size++;
			main->print = ft_strjoin(main->print, "0");
		}
	}
	else if(main->chaine[main->i] == 'X')
	{
		if((unsigned long long int)main->elem != 4294967296 || main->type >= 1)
		{
			if(main->dietat == 1 && (unsigned long long int)main->elem != 0)
			{
				//	      main->print = ft_strjoin(main->print,"0X");
				main->size += 2;        
			}
			if((unsigned long long int)main->elem != 0)
			{
				if(main->type == 0)
					base_converter_upper(main, (unsigned int)main->elem, 16);
				else  if(main->type == 1)
					base_converter_upper(main, (unsigned long int)main->elem, 16);
				else  if(main->type == 2)
					base_converter_upper(main, (unsigned long long int)main->elem, 16);
				else if(main->type == 3)
					base_converter_upper(main, (unsigned short int)main->elem, 16);
				else if(main->type == 4)
					base_converter_upper(main, (unsigned char)main->elem, 16);
				else if(main->type == 5)
					base_converter_upper(main, (uintmax_t)main->elem, 16);
				else if(main->type == 6)
					base_converter_upper(main, (size_t)main->elem, 16);
				if(main->print[0] == '\0')
				{
					main->size++;
					main->print = ft_strjoin(main->print, "0");
				} 
			}
			else
			{
				main->size++;
				main->print = ft_strjoin(main->print, "0");
			}
		}
		else
		{
			main->size++;
			main->print = ft_strjoin(main->print, "0");
		}
	}
	else
		main->i--;
	return (1);
}
Exemplo n.º 21
0
void	ft_putstr(char const *s)
{
	if (s)
		write(1, s, ft_strlen(s));
}
Exemplo n.º 22
0
void	ft_strclr(char *s)
{
	if (s != NULL)
		ft_bzero(s, ft_strlen(s));
}
Exemplo n.º 23
0
void		ft_display_no_details(s_data *data)
{
	write(1, data->ls->name, ft_strlen(data->ls->name));
	write(1, "\n", 1);
}
Exemplo n.º 24
0
  static  FT_Error
  lookup_lwfn_by_fond( const UInt8*      path_fond,
                       ConstStr255Param  base_lwfn,
                       UInt8*            path_lwfn,
                       int               path_size )
  {

#if HAVE_FSREF

    FSRef  ref, par_ref;
    int    dirname_len;


    /* Pathname for FSRef can be in various formats: HFS, HFS+, and POSIX. */
    /* We should not extract parent directory by string manipulation.      */

    if ( noErr != FSPathMakeRef( path_fond, &ref, FALSE ) )
      return FT_Err_Invalid_Argument;

    if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone,
                                    NULL, NULL, NULL, &par_ref ) )
      return FT_Err_Invalid_Argument;

    if ( noErr != FSRefMakePath( &par_ref, path_lwfn, path_size ) )
      return FT_Err_Invalid_Argument;

    if ( ft_strlen( (char *)path_lwfn ) + 1 + base_lwfn[0] > path_size )
      return FT_Err_Invalid_Argument;

    /* now we have absolute dirname in path_lwfn */
    if ( path_lwfn[0] == '/' )
      ft_strcat( (char *)path_lwfn, "/" );
    else
      ft_strcat( (char *)path_lwfn, ":" );

    dirname_len = ft_strlen( (char *)path_lwfn );
    ft_strcat( (char *)path_lwfn, (char *)base_lwfn + 1 );
    path_lwfn[dirname_len + base_lwfn[0]] = '\0';

    if ( noErr != FSPathMakeRef( path_lwfn, &ref, FALSE ) )
      return FT_Err_Cannot_Open_Resource;

    if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone,
                                    NULL, NULL, NULL, NULL ) )
      return FT_Err_Cannot_Open_Resource;

    return FT_Err_Ok;

#else

    int     i;
    FSSpec  spec;


    /* pathname for FSSpec is always HFS format */
    if ( ft_strlen( (char *)path_fond ) > path_size )
      return FT_Err_Invalid_Argument;

    ft_strcpy( (char *)path_lwfn, (char *)path_fond );

    i = ft_strlen( (char *)path_lwfn ) - 1;
    while ( i > 0 && ':' != path_lwfn[i] )
      i--;

    if ( i + 1 + base_lwfn[0] > path_size )
      return FT_Err_Invalid_Argument;

    if ( ':' == path_lwfn[i] )
    {
      ft_strcpy( (char *)path_lwfn + i + 1, (char *)base_lwfn + 1 );
      path_lwfn[i + 1 + base_lwfn[0]] = '\0';
    }
    else
    {
      ft_strcpy( (char *)path_lwfn, (char *)base_lwfn + 1 );
      path_lwfn[base_lwfn[0]] = '\0';
    }

    if ( noErr != FT_FSPathMakeSpec( path_lwfn, &spec, FALSE ) )
      return FT_Err_Cannot_Open_Resource;

    return FT_Err_Ok;

#endif /* HAVE_FSREF */

  }
Exemplo n.º 25
0
void	ft_putstr_fd(char const *s, int fd)
{
	if (s)
		write(fd, s, ft_strlen(s));
}
Exemplo n.º 26
0
void	ft_putstr_color(char *color, char *s)
{
	write(1, color, ft_strlen(color));
	write(1, s, ft_strlen(s));
	write(1, DEFAULT_COLOR, 6);
}
Exemplo n.º 27
0
void	ft_putendl_fd(char const *s, int fd)
{
	write(fd, s, ft_strlen(s));
	write(fd, "\n", 1);
}
Exemplo n.º 28
0
//debug.c
void	inspect_part(t_printf_part *part) //debug
{
	static int count = 0;
	count++;
	printf("[%02d ", count);

	
	printf("[");
    int i;
    for(i=8 * 1 - 1; i>=0; i--)
    {
		if (i / 8 < 1)
			printf("\033[35m"); fflush(stdout);
        ((part->flags) & (1 << i%8)) ? putchar('1') : putchar('0');
		printf("\033[39m"); fflush(stdout);
    }
	printf("]");
	
	printf("[");
    for(i=8 * 1 - 1; i>=0; i--)
    {
		if (i / 8 < 1)
			printf("\033[35m"); fflush(stdout);
        ((part->info) & (1 << i%8)) ? putchar('1') : putchar('0');
		printf("\033[39m"); fflush(stdout);
    }
	printf("] ");
	
	printf("wi.pr(%02d.%02d) ", part->width, part->precision);
	
	// printf("len:(%hu|", part->length);
	if (part->length > (int)ft_strlen(CHARS_LENGTH))
		printf("%c%c) ", CHARS_LENGTH[part->length - NUM_DBL_CHAR_LEN - 1], CHARS_LENGTH[part->length - NUM_DBL_CHAR_LEN - 1]);
	else if (part->length > 0)
		printf("%c ) ", CHARS_LENGTH[part->length - 1]);
	else 
		printf("  ) ");
		
		
	// printf("spe:(%2hu|", part->specifier);
	printf("%c) ", part->specifier ? CHARS_SPECIFIERS[part->specifier - 1] : ' ');
	
	char *repro;
	char *temp;
	temp = malloc(200);
	sprintf(temp, "%%"); repro = (char *)ft_strjoin("", temp);
	
	#define JOIN_REPRO repro = (char *)ft_strjoin(repro, temp);
//	{ sprintf(temp, ); JOIN_REPRO; }
	for(i = 0; i < 5; i++)
	{
		if (part->flags & (1 << i))
			{ sprintf(temp, "%c", CHARS_FLAGS[i]); JOIN_REPRO; }
	}
	
	if (part->info & WSTA_MASK)
		{ sprintf(temp, "*"); JOIN_REPRO; }
	else if (part->width)
		{ sprintf(temp, "%d", part->width); JOIN_REPRO; }

	if (part->info & PSTA_MASK)
		{ sprintf(temp, ".*"); JOIN_REPRO; }
	else if (part->precision)
		{ sprintf(temp, ".%d", part->precision); JOIN_REPRO; }
	if (part->length > (int)ft_strlen(CHARS_LENGTH))
		{ sprintf(temp, "%c%c", CHARS_LENGTH[part->length - NUM_DBL_CHAR_LEN - 1], CHARS_LENGTH[part->length - NUM_DBL_CHAR_LEN - 1]); JOIN_REPRO; }
	else if (part->length > 0)
		{ sprintf(temp, "%c", CHARS_LENGTH[part->length - 1]); JOIN_REPRO; }
	{ sprintf(temp, "%c", CHARS_SPECIFIERS[part->specifier - 1]); JOIN_REPRO; }
	repro = part->specifier ? repro : "";
	printf("%-15s ", repro); fflush(stdout);
	
	
	// printf("%2zu \033[36m|=>|\033[39m", part->str_size); fflush(stdout); ft_myputnchar((char*)part->str_ptr, part->str_size); printf("\033[36m&\033[39m");


	fflush(stdout); ft_myputnchar(part->nbr_ptr, (int)ft_strlen(part->nbr_ptr));
	
	
	
	printf("\033[36m]\n\033[39m");
	fflush(stdout);
	if (*repro) free(repro);
}
Exemplo n.º 29
0
void		ft_putstr(char const *str)
{
	write(1, str, ft_strlen(str));
}
Exemplo n.º 30
0
void		ft_putstr_red_fd(char const *str, int fd)
{
	ft_putstr_fd("\033[1;91m", fd);
	write(fd, str, ft_strlen(str));
	ft_putstr_fd("\033[0m", fd);
}