Ejemplo n.º 1
0
gchar *fake_g_strdup(const gchar *str)
{
#  ifdef DETAIL
	g_debug("! fake_g_strdup(): Trying to strdup(%s)...", str);
#  endif

#  undef g_strdup
#  undef g_strsplit
	if (str==NULL) return NULL;

	gchar *return_str = NULL;
	gchar **strs = g_strsplit(str, " ", 2);
	if (strs)
	{
		if ((! compare_strings(strs[0], "Alt", FALSE)) ||
		    (! compare_strings(strs[0], "Shift", FALSE)) ||
		    (! compare_strings(strs[0], "Ctrl", FALSE)))
		{
			return_str = g_strdup(str);
			// g_debug("fake_g_strdup(): strdup(%s) succeed!!", str);
		}
	}
	g_strfreev (strs);
	return return_str;
#  define g_strdup fake_g_strdup
#  define g_strsplit fake_g_strsplit
}
Ejemplo n.º 2
0
Archivo: lpc.c Proyecto: lanceit/cups
static void
do_command(http_t     *http,		/* I - HTTP connection to server */
           const char *command,		/* I - Command string */
	   const char *params)		/* I - Parameters for command */
{
  if (!compare_strings(command, "status", 4))
    show_status(http, params);
  else if (!compare_strings(command, "help", 1) || !strcmp(command, "?"))
    show_help(params);
  else
    _cupsLangPrintf(stdout,
                    _("%s is not implemented by the CUPS version of lpc."),
		    command);
}
Ejemplo n.º 3
0
int nl_compare_internal(ImmT left, ImmT right) {
	if (_global_const_begin_ != NULL && left >= _global_const_begin_ && left < _global_const_end_ 
			&& right >= _global_const_begin_ && right < _global_const_end_) {
		return left == right;
	}
	if (((NlData *)left)->type != ((NlData *)right)->type) {
		if(IS_INT(left) && IS_STRING(right))
			return eq_int_string((NlInt *)left, (NlString *)right);
		if(IS_INT(right) && IS_STRING(left))
			return eq_int_string((NlInt *)right, (NlString *)left);
			
		if(IS_INT(right) && IS_FLOAT(left))
			return ((NlInt *)right)->i == ((NlFloat *)left)->f;
		if(IS_INT(left) && IS_FLOAT(right))
			return ((NlInt *)left)->i == ((NlFloat *)right)->f;
			
		if(IS_FLOAT(left) && IS_STRING(right))
			return eq_float_string((NlFloat *)left, (NlString *)right);
		if(IS_FLOAT(right) && IS_STRING(left))
			return eq_float_string((NlFloat *)right, (NlString *)left);
		return 0;
	}
	if (((NlData *)left)->type == ___TYPE_STRING) {
		return compare_strings((NlString *)left, (NlString *)right) == 0;
	} else if (((NlData *)left)->type == ___TYPE_INT) {
		return (((NlInt *)left)->i == ((NlInt *)right)->i);
	} else if (((NlData *)left)->type == ___TYPE_FLOAT) {
		return (((NlFloat *)left)->f == ((NlFloat *)right)->f);
	} else {
		return left == right;
	}
}
Ejemplo n.º 4
0
void FileManager :: printValorDeCampo(const char* columna ,int num_fila){
    char* temp_register = (char*)calloc(1,*sizeOfRegister); //registro temporal para recorrer el archivo
    temp_register = (fileBuffer + (getPtrOfFirstRegister() - sizeOfHeader)) ;//obtener ultimo registro

    for(int num_row = 0; num_row < (*numberOfRegisters-*numberOfFreeRegisters) ; num_row++){ //solo recorro (registros usados) veces
        if(num_row == num_fila){

            int desplazamiento =   INICIO_DE_REGISTRO_EN_BYTES;     //se cuentan los 4 bytes del puntero al anterior
            Nodo3d<const char* ,  int , int >* temp_sch; //nodo temp del schema
            temp_sch = schema.get_primerNodo();
            schema.get_ultimoNodo()->set_siguiente(NULL);

            for(int i =0 ; schema.getLength() && (temp_sch != NULL) ; i++){  //se recorre el schema
                if(compare_strings(columna,temp_sch->get_elemento1())){//para saber cual es la columna
                    if( temp_sch->get_elemento2() == STRING_ID){ //saber que tipo de dato guardar
                        cout<<temp_sch->get_elemento1()<<" : "<<(char*)(temp_register + desplazamiento)<<endl;
                    }
                    else if( temp_sch->get_elemento2() == INT_ID){ //saber que tipo de dato guardar
                        cout<<temp_sch->get_elemento1()<<" : "<<*(int*)(temp_register + desplazamiento)<<endl;
                    }
                    else if( temp_sch->get_elemento2() == FLOAT_ID){ //saber que tipo de dato guardar
                        cout<<temp_sch->get_elemento1()<<" : "<<*(float*)(temp_register + desplazamiento)<<endl;
                    }
                }
                if(temp_sch->get_elemento2() == STRING_ID){ desplazamiento += temp_sch->get_elemento3();}
                if(temp_sch->get_elemento2() == INT_ID){desplazamiento += BYTES_4;}// obtengo el lugar exacto donde se debe guardar los datos
                if(temp_sch->get_elemento2() == FLOAT_ID){desplazamiento += BYTES_4;}// obtengo el lugar exacto donde se debe guardar los datos
                temp_sch = temp_sch->get_siguiente();
            }
        }
        temp_register = (fileBuffer + (*(int*)(temp_register+OFFSET_PTRSIG) - sizeOfHeader)) ;//get siguiente registro
    }

}
Ejemplo n.º 5
0
int find_best_command(const char *f_command, debugger_command_t ** pointer) {
	if (gDebuggerList == 0) {
		return 0;
	}

	int command_length = strlen(f_command);

	int i;
	int max_match = 0;
	int match_numbers = 0;
	debugger_command_t *best_command = 0;

	for (i = 0; i < gDebuggerList->count; i++) {
		debugger_command_t *cmd = gDebuggerList->commands[i];
		int match = compare_strings(f_command, cmd->name);
		if (match > max_match && command_length == match) {
			max_match = match;
			match_numbers = 1;
			best_command = cmd;
		} else if (match > 0 && match == max_match) {
			match_numbers++;
		}
	}

	*pointer = best_command;
	if (max_match && match_numbers == 1) {
		return 1;
	}

	if (!max_match) {
		return 0;
	}

	return match_numbers > 1 ? -1 : 0;
}
Ejemplo n.º 6
0
gboolean check_if_every_vte_is_using_restore_font_name(struct Window *win_data)
{
#ifdef DETAIL
	g_debug("! Launch check_if_every_vte_is_using_restore_font_name() with win_data = %p", win_data);
#endif
#ifdef SAFEMODE
	if ((win_data==NULL) || (win_data->notebook==NULL)) return FALSE;
#endif
	if (win_data->restore_font_name == NULL)
	//	win_data->restore_font_name = g_strdup(page_data->font_name);
		win_data->restore_font_name = g_strdup(win_data->default_font_name);

	gint i;
	struct Page *page_data = NULL;
	gboolean return_value = TRUE;
	for (i=0; i<gtk_notebook_get_n_pages(GTK_NOTEBOOK(win_data->notebook)); i++)
	{
		page_data = get_page_data_from_nth_page(win_data, i);
#ifdef SAFEMODE
		if (page_data==NULL) continue;
#endif
		if (compare_strings(page_data->font_name, win_data->restore_font_name, TRUE))
		{
			return_value = FALSE;
			break;
		}
	}
	return return_value;
}
Ejemplo n.º 7
0
/* 66 0F 3A 62 */
void BX_CPP_AttrRegparmN(1) BX_CPU_C::PCMPISTRM_VdqWdqIb(bxInstruction_c *i)
{
#if (BX_SUPPORT_SSE >= 5) || (BX_SUPPORT_SSE >= 4 && BX_SUPPORT_SSE_EXTENSION > 0)
    BX_CPU_THIS_PTR prepareSSE();

    BxPackedXmmRegister op1 = BX_READ_XMM_REG(i->nnn()), op2, result;
    Bit8u imm8 = i->Ib();

    /* op2 is a register or memory reference */
    if (i->modC0()) {
        op2 = BX_READ_XMM_REG(i->rm());
    }
    else {
        BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
        /* pointer, segment address pair */
        readVirtualDQwordAligned(i->seg(), RMAddr(i), (Bit8u *) &op2);
    }

    // compare all pairs of Ai, Bj
    bx_bool BoolRes[16][16];
    compare_strings(BoolRes, op1, op2, imm8);

    unsigned num_elements = (imm8 & 0x1) ? 8 : 16;
    unsigned len1 = find_eos(op1, imm8);
    unsigned len2 = find_eos(op2, imm8);
    Bit16u result2 = aggregate(BoolRes, len1, len2, imm8);

    // As defined by imm8[6], result2 is then either stored to the least
    // significant bits of XMM0 (zero extended to 128 bits) or expanded
    // into a byte/word-mask and then stored to XMM0
    if (imm8 & 0x40) {
        if (num_elements == 8) {
            for (int index = 0; index < 8; index++)
                result.xmm16u(index) = (result2 & (1<<index)) ? 0xffff : 0;
        }
        else {  // num_elements = 16
            for (int index = 0; index < 16; index++)
                result.xmmubyte(index) = (result2 & (1<<index)) ? 0xff : 0;
        }
    }
    else {
        result.xmm64u(1) = 0;
        result.xmm64u(0) = (Bit64u) result2;
    }

    Bit32u flags = 0;
    if (result2 != 0) flags |= EFlagsCFMask;
    if (len1 < num_elements) flags |= EFlagsSFMask;
    if (len2 < num_elements) flags |= EFlagsZFMask;
    if (result2 & 0x1)
        flags |= EFlagsOFMask;
    setEFlagsOSZAPC(flags);

    BX_WRITE_XMM_REG(0, result); /* store result XMM0 */
#else
    BX_INFO(("PCMPISTRM_VdqWdqIb: required SSE4.2, use --enable-sse and --enable-sse-extension options"));
    UndefinedOpcode(i);
#endif
}
Ejemplo n.º 8
0
static int 
compare_IDEs_by_name_space(const void *ap,
                           const void *bp)
{
    const XPTInterfaceDirectoryEntry *ide1 = ap, *ide2 = bp;
    
    return compare_strings(ide1->name_space, ide2->name_space);
}
Ejemplo n.º 9
0
Archivo: lpc.c Proyecto: lanceit/cups
static void
show_help(const char *command)		/* I - Command to describe or NULL */
{
  if (!command)
  {
    _cupsLangPrintf(stdout,
                    _("Commands may be abbreviated.  Commands are:\n"
		      "\n"
		      "exit    help    quit    status  ?"));
  }
  else if (!compare_strings(command, "help", 1) || !strcmp(command, "?"))
    _cupsLangPrintf(stdout, _("help\t\tGet help on commands."));
  else if (!compare_strings(command, "status", 4))
    _cupsLangPrintf(stdout, _("status\t\tShow status of daemon and queue."));
  else
    _cupsLangPrintf(stdout, _("?Invalid help command unknown."));
}
Ejemplo n.º 10
0
gboolean
seahorse_gpgme_uid_is_same (SeahorseGpgmeUid *self, gpgme_user_id_t userid)
{
	g_return_val_if_fail (SEAHORSE_IS_GPGME_UID (self), FALSE);
	g_return_val_if_fail (userid, FALSE);
	
	return compare_strings (self->pv->userid->uid, userid->uid);	
}
Ejemplo n.º 11
0
/* 66 0F 3A 63 */
void BX_CPP_AttrRegparmN(1) BX_CPU_C::PCMPISTRI_VdqWdqIb(bxInstruction_c *i)
{
#if (BX_SUPPORT_SSE >= 5) || (BX_SUPPORT_SSE >= 4 && BX_SUPPORT_SSE_EXTENSION > 0)
    BX_CPU_THIS_PTR prepareSSE();

    BxPackedXmmRegister op1 = BX_READ_XMM_REG(i->nnn()), op2;
    Bit8u imm8 = i->Ib();

    /* op2 is a register or memory reference */
    if (i->modC0()) {
        op2 = BX_READ_XMM_REG(i->rm());
    }
    else {
        BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
        /* pointer, segment address pair */
        readVirtualDQwordAligned(i->seg(), RMAddr(i), (Bit8u *) &op2);
    }

    // compare all pairs of Ai, Bj
    bx_bool BoolRes[16][16];
    compare_strings(BoolRes, op1, op2, imm8);
    unsigned num_elements = (imm8 & 0x1) ? 8 : 16;
    int index;

    unsigned len1 = find_eos(op1, imm8);
    unsigned len2 = find_eos(op2, imm8);
    Bit16u result2 = aggregate(BoolRes, len1, len2, imm8);

    // The index of the first (or last, according to imm8[6]) set bit of result2
    // is returned to ECX. If no bits are set in IntRes2, ECX is set to 16 (8)
    if (imm8 & 0x40) {
        // The index returned to ECX is of the MSB in result2
        for (index=num_elements-1; index>=0; index--)
            if (result2 & (1<<index)) break;
        if (index < 0) index = num_elements;
    }
    else {
        // The index returned to ECX is of the LSB in result2
        for (index=0; index<(int)num_elements; index++)
            if (result2 & (1<<index)) break;
    }
    RCX = index;

    Bit32u flags = 0;
    if (result2 != 0) flags |= EFlagsCFMask;
    if (len1 < num_elements) flags |= EFlagsSFMask;
    if (len2 < num_elements) flags |= EFlagsZFMask;
    if (result2 & 0x1)
        flags |= EFlagsOFMask;
    setEFlagsOSZAPC(flags);

#else
    BX_INFO(("PCMPISTRI_VdqWdqIb: required SSE4.2, use --enable-sse and --enable-sse-extension options"));
    UndefinedOpcode(i);
#endif
}
Ejemplo n.º 12
0
bool FileManager :: cumpleCondicion(const char* columna,const char* operador , const char* campo,void* temp_register){
        int desplazamiento =  INICIO_DE_REGISTRO_EN_BYTES;     //se cuentan los 8 bytes del puntero al anteriory siguiente
        Nodo3d<const char* ,  int , int >* temp_sch; //nodo temp del schema
        temp_sch = schema.get_primerNodo();
        schema.get_ultimoNodo()->set_siguiente(NULL);
        for(int i =0 ; schema.getLength() && (temp_sch != NULL) ; i++){  //se recorre el schema
            if(compare_strings(columna,temp_sch->get_elemento1())){//se compara la columna en el schema y la columa que se quiere verificar

                if( temp_sch->get_elemento2() == STRING_ID){ //saber que tipo de dato comparar

                    char* temp_char = (char*)(temp_register + desplazamiento);
                    std::string result = std::string(temp_char);
                    const char* temp_const= result.c_str();
                    //se compara el campo que se quiere comparar contra el campo del achivo
                    if(compare_strings(temp_const,campo)){
                        //retorna true si cumple la condicion
                        return true;
                    }
                }
                else if( temp_sch->get_elemento2() == INT_ID){ //saber que tipo de dato comparar
                    //se compara el campo que se quiere comparar contra el campo del achivo
                    if(*(int*)(temp_register + desplazamiento) == atoi(campo)){
                        //retorna true si cumple la condicion
                        return true;
                    }
                }

                else if( temp_sch->get_elemento2() == FLOAT_ID){ //saber que tipo de dato comparar
                    //se compara el campo que se quiere comparar contra el campo del achivo
                    if(*(float*)(temp_register + desplazamiento) == atof(campo)){
                        //retorna true si cumple la condicion
                        return true;
                    }
                }
            }
            if(temp_sch->get_elemento2() == STRING_ID){ desplazamiento += temp_sch->get_elemento3();}// obtengo sumatoria de desplazamiento
            if(temp_sch->get_elemento2() == INT_ID){desplazamiento += BYTES_4;}// obtengo sumatoria de desplazamiento
            if(temp_sch->get_elemento2() == FLOAT_ID){desplazamiento += BYTES_4;}// obtengo sumatoria de desplazamiento
            temp_sch = temp_sch->get_siguiente(); //muevo el puntero de recorrido al siguiente
   }
        return false; //retorna false si no cumple la condicion

}
Ejemplo n.º 13
0
gboolean set_background_saturation(GtkRange *range, GtkScrollType scroll, gdouble value, GtkWidget *vte)
{
#ifdef DETAIL
	g_debug("! Launch set_background_saturation() with value = %f, vte = %p", value, vte);
#endif
#ifdef SAFEMODE
	if (vte==NULL) return FALSE;
#endif
	struct Page *page_data = (struct Page *)g_object_get_data(G_OBJECT(vte), "Page_Data");
#ifdef SAFEMODE
	if (page_data==NULL || (page_data->window==NULL)) return FALSE;
#endif
	struct Window *win_data = (struct Window *)g_object_get_data(G_OBJECT(page_data->window), "Win_Data");
#ifdef SAFEMODE
	if (win_data==NULL) return FALSE;
#endif
	// g_debug("Get win_data = %d when set background saturation!", win_data);

	value = CLAMP(value, 0, 1);

#ifdef ENABLE_RGBA
	if (win_data->use_rgba == -1)
	{
		if (win_data->transparent_background)
			vte_terminal_set_opacity(VTE_TERMINAL(vte), (1-value) * 65535);
		else
			vte_terminal_set_opacity(VTE_TERMINAL(vte), 65535);
	}
	else
#endif
		vte_terminal_set_background_transparent(VTE_TERMINAL(vte), win_data->transparent_background);

	// g_debug("set_background_saturation(): win_data->transparent_background = %d, value = %1.3f",
	//	win_data->transparent_background, value);
	// g_debug("set_background_saturation(): win_data->background_image = %s", win_data->background_image);
	if (win_data->transparent_background)
	{
		vte_terminal_set_background_image_file (VTE_TERMINAL(vte), NULL_DEVICE);
		vte_terminal_set_background_saturation( VTE_TERMINAL(vte), value);
	}
	else
	{
		if (compare_strings(win_data->background_image, NULL_DEVICE, TRUE))
		{
			vte_terminal_set_background_saturation( VTE_TERMINAL(vte), value);
			vte_terminal_set_background_image_file (VTE_TERMINAL(vte), win_data->background_image);
			vte_terminal_set_scroll_background(VTE_TERMINAL(vte), win_data->scroll_background);
		}
		else
			vte_terminal_set_background_saturation( VTE_TERMINAL(vte), 0);
	}

	dirty_vte_terminal_set_background_tint_color(VTE_TERMINAL(page_data->vte), win_data->color[0]);
	return FALSE;
}
static int group_find_linear (const char *project_name, const char *framework_name,
                              const char *component_name, bool invalidok)
{
    for (int i = 0 ; i < pmix_mca_base_var_group_count ; ++i) {
        pmix_mca_base_var_group_t *group;

        int rc = pmix_mca_base_var_group_get_internal (i, &group, invalidok);
        if (PMIX_SUCCESS != rc) {
            continue;
        }

        if (compare_strings (project_name, group->group_project) &&
            compare_strings (framework_name, group->group_framework) &&
            compare_strings (component_name, group->group_component)) {
            return i;
        }
    }

    return PMIX_ERR_NOT_FOUND;
}
Ejemplo n.º 15
0
static gboolean
compare_pubkeys (gpgme_key_t a, gpgme_key_t b)
{
	g_assert (a);
	g_assert (b);
	
	g_return_val_if_fail (a->subkeys, FALSE);
	g_return_val_if_fail (b->subkeys, FALSE);
	
	return compare_strings (a->subkeys->keyid, b->subkeys->keyid);
}
Ejemplo n.º 16
0
/* 66 0F 3A 60 */
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::PCMPESTRM_VdqWdqIbR(bxInstruction_c *i)
{
  BxPackedXmmRegister op1 = BX_READ_XMM_REG(i->nnn());
  BxPackedXmmRegister op2 = BX_READ_XMM_REG(i->rm()), result;
  Bit8u imm8 = i->Ib();

  // compare all pairs of Ai, Bj
  Bit8u BoolRes[16][16];
  compare_strings(BoolRes, op1, op2, imm8);
  unsigned len1, len2, num_elements = (imm8 & 0x1) ? 8 : 16;

#if BX_SUPPORT_X86_64
  if (i->os64L()) {
    len1 = find_eos64(RAX, imm8);
    len2 = find_eos64(RDX, imm8);
  }
  else
#endif
  {
    len1 = find_eos32(EAX, imm8);
    len2 = find_eos32(EDX, imm8);
  }
  Bit16u result2 = aggregate(BoolRes, len1, len2, imm8);

  // As defined by imm8[6], result2 is then either stored to the least
  // significant bits of XMM0 (zero extended to 128 bits) or expanded
  // into a byte/word-mask and then stored to XMM0
  if (imm8 & 0x40) {
     if (num_elements == 8) {
       for (int index = 0; index < 8; index++)
         result.xmm16u(index) = (result2 & (1<<index)) ? 0xffff : 0;
     }
     else {  // num_elements = 16
       for (int index = 0; index < 16; index++)
         result.xmmubyte(index) = (result2 & (1<<index)) ? 0xff : 0;
     }
  }
  else {
     result.xmm64u(1) = 0;
     result.xmm64u(0) = (Bit64u) result2;
  }

  Bit32u flags = 0;
  if (result2 != 0) flags |= EFlagsCFMask;
  if (len1 < num_elements) flags |= EFlagsSFMask;
  if (len2 < num_elements) flags |= EFlagsZFMask;
  if (result2 & 0x1)
    flags |= EFlagsOFMask;
  setEFlagsOSZAPC(flags);

  BX_WRITE_XMM_REGZ(0, result, i->getVL()); /* store result XMM0 */

  BX_NEXT_INSTR(i);
}
Ejemplo n.º 17
0
gint get_default_VTE_CJK_WIDTH()
{
#ifdef DETAIL
	g_debug("! Launch get_default_VTE_CJK_WIDTH()");
#endif
	const gchar *VTE_CJK_WIDTH = g_getenv("VTE_CJK_WIDTH");
	if (VTE_CJK_WIDTH==NULL)
		return 0;
	else
	{
		// VTE_CJK_WIDTH only work under UTF-8
		if ((compare_strings (VTE_CJK_WIDTH, "wide", FALSE)==FALSE) ||
		    (compare_strings (VTE_CJK_WIDTH, "1", FALSE)==FALSE))
			return 2;
		else if ((compare_strings (VTE_CJK_WIDTH, "narrow", FALSE)==FALSE) ||
			 (compare_strings (VTE_CJK_WIDTH, "0", FALSE)==FALSE))
			return 1;
		else
			return 0;
	}
}
Ejemplo n.º 18
0
static int 
compare_IDEs_by_name(const void *ap,
                     const void *bp)
{
    const XPTInterfaceDirectoryEntry *ide1 = ap, *ide2 = bp;

    int answer = compare_strings(ide1->name, ide2->name);
    if(!answer)
        answer = compare_pointers(ide1->name, ide2->name);

    return answer;
}
Ejemplo n.º 19
0
static int 
compare_fixElements_by_IID(const void *ap,
                           const void *bp)
{
    const fixElement *fix1 = ap, *fix2 = bp;
    
    int answer = compare_IIDs(&fix1->iid, &fix2->iid);
    if(!answer)
        answer = compare_strings(fix1->name, fix2->name);

    return answer;
}  
Ejemplo n.º 20
0
int find_best_command(debugger_t *debugger, const char *f_command, debugger_command_t ** pointer) {
	int i;
	int max_match = 0;
	int match_numbers = 0;
	int command_length = strlen(f_command);
	int highest_priority = INT_MIN;
	int highest_priority_max = 0;

	debugger_command_t *best_command = 0;

	for (i = 0; i < debugger->commands.count; i++) {
		debugger_command_t *cmd = debugger->commands.commands[i];
		int match = compare_strings(f_command, cmd->name);

		if (command_length > strlen(cmd->name)) {
			continue; // ignore
		} else if (strlen(f_command) != match && match < command_length) {
			continue;
		} else if (match < max_match) {
			continue;
		} else if (match > max_match) {
			max_match = match;
			match_numbers = 0;
			highest_priority = cmd->priority;
			highest_priority_max = 0;
			best_command = cmd;
		} else if (match == max_match) {
			match_numbers++;
			if (cmd->priority > highest_priority) {
				highest_priority = cmd->priority;
				highest_priority_max = 0;
				best_command = cmd;
			} else if (cmd->priority == highest_priority) {
				highest_priority_max++;
			}
		}
	}

	*pointer = best_command;
	if ((max_match && match_numbers == 0) || (max_match && highest_priority_max < 1)) {
		return 1;
	}

	if (max_match == 0) {
		return 0;
	}

	if (match_numbers > 1 || highest_priority_max > 0) {
		return -1;
	}

	return 0;
}
Ejemplo n.º 21
0
static int 
compare_fixElements_by_name(const void *ap,
                            const void *bp)
{
    const fixElement *fix1 = ap, *fix2 = bp;

    int answer= compare_strings(fix1->name, fix2->name);
    if(!answer)
        answer = compare_pointers(fix1->name, fix2->name);

    return answer;
}
Ejemplo n.º 22
0
/* 66 0F 3A 61 */
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::PCMPESTRI_VdqWdqIbR(bxInstruction_c *i)
{
  BxPackedXmmRegister op1 = BX_READ_XMM_REG(i->nnn()), op2 = BX_READ_XMM_REG(i->rm());
  Bit8u imm8 = i->Ib();

  // compare all pairs of Ai, Bj
  Bit8u BoolRes[16][16];
  compare_strings(BoolRes, op1, op2, imm8);
  unsigned len1, len2, num_elements = (imm8 & 0x1) ? 8 : 16;
  int index;

#if BX_SUPPORT_X86_64
  if (i->os64L()) {
    len1 = find_eos64(RAX, imm8);
    len2 = find_eos64(RDX, imm8);
  }
  else
#endif
  {
    len1 = find_eos32(EAX, imm8);
    len2 = find_eos32(EDX, imm8);
  }
  Bit16u result2 = aggregate(BoolRes, len1, len2, imm8);

  // The index of the first (or last, according to imm8[6]) set bit of result2
  // is returned to ECX. If no bits are set in IntRes2, ECX is set to 16 (8)
  if (imm8 & 0x40) {
     // The index returned to ECX is of the MSB in result2
     for (index=num_elements-1; index>=0; index--)
       if (result2 & (1<<index)) break;
     if (index < 0) index = num_elements;
  }
  else {
     // The index returned to ECX is of the LSB in result2
     for (index=0; index<(int)num_elements; index++)
       if (result2 & (1<<index)) break;
  }
  RCX = index;

  Bit32u flags = 0;
  if (result2 != 0) flags |= EFlagsCFMask;
  if (len1 < num_elements) flags |= EFlagsSFMask;
  if (len2 < num_elements) flags |= EFlagsZFMask;
  if (result2 & 0x1)
    flags |= EFlagsOFMask;
  setEFlagsOSZAPC(flags);

  BX_NEXT_INSTR(i);
}
Ejemplo n.º 23
0
int main(void){
    
    // declare pointers to strings
    char *a = "Hello";
    char *b = "World!";
    
    // declar empty pointer
    char *longer;
    
    // assign the result of compare_string to longer
    longer = compare_strings(a, b);
    
    // print the longer string
    printf("The longer string is : %s\n", longer);
    
    return 0;
}
int
main (int argc, char *argv[])
{
	DBusGConnection *bus;

	g_type_init ();
	bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);

	compare_ints ();
	compare_strings ();
	compare_strv ();
	compare_garrays ();
	compare_ptrarrays ();
	compare_str_hash ();
	compare_gvalue_hash ();
	compare_ip6_addresses ();

	return 0;
}
Ejemplo n.º 25
0
int main()
{
   int flag;
   char a[1000], b[1000];
 
   printf("Input first string\n");
   gets(a);
 
   printf("Input second string\n");
   gets(b);
 
   flag = compare_strings(a, b);
 
   if (flag == 0)
      printf("Entered strings are equal.\n");
   else
      printf("Entered strings are not equal.\n");
 
   return 0;
}
Ejemplo n.º 26
0
static foreign_t
pl_prefix_string(term_t ord, term_t pre, term_t t2)
{ OrdTable ot;
  char *s1, *s2;
  size_t l1, l2;
  unsigned int flags = (CVT_ATOM|CVT_STRING|CVT_LIST|BUF_RING|CVT_EXCEPTION);

  if ( !get_order_table(ord, &ot) )
    return error(ERR_INSTANTIATION, "prefix_string/3", 1, ord);
  if ( !PL_get_nchars(pre, &l1, &s1, flags) )
    return FALSE;
  if ( !PL_get_nchars(t2, &l2, &s2, flags) )
    return FALSE;

  if ( l1 <= l2 &&
       compare_strings(s1, s2, l1, ot) == 0 )
    return TRUE;

  return FALSE;
}
int
main (int argc _GL_UNUSED, char *argv[])
{
  set_program_name (argv[0]);

#if ENABLE_NLS
  /* Clean up environment.  */
  unsetenv ("LANGUAGE");
  unsetenv ("LC_ALL");
  unsetenv ("LC_MESSAGES");
  unsetenv ("LC_CTYPE");
  unsetenv ("LANG");
  unsetenv ("OUTPUT_CHARSET");

  /* This program part runs in a French UTF-8 locale.  It uses
     the test-quotearg.mo message catalog.  */
  {
    const char *locale_name = getenv ("LOCALE");

    if (locale_name != NULL && strcmp (locale_name, "none") != 0
        && setenv ("LC_ALL", locale_name, 1) == 0
        && setlocale (LC_ALL, "") != NULL)
      {
        textdomain ("test-quotearg");
        bindtextdomain ("test-quotearg", getenv ("LOCALEDIR"));

        set_quoting_style (NULL, locale_quoting_style);
        compare_strings (use_quotearg_buffer, &locale_results[0].group1, false);
        compare_strings (use_quotearg, &locale_results[0].group2, false);
        compare_strings (use_quotearg_colon, &locale_results[0].group3, false);

        set_quoting_style (NULL, clocale_quoting_style);
        compare_strings (use_quotearg_buffer, &locale_results[1].group1, false);
        compare_strings (use_quotearg, &locale_results[1].group2, false);
        compare_strings (use_quotearg_colon, &locale_results[1].group3, false);

        quotearg_free ();
        return 0;
      }
  }

  fputs ("Skipping test: no french Unicode locale is installed\n", stderr);
  return 77;
#else
  fputs ("Skipping test: internationalization is disabled\n", stderr);
  return 77;
#endif /* ENABLE_NLS */
}
Ejemplo n.º 28
0
Archivo: shell.c Proyecto: Myvar/EFOS
int findCommand(char* command)
{
     int i;
    int ret;
 
    for(i = 0; i <= NumberOfCommands - 1; i++)
    {
        char * buf = CommandTable[NumberOfCommands - 1].name;
        char * buf1 = command;        
        Console_Write_String(buf);
        Console_Write_String(buf1);
        buf  = 0;
        buf1 = 0;
        ret  = compare_strings(command, buf);
 
        if(ret == 0)
            return i;
        else
            return -1;
        }
}
Ejemplo n.º 29
0
static foreign_t
pl_compare_strings(term_t ord, term_t t1, term_t t2, term_t result)
{ OrdTable ot;
  char *s1, *s2;
  size_t len;
  int rval;
  unsigned int flags = (CVT_ATOM|CVT_STRING|CVT_LIST|BUF_RING|CVT_EXCEPTION);

  if ( !get_order_table(ord, &ot) )
    return error(ERR_INSTANTIATION, "compare_strings/4", 1, ord);
  if ( !PL_get_nchars(t1, &len, &s1, flags) )
    return FALSE;
  if ( !PL_get_nchars(t2, &len, &s2, flags) )
    return FALSE;

  rval = compare_strings(s1, s2, len, ot);

  return PL_unify_atom(result,
		       rval == 0 ? ATOM_eq :
		       rval <  0 ? ATOM_lt :
		       	           ATOM_gt);
}
Ejemplo n.º 30
0
char test_two_alloc(void)
{
	char *message1;
	char *message2;
	char actual[64];

	printf("test_two_alloc ...");

	dumb_reset();

	message1 = dumb_dup("Hello");
	message2 = dumb_dup("World");

	sprintf(actual, "%s, %s!", message1, message2);
	if (compare_strings(actual, "Hello, World!")) {
		return 1;
	}
	printf(" ok");
	dumb_free(message1);
	dumb_free(message2);
	printf(".\n");
	return 0;
}