购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008 QQ号:85585969
函数结构:UF_PART_ask_nth_history( UF_PART_history_list_p_t history_list, int index, char * * program, char * * user, char * * machine, int * version, int * gmtime) 函数说明:
返回一个特定的信息保存历史从给定的历史记录列表对象。该history_list参数必须是UF_PART_history_list_p_t已由UF_PART_create_history_list和创建的变量与UF_PART_ask_part_history填充。索引参数定义“拯救”被询问时并的范围可以从0为num - 1,其中num是历史数通过UF_PART_ask_num_histories返回。该历史存储按时间倒序(最近的历史首先,在指数= 0)。历史上第一个也是特殊的,因为它表示当部分是加载在这个环节,而不是其他哪个历史部分被保存时表示。程序,用户和机器变量已存储在其中的代表节目,用户字符串(字符变量)的地址,和机器类型要求的“拯救”的部分。这些地址实际上的history_list对象内的地址这些价值,不应被这种调用者修改或释放常规。如果要修改这些变量返回的值,使用的strcpy复制它们,然后操纵副本。
函数参数:
第1个参数为输入:
history_list代表参数变量,UF_PART_history_list_p_t 为输入参数类型,它包含部分(由UF_PART_ask_part_history获得)保存信息的历史记录列表对象的地址。
第2个参数为输入:
输入int 整数型的参数,参数的变量格式为index,指数(从零开始)保存为其请求信息的特定部分。
第3个参数为输出:
输出char * * 字符类型的参数,参数的变量格式为program,一个指针到其中存储有保存该版本的部分的程序的名称的地址的字符(char)的变量的地址。
第4个参数为输出:
输出char * * 字符类型的参数,参数的变量格式为user,一个指针到其中存放谁救了这个版本的部分用户名的地址的字符(字符)变量的地址。
第5个参数为输出:
输出char * * 字符类型的参数,参数的变量格式为machine,一个指针到它存储在其上保存的这个版本的部分的机种名称的地址的字符(char)的变量的地址。
第6个参数为输出:
输出int * 整数型的参数,参数的变量格式为version,int变量的地址输入到其中存储与此版本的部分相关联的版本号。
第7个参数为输出:
输出int * 整数型的参数,参数的变量格式为gmtime,成存储与所请求的“保存”的一部分的相关联的时间int变量的地址。该值是自1970年1月1日,12:00 AM GMT的秒数。请参见标准UNIX例程time.h中包括程序来处理和显示时间值文件。
UF_PART_ask_nth_history函数实例代码演示:
在所有当前加载部分下面的例子周期其打印保存历史。它分配一个history_list对象,然后,在会话中的每个部分,获得其保存历史和打印信息。
[quote]
#include <stdio.h>
#include <time.h>
#include <uf.h>
#include <uf_defs.h>
#include <uf_part.h>
static char title0[] =
"\nPart History for part: %s\n";
static char title1[] =
"Version Time/Date Machine User
Program";
static char title2[] =
"------- --------------- ------- ----
-------";
static char format[] =
"%7d %-15.15s %-7.7s %-20.20s %s\n";
static char time_format[] = "%d %b %y %H:%M";
#define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))
static int report( char *file, int line, char *call, int irc)
{
if (irc)
{
char messg[133];
printf("%s, line %d: %s\n", file, line, call);
(UF_get_fail_message(irc, messg)) ?
printf(" returned a %d\n", irc) :
printf(" returned error %d: %s\n", irc, messg);
}
return(irc);
}
static void do_ugopen_api(void)
{
UF_PART_history_list_p_t history_list = NULL;
char part_fspec[MAX_FSPEC_SIZE+1];
char time_buff[21];
struct tm *time_ptr;
time_t displayed_time;
char *program, *user, *machine;
int vers_num, vers_time;
int num_parts, num_hists;
int curr_part, curr_hist;
tag_t part;
/* Get the total number of parts loaded in the current session.
*/
num_parts = UF_PART_ask_num_parts();
for ( curr_part=0 ; curr_part < num_parts ; curr_part++ )
{
/* Get the part tag and part name of each loaded part. */
part = UF_PART_ask_nth_part( curr_part );
UF_PART_ask_part_name( part, part_fspec );
printf( title0, part_fspec );
/* Create the history list if it has not been created. */
if( !history_list )
{
UF_CALL(UF_PART_create_history_list( &history_list ));
}
/* Clear the history list of the previous part. */
UF_CALL(UF_PART_clear_history_list( history_list ));
/* Get the history of the current part. */
UF_CALL(UF_PART_ask_part_history( part, history_list ));
/* Get the total number of save histories of the part. */
UF_CALL(UF_PART_ask_num_histories( history_list, &num_hists ));
/* Get information about each particular save history and
print a report.
*/
for ( curr_hist=0 ; curr_hist < num_hists ; curr_hist++ )
{
UF_PART_ask_nth_history( history_list, curr_hist,
&program, &user, &machine,
&vers_num, &vers_time );
displayed_time = (time_t) vers_time;
time_ptr = localtime ( &displayed_time );
strftime( time_buff, sizeof(time_buff),
time_format, time_ptr );
if( curr_hist == 0 )
{
printf("\n%s\n%s\n", title1, title2 );
}
printf(format,vers_num,time_buff,machine,user,program);
}
}
/* Deallocate memory for the history list. */
if ( history_list ) UF_PART_delete_history_list(history_list);
}
/*ARGSUSED*/
void ufusr(char *param, int *retcode, int param_len)
{
if (!UF_CALL(UF_initialize()))
{
do_ugopen_api();
UF_CALL(UF_terminate());
}
}
int ufusr_ask_unload(void)
{
return (UF_UNLOAD_IMMEDIATELY);
}
[/quote]