rem
stringlengths
0
274k
add
stringlengths
0
169k
context
stringlengths
9
471k
But only, if the other thread is searching already */
But only, if the other thread is not searching already */
find_domain (const char *domain, ypbind_resp *result){ int i, second; pthread_rdwr_rlock_np (&domainlock); second = 0; /* Try only once to find a new server for a unbounded domain */ i = 0; while (i < max_domains) { if (strcmp (domainlist[i].domain, domain) == 0) { if (domainlist[i].active >= 0) { result->ypbind_status = YPBIND_SUCC_VAL; memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr, &domainlist[i].server[domainlist[i].active].addr, sizeof (struct in_addr)); memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port, &domainlist[i].server[domainlist[i].active].port, sizeof (unsigned short int)); if (debug_flag) log_msg (LOG_DEBUG, "YPBINDPROC_DOMAIN: server '%s', port %d", inet_ntoa(domainlist[i].server[domainlist[i].active].addr), ntohs(domainlist[i].server[domainlist[i].active].port)); break; } else if (domainlist[i].active == -2) { result->ypbind_status = YPBIND_SUCC_VAL; memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr, &domainlist[i].ypset.addr, sizeof (struct in_addr)); memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port, &domainlist[i].ypset.port, sizeof (unsigned short int)); if (debug_flag) log_msg (LOG_DEBUG, "YPBINDPROC_DOMAIN: server '%s', port %d", inet_ntoa(domainlist[i].ypset.addr), ntohs(domainlist[i].ypset.port)); break; } else { if (second) { second = 0; break; } /* Look, if we could find a new server for this domain. But only, if the other thread is searching already */ pthread_rdwr_runlock_np (&domainlock); if (pthread_mutex_trylock (&search_lock) == 0) { if (debug_flag) log_msg (LOG_DEBUG, "trylock = success"); if (domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); else ping_all (&domainlist[i]); pthread_mutex_unlock (&search_lock); ++second; continue; } else return; pthread_rdwr_rlock_np (&domainlock); } } ++i; } pthread_rdwr_runlock_np (&domainlock); return;}
pthread_rdwr_rlock_np (&domainlock);
find_domain (const char *domain, ypbind_resp *result){ int i, second; pthread_rdwr_rlock_np (&domainlock); second = 0; /* Try only once to find a new server for a unbounded domain */ i = 0; while (i < max_domains) { if (strcmp (domainlist[i].domain, domain) == 0) { if (domainlist[i].active >= 0) { result->ypbind_status = YPBIND_SUCC_VAL; memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr, &domainlist[i].server[domainlist[i].active].addr, sizeof (struct in_addr)); memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port, &domainlist[i].server[domainlist[i].active].port, sizeof (unsigned short int)); if (debug_flag) log_msg (LOG_DEBUG, "YPBINDPROC_DOMAIN: server '%s', port %d", inet_ntoa(domainlist[i].server[domainlist[i].active].addr), ntohs(domainlist[i].server[domainlist[i].active].port)); break; } else if (domainlist[i].active == -2) { result->ypbind_status = YPBIND_SUCC_VAL; memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr, &domainlist[i].ypset.addr, sizeof (struct in_addr)); memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port, &domainlist[i].ypset.port, sizeof (unsigned short int)); if (debug_flag) log_msg (LOG_DEBUG, "YPBINDPROC_DOMAIN: server '%s', port %d", inet_ntoa(domainlist[i].ypset.addr), ntohs(domainlist[i].ypset.port)); break; } else { if (second) { second = 0; break; } /* Look, if we could find a new server for this domain. But only, if the other thread is searching already */ pthread_rdwr_runlock_np (&domainlock); if (pthread_mutex_trylock (&search_lock) == 0) { if (debug_flag) log_msg (LOG_DEBUG, "trylock = success"); if (domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); else ping_all (&domainlist[i]); pthread_mutex_unlock (&search_lock); ++second; continue; } else return; pthread_rdwr_rlock_np (&domainlock); } } ++i; } pthread_rdwr_runlock_np (&domainlock); return;}
kdDebug() << "All tests OK." << endl; return 0;
int main(int argc, char *argv[]){ KApplication::disableAutoDcopRegistration(); //KApplication app(argc,argv,"testtrash"); KCmdLineArgs::init(argc,argv,"testtrash", 0, 0, 0, 0); KApplication app; TestTrash test; test.runAll();}
assert((!(former_age > 30)) || (age > 0));
time_t get_age() { time_t age; if (_dbufs.empty()) { age = 0; } else { age = time(NULL) - _dbufs.begin()->second->dirty_since; } dout(10) << "former age: " << former_age << " age: " << age << endl; assert((!(former_age > 30)) || (age > 0)); former_age = age; return age; }
close_bindingfile(list->domain);
remove_bindingfile(list->domain);
do_broadcast (struct binding *list){ char *domain = list->domain; bool_t out; enum clnt_stat status; pthread_rdwr_wlock_np (&domainlock); list->active = -1; pthread_rdwr_wunlock_np (&domainlock); in_use = list; /* global variable for eachresult */ status = clnt_broadcast (YPPROG, YPVERS, YPPROC_DOMAIN_NONACK, (xdrproc_t) ypbind_xdr_domainname, (void *)&domain, (xdrproc_t) xdr_bool, (void *)&out, (resultproc_t) eachresult); if (status != RPC_SUCCESS) { close_bindingfile(list->domain); log_msg (LOG_ERR, "broadcast: %s.", clnt_sperrno(status)); } else { pthread_rdwr_rlock_np (&domainlock); update_bindingfile (list); pthread_rdwr_runlock_np (&domainlock); }}
int main(int argc, char **argv)
int main(int , char **)
int main(int argc, char **argv){ signal(SIGCHLD, sigchld_handler); signal(SIGSEGV, sigsegv_handler); Connection parent( 0, 1 ); TARProtocol tar( &parent ); tar.dispatchLoop();}
if (dragon[m][n].status == DEAD)
if (dragon[m][n].matcher_status == DEAD)
atari_atari(int color, int *i, int *j, int save_verbose){ int m, n; int fi, fj; int aa_val; int other = OTHER_COLOR(color); /* Collect worm statuses of opponent's worms. We need to * know this because we only want to report unexpected * results. For example, we do not want to report success * if we find we can kill a worm which is already dead. * The worm status of empty points is set to UNKNOWN to signal * that stones added along the way need special attention. */ if (aa_depth < 2) return 0; memset(forbidden, 0, sizeof(forbidden)); for (m = 0; m < board_size; m++) for (n = 0; n < board_size; n++) { if (p[m][n] == other) { if (dragon[m][n].status == DEAD) aa_status[m][n] = DEAD; else if (worm[m][n].attack_code != 0) { if (worm[m][n].defend_code != 0) aa_status[m][n] = CRITICAL; else aa_status[m][n] = DEAD; } else aa_status[m][n] = ALIVE; } else aa_status[m][n] = UNKNOWN; } /* reclassify a worm with 2 liberties as INSUBSTANTIAL if capturing * it does not result in a live group. */ for (m = 0; m < board_size; m++) for (n = 0; n < board_size; n++) if (p[m][n] == other && worm[m][n].origini == m && worm[m][n].originj == n && worm[m][n].liberties == 2 && aa_status[m][n] != DEAD && !owl_substantial(m, n)) { int ti, tj; for (ti = 0; ti < board_size; ti++) for (tj = 0; tj < board_size; tj++) if (is_worm_origin(ti, tj, m, n)) aa_status[ti][tj] = INSUBSTANTIAL; } if (debug & DEBUG_ATARI_ATARI) { gprintf("atari_atari for %C\n", color); gprintf("aa_status: (ALIVE worms not listed)\n"); for (m = 0; m < board_size; m++) for (n = 0; n < board_size; n++) { if (p[m][n] == other && is_worm_origin(m, n, m, n)) { const char *status = "UNKNOWN (shouldn't happen)"; if (aa_status[m][n] == DEAD) status = "DEAD"; else if (aa_status[m][n] == CRITICAL) status = "CRITICAL"; else if (aa_status[m][n] == INSUBSTANTIAL) status = "INSUBSTANTIAL"; if (aa_status[m][n] != ALIVE) gprintf("%M: %s\n", m, n, status); } } } aa_val = do_atari_atari(color, &fi, &fj, NULL, NULL, -1, -1, save_verbose, 0); if (aa_val == 0) return 0; /* We try excluding the first atari found and see if the * combination still works. Repeat until failure. */ while (1) { int new_aa_val; forbidden[fi][fj] = 1; new_aa_val = do_atari_atari(color, &fi, &fj, NULL, NULL, -1, -1, save_verbose, aa_val); /* The last do_atari_atari call fails. When do_atari_atari fails, * it does not change the value of (fi, fj), so these correspond * to a move that works and is necessary. */ if (new_aa_val == 0) { if (i) *i = fi; if (j) *j = fj; return aa_val; } aa_val = new_aa_val; } /* We'll never get here, but the compiler may be more happy if it * looks like we're returning something. */ return 0;}
* into (*i, *j).
* into (defendi, defendj).
atari_atari_confirm_safety(int color, int ti, int tj, int *i, int *j, int minsize){ int m, n; int fi, fj; int defendi, defendj; int aa_val; int other = OTHER_COLOR(color); /* If aa_depth is too small, we can't see any combination attacks, * so in this respect the move is safe enough. */ if (aa_depth < 2) return 1; /* Collect worm statuses of opponent's worms. We need to * know this because we only want to report unexpected * results. For example, we do not want to report success * if we find we can kill a worm which is already dead. * The worm status of empty points is set to UNKNOWN to signal * that stones added along the way need special attention. */ memset(forbidden, 0, sizeof(forbidden)); for (m = 0; m < board_size; m++) for (n = 0; n < board_size; n++) { if (p[m][n] == color) { if (dragon[m][n].matcher_status == DEAD) aa_status[m][n] = DEAD; else if (worm[m][n].attack_code != 0) { if (worm[m][n].defend_code != 0) aa_status[m][n] = CRITICAL; else aa_status[m][n] = DEAD; } else aa_status[m][n] = ALIVE; } else aa_status[m][n] = UNKNOWN; } /* reclassify a worm with 2 liberties as INSUBSTANTIAL if capturing * it does not result in a live group. */ for (m = 0; m < board_size; m++) for (n = 0; n < board_size; n++) if (p[m][n] == color && worm[m][n].origini == m && worm[m][n].originj == n && worm[m][n].liberties == 2 && aa_status[m][n] == ALIVE && !owl_substantial(m, n)) { int ui, uj; for (ui = 0; ui < board_size; ui++) for (uj = 0; uj < board_size; uj++) if (is_worm_origin(ui, uj, m, n)) aa_status[ui][uj] = INSUBSTANTIAL; } if (debug & DEBUG_ATARI_ATARI) { gprintf("atari_atari for %C\n", other); gprintf("aa_status: (ALIVE worms not listed)\n"); for (m = 0; m < board_size; m++) for (n = 0; n < board_size; n++) { if (p[m][n] == color && is_worm_origin(m, n, m, n)) { const char *status = "UNKNOWN (shouldn't happen)"; if (aa_status[m][n] == DEAD) status = "DEAD"; else if (aa_status[m][n] == CRITICAL) status = "CRITICAL"; else if (aa_status[m][n] == INSUBSTANTIAL) status = "INSUBSTANTIAL"; if (aa_status[m][n] != ALIVE) gprintf("%M: %s\n", m, n, status); } } } /* Accept illegal ko capture here. */ if (!tryko(ti, tj, color, NULL, EMPTY, -1, -1)) /* Really shouldn't happen. */ abortgo(__FILE__, __LINE__, "trymove", ti, tj); aa_val = do_atari_atari(other, &fi, &fj, &defendi, &defendj, -1, -1, 0, minsize); if (aa_val == 0 || defendi == -1) { /* No sufficiently large combination attack, so the move is safe from * this danger. * * On rare occasions do_atari_atari might find a combination * but no defense. In this case we assume that the combination * is illusory. */ popgo(); return 1; } while (aa_val > 0) { /* Try dropping moves from the combination and see if it still * works. What we really want is to get the proper defense move * into (*i, *j). */ forbidden[fi][fj] = 1; aa_val = do_atari_atari(other, &fi, &fj, i, j, -1, -1, 0, aa_val); } popgo(); /* We know that a combination exists, but we don't know if * the original move at (ai, aj) was really relevant. So we * try omitting it and see if a combination is still found. */ if (do_atari_atari(other, NULL, NULL, NULL, NULL, -1, -1, 0, minsize) >= aa_val) return 1; else return 0;}
aa_val = do_atari_atari(other, &fi, &fj, i, j, -1, -1, 0, aa_val);
aa_val = do_atari_atari(other, &fi, &fj, &defendi, &defendj, -1, -1, 0, aa_val);
atari_atari_confirm_safety(int color, int ti, int tj, int *i, int *j, int minsize){ int m, n; int fi, fj; int defendi, defendj; int aa_val; int other = OTHER_COLOR(color); /* If aa_depth is too small, we can't see any combination attacks, * so in this respect the move is safe enough. */ if (aa_depth < 2) return 1; /* Collect worm statuses of opponent's worms. We need to * know this because we only want to report unexpected * results. For example, we do not want to report success * if we find we can kill a worm which is already dead. * The worm status of empty points is set to UNKNOWN to signal * that stones added along the way need special attention. */ memset(forbidden, 0, sizeof(forbidden)); for (m = 0; m < board_size; m++) for (n = 0; n < board_size; n++) { if (p[m][n] == color) { if (dragon[m][n].matcher_status == DEAD) aa_status[m][n] = DEAD; else if (worm[m][n].attack_code != 0) { if (worm[m][n].defend_code != 0) aa_status[m][n] = CRITICAL; else aa_status[m][n] = DEAD; } else aa_status[m][n] = ALIVE; } else aa_status[m][n] = UNKNOWN; } /* reclassify a worm with 2 liberties as INSUBSTANTIAL if capturing * it does not result in a live group. */ for (m = 0; m < board_size; m++) for (n = 0; n < board_size; n++) if (p[m][n] == color && worm[m][n].origini == m && worm[m][n].originj == n && worm[m][n].liberties == 2 && aa_status[m][n] == ALIVE && !owl_substantial(m, n)) { int ui, uj; for (ui = 0; ui < board_size; ui++) for (uj = 0; uj < board_size; uj++) if (is_worm_origin(ui, uj, m, n)) aa_status[ui][uj] = INSUBSTANTIAL; } if (debug & DEBUG_ATARI_ATARI) { gprintf("atari_atari for %C\n", other); gprintf("aa_status: (ALIVE worms not listed)\n"); for (m = 0; m < board_size; m++) for (n = 0; n < board_size; n++) { if (p[m][n] == color && is_worm_origin(m, n, m, n)) { const char *status = "UNKNOWN (shouldn't happen)"; if (aa_status[m][n] == DEAD) status = "DEAD"; else if (aa_status[m][n] == CRITICAL) status = "CRITICAL"; else if (aa_status[m][n] == INSUBSTANTIAL) status = "INSUBSTANTIAL"; if (aa_status[m][n] != ALIVE) gprintf("%M: %s\n", m, n, status); } } } /* Accept illegal ko capture here. */ if (!tryko(ti, tj, color, NULL, EMPTY, -1, -1)) /* Really shouldn't happen. */ abortgo(__FILE__, __LINE__, "trymove", ti, tj); aa_val = do_atari_atari(other, &fi, &fj, &defendi, &defendj, -1, -1, 0, minsize); if (aa_val == 0 || defendi == -1) { /* No sufficiently large combination attack, so the move is safe from * this danger. * * On rare occasions do_atari_atari might find a combination * but no defense. In this case we assume that the combination * is illusory. */ popgo(); return 1; } while (aa_val > 0) { /* Try dropping moves from the combination and see if it still * works. What we really want is to get the proper defense move * into (*i, *j). */ forbidden[fi][fj] = 1; aa_val = do_atari_atari(other, &fi, &fj, i, j, -1, -1, 0, aa_val); } popgo(); /* We know that a combination exists, but we don't know if * the original move at (ai, aj) was really relevant. So we * try omitting it and see if a combination is still found. */ if (do_atari_atari(other, NULL, NULL, NULL, NULL, -1, -1, 0, minsize) >= aa_val) return 1; else return 0;}
-1, -1, 0, minsize) >= aa_val)
-1, -1, 0, minsize) >= aa_val) return 0; else
atari_atari_confirm_safety(int color, int ti, int tj, int *i, int *j, int minsize){ int m, n; int fi, fj; int defendi, defendj; int aa_val; int other = OTHER_COLOR(color); /* If aa_depth is too small, we can't see any combination attacks, * so in this respect the move is safe enough. */ if (aa_depth < 2) return 1; /* Collect worm statuses of opponent's worms. We need to * know this because we only want to report unexpected * results. For example, we do not want to report success * if we find we can kill a worm which is already dead. * The worm status of empty points is set to UNKNOWN to signal * that stones added along the way need special attention. */ memset(forbidden, 0, sizeof(forbidden)); for (m = 0; m < board_size; m++) for (n = 0; n < board_size; n++) { if (p[m][n] == color) { if (dragon[m][n].matcher_status == DEAD) aa_status[m][n] = DEAD; else if (worm[m][n].attack_code != 0) { if (worm[m][n].defend_code != 0) aa_status[m][n] = CRITICAL; else aa_status[m][n] = DEAD; } else aa_status[m][n] = ALIVE; } else aa_status[m][n] = UNKNOWN; } /* reclassify a worm with 2 liberties as INSUBSTANTIAL if capturing * it does not result in a live group. */ for (m = 0; m < board_size; m++) for (n = 0; n < board_size; n++) if (p[m][n] == color && worm[m][n].origini == m && worm[m][n].originj == n && worm[m][n].liberties == 2 && aa_status[m][n] == ALIVE && !owl_substantial(m, n)) { int ui, uj; for (ui = 0; ui < board_size; ui++) for (uj = 0; uj < board_size; uj++) if (is_worm_origin(ui, uj, m, n)) aa_status[ui][uj] = INSUBSTANTIAL; } if (debug & DEBUG_ATARI_ATARI) { gprintf("atari_atari for %C\n", other); gprintf("aa_status: (ALIVE worms not listed)\n"); for (m = 0; m < board_size; m++) for (n = 0; n < board_size; n++) { if (p[m][n] == color && is_worm_origin(m, n, m, n)) { const char *status = "UNKNOWN (shouldn't happen)"; if (aa_status[m][n] == DEAD) status = "DEAD"; else if (aa_status[m][n] == CRITICAL) status = "CRITICAL"; else if (aa_status[m][n] == INSUBSTANTIAL) status = "INSUBSTANTIAL"; if (aa_status[m][n] != ALIVE) gprintf("%M: %s\n", m, n, status); } } } /* Accept illegal ko capture here. */ if (!tryko(ti, tj, color, NULL, EMPTY, -1, -1)) /* Really shouldn't happen. */ abortgo(__FILE__, __LINE__, "trymove", ti, tj); aa_val = do_atari_atari(other, &fi, &fj, &defendi, &defendj, -1, -1, 0, minsize); if (aa_val == 0 || defendi == -1) { /* No sufficiently large combination attack, so the move is safe from * this danger. * * On rare occasions do_atari_atari might find a combination * but no defense. In this case we assume that the combination * is illusory. */ popgo(); return 1; } while (aa_val > 0) { /* Try dropping moves from the combination and see if it still * works. What we really want is to get the proper defense move * into (*i, *j). */ forbidden[fi][fj] = 1; aa_val = do_atari_atari(other, &fi, &fj, i, j, -1, -1, 0, aa_val); } popgo(); /* We know that a combination exists, but we don't know if * the original move at (ai, aj) was really relevant. So we * try omitting it and see if a combination is still found. */ if (do_atari_atari(other, NULL, NULL, NULL, NULL, -1, -1, 0, minsize) >= aa_val) return 1; else return 0;}
else return 0;
atari_atari_confirm_safety(int color, int ti, int tj, int *i, int *j, int minsize){ int m, n; int fi, fj; int defendi, defendj; int aa_val; int other = OTHER_COLOR(color); /* If aa_depth is too small, we can't see any combination attacks, * so in this respect the move is safe enough. */ if (aa_depth < 2) return 1; /* Collect worm statuses of opponent's worms. We need to * know this because we only want to report unexpected * results. For example, we do not want to report success * if we find we can kill a worm which is already dead. * The worm status of empty points is set to UNKNOWN to signal * that stones added along the way need special attention. */ memset(forbidden, 0, sizeof(forbidden)); for (m = 0; m < board_size; m++) for (n = 0; n < board_size; n++) { if (p[m][n] == color) { if (dragon[m][n].matcher_status == DEAD) aa_status[m][n] = DEAD; else if (worm[m][n].attack_code != 0) { if (worm[m][n].defend_code != 0) aa_status[m][n] = CRITICAL; else aa_status[m][n] = DEAD; } else aa_status[m][n] = ALIVE; } else aa_status[m][n] = UNKNOWN; } /* reclassify a worm with 2 liberties as INSUBSTANTIAL if capturing * it does not result in a live group. */ for (m = 0; m < board_size; m++) for (n = 0; n < board_size; n++) if (p[m][n] == color && worm[m][n].origini == m && worm[m][n].originj == n && worm[m][n].liberties == 2 && aa_status[m][n] == ALIVE && !owl_substantial(m, n)) { int ui, uj; for (ui = 0; ui < board_size; ui++) for (uj = 0; uj < board_size; uj++) if (is_worm_origin(ui, uj, m, n)) aa_status[ui][uj] = INSUBSTANTIAL; } if (debug & DEBUG_ATARI_ATARI) { gprintf("atari_atari for %C\n", other); gprintf("aa_status: (ALIVE worms not listed)\n"); for (m = 0; m < board_size; m++) for (n = 0; n < board_size; n++) { if (p[m][n] == color && is_worm_origin(m, n, m, n)) { const char *status = "UNKNOWN (shouldn't happen)"; if (aa_status[m][n] == DEAD) status = "DEAD"; else if (aa_status[m][n] == CRITICAL) status = "CRITICAL"; else if (aa_status[m][n] == INSUBSTANTIAL) status = "INSUBSTANTIAL"; if (aa_status[m][n] != ALIVE) gprintf("%M: %s\n", m, n, status); } } } /* Accept illegal ko capture here. */ if (!tryko(ti, tj, color, NULL, EMPTY, -1, -1)) /* Really shouldn't happen. */ abortgo(__FILE__, __LINE__, "trymove", ti, tj); aa_val = do_atari_atari(other, &fi, &fj, &defendi, &defendj, -1, -1, 0, minsize); if (aa_val == 0 || defendi == -1) { /* No sufficiently large combination attack, so the move is safe from * this danger. * * On rare occasions do_atari_atari might find a combination * but no defense. In this case we assume that the combination * is illusory. */ popgo(); return 1; } while (aa_val > 0) { /* Try dropping moves from the combination and see if it still * works. What we really want is to get the proper defense move * into (*i, *j). */ forbidden[fi][fj] = 1; aa_val = do_atari_atari(other, &fi, &fj, i, j, -1, -1, 0, aa_val); } popgo(); /* We know that a combination exists, but we don't know if * the original move at (ai, aj) was really relevant. So we * try omitting it and see if a combination is still found. */ if (do_atari_atari(other, NULL, NULL, NULL, NULL, -1, -1, 0, minsize) >= aa_val) return 1; else return 0;}
char *domain = list->domain;
char *domain;
do_broadcast (struct binding *list){ char *domain = list->domain; bool_t out; enum clnt_stat status; if (debug_flag) log_msg (LOG_DEBUG, _("do_broadcast() for domain '%s' is called"), domain); pthread_rdwr_wlock_np (&domainlock); list->active = -1; pthread_rdwr_wunlock_np (&domainlock); in_use = list; /* global variable for eachresult */ status = clnt_broadcast (YPPROG, YPVERS, YPPROC_DOMAIN_NONACK, (xdrproc_t) ypbind_xdr_domainname, (void *)&domain, (xdrproc_t) xdr_bool, (void *)&out, (resultproc_t) eachresult); if (status != RPC_SUCCESS) { remove_bindingfile(list->domain); log_msg (LOG_ERR, "broadcast: %s.", clnt_sperrno(status)); } else { pthread_rdwr_rlock_np (&domainlock); update_bindingfile (list); pthread_rdwr_runlock_np (&domainlock); } if (debug_flag) log_msg (LOG_DEBUG, _("leave do_broadcast() for domain '%s'"), domain);}
remove_bindingfile(list->domain); log_msg (LOG_ERR, "broadcast: %s.", clnt_sperrno(status));
remove_bindingfile (domain); log_msg (LOG_ERR, "broadcast: %s.", clnt_sperrno (status));
do_broadcast (struct binding *list){ char *domain = list->domain; bool_t out; enum clnt_stat status; if (debug_flag) log_msg (LOG_DEBUG, _("do_broadcast() for domain '%s' is called"), domain); pthread_rdwr_wlock_np (&domainlock); list->active = -1; pthread_rdwr_wunlock_np (&domainlock); in_use = list; /* global variable for eachresult */ status = clnt_broadcast (YPPROG, YPVERS, YPPROC_DOMAIN_NONACK, (xdrproc_t) ypbind_xdr_domainname, (void *)&domain, (xdrproc_t) xdr_bool, (void *)&out, (resultproc_t) eachresult); if (status != RPC_SUCCESS) { remove_bindingfile(list->domain); log_msg (LOG_ERR, "broadcast: %s.", clnt_sperrno(status)); } else { pthread_rdwr_rlock_np (&domainlock); update_bindingfile (list); pthread_rdwr_runlock_np (&domainlock); } if (debug_flag) log_msg (LOG_DEBUG, _("leave do_broadcast() for domain '%s'"), domain);}
{ pthread_rdwr_rlock_np (&domainlock); update_bindingfile (list); pthread_rdwr_runlock_np (&domainlock); }
update_bindingfile (list); pthread_rdwr_runlock_np (&domainlock);
do_broadcast (struct binding *list){ char *domain = list->domain; bool_t out; enum clnt_stat status; if (debug_flag) log_msg (LOG_DEBUG, _("do_broadcast() for domain '%s' is called"), domain); pthread_rdwr_wlock_np (&domainlock); list->active = -1; pthread_rdwr_wunlock_np (&domainlock); in_use = list; /* global variable for eachresult */ status = clnt_broadcast (YPPROG, YPVERS, YPPROC_DOMAIN_NONACK, (xdrproc_t) ypbind_xdr_domainname, (void *)&domain, (xdrproc_t) xdr_bool, (void *)&out, (resultproc_t) eachresult); if (status != RPC_SUCCESS) { remove_bindingfile(list->domain); log_msg (LOG_ERR, "broadcast: %s.", clnt_sperrno(status)); } else { pthread_rdwr_rlock_np (&domainlock); update_bindingfile (list); pthread_rdwr_runlock_np (&domainlock); } if (debug_flag) log_msg (LOG_DEBUG, _("leave do_broadcast() for domain '%s'"), domain);}
pos, dragon_value[k], dragon[k]);
pos, dragon_value[k], dragons[k]);
estimate_strategical_value(int pos, int color, float score){ int k; int l; int aa = NO_MOVE; int bb = NO_MOVE; int d1 = -1; int d2 = -1; int worm1 = -1; int worm2 = -1; int ecolor = 0; float this_value = 0.0; float tot_value = 0.0; /* Strategical value of connecting or cutting dragons. */ static float dragon_value[MAX_DRAGONS]; for (k = 0; k < next_dragon; k++) dragon_value[k] = 0.0; for (k = 0; k < MAX_REASONS; k++) { int r = move[pos].reason[k]; if (r < 0) break; this_value = 0.0; switch (move_reasons[r].type) { case ATTACK_MOVE: case DEFEND_MOVE: worm1 = move_reasons[r].what; aa = worms[worm1]; /* Attack on our stones. */ if (move_reasons[r].type == ATTACK_MOVE && board[aa] == color) break; /* Defense of enemy stones. */ if (move_reasons[r].type == DEFEND_MOVE && board[aa] != color) break; /* Defenseless stone */ if (worm[I(aa)][J(aa)].defend_code == 0) break; /* Require the defense to be strategically viable. */ if (move_reasons[r].type == DEFEND_MOVE && !strategically_sound_defense(aa, pos)) break; /* Do the same for attack moves. */ if (move_reasons[r].type == ATTACK_MOVE && !move[pos].move_safety) break; /* This is totally ad hoc, just guessing the value of * potential cutting points. */ if (worm[I(aa)][J(aa)].cutstone2 > 1) { this_value = 10.0 * (worm[I(aa)][J(aa)].cutstone2 - 1); TRACE(" %1m: %f - %1m cutstone\n", pos, this_value, aa); } tot_value += this_value; /* If the string is a lunch for a weak dragon, the attack or * defense has a strategical value. This can be valued along * the same lines as strategic_attack/strategic_defend. * * No points are awarded if the lunch is an inessential dragon * or worm. */ if (DRAGON2(I(aa), J(aa)).safety == INESSENTIAL || worm[I(aa)][J(aa)].inessential) break; /* Can't use k in this loop too. */ for (l = 0; l < next_lunch; l++) if (lunch_worm[l] == worm1) { d1 = lunch_dragon[l]; bb = dragons[d1]; /* FIXME: This value cannot be computed without some measurement of how the actual move affects the dragon. The dragon safety alone is not enough. The question is whether the dragon is threatened by the move or not. */ this_value = (dragon[I(bb)][J(bb)].effective_size * (1.0 - dragon_safety(bb, 0))); /* If this dragon consists of only one worm and that worm * can be tactically captured or defended by this move, we * have already counted the points as territorial value, * unless it's assumed to be dead. */ if (dragon[I(bb)][J(bb)].matcher_status != DEAD && dragon[I(bb)][J(bb)].size == worm[I(bb)][J(bb)].size && (move_reason_known(pos, ATTACK_MOVE, find_worm(bb)) || move_reason_known(pos, DEFEND_MOVE, find_worm(bb)))) this_value = 0.0; if (this_value > dragon_value[d1]) dragon_value[d1] = this_value; } break; case ATTACK_THREAT_MOVE: case DEFEND_THREAT_MOVE: break; case ATTACK_EITHER_MOVE: case DEFEND_BOTH_MOVE: /* This is complete nonsense, but still better than nothing. * FIXME: Do this in a reasonable way. */ worm1 = worm_pair1[move_reasons[r].what]; worm2 = worm_pair2[move_reasons[r].what]; aa = worms[worm1]; bb = worms[worm2]; /* If both worms are dead, this move reason has no value. */ if (dragon[I(aa)][J(aa)].matcher_status == DEAD && dragon[I(bb)][J(bb)].matcher_status == DEAD) break; /* If we already have unconditional attack or defense of * either worm, this move reason has no additional value. */ if (move_reasons[r].type == ATTACK_EITHER_MOVE && (move_reason_known(pos, ATTACK_MOVE, worm1) || move_reason_known(pos, ATTACK_MOVE, worm2))) break; if (move_reasons[r].type == DEFEND_BOTH_MOVE && (move_reason_known(pos, DEFEND_MOVE, worm1) || move_reason_known(pos, DEFEND_MOVE, worm2))) break; /* Also if there is a combination attack, we assume it covers * the same thing. */ if (move_reasons[r].type == ATTACK_EITHER_MOVE && move_reason_known(pos, MY_ATARI_ATARI_MOVE, -1)) break; if (move_reasons[r].type == DEFEND_BOTH_MOVE && move_reason_known(pos, YOUR_ATARI_ATARI_MOVE, -1)) break; this_value = 2 * gg_min(worm[I(aa)][J(aa)].effective_size, worm[I(bb)][J(bb)].effective_size); if (move_reasons[r].type == ATTACK_EITHER_MOVE) TRACE(" %1m: %f - attacks either %1m or %1m\n", pos, this_value, aa, bb); else TRACE(" %1m: %f - defends both %1m and %1m\n", pos, this_value, aa, bb); tot_value += this_value; break; case CONNECT_MOVE: if (!move[pos].move_safety) break; /* Otherwise fall through. */ case CUT_MOVE: if (doing_scoring && !move[pos].move_safety) break; d1 = conn_dragon1[move_reasons[r].what]; d2 = conn_dragon2[move_reasons[r].what]; aa = dragons[d1]; bb = dragons[d2]; /* If we are ahead by more than 20, value connections more strongly */ if ((color == WHITE && score > 20.0) || (color == BLACK && score < -20.0)) this_value = connection_value(aa, bb, pos, gg_abs(score)); else this_value = connection_value(aa, bb, pos, 0); if (this_value > dragon_value[d1]) dragon_value[d1] = this_value; if ((color == WHITE && score > 20.0) || (color == BLACK && score < -20.0)) this_value = connection_value(bb, aa, pos, gg_abs(score)); else this_value = connection_value(bb, aa, pos, 0); if (this_value > dragon_value[d2]) dragon_value[d2] = this_value; break; case SEMEAI_MOVE: /* * The strategical value of winning a semeai is * own dragons (usually) becomes fully secure, while adjoining * enemy dragons do not. * * FIXME: Valuation not implemented at all yet. */ break; case VITAL_EYE_MOVE: /* * The value of the threatened group itself has already been * accounted for in territorial_value. Now we need to determine * the effect this has on surrounding groups. * * FIXME: Valuation not implemented. */ aa = eyes[move_reasons[r].what]; ecolor = eyecolor[move_reasons[r].what]; if (ecolor == WHITE) bb = white_eye[I(aa)][J(aa)].dragon; else bb = black_eye[I(aa)][J(aa)].dragon; if (bb == NO_MOVE) /* Maybe we should assert this not to happen. */ break; /* If there is an owl attack/defend move reason for this location, * we don't care about it, since otherwise we would count the * points twice. */ if (move_reason_known(pos, OWL_DEFEND_MOVE, find_dragon(bb)) || move_reason_known(pos, OWL_ATTACK_MOVE, find_dragon(bb))) { DEBUG(DEBUG_MOVE_REASONS, " %1m: 0.0 - vital for %1m: owl attack/defense as well\n", pos, bb); break; }#if 0 if (dragon[bi][bj].status == CRITICAL) { this_value = ??? TRACE(" %m: %f - vital for %m\n", m, n, this_value, bi, bj); tot_value += this_value; }#endif break; case STRATEGIC_ATTACK_MOVE: case STRATEGIC_DEFEND_MOVE: /* The right way to do this is to estimate the safety of the * dragon before and after the move. Unfortunately we are * missing good ways to do this currently. * * Temporary solution is to only look at an ad hoc measure of * the dragon safety and ignoring the effectiveness of the * move. * * FIXME: Improve the implementation. */ d1 = move_reasons[r].what; aa = dragons[d1]; /* FIXME: This value cannot be computed without some measurement of how the actual move affects the dragon. The dragon safety alone is not enough. The question is whether the dragon is threatened by the move or not. */ this_value = (dragon[I(aa)][J(aa)].effective_size * (1.0 - dragon_safety(aa, 1))); /* To prefer good connections and cuts, we lower this value * somewhat. */ this_value *= 0.75; if (this_value > dragon_value[d1]) dragon_value[d1] = this_value; break; } } for (k = 0; k < next_dragon; k++) { if (dragon_value[k] == 0.0) continue; aa = dragons[k]; /* If this dragon consists of only one worm and that worm can * be tactically captured or defended by this move, we have * already counted the points as territorial value, unless * it's assumed to be dead. */ if (dragon[I(aa)][J(aa)].matcher_status != DEAD && dragon[I(aa)][J(aa)].size == worm[I(aa)][J(aa)].size && (move_reason_known(pos, ATTACK_MOVE, find_worm(aa)) || move_reason_known(pos, DEFEND_MOVE, find_worm(aa)))) continue; /* If the dragon has been owl captured, owl defended, or involved * in a semeai, we have likewise already counted the points as * territorial value. */ if (move_reason_known(pos, OWL_ATTACK_MOVE, k) || move_reason_known(pos, OWL_DEFEND_MOVE, k) || move_reason_known(pos, SEMEAI_MOVE, k)) { /* But if the strategical value was larger than the territorial * value (e.g. because connecting to strong dragon) we award the * excess value as a bonus. */ float excess_value = (dragon_value[k] - 2 * dragon[I(dragons[k])][J(dragons[k])].effective_size); if (excess_value > 0.0) { TRACE(" %1m: %f - strategic bonus for %1m\n", pos, excess_value, dragons[k]); tot_value += excess_value; } continue; } TRACE(" %1m: %f - strategic effect on %1m\n", pos, dragon_value[k], dragon[k]); tot_value += dragon_value[k]; } move[pos].strategical_value = tot_value;}
else { if (KStandardDirs::exists( QDir::currentDirPath() + "/" + URL ) ) file = QDir::currentDirPath() + "/" + URL; ret = xmlNewInputFromFile(ctxt, file.latin1()); }
xmlParserInputPtr meinExternalEntityLoader(const char *URL, const char *ID, xmlParserCtxtPtr ctxt) { xmlParserInputPtr ret = NULL; // fprintf(stderr, "loading %s %s %s\n", URL, ID, ctxt->directory); if (URL == NULL) { if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL)) ctxt->sax->warning(ctxt, "failed to load external entity \"%s\"\n", ID); return(NULL); } if (!strcmp(ID, "-//OASIS//DTD DocBook XML V4.1.2//EN")) URL = "docbook/xml-dtd-4.1.2/docbookx.dtd"; if (!strcmp(ID, "-//OASIS//DTD XML DocBook V4.1.2//EN")) URL = "docbook/xml-dtd-4.1.2/docbookx.dtd"; if (!strcmp(ID, "-//KDE//DTD DocBook XML V4.1-Based Variant V1.0//EN")) URL = "customization/dtd/kdex.dtd"; if (!strcmp(ID, "-//KDE//DTD DocBook XML V4.1.2-Based Variant V1.0//EN")) URL = "customization/dtd/kdex.dtd"; QString file = locate("dtd", URL); if (!file.isEmpty()) ret = xmlNewInputFromFile(ctxt, file.latin1()); if (ret == NULL) { if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL)) ctxt->sax->warning(ctxt, "failed to load external entity \"%s\"\n", URL); } return(ret);}
if (ctxt->xinclude != 0) { #ifdef LIBXML_XINCLUDE_ENABLED xmlXIncludeProcess(doc); #else xsltGenericError(xsltGenericErrorContext, "xsltLoadDocument(%s) : XInclude processing not compiled in\n", URI); #endif }
xsltLoadDocument(xsltTransformContextPtr ctxt, const xmlChar *URI) { xsltDocumentPtr ret; xmlDocPtr doc; if ((ctxt == NULL) || (URI == NULL)) return(NULL); /* * Walk the context list to find the document if preparsed */ ret = ctxt->docList; while (ret != NULL) { if ((ret->doc != NULL) && (ret->doc->URL != NULL) && (xmlStrEqual(ret->doc->URL, URI))) return(ret); ret = ret->next; } doc = xmlParseFile((const char *) URI); if (doc == NULL) return(NULL); ret = xsltNewDocument(ctxt, doc); return(ret);}
inline bool QgsClipper::inside(const std::vector<QgsPoint>& pa, int p, boundary b)
inline bool QgsClipper::inside(const double x, const double y, boundary b)
inline bool QgsClipper::inside(const std::vector<QgsPoint>& pa, int p, boundary b){ switch (b) { case Xmax: // x < maxX is inside if (pa[p].x() < maxX) return true; break; case Xmin: // x > minX is inside if (pa[p].x() > minX) return true; break; case Ymax: // y < maxY is inside if (pa[p].y() < maxY) return true; break; case Ymin: // y > minY is inside if (pa[p].y() > minY) return true; break; } return false;}
if (pa[p].x() < maxX)
if (x < maxX)
inline bool QgsClipper::inside(const std::vector<QgsPoint>& pa, int p, boundary b){ switch (b) { case Xmax: // x < maxX is inside if (pa[p].x() < maxX) return true; break; case Xmin: // x > minX is inside if (pa[p].x() > minX) return true; break; case Ymax: // y < maxY is inside if (pa[p].y() < maxY) return true; break; case Ymin: // y > minY is inside if (pa[p].y() > minY) return true; break; } return false;}
if (pa[p].x() > minX)
if (x > minX)
inline bool QgsClipper::inside(const std::vector<QgsPoint>& pa, int p, boundary b){ switch (b) { case Xmax: // x < maxX is inside if (pa[p].x() < maxX) return true; break; case Xmin: // x > minX is inside if (pa[p].x() > minX) return true; break; case Ymax: // y < maxY is inside if (pa[p].y() < maxY) return true; break; case Ymin: // y > minY is inside if (pa[p].y() > minY) return true; break; } return false;}
if (pa[p].y() < maxY)
if (y < maxY)
inline bool QgsClipper::inside(const std::vector<QgsPoint>& pa, int p, boundary b){ switch (b) { case Xmax: // x < maxX is inside if (pa[p].x() < maxX) return true; break; case Xmin: // x > minX is inside if (pa[p].x() > minX) return true; break; case Ymax: // y < maxY is inside if (pa[p].y() < maxY) return true; break; case Ymin: // y > minY is inside if (pa[p].y() > minY) return true; break; } return false;}
if (pa[p].y() > minY)
if (y > minY)
inline bool QgsClipper::inside(const std::vector<QgsPoint>& pa, int p, boundary b){ switch (b) { case Xmax: // x < maxX is inside if (pa[p].x() < maxX) return true; break; case Xmin: // x > minX is inside if (pa[p].x() > minX) return true; break; case Ymax: // y < maxY is inside if (pa[p].y() < maxY) return true; break; case Ymin: // y > minY is inside if (pa[p].y() > minY) return true; break; } return false;}
inline QgsPoint QgsClipper::intersect(const std::vector<QgsPoint>& pa, int i1, int i2, boundary b)
inline QgsPoint QgsClipper::intersect(const double x1, const double y1, const double x2, const double y2, boundary b)
inline QgsPoint QgsClipper::intersect(const std::vector<QgsPoint>& pa, int i1, int i2, boundary b){ // This function assumes that the two given points cross the given // boundary. Making this assumption allows some optimisations. QgsPoint p1 = pa[i1]; QgsPoint p2 = pa[i2]; double r_n, r_d; switch (b) { case Xmax: // x = maxX boundary r_n = -(p1.x() - maxX) * (maxY - minY); r_d = (p2.x() - p1.x()) * (maxY - minY); break; case Xmin: // x = minX boundary r_n = -(p1.x() - minX) * (maxY - minY); r_d = (p2.x() - p1.x()) * (maxY - minY); break; case Ymax: // y = maxY boundary r_n = (p1.y() - maxY) * (maxX - minX); r_d = - (p2.y() - p1.y()) * (maxX - minX); break; case Ymin: // y = minY boundary r_n = (p1.y() - minY) * (maxX - minX); r_d = - (p2.y() - p1.y()) * (maxX - minX); break; } QgsPoint p; if (std::abs(r_d) > SMALL_NUM && std::abs(r_n) > SMALL_NUM) { // they cross double r = r_n / r_d; p.set(p1.x() + r*(p2.x() - p1.x()), p1.y() + r*(p2.y() - p1.y())); } else { // Should never get here, but if we do for some reason, cause a // clunk because something else is wrong if we do. Q_ASSERT(std::abs(r_d) > SMALL_NUM && std::abs(r_n) > SMALL_NUM); } return p;}
QgsPoint p1 = pa[i1]; QgsPoint p2 = pa[i2];
inline QgsPoint QgsClipper::intersect(const std::vector<QgsPoint>& pa, int i1, int i2, boundary b){ // This function assumes that the two given points cross the given // boundary. Making this assumption allows some optimisations. QgsPoint p1 = pa[i1]; QgsPoint p2 = pa[i2]; double r_n, r_d; switch (b) { case Xmax: // x = maxX boundary r_n = -(p1.x() - maxX) * (maxY - minY); r_d = (p2.x() - p1.x()) * (maxY - minY); break; case Xmin: // x = minX boundary r_n = -(p1.x() - minX) * (maxY - minY); r_d = (p2.x() - p1.x()) * (maxY - minY); break; case Ymax: // y = maxY boundary r_n = (p1.y() - maxY) * (maxX - minX); r_d = - (p2.y() - p1.y()) * (maxX - minX); break; case Ymin: // y = minY boundary r_n = (p1.y() - minY) * (maxX - minX); r_d = - (p2.y() - p1.y()) * (maxX - minX); break; } QgsPoint p; if (std::abs(r_d) > SMALL_NUM && std::abs(r_n) > SMALL_NUM) { // they cross double r = r_n / r_d; p.set(p1.x() + r*(p2.x() - p1.x()), p1.y() + r*(p2.y() - p1.y())); } else { // Should never get here, but if we do for some reason, cause a // clunk because something else is wrong if we do. Q_ASSERT(std::abs(r_d) > SMALL_NUM && std::abs(r_n) > SMALL_NUM); } return p;}
r_n = -(p1.x() - maxX) * (maxY - minY); r_d = (p2.x() - p1.x()) * (maxY - minY);
r_n = -(x1 - maxX) * (maxY - minY); r_d = (x2 - x1) * (maxY - minY);
inline QgsPoint QgsClipper::intersect(const std::vector<QgsPoint>& pa, int i1, int i2, boundary b){ // This function assumes that the two given points cross the given // boundary. Making this assumption allows some optimisations. QgsPoint p1 = pa[i1]; QgsPoint p2 = pa[i2]; double r_n, r_d; switch (b) { case Xmax: // x = maxX boundary r_n = -(p1.x() - maxX) * (maxY - minY); r_d = (p2.x() - p1.x()) * (maxY - minY); break; case Xmin: // x = minX boundary r_n = -(p1.x() - minX) * (maxY - minY); r_d = (p2.x() - p1.x()) * (maxY - minY); break; case Ymax: // y = maxY boundary r_n = (p1.y() - maxY) * (maxX - minX); r_d = - (p2.y() - p1.y()) * (maxX - minX); break; case Ymin: // y = minY boundary r_n = (p1.y() - minY) * (maxX - minX); r_d = - (p2.y() - p1.y()) * (maxX - minX); break; } QgsPoint p; if (std::abs(r_d) > SMALL_NUM && std::abs(r_n) > SMALL_NUM) { // they cross double r = r_n / r_d; p.set(p1.x() + r*(p2.x() - p1.x()), p1.y() + r*(p2.y() - p1.y())); } else { // Should never get here, but if we do for some reason, cause a // clunk because something else is wrong if we do. Q_ASSERT(std::abs(r_d) > SMALL_NUM && std::abs(r_n) > SMALL_NUM); } return p;}
r_n = -(p1.x() - minX) * (maxY - minY); r_d = (p2.x() - p1.x()) * (maxY - minY);
r_n = -(x1 - minX) * (maxY - minY); r_d = (x2 - x1) * (maxY - minY);
inline QgsPoint QgsClipper::intersect(const std::vector<QgsPoint>& pa, int i1, int i2, boundary b){ // This function assumes that the two given points cross the given // boundary. Making this assumption allows some optimisations. QgsPoint p1 = pa[i1]; QgsPoint p2 = pa[i2]; double r_n, r_d; switch (b) { case Xmax: // x = maxX boundary r_n = -(p1.x() - maxX) * (maxY - minY); r_d = (p2.x() - p1.x()) * (maxY - minY); break; case Xmin: // x = minX boundary r_n = -(p1.x() - minX) * (maxY - minY); r_d = (p2.x() - p1.x()) * (maxY - minY); break; case Ymax: // y = maxY boundary r_n = (p1.y() - maxY) * (maxX - minX); r_d = - (p2.y() - p1.y()) * (maxX - minX); break; case Ymin: // y = minY boundary r_n = (p1.y() - minY) * (maxX - minX); r_d = - (p2.y() - p1.y()) * (maxX - minX); break; } QgsPoint p; if (std::abs(r_d) > SMALL_NUM && std::abs(r_n) > SMALL_NUM) { // they cross double r = r_n / r_d; p.set(p1.x() + r*(p2.x() - p1.x()), p1.y() + r*(p2.y() - p1.y())); } else { // Should never get here, but if we do for some reason, cause a // clunk because something else is wrong if we do. Q_ASSERT(std::abs(r_d) > SMALL_NUM && std::abs(r_n) > SMALL_NUM); } return p;}
r_n = (p1.y() - maxY) * (maxX - minX); r_d = - (p2.y() - p1.y()) * (maxX - minX);
r_n = (y1 - maxY) * (maxX - minX); r_d = -(y2 - y1) * (maxX - minX);
inline QgsPoint QgsClipper::intersect(const std::vector<QgsPoint>& pa, int i1, int i2, boundary b){ // This function assumes that the two given points cross the given // boundary. Making this assumption allows some optimisations. QgsPoint p1 = pa[i1]; QgsPoint p2 = pa[i2]; double r_n, r_d; switch (b) { case Xmax: // x = maxX boundary r_n = -(p1.x() - maxX) * (maxY - minY); r_d = (p2.x() - p1.x()) * (maxY - minY); break; case Xmin: // x = minX boundary r_n = -(p1.x() - minX) * (maxY - minY); r_d = (p2.x() - p1.x()) * (maxY - minY); break; case Ymax: // y = maxY boundary r_n = (p1.y() - maxY) * (maxX - minX); r_d = - (p2.y() - p1.y()) * (maxX - minX); break; case Ymin: // y = minY boundary r_n = (p1.y() - minY) * (maxX - minX); r_d = - (p2.y() - p1.y()) * (maxX - minX); break; } QgsPoint p; if (std::abs(r_d) > SMALL_NUM && std::abs(r_n) > SMALL_NUM) { // they cross double r = r_n / r_d; p.set(p1.x() + r*(p2.x() - p1.x()), p1.y() + r*(p2.y() - p1.y())); } else { // Should never get here, but if we do for some reason, cause a // clunk because something else is wrong if we do. Q_ASSERT(std::abs(r_d) > SMALL_NUM && std::abs(r_n) > SMALL_NUM); } return p;}
r_n = (p1.y() - minY) * (maxX - minX); r_d = - (p2.y() - p1.y()) * (maxX - minX);
r_n = (y1 - minY) * (maxX - minX); r_d = -(y2 - y1) * (maxX - minX);
inline QgsPoint QgsClipper::intersect(const std::vector<QgsPoint>& pa, int i1, int i2, boundary b){ // This function assumes that the two given points cross the given // boundary. Making this assumption allows some optimisations. QgsPoint p1 = pa[i1]; QgsPoint p2 = pa[i2]; double r_n, r_d; switch (b) { case Xmax: // x = maxX boundary r_n = -(p1.x() - maxX) * (maxY - minY); r_d = (p2.x() - p1.x()) * (maxY - minY); break; case Xmin: // x = minX boundary r_n = -(p1.x() - minX) * (maxY - minY); r_d = (p2.x() - p1.x()) * (maxY - minY); break; case Ymax: // y = maxY boundary r_n = (p1.y() - maxY) * (maxX - minX); r_d = - (p2.y() - p1.y()) * (maxX - minX); break; case Ymin: // y = minY boundary r_n = (p1.y() - minY) * (maxX - minX); r_d = - (p2.y() - p1.y()) * (maxX - minX); break; } QgsPoint p; if (std::abs(r_d) > SMALL_NUM && std::abs(r_n) > SMALL_NUM) { // they cross double r = r_n / r_d; p.set(p1.x() + r*(p2.x() - p1.x()), p1.y() + r*(p2.y() - p1.y())); } else { // Should never get here, but if we do for some reason, cause a // clunk because something else is wrong if we do. Q_ASSERT(std::abs(r_d) > SMALL_NUM && std::abs(r_n) > SMALL_NUM); } return p;}
p.set(p1.x() + r*(p2.x() - p1.x()), p1.y() + r*(p2.y() - p1.y()));
p.set(x1 + r*(x2 - x1), y1 + r*(y2 - y1));
inline QgsPoint QgsClipper::intersect(const std::vector<QgsPoint>& pa, int i1, int i2, boundary b){ // This function assumes that the two given points cross the given // boundary. Making this assumption allows some optimisations. QgsPoint p1 = pa[i1]; QgsPoint p2 = pa[i2]; double r_n, r_d; switch (b) { case Xmax: // x = maxX boundary r_n = -(p1.x() - maxX) * (maxY - minY); r_d = (p2.x() - p1.x()) * (maxY - minY); break; case Xmin: // x = minX boundary r_n = -(p1.x() - minX) * (maxY - minY); r_d = (p2.x() - p1.x()) * (maxY - minY); break; case Ymax: // y = maxY boundary r_n = (p1.y() - maxY) * (maxX - minX); r_d = - (p2.y() - p1.y()) * (maxX - minX); break; case Ymin: // y = minY boundary r_n = (p1.y() - minY) * (maxX - minX); r_d = - (p2.y() - p1.y()) * (maxX - minX); break; } QgsPoint p; if (std::abs(r_d) > SMALL_NUM && std::abs(r_n) > SMALL_NUM) { // they cross double r = r_n / r_d; p.set(p1.x() + r*(p2.x() - p1.x()), p1.y() + r*(p2.y() - p1.y())); } else { // Should never get here, but if we do for some reason, cause a // clunk because something else is wrong if we do. Q_ASSERT(std::abs(r_d) > SMALL_NUM && std::abs(r_n) > SMALL_NUM); } return p;}
HTMLPage += "<dt><A HREF=man:";
HTMLPage += "<dt><A HREF=man:/";
int MakeDirectory( QString &HTMLPage ){ char text[80]; char page[80]; HTMLPage = "<H1>"; HTMLPage += i18n("Online Manuals"); HTMLPage += "</H1>"; HTMLPage += "<dl>"; for (int i = 0; i < numSections; i++) { sprintf(text, i18n("Section %s"), sections[i]->GetName()); sprintf(page, "(%s)", sections[i]->GetName()); HTMLPage += "<dt><A HREF=man:"; HTMLPage += page; HTMLPage += ">"; HTMLPage += QString( text ); HTMLPage += "</A><dd>"; HTMLPage += sections[i]->GetDesc(); } HTMLPage += "</dl>"; return 0;}
QString mp=*it; ++it;
QString mp=*it; ++it;++it;
void HelloProtocol::stat(const KURL& url){ QStringList path = QStringList::split('/', url.encodedPathAndQuery(-1), false); KIO::UDSEntry entry; QString mime; QString mp; switch (path.count()) { case 0: createDirEntry(entry, i18n("My Computer"), "devices:/", "inode/directory"); statEntry(entry); finished(); break; default: QStringList info=deviceInfo(url.fileName()); if (info.empty()) { error(KIO::ERR_SLAVE_DEFINED,i18n("Unknown device")); return; } QStringList::Iterator it=info.begin(); if (it!=info.end()) { QString device=*it; ++it; if (it!=info.end()) { ++it; if (it!=info.end()) { QString mp=*it; ++it; if (it!=info.end()) { bool mounted=((*it)=="true"); if (mounted) { if (mp=="/") mp=""; redirection("file:/"+mp); finished(); } else { error(KIO::ERR_SLAVE_DEFINED,i18n("Device not mounted")); } return; } } } } error(KIO::ERR_SLAVE_DEFINED,i18n("illegal data received")); return; break; }};
QString mp=*it; ++it;
QString mp=*it; ++it;++it;
void HelloProtocol::listDir(const KURL& url){ kdDebug()<<"HELLO PROTOCOLL::listdir: "<<url.url()<<endl; if (url==KURL("devices:/")) listRoot(); else { QStringList info=deviceInfo(url.fileName()); if (info.empty()) { error(KIO::ERR_SLAVE_DEFINED,i18n("Unknown device")); return; } QStringList::Iterator it=info.begin(); if (it!=info.end()) { QString device=*it; ++it; if (it!=info.end()) { ++it; if (it!=info.end()) { QString mp=*it; ++it; if (it!=info.end()) { bool mounted=((*it)=="true"); if (mounted) { if (mp=="/") mp=""; redirection("file:/"+mp); finished(); } else { KProcess *proc = new KProcess; *proc << "kio_devices_mounthelper"; *proc << "-m" << url.url(); proc->start(KProcess::Block); delete proc; if (mp=="/") mp=""; redirection("file:/"+mp); finished(); // error(KIO::ERR_SLAVE_DEFINED,i18n("Device not mounted")); } return; } } } } error(KIO::ERR_SLAVE_DEFINED,i18n("illegal data received")); }}
int kdemain( int argc, char **argv ) {
int KDE_EXPORT kdemain( int argc, char **argv ) {
int kdemain( int argc, char **argv ) { KInstance instance("kio_man"); kdDebug(7107) << "STARTING " << getpid() << endl; if (argc != 4) { fprintf(stderr, "Usage: kio_man protocol domain-socket1 domain-socket2\n"); exit(-1); } MANProtocol slave(argv[2], argv[3]); slave.dispatchLoop(); kdDebug(7107) << "Done" << endl; return 0; }
extern "C" int kdemain( int argc, char **argv )
extern "C" int KDE_EXPORT kdemain( int argc, char **argv )
extern "C" int kdemain( int argc, char **argv ){ KAboutData aboutData( "khelpcenter", I18N_NOOP("KDE Help Center"), HELPCENTER_VERSION, I18N_NOOP("The KDE Help Center"), KAboutData::License_GPL, I18N_NOOP("(c) 1999-2003, The KHelpCenter developers") ); aboutData.addAuthor( "Cornelius Schumacher", 0, "[email protected]" ); aboutData.addAuthor( "Frerich Raabe", 0, "[email protected]" ); aboutData.addAuthor( "Matthias Elter", I18N_NOOP("Original Author"), "[email protected]" ); aboutData.addAuthor( "Wojciech Smigaj", I18N_NOOP("Info page support"), "[email protected]" ); KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineArgs::addCmdLineOptions( options ); KApplication::addCmdLineOptions(); KHC::Application app; if ( app.isRestored() ) { RESTORE( MainWindow ); } return app.exec();}
delete konfig;
int main(int argc, char **argv){ KAboutData aboutData("kwriteconfig", I18N_NOOP("KWriteConfig"), "1.0.0", I18N_NOOP("Write KConfig entries - for use in shell scripts"), KAboutData::License_GPL, "(c) 2001 Red Hat, Inc. & Lus Pedro Coelho"); aboutData.addAuthor("Lus Pedro Coelho", 0, "[email protected]"); aboutData.addAuthor("Bernhard Rosenkraenzer", "Wrote kreadconfig on which this is based", "[email protected]"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(options); KCmdLineArgs *args=KCmdLineArgs::parsedArgs(); QString group=QString::fromLocal8Bit(args->getOption("group")); QString key=QString::fromLocal8Bit(args->getOption("key")); QString file=QString::fromLocal8Bit(args->getOption("file")); QCString type=args->getOption("type").lower(); if (key.isNull() || !args->count()) { KCmdLineArgs::usage(); return 1; } QCString value = args->arg( 0 ); KInstance inst(&aboutData); KConfig *konfig; if (file.isEmpty()) konfig = new KConfig(QString::fromLatin1("kdeglobals"), false, false); else konfig = new KConfig(file, false, false); konfig->setGroup(group); if ( konfig->getConfigState() != KConfig::ReadWrite || konfig->entryIsImmutable( key ) ) return 2; if(type=="bool") { // For symmetry with kreadconfig we accept a wider range of values as true than Qt bool boolvalue=(value=="true" || value=="on" || value=="yes" || value=="1"); konfig->writeEntry( key, boolvalue ); } else { konfig->writeEntry( key, QString::fromLocal8Bit( value ) ); } konfig->sync(); return 0;}
return new Plugin(theQGisAppPointer, theQgisInterfacePointer);
return new QgsNorthArrowPlugin(theQGisAppPointer, theQgisInterfacePointer);
QGISEXTERN QgisPlugin * classFactory(QgisApp * theQGisAppPointer, QgisIface * theQgisInterfacePointer){ return new Plugin(theQGisAppPointer, theQgisInterfacePointer);}
if (debug_flag)
if (debug_flag) { if (lastcheck) log_msg (LOG_DEBUG, _("Pinging all active server.")); else log_msg (LOG_DEBUG, _("Check new for fastest server.")); } for (i = 0; i < max_domains; ++i) { char *domain = domainlist[i].domain; bool_t out = TRUE; enum clnt_stat status = RPC_SUCCESS; if (domainlist[i].active != -1)
test_bindings_once(int lastcheck){ int i; pthread_rdwr_rlock_np (&domainlock); if (debug_flag) { if (lastcheck) log_msg (LOG_DEBUG, _("Pinging all active server.")); else log_msg (LOG_DEBUG, _("Check new for fastest server.")); } for (i = 0; i < max_domains; ++i) { char *domain = domainlist[i].domain; bool_t out = TRUE; enum clnt_stat status = RPC_SUCCESS; if (domainlist[i].active != -1) { /* The binding is in use, check if it is still valid and the fastest one. */ if (lastcheck != 0) { /* Check only if the current binding is still valid. */ struct timeval time_out; time_out.tv_sec = 3; time_out.tv_usec = 0; status = clnt_call(domainlist[i].client_handle, YPPROC_DOMAIN, (xdrproc_t) ypbind_xdr_domainname, (caddr_t) &domain, (xdrproc_t) xdr_bool, (caddr_t) &out, time_out); } /* time to search a new fastest server, but only if the current one was not set with ypset. We search in every case if the above check fails and the current data is not longer valid. */ if ((lastcheck == 0 && domainlist[i].active != -2) || status != RPC_SUCCESS || out != TRUE) { /* The current binding is not valid or it is time to search for a new, fast server. */ if (debug_flag && lastcheck != 0) { /* Current active binding is not longer valid, print the old binding for debugging. */ if (domainlist[i].use_broadcast) log_msg (LOG_DEBUG, _("Server for domain '%s' doesn't answer."), domain); else { if (domainlist[i].active == -2) log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), inet_ntoa(domainlist[i].ypset.addr), domain); else log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), domainlist[i].server[domainlist[i].active].host, domain); } } lastcheck = 0; /* If we need a new server before the TTL expires, reset it. */ /* We have the read lock, but we need the write lock for changes :-( */ pthread_rdwr_runlock_np (&domainlock); pthread_rdwr_wlock_np (&domainlock); /* We can destroy the client_handle since we are the only thread who uses it. */ clnt_destroy (domainlist[i].client_handle); domainlist[i].client_handle = NULL; if (domainlist[i].active == -2) { /* We can give this free, server does not answer any longer. */ domainlist[i].active = -1; if (domainlist[i].ypset.host != NULL) free (domainlist[i].ypset.host); domainlist[i].ypset.host = NULL; } /* And give the write lock away, search a new host and get the read lock again */ pthread_rdwr_wunlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } else { /* there is no binding for this domain, try to find a new server */ pthread_rdwr_runlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } /* end for () all domains */ pthread_rdwr_runlock_np (&domainlock); return lastcheck;}
if (lastcheck) log_msg (LOG_DEBUG, _("Pinging all active server.")); else log_msg (LOG_DEBUG, _("Check new for fastest server.")); }
if (lastcheck != 0) { struct timeval time_out;
test_bindings_once(int lastcheck){ int i; pthread_rdwr_rlock_np (&domainlock); if (debug_flag) { if (lastcheck) log_msg (LOG_DEBUG, _("Pinging all active server.")); else log_msg (LOG_DEBUG, _("Check new for fastest server.")); } for (i = 0; i < max_domains; ++i) { char *domain = domainlist[i].domain; bool_t out = TRUE; enum clnt_stat status = RPC_SUCCESS; if (domainlist[i].active != -1) { /* The binding is in use, check if it is still valid and the fastest one. */ if (lastcheck != 0) { /* Check only if the current binding is still valid. */ struct timeval time_out; time_out.tv_sec = 3; time_out.tv_usec = 0; status = clnt_call(domainlist[i].client_handle, YPPROC_DOMAIN, (xdrproc_t) ypbind_xdr_domainname, (caddr_t) &domain, (xdrproc_t) xdr_bool, (caddr_t) &out, time_out); } /* time to search a new fastest server, but only if the current one was not set with ypset. We search in every case if the above check fails and the current data is not longer valid. */ if ((lastcheck == 0 && domainlist[i].active != -2) || status != RPC_SUCCESS || out != TRUE) { /* The current binding is not valid or it is time to search for a new, fast server. */ if (debug_flag && lastcheck != 0) { /* Current active binding is not longer valid, print the old binding for debugging. */ if (domainlist[i].use_broadcast) log_msg (LOG_DEBUG, _("Server for domain '%s' doesn't answer."), domain); else { if (domainlist[i].active == -2) log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), inet_ntoa(domainlist[i].ypset.addr), domain); else log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), domainlist[i].server[domainlist[i].active].host, domain); } } lastcheck = 0; /* If we need a new server before the TTL expires, reset it. */ /* We have the read lock, but we need the write lock for changes :-( */ pthread_rdwr_runlock_np (&domainlock); pthread_rdwr_wlock_np (&domainlock); /* We can destroy the client_handle since we are the only thread who uses it. */ clnt_destroy (domainlist[i].client_handle); domainlist[i].client_handle = NULL; if (domainlist[i].active == -2) { /* We can give this free, server does not answer any longer. */ domainlist[i].active = -1; if (domainlist[i].ypset.host != NULL) free (domainlist[i].ypset.host); domainlist[i].ypset.host = NULL; } /* And give the write lock away, search a new host and get the read lock again */ pthread_rdwr_wunlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } else { /* there is no binding for this domain, try to find a new server */ pthread_rdwr_runlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } /* end for () all domains */ pthread_rdwr_runlock_np (&domainlock); return lastcheck;}
for (i = 0; i < max_domains; ++i) { char *domain = domainlist[i].domain; bool_t out = TRUE; enum clnt_stat status = RPC_SUCCESS; if (domainlist[i].active != -1)
time_out.tv_sec = 3; time_out.tv_usec = 0; status = clnt_call(domainlist[i].client_handle, YPPROC_DOMAIN, (xdrproc_t) ypbind_xdr_domainname, (caddr_t) &domain, (xdrproc_t) xdr_bool, (caddr_t) &out, time_out); } if ((lastcheck == 0 && domainlist[i].active != -2) || status != RPC_SUCCESS || out != TRUE)
test_bindings_once(int lastcheck){ int i; pthread_rdwr_rlock_np (&domainlock); if (debug_flag) { if (lastcheck) log_msg (LOG_DEBUG, _("Pinging all active server.")); else log_msg (LOG_DEBUG, _("Check new for fastest server.")); } for (i = 0; i < max_domains; ++i) { char *domain = domainlist[i].domain; bool_t out = TRUE; enum clnt_stat status = RPC_SUCCESS; if (domainlist[i].active != -1) { /* The binding is in use, check if it is still valid and the fastest one. */ if (lastcheck != 0) { /* Check only if the current binding is still valid. */ struct timeval time_out; time_out.tv_sec = 3; time_out.tv_usec = 0; status = clnt_call(domainlist[i].client_handle, YPPROC_DOMAIN, (xdrproc_t) ypbind_xdr_domainname, (caddr_t) &domain, (xdrproc_t) xdr_bool, (caddr_t) &out, time_out); } /* time to search a new fastest server, but only if the current one was not set with ypset. We search in every case if the above check fails and the current data is not longer valid. */ if ((lastcheck == 0 && domainlist[i].active != -2) || status != RPC_SUCCESS || out != TRUE) { /* The current binding is not valid or it is time to search for a new, fast server. */ if (debug_flag && lastcheck != 0) { /* Current active binding is not longer valid, print the old binding for debugging. */ if (domainlist[i].use_broadcast) log_msg (LOG_DEBUG, _("Server for domain '%s' doesn't answer."), domain); else { if (domainlist[i].active == -2) log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), inet_ntoa(domainlist[i].ypset.addr), domain); else log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), domainlist[i].server[domainlist[i].active].host, domain); } } lastcheck = 0; /* If we need a new server before the TTL expires, reset it. */ /* We have the read lock, but we need the write lock for changes :-( */ pthread_rdwr_runlock_np (&domainlock); pthread_rdwr_wlock_np (&domainlock); /* We can destroy the client_handle since we are the only thread who uses it. */ clnt_destroy (domainlist[i].client_handle); domainlist[i].client_handle = NULL; if (domainlist[i].active == -2) { /* We can give this free, server does not answer any longer. */ domainlist[i].active = -1; if (domainlist[i].ypset.host != NULL) free (domainlist[i].ypset.host); domainlist[i].ypset.host = NULL; } /* And give the write lock away, search a new host and get the read lock again */ pthread_rdwr_wunlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } else { /* there is no binding for this domain, try to find a new server */ pthread_rdwr_runlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } /* end for () all domains */ pthread_rdwr_runlock_np (&domainlock); return lastcheck;}
if (lastcheck != 0)
if (debug_flag && lastcheck != 0)
test_bindings_once(int lastcheck){ int i; pthread_rdwr_rlock_np (&domainlock); if (debug_flag) { if (lastcheck) log_msg (LOG_DEBUG, _("Pinging all active server.")); else log_msg (LOG_DEBUG, _("Check new for fastest server.")); } for (i = 0; i < max_domains; ++i) { char *domain = domainlist[i].domain; bool_t out = TRUE; enum clnt_stat status = RPC_SUCCESS; if (domainlist[i].active != -1) { /* The binding is in use, check if it is still valid and the fastest one. */ if (lastcheck != 0) { /* Check only if the current binding is still valid. */ struct timeval time_out; time_out.tv_sec = 3; time_out.tv_usec = 0; status = clnt_call(domainlist[i].client_handle, YPPROC_DOMAIN, (xdrproc_t) ypbind_xdr_domainname, (caddr_t) &domain, (xdrproc_t) xdr_bool, (caddr_t) &out, time_out); } /* time to search a new fastest server, but only if the current one was not set with ypset. We search in every case if the above check fails and the current data is not longer valid. */ if ((lastcheck == 0 && domainlist[i].active != -2) || status != RPC_SUCCESS || out != TRUE) { /* The current binding is not valid or it is time to search for a new, fast server. */ if (debug_flag && lastcheck != 0) { /* Current active binding is not longer valid, print the old binding for debugging. */ if (domainlist[i].use_broadcast) log_msg (LOG_DEBUG, _("Server for domain '%s' doesn't answer."), domain); else { if (domainlist[i].active == -2) log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), inet_ntoa(domainlist[i].ypset.addr), domain); else log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), domainlist[i].server[domainlist[i].active].host, domain); } } lastcheck = 0; /* If we need a new server before the TTL expires, reset it. */ /* We have the read lock, but we need the write lock for changes :-( */ pthread_rdwr_runlock_np (&domainlock); pthread_rdwr_wlock_np (&domainlock); /* We can destroy the client_handle since we are the only thread who uses it. */ clnt_destroy (domainlist[i].client_handle); domainlist[i].client_handle = NULL; if (domainlist[i].active == -2) { /* We can give this free, server does not answer any longer. */ domainlist[i].active = -1; if (domainlist[i].ypset.host != NULL) free (domainlist[i].ypset.host); domainlist[i].ypset.host = NULL; } /* And give the write lock away, search a new host and get the read lock again */ pthread_rdwr_wunlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } else { /* there is no binding for this domain, try to find a new server */ pthread_rdwr_runlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } /* end for () all domains */ pthread_rdwr_runlock_np (&domainlock); return lastcheck;}
struct timeval time_out; time_out.tv_sec = 3; time_out.tv_usec = 0; status = clnt_call(domainlist[i].client_handle, YPPROC_DOMAIN, (xdrproc_t) ypbind_xdr_domainname, (caddr_t) &domain, (xdrproc_t) xdr_bool, (caddr_t) &out, time_out); } if ((lastcheck == 0 && domainlist[i].active != -2) || status != RPC_SUCCESS || out != TRUE) { if (debug_flag && lastcheck != 0)
if (domainlist[i].use_broadcast) log_msg (LOG_DEBUG, _("Server for domain '%s' doesn't answer."), domain); else
test_bindings_once(int lastcheck){ int i; pthread_rdwr_rlock_np (&domainlock); if (debug_flag) { if (lastcheck) log_msg (LOG_DEBUG, _("Pinging all active server.")); else log_msg (LOG_DEBUG, _("Check new for fastest server.")); } for (i = 0; i < max_domains; ++i) { char *domain = domainlist[i].domain; bool_t out = TRUE; enum clnt_stat status = RPC_SUCCESS; if (domainlist[i].active != -1) { /* The binding is in use, check if it is still valid and the fastest one. */ if (lastcheck != 0) { /* Check only if the current binding is still valid. */ struct timeval time_out; time_out.tv_sec = 3; time_out.tv_usec = 0; status = clnt_call(domainlist[i].client_handle, YPPROC_DOMAIN, (xdrproc_t) ypbind_xdr_domainname, (caddr_t) &domain, (xdrproc_t) xdr_bool, (caddr_t) &out, time_out); } /* time to search a new fastest server, but only if the current one was not set with ypset. We search in every case if the above check fails and the current data is not longer valid. */ if ((lastcheck == 0 && domainlist[i].active != -2) || status != RPC_SUCCESS || out != TRUE) { /* The current binding is not valid or it is time to search for a new, fast server. */ if (debug_flag && lastcheck != 0) { /* Current active binding is not longer valid, print the old binding for debugging. */ if (domainlist[i].use_broadcast) log_msg (LOG_DEBUG, _("Server for domain '%s' doesn't answer."), domain); else { if (domainlist[i].active == -2) log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), inet_ntoa(domainlist[i].ypset.addr), domain); else log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), domainlist[i].server[domainlist[i].active].host, domain); } } lastcheck = 0; /* If we need a new server before the TTL expires, reset it. */ /* We have the read lock, but we need the write lock for changes :-( */ pthread_rdwr_runlock_np (&domainlock); pthread_rdwr_wlock_np (&domainlock); /* We can destroy the client_handle since we are the only thread who uses it. */ clnt_destroy (domainlist[i].client_handle); domainlist[i].client_handle = NULL; if (domainlist[i].active == -2) { /* We can give this free, server does not answer any longer. */ domainlist[i].active = -1; if (domainlist[i].ypset.host != NULL) free (domainlist[i].ypset.host); domainlist[i].ypset.host = NULL; } /* And give the write lock away, search a new host and get the read lock again */ pthread_rdwr_wunlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } else { /* there is no binding for this domain, try to find a new server */ pthread_rdwr_runlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } /* end for () all domains */ pthread_rdwr_runlock_np (&domainlock); return lastcheck;}
if (domainlist[i].use_broadcast)
if (domainlist[i].active == -2)
test_bindings_once(int lastcheck){ int i; pthread_rdwr_rlock_np (&domainlock); if (debug_flag) { if (lastcheck) log_msg (LOG_DEBUG, _("Pinging all active server.")); else log_msg (LOG_DEBUG, _("Check new for fastest server.")); } for (i = 0; i < max_domains; ++i) { char *domain = domainlist[i].domain; bool_t out = TRUE; enum clnt_stat status = RPC_SUCCESS; if (domainlist[i].active != -1) { /* The binding is in use, check if it is still valid and the fastest one. */ if (lastcheck != 0) { /* Check only if the current binding is still valid. */ struct timeval time_out; time_out.tv_sec = 3; time_out.tv_usec = 0; status = clnt_call(domainlist[i].client_handle, YPPROC_DOMAIN, (xdrproc_t) ypbind_xdr_domainname, (caddr_t) &domain, (xdrproc_t) xdr_bool, (caddr_t) &out, time_out); } /* time to search a new fastest server, but only if the current one was not set with ypset. We search in every case if the above check fails and the current data is not longer valid. */ if ((lastcheck == 0 && domainlist[i].active != -2) || status != RPC_SUCCESS || out != TRUE) { /* The current binding is not valid or it is time to search for a new, fast server. */ if (debug_flag && lastcheck != 0) { /* Current active binding is not longer valid, print the old binding for debugging. */ if (domainlist[i].use_broadcast) log_msg (LOG_DEBUG, _("Server for domain '%s' doesn't answer."), domain); else { if (domainlist[i].active == -2) log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), inet_ntoa(domainlist[i].ypset.addr), domain); else log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), domainlist[i].server[domainlist[i].active].host, domain); } } lastcheck = 0; /* If we need a new server before the TTL expires, reset it. */ /* We have the read lock, but we need the write lock for changes :-( */ pthread_rdwr_runlock_np (&domainlock); pthread_rdwr_wlock_np (&domainlock); /* We can destroy the client_handle since we are the only thread who uses it. */ clnt_destroy (domainlist[i].client_handle); domainlist[i].client_handle = NULL; if (domainlist[i].active == -2) { /* We can give this free, server does not answer any longer. */ domainlist[i].active = -1; if (domainlist[i].ypset.host != NULL) free (domainlist[i].ypset.host); domainlist[i].ypset.host = NULL; } /* And give the write lock away, search a new host and get the read lock again */ pthread_rdwr_wunlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } else { /* there is no binding for this domain, try to find a new server */ pthread_rdwr_runlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } /* end for () all domains */ pthread_rdwr_runlock_np (&domainlock); return lastcheck;}
_("Server for domain '%s' doesn't answer."),
_("Server '%s' for domain '%s' doesn't answer."), inet_ntoa(domainlist[i].ypset.addr),
test_bindings_once(int lastcheck){ int i; pthread_rdwr_rlock_np (&domainlock); if (debug_flag) { if (lastcheck) log_msg (LOG_DEBUG, _("Pinging all active server.")); else log_msg (LOG_DEBUG, _("Check new for fastest server.")); } for (i = 0; i < max_domains; ++i) { char *domain = domainlist[i].domain; bool_t out = TRUE; enum clnt_stat status = RPC_SUCCESS; if (domainlist[i].active != -1) { /* The binding is in use, check if it is still valid and the fastest one. */ if (lastcheck != 0) { /* Check only if the current binding is still valid. */ struct timeval time_out; time_out.tv_sec = 3; time_out.tv_usec = 0; status = clnt_call(domainlist[i].client_handle, YPPROC_DOMAIN, (xdrproc_t) ypbind_xdr_domainname, (caddr_t) &domain, (xdrproc_t) xdr_bool, (caddr_t) &out, time_out); } /* time to search a new fastest server, but only if the current one was not set with ypset. We search in every case if the above check fails and the current data is not longer valid. */ if ((lastcheck == 0 && domainlist[i].active != -2) || status != RPC_SUCCESS || out != TRUE) { /* The current binding is not valid or it is time to search for a new, fast server. */ if (debug_flag && lastcheck != 0) { /* Current active binding is not longer valid, print the old binding for debugging. */ if (domainlist[i].use_broadcast) log_msg (LOG_DEBUG, _("Server for domain '%s' doesn't answer."), domain); else { if (domainlist[i].active == -2) log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), inet_ntoa(domainlist[i].ypset.addr), domain); else log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), domainlist[i].server[domainlist[i].active].host, domain); } } lastcheck = 0; /* If we need a new server before the TTL expires, reset it. */ /* We have the read lock, but we need the write lock for changes :-( */ pthread_rdwr_runlock_np (&domainlock); pthread_rdwr_wlock_np (&domainlock); /* We can destroy the client_handle since we are the only thread who uses it. */ clnt_destroy (domainlist[i].client_handle); domainlist[i].client_handle = NULL; if (domainlist[i].active == -2) { /* We can give this free, server does not answer any longer. */ domainlist[i].active = -1; if (domainlist[i].ypset.host != NULL) free (domainlist[i].ypset.host); domainlist[i].ypset.host = NULL; } /* And give the write lock away, search a new host and get the read lock again */ pthread_rdwr_wunlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } else { /* there is no binding for this domain, try to find a new server */ pthread_rdwr_runlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } /* end for () all domains */ pthread_rdwr_runlock_np (&domainlock); return lastcheck;}
{ if (domainlist[i].active == -2) log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), inet_ntoa(domainlist[i].ypset.addr), domain); else log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), domainlist[i].server[domainlist[i].active].host, domain); }
log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), domainlist[i].server[domainlist[i].active].host, domain);
test_bindings_once(int lastcheck){ int i; pthread_rdwr_rlock_np (&domainlock); if (debug_flag) { if (lastcheck) log_msg (LOG_DEBUG, _("Pinging all active server.")); else log_msg (LOG_DEBUG, _("Check new for fastest server.")); } for (i = 0; i < max_domains; ++i) { char *domain = domainlist[i].domain; bool_t out = TRUE; enum clnt_stat status = RPC_SUCCESS; if (domainlist[i].active != -1) { /* The binding is in use, check if it is still valid and the fastest one. */ if (lastcheck != 0) { /* Check only if the current binding is still valid. */ struct timeval time_out; time_out.tv_sec = 3; time_out.tv_usec = 0; status = clnt_call(domainlist[i].client_handle, YPPROC_DOMAIN, (xdrproc_t) ypbind_xdr_domainname, (caddr_t) &domain, (xdrproc_t) xdr_bool, (caddr_t) &out, time_out); } /* time to search a new fastest server, but only if the current one was not set with ypset. We search in every case if the above check fails and the current data is not longer valid. */ if ((lastcheck == 0 && domainlist[i].active != -2) || status != RPC_SUCCESS || out != TRUE) { /* The current binding is not valid or it is time to search for a new, fast server. */ if (debug_flag && lastcheck != 0) { /* Current active binding is not longer valid, print the old binding for debugging. */ if (domainlist[i].use_broadcast) log_msg (LOG_DEBUG, _("Server for domain '%s' doesn't answer."), domain); else { if (domainlist[i].active == -2) log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), inet_ntoa(domainlist[i].ypset.addr), domain); else log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), domainlist[i].server[domainlist[i].active].host, domain); } } lastcheck = 0; /* If we need a new server before the TTL expires, reset it. */ /* We have the read lock, but we need the write lock for changes :-( */ pthread_rdwr_runlock_np (&domainlock); pthread_rdwr_wlock_np (&domainlock); /* We can destroy the client_handle since we are the only thread who uses it. */ clnt_destroy (domainlist[i].client_handle); domainlist[i].client_handle = NULL; if (domainlist[i].active == -2) { /* We can give this free, server does not answer any longer. */ domainlist[i].active = -1; if (domainlist[i].ypset.host != NULL) free (domainlist[i].ypset.host); domainlist[i].ypset.host = NULL; } /* And give the write lock away, search a new host and get the read lock again */ pthread_rdwr_wunlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } else { /* there is no binding for this domain, try to find a new server */ pthread_rdwr_runlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } /* end for () all domains */ pthread_rdwr_runlock_np (&domainlock); return lastcheck;}
lastcheck = 0;
} lastcheck = 0;
test_bindings_once(int lastcheck){ int i; pthread_rdwr_rlock_np (&domainlock); if (debug_flag) { if (lastcheck) log_msg (LOG_DEBUG, _("Pinging all active server.")); else log_msg (LOG_DEBUG, _("Check new for fastest server.")); } for (i = 0; i < max_domains; ++i) { char *domain = domainlist[i].domain; bool_t out = TRUE; enum clnt_stat status = RPC_SUCCESS; if (domainlist[i].active != -1) { /* The binding is in use, check if it is still valid and the fastest one. */ if (lastcheck != 0) { /* Check only if the current binding is still valid. */ struct timeval time_out; time_out.tv_sec = 3; time_out.tv_usec = 0; status = clnt_call(domainlist[i].client_handle, YPPROC_DOMAIN, (xdrproc_t) ypbind_xdr_domainname, (caddr_t) &domain, (xdrproc_t) xdr_bool, (caddr_t) &out, time_out); } /* time to search a new fastest server, but only if the current one was not set with ypset. We search in every case if the above check fails and the current data is not longer valid. */ if ((lastcheck == 0 && domainlist[i].active != -2) || status != RPC_SUCCESS || out != TRUE) { /* The current binding is not valid or it is time to search for a new, fast server. */ if (debug_flag && lastcheck != 0) { /* Current active binding is not longer valid, print the old binding for debugging. */ if (domainlist[i].use_broadcast) log_msg (LOG_DEBUG, _("Server for domain '%s' doesn't answer."), domain); else { if (domainlist[i].active == -2) log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), inet_ntoa(domainlist[i].ypset.addr), domain); else log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), domainlist[i].server[domainlist[i].active].host, domain); } } lastcheck = 0; /* If we need a new server before the TTL expires, reset it. */ /* We have the read lock, but we need the write lock for changes :-( */ pthread_rdwr_runlock_np (&domainlock); pthread_rdwr_wlock_np (&domainlock); /* We can destroy the client_handle since we are the only thread who uses it. */ clnt_destroy (domainlist[i].client_handle); domainlist[i].client_handle = NULL; if (domainlist[i].active == -2) { /* We can give this free, server does not answer any longer. */ domainlist[i].active = -1; if (domainlist[i].ypset.host != NULL) free (domainlist[i].ypset.host); domainlist[i].ypset.host = NULL; } /* And give the write lock away, search a new host and get the read lock again */ pthread_rdwr_wunlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } else { /* there is no binding for this domain, try to find a new server */ pthread_rdwr_runlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } /* end for () all domains */ pthread_rdwr_runlock_np (&domainlock); return lastcheck;}
pthread_rdwr_runlock_np (&domainlock); pthread_rdwr_wlock_np (&domainlock); clnt_destroy (domainlist[i].client_handle); domainlist[i].client_handle = NULL; if (domainlist[i].active == -2) { domainlist[i].active = -1; if (domainlist[i].ypset.host != NULL) free (domainlist[i].ypset.host); domainlist[i].ypset.host = NULL; } pthread_rdwr_wunlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock);
pthread_rdwr_runlock_np (&domainlock); pthread_rdwr_wlock_np (&domainlock); clnt_destroy (domainlist[i].client_handle); domainlist[i].client_handle = NULL; if (domainlist[i].active == -2) { domainlist[i].active = -1; if (domainlist[i].ypset.host != NULL) free (domainlist[i].ypset.host); domainlist[i].ypset.host = NULL;
test_bindings_once(int lastcheck){ int i; pthread_rdwr_rlock_np (&domainlock); if (debug_flag) { if (lastcheck) log_msg (LOG_DEBUG, _("Pinging all active server.")); else log_msg (LOG_DEBUG, _("Check new for fastest server.")); } for (i = 0; i < max_domains; ++i) { char *domain = domainlist[i].domain; bool_t out = TRUE; enum clnt_stat status = RPC_SUCCESS; if (domainlist[i].active != -1) { /* The binding is in use, check if it is still valid and the fastest one. */ if (lastcheck != 0) { /* Check only if the current binding is still valid. */ struct timeval time_out; time_out.tv_sec = 3; time_out.tv_usec = 0; status = clnt_call(domainlist[i].client_handle, YPPROC_DOMAIN, (xdrproc_t) ypbind_xdr_domainname, (caddr_t) &domain, (xdrproc_t) xdr_bool, (caddr_t) &out, time_out); } /* time to search a new fastest server, but only if the current one was not set with ypset. We search in every case if the above check fails and the current data is not longer valid. */ if ((lastcheck == 0 && domainlist[i].active != -2) || status != RPC_SUCCESS || out != TRUE) { /* The current binding is not valid or it is time to search for a new, fast server. */ if (debug_flag && lastcheck != 0) { /* Current active binding is not longer valid, print the old binding for debugging. */ if (domainlist[i].use_broadcast) log_msg (LOG_DEBUG, _("Server for domain '%s' doesn't answer."), domain); else { if (domainlist[i].active == -2) log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), inet_ntoa(domainlist[i].ypset.addr), domain); else log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), domainlist[i].server[domainlist[i].active].host, domain); } } lastcheck = 0; /* If we need a new server before the TTL expires, reset it. */ /* We have the read lock, but we need the write lock for changes :-( */ pthread_rdwr_runlock_np (&domainlock); pthread_rdwr_wlock_np (&domainlock); /* We can destroy the client_handle since we are the only thread who uses it. */ clnt_destroy (domainlist[i].client_handle); domainlist[i].client_handle = NULL; if (domainlist[i].active == -2) { /* We can give this free, server does not answer any longer. */ domainlist[i].active = -1; if (domainlist[i].ypset.host != NULL) free (domainlist[i].ypset.host); domainlist[i].ypset.host = NULL; } /* And give the write lock away, search a new host and get the read lock again */ pthread_rdwr_wunlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } else { /* there is no binding for this domain, try to find a new server */ pthread_rdwr_runlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } /* end for () all domains */ pthread_rdwr_runlock_np (&domainlock); return lastcheck;}
} else { pthread_rdwr_runlock_np (&domainlock);
pthread_rdwr_wunlock_np (&domainlock);
test_bindings_once(int lastcheck){ int i; pthread_rdwr_rlock_np (&domainlock); if (debug_flag) { if (lastcheck) log_msg (LOG_DEBUG, _("Pinging all active server.")); else log_msg (LOG_DEBUG, _("Check new for fastest server.")); } for (i = 0; i < max_domains; ++i) { char *domain = domainlist[i].domain; bool_t out = TRUE; enum clnt_stat status = RPC_SUCCESS; if (domainlist[i].active != -1) { /* The binding is in use, check if it is still valid and the fastest one. */ if (lastcheck != 0) { /* Check only if the current binding is still valid. */ struct timeval time_out; time_out.tv_sec = 3; time_out.tv_usec = 0; status = clnt_call(domainlist[i].client_handle, YPPROC_DOMAIN, (xdrproc_t) ypbind_xdr_domainname, (caddr_t) &domain, (xdrproc_t) xdr_bool, (caddr_t) &out, time_out); } /* time to search a new fastest server, but only if the current one was not set with ypset. We search in every case if the above check fails and the current data is not longer valid. */ if ((lastcheck == 0 && domainlist[i].active != -2) || status != RPC_SUCCESS || out != TRUE) { /* The current binding is not valid or it is time to search for a new, fast server. */ if (debug_flag && lastcheck != 0) { /* Current active binding is not longer valid, print the old binding for debugging. */ if (domainlist[i].use_broadcast) log_msg (LOG_DEBUG, _("Server for domain '%s' doesn't answer."), domain); else { if (domainlist[i].active == -2) log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), inet_ntoa(domainlist[i].ypset.addr), domain); else log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), domainlist[i].server[domainlist[i].active].host, domain); } } lastcheck = 0; /* If we need a new server before the TTL expires, reset it. */ /* We have the read lock, but we need the write lock for changes :-( */ pthread_rdwr_runlock_np (&domainlock); pthread_rdwr_wlock_np (&domainlock); /* We can destroy the client_handle since we are the only thread who uses it. */ clnt_destroy (domainlist[i].client_handle); domainlist[i].client_handle = NULL; if (domainlist[i].active == -2) { /* We can give this free, server does not answer any longer. */ domainlist[i].active = -1; if (domainlist[i].ypset.host != NULL) free (domainlist[i].ypset.host); domainlist[i].ypset.host = NULL; } /* And give the write lock away, search a new host and get the read lock again */ pthread_rdwr_wunlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } else { /* there is no binding for this domain, try to find a new server */ pthread_rdwr_runlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } /* end for () all domains */ pthread_rdwr_runlock_np (&domainlock); return lastcheck;}
}
} else { pthread_rdwr_runlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } }
test_bindings_once(int lastcheck){ int i; pthread_rdwr_rlock_np (&domainlock); if (debug_flag) { if (lastcheck) log_msg (LOG_DEBUG, _("Pinging all active server.")); else log_msg (LOG_DEBUG, _("Check new for fastest server.")); } for (i = 0; i < max_domains; ++i) { char *domain = domainlist[i].domain; bool_t out = TRUE; enum clnt_stat status = RPC_SUCCESS; if (domainlist[i].active != -1) { /* The binding is in use, check if it is still valid and the fastest one. */ if (lastcheck != 0) { /* Check only if the current binding is still valid. */ struct timeval time_out; time_out.tv_sec = 3; time_out.tv_usec = 0; status = clnt_call(domainlist[i].client_handle, YPPROC_DOMAIN, (xdrproc_t) ypbind_xdr_domainname, (caddr_t) &domain, (xdrproc_t) xdr_bool, (caddr_t) &out, time_out); } /* time to search a new fastest server, but only if the current one was not set with ypset. We search in every case if the above check fails and the current data is not longer valid. */ if ((lastcheck == 0 && domainlist[i].active != -2) || status != RPC_SUCCESS || out != TRUE) { /* The current binding is not valid or it is time to search for a new, fast server. */ if (debug_flag && lastcheck != 0) { /* Current active binding is not longer valid, print the old binding for debugging. */ if (domainlist[i].use_broadcast) log_msg (LOG_DEBUG, _("Server for domain '%s' doesn't answer."), domain); else { if (domainlist[i].active == -2) log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), inet_ntoa(domainlist[i].ypset.addr), domain); else log_msg (LOG_DEBUG, _("Server '%s' for domain '%s' doesn't answer."), domainlist[i].server[domainlist[i].active].host, domain); } } lastcheck = 0; /* If we need a new server before the TTL expires, reset it. */ /* We have the read lock, but we need the write lock for changes :-( */ pthread_rdwr_runlock_np (&domainlock); pthread_rdwr_wlock_np (&domainlock); /* We can destroy the client_handle since we are the only thread who uses it. */ clnt_destroy (domainlist[i].client_handle); domainlist[i].client_handle = NULL; if (domainlist[i].active == -2) { /* We can give this free, server does not answer any longer. */ domainlist[i].active = -1; if (domainlist[i].ypset.host != NULL) free (domainlist[i].ypset.host); domainlist[i].ypset.host = NULL; } /* And give the write lock away, search a new host and get the read lock again */ pthread_rdwr_wunlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } else { /* there is no binding for this domain, try to find a new server */ pthread_rdwr_runlock_np (&domainlock); pthread_mutex_lock (&search_lock); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); pthread_rdwr_rlock_np (&domainlock); } } /* end for () all domains */ pthread_rdwr_runlock_np (&domainlock); return lastcheck;}
KApplication app( false, false );
KApplication app( false );
int KDE_EXPORT kdemain( int argc, char **argv ) { //KInstance instance( "kio_trash" ); // KApplication is necessary to use kio_file putenv(strdup("SESSION_MANAGER=")); KApplication::disableAutoDcopRegistration(); KCmdLineArgs::init(argc, argv, "kio_trash", 0, 0, 0); KCmdLineArgs::addCmdLineOptions( options ); KApplication app( false, false ); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); TrashProtocol slave( args->arg(0), args->arg(1), args->arg(2) ); slave.dispatchLoop(); return 0; }
int kdemain( int argc, char **argv )
int KDE_EXPORT kdemain( int argc, char **argv )
int kdemain( int argc, char **argv ){ KLocale::setMainCatalogue("kio_fish"); KInstance instance("fish"); myDebug( << "*** Starting fish " << endl); if (argc != 4) { myDebug( << "Usage: fish protocol domain-socket1 domain-socket2" << endl); exit(-1); } struct sigaction act; memset(&act,0,sizeof(act)); act.sa_handler = ripper; act.sa_flags = 0#ifdef SA_NOCLDSTOP | SA_NOCLDSTOP#endif#ifdef SA_RESTART | SA_RESTART#endif ; sigaction(SIGCHLD,&act,NULL); fishProtocol slave(argv[2], argv[3]); slave.dispatchLoop(); myDebug( << "*** fish Done" << endl); return 0;}
cinode_pins[by]++;
void get(int by) { if (ref == 0) lru_pin(); if (ref_set.count(by)) { dout(7) << " bad get " << *this << " by " << by << " " << cinode_pin_names[by] << " was " << ref << " (" << ref_set << ")" << endl; assert(ref_set.count(by) == 0); } ref++; ref_set.insert(by); dout(7) << " get " << *this << " by " << by << " " << cinode_pin_names[by] << " now " << ref << " (" << ref_set << ")" << endl; }
CInodeExport() {}
CInodeExport(CInode *in) { st.inode = in->inode; st.version = in->get_version(); st.is_dirty = in->is_dirty(); cached_by = in->cached_by; cached_by_nonce = in->cached_by_nonce; hardlock = in->hardlock; softlock = in->softlock; st.popularity_justme.take( in->popularity[MDS_POP_JUSTME] ); st.popularity_curdom.take( in->popularity[MDS_POP_CURDOM] ); in->popularity[MDS_POP_ANYDOM].adjust_down(st.popularity_curdom); for (map<fileh_t, CFile*>::iterator it = in->fh_map.begin(); it != in->fh_map.end(); it++) { fh_list.push_back(it->second); } for (list<CFile*>::iterator it = fh_list.begin(); it != fh_list.end(); it++) in->remove_fh(*it); }
CInodeExport() {}
if ( myInputSpatialRefSys.importFromWkt( &theSourceWKT ) != OGRERR_NONE || myOutputSpatialRefSys.importFromWkt( &theDestWKT ) != OGRERR_NONE )
const char * mySourceCharArray = theSourceWKT.ascii(); char *mySourceCharArrayPointer = (char *)mySourceCharArray; const char * myDestCharArray = theDestWKT.ascii(); char *myDestCharArrayPointer = (char *)myDestCharArray; if ( myInputSpatialRefSys.importFromWkt( & mySourceCharArrayPointer ) != OGRERR_NONE || myOutputSpatialRefSys.importFromWkt( & myDestCharArrayPointer ) != OGRERR_NONE )
inline QgsCoordinateTransform::QgsCoordinateTransform( QString theSourceWKT, QString theDestWKT ){ OGRSpatialReference myInputSpatialRefSys, myOutputSpatialRefSys; if ( myInputSpatialRefSys.importFromWkt( &theSourceWKT ) != OGRERR_NONE || myOutputSpatialRefSys.importFromWkt( &theDestWKT ) != OGRERR_NONE ) { printf( 1, "QgsCoordinateTransform - invalid projection:\n myInputSpatialRefSys: (%s)\n myOutputSpatialRefSys: (%s)\n", theSourceWKT, theDestWKT ); } gSourceToDestXForm = OGRCreateCoordinateTransformation( &myInputSpatialRefSys, &myOutputSpatialRefSys ); if ( ! gSourceToDestXForm ) { printf( 1, "QgsCoordinateTransform - invalid projection:\n myInputSpatialRefSys: (%s)\n myOutputSpatialRefSys: (%s)\n", theSourceWKT, theDestWKT ); } // Deactivate GDAL error messages. //CPLSetErrorHandler( errorHandler ); // Guess if the source o dest CS is in degrees. //Searchf for this phrase in each wkt: "unit[\"degree\"" }
printf( 1, "QgsCoordinateTransform - invalid projection:\n myInputSpatialRefSys: (%s)\n myOutputSpatialRefSys: (%s)\n", theSourceWKT, theDestWKT );
printf( "QgsCoordinateTransform - invalid projection:\n myInputSpatialRefSys: (%s)\n myOutputSpatialRefSys: (%s)\n", theSourceWKT.ascii(), theDestWKT.ascii() );
inline QgsCoordinateTransform::QgsCoordinateTransform( QString theSourceWKT, QString theDestWKT ){ OGRSpatialReference myInputSpatialRefSys, myOutputSpatialRefSys; if ( myInputSpatialRefSys.importFromWkt( &theSourceWKT ) != OGRERR_NONE || myOutputSpatialRefSys.importFromWkt( &theDestWKT ) != OGRERR_NONE ) { printf( 1, "QgsCoordinateTransform - invalid projection:\n myInputSpatialRefSys: (%s)\n myOutputSpatialRefSys: (%s)\n", theSourceWKT, theDestWKT ); } gSourceToDestXForm = OGRCreateCoordinateTransformation( &myInputSpatialRefSys, &myOutputSpatialRefSys ); if ( ! gSourceToDestXForm ) { printf( 1, "QgsCoordinateTransform - invalid projection:\n myInputSpatialRefSys: (%s)\n myOutputSpatialRefSys: (%s)\n", theSourceWKT, theDestWKT ); } // Deactivate GDAL error messages. //CPLSetErrorHandler( errorHandler ); // Guess if the source o dest CS is in degrees. //Searchf for this phrase in each wkt: "unit[\"degree\"" }
gSourceToDestXForm = OGRCreateCoordinateTransformation( &myInputSpatialRefSys, &myOutputSpatialRefSys );
mSourceToDestXForm = OGRCreateCoordinateTransformation( &myInputSpatialRefSys, &myOutputSpatialRefSys );
inline QgsCoordinateTransform::QgsCoordinateTransform( QString theSourceWKT, QString theDestWKT ){ OGRSpatialReference myInputSpatialRefSys, myOutputSpatialRefSys; if ( myInputSpatialRefSys.importFromWkt( &theSourceWKT ) != OGRERR_NONE || myOutputSpatialRefSys.importFromWkt( &theDestWKT ) != OGRERR_NONE ) { printf( 1, "QgsCoordinateTransform - invalid projection:\n myInputSpatialRefSys: (%s)\n myOutputSpatialRefSys: (%s)\n", theSourceWKT, theDestWKT ); } gSourceToDestXForm = OGRCreateCoordinateTransformation( &myInputSpatialRefSys, &myOutputSpatialRefSys ); if ( ! gSourceToDestXForm ) { printf( 1, "QgsCoordinateTransform - invalid projection:\n myInputSpatialRefSys: (%s)\n myOutputSpatialRefSys: (%s)\n", theSourceWKT, theDestWKT ); } // Deactivate GDAL error messages. //CPLSetErrorHandler( errorHandler ); // Guess if the source o dest CS is in degrees. //Searchf for this phrase in each wkt: "unit[\"degree\"" }
if ( ! gSourceToDestXForm )
if ( ! mSourceToDestXForm )
inline QgsCoordinateTransform::QgsCoordinateTransform( QString theSourceWKT, QString theDestWKT ){ OGRSpatialReference myInputSpatialRefSys, myOutputSpatialRefSys; if ( myInputSpatialRefSys.importFromWkt( &theSourceWKT ) != OGRERR_NONE || myOutputSpatialRefSys.importFromWkt( &theDestWKT ) != OGRERR_NONE ) { printf( 1, "QgsCoordinateTransform - invalid projection:\n myInputSpatialRefSys: (%s)\n myOutputSpatialRefSys: (%s)\n", theSourceWKT, theDestWKT ); } gSourceToDestXForm = OGRCreateCoordinateTransformation( &myInputSpatialRefSys, &myOutputSpatialRefSys ); if ( ! gSourceToDestXForm ) { printf( 1, "QgsCoordinateTransform - invalid projection:\n myInputSpatialRefSys: (%s)\n myOutputSpatialRefSys: (%s)\n", theSourceWKT, theDestWKT ); } // Deactivate GDAL error messages. //CPLSetErrorHandler( errorHandler ); // Guess if the source o dest CS is in degrees. //Searchf for this phrase in each wkt: "unit[\"degree\"" }
extern "C" int kdemain(int _argc, char *_argv[])
extern "C" KDE_EXPORT int kdemain(int _argc, char *_argv[])
extern "C" int kdemain(int _argc, char *_argv[]){ KAboutData aboutData( "kcmshell", I18N_NOOP("KDE Control Module"), KCONTROL_VERSION, I18N_NOOP("A tool to start single KDE control modules"), KAboutData::License_GPL, "(c) 1999-2004, The KDE Developers"); aboutData.addAuthor("Daniel Molkentin", I18N_NOOP("Current Maintainer"), "[email protected]"); aboutData.addAuthor("Matthias Hoelzer-Kluepfel",0, "[email protected]"); aboutData.addAuthor("Matthias Elter",0, "[email protected]"); aboutData.addAuthor("Matthias Ettrich",0, "[email protected]"); aboutData.addAuthor("Waldo Bastian",0, "[email protected]"); KCmdLineArgs::init(_argc, _argv, &aboutData); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KLocale::setMainCatalogue("kcontrol"); kcmApplication app; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); KGlobal::iconLoader()->addAppDir( "kcontrol" ); QCString lang = args->getOption("lang"); if (! lang.isNull()) { KGlobal::locale()->setLanguage(lang); } if (args->isSet("list")) { cout << i18n("The following modules are available:").local8Bit() << endl; ConfigModuleList modules; modules.readDesktopEntries(); ConfigModule *module = 0; int maxLen=0; for (module=modules.first(); module != 0; module=modules.next()) { int len = stripPath(module->fileName()).length(); if (len > maxLen) maxLen = len; } for (module=modules.first(); module != 0; module=modules.next()) { QString entry("%1 - %2"); entry = entry.arg(stripPath(module->fileName()).leftJustify(maxLen, ' ')); entry = entry.arg(!module->comment().isEmpty() ? module->comment() : i18n("No description available")); cout << entry.local8Bit() << endl; } return 0; } if (args->count() < 1) { args->usage(); return -1; } if (args->count() == 1) { app.setDCOPName(args->arg(0)); if (app.isRunning()) { app.waitForExit(); return 0; } KService::Ptr service = locateModule(args->arg(0)); if (!service) return 1; // error // load the module KCModuleInfo info(service); KCModule *module = KCModuleLoader::loadModule(info, false); if (module) { // create the dialog QCString embedStr = args->getOption("embed"); bool embed = false; int id = -1; if (!embedStr.isEmpty()) id = embedStr.toInt(&embed); if (!args->isSet("silent")) { if (!embed) { KCDialog * dlg = new KCDialog(module, module->buttons(), info.docPath(), 0, 0, true ); QString caption = (kapp->caption() != i18n("KDE Control Module")) ? kapp->caption() : info.moduleName(); if (kapp->iconName() != kapp->name()) setIcon(dlg, kapp->iconName()); else setIcon(dlg, info.icon()); dlg->setPlainCaption(i18n("Configure - %1").arg(caption)); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg->setAcceptDrops(true); // run the dialog dlg->exec(); delete dlg; } // if we are going to be embedded, embed else { QWidget *dlg = new ProxyWidget(module, info.moduleName(), "kcmshell", false); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg->setAcceptDrops(true); QXEmbed::embedClientIntoWindow(dlg, id); kapp->exec(); delete dlg; } } else { //Silent kapp->exec(); } KCModuleLoader::unloadModule(info); return 0; } KCModuleLoader::showLastLoaderError(0L); return 0; } QCString dcopName; // multiple control modules KService::List modules; for (int i = 0; i < args->count(); i++) { KService::Ptr service = locateModule(args->arg(i)); if (service) { if (!dcopName.isEmpty()) dcopName += "_"; dcopName += args->arg(i); modules.append(service); continue; } } if (modules.count() < 1) return -1; app.setDCOPName(dcopName); if (app.isRunning()) { app.waitForExit(); return 0; } // create the dialog KCMultiDialog * dlg = new KCMShellMultiDialog(0, 0, true); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg->setAcceptDrops(true); // add modules for (KService::List::ConstIterator it = modules.begin(); it != modules.end(); ++it) dlg->addModule(KCModuleInfo(*it)); // if we are going to be embedded, embed QCString embed = args->getOption("embed"); if (!embed.isEmpty()) { bool ok; int id = embed.toInt(&ok); if (ok) { // NOTE: This has to be changed for QT 3.0. See above! QXEmbed::embedClientIntoWindow(dlg, id); delete dlg; return 0; } } if (kapp->iconName() != kapp->name()) setIcon(dlg, kapp->iconName()); dlg->setPlainCaption(i18n("Configure - %1").arg(kapp->caption())); // run the dialog dlg->exec(); delete dlg; return 0;}
if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
JNIEXPORT jint JNICALL OS_NATIVE(FindWindowW) (JNIEnv *env, jclass that, jcharArray arg0, jcharArray arg1){ jchar *lparg0=NULL; jchar *lparg1=NULL; jint rc; NATIVE_ENTER(env, that, "FindWindowW\n") if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL); if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL); rc = (jint)FindWindowW((LPWSTR)lparg0, (LPWSTR)lparg1); if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0); if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0); NATIVE_EXIT(env, that, "FindWindowW\n") return rc;}
DEBUG_CHECK_NULL(env, arg0)
JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__ILorg_eclipse_swt_internal_win32_NMLVCUSTOMDRAW_2I (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2){ DECL_GLOB(pGlob) NMLVCUSTOMDRAW _arg1, *lparg1=NULL; DEBUG_CALL("MoveMemory\n") if (arg1) lparg1 = getNMLVCUSTOMDRAWFields(env, arg1, &_arg1, &PGLOB(NMLVCUSTOMDRAWFc)); MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2); if (arg1) setNMLVCUSTOMDRAWFields(env, arg1, lparg1, &PGLOB(NMLVCUSTOMDRAWFc));}
s.append((char*)&fh,sizeof(fh));
s.append((char*)&ino,sizeof(ino));
virtual void encode_payload(crope& s) { s.append((char*)&fh,sizeof(fh)); s.append((char*)&newauth,sizeof(newauth)); }
MClientInodeAuthUpdate(fileh_t fh, int newauth) :
MClientInodeAuthUpdate(inodeno_t ino, int newauth) :
MClientInodeAuthUpdate(fileh_t fh, int newauth) : Message(MSG_CLIENT_INODEAUTHUPDATE) { this->fh = fh; this->newauth = newauth; }
this->fh = fh;
this->ino = ino;
MClientInodeAuthUpdate(fileh_t fh, int newauth) : Message(MSG_CLIENT_INODEAUTHUPDATE) { this->fh = fh; this->newauth = newauth; }
s.copy(off, sizeof(fh), (char*)&fh); off += sizeof(fh);
s.copy(off, sizeof(ino), (char*)&ino); off += sizeof(ino);
virtual void decode_payload(crope& s, int& off) { s.copy(off, sizeof(fh), (char*)&fh); off += sizeof(fh); s.copy(off, sizeof(newauth), (char*)&newauth); off += sizeof(newauth); }
uriRef = xmlGetNsProp(cur, (const xmlChar *)"href", XSLT_NAMESPACE);
uriRef = xsltGetNsProp(cur, (const xmlChar *)"href", XSLT_NAMESPACE);
xsltParseStylesheetImport(xsltStylesheetPtr style, xmlNodePtr cur) { xmlDocPtr import = NULL; xmlChar *base = NULL; xmlChar *uriRef = NULL; xmlChar *URI = NULL; xsltStylesheetPtr res; if ((cur == NULL) || (style == NULL)) return; uriRef = xmlGetNsProp(cur, (const xmlChar *)"href", XSLT_NAMESPACE); if (uriRef == NULL) { xsltGenericError(xsltGenericErrorContext, "xsl:import : missing href attribute\n"); goto error; } base = xmlNodeGetBase(style->doc, cur); URI = xmlBuildURI(uriRef, base); if (URI == NULL) { xsltGenericError(xsltGenericErrorContext, "xsl:import : invalid URI reference %s\n", uriRef); goto error; } import = xmlParseFile((const char *)URI); if (import == NULL) { xsltGenericError(xsltGenericErrorContext, "xsl:import : unable to load %s\n", URI); goto error; } res = xsltParseStylesheetDoc(import); if (res != NULL) { res->parent = style; res->next = style->imports; style->imports = res; }error: if (uriRef != NULL) xmlFree(uriRef); if (base != NULL) xmlFree(base); if (URI != NULL) xmlFree(URI);}
if (strcasecmp(argv[1], "smtps") == 0) slave = new SMTPProtocol(argv[2], argv[3], true); else slave = new SMTPProtocol(argv[2], argv[3], false);
slave = new SMTPProtocol(argv[2], argv[3]);
int kdemain( int argc, char **argv ){ KInstance instance( "kio_smtp" ); if (argc != 4) { fprintf(stderr, "Usage: kio_smtp protocol domain-socket1 domain-socket2\n"); exit(-1); } SMTPProtocol *slave; // Are we looking to use SSL? if (strcasecmp(argv[1], "smtps") == 0) slave = new SMTPProtocol(argv[2], argv[3], true); else slave = new SMTPProtocol(argv[2], argv[3], false); slave->dispatchLoop(); delete slave; return 0;}
KCMultiDialog * dlg = new KCMultiDialog(0, 0, true);
KCMultiDialog * dlg = new KCMShellMultiDialog(0, 0, true);
extern "C" int kdemain(int _argc, char *_argv[]){ KAboutData aboutData( "kcmshell", I18N_NOOP("KDE Control Module"), KCONTROL_VERSION, I18N_NOOP("A tool to start single KDE control modules"), KAboutData::License_GPL, "(c) 1999-2004, The KDE Developers"); aboutData.addAuthor("Daniel Molkentin", I18N_NOOP("Current Maintainer"), "[email protected]"); aboutData.addAuthor("Matthias Hoelzer-Kluepfel",0, "[email protected]"); aboutData.addAuthor("Matthias Elter",0, "[email protected]"); aboutData.addAuthor("Matthias Ettrich",0, "[email protected]"); aboutData.addAuthor("Waldo Bastian",0, "[email protected]"); KCmdLineArgs::init(_argc, _argv, &aboutData); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KLocale::setMainCatalogue("kcontrol"); kcmApplication app; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); KGlobal::iconLoader()->addAppDir( "kcontrol" ); QCString lang = args->getOption("lang"); if (! lang.isNull()) { KGlobal::locale()->setLanguage(lang); } if (args->isSet("list")) { cout << i18n("The following modules are available:").local8Bit() << endl; ConfigModuleList modules; modules.readDesktopEntries(); ConfigModule *module = 0; int maxLen=0; for (module=modules.first(); module != 0; module=modules.next()) { int len = stripPath(module->fileName()).length(); if (len > maxLen) maxLen = len; } for (module=modules.first(); module != 0; module=modules.next()) { QString entry("%1 - %2"); entry = entry.arg(stripPath(module->fileName()).leftJustify(maxLen, ' ')); entry = entry.arg(!module->comment().isEmpty() ? module->comment() : i18n("No description available")); cout << entry.local8Bit() << endl; } return 0; } if (args->count() < 1) { args->usage(); return -1; } if (args->count() == 1) { app.setDCOPName(args->arg(0)); if (app.isRunning()) { app.waitForExit(); return 0; } KService::Ptr service = locateModule(args->arg(0)); if (!service) return 1; // error // load the module KCModuleInfo info(service); KCModule *module = KCModuleLoader::loadModule(info, false); if (module) { // create the dialog QCString embedStr = args->getOption("embed"); bool embed = false; int id = -1; if (!embedStr.isEmpty()) id = embedStr.toInt(&embed); if (!args->isSet("silent")) { if (!embed) { KCDialog * dlg = new KCDialog(module, module->buttons(), info.docPath(), 0, 0, true ); QString caption = (kapp->caption() != i18n("KDE Control Module")) ? kapp->caption() : info.moduleName(); if (kapp->iconName() != kapp->name()) setIcon(dlg, kapp->iconName()); else setIcon(dlg, info.icon()); dlg->setPlainCaption(i18n("Configure - %1").arg(caption)); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg->setAcceptDrops(true); // run the dialog dlg->exec(); delete dlg; } // if we are going to be embedded, embed else { QWidget *dlg = new ProxyWidget(module, info.moduleName(), "kcmshell", false); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg->setAcceptDrops(true); QXEmbed::embedClientIntoWindow(dlg, id); kapp->exec(); delete dlg; } } else { //Silent kapp->exec(); } KCModuleLoader::unloadModule(info); return 0; } KCModuleLoader::showLastLoaderError(0L); return 0; } // multiple control modules KService::List modules; for (int i = 0; i < args->count(); i++) { KService::Ptr service = locateModule(args->arg(i)); if (service) { modules.append(service); continue; } } if (modules.count() < 1) return -1; // create the dialog KCMultiDialog * dlg = new KCMultiDialog(0, 0, true); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg->setAcceptDrops(true); // add modules for (KService::List::ConstIterator it = modules.begin(); it != modules.end(); ++it) dlg->addModule(KCModuleInfo(*it)); // if we are going to be embedded, embed QCString embed = args->getOption("embed"); if (!embed.isEmpty()) { bool ok; int id = embed.toInt(&ok); if (ok) { // NOTE: This has to be changed for QT 3.0. See above! QXEmbed::embedClientIntoWindow(dlg, id); delete dlg; return 0; } } if (kapp->iconName() != kapp->name()) setIcon(dlg, kapp->iconName()); dlg->setPlainCaption(i18n("Configure - %1").arg(kapp->caption())); // run the dialog dlg->exec(); delete dlg; return 0;}
only acquire */
only acquire the reader lock. */
do_broadcast (struct binding *list){ char *domain; bool_t out; enum clnt_stat status; /* Get readlock and create a local copy of the domainname. Else a SIGHUP could delete the data and we will dereference invalid data. */ pthread_rdwr_rlock_np (&domainlock); domain = strdupa (list->domain); pthread_rdwr_runlock_np (&domainlock); if (debug_flag) log_msg (LOG_DEBUG, _("do_broadcast() for domain '%s' is called"), domain); /* Get a writer lock for the domain list, since we modify one entry. */ pthread_rdwr_wlock_np (&domainlock); list->active = -1; pthread_rdwr_wunlock_np (&domainlock); /* Get a reader lock while we do the broadcast. Normally we would need the writer lock, since we modify the data. But in this case, the broadcast timeout is too long and we would block all queries. Since we don't change pointers and all data is always valid, we only acquire */ pthread_rdwr_rlock_np (&domainlock); in_use = list; /* global variable for eachresult */ status = clnt_broadcast (YPPROG, YPVERS, YPPROC_DOMAIN_NONACK, (xdrproc_t) ypbind_xdr_domainname, (void *)&domain, (xdrproc_t) xdr_bool, (void *)&out, (resultproc_t) eachresult); if (status != RPC_SUCCESS) { remove_bindingfile (domain); log_msg (LOG_ERR, "broadcast: %s.", clnt_sperrno (status)); } else update_bindingfile (list); pthread_rdwr_runlock_np (&domainlock); if (debug_flag) log_msg (LOG_DEBUG, _("leave do_broadcast() for domain '%s'"), domain);}
if (flags > KRdbExportColors)
bool exportQtColors = flags & KRdbExportQtColors; bool exportQtSettings = flags & KRdbExportQtSettings; if ( exportQtColors || exportQtSettings )
void runRdb( uint flags ){ // Export colors to non-(KDE/Qt) apps (e.g. Motif, GTK+ apps) if (flags & KRdbExportColors) { KGlobal::dirs()->addResourceType("appdefaults", KStandardDirs::kde_default("data") + "kdisplay/app-defaults/"); QColorGroup cg = kapp->palette().active(); createGtkrc( true, cg ); QString preproc; addColorDef(preproc, "FOREGROUND" , cg.foreground()); QColor backCol = cg.background(); addColorDef(preproc, "BACKGROUND" , backCol); addColorDef(preproc, "HIGHLIGHT" , backCol.light(100+(2*KGlobalSettings::contrast()+4)*16/1)); addColorDef(preproc, "LOWLIGHT" , backCol.dark(100+(2*KGlobalSettings::contrast()+4)*10)); addColorDef(preproc, "SELECT_BACKGROUND" , cg.highlight()); addColorDef(preproc, "SELECT_FOREGROUND" , cg.highlightedText()); addColorDef(preproc, "WINDOW_BACKGROUND" , cg.base()); addColorDef(preproc, "WINDOW_FOREGROUND" , cg.foreground()); addColorDef(preproc, "INACTIVE_BACKGROUND", KGlobalSettings::inactiveTitleColor()); addColorDef(preproc, "INACTIVE_FOREGROUND", KGlobalSettings::inactiveTitleColor()); addColorDef(preproc, "ACTIVE_BACKGROUND" , KGlobalSettings::activeTitleColor()); addColorDef(preproc, "ACTIVE_FOREGROUND" , KGlobalSettings::activeTitleColor()); //--------------------------------------------------------------- QStringList list; QStringList adPaths = KGlobal::dirs()->findDirs("appdefaults", ""); for (QStringList::ConstIterator it = adPaths.begin(); it != adPaths.end(); it++) { QDir dSys( *it ); if ( dSys.exists() ) { dSys.setFilter( QDir::Files ); dSys.setSorting( QDir::Name ); dSys.setNameFilter("*.ad"); list += dSys.entryList(); } } QString propString; KTempFile tmpFile; if (tmpFile.status() != 0) { kdDebug() << "Couldn't open temp file" << endl; exit(0); } QFile &tmp = *(tmpFile.file()); tmp.writeBlock( preproc.latin1(), preproc.length() ); for (QStringList::ConstIterator it = list.begin(); it != list.end(); it++) copyFile(tmp, locate("appdefaults", *it ), true); // very primitive support for ~/.Xdefaults by appending it copyFile(tmp, QDir::homeDirPath() + "/.Xdefaults", true); tmpFile.close(); KProcess proc; proc << "xrdb" << tmpFile.name(); proc.start( KProcess::Block, KProcess::Stdin ); tmpFile.unlink(); applyGtkStyles(true); } else applyGtkStyles(false); if (flags > KRdbExportColors) { { /* extra braces for a qsettings.sync() in its destructor */ QSettings settings; KSimpleConfig kglobals("kdeglobals", true); /* open read-only */ if ( flags & KRdbExportQtColors ) applyQtColors( kglobals, settings ); // For kcmcolors if ( flags & KRdbExportQtSettings ) applyQtSettings( kglobals, settings ); // For kcmstyle } /* apply the settings to qt-only apps */ QApplication::setDesktopSettingsAware( true ); QApplication::x11_apply_settings(); QApplication::setDesktopSettingsAware( false ); }}
{ QSettings settings; KSimpleConfig kglobals("kdeglobals", true);
QSettings* settings = new QSettings; KSimpleConfig kglobals("kdeglobals", true);
void runRdb( uint flags ){ // Export colors to non-(KDE/Qt) apps (e.g. Motif, GTK+ apps) if (flags & KRdbExportColors) { KGlobal::dirs()->addResourceType("appdefaults", KStandardDirs::kde_default("data") + "kdisplay/app-defaults/"); QColorGroup cg = kapp->palette().active(); createGtkrc( true, cg ); QString preproc; addColorDef(preproc, "FOREGROUND" , cg.foreground()); QColor backCol = cg.background(); addColorDef(preproc, "BACKGROUND" , backCol); addColorDef(preproc, "HIGHLIGHT" , backCol.light(100+(2*KGlobalSettings::contrast()+4)*16/1)); addColorDef(preproc, "LOWLIGHT" , backCol.dark(100+(2*KGlobalSettings::contrast()+4)*10)); addColorDef(preproc, "SELECT_BACKGROUND" , cg.highlight()); addColorDef(preproc, "SELECT_FOREGROUND" , cg.highlightedText()); addColorDef(preproc, "WINDOW_BACKGROUND" , cg.base()); addColorDef(preproc, "WINDOW_FOREGROUND" , cg.foreground()); addColorDef(preproc, "INACTIVE_BACKGROUND", KGlobalSettings::inactiveTitleColor()); addColorDef(preproc, "INACTIVE_FOREGROUND", KGlobalSettings::inactiveTitleColor()); addColorDef(preproc, "ACTIVE_BACKGROUND" , KGlobalSettings::activeTitleColor()); addColorDef(preproc, "ACTIVE_FOREGROUND" , KGlobalSettings::activeTitleColor()); //--------------------------------------------------------------- QStringList list; QStringList adPaths = KGlobal::dirs()->findDirs("appdefaults", ""); for (QStringList::ConstIterator it = adPaths.begin(); it != adPaths.end(); it++) { QDir dSys( *it ); if ( dSys.exists() ) { dSys.setFilter( QDir::Files ); dSys.setSorting( QDir::Name ); dSys.setNameFilter("*.ad"); list += dSys.entryList(); } } QString propString; KTempFile tmpFile; if (tmpFile.status() != 0) { kdDebug() << "Couldn't open temp file" << endl; exit(0); } QFile &tmp = *(tmpFile.file()); tmp.writeBlock( preproc.latin1(), preproc.length() ); for (QStringList::ConstIterator it = list.begin(); it != list.end(); it++) copyFile(tmp, locate("appdefaults", *it ), true); // very primitive support for ~/.Xdefaults by appending it copyFile(tmp, QDir::homeDirPath() + "/.Xdefaults", true); tmpFile.close(); KProcess proc; proc << "xrdb" << tmpFile.name(); proc.start( KProcess::Block, KProcess::Stdin ); tmpFile.unlink(); applyGtkStyles(true); } else applyGtkStyles(false); if (flags > KRdbExportColors) { { /* extra braces for a qsettings.sync() in its destructor */ QSettings settings; KSimpleConfig kglobals("kdeglobals", true); /* open read-only */ if ( flags & KRdbExportQtColors ) applyQtColors( kglobals, settings ); // For kcmcolors if ( flags & KRdbExportQtSettings ) applyQtSettings( kglobals, settings ); // For kcmstyle } /* apply the settings to qt-only apps */ QApplication::setDesktopSettingsAware( true ); QApplication::x11_apply_settings(); QApplication::setDesktopSettingsAware( false ); }}
if ( flags & KRdbExportQtColors ) applyQtColors( kglobals, settings );
if ( exportQtColors ) applyQtColors( kglobals, *settings );
void runRdb( uint flags ){ // Export colors to non-(KDE/Qt) apps (e.g. Motif, GTK+ apps) if (flags & KRdbExportColors) { KGlobal::dirs()->addResourceType("appdefaults", KStandardDirs::kde_default("data") + "kdisplay/app-defaults/"); QColorGroup cg = kapp->palette().active(); createGtkrc( true, cg ); QString preproc; addColorDef(preproc, "FOREGROUND" , cg.foreground()); QColor backCol = cg.background(); addColorDef(preproc, "BACKGROUND" , backCol); addColorDef(preproc, "HIGHLIGHT" , backCol.light(100+(2*KGlobalSettings::contrast()+4)*16/1)); addColorDef(preproc, "LOWLIGHT" , backCol.dark(100+(2*KGlobalSettings::contrast()+4)*10)); addColorDef(preproc, "SELECT_BACKGROUND" , cg.highlight()); addColorDef(preproc, "SELECT_FOREGROUND" , cg.highlightedText()); addColorDef(preproc, "WINDOW_BACKGROUND" , cg.base()); addColorDef(preproc, "WINDOW_FOREGROUND" , cg.foreground()); addColorDef(preproc, "INACTIVE_BACKGROUND", KGlobalSettings::inactiveTitleColor()); addColorDef(preproc, "INACTIVE_FOREGROUND", KGlobalSettings::inactiveTitleColor()); addColorDef(preproc, "ACTIVE_BACKGROUND" , KGlobalSettings::activeTitleColor()); addColorDef(preproc, "ACTIVE_FOREGROUND" , KGlobalSettings::activeTitleColor()); //--------------------------------------------------------------- QStringList list; QStringList adPaths = KGlobal::dirs()->findDirs("appdefaults", ""); for (QStringList::ConstIterator it = adPaths.begin(); it != adPaths.end(); it++) { QDir dSys( *it ); if ( dSys.exists() ) { dSys.setFilter( QDir::Files ); dSys.setSorting( QDir::Name ); dSys.setNameFilter("*.ad"); list += dSys.entryList(); } } QString propString; KTempFile tmpFile; if (tmpFile.status() != 0) { kdDebug() << "Couldn't open temp file" << endl; exit(0); } QFile &tmp = *(tmpFile.file()); tmp.writeBlock( preproc.latin1(), preproc.length() ); for (QStringList::ConstIterator it = list.begin(); it != list.end(); it++) copyFile(tmp, locate("appdefaults", *it ), true); // very primitive support for ~/.Xdefaults by appending it copyFile(tmp, QDir::homeDirPath() + "/.Xdefaults", true); tmpFile.close(); KProcess proc; proc << "xrdb" << tmpFile.name(); proc.start( KProcess::Block, KProcess::Stdin ); tmpFile.unlink(); applyGtkStyles(true); } else applyGtkStyles(false); if (flags > KRdbExportColors) { { /* extra braces for a qsettings.sync() in its destructor */ QSettings settings; KSimpleConfig kglobals("kdeglobals", true); /* open read-only */ if ( flags & KRdbExportQtColors ) applyQtColors( kglobals, settings ); // For kcmcolors if ( flags & KRdbExportQtSettings ) applyQtSettings( kglobals, settings ); // For kcmstyle } /* apply the settings to qt-only apps */ QApplication::setDesktopSettingsAware( true ); QApplication::x11_apply_settings(); QApplication::setDesktopSettingsAware( false ); }}
if ( flags & KRdbExportQtSettings ) applyQtSettings( kglobals, settings );
if ( exportQtSettings ) applyQtSettings( kglobals, *settings ); delete settings; QDateTime settingsstamp = QDateTime::currentDateTime(); static Atom qt_settings_timestamp = 0; if (!qt_settings_timestamp) { QString atomname("_QT_SETTINGS_TIMESTAMP_"); atomname += XDisplayName( 0 ); qt_settings_timestamp = XInternAtom( qt_xdisplay(), atomname.latin1(), False);
void runRdb( uint flags ){ // Export colors to non-(KDE/Qt) apps (e.g. Motif, GTK+ apps) if (flags & KRdbExportColors) { KGlobal::dirs()->addResourceType("appdefaults", KStandardDirs::kde_default("data") + "kdisplay/app-defaults/"); QColorGroup cg = kapp->palette().active(); createGtkrc( true, cg ); QString preproc; addColorDef(preproc, "FOREGROUND" , cg.foreground()); QColor backCol = cg.background(); addColorDef(preproc, "BACKGROUND" , backCol); addColorDef(preproc, "HIGHLIGHT" , backCol.light(100+(2*KGlobalSettings::contrast()+4)*16/1)); addColorDef(preproc, "LOWLIGHT" , backCol.dark(100+(2*KGlobalSettings::contrast()+4)*10)); addColorDef(preproc, "SELECT_BACKGROUND" , cg.highlight()); addColorDef(preproc, "SELECT_FOREGROUND" , cg.highlightedText()); addColorDef(preproc, "WINDOW_BACKGROUND" , cg.base()); addColorDef(preproc, "WINDOW_FOREGROUND" , cg.foreground()); addColorDef(preproc, "INACTIVE_BACKGROUND", KGlobalSettings::inactiveTitleColor()); addColorDef(preproc, "INACTIVE_FOREGROUND", KGlobalSettings::inactiveTitleColor()); addColorDef(preproc, "ACTIVE_BACKGROUND" , KGlobalSettings::activeTitleColor()); addColorDef(preproc, "ACTIVE_FOREGROUND" , KGlobalSettings::activeTitleColor()); //--------------------------------------------------------------- QStringList list; QStringList adPaths = KGlobal::dirs()->findDirs("appdefaults", ""); for (QStringList::ConstIterator it = adPaths.begin(); it != adPaths.end(); it++) { QDir dSys( *it ); if ( dSys.exists() ) { dSys.setFilter( QDir::Files ); dSys.setSorting( QDir::Name ); dSys.setNameFilter("*.ad"); list += dSys.entryList(); } } QString propString; KTempFile tmpFile; if (tmpFile.status() != 0) { kdDebug() << "Couldn't open temp file" << endl; exit(0); } QFile &tmp = *(tmpFile.file()); tmp.writeBlock( preproc.latin1(), preproc.length() ); for (QStringList::ConstIterator it = list.begin(); it != list.end(); it++) copyFile(tmp, locate("appdefaults", *it ), true); // very primitive support for ~/.Xdefaults by appending it copyFile(tmp, QDir::homeDirPath() + "/.Xdefaults", true); tmpFile.close(); KProcess proc; proc << "xrdb" << tmpFile.name(); proc.start( KProcess::Block, KProcess::Stdin ); tmpFile.unlink(); applyGtkStyles(true); } else applyGtkStyles(false); if (flags > KRdbExportColors) { { /* extra braces for a qsettings.sync() in its destructor */ QSettings settings; KSimpleConfig kglobals("kdeglobals", true); /* open read-only */ if ( flags & KRdbExportQtColors ) applyQtColors( kglobals, settings ); // For kcmcolors if ( flags & KRdbExportQtSettings ) applyQtSettings( kglobals, settings ); // For kcmstyle } /* apply the settings to qt-only apps */ QApplication::setDesktopSettingsAware( true ); QApplication::x11_apply_settings(); QApplication::setDesktopSettingsAware( false ); }}
QApplication::setDesktopSettingsAware( true ); QApplication::x11_apply_settings(); QApplication::setDesktopSettingsAware( false );
QBuffer stamp; QDataStream s(stamp.buffer(), IO_WriteOnly); s << settingsstamp; XChangeProperty( qt_xdisplay(), qt_xrootwin(), qt_settings_timestamp, qt_settings_timestamp, 8, PropModeReplace, (unsigned char*) stamp.buffer().data(), stamp.buffer().size() );
void runRdb( uint flags ){ // Export colors to non-(KDE/Qt) apps (e.g. Motif, GTK+ apps) if (flags & KRdbExportColors) { KGlobal::dirs()->addResourceType("appdefaults", KStandardDirs::kde_default("data") + "kdisplay/app-defaults/"); QColorGroup cg = kapp->palette().active(); createGtkrc( true, cg ); QString preproc; addColorDef(preproc, "FOREGROUND" , cg.foreground()); QColor backCol = cg.background(); addColorDef(preproc, "BACKGROUND" , backCol); addColorDef(preproc, "HIGHLIGHT" , backCol.light(100+(2*KGlobalSettings::contrast()+4)*16/1)); addColorDef(preproc, "LOWLIGHT" , backCol.dark(100+(2*KGlobalSettings::contrast()+4)*10)); addColorDef(preproc, "SELECT_BACKGROUND" , cg.highlight()); addColorDef(preproc, "SELECT_FOREGROUND" , cg.highlightedText()); addColorDef(preproc, "WINDOW_BACKGROUND" , cg.base()); addColorDef(preproc, "WINDOW_FOREGROUND" , cg.foreground()); addColorDef(preproc, "INACTIVE_BACKGROUND", KGlobalSettings::inactiveTitleColor()); addColorDef(preproc, "INACTIVE_FOREGROUND", KGlobalSettings::inactiveTitleColor()); addColorDef(preproc, "ACTIVE_BACKGROUND" , KGlobalSettings::activeTitleColor()); addColorDef(preproc, "ACTIVE_FOREGROUND" , KGlobalSettings::activeTitleColor()); //--------------------------------------------------------------- QStringList list; QStringList adPaths = KGlobal::dirs()->findDirs("appdefaults", ""); for (QStringList::ConstIterator it = adPaths.begin(); it != adPaths.end(); it++) { QDir dSys( *it ); if ( dSys.exists() ) { dSys.setFilter( QDir::Files ); dSys.setSorting( QDir::Name ); dSys.setNameFilter("*.ad"); list += dSys.entryList(); } } QString propString; KTempFile tmpFile; if (tmpFile.status() != 0) { kdDebug() << "Couldn't open temp file" << endl; exit(0); } QFile &tmp = *(tmpFile.file()); tmp.writeBlock( preproc.latin1(), preproc.length() ); for (QStringList::ConstIterator it = list.begin(); it != list.end(); it++) copyFile(tmp, locate("appdefaults", *it ), true); // very primitive support for ~/.Xdefaults by appending it copyFile(tmp, QDir::homeDirPath() + "/.Xdefaults", true); tmpFile.close(); KProcess proc; proc << "xrdb" << tmpFile.name(); proc.start( KProcess::Block, KProcess::Stdin ); tmpFile.unlink(); applyGtkStyles(true); } else applyGtkStyles(false); if (flags > KRdbExportColors) { { /* extra braces for a qsettings.sync() in its destructor */ QSettings settings; KSimpleConfig kglobals("kdeglobals", true); /* open read-only */ if ( flags & KRdbExportQtColors ) applyQtColors( kglobals, settings ); // For kcmcolors if ( flags & KRdbExportQtSettings ) applyQtSettings( kglobals, settings ); // For kcmstyle } /* apply the settings to qt-only apps */ QApplication::setDesktopSettingsAware( true ); QApplication::x11_apply_settings(); QApplication::setDesktopSettingsAware( false ); }}
int main(int argc, char **argv)
int main(int , char **)
int main(int argc, char **argv){ signal(SIGCHLD, sigchld_handler); signal(SIGSEGV, sigsegv_handler); Connection parent( 0, 1 ); POP3Protocol pop3( &parent ); pop3.dispatchLoop();}
I18N_NOOP( "Helper program to handle the KDE trash can" ),
I18N_NOOP( "Helper program to handle the KDE trash can\n" "Note: to move files to the trash, don't use ktrash, but \"kfmclient move 'url' trash:/\"" ),
int main(int argc, char *argv[]){ KApplication::disableAutoDcopRegistration(); KCmdLineArgs::init( argc, argv, "ktrash", I18N_NOOP( "ktrash" ), I18N_NOOP( "Helper program to handle the KDE trash can" ), KDE_VERSION_STRING ); KCmdLineArgs::addCmdLineOptions( options ); KApplication app; KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); if ( args->isSet( "empty" ) ) { // We use a kio job instead of linking to TrashImpl, for a smaller binary // (and the possibility of a central service at some point) QByteArray packedArgs; QDataStream stream( packedArgs, IO_WriteOnly ); stream << (int)1; KIO::Job* job = KIO::special( "trash:/", packedArgs ); (void)KIO::NetAccess::synchronousRun( job, 0 ); // Update konq windows opened on trash:/ KDirNotify_stub allDirNotify("*", "KDirNotify*"); allDirNotify.FilesAdded( "trash:/" ); // yeah, files were removed, but we don't know which ones... return 0; }#if 0 // This is only for testing. KDesktop handles it automatically. if ( args->isSet( "migrate" ) ) { QByteArray packedArgs; QDataStream stream( packedArgs, IO_WriteOnly ); stream << (int)2; KIO::Job* job = KIO::special( "trash:/", packedArgs ); (void)KIO::NetAccess::synchronousRun( job, 0 ); return 0; }#endif QCString restoreArg = args->getOption( "restore" ); if ( !restoreArg.isEmpty() ) { KURL trashURL( restoreArg ); if ( !trashURL.isValid() || trashURL.protocol() != "trash" ) { kdError() << "Invalid URL for restoring a trashed file:" << trashURL << endl; return 1; } QByteArray packedArgs; QDataStream stream( packedArgs, IO_WriteOnly ); stream << (int)3 << trashURL; KIO::Job* job = KIO::special( trashURL, packedArgs ); bool ok = KIO::NetAccess::synchronousRun( job, 0 ); if ( !ok ) kdError() << KIO::NetAccess::lastErrorString() << endl; return 0; } return 0;}
kDebugInfo("kdesud: PID %d exited", (int) pid);
kdDebug(1205) << "PID " << (int) pid << "exited\n";
void sigchld_handler(int){ int status; pid_t pid; while (1) { pid = waitpid((pid_t) -1, &status, WNOHANG); if (pid <= 0) break; kDebugInfo("kdesud: PID %d exited", (int) pid); }}
ThumbCreator *new_creator()
KDE_EXPORT ThumbCreator *new_creator()
ThumbCreator *new_creator() { return new CursorCreator; }
ref--; if (ref == 0) lru_unpin();
if (ref == 1) lru_unpin(); return --ref;
int put() { assert(ref > 0); ref--; if (ref == 0) lru_unpin(); }
CheesySerializer *serializer = new CheesySerializer( new FakeMessenger(MSG_ADDR_CLIENT(0)) ); client[i] = new Client(mdc, i, serializer);
client[i] = new Client(mdc, i, new FakeMessenger(MSG_ADDR_CLIENT(0)));
int main(int oargc, char **oargv) { cerr << "fakefuse starting" << endl; int argc; char **argv; parse_config_options(oargc, oargv, argc, argv); MDCluster *mdc = new MDCluster(NUMMDS, NUMOSD); // start messenger thread fakemessenger_startthread(); //g_timer.add_event_after(5.0, new C_Test2); //g_timer.add_event_after(10.0, new C_Test); int mkfs = 0; for (int i=1; i<argc; i++) { if (strcmp(argv[i], "--fastmkfs") == 0) { mkfs = MDS_MKFS_FAST; argv[i] = 0; argc--; break; } if (strcmp(argv[i], "--fullmkfs") == 0) { mkfs = MDS_MKFS_FULL; argv[i] = 0; argc--; break; } } // create osd OSD *osd[NUMOSD]; for (int i=0; i<NUMOSD; i++) { osd[i] = new OSD(i, new FakeMessenger(MSG_ADDR_OSD(i))); osd[i]->init(); } // create mds MDS *mds[NUMMDS]; for (int i=0; i<NUMMDS; i++) { mds[i] = new MDS(mdc, i, new FakeMessenger(MSG_ADDR_MDS(i))); mds[i]->init(); } // create client Client *client[NUMCLIENT]; for (int i=0; i<NUMCLIENT; i++) { // build a serialized fakemessenger... CheesySerializer *serializer = new CheesySerializer( new FakeMessenger(MSG_ADDR_CLIENT(0)) ); client[i] = new Client(mdc, i, serializer); client[i]->init(); // start up fuse // use my argc, argv (make sure you pass a mount point!) cout << "starting fuse on pid " << getpid() << endl; client[i]->mount(mkfs); ceph_fuse_main(client[i], argc, argv); client[i]->unmount(); cout << "fuse finished on pid " << getpid() << endl; client[i]->shutdown(); } // wait for it to finish cout << "DONE -----" << endl; fakemessenger_stopthread(); // blocks until messenger stops // cleanup for (int i=0; i<NUMMDS; i++) { delete mds[i]; } for (int i=0; i<NUMOSD; i++) { delete osd[i]; } for (int i=0; i<NUMCLIENT; i++) { delete client[i]; } delete mdc; return 0;}
JNIEnv *env;
JNIEnv *env = NULL;
SWT_PTR callback(int index, ...){ if (!callbackEnabled) return 0; { jobject callback = callbackData[index].callin; jmethodID mid = callbackData[index].methodID; JNIEnv *env; jobject javaObject; jboolean isStatic, isArrayBased; int result = 0; va_list vl;#ifdef DEBUG_CALL_PRINTS fprintf(stderr, "* callback starting %d\n", counter++);#endif#ifdef JNI_VERSION_1_2 if (IS_JNI_1_2) { (*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_2); } else#endif { (*jvm)->AttachCurrentThread(jvm, (void **)&env, NULL); } /* Either we are disconnected from the VM or an exception has occurred. */ if (env == 0 ||(*env)->ExceptionOccurred(env)) {#ifdef DEBUG_CALL_PRINTS fprintf(stderr, "************ java exception occurred\n");#endif return 0; } javaObject = (*env)->GetObjectField(env,callback, objectID); isStatic = ((*env)->GetBooleanField(env,callback, isStaticID)) != 0; isArrayBased = ((*env)->GetBooleanField(env,callback, isArrayBasedID)) != 0; callbackEntryCount++; va_start(vl, index); if (isArrayBased) { int i; jint argCount = (*env)->GetIntField(env, callback, argCountID); SWT_PTRArray javaArray = (*env)->NewSWT_PTRArray(env, argCount); SWT_PTR *elements = (*env)->GetSWT_PTRArrayElements(env, javaArray, NULL); for (i=0; i<argCount; i++) { elements[i] = va_arg(vl, SWT_PTR); } (*env)->ReleaseSWT_PTRArrayElements(env, javaArray, elements, 0); if (isStatic) { result = (*env)->CallStaticSWT_PTRMethod(env, javaObject, mid, javaArray); } else { result = (*env)->CallSWT_PTRMethod(env, javaObject, mid, javaArray); } (*env)->DeleteLocalRef(env, javaArray); } else { if (isStatic) { result = (*env)->CallStaticSWT_PTRMethodV(env, javaObject, mid, vl); } else { result = (*env)->CallSWT_PTRMethodV(env, javaObject, mid, vl); } } va_end(vl); callbackEntryCount--; /* * This function may be called many times before we return to Java. * We have to explicitly delete local references to avoid GP's * in the JDK and IBM Hursley VM. */ (*env)->DeleteLocalRef(env, javaObject);#ifdef DEBUG_CALL_PRINTS fprintf(stderr, "* callback exiting %d\n", --counter);#endif return result; }}
if (env == 0 ||(*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionOccurred(env)) {
SWT_PTR callback(int index, ...){ if (!callbackEnabled) return 0; { jobject callback = callbackData[index].callin; jmethodID mid = callbackData[index].methodID; JNIEnv *env; jobject javaObject; jboolean isStatic, isArrayBased; int result = 0; va_list vl;#ifdef DEBUG_CALL_PRINTS fprintf(stderr, "* callback starting %d\n", counter++);#endif#ifdef JNI_VERSION_1_2 if (IS_JNI_1_2) { (*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_2); } else#endif { (*jvm)->AttachCurrentThread(jvm, (void **)&env, NULL); } /* Either we are disconnected from the VM or an exception has occurred. */ if (env == 0 ||(*env)->ExceptionOccurred(env)) {#ifdef DEBUG_CALL_PRINTS fprintf(stderr, "************ java exception occurred\n");#endif return 0; } javaObject = (*env)->GetObjectField(env,callback, objectID); isStatic = ((*env)->GetBooleanField(env,callback, isStaticID)) != 0; isArrayBased = ((*env)->GetBooleanField(env,callback, isArrayBasedID)) != 0; callbackEntryCount++; va_start(vl, index); if (isArrayBased) { int i; jint argCount = (*env)->GetIntField(env, callback, argCountID); SWT_PTRArray javaArray = (*env)->NewSWT_PTRArray(env, argCount); SWT_PTR *elements = (*env)->GetSWT_PTRArrayElements(env, javaArray, NULL); for (i=0; i<argCount; i++) { elements[i] = va_arg(vl, SWT_PTR); } (*env)->ReleaseSWT_PTRArrayElements(env, javaArray, elements, 0); if (isStatic) { result = (*env)->CallStaticSWT_PTRMethod(env, javaObject, mid, javaArray); } else { result = (*env)->CallSWT_PTRMethod(env, javaObject, mid, javaArray); } (*env)->DeleteLocalRef(env, javaArray); } else { if (isStatic) { result = (*env)->CallStaticSWT_PTRMethodV(env, javaObject, mid, vl); } else { result = (*env)->CallSWT_PTRMethodV(env, javaObject, mid, vl); } } va_end(vl); callbackEntryCount--; /* * This function may be called many times before we return to Java. * We have to explicitly delete local references to avoid GP's * in the JDK and IBM Hursley VM. */ (*env)->DeleteLocalRef(env, javaObject);#ifdef DEBUG_CALL_PRINTS fprintf(stderr, "* callback exiting %d\n", --counter);#endif return result; }}
(*env)->ExceptionDescribe(env);
SWT_PTR callback(int index, ...){ if (!callbackEnabled) return 0; { jobject callback = callbackData[index].callin; jmethodID mid = callbackData[index].methodID; JNIEnv *env; jobject javaObject; jboolean isStatic, isArrayBased; int result = 0; va_list vl;#ifdef DEBUG_CALL_PRINTS fprintf(stderr, "* callback starting %d\n", counter++);#endif#ifdef JNI_VERSION_1_2 if (IS_JNI_1_2) { (*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_2); } else#endif { (*jvm)->AttachCurrentThread(jvm, (void **)&env, NULL); } /* Either we are disconnected from the VM or an exception has occurred. */ if (env == 0 ||(*env)->ExceptionOccurred(env)) {#ifdef DEBUG_CALL_PRINTS fprintf(stderr, "************ java exception occurred\n");#endif return 0; } javaObject = (*env)->GetObjectField(env,callback, objectID); isStatic = ((*env)->GetBooleanField(env,callback, isStaticID)) != 0; isArrayBased = ((*env)->GetBooleanField(env,callback, isArrayBasedID)) != 0; callbackEntryCount++; va_start(vl, index); if (isArrayBased) { int i; jint argCount = (*env)->GetIntField(env, callback, argCountID); SWT_PTRArray javaArray = (*env)->NewSWT_PTRArray(env, argCount); SWT_PTR *elements = (*env)->GetSWT_PTRArrayElements(env, javaArray, NULL); for (i=0; i<argCount; i++) { elements[i] = va_arg(vl, SWT_PTR); } (*env)->ReleaseSWT_PTRArrayElements(env, javaArray, elements, 0); if (isStatic) { result = (*env)->CallStaticSWT_PTRMethod(env, javaObject, mid, javaArray); } else { result = (*env)->CallSWT_PTRMethod(env, javaObject, mid, javaArray); } (*env)->DeleteLocalRef(env, javaArray); } else { if (isStatic) { result = (*env)->CallStaticSWT_PTRMethodV(env, javaObject, mid, vl); } else { result = (*env)->CallSWT_PTRMethodV(env, javaObject, mid, vl); } } va_end(vl); callbackEntryCount--; /* * This function may be called many times before we return to Java. * We have to explicitly delete local references to avoid GP's * in the JDK and IBM Hursley VM. */ (*env)->DeleteLocalRef(env, javaObject);#ifdef DEBUG_CALL_PRINTS fprintf(stderr, "* callback exiting %d\n", --counter);#endif return result; }}
cerr << i18n("Module %1 not found!").arg(arg).local8Bit() << endl;
kdError(1208) << i18n("Module %1 not found!").arg(arg) << endl;
int main(int argc, char *argv[]){ KLocale::setMainCatalogue("kcontrol"); KAboutData aboutData( "kcminit", I18N_NOOP("KCMInit"), "$Id$", I18N_NOOP("KCMInit - runs startups initialisation for Control Modules.")); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KApplication app; KLocale::setMainCatalogue(0); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); QCString arg; if (args->count() == 1) { arg = args->arg(0); } // get the library loader instance KLibLoader *loader = KLibLoader::self(); KService::List list; if (!arg.isEmpty()) { QString path = KCGlobal::baseGroup(); path += arg; path += ".desktop"; KService::Ptr serv = KService::serviceByDesktopPath( path ); if (!serv) { // Path didn't work. Trying as a name serv = KService::serviceByDesktopName( arg ); } if ( !serv || serv->library().isEmpty() || serv->init().isEmpty()) { cerr << i18n("Module %1 not found!").arg(arg).local8Bit() << endl; return -1; } else list.append(serv); } else { // locate the desktop files list = KService::allInitServices(); } // look for X-KDE-Init=... entries for(KService::List::Iterator it = list.begin(); it != list.end(); ++it) { KService::Ptr service = (*it); if (service->library().isEmpty() || service->init().isEmpty()) continue; // Skip // try to load the library QString libName = QString("libkcm_%1").arg(service->library()); KLibrary *lib = loader->library(QFile::encodeName(libName)); if (lib) { // get the init_ function QString factory = QString("init_%1").arg(service->init()); void *init = lib->symbol(factory.utf8()); if (init) { // initialize the module kdDebug() << "Initializing " << libName << ": " << factory << endl; void (*func)() = (void(*)())init; func(); } loader->unloadLibrary(QFile::encodeName(libName)); } } if ( !kapp->dcopClient()->isAttached() ) kapp->dcopClient()->attach(); kapp->dcopClient()->send( "ksplash", "", "upAndRunning(QString)", QString("kcminit")); return 0;}
fprintf(stderr, "URI %s %s %s\n", obj->stringval, base, URI);
xsltDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs){ xsltDocumentPtr doc; xmlXPathObjectPtr obj, obj2=NULL; xmlChar *base, *URI; if ((nargs < 1) || (nargs > 2)) { xsltGenericError(xsltGenericErrorContext, "document() : invalid number of args %d\n", nargs); ctxt->error = XPATH_INVALID_ARITY; return; } if (ctxt->value == NULL) { xsltGenericError(xsltGenericErrorContext, "document() : invalid arg value\n"); ctxt->error = XPATH_INVALID_TYPE; return; } if (nargs == 2) { if (ctxt->value->type != XPATH_NODESET) { xsltGenericError(xsltGenericErrorContext, "document() : invalid arg expecting a nodeset\n"); ctxt->error = XPATH_INVALID_TYPE; return; } obj2 = valuePop(ctxt); } if (ctxt->value->type == XPATH_NODESET) { int i; xmlXPathObjectPtr newobj, ret; obj = valuePop(ctxt); ret = xmlXPathNewNodeSet(NULL); for (i = 0; i < obj->nodesetval->nodeNr; i++) { valuePush(ctxt, xmlXPathNewNodeSet(obj->nodesetval->nodeTab[i])); xmlXPathStringFunction(ctxt, 1); if (nargs == 2) { valuePush(ctxt, xmlXPathObjectCopy(obj2)); } else { valuePush(ctxt, xmlXPathNewNodeSet(obj->nodesetval->nodeTab[i])); } xsltDocumentFunction(ctxt, 2); newobj = valuePop(ctxt); ret->nodesetval = xmlXPathNodeSetMerge(ret->nodesetval, newobj->nodesetval); xmlXPathFreeObject(newobj); } xmlXPathFreeObject(obj); if (obj2 != NULL) xmlXPathFreeObject(obj2); valuePush(ctxt, ret); return; } /* * Make sure it's converted to a string */ xmlXPathStringFunction(ctxt, 1); if (ctxt->value->type != XPATH_STRING) { xsltGenericError(xsltGenericErrorContext, "document() : invalid arg expecting a string\n"); ctxt->error = XPATH_INVALID_TYPE; if (obj2 != NULL) xmlXPathFreeObject(obj2); return; } obj = valuePop(ctxt); if (obj->stringval == NULL) { valuePush(ctxt, xmlXPathNewNodeSet(NULL)); } else { if (obj2 != NULL) { /* obj2 should be ordered in document order !!!!! */ base = xmlNodeGetBase(obj2->nodesetval->nodeTab[0]->doc, obj->nodesetval->nodeTab[0]); } else { base = xmlNodeGetBase(ctxt->context->doc, ctxt->context->node); } URI = xmlBuildURI(obj->stringval, base); if (base != NULL) xmlFree(base); if (URI == NULL) { valuePush(ctxt, xmlXPathNewNodeSet(NULL)); } else { xsltTransformContextPtr tctxt; tctxt = (xsltTransformContextPtr) ctxt->context->extra; if (tctxt == NULL) { xsltGenericError(xsltGenericErrorContext, "document() : internal error tctxt == NULL\n"); valuePush(ctxt, xmlXPathNewNodeSet(NULL)); } else { doc = xsltLoadDocument(tctxt, URI); if (doc == NULL) valuePush(ctxt, xmlXPathNewNodeSet(NULL)); else { /* TODO: use XPointer of HTML location for fragment ID */ /* pbm #xxx can lead to location sets, not nodesets :-) */ valuePush(ctxt, xmlXPathNewNodeSet((xmlNodePtr) doc->doc)); } } xmlFree(URI); } } xmlXPathFreeObject(obj); if (obj2 != NULL) xmlXPathFreeObject(obj2);}
int k;
int k, ti, tj;
gtp_dragon_data(char *s, int id){ int i = -1; int j = -1; int m, n; if (sscanf(s, " %*c") >= 0 && !gtp_decode_coord(s, &i, &j)) return gtp_failure(id, "invalid coordinate"); examine_position(EMPTY, EXAMINE_DRAGONS); gtp_printid(id, GTP_SUCCESS); if (ON_BOARD2(i, j) && BOARD(i, j) == EMPTY) gtp_mprintf("%m empty\n", i, j); else { for (m = 0; m < board_size; m++) for (n = 0; n < board_size; n++) if ((m == i && n == j) || (i == -1 && BOARD(m, n) != EMPTY && dragon[m][n].origin == POS(m, n))) { int k; struct dragon_data *d = &dragon[m][n]; struct dragon_data2 *d2 = &(dragon2[d->id]); gtp_print_vertex(m, n); gtp_printf(":\n"); gtp_printf("color %s\n", color_to_string(d->color)); gtp_mprintf("origin %m\n", I(d->origin), J(d->origin)); gtp_printf("size %d\n", d->size); gtp_printf("effective_size %.2f\n", d->effective_size); gtp_printf("heyes %d\n", d2->heyes); gtp_mprintf("heye %m\n", I(d2->heye), J(d2->heye)); gtp_printf("genus %d\n", d2->genus); gtp_printf("escape_route %d\n", d2->escape_route); /* We would like to use the %1m format used in gprintf * but this is not implemented in gtp_mprintf. Moreover adding this * format would entail including liberty.h in gtp.c, which we * don't want to do in order to maintain independence of the * GNU Go internals. Therefore we use the I and J macros here. */ gtp_mprintf("lunch %m\n", I(d2->lunch), J(d2->lunch)); gtp_printf("status %s\n", status_to_string(d->status)); gtp_printf("owl_status %s\n", status_to_string(d->owl_status)); gtp_printf("matcher_status %s\n", status_to_string(d->matcher_status)); gtp_printf("owl_threat_status %s\n", status_to_string(d->owl_threat_status)); gtp_mprintf("owl_attack %m\n", I(d->owl_attack_point), J(d->owl_attack_point)); gtp_printf("owl_attack_certain: %s\n", (d->owl_attack_certain) ? "YES" : "NO"); gtp_mprintf("owl_2nd_attack %m\n", I(d->owl_second_attack_point), J(d->owl_second_attack_point)); gtp_mprintf("owl_defend %m\n", I(d->owl_defense_point), J(d->owl_defense_point)); gtp_printf("owl_defend_certain: %s\n", (d->owl_defend_certain) ? "YES" : "NO"); gtp_mprintf("owl_2nd_defend %m\n", I(d->owl_second_defense_point), J(d->owl_second_defense_point)); gtp_printf("semeai %d\n", d2->semeai); gtp_printf("semeai_margin_of_safety %d\n", d2->semeai_margin_of_safety); gtp_printf("neighbors: "); for (k = 0; k < DRAGON2(m, n).neighbors; k++) gtp_mprintf("%m ", I(DRAGON(DRAGON2(m, n).adjacent[k]).origin), J(DRAGON(DRAGON2(m, n).adjacent[k]).origin)); gtp_printf("\n"); gtp_printf("moyo: %d\n", DRAGON2(m, n).moyo); gtp_printf("safety: %s\n", safety_to_string(DRAGON2(m, n).safety)); } } gtp_printf("\n"); return GTP_OK;}
gtp_printf("strings: "); for (ti = 0; ti < board_size; ti++) for (tj = 0; tj < board_size; tj++) if (worm[ti][tj].origin == POS(ti, tj) && dragon[ti][tj].origin == dragon[m][n].origin) gtp_mprintf("%m ", ti, tj); gtp_printf("\n");
gtp_dragon_data(char *s, int id){ int i = -1; int j = -1; int m, n; if (sscanf(s, " %*c") >= 0 && !gtp_decode_coord(s, &i, &j)) return gtp_failure(id, "invalid coordinate"); examine_position(EMPTY, EXAMINE_DRAGONS); gtp_printid(id, GTP_SUCCESS); if (ON_BOARD2(i, j) && BOARD(i, j) == EMPTY) gtp_mprintf("%m empty\n", i, j); else { for (m = 0; m < board_size; m++) for (n = 0; n < board_size; n++) if ((m == i && n == j) || (i == -1 && BOARD(m, n) != EMPTY && dragon[m][n].origin == POS(m, n))) { int k; struct dragon_data *d = &dragon[m][n]; struct dragon_data2 *d2 = &(dragon2[d->id]); gtp_print_vertex(m, n); gtp_printf(":\n"); gtp_printf("color %s\n", color_to_string(d->color)); gtp_mprintf("origin %m\n", I(d->origin), J(d->origin)); gtp_printf("size %d\n", d->size); gtp_printf("effective_size %.2f\n", d->effective_size); gtp_printf("heyes %d\n", d2->heyes); gtp_mprintf("heye %m\n", I(d2->heye), J(d2->heye)); gtp_printf("genus %d\n", d2->genus); gtp_printf("escape_route %d\n", d2->escape_route); /* We would like to use the %1m format used in gprintf * but this is not implemented in gtp_mprintf. Moreover adding this * format would entail including liberty.h in gtp.c, which we * don't want to do in order to maintain independence of the * GNU Go internals. Therefore we use the I and J macros here. */ gtp_mprintf("lunch %m\n", I(d2->lunch), J(d2->lunch)); gtp_printf("status %s\n", status_to_string(d->status)); gtp_printf("owl_status %s\n", status_to_string(d->owl_status)); gtp_printf("matcher_status %s\n", status_to_string(d->matcher_status)); gtp_printf("owl_threat_status %s\n", status_to_string(d->owl_threat_status)); gtp_mprintf("owl_attack %m\n", I(d->owl_attack_point), J(d->owl_attack_point)); gtp_printf("owl_attack_certain: %s\n", (d->owl_attack_certain) ? "YES" : "NO"); gtp_mprintf("owl_2nd_attack %m\n", I(d->owl_second_attack_point), J(d->owl_second_attack_point)); gtp_mprintf("owl_defend %m\n", I(d->owl_defense_point), J(d->owl_defense_point)); gtp_printf("owl_defend_certain: %s\n", (d->owl_defend_certain) ? "YES" : "NO"); gtp_mprintf("owl_2nd_defend %m\n", I(d->owl_second_defense_point), J(d->owl_second_defense_point)); gtp_printf("semeai %d\n", d2->semeai); gtp_printf("semeai_margin_of_safety %d\n", d2->semeai_margin_of_safety); gtp_printf("neighbors: "); for (k = 0; k < DRAGON2(m, n).neighbors; k++) gtp_mprintf("%m ", I(DRAGON(DRAGON2(m, n).adjacent[k]).origin), J(DRAGON(DRAGON2(m, n).adjacent[k]).origin)); gtp_printf("\n"); gtp_printf("moyo: %d\n", DRAGON2(m, n).moyo); gtp_printf("safety: %s\n", safety_to_string(DRAGON2(m, n).safety)); } } gtp_printf("\n"); return GTP_OK;}
int kdemain( int argc, char **argv )
int KDE_EXPORT kdemain( int argc, char **argv )
int kdemain( int argc, char **argv ) { // KApplication is necessary to use other ioslaves putenv(strdup("SESSION_MANAGER=")); KCmdLineArgs::init(argc, argv, "kio_media", 0, 0, 0, 0); KCmdLineArgs::addCmdLineOptions( options ); KApplication app( false, false ); // We want to be anonymous even if we use DCOP app.dcopClient()->attach(); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); MediaProtocol slave( args->arg(0), args->arg(1), args->arg(2) ); slave.dispatchLoop(); return 0; }
fprintf(stderr, klocale->translate("usage: kcmlocale [-init | language])\n"));
fprintf(stderr, klocale->translate("usage: kcmlocale [-init | language]\n"));
KLocaleApplication::KLocaleApplication(int &argc, char **argv, const char *name) : KControlApplication(argc, argv, name){ locale = 0; if (runGUI()) { if (!pages || pages->contains("language")) addPage(locale = new KLocaleConfig(dialog, "locale"), klocale->translate("&Locale"), "locale.html"); if (locale) dialog->show(); else { fprintf(stderr, klocale->translate("usage: kcmlocale [-init | language])\n")); justInit = TRUE; } }}
if (arg1) setPhPoint_tFields(env, arg1, lparg1);
JNIEXPORT jobject JNICALL OS_NATIVE(PfExtentText__Lorg_eclipse_swt_internal_photon_PhRect_1t_2Lorg_eclipse_swt_internal_photon_PhPoint_1t_2III) (JNIEnv *env, jclass that, jobject arg0, jobject arg1, jint arg2, jint arg3, jint arg4){ PhRect_t _arg0, *lparg0=NULL; PhPoint_t _arg1, *lparg1=NULL; jobject rc; NATIVE_ENTER(env, that, "PfExtentText__Lorg_eclipse_swt_internal_photon_PhRect_1t_2Lorg_eclipse_swt_internal_photon_PhPoint_1t_2III\n") if (arg0) lparg0 = getPhRect_tFields(env, arg0, &_arg0); if (arg1) lparg1 = getPhPoint_tFields(env, arg1, &_arg1); rc = (jobject)PfExtentText(lparg0, lparg1, (const char *)arg2, (const char *)arg3, arg4); if (arg0) setPhRect_tFields(env, arg0, lparg0); if (arg1) setPhPoint_tFields(env, arg1, lparg1); NATIVE_EXIT(env, that, "PfExtentText__Lorg_eclipse_swt_internal_photon_PhRect_1t_2Lorg_eclipse_swt_internal_photon_PhPoint_1t_2III\n") return rc;}
if (arg1) setPhPoint_tFields(env, arg1, lparg1); if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0); if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
JNIEXPORT jobject JNICALL OS_NATIVE(PfExtentText__Lorg_eclipse_swt_internal_photon_PhRect_1t_2Lorg_eclipse_swt_internal_photon_PhPoint_1t_2_3B_3BI) (JNIEnv *env, jclass that, jobject arg0, jobject arg1, jbyteArray arg2, jbyteArray arg3, jint arg4){ PhRect_t _arg0, *lparg0=NULL; PhPoint_t _arg1, *lparg1=NULL; jbyte *lparg2=NULL; jbyte *lparg3=NULL; jobject rc; NATIVE_ENTER(env, that, "PfExtentText__Lorg_eclipse_swt_internal_photon_PhRect_1t_2Lorg_eclipse_swt_internal_photon_PhPoint_1t_2_3B_3BI\n") if (arg0) lparg0 = getPhRect_tFields(env, arg0, &_arg0); if (arg1) lparg1 = getPhPoint_tFields(env, arg1, &_arg1); if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL); if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL); rc = (jobject)PfExtentText(lparg0, lparg1, (const char *)lparg2, (const char *)lparg3, arg4); if (arg0) setPhRect_tFields(env, arg0, lparg0); if (arg1) setPhPoint_tFields(env, arg1, lparg1); if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0); if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0); NATIVE_EXIT(env, that, "PfExtentText__Lorg_eclipse_swt_internal_photon_PhRect_1t_2Lorg_eclipse_swt_internal_photon_PhPoint_1t_2_3B_3BI\n") return rc;}
if (arg1) setPhPoint_tFields(env, arg1, lparg1); if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0); if (arg3) (*env)->ReleaseCharArrayElements(env, arg3, lparg3, 0);
JNIEXPORT jobject JNICALL OS_NATIVE(PfExtentWideText) (JNIEnv *env, jclass that, jobject arg0, jobject arg1, jbyteArray arg2, jcharArray arg3, jint arg4){ PhRect_t _arg0, *lparg0=NULL; PhPoint_t _arg1, *lparg1=NULL; jbyte *lparg2=NULL; jchar *lparg3=NULL; jobject rc; NATIVE_ENTER(env, that, "PfExtentWideText\n") if (arg0) lparg0 = getPhRect_tFields(env, arg0, &_arg0); if (arg1) lparg1 = getPhPoint_tFields(env, arg1, &_arg1); if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL); if (arg3) lparg3 = (*env)->GetCharArrayElements(env, arg3, NULL); rc = (jobject)PfExtentWideText(lparg0, lparg1, (const char *)lparg2, (const uint16_t *)lparg3, arg4); if (arg0) setPhRect_tFields(env, arg0, lparg0); if (arg1) setPhPoint_tFields(env, arg1, lparg1); if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0); if (arg3) (*env)->ReleaseCharArrayElements(env, arg3, lparg3, 0); NATIVE_EXIT(env, that, "PfExtentWideText\n") return rc;}
if (arg1) setFontQueryInfoFields(env, arg1, lparg1);
JNIEXPORT jint JNICALL OS_NATIVE(PfQueryFontInfo) (JNIEnv *env, jclass that, jbyteArray arg0, jobject arg1){ jbyte *lparg0=NULL; FontQueryInfo _arg1, *lparg1=NULL; jint rc; NATIVE_ENTER(env, that, "PfQueryFontInfo\n") if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL); if (arg1) lparg1 = getFontQueryInfoFields(env, arg1, &_arg1); rc = (jint)PfQueryFontInfo((const char *)lparg0, (FontQueryInfo *)lparg1); if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0); if (arg1) setFontQueryInfoFields(env, arg1, lparg1); NATIVE_EXIT(env, that, "PfQueryFontInfo\n") return rc;}
if (arg1) setPhPoint_tFields(env, arg1, lparg1);
JNIEXPORT jint JNICALL OS_NATIVE(PgDrawArc) (JNIEnv *env, jclass that, jobject arg0, jobject arg1, jint arg2, jint arg3, jint arg4){ PhPoint_t _arg0, *lparg0=NULL; PhPoint_t _arg1, *lparg1=NULL; jint rc; NATIVE_ENTER(env, that, "PgDrawArc\n") if (arg0) lparg0 = getPhPoint_tFields(env, arg0, &_arg0); if (arg1) lparg1 = getPhPoint_tFields(env, arg1, &_arg1); rc = (jint)PgDrawArc(lparg0, lparg1, arg2, arg3, arg4); if (arg0) setPhPoint_tFields(env, arg0, lparg0); if (arg1) setPhPoint_tFields(env, arg1, lparg1); NATIVE_EXIT(env, that, "PgDrawArc\n") return rc;}
if (arg3) setPhDim_tFields(env, arg3, lparg3);
JNIEXPORT jint JNICALL OS_NATIVE(PgDrawBitmap) (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jobject arg3, jint arg4, jint arg5){ PhPoint_t _arg2, *lparg2=NULL; PhDim_t _arg3, *lparg3=NULL; jint rc; NATIVE_ENTER(env, that, "PgDrawBitmap\n") if (arg2) lparg2 = getPhPoint_tFields(env, arg2, &_arg2); if (arg3) lparg3 = getPhDim_tFields(env, arg3, &_arg3); rc = (jint)PgDrawBitmap((void const *)arg0, (int)arg1, (PhPoint_t *)lparg2, (PhPoint_t *)lparg3, (int)arg4, (long)arg5); if (arg2) setPhPoint_tFields(env, arg2, lparg2); if (arg3) setPhDim_tFields(env, arg3, lparg3); NATIVE_EXIT(env, that, "PgDrawBitmap\n") return rc;}
if (arg1) setPhPoint_tFields(env, arg1, lparg1);
JNIEXPORT jint JNICALL OS_NATIVE(PgDrawEllipse) (JNIEnv *env, jclass that, jobject arg0, jobject arg1, jint arg2){ PhPoint_t _arg0, *lparg0=NULL; PhPoint_t _arg1, *lparg1=NULL; jint rc; NATIVE_ENTER(env, that, "PgDrawEllipse\n") if (arg0) lparg0 = getPhPoint_tFields(env, arg0, &_arg0); if (arg1) lparg1 = getPhPoint_tFields(env, arg1, &_arg1); rc = (jint)PgDrawEllipse(lparg0, lparg1, arg2); if (arg0) setPhPoint_tFields(env, arg0, lparg0); if (arg1) setPhPoint_tFields(env, arg1, lparg1); NATIVE_EXIT(env, that, "PgDrawEllipse\n") return rc;}
if (arg1) setPhPoint_tFields(env, arg1, lparg1); if (arg10) (*env)->ReleaseByteArrayElements(env, arg10, lparg10, 0);
JNIEXPORT jint JNICALL OS_NATIVE(PgDrawGradient) (JNIEnv *env, jclass that, jobject arg0, jobject arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9, jbyteArray arg10){ PhPoint_t _arg0, *lparg0=NULL; PhPoint_t _arg1, *lparg1=NULL; jbyte *lparg10=NULL; jint rc; NATIVE_ENTER(env, that, "PgDrawGradient\n") if (arg0) lparg0 = getPhPoint_tFields(env, arg0, &_arg0); if (arg1) lparg1 = getPhPoint_tFields(env, arg1, &_arg1); if (arg10) lparg10 = (*env)->GetByteArrayElements(env, arg10, NULL); rc = (jint)PgDrawGradient(lparg0, lparg1, arg2, arg3, arg4, (PgColor_t)arg5, (PgColor_t)arg6, (PgColor_t)arg7, (PgColor_t)arg8, arg9, (unsigned char *)lparg10); if (arg0) setPhPoint_tFields(env, arg0, lparg0); if (arg1) setPhPoint_tFields(env, arg1, lparg1); if (arg10) (*env)->ReleaseByteArrayElements(env, arg10, lparg10, 0); NATIVE_EXIT(env, that, "PgDrawGradient\n") return rc;}
if (arg3) setPhDim_tFields(env, arg3, lparg3);
JNIEXPORT jint JNICALL OS_NATIVE(PgDrawImage) (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jobject arg3, jint arg4, jint arg5){ PhPoint_t _arg2, *lparg2=NULL; PhDim_t _arg3, *lparg3=NULL; jint rc; NATIVE_ENTER(env, that, "PgDrawImage\n") if (arg2) lparg2 = getPhPoint_tFields(env, arg2, &_arg2); if (arg3) lparg3 = getPhDim_tFields(env, arg3, &_arg3); rc = (jint)PgDrawImage((void const *)arg0, arg1, lparg2, lparg3, arg4, arg5); if (arg2) setPhPoint_tFields(env, arg2, lparg2); if (arg3) setPhDim_tFields(env, arg3, lparg3); NATIVE_EXIT(env, that, "PgDrawImage\n") return rc;}
if (arg2) setPhRect_tFields(env, arg2, lparg2);
JNIEXPORT jint JNICALL OS_NATIVE(PgDrawMultiTextArea) (JNIEnv *env, jclass that, jbyteArray arg0, jint arg1, jobject arg2, jint arg3, jint arg4, jint arg5){ jbyte *lparg0=NULL; PhRect_t _arg2, *lparg2=NULL; jint rc; NATIVE_ENTER(env, that, "PgDrawMultiTextArea\n") if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL); if (arg2) lparg2 = getPhRect_tFields(env, arg2, &_arg2); rc = (jint)PgDrawMultiTextArea((char *)lparg0, arg1, lparg2, arg3, arg4, arg5); if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0); if (arg2) setPhRect_tFields(env, arg2, lparg2); NATIVE_EXIT(env, that, "PgDrawMultiTextArea\n") return rc;}
if (arg2) setPhRect_tFields(env, arg2, lparg2);
JNIEXPORT jint JNICALL OS_NATIVE(PgDrawPhImageRectmx) (JNIEnv *env, jclass that, jobject arg0, jint arg1, jobject arg2, jint arg3){ PhPoint_t _arg0, *lparg0=NULL; PhRect_t _arg2, *lparg2=NULL; jint rc; NATIVE_ENTER(env, that, "PgDrawPhImageRectmx\n") if (arg0) lparg0 = getPhPoint_tFields(env, arg0, &_arg0); if (arg2) lparg2 = getPhRect_tFields(env, arg2, &_arg2); rc = (jint)PgDrawPhImageRectmx(lparg0, (PhImage_t const *)arg1, lparg2, arg3); if (arg0) setPhPoint_tFields(env, arg0, lparg0); if (arg2) setPhRect_tFields(env, arg2, lparg2); NATIVE_EXIT(env, that, "PgDrawPhImageRectmx\n") return rc;}
if (arg2) setPhPoint_tFields(env, arg2, lparg2);
JNIEXPORT jint JNICALL OS_NATIVE(PgDrawPolygon) (JNIEnv *env, jclass that, jshortArray arg0, jint arg1, jobject arg2, jint arg3){ jshort *lparg0=NULL; PhPoint_t _arg2, *lparg2=NULL; jint rc; NATIVE_ENTER(env, that, "PgDrawPolygon\n") if (arg0) lparg0 = (*env)->GetShortArrayElements(env, arg0, NULL); if (arg2) lparg2 = getPhPoint_tFields(env, arg2, &_arg2); rc = (jint)PgDrawPolygon((PhPoint_t const *)lparg0, arg1, (PhPoint_t const *)lparg2, arg3); if (arg0) (*env)->ReleaseShortArrayElements(env, arg0, lparg0, 0); if (arg2) setPhPoint_tFields(env, arg2, lparg2); NATIVE_EXIT(env, that, "PgDrawPolygon\n") return rc;}
if (arg1) setPhPoint_tFields(env, arg1, lparg1);
JNIEXPORT jint JNICALL OS_NATIVE(PgDrawRoundRect) (JNIEnv *env, jclass that, jobject arg0, jobject arg1, jint arg2){ PhRect_t _arg0, *lparg0=NULL; PhPoint_t _arg1, *lparg1=NULL; jint rc; NATIVE_ENTER(env, that, "PgDrawRoundRect\n") if (arg0) lparg0 = getPhRect_tFields(env, arg0, &_arg0); if (arg1) lparg1 = getPhPoint_tFields(env, arg1, &_arg1); rc = (jint)PgDrawRoundRect((PhRect_t const *)lparg0, (PhPoint_t const *)lparg1, arg2); if (arg0) setPhRect_tFields(env, arg0, lparg0); if (arg1) setPhPoint_tFields(env, arg1, lparg1); NATIVE_EXIT(env, that, "PgDrawRoundRect\n") return rc;}