FreeBSD/sbin/atm/atmconfig/main.c
/*
 * Go to that position
 *
 * We can go either to the original help file or back in the current file.
 */
Go to that position
We can go either to the original help file or back in the current file.
Go to that position We can go either to the original help file or back in the current file .
static void
help_file_seek(struct help_file *hp, struct help_pos *pos)
{
	hp->p_start = pos->p_start;
	hp->p_end = pos->p_end;
	hp->fcnt = pos->fcnt;
	if (hp->dir != NULL) {
		free(hp->dirname);
		closedir(hp->dir);
		hp->dir = NULL;
	}
	if (hp->fp != NULL &&strcmp(hp->fname, pos->fname) != 0) {
		free(hp->fname);
		fclose(hp->fp);
		hp->fp = NULL;
	}
	if (hp->fp == NULL) {
		if ((hp->fname = strdup(pos->fname)) == NULL)
			err(1, NULL);
		if ((hp->fp = fopen(hp->fname, "r")) == NULL)
			err(1, "reopen %s", hp->fname);
	}
	if (fseeko(hp->fp, pos->pos, SEEK_SET) == -1)
		err(1, "seek %s", hp->fname);
	if (pos->fcnt == 1)
		hp->file_state = 1;
	else
		hp->file_state = 3;
}
static void help_file_seek ( struct help_file * hp , struct help_pos * pos ) { hp -> p_start = pos -> p_start ; hp -> p_end = pos -> p_end ; hp -> fcnt = pos -> fcnt ; if ( hp -> dir != NULL ) { free ( hp -> dirname ) ; closedir ( hp -> dir ) ; hp -> dir = NULL ; } if ( hp -> fp != NULL && strcmp ( hp -> fname , pos -> fname ) != 0 ) { free ( hp -> fname ) ; fclose ( hp -> fp ) ; hp -> fp = NULL ; } if ( hp -> fp == NULL ) { if ( ( hp -> fname = strdup ( pos -> fname ) ) == NULL ) err ( 1 , NULL ) ; if ( ( hp -> fp = fopen ( hp -> fname , " " ) ) == NULL ) err ( 1 , " " , hp -> fname ) ; } if ( fseeko ( hp -> fp , pos -> pos , SEEK_SET ) == -1 ) err ( 1 , " " , hp -> fname ) ; if ( pos -> fcnt == 1 ) hp -> file_state = 1 ; else hp -> file_state = 3 ; }
Go to that position
 We can go either to the original help file or back in the current file.
Go to that position We can go either to the original help file or back in the current file .
/* go back to state 1 */ /* lock */