Esempio n. 1
0
/*
 * converts a string to a mac address...
 * returns 1 on success, -1 on failure...
 * failure indicates poorly formed input...
 */
int string_to_mac (char *string, unsigned int *mac_buf)
{
    char                        *ptr, *next;
    unsigned long       val;
    int                         i;


    to_upper(string);

    ptr = next = string;
    for(i=0;i < 6;i++) {
        if((val = strtoul(next, &ptr, 16)) > 255) {
            errno = EINVAL;
            return(-1);
        }
        mac_buf[i] = (unsigned int)val;
        if((next == ptr) && (i != 6 - 1)) {
            errno = EINVAL;
            return(-1);
        }
        next = ptr + 1;
    }

    return(1);
}
Esempio n. 2
0
int main()
{
  char s[200];
  printf("Enter the string in lower case\n");
  scanf("%[^\n]s",s);
  printf("your string : %s\n",s);
  int i=0;
  int j=0;
  while(s[j]!='\0')
  {
    if((s[j]>=65&&s[j]<=90)||(s[j]>=97&&s[j]<=122))
    {
     if(s[j]>=65&&s[j]<=90)
     {
       if(i%2==0)
       {   s[j]=to_lower(s[j]);
          i++;
       }
       else
       {
          s[j]=to_upper(s[j]);
          i++;
       }
      }
     }
    
    j++;
    
  }  
  printf("your string : %s\n",s);
  return 0;
} 
Esempio n. 3
0
Bool32   p2_msk_inc(CSTR_rast    rst)
{
#ifdef _USE_MSK_
    uchar       prob=0, name, lim, code;
    RecRaster   rc;
    RecVersions ver;
    int32_t       i;

    if(!HndTabInc )
        return 0;
    if(language!=PUMA_LANG_RUSSIAN && language!=PUMA_LANG_RUSENG )
        return 0;
    CSTR_GetImage(rst,(uchar*)&rc,CSTR_TYPE_IMAGE_RS);
    if( !rc.lnPixHeight || !rc.lnPixWidth )
        return 0;
    MSKSetAlphabet  ( alphabet );

    CSTR_GetCollection(rst,&ver);
    ver.lnAltCnt=2;
    ver.lnAltMax=REC_MAX_VERS;
    name = ver.Alt[0].Code;
    ver.Alt[0].Code=(uchar)to_upper((uchar)name);
    ver.Alt[0].Prob=255;
    ver.Alt[1].Code=(uchar)to_lower((uchar)name);
    ver.Alt[1].Prob=255;
    if( name=='0' )
    {
        ver.Alt[1].Code=(uchar)'О';
        ver.Alt[2].Code=(uchar)'Ѓ';
        ver.Alt[2].Prob=255;
        ver.lnAltCnt=3;
    }
    if( name=='3' )
    {
        ver.Alt[1].Code=(uchar)'З';
        ver.Alt[2].Code=(uchar)'І';
        ver.Alt[2].Prob=255;
        ver.lnAltCnt=3;
    }
    if( !MSKRecogCharExpPuma( HndTabInc, &rc, &ver,1 ) )
        return 0;
    if( !ver.lnAltCnt )
        return 0;

    for(prob=0, i=0;i<ver.lnAltCnt;i++)
    {
        if( prob<ver.Alt[i].Prob)
        {
            prob=ver.Alt[i].Prob ;
            code=ver.Alt[i].Code;
        }
    }
    lim = MIN_MSK_PROB;
    if( strchr(similar_letters,code) )
        lim = MIN_MSK_PROB_SIM;
    return (prob>lim);
#else
    return FALSE;
#endif
}
Esempio n. 4
0
char* correct_words(char* correct_word,char* word)
{
    char ch;
    char* res = NULL;
    int i = 0;
    int count_lower = 0, count_upper = 0;
    for(int i = 0; word[i] != '\0'; i++){
        if(word[i]>=65 && word[i] < 91){
            count_upper += 1;
        }
        else
            count_lower += 1;
    }
    if(count_upper > count_lower){
        for(; word[i] != '\0'; i++){
            ch = word[i];
            if(is_lower(ch)){
                ch = to_upper(ch);
            }
            correct_word[i] = ch;
        }
    }
    else{
        for(i = 0; word[i] != '\0'; i++){
            ch = word[i];
            if(is_upper(ch)){
                ch = to_lower(ch);
            }
            correct_word[i] = ch;
        }
    }
    correct_word[i] = '\0';
    res = correct_word;
    return res;
}
Esempio n. 5
0
void build_wx_wildcard_from_io_factory_aux(const std::string& family, const std::string& group, const vector<factory_key>& id, ostringstream& wildcard)
{
    ostringstream oss1;
    ostringstream oss2;
    bool first = true;
    for(vector<factory_key>::const_iterator it = id.begin(); it!=id.end(); ++it)
    {
        if(family!="" && it->family != family) continue;
        if(group !="" && it->group  != group ) continue;
        if(!first)
        {
            oss1 << " ";
            oss2 << ";";
        }
        string current_ext = it->extension;
        oss1 << current_ext;
        oss2 << "*." << current_ext << ";";
        to_upper(current_ext);
        oss2 << "*." << current_ext;
        first = false;
    }
    if(!first)
    {
        if(wildcard.tellp()>0) wildcard << "|";
        wildcard << (family==""?(group==""?"Supported":group):family) << " files (" << oss1.str() << ")|" << oss2.str();
    }
}
Esempio n. 6
0
Bool32 TestFontCourier(void)
{
#ifdef _USE_LEO_
    uchar          p;
    int32_t          name;
    RecRaster      recRast;
    int            i,j;
    int            nClust;
    int            porog=0; // test !!!
    int            numCourier,nC;

    RecVersions    MSKres;
    ClustInfo      clustinfo;
    int32_t          nf=FONGetFontCount();

    if( nf<1 || nf>2)
        return FALSE;
    nClust=FONGetClustCount();
    if(nClust < 20 )
        return FALSE;

    if(!HndTab)
        return FALSE;
    MSKSetAlphabet  ( alphabet );

    for(i=0,nC=numCourier=0;i<nClust;i++)
    {
        name=0;
        j=FONGetClusterAsBW(&name,i,porog,&recRast);
        if(j<0)
            continue;

        if( name>'9' && name<128 )
            continue;
        clustinfo.let = 0;  // from all clusters
        FONGetClustInfo( &clustinfo, i+1 );
        if( clustinfo.weight<3 )
            continue;
        if(0)
            CTB_AddRecRaster("CLUST2", &recRast,decode_ASCII_to_[name][0]);
        MSKres.lnAltCnt=2;
        MSKres.lnAltMax=REC_MAX_VERS;
        MSKres.Alt[0].Code=(uchar)to_upper((uchar)name);
        MSKres.Alt[0].Prob=255;
        MSKres.Alt[1].Code=(uchar)to_lower((uchar)name);
        MSKres.Alt[1].Prob=255;

        if(!MSKRecogCharExp( HndTab, &recRast,       &MSKres )  )
            continue;
        p = MAX(MSKres.Alt[0].Prob,MSKres.Alt[1].Prob);
        if( p> 150)
            numCourier++;
        nC++;
    }

    if(numCourier*3 > nC*2)
        return TRUE;
#endif
    return FALSE;
}
Esempio n. 7
0
int kix_code(struct zint_symbol *symbol, unsigned char source[], int length)
{
	/* Handles Dutch Post TNT KIX symbols */
	/* The same as RM4SCC but without check digit */
	/* Specification at http://www.tntpost.nl/zakelijk/klantenservice/downloads/kIX_code/download.aspx */
	char height_pattern[50], localstr[20];
	unsigned int loopey;
	int writer, i, h;
	int error_number; /* zeroes; */
	strcpy(height_pattern, "");

	error_number = 0;

	if(length > 18) {
		strcpy(symbol->errtxt, "Input too long");
		return ERROR_TOO_LONG;
	}
	to_upper(source);
	error_number = is_sane(KRSET, source, length);
	if(error_number == ERROR_INVALID_DATA) {
		strcpy(symbol->errtxt, "Invalid characters in data");
		return error_number;
	}

	/* Add leading zeroes */
	/* zeroes = 11 - length;
	memset(localstr, '0', zeroes);
	strcpy(localstr + zeroes, (char *)source);*/
	strcpy(localstr, (char *)source);

	/* Encode data */
	for (i = 0; i < 18; i++) {
		lookup(KRSET, RoyalTable, localstr[i], height_pattern);
	}

	writer = 0;
	h = strlen(height_pattern);
	for(loopey = 0; loopey < h; loopey++)
	{
		if((height_pattern[loopey] == '1') || (height_pattern[loopey] == '0'))
		{
			set_module(symbol, 0, writer);
		}
		set_module(symbol, 1, writer);
		if((height_pattern[loopey] == '2') || (height_pattern[loopey] == '0'))
		{
			set_module(symbol, 2, writer);
		}
		writer += 2;
	}

	symbol->row_height[0] = 3;
	symbol->row_height[1] = 2;
	symbol->row_height[2] = 3;
	symbol->rows = 3;
	symbol->width = writer - 1;

	return error_number;
}
Esempio n. 8
0
std::string soundex(const std::string& s)
{
  std::string head,tail;
  int n;

  if (s.length() == 0 || !is_alpha(s))
    return "";
  head=s.substr(0,1);
  head=to_upper(head);
  tail=s.substr(1);
  tail=to_upper(tail);
  replace_all(tail,"A","");
  replace_all(tail,"E","");
  replace_all(tail,"I","");
  replace_all(tail,"O","");
  replace_all(tail,"U","");
  replace_all(tail,"H","");
  replace_all(tail,"W","");
  replace_all(tail,"Y","");
  replace_all(tail,"B","1");
  replace_all(tail,"F","1");
  replace_all(tail,"P","1");
  replace_all(tail,"V","1");
  replace_all(tail,"C","2");
  replace_all(tail,"G","2");
  replace_all(tail,"J","2");
  replace_all(tail,"K","2");
  replace_all(tail,"Q","2");
  replace_all(tail,"S","2");
  replace_all(tail,"X","2");
  replace_all(tail,"Z","2");
  replace_all(tail,"D","3");
  replace_all(tail,"T","3");
  replace_all(tail,"L","4");
  replace_all(tail,"M","5");
  replace_all(tail,"N","5");
  replace_all(tail,"R","6");
  for (n=s.length()-1; n > 0; n--) {
    if (tail[n] == tail[n-1])
        tail[n]='*';
  }
  replace_all(tail,"*","");
  while (tail.length() < 3)
    tail+="0";
  return head+tail;
}
Esempio n. 9
0
string Func_get_format::getStrVal(rowgroup::Row& row,
							FunctionParm& parm,
							bool& isNull,
							CalpontSystemCatalog::ColType&)
{
	// parm[0] -- format
	// parm[1] -- type
	string format = parm[0]->data()->getStrVal(row, isNull);
	if (isNull)
		return "";

	transform (format.begin(), format.end(), format.begin(), to_upper());

	string type = parm[1]->data()->getStrVal(row, isNull);
	if (isNull)
		return "";

	transform (type.begin(), type.end(), type.begin(), to_upper());

	int itype = 0;
	for ( ; itype < 3 ; itype++ )
	{
		if ( know_types[itype] == type )
			break;
	}

	// check for match
	if ( itype == 3 )
		return "";

	for ( int i = 0 ; i < 5 ; i ++ )
	{
		if ( known_date_time_formats[i][0] == format )
		{
			switch (itype) {
				case 0:
					return known_date_time_formats[i][2];
					break;
				default:
					return "";
			}
		}
	}

	return "";
}
Esempio n. 10
0
EffectType effectFromStr(const std::string &str)
{
    auto i = allEffects.find(to_upper(str));
    if (i == std::end(allEffects)) {
        return EffectType::NONE;
    }
    return i->second;
}
Esempio n. 11
0
static dps_param_t handle_get_file_id(dps_appctx_t appctx,
    ptp_obj_handle_t autprint_mrk_file_id, char *dcf_file_path,
    ptp_obj_handle_t *id)
{
    jint_t i;
    char *filename = NULL;
    dps_param_t rc;
    DECLARE_FNAME("handle_get_file_id");

    DBG_X(DSLAVE_DPS_API, ("%s: entered\n", fname));

    *id = 0;
    rc = DPS_PARAM_MAKE(DPS_RESULT_UNSUPPORTED_OP,
            DPS_RESULT_MIN_INVALID_VALUE);
    
    for (i=0; sample_image[i].image; i++)
    {
        if (!sample_image[i].name)
            continue;

        filename = j_strdup(sample_image[i].name);
        if (!filename)
        {
            DBG_E(DSLAVE_DPS_API, ("%s: error allocating memory (strdup)\n",
                fname));
            rc = DPS_RESULT_UNEXECUTED_OP;
            goto Exit;
        }

        to_upper(filename);

        /* TODO: The code that should be implemented here is not a
         * straightforward string comparison.
         * The dcf_file_path is the image's path relative
         * to the DPOF file. In a real system e.g, the image'ss full path
         * would be reconstructed in order to do a full path search
         * for the file */
        if (!j_strcmp(dcf_file_path+sizeof(DCF_PREFIX)-1, filename))
        {
            jfree(filename);
            break;
        }

        jfree(filename);
    }

    if (sample_image[i].image)
    {
        *id = sample_image[0].id;
        rc = DPS_RESULT_OK;
    }

    DBG_X(DSLAVE_DPS_API, ("%s: autprint_id: 0x%X filename: %s"
        " img_id: 0x%X\n", fname, autprint_mrk_file_id, dcf_file_path, *id));

Exit:
    return rc;
}
Esempio n. 12
0
/*-----------------------------------------------------------------------------
** Function:	init_type()
** Purpose:	This is the initialization routine for this file. This
**		has to be called before some of the macros in |type.h|
**		will work as described. It does no harm to call this
**		initialization more than once. It just takes some time.
**
**		Note that this function is for internal purposes
**		only. The normal user should call |init_bibtool()|
**		instead.
** Arguments:	none
** Returns:	nothing
**___________________________________________________			     */
void init_type()				   /*                        */
{ register int i;				   /*                        */
 						   /*                        */
  for ( i = 0; i < 256; ++i )			   /*                        */
  { trans_lower[i] = is_upper(i)?to_lower(i):i;	   /*                        */
    trans_upper[i] = is_lower(i)?to_upper(i):i;	   /*                        */
    trans_id[i] = i;				   /*                        */
  }						   /*                        */
}						   /*------------------------*/
Esempio n. 13
0
void cmd_line_attempt(const char *line) {
    char line_copy[KEYBOARD_BUFFER_SIZE];
    strcpy(line_copy, line);
    strip_backspace(line_copy); // Get rid of backspace characters

    char *first_word = strtok(line_copy, " ");
    const char *the_rest_mixed_case = line_copy + (strlen(first_word) + 1);
    char the_rest[strlen(the_rest_mixed_case) + 1];
    to_upper(the_rest, the_rest_mixed_case);

    //Ugly case statement alternative
    if (strcmp("echo", first_word) == 0) {
        cmd_line_echo(the_rest);
    } else if (strcmp("test", first_word) == 0) {
        run_all_tests();
    } else if (strcmp("cd", first_word) == 0) {
        cmd_line_cd(the_rest);
    } else if (strcmp("pwd", first_word) == 0) {
        cmd_line_pwd(the_rest);
    } else if (strcmp("ls", first_word) == 0) {
        cmd_line_ls(the_rest);
    } else if (strcmp("cat", first_word) == 0) {
        cmd_line_cat(the_rest);
    } else if (strcmp("memory_demo", first_word) == 0) { // temporary, for debugging
        uint32_t identifier = permissions_capability_create();

        // set the memory
        int difference = get_max_memory() - get_current_memory_usage();
        capability_set_max_memory(identifier, difference);
        run("/BIN/PRINT_EV.NUN", identifier);
        console_printf("Attempting to run a process I don't have memory for.\nExpecting an error message soon...\n");
        run("/BIN/PRINT_OD.NUN", identifier);
        permissions_capability_delete(identifier);
    } else if (strcmp("clock_test", first_word) == 0) { // temporary, for debugging
        uint32_t identifier = permissions_capability_create();
        run("/BIN/TEST_CLO.NUN", identifier);
        permissions_capability_delete(identifier);
    } else if (strcmp("help", first_word) == 0) {   // Leave this as the last case
        cmd_line_help(the_rest);
    } else if (strcmp("window_test", first_word) == 0) {
        console_printf("\f");
        uint32_t identifier = permissions_capability_create();
        run("/BIN/TEST_WIN.NUN", identifier);
        permissions_capability_delete(identifier);
    }
    /*else if () {
     *...
     *}
     */
    else {
        console_printf("%s: command not found\n", first_word);
    }
    memset(line_copy, '\0', KEYBOARD_BUFFER_SIZE);
    return;
}
Esempio n. 14
0
 void on_message(proton::event &e) {
     std::cout << "Received " << e.message().body() << std::endl;
     std::string reply_to = e.message().reply_to();
     proton::message reply;
     reply.address(reply_to);
     reply.body(to_upper(e.message().body().get<std::string>()));
     reply.correlation_id(e.message().correlation_id());
     if (!senders[reply_to])
         senders[reply_to] = e.connection().open_sender(reply_to);
     senders[reply_to].send(reply);
 }
Esempio n. 15
0
int daft_code(struct zint_symbol *symbol, unsigned char source[], int length)
{
	/* Handles DAFT Code symbols */
	/* Presumably 'daft' doesn't mean the same thing in Germany as it does in the UK! */
	char height_pattern[100];
	unsigned int loopey, h;
	int writer, i, error_number;
	strcpy(height_pattern, "");

	error_number = 0;
	if(length > 50) {
		strcpy(symbol->errtxt, "Input too long");
		return ERROR_TOO_LONG;
	}
	to_upper((unsigned char*)source);
	error_number = is_sane(DAFTSET, (unsigned char*)source, length);

	if(error_number == ERROR_INVALID_DATA) {
		strcpy(symbol->errtxt, "Invalid characters in data");
		return error_number;
	}

	for (i = 0; i < length; i++) {
		if(source[i] == 'D') { concat(height_pattern, "2"); }
		if(source[i] == 'A') { concat(height_pattern, "1"); }
		if(source[i] == 'F') { concat(height_pattern, "0"); }
		if(source[i] == 'T') { concat(height_pattern, "3"); }
	}

	writer = 0;
	h = strlen(height_pattern);
	for(loopey = 0; loopey < h; loopey++)
	{
		if((height_pattern[loopey] == '1') || (height_pattern[loopey] == '0'))
		{
			set_module(symbol, 0, writer);
		}
		set_module(symbol, 1, writer);
		if((height_pattern[loopey] == '2') || (height_pattern[loopey] == '0'))
		{
			set_module(symbol, 2, writer);
		}
		writer += 2;
	}

	symbol->row_height[0] = 3;
	symbol->row_height[1] = 2;
	symbol->row_height[2] = 3;
	symbol->rows = 3;
	symbol->width = writer - 1;

	return error_number;
}
Esempio n. 16
0
int process_option_line(request * req)
{
    char c, *value, *line = req->header_line;

    /* Start by aggressively hacking the in-place copy of the header line */

#ifdef FASCIST_LOGGING
    log_error_time();
    fprintf(stderr, "%s:%d - Parsing \"%s\"\n", __FILE__, __LINE__, line);
#endif

    value = strchr(line, ':');
    if (value == NULL)
        return 0;
    *value++ = '\0';            /* overwrite the : */
    to_upper(line);             /* header types are case-insensitive */
    while ((c = *value) && (c == ' ' || c == '\t'))
        value++;

    if (!memcmp(line, "IF_MODIFIED_SINCE", 18) && !req->if_modified_since)
        req->if_modified_since = value;

    else if (!memcmp(line, "CONTENT_TYPE", 13) && !req->content_type)
        req->content_type = value;

    else if (!memcmp(line, "CONTENT_LENGTH", 15) && !req->content_length)
        req->content_length = value;

    else if (!memcmp(line, "CONNECTION", 11) &&
            ka_max && req->keepalive != KA_STOPPED) {
        req->keepalive = (!strncasecmp(value, "Keep-Alive", 10) ?
                KA_ACTIVE : KA_STOPPED);
    }
    /* #ifdef ACCEPT_ON */
    else if (!memcmp(line, "ACCEPT", 7))
        add_accept_header(req, value);
    /* #endif */

    /* Need agent and referer for logs */
    else if (!memcmp(line, "REFERER", 8)) {
        req->header_referer = value;
        if (!add_cgi_env(req, "REFERER", value, 1))
            return 0;
    } else if (!memcmp(line, "USER_AGENT", 11)) {
        req->header_user_agent = value;
        if (!add_cgi_env(req, "USER_AGENT", value, 1))
            return 0;
    } else {
        if (!add_cgi_env(req, line, value, 1))
            return 0;
    }
    return 1;
}
Esempio n. 17
0
String* string_upcase(String* string) {
  int i;

  char* upcased = (char*)malloc(sizeof(char[string->length])); 
  strcpy(upcased, string->value);

  for (i = 0; i < string->length; i++) {
    upcased[i] = to_upper(string->value[i]);
  }
  
  return string_init(upcased);
}
Esempio n. 18
0
/**
 * converts the 'str' string to uppercase
 */
char *strupper(char *str) {
  char *p = str;

  if (p == NULL) {
    return 0;
  }
  while (*p) {
    *p = to_upper(*p);
    p++;
  }
  return str;
}
int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle)
{
	int error_number;
	char output[4];
	
	switch(rotate_angle) {
		case 0:
		case 90:
		case 180:
		case 270:
			break;
		default:
			strcpy(symbol->errtxt, "Invalid rotation angle");
			return ERROR_INVALID_OPTION;
			break;
	}
	
	if(strlen(symbol->outfile) > 3) {
		output[0] = symbol->outfile[strlen(symbol->outfile) - 3];
		output[1] = symbol->outfile[strlen(symbol->outfile) - 2];
		output[2] = symbol->outfile[strlen(symbol->outfile) - 1];
		output[3] = '\0';
		to_upper((unsigned char*)output);

#ifndef NO_PNG
		if(!(strcmp(output, "PNG"))) {
			if(symbol->scale < 1.0) { symbol->text[0] = '\0'; }
			error_number = png_handle(symbol, rotate_angle);
		} else
#endif
		if(!(strcmp(output, "TXT"))) {
			error_number = dump_plot(symbol);
		} else
		if(!(strcmp(output, "EPS"))) {
			error_number = ps_plot(symbol);
		} else
		if(!(strcmp(output, "SVG"))) {
			error_number = svg_plot(symbol);
		} else
		{
			strcpy(symbol->errtxt, "Unknown output format");
			error_tag(symbol->errtxt, ERROR_INVALID_OPTION);
			return ERROR_INVALID_OPTION;
		}
	} else {
		strcpy(symbol->errtxt, "Unknown output format");
		error_tag(symbol->errtxt, ERROR_INVALID_OPTION);
		return ERROR_INVALID_OPTION;
	}

	error_tag(symbol->errtxt, error_number);
	return error_number;
}
Esempio n. 20
0
int search_dir_rec(iso_fs_t *fs, struct iso9660DirRecord *dir, char *name, struct iso9660DirRecord *ret)
{
	char buf[2048];
	char search[strlen(name)+4];
	memset(search, 0, strlen(name)+4);
	_strcpy(search, name);
	to_upper(search);
	unsigned int block=0, total=0;
	struct iso9660DirRecord *record;
	while(total < dir->DataLen_LE)
	{
		int res = iso9660_read_file(fs, dir, buf, block*2048, 2048);
		int off=0;
		while(off < res)
		{
			record = (struct iso9660DirRecord *)((char *)buf+off);
			if(!record->RecLen) {
				goto end;
			}
			/* Process the record */
			char flag=0;
			if(record->FileFlags & 0x2)
			{
				flag = (record->FileIdentLen == strlen((const char *)search) 
					&& !strncmp((const char *)record->FileIdent, 
					(const char *)search, record->FileIdentLen));
			} else
			{
				record->FileIdentLen -= 2;
				record->FileIdent[record->FileIdentLen]=0;
				if(record->FileIdent[record->FileIdentLen-1] == '.')
					record->FileIdent[--record->FileIdentLen]=0;
				flag = (record->FileIdentLen == strlen(search) 
					&& !strncmp((const char *)record->FileIdent, 
					(const char *)search, record->FileIdentLen));
			}
			if(flag)
			{
				/* Found! */
				memcpy(ret, record, sizeof(*ret));
				return 0;
			}
			off += record->RecLen;
		}
		if(res < 2048)
			break;
		block++;
		total += res;
	}
	end:
	return -1;
}
Esempio n. 21
0
void parse(File file, VolumeEntry *vol) {
	if ( file.isDirectory( ) == true ) 
	{
		vol->name = file.getName();

		for(size_t i = 0; i < vol->name.size(); i++) 
		{
			if ( changeCase == 1 ) 
				vol->name[i] = to_upper( vol->name[i] );
			else if(changeCase == 2) 
				vol->name[i] = to_lower( vol->name[i] );
		}

		printf("+ %s\n", vol->name.c_str());

		vol->type = 0;
		parseDirectory(file, vol);
	}
	else 
	{
		//printf("\"%s\"\n", file.getName().c_str());		
		vol->name = file.getName();

		for(size_t i = 0; i < vol->name.size(); i++) {
			if ( changeCase == 1 ) 
				vol->name[i] = to_upper( vol->name[i] );
			else if ( changeCase == 2 ) 
				vol->name[i] = to_lower( vol->name[i] );
		}

		printf("++ %s\n", vol->name.c_str());

		vol->type = 1;
		vol->dataOffset = fileDataPtr;
		vol->dataLength = readFile(file.getAbsolutePath().c_str());
		return;
	}
}
Esempio n. 22
0
String* string_capitalize(String* string) {
  int i;

  char* capitalized = (char*)malloc(sizeof(char[string->length])); 
  strcpy(capitalized, string->value); // TODO remove this step from all

  for (i = 0; i < string->length; i++) {
    if (' ' == string->value[i]) {
      capitalized[i + 1] = to_upper(string->value[i + 1]);
    }
  }
  
  return string_init(capitalized);
}
Esempio n. 23
0
TiXmlElement* ConfigManager::AssertPath(wxString& path)
{
    Collapse(path);

    wxString illegal(_T(" -:.\"\'$&()[]<>+#"));
    size_t i = 0;
    while ((i = path.find_first_of(illegal, i)) != wxString::npos)
        path[i] = _T('_');

    TiXmlElement *localPath = pathNode ? pathNode : root;

    if (path.GetChar(0) == '/')  // absolute path
    {
        localPath = root;
        path = path.Mid(1);
    }

    if (path.find(_T('/')) != wxString::npos) // need for path walking
        to_lower(path);

    wxString sub;

    while (path.find(_T('/')) != wxString::npos)
    {
        sub = path.BeforeFirst(_T('/'));
        path = path.AfterFirst(_T('/'));

        if (localPath != root && sub.IsSameAs(CfgMgrConsts::dotDot))
            localPath = localPath->Parent()->ToElement();
        else if (sub.GetChar(0) < _T('a') || sub.GetChar(0) > _T('z'))
        {
            cbThrow(InvalidNameMessage(_T("subpath"), sub, localPath));
        }
        else
        {
            TiXmlElement* n = localPath->FirstChildElement(cbU2C(sub));
            if (n)
                localPath = n;
            else
                localPath = (TiXmlElement*) localPath->InsertEndChild(TiXmlElement(cbU2C(sub)));
        }
    }

    to_upper(path);

    if (!path.IsEmpty() && (path.GetChar(0) < _T('A') || path.GetChar(0) > _T('Z')))
        cbThrow(InvalidNameMessage(_T("key"), path, localPath));

    return localPath;
}
Esempio n. 24
0
bool FGOutput::Load(Element* el)
{
  // Unlike the other FGModel classes, properties listed in the <output> section
  // are not intended to create new properties. For that reason, FGOutput
  // cannot load its XML directives with FGModel::Load().
  // Instead FGModelLoader::Open() and FGModel::PreLoad() must be explicitely
  // called.
  FGModelLoader ModelLoader(this);
  Element* element = ModelLoader.Open(el);

  if (!element) return false;

  FGModel::PreLoad(element, PropertyManager);

  size_t idx = OutputTypes.size();
  string type = element->GetAttributeValue("type");
  FGOutputType* Output = 0;

  if (debug_lvl > 0) cout << endl << "  Output data set: " << idx << "  " << endl;

  type = to_upper(type);

  if (type == "CSV") {
    Output = new FGOutputTextFile(FDMExec);
  } else if (type == "TABULAR") {
    Output = new FGOutputTextFile(FDMExec);
  } else if (type == "SOCKET") {
    Output = new FGOutputSocket(FDMExec);
  } else if (type == "FLIGHTGEAR") {
    Output = new FGOutputFG(FDMExec);
  } else if (type == "QTJSBSIM") {
    Output = new FGUDPOutputSocket(FDMExec);
  } else if (type == "TERMINAL") {
    // Not done yet
  } else if (type != string("NONE")) {
    cerr << "Unknown type of output specified in config file" << endl;
  }

  if (!Output) return false;

  Output->SetIdx(idx);
  Output->Load(element);
  PostLoad(element, PropertyManager);

  OutputTypes.push_back(Output);

  Debug(2);
  return true;
}
Esempio n. 25
0
int royal_plot(struct zint_symbol *symbol, unsigned char source[], int length)
{
	/* Puts RM4SCC into the data matrix */
	char height_pattern[200];
	unsigned int loopey, h;
	int writer;
	int error_number;
	strcpy(height_pattern, "");

	error_number = 0;

	if(length > 120) {
		strcpy(symbol->errtxt, "Input too long");
		return ERROR_TOO_LONG;
	}
	to_upper(source);
	error_number = is_sane(KRSET, source, length);
	if(error_number == ERROR_INVALID_DATA) {
		strcpy(symbol->errtxt, "Invalid characters in data");
		return error_number;
	}
	/*check = */rm4scc((char*)source, (unsigned char*)height_pattern, length);
	
	writer = 0;
	h = strlen(height_pattern);
	for(loopey = 0; loopey < h; loopey++)
	{
		if((height_pattern[loopey] == '1') || (height_pattern[loopey] == '0'))
		{
			set_module(symbol, 0, writer);
		}
		set_module(symbol, 1, writer);
		if((height_pattern[loopey] == '2') || (height_pattern[loopey] == '0'))
		{
			set_module(symbol, 2, writer);
		}
		writer += 2;
	}

	symbol->row_height[0] = 3;
	symbol->row_height[1] = 2;
	symbol->row_height[2] = 3;
	symbol->rows = 3;
	symbol->width = writer - 1;

	return error_number;
}
Esempio n. 26
0
bool FGOutput::Load(int subSystems, std::string protocol, std::string type,
                    std::string port, std::string name, double outRate,
                    std::vector<FGPropertyNode_ptr> & outputProperties)
{
  size_t idx = OutputTypes.size();
  FGOutputType* Output = 0;

  if (debug_lvl > 0) cout << endl << "  Output data set: " << idx << endl;

  type = to_upper(type);

  if (type == "CSV") {
    FGOutputTextFile* OutputTextFile = new FGOutputTextFile(FDMExec);
    OutputTextFile->SetDelimiter(",");
    Output = OutputTextFile;
  } else if (type == "TABULAR") {
    FGOutputTextFile* OutputTextFile = new FGOutputTextFile(FDMExec);
    OutputTextFile->SetDelimiter("\t");
    Output = OutputTextFile;
  } else if (type == "SOCKET") {
    Output = new FGOutputSocket(FDMExec);
    name += ":" + port + "/" + protocol;
  } else if (type == "FLIGHTGEAR") {
    Output = new FGOutputFG(FDMExec);
    name += ":" + port + "/" + protocol;
  } else if (type == "QTJSBSIM") {
    Output = new FGUDPOutputSocket(FDMExec);
    name += ":" + port + "/" + protocol;
  } else if (type == "TERMINAL") {
    // Not done yet
  } else if (type != string("NONE")) {
    cerr << "Unknown type of output specified in config file" << endl;
  }

  if (!Output) return false;

  Output->SetIdx(idx);
  Output->SetOutputName(name);
  Output->SetRateHz(outRate);
  Output->SetSubSystems(subSystems);
  Output->SetOutputProperties(outputProperties);

  OutputTypes.push_back(Output);

  Debug(2);
  return true;
}
Esempio n. 27
0
int main ( ){
	int k;
	char name[20], course[20];

	strcpy(course, "C_Programming");
	printf("\nprint a name = ");
	scanf("%s", name);        

	printf("\n%s is a student in %s.\n", name, course );

	course[13] = 'x';
    to_upper(name);
    printf("Our student %s is now all upper case in course %s!\n", name, course);
    	
	system("sleep 2");
	return 0;
} 
Esempio n. 28
0
EvidenceType
evidenceID(std::string evidence_type)
{
    to_upper(evidence_type);

    if (evidence_type == "CRIME")
    {
        return crime;
    }
    else if (evidence_type == "REFERENCE" || evidence_type == "REF")
    {
        return reference;
    }
    else
    {
        return ev_type_unknown;
    }
}
Esempio n. 29
0
int main()
{
    char original_line[81];
    char new_line[81];
    void *handle = dlopen("./upper.so", RTLD_LAZY);
    if (!handle)
    {
        fprintf(stderr, "Failed to load upper.so: %s\n", dlerror());
        return 1;
    }
    void (*to_upper)(char *, const char *);
    to_upper = dlsym(handle, "to_upper");
    puts("Please enter a line:");
    fgets(original_line, 81, stdin);
    to_upper(new_line, original_line);
    printf("\nUppercase version of the line:\n%s\n", new_line);
    return 0;
}
Esempio n. 30
0
    void on_message(proton::delivery &d, proton::message &m) override {
        std::cout << "Received " << m.body() << std::endl;

        std::string reply_to = m.reply_to();
        sender_map::iterator it = senders.find(reply_to);

        if (it == senders.end()) {
            std::cout << "No link for reply_to: " << reply_to << std::endl;
        } else {
            proton::sender sender = it->second;
            proton::message reply;

            reply.to(reply_to);
            reply.body(to_upper(proton::get<std::string>(m.body())));
            reply.correlation_id(m.correlation_id());

            sender.send(reply);
        }
    }