f_xkmac()
{
	if(km_flag)
		ding("Already in kbd macro!");
	else if(km_buf == 0)
		ding("No kbd macro defined");
	else if((km_exp = exp-1) >= 0)
	  {
		ex_go((SBBUF *)km_buf, (chroff) 0);
		km_flag = 1;		/* Start macro execution */
	  }
}
/** Launches a thread that periodically checks in with the wifidog auth server to perform heartbeat function.
@param arg NULL
@todo This thread loops infinitely, need a watchdog to verify that it is still running?
*/
void
thread_ding(void *arg)
{
    pthread_cond_t		cond = PTHREAD_COND_INITIALIZER;
    pthread_mutex_t		cond_mutex = PTHREAD_MUTEX_INITIALIZER;
    struct	timespec	timeout;



    while (1) {
        /* Make sure we check the servers at the very begining */
        debug(LOG_DEBUG, "Running ding()");
        ding();


        /* Sleep for config.checkinterval seconds... */
        timeout.tv_sec = time(NULL) + 30;
        timeout.tv_nsec = 0;

        /* Mutex must be locked for pthread_cond_timedwait... */
        pthread_mutex_lock(&cond_mutex);

        /* Thread safe "sleep" */
        pthread_cond_timedwait(&cond, &cond_mutex, &timeout);

        /* No longer needs to be locked */
        pthread_mutex_unlock(&cond_mutex);
    }
}
Beispiel #3
0
/* Play the current puzzle. Return when the user solves the puzzle or
 * requests a different puzzle.
 */
static void playgame(void)
{
    int index, n;

    index = 0;
    for (n = 0 ; n < currentseries ; ++n)
	index += serieslist[n].count;
    index += currentgame;

    n = 0;
    if (drawscreen(index)) {
	do {
	    if ((n = doturn())) {
		currentgame += n;
		if (readlevel())
		    break;
		currentgame -= n;
		ding();
	    }
	    drawscreen(index);
	} while (!checkfinished());
	freesavedstates();
	if (checkfinished() && replaceanswer(FALSE))
	    saveanswers(serieslist + currentseries);
    }

    if (!n) {
	++currentgame;
	n = endinput(!readlevel());
	currentgame += n;
    }
}
Beispiel #4
0
/* EFUN: "Set Fill Prefix" */
f_sfpref()
{	register int i;
	register char *cp;

	if((i = cur_dot - e_boldot()) > MAXLINE)
	  {	ding("Absurd Fill Prefix");
		return;
	  }
	if(fill_prefix)
	  {	chkfree(fill_prefix);
		fill_plen = 0;
	  }
	if(i <= 0)
	  {	fill_prefix = 0;
		cp = "";
	  }
	else
	  {	fill_prefix = cp = memalloc((SBMO)(i+1));
		fill_plen = i;
		e_gobol();
		do { *cp++ = e_getc(); }
		while(--i);
		*cp = 0;
		cp = fill_prefix;
	  }
	say("Fill Prefix = \"");
	saytoo(cp);
	saytoo("\"");
}
f_skmac()
{	register struct buffer *b;
	struct buffer *make_buf();

	if(km_flag)
	  {	ding("Kbd macro active, ignoring \"Start Kbd Macro\"");
		return;
	  }
	if((b = km_buf) == 0)
		b = km_buf = make_buf(" *KBDMAC*");
	ex_reset(b);
	km_flag = -1;		/* Say starting macro collection */
	kdef_mode = 1;
	redp(RD_MODE);
}
f_vkmac()
{	register struct buffer *b, *savbuf;
	chroff prmplen;

	if(!(b = km_buf))
	  {	ding("No kbd macro defined");
		return;
	  }
	savbuf = cur_buf;
	chg_buf(b);
	e_gobob();
	e_sputz("Current Kbd macro:\n\n");
	prmplen = e_dot();
	mk_showin(b);		/* Show the macro buffer temporarily */
	e_gobob();
        chg_buf(savbuf);
	sb_deln((SBBUF *)b, prmplen);	/* Flush the prompt */
}
Beispiel #7
0
/* Try to complete the word we are standing on or the word that ends with
   the previous character.  A space matches everything.  Word delimiters are
   space and ;. */
rl_vi_possible_completions (void)
{
  int save_pos = rl_point;

  if (rl_line_buffer[rl_point] != ' ' && rl_line_buffer[rl_point] != ';')
    {
      while (rl_point < rl_end && rl_line_buffer[rl_point] != ' ' &&
	     rl_line_buffer[rl_point] != ';')
	rl_point++;
    }
  else if (rl_line_buffer[rl_point - 1] == ';')
    {
      ding ();
      return (0);
    }

  rl_possible_completions ();
  rl_point = save_pos;

  return (0);
}
Beispiel #8
0
f_selxbuffer()
{	register char *ans;
	register struct buffer *b;

	b = last_buf;			/* This is default */
	ans = ask("Select existing buffer (%s): ", b->b_name);
	if (ans == 0)			/* Aborted */
		return;
	if (*ans != 0)
	  {	for (b = buf_head; b != 0; b = b->b_next)
			if (findstr(ans, b->b_name))
				break;
		if (b == 0)
			ding("That isn't a substring of any buffer name!");
	  }
	chkfree(ans);
	if (b != 0)
	  {	saytoo(" => ");
		sayntoo(b->b_name);
		sel_buf(b);
	  }
}
Beispiel #9
0
int main(int argc, char *argv[]) {
  int cadence = ANNEAU_CADENCE_DEFAULT; // Cadence définit en millisecondes
  
  if (argc < 2) {
    __raise(-1, "Usage: %s <projet [, cadence]>", argv[0]);
  }
  
  //
  // Initialisation
  init(argv);
  
  // Cadence
  if (argc > 2) {
    cadence = atoi(argv[2]);
  }
  
  // Anneau
  int i;
  Anneau ano;
  
  ano.id 	= __pid;
  
  for (i = 0; i < ANNEAU_NUM_CASES; i++) {
    ano.cases[i].num 	= i;
    ano.cases[i].type 	= VIDE;
    ano.connexion[i] 	= 0;
  }
  
  *((Anneau *) __anneau) = ano;
    
  // 
  // Démarrage
  
  printf("== Démarrage de l'anneau...\n");
  printf("==== Cadence de rotation: %d ms/tour\n", cadence);
  
  //
  info();
  
  //
  // Petite pause
  usleep(2000);
  
  //
  // Rotation
  int rotation = 1;
  while (1) {
    usleep(cadence * 1000); // Attente
    
    // La roue tourne d'un pas
    tourner();
    printf("\tRotation %5d: \n", rotation++);
    info();
    
    // Émission d'un signalS sonore pour informer les robots 
    ding();
  }
  
  __endProcess();
  return 0;
}
Beispiel #10
0
void
main(int argc, char *argvar[])
{
	static global_game_variables_t gvar;
	struct glob_game_vars	*ggvv;
	char *a;
	int i,c;
	word panq=1, pand=0,showding=0;
	boolean panswitch=0,bptest=1,runding=1;

	ggvv=&gvar;

	// allow changing default mode from command line
	for (i=1;i < argc;) {
		a = argvar[i++];

		if (*a == '-') {
			do { a++; } while (*a == '-');

			if (!strcmp(a,"mx")) {
				// (based on src/lib/modex16.c)
				// 1 = 320x240
				// 2 = 160x120
				// 3 = 320x200
				// 4 = 192x144
				// 5 = 256x192
				vgamodex_mode = (sword)strtoul(argvar[i++],NULL,0);
			}
			else {
				fprintf(stderr,"Unknown switch %s\n",a);
				return;
			}
		}
		else {
			fprintf(stderr,"Unknown command arg %s\n",a);
			return;
		}
	}

	// initiate doslib //
	TL_DosLibStartup(&gvar);

	// main variables values
	d=4; // switch variable
	key=2; // default screensaver number
	xpos=TILEWHD; ypos=TILEWHD; xdir=1; ydir=1;

	VGAmodeX(vgamodex_mode, 0, &gvar); // TODO: Suggestion: Instead of magic numbers for the first param, might I suggest defining an enum or some #define constants that are easier to remember? --J.C.
		// this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in.
		// we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
	bakapee.xx = rand()&0%gvar.video.page[0].width; bakapee.yy = rand()&0%gvar.video.page[0].height;
	bakapee.gq = 0; bakapee.sx=bakapee.sy=0; bakapee.bakax=bakapee.bakay=0; bakapee.coor=0;
	//once where #defines
	bakapee.tile=0; bakapee.bonk=400; bakapee.lgq=32; bakapee.hgq=55;

	switch(WCPU_detectcpu())
	{
		case 0:
			bakapee.tile=1;
		break;
		default:
			bakapee.tile=0;
		break;
	}

	// setup camera and screen~ //
	SETUPPAGEBAKAPI

	VL_ShowPage(&gvar.video.page[0], 1, 0);
	BAKAPIINITFIZZTEST

	while (bptest)
	{
/*		if (key > 0)
		{*/
		while (!kbhit() && runding)
			{
				//{ word w; for(w=0;w<(gvar.video.page[0].width*gvar.video.page[0].height);w++) {}}
				ding(&gvar.video.page[showding], &bakapee, 4);
			}
		if (kbhit())
//			{
			getch(); // eat keyboard input
//				break;
//			}
//		}*/

		{

			c = getch();
			switch (c)
			{
				case 27: // Escape key //
				case '0':
				default:
					bptest = false;
				break;
				case 'b': // test tile change //
					switch (bakapee.tile)
					{
						case 0:
							bakapee.tile=1;
						break;
						case 1:
							bakapee.tile=0;
						break;
					}
				break;
				case 'r':
					runding = false;
					BAKAPIINITFIZZTEST
				break;
				case 'e':
					runding = 1;
				break;
				case 'z':
					runding = false;
					FIZZFADEFUN
//					runding = true;
				break;
				case '3':
				case '4':
					runding = 1;
					showding = c - '0' - 3;
				break;
				case '1':
				case '2':
	//			case '5':
	//			case '6':
	//			case '9':
					key = c - '0' - 1;
					VL_ShowPage(&gvar.video.page[key], 1, 0);
				break;
			}
		}
	}


//while(!kbhit()){}

// screen savers
//#ifdef BOINK
	while(d>0)	// on!
	{
		/* run screensaver routine until keyboard input */
		while (key > 0) {
			if (kbhit()) {
				if(!panswitch)
				{
					getch(); // eat keyboard input
					break;
				}else c=getch();
			}

			if(!panswitch){
				if(key==9)
				{
					ding(&gvar.video.page[1], &bakapee, 4);
					ding(&gvar.video.page[0], &bakapee, 4);
					FIZZFADEFUN
				}else ding(&gvar.video.page[0], &bakapee, key); }
			else			ding(&gvar.video.page[0], &bakapee, 2);
Beispiel #11
0
/* Get a keystroke from the user (or from a macro) and perform the
 * indicated command. A non-zero return value indicates a request to
 * change the current puzzle, the actual value being a delta.
 */
static int doturn(void)
{
    switch (input()) {
      case ARROW_N: if (!movecursor(NORTH))		ding();	break;
      case ARROW_E: if (!movecursor(EAST))		ding();	break;
      case ARROW_S: if (!movecursor(SOUTH))		ding();	break;
      case ARROW_W: if (!movecursor(WEST))		ding();	break;
      case 'k':     if (!shiftfromcurrblock(NORTH))	ding();	break;
      case 'l':     if (!shiftfromcurrblock(EAST))	ding();	break;
      case 'j':     if (!shiftfromcurrblock(SOUTH))	ding();	break;
      case 'h':     if (!shiftfromcurrblock(WEST))	ding();	break;
      case 'K':     if (!newmove(NORTH))		ding();	break;
      case 'L':     if (!newmove(EAST))			ding();	break;
      case 'J':     if (!newmove(SOUTH)) 		ding();	break;
      case 'H':     if (!newmove(WEST))			ding();	break;
      case 'x':     if (!undomove())			ding();	break;
      case 'z':     if (!redomove())			ding();	break;
      case 'X':     if (!undostep())			ding();	break;
      case 'Z':     if (!redostep())			ding();	break;
      case 'R':     initgamestate();				break;
      case 's':     savestate();				break;
      case 'r':     if (!restorestate())		ding();	break;
      case 'S':     if (!partialsave())			ding();	break;
      case 'g':	    drawgoalscreen();				break;
      case '?':     drawhelpscreen();				break;
      case '\f':						break;
      case 'P':     return -1;
      case 'N':     return +1;
      case 'q':     exit(0);
      case 'Q':     exit(0);
    }

    return 0;
}
Beispiel #12
0
Datei: kill.c Projekt: jheiss/nn
int
kill_menu(article_header * ah)
{
    int             days;
    register flag_type flag;
    char           *mode1, *mode2;
    char           *pattern, *dflt, *days_str, buffer[512];
    group_header   *gh;

    days = dflt_kill_select % 100;
    flag = (dflt_kill_select / 100) ? AUTO_SELECT : AUTO_KILL;
    prompt("\1AUTO\1 (k)ill or (s)elect (CR => %s subject %d days) ",
           flag == AUTO_KILL ? "Kill" : "Select", days);

    switch (get_c()) {
    case CR:
    case NL:
        if (ah == NULL) {
            ah = get_menu_article();
            if (ah == NULL)
                return -1;
        }
        strcpy(buffer, ah->subject);
        enter_kill_file(current_group, buffer,
                        flag | ON_SUBJECT | KILL_CASE_MATCH, days);
        msg("DONE");
        return 1;

    case 'k':
    case 'K':
    case '!':
        flag = AUTO_KILL;
        mode1 = "KILL";
        break;
    case 's':
    case 'S':
    case '+':
        flag = AUTO_SELECT;
        mode1 = "SELECT";
        break;
    default:
        return -1;
    }

    prompt("\1AUTO %s\1 on (s)ubject or (n)ame  (s)", mode1);

    dflt = NULL;
    switch (get_c()) {
    case 'n':
    case 'N':
        flag |= ON_SENDER;
        if (ah)
            dflt = ah->sender;
        mode2 = "Name";
        break;
    case 's':
    case 'S':
    case SP:
    case CR:
    case NL:
        flag |= ON_SUBJECT;
        if (ah)
            dflt = ah->subject;
        mode2 = "Subject";
        break;
    default:
        return -1;
    }

    prompt("\1%s %s:\1 (%=/) ", mode1, mode2);

    pattern = get_s(dflt, NONE, "%=/", NULL_FCT);
    if (pattern == NULL)
        return -1;
    if (*pattern == NUL || *pattern == '%' || *pattern == '=') {
        if (dflt && *dflt)
            pattern = dflt;
        else {
            if ((ah = get_menu_article()) == NULL)
                return -1;
            pattern = (flag & ON_SUBJECT) ? ah->subject : ah->sender;
        }
        flag |= KILL_CASE_MATCH;
    } else if (*pattern == '/') {
        prompt("\1%s %s\1 (regexp): ", mode1, mode2);

        pattern = get_s(NONE, NONE, NONE, NULL_FCT);
        if (pattern == NULL || *pattern == NUL)
            return -1;
        flag |= KILL_ON_REGEXP;
    }
    strcpy(buffer, pattern);
    pattern = buffer;

    prompt("\1%s\1 in (g)roup '%s' or in (a)ll groups  (g)",
           mode1, current_group->group_name);

    switch (get_c()) {
    case 'g':
    case 'G':
    case SP:
    case CR:
    case NL:
        gh = current_group;
        break;
    case 'A':
    case 'a':
        gh = NULL;
        break;
    default:
        return -1;
    }

    prompt("\1Lifetime of entry in days\1 (p)ermanent  (30) ");
    days_str = get_s(" 30 days", NONE, "pP", NULL_FCT);
    if (days_str == NULL)
        return -1;

    if (*days_str == NUL) {
        days_str = "30 days";
        days = 30;
    } else if (*days_str == 'p' || *days_str == 'P') {
        days_str = "perm";
        days = -1;
    } else if (isdigit(*days_str)) {
        days = atoi(days_str);
        sprintf(days_str, "%d days", days);
    } else {
        ding();
        return -1;
    }

    prompt("\1CONFIRM\1 %s %s %s%s: %-.35s%s ",
           mode1, mode2, days_str,
           (flag & KILL_CASE_MATCH) ? " exact" :
           (flag & KILL_ON_REGEXP) ? " regexp" : "",
           pattern, (int) strlen(pattern) > 35 ? "..." : "");
    if (yes(0) <= 0)
        return -1;

    enter_kill_file(gh, pattern, flag, days);

    return (flag & AUTO_KILL) ? 1 : 0;
}
Beispiel #13
0
static astr
do_minibuf_read (const char *prompt, const char *value, size_t pos,
               Completion * cp, History * hp)
{
  static int overwrite_mode = 0;
  int c, thistab, lasttab = -1;
  size_t prompt_len;
  char *s;
  astr as = astr_new_cstr (value), saved = NULL;

  prompt_len = strlen (prompt);
  if (pos == SIZE_MAX)
    pos = astr_len (as);

  for (;;)
    {
      switch (lasttab)
        {
        case COMPLETION_MATCHEDNONUNIQUE:
          s = " [Complete, but not unique]";
          break;
        case COMPLETION_NOTMATCHED:
          s = " [No match]";
          break;
        case COMPLETION_MATCHED:
          s = " [Sole completion]";
          break;
        default:
          s = "";
        }
      draw_minibuf_read (prompt, astr_cstr (as), prompt_len, s, pos);

      thistab = -1;

      switch (c = getkey ())
        {
        case KBD_NOKEY:
          break;
        case KBD_CTRL | 'z':
          FUNCALL (suspend_emacs);
          break;
        case KBD_RET:
          term_move (term_height () - 1, 0);
          term_clrtoeol ();
          if (saved)
            astr_delete (saved);
          return as;
        case KBD_CANCEL:
          term_move (term_height () - 1, 0);
          term_clrtoeol ();
          if (saved)
            astr_delete (saved);
          astr_delete (as);
          return NULL;
        case KBD_CTRL | 'a':
        case KBD_HOME:
          pos = 0;
          break;
        case KBD_CTRL | 'e':
        case KBD_END:
          pos = astr_len (as);
          break;
        case KBD_CTRL | 'b':
        case KBD_LEFT:
          if (pos > 0)
            --pos;
          else
            ding ();
          break;
        case KBD_CTRL | 'f':
        case KBD_RIGHT:
          if (pos < astr_len (as))
            ++pos;
          else
            ding ();
          break;
        case KBD_CTRL | 'k':
          /* FIXME: do kill-register save. */
          if (pos < astr_len (as))
            astr_truncate (as, pos);
          else
            ding ();
          break;
        case KBD_BS:
          if (pos > 0)
            astr_remove (as, --pos, 1);
          else
            ding ();
          break;
        case KBD_CTRL | 'd':
        case KBD_DEL:
          if (pos < astr_len (as))
            astr_remove (as, pos, 1);
          else
            ding ();
          break;
        case KBD_INS:
          overwrite_mode = overwrite_mode ? 0 : 1;
          break;
        case KBD_META | 'v':
        case KBD_PGUP:
          if (cp == NULL)
            {
              ding ();
              break;
            }

          if (get_completion_flags (cp) & CFLAG_POPPEDUP)
            {
              completion_scroll_down ();
              thistab = lasttab;
            }
          break;
        case KBD_CTRL | 'v':
        case KBD_PGDN:
          if (cp == NULL)
            {
              ding ();
              break;
            }

          if (get_completion_flags (cp) & CFLAG_POPPEDUP)
            {
              completion_scroll_up ();
              thistab = lasttab;
            }
          break;
        case KBD_UP:
        case KBD_META | 'p':
          if (hp)
            {
              const char *elem = previous_history_element (hp);
              if (elem)
                {
                  if (!saved)
                    saved = astr_cpy (astr_new (), as);

                  astr_cpy_cstr (as, elem);
                }
            }
          break;
        case KBD_DOWN:
        case KBD_META | 'n':
          if (hp)
            {
              const char *elem = next_history_element (hp);
              if (elem)
                astr_cpy_cstr (as, elem);
              else if (saved)
                {
                  astr_cpy (as, saved);
                  astr_delete (saved);
                  saved = NULL;
                }
            }
          break;
        case KBD_TAB:
        got_tab:
          if (cp == NULL)
            {
              ding ();
              break;
            }

          if (lasttab != -1 && lasttab != COMPLETION_NOTMATCHED
              && get_completion_flags (cp) & CFLAG_POPPEDUP)
            {
              completion_scroll_up ();
              thistab = lasttab;
            }
          else
            {
              astr bs = astr_new ();
              astr_cpy (bs, as);
              thistab = completion_try (cp, bs, true);
              astr_delete (bs);
              switch (thistab)
                {
                case COMPLETION_MATCHED:
                case COMPLETION_MATCHEDNONUNIQUE:
                case COMPLETION_NONUNIQUE:
                  {
                    bs = astr_new ();
                    if (get_completion_flags (cp) & CFLAG_FILENAME)
                      astr_cat (bs, get_completion_path (cp));
                    astr_ncat_cstr (bs, get_completion_match (cp), get_completion_matchsize (cp));
                    if (strncmp (astr_cstr (as), astr_cstr (bs),
                                 astr_len (bs)) != 0)
                      thistab = -1;
                    astr_delete (as);
                    as = bs;
                    pos = astr_len (as);
                    break;
                  }
                case COMPLETION_NOTMATCHED:
                  ding ();
                }
            }
          break;
        case ' ':
          if (cp != NULL)
            goto got_tab;
          /* FALLTHROUGH */
        default:
          if (c > 255 || !isprint (c))
            {
              ding ();
              break;
            }
          astr_insert_char (as, pos++, c);
          if (overwrite_mode && pos != astr_len (as))
            astr_remove (as, pos, 1);
        }

      lasttab = thistab;
    }
}