コード例 #1
0
ファイル: sysbs.c プロジェクト: hardbol/spitbol
zysbs()
{
    register int c;
    register struct fcblk *fcb = WA(struct fcblk *);
    register struct ioblk *iob = ((struct ioblk *) (fcb->iob));

    // ensure the file is open
    if ( !(iob->flg1 & IO_OPN) )
        return EXIT_1;

    if (!testty(iob->fdn)
            || iob->flg2 & IO_PIP				// not allowed on pipes
       )
        return EXIT_2;						// character device

    if (fcb->mode) {						// if line mode

        /*
         * If the characters immediately preceding the current position
         * are end-of-line characters, ignore them before starting scan
         * for beginning of record.
         */
        if ((c = back(iob)) < 0)
            return c + RET_BIAS;			// beginning of file
        if (c == EOL)
            if ((c = back(iob)) < 0)
                return c + RET_BIAS;

        /*
         * Here with c containing the first character of the record
         * we should examine.
         */
        do {
            if (c == EOL)
                break;
        } while ((c = back(iob)) >= 0);

        if (c >= 0)
            doset(iob, 1L, 1);				// advance past EOL char
        else
            return c + RET_BIAS;
    }

    else {									// if raw mode
        if (doset(iob, -fcb->rsz, 1) < 0L)	// just move back record length
            return EXIT_1;					// I/O error
    }

    return NORMAL_RETURN;
}
コード例 #2
0
ファイル: wh8.cpp プロジェクト: Ancient/NetGuard
char *NetGuard_Command_Input_WH8::doportset(char *ip,char *oid, int port, char *value) {
    char *query;
    char *tmpresult;

    query = (char*)calloc(strlen(oid)+10,sizeof(char));
    sprintf(query,oid,port);
    tmpresult = doset(ip,query,value);
    free(query);
    return tmpresult;
}
コード例 #3
0
ファイル: sysrw.c プロジェクト: daveshields/mbol
zysrw()
{
    REGISTER struct fcblk *fcb = WA(struct fcblk *);
    REGISTER struct ioblk *iob = MK_MP(fcb->iob, struct ioblk *);

    /* ensure the file is open */
    if (!(iob->flg1 & IO_OPN))
	return EXI_1;

    /* see if this file can be LSEEK'ed */
    if (LSEEK(iob->fdn, (FILEPOS) 0, 1) < (FILEPOS) 0)
	return EXI_2;

    /* seek to the beginning */
    if (doset(iob, 0L, 0) == (FILEPOS) - 1)
	return EXI_3;

    return EXI_0;
}
コード例 #4
0
ファイル: SYSRW.C プロジェクト: spitbol/88-source
zysrw()
{
	register struct fcblk *fcb = WA (struct fcblk *);
	register struct ioblk *iob = MK_MP(fcb->iob, struct ioblk *);

	/* ensure the file is open */
	if ( !(iob->flg1 & IO_OPN) )
		return EXIT_1;

   /* see if this file can be LSEEK'ed */
   if ( LSEEK(iob->fdn, (FILEPOS)0, 1) < (FILEPOS)0 )
		return EXIT_2;

	/* seek to the beginning */
   if (doset( iob, 0L, 0 ) == (FILEPOS)-1)
		return EXIT_3;

	return NORMAL_RETURN;
}
コード例 #5
0
ファイル: vulture_win.cpp プロジェクト: DanielT/Vulture
/* show a main menu with common options when the user presses esc */
void vulture_show_mainmenu()
{
	int winid, n;
	anything any;
	menu_item *selected;

	winid = vulture_create_nhwindow(NHW_MENU);
	vulture_start_menu(winid);
	
	any.a_int = 1;
	vulture_add_menu(winid, NO_GLYPH, &any, 'h', 0, ATR_BOLD,
					"Help", MENU_UNSELECTED);
	any.a_int = 2;
	vulture_add_menu(winid, NO_GLYPH, &any, 'O', 0, ATR_BOLD,
					"Options", MENU_UNSELECTED);
	any.a_int = 3;
	vulture_add_menu(winid, NO_GLYPH, &any, 'I', 0, ATR_BOLD,
					"Interface options", MENU_UNSELECTED);
	any.a_int = 4;
	vulture_add_menu(winid, NO_GLYPH, &any, 'S', 0, ATR_BOLD,
					"Save & Quit", MENU_UNSELECTED);
	any.a_int = 5;
	vulture_add_menu(winid, NO_GLYPH, &any, 'Q', 0, ATR_BOLD,
					"Quit", MENU_UNSELECTED);

	vulture_end_menu(winid, "Main menu");
	n = vulture_select_menu(winid, PICK_ONE, &selected);
	vulture_destroy_nhwindow(winid);

	if (n < 1)
		return;

	switch(selected[0].item.a_int)
	{
		case 1: dohelp(); break;
		case 2: doset(); break;
		case 3: vulture_iface_opts(); break;
		case 4: dosave(); break;
		case 5: done2(); break;
	}
}
コード例 #6
0
ファイル: mhmain.c プロジェクト: Elronnd/nethack-360-nao
LRESULT
onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
    int wmId, wmEvent;
    PNHMainWindow data;

    data = (PNHMainWindow) GetWindowLong(hWnd, GWL_USERDATA);
    wmId = LOWORD(wParam);
    wmEvent = HIWORD(wParam);

    // process the menu selections:
    switch (wmId) {
    case IDM_ABOUT:
        DialogBox(GetNHApp()->hApp, (LPCTSTR) IDD_ABOUTBOX, hWnd,
                  (DLGPROC) About);
        break;

    case IDM_EXIT:
        done2();
        break;

    case IDM_SAVE:
        dosave();
        break;

    case IDM_MAP_TILES:
    case IDM_MAP_ASCII4X6:
    case IDM_MAP_ASCII6X8:
    case IDM_MAP_ASCII8X8:
    case IDM_MAP_ASCII16X8:
    case IDM_MAP_ASCII7X12:
    case IDM_MAP_ASCII8X12:
    case IDM_MAP_ASCII12X16:
    case IDM_MAP_ASCII16X12:
    case IDM_MAP_ASCII10X18:
        mswin_select_map_mode(menuid2mapmode(wmId));
        break;

    case IDM_MAP_FIT_TO_SCREEN:
        if (IS_MAP_FIT_TO_SCREEN(iflags.wc_map_mode)) {
            mswin_select_map_mode(IS_MAP_ASCII(iflags.wc_map_mode)
                                      ? data->mapAcsiiModeSave
                                      : MAP_MODE_TILES);
        } else {
            mswin_select_map_mode(IS_MAP_ASCII(iflags.wc_map_mode)
                                      ? MAP_MODE_ASCII_FIT_TO_SCREEN
                                      : MAP_MODE_TILES_FIT_TO_SCREEN);
        }
        break;

    case IDM_VIEW_KEYPAD:
        GetNHApp()->bCmdPad = !GetNHApp()->bCmdPad;
        CheckMenuItem(
            _get_main_menu(ID_VIEW), IDM_VIEW_KEYPAD,
            MF_BYCOMMAND | (GetNHApp()->bCmdPad ? MF_CHECKED : MF_UNCHECKED));
        mswin_layout_main_window(GetNHApp()->hCmdWnd);
        break;

    case IDM_VIEW_OPTIONS:
        doset();
        break;

    case IDM_DIRECT_COMMAND: /* SmartPhone: display dialog to type in arbitary
                                command text */
        mswin_direct_command();
        break;

    case IDM_HELP_LONG:
        display_file(HELP, TRUE);
        break;

    case IDM_HELP_COMMANDS:
        display_file(SHELP, TRUE);
        break;

    case IDM_HELP_HISTORY:
        (void) dohistory();
        break;

    case IDM_HELP_INFO_CHAR:
        (void) dowhatis();
        break;

    case IDM_HELP_INFO_KEY:
        (void) dowhatdoes();
        break;

    case IDM_HELP_OPTIONS:
        option_help();
        break;

    case IDM_HELP_OPTIONS_LONG:
        display_file(OPTIONFILE, TRUE);
        break;

    case IDM_HELP_EXTCMD:
        (void) doextlist();
        break;

    case IDM_HELP_LICENSE:
        display_file(LICENSE, TRUE);
        break;

    case IDM_HELP_MENU:
        dohelp();
        break;

    default:
        return 1;
    }
    return 0;
}
コード例 #7
0
ファイル: gl_role.c プロジェクト: Arc0re/acehack
/**
   Runs before player selection, and is used to determine which game
   mode to play in. If the choice is to continue or start a new game, it
   sets the character name to determine which (currently unused name for
   the player = new game, currently used name = continue that game);
   otherwise, it implements the choice itself then either loops or
   exits.

   This is based on the tty code, except that it uses a menu rather
   than rendering the game mode selection by hand.
*/
void
Sdlgl_game_mode_selection()
{
  int c;
  char** saved;
  char** sp;
  int plname_in_saved = 0;
  int plname_was_explicit = !!*plname;
  (void) plname_was_explicit; /* TODO: use this */

  winid menuwin;
  int n;
  menu_item *selected;
  anything any;

  saved = get_saved_games();

  if (*plname && saved && *saved) {
    for (sp = saved; *sp; sp++) {
      /* Note that this means that public servers need to prevent two
         users with the same name but different capitalisation. (If
         they aren't, it's likely to cause problems anyway...) */
      if (!strcmpi(plname, *sp)) {
        plname_in_saved = 1;
        /* Fix capitalisation of the name to match the saved game. */
        strncpy(plname, *sp, sizeof(plname)-1);
      }
    }
  } else if (*plname) {
    set_savefile_name();
    /* Let's just try to open the savefile directly to see if it exists */
    plname_in_saved = verify_savefile();
  }

retry_mode_selection:;
reread_char:
  menuwin = create_nhwindow(NHW_MENU);
  any.a_void = 0;
  start_menu(menuwin);

  any.a_int = 'c';
  add_menu(menuwin, NO_GLYPH, &any, 'c', 0, ATR_NONE,
           "Continue game", MENU_UNSELECTED);
  any.a_int = 'n';
  add_menu(menuwin, NO_GLYPH, &any, 'n', 0, ATR_NONE,
           "New game", MENU_UNSELECTED);
  any.a_int = 't';
  add_menu(menuwin, NO_GLYPH, &any, 't', 0, ATR_NONE,
           "Tutorial", MENU_UNSELECTED);
  any.a_int = 'm';
  add_menu(menuwin, NO_GLYPH, &any, 'm', 0, ATR_NONE,
           "Other modes", MENU_UNSELECTED);

  any.a_void = 0;
  add_menu(menuwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", FALSE);

  any.a_int = 's';
  add_menu(menuwin, NO_GLYPH, &any, 's', 0, ATR_NONE,
           "Continue game", MENU_UNSELECTED);
  any.a_int = 'o';
  add_menu(menuwin, NO_GLYPH, &any, 'o', 0, ATR_NONE,
           "New game", MENU_UNSELECTED);
  any.a_int = '?';
  add_menu(menuwin, NO_GLYPH, &any, '?', 0, ATR_NONE,
           "Tutorial", MENU_UNSELECTED);
  any.a_int = 'q';
  add_menu(menuwin, NO_GLYPH, &any, 'q', 0, ATR_NONE,
           "Other modes", MENU_UNSELECTED);

  end_menu(menuwin, "Welcome to AceHack!");
  n = select_menu(menuwin, PICK_ONE, &selected);
  destroy_nhwindow(menuwin);

  if (n > 0) {
    c = selected[0].item.a_int;
    free((genericptr_t)selected);
  } else goto retry_mode_selection;

#if 0
  /* TODO: This is tty code for graying out unavailable options;
     we should do that in SDL/GL code too */
  {
    if (c == 1) { /* gray out if there's no game to continue */
      if (!*plname && (!saved || !*saved)) xputs("\033[31m");
      else if (*plname && !plname_in_saved) xputs("\033[31m");
      /* and bold if there is */
      else xputs("\033[1m");
    }
    else if (c == 2) { /* gray out if a game must be continued */
      if (*plname && plname_in_saved) xputs("\033[31m");
    }
    else xputc(c); /* low-level as codes are in the file itself */
  }
#endif

  switch (c) {
  case 'c': /* continue game */
    if (*plname && plname_in_saved) break; /* just load by name */
    if (!saved || !*saved) goto reread_char;
    if (*plname && !plname_in_saved) goto reread_char;
    if (!saved[1]) {
      /* only one game to continue */
      (void) strncpy(plname, *saved, sizeof(plname)-1);
    } else {
      /* we'll have to ask which game to continue */
      winid win;
      win = create_nhwindow(NHW_MENU);
      start_menu(win);
      any.a_void = 0;
      for (sp = saved; *sp; sp++) {
        any.a_void = (void*) *sp;
        add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, *sp, MENU_UNSELECTED);
      }
      end_menu(win, "Continue which saved game?");
      c = select_menu(win, PICK_ONE, &selected);
      destroy_nhwindow(win);
      if (c != 1) {
        free((genericptr_t) selected);
        goto retry_mode_selection;
      }
      (void) strncpy(plname, (char*)selected[0].item.a_void, sizeof(plname)-1);
      free((genericptr_t) selected);
    }
    break;
  case 'n': case 't': case 'm': /* the new game options */
    /* if the name is forced by the -u option, don't give an option to
       start a new game, as we're forced onto the existing game */
    if (*plname && plname_in_saved) goto reread_char;
    if (!*plname) {
      Sdlgl_askname();
      if (saved)
        for (sp = saved; *sp; sp++) {
          if (!strcmpi(plname, *sp)) {
            pline("A game is running with that name already.");
            Sdlgl_dismiss_nhwindow(NHW_MESSAGE); /* force a --More-- */
            *plname = 0;
            goto retry_mode_selection;
          }
        }
    }
    if (c == 'm') {
      pline("TODO: implement game mode selection here");
      goto retry_mode_selection;
      do {
        c = 0; /* read from keyboard */
        switch(c) {
          /* -D, -X on command line are overriden by selecting a normal game
             explicitly */
        case 'n': wizard = FALSE; discover = FALSE; break;
        case 't': break;
        case 'd':
#ifdef WIZARD
          /* The rules here are a little complex:
             - with no -u (local play, private server play), anyone
               can enter debug mode;
             - with -u set (generally public server play), only an
               authorized user can enter debug mode.
             Thus people can enter it freely in their own compiles,
             but on public servers likely only the admin can enter it,
             as only they can tweak the command line. (-D works too
             to enter wizmode, whatever the -u option, as if it's
             given the player has control over the command line anyway.) */
          if (plname_was_explicit && strcmpi(plname,WIZARD)) {
            extern int wiz_error_flag; /* from unixmain.c */
            wiz_error_flag = TRUE;
          } else {
            wizard = TRUE;
            c = 'n';
            break;
          }
          /*FALLTHRU*/
#endif /* otherwise fall through, as debug mode isn't compiled in */
        case 'x': discover = TRUE; c = 'n'; break;
        case 's': solo = TRUE; c = 'n'; break;
        case '\033': goto retry_mode_selection;
        default: continue;
        }
      } while (c != 'n' && c != 't');
    }
    if (c == 't') flags.tutorial = 1;
    break;
  case 's': /* show high score list */
    prscore_interactive();
    goto retry_mode_selection;
  case 'o': /* options */
    doset();
    goto retry_mode_selection;
  case '?': /* help */
    dohelp();
    Sdlgl_dismiss_nhwindow(NHW_MESSAGE); /* force a --More-- */
    goto retry_mode_selection;
  case 'q': case '\033': /* exit */
    /* This is the standard Sdlgl method of exiting. */
    Sdlgl_exit_nhwindows(0);
    terminate(EXIT_SUCCESS);
    /*NOTREACHED*/
  default:
    goto reread_char;
  }

  if (saved) free_saved_games(saved);
}
コード例 #8
0
ファイル: handlers.c プロジェクト: YauzZ/upb
bool upb_handlers_setendmsg(upb_handlers *h, upb_endmsg_handlerfunc *func,
                            upb_handlerattr *attr) {
  assert(!upb_handlers_isfrozen(h));
  return doset(h, UPB_ENDMSG_SELECTOR, NULL, UPB_HANDLER_INT32,
               (upb_func *)func, attr);
}
コード例 #9
0
ファイル: handlers.c プロジェクト: YauzZ/upb
bool upb_handlers_setstartmsg(upb_handlers *h, upb_startmsg_handlerfunc *func,
                              upb_handlerattr *attr) {
  return doset(h, UPB_STARTMSG_SELECTOR, NULL, UPB_HANDLER_INT32,
               (upb_func *)func, attr);
}
コード例 #10
0
ファイル: sysst.c プロジェクト: daveshields/mbol
zysst()

{
    IATYPE	whence, temp;
    FILEPOS  offset;
    register struct fcblk *fcb = WA (struct fcblk *);
    register struct ioblk *iob = MK_MP(fcb->iob, struct ioblk *);
    register struct icblk *icp;

    /* ensure iob is open, fail if unsuccessful */
    if ( !(iob->flg1 & IO_OPN) )
        return EXIT_3;

#if PIPES
    /* not allowed to do a set of a pipe */
    if ( iob->flg2 & IO_PIP )
        return EXIT_4;
#endif					/* PIPES */

    /* whence may come in either integer or string form */
    icp = WC( struct icblk * );
    if ( !getint(icp,&whence) )
        return EXIT_1;

#if SETREAL
    /* offset comes in as a real in RA */
    offset = RA(FILEPOS);
#else
    /* offset may come in either integer or string form */
    icp = WB( struct icblk * );
    if ( !getint(icp,&temp) ) {
        struct scblk *scp;
        scp = (struct scblk *)icp;
        if (!checkstr(scp) || scp->len != 1)
            return EXIT_1;
        temp = whence;
        switch (uppercase(scp->str[0])) {
        case 'P':
            whence = 0;
            break;

        case 'H':
            temp = (whence << 15) + ((int)doset(iob,0,1) & 0x7FFFL);
            whence = 0;
            break;

        case 'R':
            whence = 1;
            break;

        case 'E':
            whence = 2;
            break;

        case 'C':
            if ( fcb->mode == 0 && temp > 0 && temp <= (word)maxsize ) {
                fcb->rsz = temp;
                temp = 0;
                whence = 1;			/* return current position */
                break;
            }
            else {
                if (temp < 0 || temp > (word)maxsize)
                    return EXIT_2;
                else
                    return EXIT_1;
            }

        default:
            return EXIT_1;		/* Unrecognised control */
        }
    }
    offset = (FILEPOS)temp;
#endif
    /*  finally, set the file position  */
    offset = doset( iob, offset, (int)whence );

    /*  test for error.  01.02 */
    if ( offset < (FILEPOS)0 )
        return EXIT_5;
#if SETREAL
    /*  return resulting position in RA.  01.07  */
    SET_RA( offset );
#else
    /*  return resulting position in IA.  01.02  */
    SET_IA( (IATYPE)offset );
#endif

    /* normal return */
    return NORMAL_RETURN;
}