⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bindery.c

📁 网络打印机及文件共享 C程序源代码 用于网络通信
💻 C
📖 第 1 页 / 共 3 页
字号:
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
#include <dos.h>

union  REGS    ipregs;
union  REGS    opregs;
struct SREGS   spregs;

struct DoubleWord
{
   unsigned int HiWord;
   unsigned int LoWord;
};
union  LongToWord
{
   unsigned long    dw;
   struct  DoubleWord w;
};

int  IntSwap();
long LongSwap();
void prin_secu();
int AddBinderyObjectToSet();
int ChangeBinderyObjectPassword();
int ChangeBinderySecurity();
int ChangePropertySecurity();
int CreateBinderyObject();
int CreateProperty();
int DeleteBinderyObject();
int DeleteBinderyObjectFromSet();
int DeleteProperty();
int GetBinderyObjectID();
int GetBinderyObjectName();
int ISBinderyObjectInSet();
int RenameBinderyObject();
int ReadPropertyValue();
int ScanBinderyObject();
int ScanProperty();
int VerifyBinderyObjectPassword();
int WritePropertyValue();
int CloseBindery();
int OpenBindery();
int GetBinderyAccessLevel();

void main()
{int choice,exitsign;
 char object_name[48],searchObjectName[48],new_object_name[48],member_object_name[48];
 char property_name[16],searchPropertyName[16];
 unsigned long object_ID,sequenceNumber;
 int object_type,searchObjectType, member_object_type,return_code;
 char object_flag,property_flag,is_set,objectHasProperties,propertyHasValue;
 char object_security,property_security,secu_low,secu_hign,access_level;
 char segmentNumber,moreSegments,propertyValue[128],erase_remaining_segments;
 char password[128],oldPassword[128], newPassword[128],ch;

 exitsign=0;
 while (exitsign==0)
 {
 clrscr();
 printf("\n\n\n                      The example for bindery DOS call\n\n\n");
 printf("   1. create a bindery object;        2. delete a bindery object;\n");
 printf("   3. Get bindery object ID;          4. Get bindery object name;\n");
 printf("   5. Scan bindery for object;        6. Rename bindery object;\n");
 printf("   7. Change bindery object security; 8. Create property;\n");
 printf("   9. Delete property;                10.Change property security;\n");
 printf("   11.Scan for property;              12.Read property value;\n");
 printf("   13.Write property value;           14.Verity bindery object passward;\n");
 printf("   15.change bindery object passward; 16.Add bindery object to set;\n");
 printf("   17.Delete bindery object from set; 18.Is bindery object in set;\n");
 printf("   19.Close bindery;                  20.Open bindery;\n");
 printf("   21.Get bindery access level;       22.Exit.\n\n\n\n\n");
 printf("                          Input your choice(1-22):");
 choice=0;
 scanf("%d",&choice);
 clrscr();
 switch (choice)
 {
 case 1:
    printf("\n\n                          Add a bindery object\n\n\n");
	printf("Please input the following datas: ");
	printf("\n\nobject_name:");
	scanf("%s",object_name);
	printf("\nobject_type(1-user/2-group):");
    scanf("%d",&object_type);
	printf("\nobject_flag(0-static/1-active):");
    scanf("%d",&object_flag);
	printf("\nobject_security:");
	printf("\nWho can read(0-anyone/1-logged_user/2-object_oneself/3-supervisor):");
    scanf("\n%c",&secu_low);
	printf("\nWho can write(0-anyone/1-logged_user/2-object_oneself/3-supervisor):");
    scanf("\n%c",&secu_hign);
	object_security=((secu_hign-0x30)<<4)|(secu_low-0x30);
	return_code=CreateBinderyObject(object_name, object_type, object_flag, object_security);
	if (return_code==0)
	   printf("\n\n                    Success,Press any key to continue!" );
	else
	   printf("\n\n                    Failure,Press any key to continue!");
	ch=getch();
    break;
 case 2:
    printf("\n\n                       Delete a bindery object\n\n\n");
	printf("Please input the following datas: ");
	printf("\n\nobject_name:");
	scanf("%s",object_name);
	printf("\nobject_type(1-user/2-group):");
    scanf("%d",&object_type);
	return_code=DeleteBinderyObject(object_name, object_type);
	if (return_code==0)
	   printf("\n\n                      Success,Press any key to continue!" );
	else
	   printf("\n\n                      Failure,Press any key to continue!");
	ch=getch();
	break;
 case 3:
    printf("\n\n                         Get bindery object ID\n\n\n");
	printf("Please input the following datas: ");
	printf("\n\nobject_name:");
	scanf("%s",object_name);
	printf("\nobject_type(1-user/2-group):");
    scanf("%d",&object_type);
	return_code=GetBinderyObjectID(object_name, object_type,&object_ID);
	if (return_code==0)
	   {printf("\n\nobject_ID:%lx",object_ID );
	   printf("\n\n                      Success,Press any key to continue!" );
	   }
	else
	   printf("\n\n                      Failure,Press any key to continue!");
	ch=getch();
	break;
 case 4:
    printf("\n\n                         Get bindery object name\n\n\n");
	printf("Please input the following datas: ");
	printf("\n\nobject_id:");
	scanf("%lx",&object_ID);
	return_code=GetBinderyObjectName(object_ID, object_name, object_type);
	if (return_code==0)
	   {printf("\n\nobject_name:%s",object_name );
	    printf("\n\n                     Success,Press any key to continue!" );
	   }
	else
	   printf("\n\n                      Failure,Press any key to continue!");
	ch=getch();
	break;
 case 5:
    printf("\n\n                         Scan bindery for object \n\n\n");
	printf("Please input the following datas: ");
	printf("\n\nobject_name:");
	scanf("%s",searchObjectName);
	printf("\nobject_type(1-user/2-group):");
    scanf("%d",&searchObjectType);
	object_ID=0xffffffff;
	ch='n';
	do
	{
	return_code=ScanBinderyObject(searchObjectName, searchObjectType, &object_ID, object_name,
		    &object_type, &objectHasProperties, &object_flag, &object_security);
	if (return_code==0)
	   {if (ch=='y')
           {printf("\n\nPress any key to show another object\n\n");
            ch=getch();
           }
        printf("\n\nobject_ID:%lx",object_ID );
	    printf("\n\nobject_name:%s",object_name );
	    switch (object_type)
	    {case 1:printf("\n\nobject_type:user");break;
	     case 2:printf("\n\nobject_type:group");break;
	     }
        if (object_flag==0)
     		printf("\n\nThe object is static!");
        else
	    	printf("\n\nThe object is dynatic!");
	    printf("\n\nobject_security:");
        prin_secu(object_security);
	    if (objectHasProperties==0)
		   printf("\n\nThe object has not properties!");
	    else
		   printf("\n\nThe object has properties!");
	    ch='y';
	   }
	}
    while (return_code==0);
	if (ch=='y')
	   printf("\n\n                        Success,Press any key to continue!" );
	else
	   printf("\n\n                        Failure,Press any key to continue!");
	ch=getch();
	break;
 case 6:
    printf("\n\n                           Rename a bindery object\n\n\n");
	printf("Please input the following datas: ");
	printf("\n\nobject_name:");
	scanf("%s",object_name);
	printf("\nobject_type(1-user/2-group):");
    scanf("%d",&object_type);
	printf("\nnew_object_name:");
	scanf("%s",new_object_name);
	return_code=RenameBinderyObject(object_name, new_object_name, object_type);
    if (return_code==0)
	   printf("\n\n                           Success,Press any key to continue!" );
	else
	   printf("\n\n                           Failure,Press any key to continue!");
	ch=getch();
	break;
 case 7:
    printf("\n\n                              Change bindery object security\n\n\n");
	printf("Please input the following datas: ");
	printf("\n\nobject_name:");
	scanf("%s",object_name);
	printf("\nobject_type(1-user/2-group):");
    scanf("%d",&object_type);
	printf("\nnew_object_security:");
	printf("\nWho can read(0-anyone/1-logged_user/2-object_oneself/3-supervisor):");
    scanf("\n%c",&secu_low);
	printf("\nWho can write(0-anyone/1-logged_user/2-object_oneself/3-supervisor):");
    scanf("\n%c",&secu_hign);
	object_security=((secu_hign-0x30)<<4)|(secu_low-0x30);
	return_code=ChangeBinderySecurity(object_name, object_type, object_security);
    if (return_code==0)
	   printf("\n\n                            Success,Press any key to continue!" );
	else
	   printf("\n\n                            Failure,Press any key to continue!");
	ch=getch();
    break;
 case 8:
    printf("\n\n                               Create property;\n\n\n");
	printf("Please input the following datas: ");
	printf("\n\nobject_name:");
	scanf("%s",object_name);
	printf("\nobject_type(1-user/2-group):");
	scanf("%d",&object_type);
	printf("\nproperty_name:");
	scanf("%s",property_name);
	printf("\nproperty_flag(0-static/1-active):");
	scanf("%d",&property_flag);
	printf("property_flag(0-item/1-set):");
	scanf("%d",&is_set);
	property_flag+=is_set<<1;
	printf("\nproperty_security:");
	printf("\nWho can read(0-anyone/1-logged_user/2-object_oneself/3-supervisor/4-netware):");
    scanf("\n%c",&secu_low);
	printf("\nWho can write(0-anyone/1-logged_user/2-object_oneself/3-supervisor/4-netware):");
    scanf("\n%c",&secu_hign);
	property_security=((secu_hign-0x30)<<4)|(secu_low-0x30);
	return_code=CreateProperty(object_name, object_type, property_name,
			      property_flag, property_security);
    if (return_code==0)
	   printf("\n\n                         Success,Press any key to continue!" );
	else
	   printf("\n\n                         Failure,Press any key to continue!");
	ch=getch();
	break;
 case 9:
    printf(" \n\n                           Delete property;\n\n\n");
	printf("Please input the following datas: ");
	printf("\n\nobject_name:");
	scanf("%s",object_name);
	printf("\nobject_type(1-user/2-group):");
	scanf("%d",&object_type);
	printf("\nproperty_name:");
	scanf("%s",property_name);
	return_code=DeleteProperty(object_name, object_type, property_name);
    if (return_code==0)
	   printf("\n\n                         Success,Press any key to continue!" );
	else
	   printf("\n\n                         Failure,Press any key to continue!");
	ch=getch();
	break;
 case 10:
    printf("\n\n                           Change property security;\n\n\n");
	printf("Please input the following datas: ");
	printf("\n\nobject_name:");
	scanf("%s",object_name);
	printf("\nobject_type(1-user/2-group):");
	scanf("%d",&object_type);
	printf("\nproperty_name:");
	scanf("%s",property_name);
	printf("\nnew_property_security:");
	printf("\nWho can read(0-anyone/1-logged_user/2-object_oneself/3-supervisor/4-netware):");
    scanf("\n%c",&secu_low);
	printf("\nWho can write(0-anyone/1-logged_user/2-object_oneself/3-supervisor/4-netware):");
    scanf("\n%c",&secu_hign);
	property_security=((secu_hign-0x30)<<4)|(secu_low-0x30);
	return_code=ChangePropertySecurity(object_name,object_type,property_name,property_security);
    if (return_code==0)
	   printf("\n\n                           Success,Press any key to continue!" );
	else
	   printf("\n\n                           Failure,Press any key to continue!");
	ch=getch();
	break;
 case 11:
    printf(" \n\n                             Scan for property;\n\n\n");
	printf("Please input the following datas: ");
	printf("\n\nobject_name:");
	scanf("%s",object_name);
	printf("\nobject_type(1-user/2-group):");
	scanf("%d",&object_type);
	printf("\nsearchproperty_name:");
	scanf("%s",searchPropertyName);
	sequenceNumber=0xffffffff;
	ch='n';
	do
	{
	return_code=ScanProperty(object_name,object_type,searchPropertyName,&sequenceNumber,property_name, &property_flag, &property_security, &propertyHasValue);
	if (return_code==0)
	   {if (ch=='y')
           {printf("\n\nPress any key to show another property\n\n");
            ch=getch();
           }
        ch='y';
	    printf("\n\nproperty_name:%s",property_name);
	    if (property_flag==0)
		   printf("   \nThe property is static!");
	    else
		   printf("   \nThe property is dynatic!");
	    printf("   \n\nproperty_security:");
        prin_secu(property_security);
	    if (propertyHasValue==0)
		   printf("   \n\n The property has not value!");
	    else
		   printf("    \n\nThe property has value!");
	   }
	}
	while (return_code==0);
	if (ch=='y')
	   printf("\n\n                         Success,Press any key to continue!" );
	else
	   printf("\n\n                         Failure,Press any key to continue!");
	ch=getch();
    break;
 case 12:
    printf("\n\n                            Read property value;\n\n\n");
	printf("Please input the following datas: ");
	printf("\n\nobject_name:");
	scanf("%s",object_name);
	printf("\nobject_type(1-user/2-group):");
	scanf("%d",&object_type);
	printf("\nproperty_name:");
	scanf("%s",property_name);
	segmentNumber=1;
	printf("\nproperty_value:");
	do
	{
	return_code=ReadPropertyValue(object_name, object_type, property_name, segmentNumber,
		      propertyValue, &moreSegments, &property_flag);
	if (return_code==0) printf("%s",propertyValue);
	segmentNumber+=1;
	}
	while ((return_code==0)&&(moreSegments==-1));
	if (return_code==0)
	   {if (property_flag==0)
		   printf("\nThe property is static!");
	    else
		   printf("\nThe property is dynatic!");
	    printf("\n\n                        Success,Press any key to continue!" );
	   }
	else
	   printf("\n\n                         Failure,Press any key to continue!");
	ch=getch();
	break;
 case 13:
    printf("\n\n                            Write property value;\n\n\n");
	printf("Please input the following datas: ");
	printf("\n\nobject_name:");
	scanf("%s",object_name);
	printf("\nobject_type(1-user/2-group):");
	scanf("%d",&object_type);
	printf("\nproperty_name:");
	scanf("%s",property_name);
	printf("\nerase remaining segments(y/n)?");
	ch=getch();
	if (ch=='Y'||ch=='y')
	   erase_remaining_segments=0;
	else
	   erase_remaining_segments=1;
	segmentNumber=1;
	do
	{
	printf("\nproperty_value:(128byte)");
	scanf("%s",propertyValue);
	return_code=WritePropertyValue(object_name, object_type, property_name,
		       segmentNumber, propertyValue,erase_remaining_segments);
	segmentNumber+=1;
	if (return_code==0)
	    {printf("\nIs there more value?(y/n)");
	     ch=getch();
	     if (ch=='Y'||ch=='y')
    		moreSegments=1;
	     else
	    	moreSegments=0;
	    }
	}
	while ((return_code==0)&&(moreSegments==1));
    if (return_code==0)
	   printf("\n\n                     Success,Press any key to continue!" );
	else
	   printf("\n\n                     Failure,Press any key to continue!");
	ch=getch();
	break;
 case 14:
    printf("\n\n                        Verity Bindery Object Password\n\n\n");
	printf("Please input the following datas: ");
	printf("\n\nobject_name:");
	scanf("%s",object_name);
	printf("\nobject_type(1-user/2-group):");
	scanf("%d",&object_type);
	printf("\npassword:");
	scanf("%s",password);
	return_code=VerifyBinderyObjectPassword(object_name, object_type, password);
    if (return_code==0)
	   printf("\n\n                     Success,Press any key to continue!" );
	else
	   printf("\n\n                     Failure,Press any key to continue!");
	ch=getch();
	break;
 case 15:
    printf("\n\n                        Change Bindery Object Password\n\n\n");
	printf("Please input the following datas: ");
	printf("\n\nobject_name:");
	scanf("%s",object_name);
	printf("\nobject_type(1-user/2-group):");
	scanf("%d",&object_type);
	printf("\nold_password:");
	scanf("%s",oldPassword);
	printf("\nnew_password:");
	scanf("%s",newPassword);
	return_code=ChangebinderyObjectPassword(object_name, object_type,
                                oldPassword, newPassword);
    if (return_code==0)
	   printf("\n\n                         Success,Press any key to continue!" );
	else
	   printf("\n\n                         Failure,Press any key to continue!");
	ch=getch();
	break;
 case 16:
    printf("\n\n                         Add bindery object to set\n\n\n");
	printf("Please input the following datas: ");
	printf("\n\nobject_name:");
	scanf("%s",object_name);
	printf("\nobject_type(1-user/2-group):");
    scanf("%d",&object_type);
	printf("\nproperty_name:");
	scanf("%s",property_name);
	printf("\nmember_object_name:");
	scanf("%s",member_object_name);
	printf("\nmember_object_type(1-user/2-group):");
	scanf("%d",&member_object_type);
	return_code=AddBinderyObjectToSet(object_name, object_type,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -