当前位置: 首页>>代码示例>>C++>>正文


C++ print_list函数代码示例

本文整理汇总了C++中print_list函数的典型用法代码示例。如果您正苦于以下问题:C++ print_list函数的具体用法?C++ print_list怎么用?C++ print_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了print_list函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: print_about

void
print_about(const int debuglvl)
{
    int     max_height = 0,
            max_width = 0,
            height = 0,
            width = 0,
            startx = 0,
            starty = 0;
    struct vrmr_list  about_list;

    /* top menu */
    char    *key_choices[] =    { "F10" };
    int     key_choices_n = 1;
    char    *cmd_choices[] =    { gettext("back") };
    int     cmd_choices_n = 1;
    char    about_version_string[sizeof(version_string)];

    /* create the about version string */
    snprintf(about_version_string, sizeof(about_version_string), "Version: %s\n", version_string);

    /* get screensize */
    getmaxyx(stdscr, max_height, max_width);

    width  = 72;
    height = max_height - 8;
    startx = (max_width - width) / 2;
    starty = 4;

    vrmr_list_setup(debuglvl, &about_list, free_helpword);

    (void)read_helpline(debuglvl, &about_list, "Vuurmuur_conf\n");
    (void)read_helpline(debuglvl, &about_list, "\n");
    (void)read_helpline(debuglvl, &about_list, "=============\n");
    (void)read_helpline(debuglvl, &about_list, "\n");
    (void)read_helpline(debuglvl, &about_list, about_version_string);
    (void)read_helpline(debuglvl, &about_list, "\n");
    (void)read_helpline(debuglvl, &about_list, "\n");
    (void)read_helpline(debuglvl, &about_list, "Copyright 2003-2007 (c) Victor Julien <victor(at)vuurmuur(dot)org>.\n");
    (void)read_helpline(debuglvl, &about_list, "This program is distributed under the terms of the GPL.\n");
    (void)read_helpline(debuglvl, &about_list, "\n");

    (void)read_helpline(debuglvl, &about_list, "Support\n");
    (void)read_helpline(debuglvl, &about_list, "\n");
    (void)read_helpline(debuglvl, &about_list, "=======\n");
    (void)read_helpline(debuglvl, &about_list, "\n");
    (void)read_helpline(debuglvl, &about_list, "\n");
    (void)read_helpline(debuglvl, &about_list, "Website: http://www.vuurmuur.org/\n");
    (void)read_helpline(debuglvl, &about_list, "\n");
    (void)read_helpline(debuglvl, &about_list, "Mailinglist: http://sourceforge.net/mail/?group_id=114382\n");
    (void)read_helpline(debuglvl, &about_list, "\n");
    (void)read_helpline(debuglvl, &about_list, "Forum: http://sourceforge.net/forum/?group_id=114382\n");
    (void)read_helpline(debuglvl, &about_list, "\n");
    (void)read_helpline(debuglvl, &about_list, "IRC: irc://irc.freenode.net/vuurmuur\n");
    (void)read_helpline(debuglvl, &about_list, "\n");

    (void)read_helpline(debuglvl, &about_list, "\n");
    (void)read_helpline(debuglvl, &about_list, "Thanks to\n");
    (void)read_helpline(debuglvl, &about_list, "\n");
    (void)read_helpline(debuglvl, &about_list, "=========\n");
    (void)read_helpline(debuglvl, &about_list, "\n");
    (void)read_helpline(debuglvl, &about_list, "\n");
    (void)read_helpline(debuglvl, &about_list, "Philippe Baumgart (documentation).\n");
    (void)read_helpline(debuglvl, &about_list, "Michiel Bodewes (website development).\n");
    (void)read_helpline(debuglvl, &about_list, "Nicolas Dejardin <zephura(at)free(dot)fr> (French translation).\n");
    (void)read_helpline(debuglvl, &about_list, "Adi Kriegisch (coding, documentation, Debian packages).\n");
    (void)read_helpline(debuglvl, &about_list, "Sebastian Marten (documentation).\n");
    (void)read_helpline(debuglvl, &about_list, "Holger Ohmacht (German translation).\n");
    (void)read_helpline(debuglvl, &about_list, "Hugo Ribeiro (Brazilian Portuguese translation).\n");
    (void)read_helpline(debuglvl, &about_list, "Aleksandr Shubnik <alshu(at)tut(dot)by> (rpm development, Russian translation).\n");
    (void)read_helpline(debuglvl, &about_list, "Per Olav Siggerud (Norwegian translation).\n");
    (void)read_helpline(debuglvl, &about_list, "Alexandre Simon (coding).\n");
    (void)read_helpline(debuglvl, &about_list, "Stefan Ubbink (Gentoo ebuilds, coding).\n");
    (void)read_helpline(debuglvl, &about_list, "Rob de Wit (wiki hosting).\n");
    (void)read_helpline(debuglvl, &about_list, "\n");
    (void)read_helpline(debuglvl, &about_list, "See: http://www.vuurmuur.org/trac/wiki/Credits for the latest information.\n");
    (void)read_helpline(debuglvl, &about_list, "\n");

    set_lines(debuglvl, &about_list, (size_t)(width - 4));

    draw_top_menu(debuglvl, top_win, gettext("About"), key_choices_n, key_choices, cmd_choices_n, cmd_choices);
    /* print the status list */
    print_list(debuglvl, &about_list, gettext("About"), height, width, starty, startx, UTF8_FALSE);

    vrmr_list_cleanup(debuglvl, &about_list);
}
开发者ID:ewf75,项目名称:vuurmuur,代码行数:86,代码来源:help.c

示例2: print_pkg

static int print_pkg(alpm_pkg_t *pkg, const char *format) {
  const char *f, *end;
  char fmt[64], buf[64];
  int len, out = 0;

  end = format + strlen(format);

  for (f = format; f < end; f++) {
    len = 0;
    if (*f == '%') {
      len = strspn(f + 1 + len, printf_flags);
      len += strspn(f + 1 + len, digits);
      snprintf(fmt, len + 3, "%ss", f);
      fmt[len + 1] = 's';
      f += len + 1;
      switch (*f) {
        /* simple attributes */
        case 'f': /* filename */
          out += printf(fmt, alpm_pkg_get_filename(pkg));
          break;
        case 'n': /* package name */
          out += printf(fmt, alpm_pkg_get_name(pkg));
          break;
        case 'v': /* version */
          out += printf(fmt, alpm_pkg_get_version(pkg));
          break;
        case 'd': /* description */
          out += printf(fmt, alpm_pkg_get_desc(pkg));
          break;
        case 'u': /* project url */
          out += printf(fmt, alpm_pkg_get_url(pkg));
          break;
        case 'p': /* packager name */
          out += printf(fmt, alpm_pkg_get_packager(pkg));
          break;
        case 's': /* md5sum */
          out += printf(fmt, alpm_pkg_get_md5sum(pkg));
          break;
        case 'a': /* architecutre */
          out += printf(fmt, alpm_pkg_get_arch(pkg));
          break;
        case 'i': /* has install scriptlet? */
          out += printf(fmt, alpm_pkg_has_scriptlet(pkg) ? "yes" : "no");
          break;
        case 'r': /* repo */
          out += printf(fmt, alpm_db_get_name(alpm_pkg_get_db(pkg)));
          break;
        case 'w': /* install reason */
          out += printf(fmt, alpm_pkg_get_reason(pkg) ? "dependency" : "explicit");
          break;
        case '!': /* result number */
          snprintf(buf, sizeof(buf), "%d", opt_pkgcounter++);
          out += printf(fmt, buf);
          break;
        case 'g': /* base64 gpg sig */
          out += printf(fmt, alpm_pkg_get_base64_sig(pkg));
          break;
        case 'h': /* sha256sum */
          out += printf(fmt, alpm_pkg_get_sha256sum(pkg));
          break;

        /* times */
        case 'b': /* build date */
          out += print_time(alpm_pkg_get_builddate(pkg));
          break;
        case 'l': /* install date */
          out += print_time(alpm_pkg_get_installdate(pkg));
          break;

        /* sizes */
        case 'k': /* download size */
          out += printf(fmt, size_to_string(alpm_pkg_get_size(pkg)));
          break;
        case 'm': /* install size */
          out += printf(fmt, size_to_string(alpm_pkg_get_isize(pkg)));
          break;

        /* lists */
        case 'F': /* files */
          out += print_filelist(alpm_pkg_get_files(pkg));
          break;
        case 'N': /* requiredby */
          out += print_list(alpm_pkg_compute_requiredby(pkg), NULL);
          break;
        case 'L': /* licenses */
          out += print_list(alpm_pkg_get_licenses(pkg), NULL);
          break;
        case 'G': /* groups */
          out += print_list(alpm_pkg_get_groups(pkg), NULL);
          break;
        case 'E': /* depends (shortdeps) */
          out += print_list(alpm_pkg_get_depends(pkg), (extractfn)alpm_dep_get_name);
          break;
        case 'D': /* depends */
          out += print_list(alpm_pkg_get_depends(pkg), (extractfn)alpm_dep_compute_string);
          break;
        case 'O': /* optdepends */
          out += print_list(alpm_pkg_get_optdepends(pkg), (extractfn)format_optdep);
          break;
        case 'o': /* optdepends (shortdeps) */
//.........这里部分代码省略.........
开发者ID:Acidburn0zzz,项目名称:expac,代码行数:101,代码来源:expac.c

示例3: print_list

/* Print list to file by applying print to each node that is not NULL */
void print_list(void (*print)(FILE *f, void *data), FILE *f, List list) {
    if (list) {
        print(f, list->data);
        print_list(print, f, list->next);
    }
}
开发者ID:ShreyashPatodia,项目名称:MyC,代码行数:7,代码来源:list.c

示例4: print_list

static void print_list(const SList *list, char *buf, s_erc *error)
{
	SIterator *itr;
	size_t list_size;


	S_CLR_ERR(error);

	list_size = SListSize(list, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "print_list",
				  "Call to \"list_size\" failed"))
		return;

	s_strcat(buf, "[", error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "print_list",
				  "Call to \"s_strcat\" failed"))
		return;

	itr = S_ITERATOR_GET(list, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "print_list",
				  "Call to \"S_ITERATOR_GET\" failed"))
		return;

	for (/* NOP */; itr != NULL; itr = SIteratorNext(itr), --list_size)
	{
		s_bool type_ok;
		const SObject *tmp;


		tmp = SIteratorObject(itr, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "print_list",
					  "Call to \"SIteratorObject\" failed"))
		{
			S_DELETE(itr, "print_list", error);
			return;
		}

		type_ok = SObjectIsType(tmp, "SList", error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "print_word",
					  "Call to \"SObjectIsType\" failed"))
		{
			S_DELETE(itr, "print_list", error);
			return;
		}

		if (type_ok)
		{
			print_list(S_LIST(tmp), buf, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "print_list",
						  "Call to \"print_list\" failed"))
			{
				S_DELETE(itr, "print_list", error);
				return;
			}
		}
		else
		{
			type_ok = SObjectIsType(tmp, "SString", error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "print_list",
						  "Call to \"SObjectIsType\" failed"))
			{
				S_DELETE(itr, "print_list", error);
				return;
			}

			if (type_ok)
			{
				const char *string = SObjectGetString(S_OBJECT(tmp), error);

				if (S_CHK_ERR(error, S_CONTERR,
							  "print_list",
							  "Call to \"SObjectGetString\" failed"))
				{
					S_DELETE(itr, "print_list", error);
					return;
				}
				s_strcat(buf, string, error);
				if (S_CHK_ERR(error, S_CONTERR,
							  "print_list",
							  "Call to \"s_strcat\" failed"))
				{
					S_DELETE(itr, "print_list", error);
					return;
				}

				if ((list_size-1) != 0)
				{
					s_strcat(buf, " ", error);
					if (S_CHK_ERR(error, S_CONTERR,
								  "print_list",
								  "Call to \"s_strcat\" failed"))
					{
						S_DELETE(itr, "print_list", error);
//.........这里部分代码省略.........
开发者ID:Cyofanni,项目名称:speect,代码行数:101,代码来源:load_addendum.c

示例5: createClientEndpoint

int createClientEndpoint(const char *host, const char *service,EndpointInfo *info)
{
	int sd, result, x=-1;
	struct addrinfo hints, *res =NULL, *tmp=NULL;

	if(host==NULL || service==NULL)
	{
		fprintf(stderr, "host and client can't be NULL\n");
		return -1;
	}

	memset(&hints, 0, sizeof(struct addrinfo));
       
	if(info->type==UDPEndpoint)
		hints.ai_socktype=SOCK_DGRAM;
	else if(info->type==TCPEndpoint)
		hints.ai_socktype=SOCK_STREAM;
	
	result=getaddrinfo(host, service,&hints,&res);
	if (result != 0)
	{
		fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(result));
	        return -1;
       	}
        if (res->ai_addrlen > sizeof(struct sockaddr_storage))/*perritos elegxos*/
        {
        	fprintf(stderr, "sockaddr too large\n");
           	freeaddrinfo(res);
		res = NULL;
           	return -1;
       	}

	info->sd=malloc(10);
	info->sdlen = 0;
	print_list(res);
       	for(tmp=res; tmp; tmp=tmp->ai_next)
       	{	
        	
           	//info->sd[0]
		sd=socket(tmp->ai_family,tmp->ai_socktype,tmp->ai_protocol);
           	printf("socket id %d \n",sd);
           	if(sd==-1)
           	{
               		fprintf(stderr, "socket failed :%d %s\n",errno,strerror(errno));
			continue;
           	}
           	if(info->type==TCPEndpoint)
           	{
                	x=connect(sd,tmp->ai_addr,tmp->ai_addrlen);
                 	if(x<0)
                	{
                    		/*connect didn't make it*/
				close(sd);
				fprintf(stderr, "connect failed :%s\n",strerror(errno));
                    		/*will try to connect to another socket*/
				continue;
			}
			/*connect success*/
			//printf("socket id:%d connected succsfully(connect returned %d) \n",sd,x);
			
		}
		/*connect success*/
		info->sd[info->sdlen] = sd;
		info->sdlen ++;                    
          	break;
       	}

       	if(info->sdlen == 0)
       	{
		freeaddrinfo(res);
	        fprintf(stderr, "Client :: couldn'create Endpoint.\n");
        	return -1;
       	}
       	info->sd  = (int*)malloc(sizeof(int));
		info->sd[0] = sd;
       	info->addr=res;

       return 0;
}
开发者ID:anacha,项目名称:Network-Programming-using-C,代码行数:79,代码来源:createClientEndpoint.c

示例6: file_uncompress


//.........这里部分代码省略.........
#ifndef NO_PACK_SUPPORT
	case FT_PACK:
		if (lflag) {
			maybe_warnx("no -l with packed files");
			goto lose;
		}

		size = unpack(fd, zfd, NULL, 0, NULL);
		break;
#endif

#ifndef NO_XZ_SUPPORT
	case FT_XZ:
		if (lflag) {
			maybe_warnx("no -l with xz files");
			goto lose;
		}

		size = unxz(fd, zfd, NULL, 0, NULL);
		break;
#endif

#ifndef SMALL
	case FT_UNKNOWN:
		if (lflag) {
			maybe_warnx("no -l for unknown filetypes");
			goto lose;
		}
		size = cat_fd(NULL, 0, NULL, fd);
		break;
#endif
	default:
		if (lflag) {
			print_list(fd, isb.st_size, outfile, isb.st_mtime);
			close(fd);
			return -1;	/* XXX */
		}

		size = gz_uncompress(fd, zfd, NULL, 0, NULL, file);
		break;
	}

	if (close(fd) != 0)
		maybe_warn("couldn't close input");
	if (zfd != STDOUT_FILENO && close(zfd) != 0)
		maybe_warn("couldn't close output");

	if (size == -1) {
		if (cflag == 0)
			unlink(outfile);
		maybe_warnx("%s: uncompress failed", file);
		return -1;
	}

	/* if testing, or we uncompressed to stdout, this is all we need */
#ifndef SMALL
	if (tflag)
		return size;
#endif
	/* if we are uncompressing to stdin, don't remove the file. */
	if (cflag)
		return size;

	/*
	 * if we create a file...
	 */
开发者ID:jaredmcneill,项目名称:freebsd,代码行数:67,代码来源:gzip.c

示例7: convert_postfix_expression

/*将中缀表达式转换成后缀表达式 
*@parm: sexpr 中缀表达式
*return: 存储后缀表达式的队列  
**/
List convert_postfix_expression(char *expr)
{
	List queue_exp; //后缀表达式队列,也作为操作数队列 
	List stack_opr;       //运算符栈 
	char temp[25];
	int i;
	char *pstr, *p;
	
	queue_exp = stack_opr = NULL;
	while(*expr != '\0') { //扫描整个中缀表达式 
		//isoperand = FALSE;
		i = 0; 
		
		if(isdigit(*expr) || *expr == '.') { //是操作数(实数) 
			memset(temp, 0, sizeof(temp));
			while(isdigit(*expr) || *expr == '.') {  //考虑操作数是多位的情况 
				temp[i++] = *expr++; 
			}/*while*/
			PNEW(pstr, i);
			strcpy(pstr, temp);
			queue_exp = list_push(queue_exp, pstr); //操作数入队列 
		
		}else { //是运算符 
			PNEW(pstr, OPERATOR_LEN);
			
			switch(*expr) {
				case '(':   //左括号直接压入操作符栈 
					*pstr = '(';
					stack_opr = list_push(stack_opr, pstr);
					break;
					
				case '+':
				case '-':
				case '*':
				case '/': 
					if(list_length(stack_opr)) {//操作符优先级比较 
						//当前运算符,小于栈顶运算符 
						while(priority(*expr) <= priority(*((char *)stack_opr->ptr))) {
							stack_opr = list_pop(stack_opr, &p); //取出优先级高的栈顶运算符
							queue_exp = list_push(queue_exp, p); //入队 
							
							if(list_length(stack_opr) == 0) 
								break; //如果栈顶为空,退出while 
						}/*while*/
					}/*if*/
					
					//当前运算符进栈 
					*pstr = *expr;
					stack_opr = list_push(stack_opr, pstr);
					break;
					
				case ')':
					/*取出运算符栈中左小括号以
					上得全部运算符压入操作符队列中 */
					while(*((char *)stack_opr->ptr) != '(') {
						stack_opr = list_pop(stack_opr, &p);  //出栈 
						queue_exp = list_push(queue_exp, p); //入队 
						
					}/*while*/
					
					stack_opr = list_pop(stack_opr, &p); //丢掉'(' 
					free(p);
					break;
					
				default :
					printf("----------%c\n",*expr);
					assert(!"expression format is error\n");
					break; 
				 
			}/*switch*/ 
			
			expr++;		
		}/*else*/
		#if DEBUG
		print_list(queue_exp, "queue");
		print_list(stack_opr, "stack");
		#endif
	}/*while*/
	
	//将操作符全部压入操作数队列中
	while(list_length(stack_opr)) {
		stack_opr = list_pop(stack_opr, &p);  //出栈 
		queue_exp = list_push(queue_exp, p); //入队
	} 
	#if DEBUG
	print_list(queue_exp, "queue");
	print_list(stack_opr, "stack");
	#endif
		
	return queue_exp;
}
开发者ID:Alberne,项目名称:tinyprograme,代码行数:95,代码来源:expression.c

示例8: main

int main(int argc, char **argv) {
  int choix=0;
  int value=0;

  printf("%s",menu);
  fflush(stdout);

  while(1) {
    fflush(stdin);
    choix = getchar();
    printf("\n");

    switch(choix) {
    case 'T' :
    case 't' :
      printf("Valeur du nouvel element ? ");
      scanf("%d",&value);
      if (insert_head(&la_liste,value)!=0) {
	printf("Erreur : impossible d'ajouter l'element %d\n",value);
      };
      break;

    case 'Q' :
    case 'q' :
      printf("Valeur du nouvel element ? ");
      scanf("%d",&value);
      if (insert_tail(&la_liste,value)!=0) {
		printf("Erreur : impossible d'ajouter l'element %d\n",value);
      };
      break;


    case 'F' :
    case 'f' :
		printf("Index de l'element a rechercher ? ");
		scanf("%d", &value);
		list_elem_t* result = find_element(la_liste, value);
		if(result != NULL)
			printf("La valeur de l'element numero %d est %d\n", value, result->value);
		else
			printf("Erreur, l'element numero %d n'existe pas\n", value);
      break;



    case 's' :
    case 'S' :
      printf("Valeur de l'element a supprimer ? ");
	  scanf("%d", &value);
	  if(remove_element(&la_liste, value) != 0)
		printf("Erreur, aucun element ne possede la valeur %d\n", value);
	  else
		printf("L'element de valeur %d a ete supprime avec succes\n", value);	
      break;


    case 'r' :
    case 'R' :
      printf("Renversement des elements de la liste.\n");
	  reverse_list(&la_liste);
      break;


    case 'x' :
    case 'X' :
      return 0;

    default:
      break;
    }
    print_list(la_liste);

    if (nb_malloc!=list_size(la_liste)) {
	printf("\nAttention : il y a une fuite memoire dans votre programme !\n");
	printf("la liste contient %d element, or il y a %d element vivant en memoire !\n",list_size(la_liste),nb_malloc);
    }
    getchar(); // pour consommer un RC et eviter un double affichage du menu !
    printf("%s\n",menu);
  }
  return 0;
}
开发者ID:hlabanca,项目名称:L3info,代码行数:81,代码来源:test_list.c

示例9: main

int main (void) {
    struct node* head = add_node(33);
    print_list(head);
    return 0;
}
开发者ID:nmrnmr,项目名称:Test,代码行数:5,代码来源:linked_list.c

示例10: caculate

float caculate(List queue_postfix)
{
	List stack_sum;  //栈,存储操作数 
	float f1, f2; //二元运算符两边的操作数 
	char *p, *psum;
	
	psum = p = NULL;
	stack_sum = NULL;
	f1 = f2 = 0;
	
	#if DEBUG
	print_list(queue_postfix, "postfix_queue");
	#endif
	
	//逆置队列后可以使用pop()方法取队尾元素 
	queue_postfix = list_reverse(queue_postfix); 
	
	#if DEBUG
	print_list(queue_postfix, "postfix_queue");
	#endif
	
	//循环遍历队列元素 
	while(list_length(queue_postfix)) {
		queue_postfix = list_pop(queue_postfix, &p); //取出队尾元素
		
		if((isdigit(*p)) || (*p == '.')) { //操作数 
			stack_sum = list_push(stack_sum, p);  //压栈 
		}else { //运算符 
			stack_sum = list_pop(stack_sum, &psum);
			f2 = atof(psum);  //参与运算的第二个操作数 
			free(psum);
			psum = NULL;
			stack_sum = list_pop(stack_sum, &psum);
			f1 = atof(psum);  //参与运算的第一个操作数
			free(psum);
			psum = NULL;
			
			switch(*p) {
				case '+':
					f1 += f2;
					break;
					
				case '-':
					f1 -= f2;
					break;
					  
				case '*':
					f1 *= f2;
					break;
					
				case '/':
					if(f2 == 0)
						assert(!"div by zero error\n");  //除0错误 
					
					f1 /= f2; 
					break;
				
				default:
					assert(!"expression fromat erorr\n");
					break;						
			}/*switch*/ 
			 PNEW(psum, OPERAND_LEN);
			 sprintf(psum, "%f", f1);
			 stack_sum = list_push(stack_sum, psum); //将计算结果压栈 
		}/*else*/ 
					 
	}/*while*/
	stack_sum = list_pop(stack_sum, &psum); //将最后的计算结果出栈
	return atof(psum);

} 
开发者ID:Alberne,项目名称:tinyprograme,代码行数:71,代码来源:expression.c

示例11: handle_sigwinch

static void		handle_sigwinch(void)
{
	signal(SIGWINCH, SIG_IGN);
	print_list();
	signal(SIGWINCH, &signal_handler);
}
开发者ID:ale-batt,项目名称:ft_select,代码行数:6,代码来源:signal_handler.c

示例12: print_key2

void print_key2(redis_instance* inst, char* key, size_t len)
{
    long long size = 0;
    int flag = get_key_type(inst, key, len);
    long long pttl = get_key_pttl(inst, key, len);
    printf("{key:%s, type:%s, pttl:%lldms, db:%lu,",
            key, type_name[flag], pttl, inst->db);
    switch (flag) {
        case KSTRING: {
            redisReply* kv = (redisReply*)redisCommand(inst->cxt, "get %b", key, len);
            assert(kv != nil);
            assert(kv->type == REDIS_REPLY_STRING);
            assert(kv->len != 0);
            pline(" value:%s}", kv->str);
            freeReplyObject(kv);
        }
        break;

        case KHASH: {
            size = get_hashtable_size(inst, key, len);
            printf(" size:%lld", size);
            if (size) {
                printf(",\n  kvs:[");
                print_hashtable2(inst, key, len);
                pline("\b \n  ]");
            }
            pline("}");
        }
        break;

        case KLIST: {
            size = get_list_size(inst, key, len);
            printf(" size:%lld", size);
            if (size) {
                printf(",\n  values:[");
                print_list(inst, key, len);
                pline("\b \n  ]");
            }
            pline("}");
        }
        break;

        case KSET: {
            size = get_set_size(inst, key, len);
            printf(" size:%lld", size);
            if (size) {
                printf(",\n  values:[");
                print_set2(inst, key, len);
                pline("\b \n  ]");
            }
            pline("}");
        }
        break;

        case KSSET: {
            size = get_sset_size(inst, key, len);
            printf(" size:%lld", size);
            if (size) {
                printf(",\n  values:[");
                print_sset2(inst, key, len);
                pline("\b \n  ]");
            }
            pline("}");
        }
        break;

        case KNONE: {
            FATAL("none type of key:%s", key);
        }
        break;

        case KUNKOWN: {
            FATAL("unknown type of key:%s", key);
        }
    }
}
开发者ID:bugou,项目名称:test,代码行数:76,代码来源:tool.c

示例13: print_stats

/**
 * int print_stats()
 *
 * Function to print results after algo is ran
 */
int print_stats(Algorithm algo)
{
        print_summary(algo);
        print_list(algo.data->page_table.lh_first, "Frame #", "Page Ref");
        return 0;
}
开发者ID:selbyk,项目名称:pagesim,代码行数:11,代码来源:pagesim.c

示例14: MPI_Irecv

int MPI_Irecv(void *buf, int count, MPI_Datatype datatype,
	      int source, int tag, MPI_Comm comm, MPI_Request *request)

{
  pListitem match;
  Comm *mycomm;
  Req *rreq, *sreq;

  mycomm=mpi_handle_to_ptr(comm);         /* mycomm=(Comm *)comm; */

#ifdef INFO
  fflush(stdout);
  fprintf(stderr,"MPI_Irecv: Comm=%d  tag=%d  count=%d type=%d\n",
	 mycomm->num,tag,count,datatype);
#endif


  if (source!=0 && source!=MPI_ANY_SOURCE && source!=MPI_PROC_NULL)
    {
      fprintf(stderr,"MPI_Irecv: bad source %d\n",source);
      abort();
    }

  mpi_alloc_handle(request,(void **)&rreq);

  if (source==MPI_PROC_NULL)
    {
      rreq->complete=1;
      rreq->source=MPI_PROC_NULL;
      rreq->tag=MPI_ANY_TAG;

      return(MPI_SUCCESS);
    }


  if ( match=AP_list_search_func(mycomm->sendlist,mpi_match_send,&tag) )
    {
      sreq=(Req *)AP_listitem_data(match);
      AP_list_delete_item(mycomm->sendlist,match);

      memcpy(buf,sreq->buf,count * datatype);
      rreq->complete=1;
      rreq->source=0;
      rreq->tag=sreq->tag;                   /* in case tag was MPI_ANY_TAG */

      sreq->complete=1;

#ifdef DEBUG
      printf("Completion(recv) value=%d tag=%d\n",
	     *((int *)buf),rreq->tag);
#endif

      return(MPI_SUCCESS);
    }

  rreq->buf=buf;
  rreq->tag=tag;
  rreq->complete=0;
  rreq->listitem=AP_list_append(mycomm->recvlist,rreq);

#ifdef INFO
  print_list(mycomm->recvlist,"recvlist for comm ",mycomm->num);
#endif

  return(MPI_SUCCESS);
}
开发者ID:beaucronin,项目名称:cesm-1_2_2,代码行数:66,代码来源:recv.c

示例15: gaa_try

static int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
{
    int OK = 0;
    int gaa_last_non_option;
	struct GAAOPTION_priority GAATMP_priority;
	struct GAAOPTION_ctypes GAATMP_ctypes;
	struct GAAOPTION_kx GAATMP_kx;
	struct GAAOPTION_macs GAATMP_macs;
	struct GAAOPTION_comp GAATMP_comp;
	struct GAAOPTION_protocols GAATMP_protocols;
	struct GAAOPTION_ciphers GAATMP_ciphers;
	struct GAAOPTION_opaque_prf_input GAATMP_opaque_prf_input;
	struct GAAOPTION_srppasswdconf GAATMP_srppasswdconf;
	struct GAAOPTION_srppasswd GAATMP_srppasswd;
	struct GAAOPTION_pskhint GAATMP_pskhint;
	struct GAAOPTION_pskpasswd GAATMP_pskpasswd;
	struct GAAOPTION_x509dsacertfile GAATMP_x509dsacertfile;
	struct GAAOPTION_x509dsakeyfile GAATMP_x509dsakeyfile;
	struct GAAOPTION_x509certfile GAATMP_x509certfile;
	struct GAAOPTION_x509keyfile GAATMP_x509keyfile;
	struct GAAOPTION_pgpsubkey GAATMP_pgpsubkey;
	struct GAAOPTION_pgpcertfile GAATMP_pgpcertfile;
	struct GAAOPTION_pgpkeyfile GAATMP_pgpkeyfile;
	struct GAAOPTION_pgpkeyring GAATMP_pgpkeyring;
	struct GAAOPTION_x509crlfile GAATMP_x509crlfile;
	struct GAAOPTION_x509cafile GAATMP_x509cafile;
	struct GAAOPTION_dhparams GAATMP_dhparams;
	struct GAAOPTION_port GAATMP_port;
	struct GAAOPTION_debug GAATMP_debug;

#line 393 "gaa.skel"
#ifdef GAA_REST_EXISTS
    struct GAAREST GAAREST_tmp;
#endif

    opt_list[gaa_num] = 1;
    
    for(gaa_last_non_option = gaa_index;
        (gaa_last_non_option != GAAargc) && (gaa_is_an_argument(GAAargv[gaa_last_non_option]) == GAA_NOT_AN_OPTION);
        gaa_last_non_option++);

    if(gaa_num == GAA_REST)
    {
        gaa_index = 1;
        gaa_last_non_option = GAAargc;
    }
    
    switch(gaa_num)
    {
	case GAAOPTID_version:
	OK = 0;
#line 121 "serv.gaa"
{ serv_version(); exit(0); ;};

		return GAA_OK;
		break;
	case GAAOPTID_help:
	OK = 0;
#line 119 "serv.gaa"
{ gaa_help(); exit(0); ;};

		return GAA_OK;
		break;
	case GAAOPTID_list:
	OK = 0;
#line 118 "serv.gaa"
{ print_list(0); exit(0); ;};

		return GAA_OK;
		break;
	case GAAOPTID_priority:
	OK = 0;
		GAA_TESTMOREARGS;
		GAA_FILL(GAATMP_priority.arg1, gaa_getstr, GAATMP_priority.size1);
		gaa_index++;
#line 116 "serv.gaa"
{ gaaval->priorities = GAATMP_priority.arg1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_ctypes:
	OK = 0;
		GAA_LIST_FILL(GAATMP_ctypes.arg1, gaa_getstr, char*, GAATMP_ctypes.size1);
#line 113 "serv.gaa"
{ gaaval->ctype = GAATMP_ctypes.arg1; gaaval->nctype = GAATMP_ctypes.size1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_kx:
	OK = 0;
		GAA_LIST_FILL(GAATMP_kx.arg1, gaa_getstr, char*, GAATMP_kx.size1);
#line 109 "serv.gaa"
{ gaaval->kx = GAATMP_kx.arg1; gaaval->nkx = GAATMP_kx.size1 ;};

		return GAA_OK;
		break;
	case GAAOPTID_macs:
	OK = 0;
		GAA_LIST_FILL(GAATMP_macs.arg1, gaa_getstr, char*, GAATMP_macs.size1);
#line 105 "serv.gaa"
//.........这里部分代码省略.........
开发者ID:sqs,项目名称:gnutls,代码行数:101,代码来源:serv-gaa.c


注:本文中的print_list函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。