klar, läuft auch unter R6
hier ist der Code:
#include <stdio.h>
#include <string.h>
#ifdef UNIX
#include <ctype.h>
#endif
#include <lapicinc.h>
#include <global.h>
#include <nsfdb.h>
#include <nsfsearc.h>
#include <osfile.h>
#include <osmem.h>
#include <osmisc.h>
#include <mail.h>
#include <mailserv.h>
#include <names.h>
#include <stdnames.h>
#include <nsfdata.h>
#include <nsfnote.h>
#include <nsferr.h>
#include <textlist.h>
#include <ods.h>
#include <odstypes.h>
#include <easycd.h>
#include <agents.h>
#include <nif.h>
#include <acl.h>
#include <dname.h>
#ifdef _DEBUG
#include <lapiplat.h>
#else
#include <addin.h>
#endif
#define MSG_LENGTH 512
void LogMsg (char *);
void LogError (STATUS);
#ifdef _DEBUG
LAPI_MAIN
{
#else
STATUS LNPUBLIC AddInMain (HMODULE hModule, int argc, char *argv[])
{
HANDLE hOldStatusLine;
HANDLE hStatusLineDesc;
HMODULE hMod;
#endif
STATUS error=NOERROR;
char entryname[MAXUSERNAME], canonname[MAXUSERNAME], pathname[MAXPATH];
HANDLE hACL;
DBHANDLE hDb;
ACL_PRIVILEGES PrivBits = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int i;
WORD retLen;
DWORD dwACLFlags;
#ifdef _DEBUG
LAPI_INIT(error);
if (error) LAPI_INIT_ERROR;
#else
AddInQueryDefaults (&hMod, &hOldStatusLine);
AddInDeleteStatusLine (hOldStatusLine);
hStatusLineDesc = AddInCreateStatusLine("ALADDIN");
AddInSetDefaults (hMod, hStatusLineDesc);
AddInSetStatusText("Initializing");
AddInSetStatusText("Idle");
#endif
if (argc <3 )
{
LogMsg ("usage load naladin <dbname> <username>");
return (NOERROR);
}
strcpy (pathname, argv[1]);
strcpy (entryname, argv[2]);
for (i=3; i<argc; i++)
{
strcat (entryname, " ");
strcat (entryname, argv);
}
if (error = DNCanonicalize (0L, NULL, entryname, canonname, MAXUSERNAME, &retLen))
{
LogError (error);
return (NOERROR);
}
if (error = NSFDbOpen (pathname, &hDb))
{
LogMsg ("error opening db");
LogError (error);
return (NOERROR);
}
if (error = NSFDbReadACL(hDb, &hACL))
{
NSFDbClose (hDb);
LogMsg("error reading acl");
LogError (error);
return (NOERROR);
}
if (error = ACLGetFlags(hACL, &dwACLFlags))
{
OSMemFree (hACL);
NSFDbClose (hDb);
LogMsg("could not get ACL flags");
LogError (error);
return (NOERROR);
}
if (dwACLFlags & ACL_UNIFORM_ACCESS)
{
LogMsg("error consistent acl");
OSMemFree (hACL);
NSFDbClose (hDb);
return (NOERROR);
}
for ( i = 0; i < ACL_PRIVCOUNT; i++) ACLClearPriv (PrivBits, i);
if (error = ACLAddEntry (hACL, canonname,ACL_LEVEL_MANAGER, &PrivBits,0))
{
OSMemFree (hACL);
NSFDbClose (hDb);
LogMsg ("error adding user");
LogError (error);
return (NOERROR);
}
if (error = NSFDbStoreACL (hDb,hACL,0L,0))
{
OSMemFree (hACL);
NSFDbClose (hDb);
LogMsg ("error saving acl");
LogError (error);
return (NOERROR);
}
OSMemFree (hACL);
NSFDbClose (hDb);
#ifndef _DEBUG
AddInSetStatusText("Terminating");
#endif
return (NOERROR);
}
void LogError (STATUS error)
{
char msg[MSG_LENGTH];
char error_msg[MSG_LENGTH];
OSLoadString(NULLHANDLE, ERR(error), error_msg, sizeof(error_msg)-1);
strcpy (msg, "ALADDIN: ");
strcat (msg, error_msg);
LogMsg (msg);
return;
}
void LogMsg (char *msg)
{
#ifdef _DEBUG
printf ("\n%s", msg);
#else
AddInLogMessageText(msg, NOERROR);
#endif
return;
}