本文整理汇总了C++中option函数的典型用法代码示例。如果您正苦于以下问题:C++ option函数的具体用法?C++ option怎么用?C++ option使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了option函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: add_option
void DHCP::domain_name(const string &name) {
add_option(option(DOMAIN_NAME, name.size(), (const uint8_t*)name.c_str()));
}
开发者ID:DaTrollMon,项目名称:libtins,代码行数:3,代码来源:dhcp.cpp
示例2: mutt_ssl_starttls
/* mutt_ssl_starttls: Negotiate TLS over an already opened connection.
* TODO: Merge this code better with ssl_socket_open. */
int mutt_ssl_starttls (CONNECTION* conn)
{
sslsockdata* ssldata;
int maxbits;
long ssl_options = 0;
if (ssl_init())
goto bail;
ssldata = (sslsockdata*) safe_calloc (1, sizeof (sslsockdata));
/* the ssl_use_xxx protocol options don't apply. We must use TLS in TLS.
*
* However, we need to be able to negotiate amongst various TLS versions,
* which at present can only be done with the SSLv23_client_method;
* TLSv1_client_method gives us explicitly TLSv1.0, not 1.1 or 1.2 (True as
* of OpenSSL 1.0.1c)
*/
if (! (ssldata->ctx = SSL_CTX_new (SSLv23_client_method())))
{
dprint (1, (debugfile, "mutt_ssl_starttls: Error allocating SSL_CTX\n"));
goto bail_ssldata;
}
#ifdef SSL_OP_NO_TLSv1_2
if (!option(OPTTLSV1_2))
ssl_options |= SSL_OP_NO_TLSv1_2;
#endif
#ifdef SSL_OP_NO_TLSv1_1
if (!option(OPTTLSV1_1))
ssl_options |= SSL_OP_NO_TLSv1_1;
#endif
#ifdef SSL_OP_NO_TLSv1
if (!option(OPTTLSV1))
ssl_options |= SSL_OP_NO_TLSv1;
#endif
/* these are always set */
#ifdef SSL_OP_NO_SSLv3
ssl_options |= SSL_OP_NO_SSLv3;
#endif
#ifdef SSL_OP_NO_SSLv2
ssl_options |= SSL_OP_NO_SSLv2;
#endif
if (! SSL_CTX_set_options(ssldata->ctx, ssl_options))
{
dprint(1, (debugfile, "mutt_ssl_starttls: Error setting options to %ld\n", ssl_options));
goto bail_ctx;
}
ssl_get_client_cert(ssldata, conn);
if (! (ssldata->ssl = SSL_new (ssldata->ctx)))
{
dprint (1, (debugfile, "mutt_ssl_starttls: Error allocating SSL\n"));
goto bail_ctx;
}
if (SSL_set_fd (ssldata->ssl, conn->fd) != 1)
{
dprint (1, (debugfile, "mutt_ssl_starttls: Error setting fd\n"));
goto bail_ssl;
}
if (ssl_negotiate (conn, ssldata))
goto bail_ssl;
ssldata->isopen = 1;
/* hmm. watch out if we're starting TLS over any method other than raw. */
conn->sockdata = ssldata;
conn->conn_read = ssl_socket_read;
conn->conn_write = ssl_socket_write;
conn->conn_close = tls_close;
conn->ssf = SSL_CIPHER_get_bits (SSL_get_current_cipher (ssldata->ssl),
&maxbits);
return 0;
bail_ssl:
FREE (&ssldata->ssl);
bail_ctx:
FREE (&ssldata->ctx);
bail_ssldata:
FREE (&ssldata);
bail:
return -1;
}
开发者ID:Ishpeck,项目名称:mutt-kz,代码行数:88,代码来源:mutt_ssl.c
示例3: setAddressReusable
/*!
Returns true if the address of this socket can be used by other
sockets at the same time, and false if this socket claims
exclusive ownership.
\sa setAddressReusable()
*/
bool Q3SocketDevice::addressReusable() const
{
return option( ReuseAddress );
}
开发者ID:sicily,项目名称:qt4.8.4,代码行数:11,代码来源:q3socketdevice.cpp
示例4: main
int main(void)
{
ALLEGRO_DISPLAY *display;
ALLEGRO_FONT *font;
ALLEGRO_CONFIG *config;
ALLEGRO_EVENT_QUEUE *queue;
bool write = false;
bool flip = false;
bool quit;
if (!al_init()) {
abort_example("Could not init Allegro.\n");
}
al_init_font_addon();
al_init_image_addon();
al_install_keyboard();
al_install_mouse();
/* Read parameters from ex_vsync.ini. */
config = al_load_config_file("ex_vsync.ini");
if (!config) {
config = al_create_config();
write = true;
}
/* 0 -> Driver chooses.
* 1 -> Force vsync on.
* 2 -> Force vsync off.
*/
vsync = option(config, "vsync", 0);
fullscreen = option(config, "fullscreen", 0);
frequency = option(config, "frequency", 0);
/* Write the file back (so a template is generated on first run). */
if (write) {
al_save_config_file("ex_vsync.ini", config);
}
al_destroy_config(config);
/* Vsync 1 means force on, 2 means forced off. */
if (vsync)
al_set_new_display_option(ALLEGRO_VSYNC, vsync, ALLEGRO_SUGGEST);
/* Force fullscreen mode. */
if (fullscreen) {
al_set_new_display_flags(ALLEGRO_FULLSCREEN_WINDOW);
/* Set a monitor frequency. */
if (frequency)
al_set_new_display_refresh_rate(frequency);
}
display = al_create_display(640, 480);
if (!display) {
abort_example("Error creating display.\n");
}
font = al_load_font("data/a4_font.tga", 0, 0);
if (!font) {
abort_example("Failed to load a4_font.tga\n");
}
queue = al_create_event_queue();
al_register_event_source(queue, al_get_keyboard_event_source());
al_register_event_source(queue, al_get_mouse_event_source());
al_register_event_source(queue, al_get_display_event_source(display));
quit = display_warning(queue, font);
al_flush_event_queue(queue);
while (!quit) {
ALLEGRO_EVENT event;
/* With vsync, this will appear as a 50% gray screen (maybe
* flickering a bit depending on monitor frequency).
* Without vsync, there will be black/white shearing all over.
*/
if (flip)
al_clear_to_color(al_map_rgb_f(1, 1, 1));
else
al_clear_to_color(al_map_rgb_f(0, 0, 0));
al_flip_display();
flip = !flip;
while (al_get_next_event(queue, &event)) {
switch (event.type) {
case ALLEGRO_EVENT_DISPLAY_CLOSE:
quit = true;
case ALLEGRO_EVENT_KEY_DOWN:
if (event.keyboard.keycode == ALLEGRO_KEY_ESCAPE)
quit = true;
}
}
/* Let's not go overboard and limit flipping at 1000 Hz. Without
* this my system locks up and requires a hard reboot :P
*/
//.........这里部分代码省略.........
开发者ID:gitustc,项目名称:d2imdev,代码行数:101,代码来源:ex_vsync.c
示例5: mutt_compose_menu
/* return values:
*
* 1 message should be postponed
* 0 normal exit
* -1 abort message
*/
int mutt_compose_menu (HEADER *msg, /* structure for new message */
char *fcc, /* where to save a copy of the message */
size_t fcclen,
HEADER *cur) /* current message */
{
char helpstr[SHORT_STRING];
char buf[LONG_STRING];
char fname[_POSIX_PATH_MAX];
MUTTMENU *menu;
ATTACHPTR **idx = NULL;
short idxlen = 0;
short idxmax = 0;
int i, close = 0;
int r = -1; /* return value */
int op = 0;
int loop = 1;
int fccSet = 0; /* has the user edited the Fcc: field ? */
CONTEXT *ctx = NULL, *this = NULL;
/* Sort, SortAux could be changed in mutt_index_menu() */
int oldSort, oldSortAux;
struct stat st;
idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1);
menu = mutt_new_menu ();
menu->menu = MENU_COMPOSE;
menu->offset = HDR_ATTACH;
menu->max = idxlen;
menu->make_entry = snd_entry;
menu->tag = mutt_tag_attach;
menu->title = _("Compose");
menu->data = idx;
menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);
while (loop)
{
switch (op = mutt_menuLoop (menu))
{
case OP_REDRAW:
menu_redraw_status (menu);
draw_envelope (msg, fcc);
menu->offset = HDR_ATTACH;
menu->pagelen = LINES - HDR_ATTACH - 2;
break;
case OP_COMPOSE_EDIT_FROM:
menu->redraw = edit_address_list (HDR_FROM, &msg->env->from);
break;
case OP_COMPOSE_EDIT_TO:
menu->redraw = edit_address_list (HDR_TO, &msg->env->to);
break;
case OP_COMPOSE_EDIT_BCC:
menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc);
break;
case OP_COMPOSE_EDIT_CC:
menu->redraw = edit_address_list (HDR_CC, &msg->env->cc);
break;
case OP_COMPOSE_EDIT_SUBJECT:
if (msg->env->subject)
strfcpy (buf, msg->env->subject, sizeof (buf));
else
buf[0] = 0;
if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
{
mutt_str_replace (&msg->env->subject, buf);
move (HDR_SUBJECT, HDR_XOFFSET);
clrtoeol ();
if (msg->env->subject)
printw ("%-*.*s", W, W, msg->env->subject);
}
break;
case OP_COMPOSE_EDIT_REPLY_TO:
menu->redraw = edit_address_list (HDR_REPLYTO, &msg->env->reply_to);
break;
case OP_COMPOSE_EDIT_FCC:
strfcpy (buf, fcc, sizeof (buf));
if (mutt_get_field ("Fcc: ", buf, sizeof (buf), M_FILE | M_CLEAR) == 0)
{
strfcpy (fcc, buf, _POSIX_PATH_MAX);
mutt_pretty_mailbox (fcc);
mvprintw (HDR_FCC, HDR_XOFFSET, "%-*.*s", W, W, fcc);
fccSet = 1;
}
MAYBE_REDRAW (menu->redraw);
break;
case OP_COMPOSE_EDIT_MESSAGE:
if (Editor && (mutt_strcmp ("builtin", Editor) != 0) && !option (OPTEDITHDRS))
{
mutt_edit_file (Editor, msg->content->filename);
mutt_update_encoding (msg->content);
menu->redraw = REDRAW_CURRENT;
break;
}
/* fall through */
case OP_COMPOSE_EDIT_HEADERS:
//.........这里部分代码省略.........
开发者ID:kbraga111,项目名称:muttassign6-ed.purp.only-,代码行数:101,代码来源:compose.c
示例6: parse_args
/* parse command line & set command arguments. returns the index of
* non-option arguments, -1 if there is an error.
*/
int
parse_args(char **argv,
int what, /* OF_CMDLINE or OF_SET */
int *setargsp)
{
static char cmd_opts[NELEM(options) + 3]; /* o:\0 */
static char set_opts[NELEM(options) + 5]; /* Ao;s\0 */
char *opts;
char *array = (char *) 0;
Getopt go;
int i, optc, set, sortargs = 0, arrayset = 0;
/* First call? Build option strings... */
if (cmd_opts[0] == '\0') {
char *p, *q;
/* see cmd_opts[] declaration */
strlcpy(cmd_opts, "o:", sizeof cmd_opts);
p = cmd_opts + strlen(cmd_opts);
/* see set_opts[] declaration */
strlcpy(set_opts, "A:o;s", sizeof set_opts);
q = set_opts + strlen(set_opts);
for (i = 0; i < NELEM(options); i++) {
if (options[i].c) {
if (options[i].flags & OF_CMDLINE)
*p++ = options[i].c;
if (options[i].flags & OF_SET)
*q++ = options[i].c;
}
}
*p = '\0';
*q = '\0';
}
if (what == OF_CMDLINE) {
char *p;
/* Set FLOGIN before parsing options so user can clear
* flag using +l.
*/
Flag(FLOGIN) = (argv[0][0] == '-' ||
((p = strrchr(argv[0], '/')) && *++p == '-'));
opts = cmd_opts;
} else
opts = set_opts;
ksh_getopt_reset(&go, GF_ERROR|GF_PLUSOPT);
while ((optc = ksh_getopt(argv, &go, opts)) != -1) {
set = (go.info & GI_PLUS) ? 0 : 1;
switch (optc) {
case 'A':
arrayset = set ? 1 : -1;
array = go.optarg;
break;
case 'o':
if (go.optarg == (char *) 0) {
/* lone -o: print options
*
* Note that on the command line, -o requires
* an option (ie, can't get here if what is
* OF_CMDLINE).
*/
printoptions(set);
break;
}
i = option(go.optarg);
if (i >= 0 && set == Flag(i))
/* Don't check the context if the flag
* isn't changing - makes "set -o interactive"
* work if you're already interactive. Needed
* if the output of "set +o" is to be used.
*/
;
else if (i >= 0 && (options[i].flags & what))
change_flag((enum sh_flag) i, what, set);
else {
bi_errorf("%s: bad option", go.optarg);
return -1;
}
break;
case '?':
return -1;
default:
/* -s: sort positional params (at&t ksh stupidity) */
if (what == OF_SET && optc == 's') {
sortargs = 1;
break;
}
for (i = 0; i < NELEM(options); i++)
if (optc == options[i].c &&
(what & options[i].flags)) {
change_flag((enum sh_flag) i, what,
set);
break;
}
if (i == NELEM(options)) {
//.........这里部分代码省略.........
开发者ID:UNGLinux,项目名称:Obase,代码行数:101,代码来源:misc.c
示例7: option
Message::Message(SQLite3DB::DB *db):IDatabase(db),m_nntpmessageid(-1)
{
Option option(db);
option.GetBool("UniqueBoardMessageIDs",m_uniqueboardmessageids);
Initialize();
}
开发者ID:SeekingFor,项目名称:FMS,代码行数:6,代码来源:message.cpp
示例8: QByteArray
void Message::unpack(const QByteArray &packed)
{
d->errors = MessagePrivate::Errors(0);
d->options.clear();
quint8 *p = (quint8 *)packed.data();
quint8 *pend = (quint8 *)packed.data() + packed.size() - 1;
if (packed.size() < 4) {
d->errors |= MessagePrivate::FORMAT_ERROR;
return;
}
d->version = (p[0] & 0xc0) >> 6;
if (d->version != 1)
d->errors |= MessagePrivate::UNKNOWN_VERSION;
d->type = (Message::Type)( (p[0] & 0x30) >> 4 );
quint8 tokenLength = (p[0] & 0xf);
d->code = (Message::Code)p[1];
if (tokenLength > 8)
d->errors |= MessagePrivate::WRONG_TOKEN_LENGTH;
else
d->token = QByteArray((const char *)p + 4, tokenLength);
d->message_id = endian_load16(quint16, (p + 2));
if (packed.size() == 4) // only header present, ok
return;
p += tokenLength;
p += 4;
quint16 optionNumber = 0;
do {
if (*p == 0xff) {
quint32 payloadSize = pend - p;
if (payloadSize == 0)
d->errors |= MessagePrivate::WRONG_PAYLOAD_MARKER;
d->payload = QByteArray((const char *)p + 1, payloadSize);
return;
}
quint16 optionDelta = (*p & 0xf0) >> 4;
quint16 optionLength = (*p & 0xf);
p++;
if (optionDelta == 13) {
optionDelta = *p + 13;
p++;
} else if (optionDelta == 14) {
optionDelta = endian_load16(quint16, p);
p += 2;
} else if (optionDelta == 15) {
d->errors |= MessagePrivate::WRONG_PAYLOAD_MARKER;
return;
}
if (optionLength == 13) {
optionLength = *p + 13;
p++;
} else if (optionLength == 14) {
optionLength = endian_load16(quint16, p);
p += 2;
} else if (optionLength == 15) {
d->errors |= MessagePrivate::WRONG_PAYLOAD_MARKER;
return;
}
optionNumber += optionDelta;
Option option((Message::OptionType)optionNumber, QByteArray((const char *)p, optionLength));
d->options.append(option);
p += optionLength;
} while (p <= pend);
if (p > pend + 1)
d->errors |= MessagePrivate::NOT_ENOUGH_DATA;
}
开发者ID:FutureTools,项目名称:iotlib,代码行数:75,代码来源:message.cpp
示例9: while
static ADDRESS *mutt_expand_aliases_r (ADDRESS *a, LIST **expn)
{
ADDRESS *head = NULL, *last = NULL, *t, *w;
LIST *u;
char i;
const char *fqdn;
while (a)
{
if (!a->group && !a->personal && a->mailbox && strchr (a->mailbox, '@') == NULL)
{
t = mutt_lookup_alias (a->mailbox);
if (t)
{
i = 0;
for (u = *expn; u; u = u->next)
{
if (mutt_strcmp (a->mailbox, u->data) == 0) /* alias already found */
{
dprint (1, (debugfile, "mutt_expand_aliases_r(): loop in alias found for '%s'\n", a->mailbox));
i = 1;
break;
}
}
if (!i)
{
u = safe_malloc (sizeof (LIST));
u->data = safe_strdup (a->mailbox);
u->next = *expn;
*expn = u;
w = rfc822_cpy_adr (t, 0);
w = mutt_expand_aliases_r (w, expn);
if (head)
last->next = w;
else
head = last = w;
while (last && last->next)
last = last->next;
}
t = a;
a = a->next;
t->next = NULL;
rfc822_free_address (&t);
continue;
}
else
{
struct passwd *pw = getpwnam (a->mailbox);
if (pw)
{
char namebuf[STRING];
mutt_gecos_name (namebuf, sizeof (namebuf), pw);
mutt_str_replace (&a->personal, namebuf);
#ifdef EXACT_ADDRESS
FREE (&a->val);
#endif
}
}
}
if (head)
{
last->next = a;
last = last->next;
}
else
head = last = a;
a = a->next;
last->next = NULL;
}
if (option (OPTUSEDOMAIN) && (fqdn = mutt_fqdn(1)))
{
/* now qualify all local addresses */
rfc822_qualify (head, fqdn);
}
return (head);
}
开发者ID:aschrab,项目名称:mutt,代码行数:84,代码来源:alias.c
示例10: option
void LevelSetDelegate::paint(QPainter* p, const QStyleOptionViewItem& opt, const QModelIndex& index) const
{
p->save();
QStyleOptionViewItemV4 option(opt);
initStyleOption(&option, index);
//
// Draw item with no textwith a decoration and selection (if it's selected)
//
// we want to paint text by ourselves, so set it to null, paint selection and then paint text
QString text = index.data(Qt::DisplayRole).toString();
option.text = QString();
option.decorationSize = QSize(48, 48);
QStyle* style = QApplication::style();
style->drawControl(QStyle::CE_ItemViewItem, &option, p, 0);
if (option.state & QStyle::State_Selected)
p->setPen(option.palette.color(QPalette::Normal, QPalette::HighlightedText));
else
p->setPen(option.palette.color(QPalette::Normal, QPalette::Text));
//
// Draw text
//
int marginH = style->pixelMetric( QStyle::PM_FocusFrameHMargin );
int marginV = style->pixelMetric( QStyle::PM_FocusFrameVMargin );
int innerSpacing = 9;
int textStartX = option.decorationSize.width() + innerSpacing;
QRect r = opt.rect.adjusted(textStartX, marginV*2, 0, 0);
QFontMetrics fm(opt.font);
int flags = Qt::AlignLeft | Qt::AlignTop | Qt::TextSingleLine;
QFont font = p->font();
font.setBold(true);
p->setFont(font);
p->drawText(r, flags, text);
//
// Draw Author name
//
QString authorName = index.data(KAtomic::LevelSetAuthorRole).toString();
if (!authorName.isEmpty())
{
if (option.state & QStyle::State_Selected)
p->setPen(option.palette.color(QPalette::Disabled, QPalette::HighlightedText));
else
p->setPen(option.palette.color(QPalette::Disabled, QPalette::Text));
r = r.adjusted(innerSpacing, fm.lineSpacing(), -marginH*2, 0);
flags = Qt::AlignLeft | Qt::AlignTop;
p->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
QString text = i18n("by %1", authorName);
QString authorEmail = index.data(KAtomic::LevelSetAuthorEmailRole).toString();
if (!authorEmail.isEmpty())
text.append(QStringLiteral(" <%1>").arg(authorEmail));
int numLevels = index.data(KAtomic::LevelSetLevelCountRole).toUInt();
text.append(i18np(", contains 1 level", ", contains %1 levels", numLevels));
p->drawText(r, flags, text);
}
//
// Draw description
//
QString descr = index.data(KAtomic::LevelSetDescriptionRole).toString();
if (!descr.isEmpty())
{
if (option.state & QStyle::State_Selected)
p->setPen(option.palette.color(QPalette::Normal, QPalette::HighlightedText));
else
p->setPen(option.palette.color(QPalette::Normal, QPalette::Text));
r = opt.rect.adjusted(textStartX, fm.lineSpacing()*2, -marginH*2, -marginV*2);
flags = Qt::AlignLeft | Qt::AlignBottom | Qt::TextSingleLine;
p->setFont(opt.font);
QString elided = fm.elidedText(descr, Qt::ElideMiddle, r.width(), flags);
p->drawText(r, flags, descr);
}
p->restore();
}
开发者ID:KDE,项目名称:katomic,代码行数:88,代码来源:levelsetdelegate.cpp
示例11: if
Grid::Grid(char *fname){
register int i,j;
char buf[BUFSIZ];
if(option("REAFILE")){
register int k,l;
int dim;
double **xloc, **yloc, **zloc;
int **locvid;
sprintf(buf, "%s.rea",strtok(fname,"\n"));
domainname = strdup(buf);
domainfile = fopen(domainname,"r");
if(!findSection("MESH",buf,domainfile))
{fputs("Grid_rea: Section not found\n", stderr); exit(-1);}
get_next_line(domainfile, buf);
sscanf(buf,"%d%d",&nel,&dim);
if(dim != 3){ fputs("Grid_rea: Mesh is not 3D\n",stderr); exit(-1);}
xloc = dmatrix(0,nel-1,0,Max_Nverts-1);
yloc = dmatrix(0,nel-1,0,Max_Nverts-1);
zloc = dmatrix(0,nel-1,0,Max_Nverts-1);
nverts = ivector(0, nel-1);
/* read local mesh */
for(k = 0; k < nel; k++) {
get_next_line(domainfile, buf); /* element header */
if(strstr(buf,"Hex") || strstr(buf,"hex")){
fscanf(domainfile,"%lf%lf%lf%lf%lf%lf%lf%lf",
xloc[k],xloc[k]+1,xloc[k]+2,xloc[k]+3,xloc[k]+4,
xloc[k]+5,xloc[k]+6,xloc[k]+7);
fscanf(domainfile,"%lf%lf%lf%lf%lf%lf%lf%lf",
yloc[k],yloc[k]+1,yloc[k]+2,yloc[k]+3,yloc[k]+4,
yloc[k]+5,yloc[k]+6,yloc[k]+7);
fscanf(domainfile,"%lf%lf%lf%lf%lf%lf%lf%lf",
zloc[k],zloc[k]+1,zloc[k]+2,zloc[k]+3,zloc[k]+4,
zloc[k]+5,zloc[k]+6,zloc[k]+7);
get_next_line(domainfile, buf); /* get remainder of line */
nverts[k] = 8;
}
else if(strstr(buf,"Prism") || strstr(buf,"prism")){
fscanf(domainfile,"%lf%lf%lf%lf%lf%lf",
xloc[k],xloc[k]+1,xloc[k]+2,xloc[k]+3,xloc[k]+4,xloc[k]+5);
fscanf(domainfile,"%lf%lf%lf%lf%lf%lf",
yloc[k],yloc[k]+1,yloc[k]+2,yloc[k]+3,yloc[k]+4,yloc[k]+5);
fscanf(domainfile,"%lf%lf%lf%lf%lf%lf",
zloc[k],zloc[k]+1,zloc[k]+2,zloc[k]+3,zloc[k]+4,zloc[k]+5);
get_next_line(domainfile, buf); /* get remainder of line */
nverts[k] = 6;
}
else if(strstr(buf,"Pyr") || strstr(buf,"pyr")){
fscanf(domainfile,"%lf%lf%lf%lf%lf",
xloc[k],xloc[k]+1,xloc[k]+2,xloc[k]+3,xloc[k]+4);
fscanf(domainfile,"%lf%lf%lf%lf%lf",
yloc[k],yloc[k]+1,yloc[k]+2,yloc[k]+3,yloc[k]+4);
fscanf(domainfile,"%lf%lf%lf%lf%lf",
zloc[k],zloc[k]+1,zloc[k]+2,zloc[k]+3,zloc[k]+4);
get_next_line(domainfile, buf); /* get remainder of line */
nverts[k] = 5;
}
else{ /* assume it is a tet */
fscanf(domainfile,"%lf%lf%lf%lf",xloc[k],xloc[k]+1,xloc[k]+2,xloc[k]+3);
fscanf(domainfile,"%lf%lf%lf%lf",yloc[k],yloc[k]+1,yloc[k]+2,yloc[k]+3);
fscanf(domainfile,"%lf%lf%lf%lf",zloc[k],zloc[k]+1,zloc[k]+2,zloc[k]+3);
get_next_line(domainfile, buf); /* get remainder of line */
nverts[k] = 4;
}
}
/* search through elements and search for similar elements */
vertids = imatrix(0,nel-1,0,Max_Nverts-1);
ifill(nel*Max_Nverts,-1,vertids[0],1);
totverts=0;
for(k = 0; k < nel; ++k)
for(i= 0; i < nverts[k]; ++i)
if(vertids[k][i] == -1){
vertids[k][i] = totverts++;
for(l = k+1; l < nel; ++l)
for(j = 0; j < nverts[l]; ++j)
if(vertids[l][j] == -1){
if(same(xloc[l][j],xloc[k][i]) && same(yloc[l][j],yloc[k][i])
&& same(zloc[l][j],zloc[k][i]))
vertids[l][j] = vertids[k][i];
}
}
xcoords = dvector(0, totverts-1);
ycoords = dvector(0, totverts-1);
zcoords = dvector(0, totverts-1);
for(k = 0; k < nel; ++k)
for(i= 0; i < nverts[k]; ++i){
//.........这里部分代码省略.........
开发者ID:HerculesCE,项目名称:ParaView,代码行数:101,代码来源:orienter.C
示例12: main
int main(int argc, char *argv[]) {
int retval;
R_RSA_PUBLIC_KEY key;
char log_path[256];
#ifdef _USING_FCGI_
unsigned int counter=0;
#endif
for(int c = 1; c < argc; c++) {
std::string option(argv[c]);
if(option == "-v" || option == "--version") {
printf("%s\n", SVN_VERSION);
exit(0);
} else if(option == "-h" || option == "--help") {
usage(argv[0]);
exit(0);
} else if (option.length()){
fprintf(stderr, "unknown command line argument: %s\n\n", argv[c]);
usage(argv[0]);
exit(1);
}
}
installer();
get_log_path(log_path, "file_upload_handler.log");
#ifndef _USING_FCGI_
if (!freopen(log_path, "a", stderr)) {
fprintf(stderr, "Can't open log file '%s' (errno: %d)\n",
log_path, errno
);
return_error(ERR_TRANSIENT, "can't open log file '%s' (errno: %d)",
log_path, errno
);
exit(1);
}
#else
FCGI_FILE *f = FCGI::fopen(log_path, "a");
if (f) {
log_messages.redirect(f);
} else {
fprintf(stderr, "Can't redirect FCGI log messages\n");
return_error(ERR_TRANSIENT, "can't open log file (FCGI)");
exit(1);
}
#endif
retval = config.parse_file();
if (retval) {
fprintf(stderr, "Can't parse config.xml: %s\n", boincerror(retval));
return_error(ERR_TRANSIENT,
"can't parse config file", log_path, errno
);
exit(1);
}
log_messages.pid = getpid();
log_messages.set_debug_level(config.fuh_debug_level);
if (boinc_file_exists(config.project_path("stop_upload"))) {
return_error(ERR_TRANSIENT, "Maintenance underway: file uploads are temporarily disabled.");
exit(1);
}
if (!config.ignore_upload_certificates) {
retval = get_key(key);
if (retval) {
return_error(ERR_TRANSIENT, "can't read key file");
exit(1);
}
}
#ifdef _USING_FCGI_
while(FCGI_Accept() >= 0) {
counter++;
//fprintf(stderr, "file_upload_handler (FCGI): counter: %d\n", counter);
log_messages.set_indent_level(0);
#endif
handle_request(stdin, key);
#ifdef _USING_FCGI_
// flush log for FCGI, otherwise it just buffers a lot
log_messages.flush();
}
// when exiting, write headers back to apache so it won't complain
// about "incomplete headers"
fprintf(stdout,"Content-type: text/plain\n\n");
#endif
return 0;
}
开发者ID:asimonov-im,项目名称:boinc,代码行数:89,代码来源:file_upload_handler.cpp
示例13: _mutt_copy_message
int
_mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body,
int flags, int chflags)
{
char prefix[SHORT_STRING];
STATE s;
LOFF_T new_offset = -1;
int rc = 0;
if (flags & M_CM_PREFIX)
{
if (option (OPTTEXTFLOWED))
strfcpy (prefix, ">", sizeof (prefix));
else
_mutt_make_string (prefix, sizeof (prefix), NONULL (Prefix), Context, hdr, 0);
}
if ((flags & M_CM_NOHEADER) == 0)
{
if (flags & M_CM_PREFIX)
chflags |= CH_PREFIX;
else if (hdr->attach_del && (chflags & CH_UPDATE_LEN))
{
int new_lines;
LOFF_T new_length = body->length;
char date[SHORT_STRING];
mutt_make_date (date, sizeof (date));
date[5] = date[mutt_strlen (date) - 1] = '\"';
/* Count the number of lines and bytes to be deleted */
fseeko (fpin, body->offset, SEEK_SET);
new_lines = hdr->lines -
count_delete_lines (fpin, body, &new_length, mutt_strlen (date));
/* Copy the headers */
if (mutt_copy_header (fpin, hdr, fpout,
chflags | CH_NOLEN | CH_NONEWLINE, NULL))
return -1;
fprintf (fpout, "Content-Length: " OFF_T_FMT "\n", new_length);
if (new_lines <= 0)
new_lines = 0;
else
fprintf (fpout, "Lines: %d\n", new_lines);
putc ('\n', fpout);
if (ferror (fpout) || feof (fpout))
return -1;
new_offset = ftello (fpout);
/* Copy the body */
fseeko (fpin, body->offset, SEEK_SET);
if (copy_delete_attach (body, fpin, fpout, date))
return -1;
#ifdef DEBUG
{
LOFF_T fail = ((ftello (fpout) - new_offset) - new_length);
if (fail)
{
mutt_error ("The length calculation was wrong by %ld bytes", fail);
new_length += fail;
mutt_sleep (1);
}
}
#endif
/* Update original message if we are sync'ing a mailfolder */
if (flags & M_CM_UPDATE)
{
hdr->attach_del = 0;
hdr->lines = new_lines;
body->offset = new_offset;
/* update the total size of the mailbox to reflect this deletion */
Context->size -= body->length - new_length;
/*
* if the message is visible, update the visible size of the mailbox
* as well.
*/
if (Context->v2r[hdr->msgno] != -1)
Context->vsize -= body->length - new_length;
body->length = new_length;
mutt_free_body (&body->parts);
}
return 0;
}
if (mutt_copy_header (fpin, hdr, fpout, chflags,
(chflags & CH_PREFIX) ? prefix : NULL) == -1)
return -1;
new_offset = ftello (fpout);
}
if (flags & M_CM_DECODE)
//.........这里部分代码省略.........
开发者ID:asac,项目名称:mutt-gmail,代码行数:101,代码来源:copy.c
示例14: mutt_prepare_template
//.........这里部分代码省略.........
/* create temporary files for all attachments */
for (b = newhdr->content; b; b = b->next) {
/* what follows is roughly a receive-mode variant of
* mutt_get_tmp_attachment () from muttlib.c
*/
file[0] = '\0';
if (b->filename) {
strfcpy (file, b->filename, sizeof (file));
b->d_filename = str_dup (b->filename);
}
else {
/* avoid Content-Disposition: header with temporary filename */
b->use_disp = 0;
}
/* set up state flags */
s.flags = 0;
if (b->type == TYPETEXT) {
if (!ascii_strcasecmp
("yes", mutt_get_parameter ("x-mutt-noconv", b->parameter)))
b->noconv = 1;
else {
s.flags |= M_CHARCONV;
b->noconv = 0;
}
mutt_delete_parameter ("x-mutt-noconv", &b->parameter);
}
mutt_adv_mktemp (NULL, file, sizeof (file));
if ((s.fpout = safe_fopen (file, "w")) == NULL)
goto bail;
if ((WithCrypto & APPLICATION_PGP)
&& (mutt_is_application_pgp (b) & (ENCRYPT | SIGN))) {
mutt_body_handler (b, &s);
newhdr->security |= mutt_is_application_pgp (newhdr->content);
b->type = TYPETEXT;
str_replace (&b->subtype, "plain");
mutt_delete_parameter ("x-action", &b->parameter);
}
else
mutt_decode_attachment (b, &s);
if (safe_fclose (&s.fpout) != 0)
goto bail;
str_replace (&b->filename, file);
b->unlink = 1;
mutt_stamp_attachment (b);
mutt_free_body (&b->parts);
if (b->hdr)
b->hdr->content = NULL; /* avoid dangling pointer */
}
/* Fix encryption flags. */
/* No inline if multipart. */
if (WithCrypto && (newhdr->security & INLINE) && newhdr->content->next)
newhdr->security &= ~INLINE;
/* Do we even support multiple mechanisms? */
newhdr->security &= WithCrypto | ~(APPLICATION_PGP | APPLICATION_SMIME);
/* Theoretically, both could be set. Take the one the user wants to set by default. */
if ((newhdr->security & APPLICATION_PGP)
&& (newhdr->security & APPLICATION_SMIME)) {
if (option (OPTSMIMEISDEFAULT))
newhdr->security &= ~APPLICATION_PGP;
else
newhdr->security &= ~APPLICATION_SMIME;
}
rv = 0;
bail:
/* that's it. */
if (bfp != fp)
fclose (bfp);
if (msg)
mx_close_message (&msg);
if (rv == -1) {
mutt_free_envelope (&newhdr->env);
mutt_free_body (&newhdr->content);
}
return rv;
}
开发者ID:BackupTheBerlios,项目名称:mutt-ng-svn,代码行数:101,代码来源:postpone.c
示例15: mutt_num_postponed
/* Return the number of postponed messages.
* if force is 0, use a cached value if it is costly to get a fresh
* count (IMAP) - else check.
*/
int mutt_num_postponed (int force)
{
struct stat st;
CONTEXT ctx;
static time_t LastModify = 0;
static char *OldPostponed = NULL;
if (UpdateNumPostponed) {
UpdateNumPostponed = 0;
force = 1;
}
if (Postponed != OldPostponed) {
OldPostponed = Postponed;
LastModify = 0;
force = 1;
}
if (!Postponed)
return 0;
#ifdef USE_IMAP
/* LastModify is useless for IMAP */
if (imap_is_magic (Postponed, NULL) == M_IMAP) {
if (force) {
short newpc;
newpc = imap_mailbox_check (Postponed, 0);
if (newpc >= 0) {
PostCount = newpc;
debug_print (2, ("%d postponed IMAP messages found.\n", PostCount));
}
else
debug_print (2, ("using old IMAP postponed count.\n"));
}
return PostCount;
}
#endif
if (stat (Postponed, &st) == -1) {
PostCount = 0;
LastModify = 0;
return (0);
}
if (S_ISDIR (st.st_mode)) {
/* if we have a maildir mailbox, we need to stat the "new" dir */
char buf[_POSIX_PATH_MAX];
snprintf (buf, sizeof (buf), "%s/new", Postponed);
if (access (buf, F_OK) == 0 && stat (buf, &st) == -1) {
PostCount = 0;
LastModify = 0;
return 0;
}
}
if (LastModify < st.st_mtime) {
#ifdef USE_NNTP
int optnews = option (OPTNEWS);
#endif
LastModify = st.st_mtime;
if (access (Postponed, R_OK | F_OK) != 0)
return (PostCount = 0);
#ifdef USE_NNTP
if (optnews)
unset_option (OPTNEWS);
#endif
if (mx_open_mailbox (Postponed, M_NOSORT | M_QUIET, &ctx) == NULL)
PostCount = 0;
else
PostCount = ctx.msgcount;
mx_fastclose_mailbox (&ctx);
#ifdef USE_NNTP
if (optnews)
set_option (OPTNEWS);
#endif
}
return (PostCount);
}
开发者ID:BackupTheBerlios,项目名称:mutt-ng-svn,代码行数:88,代码来源:postpone.c
示例16: calculate_visibility
/* this calculates whether a node is the root of a subtree that has visible
* nodes, whether a node itself is visible, whether, if invisible, it has
* depth anyway, and whether any of its later siblings are roots of visible
* subtrees. while it's at it, it frees the old thread display, so we can
* skip parts of the tree in mutt_draw_tree() if we've decided here that we
* don't care about them any more.
*/
static void calculate_visibility (CONTEXT *ctx, int *max_depth)
{
THREAD *tmp, *tree = ctx->tree;
int hide_top_missing = option (OPTHIDETOPMISSING) && !option (OPTHIDEMISSING);
int hide_top_limited = option (OPTHIDETOPLIMITED) && !option (OPTHIDELIMITED);
int depth = 0;
/* we walk each level backwards to make it easier to compute next_subtree_visible */
while (tree->next)
tree = tree->next;
*max_depth = 0;
FOREVER
{
if (depth > *max_depth)
*max_depth = depth;
tree->subtree_visible = 0;
if (tree->message)
{
FREE (&tree->message->tree);
if (VISIBLE (tree->message, ctx))
{
tree->deep = 1;
tree->visible = 1;
tree->message->display_subject = need_display_subject (ctx, tree->message);
for (tmp = tree; tmp; tmp = tmp->parent)
{
if (tmp->subtree_visible)
{
tmp->deep = 1;
tmp->subtree_visible = 2;
break;
}
else
tmp->subtree_visible = 1;
}
}
else
{
tree->visible = 0;
tree->deep = !option (OPTHIDELIMITED);
}
}
else
{
tree->visible = 0;
tree->deep = !option (OPTHIDEMISSING);
}
tree->next_subtree_visible = tree->next && (tree->next->next_subtree_visible
|| tree->next->subtree_visible);
if (tree->child)
{
depth++;
tree = tree->child;
while (tree->next)
tree = tree->next;
}
else if (tree->prev)
tree = tree->prev;
else
{
while (tree && !tree->prev)
{
depth--;
tree = tree->parent;
}
if (!tree)
break;
else
tree = tree->prev;
}
}
/* now fix up for the OPTHIDETOP* options if necessary */
if (hide_top_limited || hide_top_missing)
{
tree = ctx->tree;
FOREVER
{
if (!tree->visible && tree->deep && tree->subtree_visible < 2
&& ((tree->message && hide_top_limited) || (!tree->message && hide_top_missing)))
tree->deep = 0;
if (!tree->deep && tree->child && tree->subtree_visible)
tree = tree->child;
else if (tree->next)
tree = tree->next;
else
{
while (tree && !tree->next)
tree = tree->parent;
if (!tree)
break;
//.........这里部分代码省略.........
开发者ID:2ion,项目名称:mutt-1.5.22,代码行数:101,代码来源:thread.c
示例17: PLAYER
PLAYER(AnimationManager &a, Level &lev,int x,int y):Entity(a,x,y) {
option("Player",0,100,"stay");
STATE = stay;
hit = 0;
obj = lev.GetAllObjects();
}
开发者ID:KarDik465,项目名称:Game,代码行数:6,代码来源:Player.hpp
示例18: mutt_protect
int mutt_protect (HEADER *msg, char *keylist)
{
BODY *pbody = NULL, *tmp_pbody = NULL;
BODY *tmp_smime_pbody = NULL;
BODY *tmp_pgp_pbody = NULL;
int flags = (WithCrypto & APPLICATION_PGP)? msg->security: 0;
int i;
if (!WithCrypto)
return -1;
if ((msg->security & SIGN) && !crypt_valid_passphrase (msg->security))
return (-1);
if ((WithCrypto & APPLICATION_PGP) && ((msg->security & PGPINLINE) == PGPINLINE))
{
/* they really want to send it inline... go for it */
if (!isendwin ()) mutt_endwin _("Invoking PGP...");
pbody = crypt_pgp_traditional_encryptsign (msg->content, flags, keylist);
if (pbody)
{
msg->content = pbody;
return 0;
}
/* otherwise inline won't work...ask for revert */
if ((i = query_quadoption (OPT_PGPMIMEAUTO, _("Message can't be sent inline. Revert to using PGP/MIME?"))) != M_YES)
{
mutt_error _("Mail not sent.");
return -1;
}
/* go ahead with PGP/MIME */
}
if (!isendwin ()) mutt_endwin (NULL);
if ((WithCrypto & APPLICATION_SMIME))
tmp_smime_pbody = msg->content;
if ((WithCrypto & APPLICATION_PGP))
tmp_pgp_pbody = msg->content;
if (option (OPTCRYPTUSEPKA) && (msg->security & SIGN))
{
/* Set sender (necessary for e.g. PKA). */
if ((WithCrypto & APPLICATION_SMIME)
&& (msg->security & APPLICATION_SMIME))
crypt_smime_set_sender (msg->env->from->mailbox);
else if ((WithCrypto & APPLICATION_PGP)
&& (msg->security & APPLICATION_PGP))
crypt_pgp_set_sender (msg->env->from->mailbox);
}
if (msg->security & SIGN)
{
if ((WithCrypto & APPLICATION_SMIME)
&& (msg->security & APPLICATION_SMIME))
{
if (!(tmp_pbody = crypt_smime_sign_message (msg->content)))
return -1;
pbody = tmp_smime_pbody = tmp_pbody;
}
if ((WithCrypto & APPLICATION_PGP)
&& (msg->security & APPLICATION_PGP)
&& (!(flags & ENCRYPT) || option (OPTPGPRETAINABLESIG)))
{
if (!(tmp_pbody = crypt_pgp_sign_message (msg->content)))
return -1;
flags &= ~SIGN;
pbody = tmp_pgp_pbody = tmp_pbody;
}
if (WithCrypto
&& (msg->security & APPLICATION_SMIME)
&& (msg->security & APPLICATION_PGP))
{
/* here comes the draft ;-) */
}
}
if (msg->security & ENCRYPT)
{
if ((WithCrypto & APPLICATION_SMIME)
&& (msg->security & APPLICATION_SMIME))
{
if (!(tmp_pbody = crypt_smime_build_smime_entity (tmp_smime_pbody,
keylist)))
{
/* signed ? free it! */
return (-1);
}
/* free tmp_body if messages was signed AND encrypted ... */
if (tmp_smime_pbody != msg->content && tmp_smime_pbody != tmp_pbody)
{
/* detatch and don't delete msg->content,
which tmp_smime_pbody->parts after signing. */
//.........这里部分代码省略.........
开发者ID:0xAX,项目名称:mutt,代码行数:101,代码来源:crypt.c
示例19: interactive |
请发表评论