本文整理汇总了C++中print_string函数的典型用法代码示例。如果您正苦于以下问题:C++ print_string函数的具体用法?C++ print_string怎么用?C++ print_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(void) {
u16 i;
u08 data[2];
int j=0;
init();
test_motor();
clear_screen();
_delay_ms(100);
data[0] = 0x1; //change to WAKE mode
send_address(0x2A,0);
write_register(&data[0], 1);
_delay_ms(100);
unlock_bus();
//send_address(0x2);
//read_register(&data[1], 1);
print_num(data[0]);
//while(1) {}
while(1) {
//X
send_address(0x1,1);
read_register(&(data[0]), 1);
print_num(data[0]);
print_string(" ",1);
//Y
send_address(0x3,1);
read_register(&(data[0]), 1);
print_num(data[0]);
print_string(" ", 1);
//Z
lcd_cursor(0,1);
send_address(0x5,1);
read_register(&(data[0]), 1);
print_num(data[0]);
print_string(" ",1);
print_num(SP);
_delay_ms(150);
clear_screen();
}
/*
USI_TWI_Master_Initialize();
i2cMessageBuf[0] = 0x1c << 1; // Odd numbers for read
i2cMessageBuf[1] = 0x0d; // Register 0 contains version number
i2cMessageBuf[2] = (0x1c << 1) + 1; // Odd numbers for read
i2cMessageBuf[3] = 0x00; // Register 0 contains version number
USI_TWI_Start_Read_Write( i2cMessageBuf, 1 );
*/
while(get_sw1() == 0) {}
DDRD |= _BV(IR_PIN);
led_on(1);
led_on(0);
clear_screen();
while(1) {
_delay_ms(1500);
if (j) {
clear_screen();
print_string("test",4);
led_on(1);
led_off(0);
//sbi(PORTC,LCD_E_PIN);
//sbi(PORTC,LCD_RS_PIN);
//PORTA = 0xff;
sbi(PORTD,IR_PIN); //turn on IR pin
sbi(PORTC,SERVO0_PIN); //set servo pins
sbi(PORTC,SERVO1_PIN);
sbi(PORTC,SERVO2_PIN);
sbi(PORTF,SERVO3_PIN);
//test i2c pins
//sbi(PORTE,4);
//sbi(PORTE,5);
//motor test
sbi(PORTB,MOTOR0_EN_PIN);
sbi(PORTB,MOTOR1_EN_PIN);
sbi(PORTD,MOTOR0_DIR0_PIN);
sbi(PORTD,MOTOR0_DIR1_PIN);
sbi(PORTD,MOTOR1_DIR0_PIN);
sbi(PORTD,MOTOR1_DIR1_PIN);
j=0;
//.........这里部分代码省略.........
示例2: handle_message
//.........这里部分代码省略.........
if (show)
{
mutex_lock(&output_mutex);
printf("%s ", rule->identifier);
if (show_tags)
{
printf("[");
tag_name = rule->tags;
tag_length = tag_name != NULL ? strlen(tag_name) : 0;
while (tag_length > 0)
{
printf("%s", tag_name);
tag_name += tag_length + 1;
tag_length = strlen(tag_name);
if (tag_length > 0)
printf(",");
}
printf("] ");
}
// Show meta-data.
if (show_meta)
{
meta = rule->metas;
printf("[");
while(!META_IS_NULL(meta))
{
if (meta->type == META_TYPE_INTEGER)
printf("%s=%d", meta->identifier, meta->integer);
else if (meta->type == META_TYPE_BOOLEAN)
printf("%s=%s", meta->identifier, meta->integer ? "true" : "false");
else
printf("%s=\"%s\"", meta->identifier, meta->string);
meta++;
if (!META_IS_NULL(meta))
printf(",");
}
printf("] ");
}
printf("%s\n", (char*) data);
// Show matched strings.
if (show_strings)
{
string = rule->strings;
while (!STRING_IS_NULL(string))
{
string_found = STRING_FOUND(string);
if (string_found)
{
match = STRING_MATCHES(string).head;
while (match != NULL)
{
printf("0x%" PRIx64 ":%s: ", match->first_offset, string->identifier);
if (STRING_IS_HEX(string))
{
print_hex_string(match->data, match->length);
}
else
{
print_string(match->data, match->length);
}
match = match->next;
}
}
string++;
}
}
mutex_unlock(&output_mutex);
}
if (is_matching)
count++;
if (limit != 0 && count >= limit)
return CALLBACK_ABORT;
return CALLBACK_CONTINUE;
}
示例3: list_ppkg_types
/*
** list_ppkg_types:
** Print a list of packages. If package_id is 0, list all packages; otherwise
** list the single package specified. If successful, return the number of
** items listed; otherwise return -1.
*/
int
list_ppkg_types(int package_id)
{
struct fields {
int package_id;
char display_value[80 + 1];
};
int success;
int ret;
int no_items;
int item_cnt;
ABP_PPKG_TYPE keys = NULL, item = NULL, list = NULL;
for (success = 0; !success; success = 1) {
keys = new_abp_ppkg_type();
if (keys == NULL) {
logprintf(LOG_ERR, "new_abp_ppkg_type() failed\n");
break;
}
unset_abp_ppkg_type(keys);
if (package_id > 0) {
set_abp_ppkg_type_package_id(keys, package_id);
}
ret = list_abp_ppkg_types(g_dbhandle, keys, &list);
if (ret < 0) {
LOG_API_ERROR(g_dbhandle, ret);
break;
}
no_items = ret;
printf("\n");
printf("Product Package Type\n");
printf("--------------------\n");
for (item = list, item_cnt = 0;
item != NULL;
item = next_abp_ppkg_type(item), item_cnt++)
{
struct fields f;
char *label;
label = "package_id:";
ret = get_abp_ppkg_type_package_id(item, &f.package_id);
print_int(ret, label, f.package_id);
label = "display_value:";
ret = get_abp_ppkg_type_display_value(item, f.display_value);
print_string(ret, label, f.display_value);
printf("\n");
}
if (item_cnt != no_items) {
logprintf(LOG_ERR, "item_cnt != no_items\n");
break;
}
}
delete_abp_ppkg_type(keys);
abp_delete_objects(list);
return success ? item_cnt : -1;
}
示例4: draw_string
// draw string in OpenGL at position x, y
void draw_string(GLfloat x, GLfloat y, const char* word)
{
glColor4f(1.0, 1.0, 1.0, 0.0);
glRasterPos2f(x, y);
print_string(font_base, word);
}
示例5: main
void main(void)
{
x = 'Q';
print_int(x);
print_string("\n");
}
示例6: load_file
//.........这里部分代码省略.........
qsort((void *)file_list, num_files, sizeof(u8 *), sort_function);
qsort((void *)dir_list, num_dirs, sizeof(u8 *), sort_function);
closedir(current_dir);
current_dir_length = strlen(current_dir_name);
if(current_dir_length > 80)
{
memcpy(current_dir_short, "...", 3);
memcpy(current_dir_short + 3,
current_dir_name + current_dir_length - 77, 77);
current_dir_short[80] = 0;
}
else
{
memcpy(current_dir_short, current_dir_name,
current_dir_length + 1);
}
repeat = 1;
if(num_files == 0)
current_column = 1;
clear_screen(COLOR_BG);
u8 print_buffer[81];
while(repeat)
{
flip_screen();
print_string(current_dir_short, COLOR_ACTIVE_ITEM, COLOR_BG, 0, 0);
#if defined(ZAURUS) || defined(DINGUX_ON_WIN32)
print_string("Press Cancel to return to the main menu.",
COLOR_HELP_TEXT, COLOR_BG, 20, 220);
for(i = 0, current_file_number = i + current_file_scroll_value;
i < FILE_LIST_ROWS; i++, current_file_number++)
{
if(current_file_number < num_files)
{
strncpy(print_buffer,file_list[current_file_number],38);
print_buffer[38] = 0;
if((current_file_number == current_file_selection) &&
(current_column == 0))
{
print_string(print_buffer, COLOR_ACTIVE_ITEM,
COLOR_BG, FILE_LIST_POSITION, ((i + 1) * 10));
}
else
{
print_string(print_buffer, COLOR_INACTIVE_ITEM,
COLOR_BG, FILE_LIST_POSITION, ((i + 1) * 10));
}
}
}
for(i = 0, current_dir_number = i + current_dir_scroll_value;
i < FILE_LIST_ROWS; i++, current_dir_number++)
{
if(current_dir_number < num_dirs)
{
strncpy(print_buffer,dir_list[current_dir_number], 13);
print_buffer[14] = 0;
if((current_dir_number == current_dir_selection) &&
示例7: print_string_init
static int __init print_string_init(void)
{
print_string("The module has been inserted. Hello world!");
return 0;
}
示例8: print_prompt
/*
* プロンプトを表示する
* */
void print_prompt(FILE *fp) {
print_string(PROMPT, fp);
}
示例9: printk
/**********************************************************************
* Description:
* Prints Formatted strings for STD out. Format specifiers
* provide what type of data to be printed and the data value is taken
* from the argument list.
*
* Input:
* One or more Formatted string messages to be printed allong with
* other data values to be printed.
*
* Output:
* Number of characters actually printed. -1 if failure.
*********************************************************************/
int printk(char *fmt, ...)
{
va_list arg;
int ret = 0;
uint32_t val;
uint64_t val64;
//Check if valid putc() is registered.
if (_putc == NULL)
return -1;
// Variable argument processing
va_start(arg, fmt);
// Till the end of string
while(*fmt != '\0')
{
// Format the data to be printed
if(*fmt == '%')
{
fmt++;
switch(*fmt)
{
case 'd': // Print the integer
val = va_arg(arg,int);
ret += print_int32((int)val);
break;
case 'x': // Print Hex
val = va_arg(arg, uint32_t);
ret += print_hex32(val, 1);
break;
case 'c': // Print the char
val = va_arg(arg, int);
_putc((char)val);
ret++;
break;
case 'u': // Print unsigned int
val = va_arg(arg, uint32_t);
ret += print_uint32(val);
break;
case 's': // Print the string
val = va_arg(arg, uint32_t);
ret += print_string((char*)val);
break;
case 'l': // Long data
switch(*(++fmt))
{
case 'u':
val64 = va_arg(arg, uint64_t);
ret += print_uint64(val64);
break;
case 'd':
val64 = va_arg(arg, int64_t);
ret += print_int64(val64);
break;
case 'x':
val64 = va_arg(arg, uint64_t);
ret += print_hex64(val64);
break;
default:
val64 = va_arg(arg, int64_t);
ret += print_int64(val64);
break;
}
break;
default:
_putc(*fmt);
ret++;
break;
}
}
else
{
示例10: Print
void Print( const Value* value, std::ostream& result )
{
// TODO: switch on typeid?
if( !value )
{
return;
}
const IntegerValue* integervalue = dynamic_cast<const IntegerValue*>(
value );
if( integervalue )
{
print_integer( integervalue, result );
return;
}
const DecimalValue* decimalvalue = dynamic_cast<const DecimalValue*>(
value );
if( decimalvalue )
{
print_decimal( decimalvalue, result );
return;
}
const StringValue* stringvalue = dynamic_cast<const StringValue*>(
value );
if( stringvalue )
{
print_string( stringvalue, result );
return;
}
const TrueValue* truevalue = dynamic_cast<const TrueValue*>(
value );
if( truevalue )
{
print_true( truevalue, result );
return;
}
const FalseValue* falsevalue = dynamic_cast<const FalseValue*>(
value );
if( falsevalue )
{
print_false( falsevalue, result );
return;
}
const NilValue* nilvalue = dynamic_cast<const NilValue*>(
value );
if( nilvalue )
{
print_nil( nilvalue, result );
return;
}
const CombinationValue* combovalue = dynamic_cast<
const CombinationValue*>( value );
if( combovalue )
{
print_combination( combovalue, result );
return;
}
const SymbolValue* symbolvalue = dynamic_cast<
const SymbolValue*>( value );
if( symbolvalue )
{
print_symbol( symbolvalue, result );
return;
}
const NativeFunctionValue* fnvalue = dynamic_cast<
const NativeFunctionValue*>( value );
if( fnvalue )
{
print_built_in_procedure( fnvalue, result );
return;
}
const CompoundProcedureValue* procvalue = dynamic_cast<
const CompoundProcedureValue*>( value );
if( procvalue )
{
print_compound_procedure( procvalue, result );
return;
}
const PairValue* pairvalue = dynamic_cast<
const PairValue*>( value );
if( pairvalue )
{
print_pair( pairvalue, result );
return;
}
result << "<<UNPRINTABLE TYPE " << typeid(value).name() << ">>";
}
示例11: vti6_parse_opt
//.........这里部分代码省略.........
okey = rta_getattr_u32(vtiinfo[IFLA_VTI_OKEY]);
if (vtiinfo[IFLA_VTI_LINK])
link = rta_getattr_u8(vtiinfo[IFLA_VTI_LINK]);
if (vtiinfo[IFLA_VTI_FWMARK])
fwmark = rta_getattr_u32(vtiinfo[IFLA_VTI_FWMARK]);
free(answer);
}
while (argc > 0) {
if (!matches(*argv, "key")) {
NEXT_ARG();
ikey = okey = tnl_parse_key("key", *argv);
} else if (!matches(*argv, "ikey")) {
NEXT_ARG();
ikey = tnl_parse_key("ikey", *argv);
} else if (!matches(*argv, "okey")) {
NEXT_ARG();
okey = tnl_parse_key("okey", *argv);
} else if (!matches(*argv, "remote")) {
NEXT_ARG();
get_addr(&daddr, *argv, AF_INET6);
} else if (!matches(*argv, "local")) {
NEXT_ARG();
get_addr(&saddr, *argv, AF_INET6);
} else if (!matches(*argv, "dev")) {
NEXT_ARG();
link = ll_name_to_index(*argv);
if (!link)
exit(nodev(*argv));
} else if (strcmp(*argv, "fwmark") == 0) {
NEXT_ARG();
if (get_u32(&fwmark, *argv, 0))
invarg("invalid fwmark\n", *argv);
} else {
vti6_print_help(lu, argc, argv, stderr);
return -1;
}
argc--; argv++;
}
addattr32(n, 1024, IFLA_VTI_IKEY, ikey);
addattr32(n, 1024, IFLA_VTI_OKEY, okey);
if (is_addrtype_inet_not_unspec(&saddr))
addattr_l(n, 1024, IFLA_VTI_LOCAL, saddr.data, saddr.bytelen);
if (is_addrtype_inet_not_unspec(&daddr))
addattr_l(n, 1024, IFLA_VTI_REMOTE, daddr.data, daddr.bytelen);
addattr32(n, 1024, IFLA_VTI_FWMARK, fwmark);
if (link)
addattr32(n, 1024, IFLA_VTI_LINK, link);
return 0;
}
static void vti6_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
{
char s2[64];
if (!tb)
return;
tnl_print_endpoint("remote", tb[IFLA_VTI_REMOTE], AF_INET6);
tnl_print_endpoint("local", tb[IFLA_VTI_LOCAL], AF_INET6);
if (tb[IFLA_VTI_LINK]) {
__u32 link = rta_getattr_u32(tb[IFLA_VTI_LINK]);
if (link) {
print_string(PRINT_ANY, "link", "dev %s ",
ll_index_to_name(link));
}
}
if (tb[IFLA_VTI_IKEY]) {
struct rtattr *rta = tb[IFLA_VTI_IKEY];
__u32 key = rta_getattr_u32(rta);
if (key && inet_ntop(AF_INET, RTA_DATA(rta), s2, sizeof(s2)))
print_string(PRINT_ANY, "ikey", "ikey %s ", s2);
}
if (tb[IFLA_VTI_OKEY]) {
struct rtattr *rta = tb[IFLA_VTI_OKEY];
__u32 key = rta_getattr_u32(rta);
if (key && inet_ntop(AF_INET, RTA_DATA(rta), s2, sizeof(s2)))
print_string(PRINT_ANY, "okey", "okey %s ", s2);
}
if (tb[IFLA_VTI_FWMARK]) {
__u32 fwmark = rta_getattr_u32(tb[IFLA_VTI_FWMARK]);
if (fwmark) {
print_0xhex(PRINT_ANY,
"fwmark", "fwmark %#llx ", fwmark);
}
}
}
示例12: vti_parse_opt
//.........这里部分代码省略.........
NEXT_ARG();
if (!strcmp(*argv, "any")) {
fprintf(stderr, "invalid value for \"local\": \"%s\"\n", *argv);
exit(-1);
} else {
saddr = get_addr32(*argv);
}
} else if (!matches(*argv, "dev")) {
NEXT_ARG();
link = if_nametoindex(*argv);
if (link == 0) {
fprintf(stderr, "Cannot find device \"%s\"\n",
*argv);
exit(-1);
}
} else if (strcmp(*argv, "fwmark") == 0) {
NEXT_ARG();
if (get_u32(&fwmark, *argv, 0))
invarg("invalid fwmark\n", *argv);
} else
usage();
argc--; argv++;
}
addattr32(n, 1024, IFLA_VTI_IKEY, ikey);
addattr32(n, 1024, IFLA_VTI_OKEY, okey);
addattr_l(n, 1024, IFLA_VTI_LOCAL, &saddr, 4);
addattr_l(n, 1024, IFLA_VTI_REMOTE, &daddr, 4);
addattr32(n, 1024, IFLA_VTI_FWMARK, fwmark);
if (link)
addattr32(n, 1024, IFLA_VTI_LINK, link);
return 0;
}
static void vti_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
{
const char *local = "any";
const char *remote = "any";
__u32 key;
unsigned int link;
char s2[IFNAMSIZ];
if (!tb)
return;
if (tb[IFLA_VTI_REMOTE]) {
unsigned int addr = rta_getattr_u32(tb[IFLA_VTI_REMOTE]);
if (addr)
remote = format_host(AF_INET, 4, &addr);
}
print_string(PRINT_ANY, "remote", "remote %s ", remote);
if (tb[IFLA_VTI_LOCAL]) {
unsigned int addr = rta_getattr_u32(tb[IFLA_VTI_LOCAL]);
if (addr)
local = format_host(AF_INET, 4, &addr);
}
print_string(PRINT_ANY, "local", "local %s ", local);
if (tb[IFLA_VTI_LINK] &&
(link = rta_getattr_u32(tb[IFLA_VTI_LINK]))) {
const char *n = if_indextoname(link, s2);
if (n)
print_string(PRINT_ANY, "link", "dev %s ", n);
else
print_uint(PRINT_ANY, "link_index", "dev %u ", link);
}
if (tb[IFLA_VTI_IKEY] &&
(key = rta_getattr_u32(tb[IFLA_VTI_IKEY])))
print_0xhex(PRINT_ANY, "ikey", "ikey %#x ", ntohl(key));
if (tb[IFLA_VTI_OKEY] &&
(key = rta_getattr_u32(tb[IFLA_VTI_OKEY])))
print_0xhex(PRINT_ANY, "okey", "okey %#x ", ntohl(key));
if (tb[IFLA_VTI_FWMARK]) {
__u32 fwmark = rta_getattr_u32(tb[IFLA_VTI_FWMARK]);
if (fwmark) {
SPRINT_BUF(b1);
snprintf(b1, sizeof(b1), "0x%x", fwmark);
print_string(PRINT_ANY, "fwmark", "fwmark %s ", s2);
}
}
}
static void vti_print_help(struct link_util *lu, int argc, char **argv,
FILE *f)
{
print_usage(f);
}
示例13: print_fp
void print_fp(float number) {
char s[10];
dtostre(number,s,3,0);
print_string(s);
}
示例14: print_int
void print_int(u16 number) {
u08 test[7];
print_string((char*)itoa(number,test,10
));
}
示例15: switch
/* Render a value to text. */
static char *print_value(cJSON *item, int depth, int fmt, printbuffer *p)
{
char *out = 0;
if (!item) return 0;
if (p)
{
switch ((item->type) & 255)
{
case cJSON_NULL:
{
out = ensure(p, 5);
if (out) strcpy(out, "null");
break;
}
case cJSON_False:
{
out = ensure(p, 6);
if (out) strcpy(out, "false");
break;
}
case cJSON_True:
{
out = ensure(p, 5);
if (out) strcpy(out, "true");
break;
}
case cJSON_Number:
out = print_number(item, p);
break;
case cJSON_String:
out = print_string(item, p);
break;
case cJSON_Array:
out = print_array(item, depth, fmt, p);
break;
case cJSON_Object:
out = print_object(item, depth, fmt, p);
break;
}
}
else
{
switch ((item->type) & 255)
{
case cJSON_NULL:
out = cJSON_strdup("null");
break;
case cJSON_False:
out = cJSON_strdup("false");
break;
case cJSON_True:
out = cJSON_strdup("true");
break;
case cJSON_Number:
out = print_number(item, 0);
break;
case cJSON_String:
out = print_string(item, 0);
break;
case cJSON_Array:
out = print_array(item, depth, fmt, 0);
break;
case cJSON_Object:
out = print_object(item, depth, fmt, 0);
break;
}
}
return out;
}