コード例 #1
0
/*
 *  This function is only used when the input data is not PostScript. Then it
 *  runs a filter which converts non-PostScript files into PostScript. The user
 *  can choose which filter he wants to use. The filter command line is
 *  provided by 'fileconverter'.
 */
void get_fileconverter_handle(const char *alreadyread, FILE **fd, pid_t *pid)
{
    pid_t kid1;
    FILE *kid1out;
    const char *pagesize;
    char *fileconv;
    kid1_userdata_t kid1_userdata;

    _log("\nStarting converter for non-PostScript files\n");

    if (isempty(fileconverter) && !guess_fileconverter())
        rip_die(EXIT_PRNERR_NORETRY_BAD_SETTINGS, "Cannot convert file to "
                "Postscript (missing fileconverter).");

    /* Use wider margins so that the pages come out completely on every printer
     * model (especially HP inkjets) */
    pagesize = option_get_value(find_option("PageSize"), optionset("header"));
    if (pagesize && startswith(fileconverter, "a2ps")) {
        if (!strcasecmp(pagesize, "letter"))
            pagesize = "Letterdj";
        else if (!strcasecmp(pagesize, "a4"))
            pagesize = "A4dj";
    }

    if (do_docs)
        snprintf(get_current_job()->title, 128, "Documentation for the %s", printer_model);

    fileconv = fileconverter_from_template(fileconverter, pagesize, get_current_job()->title);

    kid1_userdata.fileconv = fileconv;
    kid1_userdata.alreadyread = alreadyread;
    kid1 = start_process("kid1", exec_kid1, &kid1_userdata, NULL, &kid1out);
    if (kid1 < 0)
        rip_die(EXIT_PRNERR_NORETRY_BAD_SETTINGS, "Cannot convert file to "
                "Postscript (Cannot fork for kid1!)\n");

    *fd = kid1out;
    *pid = kid1;

    free(fileconv);
}
コード例 #2
0
ファイル: char.cpp プロジェクト: cwc/OmegaRPG
/* set player to begin with */
bool initplayer(void)
{
    int i;
    int oldchar=false;
    FILE *fd;
    char *lname;
    int ret_value = false;

    lname = getlogin();

#if !defined(WIN32)
    // Get the login name if getlogin() failed
    if (!lname || strlen(lname) == 0)
    {
        struct passwd *dastuff;

        dastuff = getpwuid(getuid());
        lname = dastuff->pw_name;
    }
#endif

    strcpy(Player.name,lname);
    if (Player.name[0] >= 'a' && Player.name[0] <= 'z')
        Player.name[0] += 'A'-'a'; /* capitalise 1st letter */
    Player.itemweight = 0;
    Player.food = 36;
    Player.packptr = 0;
    Behavior = -1;
    Player.options = 0;
    for (i=0; i<MAXITEMS; i++)
        Player.possessions[i] = NULL;
    for (i=0; i<MAXPACK; i++)
        Player.pack[i] = NULL;
    for (i=0; i<NUMIMMUNITIES; i++) Player.immunity[i] = 0;
    for (i=0; i<NUMSTATI; i++) Player.status[i] = 0;
    for (i=0; i<NUMRANKS; i++) {
        Player.rank[i] = 0;
        Player.guildxp[i] = 0;
    }
    Player.patron = 0;
    Player.alignment = 0;
    Player.cash = 250;
    change_to_user_perms();
    if ((fd=omegarc_check())!=NULL) {
        fread((char *)&i,sizeof(int),1,fd);
        if (i != VERSION) {
            print1("Out of date .omegarc! Make another!");
            morewait();
        }
        else {
            oldchar = true;
            fread((char *)&Player,sizeof(Player),1,fd);
            fread((char *)&Searchnum,sizeof(int),1,fd);
            fread((char *)&Verbosity,sizeof(char),1,fd);
            strcpy(Player.name,lname);
            if (Player.name[0] >= 'a' && Player.name[0] <= 'z')
                Player.name[0] += 'A'-'a'; /* capitalise 1st letter */
        }
        fclose(fd);
    }
    change_to_game_perms();

    // Zop: initstats() can load a save file, so this block needs to precede the function
    /* DAG - put the code back in the same place, rather than duplicating */
    Searchnum = max(1,min(9,Searchnum));
    Player.hp = Player.maxhp = Player.maxcon;
    Player.mana = Player.maxmana = calcmana();
    Player.click = 1;
    strcpy(Player.combatManeuvers,"CCBC");
    calc_melee();
    ScreenOffset = -1000;	/* to force a redraw */

    if (! oldchar) {
        optionset(RUNSTOP);
        optionset(CONFIRM);
        optionset(SHOW_COLOUR);
        ret_value = initstats() ; /* RM 04-19-2000:loading patch */ /* DAG */
    }

    return ret_value > 0; /* RM 04-19-2000: loading patch */ /* DAG */
}
コード例 #3
0
ファイル: char.c プロジェクト: DavidKinder/Omega
/* set player to begin with */
void initplayer()
{
  int i;
  int oldchar=FALSE;
  FILE *fd;
  char *lname;
#if !defined(MSDOS) && !defined(_WIN32)
  struct passwd *dastuff;
#endif

  lname = getlogin();
#if !defined(MSDOS) && !defined(_WIN32)
  if (!lname || strlen(lname) == 0)
  {
       dastuff = getpwuid(getuid());
       lname = dastuff->pw_name;
  }
#endif
  strcpy(Player.name,lname);
  if (Player.name[0] >= 'a' && Player.name[0] <= 'z')
       Player.name[0] += 'A'-'a'; /* capitalise 1st letter */
  Player.itemweight = 0;
  Player.food = 36; 
  Player.packptr = 0;
  Behavior = -1;
  Player.options = 0;
  for (i=0;i<MAXITEMS;i++)
    Player.possessions[i] = NULL;
  for (i=0;i<MAXPACK;i++)
    Player.pack[i] = NULL;
  for (i=0;i<NUMIMMUNITIES;i++) Player.immunity[i] = 0;
  for (i=0;i<NUMSTATI;i++) Player.status[i] = 0;
  for (i=0;i<NUMRANKS;i++) {
    Player.rank[i] = 0;
    Player.guildxp[i] = 0;
  }
  Player.patron = 0;
  Player.alignment = 0;
  Player.cash = 250;
  change_to_user_perms();
  if ((fd=omegarc_check())!=NULL) {
    fread((char *)&i,sizeof(int),1,fd);
    if (i != VERSION) {
#if defined(MSDOS) || defined(AMIGA) || defined(_WIN32)
      print1("Out of date omega.rc! Make another!");
#else
      print1("Out of date .omegarc! Make another!");
#endif
      morewait();
    }
    else {
      oldchar = TRUE;
      fread((char *)&Player,sizeof(Player),1,fd);
      fread((char *)&Searchnum,sizeof(int),1,fd);
      fread((char *)&Verbosity,sizeof(char),1,fd);
      strcpy(Player.name,lname);
      if (Player.name[0] >= 'a' && Player.name[0] <= 'z')
	   Player.name[0] += 'A'-'a'; /* capitalise 1st letter */
    }
    fclose(fd);
  }
  change_to_game_perms();
  if (! oldchar) {
    optionset(RUNSTOP);
    optionset(CONFIRM);
#ifdef COMPRESS_SAVE_FILES
    optionset(COMPRESS_OPTION);
#endif
#if defined(MSDOS) || defined(AMIGA) || defined(_WIN32)
    optionset(SHOW_COLOUR);
#endif
    initstats();
  }
  Searchnum = max(1,min(9,Searchnum));
  Player.hp = Player.maxhp = Player.maxcon;
  Player.mana = Player.maxmana = calcmana();
  Player.click = 1;
  strcpy(Player.meleestr,"CCBC");
  calc_melee();
  ScreenOffset = -1000;	/* to force a redraw */
}