示例#1
0
static void
display_cdinfo(CdIo_t *p_cdio, track_t i_tracks, track_t i_first_track)
{
  int len;
  char line[80];
  
  if (!b_interactive) return;

  if (!b_cd) snprintf(line, sizeof(line), "-");
  else {
    len = snprintf(line, sizeof(line), "%2u tracks  (%02x:%02x min)",
                  (unsigned int) i_last_track,
                  toc[i_last_track+1].m, toc[i_last_track+1].s);
    if (i_data && i_first_track != CDIO_CDROM_LEADOUT_TRACK)
      snprintf(line+len, sizeof(line)-len, ", audio=%u-%u", 
	      (unsigned int) i_first_audio_track,
              (unsigned int) i_last_audio_track);
    
    display_line(LINE_ARTIST, 0, "CD Artist       : %s", artist);
    display_line(LINE_CDNAME, 0, "CD Title        : %s", title);
    display_line(LINE_GENRE,  0, "CD Genre        : %s", genre);
    display_line(LINE_YEAR,   0, "CD Year         : %s", year);
  }
  
  mvprintw(LINE_CDINFO, 0, (char *) "CD info: %0s", line);
  clrtoeol();
  action(NULL);
}
示例#2
0
/*
** Returns the command
*/
char			*get_next_command(const int fd)
{
  char			buffer[10];
  struct termios	backup_st;
  void			(*func_op)();
  int			r;

  cursor(0);
  command_line(malloc(sizeof(*(command_line(NULL))) * 10));
  command_line(NULL)[0] = 0;
  backup_st = get_next_init(retrieve_vars(NULL));
  display_line(retrieve_vars(NULL));
  func_op = NULL;
  while (func_op != key_enter && (r = read(fd, buffer, 9)))
    {
      buffer[r] = 0;
      func_op = get_input_modif(buffer);
      func_op ? func_op() :
	command_line(insert_string(command_line(NULL), buffer));
      display_line(retrieve_vars(NULL));
    }
  set_conf(backup_st, 0);
  signal(SIGWINCH, SIG_DFL);
  signal(SIGTSTP, SIG_DFL);
  my_putchar('\n');
  test_and_add_bindkey(command_line(NULL));
  return (command_line(NULL));
}
示例#3
0
文件: screen.c 项目: hankem/jed
static void update_minibuffer(void)
{
   Window_Type *w;

   if (Executing_Keyboard_Macro) return;

   if (MiniBuffer != NULL)
     {
	w = JWindow;
	while (!IN_MINI_WINDOW) other_window();

	JWindow->beg.line = CLine;
	mark_window_attributes (1);
	display_line(CLine, Jed_Num_Screen_Rows-1, 0);
	while (w != JWindow) other_window();
	Mini_Ghost = 1;
     }
   else if (Mini_Ghost && !*Error_Buffer && !*Message_Buffer)
     {
	/* if < 0, it is a result of flush message so let it pass this round */
	if (Mini_Ghost < 0) Mini_Ghost = 1;
	else Mini_Ghost = 0;
     }
   else Mini_Ghost = ((*Message_Buffer) || (*Error_Buffer));

   if (Mini_Ghost == 0)
     display_line(NULL, Jed_Num_Screen_Rows-1, 0);
}
示例#4
0
int display_v_up(const char *filename, fb_info fb_inf, fb_info fb_xin)
{

    fb_info jpeg_inf;
    fb_info fb_inff = fb_xin;
    int x1 = fb_inf.w/2, y1 = fb_inf.h, x2 = fb_inf.w/2, y2 = fb_inf.h; 
    int x3 = fb_inf.w/2, y3 = fb_inf.h-1, x4 = fb_inf.w/2, y4 = fb_inf.h-1; 

    u8_t *buf24 = decode_jpeg(filename, &jpeg_inf);
    u8_t *scale_buf = scale24(buf24, fb_inff, jpeg_inf);
    u32_t *buf32 = rgb24to32(scale_buf, fb_inff);
    

    while(y1>0) 
    {
            display_line(buf32, fb_inf, x1, y1, x2, y2);

            if(x1 == fb_inf.w-1)
            {
                x1 = fb_inf.w-1;
                y1--;
            }
            else
                x1++;

            if(y2 == 0)
            {
                y2=0;
                x2++;
            }
            else
                y2--;
                
            display_line(buf32, fb_inf, x3, y3, x4, y4);

            if(x3 == 0)
            {
                x3 = 0;
                y3--;
            }
            else
                x3--;

            if(y4 == 0)
            {
                y4=0;
                x4--;
            }
            else
                y4--;
            usleep(2);
            if(*status_p == 0) goto biaoshan2;
    }
    biaoshan2: free(buf24);
    free(scale_buf);
    free(buf32);

    return 0;
}
示例#5
0
void update_display(void) {
  void (*display_handler)(char*,char*) = state_handlers[state].display;
  char line_1[17];
  char line_2[17];
  
  clear_line(line_1);
  clear_line(line_2);
  
  if (display_handler == NULL) return;
  
  display_handler(line_1, line_2);
  display_line(LCD_LINE_1, line_1);
  display_line(LCD_LINE_2, line_2);
}
示例#6
0
// draw the geometry marker in the given Displayable's drawing list
void GeometryBond::create_cmd_list() {
  char valbuf[32];

  // get the transformed positions, and draw a line between them
  float pos1[3], pos2[3];

  reset_disp_list();
  if(!transformed_atom_coord(0, pos1))
    return;
  if(!transformed_atom_coord(1, pos2))
    return;

  append(DMATERIALOFF);
  DispCmdColorIndex cmdColor;
  cmdColor.putdata(my_color, cmdList);

  DispCmdLineType cmdLineType;
  DispCmdLineWidth cmdLineWidth;
  cmdLineType.putdata(DASHEDLINE, cmdList);
  cmdLineWidth.putdata(4, cmdList);

  // print value of distance at midpoint
  midpoint(valuePos, pos1, pos2);
  // left-align the value so that it doesn't appear to shift its position
  // when the label text size changes.  Shift it to the right by a constant
  // amount so that it doesn't intersect the line.
  valuePos[0] += 0.05f;
  sprintf(valbuf, "%-7.2f", geomValue);
  display_string(valbuf, cmdList);

  // draw a line into the given Displayable
  display_line(pos1, pos2, cmdList);
  
}
示例#7
0
int main ()
{

	int g = input();
	
	display_line(g);

	display_body(g);

	display_line(g);

	display_line(g);

	display_body(g);
	
	display_line(g);

	return 0;
}
示例#8
0
void
email_asciifile_tail( FILE* output, const char* file, int lines )
{
	FILE	*input;
	int		ch, last_ch;
	long	loc;
	int		first_line = TRUE;
	TAIL_QUEUE	queue, *q = &queue;

	if( !file ) {
		return;
	}		

	if( (input=safe_fopen_wrapper_follow(file,"r",0644)) == NULL ) {
	    // try the .old file in the off shoot case we hit this during the transition.
	    std::string szTmp = file;
	    szTmp += ".old"; 
	    
	    if( (input=safe_fopen_wrapper_follow(szTmp.c_str(),"r",0644)) == NULL ) {
		dprintf( D_FULLDEBUG, "Failed to email %s: cannot open file\n", file );
		return;
	    }
	}

	init_queue( q, lines );
	last_ch = '\n';

	while( (ch=getc(input)) != EOF ) {
		if( last_ch == '\n' && ch != '\n' ) {
			insert_queue( q, ftell(input) - 1 );
		}
		last_ch = ch;
	}

	while( !empty_queue( q ) ) {
		loc = delete_queue( q );
		/* If this is the first line, print header */
		if ( first_line ) {
			first_line = FALSE;
			fprintf(output,"\n*** Last %d line(s) of file %s:\n",
				lines, file);
		}
		/* Now print the line */
		display_line( loc, input, output );
	}
	(void)fclose( input );

	/* if we printed any of the file, print a footer */
	if ( first_line == FALSE ) {
		fprintf(output,"*** End of file %s\n\n", condor_basename(file));
	}
}
示例#9
0
int	swap_previous_characters(t_input *input)
{
	char	tmp;

	if (input->cursor_pos > 1)
	{
		tmp = input->buffer[input->cursor_pos - 1];
		input->buffer[input->cursor_pos - 1] =
					input->buffer[input->cursor_pos - 2];
		input->buffer[input->cursor_pos - 2] = tmp;
	}
	display_line(input, input->cursor_pos);
	return (0);
}
示例#10
0
void    my_display(char **grid)
{
  int   i;

  i = 0;
  my_printf("\n |A B C D E F G H\n");
  my_printf("-+---------------\n");
  while (i < 8)
    {
      my_printf("%d|", i + 1);
      display_line(i, grid);
      my_printf("\n");
      i++;
    }
}
示例#11
0
void		display(t_square *square, t_grid *grid, t_coord **begin)
{
    t_coord xy;
    t_coord *mine;

    mine = *begin;
    xy.y = 0;
    xy.x = 0;
    while (xy.y < grid->y)
    {
        xy.x = 0;
        mine = display_line(&xy, mine, square, grid);
        write(1, "\n", 1);
        xy.y++;
    }
}
示例#12
0
// Demo lines to make a moving Qix thing
void demo_lines() {
    int const num = 8;
    int x0s[num], y0s[num], x1s[num], y1s[num];
    int dx0 = -2, dx1 = 3, dy0 = 3, dy1 = 2;

    // init
    for (int t = 0; t < num; t++) {
        x0s[t] = 33;
        x1s[t] = 58;
        y0s[t] = 0;
        y1s[t] = 1;
    }

    // Move the lines aound
    for (int t = 0; t < 250; t++) {
        display_clear();
        // draw each line
        for (uint8_t j = 0; j < num; j++) {
            display_line(x0s[j], y0s[j], x1s[j], y1s[j]);
        }

        // move them down
        for (uint8_t j = num - 1; j >= 1; j--) {
            x0s[j] = x0s[j - 1];
            x1s[j] = x1s[j - 1];
            y0s[j] = y0s[j - 1];
            y1s[j] = y1s[j - 1];
        }

        // calculate next
        x0s[0] += dx0;
        x1s[0] += dx1;
        y0s[0] += dy0;
        y1s[0] += dy1;
#define limit(v, dv, max_v) {\
        if (v < 0) { v = 0; dv = (rand() & 3) + 2; } \
        if (v >= max_v) { v = max_v - 1; dv = -(rand() & 3) - 2; } \
}
        limit(x0s[0], dx0, 128);
        limit(x1s[0], dx1, 128);
        limit(y0s[0], dy0, 64);
        limit(y1s[0], dy1, 64);
#undef limit
        display_refresh();
    }
}
示例#13
0
文件: line.c 项目: imincik/pkg-grass
int move_line_end(void *closure)
{
    struct move_line *ml = closure;

    /* Display last highlighted in normal color */
    if (ml->last_line > 0) {
	display_line(ml->last_line, SYMB_DEFAULT, 1);
    }

    i_prompt("");
    i_prompt_buttons("", "", "");
    i_coor(COOR_NULL, COOR_NULL);

    G_debug(3, "move_line(): End");

    return 1;
}
示例#14
0
void draw_screen(editor_t *ed)
  {
  int pos;
  int i;

  gotoxy(ed, 0, 0);
  outstr(ed, TEXT_COLOR);
  pos = ed->toppos;
  for (i = 0; i < ed->lines; i++)
    {
    if (pos < 0)
      {
      outstr(ed, CLREOL "\r\n");
      }
    else
      {
      display_line(ed, pos, 1);
      pos = next_line(ed, pos);
      }
    }
  }
示例#15
0
void more(char *file_name) 
{
    FILE *f;
    uint8_t line_count = 0;

    f = fopen(file_name, "r");
    if (f != NULL) {
        while (fgets(line, sizeof(line), f) != NULL) {
            chomp(line);
            if (line_count >= screen_height - 1) {
                line_count = display_control_line(line_count);
            }
            line_count += display_line(line);
        }
        if (fclose(f)==EOF) {
            perror(file_name);
        }
    }
    else {
        perror(file_name);
    }
}
示例#16
0
void			apply_delete(void)
{
	int		win_size;
	t_hist	**historic;

	historic = init_historic(0);
	if ((*historic)->copy->index != -1)
	{
		(*historic)->copy->line = update_line((*historic)->copy->line,
												(*historic)->copy->index);
		if ((win_size = check_beginning((*historic)->copy->index)))
		{
			tputs(tgetstr("up", NULL), 1, aff_c);
			tputs(tgoto(tgetstr("ch", NULL), 0, win_size), 1, aff_c);
		}
		else
			tputs(tgetstr("le", NULL), 1, aff_c);
		tputs(tgetstr("dc", NULL), 1, aff_c);
		(*historic)->copy->index -= 1;
		(*historic)->copy->size = ft_strlen((*historic)->copy->line);
		display_line();
	}
}
示例#17
0
void ErrorList::Error::write_to_stream( Stream &os ) const {
    // last item in caller stack
    if ( caller_stack.size() ) {
        if ( display_escape_sequences )
            os << "\033[1m";
        const ErrorList::Provenance &po = caller_stack[ 0 ];
        if ( po.provenance.size() )
            os << po.provenance << ":";
        if ( po.line ) {
            os << po.line;
            if ( po.col > 0 )
                os << ":" << po.col;
            os << ": ";
        }
        os << "error: " << msg << ( display_col ? "\n" : " in '" );
        if ( po.complete_line.size() )
            display_line( os, po.complete_line.c_str(), po.complete_line.size(), po.col, display_col );
        os << ( display_col ? "\n" : "'\n" );
        if ( display_escape_sequences )
            os << "\033[0m";
    }
    else {
        if ( display_escape_sequences )
            os << "\033[1m";
        os << "error: " << msg << "\n";
        if ( display_escape_sequences )
            os << "\033[0m";
    }

    // caller_stack
    for( int num_prov = 1; num_prov < caller_stack.size(); ++num_prov ) {
        const ErrorList::Provenance &po = caller_stack[ num_prov ];
        if ( po.provenance.size() )
            os << po.provenance << ":";
        if ( po.line ) {
            os << po.line << ":" << po.col;
            //while ( num_prov>0 and error.caller_stack[ num_prov-1 ].line==po.line ) os << "," << error.caller_stack[ --num_prov ].col;
            os << ": ";
        }
        os << "instantiated from: ";
        display_line( os, po.complete_line.c_str(), po.complete_line.size(), po.col, false );
        os << "\n";
    }

    // possibilities
    if ( possibilities.size() ) {
        os << "Possibilities are:" << std::endl;
        for ( int i = 0; i < possibilities.size();++i ) {
            for( int j = 0; ; ++j ) {
                if ( j==i ) {
                    const ErrorList::Provenance & po = possibilities[ i ];
                    if ( po.provenance.size() and po.line )
                        os << "" << po.provenance << ":" << po.line << ":" << po.col << ": ";
                    else
                        os << "(in primitive functions or classes)";
                    if ( po.msg.size() )
                        os << po.msg << ": ";
                    display_line( os, po.complete_line.c_str(), po.complete_line.size(), po.col, false );
                    os << "\n";
                    break;
                }
                if ( possibilities[i].provenance == possibilities[j].provenance and
                     possibilities[i].line == possibilities[j].line and
                     possibilities[i].col  == possibilities[j].col )
                    break;
            }
        }
    }
}
示例#18
0
void update_line(editor_t *ed)
  {
  gotoxy(ed, 0, ed->line - ed->topline);
  display_line(ed, ed->linepos, 0);
  }
示例#19
0
int display_box(const char *filename, fb_info fb_inf, fb_info fb_xin)
{

    fb_info jpeg_inf;
    fb_info fb_inff = fb_xin;

    u8_t *buf24 = decode_jpeg(filename, &jpeg_inf);
    u8_t *scale_buf = scale24(buf24, fb_inff, jpeg_inf);
    u32_t *buf32 = rgb24to32(scale_buf, fb_inff);

    int x = fb_inf.h/2, y = fb_inf.h/2;
    int x1 = fb_inf.w-fb_inf.h/2, y1 = fb_inf.h/2;
    int x2 = fb_inf.h/2, y2 = fb_inf.h/2;
    int x3 = fb_inf.w-fb_inf.h/2, y3 = fb_inf.h/2;
    int x4 = fb_inf.h/2, y4=0, x5 = 0;
    int x6 = fb_inf.w-fb_inf.h/2, y6 = 0, x7 = fb_inf.w;
    int x8 = fb_inf.h/2, y8 = fb_inf.h-1, x9 = 0;
    int x10 = fb_inf.w - fb_inf.h/2, y10 = fb_inf.h - 1, x11 = fb_inf.w;

    while((x4<=fb_inf.w/2) && (y4<=fb_inf.h/2)) 
    {
        if(x>0 && y>0)
        {
            display_line(buf32, fb_inf, x, 0, 0, y);
            y--;
            x--;

            display_line(buf32, fb_inf, x1, 0, fb_inf.w, y1);
            y1--;
            x1++;

            display_line(buf32, fb_inf, 0, y2, x2, fb_inf.h);
            y2++;
            x2--;

            display_line(buf32, fb_inf, x3, fb_inf.h, fb_inf.w, y3);
            y3+=1;
            x3+=1;
        }

            display_line(buf32, fb_inf, x4, y4, x5, fb_inf.h/2);
            x5++;
            if(x4 == fb_inf.w/2)
            {
                x4 = fb_inf.w/2;
                y4++;
            }
            else
                x4++;

            display_line(buf32, fb_inf, x6, y6, x7, fb_inf.h/2);
            x7--;
            if(x6 == fb_inf.w/2)
            {
                x6 = fb_inf.w/2;
                y6++;
            }
            else
                x6--;

            display_line(buf32, fb_inf, x8, y8, x9, fb_inf.h/2);
            x9++;
            if(x8 == fb_inf.w/2)
            {
                x8 = fb_inf.w/2;
                y8--;
            }
            else
                x8++;

            display_line(buf32, fb_inf, x10, y10, x11, fb_inf.h/2);
            x11--;
            if(x10 == fb_inf.w/2)
            {
                x10 = fb_inf.w/2;
                y10--;
            }
            else
                x10--;
        if(*status_p == 0) goto biaoshan1;
        usleep(10);
    }
    biaoshan1: free(buf24);
    free(scale_buf);
    free(buf32);

    return 0;
}
示例#20
0
int display_zig(const char *filename, fb_info fb_inf, fb_info fb_xin)
{
    fb_info jpeg_inf;
    fb_info fb_inff = fb_xin;
    int y[7],y1[7];
    int x1, x2, x3, x4, y20, y11, y40, y31, y60, y51, y7, y71;
    int i = 0;
    x1 = x3 =fb_inf.w/2 - 34,  x2 = x4 = fb_inf.w/2 + 34; 
    y20 =(fb_inf.h/7+1)*2; y11 =(fb_inf.h/7+1)*1;
    y40 = (fb_inf.h/7+1)*4; y31 = (fb_inf.h/7+1)*3; 
    y60 = (fb_inf.h/7)*6; y51 = (fb_inf.h/7)*5;
    y7 = y71 = fb_inf.h - 1;

    u8_t *buf24 = decode_jpeg(filename, &jpeg_inf);
    u8_t *scale_buf = scale24(buf24, fb_inff, jpeg_inf);
    u32_t *buf32 = rgb24to32(scale_buf, fb_inff);

    for(i=0; i<7; i++)
    {
        if(i<=4)
        {
            y[i] = (fb_inf.h/7+1)*i;
            y1[i] = (fb_inf.h/7+1)*i;
        }
        else
        {
            y[i] = (fb_inf.h/7)*i;
            y1[i] = (fb_inf.h/7)*i;
        }
    }

    while(x1<fb_inf.w)
    {
        display_line(buf32, fb_inf, x1, y[1], x2, y[0]);
        display_line(buf32, fb_inf, x1, y[1], x2, y[2]);
        display_line(buf32, fb_inf, x1, y[3], x2, y20);
        display_line(buf32, fb_inf, x1, y[3], x2, y[4]);
        display_line(buf32, fb_inf, x1, y[5], x2, y40);
        display_line(buf32, fb_inf, x1, y[5], x2, y[6]);
        display_line(buf32, fb_inf, x2, y60, x1, y7);

        display_line(buf32, fb_inf, x3, y1[1], x4, y1[0]);
        display_line(buf32, fb_inf, x3, y11, x4, y1[2]);

        display_line(buf32, fb_inf, x3, y1[3], x4, y1[2]);
        display_line(buf32, fb_inf, x3, y31, x4, y1[4]);

        display_line(buf32, fb_inf, x3, y1[5], x4, y1[4]);
        display_line(buf32, fb_inf, x3, y51, x4, y1[6]);

        display_line(buf32, fb_inf, x4, y1[6], x3, y71);
        if(x3 == 0)
        {
            x3 = 0;
            y11++;
            y31++;
            y1[1]--;
            y1[3]--;
            //y7--;
            y1[5]--;
            y51++;
            y71--;
            x4--;
        }
        else
        {
            x3--;
            x4--;
        }
        if(x2 == fb_inf.w-1)
        {
            x2 = fb_inf.w - 1;
            y[0]++;
            y20++;
            y40++;
            y[2]--;
            y[4]--;
            //y7--;
            y[6]--;
            y60++;
            x1++;
        }
        else
        {
            x1++;
            x2++;
        }
        usleep(10);
        if(*status_p == 0) goto biaoshan3;
        
    }
    biaoshan3:
    free(buf24);
    free(scale_buf);
    free(buf32);
    return 0;
}
示例#21
0
文件: linux.c 项目: OPSF/uClinux
void event_loop(void)
{
canmsg_t rx[80];			/* receive buffer for read() */
fd_set rfds;
int got;				/* got this number of messages */
int i;
struct timeval tval;		/* use time out in W32 server */


    /* On LINUX we need no time out for the select call.
     * we either, wiat for:
     * a message arrives on can_fd
     * a key was hit on stdin - fd=0
     */
    tval.tv_sec = 0;		/* first try it with 1ms */
    tval.tv_usec = 1400;

    while(1) {
        FD_ZERO(&rfds);
        FD_SET(can_fd, &rfds);		/* watch on fd for CAN */
        FD_SET(0, &rfds);		/* watch on fd for stdin */

#if defined(TARGET_LINUX_PPC)
        /* select for:          read, write, except,  timeout */      
        if( select(FD_SETSIZE, &rfds, NULL, NULL,     &tval ) > 0 )
#else
        /* select for:          read, write, except, no-timeout */      
        if( select(FD_SETSIZE, &rfds, NULL, NULL,     NULL  ) > 0 )
#endif
        {
	    /* one of the read file descriptors has changed status */
	    /* fprintf(stderr, "."); fflush(stderr);         */
        
            if( FD_ISSET(can_fd, &rfds) ) {
            	/* it was the CAN fd */

		got=read(can_fd, rx , 20 );
		if( got > 0) {
		    /* Messages in read */
		    if (debug) {
			fprintf(stderr, "--------------\n");
			fprintf(stderr, "Received got=%d\n", got);
		    } 
		    for(i = 0; i < got; i++) {
		        if((rx[i].id < 0) || (filter(rx[i].id) == TRUE)) { 
			    /* for all received messages */
			    show_message(&rx[i]);
			}
		    }
		} else {
		    /* read returnd with error */
		    fprintf(stderr,
		    	"- Received got=%d: id=%d len=%d msg='%s' \n",
			    got, rx[i].id, rx[i].length, rx[i].data );
		    fflush(stderr);
		}
	    } /* it was the CAN fd */

            if( FD_ISSET(0, &rfds) ) {
            	/* it was the stdio terminal fd */
            	i = read(0 , device, 40);
            	while(i--) {
		    change_format(device[i]);
		} /* while */
	    } /* stdio fd */
	} else {
	    if(o_show_status) {
	    char line[100];
		getStat(line); /* fills line !! */
		sprintf(line,"%s %.1f\n", line, f_busload);
		send_line_cnt = strlen(line);
		display_line(line);
		send_line_cnt = 0;
	    }
	}
    }
}
示例#22
0
文件: line.c 项目: imincik/pkg-grass
int delete_line_update(void *closure, int sxn, int syn, int button)
{
    struct delete_line *dl = closure;
    double x = D_d_to_u_col(sxn);
    double y = D_d_to_u_row(syn);

    G_debug(3, "button = %d x = %d = %f y = %d = %f", button, sxn, x, syn, y);

    /* Display last highlighted in normal color */
    if (dl->last_line > 0) {
	display_line(dl->last_line, SYMB_DEFAULT, 1);
    }

    if (button == 3)		/* Quit tool */
	return 1;

    if (button == 1) {		/* Confirm / select */
	/* Delete last if any */
	if (dl->last_line > 0) {
	    int node1, node2;
	    int i;

	    /* Erase line and nodes !!! (because if the line is not connected to any other, nodes will die */
	    display_line(dl->last_line, SYMB_BACKGROUND, 1);
	    Vect_get_line_nodes(&Map, dl->line, &node1, &node2);
	    G_debug(2, "delete line = %d node1 = %d node2 = %d",
		    dl->last_line, node1, node2);

	    display_node(node1, SYMB_BACKGROUND, 1);
	    display_node(node2, SYMB_BACKGROUND, 1);

	    Vect_read_line(&Map, NULL, dl->Cats, dl->last_line);
	    Vect_delete_line(&Map, dl->last_line);
	    for (i = 0; i < dl->Cats->n_cats; i++) {
		check_record(dl->Cats->field[i], dl->Cats->cat[i]);
	    }

	    for (i = 0; i < Vect_get_num_updated_lines(&Map); i++)
		G_debug(2, "Updated line: %d",
			Vect_get_updated_line(&Map, i));

	    for (i = 0; i < Vect_get_num_updated_nodes(&Map); i++)
		G_debug(2, "Updated node: %d",
			Vect_get_updated_node(&Map, i));

	    updated_lines_and_nodes_erase_refresh_display();
	}

	/* Find neares point or line */
	dl->line =
	    Vect_find_line(&Map, x, y, 0, GV_POINT | GV_CENTROID, dl->thresh,
			   0, 0);
	G_debug(2, "point found = %d", dl->line);
	if (dl->line == 0)
	    dl->line =
		Vect_find_line(&Map, x, y, 0, GV_LINE | GV_BOUNDARY,
			       dl->thresh, 0, 0);
	G_debug(2, "line found = %d", dl->line);

	/* Display new selected line if any */
	if (dl->line > 0) {
	    display_line(dl->line, SYMB_HIGHLIGHT, 1);
	}
    }
    else {			/* button == 2 -> unselect */
	dl->line = 0;
    }

    if (dl->line > 0)
	i_prompt_buttons(_("Confirm and select next"), _("Unselect"), _("Quit tool"));
    else
	i_prompt_buttons(_("Select"), _("Unselect"), _("Quit tool"));

    dl->last_line = dl->line;
    dl->first = 0;

    return 0;
}
示例#23
0
文件: screen.c 项目: hankem/jed
/* if force then do update otherwise return 1 if update or 0 if not */
static int update_1(Line *top, int force)
{
   int i;
   Window_Type *start_win;
   int did_eob, time_has_expired = 0;

   if (Batch ||
       (!force
	&& (Executing_Keyboard_Macro || (Repeat_Factor != NULL)
	    || screen_input_pending (0)
	    || (Read_This_Character != NULL)))
       || (CBuf != JWindow->buffer))

     {
	return(0);
     }

   if (Suspend_Screen_Update != 0)
     {
	Suspend_Screen_Update = 0;
	touch_screen ();
     }

   JWindow->mark.line = CLine;
   JWindow->mark.point = Point;
   JWindow->mark.n = LineNum + CBuf->nup;
   CBuf->linenum = LineNum;
   CBuf->max_linenum = Max_LineNum;

   if (Wants_Attributes && CBuf->vis_marks)
     {
	JWindow->trashed = 1;
     }

   /* Do not bother setting this unless it is really needed */
   if (Display_Time)
     {
	Status_This_Time = sys_time();
	time_has_expired = (Status_This_Time > Status_Last_Time + 45);
     }

   /* if cursor moves just left right, do not update status line */
   if (!force && !JWindow->trashed &&
       ((JWindow == JWindow->next) || (User_Prefers_Line_Numbers && Cursor_Motion))
       /* if % wanted, assume user is like me and gets annoyed with
	* screen updates
	*/
       && (User_Prefers_Line_Numbers
	   || time_has_expired))
     {
	update_status_line(0);
	return(1);
     }

   if (!JWindow->trashed && Cursor_Motion)
     {
#if JED_HAS_LINE_ATTRIBUTES
	if (CLine->flags & JED_LINE_IS_READONLY)
	  update_status_line (0);
#endif
	return 1;
     }

   start_win = JWindow;
   do
     {
	int imax;
	unsigned int start_column;

#if JED_HAS_LINE_ATTRIBUTES
	if (CBuf->min_unparsed_line_num)
	  jed_syntax_parse_buffer (0);
#endif
	if (Wants_Syntax_Highlight) init_syntax_highlight ();

#if JED_HAS_LINE_ATTRIBUTES
	if (top != NULL) top = jed_find_non_hidden_line (top);
#endif

	/* (void) SLsmg_utf8_enable (CBuf->local_vars.is_utf8); */
	if (top == NULL)
	  {
	     top = find_top();
	     if (top == NULL) top = CLine;
	  }

	JWindow->beg.line = top;
#if JED_HAS_LINE_ATTRIBUTES
	if (top->flags & JED_LINE_HIDDEN)
	  top = NULL;
	else
#endif
	  mark_window_attributes ((start_win == JWindow) || (start_win->buffer != CBuf));

	did_eob = 0;

	i = JWindow->sy;
	imax = i + JWindow->rows;

	compute_line_display_size ();
	start_column = JWindow->sx;

	while (i < imax)
	  {
#if JED_HAS_LINE_ATTRIBUTES
	     if ((top != NULL) && (top->flags & JED_LINE_HIDDEN))
	       {
		  top = top->next;
		  continue;
	       }
#endif

	     /* the next line is really optional */
#if 0
	     if (!force && (Exit_From_MiniBuffer ||
			    screen_input_pending (0))) break;
#endif

	     if ((JScreen[i].line != top)
		 || JScreen[i].is_modified
		 || (Want_Eob
		     && !did_eob
		     && (i != Jed_Num_Screen_Rows - 1)
		     && (top == NULL)))
	       {
		  if (((top == NULL) || (top->len == 0))
		      && (Want_Eob && !did_eob && !(CBuf->flags & READ_ONLY)))
		    {
		       display_line(&Eob_Line, i, start_column);

		       /* JScreen[i].line = top; */
		       did_eob = 1;
		    }
		  else display_line(top, i, start_column);
	       }

	     if (top != NULL)
	       top = top->next;
	     i++;
	  }

	HScroll_Line = NULL;
	Mode_Has_Syntax_Highlight = 0;
	if (!force && screen_input_pending (0))
	  {
	     while (JWindow != start_win) other_window();
	     JWindow->trashed = 1;  /* since cursor not pointed */
	     /* (void) SLsmg_utf8_enable (1); */  /* default state */

	     return(0);
	  }
	else update_status_line (start_win != JWindow);

#if JED_HAS_DISPLAY_LINE_NUMBERS
	if (CBuf->line_num_display_size)
	  display_line_numbers ();
#endif
	JWindow->trashed = 0;

	other_window();
	top = NULL;
	/* if (!JWindow->trashed) top = JWindow->beg.line; else  top = NULL; */

     }
   while (JWindow != start_win);
   /* SLsmg_utf8_enable (1); */	       /* default state */
   return 1;
}
示例#24
0
文件: line.c 项目: imincik/pkg-grass
int move_line_update(void *closure, int sxn, int syn, int button)
{
    struct move_line *ml = closure;
    double x = D_d_to_u_col(sxn);
    double y = D_d_to_u_row(syn);

    G_debug(3, "button = %d x = %d = %f y = %d = %f", button, sxn, x, syn, y);

    if (ml->last_line > 0) {
	display_line(ml->last_line, SYMB_DEFAULT, 1);
    }

    if (button == 3)
	return 1;

    if (button == 1) {		/* Select / new location */
	int type;

	if (ml->last_line == 0) {	/* Select line */
	    ml->line =
		Vect_find_line(&Map, x, y, 0, GV_POINT | GV_CENTROID,
			       ml->thresh, 0, 0);
	    G_debug(2, "point found = %d", ml->line);
	    if (ml->line == 0)
		ml->line =
		    Vect_find_line(&Map, x, y, 0, GV_LINE | GV_BOUNDARY,
				   ml->thresh, 0, 0);
	    G_debug(2, "line found = %d", ml->line);

	    /* Display new selected line if any */
	    if (ml->line > 0) {
		display_line(ml->line, SYMB_HIGHLIGHT, 1);

		/* Find the nearest point on the line */
		type = Vect_read_line(&Map, ml->Points, NULL, ml->line);
		Vect_line_distance(ml->Points, x, y, 0, 0, &ml->xo, &ml->yo,
				   NULL, NULL, NULL, NULL);
		set_location(D_u_to_d_col(ml->xo), D_u_to_d_row(ml->yo));

		i_prompt_buttons(_("New location"), _("Unselect"), _("Quit tool"));
	    }
	    ml->last_line = ml->line;
	}
	else {			/* Line is already selected */
	    int node1, node2;
	    int i;

	    display_line(ml->last_line, SYMB_BACKGROUND, 1);
	    Vect_get_line_nodes(&Map, ml->last_line, &node1, &node2);
	    display_node(node1, SYMB_BACKGROUND, 1);
	    display_node(node2, SYMB_BACKGROUND, 1);

	    type = Vect_read_line(&Map, ml->Points, ml->Cats, ml->last_line);
	    for (i = 0; i < ml->Points->n_points; i++) {
		ml->Points->x[i] = ml->Points->x[i] + x - ml->xo;
		ml->Points->y[i] = ml->Points->y[i] + y - ml->yo;
	    }

	    Vect_rewrite_line(&Map, ml->last_line, type, ml->Points,
			      ml->Cats);

	    updated_lines_and_nodes_erase_refresh_display();
	    ml->last_line = 0;
	}

    }
    if (button == 2) {		/* Unselect */
	if (ml->last_line > 0) {
	    ml->last_line = 0;
	}
    }

    if (ml->last_line == 0) {
	i_prompt_buttons(_("Select"), "", _("Quit tool"));
	set_mode(MOUSE_POINT);
    }
    else
	set_mode(MOUSE_LINE);

    return 0;
}
示例#25
0
/*	Output a page
**	-------------
*/
PRIVATE void display_page (HText * text, int line_number)
{
    HTLine * line = text->last_line->prev;
    int i;
    const char * title = HTAnchor_title(text->node_anchor);
    int lines_of_text = title ? (DISPLAY_LINES-TITLE_LINES) : DISPLAY_LINES;
    int last_screen = text->lines - lines_of_text;

/*	Constrain the line number to be within the document
*/
    if (text->lines <= lines_of_text) line_number = 0;
    else if (line_number>last_screen) line_number = last_screen;
    else if (line_number < 0) line_number = 0;
    
    for(i=0,  line = text->last_line->next;		/* Find line */
    	i<line_number && (line!=text->last_line);
      i++, line=line->next) /* Loop */ assert(line->next != NULL);

    while((line!=text->last_line) && (line->size==0)) {	/* Skip blank lines */
        assert(line->next != NULL);
      line = line->next;
        line_number ++;
    }

/*	Can we just scroll to it?
*/ 
#ifndef VM			/* No scrolling */
    if (!text->stale && (line_number>=text->top_of_screen) &&
    	(line_number < text->top_of_screen + DISPLAY_LINES)) {	/* Yes */
	lines_of_text = line_number - text->top_of_screen;
	line = text->next_line;
        text->top_of_screen = line_number;
#ifdef CURSES
        scrollok(w_text, TRUE);
        for (i = 0; i < lines_of_text; i++) {
              scroll(w_text);
        }
#endif  
    } else
#endif
    {
	clear_screen();						/* No */
        text->top_of_screen = line_number;
	if (title) display_title(text);
    }
    
/* Bug: when we scroll to a part slightly futher down a page which previously
 fitted all on one screen including the [End], the code below will add an
 extra [End] to the screen, giving a total of two, one underneath the other.
*/
    
 /*	print it
 */
    if (line) {
      for(i=0;
	  (i< lines_of_text) && (line != text->last_line); i++)  {
      assert(line != NULL);
        display_line(text, line);
	line = line->next;
      }
      fill_screen(text, lines_of_text - i);
    }

    text->next_line = line;	/* Line after screen */
    text->stale = NO;		/* Display is up-to-date */
}
示例#26
0
文件: line.c 项目: imincik/pkg-grass
int edit_line_update(void *closure, int sxn, int syn, int button)
{
    struct edit_line *el = closure;
    double x = D_d_to_u_col(sxn);
    double y = D_d_to_u_row(syn);

    G_debug(3, "button = %d x = %d = %f y = %d = %f", button, sxn, x, syn, y);

    if (button == 3)		/* Tool broken by GUI */
	return 1;

    switch (el->phase) {
    case 1:
	if (button != 1)
	    return 0;

	/* Find nearest point or line */
	el->line =
	    Vect_find_line(&Map, x, y, 0, GV_LINE | GV_BOUNDARY, el->thresh,
			   0, 0);
	G_debug(2, "line found = %d", el->line);

	/* Display new selected line if any */
	if (el->line > 0) {
	    display_line(el->line, SYMB_HIGHLIGHT, 1);
	    edit_line_phase2(el, x, y);
	}
	break;

    case 2:
	if (button == 1) {	/* New point */
	    snap(&x, &y);
	    Vect_append_point(el->Points, x, y, 0);

	    if (el->line_type == GV_LINE)
		symb_set_driver_color(SYMB_LINE);
	    else
		symb_set_driver_color(SYMB_BOUNDARY_0);

	    display_points(el->Points, 1);
	    set_location(sxn, syn);
	    i_prompt_buttons(_("New Point"), _("Undo Last Point"), _("Close line"));
	}
	else if (button == 2) {	/* Undo last point */
	    if (el->Points->n_points > 1) {
		symb_set_driver_color(SYMB_BACKGROUND);
		display_points(el->Points, 1);

		el->Points->n_points--;

		if (el->line_type == GV_LINE)
		    symb_set_driver_color(SYMB_LINE);
		else
		    symb_set_driver_color(SYMB_BOUNDARY_0);

		display_points(el->Points, 1);
		set_location(D_u_to_d_col
			     (el->Points->x[el->Points->n_points - 1]),
			     D_u_to_d_row(el->Points->
					  y[el->Points->n_points - 1])
		    );
		if (el->Points->n_points == 1)
		    i_prompt_buttons(_("New Point"), "", _("Delete line and exit"));
	    }
	}
	break;
    }

    return 0;
}
示例#27
0
PRIVATE void split_line (HText * text, int split)
{
    HTStyle * style = text->style;
    int spare;
    int indent = (int) (text->in_line_1 ? text->style->indent1st
			: text->style->leftIndent);

/*	Make new line
*/
    HTLine * previous = text->last_line;
    HTLine * line;
    if ((line = (HTLine  *) HT_MALLOC(LINE_SIZE(MAX_LINE))) == NULL)
        HT_OUTOFMEM("split_line");

    text->lines++;
    
    previous->next->prev = line;
    line->prev = previous;
    line->next = previous->next;
    previous->next = line;
    text->last_line = line;
    line->size = 0;
    line->offset = 0;

/*	Split at required point
*/    
    if (split) {	/* Delete space at "split" splitting line */
	char * p;
	previous->data[previous->size] = 0;
	for (p = &previous->data[split]; *p; p++)
	    if (*p != ' ') break;
	strcpy(line->data, p);
	line->size = strlen(line->data);
	previous->size = split;
    }
    
    while ((previous->size > 0) &&
	   (previous->data[previous->size-1] == ' '))	/* Strip trailers */
        previous->size--;

    if ((previous = (HTLine *)
	 HT_REALLOC(previous, LINE_SIZE(previous->size)))==NULL)
	HT_OUTOFMEM("split_line");
    previous->prev->next = previous;	/* Link in new line */
    previous->next->prev = previous;	/* Could be same node of course */

/*	Terminate finished line for printing
*/
    previous->data[previous->size] = 0;

/*	Align left, right or center
*/

    spare =  (int) (HTScreenWidth - style->rightIndent + style->leftIndent -
		    previous->size);		     /* @@ first line indent */
		
    switch (style->alignment) {
	case HT_CENTER :
	    previous->offset = previous->offset + indent + spare/2;
	    break;
	case HT_RIGHT :
	    previous->offset = previous->offset + indent + spare;
	    break;
	case HT_LEFT :
	case HT_JUSTIFY :		/* Not implemented */
	default:
	    previous->offset = previous->offset + indent;
	    break;
    } /* switch */

    text->chars = text->chars + previous->size + 1;	/* 1 for the line */
    text->in_line_1 = NO;		/* unless caller sets it otherwise */
    
/*	If displaying as we go, output it:
*/
    if (text->display_on_the_fly) {
        if (text->display_on_the_fly == DISPLAY_LINES) { /* First line */
	    if (previous->size == 0) {
	        text->top_of_screen++;	/* Scroll white space off top */
		return;
	    }
	    if (HTAnchor_title(text->node_anchor)) { /* Title exists */
	        display_title(text);
	        text->display_on_the_fly--;
	    }
	}
	display_line(text, previous);
	text->display_on_the_fly--;
	
	/* Loop to top of next page? */
	if (!text->display_on_the_fly && text->all_pages) {
	    PUTS("\f\n"); /* Form feed on its own line a la rfc1111 */
	    text->display_on_the_fly = DISPLAY_LINES;
	}
    }
} /* split_line */
示例#28
0
文件: linux.c 项目: OPSF/uClinux
int server_event_loop(void)
{
/*----------------------------------------------------------------*/
SOCKET listenfd;                /* incoming connection socket fd  */
/* SOCKET asd; */
extern SOCKET server_fd;

int established = 0;

struct sockaddr_in servaddr;    /* incoming connection address */
struct sockaddr_in cliaddr;     /* incoming connection address */
int clilen;			/* size of client socket struct */

int maxfd;                      /* maximum fd (optimization for select) */
int maxi;                       /* number of clients ??? */
int i, j;                       /* looping index */
int rcnt;			/* receive cnt, number of received bytes */
char in_line[MAXLINE];		/* command input line from socket to horch */

    /*
     * Open a TCP socket (an Internet stream socket).
     * 
     */

    BDEBUG("Open socket\n");

    listenfd = socket(AF_INET, SOCK_STREAM, 0);
    if(listenfd < 0) {
	fprintf(stderr, "Socket open failed: %d\n", errno);
	goto TCP_SERVER_DONE;
    }
    BDEBUG("Got socket fd %d\n", listenfd);

    /*
    * Bind our local address so that the client can send to us.
    */
    memset((void *)&servaddr, 0, sizeof(servaddr));
    servaddr.sin_family         = AF_INET;
    /* servaddr.sin_addr.s_addr = htonl(INADDR_ANY); */
    servaddr.sin_port           = htons(o_portnumber);

    if (bind(listenfd, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0) {
	fprintf(stderr, "TCPserver: Socket bind failed: %d\n", errno);
	goto TCP_SERVER_DONE;
    }

    BDEBUG("\r\nHorch TCPserver, listening on port %d\r\n", o_portnumber);
    /*
    * loop forever (daemons never die!)
    */
    for ( ; ; ) {
	/*
	* Set socket to passive mode
	* and ask kernel to buffer upto LISTENQ (inet.h)
	*/
	/********************************************************************/
	/* API-Call listen for connections */
	/********************************************************************/
	BDEBUG("TCPserver: Listening for connection\n");

	if(listen(listenfd, 1) < 0) {
	    printf("TCPserver: Socket listen failed: %d\n", errno);
	}

	printf("\nWaiting for connections on port %d\n", o_portnumber);
	fflush(stdout);

	/*
	* Accept the client connection
	*/
        clilen = sizeof(cliaddr);
	server_fd = accept(listenfd, (struct sockaddr *) &cliaddr, 
		(socklen_t *)&clilen);
	if (server_fd < 0) {
	      printf("TCPserver: Socket accept failed: %d\n", errno);
	      goto TCP_SERVER_DONE;
	}
        /* save the new socketdescriptor */
        /* server_fd = outregs.x.ax; */
        established = 1;

	printf("New client: %s, port %u; Assigning fd#%d\n",
		    inet_ntoa(cliaddr.sin_addr), cliaddr.sin_port, server_fd);
	fflush(stdout);

        /* server_fd = asd; */	/* load static server_fd */ 


/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
{
canmsg_t rx[80];			/* receive buffer for read() */
canmsg_t *prx;			/* pointer to receive buffer */
fd_set rfds;
int got;				/* got this number of messages */
int i;
struct timeval tval;		/* use time out in W32 server */
static int select_flag = 0;	/* count erroneous select activity */ 


    while( read(can_fd, rx , 80 ) > 0); /* flush/remove old messages */
    reset_send_line();

    while(established)  {

	/* reinit everytime - see linux manual
	 * tval could be changed after select() call */
	tval.tv_sec = 0;		/* first try it with 1ms */
	tval.tv_usec = 1400;

        FD_ZERO(&rfds);
        FD_SET(can_fd, &rfds);		/* watch on fd for CAN */
#if 0
        FD_SET(0, &rfds);		/* watch on fd for stdin */
#endif
        FD_SET(server_fd, &rfds);	/* watch on fd for Client requests */

#if defined(TARGET_LINUX_PPC)
        /* select for:          read, write, except,  timeout */      
        if( select(FD_SETSIZE, &rfds, NULL, NULL,     &tval ) > 0 )
#else
        /* select for:          read, write, except, no-timeout */      
        if( select(FD_SETSIZE, &rfds, NULL, NULL,     NULL  ) > 0 )
#endif
        {
	    /* one of the read file descriptors has changed status */
	    /* fprintf(stderr, "."); fflush(stderr);         */

            if( FD_ISSET(can_fd, &rfds) ) {
            	/* it was the CAN fd */

/* got=read(can_fd, rx , 80 ); */
/* Stringpuffer für die TCPIP Ausgabe umfasst nur ca. 2000 Zeichen
 * 20 Zeilen x 70 Zeichen == 1400 Zeichen.
 * Nun sollte der Puffer nicht mehr überlaufen 
 */
 
/* got=read(can_fd, rx , 20 ); */
/* CAN-REport bekommt zerstückelte Zeilen und verkraftet dies nicht */

	    got=read(can_fd, rx , 20 );
	    if( got > 0) {
		/* Messages in read */
		if (debug) {
		    fprintf(stderr, "--------------\n");
		    fprintf(stderr, "Received got=%d\n", got);
		} 
		prx = &rx[0];
		/* for all received messages */
		for(i = 0; i < got; i++) {
		    if((rx[i].id < 0) || (filter(rx[i].id) == TRUE)) { 
			/* for all received messages */
			/* show_message(&rx[i]); */
/* prx muß auch bei False erhöht werden */
/* show_message() könnte zuviele Nachrichten nach 'send_line' schreiben */
			show_message(prx);
		    } 
		    prx++; /* nächste Nachricht */
		}


#if 0		
		if(send_line_cnt > 1500) 
#endif		
		{
		    /* formatted string reaches Buffer end !*/
		    j = display_line(send_line);
		    if (j == -1) {
		        if (debug) {
		            fprintf(stderr,"Error (display_line): %s\n",
		            		strerror(errno));
		        }    
		    }	
		    reset_send_line();
		    if(j == -1) {
			established = 0;
			break;
		    }
		}

	    } else {
	        /* read returned with error */
		fprintf(stderr, "- Received got = %d\n", got);
		fflush(stderr);
	    }
	    } /* it was the CAN fd */

            if( FD_ISSET(server_fd, &rfds) ) {
            	/* it was the stdio terminal fd */
            	/* Lines are coming here with \r\n */
            	rcnt = read(server_fd , in_line, MAXLINE);
		BDEBUG("%d new commands\n", rcnt);
		if(rcnt == -1) {
		    fprintf(stderr, "Error reading from socket %d\n", errno);
		    established = 0;
		} else {
/************************************************************************/
/* 
* select() kehrt für server_fd zurück, 
* obwohl der Client die Verbindung gelöst hat.
* rcnt ist immer 0 und die Schleife läuft endlos mit 100% CPU last.
*	select_flag soll diese Situation erkennen
*	Ursache unbekannt
*/
		    if (rcnt == 0) {
			select_flag++;  /* Test */
			if (select_flag > 50) {
			    established = 0;
			    fprintf(stderr, "Problem with TCP/IP connection\n");
			}
		    } else {
			select_flag = 0; /* Test */
		    }
/************************************************************************/

		    for(i = 0; i < rcnt; i++) {
			/* read input chars from recv buffer */
			if(change_format(in_line[i]) == -1) {
			    established = 0;
			}
		    }
		}
	    } /* Server-in/stdio fd */

	}
    }	/* while(established)  */
}
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
        fprintf(stderr, "Horch Server: close connection\n");
	if(close(server_fd) < 0) {
	    fprintf(stderr, "   socket close failed: %d\n", errno);
	}

    } /* for(; ; ;) */

   /************************************/
   /* Shutdown server, should not happen */
   /************************************/

TCP_SERVER_DONE:

    BDEBUG("TCPserver: Closing listening socket\n");
    /* if(socketClose(asd) < 0) { */
    if(close(server_fd) < 0) {
	 printf("TCPserver: Socket close failed %d\n", errno);
    }
    return 0;

}