コード例 #1
0
ファイル: sort.c プロジェクト: cosminadrianpopescu/vifm
/* Compares two file names or their parts (e.g. extensions).  Returns positive
 * value if s is greater than t, zero if they are equal, otherwise negative
 * value is returned. */
static int
compare_file_names(const char s[], const char t[], int ignore_case)
{
	const char *s_val = s, *t_val = t;
	char s_buf[NAME_MAX];
	char t_buf[NAME_MAX];
	int result;

	if(ignore_case)
	{
		/* Ignore too small buffer errors by not caring about part that didn't
		 * fit. */
		(void)str_to_lower(s, s_buf, sizeof(s_buf));
		(void)str_to_lower(t, t_buf, sizeof(t_buf));

		s_val = s_buf;
		t_val = t_buf;
	}

	result = cfg.sort_numbers ? strnumcmp(s_val, t_val) : strcmp(s_val, t_val);
	if(result == 0 && ignore_case)
	{
		/* Resort to comparing original names when their normalized versions match
		 * to always solve ties in deterministic way. */
		result = strcmp(s, t);
	}
	return result;
}
コード例 #2
0
bool Utils::strContains(const std::string &str, const std::string &needle, CaseSensitivity cs)
{
    if (needle.empty())
        return true;

    if (needle.length() > str.length())
        return false;

    if (cs == Utils::CaseSensitive)
        return str.find(needle) != std::string::npos;

    std::string s = str;
    return str_to_lower(s).find(str_to_lower(needle)) != std::string::npos;
}
コード例 #3
0
ファイル: main.c プロジェクト: lowgear/ITMO-CPP-HW
void phone_book_find_name(Phone_Book *pb, char *name) {
    if (!is_name(name)) {
        return;
    }
    str_to_lower(name, name);
    for (int i = 0; i < pb->used; i++) {
        char *cur_name = malloc(strlen(pb->v[i].name) * sizeof(char));
        str_to_lower(cur_name, pb->v[i].name);
        if (strstr(cur_name, name)) {
            record_print(&pb->v[i], stdout);
        }
        free(cur_name);
    }
}
コード例 #4
0
ファイル: client.c プロジェクト: Tumas/labs
/*
 * Return value
 *  0 - no mistakes, all information succesfully parsed
 *  1 - no mistakes, but parsing is not finished. Could not get all response
 *  -1 - mistake happened
 *  -2 - wrong server response code
 */
static int
spellcast_client_parse_server_response(spellcast_cache *rsp, spellcast_con_info *sp)
{
    int is_full_message = strstr(rsp->buffer, SPELLCAST_HEADER_END_TOKEN) == NULL ?  0 : 1;
    char *header_line = strtok(rsp->buffer, SPELLCAST_LINE_TOKEN);
    char *match, *prev_line;

    while (header_line != NULL) {
        str_to_lower(header_line);
        printf("Parsed line  %s\n", header_line);

        if ((match = strstr(header_line, SPELLCAST_BR_TOKEN)) != NULL) {
            sp->bitrate = atoi(match + strlen(SPELLCAST_BR_TOKEN));
        }
        else if ((match = strstr(header_line, SPELLCAST_METAINT_CLIENT_TOKEN)) != NULL) {
            sp->metaint = atoi(match + strlen(SPELLCAST_METAINT_CLIENT_TOKEN));
        }

        prev_line = header_line;
        header_line = strtok(NULL, SPELLCAST_LINE_TOKEN);
    }

    if (!is_full_message) {
        rsp->buf_start = strlen(prev_line);
        strcpy(rsp->buffer, prev_line);

        printf("Cached buffer %d %s\n", rsp->buf_start, rsp->buffer);
        return 1;
    }

    return 0;
}
コード例 #5
0
ファイル: read_file.c プロジェクト: opp11/ctp-c
struct fline_t *read_file(FILE *stream, size_t *len)
{
	struct fline_t *out = NULL;
	size_t out_len = 0;
	char *line = NULL;
	size_t line_len = 0;

	while (getline(&line, &line_len, stream) != -1){
		out_len++;
		out = realloc(out, sizeof(struct fline_t) * out_len);
		if (is_code_line(line)){
			str_to_lower(line);
			out[out_len - 1] = split_line(line);
		} else {
			out[out_len - 1].len = 0;
			out[out_len - 1].words = NULL;
		}
	}
	free(line);

	if (len){
		(*len) = out_len;
	}
	return out;
}
コード例 #6
0
ファイル: hash.c プロジェクト: frmendes/uminho
/* Finds the address where the pointer should be (whether or not it is there)
 * So that we can add it if we want
 * returns 0 if it exists, 1 otherwise
 */
static int __get_bucket_addr(hash h, char* key, bucket** ret) {
    char* lower_key = str_to_lower(key);
    unsigned int i = djb2_hash(lower_key) % (h -> size);
    free(lower_key);
    int found = 0;
    bucket* it = &(h -> table)[i];
    bucket* head = it;

    // try to find it in the current bucket
    while(*it && !found) {
        if( strcasecmp( (*it) -> key, key) == 0 )
            found = 1;
        else
            it = &( (*it) -> next );
    }

    // if we found a bucket, we need to return it
    if(*it)
        *ret = it;
    else
        *ret = head; // otherwise return where it should be (head of the bucket)

    // returning the flag
    return found;
}
コード例 #7
0
/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  parse_input
 *  Description: separates a line of input into tokens. Passes tokens off for additional
 *  processing. 
 * =====================================================================================
 */
	void
parse_input (char *input, size_t size)
{
	char s[(int)size];
	strcpy(s, input);

	char *op_code = strtok(s, " ");
  char *raw_arg_a = strtok(NULL, " ");
	char *raw_arg_b = strtok(NULL, " ");
	char *raw_arg_c = strtok(NULL, " ");

	int argc = 0;

	struct arg_t args[3];
	if(raw_arg_a != 0) {
		args[0] = parse_arg(raw_arg_a);
		argc++;
	}
	if(raw_arg_b != 0) {
		args[1] = parse_arg(raw_arg_b);
		argc++;
	}
	if(raw_arg_c != 0) {
		args[2] = parse_arg(raw_arg_b);
		argc++;
	}

	op_code = trim_whitespace(op_code);
	str_to_lower(op_code);
	unsigned long op_hashed = hash(op_code);
	assemble_op(op_hashed, args, argc);
}		/* -----  end of function parse_input  ----- */
コード例 #8
0
ファイル: device.c プロジェクト: yndi/keusb
char *
keusb_get_signature()
{
   if (!keusb_request("$KE,SER") || reply_size < 2)
      return airbag;

   return str_to_lower(reply_part[1]);
}
コード例 #9
0
ファイル: command_loop.c プロジェクト: GBuella/Taltos
static char*
get_str_arg_lower_opt(void)
{
    char *str;

    if ((str = get_str_arg_opt()) != NULL)
        (void) str_to_lower(str);
    return str;
}
コード例 #10
0
ファイル: indexer.c プロジェクト: adrianob/word_search
//create a w_token struct from a string with null list
W_TOKEN * create_word(wchar_t * token){
  wchar_t *current_word = NULL;
  W_TOKEN *w_token = NULL;
  current_word = malloc(wcslen(token) * sizeof(wchar_t) + 1);
  str_to_lower(token);
  wcscpy(current_word, token);
  w_token = malloc(sizeof(W_TOKEN));
  w_token->word = current_word;
  w_token->list = NULL;

  return w_token;
}
コード例 #11
0
ファイル: css_util.c プロジェクト: zhifeichen/libcapture
void test_css_util_stringx()
{
	char *str;
	assert(1 == str_contains("hello word","wor"));
	assert(0 == str_contains("hello word","worw"));
	assert(2 == str_index_of("hello word","ll"));
	assert(-1 == str_index_of("hello word","lldd"));

	COPY_STR(str,"2abc123");
	str_to_upper(str);
	assert(strcmp(str,"2ABC123") == 0);
	str_to_lower(str);
	assert(strcmp(str,"2abc123") == 0);
}
コード例 #12
0
ファイル: global_commands.c プロジェクト: jpoler/toxic
void cmd_status(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{   
    bool have_note = false;
    const char *errmsg;

    if (argc >= 2) {
        have_note = true;
    } else if (argc < 1) {
        errmsg = "Require a status. Statuses are: online, busy and away.";
        line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
        return;
    }

    char status[MAX_STR_SIZE];
    snprintf(status, sizeof(status), "%s", argv[1]);
    str_to_lower(status);

    TOX_USERSTATUS status_kind;

    if (!strcmp(status, "online"))
        status_kind = TOX_USERSTATUS_NONE;
    else if (!strcmp(status, "away"))
        status_kind = TOX_USERSTATUS_AWAY;
    else if (!strcmp(status, "busy"))
        status_kind = TOX_USERSTATUS_BUSY;
    else {
        errmsg = "Invalid status. Valid statuses are: online, busy and away.";
        line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
        return;
    }

    tox_set_user_status(m, status_kind);
    prompt_update_status(prompt, status_kind);

    if (have_note) {
        if (argv[2][0] != '\"') {
            line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Note must be enclosed in quotes.");
            return;
        }

        /* remove opening and closing quotes */
        char msg[MAX_STR_SIZE];
        snprintf(msg, sizeof(msg), "%s", &argv[2][1]);
        int len = strlen(msg) - 1;
        msg[len] = '\0';

        prompt_update_statusmessage(prompt, m, msg);
    }
}
コード例 #13
0
ファイル: global_commands.c プロジェクト: gracchus163/toxic
void cmd_status(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
    char *msg = NULL;
    char *errmsg;

    if (argc >= 2) {
        msg = argv[2];

        if (msg[0] != '\"') {
            errmsg = "Note must be enclosed in quotes.";
            line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
            return;
        }
    } else if (argc != 1) {
        errmsg = "Wrong number of arguments.";
        line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
        return;
    }

    char *status = argv[1];
    str_to_lower(status);

    TOX_USERSTATUS status_kind;

    if (!strcmp(status, "online"))
        status_kind = TOX_USERSTATUS_NONE;
    else if (!strcmp(status, "away"))
        status_kind = TOX_USERSTATUS_AWAY;
    else if (!strcmp(status, "busy"))
        status_kind = TOX_USERSTATUS_BUSY;
    else {
        errmsg = "Invalid status. Valid statuses are: online, busy and away.";
        line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
        return;
    }

    tox_set_user_status(m, status_kind);
    prompt_update_status(prompt, status_kind);

    if (msg != NULL) {
        ++msg;
        int len = strlen(msg) - 1;
        msg[len] = '\0';    /* remove opening and closing quotes */
        tox_set_status_message(m, (uint8_t *) msg, (uint16_t) len);
        prompt_update_statusmessage(prompt, msg);
    }
}
コード例 #14
0
ファイル: lookup.c プロジェクト: adrianob/word_search
//search for all words given in file_name and save results to output_file_name
void search_words(TREE_NODE *root, char * file_name, char * output_file_name){
  FILE *file, *output_file;
  file = fopen(file_name,"r");
  output_file = fopen(output_file_name,"w");
  if(!file){
    printf("arquivo de entrada invalido\n");
    return;
  }
  if(!output_file){
    printf("arquivo de saida invalido\n");
    return;
  }

  wchar_t line [ 10000 ];

  wchar_t *result = malloc(sizeof(wchar_t) * 10000);

  //start benchmark
  double start_time, end_time, time_elapsed;
  start_time = (double)clock();

  while ( fgetws ( line, sizeof line, file ) != NULL ){//read line by line
    if(line[wcslen(line) -1] == '\n') line[wcslen(line) -1] = '\0';//remove new line char
    if(line[wcslen(line) -1] == ' ') line[wcslen(line) -1] = '\0';
    W_TOKEN *token = malloc(sizeof(W_TOKEN));
    str_to_lower(line);
    token->word = line;
    search_word(root, token, result);
    fwprintf(output_file, L"%ls",result);
    fputws ( result, stdout );
  }

  end_time = (double)clock();
  time_elapsed = ( end_time - start_time )/CLOCKS_PER_SEC;
  //end benchmark

  fwprintf(output_file, L"%s","\n");
  fwprintf(output_file, L"O tempo gasto na busca foi de %fms.\n", time_elapsed*1000);
  printf("\n");
  printf("O tempo gasto na busca foi de %fms.\n", time_elapsed*1000);

  fclose(file);
  fclose(output_file);

}
コード例 #15
0
ファイル: dns.c プロジェクト: jpoler/toxic
/* Takes address addr in the form "username@domain", puts the username in namebuf, 
   and the domain in dombuf.

   return length of username on success, -1 on failure */
static int parse_addr(const char *addr, char *namebuf, char *dombuf)
{
    char tmpaddr[MAX_STR_SIZE];
    char *tmpname, *tmpdom;

    strcpy(tmpaddr, addr);
    tmpname = strtok(tmpaddr, "@");
    tmpdom = strtok(NULL, "");

    if (tmpname == NULL || tmpdom == NULL)
        return -1;

    str_to_lower(tmpdom);
    strcpy(namebuf, tmpname);
    strcpy(dombuf, tmpdom);

    return strlen(namebuf);
}
コード例 #16
0
/* Computes fingerprint of the file specified by path and entry.  Type of the
 * fingerprint is determined by ct parameter.  Returns newly allocated string
 * with the fingerprint, which is empty or NULL on error. */
static char *
get_file_fingerprint(const char path[], const dir_entry_t *entry,
		CompareType ct)
{
	switch(ct)
	{
		char name[NAME_MAX + 1];

		case CT_NAME:
			if(case_sensitive_paths(path))
			{
				return strdup(entry->name);
			}
			str_to_lower(entry->name, name, sizeof(name));
			return strdup(name);
		case CT_SIZE:
			return format_str("%" PRINTF_ULL, (unsigned long long)entry->size);
		case CT_CONTENTS:
			return get_contents_fingerprint(path, entry);
	}
	assert(0 && "Unexpected diffing type.");
	return strdup("");
}
コード例 #17
0
ファイル: device.c プロジェクト: yndi/keusb
int
keusb_connect(int type, char *path)
{
   char *name;
   device_name = path ? path : airbag;

   if (type == CONNECT_FILE)
      return (device_open(path)
              && keusb_request("$KE"))
         || die("keusb_connect: can't open device");

   while ((name = device_gen_name()))
   {
      if (!device_open(name))
         continue;

      if (!keusb_request("$KE"))
      {
         device_close();
         continue;
      }

      if (type == CONNECT_SIG
          && strcmp(keusb_get_signature(), str_to_lower(path)))
      {
         device_close();
         continue;
      }

      device_name = name;
      atexit(device_close);
      return 1;
   }

   return die("keusb_connect: can't find device");
}
コード例 #18
0
ファイル: parser.c プロジェクト: Andrew-Bezzubtsev/assembler
struct operation *parse_code(const char *code)
{
	struct operation *op = (struct operation*)calloc(1, sizeof(*op));
	char *tokens[5] = {op->cond, op->cmd, op->arg0, op->arg1, op->arg2};
	unsigned int i = 0;

	for (i = 0; i < 5; i++) {
        	if (sscanf(code, "%[0-9a-zA-Z@#$]", tokens[i]) <= 0) {
			fprintf(stderr, "Error!\nUnknown symbol!\n"); // Tell about excepted error

			free((void *)op);
			return 0;
        	}

		str_to_lower(tokens[i]);

		code = skip(code, tokens[i]);

		if (!code)
            		break;
	}

	return op;
}
コード例 #19
0
ファイル: command_loop.c プロジェクト: GBuella/Taltos
static char*
get_str_arg_lower(void)
{
    return str_to_lower(get_str_arg());
}
コード例 #20
0
void SearchEng::add_parse_page(std::string filename, PageParser* parser){
	MySet<std::string> temp_all_words;
	MySet<std::string> temp_all_links;

	parser->parse(filename, temp_all_words, temp_all_links);
	

	if(!map_all_webpages.count(filename) ){//this filename isn't in the map
		//create a new webpage and store a pointer to it in our map
		WebPage* wp = new WebPage(filename);
		map_all_webpages.insert ( std::pair<std::string, WebPage*>(filename, wp) );

		map_all_webpages[filename]->all_words(temp_all_words);//same as wp->all_words(temp_all_words)

		std::set<std::string>::iterator it;
		for(it = temp_all_links.begin(); it != temp_all_links.end(); ++it){
			std::ifstream checkExistence( (*it).c_str() );
			if(!checkExistence.fail() ){
				if(!map_all_webpages.count(*it) ){//add the link to our map if its not in there
					WebPage* wp2 = new WebPage(*it);
					map_all_webpages.insert ( std::pair<std::string, WebPage*>(*it, wp2) );
				}
				wp->add_outgoing_link(map_all_webpages[*it]);
				map_all_webpages[*it]->add_incoming_link(wp);
			}
			if(checkExistence.is_open() ){
				checkExistence.close();
			}
		}


		//fill second map
		std::set<std::string>::iterator it2;
		for(it2 = temp_all_words.begin(); it2 != temp_all_words.end(); ++it2){
			std::string tmp = *it2;
			str_to_lower(tmp);
			if(!word_to_setofwps.count(tmp) ){// curr word not inside map
				
				MySet<WebPage*> set_wp;
				set_wp.insert(wp);
				word_to_setofwps.insert( std::make_pair(tmp, set_wp) );
			}
			else{// curr word is inside map
				word_to_setofwps[tmp].insert(wp);
			}
		}

	}else{//webpage is in the map but hasnt had its member set filled in
		WebPage* wp = map_all_webpages[filename];

		wp->all_words(temp_all_words);

		//populate filename's 
		std::set<std::string>::iterator it;
		for(it = temp_all_links.begin(); it != temp_all_links.end(); ++it){
			std::ifstream checkExistence( (*it).c_str() );
			if(!checkExistence.fail() ){
				if(!map_all_webpages.count(*it) ){//add the link to our map if its not in there
					WebPage* wp2 = new WebPage(*it);
					map_all_webpages.insert ( std::pair<std::string, WebPage*>(*it, wp2) );
				}
				wp->add_outgoing_link(map_all_webpages[*it]);
				map_all_webpages[*it]->add_incoming_link(wp);
			}
			if(checkExistence.is_open() ){
				checkExistence.close();
			}
		}


		//fill second map
		std::set<std::string>::iterator it2;
		for(it2 = temp_all_words.begin(); it2 != temp_all_words.end(); ++it2){
			std::string tmp = *it2;
			str_to_lower(tmp);
			if(!word_to_setofwps.count(tmp) ){// curr word not inside map
				
				MySet<WebPage*> set_wp;
				set_wp.insert(wp);
				word_to_setofwps.insert( std::make_pair(tmp, set_wp) );
			}
			else{// curr word is inside map
				word_to_setofwps[tmp].insert(wp);
			}
		}
	}

	
}
コード例 #21
0
ファイル: pp_lst.c プロジェクト: Trussroads/RZE-ngspice
static Status_t check_uniqueness(
    int            num_models,  /* Number of model pathnames */
    Model_Info_t   *model_info, /* Info about each model */
    int            num_nodes,   /* Number of node type pathnames */
    Node_Info_t    *node_info   /* Info about each node type */
)
{
    int         i;                       /* A temporary counter */
    int         j;                       /* A temporary counter */
    Boolean_t   all_unique;              /* true if names are unique */

    /* Define a list of model names used internally by XSPICE */
    /* These names (except 'poly') are defined in src/sim/INP/INPdomodel.c and */
    /* are case insensitive */
    static char *SPICEmodel[] = { "npn",
                                  "pnp",
                                  "d",
                                  "njf",
                                  "pjf",
                                  "nmf",
                                  "pmf",
                                  "urc",
                                  "nmos",
                                  "pmos",
                                  "r",
                                  "c",
                                  "sw",
                                  "csw",
                                  "poly" };
    static int  numSPICEmodels = sizeof(SPICEmodel) / sizeof(char *);


    /* Define a list of node type names used internally by the simulator */
    /* These names are defined in src/sim/include/MIFtypes.h and are case */
    /* insensitive */
    static char *UDNidentifier[] = { "v",
                                     "vd",
                                     "i",
                                     "id",
                                     "vnam",
                                     "g",
                                     "gd",
                                     "h",
                                     "hd",
                                     "d" };
    static int  numUDNidentifiers = sizeof(UDNidentifier) / sizeof(char *);



    /* First, normalize case of all model and node names to lower since */
    /* SPICE is case insensitive in parsing decks */
    for(i = 0; i < num_models; i++)
        str_to_lower(model_info[i].spice_name);
    for(i = 0; i < num_nodes; i++)
        str_to_lower(node_info[i].node_name);

    /* Then, loop through all model names and report errors if same as SPICE */
    /* model name or same as another model name in list */
    for(i = 0, all_unique = TRUE; i < num_models; i++) {

        /* First check against list of SPICE internal names */
        for(j = 0; j < numSPICEmodels; j++) {
            if(strcmp(model_info[i].spice_name, SPICEmodel[j]) == 0) {
                all_unique = FALSE;
                print_error("ERROR - Model name '%s' is same as internal SPICE model name\n",
                            model_info[i].spice_name);
            }
        }

        /* Skip if already seen once */
        if(model_info[i].spice_unique == FALSE)
            continue;

        /* Then check against other names in list */
        for(j = 0; j < num_models; j++) {

            /* Skip checking against itself */
            if(i == j)
                continue;

            /* Compare the names */
            if(strcmp(model_info[i].spice_name, model_info[j].spice_name) == 0) {
                all_unique = FALSE;
                model_info[i].spice_unique = FALSE;
                model_info[j].spice_unique = FALSE;
                print_error("ERROR - Model name '%s' in directory: %s",
                            model_info[i].spice_name,
                            model_info[i].path_name);
                print_error("        is same as");
                print_error("        model name '%s' in directory: %s\n",
                            model_info[j].spice_name,
                            model_info[j].path_name);
            }
        }

    }

    /* Loop through all C function names and report errors if duplicates found */
    for(i = 0; i < num_models; i++) {

        /* Skip if already seen once */
        if(model_info[i].cfunc_unique == FALSE)
            continue;

        /* Check against other names in list only, not against SPICE identifiers */
        /* Let linker catch collisions with SPICE identifiers for now */
        for(j = 0; j < num_models; j++) {

            /* Skip checking against itself */
            if(i == j)
                continue;

            /* Compare the names */
            if(strcmp(model_info[i].cfunc_name, model_info[j].cfunc_name) == 0) {
                all_unique = FALSE;
                model_info[i].cfunc_unique = FALSE;
                model_info[j].cfunc_unique = FALSE;
                print_error("ERROR - C function name '%s' in directory: %s",
                            model_info[i].cfunc_name,
                            model_info[i].path_name);
                print_error("        is same as");
                print_error("        C function name '%s' in directory: %s\n",
                            model_info[j].cfunc_name,
                            model_info[j].path_name);
            }
        }

    }

    /* Loop through all node type names and report errors if same as internal */
    /* name or same as another name in list */
    for(i = 0; i < num_nodes; i++) {

        /* First check against list of internal names */
        for(j = 0; j < numUDNidentifiers; j++) {
            if(strcmp(node_info[i].node_name, UDNidentifier[j]) == 0) {
                all_unique = FALSE;
                print_error("ERROR - Node type '%s' is same as internal node type\n",
                            node_info[i].node_name);
            }
        }

        /* Skip if already seen once */
        if(node_info[i].unique == FALSE)
            continue;

        /* Then check against other names in list */
        for(j = 0; j < num_nodes; j++) {

            /* Skip checking against itself */
            if(i == j)
                continue;

            /* Compare the names */
            if(strcmp(node_info[i].node_name, node_info[j].node_name) == 0) {
                all_unique = FALSE;
                node_info[i].unique = FALSE;
                node_info[j].unique = FALSE;
                print_error("ERROR - Node type '%s' in directory: %s",
                            node_info[i].node_name,
                            node_info[i].path_name);
                print_error("        is same as");
                print_error("        node type '%s' in directory: %s\n",
                            node_info[j].node_name,
                            node_info[j].path_name);
            }
        }
    }


    /* Return error status */
    if(all_unique)
        return(OK);
    else
        return(ERROR);

}
コード例 #22
0
ファイル: account.c プロジェクト: Danteoriginal/bnetd
extern t_account * account_create(char const * username, char const * passhash1)
{
    t_account * account;

    if (username && account_check_name(username)<0)
    {
        eventlog(eventlog_level_error,"account_create","got bad account name");
        return NULL;
    }

    if (!(account = malloc(sizeof(t_account))))
    {
		eventlog(eventlog_level_error,"account_create","could not allocate memory for account");
		return NULL;
    }

    account->filename = NULL;
    account->attrs    = NULL;
    account->age      = 0;
    CLEAR_FLAGS(account);

    account->namehash = 0; /* hash it later before inserting */
#ifndef ACCT_DYN_LOAD
    account->uid      = 0;
#endif /* !ACCT_DYN_LOAD */
#ifdef ACCT_DYN_UNLOAD
    account->ref      = 0;
#endif /* ACCT_DYN_UNLOAD */


    if (username) /* actually making a new account */
    {
        char * temp;

		if (account_check_name(username)<0)
		{
	    	eventlog(eventlog_level_error,"account_create","invalid account name \"%s\"",username);
		    account_destroy(account);
		    return NULL;
		}
		if (!passhash1)
		{
            eventlog(eventlog_level_error,"account_create","got NULL passhash1");
            account_destroy(account);
            return NULL;
		}

#ifdef WITH_STORAGE_DB
	    /* In DB (MySQL) storage i always use the real login name as id */
	    if (!(temp = malloc(strlen(username)+1))) /* name + NUL */
	    {
	        eventlog(eventlog_level_error,"account_create","could not allocate memory for temp");
	        account_destroy(account);
	        return NULL;
	    }
	    sprintf(temp,"%s",username);
#else
# ifndef ACCT_DYN_LOAD
		if (prefs_get_savebyname()==0)
		{
	        if (!(temp = malloc(strlen(prefs_get_userdir())+1+8+1))) /* dir + / + uid + NUL */
	        {
				eventlog(eventlog_level_error,"account_create","could not allocate memory for temp");
				account_destroy(account);
				return NULL;
		    }
		    sprintf(temp,"%s/%06u",prefs_get_userdir(),maxuserid+1); /* FIXME: hmm, maybe up the %06 to %08... */
		}
		else
# endif /* ! ACCT_DYN_LOAD */
		{
		    char const * safename;
		    char *	 filename;

		    if (!(filename = strdup(username)))
		    {
				eventlog(eventlog_level_error,"account_create","could not allocate memory for filename");
				account_destroy(account);
				return NULL;
		    }
		    str_to_lower(filename);
		    if (!(safename = escape_fs_chars(filename,strlen(filename))))
		    {
				eventlog(eventlog_level_error,"account_create","could not escape username");
				account_destroy(account);
				free(filename);
				return NULL;
		    }
		    free(filename);
		    if (!(temp = malloc(strlen(prefs_get_userdir())+1+strlen(safename)+1))) /* dir + / + name + NUL */
		    {
				eventlog(eventlog_level_error,"account_create","could not allocate memory for temp");
				account_destroy(account);
				return NULL;
		    }
		    sprintf(temp,"%s/%s",prefs_get_userdir(),safename);
		    free((void *)safename); /* avoid warning */
		}
#endif /* WITH_DB_STORAGE */
		account->filename = temp;

	    SET_FLAG(account,account_flag_loaded);

		if (account_set_strattr(account,"BNET\\acct\\username",username)<0)
		{
	    	eventlog(eventlog_level_error,"account_create","could not set username");
		    account_destroy(account);
		    return NULL;
		}
#ifndef ACCT_DYN_LOAD
		if (account_set_numattr(account,"BNET\\acct\\userid",maxuserid+1)<0)
		{
		    eventlog(eventlog_level_error,"account_create","could not set userid");
		    account_destroy(account);
		    return NULL;
		}
#endif /* !ACCT_DYN_LOAD */
		if (account_set_strattr(account,"BNET\\acct\\passhash1",passhash1)<0)
		{
		    eventlog(eventlog_level_error,"account_create","could not set passhash1");
		    account_destroy(account);
		    return NULL;
		}

#ifdef WITH_BITS
		account_set_bits_state(account,account_state_valid);
		if (!bits_master) {
		    eventlog(eventlog_level_warn,"account_create","account_create should not be called on BITS clients");
		}
#endif /* WITH_BITS */
    }
#ifdef WITH_BITS
    else /* empty account to be filled in later */
		account_set_bits_state(account,account_state_valid);
#endif /* WITH_BITS */

    return account;
}
コード例 #23
0
ファイル: Parameters.cpp プロジェクト: segrax/openfodder
bool sFodderParameters::ProcessINI() {

	INI<> ini("openfodder.ini", false);

	if (!ini.parse())
		return false;

	// Section: Openfodder
	{
		if (ini.select("openfodder")) {
			if (ini.get("window", "false") == "true")
				mWindowMode = true;
			else
				mWindowMode = false;

			if (ini.get("cheats", "false") == "true")
				mCheatsEnabled = true;
			else
				mCheatsEnabled = false;

			if (ini.get("scale", "false") == "auto")
				mWindowScale = 0;
			else {
				mWindowScale = ini.get("scale", 0);
			}

			if (ini.get("columns", "0") == "0")
				mWindowColumns = 0;
			else {
				mWindowColumns = ini.get("columns", 22);
			}

			if (ini.get("rows", "0") == "0")
				mWindowRows = 0;
			else {
				mWindowRows = ini.get("rows", 16);
			}

			if (ini.get("alternate-mouse", "false") == "true")
				mMouseAlternative = true;
		}
	}

	// Section: Engine
	{
		if (ini.select("engine")) {
			auto platform = str_to_lower(ini.get("platform", ""));
			if (platform == "amiga")
				mDefaultPlatform = ePlatform::Amiga;
			if (platform == "pc")
				mDefaultPlatform = ePlatform::PC;

			auto game = str_to_lower(ini.get("engine", ""));
			if (game == "cf1")
				mDefaultGame = eGame::CF1;
			if (game == "cf2")
				mDefaultGame = eGame::CF2;


			auto maxsprite = ini.get("maxsprite", 0);
			if (maxsprite)
				mSpritesMax = maxsprite;
			auto maxspawn = ini.get("maxspawn", 0);
			if (maxspawn)
				mSpawnEnemyMax = maxspawn;
		}
	}

	// Section: Skip
	{
		if (ini.select("skip")) {
			if (ini.get("intro", "false") == "true")
				mSkipIntro = true;

			if (ini.get("briefing", "false") == "true")
				mSkipBriefing = true;

			if (ini.get("service", "false") == "true")
				mSkipService = true;

			if (ini.get("hill", "false") == "true")
				mSkipRecruit = true;
		}
	}

	if (ini.select("paths")) {

		for (auto& path : ini["paths"]) {

			g_ResourceMan->addDir(path.second);
		}
	}

	return true;
}
コード例 #24
0
ファイル: 1300.cpp プロジェクト: waiwai444/oj
void read_programs()
{
	int i, j, cnt;
	char command[100], *ptr, *dest, *operand1, op, *operand2;
	var_num = 0;
	for(i = 0; i < 2; i++)
	{
		cnt = 0;
		while(fgets(command, 100, stdin))
		{
			if(*(ptr = l_trim(command)) == '\0')
				continue;
			dest = ptr;
			while(isalnum(*ptr)) ++ptr;
			*ptr++ = '\0';
			str_to_lower(dest);
			if(strcmp(dest, "end") == 0)
				break;
			while(!isalnum(*ptr)) ++ptr;
			operand1 = ptr++;
			while(isalnum(*ptr)) ++ptr;
			op = '\0';
			if(*ptr == '+') op = '+';
			else if(*ptr == '-') op = '-';
			*ptr++ = '\0';
			while(!isalnum(*ptr))
			{
				if(!op)
				{
					if(*ptr == '+') op = '+';
					else if(*ptr == '-') op = '-';
				}
				++ptr;
			}
			operand2 = ptr++;
			while(isalnum(*ptr)) ++ptr;
			*ptr = '\0';
			str_to_lower(operand1);
			str_to_lower(operand2);

			++cnt;
			inst_set[i][cnt].inst = MOV_R1;
			if(isdigit(operand1[0]))
			{
				inst_set[i][cnt].var = IMMEDIATE;
				inst_set[i][cnt].num = atoi(operand1);
			}
			else
			{
				str_to_lower(operand1);
				inst_set[i][cnt].var = handle_variable(operand1);
			}
			++cnt;
			inst_set[i][cnt].inst = MOV_R2;
			if(isdigit(operand2[0]))
			{
				inst_set[i][cnt].var = IMMEDIATE;
				inst_set[i][cnt].num = atoi(operand2);
			}
			else
			{
				str_to_lower(operand2);
				inst_set[i][cnt].var = handle_variable(operand2);
			}
			++cnt;
			inst_set[i][cnt].inst = (op == '+' ? ADD : SUB);
			++cnt;
			inst_set[i][cnt].inst = MOV_VAR;
			inst_set[i][cnt].var = handle_variable(dest);
		}
		inst_num[i] = cnt;
	}
	std::sort(var_set, var_set+var_num, cmp_var);
	/*for(i = 1; i <= inst_num[0]; i += 4)
	{
		printf("%d R1, %d\n", inst_set[0][i].inst, inst_set[0][i].var);
		printf("%d R2, %d\n", inst_set[0][i+1].inst, inst_set[0][i+1].var);
		printf("%d R1, R2\n", inst_set[0][i+2].inst);
		printf("%d %d, R1\n", inst_set[0][i+3].inst, inst_set[0][i+3].var);
	}
	for(i = 1; i <= inst_num[1]; i += 4)
	{
		printf("%d R1, %d\n", inst_set[1][i].inst, inst_set[1][i].var);
		printf("%d R2, %d\n", inst_set[1][i+1].inst, inst_set[1][i+1].var);
		printf("%d R1, R2\n", inst_set[1][i+2].inst);
		printf("%d %d, R1\n", inst_set[1][i+3].inst, inst_set[1][i+3].var);
	}*/
}
コード例 #25
0
ファイル: echoc.c プロジェクト: patrickbrandao/compiler
// principal
int main_echoc(const char *progname, const int argc, const char **argv){
	// variaveis
	register int outlen = 0;

	// texto e opcoes
	char *_output_string = NULL;

	//varivel para cor da fonte
	int  txtcolor = 0;

	// variavel para cor de fundo
	int bgcolor = 0;

	// flags especiais de cores de letra
	// -b = negrito
	// -s = sublinhado
	// -p = piscante
	int _text_effect = 0;
	int _light = 0;


	// quebrar linha apos exibir texto
	int _do_break = 1;

	// resetar cores do terminal apos terminar
	int _do_reset = 1;

	// espacamento
	int _left_space = 0;
	int _right_space = 0;

	// conversao de strings
	int _convert_case = 0; 	// 0 = nao alterar case, 1=upper, 2=lower

	// conversao para formato numerico
	int _to_number_format = 0;		// 0=nao interpretar numero, 2=converter para formato numerico, exemplo: 123456 para 123.456


	// processar argumentos do usuario
	#define TEST_COLOR(TEXT, VALUE)			if(strcmp(TEXT, argv[argn])==0){ argn++; if(cl) bgcolor = VALUE; else txtcolor = VALUE; continue; }

	int argn = 1;
	int cl = 0;
	while( argn < argc){

		// recebe argumentos
		cl = 0;

		// opcoes multi-parametros
		if( argn +1 < argc && (0==strcmp(argv[argn],"-c") || 0==strcmp(argv[argn],"-b")) ){
			if(0==strcmp(argv[argn],"-b")) cl=1;

			if(argn < argc) argn++; else continue;

			TEST_COLOR("blue", 5);
			TEST_COLOR("azul", 5);

			TEST_COLOR("red", 2);
			TEST_COLOR("vermelho", 2);

			TEST_COLOR("green", 3);
			TEST_COLOR("verde", 3);

			TEST_COLOR("magenta", 7);
			TEST_COLOR("celeste", 7);
			TEST_COLOR("cyan", 7);
			TEST_COLOR("cian", 7);

			TEST_COLOR("pink", 6);
			TEST_COLOR("rosa", 6);

			TEST_COLOR("yellow", 4);
			TEST_COLOR("amarelo", 4);

			TEST_COLOR("white", 8);
			TEST_COLOR("light", 9);
			TEST_COLOR("black", 1);

			TEST_COLOR("gray", 10);
			TEST_COLOR("cinza", 10);

			argn++;
		}

		// evitar sair do espaco de memoria
		if(argn >= argc) break;

		// definicao de espacamento
		// ESQUERDA
		if(strcmp(argv[argn],"-L") ==0 ){
			if(argn < argc) argn++; else continue;	
			// tamanho do espaco para alinhar a esquerda
			_left_space = atoi(argv[argn++]);
			if(_left_space < 0) _left_space = 0;
			continue;
		}
		// DIREITA
		if(strcmp(argv[argn],"-R") ==0 ){
			if(argn < argc) argn++; else continue;	
			// tamanho do espaco para alinhar a esquerda
			_right_space = atoi(argv[argn++]);
			if(_right_space < 0) _right_space = 0;
			continue;
		}

		// opcoes singulares
		if(0==strcmp(argv[argn],"-h") || 0==strcmp(argv[argn],"--help")){ help_echoc(); }
		if(0==strcmp(argv[argn],"-B")){ _text_effect = 1; ++argn; continue; }
		if(0==strcmp(argv[argn],"-s")){ _text_effect = 2; ++argn; continue; }
		if(0==strcmp(argv[argn],"-p")){ _text_effect = 3; ++argn; continue; }
		if(0==strcmp(argv[argn],"-l")){ _light = 1; ++argn; continue; }

		if(0==strcmp(argv[argn],"-n")){ _do_break = 2; ++argn; continue; }
		if(0==strcmp(argv[argn],"-k")){ _do_reset = 0; ++argn; continue; }

		// number
		if(0==strcmp(argv[argn],"-N")){ _to_number_format = 1; ++argn; continue; }

		// upper
		if(0==strcmp(argv[argn],"-Y")){ _convert_case = 1; ++argn; continue; }

		// lower
		if(0==strcmp(argv[argn],"-W")){ _convert_case = 2; ++argn; continue; }

		// texto
		if(strlen(argv[argn])) _output_string = strdup(argv[argn]);

		++argn;
	}
	if ( argn != argc ) help_echoc();



	//------------- argumentos prontos



	// evitar apontar para espaco nulo
	if(_output_string==NULL) _output_string = strdup("");

	// Definir coloracao
	if(txtcolor <= 9 && _light) txtcolor+= 9;
	printf("%s%s%s",background_colors[bgcolor], effects[_text_effect], text_colors[txtcolor]);

	// Processar texto de entrada
	if(_output_string) outlen = strlen(_output_string);

	// formatar case?
	if(outlen && _convert_case){
		if(_convert_case == 1) str_to_upper(_output_string);	// Maiusculas
		if(_convert_case == 2) str_to_lower(_output_string);	// Minusculas
	}

	// apenas numeros? formatar
	if(_to_number_format){
		_output_string = str_number_format(_output_string);		// de 1234 para 1.234
		outlen = strlen(_output_string);
	}

	// fazer padding?
	if(_left_space){
		_output_string = str_pad_left(_output_string, _left_space);
	}else if(_right_space){
		_output_string = str_pad_right(_output_string, _right_space);
	}

// FINALIZAR -------------------------------------------------------------------------

	// jogar saida
	printf("%s", _output_string);

	// resetar cor
	if(_do_reset)
		printf("%s%s",background_colors[0],text_colors[0]);
	//-

	// quebra final de linha
	if(1==_do_break)
		printf("\n");
	//-

	// liberar memoria alocada nas formatacoes
	// MY_FREE();

	return 0;




}
コード例 #26
0
ファイル: main.c プロジェクト: Djidiouf/diffalternative
/***********************************************************
MAIN
***********************************************************/
int main(int argc, char** argv)
{
    //check the number of argument, less than 2 is impossible
    if (argc < 2)
    {
        printf("Not enough arguments.");
        return 1;
    }


    /*****************************************************
    Initialisation OPTIONS
    ******************************************************/
    int option_i = 0;
    int option_b = 0;
    int option_E = 0;
    int option_v = 0;
    int option_h = 0;
    int option_w = 0;
    int option_N = 0;
    int option_t = 0;

    //these options must call its functions after string behavior options
    int option_s = 0;
    int option_q = 0;
    int option_y = 0;


	//How many options do we have?
	int k;
	int cpt = 0; //total number of options
	for(k=1;k<argc;k++)
	{
			if(strcmp(argv[k], "-i") == 0 || strcmp(argv[k], "--ignore-case") == 0)
			{
				option_i = 1;
				cpt++;
			}
			if(strcmp(argv[k], "-b") == 0 || strcmp(argv[k], "--ignore-space-change") == 0)
			{
				option_b = 1;
				cpt++;
			}
			if(strcmp(argv[k], "-E") == 0 || strcmp(argv[k], "--ignore-tab-expansion") == 0)
			{
				option_E = 1;
				cpt++;
			}
			if(strcmp(argv[k], "-v") == 0  || strcmp(argv[k], "--version") == 0)
			{
				option_v = 1; //useless because of return 0;
				printf("%s: Version 2012.01.13.1727\n\n",argv[0]);
				printf("Written by Antoine Lang-Cavelier\n");
				return 0; //end of the programm now
			}
			if(strcmp(argv[k], "--help") == 0)
			{
				option_h = 1; //useless because of return 0;
                printf("Syntax:\n");
                printf("%s [OPTIONS] fichier1 fichier2\n\n",argv[0]);
				opt_help(); //we have a function to display the help
				return 0; //end of the programm now
			}
			if(strcmp(argv[k], "-w") == 0 || strcmp(argv[k], "--ignore-all-space") == 0)
			{
				option_w = 1;
				cpt++;
			}
			if(strcmp(argv[k], "-N") == 0 || strcmp(argv[k], "--new-file") == 0)
			{
				option_N = 1;
				cpt++;
				if (argv[2] == NULL)
				{
				    printf("%s: No differences between 2 empty files.\n",argv[0]);
				    return 0;
				}
			}
            if(strcmp(argv[k], "-t") == 0 || strcmp(argv[k], "--expand-tabs") == 0)
			{
				option_t = 1;
				cpt++;
			}
            if(strcmp(argv[k], "-s") == 0 || strcmp(argv[k], "--report-identical-files") == 0)
			{
				option_s = 1;
				cpt++;
			}
			if(strcmp(argv[k], "-q") == 0  || strcmp(argv[k], "--brief") == 0)
			{
				option_q = 1;
				cpt++;
			}
            if(strcmp(argv[k], "-y") == 0  || strcmp(argv[k], "--side-by-side") == 0)
			{
				option_y = 1;
				cpt++;
			}
	}
	//we increase our arguments by the number of different options selected
	//because after that, we will use argv[1] and argv[2]
	argv[1] = argv[cpt+1]; //first file
	argv[2] = argv[cpt+2]; //second file
    /*****************************************************
    ENDOF: Initialisation OPTIONS
    ******************************************************/

    if (option_N == 0 && argv[2] == NULL)
    {
        printf("%s: Missing operand after '%s'.\n",argv[0],argv[1]);
        printf("%s: Try `%s --help' for more information.\n",argv[0],argv[0]);
        return 0;
    }

    //we rename our two arguments to avoid type issues (char* vs char**)
    char* src1 = argv[1];
    char* src2 = argv[2];


    /*****************************************************
    ALGO DIFF;
    ******************************************************/
    //call of our function nombre_ligne();
    int nb1 = nombre_ligne(src1); //ask total lines of src1 and put it in nb1
    int nb2 = nombre_ligne(src2); //ask total lines of src2 and put it in nb2

    //beginning of the comparison loop in order to print the diff

    //call of our function file_to_tab();
    char** chaine_tab1 = file_to_tab(src1, nb1); //put our file1 in a tab of string
    char** chaine_tab2 = file_to_tab(src2, nb2); //put our file2 in a tab of string


	/*****************
    Option -i
    not case sensitive
    *****************/
	if (option_i == 1)
	{
	    int i;
	    for (i=0; i<nb1; i++)
	    {
	        chaine_tab1[i] = str_to_lower(chaine_tab1[i]);
	    }
	    int j;
	    for (j=0; j<nb2; j++)
	    {
	        chaine_tab2[j] = str_to_lower(chaine_tab2[j]);
	    }
	}
    /*****************
    ENDOF: Option -i
    *****************/


	/*****************
    Option -b
    no multi space
    *****************/
	if (option_b == 1)
	{
	    int i;
	    for (i=0; i<nb1; i++)
	    {
	        chaine_tab1[i] = str_onespace(chaine_tab1[i]);
	    }
	    int j;
	    for (j=0; j<nb2; j++)
	    {
	        chaine_tab2[j] = str_onespace(chaine_tab2[j]);
	    }
	}
    /*****************
    ENDOF: Option -b
    *****************/


	/*****************
    Option -E
    no multi tab
    *****************/
	if (option_E == 1)
	{
	    int i;
	    for (i=0; i<nb1; i++)
	    {
	        chaine_tab1[i] = str_onetab(chaine_tab1[i]);
	    }
	    int j;
	    for (j=0; j<nb2; j++)
	    {
	        chaine_tab2[j] = str_onetab(chaine_tab2[j]);
	    }
	}
    /*****************
    ENDOF: Option -E
    *****************/


	/*****************
    Option -w
    skip blank characters
    *****************/
	if (option_w == 1)
	{
	    int i;
	    for (i=0; i<nb1; i++)
	    {
	        chaine_tab1[i] = str_ignore_blank(chaine_tab1[i]);
	    }
	    int j;
	    for (j=0; j<nb2; j++)
	    {
	        chaine_tab2[j] = str_ignore_blank(chaine_tab2[j]);
	    }
	}
    /*****************
    ENDOF: Option -w
    *****************/


	/*****************
    Option -t
    change tab in space
    *****************/
	if (option_t == 1)
	{
	    int i;
	    for (i=0; i<nb1; i++)
	    {
	        chaine_tab1[i] = str_tabtospace(chaine_tab1[i]);
	    }
	    int j;
	    for (j=0; j<nb2; j++)
	    {
	        chaine_tab2[j] = str_tabtospace(chaine_tab2[j]);
	    }
	}
    /*****************
    ENDOF: Option -t
    *****************/


	/*****************
    Option -s
    report-identical-files
    *****************/
	if (option_s == 1)
	{
	    if (opt_s(chaine_tab1, nb1, chaine_tab2, nb2) == 0)
	    {
	        printf("Files %s and %s are identical.",src1,src2);

            free(chaine_tab1);
            free(chaine_tab2);
	        return 0;
	    }
	}
    /*****************
    ENDOF: Option -s
    *****************/


	/*****************
    Option -q
    brief diff
    MUST BE AFTER STRING BEHAVIOR OPTIONS
    *****************/
	if (option_q == 1)
	{
	    if (opt_q(chaine_tab1, nb1, chaine_tab2, nb2) != 0)
	    {
	        printf("Files %s and %s differ.", src1, src2);
	    }

        free(chaine_tab1);
        free(chaine_tab2);
	    return 0;
	}
    /*****************
    ENDOF: Option -q
    *****************/


	/*****************
    Option -y
    side by side diff
    MUST BE AFTER STRING BEHAVIOR OPTIONS
    *****************/
	if (option_y == 1)
	{
	    printf("Side by side diff of %s with %s:\n\n",src1,src2);
	    opt_y(chaine_tab1, nb1, chaine_tab2, nb2);

        free(chaine_tab1);
        free(chaine_tab2);
	    return 0;
	}
    /*****************
    ENDOF: Option -y
    *****************/


	printf("Diff of %s with %s:\n\n",src1,src2);

	// i is the index of the line we're processing in chaine_tab1.
	int i;
	// j is the index of the line we're processing in chaine_tab2.
	int j = 0;

	//Process each line of chaine_tab1 and do our job
	for (i=0; i<nb1; i++)
	{
		//Indicates if a matching line was found in chaine_tab2 (true = 1)
		int found = 0;
		//Indicates the number of lines we've skipped in chaine_tab2 before finding the matching line.
		int skipped = 0;

		//we process each line of chaine_tab2 (starting from the j-th one)
		//until we either find a matching line or the end of file
		while (j<nb2 && found == 0)
		{
			// Compare both lines
			if(strcmp(chaine_tab1[i], chaine_tab2[j]) == 0)
			{
				found = 1;
			}
			else
			{
			    skipped++;
			}
			j++;
		}

		//Now process the result:
		if (found == 1)
		{
			//Print lines we skipped (from j-skipped to j)
			int a;
			for (a=j-skipped;a<j;a++)
			{
				printf("> %s\n", chaine_tab2[a-1]);
			}
            //Print the matched line
			printf("= %s\n", chaine_tab1[i]);



		}
		else
		{
			//Only print the line from chaine_tab1, and rollback the
			//index j because we'll have to read those lines again.
			printf("< %s\n", chaine_tab1[i]);
			j = j-skipped;

		}
	}


	//Time to print all lines of chaine_tab2 if file2 have more
	//line than file1: these are all new.
	while (j < nb2)
    {
        printf("> %s\n", chaine_tab2[j]);
        j++;
    }

    //deallocation of our mallocs
    free(chaine_tab1);
    free(chaine_tab2);
    /*****************************************************
    ENDOF: ALGO DIFF;
    ******************************************************/

    return 0;
}