Beispiel #1
0
void dumb_init_pictures (char *filename)
{
    FILE *file = NULL;
    int success = FALSE;
    unsigned char gheader[16];
    unsigned char *raw_info = NULL;
    int i, entry_size, flags;
    float x_scaler, y_scaler;

    do {
        if ((h_version != V6)
        || !filename
        || ((file = fopen (filename, "rb")) == NULL)
        || (fread(&gheader, sizeof (gheader), 1, file) != 1))
            break;

        num_pictures = lookupw(gheader, PIC_FILE_HEADER_NUM_IMAGES);
        entry_size = lookupb(gheader, PIC_FILE_HEADER_ENTRY_SIZE);
        flags = lookupb(gheader, PIC_FILE_HEADER_FLAGS);

        raw_info = malloc(num_pictures * entry_size);

        if (fread(raw_info, num_pictures * entry_size, 1, file) != 1)
            break;

        pict_info = malloc((num_pictures + 1) * sizeof(*pict_info));
        pict_info[0].z_num = 0;
        pict_info[0].height = num_pictures;
        pict_info[0].width = lookupw(gheader, PIC_FILE_HEADER_VERSION);

        y_scaler = h_screen_rows / 200.0;
        x_scaler = h_screen_cols / ((flags & 0x08) ? 640.0 : 320.0);

        /* Copy and scale.  */
        for (i = 1; i <= num_pictures; i++) {
            unsigned char *p = raw_info + entry_size * (i - 1);
            pict_info[i].z_num = lookupw(p, PIC_HEADER_NUMBER);
            pict_info[i].orig_height = lookupw(p, PIC_HEADER_HEIGHT);
            pict_info[i].orig_width = lookupw(p, PIC_HEADER_WIDTH);
            pict_info[i].height = pict_info[i].orig_height * y_scaler + .5;
            pict_info[i].width = pict_info[i].orig_width * x_scaler + .5;
        }
        success = TRUE;
    } while (0);
    if (file)
        fclose(file);
    if (raw_info)
        free(raw_info);
    if (success)
        h_config |= CONFIG_PICTURES;
    else {
        h_flags &= ~GRAPHICS_FLAG;
        if (filename)
            PRINT_ALT("Warning: could not read graphics file %s\n", filename);
    }
}
Beispiel #2
0
bool_t lookupw_1_svc(char **argp, char **result, struct svc_req *rqstp)
{
	
	*result = lookupw (*argp);

	return 1;
}
Beispiel #3
0
/*------------------------------------------------------------------------
 * main - insert, delete, or look up words in a dictionary as specified
 *------------------------------------------------------------------------
 */
int
main(int argc, char *argv[])
{
	char	word[MAXWORD+1]; /* space to hold word from input line	*/
	char	cmd;
	int	wrdlen;		/* length of input word			*/

      /* set up connection for remote procedure call  */
 
       handle = clnt_create(RMACHINE, RDICTPROG, RDICTVERS, "tcp");
       if (handle == 0) {
               printf("Could not contact remote program.\n");
               exit(1);
       }

	while (1) {
		wrdlen = nextin(&cmd, word);
		if (wrdlen < 0)
			exit(0);
		word[wrdlen] = '\0';
		switch (cmd) {
		case 'I':	/* "initialize" */
			initw();
			printf("Dictionary initialized to empty.\n");
			break;
		case 'i':	/* "insert" */
			insertw(word);
			printf("%s inserted.\n",word);
			break;
		case 'd':	/* "delete" */
			if (deletew(word))
				printf("%s deleted.\n",word);
			else
				printf("%s not found.\n",word);
			break;
		case 'l':	/* "lookup" */
			if (lookupw(word))
				printf("%s was found.\n",word);
			else
				printf("%s was not found.\n",word);
			break;
		case 'q':	/* quit */
			printf("program quits.\n");
			exit(0);
		default:	/* illegal input */
			printf("command %c invalid.\n", cmd);
			break;
		}
	}
}
Beispiel #4
0
/*------------------------------------------------------------------------
 * main - insert, delete, or look up words in a dictionary as specified
 *------------------------------------------------------------------------
 */
int
main(int argc, char argv[])
{
	char	word[MAXWORD+1]; /* space to hold word from input line	*/
	char	cmd;
	int	wrdlen;		/* length of input word			*/

	while (1) {
		wrdlen = nextin(&cmd, word);
		if (wrdlen < 0)
			exit(0);
		word[wrdlen] = '\0';
		switch (cmd) {
		case 'I':	/* "initialize" */
			initw();
			printf("Dictionary initialized to empty.\n");
			break;
		case 'i':	/* "insert" */
			insertw(word);
			printf("%s inserted.\n",word);
			break;
		case 'd':	/* "delete" */
			if (deletew(word))
				printf("%s deleted.\n",word);
			else
				printf("%s not found.\n",word);
			break;
		case 'l':	/* "lookup" */
			if (lookupw(word))
				printf("%s was found.\n",word);
			else
				printf("%s was not found.\n",word);
			break;
		case 'q':	/* quit */
			printf("program quits.\n");
			exit(0);
		default:	/* illegal input */
			printf("command %c invalid.\n", cmd);
			break;
		}
	}
}
Beispiel #5
0
/*------------------------------------------------------------------------
 * lookupw_1_svc -  server side interface to remote procedure lookupw
 *------------------------------------------------------------------------
 */
int	*
lookupw_1_svc(char **w, struct svc_req *rqstp)
{
	retcode = lookupw(*(char**)w);
	return &retcode;
}
Beispiel #6
0
bool_t
lookupw_1_svc(char **w,int *ptr_retcode,struct svc_req *rqstp)
{
    *ptr_retcode=lookupw(*(char **)w);
    return(TRUE);
}