void acl_read_xyz(float *x, float *y, float *z)
{
	acl_read(ACL_AXIS_REG, acl_axisData, 6);
       
	*x = (float)((((int)acl_axisData[1]<<8)|(int)acl_axisData[0]))*G_TO_MS2;
	*y = (float)((((int)acl_axisData[3]<<8)|(int)acl_axisData[2]))*G_TO_MS2;
        *z = (float)((((int)acl_axisData[5]<<8)|(int)acl_axisData[4]))*G_TO_MS2;
}
Exemple #2
0
void acl_computeRightsOnFolder(const char *folder, char *rights)
{
	maildir_aclt_list l;
	char *owner;

	if (acl_read(&l, folder, &owner) < 0)
	{
		*rights=0;
		return;
	}
	acl_computeRights(&l, rights, owner);
	if (owner)
		free(owner);
	maildir_aclt_list_destroy(&l);
}
Exemple #3
0
void getacl()
{
	maildir_aclt_list l;
	char buf[2];
	char *owner;
	const char *a;
	const char *editentity=cgi("editentity");
	const char *editaccess=cgi("editaccess");

	const char *entitytype="";
	const char *entityval="";
	int negate=0;

	if (acl_read(&l, sqwebmail_folder, &owner) < 0)
	{
		printf("%s", getarg("ACL_noaccess"));
		return;
	}
	strcpy(buf, ACL_ADMINISTER);
	acl_computeRights(&l, buf, owner);
	if (owner)
		free(owner);

	if (buf[0] == 0)
	{
		maildir_aclt_list_destroy(&l);
		return;
	}

	printf("<form method=\"post\" name=\"form1\" action=\"");
	output_scriptptr();
	printf("\">");
	output_scriptptrpostinfo();
	printf("<input type=\"hidden\" name=\"update\" value=\"1\" />\n"
	       "<input type=\"hidden\" name=\"form\" value=\"acl\" />\n");
	printf("<table class=\"folder-acl-list\"><tbody>"
	       "<tr><th align=\"left\">%s</th><th align=\"left\">%s</th></tr>\n",
	       getarg("ENTITY"),
	       getarg("ACCESSRIGHTS"));

	maildir_aclt_list_enum(&l, getacl_cb, NULL);

	if (*editentity == '-')
	{
		++editentity;
		negate=1;
	}

	if (*editentity)
	{
		if (strncmp(editentity, "user="******"user";
			entityval=editentity+5;
		}
		else if (strncmp(editentity, "group=", 6) == 0)
		{
			entitytype="group";
			entityval=editentity+6;
		}
		else if (strcmp(editentity, "owner") == 0 ||
			 strcmp(editentity, "anonymous") == 0)
		{
			entitytype=editentity;
		}
		else
		{
			entitytype="other";
			entityval=editentity;
		}
	}

	printf("<tr><td colspan=\"2\"><hr width=\"90%%\" />");
	printf("<table><tbody>\n");
	printf("<tr><th colspan=\"2\" align=\"left\">%s</th></tr>\n",
	       getarg("UPDATEHDR"));
	printf("<tr align=\"top\"><td>"
	       "<select name=\"negate\" id=\"negate\">\n"
	       "<option value=\"\" > </option>\n"
	       "<option value=\"-\" %s>-</option>\n"
	       "</select>\n"
	       "<select name=\"entitytype\" id=\"entitytype\" "
	       "onchange=\"javascript:updent()\" >\n"
	       "<option value=\"user\" %s >%s</option>\n"
	       "<option value=\"group\" %s >%s</option>\n"
	       "<option value=\"owner\" %s >%s</option>\n"
	       "<option value=\"anonymous\" %s >%s</option>\n"
	       "<option value=\"administrators\" %s >%s</option>\n"
	       "<option value=\"other\" %s >%s</option>\n"
	       "</select><input type=\"text\" name=\"entity\" "
	       " id=\"entity\" value=\"",
	       negate ? "selected=\"selected\"":"",
	       strcmp(entitytype, "user") == 0 ? "selected=\"selected\"":"",
	       getarg("USER"),

	       strcmp(entitytype, "group") == 0 ? "selected=\"selected\"":"",
	       getarg("GROUP"),

	       strcmp(entitytype, "owner") == 0 ? "selected=\"selected\"":"",
	       getarg("OWNER"),

	       strcmp(entitytype, "anonymous") == 0 ? "selected=\"selected\"":"",
	       getarg("ANONYMOUS"),

	       strcmp(entitytype, "administrators") == 0 ? "selected=\"selected\"":"",
	       getarg("ADMINISTRATORS"),

	       strcmp(entitytype, "other") == 0 ? "selected=\"selected\"":"",
	       getarg("OTHER"));

	p_ident_name(entityval);

	printf("\"/></td><td><table><tbody>");

	a=getarg("ACL_all");

	while (*a)
	{
		char buf2[40];

		sprintf(buf2, "ACL_%c", *a);

		printf("<tr><td><input type=\"checkbox\" name=\"acl_%c\" "
		       "id=\"acl_%c\" %s />"
		       "</td><td>%s</td></tr>\n",
		       *a, *a,
		       strchr(editaccess, *a) ? "checked=\"checked\"":"",
		       getarg(buf2));
		++a;
	}

	printf("</tbody></table></td></tr>\n"
	       "<tr><td>&nbsp;</td>"
	       "<td><input type=\"submit\" name=\"do.update\" value=\"%s\" />"
	       "</td>"
	       "</table></tbody></td></tr>\n",
	       getarg("UPDATE"));

	printf("</tbody></table></form>\n");
}
Exemple #4
0
void listrights()
{
	maildir_aclt_list l;
	char buf[40];
	char *owner;

	if (*cgi("do.update") || *cgi("delentity"))
	{
		struct maildir_info minfo;

		if (maildir_info_imap_find(&minfo, sqwebmail_folder,
					   login_returnaddr()) == 0)
		{
			if (minfo.homedir)
			{
				struct maildirwatch *w;
				char *lock;
				int tryanyway;

				w=maildirwatch_alloc(minfo.homedir);

				if (!w)
				{
					maildir_info_destroy(&minfo);
					enomem();
					return;
				}

				lock=maildir_lock(minfo.homedir, w,
						  &tryanyway);

				maildir_info_destroy(&minfo);

				if (lock == NULL)
				{
					if (!tryanyway)
					{
						printf("%s",
						       getarg("ACL_noaccess"));
						return;
					}
				}
				doupdate();
				if (lock)
				{
					unlink(lock);
					free(lock);
				}
				maildirwatch_free(w);
			}
		}
	}

	if (acl_read(&l, sqwebmail_folder, &owner) < 0)
	{
		printf("%s", getarg("ACL_cantread"));
		return;
	}
	buf[0]=0;
	strncat(buf, getarg("ACL_all"), sizeof(buf)-2);
	acl_computeRights(&l, buf, owner);
	maildir_aclt_list_destroy(&l);
	if (owner)
		free(owner);

	if (!maildir_acl_canlistrights(buf))
	{
		printf("%s", getarg("ACL_cantread"));
		return;
	}

	showrights(buf);
}