Example #1
0
/*
 * Output a key, properly formatted.
 */
void
print_key(FILE *fp, char *algname, char *key, int start, int length)
{
    int i, k;

    print_space(fp, start);
    fprintf(fp, "\"%s", algname);

    for (i = 0, k = strlen(algname) + 2; i < strlen(key); i++, k++)
    {
	if (k == length)
	{
	    if (i == strlen(key))
	    {
		fprintf(fp, "\"\n");
		return;
	    }

	    fprintf(fp, "\\\n");
	    print_space(fp, start);
	    i--;
	    k = 0;
	}
	else
	  fprintf(fp, "%c", key[i]);
    }

    fprintf(fp, "\"\n");
}
Example #2
0
/*
 * Parcours g en profondeur a partir du sommet depart (si il existe),
 * necessite un tableau done initialise a 0 de la taille du graphe, et
 * un entier space pour le decalage des printfs.
 */
void		parcours_prof(t_graphe		*g,
			      int		depart,
			      int		*done,
			      int		space)
{
  t_adj_list	*adj;
  int		i;
  
  if (depart == -1)
    adj = g->adj_list;
  else
    adj = find_sommet(g, depart);
  if (!adj)
    return;
  print_space(space);
  printf("* On part du sommet: %d\n", adj->numero_sommet);

  done[adj->numero_sommet] = 1;
  
  for (i = 0; i < adj->nb_sommet_adjacent; i++)
    {
      print_space(space);
      if (!done[adj->adjacents[i]])
	{
	  printf("--Adjacent disponible: %d -> Exploration\n\n",
		 adj->adjacents[i]);
	  parcours_prof(g, adj->adjacents[i], done, space + 4);
	}
      else
	printf("--Adjacent disponible: %d -> Deja fait\n", adj->adjacents[i]);
    }

  print_space(space);
  printf("* On quitte le sommet: %d\n\n", adj->numero_sommet);
}
Example #3
0
File: print.cpp Project: csll/llvm
void
print_binary(Printer& p, char const* instr, T const* t)
{
  print_result(p, t);
  print(p, instr);
  print_space(p);
  print(p, t->type());
  print_space(p);
  print(p, t->arg1());
  print_space(p);
  print(p, t->arg2());
}
Example #4
0
File: print.cpp Project: csll/llvm
static void
print_function(Printer& p, T const* d, char const* kind)
{
  print(p, kind);
  print_space(p);
  print(p, d->return_type());
  print_space(p);
  print(p, "@{}", d->name());
  print(p, '(');
  print_list(p, d->parameters());
  print(p, ')');
}
Example #5
0
File: cmd.c Project: IVaN4B/sed
int run_script(const char script[], int fd, unsigned int flags){
	scmd_t *cmd_list = NULL;
	int result = parse_script(script, &cmd_list, flags);
	if( result != 0 ){
		return result;
	}
	sspace_t pspace, hspace;
	memset(&pspace, 0, sizeof(sspace_t));
	memset(&hspace, 0, sizeof(sspace_t));
	enum cmd_result code = RNONE;
	int line = 1, nflag = flags & NFLAG;
	TRY_REALLOC(outbuff, MIN_CHUNK);
	TRY_REALLOC(sub_buff, MIN_CHUNK);
	outbuff[0] = '\0';
	sub_buff[0] = '\0';
	while( (result = s_getline(&pspace, fd) > 0 ) ){
		if( code != RNONE ){
			result = print_space(&pspace);
			if( result < 0 ){
				goto exit;
			}
			switch(code){
				case RQUIT:
					return SUCCESS;
				default:
					if( code < 0 ){
						result = code;
						goto exit;
					}
				break;
			}
		}
		pspace.is_deleted = nflag;
		code = run_line(cmd_list, &pspace, &hspace, line, flags);
		line++;
	}
	result = print_space(&pspace);
exit:
	/* TODO: clean */
	scmd_list_free(cmd_list);
	free(outbuff);
	free(sub_buff);
	if( pspace.space != NULL ){
		free(pspace.space);
	}
	if( pspace.text != NULL ){
		free(pspace.text);
	}
	return result;
}
Example #6
0
int freq_display(void)
{

    extern float freq;
    extern int trxmode;

    int x_position = 40;
    int y_position = 17;
    int location = 0;
    char fbuffer[8];

    print_space(y_position, x_position);
    print_space(y_position + 1, x_position);
    print_space(y_position + 2, x_position);
    print_space(y_position + 3, x_position);
    print_space(y_position + 4, x_position);
    nicebox(16, 39, 5, 35, "TRX");
    print_dot(y_position + 4, 28 + x_position + 1);

    sprintf(fbuffer, "%7.1f", freq);

    location = 32;

    if (fbuffer[0] != ' ')
	print_big_number(fbuffer[0] - 48, y_position, x_position, 4);
    if (fbuffer[1] != ' ')
	print_big_number(fbuffer[1] - 48, y_position, x_position, 9);
    if (fbuffer[2] != ' ')
	print_big_number(fbuffer[2] - 48, y_position, x_position, 14);
    if (fbuffer[3] != ' ')
	print_big_number(fbuffer[3] - 48, y_position, x_position, 19);
    if (fbuffer[4] != ' ')
	print_big_number(fbuffer[4] - 48, y_position, x_position, 24);
    if (fbuffer[6] != ' ')
	print_big_number(fbuffer[6] - 48, y_position, x_position, 31);

    attron(COLOR_PAIR(C_HEADER) | A_STANDOUT);

    if (trxmode == CWMODE)
	mvprintw(18, 41, "CW");
    else if (trxmode == SSBMODE)
	mvprintw(19, 41, "SSB");
    else
	mvprintw(19, 41, "DIG");

    refreshp();

    return (0);
}
Example #7
0
File: print.cpp Project: csll/llvm
static void
print_variable(Printer& p, T const* d, char const* kind)
{
  print(p, "@{}", d->name());
  print(p, " = ");
  if (d->linkage() != unspecified_linkage) {
    print(p, get_spelling(d->linkage()));
    print_space(p);
  }
  print(p, kind);
  print_space(p);
  print(p, d->type());
  print_space(p);
  print(p, d->initializer());
}
Example #8
0
File: print.cpp Project: csll/llvm
void
print(Printer& p, Parameter_decl const* d)
{
  print(p, d->type());
  print_space(p);
  print(p, d->name());
}
Example #9
0
	void print_t(ostream &os,const CQCircuit &circuit)
	{
		auto print_circuit_row{[&](ostream &os,const size_t i){
			print_IQBit_or_space(os,circuit[0][i]);
			for(size_t j{1};j!=circuit.size();++j)
			{
				print_row(os);
				print_IQBit_or_space(os,circuit[j][i]);
			}
			os<<endl;
		}};
		if(circuit.size())
		{
			print_circuit_row(os,0);
			for(size_t i{1};i!=circuit.gate_size();++i)
			{
				print_column(os);
				for(size_t j{1};j!=circuit.size();++j)
				{
					print_space(os);
					print_column(os);
				}
				os<<endl;
				print_circuit_row(os,i);
			}
		}
	}
Example #10
0
File: print.cpp Project: csll/llvm
void 
print(Printer& p, Address_expr const* e)
{
  print(p, e->decl()->type());
  print_space(p);
  print(p, e->decl()->name());
}
Example #11
0
File: print.cpp Project: csll/llvm
void 
print(Printer& p, Float_expr const* e)
{
  print(p, e->type());
  print_space(p);
  print(p, e->value());
}
Example #12
0
/* debug-print the cloud box, and if we think it is a neighbor
 * (i.e., if we can directly see 802.11 beacons from it) print out
 * the signal strength to it.
 */
void cloud_box_print(ddprintf_t *fn, FILE *f, cloud_box_t *cloud_box, int indent)
{
    int i;
    char found = 0;

    print_space(fn, f, indent);
    fn(f, "one true name (wifi interface):  ");
    mac_dprint_no_eoln(fn, f, cloud_box->name);

    for (i = 0; i < nbr_device_list_count; i++) {
        if (mac_equal(cloud_box->name, nbr_device_list[i].name)) {
            found = 1;
            break;
        }
    }
    if (found) {
        fn(f, "; strength %d", nbr_device_list[i].signal_strength);
    } else {
        fn(f, "; (no signal strength)");
    }
    if (cloud_box->has_eth_mac_addr) {
        fn(f, "; eth address ");
        mac_dprint_no_eoln(fn, f, cloud_box->eth_mac_addr);
    }

    fn(f, "\n");
}
Example #13
0
int m_print_tree(ComputationNode * node, int depth, bool last) {
  int numArgs = node->numArgs;
  bool hasChildren = (bool) numArgs;

  print_space(depth, last );
  const char * color = node->valid ? GREEN : RED;
  color_printf(color, "%s ", node->name);
  printf("[%d]\n", node->value);

  if (!last) {
    printf("  ");
    print_pipes(depth + hasChildren);
    printf("\n");
  } else {
    printf("  ");
    print_pipes(depth - 1);
    printf("\n");
  }

  for (int i = 0; i < numArgs; i++){
    printf("  ");
    m_print_tree(node->args[i], depth + 1, i == numArgs - 1);
  }

}
Example #14
0
    // class Node
    // @Override
    virtual void debug_print(int indent) override {
        print_space(indent);

        get_modifier_set()->debug_print(0);
        get_type()->debug_print(0);
        printf(" %s;\n", get_name()->c_str());
    }
Example #15
0
void print(int depth, node<P> &top_node)
{
	print_space(depth);
	print(top_node.p);
	if ( top_node.num_children > 0 )
	{
		print_space(depth);
		printf("scale = %i\n",top_node.scale);
		print_space(depth);
		printf("max_dist = %f\n",top_node.max_dist);
		print_space(depth);
		printf("num children = %i\n",top_node.num_children);
		for (int i = 0; i < top_node.num_children;i++)
			print(depth+1, top_node.children[i]);
	}
}
Example #16
0
File: print.cpp Project: csll/llvm
void 
print(Printer& p, Return_instr const* i)
{
  print(p, "ret ");
  print(p, i->type());
  print_space(p);
  if (!is_void_type(i->type()))
    print(p, i->value());
}
Example #17
0
File: print.cpp Project: csll/llvm
void
print(Printer& p, Define_decl const* d)
{
  print_function(p, d, "define");
  print_space(p);
  print(p, '{');
  print_nested(p, d->blocks());
  print(p, '}');
}
Example #18
0
File: tree.c Project: bluke/relex
void tree_show(Tree t, int p)
{
	if(isfinal(t))
	{
		short_show(t);
	}
	else if(!empty(t))
	{
		print_space(p);
		short_show(t);
		print_space(p);
		printf("|- ");
		tree_show(left(t),p+2);
        	print_space(p);
		printf("|- ");
		tree_show(right(t),p+2);
	}
	else if(empty(t))
		printf("(Vide)");
}
Example #19
0
void print_matrix(FILE *f, arith_vartable_t *vtbl, matrix_t *matrix) {
  uint32_t i, n;

  n = matrix->nrows;
  for (i=0; i<n; i++) {
    fprintf(f, "  row[%"PRIu32"]:   ", i);
    print_space(f, i, n);
    print_row(f, vtbl, matrix->row[i]);
    fputc('\n', f);
  }
  fputc('\n', f);
}
void main()
{
	int a = 6, b = 2;
	print(a);
	print_space();
	println(b);

	add(a, b);
	sub(a, b);
	multi(a, b);
	div(a, b);
}
Example #21
0
//for debugging
void print_preorder_with_tab(ptr_rbnode node, int depth) {
    if (node == NULL) return;

    print_space(depth);
    printf("%d %s\n",
           node->val,
           node->nil ? "NIL" : (node->color == RED ?
                                "R" : "B")
    );
    if (node->left) print_preorder_with_tab(node->left, depth + 1);
    if (node->right) print_preorder_with_tab(node->right, depth + 1);
}
Example #22
0
template<class _T> static void proc(){
	_T	t;

	while(! RB_IsEof()){
		char *buf = RB_GetCin();
		t.insert(std::string(buf));
		free(buf);
	}

#if 0
	{
		_T::const_iterator first = t.begin();
		_T::const_iterator last  = t.end();
		_T::const_iterator nil_node = t.end();

		for(; first!=last ; ++first){
			print_space(node_depth(first,nil_node));
			printf("[%s]%s\n", first._Ptr->_Color==set_string_type::_Black?"B":"R", first._Ptr->_Myval.c_str());
		}
	}
#else
	{
		//rb-treeの「left-mostを最下段」「right-mostを最上段」にするため reverse_iterator を使用。
		_T::const_reverse_iterator	first = t.rbegin();
		_T::const_reverse_iterator	last  = t.rend();
		_T::const_iterator			nil_node = t.end();

		for(; first!=last ; ++first){
			//const_reverse_iterator を剥いで中身(const_iterator)を取り出す。
			_T::const_reverse_iterator tmp = first;
			++tmp;
			_T::const_iterator cur = tmp.current;

			print_space(node_depth(cur,nil_node));
			printf("[%s]%s\n", cur._Ptr->_Color==set_string_type::_Black?"B":"R", cur._Ptr->_Myval.c_str());
		}
	}
#endif
	
}
Example #23
0
void print_elim_matrix(FILE *f, arith_vartable_t *vtbl, elim_matrix_t *elim) {
  uint32_t i, n;

  n = elim->nrows;
  for (i=0; i<n; i++) {
    fprintf(f, "  elim[%"PRIu32"]:   ", i);
    print_space(f, i, n);
    print_avar_poly(f, vtbl, elim->row[i]);
    fputs("  (", f);
    print_avar(f, vtbl, elim->base_var[i]);
    fputs(")\n", f);
  }
  fputc('\n', f);
}
Example #24
0
void print_fixed_var_vector(FILE *f, arith_vartable_t *vtbl, fvar_vector_t *fvars) {
  uint32_t i, n;

  n = fvars->nvars;
  for (i=0; i<n; i++) {
    fprintf(f, "  fixed[%"PRIu32"]:   ", i);
    print_space(f, i, n);
    print_avar(f, vtbl, fvars->fvar[i].var);
    fputs(" == ", f);
    q_print(f, &fvars->fvar[i].value);
    fputc('\n', f);
  }
  fputc('\n', f);
}
Example #25
0
void print_sexpr(cell_t * list, int depth, file_io_t * out, file_io_t * err)
{
        char buf[MAX_STR];
        cell_t *tmp;
        if (list == NULL) {
                print_error("print_sexpr was passed a NULL!", err);
                return;
        }

        if (list->type == type_null) {
                print_space(depth + 1, out);
                print_string("Null\n", out);
                return;
        } else if (list->type == type_number) {
                print_space(depth + 1, out);
                sprintf(buf, "%d", list->car.i);
                print_string(buf, out);
                wrap_put(out, '\n');
        } else if (list->type == type_str) {
                print_space(depth + 1, out);
                wrap_put(out, '"');
                print_string(list->car.s, out);
                wrap_put(out, '"');
                wrap_put(out, '\n');
                return;
        } else if (list->type == type_symbol) {
                print_space(depth + 1, out);
                print_string(list->car.s, out);
                wrap_put(out, '\n');
                return;
        } else if (list->type == type_list) {
                if (depth == 0) {
                        print_string("(\n", out);
                }
                for (tmp = list; tmp != NULL; tmp = tmp->cdr.cell) {
                        if (tmp->car.cell != NULL && tmp->type == type_list) {
                                print_space(depth + 1, out);
                                print_string("(\n", out);

                                print_sexpr(tmp->car.cell, depth + 1, out, err);

                                print_space(depth + 1, out);
                                print_string(")\n", out);
                        }

                        if (tmp->type != type_list) {
                                print_sexpr(tmp, depth + 1, out, err);
                        }
                }
                if (depth == 0) {
                        print_string(")\n", out);
                }
        }

        return;
}
Example #26
0
    // @Override
    virtual void debug_print(int indent) override {
        print_space(indent);

        if (is_public())
            printf("public ");
        else if (is_protected())
            printf("protected ");
        else if (is_private())
            printf("private ");

        if (is_static())
            printf("static ");
        if (is_final())
            printf("final ");
    }
Example #27
0
	void print(ostream &os,const CQCircuit &circuit)
	{
		if(circuit.size())
		{
			print(os,circuit[0]);
			for(size_t i{1};i!=circuit.size();++i)
			{
				print_column(os);
				for(size_t j{1};j!=circuit.gate_size();++j)
				{
					print_space(os);
					print_column(os);
				}
				os<<endl;
				print(os,circuit[i]);
			}
		}
	}
void main()
{
	int a = 1;
	int b = 2;

	if (a < b)
		print(a);
	else
		print(b);
	print_newline();

	int i = 0;
	while (i < 8) {
		print(i);
		print_space();
		i = i + 1;
	}
	print_newline();
}
Example #29
0
int main () {
    
    char * level_name = "test2.level";
    cpSpace * space = core_create_space ();
    
    core_load_level ( space, level_name );  
    
    cpFloat timeStep = 1.0/60.0;
    for ( cpFloat time = 0; time < 2; time += timeStep ) {
        
        print_space(space);
        
        cpSpaceStep(space, timeStep);
    }
    
    core_destroy_space(space);
    
    return 0;  
}
Example #30
0
void		print_mprotect(pid_t pid,
			       struct user_regs_struct *regs,
			       size_t return_value)
{
  int		nb;

  nb = 0;
  nb += printf("mprotect(");
  nb += print_void_ptr(pid, get_param(regs, 0));
  nb += printf(", ");
  nb += print_size_t(pid, get_param(regs, 1));
  nb += printf(", ");
  nb += print_prot(get_param(regs, 2));
  nb += printf(")");
  print_space(nb);
  printf("= ");
  print_int(pid, return_value);
  printf("\n");
}