/* * === FUNCTION ====================================================================== * Name: main * Description: * ===================================================================================== */ int main ( int argc, char *argv[] ) { String my_string ; String mode_string; int i; Init_String(my_string , "This is my_string"); Init_String(mode_string , "my_string"); printf("\n ++++++++my_string+++++++++++\n"); Print_String(my_string); printf("\n ++++++++mode_string+++++++++++\n"); Print_String(mode_string); printf("\n ++++++++Start to KMP+++++++++++\n"); i=Index_Kmp(my_string , mode_string ); if(i==-1) { printf("\n can not find the string : %s \n ", mode_string ); } else { printf("\n find the string : %s in the string %s at position %d \n", mode_string , my_string , i); } return EXIT_SUCCESS; } /* ---------- end of function main ---------- */
// ------------------------------------------------------ // Display compressor sliders void Display_Track_Compressor(void) { char string[64]; Gui_Draw_Button_Box(544, (Cur_Height - 103), 56, 16, "Threshold", BUTTON_NORMAL | BUTTON_DISABLED); Realslider_Size(601, (Cur_Height - 103), 50, (int) (mas_comp_threshold_Track[Track_Under_Caret] * 0.5f), Compress_Track[Track_Under_Caret] ? TRUE : FALSE); sprintf(string, "%d%%", (int) (mas_comp_threshold_Track[Track_Under_Caret])); Print_String(string, 601, (Cur_Height - 101), 67, BUTTON_TEXT_CENTERED); Gui_Draw_Button_Box(544, (Cur_Height - 85), 56, 16, "Ratio", BUTTON_NORMAL | BUTTON_DISABLED); Realslider_Size(601, (Cur_Height - 85), 50, (int) (mas_comp_ratio_Track[Track_Under_Caret] * 0.5f), Compress_Track[Track_Under_Caret] ? TRUE : FALSE); sprintf(string, "%d%%", (int) (mas_comp_ratio_Track[Track_Under_Caret])); Print_String(string, 601, (Cur_Height - 83), 67, BUTTON_TEXT_CENTERED); }
// ------------------------------------------------------ // Display volume slider void Display_Track_Volume(void) { char string[64]; Gui_Draw_Button_Box(544, (Cur_Height - 51), 56, 16, "Volume", BUTTON_NORMAL | BUTTON_DISABLED); Realslider_Size(601, (Cur_Height - 51), 50, (int) (Track_Volume[Track_Under_Caret] * 50.0f), TRUE); sprintf(string, "%d%%", (int) (Track_Volume[Track_Under_Caret] * 100.0f)); Print_String(string, 601, (Cur_Height - 49), 67, BUTTON_TEXT_CENTERED); }
int main(int argc, char **argv) { char commandBuf[BUFSIZE + 1]; struct Process proc; char path[BUFSIZE + 1] = DEFAULT_PATH; char *command; int detached; /* Set attribute to gray on black. */ Print("\x1B[37m"); while (true) { /* Print shell prompt (bright cyan on black background) */ Print("\x1B[1;36m$\x1B[37m "); /* Read a line of input */ Read_Line(commandBuf, sizeof(commandBuf)); command = Strip_Leading_Whitespace(commandBuf); Trim_Newline(command); detached = isDetached(command); /* * Handle some special commands */ if (strcmp(command, "exit") == 0) { /* Exit the shell */ break; } else if (strcmp(command, "pid") == 0) { /* Print the pid of this process */ Print("%d\n", Get_PID()); continue; } else if (strcmp(command, "exitCodes") == 0) { /* Print exit codes of spawned processes. */ exitCodes = 1; continue; } else if (strncmp(command, "path=", 5) == 0) { /* Set the executable search path */ strcpy(path, command + 5); continue; } else if (strcmp(command, "") == 0) { /* Blank line. */ continue; } proc.command = Strip_Leading_Whitespace(command); if (!Copy_Token(proc.program, proc.command)) { Print("Error: invalid command\n"); continue; } Spawn_Single_Command(&proc, path, detached); if (detached && proc.pid > 0) Print("[%d]\n", proc.pid); } Print_String("DONE!\n"); return 0; }
int main(int argc, char **argv) { int nproc; char commandBuf[BUFSIZE+1]; struct Process procList[MAXPROC]; char path[BUFSIZE+1] = DEFAULT_PATH; char *command; /* Set attribute to gray on black. */ Print("\x1B[37m"); while (true) { /* Print shell prompt (bright cyan on black background) */ Print("\x1B[1;36m$\x1B[37m "); /* Read a line of input */ Read_Line(commandBuf, sizeof(commandBuf)); command = Strip_Leading_Whitespace(commandBuf); Trim_Newline(command); /* * Handle some special commands */ if (strcmp(command, "exit") == 0) { /* Exit the shell */ break; } else if (strcmp(command, "pid") == 0) { /* Print the pid of this process */ Print("%d\n", Get_PID()); continue; } else if (strcmp(command, "exitCodes") == 0) { /* Print exit codes of spawned processes. */ exitCodes = 1; continue; } else if (strncmp(command, "path=", 5) == 0) { /* Set the executable search path */ strcpy(path, command + 5); continue; } else if (strcmp(command, "") == 0) { /* Blank line. */ continue; } /* * Parse the command string and build array of * Process structs representing a pipeline of commands. */ nproc = Build_Pipeline(command, procList); if (nproc <= 0) continue; Spawn_Pipeline(procList, nproc, path); } Print_String("DONE!\n"); return 0; }
int main(int argc, char **argv) { int badsys = -1, rc; Print("%d", badsys); Print_String("I am the c program\n"); int i; for (i = 0; i < argc; ++i) { Print("Arg %d is %s\n", i, argv[i]); } /* Make an illegal system call */ __asm__ __volatile__(SYSCALL:"=a"(rc) :"a"(badsys) ); return 0; }
int main(int argc, char **argv) { /* int badsys = -1, rc; Print_String("I am the c program\n"); Make an illegal system call __asm__ __volatile__ ( SYSCALL : "=a" (rc) : "a" (badsys) ); */ while(true) Print_String("C\n\n"); return 0; }