Example #1
0
void CUI_PEVol::draw(Drawable *S) {
    int i;
    if (S->lock()==0) {
        int window_width = 40 * col(1);
        int window_height = 12 * row(1);
        int start_x = (RESOLUTION_X / 2) - (window_width / 2);
        for(;start_x % 8;start_x--);
        int start_y = (RESOLUTION_Y / 2) - (window_height / 2);
        for(;start_y % 8;start_y--);

        S->fillRect(start_x,start_y,start_x + window_width,start_y + window_height,COLORS.Background);
        printline(start_x,start_y + window_height - row(1) + 1,148,window_width / 8, COLORS.Lowlight,S);
        for (i = start_y / row(1); i < (start_y + window_height) / row(1);i++) {
            printchar(start_x,row(i),145,COLORS.Highlight,S);
            printchar(start_x + window_width - row(1) + 1,row(i),146,COLORS.Lowlight,S);
        }
        printline(start_x,start_y,143,window_width / 8,COLORS.Highlight,S);
        print(col(textcenter("Volume Set for Block")),start_y + row(2),"Volume Set for Block",COLORS.Text,S);
        print(start_x + col(1), start_y + window_height / 2,"  Percent:",COLORS.Text,S);
        UI->draw(S);
        S->unlock();
        need_refresh = need_popup_refresh = 0;
        updated++;
    }
}
int main ()

{
  int number;
  char buf [ 1024 * 1024 ] __attribute__ ((unused)); /* Try to uncover bugs. */
  Line *line, **lline, *lines;

  lines = NULL;
  lline = &lines;
  number = 0;
  while (1) {
    printline ("%6d> ", number + 1);
    //printline ("testmtcp.c: ABOUT TO malloc\n");fflush(stdout);
#ifdef USE_STATIC_MALLOC
    line = mymalloc (sizeof *line);
#else
    line = malloc (sizeof *line);
#endif
    //printline ("testmtcp.c: DID malloc\n");fflush(stdout);
    if (!readline (line -> buff, sizeof line -> buff)) break;
    *lline = line;
    line -> next = NULL;
    lline = &(line -> next);
    printline ("\n");
    number = 0;
    for (line = lines; line != NULL; line = line -> next) {
      printline ("%6d: %s", ++ number, line -> buff);
    }
  }
  //mtcp_no ();
  printline ("All done!\n");
  exit (0);
  return (0);
}
Example #3
0
main()
{
	NODEPTR *tree;
	int ch;int j=0;
	//int number;
	*tree=NULL;
	while(1){
		printline('*');
		printf("Enter the choice:-");
		printf("\n1.Insert the element\n2.Delete the element\n3.Traversal\n4.call function\n");
		scanf("%d",&ch);
		printline('=');

      switch(ch){
         
         case 1:
                insert(tree);break;
         case 2:
               // delete();break;
         case 3:
                traversal(*tree);break;  
         case 4:printf("\nEnter the no u want to smallest\n");
		        scanf("%d",&j);
               printf("\n%d\n",kthMin(*tree,&j));printline('*');break;
         default:
              printf("Hi i m default");
              break;
      }/*end of switch*/
	}/*end of while*/
}/*end of main*/
Example #4
0
// prepare to skip forward a certain # of frames backward and continue playing forward
// do not call skip_backward directly
bool ldp::pre_skip_backward(Uint16 frames_to_skip)
{
	bool result = false;

	// only skip if the LDP is playing
	if (m_status == LDP_PLAYING)
	{
		Uint16 target_frame = (Uint16) (m_uCurrentFrame - frames_to_skip);
		unsigned int uOldCurrentFrame = m_uCurrentFrame;

		m_iSkipOffsetSincePlay -= frames_to_skip;

		result = skip_backward(frames_to_skip, target_frame);

		char s[81];
		snprintf(s, sizeof(s), "Skipped backward %d frames (from %u to %u)", frames_to_skip, uOldCurrentFrame, target_frame);
		printline(s);
	}
	else
	{
		printline("LDP ERROR: Skip backward command was called when the disc wasn't playing");
	}

	return(result);
}
void append(struct Inventory item[],int num, FILE *file){
    
    int n;
    
    printline();
    printf("Enter the amount of items to add\n");
    scanf("%d",&n);
    printline();
    
    printf("Enter Inventory Data :\n");
    printline();
    
    for (int i=num; i<(num+n); i++) {
        printf("\nFor Item %d :\n\n",i+1);
        printf("Enter the Name of the Item\n");
        scanf("%s",item[i].name);
        printf("Enter the Item Number\n");
        scanf("%d",&item[i].number);
        printf("Enter the price of Item\n");
        scanf("%f",&item[i].price);
        printf("Enter the Quantity of Item\n");
        scanf("%d",&item[i].quantity);
    }
    
    printline();
    
    for (int i=num; i<(num+n); i++) {
        fwrite(&item[i],sizeof(item[i]),1,file);
    }
    
}
Example #6
0
/* Funkcija ierakstu dzesanai */
int DelRec(void) {
    unsigned short int  inputId; // Lietotāja inputs

    if(ReadDB() == EXIT_SUCCESS) { // Izvadam visus ierakstus
        printline("Enter ID of book you want to delete:");
        scanf("%hu",&inputId);
        __fpurge(stdin);
        {
            int my_rec, v_yes_no;;

            while(
                //Ejam cauri visiem atrastajiem ierakstiem (bet vajadzētu būt tikai vienam)
                (my_rec =
                     searchElement(  offsetof( struct book_rec_type, id)
                                     //, member_size( struct book_rec_type, id)
                                     , (int*)&inputId,
                                     UNSIGNED_SHORT_INT )
                ) >= 0) {
                // Prasam vai dzēst ierakstu
                v_yes_no = askForConfirmation();
                if(v_yes_no == 1)
                    //Dzēšam ierakstu
                    if(removeRecord(my_rec) == EXIT_SUCCESS)
                        printline("The record has been successfully removed");
            }
        }
    }
Example #7
0
// print a disassembly starting from addr
void debug_disassemble(unsigned int addr)
{
	char s[160] = { 0 };
	int line = 0;
	const char *name = NULL;

	// print this many lines because that's how many our console can show at a time
	while (line < 13)
	{
		name = g_game->get_address_name(addr); // check to see if this address has a name
		// if so, it's a label name, so print it
		if (name)
		{
			outstr(name);
			printline(":");
			line++;
		}
		sprintf(s, "%04x: ", addr);
		outstr(s);

		addr += get_cpu_struct(g_which_cpu)->dasm_callback(s, addr);

		printline(s);
		line++;
	}

}
Example #8
0
void fault_handler ( struct regs *r )
{
        if ( r->int_no < 32 )
        {
                printline ( exception_messages[r->int_no] );
                printline ( "Exception, System halted" );
        }
}
Example #9
0
main() {
	printf("Input Array: ");
	display();
	printline(50);
	selectionSort();
	printf("Output Array: ");
	display();
	printline(50);
}
Example #10
0
main() {
   printf("Input Array: ");
   display();
   printline(50);
   quickSort(0,MAX-1);
   printf("Output Array: ");
   display();
   printline(50);
   return0
}
Example #11
0
bool ldp::pre_change_speed(unsigned int uNumerator, unsigned int uDenominator)
{
	string strMsg;

	// if this is >= 1X
	if (uDenominator == 1)
	{
		m_uFramesToStallPerFrame = 0;	// don't want to stall at all

		// if this isn't 0 ...
		if (uNumerator > 0)
		{
			m_uFramesToSkipPerFrame = uNumerator - 1;	// show 1, skip the rest
		}
		// else it's 0, which is illegal (use pause() instead unless the game driver specifically wants to do this, in which case more coding is needed)
		else
		{
			m_uFramesToSkipPerFrame = 0;
			printline("ERROR : uNumerator of 0 sent to pre_change_speed, this isn't supported, going to 1X");
		}
	}
	// else if this is < 1X
	else if (uNumerator == 1)
	{
		m_uFramesToSkipPerFrame = 0;	// don't want to skip any ...

		// protect against divide by zero
		if (uDenominator > 0)
		{
			m_uFramesToStallPerFrame = uDenominator - 1;	// show 1, stall for the rest
		}
		// divide by zero situation
		else
		{
			m_uFramesToStallPerFrame = 0;
			printline("ERROR : uDenominator of 0 sent to pre_change_speed, this is undefined, going to 1X");
		}
	}
	// else it's a non-standard speed, so do some kind of error
	else
	{
		strMsg = "ERROR : unsupported speed specified (" + numstr::ToStr(uNumerator) +
			"/" + numstr::ToStr(uDenominator) + "), setting to 1X";
		uNumerator = uDenominator = 1;
	}

	bool bResult = change_speed(uNumerator, uDenominator);

	if (bResult) strMsg = "Successfully changed ";
	else strMsg = "Unable to change ";
	strMsg += "speed to " + numstr::ToStr(uNumerator) + "/" + numstr::ToStr(uDenominator) +
		"X";
	printline(strMsg.c_str());
	return bResult;
}
Example #12
0
int zn_shell_echo(command *cmd)
{
  int retval = 0;
  const char* output = command_next_arg(cmd);
  if (output) {
    printline(output);
  } else {
    printline("");
  }
  return retval;
}
Example #13
0
void ldp::print_frame_info()
{
	string s = "Current frame is " + numstr::ToStr(m_uCurrentFrame);
	printline(s.c_str());

	unsigned int u = m_uMsVblankBoundary - m_uElapsedMsSinceStart;
	s = "Virtual milliseconds until next vblank: " + numstr::ToStr(u);
	printline(s.c_str());

	s = "Vblanks since frame changed: " + numstr::ToStr(m_uVblankMiniCount);
	printline(s.c_str());
}
Example #14
0
// prepares to play the disc
void ldp::pre_play()
{
//	Uint32 cpu_hz;	// used to calculate elapsed cycles

	// safety check, if they try to play without checking the search result ...
	// THIS SAFETY CHECK CAN BE REMOVED ONCE ALL LDP DRIVERS HAVE BEEN CONVERTED OVER TO NON-BLOCKING SEEKING
	if (m_status == LDP_SEARCHING)
	{
		printline("LDP : tried to play without checking to see if we were still seeking! that's bad!");
		
		// if this ever happens, it is a bug in Daphne, so log it
		m_bug_log.push_back("LDP.CPP, pre_play() : tried to play without checking to see if we're still seeking!");
		
		return;
	}

	// we only want to refresh the frame calculation stuff if the disc is
	// not already playing
	if (m_status != LDP_PLAYING)
	{
		m_uElapsedMsSincePlay = 0;	// by definition, this must be reset since we are playing
		m_uBlockedMsSincePlay = 0;	// " " "
		m_iSkipOffsetSincePlay = 0;	// by definition, this must be reset since we are playing
		m_uCurrentOffsetFrame = 0;	// " " "
		m_uMsFrameBoundary = 1000000 / g_game->get_disc_fpks();	// how many ms must elapse before the first frame ends, 2nd frame begins

		// VLDP needs its timer reset with the rest of these timers before its play command is called.
		// Otherwise, it will think it's way behind and will try to catch up a bunch of frames.
		think();

		// if the disc may need to take a long time to spin up, then pause the cpu timers while the disc spins up
		if (m_status == LDP_STOPPED)
		{
			cpu_pause();
			m_play_time = play();
			cpu_unpause();
		}
		else
		{
			m_play_time = play();
		}

		m_bWaitingForVblankToPlay = true;	// don't start counting frames until the next vsync
		m_status = LDP_PLAYING;
	}
	else
	{
		printline("LDP : disc is already playing, play command ignored");
	}

	printline("Play");	// moved to the end of the function so as to not cause lag before play command could be issued
}
Example #15
0
/*
 * Draw the status information in the status window.
 */
static void
drawstatus(void)
{
    long	score;
    long	allsteps;
    long	games;

    score = 0;
    games = games0[index];
    allsteps = steps0[index];
    score += games1[index];
    games += games1[index];
    allsteps += steps1[index];
    score += games2[index] * 2;
    games += games2[index];
    allsteps += steps2[index];

    printline(0, "Size:   %2d\n", size);
    printline(1, "Mines: %3d\n", mines);
    PRINTSTEPS;
    printline(3, "Legs:    %d\n", legs);

    printline(5, "Won games:  %3d\n", games2[index]);
    printline(6, "1-leg games:%3d\n", games1[index]);
    printline(7, "Lost games: %3d\n", games0[index]);

    if (games) {
        printline(9, "Legs/game: %3d.%03d\n", score / games,
                  ((score * 1000) / games) % 1000);

        printline(10, "Steps/game:%3d.%03d\n", allsteps / games,
                  ((allsteps * 1000) / games) % 1000);
    }
}
Example #16
0
int main(void)
{

	char line[MAXLINE];
	
	while(getline(line,MAXLINE) > 0)
	{
		//printf("%s\n", line);
		printline(line);
	}

	printline(line);
	return 0;
}
Example #17
0
int main(int argc, char **argv)
{
        char *result = all_tests();
        if (result != 0) {
                printline("*", 80);
                printf("FIXME: %s\n", result);
                printline("*", 80);
        }
        else {
                printf("ALL TESTS PASSED\n");
        }
        printf("Tests run: %d\n", tests_run);

        return result != 0;
}
Example #18
0
/*
 * listing_printline
 *
 * General print routine or use by hooks in other modules.
 */
void
listing_printline (void *ctx, const char *buf, size_t len, int align_with_source)
{
    char outbuf[132];
    if (align_with_source) {
        if (len > 132-16) len = 132-16;
        memset(outbuf, ' ', 16);
        memcpy(outbuf+16, buf, len);
        printline(ctx, outbuf, len+16);
    } else {
        if (len > 132) len = 132;
        printline(ctx, buf, len);
    }

} /* listing_printline */
void modtmpdb(struct resistor *resistor_db_tmp, int *tamanho_db){
	unsigned int index, num;

	printf("Entre com o INDICE desejado para modifica-lo\n");
	do{
		scanf("%u", &index);
	} while(index >= *tamanho_db +2);
	index--;
	printf(HEADER_DB);
	printline(resistor_db_tmp, index);
	printf("Qual a nova quantidade? \n");
	scanf("%u", &resistor_db_tmp[index].qtd);
	printf(HEADER_DB);
	printline(resistor_db_tmp, index);
}
void profit_loss(struct accounts item[],FILE *file,char name[]){
    
    int n;
    
    printf("Enter the number of items to find Profit or Loss\n");
    scanf("%d",&n);
    printline();
    
    file=fopen(name,"r");
    
    for (int i=0; i<n; i++) {
        fread(&item[i],sizeof(item[i]),1,file);
    }
    fclose(file);
    
    
    printf("Enter Inventory Data :\n");
    printline();
    
    for (int i=0; i<n; i++) {
        printf("\nFor Item %d :\n\n");
        printf("Enter the cost price of item\n");
        scanf("%f",&item[i].a1.costprice);
        printf("Enter the sale price of item\n");
        scanf("%f",&item[i].a1.saleprice);
    }
    
    for (int i=0; i<n; i++) {
        
        if (item[i].a1.costprice>item[i].a1.saleprice) {
            item[i].a1.net='LOSS';
            item[i].a1.loss=(item[i].a1.costprice-item[i].a1.saleprice);
        }
        else{
            item[i].a1.net='PROFIT';
            item[i].a1.profit=(item[i].a1.saleprice-item[i].a1.costprice);
        }
        
    }
    
    file=fopen(name,"w");
    for (int i=0; i<n; i++) {
        fwrite(&item[i],sizeof(item[i]),1,file);
    }
    
    fclose(file);
    
}
Example #21
0
int
main(int argc, char** argv)
{
  auto env = environment::make ();
  core ns (env);

  // argv
  auto argvList = mal::make_list ();
  for (size_t i = 1; i < argc; ++i)
  {
    argvList->add_child (READ (argv [i]));
  }
  env->set ("*ARGV*", argvList);

  // MAL
  // define not function
  EVAL (READ ("(def! not (fn* (a) (if a false true)))"), env);
  // load file
  EVAL (READ ("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"), env);  

  if (argc < 2)
  {
    mainRepl (env);
  }
  else
  {
    const std::string fileName = ast_node_string (argv [1]).to_string (true);

    execReplSafe ([&]() {
      printline (rep ("(load-file " + fileName + ")", env));
    });
  }

  return 0;
}
int main() {
  int len;

  while ((len = printline(80)) > 0);

  return 0;
}
Example #23
0
void timetrav::port_write(Uint16 port, Uint8 value)
{
	char s[80];
   static char display_string[9] = {0};

   switch(port)
   {
      case 0x1180:
      case 0x1181:
      case 0x1182:
      case 0x1183:
      case 0x1184:
      case 0x1185:
      case 0x1186:
      case 0x1187:
         m_video_overlay_needs_update = true;
         display_string[port & 0x07] = value;
         draw_string(display_string, 0, 0, get_active_video_overlay());
         video_blit();
         break;
      default:
         sprintf(s, "Unmapped write to port %x, value %x", port, value);
		   printline(s);
         break;
   }
}
Example #24
0
// prepares to stop the disc
// "stop" is defined as going to frame 0 and stopping the motor so that
// the player has to spin up again to begin playing
void ldp::pre_stop()
{
	m_last_seeked_frame = m_uCurrentFrame = 0;
	stop();
	m_status = LDP_STOPPED;
	printline("Stop");
}
void listtmpdb(struct resistor *resistor_db_tmp, int *tamanho_db){
	printf(HEADER_DB);
	unsigned int i;
	for(i=0;i<=*tamanho_db;i++){	
		printline(resistor_db_tmp, i);
	}
}
Example #26
0
static void readout(void) {
    char *date, *time, *nick, *mesg;
    char *rawline = NULL;
    size_t len = 0;

    while (getline(&rawline, &len, out) != -1) {
        date = strtok(rawline, " \t");
        time = strtok(NULL, " \t");
        nick = strtok(NULL, " \t");
        mesg = strtok(NULL, "\n");

        if (mesg[0] == '') { /* fix: 'ACTION msg' */
            char mtmp[LINE_MAX];
            mesg += strlen("ACTION ");
            mesg[strlen(mesg) - 1] = '\0';
            snprintf(mtmp, sizeof(mtmp), "%s %s", nick, mesg);
            mesg = mtmp;
            nick = "*\0";
        } else if (nick[0] == '<') { /* nick[strlen(nick) - 1] == '>' */
            ++nick;
            nick[strlen(nick) - 1] = '\0';
        }

        printline(date, time, nick, mesg);
    }

    wrefresh(wout);
    wrefresh(winp); /* leave cursor on input window */
}
Example #27
0
File: fonts.c Project: Lopo/Lotos
/****************************************************************************
  splitline

  Splits inchrline at the last word break (bunch of consecutive blanks).
  Makes a new line out of the first part and prints it using
	printline.  Makes a new line out of the second part and returns.
****************************************************************************/
void splitline(UR_OBJECT user, UR_OBJECT u, RM_OBJECT rm)
{
	int i,gotspace=0,lastspace=0,len1,len2;
	long *part1,*part2;

	set_crash();
	part1 = (long*)myalloc(sizeof(long)*(inchrlinelen+1));
	part2 = (long*)myalloc(sizeof(long)*(inchrlinelen+1));
	for (i=inchrlinelen-1;i>=0;i--) {
		if (!gotspace && inchrline[i]==' ') {
			gotspace = 1;
			lastspace = i;
			}
		if (gotspace && inchrline[i]!=' ') break;
		}
	len1 = i+1;
	len2 = inchrlinelen-lastspace-1;
	for (i=0;i<len1;i++)
		part1[i] = inchrline[i];
	for (i=0;i<len2;i++)
		part2[i] = inchrline[lastspace+1+i];
	fclearline();
	for (i=0;i<len1;i++)
		addchar(part1[i]);
	printline(user, u, rm);
	for (i=0;i<len2;i++)
		addchar(part2[i]);
	free(part1);
	free(part2);
}
Example #28
0
/*
 * listings_finish
 *
 * Module cleanup.
 */
void
listings_finish (lstgctx_t ctx)
{
    liststate_t *l, *lnext;

    if (ctx == 0) {
        return;
    }

    if (ctx->haveabuf) {
        printline(ctx, 0, 0);
    }
    
    for (l = ctx->cur_state; l != 0 && l != &ctx->main_state; l = lnext) {
        lnext = l->next;
        free(l);
    }

    if (ctx->outf != 0) {
        file_close(ctx->outf);
    }

    if (ctx->fio != 0) {
        fileio_finish(ctx->fio);
    }

    free(ctx);

} /* listings_finish */
Example #29
0
/* print lines in this chunk, possibly recursing into getchunk */
int printchunk(int i, int chunklinelen, char *chunkname) {
  int j;
  int k;
  int linelen;
  char *getname;
  int getlen = 0;
  if (DEBUG==3) { printf("===   \\start{%s}   ===\n",chunkname); }
  for (k=i+chunklinelen+1; ((linelen=nextline(k)) != -1); ) {
    if ((getlen=foundGetchunk(k,linelen)) > 0) {
       getname = getChunkname(k,getlen);
       getchunk(getname);
       free(getname);
       k=k+getlen+12l;
    } else {
      if ((linelen >= 11) && (foundEnd(k,chunkname) == 1)) {
      if (DEBUG==3) { printf("===   \\end{%s}   ===\n",chunkname); }
      return(k+12);
    } else {
      if (DEBUG==2) { 
        printf("======== printchunk else %d %d\n",k,linelen); 
      }
      printline(k,linelen);
      k=k+linelen+1;
    }
  }}
  if (DEBUG==2) {
     printf("=================\\out{%s} %d\n",chunkname,k); 
  }
  return(k);
}
Example #30
0
int ReadDB( void ) {
    int i; // Cikla skaitītājs

    if(g_count == 0)
    {
        printline("Record list is empty!");
        return EXIT_FAILURE;
    }
    else
    {
        printf("ID");
        printf("\tTitle");
        printf("\tAuthor");
        printf("\tPublishing house");
        printf("\tYear\n");
        printf("-------------------------------------------------------------------\n");
        for (i = 0; i < g_count; i++) { // Izvadam ieraksta datus
            printf("%hd", g_book_rec_pt[i].id);
            printf("\t%s", g_book_rec_pt[i].title);
            printf("\t%s", g_book_rec_pt[i].author);
            printf("\t%s", g_book_rec_pt[i].publishing_house);
            printf("\t%hd\n", g_book_rec_pt[i].year);
        }
        printf("-------------------------------------------------------------------\n");

        return EXIT_SUCCESS;
    }
}