예제 #1
0
파일: curl_crtl_init.c 프로젝트: 2px/curl
/* How to simply create a logical name */
static int sys_crelnm
   (const char * logname,
    const char * value)
{
    int ret_val;
    const char * proc_table = "LNM$PROCESS_TABLE";
    struct dsc$descriptor_s proc_table_dsc;
    struct dsc$descriptor_s logname_dsc;
    struct itmlst_3 item_list[2];

    proc_table_dsc.dsc$a_pointer = (char *) proc_table;
    proc_table_dsc.dsc$w_length = strlen(proc_table);
    proc_table_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
    proc_table_dsc.dsc$b_class = DSC$K_CLASS_S;

    logname_dsc.dsc$a_pointer = (char *) logname;
    logname_dsc.dsc$w_length = strlen(logname);
    logname_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
    logname_dsc.dsc$b_class = DSC$K_CLASS_S;

    item_list[0].buflen = strlen(value);
    item_list[0].itmcode = LNM$_STRING;
    item_list[0].bufadr = (char *)value;
    item_list[0].retlen = NULL;

    item_list[1].buflen = 0;
    item_list[1].itmcode = 0;

    ret_val = SYS$CRELNM(NULL, &proc_table_dsc, &logname_dsc, NULL, item_list);

    return ret_val;
}
예제 #2
0
파일: HTVMSUtils.c 프로젝트: kotohvost/yui
/* PUBLIC							HTVMS_putenv()
**		Create logical name
** ON ENTRY:
**	string		name value pair separated by equal sign. 
**			"name=value"
**	
**
** ON EXIT:
**	0 		ok
**	1		failed
**	
*/
PUBLIC int HTVMS_putenv ARGS1(
	CONST char *, string)
{
    $DESCRIPTOR(job_table,"LNM$JOB");
    char * name = (char*)malloc(strlen(string)+1);
    char * value = (char*)malloc(strlen(string)+1);	/* Copies to hack */
    char * equal;
    long result = 1;

    /* separate pair */
    strcpy(name,string);
    equal = strchr(name,'=');
    if (equal)
    {
    ItemStruct ItemList[2];
    struct dsc$descriptor_s log_name;

       /* get value */
       *equal = '\0';
       strcpy(value,equal+1);

       /* fill logical name */       
       log_name.dsc$w_length = strlen(name);
       log_name.dsc$b_dtype = DSC$K_DTYPE_T;
       log_name.dsc$b_class = DSC$K_CLASS_S;
       log_name.dsc$a_pointer = name;

       /* fill Item */
       ItemList[0].BufferLength = strlen(value);
       ItemList[0].BufferAddress = value;
       ItemList[0].ReturnLengthAddress = 0;
       ItemList[0].ItemCode = LNM$_STRING;

       /* terminate list */
       ItemList[1].ItemCode = 0;
       ItemList[1].BufferLength = 0;

       /* put into job logical name table */
       result = SYS$CRELNM(0, &job_table, &log_name, 0, ItemList);
       if ((result == SS$_NORMAL) || (result == SS$_SUPERSEDE))
          result = 0;
       else
          result = 1;
    }    

    free(name);
    free(value);

    return(result);
}
예제 #3
0
/* vms_define() - assign a value to a logical name [define/process/user_mode] */
static u_long
vms_define( const char *log_name, const char *trans_val )
{
    Dsc log_dsc;
    static Descrip(lnmtable,"LNM$PROCESS_TABLE");
    static long attr = LNM$M_CONFINE;
    static Itm itemlist[] = { {sizeof attr,LNM$_ATTRIBUTES,&attr,0},
			      {0,LNM$_STRING,0,0}, {0,0} };
    static unsigned char acmode = PSL$C_USER;

    /* avoid "define SYS$OUTPUT sys$output:" for redundant ">sys$output:" */
    if (strncasecmp(log_name, trans_val, strlen(log_name)) == 0)
	return 0;

    log_dsc.len = strlen(log_dsc.adr = (char *)log_name);
    itemlist[1].buffer = (char *)trans_val;
    itemlist[1].len = strlen(trans_val);
    return SYS$CRELNM((u_long *)0, &lnmtable, &log_dsc, &acmode, itemlist);
}