summary refs log blame commit diff stats
path: root/src/common/util.h
blob: 8114cbc79b221112a062f5412756b22a2fc4a971 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                                                                           

                      
 
                     















                                                                                  
                                 











                                                                  

                                                           
                        
                                     


                                                                       
                                    
                                                                               



                                                                                         
                                
                     
                    
                                       
                                                

      
/************************************************************************
 *    This technique was borrowed in part from the source code to 
 *    ircd-hybrid-5.3 to implement case-insensitive string matches which
 *    are fully compliant with Section 2.2 of RFC 1459, the copyright
 *    of that code being (C) 1990 Jarkko Oikarinen and under the GPL.
 *    
 *    A special thanks goes to Mr. Okarinen for being the one person who
 *    seems to have ever noticed this section in the original RFC and
 *    written code for it.  Shame on all the rest of you (myself included).
 *    
 *        --+ Dagmar d'Surreal
 */

#ifndef HEXCHAT_UTIL_H
#define HEXCHAT_UTIL_H

#include "strlutil.h"
#define rfc_tolower(c) (rfc_tolowertab[(unsigned char)(c)])

extern const unsigned char rfc_tolowertab[];

int my_poptParseArgvString(const char * s, int * argcPtr, char *** argvPtr);
char *expand_homedir (char *file);
void path_part (char *file, char *path, int pathlen);
int match (const char *mask, const char *string);
char *file_part (char *file);
void for_files (char *dirname, char *mask, void callback (char *file));
int rfc_casecmp (const char *, const char *);
int rfc_ncasecmp (char *, char *, int);
int buf_get_line (char *, char **, int *, int len);
char *nocasestrstr (const char *text, const char *tofind);
char *country (char *);
void country_search (char *pattern, void *ud, void (*print)(void *, char *, ...));
char *get_sys_str (int with_cpu);
int util_exec (const char *cmd);
int util_execv (char * const argv[]);
#define STRIP_COLOR 1
#define STRIP_ATTRIB 2
#define STRIP_HIDDEN 4
#define STRIP_ESCMARKUP 8
#define STRIP_ALL 7
gchar *strip_color (const char *text, int len, int flags);
int strip_color2 (const char *src, int len, char *dst, int flags);
int strip_hidden_attribute (char *src, char *dst);
char *errorstring (int err);
int waitline (int sok, char *buf, int bufsize, int);
#ifdef WIN32
int waitline2 (GIOChannel *source, char *buf, int bufsize);
int get_cpu_arch (void);
int find_font (const char *fontname);
#else
#define waitline2(source,buf,size) waitline(serv->childread,buf,size,0)
#endif
unsigned long make_ping_time (void);
void move_file (char *src_dir, char *dst_dir, char *fname, int dccpermissions);
int token_foreach (char *str, char sep, int (*callback) (char *str, void *ud), void *ud);
guint32 str_hash (const char *key);
guint32 str_ihash (const unsigned char *key);
void safe_strcpy (char *dest, const char *src, int bytes_left);
void canonalize_key (char *key);
int portable_mode ();
int hextray_mode ();
GSList *get_subdirs (const char *path);
char *encode_sasl_pass (char *user, char *pass);

#endif
"nv">%mm0 /* r0 00 */ psllw $5, %mm1 /* 0g g0 */ por %mm2, %mm0 /* r0 0b */ por %mm1, %mm0 /* rg gb */ movq %mm0, (%esi, %ecx, 2) addl $4, %ecx js 2b jmp 4f 3: movw (%esi, %ecx, 2), %ax movd %eax, %mm0 movq %mm0, %mm1 /* rg gb */ movq %mm0, %mm2 /* rg gb */ psrlw $5, %mm1 /* 0r rg */ psrlw $10, %mm0 /* 00 0r */ psllw $11, %mm2 /* b0 00 */ psllw $11, %mm1 /* g0 00 */ psllw $8, %mm0 /* 0r 00 */ psrlw $3, %mm1 /* 0g 00 */ psrlw $3, %mm2 /* 0b 00 */ pmulhw %mm5, %mm0 /* 00 0r */ pmulhw %mm6, %mm1 /* 00 0g */ pmulhw %mm7, %mm2 /* 00 0b */ psllw $10, %mm0 /* r0 00 */ psllw $5, %mm1 /* 0g g0 */ por %mm2, %mm0 /* r0 0b */ por %mm1, %mm0 /* rg gb */ movd %mm0, %eax movw %ax, (%esi, %ecx, 2) incl %ecx 4: cmpl $2, %ecx jng 3b addl bpl, %esi decl %edx jnz 1b 5: LEAVE shade_ximage_15_mmx_saturate: pcmpeqw %mm3, %mm3 psllw $5, %mm3 /* ff e0 ff e0 ff e0 ff e0 */ 1: movl %ebx, %ecx addl $3, %ecx jns 3f 2: movq (%esi, %ecx, 2), %mm0 movq %mm0, %mm1 /* rg gb */ movq %mm0, %mm2 /* rg gb */ psrlw $5, %mm1 /* 0r rg */ psrlw $10, %mm0 /* 00 0r */ psllw $11, %mm2 /* b0 00 */ psllw $11, %mm1 /* g0 00 */ psllw $8, %mm0 /* 0r 00 */ psrlw $3, %mm1 /* 0g 00 */ psrlw $3, %mm2 /* 0b 00 */ pmulhw %mm5, %mm0 /* xx xr */ pmulhw %mm6, %mm1 /* xx xg */ pmulhw %mm7, %mm2 /* xx xb */ /* Saturate upper */ paddusw %mm3, %mm0 /* ff er */ paddusw %mm3, %mm1 /* ff eg */ paddusw %mm3, %mm2 /* ff eb */ psubw %mm3, %mm0 /* 00 0r */ psubw %mm3, %mm1 /* 00 0g */ psubw %mm3, %mm2 /* 00 0b */ psllw $10, %mm0 /* r0 00 */ psllw $5, %mm1 /* 0g g0 */ por %mm2, %mm0 /* r0 0b */ por %mm1, %mm0 /* rg gb */ movq %mm0, (%esi, %ecx, 2) addl $4, %ecx js 2b jmp 4f 3: movw (%esi, %ecx, 2), %ax movd %eax, %mm0 movq %mm0, %mm1 /* rg gb */ movq %mm0, %mm2 /* rg gb */ psrlw $5, %mm1 /* 0r rg */ psrlw $10, %mm0 /* 00 0r */ psllw $11, %mm2 /* b0 00 */ psllw $11, %mm1 /* g0 00 */ psllw $8, %mm0 /* 0r 00 */ psrlw $3, %mm1 /* 0g 00 */ psrlw $3, %mm2 /* 0b 00 */ pmulhw %mm5, %mm0 /* xx xr */ pmulhw %mm6, %mm1 /* xx xg */ pmulhw %mm7, %mm2 /* xx xb */ /* Saturate upper */ paddusw %mm3, %mm0 /* ff er */ paddusw %mm3, %mm1 /* ff eg */ paddusw %mm3, %mm2 /* ff eb */ psubw %mm3, %mm0 /* 00 0r */ psubw %mm3, %mm1 /* 00 0g */ psubw %mm3, %mm2 /* 00 0b */ psllw $10, %mm0 /* r0 00 */ psllw $5, %mm1 /* 0g g0 */ por %mm2, %mm0 /* r0 0b */ por %mm1, %mm0 /* rg gb */ movd %mm0, %eax movw %ax, (%esi, %ecx, 2) incl %ecx 4: cmpl $2, %ecx jng 3b addl bpl, %esi decl %edx jnz 1b 5: LEAVE SHADE_XIMAGE_16: ENTER leal -6(%esi, %ebx, 2), %esi negl %ebx jz 5f /* Setup multipliers */ movd rm, %mm5 movd gm, %mm6 movd bm, %mm7 punpcklwd %mm5, %mm5 /* 00 00 00 00 rm rm rm rm */ punpcklwd %mm6, %mm6 /* 00 00 00 00 gm gm gm gm */ punpcklwd %mm7, %mm7 /* 00 00 00 00 bm bm bm bm */ punpckldq %mm5, %mm5 /* rm rm rm rm rm rm rm rm */ punpckldq %mm6, %mm6 /* gm gm gm gm gm gm gm gm */ punpckldq %mm7, %mm7 /* bm bm bm bm bm bm bm bm */ cmpl $256, rm jg shade_ximage_16_mmx_saturate cmpl $256, gm jg shade_ximage_16_mmx_saturate cmpl $256, bm jg shade_ximage_16_mmx_saturate 1: movl %ebx, %ecx addl $3, %ecx jns 3f 2: movq (%esi, %ecx, 2), %mm0 movq %mm0, %mm1 /* rg gb */ movq %mm0, %mm2 /* rg gb */ psrlw $5, %mm1 /* 0r rg */ psrlw $11, %mm0 /* 00 0r */ psllw $11, %mm2 /* b0 00 */ psllw $10, %mm1 /* g0 00 */ psllw $8, %mm0 /* 0r 00 */ psrlw $2, %mm1 /* 0g 00 */ psrlw $3, %mm2 /* 0b 00 */ pmulhw %mm5, %mm0 /* 00 0r */ pmulhw %mm6, %mm1 /* 00 0g */ pmulhw %mm7, %mm2 /* 00 0b */ psllw $11, %mm0 /* r0 00 */ psllw $5, %mm1 /* 0g g0 */ por %mm2, %mm0 /* r0 0b */ por %mm1, %mm0 /* rg gb */ movq %mm0, (%esi, %ecx, 2) addl $4, %ecx js 2b jmp 4f 3: movw (%esi, %ecx, 2), %ax movd %eax, %mm0 movq %mm0, %mm1 /* rg gb */ movq %mm0, %mm2 /* rg gb */ psrlw $5, %mm1 /* 0r rg */ psrlw $11, %mm0 /* 00 0r */ psllw $11, %mm2 /* b0 00 */ psllw $10, %mm1 /* g0 00 */ psllw $8, %mm0 /* 0r 00 */ psrlw $2, %mm1 /* 0g 00 */ psrlw $3, %mm2 /* 0b 00 */ pmulhw %mm5, %mm0 /* 00 0r */ pmulhw %mm6, %mm1 /* 00 0g */ pmulhw %mm7, %mm2 /* 00 0b */ psllw $11, %mm0 /* r0 00 */ psllw $5, %mm1 /* 0g g0 */ por %mm2, %mm0 /* r0 0b */ por %mm1, %mm0 /* rg gb */ movd %mm0, %eax movw %ax, (%esi, %ecx, 2) incl %ecx 4: cmpl $2, %ecx jng 3b addl bpl, %esi decl %edx jnz 1b 5: LEAVE shade_ximage_16_mmx_saturate: pcmpeqw %mm3, %mm3 movq %mm3, %mm4 psllw $5, %mm3 /* ff e0 ff e0 ff e0 ff e0 */ psllw $6, %mm4 /* ff c0 ff c0 ff c0 ff c0 */ 1: movl %ebx, %ecx addl $3, %ecx jns 3f 2: movq (%esi, %ecx, 2), %mm0 movq %mm0, %mm1 /* rg gb */ movq %mm0, %mm2 /* rg gb */ psrlw $5, %mm1 /* 0r rg */ psrlw $11, %mm0 /* 00 0r */ psllw $11, %mm2 /* b0 00 */ psllw $10, %mm1 /* g0 00 */ psllw $8, %mm0 /* 0r 00 */ psrlw $2, %mm1 /* 0g 00 */ psrlw $3, %mm2 /* 0b 00 */ pmulhw %mm5, %mm0 /* xx xr */ pmulhw %mm6, %mm1 /* xx xg */ pmulhw %mm7, %mm2 /* xx xb */ /* Saturate upper */ paddusw %mm3, %mm0 /* ff er */ paddusw %mm4, %mm1 /* ff cg */ paddusw %mm3, %mm2 /* ff eb */ psubw %mm4, %mm1 /* 00 0g */ psubw %mm3, %mm2 /* 00 0b */ psllw $11, %mm0 /* r0 00 */ psllw $5, %mm1 /* 0g g0 */ por %mm2, %mm0 /* r0 0b */ por %mm1, %mm0 /* rg gb */ movq %mm0, (%esi, %ecx, 2) addl $4, %ecx js 2b jmp 4f 3: movw (%esi, %ecx, 2), %ax movd %eax, %mm0 movq %mm0, %mm1 /* rg gb */ movq %mm0, %mm2 /* rg gb */ psrlw $5, %mm1 /* 0r rg */ psrlw $11, %mm0 /* 00 0r */ psllw $11, %mm2 /* b0 00 */ psllw $10, %mm1 /* g0 00 */ psllw $8, %mm0 /* 0r 00 */ psrlw $2, %mm1 /* 0g 00 */ psrlw $3, %mm2 /* 0b 00 */ pmulhw %mm5, %mm0 /* xx xr */ pmulhw %mm6, %mm1 /* xx xg */ pmulhw %mm7, %mm2 /* xx xb */ /* Saturate upper */ paddusw %mm3, %mm0 /* ff er */ paddusw %mm4, %mm1 /* ff cg */ paddusw %mm3, %mm2 /* ff eb */ psubw %mm4, %mm1 /* 00 0g */ psubw %mm3, %mm2 /* 00 0b */ psllw $11, %mm0 /* r0 00 */ psllw $5, %mm1 /* 0g g0 */ por %mm2, %mm0 /* r0 0b */ por %mm1, %mm0 /* rg gb */ movd %mm0, %eax movw %ax, (%esi, %ecx, 2) incl %ecx 4: cmpl $2, %ecx jng 3b addl bpl, %esi decl %edx jnz 1b 5: LEAVE SHADE_XIMAGE_32: ENTER leal (%esi, %ebx, 4), %esi negl %ebx jz 3f movd rm, %mm4 movd gm, %mm5 movd bm, %mm6 psllq $32, %mm4 psllq $16, %mm5 por %mm6, %mm4 por %mm5, %mm4 pcmpeqw %mm6, %mm6 psllw $15, %mm6 /* 80 00 80 00 80 00 80 00 */ movq %mm6, %mm5 pmulhw %mm4, %mm5 /* Get correction factor */ 1: movl %ebx, %ecx 2: movd (%esi, %ecx, 4), %mm1 /* 00 rr gg bb */ pxor %mm0, %mm0 punpcklbw %mm1, %mm0 /* 00 00 rr 00 gg 00 bb 00 */ pxor %mm6, %mm0 /* Flip sign */ pmulhw %mm4, %mm0 /* 00 00 xx rr xx gg xx bb */ psubw %mm5, %mm0 /* Correct range */ packuswb %mm0, %mm0 /* 00 rr gg bb 00 rr gg bb */ movd %mm0, (%esi, %ecx, 4) incl %ecx jnz 2b addl bpl, %esi decl %edx jnz 1b 3: LEAVE HAVE_MMX: push %ebx /* Check if bit 21 in flags word is writeable */ pushfl popl %eax movl %eax,%ebx xorl $0x00200000, %eax pushl %eax popfl pushfl popl %eax cmpl %eax, %ebx je 8f /* OK, we have CPUID */ movl $1, %eax cpuid test $0x00800000, %edx jz 8f movl $1, %eax /* success, have mmx */ popl %ebx ret 8: xorl %eax,%eax /* failed, no mmx */ popl %ebx ret #if defined(__GNUC__) && !defined(_WIN32) .section .note.GNU-stack, "", @progbits .previous #endif